@vuu-ui/vuu-data-test 0.8.14 → 0.8.15
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,5 @@
|
|
|
1
|
-
var $s=Object.create;var $r=Object.defineProperty;var Ks=Object.getOwnPropertyDescriptor;var zs=Object.getOwnPropertyNames;var qs=Object.getPrototypeOf,js=Object.prototype.hasOwnProperty;var z=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Qs=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of zs(e))!js.call(n,s)&&s!==t&&$r(n,s,{get:()=>e[s],enumerable:!(r=Ks(e,s))||r.enumerable});return n};var Js=(n,e,t)=>(t=n!=null?$s(qs(n)):{},Qs(e||!n||!n.__esModule?$r(t,"default",{value:n,enumerable:!0}):t,n));var Kr=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var l=(n,e,t)=>(Kr(n,e,"read from private field"),t?t.call(n):e.get(n)),C=(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)=>(Kr(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),rr=(n,e,t,r)=>({set _(s){d(n,e,s,t)},get _(){return l(n,e,r)}});var ds=z((wf,ta)=>{ta.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 ms=z($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.convertStringToBaseTenNumber=void 0;var ra=function(n){return parseInt(n,10)};$t.convertStringToBaseTenNumber=ra});var gs=z(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.isOdd=void 0;var na=function(n){return n%2===1};Kt.isOdd=na});var bs=z(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.generateCusipCheckCode=void 0;var sa=ms(),ia=gs(),oa=function(n){for(var e=n.length,t,r=0,s,i=0;i<e;i++){t=n[i];var o=(0,sa.convertStringToBaseTenNumber)(t),a=isNaN(o)?t.charCodeAt(0)-"A".charCodeAt(0)+10:t;(0,ia.isOdd)(i)&&(a=a*2),r=r+Math.floor(a/10)+a%10}return s=(10-r%10)%10,s};zt.generateCusipCheckCode=oa});var Cs=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 ys=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 Ts=z(Me=>{"use strict";var Ss=Me&&Me.__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},Rs=Me&&Me.__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(Me,"__esModule",{value:!0});Me.alphanumeric=void 0;var aa=Cs(),ua=ys();Me.alphanumeric=Rs(Rs([],Ss(aa.alphabet),!1),Ss(ua.baseTenNumbers),!1)});var vs=z(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.generateRandomAlphanumeric=void 0;var ws=Ts(),la=function(){return ws.alphanumeric[Math.floor(Math.random()*ws.alphanumeric.length)]};Qt.generateRandomAlphanumeric=la});var xs=z(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.generateRandomStringOfAlphanumericChars=void 0;var ca=vs(),pa=function(){for(var n="",e=0;e<2;e++)n=n+(0,ca.generateRandomAlphanumeric)();return n};Jt.generateRandomStringOfAlphanumericChars=pa});var Ds=z(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.generateRandomBaseTenNumber=void 0;var ha=function(){return Math.floor(Math.random()*10)};Xt.generateRandomBaseTenNumber=ha});var Ms=z(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.generateRandomStringOfBaseTenChars=void 0;var fa=Ds(),da=function(){for(var n="",e=0;e<6;e++)n=n+(0,fa.generateRandomBaseTenNumber)();return n};Yt.generateRandomStringOfBaseTenChars=da});var Is=z(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.generateCusipWithoutCheckCode=void 0;var ma=xs(),ga=Ms(),ba=function(){var n=(0,ga.generateRandomStringOfBaseTenChars)(),e=(0,ma.generateRandomStringOfAlphanumericChars)();return n+e};Zt.generateCusipWithoutCheckCode=ba});var Es=z(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.generateCusip=void 0;var Ca=bs(),ya=Is(),Sa=function(){var n=(0,ya.generateCusipWithoutCheckCode)(),e=(0,Ca.generateCusipCheckCode)(n);return n+e};er.generateCusip=Sa});var ks=z(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.generateCusip=void 0;var Ra=Es();Object.defineProperty(tr,"generateCusip",{enumerable:!0,get:function(){return Ra.generateCusip}})});var Ls=z(Vs=>{var Ps=ds(),Ta=ks().generateCusip(),wa=n=>{let e=Ps[Math.floor(Math.random()*Ps.length)];return e+n+va(e+n+"0")},va=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};Vs.isinGenerator=function(){return wa(Ta)}});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 Xs={...ee,...P},zr={...ee,...P},Qa=()=>Xs,Ja=n=>{if(zr[n])return zr[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):[]},Qr=(n,e,t)=>e.filter(r=>n.findIndex(s=>t(s)===r)===-1);var Ys=new Set(["=","!=",">",">=","<","<=","starts","ends"]);var Jr=n=>n!==void 0&&Ys.has(n.op);var Xr=n=>n!==void 0&&n.op==="in";function Ee(n){return n!==void 0&&(n.op==="and"||n.op==="or")}var Zs=n=>typeof n.key=="number";var ei={};function nr(n){let e=A.count;return n?n.reduce((t,r,s)=>(typeof r=="string"?t[r]=e+s:Zs(r)?t[r.name]=r.key:t[r.name]=e+s,t),{}):ei}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:ou,IS_LEAF:au}=A;var Yr=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 sr={from:0,to:0};function Be({from:n,to:e,bufferSize:t=0}){return{from:0,to:e-n,bufferSize:t,reset:!0}}var Zr=({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:bu}=A;var ri=["error","warn","info","debug"],ni=n=>typeof n=="string"&&ri.includes(n),si="error",Rt=()=>{},ii="error",{loggingLevel:Tt=ii}=oi(),Fe=n=>{let e=Tt==="debug",t=e||Tt==="info",r=t||Tt==="warn",s=r||Tt==="error",i=t?c=>console.info(`[${n}] ${c}`):Rt,o=r?c=>console.warn(`[${n}] ${c}`):Rt,a=e?c=>console.debug(`[${n}] ${c}`):Rt;return{errorEnabled:s,error:s?c=>console.error(`[${n}] ${c}`):Rt}};function oi(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:en()}}function en(){let n=Yr("vuu-logging-level");return ni(n)?n:si}var tn=()=>`const loggingSettings = { loggingLevel: "${en()}"};`;var{debug:xu,debugEnabled:Du}=Fe("range-monitor");function rn(n){return Array.isArray(n)}function ai(n){return!Array.isArray(n)}var $,te=class{constructor(){C(this,$,new Map)}addListener(e,t){let r=l(this,$).get(e);r?rn(r)?r.push(t):ai(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(rn(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 wt=String.fromCharCode(8200),O=String.fromCharCode(8199);var Pu={DIGIT:O,TWO_DIGITS:O+O,THREE_DIGITS:O+O+O,FULL_PADDING:[null,wt+O,wt+O+O,wt+O+O+O,wt+O+O+O+O]};var Vu=O+O+O+O+O+O+O+O+O;var{COUNT:ui}=A,nn=n=>typeof n=="object"&&n!==null,li=["boolean","number","string"],ci=n=>li.includes(typeof n),pi=n=>typeof n=="boolean"?"boolean":typeof n=="number"?"number":"string",hi=(n,e)=>{if(nn(e))return{attribute:`${n}+`,attributeValue:"",type:"json"};if(e===void 0)return{attribute:n,attributeValue:"undefined",type:"string"};if(ci(e))return{attribute:n,attributeValue:e,type:pi(e)};throw Error(`unsupported type ${typeof e} in JSON`)},ir={name:"json",renderer:{name:"json"}},or=n=>{let e=[];e.push({name:"col 1",type:ir},{name:"col 2",type:ir});let t=[];return sn(t,n,e),[e,t]},sn=(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:ir});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}=hi(p,h),x=g!=="json",U=Array(i).fill(""),V=`${s}|${p}`,I=[r.value,r.value,x,!1,i,0,V,0,...U,f,m];if(n.push(I),a+=1,nn(h)){let[T,v]=sn(n,h,t,{value:r.value+1},V,i+1);I[ui]=T,o+=T,a+=v,r.value+=v}else o+=1}return[o,a]};var Ue=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 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
|
|
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 ar(n,e){let t;return(...r)=>{clearTimeout(t),t=window.setTimeout(()=>n(...r),e)}}function on(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:nl}=A;var{SELECTED:ol}=A,fe={False:0,True:1,First:2,Last:4};var an=(n,e)=>e>=n[0]&&e<=n[1],fi=fe.True+fe.First+fe.Last,di=fe.True+fe.First,mi=fe.True+fe.Last,un=(n,e)=>{for(let t of n)if(typeof t=="number"){if(t===e)return fi}else if(an(t,e))return e===t[0]?di:e===t[1]?mi:fe.True;return fe.False},ln=(n,e)=>{for(let t of n)if(typeof t=="number"){if(t===e)return!0;if(t>e)return!1}else{if(an(t,e))return!0;if(t[0]>e)return!1}return!1};var gi=(()=>{let n=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(n+=1,`u${e()}${n}`)})();var at=(n,e)=>n===e?!0:n===void 0&&e===void 0,Ri=({filter:n},{filter:e})=>n===void 0&&(e==null?void 0:e.filter)===""||e===void 0&&(n==null?void 0:n.filter)==="",Ti=(n,e)=>{var t,r;return Ri(n,e)?!1:((t=n.filter)==null?void 0:t.filter)!==((r=e.filter)==null?void 0:r.filter)},wi=({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,vi=(n,e)=>{let{sort:t}=n,{sort:r}=e;return at(t,r)||wi(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)},hn=n=>n!==void 0&&n.groupBy!==void 0&&n.groupBy.length>0,fn=n=>(n==null?void 0:n.filter)!==void 0&&n.filter.filter.length>0,dn=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},xi=({groupBy:n},{groupBy:e})=>n===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(n==null?void 0:n.length)===0,lr=(n,e)=>{let{groupBy:t}=n,{groupBy:r}=e;return at(t,r)||xi(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]))},Di=({columns:n},{columns:e})=>n===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(n==null?void 0:n.length)===0,Mi=(n,e)=>{let{columns:t}=n,{columns:r}=e;return at(t,r)||Di(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]))},Ii=({aggregations:n},{aggregations:e})=>n===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(n==null?void 0:n.length)===0,Ei=(n,e)=>{let{aggregations:t}=n,{aggregations:r}=e;return at(t,r)||Ii(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)},ki=()=>!1,vt=(n,e)=>at(n,e)?!1:n===void 0||e===void 0?!0:Mi(n,e)||Ti(n,e)||vi(n,e)||lr(n,e)||Ei(n,e)||ki(n,e),Pi=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],mn=n=>{let e=n.type;return Pi.includes(e)},gn=n=>["config","aggregate","columns","filter","groupBy","sort"].includes(n.type),Vi={filter:""},Li={sortDefs:[]},Ge={aggregations:[],columns:[],filter:Vi,groupBy:[],sort:Li},xt=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 bn="GET_TABLE_META";var cr=n=>n.type==="connection-status",Cn=n=>n.type==="connection-metrics",yn=n=>typeof n.result<"u",Sn=n=>n.type==="TABLE_META_RESP";var Rn=n=>n.type==="vuu-links";var Tn=n=>n.type==="vuu-menu";var wn='\nvar pe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var d=(s,e,t)=>(pe(s,e,"read from private field"),t?t.call(s):e.get(s)),O=(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)},de=(s,e,t,n)=>(pe(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);function ge(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:Xt,IS_LEAF:en}=V;var fe=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 J({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 st=(s,{from:e,to:t})=>s>=e&&s<t;var v=class{constructor(e,t){this.from=e,this.to=t}isWithin(e){return st(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:cn}=V;var ot=["error","warn","info","debug"],it=s=>typeof s=="string"&&ot.includes(s),at="error",k=()=>{},ut="error",{loggingLevel:A=ut}=lt(),w=s=>{let e=A==="debug",t=e||A==="info",n=t||A==="warn",r=n||A==="error",o=t?p=>console.info(`[${s}] ${p}`):k,i=n?p=>console.warn(`[${s}] ${p}`):k,u=e?p=>console.debug(`[${s}] ${p}`):k;return{errorEnabled:r,error:r?p=>console.error(`[${s}] ${p}`):k}};function lt(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:ct()}}function ct(){let s=fe("vuu-logging-level");return it(s)?s:at}var{debug:pt,debugEnabled:dt}=w("range-monitor"),U=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)dt&&pt(`<${this.source}> [${e}-${t}], ${(this.timestamp-n).toFixed(0)} ms elapsed`);else return 0}};function me(s){return Array.isArray(s)}function gt(s){return!Array.isArray(s)}var R,he=class{constructor(){O(this,R,new Map)}addListener(e,t){let n=d(this,R).get(e);n?me(n)?n.push(t):gt(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(me(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 F=String.fromCharCode(8200),f=String.fromCharCode(8199);var yn={DIGIT:f,TWO_DIGITS:f+f,THREE_DIGITS:f+f+f,FULL_PADDING:[null,F+f,F+f+f,F+f+f+f,F+f+f+f+f]};var wn=f+f+f+f+f+f+f+f+f;var{COUNT:qn}=V;var N=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:Kn}=V;var{SELECTED:Qn}=V,M={False:0,True:1,First:2,Last:4};var ft=(s,e)=>e>=s[0]&&e<=s[1],mt=M.True+M.First+M.Last,ht=M.True+M.First,Ct=M.True+M.Last,K=(s,e)=>{for(let t of s)if(typeof t=="number"){if(t===e)return mt}else if(ft(t,e))return e===t[0]?ht:e===t[1]?Ct:M.True;return M.False};var Ce=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 bt=(()=>{let s=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(s+=1,`u${e()}${s}`)})();var{debug:_s,debugEnabled:Os,error:Te,info:E,infoEnabled:wt,warn:D}=w("websocket-connection"),Se="ws",Et=s=>s.startsWith(Se+"://")||s.startsWith(Se+"s://"),Ee={},Q=Symbol("setWebsocket"),W=Symbol("connectionCallback");async function Ve(s,e,t,n=10,r=5){return Ee[s]={status:"connecting",connect:{allowed:r,remaining:r},reconnect:{allowed:n,remaining:n}},Me(s,e,t)}async function Z(s){throw Error("connection broken")}async function Me(s,e,t,n){let{status:r,connect:o,reconnect:i}=Ee[s],u=r==="connecting"?o:i;try{t({type:"connection-status",status:"connecting"});let c=typeof n<"u",p=await Mt(s,e);console.info("%c\u26A1 %cconnected","font-size: 24px;color: green;font-weight: bold;","color:green; font-size: 14px;"),n!==void 0&&n[Q](p);let a=n!=null?n:new X(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 Vt(s,e,t,n,2e3);throw Error("Failed to establish connection")}}var Vt=(s,e,t,n,r)=>new Promise(o=>{setTimeout(()=>{o(Me(s,e,t,n))},r)}),Mt=(s,e)=>new Promise((t,n)=>{let r=Et(s)?s:`wss://${s}`;wt&&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)}),ye=()=>{D==null||D("Connection cannot be closed, socket not yet opened")},we=s=>{D==null||D(`Message cannot be sent, socket closed ${s.body.type}`)},xt=s=>{try{return JSON.parse(s)}catch{throw Error(`Error parsing JSON response from server ${s}`)}},X=class{constructor(e,t,n,r){this.close=ye;this.requiresLogin=!0;this.send=we;this.status="ready";this.messagesCount=0;this.connectionMetricsInterval=null;this.handleWebsocketMessage=e=>{let t=xt(e.data);this.messagesCount+=1,this[W](t)};this.url=t,this.protocol=n,this[W]=r,this[Q](e)}reconnect(){Z(this)}[(W,Q)](e){let t=this[W];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=()=>{Te("\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"?Te("Websocket connection lost before Vuu session established, check websocket configuration"):this.status!=="closed"&&(Z(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"&&(Z(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=ye,this.send=we,E==null||E("close websocket")}}};var vt=["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"],xe=s=>vt.includes(s.type),ve=s=>s.type==="VIEW_PORT_RPC_CALL",q=({requestId:s,...e})=>[s,e],Ie=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]},De=s=>{let e={};for(let t of s)(e[t.viewPortId]||(e[t.viewPortId]=[])).push(t);return e};var ee=({columns:s,dataTypes:e,key:t,table:n})=>({table:n,columns:s.map((r,o)=>({name:r,serverDataType:e[o]})),key:t});var Pe=s=>s.type==="connection-status",Le=s=>s.type==="connection-metrics";var _e=s=>"viewport"in s,Oe=s=>s.type==="VIEW_PORT_MENU_RESP"&&s.action!==null&&$(s.action.table),$=s=>s!==null&&typeof s=="object"&&"table"in s&&"module"in s?s.table.startsWith("session"):!1;var ke="CHANGE_VP_SUCCESS";var Ae="CLOSE_TREE_NODE",Ue="CLOSE_TREE_SUCCESS";var Fe="CREATE_VP",Ne="DISABLE_VP",We="DISABLE_VP_SUCCESS";var qe="ENABLE_VP",$e="ENABLE_VP_SUCCESS";var te="GET_VP_VISUAL_LINKS",Ge="GET_VIEW_PORT_MENUS";var Be="HB",He="HB_RESP",je="LOGIN",ze="OPEN_TREE_NODE",Je="OPEN_TREE_SUCCESS";var Ke="REMOVE_VP";var Ye="SET_SELECTION_SUCCESS";var Qe=s=>{switch(s){case"TypeAheadRpcHandler":return"TYPEAHEAD";default:return"SIMUL"}};var Xe=[],T=w("array-backed-moving-window");function It(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,G=class{constructor({from:e,to:t},{from:n,to:r},o){O(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),de(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(It(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,Xe];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=Xe,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 Dt=[],{debug:C,debugEnabled:B,error:Pt,info:g,infoEnabled:Lt,warn:P}=w("viewport"),_t=({rowKey:s,updateType:e})=>e==="U"&&!s.startsWith("$root"),H=[void 0,void 0],Ot={count:0,mode:void 0,size:0,ts:0},j=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=Ot;this.updateThrottleTimer=void 0;this.rangeMonitor=new U("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 N(u),this.pendingLinkedParent=l,this.table=i,this.sort=c,this.title=p,Lt&&(g==null||g(`constructor #${a} ${i.table} bufferSize=${t}`)),this.dataWindow=new G(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:Fe,table:this.table,range:J(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){Pt(`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 P==null||P("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){B&&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,...J(t,this.bufferSize,u)}:null;if(c){B&&(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"}:P==null||P("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?re:ne;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:ze,vpId:this.serverViewportId,treeKey:t.key}}closeTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Ae,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,B&&(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?re:ne;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:qe,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:"disable"}),g==null||g(`disable: ${this.serverViewportId}`),this.suspended=!1,{type:Ne,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),B?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=Dt){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:Ce(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]=Ie(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&&_t(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 H;if(this.hasUpdates){let{keys:n,selectedRows:r}=this,o=this.isTree?re:ne;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)?H:[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}}},ne=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>[s,r.keyFor(s),!0,!1,0,0,e,t?K(o,s):0].concat(n),re=({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?K(o,s):0].concat(a)};var et=1;var{debug:x,debugEnabled:se,error:L,info:y,infoEnabled:kt,warn:oe}=w("server-proxy"),b=()=>`${et++}`,At={},Ut=s=>s.disabled!==!0&&s.suspended!==!0,Ft={type:"NO_ACTION"},Nt=(s,e,t)=>s.map(n=>n.parentVpId===e?{...n,label:t}:n);function Wt(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 z=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]=ge(Array.from(this.viewports.values()),Ut);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:je,token:this.authToken,user:t},""),this.pendingLogin={resolve:n,reject:r}});this.authToken===""&&L("login, cannot login until auth token has been obtained")}subscribe(e){if(this.mapClientToServerViewport.has(e.viewport))L(`spurious subscribe call ${e.viewport}`);else{let t=this.getTableMeta(e.table),n=new j(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),se&&x(`post DataSourceSubscribedMessage to client: ${JSON.stringify(a)}`)),n.disabled&&this.disableViewport(n),this.queuedRequests.length>0&&this.processQueuedRequests(),p==="subscribing"&&!$(n.table)&&(this.sendMessageToServer({type:te,vpId:c}),this.sendMessageToServer({type:Ge,vpId:c}),Array.from(this.viewports.entries()).filter(([l,{disabled:m}])=>l!==c&&!m).forEach(([l])=>{this.sendMessageToServer({type:te,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?(y==null||y(`Unsubscribe Message (Client to Server):\n ${t}`),this.sendMessageToServer({type:Ke,viewPortId:t})):L(`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);y==null||y(`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?(y==null||y(`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(()=>{y==null||y("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 L("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(Nt(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]=q(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]=q(e);this.sendMessageToServer({...r,vpId:t.serverViewportId,namedParams:{}},n)}}rpcCall(e){let[t,n]=q(e),r=Qe(n.service);this.sendMessageToServer(n,t,{module:r})}handleMessageFromClient(e){var t;if(_e(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(ve(e))return this.viewportRpcCall(e);if(xe(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:}}}L(`Vuu ServerProxy Unexpected message from client ${JSON.stringify(e)}`)}getTableMeta(e,t=b()){if($(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=`${et++}`,n=At){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 Be:this.sendMessageToServer({type:He,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 Ye:{let a=this.viewports.get(t.vpId);a&&a.completeOperation(n)}break;case ke:case We: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),se&&x(`postMessageToClient ${JSON.stringify(l)}`))}}break;case $e:{let a=this.viewports.get(t.viewPortId);if(a){let l=a.completeOperation(n);if(l){this.postMessageToClient(l);let[m,S]=a.resume();this.postMessageToClient({clientViewportId:a.clientViewportId,mode:"batch",rows:S,size:m,type:"viewport-update"})}}}break;case"TABLE_ROW":{let a=De(t.rows);for(let[l,m]of Object.entries(a)){let S=i.get(l);S?S.updateRows(m):oe==null||oe(`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 Je:case Ue: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:S}=t,_=a.completeOperation(n,m,l.clientViewportId,S);_&&this.postMessageToClient(_)}}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=Wt(a,this.viewports),[S,_]=l.setLinks(m);if(this.postMessageToClient(S),_){let{link:ue,parentClientVpId:tt}=_,le=b(),ce=this.mapClientToServerViewport.get(tt);if(ce){let nt=l.createLink(le,ue.fromColumn,ce,ue.toColumn);this.sendMessageToServer(nt,le)}}}}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,S=this.viewports.get(m);S&&this.postMessageToClient({clientViewportId:S.clientViewportId,error:a,rpcName:l,type:"VIEW_PORT_MENU_REJ",requestId:n});break}case"VIEW_PORT_MENU_RESP":if(Oe(t)){let{action:a,rpcName:l}=t;this.awaitResponseToMessage({type:"GET_TABLE_META",table:a.table}).then(m=>{let S=ee(m);this.postMessageToClient({rpcName:l,type:"VIEW_PORT_MENU_RESP",action:{...a,tableSchema:S},tableAlreadyOpen:this.isTableOpen(a.table),requestId:n})})}else{let{action:a}=t;this.postMessageToClient({type:"VIEW_PORT_MENU_RESP",action:a||Ft,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":L(t.msg);break;default:kt&&y(`handleMessageFromServer ${t.type}.`)}}cacheTableMeta(e){let{module:t,table:n}=e.table,r=`${t}:${n}`,o=this.cachedTableSchemas.get(r);return o||(o=ee(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!==H){let[r,o]=n,i=e.getNewRowCount();(i!==void 0||r&&r.length>0)&&(se&&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 I,{info:ie,infoEnabled:ae}=w("worker");async function qt(s,e,t,n,r,o,i){let u=await Ve(s,e,c=>{Le(c)?postMessage({type:"connection-metrics",messages:c}):Pe(c)?(r(c),c.status==="reconnected"&&I.reconnect()):I.handleMessageFromServer(c)},o,i);I=new z(u,c=>$t(c)),u.requiresLogin&&await I.login(t,n)}function $t(s){postMessage(s)}var Gt=async({data:s})=>{switch(s.type){case"connect":await qt(s.url,s.protocol,s.token,s.username,postMessage,s.retryLimitDisconnect,s.retryLimitStartup),postMessage({type:"connected"});break;case"subscribe":ae&&ie(`client subscribe: ${JSON.stringify(s)}`),I.subscribe(s);break;case"unsubscribe":ae&&ie(`client unsubscribe: ${JSON.stringify(s)}`),I.unsubscribe(s.viewport);break;default:ae&&ie(`client message: ${JSON.stringify(s)}`),I.handleMessageFromClient(s)}};self.addEventListener("message",Gt);postMessage({type:"ready"});\n\n';var Oi=new Blob([tn()+wn],{type:"text/javascript"}),_i=URL.createObjectURL(Oi),We,pr,hr=[],Ni,Bi,Fi=new Promise((n,e)=>{Ni=n,Bi=e}),xn=()=>Fi,ut=new Map,Dt=new Map,Ui=async({handleConnectionStatusChange:n,protocol:e,retryLimitDisconnect:t,retryLimitStartup:r,token:s="",username:i,url:o})=>s===""&&pr===void 0?new Promise(a=>{hr.push({resolve:a})}):pr||(pr=new Promise(a=>{let u=new Worker(_i),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=Dn,a(u);for(let f of hr)f.resolve(u);hr.length=0}else cr(h)?n({data:h}):console.warn("ConnectionManager: Unexpected message from the worker")}}));function Dn({data:n}){if(mn(n)){let e=ut.get(n.clientViewportId);e?e.postMessageToClientDataSource(n):console.error(`[ConnectionManager] ${n.type} message received, viewport not found`)}else if(cr(n))vn.emit("connection-status",n);else if(Cn(n))vn.emit("connection-metrics",n);else{let e=n.requestId;if(Dt.has(e)){let{resolve:t}=Dt.get(e);Dt.delete(e);let{type:r,requestId:s,...i}=n;yn(n)?t(n.result):n.type==="VP_EDIT_RPC_RESPONSE"||n.type==="VP_EDIT_RPC_REJECT"?t(n):Sn(n)?t(n.tableSchema):t(i)}else console.warn("%cConnectionManager Unexpected message from the worker","color:red;font-weight:bold;")}}var fr=n=>{let e=ue();return We.postMessage({requestId:e,...n}),new Promise((t,r)=>{Dt.set(e,{resolve:t,reject:r})})},Gi={subscribe:(n,e)=>{if(ut.get(n.viewport))throw Error("ConnectionManager attempting to subscribe with an existing viewport id");ut.set(n.viewport,{status:"subscribing",request:n,postMessageToClientDataSource:e}),We.postMessage({type:"subscribe",...n})},unsubscribe:n=>{We.postMessage({type:"unsubscribe",viewport:n})},send:n=>{We.postMessage(n)},destroy:n=>{n&&ut.has(n)&&ut.delete(n)},rpcCall:async n=>fr(n),getTableList:async()=>fr({type:"GET_TABLE_LIST"}),getTableSchema:async n=>fr({type:bn,table:n})},dr=class extends te{async connect({url:e,authToken:t,username:r,protocol:s,retryLimitDisconnect:i,retryLimitStartup:o}){return We=await Ui({protocol:s,url:e,token:t,username:r,retryLimitDisconnect:i,retryLimitStartup:o,handleConnectionStatusChange:Dn}),Gi}destroy(){We.terminate()}},vn=new dr;var Wi=0,lt=class{constructor(e,t){this.from=e,this.to=t}},E=class{constructor(e={}){this.id=Wi++,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]}}};E.closedBy=new E({deserialize:n=>n.split(" ")});E.openedBy=new E({deserialize:n=>n.split(" ")});E.group=new E({deserialize:n=>n.split(" ")});E.contextHash=new E({perNode:!0});E.lookAhead=new E({perNode:!0});E.mounted=new E({perNode:!0});var Hi=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):Hi,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(E.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(E.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 He=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 He(t)}},Mt=new WeakMap,Mn=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(E.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 Ke(this.topNode,e)}cursorAt(e,t=0,r=0){let s=Mt.get(this)||this.topNode,i=new Ke(s);return i.moveTo(e,t),Mt.set(this,i._tree),i}get topNode(){return new oe(this,0,0,null)}resolve(e,t=0){let r=$e(Mt.get(this)||this.topNode,e,t,!1);return Mt.set(this,r),r}resolveInner(e,t=0){let r=$e(Mn.get(this)||this.topNode,e,t,!0);return Mn.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:Cr(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 $i(e)}};H.empty=new H(Y.none,[],[],0);var ct=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 ct(this.buffer,this.index)}},de=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&&!(En(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 de(i,o,this.set)}};function En(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 kn(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 $e(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(En(s,r,h,h+p.length)){if(p instanceof de){if(i&G.ExcludeBuffers)continue;let f=p.findChild(0,p.buffer.length,t,r-h,s);if(f>-1)return new le(new mr(o,p,e,h),null,f)}else if(i&G.IncludeAnonymous||!p.type.isAnonymous||br(p)){let f;if(!(i&G.IgnoreMounts)&&p.props&&(f=p.prop(E.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(E.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 Ke(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return $e(this,e,t,!1)}resolveInner(e,t=0){return $e(this,e,t,!0)}enterUnfinishedNodesBefore(e){return kn(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 mr=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 Ke(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 $e(this,e,t,!1)}resolveInner(e,t=0){return $e(this,e,t,!0)}enterUnfinishedNodesBefore(e){return kn(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)}},Ke=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 de||!a.type.isAnonymous||br(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 br(n){return n.children.some(e=>e instanceof de||!e.type.isAnonymous||br(e))}function $i(n){var e;let{buffer:t,nodeSet:r,maxBufferLength:s=1024,reused:i=[],minRepeatType:o=r.types.length}=n,a=Array.isArray(t)?new ct(t,t.length):t,u=r.types,c=0,p=0;function h(v,L,y,D,W){let{id:M,start:w,end:N,size:X}=a,se=p;for(;X<0;)if(a.next(),X==-1){let ye=i[M];y.push(ye),D.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 _e=u[M],Ce,pe,Wr=w-v;if(N-w<=s&&(pe=x(a.pos-L,W))){let ye=new Uint16Array(pe.size-pe.skip),ie=a.pos-pe.size,he=ye.length;for(;a.pos>ie;)he=U(pe.start,ye,he);Ce=new de(ye,N-pe.start,r),Wr=pe.start-v}else{let ye=a.pos-X;a.next();let ie=[],he=[],Ie=M>=o?M:-1,Ne=0,St=N;for(;a.pos>ye;)Ie>=0&&a.id==Ie&&a.size>=0?(a.end<=St-s&&(m(ie,he,w,Ne,a.end,St,Ie,se),Ne=ie.length,St=a.end),a.next()):h(w,ye,ie,he,Ie);if(Ie>=0&&Ne>0&&Ne<ie.length&&m(ie,he,w,Ne,w,St,Ie,se),ie.reverse(),he.reverse(),Ie>-1&&Ne>0){let Hr=f(_e);Ce=Cr(_e,ie,he,0,ie.length,0,N-w,Hr,Hr)}else Ce=g(_e,ie,he,N-w,se-N)}y.push(Ce),D.push(Wr)}function f(v){return(L,y,D)=>{let W=0,M=L.length-1,w,N;if(M>=0&&(w=L[M])instanceof H){if(!M&&w.type==v&&w.length==D)return w;(N=w.prop(E.lookAhead))&&(W=y[M]+w.length+N)}return g(v,L,y,D,W)}}function m(v,L,y,D,W,M,w,N){let X=[],se=[];for(;v.length>D;)X.push(v.pop()),se.push(L.pop()+y-W);v.push(g(r.types[w],X,se,M-W,N-M)),L.push(W-y)}function g(v,L,y,D,W=0,M){if(c){let w=[E.contextHash,c];M=M?[w].concat(M):[w]}if(W>25){let w=[E.lookAhead,W];M=M?[w].concat(M):[w]}return new H(v,L,y,D,M)}function x(v,L){let y=a.fork(),D=0,W=0,M=0,w=y.end-s,N={size:0,start:0,skip:0};e:for(let X=y.pos-v;y.pos>X;){let se=y.size;if(y.id==L&&se>=0){N.size=D,N.start=W,N.skip=M,M+=4,D+=4,y.next();continue}let _e=y.pos-se;if(se<0||_e<X||y.start<w)break;let Ce=y.id>=o?4:0,pe=y.start;for(y.next();y.pos>_e;){if(y.size<0)if(y.size==-3)Ce+=4;else break e;else y.id>=o&&(Ce+=4);y.next()}W=pe,D+=se,M+=Ce}return(L<0||D==v)&&(N.size=D,N.start=W,N.skip=M),N.size>4?N:void 0}function U(v,L,y){let{id:D,start:W,end:M,size:w}=a;if(a.next(),w>=0&&D<o){let N=y;if(w>4){let X=a.pos-(w-4);for(;a.pos>X;)y=U(v,L,y)}L[--y]=N,L[--y]=M-v,L[--y]=W-v,L[--y]=D}else w==-3?c=D:w==-4&&(p=D);return y}let V=[],I=[];for(;a.pos>0;)h(n.start||0,n.bufferStart||0,V,I,-1);let T=(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(),T)}var In=new WeakMap;function It(n,e){if(!n.isAnonymous||e instanceof de||e.type!=n)return 1;let t=In.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=n||!(r instanceof H)){t=1;break}t+=It(n,r)}In.set(e,t)}return t}function Cr(n,e,t,r,s,i,o,a,u){let c=0;for(let g=r;g<s;g++)c+=It(n,e[g]);let p=Math.ceil(c*1.5/8),h=[],f=[];function m(g,x,U,V,I){for(let T=U;T<V;){let v=T,L=x[T],y=It(n,g[T]);for(T++;T<V;T++){let D=It(n,g[T]);if(y+D>=p)break;y+=D}if(T==v+1){if(y>p){let D=g[v];m(D.children,D.positions,0,D.children.length,x[v]+I);continue}h.push(g[v])}else{let D=x[T-1]+g[T-1].length-L;h.push(Cr(n,g,x,v,T,L,D,null,u))}f.push(L+I-i)}}return m(e,t,r,s,0),(a||u)(h,f,o)}var Pt=class{startParse(e,t,r){return typeof e=="string"&&(e=new gr(e)),r=r?r.length?r.map(s=>new lt(s.from,s.to)):[new lt(0,0)]:[new lt(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}}},gr=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 E({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 Vt(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 Sr(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 Vt(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()}},Vt=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},Pn;(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"})(Pn||(Pn={}));var Sr=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 pt(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 ze=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},Vn=new ze,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=Vn,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=Vn,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;Fn(this.data,e,t,this.id,r.data,r.tokenPrecTable)}};Se.prototype.contextual=Se.prototype.fallback=Se.prototype.extend=!1;var Tr=class{constructor(e,t,r){this.precTable=t,this.elseToken=r,this.data=typeof e=="string"?pt(e):e}token(e,t){let r=e.pos,s=0;for(;;){let i=e.next<0,o=e.resolveOffset(1,1);if(Fn(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))}};Tr.prototype.contextual=Se.prototype.fallback=Se.prototype.extend=!1;function Fn(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||zi(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),x=n[g],U=n[g+1]||65536;if(p<x)f=m;else if(p>=U)h=m+1;else{o=n[g+2],e.advance();continue e}}break}}function Ln(n,e,t){for(let r=e,s;(s=n[r])!=65535;r++)if(s==t)return r-e;return-1}function zi(n,e,t,r){let s=Ln(t,r,e);return s<0||Ln(t,r,n)<s}var ae=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),yr=null,An;(function(n){n[n.Margin=25]="Margin"})(An||(An={}));function On(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 wr=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?On(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?On(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(E.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}}},vr=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new ze)}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 ze,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 ze,{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}},_n;(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"})(_n||(_n={}));var xr=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 Rr(t,s),this.tokens=new vr(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 wr(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&&qi(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(E.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 Nn(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)})`),Nn(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=(yr||(yr=new WeakMap)).get(e);return t||yr.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function Nn(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 Dr=class{constructor(e,t,r){this.source=e,this.flags=t,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}};var ke=class extends Pt{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=E[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 He(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=pt(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(Bn),this.states=pt(e.states,Uint32Array),this.data=pt(e.stateData),this.goto=pt(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 xr(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(ke.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]=Bn(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 Dr(e,r,s)}static deserialize(e){return new ke(e)}};function me(n,e){return n[e]|n[e+1]<<16}function qi(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 Bn(n){if(n.external){let e=n.extend?1:0;return(t,r)=>n.external(t,r)<<1|e}return n.get}var Mr=ke.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,Ir=class{constructor(){C(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 Xr(t)?((r=t.values)!=null||(t.values=[]),t.values.push(e)):Jr(t)&&(t.value=e)}toJSON(e=l(this,Z)){return this.name?{...e,name:this.name}:e}};Z=new WeakMap;var Er=(n,e)=>{let t=new Ir,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 ji=Mr.configure({strict:!0}),Pe=n=>{let e=ji.parse(n);return Er(e,n)};function Lt(n,e){switch(e.op){case"in":return Qi(n,e);case"=":return Ji(n,e);case">":return Xi(n,e);case">=":return Yi(n,e);case"<":return Zi(n,e);case"<=":return eo(n,e);case"starts":return to(n,e);case"and":return ro(n,e);case"or":return no(n,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var Qi=(n,e)=>t=>e.values.indexOf(t[n[e.column]])!==-1,Ji=(n,e)=>t=>t[n[e.column]]===e.value,Xi=(n,e)=>t=>t[n[e.column]]>e.value,Yi=(n,e)=>t=>t[n[e.column]]>=e.value,Zi=(n,e)=>t=>t[n[e.column]]<e.value,eo=(n,e)=>t=>t[n[e.column]]<=e.value,to=(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())}},ro=(n,e)=>{let t=e.filters.map(r=>Lt(n,r));return r=>t.every(s=>s(r))};function no(n,e){let t=e.filters.map(r=>Lt(n,r));return r=>t.some(s=>s(r))}var Un=(n,e,t,r,s,i)=>{let o=Ve(s,n),a=n[n.length-1].aggType,u=t.map(c=>s[c]);switch(a){case 1:return Wn(i,r,s,n,e,u);case 2:return so(i,r,s,n,e,u);case 3:return Gn(i,s,n,e,u);case 4:return oo(i,r,s,n,e,u);case 5:return ao(i,r,s,n,e,u);case 6:return io(i,r,s,n,e,u)}};function Gn(n,e,t,r,s){let i={},o=Ve(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 Ve(n,e){console.log("!!!! aggregation length",e.length);let t=e[e.length-1].column;return n[t]}function Wn(n,e,t,r,s,i){let o={},a=Ve(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 so(n,e,t,r,s,i){let o={},a=Ve(t,r),u=Gn(n,t,r,s,i),c=Wn(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 At(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(...At(n[s],e,t));return r}function io(n,e,t,r,s,i){let o={},a=Ve(t,r);for(let u in n){let c=At(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 oo(n,e,t,r,s,i){let o={},a=Ve(t,r);for(let u in n){let c=At(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 ao(n,e,t,r,s,i){let o={},a=Ve(t,r);for(let u in n){let c=At(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:kr,IS_EXPANDED:Hn,KEY:Pr}=A,$n=(n,e)=>{let t=[];for(let r=0,s=0,i=!1,o=e.length;r<o;r++){let a=e[r],{[kr]:u,[Pr]:c}=a;if(c===n){let p=a.slice();for(p[Hn]=!1,t.push(p),s+=1,i=!0;r<o-1&&e[r+1][kr]>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},Vr=(n,e,t,r,s,i)=>{let o=t.map(a=>r[a]);return Kn(s,o,n,e,void 0,void 0,void 0,i)},Kn=(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[Hn]=!0,Array.isArray(n[c])?uo(o,n[c],r,h,i+1):Kn(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},uo=(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[kr]=s,a[Pr]=`${r}|${a[Pr]}`,n.push(a)}},zn=(n,e,t)=>{let r=e.map(o=>t[o]),s=co(n,r);return[lo(s,r),s]},lo=(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 co(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 po=(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},ho=n=>n.length===1?fo(n):n.length===2?mo(n):go(n),fo=([[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},mo=([[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},go=(n,e=po)=>(t,r)=>{for(let s of n){let i=e(t,r,s);if(i!==0)return i}return 0},qn=(n,{sortDefs:e},t)=>{let r=e.map(({column:i,sortType:o})=>[t[i],o]),s=ho(r);return n.slice().sort(s)};var{RENDER_IDX:bo,SELECTED:Co}=A,Lr=(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[bo]=e.keyFor(s),i[Co]=un(t,s),i},yo=(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},So=(n,e)=>{let{count:t}=A,r=[];return Object.entries(n).forEach(([s])=>{r.push(e[s]+t)}),r},Ar=(n,e)=>{if(e&&yo(n,e))return So(n,e)};var{KEY:jn}=A,{debug:re}=Fe("ArrayDataSource"),Or=n=>(e,t)=>[t,t,!0,!1,1,0,String(e[n]),0,...e],Ro=(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,R,B,_t,_,ht,Nt,ft,Qe,Ot=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=[];C(this,q,void 0);C(this,R,Ge);C(this,B,void 0);C(this,_t,void 0);C(this,_,sr);C(this,ht,0);C(this,Nt,0);C(this,ft,"initialising");C(this,Qe,void 0);this.selectedRows=[];this.keys=new Ue(l(this,_));this.processedData=void 0;this.insert=t=>{let r=Or(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[jn]===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[jn]===r);if(s!==-1){let i=Or(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=Ro(r,u),this.viewport=f||ue(),d(this,Nt,s.length),d(this,Qe,h);let m=r.map(g=>g.name);d(this,q,nr(m)),this.dataIndices=Ar(l(this,q),this.dataMap),d(this,B,s.map(Or(this.key))),this.config={...l(this,R),aggregations:t||l(this,R).aggregations,columns:m,filter:o||l(this,R).filter,groupBy:a||l(this,R).groupBy,sort:p||l(this,R).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,ft,"subscribed"),this.lastRangeServed={from:0,to:0};let h=l(this,R),f=s||r||u||a||o;f&&(i&&d(this,_,i),h={...h,aggregations:s||l(this,R).aggregations,columns:r||l(this,R).columns,filter:u||l(this,R).filter,groupBy:a||l(this,R).groupBy,sort:o||l(this,R).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,_)!==sr&&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,ht,t.length),re==null||re(`select ${JSON.stringify(t)}`),this.selectedRows=t,this.setRange(Be(l(this,_)),!0)}openTreeNode(t){this.openTreeNodes.push(t),this.processedData=Vr(this.openTreeNodes,l(this,B),l(this,R).groupBy,l(this,q),this.groupMap,this.processedData),this.setRange(Be(l(this,_)),!0)}closeTreeNode(t){this.openTreeNodes=this.openTreeNodes.filter(r=>r!==t),this.processedData&&(this.processedData=$n(t,this.processedData),this.setRange(Be(l(this,_)),!0))}get links(){return l(this,_t)}get menu(){return this._menu}get status(){return l(this,ft)}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,R)}set config(t){var r;if(vt(l(this,R),t)){if(t){let s=l(this,R),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:Pe(t.filter.filter)}}:t;d(this,R,xt(i));let o;if(fn(t)){let{filter:a,filterStruct:u=Pe(a)}=t.filter;if(u){let c=Lt(l(this,q),u);o=l(this,B).filter(c)}else throw Error("filter must include filterStruct")}if(dn(t)&&(o=qn(o!=null?o:l(this,B),t.sort,l(this,q))),this.openTreeNodes.length>0&&lr(s,t)&&(l(this,R).groupBy.length===0?this.openTreeNodes.length=0:console.log("adjust the openTReeNodes groupBy changed ",{originalGroupBy:s.groupBy,newGroupBy:i.groupBy})),hn(t)){let[a,u]=zn(o!=null?o:l(this,B),t.groupBy,l(this,q));this.groupMap=u,o=a,this.openTreeNodes.length>0&&(o=Vr(this.openTreeNodes,l(this,B),l(this,R).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(Be(l(this,_)),!0),this.emit("config",l(this,R))}}get selectedRowsCount(){return l(this,ht)}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:[Lr(r,this.keys,this.selectedRows,this.dataIndices)],type:"viewport-update"});else{let a=this.rangeChangeRowset==="delta"&&!t?Zr(this.lastRangeServed,l(this,_)):l(this,_),u=(i=this.processedData)!=null?i:l(this,B),c=u.slice(a.from,a.to).map(p=>Lr(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,R).columns}set columns(t){let r=jr(this.config.columns,t);if(r.length>0){let s=Qr(this.columnDescriptors,r,i=>i.name);console.log("columnsWithoutDescriptors",{columnsWithoutDescriptors:s})}d(this,q,nr(t)),this.dataIndices=Ar(l(this,q),this.dataMap),this.config={...l(this,R),columns:t}}get aggregations(){return l(this,R).aggregations}set aggregations(t){var i;d(this,R,{...l(this,R),aggregations:t});let r=(i=this.processedData)!=null?i:l(this,B),s=l(this,B);Un(t,r,l(this,R).groupBy,s,l(this,q),this.groupMap),this.setRange(Be(l(this,_)),!0),this.emit("config",l(this,R))}get sort(){return l(this,R).sort}set sort(t){re==null||re(`sort ${JSON.stringify(t)}`),this.config={...l(this,R),sort:t}}get filter(){return l(this,R).filter}set filter(t){re==null||re(`filter ${JSON.stringify(t)}`),this.config={...l(this,R),filter:t}}get groupBy(){return l(this,R).groupBy}set groupBy(t){this.config={...l(this,R),groupBy:t}}get title(){return l(this,Qe)}set title(t){d(this,Qe,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,R=new WeakMap,B=new WeakMap,_t=new WeakMap,_=new WeakMap,ht=new WeakMap,Nt=new WeakMap,ft=new WeakMap,Qe=new WeakMap;var To={columns:[],key:"",table:{module:"",table:""}},{DEPTH:Le,IDX:Qn,IS_EXPANDED:wo,IS_LEAF:vo,KEY:es,SELECTED:Jn}=A,Xn=(n,e)=>{let[t]=n,r=n.slice();return r[1]=e.keyFor(t),r},Re,ne,K,Te,we,ce,Bt,Ft,ve,Je,Xe,Yn=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=[];C(this,Re,[]);C(this,ne,Ge);C(this,K,void 0);C(this,Te,{filter:""});C(this,we,[]);C(this,ce,{from:0,to:0});C(this,Bt,0);C(this,Ft,0);C(this,ve,{sortDefs:[]});C(this,Je,"initialising");C(this,Xe,void 0);this.keys=new Ue(l(this,ce));if(!r)throw Error("JsonDataSource constructor called without data");[this.columnDescriptors,rr(this,K)._]=or(r),this.visibleRows=l(this,K).filter(c=>c[Le]===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,Te,s),i&&d(this,we,i),o&&d(this,ve,o),d(this,Xe,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,Te,u),a&&d(this,we,a),i&&d(this,ce,i),o&&d(this,ve,o),l(this,Je)==="initialising"&&(this.viewport=t,d(this,Je,"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,Te),groupBy:l(this,we),range:l(this,ce),sort:l(this,ve),tableSchema:To}),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,rr(this,K)._]=or(t),this.visibleRows=l(this,K).filter(r=>r[Le]===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{[Qn]:o,[Jn]:a}=i,u=a===1,c=ln(t,o);if(c!==u){let p=i.slice();p[Jn]=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=Zn(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=>Xn(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=Zn(l(this,K),this.expandedRows),this.sendRowsToClient()}get status(){return l(this,Je)}get config(){return l(this,ne)}get selectedRowsCount(){return l(this,Bt)}get size(){return l(this,Ft)}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=>Xn(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,ve)}set sort(t){d(this,ve,t)}get filter(){return l(this,Te)}set filter(t){d(this,Te,t)}get groupBy(){return l(this,we)}set groupBy(t){d(this,we,t)}get title(){return l(this,Xe)}set title(t){d(this,Xe,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[es]===t);if(r){let{[Qn]:s,[Le]:i}=r,o=s+1,a=[];do{let{[Le]: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[Le]===t)}};Re=new WeakMap,ne=new WeakMap,K=new WeakMap,Te=new WeakMap,we=new WeakMap,ce=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,ve=new WeakMap,Je=new WeakMap,Xe=new WeakMap;function Zn(n,e){let t=[],r={value:0};for(let s=0;s<n.length;s++){let i=n[s],{[Le]:o,[es]:a,[vo]:u}=i,c=e.has(a);if(t.push(xo(i,r,c)),!u&&!c)do s+=1;while(s<n.length-1&&n[s+1][Le]>o)}return t}var xo=(n,e,t)=>{let r=n.slice();return r[0]=e.value,r[1]=e.value,t&&(r[wo]=!0),e.value+=1,r};var{info:j}=Fe("RemoteDataSource"),{KEY:Do}=A,b,Ut,dt,mt,Ye,ge,gt,Ze,k,Ae,ts=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;C(this,b,Ge);C(this,Ut,[]);C(this,dt,void 0);C(this,mt,void 0);C(this,Ye,"throttle");C(this,ge,{from:0,to:0});C(this,gt,0);C(this,Ze,0);C(this,k,"initialising");C(this,Ae,void 0);this.handleMessageFromServer=t=>{var r,s;if(t.type==="subscribed")d(this,k,"subscribed"),t.tableSchema&&(this.tableSchema=t.tableSchema),(r=this.clientCallback)==null||r.call(this,t);else if(t.type==="disabled")d(this,k,"disabled");else if(t.type==="enabled")d(this,k,"enabled");else{if(gn(t))return;t.type==="debounce-begin"?this.optimize="debounce":(t.type==="viewport-update"&&t.size!==void 0&&t.size!==l(this,Ze)&&(d(this,Ze,t.size),this.emit("resize",t.size)),this.configChangePending&&this.setConfigPending(),Tn(t)?d(this,mt,t.menu):Rn(t)?d(this,dt,t.links):(s=this.clientCallback)==null||s.call(this,t),this.optimize==="debounce"&&this.revertDebounce())}};this.revertDebounce=ar(()=>{this.optimize="throttle"},100);this.rawRangeRequest=t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})};this.debounceRangeRequest=ar(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},50);this.throttleRangeRequest=on(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,Ae,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,k)==="disabled"||l(this,k)==="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,k)!=="initialising"&&l(this,k)!=="unsubscribed")return;d(this,k,"subscribing"),this.viewport=t,this.server=await xn();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,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(),d(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&&(d(this,k,"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,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&&((s=this.server)==null||s.send({type:"resume",viewport:this.viewport}),d(this,k,"subscribed"))),this}disable(){var t;return j==null||j(`disable #${this.viewport}, current status ${l(this,k)}`),this.viewport&&(d(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")&&(d(this,k,"enabling"),t&&(this.clientCallback=t),(r=this.server)==null||r.send({viewport:this.viewport,type:"enable"})),this}select(t){var r;d(this,gt,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,dt)}get menu(){return l(this,mt)}get status(){return l(this,k)}get optimize(){return l(this,Ye)}set optimize(t){if(t!==l(this,Ye)){switch(d(this,Ye,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,gt)}get size(){return l(this,Ze)}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,s;if(vt(l(this,b),t)&&t){let 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:Pe(t.filter.filter)}}:t;d(this,b,xt(i)),l(this,b)&&this.viewport&&this.server&&t&&((s=this.server)==null||s.send({viewport:this.viewport,type:"config",config:l(this,b)})),this.emit("config",l(this,b))}}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,Ut).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,Ae)}set title(t){var r;d(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,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[Do],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,Ut=new WeakMap,dt=new WeakMap,mt=new WeakMap,Ye=new WeakMap,ge=new WeakMap,gt=new WeakMap,Ze=new WeakMap,k=new WeakMap,Ae=new WeakMap;var Gt,et,bt,tt=class extends Ot{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:[]});C(this,Gt,void 0);C(this,et,void 0);C(this,bt,void 0);this._menu=o,d(this,Gt,r),d(this,et,s),d(this,bt,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;console.log(`applyEdit ${r} ${s}`);let i=t[A.KEY];return(o=l(this,bt))==null||o.update(i,r,s),Promise.resolve(!0)}async rpcCall(t){var s;let r=(s=l(this,et))==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,et))==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)}};Gt=new WeakMap,et=new WeakMap,bt=new WeakMap;var Hh=n=>["Row No"].concat(Array(n).fill("").map((e,t)=>`Column ${t+1}`)),Mo=n=>e=>[`row ${e+1}`].concat(Array(n.length).fill(!0).map((t,r)=>`value ${r+1} @ ${e+1}`)),Io=(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)")},_r={ColumnGenerator:Io,RowGenerator:Mo},$h=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:_r;return[i,o,a]}case"BASKET":{let{ColumnGenerator:i,RowGenerator:o,createUpdateGenerator:a}=(s=basketDataGenerators[e])!=null?s:_r;return[i,o,a]}case void 0:{let{ColumnGenerator:i,RowGenerator:o}=_r;return[i,o]}default:throw Error(`vuu-row-gererator table ${n==null?void 0:n.table} was requested but no generator is registered`)}},Kh=(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,rt,be,nt,Ct,F=class extends te{constructor(t,r,s,i){super();C(this,Q,void 0);C(this,rt,void 0);C(this,be,void 0);C(this,nt,new Map);C(this,Ct,void 0);d(this,Q,r),d(this,rt,s),d(this,Ct,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,nt).set(r,t)}}get data(){return l(this,Q)}get map(){return l(this,rt)}get schema(){return l(this,Ct)}insert(t){let r=l(this,Q).length;l(this,Q).push(t);let s=t[l(this,be)];l(this,nt).set(s,r),this.emit("insert",t)}findByKey(t){var s;let r=(s=l(this,nt).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,rt)[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,rt=new WeakMap,be=new WeakMap,nt=new WeakMap,Ct=new WeakMap;var J=n=>Object.values(n.columns).reduce((e,t,r)=>(e[t.name]=r,e),{}),Eo=(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")}},Wt=(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(x=>x.name).sort()),h={key:r,table:n,columns:Array.from(p).map(x=>({name:x,serverDataType:Eo(x,i,a)}))},f=[],m=J(h);for(let x of e.data){let U=t.findByKey(String(x[u]));if(U){let V=[];for(let I of e.schema.columns){let T=x[s[I.name]];V[m[I.name]]=T}for(let I of t.schema.columns){let T=U[o[I.name]];V[m[I.name]]=T}f.push(V)}}let g=new F(h,f,m);return e.on("insert",x=>{let U=t.findByKey(String(x[u]));if(U){let V=[];for(let I of e.schema.columns){let T=x[s[I.name]];V[m[I.name]]=T}for(let I of t.schema.columns){let T=U[o[I.name]];V[m[I.name]]=T}g.insert(V)}}),t.on("update",x=>{let U=x[c],V=g.findByKey(U);if(V){let I=V.slice();for(let{name:T}of t.schema.columns)x[o[T]]!==I[m[T]]&&(I[m[T]]=x[o[T]]);g.updateRow(I)}}),g};function S(n,e){return n=Math.ceil(n),e=Math.floor(e),Math.floor(Math.random()*(e-n+1))+n}var Ht=(n,e)=>n+(e-n)*Math.random(),rs=(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]},ko=(n,e,t,r)=>{let s=e-n;return Math.min(e+t*s,s/2+n+r)},Po=(n,e,t,r)=>Math.max(n+1,(e-n)/2+n),Vo=(n,e,t,r)=>{let s=Math.min(e-1,(e-n)/2+n);return s<1?n+1:s},Lo=(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},ns=(n,e,t,r,s)=>{let i=e;Math.abs(n-e)<=1&&(i=e+1);let o=Lo(n,i,t,r),a=Vo(n,i,t,r),u=Po(n,i,t,r),c=ko(n,i,t,r),p=Math.round(s(o,a)*100)/100,h=Math.round(s(u,c)*100)/100;return[p,h]};var Ao=n=>{let e=S(0,100)/1e3,t=S(0,10)>=5?1:-1;return n+n*e*t},st=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(S(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,[x,U]=ns(m,g,10,5,Ht);if(h[s]=U,h[r]=x,i!==void 0){let V=Math.round((g+(U-g)/2)*100)/100;h[i]=V}}for(let m of Object.values(o))if(S(0,10)<5){c+=1;let x=Ao(f[m]);this.table&&(h[m]=x)}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 ss=[["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 is=[["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 os=[["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 as=[["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 yt=[];for(let n of ss){let[e,t,r,s,i]=n,o=".FTSE100",a="BUY",u=1;yt.push([o,s,t,r,e,`${e}-${o}`,a,i,u])}for(let n of as){let[e,t,r,s,,i]=n,o=".HSI",a="BUY",u=1;yt.push([o,s,e,r,t,`${t}-${o}`,a,i,u])}for(let n of is){let[e,t,r,s,i]=n,o=".NASDAQ100",a="BUY",u=1e3;yt.push([o,i,e,s,t,`${t}-${o}`,a,u,r])}for(let n of os){let[e,t,r,,s]=n,i=".SP500",o="BUY",a=1e3,u=0;yt.push([i,s,e,u,t,`${t}-${i}`,o,a,r])}var it=yt;var{bid:Oo,bidSize:_o,ask:No,askSize:Bo,last:Fo}=J(P.prices),Uo=new st({bid:Oo,bidSize:_o,ask:No,askSize:Bo,last:Fo}),us=[];for(let[,,,n,e]of it){let t=parseFloat(String(n));if(!isNaN(t)){let[r,s]=rs(5,Ht),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",h="close";us.push([s,i,r,o,a,u,c,p,e,h])}}var Go=new F(P.prices,us,J(P.prices),Uo),ls=Go;var xe=n=>Object.values(ee[n].columns).reduce((e,t,r)=>(e[t.name]=r,e),{}),De={algoType:xe("algoType"),basket:xe("basket"),basketTrading:xe("basketTrading"),basketTradingConstituent:xe("basketTradingConstituent"),basketConstituent:xe("basketConstituent"),basketTradingConstituentJoin:xe("basketTradingConstituentJoin"),priceStrategyType:xe("priceStrategyType")},cs=new F(ee.basketConstituent,it,De.basketConstituent),ps=new F(ee.basketTrading,[],De.basketTrading),Wo=1,Nr=new F(ee.basketTradingConstituent,[],De.basketTradingConstituent),hs=(n,e,t="BUY",r="OFF MARKET")=>[n,e,0,1.25,`steve-${Wo++}`,t,r,1e6,125e4,100];function Ho(n,e){let t=hs(n,e);ps.insert(t);let{basketId:r}=xe("basketConstituent");cs.data.filter(i=>i[r]===n).forEach(([,,i,,o,,,a,u])=>{let c="",p="",U="",V="BUY",I="venue",{instanceId:T}=De.basketTrading,v=t[T],L=[c,p,n,i,v,`${v}-${o}`,95,0,0,0,0,U,a,o,V,I,u];Nr.insert(L)})}async function $o(n){console.log(`RPC call erceived ${n.rpcName}`)}async function Ko(n){let[e]=n.params;console.log(`RPC call erceived ${n.rpcName} ${e}`)}async function zo(n){console.log(`RPC call erceived ${n.rpcName}`)}async function qo(n){let{params:[e,t]}=n;Ho(e,t)}var jo={algoType:new F(ee.algoType,[["Sniper",0],["Dark Liquidity",1],["VWAP",2],["POV",3],["Dynamic Close",4]],De.algoType),basket:new F(ee.basket,[[".NASDAQ100",".NASDAQ100",0,0],[".HSI",".HSI",0,0],[".FTSE100",".FTSE100",0,0],[".SP500",".SP500",0,0]],De.basket),basketConstituent:cs,basketTrading:ps,basketTradingConstituent:Nr,basketTradingConstituentJoin:Wt({module:"BASKET",table:"basketTradingConstituentJoin"},Nr,ls,"ric"),priceStrategyType:new F(ee.priceStrategyType,[["Peg to Near Touch",0],["Far Touch",1],["Limit",2],["Algo",3]],De.priceStrategyType)},Qo={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},Jo={algoType:void 0,basket:[{rpcName:"createBasket",service:qo}],basketConstituent:void 0,basketTrading:[{rpcName:"sendToMarket",service:Ko},{rpcName:"takeOffMarket",service:zo}],basketTradingConstituent:void 0,basketTradingConstituentJoin:[{rpcName:"addConstituent",service:$o}],priceStrategyType:void 0},Xo=n=>ee[n].columns,Yo=n=>{let e=Xo(n),{key:t}=ee[n];return new tt({columnDescriptors:e,dataMap:De[n],keyColumn:t,menu:Qo[n],rpcServices:Jo[n],table:jo[n]})},Zo=async()=>[],ea={createDataSource:Yo,typeaheadHook:()=>Zo},fs=ea;var _s=Js(Ls());var As=["CAD","GBX","USD","EUR","GBP"];var Os={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"]},Br=["L","N","OQ","AS","PA","MI","FR","AT"];var Fr=[1,2,5,10,50,50,70,100,100,100,120,150,150,200,500,700,1e3,2e3,2500,5e3,1e4];var Ns={bbg:0,currency:1,description:2,exchange:3,string:4,number:5,ric:6,price:7},ot=[],Oe=Array.from("ABCEFGHKMNOPQRTUVWYZ"),xa=()=>{let n=S(0,1e4),e=S(1,10);return n/e},Da=performance.now();for(let n of Oe)for(let e=0;e<1e4;e++){let t=Oe[S(0,Oe.length-1)],r=Oe[S(0,Oe.length-1)],s=Oe[S(0,Oe.length-1)],i=Br[S(0,Br.length-1)],o=n+t+r+s+"."+i,a=n+t+r+s+" "+i,u=`${o} description`,c=As[S(0,4)],p=(0,_s.isinGenerator)(),h=Fr[S(0,Fr.length-1)],f=Os[i][1],m=xa();ot.push([a,c,u,f,String(p),h,o,m])}var Ma=performance.now();console.log(`generating 10,000 instruments took ${Ma-Da} ms`);var Ia=new F(P.instruments,ot,J(P.instruments));var Ur=Ia;var Ea=ot.map(n=>n.slice(0,-1).concat([S(0,1)===1,S(0,1)===1])),ka=new F(P.instrumentsExtended,Ea,J(P.instrumentsExtended)),Bs=ka;var{bid:Pa,bidSize:Va,ask:La,askSize:Aa}=J(P.prices),Oa=new st({bid:Pa,bidSize:Va,ask:La,askSize:Aa}),_a=["ric","price"],Fs=ot.map(n=>{let{ric:e,price:t}=_a.reduce((m,g)=>({...m,[g]:n[Ns[g]]}),{}),r=S(0,10),s=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[s,i,o,a,u,c,p,"C",e,"close"]});for(let[,,,n,e]of it){let t=parseFloat(String(n));if(!isNaN(t)){let r=S(0,10),s=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,h="C",f="close";Fs.push([s,i,o,a,u,c,p,h,e,f])}}var Na=new F(P.prices,Fs,J(P.prices),Oa);var Gr=Na;var Us=new Map,Ba=(n,e,t="")=>{let r,s=Us.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))}s?s.set(e,r):Us.set(n,new Map([[e,r]]))}return t?r.filter(i=>i.toString().startsWith(t)):r},Gs=(n,e,t)=>{let r=Ba(n,e,t);return r.length>20?r==null?void 0:r.slice(0,20).map(s=>s.toString()):r.map(s=>s.toString())};var Ws={childOrders:new F(P.childOrders,[],J(P.childOrders)),instruments:Ur,instrumentsExtended:Bs,instrumentPrices:Wt({module:"SIMUL",table:"instrumentPrices"},Ur,Gr,"ric"),orders:new F(P.orders,[],J(P.orders)),parentOrders:new F(P.parentOrders,[],J(P.parentOrders)),prices:Gr},Fa=n=>{let e=P[n];if(e)return e.columns;throw Error(`simul-module no schema found for table SIMUL ${n}`)},Ua=n=>{let e=Fa(n);return new tt({columnDescriptors:e,keyColumn:P[n].key,table:Ws[n]})},Ga=async([n,e,t])=>{let r=Ws[n.table];if(r)return Gs(r,e,t);throw Error(`SIMUL suggestionFetcher, unknown table ${n.module} ${n.table}`)},Wa={createDataSource:Ua,typeaheadHook:()=>Ga},Hs=Wa;var Ha={BASKET:fs,SIMUL:Hs},Cd=n=>Ha[n];export{Io as DefaultColumnGenerator,Mo as DefaultRowGenerator,tt as TickingArrayDataSource,Hh as VuuColumnGenerator,hs as createBasketTradingRow,Qa as getAllSchemas,$h as getColumnAndRowGenerator,Ja as getSchema,Kh as populateArray,Xs as schemas,Cd 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=(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};
|
|
5
5
|
//# sourceMappingURL=index.js.map
|