@vuu-ui/vuu-data-test 0.8.16 → 0.8.17

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,5 +1,2655 @@
1
- var qs=Object.create;var zr=Object.defineProperty;var js=Object.getOwnPropertyDescriptor;var Qs=Object.getOwnPropertyNames;var Js=Object.getPrototypeOf,Xs=Object.prototype.hasOwnProperty;var z=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Ys=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Qs(e))!Xs.call(n,s)&&s!==t&&zr(n,s,{get:()=>e[s],enumerable:!(r=js(e,s))||r.enumerable});return n};var Zs=(n,e,t)=>(t=n!=null?qs(Js(n)):{},Ys(e||!n||!n.__esModule?zr(t,"default",{value:n,enumerable:!0}):t,n));var qr=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var l=(n,e,t)=>(qr(n,e,"read from private field"),t?t.call(n):e.get(n)),y=(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)},d=(n,e,t,r)=>(qr(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),sr=(n,e,t,r)=>({set _(s){d(n,e,s,t)},get _(){return l(n,e,r)}});var Cs=z((Ud,aa)=>{aa.exports=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","ZA","ZM","ZW"]});var Ss=z(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.convertStringToBaseTenNumber=void 0;var ua=function(n){return parseInt(n,10)};zt.convertStringToBaseTenNumber=ua});var Ts=z(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.isOdd=void 0;var la=function(n){return n%2===1};qt.isOdd=la});var Rs=z(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.generateCusipCheckCode=void 0;var ca=Ss(),pa=Ts(),ha=function(n){for(var e=n.length,t,r=0,s,i=0;i<e;i++){t=n[i];var o=(0,ca.convertStringToBaseTenNumber)(t),a=isNaN(o)?t.charCodeAt(0)-"A".charCodeAt(0)+10:t;(0,pa.isOdd)(i)&&(a=a*2),r=r+Math.floor(a/10)+a%10}return s=(10-r%10)%10,s};jt.generateCusipCheckCode=ha});var ws=z(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.alphabet=void 0;Qt.alphabet=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"]});var vs=z(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.baseTenNumbers=void 0;Jt.baseTenNumbers=[0,1,2,3,4,5,6,7,8,9]});var Ms=z(Ie=>{"use strict";var Ds=Ie&&Ie.__read||function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i},xs=Ie&&Ie.__spreadArray||function(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return n.concat(i||Array.prototype.slice.call(e))};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.alphanumeric=void 0;var da=ws(),fa=vs();Ie.alphanumeric=xs(xs([],Ds(da.alphabet),!1),Ds(fa.baseTenNumbers),!1)});var Ps=z(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.generateRandomAlphanumeric=void 0;var Is=Ms(),ma=function(){return Is.alphanumeric[Math.floor(Math.random()*Is.alphanumeric.length)]};Xt.generateRandomAlphanumeric=ma});var Es=z(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.generateRandomStringOfAlphanumericChars=void 0;var ga=Ps(),ba=function(){for(var n="",e=0;e<2;e++)n=n+(0,ga.generateRandomAlphanumeric)();return n};Yt.generateRandomStringOfAlphanumericChars=ba});var ks=z(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.generateRandomBaseTenNumber=void 0;var ya=function(){return Math.floor(Math.random()*10)};Zt.generateRandomBaseTenNumber=ya});var Vs=z(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.generateRandomStringOfBaseTenChars=void 0;var Ca=ks(),Sa=function(){for(var n="",e=0;e<6;e++)n=n+(0,Ca.generateRandomBaseTenNumber)();return n};er.generateRandomStringOfBaseTenChars=Sa});var Ls=z(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.generateCusipWithoutCheckCode=void 0;var Ta=Es(),Ra=Vs(),wa=function(){var n=(0,Ra.generateRandomStringOfBaseTenChars)(),e=(0,Ta.generateRandomStringOfAlphanumericChars)();return n+e};tr.generateCusipWithoutCheckCode=wa});var As=z(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.generateCusip=void 0;var va=Rs(),Da=Ls(),xa=function(){var n=(0,Da.generateCusipWithoutCheckCode)(),e=(0,va.generateCusipCheckCode)(n);return n+e};rr.generateCusip=xa});var Os=z(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.generateCusip=void 0;var Ma=As();Object.defineProperty(nr,"generateCusip",{enumerable:!0,get:function(){return Ma.generateCusip}})});var Bs=z(Ns=>{var _s=Cs(),Ia=Os().generateCusip(),Pa=n=>{let e=_s[Math.floor(Math.random()*_s.length)];return e+n+Ea(e+n+"0")},Ea=n=>{if(n.length!=12)return!1;for(var e=[],t=n.length-2;t>=0;t--){let a=n.charAt(t);if(isNaN(a)){var r=n.charCodeAt(t)-55;e.push(r%10),r>9&&e.push(Math.floor(r/10))}else e.push(Number(a))}for(var s=0,i=e.length,t=0;t<i;t++)if(t%2==0){var o=e[t]*2;s+=Math.floor(o/10),s+=o%10}else s+=e[t];return(10-s%10)%10};Ns.isinGenerator=function(){return Pa(Ia)}});var ee={algoType:{columns:[{name:"algoType",serverDataType:"string"},{name:"id",serverDataType:"int"}],key:"id",table:{module:"BASKET",table:"algoType"}},basket:{columns:[{name:"id",serverDataType:"string"},{name:"name",serverDataType:"string"},{name:"notionalValue",serverDataType:"double"},{name:"notionalValueUsd",serverDataType:"double"}],key:"id",table:{module:"BASKET",table:"basket"}},basketConstituent:{columns:[{name:"basketId",serverDataType:"string"},{name:"change",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"lastTrade",serverDataType:"string"},{name:"ric",serverDataType:"string"},{name:"ricBasketId",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"volume",serverDataType:"string"},{name:"weighting",serverDataType:"double"}],key:"ricBasketId",table:{module:"BASKET",table:"basketConstituent"}},basketTrading:{columns:[{name:"basketId",serverDataType:"string"},{name:"basketName",serverDataType:"string"},{name:"filledPct",serverDataType:"double"},{name:"fxRateToUsd",serverDataType:"double"},{name:"instanceId",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"totalNotional",serverDataType:"double"},{name:"totalNotionalUsd",serverDataType:"double"},{name:"units",serverDataType:"int"}],key:"instanceId",table:{module:"BASKET",table:"basketTrading"}},basketTradingConstituent:{columns:[{name:"algo",serverDataType:"string"},{name:"algoParams",serverDataType:"string"},{name:"basketId",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"instanceId",serverDataType:"string"},{name:"instanceIdRic",serverDataType:"string"},{name:"limitPrice",serverDataType:"double"},{name:"notionalLocal",serverDataType:"double"},{name:"notionalUsd",serverDataType:"double"},{name:"pctFilled",serverDataType:"double"},{name:"priceSpread",serverDataType:"int"},{name:"priceStrategyId",serverDataType:"int"},{name:"quantity",serverDataType:"long"},{name:"ric",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"venue",serverDataType:"string"},{name:"weighting",serverDataType:"double"}],key:"instanceIdRic",table:{module:"BASKET",table:"basketTradingConstituent"}},basketTradingConstituentJoin:{columns:[{name:"algo",serverDataType:"string"},{name:"algoParams",serverDataType:"string"},{name:"ask",serverDataType:"double"},{name:"askSize",serverDataType:"double"},{name:"basketId",serverDataType:"string"},{name:"bid",serverDataType:"double"},{name:"bidSize",serverDataType:"double"},{name:"close",serverDataType:"double"},{name:"description",serverDataType:"string"},{name:"instanceId",serverDataType:"string"},{name:"instanceIdRic",serverDataType:"string"},{name:"last",serverDataType:"double"},{name:"limitPrice",serverDataType:"double"},{name:"notionalLocal",serverDataType:"double"},{name:"notionalUsd",serverDataType:"double"},{name:"open",serverDataType:"double"},{name:"pctFilled",serverDataType:"double"},{name:"phase",serverDataType:"string"},{name:"priceSpread",serverDataType:"int"},{name:"priceStrategyId",serverDataType:"int"},{name:"quantity",serverDataType:"long"},{name:"ric",serverDataType:"string"},{name:"scenario",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"venue",serverDataType:"string"},{name:"weighting",serverDataType:"double"}],key:"instanceIdRic",table:{module:"BASKET",table:"basketTradingConstituentJoin"}},priceStrategyType:{columns:[{name:"priceStrategy",serverDataType:"string"},{name:"id",serverDataType:"int"}],key:"",table:{module:"BASKET",table:"priceStrategyType"}}};var k={instruments:{columns:[{name:"bbg",serverDataType:"string"},{name:"currency",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"exchange",serverDataType:"string"},{name:"isin",serverDataType:"string"},{name:"lotSize",serverDataType:"int"},{name:"ric",serverDataType:"string"}],key:"ric",table:{module:"SIMUL",table:"instruments"}},instrumentsExtended:{columns:[{name:"bbg",serverDataType:"string"},{name:"currency",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"exchange",serverDataType:"string"},{name:"isin",serverDataType:"string"},{name:"lotSize",serverDataType:"int"},{name:"ric",serverDataType:"string"},{name:"supported",serverDataType:"boolean"},{name:"wishlist",serverDataType:"boolean"}],key:"ric",table:{module:"SIMUL",table:"instruments"}},instrumentPrices:{columns:[{name:"ask",serverDataType:"double"},{name:"askSize",serverDataType:"double"},{name:"bbg",serverDataType:"string"},{name:"bid",serverDataType:"double"},{name:"bidSize",serverDataType:"double"},{name:"close",serverDataType:"double"},{name:"currency",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"exchange",serverDataType:"string"},{name:"isin",serverDataType:"string"},{name:"last",serverDataType:"double"},{name:"lotSize",serverDataType:"int"},{name:"open",serverDataType:"double"},{name:"phase",serverDataType:"string"},{name:"ric",serverDataType:"string"},{name:"scenario",serverDataType:"string"}],key:"ric",table:{module:"SIMUL",table:"instrumentPrices"}},orders:{columns:[{name:"ccy",serverDataType:"string"},{name:"created",serverDataType:"long"},{name:"filledQuantity",serverDataType:"double"},{name:"lastUpdate",serverDataType:"long"},{name:"orderId",serverDataType:"string"},{name:"quantity",serverDataType:"double"},{name:"ric",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"trader",serverDataType:"string"}],key:"orderId",table:{module:"SIMUL",table:"orders"}},childOrders:{columns:[{name:"account",serverDataType:"string"},{name:"averagePrice",serverDataType:"double"},{name:"ccy",serverDataType:"string"},{name:"exchange",serverDataType:"string"},{name:"filledQty",serverDataType:"double"},{name:"id",serverDataType:"string"},{name:"idAsInt",serverDataType:"int"},{name:"lastUpdate",serverDataType:"long"},{name:"openQty",serverDataType:"double"},{name:"parentOrderId",serverDataType:"string"},{name:"price",serverDataType:"double"},{name:"quantity",serverDataType:"double"},{name:"ric",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"strategy",serverDataType:"string"},{name:"volLimit",serverDataType:"int"}],key:"id",table:{module:"SIMUL",table:"childOrders"}},parentOrders:{columns:[{name:"account",serverDataType:"string"},{name:"algo",serverDataType:"string"},{name:"averagePrice",serverDataType:"double"},{name:"ccy",serverDataType:"string"},{name:"childCount",serverDataType:"int"},{name:"exchange",serverDataType:"string"},{name:"filledQty",serverDataType:"double"},{name:"id",serverDataType:"string"},{name:"idAsInt",serverDataType:"int"},{name:"lastUpdate",serverDataType:"long"},{name:"openQty",serverDataType:"double"},{name:"price",serverDataType:"double"},{name:"quantity",serverDataType:"double"},{name:"ric",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"volLimit",serverDataType:"int"}],key:"id",table:{module:"SIMUL",table:"parentOrders"}},prices:{columns:[{name:"ask",serverDataType:"double"},{name:"askSize",serverDataType:"double"},{name:"bid",serverDataType:"double"},{name:"bidSize",serverDataType:"double"},{name:"close",serverDataType:"double"},{name:"last",serverDataType:"double"},{name:"open",serverDataType:"double"},{name:"phase",serverDataType:"string"},{name:"ric",serverDataType:"string"},{name:"scenario",serverDataType:"string"}],key:"ric",table:{module:"SIMUL",table:"prices"}}};var ei={...ee,...k},jr={...ee,...k},eu=()=>ei,tu=n=>{if(jr[n])return jr[n];throw Error(`getSchema no schema for table ${n}`)};function Qr(n,e,t){return n.length!==e.length?!0:t===void 0?n.some((r,s)=>e[s]!==r):n.some((r,s)=>e[s][t]!==r[t])}var Jr=(n,e)=>{let t=r=>!(n!=null&&n.includes(r));return n===void 0?e:e.some(t)?e.filter(t):[]},Xr=(n,e,t)=>e.filter(r=>n.findIndex(s=>t(s)===r)===-1);var ti=new Set(["=","!=",">",">=","<","<=","starts","ends"]);var Yr=n=>n!==void 0&&ti.has(n.op);var Zr=n=>n!==void 0&&n.op==="in";function Ee(n){return n!==void 0&&(n.op==="and"||n.op==="or")}var ri=n=>typeof n.key=="number";var ni={};function ir(n){let e=A.count;return n?n.reduce((t,r,s)=>(typeof r=="string"?t[r]=e+s:ri(r)?t[r.name]=r.key:t[r.name]=e+s,t),{}):ni}var A={IDX:0,RENDER_IDX:1,IS_LEAF:2,IS_EXPANDED:3,DEPTH:4,COUNT:5,KEY:6,SELECTED:7,count:8,PARENT_IDX:"parent_idx",IDX_POINTER:"idx_pointer",FILTER_COUNT:"filter_count",NEXT_FILTER_IDX:"next_filter_idx"};var{DEPTH:pu,IS_LEAF:hu}=A;var en=n=>{var e,t;if(((e=globalThis.document)==null?void 0:e.cookie)!==void 0)return(t=globalThis.document.cookie.split("; ").find(r=>r.startsWith(`${n}=`)))==null?void 0:t.split("=")[1]};var or={from:0,to:0};function Ue({from:n,to:e,bufferSize:t=0}){return{from:0,to:e-n,bufferSize:t,reset:!0}}var rn=({from:n,to:e},t)=>{let{from:r,to:s}=t,i=r>=e||s<=n,o=r<n&&s>e;return i||o?t:s>e?{from:e,to:s}:{from:r,to:n}};var{KEY:Ru}=A;var nn={hour:"2-digit",minute:"2-digit",second:"2-digit"},si={"hh:mm:ss":{locale:"en-GB",options:{...nn,hour12:!1}},"hh:mm:ss a":{locale:"en-GB",options:{...nn,hour12:!0}}},ke={day:"2-digit",month:"2-digit",year:"numeric"},ii={"dd.mm.yyyy":{locale:"en-GB",options:{...ke},postProcessor:n=>n.replaceAll("/",".")},"dd/mm/yyyy":{locale:"en-GB",options:{...ke}},"dd MMM yyyy":{locale:"en-GB",options:{...ke,month:"short"}},"dd MMMM yyyy":{locale:"en-GB",options:{...ke,month:"long"}},"mm/dd/yyyy":{locale:"en-US",options:{...ke}},"MMM dd, yyyy":{locale:"en-US",options:{...ke,month:"short"}},"MMMM dd, yyyy":{locale:"en-US",options:{...ke,month:"long"}}},xu={...ii,...si};var ai=["error","warn","info","debug"],ui=n=>typeof n=="string"&&ai.includes(n),li="error",wt=()=>{},ci="error",{loggingLevel:vt=ci}=pi(),Ge=n=>{let e=vt==="debug",t=e||vt==="info",r=t||vt==="warn",s=r||vt==="error",i=t?c=>console.info(`[${n}] ${c}`):wt,o=r?c=>console.warn(`[${n}] ${c}`):wt,a=e?c=>console.debug(`[${n}] ${c}`):wt;return{errorEnabled:s,error:s?c=>console.error(`[${n}] ${c}`):wt}};function pi(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:sn()}}function sn(){let n=en("vuu-logging-level");return ui(n)?n:li}var on=()=>`const loggingSettings = { loggingLevel: "${sn()}"};`;var{debug:Ou,debugEnabled:_u}=Ge("range-monitor");function an(n){return Array.isArray(n)}function hi(n){return!Array.isArray(n)}var $,te=class{constructor(){y(this,$,new Map)}addListener(e,t){let r=l(this,$).get(e);r?an(r)?r.push(t):hi(r)&&l(this,$).set(e,[r,t]):l(this,$).set(e,t)}removeListener(e,t){if(!l(this,$).has(e))return;let r=l(this,$).get(e),s=-1;if(r===t)l(this,$).delete(e);else if(Array.isArray(r)){for(let i=length;i-- >0;)if(r[i]===t){s=i;break}if(s<0)return;r.length===1?(r.length=0,l(this,$).delete(e)):r.splice(s,1)}}removeAllListeners(e){e&&l(this,$).has(e)?l(this,$).delete(e):e===void 0&&l(this,$).clear()}emit(e,...t){if(l(this,$)){let r=l(this,$).get(e);r&&this.invokeHandler(r,t)}}once(e,t){let r=(...s)=>{this.removeListener(e,r),t(...s)};this.on(e,r)}on(e,t){this.addListener(e,t)}hasListener(e,t){let r=l(this,$).get(e);return Array.isArray(r)?r.includes(t):r===t}invokeHandler(e,t){if(an(e))e.slice().forEach(r=>this.invokeHandler(r,t));else switch(t.length){case 0:e();break;case 1:e(t[0]);break;case 2:e(t[0],t[1]);break;default:e.call(null,...t)}}};$=new WeakMap;var Dt=String.fromCharCode(8200),O=String.fromCharCode(8199);var Gu={DIGIT:O,TWO_DIGITS:O+O,THREE_DIGITS:O+O+O,FULL_PADDING:[null,Dt+O,Dt+O+O,Dt+O+O+O,Dt+O+O+O+O]};var Wu=O+O+O+O+O+O+O+O+O;var{COUNT:di}=A,un=n=>typeof n=="object"&&n!==null,fi=["boolean","number","string"],mi=n=>fi.includes(typeof n),gi=n=>typeof n=="boolean"?"boolean":typeof n=="number"?"number":"string",bi=(n,e)=>{if(un(e))return{attribute:`${n}+`,attributeValue:"",type:"json"};if(e===void 0)return{attribute:n,attributeValue:"undefined",type:"string"};if(mi(e))return{attribute:n,attributeValue:e,type:gi(e)};throw Error(`unsupported type ${typeof e} in JSON`)},ar={name:"json",renderer:{name:"json"}},ur=n=>{let e=[];e.push({name:"col 1",type:ar},{name:"col 2",type:ar});let t=[];return ln(t,n,e),[e,t]},ln=(n,e,t,r={value:0},s="$root",i=0)=>{let o=0,a=0;i===t.length-1&&t.push({name:`col ${t.length+1}`,hidden:!0,type:ar});let u=Object.entries(e);for(let c=0;c<u.length;c++,r.value+=1){let[p,h]=u[c],{attribute:f,attributeValue:m,type:g}=bi(p,h),D=g!=="json",U=Array(i).fill(""),V=`${s}|${p}`,I=[r.value,r.value,D,!1,i,0,V,0,...U,f,m];if(n.push(I),a+=1,un(h)){let[R,v]=ln(n,h,t,{value:r.value+1},V,i+1);I[di]=R,o+=R,a+=v,r.value+=v}else o+=1}return[o,a]};var We=class{constructor(e){this.keys=new Map,this.free=[],this.nextKeyValue=0,this.reset(e)}next(){return this.free.length>0?this.free.pop():this.nextKeyValue++}reset({from:e,to:t}){this.keys.forEach((s,i)=>{(i<e||i>=t)&&(this.free.push(s),this.keys.delete(i))});let r=t-e;this.keys.size+this.free.length>r&&(this.free.length=Math.max(0,r-this.keys.size));for(let s=e;s<t;s++)if(!this.keys.has(s)){let i=this.next();this.keys.set(s,i)}this.nextKeyValue>this.keys.size&&(this.nextKeyValue=this.keys.size)}keyFor(e){let t=this.keys.get(e);if(t===void 0)throw console.log(`key not found
1
+ var zn=Object.create;var Kr=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var Qn=Object.getOwnPropertyNames;var Jn=Object.getPrototypeOf,Xn=Object.prototype.hasOwnProperty;var K=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var Yn=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Qn(e))!Xn.call(s,n)&&n!==t&&Kr(s,n,{get:()=>e[n],enumerable:!(r=jn(e,n))||r.enumerable});return s};var Zn=(s,e,t)=>(t=s!=null?zn(Jn(s)):{},Yn(e||!s||!s.__esModule?Kr(t,"default",{value:s,enumerable:!0}):t,s));var zr=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var l=(s,e,t)=>(zr(s,e,"read from private field"),t?t.call(s):e.get(s)),y=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},h=(s,e,t,r)=>(zr(s,e,"write to private field"),r?r.call(s,t):e.set(s,t),t),nr=(s,e,t,r)=>({set _(n){h(s,e,n,t)},get _(){return l(s,e,r)}});var wn=K((Uh,aa)=>{aa.exports=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","ZA","ZM","ZW"]});var Cn=K(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.convertStringToBaseTenNumber=void 0;var ua=function(s){return parseInt(s,10)};Kt.convertStringToBaseTenNumber=ua});var Sn=K(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.isOdd=void 0;var la=function(s){return s%2===1};zt.isOdd=la});var vn=K(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.generateCusipCheckCode=void 0;var ca=Cn(),pa=Sn(),da=function(s){for(var e=s.length,t,r=0,n,i=0;i<e;i++){t=s[i];var o=(0,ca.convertStringToBaseTenNumber)(t),a=isNaN(o)?t.charCodeAt(0)-"A".charCodeAt(0)+10:t;(0,pa.isOdd)(i)&&(a=a*2),r=r+Math.floor(a/10)+a%10}return n=(10-r%10)%10,n};jt.generateCusipCheckCode=da});var Rn=K(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.alphabet=void 0;Qt.alphabet=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"]});var Tn=K(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.baseTenNumbers=void 0;Jt.baseTenNumbers=[0,1,2,3,4,5,6,7,8,9]});var xn=K(Ee=>{"use strict";var In=Ee&&Ee.__read||function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var r=t.call(s),n,i=[],o;try{for(;(e===void 0||e-- >0)&&!(n=r.next()).done;)i.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return i},Dn=Ee&&Ee.__spreadArray||function(s,e,t){if(t||arguments.length===2)for(var r=0,n=e.length,i;r<n;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return s.concat(i||Array.prototype.slice.call(e))};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.alphanumeric=void 0;var ha=Rn(),fa=Tn();Ee.alphanumeric=Dn(Dn([],In(ha.alphabet),!1),In(fa.baseTenNumbers),!1)});var Mn=K(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.generateRandomAlphanumeric=void 0;var En=xn(),ma=function(){return En.alphanumeric[Math.floor(Math.random()*En.alphanumeric.length)]};Xt.generateRandomAlphanumeric=ma});var kn=K(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.generateRandomStringOfAlphanumericChars=void 0;var ga=Mn(),ba=function(){for(var s="",e=0;e<2;e++)s=s+(0,ga.generateRandomAlphanumeric)();return s};Yt.generateRandomStringOfAlphanumericChars=ba});var Pn=K(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.generateRandomBaseTenNumber=void 0;var ya=function(){return Math.floor(Math.random()*10)};Zt.generateRandomBaseTenNumber=ya});var Vn=K(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.generateRandomStringOfBaseTenChars=void 0;var wa=Pn(),Ca=function(){for(var s="",e=0;e<6;e++)s=s+(0,wa.generateRandomBaseTenNumber)();return s};er.generateRandomStringOfBaseTenChars=Ca});var _n=K(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.generateCusipWithoutCheckCode=void 0;var Sa=kn(),va=Vn(),Ra=function(){var s=(0,va.generateRandomStringOfBaseTenChars)(),e=(0,Sa.generateRandomStringOfAlphanumericChars)();return s+e};tr.generateCusipWithoutCheckCode=Ra});var Ln=K(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.generateCusip=void 0;var Ta=vn(),Ia=_n(),Da=function(){var s=(0,Ia.generateCusipWithoutCheckCode)(),e=(0,Ta.generateCusipCheckCode)(s);return s+e};rr.generateCusip=Da});var An=K(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.generateCusip=void 0;var xa=Ln();Object.defineProperty(sr,"generateCusip",{enumerable:!0,get:function(){return xa.generateCusip}})});var Bn=K(Nn=>{var On=wn(),Ea=An().generateCusip(),Ma=s=>{let e=On[Math.floor(Math.random()*On.length)];return e+s+ka(e+s+"0")},ka=s=>{if(s.length!=12)return!1;for(var e=[],t=s.length-2;t>=0;t--){let a=s.charAt(t);if(isNaN(a)){var r=s.charCodeAt(t)-55;e.push(r%10),r>9&&e.push(Math.floor(r/10))}else e.push(Number(a))}for(var n=0,i=e.length,t=0;t<i;t++)if(t%2==0){var o=e[t]*2;n+=Math.floor(o/10),n+=o%10}else n+=e[t];return(10-n%10)%10};Nn.isinGenerator=function(){return Ma(Ea)}});var ee={algoType:{columns:[{name:"algoType",serverDataType:"string"},{name:"id",serverDataType:"int"}],key:"id",table:{module:"BASKET",table:"algoType"}},basket:{columns:[{name:"id",serverDataType:"string"},{name:"name",serverDataType:"string"},{name:"notionalValue",serverDataType:"double"},{name:"notionalValueUsd",serverDataType:"double"}],key:"id",table:{module:"BASKET",table:"basket"}},basketConstituent:{columns:[{name:"basketId",serverDataType:"string"},{name:"change",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"lastTrade",serverDataType:"string"},{name:"ric",serverDataType:"string"},{name:"ricBasketId",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"volume",serverDataType:"string"},{name:"weighting",serverDataType:"double"}],key:"ricBasketId",table:{module:"BASKET",table:"basketConstituent"}},basketTrading:{columns:[{name:"basketId",serverDataType:"string"},{name:"basketName",serverDataType:"string"},{name:"filledPct",serverDataType:"double"},{name:"fxRateToUsd",serverDataType:"double"},{name:"instanceId",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"totalNotional",serverDataType:"double"},{name:"totalNotionalUsd",serverDataType:"double"},{name:"units",serverDataType:"int"}],key:"instanceId",table:{module:"BASKET",table:"basketTrading"}},basketTradingConstituent:{columns:[{name:"algo",serverDataType:"string"},{name:"algoParams",serverDataType:"string"},{name:"basketId",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"instanceId",serverDataType:"string"},{name:"instanceIdRic",serverDataType:"string"},{name:"limitPrice",serverDataType:"double"},{name:"notionalLocal",serverDataType:"double"},{name:"notionalUsd",serverDataType:"double"},{name:"pctFilled",serverDataType:"double"},{name:"priceSpread",serverDataType:"int"},{name:"priceStrategyId",serverDataType:"int"},{name:"quantity",serverDataType:"long"},{name:"ric",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"venue",serverDataType:"string"},{name:"weighting",serverDataType:"double"}],key:"instanceIdRic",table:{module:"BASKET",table:"basketTradingConstituent"}},basketTradingConstituentJoin:{columns:[{name:"algo",serverDataType:"string"},{name:"algoParams",serverDataType:"string"},{name:"ask",serverDataType:"double"},{name:"askSize",serverDataType:"double"},{name:"basketId",serverDataType:"string"},{name:"bid",serverDataType:"double"},{name:"bidSize",serverDataType:"double"},{name:"close",serverDataType:"double"},{name:"description",serverDataType:"string"},{name:"instanceId",serverDataType:"string"},{name:"instanceIdRic",serverDataType:"string"},{name:"last",serverDataType:"double"},{name:"limitPrice",serverDataType:"double"},{name:"notionalLocal",serverDataType:"double"},{name:"notionalUsd",serverDataType:"double"},{name:"open",serverDataType:"double"},{name:"pctFilled",serverDataType:"double"},{name:"phase",serverDataType:"string"},{name:"priceSpread",serverDataType:"int"},{name:"priceStrategyId",serverDataType:"int"},{name:"quantity",serverDataType:"long"},{name:"ric",serverDataType:"string"},{name:"scenario",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"venue",serverDataType:"string"},{name:"weighting",serverDataType:"double"}],key:"instanceIdRic",table:{module:"BASKET",table:"basketTradingConstituentJoin"}},priceStrategyType:{columns:[{name:"priceStrategy",serverDataType:"string"},{name:"id",serverDataType:"int"}],key:"",table:{module:"BASKET",table:"priceStrategyType"}}};var P={instruments:{columns:[{name:"bbg",serverDataType:"string"},{name:"currency",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"exchange",serverDataType:"string"},{name:"isin",serverDataType:"string"},{name:"lotSize",serverDataType:"int"},{name:"ric",serverDataType:"string"}],key:"ric",table:{module:"SIMUL",table:"instruments"}},instrumentsExtended:{columns:[{name:"bbg",serverDataType:"string"},{name:"currency",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"exchange",serverDataType:"string"},{name:"isin",serverDataType:"string"},{name:"lotSize",serverDataType:"int"},{name:"ric",serverDataType:"string"},{name:"supported",serverDataType:"boolean"},{name:"wishlist",serverDataType:"boolean"}],key:"ric",table:{module:"SIMUL",table:"instruments"}},instrumentPrices:{columns:[{name:"ask",serverDataType:"double"},{name:"askSize",serverDataType:"double"},{name:"bbg",serverDataType:"string"},{name:"bid",serverDataType:"double"},{name:"bidSize",serverDataType:"double"},{name:"close",serverDataType:"double"},{name:"currency",serverDataType:"string"},{name:"description",serverDataType:"string"},{name:"exchange",serverDataType:"string"},{name:"isin",serverDataType:"string"},{name:"last",serverDataType:"double"},{name:"lotSize",serverDataType:"int"},{name:"open",serverDataType:"double"},{name:"phase",serverDataType:"string"},{name:"ric",serverDataType:"string"},{name:"scenario",serverDataType:"string"}],key:"ric",table:{module:"SIMUL",table:"instrumentPrices"}},orders:{columns:[{name:"ccy",serverDataType:"string"},{name:"created",serverDataType:"long"},{name:"filledQuantity",serverDataType:"double"},{name:"lastUpdate",serverDataType:"long"},{name:"orderId",serverDataType:"string"},{name:"quantity",serverDataType:"double"},{name:"ric",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"trader",serverDataType:"string"}],key:"orderId",table:{module:"SIMUL",table:"orders"}},childOrders:{columns:[{name:"account",serverDataType:"string"},{name:"averagePrice",serverDataType:"double"},{name:"ccy",serverDataType:"string"},{name:"exchange",serverDataType:"string"},{name:"filledQty",serverDataType:"double"},{name:"id",serverDataType:"string"},{name:"idAsInt",serverDataType:"int"},{name:"lastUpdate",serverDataType:"long"},{name:"openQty",serverDataType:"double"},{name:"parentOrderId",serverDataType:"string"},{name:"price",serverDataType:"double"},{name:"quantity",serverDataType:"double"},{name:"ric",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"strategy",serverDataType:"string"},{name:"volLimit",serverDataType:"int"}],key:"id",table:{module:"SIMUL",table:"childOrders"}},parentOrders:{columns:[{name:"account",serverDataType:"string"},{name:"algo",serverDataType:"string"},{name:"averagePrice",serverDataType:"double"},{name:"ccy",serverDataType:"string"},{name:"childCount",serverDataType:"int"},{name:"exchange",serverDataType:"string"},{name:"filledQty",serverDataType:"double"},{name:"id",serverDataType:"string"},{name:"idAsInt",serverDataType:"int"},{name:"lastUpdate",serverDataType:"long"},{name:"openQty",serverDataType:"double"},{name:"price",serverDataType:"double"},{name:"quantity",serverDataType:"double"},{name:"ric",serverDataType:"string"},{name:"side",serverDataType:"string"},{name:"status",serverDataType:"string"},{name:"volLimit",serverDataType:"int"}],key:"id",table:{module:"SIMUL",table:"parentOrders"}},prices:{columns:[{name:"ask",serverDataType:"double"},{name:"askSize",serverDataType:"double"},{name:"bid",serverDataType:"double"},{name:"bidSize",serverDataType:"double"},{name:"close",serverDataType:"double"},{name:"last",serverDataType:"double"},{name:"open",serverDataType:"double"},{name:"phase",serverDataType:"string"},{name:"ric",serverDataType:"string"},{name:"scenario",serverDataType:"string"}],key:"ric",table:{module:"SIMUL",table:"prices"}}};var ei={...ee,...P},jr={...ee,...P},eu=()=>ei,tu=s=>{if(jr[s])return jr[s];throw Error(`getSchema no schema for table ${s}`)};function Qr(s,e,t){return s.length!==e.length?!0:t===void 0?s.some((r,n)=>e[n]!==r):s.some((r,n)=>e[n][t]!==r[t])}var Jr=(s,e)=>{let t=r=>!(s!=null&&s.includes(r));return s===void 0?e:e.some(t)?e.filter(t):[]},Xr=(s,e,t)=>e.filter(r=>s.findIndex(n=>t(n)===r)===-1);var ti=new Set(["=","!=",">",">=","<","<=","starts","ends"]);var Yr=s=>s!==void 0&&ti.has(s.op);var Zr=s=>s!==void 0&&s.op==="in";function ke(s){return s!==void 0&&(s.op==="and"||s.op==="or")}var ri=s=>typeof s.key=="number";var si={};function ir(s){let e=L.count;return s?s.reduce((t,r,n)=>(typeof r=="string"?t[r]=e+n:ri(r)?t[r.name]=r.key:t[r.name]=e+n,t),{}):si}var L={IDX:0,RENDER_IDX:1,IS_LEAF:2,IS_EXPANDED:3,DEPTH:4,COUNT:5,KEY:6,SELECTED:7,count:8,PARENT_IDX:"parent_idx",IDX_POINTER:"idx_pointer",FILTER_COUNT:"filter_count",NEXT_FILTER_IDX:"next_filter_idx"};var{DEPTH:pu,IS_LEAF:du}=L;var es=s=>{var e,t;if(((e=globalThis.document)==null?void 0:e.cookie)!==void 0)return(t=globalThis.document.cookie.split("; ").find(r=>r.startsWith(`${s}=`)))==null?void 0:t.split("=")[1]};var or={from:0,to:0};function Ue({from:s,to:e,bufferSize:t=0}){return{from:0,to:e-s,bufferSize:t,reset:!0}}var rs=({from:s,to:e},t)=>{let{from:r,to:n}=t,i=r>=e||n<=s,o=r<s&&n>e;return i||o?t:n>e?{from:e,to:n}:{from:r,to:s}};var{KEY:vu}=L;var ss={hour:"2-digit",minute:"2-digit",second:"2-digit"},ni={"hh:mm:ss":{locale:"en-GB",options:{...ss,hour12:!1}},"hh:mm:ss a":{locale:"en-GB",options:{...ss,hour12:!0}}},Pe={day:"2-digit",month:"2-digit",year:"numeric"},ii={"dd.mm.yyyy":{locale:"en-GB",options:{...Pe},postProcessor:s=>s.replaceAll("/",".")},"dd/mm/yyyy":{locale:"en-GB",options:{...Pe}},"dd MMM yyyy":{locale:"en-GB",options:{...Pe,month:"short"}},"dd MMMM yyyy":{locale:"en-GB",options:{...Pe,month:"long"}},"mm/dd/yyyy":{locale:"en-US",options:{...Pe}},"MMM dd, yyyy":{locale:"en-US",options:{...Pe,month:"short"}},"MMMM dd, yyyy":{locale:"en-US",options:{...Pe,month:"long"}}},Du={...ii,...ni};var ai=["error","warn","info","debug"],ui=s=>typeof s=="string"&&ai.includes(s),li="error",Rt=()=>{},ci="error",{loggingLevel:Tt=ci}=pi(),Ge=s=>{let e=Tt==="debug",t=e||Tt==="info",r=t||Tt==="warn",n=r||Tt==="error",i=t?c=>console.info(`[${s}] ${c}`):Rt,o=r?c=>console.warn(`[${s}] ${c}`):Rt,a=e?c=>console.debug(`[${s}] ${c}`):Rt;return{errorEnabled:n,error:n?c=>console.error(`[${s}] ${c}`):Rt}};function pi(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:ns()}}function ns(){let s=es("vuu-logging-level");return ui(s)?s:li}var is=()=>`const loggingSettings = { loggingLevel: "${ns()}"};`;var{debug:Au,debugEnabled:Ou}=Ge("range-monitor");function os(s){return Array.isArray(s)}function di(s){return!Array.isArray(s)}var H,te=class{constructor(){y(this,H,new Map)}addListener(e,t){let r=l(this,H).get(e);r?os(r)?r.push(t):di(r)&&l(this,H).set(e,[r,t]):l(this,H).set(e,t)}removeListener(e,t){if(!l(this,H).has(e))return;let r=l(this,H).get(e),n=-1;if(r===t)l(this,H).delete(e);else if(Array.isArray(r)){for(let i=length;i-- >0;)if(r[i]===t){n=i;break}if(n<0)return;r.length===1?(r.length=0,l(this,H).delete(e)):r.splice(n,1)}}removeAllListeners(e){e&&l(this,H).has(e)?l(this,H).delete(e):e===void 0&&l(this,H).clear()}emit(e,...t){if(l(this,H)){let r=l(this,H).get(e);r&&this.invokeHandler(r,t)}}once(e,t){let r=(...n)=>{this.removeListener(e,r),t(...n)};this.on(e,r)}on(e,t){this.addListener(e,t)}hasListener(e,t){let r=l(this,H).get(e);return Array.isArray(r)?r.includes(t):r===t}invokeHandler(e,t){if(os(e))e.slice().forEach(r=>this.invokeHandler(r,t));else switch(t.length){case 0:e();break;case 1:e(t[0]);break;case 2:e(t[0],t[1]);break;default:e.call(null,...t)}}};H=new WeakMap;var It=String.fromCharCode(8200),A=String.fromCharCode(8199);var Gu={DIGIT:A,TWO_DIGITS:A+A,THREE_DIGITS:A+A+A,FULL_PADDING:[null,It+A,It+A+A,It+A+A+A,It+A+A+A+A]};var qu=A+A+A+A+A+A+A+A+A;var{COUNT:hi}=L,as=s=>typeof s=="object"&&s!==null,fi=["boolean","number","string"],mi=s=>fi.includes(typeof s),gi=s=>typeof s=="boolean"?"boolean":typeof s=="number"?"number":"string",bi=(s,e)=>{if(as(e))return{attribute:`${s}+`,attributeValue:"",type:"json"};if(e===void 0)return{attribute:s,attributeValue:"undefined",type:"string"};if(mi(e))return{attribute:s,attributeValue:e,type:gi(e)};throw Error(`unsupported type ${typeof e} in JSON`)},ar={name:"json",renderer:{name:"json"}},ur=s=>{let e=[];e.push({name:"col 1",type:ar},{name:"col 2",type:ar});let t=[];return us(t,s,e),[e,t]},us=(s,e,t,r={value:0},n="$root",i=0)=>{let o=0,a=0;i===t.length-1&&t.push({name:`col ${t.length+1}`,hidden:!0,type:ar});let u=Object.entries(e);for(let c=0;c<u.length;c++,r.value+=1){let[p,d]=u[c],{attribute:f,attributeValue:m,type:g}=bi(p,d),I=g!=="json",U=Array(i).fill(""),V=`${n}|${p}`,E=[r.value,r.value,I,!1,i,0,V,0,...U,f,m];if(s.push(E),a+=1,as(d)){let[v,T]=us(s,d,t,{value:r.value+1},V,i+1);E[hi]=v,o+=v,a+=T,r.value+=T}else o+=1}return[o,a]};var qe=class{constructor(e){this.keys=new Map,this.free=[],this.nextKeyValue=0,this.reset(e)}next(){return this.free.length>0?this.free.pop():this.nextKeyValue++}reset({from:e,to:t}){this.keys.forEach((n,i)=>{(i<e||i>=t)&&(this.free.push(n),this.keys.delete(i))});let r=t-e;this.keys.size+this.free.length>r&&(this.free.length=Math.max(0,r-this.keys.size));for(let n=e;n<t;n++)if(!this.keys.has(n)){let i=this.next();this.keys.set(n,i)}this.nextKeyValue>this.keys.size&&(this.nextKeyValue=this.keys.size)}keyFor(e){let t=this.keys.get(e);if(t===void 0)throw console.log(`key not found
2
2
  keys: ${this.toDebugString()}
3
3
  free : ${this.free.join(",")}
4
- `),Error(`KeySet, no key found for rowIndex ${e}`);return t}toDebugString(){return Array.from(this.keys.entries()).map((e,t)=>`${e}=>${t}`).join(",")}};var ue=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;){let r=t[n]&63;r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r<63?e+="_":e+="-"}return e};function lr(n,e){let t;return(...r)=>{clearTimeout(t),t=window.setTimeout(()=>n(...r),e)}}function cn(n,e){let t=!1,r;function s(){r==null?t=!1:(n(...r),r=void 0,setTimeout(s,e))}return(...i)=>{t?r=i:(n(...i),t=!0,setTimeout(s,e))}}var{IDX:Cl}=A;var{SELECTED:Rl}=A,de={False:0,True:1,First:2,Last:4};var pn=(n,e)=>e>=n[0]&&e<=n[1],yi=de.True+de.First+de.Last,Ci=de.True+de.First,Si=de.True+de.Last,hn=(n,e)=>{for(let t of n)if(typeof t=="number"){if(t===e)return yi}else if(pn(t,e))return e===t[0]?Ci:e===t[1]?Si:de.True;return de.False},dn=(n,e)=>{for(let t of n)if(typeof t=="number"){if(t===e)return!0;if(t>e)return!1}else{if(pn(t,e))return!0;if(t[0]>e)return!1}return!1};var Ti=(()=>{let n=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(n+=1,`u${e()}${n}`)})();var lt=(n,e)=>n===e?!0:n===void 0&&e===void 0,xi=({filter:n},{filter:e})=>n===void 0&&(e==null?void 0:e.filter)===""||e===void 0&&(n==null?void 0:n.filter)==="",Mi=(n,e)=>{var t,r;return xi(n,e)?!1:((t=n.filter)==null?void 0:t.filter)!==((r=e.filter)==null?void 0:r.filter)},Ii=({sort:n},{sort:e})=>n===void 0&&(e==null?void 0:e.sortDefs.length)===0||e===void 0&&(n==null?void 0:n.sortDefs.length)===0,Pi=(n,e)=>{let{sort:t}=n,{sort:r}=e;return lt(t,r)||Ii(n,e)?!1:t===void 0||r===void 0||(t==null?void 0:t.sortDefs.length)!==(r==null?void 0:r.sortDefs.length)?!0:t.sortDefs.some(({column:s,sortType:i},o)=>s!==r.sortDefs[o].column||i!==r.sortDefs[o].sortType)},gn=n=>n!==void 0&&n.groupBy!==void 0&&n.groupBy.length>0,bn=n=>(n==null?void 0:n.filter)!==void 0&&n.filter.filter.length>0,yn=n=>{var e;return(n==null?void 0:n.sort)!==void 0&&Array.isArray((e=n.sort)==null?void 0:e.sortDefs)&&n.sort.sortDefs.length>0},Ei=({groupBy:n},{groupBy:e})=>n===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(n==null?void 0:n.length)===0,pr=(n,e)=>{let{groupBy:t}=n,{groupBy:r}=e;return lt(t,r)||Ei(n,e)?!1:t===void 0||r===void 0||(t==null?void 0:t.length)!==(r==null?void 0:r.length)?!0:t.some((s,i)=>s!==(r==null?void 0:r[i]))},ki=({columns:n},{columns:e})=>n===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(n==null?void 0:n.length)===0,Vi=(n,e)=>{let{columns:t}=n,{columns:r}=e;return lt(t,r)||ki(n,e)?!1:t===void 0||r===void 0||(t==null?void 0:t.length)!==(r==null?void 0:r.length)?!0:t.some((s,i)=>s!==(r==null?void 0:r[i]))},Li=({aggregations:n},{aggregations:e})=>n===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(n==null?void 0:n.length)===0,Ai=(n,e)=>{let{aggregations:t}=n,{aggregations:r}=e;return lt(t,r)||Li(n,e)?!1:t===void 0||r===void 0||t.length!==r.length?!0:t.some(({column:s,aggType:i},o)=>s!==r[o].column||i!==r[o].aggType)},Oi=()=>!1,xt=(n,e)=>lt(n,e)?!1:n===void 0||e===void 0?!0:Vi(n,e)||Mi(n,e)||Pi(n,e)||pr(n,e)||Ai(n,e)||Oi(n,e),_i=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],Cn=n=>{let e=n.type;return _i.includes(e)},Sn=n=>["config","aggregate","columns","filter","groupBy","sort"].includes(n.type),Ni={filter:""},Bi={sortDefs:[]},He={aggregations:[],columns:[],filter:Ni,groupBy:[],sort:Bi},ct=n=>{if(n.aggregations&&n.columns&&n.filter&&n.groupBy&&n.sort)return n;{let{aggregations:e=[],columns:t=[],filter:r={filter:""},groupBy:s=[],sort:i={sortDefs:[]},visualLink:o}=n;return{aggregations:e,columns:t,filter:r,groupBy:s,sort:i,visualLink:o}}};var Tn="GET_TABLE_META";var hr=n=>n.type==="connection-status",Rn=n=>n.type==="connection-metrics",wn=n=>typeof n.result<"u",vn=n=>n.type==="TABLE_META_RESP";var Dn=n=>n.type==="vuu-links";var xn=n=>n.type==="vuu-menu";var Mn='\nvar de=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var d=(s,e,t)=>(de(s,e,"read from private field"),t?t.call(s):e.get(s)),k=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},ge=(s,e,t,n)=>(de(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);function fe(s,e,t=[],n=[]){for(let r=0,o=s.length;r<o;r++)(e(s[r],r)?t:n).push(s[r]);return[t,n]}var V={IDX:0,RENDER_IDX:1,IS_LEAF:2,IS_EXPANDED:3,DEPTH:4,COUNT:5,KEY:6,SELECTED:7,count:8,PARENT_IDX:"parent_idx",IDX_POINTER:"idx_pointer",FILTER_COUNT:"filter_count",NEXT_FILTER_IDX:"next_filter_idx"};var{DEPTH:sn,IS_LEAF:on}=V;var me=s=>{var e,t;if(((e=globalThis.document)==null?void 0:e.cookie)!==void 0)return(t=globalThis.document.cookie.split("; ").find(n=>n.startsWith(`${s}=`)))==null?void 0:t.split("=")[1]};function K({from:s,to:e},t=0,n=Number.MAX_SAFE_INTEGER){if(t===0)return n<s?{from:0,to:0}:{from:s,to:Math.min(e,n)};if(s===0)return{from:s,to:Math.min(e+t,n)};{let r=e-s,o=Math.round(t/2),i=s-o<0,u=n-(e+o)<0;return i&&u?{from:0,to:n}:i?{from:0,to:r+t}:u?{from:Math.max(0,n-(r+t)),to:n}:{from:s-o,to:e+o}}}var it=(s,{from:e,to:t})=>s>=e&&s<t;var v=class{constructor(e,t){this.from=e,this.to=t}isWithin(e){return it(e,this)}overlap(e,t){return e>=this.to||t<this.from?[0,0]:[Math.max(e,this.from),Math.min(t,this.to)]}copy(){return new v(this.from,this.to)}};var{KEY:mn}=V;var Ce={hour:"2-digit",minute:"2-digit",second:"2-digit"},at={"hh:mm:ss":{locale:"en-GB",options:{...Ce,hour12:!1}},"hh:mm:ss a":{locale:"en-GB",options:{...Ce,hour12:!0}}},I={day:"2-digit",month:"2-digit",year:"numeric"},ut={"dd.mm.yyyy":{locale:"en-GB",options:{...I},postProcessor:s=>s.replaceAll("/",".")},"dd/mm/yyyy":{locale:"en-GB",options:{...I}},"dd MMM yyyy":{locale:"en-GB",options:{...I,month:"short"}},"dd MMMM yyyy":{locale:"en-GB",options:{...I,month:"long"}},"mm/dd/yyyy":{locale:"en-US",options:{...I}},"MMM dd, yyyy":{locale:"en-US",options:{...I,month:"short"}},"MMMM dd, yyyy":{locale:"en-US",options:{...I,month:"long"}}},Rn={...ut,...at};var ct=["error","warn","info","debug"],pt=s=>typeof s=="string"&&ct.includes(s),dt="error",A=()=>{},gt="error",{loggingLevel:U=gt}=ft(),w=s=>{let e=U==="debug",t=e||U==="info",n=t||U==="warn",r=n||U==="error",o=t?p=>console.info(`[${s}] ${p}`):A,i=n?p=>console.warn(`[${s}] ${p}`):A,u=e?p=>console.debug(`[${s}] ${p}`):A;return{errorEnabled:r,error:r?p=>console.error(`[${s}] ${p}`):A}};function ft(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:mt()}}function mt(){let s=me("vuu-logging-level");return pt(s)?s:dt}var{debug:ht,debugEnabled:Ct}=w("range-monitor"),F=class{constructor(e){this.source=e;this.range={from:0,to:0};this.timestamp=0}isSet(){return this.timestamp!==0}set({from:e,to:t}){let{timestamp:n}=this;if(this.range.from=e,this.range.to=t,this.timestamp=performance.now(),n)Ct&&ht(`<${this.source}> [${e}-${t}], ${(this.timestamp-n).toFixed(0)} ms elapsed`);else return 0}};function be(s){return Array.isArray(s)}function bt(s){return!Array.isArray(s)}var R,Re=class{constructor(){k(this,R,new Map)}addListener(e,t){let n=d(this,R).get(e);n?be(n)?n.push(t):bt(n)&&d(this,R).set(e,[n,t]):d(this,R).set(e,t)}removeListener(e,t){if(!d(this,R).has(e))return;let n=d(this,R).get(e),r=-1;if(n===t)d(this,R).delete(e);else if(Array.isArray(n)){for(let o=length;o-- >0;)if(n[o]===t){r=o;break}if(r<0)return;n.length===1?(n.length=0,d(this,R).delete(e)):n.splice(r,1)}}removeAllListeners(e){e&&d(this,R).has(e)?d(this,R).delete(e):e===void 0&&d(this,R).clear()}emit(e,...t){if(d(this,R)){let n=d(this,R).get(e);n&&this.invokeHandler(n,t)}}once(e,t){let n=(...r)=>{this.removeListener(e,n),t(...r)};this.on(e,n)}on(e,t){this.addListener(e,t)}hasListener(e,t){let n=d(this,R).get(e);return Array.isArray(n)?n.includes(t):n===t}invokeHandler(e,t){if(be(e))e.slice().forEach(n=>this.invokeHandler(n,t));else switch(t.length){case 0:e();break;case 1:e(t[0]);break;case 2:e(t[0],t[1]);break;default:e.call(null,...t)}}};R=new WeakMap;var N=String.fromCharCode(8200),f=String.fromCharCode(8199);var Ln={DIGIT:f,TWO_DIGITS:f+f,THREE_DIGITS:f+f+f,FULL_PADDING:[null,N+f,N+f+f,N+f+f+f,N+f+f+f+f]};var _n=f+f+f+f+f+f+f+f+f;var{COUNT:rr}=V;var W=class{constructor(e){this.keys=new Map,this.free=[],this.nextKeyValue=0,this.reset(e)}next(){return this.free.length>0?this.free.pop():this.nextKeyValue++}reset({from:e,to:t}){this.keys.forEach((r,o)=>{(o<e||o>=t)&&(this.free.push(r),this.keys.delete(o))});let n=t-e;this.keys.size+this.free.length>n&&(this.free.length=Math.max(0,n-this.keys.size));for(let r=e;r<t;r++)if(!this.keys.has(r)){let o=this.next();this.keys.set(r,o)}this.nextKeyValue>this.keys.size&&(this.nextKeyValue=this.keys.size)}keyFor(e){let t=this.keys.get(e);if(t===void 0)throw console.log(`key not found\n keys: ${this.toDebugString()}\n free : ${this.free.join(",")} \n `),Error(`KeySet, no key found for rowIndex ${e}`);return t}toDebugString(){return Array.from(this.keys.entries()).map((e,t)=>`${e}=>${t}`).join(",")}};var{IDX:pr}=V;var{SELECTED:fr}=V,M={False:0,True:1,First:2,Last:4};var Rt=(s,e)=>e>=s[0]&&e<=s[1],Tt=M.True+M.First+M.Last,yt=M.True+M.First,St=M.True+M.Last,Q=(s,e)=>{for(let t of s)if(typeof t=="number"){if(t===e)return Tt}else if(Rt(t,e))return e===t[0]?yt:e===t[1]?St:M.True;return M.False};var Te=s=>{if(s.every(t=>typeof t=="number"))return s;let e=[];for(let t of s)if(typeof t=="number")e.push(t);else for(let n=t[0];n<=t[1];n++)e.push(n);return e};var wt=(()=>{let s=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(s+=1,`u${e()}${s}`)})();var{debug:Ks,debugEnabled:Qs,error:we,info:E,infoEnabled:vt,warn:P}=w("websocket-connection"),Ee="ws",It=s=>s.startsWith(Ee+"://")||s.startsWith(Ee+"s://"),xe={},Z=Symbol("setWebsocket"),q=Symbol("connectionCallback");async function ve(s,e,t,n=10,r=5){return xe[s]={status:"connecting",connect:{allowed:r,remaining:r},reconnect:{allowed:n,remaining:n}},Ie(s,e,t)}async function Y(s){throw Error("connection broken")}async function Ie(s,e,t,n){let{status:r,connect:o,reconnect:i}=xe[s],u=r==="connecting"?o:i;try{t({type:"connection-status",status:"connecting"});let c=typeof n<"u",p=await Pt(s,e);console.info("%c\u26A1 %cconnected","font-size: 24px;color: green;font-weight: bold;","color:green; font-size: 14px;"),n!==void 0&&n[Z](p);let a=n!=null?n:new ee(p,s,e,t),l=c?"reconnected":"connection-open-awaiting-session";return t({type:"connection-status",status:l}),a.status=l,u.remaining=u.allowed,a}catch{let p=--u.remaining>0;if(t({type:"connection-status",status:"disconnected",reason:"failed to connect",retry:p}),p)return Dt(s,e,t,n,2e3);throw Error("Failed to establish connection")}}var Dt=(s,e,t,n,r)=>new Promise(o=>{setTimeout(()=>{o(Ie(s,e,t,n))},r)}),Pt=(s,e)=>new Promise((t,n)=>{let r=It(s)?s:`wss://${s}`;vt&&e!==void 0&&E(`WebSocket Protocol ${e==null?void 0:e.toString()}`);let o=new WebSocket(r,e);o.onopen=()=>t(o),o.onerror=i=>n(i)}),Ve=()=>{P==null||P("Connection cannot be closed, socket not yet opened")},Me=s=>{P==null||P(`Message cannot be sent, socket closed ${s.body.type}`)},Lt=s=>{try{return JSON.parse(s)}catch{throw Error(`Error parsing JSON response from server ${s}`)}},ee=class{constructor(e,t,n,r){this.close=Ve;this.requiresLogin=!0;this.send=Me;this.status="ready";this.messagesCount=0;this.connectionMetricsInterval=null;this.handleWebsocketMessage=e=>{let t=Lt(e.data);this.messagesCount+=1,this[q](t)};this.url=t,this.protocol=n,this[q]=r,this[Z](e)}reconnect(){Y(this)}[(q,Z)](e){let t=this[q];e.onmessage=o=>{this.status="connected",e.onmessage=this.handleWebsocketMessage,this.handleWebsocketMessage(o)},this.connectionMetricsInterval=setInterval(()=>{t({type:"connection-metrics",messagesLength:this.messagesCount}),this.messagesCount=0},2e3),e.onerror=()=>{we("\u26A1 connection error"),t({type:"connection-status",status:"disconnected",reason:"error"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status==="connection-open-awaiting-session"?we("Websocket connection lost before Vuu session established, check websocket configuration"):this.status!=="closed"&&(Y(this),this.send=r)},e.onclose=()=>{E==null||E("\u26A1 connection close"),t({type:"connection-status",status:"disconnected",reason:"close"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status!=="closed"&&(Y(this),this.send=r)};let n=o=>{e.send(JSON.stringify(o))},r=o=>{E==null||E(`TODO queue message until websocket reconnected ${o.body.type}`)};this.send=n,this.close=()=>{this.status="closed",e.close(),this.close=Ve,this.send=Me,E==null||E("close websocket")}}};var _t=["VIEW_PORT_MENUS_SELECT_RPC","VIEW_PORT_MENU_TABLE_RPC","VIEW_PORT_MENU_ROW_RPC","VIEW_PORT_MENU_CELL_RPC","VP_EDIT_CELL_RPC","VP_EDIT_ROW_RPC","VP_EDIT_ADD_ROW_RPC","VP_EDIT_DELETE_CELL_RPC","VP_EDIT_DELETE_ROW_RPC","VP_EDIT_SUBMIT_FORM_RPC"],De=s=>_t.includes(s.type),Pe=s=>s.type==="VIEW_PORT_RPC_CALL",$=({requestId:s,...e})=>[s,e],Le=s=>{let e=s.at(0);if(e.updateType==="SIZE"){if(s.length===1)return s;e=s.at(1)}let t=s.at(-1);return[e,t]},_e=s=>{let e={};for(let t of s)(e[t.viewPortId]||(e[t.viewPortId]=[])).push(t);return e};var te=({columns:s,dataTypes:e,key:t,table:n})=>({table:n,columns:s.map((r,o)=>({name:r,serverDataType:e[o]})),key:t});var Oe=s=>s.type==="connection-status",ke=s=>s.type==="connection-metrics";var Ae=s=>"viewport"in s,Ue=s=>s.type==="VIEW_PORT_MENU_RESP"&&s.action!==null&&G(s.action.table),G=s=>s!==null&&typeof s=="object"&&"table"in s&&"module"in s?s.table.startsWith("session"):!1;var Fe="CHANGE_VP_SUCCESS";var Ne="CLOSE_TREE_NODE",We="CLOSE_TREE_SUCCESS";var qe="CREATE_VP",$e="DISABLE_VP",Ge="DISABLE_VP_SUCCESS";var Be="ENABLE_VP",He="ENABLE_VP_SUCCESS";var ne="GET_VP_VISUAL_LINKS",je="GET_VIEW_PORT_MENUS";var ze="HB",Je="HB_RESP",Ke="LOGIN",Qe="OPEN_TREE_NODE",Xe="OPEN_TREE_SUCCESS";var Ye="REMOVE_VP";var Ze="SET_SELECTION_SUCCESS";var tt=s=>{switch(s){case"TypeAheadRpcHandler":return"TYPEAHEAD";default:return"SIMUL"}};var nt=[],T=w("array-backed-moving-window");function Ot(s,e){if(!e||e.data.length!==s.data.length||e.sel!==s.sel)return!1;for(let t=0;t<e.data.length;t++)if(e.data[t]!==s.data[t])return!1;return!0}var h,B=class{constructor({from:e,to:t},{from:n,to:r},o){k(this,h,void 0);this.setRowCount=e=>{var t;if((t=T.info)==null||t.call(T,`setRowCount ${e}`),e<this.internalData.length&&(this.internalData.length=e),e<this.rowCount){this.rowsWithinRange=0;let n=Math.min(e,this.clientRange.to);for(let r=this.clientRange.from;r<n;r++){let o=r-d(this,h).from;this.internalData[o]!==void 0&&(this.rowsWithinRange+=1)}}this.rowCount=e};this.bufferBreakout=(e,t)=>{let n=this.bufferSize*.25;return d(this,h).to-t<n?!0:d(this,h).from>0&&e-d(this,h).from<n};this.bufferSize=o,this.clientRange=new v(e,t),ge(this,h,new v(n,r)),this.internalData=new Array(o),this.rowsWithinRange=0,this.rowCount=0}get range(){return d(this,h)}get hasAllRowsWithinRange(){return this.rowsWithinRange===this.clientRange.to-this.clientRange.from||this.rowCount>0&&this.clientRange.from+this.rowsWithinRange===this.rowCount}outOfRange(e,t){let{from:n,to:r}=this.range;if(t<n||e>=r)return!0}setAtIndex(e){let{rowIndex:t}=e,n=t-d(this,h).from;if(Ot(e,this.internalData[n]))return!1;let r=this.isWithinClientRange(t);return(r||this.isWithinRange(t))&&(!this.internalData[n]&&r&&(this.rowsWithinRange+=1),this.internalData[n]=e),r}getAtIndex(e){return d(this,h).isWithin(e)&&this.internalData[e-d(this,h).from]!=null?this.internalData[e-d(this,h).from]:void 0}isWithinRange(e){return d(this,h).isWithin(e)}isWithinClientRange(e){return this.clientRange.isWithin(e)}setClientRange(e,t){var p;(p=T.debug)==null||p.call(T,`setClientRange ${e} - ${t}`);let n=this.clientRange.from,r=Math.min(this.clientRange.to,this.rowCount);if(e===n&&t===r)return[!1,nt];let o=this.clientRange.copy();this.clientRange.from=e,this.clientRange.to=t,this.rowsWithinRange=0;for(let a=e;a<t;a++){let l=a-d(this,h).from;this.internalData[l]&&(this.rowsWithinRange+=1)}let i=nt,u=d(this,h).from;if(this.hasAllRowsWithinRange)if(t>o.to){let a=Math.max(e,o.to);i=this.internalData.slice(a-u,t-u)}else{let a=Math.min(o.from,t);i=this.internalData.slice(e-u,a-u)}return[this.bufferBreakout(e,t),i]}setRange(e,t){var n,r;if(e!==d(this,h).from||t!==d(this,h).to){(n=T.debug)==null||n.call(T,`setRange ${e} - ${t}`);let[o,i]=d(this,h).overlap(e,t),u=new Array(t-e);this.rowsWithinRange=0;for(let c=o;c<i;c++){let p=this.getAtIndex(c);if(p){let a=c-e;u[a]=p,this.isWithinClientRange(c)&&(this.rowsWithinRange+=1)}}this.internalData=u,d(this,h).from=e,d(this,h).to=t}else(r=T.debug)==null||r.call(T,`setRange ${e} - ${t} IGNORED because not changed`)}get data(){return this.internalData}getData(){var u;let{from:e,to:t}=d(this,h),{from:n,to:r}=this.clientRange,o=Math.max(0,n-e),i=Math.min(t-e,t,r-e,(u=this.rowCount)!=null?u:t);return this.internalData.slice(o,i)}clear(){var e;(e=T.debug)==null||e.call(T,"clear"),this.internalData.length=0,this.rowsWithinRange=0,this.setRowCount(0)}getCurrentDataRange(){let e=this.internalData,t=e.length,[n]=this.internalData,r=this.internalData[t-1];if(n&&r)return[n.rowIndex,r.rowIndex];for(let o=0;o<t;o++)if(e[o]!==void 0){n=e[o];break}for(let o=t-1;o>=0;o--)if(e[o]!==void 0){r=e[o];break}return n&&r?[n.rowIndex,r.rowIndex]:[-1,-1]}};h=new WeakMap;var kt=[],{debug:C,debugEnabled:H,error:At,info:g,infoEnabled:Ut,warn:L}=w("viewport"),Ft=({rowKey:s,updateType:e})=>e==="U"&&!s.startsWith("$root"),j=[void 0,void 0],Nt={count:0,mode:void 0,size:0,ts:0},z=class{constructor({aggregations:e,bufferSize:t=50,columns:n,filter:r,groupBy:o=[],table:i,range:u,sort:c,title:p,viewport:a,visualLink:l},m){this.batchMode=!0;this.hasUpdates=!1;this.pendingUpdates=[];this.pendingOperations=new Map;this.pendingRangeRequests=[];this.rowCountChanged=!1;this.selectedRows=[];this.useBatchMode=!0;this.lastUpdateStatus=Nt;this.updateThrottleTimer=void 0;this.rangeMonitor=new F("ViewPort");this.disabled=!1;this.isTree=!1;this.status="";this.suspended=!1;this.suspendTimer=null;this.setLastSizeOnlyUpdateSize=e=>{this.lastUpdateStatus.size=e};this.setLastUpdate=e=>{let{ts:t,mode:n}=this.lastUpdateStatus,r=0;if(n===e){let o=Date.now();this.lastUpdateStatus.count+=1,this.lastUpdateStatus.ts=o,r=t===0?0:o-t}else this.lastUpdateStatus.count=1,this.lastUpdateStatus.ts=0,r=0;return this.lastUpdateStatus.mode=e,r};this.rangeRequestAlreadyPending=e=>{let{bufferSize:t}=this,n=t*.25,{from:r}=e;for(let{from:o,to:i}of this.pendingRangeRequests)if(r>=o&&r<i){if(e.to+n<=i)return!0;r=i}return!1};this.sendThrottledSizeMessage=()=>{this.updateThrottleTimer=void 0,this.lastUpdateStatus.count=3,this.postMessageToClient({clientViewportId:this.clientViewportId,mode:"size-only",size:this.lastUpdateStatus.size,type:"viewport-update"})};this.shouldThrottleMessage=e=>{let t=this.setLastUpdate(e);return e==="size-only"&&t>0&&t<500&&this.lastUpdateStatus.count>3};this.throttleMessage=e=>this.shouldThrottleMessage(e)?(g==null||g("throttling updates setTimeout to 2000"),this.updateThrottleTimer===void 0&&(this.updateThrottleTimer=setTimeout(this.sendThrottledSizeMessage,2e3)),!0):(this.updateThrottleTimer!==void 0&&(clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),!1);this.getNewRowCount=()=>{if(this.rowCountChanged&&this.dataWindow)return this.rowCountChanged=!1,this.dataWindow.rowCount};this.aggregations=e,this.bufferSize=t,this.clientRange=u,this.clientViewportId=a,this.columns=n,this.filter=r,this.groupBy=o,this.keys=new W(u),this.pendingLinkedParent=l,this.table=i,this.sort=c,this.title=p,Ut&&(g==null||g(`constructor #${a} ${i.table} bufferSize=${t}`)),this.dataWindow=new B(this.clientRange,u,this.bufferSize),this.postMessageToClient=m}get hasUpdatesToProcess(){return this.suspended?!1:this.rowCountChanged||this.hasUpdates}get size(){var e;return(e=this.dataWindow.rowCount)!=null?e:0}subscribe(){let{filter:e}=this.filter;return this.status=this.status==="subscribed"?"resubscribing":"subscribing",{type:qe,table:this.table,range:K(this.clientRange,this.bufferSize),aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:e}}}handleSubscribed({viewPortId:e,aggregations:t,columns:n,filterSpec:r,range:o,sort:i,groupBy:u},c){return this.serverViewportId=e,this.status="subscribed",this.aggregations=t,this.columns=n,this.groupBy=u,this.isTree=u&&u.length>0,this.dataWindow.setRange(o.from,o.to),{aggregations:t,type:"subscribed",clientViewportId:this.clientViewportId,columns:n,filter:r,groupBy:u,range:o,sort:i,tableSchema:c}}awaitOperation(e,t){this.pendingOperations.set(e,t)}completeOperation(e,...t){var u;let{clientViewportId:n,pendingOperations:r}=this,o=r.get(e);if(!o){At(`no matching operation found to complete for requestId ${e}`);return}let{type:i}=o;if(g==null||g(`completeOperation ${i}`),r.delete(e),i==="CHANGE_VP_RANGE"){let[c,p]=t;(u=this.dataWindow)==null||u.setRange(c,p);for(let a=this.pendingRangeRequests.length-1;a>=0;a--){let l=this.pendingRangeRequests[a];if(l.requestId===e){l.acked=!0;break}else L==null||L("range requests sent faster than they are being ACKed")}}else if(i==="config"){let{aggregations:c,columns:p,filter:a,groupBy:l,sort:m}=o.data;return this.aggregations=c,this.columns=p,this.filter=a,this.groupBy=l,this.sort=m,l.length>0?this.isTree=!0:this.isTree&&(this.isTree=!1),C==null||C(`config change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:i,config:o.data}}else{if(i==="groupBy")return this.isTree=o.data.length>0,this.groupBy=o.data,C==null||C(`groupBy change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:i,groupBy:o.data};if(i==="columns")return this.columns=o.data,{clientViewportId:n,type:i,columns:o.data};if(i==="filter")return this.filter=o.data,{clientViewportId:n,type:i,filter:o.data};if(i==="aggregate")return this.aggregations=o.data,{clientViewportId:n,type:"aggregate",aggregations:this.aggregations};if(i==="sort")return this.sort=o.data,{clientViewportId:n,type:i,sort:this.sort};if(i!=="selection"){if(i==="disable")return this.disabled=!0,{type:"disabled",clientViewportId:n};if(i==="enable")return this.disabled=!1,{type:"enabled",clientViewportId:n};if(i==="CREATE_VISUAL_LINK"){let[c,p,a]=t;return this.linkedParent={colName:c,parentViewportId:p,parentColName:a},this.pendingLinkedParent=void 0,{type:"vuu-link-created",clientViewportId:n,colName:c,parentViewportId:p,parentColName:a}}else if(i==="REMOVE_VISUAL_LINK")return this.linkedParent=void 0,{type:"vuu-link-removed",clientViewportId:n}}}}rangeRequest(e,t){H&&this.rangeMonitor.set(t);let n="CHANGE_VP_RANGE";if(this.dataWindow){let[r,o]=this.dataWindow.setClientRange(t.from,t.to),i,u=this.dataWindow.rowCount||void 0,c=r&&!this.rangeRequestAlreadyPending(t)?{type:n,viewPortId:this.serverViewportId,...K(t,this.bufferSize,u)}:null;if(c){H&&(C==null||C(`create CHANGE_VP_RANGE: [${c.from} - ${c.to}]`)),this.awaitOperation(e,{type:n});let a=this.pendingRangeRequests.at(-1);if(a)if(a.acked)console.warn("Range Request before previous request is filled");else{let{from:l,to:m}=a;this.dataWindow.outOfRange(l,m)?i={clientViewportId:this.clientViewportId,type:"debounce-begin"}:L==null||L("Range Request before previous request is acked")}this.pendingRangeRequests.push({...c,requestId:e}),this.useBatchMode&&(this.batchMode=!0)}else o.length>0&&(this.batchMode=!1);this.keys.reset(this.dataWindow.clientRange);let p=this.isTree?se:re;return o.length?[c,o.map(a=>p(a,this.keys,this.selectedRows))]:i?[c,void 0,i]:[c]}else return[null]}setLinks(e){return this.links=e,[{type:"vuu-links",links:e,clientViewportId:this.clientViewportId},this.pendingLinkedParent]}setMenu(e){return{type:"vuu-menu",menu:e,clientViewportId:this.clientViewportId}}openTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Qe,vpId:this.serverViewportId,treeKey:t.key}}closeTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Ne,vpId:this.serverViewportId,treeKey:t.key}}createLink(e,t,n,r){let o={type:"CREATE_VISUAL_LINK",parentVpId:n,childVpId:this.serverViewportId,parentColumnName:r,childColumnName:t};return this.awaitOperation(e,o),this.useBatchMode&&(this.batchMode=!0),o}removeLink(e){let t={type:"REMOVE_VISUAL_LINK",childVpId:this.serverViewportId};return this.awaitOperation(e,t),t}suspend(){this.suspended=!0,g==null||g("suspend")}resume(){return this.suspended=!1,H&&(C==null||C(`resume: ${this.currentData()}`)),[this.size,this.currentData()]}currentData(){let e=[];if(this.dataWindow){let t=this.dataWindow.getData(),{keys:n}=this,r=this.isTree?se:re;for(let o of t)o&&e.push(r(o,n,this.selectedRows))}return e}enable(e){return this.awaitOperation(e,{type:"enable"}),g==null||g(`enable: ${this.serverViewportId}`),{type:Be,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:"disable"}),g==null||g(`disable: ${this.serverViewportId}`),this.suspended=!1,{type:$e,viewPortId:this.serverViewportId}}columnRequest(e,t){return this.awaitOperation(e,{type:"columns",data:t}),C==null||C(`columnRequest: ${t}`),this.createRequest({columns:t})}filterRequest(e,t){this.awaitOperation(e,{type:"filter",data:t}),this.useBatchMode&&(this.batchMode=!0);let{filter:n}=t;return g==null||g(`filterRequest: ${n}`),this.createRequest({filterSpec:{filter:n}})}setConfig(e,t){this.awaitOperation(e,{type:"config",data:t});let{filter:n,...r}=t;return this.useBatchMode&&(this.batchMode=!0),H?C==null||C(`setConfig ${JSON.stringify(t)}`):g==null||g("setConfig"),this.createRequest({...r,filterSpec:typeof(n==null?void 0:n.filter)=="string"?{filter:n.filter}:{filter:""}},!0)}aggregateRequest(e,t){return this.awaitOperation(e,{type:"aggregate",data:t}),g==null||g(`aggregateRequest: ${t}`),this.createRequest({aggregations:t})}sortRequest(e,t){return this.awaitOperation(e,{type:"sort",data:t}),g==null||g(`sortRequest: ${JSON.stringify(t.sortDefs)}`),this.createRequest({sort:t})}groupByRequest(e,t=kt){var n;return this.awaitOperation(e,{type:"groupBy",data:t}),this.useBatchMode&&(this.batchMode=!0),this.isTree||(n=this.dataWindow)==null||n.clear(),this.createRequest({groupBy:t})}selectRequest(e,t){return this.selectedRows=t,this.awaitOperation(e,{type:"selection",data:t}),g==null||g(`selectRequest: ${t}`),{type:"SET_SELECTION",vpId:this.serverViewportId,selection:Te(t)}}removePendingRangeRequest(e,t){for(let n=this.pendingRangeRequests.length-1;n>=0;n--){let{from:r,to:o}=this.pendingRangeRequests[n],i=!0;if(e>=r&&e<o||t>r&&t<o){i||console.warn("removePendingRangeRequest TABLE_ROWS are not for latest request"),this.pendingRangeRequests.splice(n,1);break}else i=!1}}updateRows(e){var r,o,i;let[t,n]=Le(e);if(t&&n&&this.removePendingRangeRequest(t.rowIndex,n.rowIndex),e.length===1)if(t.vpSize===0&&this.disabled){C==null||C(`ignore a SIZE=0 message on disabled viewport (${e.length} rows)`);return}else t.updateType==="SIZE"&&this.setLastSizeOnlyUpdateSize(t.vpSize);for(let u of e)this.isTree&&Ft(u)||((u.updateType==="SIZE"||((r=this.dataWindow)==null?void 0:r.rowCount)!==u.vpSize)&&((o=this.dataWindow)==null||o.setRowCount(u.vpSize),this.rowCountChanged=!0),u.updateType==="U"&&(i=this.dataWindow)!=null&&i.setAtIndex(u)&&(this.hasUpdates=!0,this.batchMode||this.pendingUpdates.push(u)))}getClientRows(){let e,t="size-only";if(!this.hasUpdates&&!this.rowCountChanged)return j;if(this.hasUpdates){let{keys:n,selectedRows:r}=this,o=this.isTree?se:re;if(this.updateThrottleTimer&&(self.clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),this.pendingUpdates.length>0){e=[],t="update";for(let i of this.pendingUpdates)e.push(o(i,n,r));this.pendingUpdates.length=0}else{let i=this.dataWindow.getData();if(this.dataWindow.hasAllRowsWithinRange){e=[],t="batch";for(let u of i)e.push(o(u,n,r));this.batchMode=!1}}this.hasUpdates=!1}return this.throttleMessage(t)?j:[e,t]}createRequest(e,t=!1){return t?{type:"CHANGE_VP",viewPortId:this.serverViewportId,...e}:{type:"CHANGE_VP",viewPortId:this.serverViewportId,aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:this.filter.filter},...e}}},re=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>[s,r.keyFor(s),!0,!1,0,0,e,t?Q(o,s):0].concat(n),se=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>{let[i,u,,c,,p,...a]=n;return[s,r.keyFor(s),c,u,i,p,e,t?Q(o,s):0].concat(a)};var rt=1;var{debug:x,debugEnabled:oe,error:_,info:S,infoEnabled:Wt,warn:ie}=w("server-proxy"),b=()=>`${rt++}`,qt={},$t=s=>s.disabled!==!0&&s.suspended!==!0,Gt={type:"NO_ACTION"},Bt=(s,e,t)=>s.map(n=>n.parentVpId===e?{...n,label:t}:n);function Ht(s,e){return s.map(t=>{let{parentVpId:n}=t,r=e.get(n);if(r)return{...t,parentClientVpId:r.clientViewportId,label:r.title};throw Error("addLabelsToLinks viewport not found")})}var J=class{constructor(e,t){this.authToken="";this.user="user";this.pendingRequests=new Map;this.queuedRequests=[];this.cachedTableMetaRequests=new Map;this.cachedTableSchemas=new Map;this.connection=e,this.postMessageToClient=t,this.viewports=new Map,this.mapClientToServerViewport=new Map}async reconnect(){await this.login(this.authToken);let[e,t]=fe(Array.from(this.viewports.values()),$t);this.viewports.clear(),this.mapClientToServerViewport.clear();let n=r=>{r.forEach(o=>{let{clientViewportId:i}=o;this.viewports.set(i,o),this.sendMessageToServer(o.subscribe(),i)})};n(e),setTimeout(()=>{n(t)},2e3)}async login(e,t="user"){if(e)return this.authToken=e,this.user=t,new Promise((n,r)=>{this.sendMessageToServer({type:Ke,token:this.authToken,user:t},""),this.pendingLogin={resolve:n,reject:r}});this.authToken===""&&_("login, cannot login until auth token has been obtained")}subscribe(e){if(this.mapClientToServerViewport.has(e.viewport))_(`spurious subscribe call ${e.viewport}`);else{let t=this.getTableMeta(e.table),n=new z(e,this.postMessageToClient);this.viewports.set(e.viewport,n);let r=this.awaitResponseToMessage(n.subscribe(),e.viewport);Promise.all([r,t]).then(([i,u])=>{let{viewPortId:c}=i,{status:p}=n;e.viewport!==c&&(this.viewports.delete(e.viewport),this.viewports.set(c,n)),this.mapClientToServerViewport.set(e.viewport,c);let a=n.handleSubscribed(i,u);a&&(this.postMessageToClient(a),oe&&x(`post DataSourceSubscribedMessage to client: ${JSON.stringify(a)}`)),n.disabled&&this.disableViewport(n),this.queuedRequests.length>0&&this.processQueuedRequests(),p==="subscribing"&&!G(n.table)&&(this.sendMessageToServer({type:ne,vpId:c}),this.sendMessageToServer({type:je,vpId:c}),Array.from(this.viewports.entries()).filter(([l,{disabled:m}])=>l!==c&&!m).forEach(([l])=>{this.sendMessageToServer({type:ne,vpId:l})}))})}}processQueuedRequests(){let e={};for(;this.queuedRequests.length;){let t=this.queuedRequests.pop();if(t){let{clientViewportId:n,message:r,requestId:o}=t;if(r.type==="CHANGE_VP_RANGE"){if(e.CHANGE_VP_RANGE)continue;e.CHANGE_VP_RANGE=!0;let i=this.mapClientToServerViewport.get(n);i&&this.sendMessageToServer({...r,viewPortId:i},o)}}}}unsubscribe(e){let t=this.mapClientToServerViewport.get(e);t?(S==null||S(`Unsubscribe Message (Client to Server):\n ${t}`),this.sendMessageToServer({type:Ye,viewPortId:t})):_(`failed to unsubscribe client viewport ${e}, viewport not found`)}getViewportForClient(e,t=!0){let n=this.mapClientToServerViewport.get(e);if(n){let r=this.viewports.get(n);if(r)return r;if(t)throw Error(`Viewport not found for client viewport ${e}`);return null}else{if(this.viewports.has(e))return this.viewports.get(e);if(t)throw Error(`Viewport server id not found for client viewport ${e}`);return null}}setViewRange(e,t){let n=b(),[r,o,i]=e.rangeRequest(n,t.range);S==null||S(`setViewRange ${t.range.from} - ${t.range.to}`),r&&(this.sendIfReady(r,n,e.status==="subscribed")||this.queuedRequests.push({clientViewportId:t.viewport,message:r,requestId:n})),o?(S==null||S(`setViewRange ${o.length} rows returned from cache`),this.postMessageToClient({mode:"batch",type:"viewport-update",clientViewportId:e.clientViewportId,rows:o})):i&&this.postMessageToClient(i)}setConfig(e,t){let n=b(),r=e.setConfig(n,t.config);this.sendIfReady(r,n,e.status==="subscribed")}aggregate(e,t){let n=b(),r=e.aggregateRequest(n,t.aggregations);this.sendIfReady(r,n,e.status==="subscribed")}sort(e,t){let n=b(),r=e.sortRequest(n,t.sort);this.sendIfReady(r,n,e.status==="subscribed")}groupBy(e,t){let n=b(),r=e.groupByRequest(n,t.groupBy);this.sendIfReady(r,n,e.status==="subscribed")}filter(e,t){let n=b(),{filter:r}=t,o=e.filterRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}setColumns(e,t){let n=b(),{columns:r}=t,o=e.columnRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}setTitle(e,t){e&&(e.title=t.title,this.updateTitleOnVisualLinks(e))}select(e,t){let n=b(),{selected:r}=t,o=e.selectRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}disableViewport(e){let t=b(),n=e.disable(t);this.sendIfReady(n,t,e.status==="subscribed")}enableViewport(e){if(e.disabled){let t=b(),n=e.enable(t);this.sendIfReady(n,t,e.status==="subscribed")}}suspendViewport(e){e.suspend(),e.suspendTimer=setTimeout(()=>{S==null||S("suspendTimer expired, escalate suspend to disable"),this.disableViewport(e)},3e3)}resumeViewport(e){e.suspendTimer&&(x==null||x("clear suspend timer"),clearTimeout(e.suspendTimer),e.suspendTimer=null);let[t,n]=e.resume();x==null||x(`resumeViewport size ${t}, ${n.length} rows sent to client`),this.postMessageToClient({clientViewportId:e.clientViewportId,mode:"batch",rows:n,size:t,type:"viewport-update"})}openTreeNode(e,t){if(e.serverViewportId){let n=b();this.sendIfReady(e.openTreeNode(n,t),n,e.status==="subscribed")}}closeTreeNode(e,t){if(e.serverViewportId){let n=b();this.sendIfReady(e.closeTreeNode(n,t),n,e.status==="subscribed")}}createLink(e,t){let{parentClientVpId:n,parentColumnName:r,childColumnName:o}=t,i=b(),u=this.mapClientToServerViewport.get(n);if(u){let c=e.createLink(i,o,u,r);this.sendMessageToServer(c,i)}else _("ServerProxy unable to create link, viewport not found")}removeLink(e){let t=b(),n=e.removeLink(t);this.sendMessageToServer(n,t)}updateTitleOnVisualLinks(e){var r;let{serverViewportId:t,title:n}=e;for(let o of this.viewports.values())if(o!==e&&o.links&&t&&n&&(r=o.links)!=null&&r.some(i=>i.parentVpId===t)){let[i]=o.setLinks(Bt(o.links,t,n));this.postMessageToClient(i)}}removeViewportFromVisualLinks(e){var t;for(let n of this.viewports.values())if((t=n.links)!=null&&t.some(({parentVpId:r})=>r===e)){let[r]=n.setLinks(n.links.filter(({parentVpId:o})=>o!==e));this.postMessageToClient(r)}}menuRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,r]=$(e);this.sendMessageToServer({...r,vpId:t.serverViewportId},n)}}viewportRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,r]=$(e);this.sendMessageToServer({...r,vpId:t.serverViewportId,namedParams:{}},n)}}rpcCall(e){let[t,n]=$(e),r=tt(n.service);this.sendMessageToServer(n,t,{module:r})}handleMessageFromClient(e){var t;if(Ae(e))if(e.type==="disable"){let n=this.getViewportForClient(e.viewport,!1);return n!==null?this.disableViewport(n):void 0}else{let n=this.getViewportForClient(e.viewport);switch(e.type){case"setViewRange":return this.setViewRange(n,e);case"config":return this.setConfig(n,e);case"aggregate":return this.aggregate(n,e);case"sort":return this.sort(n,e);case"groupBy":return this.groupBy(n,e);case"filter":return this.filter(n,e);case"select":return this.select(n,e);case"suspend":return this.suspendViewport(n);case"resume":return this.resumeViewport(n);case"enable":return this.enableViewport(n);case"openTreeNode":return this.openTreeNode(n,e);case"closeTreeNode":return this.closeTreeNode(n,e);case"createLink":return this.createLink(n,e);case"removeLink":return this.removeLink(n);case"setColumns":return this.setColumns(n,e);case"setTitle":return this.setTitle(n,e);default:}}else{if(Pe(e))return this.viewportRpcCall(e);if(De(e))return this.menuRpcCall(e);{let{type:n,requestId:r}=e;switch(n){case"GET_TABLE_LIST":{(t=this.tableList)!=null||(this.tableList=this.awaitResponseToMessage({type:n},r)),this.tableList.then(o=>{this.postMessageToClient({type:"TABLE_LIST_RESP",tables:o.tables,requestId:r})});return}case"GET_TABLE_META":{this.getTableMeta(e.table,r).then(o=>{o&&this.postMessageToClient({type:"TABLE_META_RESP",tableSchema:o,requestId:r})});return}case"RPC_CALL":return this.rpcCall(e);default:}}}_(`Vuu ServerProxy Unexpected message from client ${JSON.stringify(e)}`)}getTableMeta(e,t=b()){if(G(e))return Promise.resolve(void 0);let n=`${e.module}:${e.table}`,r=this.cachedTableMetaRequests.get(n);return r||(r=this.awaitResponseToMessage({type:"GET_TABLE_META",table:e},t),this.cachedTableMetaRequests.set(n,r)),r==null?void 0:r.then(o=>this.cacheTableMeta(o))}awaitResponseToMessage(e,t=b()){return new Promise((n,r)=>{this.sendMessageToServer(e,t),this.pendingRequests.set(t,{reject:r,resolve:n})})}sendIfReady(e,t,n=!0){return n&&this.sendMessageToServer(e,t),n}sendMessageToServer(e,t=`${rt++}`,n=qt){let{module:r="CORE"}=n;this.authToken&&this.connection.send({requestId:t,sessionId:this.sessionId,token:this.authToken,user:this.user,module:r,body:e})}handleMessageFromServer(e){var u;let{body:t,requestId:n,sessionId:r}=e,o=this.pendingRequests.get(n);if(o){let{resolve:a}=o;this.pendingRequests.delete(n),a(t);return}let{viewports:i}=this;switch(t.type){case ze:this.sendMessageToServer({type:Je,ts:+new Date},"NA");break;case"LOGIN_SUCCESS":if(r)this.sessionId=r,(u=this.pendingLogin)==null||u.resolve(r),this.pendingLogin=void 0;else throw Error("LOGIN_SUCCESS did not provide sessionId");break;case"REMOVE_VP_SUCCESS":{let a=i.get(t.viewPortId);a&&(this.mapClientToServerViewport.delete(a.clientViewportId),i.delete(t.viewPortId),this.removeViewportFromVisualLinks(t.viewPortId))}break;case Ze:{let a=this.viewports.get(t.vpId);a&&a.completeOperation(n)}break;case Fe:case Ge:if(i.has(t.viewPortId)){let a=this.viewports.get(t.viewPortId);if(a){let l=a.completeOperation(n);l!==void 0&&(this.postMessageToClient(l),oe&&x(`postMessageToClient ${JSON.stringify(l)}`))}}break;case He:{let a=this.viewports.get(t.viewPortId);if(a){let l=a.completeOperation(n);if(l){this.postMessageToClient(l);let[m,y]=a.resume();this.postMessageToClient({clientViewportId:a.clientViewportId,mode:"batch",rows:y,size:m,type:"viewport-update"})}}}break;case"TABLE_ROW":{let a=_e(t.rows);for(let[l,m]of Object.entries(a)){let y=i.get(l);y?y.updateRows(m):ie==null||ie(`TABLE_ROW message received for non registered viewport ${l}`)}this.processUpdates()}break;case"CHANGE_VP_RANGE_SUCCESS":{let a=this.viewports.get(t.viewPortId);if(a){let{from:l,to:m}=t;a.completeOperation(n,l,m)}}break;case Xe:case We:break;case"CREATE_VISUAL_LINK_SUCCESS":{let a=this.viewports.get(t.childVpId),l=this.viewports.get(t.parentVpId);if(a&&l){let{childColumnName:m,parentColumnName:y}=t,O=a.completeOperation(n,m,l.clientViewportId,y);O&&this.postMessageToClient(O)}}break;case"REMOVE_VISUAL_LINK_SUCCESS":{let a=this.viewports.get(t.childVpId);if(a){let l=a.completeOperation(n);l&&this.postMessageToClient(l)}}break;case"VP_VISUAL_LINKS_RESP":{let a=this.getActiveLinks(t.links),l=this.viewports.get(t.vpId);if(a.length&&l){let m=Ht(a,this.viewports),[y,O]=l.setLinks(m);if(this.postMessageToClient(y),O){let{link:le,parentClientVpId:st}=O,ce=b(),pe=this.mapClientToServerViewport.get(st);if(pe){let ot=l.createLink(ce,le.fromColumn,pe,le.toColumn);this.sendMessageToServer(ot,ce)}}}}break;case"VIEW_PORT_MENUS_RESP":if(t.menu.name){let a=this.viewports.get(t.vpId);if(a){let l=a.setMenu(t.menu);this.postMessageToClient(l)}}break;case"VP_EDIT_RPC_RESPONSE":this.postMessageToClient({action:t.action,requestId:n,rpcName:t.rpcName,type:"VP_EDIT_RPC_RESPONSE"});break;case"VP_EDIT_RPC_REJECT":this.viewports.get(t.vpId)&&this.postMessageToClient({requestId:n,type:"VP_EDIT_RPC_REJECT",error:t.error});break;case"VIEW_PORT_MENU_REJ":{console.log("send menu error back to client");let{error:a,rpcName:l,vpId:m}=t,y=this.viewports.get(m);y&&this.postMessageToClient({clientViewportId:y.clientViewportId,error:a,rpcName:l,type:"VIEW_PORT_MENU_REJ",requestId:n});break}case"VIEW_PORT_MENU_RESP":if(Ue(t)){let{action:a,rpcName:l}=t;this.awaitResponseToMessage({type:"GET_TABLE_META",table:a.table}).then(m=>{let y=te(m);this.postMessageToClient({rpcName:l,type:"VIEW_PORT_MENU_RESP",action:{...a,tableSchema:y},tableAlreadyOpen:this.isTableOpen(a.table),requestId:n})})}else{let{action:a}=t;this.postMessageToClient({type:"VIEW_PORT_MENU_RESP",action:a||Gt,tableAlreadyOpen:a!==null&&this.isTableOpen(a.table),requestId:n})}break;case"RPC_RESP":{let{method:a,result:l}=t;this.postMessageToClient({type:"RPC_RESP",method:a,result:l,requestId:n})}break;case"VIEW_PORT_RPC_REPONSE":{let{method:a,action:l}=t;this.postMessageToClient({type:"VIEW_PORT_RPC_RESPONSE",rpcName:a,action:l,requestId:n})}break;case"ERROR":_(t.msg);break;default:Wt&&S(`handleMessageFromServer ${t.type}.`)}}cacheTableMeta(e){let{module:t,table:n}=e.table,r=`${t}:${n}`,o=this.cachedTableSchemas.get(r);return o||(o=te(e),this.cachedTableSchemas.set(r,o)),o}isTableOpen(e){if(e){let t=e.table;for(let n of this.viewports.values())if(!n.suspended&&n.table.table===t)return!0}}getActiveLinks(e){return e.filter(t=>{let n=this.viewports.get(t.parentVpId);return n&&!n.suspended})}processUpdates(){this.viewports.forEach(e=>{var t;if(e.hasUpdatesToProcess){let n=e.getClientRows();if(n!==j){let[r,o]=n,i=e.getNewRowCount();(i!==void 0||r&&r.length>0)&&(oe&&x(`postMessageToClient #${e.clientViewportId} viewport-update ${o}, ${(t=r==null?void 0:r.length)!=null?t:"no"} rows, size ${i}`),o&&this.postMessageToClient({clientViewportId:e.clientViewportId,mode:o,rows:r,size:i,type:"viewport-update"}))}}})}};var D,{info:ae,infoEnabled:ue}=w("worker");async function jt(s,e,t,n,r,o,i){let u=await ve(s,e,c=>{ke(c)?postMessage({type:"connection-metrics",messages:c}):Oe(c)?(r(c),c.status==="reconnected"&&D.reconnect()):D.handleMessageFromServer(c)},o,i);D=new J(u,c=>zt(c)),u.requiresLogin&&await D.login(t,n)}function zt(s){postMessage(s)}var Jt=async({data:s})=>{switch(s.type){case"connect":await jt(s.url,s.protocol,s.token,s.username,postMessage,s.retryLimitDisconnect,s.retryLimitStartup),postMessage({type:"connected"});break;case"subscribe":ue&&ae(`client subscribe: ${JSON.stringify(s)}`),D.subscribe(s);break;case"unsubscribe":ue&&ae(`client unsubscribe: ${JSON.stringify(s)}`),D.unsubscribe(s.viewport);break;default:ue&&ae(`client message: ${JSON.stringify(s)}`),D.handleMessageFromClient(s)}};self.addEventListener("message",Jt);postMessage({type:"ready"});\n\n';var Ui=new Blob([on()+Mn],{type:"text/javascript"}),Gi=URL.createObjectURL(Ui),$e,dr,fr=[],Wi,Hi,$i=new Promise((n,e)=>{Wi=n,Hi=e}),Pn=()=>$i,pt=new Map,Mt=new Map,Ki=async({handleConnectionStatusChange:n,protocol:e,retryLimitDisconnect:t,retryLimitStartup:r,token:s="",username:i,url:o})=>s===""&&dr===void 0?new Promise(a=>{fr.push({resolve:a})}):dr||(dr=new Promise(a=>{let u=new Worker(Gi),c=window.setTimeout(()=>{console.error("timed out waiting for worker to load")},1e3);u.onmessage=p=>{let{data:h}=p;if(h.type==="ready")window.clearTimeout(c),u.postMessage({protocol:e,retryLimitDisconnect:t,retryLimitStartup:r,token:s,type:"connect",url:o,username:i});else if(h.type==="connected"){u.onmessage=En,a(u);for(let f of fr)f.resolve(u);fr.length=0}else hr(h)?n({data:h}):console.warn("ConnectionManager: Unexpected message from the worker")}}));function En({data:n}){if(Cn(n)){let e=pt.get(n.clientViewportId);e?e.postMessageToClientDataSource(n):console.error(`[ConnectionManager] ${n.type} message received, viewport not found`)}else if(hr(n))In.emit("connection-status",n);else if(Rn(n))In.emit("connection-metrics",n);else{let e=n.requestId;if(Mt.has(e)){let{resolve:t}=Mt.get(e);Mt.delete(e);let{type:r,requestId:s,...i}=n;wn(n)?t(n.result):n.type==="VP_EDIT_RPC_RESPONSE"||n.type==="VP_EDIT_RPC_REJECT"?t(n):vn(n)?t(n.tableSchema):t(i)}else console.warn("%cConnectionManager Unexpected message from the worker","color:red;font-weight:bold;")}}var mr=n=>{let e=ue();return $e.postMessage({requestId:e,...n}),new Promise((t,r)=>{Mt.set(e,{resolve:t,reject:r})})},zi={subscribe:(n,e)=>{if(pt.get(n.viewport))throw Error("ConnectionManager attempting to subscribe with an existing viewport id");pt.set(n.viewport,{status:"subscribing",request:n,postMessageToClientDataSource:e}),$e.postMessage({type:"subscribe",...n})},unsubscribe:n=>{$e.postMessage({type:"unsubscribe",viewport:n})},send:n=>{$e.postMessage(n)},destroy:n=>{n&&pt.has(n)&&pt.delete(n)},rpcCall:async n=>mr(n),getTableList:async()=>mr({type:"GET_TABLE_LIST"}),getTableSchema:async n=>mr({type:Tn,table:n})},gr=class extends te{async connect({url:e,authToken:t,username:r,protocol:s,retryLimitDisconnect:i,retryLimitStartup:o}){return $e=await Ki({protocol:s,url:e,token:t,username:r,retryLimitDisconnect:i,retryLimitStartup:o,handleConnectionStatusChange:En}),zi}destroy(){$e.terminate()}},In=new gr;var qi=0,ht=class{constructor(e,t){this.from=e,this.to=t}},P=class{constructor(e={}){this.id=qi++,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=Y.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}};P.closedBy=new P({deserialize:n=>n.split(" ")});P.openedBy=new P({deserialize:n=>n.split(" ")});P.group=new P({deserialize:n=>n.split(" ")});P.contextHash=new P({perNode:!0});P.lookAhead=new P({perNode:!0});P.mounted=new P({perNode:!0});var ji=Object.create(null),Y=class{constructor(e,t,r,s=0){this.name=e,this.props=t,this.id=r,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):ji,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new Y(e.name||"",t,e.id,r);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(s)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}}return s}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(P.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let s of r.split(" "))t[s]=e[r];return r=>{for(let s=r.prop(P.group),i=-1;i<(s?s.length:0);i++){let o=t[i<0?r.name:s[i]];if(o)return o}}}};Y.none=new Y("",Object.create(null),0,8);var Ke=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 r of this.types){let s=null;for(let i of e){let o=i(r);o&&(s||(s=Object.assign({},r.props)),s[o[0].id]=o[1])}t.push(s?new Y(r.name,s,r.id,r.flags):r)}return new Ke(t)}},It=new WeakMap,kn=new WeakMap,G;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(G||(G={}));var H=class{constructor(e,t,r,s,i){if(this.type=e,this.children=t,this.positions=r,this.length=s,this.props=null,i&&i.length){this.props=Object.create(null);for(let[o,a]of i)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=this.prop(P.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let s=r.toString();s&&(t&&(t+=","),t+=s)}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 qe(this.topNode,e)}cursorAt(e,t=0,r=0){let s=It.get(this)||this.topNode,i=new qe(s);return i.moveTo(e,t),It.set(this,i._tree),i}get topNode(){return new oe(this,0,0,null)}resolve(e,t=0){let r=ze(It.get(this)||this.topNode,e,t,!1);return It.set(this,r),r}resolveInner(e,t=0){let r=ze(kn.get(this)||this.topNode,e,t,!0);return kn.set(this,r),r}iterate(e){let{enter:t,leave:r,from:s=0,to:i=this.length}=e,o=e.mode||0,a=(o&G.IncludeAnonymous)>0;for(let u=this.cursor(o|G.IncludeAnonymous);;){let c=!1;if(u.from<=i&&u.to>=s&&(!a&&u.type.isAnonymous||t(u)!==!1)){if(u.firstChild())continue;c=!0}for(;c&&r&&(a||!u.type.isAnonymous)&&r(u),!u.nextSibling();){if(!u.parent())return;c=!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:Sr(Y.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,s)=>new H(this.type,t,r,s,this.propValues),e.makeTree||((t,r,s)=>new H(Y.none,t,r,s)))}static build(e){return Qi(e)}};H.empty=new H(Y.none,[],[],0);var dt=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 dt(this.buffer,this.index)}},fe=class{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return Y.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],r=this.buffer[e+3],s=this.set.types[t],i=s.name;if(/\W/.test(i)&&!s.isError&&(i=JSON.stringify(i)),e+=4,r==e)return i;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,r,s,i){let{buffer:o}=this,a=-1;for(let u=e;u!=t&&!(Ln(i,s,o[u+1],o[u+2])&&(a=u,r>0));u=o[u+3]);return a}slice(e,t,r){let s=this.buffer,i=new Uint16Array(t-e),o=0;for(let a=e,u=0;a<t;){i[u++]=s[a++],i[u++]=s[a++]-r;let c=i[u++]=s[a++]-r;i[u++]=s[a++]-e,o=Math.max(o,c)}return new fe(i,o,this.set)}};function Ln(n,e,t,r){switch(n){case-2:return t<e;case-1:return r>=e&&t<e;case 0:return t<e&&r>e;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function An(n,e){let t=n.childBefore(e);for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(n=t,t=r.prevSibling):t=r}return n}function ze(n,e,t,r){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!r&&n instanceof oe&&n.index<0?null:n.parent;if(!o)return n;n=o}let i=r?0:G.IgnoreOverlays;if(r)for(let o=n,a=o.parent;a;o=a,a=o.parent)o instanceof oe&&o.index<0&&((s=a.enter(e,t,i))===null||s===void 0?void 0:s.from)!=o.from&&(n=a);for(;;){let o=n.enter(e,t,i);if(!o)return n;n=o}}var oe=class{constructor(e,t,r,s){this._tree=e,this.from=t,this.index=r,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,s,i=0){for(let o=this;;){for(let{children:a,positions:u}=o._tree,c=t>0?a.length:-1;e!=c;e+=t){let p=a[e],h=u[e]+o.from;if(Ln(s,r,h,h+p.length)){if(p instanceof fe){if(i&G.ExcludeBuffers)continue;let f=p.findChild(0,p.buffer.length,t,r-h,s);if(f>-1)return new le(new br(o,p,e,h),null,f)}else if(i&G.IncludeAnonymous||!p.type.isAnonymous||Cr(p)){let f;if(!(i&G.IgnoreMounts)&&p.props&&(f=p.prop(P.mounted))&&!f.overlay)return new oe(f.tree,h,e,o);let m=new oe(p,h,e,o);return i&G.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(t<0?p.children.length-1:0,t,r,s)}}}if(i&G.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))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,r=0){let s;if(!(r&G.IgnoreOverlays)&&(s=this._tree.prop(P.mounted))&&s.overlay){let i=e-this.from;for(let{from:o,to:a}of s.overlay)if((t>0?o<=i:o<i)&&(t<0?a>=i:a>i))return new oe(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}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 qe(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return ze(this,e,t,!1)}resolveInner(e,t=0){return ze(this,e,t,!0)}enterUnfinishedNodesBefore(e){return An(this,e)}getChild(e,t=null,r=null){let s=Et(this,e,t,r);return s.length?s[0]:null}getChildren(e,t=null,r=null){return Et(this,e,t,r)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return kt(this,e)}};function Et(n,e,t,r){let s=n.cursor(),i=[];if(!s.firstChild())return i;if(t!=null){for(;!s.type.is(t);)if(!s.nextSibling())return i}for(;;){if(r!=null&&s.type.is(r))return i;if(s.type.is(e)&&i.push(s.node),!s.nextSibling())return r==null?i:[]}}function kt(n,e,t=e.length-1){for(let r=n.parent;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}var br=class{constructor(e,t,r,s){this.parent=e,this.buffer=t,this.index=r,this.start=s}},le=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,r){this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:s}=this.context,i=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,r);return i<0?null:new le(this.context,this,i)}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,r=0){if(r&G.ExcludeBuffers)return null;let{buffer:s}=this.context,i=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new le(this.context,this,i)}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 le(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 le(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new qe(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,s=this.index+4,i=r.buffer[this.index+3];if(i>s){let o=r.buffer[this.index+1];e.push(r.slice(s,i,o)),t.push(0)}return new H(this.type,e,t,this.to-this.from)}resolve(e,t=0){return ze(this,e,t,!1)}resolveInner(e,t=0){return ze(this,e,t,!0)}enterUnfinishedNodesBefore(e){return An(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,r=null){let s=Et(this,e,t,r);return s.length?s[0]:null}getChildren(e,t=null,r=null){return Et(this,e,t,r)}get node(){return this}matchContext(e){return kt(this,e)}},qe=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 oe)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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:r,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof oe?(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,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:s}=this.buffer,i=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,r);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}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,r=this.mode){return this.buffer?r&G.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&G.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&G.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,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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,r,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(s.buffer.buffer[i+3]<this.index)return!1;({index:t,parent:r}=s)}else({index:t,_parent:r}=this._tree);for(;r;{index:t,_parent:r}=r)if(t>-1)for(let i=t+e,o=e<0?-1:r._tree.children.length;i!=o;i+=e){let a=r._tree.children[i];if(this.mode&G.IncludeAnonymous||a instanceof fe||!a.type.isAnonymous||Cr(a))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,r=0;if(e&&e.context==this.buffer)e:for(let s=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,r=i+1;break e}s=this.stack[--i]}for(let s=r;s<this.stack.length;s++)t=new le(this.buffer,t,this.stack[s]);return this.bufferNode=new le(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(s=!0)}for(;s&&t&&t(this),s=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,s=!0}}}matchContext(e){if(!this.buffer)return kt(this.node,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let s=e.length-1,i=this.stack.length-1;s>=0;i--){if(i<0)return kt(this.node,e,s);let o=r[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}};function Cr(n){return n.children.some(e=>e instanceof fe||!e.type.isAnonymous||Cr(e))}function Qi(n){var e;let{buffer:t,nodeSet:r,maxBufferLength:s=1024,reused:i=[],minRepeatType:o=r.types.length}=n,a=Array.isArray(t)?new dt(t,t.length):t,u=r.types,c=0,p=0;function h(v,L,C,x,W){let{id:M,start:w,end:N,size:X}=a,se=p;for(;X<0;)if(a.next(),X==-1){let Ce=i[M];C.push(Ce),x.push(w-v);return}else if(X==-3){c=M;return}else if(X==-4){p=M;return}else throw new RangeError(`Unrecognized record size: ${X}`);let Be=u[M],ye,pe,$r=w-v;if(N-w<=s&&(pe=D(a.pos-L,W))){let Ce=new Uint16Array(pe.size-pe.skip),ie=a.pos-pe.size,he=Ce.length;for(;a.pos>ie;)he=U(pe.start,Ce,he);ye=new fe(Ce,N-pe.start,r),$r=pe.start-v}else{let Ce=a.pos-X;a.next();let ie=[],he=[],Pe=M>=o?M:-1,Fe=0,Rt=N;for(;a.pos>Ce;)Pe>=0&&a.id==Pe&&a.size>=0?(a.end<=Rt-s&&(m(ie,he,w,Fe,a.end,Rt,Pe,se),Fe=ie.length,Rt=a.end),a.next()):h(w,Ce,ie,he,Pe);if(Pe>=0&&Fe>0&&Fe<ie.length&&m(ie,he,w,Fe,w,Rt,Pe,se),ie.reverse(),he.reverse(),Pe>-1&&Fe>0){let Kr=f(Be);ye=Sr(Be,ie,he,0,ie.length,0,N-w,Kr,Kr)}else ye=g(Be,ie,he,N-w,se-N)}C.push(ye),x.push($r)}function f(v){return(L,C,x)=>{let W=0,M=L.length-1,w,N;if(M>=0&&(w=L[M])instanceof H){if(!M&&w.type==v&&w.length==x)return w;(N=w.prop(P.lookAhead))&&(W=C[M]+w.length+N)}return g(v,L,C,x,W)}}function m(v,L,C,x,W,M,w,N){let X=[],se=[];for(;v.length>x;)X.push(v.pop()),se.push(L.pop()+C-W);v.push(g(r.types[w],X,se,M-W,N-M)),L.push(W-C)}function g(v,L,C,x,W=0,M){if(c){let w=[P.contextHash,c];M=M?[w].concat(M):[w]}if(W>25){let w=[P.lookAhead,W];M=M?[w].concat(M):[w]}return new H(v,L,C,x,M)}function D(v,L){let C=a.fork(),x=0,W=0,M=0,w=C.end-s,N={size:0,start:0,skip:0};e:for(let X=C.pos-v;C.pos>X;){let se=C.size;if(C.id==L&&se>=0){N.size=x,N.start=W,N.skip=M,M+=4,x+=4,C.next();continue}let Be=C.pos-se;if(se<0||Be<X||C.start<w)break;let ye=C.id>=o?4:0,pe=C.start;for(C.next();C.pos>Be;){if(C.size<0)if(C.size==-3)ye+=4;else break e;else C.id>=o&&(ye+=4);C.next()}W=pe,x+=se,M+=ye}return(L<0||x==v)&&(N.size=x,N.start=W,N.skip=M),N.size>4?N:void 0}function U(v,L,C){let{id:x,start:W,end:M,size:w}=a;if(a.next(),w>=0&&x<o){let N=C;if(w>4){let X=a.pos-(w-4);for(;a.pos>X;)C=U(v,L,C)}L[--C]=N,L[--C]=M-v,L[--C]=W-v,L[--C]=x}else w==-3?c=x:w==-4&&(p=x);return C}let V=[],I=[];for(;a.pos>0;)h(n.start||0,n.bufferStart||0,V,I,-1);let R=(e=n.length)!==null&&e!==void 0?e:V.length?I[0]+V[0].length:0;return new H(u[n.topID],V.reverse(),I.reverse(),R)}var Vn=new WeakMap;function Pt(n,e){if(!n.isAnonymous||e instanceof fe||e.type!=n)return 1;let t=Vn.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=n||!(r instanceof H)){t=1;break}t+=Pt(n,r)}Vn.set(e,t)}return t}function Sr(n,e,t,r,s,i,o,a,u){let c=0;for(let g=r;g<s;g++)c+=Pt(n,e[g]);let p=Math.ceil(c*1.5/8),h=[],f=[];function m(g,D,U,V,I){for(let R=U;R<V;){let v=R,L=D[R],C=Pt(n,g[R]);for(R++;R<V;R++){let x=Pt(n,g[R]);if(C+x>=p)break;C+=x}if(R==v+1){if(C>p){let x=g[v];m(x.children,x.positions,0,x.children.length,D[v]+I);continue}h.push(g[v])}else{let x=D[R-1]+g[R-1].length-L;h.push(Sr(n,g,D,v,R,L,x,null,u))}f.push(L+I-i)}}return m(e,t,r,s,0),(a||u)(h,f,o)}var Vt=class{startParse(e,t,r){return typeof e=="string"&&(e=new yr(e)),r=r?r.length?r.map(s=>new ht(s.from,s.to)):[new ht(0,0)]:[new ht(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let s=this.startParse(e,t,r);for(;;){let i=s.advance();if(i)return i}}},yr=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 Sp=new P({perNode:!0});var Qe=class{constructor(e,t,r,s,i,o,a,u,c,p=0,h){this.p=e,this.stack=t,this.state=r,this.reducePos=s,this.pos=i,this.score=o,this.buffer=a,this.bufferBase=u,this.curContext=c,this.lookAhead=p,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,r=0){let s=e.parser.context;return new Qe(e,[],t,r,r,0,[],0,s?new Lt(s,s.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 r=e>>19,s=e&65535,{parser:i}=this.p,o=i.dynamicPrecedence(s);if(o&&(this.score+=o),r==0){this.pushState(i.getGoto(this.state,s,!0),this.reducePos),s<i.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,4,!0),this.reduceContext(s,this.reducePos);return}let a=this.stack.length-(r-1)*3-(e&262144?6:0),u=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-u;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let p=a?this.stack[a-1]:0,h=this.bufferBase+this.buffer.length-p;if(s<i.minRepeatTerm||e&131072){let f=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,u,f,h+4,!0)}if(e&262144)this.state=this.stack[a];else{let f=this.stack[a-3];this.state=i.getGoto(f,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,u)}storeNode(e,t,r,s=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==r)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=r;return}}}if(!i||this.pos==r)this.buffer.push(e,t,r,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=r,this.buffer[o+3]=s}}shift(e,t,r){let s=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,s),t<=this.p.parser.maxNode&&this.buffer.push(t,s,r,4);else{let i=e,{parser:o}=this.p;(r>this.pos||t<=o.maxNode)&&(this.pos=r,o.stateFlag(i,1)||(this.reducePos=r)),this.pushState(i,s),this.shiftContext(t,s),t<=o.maxNode&&this.buffer.push(t,s,r,4)}}apply(e,t,r){e&65536?this.reduce(e):this.shift(e,t,r)}useNode(e,t){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(r,s,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 r=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new Qe(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,r?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Rr(this);;){let r=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(r==0)return!1;if(!(r&65536))return!0;t.reduce(r)}}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 s=[];for(let i=0,o;i<t.length;i+=2)(o=t[i+1])!=this.state&&this.p.parser.hasAction(o,e)&&s.push(t[i],o);if(this.stack.length<120)for(let i=0;s.length<4<<1&&i<t.length;i+=2){let o=t[i+1];s.some((a,u)=>u&1&&a==o)||s.push(t[i],o)}t=s}let r=[];for(let s=0;s<t.length&&r.length<4;s+=2){let i=t[s+1];if(i==this.state)continue;let o=this.split();o.pushState(i,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[s],this.pos),o.score-=200,r.push(o)}return r}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let r=t>>19,s=t&65535,i=this.stack.length-r*3;if(i<0||e.getGoto(this.stack[i],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],r=(s,i)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-i;if(a>1){let u=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],u,!1)>=0)return a<<19|65536|u}}else{let a=r(o,i+1);if(a!=null)return a}})};return r(this.state,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.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Lt(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()}},Lt=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},On;(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"})(On||(On={}));var Rr=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,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}},Je=class{constructor(e,t,r){this.stack=e,this.pos=t,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Je(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 Je(this.stack,this.pos,this.index)}};function ft(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let r=0,s=0;r<n.length;){let i=0;for(;;){let o=n.charCodeAt(r++),a=!1;if(o==126){i=65535;break}o>=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,a=!0),i+=u,a)break;i*=46}t?t[s++]=i:t=new e(i)}return t}var je=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},_n=new je,wr=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=_n,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 r=this.range,s=this.rangeIndex,i=this.pos+e;for(;i<r.from;){if(!s)return null;let o=this.ranges[--s];i-=r.from-o.to,r=o}for(;t<0?i>r.to:i>=r.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];i+=o.from-r.to,r=o}return i}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,r,s;if(t>=0&&t<this.chunk.length)r=this.pos+e,s=this.chunk.charCodeAt(t);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(r=i,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),s=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),s}acceptToken(e,t=0){let r=t?this.resolveOffset(t,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}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=_n,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 r="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(r+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return r}},Se=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:r}=t.p;Hn(this.data,e,t,this.id,r.data,r.tokenPrecTable)}};Se.prototype.contextual=Se.prototype.fallback=Se.prototype.extend=!1;var vr=class{constructor(e,t,r){this.precTable=t,this.elseToken=r,this.data=typeof e=="string"?ft(e):e}token(e,t){let r=e.pos,s=0;for(;;){let i=e.next<0,o=e.resolveOffset(1,1);if(Hn(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(i||s++,o==null)break;e.reset(o,e.token)}s&&(e.reset(r,e.token),e.acceptToken(this.elseToken,s))}};vr.prototype.contextual=Se.prototype.fallback=Se.prototype.extend=!1;function Hn(n,e,t,r,s,i){let o=0,a=1<<r,{dialect:u}=t.p.parser;e:for(;a&n[o];){let c=n[o+1];for(let m=o+3;m<c;m+=2)if((n[m+1]&a)>0){let g=n[m];if(u.allows(g)&&(e.token.value==-1||e.token.value==g||Xi(g,e.token.value,s,i))){e.acceptToken(g);break}}let p=e.next,h=0,f=n[o+2];if(e.next<0&&f>h&&n[c+f*3-3]==65535&&n[c+f*3-3]==65535){o=n[c+f*3-1];continue e}for(;h<f;){let m=h+f>>1,g=c+m+(m<<1),D=n[g],U=n[g+1]||65536;if(p<D)f=m;else if(p>=U)h=m+1;else{o=n[g+2],e.advance();continue e}}break}}function Nn(n,e,t){for(let r=e,s;(s=n[r])!=65535;r++)if(s==t)return r-e;return-1}function Xi(n,e,t,r){let s=Nn(t,r,e);return s<0||Nn(t,r,n)<s}var ae=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),Tr=null,Bn;(function(n){n[n.Margin=25]="Margin"})(Bn||(Bn={}));function Fn(n,e,t){let r=n.cursor(G.IncludeAnonymous);for(r.moveTo(e);;)if(!(t<0?r.childBefore(e):r.childAfter(e)))for(;;){if((t<0?r.to<e:r.from>e)&&!r.type.isError)return t<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(n.length,Math.max(r.from+1,e+25));if(t<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return t<0?0:n.length}}var Dr=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?Fn(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Fn(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 r=this.trees[t],s=this.index[t];if(s==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=r.children[s],o=this.start[t]+r.positions[s];if(o>e)return this.nextStart=o,null;if(i instanceof H){if(o==e){if(o<this.safeFrom)return null;let a=o+i.length;if(a<=this.safeTo){let u=i.prop(P.lookAhead);if(!u||a+u<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}}},xr=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new je)}getActions(e){let t=0,r=null,{parser:s}=e.p,{tokenizers:i}=s,o=s.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,u=0;for(let c=0;c<i.length;c++){if(!(1<<c&o))continue;let p=i[c],h=this.tokens[c];if(!(r&&!p.fallback)&&((p.contextual||h.start!=e.pos||h.mask!=o||h.context!=a)&&(this.updateCachedToken(h,p,e),h.mask=o,h.context=a),h.lookAhead>h.end+25&&(u=Math.max(h.lookAhead,u)),h.value!=0)){let f=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!p.extend&&(r=h,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return u&&e.setLookAhead(u),!r&&e.pos==this.stream.end&&(r=new je,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,t=this.addActions(e,r.value,r.end,t)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new je,{pos:r,p:s}=e;return t.start=r,t.end=Math.min(r+1,s.stream.end),t.value=r==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,r){let s=this.stream.clipPos(r.pos);if(t.token(this.stream.reset(s,e),r),e.value>-1){let{parser:i}=r.p;for(let o=0;o<i.specialized.length;o++)if(i.specialized[o]==e.value){let a=i.specializers[o](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,r,s){for(let i=0;i<s;i+=3)if(this.actions[i]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=r,s}addActions(e,t,r,s){let{state:i}=e,{parser:o}=e.p,{data:a}=o;for(let u=0;u<2;u++)for(let c=o.stateSlot(i,u?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=me(a,c+2);else{s==0&&a[c+1]==2&&(s=this.putAction(me(a,c+2),t,r,s));break}a[c]==t&&(s=this.putAction(me(a,c+1),t,r,s))}return s}},Un;(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"})(Un||(Un={}));var Mr=class{constructor(e,t,r,s){this.parser=e,this.input=t,this.ranges=s,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 wr(t,s),this.tokens=new xr(e,this.stream),this.topTerm=e.top[1];let{from:i}=s[0];this.stacks=[Qe.start(this,e.top[0],i)],this.fragments=r.length&&this.stream.end-i>e.bufferLength*4?new Dr(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,r=this.stacks=[],s,i;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>t)r.push(a);else{if(this.advanceStack(a,r,e))continue;{s||(s=[],i=[]),s.push(a);let u=this.tokens.getMainToken(a);i.push(u.value,u.end)}}break}}if(!r.length){let o=s&&Yi(s);if(o)return this.stackToTree(o);if(this.parser.strict)throw ae&&s&&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&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,i,r);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((a,u)=>u.score-a.score);r.length>o;)r.pop();r.some(a=>a.reducePos>t)&&this.recovering--}else if(r.length>1){e:for(let o=0;o<r.length-1;o++){let a=r[o];for(let u=o+1;u<r.length;u++){let c=r[u];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)r.splice(u--,1);else{r.splice(o--,1);continue e}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let o=1;o<r.length;o++)r[o].pos<this.minStackPos&&(this.minStackPos=r[o].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,r){let s=e.pos,{parser:i}=this,o=ae?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,p=c?e.curContext.hash:0;for(let h=this.fragments.nodeAt(s);h;){let f=this.parser.nodeSet.types[h.type.id]==h.type?i.getGoto(e.state,h.type.id):-1;if(f>-1&&h.length&&(!c||(h.prop(P.contextHash)||0)==p))return e.useNode(h,f),ae&&console.log(o+this.stackID(e)+` (via reuse of ${i.getName(h.type.id)})`),!0;if(!(h instanceof H)||h.children.length==0||h.positions[0]>0)break;let m=h.children[0];if(m instanceof H&&h.positions[0]==0)h=m;else break}}let a=i.stateSlot(e.state,4);if(a>0)return e.reduce(a),ae&&console.log(o+this.stackID(e)+` (via always-reduce ${i.getName(a&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let c=0;c<u.length;){let p=u[c++],h=u[c++],f=u[c++],m=c==u.length||!r,g=m?e:e.split();if(g.apply(p,h,f),ae&&console.log(o+this.stackID(g)+` (via ${p&65536?`reduce of ${i.getName(p&65535)}`:"shift"} for ${i.getName(h)} @ ${s}${g==e?"":", split"})`),m)return!0;g.pos>s?t.push(g):r.push(g)}return!1}advanceFully(e,t){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return Gn(e,t),!0}}runRecovery(e,t,r){let s=null,i=!1;for(let o=0;o<e.length;o++){let a=e[o],u=t[o<<1],c=t[(o<<1)+1],p=ae?this.stackID(a)+" -> ":"";if(a.deadEnd&&(i||(i=!0,a.restart(),ae&&console.log(p+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let h=a.split(),f=p;for(let m=0;h.forceReduce()&&m<10&&(ae&&console.log(f+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,r));m++)ae&&(f=this.stackID(h)+" -> ");for(let m of a.recoverByInsert(u))ae&&console.log(p+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,r);this.stream.end>a.pos?(c==a.pos&&(c++,u=0),a.recoverByDelete(u,c),ae&&console.log(p+this.stackID(a)+` (via recover-delete ${this.parser.getName(u)})`),Gn(a,r)):(!s||s.score<a.score)&&(s=a)}return s}stackToTree(e){return e.close(),H.build({buffer:Je.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=(Tr||(Tr=new WeakMap)).get(e);return t||Tr.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function Gn(n,e){for(let t=0;t<e.length;t++){let r=e[t];if(r.pos==n.pos&&r.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}var Ir=class{constructor(e,t,r){this.source=e,this.flags=t,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}};var Ve=class extends Vt{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 a=0;a<e.repeatNodeCount;a++)t.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),s=[];for(let a=0;a<t.length;a++)s.push([]);function i(a,u,c){s[a].push([u,u.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let u=a[0];typeof u=="string"&&(u=P[u]);for(let c=1;c<a.length;){let p=a[c++];if(p>=0)i(p,u,a[c++]);else{let h=a[c+-p];for(let f=-p;f>0;f--)i(a[c++],u,h);c++}}}this.nodeSet=new Ke(t.map((a,u)=>Y.define({name:u>=this.minRepeatTerm?void 0:a,id:u,props:s[u],top:r.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let o=ft(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(Wn),this.states=ft(e.states,Uint32Array),this.data=ft(e.stateData),this.goto=ft(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Se(o,a):a),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,r){let s=new Mr(this,e,t,r);for(let i of this.wrappers)s=i(s,e,t,r);return s}getGoto(e,t,r=!1){let s=this.goto;if(t>=s[0])return-1;for(let i=s[t+1];;){let o=s[i++],a=o&1,u=s[i++];if(a&&r)return u;for(let c=i+(o>>1);i<c;i++)if(s[i]==e)return u;if(a)return-1}}hasAction(e,t){let r=this.data;for(let s=0;s<2;s++)for(let i=this.stateSlot(e,s?2:1),o;;i+=3){if((o=r[i])==65535)if(r[i+1]==1)o=r[i=me(r,i+2)];else{if(r[i+1]==2)return me(r,i+2);break}if(o==t||o==0)return me(r,i+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){return!!this.allActions(e,r=>r==t?!0:null)}allActions(e,t){let r=this.stateSlot(e,4),s=r?t(r):void 0;for(let i=this.stateSlot(e,1);s==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=me(this.data,i+2);else break;s=t(me(this.data,i+1))}return s}nextStates(e){let t=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=me(this.data,r+2);else break;if(!(this.data[r+2]&1)){let s=this.data[r+1];t.some((i,o)=>o&1&&i==s)||t.push(this.data[r],s)}}return t}configure(e){let t=Object.assign(Object.create(Ve.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=r}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(r=>{let s=e.tokenizers.find(i=>i.from==r);return s?s.to:r})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((r,s)=>{let i=e.specializers.find(a=>a.from==r.external);if(!i)return r;let o=Object.assign(Object.assign({},r),{external:i.to});return t.specializers[s]=Wn(o),o})),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),r=t.map(()=>!1);if(e)for(let i of e.split(" ")){let o=t.indexOf(i);o>=0&&(r[o]=!0)}let s=null;for(let i=0;i<t.length;i++)if(!r[i])for(let o=this.dialects[t[i]],a;(a=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[a]=1;return new Ir(e,r,s)}static deserialize(e){return new Ve(e)}};function me(n,e){return n[e]|n[e+1]<<16}function Yi(n){let e=null;for(let t of n){let r=t.p.stoppedAt;(t.pos==t.p.stream.end||r!=null&&t.pos>r)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function Wn(n){if(n.external){let e=n.extend?1:0;return(t,r)=>n.external(t,r)<<1|e}return n.get}var Pr=Ve.deserialize({version:14,states:"%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",stateData:"#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",goto:"#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",nodeNames:"\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:"6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",tokenizers:[0,1],topRules:{Filter:[0,1]},tokenPrec:0});var Z,Er=class{constructor(){y(this,Z,void 0)}setFilterCombinatorOp(e,t=l(this,Z)){Ee(t)&&t.op===e||d(this,Z,{op:e,filters:[l(this,Z)]})}add(e){if(l(this,Z)===void 0)d(this,Z,e);else if(Ee(l(this,Z)))l(this,Z).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=l(this,Z)){if(Ee(t)){let r=t.filters.at(-1);r&&this.setColumn(e,r)}else t&&(t.column=e)}setOp(e,t=l(this,Z)){if(Ee(t)){let r=t.filters.at(-1);r&&this.setOp(e,r)}else t&&(t.op=e)}setValue(e,t=l(this,Z)){var r;if(Ee(t)){let s=t.filters.at(-1);s&&this.setValue(e,s)}else Zr(t)?((r=t.values)!=null||(t.values=[]),t.values.push(e)):Yr(t)&&(t.value=e)}toJSON(e=l(this,Z)){return this.name?{...e,name:this.name}:e}};Z=new WeakMap;var kr=(n,e)=>{let t=new Er,r=n.cursor();do{let{name:s,from:i,to:o}=r;switch(s){case"ColumnValueExpression":t.add({});break;case"ColumnSetExpression":t.add({op:"in"});break;case"Or":case"And":t.setFilterCombinatorOp(e.substring(i,o));break;case"Column":t.setColumn(e.substring(i,o));break;case"Operator":t.setOp(e.substring(i,o));break;case"String":t.setValue(e.substring(i+1,o-1));break;case"Number":t.setValue(parseFloat(e.substring(i,o)));break;case"True":t.setValue(!0);break;case"False":t.setValue(!1);break;case"FilterName":t.name=e.substring(i,o);break;default:}}while(r.next());return t.toJSON()};var Zi=Pr.configure({strict:!0}),Te=n=>{let e=Zi.parse(n);return kr(e,n)};function At(n,e){switch(e.op){case"in":return eo(n,e);case"=":return to(n,e);case">":return ro(n,e);case">=":return no(n,e);case"<":return so(n,e);case"<=":return io(n,e);case"starts":return oo(n,e);case"and":return ao(n,e);case"or":return uo(n,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var eo=(n,e)=>t=>e.values.indexOf(t[n[e.column]])!==-1,to=(n,e)=>t=>t[n[e.column]]===e.value,ro=(n,e)=>t=>t[n[e.column]]>e.value,no=(n,e)=>t=>t[n[e.column]]>=e.value,so=(n,e)=>t=>t[n[e.column]]<e.value,io=(n,e)=>t=>t[n[e.column]]<=e.value,oo=(n,e)=>{let t=e.value;if(typeof t!="string")throw Error("string filter applied to value of wrong type");return r=>{let s=r[n[e.column]];if(typeof s!="string")throw Error("string filter applied to value of wrong type");return s.toLowerCase().startsWith(t.toLowerCase())}},ao=(n,e)=>{let t=e.filters.map(r=>At(n,r));return r=>t.every(s=>s(r))};function uo(n,e){let t=e.filters.map(r=>At(n,r));return r=>t.some(s=>s(r))}var $n=(n,e,t,r,s,i)=>{let o=Le(s,n),a=n[n.length-1].aggType,u=t.map(c=>s[c]);switch(a){case 1:return zn(i,r,s,n,e,u);case 2:return lo(i,r,s,n,e,u);case 3:return Kn(i,s,n,e,u);case 4:return po(i,r,s,n,e,u);case 5:return ho(i,r,s,n,e,u);case 6:return co(i,r,s,n,e,u)}};function Kn(n,e,t,r,s){let i={},o=Le(e,t);function a(u){if(Array.isArray(u))return u.length;{let c=0;for(let p in u)c+=1+a(u[p]);return c}}for(let u in n){let c=a(n[u]);i[u]=c}for(let u=0;u<r.length;u++)for(let c in i)r[u][s[0]]===c&&(r[u][o]=i[c]);return console.log("!!!! targetData",r),console.log("!!!! counts",i),i}function Le(n,e){console.log("!!!! aggregation length",e.length);let t=e[e.length-1].column;return n[t]}function zn(n,e,t,r,s,i){let o={},a=Le(t,r);function u(c,p,h){if(Array.isArray(c)){let f=0;for(let m of c)f+=Number(p[m][h]);return f}else{let f=0;for(let m in c)f+=u(c[m],p,h);return f}}for(let c in n){console.log(c);let p=Number(u(n[c],e,a));o[c]=p}for(let c=0;c<s.length;c++)for(let p in o)s[c][i[0]]===p&&(s[c][a]=o[p]);return console.log("!!!! targetData",s),console.log("!!!! sums",o),o}function lo(n,e,t,r,s,i){let o={},a=Le(t,r),u=Kn(n,t,r,s,i),c=zn(n,e,t,r,s,i);for(let p in u){let h=0;h=c[p]/u[p],o[p]=h}for(let p=0;p<s.length;p++)for(let h in o)s[p][i[0]]===h&&(s[p][a]=o[h]);return console.log("!!!! targetData",s),console.log("!!!! averages",o),o}function Ot(n,e,t){let r=[];if(Array.isArray(n))for(let s of n)r.push(e[s][t]);else for(let s in n)r.push(...Ot(n[s],e,t));return r}function co(n,e,t,r,s,i){let o={},a=Le(t,r);for(let u in n){let c=Ot(n[u],e,a),p=[...new Set(c)];o[u]=p}for(let u=0;u<s.length;u++)for(let c in o)s[u][i[0]]===c&&(s[u][a]=o[c]);return o}function po(n,e,t,r,s,i){let o={},a=Le(t,r);for(let u in n){let c=Ot(n[u],e,a),p=Math.max(...c);o[u]=p}for(let u=0;u<s.length;u++)for(let c in o)s[u][i[0]]===c&&(s[u][a]=o[c]);return o}function ho(n,e,t,r,s,i){let o={},a=Le(t,r);for(let u in n){let c=Ot(n[u],e,a),p=Math.min(...c);o[u]=p}for(let u=0;u<s.length;u++)for(let c in o)s[u][i[0]]===c&&(s[u][a]=o[c]);return o}var{DEPTH:Vr,IS_EXPANDED:qn,KEY:Lr}=A,jn=(n,e)=>{let t=[];for(let r=0,s=0,i=!1,o=e.length;r<o;r++){let a=e[r],{[Vr]:u,[Lr]:c}=a;if(c===n){let p=a.slice();for(p[qn]=!1,t.push(p),s+=1,i=!0;r<o-1&&e[r+1][Vr]>u;)r+=1}else if(i){let p=a.slice();p[0]=s,p[1]=s,t.push(p),s+=1}else t.push(a),s+=1}return t},Ar=(n,e,t,r,s,i)=>{let o=t.map(a=>r[a]);return Qn(s,o,n,e,void 0,void 0,void 0,i)},Qn=(n,e,t,r=[],s="$root",i=1,o=[],a)=>{console.log("dataRowsFromGroups2 1)");let u=Object.keys(n).sort();for(let c of u){let p=o.length,h=`${s}|${c}`,f=[p,p,!1,!1,i,0,h,0];f[e[i-1]]=c,o.push(f),t.includes(h)&&(f[qn]=!0,Array.isArray(n[c])?fo(o,n[c],r,h,i+1):Qn(n[c],e,t,r,h,i+1,o,a))}console.log("dataRowsFromGroups2 2)");for(let c in o)for(let p in o)if(o[c][2]===!1&&a[p]!=null&&o[c][e[0]]===a[p][e[0]]){o[c]=o[c].splice(0,8).concat(a[p].slice(8,a[p].length));break}return console.log("dataRowsFromGroups2 3)"),o},fo=(n,e,t,r,s)=>{for(let i of e){let o=n.length,a=t[i].slice();a[0]=o,a[1]=o,a[Vr]=s,a[Lr]=`${r}|${a[Lr]}`,n.push(a)}},Jn=(n,e,t)=>{let r=e.map(o=>t[o]),s=go(n,r);return[mo(s,r),s]},mo=(n,e)=>{let r=[],s=0,i=Object.keys(n).sort();for(let o of i){let a=[s,s,!1,!1,1,0,`$root|${o}`,0];a[e[0]]=o,r.push(a),s+=1}return r};function go(n,e){let t={},r=e.length,s=r-1;for(let i=0,o=n.length;i<o;i++){let a=n[i],u=t,c,p;for(let h=0;h<r;h++){let f=e[h];p=a[f].toString(),c=u[p],c&&h===s?c.push(i):c?u=c:!c&&h<s?u=u[p]={}:c||(u[p]=[i])}}return console.log("!! groups",t),t}var bo=(n,e,[t,r])=>{let s=r==="D"?e[t]:n[t],i=r==="D"?n[t]:e[t];return s===i?0:i===null||s>i?1:-1},yo=n=>n.length===1?Co(n):n.length===2?So(n):To(n),Co=([[n,e]])=>(t,r)=>{let s=e==="D"?r[n]:t[n],i=e==="D"?t[n]:r[n];return s>i?1:i>s?-1:0},So=([[n,e],[t,r]])=>(s,i)=>{let o=e==="D"?i[n]:s[n],a=e==="D"?s[n]:i[n],u=r==="D"?i[t]:s[t],c=r==="D"?s[t]:i[t];return o>a?1:a>o?-1:u>c?1:c>u?-1:0},To=(n,e=bo)=>(t,r)=>{for(let s of n){let i=e(t,r,s);if(i!==0)return i}return 0},Xn=(n,{sortDefs:e},t)=>{let r=e.map(({column:i,sortType:o})=>[t[i],o]),s=yo(r);return n.slice().sort(s)};var{RENDER_IDX:Ro,SELECTED:wo}=A,Or=(n,e,t,r)=>{let[s]=n,i;if(r){let{count:o}=A;i=n.slice(0,o).concat(r.map(a=>n[a]))}else i=n.slice();return i[Ro]=e.keyFor(s),i[wo]=hn(t,s),i},vo=(n,e)=>{if(e){let{count:t}=A;for(let[r,s]of Object.entries(n)){let i=e[r];if(i===void 0)throw Error(`ArrayDataSource column ${r} is not in underlying data set`);if(i!==s-t)return!0}}return!1},Do=(n,e)=>{let{count:t}=A,r=[];return Object.entries(n).forEach(([s])=>{r.push(e[s]+t)}),r},_r=(n,e)=>{if(e&&vo(n,e))return Do(n,e)};var{KEY:Yn}=A,{debug:re}=Ge("ArrayDataSource"),Nr=n=>(e,t)=>[t,t,!0,!1,1,0,String(e[n]),0,...e],xo=(n,e)=>({columns:n.map(({name:r,serverDataType:s="string"})=>({name:r,serverDataType:s})),key:e!=null?e:n[0].name,table:{module:"",table:"Array"}}),q,S,B,Nt,_,mt,Bt,gt,Xe,_t=class extends te{constructor({aggregations:t,columnDescriptors:r,data:s,dataMap:i,filter:o,groupBy:a,keyColumn:u,rangeChangeRowset:c="delta",sort:p,title:h,viewport:f}){super();this.lastRangeServed={from:0,to:0};this.openTreeNodes=[];y(this,q,void 0);y(this,S,He);y(this,B,void 0);y(this,Nt,void 0);y(this,_,or);y(this,mt,0);y(this,Bt,0);y(this,gt,"initialising");y(this,Xe,void 0);this.selectedRows=[];this.keys=new We(l(this,_));this.processedData=void 0;this.insert=t=>{let r=Nr(this.key)(t,this.size);l(this,B).push(r);let{from:s,to:i}=l(this,_),[o]=r;o>=s&&o<i&&this.sendRowsToClient()};this.update=(t,r)=>{var u;let s=t[this.key],i=l(this,q)[r],o=(u=this.dataMap)==null?void 0:u[r],a=l(this,B).findIndex(c=>c[Yn]===s);if(a!==-1&&o!==void 0){let c=l(this,B)[a];c[i]=t[o];let{from:p,to:h}=l(this,_),[f]=c;f>=p&&f<h&&this.sendRowsToClient(!1,c)}};this.updateRow=t=>{let r=t[this.key],s=l(this,B).findIndex(i=>i[Yn]===r);if(s!==-1){let i=Nr(this.key)(t,s);l(this,B)[s]=i;let{from:o,to:a}=l(this,_);s>=o&&s<a&&this.sendRowsToClient(!1,i)}};if(!s||!r)throw Error("ArrayDataSource constructor called without data or without columnDescriptors");this.columnDescriptors=r,this.dataMap=i,this.key=u?this.columnDescriptors.findIndex(g=>g.name===u):0,this.rangeChangeRowset=c,this.tableSchema=xo(r,u),this.viewport=f||ue(),d(this,Bt,s.length),d(this,Xe,h);let m=r.map(g=>g.name);d(this,q,ir(m)),this.dataIndices=_r(l(this,q),this.dataMap),d(this,B,s.map(Nr(this.key))),this.config={...l(this,S),aggregations:t||l(this,S).aggregations,columns:m,filter:o||l(this,S).filter,groupBy:a||l(this,S).groupBy,sort:p||l(this,S).sort},re==null||re(`columnMap: ${JSON.stringify(l(this,q))}`)}async subscribe({viewport:t=(p=>(p=this.viewport)!=null?p:ue())(),columns:r,aggregations:s,range:i,sort:o,groupBy:a,filter:u},c){var m;this.clientCallback=c,this.viewport=t,d(this,gt,"subscribed"),this.lastRangeServed={from:0,to:0};let h=l(this,S),f=s||r||u||a||o;f&&(i&&d(this,_,i),h={...h,aggregations:s||l(this,S).aggregations,columns:r||l(this,S).columns,filter:u||l(this,S).filter,groupBy:a||l(this,S).groupBy,sort:o||l(this,S).sort}),(m=this.clientCallback)==null||m.call(this,{...h,type:"subscribed",clientViewportId:this.viewport,range:l(this,_),tableSchema:this.tableSchema}),f?this.config=h:(this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:l(this,B).length}),i?this.range=i:l(this,_)!==or&&this.sendRowsToClient())}unsubscribe(){console.log("unsubscribe noop")}suspend(){return console.log("noop"),this}resume(){return console.log("resume noop"),this}disable(){return console.log("disable noop"),this}enable(){return console.log("enable noop"),this}select(t){d(this,mt,t.length),re==null||re(`select ${JSON.stringify(t)}`),this.selectedRows=t,this.setRange(Ue(l(this,_)),!0)}openTreeNode(t){this.openTreeNodes.push(t),this.processedData=Ar(this.openTreeNodes,l(this,B),l(this,S).groupBy,l(this,q),this.groupMap,this.processedData),this.setRange(Ue(l(this,_)),!0)}closeTreeNode(t){this.openTreeNodes=this.openTreeNodes.filter(r=>r!==t),this.processedData&&(this.processedData=jn(t,this.processedData),this.setRange(Ue(l(this,_)),!0))}get links(){return l(this,Nt)}get menu(){return this._menu}get status(){return l(this,gt)}get data(){return l(this,B)}get currentData(){var t;return(t=this.processedData)!=null?t:l(this,B)}get table(){return this.tableSchema.table}get config(){return l(this,S)}set config(t){var r;if(this.applyConfig(t)){if(t){let s=l(this,S),i=(r=t==null?void 0:t.filter)!=null&&r.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Te(t.filter.filter)}}:t;d(this,S,ct(i));let o;if(bn(t)){let{filter:a,filterStruct:u=Te(a)}=t.filter;if(u){let c=At(l(this,q),u);o=l(this,B).filter(c)}else throw Error("filter must include filterStruct")}if(yn(t)&&(o=Xn(o!=null?o:l(this,B),t.sort,l(this,q))),this.openTreeNodes.length>0&&pr(s,t)&&(l(this,S).groupBy.length===0?this.openTreeNodes.length=0:console.log("adjust the openTReeNodes groupBy changed ",{originalGroupBy:s.groupBy,newGroupBy:i.groupBy})),gn(t)){let[a,u]=Jn(o!=null?o:l(this,B),t.groupBy,l(this,q));this.groupMap=u,o=a,this.openTreeNodes.length>0&&(o=Ar(this.openTreeNodes,l(this,B),l(this,S).groupBy,l(this,q),this.groupMap,o))}this.processedData=o==null?void 0:o.map((a,u)=>{let c=a.slice();return c[0]=u,c[1]=u,c})}this.setRange(Ue(l(this,_)),!0),this.emit("config",l(this,S))}}applyConfig(t){var r;if(xt(l(this,S),t)&&t){let s=(r=t==null?void 0:t.filter)!=null&&r.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Te(t.filter.filter)}}:t;return d(this,S,ct(s)),!0}}get selectedRowsCount(){return l(this,mt)}get size(){var t,r;return(r=(t=this.processedData)==null?void 0:t.length)!=null?r:l(this,B).length}get range(){return l(this,_)}set range(t){(t.from!==l(this,_).from||t.to!==l(this,_).to)&&this.setRange(t)}delete(t){console.log(`delete row ${t.join(",")}`)}setRange(t,r=!1){d(this,_,t),this.keys.reset(t),this.sendRowsToClient(r)}sendRowsToClient(t=!1,r){var s,i,o;if(r)(s=this.clientCallback)==null||s.call(this,{clientViewportId:this.viewport,mode:"update",rows:[Or(r,this.keys,this.selectedRows,this.dataIndices)],type:"viewport-update"});else{let a=this.rangeChangeRowset==="delta"&&!t?rn(this.lastRangeServed,l(this,_)):l(this,_),u=(i=this.processedData)!=null?i:l(this,B),c=u.slice(a.from,a.to).map(p=>Or(p,this.keys,this.selectedRows,this.dataIndices));(o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"batch",rows:c,size:u.length,type:"viewport-update"}),this.lastRangeServed={from:l(this,_).from,to:Math.min(l(this,_).to,l(this,_).from+c.length)}}}get columns(){return l(this,S).columns}set columns(t){let r=Jr(this.config.columns,t);if(r.length>0){let s=Xr(this.columnDescriptors,r,i=>i.name);console.log("columnsWithoutDescriptors",{columnsWithoutDescriptors:s})}d(this,q,ir(t)),this.dataIndices=_r(l(this,q),this.dataMap),this.config={...l(this,S),columns:t}}get aggregations(){return l(this,S).aggregations}set aggregations(t){var i;d(this,S,{...l(this,S),aggregations:t});let r=(i=this.processedData)!=null?i:l(this,B),s=l(this,B);$n(t,r,l(this,S).groupBy,s,l(this,q),this.groupMap),this.setRange(Ue(l(this,_)),!0),this.emit("config",l(this,S))}get sort(){return l(this,S).sort}set sort(t){re==null||re(`sort ${JSON.stringify(t)}`),this.config={...l(this,S),sort:t}}get filter(){return l(this,S).filter}set filter(t){re==null||re(`filter ${JSON.stringify(t)}`),this.config={...l(this,S),filter:t}}get groupBy(){return l(this,S).groupBy}set groupBy(t){this.config={...l(this,S),groupBy:t}}get title(){return l(this,Xe)}set title(t){d(this,Xe,t)}get _clientCallback(){return this.clientCallback}createLink({parentVpId:t,link:{fromColumn:r,toColumn:s}}){console.log("create link",{parentVpId:t,fromColumn:r,toColumn:s})}removeLink(){console.log("remove link")}findRow(t){let r=l(this,B)[t];if(r)return r;throw`no row found for key ${t}`}applyEdit(t,r,s){return console.log(`ArrayDataSource applyEdit ${t[0]} ${r} ${s}`),Promise.resolve(!0)}async menuRpcCall(t){return new Promise(r=>{let{type:s}=t;switch(s){case"VP_EDIT_CELL_RPC":break;default:r(void 0)}})}};q=new WeakMap,S=new WeakMap,B=new WeakMap,Nt=new WeakMap,_=new WeakMap,mt=new WeakMap,Bt=new WeakMap,gt=new WeakMap,Xe=new WeakMap;var Mo={columns:[],key:"",table:{module:"",table:""}},{DEPTH:Ae,IDX:Zn,IS_EXPANDED:Io,IS_LEAF:Po,KEY:ss,SELECTED:es}=A,ts=(n,e)=>{let[t]=n,r=n.slice();return r[1]=e.keyFor(t),r},Re,ne,K,we,ve,ce,Ft,Ut,De,Ye,Ze,rs=class extends te{constructor({aggregations:t,data:r,filter:s,groupBy:i,sort:o,title:a,viewport:u}){super();this.expandedRows=new Set;this.visibleRows=[];y(this,Re,[]);y(this,ne,He);y(this,K,void 0);y(this,we,{filter:""});y(this,ve,[]);y(this,ce,{from:0,to:0});y(this,Ft,0);y(this,Ut,0);y(this,De,{sortDefs:[]});y(this,Ye,"initialising");y(this,Ze,void 0);this.keys=new We(l(this,ce));if(!r)throw Error("JsonDataSource constructor called without data");[this.columnDescriptors,sr(this,K)._]=ur(r),this.visibleRows=l(this,K).filter(c=>c[Ae]===0).map((c,p)=>[p,p].concat(c.slice(2))),this.viewport=u||ue(),t&&d(this,Re,t),this.columnDescriptors&&d(this,ne,{...l(this,ne),columns:this.columnDescriptors.map(c=>c.name)}),s&&d(this,we,s),i&&d(this,ve,i),o&&d(this,De,o),d(this,Ze,a)}async subscribe({viewport:t=(p=>(p=this.viewport)!=null?p:ue())(),columns:r,aggregations:s,range:i,sort:o,groupBy:a,filter:u},c){var h;this.clientCallback=c,s&&d(this,Re,s),r&&d(this,ne,{...l(this,ne),columns:r}),u&&d(this,we,u),a&&d(this,ve,a),i&&d(this,ce,i),o&&d(this,De,o),l(this,Ye)==="initialising"&&(this.viewport=t,d(this,Ye,"subscribed"),(h=this.clientCallback)==null||h.call(this,{aggregations:l(this,Re),type:"subscribed",clientViewportId:this.viewport,columns:l(this,ne).columns,filter:l(this,we),groupBy:l(this,ve),range:l(this,ce),sort:l(this,De),tableSchema:Mo}),this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:this.visibleRows.length}))}unsubscribe(){console.log("noop")}suspend(){return console.log("noop"),this}resume(){return console.log("noop"),this}disable(){return console.log("noop"),this}enable(){return console.log("noop"),this}set data(t){console.log("set JsonDataSource data"),[this.columnDescriptors,sr(this,K)._]=ur(t),this.visibleRows=l(this,K).filter(r=>r[Ae]===0).map((r,s)=>[s,s].concat(r.slice(2))),requestAnimationFrame(()=>{this.sendRowsToClient()})}select(t){var s;let r=[];for(let i of l(this,K)){let{[Zn]:o,[es]:a}=i,u=a===1,c=dn(t,o);if(c!==u){let p=i.slice();p[es]=c?1:0,l(this,K)[o]=p,r.push(p)}}r.length>0&&((s=this.clientCallback)==null||s.call(this,{clientViewportId:this.viewport,mode:"update",type:"viewport-update",rows:r}))}openTreeNode(t){var i;this.expandedRows.add(t),this.visibleRows=ns(l(this,K),this.expandedRows);let{from:r,to:s}=l(this,ce);(i=this.clientCallback)==null||i.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(r,s).map(o=>ts(o,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}closeTreeNode(t,r=!1){if(this.expandedRows.delete(t),r)for(let s of this.expandedRows.keys())s.startsWith(t)&&this.expandedRows.delete(s);this.visibleRows=ns(l(this,K),this.expandedRows),this.sendRowsToClient()}get status(){return l(this,Ye)}get config(){return l(this,ne)}applyConfig(){return!0}get selectedRowsCount(){return l(this,Ft)}get size(){return l(this,Ut)}get range(){return l(this,ce)}set range(t){d(this,ce,t),this.keys.reset(t),requestAnimationFrame(()=>{this.sendRowsToClient()})}sendRowsToClient(){var s;let{from:t,to:r}=l(this,ce);(s=this.clientCallback)==null||s.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(t,r).map(i=>ts(i,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}get columns(){return l(this,ne).columns}set columns(t){d(this,ne,{...l(this,ne),columns:t})}get aggregations(){return l(this,Re)}set aggregations(t){d(this,Re,t)}get sort(){return l(this,De)}set sort(t){d(this,De,t)}get filter(){return l(this,we)}set filter(t){d(this,we,t)}get groupBy(){return l(this,ve)}set groupBy(t){d(this,ve,t)}get title(){return l(this,Ze)}set title(t){d(this,Ze,t)}createLink({parentVpId:t,link:{fromColumn:r,toColumn:s}}){console.log("create link",{parentVpId:t,fromColumn:r,toColumn:s})}removeLink(){console.log("remove link")}async menuRpcCall(t){console.log("rmenuRpcCall",{rpcRequest:t})}applyEdit(t,r,s){return console.log(`ArrayDataSource applyEdit ${t.join(",")} ${r} ${s}`),Promise.resolve(!0)}getChildRows(t){let r=l(this,K).find(s=>s[ss]===t);if(r){let{[Zn]:s,[Ae]:i}=r,o=s+1,a=[];do{let{[Ae]:u}=l(this,K)[o];if(u===i+1)a.push(l(this,K)[o]);else if(u<=i)break;o+=1}while(o<l(this,K).length);return a}else console.warn(`JsonDataSource getChildRows row not found for key ${t}`);return[]}getRowsAtDepth(t,r=!0){return(r?this.visibleRows:l(this,K)).filter(i=>i[Ae]===t)}};Re=new WeakMap,ne=new WeakMap,K=new WeakMap,we=new WeakMap,ve=new WeakMap,ce=new WeakMap,Ft=new WeakMap,Ut=new WeakMap,De=new WeakMap,Ye=new WeakMap,Ze=new WeakMap;function ns(n,e){let t=[],r={value:0};for(let s=0;s<n.length;s++){let i=n[s],{[Ae]:o,[ss]:a,[Po]:u}=i,c=e.has(a);if(t.push(Eo(i,r,c)),!u&&!c)do s+=1;while(s<n.length-1&&n[s+1][Ae]>o)}return t}var Eo=(n,e,t)=>{let r=n.slice();return r[0]=e.value,r[1]=e.value,t&&(r[Io]=!0),e.value+=1,r};var{info:j}=Ge("RemoteDataSource"),{KEY:ko}=A,b,Gt,bt,yt,et,ge,Ct,tt,E,Oe,is=class extends te{constructor({bufferSize:t=100,aggregations:r,columns:s,filter:i,groupBy:o,sort:a,table:u,title:c,viewport:p,visualLink:h}){super();this.server=null;y(this,b,He);y(this,Gt,[]);y(this,bt,void 0);y(this,yt,void 0);y(this,et,"throttle");y(this,ge,{from:0,to:0});y(this,Ct,0);y(this,tt,0);y(this,E,"initialising");y(this,Oe,void 0);this.handleMessageFromServer=t=>{var r,s;if(t.type==="subscribed")d(this,E,"subscribed"),t.tableSchema&&(this.tableSchema=t.tableSchema),(r=this.clientCallback)==null||r.call(this,t);else if(t.type==="disabled")d(this,E,"disabled");else if(t.type==="enabled")d(this,E,"enabled");else{if(Sn(t))return;t.type==="debounce-begin"?this.optimize="debounce":(t.type==="viewport-update"&&t.size!==void 0&&t.size!==l(this,tt)&&(d(this,tt,t.size),this.emit("resize",t.size)),this.configChangePending&&this.setConfigPending(),xn(t)?d(this,yt,t.menu):Dn(t)?d(this,bt,t.links):(s=this.clientCallback)==null||s.call(this,t),this.optimize==="debounce"&&this.revertDebounce())}};this.revertDebounce=lr(()=>{this.optimize="throttle"},100);this.rawRangeRequest=t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})};this.debounceRangeRequest=lr(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},50);this.throttleRangeRequest=cn(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},80);if(!u)throw Error("RemoteDataSource constructor called without table");this.bufferSize=t,this.table=u,this.viewport=p,d(this,b,{...l(this,b),aggregations:r||l(this,b).aggregations,columns:s||l(this,b).columns,filter:i||l(this,b).filter,groupBy:o||l(this,b).groupBy,sort:a||l(this,b).sort,visualLink:h||l(this,b).visualLink}),d(this,Oe,c),this.rangeRequest=this.throttleRangeRequest}async subscribe({viewport:t=(p=>(p=this.viewport)!=null?p:this.viewport=ue())(),columns:r,aggregations:s,range:i,sort:o,groupBy:a,filter:u},c){var f;if(l(this,E)==="disabled"||l(this,E)==="disabling"){this.enable(c);return}if(this.clientCallback=c,(s||r||u||a||o)&&d(this,b,{...l(this,b),aggregations:s||l(this,b).aggregations,columns:r||l(this,b).columns,filter:u||l(this,b).filter,groupBy:a||l(this,b).groupBy,sort:o||l(this,b).sort}),i&&d(this,ge,i),l(this,E)!=="initialising"&&l(this,E)!=="unsubscribed")return;d(this,E,"subscribing"),this.viewport=t,this.server=await Pn();let{bufferSize:h}=this;(f=this.server)==null||f.subscribe({...l(this,b),bufferSize:h,viewport:t,table:this.table,range:l(this,ge),title:l(this,Oe)},this.handleMessageFromServer)}unsubscribe(){var t,r;console.log(`unsubscribe #${this.viewport}`),j==null||j(`unsubscribe #${this.viewport}`),this.viewport&&((t=this.server)==null||t.unsubscribe(this.viewport)),(r=this.server)==null||r.destroy(this.viewport),this.server=null,this.removeAllListeners(),d(this,E,"unsubscribed"),this.viewport=void 0,this.range={from:0,to:0}}suspend(){var t;return console.log(`suspend #${this.viewport}, current status ${l(this,E)}`),j==null||j(`suspend #${this.viewport}, current status ${l(this,E)}`),this.viewport&&(d(this,E,"suspended"),(t=this.server)==null||t.send({type:"suspend",viewport:this.viewport})),this}resume(){var s;console.log(`resume #${this.viewport}, current status ${l(this,E)}`);let t=l(this,E).startsWith("disabl"),r=l(this,E)==="suspended";return j==null||j(`resume #${this.viewport}, current status ${l(this,E)}`),this.viewport&&(t?this.enable():r&&((s=this.server)==null||s.send({type:"resume",viewport:this.viewport}),d(this,E,"subscribed"))),this}disable(){var t;return j==null||j(`disable #${this.viewport}, current status ${l(this,E)}`),this.viewport&&(d(this,E,"disabling"),(t=this.server)==null||t.send({viewport:this.viewport,type:"disable"})),this}enable(t){var r;return j==null||j(`enable #${this.viewport}, current status ${l(this,E)}`),this.viewport&&(l(this,E)==="disabled"||l(this,E)==="disabling")&&(d(this,E,"enabling"),t&&(this.clientCallback=t),(r=this.server)==null||r.send({viewport:this.viewport,type:"enable"})),this}select(t){var r;d(this,Ct,t.length),this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"select",selected:t}))}openTreeNode(t){var r;this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"openTreeNode",key:t}))}closeTreeNode(t){var r;this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"closeTreeNode",key:t}))}get links(){return l(this,bt)}get menu(){return l(this,yt)}get status(){return l(this,E)}get optimize(){return l(this,et)}set optimize(t){if(t!==l(this,et)){switch(d(this,et,t),t){case"none":this.rangeRequest=this.rawRangeRequest;break;case"debounce":this.rangeRequest=this.debounceRangeRequest;break;case"throttle":this.rangeRequest=this.throttleRangeRequest;break}this.emit("optimize",t)}}get selectedRowsCount(){return l(this,Ct)}get size(){return l(this,tt)}get range(){return l(this,ge)}set range(t){(t.from!==l(this,ge).from||t.to!==l(this,ge).to)&&(d(this,ge,t),this.rangeRequest(t))}get config(){return l(this,b)}set config(t){var r;this.applyConfig(t)&&(l(this,b)&&this.viewport&&this.server&&t&&((r=this.server)==null||r.send({viewport:this.viewport,type:"config",config:l(this,b)})),this.emit("config",l(this,b)))}applyConfig(t){var r;if(xt(l(this,b),t)&&t){let s=(r=t==null?void 0:t.filter)!=null&&r.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Te(t.filter.filter)}}:t;return d(this,b,ct(s)),!0}}get columns(){return l(this,b).columns}set columns(t){if(d(this,b,{...l(this,b),columns:t}),this.viewport){let r={viewport:this.viewport,type:"setColumns",columns:t};this.server&&this.server.send(r)}this.emit("config",l(this,b))}get aggregations(){return l(this,b).aggregations}set aggregations(t){var r;d(this,b,{...l(this,b),aggregations:t}),this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"aggregate",aggregations:t})),this.emit("config",l(this,b))}get sort(){return l(this,b).sort}set sort(t){if(d(this,b,{...l(this,b),sort:t}),this.viewport){let r={viewport:this.viewport,type:"sort",sort:t};this.server&&this.server.send(r)}this.emit("config",l(this,b))}get filter(){return l(this,b).filter}set filter(t){if(d(this,b,{...l(this,b),filter:t}),this.viewport){let r={viewport:this.viewport,type:"filter",filter:t};this.server&&this.server.send(r)}this.emit("config",l(this,b))}get groupBy(){return l(this,b).groupBy}set groupBy(t){var r;if(Qr(this.groupBy,t)){let s=l(this,Gt).length>0;if(d(this,b,{...l(this,b),groupBy:t}),this.viewport){let i={viewport:this.viewport,type:"groupBy",groupBy:l(this,b).groupBy};this.server&&this.server.send(i)}!s&&t.length>0&&this.viewport&&((r=this.clientCallback)==null||r.call(this,{clientViewportId:this.viewport,mode:"batch",type:"viewport-update",size:0,rows:[]})),this.emit("config",l(this,b)),this.setConfigPending({groupBy:t})}}get title(){return l(this,Oe)}set title(t){var r;d(this,Oe,t),this.viewport&&t&&((r=this.server)==null||r.send({type:"setTitle",title:t,viewport:this.viewport}))}get visualLink(){return l(this,b).visualLink}set visualLink(t){var r,s;if(d(this,b,{...l(this,b),visualLink:t}),t){let{parentClientVpId:i,link:{fromColumn:o,toColumn:a}}=t;this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"createLink",parentClientVpId:i,parentColumnName:a,childColumnName:o}))}else this.viewport&&((s=this.server)==null||s.send({type:"removeLink",viewport:this.viewport}));this.emit("config",l(this,b))}setConfigPending(t){let r=this.configChangePending;this.configChangePending=t,t!==void 0?this.emit("config",t,!1):this.emit("config",r,!0)}async rpcCall(t){var r;if(this.viewport)return(r=this.server)==null?void 0:r.rpcCall({vpId:this.viewport,...t})}async menuRpcCall(t){var r;if(this.viewport)return(r=this.server)==null?void 0:r.rpcCall({vpId:this.viewport,...t})}applyEdit(t,r,s){return this.menuRpcCall({rowKey:t[ko],field:r,value:s,type:"VP_EDIT_CELL_RPC"}).then(i=>i!=null&&i.error?i.error:!0)}insertRow(t,r){return this.menuRpcCall({rowKey:t,data:r,type:"VP_EDIT_ADD_ROW_RPC"}).then(s=>s!=null&&s.error?s.error:!0)}deleteRow(t){return this.menuRpcCall({rowKey:t,type:"VP_EDIT_DELETE_ROW_RPC"}).then(r=>r!=null&&r.error?r.error:!0)}};b=new WeakMap,Gt=new WeakMap,bt=new WeakMap,yt=new WeakMap,et=new WeakMap,ge=new WeakMap,Ct=new WeakMap,tt=new WeakMap,E=new WeakMap,Oe=new WeakMap;var os=new Map,Vo=(n,e,t="")=>{let r,s=os.get(n);if(s&&s.has(e))r=s.get(e);else{let{data:i,map:o}=n,a=o[e];r=[];let u=new Set;for(let c of i){let p=c[a];u.has(p)||(u.add(p),r.push(p))}r.sort(),s?s.set(e,r):os.set(n,new Map([[e,r]]))}return t?r.filter(i=>i.toString().startsWith(t)):r},Wt=(n,e,t)=>new Promise(r=>{let s=Vo(n,e,t),i=s.length>20?s==null?void 0:s.slice(0,20).map(o=>o.toString()):s.map(o=>o.toString());setTimeout(()=>r(i),100)});var Ht,rt,_e,nt=class extends _t{constructor({data:t,menuRpcServices:r,rpcServices:s,table:i,menu:o,...a}){var u;if(t===void 0&&i===void 0)throw Error("TickingArrayDataSource must be constructed with data");super({...a,data:(u=t!=null?t:i==null?void 0:i.data)!=null?u:[]});y(this,Ht,void 0);y(this,rt,void 0);y(this,_e,void 0);this._menu=o,d(this,Ht,r),d(this,rt,s),d(this,_e,i),i&&(i.on("insert",this.insert),i.on("update",this.updateRow))}async subscribe(t,r){return super.subscribe(t,r)}set range(t){super.range=t}get range(){return super.range}getSelectedRows(){return this.selectedRows.reduce((t,r)=>{if(Array.isArray(r))r.forEach(s=>{let i=this.data[s];i&&t.push(i)});else{let s=this.data[r];s&&t.push(s)}return t},[])}applyEdit(t,r,s){var o;let i=t[A.KEY];return(o=l(this,_e))==null||o.update(i,r,s),Promise.resolve(!0)}async rpcCall(t){var s;let r=(s=l(this,rt))==null?void 0:s.find(i=>i.rpcName===t.rpcName);if(r)return r.service({...t});console.log(`no implementation for PRC service ${t.rpcName}`)}async menuRpcCall(t){var s;let r=(s=l(this,rt))==null?void 0:s.find(i=>i.rpcName===t.rpcName);if(r)switch(t.type){case"VIEW_PORT_MENUS_SELECT_RPC":{let i=this.getSelectedRows();return r.service({...t,selectedRows:i})}default:}return super.menuRpcCall(t)}getTypeaheadSuggestions(t,r){if(l(this,_e))return Wt(l(this,_e),t,r);throw Error("cannot call getTypeaheadSuggestions on TickingDataSOurce if table has not been provided")}};Ht=new WeakMap,rt=new WeakMap,_e=new WeakMap;var ad=n=>["Row No"].concat(Array(n).fill("").map((e,t)=>`Column ${t+1}`)),Lo=n=>e=>[`row ${e+1}`].concat(Array(n.length).fill(!0).map((t,r)=>`value ${r+1} @ ${e+1}`)),Ao=(n,e={})=>{if(typeof n=="number")return[{name:"row number",width:150}].concat(Array(n).fill(!0).map((t,r)=>{let s=`column ${r+1}`;return{name:s,width:100,...e[s]}}));throw Error("DefaultColumnGenerator must be passed columns (number)")},Br={ColumnGenerator:Ao,RowGenerator:Lo},ud=n=>{var t,r,s;let e=(t=n==null?void 0:n.table)!=null?t:"";switch(n==null?void 0:n.module){case"SIMUL":{let{ColumnGenerator:i,RowGenerator:o,createUpdateGenerator:a}=(r=simulDataGenerators[e])!=null?r:Br;return[i,o,a]}case"BASKET":{let{ColumnGenerator:i,RowGenerator:o,createUpdateGenerator:a}=(s=basketDataGenerators[e])!=null?s:Br;return[i,o,a]}case void 0:{let{ColumnGenerator:i,RowGenerator:o}=Br;return[i,o]}default:throw Error(`vuu-row-gererator table ${n==null?void 0:n.table} was requested but no generator is registered`)}},ld=(n,e,t,r)=>{let s=e(r),i=t(s.map(a=>a.name)),o=[];for(let a=0;a<n;a++){let u=i(a);if(u)o[a]=u;else break}return o};var Q,st,be,it,St,F=class extends te{constructor(t,r,s,i){super();y(this,Q,void 0);y(this,st,void 0);y(this,be,void 0);y(this,it,new Map);y(this,St,void 0);d(this,Q,r),d(this,st,s),d(this,St,t),d(this,be,s[t.key]),this.buildIndex(),i==null||i.setTable(this),i==null||i.setRange({from:0,to:100})}buildIndex(){for(let t=0;t<l(this,Q).length;t++){let r=l(this,Q)[t][l(this,be)];l(this,it).set(r,t)}}get data(){return l(this,Q)}get map(){return l(this,st)}get schema(){return l(this,St)}insert(t){let r=l(this,Q).length;l(this,Q).push(t);let s=t[l(this,be)];l(this,it).set(s,r),this.emit("insert",t)}findByKey(t){var s;let r=(s=l(this,it).get(t))!=null?s:-1;return l(this,Q)[r]}update(t,r,s){let i=l(this,Q).findIndex(a=>a[l(this,be)]===t),o=l(this,st)[r];if(i!==-1){let u=l(this,Q)[i].slice();u[o]=s,l(this,Q)[i]=u,this.emit("update",u,r)}}updateRow(t){let r=t[l(this,be)],s=l(this,Q).findIndex(i=>i[l(this,be)]===r);s!==-1&&(l(this,Q)[s]=t,this.emit("update",t))}};Q=new WeakMap,st=new WeakMap,be=new WeakMap,it=new WeakMap,St=new WeakMap;var J=n=>Object.values(n.columns).reduce((e,t,r)=>(e[t.name]=r,e),{}),Oo=(n,{columns:e,table:t},{columns:r,table:s})=>{let i=e.find(a=>a.name===n),o=r.find(a=>a.name===n);if(i&&o){if(i.serverDataType===o.serverDataType)return i.serverDataType;throw Error(`both tables ${t.table} and ${s.table} implement column ${n}, but with types differ`)}else{if(i)return i.serverDataType;if(o)return o.serverDataType;throw Error("WTF how is this possible")}},$t=(n,e,t,r)=>{let{map:s,schema:i}=e,{map:o,schema:a}=t,u=s[r],c=o[r],p=new Set([...i.columns,...a.columns].map(D=>D.name).sort()),h={key:r,table:n,columns:Array.from(p).map(D=>({name:D,serverDataType:Oo(D,i,a)}))},f=[],m=J(h);for(let D of e.data){let U=t.findByKey(String(D[u]));if(U){let V=[];for(let I of e.schema.columns){let R=D[s[I.name]];V[m[I.name]]=R}for(let I of t.schema.columns){let R=U[o[I.name]];V[m[I.name]]=R}f.push(V)}}let g=new F(h,f,m);return e.on("insert",D=>{let U=t.findByKey(String(D[u]));if(U){let V=[];for(let I of e.schema.columns){let R=D[s[I.name]];V[m[I.name]]=R}for(let I of t.schema.columns){let R=U[o[I.name]];V[m[I.name]]=R}g.insert(V)}}),t.on("update",D=>{let U=D[c],V=g.findByKey(U);if(V){let I=V.slice();for(let{name:R}of t.schema.columns)D[o[R]]!==I[m[R]]&&(I[m[R]]=D[o[R]]);g.updateRow(I)}}),g};function T(n,e){return n=Math.ceil(n),e=Math.floor(e),Math.floor(Math.random()*(e-n+1))+n}var Kt=(n,e)=>n+(e-n)*Math.random(),as=(n,e)=>{let t=e(0,1e3),r=e(t-n,t-1),s=e(t+1,t+n),i=r<0?t:r,o=Math.round(i*100)/100,a=Math.round(s*100)/100;return[o,a]},_o=(n,e,t,r)=>{let s=e-n;return Math.min(e+t*s,s/2+n+r)},No=(n,e,t,r)=>Math.max(n+1,(e-n)/2+n),Bo=(n,e,t,r)=>{let s=Math.min(e-1,(e-n)/2+n);return s<1?n+1:s},Fo=(n,e,t,r)=>{let s=e-n,i=s/2+n,o=Math.max(n-Math.min(t*s,10),i-r);return o<0?n:o},us=(n,e,t,r,s)=>{let i=e;Math.abs(n-e)<=1&&(i=e+1);let o=Fo(n,i,t,r),a=Bo(n,i,t,r),u=No(n,i,t,r),c=_o(n,i,t,r),p=Math.round(s(o,a)*100)/100,h=Math.round(s(u,c)*100)/100;return[p,h]};var Uo=n=>{let e=T(0,100)/1e3,t=T(0,10)>=5?1:-1;return n+n*e*t},ot=class{constructor(e){this.updating=!1;this.update=()=>{var e;if(this.range&&this.table){let t=(e=this.table)==null?void 0:e.data,{bid:r,ask:s,last:i,...o}=this.tickingColumns;if(t&&(t==null?void 0:t.length)>0){let a=Math.min(this.range.to,t.length);for(let u=this.range.from;u<a;u++){let c=0;if(T(0,10)<2){let h=this.table.data[u],f=t[u];if(r!==void 0&&s!==void 0){let{[r]:m,[s]:g}=f,[D,U]=us(m,g,10,5,Kt);if(h[s]=U,h[r]=D,i!==void 0){let V=Math.round((g+(U-g)/2)*100)/100;h[i]=V}}for(let m of Object.values(o))if(T(0,10)<5){c+=1;let D=Uo(f[m]);this.table&&(h[m]=D)}this.table&&c>0&&this.table.updateRow(h)}}}}this.updating&&(this.timer=window.setTimeout(this.update,500))};this.tickingColumns=e}setRange(e){this.range=e,!this.updating&&this.table&&this.startUpdating()}setTable(e){this.table=e}startUpdating(){this.updating=!0,this.update()}stopUpdating(){this.updating=!1,this.timer&&(window.clearTimeout(this.timer),this.timer=void 0)}};var ls=[["AAL.L","Anglo American PLC","436.35 13:13","5.35 (1.24%)","5,799,089"],["ABF.L","Associated British Foods PLC","3,435.60 13:12","7.40 (0.21%)","86,808"],["ADM.L","Admiral Group PLC","1,627.00 13:13",""],["ADN.L","Aberdeen Asset Management PLC","334.00 13:13","2.50 (0.75%)","806,880"],["AHT.L","Ashtead Group PLC","1,027.00 13:13","6.00 (0.59%)","331,255"],["ANTO.L","Antofagasta PLC","484.10 13:13","11.70 (2.48%)","1,753,976"],["ARM.L","ARM Holdings PLC","1,058.00 13:13","3.00 (0.28%)","475,927"],["AV.L","Aviva PLC","493.97 13:13","2.23 (0.45%)","2,226,835"],["AZN.L","AstraZeneca PLC","4,399.50 13:13","2.50 (0.06%)","815,133"],["BA.L","BAE Systems PLC","478.10 13:13","4.30 (0.91%)","2,039,934"],["BAB.L","Babcock International Group PLC","988.00 13:13","9.50 (0.97%)","209,614"],["BARC.L","Barclays PLC","226.30 13:13","1.15 (0.51%)","6,575,664"],["BATS.L","British American Tobacco PLC","3,803.50 13:13","8.50 (0.22%)","465,110"],["BDEV.L","Barratt Developments PLC","576.00 13:13","0.50 (0.09%)","1,044,365"],["BG.L","BG Group PLC","1,013.50 13:13","5.50 (0.55%)","1,507,332"],["BKG.L","Berkeley Group Holdings (The) PLC","3,126.00 13:13","15.00 (0.48%)","95,071"],["BLND.L","British Land Co PLC","828.06 13:12","10.44 (1.25%)","1,802,548"],["BLT.L","BHP Billiton PLC","881.40 13:13","4.30 (0.49%)","4,947,287"],["BNZL.L","Bunzl PLC","1,875.40 13:05","4.60 (0.24%)","104,541"],["BP.L","BP PLC","381.50 13:13","2.95 (0.78%)","10,493,561"],["BRBY.L","Burberry Group PLC","1,269.00 13:13","7.00 (0.55%)","295,647"],["BT-A","L,BT Group PLC","489.20 13:13","3.70 (0.75%)","3,914,982"],["CCL.L","Carnival PLC","3,426.00 13:12","22.00 (0.64%)","86,257"],["CNA.L","Centrica PLC","212.80 13:13","0.60 (0.28%)","2,144,540"],["CPG.L","Compass Group PLC","1,054.00 13:08","5.00 (0.48%)","1,001,167"],["CPI.L","Capita PLC","1,235.00 13:11","1.00 (0.08%)","244,591"],["CRH.L","CRH PLC","1,783.20 13:12","17.80 (0.99%)","897,325"],["DC.L","DIXONS CARPHONE","462.10 13:11",""],["DGE.L","Diageo PLC","1,881.50 13:13","6.50 (0.34%)","756,906"],["DLG.L","Direct Line Insurance Group PLC","403.80 13:13","0.40 (0.10%)","1,095,340"],["EXPN.L","Experian PLC","1,191.00 13:12","2.00 (0.17%)","467,283"],["EZJ.L","easyJet PLC","1,682.00 13:12","28.00 (1.64%)","1,191,230"],["FRES.L","Fresnillo PLC","678.50 13:12","6.50 (0.97%)","381,871"],["GFS.L","G4S PLC","232.30 13:03","2.00 (0.85%)","1,096,551"],["GKN.L","GKN PLC","294.80 13:12","2.50 (0.86%)","792,247"],["GLEN.L","Glencore PLC","90.48 13:13","1.65 (1.86%)","41,631,528"],["GSK.L","GlaxoSmithKline PLC","1,345.00 13:13","0.50 (0.04%)","1,767,356"],["HIK.L","Hikma Pharmaceuticals PLC","2,010.00 13:04","57.00 (2.92%)","261,511"],["HL.L","Hargreaves Lansdown PLC","1,488.03 13:12","9.97 (0.67%)","372,261"],["HMSO.L","Hammerson PLC","597.50 13:11","3.50 (0.58%)","478,301"],["HSBA.L","HSBC Holdings PLC","519.70 13:13","0.50 (0.10%)","7,415,629"],["IAG.L","International Consolidated Airlines Group SA","575.40 13:12","16.10 (2.72%)","4,311,514"],["IHG.L","InterContinental Hotels Group PLC","2,481.00 13:12","19.00 (0.76%)","219,918"],["III.L","3i Group PLC","487.30 13:11","4.50 (0.92%)","189,987"],["IMT.L","Imperial Tobacco Group PLC","3,571.00 13:13","29.00 (0.81%)","926,816"],["INTU.L","intu properties PLC","319.90 13:09","4.60 (1.42%)","514,821"],["ISAT.L","Inmarsat PLC","1,054.44 13:13","3.44 (0.33%)","988,089"],["ITRK.L","Intertek Group PLC","2,643.00 13:14","3.00 (0.11%)","45,868"],["ITV.L","ITV PLC","267.30 13:14","2.60 (0.96%)","3,453,208"],["JMAT.L","Johnson Matthey PLC","2,445.00 13:14","29.00 (1.20%)","276,397"],["KGF.L","Kingfisher PLC","346.20 13:14","4.30 (1.23%)","1,021,408"],["LAND.L","Land Securities Group PLC","1,239.00 13:13","7.00 (0.56%)","384,973"],["LGEN.L","Legal & General Group PLC","266.00 13:14","1.60 (0.60%)","1,998,399"],["LLOY.L","Lloyds Banking Group PLC","73.86 13:14","0.02 (0.03%)","18,907,878"],["LSE.L","London Stock Exchange Group PLC","2,544.00 13:11","6.00 (0.24%)","129,657"],["MGGT.L","Meggitt PLC","386.00 13:15","3.20 (0.84%)","611,044"],["MKS.L","Marks & Spencer Group PLC","514.75 13:12","3.25 (0.63%)","920,128"],["MNDI.L","Mondi PLC","1,463.00 13:14","7.00 (0.48%)","383,546"],["MRW.L","Morrison (Wm) Supermarkets PLC","155.20 13:14",""],["NG.L","National Grid PLC","926.40 13:14","1.10 (0.12%)","1,659,592"],["NXT.L","Next PLC","7,765.00 13:11","95.00 (1.21%)","114,062"],["OML.L","Old Mutual PLC","198.50 13:14","0.40 (0.20%)","2,040,849"],["PRU.L","Prudential PLC","1,499.50 13:15","14.00 (0.93%)","580,870"],["PSON.L","Pearson PLC","794.00 13:09","5.00 (0.63%)","1,177,953"],["RB.L","Reckitt Benckiser Group PLC","6,293.00 13:14","34.00 (0.54%)","281,172"],["RBS.L","Royal Bank of Scotland Group PLC","313.40 13:14","2.40 (0.77%)","2,100,058"],["RDSA.L","Royal Dutch Shell PLC","1,636.00 13:14","18.00 (1.11%)","2,467,461"],["RDSB.L","Royal Dutch Shell PLC","1,652.00 13:15","14.50 (0.89%)","1,457,434"],["REL.L","Reed Elsevier PLC","1,170.00 13:14","0.00 (0.00%)","908,802"],["RIO.L","Rio Tinto PLC","2,235.00 13:15","21.00 (0.95%)","2,190,722"],["RMG.L","Royal Mail PLC","453.50 13:14","1.20 (0.26%)","995,316"],["RR.L","Rolls-Royce Group PLC","546.63 13:14","8.38 (1.51%)","2,792,915"],["RRS.L","Randgold Resources Ltd","3,929.00 13:14","0.00 (0.00%)","135,524"],["RSA.L","RSA Insurance Group PLC","437.10 13:14","0.10 (0.02%)","395,477"],["SAB.L","SABMiller PLC","4,011.00 13:15","1.00 (0.02%)","892,451"],["SBRY.L","Sainsbury (J) PLC","255.80 13:14","7.40 (2.98%)","2,395,670"],["SDR.L","Schroders PLC","2,930.00 13:09","12.00 (0.41%)","44,674"],["SGE.L","Sage Group (The) PLC","545.50 13:13","0.50 (0.09%)","539,717"],["SHP.L","Shire PLC","4,685.00 13:14","22.00 (0.47%)","221,318"],["SKY.L","SKY","1,095.00 13:12","4.00 (0.37%)","925,016"],["SL.L","Standard Life PLC","399.90 13:14","3.20 (0.79%)","861,636"],["SMIN.L","Smiths Group PLC","992.50 13:14","27.50 (2.70%)","640,309"],["SN.L","Smith & Nephew PLC","1,110.00 13:14","9.00 (0.82%)","480,018"],["SPD.L","Sports Direct International PLC","694.50 13:11","1.50 (0.22%)","157,981"],["SSE.L","SSE PLC","1,463.00 13:13","2.00 (0.14%)","562,454"],["STAN.L","Standard Chartered PLC","583.00 13:14","0.60 (0.10%)","2,018,697"],["STJ.L","St James's Place PLC","964.00 13:14","11.00 (1.13%)","418,480"],["SVT.L","Severn Trent PLC","2,199.00 13:12","1.00 (0.05%)","95,342"],["TPK.L","Travis Perkins PLC","1,945.00 13:13","4.00 (0.21%)","92,916"],["TSCO.L","Tesco PLC","171.54 13:14","2.54 (1.50%)","9,831,136"],["TUI.L","TUI AG","1,115.00 13:10","5.00 (0.45%)","458,970"],["TW.L","Taylor Wimpey PLC","183.90 13:15","1.10 (0.59%)","3,180,729"],["ULVR.L","Unilever PLC","2,791.00 13:14","29.00 (1.03%)","824,827"],["UU.L","United Utilities Group PLC","959.00 13:10","2.50 (0.26%)","436,911"],["VOD.L","Vodafone Group PLC","224.25 13:15","1.30 (0.58%)","17,572,036"],["WOS.L","Wolseley PLC","3,657.00 13:14","4.00 (0.11%)","179,536"],["WPP.L","WPP PLC","1,502.00 13:15","12.00 (0.79%)","857,887"],["WTB.L","Whitbread PLC","4,484.00 13:16","60.00 (1.32%)","141,036"]];var cs=[["Apple Inc","AAPL",11.007,174.94,.15,"(0.09%)"],["Microsoft Corp","MSFT",9.61,316.98,-.03,"(-0.01%)"],["Amazon.com Inc","AMZN",5.401,129.31,.19,"(0.14%)"],["NVIDIA Corp","NVDA",4.101,415.74,-.36,"(-0.09%)"],["Meta Platforms Inc","META",3.729,299.42,.34,"(0.11%)"],["Tesla Inc","TSLA",3.285,244.13,-.75,"(-0.31%)"],["Alphabet Inc","GOOGL",3.133,130.49,.24,"(0.18%)"],["Alphabet Inc","GOOG",3.085,131.49,.24,"(0.18%)"],["Broadcom Inc","AVGO",2.896,833.04,3.96,"(0.48%)"],["Costco Wholesale Corp","COST",2.137,557.85,-.74,"(-0.13%)"],["PepsiCo Inc","PEP",2.096,174.84,-.43,"(-0.25%)"],["Adobe Inc","ADBE",2.033,511.42,-1.48,"(-0.29%)"],["Cisco Systems Inc","CSCO",1.887,53.68,.11,"(0.20%)"],["Comcast Corp","CMCSA",1.633,45.3,-.01,"(-0.01%)"],["Netflix Inc","NFLX",1.478,379.89,.08,"(0.02%)"],["T-Mobile US Inc","TMUS",1.43,140.18,.83,"(0.60%)"],["Advanced Micro Devices Inc","AMD",1.348,96.09,-.11,"(-0.12%)"],["Texas Instruments Inc","TXN",1.264,161,.69,"(0.43%)"],["Intel Corp","INTC",1.26,34.19,.01,"(0.01%)"],["Amgen Inc","AMGN",1.251,271.18,3.48,"(1.30%)"],["Intuit Inc","INTU",1.226,509,.43,"(0.08%)"],["Honeywell International Inc","HON",1.103,188.67,-1.12,"(-0.59%)"],["QUALCOMM Inc","QCOM",1.046,107.53,-.16,"(-0.14%)"],["Applied Materials Inc","AMAT",.982,136.32,.15,"(0.11%)"],["Booking Holdings Inc","BKNG",.941,3,19.2,-43.3,"(-1.42%)"],["Starbucks Corp","SBUX",.926,93.8,.12,"(0.12%)"],["Intuitive Surgical Inc","ISRG",.867,288.5,.3,"(0.10%)"],["Automatic Data Processing Inc","ADP",.854,239.45,.1,"(0.04%)"],["Mondelez International Inc","MDLZ",.835,71.25,.82,"(1.16%)"],["Gilead Sciences Inc","GILD",.814,75.47,.46,"(0.61%)"],["Vertex Pharmaceuticals Inc","VRTX",.794,353.67,4.14,"(1.18%)"],["Regeneron Pharmaceuticals Inc","REGN",.763,828.09,3.25,"(0.39%)"],["Analog Devices Inc","ADI",.752,176.82,1.34,"(0.76%)"],["Lam Research Corp","LRCX",.702,620,.89,"(0.14%)"],["Micron Technology Inc","MU",.646,68.9,.02,"(0.03%)"],["Palo Alto Networks Inc","PANW",.604,228.7,.19,"(0.08%)"],["Synopsys Inc","SNPS",.587,447.12,.27,"(0.06%)"],["Charter Communications Inc","CHTR",.581,441.88,-3.33,"(-0.75%)"],["MercadoLibre Inc","MELI",.562,1,275.5,-1.47,"(-0.11%)"],["PayPal Holdings Inc","PYPL",.559,57.9,.02,"(0.03%)"],["CSX Corp","CSX",.54,31.23,.03,"(0.09%)"],["Cadence Design Systems Inc","CDNS",.539,230.83,.17,"(0.07%)"],["KLA Corp","KLAC",.53,456.11,4.29,"(0.95%)"],["PDD Holdings Inc ADR","PDD",.521,95.93,-.01,"(-0.01%)"],["Marriott International Inc/MD","MAR",.505,193.9,-.46,"(-0.23%)"],["Monster Beverage Corp","MNST",.498,54.48,-.04,"(-0.08%)"],["Airbnb Inc","ABNB",.491,132.09,-.11,"(-0.08%)"],["O'Reilly Automotive Inc","ORLY",.485,936.67,.65,"(0.07%)"],["Cintas Corp","CTAS",.446,505.27,.52,"(0.10%)"],["ASML Holding NV","ASML",.438,585,-2.1,"(-0.36%)"],["NXP Semiconductors NV","NXPI",.434,196.76,-.04,"(-0.02%)"],["Workday Inc","WDAY",.414,235.55,4.73,"(2.05%)"],["Lululemon Athletica Inc","LULU",.405,386.36,-1.69,"(-0.44%)"],["Keurig Dr Pepper Inc,KDP",.404,33.25,.13,"(0.39%)"],["Fortinet Inc","FTNT",.401,58.29,.05,"(0.09%)"],["Marvell Technology Inc","MRVL",.388,52.38,.08,"(0.14%)"],["PACCAR Inc","PCAR",.38,84.97,.04,"(0.04%)"],["Old Dominion Freight Line Inc","ODFL",.38,401.01,.35,"(0.09%)"],["Autodesk Inc","ADSK",.379,204.07,.03,"(0.01%)"],["Kraft Heinz Co/The","KHC",.368,34.27,.11,"(0.31%)"],["Microchip Technology Inc","MCHP",.36,77,-.08,"(-0.10%)"],["Copart Inc","CPRT",.358,43.26,.1,"(0.22%)"],["American Electric Power Co Inc","AEP",.357,79.23,.06,"(0.08%)"],["Paychex Inc","PAYX",.355,113.01,.06,"(0.06%)"],["Exelon Corp","EXC",.35,40.28,.07,"(0.16%)"],["ON Semiconductor Corp","ON",.341,93.87,.06,"(0.06%)"],["AstraZeneca PLC ADR","AZN",.339,67.35,-.49,"(-0.72%)"],["Seagen Inc","SGEN",.336,212.18,-1.52,"(-0.71%)"],["Ross Stores Inc","ROST",.335,111.71,.05,"(0.04%)"],["Moderna Inc","MRNA",.331,100.32,.33,"(0.33%)"],["Biogen Inc","BIIB",.326,257.93,.25,"(0.10%)"],["Crowdstrike Holdings Inc","CRWD",.319,162.85,.28,"(0.17%)"],["IDEXX Laboratories Inc","IDXX",.316,439.41,3.72,"(0.85%)"],["Baker Hughes Co","BKR",.307,35.44,.04,"(0.10%)"],["Constellation Energy Corp","CEG",.307,110.41,.05,"(0.04%)"],["Cognizant Technology Solutions Corp","CTSH",.303,70.19,.58,"(0.83%)"],["Verisk Analytics Inc","VRSK",.303,242.05,.1,"(0.04%)"],["Dexcom Inc","DXCM",.3,88.3,.8,"(0.92%)"],["Trade Desk Inc/The","TTD",.293,76.38,.03,"(0.03%)"],["Xcel Energy Inc","XEL",.284,59.76,.03,"(0.04%)"],["Electronic Arts Inc","EA",.279,118.38,-.63,"(-0.53%)"],["CoStar Group Inc","CSGP",.277,78.18,.12,"(0.15%)"],["GLOBALFOUNDRIES Inc","GFS",.273,57.21,.38,"(0.67%)"],["Fastenal Co","FAST",.268,54.32,.11,"(0.20%)"],["Atlassian Corp","TEAM",.253,196.01,.55,"(0.28%)"],["GE HealthCare Technologies Inc","GEHC",.252,63.78,-.56,"(-0.86%)"],["Warner Bros Discovery Inc","WBD",.244,11.09,-.02,"(-0.14%)"],["Diamondback Energy Inc","FANG",.235,150.7,.13,"(0.09%)"],["Datadog Inc","DDOG",.23,88.81,.05,"(0.06%)"],["ANSYS Inc","ANSS",.227,300.6,-2.31,"(-0.76%)"],["eBay Inc","EBAY",.203,43.22,.09,"(0.20%)"],["Dollar Tree Inc","DLTR",.201,104.77,.27,"(0.25%)"],["Align Technology Inc","ALGN",.2,297.25,-1.31,"(-0.44%)"],["Zscaler Inc","ZS",.188,151.8,.09,"(0.06%)"],["Illumina Inc","ILMN",.183,132.31,-.13,"(-0.10%)"],["Walgreens Boots Alliance Inc","WBA",.161,21.18,.06,"(0.28%)"],["Zoom Video Communications Inc","ZM",.151,68.57,-.29,"(-0.41%)"],["Enphase Energy Inc","ENPH",.148,120.41,.49,"(0.41%)"],["Sirius XM Holdings Inc","SIRI",.137,4.05,.02,"(0.50%)"],["JD.com Inc ADR","JD",.117,30.43,.02,"(0.05%)"],["Lucid Group Inc","LCID",.102,5.14,.03,"(0.49%)"]];var ps=[["Apple Inc","AAPL",6.992488,171.9,1.47,"(0.86%)"],["Microsoft Corp","MSFT",6.487978,314.55,1.76,"(0.56%)"],["Amazon.com Inc","AMZN",3.193379,126.25,.27,"(0.22%)"],["Nvidia Corp","NVDA",2.928461,433.11,8.43,"(1.99%)"],["Alphabet Inc Cl A","GOOGL",2.162218,132.93,2.39,"(1.83%)"],["Tesla Inc","TSLA",1.854311,246.56,6.06,"(2.52%)"],["Alphabet Inc Cl C","GOOG",1.85251,133.81,2.35,"(1.78%)"],["Meta Platforms Inc Class A","META",1.847731,305.93,8.19,"(2.75%)"],["Berkshire Hathaway Inc Cl B","BRK.B",1.82184,358.67,.89,"(0.25%)"],["Exxon Mobil Corp","XOM",1.343563,118.97,-1.23,"(-1.03%)"],["Unitedhealth Group Inc","UNH",1.302884,510.04,6.31,"(1.25%)"],["Eli Lilly & Co","LLY",1.224046,546.65,-3.11,"(-0.57%)"],["Jpmorgan Chase & Co","JPM",1.182918,148.23,2.45,"(1.68%)"],["Johnson & Johnson W/d","JNJ",1.056344,156.83,-.28,"(-0.18%)"],["Visa Inc Class a Shares","V",1.029636,231.97,2.47,"(1.08%)"],["Procter & Gamble Co","PG",.969793,145.75,-1.59,"(-1.08%)"],["Broadcom Inc","AVGO",.941177,835.33,18.52,"(2.27%)"],["Mastercard Inc A","MA",.918779,400.65,5.17,"(1.31%)"],["Chevron Corp","CVX",.847353,170.55,-.49,"(-0.28%)"],["Home Depot Inc","HD",.847289,304.35,2.53,"(0.84%)"],["Abbvie Inc","BBV",.754672,152.14,-.99,"(-0.65%)"],["Merck & Co. Inc.","MRK",.736434,104.2,.26,"(0.25%)"],["Costco Wholesale Corp","COST",.697258,569.05,5.52,"(0.98%)"],["Pepsico Inc","PEP",.651768,168.92,-.65,"(-0.38%)"],["Walmart Inc","WMT",.644449,161.87,.15,"(0.09%)"],["Adobe Inc","ADBE",.639652,507.17,4.57,"(0.91%)"],["Coca Cola Co","KO",.60801,55.82,-.13,"(-0.23%)"],["Cisco Systems Inc","CSCO",.605326,53.97,.77,"(1.44%)"],["Accenture Plc Cl A","ACN",.55372,298.5,-15.9,"(-5.05%)"],["Salesforce Inc","CRM",.551342,204.46,1.73,"(0.85%)"],["Thermo Fisher Scientific Inc","TMO",.536951,503.47,5.18,"(1.04%)"],["Mcdonald S Corp","MCD",.536457,265.83,2.19,"(0.83%)"],["Bank of America Corp","BAC",.526405,27.51,.24,"(0.86%)"],["Comcast Corp Class A","CMCSA",.512537,45.17,.57,"(1.27%)"],["Linde Plc","LIN",.506835,375.48,3.47,"(0.93%)"],["Pfizer Inc","PFE",.506043,32.09,-.02,"(-0.05%)"],["Netflix Inc","NFLX",.467192,377.77,.18,"(0.05%)"],["Abbott Laboratories","ABT",.462893,97.52,1.99,"(2.08%)"],["Oracle Corp","ORCL",.459877,106.29,1.67,"(1.60%)"]];var hs=[["CKH HOLDINGS","00001.HK",41.9,1.15,"+2.822%","5.15M","215.13M",4.38,.31,"6.98%","160.48B"],["CLP HOLDINGS","00002.HK",57.95,-.1,"-0.172%","3.32M","193.19M",156.62,1.39,"5.35%","146.41B"],["HK & CHINA GAS","00003.HK",5.46,.13,"+2.439%","16.16M","88.00M",19.43,1.66,"6.41%","101.88B"],["HSBC HOLDINGS,00005.HK",61.7,1.1,"+1.815%","22.19M","1.37B",10.54,.86,"4.05%",1,"227.60B"],["POWER ASSETS","00006.HK",37.9,-.25,"-0.655%","4.23M","160.75M",14.3,.93,"7.44%","80.77B"],["HANG SENG BANK","00011.HK",97.45,2.95,"+3.122%","2.54M","247.44M",19.69,1.01,"4.21%","186.31B"],["HENDERSON LAND","00012.HK",20.65,.85,"+4.293%","5.07M","103.70M",10.81,.31,"8.72%","99.97B"],["SHK PPT","00016.HK",83.8,3.25,"+4.035%","8.25M","685.41M",10.16,.4,"5.91%","242.83B"],["NEW WORLD DEV","00017.HK",15.24,.8,"+5.540%","12.95M","196.19M",30.48,.18,"13.52%","38.35B"],["GALAXY ENT","00027.HK",47.15,1.9,"+4.199%","11.97M","560.21M","No Profit",3.22,"0.00%","206.21B"],["MTR CORPORATION","00066.HK",31,.8,"+2.649%","4.68M","144.86M",19.5,1.07,"4.23%","192.64B"],["HANG LUNG PPT","00101.HK",10.72,.56,"+5.512%","7.68M","81.99M",12.61,.36,"7.28%","48.23B"],["GEELY AUTO","00175.HK",9.24,.17,"+1.874%","18.77M","173.30M",16.06,1.15,"2.27%","92.99B"],["ALI HEALTH","00241.HK",4.88,.47,"+10.658%","53.62M","257.82M",108.09,3.81,"0.00%","66.04B"],["CITIC","00267.HK",7.2,.2,"+2.857%","11.54M","82.96M",2.78,.28,"9.04%","209.45B"],["WH GROUP","00288.HK",4.11,.08,"+1.985%","18.94M","77.65M",4.93,.7,"7.30%","52.73B"],["CHINA RES BEER","00291.HK",42.95,1.2,"+2.874%","4.83M","207.98M",28.41,4.57,"1.41%","139.34B"],["OOIL","00316.HK",104.5,-.4,"-0.381%","296.54K","30.98M",.89,.66,"78.90%","69.01B"],["TINGYI","00322.HK",10.94,.18,"+1.673%","2.91M","31.81M",20.75,4.09,"9.39%","61.64B"],["SINOPEC CORP","00386.HK",4.28,-.01,"-0.233%","92.43M","396.61M",6.94,.58,"9.36%","105.92B"],["HKEX","00388.HK",292.6,9,"+3.173%","4.61M","1.34B",36.76,7.46,"2.44%","370.97B"],["TECHTRONIC IND","00669.HK",76,1.35,"+1.808%","5.47M","414.78M",16.54,3.43,"2.43%","139.45B"],["CHINA OVERSEAS","00688.HK",16.24,.52,"+3.308%","13.15M","212.60M",6.76,.44,"4.93%","177.74B"],["TENCENT","00700.HK",306.2,8.8,"+2.959%","11.25M","3.43B",13.74,3.6,"0.78%",2,"926.16B"],["CHINA UNICOM","00762.HK",5.68,-.05,"-0.873%","9.23M","52.77M",9.16,.45,"5.44%","173.80B"],["LINK REIT","00823.HK",38.4,1.45,"+3.924%","12.04M","460.96M",5.42,.52,"7.03%","98.38B"],["CHINA RES POWER","00836.HK",14.94,.32,"+2.189%","9.91M","147.81M",10.23,.87,"3.92%","71.87B"],["PETROCHINA","00857.HK",5.9,0,"0.000%","64.23M","380.44M",6.38,.7,"8.08%","124.48B"],["XINYI GLASS","00868.HK",10.14,.17,"+1.705%","3.75M","38.02M",8.01,1.3,"6.11%","42.22B"],["ZHONGSHENG HLDG","00881.HK",22.05,1.45,"+7.039%","6.76M","147.71M",7.08,1.07,"4.94%","52.72B"],["CNOOC","00883.HK",13.78,-.02,"-0.145%","26.37M","365.08M",4.03,.97,"19.09%","655.47B"],["CCB","00939.HK",4.42,.06,"+1.376%","233.61M","1.03B",3.06,.35,"9.93%",1,"062.64B"],["CHINA MOBILE","00941.HK",65.7,.25,"+0.382%","7.82M","516.10M",9.91,.96,"6.71%",1,"404.46B"],["LONGFOR GROUP","00960.HK",14.08,.9,"+6.829%","10.88M","150.68M",3.06,.55,"9.05%","92.81B"],["XINYI SOLAR","00968.HK",5.86,.28,"+5.018%","15.99M","92.88M",13.64,1.75,"3.41%","52.17B"],["SMIC","00981.HK",20.05,.25,"+1.263%","13.10M","264.32M",11.17,1.06,"0.00%","159.31B"],["LENOVO GROUP","00992.HK",8.07,.25,"+3.197%","33.60M","270.50M",7.61,2.23,"4.71%","97.87B"],["CKI HOLDINGS","01038.HK",37.05,-.2,"-0.537%","1.44M","53.73M",12.03,.78,"6.83%","93.35B"],["HENGAN INT'L","01044.HK",24.95,.2,"+0.808%","2.62M","64.97M",13.35,1.32,"6.33%","28.99B"],["CHINA SHENHUA","01088.HK",25.4,.35,"+1.397%","7.98M","203.11M",6.14,1.13,"11.33%","85.79B"],["CSPC PHARMA","01093.HK",5.74,.05,"+0.879%","29.29M","167.41M",9.96,2.01,"3.66%","68.32B"],["SINOPHARM","01099.HK",22.7,.2,"+0.889%","2.07M","46.80M",7.37,.92,"4.08%","30.46B"],["CHINA RES LAND","01109.HK",31.2,1,"+3.311%","9.88M","305.88M",7.02,.81,"5.07%","222.49B"],["CK ASSET","01113.HK",41.25,1.25,"+3.125%","8.57M","352.44M",6.9,.39,"5.53%","146.47B"],["SINO BIOPHARM","01177.HK",2.83,.02,"+0.712%","26.30M","74.09M",18.37,1.59,"4.24%","53.21B"],["CHINA RES MIXC","01209.HK",31.6,1.6,"+5.333%","3.07M","96.42M",28.97,4.48,"2.87%","72.13B"],["BYD COMPANY","01211.HK",242,7,"+2.979%","3.90M","938.50M",37.57,5.63,"0.53%","265.72B"],["AIA","01299.HK",63.85,.95,"+1.510%","38.75M","2.48B",408.88,2.53,"2.41%","735.40B"],["CHINAHONGQIAO","01378.HK",7.67,.28,"+3.789%","13.05M","99.58M",7.27,.76,"6.65%","72.68B"],["ICBC","01398.HK",3.77,.07,"+1.892%","233.48M","881.67M",3.45,.36,"9.08%","327.21B"],["XIAOMI-W","01810.HK",12.34,.62,"+5.290%","78.53M","960.98M",109.39,1.9,"0.00%","308.83B"],["BUD APAC","01876.HK",15.46,.16,"+1.046%","16.17M","250.45M",28.65,2.44,"1.91%","204.74B"],["SANDS CHINA LTD","01928.HK",24,.95,"+4.121%","19.98M","475.93M","No Profit","N/A","0.00%","194.24B"],["CHOW TAI FOOK","01929.HK",11.8,.28,"+2.431%","4.88M","57.68M",21.93,3.64,"10.34%","118.00B"],["WHARF REIC","01997.HK",30.25,1.4,"+4.853%","4.23M","127.31M","No Profit",.48,"4.33%","91.85B"],["ANTA SPORTS","02020.HK",88.15,4.4,"+5.254%","4.82M","422.51M",27.71,6.16,"1.52%","249.70B"],["WUXI BIO","02269.HK",45.65,1.55,"+3.515%","17.91M","811.49M",38.18,4.88,"0.00%","194.01B"],["SHENZHOU INTL","02313.HK",75,4.6,"+6.534%","5.52M","410.68M",21.87,3.25,"2.55%","112.74B"],["PING AN","02318.HK",44.85,.85,"+1.932%","23.05M","1.03B",8.28,.85,"6.09%","334.02B"],["MENGNIU DAIRY","02319.HK",26.25,1.5,"+6.061%","8.58M","223.15M",17.34,2.3,"1.73%","103.42B"],["LI NING","02331.HK",32.95,1.5,"+4.769%","22.54M","738.37M",18.8,3.16,"1.58%","86.86B"],["SUNNY OPTICAL","02382.HK",54.7,1.05,"+1.957%","5.62M","308.60M",22.01,2.44,"0.91%","60.00B"],["BOC HONG KONG","02388.HK",21.45,.3,"+1.418%","6.53M","140.32M",8.38,.75,"6.33%","226.79B"],["CHINA LIFE","02628.HK",12.2,.24,"+2.007%","13.53M","165.07M",9.49,.7,"4.53%","90.78B"],["ENN ENERGY","02688.HK",65,1.15,"+1.801%","3.06M","198.69M",11.08,1.67,"4.48%","73.53B"],["ZIJIN MINING","02899.HK",11.98,.16,"+1.354%","16.20M","194.50M",13.97,3.14,"1.88%","68.73B"],["MEITUAN-W","03690.HK",114.6,3.8,"+3.430%","19.17M","2.19B","No Profit",4.89,"0.00%","715.43B"],["HANSOH PHARMA","03692.HK",10.66,.16,"+1.524%","17.56M","187.72M",21.48,2.47,"0.94%","63.25B"],["CM BANK","03968.HK",32.7,.1,"+0.307%","11.13M","363.99M",5.51,.86,"6.00%","150.12B"],["BANK OF CHINA","03988.HK",2.74,.05,"+1.859%","275.47M","754.54M",3.33,.33,"9.55%","229.13B"],["CG SERVICES","06098.HK",8.08,.25,"+3.193%","16.08M","128.87M",12.42,.65,"5.20%","27.01B"],["JD HEALTH","06618.HK",40.6,2.95,"+7.835%","7.75M","312.36M",299.91,2.56,"0.00%","129.12B"],["HAIER SMARTHOME","06690.HK",24.65,1.15,"+4.894%","7.24M","178.37M",13.83,2.21,"2.59%","70.46B"],["HAIDILAO","06862.HK",21,.6,"+2.941%","6.86M","143.79M",74.46,13.94,"0.55%","117.05B"],["JD-SW","09618.HK",115.1,4,"+3.600%","7.43M","852.28M",30.73,1.5,"6.38%","360.24B"],["NONGFU SPRING","09633.HK",45,1.5,"+3.448%","3.69M","165.62M",52.49,18.63,"1.71%","226.56B"],["BIDU-SW","09888.HK",133.4,4.6,"+3.571%","5.82M","772.73M",47.3,1.5,"0.00%","377.37B"],["TRIP.COM-S","09961.HK",279.2,7,"+2.572%","1.25M","349.59M",114.05,1.4,"0.00%","176.65B"],["BABA-SW","09988.HK",85.6,2.6,"+3.133%","34.61M","2.96B",21.65,1.62,"0.00%",1,"837.13B"],["NTES-S","09999.HK",159.5,8.3,"+5.489%","5.02M","797.10M",22.7,4.63,"1.36%","546.99B"]];var Tt=[];for(let n of ls){let[e,t,r,s,i]=n,o=".FTSE100",a="BUY",u=1;Tt.push([o,s,t,r,e,`${e}-${o}`,a,i,u])}for(let n of hs){let[e,t,r,s,,i]=n,o=".HSI",a="BUY",u=1;Tt.push([o,s,e,r,t,`${t}-${o}`,a,i,u])}for(let n of cs){let[e,t,r,s,i]=n,o=".NASDAQ100",a="BUY",u=1e3;Tt.push([o,i,e,s,t,`${t}-${o}`,a,u,r])}for(let n of ps){let[e,t,r,,s]=n,i=".SP500",o="BUY",a=1e3,u=0;Tt.push([i,s,e,u,t,`${t}-${i}`,o,a,r])}var at=Tt;var{bid:Go,bidSize:Wo,ask:Ho,askSize:$o,last:Ko}=J(k.prices),zo=new ot({bid:Go,bidSize:Wo,ask:Ho,askSize:$o,last:Ko}),ds=[];for(let[,,,n,e]of at){let t=parseFloat(String(n));if(!isNaN(t)){let[r,s]=as(5,Kt),i=T(1e3,3e3),o=T(1e3,3e3),a=t+T(0,1)/10,u=t+T(0,1)/10,c=t+T(0,1)/10,p="C",h="close";ds.push([s,i,r,o,a,u,c,p,e,h])}}var qo=new F(k.prices,ds,J(k.prices),zo),fs=qo;var xe=n=>Object.values(ee[n].columns).reduce((e,t,r)=>(e[t.name]=r,e),{}),Me={algoType:xe("algoType"),basket:xe("basket"),basketTrading:xe("basketTrading"),basketTradingConstituent:xe("basketTradingConstituent"),basketConstituent:xe("basketConstituent"),basketTradingConstituentJoin:xe("basketTradingConstituentJoin"),priceStrategyType:xe("priceStrategyType")},ms=new F(ee.basketConstituent,at,Me.basketConstituent),gs=new F(ee.basketTrading,[],Me.basketTrading),jo=1,Fr=new F(ee.basketTradingConstituent,[],Me.basketTradingConstituent),bs=(n,e,t="BUY",r="OFF MARKET")=>[n,e,0,1.25,`steve-${jo++}`,t,r,1e6,125e4,100];function Qo(n,e){let t=bs(n,e);gs.insert(t);let{basketId:r}=xe("basketConstituent");ms.data.filter(i=>i[r]===n).forEach(([,,i,,o,,,a,u])=>{let c="",p="",U="",V="BUY",I="venue",{instanceId:R}=Me.basketTrading,v=t[R],L=[c,p,n,i,v,`${v}-${o}`,95,0,0,0,0,U,a,o,V,I,u];Fr.insert(L)})}async function Jo(n){console.log(`RPC call erceived ${n.rpcName}`)}async function Xo(n){let[e]=n.params;console.log(`RPC call erceived ${n.rpcName} ${e}`)}async function Yo(n){console.log(`RPC call erceived ${n.rpcName}`)}async function Zo(n){let{params:[e,t]}=n;Qo(e,t)}var ea={algoType:new F(ee.algoType,[["Sniper",0],["Dark Liquidity",1],["VWAP",2],["POV",3],["Dynamic Close",4]],Me.algoType),basket:new F(ee.basket,[[".NASDAQ100",".NASDAQ100",0,0],[".HSI",".HSI",0,0],[".FTSE100",".FTSE100",0,0],[".SP500",".SP500",0,0]],Me.basket),basketConstituent:ms,basketTrading:gs,basketTradingConstituent:Fr,basketTradingConstituentJoin:$t({module:"BASKET",table:"basketTradingConstituentJoin"},Fr,fs,"ric"),priceStrategyType:new F(ee.priceStrategyType,[["Peg to Near Touch",0],["Far Touch",1],["Limit",2],["Algo",3]],Me.priceStrategyType)},ta={algoType:void 0,basket:{name:"ROOT",menus:[{context:"selected-rows",filter:"",name:"Add Basket",rpcName:"CREATE_NEW_BASKET"}]},basketConstituent:void 0,basketTrading:void 0,basketTradingConstituent:void 0,basketTradingConstituentJoin:void 0,priceStrategyType:void 0},ra={algoType:void 0,basket:[{rpcName:"createBasket",service:Zo}],basketConstituent:void 0,basketTrading:[{rpcName:"sendToMarket",service:Xo},{rpcName:"takeOffMarket",service:Yo}],basketTradingConstituent:void 0,basketTradingConstituentJoin:[{rpcName:"addConstituent",service:Jo}],priceStrategyType:void 0},na=n=>ee[n].columns,sa=n=>{let e=na(n),{key:t}=ee[n];return new nt({columnDescriptors:e,dataMap:Me[n],keyColumn:t,menu:ta[n],rpcServices:ra[n],table:ea[n]})},ia=async()=>[],oa={createDataSource:sa,typeaheadHook:()=>ia},ys=oa;var Gs=Zs(Bs());var Fs=["CAD","GBX","USD","EUR","GBP"];var Us={L:["London PLC","XLON/LSE-SETS"],N:["Corporation","XNGS/NAS-GSM"],AS:["B.V.","XAMS/ENA-MAIN"],OQ:["Co.","XNYS/NYS-MAIN"],PA:["Paris","PAR/EUR_FR"],MI:["Milan","MIL/EUR_IT"],FR:["Frankfurt","FR/EUR_DE"],AT:["Athens","AT/EUR_GR"]},Ur=["L","N","OQ","AS","PA","MI","FR","AT"];var Gr=[1,2,5,10,50,50,70,100,100,100,120,150,150,200,500,700,1e3,2e3,2500,5e3,1e4];var Ws={bbg:0,currency:1,description:2,exchange:3,string:4,number:5,ric:6,price:7},ut=[],Ne=Array.from("ABCEFGHKMNOPQRTUVWYZ"),ka=()=>{let n=T(0,1e4),e=T(1,10);return n/e},Va=performance.now();for(let n of Ne)for(let e=0;e<1e4;e++){let t=Ne[T(0,Ne.length-1)],r=Ne[T(0,Ne.length-1)],s=Ne[T(0,Ne.length-1)],i=Ur[T(0,Ur.length-1)],o=n+t+r+s+"."+i,a=n+t+r+s+" "+i,u=`${o} description`,c=Fs[T(0,4)],p=(0,Gs.isinGenerator)(),h=Gr[T(0,Gr.length-1)],f=Us[i][1],m=ka();ut.push([a,c,u,f,String(p),h,o,m])}var La=performance.now();console.log(`generating 10,000 instruments took ${La-Va} ms`);var Aa=new F(k.instruments,ut,J(k.instruments));var Wr=Aa;var Oa=ut.map(n=>n.slice(0,-1).concat([T(0,1)===1,T(0,1)===1])),_a=new F(k.instrumentsExtended,Oa,J(k.instrumentsExtended)),Hs=_a;var{bid:Na,bidSize:Ba,ask:Fa,askSize:Ua}=J(k.prices),Ga=new ot({bid:Na,bidSize:Ba,ask:Fa,askSize:Ua}),Wa=["ric","price"],$s=ut.map(n=>{let{ric:e,price:t}=Wa.reduce((m,g)=>({...m,[g]:n[Ws[g]]}),{}),r=T(0,10),s=t+r/2,i=T(1e3,3e3),o=t-r/2,a=T(1e3,3e3),u=t+T(0,1)/10,c=t+T(0,1)/10,p=t+T(0,1)/10;return[s,i,o,a,u,c,p,"C",e,"close"]});for(let[,,,n,e]of at){let t=parseFloat(String(n));if(!isNaN(t)){let r=T(0,10),s=t+r/2,i=T(1e3,3e3),o=t-r/2,a=T(1e3,3e3),u=t+T(0,1)/10,c=t+T(0,1)/10,p=t+T(0,1)/10,h="C",f="close";$s.push([s,i,o,a,u,c,p,h,e,f])}}var Ha=new F(k.prices,$s,J(k.prices),Ga);var Hr=Ha;var Ks={childOrders:new F(k.childOrders,[],J(k.childOrders)),instruments:Wr,instrumentsExtended:Hs,instrumentPrices:$t({module:"SIMUL",table:"instrumentPrices"},Wr,Hr,"ric"),orders:new F(k.orders,[],J(k.orders)),parentOrders:new F(k.parentOrders,[],J(k.parentOrders)),prices:Hr},$a=n=>{let e=k[n];if(e)return e.columns;throw Error(`simul-module no schema found for table SIMUL ${n}`)},Ka=n=>{let e=$a(n);return new nt({columnDescriptors:e,keyColumn:k[n].key,table:Ks[n]})},za=([n,e,t])=>{let r=Ks[n.table];if(r)return Wt(r,e,t);throw Error(`SIMUL suggestionFetcher, unknown table ${n.module} ${n.table}`)},qa={createDataSource:Ka,typeaheadHook:()=>za},zs=qa;var ja={BASKET:ys,SIMUL:zs},Of=n=>ja[n];export{Ao as DefaultColumnGenerator,Lo as DefaultRowGenerator,nt as TickingArrayDataSource,ad as VuuColumnGenerator,bs as createBasketTradingRow,eu as getAllSchemas,ud as getColumnAndRowGenerator,tu as getSchema,ld as populateArray,ei as schemas,Of as vuuModule};
4
+ `),Error(`KeySet, no key found for rowIndex ${e}`);return t}toDebugString(){return Array.from(this.keys.entries()).map((e,t)=>`${e}=>${t}`).join(",")}};var ue=(s=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(s));for(;s--;){let r=t[s]&63;r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r<63?e+="_":e+="-"}return e};function lr(s,e){let t;return(...r)=>{clearTimeout(t),t=window.setTimeout(()=>s(...r),e)}}function ls(s,e){let t=!1,r;function n(){r==null?t=!1:(s(...r),r=void 0,setTimeout(n,e))}return(...i)=>{t?r=i:(s(...i),t=!0,setTimeout(n,e))}}var{IDX:wl}=L;var{SELECTED:vl}=L,he={False:0,True:1,First:2,Last:4};var cs=(s,e)=>e>=s[0]&&e<=s[1],yi=he.True+he.First+he.Last,wi=he.True+he.First,Ci=he.True+he.Last,ps=(s,e)=>{for(let t of s)if(typeof t=="number"){if(t===e)return yi}else if(cs(t,e))return e===t[0]?wi:e===t[1]?Ci:he.True;return he.False},ds=(s,e)=>{for(let t of s)if(typeof t=="number"){if(t===e)return!0;if(t>e)return!1}else{if(cs(t,e))return!0;if(t[0]>e)return!1}return!1};var Si=(()=>{let s=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(s+=1,`u${e()}${s}`)})();var lt=(s,e)=>s===e?!0:s===void 0&&e===void 0,Di=({filter:s},{filter:e})=>s===void 0&&(e==null?void 0:e.filter)===""||e===void 0&&(s==null?void 0:s.filter)==="",xi=(s,e)=>{var t,r;return Di(s,e)?!1:((t=s.filter)==null?void 0:t.filter)!==((r=e.filter)==null?void 0:r.filter)},Ei=({sort:s},{sort:e})=>s===void 0&&(e==null?void 0:e.sortDefs.length)===0||e===void 0&&(s==null?void 0:s.sortDefs.length)===0,Mi=(s,e)=>{let{sort:t}=s,{sort:r}=e;return lt(t,r)||Ei(s,e)?!1:t===void 0||r===void 0||(t==null?void 0:t.sortDefs.length)!==(r==null?void 0:r.sortDefs.length)?!0:t.sortDefs.some(({column:n,sortType:i},o)=>n!==r.sortDefs[o].column||i!==r.sortDefs[o].sortType)},ms=s=>s!==void 0&&s.groupBy!==void 0&&s.groupBy.length>0,gs=s=>(s==null?void 0:s.filter)!==void 0&&s.filter.filter.length>0,bs=s=>{var e;return(s==null?void 0:s.sort)!==void 0&&Array.isArray((e=s.sort)==null?void 0:e.sortDefs)&&s.sort.sortDefs.length>0},ki=({groupBy:s},{groupBy:e})=>s===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(s==null?void 0:s.length)===0,pr=(s,e)=>{let{groupBy:t}=s,{groupBy:r}=e;return lt(t,r)||ki(s,e)?!1:t===void 0||r===void 0||(t==null?void 0:t.length)!==(r==null?void 0:r.length)?!0:t.some((n,i)=>n!==(r==null?void 0:r[i]))},Pi=({columns:s},{columns:e})=>s===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(s==null?void 0:s.length)===0,Vi=(s,e)=>{let{columns:t}=s,{columns:r}=e;return lt(t,r)||Pi(s,e)?!1:t===void 0||r===void 0||(t==null?void 0:t.length)!==(r==null?void 0:r.length)?!0:t.some((n,i)=>n!==(r==null?void 0:r[i]))},_i=({aggregations:s},{aggregations:e})=>s===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(s==null?void 0:s.length)===0,Li=(s,e)=>{let{aggregations:t}=s,{aggregations:r}=e;return lt(t,r)||_i(s,e)?!1:t===void 0||r===void 0||t.length!==r.length?!0:t.some(({column:n,aggType:i},o)=>n!==r[o].column||i!==r[o].aggType)},Ai=()=>!1,Dt=(s,e)=>lt(s,e)?!1:s===void 0||e===void 0?!0:Vi(s,e)||xi(s,e)||Mi(s,e)||pr(s,e)||Li(s,e)||Ai(s,e),Oi=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],ys=s=>{let e=s.type;return Oi.includes(e)},ws=s=>["config","aggregate","columns","filter","groupBy","sort"].includes(s.type),Ni={filter:""},Bi={sortDefs:[]},We={aggregations:[],columns:[],filter:Ni,groupBy:[],sort:Bi},ct=s=>{if(s.aggregations&&s.columns&&s.filter&&s.groupBy&&s.sort)return s;{let{aggregations:e=[],columns:t=[],filter:r={filter:""},groupBy:n=[],sort:i={sortDefs:[]},visualLink:o}=s;return{aggregations:e,columns:t,filter:r,groupBy:n,sort:i,visualLink:o}}};var Cs="GET_TABLE_META";var dr=s=>s.type==="connection-status",Ss=s=>s.type==="connection-metrics",vs=s=>typeof s.result<"u",Rs=s=>s.type==="TABLE_META_RESP";var Ts=s=>s.type==="vuu-links";var Is=s=>s.type==="vuu-menu";var Ds=`
5
+ var __accessCheck = (obj, member, msg) => {
6
+ if (!member.has(obj))
7
+ throw TypeError("Cannot " + msg);
8
+ };
9
+ var __privateGet = (obj, member, getter) => {
10
+ __accessCheck(obj, member, "read from private field");
11
+ return getter ? getter.call(obj) : member.get(obj);
12
+ };
13
+ var __privateAdd = (obj, member, value) => {
14
+ if (member.has(obj))
15
+ throw TypeError("Cannot add the same private member more than once");
16
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
17
+ };
18
+ var __privateSet = (obj, member, value, setter) => {
19
+ __accessCheck(obj, member, "write to private field");
20
+ setter ? setter.call(obj, value) : member.set(obj, value);
21
+ return value;
22
+ };
23
+
24
+ // ../vuu-utils/src/array-utils.ts
25
+ function partition(array, test, pass = [], fail = []) {
26
+ for (let i = 0, len = array.length; i < len; i++) {
27
+ (test(array[i], i) ? pass : fail).push(array[i]);
28
+ }
29
+ return [pass, fail];
30
+ }
31
+
32
+ // ../vuu-utils/src/column-utils.ts
33
+ var metadataKeys = {
34
+ IDX: 0,
35
+ RENDER_IDX: 1,
36
+ IS_LEAF: 2,
37
+ IS_EXPANDED: 3,
38
+ DEPTH: 4,
39
+ COUNT: 5,
40
+ KEY: 6,
41
+ SELECTED: 7,
42
+ count: 8,
43
+ // TODO following only used in datamodel
44
+ PARENT_IDX: "parent_idx",
45
+ IDX_POINTER: "idx_pointer",
46
+ FILTER_COUNT: "filter_count",
47
+ NEXT_FILTER_IDX: "next_filter_idx"
48
+ };
49
+ var { DEPTH, IS_LEAF } = metadataKeys;
50
+
51
+ // ../vuu-utils/src/cookie-utils.ts
52
+ var getCookieValue = (name) => {
53
+ var _a, _b;
54
+ if (((_a = globalThis.document) == null ? void 0 : _a.cookie) !== void 0) {
55
+ return (_b = globalThis.document.cookie.split("; ").find((row) => row.startsWith(\`\${name}=\`))) == null ? void 0 : _b.split("=")[1];
56
+ }
57
+ };
58
+
59
+ // ../vuu-utils/src/range-utils.ts
60
+ function getFullRange({ from, to }, bufferSize = 0, rowCount = Number.MAX_SAFE_INTEGER) {
61
+ if (bufferSize === 0) {
62
+ if (rowCount < from) {
63
+ return { from: 0, to: 0 };
64
+ } else {
65
+ return { from, to: Math.min(to, rowCount) };
66
+ }
67
+ } else if (from === 0) {
68
+ return { from, to: Math.min(to + bufferSize, rowCount) };
69
+ } else {
70
+ const rangeSize = to - from;
71
+ const buff = Math.round(bufferSize / 2);
72
+ const shortfallBefore = from - buff < 0;
73
+ const shortFallAfter = rowCount - (to + buff) < 0;
74
+ if (shortfallBefore && shortFallAfter) {
75
+ return { from: 0, to: rowCount };
76
+ } else if (shortfallBefore) {
77
+ return { from: 0, to: rangeSize + bufferSize };
78
+ } else if (shortFallAfter) {
79
+ return {
80
+ from: Math.max(0, rowCount - (rangeSize + bufferSize)),
81
+ to: rowCount
82
+ };
83
+ } else {
84
+ return { from: from - buff, to: to + buff };
85
+ }
86
+ }
87
+ }
88
+ var withinRange = (value, { from, to }) => value >= from && value < to;
89
+ var WindowRange = class {
90
+ constructor(from, to) {
91
+ this.from = from;
92
+ this.to = to;
93
+ }
94
+ isWithin(index) {
95
+ return withinRange(index, this);
96
+ }
97
+ //find the overlap of this range and a new one
98
+ overlap(from, to) {
99
+ return from >= this.to || to < this.from ? [0, 0] : [Math.max(from, this.from), Math.min(to, this.to)];
100
+ }
101
+ copy() {
102
+ return new WindowRange(this.from, this.to);
103
+ }
104
+ };
105
+
106
+ // ../vuu-utils/src/DataWindow.ts
107
+ var { KEY } = metadataKeys;
108
+
109
+ // ../vuu-utils/src/date/formatter.ts
110
+ var baseTimeFormatOptions = {
111
+ hour: "2-digit",
112
+ minute: "2-digit",
113
+ second: "2-digit"
114
+ };
115
+ var formatConfigByTimePatterns = {
116
+ "hh:mm:ss": {
117
+ locale: "en-GB",
118
+ options: { ...baseTimeFormatOptions, hour12: false }
119
+ },
120
+ "hh:mm:ss a": {
121
+ locale: "en-GB",
122
+ options: { ...baseTimeFormatOptions, hour12: true }
123
+ }
124
+ };
125
+ var baseDateFormatOptions = {
126
+ day: "2-digit",
127
+ month: "2-digit",
128
+ year: "numeric"
129
+ };
130
+ var formatConfigByDatePatterns = {
131
+ "dd.mm.yyyy": {
132
+ locale: "en-GB",
133
+ options: { ...baseDateFormatOptions },
134
+ postProcessor: (s) => s.replaceAll("/", ".")
135
+ },
136
+ "dd/mm/yyyy": { locale: "en-GB", options: { ...baseDateFormatOptions } },
137
+ "dd MMM yyyy": {
138
+ locale: "en-GB",
139
+ options: { ...baseDateFormatOptions, month: "short" }
140
+ },
141
+ "dd MMMM yyyy": {
142
+ locale: "en-GB",
143
+ options: { ...baseDateFormatOptions, month: "long" }
144
+ },
145
+ "mm/dd/yyyy": { locale: "en-US", options: { ...baseDateFormatOptions } },
146
+ "MMM dd, yyyy": {
147
+ locale: "en-US",
148
+ options: { ...baseDateFormatOptions, month: "short" }
149
+ },
150
+ "MMMM dd, yyyy": {
151
+ locale: "en-US",
152
+ options: { ...baseDateFormatOptions, month: "long" }
153
+ }
154
+ };
155
+ var formatConfigByDateTimePatterns = { ...formatConfigByDatePatterns, ...formatConfigByTimePatterns };
156
+
157
+ // ../vuu-utils/src/logging-utils.ts
158
+ var logLevels = ["error", "warn", "info", "debug"];
159
+ var isValidLogLevel = (value) => typeof value === "string" && logLevels.includes(value);
160
+ var DEFAULT_LOG_LEVEL = "error";
161
+ var NO_OP = () => void 0;
162
+ var DEFAULT_DEBUG_LEVEL = false ? "error" : "info";
163
+ var { loggingLevel = DEFAULT_DEBUG_LEVEL } = getLoggingSettings();
164
+ var logger = (category) => {
165
+ const debugEnabled5 = loggingLevel === "debug";
166
+ const infoEnabled5 = debugEnabled5 || loggingLevel === "info";
167
+ const warnEnabled = infoEnabled5 || loggingLevel === "warn";
168
+ const errorEnabled = warnEnabled || loggingLevel === "error";
169
+ const info5 = infoEnabled5 ? (message) => console.info(\`[\${category}] \${message}\`) : NO_OP;
170
+ const warn4 = warnEnabled ? (message) => console.warn(\`[\${category}] \${message}\`) : NO_OP;
171
+ const debug5 = debugEnabled5 ? (message) => console.debug(\`[\${category}] \${message}\`) : NO_OP;
172
+ const error4 = errorEnabled ? (message) => console.error(\`[\${category}] \${message}\`) : NO_OP;
173
+ if (false) {
174
+ return {
175
+ errorEnabled,
176
+ error: error4
177
+ };
178
+ } else {
179
+ return {
180
+ debugEnabled: debugEnabled5,
181
+ infoEnabled: infoEnabled5,
182
+ warnEnabled,
183
+ errorEnabled,
184
+ info: info5,
185
+ warn: warn4,
186
+ debug: debug5,
187
+ error: error4
188
+ };
189
+ }
190
+ };
191
+ function getLoggingSettings() {
192
+ if (typeof loggingSettings !== "undefined") {
193
+ return loggingSettings;
194
+ } else {
195
+ return {
196
+ loggingLevel: getLoggingLevelFromCookie()
197
+ };
198
+ }
199
+ }
200
+ function getLoggingLevelFromCookie() {
201
+ const value = getCookieValue("vuu-logging-level");
202
+ if (isValidLogLevel(value)) {
203
+ return value;
204
+ } else {
205
+ return DEFAULT_LOG_LEVEL;
206
+ }
207
+ }
208
+
209
+ // ../vuu-utils/src/debug-utils.ts
210
+ var { debug, debugEnabled } = logger("range-monitor");
211
+ var RangeMonitor = class {
212
+ constructor(source) {
213
+ this.source = source;
214
+ this.range = { from: 0, to: 0 };
215
+ this.timestamp = 0;
216
+ }
217
+ isSet() {
218
+ return this.timestamp !== 0;
219
+ }
220
+ set({ from, to }) {
221
+ const { timestamp } = this;
222
+ this.range.from = from;
223
+ this.range.to = to;
224
+ this.timestamp = performance.now();
225
+ if (timestamp) {
226
+ debugEnabled && debug(
227
+ \`<\${this.source}> [\${from}-\${to}], \${(this.timestamp - timestamp).toFixed(0)} ms elapsed\`
228
+ );
229
+ } else {
230
+ return 0;
231
+ }
232
+ }
233
+ };
234
+
235
+ // ../vuu-utils/src/event-emitter.ts
236
+ function isArrayOfListeners(listeners) {
237
+ return Array.isArray(listeners);
238
+ }
239
+ function isOnlyListener(listeners) {
240
+ return !Array.isArray(listeners);
241
+ }
242
+ var _events;
243
+ var EventEmitter = class {
244
+ constructor() {
245
+ __privateAdd(this, _events, /* @__PURE__ */ new Map());
246
+ }
247
+ addListener(event, listener) {
248
+ const listeners = __privateGet(this, _events).get(event);
249
+ if (!listeners) {
250
+ __privateGet(this, _events).set(event, listener);
251
+ } else if (isArrayOfListeners(listeners)) {
252
+ listeners.push(listener);
253
+ } else if (isOnlyListener(listeners)) {
254
+ __privateGet(this, _events).set(event, [listeners, listener]);
255
+ }
256
+ }
257
+ removeListener(event, listener) {
258
+ if (!__privateGet(this, _events).has(event)) {
259
+ return;
260
+ }
261
+ const listenerOrListeners = __privateGet(this, _events).get(event);
262
+ let position = -1;
263
+ if (listenerOrListeners === listener) {
264
+ __privateGet(this, _events).delete(event);
265
+ } else if (Array.isArray(listenerOrListeners)) {
266
+ for (let i = length; i-- > 0; ) {
267
+ if (listenerOrListeners[i] === listener) {
268
+ position = i;
269
+ break;
270
+ }
271
+ }
272
+ if (position < 0) {
273
+ return;
274
+ }
275
+ if (listenerOrListeners.length === 1) {
276
+ listenerOrListeners.length = 0;
277
+ __privateGet(this, _events).delete(event);
278
+ } else {
279
+ listenerOrListeners.splice(position, 1);
280
+ }
281
+ }
282
+ }
283
+ removeAllListeners(event) {
284
+ if (event && __privateGet(this, _events).has(event)) {
285
+ __privateGet(this, _events).delete(event);
286
+ } else if (event === void 0) {
287
+ __privateGet(this, _events).clear();
288
+ }
289
+ }
290
+ emit(event, ...args) {
291
+ if (__privateGet(this, _events)) {
292
+ const handler = __privateGet(this, _events).get(event);
293
+ if (handler) {
294
+ this.invokeHandler(handler, args);
295
+ }
296
+ }
297
+ }
298
+ once(event, listener) {
299
+ const handler = (...args) => {
300
+ this.removeListener(event, handler);
301
+ listener(...args);
302
+ };
303
+ this.on(event, handler);
304
+ }
305
+ on(event, listener) {
306
+ this.addListener(event, listener);
307
+ }
308
+ hasListener(event, listener) {
309
+ const listeners = __privateGet(this, _events).get(event);
310
+ if (Array.isArray(listeners)) {
311
+ return listeners.includes(listener);
312
+ } else {
313
+ return listeners === listener;
314
+ }
315
+ }
316
+ invokeHandler(handler, args) {
317
+ if (isArrayOfListeners(handler)) {
318
+ handler.slice().forEach((listener) => this.invokeHandler(listener, args));
319
+ } else {
320
+ switch (args.length) {
321
+ case 0:
322
+ handler();
323
+ break;
324
+ case 1:
325
+ handler(args[0]);
326
+ break;
327
+ case 2:
328
+ handler(args[0], args[1]);
329
+ break;
330
+ default:
331
+ handler.call(null, ...args);
332
+ }
333
+ }
334
+ }
335
+ };
336
+ _events = new WeakMap();
337
+
338
+ // ../vuu-utils/src/round-decimal.ts
339
+ var PUNCTUATION_STR = String.fromCharCode(8200);
340
+ var DIGIT_STR = String.fromCharCode(8199);
341
+ var Space = {
342
+ DIGIT: DIGIT_STR,
343
+ TWO_DIGITS: DIGIT_STR + DIGIT_STR,
344
+ THREE_DIGITS: DIGIT_STR + DIGIT_STR + DIGIT_STR,
345
+ FULL_PADDING: [
346
+ null,
347
+ PUNCTUATION_STR + DIGIT_STR,
348
+ PUNCTUATION_STR + DIGIT_STR + DIGIT_STR,
349
+ PUNCTUATION_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR,
350
+ PUNCTUATION_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR
351
+ ]
352
+ };
353
+ var LEADING_FILL = DIGIT_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR + DIGIT_STR;
354
+
355
+ // ../vuu-utils/src/json-utils.ts
356
+ var { COUNT } = metadataKeys;
357
+
358
+ // ../vuu-utils/src/keyset.ts
359
+ var KeySet = class {
360
+ constructor(range) {
361
+ this.keys = /* @__PURE__ */ new Map();
362
+ this.free = [];
363
+ this.nextKeyValue = 0;
364
+ this.reset(range);
365
+ }
366
+ next() {
367
+ if (this.free.length > 0) {
368
+ return this.free.pop();
369
+ } else {
370
+ return this.nextKeyValue++;
371
+ }
372
+ }
373
+ reset({ from, to }) {
374
+ this.keys.forEach((keyValue, rowIndex) => {
375
+ if (rowIndex < from || rowIndex >= to) {
376
+ this.free.push(keyValue);
377
+ this.keys.delete(rowIndex);
378
+ }
379
+ });
380
+ const size = to - from;
381
+ if (this.keys.size + this.free.length > size) {
382
+ this.free.length = Math.max(0, size - this.keys.size);
383
+ }
384
+ for (let rowIndex = from; rowIndex < to; rowIndex++) {
385
+ if (!this.keys.has(rowIndex)) {
386
+ const nextKeyValue = this.next();
387
+ this.keys.set(rowIndex, nextKeyValue);
388
+ }
389
+ }
390
+ if (this.nextKeyValue > this.keys.size) {
391
+ this.nextKeyValue = this.keys.size;
392
+ }
393
+ }
394
+ keyFor(rowIndex) {
395
+ const key = this.keys.get(rowIndex);
396
+ if (key === void 0) {
397
+ console.log(\`key not found
398
+ keys: \${this.toDebugString()}
399
+ free : \${this.free.join(",")}
400
+ \`);
401
+ throw Error(\`KeySet, no key found for rowIndex \${rowIndex}\`);
402
+ }
403
+ return key;
404
+ }
405
+ toDebugString() {
406
+ return Array.from(this.keys.entries()).map((k, v) => \`\${k}=>\${v}\`).join(",");
407
+ }
408
+ };
409
+
410
+ // ../vuu-utils/src/row-utils.ts
411
+ var { IDX } = metadataKeys;
412
+
413
+ // ../vuu-utils/src/selection-utils.ts
414
+ var { SELECTED } = metadataKeys;
415
+ var RowSelected = {
416
+ False: 0,
417
+ True: 1,
418
+ First: 2,
419
+ Last: 4
420
+ };
421
+ var rangeIncludes = (range, index) => index >= range[0] && index <= range[1];
422
+ var SINGLE_SELECTED_ROW = RowSelected.True + RowSelected.First + RowSelected.Last;
423
+ var FIRST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.First;
424
+ var LAST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.Last;
425
+ var getSelectionStatus = (selected, itemIndex) => {
426
+ for (const item of selected) {
427
+ if (typeof item === "number") {
428
+ if (item === itemIndex) {
429
+ return SINGLE_SELECTED_ROW;
430
+ }
431
+ } else if (rangeIncludes(item, itemIndex)) {
432
+ if (itemIndex === item[0]) {
433
+ return FIRST_SELECTED_ROW_OF_BLOCK;
434
+ } else if (itemIndex === item[1]) {
435
+ return LAST_SELECTED_ROW_OF_BLOCK;
436
+ } else {
437
+ return RowSelected.True;
438
+ }
439
+ }
440
+ }
441
+ return RowSelected.False;
442
+ };
443
+ var expandSelection = (selected) => {
444
+ if (selected.every((selectedItem) => typeof selectedItem === "number")) {
445
+ return selected;
446
+ }
447
+ const expandedSelected = [];
448
+ for (const selectedItem of selected) {
449
+ if (typeof selectedItem === "number") {
450
+ expandedSelected.push(selectedItem);
451
+ } else {
452
+ for (let i = selectedItem[0]; i <= selectedItem[1]; i++) {
453
+ expandedSelected.push(i);
454
+ }
455
+ }
456
+ }
457
+ return expandedSelected;
458
+ };
459
+
460
+ // ../../node_modules/html-to-image/es/util.js
461
+ var uuid = (() => {
462
+ let counter = 0;
463
+ const random = () => (
464
+ // eslint-disable-next-line no-bitwise
465
+ \`0000\${(Math.random() * 36 ** 4 << 0).toString(36)}\`.slice(-4)
466
+ );
467
+ return () => {
468
+ counter += 1;
469
+ return \`u\${random()}\${counter}\`;
470
+ };
471
+ })();
472
+
473
+ // src/websocket-connection.ts
474
+ var { debug: debug2, debugEnabled: debugEnabled2, error, info, infoEnabled, warn } = logger(
475
+ "websocket-connection"
476
+ );
477
+ var WS = "ws";
478
+ var isWebsocketUrl = (url) => url.startsWith(WS + "://") || url.startsWith(WS + "s://");
479
+ var connectionAttemptStatus = {};
480
+ var setWebsocket = Symbol("setWebsocket");
481
+ var connectionCallback = Symbol("connectionCallback");
482
+ async function connect(connectionString, protocol, callback, retryLimitDisconnect = 10, retryLimitStartup = 5) {
483
+ connectionAttemptStatus[connectionString] = {
484
+ status: "connecting",
485
+ connect: {
486
+ allowed: retryLimitStartup,
487
+ remaining: retryLimitStartup
488
+ },
489
+ reconnect: {
490
+ allowed: retryLimitDisconnect,
491
+ remaining: retryLimitDisconnect
492
+ }
493
+ };
494
+ return makeConnection(connectionString, protocol, callback);
495
+ }
496
+ async function reconnect(connection) {
497
+ throw Error("connection broken");
498
+ }
499
+ async function makeConnection(url, protocol, callback, connection) {
500
+ const {
501
+ status: currentStatus,
502
+ connect: connectStatus,
503
+ reconnect: reconnectStatus
504
+ } = connectionAttemptStatus[url];
505
+ const trackedStatus = currentStatus === "connecting" ? connectStatus : reconnectStatus;
506
+ try {
507
+ callback({ type: "connection-status", status: "connecting" });
508
+ const reconnecting = typeof connection !== "undefined";
509
+ const ws = await createWebsocket(url, protocol);
510
+ console.info(
511
+ "%c\u26A1 %cconnected",
512
+ "font-size: 24px;color: green;font-weight: bold;",
513
+ "color:green; font-size: 14px;"
514
+ );
515
+ if (connection !== void 0) {
516
+ connection[setWebsocket](ws);
517
+ }
518
+ const websocketConnection = connection != null ? connection : new WebsocketConnection(ws, url, protocol, callback);
519
+ const status = reconnecting ? "reconnected" : "connection-open-awaiting-session";
520
+ callback({ type: "connection-status", status });
521
+ websocketConnection.status = status;
522
+ trackedStatus.remaining = trackedStatus.allowed;
523
+ return websocketConnection;
524
+ } catch (err) {
525
+ const retry = --trackedStatus.remaining > 0;
526
+ callback({
527
+ type: "connection-status",
528
+ status: "disconnected",
529
+ reason: "failed to connect",
530
+ retry
531
+ });
532
+ if (retry) {
533
+ return makeConnectionIn(url, protocol, callback, connection, 2e3);
534
+ } else {
535
+ throw Error("Failed to establish connection");
536
+ }
537
+ }
538
+ }
539
+ var makeConnectionIn = (url, protocol, callback, connection, delay) => new Promise((resolve) => {
540
+ setTimeout(() => {
541
+ resolve(makeConnection(url, protocol, callback, connection));
542
+ }, delay);
543
+ });
544
+ var createWebsocket = (connectionString, protocol) => new Promise((resolve, reject) => {
545
+ const websocketUrl = isWebsocketUrl(connectionString) ? connectionString : \`wss://\${connectionString}\`;
546
+ if (infoEnabled && protocol !== void 0) {
547
+ info(\`WebSocket Protocol \${protocol == null ? void 0 : protocol.toString()}\`);
548
+ }
549
+ const ws = new WebSocket(websocketUrl, protocol);
550
+ ws.onopen = () => resolve(ws);
551
+ ws.onerror = (evt) => reject(evt);
552
+ });
553
+ var closeWarn = () => {
554
+ warn == null ? void 0 : warn(\`Connection cannot be closed, socket not yet opened\`);
555
+ };
556
+ var sendWarn = (msg) => {
557
+ warn == null ? void 0 : warn(\`Message cannot be sent, socket closed \${msg.body.type}\`);
558
+ };
559
+ var parseMessage = (message) => {
560
+ try {
561
+ return JSON.parse(message);
562
+ } catch (e) {
563
+ throw Error(\`Error parsing JSON response from server \${message}\`);
564
+ }
565
+ };
566
+ var WebsocketConnection = class {
567
+ constructor(ws, url, protocol, callback) {
568
+ this.close = closeWarn;
569
+ this.requiresLogin = true;
570
+ this.send = sendWarn;
571
+ this.status = "ready";
572
+ this.messagesCount = 0;
573
+ this.connectionMetricsInterval = null;
574
+ this.handleWebsocketMessage = (evt) => {
575
+ const vuuMessageFromServer = parseMessage(evt.data);
576
+ this.messagesCount += 1;
577
+ if (true) {
578
+ if (debugEnabled2 && vuuMessageFromServer.body.type !== "HB") {
579
+ debug2 == null ? void 0 : debug2(\`<<< \${vuuMessageFromServer.body.type}\`);
580
+ }
581
+ }
582
+ this[connectionCallback](vuuMessageFromServer);
583
+ };
584
+ this.url = url;
585
+ this.protocol = protocol;
586
+ this[connectionCallback] = callback;
587
+ this[setWebsocket](ws);
588
+ }
589
+ reconnect() {
590
+ reconnect(this);
591
+ }
592
+ [(connectionCallback, setWebsocket)](ws) {
593
+ const callback = this[connectionCallback];
594
+ ws.onmessage = (evt) => {
595
+ this.status = "connected";
596
+ ws.onmessage = this.handleWebsocketMessage;
597
+ this.handleWebsocketMessage(evt);
598
+ };
599
+ this.connectionMetricsInterval = setInterval(() => {
600
+ callback({
601
+ type: "connection-metrics",
602
+ messagesLength: this.messagesCount
603
+ });
604
+ this.messagesCount = 0;
605
+ }, 2e3);
606
+ ws.onerror = () => {
607
+ error(\`\u26A1 connection error\`);
608
+ callback({
609
+ type: "connection-status",
610
+ status: "disconnected",
611
+ reason: "error"
612
+ });
613
+ if (this.connectionMetricsInterval) {
614
+ clearInterval(this.connectionMetricsInterval);
615
+ this.connectionMetricsInterval = null;
616
+ }
617
+ if (this.status === "connection-open-awaiting-session") {
618
+ error(
619
+ \`Websocket connection lost before Vuu session established, check websocket configuration\`
620
+ );
621
+ } else if (this.status !== "closed") {
622
+ reconnect(this);
623
+ this.send = queue;
624
+ }
625
+ };
626
+ ws.onclose = () => {
627
+ info == null ? void 0 : info(\`\u26A1 connection close\`);
628
+ callback({
629
+ type: "connection-status",
630
+ status: "disconnected",
631
+ reason: "close"
632
+ });
633
+ if (this.connectionMetricsInterval) {
634
+ clearInterval(this.connectionMetricsInterval);
635
+ this.connectionMetricsInterval = null;
636
+ }
637
+ if (this.status !== "closed") {
638
+ reconnect(this);
639
+ this.send = queue;
640
+ }
641
+ };
642
+ const send = (msg) => {
643
+ if (true) {
644
+ if (debugEnabled2 && msg.body.type !== "HB_RESP") {
645
+ debug2 == null ? void 0 : debug2(\`>>> \${msg.body.type}\`);
646
+ }
647
+ }
648
+ ws.send(JSON.stringify(msg));
649
+ };
650
+ const queue = (msg) => {
651
+ info == null ? void 0 : info(\`TODO queue message until websocket reconnected \${msg.body.type}\`);
652
+ };
653
+ this.send = send;
654
+ this.close = () => {
655
+ this.status = "closed";
656
+ ws.close();
657
+ this.close = closeWarn;
658
+ this.send = sendWarn;
659
+ info == null ? void 0 : info("close websocket");
660
+ };
661
+ }
662
+ };
663
+
664
+ // src/message-utils.ts
665
+ var MENU_RPC_TYPES = [
666
+ "VIEW_PORT_MENUS_SELECT_RPC",
667
+ "VIEW_PORT_MENU_TABLE_RPC",
668
+ "VIEW_PORT_MENU_ROW_RPC",
669
+ "VIEW_PORT_MENU_CELL_RPC",
670
+ "VP_EDIT_CELL_RPC",
671
+ "VP_EDIT_ROW_RPC",
672
+ "VP_EDIT_ADD_ROW_RPC",
673
+ "VP_EDIT_DELETE_CELL_RPC",
674
+ "VP_EDIT_DELETE_ROW_RPC",
675
+ "VP_EDIT_SUBMIT_FORM_RPC"
676
+ ];
677
+ var isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
678
+ var isVuuRpcRequest = (message) => message["type"] === "VIEW_PORT_RPC_CALL";
679
+ var stripRequestId = ({
680
+ requestId,
681
+ ...rest
682
+ }) => [requestId, rest];
683
+ var getFirstAndLastRows = (rows) => {
684
+ let firstRow = rows.at(0);
685
+ if (firstRow.updateType === "SIZE") {
686
+ if (rows.length === 1) {
687
+ return rows;
688
+ } else {
689
+ firstRow = rows.at(1);
690
+ }
691
+ }
692
+ const lastRow = rows.at(-1);
693
+ return [firstRow, lastRow];
694
+ };
695
+ var groupRowsByViewport = (rows) => {
696
+ const result = {};
697
+ for (const row of rows) {
698
+ const rowsForViewport = result[row.viewPortId] || (result[row.viewPortId] = []);
699
+ rowsForViewport.push(row);
700
+ }
701
+ return result;
702
+ };
703
+ var createSchemaFromTableMetadata = ({
704
+ columns,
705
+ dataTypes,
706
+ key,
707
+ table
708
+ }) => {
709
+ return {
710
+ table,
711
+ columns: columns.map((col, idx) => ({
712
+ name: col,
713
+ serverDataType: dataTypes[idx]
714
+ })),
715
+ key
716
+ };
717
+ };
718
+
719
+ // src/vuuUIMessageTypes.ts
720
+ var isConnectionStatusMessage = (msg) => msg.type === "connection-status";
721
+ var isConnectionQualityMetrics = (msg) => msg.type === "connection-metrics";
722
+ var isViewporttMessage = (msg) => "viewport" in msg;
723
+ var isSessionTableActionMessage = (messageBody) => messageBody.type === "VIEW_PORT_MENU_RESP" && messageBody.action !== null && isSessionTable(messageBody.action.table);
724
+ var isSessionTable = (table) => {
725
+ if (table !== null && typeof table === "object" && "table" in table && "module" in table) {
726
+ return table.table.startsWith("session");
727
+ }
728
+ return false;
729
+ };
730
+
731
+ // src/server-proxy/messages.ts
732
+ var CHANGE_VP_SUCCESS = "CHANGE_VP_SUCCESS";
733
+ var CLOSE_TREE_NODE = "CLOSE_TREE_NODE";
734
+ var CLOSE_TREE_SUCCESS = "CLOSE_TREE_SUCCESS";
735
+ var CREATE_VP = "CREATE_VP";
736
+ var DISABLE_VP = "DISABLE_VP";
737
+ var DISABLE_VP_SUCCESS = "DISABLE_VP_SUCCESS";
738
+ var ENABLE_VP = "ENABLE_VP";
739
+ var ENABLE_VP_SUCCESS = "ENABLE_VP_SUCCESS";
740
+ var GET_VP_VISUAL_LINKS = "GET_VP_VISUAL_LINKS";
741
+ var GET_VIEW_PORT_MENUS = "GET_VIEW_PORT_MENUS";
742
+ var HB = "HB";
743
+ var HB_RESP = "HB_RESP";
744
+ var LOGIN = "LOGIN";
745
+ var OPEN_TREE_NODE = "OPEN_TREE_NODE";
746
+ var OPEN_TREE_SUCCESS = "OPEN_TREE_SUCCESS";
747
+ var REMOVE_VP = "REMOVE_VP";
748
+ var SET_SELECTION_SUCCESS = "SET_SELECTION_SUCCESS";
749
+
750
+ // src/server-proxy/rpc-services.ts
751
+ var getRpcServiceModule = (service) => {
752
+ switch (service) {
753
+ case "TypeAheadRpcHandler":
754
+ return "TYPEAHEAD";
755
+ default:
756
+ return "SIMUL";
757
+ }
758
+ };
759
+
760
+ // src/server-proxy/array-backed-moving-window.ts
761
+ var EMPTY_ARRAY = [];
762
+ var log = logger("array-backed-moving-window");
763
+ function dataIsUnchanged(newRow, existingRow) {
764
+ if (!existingRow) {
765
+ return false;
766
+ }
767
+ if (existingRow.data.length !== newRow.data.length) {
768
+ return false;
769
+ }
770
+ if (existingRow.sel !== newRow.sel) {
771
+ return false;
772
+ }
773
+ for (let i = 0; i < existingRow.data.length; i++) {
774
+ if (existingRow.data[i] !== newRow.data[i]) {
775
+ return false;
776
+ }
777
+ }
778
+ return true;
779
+ }
780
+ var _range;
781
+ var ArrayBackedMovingWindow = class {
782
+ // Note, the buffer is already accounted for in the range passed in here
783
+ constructor({ from: clientFrom, to: clientTo }, { from, to }, bufferSize) {
784
+ __privateAdd(this, _range, void 0);
785
+ this.setRowCount = (rowCount) => {
786
+ var _a;
787
+ (_a = log.info) == null ? void 0 : _a.call(log, \`setRowCount \${rowCount}\`);
788
+ if (rowCount < this.internalData.length) {
789
+ this.internalData.length = rowCount;
790
+ }
791
+ if (rowCount < this.rowCount) {
792
+ this.rowsWithinRange = 0;
793
+ const end = Math.min(rowCount, this.clientRange.to);
794
+ for (let i = this.clientRange.from; i < end; i++) {
795
+ const rowIndex = i - __privateGet(this, _range).from;
796
+ if (this.internalData[rowIndex] !== void 0) {
797
+ this.rowsWithinRange += 1;
798
+ }
799
+ }
800
+ }
801
+ this.rowCount = rowCount;
802
+ };
803
+ this.bufferBreakout = (from, to) => {
804
+ const bufferPerimeter = this.bufferSize * 0.25;
805
+ if (__privateGet(this, _range).to - to < bufferPerimeter) {
806
+ return true;
807
+ } else if (__privateGet(this, _range).from > 0 && from - __privateGet(this, _range).from < bufferPerimeter) {
808
+ return true;
809
+ } else {
810
+ return false;
811
+ }
812
+ };
813
+ this.bufferSize = bufferSize;
814
+ this.clientRange = new WindowRange(clientFrom, clientTo);
815
+ __privateSet(this, _range, new WindowRange(from, to));
816
+ this.internalData = new Array(bufferSize);
817
+ this.rowsWithinRange = 0;
818
+ this.rowCount = 0;
819
+ }
820
+ get range() {
821
+ return __privateGet(this, _range);
822
+ }
823
+ // TODO we shpuld probably have a hasAllClientRowsWithinRange
824
+ get hasAllRowsWithinRange() {
825
+ return this.rowsWithinRange === this.clientRange.to - this.clientRange.from || // this.rowsWithinRange === this.range.to - this.range.from ||
826
+ this.rowCount > 0 && this.clientRange.from + this.rowsWithinRange === this.rowCount;
827
+ }
828
+ // Check to see if set of rows is outside the current viewport range, indicating
829
+ // that veiwport is being scrolled quickly and server is not able to keep up.
830
+ outOfRange(firstIndex, lastIndex) {
831
+ const { from, to } = this.range;
832
+ if (lastIndex < from) {
833
+ return true;
834
+ }
835
+ if (firstIndex >= to) {
836
+ return true;
837
+ }
838
+ }
839
+ setAtIndex(row) {
840
+ const { rowIndex: index } = row;
841
+ const internalIndex = index - __privateGet(this, _range).from;
842
+ if (dataIsUnchanged(row, this.internalData[internalIndex])) {
843
+ return false;
844
+ }
845
+ const isWithinClientRange = this.isWithinClientRange(index);
846
+ if (isWithinClientRange || this.isWithinRange(index)) {
847
+ if (!this.internalData[internalIndex] && isWithinClientRange) {
848
+ this.rowsWithinRange += 1;
849
+ }
850
+ this.internalData[internalIndex] = row;
851
+ }
852
+ return isWithinClientRange;
853
+ }
854
+ getAtIndex(index) {
855
+ return __privateGet(this, _range).isWithin(index) && this.internalData[index - __privateGet(this, _range).from] != null ? this.internalData[index - __privateGet(this, _range).from] : void 0;
856
+ }
857
+ isWithinRange(index) {
858
+ return __privateGet(this, _range).isWithin(index);
859
+ }
860
+ isWithinClientRange(index) {
861
+ return this.clientRange.isWithin(index);
862
+ }
863
+ // Returns [false] or [serverDataRequired, clientRows, holdingRows]
864
+ setClientRange(from, to) {
865
+ var _a;
866
+ (_a = log.debug) == null ? void 0 : _a.call(log, \`setClientRange \${from} - \${to}\`);
867
+ const currentFrom = this.clientRange.from;
868
+ const currentTo = Math.min(this.clientRange.to, this.rowCount);
869
+ if (from === currentFrom && to === currentTo) {
870
+ return [
871
+ false,
872
+ EMPTY_ARRAY
873
+ /*, EMPTY_ARRAY*/
874
+ ];
875
+ }
876
+ const originalRange = this.clientRange.copy();
877
+ this.clientRange.from = from;
878
+ this.clientRange.to = to;
879
+ this.rowsWithinRange = 0;
880
+ for (let i = from; i < to; i++) {
881
+ const internalIndex = i - __privateGet(this, _range).from;
882
+ if (this.internalData[internalIndex]) {
883
+ this.rowsWithinRange += 1;
884
+ }
885
+ }
886
+ let clientRows = EMPTY_ARRAY;
887
+ const offset = __privateGet(this, _range).from;
888
+ if (this.hasAllRowsWithinRange) {
889
+ if (to > originalRange.to) {
890
+ const start = Math.max(from, originalRange.to);
891
+ clientRows = this.internalData.slice(start - offset, to - offset);
892
+ } else {
893
+ const end = Math.min(originalRange.from, to);
894
+ clientRows = this.internalData.slice(from - offset, end - offset);
895
+ }
896
+ }
897
+ const serverDataRequired = this.bufferBreakout(from, to);
898
+ return [serverDataRequired, clientRows];
899
+ }
900
+ setRange(from, to) {
901
+ var _a, _b;
902
+ if (from !== __privateGet(this, _range).from || to !== __privateGet(this, _range).to) {
903
+ (_a = log.debug) == null ? void 0 : _a.call(log, \`setRange \${from} - \${to}\`);
904
+ const [overlapFrom, overlapTo] = __privateGet(this, _range).overlap(from, to);
905
+ const newData = new Array(to - from);
906
+ this.rowsWithinRange = 0;
907
+ for (let i = overlapFrom; i < overlapTo; i++) {
908
+ const data = this.getAtIndex(i);
909
+ if (data) {
910
+ const index = i - from;
911
+ newData[index] = data;
912
+ if (this.isWithinClientRange(i)) {
913
+ this.rowsWithinRange += 1;
914
+ }
915
+ }
916
+ }
917
+ this.internalData = newData;
918
+ __privateGet(this, _range).from = from;
919
+ __privateGet(this, _range).to = to;
920
+ } else {
921
+ (_b = log.debug) == null ? void 0 : _b.call(log, \`setRange \${from} - \${to} IGNORED because not changed\`);
922
+ }
923
+ }
924
+ //TODO temp
925
+ get data() {
926
+ return this.internalData;
927
+ }
928
+ getData() {
929
+ var _a;
930
+ const { from, to } = __privateGet(this, _range);
931
+ const { from: clientFrom, to: clientTo } = this.clientRange;
932
+ const startOffset = Math.max(0, clientFrom - from);
933
+ const endOffset = Math.min(
934
+ to - from,
935
+ to,
936
+ clientTo - from,
937
+ (_a = this.rowCount) != null ? _a : to
938
+ );
939
+ return this.internalData.slice(startOffset, endOffset);
940
+ }
941
+ clear() {
942
+ var _a;
943
+ (_a = log.debug) == null ? void 0 : _a.call(log, "clear");
944
+ this.internalData.length = 0;
945
+ this.rowsWithinRange = 0;
946
+ this.setRowCount(0);
947
+ }
948
+ // used only for debugging
949
+ getCurrentDataRange() {
950
+ const rows = this.internalData;
951
+ const len = rows.length;
952
+ let [firstRow] = this.internalData;
953
+ let lastRow = this.internalData[len - 1];
954
+ if (firstRow && lastRow) {
955
+ return [firstRow.rowIndex, lastRow.rowIndex];
956
+ } else {
957
+ for (let i = 0; i < len; i++) {
958
+ if (rows[i] !== void 0) {
959
+ firstRow = rows[i];
960
+ break;
961
+ }
962
+ }
963
+ for (let i = len - 1; i >= 0; i--) {
964
+ if (rows[i] !== void 0) {
965
+ lastRow = rows[i];
966
+ break;
967
+ }
968
+ }
969
+ if (firstRow && lastRow) {
970
+ return [firstRow.rowIndex, lastRow.rowIndex];
971
+ } else {
972
+ return [-1, -1];
973
+ }
974
+ }
975
+ }
976
+ };
977
+ _range = new WeakMap();
978
+
979
+ // src/server-proxy/viewport.ts
980
+ var EMPTY_GROUPBY = [];
981
+ var { debug: debug3, debugEnabled: debugEnabled3, error: error2, info: info2, infoEnabled: infoEnabled2, warn: warn2 } = logger("viewport");
982
+ var isLeafUpdate = ({ rowKey, updateType }) => updateType === "U" && !rowKey.startsWith("$root");
983
+ var NO_DATA_UPDATE = [
984
+ void 0,
985
+ void 0
986
+ ];
987
+ var NO_UPDATE_STATUS = {
988
+ count: 0,
989
+ mode: void 0,
990
+ size: 0,
991
+ ts: 0
992
+ };
993
+ var Viewport = class {
994
+ constructor({
995
+ aggregations,
996
+ bufferSize = 50,
997
+ columns,
998
+ filter,
999
+ groupBy = [],
1000
+ table,
1001
+ range,
1002
+ sort,
1003
+ title,
1004
+ viewport,
1005
+ visualLink
1006
+ }, postMessageToClient) {
1007
+ /** batchMode is irrelevant for Vuu Table, it was introduced to try and improve rendering performance of AgGrid */
1008
+ this.batchMode = true;
1009
+ this.hasUpdates = false;
1010
+ this.pendingUpdates = [];
1011
+ this.pendingOperations = /* @__PURE__ */ new Map();
1012
+ this.pendingRangeRequests = [];
1013
+ this.rowCountChanged = false;
1014
+ this.selectedRows = [];
1015
+ this.useBatchMode = true;
1016
+ this.lastUpdateStatus = NO_UPDATE_STATUS;
1017
+ this.updateThrottleTimer = void 0;
1018
+ this.rangeMonitor = new RangeMonitor("ViewPort");
1019
+ this.disabled = false;
1020
+ this.isTree = false;
1021
+ // TODO roll disabled/suspended into status
1022
+ this.status = "";
1023
+ this.suspended = false;
1024
+ this.suspendTimer = null;
1025
+ // Records SIZE only updates
1026
+ this.setLastSizeOnlyUpdateSize = (size) => {
1027
+ this.lastUpdateStatus.size = size;
1028
+ };
1029
+ this.setLastUpdate = (mode) => {
1030
+ const { ts: lastTS, mode: lastMode } = this.lastUpdateStatus;
1031
+ let elapsedTime = 0;
1032
+ if (lastMode === mode) {
1033
+ const ts = Date.now();
1034
+ this.lastUpdateStatus.count += 1;
1035
+ this.lastUpdateStatus.ts = ts;
1036
+ elapsedTime = lastTS === 0 ? 0 : ts - lastTS;
1037
+ } else {
1038
+ this.lastUpdateStatus.count = 1;
1039
+ this.lastUpdateStatus.ts = 0;
1040
+ elapsedTime = 0;
1041
+ }
1042
+ this.lastUpdateStatus.mode = mode;
1043
+ return elapsedTime;
1044
+ };
1045
+ this.rangeRequestAlreadyPending = (range) => {
1046
+ const { bufferSize } = this;
1047
+ const bufferThreshold = bufferSize * 0.25;
1048
+ let { from: stillPendingFrom } = range;
1049
+ for (const { from, to } of this.pendingRangeRequests) {
1050
+ if (stillPendingFrom >= from && stillPendingFrom < to) {
1051
+ if (range.to + bufferThreshold <= to) {
1052
+ return true;
1053
+ } else {
1054
+ stillPendingFrom = to;
1055
+ }
1056
+ }
1057
+ }
1058
+ return false;
1059
+ };
1060
+ this.sendThrottledSizeMessage = () => {
1061
+ this.updateThrottleTimer = void 0;
1062
+ this.lastUpdateStatus.count = 3;
1063
+ this.postMessageToClient({
1064
+ clientViewportId: this.clientViewportId,
1065
+ mode: "size-only",
1066
+ size: this.lastUpdateStatus.size,
1067
+ type: "viewport-update"
1068
+ });
1069
+ };
1070
+ // If we are receiving multiple SIZE updates but no data, table is loading rows
1071
+ // outside of our viewport. We can safely throttle these requests. Doing so will
1072
+ // alleviate pressure on UI DataTable.
1073
+ this.shouldThrottleMessage = (mode) => {
1074
+ const elapsedTime = this.setLastUpdate(mode);
1075
+ return mode === "size-only" && elapsedTime > 0 && elapsedTime < 500 && this.lastUpdateStatus.count > 3;
1076
+ };
1077
+ this.throttleMessage = (mode) => {
1078
+ if (this.shouldThrottleMessage(mode)) {
1079
+ info2 == null ? void 0 : info2("throttling updates setTimeout to 2000");
1080
+ if (this.updateThrottleTimer === void 0) {
1081
+ this.updateThrottleTimer = setTimeout(
1082
+ this.sendThrottledSizeMessage,
1083
+ 2e3
1084
+ );
1085
+ }
1086
+ return true;
1087
+ } else if (this.updateThrottleTimer !== void 0) {
1088
+ clearTimeout(this.updateThrottleTimer);
1089
+ this.updateThrottleTimer = void 0;
1090
+ }
1091
+ return false;
1092
+ };
1093
+ this.getNewRowCount = () => {
1094
+ if (this.rowCountChanged && this.dataWindow) {
1095
+ this.rowCountChanged = false;
1096
+ return this.dataWindow.rowCount;
1097
+ }
1098
+ };
1099
+ this.aggregations = aggregations;
1100
+ this.bufferSize = bufferSize;
1101
+ this.clientRange = range;
1102
+ this.clientViewportId = viewport;
1103
+ this.columns = columns;
1104
+ this.filter = filter;
1105
+ this.groupBy = groupBy;
1106
+ this.keys = new KeySet(range);
1107
+ this.pendingLinkedParent = visualLink;
1108
+ this.table = table;
1109
+ this.sort = sort;
1110
+ this.title = title;
1111
+ infoEnabled2 && (info2 == null ? void 0 : info2(
1112
+ \`constructor #\${viewport} \${table.table} bufferSize=\${bufferSize}\`
1113
+ ));
1114
+ this.dataWindow = new ArrayBackedMovingWindow(
1115
+ this.clientRange,
1116
+ range,
1117
+ this.bufferSize
1118
+ );
1119
+ this.postMessageToClient = postMessageToClient;
1120
+ }
1121
+ get hasUpdatesToProcess() {
1122
+ if (this.suspended) {
1123
+ return false;
1124
+ }
1125
+ return this.rowCountChanged || this.hasUpdates;
1126
+ }
1127
+ get size() {
1128
+ var _a;
1129
+ return (_a = this.dataWindow.rowCount) != null ? _a : 0;
1130
+ }
1131
+ subscribe() {
1132
+ const { filter } = this.filter;
1133
+ this.status = this.status === "subscribed" ? "resubscribing" : "subscribing";
1134
+ return {
1135
+ type: CREATE_VP,
1136
+ table: this.table,
1137
+ range: getFullRange(this.clientRange, this.bufferSize),
1138
+ aggregations: this.aggregations,
1139
+ columns: this.columns,
1140
+ sort: this.sort,
1141
+ groupBy: this.groupBy,
1142
+ filterSpec: { filter }
1143
+ };
1144
+ }
1145
+ handleSubscribed({
1146
+ viewPortId,
1147
+ aggregations,
1148
+ columns,
1149
+ filterSpec: filter,
1150
+ range,
1151
+ sort,
1152
+ groupBy
1153
+ }, tableSchema) {
1154
+ this.serverViewportId = viewPortId;
1155
+ this.status = "subscribed";
1156
+ this.aggregations = aggregations;
1157
+ this.columns = columns;
1158
+ this.groupBy = groupBy;
1159
+ this.isTree = groupBy && groupBy.length > 0;
1160
+ this.dataWindow.setRange(range.from, range.to);
1161
+ return {
1162
+ aggregations,
1163
+ type: "subscribed",
1164
+ clientViewportId: this.clientViewportId,
1165
+ columns,
1166
+ filter,
1167
+ groupBy,
1168
+ range,
1169
+ sort,
1170
+ tableSchema
1171
+ };
1172
+ }
1173
+ awaitOperation(requestId, msg) {
1174
+ this.pendingOperations.set(requestId, msg);
1175
+ }
1176
+ // Return a message if we need to communicate this to client UI
1177
+ completeOperation(requestId, ...params) {
1178
+ var _a;
1179
+ const { clientViewportId, pendingOperations } = this;
1180
+ const pendingOperation = pendingOperations.get(requestId);
1181
+ if (!pendingOperation) {
1182
+ error2(
1183
+ \`no matching operation found to complete for requestId \${requestId}\`
1184
+ );
1185
+ return;
1186
+ }
1187
+ const { type } = pendingOperation;
1188
+ info2 == null ? void 0 : info2(\`completeOperation \${type}\`);
1189
+ pendingOperations.delete(requestId);
1190
+ if (type === "CHANGE_VP_RANGE") {
1191
+ const [from, to] = params;
1192
+ (_a = this.dataWindow) == null ? void 0 : _a.setRange(from, to);
1193
+ for (let i = this.pendingRangeRequests.length - 1; i >= 0; i--) {
1194
+ const pendingRangeRequest = this.pendingRangeRequests[i];
1195
+ if (pendingRangeRequest.requestId === requestId) {
1196
+ pendingRangeRequest.acked = true;
1197
+ break;
1198
+ } else {
1199
+ warn2 == null ? void 0 : warn2("range requests sent faster than they are being ACKed");
1200
+ }
1201
+ }
1202
+ } else if (type === "config") {
1203
+ const { aggregations, columns, filter, groupBy, sort } = pendingOperation.data;
1204
+ this.aggregations = aggregations;
1205
+ this.columns = columns;
1206
+ this.filter = filter;
1207
+ this.groupBy = groupBy;
1208
+ this.sort = sort;
1209
+ if (groupBy.length > 0) {
1210
+ this.isTree = true;
1211
+ } else if (this.isTree) {
1212
+ this.isTree = false;
1213
+ }
1214
+ debug3 == null ? void 0 : debug3(\`config change confirmed, isTree : \${this.isTree}\`);
1215
+ return {
1216
+ clientViewportId,
1217
+ type,
1218
+ config: pendingOperation.data
1219
+ };
1220
+ } else if (type === "groupBy") {
1221
+ this.isTree = pendingOperation.data.length > 0;
1222
+ this.groupBy = pendingOperation.data;
1223
+ debug3 == null ? void 0 : debug3(\`groupBy change confirmed, isTree : \${this.isTree}\`);
1224
+ return {
1225
+ clientViewportId,
1226
+ type,
1227
+ groupBy: pendingOperation.data
1228
+ };
1229
+ } else if (type === "columns") {
1230
+ this.columns = pendingOperation.data;
1231
+ return {
1232
+ clientViewportId,
1233
+ type,
1234
+ columns: pendingOperation.data
1235
+ };
1236
+ } else if (type === "filter") {
1237
+ this.filter = pendingOperation.data;
1238
+ return {
1239
+ clientViewportId,
1240
+ type,
1241
+ filter: pendingOperation.data
1242
+ };
1243
+ } else if (type === "aggregate") {
1244
+ this.aggregations = pendingOperation.data;
1245
+ return {
1246
+ clientViewportId,
1247
+ type: "aggregate",
1248
+ aggregations: this.aggregations
1249
+ };
1250
+ } else if (type === "sort") {
1251
+ this.sort = pendingOperation.data;
1252
+ return {
1253
+ clientViewportId,
1254
+ type,
1255
+ sort: this.sort
1256
+ };
1257
+ } else if (type === "selection") {
1258
+ } else if (type === "disable") {
1259
+ this.disabled = true;
1260
+ return {
1261
+ type: "disabled",
1262
+ clientViewportId
1263
+ };
1264
+ } else if (type === "enable") {
1265
+ this.disabled = false;
1266
+ return {
1267
+ type: "enabled",
1268
+ clientViewportId
1269
+ };
1270
+ } else if (type === "CREATE_VISUAL_LINK") {
1271
+ const [colName, parentViewportId, parentColName] = params;
1272
+ this.linkedParent = {
1273
+ colName,
1274
+ parentViewportId,
1275
+ parentColName
1276
+ };
1277
+ this.pendingLinkedParent = void 0;
1278
+ return {
1279
+ type: "vuu-link-created",
1280
+ clientViewportId,
1281
+ colName,
1282
+ parentViewportId,
1283
+ parentColName
1284
+ };
1285
+ } else if (type === "REMOVE_VISUAL_LINK") {
1286
+ this.linkedParent = void 0;
1287
+ return {
1288
+ type: "vuu-link-removed",
1289
+ clientViewportId
1290
+ };
1291
+ }
1292
+ }
1293
+ // TODO when a range request arrives, consider the viewport to be scrolling
1294
+ // until data arrives and we have the full range.
1295
+ // When not scrolling, any server data is an update
1296
+ // When scrolling, we are in batch mode
1297
+ rangeRequest(requestId, range) {
1298
+ if (debugEnabled3) {
1299
+ this.rangeMonitor.set(range);
1300
+ }
1301
+ const type = "CHANGE_VP_RANGE";
1302
+ if (this.dataWindow) {
1303
+ const [serverDataRequired, clientRows] = this.dataWindow.setClientRange(
1304
+ range.from,
1305
+ range.to
1306
+ );
1307
+ let debounceRequest;
1308
+ const maxRange = this.dataWindow.rowCount || void 0;
1309
+ const serverRequest = serverDataRequired && !this.rangeRequestAlreadyPending(range) ? {
1310
+ type,
1311
+ viewPortId: this.serverViewportId,
1312
+ ...getFullRange(range, this.bufferSize, maxRange)
1313
+ } : null;
1314
+ if (serverRequest) {
1315
+ debugEnabled3 && (debug3 == null ? void 0 : debug3(
1316
+ \`create CHANGE_VP_RANGE: [\${serverRequest.from} - \${serverRequest.to}]\`
1317
+ ));
1318
+ this.awaitOperation(requestId, { type });
1319
+ const pendingRequest = this.pendingRangeRequests.at(-1);
1320
+ if (pendingRequest) {
1321
+ if (pendingRequest.acked) {
1322
+ console.warn("Range Request before previous request is filled");
1323
+ } else {
1324
+ const { from, to } = pendingRequest;
1325
+ if (this.dataWindow.outOfRange(from, to)) {
1326
+ debounceRequest = {
1327
+ clientViewportId: this.clientViewportId,
1328
+ type: "debounce-begin"
1329
+ };
1330
+ } else {
1331
+ warn2 == null ? void 0 : warn2("Range Request before previous request is acked");
1332
+ }
1333
+ }
1334
+ }
1335
+ this.pendingRangeRequests.push({ ...serverRequest, requestId });
1336
+ if (this.useBatchMode) {
1337
+ this.batchMode = true;
1338
+ }
1339
+ } else if (clientRows.length > 0) {
1340
+ this.batchMode = false;
1341
+ }
1342
+ this.keys.reset(this.dataWindow.clientRange);
1343
+ const toClient = this.isTree ? toClientRowTree : toClientRow;
1344
+ if (clientRows.length) {
1345
+ return [
1346
+ serverRequest,
1347
+ clientRows.map((row) => {
1348
+ return toClient(row, this.keys, this.selectedRows);
1349
+ })
1350
+ ];
1351
+ } else if (debounceRequest) {
1352
+ return [serverRequest, void 0, debounceRequest];
1353
+ } else {
1354
+ return [serverRequest];
1355
+ }
1356
+ } else {
1357
+ return [null];
1358
+ }
1359
+ }
1360
+ setLinks(links) {
1361
+ this.links = links;
1362
+ return [
1363
+ {
1364
+ type: "vuu-links",
1365
+ links,
1366
+ clientViewportId: this.clientViewportId
1367
+ },
1368
+ this.pendingLinkedParent
1369
+ ];
1370
+ }
1371
+ setMenu(menu) {
1372
+ return {
1373
+ type: "vuu-menu",
1374
+ menu,
1375
+ clientViewportId: this.clientViewportId
1376
+ };
1377
+ }
1378
+ openTreeNode(requestId, message) {
1379
+ if (this.useBatchMode) {
1380
+ this.batchMode = true;
1381
+ }
1382
+ return {
1383
+ type: OPEN_TREE_NODE,
1384
+ vpId: this.serverViewportId,
1385
+ treeKey: message.key
1386
+ };
1387
+ }
1388
+ closeTreeNode(requestId, message) {
1389
+ if (this.useBatchMode) {
1390
+ this.batchMode = true;
1391
+ }
1392
+ return {
1393
+ type: CLOSE_TREE_NODE,
1394
+ vpId: this.serverViewportId,
1395
+ treeKey: message.key
1396
+ };
1397
+ }
1398
+ createLink(requestId, colName, parentVpId, parentColumnName) {
1399
+ const message = {
1400
+ type: "CREATE_VISUAL_LINK",
1401
+ parentVpId,
1402
+ childVpId: this.serverViewportId,
1403
+ parentColumnName,
1404
+ childColumnName: colName
1405
+ };
1406
+ this.awaitOperation(requestId, message);
1407
+ if (this.useBatchMode) {
1408
+ this.batchMode = true;
1409
+ }
1410
+ return message;
1411
+ }
1412
+ removeLink(requestId) {
1413
+ const message = {
1414
+ type: "REMOVE_VISUAL_LINK",
1415
+ childVpId: this.serverViewportId
1416
+ };
1417
+ this.awaitOperation(requestId, message);
1418
+ return message;
1419
+ }
1420
+ suspend() {
1421
+ this.suspended = true;
1422
+ info2 == null ? void 0 : info2("suspend");
1423
+ }
1424
+ resume() {
1425
+ this.suspended = false;
1426
+ if (debugEnabled3) {
1427
+ debug3 == null ? void 0 : debug3(\`resume: \${this.currentData()}\`);
1428
+ }
1429
+ return [this.size, this.currentData()];
1430
+ }
1431
+ currentData() {
1432
+ const out = [];
1433
+ if (this.dataWindow) {
1434
+ const records = this.dataWindow.getData();
1435
+ const { keys } = this;
1436
+ const toClient = this.isTree ? toClientRowTree : toClientRow;
1437
+ for (const row of records) {
1438
+ if (row) {
1439
+ out.push(toClient(row, keys, this.selectedRows));
1440
+ }
1441
+ }
1442
+ }
1443
+ return out;
1444
+ }
1445
+ enable(requestId) {
1446
+ this.awaitOperation(requestId, { type: "enable" });
1447
+ info2 == null ? void 0 : info2(\`enable: \${this.serverViewportId}\`);
1448
+ return {
1449
+ type: ENABLE_VP,
1450
+ viewPortId: this.serverViewportId
1451
+ };
1452
+ }
1453
+ disable(requestId) {
1454
+ this.awaitOperation(requestId, { type: "disable" });
1455
+ info2 == null ? void 0 : info2(\`disable: \${this.serverViewportId}\`);
1456
+ this.suspended = false;
1457
+ return {
1458
+ type: DISABLE_VP,
1459
+ viewPortId: this.serverViewportId
1460
+ };
1461
+ }
1462
+ columnRequest(requestId, columns) {
1463
+ this.awaitOperation(requestId, {
1464
+ type: "columns",
1465
+ data: columns
1466
+ });
1467
+ debug3 == null ? void 0 : debug3(\`columnRequest: \${columns}\`);
1468
+ return this.createRequest({ columns });
1469
+ }
1470
+ filterRequest(requestId, dataSourceFilter) {
1471
+ this.awaitOperation(requestId, {
1472
+ type: "filter",
1473
+ data: dataSourceFilter
1474
+ });
1475
+ if (this.useBatchMode) {
1476
+ this.batchMode = true;
1477
+ }
1478
+ const { filter } = dataSourceFilter;
1479
+ info2 == null ? void 0 : info2(\`filterRequest: \${filter}\`);
1480
+ return this.createRequest({ filterSpec: { filter } });
1481
+ }
1482
+ setConfig(requestId, config) {
1483
+ this.awaitOperation(requestId, { type: "config", data: config });
1484
+ const { filter, ...remainingConfig } = config;
1485
+ if (this.useBatchMode) {
1486
+ this.batchMode = true;
1487
+ }
1488
+ debugEnabled3 ? debug3 == null ? void 0 : debug3(\`setConfig \${JSON.stringify(config)}\`) : info2 == null ? void 0 : info2(\`setConfig\`);
1489
+ return this.createRequest(
1490
+ {
1491
+ ...remainingConfig,
1492
+ filterSpec: typeof (filter == null ? void 0 : filter.filter) === "string" ? {
1493
+ filter: filter.filter
1494
+ } : {
1495
+ filter: ""
1496
+ }
1497
+ },
1498
+ true
1499
+ );
1500
+ }
1501
+ aggregateRequest(requestId, aggregations) {
1502
+ this.awaitOperation(requestId, { type: "aggregate", data: aggregations });
1503
+ info2 == null ? void 0 : info2(\`aggregateRequest: \${aggregations}\`);
1504
+ return this.createRequest({ aggregations });
1505
+ }
1506
+ sortRequest(requestId, sort) {
1507
+ this.awaitOperation(requestId, { type: "sort", data: sort });
1508
+ info2 == null ? void 0 : info2(\`sortRequest: \${JSON.stringify(sort.sortDefs)}\`);
1509
+ return this.createRequest({ sort });
1510
+ }
1511
+ groupByRequest(requestId, groupBy = EMPTY_GROUPBY) {
1512
+ var _a;
1513
+ this.awaitOperation(requestId, { type: "groupBy", data: groupBy });
1514
+ if (this.useBatchMode) {
1515
+ this.batchMode = true;
1516
+ }
1517
+ if (!this.isTree) {
1518
+ (_a = this.dataWindow) == null ? void 0 : _a.clear();
1519
+ }
1520
+ return this.createRequest({ groupBy });
1521
+ }
1522
+ selectRequest(requestId, selected) {
1523
+ this.selectedRows = selected;
1524
+ this.awaitOperation(requestId, { type: "selection", data: selected });
1525
+ info2 == null ? void 0 : info2(\`selectRequest: \${selected}\`);
1526
+ return {
1527
+ type: "SET_SELECTION",
1528
+ vpId: this.serverViewportId,
1529
+ selection: expandSelection(selected)
1530
+ };
1531
+ }
1532
+ removePendingRangeRequest(firstIndex, lastIndex) {
1533
+ for (let i = this.pendingRangeRequests.length - 1; i >= 0; i--) {
1534
+ const { from, to } = this.pendingRangeRequests[i];
1535
+ let isLast = true;
1536
+ if (firstIndex >= from && firstIndex < to || lastIndex > from && lastIndex < to) {
1537
+ if (!isLast) {
1538
+ console.warn(
1539
+ "removePendingRangeRequest TABLE_ROWS are not for latest request"
1540
+ );
1541
+ }
1542
+ this.pendingRangeRequests.splice(i, 1);
1543
+ break;
1544
+ } else {
1545
+ isLast = false;
1546
+ }
1547
+ }
1548
+ }
1549
+ updateRows(rows) {
1550
+ var _a, _b, _c;
1551
+ const [firstRow, lastRow] = getFirstAndLastRows(rows);
1552
+ if (firstRow && lastRow) {
1553
+ this.removePendingRangeRequest(firstRow.rowIndex, lastRow.rowIndex);
1554
+ }
1555
+ if (rows.length === 1) {
1556
+ if (firstRow.vpSize === 0 && this.disabled) {
1557
+ debug3 == null ? void 0 : debug3(
1558
+ \`ignore a SIZE=0 message on disabled viewport (\${rows.length} rows)\`
1559
+ );
1560
+ return;
1561
+ } else if (firstRow.updateType === "SIZE") {
1562
+ this.setLastSizeOnlyUpdateSize(firstRow.vpSize);
1563
+ }
1564
+ }
1565
+ for (const row of rows) {
1566
+ if (this.isTree && isLeafUpdate(row)) {
1567
+ continue;
1568
+ } else {
1569
+ if (row.updateType === "SIZE" || ((_a = this.dataWindow) == null ? void 0 : _a.rowCount) !== row.vpSize) {
1570
+ (_b = this.dataWindow) == null ? void 0 : _b.setRowCount(row.vpSize);
1571
+ this.rowCountChanged = true;
1572
+ }
1573
+ if (row.updateType === "U") {
1574
+ if ((_c = this.dataWindow) == null ? void 0 : _c.setAtIndex(row)) {
1575
+ this.hasUpdates = true;
1576
+ if (!this.batchMode) {
1577
+ this.pendingUpdates.push(row);
1578
+ }
1579
+ }
1580
+ }
1581
+ }
1582
+ }
1583
+ }
1584
+ // This is called only after new data has been received from server - data
1585
+ // returned direcly from buffer does not use this.
1586
+ getClientRows() {
1587
+ let out = void 0;
1588
+ let mode = "size-only";
1589
+ if (!this.hasUpdates && !this.rowCountChanged) {
1590
+ return NO_DATA_UPDATE;
1591
+ }
1592
+ if (this.hasUpdates) {
1593
+ const { keys, selectedRows } = this;
1594
+ const toClient = this.isTree ? toClientRowTree : toClientRow;
1595
+ if (this.updateThrottleTimer) {
1596
+ self.clearTimeout(this.updateThrottleTimer);
1597
+ this.updateThrottleTimer = void 0;
1598
+ }
1599
+ if (this.pendingUpdates.length > 0) {
1600
+ out = [];
1601
+ mode = "update";
1602
+ for (const row of this.pendingUpdates) {
1603
+ out.push(toClient(row, keys, selectedRows));
1604
+ }
1605
+ this.pendingUpdates.length = 0;
1606
+ } else {
1607
+ const records = this.dataWindow.getData();
1608
+ if (this.dataWindow.hasAllRowsWithinRange) {
1609
+ out = [];
1610
+ mode = "batch";
1611
+ for (const row of records) {
1612
+ out.push(toClient(row, keys, selectedRows));
1613
+ }
1614
+ this.batchMode = false;
1615
+ }
1616
+ }
1617
+ this.hasUpdates = false;
1618
+ }
1619
+ if (this.throttleMessage(mode)) {
1620
+ return NO_DATA_UPDATE;
1621
+ } else {
1622
+ return [out, mode];
1623
+ }
1624
+ }
1625
+ createRequest(params, overWrite = false) {
1626
+ if (overWrite) {
1627
+ return {
1628
+ type: "CHANGE_VP",
1629
+ viewPortId: this.serverViewportId,
1630
+ ...params
1631
+ };
1632
+ } else {
1633
+ return {
1634
+ type: "CHANGE_VP",
1635
+ viewPortId: this.serverViewportId,
1636
+ aggregations: this.aggregations,
1637
+ columns: this.columns,
1638
+ sort: this.sort,
1639
+ groupBy: this.groupBy,
1640
+ filterSpec: {
1641
+ filter: this.filter.filter
1642
+ },
1643
+ ...params
1644
+ };
1645
+ }
1646
+ }
1647
+ };
1648
+ var toClientRow = ({ rowIndex, rowKey, sel: isSelected, data }, keys, selectedRows) => {
1649
+ return [
1650
+ rowIndex,
1651
+ keys.keyFor(rowIndex),
1652
+ true,
1653
+ false,
1654
+ 0,
1655
+ 0,
1656
+ rowKey,
1657
+ isSelected ? getSelectionStatus(selectedRows, rowIndex) : 0
1658
+ ].concat(data);
1659
+ };
1660
+ var toClientRowTree = ({ rowIndex, rowKey, sel: isSelected, data }, keys, selectedRows) => {
1661
+ const [depth, isExpanded, , isLeaf, , count, ...rest] = data;
1662
+ return [
1663
+ rowIndex,
1664
+ keys.keyFor(rowIndex),
1665
+ isLeaf,
1666
+ isExpanded,
1667
+ depth,
1668
+ count,
1669
+ rowKey,
1670
+ isSelected ? getSelectionStatus(selectedRows, rowIndex) : 0
1671
+ ].concat(rest);
1672
+ };
1673
+
1674
+ // src/server-proxy/server-proxy.ts
1675
+ var _requestId = 1;
1676
+ var { debug: debug4, debugEnabled: debugEnabled4, error: error3, info: info3, infoEnabled: infoEnabled3, warn: warn3 } = logger("server-proxy");
1677
+ var nextRequestId = () => \`\${_requestId++}\`;
1678
+ var DEFAULT_OPTIONS = {};
1679
+ var isActiveViewport = (viewPort) => viewPort.disabled !== true && viewPort.suspended !== true;
1680
+ var NO_ACTION = {
1681
+ type: "NO_ACTION"
1682
+ };
1683
+ var addTitleToLinks = (links, serverViewportId, label) => links.map(
1684
+ (link) => link.parentVpId === serverViewportId ? { ...link, label } : link
1685
+ );
1686
+ function addLabelsToLinks(links, viewports) {
1687
+ return links.map((linkDescriptor) => {
1688
+ const { parentVpId } = linkDescriptor;
1689
+ const viewport = viewports.get(parentVpId);
1690
+ if (viewport) {
1691
+ return {
1692
+ ...linkDescriptor,
1693
+ parentClientVpId: viewport.clientViewportId,
1694
+ label: viewport.title
1695
+ };
1696
+ } else {
1697
+ throw Error("addLabelsToLinks viewport not found");
1698
+ }
1699
+ });
1700
+ }
1701
+ var ServerProxy = class {
1702
+ constructor(connection, callback) {
1703
+ this.authToken = "";
1704
+ this.user = "user";
1705
+ this.pendingRequests = /* @__PURE__ */ new Map();
1706
+ this.queuedRequests = [];
1707
+ this.cachedTableMetaRequests = /* @__PURE__ */ new Map();
1708
+ this.cachedTableSchemas = /* @__PURE__ */ new Map();
1709
+ this.connection = connection;
1710
+ this.postMessageToClient = callback;
1711
+ this.viewports = /* @__PURE__ */ new Map();
1712
+ this.mapClientToServerViewport = /* @__PURE__ */ new Map();
1713
+ }
1714
+ async reconnect() {
1715
+ await this.login(this.authToken);
1716
+ const [activeViewports, inactiveViewports] = partition(
1717
+ Array.from(this.viewports.values()),
1718
+ isActiveViewport
1719
+ );
1720
+ this.viewports.clear();
1721
+ this.mapClientToServerViewport.clear();
1722
+ const reconnectViewports = (viewports) => {
1723
+ viewports.forEach((viewport) => {
1724
+ const { clientViewportId } = viewport;
1725
+ this.viewports.set(clientViewportId, viewport);
1726
+ this.sendMessageToServer(viewport.subscribe(), clientViewportId);
1727
+ });
1728
+ };
1729
+ reconnectViewports(activeViewports);
1730
+ setTimeout(() => {
1731
+ reconnectViewports(inactiveViewports);
1732
+ }, 2e3);
1733
+ }
1734
+ async login(authToken, user = "user") {
1735
+ if (authToken) {
1736
+ this.authToken = authToken;
1737
+ this.user = user;
1738
+ return new Promise((resolve, reject) => {
1739
+ this.sendMessageToServer(
1740
+ { type: LOGIN, token: this.authToken, user },
1741
+ ""
1742
+ );
1743
+ this.pendingLogin = { resolve, reject };
1744
+ });
1745
+ } else if (this.authToken === "") {
1746
+ error3("login, cannot login until auth token has been obtained");
1747
+ }
1748
+ }
1749
+ subscribe(message) {
1750
+ if (!this.mapClientToServerViewport.has(message.viewport)) {
1751
+ const pendingTableSchema = this.getTableMeta(message.table);
1752
+ const viewport = new Viewport(message, this.postMessageToClient);
1753
+ this.viewports.set(message.viewport, viewport);
1754
+ const pendingSubscription = this.awaitResponseToMessage(
1755
+ viewport.subscribe(),
1756
+ message.viewport
1757
+ );
1758
+ const awaitPendingReponses = Promise.all([
1759
+ pendingSubscription,
1760
+ pendingTableSchema
1761
+ ]);
1762
+ awaitPendingReponses.then(([subscribeResponse, tableSchema]) => {
1763
+ const { viewPortId: serverViewportId } = subscribeResponse;
1764
+ const { status: previousViewportStatus } = viewport;
1765
+ if (message.viewport !== serverViewportId) {
1766
+ this.viewports.delete(message.viewport);
1767
+ this.viewports.set(serverViewportId, viewport);
1768
+ }
1769
+ this.mapClientToServerViewport.set(message.viewport, serverViewportId);
1770
+ const clientResponse = viewport.handleSubscribed(
1771
+ subscribeResponse,
1772
+ tableSchema
1773
+ );
1774
+ if (clientResponse) {
1775
+ this.postMessageToClient(clientResponse);
1776
+ if (debugEnabled4) {
1777
+ debug4(
1778
+ \`post DataSourceSubscribedMessage to client: \${JSON.stringify(
1779
+ clientResponse
1780
+ )}\`
1781
+ );
1782
+ }
1783
+ }
1784
+ if (viewport.disabled) {
1785
+ this.disableViewport(viewport);
1786
+ }
1787
+ if (this.queuedRequests.length > 0) {
1788
+ this.processQueuedRequests();
1789
+ }
1790
+ if (previousViewportStatus === "subscribing" && // A session table will never have Visual Links, nor Context Menus
1791
+ !isSessionTable(viewport.table)) {
1792
+ this.sendMessageToServer({
1793
+ type: GET_VP_VISUAL_LINKS,
1794
+ vpId: serverViewportId
1795
+ });
1796
+ this.sendMessageToServer({
1797
+ type: GET_VIEW_PORT_MENUS,
1798
+ vpId: serverViewportId
1799
+ });
1800
+ Array.from(this.viewports.entries()).filter(
1801
+ ([id, { disabled }]) => id !== serverViewportId && !disabled
1802
+ ).forEach(([vpId]) => {
1803
+ this.sendMessageToServer({
1804
+ type: GET_VP_VISUAL_LINKS,
1805
+ vpId
1806
+ });
1807
+ });
1808
+ }
1809
+ });
1810
+ } else {
1811
+ error3(\`spurious subscribe call \${message.viewport}\`);
1812
+ }
1813
+ }
1814
+ processQueuedRequests() {
1815
+ const messageTypesProcessed = {};
1816
+ while (this.queuedRequests.length) {
1817
+ const queuedRequest = this.queuedRequests.pop();
1818
+ if (queuedRequest) {
1819
+ const { clientViewportId, message, requestId } = queuedRequest;
1820
+ if (message.type === "CHANGE_VP_RANGE") {
1821
+ if (messageTypesProcessed.CHANGE_VP_RANGE) {
1822
+ continue;
1823
+ }
1824
+ messageTypesProcessed.CHANGE_VP_RANGE = true;
1825
+ const serverViewportId = this.mapClientToServerViewport.get(clientViewportId);
1826
+ if (serverViewportId) {
1827
+ this.sendMessageToServer(
1828
+ {
1829
+ ...message,
1830
+ viewPortId: serverViewportId
1831
+ },
1832
+ requestId
1833
+ );
1834
+ }
1835
+ }
1836
+ }
1837
+ }
1838
+ }
1839
+ unsubscribe(clientViewportId) {
1840
+ const serverViewportId = this.mapClientToServerViewport.get(clientViewportId);
1841
+ if (serverViewportId) {
1842
+ info3 == null ? void 0 : info3(
1843
+ \`Unsubscribe Message (Client to Server):
1844
+ \${serverViewportId}\`
1845
+ );
1846
+ this.sendMessageToServer({
1847
+ type: REMOVE_VP,
1848
+ viewPortId: serverViewportId
1849
+ });
1850
+ } else {
1851
+ error3(
1852
+ \`failed to unsubscribe client viewport \${clientViewportId}, viewport not found\`
1853
+ );
1854
+ }
1855
+ }
1856
+ getViewportForClient(clientViewportId, throws = true) {
1857
+ const serverViewportId = this.mapClientToServerViewport.get(clientViewportId);
1858
+ if (serverViewportId) {
1859
+ const viewport = this.viewports.get(serverViewportId);
1860
+ if (viewport) {
1861
+ return viewport;
1862
+ } else if (throws) {
1863
+ throw Error(
1864
+ \`Viewport not found for client viewport \${clientViewportId}\`
1865
+ );
1866
+ } else {
1867
+ return null;
1868
+ }
1869
+ } else if (this.viewports.has(clientViewportId)) {
1870
+ return this.viewports.get(clientViewportId);
1871
+ } else if (throws) {
1872
+ throw Error(
1873
+ \`Viewport server id not found for client viewport \${clientViewportId}\`
1874
+ );
1875
+ } else {
1876
+ return null;
1877
+ }
1878
+ }
1879
+ /**********************************************************************/
1880
+ /* Handle messages from client */
1881
+ /**********************************************************************/
1882
+ setViewRange(viewport, message) {
1883
+ const requestId = nextRequestId();
1884
+ const [serverRequest, rows, debounceRequest] = viewport.rangeRequest(
1885
+ requestId,
1886
+ message.range
1887
+ );
1888
+ info3 == null ? void 0 : info3(\`setViewRange \${message.range.from} - \${message.range.to}\`);
1889
+ if (serverRequest) {
1890
+ if (true) {
1891
+ info3 == null ? void 0 : info3(
1892
+ \`CHANGE_VP_RANGE [\${message.range.from}-\${message.range.to}] => [\${serverRequest.from}-\${serverRequest.to}]\`
1893
+ );
1894
+ }
1895
+ const sentToServer = this.sendIfReady(
1896
+ serverRequest,
1897
+ requestId,
1898
+ viewport.status === "subscribed"
1899
+ );
1900
+ if (!sentToServer) {
1901
+ this.queuedRequests.push({
1902
+ clientViewportId: message.viewport,
1903
+ message: serverRequest,
1904
+ requestId
1905
+ });
1906
+ }
1907
+ }
1908
+ if (rows) {
1909
+ info3 == null ? void 0 : info3(\`setViewRange \${rows.length} rows returned from cache\`);
1910
+ this.postMessageToClient({
1911
+ mode: "batch",
1912
+ type: "viewport-update",
1913
+ clientViewportId: viewport.clientViewportId,
1914
+ rows
1915
+ });
1916
+ } else if (debounceRequest) {
1917
+ this.postMessageToClient(debounceRequest);
1918
+ }
1919
+ }
1920
+ setConfig(viewport, message) {
1921
+ const requestId = nextRequestId();
1922
+ const request = viewport.setConfig(requestId, message.config);
1923
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1924
+ }
1925
+ aggregate(viewport, message) {
1926
+ const requestId = nextRequestId();
1927
+ const request = viewport.aggregateRequest(requestId, message.aggregations);
1928
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1929
+ }
1930
+ sort(viewport, message) {
1931
+ const requestId = nextRequestId();
1932
+ const request = viewport.sortRequest(requestId, message.sort);
1933
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1934
+ }
1935
+ groupBy(viewport, message) {
1936
+ const requestId = nextRequestId();
1937
+ const request = viewport.groupByRequest(requestId, message.groupBy);
1938
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1939
+ }
1940
+ filter(viewport, message) {
1941
+ const requestId = nextRequestId();
1942
+ const { filter } = message;
1943
+ const request = viewport.filterRequest(requestId, filter);
1944
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1945
+ }
1946
+ setColumns(viewport, message) {
1947
+ const requestId = nextRequestId();
1948
+ const { columns } = message;
1949
+ const request = viewport.columnRequest(requestId, columns);
1950
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1951
+ }
1952
+ setTitle(viewport, message) {
1953
+ if (viewport) {
1954
+ viewport.title = message.title;
1955
+ this.updateTitleOnVisualLinks(viewport);
1956
+ }
1957
+ }
1958
+ select(viewport, message) {
1959
+ const requestId = nextRequestId();
1960
+ const { selected } = message;
1961
+ const request = viewport.selectRequest(requestId, selected);
1962
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1963
+ }
1964
+ disableViewport(viewport) {
1965
+ const requestId = nextRequestId();
1966
+ const request = viewport.disable(requestId);
1967
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1968
+ }
1969
+ enableViewport(viewport) {
1970
+ if (viewport.disabled) {
1971
+ const requestId = nextRequestId();
1972
+ const request = viewport.enable(requestId);
1973
+ this.sendIfReady(request, requestId, viewport.status === "subscribed");
1974
+ }
1975
+ }
1976
+ suspendViewport(viewport) {
1977
+ viewport.suspend();
1978
+ viewport.suspendTimer = setTimeout(() => {
1979
+ info3 == null ? void 0 : info3("suspendTimer expired, escalate suspend to disable");
1980
+ this.disableViewport(viewport);
1981
+ }, 3e3);
1982
+ }
1983
+ resumeViewport(viewport) {
1984
+ if (viewport.suspendTimer) {
1985
+ debug4 == null ? void 0 : debug4("clear suspend timer");
1986
+ clearTimeout(viewport.suspendTimer);
1987
+ viewport.suspendTimer = null;
1988
+ }
1989
+ const [size, rows] = viewport.resume();
1990
+ debug4 == null ? void 0 : debug4(\`resumeViewport size \${size}, \${rows.length} rows sent to client\`);
1991
+ this.postMessageToClient({
1992
+ clientViewportId: viewport.clientViewportId,
1993
+ mode: "batch",
1994
+ rows,
1995
+ size,
1996
+ type: "viewport-update"
1997
+ });
1998
+ }
1999
+ openTreeNode(viewport, message) {
2000
+ if (viewport.serverViewportId) {
2001
+ const requestId = nextRequestId();
2002
+ this.sendIfReady(
2003
+ viewport.openTreeNode(requestId, message),
2004
+ requestId,
2005
+ viewport.status === "subscribed"
2006
+ );
2007
+ }
2008
+ }
2009
+ closeTreeNode(viewport, message) {
2010
+ if (viewport.serverViewportId) {
2011
+ const requestId = nextRequestId();
2012
+ this.sendIfReady(
2013
+ viewport.closeTreeNode(requestId, message),
2014
+ requestId,
2015
+ viewport.status === "subscribed"
2016
+ );
2017
+ }
2018
+ }
2019
+ createLink(viewport, message) {
2020
+ const { parentClientVpId, parentColumnName, childColumnName } = message;
2021
+ const requestId = nextRequestId();
2022
+ const parentVpId = this.mapClientToServerViewport.get(parentClientVpId);
2023
+ if (parentVpId) {
2024
+ const request = viewport.createLink(
2025
+ requestId,
2026
+ childColumnName,
2027
+ parentVpId,
2028
+ parentColumnName
2029
+ );
2030
+ this.sendMessageToServer(request, requestId);
2031
+ } else {
2032
+ error3("ServerProxy unable to create link, viewport not found");
2033
+ }
2034
+ }
2035
+ removeLink(viewport) {
2036
+ const requestId = nextRequestId();
2037
+ const request = viewport.removeLink(requestId);
2038
+ this.sendMessageToServer(request, requestId);
2039
+ }
2040
+ updateTitleOnVisualLinks(viewport) {
2041
+ var _a;
2042
+ const { serverViewportId, title } = viewport;
2043
+ for (const vp of this.viewports.values()) {
2044
+ if (vp !== viewport && vp.links && serverViewportId && title) {
2045
+ if ((_a = vp.links) == null ? void 0 : _a.some((link) => link.parentVpId === serverViewportId)) {
2046
+ const [messageToClient] = vp.setLinks(
2047
+ addTitleToLinks(vp.links, serverViewportId, title)
2048
+ );
2049
+ this.postMessageToClient(messageToClient);
2050
+ }
2051
+ }
2052
+ }
2053
+ }
2054
+ removeViewportFromVisualLinks(serverViewportId) {
2055
+ var _a;
2056
+ for (const vp of this.viewports.values()) {
2057
+ if ((_a = vp.links) == null ? void 0 : _a.some(({ parentVpId }) => parentVpId === serverViewportId)) {
2058
+ const [messageToClient] = vp.setLinks(
2059
+ vp.links.filter(({ parentVpId }) => parentVpId !== serverViewportId)
2060
+ );
2061
+ this.postMessageToClient(messageToClient);
2062
+ }
2063
+ }
2064
+ }
2065
+ menuRpcCall(message) {
2066
+ const viewport = this.getViewportForClient(message.vpId, false);
2067
+ if (viewport == null ? void 0 : viewport.serverViewportId) {
2068
+ const [requestId, rpcRequest] = stripRequestId(message);
2069
+ this.sendMessageToServer(
2070
+ {
2071
+ ...rpcRequest,
2072
+ vpId: viewport.serverViewportId
2073
+ },
2074
+ requestId
2075
+ );
2076
+ }
2077
+ }
2078
+ viewportRpcCall(message) {
2079
+ const viewport = this.getViewportForClient(message.vpId, false);
2080
+ if (viewport == null ? void 0 : viewport.serverViewportId) {
2081
+ const [requestId, rpcRequest] = stripRequestId(message);
2082
+ this.sendMessageToServer(
2083
+ {
2084
+ ...rpcRequest,
2085
+ vpId: viewport.serverViewportId,
2086
+ namedParams: {}
2087
+ },
2088
+ requestId
2089
+ );
2090
+ }
2091
+ }
2092
+ rpcCall(message) {
2093
+ const [requestId, rpcRequest] = stripRequestId(message);
2094
+ const module = getRpcServiceModule(rpcRequest.service);
2095
+ this.sendMessageToServer(rpcRequest, requestId, { module });
2096
+ }
2097
+ handleMessageFromClient(message) {
2098
+ var _a;
2099
+ if (isViewporttMessage(message)) {
2100
+ if (message.type === "disable") {
2101
+ const viewport = this.getViewportForClient(message.viewport, false);
2102
+ if (viewport !== null) {
2103
+ return this.disableViewport(viewport);
2104
+ } else {
2105
+ return;
2106
+ }
2107
+ } else {
2108
+ const viewport = this.getViewportForClient(message.viewport);
2109
+ switch (message.type) {
2110
+ case "setViewRange":
2111
+ return this.setViewRange(viewport, message);
2112
+ case "config":
2113
+ return this.setConfig(viewport, message);
2114
+ case "aggregate":
2115
+ return this.aggregate(viewport, message);
2116
+ case "sort":
2117
+ return this.sort(viewport, message);
2118
+ case "groupBy":
2119
+ return this.groupBy(viewport, message);
2120
+ case "filter":
2121
+ return this.filter(viewport, message);
2122
+ case "select":
2123
+ return this.select(viewport, message);
2124
+ case "suspend":
2125
+ return this.suspendViewport(viewport);
2126
+ case "resume":
2127
+ return this.resumeViewport(viewport);
2128
+ case "enable":
2129
+ return this.enableViewport(viewport);
2130
+ case "openTreeNode":
2131
+ return this.openTreeNode(viewport, message);
2132
+ case "closeTreeNode":
2133
+ return this.closeTreeNode(viewport, message);
2134
+ case "createLink":
2135
+ return this.createLink(viewport, message);
2136
+ case "removeLink":
2137
+ return this.removeLink(viewport);
2138
+ case "setColumns":
2139
+ return this.setColumns(viewport, message);
2140
+ case "setTitle":
2141
+ return this.setTitle(viewport, message);
2142
+ default:
2143
+ }
2144
+ }
2145
+ } else if (isVuuRpcRequest(message)) {
2146
+ return this.viewportRpcCall(message);
2147
+ } else if (isVuuMenuRpcRequest(message)) {
2148
+ return this.menuRpcCall(message);
2149
+ } else {
2150
+ const { type, requestId } = message;
2151
+ switch (type) {
2152
+ case "GET_TABLE_LIST": {
2153
+ (_a = this.tableList) != null ? _a : this.tableList = this.awaitResponseToMessage(
2154
+ { type },
2155
+ requestId
2156
+ );
2157
+ this.tableList.then((response) => {
2158
+ this.postMessageToClient({
2159
+ type: "TABLE_LIST_RESP",
2160
+ tables: response.tables,
2161
+ requestId
2162
+ });
2163
+ });
2164
+ return;
2165
+ }
2166
+ case "GET_TABLE_META": {
2167
+ this.getTableMeta(message.table, requestId).then((tableSchema) => {
2168
+ if (tableSchema) {
2169
+ this.postMessageToClient({
2170
+ type: "TABLE_META_RESP",
2171
+ tableSchema,
2172
+ requestId
2173
+ });
2174
+ }
2175
+ });
2176
+ return;
2177
+ }
2178
+ case "RPC_CALL":
2179
+ return this.rpcCall(message);
2180
+ default:
2181
+ }
2182
+ }
2183
+ error3(
2184
+ \`Vuu ServerProxy Unexpected message from client \${JSON.stringify(
2185
+ message
2186
+ )}\`
2187
+ );
2188
+ }
2189
+ getTableMeta(table, requestId = nextRequestId()) {
2190
+ if (isSessionTable(table)) {
2191
+ return Promise.resolve(void 0);
2192
+ }
2193
+ const key = \`\${table.module}:\${table.table}\`;
2194
+ let tableMetaRequest = this.cachedTableMetaRequests.get(key);
2195
+ if (!tableMetaRequest) {
2196
+ tableMetaRequest = this.awaitResponseToMessage(
2197
+ { type: "GET_TABLE_META", table },
2198
+ requestId
2199
+ );
2200
+ this.cachedTableMetaRequests.set(key, tableMetaRequest);
2201
+ }
2202
+ return tableMetaRequest == null ? void 0 : tableMetaRequest.then((response) => this.cacheTableMeta(response));
2203
+ }
2204
+ awaitResponseToMessage(message, requestId = nextRequestId()) {
2205
+ return new Promise((resolve, reject) => {
2206
+ this.sendMessageToServer(message, requestId);
2207
+ this.pendingRequests.set(requestId, { reject, resolve });
2208
+ });
2209
+ }
2210
+ sendIfReady(message, requestId, isReady = true) {
2211
+ if (isReady) {
2212
+ this.sendMessageToServer(message, requestId);
2213
+ }
2214
+ return isReady;
2215
+ }
2216
+ sendMessageToServer(body, requestId = \`\${_requestId++}\`, options = DEFAULT_OPTIONS) {
2217
+ const { module = "CORE" } = options;
2218
+ if (this.authToken) {
2219
+ this.connection.send({
2220
+ requestId,
2221
+ sessionId: this.sessionId,
2222
+ token: this.authToken,
2223
+ user: this.user,
2224
+ module,
2225
+ body
2226
+ });
2227
+ }
2228
+ }
2229
+ handleMessageFromServer(message) {
2230
+ var _a, _b, _c;
2231
+ const { body, requestId, sessionId } = message;
2232
+ const pendingRequest = this.pendingRequests.get(requestId);
2233
+ if (pendingRequest) {
2234
+ const { resolve } = pendingRequest;
2235
+ this.pendingRequests.delete(requestId);
2236
+ resolve(body);
2237
+ return;
2238
+ }
2239
+ const { viewports } = this;
2240
+ switch (body.type) {
2241
+ case HB:
2242
+ this.sendMessageToServer(
2243
+ { type: HB_RESP, ts: +/* @__PURE__ */ new Date() },
2244
+ "NA"
2245
+ );
2246
+ break;
2247
+ case "LOGIN_SUCCESS":
2248
+ if (sessionId) {
2249
+ this.sessionId = sessionId;
2250
+ (_a = this.pendingLogin) == null ? void 0 : _a.resolve(sessionId);
2251
+ this.pendingLogin = void 0;
2252
+ } else {
2253
+ throw Error("LOGIN_SUCCESS did not provide sessionId");
2254
+ }
2255
+ break;
2256
+ case "REMOVE_VP_SUCCESS":
2257
+ {
2258
+ const viewport = viewports.get(body.viewPortId);
2259
+ if (viewport) {
2260
+ this.mapClientToServerViewport.delete(viewport.clientViewportId);
2261
+ viewports.delete(body.viewPortId);
2262
+ this.removeViewportFromVisualLinks(body.viewPortId);
2263
+ }
2264
+ }
2265
+ break;
2266
+ case SET_SELECTION_SUCCESS:
2267
+ {
2268
+ const viewport = this.viewports.get(body.vpId);
2269
+ if (viewport) {
2270
+ viewport.completeOperation(requestId);
2271
+ }
2272
+ }
2273
+ break;
2274
+ case CHANGE_VP_SUCCESS:
2275
+ case DISABLE_VP_SUCCESS:
2276
+ if (viewports.has(body.viewPortId)) {
2277
+ const viewport = this.viewports.get(body.viewPortId);
2278
+ if (viewport) {
2279
+ const response = viewport.completeOperation(requestId);
2280
+ if (response !== void 0) {
2281
+ this.postMessageToClient(response);
2282
+ if (debugEnabled4) {
2283
+ debug4(\`postMessageToClient \${JSON.stringify(response)}\`);
2284
+ }
2285
+ }
2286
+ }
2287
+ }
2288
+ break;
2289
+ case ENABLE_VP_SUCCESS:
2290
+ {
2291
+ const viewport = this.viewports.get(body.viewPortId);
2292
+ if (viewport) {
2293
+ const response = viewport.completeOperation(requestId);
2294
+ if (response) {
2295
+ this.postMessageToClient(response);
2296
+ const [size, rows] = viewport.resume();
2297
+ this.postMessageToClient({
2298
+ clientViewportId: viewport.clientViewportId,
2299
+ mode: "batch",
2300
+ rows,
2301
+ size,
2302
+ type: "viewport-update"
2303
+ });
2304
+ }
2305
+ }
2306
+ }
2307
+ break;
2308
+ case "TABLE_ROW":
2309
+ {
2310
+ const viewportRowMap = groupRowsByViewport(body.rows);
2311
+ if (debugEnabled4) {
2312
+ const [firstRow, secondRow] = body.rows;
2313
+ if (body.rows.length === 0) {
2314
+ debug4("handleMessageFromServer TABLE_ROW 0 rows");
2315
+ } else if ((firstRow == null ? void 0 : firstRow.rowIndex) === -1) {
2316
+ if (body.rows.length === 1) {
2317
+ if (firstRow.updateType === "SIZE") {
2318
+ debug4(
2319
+ \`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE ONLY \${firstRow.vpSize}\`
2320
+ );
2321
+ } else {
2322
+ debug4(
2323
+ \`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE \${firstRow.vpSize} rowIdx \${firstRow.rowIndex}\`
2324
+ );
2325
+ }
2326
+ } else {
2327
+ debug4(
2328
+ \`handleMessageFromServer TABLE_ROW \${body.rows.length} rows, SIZE \${firstRow.vpSize}, [\${secondRow == null ? void 0 : secondRow.rowIndex}] - [\${(_b = body.rows[body.rows.length - 1]) == null ? void 0 : _b.rowIndex}]\`
2329
+ );
2330
+ }
2331
+ } else {
2332
+ debug4(
2333
+ \`handleMessageFromServer TABLE_ROW \${body.rows.length} rows [\${firstRow == null ? void 0 : firstRow.rowIndex}] - [\${(_c = body.rows[body.rows.length - 1]) == null ? void 0 : _c.rowIndex}]\`
2334
+ );
2335
+ }
2336
+ }
2337
+ for (const [viewportId, rows] of Object.entries(viewportRowMap)) {
2338
+ const viewport = viewports.get(viewportId);
2339
+ if (viewport) {
2340
+ viewport.updateRows(rows);
2341
+ } else {
2342
+ warn3 == null ? void 0 : warn3(
2343
+ \`TABLE_ROW message received for non registered viewport \${viewportId}\`
2344
+ );
2345
+ }
2346
+ }
2347
+ this.processUpdates();
2348
+ }
2349
+ break;
2350
+ case "CHANGE_VP_RANGE_SUCCESS":
2351
+ {
2352
+ const viewport = this.viewports.get(body.viewPortId);
2353
+ if (viewport) {
2354
+ const { from, to } = body;
2355
+ if (true) {
2356
+ info3 == null ? void 0 : info3(\`CHANGE_VP_RANGE_SUCCESS \${from} - \${to}\`);
2357
+ }
2358
+ viewport.completeOperation(requestId, from, to);
2359
+ }
2360
+ }
2361
+ break;
2362
+ case OPEN_TREE_SUCCESS:
2363
+ case CLOSE_TREE_SUCCESS:
2364
+ break;
2365
+ case "CREATE_VISUAL_LINK_SUCCESS":
2366
+ {
2367
+ const viewport = this.viewports.get(body.childVpId);
2368
+ const parentViewport = this.viewports.get(body.parentVpId);
2369
+ if (viewport && parentViewport) {
2370
+ const { childColumnName, parentColumnName } = body;
2371
+ const response = viewport.completeOperation(
2372
+ requestId,
2373
+ childColumnName,
2374
+ parentViewport.clientViewportId,
2375
+ parentColumnName
2376
+ );
2377
+ if (response) {
2378
+ this.postMessageToClient(response);
2379
+ }
2380
+ }
2381
+ }
2382
+ break;
2383
+ case "REMOVE_VISUAL_LINK_SUCCESS":
2384
+ {
2385
+ const viewport = this.viewports.get(body.childVpId);
2386
+ if (viewport) {
2387
+ const response = viewport.completeOperation(
2388
+ requestId
2389
+ );
2390
+ if (response) {
2391
+ this.postMessageToClient(response);
2392
+ }
2393
+ }
2394
+ }
2395
+ break;
2396
+ case "VP_VISUAL_LINKS_RESP":
2397
+ {
2398
+ const activeLinkDescriptors = this.getActiveLinks(body.links);
2399
+ const viewport = this.viewports.get(body.vpId);
2400
+ if (activeLinkDescriptors.length && viewport) {
2401
+ const linkDescriptorsWithLabels = addLabelsToLinks(
2402
+ activeLinkDescriptors,
2403
+ this.viewports
2404
+ );
2405
+ const [clientMessage, pendingLink] = viewport.setLinks(
2406
+ linkDescriptorsWithLabels
2407
+ );
2408
+ this.postMessageToClient(clientMessage);
2409
+ if (pendingLink) {
2410
+ const { link, parentClientVpId } = pendingLink;
2411
+ const requestId2 = nextRequestId();
2412
+ const serverViewportId = this.mapClientToServerViewport.get(parentClientVpId);
2413
+ if (serverViewportId) {
2414
+ const message2 = viewport.createLink(
2415
+ requestId2,
2416
+ link.fromColumn,
2417
+ serverViewportId,
2418
+ link.toColumn
2419
+ );
2420
+ this.sendMessageToServer(message2, requestId2);
2421
+ }
2422
+ }
2423
+ }
2424
+ }
2425
+ break;
2426
+ case "VIEW_PORT_MENUS_RESP":
2427
+ if (body.menu.name) {
2428
+ const viewport = this.viewports.get(body.vpId);
2429
+ if (viewport) {
2430
+ const clientMessage = viewport.setMenu(body.menu);
2431
+ this.postMessageToClient(clientMessage);
2432
+ }
2433
+ }
2434
+ break;
2435
+ case "VP_EDIT_RPC_RESPONSE":
2436
+ {
2437
+ this.postMessageToClient({
2438
+ action: body.action,
2439
+ requestId,
2440
+ rpcName: body.rpcName,
2441
+ type: "VP_EDIT_RPC_RESPONSE"
2442
+ });
2443
+ }
2444
+ break;
2445
+ case "VP_EDIT_RPC_REJECT":
2446
+ {
2447
+ const viewport = this.viewports.get(body.vpId);
2448
+ if (viewport) {
2449
+ this.postMessageToClient({
2450
+ requestId,
2451
+ type: "VP_EDIT_RPC_REJECT",
2452
+ error: body.error
2453
+ });
2454
+ }
2455
+ }
2456
+ break;
2457
+ case "VIEW_PORT_MENU_REJ": {
2458
+ console.log(\`send menu error back to client\`);
2459
+ const { error: error4, rpcName, vpId } = body;
2460
+ const viewport = this.viewports.get(vpId);
2461
+ if (viewport) {
2462
+ this.postMessageToClient({
2463
+ clientViewportId: viewport.clientViewportId,
2464
+ error: error4,
2465
+ rpcName,
2466
+ type: "VIEW_PORT_MENU_REJ",
2467
+ requestId
2468
+ });
2469
+ }
2470
+ break;
2471
+ }
2472
+ case "VIEW_PORT_MENU_RESP":
2473
+ {
2474
+ if (isSessionTableActionMessage(body)) {
2475
+ const { action, rpcName } = body;
2476
+ this.awaitResponseToMessage({
2477
+ type: "GET_TABLE_META",
2478
+ table: action.table
2479
+ }).then((response) => {
2480
+ const tableSchema = createSchemaFromTableMetadata(
2481
+ response
2482
+ );
2483
+ this.postMessageToClient({
2484
+ rpcName,
2485
+ type: "VIEW_PORT_MENU_RESP",
2486
+ action: {
2487
+ ...action,
2488
+ tableSchema
2489
+ },
2490
+ tableAlreadyOpen: this.isTableOpen(action.table),
2491
+ requestId
2492
+ });
2493
+ });
2494
+ } else {
2495
+ const { action } = body;
2496
+ this.postMessageToClient({
2497
+ type: "VIEW_PORT_MENU_RESP",
2498
+ action: action || NO_ACTION,
2499
+ tableAlreadyOpen: action !== null && this.isTableOpen(action.table),
2500
+ requestId
2501
+ });
2502
+ }
2503
+ }
2504
+ break;
2505
+ case "RPC_RESP":
2506
+ {
2507
+ const { method, result } = body;
2508
+ this.postMessageToClient({
2509
+ type: "RPC_RESP",
2510
+ method,
2511
+ result,
2512
+ requestId
2513
+ });
2514
+ }
2515
+ break;
2516
+ case "VIEW_PORT_RPC_REPONSE":
2517
+ {
2518
+ const { method, action } = body;
2519
+ this.postMessageToClient({
2520
+ type: "VIEW_PORT_RPC_RESPONSE",
2521
+ rpcName: method,
2522
+ action,
2523
+ requestId
2524
+ });
2525
+ }
2526
+ break;
2527
+ case "ERROR":
2528
+ error3(body.msg);
2529
+ break;
2530
+ default:
2531
+ infoEnabled3 && info3(\`handleMessageFromServer \${body["type"]}.\`);
2532
+ }
2533
+ }
2534
+ cacheTableMeta(messageBody) {
2535
+ const { module, table } = messageBody.table;
2536
+ const key = \`\${module}:\${table}\`;
2537
+ let tableSchema = this.cachedTableSchemas.get(key);
2538
+ if (!tableSchema) {
2539
+ tableSchema = createSchemaFromTableMetadata(messageBody);
2540
+ this.cachedTableSchemas.set(key, tableSchema);
2541
+ }
2542
+ return tableSchema;
2543
+ }
2544
+ isTableOpen(table) {
2545
+ if (table) {
2546
+ const tableName = table.table;
2547
+ for (const viewport of this.viewports.values()) {
2548
+ if (!viewport.suspended && viewport.table.table === tableName) {
2549
+ return true;
2550
+ }
2551
+ }
2552
+ }
2553
+ }
2554
+ // Eliminate links to suspended viewports
2555
+ getActiveLinks(linkDescriptors) {
2556
+ return linkDescriptors.filter((linkDescriptor) => {
2557
+ const viewport = this.viewports.get(linkDescriptor.parentVpId);
2558
+ return viewport && !viewport.suspended;
2559
+ });
2560
+ }
2561
+ processUpdates() {
2562
+ this.viewports.forEach((viewport) => {
2563
+ var _a;
2564
+ if (viewport.hasUpdatesToProcess) {
2565
+ const result = viewport.getClientRows();
2566
+ if (result !== NO_DATA_UPDATE) {
2567
+ const [rows, mode] = result;
2568
+ const size = viewport.getNewRowCount();
2569
+ if (size !== void 0 || rows && rows.length > 0) {
2570
+ debugEnabled4 && debug4(
2571
+ \`postMessageToClient #\${viewport.clientViewportId} viewport-update \${mode}, \${(_a = rows == null ? void 0 : rows.length) != null ? _a : "no"} rows, size \${size}\`
2572
+ );
2573
+ if (mode) {
2574
+ this.postMessageToClient({
2575
+ clientViewportId: viewport.clientViewportId,
2576
+ mode,
2577
+ rows,
2578
+ size,
2579
+ type: "viewport-update"
2580
+ });
2581
+ }
2582
+ }
2583
+ }
2584
+ }
2585
+ });
2586
+ }
2587
+ };
2588
+
2589
+ // src/worker.ts
2590
+ var server;
2591
+ var { info: info4, infoEnabled: infoEnabled4 } = logger("worker");
2592
+ async function connectToServer(url, protocol, token, username, onConnectionStatusChange, retryLimitDisconnect, retryLimitStartup) {
2593
+ const connection = await connect(
2594
+ url,
2595
+ protocol,
2596
+ // if this was called during connect, we would get a ReferenceError, but it will
2597
+ // never be called until subscriptions have been made, so this is safe.
2598
+ //TODO do we need to listen in to the connection messages here so we can lock back in, in the event of a reconnenct ?
2599
+ (msg) => {
2600
+ if (isConnectionQualityMetrics(msg)) {
2601
+ postMessage({ type: "connection-metrics", messages: msg });
2602
+ } else if (isConnectionStatusMessage(msg)) {
2603
+ onConnectionStatusChange(msg);
2604
+ if (msg.status === "reconnected") {
2605
+ server.reconnect();
2606
+ }
2607
+ } else {
2608
+ server.handleMessageFromServer(msg);
2609
+ }
2610
+ },
2611
+ retryLimitDisconnect,
2612
+ retryLimitStartup
2613
+ );
2614
+ server = new ServerProxy(connection, (msg) => sendMessageToClient(msg));
2615
+ if (connection.requiresLogin) {
2616
+ await server.login(token, username);
2617
+ }
2618
+ }
2619
+ function sendMessageToClient(message) {
2620
+ postMessage(message);
2621
+ }
2622
+ var handleMessageFromClient = async ({
2623
+ data: message
2624
+ }) => {
2625
+ switch (message.type) {
2626
+ case "connect":
2627
+ await connectToServer(
2628
+ message.url,
2629
+ message.protocol,
2630
+ message.token,
2631
+ message.username,
2632
+ postMessage,
2633
+ message.retryLimitDisconnect,
2634
+ message.retryLimitStartup
2635
+ );
2636
+ postMessage({ type: "connected" });
2637
+ break;
2638
+ case "subscribe":
2639
+ infoEnabled4 && info4(\`client subscribe: \${JSON.stringify(message)}\`);
2640
+ server.subscribe(message);
2641
+ break;
2642
+ case "unsubscribe":
2643
+ infoEnabled4 && info4(\`client unsubscribe: \${JSON.stringify(message)}\`);
2644
+ server.unsubscribe(message.viewport);
2645
+ break;
2646
+ default:
2647
+ infoEnabled4 && info4(\`client message: \${JSON.stringify(message)}\`);
2648
+ server.handleMessageFromClient(message);
2649
+ }
2650
+ };
2651
+ self.addEventListener("message", handleMessageFromClient);
2652
+ postMessage({ type: "ready" });
2653
+
2654
+ `;var Ui=new Blob([is()+Ds],{type:"text/javascript"}),Gi=URL.createObjectURL(Ui),He,hr,fr=[],qi,Wi,Hi=new Promise((s,e)=>{qi=s,Wi=e}),Es=()=>Hi,pt=new Map,xt=new Map,$i=async({handleConnectionStatusChange:s,protocol:e,retryLimitDisconnect:t,retryLimitStartup:r,token:n="",username:i,url:o})=>n===""&&hr===void 0?new Promise(a=>{fr.push({resolve:a})}):hr||(hr=new Promise(a=>{let u=new Worker(Gi),c=window.setTimeout(()=>{console.error("timed out waiting for worker to load")},1e3);u.onmessage=p=>{let{data:d}=p;if(d.type==="ready")window.clearTimeout(c),u.postMessage({protocol:e,retryLimitDisconnect:t,retryLimitStartup:r,token:n,type:"connect",url:o,username:i});else if(d.type==="connected"){u.onmessage=Ms,a(u);for(let f of fr)f.resolve(u);fr.length=0}else dr(d)?s({data:d}):console.warn("ConnectionManager: Unexpected message from the worker")}}));function Ms({data:s}){if(ys(s)){let e=pt.get(s.clientViewportId);e?e.postMessageToClientDataSource(s):console.error(`[ConnectionManager] ${s.type} message received, viewport not found`)}else if(dr(s))xs.emit("connection-status",s);else if(Ss(s))xs.emit("connection-metrics",s);else{let e=s.requestId;if(xt.has(e)){let{resolve:t}=xt.get(e);xt.delete(e);let{type:r,requestId:n,...i}=s;vs(s)?t(s.result):s.type==="VP_EDIT_RPC_RESPONSE"||s.type==="VP_EDIT_RPC_REJECT"?t(s):Rs(s)?t(s.tableSchema):t(i)}else console.warn("%cConnectionManager Unexpected message from the worker","color:red;font-weight:bold;")}}var mr=s=>{let e=ue();return He.postMessage({requestId:e,...s}),new Promise((t,r)=>{xt.set(e,{resolve:t,reject:r})})},Ki={subscribe:(s,e)=>{if(pt.get(s.viewport))throw Error("ConnectionManager attempting to subscribe with an existing viewport id");pt.set(s.viewport,{status:"subscribing",request:s,postMessageToClientDataSource:e}),He.postMessage({type:"subscribe",...s})},unsubscribe:s=>{He.postMessage({type:"unsubscribe",viewport:s})},send:s=>{He.postMessage(s)},destroy:s=>{s&&pt.has(s)&&pt.delete(s)},rpcCall:async s=>mr(s),getTableList:async()=>mr({type:"GET_TABLE_LIST"}),getTableSchema:async s=>mr({type:Cs,table:s})},gr=class extends te{async connect({url:e,authToken:t,username:r,protocol:n,retryLimitDisconnect:i,retryLimitStartup:o}){return He=await $i({protocol:n,url:e,token:t,username:r,retryLimitDisconnect:i,retryLimitStartup:o,handleConnectionStatusChange:Ms}),Ki}destroy(){He.terminate()}},xs=new gr;var zi=0,dt=class{constructor(e,t){this.from=e,this.to=t}},M=class{constructor(e={}){this.id=zi++,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=Y.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}};M.closedBy=new M({deserialize:s=>s.split(" ")});M.openedBy=new M({deserialize:s=>s.split(" ")});M.group=new M({deserialize:s=>s.split(" ")});M.contextHash=new M({perNode:!0});M.lookAhead=new M({perNode:!0});M.mounted=new M({perNode:!0});var ji=Object.create(null),Y=class{constructor(e,t,r,n=0){this.name=e,this.props=t,this.id=r,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):ji,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new Y(e.name||"",t,e.id,r);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}}return n}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(M.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return r=>{for(let n=r.prop(M.group),i=-1;i<(n?n.length:0);i++){let o=t[i<0?r.name:n[i]];if(o)return o}}}};Y.none=new Y("",Object.create(null),0,8);var $e=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 r of this.types){let n=null;for(let i of e){let o=i(r);o&&(n||(n=Object.assign({},r.props)),n[o[0].id]=o[1])}t.push(n?new Y(r.name,n,r.id,r.flags):r)}return new $e(t)}},Et=new WeakMap,ks=new WeakMap,G;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays"})(G||(G={}));var W=class{constructor(e,t,r,n,i){if(this.type=e,this.children=t,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[o,a]of i)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=this.prop(M.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let n=r.toString();n&&(t&&(t+=","),t+=n)}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 ze(this.topNode,e)}cursorAt(e,t=0,r=0){let n=Et.get(this)||this.topNode,i=new ze(n);return i.moveTo(e,t),Et.set(this,i._tree),i}get topNode(){return new oe(this,0,0,null)}resolve(e,t=0){let r=Ke(Et.get(this)||this.topNode,e,t,!1);return Et.set(this,r),r}resolveInner(e,t=0){let r=Ke(ks.get(this)||this.topNode,e,t,!0);return ks.set(this,r),r}iterate(e){let{enter:t,leave:r,from:n=0,to:i=this.length}=e,o=e.mode||0,a=(o&G.IncludeAnonymous)>0;for(let u=this.cursor(o|G.IncludeAnonymous);;){let c=!1;if(u.from<=i&&u.to>=n&&(!a&&u.type.isAnonymous||t(u)!==!1)){if(u.firstChild())continue;c=!0}for(;c&&r&&(a||!u.type.isAnonymous)&&r(u),!u.nextSibling();){if(!u.parent())return;c=!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:Cr(Y.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,n)=>new W(this.type,t,r,n,this.propValues),e.makeTree||((t,r,n)=>new W(Y.none,t,r,n)))}static build(e){return Qi(e)}};W.empty=new W(Y.none,[],[],0);var ht=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 ht(this.buffer,this.index)}},fe=class{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return Y.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],r=this.buffer[e+3],n=this.set.types[t],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),e+=4,r==e)return i;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,r,n,i){let{buffer:o}=this,a=-1;for(let u=e;u!=t&&!(Vs(i,n,o[u+1],o[u+2])&&(a=u,r>0));u=o[u+3]);return a}slice(e,t,r){let n=this.buffer,i=new Uint16Array(t-e),o=0;for(let a=e,u=0;a<t;){i[u++]=n[a++],i[u++]=n[a++]-r;let c=i[u++]=n[a++]-r;i[u++]=n[a++]-e,o=Math.max(o,c)}return new fe(i,o,this.set)}};function Vs(s,e,t,r){switch(s){case-2:return t<e;case-1:return r>=e&&t<e;case 0:return t<e&&r>e;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function _s(s,e){let t=s.childBefore(e);for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(s=t,t=r.prevSibling):t=r}return s}function Ke(s,e,t,r){for(var n;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to<e);){let o=!r&&s instanceof oe&&s.index<0?null:s.parent;if(!o)return s;s=o}let i=r?0:G.IgnoreOverlays;if(r)for(let o=s,a=o.parent;a;o=a,a=o.parent)o instanceof oe&&o.index<0&&((n=a.enter(e,t,i))===null||n===void 0?void 0:n.from)!=o.from&&(s=a);for(;;){let o=s.enter(e,t,i);if(!o)return s;s=o}}var oe=class{constructor(e,t,r,n){this._tree=e,this.from=t,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,n,i=0){for(let o=this;;){for(let{children:a,positions:u}=o._tree,c=t>0?a.length:-1;e!=c;e+=t){let p=a[e],d=u[e]+o.from;if(Vs(n,r,d,d+p.length)){if(p instanceof fe){if(i&G.ExcludeBuffers)continue;let f=p.findChild(0,p.buffer.length,t,r-d,n);if(f>-1)return new le(new br(o,p,e,d),null,f)}else if(i&G.IncludeAnonymous||!p.type.isAnonymous||wr(p)){let f;if(!(i&G.IgnoreMounts)&&p.props&&(f=p.prop(M.mounted))&&!f.overlay)return new oe(f.tree,d,e,o);let m=new oe(p,d,e,o);return i&G.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(t<0?p.children.length-1:0,t,r,n)}}}if(i&G.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))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,r=0){let n;if(!(r&G.IgnoreOverlays)&&(n=this._tree.prop(M.mounted))&&n.overlay){let i=e-this.from;for(let{from:o,to:a}of n.overlay)if((t>0?o<=i:o<i)&&(t<0?a>=i:a>i))return new oe(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}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 ze(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return Ke(this,e,t,!1)}resolveInner(e,t=0){return Ke(this,e,t,!0)}enterUnfinishedNodesBefore(e){return _s(this,e)}getChild(e,t=null,r=null){let n=kt(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return kt(this,e,t,r)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Pt(this,e)}};function kt(s,e,t,r){let n=s.cursor(),i=[];if(!n.firstChild())return i;if(t!=null){for(;!n.type.is(t);)if(!n.nextSibling())return i}for(;;){if(r!=null&&n.type.is(r))return i;if(n.type.is(e)&&i.push(n.node),!n.nextSibling())return r==null?i:[]}}function Pt(s,e,t=e.length-1){for(let r=s.parent;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}var br=class{constructor(e,t,r,n){this.parent=e,this.buffer=t,this.index=r,this.start=n}},le=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,r){this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return i<0?null:new le(this.context,this,i)}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,r=0){if(r&G.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new le(this.context,this,i)}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 le(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 le(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new ze(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let o=r.buffer[this.index+1];e.push(r.slice(n,i,o)),t.push(0)}return new W(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Ke(this,e,t,!1)}resolveInner(e,t=0){return Ke(this,e,t,!0)}enterUnfinishedNodesBefore(e){return _s(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,r=null){let n=kt(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return kt(this,e,t,r)}get node(){return this}matchContext(e){return Pt(this,e)}},ze=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 oe)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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:r,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=r+n.buffer[e+1],this.to=r+n.buffer[e+2],!0}yield(e){return e?e instanceof oe?(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,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}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,r=this.mode){return this.buffer?r&G.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&G.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&G.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,r=this.stack.length-1;if(e<0){let n=r<0?0:this.stack[r]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(n)}return r<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,r,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(n.buffer.buffer[i+3]<this.index)return!1;({index:t,parent:r}=n)}else({index:t,_parent:r}=this._tree);for(;r;{index:t,_parent:r}=r)if(t>-1)for(let i=t+e,o=e<0?-1:r._tree.children.length;i!=o;i+=e){let a=r._tree.children[i];if(this.mode&G.IncludeAnonymous||a instanceof fe||!a.type.isAnonymous||wr(a))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,r=0;if(e&&e.context==this.buffer)e:for(let n=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,r=i+1;break e}n=this.stack[--i]}for(let n=r;n<this.stack.length;n++)t=new le(this.buffer,t,this.stack[n]);return this.bufferNode=new le(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;n&&t&&t(this),n=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,n=!0}}}matchContext(e){if(!this.buffer)return Pt(this.node,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let n=e.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return Pt(this.node,e,n);let o=r[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}};function wr(s){return s.children.some(e=>e instanceof fe||!e.type.isAnonymous||wr(e))}function Qi(s){var e;let{buffer:t,nodeSet:r,maxBufferLength:n=1024,reused:i=[],minRepeatType:o=r.types.length}=s,a=Array.isArray(t)?new ht(t,t.length):t,u=r.types,c=0,p=0;function d(T,_,w,D,q){let{id:x,start:R,end:N,size:X}=a,ne=p;for(;X<0;)if(a.next(),X==-1){let we=i[x];w.push(we),D.push(R-T);return}else if(X==-3){c=x;return}else if(X==-4){p=x;return}else throw new RangeError(`Unrecognized record size: ${X}`);let Be=u[x],ye,pe,Hr=R-T;if(N-R<=n&&(pe=I(a.pos-_,q))){let we=new Uint16Array(pe.size-pe.skip),ie=a.pos-pe.size,de=we.length;for(;a.pos>ie;)de=U(pe.start,we,de);ye=new fe(we,N-pe.start,r),Hr=pe.start-T}else{let we=a.pos-X;a.next();let ie=[],de=[],Me=x>=o?x:-1,Fe=0,vt=N;for(;a.pos>we;)Me>=0&&a.id==Me&&a.size>=0?(a.end<=vt-n&&(m(ie,de,R,Fe,a.end,vt,Me,ne),Fe=ie.length,vt=a.end),a.next()):d(R,we,ie,de,Me);if(Me>=0&&Fe>0&&Fe<ie.length&&m(ie,de,R,Fe,R,vt,Me,ne),ie.reverse(),de.reverse(),Me>-1&&Fe>0){let $r=f(Be);ye=Cr(Be,ie,de,0,ie.length,0,N-R,$r,$r)}else ye=g(Be,ie,de,N-R,ne-N)}w.push(ye),D.push(Hr)}function f(T){return(_,w,D)=>{let q=0,x=_.length-1,R,N;if(x>=0&&(R=_[x])instanceof W){if(!x&&R.type==T&&R.length==D)return R;(N=R.prop(M.lookAhead))&&(q=w[x]+R.length+N)}return g(T,_,w,D,q)}}function m(T,_,w,D,q,x,R,N){let X=[],ne=[];for(;T.length>D;)X.push(T.pop()),ne.push(_.pop()+w-q);T.push(g(r.types[R],X,ne,x-q,N-x)),_.push(q-w)}function g(T,_,w,D,q=0,x){if(c){let R=[M.contextHash,c];x=x?[R].concat(x):[R]}if(q>25){let R=[M.lookAhead,q];x=x?[R].concat(x):[R]}return new W(T,_,w,D,x)}function I(T,_){let w=a.fork(),D=0,q=0,x=0,R=w.end-n,N={size:0,start:0,skip:0};e:for(let X=w.pos-T;w.pos>X;){let ne=w.size;if(w.id==_&&ne>=0){N.size=D,N.start=q,N.skip=x,x+=4,D+=4,w.next();continue}let Be=w.pos-ne;if(ne<0||Be<X||w.start<R)break;let ye=w.id>=o?4:0,pe=w.start;for(w.next();w.pos>Be;){if(w.size<0)if(w.size==-3)ye+=4;else break e;else w.id>=o&&(ye+=4);w.next()}q=pe,D+=ne,x+=ye}return(_<0||D==T)&&(N.size=D,N.start=q,N.skip=x),N.size>4?N:void 0}function U(T,_,w){let{id:D,start:q,end:x,size:R}=a;if(a.next(),R>=0&&D<o){let N=w;if(R>4){let X=a.pos-(R-4);for(;a.pos>X;)w=U(T,_,w)}_[--w]=N,_[--w]=x-T,_[--w]=q-T,_[--w]=D}else R==-3?c=D:R==-4&&(p=D);return w}let V=[],E=[];for(;a.pos>0;)d(s.start||0,s.bufferStart||0,V,E,-1);let v=(e=s.length)!==null&&e!==void 0?e:V.length?E[0]+V[0].length:0;return new W(u[s.topID],V.reverse(),E.reverse(),v)}var Ps=new WeakMap;function Mt(s,e){if(!s.isAnonymous||e instanceof fe||e.type!=s)return 1;let t=Ps.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=s||!(r instanceof W)){t=1;break}t+=Mt(s,r)}Ps.set(e,t)}return t}function Cr(s,e,t,r,n,i,o,a,u){let c=0;for(let g=r;g<n;g++)c+=Mt(s,e[g]);let p=Math.ceil(c*1.5/8),d=[],f=[];function m(g,I,U,V,E){for(let v=U;v<V;){let T=v,_=I[v],w=Mt(s,g[v]);for(v++;v<V;v++){let D=Mt(s,g[v]);if(w+D>=p)break;w+=D}if(v==T+1){if(w>p){let D=g[T];m(D.children,D.positions,0,D.children.length,I[T]+E);continue}d.push(g[T])}else{let D=I[v-1]+g[v-1].length-_;d.push(Cr(s,g,I,T,v,_,D,null,u))}f.push(_+E-i)}}return m(e,t,r,n,0),(a||u)(d,f,o)}var Vt=class{startParse(e,t,r){return typeof e=="string"&&(e=new yr(e)),r=r?r.length?r.map(n=>new dt(n.from,n.to)):[new dt(0,0)]:[new dt(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let i=n.advance();if(i)return i}}},yr=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 Cp=new M({perNode:!0});var Qe=class{constructor(e,t,r,n,i,o,a,u,c,p=0,d){this.p=e,this.stack=t,this.state=r,this.reducePos=n,this.pos=i,this.score=o,this.buffer=a,this.bufferBase=u,this.curContext=c,this.lookAhead=p,this.parent=d}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,r=0){let n=e.parser.context;return new Qe(e,[],t,r,r,0,[],0,n?new _t(n,n.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 r=e>>19,n=e&65535,{parser:i}=this.p,o=i.dynamicPrecedence(n);if(o&&(this.score+=o),r==0){this.pushState(i.getGoto(this.state,n,!0),this.reducePos),n<i.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,4,!0),this.reduceContext(n,this.reducePos);return}let a=this.stack.length-(r-1)*3-(e&262144?6:0),u=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-u;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[n])===null||t===void 0)&&t.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let p=a?this.stack[a-1]:0,d=this.bufferBase+this.buffer.length-p;if(n<i.minRepeatTerm||e&131072){let f=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,u,f,d+4,!0)}if(e&262144)this.state=this.stack[a];else{let f=this.stack[a-3];this.state=i.getGoto(f,n,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(n,u)}storeNode(e,t,r,n=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==r)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=r;return}}}if(!i||this.pos==r)this.buffer.push(e,t,r,n);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,n>4&&(n-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=r,this.buffer[o+3]=n}}shift(e,t,r){let n=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:o}=this.p;(r>this.pos||t<=o.maxNode)&&(this.pos=r,o.stateFlag(i,1)||(this.reducePos=r)),this.pushState(i,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,r){e&65536?this.reduce(e):this.shift(e,t,r)}useNode(e,t){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(r,n,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 r=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new Qe(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,r?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new vr(this);;){let r=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(r==0)return!1;if(!(r&65536))return!0;t.reduce(r)}}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 n=[];for(let i=0,o;i<t.length;i+=2)(o=t[i+1])!=this.state&&this.p.parser.hasAction(o,e)&&n.push(t[i],o);if(this.stack.length<120)for(let i=0;n.length<4<<1&&i<t.length;i+=2){let o=t[i+1];n.some((a,u)=>u&1&&a==o)||n.push(t[i],o)}t=n}let r=[];for(let n=0;n<t.length&&r.length<4;n+=2){let i=t[n+1];if(i==this.state)continue;let o=this.split();o.pushState(i,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[n],this.pos),o.score-=200,r.push(o)}return r}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let r=t>>19,n=t&65535,i=this.stack.length-r*3;if(i<0||e.getGoto(this.stack[i],n,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],r=(n,i)=>{if(!t.includes(n))return t.push(n),e.allActions(n,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-i;if(a>1){let u=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],u,!1)>=0)return a<<19|65536|u}}else{let a=r(o,i+1);if(a!=null)return a}})};return r(this.state,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.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new _t(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()}},_t=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},Ls;(function(s){s[s.Insert=200]="Insert",s[s.Delete=190]="Delete",s[s.Reduce=100]="Reduce",s[s.MaxNext=4]="MaxNext",s[s.MaxInsertStackDepth=300]="MaxInsertStackDepth",s[s.DampenInsertStackDepth=120]="DampenInsertStackDepth",s[s.MinBigReduction=2e3]="MinBigReduction"})(Ls||(Ls={}));var vr=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,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}},Je=class{constructor(e,t,r){this.stack=e,this.pos=t,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Je(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 Je(this.stack,this.pos,this.index)}};function ft(s,e=Uint16Array){if(typeof s!="string")return s;let t=null;for(let r=0,n=0;r<s.length;){let i=0;for(;;){let o=s.charCodeAt(r++),a=!1;if(o==126){i=65535;break}o>=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,a=!0),i+=u,a)break;i*=46}t?t[n++]=i:t=new e(i)}return t}var je=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},As=new je,Rr=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=As,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 r=this.range,n=this.rangeIndex,i=this.pos+e;for(;i<r.from;){if(!n)return null;let o=this.ranges[--n];i-=r.from-o.to,r=o}for(;t<0?i>r.to:i>=r.to;){if(n==this.ranges.length-1)return null;let o=this.ranges[++n];i+=o.from-r.to,r=o}return i}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,r,n;if(t>=0&&t<this.chunk.length)r=this.pos+e,n=this.chunk.charCodeAt(t);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(r=i,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),n=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),n}acceptToken(e,t=0){let r=t?this.resolveOffset(t,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}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=As,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 r="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(r+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return r}},Ce=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:r}=t.p;qs(this.data,e,t,this.id,r.data,r.tokenPrecTable)}};Ce.prototype.contextual=Ce.prototype.fallback=Ce.prototype.extend=!1;var Tr=class{constructor(e,t,r){this.precTable=t,this.elseToken=r,this.data=typeof e=="string"?ft(e):e}token(e,t){let r=e.pos,n=0;for(;;){let i=e.next<0,o=e.resolveOffset(1,1);if(qs(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(i||n++,o==null)break;e.reset(o,e.token)}n&&(e.reset(r,e.token),e.acceptToken(this.elseToken,n))}};Tr.prototype.contextual=Ce.prototype.fallback=Ce.prototype.extend=!1;function qs(s,e,t,r,n,i){let o=0,a=1<<r,{dialect:u}=t.p.parser;e:for(;a&s[o];){let c=s[o+1];for(let m=o+3;m<c;m+=2)if((s[m+1]&a)>0){let g=s[m];if(u.allows(g)&&(e.token.value==-1||e.token.value==g||Xi(g,e.token.value,n,i))){e.acceptToken(g);break}}let p=e.next,d=0,f=s[o+2];if(e.next<0&&f>d&&s[c+f*3-3]==65535&&s[c+f*3-3]==65535){o=s[c+f*3-1];continue e}for(;d<f;){let m=d+f>>1,g=c+m+(m<<1),I=s[g],U=s[g+1]||65536;if(p<I)f=m;else if(p>=U)d=m+1;else{o=s[g+2],e.advance();continue e}}break}}function Os(s,e,t){for(let r=e,n;(n=s[r])!=65535;r++)if(n==t)return r-e;return-1}function Xi(s,e,t,r){let n=Os(t,r,e);return n<0||Os(t,r,s)<n}var ae=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),Sr=null,Ns;(function(s){s[s.Margin=25]="Margin"})(Ns||(Ns={}));function Bs(s,e,t){let r=s.cursor(G.IncludeAnonymous);for(r.moveTo(e);;)if(!(t<0?r.childBefore(e):r.childAfter(e)))for(;;){if((t<0?r.to<e:r.from>e)&&!r.type.isError)return t<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(s.length,Math.max(r.from+1,e+25));if(t<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return t<0?0:s.length}}var Ir=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?Bs(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Bs(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 r=this.trees[t],n=this.index[t];if(n==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=r.children[n],o=this.start[t]+r.positions[n];if(o>e)return this.nextStart=o,null;if(i instanceof W){if(o==e){if(o<this.safeFrom)return null;let a=o+i.length;if(a<=this.safeTo){let u=i.prop(M.lookAhead);if(!u||a+u<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}}},Dr=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new je)}getActions(e){let t=0,r=null,{parser:n}=e.p,{tokenizers:i}=n,o=n.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,u=0;for(let c=0;c<i.length;c++){if(!(1<<c&o))continue;let p=i[c],d=this.tokens[c];if(!(r&&!p.fallback)&&((p.contextual||d.start!=e.pos||d.mask!=o||d.context!=a)&&(this.updateCachedToken(d,p,e),d.mask=o,d.context=a),d.lookAhead>d.end+25&&(u=Math.max(d.lookAhead,u)),d.value!=0)){let f=t;if(d.extended>-1&&(t=this.addActions(e,d.extended,d.end,t)),t=this.addActions(e,d.value,d.end,t),!p.extend&&(r=d,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return u&&e.setLookAhead(u),!r&&e.pos==this.stream.end&&(r=new je,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,t=this.addActions(e,r.value,r.end,t)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new je,{pos:r,p:n}=e;return t.start=r,t.end=Math.min(r+1,n.stream.end),t.value=r==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,r){let n=this.stream.clipPos(r.pos);if(t.token(this.stream.reset(n,e),r),e.value>-1){let{parser:i}=r.p;for(let o=0;o<i.specialized.length;o++)if(i.specialized[o]==e.value){let a=i.specializers[o](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,r,n){for(let i=0;i<n;i+=3)if(this.actions[i]==e)return n;return this.actions[n++]=e,this.actions[n++]=t,this.actions[n++]=r,n}addActions(e,t,r,n){let{state:i}=e,{parser:o}=e.p,{data:a}=o;for(let u=0;u<2;u++)for(let c=o.stateSlot(i,u?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=me(a,c+2);else{n==0&&a[c+1]==2&&(n=this.putAction(me(a,c+2),t,r,n));break}a[c]==t&&(n=this.putAction(me(a,c+1),t,r,n))}return n}},Fs;(function(s){s[s.Distance=5]="Distance",s[s.MaxRemainingPerStep=3]="MaxRemainingPerStep",s[s.MinBufferLengthPrune=500]="MinBufferLengthPrune",s[s.ForceReduceLimit=10]="ForceReduceLimit",s[s.CutDepth=15e3]="CutDepth",s[s.CutTo=9e3]="CutTo",s[s.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",s[s.MaxStackCount=12]="MaxStackCount"})(Fs||(Fs={}));var xr=class{constructor(e,t,r,n){this.parser=e,this.input=t,this.ranges=n,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 Rr(t,n),this.tokens=new Dr(e,this.stream),this.topTerm=e.top[1];let{from:i}=n[0];this.stacks=[Qe.start(this,e.top[0],i)],this.fragments=r.length&&this.stream.end-i>e.bufferLength*4?new Ir(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,r=this.stacks=[],n,i;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>t)r.push(a);else{if(this.advanceStack(a,r,e))continue;{n||(n=[],i=[]),n.push(a);let u=this.tokens.getMainToken(a);i.push(u.value,u.end)}}break}}if(!r.length){let o=n&&Yi(n);if(o)return this.stackToTree(o);if(this.parser.strict)throw ae&&n&&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&&n){let o=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,i,r);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((a,u)=>u.score-a.score);r.length>o;)r.pop();r.some(a=>a.reducePos>t)&&this.recovering--}else if(r.length>1){e:for(let o=0;o<r.length-1;o++){let a=r[o];for(let u=o+1;u<r.length;u++){let c=r[u];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)r.splice(u--,1);else{r.splice(o--,1);continue e}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let o=1;o<r.length;o++)r[o].pos<this.minStackPos&&(this.minStackPos=r[o].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,r){let n=e.pos,{parser:i}=this,o=ae?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,p=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(n);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?i.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!c||(d.prop(M.contextHash)||0)==p))return e.useNode(d,f),ae&&console.log(o+this.stackID(e)+` (via reuse of ${i.getName(d.type.id)})`),!0;if(!(d instanceof W)||d.children.length==0||d.positions[0]>0)break;let m=d.children[0];if(m instanceof W&&d.positions[0]==0)d=m;else break}}let a=i.stateSlot(e.state,4);if(a>0)return e.reduce(a),ae&&console.log(o+this.stackID(e)+` (via always-reduce ${i.getName(a&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let c=0;c<u.length;){let p=u[c++],d=u[c++],f=u[c++],m=c==u.length||!r,g=m?e:e.split();if(g.apply(p,d,f),ae&&console.log(o+this.stackID(g)+` (via ${p&65536?`reduce of ${i.getName(p&65535)}`:"shift"} for ${i.getName(d)} @ ${n}${g==e?"":", split"})`),m)return!0;g.pos>n?t.push(g):r.push(g)}return!1}advanceFully(e,t){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return Us(e,t),!0}}runRecovery(e,t,r){let n=null,i=!1;for(let o=0;o<e.length;o++){let a=e[o],u=t[o<<1],c=t[(o<<1)+1],p=ae?this.stackID(a)+" -> ":"";if(a.deadEnd&&(i||(i=!0,a.restart(),ae&&console.log(p+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),f=p;for(let m=0;d.forceReduce()&&m<10&&(ae&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));m++)ae&&(f=this.stackID(d)+" -> ");for(let m of a.recoverByInsert(u))ae&&console.log(p+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,r);this.stream.end>a.pos?(c==a.pos&&(c++,u=0),a.recoverByDelete(u,c),ae&&console.log(p+this.stackID(a)+` (via recover-delete ${this.parser.getName(u)})`),Us(a,r)):(!n||n.score<a.score)&&(n=a)}return n}stackToTree(e){return e.close(),W.build({buffer:Je.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=(Sr||(Sr=new WeakMap)).get(e);return t||Sr.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function Us(s,e){for(let t=0;t<e.length;t++){let r=e[t];if(r.pos==s.pos&&r.sameState(s)){e[t].score<s.score&&(e[t]=s);return}}e.push(s)}var Er=class{constructor(e,t,r){this.source=e,this.flags=t,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}};var Ve=class extends Vt{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 a=0;a<e.repeatNodeCount;a++)t.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),n=[];for(let a=0;a<t.length;a++)n.push([]);function i(a,u,c){n[a].push([u,u.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let u=a[0];typeof u=="string"&&(u=M[u]);for(let c=1;c<a.length;){let p=a[c++];if(p>=0)i(p,u,a[c++]);else{let d=a[c+-p];for(let f=-p;f>0;f--)i(a[c++],u,d);c++}}}this.nodeSet=new $e(t.map((a,u)=>Y.define({name:u>=this.minRepeatTerm?void 0:a,id:u,props:n[u],top:r.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let o=ft(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(Gs),this.states=ft(e.states,Uint32Array),this.data=ft(e.stateData),this.goto=ft(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Ce(o,a):a),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,r){let n=new xr(this,e,t,r);for(let i of this.wrappers)n=i(n,e,t,r);return n}getGoto(e,t,r=!1){let n=this.goto;if(t>=n[0])return-1;for(let i=n[t+1];;){let o=n[i++],a=o&1,u=n[i++];if(a&&r)return u;for(let c=i+(o>>1);i<c;i++)if(n[i]==e)return u;if(a)return-1}}hasAction(e,t){let r=this.data;for(let n=0;n<2;n++)for(let i=this.stateSlot(e,n?2:1),o;;i+=3){if((o=r[i])==65535)if(r[i+1]==1)o=r[i=me(r,i+2)];else{if(r[i+1]==2)return me(r,i+2);break}if(o==t||o==0)return me(r,i+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){return!!this.allActions(e,r=>r==t?!0:null)}allActions(e,t){let r=this.stateSlot(e,4),n=r?t(r):void 0;for(let i=this.stateSlot(e,1);n==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=me(this.data,i+2);else break;n=t(me(this.data,i+1))}return n}nextStates(e){let t=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=me(this.data,r+2);else break;if(!(this.data[r+2]&1)){let n=this.data[r+1];t.some((i,o)=>o&1&&i==n)||t.push(this.data[r],n)}}return t}configure(e){let t=Object.assign(Object.create(Ve.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=r}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(r=>{let n=e.tokenizers.find(i=>i.from==r);return n?n.to:r})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((r,n)=>{let i=e.specializers.find(a=>a.from==r.external);if(!i)return r;let o=Object.assign(Object.assign({},r),{external:i.to});return t.specializers[n]=Gs(o),o})),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),r=t.map(()=>!1);if(e)for(let i of e.split(" ")){let o=t.indexOf(i);o>=0&&(r[o]=!0)}let n=null;for(let i=0;i<t.length;i++)if(!r[i])for(let o=this.dialects[t[i]],a;(a=this.data[o++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[a]=1;return new Er(e,r,n)}static deserialize(e){return new Ve(e)}};function me(s,e){return s[e]|s[e+1]<<16}function Yi(s){let e=null;for(let t of s){let r=t.p.stoppedAt;(t.pos==t.p.stream.end||r!=null&&t.pos>r)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function Gs(s){if(s.external){let e=s.extend?1:0;return(t,r)=>s.external(t,r)<<1|e}return s.get}var Mr=Ve.deserialize({version:14,states:"%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",stateData:"#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",goto:"#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",nodeNames:"\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:"6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",tokenizers:[0,1],topRules:{Filter:[0,1]},tokenPrec:0});var Z,kr=class{constructor(){y(this,Z,void 0)}setFilterCombinatorOp(e,t=l(this,Z)){ke(t)&&t.op===e||h(this,Z,{op:e,filters:[l(this,Z)]})}add(e){if(l(this,Z)===void 0)h(this,Z,e);else if(ke(l(this,Z)))l(this,Z).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=l(this,Z)){if(ke(t)){let r=t.filters.at(-1);r&&this.setColumn(e,r)}else t&&(t.column=e)}setOp(e,t=l(this,Z)){if(ke(t)){let r=t.filters.at(-1);r&&this.setOp(e,r)}else t&&(t.op=e)}setValue(e,t=l(this,Z)){var r;if(ke(t)){let n=t.filters.at(-1);n&&this.setValue(e,n)}else Zr(t)?((r=t.values)!=null||(t.values=[]),t.values.push(e)):Yr(t)&&(t.value=e)}toJSON(e=l(this,Z)){return this.name?{...e,name:this.name}:e}};Z=new WeakMap;var Pr=(s,e)=>{let t=new kr,r=s.cursor();do{let{name:n,from:i,to:o}=r;switch(n){case"ColumnValueExpression":t.add({});break;case"ColumnSetExpression":t.add({op:"in"});break;case"Or":case"And":t.setFilterCombinatorOp(e.substring(i,o));break;case"Column":t.setColumn(e.substring(i,o));break;case"Operator":t.setOp(e.substring(i,o));break;case"String":t.setValue(e.substring(i+1,o-1));break;case"Number":t.setValue(parseFloat(e.substring(i,o)));break;case"True":t.setValue(!0);break;case"False":t.setValue(!1);break;case"FilterName":t.name=e.substring(i,o);break;default:}}while(r.next());return t.toJSON()};var Zi=Mr.configure({strict:!0}),Se=s=>{let e=Zi.parse(s);return Pr(e,s)};function Lt(s,e){switch(e.op){case"in":return eo(s,e);case"=":return to(s,e);case">":return ro(s,e);case">=":return so(s,e);case"<":return no(s,e);case"<=":return io(s,e);case"starts":return oo(s,e);case"and":return ao(s,e);case"or":return uo(s,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var eo=(s,e)=>t=>e.values.indexOf(t[s[e.column]])!==-1,to=(s,e)=>t=>t[s[e.column]]===e.value,ro=(s,e)=>t=>t[s[e.column]]>e.value,so=(s,e)=>t=>t[s[e.column]]>=e.value,no=(s,e)=>t=>t[s[e.column]]<e.value,io=(s,e)=>t=>t[s[e.column]]<=e.value,oo=(s,e)=>{let t=e.value;if(typeof t!="string")throw Error("string filter applied to value of wrong type");return r=>{let n=r[s[e.column]];if(typeof n!="string")throw Error("string filter applied to value of wrong type");return n.toLowerCase().startsWith(t.toLowerCase())}},ao=(s,e)=>{let t=e.filters.map(r=>Lt(s,r));return r=>t.every(n=>n(r))};function uo(s,e){let t=e.filters.map(r=>Lt(s,r));return r=>t.some(n=>n(r))}var Ws=(s,e,t,r,n,i)=>{let o=_e(n,s),a=s[s.length-1].aggType,u=t.map(c=>n[c]);switch(a){case 1:return $s(i,r,n,s,e,u);case 2:return lo(i,r,n,s,e,u);case 3:return Hs(i,n,s,e,u);case 4:return po(i,r,n,s,e,u);case 5:return ho(i,r,n,s,e,u);case 6:return co(i,r,n,s,e,u)}};function Hs(s,e,t,r,n){let i={},o=_e(e,t);function a(u){if(Array.isArray(u))return u.length;{let c=0;for(let p in u)c+=1+a(u[p]);return c}}for(let u in s){let c=a(s[u]);i[u]=c}for(let u=0;u<r.length;u++)for(let c in i)r[u][n[0]]===c&&(r[u][o]=i[c]);return console.log("!!!! targetData",r),console.log("!!!! counts",i),i}function _e(s,e){console.log("!!!! aggregation length",e.length);let t=e[e.length-1].column;return s[t]}function $s(s,e,t,r,n,i){let o={},a=_e(t,r);function u(c,p,d){if(Array.isArray(c)){let f=0;for(let m of c)f+=Number(p[m][d]);return f}else{let f=0;for(let m in c)f+=u(c[m],p,d);return f}}for(let c in s){console.log(c);let p=Number(u(s[c],e,a));o[c]=p}for(let c=0;c<n.length;c++)for(let p in o)n[c][i[0]]===p&&(n[c][a]=o[p]);return console.log("!!!! targetData",n),console.log("!!!! sums",o),o}function lo(s,e,t,r,n,i){let o={},a=_e(t,r),u=Hs(s,t,r,n,i),c=$s(s,e,t,r,n,i);for(let p in u){let d=0;d=c[p]/u[p],o[p]=d}for(let p=0;p<n.length;p++)for(let d in o)n[p][i[0]]===d&&(n[p][a]=o[d]);return console.log("!!!! targetData",n),console.log("!!!! averages",o),o}function At(s,e,t){let r=[];if(Array.isArray(s))for(let n of s)r.push(e[n][t]);else for(let n in s)r.push(...At(s[n],e,t));return r}function co(s,e,t,r,n,i){let o={},a=_e(t,r);for(let u in s){let c=At(s[u],e,a),p=[...new Set(c)];o[u]=p}for(let u=0;u<n.length;u++)for(let c in o)n[u][i[0]]===c&&(n[u][a]=o[c]);return o}function po(s,e,t,r,n,i){let o={},a=_e(t,r);for(let u in s){let c=At(s[u],e,a),p=Math.max(...c);o[u]=p}for(let u=0;u<n.length;u++)for(let c in o)n[u][i[0]]===c&&(n[u][a]=o[c]);return o}function ho(s,e,t,r,n,i){let o={},a=_e(t,r);for(let u in s){let c=At(s[u],e,a),p=Math.min(...c);o[u]=p}for(let u=0;u<n.length;u++)for(let c in o)n[u][i[0]]===c&&(n[u][a]=o[c]);return o}var{DEPTH:Vr,IS_EXPANDED:Ks,KEY:_r}=L,zs=(s,e)=>{let t=[];for(let r=0,n=0,i=!1,o=e.length;r<o;r++){let a=e[r],{[Vr]:u,[_r]:c}=a;if(c===s){let p=a.slice();for(p[Ks]=!1,t.push(p),n+=1,i=!0;r<o-1&&e[r+1][Vr]>u;)r+=1}else if(i){let p=a.slice();p[0]=n,p[1]=n,t.push(p),n+=1}else t.push(a),n+=1}return t},Lr=(s,e,t,r,n,i)=>{let o=t.map(a=>r[a]);return js(n,o,s,e,void 0,void 0,void 0,i)},js=(s,e,t,r=[],n="$root",i=1,o=[],a)=>{console.log("dataRowsFromGroups2 1)");let u=Object.keys(s).sort();for(let c of u){let p=o.length,d=`${n}|${c}`,f=[p,p,!1,!1,i,0,d,0];f[e[i-1]]=c,o.push(f),t.includes(d)&&(f[Ks]=!0,Array.isArray(s[c])?fo(o,s[c],r,d,i+1):js(s[c],e,t,r,d,i+1,o,a))}console.log("dataRowsFromGroups2 2)");for(let c in o)for(let p in o)if(o[c][2]===!1&&a[p]!=null&&o[c][e[0]]===a[p][e[0]]){o[c]=o[c].splice(0,8).concat(a[p].slice(8,a[p].length));break}return console.log("dataRowsFromGroups2 3)"),o},fo=(s,e,t,r,n)=>{for(let i of e){let o=s.length,a=t[i].slice();a[0]=o,a[1]=o,a[Vr]=n,a[_r]=`${r}|${a[_r]}`,s.push(a)}},Qs=(s,e,t)=>{let r=e.map(o=>t[o]),n=go(s,r);return[mo(n,r),n]},mo=(s,e)=>{let r=[],n=0,i=Object.keys(s).sort();for(let o of i){let a=[n,n,!1,!1,1,0,`$root|${o}`,0];a[e[0]]=o,r.push(a),n+=1}return r};function go(s,e){let t={},r=e.length,n=r-1;for(let i=0,o=s.length;i<o;i++){let a=s[i],u=t,c,p;for(let d=0;d<r;d++){let f=e[d];p=a[f].toString(),c=u[p],c&&d===n?c.push(i):c?u=c:!c&&d<n?u=u[p]={}:c||(u[p]=[i])}}return console.log("!! groups",t),t}var bo=(s,e,[t,r])=>{let n=r==="D"?e[t]:s[t],i=r==="D"?s[t]:e[t];return n===i?0:i===null||n>i?1:-1},yo=s=>s.length===1?wo(s):s.length===2?Co(s):So(s),wo=([[s,e]])=>(t,r)=>{let n=e==="D"?r[s]:t[s],i=e==="D"?t[s]:r[s];return n>i?1:i>n?-1:0},Co=([[s,e],[t,r]])=>(n,i)=>{let o=e==="D"?i[s]:n[s],a=e==="D"?n[s]:i[s],u=r==="D"?i[t]:n[t],c=r==="D"?n[t]:i[t];return o>a?1:a>o?-1:u>c?1:c>u?-1:0},So=(s,e=bo)=>(t,r)=>{for(let n of s){let i=e(t,r,n);if(i!==0)return i}return 0},Js=(s,{sortDefs:e},t)=>{let r=e.map(({column:i,sortType:o})=>[t[i],o]),n=yo(r);return s.slice().sort(n)};var{RENDER_IDX:vo,SELECTED:Ro}=L,Ar=(s,e,t,r)=>{let[n]=s,i;if(r){let{count:o}=L;i=s.slice(0,o).concat(r.map(a=>s[a]))}else i=s.slice();return i[vo]=e.keyFor(n),i[Ro]=ps(t,n),i},To=(s,e)=>{if(e){let{count:t}=L;for(let[r,n]of Object.entries(s)){let i=e[r];if(i===void 0)throw Error(`ArrayDataSource column ${r} is not in underlying data set`);if(i!==n-t)return!0}}return!1},Io=(s,e)=>{let{count:t}=L,r=[];return Object.entries(s).forEach(([n])=>{r.push(e[n]+t)}),r},Or=(s,e)=>{if(e&&To(s,e))return Io(s,e)};var{KEY:Xs}=L,{debug:re}=Ge("ArrayDataSource"),Nr=s=>(e,t)=>[t,t,!0,!1,1,0,String(e[s]),0,...e],Do=(s,e)=>({columns:s.map(({name:r,serverDataType:n="string"})=>({name:r,serverDataType:n})),key:e!=null?e:s[0].name,table:{module:"",table:"Array"}}),z,C,B,Nt,O,mt,Bt,gt,Xe,Ot=class extends te{constructor({aggregations:t,columnDescriptors:r,data:n,dataMap:i,filter:o,groupBy:a,keyColumn:u,rangeChangeRowset:c="delta",sort:p,title:d,viewport:f}){super();this.lastRangeServed={from:0,to:0};this.openTreeNodes=[];y(this,z,void 0);y(this,C,We);y(this,B,void 0);y(this,Nt,void 0);y(this,O,or);y(this,mt,0);y(this,Bt,0);y(this,gt,"initialising");y(this,Xe,void 0);this.selectedRows=[];this.keys=new qe(l(this,O));this.processedData=void 0;this.insert=t=>{let r=Nr(this.key)(t,this.size);l(this,B).push(r);let{from:n,to:i}=l(this,O),[o]=r;o>=n&&o<i&&this.sendRowsToClient()};this.update=(t,r)=>{var u;let n=t[this.key],i=l(this,z)[r],o=(u=this.dataMap)==null?void 0:u[r],a=l(this,B).findIndex(c=>c[Xs]===n);if(a!==-1&&o!==void 0){let c=l(this,B)[a];c[i]=t[o];let{from:p,to:d}=l(this,O),[f]=c;f>=p&&f<d&&this.sendRowsToClient(!1,c)}};this.updateRow=t=>{let r=t[this.key],n=l(this,B).findIndex(i=>i[Xs]===r);if(n!==-1){let i=Nr(this.key)(t,n);l(this,B)[n]=i;let{from:o,to:a}=l(this,O);n>=o&&n<a&&this.sendRowsToClient(!1,i)}};if(!n||!r)throw Error("ArrayDataSource constructor called without data or without columnDescriptors");this.columnDescriptors=r,this.dataMap=i,this.key=u?this.columnDescriptors.findIndex(g=>g.name===u):0,this.rangeChangeRowset=c,this.tableSchema=Do(r,u),this.viewport=f||ue(),h(this,Bt,n.length),h(this,Xe,d);let m=r.map(g=>g.name);h(this,z,ir(m)),this.dataIndices=Or(l(this,z),this.dataMap),h(this,B,n.map(Nr(this.key))),this.config={...l(this,C),aggregations:t||l(this,C).aggregations,columns:m,filter:o||l(this,C).filter,groupBy:a||l(this,C).groupBy,sort:p||l(this,C).sort},re==null||re(`columnMap: ${JSON.stringify(l(this,z))}`)}async subscribe({viewport:t=(p=>(p=this.viewport)!=null?p:ue())(),columns:r,aggregations:n,range:i,sort:o,groupBy:a,filter:u},c){var m;this.clientCallback=c,this.viewport=t,h(this,gt,"subscribed"),this.lastRangeServed={from:0,to:0};let d=l(this,C),f=n||r||u||a||o;f&&(i&&h(this,O,i),d={...d,aggregations:n||l(this,C).aggregations,columns:r||l(this,C).columns,filter:u||l(this,C).filter,groupBy:a||l(this,C).groupBy,sort:o||l(this,C).sort}),(m=this.clientCallback)==null||m.call(this,{...d,type:"subscribed",clientViewportId:this.viewport,range:l(this,O),tableSchema:this.tableSchema}),f?this.config=d:(this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:l(this,B).length}),i?this.range=i:l(this,O)!==or&&this.sendRowsToClient())}unsubscribe(){console.log("unsubscribe noop")}suspend(){return console.log("noop"),this}resume(){return console.log("resume noop"),this}disable(){return console.log("disable noop"),this}enable(){return console.log("enable noop"),this}select(t){h(this,mt,t.length),re==null||re(`select ${JSON.stringify(t)}`),this.selectedRows=t,this.setRange(Ue(l(this,O)),!0)}openTreeNode(t){this.openTreeNodes.push(t),this.processedData=Lr(this.openTreeNodes,l(this,B),l(this,C).groupBy,l(this,z),this.groupMap,this.processedData),this.setRange(Ue(l(this,O)),!0)}closeTreeNode(t){this.openTreeNodes=this.openTreeNodes.filter(r=>r!==t),this.processedData&&(this.processedData=zs(t,this.processedData),this.setRange(Ue(l(this,O)),!0))}get links(){return l(this,Nt)}get menu(){return this._menu}get status(){return l(this,gt)}get data(){return l(this,B)}get currentData(){var t;return(t=this.processedData)!=null?t:l(this,B)}get table(){return this.tableSchema.table}get config(){return l(this,C)}set config(t){var r;if(this.applyConfig(t)){if(t){let n=l(this,C),i=(r=t==null?void 0:t.filter)!=null&&r.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Se(t.filter.filter)}}:t;h(this,C,ct(i));let o;if(gs(t)){let{filter:a,filterStruct:u=Se(a)}=t.filter;if(u){let c=Lt(l(this,z),u);o=l(this,B).filter(c)}else throw Error("filter must include filterStruct")}if(bs(t)&&(o=Js(o!=null?o:l(this,B),t.sort,l(this,z))),this.openTreeNodes.length>0&&pr(n,t)&&(l(this,C).groupBy.length===0?this.openTreeNodes.length=0:console.log("adjust the openTReeNodes groupBy changed ",{originalGroupBy:n.groupBy,newGroupBy:i.groupBy})),ms(t)){let[a,u]=Qs(o!=null?o:l(this,B),t.groupBy,l(this,z));this.groupMap=u,o=a,this.openTreeNodes.length>0&&(o=Lr(this.openTreeNodes,l(this,B),l(this,C).groupBy,l(this,z),this.groupMap,o))}this.processedData=o==null?void 0:o.map((a,u)=>{let c=a.slice();return c[0]=u,c[1]=u,c})}this.setRange(Ue(l(this,O)),!0),this.emit("config",l(this,C))}}applyConfig(t){var r;if(Dt(l(this,C),t)&&t){let n=(r=t==null?void 0:t.filter)!=null&&r.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Se(t.filter.filter)}}:t;return h(this,C,ct(n)),!0}}get selectedRowsCount(){return l(this,mt)}get size(){var t,r;return(r=(t=this.processedData)==null?void 0:t.length)!=null?r:l(this,B).length}get range(){return l(this,O)}set range(t){(t.from!==l(this,O).from||t.to!==l(this,O).to)&&this.setRange(t)}delete(t){console.log(`delete row ${t.join(",")}`)}setRange(t,r=!1){h(this,O,t),this.keys.reset(t),this.sendRowsToClient(r)}sendRowsToClient(t=!1,r){var n,i,o;if(r)(n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"update",rows:[Ar(r,this.keys,this.selectedRows,this.dataIndices)],type:"viewport-update"});else{let a=this.rangeChangeRowset==="delta"&&!t?rs(this.lastRangeServed,l(this,O)):l(this,O),u=(i=this.processedData)!=null?i:l(this,B),c=u.slice(a.from,a.to).map(p=>Ar(p,this.keys,this.selectedRows,this.dataIndices));(o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"batch",rows:c,size:u.length,type:"viewport-update"}),this.lastRangeServed={from:l(this,O).from,to:Math.min(l(this,O).to,l(this,O).from+c.length)}}}get columns(){return l(this,C).columns}set columns(t){let r=Jr(this.config.columns,t);if(r.length>0){let n=Xr(this.columnDescriptors,r,i=>i.name);console.log("columnsWithoutDescriptors",{columnsWithoutDescriptors:n})}h(this,z,ir(t)),this.dataIndices=Or(l(this,z),this.dataMap),this.config={...l(this,C),columns:t}}get aggregations(){return l(this,C).aggregations}set aggregations(t){var i;h(this,C,{...l(this,C),aggregations:t});let r=(i=this.processedData)!=null?i:l(this,B),n=l(this,B);Ws(t,r,l(this,C).groupBy,n,l(this,z),this.groupMap),this.setRange(Ue(l(this,O)),!0),this.emit("config",l(this,C))}get sort(){return l(this,C).sort}set sort(t){re==null||re(`sort ${JSON.stringify(t)}`),this.config={...l(this,C),sort:t}}get filter(){return l(this,C).filter}set filter(t){re==null||re(`filter ${JSON.stringify(t)}`),this.config={...l(this,C),filter:t}}get groupBy(){return l(this,C).groupBy}set groupBy(t){this.config={...l(this,C),groupBy:t}}get title(){return l(this,Xe)}set title(t){h(this,Xe,t)}get _clientCallback(){return this.clientCallback}createLink({parentVpId:t,link:{fromColumn:r,toColumn:n}}){console.log("create link",{parentVpId:t,fromColumn:r,toColumn:n})}removeLink(){console.log("remove link")}findRow(t){let r=l(this,B)[t];if(r)return r;throw`no row found for key ${t}`}applyEdit(t,r,n){return console.log(`ArrayDataSource applyEdit ${t[0]} ${r} ${n}`),Promise.resolve(!0)}async menuRpcCall(t){return new Promise(r=>{let{type:n}=t;switch(n){case"VP_EDIT_CELL_RPC":break;default:r(void 0)}})}};z=new WeakMap,C=new WeakMap,B=new WeakMap,Nt=new WeakMap,O=new WeakMap,mt=new WeakMap,Bt=new WeakMap,gt=new WeakMap,Xe=new WeakMap;var xo={columns:[],key:"",table:{module:"",table:""}},{DEPTH:Le,IDX:Ys,IS_EXPANDED:Eo,IS_LEAF:Mo,KEY:sn,SELECTED:Zs}=L,en=(s,e)=>{let[t]=s,r=s.slice();return r[1]=e.keyFor(t),r},ve,se,$,Re,Te,ce,Ft,Ut,Ie,Ye,Ze,tn=class extends te{constructor({aggregations:t,data:r,filter:n,groupBy:i,sort:o,title:a,viewport:u}){super();this.expandedRows=new Set;this.visibleRows=[];y(this,ve,[]);y(this,se,We);y(this,$,void 0);y(this,Re,{filter:""});y(this,Te,[]);y(this,ce,{from:0,to:0});y(this,Ft,0);y(this,Ut,0);y(this,Ie,{sortDefs:[]});y(this,Ye,"initialising");y(this,Ze,void 0);this.keys=new qe(l(this,ce));if(!r)throw Error("JsonDataSource constructor called without data");[this.columnDescriptors,nr(this,$)._]=ur(r),this.visibleRows=l(this,$).filter(c=>c[Le]===0).map((c,p)=>[p,p].concat(c.slice(2))),this.viewport=u||ue(),t&&h(this,ve,t),this.columnDescriptors&&h(this,se,{...l(this,se),columns:this.columnDescriptors.map(c=>c.name)}),n&&h(this,Re,n),i&&h(this,Te,i),o&&h(this,Ie,o),h(this,Ze,a)}async subscribe({viewport:t=(p=>(p=this.viewport)!=null?p:ue())(),columns:r,aggregations:n,range:i,sort:o,groupBy:a,filter:u},c){var d;this.clientCallback=c,n&&h(this,ve,n),r&&h(this,se,{...l(this,se),columns:r}),u&&h(this,Re,u),a&&h(this,Te,a),i&&h(this,ce,i),o&&h(this,Ie,o),l(this,Ye)==="initialising"&&(this.viewport=t,h(this,Ye,"subscribed"),(d=this.clientCallback)==null||d.call(this,{aggregations:l(this,ve),type:"subscribed",clientViewportId:this.viewport,columns:l(this,se).columns,filter:l(this,Re),groupBy:l(this,Te),range:l(this,ce),sort:l(this,Ie),tableSchema:xo}),this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:this.visibleRows.length}))}unsubscribe(){console.log("noop")}suspend(){return console.log("noop"),this}resume(){return console.log("noop"),this}disable(){return console.log("noop"),this}enable(){return console.log("noop"),this}set data(t){console.log("set JsonDataSource data"),[this.columnDescriptors,nr(this,$)._]=ur(t),this.visibleRows=l(this,$).filter(r=>r[Le]===0).map((r,n)=>[n,n].concat(r.slice(2))),requestAnimationFrame(()=>{this.sendRowsToClient()})}select(t){var n;let r=[];for(let i of l(this,$)){let{[Ys]:o,[Zs]:a}=i,u=a===1,c=ds(t,o);if(c!==u){let p=i.slice();p[Zs]=c?1:0,l(this,$)[o]=p,r.push(p)}}r.length>0&&((n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"update",type:"viewport-update",rows:r}))}openTreeNode(t){var i;this.expandedRows.add(t),this.visibleRows=rn(l(this,$),this.expandedRows);let{from:r,to:n}=l(this,ce);(i=this.clientCallback)==null||i.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(r,n).map(o=>en(o,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}closeTreeNode(t,r=!1){if(this.expandedRows.delete(t),r)for(let n of this.expandedRows.keys())n.startsWith(t)&&this.expandedRows.delete(n);this.visibleRows=rn(l(this,$),this.expandedRows),this.sendRowsToClient()}get status(){return l(this,Ye)}get config(){return l(this,se)}applyConfig(){return!0}get selectedRowsCount(){return l(this,Ft)}get size(){return l(this,Ut)}get range(){return l(this,ce)}set range(t){h(this,ce,t),this.keys.reset(t),requestAnimationFrame(()=>{this.sendRowsToClient()})}sendRowsToClient(){var n;let{from:t,to:r}=l(this,ce);(n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(t,r).map(i=>en(i,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}get columns(){return l(this,se).columns}set columns(t){h(this,se,{...l(this,se),columns:t})}get aggregations(){return l(this,ve)}set aggregations(t){h(this,ve,t)}get sort(){return l(this,Ie)}set sort(t){h(this,Ie,t)}get filter(){return l(this,Re)}set filter(t){h(this,Re,t)}get groupBy(){return l(this,Te)}set groupBy(t){h(this,Te,t)}get title(){return l(this,Ze)}set title(t){h(this,Ze,t)}createLink({parentVpId:t,link:{fromColumn:r,toColumn:n}}){console.log("create link",{parentVpId:t,fromColumn:r,toColumn:n})}removeLink(){console.log("remove link")}async menuRpcCall(t){console.log("rmenuRpcCall",{rpcRequest:t})}applyEdit(t,r,n){return console.log(`ArrayDataSource applyEdit ${t.join(",")} ${r} ${n}`),Promise.resolve(!0)}getChildRows(t){let r=l(this,$).find(n=>n[sn]===t);if(r){let{[Ys]:n,[Le]:i}=r,o=n+1,a=[];do{let{[Le]:u}=l(this,$)[o];if(u===i+1)a.push(l(this,$)[o]);else if(u<=i)break;o+=1}while(o<l(this,$).length);return a}else console.warn(`JsonDataSource getChildRows row not found for key ${t}`);return[]}getRowsAtDepth(t,r=!0){return(r?this.visibleRows:l(this,$)).filter(i=>i[Le]===t)}};ve=new WeakMap,se=new WeakMap,$=new WeakMap,Re=new WeakMap,Te=new WeakMap,ce=new WeakMap,Ft=new WeakMap,Ut=new WeakMap,Ie=new WeakMap,Ye=new WeakMap,Ze=new WeakMap;function rn(s,e){let t=[],r={value:0};for(let n=0;n<s.length;n++){let i=s[n],{[Le]:o,[sn]:a,[Mo]:u}=i,c=e.has(a);if(t.push(ko(i,r,c)),!u&&!c)do n+=1;while(n<s.length-1&&s[n+1][Le]>o)}return t}var ko=(s,e,t)=>{let r=s.slice();return r[0]=e.value,r[1]=e.value,t&&(r[Eo]=!0),e.value+=1,r};var{info:j}=Ge("RemoteDataSource"),{KEY:Po}=L,b,Gt,bt,yt,et,ge,wt,tt,k,Ae,nn=class extends te{constructor({bufferSize:t=100,aggregations:r,columns:n,filter:i,groupBy:o,sort:a,table:u,title:c,viewport:p,visualLink:d}){super();this.server=null;y(this,b,We);y(this,Gt,[]);y(this,bt,void 0);y(this,yt,void 0);y(this,et,"throttle");y(this,ge,{from:0,to:0});y(this,wt,0);y(this,tt,0);y(this,k,"initialising");y(this,Ae,void 0);this.handleMessageFromServer=t=>{var r,n;if(t.type==="subscribed")h(this,k,"subscribed"),t.tableSchema&&(this.tableSchema=t.tableSchema),(r=this.clientCallback)==null||r.call(this,t);else if(t.type==="disabled")h(this,k,"disabled");else if(t.type==="enabled")h(this,k,"enabled");else{if(ws(t))return;t.type==="debounce-begin"?this.optimize="debounce":(t.type==="viewport-update"&&t.size!==void 0&&t.size!==l(this,tt)&&(h(this,tt,t.size),this.emit("resize",t.size)),this.configChangePending&&this.setConfigPending(),Is(t)?h(this,yt,t.menu):Ts(t)?h(this,bt,t.links):(n=this.clientCallback)==null||n.call(this,t),this.optimize==="debounce"&&this.revertDebounce())}};this.revertDebounce=lr(()=>{this.optimize="throttle"},100);this.rawRangeRequest=t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})};this.debounceRangeRequest=lr(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},50);this.throttleRangeRequest=ls(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},80);if(!u)throw Error("RemoteDataSource constructor called without table");this.bufferSize=t,this.table=u,this.viewport=p,h(this,b,{...l(this,b),aggregations:r||l(this,b).aggregations,columns:n||l(this,b).columns,filter:i||l(this,b).filter,groupBy:o||l(this,b).groupBy,sort:a||l(this,b).sort,visualLink:d||l(this,b).visualLink}),h(this,Ae,c),this.rangeRequest=this.throttleRangeRequest}async subscribe({viewport:t=(p=>(p=this.viewport)!=null?p:this.viewport=ue())(),columns:r,aggregations:n,range:i,sort:o,groupBy:a,filter:u},c){var f;if(l(this,k)==="disabled"||l(this,k)==="disabling"){this.enable(c);return}if(this.clientCallback=c,(n||r||u||a||o)&&h(this,b,{...l(this,b),aggregations:n||l(this,b).aggregations,columns:r||l(this,b).columns,filter:u||l(this,b).filter,groupBy:a||l(this,b).groupBy,sort:o||l(this,b).sort}),i&&h(this,ge,i),l(this,k)!=="initialising"&&l(this,k)!=="unsubscribed")return;h(this,k,"subscribing"),this.viewport=t,this.server=await Es();let{bufferSize:d}=this;(f=this.server)==null||f.subscribe({...l(this,b),bufferSize:d,viewport:t,table:this.table,range:l(this,ge),title:l(this,Ae)},this.handleMessageFromServer)}unsubscribe(){var t,r;console.log(`unsubscribe #${this.viewport}`),j==null||j(`unsubscribe #${this.viewport}`),this.viewport&&((t=this.server)==null||t.unsubscribe(this.viewport)),(r=this.server)==null||r.destroy(this.viewport),this.server=null,this.removeAllListeners(),h(this,k,"unsubscribed"),this.viewport=void 0,this.range={from:0,to:0}}suspend(){var t;return console.log(`suspend #${this.viewport}, current status ${l(this,k)}`),j==null||j(`suspend #${this.viewport}, current status ${l(this,k)}`),this.viewport&&(h(this,k,"suspended"),(t=this.server)==null||t.send({type:"suspend",viewport:this.viewport})),this}resume(){var n;console.log(`resume #${this.viewport}, current status ${l(this,k)}`);let t=l(this,k).startsWith("disabl"),r=l(this,k)==="suspended";return j==null||j(`resume #${this.viewport}, current status ${l(this,k)}`),this.viewport&&(t?this.enable():r&&((n=this.server)==null||n.send({type:"resume",viewport:this.viewport}),h(this,k,"subscribed"))),this}disable(){var t;return j==null||j(`disable #${this.viewport}, current status ${l(this,k)}`),this.viewport&&(h(this,k,"disabling"),(t=this.server)==null||t.send({viewport:this.viewport,type:"disable"})),this}enable(t){var r;return j==null||j(`enable #${this.viewport}, current status ${l(this,k)}`),this.viewport&&(l(this,k)==="disabled"||l(this,k)==="disabling")&&(h(this,k,"enabling"),t&&(this.clientCallback=t),(r=this.server)==null||r.send({viewport:this.viewport,type:"enable"})),this}select(t){var r;h(this,wt,t.length),this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"select",selected:t}))}openTreeNode(t){var r;this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"openTreeNode",key:t}))}closeTreeNode(t){var r;this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"closeTreeNode",key:t}))}get links(){return l(this,bt)}get menu(){return l(this,yt)}get status(){return l(this,k)}get optimize(){return l(this,et)}set optimize(t){if(t!==l(this,et)){switch(h(this,et,t),t){case"none":this.rangeRequest=this.rawRangeRequest;break;case"debounce":this.rangeRequest=this.debounceRangeRequest;break;case"throttle":this.rangeRequest=this.throttleRangeRequest;break}this.emit("optimize",t)}}get selectedRowsCount(){return l(this,wt)}get size(){return l(this,tt)}get range(){return l(this,ge)}set range(t){(t.from!==l(this,ge).from||t.to!==l(this,ge).to)&&(h(this,ge,t),this.rangeRequest(t))}get config(){return l(this,b)}set config(t){var r;this.applyConfig(t)&&(l(this,b)&&this.viewport&&this.server&&t&&((r=this.server)==null||r.send({viewport:this.viewport,type:"config",config:l(this,b)})),this.emit("config",l(this,b)))}applyConfig(t){var r;if(Dt(l(this,b),t)&&t){let n=(r=t==null?void 0:t.filter)!=null&&r.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Se(t.filter.filter)}}:t;return h(this,b,ct(n)),!0}}get columns(){return l(this,b).columns}set columns(t){if(h(this,b,{...l(this,b),columns:t}),this.viewport){let r={viewport:this.viewport,type:"setColumns",columns:t};this.server&&this.server.send(r)}this.emit("config",l(this,b))}get aggregations(){return l(this,b).aggregations}set aggregations(t){var r;h(this,b,{...l(this,b),aggregations:t}),this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"aggregate",aggregations:t})),this.emit("config",l(this,b))}get sort(){return l(this,b).sort}set sort(t){if(h(this,b,{...l(this,b),sort:t}),this.viewport){let r={viewport:this.viewport,type:"sort",sort:t};this.server&&this.server.send(r)}this.emit("config",l(this,b))}get filter(){return l(this,b).filter}set filter(t){if(h(this,b,{...l(this,b),filter:t}),this.viewport){let r={viewport:this.viewport,type:"filter",filter:t};this.server&&this.server.send(r)}this.emit("config",l(this,b))}get groupBy(){return l(this,b).groupBy}set groupBy(t){var r;if(Qr(this.groupBy,t)){let n=l(this,Gt).length>0;if(h(this,b,{...l(this,b),groupBy:t}),this.viewport){let i={viewport:this.viewport,type:"groupBy",groupBy:l(this,b).groupBy};this.server&&this.server.send(i)}!n&&t.length>0&&this.viewport&&((r=this.clientCallback)==null||r.call(this,{clientViewportId:this.viewport,mode:"batch",type:"viewport-update",size:0,rows:[]})),this.emit("config",l(this,b)),this.setConfigPending({groupBy:t})}}get title(){return l(this,Ae)}set title(t){var r;h(this,Ae,t),this.viewport&&t&&((r=this.server)==null||r.send({type:"setTitle",title:t,viewport:this.viewport}))}get visualLink(){return l(this,b).visualLink}set visualLink(t){var r,n;if(h(this,b,{...l(this,b),visualLink:t}),t){let{parentClientVpId:i,link:{fromColumn:o,toColumn:a}}=t;this.viewport&&((r=this.server)==null||r.send({viewport:this.viewport,type:"createLink",parentClientVpId:i,parentColumnName:a,childColumnName:o}))}else this.viewport&&((n=this.server)==null||n.send({type:"removeLink",viewport:this.viewport}));this.emit("config",l(this,b))}setConfigPending(t){let r=this.configChangePending;this.configChangePending=t,t!==void 0?this.emit("config",t,!1):this.emit("config",r,!0)}async rpcCall(t){var r;if(this.viewport)return(r=this.server)==null?void 0:r.rpcCall({vpId:this.viewport,...t})}async menuRpcCall(t){var r;if(this.viewport)return(r=this.server)==null?void 0:r.rpcCall({vpId:this.viewport,...t})}applyEdit(t,r,n){return this.menuRpcCall({rowKey:t[Po],field:r,value:n,type:"VP_EDIT_CELL_RPC"}).then(i=>i!=null&&i.error?i.error:!0)}insertRow(t,r){return this.menuRpcCall({rowKey:t,data:r,type:"VP_EDIT_ADD_ROW_RPC"}).then(n=>n!=null&&n.error?n.error:!0)}deleteRow(t){return this.menuRpcCall({rowKey:t,type:"VP_EDIT_DELETE_ROW_RPC"}).then(r=>r!=null&&r.error?r.error:!0)}};b=new WeakMap,Gt=new WeakMap,bt=new WeakMap,yt=new WeakMap,et=new WeakMap,ge=new WeakMap,wt=new WeakMap,tt=new WeakMap,k=new WeakMap,Ae=new WeakMap;var on=new Map,Vo=(s,e,t="")=>{let r,n=on.get(s);if(n&&n.has(e))r=n.get(e);else{let{data:i,map:o}=s,a=o[e];r=[];let u=new Set;for(let c of i){let p=c[a];u.has(p)||(u.add(p),r.push(p))}r.sort(),n?n.set(e,r):on.set(s,new Map([[e,r]]))}return t?r.filter(i=>i.toString().startsWith(t)):r},qt=(s,e,t)=>new Promise(r=>{let n=Vo(s,e,t),i=n.length>20?n==null?void 0:n.slice(0,20).map(o=>o.toString()):n.map(o=>o.toString());setTimeout(()=>r(i),100)});var Wt,rt,Oe,st=class extends Ot{constructor({data:t,menuRpcServices:r,rpcServices:n,table:i,menu:o,...a}){var u;if(t===void 0&&i===void 0)throw Error("TickingArrayDataSource must be constructed with data");super({...a,data:(u=t!=null?t:i==null?void 0:i.data)!=null?u:[]});y(this,Wt,void 0);y(this,rt,void 0);y(this,Oe,void 0);this._menu=o,h(this,Wt,r),h(this,rt,n),h(this,Oe,i),i&&(i.on("insert",this.insert),i.on("update",this.updateRow))}async subscribe(t,r){return super.subscribe(t,r)}set range(t){super.range=t}get range(){return super.range}getSelectedRows(){return this.selectedRows.reduce((t,r)=>{if(Array.isArray(r))r.forEach(n=>{let i=this.data[n];i&&t.push(i)});else{let n=this.data[r];n&&t.push(n)}return t},[])}applyEdit(t,r,n){var o;let i=t[L.KEY];return(o=l(this,Oe))==null||o.update(i,r,n),Promise.resolve(!0)}async rpcCall(t){var n;let r=(n=l(this,rt))==null?void 0:n.find(i=>i.rpcName===t.rpcName);if(r)return r.service({...t});console.log(`no implementation for PRC service ${t.rpcName}`)}async menuRpcCall(t){var n;let r=(n=l(this,rt))==null?void 0:n.find(i=>i.rpcName===t.rpcName);if(r)switch(t.type){case"VIEW_PORT_MENUS_SELECT_RPC":{let i=this.getSelectedRows();return r.service({...t,selectedRows:i})}default:}return super.menuRpcCall(t)}getTypeaheadSuggestions(t,r){if(l(this,Oe))return qt(l(this,Oe),t,r);throw Error("cannot call getTypeaheadSuggestions on TickingDataSOurce if table has not been provided")}};Wt=new WeakMap,rt=new WeakMap,Oe=new WeakMap;var ah=s=>["Row No"].concat(Array(s).fill("").map((e,t)=>`Column ${t+1}`)),_o=s=>e=>[`row ${e+1}`].concat(Array(s.length).fill(!0).map((t,r)=>`value ${r+1} @ ${e+1}`)),Lo=(s,e={})=>{if(typeof s=="number")return[{name:"row number",width:150}].concat(Array(s).fill(!0).map((t,r)=>{let n=`column ${r+1}`;return{name:n,width:100,...e[n]}}));throw Error("DefaultColumnGenerator must be passed columns (number)")},Br={ColumnGenerator:Lo,RowGenerator:_o},uh=s=>{var t,r,n;let e=(t=s==null?void 0:s.table)!=null?t:"";switch(s==null?void 0:s.module){case"SIMUL":{let{ColumnGenerator:i,RowGenerator:o,createUpdateGenerator:a}=(r=simulDataGenerators[e])!=null?r:Br;return[i,o,a]}case"BASKET":{let{ColumnGenerator:i,RowGenerator:o,createUpdateGenerator:a}=(n=basketDataGenerators[e])!=null?n:Br;return[i,o,a]}case void 0:{let{ColumnGenerator:i,RowGenerator:o}=Br;return[i,o]}default:throw Error(`vuu-row-gererator table ${s==null?void 0:s.table} was requested but no generator is registered`)}},lh=(s,e,t,r)=>{let n=e(r),i=t(n.map(a=>a.name)),o=[];for(let a=0;a<s;a++){let u=i(a);if(u)o[a]=u;else break}return o};var Q,nt,be,it,Ct,F=class extends te{constructor(t,r,n,i){super();y(this,Q,void 0);y(this,nt,void 0);y(this,be,void 0);y(this,it,new Map);y(this,Ct,void 0);h(this,Q,r),h(this,nt,n),h(this,Ct,t),h(this,be,n[t.key]),this.buildIndex(),i==null||i.setTable(this),i==null||i.setRange({from:0,to:100})}buildIndex(){for(let t=0;t<l(this,Q).length;t++){let r=l(this,Q)[t][l(this,be)];l(this,it).set(r,t)}}get data(){return l(this,Q)}get map(){return l(this,nt)}get schema(){return l(this,Ct)}insert(t){let r=l(this,Q).length;l(this,Q).push(t);let n=t[l(this,be)];l(this,it).set(n,r),this.emit("insert",t)}findByKey(t){var n;let r=(n=l(this,it).get(t))!=null?n:-1;return l(this,Q)[r]}update(t,r,n){let i=l(this,Q).findIndex(a=>a[l(this,be)]===t),o=l(this,nt)[r];if(i!==-1){let u=l(this,Q)[i].slice();u[o]=n,l(this,Q)[i]=u,this.emit("update",u,r)}}updateRow(t){let r=t[l(this,be)],n=l(this,Q).findIndex(i=>i[l(this,be)]===r);n!==-1&&(l(this,Q)[n]=t,this.emit("update",t))}};Q=new WeakMap,nt=new WeakMap,be=new WeakMap,it=new WeakMap,Ct=new WeakMap;var J=s=>Object.values(s.columns).reduce((e,t,r)=>(e[t.name]=r,e),{}),Ao=(s,{columns:e,table:t},{columns:r,table:n})=>{let i=e.find(a=>a.name===s),o=r.find(a=>a.name===s);if(i&&o){if(i.serverDataType===o.serverDataType)return i.serverDataType;throw Error(`both tables ${t.table} and ${n.table} implement column ${s}, but with types differ`)}else{if(i)return i.serverDataType;if(o)return o.serverDataType;throw Error("WTF how is this possible")}},Ht=(s,e,t,r)=>{let{map:n,schema:i}=e,{map:o,schema:a}=t,u=n[r],c=o[r],p=new Set([...i.columns,...a.columns].map(I=>I.name).sort()),d={key:r,table:s,columns:Array.from(p).map(I=>({name:I,serverDataType:Ao(I,i,a)}))},f=[],m=J(d);for(let I of e.data){let U=t.findByKey(String(I[u]));if(U){let V=[];for(let E of e.schema.columns){let v=I[n[E.name]];V[m[E.name]]=v}for(let E of t.schema.columns){let v=U[o[E.name]];V[m[E.name]]=v}f.push(V)}}let g=new F(d,f,m);return e.on("insert",I=>{let U=t.findByKey(String(I[u]));if(U){let V=[];for(let E of e.schema.columns){let v=I[n[E.name]];V[m[E.name]]=v}for(let E of t.schema.columns){let v=U[o[E.name]];V[m[E.name]]=v}g.insert(V)}}),t.on("update",I=>{let U=I[c],V=g.findByKey(U);if(V){let E=V.slice();for(let{name:v}of t.schema.columns)I[o[v]]!==E[m[v]]&&(E[m[v]]=I[o[v]]);g.updateRow(E)}}),g};function S(s,e){return s=Math.ceil(s),e=Math.floor(e),Math.floor(Math.random()*(e-s+1))+s}var $t=(s,e)=>s+(e-s)*Math.random(),an=(s,e)=>{let t=e(0,1e3),r=e(t-s,t-1),n=e(t+1,t+s),i=r<0?t:r,o=Math.round(i*100)/100,a=Math.round(n*100)/100;return[o,a]},Oo=(s,e,t,r)=>{let n=e-s;return Math.min(e+t*n,n/2+s+r)},No=(s,e,t,r)=>Math.max(s+1,(e-s)/2+s),Bo=(s,e,t,r)=>{let n=Math.min(e-1,(e-s)/2+s);return n<1?s+1:n},Fo=(s,e,t,r)=>{let n=e-s,i=n/2+s,o=Math.max(s-Math.min(t*n,10),i-r);return o<0?s:o},un=(s,e,t,r,n)=>{let i=e;Math.abs(s-e)<=1&&(i=e+1);let o=Fo(s,i,t,r),a=Bo(s,i,t,r),u=No(s,i,t,r),c=Oo(s,i,t,r),p=Math.round(n(o,a)*100)/100,d=Math.round(n(u,c)*100)/100;return[p,d]};var Uo=s=>{let e=S(0,100)/1e3,t=S(0,10)>=5?1:-1;return s+s*e*t},ot=class{constructor(e){this.updating=!1;this.update=()=>{var e;if(this.range&&this.table){let t=(e=this.table)==null?void 0:e.data,{bid:r,ask:n,last:i,...o}=this.tickingColumns;if(t&&(t==null?void 0:t.length)>0){let a=Math.min(this.range.to,t.length);for(let u=this.range.from;u<a;u++){let c=0;if(S(0,10)<2){let d=this.table.data[u],f=t[u];if(r!==void 0&&n!==void 0){let{[r]:m,[n]:g}=f,[I,U]=un(m,g,10,5,$t);if(d[n]=U,d[r]=I,i!==void 0){let V=Math.round((g+(U-g)/2)*100)/100;d[i]=V}}for(let m of Object.values(o))if(S(0,10)<5){c+=1;let I=Uo(f[m]);this.table&&(d[m]=I)}this.table&&c>0&&this.table.updateRow(d)}}}}this.updating&&(this.timer=window.setTimeout(this.update,500))};this.tickingColumns=e}setRange(e){this.range=e,!this.updating&&this.table&&this.startUpdating()}setTable(e){this.table=e}startUpdating(){this.updating=!0,this.update()}stopUpdating(){this.updating=!1,this.timer&&(window.clearTimeout(this.timer),this.timer=void 0)}};var ln=[["AAL.L","Anglo American PLC","436.35 13:13","5.35 (1.24%)","5,799,089"],["ABF.L","Associated British Foods PLC","3,435.60 13:12","7.40 (0.21%)","86,808"],["ADM.L","Admiral Group PLC","1,627.00 13:13",""],["ADN.L","Aberdeen Asset Management PLC","334.00 13:13","2.50 (0.75%)","806,880"],["AHT.L","Ashtead Group PLC","1,027.00 13:13","6.00 (0.59%)","331,255"],["ANTO.L","Antofagasta PLC","484.10 13:13","11.70 (2.48%)","1,753,976"],["ARM.L","ARM Holdings PLC","1,058.00 13:13","3.00 (0.28%)","475,927"],["AV.L","Aviva PLC","493.97 13:13","2.23 (0.45%)","2,226,835"],["AZN.L","AstraZeneca PLC","4,399.50 13:13","2.50 (0.06%)","815,133"],["BA.L","BAE Systems PLC","478.10 13:13","4.30 (0.91%)","2,039,934"],["BAB.L","Babcock International Group PLC","988.00 13:13","9.50 (0.97%)","209,614"],["BARC.L","Barclays PLC","226.30 13:13","1.15 (0.51%)","6,575,664"],["BATS.L","British American Tobacco PLC","3,803.50 13:13","8.50 (0.22%)","465,110"],["BDEV.L","Barratt Developments PLC","576.00 13:13","0.50 (0.09%)","1,044,365"],["BG.L","BG Group PLC","1,013.50 13:13","5.50 (0.55%)","1,507,332"],["BKG.L","Berkeley Group Holdings (The) PLC","3,126.00 13:13","15.00 (0.48%)","95,071"],["BLND.L","British Land Co PLC","828.06 13:12","10.44 (1.25%)","1,802,548"],["BLT.L","BHP Billiton PLC","881.40 13:13","4.30 (0.49%)","4,947,287"],["BNZL.L","Bunzl PLC","1,875.40 13:05","4.60 (0.24%)","104,541"],["BP.L","BP PLC","381.50 13:13","2.95 (0.78%)","10,493,561"],["BRBY.L","Burberry Group PLC","1,269.00 13:13","7.00 (0.55%)","295,647"],["BT-A","L,BT Group PLC","489.20 13:13","3.70 (0.75%)","3,914,982"],["CCL.L","Carnival PLC","3,426.00 13:12","22.00 (0.64%)","86,257"],["CNA.L","Centrica PLC","212.80 13:13","0.60 (0.28%)","2,144,540"],["CPG.L","Compass Group PLC","1,054.00 13:08","5.00 (0.48%)","1,001,167"],["CPI.L","Capita PLC","1,235.00 13:11","1.00 (0.08%)","244,591"],["CRH.L","CRH PLC","1,783.20 13:12","17.80 (0.99%)","897,325"],["DC.L","DIXONS CARPHONE","462.10 13:11",""],["DGE.L","Diageo PLC","1,881.50 13:13","6.50 (0.34%)","756,906"],["DLG.L","Direct Line Insurance Group PLC","403.80 13:13","0.40 (0.10%)","1,095,340"],["EXPN.L","Experian PLC","1,191.00 13:12","2.00 (0.17%)","467,283"],["EZJ.L","easyJet PLC","1,682.00 13:12","28.00 (1.64%)","1,191,230"],["FRES.L","Fresnillo PLC","678.50 13:12","6.50 (0.97%)","381,871"],["GFS.L","G4S PLC","232.30 13:03","2.00 (0.85%)","1,096,551"],["GKN.L","GKN PLC","294.80 13:12","2.50 (0.86%)","792,247"],["GLEN.L","Glencore PLC","90.48 13:13","1.65 (1.86%)","41,631,528"],["GSK.L","GlaxoSmithKline PLC","1,345.00 13:13","0.50 (0.04%)","1,767,356"],["HIK.L","Hikma Pharmaceuticals PLC","2,010.00 13:04","57.00 (2.92%)","261,511"],["HL.L","Hargreaves Lansdown PLC","1,488.03 13:12","9.97 (0.67%)","372,261"],["HMSO.L","Hammerson PLC","597.50 13:11","3.50 (0.58%)","478,301"],["HSBA.L","HSBC Holdings PLC","519.70 13:13","0.50 (0.10%)","7,415,629"],["IAG.L","International Consolidated Airlines Group SA","575.40 13:12","16.10 (2.72%)","4,311,514"],["IHG.L","InterContinental Hotels Group PLC","2,481.00 13:12","19.00 (0.76%)","219,918"],["III.L","3i Group PLC","487.30 13:11","4.50 (0.92%)","189,987"],["IMT.L","Imperial Tobacco Group PLC","3,571.00 13:13","29.00 (0.81%)","926,816"],["INTU.L","intu properties PLC","319.90 13:09","4.60 (1.42%)","514,821"],["ISAT.L","Inmarsat PLC","1,054.44 13:13","3.44 (0.33%)","988,089"],["ITRK.L","Intertek Group PLC","2,643.00 13:14","3.00 (0.11%)","45,868"],["ITV.L","ITV PLC","267.30 13:14","2.60 (0.96%)","3,453,208"],["JMAT.L","Johnson Matthey PLC","2,445.00 13:14","29.00 (1.20%)","276,397"],["KGF.L","Kingfisher PLC","346.20 13:14","4.30 (1.23%)","1,021,408"],["LAND.L","Land Securities Group PLC","1,239.00 13:13","7.00 (0.56%)","384,973"],["LGEN.L","Legal & General Group PLC","266.00 13:14","1.60 (0.60%)","1,998,399"],["LLOY.L","Lloyds Banking Group PLC","73.86 13:14","0.02 (0.03%)","18,907,878"],["LSE.L","London Stock Exchange Group PLC","2,544.00 13:11","6.00 (0.24%)","129,657"],["MGGT.L","Meggitt PLC","386.00 13:15","3.20 (0.84%)","611,044"],["MKS.L","Marks & Spencer Group PLC","514.75 13:12","3.25 (0.63%)","920,128"],["MNDI.L","Mondi PLC","1,463.00 13:14","7.00 (0.48%)","383,546"],["MRW.L","Morrison (Wm) Supermarkets PLC","155.20 13:14",""],["NG.L","National Grid PLC","926.40 13:14","1.10 (0.12%)","1,659,592"],["NXT.L","Next PLC","7,765.00 13:11","95.00 (1.21%)","114,062"],["OML.L","Old Mutual PLC","198.50 13:14","0.40 (0.20%)","2,040,849"],["PRU.L","Prudential PLC","1,499.50 13:15","14.00 (0.93%)","580,870"],["PSON.L","Pearson PLC","794.00 13:09","5.00 (0.63%)","1,177,953"],["RB.L","Reckitt Benckiser Group PLC","6,293.00 13:14","34.00 (0.54%)","281,172"],["RBS.L","Royal Bank of Scotland Group PLC","313.40 13:14","2.40 (0.77%)","2,100,058"],["RDSA.L","Royal Dutch Shell PLC","1,636.00 13:14","18.00 (1.11%)","2,467,461"],["RDSB.L","Royal Dutch Shell PLC","1,652.00 13:15","14.50 (0.89%)","1,457,434"],["REL.L","Reed Elsevier PLC","1,170.00 13:14","0.00 (0.00%)","908,802"],["RIO.L","Rio Tinto PLC","2,235.00 13:15","21.00 (0.95%)","2,190,722"],["RMG.L","Royal Mail PLC","453.50 13:14","1.20 (0.26%)","995,316"],["RR.L","Rolls-Royce Group PLC","546.63 13:14","8.38 (1.51%)","2,792,915"],["RRS.L","Randgold Resources Ltd","3,929.00 13:14","0.00 (0.00%)","135,524"],["RSA.L","RSA Insurance Group PLC","437.10 13:14","0.10 (0.02%)","395,477"],["SAB.L","SABMiller PLC","4,011.00 13:15","1.00 (0.02%)","892,451"],["SBRY.L","Sainsbury (J) PLC","255.80 13:14","7.40 (2.98%)","2,395,670"],["SDR.L","Schroders PLC","2,930.00 13:09","12.00 (0.41%)","44,674"],["SGE.L","Sage Group (The) PLC","545.50 13:13","0.50 (0.09%)","539,717"],["SHP.L","Shire PLC","4,685.00 13:14","22.00 (0.47%)","221,318"],["SKY.L","SKY","1,095.00 13:12","4.00 (0.37%)","925,016"],["SL.L","Standard Life PLC","399.90 13:14","3.20 (0.79%)","861,636"],["SMIN.L","Smiths Group PLC","992.50 13:14","27.50 (2.70%)","640,309"],["SN.L","Smith & Nephew PLC","1,110.00 13:14","9.00 (0.82%)","480,018"],["SPD.L","Sports Direct International PLC","694.50 13:11","1.50 (0.22%)","157,981"],["SSE.L","SSE PLC","1,463.00 13:13","2.00 (0.14%)","562,454"],["STAN.L","Standard Chartered PLC","583.00 13:14","0.60 (0.10%)","2,018,697"],["STJ.L","St James's Place PLC","964.00 13:14","11.00 (1.13%)","418,480"],["SVT.L","Severn Trent PLC","2,199.00 13:12","1.00 (0.05%)","95,342"],["TPK.L","Travis Perkins PLC","1,945.00 13:13","4.00 (0.21%)","92,916"],["TSCO.L","Tesco PLC","171.54 13:14","2.54 (1.50%)","9,831,136"],["TUI.L","TUI AG","1,115.00 13:10","5.00 (0.45%)","458,970"],["TW.L","Taylor Wimpey PLC","183.90 13:15","1.10 (0.59%)","3,180,729"],["ULVR.L","Unilever PLC","2,791.00 13:14","29.00 (1.03%)","824,827"],["UU.L","United Utilities Group PLC","959.00 13:10","2.50 (0.26%)","436,911"],["VOD.L","Vodafone Group PLC","224.25 13:15","1.30 (0.58%)","17,572,036"],["WOS.L","Wolseley PLC","3,657.00 13:14","4.00 (0.11%)","179,536"],["WPP.L","WPP PLC","1,502.00 13:15","12.00 (0.79%)","857,887"],["WTB.L","Whitbread PLC","4,484.00 13:16","60.00 (1.32%)","141,036"]];var cn=[["Apple Inc","AAPL",11.007,174.94,.15,"(0.09%)"],["Microsoft Corp","MSFT",9.61,316.98,-.03,"(-0.01%)"],["Amazon.com Inc","AMZN",5.401,129.31,.19,"(0.14%)"],["NVIDIA Corp","NVDA",4.101,415.74,-.36,"(-0.09%)"],["Meta Platforms Inc","META",3.729,299.42,.34,"(0.11%)"],["Tesla Inc","TSLA",3.285,244.13,-.75,"(-0.31%)"],["Alphabet Inc","GOOGL",3.133,130.49,.24,"(0.18%)"],["Alphabet Inc","GOOG",3.085,131.49,.24,"(0.18%)"],["Broadcom Inc","AVGO",2.896,833.04,3.96,"(0.48%)"],["Costco Wholesale Corp","COST",2.137,557.85,-.74,"(-0.13%)"],["PepsiCo Inc","PEP",2.096,174.84,-.43,"(-0.25%)"],["Adobe Inc","ADBE",2.033,511.42,-1.48,"(-0.29%)"],["Cisco Systems Inc","CSCO",1.887,53.68,.11,"(0.20%)"],["Comcast Corp","CMCSA",1.633,45.3,-.01,"(-0.01%)"],["Netflix Inc","NFLX",1.478,379.89,.08,"(0.02%)"],["T-Mobile US Inc","TMUS",1.43,140.18,.83,"(0.60%)"],["Advanced Micro Devices Inc","AMD",1.348,96.09,-.11,"(-0.12%)"],["Texas Instruments Inc","TXN",1.264,161,.69,"(0.43%)"],["Intel Corp","INTC",1.26,34.19,.01,"(0.01%)"],["Amgen Inc","AMGN",1.251,271.18,3.48,"(1.30%)"],["Intuit Inc","INTU",1.226,509,.43,"(0.08%)"],["Honeywell International Inc","HON",1.103,188.67,-1.12,"(-0.59%)"],["QUALCOMM Inc","QCOM",1.046,107.53,-.16,"(-0.14%)"],["Applied Materials Inc","AMAT",.982,136.32,.15,"(0.11%)"],["Booking Holdings Inc","BKNG",.941,3,19.2,-43.3,"(-1.42%)"],["Starbucks Corp","SBUX",.926,93.8,.12,"(0.12%)"],["Intuitive Surgical Inc","ISRG",.867,288.5,.3,"(0.10%)"],["Automatic Data Processing Inc","ADP",.854,239.45,.1,"(0.04%)"],["Mondelez International Inc","MDLZ",.835,71.25,.82,"(1.16%)"],["Gilead Sciences Inc","GILD",.814,75.47,.46,"(0.61%)"],["Vertex Pharmaceuticals Inc","VRTX",.794,353.67,4.14,"(1.18%)"],["Regeneron Pharmaceuticals Inc","REGN",.763,828.09,3.25,"(0.39%)"],["Analog Devices Inc","ADI",.752,176.82,1.34,"(0.76%)"],["Lam Research Corp","LRCX",.702,620,.89,"(0.14%)"],["Micron Technology Inc","MU",.646,68.9,.02,"(0.03%)"],["Palo Alto Networks Inc","PANW",.604,228.7,.19,"(0.08%)"],["Synopsys Inc","SNPS",.587,447.12,.27,"(0.06%)"],["Charter Communications Inc","CHTR",.581,441.88,-3.33,"(-0.75%)"],["MercadoLibre Inc","MELI",.562,1,275.5,-1.47,"(-0.11%)"],["PayPal Holdings Inc","PYPL",.559,57.9,.02,"(0.03%)"],["CSX Corp","CSX",.54,31.23,.03,"(0.09%)"],["Cadence Design Systems Inc","CDNS",.539,230.83,.17,"(0.07%)"],["KLA Corp","KLAC",.53,456.11,4.29,"(0.95%)"],["PDD Holdings Inc ADR","PDD",.521,95.93,-.01,"(-0.01%)"],["Marriott International Inc/MD","MAR",.505,193.9,-.46,"(-0.23%)"],["Monster Beverage Corp","MNST",.498,54.48,-.04,"(-0.08%)"],["Airbnb Inc","ABNB",.491,132.09,-.11,"(-0.08%)"],["O'Reilly Automotive Inc","ORLY",.485,936.67,.65,"(0.07%)"],["Cintas Corp","CTAS",.446,505.27,.52,"(0.10%)"],["ASML Holding NV","ASML",.438,585,-2.1,"(-0.36%)"],["NXP Semiconductors NV","NXPI",.434,196.76,-.04,"(-0.02%)"],["Workday Inc","WDAY",.414,235.55,4.73,"(2.05%)"],["Lululemon Athletica Inc","LULU",.405,386.36,-1.69,"(-0.44%)"],["Keurig Dr Pepper Inc,KDP",.404,33.25,.13,"(0.39%)"],["Fortinet Inc","FTNT",.401,58.29,.05,"(0.09%)"],["Marvell Technology Inc","MRVL",.388,52.38,.08,"(0.14%)"],["PACCAR Inc","PCAR",.38,84.97,.04,"(0.04%)"],["Old Dominion Freight Line Inc","ODFL",.38,401.01,.35,"(0.09%)"],["Autodesk Inc","ADSK",.379,204.07,.03,"(0.01%)"],["Kraft Heinz Co/The","KHC",.368,34.27,.11,"(0.31%)"],["Microchip Technology Inc","MCHP",.36,77,-.08,"(-0.10%)"],["Copart Inc","CPRT",.358,43.26,.1,"(0.22%)"],["American Electric Power Co Inc","AEP",.357,79.23,.06,"(0.08%)"],["Paychex Inc","PAYX",.355,113.01,.06,"(0.06%)"],["Exelon Corp","EXC",.35,40.28,.07,"(0.16%)"],["ON Semiconductor Corp","ON",.341,93.87,.06,"(0.06%)"],["AstraZeneca PLC ADR","AZN",.339,67.35,-.49,"(-0.72%)"],["Seagen Inc","SGEN",.336,212.18,-1.52,"(-0.71%)"],["Ross Stores Inc","ROST",.335,111.71,.05,"(0.04%)"],["Moderna Inc","MRNA",.331,100.32,.33,"(0.33%)"],["Biogen Inc","BIIB",.326,257.93,.25,"(0.10%)"],["Crowdstrike Holdings Inc","CRWD",.319,162.85,.28,"(0.17%)"],["IDEXX Laboratories Inc","IDXX",.316,439.41,3.72,"(0.85%)"],["Baker Hughes Co","BKR",.307,35.44,.04,"(0.10%)"],["Constellation Energy Corp","CEG",.307,110.41,.05,"(0.04%)"],["Cognizant Technology Solutions Corp","CTSH",.303,70.19,.58,"(0.83%)"],["Verisk Analytics Inc","VRSK",.303,242.05,.1,"(0.04%)"],["Dexcom Inc","DXCM",.3,88.3,.8,"(0.92%)"],["Trade Desk Inc/The","TTD",.293,76.38,.03,"(0.03%)"],["Xcel Energy Inc","XEL",.284,59.76,.03,"(0.04%)"],["Electronic Arts Inc","EA",.279,118.38,-.63,"(-0.53%)"],["CoStar Group Inc","CSGP",.277,78.18,.12,"(0.15%)"],["GLOBALFOUNDRIES Inc","GFS",.273,57.21,.38,"(0.67%)"],["Fastenal Co","FAST",.268,54.32,.11,"(0.20%)"],["Atlassian Corp","TEAM",.253,196.01,.55,"(0.28%)"],["GE HealthCare Technologies Inc","GEHC",.252,63.78,-.56,"(-0.86%)"],["Warner Bros Discovery Inc","WBD",.244,11.09,-.02,"(-0.14%)"],["Diamondback Energy Inc","FANG",.235,150.7,.13,"(0.09%)"],["Datadog Inc","DDOG",.23,88.81,.05,"(0.06%)"],["ANSYS Inc","ANSS",.227,300.6,-2.31,"(-0.76%)"],["eBay Inc","EBAY",.203,43.22,.09,"(0.20%)"],["Dollar Tree Inc","DLTR",.201,104.77,.27,"(0.25%)"],["Align Technology Inc","ALGN",.2,297.25,-1.31,"(-0.44%)"],["Zscaler Inc","ZS",.188,151.8,.09,"(0.06%)"],["Illumina Inc","ILMN",.183,132.31,-.13,"(-0.10%)"],["Walgreens Boots Alliance Inc","WBA",.161,21.18,.06,"(0.28%)"],["Zoom Video Communications Inc","ZM",.151,68.57,-.29,"(-0.41%)"],["Enphase Energy Inc","ENPH",.148,120.41,.49,"(0.41%)"],["Sirius XM Holdings Inc","SIRI",.137,4.05,.02,"(0.50%)"],["JD.com Inc ADR","JD",.117,30.43,.02,"(0.05%)"],["Lucid Group Inc","LCID",.102,5.14,.03,"(0.49%)"]];var pn=[["Apple Inc","AAPL",6.992488,171.9,1.47,"(0.86%)"],["Microsoft Corp","MSFT",6.487978,314.55,1.76,"(0.56%)"],["Amazon.com Inc","AMZN",3.193379,126.25,.27,"(0.22%)"],["Nvidia Corp","NVDA",2.928461,433.11,8.43,"(1.99%)"],["Alphabet Inc Cl A","GOOGL",2.162218,132.93,2.39,"(1.83%)"],["Tesla Inc","TSLA",1.854311,246.56,6.06,"(2.52%)"],["Alphabet Inc Cl C","GOOG",1.85251,133.81,2.35,"(1.78%)"],["Meta Platforms Inc Class A","META",1.847731,305.93,8.19,"(2.75%)"],["Berkshire Hathaway Inc Cl B","BRK.B",1.82184,358.67,.89,"(0.25%)"],["Exxon Mobil Corp","XOM",1.343563,118.97,-1.23,"(-1.03%)"],["Unitedhealth Group Inc","UNH",1.302884,510.04,6.31,"(1.25%)"],["Eli Lilly & Co","LLY",1.224046,546.65,-3.11,"(-0.57%)"],["Jpmorgan Chase & Co","JPM",1.182918,148.23,2.45,"(1.68%)"],["Johnson & Johnson W/d","JNJ",1.056344,156.83,-.28,"(-0.18%)"],["Visa Inc Class a Shares","V",1.029636,231.97,2.47,"(1.08%)"],["Procter & Gamble Co","PG",.969793,145.75,-1.59,"(-1.08%)"],["Broadcom Inc","AVGO",.941177,835.33,18.52,"(2.27%)"],["Mastercard Inc A","MA",.918779,400.65,5.17,"(1.31%)"],["Chevron Corp","CVX",.847353,170.55,-.49,"(-0.28%)"],["Home Depot Inc","HD",.847289,304.35,2.53,"(0.84%)"],["Abbvie Inc","BBV",.754672,152.14,-.99,"(-0.65%)"],["Merck & Co. Inc.","MRK",.736434,104.2,.26,"(0.25%)"],["Costco Wholesale Corp","COST",.697258,569.05,5.52,"(0.98%)"],["Pepsico Inc","PEP",.651768,168.92,-.65,"(-0.38%)"],["Walmart Inc","WMT",.644449,161.87,.15,"(0.09%)"],["Adobe Inc","ADBE",.639652,507.17,4.57,"(0.91%)"],["Coca Cola Co","KO",.60801,55.82,-.13,"(-0.23%)"],["Cisco Systems Inc","CSCO",.605326,53.97,.77,"(1.44%)"],["Accenture Plc Cl A","ACN",.55372,298.5,-15.9,"(-5.05%)"],["Salesforce Inc","CRM",.551342,204.46,1.73,"(0.85%)"],["Thermo Fisher Scientific Inc","TMO",.536951,503.47,5.18,"(1.04%)"],["Mcdonald S Corp","MCD",.536457,265.83,2.19,"(0.83%)"],["Bank of America Corp","BAC",.526405,27.51,.24,"(0.86%)"],["Comcast Corp Class A","CMCSA",.512537,45.17,.57,"(1.27%)"],["Linde Plc","LIN",.506835,375.48,3.47,"(0.93%)"],["Pfizer Inc","PFE",.506043,32.09,-.02,"(-0.05%)"],["Netflix Inc","NFLX",.467192,377.77,.18,"(0.05%)"],["Abbott Laboratories","ABT",.462893,97.52,1.99,"(2.08%)"],["Oracle Corp","ORCL",.459877,106.29,1.67,"(1.60%)"]];var dn=[["CKH HOLDINGS","00001.HK",41.9,1.15,"+2.822%","5.15M","215.13M",4.38,.31,"6.98%","160.48B"],["CLP HOLDINGS","00002.HK",57.95,-.1,"-0.172%","3.32M","193.19M",156.62,1.39,"5.35%","146.41B"],["HK & CHINA GAS","00003.HK",5.46,.13,"+2.439%","16.16M","88.00M",19.43,1.66,"6.41%","101.88B"],["HSBC HOLDINGS,00005.HK",61.7,1.1,"+1.815%","22.19M","1.37B",10.54,.86,"4.05%",1,"227.60B"],["POWER ASSETS","00006.HK",37.9,-.25,"-0.655%","4.23M","160.75M",14.3,.93,"7.44%","80.77B"],["HANG SENG BANK","00011.HK",97.45,2.95,"+3.122%","2.54M","247.44M",19.69,1.01,"4.21%","186.31B"],["HENDERSON LAND","00012.HK",20.65,.85,"+4.293%","5.07M","103.70M",10.81,.31,"8.72%","99.97B"],["SHK PPT","00016.HK",83.8,3.25,"+4.035%","8.25M","685.41M",10.16,.4,"5.91%","242.83B"],["NEW WORLD DEV","00017.HK",15.24,.8,"+5.540%","12.95M","196.19M",30.48,.18,"13.52%","38.35B"],["GALAXY ENT","00027.HK",47.15,1.9,"+4.199%","11.97M","560.21M","No Profit",3.22,"0.00%","206.21B"],["MTR CORPORATION","00066.HK",31,.8,"+2.649%","4.68M","144.86M",19.5,1.07,"4.23%","192.64B"],["HANG LUNG PPT","00101.HK",10.72,.56,"+5.512%","7.68M","81.99M",12.61,.36,"7.28%","48.23B"],["GEELY AUTO","00175.HK",9.24,.17,"+1.874%","18.77M","173.30M",16.06,1.15,"2.27%","92.99B"],["ALI HEALTH","00241.HK",4.88,.47,"+10.658%","53.62M","257.82M",108.09,3.81,"0.00%","66.04B"],["CITIC","00267.HK",7.2,.2,"+2.857%","11.54M","82.96M",2.78,.28,"9.04%","209.45B"],["WH GROUP","00288.HK",4.11,.08,"+1.985%","18.94M","77.65M",4.93,.7,"7.30%","52.73B"],["CHINA RES BEER","00291.HK",42.95,1.2,"+2.874%","4.83M","207.98M",28.41,4.57,"1.41%","139.34B"],["OOIL","00316.HK",104.5,-.4,"-0.381%","296.54K","30.98M",.89,.66,"78.90%","69.01B"],["TINGYI","00322.HK",10.94,.18,"+1.673%","2.91M","31.81M",20.75,4.09,"9.39%","61.64B"],["SINOPEC CORP","00386.HK",4.28,-.01,"-0.233%","92.43M","396.61M",6.94,.58,"9.36%","105.92B"],["HKEX","00388.HK",292.6,9,"+3.173%","4.61M","1.34B",36.76,7.46,"2.44%","370.97B"],["TECHTRONIC IND","00669.HK",76,1.35,"+1.808%","5.47M","414.78M",16.54,3.43,"2.43%","139.45B"],["CHINA OVERSEAS","00688.HK",16.24,.52,"+3.308%","13.15M","212.60M",6.76,.44,"4.93%","177.74B"],["TENCENT","00700.HK",306.2,8.8,"+2.959%","11.25M","3.43B",13.74,3.6,"0.78%",2,"926.16B"],["CHINA UNICOM","00762.HK",5.68,-.05,"-0.873%","9.23M","52.77M",9.16,.45,"5.44%","173.80B"],["LINK REIT","00823.HK",38.4,1.45,"+3.924%","12.04M","460.96M",5.42,.52,"7.03%","98.38B"],["CHINA RES POWER","00836.HK",14.94,.32,"+2.189%","9.91M","147.81M",10.23,.87,"3.92%","71.87B"],["PETROCHINA","00857.HK",5.9,0,"0.000%","64.23M","380.44M",6.38,.7,"8.08%","124.48B"],["XINYI GLASS","00868.HK",10.14,.17,"+1.705%","3.75M","38.02M",8.01,1.3,"6.11%","42.22B"],["ZHONGSHENG HLDG","00881.HK",22.05,1.45,"+7.039%","6.76M","147.71M",7.08,1.07,"4.94%","52.72B"],["CNOOC","00883.HK",13.78,-.02,"-0.145%","26.37M","365.08M",4.03,.97,"19.09%","655.47B"],["CCB","00939.HK",4.42,.06,"+1.376%","233.61M","1.03B",3.06,.35,"9.93%",1,"062.64B"],["CHINA MOBILE","00941.HK",65.7,.25,"+0.382%","7.82M","516.10M",9.91,.96,"6.71%",1,"404.46B"],["LONGFOR GROUP","00960.HK",14.08,.9,"+6.829%","10.88M","150.68M",3.06,.55,"9.05%","92.81B"],["XINYI SOLAR","00968.HK",5.86,.28,"+5.018%","15.99M","92.88M",13.64,1.75,"3.41%","52.17B"],["SMIC","00981.HK",20.05,.25,"+1.263%","13.10M","264.32M",11.17,1.06,"0.00%","159.31B"],["LENOVO GROUP","00992.HK",8.07,.25,"+3.197%","33.60M","270.50M",7.61,2.23,"4.71%","97.87B"],["CKI HOLDINGS","01038.HK",37.05,-.2,"-0.537%","1.44M","53.73M",12.03,.78,"6.83%","93.35B"],["HENGAN INT'L","01044.HK",24.95,.2,"+0.808%","2.62M","64.97M",13.35,1.32,"6.33%","28.99B"],["CHINA SHENHUA","01088.HK",25.4,.35,"+1.397%","7.98M","203.11M",6.14,1.13,"11.33%","85.79B"],["CSPC PHARMA","01093.HK",5.74,.05,"+0.879%","29.29M","167.41M",9.96,2.01,"3.66%","68.32B"],["SINOPHARM","01099.HK",22.7,.2,"+0.889%","2.07M","46.80M",7.37,.92,"4.08%","30.46B"],["CHINA RES LAND","01109.HK",31.2,1,"+3.311%","9.88M","305.88M",7.02,.81,"5.07%","222.49B"],["CK ASSET","01113.HK",41.25,1.25,"+3.125%","8.57M","352.44M",6.9,.39,"5.53%","146.47B"],["SINO BIOPHARM","01177.HK",2.83,.02,"+0.712%","26.30M","74.09M",18.37,1.59,"4.24%","53.21B"],["CHINA RES MIXC","01209.HK",31.6,1.6,"+5.333%","3.07M","96.42M",28.97,4.48,"2.87%","72.13B"],["BYD COMPANY","01211.HK",242,7,"+2.979%","3.90M","938.50M",37.57,5.63,"0.53%","265.72B"],["AIA","01299.HK",63.85,.95,"+1.510%","38.75M","2.48B",408.88,2.53,"2.41%","735.40B"],["CHINAHONGQIAO","01378.HK",7.67,.28,"+3.789%","13.05M","99.58M",7.27,.76,"6.65%","72.68B"],["ICBC","01398.HK",3.77,.07,"+1.892%","233.48M","881.67M",3.45,.36,"9.08%","327.21B"],["XIAOMI-W","01810.HK",12.34,.62,"+5.290%","78.53M","960.98M",109.39,1.9,"0.00%","308.83B"],["BUD APAC","01876.HK",15.46,.16,"+1.046%","16.17M","250.45M",28.65,2.44,"1.91%","204.74B"],["SANDS CHINA LTD","01928.HK",24,.95,"+4.121%","19.98M","475.93M","No Profit","N/A","0.00%","194.24B"],["CHOW TAI FOOK","01929.HK",11.8,.28,"+2.431%","4.88M","57.68M",21.93,3.64,"10.34%","118.00B"],["WHARF REIC","01997.HK",30.25,1.4,"+4.853%","4.23M","127.31M","No Profit",.48,"4.33%","91.85B"],["ANTA SPORTS","02020.HK",88.15,4.4,"+5.254%","4.82M","422.51M",27.71,6.16,"1.52%","249.70B"],["WUXI BIO","02269.HK",45.65,1.55,"+3.515%","17.91M","811.49M",38.18,4.88,"0.00%","194.01B"],["SHENZHOU INTL","02313.HK",75,4.6,"+6.534%","5.52M","410.68M",21.87,3.25,"2.55%","112.74B"],["PING AN","02318.HK",44.85,.85,"+1.932%","23.05M","1.03B",8.28,.85,"6.09%","334.02B"],["MENGNIU DAIRY","02319.HK",26.25,1.5,"+6.061%","8.58M","223.15M",17.34,2.3,"1.73%","103.42B"],["LI NING","02331.HK",32.95,1.5,"+4.769%","22.54M","738.37M",18.8,3.16,"1.58%","86.86B"],["SUNNY OPTICAL","02382.HK",54.7,1.05,"+1.957%","5.62M","308.60M",22.01,2.44,"0.91%","60.00B"],["BOC HONG KONG","02388.HK",21.45,.3,"+1.418%","6.53M","140.32M",8.38,.75,"6.33%","226.79B"],["CHINA LIFE","02628.HK",12.2,.24,"+2.007%","13.53M","165.07M",9.49,.7,"4.53%","90.78B"],["ENN ENERGY","02688.HK",65,1.15,"+1.801%","3.06M","198.69M",11.08,1.67,"4.48%","73.53B"],["ZIJIN MINING","02899.HK",11.98,.16,"+1.354%","16.20M","194.50M",13.97,3.14,"1.88%","68.73B"],["MEITUAN-W","03690.HK",114.6,3.8,"+3.430%","19.17M","2.19B","No Profit",4.89,"0.00%","715.43B"],["HANSOH PHARMA","03692.HK",10.66,.16,"+1.524%","17.56M","187.72M",21.48,2.47,"0.94%","63.25B"],["CM BANK","03968.HK",32.7,.1,"+0.307%","11.13M","363.99M",5.51,.86,"6.00%","150.12B"],["BANK OF CHINA","03988.HK",2.74,.05,"+1.859%","275.47M","754.54M",3.33,.33,"9.55%","229.13B"],["CG SERVICES","06098.HK",8.08,.25,"+3.193%","16.08M","128.87M",12.42,.65,"5.20%","27.01B"],["JD HEALTH","06618.HK",40.6,2.95,"+7.835%","7.75M","312.36M",299.91,2.56,"0.00%","129.12B"],["HAIER SMARTHOME","06690.HK",24.65,1.15,"+4.894%","7.24M","178.37M",13.83,2.21,"2.59%","70.46B"],["HAIDILAO","06862.HK",21,.6,"+2.941%","6.86M","143.79M",74.46,13.94,"0.55%","117.05B"],["JD-SW","09618.HK",115.1,4,"+3.600%","7.43M","852.28M",30.73,1.5,"6.38%","360.24B"],["NONGFU SPRING","09633.HK",45,1.5,"+3.448%","3.69M","165.62M",52.49,18.63,"1.71%","226.56B"],["BIDU-SW","09888.HK",133.4,4.6,"+3.571%","5.82M","772.73M",47.3,1.5,"0.00%","377.37B"],["TRIP.COM-S","09961.HK",279.2,7,"+2.572%","1.25M","349.59M",114.05,1.4,"0.00%","176.65B"],["BABA-SW","09988.HK",85.6,2.6,"+3.133%","34.61M","2.96B",21.65,1.62,"0.00%",1,"837.13B"],["NTES-S","09999.HK",159.5,8.3,"+5.489%","5.02M","797.10M",22.7,4.63,"1.36%","546.99B"]];var St=[];for(let s of ln){let[e,t,r,n,i]=s,o=".FTSE100",a="BUY",u=1;St.push([o,n,t,r,e,`${e}-${o}`,a,i,u])}for(let s of dn){let[e,t,r,n,,i]=s,o=".HSI",a="BUY",u=1;St.push([o,n,e,r,t,`${t}-${o}`,a,i,u])}for(let s of cn){let[e,t,r,n,i]=s,o=".NASDAQ100",a="BUY",u=1e3;St.push([o,i,e,n,t,`${t}-${o}`,a,u,r])}for(let s of pn){let[e,t,r,,n]=s,i=".SP500",o="BUY",a=1e3,u=0;St.push([i,n,e,u,t,`${t}-${i}`,o,a,r])}var at=St;var{bid:Go,bidSize:qo,ask:Wo,askSize:Ho,last:$o}=J(P.prices),Ko=new ot({bid:Go,bidSize:qo,ask:Wo,askSize:Ho,last:$o}),hn=[];for(let[,,,s,e]of at){let t=parseFloat(String(s));if(!isNaN(t)){let[r,n]=an(5,$t),i=S(1e3,3e3),o=S(1e3,3e3),a=t+S(0,1)/10,u=t+S(0,1)/10,c=t+S(0,1)/10,p="C",d="close";hn.push([n,i,r,o,a,u,c,p,e,d])}}var zo=new F(P.prices,hn,J(P.prices),Ko),fn=zo;var De=s=>Object.values(ee[s].columns).reduce((e,t,r)=>(e[t.name]=r,e),{}),xe={algoType:De("algoType"),basket:De("basket"),basketTrading:De("basketTrading"),basketTradingConstituent:De("basketTradingConstituent"),basketConstituent:De("basketConstituent"),basketTradingConstituentJoin:De("basketTradingConstituentJoin"),priceStrategyType:De("priceStrategyType")},mn=new F(ee.basketConstituent,at,xe.basketConstituent),gn=new F(ee.basketTrading,[],xe.basketTrading),jo=1,Fr=new F(ee.basketTradingConstituent,[],xe.basketTradingConstituent),bn=(s,e,t="BUY",r="OFF MARKET")=>[s,e,0,1.25,`steve-${jo++}`,t,r,1e6,125e4,100];function Qo(s,e){let t=bn(s,e);gn.insert(t);let{basketId:r}=De("basketConstituent");mn.data.filter(i=>i[r]===s).forEach(([,,i,,o,,,a,u])=>{let c="",p="",U="",V="BUY",E="venue",{instanceId:v}=xe.basketTrading,T=t[v],_=[c,p,s,i,T,`${T}-${o}`,95,0,0,0,0,U,a,o,V,E,u];Fr.insert(_)})}async function Jo(s){console.log(`RPC call erceived ${s.rpcName}`)}async function Xo(s){let[e]=s.params;console.log(`RPC call erceived ${s.rpcName} ${e}`)}async function Yo(s){console.log(`RPC call erceived ${s.rpcName}`)}async function Zo(s){let{params:[e,t]}=s;Qo(e,t)}var ea={algoType:new F(ee.algoType,[["Sniper",0],["Dark Liquidity",1],["VWAP",2],["POV",3],["Dynamic Close",4]],xe.algoType),basket:new F(ee.basket,[[".NASDAQ100",".NASDAQ100",0,0],[".HSI",".HSI",0,0],[".FTSE100",".FTSE100",0,0],[".SP500",".SP500",0,0]],xe.basket),basketConstituent:mn,basketTrading:gn,basketTradingConstituent:Fr,basketTradingConstituentJoin:Ht({module:"BASKET",table:"basketTradingConstituentJoin"},Fr,fn,"ric"),priceStrategyType:new F(ee.priceStrategyType,[["Peg to Near Touch",0],["Far Touch",1],["Limit",2],["Algo",3]],xe.priceStrategyType)},ta={algoType:void 0,basket:{name:"ROOT",menus:[{context:"selected-rows",filter:"",name:"Add Basket",rpcName:"CREATE_NEW_BASKET"}]},basketConstituent:void 0,basketTrading:void 0,basketTradingConstituent:void 0,basketTradingConstituentJoin:void 0,priceStrategyType:void 0},ra={algoType:void 0,basket:[{rpcName:"createBasket",service:Zo}],basketConstituent:void 0,basketTrading:[{rpcName:"sendToMarket",service:Xo},{rpcName:"takeOffMarket",service:Yo}],basketTradingConstituent:void 0,basketTradingConstituentJoin:[{rpcName:"addConstituent",service:Jo}],priceStrategyType:void 0},sa=s=>ee[s].columns,na=s=>{let e=sa(s),{key:t}=ee[s];return new st({columnDescriptors:e,dataMap:xe[s],keyColumn:t,menu:ta[s],rpcServices:ra[s],table:ea[s]})},ia=async()=>[],oa={createDataSource:na,typeaheadHook:()=>ia},yn=oa;var Gn=Zn(Bn());var Fn=["CAD","GBX","USD","EUR","GBP"];var Un={L:["London PLC","XLON/LSE-SETS"],N:["Corporation","XNGS/NAS-GSM"],AS:["B.V.","XAMS/ENA-MAIN"],OQ:["Co.","XNYS/NYS-MAIN"],PA:["Paris","PAR/EUR_FR"],MI:["Milan","MIL/EUR_IT"],FR:["Frankfurt","FR/EUR_DE"],AT:["Athens","AT/EUR_GR"]},Ur=["L","N","OQ","AS","PA","MI","FR","AT"];var Gr=[1,2,5,10,50,50,70,100,100,100,120,150,150,200,500,700,1e3,2e3,2500,5e3,1e4];var qn={bbg:0,currency:1,description:2,exchange:3,string:4,number:5,ric:6,price:7},ut=[],Ne=Array.from("ABCEFGHKMNOPQRTUVWYZ"),Pa=()=>{let s=S(0,1e4),e=S(1,10);return s/e},Va=performance.now();for(let s of Ne)for(let e=0;e<1e4;e++){let t=Ne[S(0,Ne.length-1)],r=Ne[S(0,Ne.length-1)],n=Ne[S(0,Ne.length-1)],i=Ur[S(0,Ur.length-1)],o=s+t+r+n+"."+i,a=s+t+r+n+" "+i,u=`${o} description`,c=Fn[S(0,4)],p=(0,Gn.isinGenerator)(),d=Gr[S(0,Gr.length-1)],f=Un[i][1],m=Pa();ut.push([a,c,u,f,String(p),d,o,m])}var _a=performance.now();console.log(`generating 10,000 instruments took ${_a-Va} ms`);var La=new F(P.instruments,ut,J(P.instruments));var qr=La;var Aa=ut.map(s=>s.slice(0,-1).concat([S(0,1)===1,S(0,1)===1])),Oa=new F(P.instrumentsExtended,Aa,J(P.instrumentsExtended)),Wn=Oa;var{bid:Na,bidSize:Ba,ask:Fa,askSize:Ua}=J(P.prices),Ga=new ot({bid:Na,bidSize:Ba,ask:Fa,askSize:Ua}),qa=["ric","price"],Hn=ut.map(s=>{let{ric:e,price:t}=qa.reduce((m,g)=>({...m,[g]:s[qn[g]]}),{}),r=S(0,10),n=t+r/2,i=S(1e3,3e3),o=t-r/2,a=S(1e3,3e3),u=t+S(0,1)/10,c=t+S(0,1)/10,p=t+S(0,1)/10;return[n,i,o,a,u,c,p,"C",e,"close"]});for(let[,,,s,e]of at){let t=parseFloat(String(s));if(!isNaN(t)){let r=S(0,10),n=t+r/2,i=S(1e3,3e3),o=t-r/2,a=S(1e3,3e3),u=t+S(0,1)/10,c=t+S(0,1)/10,p=t+S(0,1)/10,d="C",f="close";Hn.push([n,i,o,a,u,c,p,d,e,f])}}var Wa=new F(P.prices,Hn,J(P.prices),Ga);var Wr=Wa;var $n={childOrders:new F(P.childOrders,[],J(P.childOrders)),instruments:qr,instrumentsExtended:Wn,instrumentPrices:Ht({module:"SIMUL",table:"instrumentPrices"},qr,Wr,"ric"),orders:new F(P.orders,[],J(P.orders)),parentOrders:new F(P.parentOrders,[],J(P.parentOrders)),prices:Wr},Ha=s=>{let e=P[s];if(e)return e.columns;throw Error(`simul-module no schema found for table SIMUL ${s}`)},$a=s=>{let e=Ha(s);return new st({columnDescriptors:e,keyColumn:P[s].key,table:$n[s]})},Ka=([s,e,t])=>{let r=$n[s.table];if(r)return qt(r,e,t);throw Error(`SIMUL suggestionFetcher, unknown table ${s.module} ${s.table}`)},za={createDataSource:$a,typeaheadHook:()=>Ka},Kn=za;var ja={BASKET:yn,SIMUL:Kn},Af=s=>ja[s];export{Lo as DefaultColumnGenerator,_o as DefaultRowGenerator,st as TickingArrayDataSource,ah as VuuColumnGenerator,bn as createBasketTradingRow,eu as getAllSchemas,uh as getColumnAndRowGenerator,tu as getSchema,lh as populateArray,ei as schemas,Af as vuuModule};
5
2655
  //# sourceMappingURL=index.js.map