@vuu-ui/vuu-layout 0.8.10 → 0.8.11
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 +224 -4
- package/cjs/index.js.map +4 -4
- package/esm/index.js +224 -4
- package/esm/index.js.map +4 -4
- package/index.css +1 -1
- package/index.css.map +3 -3
- package/package.json +6 -6
- package/types/index.d.ts +1 -0
- package/types/layout-persistence/LayoutPersistenceManager.d.ts +53 -0
- package/types/layout-persistence/LocalLayoutPersistenceManager.d.ts +16 -0
- package/types/layout-persistence/data.d.ts +3 -0
- package/types/layout-persistence/index.d.ts +4 -0
- package/types/layout-persistence/useLayoutContextMenuItems.d.ts +8 -0
- package/types/layout-reducer/layoutTypes.d.ts +2 -1
- package/types/toolbar/Toolbar.d.ts +2 -1
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{partition as Zo}from"@vuu-ui/vuu-utils";import Zs from"classnames";var Wo={},Vo={},ue={};function W(e){return Wo[e]===!0}function _s(e){return Vo[e]===!0}var _o=e=>W(e)||_s(e);function O(e,t,o="component"){ue[e]=t,o==="container"?Wo[e]=!0:o==="view"&&(Vo[e]=!0)}import{Button as Go,useControlled as Gs}from"@salt-ds/core";import Ko from"classnames";import{useCallback as Ks}from"react";import{jsx as De,jsxs as Ys}from"react/jsx-runtime";var re="vuuDrawer",Uo=e=>typeof e=="string"?e:e+"px",Us=(e,t,o)=>{let n=t!==void 0,r=o!==void 0;if(!(!e&&!r&&!n))return!r&&!n?e:{...e,"--drawer-size":n?Uo(t):void 0,"--drawer-peek-size":r?Uo(o):void 0}},Yo=({children:e,className:t,clickToOpen:o,defaultOpen:n,sizeOpen:r,sizeClosed:s,style:i,open:a,position:l="left",inline:c,onClick:u,peekaboo:m=!1,toggleButton:p,...d})=>{let[g,f]=Gs({controlled:a,default:n!=null?n:!1,name:"Drawer",state:"open"}),y=Ko(re,t,`${re}-${l}`,{[`${re}-open`]:g,[`${re}-inline`]:c,[`${re}-over`]:!c,[`${re}-peekaboo`]:m}),h=Ks(()=>{f(!g)},[g,f]),b=Us(i,r,s),v=o?h:u,w=()=>De("div",{className:Ko("vuuToggleButton-container"),children:g?De(Go,{"aria-label":"close",onClick:h,"data-icon":"close",variant:"secondary"}):De(Go,{"aria-label":"open",onClick:h,"data-icon":"close",variant:"secondary"})});return Ys("div",{...d,className:y,onClick:v,style:b,children:[p=="start"?w():null,De("div",{className:`${re}-liner`,children:De("div",{className:`${re}-content`,children:e})}),p=="end"?w():null]})};Yo.displayName="Drawer";var It=Yo;import{jsx as Js,jsxs as Qs}from"react/jsx-runtime";var Xs=e=>e.type===It,js=({props:{position:e="left"}})=>e.match(/top|bottom/),At=e=>{let{children:t,className:o,id:n,style:r}=e,s="vuuDockLayout",[i,a]=Zo(t,Xs),[l,c]=Zo(i,js),u=l.length===0?"horizontal":c.length===0?"vertical":"both",m=Zs(s,o,`${s}-${u}`);return Qs("div",{className:m,id:n,style:r,children:[i,Js("div",{className:`${s}-content`,children:a})]})};At.displayName="DockLayout";var qs=At;O("DockLayout",At,"container");import{forwardRef as ei}from"react";import{jsx as ti}from"react/jsx-runtime";var Ht=ei(function({resizeable:t,...o},n){return ti("div",{...o,className:"Component",ref:n})});Ht.displayName="Component";var kt=Ht;O("Component",Ht);import se,{isValidElement as jo}from"react";var oi={},D=(e,t)=>{var n;let o=T(e);return(n=o[t])!=null?n:o[`data-${t}`]},T=e=>(e==null?void 0:e.props)||e||oi,Xo=e=>{let t=T(e);if(t.children){let{children:[o,...n]}=t;return n.length>0&&console.warn(`getChild expected a single child, found ${n.length+1}`),o}};function L(e){var t;if(e){let o=e.type;if(typeof o=="function"||typeof o=="object"){let n=o.displayName||o.name||((t=o.type)==null?void 0:t.name);if(typeof n=="string")return n}if(typeof e.type=="string")return e.type;if(e.constructor)return e.constructor.displayName;throw Error("typeOf unable to determine type of element")}}var ap=(e,t)=>L(e)===t;var ni=e=>{let t=e.lastIndexOf(".");return t===-1?e:e.slice(0,t)},qo=e=>se.isValidElement(e.props.children)?[e.props.children]:e.props.children,Ot=(e,t="")=>{let[o,...n]=t.split(".");if(o!=null&&o.startsWith("#")){let r=zt(e,o.slice(1),!0);if(r&&n.length)return Ot(r,n.join("."))}else if(o==="ACTIVE_CHILD"){let{active:r}=T(e),s=qo(e),{path:i}=T(s[r]);return i}return""},ri=(e,t="")=>{let[o,...n]=t.split(".");if(o!=null&&o.startsWith("#")){let r=Qo(e,o.slice(1),!0);if(r&&n.length)return ri(r,n.join("."))}else if(o==="ACTIVE_CHILD"){let{children:r,props:s}=e,{active:i}=s;if(typeof i=="number"&&(r!=null&&r[i]))return r[i]}};function te(e,t){let{"data-path":o,path:n=o}=T(e);return t==="0"||t===n?null:z(e,ni(t),!0)}function oe(e,t){let{children:o,...n}=T(e);if(t(n))return e;if(se.Children.count(o)>0){let r=se.isValidElement(o)?[o]:o;for(let s of r){let i=oe(s,t);if(i)return i}}}function si(e,t){if(t===e)return null;let{path:o,children:n}=T(e),{idx:r,finalStep:s}=X(o,D(t,"path"));return s?e:n===void 0||n[r]===void 0?null:si(n[r],t)}var ii=(e,t)=>{if(se.isValidElement(e)&&t==0)return e;if(Array.isArray(e))return e[t]};function Jo(e,t){let o=t.split("."),n=[e];for(let r=0;r<o.length;r++){let s=parseInt(o[r]),i=n[s];if(r===o.length-1)return i;n=qo(i)}}var zt=(e,t,o=!0)=>{let{children:n,id:r}=e.props;if(r===t)return e;if(se.Children.count(n)>0){let s=jo(n)?[n]:n;for(let i of s)if(jo(i)){let a=zt(i,t,!1);if(a)return a}}if(o===!0)throw Error(`pathUtils.findTargetById id #${t} not found in source`)},Qo=(e,t,o=!0)=>{let{children:n,id:r}=e;if(r===t)return e;if(Array.isArray(n)&&n.length>0){for(let s of n)if(s!==null&&typeof s=="object"){let i=Qo(s,t,!1);if(i)return i}}if(o===!0)throw Error(`pathUtils.findTargetJSONById id #${t} not found in source`)};function z(e,t,o=!1){if(t.startsWith("#"))return zt(e,t.slice(1),o);let{"data-path":n,path:r=n}=T(e);if(t.indexOf(r)!==0)throw Error(`pathUtils.followPath path ${t} is not within source path ${r}`);let s=t.slice(r.length+1);if(s==="")return e;let i=e,a=s.split(".");for(let l=0;l<a.length;l++){if(se.Children.count(i.props.children)===0){let c=`element at 0.${a.slice(0,l).join(".")} has no children, so cannot fulfill rest of path ${a.slice(l).join(".")}`;if(o)throw Error(c);console.warn(c);return}if(i=ii(i.props.children,parseInt(a[l])),i===void 0){let c=`model at 0.${a.slice(0,l).join(".")} has no children that fulfill next step of path ${a.slice(l).join(".")}`;if(o)throw Error(c);console.warn(c)}}return i}function fp(e,t){let o=te(e,t),n=t.split(".").map(r=>parseInt(r,10));if(o){let r=n.pop(),{children:s}=o.props;if(s.length-1>r)return je(s[r+1]);{let i=n.pop(),a=te(e,D(o,"path"));if(a&&typeof i=="number"&&(n=a.props.path.split(".").map(l=>parseInt(l,10)),a.props.children.length-1>i)){let l=a.props.children[i+1];return W(L(l))?je(l):l}}}return je(e)}function hp(e,t){let o=t.split(".").map(s=>parseInt(s,10)),n=o.pop(),r=te(e,t);if(r!=null&&typeof n=="number"){let{children:s}=r.props;if(n>0)return qe(s[n-1]);for(;o.length>1;)if(n=o.pop(),r=te(e,D(r,"path")),n>0){let i=r.props.children[n-1];return W(L(i))?qe(i):i}}return qe(e)}function je(e){if(W(L(e))){let{children:t}=e.props||e;return je(t[0])}return e}function qe(e){if(W(L(e))){let{children:t}=e.props||e;return qe(t[t.length-1])}return e}function X(e,t,o=!1){if(e===t)return{idx:-1,finalStep:!0};let n=`${e}.`;if(!t.startsWith(n))throw Error("pathUtils nextStep has strayed from the path");let r=o?0:1,s=t.replace(n,"").split(".").map(i=>parseInt(i,10));return{idx:s[0],finalStep:s.length===r}}function N(e,t,o){if(D(e,"path")===t)return e;let n=[];se.Children.forEach(e.props.children,(s,i)=>{D(s,"path")?n.push(N(s,`${t}.${i}`)):n.push(s)});let r=e.props["data-path"]?"data-path":"path";return se.cloneElement(e,{[r]:t,...o},n)}function yp(e,t){typeof e=="function"?e(t):e&&(e.current=t)}import{Children as ai,isValidElement as en,useLayoutEffect as li,useMemo as ci,useRef as ui}from"react";var pi=[],mi=0,xe=e=>{let t=Array.isArray(e),o=t?e.length:ai.count(e);return t&&e.every(en)?e:o===1&&!t&&en(e)?[e]:o>1?e:pi},tn=(e,t)=>{let o=ui(!1);li(()=>{o.current?e():o.current=!0},t)},Ee=e=>ci(()=>e!=null?e:`vuu-${++mi}`,[e]);var Bt=e=>{if(typeof e!="number")throw Error(`"no support yet for flex value ${e}`);return{flexBasis:0,flexGrow:1,flexShrink:1}};import{boxContainsPoint as Je}from"@vuu-ui/vuu-utils";var me={north:1,east:2,south:4,west:8,header:16,centre:32,absolute:64},Le={AFTER:"after",BEFORE:"before"},K=Object.freeze({North:pe("north"),East:pe("east"),South:pe("south"),West:pe("west"),Header:pe("header"),Centre:pe("centre"),Absolute:pe("absolute")});function pe(e){return Object.freeze({offset:e==="north"||e==="west"?0:e==="south"||e==="east"?1:NaN,valueOf:function(){return me[e]},toString:function(){return e},North:e==="north",South:e==="south",East:e==="east",West:e==="west",Header:e==="header",Centre:e==="centre",NorthOrSouth:e==="north"||e==="south",EastOrWest:e==="east"||e==="west",NorthOrWest:e==="north"||e==="west",SouthOrEast:e==="east"||e==="south",Absolute:e==="absolute"})}var on=K.North,nn=K.South,Nt=K.East,Ft=K.West,di=K.Header,fi=K.Centre,ve=class{static measure(t,o=[]){let n={};return yi(t,n,o),n}static allBoxesContainingPoint(t,o,n,r,s){return ln(t,o,n,r,s).reverse()}};function $t(e,t,o,n=30){let r=o.right-o.left,s=o.bottom-o.top,i=e-o.left,a=t-o.top,l=0;return i<n&&(l+=8),i>r-n&&(l+=2),a<n&&(l+=1),a>s-n&&(l+=4),{pctX:i/r,pctY:a/s,closeToTheEdge:l}}function Wt(e,t,o,n){let{BEFORE:r,AFTER:s}=Le,{pctX:i,pctY:a,closeToTheEdge:l}=$t(e,t,o),c,u;if(n==="row")c=i<.5?Ft:Nt;else if(o.header&&Je(o.header,e,t))if(c=di,o.Stack){let m=o.Stack.length;if(m===0)u={index:-1,left:o.left,positionRelativeToTab:s,width:0};else{let p=o.Stack.find(({left:d,right:g})=>e>=d&&e<=g);if(p){let d=p.right-p.left;u={index:o.Stack.indexOf(p),left:p.left,positionRelativeToTab:(e-p.left)/d<.5?r:s,width:d}}else u={left:o.Stack[m-1].right,width:0,index:m,positionRelativeToTab:s}}}else if(o.header.titleWidth){let m=o.header.titleWidth;u={index:-1,left:o.left,positionRelativeToTab:(e-o.left)/m<.5?r:s,width:m}}else u={left:o.left,width:0,positionRelativeToTab:r,index:-1};else c=hi(e,t,o,i,a);return{position:c,x:e,y:t,closeToTheEdge:l,tab:u}}function hi(e,t,o,n,r){let s=gi(o,.2);if(Je(s,e,t))return fi;switch(`${r<.5?"north":"south"}${n<.5?"west":"east"}`){case"northwest":return n>r?on:Ft;case"northeast":return 1-n>r?on:Nt;case"southeast":return n>r?Nt:nn;case"southwest":return 1-n>r?Ft:nn;default:}}function gi({right:e,left:t,top:o,bottom:n},r){let s=(1-r)/2,i=(e-t)*s,a=(n-o)*s;return{left:t+i,top:o+a,right:e-i,bottom:n-a}}function yi(e,t,o){let{id:n,"data-path":r,path:s=r}=T(e),i=L(e);if(n&&s){let[a,l]=an(e);rn(e,a,l,t),W(i)&&sn(e,t,o)}}function rn(e,t,o,n){let{"data-path":r,path:s=r,header:i}=T(e);n[s]=t;let a=L(e);if(i||a==="Stack"){let l=a==="Stack"?".vuuTabstrip":".vuuHeader",c=o.querySelector(l);if(c){let{top:u,left:m,right:p,bottom:d}=c.getBoundingClientRect();if(n[s].header={top:Math.round(u),left:Math.round(m),right:Math.round(p),bottom:Math.round(d)},a==="Stack")n[s].Stack=Array.from(c.querySelectorAll(".vuuTab")).map(g=>g.getBoundingClientRect()).map(({left:g,right:f})=>({left:g,right:f}));else{let g=c.querySelector('[class^="vuuHeader-title"]'),{header:f}=n[s];g&&f&&(f.titleWidth=g.clientWidth)}}}return n[s]}function sn(e,t,o,n=0,r=0,s=0,i=0){let{children:a,"data-path":l,path:c=l,style:u,active:m=0}=T(e),p=L(e),d=p==="Flexbox",g=p==="Stack",f=d&&u.flexDirection==="column",y=d&&u.flexDirection==="row",b=(g?a.filter((w,R)=>R===m):a.filter(bi)).map(w=>{let[R,x]=an(w);return[{...R,top:R.top-s,right:R.right+r,bottom:R.bottom+i,left:R.left-n},x,w]}),v=b.map(([w,R,x],E,P)=>{let I,M,A,k,S,C,H=P.length-1;y?(S=E===0?0:w.left-P[E-1][0].right,C=E===H?0:P[E+1][0].left-w.right,I=E===0||S===0?0:S,M=E===H||C===0?0:C-C/2,w.left-=I,w.right+=M,A=s,k=i):f&&(S=E===0?0:w.top-P[E-1][0].bottom,C=E===H?0:P[E+1][0].top-w.bottom,A=E===0||S===0?0:S,k=E===H||C===0?0:C-C/2,w.top-=A,w.bottom+=k,I=n,M=r);let G=rn(x,w,R,t),B=L(x);return W(B)&&sn(x,t,o,I,M,A,k),G});b.length&&(t[c].children=v)}function bi(e){let{id:t}=T(e),o=document.getElementById(t);return o?o.dataset.dragging!=="true":(console.warn(`BoxModel: no element found with id #${t}`),!1)}function an(e){let{id:t}=T(e);if(t===void 0)throw Error("`BoxModel.measureComponentElement, component has no id");let o=document.getElementById(t);if(!o)throw Error("BoxModel.measureComponentElement, no DOM element found for component");let{top:n,left:r,right:s,bottom:i,height:a,width:l}=o.getBoundingClientRect(),c,u=L(e);if(W(u)){let m=o.scrollHeight;m>a&&(c={id:t,scrollHeight:m,scrollTop:o.scrollTop})}return[{top:Math.round(n),left:Math.round(r),right:Math.round(s),bottom:Math.round(i),height:Math.round(a),width:Math.round(l),scrolling:c},o,e]}function ln(e,t,o,n,r,s=[]){let{children:i,"data-path":a,path:l=a}=T(e),c=L(e),u=t[l];if(!Je(u,o,n))return s;if(r&&r.length){if(r.includes(l))s.push(e);else if(!r.some(m=>m.startsWith(l)))return s}else s.push(e);if(!W(c)||u.header&&Je(u.header,o,n))return s;u.scrolling&&xi(u,o,n);for(let m=0;m<i.length;m++){if(c==="Stack"&&e.props.active!==m)continue;let p=ln(i[m],t,o,n,r);if(p.length)return s.concat(p)}return s}function xi({top:e,bottom:t,scrolling:o},n,r){if(o){let{id:s,scrollTop:i,scrollHeight:a}=o,l=t-e;if(i===0&&t-r<50){let c=a-l;document.getElementById(s).scrollTo({left:0,top:c,behavior:"smooth"}),o.scrollTop=c}else if(i>0&&r-e<50)document.getElementById(s).scrollTo({left:0,top:0,behavior:"smooth"}),o.scrollTop=0;else return!1}else return!1}var Ei=.4,Qe=class{constructor(t,o,n,r,s){this.init(t,o,n,r,s)}init(t,o,n,r,s){let{left:i,top:a}=r,{pctX:l,pctY:c}=$t(o,n,r),u=Ei,m=l*r.width,p=r.width-m,d=c*r.height,g=r.height-d,f=r.width*u,y=r.height*u,h=1-u,b=m*h,v=d*h,w=p*h,R=g*h;this.intrinsicSize=s,this.constraint={zone:{x:{lo:t.left,hi:t.right},y:{lo:t.top,hi:t.bottom}},pos:{x:{lo:t.left-b,hi:t.right-r.width+w},y:{lo:t.top-v,hi:t.bottom-r.height+R}},mouse:{x:{lo:t.left+f*l,hi:t.right-f*(1-l)},y:{lo:t.top+y*c,hi:t.bottom-y*(1-c)}}},this.x={pos:i,lo:!1,hi:!1,mousePos:o,mousePct:l},this.y={pos:a,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 t,o;return((t=this==null?void 0:this.intrinsicSize)==null?void 0:t.height)&&((o=this==null?void 0:this.intrinsicSize)==null?void 0:o.width)}update(t,o){let n=this[t],r=this.constraint.mouse[t],s=this.constraint.pos[t],i=n.pos,a=o-n.mousePos;return a<0?n.lo||(o<r.lo?(n.lo=!0,n.pos=s.lo):n.hi?o<r.hi&&(n.hi=!1,n.pos+=a):n.pos+=a):a>0&&(n.hi||(o>r.hi?(n.hi=!0,n.pos=s.hi):n.lo?o>r.lo&&(n.lo=!1,n.pos+=a):n.pos+=a)),n.mousePos=o,i!==n.pos}dropXY(t){let o=this[t],n=this.constraint.zone[t];return o.lo?Math.max(n.lo,o.mousePos):o.hi?Math.min(o.mousePos,Math.round(n.hi)-1):o.mousePos}};var Vp=e=>e.pos.tab&&L(e.component)==="Stack"&&e.pos.position.Header,{north:vi,south:wi,east:Ri,west:Ti}=me,Si=Ri+Ti,Pi=vi+wi,ie=class{constructor({component:t,pos:o,clientRect:n,nextDropTarget:r}){this.component=t,this.pos=o,this.clientRect=n,this.nextDropTarget=r,this.active=!1,this.dropRect=void 0}targetTabPos(t){let{left:o,width:n,positionRelativeToTab:r}=t;return r===Le.BEFORE?o:o+n}getTargetDropOutline(t,o){if(this.pos.tab)return this.getDropTabOutline(t,this.pos.tab);if(o&&o.hasIntrinsicSize())return this.getIntrinsicDropRect(o);{let[n,r,s,i]=this.getDropRectOutline(t,o);return{l:n,t:r,r:s,b:i}}}getDropTabOutline(t,o){var h,b;let{clientRect:{top:n,left:r,right:s,bottom:i,header:a}}=this,l=0,c=Math.round(t/2)+l,u=Math.round(n),m=Math.round(r+c),p=Math.round(s-c),d=Math.round(i-c),g=this.targetTabPos(o),f=60,y=((h=a==null?void 0:a.bottom)!=null?h:0)-((b=a==null?void 0:a.top)!=null?b:0);return{l:m,t:u,r:p,b:d,tabLeft:g,tabWidth:f,tabHeight:y}}getIntrinsicDropRect(t){var f,y,h,b;let{pos:o,clientRect:n}=this,{x:r,y:s}=t,i=(y=(f=t.intrinsicSize)==null?void 0:f.height)!=null?y:0,a=(b=(h=t.intrinsicSize)==null?void 0:h.height)!=null?b:0;i&&i>n.height?(console.log("DropTarget: we're going to blow the gaff"),i=n.height):a&&a>n.width&&(console.log("DropTarget: we're going to blow the gaff"),a=n.width);let l=Math.min(n.right-a,Math.max(n.left,Math.round(o.x-r.mousePct*a))),c=Math.min(n.bottom-i,Math.max(n.top,Math.round(o.y-s.mousePct*i))),[u,m,p,d]=this.dropRect=[l,c,l+a,c+i],g=o.position.EastOrWest?[u,n.top,u,n.bottom,p,n.top,p,n.bottom]:[n.left,m,n.right,m,n.left,d,n.right,d];return{l:u,r:p,t:m,b:d,guideLines:g}}getDropRectOutline(t,o){var b,v,w;let{pos:n,clientRect:r}=this,{width:s,height:i,position:a}=n,{width:l,height:c}=(b=o==null?void 0:o.intrinsicSize)!=null?b:{},u=(v=c!=null?c:i)!=null?v:0,m=(w=l!=null?l:s)!=null?w:0;this.dropRect=void 0;let{top:p,left:d,right:g,bottom:f}=r,y=0,h=Math.round(t/2)+y;switch(a){case K.North:case K.Header:{let R=Math.round((f-p)/2),x=u?Math.min(R,Math.round(u)):R;return m&&d+m<g?[d+h,p+h,d+m-h,p+h+x]:[d+h,p+h,g-h,p+h+x]}case K.West:{let R=Math.round((g-d)/2),x=m?Math.min(R,Math.round(m)):R;return u&&p+u<f?[d+h,p+h,d-h+x,p+u+h]:[d+h,p+h,d-h+x,f-h]}case K.East:{let R=Math.round((g-d)/2),x=m?Math.min(R,Math.round(m)):R;return u&&p+u<f?[g-h-x,p+h,g-h,p+u+h]:[g-h-x,p+h,g-h,f-h]}case K.South:{let R=Math.round((f-p)/2),x=u?Math.min(R,Math.round(u)):R;return m&&d+m<g?[d+h,f-h-x,d+m-h,f-h]:[d+h,f-h-x,g-h,f-h]}case K.Centre:return[d+h,p+h,g-h,f-h];default:return console.warn(`DropTarget does not recognize position ${a}`),null}}activate(){return this.active=!0,this}toArray(){let t=this,o=[t];for(;t=t.nextDropTarget;)o.push(t);return o}static getActiveDropTarget(t){return t===null?null:t!=null&&t.active?t:ie.getActiveDropTarget(t.nextDropTarget)}};function Vt(e,t,o,n,r,s){var l;let i=null,a=ve.allBoxesContainingPoint(o,n,e,t,s);if(a.length){let[c,...u]=a,{"data-path":m,path:p=m,"data-row-placeholder":d}=T(c),g=n[p],y=Wt(e,t,g,r&&d?"row":void 0),h=n[p],b=([v,...w])=>{var R,x;if((R=y.position)!=null&&R.Header||y.closeToTheEdge){let E=Di(v,y,h,n,e,t);if(E){let[P,I]=E;return new ie({component:v,pos:P,clientRect:I,nextDropTarget:(x=b(w))!=null?x:null})}else if(w.length)return b(w)}};i=new ie({component:c,pos:y,clientRect:g,nextDropTarget:(l=b(u))!=null?l:null}).activate()}return i}function Di(e,{closeToTheEdge:t,position:o},n,r,s,i){if(!e||e.type==="DraggableLayout")return;let a=r[e.props.path],l=t&me.north,c=t&me.east,u=t&me.south,m=t&me.west,p=(l||o.Header)&&Math.round(n.top)===Math.round(a.top),d=c&&Math.round(n.right)===Math.round(a.right),g=u&&Math.round(n.bottom)===Math.round(a.bottom),f=m&&Math.round(n.left)===Math.round(a.left);if(p||d||g||f){let{"data-path":y,path:h=y}=e.props,b=r[h],v=Wt(s,i,b);if((Li(e)||cn(e))&&t&Si)return v.width=120,[v,b];if((Mi(e)||cn(e))&&(o.Header||t&Pi))return v.height=120,[v,b]}}function cn(e){return L(e)==="Stack"}function Li(e){return L(e)==="Flexbox"&&e.props.style.flexDirection==="column"}function Mi(e){return L(e)==="Flexbox"&&e.props.style.flexDirection==="row"}import{PopupService as Gt}from"@vuu-ui/vuu-popups";import Ci from"classnames";import{jsx as un}from"react/jsx-runtime";function pn(e,t=0,o=0){let{pos:n,clientRect:r}=e,s=20;return n.position.West?[r.left-o+s,n.y-t,"left"]:n.position.South?[n.x-o,r.bottom-t-s,"bottom"]:n.position.East?[r.right-o-s,n.y-t,"right"]:[n.x-o,r.top-t+s,"top"]}var _t="vuuDropMenu",mn=({className:e,dropTarget:t,onHover:o,orientation:n})=>{let r=t.toArray();return un("div",{className:Ci(_t,e,`${_t}-${n}`),onMouseLeave:()=>o(null),children:r.map((s,i)=>un("div",{className:`${_t}-item`,"data-icon":i===0?"column-2A":"column-2B",onMouseEnter:()=>o(s)},i))})};import{jsx as Bi}from"react/jsx-runtime";var Kt=!1,Me=null,j=null,Ii=e=>Me=e,Ai=([e,t])=>`M${e},${t}`,Hi=([e,t])=>`L${e},${t}`,dn=([e,...t])=>`${Ai(e)} ${t.map(Hi)}Z`,ki=e=>{if(e){let[t,o,n,r,s,i,a,l]=e;return`M${t},${o} L${n},${r} M${s},${i} L${a},${l}`}else return""};function Oi(){if(document.getElementById("hw-drag-canvas")===null){let e=document.getElementById("root"),t=document.createElement("div");t.id="hw-drag-canvas",t.innerHTML=`
|
|
1
|
+
var Oh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var T=(r,e,t)=>(Oh(r,e,"read from private field"),t?t.call(r):e.get(r)),te=(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)=>(Oh(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Nh=(r,e,t,n)=>({set _(o){z(r,e,o,t)},get _(){return T(r,e,n)}});import{partition as $h}from"@vuu-ui/vuu-utils";import gx from"classnames";var Vh={},Fh={},Fn={};function ze(r){return Vh[r]===!0}function hx(r){return Fh[r]===!0}var Bh=r=>ze(r)||hx(r);function ge(r,e,t="component"){Fn[r]=e,t==="container"?Vh[r]=!0:t==="view"&&(Fh[r]=!0)}import{Button as Hh,useControlled as fx}from"@salt-ds/core";import _h from"classnames";import{useCallback as dx}from"react";import{jsx as bo,jsxs as mx}from"react/jsx-runtime";var fn="vuuDrawer",zh=r=>typeof r=="string"?r:r+"px",px=(r,e,t)=>{let n=e!==void 0,o=t!==void 0;if(!(!r&&!o&&!n))return!o&&!n?r:{...r,"--drawer-size":n?zh(e):void 0,"--drawer-peek-size":o?zh(t):void 0}},Wh=({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]=fx({controlled:l,default:n!=null?n:!1,name:"Drawer",state:"open"}),g=_h(fn,e,`${fn}-${a}`,{[`${fn}-open`]:p,[`${fn}-inline`]:c,[`${fn}-over`]:!c,[`${fn}-peekaboo`]:h}),y=dx(()=>{m(!p)},[p,m]),v=px(s,o,i),w=t?y:u,x=()=>bo("div",{className:_h("vuuToggleButton-container"),children:p?bo(Hh,{"aria-label":"close",onClick:y,"data-icon":"close",variant:"secondary"}):bo(Hh,{"aria-label":"open",onClick:y,"data-icon":"close",variant:"secondary"})});return mx("div",{...d,className:g,onClick:w,style:v,children:[f=="start"?x():null,bo("div",{className:`${fn}-liner`,children:bo("div",{className:`${fn}-content`,children:r})}),f=="end"?x():null]})};Wh.displayName="Drawer";var Li=Wh;import{jsx as xx,jsxs as vx}from"react/jsx-runtime";var yx=r=>r.type===Li,bx=({props:{position:r="left"}})=>r.match(/top|bottom/),Zl=r=>{let{children:e,className:t,id:n,style:o}=r,i="vuuDockLayout",[s,l]=$h(e,yx),[a,c]=$h(s,bx),u=a.length===0?"horizontal":c.length===0?"vertical":"both",h=gx(i,t,`${i}-${u}`);return vx("div",{className:h,id:n,style:o,children:[s,xx("div",{className:`${i}-content`,children:l})]})};Zl.displayName="DockLayout";var Uh=Zl;ge("DockLayout",Zl,"container");import{forwardRef as wx}from"react";import{jsx as Sx}from"react/jsx-runtime";var ea=wx(function({resizeable:e,...t},n){return Sx("div",{...t,className:"Component",ref:n})});ea.displayName="Component";var ta=ea;ge("Component",ea);import dn,{isValidElement as qh}from"react";var Cx={},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||Cx,Gh=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 DD=(r,e)=>K(r)===e;var Tx=r=>{let e=r.lastIndexOf(".");return e===-1?r:r.slice(0,e)},Kh=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=Kh(r),{path:s}=_(i[o]);return s}return""},jh=(r,e="")=>{let[t,...n]=e.split(".");if(t!=null&&t.startsWith("#")){let o=Qh(r,t.slice(1),!0);if(o&&n.length)return jh(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,Tx(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 kx(r,e){if(e===r)return null;let{path:t,children:n}=_(r),{idx:o,finalStep:i}=Mt(t,q(e,"path"));return i?r:n===void 0||n[o]===void 0?null:kx(n[o],e)}var Mx=(r,e)=>{if(dn.isValidElement(r)&&e==0)return r;if(Array.isArray(r))return r[e]};function Jh(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=Kh(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=qh(n)?[n]:n;for(let s of i)if(qh(s)){let l=ra(s,e,!1);if(l)return l}}if(t===!0)throw Error(`pathUtils.findTargetById id #${e} not found in source`)},Qh=(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=Qh(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=Mx(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 BD(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 Ai(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))?Ai(a):a}}}return Ai(r)}function HD(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 Oi(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))?Oi(s):s}}return Oi(r)}function Ai(r){if(ze(K(r))){let{children:e}=r.props||r;return Ai(e[0])}return r}function Oi(r){if(ze(K(r))){let{children:e}=r.props||r;return Oi(e[e.length-1])}return r}function Mt(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 zD(r,e){typeof r=="function"?r(e):r&&(r.current=e)}import{Children as Ex,isValidElement as Yh,useLayoutEffect as Rx,useMemo as Ix,useRef as Px}from"react";var Dx=[],Lx=0,wr=r=>{let e=Array.isArray(r),t=e?r.length:Ex.count(r);return e&&r.every(Yh)?r:t===1&&!e&&Yh(r)?[r]:t>1?r:Dx},Xh=(r,e)=>{let t=Px(!1);Rx(()=>{t.current?r():t.current=!0},e)},Sr=r=>Ix(()=>r!=null?r:`vuu-${++Lx}`,[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 Ni}from"@vuu-ui/vuu-utils";var Hn={north:1,east:2,south:4,west:8,header:16,centre:32,absolute:64},xo={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 Zh=Ze.North,ef=Ze.South,ia=Ze.East,sa=Ze.West,Ax=Ze.Header,Ox=Ze.Centre,Cr=class{static measure(e,t=[]){let n={};return Fx(e,n,t),n}static allBoxesContainingPoint(e,t,n,o,i){return of(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}=xo,{pctX:s,pctY:l,closeToTheEdge:a}=la(r,e,t),c,u;if(n==="row")c=s<.5?sa:ia;else if(t.header&&Ni(t.header,r,e))if(c=Ax,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=Nx(r,e,t,s,l);return{position:c,x:r,y:e,closeToTheEdge:a,tab:u}}function Nx(r,e,t,n,o){let i=Vx(t,.2);if(Ni(i,r,e))return Ox;switch(`${o<.5?"north":"south"}${n<.5?"west":"east"}`){case"northwest":return n>o?Zh:sa;case"northeast":return 1-n>o?Zh:ia;case"southeast":return n>o?ia:ef;case"southwest":return 1-n>o?sa:ef;default:}}function Vx({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 Fx(r,e,t){let{id:n,"data-path":o,path:i=o}=_(r),s=K(r);if(n&&i){let[l,a]=rf(r);tf(r,l,a,e),ze(s)&&nf(r,e,t)}}function tf(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 nf(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",g=d&&u.flexDirection==="row",v=(p?l.filter((x,S)=>S===h):l.filter(Bx)).map(x=>{let[S,b]=rf(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,N,O,M,D,F=k.length-1;g?(M=C===0?0:x.left-k[C-1][0].right,D=C===F?0:k[C+1][0].left-x.right,E=C===0||M===0?0:M,R=C===F||D===0?0:D-D/2,x.left-=E,x.right+=R,N=i,O=s):m&&(M=C===0?0:x.top-k[C-1][0].bottom,D=C===F?0:k[C+1][0].top-x.bottom,N=C===0||M===0?0:M,O=C===F||D===0?0:D-D/2,x.top-=N,x.bottom+=O,E=n,R=o);let G=tf(b,x,S,e),A=K(b);return ze(A)&&nf(b,e,t,E,R,N,O),G});v.length&&(e[c].children=w)}function Bx(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 rf(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 of(r,e,t,n,o,i=[]){let{children:s,"data-path":l,path:a=l}=_(r),c=K(r),u=e[a];if(!Ni(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&&Ni(u.header,t,n))return i;u.scrolling&&Hx(u,t,n);for(let h=0;h<s.length;h++){if(c==="Stack"&&r.props.active!==h)continue;let f=of(s[h],e,t,n,o);if(f.length)return i.concat(f)}return i}function Hx({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,Vi=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,g=o.height*u,y=1-u,v=h*y,w=d*y,x=f*y,S=p*y;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+g*c,hi:e.bottom-g*(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 fL=r=>r.pos.tab&&K(r.component)==="Stack"&&r.pos.position.Header,{north:zx,south:Wx,east:$x,west:Ux}=Hn,Gx=$x+Ux,qx=zx+Wx,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===xo.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 y,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,g=((y=l==null?void 0:l.bottom)!=null?y: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:g}}getIntrinsicDropRect(e){var m,g,y,v;let{pos:t,clientRect:n}=this,{x:o,y:i}=e,s=(g=(m=e.intrinsicSize)==null?void 0:m.height)!=null?g:0,l=(v=(y=e.intrinsicSize)==null?void 0:y.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,g=0,y=Math.round(e/2)+g;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+y,f+y,d+h-y,f+y+b]:[d+y,f+y,p-y,f+y+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+y,f+y,d-y+b,f+u+y]:[d+y,f+y,d-y+b,m-y]}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-y-b,f+y,p-y,f+u+y]:[p-y-b,f+y,p-y,m-y]}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+y,m-y-b,d+h-y,m-y]:[d+y,m-y-b,p-y,m-y]}case Ze.Centre:return[d+y,f+y,p-y,m-y];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],g=aa(r,e,p,o&&d?"row":void 0),y=n[f],v=([w,...x])=>{var S,b;if((S=g.position)!=null&&S.Header||g.closeToTheEdge){let C=Kx(w,g,y,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:g,clientRect:p,nextDropTarget:(a=v(u))!=null?a:null}).activate()}return s}function Kx(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":g,path:y=g}=r.props,v=o[y],w=aa(i,s,v);if((jx(r)||sf(r))&&e&Gx)return w.width=120,[w,v];if((Jx(r)||sf(r))&&(t.Header||e&qx))return w.height=120,[w,v]}}function sf(r){return K(r)==="Stack"}function jx(r){return K(r)==="Flexbox"&&r.props.style.flexDirection==="column"}function Jx(r){return K(r)==="Flexbox"&&r.props.style.flexDirection==="row"}import{PopupService as ha}from"@vuu-ui/vuu-popups";import Qx from"classnames";import{jsx as lf}from"react/jsx-runtime";function af(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",cf=({className:r,dropTarget:e,onHover:t,orientation:n})=>{let o=e.toArray();return lf("div",{className:Qx(ua,r,`${ua}-${n}`),onMouseLeave:()=>t(null),children:o.map((i,s)=>lf("div",{className:`${ua}-item`,"data-icon":s===0?"column-2A":"column-2B",onMouseEnter:()=>t(i)},s))})};import{jsx as rv}from"react/jsx-runtime";var fa=!1,vo=null,Et=null,Yx=r=>vo=r,Xx=([r,e])=>`M${r},${e}`,Zx=([r,e])=>`L${r},${e}`,uf=([r,...e])=>`${Xx(r)} ${e.map(Zx)}Z`,ev=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 tv(){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,7 +14,227 @@ import{partition as Zo}from"@vuu-ui/vuu-utils";import Zs from"classnames";var Wo
|
|
|
14
14
|
/>
|
|
15
15
|
</path>
|
|
16
16
|
</svg>
|
|
17
|
-
`,document.body.insertBefore(t,e)}}var Ce=class{constructor(){this.currentPath=null;this.tabMode=null;Oi()}prepare(t,o="full-view"){document.body.classList.add("drawing"),this.currentPath=null,this.tabMode=o;let n=this.getPoints(0,0,0,0),r=dn(n),s=document.getElementById("vuu-drop-outline");s==null||s.setAttribute("d",r),this.currentPath=r}clear(){Me=null,et(),document.body.classList.remove("drawing"),Gt.hidePopup()}get hoverDropTarget(){return Me}getPoints(t,o,n,r,s=0,i=0,a=0){let l=this.tabMode==="tab-only";if(i===0)return[[t,o+a],[t,o+a],[t,o],[t+i,o],[t+i,o],[t+n,o],[t+n,o+r],[t,o+r]];if(l){let c=s;return[[c,o],[c,o],[c+i,o],[c+i,o],[c+i,o+a],[c+i,o+a],[c,o+a],[c,o+a]]}else return s===0?[[t,o+a],[t,o+a],[t,o],[t+i,o],[t+i,o+a],[t+n,o+a],[t+n,o+r],[t,o+r]]:[[t,o+a],[t+s,o+a],[t+s,o],[t+s,o],[t+s,o+a],[t+n,o+a],[t+n,o+r],[t,o+r]]}draw(t,o){let r=Kt;if(Me!==null)this.drawTarget(Me);else if(Kt=t.nextDropTarget!=null,t.pos.tab?zi(t):j&&et(),this.drawTarget(t,o),Kt){let[s,i,a]=pn(t);{let l=Bi(mn,{dropTarget:t,onHover:Ii,orientation:a});Gt.showPopup({left:s,top:i,component:l})}}else Gt.hidePopup()}drawTarget(t,o){let r=t.getTargetDropOutline(6,o);if(r){let{l:s,t:i,r:a,b:l,tabLeft:c,tabWidth:u,tabHeight:m,guideLines:p}=r,d=a-s,g=l-i;if(this.currentPath){let v=document.getElementById("vuu-drop-outline");v==null||v.setAttribute("d",this.currentPath)}let f=this.getPoints(s,i,d,g,c,u,m),y=dn(f),h=document.getElementById("hw-drop-outline-animate");h==null||h.setAttribute("to",y),h==null||h.beginElement(),this.currentPath=y;let b=document.getElementById("hw-drop-guides");b==null||b.setAttribute("d",ki(p))}}},fn="transition:margin-left .4s ease-out;margin-left: 63px",hn="transition:margin-left .4s ease-out;margin-left: 0px";function zi(e){var a,l;let{AFTER:t,BEFORE:o}=Le,{clientRect:{Stack:n},pos:{tab:r}}=e,{id:s}=e.component.props,i=null;if(n&&r&&r.positionRelativeToTab!==t){let c=r.positionRelativeToTab===o?1:2,u=`:scope .hwTabstrip > .hwTabstrip-inner > .hwTab:nth-child(${r.index+c})`;i=(a=document.getElementById(s))==null?void 0:a.querySelector(u),i?(j===null||j!==i)&&(i.style.cssText=fn,j&&(j.style.cssText=hn),j=i):et()}else if((r==null?void 0:r.positionRelativeToTab)===o){if(j===null){let c=".vuuHeader-title";i=(l=document.getElementById(s))==null?void 0:l.querySelector(c),i.style.cssText=fn,j=i}}else et()}function et(){j&&(j.style.cssText=hn,j=null)}var ne,Ie,ae,yn,bn,de,tt,fe=null,Yt,xn,nt,En,Ut,ot=null,Ni=3,rt=new Ce,gn=.4;function Fi(e,t){return t?z(e,t):oe(e,o=>o.dropTarget)}var Zt={handleMousedown(e,t,o={}){ne=t,xn=o,yn=e.clientX,bn=e.clientY,Ut=o.dragThreshold===void 0?Ni:o.dragThreshold,Ut===0?ne(e,0,0):(window.addEventListener("mousemove",st,!1),window.addEventListener("mouseup",it,!1),ot=window.setTimeout(()=>{window.removeEventListener("mousemove",st,!1),window.removeEventListener("mouseup",it,!1),ne==null||ne(e,0,0)},500)),e.preventDefault()},initDrag(e,t,{top:o,left:n,right:r,bottom:s},i,a,l,c){return{drag:Ie,drop:ae}=a,$i(e,t,{top:o,left:n,right:r,bottom:s},i,l,c)}};function st(e){let n=e.clientX-yn,r=e.clientY-bn;Math.max(Math.abs(n),Math.abs(r))>Ut&&(window.removeEventListener("mousemove",st,!1),window.removeEventListener("mouseup",it,!1),ne==null||ne(e,n,r),ne=null)}function it(){ot&&(window.clearTimeout(ot),ot=null),window.removeEventListener("mousemove",st,!1),window.removeEventListener("mouseup",it,!1)}function $i(e,t,o,n,r,s){de=Fi(e,t);let{"data-path":i,path:a=i}=T(de);s&&(Yt=s.map(p=>oe(e,d=>d.id===p)).map(p=>p.props.path)),nt=ve.measure(de,s);let l=nt[a];tt=new Qe(l,n.x,n.y,o,r);let c=Math.round(tt.x.mousePct*100),u=Math.round(tt.y.mousePct*100);return window.addEventListener("mousemove",vn,!1),window.addEventListener("mouseup",Rn,!1),window.addEventListener("keydown",wn,!1),En=!1,rt.prepare(o,"tab-only"),xn.DoNotTransform?"transform:none":`transform:scale(${gn},${gn});transform-origin:${c}% ${u}%;`}function vn(e){let t=e.clientX,o=e.clientY,n=tt,r=fe,s,i,a;n.update("x",t)&&(i=n.x.pos),n.update("y",o)&&(a=n.y.pos),i===void 0&&a===void 0||Ie==null||Ie(i,a),!(En||de===void 0)&&(n.inBounds()?s=Vt(t,o,de,nt,n.hasIntrinsicSize(),Yt):s=Vt(n.dropX(),n.dropY(),de,nt),r&&(s==null||s.box!==r.box)&&(fe=null),s&&(rt.draw(s,n),fe=s))}function wn(e){e.key==="Escape"&&(fe=null,Tn())}function Rn(){Tn()}function Tn(){if(fe){let e=rt.hoverDropTarget||ie.getActiveDropTarget(fe);ae==null||ae(e),fe=null}else ae==null||ae();Ie=null,ae=null,de=void 0,rt.clear(),Yt=void 0,window.removeEventListener("mousemove",vn,!1),window.removeEventListener("mouseup",Rn,!1),window.removeEventListener("keydown",wn,!1)}import Wi from"classnames";import{forwardRef as Vi}from"react";import{jsx as _i}from"react/jsx-runtime";var Sn=Vi(function({children:t,className:o,dropTarget:n,resizeable:r,...s},i){let a=Wi("DraggableLayout",o);return _i("div",{className:a,ref:i,...s,children:t})}),Pn="DraggableLayout";Sn.displayName=Pn;O(Pn,Sn,"container");import{useForkRef as ma}from"@salt-ds/core";import da from"classnames";import{forwardRef as fa}from"react";import{getUniqueId as sa}from"@vuu-ui/vuu-utils";import ze,{useCallback as mt,useMemo as Nn,useRef as dt,useState as ia}from"react";import Gi from"classnames";import{jsx as Ki}from"react/jsx-runtime";var Dn="vuuPlaceholder",at=({className:e,closeable:t,flexFill:o,resizeable:n,shim:r,...s})=>Ki("div",{className:Gi(Dn,e,{[`${Dn}-shim`]:r}),...s,"data-placeholder":!0,"data-resizeable":!0});at.displayName="Placeholder";O("Placeholder",at);import Ui from"classnames";import Yi,{useCallback as Ae,useRef as lt,useState as Zi}from"react";import{jsx as Ln}from"react/jsx-runtime";var ct="vuuSplitter",Mn=Yi.memo(function({column:t,index:o,onDrag:n,onDragEnd:r,onDragStart:s,style:i}){let a=lt(),l=lt(null),c=lt(0),[u,m]=Zi(!1),p=Ae(({key:x,shiftKey:E})=>{let P=E?10:1;t&&x==="ArrowDown"?n(o,P):t&&x==="ArrowUp"||!t&&x==="ArrowLeft"?n(o,-P):!t&&x==="ArrowRight"&&n(o,P)},[t,o,n]),d=Ae(x=>{let{key:E}=x;(t&&(E==="ArrowUp"||E==="ArrowDown")||!t&&(E==="ArrowLeft"||E==="ArrowRight"))&&(s(o),p(x),g.current=p)},[t,p,o,s]),g=lt(d),f=x=>g.current(x),y=Ae(x=>{a.current=!0;let E=x[t?"clientY":"clientX"],P=E-c.current;E&&E!==c.current&&n(o,P),c.current=E},[t,o,n]),h=Ae(()=>{var x;window.removeEventListener("mousemove",y,!1),window.removeEventListener("mouseup",h,!1),r(),m(!1),(x=l.current)==null||x.focus()},[y,r,m]),b=Ae(x=>{c.current=t?x.clientY:x.clientX,s(o),window.addEventListener("mousemove",y,!1),window.addEventListener("mouseup",h,!1),x.preventDefault(),m(!0)},[t,y,h,o,s,m]),v=()=>{var x;a.current?a.current=!1:(x=l.current)==null||x.focus()},w=()=>{g.current=d},R=Ui(ct,{[`${ct}-active`]:u,[`${ct}-column`]:t});return Ln("div",{className:R,"data-splitter":!0,ref:l,role:"separator",style:i,onBlur:w,onClick:v,onKeyDown:f,onMouseDown:b,tabIndex:0,children:Ln("div",{className:`${ct}-grab-zone`})})});import{uuid as Cn}from"@vuu-ui/vuu-utils";import In from"react";var Xi={"data-placeholder":!0,"data-resizeable":!0},ut={},le="auto",Xt={flexBasis:0,flexGrow:1,flexShrink:1,height:le,width:le},An={height:"width",width:"height"},Hn=(e="row")=>e==="row"?["width","height","column"]:["height","width","row"],ji=e=>typeof e=="string"&&e.endsWith("%"),U=e=>{let{style:{width:t=le,height:o=le}=ut}=e.props,n=typeof o=="number",r=typeof t=="number";return n&&r?{height:o,width:t}:n?{height:o}:r?{width:t}:void 0};function jt(e,t,o){let n=An[t],{style:{[n]:r=le,...s}=ut}=e.props;return o&&o[t]?{...s,...Xt,flexBasis:o[t],flexGrow:0,flexShrink:0}:{...s,...Xt,[n]:r}}function kn(e){let{style:{flex:t,flexGrow:o,flexShrink:n,flexBasis:r}=ut}=e.props;return typeof t=="number"||r===0&&o===1&&n===1?!0:typeof r!="number"}function qt(e,t,o){let n=An[t],{style:{[t]:r=le,[n]:s=le,...i}=ut}=e.props;return r!==le?ji(r)?{flexBasis:0,flexGrow:1,flexShrink:1,[t]:void 0,[n]:s}:{flexBasis:r,flexGrow:0,flexShrink:0,[t]:r,[n]:s}:o&&o[t]?{...i,...Xt,flexBasis:o[t],flexGrow:0,flexShrink:0}:{...i,[n]:s}}function He(e,t,o,n,r){let s=[],i=0,a;if(n&&r){let u,[m,p,d,g]=r;[u,a]=t==="column"?[p-n.top,n.bottom-g]:[m-n.left,n.right-d],u&&s.push(J(`${o}.${i++}`,u,{flexGrow:0,flexShrink:0}))}else a=!0;let{version:l=0,style:c}=T(e);return s.push(N(e,`${o}.${i++}`,{version:l+1,style:{...c,flexBasis:"auto",flexGrow:0,flexShrink:0}})),a&&s.push(J(`${o}.${i++}`,0,void 0,{[`data-${t}-placeholder`]:!0})),Jt(t,{resizeable:!1,style:{flexBasis:"auto"}},s,o)}var qi=(e,t)=>{if(!t)return e===0?1:0};function Jt(e,t,o,n){let r=Cn(),{flexFill:s,style:i,resizeable:a=!0}=t,{flexBasis:l=s?void 0:"auto"}=i,c=qi(l,s);return In.createElement(ue.Flexbox,{id:r,key:r,path:n,flexFill:s,style:{...i,flexDirection:e,flexBasis:l,flexGrow:c,flexShrink:c},resizeable:a},o)}var Ji={flexGrow:1,flexShrink:1};function J(e,t,o,n){let r=Cn();return In.createElement("div",{...Xi,...n,"data-path":e,id:r,key:r,style:{...Ji,...o,flexBasis:t}})}var Qi={},ke=1,Oe=2,ea=e=>typeof e.intrinsicSize=="number",ta=(e,t)=>{let o={};return e.forEach(n=>{o[n]=D(t,n)}),o},pt=(e,t,o)=>e.map((n,r)=>{var l;let s=D(n,"resizeable"),{[t]:i}=(l=U(n))!=null?l:Qi,a=kn(n);return o?{index:r,flexOpen:a,intrinsicSize:i,resizeable:s,...ta(o,n)}:{index:r,flexOpen:a,intrinsicSize:i,resizeable:s}}),On=e=>{let t=e.length,o=e.every(ea),n=Array(t).fill(0);if(o&&t>0&&(n[0]=Oe,n[t-1]=Oe),t<2)return n;for(let r=0,s=0;r<t-1;r++)e[r].resizeable&&!s&&(s=ke),n[r]+=s;for(let r=t-1;r>0&&(n[r]&ke&&(n[r]-=ke),!e[r].resizeable);r--);return n},zn=(e,t)=>{let o=na(e,t),n=ra(e,t),r=o!==-1&&n!==-1?[o,n]:void 0,s=oa(e,r);return[r,s]};function oa(e,t){if(t){let o=[];for(let n=0;n<e.length;n++)e[n].flexOpen&&!t.includes(n)&&o.push(n);return o}}function na(e,t){let o=t,n=!1;for(;o>=1&&!n;)o=o-1,n=Bn(e,o);return o}function ra(e,t){let o=t,n=!1,r=e.length;for(;o<r-1&&!n;)o=o+1,n=Bn(e,o);return o===r?-1:o}function Bn(e,t){let{placeholder:o,splitter:n,resizeable:r,intrinsicSize:s}=e[t];return!!(!n&&!s&&(o||r))}var aa=e=>!e.splitter&&!e.placeholder,$n=({children:e,onSplitterMoved:t,style:o})=>{let n=dt(null),r=dt(),s=dt(),i=dt([]),[,a]=ia({}),l=y=>{s.current=y,a({})},c=(o==null?void 0:o.flexDirection)==="column",u=c?"height":"width",m=Nn(()=>Array.isArray(e)?e:ze.isValidElement(e)?[e]:[],[e]),p=mt(y=>{let{current:h}=r;if(h){let[b,v]=zn(h,y);b&&(b.forEach(w=>{var x;let R=(x=n.current)==null?void 0:x.childNodes[w];if(R){let{size:E,minSize:P}=pa(R,u);h[w].currentSize=E,h[w].minSize=P}}),v&&v.forEach(w=>{var x;let R=(x=n.current)==null?void 0:x.childNodes[w];if(R){let{[u]:E}=R.getBoundingClientRect();h[w].flexBasis=E}}))}},[u]),d=mt((y,h)=>{s.current&&r.current&&l(ca(s.current,r.current,h,u))},[u]),g=mt(()=>{let y=r.current;y&&(t==null||t(y.filter(aa))),y==null||y.forEach(h=>{h.currentSize=void 0,h.flexBasis=void 0,h.flexOpen=!1})},[t]),f=mt(y=>ze.createElement(Mn,{column:c,index:y,key:`splitter-${y}`,onDrag:d,onDragEnd:g,onDragStart:p}),[d,g,p,c]);return Nn(()=>{let[y,h]=la(m,u,f,i.current);r.current=h,s.current=y},[m,f,u]),{content:s.current||[],rootRef:n}};function la(e,t,o,n){let r=pt(e,t),s=On(r),i=[],a=[];for(let l=0;l<e.length;l++){let c=e[l];if(l===0&&s[l]&Oe&&(i.push(Fn(l)),a.push({placeholder:!0,shim:!0})),c.key==null){let u=n[l]||(n[l]=sa());i.push(ze.cloneElement(c,{key:u}))}else i.push(c);a.push(r[l]),l>0&&s[l]&Oe?(i.push(Fn(l)),a.push({placeholder:!0})):s[l]&ke&&(i.push(o(i.length)),a.push({splitter:!0}))}return[i,a]}function ca(e,t,o,n){return ua(t,o)?e.map((s,i)=>{let a=t[i],{currentSize:l,flexOpen:c,flexBasis:u}=a,m=l!==void 0;if(m||c){let{flexBasis:p}=s.props.style||{},d=m?a.currentSize:u;return d!==p?ze.cloneElement(s,{style:{...s.props.style,flexBasis:d,[n]:"auto"}}):s}else return s}):e}function ua(e,t){let o=[];e.forEach((u,m)=>{u.currentSize!==void 0&&o.push(m)});let n=t<0?o[0]:o[1],{currentSize:r=0,minSize:s=0}=e[n];if(r===s)return!1;if(Math.abs(t)>r-s){let u=t<0?-1:1;t=Math.max(0,r-s)*u}let i=e[o[0]],{currentSize:a=0}=i;i.currentSize=a+t;let l=e[o[1]],{currentSize:c=0}=l;return l.currentSize=c-t,!0}function Fn(e){return ze.createElement(at,{shim:e===0,key:`placeholder-${e}`})}function pa(e,t){let{[t]:o}=e.getBoundingClientRect(),r=getComputedStyle(e).getPropertyValue(`min-${t}`),s=r.endsWith("px")?parseInt(r,10):0;return{size:o,minSize:s}}import{jsx as ha}from"react/jsx-runtime";var Qt="hwFlexbox",Wn=fa(function(t,o){let{breakPoints:n,children:r,column:s,className:i,flexFill:a,gap:l,fullPage:c,id:u,onSplitterMoved:m,resizeable:p,row:d,spacing:g,splitterSize:f,style:y,...h}=t,{content:b,rootRef:v}=$n({children:r,onSplitterMoved:m,style:y}),w=da(Qt,i,{[`${Qt}-column`]:s,[`${Qt}-row`]:d,"flex-fill":a,"full-page":c});return ha("div",{...h,className:w,"data-resizeable":p||void 0,id:u,ref:ma(v,o),style:{...y,gap:l,"--spacing":g},children:b})});Wn.displayName="Flexbox";var eo=Wn;import{useCallback as rl}from"react";var we={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 lo,useContext as co,useEffect as el,useRef as yr,useState as tl}from"react";import io from"react";import{uuid as Xn}from"@vuu-ui/vuu-utils";import $e from"react";import{uuid as Kn}from"@vuu-ui/vuu-utils";import Be,{cloneElement as ga}from"react";import{useCallback as Re}from"react";var V=new Map,Y=new Map,Vn=e=>V.get(e),_n=e=>V.has(e),Gn=(e,t)=>V.set(e,t),Te=()=>{let e=Re((i,a)=>{let l=Y.get(i);if(l)return a!==void 0&&l[a]!==void 0?l[a]:a!==void 0?void 0:l},[]),t=Re((i,a,l)=>{if(a===void 0)Y.set(i,l);else if(Y.has(i)){let c=Y.get(i);Y.set(i,{...c,[a]:l})}else Y.set(i,{[a]:l})},[]),o=Re((i,a)=>{if(Y.has(i)){if(a===void 0)Y.delete(i);else if(Y.get(i)[a]){let{[a]:c,...u}=Y.get(i);Object.keys(u).length>0?Y.set(i,u):Y.delete(i)}}},[]),n=Re((i,a)=>{let l=V.get(i);if(l)return a!==void 0?l[a]:l},[]),r=Re((i,a,l)=>{if(a===void 0)V.set(i,l);else if(V.has(i)){let c=V.get(i);V.set(i,{...c,[a]:l})}else V.set(i,{[a]:l})},[]),s=Re((i,a)=>{if(V.has(i)){if(a===void 0)V.delete(i);else if(V.get(i)[a]){let{[a]:c,...u}=V.get(i);Object.keys(u).length>0?V.set(i,u):V.delete(i)}}},[]);return{loadSessionState:e,loadState:n,saveSessionState:t,saveState:r,purgeState:s,purgeSessionState:o}};var Un=e=>e.flexDirection==="column"?["height","width"]:["width","height"],ya={},Ne=(e,t="0")=>{let[o,n]=ft(L(e),e.props,t);return Be.cloneElement(e,o,n)},oo=(e,t)=>{let o=L(e),[n,r]=ft(o,e.props,"0",void 0,t);return ga(e,n,r)},zd=(e,t,o)=>{let[n,r]=ft(e,t,"0",void 0,o);return{...t,...n,type:e,children:r}};function ba(e,t,o="0",n=null,r){var f,y;let{active:s=0,"data-path":i,path:a=i,id:l,style:c}=T(r),u=L(r)===e&&o===a,m=u?l:(f=t.id)!=null?f:Kn(),p=e==="Stack"?(y=t.active)!=null?y:s:void 0,d=m,g=u?c:Ea(e,t,n);return _o(e)?{id:m,key:d,path:o,style:g,type:e,active:p}:{id:m,key:d,style:g,"data-path":o}}function ft(e,t,o,n=null,r){var c,u;let s=ba(e,t,o,n,r);if(t.layout&&!r)return[s,[Fe(t.layout,`${o}.0`)]];let i=(u=r==null?void 0:r.children)!=null?u:(c=r==null?void 0:r.props)==null?void 0:c.children,l=t.dropTarget&&i?i:xa(e,t.children,o,i);return[s,l]}function xa(e,t,o="0",n){let r=Array.isArray(t)?t:Be.isValidElement(t)?[t]:[];return W(e)?r.map((s,i)=>{let a=L(s),l=L(n==null?void 0:n[i]);if(!l||a===l){let[c,u]=ft(a,s.props,`${o}.${i}`,e,n==null?void 0:n[i]);return Be.cloneElement(s,c,u)}return n==null?void 0:n[i]}):t}var Ea=(e,t,o)=>{let{style:n=ya}=t;if(e==="Flexbox"&&(n={flexDirection:t.column?"column":"row",...n,display:"flex"}),n.flex){let{flex:r,...s}=n;n={...s,...Bt(typeof r=="number"?r:0)}}else o==="Stack"?n={...n,...Bt(1)}:o==="Flexbox"&&(n.width||n.height)&&n.flexBasis===void 0&&(n={...n,flexBasis:"auto",flexGrow:0,flexShrink:0});return n};function Fe({id:e=Kn(),type:t,children:o,props:n,state:r},s){let i=t.match(/^[a-z]/)?t:ue[t];if(i===void 0)throw Error(`layoutUtils unable to create component from JSON, unknown type ${t}`);return r&&Gn(e,r),Be.createElement(i,{id:e,...n,key:e,path:s},o?o.map((a,l)=>Fe(a,`${s}.${l}`)):void 0)}function Yn(e){return Zn(e)}function Zn(e){let t=L(e),{id:o,children:n,type:r,...s}=T(e),i=_n(o)?Vn(o):void 0;return{id:o,type:t,props:va(s),state:i,children:Be.Children.map(n,Zn)}}function va(e){if(e){let{path:t,...o}=e,n={};for(let[r,s]of Object.entries(o))n[r]=to(s);return n}}function to(e){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(to);if(typeof e=="object"&&e!==null){let t={};for(let[o,n]of Object.entries(e))t[o]=to(n);return t}}function jn(e,t){var i;let o=e.props.children,n=o.length,{index:r=-1,positionRelativeToTab:s="after"}=t.tab||{};return r===-1||r>=n?[o[n-1],"after"]:[(i=o[r])!=null?i:null,s]}function ht(e,t,o){let{active:n,children:r=[],path:s}=T(e),i=D(t,"path"),{idx:a,finalStep:l}=X(s,i,!0),[c,u]=l?wa(e,r,o):[n,r==null?void 0:r.map((p,d)=>d===a?ht(p,t,o):p)],m=L(e)==="Stack"?Array.isArray(c)?c[0]:c:n;return $e.cloneElement(e,{active:m},u)}function wa(e,t,o){let n=D(e,"path"),r=t==null?void 0:t.length,{id:s=Xn()}=T(o);return r?[r,t.concat(N(o,`${n}.${r}`,{id:s,key:s}))]:[0,[N(o,`${n}.0`,{id:s})]]}function gt(e,t,o,n,r,s,i){let{active:a,children:l,path:c}=T(e),u=D(t,"path"),{idx:m,finalStep:p}=X(c,u),[d,g]=p?Ra(e,l,m,o,n,r,s,i):[a,l.map((y,h)=>h===m?gt(y,t,o,n,r,s,i):y)],f=L(e)==="Stack"?d:a;return $e.cloneElement(e,{active:f},g)}function Ra(e,t,o,n,r,s,i,a){let l=U(n);return l!=null&&l.width&&(l!=null&&l.height)?Sa(e,t,o,n,r,i,a):qn(e,t,o,n,r,(s==null?void 0:s.width)||(s==null?void 0:s.height),i)}var Ta=(e,t,{top:o,right:n,bottom:r,left:s},[i,a,l,c])=>{if(e==="column"&&t==="before")return a-o;if(e==="column")return r-c;if(e==="row"&&t==="before")return i-s;if(e==="row")return n-l};function Sa(e,t,o,n,r,s,i){let{style:{flexDirection:a}}=T(e),[l,c,u]=Hn(a),{[c]:m,[l]:p}=U(n),d=D(t[o],"path"),g=Ta(a,r,s,i),[f,y]=m<s[c]?[He(n,u,d,s,i),p]:[n,void 0],h=g?J(d,g,{flexGrow:0,flexShrink:0}):void 0;return m>s[c]&&(t=t.map(b=>{if(D(b,"placeholder"))return b;{let{[c]:v}=U(b);return v&&v<m?He(b,u,D(b,"path")):b}})),qn(e,t,o,f,r,y,s,h)}function qn(e,t,o,n,r,s,i,a){let l=D(e,"path"),c=0,u=!t||t.length===0?[n]:t.reduce((m,p,d)=>{if(o===d){let[g,f]=Pa(e,p,n,i);r==="before"?a?m.push(a,f,g):m.push(f,g):a?m.push(g,f,a):m.push(g,f),c=m.indexOf(f)}else m.push(p);return m},[]).map((m,p)=>p<c?m:N(m,`${l}.${p}`));return[c,u]}function Pa(e,t,o,n){let r=Xn(),{version:s=0}=T(o);if(s+=1,L(e)==="Flexbox"){let[i]=Un(e.props.style),a=6,l={[i]:(n[i]-a)/2},c=qt(t,i,l),u=qt(o,i,l);return[$e.cloneElement(t,{style:c}),$e.cloneElement(o,{id:r,version:s,style:u})]}else{let{style:{left:i,top:a,flex:l,...c}={left:void 0,top:void 0,flex:void 0}}=T(o);return[t,$e.cloneElement(o,{id:r,version:s,style:c})]}}import{cloneElement as Ma}from"react";import yt from"react";function Jn(e,{target:t,replacement:o}){return no(e,t,o)}function no(e,t,o){let n=D(t,"path"),r=D(t,"resizeable"),{style:s}=T(t),i=Ne(yt.cloneElement(o,{resizeable:r,style:{...s,...o.props.style}}),n);return _(e,t,i)}function _(e,t,o,n){if(e===t)return o;let{idx:r,finalStep:s}=X(D(e,"path"),D(t,"path")),i=e.props.children.slice();return s?n?n===we.MINIMIZE?i[r]=Da(e,i[r]):n===we.RESTORE&&(i[r]=La(i[r])):i[r]=o:i[r]=_(i[r],t,o,n),yt.cloneElement(e,void 0,i)}function Da(e,t){let{style:o}=T(e),{style:n}=T(t),{width:r,height:s,flexBasis:i,flexShrink:a,flexGrow:l,...c}=n,u={width:r,height:s,flexBasis:i,flexShrink:a,flexGrow:l},m={...c,flexBasis:0,flexGrow:0,flexShrink:0},p=o.flexDirection==="row"?"vertical":o.flexDirection==="column"?"horizontal":!1;return p?yt.cloneElement(t,{collapsed:p,restoreStyle:u,style:m}):t}function La(e){let{style:t,restoreStyle:o}=T(e),{flexBasis:n,flexShrink:r,flexGrow:s,...i}=t,a={...i,...o};return yt.cloneElement(e,{collapsed:!1,style:a,restoreStyle:void 0})}function Qn(e,{fromIndex:t,path:o,toIndex:n}){let r=z(e,o,!0),{children:s}=T(r),i=Ca(s,t,n),a=Ma(r,void 0,i);return _(e,r,a)}function Ca(e,t,o){let n=e.slice(),[r]=n.splice(t,1);return o===-1?n.concat(r):(n.splice(o,0,r),n)}var F={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"},af=e=>["switch-active-layout","open-layout","close-layout","rename-layout"].includes(e),lf=e=>["switch-active-tab","edit-feature-title","save-feature-props","remove-component","resize-component","drag-drop-operation"].includes(e);import he from"react";function ro(e,{path:t}){let o=z(e,t),n=te(e,t);if(n===null)return e;let{children:r}=T(n);if(r.length>1&&tr(r,t)){let{style:{flexBasis:s,display:i,flexDirection:a,...l}}=T(n),c=D(n,"path"),u=_(e,n,J(c,s,l));for(;(n=te(u,c))&&D(n,"path")!=="0";){let{children:m}=T(n);if(tr(m)){c=D(n,"path");let{style:{flexBasis:p,display:d,flexDirection:g,...f}}=T(n);u=_(e,n,J(c,p,f))}else if(ka(m))u=rr(e,n);else break}return u}return or(e,o)}function or(e,t){let o=T(e),{children:n,path:r,preserve:s}=o,{active:i}=o,{idx:a,finalStep:l}=X(r,D(t,"path")),c=L(e),u=n.slice();if(l){if(u.splice(a,1),i!==void 0&&i>=a&&(i=Math.max(0,i-1)),u.length===1&&!s&&r!=="0"&&c.match(/Flexbox|Stack/))return Ia(e,u[0]);!u.some(Aa)&&u.some(nr)&&(u=Ha(u))}else u[a]=or(u[a],t);return u=u.map((m,p)=>N(m,`${r}.${p}`)),he.cloneElement(e,{active:i},u)}function Ia(e,t){let o=L(e),{path:n,style:{flexBasis:r,flexGrow:s,flexShrink:i,width:a,height:l}}=T(e),c=N(t,n);if(n==="0")c=he.cloneElement(c,{style:{...t.props.style,width:a,height:l}});else if(o==="Flexbox"){let u=e.props.style.flexDirection==="column"?"height":"width",{style:{[u]:m,...p}}=c.props;c=he.cloneElement(c,{flexFill:void 0,style:{...p,flexGrow:s,flexShrink:i,flexBasis:r,width:a,height:l}})}return c}var Aa=e=>e.props.style.flexGrow>0,nr=e=>{let{width:t,height:o,flexGrow:n}=e.props.style;return n===0&&typeof t!="number"&&typeof o!="number"},Ha=e=>e.map(t=>nr(t)?he.cloneElement(t,{style:{...t.props.style,flexGrow:1}}):t),ka=e=>{if(e&&e.length>0){let t=D(e[0],"placeholder"),o=!1;for(let n=1;n<e.length;n++){if(o=D(e[n],"placeholder"),t&&o)return!0;t=o}}},rr=(e,t)=>{let{children:o,path:n}=T(e),{idx:r,finalStep:s}=X(n,D(t,"path")),i=o.slice();return s?i[r]=Oa(t):i[r]=rr(i[r],t),i=i.map((a,l)=>N(a,`${n}.${l}`)),he.cloneElement(e,void 0,i)},Oa=e=>{let{children:t}=T(e),o=[],n=[];for(let s=0;s<t.length;s++)D(t[s],"placeholder")?n.push(t[s]):(n.length===1?o.push(n.pop()):n.length>0&&(o.push(er(n)),n.length=0),o.push(t[s]));n.length===1?o.push(n.pop()):n.length>0&&o.push(er(n));let r=D(e,"path");return he.cloneElement(e,void 0,o.map((s,i)=>N(s,`${r}.${i}`)))},er=([e,...t])=>{let o=D(e,"style"),{flexBasis:n,flexGrow:r,flexShrink:s}=o;for(let{props:{style:i}}of t)n+=i.flexBasis,r=Math.max(r,i.flexGrow),s=Math.max(s,i.flexShrink);return he.cloneElement(e,{style:{...o,flexBasis:n,flexGrow:r,flexShrink:s}})},tr=(e,t)=>e.every(o=>D(o,"placeholder")||t&&D(o,"path")===t);import so from"react";function sr(e,{path:t,size:o}){let n=z(e,t,!0),{style:r}=T(n),s={...r,width:o},i=so.cloneElement(n,{style:s});return _(e,n,i)}function ir(e,{path:t,sizes:o}){let n=z(e,t,!0),{children:r,style:s}=T(n),i=s.flexDirection==="column"?"height":"width",a=za(r,o,i),l=so.cloneElement(n,void 0,a);return _(e,n,l)}function za(e,t,o){return e.map((n,r)=>{let{style:{[o]:s,flexBasis:i}}=T(n),a=t[r],{currentSize:l,flexBasis:c}=a,m=l!==void 0?a.currentSize:c;return m===void 0||s===m||i===m?n:so.cloneElement(n,{style:Ba(n.props.style,o,m)})})}function Ba(e,t,o){let n=typeof e[t]=="number",{flexShrink:r=1,flexGrow:s=1}=e;return{...e,[t]:n?o:"auto",flexBasis:n?"auto":o,flexShrink:r,flexGrow:s}}import{uuid as Na}from"@vuu-ui/vuu-utils";import bt from"react";var ar=e=>{let[t]=L(e);return t===t.toLowerCase()};function We(e,t,o,n,r,s){let{children:i,path:a}=T(e),l=D(t,"path"),{idx:c,finalStep:u}=X(a,l),m=u?Fa(e,i,t,o,n,r,s):i.map((p,d)=>d===c?We(p,t,o,n,r,s):p);return bt.cloneElement(e,void 0,m)}function Fa(e,t,o,n,r,s,i){let a=U(n);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 Wa(t,o,n,r,s,i)}return $a(e,t,o,n,r)}function $a(e,t,o,n,r){var x;let{version:s=0}=T(n),i=D(o,"path"),{type:a,flexDirection:l,showTabs:c}=cr(r),[u,m,p]=Va(a,o,n,l,r),d=lr(r),g=d?1:0,f={resizeable:!0,style:p,version:s+1},h={[ar(o)?"data-resizeable":"resizeable"]:!0,style:m},b=a==="Stack"?{showTabs:c}:void 0,v=a==="Flexbox"?{splitterSize:(x=L(e)==="Flexbox"&&e.props.splitterSize)!=null?x:void 0}:void 0,w=Na(),R=bt.createElement(ue[a],{active:g,id:w,key:w,path:D(o,"path"),flexFill:D(o,"flexFill"),...v,...b,style:u,resizeable:D(o,"resizeable")},d?[N(o,`${i}.0`,h),Ne(bt.cloneElement(n,f),`${i}.1`)]:[Ne(bt.cloneElement(n,f),`${i}.0`),N(o,`${i}.1`,h)]);return t.map(E=>E===o?R:E)}function Wa(e,t,o,n,r,s){let{flexDirection:i}=cr(n),a=i==="column"?"row":"column",l=lr(n),[c,u,m,p]=s,[d,g]=i==="column"?[u-r.top,r.bottom-p]:[c-r.left,r.right-m],f=D(t,"path"),y=0,h=ar(t)?"data-resizeable":"resizeable",b=[];d&&b.push(l?N(t,`${f}.${y++}`,{[h]:!0,style:{flexBasis:d,flexGrow:1,flexShrink:1}}):J(`${f}.${y++}`,d,{flexGrow:0,flexShrink:0})),b.push(He(o,a,`${f}.${y++}`,r,s)),g&&b.push(l?J(`${f}.${y++}`,0):N(t,`${f}.${y++}`,{[h]:!0,style:{flexBasis:0,flexGrow:1,flexShrink:1}}));let v=Jt(i,t.props,b,f);return e.map(w=>w===t?v:w)}function Va(e,t,o,n,r){let s={...t.props.style,flexDirection:n},i=e==="Flexbox"&&n==="column"?"height":"width",a=jt(o,i,r),l=jt(t,i);return[s,l,a]}var lr=e=>{var t;return e.position.SouthOrEast?!0:((t=e==null?void 0:e.tab)==null?void 0:t.positionRelativeToTab)==="before"?!1:!!e.position.Header};function cr(e){return e.position.Header?{type:"Stack",flexDirection:"column",showTabs:!0}:{type:"Flexbox",flexDirection:e.position.EastOrWest?"row":"column"}}var fr=(e,t)=>{switch(t.type){case F.ADD:return Ya(e,t);case F.DRAG_DROP:return Ua(e,t);case F.MAXIMIZE:return Ka(e,t);case F.REMOVE:return ro(e,t);case F.REPLACE:return Jn(e,t);case F.SET_PROP:return ur(e,t);case F.SET_PROPS:return Ga(e,t);case F.SET_TITLE:return ur(e,{type:"set-prop",path:t.path,propName:"title",propValue:t.title});case F.SPLITTER_RESIZE:return ir(e,t);case F.LAYOUT_RESIZE:return sr(e,t);case F.SWITCH_TAB:return _a(e,t);case F.MOVE_CHILD:return Qn(e,t);default:return e}},_a=(e,{path:t,nextIdx:o})=>{let n=z(e,t,!0),r=io.cloneElement(n,{active:o});return _(e,n,r)},ur=(e,{path:t,propName:o,propValue:n})=>{let r=z(e,t,!0),s=io.cloneElement(r,{[o]:n});return _(e,r,s)},Ga=(e,{path:t,props:o})=>{let n=z(e,t,!0),r=io.cloneElement(n,o);return _(e,n,r)},Ka=(e,{path:t,type:o})=>{if(t){let n=z(e,t,!0);return _(e,n,n,o)}else return e},Ua=(e,t)=>{var g,f;let{draggedReactElement:o,dragInstructions:n,dropTarget:r}=t,s=r.component,{pos:i}=r,a=((g=i==null?void 0:i.position)==null?void 0:g.Header)&&L(s)==="Stack",{id:l,version:c}=T(o),u=U(o),m;if(a){let[y,h]=jn(s,i);y===void 0?m=ht(e,s,o):m=gt(e,y,o,h)}else!u&&((f=i==null?void 0:i.position)!=null&&f.Centre)?m=no(e,s,o):m=Za(e,r,o);if(n.DoNotRemove)return m;let p=oe(m,y=>y.id===l&&y.version===c),d=D(p,"path");return ro(m,{path:d,type:"remove"})},Ya=(e,{path:t,component:o})=>ht(e,z(e,t),o),Za=(e,t,o)=>{let{component:n,pos:r,clientRect:s,dropRect:i}=t,a=D(n,"path");if(a==="0.0")return We(e,n,o,r);let l=te(e,a);if(pr(r,l)){let c=r.position.SouthOrEast?"after":"before";return gt(e,n,o,c,r,s,i)}if(!pr(r,l))return We(e,n,o,r,s,i);if(W(L(l)))return We(e,n,o,r);throw Error(`no support right now for position = ${r.position}`)},pr=(e,t)=>e.position.Centre?dr(t)||mr(t):e.position.NorthOrSouth?mr(t):e.position.EastOrWest?dr(t):!1,mr=e=>L(e)==="Flexbox"&&e.props.style.flexDirection==="column",dr=e=>L(e)==="Flexbox"&&e.props.style.flexDirection!=="column";import{createContext as Xa}from"react";var ja=e=>console.log(`dispatch ${e.type}, have you forgotten to provide a LayoutProvider ?`),Ve=Xa({dispatchLayoutProvider:ja,version:-1});import{useCallback as xt,useRef as ao}from"react";var qa={},hr=[0,0],Ja=(e,t,o)=>{let n=document.createElement("div");n.className="vuuSimpleDraggableWrapper",n.classList.add("vuuSimpleDraggableWrapper","salt-theme","salt-density-medium"),n.dataset.dragging="true";let r=o!=null?o:document.createElement("div");r.id=t,n.appendChild(r),document.body.appendChild(n);let s=`top:${e.top}px;left:${e.left}px;width:${e.width}px;height:${e.height}px;`;return[n,s,e.left,e.top]},Qa=e=>{let{offsetParent:t}=e;if(t===null)return hr;{let{left:o,top:n}=t.getBoundingClientRect();return[o,n]}},gr=(e,t,o)=>{let n=ao(),r=ao(),s=ao(),i=xt((u,m)=>{if(r.current&&s.current){let{dragOffsets:[p,d],targetPosition:g}=r.current,f=typeof u=="number"?u-p:g.left,y=typeof m=="number"?m-d:g.top;(f!==g.left||y!==g.top)&&(r.current.targetPosition.left=f,r.current.targetPosition.top=y,s.current.style.top=y+"px",s.current.style.left=f+"px")}},[]),a=xt(u=>{if(r.current){let{dragInstructions:m,payload:p,originalCSS:d}=r.current;u&&t({type:"drag-drop",draggedReactElement:p,dragInstructions:m,dropTarget:u}),s.current&&(!u&&m.DriftHomeIfNoDropTarget?(console.log("drift back to start"),document.body.removeChild(s.current)):m.RemoveDraggableOnDragEnd?document.body.removeChild(s.current):(s.current.style.cssText=d,delete s.current.dataset.dragging)),n.current=void 0,r.current=void 0,s.current=void 0}},[t]),l=xt(u=>{if(n.current){let{payload:m,dragContainerPath:p,dragElement:d,dragRect:g,instructions:f=qa,path:y}=n.current,{current:h}=e,b={x:u.clientX,y:u.clientY},v=m!=null?m:z(h,y,!0),{id:w}=v.props,R=U(v),x="",E="",P="",I=-1,M=-1,A=hr,k=document.getElementById(w);if(k===null)[k,E,I,M]=Ja(g,w,d);else{A=Qa(k);let[S,C]=A,{width:H,height:G,left:B,top:Z}=k.getBoundingClientRect();I=B-S,M=Z-C,E=`width:${H}px;height:${G}px;left:${I}px;top:${M}px;z-index: 100;background-color:#ccc;opacity: 0.6;`,k.dataset.dragging="true",x=k.style.cssText}P=Zt.initDrag(e.current,p,g,b,{drag:i,drop:a},R),k.style.cssText=E+P,s.current=k,r.current={payload:v,originalCSS:x,dragRect:g,dragOffsets:A,dragInstructions:f,targetPosition:{left:I,top:M}}}},[i,a,e]);return xt(u=>{let{evt:m,...p}=u;n.current={...p,dragContainerPath:Ot(e.current,o)},Zt.handleMousedown(m,l,p.instructions)},[l,o,e])};import{jsx as vr}from"react/jsx-runtime";var br=e=>e.dropTarget,ol=e=>["drag-drop","remove","set-title","splitter-resize","switch-tab"].includes(e.type),xr=e=>{switch(e.type){case"switch-tab":return e.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")}},Ih=()=>{let e=nl();return vr("div",{children:`Context: ${e} `})},Ah=e=>{let{children:t,createNewChild:o,pathToDropTarget:n,layout:r,onLayoutChange:s}=e,i=yr(void 0),a=yr(t),[,l]=tl(null),c=lo((d,g)=>{if(console.log(`serialize state ${g}`),s){let f=oe(d,br)||i.current,h=L(f)==="DraggableLayout"?T(f).children[0]:f,b=Yn(h);s(b,g)}},[s]),u=lo((d,g=!1)=>{let f=fr(i.current,d);f!==i.current&&(i.current=f,l({}),!g&&ol(d)&&c(f,xr(d)))},[l,c]),m=lo(d=>{switch(d.type){case"drag-start":{p(d);break}case"save":{c(i.current,xr(d));break}default:{u(d);break}}},[u,c]),p=gr(i,m,n);return el(()=>{if(r){let d=oe(i.current,br);if(d){let g=Xo(d),f=Fe(r,`${d.props.path}.0`),y=g?{type:F.REPLACE,target:g,replacement:f}:{type:F.ADD,path:d.props.path,component:f};u(y,!0)}else if(r.id===D(i.current,"id")){let g=Fe(r,"0"),f={type:F.REPLACE,target:i.current,replacement:g};u(f,!0)}}},[u,r]),i.current===void 0?i.current=oo(t):t!==a.current&&(i.current=oo(t,i.current),a.current=t),vr(Ve.Provider,{value:{createNewChild:o,dispatchLayoutProvider:m,version:0},children:i.current})},Q=()=>{let{dispatchLayoutProvider:e}=co(Ve);return e},Er=()=>{let{createNewChild:e}=co(Ve);return e},nl=()=>{let{version:e}=co(Ve);return e};import{jsx as sl}from"react/jsx-runtime";var wr=function(t){let{path:o}=t,n=Q(),r=rl(s=>{n({type:we.SPLITTER_RESIZE,path:o,sizes:s})},[n,o]);return sl(eo,{...t,onSplitterMoved:r})};wr.displayName="Flexbox";O("Flexbox",wr,"container");import{useForkRef as Sl}from"@salt-ds/core";import Pl from"classnames";import{forwardRef as Dl,useMemo as Ll}from"react";import{useCallback as Lr,useEffect as pl,useRef as mo,useState as ml}from"react";import{useCallback as il,useLayoutEffect as Rr,useRef as al}from"react";var Sr=["height","width"],Yh=["height"],Zh=["width"],ge=new WeakMap,Pr=(e,t,o)=>{switch(o){case"height":return t.height;case"scrollHeight":return e.scrollHeight;case"scrollWidth":return e.scrollWidth;case"width":return t.width;default:return 0}},Tr=new ResizeObserver(e=>{for(let t of e){let{target:o,contentRect:n}=t,r=ge.get(o);if(r){let{onResize:s,measurements:i}=r,a=!1;for(let[l,c]of Object.entries(i)){let u=Pr(o,n,l);u!==c&&(a=!0,i[l]=u)}a&&s&&s(i)}}});function Et(e,t,o,n=!1){let r=al(t),s=il(i=>{let a=i.getBoundingClientRect();return r.current.reduce((l,c)=>(l[c]=Pr(i,a,c),l),{})},[]);Rr(()=>{let i=e.current,a=!1;async function l(){ge.set(i,{measurements:{}}),a=!1;let{fonts:c}=document;if(c&&await c.ready,!a){let u=ge.get(i);if(u){let m=s(i);u.measurements=m,Tr.observe(i),n&&o(m)}}}if(i){if(ge.has(i))throw Error("useResizeObserver attemping to observe same element twice");l()}return()=>{i&&ge.has(i)&&(Tr.unobserve(i),ge.delete(i),a=!0)}},[e,s,n,o]),Rr(()=>{let i=e.current,a=ge.get(i);if(a){if(r.current!==t){r.current=t;let l=s(i);a.measurements=l}a.onResize=o}},[t,s,e,o])}function ll(e,t){let o=document.body.querySelector(`.${e}`),n={get:function(r,s){let i=r.getPropertyValue(`--${e}-breakpoint-${s}`);return i?parseInt(i):void 0}};return o?new Proxy(getComputedStyle(o),n):t!=null?t:{}}var cl=([,e],[,t])=>t-e,po=e=>Object.entries(e).sort(cl).map(([t,o],n,r)=>[t,o,n<r.length-1?r[n+1][1]:9999]),uo=null,ul=(e="salt")=>{let{xs:t,sm:o,md:n,lg:r,xl:s}=ll(e);return po({xs:t,sm:o,md:n,lg:r,xl:s})},Dr=e=>(uo===null&&(uo=ul(e)),uo);var dl=[],Mr=({breakPoints:e,smallerThan:t},o)=>{let[n,r]=ml(t?!1:"lg"),s=mo(document.body),i=mo(e?po(e):Dr()),a=mo("lg"),l=Lr(u=>{if(i.current){for(let[m,p]of i.current)if(u>=p)return m}},[i]),c=Lr(u=>{if(t){let m=i.current.find(([p])=>p===t);if(m){let[,,p]=m;return u<p}}else return l(u);return u},[t,l]);return Et(o||s,i.current?["width"]:dl,({width:u})=>{let m=c(u);m!==a.current&&(a.current=m,r(m))},!0),pl(()=>{let u=o||s;if(u.current){let m=a.current;if(i.current){let{clientWidth:p}=u.current,d=c(p);a.current=d,d!==m&&r(d)}}},[r,c,o]),n};var Cr="data-collapsible",fl={[Cr]:!0,"data-pad-start":!0,"data-pad-end":!0},hl=e=>{var t;return(t=fl[e])!=null?t:!1},gl=e=>e===Cr,yl={dynamic:"dynamic",instant:"instant",true:"instant"},bl=e=>{var t;return(t=yl[e])!=null?t:"none"},ng=e=>Object.keys(e).reduce((t,o)=>{let[n,r]=t;if(hl(o)){let s=gl(o)?bl(e[o]):e[o];n[o]=s,r[o]=void 0}return t},[{},{}]);import{getUniqueId as xl}from"@vuu-ui/vuu-utils";import{cloneElement as El,isValidElement as vl,useCallback as wl,useMemo as Ir,useRef as fo}from"react";var Rl=["xs","sm","md","lg","xl"],Tl=12,Ar=({children:e,cols:t,style:o})=>{let n=fo(null),r=fo(null),s=fo(),i=t!=null?t:Tl,l=(o==null?void 0:o.flexDirection)==="column"?"height":"width",c=Ir(()=>Array.isArray(e)?e:vl(e)?[e]:[],[e]),u=wl((m,p)=>{let d=pt(m,p,Rl),g=[],f=[];for(let y=0;y<m.length;y++){let h=m[y],{style:{flex:b,...v}}=h.props;g.push(El(h,{key:xl(),style:{...v,"--parent-col-count":i}})),f.push(d[y])}return[g,f]},[i]);return Ir(()=>{let[m,p]=u(c,l);r.current=p,s.current=m},[u,c,l]),{cols:i,content:s.current,rootRef:n}};import{jsx as Ml}from"react/jsx-runtime";var vt="hwFluidGrid",ho=Dl(function(t,o){let{breakPoints:n,children:r,column:s,cols:i=12,className:a,flexFill:l,gap:c=3,fullPage:u,id:m,onSplitterMoved:p,resizeable:d,row:g,showGrid:f,spacing:y,splitterSize:h,style:b,...v}=t,w=Ll(()=>xe(r),[r]),{cols:R,content:x,rootRef:E}=Ar({children:w,cols:i,style:b}),P=Mr({breakPoints:n},E),I=Pl(vt,a,{[`${vt}-column`]:s,[`${vt}-row`]:g,[`${vt}-show-grid`]:f,"flex-fill":l,"full-page":u}),M={...b,"--spacing":y,"--grid-col-count":R,"--grid-gap":c};return Ml("div",{...v,className:I,"data-breakpoint":P,"data-cols":R,"data-resizeable":d||void 0,id:m,ref:Sl(E,o),style:M,children:x})});ho.displayName="FluidGrid";import{jsx as Cl}from"react/jsx-runtime";var Hr=function(t){return Cl(ho,{...t})};Hr.displayName="FluidGrid";O("FluidGrid",Hr,"container");import{EditableLabel as Gl}from"@vuu-ui/vuu-ui-controls";import{Button as Kl}from"@salt-ds/core";import{default as Ul,default as Yl}from"classnames";import{cloneElement as Gr,useRef as Zl,useState as Kr}from"react";import{useCallback as _e,useState as Il}from"react";var wt=(e,t,o,n)=>{var y;let{loadSessionState:r,purgeSessionState:s,purgeState:i,saveSessionState:a}=Te(),[l,c]=Il((y=r(e,"contributions"))!=null?y:[]),u=Q(),m=_e((h,b)=>{let v=l.concat([{location:h,content:b}]);a(e,"contributions",v),c(v)},[l,e,a]),p=_e(()=>{s(e,"contributions"),c([])},[e,s]),d=_e(()=>{let h=r(e,"data-source");h&&h.unsubscribe(),s(e),i(e),u({type:"remove",path:o})},[u,e,r,s,i,o]),g=_e(async(h,b,v)=>{var R;h.stopPropagation();let w=(R=t.current)==null?void 0:R.getBoundingClientRect();return new Promise((x,E)=>{u({type:"drag-start",evt:h,path:b===void 0?o:`${o}.${b}`,dragRect:w,preDragActivity:v,dropTargets:n,resolveDragStart:x,rejectDragStart:E})})},[t,u,o,n]);return[_e(async(h,b)=>{var w;let{type:v}=h;switch(v){case"maximize":case"minimize":case"restore":return u({type:v,path:(w=h.path)!=null?w:o});case"remove":return d();case"mousedown":return g(b,h.index,h.preDragActivity);case"add-toolbar-contribution":return m(h.location,h.content);case"remove-toolbar-contribution":return p();default:return}},[u,o,d,g,m,p]),l]};import{useForkRef as Ol,useIdMemo as zl}from"@salt-ds/core";import Bl from"classnames";import yo,{forwardRef as Nl,useCallback as Fl,useMemo as $l,useRef as Wr,useState as Wl}from"react";import{useCallback as ye,useMemo as kr}from"react";var Or=({id:e,rootRef:t,path:o,dropTargets:n,title:r})=>{let s=Q(),{loadState:i,loadSessionState:a,purgeState:l,saveState:c,saveSessionState:u}=Te(),[m,p]=wt(e,t,o,n),d=kr(()=>{var x;return(x=i("view-title"))!=null?x:r},[i,r]),g=ye(x=>{o&&s({type:"set-title",path:o,title:x})},[s,o]),f=kr(()=>i(e),[e,i]),y=ye(x=>i(e,x),[e,i]),h=ye(x=>{l(e,x),s({type:"save"})},[e,s,l]),b=ye((x,E)=>{c(e,E,x),s({type:"save"})},[e,s,c]),v=ye(x=>a(e,x),[e,a]),w=ye((x,E)=>u(e,E,x),[e,u]),R=ye(({type:x,...E})=>{let{[x]:P}=E;b(P,x)},[b]);return{contributions:p,dispatchViewAction:m,load:y,loadSession:v,onConfigChange:R,onEditTitle:g,purge:h,restoredState:f,save:b,saveSession:w,title:d}};import{useCallback as zr,useRef as Br}from"react";var Al=[],Nr=({mainRef:e,resize:t="responsive",rootRef:o})=>{let n=t==="defer",r=Br({}),s=Br(),i=zr(()=>{e.current&&(e.current.style.height=r.current.height+"px",e.current.style.width=r.current.width+"px"),s.current=void 0},[e]),a=zr(({height:l,width:c})=>{r.current.height=l,r.current.width=c,s.current!==null&&clearTimeout(s.current),s.current=window.setTimeout(i,40)},[i]);Et(o,n?Sr:Al,a,n)};import Hl,{useContext as Fr}from"react";var kl={dispatch:null},Rt=Hl.createContext(kl),$r=()=>{var t;let e=Fr(Rt);return(t=e==null?void 0:e.dispatch)!=null?t:null},oy=()=>Fr(Rt);import{jsx as go,jsxs as _l}from"react/jsx-runtime";var Ge="vuuView",Vl=(e,t)=>e&&t?{...e,...t}:e||t,Vr=Nl(function(t,o){let{Header:n=_r,children:r,className:s,collapsed:i,closeable:a,"data-path":l,"data-resizeable":c,dropTargets:u,expanded:m,flexFill:p,id:d,header:g,orientation:f="horizontal",path:y=l,resize:h="responsive",resizeable:b=c,tearOut:v,style:w={},title:R,...x}=t,E=zl(d),P=Wr(null),I=Wr(null),[M,A]=Wl(),{contributions:k,dispatchViewAction:S,load:C,loadSession:H,onConfigChange:G,onEditTitle:B,purge:Z,restoredState:ee,save:No,saveSession:Fo,title:Ct}=Or({id:E,rootRef:P,path:y,dropTargets:u,title:R});Nr({mainRef:I,resize:h,rootRef:P});let $o=Fl(Vs=>{A(Vs)},[]),Fs=()=>yo.isValidElement(r)&&(ee||M)?yo.cloneElement(r,Vl(ee,M)):r,$s=$l(()=>({dispatch:S,id:E,path:y,title:Ct,load:C,loadSession:H,onConfigChange:G,purge:Z,save:No,saveSession:Fo,setComponentProps:$o}),[S,E,C,H,G,y,Z,No,Fo,$o,Ct]),Ws=typeof g=="object"?g:{};return go("div",{...x,className:Bl(Ge,s,{[`${Ge}-collapsed`]:i,[`${Ge}-expanded`]:m,[`${Ge}-resize-defer`]:h==="defer"}),"data-resizeable":b,id:E,ref:Ol(o,P),style:w,tabIndex:-1,children:_l(Rt.Provider,{value:$s,children:[g?go(n,{...Ws,collapsed:i,contributions:k,expanded:m,closeable:a,onEditTitle:B,orientation:f,tearOut:v,title:Ct}):null,go("div",{className:`${Ge}-main`,ref:I,children:Fs()})]})})});Vr.displayName="View";var Se=yo.memo(Vr);Se.displayName="View";O("View",Se,"view");import{jsx as Ke}from"react/jsx-runtime";var bo="vuuHeader",_r=({className:e,contributions:t,collapsed:o,closeable:n,onEditTitle:r,orientation:s="horizontal",style:i,title:a="Untitled"})=>{let l=Zl(null),[c,u]=Kr(a),[m,p]=Kr(!1),d=$r(),g=M=>d==null?void 0:d({type:"remove"},M),f=()=>{var M;(M=l.current)==null||M.focus()},y=M=>{M.stopPropagation()},b=Ul(bo,e,`${bo}-${o||s}`),v=()=>{p(!0)},w=M=>{M.key==="Enter"&&p(!0)},R=(M="",A="",k=!0,S=!1)=>{var C;p(!1),S?u(M):A!==M&&(u(A),r==null||r(A)),k===!1&&((C=l.current)==null||C.focus())},x=M=>{d==null||d({type:"mousedown"},M)},E=[],P=[],I=[];return t==null||t.forEach((M,A)=>{switch(M.location){case"pre-title":E.push(Gr(M.content,{key:A}));break;default:P.push(Gr(M.content,{key:A}))}}),a&&E.push(Ke(Gl,{className:`${bo}-title`,editing:m,value:c,onChange:u,onMouseDownCapture:f,onEnterEditMode:v,onExitEditMode:R,onKeyDown:w,ref:l,tabIndex:0},"title")),n&&I.push(Ke(Kl,{"data-icon":"close",onClick:g,onMouseDown:y,variant:"secondary"},"close")),P.length>0&&E.push(Ke("div",{className:"vuuTooltrayProxy","data-align":"end",children:P},"contributions")),I.length>0&&E.push(Ke("div",{className:"vuuTooltrayProxy","data-align":"end",children:I},"actions")),Ke("div",{className:Yl("vuuToolbarProxy",b),style:i,onMouseDown:x,children:E})};import{forwardRef as cc}from"react";import{isValidNumber as ce}from"@vuu-ui/vuu-utils";import{useCallback as ql,useEffect as Jl,useMemo as Ql,useRef as ec,useState as tc}from"react";import{useCallback as Xl,useEffect as Ur,useRef as jl}from"react";var be=new Map,Zr=(e,t,o)=>{switch(o){case"height":return t.height;case"clientHeight":return e.clientHeight;case"clientWidth":return e.clientWidth;case"contentHeight":return t.contentHeight;case"contentWidth":return t.contentWidth;case"scrollHeight":return Math.ceil(e.scrollHeight);case"scrollWidth":return Math.ceil(e.scrollWidth);case"width":return t.width;default:return 0}},Yr=new ResizeObserver(e=>{for(let t of e){let{target:o,borderBoxSize:n,contentBoxSize:r}=t,s=be.get(o);if(s){let[{blockSize:i,inlineSize:a}]=n,[{blockSize:l,inlineSize:c}]=r,{onResize:u,measurements:m}=s,p=!1;for(let[d,g]of Object.entries(m)){let f=Zr(o,{height:i,width:a,contentHeight:l,contentWidth:c},d);f!==g&&(p=!0,m[d]=f)}p&&u&&u(m)}}});function Xr(e,t,o,n=!1){let r=jl(t),s=Xl(i=>{let{width:a,height:l}=i.getBoundingClientRect(),{clientWidth:c,clientHeight:u}=i;return r.current.reduce((m,p)=>(m[p]=Zr(i,{width:a,height:l,contentHeight:u,contentWidth:c},p),m),{})},[]);Ur(()=>{let i=e.current;async function a(){be.set(i,{measurements:{}});let l=be.get(i);if(l){let c=s(i);l.measurements=c,Yr.observe(i),n&&o(c)}else console.log("%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation","font-weight:bold; color:red;")}return i&&(be.has(i)&&console.log("useResizeObserver attemping to observe same element twice",{target:i}),a()),()=>{i&&be.has(i)&&(Yr.unobserve(i),be.delete(i))}},[s,e]),Ur(()=>{let i=e.current,a=be.get(i);if(a){if(r.current!==t){r.current=t;let l=s(i);a.measurements=l}a.onResize=o}},[t,s,e,o])}var oc=["clientHeight","clientWidth"],nc=["clientWidth"],rc=["clientHeight"],sc=[],Tt=e=>Number.isFinite(e),ic={height:"100%",width:"100%"},ac=(e,t)=>ce(e)&&ce(t)?{height:`${e}px`,width:`${t}px`}:typeof e=="string"&&typeof t=="string"?{height:e,width:t}:ic,lc=(e,t)=>{if(ce(e)&&ce(t))return{height:e,width:t}},jr=({defaultHeight:e=0,defaultWidth:t=0,height:o,onResize:n,width:r})=>{let s=ec(null),[i,a]=tc({css:ac(o,r),inner:lc(o,r),outer:{height:o!=null?o:"100%",width:r!=null?r:"100%"}}),l=typeof o=="number",c=typeof r=="number",u=l&&c?sc:l?nc:c?rc:oc;Ql(()=>{a(p=>{let{inner:d,outer:g}=p;if(ce(o)&&ce(r)&&d&&g){let{height:f,width:y}=d,{height:h,width:b}=g;if(h!==o||b!==r){let v=ce(h)?h-f:0,w=ce(b)?b-y:0;return{...p,outer:{height:o,width:r},inner:{height:o-v,width:r-w}}}}return p})},[o,r]);let m=ql(({clientWidth:p,clientHeight:d})=>{let{css:g,inner:f,outer:y}=i,h=i;l&&Tt(p)&&p!==(f==null?void 0:f.width)?h={css:g,outer:y,inner:{width:Math.floor(p)||t,height:o}}:c&&Tt(d)&&d!==(f==null?void 0:f.height)?h={css:g,outer:y,inner:{height:Math.floor(d)||e,width:r}}:Tt(d)&&Tt(p)&&(p!==(f==null?void 0:f.width)||d!==(f==null?void 0:f.height))&&(h={css:g,outer:y,inner:{width:Math.floor(p)||t,height:Math.floor(d)||e}}),h!==i&&a(h)},[e,t,l,c,o,i,r]);return Jl(()=>{i.inner&&(n==null||n(i.inner))},[n,i.inner]),Xr(s,u,m,!0),{containerRef:s,cssSize:i.css,outerSize:i.outer,innerSize:i.inner}};import{useForkRef as uc}from"@salt-ds/core";import qr from"classnames";import{jsx as Jr}from"react/jsx-runtime";var xo="vuuMeasuredContainer",cb=cc(function({children:t,className:o,height:n,onResize:r,style:s,width:i,...a},l){let{containerRef:c,...u}=jr({height:n,onResize:r,width:i}),{cssSize:m,innerSize:p}=u,d=p===void 0,g=()=>d?{"--measured-css-height":`${m.height}`,"--measured-css-width":`${m.width}`}:{...s,"--measured-css-height":`${m.height}`,"--measured-css-width":`${m.width}`,"--measured-px-height":`${p==null?void 0:p.height}px`,"--measured-px-width":`${p==null?void 0:p.width}px`},f=uc(c,l);return d?Jr("div",{...a,className:qr(xo,`${xo}-ummeasured`),style:g(),ref:c}):Jr("div",{...a,className:qr(xo,o),ref:f,style:g(),children:t})});import{PopupMenu as Lc}from"@vuu-ui/vuu-popups";import Pt from"classnames";import To,{forwardRef as Mc}from"react";import{useDragDropNext as Tc}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as Sc,MEASURES as Pc}from"@vuu-ui/vuu-utils";import{useCallback as wo,useMemo as Ro,useRef as ls,useState as Dc}from"react";import{getElementByDataIndex as Qr}from"@vuu-ui/vuu-utils";var pc=".vuuOverflowContainer-item:not(.wrapped)",mc=e=>e.sort((t,o)=>{let{dataset:{index:n="?"}}=t,{dataset:{index:r="?"}}=o,s=t.classList.contains("wrapped"),i=o.classList.contains("wrapped"),a=n==="overflow",l=r==="overflow";return s&&!i?1:!s&&i?-1:a?1:l?-1:parseInt(n)>parseInt(r)?1:-1}),Eo=[],Ue=(e,t="horizontal")=>{let o=[],n=[],r=-1,s=!1,i=mc(Array.from(e.children)),a=t==="vertical"?"top":"left";for(let l of i){let c=l,{dataset:{index:u="?",label:m="?",overflowPriority:p="0"}}=c,{[a]:d}=c.getBoundingClientRect();d<=r?(u==="overflow"?n.push(o.pop()):n.push({index:u,label:m,overflowPriority:p}),s=!0):s?n.push({index:u,label:m,overflowPriority:p}):o.push({index:u,label:m,overflowPriority:p}),r=d}return[o,n]},es=(e,t)=>{let o=!1;t.find(({index:n})=>n==="overflow")&&t.length===1&&(o=!0);for(let n of e.children){let{dataset:{index:r="?"}}=n;t.length===0||o?e.classList.remove("overflowed"):e.classList.add("overflowed"),r!=="overflow"&&t.find(s=>s.index===r)?n.classList.add("wrapped"):n.classList.remove("wrapped")}},dc=(e,{overflowPriority:t})=>Math.max(e,parseInt(t)),fc=(e,{overflowPriority:t})=>Math.min(e,parseInt(t)),ts=e=>{var t;return e.length>1&&((t=e.at(-1))==null?void 0:t.index)==="overflow"},hc=e=>{let[t]=e;for(let o=1;o<e.length;o++){let n=e[o];parseInt(n.overflowPriority)>parseInt(t.overflowPriority)&&(t=n)}return t},os=(e,t)=>{var r;let o=e.reduce(fc,Number.MAX_SAFE_INTEGER);return t.reduce(dc,0)>o?!0:t.length>1&&((r=t.at(-1))==null?void 0:r.index)==="overflow"},ns=(e,t)=>new Promise(o=>{requestAnimationFrame(()=>{let[,n]=Ue(e);bc(t,n).forEach(s=>gc(e,s)),o(n)})}),rs=(e,t,o)=>new Promise(n=>{requestAnimationFrame(()=>{let[,r]=Ue(e),s=hc(r);if(s){let[i,a]=vo(e,s);n([i,a])}else n([t,o])})}),gc=(e,t)=>{let o=Qr(e,t.index);if(o)o.classList.add("wrapped");else throw Error(`markElementAsWrapped element item with index ${t.index} not found`)},yc=e=>Array.from(e.querySelectorAll(".wrapped")),bc=(e,t)=>{let o=[];for(let n of t)e.find(({index:r})=>r===n.index)||o.push(n);return o},xc=(e,t)=>{yc(e).forEach(n=>{let{dataset:{index:r="?"}}=n;t.find(s=>s.index===r)||n.classList.remove("wrapped")})},ss=e=>e.querySelector('[data-index="overflow"]'),Ec=e=>e.querySelector(".wrapped"),St=e=>parseInt(getComputedStyle(e).getPropertyValue("width")),is=(e,t)=>{let{right:o}=e.getBoundingClientRect(),n=parseInt(getComputedStyle(e).getPropertyValue("padding-right")),{right:r}=t.getBoundingClientRect();return o-n-r},as=e=>{let t=ss(e),o=is(e,t),n=St(t),r=Ec(e);return St(r)<=o+n?(e.classList.remove("overflowed"),r.classList.remove("wrapped"),!0):!1},vc=(e,t)=>{let{dataset:{index:o="0",overflowPriority:n="0"}}=e,{dataset:{index:r="0",overflowPriority:s="0"}}=t;return n>s?-1:n<s?1:parseInt(o)-parseInt(r)},wc=e=>Array.from(e.querySelectorAll(pc)).sort(vc),vo=(e,t)=>{let o=wc(e),n=Qr(e,t.index,!0),r=-1,s=o.at(r),i=St(s),a=St(n),l=ss(e),c=is(e,l)+i;if(c>=a)Rc(n,s);else{let{left:p}=s.getBoundingClientRect(),d=c,g=[s];for(;c<a;){r-=1,s=o.at(r),g.push(s);let{left:f}=s.getBoundingClientRect(),y=p-f;c=d+y}n==null||n.classList.remove("wrapped"),g.forEach(f=>{f.classList.add("wrapped")})}let[u,m]=Ue(e);return xc(e,m),[u,m]},Rc=(e,t)=>{if(!e||!t)throw Error("switchWrapOnElements, element undefined");e.classList.remove("wrapped"),t.classList.add("wrapped")};var cs=({allowDragDrop:e=!1,itemCount:t,onMoveItem:o,onSwitchWrappedItemIntoView:n,orientation:r="horizontal"})=>{let[s,i]=Dc(null),a=ls(Eo),l=ls(null),c=wo(async()=>{if(s){let[b,v]=Ue(s,r);for(es(s,v),ts(v)&&(v=await ns(s,v));os(b,v);)[b,v]=await rs(s,b,v);v.length===1&&as(s)&&(v=Eo),a.current=v}},[s,r]),u=b=>typeof b=="object"&&b!==null&&"overflowItem"in b,[m,p]=Ro(()=>[()=>{let{current:b}=a;return b.map(v=>({label:v.label,action:`activate-item-${v.index}`,options:{overflowItem:v}}))},({options:b})=>{if(s&&u(b)){let[,v]=vo(s,b.overflowItem);a.current=v,n==null||n(b.overflowItem)}return!0}],[s,n]),d=Ro(()=>{let{sizeProp:b}=Pc[r],v=0;return new ResizeObserver(w=>{for(let R of w){let{[b]:x}=R.contentRect,E=Math.round(x);Sc(E)&&v!==E&&(v=E,c())}})},[c,r]);tn(()=>{c()},[c,t]),Ro(()=>{s&&d.observe(s)},[s,d]);let g=wo(b=>{i(l.current=b)},[]),f=wo((b,v)=>{o==null||o(b,v)},[o]),{onMouseDown:y,...h}=Tc({allowDragDrop:e,containerRef:l,draggableClassName:"vuuOverflowContainer",onDrop:f,orientation:"horizontal",itemQuery:".vuuOverflowContainer-item"});return{menuActionHandler:p,menuBuilder:m,onItemMouseDown:y,rootRef:g,...h}};import{jsx as Ye,jsxs as Cc}from"react/jsx-runtime";var Pe="vuuOverflowContainer",us=To.memo(({allowDragDrop:e,children:t,className:o,height:n,id:r,onMoveItem:s,onSwitchWrappedItemIntoView:i,orientation:a="horizontal",overflowIcon:l,overflowPosition:c="end"})=>{let u=xe(t),{draggable:m,draggedItemIndex:p,menuActionHandler:d,menuBuilder:g,onItemMouseDown:f,rootRef:y}=cs({allowDragDrop:e,itemCount:u.length,onMoveItem:s,onSwitchWrappedItemIntoView:i,orientation:a});console.log(`Overflow container WRAPPER ${To.Children.count(t)} children`);let b={"--overflow-container-height":`${a==="vertical"?"100%":`${n}px`}`},v=Pt(`${Pe}-wrapContainer`,o,{[`${Pe}-horizontal`]:a==="horizontal",[`${Pe}-vertical`]:a==="vertical"}),w=u.map((x,E)=>{let{"data-align":P,"data-overflow-priority":I="0",id:M=`${r}-${E}`,label:A=`Item ${E+1}`}=x.props;return Ye("div",{className:Pt(`${Pe}-item`,{"vuuDraggable-dragAway":p===E}),"data-index":E,"data-align":P,"data-label":A,"data-overflow-priority":I,id:`${M}-wrapper`,onMouseDown:f,children:x},E)}),R=Ye("div",{className:`${Pe}-OverflowIndicator`,"data-index":"overflow",children:Ye(Lc,{icon:l,menuBuilder:g,menuActionHandler:d})},"overflow");return w.push(R),Cc("div",{className:v,ref:y,style:b,children:[w,m]})});us.displayName="OverflowContainer.InnerContainer";var ps=Mc(function({allowDragDrop:t=!1,children:o,className:n,height:r=44,id:s,onMoveItem:i,onSwitchWrappedItemIntoView:a,orientation:l,overflowIcon:c,overflowPosition:u,...m},p){let d=Ee(s);return console.log(`Overflow container ${To.Children.count(o)} children`),Ye("div",{...m,className:Pt(Pt(Pe,n)),id:d,ref:p,children:Ye(us,{allowDragDrop:t,height:r,id:d,orientation:l,overflowIcon:c,overflowPosition:u,onMoveItem:i,onSwitchWrappedItemIntoView:a,children:o})})});import{uuid as Ic}from"@vuu-ui/vuu-utils";import{List as Ac,ListItem as Hc}from"@vuu-ui/vuu-ui-controls";import ms from"classnames";import{cloneElement as kc,memo as Oc}from"react";import{jsx as So}from"react/jsx-runtime";var zc=e=>{let t=e.cloneNode(!0);return t.id="",delete t.dataset.idx,t},ds=Oc(({className:e,children:t,idx:o,resizeable:n,header:r,closeable:s,...i})=>So(Hc,{className:ms("vuuPaletteItem",e),"data-draggable":!0,"data-icon":"draggable",...i}));ds.displayName="PaletteItem";var Bc=({children:e,className:t,itemHeight:o=41,orientation:n="horizontal",ViewProps:r,...s})=>{let i=Q(),a="vuuPalette";function l(c){var P,I;let m=c.target.closest(".vuuPaletteItem"),p=parseInt((I=(P=m.dataset)==null?void 0:P.index)!=null?I:"-1"),{props:{caption:d,children:g,template:f,...y}}=e[p],{height:h,left:b,top:v,width:w}=m.getBoundingClientRect(),R=Ic(),E=f?g:So(Se,{...r,...{id:R,key:R},...y,title:y.label,children:g});i({dragRect:{left:b,top:v,right:b+w,bottom:v+150,width:w,height:h},dragElement:zc(m),evt:c.nativeEvent,instructions:{DoNotRemove:!0,DoNotTransform:!0,DriftHomeIfNoDropTarget:!0,RemoveDraggableOnDragEnd:!0,dragThreshold:10},path:"*",payload:E,type:"drag-start"})}return So(Ac,{...s,className:ms(a,t,`${a}-${n}`),itemHeight:o,selected:null,children:e.map((c,u)=>c.type===ds?kc(c,{key:u,onMouseDown:l}):c)})};O("Palette",Bc,"view");import{Tab as Nc,Tabstrip as Fc}from"@vuu-ui/vuu-ui-controls";import fs from"classnames";import Po,{forwardRef as $c,useCallback as Wc}from"react";import{jsx as gs,jsxs as Uc}from"react/jsx-runtime";var hs="Tabs",Vc=()=>{},_c=(e,t)=>{var o,n,r,s;return(s=(r=(o=e.props)==null?void 0:o.title)!=null?r:(n=e.props)==null?void 0:n["data-tab-title"])!=null?s:`Tab ${t+1}`},Gc=e=>{let t=[];return Po.Children.forEach(e,o=>{Po.isValidElement(o)?t.push(o):console.warn("Stack has unexpected child element type")}),t},Kc={allowAddTab:!1,allowCloseTab:!1,allowRenameTab:!1},Do=$c(function({active:t=0,children:o,className:n,getTabIcon:r=Vc,getTabLabel:s=_c,id:i,keyBoardActivation:a="manual",onAddTab:l,onMoveTab:c,onTabClose:u,onTabEdit:m,onTabSelectionChanged:p,showTabs:d="top",style:g,TabstripProps:f=Kc},y){var A;let h=Ee(i),{allowCloseTab:b,allowRenameTab:v,className:w}=f,R=Wc((k,S,C,H)=>{m==null||m(H,S)},[m]),x=()=>{var k;return Po.isValidElement(o)?o:Array.isArray(o)&&(k=o[t])!=null?k:null},E=()=>Gc(o).map((k,S)=>{let{closeable:C=b,id:H=`${h}-${S}`,"data-tab-location":G}=k.props;return gs(Nc,{ariaControls:H,"data-icon":r(k,S),id:`${H}-tab`,index:S,label:s(k,S),location:G,closeable:C,editable:v},H)}),P=x(),I=d==="left"||d==="right",M=I?"vertical":"horizontal";return Uc("div",{className:fs(hs,n,{[`${hs}-horizontal`]:I}),style:g,id:h,ref:y,children:[d?gs(Fc,{...f,activeTabIndex:(A=f==null?void 0:f.activeTabIndex)!=null?A:P===null?-1:t,allowDragDrop:f.allowDragDrop!==!1,animateSelectionThumb:!0,className:fs("vuuTabHeader",w),keyBoardActivation:a,onActiveChange:p,onAddTab:l,onCloseTab:u,onExitEditMode:R,onMoveTab:c,orientation:M,children:E()}):null,P]})});Do.displayName="Stack";import{useIdMemo as Yc}from"@salt-ds/core";import Zc,{useCallback as Lo,useRef as Xc}from"react";import{jsx as Mo}from"react/jsx-runtime";var jc=e=>Mo(Se,{resizeable:!0,title:`Tab ${e}`,style:{flexGrow:1,flexShrink:0,flexBasis:0},header:!0,closeable:!0,children:Mo(kt,{style:{flex:1}})}),ys=e=>{var R;let t=Xc(null),o=Q(),{loadState:n}=Te(),{createNewChild:r,id:s,onTabSelectionChanged:i,path:a,...l}=e,{children:c}=e,u=Yc(s),[m]=wt(u,t,a),p=Er(),d=(R=r!=null?r:p)!=null?R:jc,g=x=>{a&&(o({type:"switch-tab",id:u,path:a,nextIdx:x}),i==null||i(x))},f=Lo(x=>{if(Array.isArray(c)){let{props:{"data-path":E,path:P=E}}=c[x];o({type:"remove",path:P})}},[c,o]),y=Lo(()=>{if(a){let x=Zc.Children.count(c),E=d(x);o({type:"add",path:a,component:E})}},[c,d,o,a]),h=Lo((x,E)=>{a&&o({fromIndex:x,toIndex:E,path:a,type:"move-child"})},[o,a]);return Mo(Do,{...l,id:u,getTabLabel:(x,E)=>{let{id:P,title:I}=x.props;return n(P,"view-title")||I||`Tab ${E+1}`},onMouseDown:async(x,E)=>{let P;await m({type:"mousedown",index:E,preDragActivity:async()=>new Promise(A=>{console.log("preDragActivity: Ok, gonna release the drag"),P=A})},x)&&(P==null||P(void 0))},onMoveTab:h,onAddTab:y,onTabClose:f,onTabEdit:(x,E)=>{o({type:"set-title",path:`${a}.${x}`,title:E})},onTabSelectionChanged:g,ref:t})};ys.displayName="Stack";O("Stack",ys,"container");import Ao from"classnames";import gu,{useMemo as yu,useRef as bu}from"react";import{isValidNumber as fu}from"@vuu-ui/vuu-utils";import{useCallback as Io,useRef as hu}from"react";import{useControlled as Qc}from"@salt-ds/core";import{dispatchMouseEvent as eu,getFocusableElement as tu}from"@vuu-ui/vuu-utils";import{useCallback as q,useRef as Co,useState as xs}from"react";import{ArrowDown as Rs,ArrowUp as ou,ArrowLeft as nu,ArrowRight as ru,Home as Es,End as vs}from"@vuu-ui/vuu-utils";import{getElementDataIndex as qc}from"@vuu-ui/vuu-utils";var Jc=(e,t)=>{if(e){let o=e.querySelector(`[data-index]:has(${t})`);return qc(o)}return-1};var bs=e=>Jc(e,".vuuEditableLabel-editing");var Ts={horizontal:{[Es]:"start",[vs]:"end",[nu]:"bwd",[ru]:"fwd"},vertical:{[Es]:"start",[vs]:"end",[ou]:"bwd",[Rs]:"fwd"}},su=(e,t="horizontal")=>Ts[t][e]!==void 0,iu=e=>e===Rs;function ws(e,t,o){return t==="start"?0:t==="end"?e-1:t==="bwd"?o>0?o-1:o:o===null?0:o===e-1?o:o+1}var au=e=>e!==null&&!e.classList.contains("wrapped"),Ze=(e,t)=>e?e.querySelector(`[data-index="${t}"]`):null,Ss=({containerRef:e,defaultHighlightedIdx:t=-1,highlightedIdx:o,keyBoardActivation:n,orientation:r,selectedIndex:s=[]})=>{let i=n==="manual",a=Co(!1),l=Co(-1),[c,u]=xs(!1),[,m]=xs({}),[p,d]=Qc({controlled:o,default:t,name:"UseKeyboardNavigation"}),g=q(S=>{d(l.current=S)},[d]),f=Co(!1),y=q((S,C=!1,H,G=70)=>{g(S),H===!0&&!f.current&&(f.current=!0);let B=()=>{let Z=Ze(e.current,S);if(Z){let ee=tu(Z);ee==null||ee.focus()}};C?B():setTimeout(B,G)},[e,g]),h=S=>{if(l.current===-1&&S.target.tabIndex!==-1){let C=bs(e.current);C!==-1?requestAnimationFrame(()=>{g(C)}):setTimeout(()=>{let[H=null]=s;l.current===-1&&H!==null&&g(H)},200)}},b=q(()=>{var S,C;return(C=(S=e.current)==null?void 0:S.querySelectorAll("[data-index]").length)!=null?C:0},[e]),v=q((S="fwd",C)=>{let H=b(),B=ws(H,S,typeof C=="number"?C:H),Z=S==="start"?"fwd":S==="end"?"bwd":S;for(;(Z==="fwd"&&B<H||Z==="bwd"&&B>0)&&!au(Ze(e.current,B));){let ee=ws(H,Z,B);if(ee===B)break;B=ee}return B},[e,b]),w=q((S,C=!1)=>{let H=Ts[r][S.key],G=v(H,p);G!==p?i&&y(G,!0):C&&m({})},[p,i,v,y,r]),R=q(()=>{let S=Ze(e.current,p);return S?S.querySelector(".vuuPopupMenu")!=null:!1},[e,p]),x=q(()=>{let S=Ze(e.current,p);return S?S.querySelector(".vuuEditableLabel-input")!=null:!1},[e,p]),E=q(()=>{let S=Ze(e.current,p),C=S==null?void 0:S.querySelector(".vuuPopupMenu");return C&&eu(C,"click"),!1},[e,p]),P=q(S=>{b()>0&&su(S.key,r)?(S.preventDefault(),f.current?w(S):(f.current=!0,w(S,!0))):iu(S.key)&&R()&&!x()&&E()},[E,b,R,x,w,r]),I=(S,C)=>{g(C)},M=q(()=>{c||(u(!0),a.current?a.current=!1:f.current=!0)},[c]),A=q(()=>{c||(a.current=!0),f.current=!1},[c]);return{containerProps:{onBlur:S=>{let C=S.target.closest(".vuuTabstrip"),H=S.relatedTarget;C&&!(C!=null&&C.contains(H))&&(g(-1),u(!1))},onMouseDownCapture:A,onFocus:M,onMouseLeave:()=>{f.current=!0,g(-1),a.current=!1}},focusVisible:f.current?p:-1,focusIsWithinComponent:c,highlightedIdx:p,focusItem:y,onClick:I,onFocus:h,onKeyDown:P,setHighlightedIdx:g}};import{isSelectableElement as Ps,getClosestIndexItem as lu}from"@vuu-ui/vuu-utils";import{allowMultipleSelection as cu,deselectionIsAllowed as Ds,selectionIsDisallowed as uu,useControlled as pu}from"@vuu-ui/vuu-ui-controls";import{useCallback as Xe}from"react";var mu=["Enter"," "],du={},Ls=({containerRef:e,defaultSelected:t,highlightedIdx:o,itemQuery:n,onSelectionChange:r,selected:s,selectionStrategy:i})=>{let[a,l,c]=pu({controlled:s,default:t!=null?t:[],name:"useSelection",state:"selected"}),u=Xe(y=>mu.includes(y.key),[]),m=Xe((y,h=!1)=>{let b=cu(i,h)?a.concat(y):[y];l(b),r==null||r(b)},[r,a,i,l]),p=Xe((y,h=!1)=>{let b=i==="deselectable"||i==="multiple-special-key"&&!h?[]:a.filter(v=>v!==y);l(b),r==null||r(b)},[r,a,i,l]),d=Xe(y=>{u(y)&&Ps(y.target)&&(a.includes(o)?Ds(i)&&(y.stopPropagation(),y.preventDefault(),p(o,y.shiftKey)):(y.stopPropagation(),y.preventDefault(),m(o,y.shiftKey)))},[u,a,o,i,m,p]),g=Xe((y,h)=>{let b=lu(y.target);Ps(b)&&(a.includes(h)?Ds(i)&&p(h,y.shiftKey):m(h,y.shiftKey))},[p,m,a,i]),f=uu(i)?du:{onClick:g,onKeyDown:d};return{activateItem:m,itemHandlers:f,isControlled:c,selected:a}};var Ms=({activeItemIndex:e,defaultActiveItemIndex:t,containerRef:o,itemQuery:n="vuuToolbarItem",onActiveChange:r,orientation:s,selectionStrategy:i})=>{var x;let a=hu(e),{focusItem:l,highlightedIdx:c,onClick:u,onKeyDown:m,setHighlightedIdx:p,...d}=Ss({containerRef:o,keyBoardActivation:"manual",orientation:s,selectedIndex:(x=a.current)!=null?x:[]}),{activateItem:g,itemHandlers:{onClick:f,onKeyDown:y},selected:h}=Ls({containerRef:o,defaultSelected:t,highlightedIdx:c,itemQuery:n,onSelectionChange:r,selected:e,selectionStrategy:i});a.current=h;let b=Io(E=>{var M;let I=E.target.closest("[data-index]");if(I){let A=parseInt((M=I.dataset.index)!=null?M:"-1");A!==-1&&fu(A)&&(u(E,A),f==null||f(E,A))}},[u,f]),v=Io(E=>{m(E),E.defaultPrevented||y==null||y(E)},[m,y]),w=Io(E=>{let P=parseInt(E.index);isNaN(P)||g(P)},[g]),R={onClick:b,onFocus:d.onFocus,onKeyDown:v};return{activeItemIndex:h,focusVisible:d.focusVisible,containerProps:{...d.containerProps,onSwitchWrappedItemIntoView:w},itemProps:R}};import{forwardCallbackProps as xu}from"@vuu-ui/vuu-ui-controls";import{jsx as Eu}from"react/jsx-runtime";var Ho="vuuToolbar",LE=({activeItemIndex:e,defaultActiveItemIndex:t,children:o,className:n,id:r,onActiveChange:s,orientation:i="horizontal",selectionStrategy:a="none",...l})=>{let c=bu(null),{activeItemIndex:u,focusVisible:m,itemProps:p,...d}=Ms({activeItemIndex:e,defaultActiveItemIndex:t,containerRef:c,onActiveChange:s,orientation:i,selectionStrategy:a}),g=Ee(r),f=Ao(Ho,`${Ho}-${i}`,n),y=yu(()=>xe(o).map((h,b)=>{let{id:v=`${g}-tab-${b}`,className:w,...R}=h.props,x=u.includes(b);return gu.cloneElement(h,{...xu(R,p),className:Ao("vuuToolbarItem",w,{vuuFocusVisible:m===b}),"data-overflow-priority":x?"1":void 0,id:v,key:b,"aria-selected":x,tabIndex:x?0:-1})}),[u,o,m,g,p]);return Eu(ps,{...l,...d.containerProps,className:Ao(Ho,f),...l,ref:c,children:y})};import Cs,{useState as Is}from"react";import{jsx as ko,jsxs as As}from"react/jsx-runtime";var zE=({children:e})=>{let[o,n]=Is(e),[r,s]=Is(e),i=l=>{let c=Jo(o,l);s(c)},a=(l,c)=>{console.log(`change ${l} -> ${c}`);let u=Cs.cloneElement(r,{style:{...r.props.style,[l]:c}});s(u),n(Cs.cloneElement(o,{},u))};return As("div",{"data-design-mode":`${!1}`,children:[o,ko("br",{}),As("div",{style:{display:"flex"},children:[ko(Hs,{height:300,managedStyle:r.props.style,width:300,onChange:a,style:void 0}),ko(ks,{layout:o,onSelect:i,style:{width:300,height:300,backgroundColor:"#ccc"}})]})]})};import{FormField as Dt,Input as Lt}from"@salt-ds/core";import{jsx as $,jsxs as zo}from"react/jsx-runtime";var Bo={},vu={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"}},Oo=({feature:e,children:t,style:o,onChange:n})=>zo("div",{className:`LayoutBox layout-${e} layout-outer`,children:[zo("div",{className:"layout-top",children:[$("span",{className:"layout-title",children:e}),$(Dt,{className:"layout-input",style:{width:30},children:$(Lt,{value:o.top,onChange:(r,s)=>n(e,"top",s)})})]}),zo("div",{className:"layout-inner",children:[$("div",{className:"layout-left",children:$(Dt,{className:"layout-input",style:{width:30},children:$(Lt,{value:o.left,onChange:(r,s)=>n(e,"left",s)})})}),t,$("div",{className:"layout-right",children:$(Dt,{className:"layout-input",style:{width:30},children:$(Lt,{value:o.right,onChange:(r,s)=>n(e,"right",s)})})})]}),$("div",{className:"layout-bottom",children:$(Dt,{className:"layout-input",style:{width:30},children:$(Lt,{value:o.bottom,onChange:(r,s)=>n(e,"bottom",s)})})})]}),KE={margin:!0,marginTop:!0,marginRight:!0,marginBottom:!0,marginLeft:!0},UE={padding:!0,paddingTop:!0,paddingRight:!0,paddingBottom:!0,paddingLeft:!0},YE={border:!0,borderColor:!0,borderWidth:!0,borderTopWidth:!0,borderRightWidth:!0,borderBottomWidth:!0,borderLeftWidth:!0},Mt="(\\d+)(?:px)?",wu=`^(?:${Mt}(?:\\s${Mt}(?:\\s${Mt}(?:\\s${Mt})?)?)?)$`,Os=new RegExp(wu),Ru=/^(?:(\d+)(?:px)\ssolid\s([a-zA-Z,0-9().]+))$/,Hs=({height:e,managedStyle:t,onChange:o,style:n,width:r})=>{let s=zs(t),i=(v,w,R)=>{let x=parseInt(R||"0",10),E=vu[v][w];o(E,x)},{marginTop:a=0,marginRight:l=0,marginBottom:c=0,marginLeft:u=0}=s,{borderTopWidth:m=0,borderRightWidth:p=0,borderBottomWidth:d=0,borderLeftWidth:g=0}=s,{paddingTop:f=0,paddingRight:y=0,paddingBottom:h=0,paddingLeft:b=0}=s;return $("div",{className:"LayoutConfigurator",style:{width:r,height:e,...n},children:$(Oo,{feature:"margin",style:{top:a,right:l,bottom:c,left:u},onChange:i,children:$(Oo,{feature:"border",style:{top:m,right:p,bottom:d,left:g},onChange:i,children:$(Oo,{feature:"padding",style:{top:f,right:y,bottom:h,left:b},onChange:i,children:$("div",{className:"layout-content"})})})})})};function ZE(e=Bo,t=Bo){let{margin:o,marginTop:n,marginRight:r,marginBottom:s,marginLeft:i,padding:a,paddingTop:l,paddingRight:c,paddingBottom:u,paddingLeft:m,...p}=e;if(typeof o=="number")p.marginTop=p.marginRight=p.marginBottom=p.marginLeft=o;else if(typeof o=="string"){let d=Os.exec(o);if(d===null)console.error(`Invalid css value for margin '${o}'`);else{let[,g,f,y,h]=d,b=g&&f&&y;b&&h?(p.marginTop=parseInt(g,10),p.marginRight=parseInt(f,10),p.marginBottom=parseInt(y,10),p.marginLeft=parseInt(h,10)):b?(p.marginTop=parseInt(g,10),p.marginRight=p.marginLeft=parseInt(f,10),p.marginBottom=parseInt(y,10)):g&&f?(p.marginTop=p.marginBottom=parseInt(g,10),p.marginRight=p.marginLeft=parseInt(f,10)):p.marginTop=p.marginRight=p.marginBottom=p.marginLeft=parseInt(g,10)}}if(typeof n=="number"&&(p.marginTop=n),typeof r=="number"&&(p.marginRight=r),typeof s=="number"&&(p.marginBottom=s),typeof i=="number"&&(p.marginLeft=i),typeof a=="number")p.paddingTop=p.paddingRight=p.paddingBottom=p.paddingLeft=a;else if(typeof a=="string"){let d=Os.exec(a);if(d===null)console.error(`Invalid css value for padding '${a}'`);else{let[,g,f,y,h]=d,b=g&&f&&y;b&&h?(p.paddingTop=parseInt(g,10),p.paddingRight=parseInt(f,10),p.paddingBottom=parseInt(y,10),p.paddingLeft=parseInt(h,10)):b?(p.paddingTop=parseInt(g,10),p.paddingRight=p.paddingLeft=parseInt(f,10),p.paddingBottom=parseInt(y,10)):g&&f?(p.paddingTop=p.paddingBottom=parseInt(g,10),p.paddingRight=p.paddingLeft=parseInt(f,10)):p.paddingTop=p.paddingRight=p.paddingBottom=p.paddinggLeft=parseInt(g,10)}}return typeof l=="number"&&(p.paddingTop=l),typeof c=="number"&&(p.paddingRight=c),typeof u=="number"&&(p.paddingBottom=u),typeof m=="number"&&(p.paddingLeft=m),zs(p,t)}function zs(e=Bo){let t={...e},o,{border:n,borderWidth:r,borderTopWidth:s,borderRightWidth:i,borderBottomWidth:a,borderLeftWidth:l,borderColor:c,margin:u,marginTop:m,marginRight:p,marginBottom:d,marginLeft:g,padding:f,paddingTop:y,paddingRight:h,paddingBottom:b,paddingLeft:v,...w}=t,R={},x={};if(typeof u=="number"&&(t.marginTop=t.marginRight=t.marginBottom=t.marginLeft=u,R={marginTop:u,marginRight:u,marginBottom:u,marginLeft:u}),typeof f=="number"&&(t.paddingTop=t.paddingRight=t.paddingBottom=t.paddingLeft=f,x={paddingTop:f,paddingRight:f,paddingBottom:f,paddingLeft:f}),n||r||s||i||a||l){typeof n=="string"&&(o=Ru.exec(n))&&([,r,c]=o,r=parseInt(r,10)),r&&(s=s===void 0?r:s,i=i===void 0?r:i,a=a===void 0?r:a,l=l===void 0?r:l),c=c||"black";let E=`
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
`,document.body.insertBefore(e,r)}}var wo=class{constructor(){this.currentPath=null;this.tabMode=null;tv()}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=uf(n),i=document.getElementById("vuu-drop-outline");i==null||i.setAttribute("d",o),this.currentPath=o}clear(){vo=null,Fi(),document.body.classList.remove("drawing"),ha.hidePopup()}get hoverDropTarget(){return vo}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(vo!==null)this.drawTarget(vo);else if(fa=e.nextDropTarget!=null,e.pos.tab?nv(e):Et&&Fi(),this.drawTarget(e,t),fa){let[i,s,l]=af(e);{let a=rv(cf,{dropTarget:e,onHover:Yx,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),g=uf(m),y=document.getElementById("hw-drop-outline-animate");y==null||y.setAttribute("to",g),y==null||y.beginElement(),this.currentPath=g;let v=document.getElementById("hw-drop-guides");v==null||v.setAttribute("d",ev(f))}}},hf="transition:margin-left .4s ease-out;margin-left: 63px",ff="transition:margin-left .4s ease-out;margin-left: 0px";function nv(r){var l,a;let{AFTER:e,BEFORE:t}=xo,{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?(Et===null||Et!==s)&&(s.style.cssText=hf,Et&&(Et.style.cssText=ff),Et=s):Fi()}else if((o==null?void 0:o.positionRelativeToTab)===t){if(Et===null){let c=".vuuHeader-title";s=(a=document.getElementById(i))==null?void 0:a.querySelector(c),s.style.cssText=hf,Et=s}}else Fi()}function Fi(){Et&&(Et.style.cssText=ff,Et=null)}var Xt,So,mn,pf,mf,_n,Bi,zn=null,pa,gf,_i,yf,da,Hi=null,ov=3,zi=new wo,df=.4;function iv(r,e){return e?Te(r,e):Yt(r,t=>t.dropTarget)}var ma={handleMousedown(r,e,t={}){Xt=e,gf=t,pf=r.clientX,mf=r.clientY,da=t.dragThreshold===void 0?ov:t.dragThreshold,da===0?Xt(r,0,0):(window.addEventListener("mousemove",Wi,!1),window.addEventListener("mouseup",$i,!1),Hi=window.setTimeout(()=>{window.removeEventListener("mousemove",Wi,!1),window.removeEventListener("mouseup",$i,!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:So,drop:mn}=l,sv(r,e,{top:t,left:n,right:o,bottom:i},s,a,c)}};function Wi(r){let n=r.clientX-pf,o=r.clientY-mf;Math.max(Math.abs(n),Math.abs(o))>da&&(window.removeEventListener("mousemove",Wi,!1),window.removeEventListener("mouseup",$i,!1),Xt==null||Xt(r,n,o),Xt=null)}function $i(){Hi&&(window.clearTimeout(Hi),Hi=null),window.removeEventListener("mousemove",Wi,!1),window.removeEventListener("mouseup",$i,!1)}function sv(r,e,t,n,o,i){_n=iv(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)),_i=Cr.measure(_n,i);let a=_i[l];Bi=new Vi(a,n.x,n.y,t,o);let c=Math.round(Bi.x.mousePct*100),u=Math.round(Bi.y.mousePct*100);return window.addEventListener("mousemove",bf,!1),window.addEventListener("mouseup",vf,!1),window.addEventListener("keydown",xf,!1),yf=!1,zi.prepare(t,"tab-only"),gf.DoNotTransform?"transform:none":`transform:scale(${df},${df});transform-origin:${c}% ${u}%;`}function bf(r){let e=r.clientX,t=r.clientY,n=Bi,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||So==null||So(s,l),!(yf||_n===void 0)&&(n.inBounds()?i=ca(e,t,_n,_i,n.hasIntrinsicSize(),pa):i=ca(n.dropX(),n.dropY(),_n,_i),o&&(i==null||i.box!==o.box)&&(zn=null),i&&(zi.draw(i,n),zn=i))}function xf(r){r.key==="Escape"&&(zn=null,wf())}function vf(){wf()}function wf(){if(zn){let r=zi.hoverDropTarget||pn.getActiveDropTarget(zn);mn==null||mn(r),zn=null}else mn==null||mn();So=null,mn=null,_n=void 0,zi.clear(),pa=void 0,window.removeEventListener("mousemove",bf,!1),window.removeEventListener("mouseup",vf,!1),window.removeEventListener("keydown",xf,!1)}import lv from"classnames";import{forwardRef as av}from"react";import{jsx as cv}from"react/jsx-runtime";var Co=av(function({children:e,className:t,dropTarget:n,resizeable:o,...i},s){let l=lv("DraggableLayout",t);return cv("div",{className:l,ref:s,...i,children:e})}),Sf="DraggableLayout";Co.displayName=Sf;ge(Sf,Co,"container");import{useForkRef as Lv}from"@salt-ds/core";import Av from"classnames";import{forwardRef as Ov}from"react";import{getUniqueId as kv}from"@vuu-ui/vuu-utils";import Ro,{useCallback as Ji,useMemo as Of,useRef as Qi,useState as Mv}from"react";import uv from"classnames";import{jsx as hv}from"react/jsx-runtime";var Cf="vuuPlaceholder",Ui=({className:r,closeable:e,flexFill:t,resizeable:n,shim:o,...i})=>hv("div",{className:uv(Cf,r,{[`${Cf}-shim`]:o}),...i,"data-placeholder":!0,"data-resizeable":!0});Ui.displayName="Placeholder";ge("Placeholder",Ui);import fv from"classnames";import dv,{useCallback as To,useRef as Gi,useState as pv}from"react";import{jsx as Tf}from"react/jsx-runtime";var qi="vuuSplitter",kf=dv.memo(function({column:e,index:t,onDrag:n,onDragEnd:o,onDragStart:i,style:s}){let l=Gi(),a=Gi(null),c=Gi(0),[u,h]=pv(!1),f=To(({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=To(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=Gi(d),m=b=>p.current(b),g=To(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]),y=To(()=>{var b;window.removeEventListener("mousemove",g,!1),window.removeEventListener("mouseup",y,!1),o(),h(!1),(b=a.current)==null||b.focus()},[g,o,h]),v=To(b=>{c.current=e?b.clientY:b.clientX,i(t),window.addEventListener("mousemove",g,!1),window.addEventListener("mouseup",y,!1),b.preventDefault(),h(!0)},[e,g,y,t,i,h]),w=()=>{var b;l.current?l.current=!1:(b=a.current)==null||b.focus()},x=()=>{p.current=d},S=fv(qi,{[`${qi}-active`]:u,[`${qi}-column`]:e});return Tf("div",{className:S,"data-splitter":!0,ref:a,role:"separator",style:s,onBlur:x,onClick:w,onKeyDown:m,onMouseDown:v,tabIndex:0,children:Tf("div",{className:`${qi}-grab-zone`})})});import{uuid as Mf}from"@vuu-ui/vuu-utils";import Ef from"react";var mv={"data-placeholder":!0,"data-resizeable":!0},Ki={},gn="auto",ga={flexBasis:0,flexGrow:1,flexShrink:1,height:gn,width:gn},Rf={height:"width",width:"height"},If=(r="row")=>r==="row"?["width","height","column"]:["height","width","row"],gv=r=>typeof r=="string"&&r.endsWith("%"),at=r=>{let{style:{width:e=gn,height:t=gn}=Ki}=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=Rf[e],{style:{[n]:o=gn,...i}=Ki}=r.props;return t&&t[e]?{...i,...ga,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...i,...ga,[n]:o}}function Pf(r){let{style:{flex:e,flexGrow:t,flexShrink:n,flexBasis:o}=Ki}=r.props;return typeof e=="number"||o===0&&t===1&&n===1?!0:typeof o!="number"}function ba(r,e,t){let n=Rf[e],{style:{[e]:o=gn,[n]:i=gn,...s}=Ki}=r.props;return o!==gn?gv(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 ko(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 yv=(r,e)=>{if(!e)return r===0?1:0};function xa(r,e,t,n){let o=Mf(),{flexFill:i,style:s,resizeable:l=!0}=e,{flexBasis:a=i?void 0:"auto"}=s,c=yv(a,i);return Ef.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 bv={flexGrow:1,flexShrink:1};function Ft(r,e,t,n){let o=Mf();return Ef.createElement("div",{...mv,...n,"data-path":r,id:o,key:o,style:{...bv,...t,flexBasis:e}})}var xv={},Mo=1,Eo=2,vv=r=>typeof r.intrinsicSize=="number",wv=(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:xv,l=Pf(n);return t?{index:o,flexOpen:l,intrinsicSize:s,resizeable:i,...wv(t,n)}:{index:o,flexOpen:l,intrinsicSize:s,resizeable:i}}),Df=r=>{let e=r.length,t=r.every(vv),n=Array(e).fill(0);if(t&&e>0&&(n[0]=Eo,n[e-1]=Eo),e<2)return n;for(let o=0,i=0;o<e-1;o++)r[o].resizeable&&!i&&(i=Mo),n[o]+=i;for(let o=e-1;o>0&&(n[o]&Mo&&(n[o]-=Mo),!r[o].resizeable);o--);return n},Lf=(r,e)=>{let t=Cv(r,e),n=Tv(r,e),o=t!==-1&&n!==-1?[t,n]:void 0,i=Sv(r,o);return[o,i]};function Sv(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 Cv(r,e){let t=e,n=!1;for(;t>=1&&!n;)t=t-1,n=Af(r,t);return t}function Tv(r,e){let t=e,n=!1,o=r.length;for(;t<o-1&&!n;)t=t+1,n=Af(r,t);return t===o?-1:t}function Af(r,e){let{placeholder:t,splitter:n,resizeable:o,intrinsicSize:i}=r[e];return!!(!n&&!i&&(t||o))}var Ev=r=>!r.splitter&&!r.placeholder,Vf=({children:r,onSplitterMoved:e,style:t})=>{let n=Qi(null),o=Qi(),i=Qi(),s=Qi([]),[,l]=Mv({}),a=g=>{i.current=g,l({})},c=(t==null?void 0:t.flexDirection)==="column",u=c?"height":"width",h=Of(()=>Array.isArray(r)?r:Ro.isValidElement(r)?[r]:[],[r]),f=Ji(g=>{let{current:y}=o;if(y){let[v,w]=Lf(y,g);v&&(v.forEach(x=>{var b;let S=(b=n.current)==null?void 0:b.childNodes[x];if(S){let{size:C,minSize:k}=Dv(S,u);y[x].currentSize=C,y[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();y[x].flexBasis=C}}))}},[u]),d=Ji((g,y)=>{i.current&&o.current&&a(Iv(i.current,o.current,y,u))},[u]),p=Ji(()=>{let g=o.current;g&&(e==null||e(g.filter(Ev))),g==null||g.forEach(y=>{y.currentSize=void 0,y.flexBasis=void 0,y.flexOpen=!1})},[e]),m=Ji(g=>Ro.createElement(kf,{column:c,index:g,key:`splitter-${g}`,onDrag:d,onDragEnd:p,onDragStart:f}),[d,p,f,c]);return Of(()=>{let[g,y]=Rv(h,u,m,s.current);o.current=y,i.current=g},[h,m,u]),{content:i.current||[],rootRef:n}};function Rv(r,e,t,n){let o=ji(r,e),i=Df(o),s=[],l=[];for(let a=0;a<r.length;a++){let c=r[a];if(a===0&&i[a]&Eo&&(s.push(Nf(a)),l.push({placeholder:!0,shim:!0})),c.key==null){let u=n[a]||(n[a]=kv());s.push(Ro.cloneElement(c,{key:u}))}else s.push(c);l.push(o[a]),a>0&&i[a]&Eo?(s.push(Nf(a)),l.push({placeholder:!0})):i[a]&Mo&&(s.push(t(s.length)),l.push({splitter:!0}))}return[s,l]}function Iv(r,e,t,n){return Pv(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?Ro.cloneElement(i,{style:{...i.props.style,flexBasis:d,[n]:"auto"}}):i}else return i}):r}function Pv(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 Nf(r){return Ro.createElement(Ui,{shim:r===0,key:`placeholder-${r}`})}function Dv(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 Nv}from"react/jsx-runtime";var va="hwFlexbox",Ff=Ov(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:g,...y}=e,{content:v,rootRef:w}=Vf({children:o,onSplitterMoved:h,style:g}),x=Av(va,s,{[`${va}-column`]:i,[`${va}-row`]:d,"flex-fill":l,"full-page":c});return Nv("div",{...y,className:x,"data-resizeable":f||void 0,id:u,ref:Lv(w,t),style:{...g,gap:a,"--spacing":p},children:v})});Ff.displayName="Flexbox";var Io=Ff;import{useCallback as kw}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 vw,useRef as dd,useState as ww}from"react";import Ma from"react";import{uuid as Gf}from"@vuu-ui/vuu-utils";import Lo from"react";import{uuid as zf}from"@vuu-ui/vuu-utils";import Po,{cloneElement as Vv}from"react";import{useCallback as Tr}from"react";var We=new Map,ct=new Map,Bf=r=>We.get(r),Hf=r=>We.has(r),_f=(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 Wf=r=>r.flexDirection==="column"?["height","width"]:["width","height"],Fv={},Do=(r,e="0")=>{let[t,n]=Yi(K(r),r.props,e);return Po.cloneElement(r,t,n)},Sa=(r,e)=>{let t=K(r),[n,o]=Yi(t,r.props,"0",void 0,e);return Vv(r,n,o)},iO=(r,e,t)=>{let[n,o]=Yi(r,e,"0",void 0,t);return{...e,...n,type:r,children:o}};function Bv(r,e,t="0",n=null,o){var m,g;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:zf(),f=r==="Stack"?(g=e.active)!=null?g:i:void 0,d=h,p=u?c:_v(r,e,n);return Bh(r)?{id:h,key:d,path:t,style:p,type:r,active:f}:{id:h,key:d,style:p,"data-path":t}}function Yi(r,e,t,n=null,o){var c,u;let i=Bv(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:Hv(r,e.children,t,s);return[i,a]}function Hv(r,e,t="0",n){let o=Array.isArray(e)?e:Po.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]=Yi(l,i.props,`${t}.${s}`,r,n==null?void 0:n[s]);return Po.cloneElement(i,c,u)}return n==null?void 0:n[s]}):e}var _v=(r,e,t)=>{let{style:n=Fv}=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=zf(),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&&_f(r,o),Po.createElement(s,{id:r,...n,key:r,path:i},t?t.map((l,a)=>Mr(l,`${i}.${a}`)):void 0)}function $f(r){return Uf(r)}function Uf(r){let e=K(r),{id:t,children:n,type:o,...i}=_(r),s=Hf(t)?Bf(t):void 0;return{id:t,type:e,props:zv(i),state:s,children:Po.Children.map(n,Uf)}}function zv(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 qf(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 Xi(r,e,t){let{active:n,children:o=[],path:i}=_(r),s=q(e,"path"),{idx:l,finalStep:a}=Mt(i,s,!0),[c,u]=a?Wv(r,o,t):[n,o==null?void 0:o.map((f,d)=>d===l?Xi(f,e,t):f)],h=K(r)==="Stack"?Array.isArray(c)?c[0]:c:n;return Lo.cloneElement(r,{active:h},u)}function Wv(r,e,t){let n=q(r,"path"),o=e==null?void 0:e.length,{id:i=Gf()}=_(t);return o?[o,e.concat(Ee(t,`${n}.${o}`,{id:i,key:i}))]:[0,[Ee(t,`${n}.0`,{id:i})]]}function Zi(r,e,t,n,o,i,s){let{active:l,children:a,path:c}=_(r),u=q(e,"path"),{idx:h,finalStep:f}=Mt(c,u),[d,p]=f?$v(r,a,h,t,n,o,i,s):[l,a.map((g,y)=>y===h?Zi(g,e,t,n,o,i,s):g)],m=K(r)==="Stack"?d:l;return Lo.cloneElement(r,{active:m},p)}function $v(r,e,t,n,o,i,s,l){let a=at(n);return a!=null&&a.width&&(a!=null&&a.height)?Gv(r,e,t,n,o,s,l):Kf(r,e,t,n,o,(i==null?void 0:i.width)||(i==null?void 0:i.height),s)}var Uv=(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 Gv(r,e,t,n,o,i,s){let{style:{flexDirection:l}}=_(r),[a,c,u]=If(l),{[c]:h,[a]:f}=at(n),d=q(e[t],"path"),p=Uv(l,o,i,s),[m,g]=h<i[c]?[ko(n,u,d,i,s),f]:[n,void 0],y=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?ko(v,u,q(v,"path")):v}})),Kf(r,e,t,m,o,g,i,y)}function Kf(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]=qv(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 qv(r,e,t,n){let o=Gf(),{version:i=0}=_(t);if(i+=1,K(r)==="Flexbox"){let[s]=Wf(r.props.style),l=6,a={[s]:(n[s]-l)/2},c=ba(e,s,a),u=ba(t,s,a);return[Lo.cloneElement(e,{style:c}),Lo.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,Lo.cloneElement(t,{id:o,version:i,style:c})]}}import{cloneElement as Jv}from"react";import es from"react";function jf(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=Do(es.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}=Mt(q(r,"path"),q(e,"path")),s=r.props.children.slice();return i?n?n===Wn.MINIMIZE?s[o]=Kv(r,s[o]):n===Wn.RESTORE&&(s[o]=jv(s[o])):s[o]=t:s[o]=$e(s[o],e,t,n),es.cloneElement(r,void 0,s)}function Kv(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?es.cloneElement(e,{collapsed:f,restoreStyle:u,style:h}):e}function jv(r){let{style:e,restoreStyle:t}=_(r),{flexBasis:n,flexShrink:o,flexGrow:i,...s}=e,l={...s,...t};return es.cloneElement(r,{collapsed:!1,style:l,restoreStyle:void 0})}function Jf(r,{fromIndex:e,path:t,toIndex:n}){let o=Te(r,t,!0),{children:i}=_(o),s=Qv(i,e,n),l=Jv(o,void 0,s);return $e(r,o,l)}function Qv(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"},IO=r=>["switch-active-layout","open-layout","close-layout","rename-layout"].includes(r),PO=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&&Yf(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(Yf(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(ew(h))u=ed(r,n);else break}return u}return Xf(r,t)}function Xf(r,e){let t=_(r),{children:n,path:o,preserve:i}=t,{active:s}=t,{idx:l,finalStep:a}=Mt(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 Yv(r,u[0]);!u.some(Xv)&&u.some(Zf)&&(u=Zv(u))}else u[l]=Xf(u[l],e);return u=u.map((h,f)=>Ee(h,`${o}.${f}`)),$n.cloneElement(r,{active:s},u)}function Yv(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 Xv=r=>r.props.style.flexGrow>0,Zf=r=>{let{width:e,height:t,flexGrow:n}=r.props.style;return n===0&&typeof e!="number"&&typeof t!="number"},Zv=r=>r.map(e=>Zf(e)?$n.cloneElement(e,{style:{...e.props.style,flexGrow:1}}):e),ew=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}}},ed=(r,e)=>{let{children:t,path:n}=_(r),{idx:o,finalStep:i}=Mt(n,q(e,"path")),s=t.slice();return i?s[o]=tw(e):s[o]=ed(s[o],e),s=s.map((l,a)=>Ee(l,`${n}.${a}`)),$n.cloneElement(r,void 0,s)},tw=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(Qf(n)),n.length=0),t.push(e[i]));n.length===1?t.push(n.pop()):n.length>0&&t.push(Qf(n));let o=q(r,"path");return $n.cloneElement(r,void 0,t.map((i,s)=>Ee(i,`${o}.${s}`)))},Qf=([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}})},Yf=(r,e)=>r.every(t=>q(t,"placeholder")||e&&q(t,"path")===e);import ka from"react";function td(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 nd(r,{path:e,sizes:t}){let n=Te(r,e,!0),{children:o,style:i}=_(n),s=i.flexDirection==="column"?"height":"width",l=nw(o,t,s),a=ka.cloneElement(n,void 0,l);return $e(r,n,a)}function nw(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:rw(n.props.style,t,h)})})}function rw(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 ow}from"@vuu-ui/vuu-utils";import ts from"react";var rd=r=>{let[e]=K(r);return e===e.toLowerCase()};function Ao(r,e,t,n,o,i){let{children:s,path:l}=_(r),a=q(e,"path"),{idx:c,finalStep:u}=Mt(l,a),h=u?iw(r,s,e,t,n,o,i):s.map((f,d)=>d===c?Ao(f,e,t,n,o,i):f);return ts.cloneElement(r,void 0,h)}function iw(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 lw(e,t,n,o,i,s)}return sw(r,e,t,n,o)}function sw(r,e,t,n,o){var b;let{version:i=0}=_(n),s=q(t,"path"),{type:l,flexDirection:a,showTabs:c}=id(o),[u,h,f]=aw(l,t,n,a,o),d=od(o),p=d?1:0,m={resizeable:!0,style:f,version:i+1},y={[rd(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=ow(),S=ts.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`,y),Do(ts.cloneElement(n,m),`${s}.1`)]:[Do(ts.cloneElement(n,m),`${s}.0`),Ee(t,`${s}.1`,y)]);return e.map(C=>C===t?S:C)}function lw(r,e,t,n,o,i){let{flexDirection:s}=id(n),l=s==="column"?"row":"column",a=od(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"),g=0,y=rd(e)?"data-resizeable":"resizeable",v=[];d&&v.push(a?Ee(e,`${m}.${g++}`,{[y]:!0,style:{flexBasis:d,flexGrow:1,flexShrink:1}}):Ft(`${m}.${g++}`,d,{flexGrow:0,flexShrink:0})),v.push(ko(t,l,`${m}.${g++}`,o,i)),p&&v.push(a?Ft(`${m}.${g++}`,0):Ee(e,`${m}.${g++}`,{[y]:!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 aw(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 od=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 id(r){return r.position.Header?{type:"Stack",flexDirection:"column",showTabs:!0}:{type:"Flexbox",flexDirection:r.position.EastOrWest?"row":"column"}}var ud=(r,e)=>{switch(e.type){case Re.ADD:return dw(r,e);case Re.DRAG_DROP:return fw(r,e);case Re.MAXIMIZE:return hw(r,e);case Re.REMOVE:return Ta(r,e);case Re.REPLACE:return jf(r,e);case Re.SET_PROP:return sd(r,e);case Re.SET_PROPS:return uw(r,e);case Re.SET_TITLE:return sd(r,{type:"set-prop",path:e.path,propName:"title",propValue:e.title});case Re.SPLITTER_RESIZE:return nd(r,e);case Re.LAYOUT_RESIZE:return td(r,e);case Re.SWITCH_TAB:return cw(r,e);case Re.MOVE_CHILD:return Jf(r,e);default:return r}},cw=(r,{path:e,nextIdx:t})=>{let n=Te(r,e,!0),o=Ma.cloneElement(n,{active:t});return $e(r,n,o)},sd=(r,{path:e,propName:t,propValue:n})=>{let o=Te(r,e,!0),i=Ma.cloneElement(o,{[t]:n});return $e(r,o,i)},uw=(r,{path:e,props:t})=>{let n=Te(r,e,!0),o=Ma.cloneElement(n,t);return $e(r,n,o)},hw=(r,{path:e,type:t})=>{if(e){let n=Te(r,e,!0);return $e(r,n,n,t)}else return r},fw=(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[g,y]=qf(i,s);g===void 0?h=Xi(r,i,t):h=Zi(r,g,t,y)}else!u&&((m=s==null?void 0:s.position)!=null&&m.Centre)?h=Ca(r,i,t):h=pw(r,o,t);if(n.DoNotRemove)return h;let f=Yt(h,g=>g.id===a&&g.version===c),d=q(f,"path");return Ta(h,{path:d,type:"remove"})},dw=(r,{path:e,component:t})=>Xi(r,Te(r,e),t),pw=(r,e,t)=>{let{component:n,pos:o,clientRect:i,dropRect:s}=e,l=q(n,"path");if(l==="0.0")return Ao(r,n,t,o);let a=Qt(r,l);if(ld(o,a)){let c=o.position.SouthOrEast?"after":"before";return Zi(r,n,t,c,o,i,s)}if(!ld(o,a))return Ao(r,n,t,o,i,s);if(ze(K(a)))return Ao(r,n,t,o);throw Error(`no support right now for position = ${o.position}`)},ld=(r,e)=>r.position.Centre?cd(e)||ad(e):r.position.NorthOrSouth?ad(e):r.position.EastOrWest?cd(e):!1,ad=r=>K(r)==="Flexbox"&&r.props.style.flexDirection==="column",cd=r=>K(r)==="Flexbox"&&r.props.style.flexDirection!=="column";import{createContext as mw}from"react";var gw=r=>console.log(`dispatch ${r.type}, have you forgotten to provide a LayoutProvider ?`),Oo=mw({dispatchLayoutProvider:gw,version:-1});import{useCallback as ns,useRef as Ea}from"react";var yw={},hd=[0,0],bw=(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]},xw=r=>{let{offsetParent:e}=r;if(e===null)return hd;{let{left:t,top:n}=e.getBoundingClientRect();return[t,n]}},fd=(r,e,t)=>{let n=Ea(),o=Ea(),i=Ea(),s=ns((u,h)=>{if(o.current&&i.current){let{dragOffsets:[f,d],targetPosition:p}=o.current,m=typeof u=="number"?u-f:p.left,g=typeof h=="number"?h-d:p.top;(m!==p.left||g!==p.top)&&(o.current.targetPosition.left=m,o.current.targetPosition.top=g,i.current.style.top=g+"px",i.current.style.left=m+"px")}},[]),l=ns(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=ns(u=>{if(n.current){let{payload:h,dragContainerPath:f,dragElement:d,dragRect:p,instructions:m=yw,path:g}=n.current,{current:y}=r,v={x:u.clientX,y:u.clientY},w=h!=null?h:Te(y,g,!0),{id:x}=w.props,S=at(w),b="",C="",k="",E=-1,R=-1,N=hd,O=document.getElementById(x);if(O===null)[O,C,E,R]=bw(p,x,d);else{N=xw(O);let[M,D]=N,{width:F,height:G,left:A,top:V}=O.getBoundingClientRect();E=A-M,R=V-D,C=`width:${F}px;height:${G}px;left:${E}px;top:${R}px;z-index: 100;background-color:#ccc;opacity: 0.6;`,O.dataset.dragging="true",b=O.style.cssText}k=ma.initDrag(r.current,f,p,v,{drag:s,drop:l},S),O.style.cssText=C+k,i.current=O,o.current={payload:w,originalCSS:b,dragRect:p,dragOffsets:N,dragInstructions:m,targetPosition:{left:E,top:R}}}},[s,l,r]);return ns(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 yd}from"react/jsx-runtime";var pd=r=>r.dropTarget,Sw=r=>["drag-drop","remove","set-title","splitter-resize","switch-tab"].includes(r.type),md=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")}},ZN=()=>{let r=Tw();return yd("div",{children:`Context: ${r} `})},Cw=r=>{let{children:e,createNewChild:t,pathToDropTarget:n,layout:o,onLayoutChange:i}=r,s=dd(void 0),l=dd(e),[,a]=ww(null),c=Ra((d,p)=>{if(console.log(`serialize state ${p}`),i){let m=Yt(d,pd)||s.current,y=K(m)==="DraggableLayout"?_(m).children[0]:m,v=$f(y);i(v,p)}},[i]),u=Ra((d,p=!1)=>{let m=ud(s.current,d);m!==s.current&&(s.current=m,a({}),!p&&Sw(d)&&c(m,md(d)))},[a,c]),h=Ra(d=>{switch(d.type){case"drag-start":{f(d);break}case"save":{c(s.current,md(d));break}default:{u(d);break}}},[u,c]),f=fd(s,h,n);return vw(()=>{if(o){let d=Yt(s.current,pd);if(d){let p=Gh(d),m=Mr(o,`${d.props.path}.0`),g=p?{type:Re.REPLACE,target:p,replacement:m}:{type:Re.ADD,path:d.props.path,component:m};u(g,!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),yd(Oo.Provider,{value:{createNewChild:t,dispatchLayoutProvider:h,version:0},children:s.current})},ut=()=>{let{dispatchLayoutProvider:r}=Ia(Oo);return r},gd=()=>{let{createNewChild:r}=Ia(Oo);return r},Tw=()=>{let{version:r}=Ia(Oo);return r};import{jsx as Mw}from"react/jsx-runtime";var bd=function(e){let{path:t}=e,n=ut(),o=kw(i=>{n({type:Wn.SPLITTER_RESIZE,path:t,sizes:i})},[n,t]);return Mw(Io,{...e,onSplitterMoved:o})};bd.displayName="Flexbox";ge("Flexbox",bd,"container");import{useForkRef as qw}from"@salt-ds/core";import Kw from"classnames";import{forwardRef as jw,useMemo as Jw}from"react";import{useCallback as Td,useEffect as Lw,useRef as La,useState as Aw}from"react";import{useCallback as Ew,useLayoutEffect as xd,useRef as Rw}from"react";var wd=["height","width"],p2=["height"],m2=["width"],Un=new WeakMap,Sd=(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}},vd=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=Sd(t,n,a);u!==c&&(l=!0,s[a]=u)}l&&i&&i(s)}}});function rs(r,e,t,n=!1){let o=Rw(e),i=Ew(s=>{let l=s.getBoundingClientRect();return o.current.reduce((a,c)=>(a[c]=Sd(s,l,c),a),{})},[]);xd(()=>{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,vd.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)&&(vd.unobserve(s),Un.delete(s),l=!0)}},[r,i,n,t]),xd(()=>{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 Iw(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 Pw=([,r],[,e])=>e-r,Da=r=>Object.entries(r).sort(Pw).map(([e,t],n,o)=>[e,t,n<o.length-1?o[n+1][1]:9999]),Pa=null,Dw=(r="salt")=>{let{xs:e,sm:t,md:n,lg:o,xl:i}=Iw(r);return Da({xs:e,sm:t,md:n,lg:o,xl:i})},Cd=r=>(Pa===null&&(Pa=Dw(r)),Pa);var Ow=[],kd=({breakPoints:r,smallerThan:e},t)=>{let[n,o]=Aw(e?!1:"lg"),i=La(document.body),s=La(r?Da(r):Cd()),l=La("lg"),a=Td(u=>{if(s.current){for(let[h,f]of s.current)if(u>=f)return h}},[s]),c=Td(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 rs(t||i,s.current?["width"]:Ow,({width:u})=>{let h=c(u);h!==l.current&&(l.current=h,o(h))},!0),Lw(()=>{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 Md="data-collapsible",Nw={[Md]:!0,"data-pad-start":!0,"data-pad-end":!0},Vw=r=>{var e;return(e=Nw[r])!=null?e:!1},Fw=r=>r===Md,Bw={dynamic:"dynamic",instant:"instant",true:"instant"},Hw=r=>{var e;return(e=Bw[r])!=null?e:"none"},T2=r=>Object.keys(r).reduce((e,t)=>{let[n,o]=e;if(Vw(t)){let i=Fw(t)?Hw(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 zw,isValidElement as Ww,useCallback as $w,useMemo as Ed,useRef as Aa}from"react";var Uw=["xs","sm","md","lg","xl"],Gw=12,Rd=({children:r,cols:e,style:t})=>{let n=Aa(null),o=Aa(null),i=Aa(),s=e!=null?e:Gw,a=(t==null?void 0:t.flexDirection)==="column"?"height":"width",c=Ed(()=>Array.isArray(r)?r:Ww(r)?[r]:[],[r]),u=$w((h,f)=>{let d=ji(h,f,Uw),p=[],m=[];for(let g=0;g<h.length;g++){let y=h[g],{style:{flex:v,...w}}=y.props;p.push(zw(y,{key:_w(),style:{...w,"--parent-col-count":s}})),m.push(d[g])}return[p,m]},[s]);return Ed(()=>{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 Qw}from"react/jsx-runtime";var os="hwFluidGrid",Oa=jw(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:g,splitterSize:y,style:v,...w}=e,x=Jw(()=>wr(o),[o]),{cols:S,content:b,rootRef:C}=Rd({children:x,cols:s,style:v}),k=kd({breakPoints:n},C),E=Kw(os,l,{[`${os}-column`]:i,[`${os}-row`]:p,[`${os}-show-grid`]:m,"flex-fill":a,"full-page":u}),R={...v,"--spacing":g,"--grid-col-count":S,"--grid-gap":c};return Qw("div",{...w,className:E,"data-breakpoint":k,"data-cols":S,"data-resizeable":d||void 0,id:h,ref:qw(C,t),style:R,children:b})});Oa.displayName="FluidGrid";import{jsx as Yw}from"react/jsx-runtime";var Id=function(e){return Yw(Oa,{...e})};Id.displayName="FluidGrid";ge("FluidGrid",Id,"container");import{EditableLabel as hS}from"@vuu-ui/vuu-ui-controls";import{Button as fS}from"@salt-ds/core";import{default as dS,default as pS}from"classnames";import{cloneElement as _d,useRef as mS,useState as zd}from"react";import{useCallback as No,useState as Xw}from"react";var is=(r,e,t,n)=>{var g;let{loadSessionState:o,purgeSessionState:i,purgeState:s,saveSessionState:l}=kr(),[a,c]=Xw((g=o(r,"contributions"))!=null?g:[]),u=ut(),h=No((y,v)=>{let w=a.concat([{location:y,content:v}]);l(r,"contributions",w),c(w)},[a,r,l]),f=No(()=>{i(r,"contributions"),c([])},[r,i]),d=No(()=>{let y=o(r,"data-source");y&&y.unsubscribe(),i(r),s(r),u({type:"remove",path:t})},[u,r,o,i,s,t]),p=No(async(y,v,w)=>{var S;y.stopPropagation();let x=(S=e.current)==null?void 0:S.getBoundingClientRect();return new Promise((b,C)=>{u({type:"drag-start",evt:y,path:v===void 0?t:`${t}.${v}`,dragRect:x,preDragActivity:w,dropTargets:n,resolveDragStart:b,rejectDragStart:C})})},[e,u,t,n]);return[No(async(y,v)=>{var x;let{type:w}=y;switch(w){case"maximize":case"minimize":case"restore":return u({type:w,path:(x=y.path)!=null?x:t});case"remove":return d();case"mousedown":return p(v,y.index,y.preDragActivity);case"add-toolbar-contribution":return h(y.location,y.content);case"remove-toolbar-contribution":return f();default:return}},[u,t,d,p,h,f]),a]};import{useForkRef as nS,useIdMemo as rS}from"@salt-ds/core";import oS from"classnames";import Va,{forwardRef as iS,useCallback as sS,useMemo as lS,useRef as Fd,useState as aS}from"react";import{useCallback as Gn,useMemo as Pd}from"react";var Dd=({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]=is(r,e,t,n),d=Pd(()=>{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=Pd(()=>s(r),[r,s]),g=Gn(b=>s(r,b),[r,s]),y=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:g,loadSession:w,onConfigChange:S,onEditTitle:p,purge:y,restoredState:m,save:v,saveSession:x,title:d}};import{useCallback as Ld,useRef as Ad}from"react";var Zw=[],Od=({mainRef:r,resize:e="responsive",rootRef:t})=>{let n=e==="defer",o=Ad({}),i=Ad(),s=Ld(()=>{r.current&&(r.current.style.height=o.current.height+"px",r.current.style.width=o.current.width+"px"),i.current=void 0},[r]),l=Ld(({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]);rs(t,n?wd:Zw,l,n)};import eS,{useContext as Nd}from"react";var tS={dispatch:null},ss=eS.createContext(tS),Vd=()=>{var e;let r=Nd(ss);return(e=r==null?void 0:r.dispatch)!=null?e:null},CV=()=>Nd(ss);import{jsx as Na,jsxs as uS}from"react/jsx-runtime";var Vo="vuuView",cS=(r,e)=>r&&e?{...r,...e}:r||e,Bd=iS(function(e,t){let{Header:n=Hd,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:g=a,resize:y="responsive",resizeable:v=c,tearOut:w,style:x={},title:S,...b}=e,C=rS(d),k=Fd(null),E=Fd(null),[R,N]=aS(),{contributions:O,dispatchViewAction:M,load:D,loadSession:F,onConfigChange:G,onEditTitle:A,purge:V,restoredState:B,save:U,saveSession:X,title:ee}=Dd({id:C,rootRef:k,path:g,dropTargets:u,title:S});Od({mainRef:E,resize:y,rootRef:k});let _e=sS(Vt=>{N(Vt)},[]),de=()=>Va.isValidElement(o)&&(B||R)?Va.cloneElement(o,cS(B,R)):o,it=lS(()=>({dispatch:M,id:C,path:g,title:ee,load:D,loadSession:F,onConfigChange:G,purge:V,save:U,saveSession:X,setComponentProps:_e}),[M,C,D,F,G,g,V,U,X,_e,ee]),On=typeof p=="object"?p:{};return Na("div",{...b,className:oS(Vo,i,{[`${Vo}-collapsed`]:s,[`${Vo}-expanded`]:h,[`${Vo}-resize-defer`]:y==="defer"}),"data-resizeable":v,id:C,ref:nS(t,k),style:x,tabIndex:-1,children:uS(ss.Provider,{value:it,children:[p?Na(n,{...On,collapsed:s,contributions:O,expanded:h,closeable:l,onEditTitle:A,orientation:m,tearOut:w,title:ee}):null,Na("div",{className:`${Vo}-main`,ref:E,children:de()})]})})});Bd.displayName="View";var qn=Va.memo(Bd);qn.displayName="View";ge("View",qn,"view");import{jsx as Fo}from"react/jsx-runtime";var Fa="vuuHeader",Hd=({className:r,contributions:e,collapsed:t,closeable:n,onEditTitle:o,orientation:i="horizontal",style:s,title:l="Untitled"})=>{let a=mS(null),[c,u]=zd(l),[h,f]=zd(!1),d=Vd(),p=R=>d==null?void 0:d({type:"remove"},R),m=()=>{var R;(R=a.current)==null||R.focus()},g=R=>{R.stopPropagation()},v=dS(Fa,r,`${Fa}-${t||i}`),w=()=>{f(!0)},x=R=>{R.key==="Enter"&&f(!0)},S=(R="",N="",O=!0,M=!1)=>{var D;f(!1),M?u(R):N!==R&&(u(N),o==null||o(N)),O===!1&&((D=a.current)==null||D.focus())},b=R=>{d==null||d({type:"mousedown"},R)},C=[],k=[],E=[];return e==null||e.forEach((R,N)=>{switch(R.location){case"pre-title":C.push(_d(R.content,{key:N}));break;default:k.push(_d(R.content,{key:N}))}}),l&&C.push(Fo(hS,{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(Fo(fS,{"data-icon":"close",onClick:p,onMouseDown:g,variant:"secondary"},"close")),k.length>0&&C.push(Fo("div",{className:"vuuTooltrayProxy","data-align":"end",children:k},"contributions")),E.length>0&&C.push(Fo("div",{className:"vuuTooltrayProxy","data-align":"end",children:E},"actions")),Fo("div",{className:pS("vuuToolbarProxy",v),style:s,onMouseDown:b,children:C})};var cF={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},Bo={type:"Stack",id:"main-tabs",props:{className:"vuuShell-mainTabs",TabstripProps:{allowAddTab:!0,allowRenameTab:!0,animateSelectionThumb:!1,location:"main-tab",allowCloseTab:!0},preserve:!0,active:0},children:[{props:{id:"tab1",className:"vuuShell-Placeholder"},type:"Placeholder"}]};import{Prompt as Dz}from"@vuu-ui/vuu-popups";import{Button as Az}from"@salt-ds/core";import Nz from"classnames";import{useRef as Hz}from"react";import{useCallback as mF,useRef as gF}from"react";import{PopupComponent as bF,Portal as xF}from"@vuu-ui/vuu-popups";import{List as wF,ListItem as SF}from"@vuu-ui/vuu-ui-controls";import{Fragment as EF,jsx as kF,jsxs as MF}from"react/jsx-runtime";import{itemToString as gS}from"@vuu-ui/vuu-utils";import{ComboBox as yS}from"@vuu-ui/vuu-ui-controls";import Wd from"classnames";import{forwardRef as bS,useCallback as ls,useMemo as xS,useRef as vS,useState as wS}from"react";import{jsx as Ud}from"react/jsx-runtime";var $d="vuuExpandoCombobox",SS={},Ho=bS(function({className:e,InputProps:t=SS,ListProps:n,onInputChange:o,onSelectionChange:i,selectionStrategy:s,style:l,value:a="",...c},u){let[h,f]=wS(a),{itemToString:d=gS}=c,p=vS(a),m=ls(b=>{let[C,...k]=b;return k.length?`${d(C)} + ${k.length}`:d(C)},[d]),g=ls(b=>{let{value:C}=b.target;console.log(`onInputChange ${C}`),f(C),o==null||o(b)},[o]),y=ls(b=>{console.log(`handleSetSelectedText ${b}`),f(b)},[]),[v,w]=xS(()=>{let{inputProps:b,...C}=t;return[{...C,className:`${$d}-Input`,endAdornment:null,inputProps:{...b,autoComplete:"off",onInput:g}},{...n,className:Wd("vuuMenuList",n==null?void 0:n.className),"data-mode":"light",displayedItemCount:10,itemHeight:22,maxWidth:300,minWidth:100,width:"auto"}]},[t,g,n]),x=ls((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 Ud("div",{className:Wd($d,e),"data-text":h,ref:u,style:l,children:Ud(yS,{...c,PopupProps:S,defaultValue:p.current,fullWidth:!0,ListProps:w,InputProps:v,itemsToString:m,onSelectionChange:x,onSetSelectedText:y,selectionStrategy:s})})});import L_ from"classnames";import{useCallback as N_}from"react";import{Button as QF}from"@salt-ds/core";import{jsx as ZF}from"react/jsx-runtime";import{forwardRef as CS,useState as TS,useCallback as Gd}from"react";import{ExpandoInput as kS}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as Ba}from"@vuu-ui/vuu-utils";import{jsx as ES}from"react/jsx-runtime";var MS=CS(function({InputProps:e,className:t,column:n,onInputComplete:o,value:i},s){let[l,a]=TS(Ba(i)?i.toString():""),c=Gd(h=>{let{value:f}=h.target,d=parseFloat(f);Ba(d)&&console.log("its valid"),a(f)},[]),u=Gd(h=>{if(h.key==="Enter"){let{value:f}=h.target,d=parseFloat(f);Ba(d)&&o(d)}},[o]);return ES(kS,{...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 rT,useCallback as ks,useEffect as Hp,useMemo as oT,useState as _p}from"react";import{getFullRange as gB,metadataKeys as RS,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}=RS;import{useCallback as u4,useEffect as h4,useState as f4}from"react";import{EventEmitter as $S,getLoggingConfigForWorker as US,uuid as GS}from"@vuu-ui/vuu-utils";var _o=(r,e)=>r===e?!0:r===void 0&&e===void 0,IS=({filter:r},{filter:e})=>r===void 0&&(e==null?void 0:e.filter)===""||e===void 0&&(r==null?void 0:r.filter)==="",PS=(r,e)=>{var t,n;return IS(r,e)?!1:((t=r.filter)==null?void 0:t.filter)!==((n=e.filter)==null?void 0:n.filter)},DS=({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,LS=(r,e)=>{let{sort:t}=r,{sort:n}=e;return _o(t,n)||DS(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)},qd=r=>r!==void 0&&r.groupBy!==void 0&&r.groupBy.length>0,Kd=r=>(r==null?void 0:r.filter)!==void 0&&r.filter.filter.length>0,jd=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},AS=({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 _o(t,n)||AS(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]))},OS=({columns:r},{columns:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,NS=(r,e)=>{let{columns:t}=r,{columns:n}=e;return _o(t,n)||OS(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]))},VS=({aggregations:r},{aggregations:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,FS=(r,e)=>{let{aggregations:t}=r,{aggregations:n}=e;return _o(t,n)||VS(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)},BS=()=>!1,as=(r,e)=>_o(r,e)?!1:r===void 0||e===void 0?!0:NS(r,e)||PS(r,e)||LS(r,e)||Ha(r,e)||FS(r,e)||BS(r,e),HS=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],Jd=r=>{let e=r.type;return HS.includes(e)},Qd=r=>["config","aggregate","columns","filter","groupBy","sort"].includes(r.type),_S={filter:""},zS={sortDefs:[]},Er={aggregations:[],columns:[],filter:_S,groupBy:[],sort:zS},cs=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 Yd="GET_TABLE_LIST",Xd="GET_TABLE_META";var _a=r=>r.type==="connection-status",Zd=r=>r.type==="connection-metrics",ep=r=>typeof r.result<"u",tp=r=>r.type==="TABLE_META_RESP";var np='\nvar fe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var g=(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?d=>console.info(`[${s}] ${d}`):F,a=n?d=>console.warn(`[${s}] ${d}`):F,u=e?d=>console.debug(`[${s}] ${d}`):F;return{errorEnabled:r,error:r?d=>console.error(`[${s}] ${d}`):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 S,ye=class{constructor(){U(this,S,new Map)}addListener(e,t){let n=g(this,S).get(e);n?Ce(n)?n.push(t):Ct(n)&&g(this,S).set(e,[n,t]):g(this,S).set(e,t)}removeListener(e,t){if(!g(this,S).has(e))return;let n=g(this,S).get(e),r=-1;if(n===t)g(this,S).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,g(this,S).delete(e)):n.splice(r,1)}}removeAllListeners(e){e&&g(this,S).has(e)?g(this,S).delete(e):e===void 0&&g(this,S).clear()}emit(e,...t){if(g(this,S)){let n=g(this,S).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)}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)}}};S=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",d=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](d);let i=n!=null?n:new te(d,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 d=--u.remaining>0;if(t({type:"connection-status",status:"disconnected",reason:"failed to connect",retry:d}),d)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.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-g(this,h).from;this.internalData[o]!==void 0&&(this.rowsWithinRange+=1)}}this.rowCount=e};this.bufferBreakout=(e,t)=>{let n=this.bufferSize*.25;return g(this,h).to-t<n?!0:g(this,h).from>0&&e-g(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 g(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-g(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 g(this,h).isWithin(e)&&this.internalData[e-g(this,h).from]!=null?this.internalData[e-g(this,h).from]:void 0}isWithinRange(e){return g(this,h).isWithin(e)}isWithinClientRange(e){return this.clientRange.isWithin(e)}setClientRange(e,t){var d;(d=T.debug)==null||d.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-g(this,h).from;this.internalData[l]&&(this.rowsWithinRange+=1)}let a=ot,u=g(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!==g(this,h).from||t!==g(this,h).to){(n=T.debug)==null||n.call(T,`setRange ${e} - ${t}`);let[o,a]=g(this,h).overlap(e,t),u=new Array(t-e);this.rowsWithinRange=0;for(let c=o;c<a;c++){let d=this.getAtIndex(c);if(d){let i=c-e;u[i]=d,this.isWithinClientRange(c)&&(this.rowsWithinRange+=1)}}this.internalData=u,g(this,h).from=e,g(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}=g(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:p,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:d,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 console.log(`elapsed time = ${t}`),e==="size-only"&&t>0&&t<500&&this.lastUpdateStatus.count>3};this.throttleMessage=e=>this.shouldThrottleMessage(e)?(p==null||p("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=d,Ut&&(p==null||p(`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(p==null||p(`completeOperation ${a}`),r.delete(e),a==="CHANGE_VP_RANGE"){let[c,d]=t;(u=this.dataWindow)==null||u.setRange(c,d);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:d,filter:i,groupBy:l,sort:f}=o.data;return this.aggregations=c,this.columns=d,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,d,i]=t;return this.linkedParent={colName:c,parentViewportId:d,parentColName:i},this.pendingLinkedParent=void 0,{type:"vuu-link-created",clientViewportId:n,colName:c,parentViewportId:d,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 d=this.isTree?le:ue;return o.length?[c,o.map(i=>d(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,p==null||p("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"}),p==null||p(`enable: ${this.serverViewportId}`),{type:Ke,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:"disable"}),p==null||p(`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 p==null||p(`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)}`):p==null||p("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}),p==null||p(`aggregateRequest: ${t}`),this.createRequest({aggregations:t})}sortRequest(e,t){return this.awaitOperation(e,{type:"sort",data:t}),p==null||p(`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}),p==null||p(`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,,d,...i]=n;return[s,r.keyFor(s),c,u,a,d,e,t?Z(o,s):0].concat(i)};var it=1;var{debug:E,debugEnabled:L,error:O,info:y,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)){y==null||y(`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?(y==null||y(`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);y==null||y(`setViewRange ${t.range.from} - ${t.range.to}`),r&&this.sendIfReady(r,n,e.status==="subscribed"),o?(y==null||y(`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(()=>{y==null||y("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=this.viewports.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&&y(`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 qS=new Blob([US()+np],{type:"text/javascript"}),KS=URL.createObjectURL(qS),Rr,za,Wa=[],jS,JS,rp=new Promise((r,e)=>{jS=r,JS=e}),Ga=()=>rp,us=new Map,hs=new Map,QS=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(KS),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=op,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 op({data:r}){if(Jd(r)){let e=us.get(r.clientViewportId);e?e.postMessageToClientDataSource(r):console.error(`[ConnectionManager] ${r.type} message received, viewport not found`)}else if(_a(r))fs.emit("connection-status",r);else if(Zd(r))console.log({message:r}),fs.emit("connection-metrics",r);else{let e=r.requestId;if(hs.has(e)){let{resolve:t}=hs.get(e);hs.delete(e);let{type:n,requestId:o,...i}=r;ep(r)?t(r.result):r.type==="VP_EDIT_RPC_RESPONSE"||r.type==="VP_EDIT_RPC_REJECT"?t(r):tp(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=GS();return Rr.postMessage({requestId:e,...r}),new Promise((t,n)=>{hs.set(e,{resolve:t,reject:n})})},YS={subscribe:(r,e)=>{us.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&&us.has(r)&&us.delete(r)},rpcCall:async r=>$a(r),getTableList:async()=>$a({type:Yd}),getTableSchema:async r=>$a({type:Xd,table:r})},Ua=class extends $S{async connect({url:e,authToken:t,username:n,protocol:o,retryLimitDisconnect:i,retryLimitStartup:s}){return Rr=await QS({protocol:o,url:e,token:t,username:n,retryLimitDisconnect:i,retryLimitStartup:s,handleConnectionStatusChange:op}),YS}destroy(){Rr.terminate()}},fs=new Ua;var ip=async r=>{try{return(await rp).rpcCall(r)}catch{throw Error("Error accessing server api")}};var XS=0,zo=class{constructor(e,t){this.from=e,this.to=t}},J=class{constructor(e={}){this.id=XS++,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 ZS=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):ZS,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)}},ds=new WeakMap,sp=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=ds.get(this)||this.topNode,i=new Pr(o);return i.moveTo(e,t),ds.set(this,i._tree),i}get topNode(){return new Rt(this,0,0,null)}resolve(e,t=0){let n=Ir(ds.get(this)||this.topNode,e,t,!1);return ds.set(this,n),n}resolveInner(e,t=0){let n=Ir(sp.get(this)||this.topNode,e,t,!0);return sp.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 eC(e)}};le.empty=new le(ke.none,[],[],0);var Wo=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 Wo(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&&!(ap(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 ap(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 cp(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 Rt&&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 Rt&&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 Rt=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(ap(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 Rt(f.tree,h,e,s);let d=new Rt(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 Rt(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 cp(this,e)}getChild(e,t=null,n=null){let o=ms(this,e,t,n);return o.length?o[0]:null}getChildren(e,t=null,n=null){return ms(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return gs(this,e)}};function ms(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 gs(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 cp(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let o=ms(this,e,t,n);return o.length?o[0]:null}getChildren(e,t=null,n=null){return ms(this,e,t,n)}get node(){return this}matchContext(e){return gs(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 Rt)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 Rt?(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 gs(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 gs(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 eC(r){var e;let{buffer:t,nodeSet:n,maxBufferLength:o=1024,reused:i=[],minRepeatType:s=n.types.length}=r,l=Array.isArray(t)?new Wo(t,t.length):t,a=n.types,c=0,u=0;function h(x,S,b,C,k){let{id:E,start:R,end:N,size:O}=l,M=u;for(;O<0;)if(l.next(),O==-1){let V=i[E];b.push(V),C.push(R-x);return}else if(O==-3){c=E;return}else if(O==-4){u=E;return}else throw new RangeError(`Unrecognized record size: ${O}`);let D=a[E],F,G,A=R-x;if(N-R<=o&&(G=m(l.pos-S,k))){let V=new Uint16Array(G.size-G.skip),B=l.pos-G.size,U=V.length;for(;l.pos>B;)U=g(G.start,V,U);F=new Zt(V,N-G.start,n),A=G.start-x}else{let V=l.pos-O;l.next();let B=[],U=[],X=E>=s?E:-1,ee=0,_e=N;for(;l.pos>V;)X>=0&&l.id==X&&l.size>=0?(l.end<=_e-o&&(d(B,U,R,ee,l.end,_e,X,M),ee=B.length,_e=l.end),l.next()):h(R,V,B,U,X);if(X>=0&&ee>0&&ee<B.length&&d(B,U,R,ee,R,_e,X,M),B.reverse(),U.reverse(),X>-1&&ee>0){let de=f(D);F=Ja(D,B,U,0,B.length,0,N-R,de,de)}else F=p(D,B,U,N-R,M-N)}b.push(F),C.push(A)}function f(x){return(S,b,C)=>{let k=0,E=S.length-1,R,N;if(E>=0&&(R=S[E])instanceof le){if(!E&&R.type==x&&R.length==C)return R;(N=R.prop(J.lookAhead))&&(k=b[E]+R.length+N)}return p(x,S,b,C,k)}}function d(x,S,b,C,k,E,R,N){let O=[],M=[];for(;x.length>C;)O.push(x.pop()),M.push(S.pop()+b-k);x.push(p(n.types[R],O,M,E-k,N-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,N={size:0,start:0,skip:0};e:for(let O=b.pos-x;b.pos>O;){let M=b.size;if(b.id==S&&M>=0){N.size=C,N.start=k,N.skip=E,E+=4,C+=4,b.next();continue}let D=b.pos-M;if(M<0||D<O||b.start<R)break;let F=b.id>=s?4:0,G=b.start;for(b.next();b.pos>D;){if(b.size<0)if(b.size==-3)F+=4;else break e;else b.id>=s&&(F+=4);b.next()}k=G,C+=M,E+=F}return(S<0||C==x)&&(N.size=C,N.start=k,N.skip=E),N.size>4?N:void 0}function g(x,S,b){let{id:C,start:k,end:E,size:R}=l;if(l.next(),R>=0&&C<s){let N=b;if(R>4){let O=l.pos-(R-4);for(;l.pos>O;)b=g(x,S,b)}S[--b]=N,S[--b]=E-x,S[--b]=k-x,S[--b]=C}else R==-3?c=C:R==-4&&(u=C);return b}let y=[],v=[];for(;l.pos>0;)h(r.start||0,r.bufferStart||0,y,v,-1);let w=(e=r.length)!==null&&e!==void 0?e:y.length?v[0]+y[0].length:0;return new le(a[r.topID],y.reverse(),v.reverse(),w)}var lp=new WeakMap;function ps(r,e){if(!r.isAnonymous||e instanceof Zt||e.type!=r)return 1;let t=lp.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=r||!(n instanceof le)){t=1;break}t+=ps(r,n)}lp.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+=ps(r,e[p]);let u=Math.ceil(c*1.5/8),h=[],f=[];function d(p,m,g,y,v){for(let w=g;w<y;){let x=w,S=m[w],b=ps(r,p[w]);for(w++;w<y;w++){let C=ps(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 zo(o.from,o.to)):[new zo(0,0)]:[new zo(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 ys(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 ys(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()}},ys=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},up;(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"})(up||(up={}));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 $o(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}},hp=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=hp,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=hp,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;bp(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"?$o(e):e}token(e,t){let n=e.pos,o=0;for(;;){let i=e.next<0,s=e.resolveOffset(1,1);if(bp(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 bp(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||nC(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],g=r[p+1]||65536;if(u<m)f=d;else if(u>=g)h=d+1;else{s=r[p+2],e.advance();continue e}}break}}function fp(r,e,t){for(let n=e,o;(o=r[n])!=65535;n++)if(o==t)return n-e;return-1}function nC(r,e,t,n){let o=fp(t,n,e);return o<0||fp(t,n,r)<o}var It=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),Qa=null,dp;(function(r){r[r.Margin=25]="Margin"})(dp||(dp={}));function pp(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?pp(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?pp(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}},mp;(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"})(mp||(mp={}));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&&rC(o);if(s)return this.stackToTree(s);if(this.parser.strict)throw It&&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=It?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),It&&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),It&&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),It&&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 gp(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=It?this.stackID(l)+" -> ":"";if(l.deadEnd&&(i||(i=!0,l.restart(),It&&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&&(It&&console.log(f+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));d++)It&&(f=this.stackID(h)+" -> ");for(let d of l.recoverByInsert(a))It&&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),It&&console.log(u+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),gp(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 gp(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=$o(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(yp),this.states=$o(e.states,Uint32Array),this.data=$o(e.stateData),this.goto=$o(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]=yp(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 rC(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 yp(r){if(r.external){let e=r.extend?1:0;return(t,n)=>r.external(t,n)<<1|e}return r.get}var Uo=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 Go,isMultiValueFilter as oC,isSingleValueFilter as iC}from"@vuu-ui/vuu-utils";var Qe,oc=class{constructor(){te(this,Qe,void 0)}setFilterCombinatorOp(e,t=T(this,Qe)){Go(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(Go(T(this,Qe)))T(this,Qe).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=T(this,Qe)){if(Go(t)){let n=t.filters.at(-1);n&&this.setColumn(e,n)}else t&&(t.column=e)}setOp(e,t=T(this,Qe)){if(Go(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(Go(t)){let o=t.filters.at(-1);o&&this.setValue(e,o)}else oC(t)?((n=t.values)!=null||(t.values=[]),t.values.push(e)):iC(t)&&(t.value=e)}toJSON(e=T(this,Qe)){return this.name?{...e,name:this.name}:e}};Qe=new WeakMap;var bs=(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 sC=Uo.configure({strict:!0}),Jn=r=>{let e=sC.parse(r);return bs(e,r)};function xs(r,e){switch(e.op){case"in":return lC(r,e);case"=":return aC(r,e);case">":return cC(r,e);case">=":return uC(r,e);case"<":return hC(r,e);case"<=":return fC(r,e);case"starts":return dC(r,e);case"and":return pC(r,e);case"or":return mC(r,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var lC=(r,e)=>t=>e.values.indexOf(t[r[e.column]])!==-1,aC=(r,e)=>t=>t[r[e.column]]===e.value,cC=(r,e)=>t=>t[r[e.column]]>e.value,uC=(r,e)=>t=>t[r[e.column]]>=e.value,hC=(r,e)=>t=>t[r[e.column]]<e.value,fC=(r,e)=>t=>t[r[e.column]]<=e.value,dC=(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())}},pC=(r,e)=>{let t=e.filters.map(n=>xs(r,n));return n=>t.every(o=>o(n))};function mC(r,e){let t=e.filters.map(n=>xs(r,n));return n=>t.some(o=>o(n))}import{buildColumnMap as IC,EventEmitter as PC,getSelectionStatus as DC,KeySet as LC,logger as AC,metadataKeys as OC,NULL_RANGE as Ep,rangeNewItems as NC,resetRange as qo,uuid as Rp}from"@vuu-ui/vuu-utils";var xp=(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 wp(i,n,o,r,e,a);case 2:return gC(i,n,o,r,e,a);case 3:return vp(i,o,r,e,a);case 4:return bC(i,n,o,r,e,a);case 5:return xC(i,n,o,r,e,a);case 6:return yC(i,n,o,r,e,a)}};function vp(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 wp(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 gC(r,e,t,n,o,i){let s={},l=Qn(t,n),a=vp(r,t,n,o,i),c=wp(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 vs(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(...vs(r[o],e,t));return n}function yC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=vs(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 bC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=vs(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 xC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=vs(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 vC}from"@vuu-ui/vuu-utils";var{DEPTH:ic,IS_EXPANDED:Sp,KEY:sc}=vC,Cp=(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[Sp]=!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 Tp(o,s,r,e,void 0,void 0,void 0,i)},Tp=(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[Sp]=!0,Array.isArray(r[c])?wC(s,r[c],n,h,i+1):Tp(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},wC=(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)}},kp=(r,e,t)=>{let n=e.map(s=>t[s]),o=CC(r,n);return[SC(o,n),o]},SC=(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 CC(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 TC=(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},kC=r=>r.length===1?MC(r):r.length===2?EC(r):RC(r),MC=([[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},EC=([[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},RC=(r,e=TC)=>(t,n)=>{for(let o of r){let i=e(t,n,o);if(i!==0)return i}return 0},Mp=(r,{sortDefs:e},t)=>{let n=e.map(({column:i,sortType:s})=>[t[i],s]),o=kC(n);return r.slice().sort(o)};var{debug:ht}=AC("ArrayDataSource"),{RENDER_IDX:VC,SELECTED:FC}=OC,BC=(r,e)=>[e,e,!0,!1,1,0,r[0].toString(),0,...r],HC=r=>({columns:r.map(({name:t,serverDataType:n="string"})=>({name:t,serverDataType:n})),key:r[0].name,table:{module:"",table:"Array"}}),_C=(r,e,t)=>{let[n]=r,o=r.slice();return o[VC]=e.keyFor(n),o[FC]=DC(t,n),o},Ko,Pt,Q,Ae,ve,ws,jo,Nr,Ip=class extends PC{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=[];te(this,Ko,[]);te(this,Pt,void 0);te(this,Q,Er);te(this,Ae,void 0);te(this,ve,Ep);te(this,ws,0);te(this,jo,0);te(this,Nr,void 0);this.keys=new LC(T(this,ve));this.processedData=void 0;if(!o||!n)throw Error("ArrayDataSource constructor called without data or without columnDescriptors");this.columnDescriptors=n,z(this,Ko,n.map(h=>h.name)),z(this,Pt,IC(T(this,Ko))),this.rangeChangeRowset=l,this.tableSchema=HC(n),z(this,Ae,o.map(BC)),this.viewport=u||Rp(),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,Pt))}`)}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,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)!==Ep&&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(qo(T(this,ve)),!0)}openTreeNode(t){this.openTreeNodes.push(t),this.processedData=lc(this.openTreeNodes,T(this,Ae),T(this,Q).groupBy,T(this,Pt),this.groupMap,this.processedData),this.setRange(qo(T(this,ve)),!0)}closeTreeNode(t){this.openTreeNodes=this.openTreeNodes.filter(n=>n!==t),this.processedData&&(this.processedData=Cp(t,this.processedData),this.setRange(qo(T(this,ve)),!0))}get data(){return T(this,Ae)}get currentData(){var t;return(t=this.processedData)!=null?t:T(this,Ae)}get config(){return T(this,Q)}set config(t){var n;if(as(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,cs(i));let s;if(Kd(t)){let{filter:l,filterStruct:a=Jn(l)}=t.filter;if(a){let c=xs(T(this,Pt),a);s=T(this,Ae).filter(c)}else throw Error("filter must include filterStruct")}if(jd(t)&&(s=Mp(s!=null?s:T(this,Ae),t.sort,T(this,Pt))),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})),qd(t)){let[l,a]=kp(s!=null?s:T(this,Ae),t.groupBy,T(this,Pt));this.groupMap=a,s=l,this.openTreeNodes.length>0&&(s=lc(this.openTreeNodes,T(this,Ae),T(this,Q).groupBy,T(this,Pt),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(qo(T(this,ve)),!0),this.emit("config",T(this,Q))}}get selectedRowsCount(){return T(this,ws)}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?NC(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=>_C(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){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);xp(t,n,T(this,Q).groupBy,o,T(this,Pt),this.groupMap),this.setRange(qo(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)}})}};Ko=new WeakMap,Pt=new WeakMap,Q=new WeakMap,Ae=new WeakMap,ve=new WeakMap,ws=new WeakMap,jo=new WeakMap,Nr=new WeakMap;import{EventEmitter as zC,isSelected as WC,jsonToDataSourceRows as $C,KeySet as UC,metadataKeys as GC,uuid as Pp}from"@vuu-ui/vuu-utils";var qC={columns:[],key:"",table:{module:"",table:""}},{DEPTH:Vr,IDX:Dp,IS_EXPANDED:KC,IS_LEAF:jC,KEY:Vp,SELECTED:Lp}=GC,Ap=(r,e)=>{let[t]=r,n=r.slice();return n[1]=e.keyFor(t),n},bn,ft,Ye,xn,vn,_t,Ss,Cs,wn,Fr,Op=class extends zC{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=[];te(this,bn,[]);te(this,ft,Er);te(this,Ye,void 0);te(this,xn,{filter:""});te(this,vn,[]);te(this,_t,{from:0,to:0});te(this,Ss,0);te(this,Cs,0);te(this,wn,{sortDefs:[]});te(this,Fr,void 0);this.keys=new UC(T(this,_t));if(!n)throw Error("JsonDataSource constructor called without data");[this.columnDescriptors,Nh(this,Ye)._]=$C(n),this.visibleRows=T(this,Ye).filter(c=>c[Vr]===0).map((c,u)=>[u,u].concat(c.slice(2))),this.viewport=a||Pp(),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:Pp())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var h;this.clientCallback=c,console.log(`subscribe range ${i==null?void 0:i.from} ${i==null?void 0:i.to}`),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:qC}),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{[Dp]:s,[Lp]:l}=i,a=l===1,c=WC(t,s);if(c!==a){let u=i.slice();u[Lp]=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=Np(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=>Ap(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=Np(T(this,Ye),this.expandedRows),this.sendRowsToClient()}get config(){return T(this,ft)}get selectedRowsCount(){return T(this,Ss)}get size(){return T(this,Cs)}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=>Ap(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)}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[Vp]===t);if(n){let{[Dp]: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,Ss=new WeakMap,Cs=new WeakMap,wn=new WeakMap,Fr=new WeakMap;function Np(r,e){let t=[],n={value:0};for(let o=0;o<r.length;o++){let i=r[o],{[Vr]:s,[Vp]:l,[jC]:a}=i,c=e.has(l);if(t.push(JC(i,n,c)),!a&&!c)do o+=1;while(o<r.length-1&&r[o+1][Vr]>s)}return t}var JC=(r,e,t)=>{let n=r.slice();return n[0]=e.value,n[1]=e.value,t&&(n[KC]=!0),e.value+=1,n};import{debounce as Fp,EventEmitter as QC,itemsOrOrderChanged as YC,logger as XC,throttle as ZC,uuid as eT}from"@vuu-ui/vuu-utils";var{info:Ue}=XC("RemoteDataSource"),W,Ts,Br,tn,Jo,Hr,Yn,ac=class extends QC{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";te(this,W,Er);te(this,Ts,[]);te(this,Br,"throttle");te(this,tn,{from:0,to:0});te(this,Jo,0);te(this,Hr,0);te(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(Qd(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=Fp(()=>{this.optimize="throttle"},100);this.rawRangeRequest=t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})};this.debounceRangeRequest=Fp(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},50);this.throttleRangeRequest=ZC(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,W,{...T(this,W),aggregations:n||T(this,W).aggregations,columns:o||T(this,W).columns,filter:i||T(this,W).filter,groupBy:s||T(this,W).groupBy,sort:l||T(this,W).sort,visualLink:h||T(this,W).visualLink}),z(this,Yn,c),this.rangeRequest=this.throttleRangeRequest}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:eT())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var f;if(this.clientCallback=c,(o||n||a||l||s)&&z(this,W,{...T(this,W),aggregations:o||T(this,W).aggregations,columns:n||T(this,W).columns,filter:a||T(this,W).filter,groupBy:l||T(this,W).groupBy,sort:s||T(this,W).sort}),i&&z(this,tn,i),this.status!=="initialising")return;this.status="subscribing",this.viewport=t,this.server=await Ga();let{bufferSize:h}=this;(f=this.server)==null||f.subscribe({...T(this,W),bufferSize:h,viewport:t,table:this.table,range:T(this,tn),title:T(this,Yn)},this.handleMessageFromServer)}unsubscribe(){var t,n;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()}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,Jo,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,Jo)}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,W)}set config(t){var n,o;if(as(T(this,W),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,W,cs(i)),T(this,W)&&this.viewport&&this.server&&t&&((o=this.server)==null||o.send({viewport:this.viewport,type:"config",config:T(this,W)})),this.emit("config",T(this,W))}}get columns(){return T(this,W).columns}set columns(t){if(z(this,W,{...T(this,W),columns:t}),this.viewport){let n={viewport:this.viewport,type:"setColumns",columns:t};this.server&&this.server.send(n)}this.emit("config",T(this,W))}get aggregations(){return T(this,W).aggregations}set aggregations(t){var n;z(this,W,{...T(this,W),aggregations:t}),this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"aggregate",aggregations:t})),this.emit("config",T(this,W))}get sort(){return T(this,W).sort}set sort(t){if(z(this,W,{...T(this,W),sort:t}),this.viewport){let n={viewport:this.viewport,type:"sort",sort:t};this.server&&this.server.send(n)}this.emit("config",T(this,W))}get filter(){return T(this,W).filter}set filter(t){if(z(this,W,{...T(this,W),filter:t}),this.viewport){let n={viewport:this.viewport,type:"filter",filter:t};this.server&&this.server.send(n)}this.emit("config",T(this,W))}get groupBy(){return T(this,W).groupBy}set groupBy(t){var n;if(YC(this.groupBy,t)){let o=T(this,Ts).length>0;if(z(this,W,{...T(this,W),groupBy:t}),this.viewport){let i={viewport:this.viewport,type:"groupBy",groupBy:T(this,W).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,W)),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,W).visualLink}set visualLink(t){var n,o;if(z(this,W,{...T(this,W),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,W))}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}};W=new WeakMap,Ts=new WeakMap,Br=new WeakMap,tn=new WeakMap,Jo=new WeakMap,Hr=new WeakMap,Yn=new WeakMap;import{useCallback as y4,useEffect as b4,useState as x4}from"react";import{useCallback as tT}from"react";var Bp={type:"RPC_CALL",service:"TypeAheadRpcHandler"};var cc=()=>tT(async e=>{let t=e.length===2?{method:"getUniqueFieldValues",params:e,...Bp}:{method:"getUniqueFieldValuesStartingWith",params:e,...Bp};return await ip(t)},[]);import{getRowRecord as I4,isGroupMenuItemDescriptor as P4,metadataKeys as nT}from"@vuu-ui/vuu-utils";import{useCallback as L4}from"react";var{KEY:A4}=nT;import{useCallback as V4,useEffect as F4,useState as B4}from"react";import{ExpandoInput as iT}from"@vuu-ui/vuu-ui-controls";import{jsx as Ms}from"react/jsx-runtime";var sT=rT(function({InputProps:e={},className:t,column:n,onInputComplete:o,operator:i,suggestionProvider:s=cc,table:l,value:a},c){let[u,h]=_p(a!=null?a:""),[f,d]=_p([]),p=s(),m=ks((x,S)=>o(S),[o]),g=ks((x,S)=>{S.length===1?o(S[0]):S.length>1&&o(S)},[o]);Hp(()=>{},[n]),Hp(()=>{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 y=ks(x=>{let{value:S}=x.target;h(S)},[]),v=oT(()=>{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 ks(()=>{switch(i){case"in":return Ms(Ho,{InputProps:v,className:t,initialHighlightedIndex:0,source:f,onInputChange:y,onSelectionChange:g,ref:c,selectionStrategy:"multiple",value:a});case"starts":return Ms(Ho,{InputProps:v,ListProps:{className:"vuuIllustrationsOnly",disabled:!0},allowFreeText:!0,className:t,initialHighlightedIndex:0,source:f,onInputChange:y,onSelectionChange:m,ref:c,value:a});case"ends":return Ms(iT,{...v,className:t,value:u,ref:c,onChange:y});default:return Ms(Ho,{InputProps:v,className:t,initialHighlightedIndex:0,source:f,title:"value",onInputChange:y,onSelectionChange:m,ref:c,value:a})}},[i,v,t,f,y,g,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{jsx as q_,jsxs as K_}from"react/jsx-runtime";import{EditableLabel as N3}from"@vuu-ui/vuu-ui-controls";import{filterAsQuery as B3,isMultiClauseFilter as H3}from"@vuu-ui/vuu-utils";import z3 from"classnames";import{useCallback as U3,useRef as G3}from"react";import{PopupMenu as l3}from"@vuu-ui/vuu-popups";import{useMemo as c3}from"react";import h3 from"classnames";import{jsx as g3}from"react/jsx-runtime";import{extractFilterForColumn as w3,isAndFilter as S3,isCompleteFilter as C3,isInFilter as T3,isMultiClauseFilter as k3,isMultiValueFilter as M3,isOrFilter as E3,isSingleValueFilter as R3,partition as I3}from"@vuu-ui/vuu-utils";import{jsx as Q3,jsxs as Y3}from"react/jsx-runtime";import{dispatchMouseEvent as uz,filterAsQuery as hz}from"@vuu-ui/vuu-utils";import{useCallback as mz,useEffect as gz,useMemo as yz,useRef as bz,useState as xz}from"react";import{useControlled as nz}from"@vuu-ui/vuu-ui-controls";import{useCallback as oz}from"react";import{jsx as Jz,jsxs as Qz}from"react/jsx-runtime";import{createElement as jz}from"react";import{Button as K5}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 Ps(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 Ds(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=cT(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(zp(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(o&1){let s=n.pop(),l=Is(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=Is(this.text,Is(n.text,zp(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 cT(r){let e=-1;for(let t of r)e+=t.length+1;return e}function Is(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 zp(r,e,t){return Is(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)}},Ps=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!=""}},Ds=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]=Ps.prototype[Symbol.iterator]=Ds.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 uT(r){for(let e=1;e<_r.length;e+=2)if(_r[e]>r)return _r[e-1]<=r;return!1}function Wp(r){return r>=127462&&r<=127487}var $p=8205;function Ve(r,e,t=!0,n=!0){return(t?Jp:hT)(r,e,n)}function Jp(r,e,t){if(e==r.length)return e;e&&Qp(r.charCodeAt(e))&&Yp(r.charCodeAt(e-1))&&e--;let n=zt(r,e);for(e+=tr(n);e<r.length;){let o=zt(r,e);if(n==$p||o==$p||t&&uT(o))e+=tr(o),n=o;else if(Wp(o)){let i=0,s=e-2;for(;s>=0&&Wp(zt(r,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function hT(r,e,t){for(;e>0;){let n=Jp(r,e-2,t);if(n<e)return n;e--}return 0}function Qp(r){return r>=56320&&r<57344}function Yp(r){return r>=55296&&r<56320}function zt(r,e){let t=r.charCodeAt(e);if(!Yp(t)||e+1==r.length)return t;let n=r.charCodeAt(e+1);return Qp(n)?(t-55296<<10)+(n-56320)+65536:t}function Xp(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:Zp(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:Zp(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 Zp(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 I.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return I.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 I.range(e.anchor,e.head)}static create(e,t,n){return new nn(e,t,n)}},I=class{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:I.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 I([this.main],0)}addRange(e,t=!0){return I.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,I.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 I(e.ranges.map(t=>nn.fromJSON(t)),e.main)}static single(e,t=e){return new I([I.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 I.normalized(e.slice(),t);n=i.to}return new I(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?I.range(a,l):I.range(l,a))}}return new I(e,t)}};function em(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var wc=0,$=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 $(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?!Up(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=As(f,p);if(this.dependencies.every(g=>g instanceof $?f.facet(g)===h.facet(g):g instanceof qe?f.field(g,!1)==h.field(g,!1):!0)||(l?Up(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 Up(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)Yo(r,n)&1&&(t=!0);return t}function fT(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=As(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)Yo(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 Gp=$.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(Gp).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,Gp.of({field:this,create:e})]}get extension(){return this}},Xn={lowest:4,low:3,default:2,high:1,highest:0};function Qo(r){return e=>new Ls(e,r)}var ir={highest:Qo(Xn.highest),high:Qo(Xn.high),default:Qo(Xn.default),low:Qo(Xn.low),lowest:Qo(Xn.lowest)},Ls=class{constructor(e,t){this.inner=e,this.prec=t}},$r=class{of(e){return new Xo(this,e)}reconfigure(e){return $r.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Xo=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 dT(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(g=>g.type==0))if(l[p.id]=a.length<<1|1,Sc(m,d))a.push(n.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=c.length<<1,c.push(y=>g.dynamicSlot(y)));l[p.id]=c.length<<1,c.push(g=>fT(g,p,d))}}let h=c.map(f=>f(l));return new Ur(e,s,h,l,a,i)}};function dT(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 Xo&&t.delete(s.compartment)}if(o.set(s,l),Array.isArray(s))for(let c of s)i(c,l);else if(s instanceof Xo){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 Ls)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 Yo(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 As(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}var tm=$.define(),nm=$.define({combine:r=>r.some(e=>e),static:!0}),rm=$.define({combine:r=>r.length?r[0]:void 0,static:!0}),om=$.define(),im=$.define(),sm=$.define(),lm=$.define({combine:r=>r.length?r[0]:!1}),tt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Os}},Os=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&&em(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 pT(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 am(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(rm)),selection:n&&(n instanceof I?n:I.single(n.anchor,n.head)),effects:Wr(e.effects),annotations:o,scrollIntoView:!!e.scrollIntoView}}function cm(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=am(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 gT(t?mT(o):o)}function mT(r){let e=r.startState,t=!0;for(let o of e.facet(om)){let i=o(r);if(i===!1){t=!1;break}Array.isArray(i)&&(t=t===!0?i:pT(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(im);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=cm(e,Wr(i),!1)}return r}function gT(r){let e=r.startState,t=e.facet(sm),n=r;for(let o=t.length-1;o>=0;o--){let i=t[o](r);i&&Object.keys(i).length&&(n=am(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 yT=[];function Wr(r){return r==null?yT: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={})),bT=/[\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 xT(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()||bT.test(t)))return!0}return!1}function vT(r){return e=>{if(!/\S/.test(e))return Ge.Space;if(xT(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++)Yo(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 Yo(this,n),As(this,n)}update(...e){return cm(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:I.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:I.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:(Yo(this,t),As(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:I.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 I?e.selection:I.single(e.selection.anchor,e.selection.head):I.single(0);return em(o,n.length),t.staticFacet(nm)||(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(lm)}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(tm))for(let s of i(this,t,n))Object.prototype.hasOwnProperty.call(s,e)&&o.push(s[e]);return o}charCategorizer(e){return vT(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:I.range(s+n,l+n)}};Z.allowMultipleSelections=nm;Z.tabSize=$.define({combine:r=>r.length?r[0]:4});Z.lineSeparator=rm;Z.readOnly=lm;Z.phrases=$.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=tm;Z.changeFilter=om;Z.transactionFilter=im;Z.transactionExtender=sm;$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 Dt=class{eq(e){return this==e}range(e,t=e){return rr.create(e,t,this)}};Dt.prototype.startSide=Dt.prototype.endSide=0;Dt.prototype.point=!1;Dt.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 Zo=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 Zo(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 Ns(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=qp(s,l,n),c=new Zn(s,a,i),u=new Zn(l,a,i);n.iterGaps((h,f,d)=>Kp(c,h,u,f,d,o)),n.empty&&n.length==0&&Kp(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=qp(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?wT(e):e)n.add(o.from,o.to,o.value);return n.finish()}};oe.empty=new oe([],[],null,-1);function wT(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 Zo(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 qp(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 Ns=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 Ns(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){Es(this.active,e),Es(this.activeTo,e),Es(this.activeRank,e),this.minActive=jp(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++;Rs(this.active,t,n),Rs(this.activeTo,t,o),Rs(this.activeRank,t,i),e&&Rs(e,t,this.cursor.from),this.minActive=jp(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&&Es(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 Kp(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 Es(r,e){for(let t=e,n=r.length-1;t<n;t++)r[t]=r[t+1];r.pop()}function Rs(r,e,t){for(let n=r.length-1;n>=e;n--)r[n+1]=r[n];r[e]=t}function jp(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 um(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",hm=typeof Symbol>"u"?"__"+Cc:Symbol.for(Cc),Tc=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),fm=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(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),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=fm[hm]||1;return fm[hm]=e+1,Cc+e.toString(36)}static mount(e,t){(e[Tc]||new kc(e)).mount(Array.isArray(t)?t:[t])}},dm=new Map,kc=class{constructor(e){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let o=dm.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],dm.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:'"'},ST=typeof navigator<"u"&&/Mac/.test(navigator.platform),CT=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(Vs in rn)Gr.hasOwnProperty(Vs)||(Gr[Vs]=rn[Vs]);var Vs;function pm(r){var e=ST&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||CT&&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 Js(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 TT(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Us(r,e){if(!e.anchorNode)return!1;try{return Dc(r,e.anchorNode)}catch{return!1}}function ii(r){return r.nodeType==3?cr(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function Qs(r,e,t,n){return t?mm(r,e,t,n,-1)||mm(r,e,t,n,1):!1}function Ys(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function mm(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=Ys(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 kT(r){return{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function MT(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=kT(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 g=u.getBoundingClientRect();f={left:g.left,right:g.left+u.clientWidth,top:g.top,bottom:g.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 g=e.bottom-e.top,y=f.bottom-f.top;m=(o=="center"&&g<=y?e.top+g/2-y/2:o=="start"||o=="center"&&t<0?e.top-s:e.bottom-y+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 g=0,y=0;if(m){let v=u.scrollTop;u.scrollTop+=m,y=u.scrollTop-v}if(p){let v=u.scrollLeft;u.scrollLeft+=p,g=u.scrollLeft-v}e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y},g&&Math.abs(g-p)<1&&(n="nearest"),y&&Math.abs(y-m)<1&&(o="nearest")}if(d)break;u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function ET(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 jm(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 gm;function cr(r,e,t=e){let n=gm||(gm=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 RT(r){for(;r;){if(r&&(r.nodeType==9||r.nodeType==11&&r.host))return r;r=r.assignedSlot||r.parentNode}return null}function Jm(r){for(;r.attributes.length;)r.removeAttributeNode(r.attributes[0])}function IT(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=Ys(t),t=t.parentNode}}function Qm(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,Ys(e),t)}static after(e,t){return new Pe(e.parentNode,Ys(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=ym(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=ym(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 Xs(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 ym(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}var Xs=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 Ym(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 Xm(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,Ym(r,c,u,l,a,n,0,o,i)}var Kr="\uFFFF",Zs=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:bm(o))||bm(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 bm(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}var el=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),Zm=/MSIE \d/.test(nt.userAgent),Nc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nt.userAgent),sl=!!(Zm||Nc||Oc),xm=!sl&&/gecko\/(\d+)/i.test(nt.userAgent),Mc=!sl&&/Chrome\/(\d+)/.exec(nt.userAgent),vm="webkitFontSmoothing"in Ac.documentElement.style,eg=!sl&&/Apple Computer/.test(nt.vendor),wm=eg&&(/Mobile\/\w+/.test(nt.userAgent)||nt.maxTouchPoints>2),H={mac:wm||/Mac/.test(nt.platform),windows:/Win/.test(nt.platform),linux:/Linux|X11/.test(nt.platform),ie:sl,ie_version:Zm?Ac.documentMode||6:Nc?+Nc[1]:Oc?+Oc[1]:0,gecko:xm,gecko_version:xm?+(/Firefox\/(\d+)/.exec(nt.userAgent)||[0,0])[1]:0,chrome:!!Mc,chrome_version:Mc?+Mc[1]:0,ios:wm,android:/Android\b/.test(nt.userAgent),webkit:vm,safari:eg,webkit_version:vm?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Ac.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},PT=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>PT||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 DT(this.dom,e,t)}},Lt=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(Jm(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 Lt&&n.mark.eq(this.mark))||e&&i<=0||t<this.length&&s<=0)?!1:(Xm(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 Lt(this.mark,t,s)}domAtPos(e){return tg(this,e)}coordsAt(e,t){return rg(this,e,t)}};function DT(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 tg(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 ng(r,e,t){let n,{children:o}=r;t>0&&e instanceof Lt&&o.length&&(n=o[o.length-1])instanceof Lt&&n.mark.eq(e.mark)?ng(n,e.children[0],t-1):(o.push(e),e.setParent(r)),r.length+=e.length}function rg(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):LT(r)}function LT(r){let e=r.dom.lastChild;if(!e)return r.dom.getBoundingClientRect();let t=ii(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 Sm=Object.create(null);function du(r,e,t){if(r==e)return!0;r||(r=Sm),e||(e=Sm);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 AT(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 Dt{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}=og(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}=og(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&&OT(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 og(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 OT(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),Xm(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){ng(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 tg(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Jm(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 Lt;)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=ii(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=rg(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(Fs(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(Fs(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 tl("div"),l,a))}else{let a=on.create(n.widget||new tl("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(Fs(new Mn(1),o),i),i=o.length+Math.max(0,i-o.length)),h.append(Fs(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 Fs(r,e){for(let t of e)r=new Lt(t,[r],r.length);return r}var tl=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}},ig=$.define(),sg=$.define(),lg=$.define(),ag=$.define(),Hc=$.define(),cg=$.define(),ug=$.define(),hg=$.define({combine:r=>r.some(e=>e)}),fg=$.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)}},Cm=ie.define({map:(r,e)=>r.map(e)});function Ut(r,e,t){let n=r.facet(ag);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 ll=$.define({combine:r=>r.length?r[0]:!0}),NT=0,ei=$.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(NT++,e,n,s=>{let l=[ei.of(s)];return i&&l.push(si.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)}},ri=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}},dg=$.define(),pu=$.define(),si=$.define(),mu=$.define(),pg=$.define();function mg(r){let e=0,t=0,n=0,o=0;for(let i of r.state.facet(pg)){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 ti=$.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,VT=pe.RTL;function gg(r){let e=[];for(let t=0;t<r.length;t++)e.push(1<<+r[t]);return e}var FT=gg("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),BT=gg("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 HT(r){return r<=247?FT[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?BT[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:r==8204?256:1}var _T=/[\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?VT:_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 zT(r,e){let t=r.length,n=e==_c?1:2,o=e==_c?2:1;if(!r||n==1&&!_T.test(r))return yg(t);for(let s=0,l=n,a=n;s<t;s++){let c=HT(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 yg(r){return[new Tn(0,r,0)]}var bg="";function WT(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(bg=r.text.slice(Math.min(s,u),Math.max(s,u)),u!=a.side(o,t))return I.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?I.cursor(o?r.to:r.from,o?-1:1,t):h&&h.level<a.level?I.cursor(h.side(!o,t)+r.from,o?1:-1,h.level):I.cursor(u+r.from,o?-1:1,a.level)}var nl=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:UT(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=qT(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 rl&&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:g,off:y}=i.findPos(c,1),{i:v,off:w}=i.findPos(a,-1);Ym(this,v,w,g,y,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 Lt(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&&Us(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&&$T(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||!Qs(a.node,a.offset,u.anchorNode,u.anchorOffset)||!Qs(c.node,c.offset,u.focusNode,u.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(u.focusNode)&&KT(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=Js(this.view.root);if(h)if(l.empty){if(H.gecko){let f=GT(a.node,a.offset);if(f&&f!=3){let d=vg(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=Js(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?ii(p):[];if(m.length){let g=m[m.length-1],y=a?g.right-d.left:d.right-g.left;y>l&&(l=y,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=ii(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 Xs(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 rl(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(si).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=mg(this.view),s={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom};MT(this.view.scrollDOM,s,t.head<t.anchor?-1:1,e.x,e.y,e.xMargin,e.yMargin,this.view.textDirection==pe.LTR)}};function $T(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 rl=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 xg(r){let e=r.observer.selectionRange,t=e.focusNode&&vg(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 Zs([],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 UT(r,e){let t=xg(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 Lt)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:AT(f),tagName:f.tagName.toLowerCase()})});else return null}}}function vg(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 GT(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 qT(r,e,t){let n=new Wc;return oe.compare(r,e,t,n),n.changes}function KT(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 jT(r,e,t=1){let n=r.charCategorizer(e),o=r.doc.lineAt(e),i=e-o.from;if(o.length==0)return I.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 I.range(s+o.from,l+o.from)}function JT(r,e){return e.left>r?e.left-r:Math.max(0,r-e.right)}function QT(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 Tm(r,e){return e<r.top?{top:e,left:r.left,right:r.right,bottom:r.bottom}:r}function km(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=ii(p);for(let g=0;g<m.length;g++){let y=m[g];o&&Ec(o,y)&&(y=Tm(km(y,o.bottom),o.top));let v=JT(e,y),w=QT(t,y);if(v==0&&w==0)return p.nodeType==3?Mm(p,e,t):$c(p,e,t);if(!n||s>w||s==w&&i>v){n=p,o=y,i=v,s=w;let x=w?t<y.top?-1:1:v?e<y.left?-1:1:0;l=!x||(x>0?g<m.length-1:g>0)}v==0?t>y.bottom&&(!u||u.bottom<y.bottom)?(a=p,u=y):t<y.top&&(!h||h.top>y.top)&&(c=p,h=y):u&&Ec(u,y)?u=km(u,y.bottom):h&&Ec(h,y)&&(h=Tm(h,y.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 Mm(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 Mm(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 wg(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:Em(r,s,a,u,h);if(d>r.viewport.to)return r.viewport.to==r.state.doc.length?r.state.doc.length:t?null:Em(r,s,a,u,h);let p=r.dom.ownerDocument,m=r.root.elementFromPoint?r.root:p,g=m.elementFromPoint(u,h);g&&!r.contentDOM.contains(g)&&(g=null),g||(u=Math.max(s.left+1,Math.min(s.right-1,u)),g=m.elementFromPoint(u,h),g&&!r.contentDOM.contains(g)&&(g=null));let y,v=-1;if(g&&((o=r.docView.nearest(g))===null||o===void 0?void 0:o.isEditable)!=!1){if(p.caretPositionFromPoint){let x=p.caretPositionFromPoint(u,h);x&&({offsetNode:y,offset:v}=x)}else if(p.caretRangeFromPoint){let x=p.caretRangeFromPoint(u,h);x&&({startContainer:y,startOffset:v}=x,(!r.contentDOM.contains(y)||H.safari&&YT(y,v,u)||H.chrome&&XT(y,v,u))&&(y=void 0))}}if(!y||!r.docView.dom.contains(y)){let x=Ie.find(r.docView,d);if(!x)return f>a.top+a.height/2?a.to:a.from;({node:y,offset:v}=$c(x.dom,u,h))}let w=r.docView.nearest(y);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(y,v)+w.posAtStart}function Em(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+um(s,i,r.state.tabSize)}function YT(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 XT(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 ZT(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 I.cursor(a,t?-1:1)}return I.cursor(t?o.to:o.from,t?-1:1)}function Rm(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=WT(o,i,s,l,t),u=bg;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=I.cursor(t?o.from:o.to)}if(a){if(!a(u))return l}else{if(!n)return c;a=n(u)}l=c}}function ek(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 tk(r,e,t,n){let o=e.head,i=t?1:-1;if(o==(t?r.state.doc.length:0))return I.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=wg(r,{x:h,y:p},!1,i);if(p<a.top||p>a.bottom||(i<0?m<o:m>o))return I.cursor(m,e.assoc,void 0,s)}}function Gs(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=Gs(r.state.facet(mu).map(o=>o(r)),t.from,e.head>t.from?-1:1);return n==t.from?t:I.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=>{Im(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=>{Im(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&&Cg.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=Sg.find(o=>o.keyCode==t.keyCode))&&!t.ctrlKey||nk.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()}},Sg=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],nk="dthko",Cg=[16,17,18,20,91,92,224,225],Bs=6;function Hs(r){return Math.max(0,r)*.7+8}function rk(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=ET(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)&&ok(e,t),this.dragging=sk(e,t)&&Eg(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&&rk(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=mg(this.view);e.clientX-s.left<=i.left+Bs?n=-Hs(i.left-e.clientX):e.clientX+s.right>=i.right-Bs&&(n=Hs(e.clientX-i.right)),e.clientY-s.top<=i.top+Bs?o=-Hs(i.top-e.clientY):e.clientY+s.bottom>=i.bottom-Bs&&(o=Hs(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=Gs(this.atoms,o.from,0);s!=o.from&&(i=I.cursor(s,-1))}else{let s=Gs(this.atoms,o.from,-1),l=Gs(this.atoms,o.to,1);(s!=o.from||l!=o.to)&&(i=I.range(o.from==o.anchor?s:l,o.from==o.head?s:l))}i&&(t||(t=e.ranges.slice()),t[n]=i)}return t?I.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 ok(r,e){let t=r.state.facet(ig);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function ik(r,e){let t=r.state.facet(sg);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function sk(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let n=Js(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 Im(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),Tg=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function lk(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(),kg(r,t.value)},50)}function kg(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:I.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:I.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(lg))if(t=n(r,e),t)break;if(!t&&e.button==0&&(t=uk(r,e)),t){let n=!r.hasFocus;r.inputState.startMouseSelection(new qc(r,e,t,n)),n&&r.observer.ignore(()=>jm(r.contentDOM)),r.inputState.mouseSelection&&r.inputState.mouseSelection.start(e)}};function Pm(r,e,t,n){if(n==1)return I.cursor(e,t);if(n==2)return jT(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++,I.range(s,l)}}var Mg=(r,e)=>r>=e.top&&r<=e.bottom,Dm=(r,e,t)=>Mg(e,t)&&r>=t.left&&r<=t.right;function ak(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&&Dm(t,n,s))return-1;let l=o.coordsAt(i,1);return l&&Dm(t,n,l)?1:s&&Mg(n,s)?-1:1}function Lm(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:ak(r,t,e.clientX,e.clientY)}}var ck=H.ie&&H.ie_version<=11,Am=null,Om=0,Nm=0;function Eg(r){if(!ck)return r.detail;let e=Am,t=Nm;return Am=r,Nm=Date.now(),Om=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(Om+1)%3:1}function uk(r,e){let t=Lm(r,e),n=Eg(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=Lm(r,i),c,u=Pm(r,a.pos,a.bias,n);if(t.pos!=a.pos&&!s){let h=Pm(r,t.pos,t.bias,n),f=Math.min(h.from,u.from),d=Math.max(h.to,u.to);u=f<u.from?I.range(f,d):I.range(d,f)}return s?o.replaceRange(o.main.extend(u.from,u.to)):l&&n==1&&o.ranges.length>1&&(c=hk(o,a.pos))?c:l?o.addRange(u):I.create([u])}}}function hk(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 I.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 Vm(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&&ik(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&&Vm(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 Vm(r,e,e.dataTransfer.getData("Text"),!0)};xe.paste=(r,e)=>{if(r.state.readOnly)return e.preventDefault();r.observer.flush();let t=Tg?null:e.clipboardData;t?(kg(r,t.getData("text/plain")||t.getData("text/uri-text")),e.preventDefault()):lk(r)};function fk(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 dk(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}=dk(r.state);if(!t&&!o)return;jc=o?t:null;let i=Tg?null:e.clipboardData;i?(e.preventDefault(),i.clearData(),i.setData("text/plain",t)):fk(r,t),e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};var Rg=tt.define();function Ig(r,e){let t=[];for(let n of r.facet(ug)){let o=n(r,e);o&&t.push(o)}return t?r.update({effects:t,annotations:Rg.of(!0)}):null}function Pg(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=Ig(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),Pg(r)};xe.blur=r=>{r.observer.clearSelectionRange(),Pg(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=Sg.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 Fm=["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 Fm.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=Fm.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={})),qs=.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)>qs&&(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=li.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 ol=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 ol{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)>=qs&&(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)>=qs||Math.abs(a-this.heightMetrics(e,t).perLine)>=qs)&&(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&&Bm(i,s-1),t<this.length){let l=i.length;this.decomposeRight(t,i),Bm(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 Bm(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 pk=5,li=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 ol(s,o,n)):(s||i||o>=pk)&&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 li(n,e);return oe.spans(t,n,o,i,0),i.finish(n)}};function mk(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 gk(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 yk(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var oi=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}},il=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=Hm,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(si).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?Hm: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:ni(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(si).filter(u=>typeof u!="function");let o=e.changedRanges,i=Xe.extendWithRanges(o,mk(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(fg)&&(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=Qm(e.scrollDOM);let d=(this.printing?yk:gk)(t,this.paddingTop),p=d.top-this.pixelViewport.top,m=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let y=l.width;if((this.contentDOMWidth!=y||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(y-this.contentDOMWidth)>o.charWidth){let{lineHeight:x,charWidth:S,textHeight:b}=e.docView.measureTextSize();s=x>0&&o.refresh(i,x,S,b,y/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 oi(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 g of p)if(g>c&&g<u){a(c,g-10,h,f),a(g+10,u,h,f);return}let m=xk(e,g=>g.from>=h.from&&g.to<=h.to&&Math.abs(g.from-c)<i&&Math.abs(g.to-u)<i&&!p.some(y=>g.from<y&&g.to>y));if(!m){if(u<h.to&&t&&n&&t.visibleRanges.some(g=>g.from<=u&&g.to>=u)){let g=t.moveToLineBoundary(I.cursor(u),!1,!0).head;g>c&&(u=g)}m=new oi(c,u,this.gapSize(h,c,u,f))}l.push(m)};for(let c of this.viewportLines){if(c.length<s)continue;let u=bk(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,g;if(h!=null){let y=zs(u,h),v=((this.visibleBottom-this.visibleTop)/2+p)/c.height;m=y-v,g=y+v}else m=(this.visibleTop-c.top-p)/c.height,g=(this.visibleBottom-c.top+p)/c.height;f=_s(u,m),d=_s(u,g)}else{let p=u.total*this.heightOracle.charWidth,m=o*this.heightOracle.charWidth,g,y;if(h!=null){let v=zs(u,h),w=((this.pixelViewport.right-this.pixelViewport.left)/2+m)/p;g=v-w,y=v+w}else g=(this.pixelViewport.left-m)/p,y=(this.pixelViewport.right+m)/p;f=_s(u,g),d=_s(u,y)}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=zs(o,n)-zs(o,t);return this.heightOracle.lineWrapping?e.height*i:o.total*this.heightOracle.charWidth*i}updateLineGaps(e){oi.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)||ni(this.heightMap.lineAt(e,ae.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return ni(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 ni(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 bk(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 _s({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 zs(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 xk(r,e){for(let t of r)if(e(t))return t}var Hm={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 ni(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=>ni(o,e)):r._content)}var Ws=$.define({combine:r=>r.join(" ")}),tu=$.define({combine:r=>r.indexOf(!0)>-1}),nu=pt.newName(),Dg=pt.newName(),Lg=pt.newName(),Ag={"&light":"."+Dg,"&dark":"."+Lg};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 vk=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"}},Ag),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?[]:Sk(e),a=new Zs(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Ck(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=I.single(c,a)}}};function Og(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=wk(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(ll)||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=I.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=I.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(cg).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=xg(r)||r.state.doc.lineAt(o.head),p=o.to-t.to,m=o.to-o.from;a=s.changeByRange(g=>{if(g.from==o.from&&g.to==o.to)return{changes:u,range:h||g.map(u)};let y=g.to-p,v=y-f.length;if(g.to-g.from!=m||r.state.sliceDoc(v,y)!=f||d&&g.to>=d.from&&g.from<=d.to)return{range:g};let w=s.changes({from:v,to:y,insert:t.insert}),x=g.to-o.to;return{changes:w,range:h?I.range(Math.max(0,h.anchor+x),Math.max(0,h.head+x)):g.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 wk(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 Sk(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 el(t,n)),(o!=t||i!=n)&&e.push(new el(o,i))),e}function Ck(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?I.single(t+e,n+e):null}var Tk={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(ll)?n.root.activeElement!=this.dom:!Us(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&&Qs(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&&TT(this.dom.ownerDocument)==this.dom&&kk(this.view)||Js(e.root);if(!t||this.selectionRange.eq(t))return!1;let n=Us(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&IT(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,Tk),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&&Us(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=Og(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=_m(t,e.previousSibling||e.target.previousSibling,-1),o=_m(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 _m(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 kk(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 Qs(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||RT(e.parent)||document,this.viewState=new il(e.state||Z.create(e)),this.plugins=this.state.facet(ei).map(t=>new ri(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 nl(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(Rg))?(this.inputState.notifiedFocused=s,l=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=Ig(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:I.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(Cm)&&(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(ti)!=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(Ws)!=o.state.facet(Ws)&&(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&&!Og(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 il(e),this.plugins=e.facet(ei).map(n=>new ri(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new nl(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(ei),n=e.state.facet(ei);if(t!=n){let o=[];for(let i of n){let s=t.indexOf(i);if(s<0)o.push(new ri(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(Qm(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),zm}}),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]!=zm)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)?Lg:Dg)+" "+this.state.facet(Ws)}updateAttrs(){let e=Wm(this,dg,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ll)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Wm(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(ti),pt.mount(this.root,this.styleModules.concat(vk).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,Rm(this,e,t,n))}moveByGroup(e,t){return Rc(this,e,Rm(this,e,t,n=>ek(this,e.head,n)))}moveToLineBoundary(e,t,n=!0){return ZT(this,e,t,n)}moveVertically(e,t,n){return Rc(this,e,tk(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(),wg(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(hg)||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>Mk)return yg(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=zT(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(()=>{jm(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 Cm.of(new Qr(typeof e=="number"?I.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=[Ws.of(n),ti.of(ru(`.${n}`,e))];return t&&t.dark&&o.push(tu.of(!0)),o}static baseTheme(e){return ir.lowest(ti.of(ru("."+nu,e,Ag)))}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=ti;j.inputHandler=cg;j.focusChangeEffect=ug;j.perLineTextDirection=hg;j.exceptionSink=ag;j.updateListener=Hc;j.editable=ll;j.mouseSelectionStyle=lg;j.dragMovesSelection=sg;j.clickAddsSelectionRange=ig;j.decorations=si;j.atomicRanges=mu;j.scrollMargins=pg;j.darkTheme=tu;j.contentAttributes=pu;j.editorAttributes=dg;j.lineWrapping=j.contentAttributes.of({class:"cm-lineWrapping"});j.announce=ie.define();var Mk=4096,zm={},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 Wm(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 Ek=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Rk(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 $s(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 Ik=ir.default(j.domEventHandlers({keydown(r,e){return Ak(Pk(e.state),r,e,"editor")}})),Zr=$.define({enables:Ik}),$m=new WeakMap;function Pk(r){let e=r.facet(Zr),t=$m.get(e);return t||$m.set(e,t=Lk(e.reduce((n,o)=>n.concat(o),[]))),t}var Cn=null,Dk=4e3;function Lk(r,e=Ek){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(y=>Rk(y,e));for(let y=1;y<p.length;y++){let v=p.slice(0,y).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)},Dk),!0}]})}let m=p.join(" ");o(m,!1);let g=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&&g.run.push(a),c&&(g.preventDefault=!0),u&&(g.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 Ak(r,e,t,n){let o=pm(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+" ",Cg.indexOf(e.keyCode)<0&&(c=!0,Cn=null));let h=new Set,f=g=>{if(g){for(let y of g.run)if(!h.has(y)&&(h.add(y),y(t,e)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},d=r[n],p,m;return d&&(f(d[l+$s(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+$s(p,e,!0)])||e.shiftKey&&(m=Gr[e.keyCode])!=o&&m!=p&&f(d[l+$s(m,e,!1)]))&&(a=!0):s&&e.shiftKey&&f(d[l+$s(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=Ng(e);return[new fr(t,o.left-i.left,o.top-i.top,null,o.bottom-o.top)]}else return Ok(e,t,n)}};function Ng(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 Um(r,e,t){let n=I.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 Ok(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=Ng(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,g=p.type==me.Text?p:null;if(m&&(r.lineWrapping||d.widgetLineBreaks)&&(m=Um(r,n,m)),g&&(r.lineWrapping||p.widgetLineBreaks)&&(g=Um(r,o,g)),m&&g&&m.from==g.from)return v(w(t.from,t.to,m));{let S=m?w(t.from,null,m):x(d,!1),b=g?w(null,t.to,g):x(p,!0),C=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&S.bottom+r.defaultLineHeight/2<b.top?C.push(y(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 y(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(y(C[E],S,C[E+1],b));return k}function w(S,b,C){let k=1e9,E=-1e9,R=[];function N(D,F,G,A,V){let B=r.coordsAtPos(D,D==C.to?-2:2),U=r.coordsAtPos(G,G==C.from?2:-2);!B||!U||(k=Math.min(B.top,U.top,k),E=Math.max(B.bottom,U.bottom,E),V==pe.LTR?R.push(i&&F?h:B.left,i&&A?f:U.right):R.push(!i&&A?h:U.left,!i&&F?f:B.right))}let O=S!=null?S:C.from,M=b!=null?b:C.to;for(let D of r.visibleRanges)if(D.to>O&&D.from<M)for(let F=Math.max(D.from,O),G=Math.min(D.to,M);;){let A=r.state.doc.lineAt(F);for(let V of r.bidiSpans(A)){let B=V.from+A.from,U=V.to+A.from;if(B>=G)break;U>F&&N(Math.max(B,F),S==null&&B<=O,Math.min(U,G),b==null&&U>=M,V.dir)}if(F=A.to+1,F>=G)break}return R.length==0&&N(O,S==null,M,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 Nk(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(Ks)!=e.state.facet(Ks)&&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(Ks);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)=>!Nk(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()}},Ks=$.define();function Vg(r){return[yt.define(e=>new su(e,r)),Ks.of(r)]}var Fg=!H.ios,ai=$.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[ai.of(r),Vk,Fk,Bk,fg.of(!0)]}function Bg(r){return r.startState.facet(ai)!=r.state.facet(ai)}var Vk=Vg({above:!0,markers(r){let{state:e}=r,t=e.facet(ai),n=[];for(let o of e.selection.ranges){let i=o==e.selection.main;if(o.empty?!i||Fg:t.drawRangeCursor){let s=i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=o.empty?o:I.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=Bg(r);return t&&Gm(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){Gm(e.state,r)},class:"cm-cursorLayer"});function Gm(r,e){e.style.animationDuration=r.facet(ai).cursorBlinkRate+"ms"}var Fk=Vg({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||Bg(r)},class:"cm-selectionLayer"}),Hg={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Fg&&(Hg[".cm-line"].caretColor="transparent !important");var Bk=ir.highest(j.theme(Hg));function qm(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 Hk(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 Hk(e,this.maxLength))qm(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,g,y)=>f.push(y.range(m,g));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 qm(e.state.doc,this.regexp,u,h,(m,g)=>this.addMatch(g,e,m,p));t=t.update({filterFrom:u,filterTo:h,filter:(m,g)=>m<u||g>h,add:f})}}return t}},au=/x/.unicode!=null?"gu":"g",_k=new RegExp(`[\0-\b
|
|
26
|
+
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,au),zk={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 Wk(){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=$.define({combine(r){let e=sr(r,{render:null,specialChars:_k,addSpecialChars:null});return(e.replaceTabs=!Wk())&&(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),$k()]}var Km=null;function $k(){return Km||(Km=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 Uk="\u2022";function Gk(r){return r>=32?Uk: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=Gk(this.code),n=e.state.phrase("Control character")+" "+(zk[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 aW=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 Dt{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 qk=0,bt=class{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=qk++}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))}},Kk=0,eo=class{constructor(){this.instances=[],this.id=Kk++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&jk(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=Jk(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 jk(r,e){return r.length==e.length&&r.every((t,n)=>t==e[n])}function Jk(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 ui(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 Wg.add(e)}var Wg=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 Qk(r,e){let t=null;for(let n of r){let o=n.style(e);o&&(t=t?t+" "+o:o)}return t}function $g(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=Yk(e)||to.empty,h=Qk(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(g=>!g.scope||g.scope(f.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let v=g<f.overlay.length?f.overlay[g]:null,w=v?v.from+l:a,x=Math.max(t,y),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;y=v.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,v.from+l),Math.min(n,y),"",p),this.startSpan(Math.min(n,y),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 Yk(r){let e=r.type.prop(Wg);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}var L=bt.define,al=L(),En=L(),_g=L(En),zg=L(En),Rn=L(),cl=L(Rn),bu=L(Rn),jt=L(),dr=L(jt),qt=L(),Kt=L(),vu=L(),ci=L(vu),ul=L(),P={comment:al,lineComment:L(al),blockComment:L(al),docComment:L(al),name:En,variableName:L(En),typeName:_g,tagName:L(_g),propertyName:zg,attributeName:L(zg),className:L(En),labelName:L(En),namespace:L(En),macroName:L(En),literal:Rn,string:cl,docString:L(cl),character:L(cl),attributeValue:L(cl),number:bu,integer:L(bu),float:L(bu),bool:L(Rn),regexp:L(Rn),escape:L(Rn),color:L(Rn),url:L(Rn),keyword:qt,self:L(qt),null:L(qt),atom:L(qt),unit:L(qt),modifier:L(qt),operatorKeyword:L(qt),controlKeyword:L(qt),definitionKeyword:L(qt),moduleKeyword:L(qt),operator:Kt,derefOperator:L(Kt),arithmeticOperator:L(Kt),logicOperator:L(Kt),bitwiseOperator:L(Kt),compareOperator:L(Kt),updateOperator:L(Kt),definitionOperator:L(Kt),typeOperator:L(Kt),controlOperator:L(Kt),punctuation:vu,separator:L(vu),bracket:ci,angleBracket:L(ci),squareBracket:L(ci),paren:L(ci),brace:L(ci),content:jt,heading:dr,heading1:L(dr),heading2:L(dr),heading3:L(dr),heading4:L(dr),heading5:L(dr),heading6:L(dr),contentSeparator:L(jt),list:L(jt),quote:L(jt),emphasis:L(jt),strong:L(jt),link:L(jt),monospace:L(jt),strikethrough:L(jt),inserted:L(),deleted:L(),changed:L(),invalid:L(),meta:ul,documentMeta:L(ul),annotation:L(ul),processingInstruction:L(ul),definition:bt.defineModifier(),constant:bt.defineModifier(),function:bt.defineModifier(),standard:bt.defineModifier(),local:bt.defineModifier(),special:bt.defineModifier()},fW=wu([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var Su,no=new J;function Xk(r){return $.define({combine:r?e=>e.concat(r):void 0})}var Zk=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=Ug(i,s,l),c=a.type.prop(no);if(!c)return[];let u=i.facet(c),h=a.type.prop(Zk);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 Ug(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 Ug(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=Xk(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)}},hi=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=hi;hi=this;try{return e()}finally{hi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Gg(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=Gg(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=hi;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 hi}};function Gg(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 jg=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(jg=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,e1=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=jg(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=$.define({combine(r){return r.length?r[0]:null},enables:r=>[rt.state,e1,j.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]});var t1=$.define(),di=$.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 pi(r){let e=r.facet(di);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function mi(r,e){let t="",n=r.tabSize,o=r.facet(di)[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(t1)){let o=n(r,e);if(o!==void 0)return o}let t=Fe(r.state);return t?r1(r,t,e):null}var pr=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=pi(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}},n1=new J;function r1(r,e,t){return Jg(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,r)}function o1(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function i1(r){let e=r.type.prop(n1);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=>c1(s,!0,1,void 0,i&&!o1(s)?o.from:void 0)}return r.parent==null?s1:null}function Jg(r,e,t){for(;r;r=r.parent){let n=i1(r);if(n)return n(fi.create(t,e,r))}return null}function s1(){return 0}var fi=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 fi(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(l1(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?Jg(e,this.pos,this.base):0}};function l1(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function a1(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 c1(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?a1(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=$.define(),Qg=$.define({combine(r){return r.length?[r[0]]:null}});function Tu(r){let e=r.facet(Eu);return e.length?e:r.facet(Qg)}function gi(r,e){let t=[u1],n;return r instanceof cn&&(r.module&&t.push(j.styleModule.of(r.module)),n=r.themeType),e!=null&&e.fallback?t.push(Qg.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)$g(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()}},u1=ir.high(yt.fromClass(Ru,{decorations:r=>r.decorations})),Lu=cn.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]);var h1=1e4,f1="()[]{}";var d1=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(d1);return e?e(r.node):r}function mr(r,e,t,n={}){let o=n.maxScanDistance||h1,i=n.brackets||f1,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 p1(r,e,t,a,u,c,i)}}return m1(r,e,t,s,l.type,o,i)}function p1(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 m1(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,g=t>0?d.length:-1;m!=g;m+=t){let y=s.indexOf(d[m]);if(!(y<0||n.resolveInner(p+m,1).type!=o))if(y%2==0==t>0)h++;else{if(h==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};h--}}t>0&&(f+=d.length)}return u.done?{start:c,matched:!1}:null}var g1=Object.create(null),qg=[ke.none];var Kg=[],y1=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"]])y1[r]=b1(g1,e);function ku(r,e){Kg.indexOf(r)>-1||(Kg.push(r),console.warn(e))}function b1(r,e){let t=null;for(let i of e.split(".")){let s=r[i]||P[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:qg.length,name:n,props:[ui({[n]:t})]});return qg.push(o),o.id}var hl={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 Dt{};Ou.startSide=1;Ou.endSide=-1;var Zg=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 Nu(){return[S1,Zg]}var Au="()[]{}<>";function x1(r){for(let e=0;e<Au.length;e+=2)if(Au.charCodeAt(e)==r)return Au.charAt(e+1);return Xp(r<128?r:r+1)}function v1(r,e){return r.languageDataAt("closeBrackets",e)[0]||hl}var w1=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),S1=j.inputHandler.of((r,e,t,n)=>{if((w1?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=C1(r.state,n);return i?(r.dispatch(i),!0):!1});function C1(r,e){let t=v1(r,r.selection.main.head),n=t.brackets||hl.brackets;for(let o of n){let i=x1(zt(o,0));if(e==o)return i==o?M1(r,o,n.indexOf(o+o+o)>-1,t):T1(r,o,i,t.before||hl.before);if(e==i&&ey(r,r.selection.main.from))return k1(r,o,i)}return null}function ey(r,e){let t=!1;return r.field(Zg).between(0,r.doc.length,n=>{n==e&&(t=!0)}),t}function Vu(r,e){let t=r.sliceString(e,e+2);return t.slice(0,tr(zt(t,0)))}function T1(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:I.range(s.anchor+e.length,s.head+e.length)};let l=Vu(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:I.cursor(s.head+e.length)}:{range:o=s}});return o?null:r.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function k1(r,e,t){let n=null,o=r.changeByRange(i=>i.empty&&Vu(r.doc,i.head)==t?{changes:{from:i.head,to:i.head+t.length,insert:t},range:I.cursor(i.head+t.length)}:n={range:i});return n?null:r.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function M1(r,e,t,n){let o=n.stringPrefixes||hl.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:I.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=Vu(r.doc,a),u;if(c==e){if(Yg(r,a))return{changes:{insert:e+e,from:a},effects:gr.of(a+e.length),range:I.cursor(a+e.length)};if(ey(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:I.cursor(a+f.length)}}}else{if(t&&r.sliceDoc(a-2*e.length,a)==e+e&&(u=Xg(r,a-2*e.length,o))>-1&&Yg(r,u))return{changes:{insert:e+e+e+e,from:a},effects:gr.of(a+e.length),range:I.cursor(a+e.length)};if(r.charCategorizer(a)(c)!=Ge.Word&&Xg(r,a,o)>-1&&!E1(r,a,e,o))return{changes:{insert:e+e,from:a},effects:gr.of(a+e.length),range:I.cursor(a+e.length)}}return{range:i=l}});return i?null:r.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Yg(r,e){let t=Fe(r).resolveInner(e+1);return t.parent&&t.from==e}function E1(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 Xg(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 R1=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),n=$u(r.state,t.from);return n.line?I1(r):n.block?D1(r):!1};function Wu(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 I1=Wu(O1,0);var P1=Wu(ay,0);var D1=Wu((r,e)=>ay(r,e,A1(e)),0);function $u(r,e){let t=r.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var yi=50;function L1(r,{open:e,close:t},n,o){let i=r.sliceDoc(n-yi,n),s=r.sliceDoc(o,o+yi),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*yi?u=h=r.sliceDoc(n,o):(u=r.sliceDoc(n,n+yi),h=r.sliceDoc(o-yi,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 A1(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 ay(r,e,t=e.selection.ranges){let n=t.map(i=>$u(e,i.from).block);if(!n.every(i=>i))return null;let o=t.map((i,s)=>L1(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 O1(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=$u(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 Bu=tt.define(),N1=tt.define(),V1=$.define(),cy=$.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 F1(r){let e=0;return r.iterChangedRanges((t,n)=>e=n),e}var uy=qe.define({create(){return vt.empty},update(r,e){let t=e.state.facet(cy),n=e.annotation(Bu);if(n){let a=e.docChanged?I.single(F1(e.changes)):void 0,c=Be.fromTransaction(e,a),u=n.side,h=u==0?r.undone:r.done;return c?h=dl(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(N1);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 Uu(r={}){return[uy,cy.of(r),j.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?hy:e.inputType=="historyRedo"?Hu:null;return n?(e.preventDefault(),n(t)):!1}})]}function pl(r,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let o=t.field(uy,!1);if(!o)return!1;let i=o.pop(r,t,e);return i?(n(i),!0):!1}}var hy=pl(0,!1),Hu=pl(1,!1),B1=pl(0,!0),H1=pl(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&&I.fromJSON(e.startSelection),e.selectionsAfter.map(I.fromJSON))}static fromTransaction(e,t){let n=xt;for(let o of e.startState.facet(V1)){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 dl(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 _1(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 z1(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=[],W1=200;function dy(r,e){if(r.length){let t=r[r.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-W1));return n.length&&n[n.length-1].eq(e)?r:(n.push(e),dl(r,r.length-1,1e9,t.setSelAfter(n)))}else return[Be.selection([e])]}function $1(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 Fu(r,e){if(!r.length)return r;let t=r.length,n=xt;for(;t;){let o=U1(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 U1(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 G1=/^(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||G1.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<o.newGroupDelay&&o.joinToEvent(i,_1(l.changes,e.changes))||n=="input.type.compose")?s=dl(s,s.length-1,o.minDepth,new Be(e.changes.compose(l.changes),fy(e.effects,l.effects),l.mapped,l.startSelection,xt)):s=dl(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)&&z1(i[i.length-1],e)?this:new vt(dy(this.done,e),this.undone,t,n)}addMapping(e){return new vt(Fu(this.done,e),Fu(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:Bu.of({side:e,rest:$1(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=Fu(s,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Bu.of({side:e,rest:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};vt.empty=new vt(xt,xt);var Gu=[{key:"Mod-z",run:hy,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Hu,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Hu,preventDefault:!0},{key:"Mod-u",run:B1,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:H1,preventDefault:!0}];function io(r,e){return I.create(r.ranges.map(e),r.mainIndex)}function Jt(r,e){return r.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function At({state:r,dispatch:e},t){let n=io(r.selection,t);return n.eq(r.selection)?!1:(e(Jt(r,n)),!0)}function ml(r,e){return I.cursor(e?r.to:r.from)}function py(r,e){return At(r,t=>t.empty?r.moveByChar(t,e):ml(t,e))}function He(r){return r.textDirectionAt(r.state.selection.main.head)==pe.LTR}var my=r=>py(r,!He(r)),gy=r=>py(r,He(r));function yy(r,e){return At(r,t=>t.empty?r.moveByGroup(t,e):ml(t,e))}var q1=r=>yy(r,!He(r)),K1=r=>yy(r,He(r));function j1(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 gl(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;j1(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,I.cursor(l,t?-1:1)}var J1=r=>At(r,e=>gl(r.state,e,!He(r))),Q1=r=>At(r,e=>gl(r.state,e,He(r)));function by(r,e){return At(r,t=>{if(!t.empty)return ml(t,e);let n=r.moveVertically(t,e);return n.head!=t.head?n:r.moveToLineBoundary(t,e)})}var xy=r=>by(r,!1),vy=r=>by(r,!0);function wy(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 Sy(r,e){let t=wy(r),{state:n}=r,o=io(n.selection,s=>s.empty?r.moveVertically(s,e,t.height):ml(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 ty=r=>Sy(r,!1),_u=r=>Sy(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=I.cursor(n.from+i))}return o}var Y1=r=>At(r,e=>Dn(r,e,!0)),X1=r=>At(r,e=>Dn(r,e,!1)),Z1=r=>At(r,e=>Dn(r,e,!He(r))),eM=r=>At(r,e=>Dn(r,e,He(r))),tM=r=>At(r,e=>I.cursor(r.lineBlockAt(e.head).from,1)),nM=r=>At(r,e=>I.cursor(r.lineBlockAt(e.head).to,-1));function rM(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?I.range(i.anchor,l):I.cursor(l)});return n?(e(Jt(r,o)),!0):!1}var oM=({state:r,dispatch:e})=>rM(r,e,!1);function wt(r,e){let t=io(r.state.selection,n=>{let o=e(n);return I.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 Cy(r,e){return wt(r,t=>r.moveByChar(t,e))}var Ty=r=>Cy(r,!He(r)),ky=r=>Cy(r,He(r));function My(r,e){return wt(r,t=>r.moveByGroup(t,e))}var iM=r=>My(r,!He(r)),sM=r=>My(r,He(r));var lM=r=>wt(r,e=>gl(r.state,e,!He(r))),aM=r=>wt(r,e=>gl(r.state,e,He(r)));function Ey(r,e){return wt(r,t=>r.moveVertically(t,e))}var Ry=r=>Ey(r,!1),Iy=r=>Ey(r,!0);function Py(r,e){return wt(r,t=>r.moveVertically(t,e,wy(r).height))}var ny=r=>Py(r,!1),ry=r=>Py(r,!0),cM=r=>wt(r,e=>Dn(r,e,!0)),uM=r=>wt(r,e=>Dn(r,e,!1)),hM=r=>wt(r,e=>Dn(r,e,!He(r))),fM=r=>wt(r,e=>Dn(r,e,He(r))),dM=r=>wt(r,e=>I.cursor(r.lineBlockAt(e.head).from)),pM=r=>wt(r,e=>I.cursor(r.lineBlockAt(e.head).to)),oy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:0})),!0),iy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.doc.length})),!0),sy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.selection.main.anchor,head:0})),!0),ly=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),mM=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),gM=({state:r,dispatch:e})=>{let t=bl(r).map(({from:n,to:o})=>I.range(n,Math.min(o+1,r.doc.length)));return e(r.update({selection:I.create(t),userEvent:"select"})),!0},yM=({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 I.range(i.to,i.from)});return e(Jt(r,t)),!0},bM=({state:r,dispatch:e})=>{let t=r.selection,n=null;return t.ranges.length>1?n=I.create([t.main]):t.main.empty||(n=I.create([I.cursor(t.main.head)])),n?(e(Jt(r,n)),!0):!1};function yl(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=fl(r,a,!1)):a>s&&(t="delete.forward",a=fl(r,a,!0)),s=Math.min(s,a),l=Math.max(l,a)}else s=fl(r,s,!1),l=fl(r,l,!0);return s==l?{range:i}:{changes:{from:s,to:l},range:I.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 fl(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 Dy=(r,e)=>yl(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%pi(n)||pi(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}),zu=r=>Dy(r,!1),Ly=r=>Dy(r,!0),Ay=(r,e)=>yl(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}),Oy=r=>Ay(r,!1),xM=r=>Ay(r,!0),Ny=r=>yl(r,e=>{let t=r.lineBlockAt(e).to;return e<t?t:Math.min(r.state.doc.length,e+1)}),vM=r=>yl(r,e=>{let t=r.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)});var wM=({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:I.cursor(n.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},SM=({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:I.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function bl(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 Vy(r,e,t){if(r.readOnly)return!1;let n=[],o=[];for(let i of bl(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(I.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(I.range(a.anchor-l,a.head-l))}}return n.length?(e(r.update({changes:n,scrollIntoView:!0,selection:I.create(o,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}var CM=({state:r,dispatch:e})=>Vy(r,e,!1),TM=({state:r,dispatch:e})=>Vy(r,e,!0);function Fy(r,e,t){if(r.readOnly)return!1;let n=[];for(let o of bl(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 kM=({state:r,dispatch:e})=>Fy(r,e,!1),MM=({state:r,dispatch:e})=>Fy(r,e,!0),EM=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(bl(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 RM(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 IM=By(!1),PM=By(!0);function By(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&&RM(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=["",mi(e,u)];return a&&h.push(mi(e,c.lineIndent(l.from,-1))),{changes:{from:i,to:s,insert:Y.of(h)},range:I.cursor(i+1+h[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function qu(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:I.range(i.mapPos(n.anchor,1),i.mapPos(n.head,1))}})}var DM=({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=qu(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=mi(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},LM=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(qu(r,(t,n)=>{n.push({from:t.from,insert:r.facet(di)})}),{userEvent:"input.indent"})),!0),AM=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(qu(r,(t,n)=>{let o=/^\s*/.exec(t.text)[0];if(!o)return;let i=lr(o,r.tabSize),s=0,l=mi(r,Math.max(0,i-pi(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 OM=[{key:"Ctrl-b",run:my,shift:Ty,preventDefault:!0},{key:"Ctrl-f",run:gy,shift:ky},{key:"Ctrl-p",run:xy,shift:Ry},{key:"Ctrl-n",run:vy,shift:Iy},{key:"Ctrl-a",run:tM,shift:dM},{key:"Ctrl-e",run:nM,shift:pM},{key:"Ctrl-d",run:Ly},{key:"Ctrl-h",run:zu},{key:"Ctrl-k",run:Ny},{key:"Ctrl-Alt-h",run:Oy},{key:"Ctrl-o",run:wM},{key:"Ctrl-t",run:SM},{key:"Ctrl-v",run:_u}],NM=[{key:"ArrowLeft",run:my,shift:Ty,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:q1,shift:iM,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Z1,shift:hM,preventDefault:!0},{key:"ArrowRight",run:gy,shift:ky,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:K1,shift:sM,preventDefault:!0},{mac:"Cmd-ArrowRight",run:eM,shift:fM,preventDefault:!0},{key:"ArrowUp",run:xy,shift:Ry,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oy,shift:sy},{mac:"Ctrl-ArrowUp",run:ty,shift:ny},{key:"ArrowDown",run:vy,shift:Iy,preventDefault:!0},{mac:"Cmd-ArrowDown",run:iy,shift:ly},{mac:"Ctrl-ArrowDown",run:_u,shift:ry},{key:"PageUp",run:ty,shift:ny},{key:"PageDown",run:_u,shift:ry},{key:"Home",run:X1,shift:uM,preventDefault:!0},{key:"Mod-Home",run:oy,shift:sy},{key:"End",run:Y1,shift:cM,preventDefault:!0},{key:"Mod-End",run:iy,shift:ly},{key:"Enter",run:IM},{key:"Mod-a",run:mM},{key:"Backspace",run:zu,shift:zu},{key:"Delete",run:Ly},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Oy},{key:"Mod-Delete",mac:"Alt-Delete",run:xM},{mac:"Mod-Backspace",run:vM},{mac:"Mod-Delete",run:Ny}].concat(OM.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),xl=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:J1,shift:lM},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Q1,shift:aM},{key:"Alt-ArrowUp",run:CM},{key:"Shift-Alt-ArrowUp",run:kM},{key:"Alt-ArrowDown",run:TM},{key:"Shift-Alt-ArrowDown",run:MM},{key:"Escape",run:bM},{key:"Mod-Enter",run:PM},{key:"Alt-l",mac:"Ctrl-l",run:gM},{key:"Mod-i",run:yM,preventDefault:!0},{key:"Mod-[",run:AM},{key:"Mod-]",run:LM},{key:"Mod-Alt-\\",run:DM},{key:"Shift-Mod-k",run:EM},{key:"Shift-Mod-\\",run:oM},{key:"Mod-/",run:R1},{key:"Alt-A",run:P1}].concat(NM);var VM=[...xl,...Gu],FM=(()=>[yu(),Uu(),gu(),Nu(),gi(Lu,{fallback:!0}),Zr.of(VM)])();import{isNumericColumn as $W}from"@vuu-ui/vuu-utils";var Hy=[{label:"=",boost:10,type:"operator"},{label:"!=",boost:9,type:"operator"}],BM=[...Hy,{label:"in",boost:6,type:"operator"},{label:"starts",boost:5,type:"operator"},{label:"ends",boost:4,type:"operator"}],HM=[...Hy,{label:">",boost:8,type:"operator"},{label:"<",boost:7,type:"operator"}];import P5 from"classnames";import{useEffect as A5,useMemo as O5,useRef as N5}from"react";var s5=In.define({name:"VuuFilterQuery",parser:Uo.configure({props:[ui({Identifier:P.variableName,String:P.string,Or:P.emphasis,Operator:P.operator})]})});var UM=cn.define([{tag:P.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:P.comment,color:"green",fontStyle:"italic"}]),GM=gi(UM);var qM=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 w5}from"react";import{jsx as Z5,jsxs as e$}from"react/jsx-runtime";import{useCallback as g$,useRef as y$}from"react";import{createEl as r$}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 KM}from"@vuu-ui/vuu-utils";var _y="layouts/metadata",zy="layouts/layouts",Sl=class{createLayout(e,t){return new Promise(n=>{console.log(`Saving layout as ${e.name} to group ${e.group}...`),Promise.all([this.loadLayouts(),this.loadMetadata()]).then(([o,i])=>{let s=KM();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(_y);e(t||[])})}loadApplicationLayout(){return new Promise(e=>{let t=vl("api/vui");e(t||Bo)})}saveApplicationLayout(e){return new Promise((t,n)=>{wl("api/vui",e)?t():n(new Error("Layout failed to save"))})}loadLayouts(){return new Promise(e=>{let t=vl(zy);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(zy,e),wl(_y,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}`))}})})}};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 Wy(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=Wy(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=Wy(r))&&(n&&(n+=" "),n+=e);return n}var jM=/[.*+?^${}()|[\]\\]/g;function Cl(r){return r.replace(jM,"\\$&")}import{jsx as n8}from"react/jsx-runtime";import{createContext as JM,useContext as QM}from"react";var YM=JM(typeof window<"u"?window:null);function un(){return QM(YM)}import*as Tl from"react";import{jsx as c8}from"react/jsx-runtime";import{createContext as XM,useMemo as h8,useContext as ZM}from"react";var eE=XM(null);function $y(){return ZM(eE)}var Uy,tE=(Uy=Tl.useInsertionEffect)!=null?Uy:Tl.useLayoutEffect,Ku=new WeakMap;function hn({testId:r,css:e,window:t}){let n=$y();tE(()=>{var o,i;if(!t)return;let s=(o=Ku.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),Ku.set(t,s),()=>{let a=Ku.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 nE,cloneElement as v8,useContext as rE}from"react";var oE=nE(void 0);function Gy(){let r=rE(oE);if(r)return r}function iE(r,...e){let t=new Set(r);for(let n of e)for(let o of n)t.add(o);return t}var bi="ArrowUp",xi="ArrowDown",qy="ArrowLeft",Ky="ArrowRight",ju="Enter",kl="Home",vi="End",Ju="PageUp",Ml="PageDown",jy=" ",sE=new Set(["Enter","Delete"," "]),lE=new Set(["Tab"]),aE=new Set(["ArrowRight","ArrowLeft"]),Jy=new Set([kl,vi,Ju,Ml,xi,bi]),cE=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),uE=iE(sE,Jy,aE,cE,lE),El=r=>uE.has(r.key)?!1:r.key.length===1&&!r.ctrlKey&&!r.metaKey&&!r.altKey,Qy=({key:r})=>Jy.has(r);import{useState as SE,useRef as Il,useMemo as Pl,useCallback as St,isValidElement as lb}from"react";import{isValidElement as Qu,Children as fE}from"react";var Yy=r=>null;var Xy=r=>null;var hE=r=>Object.prototype.toString.call(r)==="[object Object]";function so(r){return typeof r=="string"?r:hE(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 Yu=(r,e)=>r!==null&&Object.prototype.hasOwnProperty.call(r,e),Xu=r=>Yu(r,"header"),Zy=r=>Yu(r,"childNodes"),wi=(r,e)=>r&&Object.prototype.hasOwnProperty.call(r.props,e),eb=r=>{if(Qu(r)){if(wi(r,"disabled"))return r.props.disabled===!0}else if(Yu(r,"disabled"))return r.disabled===!0;return!1},tb=r=>Qu(r)&&wi(r,"focusable")?r.props.focusable:!0,nb=(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},dE=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},rb=r=>r.type===Xy||wi(r,"data-header"),ob=r=>r.type===Yy||wi(r,"data-group"),pE=r=>wi(r,"selectable")?r.props.selectable===!0:!ob(r)&&!rb(r),mE=r=>{if(ob(r)){let{props:{children:e}}=r;if(typeof e!="string")return eh(e)}},gE=(r,e)=>{let t=[];return fE.forEach(r,n=>{Qu(n)&&t.push(e(n))}),t},Zu=(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:Zu(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:so(t)}});if(r)throw Error("list-child-items expects source to be an array")},eh=r=>{if(r)return gE(r,e=>{let{"data-id":t,disabled:n,id:o=t,"data-expanded":i,expanded:s=i}=e.props;return{childNodes:mE(e),disabled:n,expanded:s,header:rb(e),id:o,label:dE(e),selectable:pE(e),value:e}})},yE=new Set(["/","-","."]),bE=r=>yE.has(r),ib=(r,e)=>e.startsWith(r)&&bE(e[r.length]),xE=new Set([".","/"]);function vE(r,e){return e.startsWith(r)?xE.has(e.charAt(r.length)):!1}function Rl(r,e,t){let n;return r.map(i=>i.id===e?{...i,...t}:vE(i.id,e)&&i.childNodes?(n=Rl(i.childNodes,e,t),{...i,childNodes:n}):i)}import"react";import"@salt-ds/core";var wE=r=>r&&r.replace(/^\s+/g,""),th=r=>new RegExp(`(${Cl(wE(r))})`,"gi"),sb=(r="",e=th)=>(t="")=>!!t.length&&!!r.length&&t.match(e(r))!==null;var CE={},ab=({children:r,id:e,label:t="",options:n=CE,source:o})=>{var i;let{getItemId:s}=n,[,l]=SE(null),a=Gy(),c=Il([]),u=Il([]),h=Pl(()=>[],[]),f=Il((i=n.filterPattern)!=null?i:""),{getFilterRegex:d=th,noChildrenLabel:p,itemToString:m=so}=n,g=St(A=>n.defaultExpanded||!1,[n.defaultExpanded]),y=St((A,V,B=1,U="",X=[],ee=[],_e=[])=>(A.forEach((de,it,On)=>{var Vt,re;let se=de.header&&n.collapsibleHeaders,Me=de.childNodes&&n.collapsibleHeaders===!1,Tt=!de.childNodes||de.childNodes.length===0,ho=Me||Tt&&!se,fo=U?`${U}.${it}`:`item-${it}`,po=(Vt=de.id)!=null?Vt:s?s(it):`${e}-${fo}`,kt=ho?void 0:(re=de.expanded)!=null?re:g(po),mo={...de,childNodes:void 0,count:!Me&&kt===void 0?0:nb(de,On,it),description:de.description,disabled:eb(de.value),focusable:tb(de.value)?void 0:!1,id:po,index:V.value,expanded:kt,level:B};if(X.push(mo),ee.push(mo),_e.push(A[it].value),V.value+=1,de.childNodes){let[Ql]=y(de.childNodes,V,B+1,fo,[],ee,_e);mo.childNodes=Ql}}),[X,_e,ee]),[n.collapsibleHeaders,s,e,g]),v=St(()=>f.current?sb(f.current,d):null,[d]),w=St((A,V=v(),B=[],U={value:0})=>{let X=!1;for(let ee of A)X&&!Xu(ee)||(ee.value!==null&&(V===null||V(m(ee.value)))&&(B[U.value]=ee,U.value+=1),X=!1,Xu(ee)&&ee.expanded===!1?X=!0:Zy(ee)&&ee.expanded!==!1&&ee.childNodes&&w(ee.childNodes,V,B,U));return B},[v,m]),x=Pl(()=>a?h:Zu(o,{itemToString:m,noChildrenLabel:p})||eh(r)||[],[a,h,o,m,p,r]),[S,b,C]=Pl(()=>a?[h,h,h]:y(x,{value:0}),[h,y,a,x]);u.current=C,Pl(()=>a?h:c.current=w(S),[h,w,S,a]);let k=Il(S),E=St((A="")=>{typeof A=="string"&&(f.current=A,c.current=w(S),l({}))},[S,w]),R=St((A,V=S)=>{let B=V.find(U=>{var X;return U.id===A||((X=U==null?void 0:U.childNodes)==null?void 0:X.length)&&ib(U.id,A)});if((B==null?void 0:B.id)===A)return b==null?void 0:b[B.index];if(B)return R(A,B.childNodes);throw Error(`useCollectionData itemById, id ${A} not found `)},[b,S]),N=St(A=>{let V=u.current.find(B=>lb(B.value)?B.label===A:B.value===A);if(V)return V;throw Error("useCollectionData toCollectionItem, item not found ")},[]),O=St(A=>{if(A===null)return null;if(Array.isArray(A)){let V=[];for(let B of A){let U=N(B);V.push(U)}return V}else if(A!==void 0)return N(A)},[N]),M=St(A=>{let V=B=>{let U=u.current.find(X=>lb(X.value)?X.label===B:X.value!==null&&m(X.value)===B);if(U)return U};if(A===null)return null;if(Array.isArray(A)){let B=[];for(let U of A){let X=V(U);X&&B.push(X)}return B}else if(A!==void 0)return V(A)},[m]),D=St(A=>{for(let V of k.current)if(A===V.value)return V.id;throw Error("useCollectionData itemToId, item not found")},[]),F=St(A=>{k.current=Rl(k.current,A.id,{expanded:!1}),c.current=w(k.current),l({})},[w]),G=St(A=>{k.current=Rl(k.current,A.id,{expanded:!0}),c.current=w(k.current),l({})},[w]);return a||{collapseGroupItem:F,data:c.current,expandGroupItem:G,setFilterPattern:E,itemById:R,itemToId:D,toCollectionItem:N,itemToCollectionItem:O,stringToCollectionItem:M}};import{useIsomorphicLayoutEffect as cb}from"@salt-ds/core";import{useRef as TE,useCallback as kE}from"react";var ub=["height"];var br=new WeakMap,hb=(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=hb(t,n,a);u!==c&&(l=!0,s[a]=u)}l&&i&&i(s)}}}):null;function Si(r,e,t,n=!1){let o=TE(e),i=kE(s=>{let l=s.getBoundingClientRect();return o.current.reduce((a,c)=>(a[c]=hb(s,l,c),a),{})},[]);cb(()=>{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]),cb(()=>{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 iR,jsx as xr,Fragment as sR}from"react/jsx-runtime";import{forwardRef as lR,useRef as uh,createElement as aR,isValidElement as cR,cloneElement as uR}from"react";import{makePrefixer as hR,useIdMemo as fR,useForkRef as dR}from"@salt-ds/core";import{useMemo as ME,useImperativeHandle as EE}from"react";var RE={scrollToIndex:r=>{},scrollToItem:r=>{},scrollTo:r=>{}},fb=({collectionHook:r,forwardedRef:e,scrollableRef:t,scrollIntoView:n})=>{let o=ME(()=>({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]);EE(e,()=>t.current?o:RE,[o])};import{useControlled as IE}from"@salt-ds/core";import{useRef as nh,useState as PE,useCallback as lo,useMemo as DE}from"react";var db=r=>Array.isArray(r)?r.length>0:r!=null,pb=r=>Array.isArray(r)?r[0]:r;var oh=-2;function mb(r,e,t){return e===bi||e===vi?t>0?t-1:t:t===null?0:t===r-1?t:t+1}var rh=(r,e)=>{let t=pb(e);return t?r.indexOf(t):-1},LE=(r,e,t,n)=>r===vi?n:r===kl?-1:e!==-1?e:t,yb=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}`)},AE=(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=yb(t[u]);while(h.top<o&&u<a);return u}},OE=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=yb(t[c]);while(u.top>o&&c>0);a(c)})})},NE=r=>!r.header&&!r.childNodes,gb=r=>NE(r)||r.expanded!==void 0,bb=({containerRef:r,defaultHighlightedIndex:e=-1,disableHighlightOnFocus:t,highlightedIndex:n,indexPositions:o,onHighlight:i,onKeyboardNavigation:s,restoreLastFocus:l,selected:a})=>{let c=nh(-1),[,u]=PE({}),[h,f,d]=IE({controlled:n,default:e,name:"UseKeyboardNavigation"}),p=lo((k,E=!1)=>{i==null||i(k),f(k),E&&(c.current=k)},[i,f]),m=lo(async(k,E)=>{let{id:R}=o[E],N;if(R){let O=document.getElementById(R),{current:M}=r;O&&M&&(N=k.key===Ml?AE(M,O,o,E):await OE(M,O,o,E))}return N!=null?N:E},[r,o]),g=lo((k=xi,E=k===xi?-1:o.length)=>{if(o.length===0)return-1;{let R=rh(o,a),N=LE(k,E,R,o.length),O=mb(o.length,k,N);if(O===0&&k===bi&&!gb(o[0]))return E;for(;((k===xi||k===kl)&&O<o.length||(k===bi||k===vi)&&O>0)&&!gb(o[O]);)O=mb(o.length,k,O);return O}},[o,a]),y=nh(!1),v=nh(!1),w=k=>v.current=k,x=lo(k=>{if(v.current)v.current=!1;else if(y.current=!0,o.length===0)p(oh);else if(h!==-1)u({});else if(l)if(c.current!==-1)p(c.current);else{let E=rh(o,a);p(E!==-1?E:0)}else if(db(a)){let E=rh(o,a);p(E)}else t!==!0&&p(g())},[t,h,o,g,l,a,p]),S=lo(async k=>{let E=k.key===Ml||k.key===Ju?await m(k,h):g(k.key,h);E!==h&&p(E,!0),s==null||s(k,E)},[h,g,m,s,p]),b=lo(k=>{o.length>0&&Qy(k)?(k.preventDefault(),k.stopPropagation(),y.current=!0,S(k)):El(k)&&(y.current=!0)},[o,S]),C=DE(()=>({onBlur:k=>{let E=k.target.closest(".saltList"),R=k.relatedTarget;E&&!(E!=null&&E.contains(R))&&(y.current=!1,f(-1),l||(c.current=-1))},onFocus:x,onKeyDown:b,onMouseDownCapture:()=>{y.current=!1,w(!0)},onMouseMove:()=>{y.current&&(y.current=!1)},onMouseLeave:()=>{y.current=!1,w(!1),p(-1)}}),[x,b,l,f,p]);return{focusVisible:y.current?h:-1,controlledHighlighting:d,highlightedIndex:h,setHighlightedIndex:p,keyboardNavigation:y,listProps:C,setIgnoreFocus:w}};function xb(r,e){return Array.isArray(r)?r.includes(e):r===e}import{jsx as Ll,jsxs as HE}from"react/jsx-runtime";import{forwardRef as Cb}from"react";import{makePrefixer as _E,CheckboxIcon as zE}from"@salt-ds/core";import{jsx as ih,Fragment as VE}from"react/jsx-runtime";import{makePrefixer as FE}from"@salt-ds/core";import"react";var vb=`.saltHighlighter-highlight {
|
|
28
|
+
font-weight: var(--salt-text-fontWeight-strong); /* TODO: Check with design */
|
|
29
|
+
}
|
|
30
|
+
`;var BE=FE("saltHighlighter"),wb=r=>{let{matchPattern:e,text:t=""}=r,n=un();hn({testId:"salt-hightligher",css:vb,window:n});let o=typeof e=="string"?new RegExp(`(${Cl(e)})`,"gi"):e;return o===void 0?ih(VE,{children:t}):ih("span",{children:t.split(o).map((i,s)=>i.match(o)?ih("strong",{className:BE("highlight"),children:i},`${s}-${i}`):i)})};var Sb=`.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 Ci=_E("saltListItem"),sh=Cb(function(e,t){return Ll("div",{"aria-hidden":!0,className:yr(Ci(),Ci("proxy")),ref:t})}),Ti=Cb(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:Sb,window:m});let g=yr(Ci(),t,{saltDisabled:n,[Ci("checkbox")]:h}),y=s!==void 0?{...f,height:s}:f;return HE("div",{className:g,...d,"aria-disabled":n||void 0,"aria-selected":u||void 0,ref:p,style:y,children:[h&&Ll(zE,{"aria-hidden":!0,checked:u}),e&&typeof e!="string"?e:l==null?Ll("span",{className:Ci("textWrapper"),children:a||e}):Ll(wb,{matchPattern:l,text:a||e})]})});import{useRef as tR,useCallback as Al,isValidElement as ch}from"react";import"@salt-ds/core";import{useCallback as Tb}from"react";var WE={},$E=r=>Array.isArray(r.childNodes),UE=r=>r.closest("[data-toggle],[aria-expanded]").dataset.toggle==="true",kb=({collapsibleHeaders:r,collectionHook:e,highlightedIdx:t,onToggle:n})=>{let o=Tb(l=>{if(l.key===Ky||l.key===ju){let a=e.data[t];a&&a.expanded===!1&&a.value&&(l.preventDefault(),e.expandGroupItem(a),n==null||n(a.value))}if(l.key===qy||l.key===ju){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:Tb(l=>{console.log(`useCollapsibleGroups idx=${t}`);let a=e.data[t];console.log(l.target,l.currentTarget),a&&$E(a)&&UE(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:WE};function GE(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 qE=r=>r.closest("[data-idx],[aria-posinset]"),Mb=r=>GE(qE(r));import{useControlled as KE}from"@salt-ds/core";import{useRef as jE,useCallback as Ot}from"react";var JE=["Enter"," "],lh=r=>r&&r.disabled!==!0&&r.selectable!==!1,Eb=(r,e)=>{var t,n;return((t=r.index)!=null?t:0)-((n=e.index)!=null?n:0)},Rb=({defaultSelected:r,disableSelection:e=!1,highlightedIdx:t,indexPositions:n,label:o="",onSelect:i,onSelectionChange:s,selected:l,selectionStrategy:a,selectionKeys:c=JE,tabToSelect:u})=>{let h=a==="deselectable",f=a==="multiple",d=a==="extended",p=jE(-1),m=Ot(M=>c.includes(M.key),[c]),g=Ot(()=>f||d?[]:null,[f,d]),[y,v]=KE({controlled:l,default:r!=null?r:g(),name:"UseSelection",state:"selected"}),w=Ot(M=>Array.isArray(y)?y.includes(M):y===M,[y]),x=Ot(M=>M,[]),S=Ot(M=>w(M)?null:M,[w]),b=Ot(M=>{let D=w(M)?y.filter(F=>F!==M):y.concat(M);return D.sort(Eb),D},[w,y]),C=Ot((M,D)=>{let F=D?y:[],[G]=y.slice(-1),A=G?n.indexOf(G):0,V=Math.min(M,A),B=Math.max(M,A),U=n.slice(V,B+1),X=[...new Set([...F,...U])];return X.sort(Eb),X},[n,y]),k=Ot((M,D,F,G,A)=>{let V;f?V=b(F):d?A&&!G?V=b(F):G?V=C(D,A):V=[F]:h?V=S(F):V=x(F),V!==y&&v(V),i==null||i(M,F),V!==y&&s&&s(M,V)},[f,d,h,y,i,b,C,S,x,v,s]),E=Ot(M=>{let D=n[t];lh(D)&&(m(M)||u&&M.key==="Tab")&&(M.key!=="Tab"&&M.preventDefault(),k(M,t,D,!1,M.ctrlKey||M.metaKey),d&&(p.current=t))},[n,t,m,u,k,d]),R=Ot((M,D)=>{if(d&&M.shiftKey){let F=n[D];lh(F)&&k(M,D,F,!0)}},[d,n,k]);return{listHandlers:{onClick:Ot(M=>{let D=n[t];!e&&lh(D)&&(M.preventDefault(),M.stopPropagation(),k(M,t,D,M.shiftKey,M.ctrlKey||M.metaKey),d&&(p.current=t))},[e,d,t,n,k]),onKeyDown:E,onKeyboardNavigation:R},selected:y,setSelected:v}};import{useRef as ah,useCallback as Ib}from"react";var Pb=({disableTypeToSelect:r,highlightedIdx:e,highlightItemAtIndex:t,typeToNavigate:n,items:o,applyIncrementalSearch:i=!0})=>{let s=ah(null),l=ah(""),a=ah(-1),c=Ib(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=Ib(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 Db,useCallback as ao}from"react";import{useIsomorphicLayoutEffect as QE}from"@salt-ds/core";import"react/jsx-runtime";var Lb=["height"],YE=["height","scrollHeight"],XE=[],Ab={containerOnly:[YE,XE],withContent:[Lb,Lb]},ZE=r=>r?Ab.containerOnly:Ab.withContent,Ob={current:null},eR=(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}}},Nb=({containerRef:r,contentRef:e=Ob,highlightedIdx:t=-1,indexPositions:n,stickyHeaders:o=!1})=>{let i=Db(!1),s=Db({height:0,contentHeight:0}),l=ao(m=>{i.current=!0,r.current&&(r.current.scrollTop=m),setTimeout(()=>{i.current=!1})},[]),a=ao(()=>l(0),[l]),c=ao(()=>{l(s.current.contentHeight-s.current.height)},[l]),u=ao(m=>{let g=e.current||r.current;if(m.id){let y=document.getElementById(m.id);if(y&&r.current){let{height:v}=s.current,w=y.ariaExpanded&&y.firstChild?y.firstChild:y,x=o?36:0,S=eR(w,g),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]);QE(()=>{let{height:m,contentHeight:g}=s.current,y=n[t];if(g>m&&y){let[v]=n,[w]=n.slice(-1);y===v?a():y===w?c():u(n[t])}},[t,n,u,c,a]);let h=ao(({height:m,scrollHeight:g})=>{typeof m=="number"&&(s.current.height=m),typeof g=="number"&&(s.current.contentHeight=g)},[]),f=ao(({height:m})=>{typeof m=="number"&&(s.current.contentHeight=m)},[]),[d,p]=ZE(e===Ob);return Si(r,d,h,!0),Si(e,p,f,!0),{isScrolling:i,scrollIntoView:u}};var Vb=({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:g,onKeyDown:y,restoreLastFocus:v,selected:w,selectionStrategy:x,selectionKeys:S,stickyHeaders:b,tabToSelect:C})=>{let k=tR(w||i),E=(re,se)=>{var Me,Tt;(Tt=(Me=B.listHandlers).onKeyboardNavigation)==null||Tt.call(Me,re,se),g==null||g(re,se)},R=Al((re,se)=>{d&&(ch(se.value)?d(re,se.label):se.value!==null&&d(re,se.value))},[d]),N=Al((re,se)=>{p&&p(re,Array.isArray(se)?se.map(Me=>ch(Me.value)?Me.label:Me.value):se&&(ch(se.value)?se.label:se.value))},[p]),{highlightedIndex:O,listProps:{onKeyDown:M,onMouseMove:D,...F},setHighlightedIndex:G,...A}=bb({containerRef:t,defaultHighlightedIndex:o,disableHighlightOnFocus:a,highlightedIndex:u,indexPositions:e.data,label:h,onHighlight:m,onKeyboardNavigation:E,restoreLastFocus:v,selected:k.current}),V=kb({collapsibleHeaders:r,highlightedIdx:O,collectionHook:e}),B=Rb({defaultSelected:i,highlightedIdx:O,indexPositions:e.data,label:h,onSelect:R,onSelectionChange:N,selected:w,selectionStrategy:x,selectionKeys:S,tabToSelect:C}),{onKeyDown:U}=Pb({disableTypeToSelect:c,highlightedIdx:O,highlightItemAtIndex:G,typeToNavigate:!0,items:e.data}),X=Al(re=>{var se,Me,Tt;re.defaultPrevented||U==null||U(re),M(re),re.defaultPrevented||(Me=(se=B.listHandlers).onKeyDown)==null||Me.call(se,re),re.defaultPrevented||(Tt=V==null?void 0:V.onKeyDown)==null||Tt.call(V,re),re.defaultPrevented||y==null||y(re)},[V,M,y,B.listHandlers,U]),{isScrolling:ee,scrollIntoView:_e}=Nb({containerRef:t,contentRef:n,highlightedIdx:O,indexPositions:e.data,stickyHeaders:b}),de=Al(re=>{if(!ee.current&&!s){D();let se=Mb(re.target);if(se!==O){let Me=e.data[se];!Me||Me.disabled?G(-1):G(se)}}},[ee,s,G,D,O,e.data]),it=()=>{var re;return O===void 0||O===-1||l||(re=e.data[O])==null?void 0:re.id};k.current=B.selected;let On={"aria-activedescendant":it(),onBlur:F.onBlur,onFocus:F.onFocus,onKeyDown:X,onMouseDownCapture:F.onMouseDownCapture,onMouseLeave:F.onMouseLeave},Vt=f||{onClick:B.listHandlers.onClick,onMouseMove:de};return{focusVisible:A.focusVisible,controlledHighlighting:A.controlledHighlighting,highlightedIndex:O,keyboardNavigation:A.keyboardNavigation,listHandlers:Vt,listItemHeaderHandlers:V,listControlProps:On,scrollIntoView:_e,selected:B.selected,setHighlightedIndex:G,setIgnoreFocus:A.setIgnoreFocus,setSelected:B.setSelected}};import{useState as nR,useMemo as rR,useCallback as oR}from"react";import"@salt-ds/core";import"react/jsx-runtime";var Fb=({borderless:r,displayedItemCount:e,getItemHeight:t,height:n,itemCount:o,itemGapSize:i,itemHeight:s,rowHeightRef:l})=>{let[a,c]=nR(36),u=rR(()=>{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,g,y)=>m+t(y)+i,0)-i:f+=p*Number(d)+(p-1)*i,isNaN(f)?void 0:f},[r,e,t,o,i,s,a]),h=oR(({height:f})=>{c(f)},[]);return Si(l,ub,h,!0),{preferredHeight:u}};var Bb=`.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 pR="No data to display",ki=hR("saltList"),hh=lR(function({ListItem:e=Ti,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:g,height:y,highlightedIndex:v,id:w,itemGapSize:x=0,itemHeight:S,itemTextHighlightPattern:b,itemToString:C=so,listHandlers:k,maxHeight:E,maxWidth:R,minHeight:N,minWidth:O,onSelect:M,onSelectionChange:D,onHighlight:F,restoreLastFocus:G,selected:A,selectionStrategy:V,checkable:B=V==="multiple",scrollingApiRef:U,selectionKeys:X,showEmptyMessage:ee=!1,source:_e,style:de,stickyHeaders:it,tabToSelect:On,width:Vt,...re},se){let Me=un();hn({testId:"salt-list",css:Bb,window:Me});let Tt=fR(w),ho=uh(null),fo=uh(null),po=uh(null),kt=ab({id:Tt,label:"List",source:_e,children:o,options:{collapsibleHeaders:s,getItemId:g,itemToString:C}}),{preferredHeight:mo}=Fb({borderless:n,displayedItemCount:f,getItemHeight:m,height:y,itemCount:kt.data.length,itemGapSize:x,itemHeight:S,rowHeightRef:po}),{focusVisible:Ql,highlightedIndex:Yl,listControlProps:Z0,listHandlers:ex,listItemHeaderHandlers:tx,scrollIntoView:nx,selected:rx}=Vb({collapsibleHeaders:s,collectionHook:kt,containerRef:ho,contentRef:fo,defaultHighlightedIndex:l,defaultSelected:kt.itemToCollectionItem(a),disabled:c,disableTypeToSelect:h,highlightedIndex:v,label:Tt,listHandlers:k,onSelect:M,onSelectionChange:D,onHighlight:F,restoreLastFocus:G,selected:kt.itemToCollectionItem(A),selectionStrategy:V,selectionKeys:X,stickyHeaders:it,tabToSelect:On});fb({collectionHook:kt,forwardedRef:U,scrollableRef:ho,scrollIntoView:nx});let Dh=p!=null?p:Ql,Lh=function(Ce,st,Je,lt){let Vn=aR(e,{...tx,className:yr("saltListItemHeader",{focusVisible:s&&Dh===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},ox=m===void 0?()=>S:m;function ix(Nn,Ce,st){var Je;let{disabled:lt,value:Vn,id:go,label:Xl}=Ce,yo=cR(Vn),Di={className:yr({saltHighlighted:st.value===Yl,saltFocusVisible:Dh===st.value}),disabled:lt||c,id:go,item:yo?void 0:(Je=Ce==null?void 0:Ce.value)!=null?Je:void 0,itemHeight:ox(st.value),itemTextHighlightPattern:b,key:go,"data-idx":st.value,label:Xl,role:"option",selected:xb(rx,Ce),showCheckbox:B};Nn.push(yo?uR(Vn,Di):xr(e,{...Di})),st.value+=1}let sx=function(Ce,st,Je){let{count:lt=0,id:Vn,expanded:go,label:Xl=""}=st[Je.value],yo=Lh(Je,Vn,Xl,go),Di=go!==!1?[yo].concat(Ah(st,Je,Je.value+lt)||[]):yo;Ce.push(xr("div",{role:"group",children:Di},Vn))},Ah=(Nn,Ce={value:0},st=Nn.length)=>{let Je=[];for(;Ce.value<st;){let lt=Nn[Ce.value];lt.header?Je.push(Lh(Ce,lt.id,lt.label,lt.expanded===!1)):lt.childNodes?sx(Je,Nn,Ce):ix(Je,lt,Ce)}return Je};function lx(){return d||ee?xr("span",{className:ki("empty-message"),children:d!=null?d:pR}):null}let ax=()=>{if(kt.data.length)return Ah(kt.data);lx()},cx="auto",ux={"--list-item-gap":x?`${x}px`:void 0,minWidth:O,minHeight:N,width:Vt!=null?Vt:"100%",height:y!=null?y:"100%",maxWidth:R!=null?R:Vt,maxHeight:E!=null?E:mo};return iR("div",{"aria-multiselectable":V==="multiple"||V==="extended"||V==="extended-multi-range"||void 0,...re,...ex,...Z0,className:yr(ki(),i,{[ki("borderless")]:n,saltDisabled:c,[ki("collapsible")]:s,saltFocusVisible:Yl===oh}),id:`${Tt}`,ref:dR(ho,se),role:"listbox",style:{...de,...ux},tabIndex:c||u?void 0:0,children:[xr(sh,{ref:po}),kt.data.length===0&&t!==void 0?xr(sR,{children:xr(t,{})}):xr("div",{className:ki("scrollingContentContainer"),ref:fo,style:{height:cx},children:ax()})]})});import{useCallback as y9}from"react";import x9 from"classnames";import{jsx as w9}from"react/jsx-runtime";import Wb,{Suspense as xR,useEffect as vR}from"react";import mR from"react";import{Fragment as gR,jsx as Hb,jsxs as yR}from"react/jsx-runtime";var Ol=class extends mR.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?yR(gR,{children:[Hb("h1",{children:"An error occured while creating component."}),Hb("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as bR}from"react/jsx-runtime";var _b=()=>bR("div",{className:"hwLoader",children:"loading"});var zb=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,wR=r=>{vR(()=>()=>{Nl.delete(r)},[r]),Nl.has(r)||Nl.set(r,Wb.lazy(()=>import(r)));let e=Nl.get(r);if(e)return e;throw Error(`Unable to load Lazy Feature at url ${r}`)};function SR({url:r,css:e,ComponentProps:t,...n}){e&&zb(e).then(i=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,i]});let o=wR(r);return Vl(Ol,{url:r,children:Vl(xR,{fallback:Vl(_b,{}),children:Vl(o,{...n,...t})})})}var fh=Wb.memo(SR);fh.displayName="Feature";ge("Feature",fh,"view");import{useEffect as CR,useState as Mi}from"react";import{Input as TR,Button as $b,FormField as Fl,FormFieldLabel as Bl,Text as kR}from"@salt-ds/core";import{ComboBox as MR,Checkbox as ER,RadioButton as RR}from"@vuu-ui/vuu-ui-controls";import{formatDate as IR,takeScreenshot as PR}from"@vuu-ui/vuu-utils";import{jsx as je,jsxs as Ln}from"react/jsx-runtime";var ot="saveLayoutPanel",Hl=`${ot}-formField`,DR=["Group 1","Group 2","Group 3","Group 4","Group 5"],LR=["Value 1","Value 2","Value 3"],Ub=["Value 1","Value 2","Value 3"],Gb=r=>{let{onCancel:e,onSave:t,componentId:n}=r,[o,i]=Mi(""),[s,l]=Mi(""),[a,c]=Mi([]),[u,h]=Mi(Ub[0]),[f,d]=Mi();CR(()=>{n&&PR(document.getElementById(n)).then(m=>d(m))},[n]);let p=()=>{t({name:o,group:s,screenshot:f!=null?f:"",user:"User",date:IR(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(MR,{source:DR,allowFreeText:!0,InputProps:{inputProps:{className:`${ot}-inputText`,placeholder:"Select Group or Enter New Name",onChange:m=>l(m.target.value)}},width:120,onSelectionChange:(m,g)=>l(g||"")})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Layout Name"}),je(TR,{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:LR.map((m,g)=>je(ER,{onToggle:()=>c(y=>y.includes(m)?y.filter(v=>v!==m):[...y,m]),checked:a.includes(m),label:m},g))})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Some Layout Setting"}),je("div",{className:`${ot}-settingsGroup`,children:Ub.map((m,g)=>je(RR,{onClick:()=>h(m),checked:u===m,label:m,groupName:"radioGroup"},g))})]})]}),je("div",{className:`${ot}-screenshotContainer`,children:f?je("img",{className:`${ot}-screenshot`,src:f,alt:"screenshot of current layout"}):je(kR,{className:"screenshot",children:"No screenshot available"})})]}),Ln("div",{className:`${ot}-buttonsContainer`,children:[je($b,{className:`${ot}-cancelButton`,onClick:e,children:"Cancel"}),je($b,{className:`${ot}-saveButton`,onClick:p,disabled:o===""||s==="",children:"Save"})]})]})};import{List as f6}from"@vuu-ui/vuu-ui-controls";import AR,{useState as Z9,useCallback as e6,useContext as OR,useEffect as t6}from"react";import{jsx as l6}from"react/jsx-runtime";var i6=new Sl,NR=AR.createContext({layoutMetadata:[],saveLayout:()=>{},applicationLayout:Bo,saveApplicationLayout:()=>{},loadLayoutById:()=>Bo});var _l=()=>OR(NR);import{Fragment as y6,jsx as g6,jsxs as b6}from"react/jsx-runtime";import{memo as VR}from"react";import{jsx as Ct,jsxs as co}from"react/jsx-runtime";var qb=VR(()=>co("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[co("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"}),co("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"})]})]}),co("defs",{children:[co("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"})]}),co("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"})})]})]}));qb.displayName="VuuLogo";import{Tab as o7,Tabstrip as i7}from"@vuu-ui/vuu-ui-controls";import l7 from"classnames";import{useCallback as f7,useState as d7}from"react";import{jsx as F6,jsxs as B6}from"react/jsx-runtime";import{createContext as FR,isValidElement as BR,cloneElement as HR,useContext as _R}from"react";import zR from"classnames";import{jsx as qR}from"react/jsx-runtime";var WR="medium",$R="salt-theme",UR="light",jb=FR({density:"high",theme:"vuu",themeMode:"light"});var GR=(r,e,t,n)=>{var o;return BR(r)?HR(r,{className:zR((o=r.props)==null?void 0:o.className,`${e}-theme`,`${e}-density-${n}`),"data-mode":t}):(console.warn(`
|
|
205
|
+
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)},Jb=({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:WR,c=(d=n!=null?n:s)!=null?d:UR,u=(p=t!=null?t:l)!=null?p:$R,h=r?GR(e,u,c,a):e;return qR(jb.Provider,{value:{themeMode:c,density:a,theme:u},children:h})};Jb.displayName="ThemeProvider";import{jsx as b7,jsxs as x7}from"react/jsx-runtime";import{useState as R7}from"react";import{Button as P7,FormField as D7,FormFieldLabel as L7,Input as A7}from"@salt-ds/core";import{jsx as V7,jsxs as F7}from"react/jsx-runtime";import{getCookieValue as jR}from"@vuu-ui/vuu-utils";var JR=()=>{let r=jR("vuu-auth-mode");return r!=null?r:""};var QR=()=>JR()==="login"?"login.html":"demo.html",YR=(r=QR())=>{window.location.href=r},Qb=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",YR(r)};import{useCallback as X7,useEffect as Z7,useMemo as eG,useRef as tG,useState as nG}from"react";import oG from"classnames";import{useIdMemo as sG}from"@salt-ds/core";import{Button as aG}from"@salt-ds/core";import{buildColumnMap as dG,isValidNumber as pG,shallowEquals as mG}from"@vuu-ui/vuu-utils";import{jsx as bG,jsxs as xG}from"react/jsx-runtime";import KK from"classnames";import{useCallback as XK,useEffect as ZK,useRef as ej}from"react";import{useCallback as Bq}from"react";import{Button as oq}from"@salt-ds/core";import{jsx as e0}from"react/jsx-runtime";import{forwardRef as XR}from"react";function Yb(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=Yb(r[e]))&&(n&&(n+=" "),n+=t);else for(e in r)r[e]&&(n&&(n+=" "),n+=e);return n}function Xb(){for(var r,e,t=0,n="";t<arguments.length;)(r=arguments[t++])&&(e=Yb(r))&&(n&&(n+=" "),n+=e);return n}var Zb=`/* Style applied to the root element */
|
|
207
|
+
.saltIcon {
|
|
208
|
+
--icon-color: var(--saltIcon-color, var(--salt-text-secondary-foreground));
|
|
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 ZR=r=>(...e)=>[r,...e].join("-"),eI=ZR("saltIcon"),tI=1,t0=XR(function({children:e,className:t,size:n=tI,style:o,...i},s){let l=un();hn({testId:"salt-icon",css:Zb,window:l});let a={...o,"--saltIcon-size-multiplier":`${n}`};return e0("svg",{className:Xb(eI(),t),style:a,role:"img",...i,ref:s,children:e0("g",{"aria-hidden":!0,children:e})})});import{jsxs as nI,jsx as n0}from"react/jsx-runtime";import{forwardRef as rI}from"react";var ph=rI(function(e,t){return nI(t0,{"data-testid":"ExportIcon","aria-label":"export",viewBox:"0 0 12 12",ref:t,...e,children:[n0("path",{d:"M5 1H1v10h4v-1H2V2h3V1Z"}),n0("path",{d:"M3 5h5V3l4 3-4 3V7H3V5Z"})]})});import{formatDate as oI}from"@vuu-ui/vuu-utils";import{Button as iI}from"@salt-ds/core";import{forwardRef as sI,useCallback as o0,useEffect as lI,useState as aI}from"react";var r0=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 i0}from"react/jsx-runtime";var cI=({lastUpdate:r},{lastUpdate:e})=>e===r?0:e<r?-1:1,uI=r=>Wl(Ti,{...r}),hI=sI(function({loginUrl:e,onNavigate:t,user:n,layoutId:o="latest"},i){let[s,l]=aI([]);lI(()=>{async function h(){let d=(await r0(n)).filter(p=>p.id!=="latest").sort(cI).map(({id:p,lastUpdate:m})=>({lastUpdate:m,id:p,label:`Saved at ${oI(new Date(m),"kk:mm:ss")}`}));console.log({sortedHistory:d}),l(d)}h()},[n]);let a=o0((h,f)=>{f&&t(f.id)},[t]),c=o0(()=>{Qb(e)},[e]),u=s.length===0?null:o==="latest"?s[0]:s.find(h=>h.id===o);return i0("div",{className:"vuuUserPanel",ref:i,children:[Wl(hh,{ListItem:uI,className:"vuuUserPanel-history",onSelect:a,selected:u,source:s}),Wl("div",{className:"vuuUserPanel-buttonBar",children:i0(iI,{"aria-label":"logout",onClick:c,children:[Wl(ph,{})," Logout"]})})]})});import{jsx as aq,jsxs as cq}from"react/jsx-runtime";import gq from"classnames";import{ToggleButton as bq,ToggleButtonGroup as xq,useControlled as vq}from"@salt-ds/core";import{useCallback as Tq}from"react";import{jsx as Eq,jsxs as Rq}from"react/jsx-runtime";import Wq from"classnames";import{jsx as Gq,jsxs as qq}from"react/jsx-runtime";import{logger as fI}from"@vuu-ui/vuu-utils";import{Button as Zq}from"@salt-ds/core";import tK from"classnames";import{useCallback as rK,useMemo as oK}from"react";import{jsx as cK,jsxs as uK}from"react/jsx-runtime";import{jsx as bK,jsxs as xK}from"react/jsx-runtime";import{useCallback as kK,useRef as MK,useState as EK}from"react";import{jsx as IK,jsxs as PK}from"react/jsx-runtime";import{jsx as fj,jsxs as dj}from"react/jsx-runtime";var{error:uj}=fI("Shell");import{createContext as dI,useContext as bj}from"react";import{jsx as wj}from"react/jsx-runtime";var pI={},xj=dI(pI);import{useCallback as s0,useMemo as mI,useState as gI}from"react";import{jsx as yI}from"react/jsx-runtime";var Wj=()=>{let[r,e]=gI(),{saveLayout:t}=_l(),n=s0(()=>{e(void 0)},[]),o=s0(l=>{t(l),e(void 0)},[t]),[i,s]=mI(()=>[(l,a)=>{console.log({options: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(yI(Gb,{onCancel:n,onSave:o,componentId:l.options.controlledComponentId})),!0):!1)],[n,o]);return{buildMenuOptions:i,dialogContent:r,handleCloseDialog:n,handleMenuAction:s}};import{forwardRef as LI}from"react";import{isValidNumber as An}from"@vuu-ui/vuu-utils";import{useCallback as vI,useEffect as wI,useMemo as SI,useRef as CI,useState as TI}from"react";import{useCallback as bI,useEffect as l0,useRef as xI}from"react";var vr=new Map,c0=(r,e,t)=>{switch(t){case"height":return e.height;case"clientHeight":return r.clientHeight;case"clientWidth":return r.clientWidth;case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(r.scrollHeight);case"scrollWidth":return Math.ceil(r.scrollWidth);case"width":return e.width;default:return 0}},a0=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=c0(t,{height:s,width:l,contentHeight:a,contentWidth:c},d);m!==p&&(f=!0,h[d]=m)}f&&u&&u(h)}}});function u0(r,e,t,n=!1){let o=xI(e),i=bI(s=>{let{width:l,height:a}=s.getBoundingClientRect(),{clientWidth:c,clientHeight:u}=s;return o.current.reduce((h,f)=>(h[f]=c0(s,{width:l,height:a,contentHeight:u,contentWidth:c},f),h),{})},[]);l0(()=>{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,a0.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)&&(a0.unobserve(s),vr.delete(s))}},[i,r]),l0(()=>{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 kI=["clientHeight","clientWidth"],MI=["clientWidth"],EI=["clientHeight"],RI=[],$l=r=>Number.isFinite(r),II={height:"100%",width:"100%"},PI=(r,e)=>An(r)&&An(e)?{height:`${r}px`,width:`${e}px`}:typeof r=="string"&&typeof e=="string"?{height:r,width:e}:II,DI=(r,e)=>{if(An(r)&&An(e))return{height:r,width:e}},h0=({defaultHeight:r=0,defaultWidth:e=0,height:t,onResize:n,width:o})=>{let i=CI(null),[s,l]=TI({css:PI(t,o),inner:DI(t,o),outer:{height:t!=null?t:"100%",width:o!=null?o:"100%"}}),a=typeof t=="number",c=typeof o=="number",u=a&&c?RI:a?MI:c?EI:kI;SI(()=>{l(f=>{let{inner:d,outer:p}=f;if(An(t)&&An(o)&&d&&p){let{height:m,width:g}=d,{height:y,width:v}=p;if(y!==t||v!==o){let w=An(y)?y-m:0,x=An(v)?v-g:0;return{...f,outer:{height:t,width:o},inner:{height:t-w,width:o-x}}}}return f})},[t,o]);let h=vI(({clientWidth:f,clientHeight:d})=>{let{css:p,inner:m,outer:g}=s,y=s;a&&$l(f)&&f!==(m==null?void 0:m.width)?y={css:p,outer:g,inner:{width:Math.floor(f)||e,height:t}}:c&&$l(d)&&d!==(m==null?void 0:m.height)?y={css:p,outer:g,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))&&(y={css:p,outer:g,inner:{width:Math.floor(f)||e,height:Math.floor(d)||r}}),y!==s&&l(y)},[r,e,a,c,t,s,o]);return wI(()=>{s.inner&&(n==null||n(s.inner))},[n,s.inner]),u0(i,u,h,!0),{containerRef:i,cssSize:s.css,outerSize:s.outer,innerSize:s.inner}};import{useForkRef as AI}from"@salt-ds/core";import f0 from"classnames";import{jsx as d0}from"react/jsx-runtime";var mh="vuuMeasuredContainer",yJ=LI(function({children:e,className:t,height:n,onResize:o,style:i,width:s,...l},a){let{containerRef:c,...u}=h0({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=AI(c,a);return d?d0("div",{...l,className:f0(mh,`${mh}-ummeasured`),style:p(),ref:c}):d0("div",{...l,className:f0(mh,t),ref:m,style:p(),children:e})});import{PopupMenu as YI}from"@vuu-ui/vuu-popups";import ql from"classnames";import XI,{forwardRef as ZI}from"react";import{useDragDropNext as KI}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as jI,MEASURES as JI}from"@vuu-ui/vuu-utils";import{useCallback as Gl,useMemo as bh,useRef as C0,useState as QI}from"react";import{getElementByDataIndex as p0}from"@vuu-ui/vuu-utils";var OI=".vuuOverflowContainer-item:not(.wrapped)",NI=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}),gh=[],Ei=(r,e="horizontal")=>{let t=[],n=[],o=-1,i=!1,s=NI(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]},m0=(r,e)=>{let t=!1;e.find(({index:n})=>n==="overflow")&&e.length===1&&(t=!0);for(let n of r.children){let{dataset:{index:o="?"}}=n;e.length===0||t?r.classList.remove("overflowed"):r.classList.add("overflowed"),o!=="overflow"&&e.find(i=>i.index===o)?n.classList.add("wrapped"):n.classList.remove("wrapped")}},VI=(r,{overflowPriority:e})=>Math.max(r,parseInt(e)),FI=(r,{overflowPriority:e})=>Math.min(r,parseInt(e)),g0=r=>{var e;return r.length>1&&((e=r.at(-1))==null?void 0:e.index)==="overflow"},BI=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},y0=(r,e)=>{var o;let t=r.reduce(FI,Number.MAX_SAFE_INTEGER);return e.reduce(VI,0)>t?!0:e.length>1&&((o=e.at(-1))==null?void 0:o.index)==="overflow"},b0=(r,e)=>new Promise(t=>{requestAnimationFrame(()=>{let[,n]=Ei(r);zI(e,n).forEach(i=>HI(r,i)),t(n)})}),x0=(r,e,t)=>new Promise(n=>{requestAnimationFrame(()=>{let[,o]=Ei(r),i=BI(o);if(i){let[s,l]=yh(r,i);n([s,l])}else n([e,t])})}),HI=(r,e)=>{let t=p0(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")),zI=(r,e)=>{let t=[];for(let n of e)r.find(({index:o})=>o===n.index)||t.push(n);return t},WI=(r,e)=>{_I(r).forEach(n=>{let{dataset:{index:o="?"}}=n;e.find(i=>i.index===o)||n.classList.remove("wrapped")})},v0=r=>r.querySelector('[data-index="overflow"]'),$I=r=>r.querySelector(".wrapped"),Ul=r=>parseInt(getComputedStyle(r).getPropertyValue("width")),w0=(r,e)=>{let{right:t}=r.getBoundingClientRect(),n=parseInt(getComputedStyle(r).getPropertyValue("padding-right")),{right:o}=e.getBoundingClientRect();return t-n-o},S0=r=>{let e=v0(r),t=w0(r,e),n=Ul(e),o=$I(r);return Ul(o)<=t+n?(r.classList.remove("overflowed"),o.classList.remove("wrapped"),!0):!1},UI=(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)},GI=r=>Array.from(r.querySelectorAll(OI)).sort(UI),yh=(r,e)=>{let t=GI(r),n=p0(r,e.index,!0),o=-1,i=t.at(o),s=Ul(i),l=Ul(n),a=v0(r),c=w0(r,a)+s;if(c>=l)qI(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(),g=f-m;c=d+g}n==null||n.classList.remove("wrapped"),p.forEach(m=>{m.classList.add("wrapped")})}let[u,h]=Ei(r);return WI(r,h),[u,h]},qI=(r,e)=>{if(!r||!e)throw Error("switchWrapOnElements, element undefined");r.classList.remove("wrapped"),e.classList.add("wrapped")};var T0=({allowDragDrop:r=!1,itemCount:e,onMoveItem:t,onSwitchWrappedItemIntoView:n,orientation:o="horizontal"})=>{let[i,s]=QI(null),l=C0(gh),a=C0(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]=Ei(i,o);for(m0(i,x),g0(x)&&(x=await b0(i,x));y0(w,x);)[w,x]=await x0(i,w,x);x.length===1&&S0(i)&&(x=gh),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]=bh(()=>[()=>{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]=yh(i,w.overflowItem);l.current=x,n==null||n(w.overflowItem)}return!0}],[i,n]),p=bh(()=>{let{sizeProp:w}=JI[o],x=0;return new ResizeObserver(S=>{for(let b of S){let{[w]:C}=b.contentRect,k=Math.round(C);jI(k)&&x!==k&&(x=k,u())}})},[u,o]);Xh(()=>{u()},[u,e]),bh(()=>{i&&p.observe(i)},[i,p]);let m=Gl(w=>{s(a.current=w)},[]),g=Gl((w,x)=>{t==null||t(w,x)},[t]),{onMouseDown:y,...v}=KI({allowDragDrop:r,containerRef:a,draggableClassName:"vuuOverflowContainer",onDrop:g,orientation:"horizontal",itemQuery:".vuuOverflowContainer-item"});return{menuActionHandler:d,menuBuilder:f,onItemMouseDown:y,rootRef:m,...v}};import{jsx as Ri,jsxs as eP}from"react/jsx-runtime";var uo="vuuOverflowContainer",k0=XI.memo(({allowDragDrop:r,children:e,className:t,height:n,id:o,onMoveItem:i,onSwitchWrappedItemIntoView:s,orientation:l="horizontal",overflowIcon:a,overflowPosition:c="end"})=>{let u=wr(e),{draggable:h,draggedItemIndex:f,menuActionHandler:d,menuBuilder:p,onItemMouseDown:m,rootRef:g}=T0({allowDragDrop:r,itemCount:u.length,onMoveItem:i,onSwitchWrappedItemIntoView:s,orientation:l}),v={"--overflow-container-height":`${l==="vertical"?"100%":`${n}px`}`},w=ql(`${uo}-wrapContainer`,t,{[`${uo}-horizontal`]:l==="horizontal",[`${uo}-vertical`]:l==="vertical"}),x=u.map((b,C)=>{let{"data-align":k,"data-overflow-priority":E="0",id:R=`${o}-${C}`,label:N=`Item ${C+1}`}=b.props;return Ri("div",{className:ql(`${uo}-item`,{"vuuDraggable-dragAway":f===C}),"data-index":C,"data-align":k,"data-label":N,"data-overflow-priority":E,id:`${R}-wrapper`,onMouseDown:m,children:b},C)}),S=Ri("div",{className:`${uo}-OverflowIndicator`,"data-index":"overflow",children:Ri(YI,{icon:a,menuBuilder:p,menuActionHandler:d,tabIndex:-1})},"overflow");return x.push(S),eP("div",{className:w,ref:g,style:v,children:[x,h]})});k0.displayName="OverflowContainer.InnerContainer";var M0=ZI(function({allowDragDrop:e=!1,children:t,className:n,height:o=44,id:i,onMoveItem:s,onSwitchWrappedItemIntoView:l,orientation:a,overflowIcon:c,overflowPosition:u,...h},f){let d=Sr(i);return Ri("div",{...h,className:ql(ql(uo,n)),id:d,ref:f,children:Ri(k0,{allowDragDrop:e,height:o,id:d,orientation:a,overflowIcon:c,overflowPosition:u,onMoveItem:s,onSwitchWrappedItemIntoView:l,children:t})})});import{uuid as tP}from"@vuu-ui/vuu-utils";import{List as nP,ListItem as rP}from"@vuu-ui/vuu-ui-controls";import E0 from"classnames";import{cloneElement as oP,memo as iP}from"react";import{jsx as xh}from"react/jsx-runtime";var sP=r=>{let e=r.cloneNode(!0);return e.id="",delete e.dataset.idx,e},dh=iP(({className:r,children:e,idx:t,resizeable:n,header:o,closeable:i,...s})=>xh(rP,{className:E0("vuuPaletteItem",r),"data-draggable":!0,"data-icon":"draggable",...s}));dh.displayName="PaletteItem";var Kb=({children:r,className:e,itemHeight:t=41,orientation:n="horizontal",ViewProps:o,...i})=>{let s=ut(),l="vuuPalette";function a(c){var k,E;let h=c.target.closest(".vuuPaletteItem"),f=parseInt((E=(k=h.dataset)==null?void 0:k.index)!=null?E:"-1"),{props:{caption:d,children:p,template:m,...g}}=r[f],{height:y,left:v,top:w,width:x}=h.getBoundingClientRect(),S=tP(),C=m?p:xh(qn,{...o,...{id:S,key:S},...g,title:g.label,children:p});s({dragRect:{left:v,top:w,right:v+x,bottom:w+150,width:x,height:y},dragElement:sP(h),evt:c.nativeEvent,instructions:{DoNotRemove:!0,DoNotTransform:!0,DriftHomeIfNoDropTarget:!0,RemoveDraggableOnDragEnd:!0,dragThreshold:10},path:"*",payload:C,type:"drag-start"})}return xh(nP,{...i,className:E0(l,e,`${l}-${n}`),itemHeight:t,selected:null,children:r.map((c,u)=>c.type===dh?oP(c,{key:u,onMouseDown:a}):c)})};ge("Palette",Kb,"view");import{Tab as lP,Tabstrip as aP}from"@vuu-ui/vuu-ui-controls";import R0 from"classnames";import vh,{forwardRef as cP,useCallback as uP}from"react";import{jsx as P0,jsxs as mP}from"react/jsx-runtime";var I0="Tabs",hP=()=>{},fP=(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}`},dP=r=>{let e=[];return vh.Children.forEach(r,t=>{vh.isValidElement(t)?e.push(t):console.warn("Stack has unexpected child element type")}),e},pP={allowAddTab:!1,allowCloseTab:!1,allowRenameTab:!1},zl=cP(function({active:e=0,children:t,className:n,getTabIcon:o=hP,getTabLabel:i=fP,id:s,keyBoardActivation:l="manual",onAddTab:a,onMoveTab:c,onTabClose:u,onTabEdit:h,onTabSelectionChanged:f,showTabs:d="top",style:p,TabstripProps:m=pP},g){var N;let y=Sr(s),{allowCloseTab:v,allowRenameTab:w,className:x}=m,S=uP((O,M,D,F)=>{h==null||h(F,M)},[h]),b=()=>{var O;return vh.isValidElement(t)?t:Array.isArray(t)&&(O=t[e])!=null?O:null},C=()=>dP(t).map((O,M)=>{let{closeable:D=v,id:F=`${y}-${M}`,"data-tab-location":G}=O.props;return P0(lP,{ariaControls:F,"data-icon":o(O,M),id:`${F}-tab`,index:M,label:i(O,M),location:G,closeable:D,editable:w},F)}),k=b(),E=d==="left"||d==="right",R=E?"vertical":"horizontal";return mP("div",{className:R0(I0,n,{[`${I0}-horizontal`]:E}),style:p,id:y,ref:g,children:[d?P0(aP,{...m,activeTabIndex:(N=m==null?void 0:m.activeTabIndex)!=null?N:k===null?-1:e,allowDragDrop:m.allowDragDrop!==!1,animateSelectionThumb:!0,className:R0("vuuTabHeader",x),keyBoardActivation:l,onActiveChange:f,onAddTab:a,onCloseTab:u,onExitEditMode:S,onMoveTab:c,orientation:R,children:C()}):null,k]})});zl.displayName="Stack";import{useIdMemo as gP}from"@salt-ds/core";import yP,{useCallback as wh,useRef as bP}from"react";import{jsx as Sh}from"react/jsx-runtime";var xP=r=>Sh(qn,{resizeable:!0,title:`Tab ${r}`,style:{flexGrow:1,flexShrink:0,flexBasis:0},header:!0,closeable:!0,children:Sh(ta,{style:{flex:1}})}),D0=r=>{var S;let e=bP(null),t=ut(),{loadState:n}=kr(),{createNewChild:o,id:i,onTabSelectionChanged:s,path:l,...a}=r,{children:c}=r,u=gP(i),[h]=is(u,e,l),f=gd(),d=(S=o!=null?o:f)!=null?S:xP,p=b=>{l&&(t({type:"switch-tab",id:u,path:l,nextIdx:b}),s==null||s(b))},m=wh(b=>{if(Array.isArray(c)){let{props:{"data-path":C,path:k=C}}=c[b];t({type:"remove",path:k})}},[c,t]),g=wh(()=>{if(l){let b=yP.Children.count(c),C=d(b);t({type:"add",path:l,component:C})}},[c,d,t,l]),y=wh((b,C)=>{l&&t({fromIndex:b,toIndex:C,path:l,type:"move-child"})},[t,l]);return Sh(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(N=>{console.log("preDragActivity: Ok, gonna release the drag"),k=N})},b)&&(k==null||k(void 0))},onMoveTab:y,onAddTab:g,onTabClose:m,onTabEdit:(b,C)=>{t({type:"set-title",path:`${l}.${b}`,title:C})},onTabSelectionChanged:p,ref:e})};D0.displayName="Stack";ge("Stack",D0,"container");import kh from"classnames";import HP,{useMemo as _P,useRef as zP}from"react";import{isValidNumber as FP}from"@vuu-ui/vuu-utils";import{useCallback as Th,useRef as BP}from"react";import{useControlled as SP}from"@salt-ds/core";import{dispatchMouseEvent as CP,getFocusableElement as TP}from"@vuu-ui/vuu-utils";import{useCallback as Nt,useRef as Ch,useState as A0}from"react";import{ArrowDown as F0,ArrowUp as kP,ArrowLeft as MP,ArrowRight as EP,Home as O0,End as N0}from"@vuu-ui/vuu-utils";import{getElementDataIndex as vP}from"@vuu-ui/vuu-utils";var wP=(r,e)=>{if(r){let t=r.querySelector(`[data-index]:has(${e})`);return vP(t)}return-1};var L0=r=>wP(r,".vuuEditableLabel-editing");var B0={horizontal:{[O0]:"start",[N0]:"end",[MP]:"bwd",[EP]:"fwd"},vertical:{[O0]:"start",[N0]:"end",[kP]:"bwd",[F0]:"fwd"}},RP=(r,e="horizontal")=>B0[e][r]!==void 0,IP=r=>r===F0;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 PP=r=>r!==null&&!r.classList.contains("wrapped"),Ii=(r,e)=>r?r.querySelector(`[data-index="${e}"]`):null,H0=({containerRef:r,defaultHighlightedIdx:e=-1,highlightedIdx:t,keyBoardActivation:n,orientation:o,selectedIndex:i=[]})=>{let s=n==="manual",l=Ch(!1),a=Ch(-1),[c,u]=A0(!1),[,h]=A0({}),[f,d]=SP({controlled:t,default:e,name:"UseKeyboardNavigation"}),p=Nt(M=>{d(a.current=M)},[d]),m=Ch(!1),g=Nt((M,D=!1,F,G=70)=>{p(M),F===!0&&!m.current&&(m.current=!0);let A=()=>{let V=Ii(r.current,M);if(V){let B=TP(V);B==null||B.focus()}};D?A():setTimeout(A,G)},[r,p]),y=M=>{if(a.current===-1&&M.target.tabIndex!==-1){let D=L0(r.current);D!==-1?requestAnimationFrame(()=>{p(D)}):setTimeout(()=>{let[F=null]=i;a.current===-1&&F!==null&&p(F)},200)}},v=Nt(()=>{var M,D;return(D=(M=r.current)==null?void 0:M.querySelectorAll("[data-index]").length)!=null?D:0},[r]),w=Nt((M="fwd",D)=>{let F=v(),A=V0(F,M,typeof D=="number"?D:F),V=M==="start"?"fwd":M==="end"?"bwd":M;for(;(V==="fwd"&&A<F||V==="bwd"&&A>0)&&!PP(Ii(r.current,A));){let B=V0(F,V,A);if(B===A)break;A=B}return A},[r,v]),x=Nt((M,D=!1)=>{let F=B0[o][M.key],G=w(F,f);G!==f?s&&g(G,!0):D&&h({})},[f,s,w,g,o]),S=Nt(()=>{let M=Ii(r.current,f);return M?M.querySelector(".vuuPopupMenu")!=null:!1},[r,f]),b=Nt(()=>{let M=Ii(r.current,f);return M?M.querySelector(".vuuEditableLabel-input")!=null:!1},[r,f]),C=Nt(()=>{let M=Ii(r.current,f),D=M==null?void 0:M.querySelector(".vuuPopupMenu");return D&&CP(D,"click"),!1},[r,f]),k=Nt(M=>{v()>0&&RP(M.key,o)?(M.preventDefault(),m.current?x(M):(m.current=!0,x(M,!0))):IP(M.key)&&S()&&!b()&&C()},[C,v,S,b,x,o]),E=(M,D)=>{p(D)},R=Nt(()=>{c||(u(!0),l.current?l.current=!1:m.current=!0)},[c]),N=Nt(()=>{c||(l.current=!0),m.current=!1},[c]);return{containerProps:{onBlur:M=>{let D=M.target.closest(".vuuTabstrip"),F=M.relatedTarget;D&&!(D!=null&&D.contains(F))&&(p(-1),u(!1))},onMouseDownCapture:N,onFocus:R,onMouseLeave:()=>{m.current=!0,p(-1),l.current=!1}},focusVisible:m.current?f:-1,focusIsWithinComponent:c,highlightedIdx:f,focusItem:g,onClick:E,onFocus:y,onKeyDown:k,setHighlightedIdx:p}};import{isSelectableElement as _0,getClosestIndexItem as DP}from"@vuu-ui/vuu-utils";import{allowMultipleSelection as LP,deselectionIsAllowed as z0,selectionIsDisallowed as AP,useControlled as OP}from"@vuu-ui/vuu-ui-controls";import{useCallback as Pi}from"react";var NP=["Enter"," "],VP={},W0=({containerRef:r,defaultSelected:e,highlightedIdx:t,itemQuery:n,onSelectionChange:o,selected:i,selectionStrategy:s})=>{let[l,a,c]=OP({controlled:i,default:e!=null?e:[],name:"useSelection",state:"selected"}),u=Pi(g=>NP.includes(g.key),[]),h=Pi((g,y=!1)=>{let v=LP(s,y)?l.concat(g):[g];a(v),o==null||o(v)},[o,l,s,a]),f=Pi((g,y=!1)=>{let v=s==="deselectable"||s==="multiple-special-key"&&!y?[]:l.filter(w=>w!==g);a(v),o==null||o(v)},[o,l,s,a]),d=Pi(g=>{u(g)&&_0(g.target)&&(l.includes(t)?z0(s)&&(g.stopPropagation(),g.preventDefault(),f(t,g.shiftKey)):(g.stopPropagation(),g.preventDefault(),h(t,g.shiftKey)))},[u,l,t,s,h,f]),p=Pi((g,y)=>{let v=DP(g.target);_0(v)&&(l.includes(y)?z0(s)&&f(y,g.shiftKey):h(y,g.shiftKey))},[f,h,l,s]),m=AP(s)?VP:{onClick:p,onKeyDown:d};return{activateItem:h,itemHandlers:m,isControlled:c,selected:l}};var $0=({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:t,itemQuery:n="vuuToolbarItem",onActiveChange:o,orientation:i,selectionStrategy:s})=>{var b;let l=BP(r),{focusItem:a,highlightedIdx:c,onClick:u,onKeyDown:h,setHighlightedIdx:f,...d}=H0({containerRef:t,keyBoardActivation:"manual",orientation:i,selectedIndex:(b=l.current)!=null?b:[]}),{activateItem:p,itemHandlers:{onClick:m,onKeyDown:g},selected:y}=W0({containerRef:t,defaultSelected:e,highlightedIdx:c,itemQuery:n,onSelectionChange:o,selected:r,selectionStrategy:s});l.current=y;let v=Th(C=>{var R;let E=C.target.closest("[data-index]");if(E){let N=parseInt((R=E.dataset.index)!=null?R:"-1");N!==-1&&FP(N)&&(u(C,N),m==null||m(C,N))}},[u,m]),w=Th(C=>{h(C),C.defaultPrevented||g==null||g(C)},[h,g]),x=Th(C=>{let k=parseInt(C.index);isNaN(k)||p(k)},[p]),S={onClick:v,onFocus:d.onFocus,onKeyDown:w};return{activeItemIndex:y,focusVisible:d.focusVisible,containerProps:{...d.containerProps,onSwitchWrappedItemIntoView:x},itemProps:S}};import{forwardCallbackProps as WP}from"@vuu-ui/vuu-ui-controls";import{jsx as $P}from"react/jsx-runtime";var Mh="vuuToolbar",aT=({activeItemIndex:r,defaultActiveItemIndex:e,children:t,className:n,id:o,onActiveChange:i,orientation:s="horizontal",selectionStrategy:l="none",...a})=>{let c=zP(null),{activeItemIndex:u,focusVisible:h,itemProps:f,...d}=$0({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:c,onActiveChange:i,orientation:s,selectionStrategy:l}),p=Sr(o),m=kh(Mh,`${Mh}-${s}`,n),g=_P(()=>wr(t).map((y,v)=>{let{id:w=`${p}-tab-${v}`,className:x,...S}=y.props,b=u.includes(v);return HP.cloneElement(y,{...WP(S,f),className:kh("vuuToolbarItem",x,{vuuFocusVisible:h===v}),"data-overflow-priority":b?"1":void 0,id:w,key:v,"aria-selected":b,tabIndex:b?0:-1})}),[u,t,h,p,f]);return $P(M0,{...a,...d.containerProps,className:kh(Mh,m),...a,ref:c,children:g})};import U0,{useState as G0}from"react";import{jsx as Eh,jsxs as q0}from"react/jsx-runtime";var $Y=({children:r})=>{let[t,n]=G0(r),[o,i]=G0(r),s=a=>{let c=Jh(t,a);i(c)},l=(a,c)=>{console.log(`change ${a} -> ${c}`);let u=U0.cloneElement(o,{style:{...o.props.style,[a]:c}});i(u),n(U0.cloneElement(t,{},u))};return q0("div",{"data-design-mode":`${!1}`,children:[t,Eh("br",{}),q0("div",{style:{display:"flex"},children:[Eh(K0,{height:300,managedStyle:o.props.style,width:300,onChange:l,style:void 0}),Eh(j0,{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 Ih}from"react/jsx-runtime";var Ph={},UP={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"}},Rh=({feature:r,children:e,style:t,onChange:n})=>Ih("div",{className:`LayoutBox layout-${r} layout-outer`,children:[Ih("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)})})]}),Ih("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)})})})]}),XY={margin:!0,marginTop:!0,marginRight:!0,marginBottom:!0,marginLeft:!0},ZY={padding:!0,paddingTop:!0,paddingRight:!0,paddingBottom:!0,paddingLeft:!0},eX={border:!0,borderColor:!0,borderWidth:!0,borderTopWidth:!0,borderRightWidth:!0,borderBottomWidth:!0,borderLeftWidth:!0},Jl="(\\d+)(?:px)?",GP=`^(?:${Jl}(?:\\s${Jl}(?:\\s${Jl}(?:\\s${Jl})?)?)?)$`,J0=new RegExp(GP),qP=/^(?:(\d+)(?:px)\ssolid\s([a-zA-Z,0-9().]+))$/,K0=({height:r,managedStyle:e,onChange:t,style:n,width:o})=>{let i=Q0(e),s=(w,x,S)=>{let b=parseInt(S||"0",10),C=UP[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:g=0,paddingBottom:y=0,paddingLeft:v=0}=i;return Le("div",{className:"LayoutConfigurator",style:{width:o,height:r,...n},children:Le(Rh,{feature:"margin",style:{top:l,right:a,bottom:c,left:u},onChange:s,children:Le(Rh,{feature:"border",style:{top:h,right:f,bottom:d,left:p},onChange:s,children:Le(Rh,{feature:"padding",style:{top:m,right:g,bottom:y,left:v},onChange:s,children:Le("div",{className:"layout-content"})})})})})};function tX(r=Ph,e=Ph){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=J0.exec(t);if(d===null)console.error(`Invalid css value for margin '${t}'`);else{let[,p,m,g,y]=d,v=p&&m&&g;v&&y?(f.marginTop=parseInt(p,10),f.marginRight=parseInt(m,10),f.marginBottom=parseInt(g,10),f.marginLeft=parseInt(y,10)):v?(f.marginTop=parseInt(p,10),f.marginRight=f.marginLeft=parseInt(m,10),f.marginBottom=parseInt(g,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=J0.exec(l);if(d===null)console.error(`Invalid css value for padding '${l}'`);else{let[,p,m,g,y]=d,v=p&&m&&g;v&&y?(f.paddingTop=parseInt(p,10),f.paddingRight=parseInt(m,10),f.paddingBottom=parseInt(g,10),f.paddingLeft=parseInt(y,10)):v?(f.paddingTop=parseInt(p,10),f.paddingRight=f.paddingLeft=parseInt(m,10),f.paddingBottom=parseInt(g,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),Q0(f,e)}function Q0(r=Ph){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:g,paddingRight:y,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=qP.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 KP from"react";import jP from"classnames";import{Tree as JP}from"@vuu-ui/vuu-ui-controls";import{jsx as Y0}from"react/jsx-runtime";var QP="hwLayoutTreeViewer",X0=(r,e="0")=>({label:K(r),path:e,childNodes:KP.Children.map(r.props.children,(t,n)=>X0(t,e?`${e}.${n}`:`${n}`))}),j0=({layout:r,onSelect:e,style:t})=>{let n=[X0(r)],o=(i,[{path:s}])=>{e(s)};return Y0("div",{className:jP(QP),style:t,children:Y0(JP,{source:n,groupSelection:"single",onSelectionChange:o})})};export{Wn as Action,eX as BORDER_STYLES,ta as Component,Fn as ComponentRegistry,$Y as ConfigWrapper,Uh as DockLayout,ma as Draggable,Co as DraggableLayout,Li as Drawer,cf as DropMenu,pn as DropTarget,Io as Flexbox,bd as FlexboxLayout,Oa as FluidGrid,Id as FluidGridLayout,Hd as Header,p2 as HeightOnly,Re as LayoutActionType,K0 as LayoutConfigurator,Cw as LayoutProvider,Oo as LayoutProviderContext,ZN as LayoutProviderVersion,j0 as LayoutTreeViewer,Sl as LocalLayoutPersistenceManager,XY as MARGIN_STYLES,yJ as MeasuredContainer,gh as NO_WRAPPED_ITEMS,M0 as OverflowContainer,ZY as PADDING_STYLES,Kb as Palette,dh as PaletteItem,Ui as Placeholder,zl as Stack,D0 as StackLayout,aT as Toolbar,qn as View,ss as ViewContext,wd as WidthHeight,m2 as WidthOnly,tX as XXXnormalizeStyles,iO as applyLayout,Do as applyLayoutProps,m0 as applyOverflowClassToWrappedItems,wr as asReactElements,Uf as componentToJson,af as computeMenuPosition,kx as containerOf,x0 as correctForWrappedHighPriorityItems,b0 as correctForWrappedOverflowIndicator,xa as createFlexbox,Ft as createPlaceHolder,Bo as defaultLayout,oa as expandFlex,T2 as extractResponsiveProps,Yt as findTarget,Te as followPath,Jh as followPathToComponent,Qt as followPathToParent,Mx as getChild,Gh as getChildProp,_I as getElementsMarkedAsWrapped,If as getFlexDimensions,ba as getFlexOrIntrinsicStyle,ya as getFlexStyle,at as getIntrinsicSize,Wf as getManagedDimension,Ei as getNonWrappedAndWrappedItems,Bf as getPersistentState,q as getProp,_ as getProps,Hf as hasPersistentState,Pf as hasUnboundedFlexStyle,y0 as highPriorityItemsHaveWrappedButShouldNotHave,ca as identifyDropTarget,IO as isApplicationLevelChange,ze as isContainer,Bh as isLayoutComponent,PO as isLayoutLevelChange,Vw as isResponsiveAttribute,fL as isTabstrip,DD as isTypeOf,hx as isView,Mr as layoutFromJson,ud as layoutReducer,$f as layoutToJSON,HI as markElementAsWrapped,BD as nextLeaf,Mt as nextStep,g0 as overflowIndicatorHasWrappedButShouldNotHave,HD as previousLeaf,Sa as processLayoutElement,ge as registerComponent,S0 as removeOverflowIndicatorIfNoLongerNeeded,Ee as resetPath,vd as resizeObserver,jh as resolveJSONPath,na as resolvePath,zv as serializeProps,_f as setPersistentState,zD as setRef,NI as sortByScreenOrder,yh as switchWrappedItemIntoView,K as typeOf,WI as unmarkItemsWhichAreNoLongerWrapped,kd as useBreakpoints,Sr as useId,Wj as useLayoutContextMenuItems,gd as useLayoutCreateNewChild,Xh as useLayoutEffectSkipFirst,ut as useLayoutProviderDispatch,Tw as useLayoutProviderVersion,h0 as useMeasuredContainer,kr as usePersistentState,rs as useResizeObserver,is as useViewActionDispatcher,CV as useViewContext,Vd as useViewDispatch,cF as warningLayout,ko as wrapIntrinsicSizeComponentWithFlexbox};
|
|
20
240
|
//# sourceMappingURL=index.js.map
|