@vuu-ui/vuu-table-extras 0.6.18 → 0.6.19-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/esm/index.js CHANGED
@@ -1,2 +1,2850 @@
1
- var qt=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var m=(n,e,t)=>(qt(n,e,"read from private field"),t?t.call(n):e.get(n)),U=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},te=(n,e,t,s)=>(qt(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t);import{DOWN1 as pn,DOWN2 as hn,metadataKeys as cn,registerComponent as fn,UP1 as dn,UP2 as mn}from"@vuu-ui/vuu-utils";import gn from"classnames";import{useEffect as rn,useRef as on}from"react";import{isTypeDescriptor as ln}from"@vuu-ui/vuu-utils";import{getMovingValueDirection as an,isValidNumber as Kt}from"@vuu-ui/vuu-utils";var un=[void 0,void 0,void 0,void 0];function es(n,e,t){var h;let s=on(),[i,o,r,l]=s.current||un,{type:a}=t,u=ln(a)?(h=a.formatting)==null?void 0:h.decimals:void 0,c=n===i&&Kt(e)&&Kt(o)&&t===r?an(e,l,o,u):"";return rn(()=>{s.current=[n,e,t,c]}),c}import{jsx as kn,jsxs as En}from"react/jsx-runtime";var xn=String.fromCharCode(11014),Cn=String.fromCharCode(11015),{KEY:bn}=cn,Je="vuuBackgroundCell",de={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},yn=n=>{if(typeof n=="string")return de.BackgroundOnly;if(n){let{renderer:e}=n;return e&&e.flashStyle||de.BackgroundOnly}},vn=({column:n,row:e})=>{let{key:t,type:s,valueFormatter:i}=n,o=e[t],r=yn(s),l=es(e[bn],o,n),a=r===de.ArrowOnly||r===de.ArrowBackground?l===dn||l===mn?xn:l===pn||l===hn?Cn:null:null,u=l?" "+l:"",c=gn(Je,u,{[`${Je}-arrowOnly`]:r===de.ArrowOnly,[`${Je}-arrowBackground`]:r===de.ArrowBackground});return En("div",{className:c,tabIndex:-1,children:[kn("div",{className:`${Je}-flasher`,children:a}),i(e[n.key])]})};fn("background",vn,"cell-renderer",{serverDataType:["long","int","double"]});import{autocompletion as Yn,defaultKeymap as Zn,EditorState as jn,EditorView as As,ensureSyntaxTree as Jn,keymap as Lt,minimalSetup as qn,startCompletion as Ts}from"@vuu-ui/vuu-codemirror";import{createEl as Ds}from"@vuu-ui/vuu-utils";import{useEffect as Kn,useMemo as ei,useRef as Qt}from"react";import{LanguageSupport as Dn,LRLanguage as Nn,styleTags as Rn,tags as rt}from"@vuu-ui/vuu-codemirror";var On=0,Qe=class{constructor(e,t){this.from=e,this.to=t}},S=class{constructor(e={}){this.id=On++,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=Q.match(e)),t=>{let s=e(t);return s===void 0?null:[this,s]}}};S.closedBy=new S({deserialize:n=>n.split(" ")});S.openedBy=new S({deserialize:n=>n.split(" ")});S.group=new S({deserialize:n=>n.split(" ")});S.contextHash=new S({perNode:!0});S.lookAhead=new S({perNode:!0});S.mounted=new S({perNode:!0});var Sn=Object.create(null),Q=class{constructor(e,t,s,i=0){this.name=e,this.props=t,this.id=s,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):Sn,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Q(e.name||"",t,e.id,s);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(i)),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 i}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(S.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 i of s.split(" "))t[i]=e[s];return s=>{for(let i=s.prop(S.group),o=-1;o<(i?i.length:0);o++){let r=t[o<0?s.name:i[o]];if(r)return r}}}};Q.none=new Q("",Object.create(null),0,8);var me=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 i=null;for(let o of e){let r=o(s);r&&(i||(i=Object.assign({},s.props)),i[r[0].id]=r[1])}t.push(i?new Q(s.name,i,s.id,s.flags):s)}return new me(t)}},qe=new WeakMap,ts=new WeakMap,R;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(R||(R={}));var I=class{constructor(e,t,s,i,o){if(this.type=e,this.children=t,this.positions=s,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);for(let[r,l]of o)this.props[typeof r=="number"?r:r.id]=l}}toString(){let e=this.prop(S.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let s of this.children){let i=s.toString();i&&(t&&(t+=","),t+=i)}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 xe(this.topNode,e)}cursorAt(e,t=0,s=0){let i=qe.get(this)||this.topNode,o=new xe(i);return o.moveTo(e,t),qe.set(this,o._tree),o}get topNode(){return new G(this,0,0,null)}resolve(e,t=0){let s=ge(qe.get(this)||this.topNode,e,t,!1);return qe.set(this,s),s}resolveInner(e,t=0){let s=ge(ts.get(this)||this.topNode,e,t,!0);return ts.set(this,s),s}iterate(e){let{enter:t,leave:s,from:i=0,to:o=this.length}=e;for(let r=this.cursor((e.mode||0)|R.IncludeAnonymous);;){let l=!1;if(r.from<=o&&r.to>=i&&(r.type.isAnonymous||t(r)!==!1)){if(r.firstChild())continue;l=!0}for(;l&&s&&!r.type.isAnonymous&&s(r),!r.nextSibling();){if(!r.parent())return;l=!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:gt(Q.none,this.children,this.positions,0,this.children.length,0,this.length,(t,s,i)=>new I(this.type,t,s,i,this.propValues),e.makeTree||((t,s,i)=>new I(Q.none,t,s,i)))}static build(e){return Pn(e)}};I.empty=new I(Q.none,[],[],0);var ze=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 ze(this.buffer,this.index)}},Y=class{constructor(e,t,s){this.buffer=e,this.length=t,this.set=s}get type(){return Q.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],i=this.set.types[t],o=i.name;if(/\W/.test(o)&&!i.isError&&(o=JSON.stringify(o)),e+=4,s==e)return o;let r=[];for(;e<s;)r.push(this.childString(e)),e=this.buffer[e+3];return o+"("+r.join(",")+")"}findChild(e,t,s,i,o){let{buffer:r}=this,l=-1;for(let a=e;a!=t&&!(ns(o,i,r[a+1],r[a+2])&&(l=a,s>0));a=r[a+3]);return l}slice(e,t,s){let i=this.buffer,o=new Uint16Array(t-e),r=0;for(let l=e,a=0;l<t;){o[a++]=i[l++],o[a++]=i[l++]-s;let u=o[a++]=i[l++]-s;o[a++]=i[l++]-e,r=Math.max(r,u)}return new Y(o,r,this.set)}};function ns(n,e,t,s){switch(n){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 is(n,e){let t=n.childBefore(e);for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(n=t,t=s.prevSibling):t=s}return n}function ge(n,e,t,s){for(var i;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let r=!s&&n instanceof G&&n.index<0?null:n.parent;if(!r)return n;n=r}let o=s?0:R.IgnoreOverlays;if(s)for(let r=n,l=r.parent;l;r=l,l=r.parent)r instanceof G&&r.index<0&&((i=l.enter(e,t,o))===null||i===void 0?void 0:i.from)!=r.from&&(n=l);for(;;){let r=n.enter(e,t,o);if(!r)return n;n=r}}var G=class{constructor(e,t,s,i){this._tree=e,this.from=t,this.index=s,this._parent=i}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,i,o=0){for(let r=this;;){for(let{children:l,positions:a}=r._tree,u=t>0?l.length:-1;e!=u;e+=t){let c=l[e],h=a[e]+r.from;if(ns(i,s,h,h+c.length)){if(c instanceof Y){if(o&R.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,s-h,i);if(d>-1)return new W(new ft(r,c,e,h),null,d)}else if(o&R.IncludeAnonymous||!c.type.isAnonymous||mt(c)){let d;if(!(o&R.IgnoreMounts)&&c.props&&(d=c.prop(S.mounted))&&!d.overlay)return new G(d.tree,h,e,r);let p=new G(c,h,e,r);return o&R.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,s,i)}}}if(o&R.IncludeAnonymous||!r.type.isAnonymous||(r.index>=0?e=r.index+t:e=t<0?-1:r._parent._tree.children.length,r=r._parent,!r))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 i;if(!(s&R.IgnoreOverlays)&&(i=this._tree.prop(S.mounted))&&i.overlay){let o=e-this.from;for(let{from:r,to:l}of i.overlay)if((t>0?r<=o:r<o)&&(t<0?l>=o:l>o))return new G(i.tree,i.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 xe(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return ge(this,e,t,!1)}resolveInner(e,t=0){return ge(this,e,t,!0)}enterUnfinishedNodesBefore(e){return is(this,e)}getChild(e,t=null,s=null){let i=et(this,e,t,s);return i.length?i[0]:null}getChildren(e,t=null,s=null){return et(this,e,t,s)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return tt(this,e)}};function et(n,e,t,s){let i=n.cursor(),o=[];if(!i.firstChild())return o;if(t!=null){for(;!i.type.is(t);)if(!i.nextSibling())return o}for(;;){if(s!=null&&i.type.is(s))return o;if(i.type.is(e)&&o.push(i.node),!i.nextSibling())return s==null?o:[]}}function tt(n,e,t=e.length-1){for(let s=n.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 ft=class{constructor(e,t,s,i){this.parent=e,this.buffer=t,this.index=s,this.start=i}},W=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:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,s);return o<0?null:new W(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&R.ExcludeBuffers)return null;let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new W(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 W(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 W(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new xe(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:s}=this.context,i=this.index+4,o=s.buffer[this.index+3];if(o>i){let r=s.buffer[this.index+1];e.push(s.slice(i,o,r)),t.push(0)}return new I(this.type,e,t,this.to-this.from)}resolve(e,t=0){return ge(this,e,t,!1)}resolveInner(e,t=0){return ge(this,e,t,!0)}enterUnfinishedNodesBefore(e){return is(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,s=null){let i=et(this,e,t,s);return i.length?i[0]:null}getChildren(e,t=null,s=null){return et(this,e,t,s)}get node(){return this}matchContext(e){return tt(this,e)}},xe=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 G)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:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=s+i.buffer[e+1],this.to=s+i.buffer[e+2],!0}yield(e){return e?e instanceof G?(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:i}=this.buffer,o=i.findChild(this.index+4,i.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&R.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&R.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&R.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 i=s<0?0:this.stack[s]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(s<0?t.buffer.length:t.buffer[this.stack[s]+3]))return this.yieldBuf(i)}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:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(i.buffer.buffer[o+3]<this.index)return!1;({index:t,parent:s}=i)}else({index:t,_parent:s}=this._tree);for(;s;{index:t,_parent:s}=s)if(t>-1)for(let o=t+e,r=e<0?-1:s._tree.children.length;o!=r;o+=e){let l=s._tree.children[o];if(this.mode&R.IncludeAnonymous||l instanceof Y||!l.type.isAnonymous||mt(l))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 i=this.index,o=this.stack.length;o>=0;){for(let r=e;r;r=r._parent)if(r.index==i){if(i==this.index)return r;t=r,s=o+1;break e}i=this.stack[--o]}for(let i=s;i<this.stack.length;i++)t=new W(this.buffer,t,this.stack[i]);return this.bufferNode=new W(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let s=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){s++;continue}this.type.isAnonymous||(i=!0)}for(;i&&t&&t(this),i=this.type.isAnonymous,!this.nextSibling();){if(!s)return;this.parent(),s--,i=!0}}}matchContext(e){if(!this.buffer)return tt(this.node,e);let{buffer:t}=this.buffer,{types:s}=t.set;for(let i=e.length-1,o=this.stack.length-1;i>=0;o--){if(o<0)return tt(this.node,e,i);let r=s[t.buffer[this.stack[o]]];if(!r.isAnonymous){if(e[i]&&e[i]!=r.name)return!1;i--}}return!0}};function mt(n){return n.children.some(e=>e instanceof Y||!e.type.isAnonymous||mt(e))}function Pn(n){var e;let{buffer:t,nodeSet:s,maxBufferLength:i=1024,reused:o=[],minRepeatType:r=s.types.length}=n,l=Array.isArray(t)?new ze(t,t.length):t,a=s.types,u=0,c=0;function h(k,y,C,E,N){let{id:O,start:v,end:A,size:L}=l,M=c;for(;L<0;)if(l.next(),L==-1){let ee=o[O];C.push(ee),E.push(v-k);return}else if(L==-3){u=O;return}else if(L==-4){c=O;return}else throw new RangeError(`Unrecognized record size: ${L}`);let ce=a[O],K,X,jt=v-k;if(A-v<=i&&(X=x(l.pos-y,N))){let ee=new Uint16Array(X.size-X.skip),$=l.pos-X.size,V=ee.length;for(;l.pos>$;)V=g(X.start,ee,V);K=new Y(ee,A-X.start,s),jt=X.start-k}else{let ee=l.pos-L;l.next();let $=[],V=[],ne=O>=r?O:-1,fe=0,je=A;for(;l.pos>ee;)ne>=0&&l.id==ne&&l.size>=0?(l.end<=je-i&&(p($,V,v,fe,l.end,je,ne,M),fe=$.length,je=l.end),l.next()):h(v,ee,$,V,ne);if(ne>=0&&fe>0&&fe<$.length&&p($,V,v,fe,v,je,ne,M),$.reverse(),V.reverse(),ne>-1&&fe>0){let Jt=d(ce);K=gt(ce,$,V,0,$.length,0,A-v,Jt,Jt)}else K=f(ce,$,V,A-v,M-A)}C.push(K),E.push(jt)}function d(k){return(y,C,E)=>{let N=0,O=y.length-1,v,A;if(O>=0&&(v=y[O])instanceof I){if(!O&&v.type==k&&v.length==E)return v;(A=v.prop(S.lookAhead))&&(N=C[O]+v.length+A)}return f(k,y,C,E,N)}}function p(k,y,C,E,N,O,v,A){let L=[],M=[];for(;k.length>E;)L.push(k.pop()),M.push(y.pop()+C-N);k.push(f(s.types[v],L,M,O-N,A-O)),y.push(N-C)}function f(k,y,C,E,N=0,O){if(u){let v=[S.contextHash,u];O=O?[v].concat(O):[v]}if(N>25){let v=[S.lookAhead,N];O=O?[v].concat(O):[v]}return new I(k,y,C,E,O)}function x(k,y){let C=l.fork(),E=0,N=0,O=0,v=C.end-i,A={size:0,start:0,skip:0};e:for(let L=C.pos-k;C.pos>L;){let M=C.size;if(C.id==y&&M>=0){A.size=E,A.start=N,A.skip=O,O+=4,E+=4,C.next();continue}let ce=C.pos-M;if(M<0||ce<L||C.start<v)break;let K=C.id>=r?4:0,X=C.start;for(C.next();C.pos>ce;){if(C.size<0)if(C.size==-3)K+=4;else break e;else C.id>=r&&(K+=4);C.next()}N=X,E+=M,O+=K}return(y<0||E==k)&&(A.size=E,A.start=N,A.skip=O),A.size>4?A:void 0}function g(k,y,C){let{id:E,start:N,end:O,size:v}=l;if(l.next(),v>=0&&E<r){let A=C;if(v>4){let L=l.pos-(v-4);for(;l.pos>L;)C=g(k,y,C)}y[--C]=A,y[--C]=O-k,y[--C]=N-k,y[--C]=E}else v==-3?u=E:v==-4&&(c=E);return C}let P=[],T=[];for(;l.pos>0;)h(n.start||0,n.bufferStart||0,P,T,-1);let w=(e=n.length)!==null&&e!==void 0?e:P.length?T[0]+P[0].length:0;return new I(a[n.topID],P.reverse(),T.reverse(),w)}var ss=new WeakMap;function Ke(n,e){if(!n.isAnonymous||e instanceof Y||e.type!=n)return 1;let t=ss.get(e);if(t==null){t=1;for(let s of e.children){if(s.type!=n||!(s instanceof I)){t=1;break}t+=Ke(n,s)}ss.set(e,t)}return t}function gt(n,e,t,s,i,o,r,l,a){let u=0;for(let f=s;f<i;f++)u+=Ke(n,e[f]);let c=Math.ceil(u*1.5/8),h=[],d=[];function p(f,x,g,P,T){for(let w=g;w<P;){let k=w,y=x[w],C=Ke(n,f[w]);for(w++;w<P;w++){let E=Ke(n,f[w]);if(C+E>=c)break;C+=E}if(w==k+1){if(C>c){let E=f[k];p(E.children,E.positions,0,E.children.length,x[k]+T);continue}h.push(f[k])}else{let E=x[w-1]+f[w-1].length-y;h.push(gt(n,f,x,k,w,y,E,null,a))}d.push(y+T-o)}}return p(e,t,s,i,0),(l||a)(h,d,r)}var st=class{startParse(e,t,s){return typeof e=="string"&&(e=new dt(e)),s=s?s.length?s.map(i=>new Qe(i.from,i.to)):[new Qe(0,0)]:[new Qe(0,e.length)],this.createParse(e,t||[],s)}parse(e,t,s){let i=this.startParse(e,t,s);for(;;){let o=i.advance();if(o)return o}}},dt=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 qr=new S({perNode:!0});var be=class{constructor(e,t,s,i,o,r,l,a,u,c=0,h){this.p=e,this.stack=t,this.state=s,this.reducePos=i,this.pos=o,this.score=r,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=h}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 i=e.parser.context;return new be(e,[],t,s,s,0,[],0,i?new nt(i,i.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,i=e&65535,{parser:o}=this.p,r=o.dynamicPrecedence(i);if(r&&(this.score+=r),s==0){this.pushState(o.getGoto(this.state,i,!0),this.reducePos),i<o.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(s-1)*3-(e&262144?6:0),a=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-a;u>=2e3&&!(!((t=this.p.parser.nodeSet.types[i])===null||t===void 0)&&t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=u));let c=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-c;if(i<o.minRepeatTerm||e&131072){let d=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,d,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let d=this.stack[l-3];this.state=o.getGoto(d,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,a)}storeNode(e,t,s,i=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let r=this,l=this.buffer.length;if(l==0&&r.parent&&(l=r.bufferBase-r.parent.bufferBase,r=r.parent),l>0&&r.buffer[l-4]==0&&r.buffer[l-1]>-1){if(t==s)return;if(r.buffer[l-2]>=t){r.buffer[l-2]=s;return}}}if(!o||this.pos==s)this.buffer.push(e,t,s,i);else{let r=this.buffer.length;if(r>0&&this.buffer[r-4]!=0)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4);this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=s,this.buffer[r+3]=i}}shift(e,t,s){let i=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=s,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,s,4);else{let o=e,{parser:r}=this.p;(s>this.pos||t<=r.maxNode)&&(this.pos=s,r.stateFlag(o,1)||(this.reducePos=s)),this.pushState(o,i),this.shiftContext(t,i),t<=r.maxNode&&this.buffer.push(t,i,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 i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(s,i,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),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new be(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,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 Ct(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 i=[];for(let o=0,r;o<t.length;o+=2)(r=t[o+1])!=this.state&&this.p.parser.hasAction(r,e)&&i.push(t[o],r);if(this.stack.length<120)for(let o=0;i.length<4<<1&&o<t.length;o+=2){let r=t[o+1];i.some((l,a)=>a&1&&l==r)||i.push(t[o],r)}t=i}let s=[];for(let i=0;i<t.length&&s.length<4;i+=2){let o=t[i+1];if(o==this.state)continue;let r=this.split();r.pushState(o,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(t[i],this.pos),r.score-=200,s.push(r)}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,i=e&65535,o=this.stack.length-s*3;if(o<0||t.getGoto(this.stack[o],i,!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 nt(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()}},nt=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},rs;(function(n){n[n.Insert=200]="Insert",n[n.Delete=190]="Delete",n[n.Reduce=100]="Reduce",n[n.MaxNext=4]="MaxNext",n[n.MaxInsertStackDepth=300]="MaxInsertStackDepth",n[n.DampenInsertStackDepth=120]="DampenInsertStackDepth",n[n.MinBigReduction=2e3]="MinBigReduction"})(rs||(rs={}));var Ct=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 i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}},ye=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 ye(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 ye(this.stack,this.pos,this.index)}};function Me(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let s=0,i=0;s<n.length;){let o=0;for(;;){let r=n.charCodeAt(s++),l=!1;if(r==126){o=65535;break}r>=92&&r--,r>=34&&r--;let a=r-32;if(a>=46&&(a-=46,l=!0),o+=a,l)break;o*=46}t?t[i++]=o:t=new e(o)}return t}var Ce=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},os=new Ce,bt=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=os,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,i=this.rangeIndex,o=this.pos+e;for(;o<s.from;){if(!i)return null;let r=this.ranges[--i];o-=s.from-r.to,s=r}for(;t<0?o>s.to:o>=s.to;){if(i==this.ranges.length-1)return null;let r=this.ranges[++i];o+=r.from-s.to,s=r}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,i;if(t>=0&&t<this.chunk.length)s=this.pos+e,i=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)i=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let r=this.rangeIndex,l=this.range;for(;l.to<=s;)l=this.ranges[++r];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-s)),i=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),i}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=os,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 i of this.ranges){if(i.from>=t)break;i.to>e&&(s+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return s}},se=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:s}=t.p;fs(this.data,e,t,this.id,s.data,s.tokenPrecTable)}};se.prototype.contextual=se.prototype.fallback=se.prototype.extend=!1;var yt=class{constructor(e,t,s){this.precTable=t,this.elseToken=s,this.data=typeof e=="string"?Me(e):e}token(e,t){let s=e.pos,i;for(;i=e.pos,fs(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(i+1,e.token)}i>s&&(e.reset(s,e.token),e.acceptToken(this.elseToken,i-s))}};yt.prototype.contextual=se.prototype.fallback=se.prototype.extend=!1;function fs(n,e,t,s,i,o){let r=0,l=1<<s,{dialect:a}=t.p.parser;e:for(;l&n[r];){let u=n[r+1];for(let p=r+3;p<u;p+=2)if((n[p+1]&l)>0){let f=n[p];if(a.allows(f)&&(e.token.value==-1||e.token.value==f||An(f,e.token.value,i,o))){e.acceptToken(f);break}}let c=e.next,h=0,d=n[r+2];if(e.next<0&&d>h&&n[u+d*3-3]==65535&&n[u+d*3-3]==65535){r=n[u+d*3-1];continue e}for(;h<d;){let p=h+d>>1,f=u+p+(p<<1),x=n[f],g=n[f+1]||65536;if(c<x)d=p;else if(c>=g)h=p+1;else{r=n[f+2],e.advance();continue e}}break}}function ls(n,e,t){for(let s=e,i;(i=n[s])!=65535;s++)if(i==t)return s-e;return-1}function An(n,e,t,s){let i=ls(t,s,e);return i<0||ls(t,s,n)<i}var _=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),xt=null,as;(function(n){n[n.Margin=25]="Margin"})(as||(as={}));function us(n,e,t){let s=n.cursor(R.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(n.length,Math.max(s.from+1,e+25));if(t<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return t<0?0:n.length}}var vt=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?us(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?us(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],i=this.index[t];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let o=s.children[i],r=this.start[t]+s.positions[i];if(r>e)return this.nextStart=r,null;if(o instanceof I){if(r==e){if(r<this.safeFrom)return null;let l=r+o.length;if(l<=this.safeTo){let a=o.prop(S.lookAhead);if(!a||l+a<this.fragment.to)return o}}this.index[t]++,r+o.length>=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(r),this.index.push(0))}else this.index[t]++,this.nextStart=r+o.length}}},kt=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(s=>new Ce)}getActions(e){let t=0,s=null,{parser:i}=e.p,{tokenizers:o}=i,r=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;u<o.length;u++){if(!(1<<u&r))continue;let c=o[u],h=this.tokens[u];if(!(s&&!c.fallback)&&((c.contextual||h.start!=e.pos||h.mask!=r||h.context!=l)&&(this.updateCachedToken(h,c,e),h.mask=r,h.context=l),h.lookAhead>h.end+25&&(a=Math.max(h.lookAhead,a)),h.value!=0)){let d=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!c.extend&&(s=h,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!s&&e.pos==this.stream.end&&(s=new Ce,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 Ce,{pos:s,p:i}=e;return t.start=s,t.end=Math.min(s+1,i.stream.end),t.value=s==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,s){let i=this.stream.clipPos(s.pos);if(t.token(this.stream.reset(i,e),s),e.value>-1){let{parser:o}=s.p;for(let r=0;r<o.specialized.length;r++)if(o.specialized[r]==e.value){let l=o.specializers[r](this.stream.read(e.start,e.end),s);if(l>=0&&s.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,s,i){for(let o=0;o<i;o+=3)if(this.actions[o]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=s,i}addActions(e,t,s,i){let{state:o}=e,{parser:r}=e.p,{data:l}=r;for(let a=0;a<2;a++)for(let u=r.stateSlot(o,a?2:1);;u+=3){if(l[u]==65535)if(l[u+1]==1)u=Z(l,u+2);else{i==0&&l[u+1]==2&&(i=this.putAction(Z(l,u+2),t,s,i));break}l[u]==t&&(i=this.putAction(Z(l,u+1),t,s,i))}return i}},ps;(function(n){n[n.Distance=5]="Distance",n[n.MaxRemainingPerStep=3]="MaxRemainingPerStep",n[n.MinBufferLengthPrune=500]="MinBufferLengthPrune",n[n.ForceReduceLimit=10]="ForceReduceLimit",n[n.CutDepth=15e3]="CutDepth",n[n.CutTo=9e3]="CutTo",n[n.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",n[n.MaxStackCount=12]="MaxStackCount"})(ps||(ps={}));var Et=class{constructor(e,t,s,i){this.parser=e,this.input=t,this.ranges=i,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 bt(t,i),this.tokens=new kt(e,this.stream),this.topTerm=e.top[1];let{from:o}=i[0];this.stacks=[be.start(this,e.top[0],o)],this.fragments=s.length&&this.stream.end-o>e.bufferLength*4?new vt(s,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,s=this.stacks=[],i,o;if(this.bigReductionCount>300&&e.length==1){let[r]=e;for(;r.forceReduce()&&r.stack.length&&r.stack[r.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<e.length;r++){let l=e[r];for(;;){if(this.tokens.mainToken=null,l.pos>t)s.push(l);else{if(this.advanceStack(l,s,e))continue;{i||(i=[],o=[]),i.push(l);let a=this.tokens.getMainToken(l);o.push(a.value,a.end)}}break}}if(!s.length){let r=i&&Tn(i);if(r)return this.stackToTree(r);if(this.parser.strict)throw _&&i&&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&&i){let r=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,o,s);if(r)return this.stackToTree(r.forceAll())}if(this.recovering){let r=this.recovering==1?1:this.recovering*3;if(s.length>r)for(s.sort((l,a)=>a.score-l.score);s.length>r;)s.pop();s.some(l=>l.reducePos>t)&&this.recovering--}else if(s.length>1){e:for(let r=0;r<s.length-1;r++){let l=s[r];for(let a=r+1;a<s.length;a++){let u=s[a];if(l.sameState(u)||l.buffer.length>500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)s.splice(a--,1);else{s.splice(r--,1);continue e}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let r=1;r<s.length;r++)s[r].pos<this.minStackPos&&(this.minStackPos=s[r].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 i=e.pos,{parser:o}=this,r=_?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let h=this.fragments.nodeAt(i);h;){let d=this.parser.nodeSet.types[h.type.id]==h.type?o.getGoto(e.state,h.type.id):-1;if(d>-1&&h.length&&(!u||(h.prop(S.contextHash)||0)==c))return e.useNode(h,d),_&&console.log(r+this.stackID(e)+` (via reuse of ${o.getName(h.type.id)})`),!0;if(!(h instanceof I)||h.children.length==0||h.positions[0]>0)break;let p=h.children[0];if(p instanceof I&&h.positions[0]==0)h=p;else break}}let l=o.stateSlot(e.state,4);if(l>0)return e.reduce(l),_&&console.log(r+this.stackID(e)+` (via always-reduce ${o.getName(l&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;u<a.length;){let c=a[u++],h=a[u++],d=a[u++],p=u==a.length||!s,f=p?e:e.split();if(f.apply(c,h,d),_&&console.log(r+this.stackID(f)+` (via ${c&65536?`reduce of ${o.getName(c&65535)}`:"shift"} for ${o.getName(h)} @ ${i}${f==e?"":", split"})`),p)return!0;f.pos>i?t.push(f):s.push(f)}return!1}advanceFully(e,t){let s=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>s)return hs(e,t),!0}}runRecovery(e,t,s){let i=null,o=!1;for(let r=0;r<e.length;r++){let l=e[r],a=t[r<<1],u=t[(r<<1)+1],c=_?this.stackID(l)+" -> ":"";if(l.deadEnd&&(o||(o=!0,l.restart(),_&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,s))))continue;let h=l.split(),d=c;for(let p=0;h.forceReduce()&&p<10&&(_&&console.log(d+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,s));p++)_&&(d=this.stackID(h)+" -> ");for(let p of l.recoverByInsert(a))_&&console.log(c+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,s);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),_&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),hs(l,s)):(!i||i.score<l.score)&&(i=l)}return i}stackToTree(e){return e.close(),I.build({buffer:ye.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=(xt||(xt=new WeakMap)).get(e);return t||xt.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function hs(n,e){for(let t=0;t<e.length;t++){let s=e[t];if(s.pos==n.pos&&s.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}var Ot=class{constructor(e,t,s){this.source=e,this.flags=t,this.disabled=s}allows(e){return!this.disabled||this.disabled[e]==0}};var ie=class extends st{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 l=0;l<e.repeatNodeCount;l++)t.push("");let s=Object.keys(e.topRules).map(l=>e.topRules[l][1]),i=[];for(let l=0;l<t.length;l++)i.push([]);function o(l,a,u){i[l].push([a,a.deserialize(String(u))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=S[a]);for(let u=1;u<l.length;){let c=l[u++];if(c>=0)o(c,a,l[u++]);else{let h=l[u+-c];for(let d=-c;d>0;d--)o(l[u++],a,h);u++}}}this.nodeSet=new me(t.map((l,a)=>Q.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:s.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let r=Me(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(cs),this.states=Me(e.states,Uint32Array),this.data=Me(e.stateData),this.goto=Me(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new se(r,l):l),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 i=new Et(this,e,t,s);for(let o of this.wrappers)i=o(i,e,t,s);return i}getGoto(e,t,s=!1){let i=this.goto;if(t>=i[0])return-1;for(let o=i[t+1];;){let r=i[o++],l=r&1,a=i[o++];if(l&&s)return a;for(let u=o+(r>>1);o<u;o++)if(i[o]==e)return a;if(l)return-1}}hasAction(e,t){let s=this.data;for(let i=0;i<2;i++)for(let o=this.stateSlot(e,i?2:1),r;;o+=3){if((r=s[o])==65535)if(s[o+1]==1)r=s[o=Z(s,o+2)];else{if(s[o+1]==2)return Z(s,o+2);break}if(r==t||r==0)return Z(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=Z(this.data,s+2);else return!1;if(t==Z(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=Z(this.data,s+2);else break;if(!(this.data[s+2]&1)){let i=this.data[s+1];t.some((o,r)=>r&1&&o==i)||t.push(this.data[s],i)}}return t}configure(e){let t=Object.assign(Object.create(ie.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 i=e.tokenizers.find(o=>o.from==s);return i?i.to:s})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((s,i)=>{let o=e.specializers.find(l=>l.from==s.external);if(!o)return s;let r=Object.assign(Object.assign({},s),{external:o.to});return t.specializers[i]=cs(r),r})),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 r=t.indexOf(o);r>=0&&(s[r]=!0)}let i=null;for(let o=0;o<t.length;o++)if(!s[o])for(let r=this.dialects[t[o]],l;(l=this.data[r++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[l]=1;return new Ot(e,s,i)}static deserialize(e){return new ie(e)}};function Z(n,e){return n[e]|n[e+1]<<16}function Tn(n){let e=null;for(let t of n){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 cs(n){if(n.external){let e=n.extend?1:0;return(t,s)=>n.external(t,s)<<1|e}return n.get}var it=ie.deserialize({version:14,states:"&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",stateData:")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",goto:"#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",nodeNames:"\u26A0 ColumnDefinitionExpression Column Number String True False ParenthesizedExpression OpenBrace CloseBrace ArithmeticExpression Divide Times Plus Minus ConditionalExpression If RelationalExpression RelationalOperator AndCondition OrCondition Comma CallExpression Function ArgList",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:".^~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$jz{$o{|$t|}$y}!O%O!O!P%T!P!Q%c!Q![%h!^!_%s!_!`&Q!`!a&V!c!}&d#R#S&d#T#U&u#U#Y&d#Y#Z(Y#Z#]&d#]#^*j#^#c&d#c#d+f#d#h&d#h#i,b#i#o&d~#USl~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOu~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_OS~~$bP;=`<%l#m~$jOW~~$oOX~~$tO[~~$yO]~~%OOe~~%TO^~~%WP!Q![%Z~%`PR~!Q![%Z~%hOZ~~%mQR~!O!P%Z!Q![%h~%xPr~!_!`%{~&QOt~~&VOp~~&[Pq~!_!`&_~&dOs~P&iSnP!Q![&d!c!}&d#R#S&d#T#o&dR&zUnP!Q![&d!c!}&d#R#S&d#T#b&d#b#c'^#c#o&dR'cUnP!Q![&d!c!}&d#R#S&d#T#W&d#W#X'u#X#o&dR'|SvQnP!Q![&d!c!}&d#R#S&d#T#o&d~(_TnP!Q![&d!c!}&d#R#S&d#T#U(n#U#o&d~(sUnP!Q![&d!c!}&d#R#S&d#T#`&d#`#a)V#a#o&d~)[UnP!Q![&d!c!}&d#R#S&d#T#g&d#g#h)n#h#o&d~)sUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y*V#Y#o&d~*^SU~nP!Q![&d!c!}&d#R#S&d#T#o&d~*oUnP!Q![&d!c!}&d#R#S&d#T#Y&d#Y#Z+R#Z#o&d~+YS`~nP!Q![&d!c!}&d#R#S&d#T#o&dR+kUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g+}#g#o&dR,USwQnP!Q![&d!c!}&d#R#S&d#T#o&d~,gUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g,y#g#o&d~-OUnP!Q![&d!c!}&d#R#S&d#T#i&d#i#j-b#j#o&d~-gUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y-y#Y#o&d~.QST~nP!Q![&d!c!}&d#R#S&d#T#o&d",tokenizers:[0,1],topRules:{ColumnDefinitionExpression:[0,1]},tokenPrec:375});var In=Nn.define({name:"VuuColumnExpression",parser:it.configure({props:[Rn({Function:rt.variableName,String:rt.string,Or:rt.emphasis,Operator:rt.operator})]})}),ds=()=>new Dn(In);var St=class{constructor(e){switch(this.value=e,typeof e){case"boolean":this.type="booleanLiteralExpression";break;case"number":this.type="numberLiteralExpression";break;default:this.type="stringLiteralExpression"}}toJSON(){return{type:this.type,value:this.value}}},Pt=class{constructor(e){this.type="colExpression";this.column=e}toJSON(){return{type:this.type,column:this.column}}},Ue,oe,wt=class{constructor(e="unknown"){U(this,Ue,[{type:"unknown"},{type:"unknown"}]);U(this,oe,void 0);this.type="arithmeticExpression";te(this,oe,e)}get op(){return m(this,oe)}set op(e){te(this,oe,e)}get expressions(){return m(this,Ue)}toJSON(){return{type:this.type,op:m(this,oe),expressions:m(this,Ue)}}};Ue=new WeakMap,oe=new WeakMap;var Oe,At=class{constructor(e){U(this,Oe,[]);this.type="callExpression";this.functionName=e}get expressions(){return m(this,Oe)}get arguments(){return m(this,Oe)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:m(this,Oe).map(e=>{var t;return(t=e.toJSON)==null?void 0:t.call(e)})}}};Oe=new WeakMap;var Ge,Se,ke=class{constructor(){U(this,Ge,[{type:"unknown"},{type:"unknown"}]);U(this,Se,"unknown");this.type="relationalExpression"}get op(){return m(this,Se)}set op(e){te(this,Se,e)}get expressions(){return m(this,Ge)}toJSON(){return{type:this.type,op:m(this,Se),expressions:m(this,Ge)}}};Ge=new WeakMap,Se=new WeakMap;var _e,Pe,Ee=class{constructor(e){U(this,_e,[{type:"unknown"},{type:"unknown"}]);U(this,Pe,void 0);this.type="booleanCondition";te(this,Pe,e)}get op(){return m(this,Pe)}get expressions(){return m(this,_e)}toJSON(){return{type:this.type,op:m(this,Pe),expressions:m(this,_e).map(e=>{var t;return(t=e.toJSON)==null?void 0:t.call(e)})}}};_e=new WeakMap,Pe=new WeakMap;var H,$e=class{constructor(e){U(this,H,void 0);this.type="conditionalExpression";te(this,H,[e?new Ee(e):new ke,{type:"unknown"},{type:"unknown"}])}get expressions(){return m(this,H)}get condition(){return m(this,H)[0]}get truthyExpression(){return m(this,H)[1]}set truthyExpression(e){m(this,H)[1]=e}get falsyExpression(){return m(this,H)[2]}set falsyExpression(e){m(this,H)[2]=e}toJSON(){var e,t,s,i,o;return{type:this.type,condition:(t=(e=this.condition).toJSON)==null?void 0:t.call(e),truthyExpression:this.truthyExpression,falsyExpression:(o=(i=(s=this.falsyExpression)==null?void 0:s.toJSON)==null?void 0:i.call(s))!=null?o:this.falsyExpression}}};H=new WeakMap;var re=n=>n.type==="unknown",ot=n=>n.type==="arithmeticExpression",Bn=n=>n.type==="callExpression",ve=n=>n.type==="conditionalExpression",Fn=n=>n.type==="relationalExpression"||n.type==="booleanCondition";var Ln=n=>n.type==="booleanCondition",Dt=n=>(n==null?void 0:n.type)==="relationalExpression";var z=n=>{if(re(n))return n;if(Dt(n)){let[e,t]=n.expressions;if(F(e))return z(e);if(n.op==="unknown")return n;if(F(t))return z(t)}else if(Fn(n)){let{expressions:e=[]}=n;for(let t of e)if(F(t))return z(t)}else if(ve(n)){let{condition:e,truthyExpression:t,falsyExpression:s}=n;if(F(e))return z(e);if(F(t))return z(t);if(F(s))return z(s)}else if(ot(n)){let{expressions:e=[]}=n;for(let t of e)if(F(t))return z(t)}},lt=(n,e,t)=>{let{expressions:s=[]}=n;if(s.includes(e)){let i=s.indexOf(e);return s.splice(i,1,t),!0}else for(let i of s)if(lt(i,e,t))return!0;return!1},F=n=>re(n)?!0:ve(n)?F(n.condition)||F(n.truthyExpression)||F(n.falsyExpression):Dt(n)||Ln(n)?n.op===void 0||n.expressions.some(e=>F(e)):!1,ms=(n,e)=>{let t=z(n);t?t.expressions?t.expressions.push(e):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},b,le,Tt=class{constructor(){U(this,b,void 0);U(this,le,[])}setCondition(e){if(m(this,b)===void 0)this.addExpression(new $e(e));else if(ve(m(this,b))){if(F(m(this,b).condition)){let t=e?new Ee(e):new ke;this.addExpression(t)}else if(re(m(this,b).truthyExpression))m(this,b).truthyExpression=new $e(e);else if(F(m(this,b).truthyExpression)){let t=e?new Ee(e):new ke;this.addExpression(t)}else if(re(m(this,b).falsyExpression))m(this,b).falsyExpression=new $e(e);else if(F(m(this,b).falsyExpression)){let t=e?new Ee(e):new ke;this.addExpression(t)}}else console.error("setCondition called unexpectedly")}addExpression(e){if(m(this,le).length>0){let t=m(this,le).at(-1);t==null||t.arguments.push(e)}else if(m(this,b)===void 0)te(this,b,e);else if(ot(m(this,b))){let t=z(m(this,b));t&&re(t)&&lt(m(this,b),t,e)}else if(ve(m(this,b))&&F(m(this,b))){let t=z(m(this,b));t&&re(t)?lt(m(this,b),t,e):t&&ms(t,e)}}setFunction(e){let t=new At(e);this.addExpression(t),m(this,le).push(t)}setColumn(e){this.addExpression(new Pt(e))}setArithmeticOp(e){let t=e,s=m(this,b);ot(s)&&(s.op=t)}setRelationalOperator(e){let t=e;if(m(this,b)&&ve(m(this,b))){let s=z(m(this,b));Dt(s)?s.op=t:console.error(`no target expression found (op = ${e})`)}}setValue(e){let t=new St(e);if(m(this,b)===void 0)te(this,b,t);else if(ot(m(this,b)))this.addExpression(t);else if(Bn(m(this,b)))m(this,b).arguments.push(t);else if(ve(m(this,b)))if(F(m(this,b))){let s=z(m(this,b));s&&re(s)?lt(m(this,b),s,t):s&&ms(s,t)}else console.log("what do we do with value, in a complete expression")}closeBrace(){m(this,le).pop()}get expression(){return m(this,b)}toJSON(){var e;return(e=m(this,b))==null?void 0:e.toJSON()}};b=new WeakMap,le=new WeakMap;var gs=(n,e)=>{let t=new Tt,s=n.cursor();do{let{name:i,from:o,to:r}=s;switch(i){case"AndCondition":t.setCondition("and");break;case"OrCondition":t.setCondition("or");break;case"RelationalExpression":t.setCondition();break;case"ArithmeticExpression":t.addExpression(new wt);break;case"Column":{let l=e.substring(o,r);t.setColumn(l)}break;case"Function":{let l=e.substring(o,r);t.setFunction(l)}break;case"Times":case"Divide":case"Plus":case"Minus":{let l=e.substring(o,r);t.setArithmeticOp(l)}break;case"RelationalOperator":{let l=e.substring(o,r);t.setRelationalOperator(l)}break;case"False":case"True":{let l=e.substring(o,r);t.setValue(l==="true")}break;case"String":t.setValue(e.substring(o+1,r-1));break;case"Number":t.setValue(parseFloat(e.substring(o,r)));break;case"CloseBrace":t.closeBrace();break;default:}}while(s.next());return t.toJSON()};var Qn=it.configure({strict:!0}),xs=["Number","String"],Nt=[...xs,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"],Cs=n=>{try{return Qn.parse(n),!0}catch{return!1}},Rt=n=>{let{lastChild:e}=n;for(;e&&!Nt.includes(e.name);)e=e.prevSibling,console.log(e==null?void 0:e.name);return e},bs=n=>{if((n==null?void 0:n.name)==="RelationalExpression"){let{firstChild:e}=n,t=Rt(n);if((e==null?void 0:e.name)==="Column"&&typeof(t==null?void 0:t.name)=="string"&&xs.includes(t.name))return!0}return!1};import{HighlightStyle as zn,syntaxHighlighting as Mn,tags as ys}from"@vuu-ui/vuu-codemirror";var $n=zn.define([{tag:ys.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:ys.comment,color:"green",fontStyle:"italic"}]),vs=Mn($n);import{EditorView as Un}from"@vuu-ui/vuu-codemirror";var ks=Un.theme({"&":{border:"solid 1px var(--salt-container-primary-borderColor)",color:"var(--vuuFilterEditor-color)",backgroundColor:"var(--vuuFilterEditor-background)"},".cm-content":{caretColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-scroller":{fontFamily:"var(--vuuFilterEditor-fontFamily)"},".cm-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",boxShadow:"var(--vuuFilterEditor-tooltipElevation)","&.cm-tooltip-autocomplete > ul":{fontFamily:"var(--vuuFilterEditor-fontFamily)",fontSize:"var(--vuuFilterEditor-fontSize)",maxHeight:"240px"},"&.cm-tooltip-autocomplete > ul > li":{height:"var(--vuuFilterEditor-suggestion-height)",padding:"0 3px",lineHeight:"var(--vuuFilterEditor-suggestion-height)"},"&.cm-tooltip-autocomplete li[aria-selected]":{background:"var(--vuuFilterEditor-suggestion-selectedBackground)",color:"var(--vuuFilterEditor-suggestion-selectedColor)"},"&.cm-tooltip-autocomplete li .cm-completionDetail":{color:"var(--vuuFilterEditor-suggestion-detailColor)"}}},{dark:!1});import{booleanJoinSuggestions as Gn,getNamedParentNode as Es,getPreviousNode as _n,getValue as j,syntaxTree as Wn}from"@vuu-ui/vuu-codemirror";import{useCallback as Os}from"react";var Hn=(n,e)=>e?n.map(t=>{var s;return{...t,apply:typeof t.apply=="function"?t.apply:`${e}${(s=t.apply)!=null?s:t.label}`}}):n,Xn=n=>n===void 0?!1:["Times","Divide","Plus","Minus"].includes(n.name),we=(n,e)=>{var i;let{lastChild:t}=n,{pos:s}=e;for(;t;)if(t.from<s&&Nt.includes(t.name)){if(t.name==="ParenthesizedExpression"){let r=(i=t.firstChild)==null?void 0:i.nextSibling;r&&(t=r)}return t}else t=t.prevSibling},Ss=(n,e)=>{var t;if(n.name==="ArgList"){let s=n.prevSibling;if(s)return j(s,e)}else if(n.name==="OpenBrace"){let s=(t=n.parent)==null?void 0:t.prevSibling;if((s==null?void 0:s.name)==="Function")return j(s,e)}},Ps=(n,e)=>{if(n.name==="RelationalExpression"){let t=Rt(n);if((t==null?void 0:t.name)==="RelationalOperator")return j(t,e)}else{let t=n.prevSibling;if((t==null?void 0:t.name)==="RelationalOperator")return j(t,e)}},Ft=(n,e)=>{var t;if(n.name==="RelationalExpression"){if(((t=n.firstChild)==null?void 0:t.name)==="Column")return j(n.firstChild,e)}else{let s=n.prevSibling;if((s==null?void 0:s.name)==="Column")return j(s,e);if((s==null?void 0:s.name)==="RelationalOperator")return Ft(s,e)}},It=async(n,e,t,s={})=>{let i=await e.getSuggestions(t,s),{startsWith:o=""}=s;return{from:n.pos-o.length,options:i}},Bt=(n,e,t,s,i)=>{let o=we(n,e);switch(console.log(`conditional expression last child ${o==null?void 0:o.name}`),o==null?void 0:o.name){case"If":return It(e,t,"expression",{prefix:"( "});case"OpenBrace":return It(e,t,"expression");case"Condition":return It(e,t,"expression",{prefix:", "});case"CloseBrace":if(s){let r=[{apply:()=>{i==null||i()},label:"Save Expression",boost:10}];return{from:e.pos,options:r}}}},Vn=(n,e)=>{let t=[{apply:()=>{e==null||e()},label:"Save Expression",boost:10}];return{from:n.pos,options:t}},ws=(n,e)=>{let t=Os(async(s,i,o={})=>{let r=await n.getSuggestions(i,o),{startsWith:l=""}=o;return{from:s.pos-l.length,options:r}},[n]);return Os(async s=>{var h,d;let{state:i,pos:o}=s,r=(h=s.matchBefore(/\w*/))!=null?h:{from:0,to:0,text:void 0},a=Wn(i).resolveInner(o,-1),u=i.doc.toString(),c=Cs(u);switch(console.log({nodeBeforeName:a.name}),a.name){case"If":return console.log("conditional expression If"),t(s,"expression",{prefix:"( "});case"Condition":{let p=we(a,s);if((p==null?void 0:p.name)==="Column"){let f=_n(p);if((f==null?void 0:f.name)!=="RelationalOperator")return t(s,"condition-operator",{columnName:j(p,i)});console.log(`Condition last child Column, prev child ${f==null?void 0:f.name}`)}else if((p==null?void 0:p.name)==="RelationalOperator")return t(s,"expression");console.log(`condition last child ${p==null?void 0:p.name}`)}break;case"ConditionalExpression":return Bt(a,s,n);case"RelationalExpression":{if(bs(a))return{from:s.pos,options:Gn.concat({label:", <truthy expression>, <falsy expression>",apply:", "})};{let p=Ps(a,i),f=Ft(a,i);if(p)return t(s,"expression");{let x=await n.getSuggestions("condition-operator",{columnName:f});return{from:s.pos,options:x}}}}break;case"RelationalOperator":return t(s,"expression");case"String":{let p=Ps(a,i),f=Ft(a,i),{from:x,to:g}=a;if(g-x===2&&s.pos===x+1){if(f&&p)return t(s,"columnValue",{columnName:f,operator:p,startsWith:r.text})}else if(g-x>2&&s.pos===g)return t(s,"expression",{prefix:", "});console.log(`we have a string, column is ${f} ${x} ${g}`)}break;case"ArithmeticExpression":{let p=we(a,s);if((p==null?void 0:p.name)==="Column")return t(s,"expression");if(Xn(p)){let f=p.name;return t(s,"column",{operator:f})}}break;case"OpenBrace":{let p=Ss(a,i);return t(s,"expression",{functionName:p})}break;case"ArgList":{let p=Ss(a,i),f=we(a,s),x=(f==null?void 0:f.name)==="OpenBrace"?void 0:",",g=await n.getSuggestions("expression",{functionName:p});return g=x?Hn(g,", "):g,(f==null?void 0:f.name)!=="OpenBrace"&&(f==null?void 0:f.name)!=="Comma"&&(g=[{apply:") ",boost:10,label:"Done - no more arguments"}].concat(g)),{from:s.pos,options:g}}case"Equal":if(u.trim()==="=")return t(s,"expression");break;case"ParenthesizedExpression":case"ColumnDefinitionExpression":if(s.pos===0)return t(s,"expression");{let p=we(a,s);if((p==null?void 0:p.name)==="Column"){if(c){let f=[{apply:()=>{e.current()},label:"Save Expression",boost:10}],x=j(p,i),g=await n.getSuggestions("operator",{columnName:x});return{from:s.pos,options:f.concat(g)}}}else if((p==null?void 0:p.name)==="CallExpression"){if(c){let f=[{apply:()=>{e.current()},label:"Save Expression",boost:10}];return{from:s.pos,options:f}}}else if((p==null?void 0:p.name)==="ArithmeticExpression"){if(c){let f=[{apply:()=>{e.current()},label:"Save Expression",boost:10}],x=we(p,s);if((x==null?void 0:x.name)==="Column"){let g=j(x,i),P=await n.getSuggestions("operator",{columnName:g});f=f.concat(P)}return{from:s.pos,options:f}}}else if((p==null?void 0:p.name)==="ConditionalExpression")return Bt(p,s,n,c,e.current);break}case"Column":if(await n.isPartialMatch("expression",void 0,r.text))return t(s,"expression",{startsWith:r.text});break;case"Comma":{let p=Es(a);if((p==null?void 0:p.name)==="ConditionalExpression")return t(s,"expression")}break;case"CloseBrace":{let p=Es(a);if((p==null?void 0:p.name)==="ConditionalExpression")return Bt(p,s,n,c,e.current);if((p==null?void 0:p.name)==="ArgList"&&c)return Vn(s,e.current);console.log(`does closebrace denote an ARgList or a parenthetised expression ? ${p}`)}break;default:((d=a==null?void 0:a.prevSibling)==null?void 0:d.name)==="FilterClause"&&console.log("looks like we ight be a or|and operator")}},[t,e,n])};var We=n=>{if(n.current==null)throw Error("EditorView not defined");return n.current},ti=()=>"vuuSuggestion",si=()=>console.log("noooop"),ni=n=>"expressionType"in n,ii=n=>{if(ni(n)){let e=Ds("div","expression-type-container"),t=Ds("span","expression-type",n.expressionType);return e.appendChild(t),e}else return null},Ns=({onChange:n,onSubmitExpression:e,suggestionProvider:t})=>{let s=Qt(null),i=Qt(si),o=Qt(),r=ws(t,i),[l,a]=ei(()=>{let u=()=>{let x=We(o),g=x.state.doc.toString(),P=Jn(x.state,x.state.doc.length,5e3);if(P){let T=gs(P,g);return[g,T]}else return["",void 0]},c=()=>{We(o).setState(f())},h=()=>{let[x,g]=u();e==null||e(x,g),c()},d=x=>Lt.of([{key:x,run(){return h(),!0}}]),p=x=>Lt.of([{key:x,run(){return Ts(We(o)),!0}}]),f=()=>jn.create({doc:"",extensions:[qn,Yn({addToOptions:[{render:ii,position:70}],override:[r],optionClass:ti}),ds(),Lt.of(Zn),d("Ctrl-Enter"),p("ArrowDown"),As.updateListener.of(x=>{let g=We(o);if(x.docChanged){Ts(g);let P=g.state.doc.toString();n==null||n(P,void 0)}}),ks,vs]});return i.current=()=>{h(),setTimeout(()=>{We(o).focus()},100)},[f,c]},[r,n,e]);return Kn(()=>{if(!s.current)throw Error("editor not in dom");return o.current=new As({state:l(),parent:s.current}),()=>{var u;(u=o.current)==null||u.destroy()}},[r,l]),{editorRef:s,clearInput:a}};import{jsx as oi}from"react/jsx-runtime";var ri="vuuColumnExpressionInput",Rs=({onChange:n,onSubmitExpression:e,suggestionProvider:t})=>{let{editorRef:s}=Ns({onChange:n,onSubmitExpression:e,suggestionProvider:t});return oi("div",{className:`${ri}`,ref:s})};import{AnnotationType as li,getRelationalOperators as ai,numericOperators as ui,stringOperators as pi,toSuggestions as hi}from"@vuu-ui/vuu-codemirror";import{getTypeaheadParams as ci,useTypeaheadSuggestions as fi}from"@vuu-ui/vuu-data";import{isNumericColumn as Mt,isTextColumn as di}from"@vuu-ui/vuu-utils";import{useCallback as zt,useRef as mi}from"react";var Ae=[{accepts:"string",description:"Returns multiple string values as a single joined string. Arguments may be string literal values, string columns or other string expressions. Non string arguments may also be included, these will be converted to strings.",example:{expression:'concatenate("example", "-test")',result:'"example-test"'},name:"concatenate",params:{description:"( string, string, [ string* ] )"},type:"string"},{accepts:["string","string"],description:"Tests a string value to determine whether it contains a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> contains one or more occurrences of <target subscring>",example:{expression:'contains("Royal Bank of Scotland", "bank")',result:"true"},name:"contains",params:{description:"( string )"},type:"boolean"},{accepts:["string","number"],description:"Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:'left("USD Benchmark Report", 3)',result:'"USD"'},name:"left",params:{count:2,description:"( string, number )"},type:"string"},{accepts:"string",description:"Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",example:{expression:'len("example")',result:"7"},name:"len",params:{description:"(string)"},type:"number"},{accepts:"string",description:"Convert a string value to lowercase. Argument may be a string column or other string expression.",example:{expression:'lower("examPLE")',result:'"example"'},name:"lower",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Convert a string value to uppercase. Argument may be a string column or other string expression.",example:{expression:'upper("example")',result:'"EXAMPLE"'},name:"upper",params:{description:"( string )"},type:"string"},{accepts:["string","number"],description:"Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:"blah",result:"blah"},name:"right",params:{description:"( string )"},type:"string"},{accepts:["string","string","string"],description:"Replace characters within a string. Accepts three arguments: source text, text to replace and replacement text. Returns a copy of <source text> with any occurrences of <text to replace> replaced by <replacement text>",example:{expression:"blah",result:"blah"},name:"replace",params:{description:"( string )"},type:"string"},{accepts:"number",description:"Converts a number to a string.",example:{expression:"blah",result:"blah"},name:"text",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Tests a string value to determine whether it starts with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> starts with <target subscring>.",example:{expression:"blah",result:"blah"},name:"starts",params:{description:"( string )"},type:"boolean"},{accepts:"string",description:"Tests a string value to determine whether it ends with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> ends with <target subscring>.",example:{expression:"blah",result:"blah"},name:"ends",params:{description:"( string )"},type:"boolean"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"min",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"max",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"sum",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"round",params:{description:"( string )"},type:"number"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"or",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"and",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"Return one of two possible result values, depending on the evaluation of a filter expression. If <filterExpression> resolves to true, result is <expression1>, otherwise <expression2>. ",example:{expression:"blah",result:"blah"},name:"if",params:{description:"( filterExpression, expression1, expression 2)"},type:"variable"}];import{createEl as J}from"@vuu-ui/vuu-utils";var Is=({name:n,description:e,example:t,params:s,type:i})=>{let o=J("div","vuuFunctionDoc"),r=J("div","function-heading"),l=J("span","function-name",n),a=J("span","param-list",s.description),u=J("span","function-type",i);r.appendChild(l),r.appendChild(a),r.appendChild(u);let c=J("p",void 0,e);if(o.appendChild(r),o.appendChild(c),t){let h=J("div","example-container","Example:"),d=J("div","example-expression",t.expression),p=J("div","example-result",t.result);h.appendChild(d),h.appendChild(p),o.appendChild(h)}return o};var gi=[],ae=n=>n.map(e=>{var t;return{...e,apply:((t=e.apply)!=null?t:e.label)+" "}}),xi=(n,{functionName:e,operator:t})=>{if(t)return n.filter(Mt);if(e){let s=Ae.find(i=>i.name===e);if(s)switch(s.accepts){case"string":return n.filter(di);case"number":return n.filter(Mt);default:return n}}return n},Bs=(n,e)=>xi(n,e).map(s=>{var o;let i=(o=s.label)!=null?o:s.name;return{apply:e.prefix?`${e.prefix}${i}`:i,label:i,boost:5,type:"column",expressionType:s.serverDataType}}),Ci=[{apply:"* ",boost:2,label:"*",type:"operator"},{apply:"/ ",boost:2,label:"/",type:"operator"},{apply:"+ ",boost:2,label:"+",type:"operator"},{apply:"- ",boost:2,label:"-",type:"operator"}],bi=n=>n===void 0||Mt(n)?Ci:gi,yi=n=>{switch(n.serverDataType){case"string":case"char":return ae(pi);case"int":case"long":case"double":return ae(ui)}},$t=n=>({apply:`${n.name}( `,boost:2,expressionType:n.type,info:()=>Is(n),label:n.name,type:"function"}),vi=n=>{if(n){if(typeof n.accepts=="string")return n.accepts;if(Array.isArray(n.accepts))return n.accepts.every(e=>e==="string")?"string":"any"}return"any"},ki=Ae.map($t),Ei=({functionName:n})=>{if(n){let e=Ae.find(s=>s.name===n),t=vi(e);if(e)switch(t){case"string":return Ae.filter(s=>s.type==="string"||s.type==="variable").map($t);case"number":return Ae.filter(s=>s.type==="number"||s.type==="variable").map($t);default:}}return ki},Oi={},Fs=({columns:n,table:e})=>{let t=zt(l=>l?n.find(a=>a.name===l):void 0,[n]),s=mi(),i=fi(),o=zt(async(l,a=Oi)=>{let{columnName:u,functionName:c,operator:h,prefix:d}=a;switch(l){case"expression":{let p=await ae(Bs(n,{functionName:c,prefix:d})).concat(Ei(a));return s.current=p}case"column":{let p=await Bs(n,a);return s.current=ae(p)}case"operator":{let p=await bi(t(u));return s.current=ae(p)}case"relational-operator":{let p=await ai(t(u));return s.current=ae(p)}case"condition-operator":{let p=t(u);if(p){let f=await yi(p);if(f)return s.current=ae(f)}}break;case"columnValue":if(u&&h){let p=ci(e,u),f=await i(p);return s.current=hi(f,{suffix:""}),s.current.forEach(x=>{x.apply=(g,P,T)=>{let w=new li,k=T+P.label.length+1;g.dispatch({changes:{from:T,insert:P.label},selection:{anchor:k,head:k},annotations:w.of(P)})}}),s.current}break}return[]},[n,t,i,e]),r=zt(async(l,a,u)=>{let{current:c}=s,h=!1,d=c||await o(l,{columnName:a});if(u&&d)for(let p of d){if(p.label===u)return!1;p.label.startsWith(u)&&(h=!0)}return h},[o]);return{getSuggestions:o,isPartialMatch:r}};import{Button as Vt,Panel as Sr}from"@salt-ds/core";import Pr from"classnames";import{useCallback as Ye,useState as nn}from"react";import{List as Qs}from"@heswell/salt-lab";import{Button as He,Text as zs,useIdMemo as Ai}from"@salt-ds/core";import{useCallback as ue,useState as Ti}from"react";import{ListItem as Si}from"@heswell/salt-lab";import Pi from"classnames";import{jsx as Ut,jsxs as wi}from"react/jsx-runtime";var Te="vuuColumnListItem",Ls=({className:n,item:e,label:t,style:s,...i})=>{let o=Pi(Te,n,{[`${Te}-calculated`]:e==null?void 0:e.expression,[`${Te}-hidden`]:e==null?void 0:e.hidden});return wi(Si,{className:o,...i,children:[Ut("span",{className:`${Te}-iconType`}),Ut("label",{className:`${Te}-label`,children:t}),Ut("span",{className:`${Te}-iconHidden`})]})};import{jsx as B,jsxs as Ne}from"react/jsx-runtime";var De="vuuColumnPicker",Di=(n,e)=>n.filter(t=>e.find(s=>s.name===t.name)==null),Ms=({availableColumns:n,id:e,dispatchColumnAction:t,onAddCalculatedColumnClick:s,onSelectionChange:i,chosenColumns:o,selectedColumn:r})=>{let[l,a]=Ti([]),u=Ai(e),c=Di(n,o),h=ue(()=>{l.length>0&&(a([]),t({type:"addColumn",columns:l}))},[t,l]),d=ue(()=>r&&t({type:"removeColumn",column:r}),[r,t]),p=ue(()=>r&&t({type:"moveColumn",column:r,moveBy:-1}),[t,r]),f=ue(()=>r&&t({type:"moveColumn",column:r,moveBy:1}),[t,r]),x=ue((T,w)=>a(w),[]),g=ue((T,w)=>i==null?void 0:i(w),[i]),P=ue((T,w)=>{t({type:"moveColumn",moveFrom:T,moveTo:w})},[t]);return Ne("div",{className:De,id:u,children:[Ne("div",{className:`${De}-listColumn`,children:[B("label",{htmlFor:`available-${u}`,children:B(zs,{as:"h4",children:"Available Columns"})}),B("div",{className:`${De}-listContainer`,style:{flex:1,overflow:"hidden"},children:B(Qs,{borderless:!0,checkable:!1,height:"100%",id:`available-${u}`,itemHeight:24,itemToString:T=>T.name,onSelectionChange:x,selected:l,selectionStrategy:"extended",source:c})}),B("div",{style:{display:"flex",alignItems:"center",flex:"0 0 32px",marginTop:"var(--salt-size-basis-unit)"},children:Ne(He,{onClick:h,disabled:l.length===0,children:["Show",B("span",{"data-icon":"arrow-thin-right",style:{marginLeft:8}})]})})]}),Ne("div",{className:`${De}-listColumn`,children:[B("label",{htmlFor:`selected-${u}`,children:B(zs,{as:"h4",children:"Included Columns"})}),B("div",{className:`${De}-listContainer`,style:{flex:1,overflow:"hidden"},children:B(Qs,{ListItem:Ls,allowDragDrop:!0,borderless:!0,height:"100%",id:`selected-${u}`,itemHeight:24,itemToString:T=>T.name,onMoveListItem:P,onSelectionChange:g,selected:r,style:{flex:1},source:o})}),Ne("div",{style:{alignItems:"center",flex:"0 0 32px",display:"flex",gap:6,marginTop:"var(--salt-size-basis-unit)"},children:[Ne(He,{onClick:d,disabled:r===null,children:[B("span",{"data-icon":"arrow-thin-left",style:{marginRight:8}}),"Hide"]}),B(He,{"aria-label":"Move column up",onClick:p,disabled:r===null||(o==null?void 0:o.indexOf(r))===0,style:{width:28},children:B("span",{"data-icon":"arrow-thin-up"})}),B(He,{"aria-label":"Move column down",onClick:f,disabled:r===null||o.indexOf(r)===o.length-1,style:{width:28},children:B("span",{"data-icon":"arrow-thin-down"})}),B(He,{"aria-label":"Add calculated column",className:`${De}-addCalculatedColumn`,onClick:s,variant:"primary",children:B("span",{"data-icon":"add"})})]})]})]})};import{Stack as Yi}from"@vuu-ui/vuu-layout";import{Checkbox as Zi,FormField as pe,Input as _t,RadioButton as Xe,RadioButtonGroup as Vs,StepperInput as ji}from"@heswell/salt-lab";import{Panel as Ys,Text as Ji}from"@salt-ds/core";import qi from"classnames";import{useCallback as Ie,useState as Ki}from"react";import{getRegisteredCellRenderers as Mi}from"@vuu-ui/vuu-utils";import{Dropdown as $i}from"@heswell/salt-lab";import{Panel as Ui}from"@salt-ds/core";import Ws from"classnames";import{useMemo as Gi}from"react";import{FormField as Ni,StepperInput as Ri,Switch as $s}from"@heswell/salt-lab";import{Text as Ii}from"@salt-ds/core";import{useCallback as at}from"react";import{Fragment as Us,jsx as Re,jsxs as Li}from"react/jsx-runtime";var Bi={alignOnDecimals:!1,decimals:4,zeroPad:!1},Fi=(n,e)=>{let t=typeof n=="object"&&n.formatting?n.formatting:{};return["alignOnDecimals","decimals","zeroPad"].reduce((i,o)=>t[o]!==void 0?{...i,[o]:t[o]}:(e==null?void 0:e[o])!==void 0?{...i,[o]:e[o]}:i,Bi)},Gs=({column:n,dispatchColumnAction:e})=>{let{decimals:t,alignOnDecimals:s,zeroPad:i}=Fi(n==null?void 0:n.type),o=at(u=>e({type:"updateColumnTypeFormatting",column:n,...u}),[n,e]),r=at(u=>o({decimals:parseInt(u.toString(),10)}),[o]),l=at((u,c)=>o({alignOnDecimals:c}),[o]),a=at((u,c)=>o({zeroPad:c}),[o]);switch(n.serverDataType){case"double":return Li(Us,{children:[Re(Ni,{label:"No of Decimals",labelPlacement:"top",children:Re(Ri,{value:t,onChange:r})}),Re($s,{checked:s,label:"Align on decimals",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:l}),Re($s,{checked:i,label:"Zero pad",LabelProps:{className:"vuuColumnPanelSwitch"},onChange:a})]});case"long":case"int":return Re(Us,{children:Re(Ii,{children:"Work in progress"})});default:return null}};import{Fragment as Qi,jsx as zi}from"react/jsx-runtime";var _s=({column:n,dispatchColumnAction:e})=>zi(Qi,{children:"String"});import{Fragment as Xi,jsx as ut,jsxs as Vi}from"react/jsx-runtime";var Gt="vuuColumnTypePanel",_i=["Default Renderer (int, long)"],Wi=["Default Renderer (double)"],Hs=["Default Renderer (string)"],Hi=n=>{let t=Mi(n.serverDataType).map(s=>s.name);switch(console.log({customRendererNames:t}),n.serverDataType){case"char":case"string":return Hs;case"int":case"long":return _i;case"double":return Wi.concat(t);default:return Hs}},Xs=({className:n,column:e,dispatchColumnAction:t,...s})=>{let i=Gi(()=>{switch(e.serverDataType){case"double":case"int":case"long":return ut(Gs,{column:e,dispatchColumnAction:t});default:return ut(_s,{column:e,dispatchColumnAction:t})}},[e,t]),{serverDataType:o="string"}=e,r=Hi(e);return Vi(Xi,{children:[ut($i,{className:Ws(`${Gt}-renderer`),fullWidth:!0,selected:r[0],source:r}),ut(Ui,{...s,className:Ws(Gt,n,`${Gt}-${o}`),children:i})]})};import{jsx as D,jsxs as Be}from"react/jsx-runtime";var Zs="vuuColumnSettingsPanel",er={className:"salt-density-high"},js=()=>null,Js=({column:n,dispatchColumnAction:e,style:t,...s})=>{var d,p,f,x;let[i,o]=Ki(0),r=Ie(g=>e({type:"updateColumnProp",column:n,...g}),[n,e]),l=Ie(g=>r({align:g.target.value}),[r]),a=Ie(g=>r({pin:g.target.value}),[r]),u=Ie((g,P)=>r({hidden:P}),[r]),c=Ie((g,P)=>r({label:P}),[r]),h=Ie(g=>r({width:parseInt(g.toString(),10)}),[r]);return Be("div",{className:Zs,...s,style:{...t},children:[D(Ji,{as:"h4",children:"Column Settings"}),Be(Yi,{active:i,showTabs:!0,className:qi(`${Zs}-columnTabs`),onTabSelectionChanged:o,TabstripProps:er,children:[Be(Ys,{title:"Column",children:[D(pe,{label:"Hidden",labelPlacement:"left",children:D(Zi,{checked:n.hidden===!0,onChange:u})}),D(pe,{label:"Label",labelPlacement:"left",children:D(_t,{value:(d=n.label)!=null?d:n.name,onChange:c})}),D(pe,{label:"Width",labelPlacement:"left",children:D(ji,{value:(p=n.width)!=null?p:100,onChange:h})}),D(pe,{label:"Align",labelPlacement:"left",ActivationIndicatorComponent:js,children:Be(Vs,{"aria-label":"Column Align",value:(f=n.align)!=null?f:"left",legend:"Align",onChange:l,children:[D(Xe,{label:"Left",value:"left"}),D(Xe,{label:"Right",value:"right"})]})}),D(pe,{label:"Pin Column",labelPlacement:"left",ActivationIndicatorComponent:js,children:Be(Vs,{"aria-label":"Pin Column",value:(x=n.pin)!=null?x:"",legend:"Pin Column",onChange:a,children:[D(Xe,{label:"Do not pin",value:""}),D(Xe,{label:"Left",value:"left"}),D(Xe,{label:"Right",value:"right"})]})})]}),D(Xs,{column:n,dispatchColumnAction:e,title:"Data Cell"}),Be(Ys,{title:"Vuu",variant:"secondary",children:[D(pe,{label:"Name",labelPlacement:"top",readOnly:!0,variant:"secondary",children:D(_t,{value:n.name})}),D(pe,{label:"Vuu type",labelPlacement:"top",readOnly:!0,variant:"secondary",children:D(_t,{value:n.serverDataType})})]})]})]})};import{FormField as qs,RadioButton as Wt,RadioButtonGroup as tr,StepperInput as sr}from"@heswell/salt-lab";import{Panel as nr,Text as ir}from"@salt-ds/core";import{useCallback as Ht}from"react";import{jsx as he,jsxs as Xt}from"react/jsx-runtime";var rr="vuuGridSettingsPanel",or=()=>null,Ks=({config:n,dispatchColumnAction:e,style:t,...s})=>{var l;let i=Ht(a=>e({type:"updateGridSettings",...a}),[e]),o=Ht(a=>i({columnFormatHeader:a.target.value}),[i]),r=Ht(a=>i({columnDefaultWidth:parseInt(a.toString(),10)}),[i]);return console.log(`GridSettingsPanel ${JSON.stringify(n.columns,null,2)}`),Xt("div",{className:rr,...s,style:{...t},children:[he(ir,{as:"h4",children:"Grid Settings"}),Xt(nr,{children:[he(qs,{label:"Format column labels",labelPlacement:"left",ActivationIndicatorComponent:or,children:Xt(tr,{"aria-label":"Format column labels",value:n.columnFormatHeader,legend:"Format column labels",onChange:o,children:[he(Wt,{label:"No Formatting",value:void 0}),he(Wt,{label:"Capitalize",value:"capitalize"}),he(Wt,{label:"Uppercase",value:"uppercase"})]})}),he(qs,{label:"Default Column Width",labelPlacement:"left",children:he(sr,{value:(l=n.columnDefaultWidth)!=null?l:100,onChange:r})})]})]})};import{useReducer as lr}from"react";import{moveItem as ar}from"@heswell/salt-lab";import{fromServerDataType as ur}from"@vuu-ui/vuu-utils";var pr=(n,e)=>{switch(console.log(`gridSettingsReducer ${e.type}`),e.type){case"addColumn":return hr(n,e);case"addCalculatedColumn":return cr(n,e);case"moveColumn":return dr(n,e);case"removeColumn":return fr(n,e);case"updateColumn":return n;case"updateColumnProp":return mr(n,e);case"updateGridSettings":return gr(n,e);case"updateColumnTypeFormatting":return xr(n,e);default:return n}},en=n=>{let[e,t]=lr(pr,n);return{gridSettings:e,dispatchColumnAction:t}};function hr(n,{column:e,columns:t,index:s=-1}){let{columns:i}=n;if(s===-1){if(Array.isArray(t))return{...n,columns:i.concat(t)};if(e)return{...n,columns:i.concat(e)}}return n}function cr(n,{columnName:e,columnType:t,expression:s}){let{columns:i}=n,o={name:e,expression:s,serverDataType:t};return{...n,columns:i.concat(o)}}function fr(n,{column:e}){let{columns:t}=n;return{...n,columns:t.filter(s=>s.name!==e.name)}}function dr(n,{column:e,moveBy:t,moveFrom:s,moveTo:i}){let{columns:o}=n;if(e&&typeof t=="number"){let r=o.indexOf(e),l=o.slice(),[a]=l.splice(r,1);return l.splice(r+t,0,a),{...n,columns:l}}else return typeof s=="number"&&typeof i=="number"?{...n,columns:ar(o,s,i)}:n}function mr(n,{align:e,column:t,hidden:s,label:i,width:o}){let{columns:r}=n;return(e==="left"||e==="right")&&(r=Ve(r,{...t,align:e})),typeof s=="boolean"&&(r=Ve(r,{...t,hidden:s})),typeof i=="string"&&(r=Ve(r,{...t,label:i})),typeof o=="number"&&(r=Ve(r,{...t,width:o})),{...n,columns:r}}function gr(n,{columnFormatHeader:e}){return{...n,columnFormatHeader:e!=null?e:n.columnFormatHeader}}function xr(n,{alignOnDecimals:e,column:t,decimals:s,zeroPad:i}){let{columns:o}=n;if(o.find(l=>l.name===t.name)){let{serverDataType:l="string",type:a=ur(l)}=t,u=typeof a=="string"?{name:a}:{...a};return typeof e=="boolean"&&(u.formatting={...u.formatting,alignOnDecimals:e}),typeof s=="number"&&(u.formatting={...u.formatting,decimals:s}),typeof i=="boolean"&&(u.formatting={...u.formatting,zeroPad:i}),{...n,columns:Ve(o,{...t,type:u})}}else return n}function Ve(n,e){return n.map(t=>t.name===e.name?e:t)}import{Stack as wr}from"@vuu-ui/vuu-layout";import{FormField as Cr,Input as br}from"@heswell/salt-lab";import{Button as yr,Panel as vr,Text as kr}from"@salt-ds/core";import{useCallback as pt,useRef as Er,useState as tn}from"react";import{jsx as Fe,jsxs as Or}from"react/jsx-runtime";var sn=({columns:n,dispatchColumnAction:e,table:t})=>{let[s,i]=tn(""),[,o]=tn(),r=Er(""),l=Fs({columns:n,table:t}),a=pt(d=>{let{value:p}=d.target;i(p)},[]),u=pt(d=>{r.current=d},[]),c=pt((d,p)=>{console.log({source:d}),o(p)},[]),h=pt(()=>{r.current&&(console.log(`save expression ${JSON.stringify(r.current,null,2)}`),e({type:"addCalculatedColumn",columnName:s,expression:r.current,columnType:"string"}))},[s,e]);return Or(vr,{className:"vuuCalculatedColumnPanel",title:"Define Computed Column",children:[Fe(kr,{styleAs:"h4",children:"Define Computed Column"}),Fe(Cr,{label:"Column Name",labelPlacement:"left",children:Fe(br,{value:s,onChange:a})}),Fe(Rs,{onChange:u,onSubmitExpression:c,suggestionProvider:l}),Fe("div",{style:{marginTop:12},children:Fe(yr,{onClick:h,children:"Add Column"})})]})};import{jsx as q,jsxs as ct}from"react/jsx-runtime";var ht="vuuDatagridSettingsPanel",Ar=()=>{},Tr=["table-settings","column-chooser","column-settings","define-column"],Dr=(n,e)=>Tr[e],mu=({availableColumns:n,className:e,gridConfig:t,onCancel:s,onConfigChange:i,...o})=>{var k;console.log("DatagridSettingsPanel render");let[r,l]=nn(0),{gridSettings:a,dispatchColumnAction:u}=en(t),[c,h]=nn(null),d=Ye(y=>{h(y?y.name:null)},[]),p=Ye((y,C=!1)=>{console.log("1) DataGridSettingsPanel fire onConfigChange"),i==null||i(a,C)},[a,i]),f=Ye(y=>{l(y)},[]),x=Ye(y=>p(y,!0),[p]),g=c===null?null:(k=a.columns.find(y=>y.name===c))!=null?k:null,P={activeTabIndex:r,enableRenameTab:!1,orientation:"vertical"},T=Ye(()=>l(3),[]),w=r===2?"right":void 0;return ct("div",{...o,className:Pr(ht,e),children:[ct(wr,{TabstripProps:P,className:`${ht}-stack`,getTabIcon:Dr,getTabLabel:Ar,active:r===2?1:r,onTabSelectionChanged:f,showTabs:!0,children:[q(Ks,{config:a,dispatchColumnAction:u}),ct("div",{className:`${ht}-columnPanels`,"data-align":w,children:[q(Ms,{availableColumns:n,chosenColumns:a.columns,dispatchColumnAction:u,onSelectionChange:d,onAddCalculatedColumnClick:T,selectedColumn:g}),g===null?q(Sr,{className:"vuuColumnSettingsPanel",children:"Select a column"}):q(Js,{column:g,dispatchColumnAction:u,style:{background:"white",flex:"1 0 150px"}})]}),q("div",{title:"Column Settings",children:"Column Settings"}),q(sn,{columns:a.columns,dispatchColumnAction:u,table:{module:"SIMUL",table:"instruments"}})]}),ct("div",{className:`${ht}-buttonBar`,children:[q(Vt,{onClick:s,children:"Cancel"}),q(Vt,{onClick:p,children:"Apply"}),q(Vt,{onClick:x,children:"Save"})]})]})};import{useEffect as Nr,useState as Yt}from"react";import Rr from"classnames";import{jsx as Le,jsxs as Ir}from"react/jsx-runtime";var Ze="vuuDatasourceStats",Zt=new Intl.NumberFormat,Au=({className:n,dataSource:e})=>{let[t,s]=Yt(e.optimize),[i,o]=Yt(e.range),[r,l]=Yt(e.size);Nr(()=>{s(e.optimize),l(e.size),e.on("optimize",s),e.on("resize",l),e.on("range",o)},[e]);let a=Rr(Ze,n),u=Zt.format(i.from),c=Zt.format(i.to-1),h=Zt.format(r);return Ir("div",{className:a,children:[Le("span",{children:"Showing rows"}),Le("span",{className:`${Ze}-range`,children:u}),Le("span",{className:`${Ze}-range`,children:c}),Le("span",{children:"of"}),Le("span",{className:`${Ze}-size`,children:h}),Le("span",{className:`${Ze}-optimize`,children:t})]})};export{Rs as ColumnExpressionInput,Nt as ColumnNamedTerms,Au as DataSourceStats,mu as DatagridSettingsPanel,ds as columnExpressionLanguageSupport,Cs as isCompleteExpression,bs as isCompleteRelationalExpression,Rt as lastNamedChild,Ns as useColumnExpressionEditor,Fs as useColumnExpressionSuggestionProvider,gs as walkTree};
1
+ var __accessCheck = (obj, member, msg) => {
2
+ if (!member.has(obj))
3
+ throw TypeError("Cannot " + msg);
4
+ };
5
+ var __privateGet = (obj, member, getter) => {
6
+ __accessCheck(obj, member, "read from private field");
7
+ return getter ? getter.call(obj) : member.get(obj);
8
+ };
9
+ var __privateAdd = (obj, member, value) => {
10
+ if (member.has(obj))
11
+ throw TypeError("Cannot add the same private member more than once");
12
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ };
14
+ var __privateSet = (obj, member, value, setter) => {
15
+ __accessCheck(obj, member, "write to private field");
16
+ setter ? setter.call(obj, value) : member.set(obj, value);
17
+ return value;
18
+ };
19
+
20
+ // src/cell-renderers/background-cell/BackgroundCell.tsx
21
+ import {
22
+ DOWN1,
23
+ DOWN2,
24
+ metadataKeys,
25
+ registerComponent,
26
+ UP1,
27
+ UP2
28
+ } from "@vuu-ui/vuu-utils";
29
+ import cx from "classnames";
30
+
31
+ // src/cell-renderers/background-cell/useDirection.ts
32
+ import { useEffect, useRef } from "react";
33
+ import { isTypeDescriptor } from "@vuu-ui/vuu-utils";
34
+ import {
35
+ getMovingValueDirection,
36
+ isValidNumber
37
+ } from "@vuu-ui/vuu-utils";
38
+ var INITIAL_VALUE = [void 0, void 0, void 0, void 0];
39
+ function useDirection(key, value, column) {
40
+ var _a;
41
+ const ref = useRef();
42
+ const [prevKey, prevValue, prevColumn, prevDirection] = ref.current || INITIAL_VALUE;
43
+ const { type: dataType } = column;
44
+ const decimals = isTypeDescriptor(dataType) ? (_a = dataType.formatting) == null ? void 0 : _a.decimals : void 0;
45
+ const direction = key === prevKey && isValidNumber(value) && isValidNumber(prevValue) && column === prevColumn ? getMovingValueDirection(value, prevDirection, prevValue, decimals) : "";
46
+ useEffect(() => {
47
+ ref.current = [key, value, column, direction];
48
+ });
49
+ return direction;
50
+ }
51
+
52
+ // src/cell-renderers/background-cell/BackgroundCell.tsx
53
+ import { jsx, jsxs } from "react/jsx-runtime";
54
+ var CHAR_ARROW_UP = String.fromCharCode(11014);
55
+ var CHAR_ARROW_DOWN = String.fromCharCode(11015);
56
+ var { KEY } = metadataKeys;
57
+ var classBase = "vuuBackgroundCell";
58
+ var FlashStyle = {
59
+ ArrowOnly: "arrow",
60
+ BackgroundOnly: "bg-only",
61
+ ArrowBackground: "arrow-bg"
62
+ };
63
+ var getFlashStyle = (colType) => {
64
+ if (typeof colType === "string") {
65
+ return FlashStyle.BackgroundOnly;
66
+ } else if (colType) {
67
+ const { renderer } = colType;
68
+ return renderer && renderer.flashStyle || FlashStyle.BackgroundOnly;
69
+ }
70
+ };
71
+ var BackgroundCell = ({ column, row }) => {
72
+ const { key, type, valueFormatter } = column;
73
+ const value = row[key];
74
+ const flashStyle = getFlashStyle(type);
75
+ const direction = useDirection(row[KEY], value, column);
76
+ const arrow = flashStyle === FlashStyle.ArrowOnly || flashStyle === FlashStyle.ArrowBackground ? direction === UP1 || direction === UP2 ? CHAR_ARROW_UP : direction === DOWN1 || direction === DOWN2 ? CHAR_ARROW_DOWN : null : null;
77
+ const dirClass = direction ? ` ` + direction : "";
78
+ const className = cx(classBase, dirClass, {
79
+ [`${classBase}-arrowOnly`]: flashStyle === FlashStyle.ArrowOnly,
80
+ [`${classBase}-arrowBackground`]: flashStyle === FlashStyle.ArrowBackground
81
+ });
82
+ return /* @__PURE__ */ jsxs("div", { className, tabIndex: -1, children: [
83
+ /* @__PURE__ */ jsx("div", { className: `${classBase}-flasher`, children: arrow }),
84
+ valueFormatter(row[column.key])
85
+ ] });
86
+ };
87
+ registerComponent("background", BackgroundCell, "cell-renderer", {
88
+ serverDataType: ["long", "int", "double"]
89
+ });
90
+
91
+ // src/column-expression-input/useColumnExpressionEditor.ts
92
+ import {
93
+ autocompletion,
94
+ defaultKeymap,
95
+ EditorState as EditorState2,
96
+ EditorView as EditorView2,
97
+ ensureSyntaxTree,
98
+ keymap,
99
+ minimalSetup,
100
+ startCompletion
101
+ } from "@vuu-ui/vuu-codemirror";
102
+ import { createEl } from "@vuu-ui/vuu-utils";
103
+ import { useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
104
+
105
+ // src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
106
+ import {
107
+ LanguageSupport,
108
+ LRLanguage,
109
+ styleTags,
110
+ tags as tag
111
+ } from "@vuu-ui/vuu-codemirror";
112
+
113
+ // src/column-expression-input/column-language-parser/generated/column-parser.js
114
+ import { LRParser } from "@lezer/lr";
115
+ var parser = LRParser.deserialize({
116
+ version: 14,
117
+ states: "&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",
118
+ stateData: ")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",
119
+ goto: "#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",
120
+ nodeNames: "\u26A0 ColumnDefinitionExpression Column Number String True False ParenthesizedExpression OpenBrace CloseBrace ArithmeticExpression Divide Times Plus Minus ConditionalExpression If RelationalExpression RelationalOperator AndCondition OrCondition Comma CallExpression Function ArgList",
121
+ maxTerm: 39,
122
+ skippedNodes: [0],
123
+ repeatNodeCount: 1,
124
+ tokenData: ".^~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$jz{$o{|$t|}$y}!O%O!O!P%T!P!Q%c!Q![%h!^!_%s!_!`&Q!`!a&V!c!}&d#R#S&d#T#U&u#U#Y&d#Y#Z(Y#Z#]&d#]#^*j#^#c&d#c#d+f#d#h&d#h#i,b#i#o&d~#USl~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOu~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_OS~~$bP;=`<%l#m~$jOW~~$oOX~~$tO[~~$yO]~~%OOe~~%TO^~~%WP!Q![%Z~%`PR~!Q![%Z~%hOZ~~%mQR~!O!P%Z!Q![%h~%xPr~!_!`%{~&QOt~~&VOp~~&[Pq~!_!`&_~&dOs~P&iSnP!Q![&d!c!}&d#R#S&d#T#o&dR&zUnP!Q![&d!c!}&d#R#S&d#T#b&d#b#c'^#c#o&dR'cUnP!Q![&d!c!}&d#R#S&d#T#W&d#W#X'u#X#o&dR'|SvQnP!Q![&d!c!}&d#R#S&d#T#o&d~(_TnP!Q![&d!c!}&d#R#S&d#T#U(n#U#o&d~(sUnP!Q![&d!c!}&d#R#S&d#T#`&d#`#a)V#a#o&d~)[UnP!Q![&d!c!}&d#R#S&d#T#g&d#g#h)n#h#o&d~)sUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y*V#Y#o&d~*^SU~nP!Q![&d!c!}&d#R#S&d#T#o&d~*oUnP!Q![&d!c!}&d#R#S&d#T#Y&d#Y#Z+R#Z#o&d~+YS`~nP!Q![&d!c!}&d#R#S&d#T#o&dR+kUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g+}#g#o&dR,USwQnP!Q![&d!c!}&d#R#S&d#T#o&d~,gUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g,y#g#o&d~-OUnP!Q![&d!c!}&d#R#S&d#T#i&d#i#j-b#j#o&d~-gUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y-y#Y#o&d~.QST~nP!Q![&d!c!}&d#R#S&d#T#o&d",
125
+ tokenizers: [0, 1],
126
+ topRules: { "ColumnDefinitionExpression": [0, 1] },
127
+ tokenPrec: 375
128
+ });
129
+
130
+ // src/column-expression-input/column-language-parser/ColumnExpressionLanguage.ts
131
+ var columnExpressionLanguage = LRLanguage.define({
132
+ name: "VuuColumnExpression",
133
+ parser: parser.configure({
134
+ props: [
135
+ styleTags({
136
+ Function: tag.variableName,
137
+ String: tag.string,
138
+ Or: tag.emphasis,
139
+ Operator: tag.operator
140
+ })
141
+ ]
142
+ })
143
+ });
144
+ var columnExpressionLanguageSupport = () => {
145
+ return new LanguageSupport(
146
+ columnExpressionLanguage
147
+ /*, [exampleCompletion]*/
148
+ );
149
+ };
150
+
151
+ // src/column-expression-input/column-language-parser/ColumnExpressionTreeWalker.ts
152
+ var LiteralExpressionImpl = class {
153
+ constructor(value) {
154
+ this.value = value;
155
+ switch (typeof value) {
156
+ case "boolean":
157
+ this.type = "booleanLiteralExpression";
158
+ break;
159
+ case "number":
160
+ this.type = "numberLiteralExpression";
161
+ break;
162
+ default:
163
+ this.type = "stringLiteralExpression";
164
+ }
165
+ }
166
+ toJSON() {
167
+ return {
168
+ type: this.type,
169
+ value: this.value
170
+ };
171
+ }
172
+ };
173
+ var ColumnExpressionImpl = class {
174
+ constructor(columnName) {
175
+ this.type = "colExpression";
176
+ this.column = columnName;
177
+ }
178
+ toJSON() {
179
+ return {
180
+ type: this.type,
181
+ column: this.column
182
+ };
183
+ }
184
+ };
185
+ var _expressions, _op;
186
+ var ArithmeticExpressionImpl = class {
187
+ constructor(op = "unknown") {
188
+ __privateAdd(this, _expressions, [
189
+ { type: "unknown" },
190
+ { type: "unknown" }
191
+ ]);
192
+ __privateAdd(this, _op, void 0);
193
+ this.type = "arithmeticExpression";
194
+ __privateSet(this, _op, op);
195
+ }
196
+ get op() {
197
+ return __privateGet(this, _op);
198
+ }
199
+ set op(op) {
200
+ __privateSet(this, _op, op);
201
+ }
202
+ get expressions() {
203
+ return __privateGet(this, _expressions);
204
+ }
205
+ toJSON() {
206
+ return {
207
+ type: this.type,
208
+ op: __privateGet(this, _op),
209
+ expressions: __privateGet(this, _expressions)
210
+ };
211
+ }
212
+ };
213
+ _expressions = new WeakMap();
214
+ _op = new WeakMap();
215
+ var _expressions2;
216
+ var CallExpressionImpl = class {
217
+ constructor(functionName) {
218
+ __privateAdd(this, _expressions2, []);
219
+ this.type = "callExpression";
220
+ this.functionName = functionName;
221
+ }
222
+ get expressions() {
223
+ return __privateGet(this, _expressions2);
224
+ }
225
+ get arguments() {
226
+ return __privateGet(this, _expressions2);
227
+ }
228
+ toJSON() {
229
+ return {
230
+ type: this.type,
231
+ functionName: this.functionName,
232
+ arguments: __privateGet(this, _expressions2).map((e) => {
233
+ var _a;
234
+ return (_a = e.toJSON) == null ? void 0 : _a.call(e);
235
+ })
236
+ };
237
+ }
238
+ };
239
+ _expressions2 = new WeakMap();
240
+ var _expressions3, _op2;
241
+ var RelationalExpressionImpl = class {
242
+ constructor() {
243
+ __privateAdd(this, _expressions3, [
244
+ { type: "unknown" },
245
+ { type: "unknown" }
246
+ ]);
247
+ __privateAdd(this, _op2, "unknown");
248
+ this.type = "relationalExpression";
249
+ }
250
+ get op() {
251
+ return __privateGet(this, _op2);
252
+ }
253
+ set op(op) {
254
+ __privateSet(this, _op2, op);
255
+ }
256
+ get expressions() {
257
+ return __privateGet(this, _expressions3);
258
+ }
259
+ toJSON() {
260
+ return {
261
+ type: this.type,
262
+ op: __privateGet(this, _op2),
263
+ expressions: __privateGet(this, _expressions3)
264
+ };
265
+ }
266
+ };
267
+ _expressions3 = new WeakMap();
268
+ _op2 = new WeakMap();
269
+ var _expressions4, _op3;
270
+ var BooleanConditionImp = class {
271
+ constructor(booleanOperator) {
272
+ __privateAdd(this, _expressions4, [
273
+ { type: "unknown" },
274
+ { type: "unknown" }
275
+ ]);
276
+ __privateAdd(this, _op3, void 0);
277
+ this.type = "booleanCondition";
278
+ __privateSet(this, _op3, booleanOperator);
279
+ }
280
+ get op() {
281
+ return __privateGet(this, _op3);
282
+ }
283
+ get expressions() {
284
+ return __privateGet(this, _expressions4);
285
+ }
286
+ toJSON() {
287
+ return {
288
+ type: this.type,
289
+ op: __privateGet(this, _op3),
290
+ expressions: __privateGet(this, _expressions4).map((e) => {
291
+ var _a;
292
+ return (_a = e.toJSON) == null ? void 0 : _a.call(e);
293
+ })
294
+ };
295
+ }
296
+ };
297
+ _expressions4 = new WeakMap();
298
+ _op3 = new WeakMap();
299
+ var _expressions5;
300
+ var ConditionalExpressionImpl = class {
301
+ constructor(booleanOperator) {
302
+ __privateAdd(this, _expressions5, void 0);
303
+ this.type = "conditionalExpression";
304
+ __privateSet(this, _expressions5, [
305
+ booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl(),
306
+ { type: "unknown" },
307
+ { type: "unknown" }
308
+ ]);
309
+ }
310
+ get expressions() {
311
+ return __privateGet(this, _expressions5);
312
+ }
313
+ get condition() {
314
+ return __privateGet(this, _expressions5)[0];
315
+ }
316
+ get truthyExpression() {
317
+ return __privateGet(this, _expressions5)[1];
318
+ }
319
+ set truthyExpression(expression) {
320
+ __privateGet(this, _expressions5)[1] = expression;
321
+ }
322
+ get falsyExpression() {
323
+ return __privateGet(this, _expressions5)[2];
324
+ }
325
+ set falsyExpression(expression) {
326
+ __privateGet(this, _expressions5)[2] = expression;
327
+ }
328
+ toJSON() {
329
+ var _a, _b, _c, _d, _e;
330
+ return {
331
+ type: this.type,
332
+ condition: (_b = (_a = this.condition).toJSON) == null ? void 0 : _b.call(_a),
333
+ truthyExpression: this.truthyExpression,
334
+ falsyExpression: (_e = (_d = (_c = this.falsyExpression) == null ? void 0 : _c.toJSON) == null ? void 0 : _d.call(_c)) != null ? _e : this.falsyExpression
335
+ };
336
+ }
337
+ };
338
+ _expressions5 = new WeakMap();
339
+ var isUnknown = (e) => e.type === "unknown";
340
+ var isArithmeticExpression = (expression) => expression.type === "arithmeticExpression";
341
+ var isCallExpression = (expression) => expression.type === "callExpression";
342
+ var isConditionalExpression = (expression) => expression.type === "conditionalExpression";
343
+ var isCondition = (expression) => expression.type === "relationalExpression" || expression.type === "booleanCondition";
344
+ var isBooleanCondition = (expression) => expression.type === "booleanCondition";
345
+ var isRelationalExpression = (expression) => (expression == null ? void 0 : expression.type) === "relationalExpression";
346
+ var firstIncompleteExpression = (expression) => {
347
+ if (isUnknown(expression)) {
348
+ return expression;
349
+ } else if (isRelationalExpression(expression)) {
350
+ const [operand1, operand2] = expression.expressions;
351
+ if (expressionIsIncomplete(operand1)) {
352
+ return firstIncompleteExpression(operand1);
353
+ } else if (expression.op === "unknown") {
354
+ return expression;
355
+ } else if (expressionIsIncomplete(operand2)) {
356
+ return firstIncompleteExpression(operand2);
357
+ }
358
+ } else if (isCondition(expression)) {
359
+ const { expressions = [] } = expression;
360
+ for (const e of expressions) {
361
+ if (expressionIsIncomplete(e)) {
362
+ return firstIncompleteExpression(e);
363
+ }
364
+ }
365
+ } else if (isConditionalExpression(expression)) {
366
+ const { condition, truthyExpression, falsyExpression } = expression;
367
+ if (expressionIsIncomplete(condition)) {
368
+ return firstIncompleteExpression(condition);
369
+ } else if (expressionIsIncomplete(truthyExpression)) {
370
+ return firstIncompleteExpression(truthyExpression);
371
+ } else if (expressionIsIncomplete(falsyExpression)) {
372
+ return firstIncompleteExpression(falsyExpression);
373
+ }
374
+ } else if (isArithmeticExpression(expression)) {
375
+ const { expressions = [] } = expression;
376
+ for (const e of expressions) {
377
+ if (expressionIsIncomplete(e)) {
378
+ return firstIncompleteExpression(e);
379
+ }
380
+ }
381
+ }
382
+ };
383
+ var replaceUnknownExpression = (incompleteExpression, unknownExpression, expression) => {
384
+ const { expressions = [] } = incompleteExpression;
385
+ if (expressions.includes(unknownExpression)) {
386
+ const pos = expressions.indexOf(unknownExpression);
387
+ expressions.splice(pos, 1, expression);
388
+ return true;
389
+ } else {
390
+ for (const e of expressions) {
391
+ if (replaceUnknownExpression(e, unknownExpression, expression)) {
392
+ return true;
393
+ }
394
+ }
395
+ }
396
+ return false;
397
+ };
398
+ var expressionIsIncomplete = (expression) => {
399
+ if (isUnknown(expression)) {
400
+ return true;
401
+ } else if (isConditionalExpression(expression)) {
402
+ return expressionIsIncomplete(expression.condition) || expressionIsIncomplete(expression.truthyExpression) || expressionIsIncomplete(expression.falsyExpression);
403
+ } else if (isRelationalExpression(expression) || isBooleanCondition(expression)) {
404
+ return expression.op === void 0 || expression.expressions.some((e) => expressionIsIncomplete(e));
405
+ }
406
+ return false;
407
+ };
408
+ var addExpression = (expression, subExpression) => {
409
+ const targetExpression = firstIncompleteExpression(expression);
410
+ if (targetExpression) {
411
+ if (targetExpression.expressions) {
412
+ targetExpression.expressions.push(subExpression);
413
+ } else {
414
+ console.warn("don't know how to treat targetExpression");
415
+ }
416
+ } else {
417
+ console.error("no target expression found");
418
+ }
419
+ };
420
+ var _expression, _callStack;
421
+ var ColumnExpression = class {
422
+ constructor() {
423
+ __privateAdd(this, _expression, void 0);
424
+ __privateAdd(this, _callStack, []);
425
+ }
426
+ setCondition(booleanOperator) {
427
+ if (__privateGet(this, _expression) === void 0) {
428
+ this.addExpression(new ConditionalExpressionImpl(booleanOperator));
429
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
430
+ if (expressionIsIncomplete(__privateGet(this, _expression).condition)) {
431
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
432
+ this.addExpression(condition);
433
+ } else if (isUnknown(__privateGet(this, _expression).truthyExpression)) {
434
+ __privateGet(this, _expression).truthyExpression = new ConditionalExpressionImpl(
435
+ booleanOperator
436
+ );
437
+ } else if (expressionIsIncomplete(__privateGet(this, _expression).truthyExpression)) {
438
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
439
+ this.addExpression(condition);
440
+ } else if (isUnknown(__privateGet(this, _expression).falsyExpression)) {
441
+ __privateGet(this, _expression).falsyExpression = new ConditionalExpressionImpl(
442
+ booleanOperator
443
+ );
444
+ } else if (expressionIsIncomplete(__privateGet(this, _expression).falsyExpression)) {
445
+ const condition = booleanOperator ? new BooleanConditionImp(booleanOperator) : new RelationalExpressionImpl();
446
+ this.addExpression(condition);
447
+ }
448
+ } else {
449
+ console.error("setCondition called unexpectedly");
450
+ }
451
+ }
452
+ addExpression(expression) {
453
+ if (__privateGet(this, _callStack).length > 0) {
454
+ const currentCallExpression = __privateGet(this, _callStack).at(-1);
455
+ currentCallExpression == null ? void 0 : currentCallExpression.arguments.push(expression);
456
+ } else if (__privateGet(this, _expression) === void 0) {
457
+ __privateSet(this, _expression, expression);
458
+ } else if (isArithmeticExpression(__privateGet(this, _expression))) {
459
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
460
+ if (targetExpression && isUnknown(targetExpression)) {
461
+ replaceUnknownExpression(
462
+ __privateGet(this, _expression),
463
+ targetExpression,
464
+ expression
465
+ );
466
+ }
467
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
468
+ if (expressionIsIncomplete(__privateGet(this, _expression))) {
469
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
470
+ if (targetExpression && isUnknown(targetExpression)) {
471
+ replaceUnknownExpression(
472
+ __privateGet(this, _expression),
473
+ targetExpression,
474
+ expression
475
+ );
476
+ } else if (targetExpression) {
477
+ addExpression(targetExpression, expression);
478
+ }
479
+ }
480
+ }
481
+ }
482
+ setFunction(functionName) {
483
+ const callExpression = new CallExpressionImpl(functionName);
484
+ this.addExpression(callExpression);
485
+ __privateGet(this, _callStack).push(callExpression);
486
+ }
487
+ setColumn(columnName) {
488
+ this.addExpression(new ColumnExpressionImpl(columnName));
489
+ }
490
+ setArithmeticOp(value) {
491
+ const op = value;
492
+ const expression = __privateGet(this, _expression);
493
+ if (isArithmeticExpression(expression)) {
494
+ expression.op = op;
495
+ }
496
+ }
497
+ setRelationalOperator(value) {
498
+ const op = value;
499
+ if (__privateGet(this, _expression) && isConditionalExpression(__privateGet(this, _expression))) {
500
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
501
+ if (isRelationalExpression(targetExpression)) {
502
+ targetExpression.op = op;
503
+ } else {
504
+ console.error(`no target expression found (op = ${value})`);
505
+ }
506
+ }
507
+ }
508
+ setValue(value) {
509
+ const literalExpression = new LiteralExpressionImpl(value);
510
+ if (__privateGet(this, _expression) === void 0) {
511
+ __privateSet(this, _expression, literalExpression);
512
+ } else if (isArithmeticExpression(__privateGet(this, _expression))) {
513
+ this.addExpression(literalExpression);
514
+ } else if (isCallExpression(__privateGet(this, _expression))) {
515
+ __privateGet(this, _expression).arguments.push(literalExpression);
516
+ } else if (isConditionalExpression(__privateGet(this, _expression))) {
517
+ if (expressionIsIncomplete(__privateGet(this, _expression))) {
518
+ const targetExpression = firstIncompleteExpression(__privateGet(this, _expression));
519
+ if (targetExpression && isUnknown(targetExpression)) {
520
+ replaceUnknownExpression(
521
+ __privateGet(this, _expression),
522
+ targetExpression,
523
+ literalExpression
524
+ );
525
+ } else if (targetExpression) {
526
+ addExpression(targetExpression, literalExpression);
527
+ }
528
+ } else {
529
+ console.log("what do we do with value, in a complete expression");
530
+ }
531
+ }
532
+ }
533
+ closeBrace() {
534
+ __privateGet(this, _callStack).pop();
535
+ }
536
+ get expression() {
537
+ return __privateGet(this, _expression);
538
+ }
539
+ toJSON() {
540
+ var _a;
541
+ return (_a = __privateGet(this, _expression)) == null ? void 0 : _a.toJSON();
542
+ }
543
+ };
544
+ _expression = new WeakMap();
545
+ _callStack = new WeakMap();
546
+ var walkTree = (tree, source) => {
547
+ const columnExpression = new ColumnExpression();
548
+ const cursor = tree.cursor();
549
+ do {
550
+ const { name, from, to } = cursor;
551
+ switch (name) {
552
+ case "AndCondition":
553
+ columnExpression.setCondition("and");
554
+ break;
555
+ case "OrCondition":
556
+ columnExpression.setCondition("or");
557
+ break;
558
+ case "RelationalExpression":
559
+ columnExpression.setCondition();
560
+ break;
561
+ case "ArithmeticExpression":
562
+ columnExpression.addExpression(new ArithmeticExpressionImpl());
563
+ break;
564
+ case "Column":
565
+ {
566
+ const columnName = source.substring(from, to);
567
+ columnExpression.setColumn(columnName);
568
+ }
569
+ break;
570
+ case "Function":
571
+ {
572
+ const functionName = source.substring(from, to);
573
+ columnExpression.setFunction(functionName);
574
+ }
575
+ break;
576
+ case "Times":
577
+ case "Divide":
578
+ case "Plus":
579
+ case "Minus":
580
+ {
581
+ const op = source.substring(from, to);
582
+ columnExpression.setArithmeticOp(op);
583
+ }
584
+ break;
585
+ case "RelationalOperator":
586
+ {
587
+ const op = source.substring(from, to);
588
+ columnExpression.setRelationalOperator(op);
589
+ }
590
+ break;
591
+ case "False":
592
+ case "True":
593
+ {
594
+ const value = source.substring(from, to);
595
+ columnExpression.setValue(value === "true" ? true : false);
596
+ }
597
+ break;
598
+ case "String":
599
+ columnExpression.setValue(source.substring(from + 1, to - 1));
600
+ break;
601
+ case "Number":
602
+ columnExpression.setValue(parseFloat(source.substring(from, to)));
603
+ break;
604
+ case "CloseBrace":
605
+ columnExpression.closeBrace();
606
+ break;
607
+ default:
608
+ }
609
+ } while (cursor.next());
610
+ return columnExpression.toJSON();
611
+ };
612
+
613
+ // src/column-expression-input/column-language-parser/column-expression-parse-utils.ts
614
+ var strictParser = parser.configure({ strict: true });
615
+ var RelationalOperands = ["Number", "String"];
616
+ var ColumnNamedTerms = [
617
+ ...RelationalOperands,
618
+ "AndCondition",
619
+ "ArithmeticExpression",
620
+ "BooleanOperator",
621
+ "RelationalOperatorOperator",
622
+ "CallExpression",
623
+ "CloseBrace",
624
+ "Column",
625
+ "Comma",
626
+ "ConditionalExpression",
627
+ "Divide",
628
+ "Equal",
629
+ "If",
630
+ "Minus",
631
+ "OpenBrace",
632
+ "OrCondition",
633
+ "ParenthesizedExpression",
634
+ "Plus",
635
+ "RelationalExpression",
636
+ "RelationalOperator",
637
+ "Times"
638
+ ];
639
+ var isCompleteExpression = (src) => {
640
+ try {
641
+ strictParser.parse(src);
642
+ return true;
643
+ } catch (err) {
644
+ return false;
645
+ }
646
+ };
647
+ var lastNamedChild = (node) => {
648
+ let { lastChild } = node;
649
+ while (lastChild && !ColumnNamedTerms.includes(lastChild.name)) {
650
+ lastChild = lastChild.prevSibling;
651
+ console.log(lastChild == null ? void 0 : lastChild.name);
652
+ }
653
+ return lastChild;
654
+ };
655
+ var isCompleteRelationalExpression = (node) => {
656
+ if ((node == null ? void 0 : node.name) === "RelationalExpression") {
657
+ const { firstChild } = node;
658
+ const lastChild = lastNamedChild(node);
659
+ if ((firstChild == null ? void 0 : firstChild.name) === "Column" && typeof (lastChild == null ? void 0 : lastChild.name) === "string" && RelationalOperands.includes(lastChild.name)) {
660
+ return true;
661
+ }
662
+ }
663
+ return false;
664
+ };
665
+
666
+ // src/column-expression-input/highlighting.ts
667
+ import {
668
+ HighlightStyle,
669
+ syntaxHighlighting,
670
+ tags
671
+ } from "@vuu-ui/vuu-codemirror";
672
+ var myHighlightStyle = HighlightStyle.define([
673
+ { tag: tags.variableName, color: "var(--vuuFilterEditor-variableColor)" },
674
+ { tag: tags.comment, color: "green", fontStyle: "italic" }
675
+ ]);
676
+ var vuuHighlighting = syntaxHighlighting(myHighlightStyle);
677
+
678
+ // src/column-expression-input/theme.ts
679
+ import { EditorView } from "@vuu-ui/vuu-codemirror";
680
+ var vuuTheme = EditorView.theme(
681
+ {
682
+ "&": {
683
+ border: "solid 1px var(--salt-container-primary-borderColor)",
684
+ color: "var(--vuuFilterEditor-color)",
685
+ backgroundColor: "var(--vuuFilterEditor-background)"
686
+ },
687
+ ".cm-content": {
688
+ caretColor: "var(--vuuFilterEditor-cursorColor)"
689
+ },
690
+ "&.cm-focused .cm-cursor": {
691
+ borderLeftColor: "var(--vuuFilterEditor-cursorColor)"
692
+ },
693
+ "&.cm-focused .cm-selectionBackground, ::selection": {
694
+ backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
695
+ },
696
+ ".cm-selectionBackground, ::selection": {
697
+ backgroundColor: "var(--vuuFilterEditor-selectionBackground)"
698
+ },
699
+ ".cm-scroller": {
700
+ fontFamily: "var(--vuuFilterEditor-fontFamily)"
701
+ },
702
+ ".cm-tooltip": {
703
+ background: "var(--vuuFilterEditor-tooltipBackground)",
704
+ border: "var(--vuuFilterEditor-tooltipBorder)",
705
+ boxShadow: "var(--vuuFilterEditor-tooltipElevation)",
706
+ "&.cm-tooltip-autocomplete > ul": {
707
+ fontFamily: "var(--vuuFilterEditor-fontFamily)",
708
+ fontSize: "var(--vuuFilterEditor-fontSize)",
709
+ maxHeight: "240px"
710
+ },
711
+ "&.cm-tooltip-autocomplete > ul > li": {
712
+ height: "var(--vuuFilterEditor-suggestion-height)",
713
+ padding: "0 3px",
714
+ lineHeight: "var(--vuuFilterEditor-suggestion-height)"
715
+ },
716
+ "&.cm-tooltip-autocomplete li[aria-selected]": {
717
+ background: "var(--vuuFilterEditor-suggestion-selectedBackground)",
718
+ color: "var(--vuuFilterEditor-suggestion-selectedColor)"
719
+ },
720
+ "&.cm-tooltip-autocomplete li .cm-completionDetail": {
721
+ color: "var(--vuuFilterEditor-suggestion-detailColor)"
722
+ }
723
+ }
724
+ },
725
+ { dark: false }
726
+ );
727
+
728
+ // src/column-expression-input/useColumnAutoComplete.ts
729
+ import {
730
+ booleanJoinSuggestions,
731
+ getNamedParentNode,
732
+ getPreviousNode,
733
+ getValue,
734
+ syntaxTree
735
+ } from "@vuu-ui/vuu-codemirror";
736
+ import { useCallback } from "react";
737
+ var applyPrefix = (completions, prefix) => prefix ? completions.map((completion) => {
738
+ var _a;
739
+ return {
740
+ ...completion,
741
+ apply: typeof completion.apply === "function" ? completion.apply : `${prefix}${(_a = completion.apply) != null ? _a : completion.label}`
742
+ };
743
+ }) : completions;
744
+ var isOperator = (node) => node === void 0 ? false : ["Times", "Divide", "Plus", "Minus"].includes(node.name);
745
+ var getLastChild = (node, context) => {
746
+ var _a;
747
+ let { lastChild: childNode } = node;
748
+ const { pos } = context;
749
+ while (childNode) {
750
+ const isBeforeCursor = childNode.from < pos;
751
+ if (isBeforeCursor && ColumnNamedTerms.includes(childNode.name)) {
752
+ if (childNode.name === "ParenthesizedExpression") {
753
+ const expression = (_a = childNode.firstChild) == null ? void 0 : _a.nextSibling;
754
+ if (expression) {
755
+ childNode = expression;
756
+ }
757
+ }
758
+ return childNode;
759
+ } else {
760
+ childNode = childNode.prevSibling;
761
+ }
762
+ }
763
+ };
764
+ var getFunctionName = (node, state) => {
765
+ var _a;
766
+ if (node.name === "ArgList") {
767
+ const functionNode = node.prevSibling;
768
+ if (functionNode) {
769
+ return getValue(functionNode, state);
770
+ }
771
+ } else if (node.name === "OpenBrace") {
772
+ const maybeFunction = (_a = node.parent) == null ? void 0 : _a.prevSibling;
773
+ if ((maybeFunction == null ? void 0 : maybeFunction.name) === "Function") {
774
+ return getValue(maybeFunction, state);
775
+ }
776
+ }
777
+ };
778
+ var getRelationalOperator = (node, state) => {
779
+ if (node.name === "RelationalExpression") {
780
+ const lastNode = lastNamedChild(node);
781
+ if ((lastNode == null ? void 0 : lastNode.name) === "RelationalOperator") {
782
+ return getValue(lastNode, state);
783
+ }
784
+ } else {
785
+ const prevNode = node.prevSibling;
786
+ if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
787
+ return getValue(prevNode, state);
788
+ }
789
+ }
790
+ };
791
+ var getColumnName = (node, state) => {
792
+ var _a;
793
+ if (node.name === "RelationalExpression") {
794
+ if (((_a = node.firstChild) == null ? void 0 : _a.name) === "Column") {
795
+ return getValue(node.firstChild, state);
796
+ }
797
+ } else {
798
+ const prevNode = node.prevSibling;
799
+ if ((prevNode == null ? void 0 : prevNode.name) === "Column") {
800
+ return getValue(prevNode, state);
801
+ } else if ((prevNode == null ? void 0 : prevNode.name) === "RelationalOperator") {
802
+ return getColumnName(prevNode, state);
803
+ }
804
+ }
805
+ };
806
+ var makeSuggestions = async (context, suggestionProvider, suggestionType, optionalArgs = {}) => {
807
+ const options = await suggestionProvider.getSuggestions(
808
+ suggestionType,
809
+ optionalArgs
810
+ );
811
+ const { startsWith = "" } = optionalArgs;
812
+ return { from: context.pos - startsWith.length, options };
813
+ };
814
+ var handleConditionalExpression = (node, context, suggestionProvider, maybeComplete, onSubmit) => {
815
+ const lastChild = getLastChild(node, context);
816
+ console.log(`conditional expression last child ${lastChild == null ? void 0 : lastChild.name}`);
817
+ switch (lastChild == null ? void 0 : lastChild.name) {
818
+ case "If":
819
+ return makeSuggestions(context, suggestionProvider, "expression", {
820
+ prefix: "( "
821
+ });
822
+ case "OpenBrace":
823
+ return makeSuggestions(context, suggestionProvider, "expression");
824
+ case "Condition":
825
+ return makeSuggestions(context, suggestionProvider, "expression", {
826
+ prefix: ", "
827
+ });
828
+ case "CloseBrace":
829
+ if (maybeComplete) {
830
+ const options = [
831
+ {
832
+ apply: () => {
833
+ onSubmit == null ? void 0 : onSubmit();
834
+ },
835
+ label: "Save Expression",
836
+ boost: 10
837
+ }
838
+ ];
839
+ return { from: context.pos, options };
840
+ }
841
+ }
842
+ };
843
+ var promptToSave = (context, onSubmit) => {
844
+ const options = [
845
+ {
846
+ apply: () => {
847
+ onSubmit == null ? void 0 : onSubmit();
848
+ },
849
+ label: "Save Expression",
850
+ boost: 10
851
+ }
852
+ ];
853
+ return { from: context.pos, options };
854
+ };
855
+ var useColumnAutoComplete = (suggestionProvider, onSubmit) => {
856
+ const makeSuggestions2 = useCallback(
857
+ async (context, suggestionType, optionalArgs = {}) => {
858
+ const options = await suggestionProvider.getSuggestions(
859
+ suggestionType,
860
+ optionalArgs
861
+ );
862
+ const { startsWith = "" } = optionalArgs;
863
+ return { from: context.pos - startsWith.length, options };
864
+ },
865
+ [suggestionProvider]
866
+ );
867
+ return useCallback(
868
+ async (context) => {
869
+ var _a, _b;
870
+ const { state, pos } = context;
871
+ const word = (_a = context.matchBefore(/\w*/)) != null ? _a : {
872
+ from: 0,
873
+ to: 0,
874
+ text: void 0
875
+ };
876
+ const tree = syntaxTree(state);
877
+ const nodeBefore = tree.resolveInner(pos, -1);
878
+ const text = state.doc.toString();
879
+ const maybeComplete = isCompleteExpression(text);
880
+ console.log({ nodeBeforeName: nodeBefore.name });
881
+ switch (nodeBefore.name) {
882
+ case "If": {
883
+ console.log(`conditional expression If`);
884
+ return makeSuggestions2(context, "expression", { prefix: "( " });
885
+ }
886
+ case "Condition":
887
+ {
888
+ const lastChild = getLastChild(nodeBefore, context);
889
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
890
+ const prevChild = getPreviousNode(lastChild);
891
+ if ((prevChild == null ? void 0 : prevChild.name) !== "RelationalOperator") {
892
+ return makeSuggestions2(context, "condition-operator", {
893
+ columnName: getValue(lastChild, state)
894
+ });
895
+ }
896
+ console.log(
897
+ `Condition last child Column, prev child ${prevChild == null ? void 0 : prevChild.name}`
898
+ );
899
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "RelationalOperator") {
900
+ return makeSuggestions2(context, "expression");
901
+ }
902
+ console.log(`condition last child ${lastChild == null ? void 0 : lastChild.name}`);
903
+ }
904
+ break;
905
+ case "ConditionalExpression":
906
+ return handleConditionalExpression(
907
+ nodeBefore,
908
+ context,
909
+ suggestionProvider
910
+ );
911
+ case "RelationalExpression":
912
+ {
913
+ if (isCompleteRelationalExpression(nodeBefore)) {
914
+ return {
915
+ from: context.pos,
916
+ options: booleanJoinSuggestions.concat({
917
+ label: ", <truthy expression>, <falsy expression>",
918
+ apply: ", "
919
+ })
920
+ };
921
+ } else {
922
+ const operator = getRelationalOperator(nodeBefore, state);
923
+ const columnName = getColumnName(nodeBefore, state);
924
+ if (!operator) {
925
+ const options = await suggestionProvider.getSuggestions(
926
+ "condition-operator",
927
+ {
928
+ columnName
929
+ }
930
+ );
931
+ return { from: context.pos, options };
932
+ } else {
933
+ return makeSuggestions2(context, "expression");
934
+ }
935
+ }
936
+ }
937
+ break;
938
+ case "RelationalOperator":
939
+ return makeSuggestions2(context, "expression");
940
+ case "String":
941
+ {
942
+ const operator = getRelationalOperator(
943
+ nodeBefore,
944
+ state
945
+ );
946
+ const columnName = getColumnName(nodeBefore, state);
947
+ const { from, to } = nodeBefore;
948
+ if (to - from === 2 && context.pos === from + 1) {
949
+ if (columnName && operator) {
950
+ return makeSuggestions2(context, "columnValue", {
951
+ columnName,
952
+ operator,
953
+ startsWith: word.text
954
+ });
955
+ }
956
+ } else if (to - from > 2 && context.pos === to) {
957
+ return makeSuggestions2(context, "expression", {
958
+ prefix: ", "
959
+ });
960
+ }
961
+ console.log(
962
+ `we have a string, column is ${columnName} ${from} ${to}`
963
+ );
964
+ }
965
+ break;
966
+ case "ArithmeticExpression":
967
+ {
968
+ const lastChild = getLastChild(nodeBefore, context);
969
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
970
+ return makeSuggestions2(context, "expression");
971
+ } else if (isOperator(lastChild)) {
972
+ const operator = lastChild.name;
973
+ return makeSuggestions2(context, "column", { operator });
974
+ }
975
+ }
976
+ break;
977
+ case "OpenBrace":
978
+ {
979
+ const functionName = getFunctionName(nodeBefore, state);
980
+ return makeSuggestions2(context, "expression", { functionName });
981
+ }
982
+ break;
983
+ case "ArgList": {
984
+ const functionName = getFunctionName(nodeBefore, state);
985
+ const lastArgument = getLastChild(nodeBefore, context);
986
+ const prefix = (lastArgument == null ? void 0 : lastArgument.name) === "OpenBrace" ? void 0 : ",";
987
+ let options = await suggestionProvider.getSuggestions("expression", {
988
+ functionName
989
+ });
990
+ options = prefix ? applyPrefix(options, ", ") : options;
991
+ if ((lastArgument == null ? void 0 : lastArgument.name) !== "OpenBrace" && (lastArgument == null ? void 0 : lastArgument.name) !== "Comma") {
992
+ options = [
993
+ {
994
+ apply: ") ",
995
+ boost: 10,
996
+ label: "Done - no more arguments"
997
+ }
998
+ ].concat(options);
999
+ }
1000
+ return { from: context.pos, options };
1001
+ }
1002
+ case "Equal":
1003
+ if (text.trim() === "=") {
1004
+ return makeSuggestions2(context, "expression");
1005
+ }
1006
+ break;
1007
+ case "ParenthesizedExpression":
1008
+ case "ColumnDefinitionExpression":
1009
+ if (context.pos === 0) {
1010
+ return makeSuggestions2(context, "expression");
1011
+ } else {
1012
+ const lastChild = getLastChild(nodeBefore, context);
1013
+ if ((lastChild == null ? void 0 : lastChild.name) === "Column") {
1014
+ if (maybeComplete) {
1015
+ const options = [
1016
+ {
1017
+ apply: () => {
1018
+ onSubmit.current();
1019
+ },
1020
+ label: "Save Expression",
1021
+ boost: 10
1022
+ }
1023
+ ];
1024
+ const columnName = getValue(lastChild, state);
1025
+ const columnOptions = await suggestionProvider.getSuggestions("operator", {
1026
+ columnName
1027
+ });
1028
+ return {
1029
+ from: context.pos,
1030
+ options: options.concat(columnOptions)
1031
+ };
1032
+ }
1033
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "CallExpression") {
1034
+ if (maybeComplete) {
1035
+ const options = [
1036
+ {
1037
+ apply: () => {
1038
+ onSubmit.current();
1039
+ },
1040
+ label: "Save Expression",
1041
+ boost: 10
1042
+ }
1043
+ ];
1044
+ return {
1045
+ from: context.pos,
1046
+ options
1047
+ };
1048
+ }
1049
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "ArithmeticExpression") {
1050
+ if (maybeComplete) {
1051
+ let options = [
1052
+ {
1053
+ apply: () => {
1054
+ onSubmit.current();
1055
+ },
1056
+ label: "Save Expression",
1057
+ boost: 10
1058
+ }
1059
+ ];
1060
+ const lastExpressionChild = getLastChild(lastChild, context);
1061
+ if ((lastExpressionChild == null ? void 0 : lastExpressionChild.name) === "Column") {
1062
+ const columnName = getValue(lastExpressionChild, state);
1063
+ const suggestions = await suggestionProvider.getSuggestions(
1064
+ "operator",
1065
+ { columnName }
1066
+ );
1067
+ options = options.concat(suggestions);
1068
+ }
1069
+ return {
1070
+ from: context.pos,
1071
+ options
1072
+ };
1073
+ }
1074
+ } else if ((lastChild == null ? void 0 : lastChild.name) === "ConditionalExpression") {
1075
+ return handleConditionalExpression(
1076
+ lastChild,
1077
+ context,
1078
+ suggestionProvider,
1079
+ maybeComplete,
1080
+ onSubmit.current
1081
+ );
1082
+ }
1083
+ break;
1084
+ }
1085
+ case "Column":
1086
+ {
1087
+ const isPartialMatch = await suggestionProvider.isPartialMatch(
1088
+ "expression",
1089
+ void 0,
1090
+ word.text
1091
+ );
1092
+ if (isPartialMatch) {
1093
+ return makeSuggestions2(context, "expression", {
1094
+ startsWith: word.text
1095
+ });
1096
+ }
1097
+ }
1098
+ break;
1099
+ case "Comma":
1100
+ {
1101
+ const parentNode = getNamedParentNode(nodeBefore);
1102
+ if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
1103
+ return makeSuggestions2(context, "expression");
1104
+ }
1105
+ }
1106
+ break;
1107
+ case "CloseBrace":
1108
+ {
1109
+ const parentNode = getNamedParentNode(nodeBefore);
1110
+ if ((parentNode == null ? void 0 : parentNode.name) === "ConditionalExpression") {
1111
+ return handleConditionalExpression(
1112
+ parentNode,
1113
+ context,
1114
+ suggestionProvider,
1115
+ maybeComplete,
1116
+ onSubmit.current
1117
+ );
1118
+ } else if ((parentNode == null ? void 0 : parentNode.name) === "ArgList") {
1119
+ if (maybeComplete) {
1120
+ return promptToSave(context, onSubmit.current);
1121
+ }
1122
+ }
1123
+ console.log(
1124
+ `does closebrace denote an ARgList or a parenthetised expression ? ${parentNode}`
1125
+ );
1126
+ }
1127
+ break;
1128
+ default: {
1129
+ if (((_b = nodeBefore == null ? void 0 : nodeBefore.prevSibling) == null ? void 0 : _b.name) === "FilterClause") {
1130
+ console.log("looks like we ight be a or|and operator");
1131
+ }
1132
+ }
1133
+ }
1134
+ },
1135
+ [makeSuggestions2, onSubmit, suggestionProvider]
1136
+ );
1137
+ };
1138
+
1139
+ // src/column-expression-input/useColumnExpressionEditor.ts
1140
+ var getView = (ref) => {
1141
+ if (ref.current == void 0) {
1142
+ throw Error("EditorView not defined");
1143
+ }
1144
+ return ref.current;
1145
+ };
1146
+ var getOptionClass = () => {
1147
+ return "vuuSuggestion";
1148
+ };
1149
+ var noop = () => console.log("noooop");
1150
+ var hasExpressionType = (completion) => "expressionType" in completion;
1151
+ var injectOptionContent = (completion) => {
1152
+ if (hasExpressionType(completion)) {
1153
+ const div = createEl("div", "expression-type-container");
1154
+ const span = createEl("span", "expression-type", completion.expressionType);
1155
+ div.appendChild(span);
1156
+ return div;
1157
+ } else {
1158
+ return null;
1159
+ }
1160
+ };
1161
+ var useColumnExpressionEditor = ({
1162
+ onChange,
1163
+ onSubmitExpression,
1164
+ suggestionProvider
1165
+ }) => {
1166
+ const editorRef = useRef2(null);
1167
+ const onSubmit = useRef2(noop);
1168
+ const viewRef = useRef2();
1169
+ const completionFn = useColumnAutoComplete(suggestionProvider, onSubmit);
1170
+ const [createState, clearInput] = useMemo(() => {
1171
+ const parseExpression = () => {
1172
+ const view = getView(viewRef);
1173
+ const source = view.state.doc.toString();
1174
+ const tree = ensureSyntaxTree(view.state, view.state.doc.length, 5e3);
1175
+ if (tree) {
1176
+ const expression = walkTree(tree, source);
1177
+ return [source, expression];
1178
+ } else {
1179
+ return ["", void 0];
1180
+ }
1181
+ };
1182
+ const clearInput2 = () => {
1183
+ getView(viewRef).setState(createState2());
1184
+ };
1185
+ const submitExpressionAndClearInput = () => {
1186
+ const [source, expression] = parseExpression();
1187
+ onSubmitExpression == null ? void 0 : onSubmitExpression(source, expression);
1188
+ clearInput2();
1189
+ };
1190
+ const submitFilter = (key) => {
1191
+ return keymap.of([
1192
+ {
1193
+ key,
1194
+ run() {
1195
+ submitExpressionAndClearInput();
1196
+ return true;
1197
+ }
1198
+ }
1199
+ ]);
1200
+ };
1201
+ const showSuggestions = (key) => {
1202
+ return keymap.of([
1203
+ {
1204
+ key,
1205
+ run() {
1206
+ startCompletion(getView(viewRef));
1207
+ return true;
1208
+ }
1209
+ }
1210
+ ]);
1211
+ };
1212
+ const createState2 = () => EditorState2.create({
1213
+ doc: "",
1214
+ extensions: [
1215
+ minimalSetup,
1216
+ autocompletion({
1217
+ addToOptions: [
1218
+ {
1219
+ render: injectOptionContent,
1220
+ position: 70
1221
+ }
1222
+ ],
1223
+ override: [completionFn],
1224
+ optionClass: getOptionClass
1225
+ }),
1226
+ columnExpressionLanguageSupport(),
1227
+ keymap.of(defaultKeymap),
1228
+ submitFilter("Ctrl-Enter"),
1229
+ showSuggestions("ArrowDown"),
1230
+ EditorView2.updateListener.of((v) => {
1231
+ const view = getView(viewRef);
1232
+ if (v.docChanged) {
1233
+ startCompletion(view);
1234
+ const source = view.state.doc.toString();
1235
+ onChange == null ? void 0 : onChange(source, void 0);
1236
+ }
1237
+ }),
1238
+ // Enforces single line view
1239
+ // EditorState.transactionFilter.of((tr) =>
1240
+ // tr.newDoc.lines > 1 ? [] : tr
1241
+ // ),
1242
+ vuuTheme,
1243
+ vuuHighlighting
1244
+ ]
1245
+ });
1246
+ onSubmit.current = () => {
1247
+ submitExpressionAndClearInput();
1248
+ setTimeout(() => {
1249
+ getView(viewRef).focus();
1250
+ }, 100);
1251
+ };
1252
+ return [createState2, clearInput2];
1253
+ }, [completionFn, onChange, onSubmitExpression]);
1254
+ useEffect2(() => {
1255
+ if (!editorRef.current) {
1256
+ throw Error("editor not in dom");
1257
+ }
1258
+ viewRef.current = new EditorView2({
1259
+ state: createState(),
1260
+ parent: editorRef.current
1261
+ });
1262
+ return () => {
1263
+ var _a;
1264
+ (_a = viewRef.current) == null ? void 0 : _a.destroy();
1265
+ };
1266
+ }, [completionFn, createState]);
1267
+ return { editorRef, clearInput };
1268
+ };
1269
+
1270
+ // src/column-expression-input/ColumnExpressionInput.tsx
1271
+ import { jsx as jsx2 } from "react/jsx-runtime";
1272
+ var classBase2 = "vuuColumnExpressionInput";
1273
+ var ColumnExpressionInput = ({
1274
+ onChange,
1275
+ onSubmitExpression,
1276
+ suggestionProvider
1277
+ }) => {
1278
+ const { editorRef } = useColumnExpressionEditor({
1279
+ onChange,
1280
+ onSubmitExpression,
1281
+ suggestionProvider
1282
+ });
1283
+ return /* @__PURE__ */ jsx2("div", { className: `${classBase2}`, ref: editorRef });
1284
+ };
1285
+
1286
+ // src/column-expression-input/useColumnExpressionSuggestionProvider.ts
1287
+ import {
1288
+ AnnotationType,
1289
+ getRelationalOperators,
1290
+ numericOperators,
1291
+ stringOperators,
1292
+ toSuggestions
1293
+ } from "@vuu-ui/vuu-codemirror";
1294
+ import { getTypeaheadParams, useTypeaheadSuggestions } from "@vuu-ui/vuu-data";
1295
+ import { isNumericColumn, isTextColumn } from "@vuu-ui/vuu-utils";
1296
+ import { useCallback as useCallback2, useRef as useRef3 } from "react";
1297
+
1298
+ // src/column-expression-input/column-function-descriptors.ts
1299
+ var columnFunctionDescriptors = [
1300
+ /**
1301
+ * concatenate()
1302
+ */
1303
+ {
1304
+ accepts: "string",
1305
+ description: "Returns multiple string values as a single joined string. Arguments may be string literal values, string columns or other string expressions. Non string arguments may also be included, these will be converted to strings.",
1306
+ example: {
1307
+ expression: 'concatenate("example", "-test")',
1308
+ result: '"example-test"'
1309
+ },
1310
+ name: "concatenate",
1311
+ params: {
1312
+ description: "( string, string, [ string* ] )"
1313
+ },
1314
+ type: "string"
1315
+ },
1316
+ /**
1317
+ * contains()
1318
+ */
1319
+ {
1320
+ accepts: ["string", "string"],
1321
+ description: "Tests a string value to determine whether it contains a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> contains one or more occurrences of <target subscring>",
1322
+ example: {
1323
+ expression: 'contains("Royal Bank of Scotland", "bank")',
1324
+ result: "true"
1325
+ },
1326
+ name: "contains",
1327
+ params: {
1328
+ description: "( string )"
1329
+ },
1330
+ type: "boolean"
1331
+ },
1332
+ /**
1333
+ * left()
1334
+ */
1335
+ {
1336
+ accepts: ["string", "number"],
1337
+ description: "Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
1338
+ example: {
1339
+ expression: 'left("USD Benchmark Report", 3)',
1340
+ result: '"USD"'
1341
+ },
1342
+ name: "left",
1343
+ params: {
1344
+ count: 2,
1345
+ description: "( string, number )"
1346
+ },
1347
+ type: "string"
1348
+ },
1349
+ /**
1350
+ * len()
1351
+ */
1352
+ {
1353
+ accepts: "string",
1354
+ description: "Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",
1355
+ example: {
1356
+ expression: 'len("example")',
1357
+ result: "7"
1358
+ },
1359
+ name: "len",
1360
+ params: {
1361
+ description: "(string)"
1362
+ },
1363
+ type: "number"
1364
+ },
1365
+ /**
1366
+ * lower()
1367
+ */
1368
+ {
1369
+ accepts: "string",
1370
+ description: "Convert a string value to lowercase. Argument may be a string column or other string expression.",
1371
+ example: {
1372
+ expression: 'lower("examPLE")',
1373
+ result: '"example"'
1374
+ },
1375
+ name: "lower",
1376
+ params: {
1377
+ description: "( string )"
1378
+ },
1379
+ type: "string"
1380
+ },
1381
+ /**
1382
+ * upper()
1383
+ */
1384
+ {
1385
+ accepts: "string",
1386
+ description: "Convert a string value to uppercase. Argument may be a string column or other string expression.",
1387
+ example: {
1388
+ expression: 'upper("example")',
1389
+ result: '"EXAMPLE"'
1390
+ },
1391
+ name: "upper",
1392
+ params: {
1393
+ description: "( string )"
1394
+ },
1395
+ type: "string"
1396
+ },
1397
+ /**
1398
+ * right()
1399
+ */
1400
+ {
1401
+ accepts: ["string", "number"],
1402
+ description: "Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",
1403
+ example: {
1404
+ expression: "blah",
1405
+ result: "blah"
1406
+ },
1407
+ name: "right",
1408
+ params: {
1409
+ description: "( string )"
1410
+ },
1411
+ type: "string"
1412
+ },
1413
+ /**
1414
+ * replace()
1415
+ */
1416
+ {
1417
+ accepts: ["string", "string", "string"],
1418
+ description: "Replace characters within a string. Accepts three arguments: source text, text to replace and replacement text. Returns a copy of <source text> with any occurrences of <text to replace> replaced by <replacement text>",
1419
+ example: {
1420
+ expression: "blah",
1421
+ result: "blah"
1422
+ },
1423
+ name: "replace",
1424
+ params: {
1425
+ description: "( string )"
1426
+ },
1427
+ type: "string"
1428
+ },
1429
+ /**
1430
+ * text()
1431
+ */
1432
+ {
1433
+ accepts: "number",
1434
+ description: "Converts a number to a string.",
1435
+ example: {
1436
+ expression: "blah",
1437
+ result: "blah"
1438
+ },
1439
+ name: "text",
1440
+ params: {
1441
+ description: "( string )"
1442
+ },
1443
+ type: "string"
1444
+ },
1445
+ /**
1446
+ * starts()
1447
+ */
1448
+ {
1449
+ accepts: "string",
1450
+ description: "Tests a string value to determine whether it starts with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> starts with <target subscring>.",
1451
+ example: {
1452
+ expression: "blah",
1453
+ result: "blah"
1454
+ },
1455
+ name: "starts",
1456
+ params: {
1457
+ description: "( string )"
1458
+ },
1459
+ type: "boolean"
1460
+ },
1461
+ /**
1462
+ * starts()
1463
+ */
1464
+ {
1465
+ accepts: "string",
1466
+ description: "Tests a string value to determine whether it ends with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> ends with <target subscring>.",
1467
+ example: {
1468
+ expression: "blah",
1469
+ result: "blah"
1470
+ },
1471
+ name: "ends",
1472
+ params: {
1473
+ description: "( string )"
1474
+ },
1475
+ type: "boolean"
1476
+ },
1477
+ {
1478
+ accepts: "number",
1479
+ description: "blah",
1480
+ example: {
1481
+ expression: "blah",
1482
+ result: "blah"
1483
+ },
1484
+ name: "min",
1485
+ params: {
1486
+ description: "( string )"
1487
+ },
1488
+ type: "number"
1489
+ },
1490
+ {
1491
+ accepts: "number",
1492
+ description: "blah",
1493
+ example: {
1494
+ expression: "blah",
1495
+ result: "blah"
1496
+ },
1497
+ name: "max",
1498
+ params: {
1499
+ description: "( string )"
1500
+ },
1501
+ type: "number"
1502
+ },
1503
+ {
1504
+ accepts: "number",
1505
+ description: "blah",
1506
+ example: {
1507
+ expression: "blah",
1508
+ result: "blah"
1509
+ },
1510
+ name: "sum",
1511
+ params: {
1512
+ description: "( string )"
1513
+ },
1514
+ type: "number"
1515
+ },
1516
+ {
1517
+ accepts: "number",
1518
+ description: "blah",
1519
+ example: {
1520
+ expression: "blah",
1521
+ result: "blah"
1522
+ },
1523
+ name: "round",
1524
+ params: {
1525
+ description: "( string )"
1526
+ },
1527
+ type: "number"
1528
+ },
1529
+ {
1530
+ accepts: "any",
1531
+ description: "blah",
1532
+ example: {
1533
+ expression: "blah",
1534
+ result: "blah"
1535
+ },
1536
+ name: "or",
1537
+ params: {
1538
+ description: "( string )"
1539
+ },
1540
+ type: "boolean"
1541
+ },
1542
+ {
1543
+ accepts: "any",
1544
+ description: "blah",
1545
+ example: {
1546
+ expression: "blah",
1547
+ result: "blah"
1548
+ },
1549
+ name: "and",
1550
+ params: {
1551
+ description: "( string )"
1552
+ },
1553
+ type: "boolean"
1554
+ },
1555
+ {
1556
+ accepts: "any",
1557
+ description: "Return one of two possible result values, depending on the evaluation of a filter expression. If <filterExpression> resolves to true, result is <expression1>, otherwise <expression2>. ",
1558
+ example: {
1559
+ expression: "blah",
1560
+ result: "blah"
1561
+ },
1562
+ name: "if",
1563
+ params: {
1564
+ description: "( filterExpression, expression1, expression 2)"
1565
+ },
1566
+ type: "variable"
1567
+ }
1568
+ ];
1569
+
1570
+ // src/column-expression-input/functionDocInfo.ts
1571
+ import { createEl as createEl2 } from "@vuu-ui/vuu-utils";
1572
+ var functionDocInfo = ({
1573
+ name,
1574
+ description,
1575
+ example,
1576
+ params,
1577
+ type
1578
+ }) => {
1579
+ const rootElement = createEl2("div", "vuuFunctionDoc");
1580
+ const headingElement = createEl2("div", "function-heading");
1581
+ const nameElement = createEl2("span", "function-name", name);
1582
+ const paramElement = createEl2("span", "param-list", params.description);
1583
+ const typeElement = createEl2("span", "function-type", type);
1584
+ headingElement.appendChild(nameElement);
1585
+ headingElement.appendChild(paramElement);
1586
+ headingElement.appendChild(typeElement);
1587
+ const child2 = createEl2("p", void 0, description);
1588
+ rootElement.appendChild(headingElement);
1589
+ rootElement.appendChild(child2);
1590
+ if (example) {
1591
+ const exampleElement = createEl2("div", "example-container", "Example:");
1592
+ const expressionElement = createEl2(
1593
+ "div",
1594
+ "example-expression",
1595
+ example.expression
1596
+ );
1597
+ const resultElement = createEl2("div", "example-result", example.result);
1598
+ exampleElement.appendChild(expressionElement);
1599
+ exampleElement.appendChild(resultElement);
1600
+ rootElement.appendChild(exampleElement);
1601
+ }
1602
+ return rootElement;
1603
+ };
1604
+
1605
+ // src/column-expression-input/useColumnExpressionSuggestionProvider.ts
1606
+ var NO_OPERATORS = [];
1607
+ var withApplySpace = (suggestions) => suggestions.map((suggestion) => {
1608
+ var _a;
1609
+ return {
1610
+ ...suggestion,
1611
+ apply: ((_a = suggestion.apply) != null ? _a : suggestion.label) + " "
1612
+ };
1613
+ });
1614
+ var getValidColumns = (columns, { functionName, operator }) => {
1615
+ if (operator) {
1616
+ return columns.filter(isNumericColumn);
1617
+ } else if (functionName) {
1618
+ const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
1619
+ if (fn) {
1620
+ switch (fn.accepts) {
1621
+ case "string":
1622
+ return columns.filter(isTextColumn);
1623
+ case "number":
1624
+ return columns.filter(isNumericColumn);
1625
+ default:
1626
+ return columns;
1627
+ }
1628
+ }
1629
+ }
1630
+ return columns;
1631
+ };
1632
+ var getColumns = (columns, options) => {
1633
+ const validColumns = getValidColumns(columns, options);
1634
+ return validColumns.map((column) => {
1635
+ var _a;
1636
+ const label = (_a = column.label) != null ? _a : column.name;
1637
+ return {
1638
+ apply: options.prefix ? `${options.prefix}${label}` : label,
1639
+ label,
1640
+ boost: 5,
1641
+ type: "column",
1642
+ expressionType: column.serverDataType
1643
+ };
1644
+ });
1645
+ };
1646
+ var arithmeticOperators = [
1647
+ { apply: "* ", boost: 2, label: "*", type: "operator" },
1648
+ { apply: "/ ", boost: 2, label: "/", type: "operator" },
1649
+ { apply: "+ ", boost: 2, label: "+", type: "operator" },
1650
+ { apply: "- ", boost: 2, label: "-", type: "operator" }
1651
+ ];
1652
+ var getOperators = (column) => {
1653
+ if (column === void 0 || isNumericColumn(column)) {
1654
+ return arithmeticOperators;
1655
+ } else {
1656
+ return NO_OPERATORS;
1657
+ }
1658
+ };
1659
+ var getConditionOperators = (column) => {
1660
+ switch (column.serverDataType) {
1661
+ case "string":
1662
+ case "char":
1663
+ return withApplySpace(
1664
+ stringOperators
1665
+ /*, startsWith*/
1666
+ );
1667
+ case "int":
1668
+ case "long":
1669
+ case "double":
1670
+ return withApplySpace(numericOperators);
1671
+ }
1672
+ };
1673
+ var toFunctionCompletion = (functionDescriptor) => ({
1674
+ apply: `${functionDescriptor.name}( `,
1675
+ boost: 2,
1676
+ expressionType: functionDescriptor.type,
1677
+ info: () => functionDocInfo(functionDescriptor),
1678
+ label: functionDescriptor.name,
1679
+ type: "function"
1680
+ });
1681
+ var getAcceptedTypes = (fn) => {
1682
+ if (fn) {
1683
+ if (typeof fn.accepts === "string") {
1684
+ return fn.accepts;
1685
+ } else if (Array.isArray(fn.accepts)) {
1686
+ if (fn.accepts.every((s) => s === "string")) {
1687
+ return "string";
1688
+ } else {
1689
+ return "any";
1690
+ }
1691
+ }
1692
+ }
1693
+ return "any";
1694
+ };
1695
+ var functions = columnFunctionDescriptors.map(toFunctionCompletion);
1696
+ var getFunctions = ({ functionName }) => {
1697
+ if (functionName) {
1698
+ const fn = columnFunctionDescriptors.find((f) => f.name === functionName);
1699
+ const acceptedTypes = getAcceptedTypes(fn);
1700
+ if (fn) {
1701
+ switch (acceptedTypes) {
1702
+ case "string":
1703
+ return columnFunctionDescriptors.filter((f) => f.type === "string" || f.type === "variable").map(toFunctionCompletion);
1704
+ case "number":
1705
+ return columnFunctionDescriptors.filter((f) => f.type === "number" || f.type === "variable").map(toFunctionCompletion);
1706
+ default:
1707
+ }
1708
+ }
1709
+ }
1710
+ return functions;
1711
+ };
1712
+ var NONE = {};
1713
+ var useColumnExpressionSuggestionProvider = ({
1714
+ columns,
1715
+ table
1716
+ }) => {
1717
+ const findColumn = useCallback2(
1718
+ (name) => name ? columns.find((col) => col.name === name) : void 0,
1719
+ [columns]
1720
+ );
1721
+ const latestSuggestionsRef = useRef3();
1722
+ const getTypeaheadSuggestions = useTypeaheadSuggestions();
1723
+ const getSuggestions = useCallback2(
1724
+ async (suggestionType, options = NONE) => {
1725
+ const { columnName, functionName, operator, prefix } = options;
1726
+ switch (suggestionType) {
1727
+ case "expression": {
1728
+ const suggestions = await withApplySpace(
1729
+ getColumns(columns, { functionName, prefix })
1730
+ ).concat(getFunctions(options));
1731
+ return latestSuggestionsRef.current = suggestions;
1732
+ }
1733
+ case "column": {
1734
+ const suggestions = await getColumns(columns, options);
1735
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
1736
+ }
1737
+ case "operator": {
1738
+ const suggestions = await getOperators(findColumn(columnName));
1739
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
1740
+ }
1741
+ case "relational-operator": {
1742
+ const suggestions = await getRelationalOperators(
1743
+ findColumn(columnName)
1744
+ );
1745
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
1746
+ }
1747
+ case "condition-operator":
1748
+ {
1749
+ const column = findColumn(columnName);
1750
+ if (column) {
1751
+ const suggestions = await getConditionOperators(column);
1752
+ if (suggestions) {
1753
+ return latestSuggestionsRef.current = withApplySpace(suggestions);
1754
+ }
1755
+ }
1756
+ }
1757
+ break;
1758
+ case "columnValue":
1759
+ if (columnName && operator) {
1760
+ const params = getTypeaheadParams(
1761
+ table,
1762
+ columnName
1763
+ /*, startsWith*/
1764
+ );
1765
+ const suggestions = await getTypeaheadSuggestions(params);
1766
+ latestSuggestionsRef.current = toSuggestions(suggestions, {
1767
+ suffix: ""
1768
+ });
1769
+ latestSuggestionsRef.current.forEach((suggestion) => {
1770
+ suggestion.apply = (view, completion, from) => {
1771
+ const annotation = new AnnotationType();
1772
+ const cursorPos = from + completion.label.length + 1;
1773
+ view.dispatch({
1774
+ changes: { from, insert: completion.label },
1775
+ selection: { anchor: cursorPos, head: cursorPos },
1776
+ annotations: annotation.of(completion)
1777
+ });
1778
+ };
1779
+ });
1780
+ return latestSuggestionsRef.current;
1781
+ }
1782
+ break;
1783
+ }
1784
+ return [];
1785
+ },
1786
+ [columns, findColumn, getTypeaheadSuggestions, table]
1787
+ );
1788
+ const isPartialMatch = useCallback2(
1789
+ async (valueType, columnName, pattern) => {
1790
+ const { current: latestSuggestions } = latestSuggestionsRef;
1791
+ let maybe = false;
1792
+ const suggestions = latestSuggestions || await getSuggestions(valueType, { columnName });
1793
+ if (pattern && suggestions) {
1794
+ for (const option of suggestions) {
1795
+ if (option.label === pattern) {
1796
+ return false;
1797
+ } else if (option.label.startsWith(pattern)) {
1798
+ maybe = true;
1799
+ }
1800
+ }
1801
+ }
1802
+ return maybe;
1803
+ },
1804
+ [getSuggestions]
1805
+ );
1806
+ return {
1807
+ getSuggestions,
1808
+ isPartialMatch
1809
+ };
1810
+ };
1811
+
1812
+ // src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
1813
+ import { Button as Button3, Panel as Panel5 } from "@salt-ds/core";
1814
+ import cx5 from "classnames";
1815
+ import {
1816
+ useCallback as useCallback8,
1817
+ useState as useState4
1818
+ } from "react";
1819
+
1820
+ // src/datagrid-configuration-ui/column-picker/ColumnPicker.tsx
1821
+ import { List } from "@heswell/salt-lab";
1822
+ import { Button, Text, useIdMemo as useId } from "@salt-ds/core";
1823
+ import { useCallback as useCallback3, useState } from "react";
1824
+
1825
+ // src/datagrid-configuration-ui/column-picker/ColumnListItem.tsx
1826
+ import { ListItem } from "@heswell/salt-lab";
1827
+ import cx2 from "classnames";
1828
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1829
+ var classBase3 = "vuuColumnListItem";
1830
+ var ColumnListItem = ({
1831
+ className: classNameProp,
1832
+ item,
1833
+ label,
1834
+ style: styleProp,
1835
+ ...restProps
1836
+ }) => {
1837
+ const className = cx2(classBase3, classNameProp, {
1838
+ [`${classBase3}-calculated`]: item == null ? void 0 : item.expression,
1839
+ [`${classBase3}-hidden`]: item == null ? void 0 : item.hidden
1840
+ });
1841
+ return /* @__PURE__ */ jsxs2(ListItem, { className, ...restProps, children: [
1842
+ /* @__PURE__ */ jsx3("span", { className: `${classBase3}-iconType` }),
1843
+ /* @__PURE__ */ jsx3("label", { className: `${classBase3}-label`, children: label }),
1844
+ /* @__PURE__ */ jsx3("span", { className: `${classBase3}-iconHidden` })
1845
+ ] });
1846
+ };
1847
+
1848
+ // src/datagrid-configuration-ui/column-picker/ColumnPicker.tsx
1849
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1850
+ var classBase4 = "vuuColumnPicker";
1851
+ var removeSelectedColumns = (availableColumns, selectedColumns) => {
1852
+ return availableColumns.filter(
1853
+ (column) => selectedColumns.find((col) => col.name === column.name) == null
1854
+ );
1855
+ };
1856
+ var ColumnPicker = ({
1857
+ availableColumns,
1858
+ id: idProp,
1859
+ dispatchColumnAction: dispatch,
1860
+ onAddCalculatedColumnClick,
1861
+ onSelectionChange,
1862
+ chosenColumns,
1863
+ selectedColumn
1864
+ }) => {
1865
+ const [selected1, setSelected1] = useState([]);
1866
+ const id = useId(idProp);
1867
+ const unusedColumns = removeSelectedColumns(availableColumns, chosenColumns);
1868
+ const addColumn2 = useCallback3(() => {
1869
+ if (selected1.length > 0) {
1870
+ setSelected1([]);
1871
+ dispatch({ type: "addColumn", columns: selected1 });
1872
+ }
1873
+ }, [dispatch, selected1]);
1874
+ const removeColumn2 = useCallback3(
1875
+ () => selectedColumn && dispatch({ type: "removeColumn", column: selectedColumn }),
1876
+ [selectedColumn, dispatch]
1877
+ );
1878
+ const moveColumnUp = useCallback3(
1879
+ () => selectedColumn && dispatch({ type: "moveColumn", column: selectedColumn, moveBy: -1 }),
1880
+ [dispatch, selectedColumn]
1881
+ );
1882
+ const moveColumnDown = useCallback3(
1883
+ () => selectedColumn && dispatch({ type: "moveColumn", column: selectedColumn, moveBy: 1 }),
1884
+ [dispatch, selectedColumn]
1885
+ );
1886
+ const handleSelectionChange1 = useCallback3(
1887
+ (evt, selected) => setSelected1(selected),
1888
+ []
1889
+ );
1890
+ const handleSelectionChange2 = useCallback3(
1891
+ (evt, selected) => onSelectionChange == null ? void 0 : onSelectionChange(selected),
1892
+ [onSelectionChange]
1893
+ );
1894
+ const handleDrop = useCallback3(
1895
+ (moveFrom, moveTo) => {
1896
+ dispatch({ type: "moveColumn", moveFrom, moveTo });
1897
+ },
1898
+ [dispatch]
1899
+ );
1900
+ return /* @__PURE__ */ jsxs3("div", { className: classBase4, id, children: [
1901
+ /* @__PURE__ */ jsxs3("div", { className: `${classBase4}-listColumn`, children: [
1902
+ /* @__PURE__ */ jsx4("label", { htmlFor: `available-${id}`, children: /* @__PURE__ */ jsx4(Text, { as: "h4", children: "Available Columns" }) }),
1903
+ /* @__PURE__ */ jsx4(
1904
+ "div",
1905
+ {
1906
+ className: `${classBase4}-listContainer`,
1907
+ style: { flex: 1, overflow: "hidden" },
1908
+ children: /* @__PURE__ */ jsx4(
1909
+ List,
1910
+ {
1911
+ borderless: true,
1912
+ checkable: false,
1913
+ height: "100%",
1914
+ id: `available-${id}`,
1915
+ itemHeight: 24,
1916
+ itemToString: (item) => item.name,
1917
+ onSelectionChange: handleSelectionChange1,
1918
+ selected: selected1,
1919
+ selectionStrategy: "extended",
1920
+ source: unusedColumns
1921
+ }
1922
+ )
1923
+ }
1924
+ ),
1925
+ /* @__PURE__ */ jsx4(
1926
+ "div",
1927
+ {
1928
+ style: {
1929
+ display: "flex",
1930
+ alignItems: "center",
1931
+ flex: "0 0 32px",
1932
+ marginTop: "var(--salt-size-basis-unit)"
1933
+ },
1934
+ children: /* @__PURE__ */ jsxs3(Button, { onClick: addColumn2, disabled: selected1.length === 0, children: [
1935
+ "Show",
1936
+ /* @__PURE__ */ jsx4("span", { "data-icon": "arrow-thin-right", style: { marginLeft: 8 } })
1937
+ ] })
1938
+ }
1939
+ )
1940
+ ] }),
1941
+ /* @__PURE__ */ jsxs3("div", { className: `${classBase4}-listColumn`, children: [
1942
+ /* @__PURE__ */ jsx4("label", { htmlFor: `selected-${id}`, children: /* @__PURE__ */ jsx4(Text, { as: "h4", children: "Included Columns" }) }),
1943
+ /* @__PURE__ */ jsx4(
1944
+ "div",
1945
+ {
1946
+ className: `${classBase4}-listContainer`,
1947
+ style: { flex: 1, overflow: "hidden" },
1948
+ children: /* @__PURE__ */ jsx4(
1949
+ List,
1950
+ {
1951
+ ListItem: ColumnListItem,
1952
+ allowDragDrop: true,
1953
+ borderless: true,
1954
+ height: "100%",
1955
+ id: `selected-${id}`,
1956
+ itemHeight: 24,
1957
+ itemToString: (item) => item.name,
1958
+ onMoveListItem: handleDrop,
1959
+ onSelectionChange: handleSelectionChange2,
1960
+ selected: selectedColumn,
1961
+ style: { flex: 1 },
1962
+ source: chosenColumns
1963
+ }
1964
+ )
1965
+ }
1966
+ ),
1967
+ /* @__PURE__ */ jsxs3(
1968
+ "div",
1969
+ {
1970
+ style: {
1971
+ alignItems: "center",
1972
+ flex: "0 0 32px",
1973
+ display: "flex",
1974
+ gap: 6,
1975
+ marginTop: "var(--salt-size-basis-unit)"
1976
+ },
1977
+ children: [
1978
+ /* @__PURE__ */ jsxs3(Button, { onClick: removeColumn2, disabled: selectedColumn === null, children: [
1979
+ /* @__PURE__ */ jsx4("span", { "data-icon": "arrow-thin-left", style: { marginRight: 8 } }),
1980
+ "Hide"
1981
+ ] }),
1982
+ /* @__PURE__ */ jsx4(
1983
+ Button,
1984
+ {
1985
+ "aria-label": "Move column up",
1986
+ onClick: moveColumnUp,
1987
+ disabled: selectedColumn === null || (chosenColumns == null ? void 0 : chosenColumns.indexOf(selectedColumn)) === 0,
1988
+ style: { width: 28 },
1989
+ children: /* @__PURE__ */ jsx4("span", { "data-icon": "arrow-thin-up" })
1990
+ }
1991
+ ),
1992
+ /* @__PURE__ */ jsx4(
1993
+ Button,
1994
+ {
1995
+ "aria-label": "Move column down",
1996
+ onClick: moveColumnDown,
1997
+ disabled: selectedColumn === null || chosenColumns.indexOf(selectedColumn) === chosenColumns.length - 1,
1998
+ style: { width: 28 },
1999
+ children: /* @__PURE__ */ jsx4("span", { "data-icon": "arrow-thin-down" })
2000
+ }
2001
+ ),
2002
+ /* @__PURE__ */ jsx4(
2003
+ Button,
2004
+ {
2005
+ "aria-label": "Add calculated column",
2006
+ className: `${classBase4}-addCalculatedColumn`,
2007
+ onClick: onAddCalculatedColumnClick,
2008
+ variant: "primary",
2009
+ children: /* @__PURE__ */ jsx4("span", { "data-icon": "add" })
2010
+ }
2011
+ )
2012
+ ]
2013
+ }
2014
+ )
2015
+ ] })
2016
+ ] });
2017
+ };
2018
+
2019
+ // src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
2020
+ import { Stack } from "@vuu-ui/vuu-layout";
2021
+ import {
2022
+ Checkbox,
2023
+ FormField as FormField2,
2024
+ Input,
2025
+ RadioButton,
2026
+ RadioButtonGroup,
2027
+ StepperInput as StepperInput2
2028
+ } from "@heswell/salt-lab";
2029
+ import { Panel as Panel2, Text as Text3 } from "@salt-ds/core";
2030
+ import cx4 from "classnames";
2031
+ import {
2032
+ useCallback as useCallback5,
2033
+ useState as useState2
2034
+ } from "react";
2035
+
2036
+ // src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
2037
+ import { getRegisteredCellRenderers } from "@vuu-ui/vuu-utils";
2038
+ import { Dropdown } from "@heswell/salt-lab";
2039
+ import { Panel } from "@salt-ds/core";
2040
+ import cx3 from "classnames";
2041
+ import { useMemo as useMemo2 } from "react";
2042
+
2043
+ // src/datagrid-configuration-ui/column-type-panel/NumericColumnPanel.tsx
2044
+ import { FormField, StepperInput, Switch } from "@heswell/salt-lab";
2045
+ import { Text as Text2 } from "@salt-ds/core";
2046
+ import { useCallback as useCallback4 } from "react";
2047
+ import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
2048
+ var defaultValues = {
2049
+ alignOnDecimals: false,
2050
+ decimals: 4,
2051
+ zeroPad: false
2052
+ };
2053
+ var getColumnValues = (columnType, gridDefaultValues) => {
2054
+ const columnValue = typeof columnType === "object" && columnType.formatting ? columnType.formatting : {};
2055
+ const properties = ["alignOnDecimals", "decimals", "zeroPad"];
2056
+ return properties.reduce((configValues, property) => {
2057
+ if (columnValue[property] !== void 0) {
2058
+ return {
2059
+ ...configValues,
2060
+ [property]: columnValue[property]
2061
+ };
2062
+ } else if ((gridDefaultValues == null ? void 0 : gridDefaultValues[property]) !== void 0) {
2063
+ return {
2064
+ ...configValues,
2065
+ [property]: gridDefaultValues[property]
2066
+ };
2067
+ }
2068
+ return configValues;
2069
+ }, defaultValues);
2070
+ };
2071
+ var NumericColumnPanel = ({
2072
+ column,
2073
+ dispatchColumnAction
2074
+ }) => {
2075
+ const { decimals, alignOnDecimals, zeroPad } = getColumnValues(column == null ? void 0 : column.type);
2076
+ const dispatchUpdate = useCallback4(
2077
+ (values) => dispatchColumnAction({
2078
+ type: "updateColumnTypeFormatting",
2079
+ column,
2080
+ ...values
2081
+ }),
2082
+ [column, dispatchColumnAction]
2083
+ );
2084
+ const handleChangeDecimals = useCallback4(
2085
+ (value) => dispatchUpdate({ decimals: parseInt(value.toString(), 10) }),
2086
+ [dispatchUpdate]
2087
+ );
2088
+ const handleChangeAlignOnDecimals = useCallback4(
2089
+ (evt, value) => dispatchUpdate({ alignOnDecimals: value }),
2090
+ [dispatchUpdate]
2091
+ );
2092
+ const handleChangeZeroPad = useCallback4(
2093
+ (evt, value) => dispatchUpdate({ zeroPad: value }),
2094
+ [dispatchUpdate]
2095
+ );
2096
+ switch (column.serverDataType) {
2097
+ case "double":
2098
+ return /* @__PURE__ */ jsxs4(Fragment, { children: [
2099
+ /* @__PURE__ */ jsx5(FormField, { label: "No of Decimals", labelPlacement: "top", children: /* @__PURE__ */ jsx5(StepperInput, { value: decimals, onChange: handleChangeDecimals }) }),
2100
+ /* @__PURE__ */ jsx5(
2101
+ Switch,
2102
+ {
2103
+ checked: alignOnDecimals,
2104
+ label: "Align on decimals",
2105
+ LabelProps: { className: "vuuColumnPanelSwitch" },
2106
+ onChange: handleChangeAlignOnDecimals
2107
+ }
2108
+ ),
2109
+ /* @__PURE__ */ jsx5(
2110
+ Switch,
2111
+ {
2112
+ checked: zeroPad,
2113
+ label: "Zero pad",
2114
+ LabelProps: { className: "vuuColumnPanelSwitch" },
2115
+ onChange: handleChangeZeroPad
2116
+ }
2117
+ )
2118
+ ] });
2119
+ case "long":
2120
+ case "int":
2121
+ return /* @__PURE__ */ jsx5(Fragment, { children: /* @__PURE__ */ jsx5(Text2, { children: "Work in progress" }) });
2122
+ default:
2123
+ return null;
2124
+ }
2125
+ };
2126
+
2127
+ // src/datagrid-configuration-ui/column-type-panel/StringColumnPanel.tsx
2128
+ import { Fragment as Fragment2, jsx as jsx6 } from "react/jsx-runtime";
2129
+ var StringColumnPanel = ({
2130
+ column,
2131
+ dispatchColumnAction
2132
+ }) => {
2133
+ return /* @__PURE__ */ jsx6(Fragment2, { children: "String" });
2134
+ };
2135
+
2136
+ // src/datagrid-configuration-ui/column-type-panel/ColumnTypePanel.tsx
2137
+ import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
2138
+ var classBase5 = "vuuColumnTypePanel";
2139
+ var integerCellRenderers = ["Default Renderer (int, long)"];
2140
+ var doubleCellRenderers = ["Default Renderer (double)"];
2141
+ var stringCellRenderers = ["Default Renderer (string)"];
2142
+ var getAvailableCellRenderers = (column) => {
2143
+ const customCellRenderers = getRegisteredCellRenderers(column.serverDataType);
2144
+ const customRendererNames = customCellRenderers.map((r) => r.name);
2145
+ console.log({ customRendererNames });
2146
+ switch (column.serverDataType) {
2147
+ case "char":
2148
+ case "string":
2149
+ return stringCellRenderers;
2150
+ case "int":
2151
+ case "long":
2152
+ return integerCellRenderers;
2153
+ case "double":
2154
+ return doubleCellRenderers.concat(customRendererNames);
2155
+ default:
2156
+ return stringCellRenderers;
2157
+ }
2158
+ };
2159
+ var ColumnTypePanel = ({
2160
+ className,
2161
+ column,
2162
+ dispatchColumnAction,
2163
+ ...props
2164
+ }) => {
2165
+ const content = useMemo2(() => {
2166
+ switch (column.serverDataType) {
2167
+ case "double":
2168
+ case "int":
2169
+ case "long":
2170
+ return /* @__PURE__ */ jsx7(
2171
+ NumericColumnPanel,
2172
+ {
2173
+ column,
2174
+ dispatchColumnAction
2175
+ }
2176
+ );
2177
+ default:
2178
+ return /* @__PURE__ */ jsx7(
2179
+ StringColumnPanel,
2180
+ {
2181
+ column,
2182
+ dispatchColumnAction
2183
+ }
2184
+ );
2185
+ }
2186
+ }, [column, dispatchColumnAction]);
2187
+ const { serverDataType = "string" } = column;
2188
+ const availableRenderers = getAvailableCellRenderers(column);
2189
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
2190
+ /* @__PURE__ */ jsx7(
2191
+ Dropdown,
2192
+ {
2193
+ className: cx3(`${classBase5}-renderer`),
2194
+ fullWidth: true,
2195
+ selected: availableRenderers[0],
2196
+ source: availableRenderers
2197
+ }
2198
+ ),
2199
+ /* @__PURE__ */ jsx7(
2200
+ Panel,
2201
+ {
2202
+ ...props,
2203
+ className: cx3(classBase5, className, `${classBase5}-${serverDataType}`),
2204
+ children: content
2205
+ }
2206
+ )
2207
+ ] });
2208
+ };
2209
+
2210
+ // src/datagrid-configuration-ui/column-settings-panel/ColumnSettingsPanel.tsx
2211
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
2212
+ var classBase6 = "vuuColumnSettingsPanel";
2213
+ var tabstripProps = {
2214
+ className: "salt-density-high"
2215
+ };
2216
+ var NullActivationIndicator = () => null;
2217
+ var ColumnSettingsPanel = ({
2218
+ column,
2219
+ dispatchColumnAction,
2220
+ style: styleProp,
2221
+ ...props
2222
+ }) => {
2223
+ var _a, _b, _c, _d;
2224
+ const [activeTab, setActiveTab] = useState2(0);
2225
+ const dispatchUpdate = useCallback5(
2226
+ (values) => dispatchColumnAction({
2227
+ type: "updateColumnProp",
2228
+ column,
2229
+ ...values
2230
+ }),
2231
+ [column, dispatchColumnAction]
2232
+ );
2233
+ const handleChangeAlign = useCallback5(
2234
+ (evt) => dispatchUpdate({ align: evt.target.value }),
2235
+ [dispatchUpdate]
2236
+ );
2237
+ const handleChangePin = useCallback5(
2238
+ (evt) => dispatchUpdate({ pin: evt.target.value }),
2239
+ [dispatchUpdate]
2240
+ );
2241
+ const handleChangeHidden = useCallback5(
2242
+ (evt, value) => dispatchUpdate({ hidden: value }),
2243
+ [dispatchUpdate]
2244
+ );
2245
+ const handleChangeLabel = useCallback5(
2246
+ (evt, value) => dispatchUpdate({ label: value }),
2247
+ [dispatchUpdate]
2248
+ );
2249
+ const handleChangeWidth = useCallback5(
2250
+ (value) => dispatchUpdate({ width: parseInt(value.toString(), 10) }),
2251
+ [dispatchUpdate]
2252
+ );
2253
+ return /* @__PURE__ */ jsxs6(
2254
+ "div",
2255
+ {
2256
+ className: classBase6,
2257
+ ...props,
2258
+ style: {
2259
+ ...styleProp
2260
+ },
2261
+ children: [
2262
+ /* @__PURE__ */ jsx8(Text3, { as: "h4", children: "Column Settings" }),
2263
+ /* @__PURE__ */ jsxs6(
2264
+ Stack,
2265
+ {
2266
+ active: activeTab,
2267
+ showTabs: true,
2268
+ className: cx4(`${classBase6}-columnTabs`),
2269
+ onTabSelectionChanged: setActiveTab,
2270
+ TabstripProps: tabstripProps,
2271
+ children: [
2272
+ /* @__PURE__ */ jsxs6(Panel2, { title: "Column", children: [
2273
+ /* @__PURE__ */ jsx8(FormField2, { label: "Hidden", labelPlacement: "left", children: /* @__PURE__ */ jsx8(
2274
+ Checkbox,
2275
+ {
2276
+ checked: column.hidden === true,
2277
+ onChange: handleChangeHidden
2278
+ }
2279
+ ) }),
2280
+ /* @__PURE__ */ jsx8(FormField2, { label: "Label", labelPlacement: "left", children: /* @__PURE__ */ jsx8(
2281
+ Input,
2282
+ {
2283
+ value: (_a = column.label) != null ? _a : column.name,
2284
+ onChange: handleChangeLabel
2285
+ }
2286
+ ) }),
2287
+ /* @__PURE__ */ jsx8(FormField2, { label: "Width", labelPlacement: "left", children: /* @__PURE__ */ jsx8(
2288
+ StepperInput2,
2289
+ {
2290
+ value: (_b = column.width) != null ? _b : 100,
2291
+ onChange: handleChangeWidth
2292
+ }
2293
+ ) }),
2294
+ /* @__PURE__ */ jsx8(
2295
+ FormField2,
2296
+ {
2297
+ label: "Align",
2298
+ labelPlacement: "left",
2299
+ ActivationIndicatorComponent: NullActivationIndicator,
2300
+ children: /* @__PURE__ */ jsxs6(
2301
+ RadioButtonGroup,
2302
+ {
2303
+ "aria-label": "Column Align",
2304
+ value: (_c = column.align) != null ? _c : "left",
2305
+ legend: "Align",
2306
+ onChange: handleChangeAlign,
2307
+ children: [
2308
+ /* @__PURE__ */ jsx8(RadioButton, { label: "Left", value: "left" }),
2309
+ /* @__PURE__ */ jsx8(RadioButton, { label: "Right", value: "right" })
2310
+ ]
2311
+ }
2312
+ )
2313
+ }
2314
+ ),
2315
+ /* @__PURE__ */ jsx8(
2316
+ FormField2,
2317
+ {
2318
+ label: "Pin Column",
2319
+ labelPlacement: "left",
2320
+ ActivationIndicatorComponent: NullActivationIndicator,
2321
+ children: /* @__PURE__ */ jsxs6(
2322
+ RadioButtonGroup,
2323
+ {
2324
+ "aria-label": "Pin Column",
2325
+ value: (_d = column.pin) != null ? _d : "",
2326
+ legend: "Pin Column",
2327
+ onChange: handleChangePin,
2328
+ children: [
2329
+ /* @__PURE__ */ jsx8(RadioButton, { label: "Do not pin", value: "" }),
2330
+ /* @__PURE__ */ jsx8(RadioButton, { label: "Left", value: "left" }),
2331
+ /* @__PURE__ */ jsx8(RadioButton, { label: "Right", value: "right" })
2332
+ ]
2333
+ }
2334
+ )
2335
+ }
2336
+ )
2337
+ ] }),
2338
+ /* @__PURE__ */ jsx8(
2339
+ ColumnTypePanel,
2340
+ {
2341
+ column,
2342
+ dispatchColumnAction,
2343
+ title: "Data Cell"
2344
+ }
2345
+ ),
2346
+ /* @__PURE__ */ jsxs6(Panel2, { title: "Vuu", variant: "secondary", children: [
2347
+ /* @__PURE__ */ jsx8(
2348
+ FormField2,
2349
+ {
2350
+ label: "Name",
2351
+ labelPlacement: "top",
2352
+ readOnly: true,
2353
+ variant: "secondary",
2354
+ children: /* @__PURE__ */ jsx8(Input, { value: column.name })
2355
+ }
2356
+ ),
2357
+ /* @__PURE__ */ jsx8(
2358
+ FormField2,
2359
+ {
2360
+ label: "Vuu type",
2361
+ labelPlacement: "top",
2362
+ readOnly: true,
2363
+ variant: "secondary",
2364
+ children: /* @__PURE__ */ jsx8(Input, { value: column.serverDataType })
2365
+ }
2366
+ )
2367
+ ] })
2368
+ ]
2369
+ }
2370
+ )
2371
+ ]
2372
+ }
2373
+ );
2374
+ };
2375
+
2376
+ // src/datagrid-configuration-ui/settings-panel/GridSettingsPanel.tsx
2377
+ import {
2378
+ FormField as FormField3,
2379
+ RadioButton as RadioButton2,
2380
+ RadioButtonGroup as RadioButtonGroup2,
2381
+ StepperInput as StepperInput3
2382
+ } from "@heswell/salt-lab";
2383
+ import { Panel as Panel3, Text as Text4 } from "@salt-ds/core";
2384
+ import { useCallback as useCallback6 } from "react";
2385
+ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
2386
+ var classBase7 = "vuuGridSettingsPanel";
2387
+ var NullActivationIndicator2 = () => null;
2388
+ var GridSettingsPanel = ({
2389
+ config,
2390
+ dispatchColumnAction,
2391
+ style: styleProp,
2392
+ ...props
2393
+ }) => {
2394
+ var _a;
2395
+ const dispatchUpdate = useCallback6(
2396
+ (values) => dispatchColumnAction({
2397
+ type: "updateGridSettings",
2398
+ ...values
2399
+ }),
2400
+ [dispatchColumnAction]
2401
+ );
2402
+ const handleChangeLabelFormatting = useCallback6(
2403
+ (evt) => dispatchUpdate({
2404
+ columnFormatHeader: evt.target.value
2405
+ }),
2406
+ [dispatchUpdate]
2407
+ );
2408
+ const handleChangeWidth = useCallback6(
2409
+ (value) => dispatchUpdate({ columnDefaultWidth: parseInt(value.toString(), 10) }),
2410
+ [dispatchUpdate]
2411
+ );
2412
+ console.log(`GridSettingsPanel ${JSON.stringify(config.columns, null, 2)}`);
2413
+ return /* @__PURE__ */ jsxs7(
2414
+ "div",
2415
+ {
2416
+ className: classBase7,
2417
+ ...props,
2418
+ style: {
2419
+ ...styleProp
2420
+ },
2421
+ children: [
2422
+ /* @__PURE__ */ jsx9(Text4, { as: "h4", children: "Grid Settings" }),
2423
+ /* @__PURE__ */ jsxs7(Panel3, { children: [
2424
+ /* @__PURE__ */ jsx9(
2425
+ FormField3,
2426
+ {
2427
+ label: "Format column labels",
2428
+ labelPlacement: "left",
2429
+ ActivationIndicatorComponent: NullActivationIndicator2,
2430
+ children: /* @__PURE__ */ jsxs7(
2431
+ RadioButtonGroup2,
2432
+ {
2433
+ "aria-label": "Format column labels",
2434
+ value: config.columnFormatHeader,
2435
+ legend: "Format column labels",
2436
+ onChange: handleChangeLabelFormatting,
2437
+ children: [
2438
+ /* @__PURE__ */ jsx9(RadioButton2, { label: "No Formatting", value: void 0 }),
2439
+ /* @__PURE__ */ jsx9(RadioButton2, { label: "Capitalize", value: "capitalize" }),
2440
+ /* @__PURE__ */ jsx9(RadioButton2, { label: "Uppercase", value: "uppercase" })
2441
+ ]
2442
+ }
2443
+ )
2444
+ }
2445
+ ),
2446
+ /* @__PURE__ */ jsx9(FormField3, { label: "Default Column Width", labelPlacement: "left", children: /* @__PURE__ */ jsx9(
2447
+ StepperInput3,
2448
+ {
2449
+ value: (_a = config.columnDefaultWidth) != null ? _a : 100,
2450
+ onChange: handleChangeWidth
2451
+ }
2452
+ ) })
2453
+ ] })
2454
+ ]
2455
+ }
2456
+ );
2457
+ };
2458
+
2459
+ // src/datagrid-configuration-ui/settings-panel/useGridSettings.ts
2460
+ import { useReducer } from "react";
2461
+ import { moveItem } from "@heswell/salt-lab";
2462
+ import { fromServerDataType } from "@vuu-ui/vuu-utils";
2463
+ var gridSettingsReducer = (state, action) => {
2464
+ console.log(`gridSettingsReducer ${action.type}`);
2465
+ switch (action.type) {
2466
+ case "addColumn":
2467
+ return addColumn(state, action);
2468
+ case "addCalculatedColumn":
2469
+ return addCalculatedColumn(state, action);
2470
+ case "moveColumn":
2471
+ return moveColumn(state, action);
2472
+ case "removeColumn":
2473
+ return removeColumn(state, action);
2474
+ case "updateColumn":
2475
+ return state;
2476
+ case "updateColumnProp":
2477
+ return updateColumnProp(state, action);
2478
+ case "updateGridSettings":
2479
+ return updateGridSettings(state, action);
2480
+ case "updateColumnTypeFormatting":
2481
+ return updateColumnTypeFormatting(state, action);
2482
+ default:
2483
+ return state;
2484
+ }
2485
+ };
2486
+ var useGridSettings = (config) => {
2487
+ const [state, dispatchColumnAction] = useReducer(
2488
+ gridSettingsReducer,
2489
+ config
2490
+ );
2491
+ return {
2492
+ gridSettings: state,
2493
+ dispatchColumnAction
2494
+ };
2495
+ };
2496
+ function addColumn(state, { column, columns, index = -1 }) {
2497
+ const { columns: stateColumns } = state;
2498
+ if (index === -1) {
2499
+ if (Array.isArray(columns)) {
2500
+ return { ...state, columns: stateColumns.concat(columns) };
2501
+ } else if (column) {
2502
+ return { ...state, columns: stateColumns.concat(column) };
2503
+ }
2504
+ }
2505
+ return state;
2506
+ }
2507
+ function addCalculatedColumn(state, { columnName, columnType, expression }) {
2508
+ const { columns: stateColumns } = state;
2509
+ const calculatedColumn = {
2510
+ name: columnName,
2511
+ expression,
2512
+ serverDataType: columnType
2513
+ };
2514
+ return { ...state, columns: stateColumns.concat(calculatedColumn) };
2515
+ }
2516
+ function removeColumn(state, { column }) {
2517
+ const { columns: stateColumns } = state;
2518
+ return {
2519
+ ...state,
2520
+ columns: stateColumns.filter((col) => col.name !== column.name)
2521
+ };
2522
+ }
2523
+ function moveColumn(state, { column, moveBy, moveFrom, moveTo }) {
2524
+ const { columns: stateColumns } = state;
2525
+ if (column && typeof moveBy === "number") {
2526
+ const idx = stateColumns.indexOf(column);
2527
+ const newColumns = stateColumns.slice();
2528
+ const [movedColumns] = newColumns.splice(idx, 1);
2529
+ newColumns.splice(idx + moveBy, 0, movedColumns);
2530
+ return {
2531
+ ...state,
2532
+ columns: newColumns
2533
+ };
2534
+ } else if (typeof moveFrom === "number" && typeof moveTo === "number") {
2535
+ return {
2536
+ ...state,
2537
+ columns: moveItem(stateColumns, moveFrom, moveTo)
2538
+ };
2539
+ } else {
2540
+ return state;
2541
+ }
2542
+ }
2543
+ function updateColumnProp(state, { align, column, hidden, label, width }) {
2544
+ let { columns: stateColumns } = state;
2545
+ if (align === "left" || align === "right") {
2546
+ stateColumns = replaceColumn(stateColumns, { ...column, align });
2547
+ }
2548
+ if (typeof hidden === "boolean") {
2549
+ stateColumns = replaceColumn(stateColumns, { ...column, hidden });
2550
+ }
2551
+ if (typeof label === "string") {
2552
+ stateColumns = replaceColumn(stateColumns, { ...column, label });
2553
+ }
2554
+ if (typeof width === "number") {
2555
+ stateColumns = replaceColumn(stateColumns, { ...column, width });
2556
+ }
2557
+ return {
2558
+ ...state,
2559
+ columns: stateColumns
2560
+ };
2561
+ }
2562
+ function updateGridSettings(state, { columnFormatHeader }) {
2563
+ return {
2564
+ ...state,
2565
+ columnFormatHeader: columnFormatHeader != null ? columnFormatHeader : state.columnFormatHeader
2566
+ };
2567
+ }
2568
+ function updateColumnTypeFormatting(state, {
2569
+ alignOnDecimals,
2570
+ column,
2571
+ decimals,
2572
+ zeroPad
2573
+ }) {
2574
+ const { columns: stateColumns } = state;
2575
+ const targetColumn = stateColumns.find((col) => col.name === column.name);
2576
+ if (targetColumn) {
2577
+ const {
2578
+ serverDataType = "string",
2579
+ type: columnType = fromServerDataType(serverDataType)
2580
+ } = column;
2581
+ const type = typeof columnType === "string" ? {
2582
+ name: columnType
2583
+ } : {
2584
+ ...columnType
2585
+ };
2586
+ if (typeof alignOnDecimals === "boolean") {
2587
+ type.formatting = {
2588
+ ...type.formatting,
2589
+ alignOnDecimals
2590
+ };
2591
+ }
2592
+ if (typeof decimals === "number") {
2593
+ type.formatting = {
2594
+ ...type.formatting,
2595
+ decimals
2596
+ };
2597
+ }
2598
+ if (typeof zeroPad === "boolean") {
2599
+ type.formatting = {
2600
+ ...type.formatting,
2601
+ zeroPad
2602
+ };
2603
+ }
2604
+ return {
2605
+ ...state,
2606
+ columns: replaceColumn(stateColumns, { ...column, type })
2607
+ };
2608
+ } else {
2609
+ return state;
2610
+ }
2611
+ }
2612
+ function replaceColumn(columns, column) {
2613
+ return columns.map((col) => col.name === column.name ? column : col);
2614
+ }
2615
+
2616
+ // src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
2617
+ import { Stack as Stack2 } from "@vuu-ui/vuu-layout";
2618
+
2619
+ // src/datagrid-configuration-ui/calculated-column-panel/CalculatedColumnPanel.tsx
2620
+ import { FormField as FormField4, Input as Input2 } from "@heswell/salt-lab";
2621
+ import { Button as Button2, Panel as Panel4, Text as Text5 } from "@salt-ds/core";
2622
+ import {
2623
+ useCallback as useCallback7,
2624
+ useRef as useRef4,
2625
+ useState as useState3
2626
+ } from "react";
2627
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
2628
+ var CalculatedColumnPanel = ({
2629
+ columns,
2630
+ dispatchColumnAction,
2631
+ table
2632
+ }) => {
2633
+ const [columnName, setColumnName] = useState3("");
2634
+ const [, setExpression] = useState3();
2635
+ const sourceRef = useRef4("");
2636
+ const suggestionProvider = useColumnExpressionSuggestionProvider({
2637
+ columns,
2638
+ table
2639
+ });
2640
+ const handleChangeName = useCallback7(
2641
+ (evt) => {
2642
+ const { value } = evt.target;
2643
+ setColumnName(value);
2644
+ },
2645
+ []
2646
+ );
2647
+ const handleChangeExpression = useCallback7((source) => {
2648
+ sourceRef.current = source;
2649
+ }, []);
2650
+ const handleSubmitExpression = useCallback7(
2651
+ (source, expression) => {
2652
+ console.log({ source });
2653
+ setExpression(expression);
2654
+ },
2655
+ []
2656
+ );
2657
+ const handleSave = useCallback7(() => {
2658
+ if (sourceRef.current) {
2659
+ console.log(
2660
+ `save expression ${JSON.stringify(sourceRef.current, null, 2)}`
2661
+ );
2662
+ dispatchColumnAction({
2663
+ type: "addCalculatedColumn",
2664
+ columnName,
2665
+ expression: sourceRef.current,
2666
+ columnType: "string"
2667
+ });
2668
+ }
2669
+ }, [columnName, dispatchColumnAction]);
2670
+ return /* @__PURE__ */ jsxs8(Panel4, { className: "vuuCalculatedColumnPanel", title: "Define Computed Column", children: [
2671
+ /* @__PURE__ */ jsx10(Text5, { styleAs: "h4", children: "Define Computed Column" }),
2672
+ /* @__PURE__ */ jsx10(FormField4, { label: "Column Name", labelPlacement: "left", children: /* @__PURE__ */ jsx10(Input2, { value: columnName, onChange: handleChangeName }) }),
2673
+ /* @__PURE__ */ jsx10(
2674
+ ColumnExpressionInput,
2675
+ {
2676
+ onChange: handleChangeExpression,
2677
+ onSubmitExpression: handleSubmitExpression,
2678
+ suggestionProvider
2679
+ }
2680
+ ),
2681
+ /* @__PURE__ */ jsx10("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx10(Button2, { onClick: handleSave, children: "Add Column" }) })
2682
+ ] });
2683
+ };
2684
+
2685
+ // src/datagrid-configuration-ui/settings-panel/DatagridSettingsPanel.tsx
2686
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
2687
+ var classBase8 = "vuuDatagridSettingsPanel";
2688
+ var getTabLabel = () => void 0;
2689
+ var icons = [
2690
+ "table-settings",
2691
+ "column-chooser",
2692
+ "column-settings",
2693
+ "define-column"
2694
+ ];
2695
+ var getTabIcon = (component, tabIndex) => icons[tabIndex];
2696
+ var DatagridSettingsPanel = ({
2697
+ availableColumns,
2698
+ className,
2699
+ gridConfig,
2700
+ onCancel,
2701
+ onConfigChange,
2702
+ ...props
2703
+ }) => {
2704
+ var _a;
2705
+ console.log(`DatagridSettingsPanel render`);
2706
+ const [selectedTabIndex, setSelectedTabIndex] = useState4(0);
2707
+ const { gridSettings, dispatchColumnAction } = useGridSettings(gridConfig);
2708
+ const [selectedColumnName, setSelectedColumnName] = useState4(
2709
+ null
2710
+ );
2711
+ const handleColumnSelected = useCallback8(
2712
+ (selected) => {
2713
+ setSelectedColumnName(selected ? selected.name : null);
2714
+ },
2715
+ []
2716
+ );
2717
+ const handleApply = useCallback8(
2718
+ (evt, closePanel = false) => {
2719
+ console.log(`1) DataGridSettingsPanel fire onConfigChange`);
2720
+ onConfigChange == null ? void 0 : onConfigChange(gridSettings, closePanel);
2721
+ },
2722
+ [gridSettings, onConfigChange]
2723
+ );
2724
+ const handleTabSelectionChanged = useCallback8((selectedTabIndex2) => {
2725
+ setSelectedTabIndex(selectedTabIndex2);
2726
+ }, []);
2727
+ const handleSave = useCallback8(
2728
+ (evt) => handleApply(evt, true),
2729
+ [handleApply]
2730
+ );
2731
+ const selectedColumn = selectedColumnName === null ? null : (_a = gridSettings.columns.find((col) => col.name === selectedColumnName)) != null ? _a : null;
2732
+ const tabstripProps2 = {
2733
+ activeTabIndex: selectedTabIndex,
2734
+ enableRenameTab: false,
2735
+ orientation: "vertical"
2736
+ };
2737
+ const handleAddCalculatedColumn = useCallback8(
2738
+ () => setSelectedTabIndex(3),
2739
+ []
2740
+ );
2741
+ const panelShift = selectedTabIndex === 2 ? "right" : void 0;
2742
+ return /* @__PURE__ */ jsxs9("div", { ...props, className: cx5(classBase8, className), children: [
2743
+ /* @__PURE__ */ jsxs9(
2744
+ Stack2,
2745
+ {
2746
+ TabstripProps: tabstripProps2,
2747
+ className: `${classBase8}-stack`,
2748
+ getTabIcon,
2749
+ getTabLabel,
2750
+ active: selectedTabIndex === 2 ? 1 : selectedTabIndex,
2751
+ onTabSelectionChanged: handleTabSelectionChanged,
2752
+ showTabs: true,
2753
+ children: [
2754
+ /* @__PURE__ */ jsx11(
2755
+ GridSettingsPanel,
2756
+ {
2757
+ config: gridSettings,
2758
+ dispatchColumnAction
2759
+ }
2760
+ ),
2761
+ /* @__PURE__ */ jsxs9("div", { className: `${classBase8}-columnPanels`, "data-align": panelShift, children: [
2762
+ /* @__PURE__ */ jsx11(
2763
+ ColumnPicker,
2764
+ {
2765
+ availableColumns,
2766
+ chosenColumns: gridSettings.columns,
2767
+ dispatchColumnAction,
2768
+ onSelectionChange: handleColumnSelected,
2769
+ onAddCalculatedColumnClick: handleAddCalculatedColumn,
2770
+ selectedColumn
2771
+ }
2772
+ ),
2773
+ selectedColumn === null ? /* @__PURE__ */ jsx11(Panel5, { className: "vuuColumnSettingsPanel", children: "Select a column" }) : /* @__PURE__ */ jsx11(
2774
+ ColumnSettingsPanel,
2775
+ {
2776
+ column: selectedColumn,
2777
+ dispatchColumnAction,
2778
+ style: { background: "white", flex: "1 0 150px" }
2779
+ }
2780
+ )
2781
+ ] }),
2782
+ /* @__PURE__ */ jsx11("div", { title: "Column Settings", children: "Column Settings" }),
2783
+ /* @__PURE__ */ jsx11(
2784
+ CalculatedColumnPanel,
2785
+ {
2786
+ columns: gridSettings.columns,
2787
+ dispatchColumnAction,
2788
+ table: { module: "SIMUL", table: "instruments" }
2789
+ }
2790
+ )
2791
+ ]
2792
+ }
2793
+ ),
2794
+ /* @__PURE__ */ jsxs9("div", { className: `${classBase8}-buttonBar`, children: [
2795
+ /* @__PURE__ */ jsx11(Button3, { onClick: onCancel, children: "Cancel" }),
2796
+ /* @__PURE__ */ jsx11(Button3, { onClick: handleApply, children: "Apply" }),
2797
+ /* @__PURE__ */ jsx11(Button3, { onClick: handleSave, children: "Save" })
2798
+ ] })
2799
+ ] });
2800
+ };
2801
+
2802
+ // src/datasource-stats/DatasourceStats.tsx
2803
+ import { useEffect as useEffect3, useState as useState5 } from "react";
2804
+ import cx6 from "classnames";
2805
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
2806
+ var classBase9 = "vuuDatasourceStats";
2807
+ var numberFormatter = new Intl.NumberFormat();
2808
+ var DataSourceStats = ({
2809
+ className: classNameProp,
2810
+ dataSource
2811
+ }) => {
2812
+ const [optimize, setOptimize] = useState5(
2813
+ dataSource.optimize
2814
+ );
2815
+ const [range, setRange] = useState5(dataSource.range);
2816
+ const [size, setSize] = useState5(dataSource.size);
2817
+ useEffect3(() => {
2818
+ setOptimize(dataSource.optimize);
2819
+ setSize(dataSource.size);
2820
+ dataSource.on("optimize", setOptimize);
2821
+ dataSource.on("resize", setSize);
2822
+ dataSource.on("range", setRange);
2823
+ }, [dataSource]);
2824
+ const className = cx6(classBase9, classNameProp);
2825
+ const from = numberFormatter.format(range.from);
2826
+ const to = numberFormatter.format(range.to - 1);
2827
+ const value = numberFormatter.format(size);
2828
+ return /* @__PURE__ */ jsxs10("div", { className, children: [
2829
+ /* @__PURE__ */ jsx12("span", { children: "Showing rows" }),
2830
+ /* @__PURE__ */ jsx12("span", { className: `${classBase9}-range`, children: from }),
2831
+ /* @__PURE__ */ jsx12("span", { className: `${classBase9}-range`, children: to }),
2832
+ /* @__PURE__ */ jsx12("span", { children: "of" }),
2833
+ /* @__PURE__ */ jsx12("span", { className: `${classBase9}-size`, children: value }),
2834
+ /* @__PURE__ */ jsx12("span", { className: `${classBase9}-optimize`, children: optimize })
2835
+ ] });
2836
+ };
2837
+ export {
2838
+ ColumnExpressionInput,
2839
+ ColumnNamedTerms,
2840
+ DataSourceStats,
2841
+ DatagridSettingsPanel,
2842
+ columnExpressionLanguageSupport,
2843
+ isCompleteExpression,
2844
+ isCompleteRelationalExpression,
2845
+ lastNamedChild,
2846
+ useColumnExpressionEditor,
2847
+ useColumnExpressionSuggestionProvider,
2848
+ walkTree
2849
+ };
2
2850
  //# sourceMappingURL=index.js.map