@vuu-ui/vuu-layout 0.8.12 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +5 -223
- package/cjs/index.js.map +4 -4
- package/esm/index.js +5 -223
- package/esm/index.js.map +4 -4
- package/index.css +1 -1
- package/index.css.map +3 -3
- package/package.json +7 -6
- package/types/layout-persistence/LayoutPersistenceManager.d.ts +11 -9
- package/types/layout-persistence/LocalLayoutPersistenceManager.d.ts +6 -7
- package/types/layout-persistence/RemoteLayoutPersistenceManager.d.ts +21 -0
- package/types/layout-persistence/defaultApplicationJson.d.ts +4 -0
- package/types/layout-persistence/index.d.ts +2 -1
- package/types/layout-persistence/useLayoutContextMenuItems.d.ts +2 -4
- package/types/layout-provider/LayoutProviderContext.d.ts +2 -2
- package/types/layout-reducer/layoutTypes.d.ts +17 -1
- package/types/layout-reducer/layoutUtils.d.ts +7 -0
- package/types/layout-reducer/remove-layout-element.d.ts +2 -2
- package/types/layout-reducer/wrap-layout-element.d.ts +1 -1
- package/types/layout-view/ViewContext.d.ts +5 -2
- package/types/layout-view/viewTypes.d.ts +2 -2
- package/types/measured-container/MeasuredContainer.d.ts +6 -0
- package/types/overflow-container/useOverflowContainer.d.ts +1 -1
- package/types/placeholder/LayoutStartPanel.d.ts +6 -0
- package/types/placeholder/Placeholder.d.ts +9 -3
- package/types/stack/stackTypes.d.ts +2 -1
- package/types/toolbar/Toolbar.d.ts +3 -1
- package/types/layout-persistence/data.d.ts +0 -3
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Lh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var T=(r,e,t)=>(Lh(r,e,"read from private field"),t?t.call(r):e.get(r)),ee=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},z=(r,e,t,n)=>(Lh(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Ah=(r,e,t,n)=>({set _(o){z(r,e,o,t)},get _(){return T(r,e,n)}});import{partition as zh}from"@vuu-ui/vuu-utils";import xx from"classnames";var Oh={},Nh={},Fn={};function ze(r){return Oh[r]===!0}function px(r){return Nh[r]===!0}var Vh=r=>ze(r)||px(r);function ge(r,e,t="component"){Fn[r]=e,t==="container"?Oh[r]=!0:t==="view"&&(Nh[r]=!0)}import{Button as Fh,useControlled as mx}from"@salt-ds/core";import Bh from"classnames";import{useCallback as gx}from"react";import{jsx as xo,jsxs as bx}from"react/jsx-runtime";var fn="vuuDrawer",Hh=r=>typeof r=="string"?r:r+"px",yx=(r,e,t)=>{let n=e!==void 0,o=t!==void 0;if(!(!r&&!o&&!n))return!o&&!n?r:{...r,"--drawer-size":n?Hh(e):void 0,"--drawer-peek-size":o?Hh(t):void 0}},_h=({children:r,className:e,clickToOpen:t,defaultOpen:n,sizeOpen:o,sizeClosed:i,style:s,open:l,position:a="left",inline:c,onClick:u,peekaboo:h=!1,toggleButton:f,...d})=>{let[p,m]=mx({controlled:l,default:n!=null?n:!1,name:"Drawer",state:"open"}),y=Bh(fn,e,`${fn}-${a}`,{[`${fn}-open`]:p,[`${fn}-inline`]:c,[`${fn}-over`]:!c,[`${fn}-peekaboo`]:h}),g=gx(()=>{m(!p)},[p,m]),v=yx(s,o,i),w=t?g:u,x=()=>xo("div",{className:Bh("vuuToggleButton-container"),children:p?xo(Fh,{"aria-label":"close",onClick:g,"data-icon":"close",variant:"secondary"}):xo(Fh,{"aria-label":"open",onClick:g,"data-icon":"close",variant:"secondary"})});return bx("div",{...d,className:y,onClick:w,style:v,children:[f=="start"?x():null,xo("div",{className:`${fn}-liner`,children:xo("div",{className:`${fn}-content`,children:r})}),f=="end"?x():null]})};_h.displayName="Drawer";var Ai=_h;import{jsx as Sx,jsxs as Cx}from"react/jsx-runtime";var vx=r=>r.type===Ai,wx=({props:{position:r="left"}})=>r.match(/top|bottom/),Zl=r=>{let{children:e,className:t,id:n,style:o}=r,i="vuuDockLayout",[s,l]=zh(e,vx),[a,c]=zh(s,wx),u=a.length===0?"horizontal":c.length===0?"vertical":"both",h=xx(i,t,`${i}-${u}`);return Cx("div",{className:h,id:n,style:o,children:[s,Sx("div",{className:`${i}-content`,children:l})]})};Zl.displayName="DockLayout";var Wh=Zl;ge("DockLayout",Zl,"container");import{forwardRef as Tx}from"react";import{jsx as kx}from"react/jsx-runtime";var ea=Tx(function({resizeable:e,...t},n){return kx("div",{...t,className:"Component",ref:n})});ea.displayName="Component";var ta=ea;ge("Component",ea);import dn,{isValidElement as Uh}from"react";var Mx={},q=(r,e)=>{var n;let t=_(r);return(n=t[e])!=null?n:t[`data-${e}`]},_=r=>(r==null?void 0:r.props)||r||Mx,$h=r=>{let e=_(r);if(e.children){let{children:[t,...n]}=e;return n.length>0&&console.warn(`getChild expected a single child, found ${n.length+1}`),t}};function K(r){var e;if(r){let t=r.type;if(typeof t=="function"||typeof t=="object"){let n=t.displayName||t.name||((e=t.type)==null?void 0:e.name);if(typeof n=="string")return n}if(typeof r.type=="string")return r.type;if(r.constructor)return r.constructor.displayName;throw Error("typeOf unable to determine type of element")}}var BD=(r,e)=>K(r)===e;var Ex=r=>{let e=r.lastIndexOf(".");return e===-1?r:r.slice(0,e)},Gh=r=>dn.isValidElement(r.props.children)?[r.props.children]:r.props.children,na=(r,e="")=>{let[t,...n]=e.split(".");if(t!=null&&t.startsWith("#")){let o=ra(r,t.slice(1),!0);if(o&&n.length)return na(o,n.join("."))}else if(t==="ACTIVE_CHILD"){let{active:o}=_(r),i=Gh(r),{path:s}=_(i[o]);return s}return""},qh=(r,e="")=>{let[t,...n]=e.split(".");if(t!=null&&t.startsWith("#")){let o=jh(r,t.slice(1),!0);if(o&&n.length)return qh(o,n.join("."))}else if(t==="ACTIVE_CHILD"){let{children:o,props:i}=r,{active:s}=i;if(typeof s=="number"&&(o!=null&&o[s]))return o[s]}};function Qt(r,e){let{"data-path":t,path:n=t}=_(r);return e==="0"||e===n?null:Te(r,Ex(e),!0)}function Yt(r,e){let{children:t,...n}=_(r);if(e(n))return r;if(dn.Children.count(t)>0){let o=dn.isValidElement(t)?[t]:t;for(let i of o){let s=Yt(i,e);if(s)return s}}}function Rx(r,e){if(e===r)return null;let{path:t,children:n}=_(r),{idx:o,finalStep:i}=Et(t,q(e,"path"));return i?r:n===void 0||n[o]===void 0?null:Rx(n[o],e)}var Ix=(r,e)=>{if(dn.isValidElement(r)&&e==0)return r;if(Array.isArray(r))return r[e]};function Kh(r,e){let t=e.split("."),n=[r];for(let o=0;o<t.length;o++){let i=parseInt(t[o]),s=n[i];if(o===t.length-1)return s;n=Gh(s)}}var ra=(r,e,t=!0)=>{let{children:n,id:o}=r.props;if(o===e)return r;if(dn.Children.count(n)>0){let i=Uh(n)?[n]:n;for(let s of i)if(Uh(s)){let l=ra(s,e,!1);if(l)return l}}if(t===!0)throw Error(`pathUtils.findTargetById id #${e} not found in source`)},jh=(r,e,t=!0)=>{let{children:n,id:o}=r;if(o===e)return r;if(Array.isArray(n)&&n.length>0){for(let i of n)if(i!==null&&typeof i=="object"){let s=jh(i,e,!1);if(s)return s}}if(t===!0)throw Error(`pathUtils.findTargetJSONById id #${e} not found in source`)};function Te(r,e,t=!1){if(e.startsWith("#"))return ra(r,e.slice(1),t);let{"data-path":n,path:o=n}=_(r);if(e.indexOf(o)!==0)throw Error(`pathUtils.followPath path ${e} is not within source path ${o}`);let i=e.slice(o.length+1);if(i==="")return r;let s=r,l=i.split(".");for(let a=0;a<l.length;a++){if(dn.Children.count(s.props.children)===0){let c=`element at 0.${l.slice(0,a).join(".")} has no children, so cannot fulfill rest of path ${l.slice(a).join(".")}`;if(t)throw Error(c);console.warn(c);return}if(s=Ix(s.props.children,parseInt(l[a])),s===void 0){let c=`model at 0.${l.slice(0,a).join(".")} has no children that fulfill next step of path ${l.slice(a).join(".")}`;if(t)throw Error(c);console.warn(c)}}return s}function GD(r,e){let t=Qt(r,e),n=e.split(".").map(o=>parseInt(o,10));if(t){let o=n.pop(),{children:i}=t.props;if(i.length-1>o)return Oi(i[o+1]);{let s=n.pop(),l=Qt(r,q(t,"path"));if(l&&typeof s=="number"&&(n=l.props.path.split(".").map(a=>parseInt(a,10)),l.props.children.length-1>s)){let a=l.props.children[s+1];return ze(K(a))?Oi(a):a}}}return Oi(r)}function qD(r,e){let t=e.split(".").map(i=>parseInt(i,10)),n=t.pop(),o=Qt(r,e);if(o!=null&&typeof n=="number"){let{children:i}=o.props;if(n>0)return Ni(i[n-1]);for(;t.length>1;)if(n=t.pop(),o=Qt(r,q(o,"path")),n>0){let s=o.props.children[n-1];return ze(K(s))?Ni(s):s}}return Ni(r)}function Oi(r){if(ze(K(r))){let{children:e}=r.props||r;return Oi(e[0])}return r}function Ni(r){if(ze(K(r))){let{children:e}=r.props||r;return Ni(e[e.length-1])}return r}function Et(r,e,t=!1){if(r===e)return{idx:-1,finalStep:!0};let n=`${r}.`;if(!e.startsWith(n))throw Error("pathUtils nextStep has strayed from the path");let o=t?0:1,i=e.replace(n,"").split(".").map(s=>parseInt(s,10));return{idx:i[0],finalStep:i.length===o}}function Ee(r,e,t){if(q(r,"path")===e)return r;let n=[];dn.Children.forEach(r.props.children,(i,s)=>{q(i,"path")?n.push(Ee(i,`${e}.${s}`)):n.push(i)});let o=r.props["data-path"]?"data-path":"path";return dn.cloneElement(r,{[o]:e,...t},n)}function jD(r,e){typeof r=="function"?r(e):r&&(r.current=e)}import{Children as Px,isValidElement as Jh,useLayoutEffect as Dx,useMemo as Lx,useRef as Ax}from"react";var Ox=[],Nx=0,wr=r=>{let e=Array.isArray(r),t=e?r.length:Px.count(r);return e&&r.every(Jh)?r:t===1&&!e&&Jh(r)?[r]:t>1?r:Ox},Qh=(r,e)=>{let t=Ax(!1);Dx(()=>{t.current?r():t.current=!0},e)},Sr=r=>Lx(()=>r!=null?r:`vuu-${++Nx}`,[r]);var oa=r=>{if(typeof r!="number")throw Error(`"no support yet for flex value ${r}`);return{flexBasis:0,flexGrow:1,flexShrink:1}};import{boxContainsPoint as Vi}from"@vuu-ui/vuu-utils";var Hn={north:1,east:2,south:4,west:8,header:16,centre:32,absolute:64},vo={AFTER:"after",BEFORE:"before"},Ze=Object.freeze({North:Bn("north"),East:Bn("east"),South:Bn("south"),West:Bn("west"),Header:Bn("header"),Centre:Bn("centre"),Absolute:Bn("absolute")});function Bn(r){return Object.freeze({offset:r==="north"||r==="west"?0:r==="south"||r==="east"?1:NaN,valueOf:function(){return Hn[r]},toString:function(){return r},North:r==="north",South:r==="south",East:r==="east",West:r==="west",Header:r==="header",Centre:r==="centre",NorthOrSouth:r==="north"||r==="south",EastOrWest:r==="east"||r==="west",NorthOrWest:r==="north"||r==="west",SouthOrEast:r==="east"||r==="south",Absolute:r==="absolute"})}var Yh=Ze.North,Xh=Ze.South,ia=Ze.East,sa=Ze.West,Vx=Ze.Header,Fx=Ze.Centre,Cr=class{static measure(e,t=[]){let n={};return _x(e,n,t),n}static allBoxesContainingPoint(e,t,n,o,i){return nf(e,t,n,o,i).reverse()}};function la(r,e,t,n=30){let o=t.right-t.left,i=t.bottom-t.top,s=r-t.left,l=e-t.top,a=0;return s<n&&(a+=8),s>o-n&&(a+=2),l<n&&(a+=1),l>i-n&&(a+=4),{pctX:s/o,pctY:l/i,closeToTheEdge:a}}function aa(r,e,t,n){let{BEFORE:o,AFTER:i}=vo,{pctX:s,pctY:l,closeToTheEdge:a}=la(r,e,t),c,u;if(n==="row")c=s<.5?sa:ia;else if(t.header&&Vi(t.header,r,e))if(c=Vx,t.Stack){let h=t.Stack.length;if(h===0)u={index:-1,left:t.left,positionRelativeToTab:i,width:0};else{let f=t.Stack.find(({left:d,right:p})=>r>=d&&r<=p);if(f){let d=f.right-f.left;u={index:t.Stack.indexOf(f),left:f.left,positionRelativeToTab:(r-f.left)/d<.5?o:i,width:d}}else u={left:t.Stack[h-1].right,width:0,index:h,positionRelativeToTab:i}}}else if(t.header.titleWidth){let h=t.header.titleWidth;u={index:-1,left:t.left,positionRelativeToTab:(r-t.left)/h<.5?o:i,width:h}}else u={left:t.left,width:0,positionRelativeToTab:o,index:-1};else c=Bx(r,e,t,s,l);return{position:c,x:r,y:e,closeToTheEdge:a,tab:u}}function Bx(r,e,t,n,o){let i=Hx(t,.2);if(Vi(i,r,e))return Fx;switch(`${o<.5?"north":"south"}${n<.5?"west":"east"}`){case"northwest":return n>o?Yh:sa;case"northeast":return 1-n>o?Yh:ia;case"southeast":return n>o?ia:Xh;case"southwest":return 1-n>o?sa:Xh;default:}}function Hx({right:r,left:e,top:t,bottom:n},o){let i=(1-o)/2,s=(r-e)*i,l=(n-t)*i;return{left:e+s,top:t+l,right:r-s,bottom:n-l}}function _x(r,e,t){let{id:n,"data-path":o,path:i=o}=_(r),s=K(r);if(n&&i){let[l,a]=tf(r);Zh(r,l,a,e),ze(s)&&ef(r,e,t)}}function Zh(r,e,t,n){let{"data-path":o,path:i=o,header:s}=_(r);n[i]=e;let l=K(r);if(s||l==="Stack"){let a=l==="Stack"?".vuuTabstrip":".vuuHeader",c=t.querySelector(a);if(c){let{top:u,left:h,right:f,bottom:d}=c.getBoundingClientRect();if(n[i].header={top:Math.round(u),left:Math.round(h),right:Math.round(f),bottom:Math.round(d)},l==="Stack")n[i].Stack=Array.from(c.querySelectorAll(".vuuTab")).map(p=>p.getBoundingClientRect()).map(({left:p,right:m})=>({left:p,right:m}));else{let p=c.querySelector('[class^="vuuHeader-title"]'),{header:m}=n[i];p&&m&&(m.titleWidth=p.clientWidth)}}}return n[i]}function ef(r,e,t,n=0,o=0,i=0,s=0){let{children:l,"data-path":a,path:c=a,style:u,active:h=0}=_(r),f=K(r),d=f==="Flexbox",p=f==="Stack",m=d&&u.flexDirection==="column",y=d&&u.flexDirection==="row",v=(p?l.filter((x,S)=>S===h):l.filter(zx)).map(x=>{let[S,b]=tf(x);return[{...S,top:S.top-i,right:S.right+o,bottom:S.bottom+s,left:S.left-n},b,x]}),w=v.map(([x,S,b],C,k)=>{let E,R,M,P,I,V,B=k.length-1;y?(I=C===0?0:x.left-k[C-1][0].right,V=C===B?0:k[C+1][0].left-x.right,E=C===0||I===0?0:I,R=C===B||V===0?0:V-V/2,x.left-=E,x.right+=R,M=i,P=s):m&&(I=C===0?0:x.top-k[C-1][0].bottom,V=C===B?0:k[C+1][0].top-x.bottom,M=C===0||I===0?0:I,P=C===B||V===0?0:V-V/2,x.top-=M,x.bottom+=P,E=n,R=o);let W=Zh(b,x,S,e),O=K(b);return ze(O)&&ef(b,e,t,E,R,M,P),W});v.length&&(e[c].children=w)}function zx(r){let{id:e}=_(r),t=document.getElementById(e);return t?t.dataset.dragging!=="true":(console.warn(`BoxModel: no element found with id #${e}`),!1)}function tf(r){let{id:e}=_(r);if(e===void 0)throw Error("`BoxModel.measureComponentElement, component has no id");let t=document.getElementById(e);if(!t)throw Error("BoxModel.measureComponentElement, no DOM element found for component");let{top:n,left:o,right:i,bottom:s,height:l,width:a}=t.getBoundingClientRect(),c,u=K(r);if(ze(u)){let h=t.scrollHeight;h>l&&(c={id:e,scrollHeight:h,scrollTop:t.scrollTop})}return[{top:Math.round(n),left:Math.round(o),right:Math.round(i),bottom:Math.round(s),height:Math.round(l),width:Math.round(a),scrolling:c},t,r]}function nf(r,e,t,n,o,i=[]){let{children:s,"data-path":l,path:a=l}=_(r),c=K(r),u=e[a];if(!Vi(u,t,n))return i;if(o&&o.length){if(o.includes(a))i.push(r);else if(!o.some(h=>h.startsWith(a)))return i}else i.push(r);if(!ze(c)||u.header&&Vi(u.header,t,n))return i;u.scrolling&&Wx(u,t,n);for(let h=0;h<s.length;h++){if(c==="Stack"&&r.props.active!==h)continue;let f=nf(s[h],e,t,n,o);if(f.length)return i.concat(f)}return i}function Wx({top:r,bottom:e,scrolling:t},n,o){if(t){let{id:i,scrollTop:s,scrollHeight:l}=t,a=e-r;if(s===0&&e-o<50){let c=l-a;document.getElementById(i).scrollTo({left:0,top:c,behavior:"smooth"}),t.scrollTop=c}else if(s>0&&o-r<50)document.getElementById(i).scrollTo({left:0,top:0,behavior:"smooth"}),t.scrollTop=0;else return!1}else return!1}var $x=.4,Fi=class{constructor(e,t,n,o,i){this.init(e,t,n,o,i)}init(e,t,n,o,i){let{left:s,top:l}=o,{pctX:a,pctY:c}=la(t,n,o),u=$x,h=a*o.width,f=o.width-h,d=c*o.height,p=o.height-d,m=o.width*u,y=o.height*u,g=1-u,v=h*g,w=d*g,x=f*g,S=p*g;this.intrinsicSize=i,this.constraint={zone:{x:{lo:e.left,hi:e.right},y:{lo:e.top,hi:e.bottom}},pos:{x:{lo:e.left-v,hi:e.right-o.width+x},y:{lo:e.top-w,hi:e.bottom-o.height+S}},mouse:{x:{lo:e.left+m*a,hi:e.right-m*(1-a)},y:{lo:e.top+y*c,hi:e.bottom-y*(1-c)}}},this.x={pos:s,lo:!1,hi:!1,mousePos:t,mousePct:a},this.y={pos:l,lo:!1,hi:!1,mousePos:n,mousePct:c}}outOfBounds(){return this.x.lo||this.x.hi||this.y.lo||this.y.hi}inBounds(){return!this.outOfBounds()}dropX(){return this.dropXY("x")}dropY(){return this.dropXY("y")}hasIntrinsicSize(){var e,t;return((e=this==null?void 0:this.intrinsicSize)==null?void 0:e.height)&&((t=this==null?void 0:this.intrinsicSize)==null?void 0:t.width)}update(e,t){let n=this[e],o=this.constraint.mouse[e],i=this.constraint.pos[e],s=n.pos,l=t-n.mousePos;return l<0?n.lo||(t<o.lo?(n.lo=!0,n.pos=i.lo):n.hi?t<o.hi&&(n.hi=!1,n.pos+=l):n.pos+=l):l>0&&(n.hi||(t>o.hi?(n.hi=!0,n.pos=i.hi):n.lo?t>o.lo&&(n.lo=!1,n.pos+=l):n.pos+=l)),n.mousePos=t,s!==n.pos}dropXY(e){let t=this[e],n=this.constraint.zone[e];return t.lo?Math.max(n.lo,t.mousePos):t.hi?Math.min(t.mousePos,Math.round(n.hi)-1):t.mousePos}};var xL=r=>r.pos.tab&&K(r.component)==="Stack"&&r.pos.position.Header,{north:Ux,south:Gx,east:qx,west:Kx}=Hn,jx=qx+Kx,Jx=Ux+Gx,pn=class{constructor({component:e,pos:t,clientRect:n,nextDropTarget:o}){this.component=e,this.pos=t,this.clientRect=n,this.nextDropTarget=o,this.active=!1,this.dropRect=void 0}targetTabPos(e){let{left:t,width:n,positionRelativeToTab:o}=e;return o===vo.BEFORE?t:t+n}getTargetDropOutline(e,t){if(this.pos.tab)return this.getDropTabOutline(e,this.pos.tab);if(t&&t.hasIntrinsicSize())return this.getIntrinsicDropRect(t);{let[n,o,i,s]=this.getDropRectOutline(e,t);return{l:n,t:o,r:i,b:s}}}getDropTabOutline(e,t){var g,v;let{clientRect:{top:n,left:o,right:i,bottom:s,header:l}}=this,a=0,c=Math.round(e/2)+a,u=Math.round(n),h=Math.round(o+c),f=Math.round(i-c),d=Math.round(s-c),p=this.targetTabPos(t),m=60,y=((g=l==null?void 0:l.bottom)!=null?g:0)-((v=l==null?void 0:l.top)!=null?v:0);return{l:h,t:u,r:f,b:d,tabLeft:p,tabWidth:m,tabHeight:y}}getIntrinsicDropRect(e){var m,y,g,v;let{pos:t,clientRect:n}=this,{x:o,y:i}=e,s=(y=(m=e.intrinsicSize)==null?void 0:m.height)!=null?y:0,l=(v=(g=e.intrinsicSize)==null?void 0:g.height)!=null?v:0;s&&s>n.height?(console.log("DropTarget: we're going to blow the gaff"),s=n.height):l&&l>n.width&&(console.log("DropTarget: we're going to blow the gaff"),l=n.width);let a=Math.min(n.right-l,Math.max(n.left,Math.round(t.x-o.mousePct*l))),c=Math.min(n.bottom-s,Math.max(n.top,Math.round(t.y-i.mousePct*s))),[u,h,f,d]=this.dropRect=[a,c,a+l,c+s],p=t.position.EastOrWest?[u,n.top,u,n.bottom,f,n.top,f,n.bottom]:[n.left,h,n.right,h,n.left,d,n.right,d];return{l:u,r:f,t:h,b:d,guideLines:p}}getDropRectOutline(e,t){var v,w,x;let{pos:n,clientRect:o}=this,{width:i,height:s,position:l}=n,{width:a,height:c}=(v=t==null?void 0:t.intrinsicSize)!=null?v:{},u=(w=c!=null?c:s)!=null?w:0,h=(x=a!=null?a:i)!=null?x:0;this.dropRect=void 0;let{top:f,left:d,right:p,bottom:m}=o,y=0,g=Math.round(e/2)+y;switch(l){case Ze.North:case Ze.Header:{let S=Math.round((m-f)/2),b=u?Math.min(S,Math.round(u)):S;return h&&d+h<p?[d+g,f+g,d+h-g,f+g+b]:[d+g,f+g,p-g,f+g+b]}case Ze.West:{let S=Math.round((p-d)/2),b=h?Math.min(S,Math.round(h)):S;return u&&f+u<m?[d+g,f+g,d-g+b,f+u+g]:[d+g,f+g,d-g+b,m-g]}case Ze.East:{let S=Math.round((p-d)/2),b=h?Math.min(S,Math.round(h)):S;return u&&f+u<m?[p-g-b,f+g,p-g,f+u+g]:[p-g-b,f+g,p-g,m-g]}case Ze.South:{let S=Math.round((m-f)/2),b=u?Math.min(S,Math.round(u)):S;return h&&d+h<p?[d+g,m-g-b,d+h-g,m-g]:[d+g,m-g-b,p-g,m-g]}case Ze.Centre:return[d+g,f+g,p-g,m-g];default:return console.warn(`DropTarget does not recognize position ${l}`),null}}activate(){return this.active=!0,this}toArray(){let e=this,t=[e];for(;e=e.nextDropTarget;)t.push(e);return t}static getActiveDropTarget(e){return e===null?null:e!=null&&e.active?e:pn.getActiveDropTarget(e.nextDropTarget)}};function ca(r,e,t,n,o,i){var a;let s=null,l=Cr.allBoxesContainingPoint(t,n,r,e,i);if(l.length){let[c,...u]=l,{"data-path":h,path:f=h,"data-row-placeholder":d}=_(c),p=n[f],y=aa(r,e,p,o&&d?"row":void 0),g=n[f],v=([w,...x])=>{var S,b;if((S=y.position)!=null&&S.Header||y.closeToTheEdge){let C=Qx(w,y,g,n,r,e);if(C){let[k,E]=C;return new pn({component:w,pos:k,clientRect:E,nextDropTarget:(b=v(x))!=null?b:null})}else if(x.length)return v(x)}};s=new pn({component:c,pos:y,clientRect:p,nextDropTarget:(a=v(u))!=null?a:null}).activate()}return s}function Qx(r,{closeToTheEdge:e,position:t},n,o,i,s){if(!r||r.type==="DraggableLayout")return;let l=o[r.props.path],a=e&Hn.north,c=e&Hn.east,u=e&Hn.south,h=e&Hn.west,f=(a||t.Header)&&Math.round(n.top)===Math.round(l.top),d=c&&Math.round(n.right)===Math.round(l.right),p=u&&Math.round(n.bottom)===Math.round(l.bottom),m=h&&Math.round(n.left)===Math.round(l.left);if(f||d||p||m){let{"data-path":y,path:g=y}=r.props,v=o[g],w=aa(i,s,v);if((Yx(r)||rf(r))&&e&jx)return w.width=120,[w,v];if((Xx(r)||rf(r))&&(t.Header||e&Jx))return w.height=120,[w,v]}}function rf(r){return K(r)==="Stack"}function Yx(r){return K(r)==="Flexbox"&&r.props.style.flexDirection==="column"}function Xx(r){return K(r)==="Flexbox"&&r.props.style.flexDirection==="row"}import{PopupService as ha}from"@vuu-ui/vuu-popups";import Zx from"classnames";import{jsx as of}from"react/jsx-runtime";function sf(r,e=0,t=0){let{pos:n,clientRect:o}=r,i=20;return n.position.West?[o.left-t+i,n.y-e,"left"]:n.position.South?[n.x-t,o.bottom-e-i,"bottom"]:n.position.East?[o.right-t-i,n.y-e,"right"]:[n.x-t,o.top-e+i,"top"]}var ua="vuuDropMenu",lf=({className:r,dropTarget:e,onHover:t,orientation:n})=>{let o=e.toArray();return of("div",{className:Zx(ua,r,`${ua}-${n}`),onMouseLeave:()=>t(null),children:o.map((i,s)=>of("div",{className:`${ua}-item`,"data-icon":s===0?"column-2A":"column-2B",onMouseEnter:()=>t(i)},s))})};import{jsx as sv}from"react/jsx-runtime";var fa=!1,wo=null,Rt=null,ev=r=>wo=r,tv=([r,e])=>`M${r},${e}`,nv=([r,e])=>`L${r},${e}`,af=([r,...e])=>`${tv(r)} ${e.map(nv)}Z`,rv=r=>{if(r){let[e,t,n,o,i,s,l,a]=r;return`M${e},${t} L${n},${o} M${i},${s} L${l},${a}`}else return""};function ov(){if(document.getElementById("hw-drag-canvas")===null){let r=document.getElementById("root"),e=document.createElement("div");e.id="hw-drag-canvas",e.innerHTML=`
|
|
1
|
+
var ds=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var m=(r,e,t)=>(ds(r,e,"read from private field"),t?t.call(r):e.get(r)),N=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},L=(r,e,t,o)=>(ds(r,e,"write to private field"),o?o.call(r,t):e.set(r,t),t),Io=(r,e,t,o)=>({set _(n){L(r,e,n,t)},get _(){return m(r,e,o)}});import{partition as ws}from"@vuu-ui/vuu-utils";import Nu from"classnames";var hs={},fs={},je={};function re(r){return hs[r]===!0}function Iu(r){return fs[r]===!0}var ms=r=>re(r)||Iu(r);function G(r,e,t="component"){je[r]=e,t==="container"?hs[r]=!0:t==="view"&&(fs[r]=!0)}import{Button as gs,useControlled as ku}from"@salt-ds/core";import ys from"classnames";import{useCallback as Ou}from"react";import{jsx as At,jsxs as Au}from"react/jsx-runtime";var Ae="vuuDrawer",bs=r=>typeof r=="string"?r:r+"px",Vu=(r,e,t)=>{let o=e!==void 0,n=t!==void 0;if(!(!r&&!n&&!o))return!n&&!o?r:{...r,"--drawer-size":o?bs(e):void 0,"--drawer-peek-size":n?bs(t):void 0}},vs=({children:r,className:e,clickToOpen:t,defaultOpen:o,sizeOpen:n,sizeClosed:s,style:i,open:a,position:l="left",inline:u,onClick:c,peekaboo:p=!1,toggleButton:d,...h})=>{let[f,b]=ku({controlled:a,default:o!=null?o:!1,name:"Drawer",state:"open"});console.log(`Drawer sizeOpen ${n} sizeClosed ${s}`);let y=ys(Ae,e,`${Ae}-${l}`,{[`${Ae}-open`]:f,[`${Ae}-inline`]:u,[`${Ae}-over`]:!u,[`${Ae}-peekaboo`]:p}),g=Ou(()=>{b(!f)},[f,b]),C=Vu(i,n,s),R=t?g:c,w=()=>At("div",{className:ys("vuuToggleButton-container"),children:f?At(gs,{"aria-label":"close",onClick:g,"data-icon":"close",variant:"secondary"}):At(gs,{"aria-label":"open",onClick:g,"data-icon":"close",variant:"secondary"})});return Au("div",{...h,className:y,onClick:R,style:C,children:[d=="start"?w():null,At("div",{className:`${Ae}-liner`,children:At("div",{className:`${Ae}-content`,children:r})}),d=="end"?w():null]})};vs.displayName="Drawer";var wr=vs;import{jsx as Fu,jsxs as zu}from"react/jsx-runtime";var _u=r=>r.type===wr,Bu=({props:{position:r="left"}})=>r.match(/top|bottom/),ko=r=>{let{children:e,className:t,id:o,style:n}=r,s="vuuDockLayout",[i,a]=ws(e,_u),[l,u]=ws(i,Bu),c=l.length===0?"horizontal":u.length===0?"vertical":"both",p=Nu(s,t,`${s}-${c}`);return zu("div",{className:p,id:o,style:n,children:[i,Fu("div",{className:`${s}-content`,children:a})]})};ko.displayName="DockLayout";var Ss=ko;G("DockLayout",ko,"container");import{forwardRef as Hu}from"react";import{jsx as Wu}from"react/jsx-runtime";var Oo=Hu(function({resizeable:e,...t},o){return Wu("div",{...t,className:"Component",ref:o})});Oo.displayName="Component";var $u=Oo;G("Component",Oo);import Ne,{isValidElement as Rs}from"react";var Uu={},A=(r,e)=>{var o;let t=I(r);return(o=t[e])!=null?o:t[`data-${e}`]},I=r=>(r==null?void 0:r.props)||r||Uu,Cs=r=>{let e=I(r);if(e.children){let{children:[t,...o]}=e;return o.length>0&&console.warn(`getChild expected a single child, found ${o.length+1}`),t}};function O(r){var e;if(r){let t=r.type;if(typeof t=="function"||typeof t=="object"){let o=t.displayName||t.name||((e=t.type)==null?void 0:e.name);if(typeof o=="string")return o}if(typeof r.type=="string")return r.type;if(r.constructor)return r.constructor.displayName;throw Error("typeOf unable to determine type of element")}}var Ey=(r,e)=>O(r)===e;var Gu=r=>{let e=r.lastIndexOf(".");return e===-1?r:r.slice(0,e)},xs=r=>Ne.isValidElement(r.props.children)?[r.props.children]:r.props.children,Vo=(r,e="")=>{let[t,...o]=e.split(".");if(t!=null&&t.startsWith("#")){let n=Ao(r,t.slice(1),!0);if(n&&o.length)return Vo(n,o.join("."))}else if(t==="ACTIVE_CHILD"){let{active:n}=I(r),s=xs(r),{path:i}=I(s[n]);return i}return""},Ts=(r,e="")=>{let[t,...o]=e.split(".");if(t!=null&&t.startsWith("#")){let n=Ps(r,t.slice(1),!0);if(n&&o.length)return Ts(n,o.join("."))}else if(t==="ACTIVE_CHILD"){let{children:n,props:s}=r,{active:i}=s;if(typeof i=="number"&&(n!=null&&n[i]))return n[i]}};function we(r,e){let{"data-path":t,path:o=t}=I(r);return e==="0"||e===o?null:J(r,Gu(e),!0)}function De(r,e){let{children:t,...o}=I(r);if(e(o))return r;if(Ne.Children.count(t)>0){let n=Ne.isValidElement(t)?[t]:t;for(let s of n){let i=De(s,e);if(i)return i}}}function qu(r,e){if(e===r)return null;let{path:t,children:o}=I(r),{idx:n,finalStep:s}=Se(t,A(e,"path"));return s?r:o===void 0||o[n]===void 0?null:qu(o[n],e)}var Ju=(r,e)=>{if(Ne.isValidElement(r)&&e==0)return r;if(Array.isArray(r))return r[e]};function Es(r,e){let t=e.split("."),o=[r];for(let n=0;n<t.length;n++){let s=parseInt(t[n]),i=o[s];if(n===t.length-1)return i;o=xs(i)}}var Ao=(r,e,t=!0)=>{let{children:o,id:n}=r.props;if(n===e)return r;if(Ne.Children.count(o)>0){let s=Rs(o)?[o]:o;for(let i of s)if(Rs(i)){let a=Ao(i,e,!1);if(a)return a}}if(t===!0)throw Error(`pathUtils.findTargetById id #${e} not found in source`)},Ps=(r,e,t=!0)=>{let{children:o,id:n}=r;if(n===e)return r;if(Array.isArray(o)&&o.length>0){for(let s of o)if(s!==null&&typeof s=="object"){let i=Ps(s,e,!1);if(i)return i}}if(t===!0)throw Error(`pathUtils.findTargetJSONById id #${e} not found in source`)};function J(r,e,t=!1){if(e.startsWith("#"))return Ao(r,e.slice(1),t);let{"data-path":o,path:n=o}=I(r);if(e.indexOf(n)!==0)throw Error(`pathUtils.followPath path ${e} is not within source path ${n}`);let s=e.slice(n.length+1);if(s==="")return r;let i=r,a=s.split(".");for(let l=0;l<a.length;l++){if(Ne.Children.count(i.props.children)===0){let u=`element at 0.${a.slice(0,l).join(".")} has no children, so cannot fulfill rest of path ${a.slice(l).join(".")}`;if(t)throw Error(u);console.warn(u);return}if(i=Ju(i.props.children,parseInt(a[l])),i===void 0){let u=`model at 0.${a.slice(0,l).join(".")} has no children that fulfill next step of path ${a.slice(l).join(".")}`;if(t)throw Error(u);console.warn(u)}}return i}function Oy(r,e){let t=we(r,e),o=e.split(".").map(n=>parseInt(n,10));if(t){let n=o.pop(),{children:s}=t.props;if(s.length-1>n)return Sr(s[n+1]);{let i=o.pop(),a=we(r,A(t,"path"));if(a&&typeof i=="number"&&(o=a.props.path.split(".").map(l=>parseInt(l,10)),a.props.children.length-1>i)){let l=a.props.children[i+1];return re(O(l))?Sr(l):l}}}return Sr(r)}function Vy(r,e){let t=e.split(".").map(s=>parseInt(s,10)),o=t.pop(),n=we(r,e);if(n!=null&&typeof o=="number"){let{children:s}=n.props;if(o>0)return Cr(s[o-1]);for(;t.length>1;)if(o=t.pop(),n=we(r,A(n,"path")),o>0){let i=n.props.children[o-1];return re(O(i))?Cr(i):i}}return Cr(r)}function Sr(r){if(re(O(r))){let{children:e}=r.props||r;return Sr(e[0])}return r}function Cr(r){if(re(O(r))){let{children:e}=r.props||r;return Cr(e[e.length-1])}return r}function Se(r,e,t=!1){if(r===e)return{idx:-1,finalStep:!0};let o=`${r}.`;if(!e.startsWith(o))throw Error("pathUtils nextStep has strayed from the path");let n=t?0:1,s=e.replace(o,"").split(".").map(i=>parseInt(i,10));return{idx:s[0],finalStep:s.length===n}}function j(r,e,t){if(A(r,"path")===e)return r;let o=[];Ne.Children.forEach(r.props.children,(s,i)=>{A(s,"path")?o.push(j(s,`${e}.${i}`)):o.push(s)});let n=r.props["data-path"]?"data-path":"path";return Ne.cloneElement(r,{[n]:e,...t},o)}function Ny(r,e){typeof r=="function"?r(e):r&&(r.current=e)}import{Children as Qu,isValidElement as Ms,useLayoutEffect as Ku,useMemo as ju,useRef as Xu}from"react";var Zu=[],Yu=0,pt=r=>{let e=Array.isArray(r),t=e?r.length:Qu.count(r);return e&&r.every(Ms)?r:t===1&&!e&&Ms(r)?[r]:t>1?r:Zu},Ls=(r,e)=>{let t=Xu(!1);Ku(()=>{t.current?r():t.current=!0},e)},dt=r=>ju(()=>r!=null?r:`vuu-${++Yu}`,[r]);var No=r=>{if(typeof r!="number")throw Error(`"no support yet for flex value ${r}`);return{flexBasis:0,flexGrow:1,flexShrink:1}};import{boxContainsPoint as Rr}from"@vuu-ui/vuu-utils";var Ze={north:1,east:2,south:4,west:8,header:16,centre:32,absolute:64},Nt={AFTER:"after",BEFORE:"before"},ce=Object.freeze({North:Xe("north"),East:Xe("east"),South:Xe("south"),West:Xe("west"),Header:Xe("header"),Centre:Xe("centre"),Absolute:Xe("absolute")});function Xe(r){return Object.freeze({offset:r==="north"||r==="west"?0:r==="south"||r==="east"?1:NaN,valueOf:function(){return Ze[r]},toString:function(){return r},North:r==="north",South:r==="south",East:r==="east",West:r==="west",Header:r==="header",Centre:r==="centre",NorthOrSouth:r==="north"||r==="south",EastOrWest:r==="east"||r==="west",NorthOrWest:r==="north"||r==="west",SouthOrEast:r==="east"||r==="south",Absolute:r==="absolute"})}var Ds=ce.North,Is=ce.South,_o=ce.East,Bo=ce.West,ec=ce.Header,tc=ce.Centre,ht=class{static measure(e,t=[]){let o={};return nc(e,o,t),o}static allBoxesContainingPoint(e,t,o,n,s){return As(e,t,o,n,s).reverse()}};function Fo(r,e,t,o=30){let n=t.right-t.left,s=t.bottom-t.top,i=r-t.left,a=e-t.top,l=0;return i<o&&(l+=8),i>n-o&&(l+=2),a<o&&(l+=1),a>s-o&&(l+=4),{pctX:i/n,pctY:a/s,closeToTheEdge:l}}function zo(r,e,t,o){let{BEFORE:n,AFTER:s}=Nt,{pctX:i,pctY:a,closeToTheEdge:l}=Fo(r,e,t),u,c;if(o==="row")u=i<.5?Bo:_o;else if(t.header&&Rr(t.header,r,e))if(u=ec,t.Stack){let p=t.Stack.length;if(p===0)c={index:-1,left:t.left,positionRelativeToTab:s,width:0};else{let d=t.Stack.find(({left:h,right:f})=>r>=h&&r<=f);if(d){let h=d.right-d.left;c={index:t.Stack.indexOf(d),left:d.left,positionRelativeToTab:(r-d.left)/h<.5?n:s,width:h}}else c={left:t.Stack[p-1].right,width:0,index:p,positionRelativeToTab:s}}}else if(t.header.titleWidth){let p=t.header.titleWidth;c={index:-1,left:t.left,positionRelativeToTab:(r-t.left)/p<.5?n:s,width:p}}else c={left:t.left,width:0,positionRelativeToTab:n,index:-1};else u=rc(r,e,t,i,a);return{position:u,x:r,y:e,closeToTheEdge:l,tab:c}}function rc(r,e,t,o,n){let s=oc(t,.2);if(Rr(s,r,e))return tc;switch(`${n<.5?"north":"south"}${o<.5?"west":"east"}`){case"northwest":return o>n?Ds:Bo;case"northeast":return 1-o>n?Ds:_o;case"southeast":return o>n?_o:Is;case"southwest":return 1-o>n?Bo:Is;default:}}function oc({right:r,left:e,top:t,bottom:o},n){let s=(1-n)/2,i=(r-e)*s,a=(o-t)*s;return{left:e+i,top:t+a,right:r-i,bottom:o-a}}function nc(r,e,t){let{id:o,"data-path":n,path:s=n}=I(r),i=O(r);if(o&&s){let[a,l]=Vs(r);ks(r,a,l,e),re(i)&&Os(r,e,t)}}function ks(r,e,t,o){let{"data-path":n,path:s=n,header:i}=I(r);o[s]=e;let a=O(r);if(i||a==="Stack"){let l=a==="Stack"?".vuuTabstrip":".vuuHeader",u=t.querySelector(l);if(u){let{top:c,left:p,right:d,bottom:h}=u.getBoundingClientRect();if(o[s].header={top:Math.round(c),left:Math.round(p),right:Math.round(d),bottom:Math.round(h)},a==="Stack")o[s].Stack=Array.from(u.querySelectorAll(".vuuTab")).map(f=>f.getBoundingClientRect()).map(({left:f,right:b})=>({left:f,right:b}));else{let f=u.querySelector('[class^="vuuHeader-title"]'),{header:b}=o[s];f&&b&&(b.titleWidth=f.clientWidth)}}}return o[s]}function Os(r,e,t,o=0,n=0,s=0,i=0){let{children:a,"data-path":l,path:u=l,style:c,active:p=0}=I(r),d=O(r),h=d==="Flexbox",f=d==="Stack",b=h&&c.flexDirection==="column",y=h&&c.flexDirection==="row",C=(f?a.filter((w,x)=>x===p):a.filter(sc)).map(w=>{let[x,v]=Vs(w);return[{...x,top:x.top-s,right:x.right+n,bottom:x.bottom+i,left:x.left-o},v,w]}),R=C.map(([w,x,v],S,E)=>{let M,P,T,D,V,_,F=E.length-1;y?(V=S===0?0:w.left-E[S-1][0].right,_=S===F?0:E[S+1][0].left-w.right,M=S===0||V===0?0:V,P=S===F||_===0?0:_-_/2,w.left-=M,w.right+=P,T=s,D=i):b&&(V=S===0?0:w.top-E[S-1][0].bottom,_=S===F?0:E[S+1][0].top-w.bottom,T=S===0||V===0?0:V,D=S===F||_===0?0:_-_/2,w.top-=T,w.bottom+=D,M=o,P=n);let z=ks(v,w,x,e),ee=O(v);return re(ee)&&Os(v,e,t,M,P,T,D),z});C.length&&(e[u].children=R)}function sc(r){let{id:e}=I(r),t=document.getElementById(e);return t?t.dataset.dragging!=="true":(console.warn(`BoxModel: no element found with id #${e}`),!1)}function Vs(r){let{id:e}=I(r);if(e===void 0)throw Error("`BoxModel.measureComponentElement, component has no id");let t=document.getElementById(e);if(!t)throw Error("BoxModel.measureComponentElement, no DOM element found for component");let{top:o,left:n,right:s,bottom:i,height:a,width:l}=t.getBoundingClientRect(),u,c=O(r);if(re(c)){let p=t.scrollHeight;p>a&&(u={id:e,scrollHeight:p,scrollTop:t.scrollTop})}return[{top:Math.round(o),left:Math.round(n),right:Math.round(s),bottom:Math.round(i),height:Math.round(a),width:Math.round(l),scrolling:u},t,r]}function As(r,e,t,o,n,s=[]){let{children:i,"data-path":a,path:l=a}=I(r),u=O(r),c=e[l];if(!Rr(c,t,o))return s;if(n&&n.length){if(n.includes(l))s.push(r);else if(!n.some(p=>p.startsWith(l)))return s}else s.push(r);if(!re(u)||c.header&&Rr(c.header,t,o))return s;c.scrolling&&ic(c,t,o);for(let p=0;p<i.length;p++){if(u==="Stack"&&r.props.active!==p)continue;let d=As(i[p],e,t,o,n);if(d.length)return s.concat(d)}return s}function ic({top:r,bottom:e,scrolling:t},o,n){if(t){let{id:s,scrollTop:i,scrollHeight:a}=t,l=e-r;if(i===0&&e-n<50){let u=a-l;document.getElementById(s).scrollTo({left:0,top:u,behavior:"smooth"}),t.scrollTop=u}else if(i>0&&n-r<50)document.getElementById(s).scrollTo({left:0,top:0,behavior:"smooth"}),t.scrollTop=0;else return!1}else return!1}var ac=.4,xr=class{constructor(e,t,o,n,s){this.init(e,t,o,n,s)}init(e,t,o,n,s){let{left:i,top:a}=n,{pctX:l,pctY:u}=Fo(t,o,n),c=ac,p=l*n.width,d=n.width-p,h=u*n.height,f=n.height-h,b=n.width*c,y=n.height*c,g=1-c,C=p*g,R=h*g,w=d*g,x=f*g;this.intrinsicSize=s,this.constraint={zone:{x:{lo:e.left,hi:e.right},y:{lo:e.top,hi:e.bottom}},pos:{x:{lo:e.left-C,hi:e.right-n.width+w},y:{lo:e.top-R,hi:e.bottom-n.height+x}},mouse:{x:{lo:e.left+b*l,hi:e.right-b*(1-l)},y:{lo:e.top+y*u,hi:e.bottom-y*(1-u)}}},this.x={pos:i,lo:!1,hi:!1,mousePos:t,mousePct:l},this.y={pos:a,lo:!1,hi:!1,mousePos:o,mousePct:u}}outOfBounds(){return this.x.lo||this.x.hi||this.y.lo||this.y.hi}inBounds(){return!this.outOfBounds()}dropX(){return this.dropXY("x")}dropY(){return this.dropXY("y")}hasIntrinsicSize(){var e,t;return((e=this==null?void 0:this.intrinsicSize)==null?void 0:e.height)&&((t=this==null?void 0:this.intrinsicSize)==null?void 0:t.width)}update(e,t){let o=this[e],n=this.constraint.mouse[e],s=this.constraint.pos[e],i=o.pos,a=t-o.mousePos;return a<0?o.lo||(t<n.lo?(o.lo=!0,o.pos=s.lo):o.hi?t<n.hi&&(o.hi=!1,o.pos+=a):o.pos+=a):a>0&&(o.hi||(t>n.hi?(o.hi=!0,o.pos=s.hi):o.lo?t>n.lo&&(o.lo=!1,o.pos+=a):o.pos+=a)),o.mousePos=t,i!==o.pos}dropXY(e){let t=this[e],o=this.constraint.zone[e];return t.lo?Math.max(o.lo,t.mousePos):t.hi?Math.min(t.mousePos,Math.round(o.hi)-1):t.mousePos}};var ab=r=>r.pos.tab&&O(r.component)==="Stack"&&r.pos.position.Header,{north:lc,south:uc,east:cc,west:pc}=Ze,dc=cc+pc,hc=lc+uc,_e=class{constructor({component:e,pos:t,clientRect:o,nextDropTarget:n}){this.component=e,this.pos=t,this.clientRect=o,this.nextDropTarget=n,this.active=!1,this.dropRect=void 0}targetTabPos(e){let{left:t,width:o,positionRelativeToTab:n}=e;return n===Nt.BEFORE?t:t+o}getTargetDropOutline(e,t){if(this.pos.tab)return this.getDropTabOutline(e,this.pos.tab);if(t&&t.hasIntrinsicSize())return this.getIntrinsicDropRect(t);{let[o,n,s,i]=this.getDropRectOutline(e,t);return{l:o,t:n,r:s,b:i}}}getDropTabOutline(e,t){var g,C;let{clientRect:{top:o,left:n,right:s,bottom:i,header:a}}=this,l=0,u=Math.round(e/2)+l,c=Math.round(o),p=Math.round(n+u),d=Math.round(s-u),h=Math.round(i-u),f=this.targetTabPos(t),b=60,y=((g=a==null?void 0:a.bottom)!=null?g:0)-((C=a==null?void 0:a.top)!=null?C:0);return{l:p,t:c,r:d,b:h,tabLeft:f,tabWidth:b,tabHeight:y}}getIntrinsicDropRect(e){var b,y,g,C;let{pos:t,clientRect:o}=this,{x:n,y:s}=e,i=(y=(b=e.intrinsicSize)==null?void 0:b.height)!=null?y:0,a=(C=(g=e.intrinsicSize)==null?void 0:g.height)!=null?C:0;i&&i>o.height?(console.log("DropTarget: we're going to blow the gaff"),i=o.height):a&&a>o.width&&(console.log("DropTarget: we're going to blow the gaff"),a=o.width);let l=Math.min(o.right-a,Math.max(o.left,Math.round(t.x-n.mousePct*a))),u=Math.min(o.bottom-i,Math.max(o.top,Math.round(t.y-s.mousePct*i))),[c,p,d,h]=this.dropRect=[l,u,l+a,u+i],f=t.position.EastOrWest?[c,o.top,c,o.bottom,d,o.top,d,o.bottom]:[o.left,p,o.right,p,o.left,h,o.right,h];return{l:c,r:d,t:p,b:h,guideLines:f}}getDropRectOutline(e,t){var C,R,w;let{pos:o,clientRect:n}=this,{width:s,height:i,position:a}=o,{width:l,height:u}=(C=t==null?void 0:t.intrinsicSize)!=null?C:{},c=(R=u!=null?u:i)!=null?R:0,p=(w=l!=null?l:s)!=null?w:0;this.dropRect=void 0;let{top:d,left:h,right:f,bottom:b}=n,y=0,g=Math.round(e/2)+y;switch(a){case ce.North:case ce.Header:{let x=Math.round((b-d)/2),v=c?Math.min(x,Math.round(c)):x;return p&&h+p<f?[h+g,d+g,h+p-g,d+g+v]:[h+g,d+g,f-g,d+g+v]}case ce.West:{let x=Math.round((f-h)/2),v=p?Math.min(x,Math.round(p)):x;return c&&d+c<b?[h+g,d+g,h-g+v,d+c+g]:[h+g,d+g,h-g+v,b-g]}case ce.East:{let x=Math.round((f-h)/2),v=p?Math.min(x,Math.round(p)):x;return c&&d+c<b?[f-g-v,d+g,f-g,d+c+g]:[f-g-v,d+g,f-g,b-g]}case ce.South:{let x=Math.round((b-d)/2),v=c?Math.min(x,Math.round(c)):x;return p&&h+p<f?[h+g,b-g-v,h+p-g,b-g]:[h+g,b-g-v,f-g,b-g]}case ce.Centre:return[h+g,d+g,f-g,b-g];default:return console.warn(`DropTarget does not recognize position ${a}`),null}}activate(){return this.active=!0,this}toArray(){let e=this,t=[e];for(;e=e.nextDropTarget;)t.push(e);return t}static getActiveDropTarget(e){return e===null?null:e!=null&&e.active?e:_e.getActiveDropTarget(e.nextDropTarget)}};function Ho(r,e,t,o,n,s){var l;let i=null,a=ht.allBoxesContainingPoint(t,o,r,e,s);if(a.length){let[u,...c]=a,{"data-path":p,path:d=p,"data-row-placeholder":h}=I(u),f=o[d],y=zo(r,e,f,n&&h?"row":void 0),g=o[d],C=([R,...w])=>{var x,v;if((x=y.position)!=null&&x.Header||y.closeToTheEdge){let S=fc(R,y,g,o,r,e);if(S){let[E,M]=S;return new _e({component:R,pos:E,clientRect:M,nextDropTarget:(v=C(w))!=null?v:null})}else if(w.length)return C(w)}};i=new _e({component:u,pos:y,clientRect:f,nextDropTarget:(l=C(c))!=null?l:null}).activate()}return i}function fc(r,{closeToTheEdge:e,position:t},o,n,s,i){if(!r||r.type==="DraggableLayout")return;let a=n[r.props.path],l=e&Ze.north,u=e&Ze.east,c=e&Ze.south,p=e&Ze.west,d=(l||t.Header)&&Math.round(o.top)===Math.round(a.top),h=u&&Math.round(o.right)===Math.round(a.right),f=c&&Math.round(o.bottom)===Math.round(a.bottom),b=p&&Math.round(o.left)===Math.round(a.left);if(d||h||f||b){let{"data-path":y,path:g=y}=r.props,C=n[g],R=zo(s,i,C);if((mc(r)||Ns(r))&&e&dc)return R.width=120,[R,C];if((gc(r)||Ns(r))&&(t.Header||e&hc))return R.height=120,[R,C]}}function Ns(r){return O(r)==="Stack"}function mc(r){return O(r)==="Flexbox"&&r.props.style.flexDirection==="column"}function gc(r){return O(r)==="Flexbox"&&r.props.style.flexDirection==="row"}import{PopupService as Wo}from"@vuu-ui/vuu-popups";import yc from"classnames";import{jsx as _s}from"react/jsx-runtime";function Bs(r,e=0,t=0){let{pos:o,clientRect:n}=r,s=20;return o.position.West?[n.left-t+s,o.y-e,"left"]:o.position.South?[o.x-t,n.bottom-e-s,"bottom"]:o.position.East?[n.right-t-s,o.y-e,"right"]:[o.x-t,n.top-e+s,"top"]}var $o="vuuDropMenu",Fs=({className:r,dropTarget:e,onHover:t,orientation:o})=>{let n=e.toArray();return _s("div",{className:yc($o,r,`${$o}-${o}`),onMouseLeave:()=>t(null),children:n.map((s,i)=>_s("div",{className:`${$o}-item`,"data-icon":i===0?"column-2A":"column-2B",onMouseEnter:()=>t(s)},i))})};import{jsx as xc}from"react/jsx-runtime";var Uo=!1,_t=null,Ce=null,bc=r=>_t=r,vc=([r,e])=>`M${r},${e}`,wc=([r,e])=>`L${r},${e}`,zs=([r,...e])=>`${vc(r)} ${e.map(wc)}Z`,Sc=r=>{if(r){let[e,t,o,n,s,i,a,l]=r;return`M${e},${t} L${o},${n} M${s},${i} L${a},${l}`}else return""};function Cc(){if(document.getElementById("hw-drag-canvas")===null){let r=document.getElementById("root"),e=document.createElement("div");e.id="hw-drag-canvas",e.innerHTML=`
|
|
2
2
|
<svg width="100%" height="100%">
|
|
3
3
|
<path id="hw-drop-guides" />
|
|
4
4
|
<path
|
|
@@ -14,227 +14,9 @@ var Lh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var T=(r,e,t)=>(Lh(r
|
|
|
14
14
|
/>
|
|
15
15
|
</path>
|
|
16
16
|
</svg>
|
|
17
|
-
`,document.body.insertBefore(e,r)}}var So=class{constructor(){this.currentPath=null;this.tabMode=null;ov()}prepare(e,t="full-view"){document.body.classList.add("drawing"),this.currentPath=null,this.tabMode=t;let n=this.getPoints(0,0,0,0),o=af(n),i=document.getElementById("vuu-drop-outline");i==null||i.setAttribute("d",o),this.currentPath=o}clear(){wo=null,Bi(),document.body.classList.remove("drawing"),ha.hidePopup()}get hoverDropTarget(){return wo}getPoints(e,t,n,o,i=0,s=0,l=0){let a=this.tabMode==="tab-only";if(s===0)return[[e,t+l],[e,t+l],[e,t],[e+s,t],[e+s,t],[e+n,t],[e+n,t+o],[e,t+o]];if(a){let c=i;return[[c,t],[c,t],[c+s,t],[c+s,t],[c+s,t+l],[c+s,t+l],[c,t+l],[c,t+l]]}else return i===0?[[e,t+l],[e,t+l],[e,t],[e+s,t],[e+s,t+l],[e+n,t+l],[e+n,t+o],[e,t+o]]:[[e,t+l],[e+i,t+l],[e+i,t],[e+i,t],[e+i,t+l],[e+n,t+l],[e+n,t+o],[e,t+o]]}draw(e,t){let o=fa;if(wo!==null)this.drawTarget(wo);else if(fa=e.nextDropTarget!=null,e.pos.tab?iv(e):Rt&&Bi(),this.drawTarget(e,t),fa){let[i,s,l]=sf(e);{let a=sv(lf,{dropTarget:e,onHover:ev,orientation:l});ha.showPopup({left:i,top:s,component:a})}}else ha.hidePopup()}drawTarget(e,t){let o=e.getTargetDropOutline(6,t);if(o){let{l:i,t:s,r:l,b:a,tabLeft:c,tabWidth:u,tabHeight:h,guideLines:f}=o,d=l-i,p=a-s;if(this.currentPath){let w=document.getElementById("vuu-drop-outline");w==null||w.setAttribute("d",this.currentPath)}let m=this.getPoints(i,s,d,p,c,u,h),y=af(m),g=document.getElementById("hw-drop-outline-animate");g==null||g.setAttribute("to",y),g==null||g.beginElement(),this.currentPath=y;let v=document.getElementById("hw-drop-guides");v==null||v.setAttribute("d",rv(f))}}},cf="transition:margin-left .4s ease-out;margin-left: 63px",uf="transition:margin-left .4s ease-out;margin-left: 0px";function iv(r){var l,a;let{AFTER:e,BEFORE:t}=vo,{clientRect:{Stack:n},pos:{tab:o}}=r,{id:i}=r.component.props,s=null;if(n&&o&&o.positionRelativeToTab!==e){let c=o.positionRelativeToTab===t?1:2,u=`:scope .hwTabstrip > .hwTabstrip-inner > .hwTab:nth-child(${o.index+c})`;s=(l=document.getElementById(i))==null?void 0:l.querySelector(u),s?(Rt===null||Rt!==s)&&(s.style.cssText=cf,Rt&&(Rt.style.cssText=uf),Rt=s):Bi()}else if((o==null?void 0:o.positionRelativeToTab)===t){if(Rt===null){let c=".vuuHeader-title";s=(a=document.getElementById(i))==null?void 0:a.querySelector(c),s.style.cssText=cf,Rt=s}}else Bi()}function Bi(){Rt&&(Rt.style.cssText=uf,Rt=null)}var Xt,Co,mn,ff,df,_n,Hi,zn=null,pa,pf,zi,mf,da,_i=null,lv=3,Wi=new So,hf=.4;function av(r,e){return e?Te(r,e):Yt(r,t=>t.dropTarget)}var ma={handleMousedown(r,e,t={}){Xt=e,pf=t,ff=r.clientX,df=r.clientY,da=t.dragThreshold===void 0?lv:t.dragThreshold,da===0?Xt(r,0,0):(window.addEventListener("mousemove",$i,!1),window.addEventListener("mouseup",Ui,!1),_i=window.setTimeout(()=>{window.removeEventListener("mousemove",$i,!1),window.removeEventListener("mouseup",Ui,!1),Xt==null||Xt(r,0,0)},500)),r.preventDefault()},initDrag(r,e,{top:t,left:n,right:o,bottom:i},s,l,a,c){return{drag:Co,drop:mn}=l,cv(r,e,{top:t,left:n,right:o,bottom:i},s,a,c)}};function $i(r){let n=r.clientX-ff,o=r.clientY-df;Math.max(Math.abs(n),Math.abs(o))>da&&(window.removeEventListener("mousemove",$i,!1),window.removeEventListener("mouseup",Ui,!1),Xt==null||Xt(r,n,o),Xt=null)}function Ui(){_i&&(window.clearTimeout(_i),_i=null),window.removeEventListener("mousemove",$i,!1),window.removeEventListener("mouseup",Ui,!1)}function cv(r,e,t,n,o,i){_n=av(r,e);let{"data-path":s,path:l=s}=_(_n);i&&(pa=i.map(f=>Yt(r,d=>d.id===f)).map(f=>f.props.path)),zi=Cr.measure(_n,i);let a=zi[l];Hi=new Fi(a,n.x,n.y,t,o);let c=Math.round(Hi.x.mousePct*100),u=Math.round(Hi.y.mousePct*100);return window.addEventListener("mousemove",gf,!1),window.addEventListener("mouseup",bf,!1),window.addEventListener("keydown",yf,!1),mf=!1,Wi.prepare(t,"tab-only"),pf.DoNotTransform?"transform:none":`transform:scale(${hf},${hf});transform-origin:${c}% ${u}%;`}function gf(r){let e=r.clientX,t=r.clientY,n=Hi,o=zn,i,s,l;n.update("x",e)&&(s=n.x.pos),n.update("y",t)&&(l=n.y.pos),s===void 0&&l===void 0||Co==null||Co(s,l),!(mf||_n===void 0)&&(n.inBounds()?i=ca(e,t,_n,zi,n.hasIntrinsicSize(),pa):i=ca(n.dropX(),n.dropY(),_n,zi),o&&(i==null||i.box!==o.box)&&(zn=null),i&&(Wi.draw(i,n),zn=i))}function yf(r){r.key==="Escape"&&(zn=null,xf())}function bf(){xf()}function xf(){if(zn){let r=Wi.hoverDropTarget||pn.getActiveDropTarget(zn);mn==null||mn(r),zn=null}else mn==null||mn();Co=null,mn=null,_n=void 0,Wi.clear(),pa=void 0,window.removeEventListener("mousemove",gf,!1),window.removeEventListener("mouseup",bf,!1),window.removeEventListener("keydown",yf,!1)}import uv from"classnames";import{forwardRef as hv}from"react";import{jsx as fv}from"react/jsx-runtime";var To=hv(function({children:e,className:t,dropTarget:n,resizeable:o,...i},s){let l=uv("DraggableLayout",t);return fv("div",{className:l,ref:s,...i,children:e})}),vf="DraggableLayout";To.displayName=vf;ge(vf,To,"container");import{useForkRef as Nv}from"@salt-ds/core";import Vv from"classnames";import{forwardRef as Fv}from"react";import{getUniqueId as Rv}from"@vuu-ui/vuu-utils";import Io,{useCallback as Qi,useMemo as Lf,useRef as Yi,useState as Iv}from"react";import dv from"classnames";import{jsx as pv}from"react/jsx-runtime";var wf="vuuPlaceholder",Gi=({className:r,closeable:e,flexFill:t,resizeable:n,shim:o,...i})=>pv("div",{className:dv(wf,r,{[`${wf}-shim`]:o}),...i,"data-placeholder":!0,"data-resizeable":!0});Gi.displayName="Placeholder";ge("Placeholder",Gi);import mv from"classnames";import gv,{useCallback as ko,useRef as qi,useState as yv}from"react";import{jsx as Sf}from"react/jsx-runtime";var Ki="vuuSplitter",Cf=gv.memo(function({column:e,index:t,onDrag:n,onDragEnd:o,onDragStart:i,style:s}){let l=qi(),a=qi(null),c=qi(0),[u,h]=yv(!1),f=ko(({key:b,shiftKey:C})=>{let k=C?10:1;e&&b==="ArrowDown"?n(t,k):e&&b==="ArrowUp"||!e&&b==="ArrowLeft"?n(t,-k):!e&&b==="ArrowRight"&&n(t,k)},[e,t,n]),d=ko(b=>{let{key:C}=b;(e&&(C==="ArrowUp"||C==="ArrowDown")||!e&&(C==="ArrowLeft"||C==="ArrowRight"))&&(i(t),f(b),p.current=f)},[e,f,t,i]),p=qi(d),m=b=>p.current(b),y=ko(b=>{l.current=!0;let C=b[e?"clientY":"clientX"],k=C-c.current;C&&C!==c.current&&n(t,k),c.current=C},[e,t,n]),g=ko(()=>{var b;window.removeEventListener("mousemove",y,!1),window.removeEventListener("mouseup",g,!1),o(),h(!1),(b=a.current)==null||b.focus()},[y,o,h]),v=ko(b=>{c.current=e?b.clientY:b.clientX,i(t),window.addEventListener("mousemove",y,!1),window.addEventListener("mouseup",g,!1),b.preventDefault(),h(!0)},[e,y,g,t,i,h]),w=()=>{var b;l.current?l.current=!1:(b=a.current)==null||b.focus()},x=()=>{p.current=d},S=mv(Ki,{[`${Ki}-active`]:u,[`${Ki}-column`]:e});return Sf("div",{className:S,"data-splitter":!0,ref:a,role:"separator",style:s,onBlur:x,onClick:w,onKeyDown:m,onMouseDown:v,tabIndex:0,children:Sf("div",{className:`${Ki}-grab-zone`})})});import{uuid as Tf}from"@vuu-ui/vuu-utils";import kf from"react";var bv={"data-placeholder":!0,"data-resizeable":!0},ji={},gn="auto",ga={flexBasis:0,flexGrow:1,flexShrink:1,height:gn,width:gn},Mf={height:"width",width:"height"},Ef=(r="row")=>r==="row"?["width","height","column"]:["height","width","row"],xv=r=>typeof r=="string"&&r.endsWith("%"),at=r=>{let{style:{width:e=gn,height:t=gn}=ji}=r.props,n=typeof t=="number",o=typeof e=="number";return n&&o?{height:t,width:e}:n?{height:t}:o?{width:e}:void 0};function ya(r,e,t){let n=Mf[e],{style:{[n]:o=gn,...i}=ji}=r.props;return t&&t[e]?{...i,...ga,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...i,...ga,[n]:o}}function Rf(r){let{style:{flex:e,flexGrow:t,flexShrink:n,flexBasis:o}=ji}=r.props;return typeof e=="number"||o===0&&t===1&&n===1?!0:typeof o!="number"}function ba(r,e,t){let n=Mf[e],{style:{[e]:o=gn,[n]:i=gn,...s}=ji}=r.props;return o!==gn?xv(o)?{flexBasis:0,flexGrow:1,flexShrink:1,[e]:void 0,[n]:i}:{flexBasis:o,flexGrow:0,flexShrink:0,[e]:o,[n]:i}:t&&t[e]?{...s,...ga,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...s,[n]:i}}function Mo(r,e,t,n,o){let i=[],s=0,l;if(n&&o){let u,[h,f,d,p]=o;[u,l]=e==="column"?[f-n.top,n.bottom-p]:[h-n.left,n.right-d],u&&i.push(Ft(`${t}.${s++}`,u,{flexGrow:0,flexShrink:0}))}else l=!0;let{version:a=0,style:c}=_(r);return i.push(Ee(r,`${t}.${s++}`,{version:a+1,style:{...c,flexBasis:"auto",flexGrow:0,flexShrink:0}})),l&&i.push(Ft(`${t}.${s++}`,0,void 0,{[`data-${e}-placeholder`]:!0})),xa(e,{resizeable:!1,style:{flexBasis:"auto"}},i,t)}var vv=(r,e)=>{if(!e)return r===0?1:0};function xa(r,e,t,n){let o=Tf(),{flexFill:i,style:s,resizeable:l=!0}=e,{flexBasis:a=i?void 0:"auto"}=s,c=vv(a,i);return kf.createElement(Fn.Flexbox,{id:o,key:o,path:n,flexFill:i,style:{...s,flexDirection:r,flexBasis:a,flexGrow:c,flexShrink:c},resizeable:l},t)}var wv={flexGrow:1,flexShrink:1};function Ft(r,e,t,n){let o=Tf();return kf.createElement("div",{...bv,...n,"data-path":r,id:o,key:o,style:{...wv,...t,flexBasis:e}})}var Sv={},Eo=1,Ro=2,Cv=r=>typeof r.intrinsicSize=="number",Tv=(r,e)=>{let t={};return r.forEach(n=>{t[n]=q(e,n)}),t},Ji=(r,e,t)=>r.map((n,o)=>{var a;let i=q(n,"resizeable"),{[e]:s}=(a=at(n))!=null?a:Sv,l=Rf(n);return t?{index:o,flexOpen:l,intrinsicSize:s,resizeable:i,...Tv(t,n)}:{index:o,flexOpen:l,intrinsicSize:s,resizeable:i}}),If=r=>{let e=r.length,t=r.every(Cv),n=Array(e).fill(0);if(t&&e>0&&(n[0]=Ro,n[e-1]=Ro),e<2)return n;for(let o=0,i=0;o<e-1;o++)r[o].resizeable&&!i&&(i=Eo),n[o]+=i;for(let o=e-1;o>0&&(n[o]&Eo&&(n[o]-=Eo),!r[o].resizeable);o--);return n},Pf=(r,e)=>{let t=Mv(r,e),n=Ev(r,e),o=t!==-1&&n!==-1?[t,n]:void 0,i=kv(r,o);return[o,i]};function kv(r,e){if(e){let t=[];for(let n=0;n<r.length;n++)r[n].flexOpen&&!e.includes(n)&&t.push(n);return t}}function Mv(r,e){let t=e,n=!1;for(;t>=1&&!n;)t=t-1,n=Df(r,t);return t}function Ev(r,e){let t=e,n=!1,o=r.length;for(;t<o-1&&!n;)t=t+1,n=Df(r,t);return t===o?-1:t}function Df(r,e){let{placeholder:t,splitter:n,resizeable:o,intrinsicSize:i}=r[e];return!!(!n&&!i&&(t||o))}var Pv=r=>!r.splitter&&!r.placeholder,Of=({children:r,onSplitterMoved:e,style:t})=>{let n=Yi(null),o=Yi(),i=Yi(),s=Yi([]),[,l]=Iv({}),a=y=>{i.current=y,l({})},c=(t==null?void 0:t.flexDirection)==="column",u=c?"height":"width",h=Lf(()=>Array.isArray(r)?r:Io.isValidElement(r)?[r]:[],[r]),f=Qi(y=>{let{current:g}=o;if(g){let[v,w]=Pf(g,y);v&&(v.forEach(x=>{var b;let S=(b=n.current)==null?void 0:b.childNodes[x];if(S){let{size:C,minSize:k}=Ov(S,u);g[x].currentSize=C,g[x].minSize=k}}),w&&w.forEach(x=>{var b;let S=(b=n.current)==null?void 0:b.childNodes[x];if(S){let{[u]:C}=S.getBoundingClientRect();g[x].flexBasis=C}}))}},[u]),d=Qi((y,g)=>{i.current&&o.current&&a(Lv(i.current,o.current,g,u))},[u]),p=Qi(()=>{let y=o.current;y&&(e==null||e(y.filter(Pv))),y==null||y.forEach(g=>{g.currentSize=void 0,g.flexBasis=void 0,g.flexOpen=!1})},[e]),m=Qi(y=>Io.createElement(Cf,{column:c,index:y,key:`splitter-${y}`,onDrag:d,onDragEnd:p,onDragStart:f}),[d,p,f,c]);return Lf(()=>{let[y,g]=Dv(h,u,m,s.current);o.current=g,i.current=y},[h,m,u]),{content:i.current||[],rootRef:n}};function Dv(r,e,t,n){let o=Ji(r,e),i=If(o),s=[],l=[];for(let a=0;a<r.length;a++){let c=r[a];if(a===0&&i[a]&Ro&&(s.push(Af(a)),l.push({placeholder:!0,shim:!0})),c.key==null){let u=n[a]||(n[a]=Rv());s.push(Io.cloneElement(c,{key:u}))}else s.push(c);l.push(o[a]),a>0&&i[a]&Ro?(s.push(Af(a)),l.push({placeholder:!0})):i[a]&Eo&&(s.push(t(s.length)),l.push({splitter:!0}))}return[s,l]}function Lv(r,e,t,n){return Av(e,t)?r.map((i,s)=>{let l=e[s],{currentSize:a,flexOpen:c,flexBasis:u}=l,h=a!==void 0;if(h||c){let{flexBasis:f}=i.props.style||{},d=h?l.currentSize:u;return d!==f?Io.cloneElement(i,{style:{...i.props.style,flexBasis:d,[n]:"auto"}}):i}else return i}):r}function Av(r,e){let t=[];r.forEach((u,h)=>{u.currentSize!==void 0&&t.push(h)});let n=e<0?t[0]:t[1],{currentSize:o=0,minSize:i=0}=r[n];if(o===i)return!1;if(Math.abs(e)>o-i){let u=e<0?-1:1;e=Math.max(0,o-i)*u}let s=r[t[0]],{currentSize:l=0}=s;s.currentSize=l+e;let a=r[t[1]],{currentSize:c=0}=a;return a.currentSize=c-e,!0}function Af(r){return Io.createElement(Gi,{shim:r===0,key:`placeholder-${r}`})}function Ov(r,e){let{[e]:t}=r.getBoundingClientRect(),o=getComputedStyle(r).getPropertyValue(`min-${e}`),i=o.endsWith("px")?parseInt(o,10):0;return{size:t,minSize:i}}import{jsx as Bv}from"react/jsx-runtime";var va="hwFlexbox",Nf=Fv(function(e,t){let{breakPoints:n,children:o,column:i,className:s,flexFill:l,gap:a,fullPage:c,id:u,onSplitterMoved:h,resizeable:f,row:d,spacing:p,splitterSize:m,style:y,...g}=e,{content:v,rootRef:w}=Of({children:o,onSplitterMoved:h,style:y}),x=Vv(va,s,{[`${va}-column`]:i,[`${va}-row`]:d,"flex-fill":l,"full-page":c});return Bv("div",{...g,className:x,"data-resizeable":f||void 0,id:u,ref:Nv(w,t),style:{...y,gap:a,"--spacing":p},children:v})});Nf.displayName="Flexbox";var Po=Nf;import{useCallback as Rw}from"react";var Wn={ADD:"add",BLUR:"blur",BLUR_SPLITTER:"blur-splitter",DRAG_START:"drag-start",DRAG_STARTED:"drag-started",DRAG_DROP:"drag-drop",FOCUS:"focus",FOCUS_SPLITTER:"focus-splitter",INITIALIZE:"initialize",LAYOUT_RESIZE:"layout-resize",MAXIMIZE:"maximize",MINIMIZE:"minimize",REMOVE:"remove",REPLACE:"replace",RESTORE:"restore",SAVE:"save",SET_TITLE:"set-title",SPLITTER_RESIZE:"splitter-resize",SWITCH_TAB:"switch-tab",TEAR_OUT:"tear-out"};import{useCallback as Ra,useContext as Ia,useEffect as Cw,useRef as hd,useState as Tw}from"react";import Ma from"react";import{uuid as $f}from"@vuu-ui/vuu-utils";import Ao from"react";import{uuid as Hf}from"@vuu-ui/vuu-utils";import Do,{cloneElement as Hv}from"react";import{useCallback as Tr}from"react";var We=new Map,ct=new Map,Vf=r=>We.get(r),Ff=r=>We.has(r),Bf=(r,e)=>We.set(r,e),kr=()=>{let r=Tr((s,l)=>{let a=ct.get(s);if(a)return l!==void 0&&a[l]!==void 0?a[l]:l!==void 0?void 0:a},[]),e=Tr((s,l,a)=>{if(l===void 0)ct.set(s,a);else if(ct.has(s)){let c=ct.get(s);ct.set(s,{...c,[l]:a})}else ct.set(s,{[l]:a})},[]),t=Tr((s,l)=>{if(ct.has(s)){if(l===void 0)ct.delete(s);else if(ct.get(s)[l]){let{[l]:c,...u}=ct.get(s);Object.keys(u).length>0?ct.set(s,u):ct.delete(s)}}},[]),n=Tr((s,l)=>{let a=We.get(s);if(a)return l!==void 0?a[l]:a},[]),o=Tr((s,l,a)=>{if(l===void 0)We.set(s,a);else if(We.has(s)){let c=We.get(s);We.set(s,{...c,[l]:a})}else We.set(s,{[l]:a})},[]),i=Tr((s,l)=>{if(We.has(s)){if(l===void 0)We.delete(s);else if(We.get(s)[l]){let{[l]:c,...u}=We.get(s);Object.keys(u).length>0?We.set(s,u):We.delete(s)}}},[]);return{loadSessionState:r,loadState:n,saveSessionState:e,saveState:o,purgeState:i,purgeSessionState:t}};var _f=r=>r.flexDirection==="column"?["height","width"]:["width","height"],_v={},Lo=(r,e="0")=>{let[t,n]=Xi(K(r),r.props,e);return Do.cloneElement(r,t,n)},Sa=(r,e)=>{let t=K(r),[n,o]=Xi(t,r.props,"0",void 0,e);return Hv(r,n,o)},fO=(r,e,t)=>{let[n,o]=Xi(r,e,"0",void 0,t);return{...e,...n,type:r,children:o}};function zv(r,e,t="0",n=null,o){var m,y;let{active:i=0,"data-path":s,path:l=s,id:a,style:c}=_(o),u=K(o)===r&&t===l,h=u?a:(m=e.id)!=null?m:Hf(),f=r==="Stack"?(y=e.active)!=null?y:i:void 0,d=h,p=u?c:$v(r,e,n);return Vh(r)?{id:h,key:d,path:t,style:p,type:r,active:f}:{id:h,key:d,style:p,"data-path":t}}function Xi(r,e,t,n=null,o){var c,u;let i=zv(r,e,t,n,o);if(e.layout&&!o)return[i,[Mr(e.layout,`${t}.0`)]];let s=(u=o==null?void 0:o.children)!=null?u:(c=o==null?void 0:o.props)==null?void 0:c.children,a=e.dropTarget&&s?s:Wv(r,e.children,t,s);return[i,a]}function Wv(r,e,t="0",n){let o=Array.isArray(e)?e:Do.isValidElement(e)?[e]:[];return ze(r)?o.map((i,s)=>{let l=K(i),a=K(n==null?void 0:n[s]);if(!a||l===a){let[c,u]=Xi(l,i.props,`${t}.${s}`,r,n==null?void 0:n[s]);return Do.cloneElement(i,c,u)}return n==null?void 0:n[s]}):e}var $v=(r,e,t)=>{let{style:n=_v}=e;if(r==="Flexbox"&&(n={flexDirection:e.column?"column":"row",...n,display:"flex"}),n.flex){let{flex:o,...i}=n;n={...i,...oa(typeof o=="number"?o:0)}}else t==="Stack"?n={...n,...oa(1)}:t==="Flexbox"&&(n.width||n.height)&&n.flexBasis===void 0&&(n={...n,flexBasis:"auto",flexGrow:0,flexShrink:0});return n};function Mr({id:r=Hf(),type:e,children:t,props:n,state:o},i){let s=e.match(/^[a-z]/)?e:Fn[e];if(s===void 0)throw Error(`layoutUtils unable to create component from JSON, unknown type ${e}`);return o&&Bf(r,o),Do.createElement(s,{id:r,...n,key:r,path:i},t?t.map((l,a)=>Mr(l,`${i}.${a}`)):void 0)}function zf(r){return Wf(r)}function Wf(r){let e=K(r),{id:t,children:n,type:o,...i}=_(r),s=Ff(t)?Vf(t):void 0;return{id:t,type:e,props:Uv(i),state:s,children:Do.Children.map(n,Wf)}}function Uv(r){if(r){let{path:e,...t}=r,n={};for(let[o,i]of Object.entries(t))n[o]=wa(i);return n}}function wa(r){if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;if(Array.isArray(r))return r.map(wa);if(typeof r=="object"&&r!==null){let e={};for(let[t,n]of Object.entries(r))e[t]=wa(n);return e}}function Uf(r,e){var s;let t=r.props.children,n=t.length,{index:o=-1,positionRelativeToTab:i="after"}=e.tab||{};return o===-1||o>=n?[t[n-1],"after"]:[(s=t[o])!=null?s:null,i]}function Zi(r,e,t){let{active:n,children:o=[],path:i}=_(r),s=q(e,"path"),{idx:l,finalStep:a}=Et(i,s,!0),[c,u]=a?Gv(r,o,t):[n,o==null?void 0:o.map((f,d)=>d===l?Zi(f,e,t):f)],h=K(r)==="Stack"?Array.isArray(c)?c[0]:c:n;return Ao.cloneElement(r,{active:h},u)}function Gv(r,e,t){let n=q(r,"path"),o=e==null?void 0:e.length,{id:i=$f()}=_(t);return o?[o,e.concat(Ee(t,`${n}.${o}`,{id:i,key:i}))]:[0,[Ee(t,`${n}.0`,{id:i})]]}function es(r,e,t,n,o,i,s){let{active:l,children:a,path:c}=_(r),u=q(e,"path"),{idx:h,finalStep:f}=Et(c,u),[d,p]=f?qv(r,a,h,t,n,o,i,s):[l,a.map((y,g)=>g===h?es(y,e,t,n,o,i,s):y)],m=K(r)==="Stack"?d:l;return Ao.cloneElement(r,{active:m},p)}function qv(r,e,t,n,o,i,s,l){let a=at(n);return a!=null&&a.width&&(a!=null&&a.height)?jv(r,e,t,n,o,s,l):Gf(r,e,t,n,o,(i==null?void 0:i.width)||(i==null?void 0:i.height),s)}var Kv=(r,e,{top:t,right:n,bottom:o,left:i},[s,l,a,c])=>{if(r==="column"&&e==="before")return l-t;if(r==="column")return o-c;if(r==="row"&&e==="before")return s-i;if(r==="row")return n-a};function jv(r,e,t,n,o,i,s){let{style:{flexDirection:l}}=_(r),[a,c,u]=Ef(l),{[c]:h,[a]:f}=at(n),d=q(e[t],"path"),p=Kv(l,o,i,s),[m,y]=h<i[c]?[Mo(n,u,d,i,s),f]:[n,void 0],g=p?Ft(d,p,{flexGrow:0,flexShrink:0}):void 0;return h>i[c]&&(e=e.map(v=>{if(q(v,"placeholder"))return v;{let{[c]:w}=at(v);return w&&w<h?Mo(v,u,q(v,"path")):v}})),Gf(r,e,t,m,o,y,i,g)}function Gf(r,e,t,n,o,i,s,l){let a=q(r,"path"),c=0,u=!e||e.length===0?[n]:e.reduce((h,f,d)=>{if(t===d){let[p,m]=Jv(r,f,n,s);o==="before"?l?h.push(l,m,p):h.push(m,p):l?h.push(p,m,l):h.push(p,m),c=h.indexOf(m)}else h.push(f);return h},[]).map((h,f)=>f<c?h:Ee(h,`${a}.${f}`));return[c,u]}function Jv(r,e,t,n){let o=$f(),{version:i=0}=_(t);if(i+=1,K(r)==="Flexbox"){let[s]=_f(r.props.style),l=6,a={[s]:(n[s]-l)/2},c=ba(e,s,a),u=ba(t,s,a);return[Ao.cloneElement(e,{style:c}),Ao.cloneElement(t,{id:o,version:i,style:u})]}else{let{style:{left:s,top:l,flex:a,...c}={left:void 0,top:void 0,flex:void 0}}=_(t);return[e,Ao.cloneElement(t,{id:o,version:i,style:c})]}}import{cloneElement as Xv}from"react";import ts from"react";function qf(r,{target:e,replacement:t}){return Ca(r,e,t)}function Ca(r,e,t){let n=q(e,"path"),o=q(e,"resizeable"),{style:i}=_(e),s=Lo(ts.cloneElement(t,{resizeable:o,style:{...i,...t.props.style}}),n);return $e(r,e,s)}function $e(r,e,t,n){if(r===e)return t;let{idx:o,finalStep:i}=Et(q(r,"path"),q(e,"path")),s=r.props.children.slice();return i?n?n===Wn.MINIMIZE?s[o]=Qv(r,s[o]):n===Wn.RESTORE&&(s[o]=Yv(s[o])):s[o]=t:s[o]=$e(s[o],e,t,n),ts.cloneElement(r,void 0,s)}function Qv(r,e){let{style:t}=_(r),{style:n}=_(e),{width:o,height:i,flexBasis:s,flexShrink:l,flexGrow:a,...c}=n,u={width:o,height:i,flexBasis:s,flexShrink:l,flexGrow:a},h={...c,flexBasis:0,flexGrow:0,flexShrink:0},f=t.flexDirection==="row"?"vertical":t.flexDirection==="column"?"horizontal":!1;return f?ts.cloneElement(e,{collapsed:f,restoreStyle:u,style:h}):e}function Yv(r){let{style:e,restoreStyle:t}=_(r),{flexBasis:n,flexShrink:o,flexGrow:i,...s}=e,l={...s,...t};return ts.cloneElement(r,{collapsed:!1,style:l,restoreStyle:void 0})}function Kf(r,{fromIndex:e,path:t,toIndex:n}){let o=Te(r,t,!0),{children:i}=_(o),s=Zv(i,e,n),l=Xv(o,void 0,s);return $e(r,o,l)}function Zv(r,e,t){let n=r.slice(),[o]=n.splice(e,1);return t===-1?n.concat(o):(n.splice(t,0,o),n)}var Re={ADD:"add",DRAG_START:"drag-start",DRAG_DROP:"drag-drop",LAYOUT_RESIZE:"layout-resize",MAXIMIZE:"maximize",MINIMIZE:"minimize",MOVE_CHILD:"move-child",REMOVE:"remove",REPLACE:"replace",RESTORE:"restore",SAVE:"save",SET_PROP:"set-prop",SET_PROPS:"set-props",SET_TITLE:"set-title",SPLITTER_RESIZE:"splitter-resize",SWITCH_TAB:"switch-tab",TEAROUT:"tearout"},VO=r=>["switch-active-layout","open-layout","close-layout","rename-layout"].includes(r),FO=r=>["switch-active-tab","edit-feature-title","save-feature-props","remove-component","resize-component","drag-drop-operation"].includes(r);import $n from"react";function Ta(r,{path:e}){let t=Te(r,e),n=Qt(r,e);if(n===null)return r;let{children:o}=_(n);if(o.length>1&&Jf(o,e)){let{style:{flexBasis:i,display:s,flexDirection:l,...a}}=_(n),c=q(n,"path"),u=$e(r,n,Ft(c,i,a));for(;(n=Qt(u,c))&&q(n,"path")!=="0";){let{children:h}=_(n);if(Jf(h)){c=q(n,"path");let{style:{flexBasis:f,display:d,flexDirection:p,...m}}=_(n);u=$e(r,n,Ft(c,f,m))}else if(rw(h))u=Xf(r,n);else break}return u}return Qf(r,t)}function Qf(r,e){let t=_(r),{children:n,path:o,preserve:i}=t,{active:s}=t,{idx:l,finalStep:a}=Et(o,q(e,"path")),c=K(r),u=n.slice();if(a){if(u.splice(l,1),s!==void 0&&s>=l&&(s=Math.max(0,s-1)),u.length===1&&!i&&o!=="0"&&c.match(/Flexbox|Stack/))return ew(r,u[0]);!u.some(tw)&&u.some(Yf)&&(u=nw(u))}else u[l]=Qf(u[l],e);return u=u.map((h,f)=>Ee(h,`${o}.${f}`)),$n.cloneElement(r,{active:s},u)}function ew(r,e){let t=K(r),{path:n,style:{flexBasis:o,flexGrow:i,flexShrink:s,width:l,height:a}}=_(r),c=Ee(e,n);if(n==="0")c=$n.cloneElement(c,{style:{...e.props.style,width:l,height:a}});else if(t==="Flexbox"){let u=r.props.style.flexDirection==="column"?"height":"width",{style:{[u]:h,...f}}=c.props;c=$n.cloneElement(c,{flexFill:void 0,style:{...f,flexGrow:i,flexShrink:s,flexBasis:o,width:l,height:a}})}return c}var tw=r=>r.props.style.flexGrow>0,Yf=r=>{let{width:e,height:t,flexGrow:n}=r.props.style;return n===0&&typeof e!="number"&&typeof t!="number"},nw=r=>r.map(e=>Yf(e)?$n.cloneElement(e,{style:{...e.props.style,flexGrow:1}}):e),rw=r=>{if(r&&r.length>0){let e=q(r[0],"placeholder"),t=!1;for(let n=1;n<r.length;n++){if(t=q(r[n],"placeholder"),e&&t)return!0;e=t}}},Xf=(r,e)=>{let{children:t,path:n}=_(r),{idx:o,finalStep:i}=Et(n,q(e,"path")),s=t.slice();return i?s[o]=ow(e):s[o]=Xf(s[o],e),s=s.map((l,a)=>Ee(l,`${n}.${a}`)),$n.cloneElement(r,void 0,s)},ow=r=>{let{children:e}=_(r),t=[],n=[];for(let i=0;i<e.length;i++)q(e[i],"placeholder")?n.push(e[i]):(n.length===1?t.push(n.pop()):n.length>0&&(t.push(jf(n)),n.length=0),t.push(e[i]));n.length===1?t.push(n.pop()):n.length>0&&t.push(jf(n));let o=q(r,"path");return $n.cloneElement(r,void 0,t.map((i,s)=>Ee(i,`${o}.${s}`)))},jf=([r,...e])=>{let t=q(r,"style"),{flexBasis:n,flexGrow:o,flexShrink:i}=t;for(let{props:{style:s}}of e)n+=s.flexBasis,o=Math.max(o,s.flexGrow),i=Math.max(i,s.flexShrink);return $n.cloneElement(r,{style:{...t,flexBasis:n,flexGrow:o,flexShrink:i}})},Jf=(r,e)=>r.every(t=>q(t,"placeholder")||e&&q(t,"path")===e);import ka from"react";function Zf(r,{path:e,size:t}){let n=Te(r,e,!0),{style:o}=_(n),i={...o,width:t},s=ka.cloneElement(n,{style:i});return $e(r,n,s)}function ed(r,{path:e,sizes:t}){let n=Te(r,e,!0),{children:o,style:i}=_(n),s=i.flexDirection==="column"?"height":"width",l=iw(o,t,s),a=ka.cloneElement(n,void 0,l);return $e(r,n,a)}function iw(r,e,t){return r.map((n,o)=>{let{style:{[t]:i,flexBasis:s}}=_(n),l=e[o],{currentSize:a,flexBasis:c}=l,h=a!==void 0?l.currentSize:c;return h===void 0||i===h||s===h?n:ka.cloneElement(n,{style:sw(n.props.style,t,h)})})}function sw(r,e,t){let n=typeof r[e]=="number",{flexShrink:o=1,flexGrow:i=1}=r;return{...r,[e]:n?t:"auto",flexBasis:n?"auto":t,flexShrink:o,flexGrow:i}}import{uuid as lw}from"@vuu-ui/vuu-utils";import ns from"react";var td=r=>{let[e]=K(r);return e===e.toLowerCase()};function Oo(r,e,t,n,o,i){let{children:s,path:l}=_(r),a=q(e,"path"),{idx:c,finalStep:u}=Et(l,a),h=u?aw(r,s,e,t,n,o,i):s.map((f,d)=>d===c?Oo(f,e,t,n,o,i):f);return ns.cloneElement(r,void 0,h)}function aw(r,e,t,n,o,i,s){let l=at(n);if(l!=null&&l.width&&(l!=null&&l.height)){if(i===void 0||s===void 0)throw Error("wrap-layout-element, updateChildren clientRect and dropRect must both be available");return uw(e,t,n,o,i,s)}return cw(r,e,t,n,o)}function cw(r,e,t,n,o){var b;let{version:i=0}=_(n),s=q(t,"path"),{type:l,flexDirection:a,showTabs:c}=rd(o),[u,h,f]=hw(l,t,n,a,o),d=nd(o),p=d?1:0,m={resizeable:!0,style:f,version:i+1},g={[td(t)?"data-resizeable":"resizeable"]:!0,style:h},v=l==="Stack"?{showTabs:c}:void 0,w=l==="Flexbox"?{splitterSize:(b=K(r)==="Flexbox"&&r.props.splitterSize)!=null?b:void 0}:void 0,x=lw(),S=ns.createElement(Fn[l],{active:p,id:x,key:x,path:q(t,"path"),flexFill:q(t,"flexFill"),...w,...v,style:u,resizeable:q(t,"resizeable")},d?[Ee(t,`${s}.0`,g),Lo(ns.cloneElement(n,m),`${s}.1`)]:[Lo(ns.cloneElement(n,m),`${s}.0`),Ee(t,`${s}.1`,g)]);return e.map(C=>C===t?S:C)}function uw(r,e,t,n,o,i){let{flexDirection:s}=rd(n),l=s==="column"?"row":"column",a=nd(n),[c,u,h,f]=i,[d,p]=s==="column"?[u-o.top,o.bottom-f]:[c-o.left,o.right-h],m=q(e,"path"),y=0,g=td(e)?"data-resizeable":"resizeable",v=[];d&&v.push(a?Ee(e,`${m}.${y++}`,{[g]:!0,style:{flexBasis:d,flexGrow:1,flexShrink:1}}):Ft(`${m}.${y++}`,d,{flexGrow:0,flexShrink:0})),v.push(Mo(t,l,`${m}.${y++}`,o,i)),p&&v.push(a?Ft(`${m}.${y++}`,0):Ee(e,`${m}.${y++}`,{[g]:!0,style:{flexBasis:0,flexGrow:1,flexShrink:1}}));let w=xa(s,e.props,v,m);return r.map(x=>x===e?w:x)}function hw(r,e,t,n,o){let i={...e.props.style,flexDirection:n},s=r==="Flexbox"&&n==="column"?"height":"width",l=ya(t,s,o),a=ya(e,s);return[i,a,l]}var nd=r=>{var e;return r.position.SouthOrEast?!0:((e=r==null?void 0:r.tab)==null?void 0:e.positionRelativeToTab)==="before"?!1:!!r.position.Header};function rd(r){return r.position.Header?{type:"Stack",flexDirection:"column",showTabs:!0}:{type:"Flexbox",flexDirection:r.position.EastOrWest?"row":"column"}}var ad=(r,e)=>{switch(e.type){case Re.ADD:return gw(r,e);case Re.DRAG_DROP:return mw(r,e);case Re.MAXIMIZE:return pw(r,e);case Re.REMOVE:return Ta(r,e);case Re.REPLACE:return qf(r,e);case Re.SET_PROP:return od(r,e);case Re.SET_PROPS:return dw(r,e);case Re.SET_TITLE:return od(r,{type:"set-prop",path:e.path,propName:"title",propValue:e.title});case Re.SPLITTER_RESIZE:return ed(r,e);case Re.LAYOUT_RESIZE:return Zf(r,e);case Re.SWITCH_TAB:return fw(r,e);case Re.MOVE_CHILD:return Kf(r,e);default:return r}},fw=(r,{path:e,nextIdx:t})=>{let n=Te(r,e,!0),o=Ma.cloneElement(n,{active:t});return $e(r,n,o)},od=(r,{path:e,propName:t,propValue:n})=>{let o=Te(r,e,!0),i=Ma.cloneElement(o,{[t]:n});return $e(r,o,i)},dw=(r,{path:e,props:t})=>{let n=Te(r,e,!0),o=Ma.cloneElement(n,t);return $e(r,n,o)},pw=(r,{path:e,type:t})=>{if(e){let n=Te(r,e,!0);return $e(r,n,n,t)}else return r},mw=(r,e)=>{var p,m;let{draggedReactElement:t,dragInstructions:n,dropTarget:o}=e,i=o.component,{pos:s}=o,l=((p=s==null?void 0:s.position)==null?void 0:p.Header)&&K(i)==="Stack",{id:a,version:c}=_(t),u=at(t),h;if(l){let[y,g]=Uf(i,s);y===void 0?h=Zi(r,i,t):h=es(r,y,t,g)}else!u&&((m=s==null?void 0:s.position)!=null&&m.Centre)?h=Ca(r,i,t):h=yw(r,o,t);if(n.DoNotRemove)return h;let f=Yt(h,y=>y.id===a&&y.version===c),d=q(f,"path");return Ta(h,{path:d,type:"remove"})},gw=(r,{path:e,component:t})=>Zi(r,Te(r,e),t),yw=(r,e,t)=>{let{component:n,pos:o,clientRect:i,dropRect:s}=e,l=q(n,"path");if(l==="0.0")return Oo(r,n,t,o);let a=Qt(r,l);if(id(o,a)){let c=o.position.SouthOrEast?"after":"before";return es(r,n,t,c,o,i,s)}if(!id(o,a))return Oo(r,n,t,o,i,s);if(ze(K(a)))return Oo(r,n,t,o);throw Error(`no support right now for position = ${o.position}`)},id=(r,e)=>r.position.Centre?ld(e)||sd(e):r.position.NorthOrSouth?sd(e):r.position.EastOrWest?ld(e):!1,sd=r=>K(r)==="Flexbox"&&r.props.style.flexDirection==="column",ld=r=>K(r)==="Flexbox"&&r.props.style.flexDirection!=="column";import{createContext as bw}from"react";var xw=r=>console.log(`dispatch ${r.type}, have you forgotten to provide a LayoutProvider ?`),No=bw({dispatchLayoutProvider:xw,version:-1});import{useCallback as rs,useRef as Ea}from"react";var vw={},cd=[0,0],ww=(r,e,t)=>{let n=document.createElement("div");n.className="vuuSimpleDraggableWrapper",n.classList.add("vuuSimpleDraggableWrapper","salt-theme","salt-density-medium"),n.dataset.dragging="true";let o=t!=null?t:document.createElement("div");o.id=e,n.appendChild(o),document.body.appendChild(n);let i=`top:${r.top}px;left:${r.left}px;width:${r.width}px;height:${r.height}px;`;return[n,i,r.left,r.top]},Sw=r=>{let{offsetParent:e}=r;if(e===null)return cd;{let{left:t,top:n}=e.getBoundingClientRect();return[t,n]}},ud=(r,e,t)=>{let n=Ea(),o=Ea(),i=Ea(),s=rs((u,h)=>{if(o.current&&i.current){let{dragOffsets:[f,d],targetPosition:p}=o.current,m=typeof u=="number"?u-f:p.left,y=typeof h=="number"?h-d:p.top;(m!==p.left||y!==p.top)&&(o.current.targetPosition.left=m,o.current.targetPosition.top=y,i.current.style.top=y+"px",i.current.style.left=m+"px")}},[]),l=rs(u=>{if(o.current){let{dragInstructions:h,payload:f,originalCSS:d}=o.current;u&&e({type:"drag-drop",draggedReactElement:f,dragInstructions:h,dropTarget:u}),i.current&&(!u&&h.DriftHomeIfNoDropTarget?(console.log("drift back to start"),document.body.removeChild(i.current)):h.RemoveDraggableOnDragEnd?document.body.removeChild(i.current):(i.current.style.cssText=d,delete i.current.dataset.dragging)),n.current=void 0,o.current=void 0,i.current=void 0}},[e]),a=rs(u=>{if(n.current){let{payload:h,dragContainerPath:f,dragElement:d,dragRect:p,instructions:m=vw,path:y}=n.current,{current:g}=r,v={x:u.clientX,y:u.clientY},w=h!=null?h:Te(g,y,!0),{id:x}=w.props,S=at(w),b="",C="",k="",E=-1,R=-1,M=cd,P=document.getElementById(x);if(P===null)[P,C,E,R]=ww(p,x,d);else{M=Sw(P);let[I,V]=M,{width:B,height:W,left:O,top:N}=P.getBoundingClientRect();E=O-I,R=N-V,C=`width:${B}px;height:${W}px;left:${E}px;top:${R}px;z-index: 100;background-color:#ccc;opacity: 0.6;`,P.dataset.dragging="true",b=P.style.cssText}k=ma.initDrag(r.current,f,p,v,{drag:s,drop:l},S),P.style.cssText=C+k,i.current=P,o.current={payload:w,originalCSS:b,dragRect:p,dragOffsets:M,dragInstructions:m,targetPosition:{left:E,top:R}}}},[s,l,r]);return rs(u=>{let{evt:h,...f}=u;n.current={...f,dragContainerPath:na(r.current,t)},ma.handleMousedown(h,a,f.instructions)},[a,t,r])};import{jsx as md}from"react/jsx-runtime";var fd=r=>r.dropTarget,kw=r=>["drag-drop","remove","set-title","splitter-resize","switch-tab"].includes(r.type),dd=r=>{switch(r.type){case"switch-tab":return r.id==="main-tabs"?"switch-active-layout":"switch-active-tab";case"save":return"save-feature-props";case"drag-drop":return"drag-drop-operation";case"remove":return"remove-component";case"splitter-resize":return"resize-component";case"set-title":return"edit-feature-title";default:throw Error("unknown layout action")}},l2=()=>{let r=Ew();return md("div",{children:`Context: ${r} `})},Mw=r=>{let{children:e,createNewChild:t,pathToDropTarget:n,layout:o,onLayoutChange:i}=r,s=hd(void 0),l=hd(e),[,a]=Tw(null),c=Ra((d,p)=>{if(i){let m=Yt(d,fd)||s.current,g=K(m)==="DraggableLayout"?_(m).children[0]:m,v=zf(g);i(v,p)}},[i]),u=Ra((d,p=!1)=>{let m=ad(s.current,d);m!==s.current&&(s.current=m,a({}),!p&&kw(d)&&c(m,dd(d)))},[a,c]),h=Ra(d=>{switch(d.type){case"drag-start":{f(d);break}case"save":{c(s.current,dd(d));break}default:{u(d);break}}},[u,c]),f=ud(s,h,n);return Cw(()=>{if(o){let d=Yt(s.current,fd);if(d){let p=$h(d),m=Mr(o,`${d.props.path}.0`),y=p?{type:Re.REPLACE,target:p,replacement:m}:{type:Re.ADD,path:d.props.path,component:m};u(y,!0)}else if(o.id===q(s.current,"id")){let p=Mr(o,"0"),m={type:Re.REPLACE,target:s.current,replacement:p};u(m,!0)}}},[u,o]),s.current===void 0?s.current=Sa(e):e!==l.current&&(s.current=Sa(e,s.current),l.current=e),md(No.Provider,{value:{createNewChild:t,dispatchLayoutProvider:h,version:0},children:s.current})},ut=()=>{let{dispatchLayoutProvider:r}=Ia(No);return r},pd=()=>{let{createNewChild:r}=Ia(No);return r},Ew=()=>{let{version:r}=Ia(No);return r};import{jsx as Iw}from"react/jsx-runtime";var gd=function(e){let{path:t}=e,n=ut(),o=Rw(i=>{n({type:Wn.SPLITTER_RESIZE,path:t,sizes:i})},[n,t]);return Iw(Po,{...e,onSplitterMoved:o})};gd.displayName="Flexbox";ge("Flexbox",gd,"container");import{useForkRef as Jw}from"@salt-ds/core";import Qw from"classnames";import{forwardRef as Yw,useMemo as Xw}from"react";import{useCallback as Sd,useEffect as Nw,useRef as La,useState as Vw}from"react";import{useCallback as Pw,useLayoutEffect as yd,useRef as Dw}from"react";var xd=["height","width"],S2=["height"],C2=["width"],Un=new WeakMap,vd=(r,e,t)=>{switch(t){case"height":return e.height;case"scrollHeight":return r.scrollHeight;case"scrollWidth":return r.scrollWidth;case"width":return e.width;default:return 0}},bd=new ResizeObserver(r=>{for(let e of r){let{target:t,contentRect:n}=e,o=Un.get(t);if(o){let{onResize:i,measurements:s}=o,l=!1;for(let[a,c]of Object.entries(s)){let u=vd(t,n,a);u!==c&&(l=!0,s[a]=u)}l&&i&&i(s)}}});function os(r,e,t,n=!1){let o=Dw(e),i=Pw(s=>{let l=s.getBoundingClientRect();return o.current.reduce((a,c)=>(a[c]=vd(s,l,c),a),{})},[]);yd(()=>{let s=r.current,l=!1;async function a(){Un.set(s,{measurements:{}}),l=!1;let{fonts:c}=document;if(c&&await c.ready,!l){let u=Un.get(s);if(u){let h=i(s);u.measurements=h,bd.observe(s),n&&t(h)}}}if(s){if(Un.has(s))throw Error("useResizeObserver attemping to observe same element twice");a()}return()=>{s&&Un.has(s)&&(bd.unobserve(s),Un.delete(s),l=!0)}},[r,i,n,t]),yd(()=>{let s=r.current,l=Un.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}function Lw(r,e){let t=document.body.querySelector(`.${r}`),n={get:function(o,i){let s=o.getPropertyValue(`--${r}-breakpoint-${i}`);return s?parseInt(s):void 0}};return t?new Proxy(getComputedStyle(t),n):e!=null?e:{}}var Aw=([,r],[,e])=>e-r,Da=r=>Object.entries(r).sort(Aw).map(([e,t],n,o)=>[e,t,n<o.length-1?o[n+1][1]:9999]),Pa=null,Ow=(r="salt")=>{let{xs:e,sm:t,md:n,lg:o,xl:i}=Lw(r);return Da({xs:e,sm:t,md:n,lg:o,xl:i})},wd=r=>(Pa===null&&(Pa=Ow(r)),Pa);var Fw=[],Cd=({breakPoints:r,smallerThan:e},t)=>{let[n,o]=Vw(e?!1:"lg"),i=La(document.body),s=La(r?Da(r):wd()),l=La("lg"),a=Sd(u=>{if(s.current){for(let[h,f]of s.current)if(u>=f)return h}},[s]),c=Sd(u=>{if(e){let h=s.current.find(([f])=>f===e);if(h){let[,,f]=h;return u<f}}else return a(u);return u},[e,a]);return os(t||i,s.current?["width"]:Fw,({width:u})=>{let h=c(u);h!==l.current&&(l.current=h,o(h))},!0),Nw(()=>{let u=t||i;if(u.current){let h=l.current;if(s.current){let{clientWidth:f}=u.current,d=c(f);l.current=d,d!==h&&o(d)}}},[o,c,t]),n};var Td="data-collapsible",Bw={[Td]:!0,"data-pad-start":!0,"data-pad-end":!0},Hw=r=>{var e;return(e=Bw[r])!=null?e:!1},_w=r=>r===Td,zw={dynamic:"dynamic",instant:"instant",true:"instant"},Ww=r=>{var e;return(e=zw[r])!=null?e:"none"},L2=r=>Object.keys(r).reduce((e,t)=>{let[n,o]=e;if(Hw(t)){let i=_w(t)?Ww(r[t]):r[t];n[t]=i,o[t]=void 0}return e},[{},{}]);import{getUniqueId as $w}from"@vuu-ui/vuu-utils";import{cloneElement as Uw,isValidElement as Gw,useCallback as qw,useMemo as kd,useRef as Aa}from"react";var Kw=["xs","sm","md","lg","xl"],jw=12,Md=({children:r,cols:e,style:t})=>{let n=Aa(null),o=Aa(null),i=Aa(),s=e!=null?e:jw,a=(t==null?void 0:t.flexDirection)==="column"?"height":"width",c=kd(()=>Array.isArray(r)?r:Gw(r)?[r]:[],[r]),u=qw((h,f)=>{let d=Ji(h,f,Kw),p=[],m=[];for(let y=0;y<h.length;y++){let g=h[y],{style:{flex:v,...w}}=g.props;p.push(Uw(g,{key:$w(),style:{...w,"--parent-col-count":s}})),m.push(d[y])}return[p,m]},[s]);return kd(()=>{let[h,f]=u(c,a);o.current=f,i.current=h},[u,c,a]),{cols:s,content:i.current,rootRef:n}};import{jsx as Zw}from"react/jsx-runtime";var is="hwFluidGrid",Oa=Yw(function(e,t){let{breakPoints:n,children:o,column:i,cols:s=12,className:l,flexFill:a,gap:c=3,fullPage:u,id:h,onSplitterMoved:f,resizeable:d,row:p,showGrid:m,spacing:y,splitterSize:g,style:v,...w}=e,x=Xw(()=>wr(o),[o]),{cols:S,content:b,rootRef:C}=Md({children:x,cols:s,style:v}),k=Cd({breakPoints:n},C),E=Qw(is,l,{[`${is}-column`]:i,[`${is}-row`]:p,[`${is}-show-grid`]:m,"flex-fill":a,"full-page":u}),R={...v,"--spacing":y,"--grid-col-count":S,"--grid-gap":c};return Zw("div",{...w,className:E,"data-breakpoint":k,"data-cols":S,"data-resizeable":d||void 0,id:h,ref:Jw(C,t),style:R,children:b})});Oa.displayName="FluidGrid";import{jsx as eS}from"react/jsx-runtime";var Ed=function(e){return eS(Oa,{...e})};Ed.displayName="FluidGrid";ge("FluidGrid",Ed,"container");import{EditableLabel as pS}from"@vuu-ui/vuu-ui-controls";import{Button as mS}from"@salt-ds/core";import{default as gS,default as yS}from"classnames";import{cloneElement as Bd,useRef as bS,useState as Hd}from"react";import{useCallback as Vo,useState as tS}from"react";var ss=(r,e,t,n)=>{var y;let{loadSessionState:o,purgeSessionState:i,purgeState:s,saveSessionState:l}=kr(),[a,c]=tS((y=o(r,"contributions"))!=null?y:[]),u=ut(),h=Vo((g,v)=>{let w=a.concat([{location:g,content:v}]);l(r,"contributions",w),c(w)},[a,r,l]),f=Vo(()=>{i(r,"contributions"),c([])},[r,i]),d=Vo(()=>{let g=o(r,"data-source");g&&g.unsubscribe(),i(r),s(r),u({type:"remove",path:t})},[u,r,o,i,s,t]),p=Vo(async(g,v,w)=>{var S;g.stopPropagation();let x=(S=e.current)==null?void 0:S.getBoundingClientRect();return new Promise((b,C)=>{u({type:"drag-start",evt:g,path:v===void 0?t:`${t}.${v}`,dragRect:x,preDragActivity:w,dropTargets:n,resolveDragStart:b,rejectDragStart:C})})},[e,u,t,n]);return[Vo(async(g,v)=>{var x;let{type:w}=g;switch(w){case"maximize":case"minimize":case"restore":return u({type:w,path:(x=g.path)!=null?x:t});case"remove":return d();case"mousedown":return p(v,g.index,g.preDragActivity);case"add-toolbar-contribution":return h(g.location,g.content);case"remove-toolbar-contribution":return f();default:return}},[u,t,d,p,h,f]),a]};import{useForkRef as iS,useIdMemo as sS}from"@salt-ds/core";import lS from"classnames";import Va,{forwardRef as aS,useCallback as cS,useMemo as uS,useRef as Nd,useState as hS}from"react";import{useCallback as Gn,useMemo as Rd}from"react";var Id=({id:r,rootRef:e,path:t,dropTargets:n,title:o})=>{let i=ut(),{loadState:s,loadSessionState:l,purgeState:a,saveState:c,saveSessionState:u}=kr(),[h,f]=ss(r,e,t,n),d=Rd(()=>{var b;return(b=s("view-title"))!=null?b:o},[s,o]),p=Gn(b=>{t&&i({type:"set-title",path:t,title:b})},[i,t]),m=Rd(()=>s(r),[r,s]),y=Gn(b=>s(r,b),[r,s]),g=Gn(b=>{a(r,b),i({type:"save"})},[r,i,a]),v=Gn((b,C)=>{c(r,C,b),i({type:"save"})},[r,i,c]),w=Gn(b=>l(r,b),[r,l]),x=Gn((b,C)=>u(r,C,b),[r,u]),S=Gn(({type:b,...C})=>{let{[b]:k}=C;v(k,b)},[v]);return{contributions:f,dispatchViewAction:h,load:y,loadSession:w,onConfigChange:S,onEditTitle:p,purge:g,restoredState:m,save:v,saveSession:x,title:d}};import{useCallback as Pd,useRef as Dd}from"react";var nS=[],Ld=({mainRef:r,resize:e="responsive",rootRef:t})=>{let n=e==="defer",o=Dd({}),i=Dd(),s=Pd(()=>{r.current&&(r.current.style.height=o.current.height+"px",r.current.style.width=o.current.width+"px"),i.current=void 0},[r]),l=Pd(({height:a,width:c})=>{o.current.height=a,o.current.width=c,i.current!==null&&clearTimeout(i.current),i.current=window.setTimeout(s,40)},[s]);os(t,n?xd:nS,l,n)};import rS,{useContext as Ad}from"react";var oS={dispatch:null},ls=rS.createContext(oS),Od=()=>{var e;let r=Ad(ls);return(e=r==null?void 0:r.dispatch)!=null?e:null},DV=()=>Ad(ls);import{jsx as Na,jsxs as dS}from"react/jsx-runtime";var Fo="vuuView",fS=(r,e)=>r&&e?{...r,...e}:r||e,Vd=aS(function(e,t){let{Header:n=Fd,children:o,className:i,collapsed:s,closeable:l,"data-path":a,"data-resizeable":c,dropTargets:u,expanded:h,flexFill:f,id:d,header:p,orientation:m="horizontal",path:y=a,resize:g="responsive",resizeable:v=c,tearOut:w,style:x={},title:S,...b}=e,C=sS(d),k=Nd(null),E=Nd(null),[R,M]=hS(),{contributions:P,dispatchViewAction:I,load:V,loadSession:B,onConfigChange:W,onEditTitle:O,purge:N,restoredState:F,save:G,saveSession:X,title:te}=Id({id:C,rootRef:k,path:y,dropTargets:u,title:S});Ld({mainRef:E,resize:g,rootRef:k});let _e=cS(Vt=>{M(Vt)},[]),de=()=>Va.isValidElement(o)&&(F||R)?Va.cloneElement(o,fS(F,R)):o,it=uS(()=>({dispatch:I,id:C,path:y,title:te,load:V,loadSession:B,onConfigChange:W,purge:N,save:G,saveSession:X,setComponentProps:_e}),[I,C,V,B,W,y,N,G,X,_e,te]),On=typeof p=="object"?p:{};return Na("div",{...b,className:lS(Fo,i,{[`${Fo}-collapsed`]:s,[`${Fo}-expanded`]:h,[`${Fo}-resize-defer`]:g==="defer"}),"data-resizeable":v,id:C,ref:iS(t,k),style:x,tabIndex:-1,children:dS(ls.Provider,{value:it,children:[p?Na(n,{...On,collapsed:s,contributions:P,expanded:h,closeable:l,onEditTitle:O,orientation:m,tearOut:w,title:te}):null,Na("div",{className:`${Fo}-main`,ref:E,children:de()})]})})});Vd.displayName="View";var qn=Va.memo(Vd);qn.displayName="View";ge("View",qn,"view");import{jsx as Bo}from"react/jsx-runtime";var Fa="vuuHeader",Fd=({className:r,contributions:e,collapsed:t,closeable:n,onEditTitle:o,orientation:i="horizontal",style:s,title:l="Untitled"})=>{let a=bS(null),[c,u]=Hd(l),[h,f]=Hd(!1),d=Od(),p=R=>d==null?void 0:d({type:"remove"},R),m=()=>{var R;(R=a.current)==null||R.focus()},y=R=>{R.stopPropagation()},v=gS(Fa,r,`${Fa}-${t||i}`),w=()=>{f(!0)},x=R=>{R.key==="Enter"&&f(!0)},S=(R="",M="",P=!0,I=!1)=>{var V;f(!1),I?u(R):M!==R&&(u(M),o==null||o(M)),P===!1&&((V=a.current)==null||V.focus())},b=R=>{d==null||d({type:"mousedown"},R)},C=[],k=[],E=[];return e==null||e.forEach((R,M)=>{switch(R.location){case"pre-title":C.push(Bd(R.content,{key:M}));break;default:k.push(Bd(R.content,{key:M}))}}),l&&C.push(Bo(pS,{className:`${Fa}-title`,editing:h,value:c,onChange:u,onMouseDownCapture:m,onEnterEditMode:w,onExitEditMode:S,onKeyDown:x,ref:a,tabIndex:0},"title")),n&&E.push(Bo(mS,{"data-icon":"close",onClick:p,onMouseDown:y,variant:"secondary"},"close")),k.length>0&&C.push(Bo("div",{className:"vuuTooltrayProxy","data-align":"end",children:k},"contributions")),E.length>0&&C.push(Bo("div",{className:"vuuTooltrayProxy","data-align":"end",children:E},"actions")),Bo("div",{className:yS("vuuToolbarProxy",v),style:s,onMouseDown:b,children:C})};var yF={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},Ho={type:"Stack",id:"main-tabs",props:{className:"vuuShell-mainTabs",TabstripProps:{allowAddTab:!0,allowCloseTab:!0,allowRenameTab:!0,animateSelectionThumb:!1,location:"main-tab",tabClassName:"MainTab"},preserve:!0,active:0},children:[{props:{id:"tab1",className:"vuuShell-Placeholder"},type:"Placeholder"}]};import{Prompt as Pz}from"@vuu-ui/vuu-popups";import{Button as Lz}from"@salt-ds/core";import Oz from"classnames";import{useRef as Bz}from"react";import{useCallback as CF,useRef as TF}from"react";import{PopupComponent as MF,Portal as EF}from"@vuu-ui/vuu-popups";import{List as IF,ListItem as PF}from"@vuu-ui/vuu-ui-controls";import{Fragment as NF,jsx as AF,jsxs as OF}from"react/jsx-runtime";import{itemToString as xS}from"@vuu-ui/vuu-utils";import{ComboBox as vS}from"@vuu-ui/vuu-ui-controls";import _d from"classnames";import{forwardRef as wS,useCallback as as,useMemo as SS,useRef as CS,useState as TS}from"react";import{jsx as Wd}from"react/jsx-runtime";var zd="vuuExpandoCombobox",kS={},_o=wS(function({className:e,InputProps:t=kS,ListProps:n,onInputChange:o,onSelectionChange:i,selectionStrategy:s,style:l,value:a="",...c},u){let[h,f]=TS(a),{itemToString:d=xS}=c,p=CS(a),m=as(b=>{let[C,...k]=b;return k.length?`${d(C)} + ${k.length}`:d(C)},[d]),y=as(b=>{let{value:C}=b.target;console.log(`onInputChange ${C}`),f(C),o==null||o(b)},[o]),g=as(b=>{console.log(`handleSetSelectedText ${b}`),f(b)},[]),[v,w]=SS(()=>{let{inputProps:b,...C}=t;return[{...C,className:`${zd}-Input`,endAdornment:null,inputProps:{...b,autoComplete:"off",onInput:y}},{...n,className:_d("vuuMenuList",n==null?void 0:n.className),"data-mode":"light",displayedItemCount:10,itemHeight:22,maxWidth:300,minWidth:100,width:"auto"}]},[t,y,n]),x=as((b,C)=>{Array.isArray(C)?i==null||i(null,C):C&&(f(d(C)),i==null||i(null,C))},[d,i]),S={minWidth:102};return Wd("div",{className:_d(zd,e),"data-text":h,ref:u,style:l,children:Wd(vS,{...c,PopupProps:S,defaultValue:p.current,fullWidth:!0,ListProps:w,InputProps:v,itemsToString:m,onSelectionChange:x,onSetSelectedText:g,selectionStrategy:s})})});import D_ from"classnames";import{useCallback as O_}from"react";import{forwardRef as MS,useState as ES,useCallback as $d}from"react";import{ExpandoInput as RS}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as Ba}from"@vuu-ui/vuu-utils";import{jsx as PS}from"react/jsx-runtime";var IS=MS(function({InputProps:e,className:t,column:n,onInputComplete:o,value:i},s){let[l,a]=ES(Ba(i)?i.toString():""),c=$d(h=>{let{value:f}=h.target,d=parseFloat(f);Ba(d)&&console.log("its valid"),a(f)},[]),u=$d(h=>{if(h.key==="Enter"){let{value:f}=h.target,d=parseFloat(f);Ba(d)&&o(d)}},[o]);return PS(RS,{...e,className:t,value:l,ref:s,onChange:c,onKeyDown:u})});import{isNumericColumn as fB,isTextColumn as dB}from"@vuu-ui/vuu-utils";import{forwardRef as aT,useCallback as Ms,useEffect as Fp,useMemo as cT,useState as Bp}from"react";import{getFullRange as gB,metadataKeys as DS,WindowRange as yB}from"@vuu-ui/vuu-utils";import{useCallback as xB,useEffect as vB,useMemo as wB,useRef as SB,useState as CB}from"react";var{SELECTED:TB}=DS;import{useCallback as u4,useEffect as h4,useState as f4}from"react";import{EventEmitter as qS,getLoggingConfigForWorker as KS,uuid as jS}from"@vuu-ui/vuu-utils";var zo=(r,e)=>r===e?!0:r===void 0&&e===void 0,LS=({filter:r},{filter:e})=>r===void 0&&(e==null?void 0:e.filter)===""||e===void 0&&(r==null?void 0:r.filter)==="",AS=(r,e)=>{var t,n;return LS(r,e)?!1:((t=r.filter)==null?void 0:t.filter)!==((n=e.filter)==null?void 0:n.filter)},OS=({sort:r},{sort:e})=>r===void 0&&(e==null?void 0:e.sortDefs.length)===0||e===void 0&&(r==null?void 0:r.sortDefs.length)===0,NS=(r,e)=>{let{sort:t}=r,{sort:n}=e;return zo(t,n)||OS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.sortDefs.length)!==(n==null?void 0:n.sortDefs.length)?!0:t.sortDefs.some(({column:o,sortType:i},s)=>o!==n.sortDefs[s].column||i!==n.sortDefs[s].sortType)},Ud=r=>r!==void 0&&r.groupBy!==void 0&&r.groupBy.length>0,Gd=r=>(r==null?void 0:r.filter)!==void 0&&r.filter.filter.length>0,qd=r=>{var e;return(r==null?void 0:r.sort)!==void 0&&Array.isArray((e=r.sort)==null?void 0:e.sortDefs)&&r.sort.sortDefs.length>0},VS=({groupBy:r},{groupBy:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,Ha=(r,e)=>{let{groupBy:t}=r,{groupBy:n}=e;return zo(t,n)||VS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.length)!==(n==null?void 0:n.length)?!0:t.some((o,i)=>o!==(n==null?void 0:n[i]))},FS=({columns:r},{columns:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,BS=(r,e)=>{let{columns:t}=r,{columns:n}=e;return zo(t,n)||FS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.length)!==(n==null?void 0:n.length)?!0:t.some((o,i)=>o!==(n==null?void 0:n[i]))},HS=({aggregations:r},{aggregations:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,_S=(r,e)=>{let{aggregations:t}=r,{aggregations:n}=e;return zo(t,n)||HS(r,e)?!1:t===void 0||n===void 0||t.length!==n.length?!0:t.some(({column:o,aggType:i},s)=>o!==n[s].column||i!==n[s].aggType)},zS=()=>!1,cs=(r,e)=>zo(r,e)?!1:r===void 0||e===void 0?!0:BS(r,e)||AS(r,e)||NS(r,e)||Ha(r,e)||_S(r,e)||zS(r,e),WS=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],Kd=r=>{let e=r.type;return WS.includes(e)},jd=r=>["config","aggregate","columns","filter","groupBy","sort"].includes(r.type),$S={filter:""},US={sortDefs:[]},Er={aggregations:[],columns:[],filter:$S,groupBy:[],sort:US},us=r=>{if(r.aggregations&&r.columns&&r.filter&&r.groupBy&&r.sort)return r;{let{aggregations:e=[],columns:t=[],filter:n={filter:""},groupBy:o=[],sort:i={sortDefs:[]},visualLink:s}=r;return{aggregations:e,columns:t,filter:n,groupBy:o,sort:i,visualLink:s}}};var Jd="GET_TABLE_LIST",Qd="GET_TABLE_META";var _a=r=>r.type==="connection-status",Yd=r=>r.type==="connection-metrics",Xd=r=>typeof r.result<"u",Zd=r=>r.type==="TABLE_META_RESP";var ep='\nvar fe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var p=(s,e,t)=>(fe(s,e,"read from private field"),t?t.call(s):e.get(s)),U=(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)},me=(s,e,t,n)=>(fe(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);function he(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 x={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:nn,IS_LEAF:rn}=x;var be=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 Y({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),a=s-o<0,u=n-(e+o)<0;return a&&u?{from:0,to:n}:a?{from:0,to:r+t}:u?{from:Math.max(0,n-(r+t)),to:n}:{from:s-o,to:e+o}}}var lt=(s,{from:e,to:t})=>s>=e&&s<t;var v=class{constructor(e,t){this.from=e,this.to=t}isWithin(e){return lt(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:pn}=x;var ct=["error","warn","info","debug"],pt=s=>typeof s=="string"&&ct.includes(s),dt="error",F=()=>{},gt="error",{loggingLevel:N=gt}=ft(),w=s=>{let e=N==="debug",t=e||N==="info",n=t||N==="warn",r=n||N==="error",o=t?g=>console.info(`[${s}] ${g}`):F,a=n?g=>console.warn(`[${s}] ${g}`):F,u=e?g=>console.debug(`[${s}] ${g}`):F;return{errorEnabled:r,error:r?g=>console.error(`[${s}] ${g}`):F}};function ft(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:mt()}}function mt(){let s=be("vuu-logging-level");return pt(s)?s:dt}var{debug:ht,debugEnabled:bt}=w("range-monitor"),W=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)bt&&ht(`<${this.source}> [${e}-${t}], ${(this.timestamp-n).toFixed(0)} ms elapsed`);else return 0}};function Ce(s){return Array.isArray(s)}function Ct(s){return!Array.isArray(s)}var y,ye=class{constructor(){U(this,y,new Map)}addListener(e,t){let n=p(this,y).get(e);n?Ce(n)?n.push(t):Ct(n)&&p(this,y).set(e,[n,t]):p(this,y).set(e,t)}removeListener(e,t){if(!p(this,y).has(e))return;let n=p(this,y).get(e),r=-1;if(n===t)p(this,y).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,p(this,y).delete(e)):n.splice(r,1)}}removeAllListeners(e){e&&p(this,y).has(e)?p(this,y).delete(e):e===void 0&&p(this,y).clear()}emit(e,...t){if(p(this,y)){let n=p(this,y).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=p(this,y).get(e);return Array.isArray(n)?n.includes(t):n===t}invokeHandler(e,t){if(Ce(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)}}};y=new WeakMap;var $=String.fromCharCode(8200),m=String.fromCharCode(8199);var wn={DIGIT:m,TWO_DIGITS:m+m,THREE_DIGITS:m+m+m,FULL_PADDING:[null,$+m,$+m+m,$+m+m+m,$+m+m+m+m]};var En=m+m+m+m+m+m+m+m+m;var{COUNT:Bn}=x;var q=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:Zn}=x;var{SELECTED:er}=x,I={False:0,True:1,First:2,Last:4};var yt=(s,e)=>e>=s[0]&&e<=s[1],St=I.True+I.First+I.Last,Tt=I.True+I.First,Rt=I.True+I.Last,Z=(s,e)=>{for(let t of s)if(typeof t=="number"){if(t===e)return St}else if(yt(t,e))return e===t[0]?Tt:e===t[1]?Rt:I.True;return I.False};var Se=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:As,error:we,info:V,infoEnabled:It,warn:_}=w("websocket-connection"),Ee="ws",vt=s=>s.startsWith(Ee+"://")||s.startsWith(Ee+"s://"),xe={},ee=Symbol("setWebsocket"),B=Symbol("connectionCallback");async function Ie(s,e,t,n=10,r=5){return xe[s]={status:"connecting",connect:{allowed:r,remaining:r},reconnect:{allowed:n,remaining:n}},ve(s,e,t)}async function Q(s){throw Error("connection broken")}async function ve(s,e,t,n){let{status:r,connect:o,reconnect:a}=xe[s],u=r==="connecting"?o:a;try{t({type:"connection-status",status:"connecting"});let c=typeof n<"u",g=await _t(s,e);console.info("%c\u26A1 %cconnected","font-size: 24px;color: green;font-weight: bold;","color:green; font-size: 14px;"),n!==void 0&&n[ee](g);let i=n!=null?n:new te(g,s,e,t),l=c?"reconnected":"connection-open-awaiting-session";return t({type:"connection-status",status:l}),i.status=l,u.remaining=u.allowed,i}catch{let g=--u.remaining>0;if(t({type:"connection-status",status:"disconnected",reason:"failed to connect",retry:g}),g)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(ve(s,e,t,n))},r)}),_t=(s,e)=>new Promise((t,n)=>{let r=vt(s)?s:`wss://${s}`;It&&e!==void 0&&V(`WebSocket Protocol ${e==null?void 0:e.toString()}`);let o=new WebSocket(r,e);o.onopen=()=>t(o),o.onerror=a=>n(a)}),Ve=()=>{_==null||_("Connection cannot be closed, socket not yet opened")},Me=s=>{_==null||_(`Message cannot be sent, socket closed ${s.body.type}`)},Pt=s=>{try{return JSON.parse(s)}catch{throw Error(`Error parsing JSON response from server ${s}`)}},te=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=Pt(e.data);this.messagesCount+=1,this[B](t)};this.url=t,this.protocol=n,this[B]=r,this[ee](e)}reconnect(){Q(this)}[(B,ee)](e){let t=this[B];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"&&(Q(this),this.send=r)},e.onclose=()=>{V==null||V("\u26A1 connection close"),t({type:"connection-status",status:"disconnected",reason:"close"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status!=="closed"&&(Q(this),this.send=r)};let n=o=>{e.send(JSON.stringify(o))},r=o=>{V==null||V(`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,V==null||V("close websocket")}}};var Lt=["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=>Lt.includes(s.type),ne=({requestId:s,...e})=>[s,e],_e=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]},Pe=s=>{let e={};for(let t of s)(e[t.viewPortId]||(e[t.viewPortId]=[])).push(t);return e};var re=({columns:s,dataTypes:e,key:t,table:n})=>({table:n,columns:s.map((r,o)=>({name:r,serverDataType:e[o]})),key:t});var Le=s=>s.type==="connection-status",Oe=s=>s.type==="connection-metrics";var ke=s=>"viewport"in s,Ae=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 Ue="CHANGE_VP_SUCCESS",Fe="CHANGE_VP_RANGE_SUCCESS",Ne="CLOSE_TREE_NODE",We="CLOSE_TREE_SUCCESS";var $e="CREATE_VP",qe="CREATE_VP_SUCCESS",Be="DISABLE_VP",Ge="DISABLE_VP_SUCCESS";var Ke="ENABLE_VP",He="ENABLE_VP_SUCCESS";var se="GET_VP_VISUAL_LINKS",je="GET_VIEW_PORT_MENUS";var ze="HB",Je="HB_RESP",Ye="LOGIN",Ze="LOGIN_SUCCESS",Xe="OPEN_TREE_NODE",Qe="OPEN_TREE_SUCCESS";var et="REMOVE_VP";var oe="RPC_RESP";var tt="SET_SELECTION_SUCCESS",ie="TABLE_META_RESP",ae="TABLE_LIST_RESP",nt="TABLE_ROW";var st=s=>{switch(s){case"TypeAheadRpcHandler":return"TYPEAHEAD";default:return"SIMUL"}};var ot=[],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,K=class{constructor({from:e,to:t},{from:n,to:r},o){U(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-p(this,h).from;this.internalData[o]!==void 0&&(this.rowsWithinRange+=1)}}this.rowCount=e};this.bufferBreakout=(e,t)=>{let n=this.bufferSize*.25;return p(this,h).to-t<n?!0:p(this,h).from>0&&e-p(this,h).from<n};this.bufferSize=o,this.clientRange=new v(e,t),me(this,h,new v(n,r)),this.internalData=new Array(o),this.rowsWithinRange=0,this.rowCount=0}get range(){return p(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-p(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 p(this,h).isWithin(e)&&this.internalData[e-p(this,h).from]!=null?this.internalData[e-p(this,h).from]:void 0}isWithinRange(e){return p(this,h).isWithin(e)}isWithinClientRange(e){return this.clientRange.isWithin(e)}setClientRange(e,t){var g;(g=T.debug)==null||g.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,ot];let o=this.clientRange.copy();this.clientRange.from=e,this.clientRange.to=t,this.rowsWithinRange=0;for(let i=e;i<t;i++){let l=i-p(this,h).from;this.internalData[l]&&(this.rowsWithinRange+=1)}let a=ot,u=p(this,h).from;if(this.hasAllRowsWithinRange)if(t>o.to){let i=Math.max(e,o.to);a=this.internalData.slice(i-u,t-u)}else{let i=Math.min(o.from,t);a=this.internalData.slice(e-u,i-u)}return[this.bufferBreakout(e,t),a]}setRange(e,t){var n,r;if(e!==p(this,h).from||t!==p(this,h).to){(n=T.debug)==null||n.call(T,`setRange ${e} - ${t}`);let[o,a]=p(this,h).overlap(e,t),u=new Array(t-e);this.rowsWithinRange=0;for(let c=o;c<a;c++){let g=this.getAtIndex(c);if(g){let i=c-e;u[i]=g,this.isWithinClientRange(c)&&(this.rowsWithinRange+=1)}}this.internalData=u,p(this,h).from=e,p(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}=p(this,h),{from:n,to:r}=this.clientRange,o=Math.max(0,n-e),a=Math.min(t-e,t,r-e,(u=this.rowCount)!=null?u:t);return this.internalData.slice(o,a)}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:b,debugEnabled:H,error:At,info:d,infoEnabled:Ut,warn:P}=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:a,range:u,sort:c,title:g,viewport:i,visualLink:l},f){this.batchMode=!0;this.hasUpdates=!1;this.pendingUpdates=[];this.pendingOperations=new Map;this.pendingRangeRequests=[];this.rowCountChanged=!1;this.selectedRows=[];this.tableSchema=null;this.useBatchMode=!0;this.lastUpdateStatus=Nt;this.updateThrottleTimer=void 0;this.rangeMonitor=new W("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:a}of this.pendingRangeRequests)if(r>=o&&r<a){if(e.to+n<=a)return!0;r=a}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)?(d==null||d("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=i,this.columns=n,this.filter=r,this.groupBy=o,this.keys=new q(u),this.pendingLinkedParent=l,this.table=a,this.sort=c,this.title=g,Ut&&(d==null||d(`constructor #${i} ${a.table} bufferSize=${t}`)),this.dataWindow=new K(this.clientRange,u,this.bufferSize),this.postMessageToClient=f}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:$e,table:this.table,range:Y(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:a,groupBy:u}){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:a,tableSchema:this.tableSchema}}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");return}let{type:a}=o;if(d==null||d(`completeOperation ${a}`),r.delete(e),a==="CHANGE_VP_RANGE"){let[c,g]=t;(u=this.dataWindow)==null||u.setRange(c,g);for(let i=this.pendingRangeRequests.length-1;i>=0;i--){let l=this.pendingRangeRequests[i];if(l.requestId===e){l.acked=!0;break}else P==null||P("range requests sent faster than they are being ACKed")}}else if(a==="config"){let{aggregations:c,columns:g,filter:i,groupBy:l,sort:f}=o.data;return this.aggregations=c,this.columns=g,this.filter=i,this.groupBy=l,this.sort=f,l.length>0?this.isTree=!0:this.isTree&&(this.isTree=!1),b==null||b(`config change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:a,config:o.data}}else{if(a==="groupBy")return this.isTree=o.data.length>0,this.groupBy=o.data,b==null||b(`groupBy change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:a,groupBy:o.data};if(a==="columns")return this.columns=o.data,{clientViewportId:n,type:a,columns:o.data};if(a==="filter")return this.filter=o.data,{clientViewportId:n,type:a,filter:o.data};if(a==="aggregate")return this.aggregations=o.data,{clientViewportId:n,type:"aggregate",aggregations:this.aggregations};if(a==="sort")return this.sort=o.data,{clientViewportId:n,type:a,sort:this.sort};if(a!=="selection"){if(a==="disable")return this.disabled=!0,{type:"disabled",clientViewportId:n};if(a==="enable")return this.disabled=!1,{type:"enabled",clientViewportId:n};if(a==="CREATE_VISUAL_LINK"){let[c,g,i]=t;return this.linkedParent={colName:c,parentViewportId:g,parentColName:i},this.pendingLinkedParent=void 0,{type:"vuu-link-created",clientViewportId:n,colName:c,parentViewportId:g,parentColName:i}}else if(a==="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),a,u=this.dataWindow.rowCount||void 0,c=r&&!this.rangeRequestAlreadyPending(t)?{type:n,viewPortId:this.serverViewportId,...Y(t,this.bufferSize,u)}:null;if(c){H&&(b==null||b(`create CHANGE_VP_RANGE: [${c.from} - ${c.to}]`)),this.awaitOperation(e,{type:n});let i=this.pendingRangeRequests.at(-1);if(i)if(i.acked)console.warn("Range Request before previous request is filled");else{let{from:l,to:f}=i;this.dataWindow.outOfRange(l,f)?a={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 g=this.isTree?le:ue;return o.length?[c,o.map(i=>g(i,this.keys,this.selectedRows))]:a?[c,void 0,a]:[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}}setTableSchema(e){this.tableSchema=e}openTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Xe,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,d==null||d("suspend")}resume(){return this.suspended=!1,H&&(b==null||b(`resume: ${this.currentData()}`)),this.currentData()}currentData(){let e=[];if(this.dataWindow){let t=this.dataWindow.getData(),{keys:n}=this,r=this.isTree?le:ue;for(let o of t)o&&e.push(r(o,n,this.selectedRows))}return e}enable(e){return this.awaitOperation(e,{type:"enable"}),d==null||d(`enable: ${this.serverViewportId}`),{type:Ke,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:"disable"}),d==null||d(`disable: ${this.serverViewportId}`),this.suspended=!1,{type:Be,viewPortId:this.serverViewportId}}columnRequest(e,t){return this.awaitOperation(e,{type:"columns",data:t}),b==null||b(`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 d==null||d(`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?b==null||b(`setConfig ${JSON.stringify(t)}`):d==null||d("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}),d==null||d(`aggregateRequest: ${t}`),this.createRequest({aggregations:t})}sortRequest(e,t){return this.awaitOperation(e,{type:"sort",data:t}),d==null||d(`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}),d==null||d(`selectRequest: ${t}`),{type:"SET_SELECTION",vpId:this.serverViewportId,selection:Se(t)}}removePendingRangeRequest(e,t){for(let n=this.pendingRangeRequests.length-1;n>=0;n--){let{from:r,to:o}=this.pendingRangeRequests[n],a=!0;if(e>=r&&e<o||t>r&&t<o){a||console.warn("removePendingRangeRequest TABLE_ROWS are not for latest request"),this.pendingRangeRequests.splice(n,1);break}else a=!1}}updateRows(e){var r,o,a;let[t,n]=_e(e);if(t&&n&&this.removePendingRangeRequest(t.rowIndex,n.rowIndex),e.length===1)if(t.vpSize===0&&this.disabled){b==null||b(`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"&&(a=this.dataWindow)!=null&&a.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?le:ue;if(this.updateThrottleTimer&&(self.clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),this.pendingUpdates.length>0){e=[],t="update";for(let a of this.pendingUpdates)e.push(o(a,n,r));this.pendingUpdates.length=0}else{let a=this.dataWindow.getData();if(this.dataWindow.hasAllRowsWithinRange){e=[],t="batch";for(let u of a)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}}},ue=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>[s,r.keyFor(s),!0,!1,0,0,e,t?Z(o,s):0].concat(n),le=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>{let[a,u,,c,,g,...i]=n;return[s,r.keyFor(s),c,u,a,g,e,t?Z(o,s):0].concat(i)};var it=1;var{debug:E,debugEnabled:L,error:O,info:S,infoEnabled:Wt,warn:k}=w("server-proxy"),C=()=>`${it++}`,$t={},qt=s=>s.disabled!==!0&&s.suspended!==!0,Bt={type:"NO_ACTION"},Gt=(s,e,t)=>s.map(n=>n.parentVpId===e?{...n,label:t}:n);function Kt(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.pendingTableMetaRequests=new Map;this.pendingRequests=new Map;this.queuedRequests=[];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]=he(Array.from(this.viewports.values()),qt);this.viewports.clear(),this.mapClientToServerViewport.clear();let n=r=>{r.forEach(o=>{let{clientViewportId:a}=o;this.viewports.set(a,o),this.sendMessageToServer(o.subscribe(),a)})};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:Ye,token:this.authToken,user:t},""),this.pendingLogin={resolve:n,reject:r}});this.authToken===""&&O("login, cannot login until auth token has been obtained")}subscribe(e){if(this.mapClientToServerViewport.has(e.viewport))O(`spurious subscribe call ${e.viewport}`);else{if(!this.hasSchemaForTable(e.table)&&!G(e.table)){S==null||S(`subscribe to ${e.table.table}, no metadata yet, request metadata`);let n=C();this.sendMessageToServer({type:"GET_TABLE_META",table:e.table},n),this.pendingTableMetaRequests.set(n,e.viewport)}let t=new z(e,this.postMessageToClient);this.viewports.set(e.viewport,t),this.sendIfReady(t.subscribe(),e.viewport,this.sessionId!=="")}}unsubscribe(e){let t=this.mapClientToServerViewport.get(e);t?(S==null||S(`Unsubscribe Message (Client to Server):\n ${t}`),this.sendMessageToServer({type:et,viewPortId:t})):O(`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=C(),[r,o,a]=e.rangeRequest(n,t.range);S==null||S(`setViewRange ${t.range.from} - ${t.range.to}`),r&&this.sendIfReady(r,n,e.status==="subscribed"),o?(S==null||S(`setViewRange ${o.length} rows returned from cache`),this.postMessageToClient({mode:"batch",type:"viewport-update",clientViewportId:e.clientViewportId,rows:o})):a&&this.postMessageToClient(a)}setConfig(e,t){let n=C(),r=e.setConfig(n,t.config);this.sendIfReady(r,n,e.status==="subscribed")}aggregate(e,t){let n=C(),r=e.aggregateRequest(n,t.aggregations);this.sendIfReady(r,n,e.status==="subscribed")}sort(e,t){let n=C(),r=e.sortRequest(n,t.sort);this.sendIfReady(r,n,e.status==="subscribed")}groupBy(e,t){let n=C(),r=e.groupByRequest(n,t.groupBy);this.sendIfReady(r,n,e.status==="subscribed")}filter(e,t){let n=C(),{filter:r}=t,o=e.filterRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}setColumns(e,t){let n=C(),{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=C(),{selected:r}=t,o=e.selectRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}disableViewport(e){let t=C(),n=e.disable(t);this.sendIfReady(n,t,e.status==="subscribed")}enableViewport(e){if(e.disabled){let t=C(),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&&(E==null||E("clear suspend timer"),clearTimeout(e.suspendTimer),e.suspendTimer=null);let t=e.resume();this.postMessageToClient({clientViewportId:e.clientViewportId,mode:"batch",rows:t,type:"viewport-update"})}openTreeNode(e,t){if(e.serverViewportId){let n=C();this.sendIfReady(e.openTreeNode(n,t),n,e.status==="subscribed")}}closeTreeNode(e,t){if(e.serverViewportId){let n=C();this.sendIfReady(e.closeTreeNode(n,t),n,e.status==="subscribed")}}createLink(e,t){let{parentClientVpId:n,parentColumnName:r,childColumnName:o}=t,a=C(),u=this.mapClientToServerViewport.get(n);if(u){let c=e.createLink(a,o,u,r);this.sendMessageToServer(c,a)}else O("ServerProxy unable to create link, viewport not found")}removeLink(e){let t=C(),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(a=>a.parentVpId===t)){let[a]=o.setLinks(Gt(o.links,t,n));this.postMessageToClient(a)}}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]=ne(e);this.sendMessageToServer({...r,vpId:t.serverViewportId},n)}}rpcCall(e){let[t,n]=ne(e),r=st(n.service);this.sendMessageToServer(n,t,{module:r})}handleMessageFromClient(e){if(E==null||E(`handleMessageFromClient: ${e.type}`),ke(e))if(e.type==="disable"){let t=this.getViewportForClient(e.viewport,!1);return t!==null?this.disableViewport(t):void 0}else{let t=this.getViewportForClient(e.viewport);switch(e.type){case"setViewRange":return this.setViewRange(t,e);case"config":return this.setConfig(t,e);case"aggregate":return this.aggregate(t,e);case"sort":return this.sort(t,e);case"groupBy":return this.groupBy(t,e);case"filter":return this.filter(t,e);case"select":return this.select(t,e);case"suspend":return this.suspendViewport(t);case"resume":return this.resumeViewport(t);case"enable":return this.enableViewport(t);case"openTreeNode":return this.openTreeNode(t,e);case"closeTreeNode":return this.closeTreeNode(t,e);case"createLink":return this.createLink(t,e);case"removeLink":return this.removeLink(t);case"setColumns":return this.setColumns(t,e);case"setTitle":return this.setTitle(t,e);default:}}else{if(De(e))return this.menuRpcCall(e);{let{type:t,requestId:n}=e;switch(t){case"GET_TABLE_LIST":return this.sendMessageToServer({type:t},n);case"GET_TABLE_META":return this.sendMessageToServer({type:t,table:e.table},n);case"RPC_CALL":return this.rpcCall(e);default:}}}O(`Vuu ServerProxy Unexpected message from client ${JSON.stringify(e)}`)}awaitResponseToMessage(e){return new Promise((t,n)=>{let r=C();this.sendMessageToServer(e,r),this.pendingRequests.set(r,{reject:n,resolve:t})})}sendIfReady(e,t,n=!0){return n?this.sendMessageToServer(e,t):this.queuedRequests.push(e),n}sendMessageToServer(e,t=`${it++}`,n=$t){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:i}=o;this.pendingRequests.delete(n),i(t);return}let{viewports:a}=this;switch(t.type){case ze:this.sendMessageToServer({type:Je,ts:+new Date},"NA");break;case Ze: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 qe:{let i=a.get(n);if(i){let{status:l}=i,{viewPortId:f}=t;n!==f&&(a.delete(n),a.set(f,i)),this.mapClientToServerViewport.set(n,f);let R=i.handleSubscribed(t);R&&(this.postMessageToClient(R),L&&E(`post DataSourceSubscribedMessage to client: ${JSON.stringify(R)}`)),i.disabled&&this.disableViewport(i),l==="subscribing"&&!G(i.table)&&(this.sendMessageToServer({type:se,vpId:f}),this.sendMessageToServer({type:je,vpId:f}),Array.from(a.entries()).filter(([M,{disabled:A}])=>M!==f&&!A).forEach(([M])=>{this.sendMessageToServer({type:se,vpId:M})}))}}break;case"REMOVE_VP_SUCCESS":{let i=a.get(t.viewPortId);i&&(this.mapClientToServerViewport.delete(i.clientViewportId),a.delete(t.viewPortId),this.removeViewportFromVisualLinks(t.viewPortId))}break;case tt:{let i=this.viewports.get(t.vpId);i&&i.completeOperation(n)}break;case Ue:case Ge:if(a.has(t.viewPortId)){let i=this.viewports.get(t.viewPortId);if(i){let l=i.completeOperation(n);l!==void 0&&(this.postMessageToClient(l),L&&E(`postMessageToClient ${JSON.stringify(l)}`))}}break;case He:{let i=this.viewports.get(t.viewPortId);if(i){let l=i.completeOperation(n);if(l){this.postMessageToClient(l);let f=i.currentData();L&&E(`Enable Response (ServerProxy to Client): ${JSON.stringify(l)}`),i.size===0?L&&E("Viewport Enabled but size 0, resend to server"):(this.postMessageToClient({clientViewportId:i.clientViewportId,mode:"batch",rows:f,size:i.size,type:"viewport-update"}),L&&E(`Enable Response (ServerProxy to Client): send size ${i.size} ${f.length} rows from cache`))}}}break;case nt:{let i=Pe(t.rows);for(let[l,f]of Object.entries(i)){let R=a.get(l);R?R.updateRows(f):k==null||k(`TABLE_ROW message received for non registered viewport ${l}`)}this.processUpdates()}break;case Fe:{let i=this.viewports.get(t.viewPortId);if(i){let{from:l,to:f}=t;i.completeOperation(n,l,f)}}break;case Qe:case We:break;case"CREATE_VISUAL_LINK_SUCCESS":{let i=this.viewports.get(t.childVpId),l=this.viewports.get(t.parentVpId);if(i&&l){let{childColumnName:f,parentColumnName:R}=t,M=i.completeOperation(n,f,l.clientViewportId,R);M&&this.postMessageToClient(M)}}break;case"REMOVE_VISUAL_LINK_SUCCESS":{let i=this.viewports.get(t.childVpId);if(i){let l=i.completeOperation(n);l&&this.postMessageToClient(l)}}break;case ae:this.postMessageToClient({type:ae,tables:t.tables,requestId:n});break;case ie:{let i=this.cacheTableMeta(t),l=this.pendingTableMetaRequests.get(n);if(l){this.pendingTableMetaRequests.delete(n);let f=this.viewports.get(l);f?f.setTableSchema(i):k==null||k("Message has come back AFTER CREATE_VP_SUCCESS, what do we do now")}else this.postMessageToClient({type:ie,tableSchema:i,requestId:n})}break;case"VP_VISUAL_LINKS_RESP":{let i=this.getActiveLinks(t.links),l=this.viewports.get(t.vpId);if(i.length&&l){let f=Kt(i,this.viewports),[R,M]=l.setLinks(f);if(this.postMessageToClient(R),M){let{link:A,parentClientVpId:at}=M,de=C(),ge=this.mapClientToServerViewport.get(at);if(ge){let ut=l.createLink(de,A.fromColumn,ge,A.toColumn);this.sendMessageToServer(ut,de)}}}}break;case"VIEW_PORT_MENUS_RESP":if(t.menu.name){let i=this.viewports.get(t.vpId);if(i){let l=i.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_RESP":if(Ae(t)){let{action:i,rpcName:l}=t;this.awaitResponseToMessage({type:"GET_TABLE_META",table:i.table}).then(f=>{let R=re(f);this.postMessageToClient({rpcName:l,type:"VIEW_PORT_MENU_RESP",action:{...i,tableSchema:R},tableAlreadyOpen:this.isTableOpen(i.table),requestId:n})})}else{let{action:i}=t;this.postMessageToClient({type:"VIEW_PORT_MENU_RESP",action:i||Bt,tableAlreadyOpen:i!==null&&this.isTableOpen(i.table),requestId:n})}break;case oe:{let{method:i,result:l}=t;this.postMessageToClient({type:oe,method:i,result:l,requestId:n})}break;case"ERROR":O(t.msg);break;default:Wt&&S(`handleMessageFromServer ${t.type}.`)}}hasSchemaForTable(e){return this.cachedTableSchemas.has(`${e.module}:${e.table}`)}cacheTableMeta(e){let{module:t,table:n}=e.table,r=`${t}:${n}`,o=this.cachedTableSchemas.get(r);return o||(o=re(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,a=e.getNewRowCount();(a!==void 0||r&&r.length>0)&&(L&&E(`postMessageToClient #${e.clientViewportId} viewport-update ${o}, ${(t=r==null?void 0:r.length)!=null?t:"no"} rows, size ${a}`),o&&this.postMessageToClient({clientViewportId:e.clientViewportId,mode:o,rows:r,size:a,type:"viewport-update"}))}}})}};var D,{info:ce,infoEnabled:pe}=w("worker");async function Ht(s,e,t,n,r,o,a){let u=await Ie(s,e,c=>{Oe(c)?(console.log("post connection metrics"),postMessage({type:"connection-metrics",messages:c})):Le(c)?(r(c),c.status==="reconnected"&&D.reconnect()):D.handleMessageFromServer(c)},o,a);D=new J(u,c=>jt(c)),u.requiresLogin&&await D.login(t,n)}function jt(s){postMessage(s)}var zt=async({data:s})=>{switch(s.type){case"connect":await Ht(s.url,s.protocol,s.token,s.username,postMessage,s.retryLimitDisconnect,s.retryLimitStartup),postMessage({type:"connected"});break;case"subscribe":pe&&ce(`client subscribe: ${JSON.stringify(s)}`),D.subscribe(s);break;case"unsubscribe":pe&&ce(`client unsubscribe: ${JSON.stringify(s)}`),D.unsubscribe(s.viewport);break;default:pe&&ce(`client message: ${JSON.stringify(s)}`),D.handleMessageFromClient(s)}};self.addEventListener("message",zt);postMessage({type:"ready"});\n\n';var JS=new Blob([KS()+ep],{type:"text/javascript"}),QS=URL.createObjectURL(JS),Rr,za,Wa=[],YS,XS,tp=new Promise((r,e)=>{YS=r,XS=e}),Ga=()=>tp,hs=new Map,fs=new Map,ZS=async({handleConnectionStatusChange:r,protocol:e,retryLimitDisconnect:t,retryLimitStartup:n,token:o="",username:i,url:s})=>o===""&&za===void 0?new Promise(l=>{Wa.push({resolve:l})}):za||(za=new Promise(l=>{let a=new Worker(QS),c=window.setTimeout(()=>{console.error("timed out waiting for worker to load")},1e3);a.onmessage=u=>{let{data:h}=u;if(h.type==="ready")window.clearTimeout(c),a.postMessage({protocol:e,retryLimitDisconnect:t,retryLimitStartup:n,token:o,type:"connect",url:s,username:i});else if(h.type==="connected"){a.onmessage=np,l(a);for(let f of Wa)f.resolve(a);Wa.length=0}else _a(h)?r({data:h}):console.warn("ConnectionManager: Unexpected message from the worker")}}));function np({data:r}){if(Kd(r)){let e=hs.get(r.clientViewportId);e?e.postMessageToClientDataSource(r):console.error(`[ConnectionManager] ${r.type} message received, viewport not found`)}else if(_a(r))ds.emit("connection-status",r);else if(Yd(r))ds.emit("connection-metrics",r);else{let e=r.requestId;if(fs.has(e)){let{resolve:t}=fs.get(e);fs.delete(e);let{type:n,requestId:o,...i}=r;Xd(r)?t(r.result):r.type==="VP_EDIT_RPC_RESPONSE"||r.type==="VP_EDIT_RPC_REJECT"?t(r):Zd(r)?t(r.tableSchema):t(i)}else console.warn("%cConnectionManager Unexpected message from the worker","color:red;font-weight:bold;")}}var $a=r=>{let e=jS();return Rr.postMessage({requestId:e,...r}),new Promise((t,n)=>{fs.set(e,{resolve:t,reject:n})})},eC={subscribe:(r,e)=>{hs.set(r.viewport,{status:"subscribing",request:r,postMessageToClientDataSource:e}),Rr.postMessage({type:"subscribe",...r})},unsubscribe:r=>{Rr.postMessage({type:"unsubscribe",viewport:r})},send:r=>{Rr.postMessage(r)},destroy:r=>{r&&hs.has(r)&&hs.delete(r)},rpcCall:async r=>$a(r),getTableList:async()=>$a({type:Jd}),getTableSchema:async r=>$a({type:Qd,table:r})},Ua=class extends qS{async connect({url:e,authToken:t,username:n,protocol:o,retryLimitDisconnect:i,retryLimitStartup:s}){return Rr=await ZS({protocol:o,url:e,token:t,username:n,retryLimitDisconnect:i,retryLimitStartup:s,handleConnectionStatusChange:np}),eC}destroy(){Rr.terminate()}},ds=new Ua;var rp=async r=>{try{return(await tp).rpcCall(r)}catch{throw Error("Error accessing server api")}};var tC=0,Wo=class{constructor(e,t){this.from=e,this.to=t}},J=class{constructor(e={}){this.id=tC++,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=ke.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};J.closedBy=new J({deserialize:r=>r.split(" ")});J.openedBy=new J({deserialize:r=>r.split(" ")});J.group=new J({deserialize:r=>r.split(" ")});J.contextHash=new J({perNode:!0});J.lookAhead=new J({perNode:!0});J.mounted=new J({perNode:!0});var nC=Object.create(null),ke=class{constructor(e,t,n,o=0){this.name=e,this.props=t,this.id=n,this.flags=o}static define(e){let t=e.props&&e.props.length?Object.create(null):nC,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new ke(e.name||"",t,e.id,n);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(o)),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 o}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(J.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let o of n.split(" "))t[o]=e[n];return n=>{for(let o=n.prop(J.group),i=-1;i<(o?o.length:0);i++){let s=t[i<0?n.name:o[i]];if(s)return s}}}};ke.none=new ke("",Object.create(null),0,8);var Kn=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 n of this.types){let o=null;for(let i of e){let s=i(n);s&&(o||(o=Object.assign({},n.props)),o[s[0].id]=s[1])}t.push(o?new ke(n.name,o,n.id,n.flags):n)}return new Kn(t)}},ps=new WeakMap,op=new WeakMap,ye;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays"})(ye||(ye={}));var le=class{constructor(e,t,n,o,i){if(this.type=e,this.children=t,this.positions=n,this.length=o,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,l]of i)this.props[typeof s=="number"?s:s.id]=l}}toString(){let e=this.prop(J.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let o=n.toString();o&&(t&&(t+=","),t+=o)}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 Pr(this.topNode,e)}cursorAt(e,t=0,n=0){let o=ps.get(this)||this.topNode,i=new Pr(o);return i.moveTo(e,t),ps.set(this,i._tree),i}get topNode(){return new It(this,0,0,null)}resolve(e,t=0){let n=Ir(ps.get(this)||this.topNode,e,t,!1);return ps.set(this,n),n}resolveInner(e,t=0){let n=Ir(op.get(this)||this.topNode,e,t,!0);return op.set(this,n),n}iterate(e){let{enter:t,leave:n,from:o=0,to:i=this.length}=e,s=e.mode||0,l=(s&ye.IncludeAnonymous)>0;for(let a=this.cursor(s|ye.IncludeAnonymous);;){let c=!1;if(a.from<=i&&a.to>=o&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.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:Ja(ke.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,o)=>new le(this.type,t,n,o,this.propValues),e.makeTree||((t,n,o)=>new le(ke.none,t,n,o)))}static build(e){return rC(e)}};le.empty=new le(ke.none,[],[],0);var $o=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 $o(this.buffer,this.index)}},Zt=class{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return ke.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],n=this.buffer[e+3],o=this.set.types[t],i=o.name;if(/\W/.test(i)&&!o.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let s=[];for(;e<n;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,t,n,o,i){let{buffer:s}=this,l=-1;for(let a=e;a!=t&&!(sp(i,o,s[a+1],s[a+2])&&(l=a,n>0));a=s[a+3]);return l}slice(e,t,n){let o=this.buffer,i=new Uint16Array(t-e),s=0;for(let l=e,a=0;l<t;){i[a++]=o[l++],i[a++]=o[l++]-n;let c=i[a++]=o[l++]-n;i[a++]=o[l++]-e,s=Math.max(s,c)}return new Zt(i,s,this.set)}};function sp(r,e,t,n){switch(r){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function lp(r,e){let t=r.childBefore(e);for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(r=t,t=n.prevSibling):t=n}return r}function Ir(r,e,t,n){for(var o;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let s=!n&&r instanceof It&&r.index<0?null:r.parent;if(!s)return r;r=s}let i=n?0:ye.IgnoreOverlays;if(n)for(let s=r,l=s.parent;l;s=l,l=s.parent)s instanceof It&&s.index<0&&((o=l.enter(e,t,i))===null||o===void 0?void 0:o.from)!=s.from&&(r=l);for(;;){let s=r.enter(e,t,i);if(!s)return r;r=s}}var It=class{constructor(e,t,n,o){this._tree=e,this.from=t,this.index=n,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,o,i=0){for(let s=this;;){for(let{children:l,positions:a}=s._tree,c=t>0?l.length:-1;e!=c;e+=t){let u=l[e],h=a[e]+s.from;if(sp(o,n,h,h+u.length)){if(u instanceof Zt){if(i&ye.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,t,n-h,o);if(f>-1)return new Bt(new qa(s,u,e,h),null,f)}else if(i&ye.IncludeAnonymous||!u.type.isAnonymous||ja(u)){let f;if(!(i&ye.IgnoreMounts)&&u.props&&(f=u.prop(J.mounted))&&!f.overlay)return new It(f.tree,h,e,s);let d=new It(u,h,e,s);return i&ye.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?u.children.length-1:0,t,n,o)}}}if(i&ye.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))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,n=0){let o;if(!(n&ye.IgnoreOverlays)&&(o=this._tree.prop(J.mounted))&&o.overlay){let i=e-this.from;for(let{from:s,to:l}of o.overlay)if((t>0?s<=i:s<i)&&(t<0?l>=i:l>i))return new It(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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 Pr(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return Ir(this,e,t,!1)}resolveInner(e,t=0){return Ir(this,e,t,!0)}enterUnfinishedNodesBefore(e){return lp(this,e)}getChild(e,t=null,n=null){let o=gs(this,e,t,n);return o.length?o[0]:null}getChildren(e,t=null,n=null){return gs(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return ys(this,e)}};function gs(r,e,t,n){let o=r.cursor(),i=[];if(!o.firstChild())return i;if(t!=null){for(;!o.type.is(t);)if(!o.nextSibling())return i}for(;;){if(n!=null&&o.type.is(n))return i;if(o.type.is(e)&&i.push(o.node),!o.nextSibling())return n==null?i:[]}}function ys(r,e,t=e.length-1){for(let n=r.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var qa=class{constructor(e,t,n,o){this.parent=e,this.buffer=t,this.index=n,this.start=o}},Bt=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,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new Bt(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,n=0){if(n&ye.ExcludeBuffers)return null;let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new Bt(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 Bt(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 Bt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Pr(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,o=this.index+4,i=n.buffer[this.index+3];if(i>o){let s=n.buffer[this.index+1];e.push(n.slice(o,i,s)),t.push(0)}return new le(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Ir(this,e,t,!1)}resolveInner(e,t=0){return Ir(this,e,t,!0)}enterUnfinishedNodesBefore(e){return lp(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let o=gs(this,e,t,n);return o.length?o[0]:null}getChildren(e,t=null,n=null){return gs(this,e,t,n)}get node(){return this}matchContext(e){return ys(this,e)}},Pr=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 It)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.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:n,buffer:o}=this.buffer;return this.type=t||o.set.types[o.buffer[e]],this.from=n+o.buffer[e+1],this.to=n+o.buffer[e+2],!0}yield(e){return e?e instanceof It?(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,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:o}=this.buffer,i=o.findChild(this.index+4,o.buffer[this.index+3],e,t-this.buffer.start,n);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,n=this.mode){return this.buffer?n&ye.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ye.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ye.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,n=this.stack.length-1;if(e<0){let o=n<0?0:this.stack[n]+4;if(this.index!=o)return this.yieldBuf(t.findChild(o,this.index,-1,0,4))}else{let o=t.buffer[this.index+3];if(o<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(o)}return n<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,n,{buffer:o}=this;if(o){if(e>0){if(this.index<o.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(o.buffer.buffer[i+3]<this.index)return!1;({index:t,parent:n}=o)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let i=t+e,s=e<0?-1:n._tree.children.length;i!=s;i+=e){let l=n._tree.children[i];if(this.mode&ye.IncludeAnonymous||l instanceof Zt||!l.type.isAnonymous||ja(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let o=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==o){if(o==this.index)return s;t=s,n=i+1;break e}o=this.stack[--i]}for(let o=n;o<this.stack.length;o++)t=new Bt(this.buffer,t,this.stack[o]);return this.bufferNode=new Bt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let o=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(o=!0)}for(;o&&t&&t(this),o=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,o=!0}}}matchContext(e){if(!this.buffer)return ys(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let o=e.length-1,i=this.stack.length-1;o>=0;i--){if(i<0)return ys(this.node,e,o);let s=n[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[o]&&e[o]!=s.name)return!1;o--}}return!0}};function ja(r){return r.children.some(e=>e instanceof Zt||!e.type.isAnonymous||ja(e))}function rC(r){var e;let{buffer:t,nodeSet:n,maxBufferLength:o=1024,reused:i=[],minRepeatType:s=n.types.length}=r,l=Array.isArray(t)?new $o(t,t.length):t,a=n.types,c=0,u=0;function h(x,S,b,C,k){let{id:E,start:R,end:M,size:P}=l,I=u;for(;P<0;)if(l.next(),P==-1){let N=i[E];b.push(N),C.push(R-x);return}else if(P==-3){c=E;return}else if(P==-4){u=E;return}else throw new RangeError(`Unrecognized record size: ${P}`);let V=a[E],B,W,O=R-x;if(M-R<=o&&(W=m(l.pos-S,k))){let N=new Uint16Array(W.size-W.skip),F=l.pos-W.size,G=N.length;for(;l.pos>F;)G=y(W.start,N,G);B=new Zt(N,M-W.start,n),O=W.start-x}else{let N=l.pos-P;l.next();let F=[],G=[],X=E>=s?E:-1,te=0,_e=M;for(;l.pos>N;)X>=0&&l.id==X&&l.size>=0?(l.end<=_e-o&&(d(F,G,R,te,l.end,_e,X,I),te=F.length,_e=l.end),l.next()):h(R,N,F,G,X);if(X>=0&&te>0&&te<F.length&&d(F,G,R,te,R,_e,X,I),F.reverse(),G.reverse(),X>-1&&te>0){let de=f(V);B=Ja(V,F,G,0,F.length,0,M-R,de,de)}else B=p(V,F,G,M-R,I-M)}b.push(B),C.push(O)}function f(x){return(S,b,C)=>{let k=0,E=S.length-1,R,M;if(E>=0&&(R=S[E])instanceof le){if(!E&&R.type==x&&R.length==C)return R;(M=R.prop(J.lookAhead))&&(k=b[E]+R.length+M)}return p(x,S,b,C,k)}}function d(x,S,b,C,k,E,R,M){let P=[],I=[];for(;x.length>C;)P.push(x.pop()),I.push(S.pop()+b-k);x.push(p(n.types[R],P,I,E-k,M-E)),S.push(k-b)}function p(x,S,b,C,k=0,E){if(c){let R=[J.contextHash,c];E=E?[R].concat(E):[R]}if(k>25){let R=[J.lookAhead,k];E=E?[R].concat(E):[R]}return new le(x,S,b,C,E)}function m(x,S){let b=l.fork(),C=0,k=0,E=0,R=b.end-o,M={size:0,start:0,skip:0};e:for(let P=b.pos-x;b.pos>P;){let I=b.size;if(b.id==S&&I>=0){M.size=C,M.start=k,M.skip=E,E+=4,C+=4,b.next();continue}let V=b.pos-I;if(I<0||V<P||b.start<R)break;let B=b.id>=s?4:0,W=b.start;for(b.next();b.pos>V;){if(b.size<0)if(b.size==-3)B+=4;else break e;else b.id>=s&&(B+=4);b.next()}k=W,C+=I,E+=B}return(S<0||C==x)&&(M.size=C,M.start=k,M.skip=E),M.size>4?M:void 0}function y(x,S,b){let{id:C,start:k,end:E,size:R}=l;if(l.next(),R>=0&&C<s){let M=b;if(R>4){let P=l.pos-(R-4);for(;l.pos>P;)b=y(x,S,b)}S[--b]=M,S[--b]=E-x,S[--b]=k-x,S[--b]=C}else R==-3?c=C:R==-4&&(u=C);return b}let g=[],v=[];for(;l.pos>0;)h(r.start||0,r.bufferStart||0,g,v,-1);let w=(e=r.length)!==null&&e!==void 0?e:g.length?v[0]+g[0].length:0;return new le(a[r.topID],g.reverse(),v.reverse(),w)}var ip=new WeakMap;function ms(r,e){if(!r.isAnonymous||e instanceof Zt||e.type!=r)return 1;let t=ip.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=r||!(n instanceof le)){t=1;break}t+=ms(r,n)}ip.set(e,t)}return t}function Ja(r,e,t,n,o,i,s,l,a){let c=0;for(let p=n;p<o;p++)c+=ms(r,e[p]);let u=Math.ceil(c*1.5/8),h=[],f=[];function d(p,m,y,g,v){for(let w=y;w<g;){let x=w,S=m[w],b=ms(r,p[w]);for(w++;w<g;w++){let C=ms(r,p[w]);if(b+C>=u)break;b+=C}if(w==x+1){if(b>u){let C=p[x];d(C.children,C.positions,0,C.children.length,m[x]+v);continue}h.push(p[x])}else{let C=m[w-1]+p[w-1].length-S;h.push(Ja(r,p,m,x,w,S,C,null,a))}f.push(S+v-i)}}return d(e,t,n,o,0),(l||a)(h,f,s)}var Ht=class{constructor(e,t,n,o,i=!1,s=!1){this.from=e,this.to=t,this.tree=n,this.offset=o,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let o=[new Ht(0,e.length,e,0,!1,n)];for(let i of t)i.to>e.length&&o.push(i);return o}static applyChanges(e,t,n=128){if(!t.length)return e;let o=[],i=1,s=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let u=l<t.length?t[l]:null,h=u?u.fromA:1e9;if(h-a>=n)for(;s&&s.from<h;){let f=s;if(a>=f.from||h<=f.to||c){let d=Math.max(f.from,a)-c,p=Math.min(f.to,h)-c;f=d>=p?null:new Ht(d,p,f.tree,f.offset+c,l>0,!!u)}if(f&&o.push(f),s.to>h)break;s=i<e.length?e[i++]:null}if(!u)break;a=u.toA,c=u.toA-u.toB}return o}},Dr=class{startParse(e,t,n){return typeof e=="string"&&(e=new Ka(e)),n=n?n.length?n.map(o=>new Wo(o.from,o.to)):[new Wo(0,0)]:[new Wo(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let o=this.startParse(e,t,n);for(;;){let i=o.advance();if(i)return i}}},Ka=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 GB=new J({perNode:!0});var Ar=class{constructor(e,t,n,o,i,s,l,a,c,u=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=o,this.pos=i,this.score=s,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=u,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,n=0){let o=e.parser.context;return new Ar(e,[],t,n,n,0,[],0,o?new bs(o,o.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 n=e>>19,o=e&65535,{parser:i}=this.p,s=i.dynamicPrecedence(o);if(s&&(this.score+=s),n==0){this.pushState(i.getGoto(this.state,o,!0),this.reducePos),o<i.minRepeatTerm&&this.storeNode(o,this.reducePos,this.reducePos,4,!0),this.reduceContext(o,this.reducePos);return}let l=this.stack.length-(n-1)*3-(e&262144?6:0),a=l?this.stack[l-2]:this.p.ranges[0].from,c=this.reducePos-a;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[o])===null||t===void 0)&&t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=c));let u=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-u;if(o<i.minRepeatTerm||e&131072){let f=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(o,a,f,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=i.getGoto(f,o,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(o,a)}storeNode(e,t,n,o=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,l=this.buffer.length;if(l==0&&s.parent&&(l=s.bufferBase-s.parent.bufferBase,s=s.parent),l>0&&s.buffer[l-4]==0&&s.buffer[l-1]>-1){if(t==n)return;if(s.buffer[l-2]>=t){s.buffer[l-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,o);else{let s=this.buffer.length;if(s>0&&this.buffer[s-4]!=0)for(;s>0&&this.buffer[s-2]>n;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,o>4&&(o-=4);this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=n,this.buffer[s+3]=o}}shift(e,t,n){let o=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=n,this.shiftContext(t,o),t<=this.p.parser.maxNode&&this.buffer.push(t,o,n,4);else{let i=e,{parser:s}=this.p;(n>this.pos||t<=s.maxNode)&&(this.pos=n,s.stateFlag(i,1)||(this.reducePos=n)),this.pushState(i,o),this.shiftContext(t,o),t<=s.maxNode&&this.buffer.push(t,o,n,4)}}apply(e,t,n){e&65536?this.reduce(e):this.shift(e,t,n)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(t,o),this.buffer.push(n,o,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 n=e.buffer.slice(t),o=e.bufferBase+t;for(;e&&o==e.bufferBase;)e=e.parent;return new Ar(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Ya(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}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 o=[];for(let i=0,s;i<t.length;i+=2)(s=t[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&o.push(t[i],s);if(this.stack.length<120)for(let i=0;o.length<4<<1&&i<t.length;i+=2){let s=t[i+1];o.some((l,a)=>a&1&&l==s)||o.push(t[i],s)}t=o}let n=[];for(let o=0;o<t.length&&n.length<4;o+=2){let i=t[o+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(t[o],this.pos),s.score-=200,n.push(s)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,o=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],o,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;t=s}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=[],n=(o,i)=>{if(!t.includes(o))return t.push(o),e.allActions(o,s=>{if(!(s&393216))if(s&65536){let l=(s>>19)-i;if(l>1){let a=s&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],a,!1)>=0)return l<<19|65536|a}}else{let l=n(s,i+1);if(l!=null)return l}})};return n(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 bs(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()}},bs=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},ap;(function(r){r[r.Insert=200]="Insert",r[r.Delete=190]="Delete",r[r.Reduce=100]="Reduce",r[r.MaxNext=4]="MaxNext",r[r.MaxInsertStackDepth=300]="MaxInsertStackDepth",r[r.DampenInsertStackDepth=120]="DampenInsertStackDepth",r[r.MinBigReduction=2e3]="MinBigReduction"})(ap||(ap={}));var Ya=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,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=o}},Or=class{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Or(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 Or(this.stack,this.pos,this.index)}};function Uo(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let n=0,o=0;n<r.length;){let i=0;for(;;){let s=r.charCodeAt(n++),l=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let a=s-32;if(a>=46&&(a-=46,l=!0),i+=a,l)break;i*=46}t?t[o++]=i:t=new e(i)}return t}var Lr=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},cp=new Lr,Xa=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=cp,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 n=this.range,o=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!o)return null;let s=this.ranges[--o];i-=n.from-s.to,n=s}for(;t<0?i>n.to:i>=n.to;){if(o==this.ranges.length-1)return null;let s=this.ranges[++o];i+=s.from-n.to,n=s}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,n,o;if(t>=0&&t<this.chunk.length)n=this.pos+e,o=this.chunk.charCodeAt(t);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(n=i,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)o=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let s=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),o=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),o}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}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=cp,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 n="";for(let o of this.ranges){if(o.from>=t)break;o.to>e&&(n+=this.input.read(Math.max(o.from,e),Math.min(o.to,t)))}return n}},yn=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;gp(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};yn.prototype.contextual=yn.prototype.fallback=yn.prototype.extend=!1;var Za=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?Uo(e):e}token(e,t){let n=e.pos,o=0;for(;;){let i=e.next<0,s=e.resolveOffset(1,1);if(gp(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(i||o++,s==null)break;e.reset(s,e.token)}o&&(e.reset(n,e.token),e.acceptToken(this.elseToken,o))}};Za.prototype.contextual=yn.prototype.fallback=yn.prototype.extend=!1;function gp(r,e,t,n,o,i){let s=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;l&r[s];){let c=r[s+1];for(let d=s+3;d<c;d+=2)if((r[d+1]&l)>0){let p=r[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||iC(p,e.token.value,o,i))){e.acceptToken(p);break}}let u=e.next,h=0,f=r[s+2];if(e.next<0&&f>h&&r[c+f*3-3]==65535&&r[c+f*3-3]==65535){s=r[c+f*3-1];continue e}for(;h<f;){let d=h+f>>1,p=c+d+(d<<1),m=r[p],y=r[p+1]||65536;if(u<m)f=d;else if(u>=y)h=d+1;else{s=r[p+2],e.advance();continue e}}break}}function up(r,e,t){for(let n=e,o;(o=r[n])!=65535;n++)if(o==t)return n-e;return-1}function iC(r,e,t,n){let o=up(t,n,e);return o<0||up(t,n,r)<o}var Pt=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),Qa=null,hp;(function(r){r[r.Margin=25]="Margin"})(hp||(hp={}));function fp(r,e,t){let n=r.cursor(ye.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(r.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:r.length}}var ec=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?fp(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?fp(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 n=this.trees[t],o=this.index[t];if(o==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[o],s=this.start[t]+n.positions[o];if(s>e)return this.nextStart=s,null;if(i instanceof le){if(s==e){if(s<this.safeFrom)return null;let l=s+i.length;if(l<=this.safeTo){let a=i.prop(J.lookAhead);if(!a||l+a<this.fragment.to)return i}}this.index[t]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+i.length}}},tc=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Lr)}getActions(e){let t=0,n=null,{parser:o}=e.p,{tokenizers:i}=o,s=o.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;c<i.length;c++){if(!(1<<c&s))continue;let u=i[c],h=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||h.start!=e.pos||h.mask!=s||h.context!=l)&&(this.updateCachedToken(h,u,e),h.mask=s,h.context=l),h.lookAhead>h.end+25&&(a=Math.max(h.lookAhead,a)),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),!u.extend&&(n=h,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Lr,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Lr,{pos:n,p:o}=e;return t.start=n,t.end=Math.min(n+1,o.stream.end),t.value=n==o.stream.end?o.parser.eofTerm:0,t}updateCachedToken(e,t,n){let o=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(o,e),n),e.value>-1){let{parser:i}=n.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let l=i.specializers[s](this.stream.read(e.start,e.end),n);if(l>=0&&n.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,t,n,o){for(let i=0;i<o;i+=3)if(this.actions[i]==e)return o;return this.actions[o++]=e,this.actions[o++]=t,this.actions[o++]=n,o}addActions(e,t,n,o){let{state:i}=e,{parser:s}=e.p,{data:l}=s;for(let a=0;a<2;a++)for(let c=s.stateSlot(i,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=en(l,c+2);else{o==0&&l[c+1]==2&&(o=this.putAction(en(l,c+2),t,n,o));break}l[c]==t&&(o=this.putAction(en(l,c+1),t,n,o))}return o}},dp;(function(r){r[r.Distance=5]="Distance",r[r.MaxRemainingPerStep=3]="MaxRemainingPerStep",r[r.MinBufferLengthPrune=500]="MinBufferLengthPrune",r[r.ForceReduceLimit=10]="ForceReduceLimit",r[r.CutDepth=15e3]="CutDepth",r[r.CutTo=9e3]="CutTo",r[r.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",r[r.MaxStackCount=12]="MaxStackCount"})(dp||(dp={}));var nc=class{constructor(e,t,n,o){this.parser=e,this.input=t,this.ranges=o,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 Xa(t,o),this.tokens=new tc(e,this.stream),this.topTerm=e.top[1];let{from:i}=o[0];this.stacks=[Ar.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new ec(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],o,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let l=e[s];for(;;){if(this.tokens.mainToken=null,l.pos>t)n.push(l);else{if(this.advanceStack(l,n,e))continue;{o||(o=[],i=[]),o.push(l);let a=this.tokens.getMainToken(l);i.push(a.value,a.end)}}break}}if(!n.length){let s=o&&sC(o);if(s)return this.stackToTree(s);if(this.parser.strict)throw Pt&&o&&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&&o){let s=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,i,n);if(s)return this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(n.length>s)for(n.sort((l,a)=>a.score-l.score);n.length>s;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let s=0;s<n.length-1;s++){let l=n[s];for(let a=s+1;a<n.length;a++){let c=n[a];if(l.sameState(c)||l.buffer.length>500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)n.splice(a--,1);else{n.splice(s--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let s=1;s<n.length;s++)n[s].pos<this.minStackPos&&(this.minStackPos=n[s].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,n){let o=e.pos,{parser:i}=this,s=Pt?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let h=this.fragments.nodeAt(o);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(J.contextHash)||0)==u))return e.useNode(h,f),Pt&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(h.type.id)})`),!0;if(!(h instanceof le)||h.children.length==0||h.positions[0]>0)break;let d=h.children[0];if(d instanceof le&&h.positions[0]==0)h=d;else break}}let l=i.stateSlot(e.state,4);if(l>0)return e.reduce(l),Pt&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(l&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let c=0;c<a.length;){let u=a[c++],h=a[c++],f=a[c++],d=c==a.length||!n,p=d?e:e.split();if(p.apply(u,h,f),Pt&&console.log(s+this.stackID(p)+` (via ${u&65536?`reduce of ${i.getName(u&65535)}`:"shift"} for ${i.getName(h)} @ ${o}${p==e?"":", split"})`),d)return!0;p.pos>o?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return pp(e,t),!0}}runRecovery(e,t,n){let o=null,i=!1;for(let s=0;s<e.length;s++){let l=e[s],a=t[s<<1],c=t[(s<<1)+1],u=Pt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(i||(i=!0,l.restart(),Pt&&console.log(u+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let h=l.split(),f=u;for(let d=0;h.forceReduce()&&d<10&&(Pt&&console.log(f+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));d++)Pt&&(f=this.stackID(h)+" -> ");for(let d of l.recoverByInsert(a))Pt&&console.log(u+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,n);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),Pt&&console.log(u+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),pp(l,n)):(!o||o.score<l.score)&&(o=l)}return o}stackToTree(e){return e.close(),le.build({buffer:Or.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=(Qa||(Qa=new WeakMap)).get(e);return t||Qa.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function pp(r,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==r.pos&&n.sameState(r)){e[t].score<r.score&&(e[t]=r);return}}e.push(r)}var rc=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}};var jn=class extends Dr{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),o=[];for(let l=0;l<t.length;l++)o.push([]);function i(l,a,c){o[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=J[a]);for(let c=1;c<l.length;){let u=l[c++];if(u>=0)i(u,a,l[c++]);else{let h=l[c+-u];for(let f=-u;f>0;f--)i(l[c++],a,h);c++}}}this.nodeSet=new Kn(t.map((l,a)=>ke.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:o[a],top:n.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let s=Uo(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(mp),this.states=Uo(e.states,Uint32Array),this.data=Uo(e.stateData),this.goto=Uo(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new yn(s,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let o=new nc(this,e,t,n);for(let i of this.wrappers)o=i(o,e,t,n);return o}getGoto(e,t,n=!1){let o=this.goto;if(t>=o[0])return-1;for(let i=o[t+1];;){let s=o[i++],l=s&1,a=o[i++];if(l&&n)return a;for(let c=i+(s>>1);i<c;i++)if(o[i]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let o=0;o<2;o++)for(let i=this.stateSlot(e,o?2:1),s;;i+=3){if((s=n[i])==65535)if(n[i+1]==1)s=n[i=en(n,i+2)];else{if(n[i+1]==2)return en(n,i+2);break}if(s==t||s==0)return en(n,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,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),o=n?t(n):void 0;for(let i=this.stateSlot(e,1);o==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=en(this.data,i+2);else break;o=t(en(this.data,i+1))}return o}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=en(this.data,n+2);else break;if(!(this.data[n+2]&1)){let o=this.data[n+1];t.some((i,s)=>s&1&&i==o)||t.push(this.data[n],o)}}return t}configure(e){let t=Object.assign(Object.create(jn.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let o=e.tokenizers.find(i=>i.from==n);return o?o.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,o)=>{let i=e.specializers.find(l=>l.from==n.external);if(!i)return n;let s=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[o]=mp(s),s})),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),n=t.map(()=>!1);if(e)for(let i of e.split(" ")){let s=t.indexOf(i);s>=0&&(n[s]=!0)}let o=null;for(let i=0;i<t.length;i++)if(!n[i])for(let s=this.dialects[t[i]],l;(l=this.data[s++])!=65535;)(o||(o=new Uint8Array(this.maxTerm+1)))[l]=1;return new rc(e,n,o)}static deserialize(e){return new jn(e)}};function en(r,e){return r[e]|r[e+1]<<16}function sC(r){let e=null;for(let t of r){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function mp(r){if(r.external){let e=r.extend?1:0;return(t,n)=>r.external(t,n)<<1|e}return r.get}var Go=jn.deserialize({version:14,states:"%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",stateData:"#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",goto:"#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",nodeNames:"\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:"6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",tokenizers:[0,1],topRules:{Filter:[0,1]},tokenPrec:0});import{isMultiClauseFilter as qo,isMultiValueFilter as lC,isSingleValueFilter as aC}from"@vuu-ui/vuu-utils";var Qe,oc=class{constructor(){ee(this,Qe,void 0)}setFilterCombinatorOp(e,t=T(this,Qe)){qo(t)&&t.op===e||z(this,Qe,{op:e,filters:[T(this,Qe)]})}add(e){if(T(this,Qe)===void 0)z(this,Qe,e);else if(qo(T(this,Qe)))T(this,Qe).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=T(this,Qe)){if(qo(t)){let n=t.filters.at(-1);n&&this.setColumn(e,n)}else t&&(t.column=e)}setOp(e,t=T(this,Qe)){if(qo(t)){let n=t.filters.at(-1);n&&this.setOp(e,n)}else t&&(t.op=e)}setValue(e,t=T(this,Qe)){var n;if(qo(t)){let o=t.filters.at(-1);o&&this.setValue(e,o)}else lC(t)?((n=t.values)!=null||(t.values=[]),t.values.push(e)):aC(t)&&(t.value=e)}toJSON(e=T(this,Qe)){return this.name?{...e,name:this.name}:e}};Qe=new WeakMap;var xs=(r,e)=>{let t=new oc,n=r.cursor();do{let{name:o,from:i,to:s}=n;switch(o){case"ColumnValueExpression":t.add({});break;case"ColumnSetExpression":t.add({op:"in"});break;case"Or":case"And":t.setFilterCombinatorOp(e.substring(i,s));break;case"Column":t.setColumn(e.substring(i,s));break;case"Operator":t.setOp(e.substring(i,s));break;case"String":t.setValue(e.substring(i+1,s-1));break;case"Number":t.setValue(parseFloat(e.substring(i,s)));break;case"True":t.setValue(!0);break;case"False":t.setValue(!1);break;case"FilterName":t.name=e.substring(i,s);break;default:}}while(n.next());return t.toJSON()};var cC=Go.configure({strict:!0}),Jn=r=>{let e=cC.parse(r);return xs(e,r)};function vs(r,e){switch(e.op){case"in":return uC(r,e);case"=":return hC(r,e);case">":return fC(r,e);case">=":return dC(r,e);case"<":return pC(r,e);case"<=":return mC(r,e);case"starts":return gC(r,e);case"and":return yC(r,e);case"or":return bC(r,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var uC=(r,e)=>t=>e.values.indexOf(t[r[e.column]])!==-1,hC=(r,e)=>t=>t[r[e.column]]===e.value,fC=(r,e)=>t=>t[r[e.column]]>e.value,dC=(r,e)=>t=>t[r[e.column]]>=e.value,pC=(r,e)=>t=>t[r[e.column]]<e.value,mC=(r,e)=>t=>t[r[e.column]]<=e.value,gC=(r,e)=>{let t=e.value;if(typeof t!="string")throw Error("string filter applied to value of wrong type");return n=>{let o=n[r[e.column]];if(typeof o!="string")throw Error("string filter applied to value of wrong type");return o.toLowerCase().startsWith(t.toLowerCase())}},yC=(r,e)=>{let t=e.filters.map(n=>vs(r,n));return n=>t.every(o=>o(n))};function bC(r,e){let t=e.filters.map(n=>vs(r,n));return n=>t.some(o=>o(n))}import{buildColumnMap as LC,EventEmitter as AC,getAddedItems as OC,getMissingItems as NC,getSelectionStatus as VC,KeySet as FC,logger as BC,metadataKeys as HC,NULL_RANGE as kp,rangeNewItems as _C,resetRange as Ko,uuid as Mp}from"@vuu-ui/vuu-utils";var yp=(r,e,t,n,o,i)=>{let s=Qn(o,r),l=r[r.length-1].aggType,a=t.map(c=>o[c]);switch(l){case 1:return xp(i,n,o,r,e,a);case 2:return xC(i,n,o,r,e,a);case 3:return bp(i,o,r,e,a);case 4:return wC(i,n,o,r,e,a);case 5:return SC(i,n,o,r,e,a);case 6:return vC(i,n,o,r,e,a)}};function bp(r,e,t,n,o){let i={},s=Qn(e,t);function l(a){if(Array.isArray(a))return a.length;{let c=0;for(let u in a)c+=1+l(a[u]);return c}}for(let a in r){let c=l(r[a]);i[a]=c}for(let a=0;a<n.length;a++)for(let c in i)n[a][o[0]]===c&&(n[a][s]=i[c]);return console.log("!!!! targetData",n),console.log("!!!! counts",i),i}function Qn(r,e){console.log("!!!! aggregation length",e.length);let t=e[e.length-1].column;return r[t]}function xp(r,e,t,n,o,i){let s={},l=Qn(t,n);function a(c,u,h){if(Array.isArray(c)){let f=0;for(let d of c)f+=Number(u[d][h]);return f}else{let f=0;for(let d in c)f+=a(c[d],u,h);return f}}for(let c in r){console.log(c);let u=Number(a(r[c],e,l));s[c]=u}for(let c=0;c<o.length;c++)for(let u in s)o[c][i[0]]===u&&(o[c][l]=s[u]);return console.log("!!!! targetData",o),console.log("!!!! sums",s),s}function xC(r,e,t,n,o,i){let s={},l=Qn(t,n),a=bp(r,t,n,o,i),c=xp(r,e,t,n,o,i);for(let u in a){let h=0;h=c[u]/a[u],s[u]=h}for(let u=0;u<o.length;u++)for(let h in s)o[u][i[0]]===h&&(o[u][l]=s[h]);return console.log("!!!! targetData",o),console.log("!!!! averages",s),s}function ws(r,e,t){let n=[];if(Array.isArray(r))for(let o of r)n.push(e[o][t]);else for(let o in r)n.push(...ws(r[o],e,t));return n}function vC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=ws(r[a],e,l),u=[...new Set(c)];s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}function wC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=ws(r[a],e,l),u=Math.max(...c);s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}function SC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=ws(r[a],e,l),u=Math.min(...c);s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}import{metadataKeys as CC}from"@vuu-ui/vuu-utils";var{DEPTH:ic,IS_EXPANDED:vp,KEY:sc}=CC,wp=(r,e)=>{let t=[];for(let n=0,o=0,i=!1,s=e.length;n<s;n++){let l=e[n],{[ic]:a,[sc]:c}=l;if(c===r){let u=l.slice();for(u[vp]=!1,t.push(u),o+=1,i=!0;n<s-1&&e[n+1][ic]>a;)n+=1}else if(i){let u=l.slice();u[0]=o,u[1]=o,t.push(u),o+=1}else t.push(l),o+=1}return t},lc=(r,e,t,n,o,i)=>{let s=t.map(l=>n[l]);return Sp(o,s,r,e,void 0,void 0,void 0,i)},Sp=(r,e,t,n=[],o="$root",i=1,s=[],l)=>{let a=Object.keys(r).sort();for(let c of a){let u=s.length,h=`${o}|${c}`,f=[u,u,!1,!1,i,0,h,0];f[e[i-1]]=c,s.push(f),t.includes(h)&&(f[vp]=!0,Array.isArray(r[c])?TC(s,r[c],n,h,i+1):Sp(r[c],e,t,n,h,i+1,s,l))}for(let c in s)for(let u in s)if(s[c][2]===!1&&l[u]!=null&&s[c][e[0]]===l[u][e[0]]){s[c]=s[c].splice(0,8).concat(l[u].slice(8,l[u].length));break}return s},TC=(r,e,t,n,o)=>{for(let i of e){let s=r.length,l=t[i].slice();l[0]=s,l[1]=s,l[ic]=o,l[sc]=`${n}|${l[sc]}`,r.push(l)}},Cp=(r,e,t)=>{let n=e.map(s=>t[s]),o=MC(r,n);return[kC(o,n),o]},kC=(r,e)=>{let n=[],o=0,i=Object.keys(r).sort();for(let s of i){let l=[o,o,!1,!1,1,0,`$root|${s}`,0];l[e[0]]=s,n.push(l),o+=1}return n};function MC(r,e){let t={},n=e.length,o=n-1;for(let i=0,s=r.length;i<s;i++){let l=r[i],a=t,c,u;for(let h=0;h<n;h++){let f=e[h];u=l[f].toString(),c=a[u],c&&h===o?c.push(i):c?a=c:!c&&h<o?a=a[u]={}:c||(a[u]=[i])}}return console.log("!! groups",t),t}var EC=(r,e,[t,n])=>{let o=n==="D"?e[t]:r[t],i=n==="D"?r[t]:e[t];return o===i?0:i===null||o>i?1:-1},RC=r=>r.length===1?IC(r):r.length===2?PC(r):DC(r),IC=([[r,e]])=>(t,n)=>{let o=e==="D"?n[r]:t[r],i=e==="D"?t[r]:n[r];return o>i?1:i>o?-1:0},PC=([[r,e],[t,n]])=>(o,i)=>{let s=e==="D"?i[r]:o[r],l=e==="D"?o[r]:i[r],a=n==="D"?i[t]:o[t],c=n==="D"?o[t]:i[t];return s>l?1:l>s?-1:a>c?1:c>a?-1:0},DC=(r,e=EC)=>(t,n)=>{for(let o of r){let i=e(t,n,o);if(i!==0)return i}return 0},Tp=(r,{sortDefs:e},t)=>{let n=e.map(({column:i,sortType:s})=>[t[i],s]),o=RC(n);return r.slice().sort(o)};var{debug:ht}=BC("ArrayDataSource"),{RENDER_IDX:zC,SELECTED:WC}=HC,$C=(r,e)=>[e,e,!0,!1,1,0,r[0].toString(),0,...r],UC=r=>({columns:r.map(({name:t,serverDataType:n="string"})=>({name:t,serverDataType:n})),key:r[0].name,table:{module:"",table:"Array"}}),GC=(r,e,t)=>{let[n]=r,o=r.slice();return o[zC]=e.keyFor(n),o[WC]=VC(t,n),o},jo,Dt,Q,Ae,ve,Ss,Jo,Nr,Ep=class extends AC{constructor({aggregations:t,columnDescriptors:n,data:o,filter:i,groupBy:s,rangeChangeRowset:l="delta",sort:a,title:c,viewport:u}){super();this.status="initialising";this.disabled=!1;this.selectedRows=[];this.suspended=!1;this.lastRangeServed={from:0,to:0};this.openTreeNodes=[];ee(this,jo,[]);ee(this,Dt,void 0);ee(this,Q,Er);ee(this,Ae,void 0);ee(this,ve,kp);ee(this,Ss,0);ee(this,Jo,0);ee(this,Nr,void 0);this.keys=new FC(T(this,ve));this.processedData=void 0;if(console.log("ArrayDataSource",{columnDescriptors:n}),!o||!n)throw Error("ArrayDataSource constructor called without data or without columnDescriptors");this.columnDescriptors=n,z(this,jo,n.map(h=>h.name)),z(this,Dt,LC(T(this,jo))),this.rangeChangeRowset=l,this.tableSchema=UC(n),z(this,Ae,o.map($C)),this.viewport=u||Mp(),z(this,Jo,o.length),z(this,Nr,c),this.config={...T(this,Q),aggregations:t||T(this,Q).aggregations,columns:n.map(h=>h.name),filter:i||T(this,Q).filter,groupBy:s||T(this,Q).groupBy,sort:a||T(this,Q).sort},ht==null||ht(`columnMap: ${JSON.stringify(T(this,Dt))}`)}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:Mp())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var h;this.clientCallback=c,this.viewport=t,this.status="subscribed",this.lastRangeServed={from:0,to:0},o||n||a||l||s?(i&&z(this,ve,i),this.config={...T(this,Q),aggregations:o||T(this,Q).aggregations,columns:n||T(this,Q).columns,filter:a||T(this,Q).filter,groupBy:l||T(this,Q).groupBy,sort:s||T(this,Q).sort}):((h=this.clientCallback)==null||h.call(this,{...T(this,Q),type:"subscribed",clientViewportId:this.viewport,range:T(this,ve),tableSchema:this.tableSchema}),this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:T(this,Ae).length}),i?this.range=i:T(this,ve)!==kp&&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){ht==null||ht(`select ${JSON.stringify(t)}`),this.selectedRows=t,this.setRange(Ko(T(this,ve)),!0)}openTreeNode(t){this.openTreeNodes.push(t),this.processedData=lc(this.openTreeNodes,T(this,Ae),T(this,Q).groupBy,T(this,Dt),this.groupMap,this.processedData),this.setRange(Ko(T(this,ve)),!0)}closeTreeNode(t){this.openTreeNodes=this.openTreeNodes.filter(n=>n!==t),this.processedData&&(this.processedData=wp(t,this.processedData),this.setRange(Ko(T(this,ve)),!0))}get data(){return T(this,Ae)}get currentData(){var t;return(t=this.processedData)!=null?t:T(this,Ae)}get table(){return this.tableSchema.table}get config(){return T(this,Q)}set config(t){var n;if(cs(T(this,Q),t)){if(t){let o=T(this,Q),i=(n=t==null?void 0:t.filter)!=null&&n.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Jn(t.filter.filter)}}:t;z(this,Q,us(i));let s;if(Gd(t)){let{filter:l,filterStruct:a=Jn(l)}=t.filter;if(a){let c=vs(T(this,Dt),a);s=T(this,Ae).filter(c)}else throw Error("filter must include filterStruct")}if(qd(t)&&(s=Tp(s!=null?s:T(this,Ae),t.sort,T(this,Dt))),this.openTreeNodes.length>0&&Ha(o,t)&&(T(this,Q).groupBy.length===0?this.openTreeNodes.length=0:console.log("adjust the openTReeNodes groupBy changed ",{originalGroupBy:o.groupBy,newGroupBy:i.groupBy})),Ud(t)){let[l,a]=Cp(s!=null?s:T(this,Ae),t.groupBy,T(this,Dt));this.groupMap=a,s=l,this.openTreeNodes.length>0&&(s=lc(this.openTreeNodes,T(this,Ae),T(this,Q).groupBy,T(this,Dt),this.groupMap,s))}this.processedData=s==null?void 0:s.map((l,a)=>{let c=l.slice();return c[0]=a,c[1]=a,c})}this.setRange(Ko(T(this,ve)),!0),this.emit("config",T(this,Q))}}get selectedRowsCount(){return T(this,Ss)}get size(){return T(this,Jo)}get range(){return T(this,ve)}set range(t){(t.from!==T(this,ve).from||t.to!==T(this,ve).to)&&this.setRange(t)}setRange(t,n=!1){z(this,ve,t),this.keys.reset(t),this.sendRowsToClient(n)}sendRowsToClient(t=!1){var s,l;let n=this.rangeChangeRowset==="delta"&&!t?_C(this.lastRangeServed,T(this,ve)):T(this,ve),o=(s=this.processedData)!=null?s:T(this,Ae),i=o.slice(n.from,n.to).map(a=>GC(a,this.keys,this.selectedRows));(l=this.clientCallback)==null||l.call(this,{clientViewportId:this.viewport,mode:"batch",rows:i,size:o.length,type:"viewport-update"}),this.lastRangeServed=T(this,ve)}get columns(){return T(this,Q).columns}set columns(t){let n=OC(this.config.columns,t);if(n.length>0){let o=NC(this.columnDescriptors,n,i=>i.name);console.log("columnsWithoutDescriptors",{columnsWithoutDescriptors:o})}this.config={...T(this,Q),columns:t}}get aggregations(){return T(this,Q).aggregations}set aggregations(t){var i;z(this,Q,{...T(this,Q),aggregations:t});let n=(i=this.processedData)!=null?i:T(this,Ae),o=T(this,Ae);yp(t,n,T(this,Q).groupBy,o,T(this,Dt),this.groupMap),this.setRange(Ko(T(this,ve)),!0),this.emit("config",T(this,Q))}get sort(){return T(this,Q).sort}set sort(t){console.log("set sort",{sort:t}),ht==null||ht(`sort ${JSON.stringify(t)}`),this.config={...T(this,Q),sort:t}}get filter(){return T(this,Q).filter}set filter(t){ht==null||ht(`filter ${JSON.stringify(t)}`),this.config={...T(this,Q),filter:t}}get groupBy(){return T(this,Q).groupBy}set groupBy(t){this.config={...T(this,Q),groupBy:t}}get title(){return T(this,Nr)}set title(t){z(this,Nr,t)}get _clientCallback(){return this.clientCallback}createLink({parentVpId:t,link:{fromColumn:n,toColumn:o}}){console.log("create link",{parentVpId:t,fromColumn:n,toColumn:o})}removeLink(){console.log("remove link")}findRow(t){let n=T(this,Ae)[t];if(n)return n;throw`no row found for key ${t}`}updateRow(t,n,o){let i=this.findRow(parseInt(t));console.log({row:i,colName:n,value:o})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}async menuRpcCall(t){return new Promise(n=>{let{type:o}=t;switch(o){case"VP_EDIT_CELL_RPC":{let{rowKey:i,field:s,value:l}=t;try{this.updateRow(i,s,l),n(void 0)}catch(a){n({error:String(a),type:"VP_EDIT_RPC_REJECT"})}}break;default:n(void 0)}})}};jo=new WeakMap,Dt=new WeakMap,Q=new WeakMap,Ae=new WeakMap,ve=new WeakMap,Ss=new WeakMap,Jo=new WeakMap,Nr=new WeakMap;import{EventEmitter as qC,isSelected as KC,jsonToDataSourceRows as jC,KeySet as JC,metadataKeys as QC,uuid as Rp}from"@vuu-ui/vuu-utils";var YC={columns:[],key:"",table:{module:"",table:""}},{DEPTH:Vr,IDX:Ip,IS_EXPANDED:XC,IS_LEAF:ZC,KEY:Op,SELECTED:Pp}=QC,Dp=(r,e)=>{let[t]=r,n=r.slice();return n[1]=e.keyFor(t),n},bn,ft,Ye,xn,vn,_t,Cs,Ts,wn,Fr,Lp=class extends qC{constructor({aggregations:t,data:n,filter:o,groupBy:i,sort:s,title:l,viewport:a}){super();this.status="initialising";this.expandedRows=new Set;this.visibleRows=[];ee(this,bn,[]);ee(this,ft,Er);ee(this,Ye,void 0);ee(this,xn,{filter:""});ee(this,vn,[]);ee(this,_t,{from:0,to:0});ee(this,Cs,0);ee(this,Ts,0);ee(this,wn,{sortDefs:[]});ee(this,Fr,void 0);this.keys=new JC(T(this,_t));if(!n)throw Error("JsonDataSource constructor called without data");[this.columnDescriptors,Ah(this,Ye)._]=jC(n),this.visibleRows=T(this,Ye).filter(c=>c[Vr]===0).map((c,u)=>[u,u].concat(c.slice(2))),this.viewport=a||Rp(),t&&z(this,bn,t),this.columnDescriptors&&z(this,ft,{...T(this,ft),columns:this.columnDescriptors.map(c=>c.name)}),o&&z(this,xn,o),i&&z(this,vn,i),s&&z(this,wn,s),z(this,Fr,l)}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:Rp())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var h;this.clientCallback=c,o&&z(this,bn,o),n&&z(this,ft,{...T(this,ft),columns:n}),a&&z(this,xn,a),l&&z(this,vn,l),i&&z(this,_t,i),s&&z(this,wn,s),this.status==="initialising"&&(this.viewport=t,this.status="subscribed",(h=this.clientCallback)==null||h.call(this,{aggregations:T(this,bn),type:"subscribed",clientViewportId:this.viewport,columns:T(this,ft).columns,filter:T(this,xn),groupBy:T(this,vn),range:T(this,_t),sort:T(this,wn),tableSchema:YC}),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}select(t){var o;let n=[];for(let i of T(this,Ye)){let{[Ip]:s,[Pp]:l}=i,a=l===1,c=KC(t,s);if(c!==a){let u=i.slice();u[Pp]=c?1:0,T(this,Ye)[s]=u,n.push(u)}}n.length>0&&((o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"update",type:"viewport-update",rows:n}))}openTreeNode(t){var i;this.expandedRows.add(t),this.visibleRows=Ap(T(this,Ye),this.expandedRows);let{from:n,to:o}=T(this,_t);(i=this.clientCallback)==null||i.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(n,o).map(s=>Dp(s,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}closeTreeNode(t,n=!1){if(this.expandedRows.delete(t),n)for(let o of this.expandedRows.keys())o.startsWith(t)&&this.expandedRows.delete(o);this.visibleRows=Ap(T(this,Ye),this.expandedRows),this.sendRowsToClient()}get config(){return T(this,ft)}get selectedRowsCount(){return T(this,Cs)}get size(){return T(this,Ts)}get range(){return T(this,_t)}set range(t){z(this,_t,t),this.keys.reset(t),requestAnimationFrame(()=>{this.sendRowsToClient()})}sendRowsToClient(){var o;let{from:t,to:n}=T(this,_t);(o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(t,n).map(i=>Dp(i,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}get columns(){return T(this,ft).columns}set columns(t){z(this,ft,{...T(this,ft),columns:t})}get aggregations(){return T(this,bn)}set aggregations(t){z(this,bn,t)}set data(t){console.log("set JsonDataSource data")}get sort(){return T(this,wn)}set sort(t){z(this,wn,t)}get filter(){return T(this,xn)}set filter(t){z(this,xn,t)}get groupBy(){return T(this,vn)}set groupBy(t){z(this,vn,t)}get title(){return T(this,Fr)}set title(t){z(this,Fr,t)}createLink({parentVpId:t,link:{fromColumn:n,toColumn:o}}){console.log("create link",{parentVpId:t,fromColumn:n,toColumn:o})}removeLink(){console.log("remove link")}async menuRpcCall(t){console.log("rmenuRpcCall",{rpcRequest:t})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}getChildRows(t){let n=T(this,Ye).find(o=>o[Op]===t);if(n){let{[Ip]:o,[Vr]:i}=n,s=o+1,l=[];do{let{[Vr]:a}=T(this,Ye)[s];if(a===i+1)l.push(T(this,Ye)[s]);else if(a<=i)break;s+=1}while(s<T(this,Ye).length);return l}else console.warn(`JsonDataSource getChildRows row not found for key ${t}`);return[]}getRowsAtDepth(t,n=!0){return(n?this.visibleRows:T(this,Ye)).filter(i=>i[Vr]===t)}};bn=new WeakMap,ft=new WeakMap,Ye=new WeakMap,xn=new WeakMap,vn=new WeakMap,_t=new WeakMap,Cs=new WeakMap,Ts=new WeakMap,wn=new WeakMap,Fr=new WeakMap;function Ap(r,e){let t=[],n={value:0};for(let o=0;o<r.length;o++){let i=r[o],{[Vr]:s,[Op]:l,[ZC]:a}=i,c=e.has(l);if(t.push(eT(i,n,c)),!a&&!c)do o+=1;while(o<r.length-1&&r[o+1][Vr]>s)}return t}var eT=(r,e,t)=>{let n=r.slice();return n[0]=e.value,n[1]=e.value,t&&(n[XC]=!0),e.value+=1,n};import{debounce as Np,EventEmitter as tT,itemsOrOrderChanged as nT,logger as rT,throttle as oT,uuid as iT}from"@vuu-ui/vuu-utils";var{info:Ue}=rT("RemoteDataSource"),$,ks,Br,tn,Qo,Hr,Yn,ac=class extends tT{constructor({bufferSize:t=100,aggregations:n,columns:o,filter:i,groupBy:s,sort:l,table:a,title:c,viewport:u,visualLink:h}){super();this.server=null;this.status="initialising";ee(this,$,Er);ee(this,ks,[]);ee(this,Br,"throttle");ee(this,tn,{from:0,to:0});ee(this,Qo,0);ee(this,Hr,0);ee(this,Yn,void 0);this.handleMessageFromServer=t=>{var n,o;if(t.type==="subscribed")this.status="subscribed",(n=this.clientCallback)==null||n.call(this,t);else if(t.type==="disabled")this.status="disabled";else if(t.type==="enabled")this.status="enabled";else{if(jd(t))return;t.type==="debounce-begin"?this.optimize="debounce":(t.type==="viewport-update"&&t.size!==void 0&&t.size!==T(this,Hr)&&(z(this,Hr,t.size),this.emit("resize",t.size)),this.configChangePending&&this.setConfigPending(),(o=this.clientCallback)==null||o.call(this,t),this.optimize==="debounce"&&this.revertDebounce())}};this.revertDebounce=Np(()=>{this.optimize="throttle"},100);this.rawRangeRequest=t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})};this.debounceRangeRequest=Np(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},50);this.throttleRangeRequest=oT(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},80);if(!a)throw Error("RemoteDataSource constructor called without table");this.bufferSize=t,this.table=a,this.viewport=u,z(this,$,{...T(this,$),aggregations:n||T(this,$).aggregations,columns:o||T(this,$).columns,filter:i||T(this,$).filter,groupBy:s||T(this,$).groupBy,sort:l||T(this,$).sort,visualLink:h||T(this,$).visualLink}),z(this,Yn,c),this.rangeRequest=this.throttleRangeRequest}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:iT())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var f;if(console.log("%csubscribe","color:red;font-weight:bold;"),this.clientCallback=c,(o||n||a||l||s)&&z(this,$,{...T(this,$),aggregations:o||T(this,$).aggregations,columns:n||T(this,$).columns,filter:a||T(this,$).filter,groupBy:l||T(this,$).groupBy,sort:s||T(this,$).sort}),i&&z(this,tn,i),this.status!=="initialising"&&this.status!=="unsubscribed")return;this.status="subscribing",this.viewport=t,this.server=await Ga();let{bufferSize:h}=this;(f=this.server)==null||f.subscribe({...T(this,$),bufferSize:h,viewport:t,table:this.table,range:T(this,tn),title:T(this,Yn)},this.handleMessageFromServer)}unsubscribe(){var t,n;console.log("%cunsubscribe","color:red;font-weight:bold;"),Ue==null||Ue(`unsubscribe #${this.viewport}`),this.viewport&&((t=this.server)==null||t.unsubscribe(this.viewport)),(n=this.server)==null||n.destroy(this.viewport),this.removeAllListeners(),this.status="unsubscribed",this.viewport=void 0}suspend(){var t;return Ue==null||Ue(`suspend #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status="suspended",(t=this.server)==null||t.send({type:"suspend",viewport:this.viewport})),this}resume(){var t;return Ue==null||Ue(`resume #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status==="disabled"||this.status==="disabling"?this.enable():this.status==="suspended"&&((t=this.server)==null||t.send({type:"resume",viewport:this.viewport}),this.status="subscribed")),this}disable(){var t;return Ue==null||Ue(`disable #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status="disabling",(t=this.server)==null||t.send({viewport:this.viewport,type:"disable"})),this}enable(){var t;return Ue==null||Ue(`enable #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status==="disabled"||this.status==="disabling")&&(this.status="enabling",(t=this.server)==null||t.send({viewport:this.viewport,type:"enable"})),this}select(t){var n;z(this,Qo,t.length),this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"select",selected:t}))}openTreeNode(t){var n;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"openTreeNode",key:t}))}closeTreeNode(t){var n;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"closeTreeNode",key:t}))}get optimize(){return T(this,Br)}set optimize(t){if(t!==T(this,Br)){switch(z(this,Br,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 T(this,Qo)}get size(){return T(this,Hr)}get range(){return T(this,tn)}set range(t){(t.from!==T(this,tn).from||t.to!==T(this,tn).to)&&(z(this,tn,t),this.rangeRequest(t))}get config(){return T(this,$)}set config(t){var n,o;if(cs(T(this,$),t)&&t){let i=(n=t==null?void 0:t.filter)!=null&&n.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Jn(t.filter.filter)}}:t;z(this,$,us(i)),T(this,$)&&this.viewport&&this.server&&t&&((o=this.server)==null||o.send({viewport:this.viewport,type:"config",config:T(this,$)})),this.emit("config",T(this,$))}}get columns(){return T(this,$).columns}set columns(t){if(z(this,$,{...T(this,$),columns:t}),this.viewport){let n={viewport:this.viewport,type:"setColumns",columns:t};this.server&&this.server.send(n)}this.emit("config",T(this,$))}get aggregations(){return T(this,$).aggregations}set aggregations(t){var n;z(this,$,{...T(this,$),aggregations:t}),this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"aggregate",aggregations:t})),this.emit("config",T(this,$))}get sort(){return T(this,$).sort}set sort(t){if(z(this,$,{...T(this,$),sort:t}),this.viewport){let n={viewport:this.viewport,type:"sort",sort:t};this.server&&this.server.send(n)}this.emit("config",T(this,$))}get filter(){return T(this,$).filter}set filter(t){if(z(this,$,{...T(this,$),filter:t}),this.viewport){let n={viewport:this.viewport,type:"filter",filter:t};this.server&&this.server.send(n)}this.emit("config",T(this,$))}get groupBy(){return T(this,$).groupBy}set groupBy(t){var n;if(nT(this.groupBy,t)){let o=T(this,ks).length>0;if(z(this,$,{...T(this,$),groupBy:t}),this.viewport){let i={viewport:this.viewport,type:"groupBy",groupBy:T(this,$).groupBy};this.server&&this.server.send(i)}!o&&t.length>0&&this.viewport&&((n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"batch",type:"viewport-update",size:0,rows:[]})),this.emit("config",T(this,$)),this.setConfigPending({groupBy:t})}}get title(){return T(this,Yn)}set title(t){var n;z(this,Yn,t),this.viewport&&t&&((n=this.server)==null||n.send({type:"setTitle",title:t,viewport:this.viewport}))}get visualLink(){return T(this,$).visualLink}set visualLink(t){var n,o;if(z(this,$,{...T(this,$),visualLink:t}),t){let{parentClientVpId:i,link:{fromColumn:s,toColumn:l}}=t;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"createLink",parentClientVpId:i,parentColumnName:l,childColumnName:s}))}else this.viewport&&((o=this.server)==null||o.send({type:"removeLink",viewport:this.viewport}));this.emit("config",T(this,$))}setConfigPending(t){let n=this.configChangePending;this.configChangePending=t,t!==void 0?this.emit("config",t,!1):this.emit("config",n,!0)}async menuRpcCall(t){var n;if(this.viewport)return(n=this.server)==null?void 0:n.rpcCall({vpId:this.viewport,...t})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}};$=new WeakMap,ks=new WeakMap,Br=new WeakMap,tn=new WeakMap,Qo=new WeakMap,Hr=new WeakMap,Yn=new WeakMap;import{useCallback as y4,useEffect as b4,useState as x4}from"react";import{useCallback as sT}from"react";var Vp={type:"RPC_CALL",service:"TypeAheadRpcHandler"};var cc=()=>sT(async e=>{let t=e.length===2?{method:"getUniqueFieldValues",params:e,...Vp}:{method:"getUniqueFieldValuesStartingWith",params:e,...Vp};return await rp(t)},[]);import{getRowRecord as I4,isGroupMenuItemDescriptor as P4,metadataKeys as lT}from"@vuu-ui/vuu-utils";import{useCallback as L4}from"react";var{KEY:A4}=lT;import{useCallback as V4,useEffect as F4,useState as B4}from"react";import{ExpandoInput as uT}from"@vuu-ui/vuu-ui-controls";import{jsx as Es}from"react/jsx-runtime";var hT=aT(function({InputProps:e={},className:t,column:n,onInputComplete:o,operator:i,suggestionProvider:s=cc,table:l,value:a},c){let[u,h]=Bp(a!=null?a:""),[f,d]=Bp([]),p=s(),m=Ms((x,S)=>o(S),[o]),y=Ms((x,S)=>{S.length===1?o(S[0]):S.length>1&&o(S)},[o]);Fp(()=>{},[n]),Fp(()=>{if(l){let x=u?[l,n.name,u]:[l,n.name];p(x).then(S=>{d(S)}).catch(S=>{console.error("Error getting suggsetions",S)})}},[l,n,u,p]);let g=Ms(x=>{let{value:S}=x.target;h(S)},[]),v=cT(()=>{if(i==="starts"||i==="ends"){let{inputProps:x,...S}=e;return{...S,inputProps:{...x,onKeyDown:b=>{var C;b.key==="Enter"&&u!==""?(b.stopPropagation(),b.preventDefault(),o(u)):(C=x==null?void 0:x.onKeyDown)==null||C.call(x,b)}}}}else return e},[e,o,i,u]);return Ms(()=>{switch(i){case"in":return Es(_o,{InputProps:v,className:t,initialHighlightedIndex:0,source:f,onInputChange:g,onSelectionChange:y,ref:c,selectionStrategy:"multiple",value:a});case"starts":return Es(_o,{InputProps:v,ListProps:{className:"vuuIllustrationsOnly",disabled:!0},allowFreeText:!0,className:t,initialHighlightedIndex:0,source:f,onInputChange:g,onSelectionChange:m,ref:c,value:a});case"ends":return Es(uT,{...v,className:t,value:u,ref:c,onChange:g});default:return Es(_o,{InputProps:v,className:t,initialHighlightedIndex:0,source:f,title:"value",onInputChange:g,onSelectionChange:m,ref:c,value:a})}},[i,v,t,f,g,y,c,a,m,u])()});import{isMultiValueFilter as d_,isSingleValueFilter as p_,isValidFilterClauseOp as m_}from"@vuu-ui/vuu-utils";import{useCallback as v_,useEffect as w_,useMemo as S_,useRef as C_,useState as T_}from"react";import{Button as W_}from"@salt-ds/core";import{jsx as U_,jsxs as G_}from"react/jsx-runtime";import{EditableLabel as A3}from"@vuu-ui/vuu-ui-controls";import{filterAsQuery as V3,isMultiClauseFilter as F3}from"@vuu-ui/vuu-utils";import H3 from"classnames";import{useCallback as W3,useRef as $3}from"react";import{PopupMenu as i3}from"@vuu-ui/vuu-popups";import{useMemo as l3}from"react";import c3 from"classnames";import{jsx as p3}from"react/jsx-runtime";import{extractFilterForColumn as x3,isAndFilter as v3,isCompleteFilter as w3,isInFilter as S3,isMultiClauseFilter as C3,isMultiValueFilter as T3,isOrFilter as k3,isSingleValueFilter as M3,partition as E3}from"@vuu-ui/vuu-utils";import{jsx as j3,jsxs as J3}from"react/jsx-runtime";import{dispatchMouseEvent as az,filterAsQuery as cz}from"@vuu-ui/vuu-utils";import{useCallback as pz,useEffect as mz,useMemo as gz,useRef as yz,useState as bz}from"react";import{useControlled as ez}from"@vuu-ui/vuu-ui-controls";import{useCallback as nz}from"react";import{jsx as jz,jsxs as Jz}from"react/jsx-runtime";import{createElement as Kz}from"react";import{Button as q5}from"@salt-ds/core";var Y=class{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){let o=[];return this.decompose(0,e,o,2),n.length&&n.decompose(0,n.length,o,3),this.decompose(t,this.length,o,1),dt.from(o,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let n=[];return this.decompose(e,t,n,0),dt.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),o=new er(this),i=new er(e);for(let s=t,l=t;;){if(o.next(s),i.next(s),s=0,o.lineBreak!=i.lineBreak||o.done!=i.done||o.value!=i.value)return!1;if(l+=o.value.length,o.done||l>=n)return!0}}iter(e=1){return new er(this,e)}iterRange(e,t=this.length){return new Ds(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let o=this.line(e).from;n=this.iterRange(o,Math.max(o,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ls(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Y.empty:e.length<=32?new ce(e):dt.from(ce.split(e,[]))}},ce=class extends Y{constructor(e,t=pT(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,o){for(let i=0;;i++){let s=this.text[i],l=o+s.length;if((t?n:l)>=e)return new hc(o,l,n,s);o=l+1,n++}}decompose(e,t,n,o){let i=e<=0&&t>=this.length?this:new ce(Hp(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(o&1){let s=n.pop(),l=Ps(i.text,s.text.slice(),0,i.length);if(l.length<=32)n.push(new ce(l,s.length+i.length));else{let a=l.length>>1;n.push(new ce(l.slice(0,a)),new ce(l.slice(a)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof ce))return super.replace(e,t,n);let o=Ps(this.text,Ps(n.text,Hp(this.text,0,e)),t),i=this.length+n.length-(t-e);return o.length<=32?new ce(o,i):dt.from(ce.split(o,[]),i)}sliceString(e,t=this.length,n=`
|
|
18
|
-
`){let o="";for(let i=0,s=0;i<=t&&s<this.text.length;s++){let l=this.text[s],a=i+l.length;i>e&&s&&(o+=n),e<a&&t>i&&(o+=l.slice(Math.max(0,e-i),t-i)),i=a+1}return o}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],o=-1;for(let i of e)n.push(i),o+=i.length+1,n.length==32&&(t.push(new ce(n,o)),n=[],o=-1);return o>-1&&t.push(new ce(n,o)),t}},dt=class extends Y{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,o){for(let i=0;;i++){let s=this.children[i],l=o+s.length,a=n+s.lines-1;if((t?a:l)>=e)return s.lineInner(e,t,n,o);o=l+1,n=a+1}}decompose(e,t,n,o){for(let i=0,s=0;s<=t&&i<this.children.length;i++){let l=this.children[i],a=s+l.length;if(e<=a&&t>=s){let c=o&((s<=e?1:0)|(a>=t?2:0));s>=e&&a<=t&&!c?n.push(l):l.decompose(e-s,t-s,n,c)}s=a+1}}replace(e,t,n){if(n.lines<this.lines)for(let o=0,i=0;o<this.children.length;o++){let s=this.children[o],l=i+s.length;if(e>=i&&t<=l){let a=s.replace(e-i,t-i,n),c=this.lines-s.lines+a.lines;if(a.lines<c>>5-1&&a.lines>c>>5+1){let u=this.children.slice();return u[o]=a,new dt(u,this.length-(t-e)+n.length)}return super.replace(i,l,a)}i=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
|
|
19
|
-
`){let o="";for(let i=0,s=0;i<this.children.length&&s<=t;i++){let l=this.children[i],a=s+l.length;s>e&&i&&(o+=n),e<a&&t>s&&(o+=l.sliceString(e-s,t-s,n)),s=a+1}return o}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof dt))return 0;let n=0,[o,i,s,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=t,i+=t){if(o==s||i==l)return n;let a=this.children[o],c=e.children[i];if(a!=c)return n+a.scanIdentical(c,t);n+=a.length+1}}static from(e,t=e.reduce((n,o)=>n+o.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new ce(d,t)}let o=Math.max(32,n>>5),i=o<<1,s=o>>1,l=[],a=0,c=-1,u=[];function h(d){let p;if(d.lines>i&&d instanceof dt)for(let m of d.children)h(m);else d.lines>s&&(a>s||!a)?(f(),l.push(d)):d instanceof ce&&a&&(p=u[u.length-1])instanceof ce&&d.lines+p.lines<=32?(a+=d.lines,c+=d.length+1,u[u.length-1]=new ce(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>o&&f(),a+=d.lines,c+=d.length+1,u.push(d))}function f(){a!=0&&(l.push(u.length==1?u[0]:dt.from(u,c)),c=-1,a=u.length=0)}for(let d of e)h(d);return f(),l.length==1?l[0]:new dt(l,t)}};Y.empty=new ce([""],0);function pT(r){let e=-1;for(let t of r)e+=t.length+1;return e}function Ps(r,e,t=0,n=1e9){for(let o=0,i=0,s=!0;i<r.length&&o<=n;i++){let l=r[i],a=o+l.length;a>=t&&(a>n&&(l=l.slice(0,n-o)),o<t&&(l=l.slice(t-o)),s?(e[e.length-1]+=l,s=!1):e.push(l)),o=a+1}return e}function Hp(r,e,t){return Ps(r,[""],e,t)}var er=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ce?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,o=this.nodes[n],i=this.offsets[n],s=i>>1,l=o instanceof ce?o.text.length:o.children.length;if(s==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
20
|
-
`,this;e--}else if(o instanceof ce){let a=o.text[s+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=o.children[s+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ce?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Ds=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new er(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*t,this.value=o.length<=n?o:t<0?o.slice(o.length-n):o.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Ls=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:o}=this.inner.next(e);return t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},er.prototype[Symbol.iterator]=Ds.prototype[Symbol.iterator]=Ls.prototype[Symbol.iterator]=function(){return this});var hc=class{constructor(e,t,n,o){this.from=e,this.to=t,this.number=n,this.text=o}get length(){return this.to-this.from}},_r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(r=>r?parseInt(r,36):1);for(let r=1;r<_r.length;r++)_r[r]+=_r[r-1];function mT(r){for(let e=1;e<_r.length;e+=2)if(_r[e]>r)return _r[e-1]<=r;return!1}function _p(r){return r>=127462&&r<=127487}var zp=8205;function Ve(r,e,t=!0,n=!0){return(t?Kp:gT)(r,e,n)}function Kp(r,e,t){if(e==r.length)return e;e&&jp(r.charCodeAt(e))&&Jp(r.charCodeAt(e-1))&&e--;let n=zt(r,e);for(e+=tr(n);e<r.length;){let o=zt(r,e);if(n==zp||o==zp||t&&mT(o))e+=tr(o),n=o;else if(_p(o)){let i=0,s=e-2;for(;s>=0&&_p(zt(r,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function gT(r,e,t){for(;e>0;){let n=Kp(r,e-2,t);if(n<e)return n;e--}return 0}function jp(r){return r>=56320&&r<57344}function Jp(r){return r>=55296&&r<56320}function zt(r,e){let t=r.charCodeAt(e);if(!Jp(t)||e+1==r.length)return t;let n=r.charCodeAt(e+1);return jp(n)?(t-55296<<10)+(n-56320)+65536:t}function Qp(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function tr(r){return r<65536?1:2}var fc=/\r\n?|\n/,Ne=function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r}(Ne||(Ne={})),et=class{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,o=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?(e(n,o,i),o+=i):o+=s,n+=i}}iterChangedRanges(e,t=!1){dc(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],o=this.sections[t++];o<0?e.push(n,o):e.push(o,n)}return new et(e)}composeDesc(e){return this.empty?e:e.empty?this:Yp(this,e)}mapDesc(e,t=!1){return e.empty?this:pc(this,e,t)}mapPos(e,t=-1,n=Ne.Simple){let o=0,i=0;for(let s=0;s<this.sections.length;){let l=this.sections[s++],a=this.sections[s++],c=o+l;if(a<0){if(c>e)return i+(e-o);i+=l}else{if(n!=Ne.Simple&&c>=e&&(n==Ne.TrackDel&&o<e&&c>e||n==Ne.TrackBefore&&o<e||n==Ne.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!l)return e==o||t<0?i:i+a;i+=a}o=c}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return i}touchesRange(e,t=e){for(let n=0,o=0;n<this.sections.length&&o<=t;){let i=this.sections[n++],s=this.sections[n++],l=o+i;if(s>=0&&o<=t&&l>=e)return o<e&&l>t?"cover":!0;o=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],o=this.sections[t++];e+=(e?" ":"")+n+(o>=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new et(e)}static create(e){return new et(e)}},ue=class extends et{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return dc(this,(t,n,o,i,s)=>e=e.replace(o,o+(n-t),s),!1),e}mapDesc(e,t=!1){return pc(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let o=0,i=0;o<t.length;o+=2){let s=t[o],l=t[o+1];if(l>=0){t[o]=l,t[o+1]=s;let a=o>>1;for(;n.length<a;)n.push(Y.empty);n.push(s?e.slice(i,i+s):Y.empty)}i+=s}return new ue(t,n)}compose(e){return this.empty?e:e.empty?this:Yp(this,e,!0)}map(e,t=!1){return e.empty?this:pc(this,e,t,!0)}iterChanges(e,t=!1){dc(this,e,t)}get desc(){return et.create(this.sections)}filter(e){let t=[],n=[],o=[],i=new nr(this);e:for(let s=0,l=0;;){let a=s==e.length?1e9:e[s++];for(;l<a||l==a&&i.len==0;){if(i.done)break e;let u=Math.min(i.len,a-l);Oe(o,u,-1);let h=i.ins==-1?-1:i.off==0?i.ins:0;Oe(t,u,h),h>0&&Sn(n,t,i.text),i.forward(u),l+=u}let c=e[s++];for(;l<c;){if(i.done)break e;let u=Math.min(i.len,c-l);Oe(t,u,-1),Oe(o,u,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(u),l+=u}}return{changes:new ue(t,n),filtered:et.create(o)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],o=this.sections[t+1];o<0?e.push(n):o==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let o=[],i=[],s=0,l=null;function a(u=!1){if(!u&&!o.length)return;s<t&&Oe(o,t-s,-1);let h=new ue(o,i);l=l?l.compose(h.map(l)):h,o=[],i=[],s=0}function c(u){if(Array.isArray(u))for(let h of u)c(h);else if(u instanceof ue){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);a(),l=l?l.compose(u.map(l)):u}else{let{from:h,to:f=h,insert:d}=u;if(h>f||h<0||f>t)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?Y.of(d.split(n||fc)):d:Y.empty,m=p.length;if(h==f&&m==0)return;h<s&&a(),h>s&&Oe(o,h-s,-1),Oe(o,f-h,m),Sn(i,o,p),s=f}}return c(e),a(!l),l}static empty(e){return new ue(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let o=0;o<e.length;o++){let i=e[o];if(typeof i=="number")t.push(i,-1);else{if(!Array.isArray(i)||typeof i[0]!="number"||i.some((s,l)=>l&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(i.length==1)t.push(i[0],0);else{for(;n.length<o;)n.push(Y.empty);n[o]=Y.of(i.slice(1)),t.push(i[0],n[o].length)}}}return new ue(t,n)}static createSet(e,t){return new ue(e,t)}};function Oe(r,e,t,n=!1){if(e==0&&t<=0)return;let o=r.length-2;o>=0&&t<=0&&t==r[o+1]?r[o]+=e:e==0&&r[o]==0?r[o+1]+=t:n?(r[o]+=e,r[o+1]+=t):r.push(e,t)}function Sn(r,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<r.length)r[r.length-1]=r[r.length-1].append(t);else{for(;r.length<n;)r.push(Y.empty);r.push(t)}}function dc(r,e,t){let n=r.inserted;for(let o=0,i=0,s=0;s<r.sections.length;){let l=r.sections[s++],a=r.sections[s++];if(a<0)o+=l,i+=l;else{let c=o,u=i,h=Y.empty;for(;c+=l,u+=a,a&&n&&(h=h.append(n[s-2>>1])),!(t||s==r.sections.length||r.sections[s+1]<0);)l=r.sections[s++],a=r.sections[s++];e(o,c,i,u,h),o=c,i=u}}}function pc(r,e,t,n=!1){let o=[],i=n?[]:null,s=new nr(r),l=new nr(e);for(let a=-1;;)if(s.ins==-1&&l.ins==-1){let c=Math.min(s.len,l.len);Oe(o,c,-1),s.forward(c),l.forward(c)}else if(l.ins>=0&&(s.ins<0||a==s.i||s.off==0&&(l.len<s.len||l.len==s.len&&!t))){let c=l.len;for(Oe(o,l.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&a<s.i&&s.len<=u&&(Oe(o,0,s.ins),i&&Sn(i,o,s.text),a=s.i),s.forward(u),c-=u}l.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(l.ins==-1){let h=Math.min(u,l.len);c+=h,u-=h,l.forward(h)}else if(l.ins==0&&l.len<u)u-=l.len,l.next();else break;Oe(o,c,a<s.i?s.ins:0),i&&a<s.i&&Sn(i,o,s.text),a=s.i,s.forward(s.len-u)}else{if(s.done&&l.done)return i?ue.createSet(o,i):et.create(o);throw new Error("Mismatched change set lengths")}}function Yp(r,e,t=!1){let n=[],o=t?[]:null,i=new nr(r),s=new nr(e);for(let l=!1;;){if(i.done&&s.done)return o?ue.createSet(n,o):et.create(n);if(i.ins==0)Oe(n,i.len,0,l),i.next();else if(s.len==0&&!s.done)Oe(n,0,s.ins,l),o&&Sn(o,n,s.text),s.next();else{if(i.done||s.done)throw new Error("Mismatched change set lengths");{let a=Math.min(i.len2,s.len),c=n.length;if(i.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;Oe(n,a,u,l),o&&u&&Sn(o,n,s.text)}else s.ins==-1?(Oe(n,i.off?0:i.len,a,l),o&&Sn(o,n,i.textBit(a))):(Oe(n,i.off?0:i.len,s.off?0:s.ins,l),o&&!s.off&&Sn(o,n,s.text));l=(i.ins>a||s.ins>=0&&s.len>a)&&(l||n.length>c),i.forward2(a),s.forward(a)}}}}var nr=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Y.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Y.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},nn=class{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let n,o;return this.empty?n=o=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),n==this.from&&o==this.to?this:new nn(n,o,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return D.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return D.range(this.anchor,n)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return D.range(e.anchor,e.head)}static create(e,t,n){return new nn(e,t,n)}},D=class{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:D.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new D([this.main],0)}addRange(e,t=!0){return D.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,D.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new D(e.ranges.map(t=>nn.fromJSON(t)),e.main)}static single(e,t=e){return new D([D.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,o=0;o<e.length;o++){let i=e[o];if(i.empty?i.from<=n:i.from<n)return D.normalized(e.slice(),t);n=i.to}return new D(e,t)}static cursor(e,t=0,n,o){return nn.create(e,e,(t==0?0:t<0?4:8)|(n==null?3:Math.min(2,n))|(o!=null?o:33554431)<<5)}static range(e,t,n,o){let i=(n!=null?n:33554431)<<5|(o==null?3:Math.min(2,o));return t<e?nn.create(t,e,24|i):nn.create(e,t,(t>e?4:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((o,i)=>o.from-i.from),t=e.indexOf(n);for(let o=1;o<e.length;o++){let i=e[o],s=e[o-1];if(i.empty?i.from<=s.to:i.from<s.to){let l=s.from,a=Math.max(i.to,s.to);o<=t&&t--,e.splice(--o,2,i.anchor>i.head?D.range(a,l):D.range(l,a))}}return new D(e,t)}};function Xp(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var wc=0,U=class{constructor(e,t,n,o,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=o,this.id=wc++,this.default=e([]),this.extensions=typeof i=="function"?i(this):i}static define(e={}){return new U(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:Sc),!!e.static,e.enables)}of(e){return new zr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new zr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new zr(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function Sc(r,e){return r==e||r.length==e.length&&r.every((t,n)=>t===e[n])}var zr=class{constructor(e,t,n,o){this.dependencies=e,this.facet=t,this.type=n,this.value=o,this.id=wc++}dynamicSlot(e){var t;let n=this.value,o=this.facet.compareInput,i=this.id,s=e[i]>>1,l=this.type==2,a=!1,c=!1,u=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?c=!0:((t=e[h.id])!==null&&t!==void 0?t:1)&1||u.push(e[h.id]);return{create(h){return h.values[s]=n(h),1},update(h,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||mc(h,u)){let d=n(h);if(l?!Wp(d,h.values[s],o):!o(d,h.values[s]))return h.values[s]=d,1}return 0},reconfigure:(h,f)=>{let d,p=f.config.address[i];if(p!=null){let m=Os(f,p);if(this.dependencies.every(y=>y instanceof U?f.facet(y)===h.facet(y):y instanceof qe?f.field(y,!1)==h.field(y,!1):!0)||(l?Wp(d=n(h),m,o):o(d=n(h),m)))return h.values[s]=m,0}else d=n(h);return h.values[s]=d,1}}}};function Wp(r,e,t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!t(r[n],e[n]))return!1;return!0}function mc(r,e){let t=!1;for(let n of e)Xo(r,n)&1&&(t=!0);return t}function yT(r,e,t){let n=t.map(a=>r[a.id]),o=t.map(a=>a.type),i=n.filter(a=>!(a&1)),s=r[e.id]>>1;function l(a){let c=[];for(let u=0;u<n.length;u++){let h=Os(a,n[u]);if(o[u]==2)for(let f of h)c.push(f);else c.push(h)}return e.combine(c)}return{create(a){for(let c of n)Xo(a,c);return a.values[s]=l(a),1},update(a,c){if(!mc(a,i))return 0;let u=l(a);return e.compare(u,a.values[s])?0:(a.values[s]=u,1)},reconfigure(a,c){let u=mc(a,n),h=c.config.facets[e.id],f=c.facet(e);if(h&&!u&&Sc(t,h))return a.values[s]=f,0;let d=l(a);return e.compare(d,f)?(a.values[s]=f,0):(a.values[s]=d,1)}}}var $p=U.define({static:!0}),qe=class{constructor(e,t,n,o,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=o,this.spec=i,this.provides=void 0}static define(e){let t=new qe(wc++,e.create,e.update,e.compare||((n,o)=>n===o),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet($p).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,o)=>{let i=n.values[t],s=this.updateF(i,o);return this.compareF(i,s)?0:(n.values[t]=s,1)},reconfigure:(n,o)=>o.config.address[this.id]!=null?(n.values[t]=o.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,$p.of({field:this,create:e})]}get extension(){return this}},Xn={lowest:4,low:3,default:2,high:1,highest:0};function Yo(r){return e=>new As(e,r)}var ir={highest:Yo(Xn.highest),high:Yo(Xn.high),default:Yo(Xn.default),low:Yo(Xn.low),lowest:Yo(Xn.lowest)},As=class{constructor(e,t){this.inner=e,this.prec=t}},$r=class{of(e){return new Zo(this,e)}reconfigure(e){return $r.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Zo=class{constructor(e,t){this.compartment=e,this.inner=t}},Ur=class{constructor(e,t,n,o,i,s){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=o,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let o=[],i=Object.create(null),s=new Map;for(let f of bT(e,t,s))f instanceof qe?o.push(f):(i[f.facet.id]||(i[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of o)l[f.id]=c.length<<1,c.push(d=>f.slot(d));let u=n==null?void 0:n.config.facets;for(let f in i){let d=i[f],p=d[0].facet,m=u&&u[f]||[];if(d.every(y=>y.type==0))if(l[p.id]=a.length<<1|1,Sc(m,d))a.push(n.facet(p));else{let y=p.combine(d.map(g=>g.value));a.push(n&&p.compare(y,n.facet(p))?n.facet(p):y)}else{for(let y of d)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=c.length<<1,c.push(g=>y.dynamicSlot(g)));l[p.id]=c.length<<1,c.push(y=>yT(y,p,d))}}let h=c.map(f=>f(l));return new Ur(e,s,h,l,a,i)}};function bT(r,e,t){let n=[[],[],[],[],[]],o=new Map;function i(s,l){let a=o.get(s);if(a!=null){if(a<=l)return;let c=n[a].indexOf(s);c>-1&&n[a].splice(c,1),s instanceof Zo&&t.delete(s.compartment)}if(o.set(s,l),Array.isArray(s))for(let c of s)i(c,l);else if(s instanceof Zo){if(t.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;t.set(s.compartment,c),i(c,l)}else if(s instanceof As)i(s.inner,s.prec);else if(s instanceof qe)n[l].push(s),s.provides&&i(s.provides,l);else if(s instanceof zr)n[l].push(s),s.facet.extensions&&i(s.facet.extensions,Xn.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);i(c,l)}}return i(r,Xn.default),n.reduce((s,l)=>s.concat(l))}function Xo(r,e){if(e&1)return 2;let t=e>>1,n=r.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;r.status[t]=4;let o=r.computeSlot(r,r.config.dynamicSlots[t]);return r.status[t]=2|o}function Os(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}var Zp=U.define(),em=U.define({combine:r=>r.some(e=>e),static:!0}),tm=U.define({combine:r=>r.length?r[0]:void 0,static:!0}),nm=U.define(),rm=U.define(),om=U.define(),im=U.define({combine:r=>r.length?r[0]:!1}),tt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Ns}},Ns=class{of(e){return new tt(this,e)}},gc=class{constructor(e){this.map=e}of(e){return new ie(this,e)}},ie=class{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new ie(this.type,t)}is(e){return this.type==e}static define(e={}){return new gc(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let o of e){let i=o.map(t);i&&n.push(i)}return n}};ie.reconfigure=ie.define();ie.appendConfig=ie.define();var he=class{constructor(e,t,n,o,i,s){this.startState=e,this.changes=t,this.selection=n,this.effects=o,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,n&&Xp(n,t.newLength),i.some(l=>l.type==he.time)||(this.annotations=i.concat(he.time.of(Date.now())))}static create(e,t,n,o,i,s){return new he(e,t,n,o,i,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(he.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};he.time=tt.define();he.userEvent=tt.define();he.addToHistory=tt.define();he.remote=tt.define();function xT(r,e){let t=[];for(let n=0,o=0;;){let i,s;if(n<r.length&&(o==e.length||e[o]>=r[n]))i=r[n++],s=r[n++];else if(o<e.length)i=e[o++],s=e[o++];else return t;!t.length||t[t.length-1]<i?t.push(i,s):t[t.length-1]<s&&(t[t.length-1]=s)}}function sm(r,e,t){var n;let o,i,s;return t?(o=e.changes,i=ue.empty(e.changes.length),s=r.changes.compose(e.changes)):(o=e.changes.map(r.changes),i=r.changes.mapDesc(e.changes,!0),s=r.changes.compose(o)),{changes:s,selection:e.selection?e.selection.map(i):(n=r.selection)===null||n===void 0?void 0:n.map(o),effects:ie.mapEffects(r.effects,o).concat(ie.mapEffects(e.effects,i)),annotations:r.annotations.length?r.annotations.concat(e.annotations):e.annotations,scrollIntoView:r.scrollIntoView||e.scrollIntoView}}function yc(r,e,t){let n=e.selection,o=Wr(e.annotations);return e.userEvent&&(o=o.concat(he.userEvent.of(e.userEvent))),{changes:e.changes instanceof ue?e.changes:ue.of(e.changes||[],t,r.facet(tm)),selection:n&&(n instanceof D?n:D.single(n.anchor,n.head)),effects:Wr(e.effects),annotations:o,scrollIntoView:!!e.scrollIntoView}}function lm(r,e,t){let n=yc(r,e.length?e[0]:{},r.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let i=1;i<e.length;i++){e[i].filter===!1&&(t=!1);let s=!!e[i].sequential;n=sm(n,yc(r,e[i],s?n.changes.newLength:r.doc.length),s)}let o=he.create(r,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return wT(t?vT(o):o)}function vT(r){let e=r.startState,t=!0;for(let o of e.facet(nm)){let i=o(r);if(i===!1){t=!1;break}Array.isArray(i)&&(t=t===!0?i:xT(t,i))}if(t!==!0){let o,i;if(t===!1)i=r.changes.invertedDesc,o=ue.empty(e.doc.length);else{let s=r.changes.filter(t);o=s.changes,i=s.filtered.mapDesc(s.changes).invertedDesc}r=he.create(e,o,r.selection&&r.selection.map(i),ie.mapEffects(r.effects,i),r.annotations,r.scrollIntoView)}let n=e.facet(rm);for(let o=n.length-1;o>=0;o--){let i=n[o](r);i instanceof he?r=i:Array.isArray(i)&&i.length==1&&i[0]instanceof he?r=i[0]:r=lm(e,Wr(i),!1)}return r}function wT(r){let e=r.startState,t=e.facet(om),n=r;for(let o=t.length-1;o>=0;o--){let i=t[o](r);i&&Object.keys(i).length&&(n=sm(n,yc(e,i,r.changes.newLength),!0))}return n==r?r:he.create(e,r.changes,r.selection,n.effects,n.annotations,n.scrollIntoView)}var ST=[];function Wr(r){return r==null?ST:Array.isArray(r)?r:[r]}var Ge=function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r}(Ge||(Ge={})),CT=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,bc;try{bc=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function TT(r){if(bc)return bc.test(r);for(let e=0;e<r.length;e++){let t=r[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||CT.test(t)))return!0}return!1}function kT(r){return e=>{if(!/\S/.test(e))return Ge.Space;if(TT(e))return Ge.Word;for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return Ge.Word;return Ge.Other}}var Z=class{constructor(e,t,n,o,i,s){this.config=e,this.doc=t,this.selection=n,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Xo(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Xo(this,n),Os(this,n)}update(...e){return lm(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:o}=t;for(let s of e.effects)s.is($r.reconfigure)?(t&&(o=new Map,t.compartments.forEach((l,a)=>o.set(a,l)),t=null),o.set(s.value.compartment,s.value.extension)):s.is(ie.reconfigure)?(t=null,n=s.value):s.is(ie.appendConfig)&&(t=null,n=Wr(n).concat(s.value));let i;t?i=e.startState.values.slice():(t=Ur.resolve(n,o,this),i=new Z(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values),new Z(t,e.newDoc,e.newSelection,i,(s,l)=>l.update(s,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:D.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),o=this.changes(n.changes),i=[n.range],s=Wr(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),c=this.changes(a.changes),u=c.map(o);for(let f=0;f<l;f++)i[f]=i[f].map(u);let h=o.mapDesc(c,!0);i.push(a.range.map(h)),o=o.compose(u),s=ie.mapEffects(s,u).concat(ie.mapEffects(Wr(a.effects),h))}return{changes:o,selection:D.create(i,t.mainIndex),effects:s}}changes(e=[]){return e instanceof ue?e:ue.of(e,this.doc.length,this.facet(Z.lineSeparator))}toText(e){return Y.of(e.split(this.facet(Z.lineSeparator)||fc))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Xo(this,t),Os(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let o=e[n];o instanceof qe&&this.config.address[o.id]!=null&&(t[n]=o.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let o=[];if(n){for(let i in n)if(Object.prototype.hasOwnProperty.call(e,i)){let s=n[i],l=e[i];o.push(s.init(a=>s.spec.fromJSON(l,a)))}}return Z.create({doc:e.doc,selection:D.fromJSON(e.selection),extensions:t.extensions?o.concat([t.extensions]):o})}static create(e={}){let t=Ur.resolve(e.extensions||[],new Map),n=e.doc instanceof Y?e.doc:Y.of((e.doc||"").split(t.staticFacet(Z.lineSeparator)||fc)),o=e.selection?e.selection instanceof D?e.selection:D.single(e.selection.anchor,e.selection.head):D.single(0);return Xp(o,n.length),t.staticFacet(em)||(o=o.asSingle()),new Z(t,n,o,t.dynamicSlots.map(()=>null),(i,s)=>s.create(i),null)}get tabSize(){return this.facet(Z.tabSize)}get lineBreak(){return this.facet(Z.lineSeparator)||`
|
|
21
|
-
`}get readOnly(){return this.facet(im)}phrase(e,...t){for(let n of this.facet(Z.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,o)=>{if(o=="$")return"$";let i=+(o||1);return!i||i>t.length?n:t[i-1]})),e}languageDataAt(e,t,n=-1){let o=[];for(let i of this.facet(Zp))for(let s of i(this,t,n))Object.prototype.hasOwnProperty.call(s,e)&&o.push(s[e]);return o}charCategorizer(e){return kT(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:o}=this.doc.lineAt(e),i=this.charCategorizer(e),s=e-n,l=e-n;for(;s>0;){let a=Ve(t,s,!1);if(i(t.slice(a,s))!=Ge.Word)break;s=a}for(;l<o;){let a=Ve(t,l);if(i(t.slice(l,a))!=Ge.Word)break;l=a}return s==l?null:D.range(s+n,l+n)}};Z.allowMultipleSelections=em;Z.tabSize=U.define({combine:r=>r.length?r[0]:4});Z.lineSeparator=tm;Z.readOnly=im;Z.phrases=U.define({compare(r,e){let t=Object.keys(r),n=Object.keys(e);return t.length==n.length&&t.every(o=>r[o]==e[o])}});Z.languageData=Zp;Z.changeFilter=nm;Z.transactionFilter=rm;Z.transactionExtender=om;$r.reconfigure=ie.define();function sr(r,e,t={}){let n={};for(let o of r)for(let i of Object.keys(o)){let s=o[i],l=n[i];if(l===void 0)n[i]=s;else if(!(l===s||s===void 0))if(Object.hasOwnProperty.call(t,i))n[i]=t[i](l,s);else throw new Error("Config merge conflict for field "+i)}for(let o in e)n[o]===void 0&&(n[o]=e[o]);return n}var Lt=class{eq(e){return this==e}range(e,t=e){return rr.create(e,t,this)}};Lt.prototype.startSide=Lt.prototype.endSide=0;Lt.prototype.point=!1;Lt.prototype.mapMode=Ne.TrackDel;var rr=class{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new rr(e,t,n)}};function xc(r,e){return r.from-e.from||r.value.startSide-e.value.startSide}var ei=class{constructor(e,t,n,o){this.from=e,this.to=t,this.value=n,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,o=0){let i=n?this.to:this.from;for(let s=o,l=i.length;;){if(s==l)return s;let a=s+l>>1,c=i[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==s)return c>=0?s:l;c>=0?l=a:s=a+1}}between(e,t,n,o){for(let i=this.findIndex(t,-1e9,!0),s=this.findIndex(n,1e9,!1,i);i<s;i++)if(o(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(e,t){let n=[],o=[],i=[],s=-1,l=-1;for(let a=0;a<this.value.length;a++){let c=this.value[a],u=this.from[a]+e,h=this.to[a]+e,f,d;if(u==h){let p=t.mapPos(u,c.startSide,c.mapMode);if(p==null||(f=d=p,c.startSide!=c.endSide&&(d=t.mapPos(u,c.endSide),d<f)))continue}else if(f=t.mapPos(u,c.startSide),d=t.mapPos(h,c.endSide),f>d||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(s<0&&(s=f),c.point&&(l=Math.max(l,d-f)),n.push(c),o.push(f-s),i.push(d-s))}return{mapped:n.length?new ei(o,i,n,l):null,pos:s}}},oe=class{constructor(e,t,n,o){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=o}static create(e,t,n,o){return new oe(e,t,n,o)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:o=0,filterTo:i=this.length}=e,s=e.filter;if(t.length==0&&!s)return this;if(n&&(t=t.slice().sort(xc)),this.isEmpty)return t.length?oe.of(t):this;let l=new Vs(this,null,-1).goto(0),a=0,c=[],u=new Wt;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let h=t[a++];u.addInner(h.from,h.to,h.value)||c.push(h)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!s||o>this.chunkEnd(l.chunkIndex)||i<this.chunkPos[l.chunkIndex])&&u.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!s||o>l.to||i<l.from||s(l.from,l.to,l.value))&&(u.addInner(l.from,l.to,l.value)||c.push(rr.create(l.from,l.to,l.value))),l.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?oe.empty:this.nextLayer.update({add:c,filter:s,filterFrom:o,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],o=-1;for(let s=0;s<this.chunk.length;s++){let l=this.chunkPos[s],a=this.chunk[s],c=e.touchesRange(l,l+a.length);if(c===!1)o=Math.max(o,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(c===!0){let{mapped:u,pos:h}=a.map(l,e);u&&(o=Math.max(o,u.maxPoint),t.push(u),n.push(h))}}let i=this.nextLayer.map(e);return t.length==0?i:new oe(n,t,i||oe.empty,o)}between(e,t,n){if(!this.isEmpty){for(let o=0;o<this.chunk.length;o++){let i=this.chunkPos[o],s=this.chunk[o];if(t>=i&&e<=i+s.length&&s.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return or.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return or.from(e).goto(t)}static compare(e,t,n,o,i=-1){let s=e.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=i),l=t.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=i),a=Up(s,l,n),c=new Zn(s,a,i),u=new Zn(l,a,i);n.iterGaps((h,f,d)=>Gp(c,h,u,f,d,o)),n.empty&&n.length==0&&Gp(c,0,u,0,0,o)}static eq(e,t,n=0,o){o==null&&(o=1e9-1);let i=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),s=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(i.length!=s.length)return!1;if(!i.length)return!0;let l=Up(i,s),a=new Zn(i,l,0).goto(n),c=new Zn(s,l,0).goto(n);for(;;){if(a.to!=c.to||!vc(a.active,c.active)||a.point&&(!c.point||!a.point.eq(c.point)))return!1;if(a.to>o)return!0;a.next(),c.next()}}static spans(e,t,n,o,i=-1){let s=new Zn(e,null,i).goto(t),l=t,a=s.openStart;for(;;){let c=Math.min(s.to,n);if(s.point){let u=s.activeForPoint(s.to),h=s.pointFrom<t?u.length+1:Math.min(u.length,a);o.point(l,c,s.point,u,h,s.pointRank),a=Math.min(s.openEnd(c),u.length)}else c>l&&(o.span(l,c,s.active,a),a=s.openEnd(c));if(s.to>n)return a+(s.point&&s.to>n?1:0);l=s.to,s.next()}}static of(e,t=!1){let n=new Wt;for(let o of e instanceof rr?[e]:t?MT(e):e)n.add(o.from,o.to,o.value);return n.finish()}};oe.empty=new oe([],[],null,-1);function MT(r){if(r.length>1)for(let e=r[0],t=1;t<r.length;t++){let n=r[t];if(xc(e,n)>0)return r.slice().sort(xc);e=n}return r}oe.empty.nextLayer=oe.empty;var Wt=class{finishChunk(e){this.chunks.push(new ei(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Wt)).add(e,t,n)}addInner(e,t,n){let o=e-this.lastTo||n.startSide-this.last.endSide;if(o<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(oe.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=oe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Up(r,e,t){let n=new Map;for(let i of r)for(let s=0;s<i.chunk.length;s++)i.chunk[s].maxPoint<=0&&n.set(i.chunk[s],i.chunkPos[s]);let o=new Set;for(let i of e)for(let s=0;s<i.chunk.length;s++){let l=n.get(i.chunk[s]);l!=null&&(t?t.mapPos(l):l)==i.chunkPos[s]&&!(t!=null&&t.touchesRange(l,l+i.chunk[s].length))&&o.add(i.chunk[s])}return o}var Vs=class{constructor(e,t,n,o=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=o}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let o=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(o)||this.layer.chunkEnd(this.chunkIndex)<e||o.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let o=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<o)&&this.setRangeIndex(o)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},or=class{constructor(e){this.heap=e}static from(e,t=null,n=-1){let o=[];for(let i=0;i<e.length;i++)for(let s=e[i];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&o.push(new Vs(s,t,n,i));return o.length==1?o[0]:new or(o)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)uc(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)uc(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),uc(this.heap,0)}}};function uc(r,e){for(let t=r[e];;){let n=(e<<1)+1;if(n>=r.length)break;let o=r[n];if(n+1<r.length&&o.compare(r[n+1])>=0&&(o=r[n+1],n++),t.compare(o)<0)break;r[n]=t,r[e]=o,e=n}}var Zn=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=or.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Rs(this.active,e),Rs(this.activeTo,e),Rs(this.activeRank,e),this.minActive=qp(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:o,rank:i}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=i;)t++;Is(this.active,t,n),Is(this.activeTo,t,o),Is(this.activeRank,t,i),e&&Is(e,t,this.cursor.from),this.minActive=qp(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),n&&Rs(n,o)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let i=this.cursor.value;if(!i.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=i,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=i.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let o=n.length-1;o>=0&&n[o]<e;o--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function Gp(r,e,t,n,o,i){r.goto(e),t.goto(n);let s=n+o,l=n,a=n-e;for(;;){let c=r.to+a-t.to||r.endSide-t.endSide,u=c<0?r.to+a:t.to,h=Math.min(u,s);if(r.point||t.point?r.point&&t.point&&(r.point==t.point||r.point.eq(t.point))&&vc(r.activeForPoint(r.to),t.activeForPoint(t.to))||i.comparePoint(l,h,r.point,t.point):h>l&&!vc(r.active,t.active)&&i.compareRange(l,h,r.active,t.active),u>s)break;l=u,c<=0&&r.next(),c>=0&&t.next()}}function vc(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!=e[t]&&!r[t].eq(e[t]))return!1;return!0}function Rs(r,e){for(let t=e,n=r.length-1;t<n;t++)r[t]=r[t+1];r.pop()}function Is(r,e,t){for(let n=r.length-1;n>=e;n--)r[n+1]=r[n];r[e]=t}function qp(r,e){let t=-1,n=1e9;for(let o=0;o<e.length;o++)(e[o]-n||r[o].endSide-r[t].endSide)<0&&(t=o,n=e[o]);return t}function lr(r,e,t=r.length){let n=0;for(let o=0;o<t;)r.charCodeAt(o)==9?(n+=e-n%e,o++):(n++,o=Ve(r,o));return n}function am(r,e,t,n){for(let o=0,i=0;;){if(i>=e)return o;if(o==r.length)break;i+=r.charCodeAt(o)==9?t-i%t:1,o=Ve(r,o)}return n===!0?-1:r.length}var Cc="\u037C",cm=typeof Symbol>"u"?"__"+Cc:Symbol.for(Cc),Tc=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),um=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},pt=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function o(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function i(s,l,a,c){let u=[],h=/^@(\w+)\b/.exec(s[0]),f=h&&h[1]=="keyframes";if(h&&l==null)return a.push(s[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))i(d.split(/,\s*/).map(m=>s.map(y=>m.replace(/&/,y))).reduce((m,y)=>m.concat(y)),p,a);else if(p&&typeof p=="object"){if(!h)throw new RangeError("The value of a property ("+d+") should be a primitive value.");i(o(d),p,u,f)}else p!=null&&u.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(u.length||f)&&a.push((n&&!h&&!c?s.map(n):s).join(", ")+" {"+u.join(" ")+"}")}for(let s in e)i(o(s),e[s],this.rules)}getRules(){return this.rules.join(`
|
|
22
|
-
`)}static newName(){let e=um[cm]||1;return um[cm]=e+1,Cc+e.toString(36)}static mount(e,t){(e[Tc]||new kc(e)).mount(Array.isArray(t)?t:[t])}},hm=new Map,kc=class{constructor(e){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let o=hm.get(t);if(o)return e.adoptedStyleSheets=[o.sheet,...e.adoptedStyleSheets],e[Tc]=o;this.sheet=new n.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],hm.set(t,this)}else{this.styleTag=t.createElement("style");let o=e.head||e;o.insertBefore(this.styleTag,o.firstChild)}this.modules=[],e[Tc]=this}mount(e){let t=this.sheet,n=0,o=0;for(let i=0;i<e.length;i++){let s=e[i],l=this.modules.indexOf(s);if(l<o&&l>-1&&(this.modules.splice(l,1),o--,l=-1),l==-1){if(this.modules.splice(o++,0,s),t)for(let a=0;a<s.rules.length;a++)t.insertRule(s.rules[a],n++)}else{for(;o<l;)n+=this.modules[o++].rules.length;n+=s.rules.length,o++}}if(!t){let i="";for(let s=0;s<this.modules.length;s++)i+=this.modules[s].getRules()+`
|
|
23
|
-
`;this.styleTag.textContent=i}}};var rn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Gr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ET=typeof navigator<"u"&&/Mac/.test(navigator.platform),RT=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(be=0;be<10;be++)rn[48+be]=rn[96+be]=String(be);var be;for(be=1;be<=24;be++)rn[be+111]="F"+be;var be;for(be=65;be<=90;be++)rn[be]=String.fromCharCode(be+32),Gr[be]=String.fromCharCode(be);var be;for(Fs in rn)Gr.hasOwnProperty(Fs)||(Gr[Fs]=rn[Fs]);var Fs;function fm(r){var e=ET&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||RT&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Gr:rn)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Qs(r){let e;return r.nodeType==11?e=r.getSelection?r:r.ownerDocument:e=r,e.getSelection()}function Dc(r,e){return e?r==e||r.contains(e.nodeType!=1?e.parentNode:e):!1}function IT(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Gs(r,e){if(!e.anchorNode)return!1;try{return Dc(r,e.anchorNode)}catch{return!1}}function si(r){return r.nodeType==3?cr(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function Ys(r,e,t,n){return t?dm(r,e,t,n,-1)||dm(r,e,t,n,1):!1}function Xs(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function dm(r,e,t,n,o){for(;;){if(r==t&&e==n)return!0;if(e==(o<0?0:kn(r))){if(r.nodeName=="DIV")return!1;let i=r.parentNode;if(!i||i.nodeType!=1)return!1;e=Xs(r)+(o<0?0:1),r=i}else if(r.nodeType==1){if(r=r.childNodes[e+(o<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;e=o<0?kn(r):0}else return!1}}function kn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function hu(r,e){let t=e?r.left:r.right;return{left:t,right:t,top:r.top,bottom:r.bottom}}function PT(r){return{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function DT(r,e,t,n,o,i,s,l){let a=r.ownerDocument,c=a.defaultView||window;for(let u=r,h=!1;u&&!h;)if(u.nodeType==1){let f,d=u==a.body;if(d)f=PT(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let y=u.getBoundingClientRect();f={left:y.left,right:y.left+u.clientWidth,top:y.top,bottom:y.top+u.clientHeight}}let p=0,m=0;if(o=="nearest")e.top<f.top?(m=-(f.top-e.top+s),t>0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+m+s)):e.bottom>f.bottom&&(m=e.bottom-f.bottom+s,t<0&&e.top-m<f.top&&(m=-(f.top+m-e.top+s)));else{let y=e.bottom-e.top,g=f.bottom-f.top;m=(o=="center"&&y<=g?e.top+y/2-g/2:o=="start"||o=="center"&&t<0?e.top-s:e.bottom-g+s)-f.top}if(n=="nearest"?e.left<f.left?(p=-(f.left-e.left+i),t>0&&e.right>f.right+p&&(p=e.right-f.right+p+i)):e.right>f.right&&(p=e.right-f.right+i,t<0&&e.left<f.left+p&&(p=-(f.left+p-e.left+i))):p=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==l?e.left-i:e.right-(f.right-f.left)+i)-f.left,p||m)if(d)c.scrollBy(p,m);else{let y=0,g=0;if(m){let v=u.scrollTop;u.scrollTop+=m,g=u.scrollTop-v}if(p){let v=u.scrollLeft;u.scrollLeft+=p,y=u.scrollLeft-v}e={left:e.left-y,top:e.top-g,right:e.right-y,bottom:e.bottom-g},y&&Math.abs(y-p)<1&&(n="nearest"),g&&Math.abs(g-m)<1&&(o="nearest")}if(d)break;u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function LT(r){let e=r.ownerDocument;for(let t=r.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var Lc=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?kn(t):0),n,Math.min(e.focusOffset,n?kn(n):0))}set(e,t,n,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=o}},qr=null;function qm(r){if(r.setActive)return r.setActive();if(qr)return r.focus(qr);let e=[];for(let t=r;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(r.focus(qr==null?{get preventScroll(){return qr={preventScroll:!0},!0}}:void 0),!qr){qr=!1;for(let t=0;t<e.length;){let n=e[t++],o=e[t++],i=e[t++];n.scrollTop!=o&&(n.scrollTop=o),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var pm;function cr(r,e,t=e){let n=pm||(pm=document.createRange());return n.setEnd(r,t),n.setStart(r,e),n}function Jr(r,e,t){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0},o=new KeyboardEvent("keydown",n);o.synthetic=!0,r.dispatchEvent(o);let i=new KeyboardEvent("keyup",n);return i.synthetic=!0,r.dispatchEvent(i),o.defaultPrevented||i.defaultPrevented}function AT(r){for(;r;){if(r&&(r.nodeType==9||r.nodeType==11&&r.host))return r;r=r.assignedSlot||r.parentNode}return null}function Km(r){for(;r.attributes.length;)r.removeAttributeNode(r.attributes[0])}function OT(r,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,kn(t));;)if(n){if(t.nodeType!=1)return!1;let o=t.childNodes[n-1];o.contentEditable=="false"?n--:(t=o,n=kn(t))}else{if(t==r)return!0;n=Xs(t),t=t.parentNode}}function jm(r){return r.scrollTop>Math.max(1,r.scrollHeight-r.clientHeight-4)}var Pe=class{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Pe(e.parentNode,Xs(e),t)}static after(e,t){return new Pe(e.parentNode,Xs(e)+1,t)}},fu=[],ne=class{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,o=null,i;for(let s of this.children){if(s.flags&7){if(!s.dom&&(i=o?o.nextSibling:n.firstChild)){let l=ne.get(i);(!l||!l.parent&&l.canReuseDOM(s))&&s.reuseDOM(i)}s.sync(e,t),s.flags&=-8}if(i=o?o.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&i!=s.dom&&(t.written=!0),s.dom.parentNode==n)for(;i&&i!=s.dom;)i=mm(i);else n.insertBefore(s.dom,i);o=s.dom}for(i=o?o.nextSibling:n.firstChild,i&&t&&t.node==n&&(t.written=!0);i;)i=mm(i)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let o=kn(e)==0?0:t==0?-1:1;for(;;){let i=e.parentNode;if(i==this.dom)break;o==0&&i.firstChild!=i.lastChild&&(e==i.firstChild?o=-1:o=1),e=i}o<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!ne.get(n);)n=n.nextSibling;if(!n)return this.length;for(let o=0,i=0;;o++){let s=this.children[o];if(s.dom==n)return i;i+=s.length+s.breakAfter}}domBoundsAround(e,t,n=0){let o=-1,i=-1,s=-1,l=-1;for(let a=0,c=n,u=n;a<this.children.length;a++){let h=this.children[a],f=c+h.length;if(c<e&&f>t)return h.domBoundsAround(e,t,c);if(f>=e&&o==-1&&(o=a,i=c),c>t&&h.dom.parentNode==this.dom){s=a,l=u;break}u=f,c=f+h.breakAfter}return{from:i,to:l<0?n+this.length:l,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=fu){this.markDirty();for(let o=e;o<t;o++){let i=this.children[o];i.parent==this&&i.destroy()}this.children.splice(e,t-e,...n);for(let o=0;o<n.length;o++)n[o].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Zs(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,o,i,s){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){this.parent=null}};ne.prototype.breakAfter=0;function mm(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}var Zs=class{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function Jm(r,e,t,n,o,i,s,l,a){let{children:c}=r,u=c.length?c[e]:null,h=i.length?i[i.length-1]:null,f=h?h.breakAfter:s;if(!(e==n&&u&&!s&&!f&&i.length<2&&u.merge(t,o,i.length?h:null,t==0,l,a))){if(n<c.length){let d=c[n];d&&o<d.length?(e==n&&(d=d.split(o),o=0),!f&&h&&d.merge(0,o,h,!0,0,a)?i[i.length-1]=d:(o&&d.merge(0,o,null,!1,0,a),i.push(d))):d!=null&&d.breakAfter&&(h?h.breakAfter=1:s=1),n++}for(u&&(u.breakAfter=s,t>0&&(!s&&i.length&&u.merge(t,u.length,i[0],!1,l,0)?u.breakAfter=i.shift().breakAfter:(t<u.length||u.children.length&&u.children[u.children.length-1].length==0)&&u.merge(t,u.length,null,!1,l,0),e++));e<n&&i.length;)if(c[n-1].become(i[i.length-1]))n--,i.pop(),a=i.length?0:l;else if(c[e].become(i[0]))e++,i.shift(),l=i.length?0:a;else break;!i.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,l,a)&&e--,(e<n||i.length)&&r.replaceChildren(e,n,i)}}function Qm(r,e,t,n,o,i){let s=r.childCursor(),{i:l,off:a}=s.findPos(t,1),{i:c,off:u}=s.findPos(e,-1),h=e-t;for(let f of n)h+=f.length;r.length+=h,Jm(r,c,u,l,a,n,0,o,i)}var Kr="\uFFFF",el=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(Z.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Kr}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let o=e;;){this.findPointBefore(n,o);let i=this.text.length;this.readNode(o);let s=o.nextSibling;if(s==t)break;let l=ne.get(o),a=ne.get(s);(l&&a?l.breakAfter:(l?l.breakAfter:gm(o))||gm(s)&&(o.nodeName!="BR"||o.cmIgnore)&&this.text.length>i)&&this.lineBreak(),o=s}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,s=1,l;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(l=o.exec(t))&&(i=l.index,s=l[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),s>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=s-1);n=i+s}}readNode(e){if(e.cmIgnore)return;let t=ne.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let o=n.iter();!o.next().done;)o.lineBreak?this.lineBreak():this.append(o.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+Math.min(t,n.offset))}};function gm(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}var tl=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},nt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ac=typeof document<"u"?document:{documentElement:{style:{}}},Oc=/Edge\/(\d+)/.exec(nt.userAgent),Ym=/MSIE \d/.test(nt.userAgent),Nc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nt.userAgent),ll=!!(Ym||Nc||Oc),ym=!ll&&/gecko\/(\d+)/i.test(nt.userAgent),Mc=!ll&&/Chrome\/(\d+)/.exec(nt.userAgent),bm="webkitFontSmoothing"in Ac.documentElement.style,Xm=!ll&&/Apple Computer/.test(nt.vendor),xm=Xm&&(/Mobile\/\w+/.test(nt.userAgent)||nt.maxTouchPoints>2),H={mac:xm||/Mac/.test(nt.platform),windows:/Win/.test(nt.platform),linux:/Linux|X11/.test(nt.platform),ie:ll,ie_version:Ym?Ac.documentMode||6:Nc?+Nc[1]:Oc?+Oc[1]:0,gecko:ym,gecko_version:ym?+(/Firefox\/(\d+)/.exec(nt.userAgent)||[0,0])[1]:0,chrome:!!Mc,chrome_version:Mc?+Mc[1]:0,ios:xm,android:/Android\b/.test(nt.userAgent),webkit:bm,safari:Xm,webkit_version:bm?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Ac.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},NT=256,gt=class extends ne{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof gt)||this.length-(t-e)+n.length>NT||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new gt(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Pe(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return VT(this.dom,e,t)}},At=class extends ne{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let o of t)o.setParent(this)}setAttrs(e){if(Km(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,o,i,s){return n&&(!(n instanceof At&&n.mark.eq(this.mark))||e&&i<=0||t<this.length&&s<=0)?!1:(Qm(this,e,t,n?n.children:[],i-1,s-1),this.markDirty(),!0)}split(e){let t=[],n=0,o=-1,i=0;for(let l of this.children){let a=n+l.length;a>e&&t.push(n<e?l.split(e-n):l),o<0&&n>=e&&(o=i),n=a,i++}let s=this.length-e;return this.length=e,o>-1&&(this.children.length=o,this.markDirty()),new At(this.mark,t,s)}domAtPos(e){return Zm(this,e)}coordsAt(e,t){return tg(this,e,t)}};function VT(r,e,t){let n=r.nodeValue.length;e>n&&(e=n);let o=e,i=e,s=0;e==0&&t<0||e==n&&t>=0?H.chrome||H.gecko||(e?(o--,s=1):i<n&&(i++,s=-1)):t<0?o--:i<n&&i++;let l=cr(r,o,i).getClientRects();if(!l.length)return null;let a=l[(s?s<0:t>=0)?0:l.length-1];return H.safari&&!s&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),s?hu(a,s<0):a||null}var on=class extends ne{constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}static create(e,t,n){return new on(e,t,n)}split(e){let t=on.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,n,o,i,s){return n&&(!(n instanceof on)||!this.widget.compare(n.widget)||e>0&&i<=0||t<this.length&&s<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof on&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Y.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,o=this.posAtStart;return n?n.slice(o,o+this.length):Y.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Pe.before(this.dom):Pe.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let o=this.dom.getClientRects(),i=null;if(!o.length)return null;let s=this.side?this.side<0:e>0;for(let l=s?o.length-1:0;i=o[l],!(e>0?l==0:l==o.length-1||i.top<i.bottom);l+=s?-1:1);return hu(i,!s)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},Mn=class extends ne{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Mn&&e.side==this.side}split(){return new Mn(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Pe.before(this.dom):Pe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Y.empty}get isHidden(){return!0}};gt.prototype.children=on.prototype.children=Mn.prototype.children=fu;function Zm(r,e){let t=r.dom,{children:n}=r,o=0;for(let i=0;o<n.length;o++){let s=n[o],l=i+s.length;if(!(l==i&&s.getSide()<=0)){if(e>i&&e<l&&s.dom.parentNode==t)return s.domAtPos(e-i);if(e<=i)break;i=l}}for(let i=o;i>0;i--){let s=n[i-1];if(s.dom.parentNode==t)return s.domAtPos(s.length)}for(let i=o;i<n.length;i++){let s=n[i];if(s.dom.parentNode==t)return s.domAtPos(0)}return new Pe(t,0)}function eg(r,e,t){let n,{children:o}=r;t>0&&e instanceof At&&o.length&&(n=o[o.length-1])instanceof At&&n.mark.eq(e.mark)?eg(n,e.children[0],t-1):(o.push(e),e.setParent(r)),r.length+=e.length}function tg(r,e,t){let n=null,o=-1,i=null,s=-1;function l(c,u){for(let h=0,f=0;h<c.children.length&&f<=u;h++){let d=c.children[h],p=f+d.length;p>=u&&(d.children.length?l(d,u-f):(!i||i.isHidden&&t>0)&&(p>u||f==p&&d.getSide()>0)?(i=d,s=u-f):(f<u||f==p&&d.getSide()<0&&!d.isHidden)&&(n=d,o=u-f)),f=p}}l(r,e);let a=(t<0?n:i)||n||i;return a?a.coordsAt(Math.max(0,a==n?o:s),t):FT(r)}function FT(r){let e=r.dom.lastChild;if(!e)return r.dom.getBoundingClientRect();let t=si(e);return t[t.length-1]||null}function Vc(r,e){for(let t in r)t=="class"&&e.class?e.class+=" "+r.class:t=="style"&&e.style?e.style+=";"+r.style:e[t]=r[t];return e}var vm=Object.create(null);function du(r,e,t){if(r==e)return!0;r||(r=vm),e||(e=vm);let n=Object.keys(r),o=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=o.length-(t&&o.indexOf(t)>-1?1:0))return!1;for(let i of n)if(i!=t&&(o.indexOf(i)==-1||r[i]!==e[i]))return!1;return!0}function Fc(r,e,t){let n=null;if(e)for(let o in e)t&&o in t||r.removeAttribute(n=o);if(t)for(let o in t)e&&e[o]==t[o]||r.setAttribute(n=o,t[o]);return!!n}function BT(r){let e=Object.create(null);for(let t=0;t<r.attributes.length;t++){let n=r.attributes[t];e[n.name]=n.value}return e}var ln=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}destroy(e){}},me=function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r}(me||(me={})),Se=class extends Lt{constructor(e,t,n,o){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=o}get heightRelevant(){return!1}static mark(e){return new ur(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Gt(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,o;if(e.isBlockGap)n=-5e8,o=4e8;else{let{start:i,end:s}=ng(e,t);n=(i?t?-3e8:-1:5e8)-1,o=(s?t?2e8:1:-6e8)+1}return new Gt(e,n,o,t,e.widget||null,!0)}static line(e){return new hr(e)}static set(e,t=!1){return oe.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Se.none=oe.empty;var ur=class extends Se{constructor(e){let{start:t,end:n}=ng(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof ur&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&du(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};ur.prototype.point=!1;var hr=class extends Se{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof hr&&this.spec.class==e.spec.class&&du(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};hr.prototype.mapMode=Ne.TrackBefore;hr.prototype.point=!0;var Gt=class extends Se{constructor(e,t,n,o,i,s){super(t,n,i,e),this.block=o,this.isReplace=s,this.mapMode=o?t<=0?Ne.TrackBefore:Ne.TrackAfter:Ne.TrackDel}get type(){return this.startSide<this.endSide?me.WidgetRange:this.startSide<=0?me.WidgetBefore:me.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Gt&&HT(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Gt.prototype.point=!0;function ng(r,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=r;return t==null&&(t=r.inclusive),n==null&&(n=r.inclusive),{start:t!=null?t:e,end:n!=null?n:e}}function HT(r,e){return r==e||!!(r&&e&&r.compare(e))}function Bc(r,e,t,n=0){let o=t.length-1;o>=0&&t[o]+n>=r?t[o]=Math.max(t[o],e):t.push(r,e)}var Ie=class extends ne{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,o,i,s){if(n){if(!(n instanceof Ie))return!1;this.dom||n.transferDOM(this)}return o&&this.setDeco(n?n.attrs:null),Qm(this,e,t,n?n.children:[],i,s),!0}split(e){let t=new Ie;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:o}=this.childPos(e);o&&(t.append(this.children[n].split(o),0),this.children[n].merge(o,this.children[n].length,null,!1,0,0),n++);for(let i=n;i<this.children.length;i++)t.append(this.children[i],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){du(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){eg(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Vc(t,this.attrs||{})),n&&(this.attrs=Vc({class:n},this.attrs||{}))}domAtPos(e){return Zm(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Km(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Fc(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let o=this.dom.lastChild;for(;o&&ne.get(o)instanceof At;)o=o.lastChild;if(!o||!this.length||o.nodeName!="BR"&&((n=ne.get(o))===null||n===void 0?void 0:n.isEditable)==!1&&(!H.ios||!this.children.some(i=>i instanceof gt))){let i=document.createElement("BR");i.cmIgnore=!0,this.dom.appendChild(i)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof gt)||/[^ -~]/.test(n.text))return null;let o=si(n.dom);if(o.length!=1)return null;e+=o[0].width,t=o[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=tg(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:o}=this.parent.view.viewState,i=n.bottom-n.top;if(Math.abs(i-o.lineHeight)<2&&o.textHeight<i){let s=(i-o.textHeight)/2;return{top:n.top+s,bottom:n.bottom-s,left:n.left,right:n.left}}}return n}become(e){return!1}get type(){return me.Text}static find(e,t){for(let n=0,o=0;n<e.children.length;n++){let i=e.children[n],s=o+i.length;if(s>=t){if(i instanceof Ie)return i;if(s>t)break}o=s+i.breakAfter}return null}},sn=class extends ne{constructor(e,t,n){super(),this.widget=e,this.length=t,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,o,i,s){return n&&(!(n instanceof sn)||!this.widget.compare(n.widget)||e>0&&i<=0||t<this.length&&s<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Pe.before(this.dom):Pe.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new sn(this.widget,t,this.type);return n.breakAfter=this.breakAfter,n}get children(){return fu}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Y.empty}domBoundsAround(){return null}become(e){return e instanceof sn&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.type=e.type,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},ar=class{constructor(e,t,n,o){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!e.breakAfter&&!(e instanceof sn&&e.type==me.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ie),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Bs(new Mn(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(s){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=i,this.textOff=0}let o=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Bs(new gt(this.text.slice(this.textOff,this.textOff+o)),t),n),this.atCursorPos=!0,this.textOff+=o,e-=o,n=0}}span(e,t,n,o){this.buildText(t-e,n,o),this.pos=t,this.openStart<0&&(this.openStart=o)}point(e,t,n,o,i,s){if(this.disallowBlockEffectsFor[s]&&n instanceof Gt){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(n instanceof Gt)if(n.block){let{type:a}=n;a==me.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new sn(n.widget||new nl("div"),l,a))}else{let a=on.create(n.widget||new nl("span"),l,l?0:n.startSide),c=this.atCursorPos&&!a.isEditable&&i<=o.length&&(e<t||n.startSide>0),u=!a.isEditable&&(e<t||i>o.length||n.startSide<=0),h=this.getLine();this.pendingBuffer==2&&!c&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(o),c&&(h.append(Bs(new Mn(1),o),i),i=o.length+Math.max(0,i-o.length)),h.append(Bs(a,o),i),this.atCursorPos=u,this.pendingBuffer=u?e<t||i>o.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=i)}static build(e,t,n,o,i){let s=new ar(e,t,n,i);return s.openEnd=oe.spans(o,t,n,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}};function Bs(r,e){for(let t of e)r=new At(t,[r],r.length);return r}var nl=class extends ln{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}},rg=U.define(),og=U.define(),ig=U.define(),sg=U.define(),Hc=U.define(),lg=U.define(),ag=U.define(),cg=U.define({combine:r=>r.some(e=>e)}),ug=U.define({combine:r=>r.some(e=>e)}),Qr=class{constructor(e,t="nearest",n="nearest",o=5,i=5){this.range=e,this.y=t,this.x=n,this.yMargin=o,this.xMargin=i}map(e){return e.empty?this:new Qr(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}},wm=ie.define({map:(r,e)=>r.map(e)});function Ut(r,e,t){let n=r.facet(sg);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var al=U.define({combine:r=>r.length?r[0]:!0}),_T=0,ti=U.define(),yt=class{constructor(e,t,n,o){this.id=e,this.create=t,this.domEventHandlers=n,this.extension=o(this)}static define(e,t){let{eventHandlers:n,provide:o,decorations:i}=t||{};return new yt(_T++,e,n,s=>{let l=[ti.of(s)];return i&&l.push(li.of(a=>{let c=a.plugin(s);return c?i(c):Se.none})),o&&l.push(o(s)),l})}static fromClass(e,t){return yt.define(n=>new e(n),t)}},oi=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Ut(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ut(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Ut(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},hg=U.define(),pu=U.define(),li=U.define(),mu=U.define(),fg=U.define();function dg(r){let e=0,t=0,n=0,o=0;for(let i of r.state.facet(fg)){let s=i(r);s&&(s.left!=null&&(e=Math.max(e,s.left)),s.right!=null&&(t=Math.max(t,s.right)),s.top!=null&&(n=Math.max(n,s.top)),s.bottom!=null&&(o=Math.max(o,s.bottom)))}return{left:e,right:t,top:n,bottom:o}}var ni=U.define(),Xe=class{constructor(e,t,n,o){this.fromA=e,this.toA=t,this.fromB=n,this.toB=o}join(e){return new Xe(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let o=e[t-1];if(!(o.fromA>n.toA)){if(o.toA<n.fromA)break;n=n.join(o),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let o=0,i=0,s=0,l=0;;o++){let a=o==e.length?null:e[o],c=s-l,u=a?a.fromB:1e9;for(;i<t.length&&t[i]<u;){let h=t[i],f=t[i+1],d=Math.max(l,h),p=Math.min(u,f);if(d<=p&&new Xe(d+c,p+c,d,p).addToSet(n),f>u)break;i+=2}if(!a)return n;new Xe(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),s=a.toA,l=a.toB}}},Yr=class{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=ue.empty(this.startState.doc.length);for(let i of n)this.changes=this.changes.compose(i.changes);let o=[];this.changes.iterChangedRanges((i,s,l,a)=>o.push(new Xe(i,s,l,a))),this.changedRanges=o}static create(e,t,n){return new Yr(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},pe=function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r}(pe||(pe={})),_c=pe.LTR,zT=pe.RTL;function pg(r){let e=[];for(let t=0;t<r.length;t++)e.push(1<<+r[t]);return e}var WT=pg("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),$T=pg("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),zc=Object.create(null),$t=[];for(let r of["()","[]","{}"]){let e=r.charCodeAt(0),t=r.charCodeAt(1);zc[e]=t,zc[t]=-e}function UT(r){return r<=247?WT[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?$T[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:r==8204?256:1}var GT=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Tn=class{constructor(e,t,n){this.from=e,this.to=t,this.level=n}get dir(){return this.level%2?zT:_c}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,n,o){let i=-1;for(let s=0;s<e.length;s++){let l=e[s];if(l.from<=t&&l.to>=t){if(l.level==n)return s;(i<0||(o!=0?o<0?l.from<t:l.to>t:e[i].level>l.level))&&(i=s)}}if(i<0)throw new RangeError("Index out of range");return i}},fe=[];function qT(r,e){let t=r.length,n=e==_c?1:2,o=e==_c?2:1;if(!r||n==1&&!GT.test(r))return mg(t);for(let s=0,l=n,a=n;s<t;s++){let c=UT(r.charCodeAt(s));c==512?c=l:c==8&&a==4&&(c=16),fe[s]=c==4?2:c,c&7&&(a=c),l=c}for(let s=0,l=n,a=n;s<t;s++){let c=fe[s];if(c==128)s<t-1&&l==fe[s+1]&&l&24?c=fe[s]=l:fe[s]=256;else if(c==64){let u=s+1;for(;u<t&&fe[u]==64;)u++;let h=s&&l==8||u<t&&fe[u]==8?a==1?1:8:256;for(let f=s;f<u;f++)fe[f]=h;s=u-1}else c==8&&a==1&&(fe[s]=1);l=c,c&7&&(a=c)}for(let s=0,l=0,a=0,c,u,h;s<t;s++)if(u=zc[c=r.charCodeAt(s)])if(u<0){for(let f=l-3;f>=0;f-=3)if($t[f+1]==-u){let d=$t[f+2],p=d&2?n:d&4?d&1?o:n:0;p&&(fe[s]=fe[$t[f]]=p),l=f;break}}else{if($t.length==189)break;$t[l++]=s,$t[l++]=c,$t[l++]=a}else if((h=fe[s])==2||h==1){let f=h==n;a=f?0:1;for(let d=l-3;d>=0;d-=3){let p=$t[d+2];if(p&2)break;if(f)$t[d+2]|=2;else{if(p&4)break;$t[d+2]|=4}}}for(let s=0;s<t;s++)if(fe[s]==256){let l=s+1;for(;l<t&&fe[l]==256;)l++;let a=(s?fe[s-1]:n)==1,c=(l<t?fe[l]:n)==1,u=a==c?a?1:2:n;for(let h=s;h<l;h++)fe[h]=u;s=l-1}let i=[];if(n==1)for(let s=0;s<t;){let l=s,a=fe[s++]!=1;for(;s<t&&a==(fe[s]!=1);)s++;if(a)for(let c=s;c>l;){let u=c,h=fe[--c]!=2;for(;c>l&&h==(fe[c-1]!=2);)c--;i.push(new Tn(c,u,h?2:1))}else i.push(new Tn(l,s,0))}else for(let s=0;s<t;){let l=s,a=fe[s++]==2;for(;s<t&&a==(fe[s]==2);)s++;i.push(new Tn(l,s,a?1:2))}return i}function mg(r){return[new Tn(0,r,0)]}var gg="";function KT(r,e,t,n,o){var i;let s=n.head-r.from,l=-1;if(s==0){if(!o||!r.length)return null;e[0].level!=t&&(s=e[0].side(!1,t),l=0)}else if(s==r.length){if(o)return null;let f=e[e.length-1];f.level!=t&&(s=f.side(!0,t),l=e.length-1)}l<0&&(l=Tn.find(e,s,(i=n.bidiLevel)!==null&&i!==void 0?i:-1,n.assoc));let a=e[l];s==a.side(o,t)&&(a=e[l+=o?1:-1],s=a.side(!o,t));let c=o==(a.dir==t),u=Ve(r.text,s,c);if(gg=r.text.slice(Math.min(s,u),Math.max(s,u)),u!=a.side(o,t))return D.cursor(u+r.from,c?-1:1,a.level);let h=l==(o?e.length-1:0)?null:e[l+(o?1:-1)];return!h&&a.level!=t?D.cursor(o?r.to:r.from,o?-1:1,t):h&&h.level<a.level?D.cursor(h.side(!o,t)+r.from,o?1:-1,h.level):D.cursor(u+r.from,o?-1:1,a.level)}var rl=class extends ne{constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ie],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Xe(0,0,0,e.state.doc.length)],0,null)}get length(){return this.view.state.doc.length}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:l,toA:a})=>a<this.minWidthFrom||l>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=this.view.inputState.composing<0?null:JT(this.view,e.changes);if(this.hasComposition){this.markedForComposition.clear();let{from:l,to:a}=this.hasComposition;t=new Xe(l,a,e.changes.mapPos(l,-1),e.changes.mapPos(a,1)).addToSet(t.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(H.ie||H.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,i=this.updateDeco(),s=YT(o,i,e.changes);return t=Xe.extendWithRanges(t,s),!(this.flags&7)&&t.length==0?!1:(this.updateInner(t,e.startState.doc.length,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:o}=this.view;o.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=H.chrome||H.ios?{node:o.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,s),this.flags&=-8,s&&(s.written||o.selectionRange.focusNode!=s.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(s=>s.flags&=-9);let i=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.children)s instanceof sn&&s.widget instanceof ol&&i.push(s.dom);o.updateGaps(i)}updateChildren(e,t,n){let o=n?n.range.addToSet(e.slice()):e,i=this.childCursor(t);for(let s=o.length-1;;s--){let l=s>=0?o[s]:null;if(!l)break;let{fromA:a,toA:c,fromB:u,toB:h}=l,f,d,p,m;if(n&&n.range.fromB<h&&n.range.toB>u){let x=ar.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),S=ar.build(this.view.state.doc,n.range.toB,h,this.decorations,this.dynamicDecorationMap);d=x.breakAtStart,p=x.openStart,m=S.openEnd;let b=this.compositionView(n);S.breakAtStart?b.breakAfter=1:S.content.length&&b.merge(b.length,b.length,S.content[0],!1,S.openStart,0)&&(b.breakAfter=S.content[0].breakAfter,S.content.shift()),x.content.length&&b.merge(0,0,x.content[x.content.length-1],!0,0,x.openEnd)&&x.content.pop(),f=x.content.concat(b).concat(S.content)}else({content:f,breakAtStart:d,openStart:p,openEnd:m}=ar.build(this.view.state.doc,u,h,this.decorations,this.dynamicDecorationMap));let{i:y,off:g}=i.findPos(c,1),{i:v,off:w}=i.findPos(a,-1);Jm(this,v,w,y,g,f,d,p,m)}n&&this.fixCompositionDOM(n)}compositionView(e){let t=new gt(e.text.nodeValue);t.flags|=8;for(let{deco:o}of e.marks)t=new At(o,[t],t.length);let n=new Ie;return n.append(t,0),n}fixCompositionDOM(e){let t=(i,s)=>{s.flags|=8,this.markedForComposition.add(s);let l=ne.get(i);l!=s&&(l&&(l.dom=null),s.setDOM(i))},n=this.childPos(e.range.fromB,1),o=this.children[n.i];t(e.line,o);for(let i=e.marks.length-1;i>=-1;i--)n=o.childPos(n.off,1),o=o.children[n.i],t(i>=0?e.marks[i].node:e.text,o)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,o=n==this.dom,i=!o&&Gs(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(o||t||i))return;let s=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.domAtPos(l.anchor),c=l.empty?a:this.domAtPos(l.head);if(H.gecko&&l.empty&&!this.hasComposition&&jT(a)){let h=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(h,a.node.childNodes[a.offset]||null)),a=c=new Pe(h,0),s=!0}let u=this.view.observer.selectionRange;(s||!u.focusNode||!Ys(a.node,a.offset,u.anchorNode,u.anchorOffset)||!Ys(c.node,c.offset,u.focusNode,u.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(u.focusNode)&&XT(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=Qs(this.view.root);if(h)if(l.empty){if(H.gecko){let f=QT(a.node,a.offset);if(f&&f!=3){let d=bg(a.node,a.offset,f==1?1:-1);d&&(a=new Pe(d,f==1?0:d.nodeValue.length))}}h.collapse(a.node,a.offset),l.bidiLevel!=null&&u.cursorBidiLevel!=null&&(u.cursorBidiLevel=l.bidiLevel)}else if(h.extend){h.collapse(a.node,a.offset);try{h.extend(c.node,c.offset)}catch{}}else{let f=document.createRange();l.anchor>l.head&&([a,c]=[c,a]),f.setEnd(c.node,c.offset),f.setStart(a.node,a.offset),h.removeAllRanges(),h.addRange(f)}i&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,c)),this.impreciseAnchor=a.precise?null:new Pe(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Pe(u.focusNode,u.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Qs(e.root),{anchorNode:o,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let s=Ie.find(this,t.head);if(!s)return;let l=s.posAtStart;if(t.head==l||t.head==l+s.length)return;let a=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(o,i)}nearest(e){for(let t=e;t;){let n=ne.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let o=this.children[t];if(n<o.length||o instanceof Ie)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){for(let n=this.length,o=this.children.length-1;;o--){let i=this.children[o],s=n-i.breakAfter-i.length;if(e>s||e==s&&i.type!=me.WidgetBefore&&i.type!=me.WidgetAfter&&(!o||t==2||this.children[o-1].breakAfter||this.children[o-1].type==me.WidgetBefore&&t>-2))return i.coordsAt(e-s,t);n=s}}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),o=this.children[t];if(!(o instanceof Ie))return null;for(;o.children.length;){let{i:l,off:a}=o.childPos(n,1);for(;;l++){if(l==o.children.length)return null;if((o=o.children[l]).length)break}n=a}if(!(o instanceof gt))return null;let i=Ve(o.text,n);if(i==n)return null;let s=cr(o.dom,n,i).getClientRects();return!s.length||s[0].top>=s[0].bottom?null:s[0]}measureVisibleLineHeights(e){let t=[],{from:n,to:o}=e,i=this.view.contentDOM.clientWidth,s=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==pe.LTR;for(let c=0,u=0;u<this.children.length;u++){let h=this.children[u],f=c+h.length;if(f>o)break;if(c>=n){let d=h.dom.getBoundingClientRect();if(t.push(d.height),s){let p=h.dom.lastChild,m=p?si(p):[];if(m.length){let y=m[m.length-1],g=a?y.right-d.left:d.right-y.left;g>l&&(l=g,this.minWidth=i,this.minWidthFrom=c,this.minWidthTo=f)}}}c=f+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?pe.RTL:pe.LTR}measureTextSize(){for(let i of this.children)if(i instanceof Ie){let s=i.measureTextSize();if(s)return s}let e=document.createElement("div"),t,n,o;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let i=si(e.firstChild)[0];t=e.getBoundingClientRect().height,n=i?i.width/27:7,o=i?i.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:o}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Zs(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,o=0;;o++){let i=o==t.viewports.length?null:t.viewports[o],s=i?i.from-1:this.length;if(s>n){let l=t.lineBlockAt(s).bottom-t.lineBlockAt(n).top;e.push(Se.replace({widget:new ol(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!i)break;n=i.to+1}return Se.set(e)}updateDeco(){let e=this.view.state.facet(li).map((t,n)=>(this.dynamicDecorationMap[n]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),o;if(!n)return;!t.empty&&(o=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,o.left),top:Math.min(n.top,o.top),right:Math.max(n.right,o.right),bottom:Math.max(n.bottom,o.bottom)});let i=dg(this.view),s={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom};DT(this.view.scrollDOM,s,t.head<t.anchor?-1:1,e.x,e.y,e.xMargin,e.yMargin,this.view.textDirection==pe.LTR)}};function jT(r){return r.node.nodeType==1&&r.node.firstChild&&(r.offset==0||r.node.childNodes[r.offset-1].contentEditable=="false")&&(r.offset==r.node.childNodes.length||r.node.childNodes[r.offset].contentEditable=="false")}var ol=class extends ln{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function yg(r){let e=r.observer.selectionRange,t=e.focusNode&&bg(e.focusNode,e.focusOffset,0);if(!t)return null;let n=ne.get(t),o,i;if(n instanceof gt)o=n.posAtStart,i=o+n.length;else e:for(let s=0,l=t;;){for(let c=l.previousSibling,u;c;c=c.previousSibling){if(u=ne.get(c)){o=i=u.posAtEnd+s;break e}let h=new el([],r.state);if(h.readNode(c),h.text.indexOf(Kr)>-1)return null;s+=h.text.length}if(l=l.parentNode,!l)return null;let a=ne.get(l);if(a){o=i=a.posAtStart+s;break}}return{from:o,to:i,node:t}}function JT(r,e){let t=yg(r);if(!t)return null;let{from:n,to:o,node:i}=t,s=e.mapPos(n,-1),l=e.mapPos(o,1),a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(l-s!=a.length){let f=e.mapPos(n,1),d=e.mapPos(o,-1);if(d-f==a.length)s=f,l=d;else if(r.state.doc.sliceString(l-a.length,l)==a)s=l-a.length;else if(r.state.doc.sliceString(s,s+a.length)==a)l=s+a.length;else return null}let{main:c}=r.state.selection;if(r.state.doc.sliceString(s,l)!=a||s>c.head||l<c.head)return null;let u=[],h=new Xe(n,o,s,l);for(let f=i.parentNode;;f=f.parentNode){let d=ne.get(f);if(d instanceof At)u.push({node:f,deco:d.mark});else{if(d instanceof Ie||f.nodeName=="DIV"&&f.parentNode==r.contentDOM)return{range:h,text:i,marks:u,line:f};if(f!=r.contentDOM)u.push({node:f,deco:new ur({inclusive:!0,attributes:BT(f),tagName:f.tagName.toLowerCase()})});else return null}}}function bg(r,e,t){if(t<=0)for(let n=r,o=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&o>0)n=n.childNodes[o-1],o=kn(n);else break}if(t>=0)for(let n=r,o=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&o<n.childNodes.length&&t>=0)n=n.childNodes[o],o=0;else break}return null}function QT(r,e){return r.nodeType!=1?0:(e&&r.childNodes[e-1].contentEditable=="false"?1:0)|(e<r.childNodes.length&&r.childNodes[e].contentEditable=="false"?2:0)}var Wc=class{constructor(){this.changes=[]}compareRange(e,t){Bc(e,t,this.changes)}comparePoint(e,t){Bc(e,t,this.changes)}};function YT(r,e,t){let n=new Wc;return oe.compare(r,e,t,n),n.changes}function XT(r,e){for(let t=r;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function ZT(r,e,t=1){let n=r.charCategorizer(e),o=r.doc.lineAt(e),i=e-o.from;if(o.length==0)return D.cursor(e);i==0?t=1:i==o.length&&(t=-1);let s=i,l=i;t<0?s=Ve(o.text,i,!1):l=Ve(o.text,i);let a=n(o.text.slice(s,l));for(;s>0;){let c=Ve(o.text,s,!1);if(n(o.text.slice(c,s))!=a)break;s=c}for(;l<o.length;){let c=Ve(o.text,l);if(n(o.text.slice(l,c))!=a)break;l=c}return D.range(s+o.from,l+o.from)}function ek(r,e){return e.left>r?e.left-r:Math.max(0,r-e.right)}function tk(r,e){return e.top>r?e.top-r:Math.max(0,r-e.bottom)}function Ec(r,e){return r.top<e.bottom-1&&r.bottom>e.top+1}function Sm(r,e){return e<r.top?{top:e,left:r.left,right:r.right,bottom:r.bottom}:r}function Cm(r,e){return e>r.bottom?{top:r.top,left:r.left,right:r.right,bottom:e}:r}function $c(r,e,t){let n,o,i,s,l=!1,a,c,u,h;for(let p=r.firstChild;p;p=p.nextSibling){let m=si(p);for(let y=0;y<m.length;y++){let g=m[y];o&&Ec(o,g)&&(g=Sm(Cm(g,o.bottom),o.top));let v=ek(e,g),w=tk(t,g);if(v==0&&w==0)return p.nodeType==3?Tm(p,e,t):$c(p,e,t);if(!n||s>w||s==w&&i>v){n=p,o=g,i=v,s=w;let x=w?t<g.top?-1:1:v?e<g.left?-1:1:0;l=!x||(x>0?y<m.length-1:y>0)}v==0?t>g.bottom&&(!u||u.bottom<g.bottom)?(a=p,u=g):t<g.top&&(!h||h.top>g.top)&&(c=p,h=g):u&&Ec(u,g)?u=Cm(u,g.bottom):h&&Ec(h,g)&&(h=Sm(h,g.top))}}if(u&&u.bottom>=t?(n=a,o=u):h&&h.top<=t&&(n=c,o=h),!n)return{node:r,offset:0};let f=Math.max(o.left,Math.min(o.right,e));if(n.nodeType==3)return Tm(n,f,t);if(l&&n.contentEditable!="false")return $c(n,f,t);let d=Array.prototype.indexOf.call(r.childNodes,n)+(e>=(o.left+o.right)/2?1:0);return{node:r,offset:d}}function Tm(r,e,t){let n=r.nodeValue.length,o=-1,i=1e9,s=0;for(let l=0;l<n;l++){let a=cr(r,l,l+1).getClientRects();for(let c=0;c<a.length;c++){let u=a[c];if(u.top==u.bottom)continue;s||(s=e-u.left);let h=(u.top>t?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&h<i){let f=e>=(u.left+u.right)/2,d=f;if((H.chrome||H.gecko)&&cr(r,l).getBoundingClientRect().left==u.right&&(d=!f),h<=0)return{node:r,offset:l+(d?1:0)};o=l+(d?1:0),i=h}}}return{node:r,offset:o>-1?o:s>0?r.nodeValue.length:0}}function xg(r,e,t,n=-1){var o,i;let s=r.contentDOM.getBoundingClientRect(),l=s.top+r.viewState.paddingTop,a,{docHeight:c}=r.viewState,{x:u,y:h}=e,f=h-l;if(f<0)return 0;if(f>c)return r.state.doc.length;for(let x=r.viewState.heightOracle.textHeight/2,S=!1;a=r.elementAtHeight(f),a.type!=me.Text;)for(;f=n>0?a.bottom+x:a.top-x,!(f>=0&&f<=c);){if(S)return t?null:0;S=!0,n=-n}h=l+f;let d=a.from;if(d<r.viewport.from)return r.viewport.from==0?0:t?null:km(r,s,a,u,h);if(d>r.viewport.to)return r.viewport.to==r.state.doc.length?r.state.doc.length:t?null:km(r,s,a,u,h);let p=r.dom.ownerDocument,m=r.root.elementFromPoint?r.root:p,y=m.elementFromPoint(u,h);y&&!r.contentDOM.contains(y)&&(y=null),y||(u=Math.max(s.left+1,Math.min(s.right-1,u)),y=m.elementFromPoint(u,h),y&&!r.contentDOM.contains(y)&&(y=null));let g,v=-1;if(y&&((o=r.docView.nearest(y))===null||o===void 0?void 0:o.isEditable)!=!1){if(p.caretPositionFromPoint){let x=p.caretPositionFromPoint(u,h);x&&({offsetNode:g,offset:v}=x)}else if(p.caretRangeFromPoint){let x=p.caretRangeFromPoint(u,h);x&&({startContainer:g,startOffset:v}=x,(!r.contentDOM.contains(g)||H.safari&&nk(g,v,u)||H.chrome&&rk(g,v,u))&&(g=void 0))}}if(!g||!r.docView.dom.contains(g)){let x=Ie.find(r.docView,d);if(!x)return f>a.top+a.height/2?a.to:a.from;({node:g,offset:v}=$c(x.dom,u,h))}let w=r.docView.nearest(g);if(!w)return null;if(w.isWidget&&((i=w.dom)===null||i===void 0?void 0:i.nodeType)==1){let x=w.dom.getBoundingClientRect();return e.y<x.top||e.y<=x.bottom&&e.x<=(x.left+x.right)/2?w.posAtStart:w.posAtEnd}else return w.localPosFromDOM(g,v)+w.posAtStart}function km(r,e,t,n,o){let i=Math.round((n-e.left)*r.defaultCharacterWidth);if(r.lineWrapping&&t.height>r.defaultLineHeight*1.5){let l=r.viewState.heightOracle.textHeight,a=Math.floor((o-t.top-(r.defaultLineHeight-l)*.5)/l);i+=a*r.viewState.heightOracle.lineLength}let s=r.state.sliceDoc(t.from,t.to);return t.from+am(s,i,r.state.tabSize)}function nk(r,e,t){let n;if(r.nodeType!=3||e!=(n=r.nodeValue.length))return!1;for(let o=r.nextSibling;o;o=o.nextSibling)if(o.nodeType!=1||o.nodeName!="BR")return!1;return cr(r,n-1,n).getBoundingClientRect().left>t}function rk(r,e,t){if(e!=0)return!1;for(let o=r;;){let i=o.parentNode;if(!i||i.nodeType!=1||i.firstChild!=o)return!1;if(i.classList.contains("cm-line"))break;o=i}let n=r.nodeType==1?r.getBoundingClientRect():cr(r,0,Math.max(r.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Uc(r,e){let t=r.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==me.Text))return n}return t}function ok(r,e,t,n){let o=Uc(r,e.head),i=!n||o.type!=me.Text||!(r.lineWrapping||o.widgetLineBreaks)?null:r.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head);if(i){let s=r.dom.getBoundingClientRect(),l=r.textDirectionAt(o.from),a=r.posAtCoords({x:t==(l==pe.LTR)?s.right-1:s.left+1,y:(i.top+i.bottom)/2});if(a!=null)return D.cursor(a,t?-1:1)}return D.cursor(t?o.to:o.from,t?-1:1)}function Mm(r,e,t,n){let o=r.state.doc.lineAt(e.head),i=r.bidiSpans(o),s=r.textDirectionAt(o.from);for(let l=e,a=null;;){let c=KT(o,i,s,l,t),u=gg;if(!c){if(o.number==(t?r.state.doc.lines:1))return l;u=`
|
|
24
|
-
`,o=r.state.doc.line(o.number+(t?1:-1)),i=r.bidiSpans(o),c=D.cursor(t?o.from:o.to)}if(a){if(!a(u))return l}else{if(!n)return c;a=n(u)}l=c}}function ik(r,e,t){let n=r.state.charCategorizer(e),o=n(t);return i=>{let s=n(i);return o==Ge.Space&&(o=s),o==s}}function sk(r,e,t,n){let o=e.head,i=t?1:-1;if(o==(t?r.state.doc.length:0))return D.cursor(o,e.assoc);let s=e.goalColumn,l,a=r.contentDOM.getBoundingClientRect(),c=r.coordsAtPos(o),u=r.documentTop;if(c)s==null&&(s=c.left-a.left),l=i<0?c.top:c.bottom;else{let d=r.viewState.lineBlockAt(o);s==null&&(s=Math.min(a.right-a.left,r.defaultCharacterWidth*(o-d.from))),l=(i<0?d.top:d.bottom)+u}let h=a.left+s,f=n!=null?n:r.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(f+d)*i,m=xg(r,{x:h,y:p},!1,i);if(p<a.top||p>a.bottom||(i<0?m<o:m>o))return D.cursor(m,e.assoc,void 0,s)}}function qs(r,e,t){for(;;){let n=0;for(let o of r)o.between(e-1,e+1,(i,s,l)=>{if(e>i&&e<s){let a=n||t||(e-i<s-e?-1:1);e=a<0?i:s,n=a}});if(!n)return e}}function Rc(r,e,t){let n=qs(r.state.facet(mu).map(o=>o(r)),t.from,e.head>t.from?-1:1);return n==t.from?t:D.cursor(n,n<t.from?1:-1)}var Gc=class{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let t=(n,o)=>{this.ignoreDuringComposition(o)||o.type=="keydown"&&this.keydown(e,o)||(this.mustFlushObserver(o)&&e.observer.forceFlush(),this.runCustomHandlers(o.type,e,o)?o.preventDefault():n(e,o))};for(let n in xe){let o=xe[n];e.contentDOM.addEventListener(n,i=>{Em(e,i)&&t(o,i)},Kc[n]),this.registeredEvents.push(n)}e.scrollDOM.addEventListener("mousedown",n=>{if(n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(xe.mousedown,n),!n.defaultPrevented&&n.button==2)){let o=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=o,200)}}),e.scrollDOM.addEventListener("drop",n=>{n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&t(xe.drop,n)}),H.chrome&&H.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,H.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var n;let o;this.customHandlers=[];for(let i of t)if(o=(n=i.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:i.value,handlers:o});for(let s in o)this.registeredEvents.indexOf(s)<0&&s!="scroll"&&(this.registeredEvents.push(s),e.contentDOM.addEventListener(s,l=>{Em(e,l)&&this.runCustomHandlers(s,e,l)&&l.preventDefault()}))}}runCustomHandlers(e,t,n){for(let o of this.customHandlers){let i=o.handlers[e];if(i)try{if(i.call(o.plugin,n,t)||n.defaultPrevented)return!0}catch(s){Ut(t.state,s)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let n of this.customHandlers){let o=n.handlers.scroll;if(o)try{o.call(n.plugin,t,e)}catch(i){Ut(e.state,i)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(t.keyCode!=27&&wg.indexOf(t.keyCode)<0&&(e.inputState.lastEscPress=0),H.android&&H.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return e.observer.delayAndroidKey(t.key,t.keyCode),!0;let n;return H.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((n=vg.find(o=>o.keyCode==t.keyCode))&&!t.ctrlKey||lk.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=n||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,Jr(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:H.safari&&!H.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}},vg=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],lk="dthko",wg=[16,17,18,20,91,92,224,225],Hs=6;function _s(r){return Math.max(0,r)*.7+8}function ak(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}var qc=class{constructor(e,t,n,o){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=LT(e.contentDOM),this.atoms=e.state.facet(mu).map(s=>s(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Z.allowMultipleSelections)&&ck(e,t),this.dragging=hk(e,t)&&kg(t)==1?null:!1}start(e){this.dragging===!1&&(e.preventDefault(),this.select(e))}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&ak(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,o=0,i=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},s=dg(this.view);e.clientX-s.left<=i.left+Hs?n=-_s(i.left-e.clientX):e.clientX+s.right>=i.right-Hs&&(n=_s(e.clientX-i.right)),e.clientY-s.top<=i.top+Hs?o=-_s(i.top-e.clientY):e.clientY+s.bottom>=i.bottom-Hs&&(o=_s(e.clientY-i.bottom)),this.setScrollSpeed(n,o)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let o=e.ranges[n],i=null;if(o.empty){let s=qs(this.atoms,o.from,0);s!=o.from&&(i=D.cursor(s,-1))}else{let s=qs(this.atoms,o.from,-1),l=qs(this.atoms,o.to,1);(s!=o.from||l!=o.to)&&(i=D.range(o.from==o.anchor?s:l,o.from==o.head?s:l))}i&&(t||(t=e.ranges.slice()),t[n]=i)}return t?D.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection)||n.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function ck(r,e){let t=r.state.facet(rg);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function uk(r,e){let t=r.state.facet(og);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function hk(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let n=Qs(r.root);if(!n||n.rangeCount==0)return!0;let o=n.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function Em(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=r.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=ne.get(t))&&n.ignoreEvent(e))return!1;return!0}var xe=Object.create(null),Kc=Object.create(null),Sg=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function fk(r){let e=r.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{r.focus(),t.remove(),Cg(r,t.value)},50)}function Cg(r,e){let{state:t}=r,n,o=1,i=t.toText(e),s=i.lines==t.selection.ranges.length;if(jc!=null&&t.selection.ranges.every(a=>a.empty)&&jc==i.toString()){let a=-1;n=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==a)return{range:c};a=u.from;let h=t.toText((s?i.line(o++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:h},range:D.cursor(c.from+h.length)}})}else s?n=t.changeByRange(a=>{let c=i.line(o++);return{changes:{from:a.from,to:a.to,insert:c.text},range:D.cursor(a.from+c.length)}}):n=t.replaceSelection(i);r.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}xe.keydown=(r,e)=>{r.inputState.setSelectionOrigin("select"),e.keyCode==27&&(r.inputState.lastEscPress=Date.now())};xe.touchstart=(r,e)=>{r.inputState.lastTouchTime=Date.now(),r.inputState.setSelectionOrigin("select.pointer")};xe.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};Kc.touchstart=Kc.touchmove={passive:!0};xe.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return;let t=null;for(let n of r.state.facet(ig))if(t=n(r,e),t)break;if(!t&&e.button==0&&(t=mk(r,e)),t){let n=!r.hasFocus;r.inputState.startMouseSelection(new qc(r,e,t,n)),n&&r.observer.ignore(()=>qm(r.contentDOM)),r.inputState.mouseSelection&&r.inputState.mouseSelection.start(e)}};function Rm(r,e,t,n){if(n==1)return D.cursor(e,t);if(n==2)return ZT(r.state,e,t);{let o=Ie.find(r.docView,e),i=r.state.doc.lineAt(o?o.posAtEnd:e),s=o?o.posAtStart:i.from,l=o?o.posAtEnd:i.to;return l<r.state.doc.length&&l==i.to&&l++,D.range(s,l)}}var Tg=(r,e)=>r>=e.top&&r<=e.bottom,Im=(r,e,t)=>Tg(e,t)&&r>=t.left&&r<=t.right;function dk(r,e,t,n){let o=Ie.find(r.docView,e);if(!o)return 1;let i=e-o.posAtStart;if(i==0)return 1;if(i==o.length)return-1;let s=o.coordsAt(i,-1);if(s&&Im(t,n,s))return-1;let l=o.coordsAt(i,1);return l&&Im(t,n,l)?1:s&&Tg(n,s)?-1:1}function Pm(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:dk(r,t,e.clientX,e.clientY)}}var pk=H.ie&&H.ie_version<=11,Dm=null,Lm=0,Am=0;function kg(r){if(!pk)return r.detail;let e=Dm,t=Am;return Dm=r,Am=Date.now(),Lm=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(Lm+1)%3:1}function mk(r,e){let t=Pm(r,e),n=kg(e),o=r.state.selection;return{update(i){i.docChanged&&(t.pos=i.changes.mapPos(t.pos),o=o.map(i.changes))},get(i,s,l){let a=Pm(r,i),c,u=Rm(r,a.pos,a.bias,n);if(t.pos!=a.pos&&!s){let h=Rm(r,t.pos,t.bias,n),f=Math.min(h.from,u.from),d=Math.max(h.to,u.to);u=f<u.from?D.range(f,d):D.range(d,f)}return s?o.replaceRange(o.main.extend(u.from,u.to)):l&&n==1&&o.ranges.length>1&&(c=gk(o,a.pos))?c:l?o.addRange(u):D.create([u])}}}function gk(r,e){for(let t=0;t<r.ranges.length;t++){let{from:n,to:o}=r.ranges[t];if(n<=e&&o>=e)return D.create(r.ranges.slice(0,t).concat(r.ranges.slice(t+1)),r.mainIndex==t?0:r.mainIndex-(r.mainIndex>t?1:0))}return null}xe.dragstart=(r,e)=>{let{selection:{main:t}}=r.state,{mouseSelection:n}=r.inputState;n&&(n.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",r.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function Om(r,e,t,n){if(!t)return;let o=r.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:i}=r.inputState,s=n&&i&&i.dragging&&uk(r,e)?{from:i.dragging.from,to:i.dragging.to}:null,l={from:o,insert:t},a=r.state.changes(s?[s,l]:l);r.focus(),r.dispatch({changes:a,selection:{anchor:a.mapPos(o,-1),head:a.mapPos(o,1)},userEvent:s?"move.drop":"input.drop"})}xe.drop=(r,e)=>{if(!e.dataTransfer)return;if(r.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let n=Array(t.length),o=0,i=()=>{++o==t.length&&Om(r,e,n.filter(s=>s!=null).join(r.state.lineBreak),!1)};for(let s=0;s<t.length;s++){let l=new FileReader;l.onerror=i,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[s]=l.result),i()},l.readAsText(t[s])}}else Om(r,e,e.dataTransfer.getData("Text"),!0)};xe.paste=(r,e)=>{if(r.state.readOnly)return e.preventDefault();r.observer.flush();let t=Sg?null:e.clipboardData;t?(Cg(r,t.getData("text/plain")||t.getData("text/uri-text")),e.preventDefault()):fk(r)};function yk(r,e){let t=r.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),r.focus()},50)}function bk(r){let e=[],t=[],n=!1;for(let o of r.selection.ranges)o.empty||(e.push(r.sliceDoc(o.from,o.to)),t.push(o));if(!e.length){let o=-1;for(let{from:i}of r.selection.ranges){let s=r.doc.lineAt(i);s.number>o&&(e.push(s.text),t.push({from:s.from,to:Math.min(r.doc.length,s.to+1)})),o=s.number}n=!0}return{text:e.join(r.lineBreak),ranges:t,linewise:n}}var jc=null;xe.copy=xe.cut=(r,e)=>{let{text:t,ranges:n,linewise:o}=bk(r.state);if(!t&&!o)return;jc=o?t:null;let i=Sg?null:e.clipboardData;i?(e.preventDefault(),i.clearData(),i.setData("text/plain",t)):yk(r,t),e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};var Mg=tt.define();function Eg(r,e){let t=[];for(let n of r.facet(ag)){let o=n(r,e);o&&t.push(o)}return t?r.update({effects:t,annotations:Mg.of(!0)}):null}function Rg(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=Eg(r.state,e);t?r.dispatch(t):r.update([])}},10)}xe.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),Rg(r)};xe.blur=r=>{r.observer.clearSelectionRange(),Rg(r)};xe.compositionstart=xe.compositionupdate=r=>{r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0)};xe.compositionend=r=>{r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,H.chrome&&H.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50)};xe.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};xe.beforeinput=(r,e)=>{var t;let n;if(H.chrome&&H.android&&(n=vg.find(o=>o.inputType==e.inputType))&&(r.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let o=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var i;(((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0)>o+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}};var Nm=["pre-wrap","normal","pre-line","break-spaces"],Jc=class{constructor(e){this.lineWrapping=e,this.doc=Y.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Nm.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let o=e[n];o<0?n++:this.heightSamples[Math.floor(o*10)]||(t=!0,this.heightSamples[Math.floor(o*10)]=!0)}return t}refresh(e,t,n,o,i,s){let l=Nm.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=o,this.lineLength=i,a){this.heightSamples={};for(let c=0;c<s.length;c++){let u=s[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return a}},Qc=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},mt=class{constructor(e,t,n,o,i){this.from=e,this.length=t,this.top=n,this.height=o,this._content=i}get type(){return typeof this._content=="number"?me.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Gt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new mt(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ae=function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r}(ae||(ae={})),Ks=.001,De=class{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>Ks&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return De.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,o){let i=this,s=n.doc;for(let l=o.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:u,toB:h}=o[l],f=i.lineAt(a,ae.ByPosNoHeight,n.setDoc(t),0,0),d=f.to>=c?f:i.lineAt(c,ae.ByPosNoHeight,n,0,0);for(h+=d.to-c,c=d.to;l>0&&f.from<=o[l-1].toA;)a=o[l-1].fromA,u=o[l-1].fromB,l--,a<f.from&&(f=i.lineAt(a,ae.ByPosNoHeight,n,0,0));u+=f.from-a,a=f.from;let p=ai.build(n.setDoc(s),e,u,h);i=i.replace(a,c,p)}return i.updateHeight(n,0)}static empty(){return new Ke(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,o=0,i=0;for(;;)if(t==n)if(o>i*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,o-=l.size}else if(i>o*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,i-=l.size}else break;else if(o<i){let l=e[t++];l&&(o+=l.size)}else{let l=e[--n];l&&(i+=l.size)}let s=0;return e[t-1]==null?(s=1,t--):e[t]==null&&(s=1,n++),new Yc(De.of(e.slice(0,t)),s,De.of(e.slice(n)))}};De.prototype.size=1;var il=class extends De{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,o){return new mt(o,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,o,i){return this.blockAt(0,n,o,i)}forEachLine(e,t,n,o,i,s){e<=i+this.length&&t>=i&&s(this.blockAt(0,n,o,i))}updateHeight(e,t=0,n=!1,o){return o&&o.from<=t&&o.more&&this.setHeight(e,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},Ke=class extends il{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,o){return new mt(o,this.length,n,this.height,this.breaks)}replace(e,t,n){let o=n[0];return n.length==1&&(o instanceof Ke||o instanceof we&&o.flags&4)&&Math.abs(this.length-o.length)<10?(o instanceof we?o=new Ke(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):De.of(n)}updateHeight(e,t=0,n=!1,o){return o&&o.from<=t&&o.more?this.setHeight(e,o.heights[o.index++]):(n||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},we=class extends De{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,o=e.doc.lineAt(t+this.length).number,i=o-n+1,s,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*i);s=a/i,this.length>i+1&&(l=(this.height-a)/(this.length-i-1))}else s=this.height/i;return{firstLine:n,lastLine:o,perLine:s,perChar:l}}blockAt(e,t,n,o){let{firstLine:i,lastLine:s,perLine:l,perChar:a}=this.heightMetrics(t,o);if(t.lineWrapping){let c=o+Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length),u=t.doc.lineAt(c),h=l+u.length*a,f=Math.max(n,e-h/2);return new mt(u.from,u.length,f,h,0)}else{let c=Math.max(0,Math.min(s-i,Math.floor((e-n)/l))),{from:u,length:h}=t.doc.line(i+c);return new mt(u,h,n+l*c,l,0)}}lineAt(e,t,n,o,i){if(t==ae.ByHeight)return this.blockAt(e,n,o,i);if(t==ae.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new mt(d,p-d,0,0,0)}let{firstLine:s,perLine:l,perChar:a}=this.heightMetrics(n,i),c=n.doc.lineAt(e),u=l+c.length*a,h=c.number-s,f=o+l*h+a*(c.from-i-h);return new mt(c.from,c.length,Math.max(o,Math.min(f,o+this.height-u)),u,0)}forEachLine(e,t,n,o,i,s){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(n,i);for(let u=e,h=o;u<=t;){let f=n.doc.lineAt(u);if(u==e){let p=f.number-l;h+=a*p+c*(e-i-p)}let d=a+c*f.length;s(new mt(f.from,f.length,h,d,0)),h+=d,u=f.to+1}}replace(e,t,n){let o=this.length-t;if(o>0){let i=n[n.length-1];i instanceof we?n[n.length-1]=new we(i.length+o):n.push(null,new we(o-1))}if(e>0){let i=n[0];i instanceof we?n[0]=new we(e+i.length):n.unshift(new we(e-1),null)}return De.of(n)}decomposeLeft(e,t){t.push(new we(e-1),null)}decomposeRight(e,t){t.push(null,new we(this.length-e-1))}updateHeight(e,t=0,n=!1,o){let i=t+this.length;if(o&&o.from<=t+this.length&&o.more){let s=[],l=Math.max(t,o.from),a=-1;for(o.from>t&&s.push(new we(o.from-t-1).updateHeight(e,t));l<=i&&o.more;){let u=e.doc.lineAt(l).length;s.length&&s.push(null);let h=o.heights[o.index++];a==-1?a=h:Math.abs(h-a)>=Ks&&(a=-2);let f=new Ke(u,h);f.outdated=!1,s.push(f),l+=u+1}l<=i&&s.push(null,new we(i-l).updateHeight(e,l));let c=De.of(s);return(a<0||Math.abs(c.height-this.height)>=Ks||Math.abs(a-this.heightMetrics(e,t).perLine)>=Ks)&&(e.heightChanged=!0),c}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Yc=class extends De{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,o){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,o):this.right.blockAt(e,t,i,o+this.left.length+this.break)}lineAt(e,t,n,o,i){let s=o+this.left.height,l=i+this.left.length+this.break,a=t==ae.ByHeight?e<s:e<l,c=a?this.left.lineAt(e,t,n,o,i):this.right.lineAt(e,t,n,s,l);if(this.break||(a?c.to<l:c.from>l))return c;let u=t==ae.ByPosNoHeight?ae.ByPosNoHeight:ae.ByPos;return a?c.join(this.right.lineAt(l,u,n,s,l)):this.left.lineAt(l,u,n,o,i).join(c)}forEachLine(e,t,n,o,i,s){let l=o+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,o,i,s),t>=a&&this.right.forEachLine(e,t,n,l,a,s);else{let c=this.lineAt(a,ae.ByPos,n,o,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,o,i,s),c.to>=e&&c.from<=t&&s(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,l,a,s)}}replace(e,t,n){let o=this.left.length+this.break;if(t<o)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-o,t-o,n));let i=[];e>0&&this.decomposeLeft(e,i);let s=i.length;for(let l of n)i.push(l);if(e>0&&Vm(i,s-1),t<this.length){let l=i.length;this.decomposeRight(t,i),Vm(i,l)}return De.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,o=n+this.break;if(e>=o)return this.right.decomposeRight(e-o,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<o&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?De.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,o){let{left:i,right:s}=this,l=t+i.length+this.break,a=null;return o&&o.from<=t+i.length&&o.more?a=i=i.updateHeight(e,t,n,o):i.updateHeight(e,t,n),o&&o.from<=l+s.length&&o.more?a=s=s.updateHeight(e,l,n,o):s.updateHeight(e,l,n),a?this.balanced(i,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Vm(r,e){let t,n;r[e]==null&&(t=r[e-1])instanceof we&&(n=r[e+1])instanceof we&&r.splice(e-1,3,new we(t.length+1+n.length))}var xk=5,ai=class{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),o=this.nodes[this.nodes.length-1];o instanceof Ke?o.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Ke(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let o=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;o<0&&(o=this.oracle.lineHeight);let s=t-e;n.block?this.addBlock(new il(s,o,n)):(s||i||o>=xk)&&this.addLineDeco(o,i,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ke(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new we(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ke)return e;let t=new Ke(0,-1);return this.nodes.push(t),t}addBlock(e){var t;this.enterLine();let n=(t=e.deco)===null||t===void 0?void 0:t.type;n==me.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n!=me.WidgetBefore&&(this.covering=e)}addLineDeco(e,t,n){let o=this.ensureLine();o.length+=n,o.collapsed+=n,o.widgetHeight=Math.max(o.widgetHeight,e),o.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ke)&&!this.isCovered?this.nodes.push(new Ke(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let o of this.nodes)o instanceof Ke&&o.updateHeight(this.oracle,n),n+=o?o.length:1;return this.nodes}static build(e,t,n,o){let i=new ai(n,e);return oe.spans(t,n,o,i,0),i.finish(n)}};function vk(r,e,t){let n=new Xc;return oe.compare(r,e,t,n,0),n.changes}var Xc=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,o){(e<t||n&&n.heightRelevant||o&&o.heightRelevant)&&Bc(e,t,this.changes,5)}};function wk(r,e){let t=r.getBoundingClientRect(),n=r.ownerDocument,o=n.defaultView||window,i=Math.max(0,t.left),s=Math.min(o.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(o.innerHeight,t.bottom);for(let c=r.parentNode;c&&c!=n.body;)if(c.nodeType==1){let u=c,h=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&h.overflow!="visible"){let f=u.getBoundingClientRect();i=Math.max(i,f.left),s=Math.min(s,f.right),l=Math.max(l,f.top),a=c==r.parentNode?f.bottom:Math.min(a,f.bottom)}c=h.position=="absolute"||h.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:i-t.left,right:Math.max(i,s)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Sk(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var ii=class{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let o=e[n],i=t[n];if(o.from!=i.from||o.to!=i.to||o.size!=i.size)return!1}return!0}draw(e){return Se.replace({widget:new Zc(this.size,e)}).range(this.from,this.to)}},Zc=class extends ln{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},sl=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Fm,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=pe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(pu).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Jc(t),this.stateDeco=e.facet(li).filter(n=>typeof n!="function"),this.heightMap=De.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle.setDoc(e.doc),[new Xe(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Se.set(this.lineGaps.map(n=>n.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let o=n?t.head:t.anchor;if(!e.some(({from:i,to:s})=>o>=i&&o<=s)){let{from:i,to:s}=this.lineBlockAt(o);e.push(new jr(i,s))}}this.viewports=e.sort((n,o)=>n.from-o.from),this.scaler=this.heightMap.height<=7e6?Fm:new eu(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:ri(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(li).filter(u=>typeof u!="function");let o=e.changedRanges,i=Xe.extendWithRanges(o,vk(n,this.stateDeco,e?e.changes:ue.empty(this.state.doc.length))),s=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),this.heightMap.height!=s&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),c&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(ug)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),o=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?pe.RTL:pe.LTR;let s=this.heightOracle.mustRefreshForWrapping(i),l=t.getBoundingClientRect(),a=s||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,u=0,h=parseInt(n.paddingTop)||0,f=parseInt(n.paddingBottom)||0;(this.paddingTop!=h||this.paddingBottom!=f)&&(this.paddingTop=h,this.paddingBottom=f,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=8),this.scrollTop!=e.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=e.scrollDOM.scrollTop),this.scrolledToBottom=jm(e.scrollDOM);let d=(this.printing?Sk:wk)(t,this.paddingTop),p=d.top-this.pixelViewport.top,m=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let g=l.width;if((this.contentDOMWidth!=g||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(w)&&(s=!0),s||o.lineWrapping&&Math.abs(g-this.contentDOMWidth)>o.charWidth){let{lineHeight:x,charWidth:S,textHeight:b}=e.docView.measureTextSize();s=x>0&&o.refresh(i,x,S,b,g/S,w),s&&(e.docView.minWidth=0,c|=8)}p>0&&m>0?u=Math.max(p,m):p<0&&m<0&&(u=Math.min(p,m)),o.heightChanged=!1;for(let x of this.viewports){let S=x.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(x);this.heightMap=(s?De.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle,[new Xe(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,s,new Qc(x.from,S))}o.heightChanged&&(c|=2)}let v=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(c&2||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),o=this.heightMap,i=this.heightOracle,{visibleTop:s,visibleBottom:l}=this,a=new jr(o.lineAt(s-n*1e3,ae.ByHeight,i,0,0).from,o.lineAt(l+(1-n)*1e3,ae.ByHeight,i,0,0).to);if(t){let{head:c}=t.range;if(c<a.from||c>a.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=o.lineAt(c,ae.ByPos,i,0,0),f;t.y=="center"?f=(h.top+h.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<a.from?f=h.top:f=h.bottom-u,a=new jr(o.lineAt(f-1e3/2,ae.ByHeight,i,0,0).from,o.lineAt(f+u+1e3/2,ae.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),o=t.mapPos(e.to,1);return new jr(this.heightMap.lineAt(n,ae.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(o,ae.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:o}=this.heightMap.lineAt(e,ae.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,ae.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:l}=this;return(e==0||o<=s-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=l+Math.max(10,Math.min(n,250)))&&o>s-2*1e3&&i<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let o of e)t.touchesRange(o.from,o.to)||n.push(new ii(t.mapPos(o.from),t.mapPos(o.to),o.size));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,o=n?1e4:2e3,i=o>>1,s=o<<1;if(this.defaultTextDirection!=pe.LTR&&!n)return[];let l=[],a=(c,u,h,f)=>{if(u-c<i)return;let d=this.state.selection.main,p=[d.from];d.empty||p.push(d.to);for(let y of p)if(y>c&&y<u){a(c,y-10,h,f),a(y+10,u,h,f);return}let m=Tk(e,y=>y.from>=h.from&&y.to<=h.to&&Math.abs(y.from-c)<i&&Math.abs(y.to-u)<i&&!p.some(g=>y.from<g&&y.to>g));if(!m){if(u<h.to&&t&&n&&t.visibleRanges.some(y=>y.from<=u&&y.to>=u)){let y=t.moveToLineBoundary(D.cursor(u),!1,!0).head;y>c&&(u=y)}m=new ii(c,u,this.gapSize(h,c,u,f))}l.push(m)};for(let c of this.viewportLines){if(c.length<s)continue;let u=Ck(c.from,c.to,this.stateDeco);if(u.total<s)continue;let h=this.scrollTarget?this.scrollTarget.range.head:null,f,d;if(n){let p=o/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,y;if(h!=null){let g=Ws(u,h),v=((this.visibleBottom-this.visibleTop)/2+p)/c.height;m=g-v,y=g+v}else m=(this.visibleTop-c.top-p)/c.height,y=(this.visibleBottom-c.top+p)/c.height;f=zs(u,m),d=zs(u,y)}else{let p=u.total*this.heightOracle.charWidth,m=o*this.heightOracle.charWidth,y,g;if(h!=null){let v=Ws(u,h),w=((this.pixelViewport.right-this.pixelViewport.left)/2+m)/p;y=v-w,g=v+w}else y=(this.pixelViewport.left-m)/p,g=(this.pixelViewport.right+m)/p;f=zs(u,y),d=zs(u,g)}f>c.from&&a(c.from,f,c,u),d<c.to&&a(d,c.to,c,u)}return l}gapSize(e,t,n,o){let i=Ws(o,n)-Ws(o,t);return this.heightOracle.lineWrapping?e.height*i:o.total*this.heightOracle.charWidth*i}updateLineGaps(e){ii.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Se.set(e.map(t=>t.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];oe.spans(e,this.viewport.from,this.viewport.to,{span(o,i){t.push({from:o,to:i})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((o,i)=>o.from!=t[i].from||o.to!=t[i].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ri(this.heightMap.lineAt(e,ae.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return ri(this.heightMap.lineAt(this.scaler.fromDOM(e),ae.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ri(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},jr=class{constructor(e,t){this.from=e,this.to=t}};function Ck(r,e,t){let n=[],o=r,i=0;return oe.spans(t,r,e,{span(){},point(s,l){s>o&&(n.push({from:o,to:s}),i+=s-o),o=l}},20),o<e&&(n.push({from:o,to:e}),i+=e-o),{total:i,ranges:n}}function zs({total:r,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(r*t);for(let o=0;;o++){let{from:i,to:s}=e[o],l=s-i;if(n<=l)return i+n;n-=l}}function Ws(r,e){let t=0;for(let{from:n,to:o}of r.ranges){if(e<=o){t+=e-n;break}t+=o-n}return t/r.total}function Tk(r,e){for(let t of r)if(e(t))return t}var Fm={toDOM(r){return r},fromDOM(r){return r},scale:1},eu=class{constructor(e,t,n){let o=0,i=0,s=0;this.viewports=n.map(({from:l,to:a})=>{let c=t.lineAt(l,ae.ByPos,e,0,0).top,u=t.lineAt(a,ae.ByPos,e,0,0).bottom;return o+=u-c,{from:l,to:a,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(t.height-o);for(let l of this.viewports)l.domTop=s+(l.top-i)*this.scale,s=l.domBottom=l.domTop+(l.bottom-l.top),i=l.bottom}toDOM(e){for(let t=0,n=0,o=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return o+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,o=i.domBottom}}fromDOM(e){for(let t=0,n=0,o=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-o)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,o=i.domBottom}}};function ri(r,e){if(e.scale==1)return r;let t=e.toDOM(r.top),n=e.toDOM(r.bottom);return new mt(r.from,r.length,t,n-t,Array.isArray(r._content)?r._content.map(o=>ri(o,e)):r._content)}var $s=U.define({combine:r=>r.join(" ")}),tu=U.define({combine:r=>r.indexOf(!0)>-1}),nu=pt.newName(),Ig=pt.newName(),Pg=pt.newName(),Dg={"&light":"."+Ig,"&dark":"."+Pg};function ru(r,e,t){return new pt(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,o=>{if(o=="&")return r;if(!t||!t[o])throw new RangeError(`Unsupported selector: ${o}`);return t[o]}):r+" "+n}})}var kk=ru("."+nu,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Dg),ou=class{constructor(e,t,n,o){this.typeOver=o,this.bounds=null,this.text="";let{impreciseHead:i,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let l=i||s?[]:Ek(e),a=new el(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Rk(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=i&&i.node==l.focusNode&&i.offset==l.focusOffset||!Dc(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),c=s&&s.node==l.anchorNode&&s.offset==l.anchorOffset||!Dc(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=D.single(c,a)}}};function Lg(r,e){let t,{newSel:n}=e,o=r.state.selection.main,i=r.inputState.lastKeyTime>Date.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:l}=e.bounds,a=o.from,c=null;(i===8||H.android&&e.text.length<l-s)&&(a=o.to,c="end");let u=Mk(r.state.doc.sliceString(s,l,Kr),e.text,a-s,c);u&&(H.chrome&&i==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==Kr+Kr&&u.toB--,t={from:s+u.from,to:s+u.toA,insert:Y.of(e.text.slice(u.from,u.toB).split(Kr))})}else n&&(!r.hasFocus&&r.state.facet(al)||n.main.eq(o))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!o.empty&&n&&n.main.empty?t={from:o.from,to:o.to,insert:r.state.doc.slice(o.from,o.to)}:t&&t.from>=o.from&&t.to<=o.to&&(t.from!=o.from||t.to!=o.to)&&o.to-o.from-(t.to-t.from)<=4?t={from:o.from,to:o.to,insert:r.state.doc.slice(o.from,t.from).append(t.insert).append(r.state.doc.slice(t.to,o.to))}:(H.mac||H.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=D.single(n.main.anchor-1,n.main.head-1)),t={from:o.from,to:o.to,insert:Y.of([" "])}):H.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==`
|
|
25
|
-
`&&r.lineWrapping&&(n&&(n=D.single(n.main.anchor-1,n.main.head-1)),t={from:o.from,to:o.to,insert:Y.of([" "])}),t){let s=r.state;if(H.ios&&r.inputState.flushIOSKey(r)||H.android&&(t.from==o.from&&t.to==o.to&&t.insert.length==1&&t.insert.lines==2&&Jr(r.contentDOM,"Enter",13)||(t.from==o.from-1&&t.to==o.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from)&&Jr(r.contentDOM,"Backspace",8)||t.from==o.from&&t.to==o.to+1&&t.insert.length==0&&Jr(r.contentDOM,"Delete",46)))return!0;let l=t.insert.toString();if(r.state.facet(lg).some(u=>u(r,t.from,t.to,l)))return!0;r.inputState.composing>=0&&r.inputState.composing++;let a;if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&r.inputState.composing<0){let u=o.from<t.from?s.sliceDoc(o.from,t.from):"",h=o.to>t.to?s.sliceDoc(t.to,o.to):"";a=s.replaceSelection(r.state.toText(u+t.insert.sliceString(0,void 0,r.state.lineBreak)+h))}else{let u=s.changes(t),h=n&&n.main.to<=u.newLength?n.main:void 0;if(s.selection.ranges.length>1&&r.inputState.composing>=0&&t.to<=o.to&&t.to>=o.to-10){let f=r.state.sliceDoc(t.from,t.to),d=yg(r)||r.state.doc.lineAt(o.head),p=o.to-t.to,m=o.to-o.from;a=s.changeByRange(y=>{if(y.from==o.from&&y.to==o.to)return{changes:u,range:h||y.map(u)};let g=y.to-p,v=g-f.length;if(y.to-y.from!=m||r.state.sliceDoc(v,g)!=f||d&&y.to>=d.from&&y.from<=d.to)return{range:y};let w=s.changes({from:v,to:g,insert:t.insert}),x=y.to-o.to;return{changes:w,range:h?D.range(Math.max(0,h.anchor+x),Math.max(0,h.head+x)):y.map(w)}})}else a={changes:u,selection:h&&s.selection.replaceRange(h)}}let c="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,c+=".compose",r.inputState.compositionFirstChange&&(c+=".start",r.inputState.compositionFirstChange=!1)),r.dispatch(a,{scrollIntoView:!0,userEvent:c}),!0}else if(n&&!n.main.eq(o)){let s=!1,l="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(s=!0),l=r.inputState.lastSelectionOrigin),r.dispatch({selection:n,scrollIntoView:s,userEvent:l}),!0}else return!1}function Mk(r,e,t,n){let o=Math.min(r.length,e.length),i=0;for(;i<o&&r.charCodeAt(i)==e.charCodeAt(i);)i++;if(i==o&&r.length==e.length)return null;let s=r.length,l=e.length;for(;s>0&&l>0&&r.charCodeAt(s-1)==e.charCodeAt(l-1);)s--,l--;if(n=="end"){let a=Math.max(0,i-Math.min(s,l));t-=s+a-i}if(s<i&&r.length<e.length){let a=t<=i&&t>=s?i-t:0;i-=a,l=i+(l-s),s=i}else if(l<i){let a=t<=i&&t>=l?i-t:0;i-=a,s=i+(s-l),l=i}return{from:i,toA:s,toB:l}}function Ek(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:o,focusOffset:i}=r.observer.selectionRange;return t&&(e.push(new tl(t,n)),(o!=t||i!=n)&&e.push(new tl(o,i))),e}function Rk(r,e){if(r.length==0)return null;let t=r[0].pos,n=r.length==2?r[1].pos:t;return t>-1&&n>-1?D.single(t+e,n+e):null}var Ik={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ic=H.ie&&H.ie_version<=11,iu=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Lc,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(H.ie&&H.ie_version<=11||H.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),Ic&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM),this.resizeContent=new ResizeObserver(()=>this.view.requestMeasure()),this.resizeContent.observe(e.contentDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runScrollHandlers(this.view,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,o=this.selectionRange;if(n.state.facet(al)?n.root.activeElement!=this.dom:!Gs(n.dom,o))return;let i=o.anchorNode&&n.docView.nearest(o.anchorNode);if(i&&i.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!n.state.selection.main.empty&&o.focusNode&&Ys(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=H.safari&&e.root.nodeType==11&&IT(this.dom.ownerDocument)==this.dom&&Pk(this.view)||Qs(e.root);if(!t||this.selectionRange.eq(t))return!1;let n=Gs(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&OT(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Ik),Ic&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ic&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let o=()=>{let i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&Jr(this.dom,i.key,i.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(o)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,o=!1;for(let i of e){let s=this.readMutation(i);s&&(s.typeOver&&(o=!0),t==-1?{from:t,to:n}=s:(t=Math.min(s.from,t),n=Math.max(s.to,n)))}return{from:t,to:n,typeOver:o}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),o=this.selectionChanged&&Gs(this.dom,this.selectionRange);return e<0&&!o?null:(e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new ou(this.view,e,t,n))}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return!1;let n=this.view.state,o=Lg(this.view,t);return this.view.state==n&&this.view.update([]),o}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=Bm(t,e.previousSibling||e.target.previousSibling,-1),o=Bm(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:o?t.posBefore(o):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,n,o;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect(),(o=this.resizeContent)===null||o===void 0||o.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function Bm(r,e,t){for(;e;){let n=ne.get(e);if(n&&n.parent==r)return n;let o=e.parentNode;e=o!=r.dom?o:t>0?e.nextSibling:e.previousSibling}return null}function Pk(r){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(r.contentDOM.addEventListener("beforeinput",t,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let n=e.startContainer,o=e.startOffset,i=e.endContainer,s=e.endOffset,l=r.docView.domAtPos(r.state.selection.main.anchor);return Ys(l.node,l.offset,i,s)&&([n,o,i,s]=[i,s,n,o]),{anchorNode:n,anchorOffset:o,focusNode:i,focusOffset:s}}var j=class{constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=e.root||AT(e.parent)||document,this.viewState=new sl(e.state||Z.create(e)),this.plugins=this.state.facet(ti).map(t=>new oi(t));for(let t of this.plugins)t.update(this);this.observer=new iu(this),this.inputState=new Gc(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new rl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...e){let t=e.length==1&&e[0]instanceof he?e[0]:this.state.update(...e);this._dispatch(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,o,i=this.state;for(let f of e){if(f.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=f.state}if(this.destroyed){this.viewState.state=i;return}let s=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(Mg))?(this.inputState.notifiedFocused=s,l=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=Eg(i,s),a||(l=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(u=null)):this.observer.clear(),i.facet(Z.phrases)!=this.state.facet(Z.phrases))return this.setState(i);o=Yr.create(this,i,e),o.flags|=l;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection;h=new Qr(d.empty?d:D.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(wm)&&(h=d.value)}this.viewState.update(o,h),this.bidiCache=Xr.update(this.bidiCache,o.changes),o.empty||(this.updatePlugins(o),this.inputState.update(o)),t=this.docView.update(o),this.state.facet(ni)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(o.startState.facet($s)!=o.state.facet($s)&&(this.viewState.mustMeasureContent=!0),(t||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!o.empty)for(let f of this.state.facet(Hc))f(o);(a||u)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),u&&!Lg(this,u)&&c.force&&Jr(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new sl(e),this.plugins=e.facet(ti).map(n=>new oi(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new rl(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(ti),n=e.state.facet(ti);if(t!=n){let o=[];for(let i of n){let s=t.indexOf(i);if(s<0)o.push(new oi(i));else{let l=this.plugins[s];l.mustUpdate=e,o.push(l)}}for(let i of this.plugins)i.mustUpdate!=e&&i.destroy(this);this.plugins=o,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let o of this.plugins)o.mustUpdate=e;for(let o=0;o<this.plugins.length;o++)this.plugins[o].update(this)}measure(e=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,{scrollTop:o}=n,{scrollAnchorPos:i,scrollAnchorHeight:s}=this.viewState;o!=this.viewState.scrollTop&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(s<0)if(jm(n))i=-1,s=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(o);i=d.from,s=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return Ut(this.state,p),Hm}}),h=Yr.create(this,this.state,[]),f=!1;h.flags|=a,t?t.flags|=a:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h));for(let d=0;d<c.length;d++)if(u[d]!=Hm)try{let p=c[d];p.write&&p.write(u[d],this)}catch(p){Ut(this.state,p)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null;continue}else{let p=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-s;if(p>1||p<-1){o=n.scrollTop=o+p,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Hc))l(t)}get themeClasses(){return nu+" "+(this.state.facet(tu)?Pg:Ig)+" "+this.state.facet($s)}updateAttrs(){let e=_m(this,hg,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(al)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),_m(this,pu,t);let n=this.observer.ignore(()=>{let o=Fc(this.contentDOM,this.contentAttrs,t),i=Fc(this.dom,this.editorAttrs,e);return o||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let o of n.effects)if(o.is(j.announce)){t&&(this.announceDOM.textContent=""),t=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=o.value}}mountStyles(){this.styleModules=this.state.facet(ni),pt.mount(this.root,this.styleModules.concat(kk).reverse())}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Rc(this,e,Mm(this,e,t,n))}moveByGroup(e,t){return Rc(this,e,Mm(this,e,t,n=>ik(this,e.head,n)))}moveToLineBoundary(e,t,n=!0){return ok(this,e,t,n)}moveVertically(e,t,n){return Rc(this,e,sk(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),xg(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let o=this.state.doc.lineAt(e),i=this.bidiSpans(o),s=i[Tn.find(i,e-o.from,-1,t)];return hu(n,s.dir==pe.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(cg)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Dk)return mg(e.length);let t=this.textDirectionAt(e.from);for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t)return o.order;let n=qT(e.text,t);return this.bidiCache.push(new Xr(e.from,e.to,t,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{qm(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return wm.of(new Qr(typeof e=="number"?D.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return yt.define(()=>({}),{eventHandlers:e})}static theme(e,t){let n=pt.newName(),o=[$s.of(n),ni.of(ru(`.${n}`,e))];return t&&t.dark&&o.push(tu.of(!0)),o}static baseTheme(e){return ir.lowest(ni.of(ru("."+nu,e,Dg)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),o=n&&ne.get(n)||ne.get(e);return((t=o==null?void 0:o.rootView)===null||t===void 0?void 0:t.view)||null}};j.styleModule=ni;j.inputHandler=lg;j.focusChangeEffect=ag;j.perLineTextDirection=cg;j.exceptionSink=sg;j.updateListener=Hc;j.editable=al;j.mouseSelectionStyle=ig;j.dragMovesSelection=og;j.clickAddsSelectionRange=rg;j.decorations=li;j.atomicRanges=mu;j.scrollMargins=fg;j.darkTheme=tu;j.contentAttributes=pu;j.editorAttributes=hg;j.lineWrapping=j.contentAttributes.of({class:"cm-lineWrapping"});j.announce=ie.define();var Dk=4096,Hm={},Xr=class{constructor(e,t,n,o){this.from=e,this.to=t,this.dir=n,this.order=o}static update(e,t){if(t.empty)return e;let n=[],o=e.length?e[e.length-1].dir:pe.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let s=e[i];s.dir==o&&!t.touchesRange(s.from,s.to)&&n.push(new Xr(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.order))}return n}};function _m(r,e,t){for(let n=r.state.facet(e),o=n.length-1;o>=0;o--){let i=n[o],s=typeof i=="function"?i(r):i;s&&Vc(s,t)}return t}var Lk=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Ak(r,e){let t=r.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let o,i,s,l;for(let a=0;a<t.length-1;++a){let c=t[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(n="Alt-"+n),i&&(n="Ctrl-"+n),l&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Us(r,e,t){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t!==!1&&e.shiftKey&&(r="Shift-"+r),r}var Ok=ir.default(j.domEventHandlers({keydown(r,e){return Bk(Nk(e.state),r,e,"editor")}})),Zr=U.define({enables:Ok}),zm=new WeakMap;function Nk(r){let e=r.facet(Zr),t=zm.get(e);return t||zm.set(e,t=Fk(e.reduce((n,o)=>n.concat(o),[]))),t}var Cn=null,Vk=4e3;function Fk(r,e=Lk){let t=Object.create(null),n=Object.create(null),o=(s,l)=>{let a=n[s];if(a==null)n[s]=l;else if(a!=l)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},i=(s,l,a,c,u)=>{var h,f;let d=t[s]||(t[s]=Object.create(null)),p=l.split(/ (?!$)/).map(g=>Ak(g,e));for(let g=1;g<p.length;g++){let v=p.slice(0,g).join(" ");o(v,!0),d[v]||(d[v]={preventDefault:!0,stopPropagation:!1,run:[w=>{let x=Cn={view:w,prefix:v,scope:s};return setTimeout(()=>{Cn==x&&(Cn=null)},Vk),!0}]})}let m=p.join(" ");o(m,!1);let y=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(h=d._any)===null||h===void 0?void 0:h.run)===null||f===void 0?void 0:f.slice())||[]});a&&y.run.push(a),c&&(y.preventDefault=!0),u&&(y.stopPropagation=!0)};for(let s of r){let l=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of l){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let h in u)u[h].run.push(s.any)}let a=s[e]||s.key;if(a)for(let c of l)i(c,a,s.run,s.preventDefault,s.stopPropagation),s.shift&&i(c,"Shift-"+a,s.shift,s.preventDefault,s.stopPropagation)}return t}function Bk(r,e,t,n){let o=fm(e),i=zt(o,0),s=tr(i)==o.length&&o!=" ",l="",a=!1,c=!1,u=!1;Cn&&Cn.view==t&&Cn.scope==n&&(l=Cn.prefix+" ",wg.indexOf(e.keyCode)<0&&(c=!0,Cn=null));let h=new Set,f=y=>{if(y){for(let g of y.run)if(!h.has(g)&&(h.add(g),g(t,e)))return y.stopPropagation&&(u=!0),!0;y.preventDefault&&(y.stopPropagation&&(u=!0),c=!0)}return!1},d=r[n],p,m;return d&&(f(d[l+Us(o,e,!s)])?a=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&(p=rn[e.keyCode])&&p!=o?(f(d[l+Us(p,e,!0)])||e.shiftKey&&(m=Gr[e.keyCode])!=o&&m!=p&&f(d[l+Us(m,e,!1)]))&&(a=!0):s&&e.shiftKey&&f(d[l+Us(o,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&u&&e.stopPropagation(),a}var fr=class{constructor(e,t,n,o,i){this.className=e,this.left=t,this.top=n,this.width=o,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let o=e.coordsAtPos(n.head,n.assoc||1);if(!o)return[];let i=Ag(e);return[new fr(t,o.left-i.left,o.top-i.top,null,o.bottom-o.top)]}else return Hk(e,t,n)}};function Ag(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==pe.LTR?e.left:e.right-r.scrollDOM.clientWidth)-r.scrollDOM.scrollLeft,top:e.top-r.scrollDOM.scrollTop}}function Wm(r,e,t){let n=D.cursor(e);return{from:Math.max(t.from,r.moveToLineBoundary(n,!1,!0).from),to:Math.min(t.to,r.moveToLineBoundary(n,!0,!0).from),type:me.Text}}function Hk(r,e,t){if(t.to<=r.viewport.from||t.from>=r.viewport.to)return[];let n=Math.max(t.from,r.viewport.from),o=Math.min(t.to,r.viewport.to),i=r.textDirection==pe.LTR,s=r.contentDOM,l=s.getBoundingClientRect(),a=Ag(r),c=s.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),h=l.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=l.right-(u?parseInt(u.paddingRight):0),d=Uc(r,n),p=Uc(r,o),m=d.type==me.Text?d:null,y=p.type==me.Text?p:null;if(m&&(r.lineWrapping||d.widgetLineBreaks)&&(m=Wm(r,n,m)),y&&(r.lineWrapping||p.widgetLineBreaks)&&(y=Wm(r,o,y)),m&&y&&m.from==y.from)return v(w(t.from,t.to,m));{let S=m?w(t.from,null,m):x(d,!1),b=y?w(null,t.to,y):x(p,!0),C=[];return(m||d).to<(y||p).from-(m&&y?1:0)||d.widgetLineBreaks>1&&S.bottom+r.defaultLineHeight/2<b.top?C.push(g(h,S.bottom,f,b.top)):S.bottom<b.top&&r.elementAtHeight((S.bottom+b.top)/2).type==me.Text&&(S.bottom=b.top=(S.bottom+b.top)/2),v(S).concat(C).concat(v(b))}function g(S,b,C,k){return new fr(e,S-a.left,b-a.top-.01,C-S,k-b+.01)}function v({top:S,bottom:b,horizontal:C}){let k=[];for(let E=0;E<C.length;E+=2)k.push(g(C[E],S,C[E+1],b));return k}function w(S,b,C){let k=1e9,E=-1e9,R=[];function M(V,B,W,O,N){let F=r.coordsAtPos(V,V==C.to?-2:2),G=r.coordsAtPos(W,W==C.from?2:-2);!F||!G||(k=Math.min(F.top,G.top,k),E=Math.max(F.bottom,G.bottom,E),N==pe.LTR?R.push(i&&B?h:F.left,i&&O?f:G.right):R.push(!i&&O?h:G.left,!i&&B?f:F.right))}let P=S!=null?S:C.from,I=b!=null?b:C.to;for(let V of r.visibleRanges)if(V.to>P&&V.from<I)for(let B=Math.max(V.from,P),W=Math.min(V.to,I);;){let O=r.state.doc.lineAt(B);for(let N of r.bidiSpans(O)){let F=N.from+O.from,G=N.to+O.from;if(F>=W)break;G>B&&M(Math.max(F,B),S==null&&F<=P,Math.min(G,W),b==null&&G>=I,N.dir)}if(B=O.to+1,B>=W)break}return R.length==0&&M(P,S==null,I,b==null,r.textDirection),{top:k,bottom:E,horizontal:R}}function x(S,b){let C=l.top+(b?S.top:S.bottom);return{top:C,bottom:C,horizontal:[]}}}function _k(r,e){return r.constructor==e.constructor&&r.eq(e)}var su=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(js)!=e.state.facet(js)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&e.view.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(js);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!_k(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let o of e)o.update&&t&&o.constructor&&this.drawn[n].constructor&&o.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(o.draw(),t);for(;t;){let o=t.nextSibling;t.remove(),t=o}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},js=U.define();function Og(r){return[yt.define(e=>new su(e,r)),js.of(r)]}var Ng=!H.ios,ci=U.define({combine(r){return sr(r,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function gu(r={}){return[ci.of(r),zk,Wk,$k,ug.of(!0)]}function Vg(r){return r.startState.facet(ci)!=r.state.facet(ci)}var zk=Og({above:!0,markers(r){let{state:e}=r,t=e.facet(ci),n=[];for(let o of e.selection.ranges){let i=o==e.selection.main;if(o.empty?!i||Ng:t.drawRangeCursor){let s=i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=o.empty?o:D.cursor(o.head,o.head>o.anchor?-1:1);for(let a of fr.forRange(r,s,l))n.push(a)}}return n},update(r,e){r.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Vg(r);return t&&$m(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){$m(e.state,r)},class:"cm-cursorLayer"});function $m(r,e){e.style.animationDuration=r.facet(ci).cursorBlinkRate+"ms"}var Wk=Og({above:!1,markers(r){return r.state.selection.ranges.map(e=>e.empty?[]:fr.forRange(r,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||Vg(r)},class:"cm-selectionLayer"}),Fg={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Ng&&(Fg[".cm-line"].caretColor="transparent !important");var $k=ir.highest(j.theme(Fg));function Um(r,e,t,n,o){e.lastIndex=0;for(let i=r.iterRange(t,n),s=t,l;!i.next().done;s+=i.value.length)if(!i.lineBreak)for(;l=e.exec(i.value);)o(s+l.index,l)}function Uk(r,e){let t=r.visibleRanges;if(t.length==1&&t[0].from==r.viewport.from&&t[0].to==r.viewport.to)return t;let n=[];for(let{from:o,to:i}of t)o=Math.max(r.state.doc.lineAt(o).from,o-e),i=Math.min(r.state.doc.lineAt(i).to,i+e),n.length&&n[n.length-1].to>=o?n[n.length-1].to=i:n.push({from:o,to:i});return n}var lu=class{constructor(e){let{regexp:t,decoration:n,decorate:o,boundary:i,maxLength:s=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,o)this.addMatch=(l,a,c,u)=>o(u,c,c+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,c,u)=>{let h=n(l,a,c);h&&u(c,c+l[0].length,h)};else if(n)this.addMatch=(l,a,c,u)=>u(c,c+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=i,this.maxLength=s}createDeco(e){let t=new Wt,n=t.add.bind(t);for(let{from:o,to:i}of Uk(e,this.maxLength))Um(e.state.doc,this.regexp,o,i,(s,l)=>this.addMatch(l,e,s,n));return t.finish()}updateDeco(e,t){let n=1e9,o=-1;return e.docChanged&&e.changes.iterChanges((i,s,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(n=Math.min(l,n),o=Math.max(a,o))}),e.viewportChanged||o-n>1e3?this.createDeco(e.view):o>-1?this.updateRange(e.view,t.map(e.changes),n,o):t}updateRange(e,t,n,o){for(let i of e.visibleRanges){let s=Math.max(i.from,n),l=Math.min(i.to,o);if(l>s){let a=e.state.doc.lineAt(s),c=a.to<l?e.state.doc.lineAt(l):a,u=Math.max(i.from,a.from),h=Math.min(i.to,c.to);if(this.boundary){for(;s>a.from;s--)if(this.boundary.test(a.text[s-1-a.from])){u=s;break}for(;l<c.to;l++)if(this.boundary.test(c.text[l-c.from])){h=l;break}}let f=[],d,p=(m,y,g)=>f.push(g.range(m,y));if(a==c)for(this.regexp.lastIndex=u-a.from;(d=this.regexp.exec(a.text))&&d.index<h-a.from;)this.addMatch(d,e,d.index+a.from,p);else Um(e.state.doc,this.regexp,u,h,(m,y)=>this.addMatch(y,e,m,p));t=t.update({filterFrom:u,filterTo:h,filter:(m,y)=>m<u||y>h,add:f})}}return t}},au=/x/.unicode!=null?"gu":"g",Gk=new RegExp(`[\0-\b
|
|
26
|
-
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,au),qk={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},Pc=null;function Kk(){var r;if(Pc==null&&typeof document<"u"&&document.body){let e=document.body.style;Pc=((r=e.tabSize)!==null&&r!==void 0?r:e.MozTabSize)!=null}return Pc||!1}var Js=U.define({combine(r){let e=sr(r,{render:null,specialChars:Gk,addSpecialChars:null});return(e.replaceTabs=!Kk())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,au)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,au)),e}});function yu(r={}){return[Js.of(r),jk()]}var Gm=null;function jk(){return Gm||(Gm=yt.fromClass(class{constructor(r){this.view=r,this.decorations=Se.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(r.state.facet(Js)),this.decorations=this.decorator.createDeco(r)}makeDecorator(r){return new lu({regexp:r.specialChars,decoration:(e,t,n)=>{let{doc:o}=t.state,i=zt(e[0],0);if(i==9){let s=o.lineAt(n),l=t.state.tabSize,a=lr(s.text,l,n-s.from);return Se.replace({widget:new uu((l-a%l)*this.view.defaultCharacterWidth)})}return this.decorationCache[i]||(this.decorationCache[i]=Se.replace({widget:new cu(r,i)}))},boundary:r.replaceTabs?void 0:/[^]/})}update(r){let e=r.state.facet(Js);r.startState.facet(Js)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(r.view)):this.decorations=this.decorator.updateDeco(r,this.decorations)}},{decorations:r=>r.decorations}))}var Jk="\u2022";function Qk(r){return r>=32?Jk:r==10?"\u2424":String.fromCharCode(9216+r)}var cu=class extends ln{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Qk(this.code),n=e.state.phrase("Control character")+" "+(qk[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,n,t);if(o)return o;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}},uu=class extends ln{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};var lW=j.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var an=class extends Lt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};an.prototype.elementClass="";an.prototype.toDOM=void 0;an.prototype.mapMode=Ne.TrackBefore;an.prototype.startSide=an.prototype.endSide=-1;an.prototype.point=!0;var Yk=0,bt=class{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=Yk++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new bt([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new eo;return t=>t.modified.indexOf(e)>-1?t:eo.get(t.base||t,t.modified.concat(e).sort((n,o)=>n.id-o.id))}},Xk=0,eo=class{constructor(){this.instances=[],this.id=Xk++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&Zk(t,l.modified));if(n)return n;let o=[],i=new bt(o,e,t);for(let l of t)l.instances.push(i);let s=eM(t);for(let l of e.set)if(!l.modified.length)for(let a of s)o.push(eo.get(l,a));return i}};function Zk(r,e){return r.length==e.length&&r.every((t,n)=>t==e[n])}function eM(r){let e=[[]];for(let t=0;t<r.length;t++)for(let n=0,o=e.length;n<o;n++)e.push(e[n].concat(r[t]));return e.sort((t,n)=>n.length-t.length)}function hi(r){let e=Object.create(null);for(let t in r){let n=r[t];Array.isArray(n)||(n=[n]);for(let o of t.split(" "))if(o){let i=[],s=2,l=o;for(let h=0;;){if(l=="..."&&h>0&&h+3==o.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+o);if(i.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==o.length)break;let d=o[h++];if(h==o.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+o);l=o.slice(h)}let a=i.length-1,c=i[a];if(!c)throw new RangeError("Invalid path: "+o);let u=new to(n,s,a>0?i.slice(0,a):null);e[c]=u.sort(e[c])}}return _g.add(e)}var _g=new J,to=class{constructor(e,t,n,o){this.tags=e,this.mode=t,this.context=n,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};to.empty=new to([],2,null);function wu(r,e){let t=Object.create(null);for(let i of r)if(!Array.isArray(i.tag))t[i.tag.id]=i.class;else for(let s of i.tag)t[s.id]=i.class;let{scope:n,all:o=null}=e||{};return{style:i=>{let s=o;for(let l of i)for(let a of l.set){let c=t[a.id];if(c){s=s?s+" "+c:c;break}}return s},scope:n}}function tM(r,e){let t=null;for(let n of r){let o=n.style(e);o&&(t=t?t+" "+o:o)}return t}function zg(r,e,t,n=0,o=r.length){let i=new xu(n,Array.isArray(e)?e:[e],t);i.highlightRange(r.cursor(),n,o,"",i.highlighters),i.flush(o)}var xu=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,o,i){let{type:s,from:l,to:a}=e;if(l>=n||a<=t)return;s.isTop&&(i=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=o,u=nM(e)||to.empty,h=tM(i,u.tags);if(h&&(c&&(c+=" "),c+=h,u.mode==1&&(o+=(o?" ":"")+h)),this.startSpan(Math.max(t,l),c),u.opaque)return;let f=e.tree&&e.tree.prop(J.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(y=>!y.scope||y.scope(f.tree.type)),m=e.firstChild();for(let y=0,g=l;;y++){let v=y<f.overlay.length?f.overlay[y]:null,w=v?v.from+l:a,x=Math.max(t,g),S=Math.min(n,w);if(x<S&&m)for(;e.from<S&&(this.highlightRange(e,x,S,o,i),this.startSpan(Math.min(S,e.to),c),!(e.to>=w||!e.nextSibling())););if(!v||w>n)break;g=v.to+l,g>t&&(this.highlightRange(d.cursor(),Math.max(t,v.from+l),Math.min(n,g),"",p),this.startSpan(Math.min(n,g),c))}m&&e.parent()}else if(e.firstChild()){f&&(o="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,o,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function nM(r){let e=r.type.prop(_g);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}var A=bt.define,cl=A(),En=A(),Bg=A(En),Hg=A(En),Rn=A(),ul=A(Rn),bu=A(Rn),jt=A(),dr=A(jt),qt=A(),Kt=A(),vu=A(),ui=A(vu),hl=A(),L={comment:cl,lineComment:A(cl),blockComment:A(cl),docComment:A(cl),name:En,variableName:A(En),typeName:Bg,tagName:A(Bg),propertyName:Hg,attributeName:A(Hg),className:A(En),labelName:A(En),namespace:A(En),macroName:A(En),literal:Rn,string:ul,docString:A(ul),character:A(ul),attributeValue:A(ul),number:bu,integer:A(bu),float:A(bu),bool:A(Rn),regexp:A(Rn),escape:A(Rn),color:A(Rn),url:A(Rn),keyword:qt,self:A(qt),null:A(qt),atom:A(qt),unit:A(qt),modifier:A(qt),operatorKeyword:A(qt),controlKeyword:A(qt),definitionKeyword:A(qt),moduleKeyword:A(qt),operator:Kt,derefOperator:A(Kt),arithmeticOperator:A(Kt),logicOperator:A(Kt),bitwiseOperator:A(Kt),compareOperator:A(Kt),updateOperator:A(Kt),definitionOperator:A(Kt),typeOperator:A(Kt),controlOperator:A(Kt),punctuation:vu,separator:A(vu),bracket:ui,angleBracket:A(ui),squareBracket:A(ui),paren:A(ui),brace:A(ui),content:jt,heading:dr,heading1:A(dr),heading2:A(dr),heading3:A(dr),heading4:A(dr),heading5:A(dr),heading6:A(dr),contentSeparator:A(jt),list:A(jt),quote:A(jt),emphasis:A(jt),strong:A(jt),link:A(jt),monospace:A(jt),strikethrough:A(jt),inserted:A(),deleted:A(),changed:A(),invalid:A(),meta:hl,documentMeta:A(hl),annotation:A(hl),processingInstruction:A(hl),definition:bt.defineModifier(),constant:bt.defineModifier(),function:bt.defineModifier(),standard:bt.defineModifier(),local:bt.defineModifier(),special:bt.defineModifier()},hW=wu([{tag:L.link,class:"tok-link"},{tag:L.heading,class:"tok-heading"},{tag:L.emphasis,class:"tok-emphasis"},{tag:L.strong,class:"tok-strong"},{tag:L.keyword,class:"tok-keyword"},{tag:L.atom,class:"tok-atom"},{tag:L.bool,class:"tok-bool"},{tag:L.url,class:"tok-url"},{tag:L.labelName,class:"tok-labelName"},{tag:L.inserted,class:"tok-inserted"},{tag:L.deleted,class:"tok-deleted"},{tag:L.literal,class:"tok-literal"},{tag:L.string,class:"tok-string"},{tag:L.number,class:"tok-number"},{tag:[L.regexp,L.escape,L.special(L.string)],class:"tok-string2"},{tag:L.variableName,class:"tok-variableName"},{tag:L.local(L.variableName),class:"tok-variableName tok-local"},{tag:L.definition(L.variableName),class:"tok-variableName tok-definition"},{tag:L.special(L.variableName),class:"tok-variableName2"},{tag:L.definition(L.propertyName),class:"tok-propertyName tok-definition"},{tag:L.typeName,class:"tok-typeName"},{tag:L.namespace,class:"tok-namespace"},{tag:L.className,class:"tok-className"},{tag:L.macroName,class:"tok-macroName"},{tag:L.propertyName,class:"tok-propertyName"},{tag:L.operator,class:"tok-operator"},{tag:L.comment,class:"tok-comment"},{tag:L.meta,class:"tok-meta"},{tag:L.invalid,class:"tok-invalid"},{tag:L.punctuation,class:"tok-punctuation"}]);var Su,no=new J;function rM(r){return U.define({combine:r?e=>e.concat(r):void 0})}var oM=new J,rt=class{constructor(e,t,n=[],o=""){this.data=e,this.name=o,Z.prototype.hasOwnProperty("tree")||Object.defineProperty(Z.prototype,"tree",{get(){return Fe(this)}}),this.parser=t,this.extension=[oo.of(this),Z.languageData.of((i,s,l)=>{let a=Wg(i,s,l),c=a.type.prop(no);if(!c)return[];let u=i.facet(c),h=a.type.prop(oM);if(h){let f=a.resolve(s-a.from,l);for(let d of h)if(d.test(f,i)){let p=i.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return Wg(e,t,n).type.prop(no)==this.data}findRegions(e){let t=e.facet(oo);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],o=(i,s)=>{if(i.prop(no)==this.data){n.push({from:s,to:s+i.length});return}let l=i.prop(J.mounted);if(l){if(l.tree.prop(no)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+s,to:a.to+s});else n.push({from:s,to:s+i.length});return}else if(l.overlay){let a=n.length;if(o(l.tree,l.overlay[0].from+s),n.length>a)return}}for(let a=0;a<i.children.length;a++){let c=i.children[a];c instanceof le&&o(c,i.positions[a]+s)}};return o(Fe(e),0),n}get allowsNesting(){return!0}};rt.setState=ie.define();function Wg(r,e,t){let n=r.facet(oo),o=Fe(r).topNode;if(!n||n.allowsNesting)for(let i=o;i;i=i.enter(e,t,ye.ExcludeBuffers))i.type.isTop&&(o=i);return o}var In=class extends rt{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=rM(e.languageData);return new In(t,e.parser.configure({props:[no.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new In(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Fe(r){let e=r.field(rt.state,!1);return e?e.tree:le.empty}var Mu=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},fi=null,ro=class{constructor(e,t,n=[],o,i,s,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=o,this.treeLen=i,this.viewport=s,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new ro(e,t,[],le.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Mu(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=le.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let o=Date.now()+e;e=()=>Date.now()>o}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let o=this.parse.advance();if(o)if(this.fragments=this.withoutTempSkipped(Ht.addTree(o,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=o,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Ht.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=fi;fi=this;try{return e()}finally{fi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=$g(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:o,treeLen:i,viewport:s,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,u,h,f)=>a.push({fromA:c,toA:u,fromB:h,toB:f})),n=Ht.applyChanges(n,a),o=le.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),h=e.mapPos(c.to,-1);u<h&&l.push({from:u,to:h})}}}return new ro(this.parser,t,n,o,i,s,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:o,to:i}=this.skipped[n];o<e.to&&i>e.from&&(this.fragments=$g(this.fragments,o,i),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Dr{createParse(t,n,o){let i=o[0].from,s=o[o.length-1].to;return{parsedPos:i,advance(){let a=fi;if(a){for(let c of o)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=s,new le(ke.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return fi}};function $g(r,e,t){return Ht.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}var Pn=class{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Pn(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=ro.create(e.facet(oo).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Pn(n)}};rt.state=qe.define({create:Pn.init,update(r,e){for(let t of e.effects)if(t.is(rt.setState))return t.value;return e.startState.facet(oo)!=e.state.facet(oo)?Pn.init(e.state):r.apply(e)}});var qg=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(qg=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Cu=typeof navigator<"u"&&(!((Su=navigator.scheduling)===null||Su===void 0)&&Su.isInputPending)?()=>navigator.scheduling.isInputPending():null,iM=yt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(rt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(rt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=qg(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:o}}=this.view,i=n.field(rt.state);if(i.tree==i.context.tree&&i.context.isDone(o+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Cu?Math.max(25,e.timeRemaining()-5):1e9),l=i.context.treeLen<o&&n.doc.length>o+1e3,a=i.context.work(()=>Cu&&Cu()||Date.now()>s,o+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:rt.setState.of(new Pn(i.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ut(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),oo=U.define({combine(r){return r.length?r[0]:null},enables:r=>[rt.state,iM,j.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]});var sM=U.define(),pi=U.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function mi(r){let e=r.facet(pi);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function gi(r,e){let t="",n=r.tabSize,o=r.facet(pi)[0];if(o==" "){for(;e>=n;)t+=" ",e-=n;o=" "}for(let i=0;i<e;i++)t+=o;return t}function Du(r,e){r instanceof Z&&(r=new pr(r));for(let n of r.state.facet(sM)){let o=n(r,e);if(o!==void 0)return o}let t=Fe(r.state);return t?aM(r,t,e):null}var pr=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=mi(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:o,simulateDoubleBreak:i}=this.options;return o!=null&&o>=n.from&&o<=n.to?i&&o==e?{text:"",from:e}:(t<0?o<e:o<=e)?{text:n.text.slice(o-n.from),from:o}:{text:n.text.slice(0,o-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:o}=this.lineAt(e,t);return n.slice(e-o,Math.min(n.length,e+100-o))}column(e,t=1){let{text:n,from:o}=this.lineAt(e,t),i=this.countColumn(n,e-o),s=this.options.overrideIndentation?this.options.overrideIndentation(o):-1;return s>-1&&(i+=s-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return lr(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:o}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let s=i(o);if(s>-1)return s}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},lM=new J;function aM(r,e,t){return Kg(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,r)}function cM(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function uM(r){let e=r.type.prop(lM);if(e)return e;let t=r.firstChild,n;if(t&&(n=t.type.prop(J.closedBy))){let o=r.lastChild,i=o&&n.indexOf(o.name)>-1;return s=>pM(s,!0,1,void 0,i&&!cM(s)?o.from:void 0)}return r.parent==null?hM:null}function Kg(r,e,t){for(;r;r=r.parent){let n=uM(r);if(n)return n(di.create(t,e,r))}return null}function hM(){return 0}var di=class extends pr{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new di(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(fM(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?Kg(e,this.pos,this.base):0}};function fM(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function dM(r){let e=r.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let o=r.options.simulateBreak,i=r.state.doc.lineAt(t.from),s=o==null||o<=i.from?i.to:Math.min(i.to,o);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped)return a.from<s?t:null;l=a.to}}function pM(r,e,t,n,o){let i=r.textAfter,s=i.match(/^\s*/)[0].length,l=n&&i.slice(s,s+n.length)==n||o==r.pos+s,a=e?dM(r):null;return a?l?r.column(a.from):r.column(a.to):r.baseIndent+(l?0:r.unit*t)}var cn=class{constructor(e,t){this.specs=e;let n;function o(l){let a=pt.newName();return(n||(n=Object.create(null)))["."+a]=l,a}let i=typeof t.all=="string"?t.all:t.all?o(t.all):void 0,s=t.scope;this.scope=s instanceof rt?l=>l.prop(no)==s.data:s?l=>l==s:void 0,this.style=wu(e.map(l=>({tag:l.tag,class:l.class||o(Object.assign({},l,{tag:null}))})),{all:i}).style,this.module=n?new pt(n):null,this.themeType=t.themeType}static define(e,t){return new cn(e,t||{})}},Eu=U.define(),jg=U.define({combine(r){return r.length?[r[0]]:null}});function Tu(r){let e=r.facet(Eu);return e.length?e:r.facet(jg)}function yi(r,e){let t=[mM],n;return r instanceof cn&&(r.module&&t.push(j.styleModule.of(r.module)),n=r.themeType),e!=null&&e.fallback?t.push(jg.of(r)):n?t.push(Eu.computeN([j.darkTheme],o=>o.facet(j.darkTheme)==(n=="dark")?[r]:[])):t.push(Eu.of(r)),t}var Ru=class{constructor(e){this.markCache=Object.create(null),this.tree=Fe(e.state),this.decorations=this.buildDeco(e,Tu(e.state))}update(e){let t=Fe(e.state),n=Tu(e.state),o=n!=Tu(e.startState);t.length<e.view.viewport.to&&!o&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||o)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return Se.none;let n=new Wt;for(let{from:o,to:i}of e.visibleRanges)zg(this.tree,t,(s,l,a)=>{n.add(s,l,this.markCache[a]||(this.markCache[a]=Se.mark({class:a})))},o,i);return n.finish()}},mM=ir.high(yt.fromClass(Ru,{decorations:r=>r.decorations})),Lu=cn.define([{tag:L.meta,color:"#404740"},{tag:L.link,textDecoration:"underline"},{tag:L.heading,textDecoration:"underline",fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.keyword,color:"#708"},{tag:[L.atom,L.bool,L.url,L.contentSeparator,L.labelName],color:"#219"},{tag:[L.literal,L.inserted],color:"#164"},{tag:[L.string,L.deleted],color:"#a11"},{tag:[L.regexp,L.escape,L.special(L.string)],color:"#e40"},{tag:L.definition(L.variableName),color:"#00f"},{tag:L.local(L.variableName),color:"#30a"},{tag:[L.typeName,L.namespace],color:"#085"},{tag:L.className,color:"#167"},{tag:[L.special(L.variableName),L.macroName],color:"#256"},{tag:L.definition(L.propertyName),color:"#00c"},{tag:L.comment,color:"#940"},{tag:L.invalid,color:"#f00"}]);var gM=1e4,yM="()[]{}";var bM=new J;function Iu(r,e,t){let n=r.prop(e<0?J.openedBy:J.closedBy);if(n)return n;if(r.name.length==1){let o=t.indexOf(r.name);if(o>-1&&o%2==(e<0?1:0))return[t[o+e]]}return null}function Pu(r){let e=r.type.prop(bM);return e?e(r.node):r}function mr(r,e,t,n={}){let o=n.maxScanDistance||gM,i=n.brackets||yM,s=Fe(r),l=s.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=Iu(a.type,t,i);if(c&&a.from<a.to){let u=Pu(a);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return xM(r,e,t,a,u,c,i)}}return vM(r,e,t,s,l.type,o,i)}function xM(r,e,t,n,o,i,s){let l=n.parent,a={from:o.from,to:o.to},c=0,u=l==null?void 0:l.cursor();if(u&&(t<0?u.childBefore(n.from):u.childAfter(n.to)))do if(t<0?u.to<=n.from:u.from>=n.to){if(c==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let h=Pu(u);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Iu(u.type,t,s))c++;else if(Iu(u.type,-t,s)){if(c==0){let h=Pu(u);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:a,matched:!1}}function vM(r,e,t,n,o,i,s){let l=t<0?r.sliceDoc(e-1,e):r.sliceDoc(e,e+1),a=s.indexOf(l);if(a<0||a%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=r.doc.iterRange(e,t>0?r.doc.length:0),h=0;for(let f=0;!u.next().done&&f<=i;){let d=u.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,y=t>0?d.length:-1;m!=y;m+=t){let g=s.indexOf(d[m]);if(!(g<0||n.resolveInner(p+m,1).type!=o))if(g%2==0==t>0)h++;else{if(h==1)return{start:c,end:{from:p+m,to:p+m+1},matched:g>>1==a>>1};h--}}t>0&&(f+=d.length)}return u.done?{start:c,matched:!1}:null}var wM=Object.create(null),Ug=[ke.none];var Gg=[],SM=Object.create(null);for(let[r,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])SM[r]=CM(wM,e);function ku(r,e){Gg.indexOf(r)>-1||(Gg.push(r),console.warn(e))}function CM(r,e){let t=null;for(let i of e.split(".")){let s=r[i]||L[i];s?typeof s=="function"?t?t=s(t):ku(i,`Modifier ${i} used at start of tag`):t?ku(i,`Tag ${i} used as modifier`):t=s:ku(i,`Unknown highlighting tag ${i}`)}if(!t)return 0;let n=e.replace(/ /g,"_"),o=ke.define({id:Ug.length,name:n,props:[hi({[n]:t})]});return Ug.push(o),o.id}var fl={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},gr=ie.define({map(r,e){let t=e.mapPos(r,-1,Ne.TrackAfter);return t==null?void 0:t}}),Ou=new class extends Lt{};Ou.startSide=1;Ou.endSide=-1;var Yg=qe.define({create(){return oe.empty},update(r,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,n=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(n,-1)&&(r=oe.empty)}r=r.map(e.changes);for(let t of e.effects)t.is(gr)&&(r=r.update({add:[Ou.range(t.value,t.value+1)]}));return r}});function Xg(){return[EM,Yg]}var Au="()[]{}<>";function TM(r){for(let e=0;e<Au.length;e+=2)if(Au.charCodeAt(e)==r)return Au.charAt(e+1);return Qp(r<128?r:r+1)}function kM(r,e){return r.languageDataAt("closeBrackets",e)[0]||fl}var MM=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),EM=j.inputHandler.of((r,e,t,n)=>{if((MM?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let o=r.state.selection.main;if(n.length>2||n.length==2&&tr(zt(n,0))==1||e!=o.from||t!=o.to)return!1;let i=RM(r.state,n);return i?(r.dispatch(i),!0):!1});function RM(r,e){let t=kM(r,r.selection.main.head),n=t.brackets||fl.brackets;for(let o of n){let i=TM(zt(o,0));if(e==o)return i==o?DM(r,o,n.indexOf(o+o+o)>-1,t):IM(r,o,i,t.before||fl.before);if(e==i&&Zg(r,r.selection.main.from))return PM(r,o,i)}return null}function Zg(r,e){let t=!1;return r.field(Yg).between(0,r.doc.length,n=>{n==e&&(t=!0)}),t}function Nu(r,e){let t=r.sliceString(e,e+2);return t.slice(0,tr(zt(t,0)))}function IM(r,e,t,n){let o=null,i=r.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:t,from:s.to}],effects:gr.of(s.to+e.length),range:D.range(s.anchor+e.length,s.head+e.length)};let l=Nu(r.doc,s.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:s.head},effects:gr.of(s.head+e.length),range:D.cursor(s.head+e.length)}:{range:o=s}});return o?null:r.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function PM(r,e,t){let n=null,o=r.changeByRange(i=>i.empty&&Nu(r.doc,i.head)==t?{changes:{from:i.head,to:i.head+t.length,insert:t},range:D.cursor(i.head+t.length)}:n={range:i});return n?null:r.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function DM(r,e,t,n){let o=n.stringPrefixes||fl.stringPrefixes,i=null,s=r.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:gr.of(l.to+e.length),range:D.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=Nu(r.doc,a),u;if(c==e){if(Jg(r,a))return{changes:{insert:e+e,from:a},effects:gr.of(a+e.length),range:D.cursor(a+e.length)};if(Zg(r,a)){let f=t&&r.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+f.length,insert:f},range:D.cursor(a+f.length)}}}else{if(t&&r.sliceDoc(a-2*e.length,a)==e+e&&(u=Qg(r,a-2*e.length,o))>-1&&Jg(r,u))return{changes:{insert:e+e+e+e,from:a},effects:gr.of(a+e.length),range:D.cursor(a+e.length)};if(r.charCategorizer(a)(c)!=Ge.Word&&Qg(r,a,o)>-1&&!LM(r,a,e,o))return{changes:{insert:e+e,from:a},effects:gr.of(a+e.length),range:D.cursor(a+e.length)}}return{range:i=l}});return i?null:r.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Jg(r,e){let t=Fe(r).resolveInner(e+1);return t.parent&&t.from==e}function LM(r,e,t,n){let o=Fe(r).resolveInner(e,-1),i=n.reduce((s,l)=>Math.max(s,l.length),0);for(let s=0;s<5;s++){let l=r.sliceDoc(o.from,Math.min(o.to,o.from+t.length+i)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let u=o.firstChild;for(;u&&u.from==o.from&&u.to-u.from>t.length+a;){if(r.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}function Qg(r,e,t){let n=r.charCategorizer(e);if(n(r.sliceDoc(e-1,e))!=Ge.Word)return e;for(let o of t){let i=e-o.length;if(r.sliceDoc(i,e)==o&&n(r.sliceDoc(i-1,i))!=Ge.Word)return i}return-1}var AM=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),n=Wu(r.state,t.from);return n.line?OM(r):n.block?VM(r):!1};function zu(r,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let o=r(e,t);return o?(n(t.update(o)),!0):!1}}var OM=zu(HM,0);var NM=zu(ly,0);var VM=zu((r,e)=>ly(r,e,BM(e)),0);function Wu(r,e){let t=r.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var bi=50;function FM(r,{open:e,close:t},n,o){let i=r.sliceDoc(n-bi,n),s=r.sliceDoc(o,o+bi),l=/\s*$/.exec(i)[0].length,a=/^\s*/.exec(s)[0].length,c=i.length-l;if(i.slice(c-e.length,c)==e&&s.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:o+a,margin:a&&1}};let u,h;o-n<=2*bi?u=h=r.sliceDoc(n,o):(u=r.sliceDoc(n,n+bi),h=r.sliceDoc(o-bi,o));let f=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(h)[0].length,p=h.length-d-t.length;return u.slice(f,f+e.length)==e&&h.slice(p,p+t.length)==t?{open:{pos:n+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:o-d-t.length,margin:/\s/.test(h.charAt(p-1))?1:0}}:null}function BM(r){let e=[];for(let t of r.selection.ranges){let n=r.doc.lineAt(t.from),o=t.to<=n.to?n:r.doc.lineAt(t.to),i=e.length-1;i>=0&&e[i].to>n.from?e[i].to=o.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:o.to})}return e}function ly(r,e,t=e.selection.ranges){let n=t.map(i=>Wu(e,i.from).block);if(!n.every(i=>i))return null;let o=t.map((i,s)=>FM(e,n[s],i.from,i.to));if(r!=2&&!o.every(i=>i))return{changes:e.changes(t.map((i,s)=>o[s]?[]:[{from:i.from,insert:n[s].open+" "},{from:i.to,insert:" "+n[s].close}]))};if(r!=1&&o.some(i=>i)){let i=[];for(let s=0,l;s<o.length;s++)if(l=o[s]){let a=n[s],{open:c,close:u}=l;i.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:i}}return null}function HM(r,e,t=e.selection.ranges){let n=[],o=-1;for(let{from:i,to:s}of t){let l=n.length,a=1e9,c=Wu(e,i).line;if(c){for(let u=i;u<=s;){let h=e.doc.lineAt(u);if(h.from>o&&(i==s||s>h.from)){o=h.from;let f=/^\s*/.exec(h.text)[0].length,d=f==h.length,p=h.text.slice(f,f+c.length)==c?f:-1;f<h.text.length&&f<a&&(a=f),n.push({line:h,comment:p,token:c,indent:f,empty:d,single:!1})}u=h.to+1}if(a<1e9)for(let u=l;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=a);n.length==l+1&&(n[l].single=!0)}}if(r!=2&&n.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:l,token:a,indent:c,empty:u,single:h}of n)(h||!u)&&i.push({from:l.from+c,insert:a+" "});let s=e.changes(i);return{changes:s,selection:e.selection.map(s,1)}}else if(r!=1&&n.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:l,token:a}of n)if(l>=0){let c=s.from+l,u=c+a.length;s.text[u-s.from]==" "&&u++,i.push({from:c,to:u})}return{changes:i}}return null}var Fu=tt.define(),_M=tt.define(),zM=U.define(),ay=U.define({combine(r){return sr(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,o)=>e(n,o)||t(n,o)})}});function WM(r){let e=0;return r.iterChangedRanges((t,n)=>e=n),e}var cy=qe.define({create(){return vt.empty},update(r,e){let t=e.state.facet(ay),n=e.annotation(Fu);if(n){let a=e.docChanged?D.single(WM(e.changes)):void 0,c=Be.fromTransaction(e,a),u=n.side,h=u==0?r.undone:r.done;return c?h=pl(h,h.length,t.minDepth,c):h=dy(h,e.startState.selection),new vt(u==0?n.rest:h,u==0?h:n.rest)}let o=e.annotation(_M);if((o=="full"||o=="before")&&(r=r.isolate()),e.annotation(he.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let i=Be.fromTransaction(e),s=e.annotation(he.time),l=e.annotation(he.userEvent);return i?r=r.addChanges(i,s,l,t,e):e.selection&&(r=r.addSelection(e.startState.selection,s,l,t.newGroupDelay)),(o=="full"||o=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new vt(r.done.map(Be.fromJSON),r.undone.map(Be.fromJSON))}});function uy(r={}){return[cy,ay.of(r),j.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?hy:e.inputType=="historyRedo"?Bu:null;return n?(e.preventDefault(),n(t)):!1}})]}function ml(r,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let o=t.field(cy,!1);if(!o)return!1;let i=o.pop(r,t,e);return i?(n(i),!0):!1}}var hy=ml(0,!1),Bu=ml(1,!1),$M=ml(0,!0),UM=ml(1,!0);var Be=class{constructor(e,t,n,o,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=o,this.selectionsAfter=i}setSelAfter(e){return new Be(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new Be(e.changes&&ue.fromJSON(e.changes),[],e.mapped&&et.fromJSON(e.mapped),e.startSelection&&D.fromJSON(e.startSelection),e.selectionsAfter.map(D.fromJSON))}static fromTransaction(e,t){let n=xt;for(let o of e.startState.facet(zM)){let i=o(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new Be(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,xt)}static selection(e){return new Be(void 0,xt,void 0,void 0,e)}};function pl(r,e,t,n){let o=e+1>t+20?e-t-1:0,i=r.slice(o,e);return i.push(n),i}function GM(r,e){let t=[],n=!1;return r.iterChangedRanges((o,i)=>t.push(o,i)),e.iterChangedRanges((o,i,s,l)=>{for(let a=0;a<t.length;){let c=t[a++],u=t[a++];l>=c&&s<=u&&(n=!0)}}),n}function qM(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function fy(r,e){return r.length?e.length?r.concat(e):r:e}var xt=[],KM=200;function dy(r,e){if(r.length){let t=r[r.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-KM));return n.length&&n[n.length-1].eq(e)?r:(n.push(e),pl(r,r.length-1,1e9,t.setSelAfter(n)))}else return[Be.selection([e])]}function jM(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Vu(r,e){if(!r.length)return r;let t=r.length,n=xt;for(;t;){let o=JM(r[t-1],e,n);if(o.changes&&!o.changes.empty||o.effects.length){let i=r.slice(0,t);return i[t-1]=o,i}else e=o.mapped,t--,n=o.selectionsAfter}return n.length?[Be.selection(n)]:xt}function JM(r,e,t){let n=fy(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(e)):xt,t);if(!r.changes)return Be.selection(n);let o=r.changes.map(e),i=e.mapDesc(r.changes,!0),s=r.mapped?r.mapped.composeDesc(i):i;return new Be(o,ie.mapEffects(r.effects,e),s,r.startSelection.map(i),n)}var QM=/^(input\.type|delete)($|\.)/,vt=class{constructor(e,t,n=0,o=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=o}isolate(){return this.prevTime?new vt(this.done,this.undone):this}addChanges(e,t,n,o,i){let s=this.done,l=s[s.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||QM.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<o.newGroupDelay&&o.joinToEvent(i,GM(l.changes,e.changes))||n=="input.type.compose")?s=pl(s,s.length-1,o.minDepth,new Be(e.changes.compose(l.changes),fy(e.effects,l.effects),l.mapped,l.startSelection,xt)):s=pl(s,s.length,o.minDepth,e),new vt(s,xt,t,n)}addSelection(e,t,n,o){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:xt;return i.length>0&&t-this.prevTime<o&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&qM(i[i.length-1],e)?this:new vt(dy(this.done,e),this.undone,t,n)}addMapping(e){return new vt(Vu(this.done,e),Vu(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let o=e==0?this.done:this.undone;if(o.length==0)return null;let i=o[o.length-1];if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Fu.of({side:e,rest:jM(o)}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let s=o.length==1?xt:o.slice(0,o.length-1);return i.mapped&&(s=Vu(s,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Fu.of({side:e,rest:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};vt.empty=new vt(xt,xt);var py=[{key:"Mod-z",run:hy,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Bu,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Bu,preventDefault:!0},{key:"Mod-u",run:$M,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:UM,preventDefault:!0}];function io(r,e){return D.create(r.ranges.map(e),r.mainIndex)}function Jt(r,e){return r.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ot({state:r,dispatch:e},t){let n=io(r.selection,t);return n.eq(r.selection)?!1:(e(Jt(r,n)),!0)}function gl(r,e){return D.cursor(e?r.to:r.from)}function my(r,e){return Ot(r,t=>t.empty?r.moveByChar(t,e):gl(t,e))}function He(r){return r.textDirectionAt(r.state.selection.main.head)==pe.LTR}var gy=r=>my(r,!He(r)),yy=r=>my(r,He(r));function by(r,e){return Ot(r,t=>t.empty?r.moveByGroup(t,e):gl(t,e))}var YM=r=>by(r,!He(r)),XM=r=>by(r,He(r));function ZM(r,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function yl(r,e,t){let n=Fe(r).resolveInner(e.head),o=t?J.closedBy:J.openedBy;for(let a=e.head;;){let c=t?n.childAfter(a):n.childBefore(a);if(!c)break;ZM(r,c,o)?n=c:a=t?c.to:c.from}let i=n.type.prop(o),s,l;return i&&(s=t?mr(r,n.from,1):mr(r,n.to,-1))&&s.matched?l=t?s.end.to:s.end.from:l=t?n.to:n.from,D.cursor(l,t?-1:1)}var e1=r=>Ot(r,e=>yl(r.state,e,!He(r))),t1=r=>Ot(r,e=>yl(r.state,e,He(r)));function xy(r,e){return Ot(r,t=>{if(!t.empty)return gl(t,e);let n=r.moveVertically(t,e);return n.head!=t.head?n:r.moveToLineBoundary(t,e)})}var vy=r=>xy(r,!1),wy=r=>xy(r,!0);function Sy(r){let e=r.scrollDOM.clientHeight<r.scrollDOM.scrollHeight-2,t=0,n=0,o;if(e){for(let i of r.state.facet(j.scrollMargins)){let s=i(r);s!=null&&s.top&&(t=Math.max(s==null?void 0:s.top,t)),s!=null&&s.bottom&&(n=Math.max(s==null?void 0:s.bottom,n))}o=r.scrollDOM.clientHeight-t-n}else o=(r.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(r.defaultLineHeight,o-5)}}function Cy(r,e){let t=Sy(r),{state:n}=r,o=io(n.selection,s=>s.empty?r.moveVertically(s,e,t.height):gl(s,e));if(o.eq(n.selection))return!1;let i;if(t.selfScroll){let s=r.coordsAtPos(n.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;s&&s.top>a&&s.bottom<c&&(i=j.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-a}))}return r.dispatch(Jt(n,o),{effects:i}),!0}var ey=r=>Cy(r,!1),Hu=r=>Cy(r,!0);function Dn(r,e,t){let n=r.lineBlockAt(e.head),o=r.moveToLineBoundary(e,t);if(o.head==e.head&&o.head!=(t?n.to:n.from)&&(o=r.moveToLineBoundary(e,t,!1)),!t&&o.head==n.from&&n.length){let i=/^\s*/.exec(r.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(o=D.cursor(n.from+i))}return o}var n1=r=>Ot(r,e=>Dn(r,e,!0)),r1=r=>Ot(r,e=>Dn(r,e,!1)),o1=r=>Ot(r,e=>Dn(r,e,!He(r))),i1=r=>Ot(r,e=>Dn(r,e,He(r))),s1=r=>Ot(r,e=>D.cursor(r.lineBlockAt(e.head).from,1)),l1=r=>Ot(r,e=>D.cursor(r.lineBlockAt(e.head).to,-1));function a1(r,e,t){let n=!1,o=io(r.selection,i=>{let s=mr(r,i.head,-1)||mr(r,i.head,1)||i.head>0&&mr(r,i.head-1,1)||i.head<r.doc.length&&mr(r,i.head+1,-1);if(!s||!s.end)return i;n=!0;let l=s.start.from==i.head?s.end.to:s.end.from;return t?D.range(i.anchor,l):D.cursor(l)});return n?(e(Jt(r,o)),!0):!1}var c1=({state:r,dispatch:e})=>a1(r,e,!1);function wt(r,e){let t=io(r.state.selection,n=>{let o=e(n);return D.range(n.anchor,o.head,o.goalColumn,o.bidiLevel||void 0)});return t.eq(r.state.selection)?!1:(r.dispatch(Jt(r.state,t)),!0)}function Ty(r,e){return wt(r,t=>r.moveByChar(t,e))}var ky=r=>Ty(r,!He(r)),My=r=>Ty(r,He(r));function Ey(r,e){return wt(r,t=>r.moveByGroup(t,e))}var u1=r=>Ey(r,!He(r)),h1=r=>Ey(r,He(r));var f1=r=>wt(r,e=>yl(r.state,e,!He(r))),d1=r=>wt(r,e=>yl(r.state,e,He(r)));function Ry(r,e){return wt(r,t=>r.moveVertically(t,e))}var Iy=r=>Ry(r,!1),Py=r=>Ry(r,!0);function Dy(r,e){return wt(r,t=>r.moveVertically(t,e,Sy(r).height))}var ty=r=>Dy(r,!1),ny=r=>Dy(r,!0),p1=r=>wt(r,e=>Dn(r,e,!0)),m1=r=>wt(r,e=>Dn(r,e,!1)),g1=r=>wt(r,e=>Dn(r,e,!He(r))),y1=r=>wt(r,e=>Dn(r,e,He(r))),b1=r=>wt(r,e=>D.cursor(r.lineBlockAt(e.head).from)),x1=r=>wt(r,e=>D.cursor(r.lineBlockAt(e.head).to)),ry=({state:r,dispatch:e})=>(e(Jt(r,{anchor:0})),!0),oy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.doc.length})),!0),iy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.selection.main.anchor,head:0})),!0),sy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),v1=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),w1=({state:r,dispatch:e})=>{let t=xl(r).map(({from:n,to:o})=>D.range(n,Math.min(o+1,r.doc.length)));return e(r.update({selection:D.create(t),userEvent:"select"})),!0},S1=({state:r,dispatch:e})=>{let t=io(r.selection,n=>{var o;let i=Fe(r).resolveInner(n.head,1);for(;!(i.from<n.from&&i.to>=n.to||i.to>n.to&&i.from<=n.from||!(!((o=i.parent)===null||o===void 0)&&o.parent));)i=i.parent;return D.range(i.to,i.from)});return e(Jt(r,t)),!0},C1=({state:r,dispatch:e})=>{let t=r.selection,n=null;return t.ranges.length>1?n=D.create([t.main]):t.main.empty||(n=D.create([D.cursor(t.main.head)])),n?(e(Jt(r,n)),!0):!1};function bl(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:n}=r,o=n.changeByRange(i=>{let{from:s,to:l}=i;if(s==l){let a=e(s);a<s?(t="delete.backward",a=dl(r,a,!1)):a>s&&(t="delete.forward",a=dl(r,a,!0)),s=Math.min(s,a),l=Math.max(l,a)}else s=dl(r,s,!1),l=dl(r,l,!0);return s==l?{range:i}:{changes:{from:s,to:l},range:D.cursor(s)}});return o.changes.empty?!1:(r.dispatch(n.update(o,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?j.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function dl(r,e,t){if(r instanceof j)for(let n of r.state.facet(j.atomicRanges).map(o=>o(r)))n.between(e,e,(o,i)=>{o<e&&i>e&&(e=t?i:o)});return e}var Ly=(r,e)=>bl(r,t=>{let{state:n}=r,o=n.doc.lineAt(t),i,s;if(!e&&t>o.from&&t<o.from+200&&!/[^ \t]/.test(i=o.text.slice(0,t-o.from))){if(i[i.length-1]==" ")return t-1;let l=lr(i,n.tabSize),a=l%mi(n)||mi(n);for(let c=0;c<a&&i[i.length-1-c]==" ";c++)t--;s=t}else s=Ve(o.text,t-o.from,e,e)+o.from,s==t&&o.number!=(e?n.doc.lines:1)&&(s+=e?1:-1);return s}),_u=r=>Ly(r,!1),Ay=r=>Ly(r,!0),Oy=(r,e)=>bl(r,t=>{let n=t,{state:o}=r,i=o.doc.lineAt(n),s=o.charCategorizer(n);for(let l=null;;){if(n==(e?i.to:i.from)){n==t&&i.number!=(e?o.doc.lines:1)&&(n+=e?1:-1);break}let a=Ve(i.text,n-i.from,e)+i.from,c=i.text.slice(Math.min(n,a)-i.from,Math.max(n,a)-i.from),u=s(c);if(l!=null&&u!=l)break;(c!=" "||n!=t)&&(l=u),n=a}return n}),Ny=r=>Oy(r,!1),T1=r=>Oy(r,!0),Vy=r=>bl(r,e=>{let t=r.lineBlockAt(e).to;return e<t?t:Math.min(r.state.doc.length,e+1)}),k1=r=>bl(r,e=>{let t=r.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)});var M1=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:Y.of(["",""])},range:D.cursor(n.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},E1=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(n=>{if(!n.empty||n.from==0||n.from==r.doc.length)return{range:n};let o=n.from,i=r.doc.lineAt(o),s=o==i.from?o-1:Ve(i.text,o-i.from,!1)+i.from,l=o==i.to?o+1:Ve(i.text,o-i.from,!0)+i.from;return{changes:{from:s,to:l,insert:r.doc.slice(o,l).append(r.doc.slice(s,o))},range:D.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function xl(r){let e=[],t=-1;for(let n of r.selection.ranges){let o=r.doc.lineAt(n.from),i=r.doc.lineAt(n.to);if(!n.empty&&n.to==i.from&&(i=r.doc.lineAt(n.to-1)),t>=o.number){let s=e[e.length-1];s.to=i.to,s.ranges.push(n)}else e.push({from:o.from,to:i.to,ranges:[n]});t=i.number+1}return e}function Fy(r,e,t){if(r.readOnly)return!1;let n=[],o=[];for(let i of xl(r)){if(t?i.to==r.doc.length:i.from==0)continue;let s=r.doc.lineAt(t?i.to+1:i.from-1),l=s.length+1;if(t){n.push({from:i.to,to:s.to},{from:i.from,insert:s.text+r.lineBreak});for(let a of i.ranges)o.push(D.range(Math.min(r.doc.length,a.anchor+l),Math.min(r.doc.length,a.head+l)))}else{n.push({from:s.from,to:i.from},{from:i.to,insert:r.lineBreak+s.text});for(let a of i.ranges)o.push(D.range(a.anchor-l,a.head-l))}}return n.length?(e(r.update({changes:n,scrollIntoView:!0,selection:D.create(o,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}var R1=({state:r,dispatch:e})=>Fy(r,e,!1),I1=({state:r,dispatch:e})=>Fy(r,e,!0);function By(r,e,t){if(r.readOnly)return!1;let n=[];for(let o of xl(r))t?n.push({from:o.from,insert:r.doc.slice(o.from,o.to)+r.lineBreak}):n.push({from:o.to,insert:r.lineBreak+r.doc.slice(o.from,o.to)});return e(r.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var P1=({state:r,dispatch:e})=>By(r,e,!1),D1=({state:r,dispatch:e})=>By(r,e,!0),L1=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(xl(e).map(({from:o,to:i})=>(o>0?o--:i<e.doc.length&&i++,{from:o,to:i}))),n=io(e.selection,o=>r.moveVertically(o,!0)).map(t);return r.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function A1(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Fe(r).resolveInner(e),n=t.childBefore(e),o=t.childAfter(e),i;return n&&o&&n.to<=e&&o.from>=e&&(i=n.type.prop(J.closedBy))&&i.indexOf(o.name)>-1&&r.doc.lineAt(n.to).from==r.doc.lineAt(o.from).from?{from:n.to,to:o.from}:null}var O1=Hy(!1),N1=Hy(!0);function Hy(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(o=>{let{from:i,to:s}=o,l=e.doc.lineAt(i),a=!r&&i==s&&A1(e,i);r&&(i=s=(s<=l.to?l:e.doc.lineAt(s)).to);let c=new pr(e,{simulateBreak:i,simulateDoubleBreak:!!a}),u=Du(c,i);for(u==null&&(u=/^\s*/.exec(e.doc.lineAt(i).text)[0].length);s<l.to&&/\s/.test(l.text[s-l.from]);)s++;a?{from:i,to:s}=a:i>l.from&&i<l.from+100&&!/\S/.test(l.text.slice(0,i))&&(i=l.from);let h=["",gi(e,u)];return a&&h.push(gi(e,c.lineIndent(l.from,-1))),{changes:{from:i,to:s,insert:Y.of(h)},range:D.cursor(i+1+h[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function $u(r,e){let t=-1;return r.changeByRange(n=>{let o=[];for(let s=n.from;s<=n.to;){let l=r.doc.lineAt(s);l.number>t&&(n.empty||n.to>l.from)&&(e(l,o,n),t=l.number),s=l.to+1}let i=r.changes(o);return{changes:o,range:D.range(i.mapPos(n.anchor,1),i.mapPos(n.head,1))}})}var V1=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),n=new pr(r,{overrideIndentation:i=>{let s=t[i];return s==null?-1:s}}),o=$u(r,(i,s,l)=>{let a=Du(n,i.from);if(a==null)return;/\S/.test(i.text)||(a=0);let c=/^\s*/.exec(i.text)[0],u=gi(r,a);(c!=u||l.from<i.from+c.length)&&(t[i.from]=a,s.push({from:i.from,to:i.from+c.length,insert:u}))});return o.changes.empty||e(r.update(o,{userEvent:"indent"})),!0},F1=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update($u(r,(t,n)=>{n.push({from:t.from,insert:r.facet(pi)})}),{userEvent:"input.indent"})),!0),B1=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update($u(r,(t,n)=>{let o=/^\s*/.exec(t.text)[0];if(!o)return;let i=lr(o,r.tabSize),s=0,l=gi(r,Math.max(0,i-mi(r)));for(;s<o.length&&s<l.length&&o.charCodeAt(s)==l.charCodeAt(s);)s++;n.push({from:t.from+s,to:t.from+o.length,insert:l.slice(s)})}),{userEvent:"delete.dedent"})),!0);var H1=[{key:"Ctrl-b",run:gy,shift:ky,preventDefault:!0},{key:"Ctrl-f",run:yy,shift:My},{key:"Ctrl-p",run:vy,shift:Iy},{key:"Ctrl-n",run:wy,shift:Py},{key:"Ctrl-a",run:s1,shift:b1},{key:"Ctrl-e",run:l1,shift:x1},{key:"Ctrl-d",run:Ay},{key:"Ctrl-h",run:_u},{key:"Ctrl-k",run:Vy},{key:"Ctrl-Alt-h",run:Ny},{key:"Ctrl-o",run:M1},{key:"Ctrl-t",run:E1},{key:"Ctrl-v",run:Hu}],_1=[{key:"ArrowLeft",run:gy,shift:ky,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:YM,shift:u1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:o1,shift:g1,preventDefault:!0},{key:"ArrowRight",run:yy,shift:My,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:XM,shift:h1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:i1,shift:y1,preventDefault:!0},{key:"ArrowUp",run:vy,shift:Iy,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ry,shift:iy},{mac:"Ctrl-ArrowUp",run:ey,shift:ty},{key:"ArrowDown",run:wy,shift:Py,preventDefault:!0},{mac:"Cmd-ArrowDown",run:oy,shift:sy},{mac:"Ctrl-ArrowDown",run:Hu,shift:ny},{key:"PageUp",run:ey,shift:ty},{key:"PageDown",run:Hu,shift:ny},{key:"Home",run:r1,shift:m1,preventDefault:!0},{key:"Mod-Home",run:ry,shift:iy},{key:"End",run:n1,shift:p1,preventDefault:!0},{key:"Mod-End",run:oy,shift:sy},{key:"Enter",run:O1},{key:"Mod-a",run:v1},{key:"Backspace",run:_u,shift:_u},{key:"Delete",run:Ay},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ny},{key:"Mod-Delete",mac:"Alt-Delete",run:T1},{mac:"Mod-Backspace",run:k1},{mac:"Mod-Delete",run:Vy}].concat(H1.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),Uu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e1,shift:f1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t1,shift:d1},{key:"Alt-ArrowUp",run:R1},{key:"Shift-Alt-ArrowUp",run:P1},{key:"Alt-ArrowDown",run:I1},{key:"Shift-Alt-ArrowDown",run:D1},{key:"Escape",run:C1},{key:"Mod-Enter",run:N1},{key:"Alt-l",mac:"Ctrl-l",run:w1},{key:"Mod-i",run:S1,preventDefault:!0},{key:"Mod-[",run:B1},{key:"Mod-]",run:F1},{key:"Mod-Alt-\\",run:V1},{key:"Shift-Mod-k",run:L1},{key:"Shift-Mod-\\",run:c1},{key:"Mod-/",run:AM},{key:"Alt-A",run:NM}].concat(_1);var z1=[...Uu,...py],W1=(()=>[yu(),uy(),gu(),Xg(),yi(Lu,{fallback:!0}),Zr.of(z1)])();import{isNumericColumn as GW}from"@vuu-ui/vuu-utils";var _y=[{label:"=",boost:10,type:"operator"},{label:"!=",boost:9,type:"operator"}],$1=[..._y,{label:"in",boost:6,type:"operator"},{label:"starts",boost:5,type:"operator"},{label:"ends",boost:4,type:"operator"}],U1=[..._y,{label:">",boost:8,type:"operator"},{label:"<",boost:7,type:"operator"}];import I5 from"classnames";import{useEffect as L5,useMemo as A5,useRef as O5}from"react";var r5=In.define({name:"VuuFilterQuery",parser:Go.configure({props:[hi({Identifier:L.variableName,String:L.string,Or:L.emphasis,Operator:L.operator})]})});var K1=cn.define([{tag:L.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:L.comment,color:"green",fontStyle:"italic"}]),j1=yi(K1);var J1=j.theme({"&":{color:"var(--vuuFilterEditor-color)",backgroundColor:"var(--vuuFilterEditor-background)",fontSize:"var(--vuuFilterEditor-fontSize)"},".cm-content":{caretColor:"var(--vuuFilterEditor-cursorColor)",padding:0},".cm-line":{lineHeight:"var(--vuuFilterEditor-lineHeight)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-scroller":{fontFamily:"var(--vuuFilterEditor-fontFamily)"},".cm-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",boxShadow:"var(--vuuFilterEditor-tooltipElevation)","&.cm-tooltip-autocomplete > ul":{fontFamily:"var(--vuuFilterEditor-fontFamily)",fontSize:"var(--vuuFilterEditor-fontSize)",maxHeight:"240px"},"&.cm-tooltip-autocomplete > ul > li":{alignItems:"center",display:"flex",height:"var(--vuuFilterEditor-suggestion-height)",padding:"0 3px",lineHeight:"var(--vuuFilterEditor-suggestion-height)"},"&.cm-tooltip-autocomplete li[aria-selected]":{background:"var(--vuuFilterEditor-suggestion-selectedBackground)",color:"var(--vuuFilterEditor-suggestion-selectedColor)"}},".cm-completionIcon":{height:"18px",flex:"0 0 16px"},".cm-completionLabel":{flex:"1 1 auto"},".cm-completionIcon-filter":{position:"relative","&:after":{background:"var(--salt-text-secondary-foreground)",content:"''","-webkit-mask":"var(--svg-filter) center center/13px 13px","-webkit-mask-repeat":"no-repeat",position:"absolute",height:"18px",left:"0px",top:"0px",width:"16px"}}},{dark:!1});import{useCallback as b5}from"react";import{jsx as X5,jsxs as Z5}from"react/jsx-runtime";import{useCallback as m$,useRef as g$}from"react";import{createEl as n$}from"@vuu-ui/vuu-utils";var vl=r=>{let e=localStorage.getItem(r);return e?JSON.parse(e):void 0};var wl=(r,e)=>{try{return localStorage.setItem(r,JSON.stringify(e)),e}catch{return}};import{getUniqueId as Q1}from"@vuu-ui/vuu-utils";var zy="layouts/metadata",Wy="layouts/layouts",so,Sl=class{constructor(e){ee(this,so,"api/vui");e&&z(this,so,e)}createLayout(e,t){return new Promise(n=>{Promise.all([this.loadLayouts(),this.loadMetadata()]).then(([o,i])=>{let s=Q1();this.appendAndPersist(s,e,t,o,i),n(s)})})}updateLayout(e,t,n){return new Promise((o,i)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([s,l])=>{let a=s.filter(u=>u.id!==e),c=l.filter(u=>u.id!==e);this.appendAndPersist(e,t,n,a,c),o()}).catch(s=>i(s))})}deleteLayout(e){return new Promise((t,n)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([o,i])=>{let s=o.filter(a=>a.id!==e),l=i.filter(a=>a.id!==e);this.saveLayoutsWithMetadata(s,l),t()}).catch(o=>n(o))})}loadLayout(e){return new Promise((t,n)=>{this.validateId(e,"layout").then(()=>this.loadLayouts()).then(o=>{let i=o.find(s=>s.id===e);t(i.json)}).catch(o=>n(o))})}loadMetadata(){return new Promise(e=>{let t=vl(zy);e(t||[])})}loadApplicationLayout(){return new Promise(e=>{let t=vl(T(this,so));e(t||Ho)})}saveApplicationLayout(e){return new Promise((t,n)=>{wl(T(this,so),e)?t():n(new Error("Layout failed to save"))})}loadLayouts(){return new Promise(e=>{let t=vl(Wy);e(t||[])})}appendAndPersist(e,t,n,o,i){o.push({id:e,json:n}),i.push({id:e,...t}),this.saveLayoutsWithMetadata(o,i)}saveLayoutsWithMetadata(e,t){wl(Wy,e),wl(zy,t)}async validateIds(e){return Promise.all([this.validateId(e,"metadata").catch(t=>t.message),this.validateId(e,"layout").catch(t=>t.message)]).then(t=>{let n=t.filter(o=>o!==void 0).join("; ");if(n)throw new Error(n)})}validateId(e,t){return new Promise((n,o)=>{(t==="metadata"?this.loadMetadata:this.loadLayouts)().then(s=>{switch(s.filter(a=>a.id===e).length){case 1:{n();break}case 0:{o(new Error(`No ${t} with ID ${e}`));break}default:o(new Error(`Non-unique ${t} with ID ${e}`))}})})}};so=new WeakMap;import _$,{useEffect as z$,useState as W$}from"react";import U$ from"classnames";import{Fragment as j$,jsx as J$,jsxs as K$}from"react/jsx-runtime";function $y(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(t=$y(r[e]))&&(n&&(n+=" "),n+=t);else for(e in r)r[e]&&(n&&(n+=" "),n+=e);return n}function yr(){for(var r,e,t=0,n="";t<arguments.length;)(r=arguments[t++])&&(e=$y(r))&&(n&&(n+=" "),n+=e);return n}var Y1=/[.*+?^${}()|[\]\\]/g;function Cl(r){return r.replace(Y1,"\\$&")}import{jsx as n8}from"react/jsx-runtime";import{createContext as X1,useContext as Z1}from"react";var eE=X1(typeof window<"u"?window:null);function un(){return Z1(eE)}import*as Tl from"react";import{jsx as c8}from"react/jsx-runtime";import{createContext as tE,useMemo as h8,useContext as nE}from"react";var rE=tE(null);function Uy(){return nE(rE)}var Gy,oE=(Gy=Tl.useInsertionEffect)!=null?Gy:Tl.useLayoutEffect,Gu=new WeakMap;function hn({testId:r,css:e,window:t}){let n=Uy();oE(()=>{var o,i;if(!t)return;let s=(o=Gu.get(t))!=null?o:new Map,l=(i=s.get(e))!=null?i:{styleElement:null,count:0};return l.styleElement==null?(l.styleElement=t.document.createElement("style"),l.styleElement.setAttribute("type","text/css"),l.styleElement.setAttribute("data-salt-style",r||""),l.styleElement.textContent=e,l.count=1,t.document.head.insertBefore(l.styleElement,n||t.document.head.firstChild)):(l.styleElement.textContent=e,l.count++),s.set(e,l),Gu.set(t,s),()=>{let a=Gu.get(t),c=a==null?void 0:a.get(e);c!=null&&c.styleElement&&(c.count--,c.count<1&&(t.document.head.removeChild(c.styleElement),c.styleElement=null,a==null||a.delete(e)))}},[r,e,t])}import"@salt-ds/core";import"react";import{jsx as b8}from"react/jsx-runtime";import{createContext as iE,cloneElement as v8,useContext as sE}from"react";var lE=iE(void 0);function qy(){let r=sE(lE);if(r)return r}function aE(r,...e){let t=new Set(r);for(let n of e)for(let o of n)t.add(o);return t}var xi="ArrowUp",vi="ArrowDown",Ky="ArrowLeft",jy="ArrowRight",qu="Enter",kl="Home",wi="End",Ku="PageUp",Ml="PageDown",Jy=" ",cE=new Set(["Enter","Delete"," "]),uE=new Set(["Tab"]),hE=new Set(["ArrowRight","ArrowLeft"]),Qy=new Set([kl,wi,Ku,Ml,vi,xi]),fE=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),dE=aE(cE,Qy,hE,fE,uE),El=r=>dE.has(r.key)?!1:r.key.length===1&&!r.ctrlKey&&!r.metaKey&&!r.altKey,Yy=({key:r})=>Qy.has(r);import{useState as kE,useRef as Il,useMemo as Pl,useCallback as St,isValidElement as ab}from"react";import{isValidElement as ju,Children as mE}from"react";var Xy=r=>null;var Zy=r=>null;var pE=r=>Object.prototype.toString.call(r)==="[object Object]";function lo(r){return typeof r=="string"?r:pE(r)?Object.prototype.hasOwnProperty.call(r,"label")?String(r.label):(console.warn(["itemToString: you've likely forgotten to set the label prop on the item object.","You can also provide your own `itemToString` implementation."].join(`
|
|
27
|
-
`)),""):String(r)}var Ju=(r,e)=>r!==null&&Object.prototype.hasOwnProperty.call(r,e),Qu=r=>Ju(r,"header"),eb=r=>Ju(r,"childNodes"),Si=(r,e)=>r&&Object.prototype.hasOwnProperty.call(r.props,e),tb=r=>{if(ju(r)){if(Si(r,"disabled"))return r.props.disabled===!0}else if(Ju(r,"disabled"))return r.disabled===!0;return!1},nb=r=>ju(r)&&Si(r,"focusable")?r.props.focusable:!0,rb=(r,e,t)=>{if(r.childNodes)return r.childNodes.length;if(r.header){let n=t+1,o=0;for(;n<e.length&&!e[n].header;)o++,n++;return o}else return 0},gE=r=>{if(typeof r.props.children=="string")return r.props.children;if(r.props.title)return r.props.title;if(r.props.label)return r.props.label},ob=r=>r.type===Zy||Si(r,"data-header"),ib=r=>r.type===Xy||Si(r,"data-group"),yE=r=>Si(r,"selectable")?r.props.selectable===!0:!ib(r)&&!ob(r),bE=r=>{if(ib(r)){let{props:{children:e}}=r;if(typeof e!="string")return Xu(e)}},xE=(r,e)=>{let t=[];return mE.forEach(r,n=>{ju(n)&&t.push(e(n))}),t},Yu=(r,e)=>{if(Array.isArray(r))return r.length===0&&(e!=null&&e.noChildrenLabel)?[{label:e.noChildrenLabel,value:null}]:r.map((t,n)=>{var o,i;return{childNodes:Yu(t.childNodes,e),description:t.description,expanded:t.expanded,value:t,label:(i=(o=e==null?void 0:e.itemToString)==null?void 0:o.call(e,t))!=null?i:lo(t)}});if(r)throw Error("list-child-items expects source to be an array")},Xu=r=>{if(r)return xE(r,e=>{let{"data-id":t,disabled:n,id:o=t,"data-expanded":i,expanded:s=i}=e.props;return{childNodes:bE(e),disabled:n,expanded:s,header:ob(e),id:o,label:gE(e),selectable:yE(e),value:e}})},vE=new Set(["/","-","."]),wE=r=>vE.has(r),sb=(r,e)=>e.startsWith(r)&&wE(e[r.length]),SE=new Set([".","/"]);function CE(r,e){return e.startsWith(r)?SE.has(e.charAt(r.length)):!1}function Rl(r,e,t){let n;return r.map(i=>i.id===e?{...i,...t}:CE(i.id,e)&&i.childNodes?(n=Rl(i.childNodes,e,t),{...i,childNodes:n}):i)}import"react";import"@salt-ds/core";var TE=r=>r&&r.replace(/^\s+/g,""),Zu=r=>new RegExp(`(${Cl(TE(r))})`,"gi"),lb=(r="",e=Zu)=>(t="")=>!!t.length&&!!r.length&&t.match(e(r))!==null;var ME={},cb=({children:r,id:e,label:t="",options:n=ME,source:o})=>{var i;let{getItemId:s}=n,[,l]=kE(null),a=qy(),c=Il([]),u=Il([]),h=Pl(()=>[],[]),f=Il((i=n.filterPattern)!=null?i:""),{getFilterRegex:d=Zu,noChildrenLabel:p,itemToString:m=lo}=n,y=St(O=>n.defaultExpanded||!1,[n.defaultExpanded]),g=St((O,N,F=1,G="",X=[],te=[],_e=[])=>(O.forEach((de,it,On)=>{var Vt,re;let se=de.header&&n.collapsibleHeaders,Me=de.childNodes&&n.collapsibleHeaders===!1,kt=!de.childNodes||de.childNodes.length===0,fo=Me||kt&&!se,po=G?`${G}.${it}`:`item-${it}`,mo=(Vt=de.id)!=null?Vt:s?s(it):`${e}-${po}`,Mt=fo?void 0:(re=de.expanded)!=null?re:y(mo),go={...de,childNodes:void 0,count:!Me&&Mt===void 0?0:rb(de,On,it),description:de.description,disabled:tb(de.value),focusable:nb(de.value)?void 0:!1,id:mo,index:N.value,expanded:Mt,level:F};if(X.push(go),te.push(go),_e.push(O[it].value),N.value+=1,de.childNodes){let[Ql]=g(de.childNodes,N,F+1,po,[],te,_e);go.childNodes=Ql}}),[X,_e,te]),[n.collapsibleHeaders,s,e,y]),v=St(()=>f.current?lb(f.current,d):null,[d]),w=St((O,N=v(),F=[],G={value:0})=>{let X=!1;for(let te of O)X&&!Qu(te)||(te.value!==null&&(N===null||N(m(te.value)))&&(F[G.value]=te,G.value+=1),X=!1,Qu(te)&&te.expanded===!1?X=!0:eb(te)&&te.expanded!==!1&&te.childNodes&&w(te.childNodes,N,F,G));return F},[v,m]),x=Pl(()=>a?h:Yu(o,{itemToString:m,noChildrenLabel:p})||Xu(r)||[],[a,h,o,m,p,r]),[S,b,C]=Pl(()=>a?[h,h,h]:g(x,{value:0}),[h,g,a,x]);u.current=C,Pl(()=>a?h:c.current=w(S),[h,w,S,a]);let k=Il(S),E=St((O="")=>{typeof O=="string"&&(f.current=O,c.current=w(S),l({}))},[S,w]),R=St((O,N=S)=>{let F=N.find(G=>{var X;return G.id===O||((X=G==null?void 0:G.childNodes)==null?void 0:X.length)&&sb(G.id,O)});if((F==null?void 0:F.id)===O)return b==null?void 0:b[F.index];if(F)return R(O,F.childNodes);throw Error(`useCollectionData itemById, id ${O} not found `)},[b,S]),M=St(O=>{let N=u.current.find(F=>ab(F.value)?F.label===O:F.value===O);if(N)return N;throw Error("useCollectionData toCollectionItem, item not found ")},[]),P=St(O=>{if(O===null)return null;if(Array.isArray(O)){let N=[];for(let F of O){let G=M(F);N.push(G)}return N}else if(O!==void 0)return M(O)},[M]),I=St(O=>{let N=F=>{let G=u.current.find(X=>ab(X.value)?X.label===F:X.value!==null&&m(X.value)===F);if(G)return G};if(O===null)return null;if(Array.isArray(O)){let F=[];for(let G of O){let X=N(G);X&&F.push(X)}return F}else if(O!==void 0)return N(O)},[m]),V=St(O=>{for(let N of k.current)if(O===N.value)return N.id;throw Error("useCollectionData itemToId, item not found")},[]),B=St(O=>{k.current=Rl(k.current,O.id,{expanded:!1}),c.current=w(k.current),l({})},[w]),W=St(O=>{k.current=Rl(k.current,O.id,{expanded:!0}),c.current=w(k.current),l({})},[w]);return a||{collapseGroupItem:B,data:c.current,expandGroupItem:W,setFilterPattern:E,itemById:R,itemToId:V,toCollectionItem:M,itemToCollectionItem:P,stringToCollectionItem:I}};import{useIsomorphicLayoutEffect as ub}from"@salt-ds/core";import{useRef as EE,useCallback as RE}from"react";var hb=["height"];var br=new WeakMap,fb=(r,e,t)=>{switch(t){case"height":return e.height;case"scrollHeight":return r.scrollHeight;case"scrollWidth":return r.scrollWidth;case"width":return e.width;default:return 0}},Dl=typeof ResizeObserver<"u"?new ResizeObserver(r=>{for(let e of r){let{target:t,contentRect:n}=e,o=br.get(t);if(o){let{onResize:i,measurements:s}=o,l=!1;for(let[a,c]of Object.entries(s)){let u=fb(t,n,a);u!==c&&(l=!0,s[a]=u)}l&&i&&i(s)}}}):null;function Ci(r,e,t,n=!1){let o=EE(e),i=RE(s=>{let l=s.getBoundingClientRect();return o.current.reduce((a,c)=>(a[c]=fb(s,l,c),a),{})},[]);ub(()=>{if(!Dl)return;let s=r.current,l=!1;async function a(){br.set(s,{measurements:{}}),l=!1;let{fonts:c}=document;if(c&&await c.ready,!l&&Dl){let u=br.get(s);if(u){let h=i(s);u.measurements=h,Dl.observe(s),n&&t(h)}}}if(s){if(br.has(s))throw Error("useResizeObserver attemping to observe same element twice");a()}return()=>{s&&br.has(s)&&(Dl.unobserve(s),br.delete(s),l=!0)}},[r,i]),ub(()=>{let s=r.current,l=br.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}import{jsxs as aR,jsx as xr,Fragment as cR}from"react/jsx-runtime";import{forwardRef as uR,useRef as ah,createElement as hR,isValidElement as fR,cloneElement as dR}from"react";import{makePrefixer as pR,useIdMemo as mR,useForkRef as gR}from"@salt-ds/core";import{useMemo as IE,useImperativeHandle as PE}from"react";var DE={scrollToIndex:r=>{},scrollToItem:r=>{},scrollTo:r=>{}},db=({collectionHook:r,forwardedRef:e,scrollableRef:t,scrollIntoView:n})=>{let o=IE(()=>({scrollToIndex:i=>{let s=r.data[i];s&&(n==null||n(s))},scrollToItem:i=>{let s=r.toCollectionItem(i);s&&(n==null||n(s))},scrollTo:i=>{t!=null&&t.current&&(t.current.scrollTop=i)}}),[r.data,r.toCollectionItem,n]);PE(e,()=>t.current?o:DE,[o])};import{useControlled as LE}from"@salt-ds/core";import{useRef as eh,useState as AE,useCallback as ao,useMemo as OE}from"react";var pb=r=>Array.isArray(r)?r.length>0:r!=null,mb=r=>Array.isArray(r)?r[0]:r;var nh=-2;function gb(r,e,t){return e===xi||e===wi?t>0?t-1:t:t===null?0:t===r-1?t:t+1}var th=(r,e)=>{let t=mb(e);return t?r.indexOf(t):-1},NE=(r,e,t,n)=>r===wi?n:r===kl?-1:e!==-1?e:t,bb=r=>{let e=document.getElementById(r.id);if(e)return e.getBoundingClientRect();throw Error(`useKeyboardNavigation.getItemRect no element found for item #${r==null?void 0:r.id}`)},VE=(r,e,t,n)=>{let{top:o}=e.getBoundingClientRect(),{scrollTop:i,clientHeight:s,scrollHeight:l}=r,a=t.length-1,c=Math.min(i+s,l-s);if(c!==i&&n<a){r.scrollTo(0,c);let u=n,h;do u+=1,h=bb(t[u]);while(h.top<o&&u<a);return u}},FE=async(r,e,t,n)=>{let{top:o}=e.getBoundingClientRect(),{scrollTop:i,clientHeight:s}=r,l=Math.max(i-s,0);if(l!==i&&n>0)return r.scrollTo(0,l),new Promise(a=>{requestAnimationFrame(()=>{let c=n,u;do c-=1,u=bb(t[c]);while(u.top>o&&c>0);a(c)})})},BE=r=>!r.header&&!r.childNodes,yb=r=>BE(r)||r.expanded!==void 0,xb=({containerRef:r,defaultHighlightedIndex:e=-1,disableHighlightOnFocus:t,highlightedIndex:n,indexPositions:o,onHighlight:i,onKeyboardNavigation:s,restoreLastFocus:l,selected:a})=>{let c=eh(-1),[,u]=AE({}),[h,f,d]=LE({controlled:n,default:e,name:"UseKeyboardNavigation"}),p=ao((k,E=!1)=>{i==null||i(k),f(k),E&&(c.current=k)},[i,f]),m=ao(async(k,E)=>{let{id:R}=o[E],M;if(R){let P=document.getElementById(R),{current:I}=r;P&&I&&(M=k.key===Ml?VE(I,P,o,E):await FE(I,P,o,E))}return M!=null?M:E},[r,o]),y=ao((k=vi,E=k===vi?-1:o.length)=>{if(o.length===0)return-1;{let R=th(o,a),M=NE(k,E,R,o.length),P=gb(o.length,k,M);if(P===0&&k===xi&&!yb(o[0]))return E;for(;((k===vi||k===kl)&&P<o.length||(k===xi||k===wi)&&P>0)&&!yb(o[P]);)P=gb(o.length,k,P);return P}},[o,a]),g=eh(!1),v=eh(!1),w=k=>v.current=k,x=ao(k=>{if(v.current)v.current=!1;else if(g.current=!0,o.length===0)p(nh);else if(h!==-1)u({});else if(l)if(c.current!==-1)p(c.current);else{let E=th(o,a);p(E!==-1?E:0)}else if(pb(a)){let E=th(o,a);p(E)}else t!==!0&&p(y())},[t,h,o,y,l,a,p]),S=ao(async k=>{let E=k.key===Ml||k.key===Ku?await m(k,h):y(k.key,h);E!==h&&p(E,!0),s==null||s(k,E)},[h,y,m,s,p]),b=ao(k=>{o.length>0&&Yy(k)?(k.preventDefault(),k.stopPropagation(),g.current=!0,S(k)):El(k)&&(g.current=!0)},[o,S]),C=OE(()=>({onBlur:k=>{let E=k.target.closest(".saltList"),R=k.relatedTarget;E&&!(E!=null&&E.contains(R))&&(g.current=!1,f(-1),l||(c.current=-1))},onFocus:x,onKeyDown:b,onMouseDownCapture:()=>{g.current=!1,w(!0)},onMouseMove:()=>{g.current&&(g.current=!1)},onMouseLeave:()=>{g.current=!1,w(!1),p(-1)}}),[x,b,l,f,p]);return{focusVisible:g.current?h:-1,controlledHighlighting:d,highlightedIndex:h,setHighlightedIndex:p,keyboardNavigation:g,listProps:C,setIgnoreFocus:w}};function vb(r,e){return Array.isArray(r)?r.includes(e):r===e}import{jsx as Ll,jsxs as WE}from"react/jsx-runtime";import{forwardRef as Tb}from"react";import{makePrefixer as $E,CheckboxIcon as UE}from"@salt-ds/core";import{jsx as rh,Fragment as HE}from"react/jsx-runtime";import{makePrefixer as _E}from"@salt-ds/core";import"react";var wb=`.saltHighlighter-highlight {
|
|
28
|
-
font-weight: var(--salt-text-fontWeight-strong); /* TODO: Check with design */
|
|
29
|
-
}
|
|
30
|
-
`;var zE=_E("saltHighlighter"),Sb=r=>{let{matchPattern:e,text:t=""}=r,n=un();hn({testId:"salt-hightligher",css:wb,window:n});let o=typeof e=="string"?new RegExp(`(${Cl(e)})`,"gi"):e;return o===void 0?rh(HE,{children:t}):rh("span",{children:t.split(o).map((i,s)=>i.match(o)?rh("strong",{className:zE("highlight"),children:i},`${s}-${i}`):i)})};var Cb=`.saltListItem {
|
|
31
|
-
/* Color */
|
|
32
|
-
--list-item-text-color: var(--salt-text-primary-foreground);
|
|
33
|
-
--list-item-background: var(--saltList-item-background, var(--salt-selectable-background));
|
|
34
|
-
/* --list-item-selected-focus-outlineColor: var(--salt-color-white); TODO: Check token with design */
|
|
35
|
-
--list-item-text-color-active: var(--salt-text-primary-foreground);
|
|
36
|
-
--list-item-background-active: var(--salt-selectable-background-selected);
|
|
37
|
-
--list-item-alignItems: center;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.saltListItem.saltHighlighted {
|
|
41
|
-
--saltCheckbox-icon-stroke: var(--salt-selectable-borderColor-hover);
|
|
42
|
-
--list-item-background: var(--salt-selectable-background-hover);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.saltListItemHeader {
|
|
46
|
-
font-weight: var(--salt-text-fontWeight-strong); /* TODO: Check token with design */
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.saltListItemHeader[data-sticky] {
|
|
50
|
-
position: sticky;
|
|
51
|
-
top: 0;
|
|
52
|
-
z-index: 1;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.saltListItem {
|
|
56
|
-
color: var(--list-item-text-color);
|
|
57
|
-
cursor: var(--saltList-item-cursor, pointer);
|
|
58
|
-
background: var(--saltList-item-background, var(--list-item-background));
|
|
59
|
-
font-size: var(--salt-text-fontSize);
|
|
60
|
-
text-align: var(--salt-text-textAlign);
|
|
61
|
-
line-height: var(--salt-text-lineHeight);
|
|
62
|
-
height: var(--saltList-item-height, var(--list-item-height, auto));
|
|
63
|
-
/* Replaced border-bottom with margin. In design spec, the height of the items should not include gap */
|
|
64
|
-
margin-bottom: var(--list-item-gap);
|
|
65
|
-
padding: 0 var(--salt-size-unit);
|
|
66
|
-
left: 0;
|
|
67
|
-
right: 0;
|
|
68
|
-
display: flex;
|
|
69
|
-
position: relative;
|
|
70
|
-
align-items: var(--list-item-alignItems);
|
|
71
|
-
white-space: nowrap;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.saltListItem:last-child {
|
|
75
|
-
margin-bottom: 0px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.saltListItem-checkbox {
|
|
79
|
-
--list-item-background-active: var(--salt-selectable-background);
|
|
80
|
-
--list-item-text-color-active: var(--salt-text-primary-foreground);
|
|
81
|
-
--list-item-text-padding: 0 0 0 var(--salt-size-unit);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.saltListItem[aria-selected="true"]:not(.saltListItem-checkbox) {
|
|
85
|
-
--list-item-background: var(--list-item-background-active);
|
|
86
|
-
color: var(--list-item-text-color-active);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.saltListItem.saltDisabled {
|
|
90
|
-
--list-item-text-color: var(--salt-text-primary-foreground-disabled);
|
|
91
|
-
cursor: var(--salt-selectable-cursor-disabled);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.saltListItem.saltFocusVisible {
|
|
95
|
-
outline-style: var(--salt-focused-outlineStyle);
|
|
96
|
-
outline-width: var(--salt-focused-outlineWidth);
|
|
97
|
-
outline-offset: -2px;
|
|
98
|
-
outline-color: var(--salt-focused-outlineColor);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.saltListItem.saltFocusVisible:after {
|
|
102
|
-
content: none;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.saltListItem[aria-selected="true"]:not(.saltListItem-checkbox).saltFocusVisible {
|
|
106
|
-
outline-color: var(--list-item-selected-focus-outlineColor);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.saltListItem-textWrapper {
|
|
110
|
-
flex: 1;
|
|
111
|
-
overflow: hidden;
|
|
112
|
-
padding: var(--list-item-text-padding, 0px);
|
|
113
|
-
white-space: nowrap;
|
|
114
|
-
text-overflow: ellipsis;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.saltListItem-proxy {
|
|
118
|
-
position: absolute !important;
|
|
119
|
-
visibility: hidden;
|
|
120
|
-
}
|
|
121
|
-
`;var Ti=$E("saltListItem"),oh=Tb(function(e,t){return Ll("div",{"aria-hidden":!0,className:yr(Ti(),Ti("proxy")),ref:t})}),ki=Tb(function({children:e,className:t,disabled:n,tabIndex:o,item:i,itemHeight:s,itemTextHighlightPattern:l,label:a,selectable:c,selected:u,showCheckbox:h,style:f,...d},p){let m=un();hn({testId:"salt-list-item",css:Cb,window:m});let y=yr(Ti(),t,{saltDisabled:n,[Ti("checkbox")]:h}),g=s!==void 0?{...f,height:s}:f;return WE("div",{className:y,...d,"aria-disabled":n||void 0,"aria-selected":u||void 0,ref:p,style:g,children:[h&&Ll(UE,{"aria-hidden":!0,checked:u}),e&&typeof e!="string"?e:l==null?Ll("span",{className:Ti("textWrapper"),children:a||e}):Ll(Sb,{matchPattern:l,text:a||e})]})});import{useRef as oR,useCallback as Al,isValidElement as lh}from"react";import"@salt-ds/core";import{useCallback as kb}from"react";var GE={},qE=r=>Array.isArray(r.childNodes),KE=r=>r.closest("[data-toggle],[aria-expanded]").dataset.toggle==="true",Mb=({collapsibleHeaders:r,collectionHook:e,highlightedIdx:t,onToggle:n})=>{let o=kb(l=>{if(l.key===jy||l.key===qu){let a=e.data[t];a&&a.expanded===!1&&a.value&&(l.preventDefault(),e.expandGroupItem(a),n==null||n(a.value))}if(l.key===Ky||l.key===qu){let a=e.data[t];a&&a.expanded&&a.value&&(l.preventDefault(),e.collapseGroupItem(a),n==null||n(a.value))}},[e.collapseGroupItem,e.data,e.expandGroupItem,t]),s={onClick:kb(l=>{console.log(`useCollapsibleGroups idx=${t}`);let a=e.data[t];console.log(l.target,l.currentTarget),a&&qE(a)&&KE(l.target)&&(l.stopPropagation(),l.preventDefault(),a.expanded===!1&&a.value?(e.expandGroupItem(a),n==null||n(a.value)):a.expanded===!0&&a.value&&(e.collapseGroupItem(a),n==null||n(a.value)))},[e.collapseGroupItem,e.data,e.expandGroupItem,t]),onKeyDown:o};return r?s:GE};function jE(r){if(r){let e=r.dataset.idx;if(e)return parseInt(e,10);if(e=r.ariaPosInSet)return parseInt(e,10)-1}return-1}var JE=r=>r.closest("[data-idx],[aria-posinset]"),Eb=r=>jE(JE(r));import{useControlled as QE}from"@salt-ds/core";import{useRef as YE,useCallback as Nt}from"react";var XE=["Enter"," "],ih=r=>r&&r.disabled!==!0&&r.selectable!==!1,Rb=(r,e)=>{var t,n;return((t=r.index)!=null?t:0)-((n=e.index)!=null?n:0)},Ib=({defaultSelected:r,disableSelection:e=!1,highlightedIdx:t,indexPositions:n,label:o="",onSelect:i,onSelectionChange:s,selected:l,selectionStrategy:a,selectionKeys:c=XE,tabToSelect:u})=>{let h=a==="deselectable",f=a==="multiple",d=a==="extended",p=YE(-1),m=Nt(I=>c.includes(I.key),[c]),y=Nt(()=>f||d?[]:null,[f,d]),[g,v]=QE({controlled:l,default:r!=null?r:y(),name:"UseSelection",state:"selected"}),w=Nt(I=>Array.isArray(g)?g.includes(I):g===I,[g]),x=Nt(I=>I,[]),S=Nt(I=>w(I)?null:I,[w]),b=Nt(I=>{let V=w(I)?g.filter(B=>B!==I):g.concat(I);return V.sort(Rb),V},[w,g]),C=Nt((I,V)=>{let B=V?g:[],[W]=g.slice(-1),O=W?n.indexOf(W):0,N=Math.min(I,O),F=Math.max(I,O),G=n.slice(N,F+1),X=[...new Set([...B,...G])];return X.sort(Rb),X},[n,g]),k=Nt((I,V,B,W,O)=>{let N;f?N=b(B):d?O&&!W?N=b(B):W?N=C(V,O):N=[B]:h?N=S(B):N=x(B),N!==g&&v(N),i==null||i(I,B),N!==g&&s&&s(I,N)},[f,d,h,g,i,b,C,S,x,v,s]),E=Nt(I=>{let V=n[t];ih(V)&&(m(I)||u&&I.key==="Tab")&&(I.key!=="Tab"&&I.preventDefault(),k(I,t,V,!1,I.ctrlKey||I.metaKey),d&&(p.current=t))},[n,t,m,u,k,d]),R=Nt((I,V)=>{if(d&&I.shiftKey){let B=n[V];ih(B)&&k(I,V,B,!0)}},[d,n,k]);return{listHandlers:{onClick:Nt(I=>{let V=n[t];!e&&ih(V)&&(I.preventDefault(),I.stopPropagation(),k(I,t,V,I.shiftKey,I.ctrlKey||I.metaKey),d&&(p.current=t))},[e,d,t,n,k]),onKeyDown:E,onKeyboardNavigation:R},selected:g,setSelected:v}};import{useRef as sh,useCallback as Pb}from"react";var Db=({disableTypeToSelect:r,highlightedIdx:e,highlightItemAtIndex:t,typeToNavigate:n,items:o,applyIncrementalSearch:i=!0})=>{let s=sh(null),l=sh(""),a=sh(-1),c=Pb(h=>{if(h||!i){let f=new RegExp(`^${l.current}`,"i"),d=o.findIndex(({label:p},m)=>m>a.current&&f.test(p));d===-1&&(d=o.findIndex(({label:p},m)=>m<=a.current&&f.test(p))),d!==-1&&t(d)}else l.current="",s.current=null,a.current=-1},[i,t,o]),u=Pb(h=>{let f=a.current!==-1;(El(h)||f&&h.key===Jy)&&n&&(h.preventDefault(),h.stopPropagation(),(a.current===-1||h.key===l.current)&&(a.current=e),s.current!==null&&(clearTimeout(s.current),s.current=null),h.key!==l.current&&(l.current+=h.key),i&&c(!0),s.current=window.setTimeout(()=>{c()},100))},[n,i,e,c]);return{onKeyDown:r?void 0:u}};import{useRef as Lb,useCallback as co}from"react";import{useIsomorphicLayoutEffect as ZE}from"@salt-ds/core";import"react/jsx-runtime";var Ab=["height"],eR=["height","scrollHeight"],tR=[],Ob={containerOnly:[eR,tR],withContent:[Ab,Ab]},nR=r=>r?Ob.containerOnly:Ob.withContent,Nb={current:null},rR=(r,e)=>{let{transform:t="none"}=getComputedStyle(r);if(t.startsWith("matrix")){let n=t.lastIndexOf(",");return parseInt(t.slice(n+1))}else{let n=r.offsetParent;if(n===e||e===null)return r.offsetTop;{let o=r.offsetTop;for(;n!==null&&n!==e;)o+=n.offsetTop,n=n.offsetParent;return o}}},Vb=({containerRef:r,contentRef:e=Nb,highlightedIdx:t=-1,indexPositions:n,stickyHeaders:o=!1})=>{let i=Lb(!1),s=Lb({height:0,contentHeight:0}),l=co(m=>{i.current=!0,r.current&&(r.current.scrollTop=m),setTimeout(()=>{i.current=!1})},[]),a=co(()=>l(0),[l]),c=co(()=>{l(s.current.contentHeight-s.current.height)},[l]),u=co(m=>{let y=e.current||r.current;if(m.id){let g=document.getElementById(m.id);if(g&&r.current){let{height:v}=s.current,w=g.ariaExpanded&&g.firstChild?g.firstChild:g,x=o?36:0,S=rR(w,y),b=w.offsetHeight,{scrollTop:C}=r.current,k=C+x,E=k+v-x;if(S+b>E||S<k){let R=S+b>E?C+(S+b)-E:S-x;l(R)}}}},[r,e,l,o]);ZE(()=>{let{height:m,contentHeight:y}=s.current,g=n[t];if(y>m&&g){let[v]=n,[w]=n.slice(-1);g===v?a():g===w?c():u(n[t])}},[t,n,u,c,a]);let h=co(({height:m,scrollHeight:y})=>{typeof m=="number"&&(s.current.height=m),typeof y=="number"&&(s.current.contentHeight=y)},[]),f=co(({height:m})=>{typeof m=="number"&&(s.current.contentHeight=m)},[]),[d,p]=nR(e===Nb);return Ci(r,d,h,!0),Ci(e,p,f,!0),{isScrolling:i,scrollIntoView:u}};var Fb=({collapsibleHeaders:r,collectionHook:e,containerRef:t,contentRef:n,defaultHighlightedIndex:o,defaultSelected:i,disabled:s,disableAriaActiveDescendant:l,disableHighlightOnFocus:a,disableTypeToSelect:c,highlightedIndex:u,label:h="",listHandlers:f,onSelect:d,onSelectionChange:p,onHighlight:m,onKeyboardNavigation:y,onKeyDown:g,restoreLastFocus:v,selected:w,selectionStrategy:x,selectionKeys:S,stickyHeaders:b,tabToSelect:C})=>{let k=oR(w||i),E=(re,se)=>{var Me,kt;(kt=(Me=F.listHandlers).onKeyboardNavigation)==null||kt.call(Me,re,se),y==null||y(re,se)},R=Al((re,se)=>{d&&(lh(se.value)?d(re,se.label):se.value!==null&&d(re,se.value))},[d]),M=Al((re,se)=>{p&&p(re,Array.isArray(se)?se.map(Me=>lh(Me.value)?Me.label:Me.value):se&&(lh(se.value)?se.label:se.value))},[p]),{highlightedIndex:P,listProps:{onKeyDown:I,onMouseMove:V,...B},setHighlightedIndex:W,...O}=xb({containerRef:t,defaultHighlightedIndex:o,disableHighlightOnFocus:a,highlightedIndex:u,indexPositions:e.data,label:h,onHighlight:m,onKeyboardNavigation:E,restoreLastFocus:v,selected:k.current}),N=Mb({collapsibleHeaders:r,highlightedIdx:P,collectionHook:e}),F=Ib({defaultSelected:i,highlightedIdx:P,indexPositions:e.data,label:h,onSelect:R,onSelectionChange:M,selected:w,selectionStrategy:x,selectionKeys:S,tabToSelect:C}),{onKeyDown:G}=Db({disableTypeToSelect:c,highlightedIdx:P,highlightItemAtIndex:W,typeToNavigate:!0,items:e.data}),X=Al(re=>{var se,Me,kt;re.defaultPrevented||G==null||G(re),I(re),re.defaultPrevented||(Me=(se=F.listHandlers).onKeyDown)==null||Me.call(se,re),re.defaultPrevented||(kt=N==null?void 0:N.onKeyDown)==null||kt.call(N,re),re.defaultPrevented||g==null||g(re)},[N,I,g,F.listHandlers,G]),{isScrolling:te,scrollIntoView:_e}=Vb({containerRef:t,contentRef:n,highlightedIdx:P,indexPositions:e.data,stickyHeaders:b}),de=Al(re=>{if(!te.current&&!s){V();let se=Eb(re.target);if(se!==P){let Me=e.data[se];!Me||Me.disabled?W(-1):W(se)}}},[te,s,W,V,P,e.data]),it=()=>{var re;return P===void 0||P===-1||l||(re=e.data[P])==null?void 0:re.id};k.current=F.selected;let On={"aria-activedescendant":it(),onBlur:B.onBlur,onFocus:B.onFocus,onKeyDown:X,onMouseDownCapture:B.onMouseDownCapture,onMouseLeave:B.onMouseLeave},Vt=f||{onClick:F.listHandlers.onClick,onMouseMove:de};return{focusVisible:O.focusVisible,controlledHighlighting:O.controlledHighlighting,highlightedIndex:P,keyboardNavigation:O.keyboardNavigation,listHandlers:Vt,listItemHeaderHandlers:N,listControlProps:On,scrollIntoView:_e,selected:F.selected,setHighlightedIndex:W,setIgnoreFocus:O.setIgnoreFocus,setSelected:F.setSelected}};import{useState as iR,useMemo as sR,useCallback as lR}from"react";import"@salt-ds/core";import"react/jsx-runtime";var Bb=({borderless:r,displayedItemCount:e,getItemHeight:t,height:n,itemCount:o,itemGapSize:i,itemHeight:s,rowHeightRef:l})=>{let[a,c]=iR(36),u=sR(()=>{let f=r?0:2,d=s!=null?s:a,p=Math.min(e,o)||e;return typeof t=="function"?f+=Array(p).fill(0).reduce((m,y,g)=>m+t(g)+i,0)-i:f+=p*Number(d)+(p-1)*i,isNaN(f)?void 0:f},[r,e,t,o,i,s,a]),h=lR(({height:f})=>{c(f)},[]);return Ci(l,hb,h,!0),{preferredHeight:u}};var Hb=`.saltList {
|
|
122
|
-
--list-background: var(--salt-container-primary-background);
|
|
123
|
-
--list-borderStyle: var(--salt-container-borderStyle);
|
|
124
|
-
--list-borderWidth: var(--salt-size-border);
|
|
125
|
-
--list-height: auto;
|
|
126
|
-
--list-item-height: var(--salt-size-stackable);
|
|
127
|
-
--list-item-gap: 0px;
|
|
128
|
-
--list-maxHeight: 100%;
|
|
129
|
-
|
|
130
|
-
background: var(--list-background);
|
|
131
|
-
border-color: var(--salt-container-primary-borderColor);
|
|
132
|
-
border-style: var(--list-borderStyle);
|
|
133
|
-
border-width: var(--list-borderWidth);
|
|
134
|
-
height: var(--saltList-height, var(--list-height));
|
|
135
|
-
max-height: var(--list-maxHeight);
|
|
136
|
-
outline: none;
|
|
137
|
-
overflow-y: auto;
|
|
138
|
-
position: relative;
|
|
139
|
-
user-select: none;
|
|
140
|
-
width: var(--saltList-width, auto);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.saltList-borderless {
|
|
144
|
-
--list-borderStyle: none;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/* virtualised list */
|
|
148
|
-
.saltList-viewport {
|
|
149
|
-
--list-item-height: 30px;
|
|
150
|
-
max-height: calc(var(--list-maxHeight) - 2 * var(--list-borderWidth));
|
|
151
|
-
overflow: auto;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.saltListItemHeader {
|
|
155
|
-
--saltList-item-background: var(--list-item-header-background);
|
|
156
|
-
color: var(--list-item-header-color);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.saltListItemHeader[data-sticky="true"] {
|
|
160
|
-
--saltList-item-background: var(--list-background);
|
|
161
|
-
position: sticky;
|
|
162
|
-
top: 0;
|
|
163
|
-
z-index: 1;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.saltList-collapsible .saltListItemHeader:after {
|
|
167
|
-
border-width: var(--checkbox-borderWidth);
|
|
168
|
-
border-color: var(--checkbox-borderColor);
|
|
169
|
-
content: var(--list-item-header-twisty-content);
|
|
170
|
-
-webkit-mask: var(--list-svg-chevron-down) center center/12px 12px no-repeat;
|
|
171
|
-
mask: var(--list-svg-chevron-down) center center/12px 12px no-repeat;
|
|
172
|
-
background: var(--list-item-header-twisty-color);
|
|
173
|
-
height: 12px;
|
|
174
|
-
left: var(--list-item-header-twisty-left);
|
|
175
|
-
right: var(--list-item-header-twisty-right);
|
|
176
|
-
margin-top: -8px;
|
|
177
|
-
position: absolute;
|
|
178
|
-
top: var(--list-item-header-twisty-top);
|
|
179
|
-
transition: transform 0.3s;
|
|
180
|
-
width: 12px;
|
|
181
|
-
}
|
|
182
|
-
.saltListItemHeader[aria-expanded="false"]:after {
|
|
183
|
-
transform: rotate(-90deg);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/* Selection */
|
|
187
|
-
|
|
188
|
-
.saltList-scrollingContentContainer {
|
|
189
|
-
box-sizing: inherit;
|
|
190
|
-
position: relative;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.saltList-virtualized .saltListItem {
|
|
194
|
-
line-height: 30px;
|
|
195
|
-
position: absolute;
|
|
196
|
-
top: 0;
|
|
197
|
-
left: 0;
|
|
198
|
-
right: 0;
|
|
199
|
-
will-change: transform;
|
|
200
|
-
}
|
|
201
|
-
.saltList.saltFocusVisible:after {
|
|
202
|
-
inset: 2px;
|
|
203
|
-
}
|
|
204
|
-
`;var yR="No data to display",Mi=pR("saltList"),ch=uR(function({ListItem:e=ki,ListPlaceholder:t,borderless:n,children:o,className:i,collapsibleHeaders:s=!1,defaultHighlightedIndex:l,defaultSelected:a,disabled:c=!1,disableFocus:u=!1,disableTypeToSelect:h,displayedItemCount:f=10,emptyMessage:d,focusVisible:p,getItemHeight:m,getItemId:y,height:g,highlightedIndex:v,id:w,itemGapSize:x=0,itemHeight:S,itemTextHighlightPattern:b,itemToString:C=lo,listHandlers:k,maxHeight:E,maxWidth:R,minHeight:M,minWidth:P,onSelect:I,onSelectionChange:V,onHighlight:B,restoreLastFocus:W,selected:O,selectionStrategy:N,checkable:F=N==="multiple",scrollingApiRef:G,selectionKeys:X,showEmptyMessage:te=!1,source:_e,style:de,stickyHeaders:it,tabToSelect:On,width:Vt,...re},se){let Me=un();hn({testId:"salt-list",css:Hb,window:Me});let kt=mR(w),fo=ah(null),po=ah(null),mo=ah(null),Mt=cb({id:kt,label:"List",source:_e,children:o,options:{collapsibleHeaders:s,getItemId:y,itemToString:C}}),{preferredHeight:go}=Bb({borderless:n,displayedItemCount:f,getItemHeight:m,height:g,itemCount:Mt.data.length,itemGapSize:x,itemHeight:S,rowHeightRef:mo}),{focusVisible:Ql,highlightedIndex:Yl,listControlProps:nx,listHandlers:rx,listItemHeaderHandlers:ox,scrollIntoView:ix,selected:sx}=Fb({collapsibleHeaders:s,collectionHook:Mt,containerRef:fo,contentRef:po,defaultHighlightedIndex:l,defaultSelected:Mt.itemToCollectionItem(a),disabled:c,disableTypeToSelect:h,highlightedIndex:v,label:kt,listHandlers:k,onSelect:I,onSelectionChange:V,onHighlight:B,restoreLastFocus:W,selected:Mt.itemToCollectionItem(O),selectionStrategy:N,selectionKeys:X,stickyHeaders:it,tabToSelect:On});db({collectionHook:Mt,forwardedRef:G,scrollableRef:fo,scrollIntoView:ix});let Ih=p!=null?p:Ql,Ph=function(Ce,st,Je,lt){let Vn=hR(e,{...ox,className:yr("saltListItemHeader",{focusVisible:s&&Ih===Ce.value}),"aria-expanded":lt,"data-idx":s?Ce.value:void 0,"data-highlighted":Ce.value===Yl||void 0,"data-sticky":it,"data-selectable":!1,id:st,key:`header-${Ce.value}`,label:Je});return Ce.value+=1,Vn},lx=m===void 0?()=>S:m;function ax(Nn,Ce,st){var Je;let{disabled:lt,value:Vn,id:yo,label:Xl}=Ce,bo=fR(Vn),Li={className:yr({saltHighlighted:st.value===Yl,saltFocusVisible:Ih===st.value}),disabled:lt||c,id:yo,item:bo?void 0:(Je=Ce==null?void 0:Ce.value)!=null?Je:void 0,itemHeight:lx(st.value),itemTextHighlightPattern:b,key:yo,"data-idx":st.value,label:Xl,role:"option",selected:vb(sx,Ce),showCheckbox:F};Nn.push(bo?dR(Vn,Li):xr(e,{...Li})),st.value+=1}let cx=function(Ce,st,Je){let{count:lt=0,id:Vn,expanded:yo,label:Xl=""}=st[Je.value],bo=Ph(Je,Vn,Xl,yo),Li=yo!==!1?[bo].concat(Dh(st,Je,Je.value+lt)||[]):bo;Ce.push(xr("div",{role:"group",children:Li},Vn))},Dh=(Nn,Ce={value:0},st=Nn.length)=>{let Je=[];for(;Ce.value<st;){let lt=Nn[Ce.value];lt.header?Je.push(Ph(Ce,lt.id,lt.label,lt.expanded===!1)):lt.childNodes?cx(Je,Nn,Ce):ax(Je,lt,Ce)}return Je};function ux(){return d||te?xr("span",{className:Mi("empty-message"),children:d!=null?d:yR}):null}let hx=()=>{if(Mt.data.length)return Dh(Mt.data);ux()},fx="auto",dx={"--list-item-gap":x?`${x}px`:void 0,minWidth:P,minHeight:M,width:Vt!=null?Vt:"100%",height:g!=null?g:"100%",maxWidth:R!=null?R:Vt,maxHeight:E!=null?E:go};return aR("div",{"aria-multiselectable":N==="multiple"||N==="extended"||N==="extended-multi-range"||void 0,...re,...rx,...nx,className:yr(Mi(),i,{[Mi("borderless")]:n,saltDisabled:c,[Mi("collapsible")]:s,saltFocusVisible:Yl===nh}),id:`${kt}`,ref:gR(fo,se),role:"listbox",style:{...de,...dx},tabIndex:c||u?void 0:0,children:[xr(oh,{ref:mo}),Mt.data.length===0&&t!==void 0?xr(cR,{children:xr(t,{})}):xr("div",{className:Mi("scrollingContentContainer"),ref:po,style:{height:fx},children:hx()})]})});import{useCallback as y9}from"react";import x9 from"classnames";import{jsx as w9}from"react/jsx-runtime";import $b,{Suspense as SR,useEffect as CR}from"react";import bR from"react";import{Fragment as xR,jsx as _b,jsxs as vR}from"react/jsx-runtime";var Ol=class extends bR.Component{constructor(e){super(e),this.state={errorMessage:null}}static getDerivedStateFromError(e){return{errorMessage:e.message}}componentDidCatch(e,t){console.log(`error creating component at ${this.props.url}`),console.log(e,t)}render(){return this.state.errorMessage?vR(xR,{children:[_b("h1",{children:"An error occured while creating component."}),_b("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as wR}from"react/jsx-runtime";var zb=()=>wR("div",{className:"hwLoader",children:"loading"});var Wb=async r=>{let e=new CSSStyleSheet;return fetch(r).then(t=>t.text()).then(t=>e.replace(t))};import{jsx as Vl}from"react/jsx-runtime";var Nl=new Map,TR=r=>{CR(()=>()=>{Nl.delete(r)},[r]),Nl.has(r)||Nl.set(r,$b.lazy(()=>import(r)));let e=Nl.get(r);if(e)return e;throw Error(`Unable to load Lazy Feature at url ${r}`)};function kR({url:r,css:e,ComponentProps:t,...n}){e&&Wb(e).then(i=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,i]});let o=TR(r);return Vl(Ol,{url:r,children:Vl(SR,{fallback:Vl(zb,{}),children:Vl(o,{...n,...t})})})}var uh=$b.memo(kR);uh.displayName="Feature";ge("Feature",uh,"view");import{useEffect as MR,useState as Ei}from"react";import{Input as ER,Button as Ub,FormField as Fl,FormFieldLabel as Bl,Text as RR}from"@salt-ds/core";import{ComboBox as IR,Checkbox as PR,RadioButton as DR}from"@vuu-ui/vuu-ui-controls";import{formatDate as LR,takeScreenshot as AR}from"@vuu-ui/vuu-utils";import{jsx as je,jsxs as Ln}from"react/jsx-runtime";var ot="saveLayoutPanel",Hl=`${ot}-formField`,OR=["Group 1","Group 2","Group 3","Group 4","Group 5"],NR=["Value 1","Value 2","Value 3"],Gb=["Value 1","Value 2","Value 3"],qb=r=>{let{onCancel:e,onSave:t,componentId:n}=r,[o,i]=Ei(""),[s,l]=Ei(""),[a,c]=Ei([]),[u,h]=Ei(Gb[0]),[f,d]=Ei();MR(()=>{n&&AR(document.getElementById(n)).then(m=>d(m))},[n]);let p=()=>{t({name:o,group:s,screenshot:f!=null?f:"",user:"User",date:LR(new Date,"dd.mm.yyyy")})};return Ln("div",{className:`${ot}-panelContainer`,children:[Ln("div",{className:`${ot}-panelContent`,children:[Ln("div",{className:`${ot}-formContainer`,children:[Ln(Fl,{className:Hl,children:[je(Bl,{children:"Group"}),je(IR,{source:OR,allowFreeText:!0,InputProps:{inputProps:{className:`${ot}-inputText`,placeholder:"Select Group or Enter New Name",onChange:m=>l(m.target.value)}},width:"100%",onSelectionChange:(m,y)=>l(y||"")})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Layout Name"}),je(ER,{inputProps:{className:`${ot}-inputText`,placeholder:"Enter Layout Name"},onChange:m=>i(m.target.value),value:o})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Some Layout Setting"}),je("div",{className:`${ot}-settingsGroup`,children:NR.map((m,y)=>je(PR,{onToggle:()=>c(g=>g.includes(m)?g.filter(v=>v!==m):[...g,m]),checked:a.includes(m),label:m},y))})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Some Layout Setting"}),je("div",{className:`${ot}-settingsGroup`,children:Gb.map((m,y)=>je(DR,{onClick:()=>h(m),checked:u===m,label:m,groupName:"radioGroup"},y))})]})]}),je("div",{className:`${ot}-screenshotContainer`,children:f?je("img",{className:`${ot}-screenshot`,src:f,alt:"screenshot of current layout"}):je(RR,{className:"screenshot",children:"No screenshot available"})})]}),Ln("div",{className:`${ot}-buttonsContainer`,children:[je(Ub,{className:`${ot}-cancelButton`,onClick:e,children:"Cancel"}),je(Ub,{className:`${ot}-saveButton`,onClick:p,disabled:o===""||s==="",children:"Save"})]})]})};import{List as d6}from"@vuu-ui/vuu-ui-controls";import VR,{useState as Z9,useCallback as e6,useContext as FR,useEffect as t6,useRef as n6}from"react";import{jsx as a6}from"react/jsx-runtime";var s6=new Sl,BR=VR.createContext({layoutMetadata:[],saveLayout:()=>{},applicationLayout:Ho,saveApplicationLayout:()=>{},loadLayoutById:()=>Ho});var _l=()=>FR(BR);import{Fragment as b6,jsx as y6,jsxs as x6}from"react/jsx-runtime";import{memo as HR}from"react";import{jsx as Ct,jsxs as uo}from"react/jsx-runtime";var Kb=HR(()=>uo("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[uo("g",{clipPath:"url(#clip0_217_6990)",children:[Ct("path",{d:"M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",fill:"url(#paint0_linear_217_6990)"}),Ct("path",{d:"M42.6246 24.8716C41.9199 25.9157 40.9625 26.824 39.767 27.4905C38.424 28.2396 36.9563 28.597 35.5081 28.597C32.7541 28.597 30.0715 27.3094 28.4466 24.9855L15.772 3.90967L15.7655 3.9206C13.3615 0.137431 8.25372 -1.13143 4.24754 1.10507C0.178173 3.37435 -1.20852 8.39359 1.14854 12.3125L18.3445 40.9095C19.1108 42.1846 20.1816 43.1834 21.4144 43.8764C21.4241 43.8826 21.4338 43.8889 21.4435 43.8951C21.4484 43.8982 21.4549 43.9013 21.4597 43.9045C22.0332 44.2228 22.6423 44.471 23.2725 44.6536C23.3194 44.6677 23.368 44.6817 23.415 44.6942C23.6418 44.7551 23.8702 44.8097 24.1019 44.8534C24.1456 44.8612 24.1894 44.8659 24.2331 44.8737C24.4194 44.9049 24.6073 44.9314 24.7952 44.9501C24.8698 44.9579 24.9443 44.9658 25.0188 44.9704C25.2342 44.9876 25.4497 44.9985 25.6668 45.0001C25.6781 45.0001 25.6895 45.0001 25.6992 45.0001C25.7024 45.0001 25.704 45.0001 25.7073 45.0001C25.7105 45.0001 25.7121 45.0001 25.7154 45.0001C25.9503 45.0001 26.1868 44.9876 26.4217 44.9689C26.4751 44.9642 26.5286 44.9595 26.5837 44.9533C26.8137 44.9299 27.0438 44.9002 27.2738 44.8596C27.277 44.8596 27.2803 44.8596 27.2835 44.8596C27.5362 44.8144 27.7889 44.7551 28.0384 44.6864C28.0546 44.6817 28.0692 44.677 28.0854 44.6723C28.4483 44.5709 28.8063 44.4445 29.1594 44.2931C29.1659 44.29 29.174 44.2868 29.1805 44.2837C29.4494 44.1682 29.7151 44.0418 29.9759 43.8967C30.24 43.75 30.491 43.5908 30.7308 43.4206C30.9398 43.2739 31.1407 43.1179 31.3367 42.9524C31.5748 42.7495 31.8 42.5373 32.009 42.3141C32.1661 42.1471 32.3168 41.9723 32.4609 41.7913C32.5079 41.732 32.5517 41.6711 32.5954 41.6118C32.6942 41.4807 32.7882 41.3465 32.8789 41.2091C32.9259 41.1373 32.9728 41.0671 33.0182 40.9953C33.036 40.9672 33.0555 40.9407 33.0717 40.9126L42.7153 24.8763H42.6214L42.6246 24.8716Z",fill:"url(#paint1_linear_217_6990)"}),Ct("path",{d:"M42.8402 16.4218L42.1112 15.2232L38.9636 9.58433L37.504 7.19644C37.2286 6.56123 36.579 6.11331 35.8176 6.11331C34.8083 6.11331 33.9919 6.90147 33.9919 7.87223C33.9919 8.20154 34.0907 8.50432 34.2543 8.76808L34.2349 8.78056L39.9048 18.0808C40.5884 19.2186 40.7715 20.5437 40.4199 21.8141C40.0684 23.0845 39.226 24.1458 38.045 24.806C37.2675 25.2398 36.3846 25.4693 35.4936 25.4693C33.6727 25.4693 31.9766 24.5281 31.0662 23.0143L22.9161 9.63271H22.9323L19.4899 3.90958L19.4834 3.92051C19.4235 3.8253 19.3538 3.73947 19.2907 3.64738L19.1935 3.48663C19.1935 3.48663 19.1854 3.49131 19.1821 3.49443C17.5654 1.27666 14.9799 0.0390178 12.3118 0.00936427V0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.961 26.8255 41.9168 25.9156 42.6231 24.8731H42.717L42.6846 24.9261C43.1366 24.2347 43.4833 23.4731 43.7068 22.6615C44.2916 20.5452 43.9871 18.3352 42.8369 16.4234L42.8402 16.4218Z",fill:"#F37880"}),uo("g",{opacity:"0.86",children:[Ct("path",{d:"M34.2332 8.78212L39.9031 18.0824C40.5868 19.2202 40.7698 20.5452 40.4183 21.8156C40.2044 22.5897 39.8059 23.2858 39.2616 23.8617C39.9744 23.2343 40.4879 22.4243 40.7423 21.5035C41.0938 20.2331 40.9107 18.908 40.2271 17.7703L34.5572 8.46998L34.5767 8.4575C34.413 8.19374 34.3142 7.89096 34.3142 7.56165C34.3142 7.15586 34.4584 6.78285 34.6982 6.48476C34.2672 6.80626 33.9902 7.30881 33.9902 7.87379C33.9902 8.2031 34.0891 8.50588 34.2527 8.76964L34.2332 8.78212Z",fill:"white"}),Ct("path",{d:"M42.6917 24.9169L42.6863 24.9256C42.6863 24.9256 42.6899 24.9187 42.6935 24.9152C42.6935 24.9152 42.6935 24.9152 42.6935 24.9169H42.6917Z",fill:"white"}),Ct("path",{d:"M40.0911 27.1798C38.7481 27.9289 37.2804 28.2863 35.8322 28.2863C33.0782 28.2863 30.3955 26.9988 28.7707 24.6749L16.0961 3.59744L16.0896 3.60837C14.9281 1.78077 13.1364 0.543128 11.1422 0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.4815 27.0924 41.1084 26.6055 41.6511 26.0561C41.1862 26.479 40.6662 26.8583 40.0894 27.1798H40.0911Z",fill:"white"})]})]}),uo("defs",{children:[uo("linearGradient",{id:"paint0_linear_217_6990",x1:"24.6235",y1:"18.7363",x2:"42.3152",y2:"18.7363",gradientUnits:"userSpaceOnUse",children:[Ct("stop",{stopColor:"#4906A5"}),Ct("stop",{offset:"1",stopColor:"#D3423A"})]}),uo("linearGradient",{id:"paint1_linear_217_6990",x1:"-2.35794e-05",y1:"22.5009",x2:"42.7186",y2:"22.5009",gradientUnits:"userSpaceOnUse",children:[Ct("stop",{stopColor:"#7C06A5"}),Ct("stop",{offset:"1",stopColor:"#D3423A"})]}),Ct("clipPath",{id:"clip0_217_6990",children:Ct("rect",{width:"44",height:"45",fill:"white"})})]})]}));Kb.displayName="VuuLogo";import{Tab as i7,Tabstrip as s7}from"@vuu-ui/vuu-ui-controls";import a7 from"classnames";import{useCallback as d7,useState as p7}from"react";import{jsx as B6,jsxs as H6}from"react/jsx-runtime";import{createContext as _R,isValidElement as zR,cloneElement as WR,useContext as $R}from"react";import UR from"classnames";import{jsx as JR}from"react/jsx-runtime";var GR="medium",qR="salt-theme",KR="light",Jb=_R({density:"high",theme:"vuu",themeMode:"light"});var jR=(r,e,t,n)=>{var o;return zR(r)?WR(r,{className:UR((o=r.props)==null?void 0:o.className,`${e}-theme`,`${e}-density-${n}`),"data-mode":t}):(console.warn(`
|
|
17
|
+
`,document.body.insertBefore(e,r)}}var Bt=class{constructor(){this.currentPath=null;this.tabMode=null;Cc()}prepare(e,t="full-view"){document.body.classList.add("drawing"),this.currentPath=null,this.tabMode=t;let o=this.getPoints(0,0,0,0),n=zs(o),s=document.getElementById("vuu-drop-outline");s==null||s.setAttribute("d",n),this.currentPath=n}clear(){_t=null,Tr(),document.body.classList.remove("drawing"),Wo.hidePopup()}get hoverDropTarget(){return _t}getPoints(e,t,o,n,s=0,i=0,a=0){let l=this.tabMode==="tab-only";if(i===0)return[[e,t+a],[e,t+a],[e,t],[e+i,t],[e+i,t],[e+o,t],[e+o,t+n],[e,t+n]];if(l){let u=s;return[[u,t],[u,t],[u+i,t],[u+i,t],[u+i,t+a],[u+i,t+a],[u,t+a],[u,t+a]]}else return s===0?[[e,t+a],[e,t+a],[e,t],[e+i,t],[e+i,t+a],[e+o,t+a],[e+o,t+n],[e,t+n]]:[[e,t+a],[e+s,t+a],[e+s,t],[e+s,t],[e+s,t+a],[e+o,t+a],[e+o,t+n],[e,t+n]]}draw(e,t){let n=Uo;if(_t!==null)this.drawTarget(_t);else if(Uo=e.nextDropTarget!=null,e.pos.tab?Rc(e):Ce&&Tr(),this.drawTarget(e,t),Uo){let[s,i,a]=Bs(e);{let l=xc(Fs,{dropTarget:e,onHover:bc,orientation:a});Wo.showPopup({left:s,top:i,component:l})}}else Wo.hidePopup()}drawTarget(e,t){let n=e.getTargetDropOutline(6,t);if(n){let{l:s,t:i,r:a,b:l,tabLeft:u,tabWidth:c,tabHeight:p,guideLines:d}=n,h=a-s,f=l-i;if(this.currentPath){let R=document.getElementById("vuu-drop-outline");R==null||R.setAttribute("d",this.currentPath)}let b=this.getPoints(s,i,h,f,u,c,p),y=zs(b),g=document.getElementById("hw-drop-outline-animate");g==null||g.setAttribute("to",y),g==null||g.beginElement(),this.currentPath=y;let C=document.getElementById("hw-drop-guides");C==null||C.setAttribute("d",Sc(d))}}},Hs="transition:margin-left .4s ease-out;margin-left: 63px",$s="transition:margin-left .4s ease-out;margin-left: 0px";function Rc(r){var a,l;let{AFTER:e,BEFORE:t}=Nt,{clientRect:{Stack:o},pos:{tab:n}}=r,{id:s}=r.component.props,i=null;if(o&&n&&n.positionRelativeToTab!==e){let u=n.positionRelativeToTab===t?1:2,c=`:scope .hwTabstrip > .hwTabstrip-inner > .hwTab:nth-child(${n.index+u})`;i=(a=document.getElementById(s))==null?void 0:a.querySelector(c),i?(Ce===null||Ce!==i)&&(i.style.cssText=Hs,Ce&&(Ce.style.cssText=$s),Ce=i):Tr()}else if((n==null?void 0:n.positionRelativeToTab)===t){if(Ce===null){let u=".vuuHeader-title";i=(l=document.getElementById(s))==null?void 0:l.querySelector(u),i.style.cssText=Hs,Ce=i}}else Tr()}function Tr(){Ce&&(Ce.style.cssText=$s,Ce=null)}var Ie,Ft,Be,Us,Gs,Ye,Er,et=null,qo,qs,Mr,Js,Go,Pr=null,Tc=3,Lr=new Bt,Ws=.4;function Ec(r,e){return e?J(r,e):De(r,t=>t.dropTarget)}var Jo={handleMousedown(r,e,t={}){Ie=e,qs=t,Us=r.clientX,Gs=r.clientY,Go=t.dragThreshold===void 0?Tc:t.dragThreshold,Go===0?Ie(r,0,0):(window.addEventListener("mousemove",Dr,!1),window.addEventListener("mouseup",Ir,!1),Pr=window.setTimeout(()=>{window.removeEventListener("mousemove",Dr,!1),window.removeEventListener("mouseup",Ir,!1),Ie==null||Ie(r,0,0)},500)),r.preventDefault()},initDrag(r,e,{top:t,left:o,right:n,bottom:s},i,a,l,u){return{drag:Ft,drop:Be}=a,Pc(r,e,{top:t,left:o,right:n,bottom:s},i,l,u)}};function Dr(r){let o=r.clientX-Us,n=r.clientY-Gs;Math.max(Math.abs(o),Math.abs(n))>Go&&(window.removeEventListener("mousemove",Dr,!1),window.removeEventListener("mouseup",Ir,!1),Ie==null||Ie(r,o,n),Ie=null)}function Ir(){Pr&&(window.clearTimeout(Pr),Pr=null),window.removeEventListener("mousemove",Dr,!1),window.removeEventListener("mouseup",Ir,!1)}function Pc(r,e,t,o,n,s){Ye=Ec(r,e);let{"data-path":i,path:a=i}=I(Ye);s&&(qo=s.map(d=>De(r,h=>h.id===d)).map(d=>d.props.path)),Mr=ht.measure(Ye,s);let l=Mr[a];Er=new xr(l,o.x,o.y,t,n);let u=Math.round(Er.x.mousePct*100),c=Math.round(Er.y.mousePct*100);return window.addEventListener("mousemove",Qs,!1),window.addEventListener("mouseup",js,!1),window.addEventListener("keydown",Ks,!1),Js=!1,Lr.prepare(t,"tab-only"),qs.DoNotTransform?"transform:none":`transform:scale(${Ws},${Ws});transform-origin:${u}% ${c}%;`}function Qs(r){let e=r.clientX,t=r.clientY,o=Er,n=et,s,i,a;o.update("x",e)&&(i=o.x.pos),o.update("y",t)&&(a=o.y.pos),i===void 0&&a===void 0||Ft==null||Ft(i,a),!(Js||Ye===void 0)&&(o.inBounds()?s=Ho(e,t,Ye,Mr,o.hasIntrinsicSize(),qo):s=Ho(o.dropX(),o.dropY(),Ye,Mr),n&&(s==null||s.box!==n.box)&&(et=null),s&&(Lr.draw(s,o),et=s))}function Ks(r){r.key==="Escape"&&(et=null,Xs())}function js(){Xs()}function Xs(){if(et){let r=Lr.hoverDropTarget||_e.getActiveDropTarget(et);Be==null||Be(r),et=null}else Be==null||Be();Ft=null,Be=null,Ye=void 0,Lr.clear(),qo=void 0,window.removeEventListener("mousemove",Qs,!1),window.removeEventListener("mouseup",js,!1),window.removeEventListener("keydown",Ks,!1)}import Mc from"classnames";import{forwardRef as Lc}from"react";import{jsx as Dc}from"react/jsx-runtime";var zt=Lc(function({children:e,className:t,dropTarget:o,resizeable:n,...s},i){let a=Mc("DraggableLayout",t);return Dc("div",{className:a,ref:i,...s,children:e})}),Zs="DraggableLayout";zt.displayName=Zs;G(Zs,zt,"container");import{useForkRef as sp}from"@salt-ds/core";import ip from"classnames";import{forwardRef as ap}from"react";import{getUniqueId as Zc}from"@vuu-ui/vuu-utils";import Gt,{useCallback as Br,useMemo as di,useRef as Fr,useState as Yc}from"react";import Ac from"classnames";import{Button as Ic}from"@salt-ds/core";import{useMemo as kc,useState as Oc}from"react";import{Fragment as Vc,jsx as Qo,jsxs as Ys}from"react/jsx-runtime";var kr="vuuLayoutStartPanel",ei=r=>{let{dispatch:e,path:t}=ti(),[o,n]=Oc();return kc(()=>{e==null||e({type:"query",path:t,query:"PARENT_CONTAINER"}).then(i=>{(i==null?void 0:i.parentContainerId)==="main-tabs"?n("initial"):n("nested")})},[e,t]),o===void 0?null:Ys("div",{...r,className:kr,children:[o==="initial"?Ys(Vc,{children:[Qo("header",{className:`${kr}-title`,children:"Start by adding a table"}),Qo("div",{className:`${kr}-text`,children:"To add a table, drag any of the Vuu Tables to this area or click the button below"})]}):null,Qo(Ic,{className:`${kr}-addButton`,"data-icon":"add",variant:"cta"})]})};import{Fragment as Bc,jsx as Or}from"react/jsx-runtime";var Nc="vuuPlaceholder",_c=({showStartMenu:r=!0})=>Or(Bc,{children:r?Or(ei,{}):null}),ft=({className:r,showStartMenu:e,...t})=>{let o=Ac(Nc,r);return Or(Fe,{...t,className:o,"data-placeholder":!0,resizeable:!0,children:Or(_c,{showStartMenu:e})})};ft.displayName="Placeholder";G("Placeholder",ft);import Fc from"classnames";import zc,{useCallback as Ht,useRef as Vr,useState as Hc}from"react";import{jsx as ri}from"react/jsx-runtime";var Ar="vuuSplitter",oi=zc.memo(function({column:e,index:t,onDrag:o,onDragEnd:n,onDragStart:s,style:i}){let a=Vr(),l=Vr(null),u=Vr(0),[c,p]=Hc(!1),d=Ht(({key:v,shiftKey:S})=>{let E=S?10:1;e&&v==="ArrowDown"?o(t,E):e&&v==="ArrowUp"||!e&&v==="ArrowLeft"?o(t,-E):!e&&v==="ArrowRight"&&o(t,E)},[e,t,o]),h=Ht(v=>{let{key:S}=v;(e&&(S==="ArrowUp"||S==="ArrowDown")||!e&&(S==="ArrowLeft"||S==="ArrowRight"))&&(s(t),d(v),f.current=d)},[e,d,t,s]),f=Vr(h),b=v=>f.current(v),y=Ht(v=>{a.current=!0;let S=v[e?"clientY":"clientX"],E=S-u.current;S&&S!==u.current&&o(t,E),u.current=S},[e,t,o]),g=Ht(()=>{var v;window.removeEventListener("mousemove",y,!1),window.removeEventListener("mouseup",g,!1),n(),p(!1),(v=l.current)==null||v.focus()},[y,n,p]),C=Ht(v=>{u.current=e?v.clientY:v.clientX,s(t),window.addEventListener("mousemove",y,!1),window.addEventListener("mouseup",g,!1),v.preventDefault(),p(!0)},[e,y,g,t,s,p]),R=()=>{var v;a.current?a.current=!1:(v=l.current)==null||v.focus()},w=()=>{f.current=h},x=Fc(Ar,{[`${Ar}-active`]:c,[`${Ar}-column`]:e});return ri("div",{className:x,"data-splitter":!0,ref:l,role:"separator",style:i,onBlur:w,onClick:R,onKeyDown:b,onMouseDown:C,tabIndex:0,children:ri("div",{className:`${Ar}-grab-zone`})})});import{uuid as ni}from"@vuu-ui/vuu-utils";import si from"react";var $c={"data-placeholder":!0,"data-resizeable":!0},Nr={},ze="auto",Ko={flexBasis:0,flexGrow:1,flexShrink:1,height:ze,width:ze},ii={height:"width",width:"height"},ai=(r="row")=>r==="row"?["width","height","column"]:["height","width","row"],Wc=r=>typeof r=="string"&&r.endsWith("%"),he=r=>{let{style:{width:e=ze,height:t=ze}=Nr}=r.props,o=typeof t=="number",n=typeof e=="number";return o&&n?{height:t,width:e}:o?{height:t}:n?{width:e}:void 0};function jo(r,e,t){let o=ii[e],{style:{[o]:n=ze,...s}=Nr}=r.props;return t&&t[e]?{...s,...Ko,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...s,...Ko,[o]:n}}function li(r){let{style:{flex:e,flexGrow:t,flexShrink:o,flexBasis:n}=Nr}=r.props;return typeof e=="number"||n===0&&t===1&&o===1?!0:typeof n!="number"}function Xo(r,e,t){let o=ii[e],{style:{[e]:n=ze,[o]:s=ze,...i}=Nr}=r.props;return n!==ze?Wc(n)?{flexBasis:0,flexGrow:1,flexShrink:1,[e]:void 0,[o]:s}:{flexBasis:n,flexGrow:0,flexShrink:0,[e]:n,[o]:s}:t&&t[e]?{...i,...Ko,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...i,[o]:s}}function $t(r,e,t,o,n){let s=[],i=0,a;if(o&&n){let c,[p,d,h,f]=n;[c,a]=e==="column"?[d-o.top,o.bottom-f]:[p-o.left,o.right-h],c&&s.push(Re(`${t}.${i++}`,c,{flexGrow:0,flexShrink:0}))}else a=!0;let{version:l=0,style:u}=I(r);return s.push(j(r,`${t}.${i++}`,{version:l+1,style:{...u,flexBasis:"auto",flexGrow:0,flexShrink:0}})),a&&s.push(Re(`${t}.${i++}`,0,void 0,{[`data-${e}-placeholder`]:!0})),Zo(e,{resizeable:!1,style:{flexBasis:"auto"}},s,t)}var Uc=(r,e)=>{if(!e)return r===0?1:0};function Zo(r,e,t,o){let n=ni(),{flexFill:s,style:i,resizeable:a=!0}=e,{flexBasis:l=s?void 0:"auto"}=i,u=Uc(l,s);return si.createElement(je.Flexbox,{id:n,key:n,path:o,flexFill:s,style:{...i,flexDirection:r,flexBasis:l,flexGrow:u,flexShrink:u},resizeable:a},t)}var Gc={flexGrow:1,flexShrink:1};function Re(r,e,t,o){let n=ni();return si.createElement("div",{...$c,...o,"data-path":r,id:n,key:n,style:{...Gc,...t,flexBasis:e}})}var qc={},Wt=1,Ut=2,Jc=r=>typeof r.intrinsicSize=="number",Qc=(r,e)=>{let t={};return r.forEach(o=>{t[o]=A(e,o)}),t},_r=(r,e,t)=>r.map((o,n)=>{var l;let s=A(o,"resizeable"),{[e]:i}=(l=he(o))!=null?l:qc,a=li(o);return t?{index:n,flexOpen:a,intrinsicSize:i,resizeable:s,...Qc(t,o)}:{index:n,flexOpen:a,intrinsicSize:i,resizeable:s}}),ui=r=>{let e=r.length,t=r.every(Jc),o=Array(e).fill(0);if(t&&e>0&&(o[0]=Ut,o[e-1]=Ut),e<2)return o;for(let n=0,s=0;n<e-1;n++)r[n].resizeable&&!s&&(s=Wt),o[n]+=s;for(let n=e-1;n>0&&(o[n]&Wt&&(o[n]-=Wt),!r[n].resizeable);n--);return o},ci=(r,e)=>{let t=jc(r,e),o=Xc(r,e),n=t!==-1&&o!==-1?[t,o]:void 0,s=Kc(r,n);return[n,s]};function Kc(r,e){if(e){let t=[];for(let o=0;o<r.length;o++)r[o].flexOpen&&!e.includes(o)&&t.push(o);return t}}function jc(r,e){let t=e,o=!1;for(;t>=1&&!o;)t=t-1,o=pi(r,t);return t}function Xc(r,e){let t=e,o=!1,n=r.length;for(;t<n-1&&!o;)t=t+1,o=pi(r,t);return t===n?-1:t}function pi(r,e){let{placeholder:t,splitter:o,resizeable:n,intrinsicSize:s}=r[e];return!!(!o&&!s&&(t||n))}var ep=r=>!r.splitter&&!r.placeholder,fi=({children:r,onSplitterMoved:e,style:t})=>{let o=Fr(null),n=Fr(),s=Fr(),i=Fr([]),[,a]=Yc({}),l=y=>{s.current=y,a({})},u=(t==null?void 0:t.flexDirection)==="column",c=u?"height":"width",p=di(()=>Array.isArray(r)?r:Gt.isValidElement(r)?[r]:[],[r]),d=Br(y=>{let{current:g}=n;if(g){let[C,R]=ci(g,y);C&&(C.forEach(w=>{var v;let x=(v=o.current)==null?void 0:v.childNodes[w];if(x){let{size:S,minSize:E}=np(x,c);g[w].currentSize=S,g[w].minSize=E}}),R&&R.forEach(w=>{var v;let x=(v=o.current)==null?void 0:v.childNodes[w];if(x){let{[c]:S}=x.getBoundingClientRect();g[w].flexBasis=S}}))}},[c]),h=Br((y,g)=>{s.current&&n.current&&l(rp(s.current,n.current,g,c))},[c]),f=Br(()=>{let y=n.current;y&&(e==null||e(y.filter(ep))),y==null||y.forEach(g=>{g.currentSize=void 0,g.flexBasis=void 0,g.flexOpen=!1})},[e]),b=Br(y=>Gt.createElement(oi,{column:u,index:y,key:`splitter-${y}`,onDrag:h,onDragEnd:f,onDragStart:d}),[h,f,d,u]);return di(()=>{let[y,g]=tp(p,c,b,i.current);n.current=g,s.current=y},[p,b,c]),{content:s.current||[],rootRef:o}};function tp(r,e,t,o){let n=_r(r,e),s=ui(n),i=[],a=[];for(let l=0;l<r.length;l++){let u=r[l];if(l===0&&s[l]&Ut&&(i.push(hi(l)),a.push({placeholder:!0,shim:!0})),u.key==null){let c=o[l]||(o[l]=Zc());i.push(Gt.cloneElement(u,{key:c}))}else i.push(u);a.push(n[l]),l>0&&s[l]&Ut?(i.push(hi(l)),a.push({placeholder:!0})):s[l]&Wt&&(i.push(t(i.length)),a.push({splitter:!0}))}return[i,a]}function rp(r,e,t,o){return op(e,t)?r.map((s,i)=>{let a=e[i],{currentSize:l,flexOpen:u,flexBasis:c}=a,p=l!==void 0;if(p||u){let{flexBasis:d}=s.props.style||{},h=p?a.currentSize:c;return h!==d?Gt.cloneElement(s,{style:{...s.props.style,flexBasis:h,[o]:"auto"}}):s}else return s}):r}function op(r,e){let t=[];r.forEach((c,p)=>{c.currentSize!==void 0&&t.push(p)});let o=e<0?t[0]:t[1],{currentSize:n=0,minSize:s=0}=r[o];if(n===s)return!1;if(Math.abs(e)>n-s){let c=e<0?-1:1;e=Math.max(0,n-s)*c}let i=r[t[0]],{currentSize:a=0}=i;i.currentSize=a+e;let l=r[t[1]],{currentSize:u=0}=l;return l.currentSize=u-e,!0}function hi(r){return Gt.createElement(ft,{shim:r===0,key:`placeholder-${r}`})}function np(r,e){let{[e]:t}=r.getBoundingClientRect(),n=getComputedStyle(r).getPropertyValue(`min-${e}`),s=n.endsWith("px")?parseInt(n,10):0;return{size:t,minSize:s}}import{jsx as lp}from"react/jsx-runtime";var Yo="hwFlexbox",mi=ap(function(e,t){let{breakPoints:o,children:n,column:s,className:i,flexFill:a,gap:l,fullPage:u,id:c,onSplitterMoved:p,resizeable:d,row:h,spacing:f,splitterSize:b,style:y,...g}=e,{content:C,rootRef:R}=fi({children:n,onSplitterMoved:p,style:y}),w=ip(Yo,i,{[`${Yo}-column`]:s,[`${Yo}-row`]:h,"flex-fill":a,"full-page":u});return lp("div",{...g,className:w,"data-resizeable":d||void 0,id:c,ref:sp(R,t),style:{...y,gap:l,"--spacing":f},children:C})});mi.displayName="Flexbox";var qt=mi;import{useCallback as ed}from"react";var mt={ADD:"add",BLUR:"blur",BLUR_SPLITTER:"blur-splitter",DRAG_START:"drag-start",DRAG_STARTED:"drag-started",DRAG_DROP:"drag-drop",FOCUS:"focus",FOCUS_SPLITTER:"focus-splitter",INITIALIZE:"initialize",LAYOUT_RESIZE:"layout-resize",MAXIMIZE:"maximize",MINIMIZE:"minimize",REMOVE:"remove",REPLACE:"replace",RESTORE:"restore",SAVE:"save",SET_TITLE:"set-title",SPLITTER_RESIZE:"splitter-resize",SWITCH_TAB:"switch-tab",TEAR_OUT:"tear-out"};import{useCallback as ln,useContext as un,useEffect as Kp,useRef as qi,useState as jp}from"react";import sn from"react";import{uuid as xi}from"@vuu-ui/vuu-utils";import Kt from"react";import{uuid as vi}from"@vuu-ui/vuu-utils";import Jt,{cloneElement as up}from"react";import{useCallback as gt}from"react";var oe=new Map,fe=new Map,gi=r=>oe.get(r),yi=r=>oe.has(r),bi=(r,e)=>oe.set(r,e),yt=()=>{let r=gt((i,a)=>{let l=fe.get(i);if(l)return a!==void 0&&l[a]!==void 0?l[a]:a!==void 0?void 0:l},[]),e=gt((i,a,l)=>{if(a===void 0)fe.set(i,l);else if(fe.has(i)){let u=fe.get(i);fe.set(i,{...u,[a]:l})}else fe.set(i,{[a]:l})},[]),t=gt((i,a)=>{if(fe.has(i)){if(a===void 0)fe.delete(i);else if(fe.get(i)[a]){let{[a]:u,...c}=fe.get(i);Object.keys(c).length>0?fe.set(i,c):fe.delete(i)}}},[]),o=gt((i,a)=>{let l=oe.get(i);if(l)return a!==void 0?l[a]:l},[]),n=gt((i,a,l)=>{if(a===void 0)oe.set(i,l);else if(oe.has(i)){let u=oe.get(i);oe.set(i,{...u,[a]:l})}else oe.set(i,{[a]:l})},[]),s=gt((i,a)=>{if(oe.has(i)){if(a===void 0)oe.delete(i);else if(oe.get(i)[a]){let{[a]:u,...c}=oe.get(i);Object.keys(c).length>0?oe.set(i,c):oe.delete(i)}}},[]);return{loadSessionState:r,loadState:o,saveSessionState:e,saveState:n,purgeState:s,purgeSessionState:t}};var wi=r=>r.flexDirection==="column"?["height","width"]:["width","height"],cp={},Qt=(r,e="0")=>{let[t,o]=zr(O(r),r.props,e);return Jt.cloneElement(r,t,o)},tn=(r,e)=>{let t=O(r),[o,n]=zr(t,r.props,"0",void 0,e);return up(r,o,n)},hw=(r,e,t)=>{let[o,n]=zr(r,e,"0",void 0,t);return{...e,...o,type:r,children:n}};function pp(r,e,t="0",o=null,n){var b,y;let{active:s=0,"data-path":i,path:a=i,id:l,style:u}=I(n),c=O(n)===r&&t===a,p=c?l:(b=e.id)!=null?b:vi(),d=r==="Stack"?(y=e.active)!=null?y:s:void 0,h=p,f=c?u:hp(r,e,o);return ms(r)?{id:p,key:h,path:t,style:f,type:r,active:d}:{id:p,key:h,style:f,"data-path":t}}function zr(r,e,t,o=null,n){var u,c;let s=pp(r,e,t,o,n);if(e.layout&&!n)return[s,[He(e.layout,`${t}.0`)]];let i=(c=n==null?void 0:n.children)!=null?c:(u=n==null?void 0:n.props)==null?void 0:u.children,l=e.dropTarget&&i?i:dp(r,e.children,t,i);return[s,l]}function dp(r,e,t="0",o){let n=Array.isArray(e)?e:Jt.isValidElement(e)?[e]:[];return re(r)?n.map((s,i)=>{let a=O(s),l=O(o==null?void 0:o[i]);if(!l||a===l){let[u,c]=zr(a,s.props,`${t}.${i}`,r,o==null?void 0:o[i]);return Jt.cloneElement(s,u,c)}return o==null?void 0:o[i]}):e}var hp=(r,e,t)=>{let{style:o=cp}=e;if(r==="Flexbox"&&(o={flexDirection:e.column?"column":"row",...o,display:"flex"}),o.flex){let{flex:n,...s}=o;o={...s,...No(typeof n=="number"?n:0)}}else t==="Stack"?o={...o,...No(1)}:t==="Flexbox"&&(o.width||o.height)&&o.flexBasis===void 0&&(o={...o,flexBasis:"auto",flexGrow:0,flexShrink:0});return o};function He({id:r=vi(),type:e,children:t,props:o,state:n},s){let i=e.match(/^[a-z]/)?e:je[e];if(i===void 0)throw Error(`layoutUtils unable to create component from JSON, unknown type ${e}`);return n&&bi(r,n),Jt.createElement(i,{id:r,...o,key:r,path:s},t?t.map((a,l)=>He(a,`${s}.${l}`)):void 0)}function Si(r){return Ci(r)}function Ci(r){let e=O(r),{id:t,children:o,type:n,...s}=I(r),i=yi(t)?gi(t):void 0;return{id:t,type:e,props:fp(s),state:i,children:Jt.Children.map(o,Ci)}}function fp(r){if(r){let{path:e,...t}=r,o={};for(let[n,s]of Object.entries(t))o[n]=en(s);return o}}function en(r){if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;if(Array.isArray(r))return r.map(en);if(typeof r=="object"&&r!==null){let e={};for(let[t,o]of Object.entries(r))e[t]=en(o);return e}}var Ri=(r,e,t)=>{if(e&&t){let o=we(t,e);if(o){let{id:n}=I(o),s=O(o);return{parentContainerId:n,parentContainerType:s}}return{parentContainerType:"Stack",parentContainerId:"blah"}}},bt=(r,e,t=[])=>{var n,s,i;let o=(i=(n=r.props)==null?void 0:n.title)!=null?i:(s=r.props)==null?void 0:s["data-tab-title"];if(o)return o;{let a=e;do o=`Tab ${++a}`;while(t.includes(o));return o}};function Ti(r,e){var i;let t=r.props.children,o=t.length,{index:n=-1,positionRelativeToTab:s="after"}=e.tab||{};return n===-1||n>=o?[t[o-1],"after"]:[(i=t[n])!=null?i:null,s]}function Hr(r,e,t){let{active:o,children:n=[],path:s}=I(r),i=A(e,"path"),{idx:a,finalStep:l}=Se(s,i,!0),[u,c]=l?yp(r,n,t):[o,n==null?void 0:n.map((d,h)=>h===a?Hr(d,e,t):d)],p=O(r)==="Stack"?Array.isArray(u)?u[0]:u:o;return Kt.cloneElement(r,{active:p},c)}var mp=(r,e,t,o)=>r==="Stack"?bt(e,t,o):void 0,gp=r=>r.map(e=>e.props.title);function yp(r,e,t){let o=A(r,"path"),n=e==null?void 0:e.length,{id:s=xi(),title:i=mp(O(r),t,n!=null?n:0,gp(e))}=I(t);return n?[n,e.concat(j(t,`${o}.${n}`,{id:s,key:s,title:i}))]:[0,[j(t,`${o}.0`,{id:s,title:i})]]}function $r(r,e,t,o,n,s,i){let{active:a,children:l,path:u}=I(r),c=A(e,"path"),{idx:p,finalStep:d}=Se(u,c),[h,f]=d?bp(r,l,p,t,o,n,s,i):[a,l.map((y,g)=>g===p?$r(y,e,t,o,n,s,i):y)],b=O(r)==="Stack"?h:a;return Kt.cloneElement(r,{active:b},f)}function bp(r,e,t,o,n,s,i,a){let l=he(o);return l!=null&&l.width&&(l!=null&&l.height)?wp(r,e,t,o,n,i,a):Ei(r,e,t,o,n,(s==null?void 0:s.width)||(s==null?void 0:s.height),i)}var vp=(r,e,{top:t,right:o,bottom:n,left:s},[i,a,l,u])=>{if(r==="column"&&e==="before")return a-t;if(r==="column")return n-u;if(r==="row"&&e==="before")return i-s;if(r==="row")return o-l};function wp(r,e,t,o,n,s,i){let{style:{flexDirection:a}}=I(r),[l,u,c]=ai(a),{[u]:p,[l]:d}=he(o),h=A(e[t],"path"),f=vp(a,n,s,i),[b,y]=p<s[u]?[$t(o,c,h,s,i),d]:[o,void 0],g=f?Re(h,f,{flexGrow:0,flexShrink:0}):void 0;return p>s[u]&&(e=e.map(C=>{if(A(C,"placeholder"))return C;{let{[u]:R}=he(C);return R&&R<p?$t(C,c,A(C,"path")):C}})),Ei(r,e,t,b,n,y,s,g)}function Ei(r,e,t,o,n,s,i,a){let l=A(r,"path"),u=0,c=!e||e.length===0?[o]:e.reduce((p,d,h)=>{if(t===h){let[f,b]=Sp(r,d,o,i);n==="before"?a?p.push(a,b,f):p.push(b,f):a?p.push(f,b,a):p.push(f,b),u=p.indexOf(b)}else p.push(d);return p},[]).map((p,d)=>d<u?p:j(p,`${l}.${d}`));return[u,c]}function Sp(r,e,t,o){let n=xi(),{version:s=0}=I(t);if(s+=1,O(r)==="Flexbox"){let[i]=wi(r.props.style),a=6,l={[i]:(o[i]-a)/2},u=Xo(e,i,l),c=Xo(t,i,l);return[Kt.cloneElement(e,{style:u}),Kt.cloneElement(t,{id:n,version:s,style:c})]}else{let{style:{left:i,top:a,flex:l,...u}={left:void 0,top:void 0,flex:void 0}}=I(t);return[e,Kt.cloneElement(t,{id:n,version:s,style:u})]}}import{cloneElement as xp}from"react";import Wr from"react";function Pi(r,{target:e,replacement:t}){return rn(r,e,t)}function rn(r,e,t){let o=A(e,"path"),n=A(e,"resizeable"),{style:s}=I(e),i=Qt(Wr.cloneElement(t,{resizeable:n,style:{...s,...t.props.style}}),o);return ne(r,e,i)}function ne(r,e,t,o){if(r===e)return t;let{idx:n,finalStep:s}=Se(A(r,"path"),A(e,"path")),i=r.props.children.slice();return s?o?o===mt.MINIMIZE?i[n]=Cp(r,i[n]):o===mt.RESTORE&&(i[n]=Rp(i[n])):i[n]=t:i[n]=ne(i[n],e,t,o),Wr.cloneElement(r,void 0,i)}function Cp(r,e){let{style:t}=I(r),{style:o}=I(e),{width:n,height:s,flexBasis:i,flexShrink:a,flexGrow:l,...u}=o,c={width:n,height:s,flexBasis:i,flexShrink:a,flexGrow:l},p={...u,flexBasis:0,flexGrow:0,flexShrink:0},d=t.flexDirection==="row"?"vertical":t.flexDirection==="column"?"horizontal":!1;return d?Wr.cloneElement(e,{collapsed:d,restoreStyle:c,style:p}):e}function Rp(r){let{style:e,restoreStyle:t}=I(r),{flexBasis:o,flexShrink:n,flexGrow:s,...i}=e,a={...i,...t};return Wr.cloneElement(r,{collapsed:!1,style:a,restoreStyle:void 0})}function Mi(r,{fromIndex:e,path:t,toIndex:o}){let n=J(r,t,!0),{children:s}=I(n),i=Tp(s,e,o),a=xp(n,void 0,i);return ne(r,n,a)}function Tp(r,e,t){let o=r.slice(),[n]=o.splice(e,1);return t===-1?o.concat(n):(o.splice(t,0,n),o)}var X={ADD:"add",DRAG_START:"drag-start",DRAG_DROP:"drag-drop",LAYOUT_RESIZE:"layout-resize",MAXIMIZE:"maximize",MINIMIZE:"minimize",MOVE_CHILD:"move-child",QUERY:"query",REMOVE:"remove",REPLACE:"replace",RESTORE:"restore",SAVE:"save",SET_PROP:"set-prop",SET_PROPS:"set-props",SET_TITLE:"set-title",SPLITTER_RESIZE:"splitter-resize",SWITCH_TAB:"switch-tab",TEAROUT:"tearout"},_w=r=>["switch-active-layout","open-layout","close-layout","rename-layout"].includes(r),Bw=r=>["switch-active-tab","edit-feature-title","save-feature-props","remove-component","resize-component","drag-drop-operation"].includes(r);import tt from"react";function on(r,{path:e}){let t=J(r,e),o=we(r,e);if(o===null)return r;let{children:n}=I(o);if(n.length>1&&O(o)!=="Stack"&&Di(n,e)){let{style:{flexBasis:s,display:i,flexDirection:a,...l}}=I(o),u=A(o,"path"),c=ne(r,o,Re(u,s,l));for(;(o=we(c,u))&&A(o,"path")!=="0";){let{children:p}=I(o);if(Di(p)){u=A(o,"path");let{style:{flexBasis:d,display:h,flexDirection:f,...b}}=I(o);c=ne(r,o,Re(u,d,b))}else if(Lp(p))c=Oi(r,o);else break}return c}return Ii(r,t)}function Ii(r,e){let t=I(r),{children:o,path:n,preserve:s}=t,{active:i,id:a}=t,{idx:l,finalStep:u}=Se(n,A(e,"path")),c=O(r),p=o.slice();if(u){if(p.splice(l,1),i!==void 0&&i>=l&&(i=Math.max(0,i-1)),p.length===0&&s&&c==="Stack"){let{path:d,style:{flexBasis:h}}=I(e),f=a==="main-tabs"?He({props:{style:{flexGrow:1,flexShrink:1,flexBasis:h},title:"Tab 1"},type:"Placeholder"},d):Re(d,h);p.push(f)}else if(p.length===1&&!s&&n!=="0"&&c.match(/Flexbox|Stack/))return Ep(r,p[0]);!p.some(Pp)&&p.some(ki)&&(p=Mp(p))}else p[l]=Ii(p[l],e);return p=p.map((d,h)=>j(d,`${n}.${h}`)),tt.cloneElement(r,{active:i},p)}function Ep(r,e){let t=O(r),{path:o,style:{flexBasis:n,flexGrow:s,flexShrink:i,width:a,height:l}}=I(r),u=j(e,o);if(o==="0")u=tt.cloneElement(u,{style:{...e.props.style,width:a,height:l}});else if(t==="Flexbox"){let c=r.props.style.flexDirection==="column"?"height":"width",{style:{[c]:p,...d}}=u.props;u=tt.cloneElement(u,{flexFill:void 0,style:{...d,flexGrow:s,flexShrink:i,flexBasis:n,width:a,height:l}})}return u}var Pp=r=>r.props.style.flexGrow>0,ki=r=>{let{width:e,height:t,flexGrow:o}=r.props.style;return o===0&&typeof e!="number"&&typeof t!="number"},Mp=r=>r.map(e=>ki(e)?tt.cloneElement(e,{style:{...e.props.style,flexGrow:1}}):e),Lp=r=>{if(r&&r.length>0){let e=A(r[0],"placeholder"),t=!1;for(let o=1;o<r.length;o++){if(t=A(r[o],"placeholder"),e&&t)return!0;e=t}}},Oi=(r,e)=>{let{children:t,path:o}=I(r),{idx:n,finalStep:s}=Se(o,A(e,"path")),i=t.slice();return s?i[n]=Dp(e):i[n]=Oi(i[n],e),i=i.map((a,l)=>j(a,`${o}.${l}`)),tt.cloneElement(r,void 0,i)},Dp=r=>{let{children:e}=I(r),t=[],o=[];for(let s=0;s<e.length;s++)A(e[s],"placeholder")?o.push(e[s]):(o.length===1?t.push(o.pop()):o.length>0&&(t.push(Li(o)),o.length=0),t.push(e[s]));o.length===1?t.push(o.pop()):o.length>0&&t.push(Li(o));let n=A(r,"path");return tt.cloneElement(r,void 0,t.map((s,i)=>j(s,`${n}.${i}`)))},Li=([r,...e])=>{let t=A(r,"style"),{flexBasis:o,flexGrow:n,flexShrink:s}=t;for(let{props:{style:i}}of e)o+=i.flexBasis,n=Math.max(n,i.flexGrow),s=Math.max(s,i.flexShrink);return tt.cloneElement(r,{style:{...t,flexBasis:o,flexGrow:n,flexShrink:s}})},Di=(r,e)=>r.every(t=>A(t,"placeholder")||e&&A(t,"path")===e);import nn from"react";function Vi(r,{path:e,size:t}){let o=J(r,e,!0),{style:n}=I(o),s={...n,width:t},i=nn.cloneElement(o,{style:s});return ne(r,o,i)}function Ai(r,{path:e,sizes:t}){let o=J(r,e,!0),{children:n,style:s}=I(o),i=s.flexDirection==="column"?"height":"width",a=Ip(n,t,i),l=nn.cloneElement(o,void 0,a);return ne(r,o,l)}function Ip(r,e,t){return r.map((o,n)=>{let{style:{[t]:s,flexBasis:i}}=I(o),a=e[n],{currentSize:l,flexBasis:u}=a,p=l!==void 0?a.currentSize:u;return p===void 0||s===p||i===p?o:nn.cloneElement(o,{style:kp(o.props.style,t,p)})})}function kp(r,e,t){let o=typeof r[e]=="number",{flexShrink:n=1,flexGrow:s=1}=r;return{...r,[e]:o?t:"auto",flexBasis:o?"auto":t,flexShrink:n,flexGrow:s}}import{uuid as Op}from"@vuu-ui/vuu-utils";import Ur from"react";var Ni=r=>{let[e]=O(r);return e===e.toLowerCase()};function jt(r,e,t,o,n,s){let{children:i,path:a}=I(r),l=A(e,"path"),{idx:u,finalStep:c}=Se(a,l),p=c?Vp(r,i,e,t,o,n,s):i.map((d,h)=>h===u?jt(d,e,t,o,n,s):d);return Ur.cloneElement(r,void 0,p)}function Vp(r,e,t,o,n,s,i){let a=he(o);if(a!=null&&a.width&&(a!=null&&a.height)){if(s===void 0||i===void 0)throw Error("wrap-layout-element, updateChildren clientRect and dropRect must both be available");return Np(e,t,o,n,s,i)}return Ap(r,e,t,o,n)}function Ap(r,e,t,o,n){var S;let{version:s=0}=I(o),{path:i,title:a}=I(t),{type:l,flexDirection:u,showTabs:c}=Bi(n),[p,d,h]=_p(l,t,o,u,n),f=_i(n),b=f?1:0,y={resizeable:!0,style:h,version:s+1},C={[Ni(t)?"data-resizeable":"resizeable"]:!0,style:d},R=l==="Stack"?{showTabs:c}:void 0,w=l==="Flexbox"?{splitterSize:(S=O(r)==="Flexbox"&&r.props.splitterSize)!=null?S:void 0}:void 0,x=Op(),v=Ur.createElement(je[l],{active:b,id:x,key:x,path:A(t,"path"),flexFill:A(t,"flexFill"),...w,...R,style:p,title:a,resizeable:A(t,"resizeable")},f?[j(t,`${i}.0`,C),Qt(Ur.cloneElement(o,y),`${i}.1`)]:[Qt(Ur.cloneElement(o,y),`${i}.0`),j(t,`${i}.1`,C)]);return e.map(E=>E===t?v:E)}function Np(r,e,t,o,n,s){let{flexDirection:i}=Bi(o),a=i==="column"?"row":"column",l=_i(o),[u,c,p,d]=s,[h,f]=i==="column"?[c-n.top,n.bottom-d]:[u-n.left,n.right-p],b=A(e,"path"),y=0,g=Ni(e)?"data-resizeable":"resizeable",C=[];h&&C.push(l?j(e,`${b}.${y++}`,{[g]:!0,style:{flexBasis:h,flexGrow:1,flexShrink:1}}):Re(`${b}.${y++}`,h,{flexGrow:0,flexShrink:0})),C.push($t(t,a,`${b}.${y++}`,n,s)),f&&C.push(l?Re(`${b}.${y++}`,0):j(e,`${b}.${y++}`,{[g]:!0,style:{flexBasis:0,flexGrow:1,flexShrink:1}}));let R=Zo(i,e.props,C,b);return r.map(w=>w===e?R:w)}function _p(r,e,t,o,n){let s={...e.props.style,flexDirection:o},i=r==="Flexbox"&&o==="column"?"height":"width",a=jo(t,i,n),l=jo(e,i);return[s,l,a]}var _i=r=>{var e;return r.position.SouthOrEast?!0:((e=r==null?void 0:r.tab)==null?void 0:e.positionRelativeToTab)==="before"?!1:!!r.position.Header};function Bi(r){return r.position.Header?{type:"Stack",flexDirection:"column",showTabs:!0}:{type:"Flexbox",flexDirection:r.position.EastOrWest?"row":"column"}}var Wi=(r,e)=>{switch(e.type){case X.ADD:return $p(r,e);case X.DRAG_DROP:return Hp(r,e);case X.MAXIMIZE:return zp(r,e);case X.REMOVE:return on(r,e);case X.REPLACE:return Pi(r,e);case X.SET_PROP:return Fi(r,e);case X.SET_PROPS:return Fp(r,e);case X.SET_TITLE:return Fi(r,{type:"set-prop",path:e.path,propName:"title",propValue:e.title});case X.SPLITTER_RESIZE:return Ai(r,e);case X.LAYOUT_RESIZE:return Vi(r,e);case X.SWITCH_TAB:return Bp(r,e);case X.MOVE_CHILD:return Mi(r,e);default:return r}},Bp=(r,{path:e,nextIdx:t})=>{let o=J(r,e,!0),n=sn.cloneElement(o,{active:t});return ne(r,o,n)},Fi=(r,{path:e,propName:t,propValue:o})=>{let n=J(r,e,!0),s=sn.cloneElement(n,{[t]:o});return ne(r,n,s)},Fp=(r,{path:e,props:t})=>{let o=J(r,e,!0),n=sn.cloneElement(o,t);return ne(r,o,n)},zp=(r,{path:e,type:t})=>{if(e){let o=J(r,e,!0);return ne(r,o,o,t)}else return r},Hp=(r,e)=>{var f,b;let{draggedReactElement:t,dragInstructions:o,dropTarget:n}=e,s=n.component,{pos:i}=n,a=((f=i==null?void 0:i.position)==null?void 0:f.Header)&&O(s)==="Stack",{id:l,version:u}=I(t),c=he(t),p;if(a){let[y,g]=Ti(s,i);y===void 0?p=Hr(r,s,t):p=$r(r,y,t,g)}else!c&&((b=i==null?void 0:i.position)!=null&&b.Centre)?p=rn(r,s,t):p=Wp(r,n,t);if(o.DoNotRemove)return p;let d=De(p,y=>y.id===l&&y.version===u),h=A(d,"path");return on(p,{path:h,type:"remove"})},$p=(r,{path:e,component:t})=>Hr(r,J(r,e),t),Wp=(r,e,t)=>{let{component:o,pos:n,clientRect:s,dropRect:i}=e,a=o,l=A(a,"path");if(l==="0.0")return jt(r,a,t,n);let u=we(r,l);if(zi(n,u)){let c=n.position.SouthOrEast?"after":"before";return $r(r,a,t,c,n,s,i)}if(!zi(n,u))return jt(r,a,t,n,s,i);if(re(O(u)))return jt(r,a,t,n);throw Error(`no support right now for position = ${n.position}`)},zi=(r,e)=>r.position.Centre?$i(e)||Hi(e):r.position.NorthOrSouth?Hi(e):r.position.EastOrWest?$i(e):!1,Hi=r=>O(r)==="Flexbox"&&r.props.style.flexDirection==="column",$i=r=>O(r)==="Flexbox"&&r.props.style.flexDirection!=="column";import{createContext as Up}from"react";var Gp=r=>console.log(`dispatch ${r.type}, have you forgotten to provide a LayoutProvider ?`),Xt=Up({dispatchLayoutProvider:Gp,version:-1});import{useCallback as Gr,useRef as an}from"react";var qp={},Ui=[0,0],Jp=(r,e,t)=>{let o=document.createElement("div");o.className="vuuSimpleDraggableWrapper",o.classList.add("vuuSimpleDraggableWrapper","salt-theme","salt-density-medium"),o.dataset.dragging="true";let n=t!=null?t:document.createElement("div");n.id=e,o.appendChild(n),document.body.appendChild(o);let s=`top:${r.top}px;left:${r.left}px;width:${r.width}px;height:${r.height}px;`;return[o,s,r.left,r.top]},Qp=r=>{let{offsetParent:e}=r;if(e===null)return Ui;{let{left:t,top:o}=e.getBoundingClientRect();return[t,o]}},Gi=(r,e,t)=>{let o=an(),n=an(),s=an(),i=Gr((c,p)=>{if(n.current&&s.current){let{dragOffsets:[d,h],targetPosition:f}=n.current,b=typeof c=="number"?c-d:f.left,y=typeof p=="number"?p-h:f.top;(b!==f.left||y!==f.top)&&(n.current.targetPosition.left=b,n.current.targetPosition.top=y,s.current.style.top=y+"px",s.current.style.left=b+"px")}},[]),a=Gr(c=>{if(n.current){let{dragInstructions:p,payload:d,originalCSS:h}=n.current;c&&e({type:"drag-drop",draggedReactElement:d,dragInstructions:p,dropTarget:c}),s.current&&(!c&&p.DriftHomeIfNoDropTarget?(console.log("drift back to start"),document.body.removeChild(s.current)):p.RemoveDraggableOnDragEnd?document.body.removeChild(s.current):(s.current.style.cssText=h,delete s.current.dataset.dragging)),o.current=void 0,n.current=void 0,s.current=void 0}},[e]),l=Gr(c=>{if(o.current){let{payload:p,dragContainerPath:d,dragElement:h,dragRect:f,instructions:b=qp,path:y}=o.current,{current:g}=r,C={x:c.clientX,y:c.clientY},R=p!=null?p:J(g,y,!0),{id:w}=R.props,x=he(R),v="",S="",E="",M=-1,P=-1,T=Ui,D=document.getElementById(w);if(D===null)[D,S,M,P]=Jp(f,w,h);else{T=Qp(D);let[V,_]=T,{width:F,height:z,left:ee,top:q}=D.getBoundingClientRect();M=ee-V,P=q-_,S=`width:${F}px;height:${z}px;left:${M}px;top:${P}px;z-index: 100;background-color:#ccc;opacity: 0.6;`,D.dataset.dragging="true",v=D.style.cssText}E=Jo.initDrag(r.current,d,f,C,{drag:i,drop:a},x),D.style.cssText=S+E,s.current=D,n.current={payload:R,originalCSS:v,dragRect:f,dragOffsets:T,dragInstructions:b,targetPosition:{left:M,top:P}}}},[i,a,r]);return Gr(c=>{let{evt:p,...d}=c;o.current={...d,dragContainerPath:Vo(r.current,t)},Jo.handleMousedown(p,l,d.instructions)},[l,t,r])};import{jsx as ji}from"react/jsx-runtime";var Ji=r=>r.dropTarget,Xp=r=>["drag-drop","remove","set-title","splitter-resize","switch-tab"].includes(r.type),Qi=r=>{switch(r.type){case"switch-tab":return r.id==="main-tabs"?"switch-active-layout":"switch-active-tab";case"save":return"save-feature-props";case"drag-drop":return"drag-drop-operation";case"remove":return"remove-component";case"splitter-resize":return"resize-component";case"set-title":return"edit-feature-title";default:throw Error("unknown layout action")}},lC=()=>{let r=Yp();return ji("div",{children:`Context: ${r} `})},Zp=r=>{let{children:e,createNewChild:t,pathToDropTarget:o,layout:n,onLayoutChange:s}=r,i=qi(void 0),a=qi(e),[,l]=jp(null),u=ln((h,f)=>{if(s){let b=De(h,Ji)||i.current,g=O(b)==="DraggableLayout"?I(b).children[0]:b,C=Si(g);s(C,f)}},[s]),c=ln((h,f=!1)=>{let b=Wi(i.current,h);b!==i.current&&(i.current=b,l({}),!f&&Xp(h)&&u(b,Qi(h)))},[l,u]),p=ln(h=>{switch(h.type){case"drag-start":{d(h);break}case"save":{u(i.current,Qi(h));break}case"query":if(h.query==="PARENT_CONTAINER")return Ri(h.query,h.path,i.current);break;default:{c(h);break}}},[c,u]),d=Gi(i,p,o);return Kp(()=>{if(n){let h=De(i.current,Ji);if(h){let f=Cs(h),b=He(n,`${h.props.path}.0`),y=f?{type:X.REPLACE,target:f,replacement:b}:{type:X.ADD,path:h.props.path,component:b};c(y,!0)}else if(n.id===A(i.current,"id")){let f=He(n,"0"),b={type:X.REPLACE,target:i.current,replacement:f};c(b,!0)}}},[c,n]),i.current===void 0?i.current=tn(e):e!==a.current&&(i.current=tn(e,i.current),a.current=e),ji(Xt.Provider,{value:{createNewChild:t,dispatchLayoutProvider:p,version:0},children:i.current})},me=()=>{let{dispatchLayoutProvider:r}=un(Xt);return r},Ki=()=>{let{createNewChild:r}=un(Xt);return r},Yp=()=>{let{version:r}=un(Xt);return r};import{jsx as td}from"react/jsx-runtime";var Xi=function(e){let{path:t}=e,o=me(),n=ed(s=>{o({type:mt.SPLITTER_RESIZE,path:t,sizes:s})},[o,t]);return td(qt,{...e,onSplitterMoved:n})};Xi.displayName="Flexbox";G("Flexbox",Xi,"container");import{useForkRef as Sd}from"@salt-ds/core";import Cd from"classnames";import{forwardRef as Rd,useMemo as xd}from"react";import{useCallback as oa,useEffect as ad,useRef as dn,useState as ld}from"react";import{useCallback as rd,useLayoutEffect as Zi,useRef as od}from"react";var ea=["height","width"],RC=["height"],xC=["width"],rt=new WeakMap,ta=(r,e,t)=>{switch(t){case"height":return e.height;case"scrollHeight":return r.scrollHeight;case"scrollWidth":return r.scrollWidth;case"width":return e.width;default:return 0}},Yi=new ResizeObserver(r=>{for(let e of r){let{target:t,contentRect:o}=e,n=rt.get(t);if(n){let{onResize:s,measurements:i}=n,a=!1;for(let[l,u]of Object.entries(i)){let c=ta(t,o,l);c!==u&&(a=!0,i[l]=c)}a&&s&&s(i)}}});function qr(r,e,t,o=!1){let n=od(e),s=rd(i=>{let a=i.getBoundingClientRect();return n.current.reduce((l,u)=>(l[u]=ta(i,a,u),l),{})},[]);Zi(()=>{let i=r.current,a=!1;async function l(){rt.set(i,{measurements:{}}),a=!1;let{fonts:u}=document;if(u&&await u.ready,!a){let c=rt.get(i);if(c){let p=s(i);c.measurements=p,Yi.observe(i),o&&t(p)}}}if(i){if(rt.has(i))throw Error("useResizeObserver attemping to observe same element twice");l()}return()=>{i&&rt.has(i)&&(Yi.unobserve(i),rt.delete(i),a=!0)}},[r,s,o,t]),Zi(()=>{let i=r.current,a=rt.get(i);if(a){if(n.current!==e){n.current=e;let l=s(i);a.measurements=l}a.onResize=t}},[e,s,r,t])}function nd(r,e){let t=document.body.querySelector(`.${r}`),o={get:function(n,s){let i=n.getPropertyValue(`--${r}-breakpoint-${s}`);return i?parseInt(i):void 0}};return t?new Proxy(getComputedStyle(t),o):e!=null?e:{}}var sd=([,r],[,e])=>e-r,pn=r=>Object.entries(r).sort(sd).map(([e,t],o,n)=>[e,t,o<n.length-1?n[o+1][1]:9999]),cn=null,id=(r="salt")=>{let{xs:e,sm:t,md:o,lg:n,xl:s}=nd(r);return pn({xs:e,sm:t,md:o,lg:n,xl:s})},ra=r=>(cn===null&&(cn=id(r)),cn);var ud=[],na=({breakPoints:r,smallerThan:e},t)=>{let[o,n]=ld(e?!1:"lg"),s=dn(document.body),i=dn(r?pn(r):ra()),a=dn("lg"),l=oa(c=>{if(i.current){for(let[p,d]of i.current)if(c>=d)return p}},[i]),u=oa(c=>{if(e){let p=i.current.find(([d])=>d===e);if(p){let[,,d]=p;return c<d}}else return l(c);return c},[e,l]);return qr(t||s,i.current?["width"]:ud,({width:c})=>{let p=u(c);p!==a.current&&(a.current=p,n(p))},!0),ad(()=>{let c=t||s;if(c.current){let p=a.current;if(i.current){let{clientWidth:d}=c.current,h=u(d);a.current=h,h!==p&&n(h)}}},[n,u,t]),o};var sa="data-collapsible",cd={[sa]:!0,"data-pad-start":!0,"data-pad-end":!0},pd=r=>{var e;return(e=cd[r])!=null?e:!1},dd=r=>r===sa,hd={dynamic:"dynamic",instant:"instant",true:"instant"},fd=r=>{var e;return(e=hd[r])!=null?e:"none"},OC=r=>Object.keys(r).reduce((e,t)=>{let[o,n]=e;if(pd(t)){let s=dd(t)?fd(r[t]):r[t];o[t]=s,n[t]=void 0}return e},[{},{}]);import{getUniqueId as md}from"@vuu-ui/vuu-utils";import{cloneElement as gd,isValidElement as yd,useCallback as bd,useMemo as ia,useRef as hn}from"react";var vd=["xs","sm","md","lg","xl"],wd=12,aa=({children:r,cols:e,style:t})=>{let o=hn(null),n=hn(null),s=hn(),i=e!=null?e:wd,l=(t==null?void 0:t.flexDirection)==="column"?"height":"width",u=ia(()=>Array.isArray(r)?r:yd(r)?[r]:[],[r]),c=bd((p,d)=>{let h=_r(p,d,vd),f=[],b=[];for(let y=0;y<p.length;y++){let g=p[y],{style:{flex:C,...R}}=g.props;f.push(gd(g,{key:md(),style:{...R,"--parent-col-count":i}})),b.push(h[y])}return[f,b]},[i]);return ia(()=>{let[p,d]=c(u,l);n.current=d,s.current=p},[c,u,l]),{cols:i,content:s.current,rootRef:o}};import{jsx as Td}from"react/jsx-runtime";var Jr="hwFluidGrid",fn=Rd(function(e,t){let{breakPoints:o,children:n,column:s,cols:i=12,className:a,flexFill:l,gap:u=3,fullPage:c,id:p,onSplitterMoved:d,resizeable:h,row:f,showGrid:b,spacing:y,splitterSize:g,style:C,...R}=e,w=xd(()=>pt(n),[n]),{cols:x,content:v,rootRef:S}=aa({children:w,cols:i,style:C}),E=na({breakPoints:o},S),M=Cd(Jr,a,{[`${Jr}-column`]:s,[`${Jr}-row`]:f,[`${Jr}-show-grid`]:b,"flex-fill":l,"full-page":c}),P={...C,"--spacing":y,"--grid-col-count":x,"--grid-gap":u};return Td("div",{...R,className:M,"data-breakpoint":E,"data-cols":x,"data-resizeable":h||void 0,id:p,ref:Sd(S,t),style:P,children:v})});fn.displayName="FluidGrid";import{jsx as Ed}from"react/jsx-runtime";var la=function(e){return Ed(fn,{...e})};la.displayName="FluidGrid";G("FluidGrid",la,"container");import{EditableLabel as zd}from"@vuu-ui/vuu-ui-controls";import{Button as Hd}from"@salt-ds/core";import{default as $d,default as Wd}from"classnames";import{cloneElement as va,useRef as Ud,useState as wa}from"react";import{useCallback as Zt,useState as Pd}from"react";var Qr=(r,e,t,o)=>{var y;let{loadSessionState:n,purgeSessionState:s,purgeState:i,saveSessionState:a}=yt(),[l,u]=Pd((y=n(r,"contributions"))!=null?y:[]),c=me(),p=Zt((g,C)=>{let R=l.concat([{location:g,content:C}]);a(r,"contributions",R),u(R)},[l,r,a]),d=Zt(()=>{s(r,"contributions"),u([])},[r,s]),h=Zt(()=>{let g=n(r,"data-source");g&&g.unsubscribe(),s(r),i(r),c({type:"remove",path:t})},[c,r,n,s,i,t]),f=Zt(async(g,C,R)=>{var x;g.stopPropagation();let w=(x=e.current)==null?void 0:x.getBoundingClientRect();return new Promise((v,S)=>{c({type:"drag-start",evt:g,path:C===void 0?t:`${t}.${C}`,dragRect:w,preDragActivity:R,dropTargets:o,resolveDragStart:v,rejectDragStart:S})})},[e,c,t,o]);return[Zt(async(g,C)=>{var w;let{type:R}=g;switch(R){case"maximize":case"minimize":case"restore":return c({type:R,path:(w=g.path)!=null?w:t});case"remove":return h();case"mousedown":return f(C,g.index,g.preDragActivity);case"add-toolbar-contribution":return p(g.location,g.content);case"remove-toolbar-contribution":return d();case"query":return c({type:R,path:g.path,query:g.query});default:return}},[c,t,h,f,p,d]),l]};import{useForkRef as Id,useIdMemo as kd}from"@salt-ds/core";import Od from"classnames";import gn,{forwardRef as Vd,useCallback as Ad,useMemo as Nd,useRef as ga,useState as _d}from"react";import{useCallback as ot,useMemo as ua}from"react";var ca=({id:r,rootRef:e,path:t,dropTargets:o,title:n})=>{let s=me(),{loadState:i,loadSessionState:a,purgeState:l,saveState:u,saveSessionState:c}=yt(),[p,d]=Qr(r,e,t,o),h=ua(()=>{var v;return(v=i("view-title"))!=null?v:n},[i,n]),f=ot(v=>{t&&s({type:"set-title",path:t,title:v})},[s,t]),b=ua(()=>i(r),[r,i]),y=ot(v=>i(r,v),[r,i]),g=ot(v=>{l(r,v),s({type:"save"})},[r,s,l]),C=ot((v,S)=>{u(r,S,v),s({type:"save"})},[r,s,u]),R=ot(v=>a(r,v),[r,a]),w=ot((v,S)=>c(r,S,v),[r,c]),x=ot(({type:v,...S})=>{let{[v]:E}=S;C(E,v)},[C]);return{contributions:d,dispatchViewAction:p,load:y,loadSession:R,onConfigChange:x,onEditTitle:f,purge:g,restoredState:b,save:C,saveSession:w,title:h}};import{useCallback as pa,useRef as da}from"react";var Md=[],ha=({mainRef:r,resize:e="responsive",rootRef:t})=>{let o=e==="defer",n=da({}),s=da(),i=pa(()=>{r.current&&(r.current.style.height=n.current.height+"px",r.current.style.width=n.current.width+"px"),s.current=void 0},[r]),a=pa(({height:l,width:u})=>{n.current.height=l,n.current.width=u,s.current!==null&&clearTimeout(s.current),s.current=window.setTimeout(i,40)},[i]);qr(t,o?ea:Md,a,o)};import Ld,{useContext as fa}from"react";var Dd={dispatch:null},Kr=Ld.createContext(Dd),ma=()=>{var e;let r=fa(Kr);return(e=r==null?void 0:r.dispatch)!=null?e:null},ti=()=>fa(Kr);import{jsx as mn,jsxs as Fd}from"react/jsx-runtime";var Yt="vuuView",Bd=(r,e)=>r&&e?{...r,...e}:r||e,ya=Vd(function(e,t){let{Header:o=ba,children:n,className:s,collapsed:i,closeable:a,"data-path":l,"data-resizeable":u,dropTargets:c,expanded:p,flexFill:d,id:h,header:f,orientation:b="horizontal",path:y=l,resize:g="responsive",resizeable:C=u,tearOut:R,style:w={},title:x,...v}=e,S=kd(h),E=ga(null),M=ga(null),[P,T]=_d(),{contributions:D,dispatchViewAction:V,load:_,loadSession:F,onConfigChange:z,onEditTitle:ee,purge:q,restoredState:K,save:de,saveSession:Ee,title:Pe}=ca({id:S,rootRef:E,path:y,dropTargets:c,title:x});ha({mainRef:M,resize:g,rootRef:E});let Ke=Ad(Du=>{T(Du)},[]),vr=()=>gn.isValidElement(n)&&(K||P)?gn.cloneElement(n,Bd(K,P)):n,Mu=Nd(()=>({dispatch:V,id:S,path:y,title:Pe,load:_,loadSession:F,onConfigChange:z,purge:q,save:de,saveSession:Ee,setComponentProps:Ke}),[V,S,_,F,z,y,q,de,Ee,Ke,Pe]),Lu=typeof f=="object"?f:{};return mn("div",{...v,className:Od(Yt,s,{[`${Yt}-collapsed`]:i,[`${Yt}-expanded`]:p,[`${Yt}-resize-defer`]:g==="defer"}),"data-resizeable":C,id:S,ref:Id(t,E),style:w,tabIndex:-1,children:Fd(Kr.Provider,{value:Mu,children:[f?mn(o,{...Lu,collapsed:i,contributions:D,expanded:p,closeable:a,onEditTitle:ee,orientation:b,tearOut:R,title:Pe}):null,mn("div",{className:`${Yt}-main`,ref:M,children:vr()})]})})});ya.displayName="View";var Fe=gn.memo(ya);Fe.displayName="View";G("View",Fe,"view");import{jsx as er}from"react/jsx-runtime";var yn="vuuHeader",ba=({className:r,contributions:e,collapsed:t,closeable:o,onEditTitle:n,orientation:s="horizontal",style:i,title:a="Untitled"})=>{let l=Ud(null),[u,c]=wa(a),[p,d]=wa(!1),h=ma(),f=P=>h==null?void 0:h({type:"remove"},P),b=()=>{var P;(P=l.current)==null||P.focus()},y=P=>{P.stopPropagation()},C=$d(yn,r,`${yn}-${t||s}`),R=()=>{d(!0)},w=P=>{P.key==="Enter"&&d(!0)},x=(P="",T="",D=!0,V=!1)=>{var _;d(!1),V?c(P):T!==P&&(c(T),n==null||n(T)),D===!1&&((_=l.current)==null||_.focus())},v=P=>{h==null||h({type:"mousedown"},P)},S=[],E=[],M=[];return e==null||e.forEach((P,T)=>{switch(P.location){case"pre-title":S.push(va(P.content,{key:T}));break;default:E.push(va(P.content,{key:T}))}}),a&&S.push(er(zd,{className:`${yn}-title`,editing:p,value:u,onChange:c,onMouseDownCapture:b,onEnterEditMode:R,onExitEditMode:x,onKeyDown:w,ref:l,tabIndex:0},"title")),o&&M.push(er(Hd,{"data-icon":"close",onClick:f,onMouseDown:y,variant:"secondary"},"close")),E.length>0&&S.push(er("div",{className:"vuuTooltrayProxy","data-align":"end",children:E},"contributions")),M.length>0&&S.push(er("div",{className:"vuuTooltrayProxy","data-align":"end",children:M},"actions")),er("div",{className:Wd("vuuToolbarProxy",C),style:i,onMouseDown:v,children:S})};var yx={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},Sa={layout:{type:"Component",id:"loading-main",props:{}}},jr={layout:{type:"Stack",id:"main-tabs",props:{className:"vuuShell-mainTabs",TabstripProps:{allowAddTab:!0,allowCloseTab:!0,allowRenameTab:!0,animateSelectionThumb:!1,location:"main-tab",tabClassName:"MainTab"},preserve:!0,active:0},children:[{props:{id:"tab1",title:"Tab 1",className:"vuuShell-Placeholder"},type:"Placeholder"}]}};import{getLocalEntity as bn,saveLocalEntity as vn}from"@vuu-ui/vuu-filters";import{formatDate as Gd,getUniqueId as qd}from"@vuu-ui/vuu-utils";var Ca="layouts/metadata",Ra="layouts/layouts",vt,wn=class{constructor(e){N(this,vt,"api/vui");e&&L(this,vt,e)}createLayout(e,t){return new Promise(o=>{Promise.all([this.loadLayouts(),this.loadMetadata()]).then(([n,s])=>{let i=qd(),a={...e,id:i,created:Gd(new Date,"dd.mm.yyyy")};this.saveLayoutsWithMetadata([...n,{id:i,json:t}],[...s,a]),o(a)})})}updateLayout(e,t,o){return new Promise((n,s)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([i,a])=>{let l=i.map(c=>c.id===e?{...c,json:o}:c),u=a.map(c=>c.id===e?{...c,...t}:c);this.saveLayoutsWithMetadata(l,u),n()}).catch(i=>s(i))})}deleteLayout(e){return new Promise((t,o)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([n,s])=>{let i=n.filter(l=>l.id!==e),a=s.filter(l=>l.id!==e);this.saveLayoutsWithMetadata(i,a),t()}).catch(n=>o(n))})}loadLayout(e){return new Promise((t,o)=>{this.validateId(e,"layout").then(()=>this.loadLayouts()).then(n=>{let s=n.find(i=>i.id===e);s?t(s.json):o(new Error(`no layout found matching id ${e}`))}).catch(n=>o(n))})}loadMetadata(){return new Promise(e=>{let t=bn(Ca);e(t||[])})}loadApplicationJSON(){return new Promise(e=>{let t=bn(m(this,vt));e(t||jr)})}saveApplicationJSON(e){return new Promise((t,o)=>{vn(m(this,vt),e)?t():o(new Error("Application Json failed to save"))})}loadLayouts(){return new Promise(e=>{let t=bn(Ra);e(t||[])})}saveLayoutsWithMetadata(e,t){vn(Ra,e),vn(Ca,t)}async validateIds(e){return Promise.all([this.validateId(e,"metadata").catch(t=>t.message),this.validateId(e,"layout").catch(t=>t.message)]).then(t=>{let o=t.filter(n=>n!==void 0).join("; ");if(o)throw new Error(o)})}validateId(e,t){return new Promise((o,n)=>{(t==="metadata"?this.loadMetadata:this.loadLayouts)().then(i=>{switch(i.filter(l=>l.id===e).length){case 1:{o();break}case 0:{n(new Error(`No ${t} with ID ${e}`));break}default:n(new Error(`Non-unique ${t} with ID ${e}`))}})})}};vt=new WeakMap;var nt="http://127.0.0.1:8081/api",Jd="layouts/metadata",Xr="layouts",xa="application-layouts",Ta=class{createLayout(e,t){return new Promise((o,n)=>fetch(`${nt}/${Xr}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({metadata:e,definition:t})}).then(s=>{s.ok||n(new Error(s.statusText)),s.json().then(({metadata:i})=>{i||n(new Error("Response did not contain valid metadata")),o(i)})}).catch(s=>{n(s)}))}updateLayout(e,t,o){return new Promise((n,s)=>fetch(`${nt}/${Xr}/${e}`,{method:"PUT",body:JSON.stringify({metadata:t,layout:o})}).then(i=>{i.ok||s(new Error(i.statusText)),n()}).catch(i=>{s(i)}))}deleteLayout(e){return new Promise((t,o)=>fetch(`${nt}/${Xr}/${e}`,{method:"DELETE"}).then(n=>{n.ok||o(new Error(n.statusText)),t()}).catch(n=>{o(n)}))}loadLayout(e){return new Promise((t,o)=>{fetch(`${nt}/${Xr}/${e}`,{method:"GET"}).then(n=>{n.ok||o(new Error(n.statusText)),n.json().then(({definition:s})=>{s||o(new Error("Response did not contain a valid layout")),t(s)})}).catch(n=>{o(n)})})}loadMetadata(){return new Promise((e,t)=>fetch(`${nt}/${Jd}`,{method:"GET"}).then(o=>{o.ok||t(new Error(o.statusText)),o.json().then(n=>{n||t(new Error("Response did not contain valid metadata")),e(n)})}).catch(o=>{t(o)}))}saveApplicationJSON(e){return new Promise((t,o)=>fetch(`${nt}/${xa}`,{method:"PUT",headers:{"Content-Type":"application/json",username:"vuu-user"},body:JSON.stringify(e)}).then(n=>{n.ok||o(new Error(n.statusText)),t()}).catch(n=>{o(n)}))}loadApplicationJSON(){return new Promise((e,t)=>fetch(`${nt}/${xa}`,{method:"GET",headers:{username:"vuu-user"}}).then(o=>{o.ok||t(new Error(o.statusText)),o.json().then(n=>{n||t(new Error("Response did not contain valid application layout information")),e(n.definition)})}).catch(o=>{t(o)}))}};import{useCallback as dT}from"react";import fT from"classnames";import{useCallback as _x,useEffect as Bx,useRef as Fx,useState as zx}from"react";import{Button as $x,FormField as Wx,FormFieldLabel as Ux}from"@salt-ds/core";import{VuuInput as qx}from"@vuu-ui/vuu-ui-controls";import{useMemo as Ex}from"react";import{jsx as Mx,jsxs as Lx}from"react/jsx-runtime";import Kx from"classnames";import{jsx as Zx,jsxs as Yx}from"react/jsx-runtime";import{getCookieValue as rT}from"@vuu-ui/vuu-utils";import{Button as vT}from"@salt-ds/core";import{jsx as ST,jsxs as CT}from"react/jsx-runtime";import LT,{useEffect as DT,useState as IT}from"react";import OT from"classnames";import{Fragment as _T,jsx as BT,jsxs as NT}from"react/jsx-runtime";import{useCallback as UT}from"react";import qT from"classnames";import{jsx as QT}from"react/jsx-runtime";import La,{Suspense as Yd,useEffect as eh}from"react";import Kd from"react";import{Fragment as jd,jsx as Ea,jsxs as Xd}from"react/jsx-runtime";var Zr=class extends Kd.Component{constructor(e){super(e),this.state={errorMessage:null}}static getDerivedStateFromError(e){return{errorMessage:e.message}}componentDidCatch(e,t){console.log(`error creating component at ${this.props.url}`),console.log(e,t)}render(){return this.state.errorMessage?Xd(jd,{children:[Ea("h1",{children:"An error occured while creating component."}),Ea("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as Zd}from"react/jsx-runtime";var Pa=()=>Zd("div",{className:"hwLoader"});var Ma=async r=>{let e=new CSSStyleSheet;return fetch(r).then(t=>t.text()).then(t=>e.replace(t))};import{jsx as eo}from"react/jsx-runtime";var Yr=new Map,th=r=>{eh(()=>()=>{Yr.delete(r)},[r]),Yr.has(r)||Yr.set(r,La.lazy(()=>import(r)));let e=Yr.get(r);if(e)return e;throw Error(`Unable to load Lazy Feature at url ${r}`)};function rh({url:r,css:e,ComponentProps:t,...o}){e&&Ma(e).then(s=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,s]});let n=th(r);return eo(Zr,{url:r,children:eo(Yd,{fallback:eo(Pa,{}),children:eo(n,{...o,...t})})})}var Sn=La.memo(rh);Sn.displayName="Feature";G("Feature",Sn,"view");import{useEffect as oh,useState as tr}from"react";import{Input as nh,Button as Da,FormField as to,FormFieldLabel as ro,Text as sh}from"@salt-ds/core";import{ComboBox as ih,Checkbox as ah,RadioButton as lh}from"@vuu-ui/vuu-ui-controls";import{takeScreenshot as uh}from"@vuu-ui/vuu-utils";import{jsx as se,jsxs as $e}from"react/jsx-runtime";var pe="saveLayoutPanel",oo=`${pe}-formField`,ch=["Group 1","Group 2","Group 3","Group 4","Group 5"],ph=["Value 1","Value 2","Value 3"],Ia=["Value 1","Value 2","Value 3"],ka=r=>{let{defaultTitle:e="",onCancel:t,onSave:o,componentId:n}=r,[s,i]=tr(e),[a,l]=tr(""),[u,c]=tr([]),[p,d]=tr(Ia[0]),[h,f]=tr();oh(()=>{n&&uh(document.getElementById(n)).then(y=>f(y))},[n]);let b=()=>{o({name:s,group:a,screenshot:h!=null?h:"",user:"User"})};return $e("div",{className:`${pe}-panelContainer`,children:[$e("div",{className:`${pe}-panelContent`,children:[$e("div",{className:`${pe}-formContainer`,children:[$e(to,{className:oo,children:[se(ro,{children:"Group"}),se(ih,{source:ch,allowFreeText:!0,InputProps:{inputProps:{className:`${pe}-inputText`,placeholder:"Select Group or Enter New Name",onChange:y=>l(y.target.value)}},width:"100%",onSelectionChange:(y,g)=>l(g||"")})]}),$e(to,{className:oo,children:[se(ro,{children:"Layout Name"}),se(nh,{inputProps:{className:`${pe}-inputText`,placeholder:"Enter Layout Name"},onChange:y=>i(y.target.value),value:s})]}),$e(to,{className:oo,children:[se(ro,{children:"Some Layout Setting"}),se("div",{className:`${pe}-settingsGroup`,children:ph.map((y,g)=>se(ah,{onToggle:()=>c(C=>C.includes(y)?C.filter(R=>R!==y):[...C,y]),checked:u.includes(y),label:y},g))})]}),$e(to,{className:oo,children:[se(ro,{children:"Some Layout Setting"}),se("div",{className:`${pe}-settingsGroup`,children:Ia.map((y,g)=>se(lh,{onClick:()=>d(y),checked:p===y,label:y,groupName:"radioGroup"},g))})]})]}),se("div",{className:`${pe}-screenshotContainer`,children:h?se("img",{className:`${pe}-screenshot`,src:h,alt:"screenshot of current layout"}):se(sh,{className:"screenshot",children:"No screenshot available"})})]}),$e("div",{className:`${pe}-buttonsContainer`,children:[se(Da,{className:`${pe}-cancelButton`,onClick:t,children:"Cancel"}),se(Da,{className:`${pe}-saveButton`,onClick:b,disabled:s===""||a==="",children:"Save"})]})]})};import{List as qE}from"@vuu-ui/vuu-ui-controls";import dh,{useCallback as PE,useContext as hh,useEffect as ME,useRef as LE,useState as DE}from"react";import{NotificationLevel as BE,useNotifications as FE}from"@vuu-ui/vuu-popups";import{jsx as HE}from"react/jsx-runtime";var fh=dh.createContext({layoutMetadata:[],saveLayout:()=>{},applicationJson:jr,saveApplicationLayout:()=>{},saveApplicationSettings:()=>{},loadLayoutById:()=>{}});var no=()=>hh(fh);import{Fragment as XE,jsx as jE,jsxs as ZE}from"react/jsx-runtime";import{memo as mh}from"react";import{jsx as ge,jsxs as wt}from"react/jsx-runtime";var Oa=mh(()=>wt("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[wt("g",{clipPath:"url(#clip0_217_6990)",children:[ge("path",{d:"M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",fill:"url(#paint0_linear_217_6990)"}),ge("path",{d:"M42.6246 24.8716C41.9199 25.9157 40.9625 26.824 39.767 27.4905C38.424 28.2396 36.9563 28.597 35.5081 28.597C32.7541 28.597 30.0715 27.3094 28.4466 24.9855L15.772 3.90967L15.7655 3.9206C13.3615 0.137431 8.25372 -1.13143 4.24754 1.10507C0.178173 3.37435 -1.20852 8.39359 1.14854 12.3125L18.3445 40.9095C19.1108 42.1846 20.1816 43.1834 21.4144 43.8764C21.4241 43.8826 21.4338 43.8889 21.4435 43.8951C21.4484 43.8982 21.4549 43.9013 21.4597 43.9045C22.0332 44.2228 22.6423 44.471 23.2725 44.6536C23.3194 44.6677 23.368 44.6817 23.415 44.6942C23.6418 44.7551 23.8702 44.8097 24.1019 44.8534C24.1456 44.8612 24.1894 44.8659 24.2331 44.8737C24.4194 44.9049 24.6073 44.9314 24.7952 44.9501C24.8698 44.9579 24.9443 44.9658 25.0188 44.9704C25.2342 44.9876 25.4497 44.9985 25.6668 45.0001C25.6781 45.0001 25.6895 45.0001 25.6992 45.0001C25.7024 45.0001 25.704 45.0001 25.7073 45.0001C25.7105 45.0001 25.7121 45.0001 25.7154 45.0001C25.9503 45.0001 26.1868 44.9876 26.4217 44.9689C26.4751 44.9642 26.5286 44.9595 26.5837 44.9533C26.8137 44.9299 27.0438 44.9002 27.2738 44.8596C27.277 44.8596 27.2803 44.8596 27.2835 44.8596C27.5362 44.8144 27.7889 44.7551 28.0384 44.6864C28.0546 44.6817 28.0692 44.677 28.0854 44.6723C28.4483 44.5709 28.8063 44.4445 29.1594 44.2931C29.1659 44.29 29.174 44.2868 29.1805 44.2837C29.4494 44.1682 29.7151 44.0418 29.9759 43.8967C30.24 43.75 30.491 43.5908 30.7308 43.4206C30.9398 43.2739 31.1407 43.1179 31.3367 42.9524C31.5748 42.7495 31.8 42.5373 32.009 42.3141C32.1661 42.1471 32.3168 41.9723 32.4609 41.7913C32.5079 41.732 32.5517 41.6711 32.5954 41.6118C32.6942 41.4807 32.7882 41.3465 32.8789 41.2091C32.9259 41.1373 32.9728 41.0671 33.0182 40.9953C33.036 40.9672 33.0555 40.9407 33.0717 40.9126L42.7153 24.8763H42.6214L42.6246 24.8716Z",fill:"url(#paint1_linear_217_6990)"}),ge("path",{d:"M42.8402 16.4218L42.1112 15.2232L38.9636 9.58433L37.504 7.19644C37.2286 6.56123 36.579 6.11331 35.8176 6.11331C34.8083 6.11331 33.9919 6.90147 33.9919 7.87223C33.9919 8.20154 34.0907 8.50432 34.2543 8.76808L34.2349 8.78056L39.9048 18.0808C40.5884 19.2186 40.7715 20.5437 40.4199 21.8141C40.0684 23.0845 39.226 24.1458 38.045 24.806C37.2675 25.2398 36.3846 25.4693 35.4936 25.4693C33.6727 25.4693 31.9766 24.5281 31.0662 23.0143L22.9161 9.63271H22.9323L19.4899 3.90958L19.4834 3.92051C19.4235 3.8253 19.3538 3.73947 19.2907 3.64738L19.1935 3.48663C19.1935 3.48663 19.1854 3.49131 19.1821 3.49443C17.5654 1.27666 14.9799 0.0390178 12.3118 0.00936427V0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.961 26.8255 41.9168 25.9156 42.6231 24.8731H42.717L42.6846 24.9261C43.1366 24.2347 43.4833 23.4731 43.7068 22.6615C44.2916 20.5452 43.9871 18.3352 42.8369 16.4234L42.8402 16.4218Z",fill:"#F37880"}),wt("g",{opacity:"0.86",children:[ge("path",{d:"M34.2332 8.78212L39.9031 18.0824C40.5868 19.2202 40.7698 20.5452 40.4183 21.8156C40.2044 22.5897 39.8059 23.2858 39.2616 23.8617C39.9744 23.2343 40.4879 22.4243 40.7423 21.5035C41.0938 20.2331 40.9107 18.908 40.2271 17.7703L34.5572 8.46998L34.5767 8.4575C34.413 8.19374 34.3142 7.89096 34.3142 7.56165C34.3142 7.15586 34.4584 6.78285 34.6982 6.48476C34.2672 6.80626 33.9902 7.30881 33.9902 7.87379C33.9902 8.2031 34.0891 8.50588 34.2527 8.76964L34.2332 8.78212Z",fill:"white"}),ge("path",{d:"M42.6917 24.9169L42.6863 24.9256C42.6863 24.9256 42.6899 24.9187 42.6935 24.9152C42.6935 24.9152 42.6935 24.9152 42.6935 24.9169H42.6917Z",fill:"white"}),ge("path",{d:"M40.0911 27.1798C38.7481 27.9289 37.2804 28.2863 35.8322 28.2863C33.0782 28.2863 30.3955 26.9988 28.7707 24.6749L16.0961 3.59744L16.0896 3.60837C14.9281 1.78077 13.1364 0.543128 11.1422 0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.4815 27.0924 41.1084 26.6055 41.6511 26.0561C41.1862 26.479 40.6662 26.8583 40.0894 27.1798H40.0911Z",fill:"white"})]})]}),wt("defs",{children:[wt("linearGradient",{id:"paint0_linear_217_6990",x1:"24.6235",y1:"18.7363",x2:"42.3152",y2:"18.7363",gradientUnits:"userSpaceOnUse",children:[ge("stop",{stopColor:"#4906A5"}),ge("stop",{offset:"1",stopColor:"#D3423A"})]}),wt("linearGradient",{id:"paint1_linear_217_6990",x1:"-2.35794e-05",y1:"22.5009",x2:"42.7186",y2:"22.5009",gradientUnits:"userSpaceOnUse",children:[ge("stop",{stopColor:"#7C06A5"}),ge("stop",{offset:"1",stopColor:"#D3423A"})]}),ge("clipPath",{id:"clip0_217_6990",children:ge("rect",{width:"44",height:"45",fill:"white"})})]})]}));Oa.displayName="VuuLogo";import{Tab as B0,Tabstrip as F0}from"@vuu-ui/vuu-ui-controls";import H0 from"classnames";import{useCallback as q0,useState as J0}from"react";import{jsx as y0,jsxs as b0}from"react/jsx-runtime";import{createContext as gh,isValidElement as yh,cloneElement as bh,useContext as vh}from"react";import wh from"classnames";import{jsx as Th}from"react/jsx-runtime";var Sh="medium",Ch="salt-theme",Rh="light",Aa=gh({density:"high",theme:"vuu",themeMode:"light"});var xh=(r,e,t,o)=>{var n;return yh(r)?bh(r,{className:wh((n=r.props)==null?void 0:n.className,`${e}-theme`,`${e}-density-${o}`),"data-mode":t}):(console.warn(`
|
|
205
18
|
ThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.
|
|
206
|
-
Wrap elements with a single container`),r)},Qb=({applyThemeClasses:r=!1,children:e,theme:t,themeMode:n,density:o})=>{var f,d,p;let{density:i,themeMode:s,theme:l}=$R(Jb),a=(f=o!=null?o:i)!=null?f:GR,c=(d=n!=null?n:s)!=null?d:KR,u=(p=t!=null?t:l)!=null?p:qR,h=r?jR(e,u,c,a):e;return JR(Jb.Provider,{value:{themeMode:c,density:a,theme:u},children:h})};Qb.displayName="ThemeProvider";import{jsx as x7,jsxs as v7}from"react/jsx-runtime";import{useState as I7}from"react";import{Button as D7,FormField as L7,FormFieldLabel as A7,Input as O7}from"@salt-ds/core";import{jsx as F7,jsxs as B7}from"react/jsx-runtime";import{getCookieValue as YR}from"@vuu-ui/vuu-utils";var XR=()=>{let r=YR("vuu-auth-mode");return r!=null?r:""};var ZR=()=>XR()==="login"?"login.html":"demo.html",eI=(r=ZR())=>{window.location.href=r},Yb=r=>{document.cookie="vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",document.cookie="vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",eI(r)};import{useCallback as Z7,useEffect as eG,useMemo as tG,useRef as nG,useState as rG}from"react";import iG from"classnames";import{useIdMemo as lG}from"@salt-ds/core";import{Button as cG}from"@salt-ds/core";import{buildColumnMap as pG,isValidNumber as mG,shallowEquals as gG}from"@vuu-ui/vuu-utils";import{jsx as xG,jsxs as vG}from"react/jsx-runtime";import jK from"classnames";import{useCallback as ZK,useEffect as ej,useRef as tj}from"react";import{useCallback as Hq}from"react";import{Button as iq}from"@salt-ds/core";import{jsx as t0}from"react/jsx-runtime";import{forwardRef as tI}from"react";function Xb(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(t=Xb(r[e]))&&(n&&(n+=" "),n+=t);else for(e in r)r[e]&&(n&&(n+=" "),n+=e);return n}function Zb(){for(var r,e,t=0,n="";t<arguments.length;)(r=arguments[t++])&&(e=Xb(r))&&(n&&(n+=" "),n+=e);return n}var e0=`/* Style applied to the root element */
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
--icon-size-multiplier: var(--saltIcon-size-multiplier, 1);
|
|
210
|
-
--icon-base-size: var(--salt-icon-size-base, 12px);
|
|
211
|
-
/**
|
|
212
|
-
* Icon size will be the multiplier (an integer from the size prop) * the base size (set by the theme per density)
|
|
213
|
-
* Icons should never be smaller than 12px for readability so we've added a max() to enforce this
|
|
214
|
-
* Consumers can use --saltIcon-size variable to override this rule as an escape hatch
|
|
215
|
-
*/
|
|
216
|
-
--icon-size: var(--saltIcon-size, max(calc(var(--icon-base-size) * var(--icon-size-multiplier)), 12px));
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.saltIcon {
|
|
220
|
-
fill: var(--saltIcon-color, var(--icon-color));
|
|
221
|
-
display: inline-block;
|
|
222
|
-
margin: var(--saltIcon-margin, 0);
|
|
223
|
-
position: relative;
|
|
224
|
-
width: var(--icon-size);
|
|
225
|
-
height: var(--icon-size);
|
|
226
|
-
min-width: var(--icon-size);
|
|
227
|
-
min-height: var(--icon-size);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.saltIcon:hover {
|
|
231
|
-
--icon-color: var(--saltIcon-color-hover, var(--salt-text-secondary-foreground));
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.saltIcon:active {
|
|
235
|
-
--icon-color: var(--saltIcon-color-active, var(--salt-text-secondary-foreground));
|
|
236
|
-
}
|
|
237
|
-
`;var nI=r=>(...e)=>[r,...e].join("-"),rI=nI("saltIcon"),oI=1,n0=tI(function({children:e,className:t,size:n=oI,style:o,...i},s){let l=un();hn({testId:"salt-icon",css:e0,window:l});let a={...o,"--saltIcon-size-multiplier":`${n}`};return t0("svg",{className:Zb(rI(),t),style:a,role:"img",...i,ref:s,children:t0("g",{"aria-hidden":!0,children:e})})});import{jsxs as iI,jsx as r0}from"react/jsx-runtime";import{forwardRef as sI}from"react";var fh=sI(function(e,t){return iI(n0,{"data-testid":"ExportIcon","aria-label":"export",viewBox:"0 0 12 12",ref:t,...e,children:[r0("path",{d:"M5 1H1v10h4v-1H2V2h3V1Z"}),r0("path",{d:"M3 5h5V3l4 3-4 3V7H3V5Z"})]})});import{formatDate as lI}from"@vuu-ui/vuu-utils";import{Button as aI}from"@salt-ds/core";import{forwardRef as cI,useCallback as i0,useEffect as uI,useState as hI}from"react";var o0=async r=>await fetch(`api/vui/${r.username}`,{}).then(t=>t.ok?t.json():null).catch(()=>{console.log("error getting history")});import{jsx as Wl,jsxs as s0}from"react/jsx-runtime";var fI=({lastUpdate:r},{lastUpdate:e})=>e===r?0:e<r?-1:1,dI=r=>Wl(ki,{...r}),pI=cI(function({loginUrl:e,onNavigate:t,user:n,layoutId:o="latest"},i){let[s,l]=hI([]);uI(()=>{async function h(){let d=(await o0(n)).filter(p=>p.id!=="latest").sort(fI).map(({id:p,lastUpdate:m})=>({lastUpdate:m,id:p,label:`Saved at ${lI(new Date(m),"kk:mm:ss")}`}));console.log({sortedHistory:d}),l(d)}h()},[n]);let a=i0((h,f)=>{f&&t(f.id)},[t]),c=i0(()=>{Yb(e)},[e]),u=s.length===0?null:o==="latest"?s[0]:s.find(h=>h.id===o);return s0("div",{className:"vuuUserPanel",ref:i,children:[Wl(ch,{ListItem:dI,className:"vuuUserPanel-history",onSelect:a,selected:u,source:s}),Wl("div",{className:"vuuUserPanel-buttonBar",children:s0(aI,{"aria-label":"logout",onClick:c,children:[Wl(fh,{})," Logout"]})})]})});import{jsx as cq,jsxs as uq}from"react/jsx-runtime";import yq from"classnames";import{ToggleButton as xq,ToggleButtonGroup as vq,useControlled as wq}from"@salt-ds/core";import{useCallback as kq}from"react";import{jsx as Rq,jsxs as Iq}from"react/jsx-runtime";import $q from"classnames";import{jsx as qq,jsxs as Kq}from"react/jsx-runtime";import{logger as mI}from"@vuu-ui/vuu-utils";import{Button as eK}from"@salt-ds/core";import nK from"classnames";import{useCallback as oK,useMemo as iK}from"react";import{jsx as uK,jsxs as hK}from"react/jsx-runtime";import{jsx as xK,jsxs as vK}from"react/jsx-runtime";import{useCallback as MK,useRef as EK,useState as RK}from"react";import{jsx as PK,jsxs as DK}from"react/jsx-runtime";import{jsx as dj,jsxs as pj}from"react/jsx-runtime";var{error:hj}=mI("Shell");import{createContext as gI,useContext as vj}from"react";import{jsx as Cj}from"react/jsx-runtime";var yI={},wj=gI(yI);import{useCallback as l0,useMemo as bI,useState as xI}from"react";import{jsx as vI}from"react/jsx-runtime";var Uj=()=>{let[r,e]=xI(),{saveLayout:t}=_l(),n=l0(()=>{e(void 0)},[]),o=l0(l=>{t(l),e(void 0)},[t]),[i,s]=bI(()=>[(l,a)=>{let c=l.split(" "),u=[];return c.includes("main-tab")&&u.push({label:"Save Layout",action:"save-layout",options:a},{label:"Layout Settings",action:"layout-settings",options:a}),u},l=>(console.log("menu action",{action:l}),l.menuId==="save-layout"?(e(vI(qb,{onCancel:n,onSave:o,componentId:l.options.controlledComponentId})),!0):!1)],[n,o]);return{buildMenuOptions:i,dialogContent:r,handleCloseDialog:n,handleMenuAction:s}};import{forwardRef as NI}from"react";import{isValidNumber as An}from"@vuu-ui/vuu-utils";import{useCallback as CI,useEffect as TI,useMemo as kI,useRef as MI,useState as EI}from"react";import{useCallback as wI,useEffect as a0,useRef as SI}from"react";var vr=new Map,u0=(r,e,t)=>{switch(t){case"height":return e.height;case"clientHeight":return Math.floor(r.clientHeight);case"clientWidth":return Math.floor(r.clientWidth);case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(Math.floor(r.scrollHeight));case"scrollWidth":return Math.ceil(Math.floor(r.scrollWidth));case"width":return e.width;default:return 0}},c0=new ResizeObserver(r=>{for(let e of r){let{target:t,borderBoxSize:n,contentBoxSize:o}=e,i=vr.get(t);if(i){let[{blockSize:s,inlineSize:l}]=n,[{blockSize:a,inlineSize:c}]=o,{onResize:u,measurements:h}=i,f=!1;for(let[d,p]of Object.entries(h)){let m=u0(t,{height:s,width:l,contentHeight:a,contentWidth:c},d);m!==p&&(f=!0,h[d]=m)}f&&u&&u(h)}}});function h0(r,e,t,n=!1){let o=SI(e),i=wI(s=>{let{width:l,height:a}=s.getBoundingClientRect(),{clientWidth:c,clientHeight:u}=s,h=Math.floor(a),f=Math.floor(l);return o.current.reduce((d,p)=>(d[p]=u0(s,{width:f,height:h,contentHeight:u,contentWidth:c},p),d),{})},[]);a0(()=>{let s=r.current;async function l(){vr.set(s,{measurements:{}});let a=vr.get(s);if(a){let c=i(s);a.measurements=c,c0.observe(s),n&&t(c)}else console.log("%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation","font-weight:bold; color:red;")}return s&&(vr.has(s)&&console.log("useResizeObserver attemping to observe same element twice",{target:s}),l()),()=>{s&&vr.has(s)&&(c0.unobserve(s),vr.delete(s))}},[i,r]),a0(()=>{let s=r.current,l=vr.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}var RI=["clientHeight","clientWidth"],II=["clientWidth"],PI=["clientHeight"],DI=[],$l=r=>Number.isFinite(r),LI={height:"100%",width:"auto"},AI=(r,e)=>An(r)&&An(e)?{height:`${r}px`,width:`${e}px`}:typeof r=="string"||typeof e=="string"?{height:r!=null?r:"100%",width:e!=null?e:"auto"}:LI,OI=(r,e)=>{if(An(r)&&An(e))return{height:r,width:e}},f0=({defaultHeight:r=0,defaultWidth:e=0,height:t,onResize:n,width:o})=>{let i=MI(null),[s,l]=EI({css:AI(t,o),inner:OI(t,o),outer:{height:t!=null?t:"100%",width:o!=null?o:"auto"}}),a=typeof t=="number",c=typeof o=="number",u=a&&c?DI:a?II:c?PI:RI;kI(()=>{l(f=>{let{inner:d,outer:p}=f;if(An(t)&&An(o)&&d&&p){let{height:m,width:y}=d,{height:g,width:v}=p;if(g!==t||v!==o){let w=An(g)?g-m:0,x=An(v)?v-y:0;return{...f,outer:{height:t,width:o},inner:{height:t-w,width:o-x}}}}return f})},[t,o]);let h=CI(({clientWidth:f,clientHeight:d})=>{let{css:p,inner:m,outer:y}=s,g=s;a&&$l(f)&&Math.floor(f)!==(m==null?void 0:m.width)?g={css:p,outer:y,inner:{width:Math.floor(f)||e,height:t}}:c&&$l(d)&&Math.floor(d)!==(m==null?void 0:m.height)?g={css:p,outer:y,inner:{height:Math.floor(d)||r,width:o}}:$l(d)&&$l(f)&&(f!==(m==null?void 0:m.width)||d!==(m==null?void 0:m.height))&&(g={css:p,outer:y,inner:{width:Math.floor(f)||e,height:Math.floor(d)||r}}),g!==s&&l(g)},[r,e,a,c,t,s,o]);return TI(()=>{s.inner&&(n==null||n(s.inner))},[n,s.inner]),h0(i,u,h,!0),{containerRef:i,cssSize:s.css,outerSize:s.outer,innerSize:s.inner}};import{useForkRef as VI}from"@salt-ds/core";import d0 from"classnames";import{jsx as p0}from"react/jsx-runtime";var dh="vuuMeasuredContainer",xJ=NI(function({children:e,className:t,height:n,onResize:o,style:i,width:s,...l},a){let{containerRef:c,...u}=f0({height:n,onResize:o,width:s}),{cssSize:h,innerSize:f}=u,d=f===void 0,p=()=>d?{"--measured-css-height":`${h.height}`,"--measured-css-width":`${h.width}`}:{...i,"--measured-css-height":`${h.height}`,"--measured-css-width":`${h.width}`,"--measured-px-height":`${f==null?void 0:f.height}px`,"--measured-px-width":`${f==null?void 0:f.width}px`},m=VI(c,a);return d?p0("div",{...l,className:d0(dh,`${dh}-ummeasured`),style:p(),ref:c}):p0("div",{...l,className:d0(dh,t),ref:m,style:p(),children:e})});import{PopupMenu as eP}from"@vuu-ui/vuu-popups";import ql from"classnames";import tP,{forwardRef as nP}from"react";import{useDragDropNext as QI}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as YI,MEASURES as XI}from"@vuu-ui/vuu-utils";import{useCallback as Gl,useMemo as gh,useRef as T0,useState as ZI}from"react";import{getElementByDataIndex as m0}from"@vuu-ui/vuu-utils";var FI=".vuuOverflowContainer-item:not(.wrapped)",EJ=r=>r!==null&&r.dataset.index==="overflow"&&r.parentElement!==null&&r.parentElement.classList.contains("vuuOverflowContainer-wrapContainer-overflowed"),BI=r=>r.sort((e,t)=>{let{dataset:{index:n="?"}}=e,{dataset:{index:o="?"}}=t,i=e.classList.contains("wrapped"),s=t.classList.contains("wrapped"),l=n==="overflow",a=o==="overflow";return i&&!s?1:!i&&s?-1:l?1:a?-1:parseInt(n)>parseInt(o)?1:-1}),ph=[],Ri=(r,e="horizontal")=>{let t=[],n=[],o=-1,i=!1,s=BI(Array.from(r.children)),l=e==="vertical"?"top":"left";for(let a of s){let c=a,{dataset:{index:u="?",label:h="?",overflowPriority:f="0"}}=c,{[l]:d}=c.getBoundingClientRect();d<=o?(u==="overflow"?n.push(t.pop()):n.push({index:u,label:h,overflowPriority:f}),i=!0):i?n.push({index:u,label:h,overflowPriority:f}):t.push({index:u,label:h,overflowPriority:f}),o=d}return[t,n]},g0=(r,e,t)=>{let n=!1,o=t?`${t}-overflowed`:"overflow";e.find(({index:i})=>i==="overflow")&&e.length===1&&(n=!0);for(let i of r.children){let{dataset:{index:s="?"}}=i;e.length===0||n?r.classList.remove(o):r.classList.add(o),s!=="overflow"&&e.find(l=>l.index===s)?i.classList.add("wrapped"):i.classList.remove("wrapped")}},HI=(r,{overflowPriority:e})=>Math.max(r,parseInt(e)),_I=(r,{overflowPriority:e})=>Math.min(r,parseInt(e)),y0=r=>{var e;return r.length>1&&((e=r.at(-1))==null?void 0:e.index)==="overflow"},zI=r=>{let[e]=r;for(let t=1;t<r.length;t++){let n=r[t];parseInt(n.overflowPriority)>parseInt(e.overflowPriority)&&(e=n)}return e},b0=(r,e)=>{var o;let t=r.reduce(_I,Number.MAX_SAFE_INTEGER);return e.reduce(HI,0)>t?!0:e.length>1&&((o=e.at(-1))==null?void 0:o.index)==="overflow"},x0=(r,e)=>new Promise(t=>{requestAnimationFrame(()=>{let[,n]=Ri(r);UI(e,n).forEach(i=>WI(r,i)),t(n)})}),v0=(r,e,t)=>new Promise(n=>{requestAnimationFrame(()=>{let[,o]=Ri(r),i=zI(o);if(i){let[s,l]=mh(r,i);n([s,l])}else n([e,t])})}),WI=(r,e)=>{let t=m0(r,e.index);if(t)t.classList.add("wrapped");else throw Error(`markElementAsWrapped element item with index ${e.index} not found`)},$I=r=>Array.from(r.querySelectorAll(".wrapped")),UI=(r,e)=>{let t=[];for(let n of e)r.find(({index:o})=>o===n.index)||t.push(n);return t},GI=(r,e)=>{$I(r).forEach(n=>{let{dataset:{index:o="?"}}=n;e.find(i=>i.index===o)||n.classList.remove("wrapped")})},w0=r=>r.querySelector('[data-index="overflow"]'),qI=r=>r.querySelector(".wrapped"),Ul=r=>parseInt(getComputedStyle(r).getPropertyValue("width")),S0=(r,e)=>{let{right:t}=r.getBoundingClientRect(),n=parseInt(getComputedStyle(r).getPropertyValue("padding-right")),{right:o}=e.getBoundingClientRect();return t-n-o},C0=r=>{let e=w0(r),t=S0(r,e),n=Ul(e),o=qI(r);return Ul(o)<=t+n?(r.classList.remove("overflowed"),o.classList.remove("wrapped"),!0):!1},KI=(r,e)=>{let{dataset:{index:t="0",overflowPriority:n="0"}}=r,{dataset:{index:o="0",overflowPriority:i="0"}}=e;return n>i?-1:n<i?1:parseInt(t)-parseInt(o)},jI=r=>Array.from(r.querySelectorAll(FI)).sort(KI),mh=(r,e)=>{let t=jI(r),n=m0(r,e.index,!0),o=-1,i=t.at(o),s=Ul(i),l=Ul(n),a=w0(r),c=S0(r,a)+s;if(c>=l)JI(n,i);else{let{left:f}=i.getBoundingClientRect(),d=c,p=[i];for(;c<l;){o-=1,i=t.at(o),p.push(i);let{left:m}=i.getBoundingClientRect(),y=f-m;c=d+y}n==null||n.classList.remove("wrapped"),p.forEach(m=>{m.classList.add("wrapped")})}let[u,h]=Ri(r);return GI(r,h),[u,h]},JI=(r,e)=>{if(!r||!e)throw Error("switchWrapOnElements, element undefined");r.classList.remove("wrapped"),e.classList.add("wrapped")};var k0=({allowDragDrop:r=!1,itemCount:e,onMoveItem:t,onSwitchWrappedItemIntoView:n,orientation:o="horizontal"})=>{let[i,s]=ZI(null),l=T0(ph),a=T0(null),c=Gl(w=>{var x;a.current&&((x=a.current.querySelector(".vuuOverflowContainer-OverflowIndicator button"))==null||x.setAttribute("tabindex",w))},[]),u=Gl(async()=>{if(i){let[w,x]=Ri(i,o);for(g0(i,x,"vuuOverflowContainer-wrapContainer"),y0(x)&&(x=await x0(i,x));b0(w,x);)[w,x]=await v0(i,w,x);x.length===1&&C0(i)&&(x=ph),l.current.length===0&&x.length>0?c("0"):l.current.length>0&&x.length===0&&c("-1"),l.current=x}},[i,o,c]),h=w=>typeof w=="object"&&w!==null&&"overflowItem"in w,[f,d]=gh(()=>[()=>{let{current:w}=l;return w.map(x=>({label:x.label,action:`activate-item-${x.index}`,options:{overflowItem:x}}))},({options:w})=>{if(i&&h(w)){let[,x]=mh(i,w.overflowItem);l.current=x,n==null||n(w.overflowItem)}return!0}],[i,n]),p=gh(()=>{let{sizeProp:w}=XI[o],x=0;return new ResizeObserver(S=>{for(let b of S){let{[w]:C}=b.contentRect,k=Math.round(C);YI(k)&&x!==k&&(x=k,u())}})},[u,o]);Qh(()=>{u()},[u,e]),gh(()=>{i&&p.observe(i)},[i,p]);let m=Gl(w=>{s(a.current=w)},[]),y=Gl((w,x)=>{t==null||t(w,x)},[t]),{onMouseDown:g,...v}=QI({allowDragDrop:r,containerRef:a,draggableClassName:"vuuOverflowContainer",onDrop:y,orientation:"horizontal",itemQuery:".vuuOverflowContainer-item"});return{menuActionHandler:d,menuBuilder:f,onItemMouseDown:g,rootRef:m,...v}};import{jsx as Ii,jsxs as rP}from"react/jsx-runtime";var ho="vuuOverflowContainer",M0=tP.memo(({PopupMenuProps:r,allowDragDrop:e,children:t,className:n,height:o,id:i,onMoveItem:s,onSwitchWrappedItemIntoView:l,orientation:a="horizontal",overflowIcon:c,overflowPosition:u="end"})=>{let h=wr(t),{draggable:f,draggedItemIndex:d,menuActionHandler:p,menuBuilder:m,onItemMouseDown:y,rootRef:g}=k0({allowDragDrop:e,itemCount:h.length,onMoveItem:s,onSwitchWrappedItemIntoView:l,orientation:a}),w={"--overflow-container-height":`${a==="vertical"?"100%":`${o}px`}`},x=ql(`${ho}-wrapContainer`,n,{[`${ho}-horizontal`]:a==="horizontal",[`${ho}-vertical`]:a==="vertical"}),S=h.map((C,k)=>{let{"data-align":E,"data-overflow-priority":R="0",id:M=`${i}-${k}`,label:P=`Item ${k+1}`}=C.props;return Ii("div",{className:ql(`${ho}-item`,{"vuuDraggable-dragAway":d===k}),"data-index":k,"data-align":E,"data-label":P,"data-overflow-priority":R,id:`${M}-wrapper`,onMouseDown:y,children:C},k)}),b=Ii("div",{className:`${ho}-OverflowIndicator`,"data-index":"overflow",children:Ii(eP,{...r,icon:c,menuBuilder:m,menuActionHandler:p,tabIndex:-1})},"overflow");return S.push(b),rP("div",{className:x,ref:g,style:w,children:[S,f]})});M0.displayName="OverflowContainer.InnerContainer";var E0=nP(function({PopupMenuProps:e,allowDragDrop:t=!1,children:n,className:o,height:i=44,id:s,onMoveItem:l,onSwitchWrappedItemIntoView:a,orientation:c,overflowIcon:u,overflowPosition:h,...f},d){let p=Sr(s);return Ii("div",{...f,className:ql(ql(ho,o)),id:p,ref:d,children:Ii(M0,{PopupMenuProps:e,allowDragDrop:t,height:i,id:p,orientation:c,overflowIcon:u,overflowPosition:h,onMoveItem:l,onSwitchWrappedItemIntoView:a,children:n})})});import{uuid as oP}from"@vuu-ui/vuu-utils";import{List as iP,ListItem as sP}from"@vuu-ui/vuu-ui-controls";import R0 from"classnames";import{cloneElement as lP,memo as aP}from"react";import{jsx as yh}from"react/jsx-runtime";var cP=r=>{let e=r.cloneNode(!0);return e.id="",delete e.dataset.idx,e},hh=aP(({className:r,children:e,idx:t,resizeable:n,header:o,closeable:i,...s})=>yh(sP,{className:R0("vuuPaletteItem",r),"data-draggable":!0,"data-icon":"draggable",...s}));hh.displayName="PaletteItem";var jb=({ListProps:r,ViewProps:e,children:t,className:n,itemHeight:o=41,orientation:i="horizontal",...s})=>{let l=ut(),a="vuuPalette";function c(u){var E,R;let f=u.target.closest(".vuuPaletteItem"),d=parseInt((R=(E=f.dataset)==null?void 0:E.index)!=null?R:"-1"),{props:{caption:p,children:m,template:y,...g}}=t[d],{height:v,left:w,top:x,width:S}=f.getBoundingClientRect(),b=oP(),k=y?m:yh(qn,{...e,...{id:b,key:b},...g,title:g.label,children:m});l({dragRect:{left:w,top:x,right:w+S,bottom:x+150,width:S,height:v},dragElement:cP(f),evt:u.nativeEvent,instructions:{DoNotRemove:!0,DoNotTransform:!0,DriftHomeIfNoDropTarget:!0,RemoveDraggableOnDragEnd:!0,dragThreshold:10},path:"*",payload:k,type:"drag-start"})}return yh(iP,{...r,...s,className:R0(a,n,`${a}-${i}`),itemHeight:o,selected:null,children:t.map((u,h)=>u.type===hh?lP(u,{key:h,onMouseDown:c}):u)})};ge("Palette",jb,"view");import{Tab as uP,Tabstrip as hP}from"@vuu-ui/vuu-ui-controls";import I0 from"classnames";import bh,{forwardRef as fP,useCallback as dP}from"react";import{jsx as D0,jsxs as bP}from"react/jsx-runtime";var P0="Tabs",pP=()=>{},mP=(r,e)=>{var t,n,o,i;return(i=(o=(t=r.props)==null?void 0:t.title)!=null?o:(n=r.props)==null?void 0:n["data-tab-title"])!=null?i:`Tab ${e+1}`},gP=r=>{let e=[];return bh.Children.forEach(r,t=>{bh.isValidElement(t)?e.push(t):console.warn("Stack has unexpected child element type")}),e},yP={allowAddTab:!1,allowCloseTab:!1,allowRenameTab:!1},zl=fP(function({TabstripProps:e=yP,active:t=0,children:n,className:o,getTabIcon:i=pP,getTabLabel:s=mP,id:l,keyBoardActivation:a="manual",onAddTab:c,onMoveTab:u,onTabClose:h,onTabEdit:f,onTabSelectionChanged:d,showTabs:p="top",style:m},y){var P;let g=Sr(l),{allowCloseTab:v,allowRenameTab:w,className:x,tabClassName:S}=e,b=dP((I,V,B,W)=>{f==null||f(W,V)},[f]),C=()=>{var I;return bh.isValidElement(n)?n:Array.isArray(n)&&(I=n[t])!=null?I:null},k=()=>gP(n).map((I,V)=>{let{closeable:B=v,id:W=`${g}-${V}`,"data-tab-location":O}=I.props;return D0(uP,{ariaControls:W,"data-icon":i(I,V),id:`${W}-tab`,index:V,label:s(I,V),location:O,closeable:B,editable:w},W)}),E=C(),R=p==="left"||p==="right",M=R?"vertical":"horizontal";return bP("div",{className:I0(P0,o,{[`${P0}-horizontal`]:R}),style:m,id:g,ref:y,children:[p?D0(hP,{...e,activeTabIndex:(P=e==null?void 0:e.activeTabIndex)!=null?P:E===null?-1:t,allowDragDrop:e.allowDragDrop!==!1,animateSelectionThumb:!0,className:I0("vuuTabHeader",x),keyBoardActivation:a,onActiveChange:d,onAddTab:c,onCloseTab:h,onExitEditMode:b,onMoveTab:u,orientation:M,children:k()}):null,E]})});zl.displayName="Stack";import{useIdMemo as xP}from"@salt-ds/core";import vP,{useCallback as xh,useRef as wP}from"react";import{jsx as vh}from"react/jsx-runtime";var SP=r=>vh(qn,{resizeable:!0,title:`Tab ${r}`,style:{flexGrow:1,flexShrink:0,flexBasis:0},header:!0,closeable:!0,children:vh(ta,{style:{flex:1}})}),L0=r=>{var S;let e=wP(null),t=ut(),{loadState:n}=kr(),{createNewChild:o,id:i,onTabSelectionChanged:s,path:l,...a}=r,{children:c}=r,u=xP(i),[h]=ss(u,e,l),f=pd(),d=(S=o!=null?o:f)!=null?S:SP,p=b=>{l&&(t({type:"switch-tab",id:u,path:l,nextIdx:b}),s==null||s(b))},m=xh(b=>{if(Array.isArray(c)){let{props:{"data-path":C,path:k=C}}=c[b];t({type:"remove",path:k})}},[c,t]),y=xh(()=>{if(l){let b=vP.Children.count(c),C=d(b);t({type:"add",path:l,component:C})}},[c,d,t,l]),g=xh((b,C)=>{l&&t({fromIndex:b,toIndex:C,path:l,type:"move-child"})},[t,l]);return vh(zl,{...a,id:u,getTabLabel:(b,C)=>{let{id:k,title:E}=b.props;return n(k,"view-title")||E||`Tab ${C+1}`},onMouseDown:async(b,C)=>{let k;await h({type:"mousedown",index:C,preDragActivity:async()=>new Promise(M=>{console.log("preDragActivity: Ok, gonna release the drag"),k=M})},b)&&(k==null||k(void 0))},onMoveTab:g,onAddTab:y,onTabClose:m,onTabEdit:(b,C)=>{t({type:"set-title",path:`${l}.${b}`,title:C})},onTabSelectionChanged:p,ref:e})};L0.displayName="Stack";ge("Stack",L0,"container");import Ch from"classnames";import qP,{useMemo as KP,useRef as jP}from"react";import{isValidNumber as UP}from"@vuu-ui/vuu-utils";import{useCallback as Sh,useRef as GP}from"react";import{useControlled as kP}from"@salt-ds/core";import{dispatchMouseEvent as MP,getClosest as EP,getElementDataIndex as RP,getFocusableElement as IP}from"@vuu-ui/vuu-utils";import{useCallback as Tt,useRef as wh,useState as PP}from"react";import{ArrowDown as B0,ArrowUp as DP,ArrowLeft as LP,ArrowRight as AP,Home as O0,End as N0}from"@vuu-ui/vuu-utils";import{getElementDataIndex as CP}from"@vuu-ui/vuu-utils";var TP=(r,e)=>{if(r){let t=r.querySelector(`[data-index]:has(${e})`);return CP(t)}return-1};var A0=r=>TP(r,".vuuEditableLabel-editing");var H0={horizontal:{[O0]:"start",[N0]:"end",[LP]:"bwd",[AP]:"fwd"},vertical:{[O0]:"start",[N0]:"end",[DP]:"bwd",[B0]:"fwd"}},_0=r=>r!==null&&r.dataset.index==="overflow",OP=(r,e,t,n,o)=>{if(r){let i=e==="bwd"&&n>0,s=e==="fwd"&&n<t,l=i||s,a=Pi(r,n,!0),c=o&&!F0(a),u=!o&&_0(a);return o&&F0(a),l&&(c||u)}else return!1},NP=(r,e="horizontal")=>H0[e][r]!==void 0,VP=r=>r===B0;function V0(r,e,t){return e==="start"?0:e==="end"?r-1:e==="bwd"?t>0?t-1:t:t===null?0:t===r-1?t:t+1}var F0=r=>r!==null&&!r.classList.contains("wrapped"),z0=r=>Array.from(r.querySelectorAll("[data-index]")),FP=r=>r===null?-1:z0(r).map(n=>n.dataset.index).indexOf("overflow"),Pi=(r,e,t=!1)=>{if(r!==null){let o=z0(r)[e];return!t&&_0(o)?null:o}return null},W0=({containerRef:r,defaultHighlightedIdx:e=-1,highlightedIdx:t,onNavigateOutOfBounds:n,orientation:o})=>{let i=wh(!1),s=wh(-1),[l,a]=PP(!1),[c,u]=kP({controlled:t,default:e,name:"UseKeyboardNavigation"}),h=Tt(M=>{u(s.current=M)},[u]),f=wh(!1),d=Tt((M,P=!1,I,V=70)=>{console.log(`focus item ${M}`),h(M),I===!0&&!f.current&&(f.current=!0);let B=()=>{let W=Pi(r.current,M,!0);if(W){let O=IP(W);O==null||O.focus()}};P?B():setTimeout(B,V)},[r,h]),p=M=>{if(s.current===-1){if(M.target.tabIndex===0){let P=RP(EP(M.target,"index"));h(P)}else if(M.target.tabIndex!==-1){let P=A0(r.current);P!==-1&&requestAnimationFrame(()=>{h(P)})}}},m=Tt(()=>{var M,P;return(P=(M=r.current)==null?void 0:M.querySelectorAll("[data-index]").length)!=null?P:0},[r]),y=Tt((M="fwd",P)=>{var N;let I=m(),V=typeof P=="number"?P:I,B=V0(I,M,V),W=M==="start"?"fwd":M==="end"?"bwd":M,O=((N=r.current)==null?void 0:N.querySelector(".vuuOverflowContainer-wrapContainer-overflowed"))!=null;for(;OP(r.current,W,I,B,O);){let F=V0(I,W,B);if(F===B)return V;B=F}return B},[r,m]),g=Tt(M=>{let P=H0[o][M.key],I=y(P,c);console.log(`highlightedIdx = ${c}, nextIdx = ${I} `),I!==c?d(I,!0):n==null||n(P==="bwd"?"start":"end")},[o,y,c,d,n]),v=Tt(()=>{let M=Pi(r.current,c);return M?M.querySelector(".vuuPopupMenu")!=null:!1},[r,c]),w=Tt(()=>{let M=Pi(r.current,c);return M?M.querySelector(".vuuEditableLabel-input")!=null:!1},[r,c]),x=Tt(()=>{let M=Pi(r.current,c),P=M==null?void 0:M.querySelector(".vuuPopupMenu");return P&&MP(P,"click"),!1},[r,c]),S=Tt(M=>{m()>0&&NP(M.key,o)?(M.preventDefault(),f.current||(f.current=!0),g(M)):VP(M.key)&&v()&&!w()&&x()},[x,m,v,w,g,o]),b=(M,P)=>{h(P)},C=Tt(()=>{l||(a(!0),i.current?i.current=!1:f.current=!0)},[l]),k=Tt(()=>{l||(i.current=!0),f.current=!1},[l]),E=Tt(M=>{if((M==null?void 0:M.type)==="escape"){let P=FP(r.current);P!==-1&&d(P)}},[r,d]);return{containerProps:{onBlur:M=>{let P=M.target.closest(".vuuToolbar"),I=M.relatedTarget;P&&!(P!=null&&P.contains(I))&&(h(-1),a(!1))},onMouseDownCapture:k,onFocus:C,onMouseLeave:()=>{f.current=!0,h(-1),i.current=!1}},focusVisible:f.current?c:-1,focusIsWithinComponent:l,highlightedIdx:c,focusableIdx:0,focusItem:d,onClick:b,onFocus:p,onKeyDown:S,onOverflowMenuClose:E,setHighlightedIdx:h}};import{isSelectableElement as $0,getClosestIndexItem as BP}from"@vuu-ui/vuu-utils";import{allowMultipleSelection as HP,deselectionIsAllowed as U0,selectionIsDisallowed as _P,useControlled as zP}from"@vuu-ui/vuu-ui-controls";import{useCallback as Di}from"react";var WP=["Enter"," "],$P={},G0=({containerRef:r,defaultSelected:e,highlightedIdx:t,itemQuery:n,onSelectionChange:o,selected:i,selectionStrategy:s})=>{let[l,a,c]=zP({controlled:i,default:e!=null?e:[],name:"useSelection",state:"selected"}),u=Di(y=>WP.includes(y.key),[]),h=Di((y,g=!1)=>{let v=HP(s,g)?l.concat(y):[y];a(v),o==null||o(v)},[o,l,s,a]),f=Di((y,g=!1)=>{let v=s==="deselectable"||s==="multiple-special-key"&&!g?[]:l.filter(w=>w!==y);a(v),o==null||o(v)},[o,l,s,a]),d=Di(y=>{u(y)&&$0(y.target)&&(l.includes(t)?U0(s)&&(y.stopPropagation(),y.preventDefault(),f(t,y.shiftKey)):(y.stopPropagation(),y.preventDefault(),h(t,y.shiftKey)))},[u,l,t,s,h,f]),p=Di((y,g)=>{let v=BP(y.target);$0(v)&&(l.includes(g)?U0(s)&&f(g,y.shiftKey):h(g,y.shiftKey))},[f,h,l,s]),m=_P(s)?$P:{onClick:p,onKeyDown:d};return{activateItem:h,itemHandlers:m,isControlled:c,selected:l}};var q0=({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:t,itemQuery:n="vuuToolbarItem",onActiveChange:o,onNavigateOutOfBounds:i,orientation:s,selectionStrategy:l})=>{let a=GP(r),{focusItem:c,highlightedIdx:u,onClick:h,onKeyDown:f,setHighlightedIdx:d,...p}=W0({containerRef:t,onNavigateOutOfBounds:i,orientation:s}),{activateItem:m,itemHandlers:{onClick:y,onKeyDown:g},selected:v}=G0({containerRef:t,defaultSelected:e,highlightedIdx:u,itemQuery:n,onSelectionChange:o,selected:r,selectionStrategy:l});a.current=v;let w=Sh(C=>{var R;let E=C.target.closest("[data-index]");if(E){let M=parseInt((R=E.dataset.index)!=null?R:"-1");M!==-1&&UP(M)&&(h(C,M),y==null||y(C,M))}},[h,y]),x=Sh(C=>{f(C),C.defaultPrevented||g==null||g(C)},[f,g]),S=Sh(C=>{let k=parseInt(C.index);isNaN(k)||(m(k),c(k))},[c,m]),b={onClick:w,onFocus:p.onFocus,onKeyDown:x};return{activeItemIndex:v,focusableIdx:p.focusableIdx,focusVisible:p.focusVisible,containerProps:{PopupMenuProps:{onKeyDown:x,onMenuClose:p.onOverflowMenuClose},...p.containerProps,onSwitchWrappedItemIntoView:S},itemProps:b}};import{forwardCallbackProps as JP}from"@vuu-ui/vuu-ui-controls";import{jsx as QP}from"react/jsx-runtime";var Th="vuuToolbar",dT=({activeItemIndex:r,defaultActiveItemIndex:e,children:t,className:n,id:o,onActiveChange:i,onNavigateOutOfBounds:s,orientation:l="horizontal",selectionStrategy:a="none",...c})=>{let u=jP(null),{activeItemIndex:h,focusableIdx:f,focusVisible:d,itemProps:p,...m}=q0({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:u,onActiveChange:i,onNavigateOutOfBounds:s,orientation:l,selectionStrategy:a}),y=Sr(o),g=Ch(Th,`${Th}-${l}`,n),v=KP(()=>wr(t).map((w,x)=>{let{id:S=`${y}-tab-${x}`,className:b,...C}=w.props,k=h.includes(x);return qP.cloneElement(w,{...JP(C,p),className:Ch("vuuToolbarItem",b),"data-overflow-priority":k?"1":void 0,id:S,key:x,"aria-selected":k,tabIndex:f===x?0:-1})}),[h,t,f,y,p]);return QP(E0,{...c,...m.containerProps,className:Ch(Th,g),...c,ref:u,children:v})};import K0,{useState as j0}from"react";import{jsx as kh,jsxs as J0}from"react/jsx-runtime";var jY=({children:r})=>{let[t,n]=j0(r),[o,i]=j0(r),s=a=>{let c=Kh(t,a);i(c)},l=(a,c)=>{console.log(`change ${a} -> ${c}`);let u=K0.cloneElement(o,{style:{...o.props.style,[a]:c}});i(u),n(K0.cloneElement(t,{},u))};return J0("div",{"data-design-mode":`${!1}`,children:[t,kh("br",{}),J0("div",{style:{display:"flex"},children:[kh(Q0,{height:300,managedStyle:o.props.style,width:300,onChange:l,style:void 0}),kh(Y0,{layout:t,onSelect:s,style:{width:300,height:300,backgroundColor:"#ccc"}})]})]})};import{FormField as Kl,Input as jl}from"@salt-ds/core";import{jsx as Le,jsxs as Eh}from"react/jsx-runtime";var Rh={},YP={margin:{top:"marginTop",right:"marginRight",bottom:"marginBottom",left:"marginLeft"},border:{top:"borderTopWidth",right:"borderRightWidth",bottom:"borderBottomWidth",left:"borderLeftWidth"},padding:{top:"paddingTop",right:"paddingRight",bottom:"paddingBottom",left:"paddingLeft"}},Mh=({feature:r,children:e,style:t,onChange:n})=>Eh("div",{className:`LayoutBox layout-${r} layout-outer`,children:[Eh("div",{className:"layout-top",children:[Le("span",{className:"layout-title",children:r}),Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.top,onChange:(o,i)=>n(r,"top",i)})})]}),Eh("div",{className:"layout-inner",children:[Le("div",{className:"layout-left",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.left,onChange:(o,i)=>n(r,"left",i)})})}),e,Le("div",{className:"layout-right",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.right,onChange:(o,i)=>n(r,"right",i)})})})]}),Le("div",{className:"layout-bottom",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.bottom,onChange:(o,i)=>n(r,"bottom",i)})})})]}),rX={margin:!0,marginTop:!0,marginRight:!0,marginBottom:!0,marginLeft:!0},oX={padding:!0,paddingTop:!0,paddingRight:!0,paddingBottom:!0,paddingLeft:!0},iX={border:!0,borderColor:!0,borderWidth:!0,borderTopWidth:!0,borderRightWidth:!0,borderBottomWidth:!0,borderLeftWidth:!0},Jl="(\\d+)(?:px)?",XP=`^(?:${Jl}(?:\\s${Jl}(?:\\s${Jl}(?:\\s${Jl})?)?)?)$`,X0=new RegExp(XP),ZP=/^(?:(\d+)(?:px)\ssolid\s([a-zA-Z,0-9().]+))$/,Q0=({height:r,managedStyle:e,onChange:t,style:n,width:o})=>{let i=Z0(e),s=(w,x,S)=>{let b=parseInt(S||"0",10),C=YP[w][x];t(C,b)},{marginTop:l=0,marginRight:a=0,marginBottom:c=0,marginLeft:u=0}=i,{borderTopWidth:h=0,borderRightWidth:f=0,borderBottomWidth:d=0,borderLeftWidth:p=0}=i,{paddingTop:m=0,paddingRight:y=0,paddingBottom:g=0,paddingLeft:v=0}=i;return Le("div",{className:"LayoutConfigurator",style:{width:o,height:r,...n},children:Le(Mh,{feature:"margin",style:{top:l,right:a,bottom:c,left:u},onChange:s,children:Le(Mh,{feature:"border",style:{top:h,right:f,bottom:d,left:p},onChange:s,children:Le(Mh,{feature:"padding",style:{top:m,right:y,bottom:g,left:v},onChange:s,children:Le("div",{className:"layout-content"})})})})})};function sX(r=Rh,e=Rh){let{margin:t,marginTop:n,marginRight:o,marginBottom:i,marginLeft:s,padding:l,paddingTop:a,paddingRight:c,paddingBottom:u,paddingLeft:h,...f}=r;if(typeof t=="number")f.marginTop=f.marginRight=f.marginBottom=f.marginLeft=t;else if(typeof t=="string"){let d=X0.exec(t);if(d===null)console.error(`Invalid css value for margin '${t}'`);else{let[,p,m,y,g]=d,v=p&&m&&y;v&&g?(f.marginTop=parseInt(p,10),f.marginRight=parseInt(m,10),f.marginBottom=parseInt(y,10),f.marginLeft=parseInt(g,10)):v?(f.marginTop=parseInt(p,10),f.marginRight=f.marginLeft=parseInt(m,10),f.marginBottom=parseInt(y,10)):p&&m?(f.marginTop=f.marginBottom=parseInt(p,10),f.marginRight=f.marginLeft=parseInt(m,10)):f.marginTop=f.marginRight=f.marginBottom=f.marginLeft=parseInt(p,10)}}if(typeof n=="number"&&(f.marginTop=n),typeof o=="number"&&(f.marginRight=o),typeof i=="number"&&(f.marginBottom=i),typeof s=="number"&&(f.marginLeft=s),typeof l=="number")f.paddingTop=f.paddingRight=f.paddingBottom=f.paddingLeft=l;else if(typeof l=="string"){let d=X0.exec(l);if(d===null)console.error(`Invalid css value for padding '${l}'`);else{let[,p,m,y,g]=d,v=p&&m&&y;v&&g?(f.paddingTop=parseInt(p,10),f.paddingRight=parseInt(m,10),f.paddingBottom=parseInt(y,10),f.paddingLeft=parseInt(g,10)):v?(f.paddingTop=parseInt(p,10),f.paddingRight=f.paddingLeft=parseInt(m,10),f.paddingBottom=parseInt(y,10)):p&&m?(f.paddingTop=f.paddingBottom=parseInt(p,10),f.paddingRight=f.paddingLeft=parseInt(m,10)):f.paddingTop=f.paddingRight=f.paddingBottom=f.paddinggLeft=parseInt(p,10)}}return typeof a=="number"&&(f.paddingTop=a),typeof c=="number"&&(f.paddingRight=c),typeof u=="number"&&(f.paddingBottom=u),typeof h=="number"&&(f.paddingLeft=h),Z0(f,e)}function Z0(r=Rh){let e={...r},t,{border:n,borderWidth:o,borderTopWidth:i,borderRightWidth:s,borderBottomWidth:l,borderLeftWidth:a,borderColor:c,margin:u,marginTop:h,marginRight:f,marginBottom:d,marginLeft:p,padding:m,paddingTop:y,paddingRight:g,paddingBottom:v,paddingLeft:w,...x}=e,S={},b={};if(typeof u=="number"&&(e.marginTop=e.marginRight=e.marginBottom=e.marginLeft=u,S={marginTop:u,marginRight:u,marginBottom:u,marginLeft:u}),typeof m=="number"&&(e.paddingTop=e.paddingRight=e.paddingBottom=e.paddingLeft=m,b={paddingTop:m,paddingRight:m,paddingBottom:m,paddingLeft:m}),n||o||i||s||l||a){typeof n=="string"&&(t=ZP.exec(n))&&([,o,c]=t,o=parseInt(o,10)),o&&(i=i===void 0?o:i,s=s===void 0?o:s,l=l===void 0?o:l,a=a===void 0?o:a),c=c||"black";let C=`
|
|
238
|
-
${c} ${a||0}px ${i||0}px 0 0 inset,
|
|
239
|
-
${c} ${-s||0}px ${-l||0}px 0 0 inset`;return{...x,...S,...b,borderTopWidth:i,borderRightWidth:s,borderBottomWidth:l,borderLeftWidth:a,borderColor:c,borderStyle:"solid",boxShadow:C}}else return e}import eD from"react";import tD from"classnames";import{Tree as nD}from"@vuu-ui/vuu-ui-controls";import{jsx as ex}from"react/jsx-runtime";var rD="hwLayoutTreeViewer",tx=(r,e="0")=>({label:K(r),path:e,childNodes:eD.Children.map(r.props.children,(t,n)=>tx(t,e?`${e}.${n}`:`${n}`))}),Y0=({layout:r,onSelect:e,style:t})=>{let n=[tx(r)],o=(i,[{path:s}])=>{e(s)};return ex("div",{className:tD(rD),style:t,children:ex(nD,{source:n,groupSelection:"single",onSelectionChange:o})})};export{Wn as Action,iX as BORDER_STYLES,ta as Component,Fn as ComponentRegistry,jY as ConfigWrapper,Wh as DockLayout,ma as Draggable,To as DraggableLayout,Ai as Drawer,lf as DropMenu,pn as DropTarget,Po as Flexbox,gd as FlexboxLayout,Oa as FluidGrid,Ed as FluidGridLayout,Fd as Header,S2 as HeightOnly,Re as LayoutActionType,Q0 as LayoutConfigurator,Mw as LayoutProvider,No as LayoutProviderContext,l2 as LayoutProviderVersion,Y0 as LayoutTreeViewer,Sl as LocalLayoutPersistenceManager,rX as MARGIN_STYLES,xJ as MeasuredContainer,ph as NO_WRAPPED_ITEMS,E0 as OverflowContainer,oX as PADDING_STYLES,jb as Palette,hh as PaletteItem,Gi as Placeholder,zl as Stack,L0 as StackLayout,dT as Toolbar,qn as View,ls as ViewContext,xd as WidthHeight,C2 as WidthOnly,sX as XXXnormalizeStyles,fO as applyLayout,Lo as applyLayoutProps,g0 as applyOverflowClassToWrappedItems,wr as asReactElements,Wf as componentToJson,sf as computeMenuPosition,Rx as containerOf,v0 as correctForWrappedHighPriorityItems,x0 as correctForWrappedOverflowIndicator,xa as createFlexbox,Ft as createPlaceHolder,Ho as defaultLayout,oa as expandFlex,L2 as extractResponsiveProps,Yt as findTarget,Te as followPath,Kh as followPathToComponent,Qt as followPathToParent,Ix as getChild,$h as getChildProp,$I as getElementsMarkedAsWrapped,Ef as getFlexDimensions,ba as getFlexOrIntrinsicStyle,ya as getFlexStyle,at as getIntrinsicSize,_f as getManagedDimension,Ri as getNonWrappedAndWrappedItems,Vf as getPersistentState,q as getProp,_ as getProps,Ff as hasPersistentState,Rf as hasUnboundedFlexStyle,b0 as highPriorityItemsHaveWrappedButShouldNotHave,ca as identifyDropTarget,VO as isApplicationLevelChange,ze as isContainer,Vh as isLayoutComponent,FO as isLayoutLevelChange,EJ as isOverflowElement,Hw as isResponsiveAttribute,xL as isTabstrip,BD as isTypeOf,px as isView,Mr as layoutFromJson,ad as layoutReducer,zf as layoutToJSON,WI as markElementAsWrapped,GD as nextLeaf,Et as nextStep,y0 as overflowIndicatorHasWrappedButShouldNotHave,qD as previousLeaf,Sa as processLayoutElement,ge as registerComponent,C0 as removeOverflowIndicatorIfNoLongerNeeded,Ee as resetPath,bd as resizeObserver,qh as resolveJSONPath,na as resolvePath,Uv as serializeProps,Bf as setPersistentState,jD as setRef,BI as sortByScreenOrder,mh as switchWrappedItemIntoView,K as typeOf,GI as unmarkItemsWhichAreNoLongerWrapped,Cd as useBreakpoints,Sr as useId,Uj as useLayoutContextMenuItems,pd as useLayoutCreateNewChild,Qh as useLayoutEffectSkipFirst,ut as useLayoutProviderDispatch,Ew as useLayoutProviderVersion,f0 as useMeasuredContainer,kr as usePersistentState,os as useResizeObserver,ss as useViewActionDispatcher,DV as useViewContext,Od as useViewDispatch,yF as warningLayout,Mo as wrapIntrinsicSizeComponentWithFlexbox};
|
|
19
|
+
Wrap elements with a single container`),r)},Na=({applyThemeClasses:r=!1,children:e,theme:t,themeMode:o,density:n})=>{var d,h,f;let{density:s,themeMode:i,theme:a}=vh(Aa),l=(d=n!=null?n:s)!=null?d:Sh,u=(h=o!=null?o:i)!=null?h:Rh,c=(f=t!=null?t:a)!=null?f:Ch,p=r?xh(e,c,u,l):e;return Th(Aa.Provider,{value:{themeMode:u,density:l,theme:c},children:p})};Na.displayName="ThemeProvider";import{jsx as Z0,jsxs as Y0}from"react/jsx-runtime";import{useCallback as nM,useEffect as sM,useMemo as iM,useRef as aM,useState as lM}from"react";import cM from"classnames";import{useIdMemo as dM}from"@salt-ds/core";import{Button as fM}from"@salt-ds/core";import{EventEmitter as Hh,getLoggingConfigForWorker as $h,uuid as Wh}from"@vuu-ui/vuu-utils";var rr=(r,e)=>r===e?!0:r===void 0&&e===void 0,Ph=({filter:r},{filter:e})=>r===void 0&&(e==null?void 0:e.filter)===""||e===void 0&&(r==null?void 0:r.filter)==="",Mh=(r,e)=>{var t,o;return Ph(r,e)?!1:((t=r.filter)==null?void 0:t.filter)!==((o=e.filter)==null?void 0:o.filter)},Lh=({sort:r},{sort:e})=>r===void 0&&(e==null?void 0:e.sortDefs.length)===0||e===void 0&&(r==null?void 0:r.sortDefs.length)===0,Dh=(r,e)=>{let{sort:t}=r,{sort:o}=e;return rr(t,o)||Lh(r,e)?!1:t===void 0||o===void 0||(t==null?void 0:t.sortDefs.length)!==(o==null?void 0:o.sortDefs.length)?!0:t.sortDefs.some(({column:n,sortType:s},i)=>n!==o.sortDefs[i].column||s!==o.sortDefs[i].sortType)},_a=r=>r!==void 0&&r.groupBy!==void 0&&r.groupBy.length>0,Ba=r=>(r==null?void 0:r.filter)!==void 0&&r.filter.filter.length>0,Fa=r=>{var e;return(r==null?void 0:r.sort)!==void 0&&Array.isArray((e=r.sort)==null?void 0:e.sortDefs)&&r.sort.sortDefs.length>0},Ih=({groupBy:r},{groupBy:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,Rn=(r,e)=>{let{groupBy:t}=r,{groupBy:o}=e;return rr(t,o)||Ih(r,e)?!1:t===void 0||o===void 0||(t==null?void 0:t.length)!==(o==null?void 0:o.length)?!0:t.some((n,s)=>n!==(o==null?void 0:o[s]))},kh=({columns:r},{columns:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,Oh=(r,e)=>{let{columns:t}=r,{columns:o}=e;return rr(t,o)||kh(r,e)?!1:t===void 0||o===void 0||(t==null?void 0:t.length)!==(o==null?void 0:o.length)?!0:t.some((n,s)=>n!==(o==null?void 0:o[s]))},Vh=({aggregations:r},{aggregations:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,Ah=(r,e)=>{let{aggregations:t}=r,{aggregations:o}=e;return rr(t,o)||Vh(r,e)?!1:t===void 0||o===void 0||t.length!==o.length?!0:t.some(({column:n,aggType:s},i)=>n!==o[i].column||s!==o[i].aggType)},Nh=()=>!1,io=(r,e)=>rr(r,e)?!1:r===void 0||e===void 0?!0:Oh(r,e)||Mh(r,e)||Dh(r,e)||Rn(r,e)||Ah(r,e)||Nh(r,e),_h=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],za=r=>{let e=r.type;return _h.includes(e)},Ha=r=>["config","aggregate","columns","filter","groupBy","sort"].includes(r.type),Bh={filter:""},Fh={sortDefs:[]},St={aggregations:[],columns:[],filter:Bh,groupBy:[],sort:Fh},ao=r=>{if(r.aggregations&&r.columns&&r.filter&&r.groupBy&&r.sort)return r;{let{aggregations:e=[],columns:t=[],filter:o={filter:""},groupBy:n=[],sort:s={sortDefs:[]},visualLink:i}=r;return{aggregations:e,columns:t,filter:o,groupBy:n,sort:s,visualLink:i}}};var $a="GET_TABLE_META";var xn=r=>r.type==="connection-status",Wa=r=>r.type==="connection-metrics",Ua=r=>typeof r.result<"u",Ga=r=>r.type==="TABLE_META_RESP";var qa=r=>r.type==="vuu-links";var Ja=r=>r.type==="vuu-menu";var Qa='\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 Uh=new Blob([$h()+Qa],{type:"text/javascript"}),Gh=URL.createObjectURL(Uh),Ct,Tn,En=[],qh,Jh,Qh=new Promise((r,e)=>{qh=r,Jh=e}),ja=()=>Qh,or=new Map,lo=new Map,Kh=async({handleConnectionStatusChange:r,protocol:e,retryLimitDisconnect:t,retryLimitStartup:o,token:n="",username:s,url:i})=>n===""&&Tn===void 0?new Promise(a=>{En.push({resolve:a})}):Tn||(Tn=new Promise(a=>{let l=new Worker(Gh),u=window.setTimeout(()=>{console.error("timed out waiting for worker to load")},1e3);l.onmessage=c=>{let{data:p}=c;if(p.type==="ready")window.clearTimeout(u),l.postMessage({protocol:e,retryLimitDisconnect:t,retryLimitStartup:o,token:n,type:"connect",url:i,username:s});else if(p.type==="connected"){l.onmessage=Xa,a(l);for(let d of En)d.resolve(l);En.length=0}else xn(p)?r({data:p}):console.warn("ConnectionManager: Unexpected message from the worker")}}));function Xa({data:r}){if(za(r)){let e=or.get(r.clientViewportId);e?e.postMessageToClientDataSource(r):console.error(`[ConnectionManager] ${r.type} message received, viewport not found`)}else if(xn(r))Ka.emit("connection-status",r);else if(Wa(r))Ka.emit("connection-metrics",r);else{let e=r.requestId;if(lo.has(e)){let{resolve:t}=lo.get(e);lo.delete(e);let{type:o,requestId:n,...s}=r;Ua(r)?t(r.result):r.type==="VP_EDIT_RPC_RESPONSE"||r.type==="VP_EDIT_RPC_REJECT"?t(r):Ga(r)?t(r.tableSchema):t(s)}else console.warn("%cConnectionManager Unexpected message from the worker","color:red;font-weight:bold;")}}var Pn=r=>{let e=Wh();return Ct.postMessage({requestId:e,...r}),new Promise((t,o)=>{lo.set(e,{resolve:t,reject:o})})},jh={subscribe:(r,e)=>{if(or.get(r.viewport))throw Error("ConnectionManager attempting to subscribe with an existing viewport id");or.set(r.viewport,{status:"subscribing",request:r,postMessageToClientDataSource:e}),Ct.postMessage({type:"subscribe",...r})},unsubscribe:r=>{Ct.postMessage({type:"unsubscribe",viewport:r})},send:r=>{Ct.postMessage(r)},destroy:r=>{r&&or.has(r)&&or.delete(r)},rpcCall:async r=>Pn(r),getTableList:async()=>Pn({type:"GET_TABLE_LIST"}),getTableSchema:async r=>Pn({type:$a,table:r})},Mn=class extends Hh{async connect({url:e,authToken:t,username:o,protocol:n,retryLimitDisconnect:s,retryLimitStartup:i}){return Ct=await Kh({protocol:n,url:e,token:t,username:o,retryLimitDisconnect:s,retryLimitStartup:i,handleConnectionStatusChange:Xa}),jh}destroy(){Ct.terminate()}},Ka=new Mn;var Xh=0,nr=class{constructor(e,t){this.from=e,this.to=t}},H=class{constructor(e={}){this.id=Xh++,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=le.match(e)),t=>{let o=e(t);return o===void 0?null:[this,o]}}};H.closedBy=new H({deserialize:r=>r.split(" ")});H.openedBy=new H({deserialize:r=>r.split(" ")});H.group=new H({deserialize:r=>r.split(" ")});H.contextHash=new H({perNode:!0});H.lookAhead=new H({perNode:!0});H.mounted=new H({perNode:!0});var Zh=Object.create(null),le=class{constructor(e,t,o,n=0){this.name=e,this.props=t,this.id=o,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):Zh,o=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new le(e.name||"",t,e.id,o);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(n)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(H.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let o in e)for(let n of o.split(" "))t[n]=e[o];return o=>{for(let n=o.prop(H.group),s=-1;s<(n?n.length:0);s++){let i=t[s<0?o.name:n[s]];if(i)return i}}}};le.none=new le("",Object.create(null),0,8);var Rt=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 o of this.types){let n=null;for(let s of e){let i=s(o);i&&(n||(n=Object.assign({},o.props)),n[i[0].id]=i[1])}t.push(n?new le(o.name,n,o.id,o.flags):o)}return new Rt(t)}},uo=new WeakMap,Za=new WeakMap,Q;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays"})(Q||(Q={}));var Z=class{constructor(e,t,o,n,s){if(this.type=e,this.children=t,this.positions=o,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[i,a]of s)this.props[typeof i=="number"?i:i.id]=a}}toString(){let e=this.prop(H.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let o of this.children){let n=o.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Tt(this.topNode,e)}cursorAt(e,t=0,o=0){let n=uo.get(this)||this.topNode,s=new Tt(n);return s.moveTo(e,t),uo.set(this,s._tree),s}get topNode(){return new xe(this,0,0,null)}resolve(e,t=0){let o=xt(uo.get(this)||this.topNode,e,t,!1);return uo.set(this,o),o}resolveInner(e,t=0){let o=xt(Za.get(this)||this.topNode,e,t,!0);return Za.set(this,o),o}iterate(e){let{enter:t,leave:o,from:n=0,to:s=this.length}=e,i=e.mode||0,a=(i&Q.IncludeAnonymous)>0;for(let l=this.cursor(i|Q.IncludeAnonymous);;){let u=!1;if(l.from<=s&&l.to>=n&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&o&&(a||!l.type.isAnonymous)&&o(l),!l.nextSibling();){if(!l.parent())return;u=!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:kn(le.none,this.children,this.positions,0,this.children.length,0,this.length,(t,o,n)=>new Z(this.type,t,o,n,this.propValues),e.makeTree||((t,o,n)=>new Z(le.none,t,o,n)))}static build(e){return Yh(e)}};Z.empty=new Z(le.none,[],[],0);var sr=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 sr(this.buffer,this.index)}},ke=class{constructor(e,t,o){this.buffer=e,this.length=t,this.set=o}get type(){return le.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],o=this.buffer[e+3],n=this.set.types[t],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),e+=4,o==e)return s;let i=[];for(;e<o;)i.push(this.childString(e)),e=this.buffer[e+3];return s+"("+i.join(",")+")"}findChild(e,t,o,n,s){let{buffer:i}=this,a=-1;for(let l=e;l!=t&&!(el(s,n,i[l+1],i[l+2])&&(a=l,o>0));l=i[l+3]);return a}slice(e,t,o){let n=this.buffer,s=new Uint16Array(t-e),i=0;for(let a=e,l=0;a<t;){s[l++]=n[a++],s[l++]=n[a++]-o;let u=s[l++]=n[a++]-o;s[l++]=n[a++]-e,i=Math.max(i,u)}return new ke(s,i,this.set)}};function el(r,e,t,o){switch(r){case-2:return t<e;case-1:return o>=e&&t<e;case 0:return t<e&&o>e;case 1:return t<=e&&o>e;case 2:return o>e;case 4:return!0}}function tl(r,e){let t=r.childBefore(e);for(;t;){let o=t.lastChild;if(!o||o.to!=t.to)break;o.type.isError&&o.from==o.to?(r=t,t=o.prevSibling):t=o}return r}function xt(r,e,t,o){for(var n;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let i=!o&&r instanceof xe&&r.index<0?null:r.parent;if(!i)return r;r=i}let s=o?0:Q.IgnoreOverlays;if(o)for(let i=r,a=i.parent;a;i=a,a=i.parent)i instanceof xe&&i.index<0&&((n=a.enter(e,t,s))===null||n===void 0?void 0:n.from)!=i.from&&(r=a);for(;;){let i=r.enter(e,t,s);if(!i)return r;r=i}}var xe=class{constructor(e,t,o,n){this._tree=e,this.from=t,this.index=o,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,o,n,s=0){for(let i=this;;){for(let{children:a,positions:l}=i._tree,u=t>0?a.length:-1;e!=u;e+=t){let c=a[e],p=l[e]+i.from;if(el(n,o,p,p+c.length)){if(c instanceof ke){if(s&Q.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,o-p,n);if(d>-1)return new Me(new Ln(i,c,e,p),null,d)}else if(s&Q.IncludeAnonymous||!c.type.isAnonymous||In(c)){let d;if(!(s&Q.IgnoreMounts)&&c.props&&(d=c.prop(H.mounted))&&!d.overlay)return new xe(d.tree,p,e,i);let h=new xe(c,p,e,i);return s&Q.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(t<0?c.children.length-1:0,t,o,n)}}}if(s&Q.IncludeAnonymous||!i.type.isAnonymous||(i.index>=0?e=i.index+t:e=t<0?-1:i._parent._tree.children.length,i=i._parent,!i))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,o=0){let n;if(!(o&Q.IgnoreOverlays)&&(n=this._tree.prop(H.mounted))&&n.overlay){let s=e-this.from;for(let{from:i,to:a}of n.overlay)if((t>0?i<=s:i<s)&&(t<0?a>=s:a>s))return new xe(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,o)}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 Tt(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return xt(this,e,t,!1)}resolveInner(e,t=0){return xt(this,e,t,!0)}enterUnfinishedNodesBefore(e){return tl(this,e)}getChild(e,t=null,o=null){let n=po(this,e,t,o);return n.length?n[0]:null}getChildren(e,t=null,o=null){return po(this,e,t,o)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return ho(this,e)}};function po(r,e,t,o){let n=r.cursor(),s=[];if(!n.firstChild())return s;if(t!=null){for(;!n.type.is(t);)if(!n.nextSibling())return s}for(;;){if(o!=null&&n.type.is(o))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return o==null?s:[]}}function ho(r,e,t=e.length-1){for(let o=r.parent;t>=0;o=o.parent){if(!o)return!1;if(!o.type.isAnonymous){if(e[t]&&e[t]!=o.name)return!1;t--}}return!0}var Ln=class{constructor(e,t,o,n){this.parent=e,this.buffer=t,this.index=o,this.start=n}},Me=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,o){this.context=e,this._parent=t,this.index=o,this.type=e.buffer.set.types[e.buffer.buffer[o]]}child(e,t,o){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,o);return s<0?null:new Me(this.context,this,s)}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,o=0){if(o&Q.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new Me(this.context,this,s)}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 Me(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 Me(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Tt(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:o}=this.context,n=this.index+4,s=o.buffer[this.index+3];if(s>n){let i=o.buffer[this.index+1];e.push(o.slice(n,s,i)),t.push(0)}return new Z(this.type,e,t,this.to-this.from)}resolve(e,t=0){return xt(this,e,t,!1)}resolveInner(e,t=0){return xt(this,e,t,!0)}enterUnfinishedNodesBefore(e){return tl(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,o=null){let n=po(this,e,t,o);return n.length?n[0]:null}getChildren(e,t=null,o=null){return po(this,e,t,o)}get node(){return this}matchContext(e){return ho(this,e)}},Tt=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 xe)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let o=e._parent;o;o=o._parent)this.stack.unshift(o.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:o,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=o+n.buffer[e+1],this.to=o+n.buffer[e+2],!0}yield(e){return e?e instanceof xe?(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,o){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,o,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,o);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}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,o=this.mode){return this.buffer?o&Q.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,o))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Q.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Q.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,o=this.stack.length-1;if(e<0){let n=o<0?0:this.stack[o]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(o<0?t.buffer.length:t.buffer[this.stack[o]+3]))return this.yieldBuf(n)}return o<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,o,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(n.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:o}=n)}else({index:t,_parent:o}=this._tree);for(;o;{index:t,_parent:o}=o)if(t>-1)for(let s=t+e,i=e<0?-1:o._tree.children.length;s!=i;s+=e){let a=o._tree.children[s];if(this.mode&Q.IncludeAnonymous||a instanceof ke||!a.type.isAnonymous||In(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,o=0;if(e&&e.context==this.buffer)e:for(let n=this.index,s=this.stack.length;s>=0;){for(let i=e;i;i=i._parent)if(i.index==n){if(n==this.index)return i;t=i,o=s+1;break e}n=this.stack[--s]}for(let n=o;n<this.stack.length;n++)t=new Me(this.buffer,t,this.stack[n]);return this.bufferNode=new Me(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let o=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){o++;continue}this.type.isAnonymous||(n=!0)}for(;n&&t&&t(this),n=this.type.isAnonymous,!this.nextSibling();){if(!o)return;this.parent(),o--,n=!0}}}matchContext(e){if(!this.buffer)return ho(this.node,e);let{buffer:t}=this.buffer,{types:o}=t.set;for(let n=e.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return ho(this.node,e,n);let i=o[t.buffer[this.stack[s]]];if(!i.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}};function In(r){return r.children.some(e=>e instanceof ke||!e.type.isAnonymous||In(e))}function Yh(r){var e;let{buffer:t,nodeSet:o,maxBufferLength:n=1024,reused:s=[],minRepeatType:i=o.types.length}=r,a=Array.isArray(t)?new sr(t,t.length):t,l=o.types,u=0,c=0;function p(w,x,v,S,E){let{id:M,start:P,end:T,size:D}=a,V=c;for(;D<0;)if(a.next(),D==-1){let q=s[M];v.push(q),S.push(P-w);return}else if(D==-3){u=M;return}else if(D==-4){c=M;return}else throw new RangeError(`Unrecognized record size: ${D}`);let _=l[M],F,z,ee=P-w;if(T-P<=n&&(z=b(a.pos-x,E))){let q=new Uint16Array(z.size-z.skip),K=a.pos-z.size,de=q.length;for(;a.pos>K;)de=y(z.start,q,de);F=new ke(q,T-z.start,o),ee=z.start-w}else{let q=a.pos-D;a.next();let K=[],de=[],Ee=M>=i?M:-1,Pe=0,Ke=T;for(;a.pos>q;)Ee>=0&&a.id==Ee&&a.size>=0?(a.end<=Ke-n&&(h(K,de,P,Pe,a.end,Ke,Ee,V),Pe=K.length,Ke=a.end),a.next()):p(P,q,K,de,Ee);if(Ee>=0&&Pe>0&&Pe<K.length&&h(K,de,P,Pe,P,Ke,Ee,V),K.reverse(),de.reverse(),Ee>-1&&Pe>0){let vr=d(_);F=kn(_,K,de,0,K.length,0,T-P,vr,vr)}else F=f(_,K,de,T-P,V-T)}v.push(F),S.push(ee)}function d(w){return(x,v,S)=>{let E=0,M=x.length-1,P,T;if(M>=0&&(P=x[M])instanceof Z){if(!M&&P.type==w&&P.length==S)return P;(T=P.prop(H.lookAhead))&&(E=v[M]+P.length+T)}return f(w,x,v,S,E)}}function h(w,x,v,S,E,M,P,T){let D=[],V=[];for(;w.length>S;)D.push(w.pop()),V.push(x.pop()+v-E);w.push(f(o.types[P],D,V,M-E,T-M)),x.push(E-v)}function f(w,x,v,S,E=0,M){if(u){let P=[H.contextHash,u];M=M?[P].concat(M):[P]}if(E>25){let P=[H.lookAhead,E];M=M?[P].concat(M):[P]}return new Z(w,x,v,S,M)}function b(w,x){let v=a.fork(),S=0,E=0,M=0,P=v.end-n,T={size:0,start:0,skip:0};e:for(let D=v.pos-w;v.pos>D;){let V=v.size;if(v.id==x&&V>=0){T.size=S,T.start=E,T.skip=M,M+=4,S+=4,v.next();continue}let _=v.pos-V;if(V<0||_<D||v.start<P)break;let F=v.id>=i?4:0,z=v.start;for(v.next();v.pos>_;){if(v.size<0)if(v.size==-3)F+=4;else break e;else v.id>=i&&(F+=4);v.next()}E=z,S+=V,M+=F}return(x<0||S==w)&&(T.size=S,T.start=E,T.skip=M),T.size>4?T:void 0}function y(w,x,v){let{id:S,start:E,end:M,size:P}=a;if(a.next(),P>=0&&S<i){let T=v;if(P>4){let D=a.pos-(P-4);for(;a.pos>D;)v=y(w,x,v)}x[--v]=T,x[--v]=M-w,x[--v]=E-w,x[--v]=S}else P==-3?u=S:P==-4&&(c=S);return v}let g=[],C=[];for(;a.pos>0;)p(r.start||0,r.bufferStart||0,g,C,-1);let R=(e=r.length)!==null&&e!==void 0?e:g.length?C[0]+g[0].length:0;return new Z(l[r.topID],g.reverse(),C.reverse(),R)}var Ya=new WeakMap;function co(r,e){if(!r.isAnonymous||e instanceof ke||e.type!=r)return 1;let t=Ya.get(e);if(t==null){t=1;for(let o of e.children){if(o.type!=r||!(o instanceof Z)){t=1;break}t+=co(r,o)}Ya.set(e,t)}return t}function kn(r,e,t,o,n,s,i,a,l){let u=0;for(let f=o;f<n;f++)u+=co(r,e[f]);let c=Math.ceil(u*1.5/8),p=[],d=[];function h(f,b,y,g,C){for(let R=y;R<g;){let w=R,x=b[R],v=co(r,f[R]);for(R++;R<g;R++){let S=co(r,f[R]);if(v+S>=c)break;v+=S}if(R==w+1){if(v>c){let S=f[w];h(S.children,S.positions,0,S.children.length,b[w]+C);continue}p.push(f[w])}else{let S=b[R-1]+f[R-1].length-x;p.push(kn(r,f,b,w,R,x,S,null,l))}d.push(x+C-s)}}return h(e,t,o,n,0),(a||l)(p,d,i)}var fo=class{startParse(e,t,o){return typeof e=="string"&&(e=new Dn(e)),o=o?o.length?o.map(n=>new nr(n.from,n.to)):[new nr(0,0)]:[new nr(0,e.length)],this.createParse(e,t||[],o)}parse(e,t,o){let n=this.startParse(e,t,o);for(;;){let s=n.advance();if(s)return s}}},Dn=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 C1=new H({perNode:!0});var Pt=class{constructor(e,t,o,n,s,i,a,l,u,c=0,p){this.p=e,this.stack=t,this.state=o,this.reducePos=n,this.pos=s,this.score=i,this.buffer=a,this.bufferBase=l,this.curContext=u,this.lookAhead=c,this.parent=p}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,o=0){let n=e.parser.context;return new Pt(e,[],t,o,o,0,[],0,n?new mo(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let o=e>>19,n=e&65535,{parser:s}=this.p,i=s.dynamicPrecedence(n);if(i&&(this.score+=i),o==0){this.pushState(s.getGoto(this.state,n,!0),this.reducePos),n<s.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,4,!0),this.reduceContext(n,this.reducePos);return}let a=this.stack.length-(o-1)*3-(e&262144?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,u=this.reducePos-l;u>=2e3&&!(!((t=this.p.parser.nodeSet.types[n])===null||t===void 0)&&t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=u));let c=a?this.stack[a-1]:0,p=this.bufferBase+this.buffer.length-c;if(n<s.minRepeatTerm||e&131072){let d=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,l,d,p+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=s.getGoto(d,n,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(n,l)}storeNode(e,t,o,n=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let i=this,a=this.buffer.length;if(a==0&&i.parent&&(a=i.bufferBase-i.parent.bufferBase,i=i.parent),a>0&&i.buffer[a-4]==0&&i.buffer[a-1]>-1){if(t==o)return;if(i.buffer[a-2]>=t){i.buffer[a-2]=o;return}}}if(!s||this.pos==o)this.buffer.push(e,t,o,n);else{let i=this.buffer.length;if(i>0&&this.buffer[i-4]!=0)for(;i>0&&this.buffer[i-2]>o;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,n>4&&(n-=4);this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=o,this.buffer[i+3]=n}}shift(e,t,o){let n=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=o,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,o,4);else{let s=e,{parser:i}=this.p;(o>this.pos||t<=i.maxNode)&&(this.pos=o,i.stateFlag(s,1)||(this.reducePos=o)),this.pushState(s,n),this.shiftContext(t,n),t<=i.maxNode&&this.buffer.push(t,n,o,4)}}apply(e,t,o){e&65536?this.reduce(e):this.shift(e,t,o)}useNode(e,t){let o=this.p.reused.length-1;(o<0||this.p.reused[o]!=e)&&(this.p.reused.push(e),o++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(o,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let o=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new Pt(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,o,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let o=e<=this.p.parser.maxNode;o&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,o?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Vn(this);;){let o=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(o==0)return!1;if(!(o&65536))return!0;t.reduce(o)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>4<<1||this.stack.length>=120){let n=[];for(let s=0,i;s<t.length;s+=2)(i=t[s+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[s],i);if(this.stack.length<120)for(let s=0;n.length<4<<1&&s<t.length;s+=2){let i=t[s+1];n.some((a,l)=>l&1&&a==i)||n.push(t[s],i)}t=n}let o=[];for(let n=0;n<t.length&&o.length<4;n+=2){let s=t[n+1];if(s==this.state)continue;let i=this.split();i.pushState(s,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[n],this.pos),i.score-=200,o.push(i)}return o}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let o=t>>19,n=t&65535,s=this.stack.length-o*3;if(s<0||e.getGoto(this.stack[s],n,!1)<0){let i=this.findForcedReduction();if(i==null)return!1;t=i}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=[],o=(n,s)=>{if(!t.includes(n))return t.push(n),e.allActions(n,i=>{if(!(i&393216))if(i&65536){let a=(i>>19)-s;if(a>1){let l=i&65535,u=this.stack.length-a*3;if(u>=0&&e.getGoto(this.stack[u],l,!1)>=0)return a<<19|65536|l}}else{let a=o(i,s+1);if(a!=null)return a}})};return o(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 mo(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()}},mo=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},rl;(function(r){r[r.Insert=200]="Insert",r[r.Delete=190]="Delete",r[r.Reduce=100]="Reduce",r[r.MaxNext=4]="MaxNext",r[r.MaxInsertStackDepth=300]="MaxInsertStackDepth",r[r.DampenInsertStackDepth=120]="DampenInsertStackDepth",r[r.MinBigReduction=2e3]="MinBigReduction"})(rl||(rl={}));var Vn=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,o=e>>19;o==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(o-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}},Mt=class{constructor(e,t,o){this.stack=e,this.pos=t,this.index=o,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Mt(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 Mt(this.stack,this.pos,this.index)}};function ir(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let o=0,n=0;o<r.length;){let s=0;for(;;){let i=r.charCodeAt(o++),a=!1;if(i==126){s=65535;break}i>=92&&i--,i>=34&&i--;let l=i-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[n++]=s:t=new e(s)}return t}var Et=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},ol=new Et,An=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=ol,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 o=this.range,n=this.rangeIndex,s=this.pos+e;for(;s<o.from;){if(!n)return null;let i=this.ranges[--n];s-=o.from-i.to,o=i}for(;t<0?s>o.to:s>=o.to;){if(n==this.ranges.length-1)return null;let i=this.ranges[++n];s+=i.from-o.to,o=i}return s}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,o,n;if(t>=0&&t<this.chunk.length)o=this.pos+e,n=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(o=s,o>=this.chunk2Pos&&o<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(o-this.chunk2Pos);else{let i=this.rangeIndex,a=this.range;for(;a.to<=o;)a=this.ranges[++i];this.chunk2=this.input.chunk(this.chunk2Pos=o),o+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-o)),n=this.chunk2.charCodeAt(0)}}return o>=this.token.lookAhead&&(this.token.lookAhead=o+1),n}acceptToken(e,t=0){let o=t?this.resolveOffset(t,-1):this.pos;if(o==null||o<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=o}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=ol,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 o="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(o+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return o}},We=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:o}=t.p;cl(this.data,e,t,this.id,o.data,o.tokenPrecTable)}};We.prototype.contextual=We.prototype.fallback=We.prototype.extend=!1;var Nn=class{constructor(e,t,o){this.precTable=t,this.elseToken=o,this.data=typeof e=="string"?ir(e):e}token(e,t){let o=e.pos,n=0;for(;;){let s=e.next<0,i=e.resolveOffset(1,1);if(cl(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||n++,i==null)break;e.reset(i,e.token)}n&&(e.reset(o,e.token),e.acceptToken(this.elseToken,n))}};Nn.prototype.contextual=We.prototype.fallback=We.prototype.extend=!1;function cl(r,e,t,o,n,s){let i=0,a=1<<o,{dialect:l}=t.p.parser;e:for(;a&r[i];){let u=r[i+1];for(let h=i+3;h<u;h+=2)if((r[h+1]&a)>0){let f=r[h];if(l.allows(f)&&(e.token.value==-1||e.token.value==f||tf(f,e.token.value,n,s))){e.acceptToken(f);break}}let c=e.next,p=0,d=r[i+2];if(e.next<0&&d>p&&r[u+d*3-3]==65535&&r[u+d*3-3]==65535){i=r[u+d*3-1];continue e}for(;p<d;){let h=p+d>>1,f=u+h+(h<<1),b=r[f],y=r[f+1]||65536;if(c<b)d=h;else if(c>=y)p=h+1;else{i=r[f+2],e.advance();continue e}}break}}function nl(r,e,t){for(let o=e,n;(n=r[o])!=65535;o++)if(n==t)return o-e;return-1}function tf(r,e,t,o){let n=nl(t,o,e);return n<0||nl(t,o,r)<n}var Te=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),On=null,sl;(function(r){r[r.Margin=25]="Margin"})(sl||(sl={}));function il(r,e,t){let o=r.cursor(Q.IncludeAnonymous);for(o.moveTo(e);;)if(!(t<0?o.childBefore(e):o.childAfter(e)))for(;;){if((t<0?o.to<e:o.from>e)&&!o.type.isError)return t<0?Math.max(0,Math.min(o.to-1,e-25)):Math.min(r.length,Math.max(o.from+1,e+25));if(t<0?o.prevSibling():o.nextSibling())break;if(!o.parent())return t<0?0:r.length}}var _n=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?il(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?il(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 o=this.trees[t],n=this.index[t];if(n==o.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=o.children[n],i=this.start[t]+o.positions[n];if(i>e)return this.nextStart=i,null;if(s instanceof Z){if(i==e){if(i<this.safeFrom)return null;let a=i+s.length;if(a<=this.safeTo){let l=s.prop(H.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[t]++,i+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(i),this.index.push(0))}else this.index[t]++,this.nextStart=i+s.length}}},Bn=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(o=>new Et)}getActions(e){let t=0,o=null,{parser:n}=e.p,{tokenizers:s}=n,i=n.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let u=0;u<s.length;u++){if(!(1<<u&i))continue;let c=s[u],p=this.tokens[u];if(!(o&&!c.fallback)&&((c.contextual||p.start!=e.pos||p.mask!=i||p.context!=a)&&(this.updateCachedToken(p,c,e),p.mask=i,p.context=a),p.lookAhead>p.end+25&&(l=Math.max(p.lookAhead,l)),p.value!=0)){let d=t;if(p.extended>-1&&(t=this.addActions(e,p.extended,p.end,t)),t=this.addActions(e,p.value,p.end,t),!c.extend&&(o=p,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!o&&e.pos==this.stream.end&&(o=new Et,o.value=e.p.parser.eofTerm,o.start=o.end=e.pos,t=this.addActions(e,o.value,o.end,t)),this.mainToken=o,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Et,{pos:o,p:n}=e;return t.start=o,t.end=Math.min(o+1,n.stream.end),t.value=o==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,o){let n=this.stream.clipPos(o.pos);if(t.token(this.stream.reset(n,e),o),e.value>-1){let{parser:s}=o.p;for(let i=0;i<s.specialized.length;i++)if(s.specialized[i]==e.value){let a=s.specializers[i](this.stream.read(e.start,e.end),o);if(a>=0&&o.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,o,n){for(let s=0;s<n;s+=3)if(this.actions[s]==e)return n;return this.actions[n++]=e,this.actions[n++]=t,this.actions[n++]=o,n}addActions(e,t,o,n){let{state:s}=e,{parser:i}=e.p,{data:a}=i;for(let l=0;l<2;l++)for(let u=i.stateSlot(s,l?2:1);;u+=3){if(a[u]==65535)if(a[u+1]==1)u=Oe(a,u+2);else{n==0&&a[u+1]==2&&(n=this.putAction(Oe(a,u+2),t,o,n));break}a[u]==t&&(n=this.putAction(Oe(a,u+1),t,o,n))}return n}},al;(function(r){r[r.Distance=5]="Distance",r[r.MaxRemainingPerStep=3]="MaxRemainingPerStep",r[r.MinBufferLengthPrune=500]="MinBufferLengthPrune",r[r.ForceReduceLimit=10]="ForceReduceLimit",r[r.CutDepth=15e3]="CutDepth",r[r.CutTo=9e3]="CutTo",r[r.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",r[r.MaxStackCount=12]="MaxStackCount"})(al||(al={}));var Fn=class{constructor(e,t,o,n){this.parser=e,this.input=t,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new An(t,n),this.tokens=new Bn(e,this.stream),this.topTerm=e.top[1];let{from:s}=n[0];this.stacks=[Pt.start(this,e.top[0],s)],this.fragments=o.length&&this.stream.end-s>e.bufferLength*4?new _n(o,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,o=this.stacks=[],n,s;if(this.bigReductionCount>300&&e.length==1){let[i]=e;for(;i.forceReduce()&&i.stack.length&&i.stack[i.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let i=0;i<e.length;i++){let a=e[i];for(;;){if(this.tokens.mainToken=null,a.pos>t)o.push(a);else{if(this.advanceStack(a,o,e))continue;{n||(n=[],s=[]),n.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!o.length){let i=n&&rf(n);if(i)return this.stackToTree(i);if(this.parser.strict)throw Te&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&n){let i=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,s,o);if(i)return this.stackToTree(i.forceAll())}if(this.recovering){let i=this.recovering==1?1:this.recovering*3;if(o.length>i)for(o.sort((a,l)=>l.score-a.score);o.length>i;)o.pop();o.some(a=>a.reducePos>t)&&this.recovering--}else if(o.length>1){e:for(let i=0;i<o.length-1;i++){let a=o[i];for(let l=i+1;l<o.length;l++){let u=o[l];if(a.sameState(u)||a.buffer.length>500&&u.buffer.length>500)if((a.score-u.score||a.buffer.length-u.buffer.length)>0)o.splice(l--,1);else{o.splice(i--,1);continue e}}}o.length>12&&o.splice(12,o.length-12)}this.minStackPos=o[0].pos;for(let i=1;i<o.length;i++)o[i].pos<this.minStackPos&&(this.minStackPos=o[i].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,o){let n=e.pos,{parser:s}=this,i=Te?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let p=this.fragments.nodeAt(n);p;){let d=this.parser.nodeSet.types[p.type.id]==p.type?s.getGoto(e.state,p.type.id):-1;if(d>-1&&p.length&&(!u||(p.prop(H.contextHash)||0)==c))return e.useNode(p,d),Te&&console.log(i+this.stackID(e)+` (via reuse of ${s.getName(p.type.id)})`),!0;if(!(p instanceof Z)||p.children.length==0||p.positions[0]>0)break;let h=p.children[0];if(h instanceof Z&&p.positions[0]==0)p=h;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),Te&&console.log(i+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let u=0;u<l.length;){let c=l[u++],p=l[u++],d=l[u++],h=u==l.length||!o,f=h?e:e.split();if(f.apply(c,p,d),Te&&console.log(i+this.stackID(f)+` (via ${c&65536?`reduce of ${s.getName(c&65535)}`:"shift"} for ${s.getName(p)} @ ${n}${f==e?"":", split"})`),h)return!0;f.pos>n?t.push(f):o.push(f)}return!1}advanceFully(e,t){let o=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>o)return ll(e,t),!0}}runRecovery(e,t,o){let n=null,s=!1;for(let i=0;i<e.length;i++){let a=e[i],l=t[i<<1],u=t[(i<<1)+1],c=Te?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),Te&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,o))))continue;let p=a.split(),d=c;for(let h=0;p.forceReduce()&&h<10&&(Te&&console.log(d+this.stackID(p)+" (via force-reduce)"),!this.advanceFully(p,o));h++)Te&&(d=this.stackID(p)+" -> ");for(let h of a.recoverByInsert(l))Te&&console.log(c+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,o);this.stream.end>a.pos?(u==a.pos&&(u++,l=0),a.recoverByDelete(l,u),Te&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),ll(a,o)):(!n||n.score<a.score)&&(n=a)}return n}stackToTree(e){return e.close(),Z.build({buffer:Mt.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=(On||(On=new WeakMap)).get(e);return t||On.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function ll(r,e){for(let t=0;t<e.length;t++){let o=e[t];if(o.pos==r.pos&&o.sameState(r)){e[t].score<r.score&&(e[t]=r);return}}e.push(r)}var zn=class{constructor(e,t,o){this.source=e,this.flags=t,this.disabled=o}allows(e){return!this.disabled||this.disabled[e]==0}};var st=class extends fo{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 o=Object.keys(e.topRules).map(a=>e.topRules[a][1]),n=[];for(let a=0;a<t.length;a++)n.push([]);function s(a,l,u){n[a].push([l,l.deserialize(String(u))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=H[l]);for(let u=1;u<a.length;){let c=a[u++];if(c>=0)s(c,l,a[u++]);else{let p=a[u+-c];for(let d=-c;d>0;d--)s(a[u++],l,p);u++}}}this.nodeSet=new Rt(t.map((a,l)=>le.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:n[l],top:o.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let i=ir(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(ul),this.states=ir(e.states,Uint32Array),this.data=ir(e.stateData),this.goto=ir(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new We(i,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,o){let n=new Fn(this,e,t,o);for(let s of this.wrappers)n=s(n,e,t,o);return n}getGoto(e,t,o=!1){let n=this.goto;if(t>=n[0])return-1;for(let s=n[t+1];;){let i=n[s++],a=i&1,l=n[s++];if(a&&o)return l;for(let u=s+(i>>1);s<u;s++)if(n[s]==e)return l;if(a)return-1}}hasAction(e,t){let o=this.data;for(let n=0;n<2;n++)for(let s=this.stateSlot(e,n?2:1),i;;s+=3){if((i=o[s])==65535)if(o[s+1]==1)i=o[s=Oe(o,s+2)];else{if(o[s+1]==2)return Oe(o,s+2);break}if(i==t||i==0)return Oe(o,s+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,o=>o==t?!0:null)}allActions(e,t){let o=this.stateSlot(e,4),n=o?t(o):void 0;for(let s=this.stateSlot(e,1);n==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Oe(this.data,s+2);else break;n=t(Oe(this.data,s+1))}return n}nextStates(e){let t=[];for(let o=this.stateSlot(e,1);;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=Oe(this.data,o+2);else break;if(!(this.data[o+2]&1)){let n=this.data[o+1];t.some((s,i)=>i&1&&s==n)||t.push(this.data[o],n)}}return t}configure(e){let t=Object.assign(Object.create(st.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let o=this.topRules[e.top];if(!o)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=o}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(o=>{let n=e.tokenizers.find(s=>s.from==o);return n?n.to:o})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((o,n)=>{let s=e.specializers.find(a=>a.from==o.external);if(!s)return o;let i=Object.assign(Object.assign({},o),{external:s.to});return t.specializers[n]=ul(i),i})),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),o=t.map(()=>!1);if(e)for(let s of e.split(" ")){let i=t.indexOf(s);i>=0&&(o[i]=!0)}let n=null;for(let s=0;s<t.length;s++)if(!o[s])for(let i=this.dialects[t[s]],a;(a=this.data[i++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[a]=1;return new zn(e,o,n)}static deserialize(e){return new st(e)}};function Oe(r,e){return r[e]|r[e+1]<<16}function rf(r){let e=null;for(let t of r){let o=t.p.stoppedAt;(t.pos==t.p.stream.end||o!=null&&t.pos>o)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function ul(r){if(r.external){let e=r.extend?1:0;return(t,o)=>r.external(t,o)<<1|e}return r.get}var Hn=st.deserialize({version:14,states:"%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",stateData:"#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",goto:"#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",nodeNames:"\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:"6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",tokenizers:[0,1],topRules:{Filter:[0,1]},tokenPrec:0});import{isMultiClauseFilter as ar,isMultiValueFilter as of,isSingleValueFilter as nf}from"@vuu-ui/vuu-utils";var ue,$n=class{constructor(){N(this,ue,void 0)}setFilterCombinatorOp(e,t=m(this,ue)){ar(t)&&t.op===e||L(this,ue,{op:e,filters:[m(this,ue)]})}add(e){if(m(this,ue)===void 0)L(this,ue,e);else if(ar(m(this,ue)))m(this,ue).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=m(this,ue)){if(ar(t)){let o=t.filters.at(-1);o&&this.setColumn(e,o)}else t&&(t.column=e)}setOp(e,t=m(this,ue)){if(ar(t)){let o=t.filters.at(-1);o&&this.setOp(e,o)}else t&&(t.op=e)}setValue(e,t=m(this,ue)){var o;if(ar(t)){let n=t.filters.at(-1);n&&this.setValue(e,n)}else of(t)?((o=t.values)!=null||(t.values=[]),t.values.push(e)):nf(t)&&(t.value=e)}toJSON(e=m(this,ue)){return this.name?{...e,name:this.name}:e}};ue=new WeakMap;var Wn=(r,e)=>{let t=new $n,o=r.cursor();do{let{name:n,from:s,to:i}=o;switch(n){case"ColumnValueExpression":t.add({});break;case"ColumnSetExpression":t.add({op:"in"});break;case"Or":case"And":t.setFilterCombinatorOp(e.substring(s,i));break;case"Column":t.setColumn(e.substring(s,i));break;case"Operator":t.setOp(e.substring(s,i));break;case"String":t.setValue(e.substring(s+1,i-1));break;case"Number":t.setValue(parseFloat(e.substring(s,i)));break;case"True":t.setValue(!0);break;case"False":t.setValue(!1);break;case"FilterName":t.name=e.substring(s,i);break;default:}}while(o.next());return t.toJSON()};var sf=Hn.configure({strict:!0}),it=r=>{let e=sf.parse(r);return Wn(e,r)};function go(r,e){switch(e.op){case"in":return af(r,e);case"=":return lf(r,e);case">":return uf(r,e);case">=":return cf(r,e);case"<":return pf(r,e);case"<=":return df(r,e);case"starts":return hf(r,e);case"and":return ff(r,e);case"or":return mf(r,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var af=(r,e)=>t=>e.values.indexOf(t[r[e.column]])!==-1,lf=(r,e)=>t=>t[r[e.column]]===e.value,uf=(r,e)=>t=>t[r[e.column]]>e.value,cf=(r,e)=>t=>t[r[e.column]]>=e.value,pf=(r,e)=>t=>t[r[e.column]]<e.value,df=(r,e)=>t=>t[r[e.column]]<=e.value,hf=(r,e)=>{let t=e.value;if(typeof t!="string")throw Error("string filter applied to value of wrong type");return o=>{let n=o[r[e.column]];if(typeof n!="string")throw Error("string filter applied to value of wrong type");return n.toLowerCase().startsWith(t.toLowerCase())}},ff=(r,e)=>{let t=e.filters.map(o=>go(r,o));return o=>t.every(n=>n(o))};function mf(r,e){let t=e.filters.map(o=>go(r,o));return o=>t.some(n=>n(o))}import{buildColumnMap as vl,EventEmitter as Vf,getAddedItems as Af,getMissingItems as Nf,KeySet as _f,logger as Bf,metadataKeys as Ff,NULL_RANGE as wl,rangeNewItems as zf,resetRange as lr,uuid as Sl}from"@vuu-ui/vuu-utils";var pl=(r,e,t,o,n,s)=>{let i=at(n,r),a=r[r.length-1].aggType,l=t.map(u=>n[u]);switch(a){case 1:return hl(s,o,n,r,e,l);case 2:return gf(s,o,n,r,e,l);case 3:return dl(s,n,r,e,l);case 4:return bf(s,o,n,r,e,l);case 5:return vf(s,o,n,r,e,l);case 6:return yf(s,o,n,r,e,l)}};function dl(r,e,t,o,n){let s={},i=at(e,t);function a(l){if(Array.isArray(l))return l.length;{let u=0;for(let c in l)u+=1+a(l[c]);return u}}for(let l in r){let u=a(r[l]);s[l]=u}for(let l=0;l<o.length;l++)for(let u in s)o[l][n[0]]===u&&(o[l][i]=s[u]);return console.log("!!!! targetData",o),console.log("!!!! counts",s),s}function at(r,e){console.log("!!!! aggregation length",e.length);let t=e[e.length-1].column;return r[t]}function hl(r,e,t,o,n,s){let i={},a=at(t,o);function l(u,c,p){if(Array.isArray(u)){let d=0;for(let h of u)d+=Number(c[h][p]);return d}else{let d=0;for(let h in u)d+=l(u[h],c,p);return d}}for(let u in r){console.log(u);let c=Number(l(r[u],e,a));i[u]=c}for(let u=0;u<n.length;u++)for(let c in i)n[u][s[0]]===c&&(n[u][a]=i[c]);return console.log("!!!! targetData",n),console.log("!!!! sums",i),i}function gf(r,e,t,o,n,s){let i={},a=at(t,o),l=dl(r,t,o,n,s),u=hl(r,e,t,o,n,s);for(let c in l){let p=0;p=u[c]/l[c],i[c]=p}for(let c=0;c<n.length;c++)for(let p in i)n[c][s[0]]===p&&(n[c][a]=i[p]);return console.log("!!!! targetData",n),console.log("!!!! averages",i),i}function yo(r,e,t){let o=[];if(Array.isArray(r))for(let n of r)o.push(e[n][t]);else for(let n in r)o.push(...yo(r[n],e,t));return o}function yf(r,e,t,o,n,s){let i={},a=at(t,o);for(let l in r){let u=yo(r[l],e,a),c=[...new Set(u)];i[l]=c}for(let l=0;l<n.length;l++)for(let u in i)n[l][s[0]]===u&&(n[l][a]=i[u]);return i}function bf(r,e,t,o,n,s){let i={},a=at(t,o);for(let l in r){let u=yo(r[l],e,a),c=Math.max(...u);i[l]=c}for(let l=0;l<n.length;l++)for(let u in i)n[l][s[0]]===u&&(n[l][a]=i[u]);return i}function vf(r,e,t,o,n,s){let i={},a=at(t,o);for(let l in r){let u=yo(r[l],e,a),c=Math.min(...u);i[l]=c}for(let l=0;l<n.length;l++)for(let u in i)n[l][s[0]]===u&&(n[l][a]=i[u]);return i}import{metadataKeys as wf}from"@vuu-ui/vuu-utils";var{DEPTH:Un,IS_EXPANDED:fl,KEY:Gn}=wf,ml=(r,e)=>{let t=[];for(let o=0,n=0,s=!1,i=e.length;o<i;o++){let a=e[o],{[Un]:l,[Gn]:u}=a;if(u===r){let c=a.slice();for(c[fl]=!1,t.push(c),n+=1,s=!0;o<i-1&&e[o+1][Un]>l;)o+=1}else if(s){let c=a.slice();c[0]=n,c[1]=n,t.push(c),n+=1}else t.push(a),n+=1}return t},qn=(r,e,t,o,n,s)=>{let i=t.map(a=>o[a]);return gl(n,i,r,e,void 0,void 0,void 0,s)},gl=(r,e,t,o=[],n="$root",s=1,i=[],a)=>{console.log("dataRowsFromGroups2 1)");let l=Object.keys(r).sort();for(let u of l){let c=i.length,p=`${n}|${u}`,d=[c,c,!1,!1,s,0,p,0];d[e[s-1]]=u,i.push(d),t.includes(p)&&(d[fl]=!0,Array.isArray(r[u])?Sf(i,r[u],o,p,s+1):gl(r[u],e,t,o,p,s+1,i,a))}console.log("dataRowsFromGroups2 2)");for(let u in i)for(let c in i)if(i[u][2]===!1&&a[c]!=null&&i[u][e[0]]===a[c][e[0]]){i[u]=i[u].splice(0,8).concat(a[c].slice(8,a[c].length));break}return console.log("dataRowsFromGroups2 3)"),i},Sf=(r,e,t,o,n)=>{for(let s of e){let i=r.length,a=t[s].slice();a[0]=i,a[1]=i,a[Un]=n,a[Gn]=`${o}|${a[Gn]}`,r.push(a)}},yl=(r,e,t)=>{let o=e.map(i=>t[i]),n=Rf(r,o);return[Cf(n,o),n]},Cf=(r,e)=>{let o=[],n=0,s=Object.keys(r).sort();for(let i of s){let a=[n,n,!1,!1,1,0,`$root|${i}`,0];a[e[0]]=i,o.push(a),n+=1}return o};function Rf(r,e){let t={},o=e.length,n=o-1;for(let s=0,i=r.length;s<i;s++){let a=r[s],l=t,u,c;for(let p=0;p<o;p++){let d=e[p];c=a[d].toString(),u=l[c],u&&p===n?u.push(s):u?l=u:!u&&p<n?l=l[c]={}:u||(l[c]=[s])}}return console.log("!! groups",t),t}var xf=(r,e,[t,o])=>{let n=o==="D"?e[t]:r[t],s=o==="D"?r[t]:e[t];return n===s?0:s===null||n>s?1:-1},Tf=r=>r.length===1?Ef(r):r.length===2?Pf(r):Mf(r),Ef=([[r,e]])=>(t,o)=>{let n=e==="D"?o[r]:t[r],s=e==="D"?t[r]:o[r];return n>s?1:s>n?-1:0},Pf=([[r,e],[t,o]])=>(n,s)=>{let i=e==="D"?s[r]:n[r],a=e==="D"?n[r]:s[r],l=o==="D"?s[t]:n[t],u=o==="D"?n[t]:s[t];return i>a?1:a>i?-1:l>u?1:u>l?-1:0},Mf=(r,e=xf)=>(t,o)=>{for(let n of r){let s=e(t,o,n);if(s!==0)return s}return 0},bl=(r,{sortDefs:e},t)=>{let o=e.map(({column:s,sortType:i})=>[t[s],i]),n=Tf(o);return r.slice().sort(n)};import{getSelectionStatus as Lf,metadataKeys as bo}from"@vuu-ui/vuu-utils";var{RENDER_IDX:Df,SELECTED:If}=bo,Jn=(r,e,t,o)=>{let[n]=r,s;if(o){let{count:i}=bo;s=r.slice(0,i).concat(o.map(a=>r[a]))}else s=r.slice();return s[Df]=e.keyFor(n),s[If]=Lf(t,n),s},kf=(r,e)=>{if(e){let{count:t}=bo;for(let[o,n]of Object.entries(r)){let s=e[o];if(s===void 0)throw Error(`ArrayDataSource column ${o} is not in underlying data set`);if(s!==n-t)return!0}}return!1},Of=(r,e)=>{let{count:t}=bo,o=[];return Object.entries(r).forEach(([n])=>{o.push(e[n]+t)}),o},Qn=(r,e)=>{if(e&&kf(r,e))return Of(r,e)};var{KEY:Cl}=Ff,{debug:ye}=Bf("ArrayDataSource"),Kn=r=>(e,t)=>[t,t,!0,!1,1,0,String(e[r]),0,...e],Hf=(r,e)=>({columns:r.map(({name:o,serverDataType:n="string"})=>({name:o,serverDataType:n})),key:e!=null?e:r[0].name,table:{module:"",table:"Array"}}),ie,B,U,vo,W,ur,wo,cr,Lt,Rl=class extends Vf{constructor({aggregations:t,columnDescriptors:o,data:n,dataMap:s,filter:i,groupBy:a,keyColumn:l,rangeChangeRowset:u="delta",sort:c,title:p,viewport:d}){super();this.lastRangeServed={from:0,to:0};this.openTreeNodes=[];N(this,ie,void 0);N(this,B,St);N(this,U,void 0);N(this,vo,void 0);N(this,W,wl);N(this,ur,0);N(this,wo,0);N(this,cr,"initialising");N(this,Lt,void 0);this.selectedRows=[];this.keys=new _f(m(this,W));this.processedData=void 0;this.insert=t=>{let o=Kn(this.key)(t,this.size);m(this,U).push(o);let{from:n,to:s}=m(this,W),[i]=o;i>=n&&i<s&&this.sendRowsToClient()};this.update=(t,o)=>{var l;let n=t[this.key],s=m(this,ie)[o],i=(l=this.dataMap)==null?void 0:l[o],a=m(this,U).findIndex(u=>u[Cl]===n);if(a!==-1&&i!==void 0){let u=m(this,U)[a];u[s]=t[i];let{from:c,to:p}=m(this,W),[d]=u;d>=c&&d<p&&this.sendRowsToClient(!1,u)}};this.updateRow=t=>{let o=t[this.key],n=m(this,U).findIndex(s=>s[Cl]===o);if(n!==-1){let s=Kn(this.key)(t,n);m(this,U)[n]=s;let{from:i,to:a}=m(this,W);n>=i&&n<a&&this.sendRowsToClient(!1,s)}};if(!n||!o)throw Error("ArrayDataSource constructor called without data or without columnDescriptors");this.columnDescriptors=o,this.dataMap=s,this.key=l?this.columnDescriptors.findIndex(f=>f.name===l):0,this.rangeChangeRowset=u,this.tableSchema=Hf(o,l),this.viewport=d||Sl(),L(this,wo,n.length),L(this,Lt,p);let h=o.map(f=>f.name);L(this,ie,vl(h)),this.dataIndices=Qn(m(this,ie),this.dataMap),L(this,U,n.map(Kn(this.key))),this.config={...m(this,B),aggregations:t||m(this,B).aggregations,columns:h,filter:i||m(this,B).filter,groupBy:a||m(this,B).groupBy,sort:c||m(this,B).sort},ye==null||ye(`columnMap: ${JSON.stringify(m(this,ie))}`)}async subscribe({viewport:t=(c=>(c=this.viewport)!=null?c:Sl())(),columns:o,aggregations:n,range:s,sort:i,groupBy:a,filter:l},u){var h;this.clientCallback=u,this.viewport=t,L(this,cr,"subscribed"),this.lastRangeServed={from:0,to:0};let p=m(this,B),d=n||o||l||a||i;d&&(s&&L(this,W,s),p={...p,aggregations:n||m(this,B).aggregations,columns:o||m(this,B).columns,filter:l||m(this,B).filter,groupBy:a||m(this,B).groupBy,sort:i||m(this,B).sort}),(h=this.clientCallback)==null||h.call(this,{...p,type:"subscribed",clientViewportId:this.viewport,range:m(this,W),tableSchema:this.tableSchema}),d?this.config=p:(this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:m(this,U).length}),s?this.range=s:m(this,W)!==wl&&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){L(this,ur,t.length),ye==null||ye(`select ${JSON.stringify(t)}`),this.selectedRows=t,this.setRange(lr(m(this,W)),!0)}openTreeNode(t){this.openTreeNodes.push(t),this.processedData=qn(this.openTreeNodes,m(this,U),m(this,B).groupBy,m(this,ie),this.groupMap,this.processedData),this.setRange(lr(m(this,W)),!0)}closeTreeNode(t){this.openTreeNodes=this.openTreeNodes.filter(o=>o!==t),this.processedData&&(this.processedData=ml(t,this.processedData),this.setRange(lr(m(this,W)),!0))}get links(){return m(this,vo)}get menu(){return this._menu}get status(){return m(this,cr)}get data(){return m(this,U)}get currentData(){var t;return(t=this.processedData)!=null?t:m(this,U)}get table(){return this.tableSchema.table}get config(){return m(this,B)}set config(t){var o;if(io(m(this,B),t)){if(t){let n=m(this,B),s=(o=t==null?void 0:t.filter)!=null&&o.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:it(t.filter.filter)}}:t;L(this,B,ao(s));let i;if(Ba(t)){let{filter:a,filterStruct:l=it(a)}=t.filter;if(l){let u=go(m(this,ie),l);i=m(this,U).filter(u)}else throw Error("filter must include filterStruct")}if(Fa(t)&&(i=bl(i!=null?i:m(this,U),t.sort,m(this,ie))),this.openTreeNodes.length>0&&Rn(n,t)&&(m(this,B).groupBy.length===0?this.openTreeNodes.length=0:console.log("adjust the openTReeNodes groupBy changed ",{originalGroupBy:n.groupBy,newGroupBy:s.groupBy})),_a(t)){let[a,l]=yl(i!=null?i:m(this,U),t.groupBy,m(this,ie));this.groupMap=l,i=a,this.openTreeNodes.length>0&&(i=qn(this.openTreeNodes,m(this,U),m(this,B).groupBy,m(this,ie),this.groupMap,i))}this.processedData=i==null?void 0:i.map((a,l)=>{let u=a.slice();return u[0]=l,u[1]=l,u})}this.setRange(lr(m(this,W)),!0),this.emit("config",m(this,B))}}get selectedRowsCount(){return m(this,ur)}get size(){var t,o;return(o=(t=this.processedData)==null?void 0:t.length)!=null?o:m(this,U).length}get range(){return m(this,W)}set range(t){(t.from!==m(this,W).from||t.to!==m(this,W).to)&&this.setRange(t)}delete(t){console.log(`delete row ${t.join(",")}`)}setRange(t,o=!1){L(this,W,t),this.keys.reset(t),this.sendRowsToClient(o)}sendRowsToClient(t=!1,o){var n,s,i;if(o)(n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"update",rows:[Jn(o,this.keys,this.selectedRows,this.dataIndices)],type:"viewport-update"});else{let a=this.rangeChangeRowset==="delta"&&!t?zf(this.lastRangeServed,m(this,W)):m(this,W),l=(s=this.processedData)!=null?s:m(this,U),u=l.slice(a.from,a.to).map(c=>Jn(c,this.keys,this.selectedRows,this.dataIndices));(i=this.clientCallback)==null||i.call(this,{clientViewportId:this.viewport,mode:"batch",rows:u,size:l.length,type:"viewport-update"}),this.lastRangeServed={from:m(this,W).from,to:Math.min(m(this,W).to,m(this,W).from+u.length)}}}get columns(){return m(this,B).columns}set columns(t){let o=Af(this.config.columns,t);if(o.length>0){let n=Nf(this.columnDescriptors,o,s=>s.name);console.log("columnsWithoutDescriptors",{columnsWithoutDescriptors:n})}L(this,ie,vl(t)),this.dataIndices=Qn(m(this,ie),this.dataMap),this.config={...m(this,B),columns:t}}get aggregations(){return m(this,B).aggregations}set aggregations(t){var s;L(this,B,{...m(this,B),aggregations:t});let o=(s=this.processedData)!=null?s:m(this,U),n=m(this,U);pl(t,o,m(this,B).groupBy,n,m(this,ie),this.groupMap),this.setRange(lr(m(this,W)),!0),this.emit("config",m(this,B))}get sort(){return m(this,B).sort}set sort(t){ye==null||ye(`sort ${JSON.stringify(t)}`),this.config={...m(this,B),sort:t}}get filter(){return m(this,B).filter}set filter(t){ye==null||ye(`filter ${JSON.stringify(t)}`),this.config={...m(this,B),filter:t}}get groupBy(){return m(this,B).groupBy}set groupBy(t){this.config={...m(this,B),groupBy:t}}get title(){return m(this,Lt)}set title(t){L(this,Lt,t)}get _clientCallback(){return this.clientCallback}createLink({parentVpId:t,link:{fromColumn:o,toColumn:n}}){console.log("create link",{parentVpId:t,fromColumn:o,toColumn:n})}removeLink(){console.log("remove link")}findRow(t){let o=m(this,U)[t];if(o)return o;throw`no row found for key ${t}`}applyEdit(t,o,n){return console.log(`ArrayDataSource applyEdit ${t[0]} ${o} ${n}`),Promise.resolve(!0)}async menuRpcCall(t){return new Promise(o=>{let{type:n}=t;switch(n){case"VP_EDIT_CELL_RPC":break;default:o(void 0)}})}};ie=new WeakMap,B=new WeakMap,U=new WeakMap,vo=new WeakMap,W=new WeakMap,ur=new WeakMap,wo=new WeakMap,cr=new WeakMap,Lt=new WeakMap;import{EventEmitter as $f,isSelected as Wf,jsonToDataSourceRows as xl,KeySet as Uf,metadataKeys as Gf,uuid as Tl}from"@vuu-ui/vuu-utils";var qf={columns:[],key:"",table:{module:"",table:""}},{DEPTH:lt,IDX:El,IS_EXPANDED:Jf,IS_LEAF:Qf,KEY:Il,SELECTED:Pl}=Gf,Ml=(r,e)=>{let[t]=r,o=r.slice();return o[1]=e.keyFor(t),o},Ue,be,te,Ge,qe,Le,So,Co,Je,Dt,It,Ll=class extends $f{constructor({aggregations:t,data:o,filter:n,groupBy:s,sort:i,title:a,viewport:l}){super();this.expandedRows=new Set;this.visibleRows=[];N(this,Ue,[]);N(this,be,St);N(this,te,void 0);N(this,Ge,{filter:""});N(this,qe,[]);N(this,Le,{from:0,to:0});N(this,So,0);N(this,Co,0);N(this,Je,{sortDefs:[]});N(this,Dt,"initialising");N(this,It,void 0);this.keys=new Uf(m(this,Le));if(!o)throw Error("JsonDataSource constructor called without data");[this.columnDescriptors,Io(this,te)._]=xl(o),this.visibleRows=m(this,te).filter(u=>u[lt]===0).map((u,c)=>[c,c].concat(u.slice(2))),this.viewport=l||Tl(),t&&L(this,Ue,t),this.columnDescriptors&&L(this,be,{...m(this,be),columns:this.columnDescriptors.map(u=>u.name)}),n&&L(this,Ge,n),s&&L(this,qe,s),i&&L(this,Je,i),L(this,It,a)}async subscribe({viewport:t=(c=>(c=this.viewport)!=null?c:Tl())(),columns:o,aggregations:n,range:s,sort:i,groupBy:a,filter:l},u){var p;this.clientCallback=u,n&&L(this,Ue,n),o&&L(this,be,{...m(this,be),columns:o}),l&&L(this,Ge,l),a&&L(this,qe,a),s&&L(this,Le,s),i&&L(this,Je,i),m(this,Dt)==="initialising"&&(this.viewport=t,L(this,Dt,"subscribed"),(p=this.clientCallback)==null||p.call(this,{aggregations:m(this,Ue),type:"subscribed",clientViewportId:this.viewport,columns:m(this,be).columns,filter:m(this,Ge),groupBy:m(this,qe),range:m(this,Le),sort:m(this,Je),tableSchema:qf}),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,Io(this,te)._]=xl(t),this.visibleRows=m(this,te).filter(o=>o[lt]===0).map((o,n)=>[n,n].concat(o.slice(2))),requestAnimationFrame(()=>{this.sendRowsToClient()})}select(t){var n;let o=[];for(let s of m(this,te)){let{[El]:i,[Pl]:a}=s,l=a===1,u=Wf(t,i);if(u!==l){let c=s.slice();c[Pl]=u?1:0,m(this,te)[i]=c,o.push(c)}}o.length>0&&((n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"update",type:"viewport-update",rows:o}))}openTreeNode(t){var s;this.expandedRows.add(t),this.visibleRows=Dl(m(this,te),this.expandedRows);let{from:o,to:n}=m(this,Le);(s=this.clientCallback)==null||s.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(o,n).map(i=>Ml(i,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}closeTreeNode(t,o=!1){if(this.expandedRows.delete(t),o)for(let n of this.expandedRows.keys())n.startsWith(t)&&this.expandedRows.delete(n);this.visibleRows=Dl(m(this,te),this.expandedRows),this.sendRowsToClient()}get status(){return m(this,Dt)}get config(){return m(this,be)}get selectedRowsCount(){return m(this,So)}get size(){return m(this,Co)}get range(){return m(this,Le)}set range(t){L(this,Le,t),this.keys.reset(t),requestAnimationFrame(()=>{this.sendRowsToClient()})}sendRowsToClient(){var n;let{from:t,to:o}=m(this,Le);(n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(t,o).map(s=>Ml(s,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}get columns(){return m(this,be).columns}set columns(t){L(this,be,{...m(this,be),columns:t})}get aggregations(){return m(this,Ue)}set aggregations(t){L(this,Ue,t)}get sort(){return m(this,Je)}set sort(t){L(this,Je,t)}get filter(){return m(this,Ge)}set filter(t){L(this,Ge,t)}get groupBy(){return m(this,qe)}set groupBy(t){L(this,qe,t)}get title(){return m(this,It)}set title(t){L(this,It,t)}createLink({parentVpId:t,link:{fromColumn:o,toColumn:n}}){console.log("create link",{parentVpId:t,fromColumn:o,toColumn:n})}removeLink(){console.log("remove link")}async menuRpcCall(t){console.log("rmenuRpcCall",{rpcRequest:t})}applyEdit(t,o,n){return console.log(`ArrayDataSource applyEdit ${t.join(",")} ${o} ${n}`),Promise.resolve(!0)}getChildRows(t){let o=m(this,te).find(n=>n[Il]===t);if(o){let{[El]:n,[lt]:s}=o,i=n+1,a=[];do{let{[lt]:l}=m(this,te)[i];if(l===s+1)a.push(m(this,te)[i]);else if(l<=s)break;i+=1}while(i<m(this,te).length);return a}else console.warn(`JsonDataSource getChildRows row not found for key ${t}`);return[]}getRowsAtDepth(t,o=!0){return(o?this.visibleRows:m(this,te)).filter(s=>s[lt]===t)}};Ue=new WeakMap,be=new WeakMap,te=new WeakMap,Ge=new WeakMap,qe=new WeakMap,Le=new WeakMap,So=new WeakMap,Co=new WeakMap,Je=new WeakMap,Dt=new WeakMap,It=new WeakMap;function Dl(r,e){let t=[],o={value:0};for(let n=0;n<r.length;n++){let s=r[n],{[lt]:i,[Il]:a,[Qf]:l}=s,u=e.has(a);if(t.push(Kf(s,o,u)),!l&&!u)do n+=1;while(n<r.length-1&&r[n+1][lt]>i)}return t}var Kf=(r,e,t)=>{let o=r.slice();return o[0]=e.value,o[1]=e.value,t&&(o[Jf]=!0),e.value+=1,o};import{debounce as kl,EventEmitter as jf,itemsOrOrderChanged as Xf,logger as Zf,metadataKeys as Yf,throttle as em,uuid as tm}from"@vuu-ui/vuu-utils";var{info:ae}=Zf("RemoteDataSource"),{KEY:rm}=Yf,k,Ro,pr,dr,kt,Ve,hr,Ot,$,ut,jn=class extends jf{constructor({bufferSize:t=100,aggregations:o,columns:n,filter:s,groupBy:i,sort:a,table:l,title:u,viewport:c,visualLink:p}){super();this.server=null;N(this,k,St);N(this,Ro,[]);N(this,pr,void 0);N(this,dr,void 0);N(this,kt,"throttle");N(this,Ve,{from:0,to:0});N(this,hr,0);N(this,Ot,0);N(this,$,"initialising");N(this,ut,void 0);this.handleMessageFromServer=t=>{var o,n;if(t.type==="subscribed")L(this,$,"subscribed"),t.tableSchema&&(this.tableSchema=t.tableSchema),(o=this.clientCallback)==null||o.call(this,t);else if(t.type==="disabled")L(this,$,"disabled");else if(t.type==="enabled")L(this,$,"enabled");else{if(Ha(t))return;t.type==="debounce-begin"?this.optimize="debounce":(t.type==="viewport-update"&&t.size!==void 0&&t.size!==m(this,Ot)&&(L(this,Ot,t.size),this.emit("resize",t.size)),this.configChangePending&&this.setConfigPending(),Ja(t)?L(this,dr,t.menu):qa(t)?L(this,pr,t.links):(n=this.clientCallback)==null||n.call(this,t),this.optimize==="debounce"&&this.revertDebounce())}};this.revertDebounce=kl(()=>{this.optimize="throttle"},100);this.rawRangeRequest=t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})};this.debounceRangeRequest=kl(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},50);this.throttleRangeRequest=em(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},80);if(!l)throw Error("RemoteDataSource constructor called without table");this.bufferSize=t,this.table=l,this.viewport=c,L(this,k,{...m(this,k),aggregations:o||m(this,k).aggregations,columns:n||m(this,k).columns,filter:s||m(this,k).filter,groupBy:i||m(this,k).groupBy,sort:a||m(this,k).sort,visualLink:p||m(this,k).visualLink}),L(this,ut,u),this.rangeRequest=this.throttleRangeRequest}async subscribe({viewport:t=(c=>(c=this.viewport)!=null?c:this.viewport=tm())(),columns:o,aggregations:n,range:s,sort:i,groupBy:a,filter:l},u){var d;if(m(this,$)==="disabled"||m(this,$)==="disabling"){this.enable(u);return}if(this.clientCallback=u,(n||o||l||a||i)&&L(this,k,{...m(this,k),aggregations:n||m(this,k).aggregations,columns:o||m(this,k).columns,filter:l||m(this,k).filter,groupBy:a||m(this,k).groupBy,sort:i||m(this,k).sort}),s&&L(this,Ve,s),m(this,$)!=="initialising"&&m(this,$)!=="unsubscribed")return;L(this,$,"subscribing"),this.viewport=t,this.server=await ja();let{bufferSize:p}=this;(d=this.server)==null||d.subscribe({...m(this,k),bufferSize:p,viewport:t,table:this.table,range:m(this,Ve),title:m(this,ut)},this.handleMessageFromServer)}unsubscribe(){var t,o;console.log(`unsubscribe #${this.viewport}`),ae==null||ae(`unsubscribe #${this.viewport}`),this.viewport&&((t=this.server)==null||t.unsubscribe(this.viewport)),(o=this.server)==null||o.destroy(this.viewport),this.server=null,this.removeAllListeners(),L(this,$,"unsubscribed"),this.viewport=void 0,this.range={from:0,to:0}}suspend(){var t;return console.log(`suspend #${this.viewport}, current status ${m(this,$)}`),ae==null||ae(`suspend #${this.viewport}, current status ${m(this,$)}`),this.viewport&&(L(this,$,"suspended"),(t=this.server)==null||t.send({type:"suspend",viewport:this.viewport})),this}resume(){var n;console.log(`resume #${this.viewport}, current status ${m(this,$)}`);let t=m(this,$).startsWith("disabl"),o=m(this,$)==="suspended";return ae==null||ae(`resume #${this.viewport}, current status ${m(this,$)}`),this.viewport&&(t?this.enable():o&&((n=this.server)==null||n.send({type:"resume",viewport:this.viewport}),L(this,$,"subscribed"))),this}disable(){var t;return ae==null||ae(`disable #${this.viewport}, current status ${m(this,$)}`),this.viewport&&(L(this,$,"disabling"),(t=this.server)==null||t.send({viewport:this.viewport,type:"disable"})),this}enable(t){var o;return ae==null||ae(`enable #${this.viewport}, current status ${m(this,$)}`),this.viewport&&(m(this,$)==="disabled"||m(this,$)==="disabling")&&(L(this,$,"enabling"),t&&(this.clientCallback=t),(o=this.server)==null||o.send({viewport:this.viewport,type:"enable"})),this}select(t){var o;L(this,hr,t.length),this.viewport&&((o=this.server)==null||o.send({viewport:this.viewport,type:"select",selected:t}))}openTreeNode(t){var o;this.viewport&&((o=this.server)==null||o.send({viewport:this.viewport,type:"openTreeNode",key:t}))}closeTreeNode(t){var o;this.viewport&&((o=this.server)==null||o.send({viewport:this.viewport,type:"closeTreeNode",key:t}))}get links(){return m(this,pr)}get menu(){return m(this,dr)}get status(){return m(this,$)}get optimize(){return m(this,kt)}set optimize(t){if(t!==m(this,kt)){switch(L(this,kt,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 m(this,hr)}get size(){return m(this,Ot)}get range(){return m(this,Ve)}set range(t){(t.from!==m(this,Ve).from||t.to!==m(this,Ve).to)&&(L(this,Ve,t),this.rangeRequest(t))}get config(){return m(this,k)}set config(t){var o,n;if(io(m(this,k),t)&&t){let s=(o=t==null?void 0:t.filter)!=null&&o.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:it(t.filter.filter)}}:t;L(this,k,ao(s)),m(this,k)&&this.viewport&&this.server&&t&&((n=this.server)==null||n.send({viewport:this.viewport,type:"config",config:m(this,k)})),this.emit("config",m(this,k))}}get columns(){return m(this,k).columns}set columns(t){if(L(this,k,{...m(this,k),columns:t}),this.viewport){let o={viewport:this.viewport,type:"setColumns",columns:t};this.server&&this.server.send(o)}this.emit("config",m(this,k))}get aggregations(){return m(this,k).aggregations}set aggregations(t){var o;L(this,k,{...m(this,k),aggregations:t}),this.viewport&&((o=this.server)==null||o.send({viewport:this.viewport,type:"aggregate",aggregations:t})),this.emit("config",m(this,k))}get sort(){return m(this,k).sort}set sort(t){if(L(this,k,{...m(this,k),sort:t}),this.viewport){let o={viewport:this.viewport,type:"sort",sort:t};this.server&&this.server.send(o)}this.emit("config",m(this,k))}get filter(){return m(this,k).filter}set filter(t){if(L(this,k,{...m(this,k),filter:t}),this.viewport){let o={viewport:this.viewport,type:"filter",filter:t};this.server&&this.server.send(o)}this.emit("config",m(this,k))}get groupBy(){return m(this,k).groupBy}set groupBy(t){var o;if(Xf(this.groupBy,t)){let n=m(this,Ro).length>0;if(L(this,k,{...m(this,k),groupBy:t}),this.viewport){let s={viewport:this.viewport,type:"groupBy",groupBy:m(this,k).groupBy};this.server&&this.server.send(s)}!n&&t.length>0&&this.viewport&&((o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"batch",type:"viewport-update",size:0,rows:[]})),this.emit("config",m(this,k)),this.setConfigPending({groupBy:t})}}get title(){return m(this,ut)}set title(t){var o;L(this,ut,t),this.viewport&&t&&((o=this.server)==null||o.send({type:"setTitle",title:t,viewport:this.viewport}))}get visualLink(){return m(this,k).visualLink}set visualLink(t){var o,n;if(L(this,k,{...m(this,k),visualLink:t}),t){let{parentClientVpId:s,link:{fromColumn:i,toColumn:a}}=t;this.viewport&&((o=this.server)==null||o.send({viewport:this.viewport,type:"createLink",parentClientVpId:s,parentColumnName:a,childColumnName:i}))}else this.viewport&&((n=this.server)==null||n.send({type:"removeLink",viewport:this.viewport}));this.emit("config",m(this,k))}setConfigPending(t){let o=this.configChangePending;this.configChangePending=t,t!==void 0?this.emit("config",t,!1):this.emit("config",o,!0)}async rpcCall(t){var o;if(this.viewport)return(o=this.server)==null?void 0:o.rpcCall({vpId:this.viewport,...t})}async menuRpcCall(t){var o;if(this.viewport)return(o=this.server)==null?void 0:o.rpcCall({vpId:this.viewport,...t})}applyEdit(t,o,n){return this.menuRpcCall({rowKey:t[rm],field:o,value:n,type:"VP_EDIT_CELL_RPC"}).then(s=>s!=null&&s.error?s.error:!0)}insertRow(t,o){return this.menuRpcCall({rowKey:t,data:o,type:"VP_EDIT_ADD_ROW_RPC"}).then(n=>n!=null&&n.error?n.error:!0)}deleteRow(t){return this.menuRpcCall({rowKey:t,type:"VP_EDIT_DELETE_ROW_RPC"}).then(o=>o!=null&&o.error?o.error:!0)}};k=new WeakMap,Ro=new WeakMap,pr=new WeakMap,dr=new WeakMap,kt=new WeakMap,Ve=new WeakMap,hr=new WeakMap,Ot=new WeakMap,$=new WeakMap,ut=new WeakMap;import{buildColumnMap as vM,isValidNumber as wM,shallowEquals as SM}from"@vuu-ui/vuu-utils";import{jsx as xM,jsxs as TM}from"react/jsx-runtime";import{logger as om}from"@vuu-ui/vuu-utils";import qL from"classnames";import{useCallback as XL,useEffect as ZL,useRef as YL}from"react";import{Button as kM}from"@salt-ds/core";import VM from"classnames";import{useCallback as NM,useMemo as _M}from"react";import{jsx as $M,jsxs as WM}from"react/jsx-runtime";import{useMemo as ZM}from"react";import eL from"classnames";import{jsx as oL}from"react/jsx-runtime";import{jsx as hL,jsxs as fL}from"react/jsx-runtime";import{useCallback as wL,useRef as SL,useState as CL}from"react";import{jsx as xL,jsxs as TL}from"react/jsx-runtime";import{ContextMenuProvider as aD,useDialog as lD}from"@vuu-ui/vuu-popups";import{jsx as dD,jsxs as hD}from"react/jsx-runtime";var{error:cD}=om("Shell");import{createContext as sm,useContext as vD}from"react";import{jsx as CD}from"react/jsx-runtime";var im={},wD=sm(im);import PD from"classnames";import{ToggleButton as LD,ToggleButtonGroup as DD,useControlled as ID}from"@salt-ds/core";import{useCallback as AD}from"react";import{jsx as BD,jsxs as FD}from"react/jsx-runtime";import{useCallback as Ol,useMemo as am}from"react";import{jsx as lm}from"react/jsx-runtime";var nm=r=>{let{saveLayout:e}=no(),t=Ol(()=>{r(void 0)},[r]),o=Ol(i=>{e(i),r(void 0)},[e,r]),[n,s]=am(()=>[(i,a)=>{let l=i.split(" "),u=[];return l.includes("main-tab")&&u.push({label:"Save Layout",action:"save-layout",options:a},{label:"Layout Settings",action:"layout-settings",options:a}),u},i=>{var a,l;return console.log("menu action",{action:i}),i.menuId==="save-layout"?(r({content:lm(ka,{onCancel:t,onSave:o,componentId:(a=i.options)==null?void 0:a.controlledComponentId,defaultTitle:(l=i.options)==null?void 0:l.controlledComponentTitle}),title:"Save Layout",hideCloseButton:!0}),!0):!1}],[t,o,r]);return{buildMenuOptions:n,handleMenuAction:s}};import{forwardRef as Rm}from"react";import{isValidNumber as Qe}from"@vuu-ui/vuu-utils";import{useCallback as pm,useEffect as dm,useMemo as hm,useRef as fm,useState as mm}from"react";import{useCallback as um,useEffect as Vl,useRef as cm}from"react";var ct=new Map,Nl=(r,e,t)=>{switch(t){case"height":return e.height;case"clientHeight":return Math.floor(r.clientHeight);case"clientWidth":return Math.floor(r.clientWidth);case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(Math.floor(r.scrollHeight));case"scrollWidth":return Math.ceil(Math.floor(r.scrollWidth));case"width":return e.width;default:return 0}},Al=new ResizeObserver(r=>{for(let e of r){let{target:t,borderBoxSize:o,contentBoxSize:n}=e,s=ct.get(t);if(s){let[{blockSize:i,inlineSize:a}]=o,[{blockSize:l,inlineSize:u}]=n,{onResize:c,measurements:p}=s,d=!1;for(let[h,f]of Object.entries(p)){let b=Nl(t,{height:i,width:a,contentHeight:l,contentWidth:u},h);b!==f&&(d=!0,p[h]=b)}d&&c&&c(p)}}});function _l(r,e,t,o=!1){let n=cm(e),s=um(i=>{let{width:a,height:l}=i.getBoundingClientRect(),{clientWidth:u,clientHeight:c}=i,p=Math.floor(l),d=Math.floor(a);return n.current.reduce((h,f)=>(h[f]=Nl(i,{width:d,height:p,contentHeight:c,contentWidth:u},f),h),{})},[]);Vl(()=>{let i=r.current;async function a(){ct.set(i,{measurements:{}});let l=ct.get(i);if(l){let u=s(i);l.measurements=u,Al.observe(i),o&&t(u)}else console.log("%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation","font-weight:bold; color:red;")}return i&&(ct.has(i)&&console.log("useResizeObserver attemping to observe same element twice",{target:i}),a()),()=>{i&&ct.has(i)&&(Al.unobserve(i),ct.delete(i))}},[s,r]),Vl(()=>{let i=r.current,a=ct.get(i);if(a){if(n.current!==e){n.current=e;let l=s(i);a.measurements=l}a.onResize=t}},[e,s,r,t])}var gm=["clientHeight","clientWidth"],ym=["clientWidth"],bm=["clientHeight"],vm=[],xo=r=>Number.isFinite(r),wm={height:"100%",width:"auto"},Sm=(r,e)=>Qe(r)&&Qe(e)?{height:`${r}px`,width:`${e}px`}:typeof r=="string"||typeof e=="string"?{height:r!=null?r:"100%",width:e!=null?e:"auto"}:wm,Cm=(r,e)=>{if(Qe(r)&&Qe(e))return{height:r,width:e}},Bl=({defaultHeight:r=0,defaultWidth:e=0,height:t,onResize:o,width:n})=>{let s=fm(null),[i,a]=mm({css:Sm(t,n),inner:Cm(t,n),outer:{height:t!=null?t:"100%",width:n!=null?n:"auto"}}),l=typeof t=="number",u=typeof n=="number",c=l&&u?vm:l?ym:u?bm:gm;hm(()=>{a(d=>{let{inner:h,outer:f}=d;if(Qe(t)&&Qe(n)&&h&&f){let{height:b,width:y}=h,{height:g,width:C}=f;if(g!==t||C!==n){let R=Qe(g)?g-b:0,w=Qe(C)?C-y:0;return{...d,outer:{height:t,width:n},inner:{height:t-R,width:n-w}}}}return d})},[t,n]);let p=pm(({clientWidth:d,clientHeight:h})=>{let{css:f,inner:b,outer:y}=i,g=i;l&&xo(d)&&Math.floor(d)!==(b==null?void 0:b.width)?g={css:f,outer:y,inner:{width:Math.floor(d)||e,height:t}}:u&&xo(h)&&Math.floor(h)!==(b==null?void 0:b.height)?g={css:f,outer:y,inner:{height:Math.floor(h)||r,width:n}}:xo(h)&&xo(d)&&(d!==(b==null?void 0:b.width)||h!==(b==null?void 0:b.height))&&(g={css:f,outer:y,inner:{width:Math.floor(d)||e,height:Math.floor(h)||r}}),g!==i&&a(g)},[r,e,l,u,t,i,n]);return dm(()=>{i.inner&&(o==null||o(i.inner))},[o,i.inner]),_l(s,c,p,!0),{containerRef:s,cssSize:i.css,outerSize:i.outer,innerSize:i.inner}};import{useForkRef as xm}from"@salt-ds/core";import Fl from"classnames";import{jsx as zl}from"react/jsx-runtime";var Xn="vuuMeasuredContainer",_I=Rm(function({children:e,className:t,height:o,onResize:n,style:s,width:i,...a},l){let{containerRef:u,...c}=Bl({height:o,onResize:n,width:i}),{cssSize:p,innerSize:d}=c,h=d===void 0,f=()=>h?{"--measured-css-height":`${p.height}`,"--measured-css-width":`${p.width}`}:{...s,"--measured-css-height":`${p.height}`,"--measured-css-width":`${p.width}`,"--measured-px-height":`${d==null?void 0:d.height}px`,"--measured-px-width":`${d==null?void 0:d.width}px`},b=xm(u,l);return h?zl("div",{...a,className:Fl(Xn,`${Xn}-ummeasured`),style:f(),ref:u}):zl("div",{...a,className:Fl(Xn,t),ref:b,style:f(),children:e})});import{PopupMenu as $m}from"@vuu-ui/vuu-popups";import Po from"classnames";import Wm,{forwardRef as Um}from"react";import{useDragDropNext as Bm}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as Fm,MEASURES as zm}from"@vuu-ui/vuu-utils";import{useCallback as Eo,useMemo as es,useRef as jl,useState as Hm}from"react";import{getElementByDataIndex as Hl}from"@vuu-ui/vuu-utils";var Tm=".vuuOverflowContainer-item:not(.wrapped)",GI=r=>r!==null&&r.dataset.index==="overflow"&&r.parentElement!==null&&r.parentElement.classList.contains("vuuOverflowContainer-wrapContainer-overflowed"),Em=r=>r.sort((e,t)=>{let{dataset:{index:o="?"}}=e,{dataset:{index:n="?"}}=t,s=e.classList.contains("wrapped"),i=t.classList.contains("wrapped"),a=o==="overflow",l=n==="overflow";return s&&!i?1:!s&&i?-1:a?1:l?-1:parseInt(o)>parseInt(n)?1:-1}),Zn=[],fr=(r,e="horizontal")=>{let t=[],o=[],n=-1,s=!1,i=Em(Array.from(r.children)),a=e==="vertical"?"top":"left";for(let l of i){let u=l,{dataset:{index:c="?",label:p="?",overflowPriority:d="0"}}=u,{[a]:h}=u.getBoundingClientRect();h<=n?(c==="overflow"?o.push(t.pop()):o.push({index:c,label:p,overflowPriority:d}),s=!0):s?o.push({index:c,label:p,overflowPriority:d}):t.push({index:c,label:p,overflowPriority:d}),n=h}return[t,o]},$l=(r,e,t)=>{let o=!1,n=t?`${t}-overflowed`:"overflow";e.find(({index:s})=>s==="overflow")&&e.length===1&&(o=!0);for(let s of r.children){let{dataset:{index:i="?"}}=s;e.length===0||o?r.classList.remove(n):r.classList.add(n),i!=="overflow"&&e.find(a=>a.index===i)?s.classList.add("wrapped"):s.classList.remove("wrapped")}},Pm=(r,{overflowPriority:e})=>Math.max(r,parseInt(e)),Mm=(r,{overflowPriority:e})=>Math.min(r,parseInt(e)),Wl=r=>{var e;return r.length>1&&((e=r.at(-1))==null?void 0:e.index)==="overflow"},Lm=r=>{let[e]=r;for(let t=1;t<r.length;t++){let o=r[t];parseInt(o.overflowPriority)>parseInt(e.overflowPriority)&&(e=o)}return e},Ul=(r,e)=>{var n;let t=r.reduce(Mm,Number.MAX_SAFE_INTEGER);return e.reduce(Pm,0)>t?!0:e.length>1&&((n=e.at(-1))==null?void 0:n.index)==="overflow"},Gl=(r,e)=>new Promise(t=>{requestAnimationFrame(()=>{let[,o]=fr(r);km(e,o).forEach(s=>Dm(r,s)),t(o)})}),ql=(r,e,t)=>new Promise(o=>{requestAnimationFrame(()=>{let[,n]=fr(r),s=Lm(n);if(s){let[i,a]=Yn(r,s);o([i,a])}else o([e,t])})}),Dm=(r,e)=>{let t=Hl(r,e.index);if(t)t.classList.add("wrapped");else throw Error(`markElementAsWrapped element item with index ${e.index} not found`)},Im=r=>Array.from(r.querySelectorAll(".wrapped")),km=(r,e)=>{let t=[];for(let o of e)r.find(({index:n})=>n===o.index)||t.push(o);return t},Om=(r,e)=>{Im(r).forEach(o=>{let{dataset:{index:n="?"}}=o;e.find(s=>s.index===n)||o.classList.remove("wrapped")})},Jl=r=>r.querySelector('[data-index="overflow"]'),Vm=r=>r.querySelector(".wrapped"),To=r=>parseInt(getComputedStyle(r).getPropertyValue("width")),Ql=(r,e)=>{let{right:t}=r.getBoundingClientRect(),o=parseInt(getComputedStyle(r).getPropertyValue("padding-right")),{right:n}=e.getBoundingClientRect();return t-o-n},Kl=r=>{let e=Jl(r),t=Ql(r,e),o=To(e),n=Vm(r);return To(n)<=t+o?(r.classList.remove("overflowed"),n.classList.remove("wrapped"),!0):!1},Am=(r,e)=>{let{dataset:{index:t="0",overflowPriority:o="0"}}=r,{dataset:{index:n="0",overflowPriority:s="0"}}=e;return o>s?-1:o<s?1:parseInt(t)-parseInt(n)},Nm=r=>Array.from(r.querySelectorAll(Tm)).sort(Am),Yn=(r,e)=>{let t=Nm(r),o=Hl(r,e.index,!0),n=-1,s=t.at(n),i=To(s),a=To(o),l=Jl(r),u=Ql(r,l)+i;if(u>=a)_m(o,s);else{let{left:d}=s.getBoundingClientRect(),h=u,f=[s];for(;u<a;){n-=1,s=t.at(n),f.push(s);let{left:b}=s.getBoundingClientRect(),y=d-b;u=h+y}o==null||o.classList.remove("wrapped"),f.forEach(b=>{b.classList.add("wrapped")})}let[c,p]=fr(r);return Om(r,p),[c,p]},_m=(r,e)=>{if(!r||!e)throw Error("switchWrapOnElements, element undefined");r.classList.remove("wrapped"),e.classList.add("wrapped")};var Xl=({allowDragDrop:r=!1,itemCount:e,onMoveItem:t,onSwitchWrappedItemIntoView:o,orientation:n="horizontal"})=>{let[s,i]=Hm(null),a=jl(Zn),l=jl(null),u=Eo(R=>{var w;l.current&&((w=l.current.querySelector(".vuuOverflowContainer-OverflowIndicator button"))==null||w.setAttribute("tabindex",R))},[]),c=Eo(async()=>{if(s){let[R,w]=fr(s,n);for($l(s,w,"vuuOverflowContainer-wrapContainer"),Wl(w)&&(w=await Gl(s,w));Ul(R,w);)[R,w]=await ql(s,R,w);w.length===1&&Kl(s)&&(w=Zn),a.current.length===0&&w.length>0?u("0"):a.current.length>0&&w.length===0&&u("-1"),a.current=w}},[s,n,u]),p=R=>typeof R=="object"&&R!==null&&"overflowItem"in R,[d,h]=es(()=>[()=>{let{current:R}=a;return R.map(w=>({label:w.label,action:`activate-item-${w.index}`,options:{overflowItem:w}}))},({options:R})=>{if(s&&p(R)){let[,w]=Yn(s,R.overflowItem);a.current=w,o==null||o(R.overflowItem)}return!0}],[s,o]),f=es(()=>{let{sizeProp:R}=zm[n],w=0;return new ResizeObserver(x=>{for(let v of x){let{[R]:S}=v.contentRect,E=Math.round(S);Fm(E)&&w!==E&&(w=E,c())}})},[c,n]);Ls(()=>{c()},[c,e]),es(()=>{s&&f.observe(s)},[s,f]);let b=Eo(R=>{i(l.current=R)},[]),y=Eo((R,w)=>{t==null||t(R,w)},[t]),{onMouseDown:g,...C}=Bm({allowDragDrop:r,containerRef:l,draggableClassName:"vuuOverflowContainer",onDrop:y,orientation:"horizontal",itemQuery:".vuuOverflowContainer-item"});return{menuActionHandler:h,menuBuilder:d,onItemMouseDown:g,rootRef:b,...C}};import{jsx as mr,jsxs as Gm}from"react/jsx-runtime";var Vt="vuuOverflowContainer",Zl=Wm.memo(({PopupMenuProps:r,allowDragDrop:e,children:t,className:o,height:n,id:s,onMoveItem:i,onSwitchWrappedItemIntoView:a,orientation:l="horizontal",overflowIcon:u,overflowPosition:c="end"})=>{let p=pt(t),{draggable:d,draggedItemIndex:h,menuActionHandler:f,menuBuilder:b,onItemMouseDown:y,rootRef:g}=Xl({allowDragDrop:e,itemCount:p.length,onMoveItem:i,onSwitchWrappedItemIntoView:a,orientation:l}),R={"--overflow-container-height":`${l==="vertical"?"100%":`${n}px`}`},w=Po(`${Vt}-wrapContainer`,o,{[`${Vt}-horizontal`]:l==="horizontal",[`${Vt}-vertical`]:l==="vertical"}),x=p.map((S,E)=>{let{"data-align":M,"data-overflow-priority":P="0",id:T=`${s}-${E}`,label:D=`Item ${E+1}`}=S.props;return mr("div",{className:Po(`${Vt}-item`,{"vuuDraggable-dragAway":h===E}),"data-index":E,"data-align":M,"data-label":D,"data-overflow-priority":P,id:`${T}-wrapper`,onMouseDown:y,children:S},E)}),v=mr("div",{className:`${Vt}-OverflowIndicator`,"data-index":"overflow",children:mr($m,{...r,icon:u,menuBuilder:b,menuActionHandler:f,tabIndex:-1})},"overflow");return x.push(v),Gm("div",{className:w,ref:g,style:R,children:[x,d]})});Zl.displayName="OverflowContainer.InnerContainer";var Yl=Um(function({PopupMenuProps:e,allowDragDrop:t=!1,children:o,className:n,height:s=44,id:i,onMoveItem:a,onSwitchWrappedItemIntoView:l,orientation:u,overflowIcon:c,overflowPosition:p,...d},h){let f=dt(i);return mr("div",{...d,className:Po(Po(n,Vt)),id:f,ref:h,children:mr(Zl,{PopupMenuProps:e,allowDragDrop:t,height:s,id:f,orientation:u,overflowIcon:c,overflowPosition:p,onMoveItem:a,onSwitchWrappedItemIntoView:l,children:o})})});import{uuid as qm}from"@vuu-ui/vuu-utils";import{List as Jm,ListItem as Qm}from"@vuu-ui/vuu-ui-controls";import eu from"classnames";import{cloneElement as Km,memo as jm}from"react";import{jsx as ts}from"react/jsx-runtime";var Xm=r=>{let e=r.cloneNode(!0);return e.id="",delete e.dataset.idx,e},Cn=jm(({className:r,children:e,idx:t,resizeable:o,header:n,closeable:s,...i})=>ts(Qm,{className:eu("vuuPaletteItem",r),"data-draggable":!0,"data-icon":"draggable",...i}));Cn.displayName="PaletteItem";var Va=({ListProps:r,ViewProps:e,children:t,className:o,itemHeight:n=41,orientation:s="horizontal",...i})=>{let a=me(),l="vuuPalette";function u(c){var P,T;let d=c.target.closest(".vuuPaletteItem"),h=parseInt((T=(P=d.dataset)==null?void 0:P.index)!=null?T:"-1"),{props:{caption:f,children:b,template:y,...g}}=t[h],{ViewProps:C}=b.props,{height:R,left:w,top:x,width:v}=d.getBoundingClientRect(),S=qm(),M=y?b:ts(Fe,{...e,...{id:S,key:S},...g,...C,title:g.label,children:b});a({dragRect:{left:w,top:x,right:w+v,bottom:x+150,width:v,height:R},dragElement:Xm(d),evt:c.nativeEvent,instructions:{DoNotRemove:!0,DoNotTransform:!0,DriftHomeIfNoDropTarget:!0,RemoveDraggableOnDragEnd:!0,dragThreshold:10},path:"*",payload:M,type:"drag-start"})}return ts(Jm,{...r,...i,className:eu(l,o,`${l}-${s}`),itemHeight:n,selected:null,children:t.map((c,p)=>c.type===Cn?Km(c,{key:p,onMouseDown:u}):c)})};G("Palette",Va,"view");import{Tab as Zm,Tabstrip as Ym}from"@vuu-ui/vuu-ui-controls";import tu from"classnames";import ns,{forwardRef as eg,useCallback as tg,useRef as rg}from"react";import{jsx as os,jsxs as ig}from"react/jsx-runtime";var rs="Tabs",og=()=>{},ng=r=>{let e=[];return ns.Children.forEach(r,t=>{ns.isValidElement(t)?e.push(t):console.warn("Stack has unexpected child element type")}),e},sg={allowAddTab:!1,allowCloseTab:!1,allowRenameTab:!1},so=eg(function({TabstripProps:e=sg,active:t=0,children:o,className:n,getTabIcon:s=og,getTabLabel:i=bt,id:a,keyBoardActivation:l="manual",onAddTab:u,onMoveTab:c,onTabClose:p,onTabEdit:d,onTabSelectionChanged:h,showTabs:f="top",style:b},y){var D;let g=dt(a),C=rg([]),{allowCloseTab:R,allowRenameTab:w,className:x}=e,v=tg((V,_,F,z)=>{d==null||d(z,_)},[d]),S=()=>{var V;return ns.isValidElement(o)?o:Array.isArray(o)&&(V=o[t])!=null?V:null},E=()=>ng(o).map((V,_)=>{let{closeable:F=R,id:z=`${g}-${_}`,"data-tab-location":ee}=V.props,q=i(V,_,C.current);return C.current.push(q),os(Zm,{ariaControls:z,"data-icon":s(V,_),id:`${z}-tab`,index:_,label:q,location:ee,closeable:F,editable:w},z)}),M=S(),P=f==="left"||f==="right",T=P?"vertical":"horizontal";return ig("div",{className:tu(rs,n,{[`${rs}-horizontal`]:P}),style:b,id:g,ref:y,children:[f?os(Ym,{...e,activeTabIndex:(D=e==null?void 0:e.activeTabIndex)!=null?D:M===null?-1:t,allowDragDrop:e.allowDragDrop!==!1,animateSelectionThumb:!0,className:tu("vuuTabHeader",x),keyBoardActivation:l,onActiveChange:h,onAddTab:u,onCloseTab:p,onExitEditMode:v,onMoveTab:c,orientation:T,children:E()}):null,os("div",{"aria-labelledby":`${g}-${t}`,className:`${rs}-tabPanel`,role:"tabpanel",children:M})]})});so.displayName="Stack";import{useIdMemo as ag}from"@salt-ds/core";import lg,{useCallback as ss,useRef as ug}from"react";import{jsx as ou}from"react/jsx-runtime";var cg=()=>ou(ft,{resizeable:!0,style:{flexGrow:1,flexShrink:0,flexBasis:0}}),ru=r=>{var x;let e=ug(null),t=me(),{loadState:o}=yt(),{createNewChild:n,id:s,onTabSelectionChanged:i,path:a,...l}=r,{children:u}=r,c=ag(s),[p]=Qr(c,e,a),d=Ki(),h=(x=n!=null?n:d)!=null?x:cg,f=v=>{a&&(t({type:"switch-tab",id:c,path:a,nextIdx:v}),i==null||i(v))},b=ss(v=>{if(Array.isArray(u)){let{props:{"data-path":S,path:E=S}}=u[v];t({type:"remove",path:E})}},[u,t]),y=ss(()=>{if(a){let v=lg.Children.count(u),S=h(v);t({type:"add",path:a,component:S})}},[u,h,t,a]),g=ss((v,S)=>{a&&t({fromIndex:v,toIndex:S,path:a,type:"move-child"})},[t,a]);return ou(so,{...l,id:c,getTabLabel:(v,S,E)=>{let{id:M,title:P}=v.props;return o(M,"view-title")||P||bt(v,S,E)},onMouseDown:async(v,S)=>{let E;await p({type:"mousedown",index:S,preDragActivity:async()=>new Promise(T=>{console.log("preDragActivity: Ok, gonna release the drag"),E=T})},v)&&(E==null||E(void 0))},onMoveTab:g,onAddTab:y,onTabClose:b,onTabEdit:(v,S)=>{t({type:"set-title",path:`${a}.${v}`,title:S})},onTabSelectionChanged:f,ref:e})};ru.displayName="Stack";G("Stack",ru,"container");import bu from"classnames";import Vg,{useMemo as Ag,useRef as Ng}from"react";import{isValidNumber as kg}from"@vuu-ui/vuu-utils";import{useCallback as as,useRef as Og}from"react";import{useControlled as hg}from"@salt-ds/core";import{dispatchMouseEvent as fg,getClosest as mg,getElementDataIndex as gg,getFocusableElement as yg}from"@vuu-ui/vuu-utils";import{useCallback as ve,useRef as is,useState as bg}from"react";import{ArrowDown as uu,ArrowUp as vg,ArrowLeft as wg,ArrowRight as Sg,Home as su,End as iu}from"@vuu-ui/vuu-utils";import{getElementDataIndex as pg}from"@vuu-ui/vuu-utils";var dg=(r,e)=>{if(r){let t=r.querySelector(`[data-index]:has(${e})`);return pg(t)}return-1};var nu=r=>dg(r,".vuuEditableLabel-editing");var cu={horizontal:{[su]:"start",[iu]:"end",[wg]:"bwd",[Sg]:"fwd"},vertical:{[su]:"start",[iu]:"end",[vg]:"bwd",[uu]:"fwd"}},pu=r=>r!==null&&r.dataset.index==="overflow",Cg=(r,e,t,o,n)=>{if(r){let s=e==="bwd"&&o>0,i=e==="fwd"&&o<t,a=s||i,l=gr(r,o,!0),u=n&&!lu(l),c=!n&&pu(l);return n&&lu(l),a&&(u||c)}else return!1},Rg=(r,e="horizontal")=>cu[e][r]!==void 0,xg=r=>r===uu;function au(r,e,t){return e==="start"?0:e==="end"?r-1:e==="bwd"?t>0?t-1:t:t===null?0:t===r-1?t:t+1}var lu=r=>r!==null&&!r.classList.contains("wrapped"),du=r=>Array.from(r.querySelectorAll("[data-index]")),Tg=r=>r===null?-1:du(r).map(o=>o.dataset.index).indexOf("overflow"),gr=(r,e,t=!1)=>{if(r!==null){let n=du(r)[e];return!t&&pu(n)?null:n}return null},hu=({containerRef:r,defaultHighlightedIdx:e=-1,highlightedIdx:t,onNavigateOutOfBounds:o,orientation:n})=>{let s=is(!1),i=is(-1),[a,l]=bg(!1),[u,c]=hg({controlled:t,default:e,name:"UseKeyboardNavigation"}),p=ve(T=>{c(i.current=T)},[c]),d=is(!1),h=ve((T,D=!1,V,_=70)=>{console.log(`focus item ${T}`),p(T),V===!0&&!d.current&&(d.current=!0);let F=()=>{let z=gr(r.current,T,!0);if(z){let ee=yg(z);ee==null||ee.focus()}};D?F():setTimeout(F,_)},[r,p]),f=T=>{if(i.current===-1){if(T.target.tabIndex===0){let D=gg(mg(T.target,"index"));p(D)}else if(T.target.tabIndex!==-1){let D=nu(r.current);D!==-1&&requestAnimationFrame(()=>{p(D)})}}},b=ve(()=>{var T,D;return(D=(T=r.current)==null?void 0:T.querySelectorAll("[data-index]").length)!=null?D:0},[r]),y=ve((T="fwd",D)=>{var q;let V=b(),_=typeof D=="number"?D:V,F=au(V,T,_),z=T==="start"?"fwd":T==="end"?"bwd":T,ee=((q=r.current)==null?void 0:q.querySelector(".vuuOverflowContainer-wrapContainer-overflowed"))!=null;for(;Cg(r.current,z,V,F,ee);){let K=au(V,z,F);if(K===F)return _;F=K}return F},[r,b]),g=ve(T=>{let D=cu[n][T.key],V=y(D,u);console.log(`highlightedIdx = ${u}, nextIdx = ${V} `),V!==u?h(V,!0):o==null||o(D==="bwd"?"start":"end")},[n,y,u,h,o]),C=ve(()=>{let T=gr(r.current,u);return T?T.querySelector(".vuuPopupMenu")!=null:!1},[r,u]),R=ve(()=>{let T=gr(r.current,u);return T?T.querySelector(".vuuEditableLabel-input")!=null:!1},[r,u]),w=ve(()=>{let T=gr(r.current,u),D=T==null?void 0:T.querySelector(".vuuPopupMenu");return D&&fg(D,"click"),!1},[r,u]),x=ve(T=>{b()>0&&Rg(T.key,n)?(T.preventDefault(),d.current||(d.current=!0),g(T)):xg(T.key)&&C()&&!R()&&w()},[w,b,C,R,g,n]),v=(T,D)=>{p(D)},S=ve(()=>{a||(l(!0),s.current?s.current=!1:d.current=!0)},[a]),E=ve(()=>{a||(s.current=!0),d.current=!1},[a]),M=ve(T=>{if((T==null?void 0:T.type)==="escape"){let D=Tg(r.current);D!==-1&&h(D)}},[r,h]);return{containerProps:{onBlur:T=>{let D=T.target.closest(".vuuToolbar"),V=T.relatedTarget;D&&!(D!=null&&D.contains(V))&&(p(-1),l(!1))},onMouseDownCapture:E,onFocus:S,onMouseLeave:()=>{d.current=!0,p(-1),s.current=!1}},focusVisible:d.current?u:-1,focusIsWithinComponent:a,highlightedIdx:u,focusableIdx:0,focusItem:h,onClick:v,onFocus:f,onKeyDown:x,onOverflowMenuClose:M,setHighlightedIdx:p}};import{isSelectableElement as fu,getClosestIndexItem as Eg}from"@vuu-ui/vuu-utils";import{allowMultipleSelection as Pg,deselectionIsAllowed as mu,selectionIsDisallowed as Mg,useControlled as Lg}from"@vuu-ui/vuu-ui-controls";import{useCallback as yr}from"react";var Dg=["Enter"," "],Ig={},gu=({containerRef:r,defaultSelected:e,highlightedIdx:t,itemQuery:o,onSelectionChange:n,selected:s,selectionStrategy:i})=>{let[a,l,u]=Lg({controlled:s,default:e!=null?e:[],name:"useSelection",state:"selected"}),c=yr(y=>Dg.includes(y.key),[]),p=yr((y,g=!1)=>{let C=Pg(i,g)?a.concat(y):[y];l(C),n==null||n(C)},[n,a,i,l]),d=yr((y,g=!1)=>{let C=i==="deselectable"||i==="multiple-special-key"&&!g?[]:a.filter(R=>R!==y);l(C),n==null||n(C)},[n,a,i,l]),h=yr(y=>{c(y)&&fu(y.target)&&(a.includes(t)?mu(i)&&(y.stopPropagation(),y.preventDefault(),d(t,y.shiftKey)):(y.stopPropagation(),y.preventDefault(),p(t,y.shiftKey)))},[c,a,t,i,p,d]),f=yr((y,g)=>{let C=Eg(y.target);fu(C)&&(a.includes(g)?mu(i)&&d(g,y.shiftKey):p(g,y.shiftKey))},[d,p,a,i]),b=Mg(i)?Ig:{onClick:f,onKeyDown:h};return{activateItem:p,itemHandlers:b,isControlled:u,selected:a}};var yu=({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:t,itemQuery:o="vuuToolbarItem",onActiveChange:n,onNavigateOutOfBounds:s,orientation:i,selectionStrategy:a})=>{let l=Og(r),{focusItem:u,highlightedIdx:c,onClick:p,onKeyDown:d,setHighlightedIdx:h,...f}=hu({containerRef:t,onNavigateOutOfBounds:s,orientation:i}),{activateItem:b,itemHandlers:{onClick:y,onKeyDown:g},selected:C}=gu({containerRef:t,defaultSelected:e,highlightedIdx:c,itemQuery:o,onSelectionChange:n,selected:r,selectionStrategy:a});l.current=C;let R=as(S=>{var P;let M=S.target.closest("[data-index]");if(M){let T=parseInt((P=M.dataset.index)!=null?P:"-1");T!==-1&&kg(T)&&(p(S,T),y==null||y(S,T))}},[p,y]),w=as(S=>{d(S),S.defaultPrevented||g==null||g(S)},[d,g]),x=as(S=>{let E=parseInt(S.index);isNaN(E)||(b(E),u(E))},[u,b]),v={onClick:R,onFocus:f.onFocus,onKeyDown:w};return{activeItemIndex:C,focusableIdx:f.focusableIdx,focusVisible:f.focusVisible,containerProps:{PopupMenuProps:{onKeyDown:w,onMenuClose:f.onOverflowMenuClose},...f.containerProps,onSwitchWrappedItemIntoView:x},itemProps:v}};import{forwardCallbackProps as _g}from"@vuu-ui/vuu-ui-controls";import{jsx as Bg}from"react/jsx-runtime";var br="vuuToolbar",Qd=({activeItemIndex:r,alignItems:e="start",defaultActiveItemIndex:t,children:o,className:n,id:s,onActiveChange:i,onNavigateOutOfBounds:a,orientation:l="horizontal",selectionStrategy:u="none",showSeparators:c=!1,...p})=>{let d=Ng(null),{activeItemIndex:h,focusableIdx:f,focusVisible:b,itemProps:y,...g}=yu({activeItemIndex:r,defaultActiveItemIndex:t,containerRef:d,onActiveChange:i,onNavigateOutOfBounds:a,orientation:l,selectionStrategy:u}),C=dt(s),R=Ag(()=>pt(o).map((w,x)=>{let{id:v=`${C}-tab-${x}`,className:S,...E}=w.props,M=h.includes(x);return Vg.cloneElement(w,{..._g(E,y),className:bu("vuuToolbarItem",S),"data-overflow-priority":M?"1":void 0,id:v,key:x,"aria-selected":M,tabIndex:f===x?0:-1})}),[h,o,f,C,y]);return Bg(Yl,{...p,...g.containerProps,className:bu(n,br,`${br}-${l}`,{[`${br}-alignCenter`]:e==="center",[`${br}-alignEnd`]:e==="end",[`${br}-withSeparators`]:c}),...p,ref:d,children:R})};import vu,{useState as wu}from"react";import{jsx as ls,jsxs as Su}from"react/jsx-runtime";var h2=({children:r})=>{let[t,o]=wu(r),[n,s]=wu(r),i=l=>{let u=Es(t,l);s(u)},a=(l,u)=>{console.log(`change ${l} -> ${u}`);let c=vu.cloneElement(n,{style:{...n.props.style,[l]:u}});s(c),o(vu.cloneElement(t,{},c))};return Su("div",{"data-design-mode":`${!1}`,children:[t,ls("br",{}),Su("div",{style:{display:"flex"},children:[ls(Cu,{height:300,managedStyle:n.props.style,width:300,onChange:a,style:void 0}),ls(Ru,{layout:t,onSelect:i,style:{width:300,height:300,backgroundColor:"#ccc"}})]})]})};import{FormField as Mo,Input as Lo}from"@salt-ds/core";import{jsx as Y,jsxs as cs}from"react/jsx-runtime";var ps={},Fg={margin:{top:"marginTop",right:"marginRight",bottom:"marginBottom",left:"marginLeft"},border:{top:"borderTopWidth",right:"borderRightWidth",bottom:"borderBottomWidth",left:"borderLeftWidth"},padding:{top:"paddingTop",right:"paddingRight",bottom:"paddingBottom",left:"paddingLeft"}},us=({feature:r,children:e,style:t,onChange:o})=>cs("div",{className:`LayoutBox layout-${r} layout-outer`,children:[cs("div",{className:"layout-top",children:[Y("span",{className:"layout-title",children:r}),Y(Mo,{className:"layout-input",style:{width:30},children:Y(Lo,{value:t.top,onChange:(n,s)=>o(r,"top",s)})})]}),cs("div",{className:"layout-inner",children:[Y("div",{className:"layout-left",children:Y(Mo,{className:"layout-input",style:{width:30},children:Y(Lo,{value:t.left,onChange:(n,s)=>o(r,"left",s)})})}),e,Y("div",{className:"layout-right",children:Y(Mo,{className:"layout-input",style:{width:30},children:Y(Lo,{value:t.right,onChange:(n,s)=>o(r,"right",s)})})})]}),Y("div",{className:"layout-bottom",children:Y(Mo,{className:"layout-input",style:{width:30},children:Y(Lo,{value:t.bottom,onChange:(n,s)=>o(r,"bottom",s)})})})]}),C2={margin:!0,marginTop:!0,marginRight:!0,marginBottom:!0,marginLeft:!0},R2={padding:!0,paddingTop:!0,paddingRight:!0,paddingBottom:!0,paddingLeft:!0},x2={border:!0,borderColor:!0,borderWidth:!0,borderTopWidth:!0,borderRightWidth:!0,borderBottomWidth:!0,borderLeftWidth:!0},Do="(\\d+)(?:px)?",zg=`^(?:${Do}(?:\\s${Do}(?:\\s${Do}(?:\\s${Do})?)?)?)$`,xu=new RegExp(zg),Hg=/^(?:(\d+)(?:px)\ssolid\s([a-zA-Z,0-9().]+))$/,Cu=({height:r,managedStyle:e,onChange:t,style:o,width:n})=>{let s=Tu(e),i=(R,w,x)=>{let v=parseInt(x||"0",10),S=Fg[R][w];t(S,v)},{marginTop:a=0,marginRight:l=0,marginBottom:u=0,marginLeft:c=0}=s,{borderTopWidth:p=0,borderRightWidth:d=0,borderBottomWidth:h=0,borderLeftWidth:f=0}=s,{paddingTop:b=0,paddingRight:y=0,paddingBottom:g=0,paddingLeft:C=0}=s;return Y("div",{className:"LayoutConfigurator",style:{width:n,height:r,...o},children:Y(us,{feature:"margin",style:{top:a,right:l,bottom:u,left:c},onChange:i,children:Y(us,{feature:"border",style:{top:p,right:d,bottom:h,left:f},onChange:i,children:Y(us,{feature:"padding",style:{top:b,right:y,bottom:g,left:C},onChange:i,children:Y("div",{className:"layout-content"})})})})})};function T2(r=ps,e=ps){let{margin:t,marginTop:o,marginRight:n,marginBottom:s,marginLeft:i,padding:a,paddingTop:l,paddingRight:u,paddingBottom:c,paddingLeft:p,...d}=r;if(typeof t=="number")d.marginTop=d.marginRight=d.marginBottom=d.marginLeft=t;else if(typeof t=="string"){let h=xu.exec(t);if(h===null)console.error(`Invalid css value for margin '${t}'`);else{let[,f,b,y,g]=h,C=f&&b&&y;C&&g?(d.marginTop=parseInt(f,10),d.marginRight=parseInt(b,10),d.marginBottom=parseInt(y,10),d.marginLeft=parseInt(g,10)):C?(d.marginTop=parseInt(f,10),d.marginRight=d.marginLeft=parseInt(b,10),d.marginBottom=parseInt(y,10)):f&&b?(d.marginTop=d.marginBottom=parseInt(f,10),d.marginRight=d.marginLeft=parseInt(b,10)):d.marginTop=d.marginRight=d.marginBottom=d.marginLeft=parseInt(f,10)}}if(typeof o=="number"&&(d.marginTop=o),typeof n=="number"&&(d.marginRight=n),typeof s=="number"&&(d.marginBottom=s),typeof i=="number"&&(d.marginLeft=i),typeof a=="number")d.paddingTop=d.paddingRight=d.paddingBottom=d.paddingLeft=a;else if(typeof a=="string"){let h=xu.exec(a);if(h===null)console.error(`Invalid css value for padding '${a}'`);else{let[,f,b,y,g]=h,C=f&&b&&y;C&&g?(d.paddingTop=parseInt(f,10),d.paddingRight=parseInt(b,10),d.paddingBottom=parseInt(y,10),d.paddingLeft=parseInt(g,10)):C?(d.paddingTop=parseInt(f,10),d.paddingRight=d.paddingLeft=parseInt(b,10),d.paddingBottom=parseInt(y,10)):f&&b?(d.paddingTop=d.paddingBottom=parseInt(f,10),d.paddingRight=d.paddingLeft=parseInt(b,10)):d.paddingTop=d.paddingRight=d.paddingBottom=d.paddinggLeft=parseInt(f,10)}}return typeof l=="number"&&(d.paddingTop=l),typeof u=="number"&&(d.paddingRight=u),typeof c=="number"&&(d.paddingBottom=c),typeof p=="number"&&(d.paddingLeft=p),Tu(d,e)}function Tu(r=ps){let e={...r},t,{border:o,borderWidth:n,borderTopWidth:s,borderRightWidth:i,borderBottomWidth:a,borderLeftWidth:l,borderColor:u,margin:c,marginTop:p,marginRight:d,marginBottom:h,marginLeft:f,padding:b,paddingTop:y,paddingRight:g,paddingBottom:C,paddingLeft:R,...w}=e,x={},v={};if(typeof c=="number"&&(e.marginTop=e.marginRight=e.marginBottom=e.marginLeft=c,x={marginTop:c,marginRight:c,marginBottom:c,marginLeft:c}),typeof b=="number"&&(e.paddingTop=e.paddingRight=e.paddingBottom=e.paddingLeft=b,v={paddingTop:b,paddingRight:b,paddingBottom:b,paddingLeft:b}),o||n||s||i||a||l){typeof o=="string"&&(t=Hg.exec(o))&&([,n,u]=t,n=parseInt(n,10)),n&&(s=s===void 0?n:s,i=i===void 0?n:i,a=a===void 0?n:a,l=l===void 0?n:l),u=u||"black";let S=`
|
|
20
|
+
${u} ${l||0}px ${s||0}px 0 0 inset,
|
|
21
|
+
${u} ${-i||0}px ${-a||0}px 0 0 inset`;return{...w,...x,...v,borderTopWidth:s,borderRightWidth:i,borderBottomWidth:a,borderLeftWidth:l,borderColor:u,borderStyle:"solid",boxShadow:S}}else return e}import $g from"react";import Wg from"classnames";import{Tree as Ug}from"@vuu-ui/vuu-ui-controls";import{jsx as Eu}from"react/jsx-runtime";var Gg="hwLayoutTreeViewer",Pu=(r,e="0")=>({label:O(r),path:e,childNodes:$g.Children.map(r.props.children,(t,o)=>Pu(t,e?`${e}.${o}`:`${o}`))}),Ru=({layout:r,onSelect:e,style:t})=>{let o=[Pu(r)],n=(s,[{path:i}])=>{e(i)};return Eu("div",{className:Wg(Gg),style:t,children:Eu(Ug,{source:o,groupSelection:"single",onSelectionChange:n})})};export{mt as Action,x2 as BORDER_STYLES,$u as Component,je as ComponentRegistry,h2 as ConfigWrapper,Ss as DockLayout,Jo as Draggable,zt as DraggableLayout,wr as Drawer,Fs as DropMenu,_e as DropTarget,qt as Flexbox,Xi as FlexboxLayout,fn as FluidGrid,la as FluidGridLayout,ba as Header,RC as HeightOnly,X as LayoutActionType,Cu as LayoutConfigurator,Zp as LayoutProvider,Xt as LayoutProviderContext,lC as LayoutProviderVersion,Ru as LayoutTreeViewer,wn as LocalLayoutPersistenceManager,C2 as MARGIN_STYLES,_I as MeasuredContainer,Zn as NO_WRAPPED_ITEMS,Yl as OverflowContainer,R2 as PADDING_STYLES,Va as Palette,Cn as PaletteItem,ft as Placeholder,Ta as RemoteLayoutPersistenceManager,so as Stack,ru as StackLayout,Qd as Toolbar,Fe as View,Kr as ViewContext,ea as WidthHeight,xC as WidthOnly,T2 as XXXnormalizeStyles,hw as applyLayout,Qt as applyLayoutProps,$l as applyOverflowClassToWrappedItems,pt as asReactElements,Ci as componentToJson,Bs as computeMenuPosition,qu as containerOf,ql as correctForWrappedHighPriorityItems,Gl as correctForWrappedOverflowIndicator,Zo as createFlexbox,Re as createPlaceHolder,jr as defaultApplicationJson,No as expandFlex,OC as extractResponsiveProps,De as findTarget,J as followPath,Es as followPathToComponent,we as followPathToParent,Ju as getChild,Cs as getChildProp,bt as getDefaultTabLabel,Im as getElementsMarkedAsWrapped,ai as getFlexDimensions,Xo as getFlexOrIntrinsicStyle,jo as getFlexStyle,he as getIntrinsicSize,wi as getManagedDimension,fr as getNonWrappedAndWrappedItems,gi as getPersistentState,A as getProp,I as getProps,yi as hasPersistentState,li as hasUnboundedFlexStyle,Ul as highPriorityItemsHaveWrappedButShouldNotHave,Ho as identifyDropTarget,_w as isApplicationLevelChange,re as isContainer,ms as isLayoutComponent,Bw as isLayoutLevelChange,GI as isOverflowElement,pd as isResponsiveAttribute,ab as isTabstrip,Ey as isTypeOf,Iu as isView,He as layoutFromJson,Ri as layoutQuery,Wi as layoutReducer,Si as layoutToJSON,Sa as loadingApplicationJson,Dm as markElementAsWrapped,Oy as nextLeaf,Se as nextStep,Wl as overflowIndicatorHasWrappedButShouldNotHave,Vy as previousLeaf,tn as processLayoutElement,G as registerComponent,Kl as removeOverflowIndicatorIfNoLongerNeeded,j as resetPath,Yi as resizeObserver,Ts as resolveJSONPath,Vo as resolvePath,fp as serializeProps,bi as setPersistentState,Ny as setRef,Em as sortByScreenOrder,Yn as switchWrappedItemIntoView,O as typeOf,Om as unmarkItemsWhichAreNoLongerWrapped,na as useBreakpoints,dt as useId,nm as useLayoutContextMenuItems,Ki as useLayoutCreateNewChild,Ls as useLayoutEffectSkipFirst,me as useLayoutProviderDispatch,Yp as useLayoutProviderVersion,Bl as useMeasuredContainer,yt as usePersistentState,qr as useResizeObserver,Qr as useViewActionDispatcher,ti as useViewContext,ma as useViewDispatch,yx as warningLayout,$t as wrapIntrinsicSizeComponentWithFlexbox};
|
|
240
22
|
//# sourceMappingURL=index.js.map
|