@malloy-publisher/app 0.4.1 → 0.5.1
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/dist/api-doc.yaml +158 -7
- package/dist/assets/{EnvironmentPage-BW0WDIHv.js → EnvironmentPage-B02geyxh.js} +1 -1
- package/dist/assets/{HomePage-Dg3KqJ6Q.js → HomePage-BdKzZEto.js} +1 -1
- package/dist/assets/{LightMode-CWfnd7K7.js → LightMode-BRAs1k98.js} +1 -1
- package/dist/assets/{MainPage-DDnYfzIk.js → MainPage-D9XZbGvk.js} +2 -2
- package/dist/assets/ModelPage-B-U47DzF.js +2 -0
- package/dist/assets/PackagePage-CDp9A3_k.js +1 -0
- package/dist/assets/{RenderedResult-CvrmYyr5.es-El82-Fnv.js → RenderedResult-CTD2Ej2S.es-BZsZAiwo.js} +24 -4
- package/dist/assets/{RouteError-3jz4UdKd.js → RouteError-CSsLG99c.js} +1 -1
- package/dist/assets/{ThemeEditorPage-JOWkUiHa.js → ThemeEditorPage-C4u5l49i.js} +1 -1
- package/dist/assets/{ToggleButtonGroup-CmtgJ1bB.js → ToggleButtonGroup-IBhUYkv_.js} +1 -1
- package/dist/assets/{index-9jIrTEvL.js → index--DAcpR5Y.js} +1 -1
- package/dist/assets/{index-DP4T7js_.js → index-BKNRDF5y.js} +1 -1
- package/dist/assets/{index-CqxPodI3.js → index-Bd7WYNw_.js} +92 -92
- package/dist/assets/{index-CYhW8lq5.js → index-CshLRozl.js} +1 -1
- package/dist/assets/{index-BU0_UiMu.js → index-DOXSuS-a.js} +1 -1
- package/dist/assets/index.es-Bj77sE9l.js +111 -0
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/assets/ModelPage-DOACbTsK.js +0 -2
- package/dist/assets/PackagePage-4tYaVCFt.js +0 -1
- package/dist/assets/index.es-DcmGg13s.js +0 -106
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-9jIrTEvL.js","assets/index-CqxPodI3.js","assets/index-DUqldpo0.css","assets/index-w_0OQJgZ.js","assets/index-CRAwrhYM.js","assets/index-BU0_UiMu.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as S,aM as su,aN as vn,j as m,aa as le,aO as ou,at as cn,L as de,aP as au,U as hl,ar as lu,aQ as cu,aR as Br,aS as da,aT as du,a4 as fl,a0 as uu,ay as ge,a5 as pl,aU as gl,a8 as ua,aV as us,aW as hu,aX as Zr,F as tt,aY as ml,aZ as Kt,a_ as hs,G as xn,I as fs,N as oo,T as Q,a$ as fu,b0 as pu,ax as Ai,am as De,aq as yt,b1 as ps,an as vl,Y as bl,b2 as gu,b3 as mu,O as vu,W as bu,b4 as yu,b5 as xu,b6 as wu,b7 as ku,b8 as Su,b9 as yl,ba as gs,bb as ms,bc as ju,bd as $u,aI as Ou}from"./index-CqxPodI3.js";import{T as Cu,a as ha}from"./ToggleButtonGroup-CmtgJ1bB.js";var fa={},Mu=Symbol.for("preact-signals");function Di(){if(xt>1)xt--;else{var e,t=!1;for((function(){var i=hi;for(hi=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();hr!==void 0;){var n=hr;for(hr=void 0,ui++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&wl(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(ui=0,xt--,t)throw e}}function oe(e){if(xt>0)return e();vs=++Eu,xt++;try{return e()}finally{Di()}}var ur,ne=void 0;function q(e){var t=ne,n=ur;ne=void 0,ur=void 0;try{return e()}finally{ne=t,ur=n}}var hr=void 0,xt=0,ui=0,Eu=0,vs=0,hi=void 0,fi=0;function xl(e){if(ne!==void 0){var t=e.n;if(t===void 0||t.t!==ne)return t={i:0,S:e,p:ne.s,n:void 0,t:ne,e:void 0,x:void 0,r:t},ne.s!==void 0&&(ne.s.n=t),ne.s=t,e.n=t,32&ne.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ne.s,t.n=void 0,ne.s.n=t,ne.s=t),t}}function Ie(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Ie.prototype.brand=Mu;Ie.prototype.h=function(){return!0};Ie.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:q(function(){var r;(r=t.W)==null||r.call(t)}))};Ie.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&q(function(){var i;(i=t.Z)==null||i.call(t)}))}};Ie.prototype.subscribe=function(e){var t=this;return nt(function(){var n=t.value;q(function(){return e(n)})},{name:"sub"})};Ie.prototype.valueOf=function(){return this.value};Ie.prototype.toString=function(){return this.value+""};Ie.prototype.toJSON=function(){return this.value};Ie.prototype.peek=function(){var e=this;return q(function(){return e.value})};Object.defineProperty(Ie.prototype,"value",{get:function(){var e=xl(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ui>100)throw new Error("Cycle detected");(function(n){xt!==0&&ui===0&&n.l!==vs&&(n.l=vs,hi={S:n,v:n.v,i:n.i,o:hi})})(this),this.v=e,this.i++,fi++,xt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Di()}}}});function Dn(e,t){return new Ie(e,t)}function wl(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function kl(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Sl(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Gt(e,t){Ie.call(this,void 0,t),this.x=e,this.s=void 0,this.g=fi-1,this.f=4}Gt.prototype=new Ie;Gt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===fi))return!0;if(this.g=fi,this.f|=1,this.i>0&&!wl(this))return this.f&=-2,!0;var e=ne;try{kl(this),ne=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ne=e,Sl(this),this.f&=-2,!0};Gt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Ie.prototype.S.call(this,e)};Gt.prototype.U=function(e){if(this.t!==void 0&&(Ie.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Gt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Gt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=xl(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function pa(e,t){return new Gt(e,t)}function jl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){xt++;var n=ne;ne=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,ao(e),r}finally{ne=n,Di()}}}function ao(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,jl(e)}function Au(e){if(ne!==this)throw new Error("Out-of-order effect");Sl(this),ne=e,this.f&=-2,8&this.f&&ao(this),Di()}function Tn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,ur&&ur.push(this)}Tn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Tn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,jl(this),kl(this),xt++;var e=ne;return ne=this,Au.bind(this,e)};Tn.prototype.N=function(){2&this.f||(this.f|=2,this.u=hr,hr=this)};Tn.prototype.d=function(){this.f|=8,1&this.f||ao(this)};Tn.prototype.dispose=function(){this.d()};function nt(e,t){var n=new Tn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Du=Object.create,lo=Object.defineProperty,Tu=Object.defineProperties,Pu=Object.getOwnPropertyDescriptor,Ru=Object.getOwnPropertyDescriptors,ga=Object.getOwnPropertySymbols,Wu=Object.prototype.hasOwnProperty,Iu=Object.prototype.propertyIsEnumerable,zu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Pn=e=>{throw TypeError(e)},bs=(e,t,n)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Lu=(e,t)=>{for(var n in t||(t={}))Wu.call(t,n)&&bs(e,n,t[n]);if(ga)for(var n of ga(t))Iu.call(t,n)&&bs(e,n,t[n]);return e},Fu=(e,t)=>Tu(e,Ru(t)),ma=(e,t)=>lo(e,"name",{value:t,configurable:!0}),Nu=e=>{var t;return[,,,Du((t=void 0)!=null?t:null)]},$l=["class","method","getter","setter","accessor","field","value","get","set"],Gn=e=>e!==void 0&&typeof e!="function"?Pn("Function expected"):e,_u=(e,t,n,r,i)=>({kind:$l[e],name:t,metadata:r,addInitializer:s=>n._?Pn("Already initialized"):i.push(Gn(s||null))}),Ol=(e,t)=>bs(t,zu("metadata"),e[3]),Rt=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Rn=(e,t,n,r,i,s)=>{var o,a,l,c,u,d=t&7,p=!!(t&8),h=!!(t&16),g=d>3?e.length+1:d?p?1:2:0,b=$l[d+5],w=d>3&&(e[g-1]=[]),v=e[g]||(e[g]=[]),f=d&&(!h&&!p&&(i=i.prototype),d<5&&(d>3||!h)&&Pu(d<4?i:{get[n](){return Ze(this,s)},set[n](x){return Ct(this,s,x)}},n));d?h&&d<4&&ma(s,(d>2?"set ":d>1?"get ":"")+n):ma(i,n);for(var y=r.length-1;y>=0;y--)c=_u(d,n,l={},e[3],v),d&&(c.static=p,c.private=h,u=c.access={has:h?x=>qu(i,x):x=>n in x},d^3&&(u.get=h?x=>(d^1?Ze:Hu)(x,i,d^4?s:f.get):x=>x[n]),d>2&&(u.set=h?(x,k)=>Ct(x,i,k,d^4?s:f.set):(x,k)=>x[n]=k)),a=(0,r[y])(d?d<4?h?s:f[b]:d>4?void 0:{get:f.get,set:f.set}:i,c),l._=1,d^4||a===void 0?Gn(a)&&(d>4?w.unshift(a):d?h?s=a:f[b]=a:i=a):typeof a!="object"||a===null?Pn("Object expected"):(Gn(o=a.get)&&(f.get=o),Gn(o=a.set)&&(f.set=o),Gn(o=a.init)&&w.unshift(o));return d||Ol(e,i),f&&lo(i,n,f),h?d^4?s:f:i},co=(e,t,n)=>t.has(e)||Pn("Cannot "+n),qu=(e,t)=>Object(t)!==t?Pn('Cannot use the "in" operator on this value'):e.has(t),Ze=(e,t,n)=>(co(e,t,"read from private field"),n?n.call(e):t.get(e)),Bn=(e,t,n)=>t.has(e)?Pn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ct=(e,t,n,r)=>(co(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Hu=(e,t,n)=>(co(e,t,"access private method"),n);function ys(e,t){if(t){let n;return pa(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return pa(e)}function ot(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((n,r)=>!ot(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!ot(e[i],t[i]))}return!1}function H({get:e},t){return{init(n){return Dn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function ce(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=ys(e.bind(this)),n.set(this,r)),r.value}}function Vi(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),i=Object.getOwnPropertyDescriptor(r,n.name);i&&Object.defineProperty(r,n.name,Fu(Lu({},i),{enumerable:e}))})}}function Cr(...e){const t=e.map(n=>nt(n));return()=>t.forEach(n=>n())}var Cl,Ml,El,Al,Dl,Tl,Pe,uo,Ki,xs,ws,Ae,ho,Gi,Pl,ks,fo,Bi,Ss,js;Tl=[H],Dl=[H],Al=[H],El=[Vi()],Ml=[Vi()],Cl=[Vi()];var Bt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Rt(Pe,5,this),Bn(this,Ae),Bn(this,uo,Rt(Pe,8,this)),Rt(Pe,11,this),Bn(this,ho,Rt(Pe,12,this)),Rt(Pe,15,this),Bn(this,fo,Rt(Pe,16,this)),Rt(Pe,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Ze(this,Ae,Ss)}get initial(){return Ze(this,Ae,xs)}get previous(){return Ze(this,Ae,Pl)}set current(e){const t=q(()=>Ze(this,Ae,Ss));e&&t&&this.equals(t,e)||oe(()=>{Ze(this,Ae,xs)||Ct(this,Ae,e,ws),Ct(this,Ae,t,ks),Ct(this,Ae,e,js)})}reset(e=this.defaultValue){oe(()=>{Ct(this,Ae,void 0,ks),Ct(this,Ae,e,ws),Ct(this,Ae,e,js)})}};Pe=Nu();uo=new WeakMap;Ae=new WeakSet;ho=new WeakMap;fo=new WeakMap;Ki=Rn(Pe,20,"#initial",Tl,Ae,uo),xs=Ki.get,ws=Ki.set;Gi=Rn(Pe,20,"#previous",Dl,Ae,ho),Pl=Gi.get,ks=Gi.set;Bi=Rn(Pe,20,"#current",Al,Ae,fo),Ss=Bi.get,js=Bi.set;Rn(Pe,2,"current",El,Bt);Rn(Pe,2,"initial",Ml,Bt);Rn(Pe,2,"previous",Cl,Bt);Ol(Pe,Bt);function Zi(e){return q(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Wt,Uu=class{constructor(){Bn(this,Wt,new WeakMap)}get(e,t){var n;return e?(n=Ze(this,Wt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Ze(this,Wt).has(e)||Ze(this,Wt).set(e,new Map),(r=Ze(this,Wt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Ze(this,Wt).get(e))==null?void 0:t.clear():void 0}};Wt=new WeakMap;var Yu=Object.create,Rl=Object.defineProperty,Xu=Object.getOwnPropertyDescriptor,va=Object.getOwnPropertySymbols,Vu=Object.prototype.hasOwnProperty,Ku=Object.prototype.propertyIsEnumerable,Wl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ti=e=>{throw TypeError(e)},ba=Math.pow,$s=(e,t,n)=>t in e?Rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gu=(e,t)=>{for(var n in t||(t={}))Vu.call(t,n)&&$s(e,n,t[n]);if(va)for(var n of va(t))Ku.call(t,n)&&$s(e,n,t[n]);return e},Bu=e=>{var t;return[,,,Yu((t=e?.[Wl("metadata")])!=null?t:null)]},Il=["class","method","getter","setter","accessor","field","value","get","set"],zl=e=>e!==void 0&&typeof e!="function"?Ti("Function expected"):e,Zu=(e,t,n,r,i)=>({kind:Il[e],name:t,metadata:r,addInitializer:s=>n._?Ti("Already initialized"):i.push(zl(s||null))}),Ju=(e,t)=>$s(t,Wl("metadata"),e[3]),Qu=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},Ll=(e,t,n,r,i,s)=>{for(var o,a,l,c,u=t&7,d=!1,p=!1,h=2,g=Il[u+5],b=e[h]||(e[h]=[]),w=(i=i.prototype,Xu(i,n)),v=r.length-1;v>=0;v--)l=Zu(u,n,a={},e[3],b),l.static=d,l.private=p,c=l.access={has:f=>n in f},c.get=f=>f[n],o=(0,r[v])(w[g],l),a._=1,zl(o)&&(w[g]=o);return w&&Rl(i,n,w),i},Fl=(e,t,n)=>t.has(e)||Ti("Cannot "+n),eh=(e,t,n)=>(Fl(e,t,"read from private field"),t.get(e)),th=(e,t,n)=>t.has(e)?Ti("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),nh=(e,t,n,r)=>(Fl(e,t,"write to private field"),t.set(e,n),n),Je=class Os{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Os(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Os(t,n)}},ht=class It{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,l=new It(i+t,r+n,s,o);return l.scale=Gu({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new Je((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof It))return!1;const{left:n,top:r,width:i,height:s}=this;return n===t.left&&r===t.top&&i===t.width&&s===t.height}containsPoint(t){const{top:n,left:r,bottom:i,right:s}=this;return n<=t.y&&t.y<=i&&r<=t.x&&t.x<=s}intersectionArea(t){return t instanceof It?rh(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new It(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],l=o==="x"?s.left:s.top,c=o==="x"?s.width:s.height;return a=="start"?l:a=="end"?l+c:l+c/2};return Je.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return It.from(t).intersectionRatio(It.from(n))}};function rh(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;return r<i&&n<s?o*a:0}var Nl,_l,Cs,Jr,Mr,Pi=class extends(Cs=Bt,_l=[ce],Nl=[ce],Cs){constructor(e){const t=Je.from(e);super(t,(n,r)=>Je.equals(n,r)),Qu(Mr,5,this),th(this,Jr,0),this.velocity={x:0,y:0}}get delta(){return Je.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=Je.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-eh(this,Jr),o=a=>Math.round(a/s*100);oe(()=>{nh(this,Jr,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Je.from(e)),this.velocity={x:0,y:0}}};Mr=Bu(Cs);Jr=new WeakMap;Ll(Mr,2,"delta",_l,Pi);Ll(Mr,2,"direction",Nl,Pi);Ju(Mr,Pi);function Ms({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(ba(r,2)+ba(i,2))>n:"x"in n&&"y"in n?r>n.x&&i>n.y:"x"in n?r>n.x:"y"in n?i>n.y:!1}var ql=(e=>(e.Horizontal="x",e.Vertical="y",e))(ql||{}),Hl=Object.values(ql),ih=Object.create,po=Object.defineProperty,sh=Object.defineProperties,oh=Object.getOwnPropertyDescriptor,ah=Object.getOwnPropertyDescriptors,pi=Object.getOwnPropertySymbols,Ul=Object.prototype.hasOwnProperty,Yl=Object.prototype.propertyIsEnumerable,Xl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Wn=e=>{throw TypeError(e)},Es=(e,t,n)=>t in e?po(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,go=(e,t)=>{for(var n in t||(t={}))Ul.call(t,n)&&Es(e,n,t[n]);if(pi)for(var n of pi(t))Yl.call(t,n)&&Es(e,n,t[n]);return e},mo=(e,t)=>sh(e,ah(t)),ya=(e,t)=>po(e,"name",{value:t,configurable:!0}),Vl=(e,t)=>{var n={};for(var r in e)Ul.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&pi)for(var r of pi(e))t.indexOf(r)<0&&Yl.call(e,r)&&(n[r]=e[r]);return n},In=e=>{var t;return[,,,ih((t=e?.[Xl("metadata")])!=null?t:null)]},Kl=["class","method","getter","setter","accessor","field","value","get","set"],Zn=e=>e!==void 0&&typeof e!="function"?Wn("Function expected"):e,lh=(e,t,n,r,i)=>({kind:Kl[e],name:t,metadata:r,addInitializer:s=>n._?Wn("Already initialized"):i.push(Zn(s||null))}),Zt=(e,t)=>Es(t,Xl("metadata"),e[3]),F=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},U=(e,t,n,r,i,s)=>{var o,a,l,c,u,d=t&7,p=!!(t&8),h=!!(t&16),g=d>3?e.length+1:d?p?1:2:0,b=Kl[d+5],w=d>3&&(e[g-1]=[]),v=e[g]||(e[g]=[]),f=d&&(!h&&!p&&(i=i.prototype),d<5&&(d>3||!h)&&oh(d<4?i:{get[n](){return ae(this,s)},set[n](x){return Xe(this,s,x)}},n));d?h&&d<4&&ya(s,(d>2?"set ":d>1?"get ":"")+n):ya(i,n);for(var y=r.length-1;y>=0;y--)c=lh(d,n,l={},e[3],v),d&&(c.static=p,c.private=h,u=c.access={has:h?x=>ch(i,x):x=>n in x},d^3&&(u.get=h?x=>(d^1?ae:Gl)(x,i,d^4?s:f.get):x=>x[n]),d>2&&(u.set=h?(x,k)=>Xe(x,i,k,d^4?s:f.set):(x,k)=>x[n]=k)),a=(0,r[y])(d?d<4?h?s:f[b]:d>4?void 0:{get:f.get,set:f.set}:i,c),l._=1,d^4||a===void 0?Zn(a)&&(d>4?w.unshift(a):d?h?s=a:f[b]=a:i=a):typeof a!="object"||a===null?Wn("Object expected"):(Zn(o=a.get)&&(f.get=o),Zn(o=a.set)&&(f.set=o),Zn(o=a.init)&&w.unshift(o));return d||Zt(e,i),f&&po(i,n,f),h?d^4?s:f:i},vo=(e,t,n)=>t.has(e)||Wn("Cannot "+n),ch=(e,t)=>Object(t)!==t?Wn('Cannot use the "in" operator on this value'):e.has(t),ae=(e,t,n)=>(vo(e,t,"read from private field"),n?n.call(e):t.get(e)),X=(e,t,n)=>t.has(e)?Wn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xe=(e,t,n,r)=>(vo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Gl=(e,t,n)=>(vo(e,t,"access private method"),n);function Bl(e,t){return{plugin:e,options:t}}function Er(e){return t=>Bl(e,t)}function br(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Zl,yr,bo,Qr;Zl=[H];var Te=class{constructor(e,t){this.manager=e,this.options=t,X(this,bo,F(yr,8,this,!1)),F(yr,11,this),X(this,Qr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return q(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=nt(e.bind(this));return ae(this,Qr).add(t),t}destroy(){ae(this,Qr).forEach(e=>e())}static configure(e){return Bl(this,e)}};yr=In(null);bo=new WeakMap;Qr=new WeakMap;U(yr,4,"disabled",Zl,Te,bo);Zt(yr,Te);var Ar=class extends Te{},ei,Ji=class{constructor(e){this.manager=e,this.instances=new Map,X(this,ei,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(br).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of ae(this,ei))if(!n.includes(r)){if(r.prototype instanceof Ar)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);Xe(this,ei,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};ei=new WeakMap;function dh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Lr=[],dn,un,uh=class extends Te{constructor(e){super(e),X(this,dn),X(this,un),this.computeCollisions=this.computeCollisions.bind(this),Xe(this,un,Dn(Lr)),this.destroy=Cr(()=>{const t=this.computeCollisions(),n=q(()=>this.manager.dragOperation.position.current);if(t!==Lr){const r=ae(this,dn);if(Xe(this,dn,n),r&&n.x==r.x&&n.y==r.y)return}else Xe(this,dn,void 0);ae(this,un).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){q(()=>{e?ae(this,un).value=this.computeCollisions():Xe(this,dn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Lr;const a=[],l=[];for(const c of e??n.droppables){if(c.disabled||i&&!c.accepts(i))continue;const u=t??c.collisionDetector;if(!u)continue;l.push(c),c.shape;const d=q(()=>u({droppable:c,dragOperation:r}));d&&(c.collisionPriority!=null&&(d.priority=c.collisionPriority),a.push(d))}return l.length===0?Lr:(a.sort(dh),a)}get collisions(){return ae(this,un).value}};dn=new WeakMap;un=new WeakMap;var Jl,Ql,ec,yo,tc,at,xo,bn,wo,ko;ec=[H],Ql=[H],Jl=[H];var kt=class zt{constructor(t,n){X(this,xo,F(at,8,this)),F(at,11,this),X(this,bn),X(this,wo,F(at,12,this)),F(at,15,this),X(this,ko,F(at,16,this)),F(at,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let l=i;Xe(this,bn,Dn(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var c;return[()=>{const{id:u,manager:d}=this;if(u!==l)return l=u,d?.registry.register(this),()=>d?.registry.unregister(this)},...(c=r?.())!=null?c:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=ae(this,bn).value;return(n=(t=zt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=zt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:ae(this,bn).peek();t!==i&&(zt.pendingIdChanges||(zt.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return Gl(s=zt,yo,tc).call(s)})),zt.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};at=In(null);yo=new WeakSet;tc=function(){const e=kt.pendingIdChanges;kt.pendingIdChanges=null,e&&oe(()=>{for(const[t,n]of e)ae(t,bn).value=n})};xo=new WeakMap;bn=new WeakMap;wo=new WeakMap;ko=new WeakMap;U(at,4,"manager",ec,kt,xo);U(at,4,"data",Ql,kt,wo);U(at,4,"disabled",Jl,kt,ko);X(kt,yo);Zt(at,kt);kt.pendingIdChanges=null;var Ri=kt,xa=class{constructor(){this.map=Dn(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=Cr(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},nc,rc,ic,sc,oc,ac,As,Re,So,jo,$o,ft=class extends(As=Ri,ac=[H],oc=[H],sc=[H],ic=[ce],rc=[ce],nc=[ce],As){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,l=Vl(n,["modifiers","type","sensors","plugins","effects"]);super(mo(go({},l),{effects:()=>{var c;return[...(c=a?.())!=null?c:[],()=>{const{manager:u,plugins:d}=this;if(!(!u||!d))for(const p of d){const{plugin:h}=br(p);u.registry.plugins.register(h)}}]}}),t),F(Re,5,this),X(this,So,F(Re,8,this)),F(Re,11,this),X(this,jo,F(Re,12,this)),F(Re,15,this),X(this,$o,F(Re,16,this,this.isDragSource?"dragging":"idle")),F(Re,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=l.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=br(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.source)==null?void 0:t.id)===this.id}};Re=In(As);So=new WeakMap;jo=new WeakMap;$o=new WeakMap;U(Re,4,"type",ac,ft,So);U(Re,4,"modifiers",oc,ft,jo);U(Re,4,"status",sc,ft,$o);U(Re,2,"isDropping",ic,ft);U(Re,2,"isDragging",rc,ft);U(Re,2,"isDragSource",nc,ft);Zt(Re,ft);var lc,cc,dc,uc,hc,fc,Ds,pe,Oo,Co,Mo,Eo,Ao,pt=class extends(Ds=Ri,fc=[H],hc=[H],uc=[H],dc=[H],cc=[H],lc=[ce],Ds){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=Vl(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),F(pe,5,this),X(this,Oo,F(pe,8,this)),F(pe,11,this),X(this,Co,F(pe,12,this)),F(pe,15,this),X(this,Mo,F(pe,16,this)),F(pe,19,this),X(this,Eo,F(pe,20,this)),F(pe,23,this),X(this,Ao,F(pe,24,this)),F(pe,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=s,this.type=o}accepts(e){const{accept:t}=this;return t?typeof t=="function"?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.target)==null?void 0:t.id)===this.id}};pe=In(Ds);Oo=new WeakMap;Co=new WeakMap;Mo=new WeakMap;Eo=new WeakMap;Ao=new WeakMap;U(pe,4,"accept",fc,pt,Oo);U(pe,4,"type",hc,pt,Co);U(pe,4,"collisionDetector",uc,pt,Mo);U(pe,4,"collisionPriority",dc,pt,Eo);U(pe,4,"shape",cc,pt,Ao);U(pe,2,"isDropTarget",lc,pt);Zt(pe,pt);var hh=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const i of r)i(...t)}},fh=class extends hh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ti(e,t=!0){let n=!1;return mo(go({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var ph=class extends Ar{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=Cr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Ri.pendingIdChanges)return;const o=ti({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;q(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},zn=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(zn||{}),Ln=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Ln||{}),pc,gc,mc,vc,bc,yc,xc,et,Do;xc=[H],yc=[ce],bc=[ce],vc=[ce],mc=[ce],gc=[ce],pc=[ce];var St=class{constructor(){F(et,5,this),X(this,Do,F(et,8,this,"idle")),F(et,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};et=In(null);Do=new WeakMap;U(et,4,"value",xc,St,Do);U(et,2,"current",yc,St);U(et,2,"idle",bc,St);U(et,2,"initializing",vc,St);U(et,2,"initialized",mc,St);U(et,2,"dragging",gc,St);U(et,2,"dropped",pc,St);Zt(et,St);var gh=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return q(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=ti({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return q(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const n=new AbortController,{event:r,coordinates:i}=e;oe(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=ti({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",s),s.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set("initializing"),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;const{status:o}=t;o.current==="initializing"&&oe(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return q(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=ti({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,c,u,d;if(o.defaultPrevented)return;const p=(d=e.to)!=null?d:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((u=(c=e.by)==null?void 0:c.y)!=null?u:0)};r.position.current=p})})}stop(e={}){return q(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const l={resume:()=>{},abort:()=>{}};return s=new Promise((c,u)=>{l.resume=c,l.abort=u}),l};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=q(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),c=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,d=nt(()=>{u?.status==="idle"&&(d(),c())})}else this.manager.renderer.rendering.then(c)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),s?s.then(a).catch(()=>r.reset()):a()})}},jn=class extends Te{constructor(e,t){super(e,t),this.manager=e,this.options=t}},mh=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},ni,wc=class{constructor(e){this.options=e,X(this,ni)}set controller(e){Xe(this,ni,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=ae(this,ni))==null||t.activate(e)}};ni=new WeakMap;var wa=class extends Te{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},vh=class{constructor(e){this.draggables=new xa,this.droppables=new xa,this.plugins=new Ji(e),this.sensors=new Ji(e),this.modifiers=new Ji(e)}register(e,t){if(e instanceof ft)return this.draggables.register(e.id,e);if(e instanceof pt)return this.droppables.register(e.id,e);if(e.prototype instanceof wa)return this.modifiers.register(e,t);if(e.prototype instanceof jn)return this.sensors.register(e,t);if(e.prototype instanceof Te)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Ri)return e instanceof ft?this.draggables.unregister(e.id,e):e instanceof pt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof wa)return this.modifiers.unregister(e);if(e.prototype instanceof jn)return this.sensors.unregister(e);if(e.prototype instanceof Te)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},kc,Sc,jc,$c,Oc,Cc,Mc,Ec,Ac,Jn,ri,hn,se,To,Po,Ro,Wo,Io,Qn;Ac=[ce],Ec=[H],Mc=[H],Cc=[H],Oc=[H],$c=[H],jc=[ce],Sc=[ce],kc=[ce];var ct=class{constructor(e){F(se,5,this),X(this,Jn),X(this,ri),X(this,hn,new Bt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new St,X(this,To,F(se,8,this,!1)),F(se,11,this),X(this,Po,F(se,12,this,null)),F(se,15,this),X(this,Ro,F(se,16,this,null)),F(se,19,this),X(this,Wo,F(se,20,this,null)),F(se,23,this),X(this,Io,F(se,24,this,[])),F(se,27,this),this.position=new Pi({x:0,y:0}),X(this,Qn,{x:0,y:0}),Xe(this,Jn,e)}get shape(){const{current:e,initial:t,previous:n}=ae(this,hn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?ae(this,hn).current=e:ae(this,hn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=ae(this,Jn).registry.draggables.get(t);return n&&Xe(this,ri,n),(e=n??ae(this,ri))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=ae(this,Jn).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(mo(go({},this.snapshot()),{transform:n}));return Xe(this,Qn,n),n}snapshot(){return q(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:ae(this,Qn),shape:this.shape?Zi(this.shape):null,position:Zi(this.position),status:Zi(this.status),canceled:this.canceled}))}reset(){oe(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,ae(this,hn).reset(),this.position.reset({x:0,y:0}),Xe(this,Qn,{x:0,y:0}),this.modifiers=[]})}};se=In(null);Jn=new WeakMap;ri=new WeakMap;hn=new WeakMap;To=new WeakMap;Po=new WeakMap;Ro=new WeakMap;Wo=new WeakMap;Io=new WeakMap;Qn=new WeakMap;U(se,2,"shape",Ac,ct);U(se,4,"canceled",Ec,ct,To);U(se,4,"activatorEvent",Mc,ct,Po);U(se,4,"sourceIdentifier",Cc,ct,Ro);U(se,4,"targetIdentifier",Oc,ct,Wo);U(se,4,"modifiers",$c,ct,Io);U(se,2,"source",jc,ct);U(se,2,"target",Sc,ct);U(se,2,"transform",kc,ct);Zt(se,ct);var bh={get rendering(){return Promise.resolve()}};function lt(e,t){return typeof e=="function"?e(t):e??t}var yh=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(d=>d.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=lt(n.plugins,[]),i=lt(n.sensors,[]),s=lt(n.modifiers,[]),o=(t=n.renderer)!=null?t:bh,a=new fh(this),l=new vh(this);this.registry=l,this.monitor=a,this.renderer=o,this.actions=new gh(this),this.dragOperation=new ct(this),this.collisionObserver=new uh(this),this.plugins=[ph,...r],this.modifiers=s,this.sensors=i;const{destroy:c}=this,u=Cr(()=>{var d,p,h;const g=q(()=>this.dragOperation.modifiers),b=this.modifiers;for(const w of g)b.includes(w)||w.destroy();this.dragOperation.modifiers=(h=(p=(d=this.dragOperation.source)==null?void 0:d.modifiers)==null?void 0:p.map(w=>{const{plugin:v,options:f}=br(w);return new v(this,f)}))!=null?h:b});this.destroy=()=>{u(),c()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Dc=e=>{throw TypeError(e)},zo=(e,t,n)=>t.has(e)||Dc("Cannot "+n),L=(e,t,n)=>(zo(e,t,"read from private field"),t.get(e)),Ne=(e,t,n)=>t.has(e)?Dc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ye=(e,t,n,r)=>(zo(e,t,"write to private field"),t.set(e,n),n),Tc=(e,t,n)=>(zo(e,t,"access private method"),n);function Wi(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Pc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(Wi(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function Ii(e){const{width:t,height:n,top:r,left:i,bottom:s,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:s,right:o}}function Lo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Dr(e){return"nodeType"in e}function Ve(e){var t,n,r;return e?Lo(e)?e:Dr(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function Fo(e){const{Document:t}=Ve(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Tt(e){return!e||Lo(e)?!1:e instanceof Ve(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Rc(e){return e instanceof Ve(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Fn(e){return e?Lo(e)?e.document:Dr(e)?Fo(e)?e:Tt(e)||Rc(e)?e.ownerDocument:document:document:document}function xh(e){var t,n,r,i;const{documentElement:s}=Fn(e),o=Ve(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,l=(n=o?.height)!=null?n:s.clientHeight,c=(r=o?.offsetTop)!=null?r:0,u=(i=o?.offsetLeft)!=null?i:0;return{top:c,left:u,right:u+a,bottom:c+l,width:a,height:l}}function wh(e,t){if(kh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function kh(e){return e.tagName==="DETAILS"}function xr(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let l=t;const{ownerDocument:c}=e,u=(r=c.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==c.documentElement;){if(!wh(d)){const y=d.getBoundingClientRect(),x=n*(y.bottom-y.top),k=n*(y.right-y.left),M=n*(y.bottom-y.top),$=n*(y.right-y.left);l={top:Math.max(l.top,y.top-x),right:Math.min(l.right,y.right+k),bottom:Math.min(l.bottom,y.bottom+M),left:Math.max(l.left,y.left-$),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const p=u.visualViewport,h=(i=p?.offsetTop)!=null?i:0,g=(s=p?.offsetLeft)!=null?s:0,b=(o=p?.width)!=null?o:u.innerWidth,w=(a=p?.height)!=null?a:u.innerHeight,v=n*w,f=n*b;return l={top:Math.max(l.top,h-v),right:Math.min(l.right,g+b+f),bottom:Math.min(l.bottom,h+w+v),left:Math.max(l.left,g-f),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function $n(e){return{x:e.clientX,y:e.clientY}}var Wc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ts(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(...Ts(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...Ts(i.document,t))}}catch{}return n}function No(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ic(){var e,t;const n=No()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function _o(e){return!e||!Dr(e)?!1:e instanceof Ve(e).ShadowRoot}function gi(e){if(e&&Dr(e)){let t=e.getRootNode();if(_o(t)||t instanceof Document)return t}return Fn(e)}function qo(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Sh(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,s)=>{const o=r[s];ka(i)&&ka(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Sa(i)&&Sa(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function ka(e){return"value"in e}function Sa(e){return e.tagName==="CANVAS"}function zc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(jh(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return zc(i,{x:t-s,y:n-o})}}return r}function jh(e){return e?.tagName==="IFRAME"}var Ps=new WeakMap;function $h(e){return e.closest(`
|
|
3
|
-
input:not([disabled]),
|
|
4
|
-
select:not([disabled]),
|
|
5
|
-
textarea:not([disabled]),
|
|
6
|
-
button:not([disabled]),
|
|
7
|
-
a[href],
|
|
8
|
-
[contenteditable]:not([contenteditable="false"])
|
|
9
|
-
`)}var Lc=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];for(const o of n)for(const a of r){const{type:l,listener:c,options:u}=a,d=[o,a];o.addEventListener(l,c,u),this.entries.add(d),i.push(d)}const s=this.entries;return function(){for(const o of i){const[a,{type:l,listener:c,options:u}]=o;a.removeEventListener(l,c,u),s.delete(o)}}}};function On(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Oh(e){const t=new Set;let n=On(e);for(;n;)t.add(n),n=On(n);return t}function Ch(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Fc(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=Ch(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function Mh(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function Eh(e,t=e.getBoundingClientRect()){const{width:n,height:r}=xr(e,t);return n>0&&r>0}var Ah=Wc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ii,Dh=class extends Ah{constructor(e){super(t=>{if(!L(this,ii)){Ye(this,ii,!0);return}e(t,this)}),Ne(this,ii,!1)}};ii=new WeakMap;var ja=Array.from({length:100},(e,t)=>t/100),Nc=75,Lt,mi,$t,Ft,er,$e,fr,tr,vi,_c,qc,Hc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ne(this,vi),this.disconnect=()=>{var s,o,a;Ye(this,fr,!0),(s=L(this,$t))==null||s.disconnect(),(o=L(this,Ft))==null||o.disconnect(),L(this,er).disconnect(),(a=L(this,$e))==null||a.remove()},Ne(this,Lt,!0),Ne(this,mi),Ne(this,$t),Ne(this,Ft),Ne(this,er),Ne(this,$e),Ne(this,fr,!1),Ne(this,tr,Fc(()=>{var s,o,a;const{element:l}=this;if((s=L(this,Ft))==null||s.disconnect(),L(this,fr)||!L(this,Lt)||!l.isConnected)return;const c=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:d}=(a=c.defaultView)!=null?a:window,p=l.getBoundingClientRect(),h=xr(l,p),{top:g,left:b,bottom:w,right:v}=h,f=-Math.floor(g),y=-Math.floor(b),x=-Math.floor(d-v),k=-Math.floor(u-w),M=`${f}px ${x}px ${k}px ${y}px`;this.boundingClientRect=p,Ye(this,Ft,new IntersectionObserver($=>{const[A]=$,{intersectionRect:T}=A;(A.intersectionRatio!==1?A.intersectionRatio:ht.intersectionRatio(T,xr(l)))!==1&&L(this,tr).call(this)},{threshold:ja,rootMargin:M,root:c})),L(this,Ft).observe(l),Tc(this,vi,_c).call(this)},Nc)),this.boundingClientRect=e.getBoundingClientRect(),Ye(this,Lt,Eh(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(Ye(this,$e,document.createElement("div")),L(this,$e).style.background="rgba(0,0,0,0.15)",L(this,$e).style.position="fixed",L(this,$e).style.pointerEvents="none",i.body.appendChild(L(this,$e))),Ye(this,er,new IntersectionObserver(s=>{var o,a;const l=s[s.length-1],{boundingClientRect:c,isIntersecting:u}=l,{width:d,height:p}=c,h=L(this,Lt);Ye(this,Lt,u),!(!d&&!p)&&(h&&!u?((o=L(this,Ft))==null||o.disconnect(),this.callback(null),(a=L(this,$t))==null||a.disconnect(),Ye(this,$t,void 0),L(this,$e)&&(L(this,$e).style.visibility="hidden")):L(this,tr).call(this),u&&!L(this,$t)&&(Ye(this,$t,new Dh(L(this,tr))),L(this,$t).observe(e)))},{threshold:ja,root:i})),L(this,Lt)&&!n.skipInitial&&this.callback(this.boundingClientRect),L(this,er).observe(e)}};Lt=new WeakMap;mi=new WeakMap;$t=new WeakMap;Ft=new WeakMap;er=new WeakMap;$e=new WeakMap;fr=new WeakMap;tr=new WeakMap;vi=new WeakSet;_c=function(){L(this,fr)||(Tc(this,vi,qc).call(this),!Mh(this.boundingClientRect,L(this,mi))&&(this.callback(this.boundingClientRect),Ye(this,mi,this.boundingClientRect)))};qc=function(){if(L(this,$e)){const{top:e,left:t,width:n,height:r}=xr(this.element);L(this,$e).style.overflow="hidden",L(this,$e).style.visibility="visible",L(this,$e).style.top=`${Math.floor(e)}px`,L(this,$e).style.left=`${Math.floor(t)}px`,L(this,$e).style.width=`${Math.floor(n)}px`,L(this,$e).style.height=`${Math.floor(r)}px`}};var Fr=new WeakMap,Nr=new WeakMap;function Th(e,t){let n=Fr.get(e);return n||(n={disconnect:new Hc(e,r=>{const i=Fr.get(e);i&&i.callbacks.forEach(s=>s(r))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Fr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Fr.delete(e),n.disconnect())}}function Ph(e,t){const n=new Set;for(const r of e){const i=Th(r,t);n.add(i)}return()=>n.forEach(r=>r())}function Rh(e,t){var n;const r=e.ownerDocument;if(!Nr.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",l=>a.forEach(c=>c(l)),{capture:!0,passive:!0,signal:o.signal}),Nr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=Nr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),Nr.delete(r))})}var nr,rr,si,Rs,Wh=class{constructor(e,t,n){this.callback=t,Ne(this,nr),Ne(this,rr,!1),Ne(this,si),Ne(this,Rs,Fc(o=>{if(!L(this,rr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of L(this,si))if(o.target.contains(a)){this.callback(L(this,nr).boundingClientRect);break}}},Nc));const r=Oh(e),i=Ph(r,t),s=Rh(e,L(this,Rs));Ye(this,si,r),Ye(this,nr,new Hc(e,t,n)),this.disconnect=()=>{L(this,rr)||(Ye(this,rr,!0),i(),s(),L(this,nr).disconnect())}}};nr=new WeakMap;rr=new WeakMap;si=new WeakMap;Rs=new WeakMap;function Ws(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function wn(e){try{Ws(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function $a(e){return!Wc||!e?!1:e===Fn(e).scrollingElement}function Uc(e){var t,n;const r=Ve(e),i=$a(e)?xh(e):Ii(e),s=r.visualViewport,o=$a(e)?{height:(t=s?.height)!=null?t:r.innerHeight,width:(n=s?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=a.current.y<=0,c=a.current.x<=0,u=a.current.y>=a.max.y,d=a.current.x>=a.max.x;return{rect:i,position:a,isTop:l,isLeft:c,isBottom:u,isRight:d}}function Ih(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=Uc(e),{x:a,y:l}=t??{x:0,y:0},c=!n&&o.current.y+l>0,u=!r&&o.current.y+l<o.max.y,d=!i&&o.current.x+a>0,p=!s&&o.current.x+a<o.max.x;return{top:c,bottom:u,left:d,right:p,x:d||p,y:c||u}}var Ho=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},bi=new Ho(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),zh=new Ho(e=>setTimeout(e,50)),yi=new Map,Lh=yi.clear.bind(yi);function gt(e,t=!1){if(!t)return Oa(e);let n=yi.get(e);return n||(n=Oa(e),yi.set(e,n),zh.schedule(Lh),n)}function Oa(e){return Ve(e).getComputedStyle(e)}function Fh(e,t=gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Nh(e,t=gt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const i=t[r];return typeof i=="string"?n.test(i):!1})}var _h={excludeElement:!0,escapeShadowDOM:!0};function Is(e,t=_h){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Fo(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&_o(a))return o(a.host);if(!Tt(a))return Rc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=gt(a,!0);if(r&&a===e||Nh(a,l)&&s.add(a),Fh(a,l)){const{scrollingElement:c}=a.ownerDocument;return c&&s.add(c),s}return o(a.parentNode)}return e?o(e):s}function Cn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=On(e);for(;r;){if(r===t)return n;const i=Ii(r),{x:s,y:o}=qh(r,i);n.x=n.x+i.left,n.y=n.y+i.top,n.scaleX=n.scaleX*s,n.scaleY=n.scaleY*o,r=On(r)}return n}function qh(e,t=Ii(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Tt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=gt(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function Hh(e){if(!e||e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function wr(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function zi(e){var t,n,r,i,s,o,a,l,c;const{scale:u,transform:d,translate:p}=e,h=Hh(u),g=wr(p),b=Uh(d);if(!b&&!h&&!g)return null;const w={x:(t=h?.x)!=null?t:1,y:(n=h?.y)!=null?n:1},v={x:(r=g?.x)!=null?r:0,y:(i=g?.y)!=null?i:0},f={x:(s=b?.x)!=null?s:0,y:(o=b?.y)!=null?o:0,scaleX:(a=b?.scaleX)!=null?a:1,scaleY:(l=b?.scaleY)!=null?l:1};return{x:v.x+f.x,y:v.y+f.y,z:(c=g?.z)!=null?c:0,scaleX:w.x*f.scaleX,scaleY:w.y*f.scaleY}}function Uh(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var Qe=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Qe||{}),Yh={x:.2,y:.2},Xh={x:10,y:10};function Vh(e,t,n,r=25,i=Yh,s=Xh){const{x:o,y:a}=t,{rect:l,isTop:c,isBottom:u,isLeft:d,isRight:p}=Uc(e),h=Cn(e),g=gt(e,!0),b=zi(g),w=b!==null?b?.scaleX<0:!1,v=b!==null?b?.scaleY<0:!1,f=new ht(l.left*h.scaleX+h.x,l.top*h.scaleY+h.y,l.width*h.scaleX,l.height*h.scaleY),y={x:0,y:0},x={x:0,y:0},k={height:f.height*i.y,width:f.width*i.x};return k.height>0&&(!c||v&&!u)&&a<=f.top+k.height&&n?.y!==1&&o>=f.left-s.x&&o<=f.right+s.x?(y.y=v?1:-1,x.y=r*Math.abs((f.top+k.height-a)/k.height)):k.height>0&&(!u||v&&!c)&&a>=f.bottom-k.height&&n?.y!==-1&&o>=f.left-s.x&&o<=f.right+s.x&&(y.y=v?-1:1,x.y=r*Math.abs((f.bottom-k.height-a)/k.height)),k.width>0&&(!p||w&&!d)&&o>=f.right-k.width&&n?.x!==-1&&a>=f.top-s.y&&a<=f.bottom+s.y?(y.x=w?-1:1,x.x=r*Math.abs((f.right-k.width-o)/k.width)):k.width>0&&(!d||w&&!p)&&o<=f.left+k.width&&n?.x!==1&&a>=f.top-s.y&&a<=f.bottom+s.y&&(y.x=w?1:-1,x.x=r*Math.abs((f.left+k.width-o)/k.width)),{direction:y,speed:x}}function Yc(e,{block:t="nearest",inline:n="nearest"}={}){if(!Tt(e))return;const r=Is(e),i=[];for(const s of r){if(!Tt(s))continue;const{top:o,left:a}=Kh(e,s);let l=o,c=a;for(const u of i)l-=u.scrollTop,c-=u.scrollLeft;if(t!=="none"){const u=l<s.scrollTop,d=l+e.offsetHeight>s.scrollTop+s.clientHeight;u!==d&&(t==="center"?s.scrollTop=l-s.clientHeight/2+e.offsetHeight/2:u?s.scrollTop=l:s.scrollTop=l+e.offsetHeight-s.clientHeight)}if(n!=="none"){const u=c<s.scrollLeft,d=c+e.offsetWidth>s.scrollLeft+s.clientWidth;u!==d&&(n==="center"?s.scrollLeft=c-s.clientWidth/2+e.offsetWidth/2:u?s.scrollLeft=c:s.scrollLeft=c+e.offsetWidth-s.clientWidth)}i.push(s)}}function Ca(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Tt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function Kh(e,t){const n=Ca(e),r=Ca(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Gh(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),l=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width*r:e.width,u=i?e.height*i:e.height;return{width:c,height:u,top:l,right:a+c,bottom:l+u,left:a}}function Bh(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left-s-(1-r)*parseFloat(n),l=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),c=r?e.width/r:e.width,u=i?e.height/i:e.height;return{width:c,height:u,top:l,right:a+c,bottom:l+u,left:a}}function Xc({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Ma(e,t=gt(e).translate,n=!0){if(n){const r=Pc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=wr(i);if(s)return s}}}if(t){const r=wr(t);if(r)return r}return{x:0,y:0,z:0}}var Zh=new Ho(e=>setTimeout(e,0)),pr=new Map,Jh=pr.clear.bind(pr);function Qh(e){const t=e.ownerDocument;let n=pr.get(t);if(n)return n;n=t.getAnimations(),pr.set(t,n),Zh.schedule(Jh);const r=n.filter(i=>Wi(i.effect)&&i.effect.target===e);return pr.set(e,r),n}function ef(e,t){const n=Qh(e).filter(r=>{var i,s;if(Wi(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))==null||s)return r.effect.getKeyframes().some(a=>{for(const l of t.properties)if(a[l])return!0})}}).map(r=>{const{effect:i,currentTime:s}=r,o=i?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof s=="number"&&s<o)return r.currentTime=o,()=>{r.currentTime=s}});if(n.length>0)return()=>n.forEach(r=>r?.())}var ut=class extends ht{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=Cn(e),ignoreTransforms:a,getBoundingClientRect:l=Ii}=t,c=ef(e,{properties:["transform","translate","scale","width","height"],isValidTarget:k=>(k!==e||No())&&k.contains(e)}),u=l(e);let{top:d,left:p,width:h,height:g}=u,b;const w=gt(e),v=zi(w),f={x:(n=v?.scaleX)!=null?n:1,y:(r=v?.scaleY)!=null?r:1},y=tf(e,w);c?.(),v&&(b=Bh(u,v,w.transformOrigin),(a||y)&&(d=b.top,p=b.left,h=b.width,g=b.height));const x={width:(i=b?.width)!=null?i:h,height:(s=b?.height)!=null?s:g};if(y&&!a&&b){const k=Gh(b,y,w.transformOrigin);d=k.top,p=k.left,h=k.width,g=k.height,f.x=y.scaleX,f.y=y.scaleY}o&&(a||(p*=o.scaleX,h*=o.scaleX,d*=o.scaleY,g*=o.scaleY),p+=o.x,d+=o.y),super(p,d,h,g),this.scale=f,this.intrinsicWidth=x.width,this.intrinsicHeight=x.height}};function tf(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=Wi(a.effect)?a.effect.getKeyframes():[],c=l[l.length-1];if(!c)continue;const{transform:u,translate:d,scale:p}=c;typeof u=="string"&&u&&(r=u,o=!0),typeof d=="string"&&d&&(i=d,o=!0),typeof p=="string"&&p&&(s=p,o=!0)}return o?zi({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function gr(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var nf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(gr(n))for(const[r,i]of Object.entries(e)){const s=`${t}${r}`;this.initial.has(s)||this.initial.set(s,n.style.getPropertyValue(s)),n.style.setProperty(s,typeof i=="string"?i:`${i}px`)}}remove(e,t=""){const{element:n}=this;if(gr(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(gr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Yt(e){return e?e instanceof Ve(e).Element||Dr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function kr(e){if(!e)return!1;const{KeyboardEvent:t}=Ve(e.target);return e instanceof t}function rf(e){if(!e)return!1;const{PointerEvent:t}=Ve(e.target);return e instanceof t}function sf(e){if(!Yt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||of(e)}function of(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Qi={};function zs(e){const t=Qi[e]==null?0:Qi[e]+1;return Qi[e]=t,`${e}-${t}`}var Uo=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Je.distance(t.shape.center,n);return{id:r,value:1/i,type:Ln.PointerIntersection,priority:zn.High}}return null},af=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=Je.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:Ln.ShapeIntersection,priority:zn.Normal}}return null},Vc=e=>{var t;return(t=Uo(e))!=null?t:af(e)},lf=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?ht.from(r.current.boundingRectangle).corners:void 0,o=ht.from(n.shape.boundingRectangle).corners.reduce((a,l,c)=>{var u;return a+Je.distance(Je.from(l),(u=s?.[c])!=null?u:i.current)},0)/4;return{id:n.id,value:1/o,type:Ln.Collision,priority:zn.Normal}},cf=Object.create,Yo=Object.defineProperty,df=Object.defineProperties,uf=Object.getOwnPropertyDescriptor,hf=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertySymbols,Kc=Object.prototype.hasOwnProperty,Gc=Object.prototype.propertyIsEnumerable,Bc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Nn=e=>{throw TypeError(e)},Ls=(e,t,n)=>t in e?Yo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sr=(e,t)=>{for(var n in t||(t={}))Kc.call(t,n)&&Ls(e,n,t[n]);if(xi)for(var n of xi(t))Gc.call(t,n)&&Ls(e,n,t[n]);return e},Xo=(e,t)=>df(e,hf(t)),Ea=(e,t)=>Yo(e,"name",{value:t,configurable:!0}),Zc=(e,t)=>{var n={};for(var r in e)Kc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&xi)for(var r of xi(e))t.indexOf(r)<0&&Gc.call(e,r)&&(n[r]=e[r]);return n},_n=e=>{var t;return[,,,cf((t=e?.[Bc("metadata")])!=null?t:null)]},Jc=["class","method","getter","setter","accessor","field","value","get","set"],ir=e=>e!==void 0&&typeof e!="function"?Nn("Function expected"):e,ff=(e,t,n,r,i)=>({kind:Jc[e],name:t,metadata:r,addInitializer:s=>n._?Nn("Already initialized"):i.push(ir(s||null))}),Jt=(e,t)=>Ls(t,Bc("metadata"),e[3]),me=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},rt=(e,t,n,r,i,s)=>{var o,a,l,c,u,d=t&7,p=!!(t&8),h=!!(t&16),g=d>3?e.length+1:d?p?1:2:0,b=Jc[d+5],w=d>3&&(e[g-1]=[]),v=e[g]||(e[g]=[]),f=d&&(!h&&!p&&(i=i.prototype),d<5&&(d>3||!h)&&uf(d<4?i:{get[n](){return B(this,s)},set[n](x){return We(this,s,x)}},n));d?h&&d<4&&Ea(s,(d>2?"set ":d>1?"get ":"")+n):Ea(i,n);for(var y=r.length-1;y>=0;y--)c=ff(d,n,l={},e[3],v),d&&(c.static=p,c.private=h,u=c.access={has:h?x=>pf(i,x):x=>n in x},d^3&&(u.get=h?x=>(d^1?B:Xt)(x,i,d^4?s:f.get):x=>x[n]),d>2&&(u.set=h?(x,k)=>We(x,i,k,d^4?s:f.set):(x,k)=>x[n]=k)),a=(0,r[y])(d?d<4?h?s:f[b]:d>4?void 0:{get:f.get,set:f.set}:i,c),l._=1,d^4||a===void 0?ir(a)&&(d>4?w.unshift(a):d?h?s=a:f[b]=a:i=a):typeof a!="object"||a===null?Nn("Object expected"):(ir(o=a.get)&&(f.get=o),ir(o=a.set)&&(f.set=o),ir(o=a.init)&&w.unshift(o));return d||Jt(e,i),f&&Yo(i,n,f),h?d^4?s:f:i},Vo=(e,t,n)=>t.has(e)||Nn("Cannot "+n),pf=(e,t)=>Object(t)!==t?Nn('Cannot use the "in" operator on this value'):e.has(t),B=(e,t,n)=>(Vo(e,t,"read from private field"),n?n.call(e):t.get(e)),ue=(e,t,n)=>t.has(e)?Nn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),We=(e,t,n,r)=>(Vo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Xt=(e,t,n)=>(Vo(e,t,"access private method"),n),Aa={role:"button",roleDescription:"draggable"},gf="dnd-kit-description",mf="dnd-kit-announcement",vf={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},bf={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function yf(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function xf(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function wf(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var kf=["dragover","dragmove"],Sf=class extends Te{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=gf,announcement:i=mf}={},announcements:s=bf,screenReaderInstructions:o=vf,debounce:a=500}=t??{},l=n?`${r}-${n}`:zs(r),c=n?`${i}-${n}`:zs(i);let u,d,p,h;const g=(k=h)=>{!p||!k||p?.nodeValue!==k&&(p.nodeValue=k)},b=()=>bi.schedule(g),w=jf(b,a),v=Object.entries(s).map(([k,M])=>this.manager.monitor.addEventListener(k,($,A)=>{const T=p;if(!T)return;const O=M?.($,A);O&&T.nodeValue!==O&&(h=O,kf.includes(k)?w():(b(),w.cancel()))})),f=()=>{let k=[];u?.isConnected||(u=xf(l,o.draggable),k.push(u)),d?.isConnected||(d=wf(c),p=document.createTextNode(""),d.appendChild(p),k.push(d)),k.length>0&&document.body.append(...k)},y=new Set;function x(){for(const k of y)k()}this.registerEffect(()=>{var k;y.clear();for(const M of this.manager.registry.draggables.value){const $=(k=M.handle)!=null?k:M.element;if($){(!u||!d)&&y.add(f),(!yf($)||No())&&!$.hasAttribute("tabindex")&&y.add(()=>$.setAttribute("tabindex","0")),!$.hasAttribute("role")&&$.tagName.toLowerCase()!=="button"&&y.add(()=>$.setAttribute("role",Aa.role)),$.hasAttribute("aria-roledescription")||y.add(()=>$.setAttribute("aria-roledescription",Aa.roleDescription)),$.hasAttribute("aria-describedby")||y.add(()=>$.setAttribute("aria-describedby",l));for(const T of["aria-pressed","aria-grabbed"]){const O=String(M.isDragging);$.getAttribute(T)!==O&&y.add(()=>$.setAttribute(T,O))}const A=String(M.disabled);$.getAttribute("aria-disabled")!==A&&y.add(()=>$.setAttribute("aria-disabled",A))}}y.size>0&&bi.schedule(x)}),this.destroy=()=>{super.destroy(),u?.remove(),d?.remove(),v.forEach(k=>k())}}};function jf(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var wi=new Map,Qc,ed,td,nd,Fs,mr,wt,Ko,Mn,rd,id,sd,od,Pt=class extends(Fs=Ar,nd=[H],td=[ce],ed=[ce],Qc=[ce],Fs){constructor(e,t){super(e,t),me(wt,5,this),ue(this,Mn),ue(this,mr,new Set),ue(this,Ko,me(wt,8,this,new Set)),me(wt,11,this),this.registerEffect(Xt(this,Mn,rd))}register(e){return B(this,mr).add(e),()=>{B(this,mr).delete(e)}}addRoot(e){return q(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{q(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return gi((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return gi((e=t?.element)!=null?e:null)}get roots(){const{status:e}=this.manager.dragOperation;if(e.initializing||e.initialized){const t=[this.sourceRoot,this.targetRoot].filter(n=>n!=null);return new Set([...t,...this.additionalRoots])}return new Set}};wt=_n(Fs);mr=new WeakMap;Ko=new WeakMap;Mn=new WeakSet;rd=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of B(this,mr))t.push(Xt(this,Mn,id).call(this,n,r));return()=>{for(const n of t)n()}};id=function(e,t){let n=wi.get(e);n||(n=new Map,wi.set(e,n));let r=n.get(t);if(!r){const s=Fo(e)?Xt(this,Mn,sd).call(this,e,n,t):Xt(this,Mn,od).call(this,e,n,t);if(!s)return()=>{};r=s,n.set(t,r)}r.refCount++;let i=!1;return()=>{i||(i=!0,r.refCount--,r.refCount===0&&r.cleanup())}};sd=function(e,t,n){var r;const i=e.createElement("style"),{nonce:s}=(r=this.options)!=null?r:{};s&&i.setAttribute("nonce",s),i.textContent=n,e.head.prepend(i);const o=new MutationObserver(a=>{for(const l of a)for(const c of Array.from(l.removedNodes))if(c===i){e.head.prepend(i);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),i.remove(),t.delete(n),t.size===0&&wi.delete(e)}}};od=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:i}=r??{};if(!i)return null;const s=new i;return s.replaceSync(n),e.adoptedStyleSheets.push(s),{refCount:0,cleanup:()=>{var o;if(_o(e)&&(o=e.host)!=null&&o.isConnected){const a=e.adoptedStyleSheets.indexOf(s);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&wi.delete(e)}}};rt(wt,4,"additionalRoots",nd,Pt,Ko);rt(wt,2,"sourceRoot",td,Pt);rt(wt,2,"targetRoot",ed,Pt);rt(wt,2,"roots",Qc,Pt);Jt(wt,Pt);Pt.configure=Er(Pt);var Li=Pt,$f=class extends Te{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Li),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},Tr="data-dnd-",Ns=`${Tr}dropping`,je="--dnd-",dt=`${Tr}dragging`,ki=`${Tr}placeholder`,Of=[dt,ki,"popover","aria-pressed","aria-grabbing"],Cf=["view-transition-name"],Mf=`
|
|
10
|
-
:is(:root,:host) [${dt}] {
|
|
11
|
-
position: fixed !important;
|
|
12
|
-
pointer-events: none !important;
|
|
13
|
-
touch-action: none;
|
|
14
|
-
z-index: calc(infinity);
|
|
15
|
-
will-change: translate;
|
|
16
|
-
top: var(${je}top, 0px) !important;
|
|
17
|
-
left: var(${je}left, 0px) !important;
|
|
18
|
-
right: unset !important;
|
|
19
|
-
bottom: unset !important;
|
|
20
|
-
width: var(${je}width, auto);
|
|
21
|
-
max-width: var(${je}width, auto);
|
|
22
|
-
height: var(${je}height, auto);
|
|
23
|
-
max-height: var(${je}height, auto);
|
|
24
|
-
transform: var(${je}transform, none) !important;
|
|
25
|
-
transition: var(${je}transition) !important;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
:is(:root,:host) [${ki}] {
|
|
29
|
-
transition: none;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
:is(:root,:host) [${ki}='hidden'] {
|
|
33
|
-
visibility: hidden;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
[${dt}] * {
|
|
37
|
-
pointer-events: none !important;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
[${dt}]:not([${Ns}]) {
|
|
41
|
-
translate: var(${je}translate) !important;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[${dt}][style*='${je}scale'] {
|
|
45
|
-
scale: var(${je}scale) !important;
|
|
46
|
-
transform-origin: var(${je}transform-origin) !important;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@layer dnd-kit {
|
|
50
|
-
:where([${dt}][popover]) {
|
|
51
|
-
overflow: visible;
|
|
52
|
-
background: unset;
|
|
53
|
-
border: unset;
|
|
54
|
-
margin: unset;
|
|
55
|
-
padding: unset;
|
|
56
|
-
color: inherit;
|
|
57
|
-
|
|
58
|
-
&:is(input, button) {
|
|
59
|
-
border: revert;
|
|
60
|
-
background: revert;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
[${dt}]::backdrop, [${Tr}overlay]:not([${dt}]) {
|
|
65
|
-
display: none;
|
|
66
|
-
visibility: hidden;
|
|
67
|
-
}
|
|
68
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Ef(e,t="hidden"){return q(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=Af(n,r.registry.droppables),s=[],o=Sh(n),{remove:a}=o;return Df(i,o,s),Tf(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function Af(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Tr}${zs("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function Df(e,t,n){for(const[r,i]of e){if(!r.element)continue;const s=`[${i}]`,o=t.matches(s)?t:t.querySelector(s);if(r.element.removeAttribute(i),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(i),Ps.set(a,o),n.push(()=>{Ps.delete(a),r.proxy=void 0})}}function Tf(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(ki,t)}function ad(e,t){return e===t?!0:On(e)===On(t)}function Da(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Yt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>wn(t))}function _s(e){return e.tagName==="TR"}function Pf(e,t,n){const r=new MutationObserver(i=>{let s=!1;for(const o of i){if(o.target!==e){s=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||Of.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(gr(e)&&gr(t)){const c=e.style;for(const u of Array.from(t.style))c.getPropertyValue(u)===""&&t.style.removeProperty(u);for(const u of Array.from(c)){if(Cf.includes(u)||u.startsWith(je))continue;const d=c.getPropertyValue(u);t.style.setProperty(u,d)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function Rf(e,t,n){const r=new MutationObserver(i=>{for(const s of i)if(s.addedNodes.length!==0)for(const o of Array.from(s.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),wn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),wn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),wn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Wf(e){return new ResizeObserver(()=>{var t,n,r;const i=new ut(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-i.width)*s.x+e.delta.x,a=(e.height-i.height)*s.y+e.delta.y,l=Ic();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},je),(n=e.getElementMutationObserver())==null||n.takeRecords(),_s(e.element)&&_s(e.placeholder)){const b=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(b.map(v=>v.style.width));for(const[v,f]of b.entries()){const y=w[v];f.style.width=`${y.getBoundingClientRect().width}px`}}const c=(r=e.getTranslate())!=null?r:{x:0,y:0},u=e.left+o+l.x+c.x,d=e.top+a+l.y+c.y,p=i.width-e.widthOffset,h=i.height-e.heightOffset,g=e.frameTransform;e.dragOperation.shape=new ht(u*g.scaleX+g.x,d*g.scaleY+g.y,p*g.scaleX,h*g.scaleY)})}var If=250,zf="ease";function Lf(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const f=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(f).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=If,easing:a=zf}=s??{};wn(e.feedbackElement);const[,l]=(t=Pc(e.feedbackElement,f=>"translate"in f))!=null?t:[];l?.pause();const c=(n=e.placeholder)!=null?n:e.element,u={frameTransform:ad(e.feedbackElement,c)?null:void 0},d=new ut(e.feedbackElement,u),p=(r=wr(gt(e.feedbackElement).translate))!=null?r:e.translate,h=new ut(c,u),g=ht.delta(d,h,e.alignment),b={x:p.x-g.x,y:p.y-g.y},w=Math.round(d.intrinsicHeight)!==Math.round(h.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${h.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${h.intrinsicHeight}px`]}:{},v=Math.round(d.intrinsicWidth)!==Math.round(h.intrinsicWidth)?{minWidth:[`${d.intrinsicWidth}px`,`${h.intrinsicWidth}px`],maxWidth:[`${d.intrinsicWidth}px`,`${h.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},je),e.feedbackElement.setAttribute(Ns,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),Xc({element:e.feedbackElement,keyframes:Xo(Sr(Sr({},w),v),{translate:[`${p.x}px ${p.y}px 0`,`${b.x}px ${b.y}px 0`]}),options:{duration:qo(Ve(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Ns),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var ld,qs,jr,Go,oi,cd,dd,En=class extends(qs=Te,ld=[H],qs){constructor(e,t){super(e,t),ue(this,oi),ue(this,Go,me(jr,8,this)),me(jr,11,this),this.state={initial:{},current:{}};const n=e.registry.plugins.get(Li),r=n?.register(Mf);if(r){const i=this.destroy.bind(this);this.destroy=()=>{r(),i()}}this.registerEffect(Xt(this,oi,cd).bind(this,n)),this.registerEffect(Xt(this,oi,dd))}};jr=_n(qs);Go=new WeakMap;oi=new WeakSet;cd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=gi(t);if(n)return e.addRoot(n)};dd=function(){var e,t,n,r,i,s,o;const{state:a,manager:l,options:c}=this,{dragOperation:u}=l,{position:d,source:p,status:h}=u;if(h.idle){a.current={},a.initial={};return}if(!p)return;const{element:g}=p,b=p.pluginConfig(En),w=(t=(e=b?.feedback)!=null?e:c?.feedback)!=null?t:"default",v=typeof w=="function"?w(p,l):w;if(!g||v==="none"||!h.initialized||h.initializing)return;const{initial:f}=a,y=(n=this.overlay)!=null?n:g,x=Cn(y),k=Cn(g),M=!ad(g,y),$=new ut(g,{frameTransform:M?k:null,ignoreTransforms:!M}),A={x:k.scaleX/x.scaleX,y:k.scaleY/x.scaleY};let{width:T,height:O,top:I,left:E}=$;M&&(T=T/A.x,O=O/A.y);const P=new nf(y),Z=gt(g),{transition:G,translate:xe,boxSizing:ze,paddingBlockStart:re,paddingBlockEnd:_e,paddingInlineStart:Ke,paddingInlineEnd:we,borderInlineStartWidth:Ge,borderInlineEndWidth:qe,borderBlockStartWidth:Le,borderBlockEndWidth:He}=Z,ke=G.split(",").filter(J=>!/^\s*(transform|translate|scale)\b/.test(J)).join(","),ee=zi(Z),W=Z.transform,N=v==="clone",Se=ze==="content-box",te=Se?parseInt(Ke)+parseInt(we)+parseInt(Ge)+parseInt(qe):0,Fe=Se?parseInt(re)+parseInt(_e)+parseInt(Le)+parseInt(He):0,V=v!=="move"&&!this.overlay?Ef(p,N?"clone":"hidden"):null,it=q(()=>kr(l.dragOperation.activatorEvent));if(!f.translate){if(this.overlay&&ee)f.translate={x:ee.x,y:ee.y};else if(xe!=="none"){const J=wr(xe);J&&(f.translate=J)}}if(!f.transformOrigin){const J=q(()=>d.current),be=E+((r=ee?.x)!=null?r:0),Ue=I+((i=ee?.y)!=null?i:0);f.transformOrigin={x:(J.x-be*x.scaleX-x.x)/(T*x.scaleX),y:(J.y-Ue*x.scaleY-x.y)/(O*x.scaleY)}}const{transformOrigin:Oe}=f,mt=I*x.scaleY+x.y,C=E*x.scaleX+x.x;if(!f.coordinates&&(f.coordinates={x:C,y:mt},A.x!==1||A.y!==1)){const{scaleX:J,scaleY:be}=k,{x:Ue,y:jt}=Oe;f.coordinates.x+=(T*J-T)*Ue,f.coordinates.y+=(O*be-O)*jt}f.dimensions||(f.dimensions={width:T,height:O}),f.frameTransform||(f.frameTransform=x);const R={x:f.coordinates.x-C,y:f.coordinates.y-mt},Y={width:(f.dimensions.width*f.frameTransform.scaleX-T*x.scaleX)*Oe.x,height:(f.dimensions.height*f.frameTransform.scaleY-O*x.scaleY)*Oe.y},j={x:R.x/x.scaleX+Y.width,y:R.y/x.scaleY+Y.height},D={left:E+j.x,top:I+j.y};y.setAttribute(dt,"true");const z=q(()=>u.transform),K=(s=f.translate)!=null?s:{x:0,y:0},st=z.x*x.scaleX+K.x,ve=z.y*x.scaleY+K.y,Ce=Ic();P.set({width:T-te,height:O-Fe,top:D.top+Ce.y,left:D.left+Ce.x,translate:`${st}px ${ve}px 0`,transform:this.overlay?"none":W,transition:ke?`${ke}, translate 0ms linear`:"translate 0ms linear",scale:M?`${A.x} ${A.y}`:"","transform-origin":`${Oe.x*100}% ${Oe.y*100}%`},je),V&&(g.insertAdjacentElement("afterend",V),c?.rootElement&&(typeof c.rootElement=="function"?c.rootElement(p):c.rootElement).appendChild(g)),Ws(y)&&(y.hasAttribute("popover")||y.setAttribute("popover","manual"),wn(y),y.addEventListener("beforetoggle",Da));let Me,Hn,Qt;const en=Wf({placeholder:V,element:g,feedbackElement:y,frameTransform:x,transformOrigin:Oe,width:T,height:O,top:I,left:E,widthOffset:te,heightOffset:Fe,delta:j,styles:P,dragOperation:u,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Me,getSavedCellWidths:()=>Qt,setSavedCellWidths:J=>{Qt=J}}),Ir=new ut(y);q(()=>u.shape=Ir);const Un=Ve(y),Yn=J=>{this.manager.actions.stop({event:J})},Hi=qo(Un);it&&Un.addEventListener("resize",Yn),q(()=>p.status)==="idle"&&requestAnimationFrame(()=>p.status="dragging"),V&&(en.observe(V),Me=Pf(g,V,N),Hn=Rf(g,V,y));const _=(o=l.dragOperation.source)==null?void 0:o.id,Ee=()=>{var J;if(!it||_==null)return;const be=l.registry.draggables.get(_),Ue=(J=be?.handle)!=null?J:be?.element;Tt(Ue)&&Ue.focus()},Be=()=>{Me?.disconnect(),Hn?.disconnect(),en.disconnect(),Un.removeEventListener("resize",Yn),Ws(y)&&(y.removeEventListener("beforetoggle",Da),y.removeAttribute("popover")),y.removeAttribute(dt),P.reset();const J=()=>{var be;if(Qt&&_s(g)){const Ui=Array.from(g.cells);for(const[zr,tn]of Ui.entries())tn.style.width=(be=Qt[zr])!=null?be:""}p.status="idle";const Ue=a.current.translate!=null,jt=u.status.dragging;V&&(!jt&&Ue||V.parentElement!==y.parentElement)&&y.isConnected&&V.replaceWith(y),V?.remove()};y===this.overlay?setTimeout(J,0):J()},fe=c?.dropAnimation,he=this,ru=Cr(()=>{var J,be,Ue;const{transform:jt,status:Ui}=u;if(!(!jt.x&&!jt.y&&!a.current.translate)&&Ui.dragging){const zr=(J=f.translate)!=null?J:{x:0,y:0},tn={x:jt.x/x.scaleX+zr.x,y:jt.y/x.scaleY+zr.y},la=a.current.translate,iu=q(()=>u.modifiers),Yi=q(()=>{var Xn;return(Xn=u.shape)==null?void 0:Xn.current}),Xi=c?.keyboardTransition,ca=it&&!Hi&&Xi!==null?`${(be=Xi?.duration)!=null?be:250}ms ${(Ue=Xi?.easing)!=null?Ue:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(P.set({transition:ke?`${ke}, translate ${ca}`:`translate ${ca}`,translate:`${tn.x}px ${tn.y}px 0`},je),Me?.takeRecords(),Yi&&Yi!==Ir&&la&&!iu.length){const Xn=Je.delta(tn,la);u.shape=ht.from(Yi.boundingRectangle).translate(Xn.x*x.scaleX,Xn.y*x.scaleY)}else u.shape=new ut(y);a.current.translate=tn}},function(){if(u.status.dropped){this.dispose(),p.status="dropping";const J=b?.dropAnimation!==void 0?b.dropAnimation:he.dropAnimation!==void 0?he.dropAnimation:fe;let be=a.current.translate;const Ue=be!=null;if(!be&&g!==y&&(be={x:0,y:0}),!be||J===null){Be();return}l.renderer.rendering.then(()=>{Lf({source:p,element:g,feedbackElement:y,placeholder:V,translate:be,moved:Ue,transition:G,alignment:p.alignment,styles:P,animation:J??void 0,getElementMutationObserver:()=>Me,cleanup:Be,restoreFocus:Ee})})}});return()=>{Be(),ru()}};rt(jr,4,"overlay",ld,En,Go);Jt(jr,En);En.configure=Er(En);var Bo=En,Vn=!0,Ff=!1,ud,hd,fd,pd,Mt,Zo,Jo;pd=(fd=[H],Qe.Forward),hd=(ud=[H],Qe.Reverse);var $r=class{constructor(){ue(this,Zo,me(Mt,8,this,Vn)),me(Mt,11,this),ue(this,Jo,me(Mt,12,this,Vn)),me(Mt,15,this)}isLocked(e){return e===Qe.Idle?!1:e==null?this[Qe.Forward]===Vn&&this[Qe.Reverse]===Vn:this[e]===Vn}unlock(e){e!==Qe.Idle&&(this[e]=Ff)}};Mt=_n(null);Zo=new WeakMap;Jo=new WeakMap;rt(Mt,4,pd,fd,$r,Zo);rt(Mt,4,hd,ud,$r,Jo);Jt(Mt,$r);var Nf=[Qe.Forward,Qe.Reverse],Ta=class{constructor(){this.x=new $r,this.y=new $r}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},_f=class extends Te{constructor(e){super(e);const t=Dn(new Ta);let n=null;this.signal=t,nt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ta;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:Pa(i.x,n.x),y:Pa(i.y,n.y)},o=t.peek();oe(()=>{for(const a of Hl)for(const l of Nf)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Pa(e,t){return Math.sign(e-t)}var gd,Hs,Or,Qo,Ot,Us,Pr=class extends(Hs=Ar,gd=[H],Hs){constructor(e){super(e),ue(this,Qo,me(Or,8,this,!1)),me(Or,11,this),ue(this,Ot),ue(this,Us,()=>{if(!B(this,Ot))return;const{element:s,by:o}=B(this,Ot);o.y&&(s.scrollTop+=o.y),o.x&&(s.scrollLeft+=o.x)}),this.scroll=(s,o)=>{var a;if(this.disabled)return!1;const l=this.getScrollableElements();if(!l)return We(this,Ot,void 0),!1;const{position:c}=this.manager.dragOperation,u=c?.current;if(u){const{by:d}=s??{},p=d?{x:Ra(d.x),y:Ra(d.y)}:void 0,h=p?void 0:this.scrollIntentTracker.current;if(h?.isLocked())return!1;for(const g of l){const b=Ih(g,d);if(b.x||b.y){const{speed:w,direction:v}=Vh(g,u,p,o?.acceleration,o?.threshold);if(h)for(const f of Hl)h[f].isLocked(v[f])&&(w[f]=0,v[f]=0);if(v.x||v.y){const{x:f,y}=d??v,x=f*w.x,k=y*w.y;if(x||k){const M=(a=B(this,Ot))==null?void 0:a.by;if(this.autoScrolling&&M&&(M.x&&!x||M.y&&!k))continue;return We(this,Ot,{element:g,by:{x,y:k}}),bi.schedule(B(this,Us)),!0}}}}}return We(this,Ot,void 0),!1};let t=null,n=null;const r=ys(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=zc(gi(o?.element),s.current);return a&&(t=a),a??t}),i=ys(()=>{const s=r.value,{documentElement:o}=Fn(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const c=Is(l,{excludeElement:!1});return n=c,c}}if(s){const a=Is(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},ot);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new _f(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!kr(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};Or=_n(Hs);Qo=new WeakMap;Ot=new WeakMap;Us=new WeakMap;rt(Or,4,"autoScrolling",gd,Pr,Qo);Jt(Or,Pr);function Ra(e){return e>0?Qe.Forward:e<0?Qe.Reverse:Qe.Idle}var qf=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},Hf=new qf(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Uf=10,Ys=class extends Te{constructor(e,t){super(e,t);const n=e.registry.plugins.get(Pr);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=nt(()=>{var r,i,s;if(this.disabled)return;const{position:o,status:a}=e.dragOperation;if(a.dragging){const l={acceleration:(r=this.options)==null?void 0:r.acceleration,threshold:typeof((i=this.options)==null?void 0:i.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(s=this.options)==null?void 0:s.threshold};if(n.scroll(void 0,l)){n.autoScrolling=!0;const c=setInterval(()=>Hf.schedule(()=>n.scroll(void 0,l)),Uf);return()=>{clearInterval(c)}}else n.autoScrolling=!1}})}};Ys.configure=Er(Ys);var md=Ys,Wa={capture:!0,passive:!0},sr,Yf=class extends Ar{constructor(e){super(e),ue(this,sr),this.handleScroll=()=>{B(this,sr)==null&&We(this,sr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),We(this,sr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=nt(()=>{var n,r,i;if(t.status.dragging){const s=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return s.addEventListener("scroll",this.handleScroll,Wa),()=>{s.removeEventListener("scroll",this.handleScroll,Wa)}}})}};sr=new WeakMap;var Xf="* { user-select: none !important; -webkit-user-select: none !important; }",Vf=class extends Te{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Li),n=t?.register(Xf);if(this.destroy=nt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return es(),document.addEventListener("selectionchange",es,{capture:!0}),()=>{document.removeEventListener("selectionchange",es,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function es(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var or=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),fn,Si=class extends jn{constructor(e,t){super(e),this.manager=e,this.options=t,ue(this,fn,[]),this.listeners=new Lc,this.handleSourceKeyDown=(n,r,i)=>{if(this.disabled||n.defaultPrevented||!Yt(n.target)||r.disabled)return;const{keyboardCodes:s=or.keyboardCodes,preventActivation:o=or.preventActivation}=i??{};s.start.includes(n.code)&&this.manager.dragOperation.status.idle&&(o?.(n,r)||this.handleStart(n,r,i))}}bind(e,t=this.options){return nt(()=>{var n;const r=(n=e.handle)!=null?n:e.element,i=s=>{kr(s)&&this.handleSourceKeyDown(s,e,t)};if(r)return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}})}handleStart(e,t,n){const{element:r}=t;if(!r)throw new Error("Source draggable does not have an associated element");e.preventDefault(),e.stopImmediatePropagation(),Yc(r);const{center:i}=new ut(r);if(this.manager.actions.start({event:e,coordinates:{x:i.x,y:i.y},source:t}).signal.aborted)return this.cleanup();this.sideEffects();const s=Fn(r),o=[this.listeners.bind(s,[{type:"keydown",listener:a=>this.handleKeyDown(a,t,n),options:{capture:!0}}])];B(this,fn).push(...o)}handleKeyDown(e,t,n){const{keyboardCodes:r=or.keyboardCodes}=n??{};if(nn(e,[...r.end,...r.cancel])){e.preventDefault();const i=nn(e,r.cancel);this.handleEnd(e,i);return}nn(e,r.up)?this.handleMove("up",e):nn(e,r.down)&&this.handleMove("down",e),nn(e,r.left)?this.handleMove("left",e):nn(e,r.right)&&this.handleMove("right",e)}handleEnd(e,t){this.manager.actions.stop({event:e,canceled:t}),this.cleanup()}handleMove(e,t){var n,r;const{shape:i}=this.manager.dragOperation,s=t.shiftKey?5:1;let o={x:0,y:0},a=(r=(n=this.options)==null?void 0:n.offset)!=null?r:or.offset;if(typeof a=="number"&&(a={x:a,y:a}),!!i){switch(e){case"up":o={x:0,y:-a.y*s};break;case"down":o={x:0,y:a.y*s};break;case"left":o={x:-a.x*s,y:0};break;case"right":o={x:a.x*s,y:0};break}(o.x||o.y)&&(t.preventDefault(),this.manager.actions.move({event:t,by:o}))}}sideEffects(){const e=this.manager.registry.plugins.get(md);e?.disabled===!1&&(e.disable(),B(this,fn).push(()=>{e.enable()}))}cleanup(){B(this,fn).forEach(e=>e()),We(this,fn,[])}destroy(){this.cleanup(),this.listeners.clear()}};fn=new WeakMap;Si.configure=Er(Si);Si.defaults=or;var vd=Si;function nn(e,t){return t.includes(e.code)}var Nt,Kf=class extends wc{constructor(){super(...arguments),ue(this,Nt)}onEvent(e){switch(e.type){case"pointerdown":We(this,Nt,$n(e));break;case"pointermove":if(!B(this,Nt))return;const{x:t,y:n}=$n(e),r={x:t-B(this,Nt).x,y:n-B(this,Nt).y},{tolerance:i}=this.options;if(i&&Ms(r,i)){this.abort();return}Ms(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){We(this,Nt,void 0)}};Nt=new WeakMap;var pn,_t,Gf=class extends wc{constructor(){super(...arguments),ue(this,pn),ue(this,_t)}onEvent(e){switch(e.type){case"pointerdown":We(this,_t,$n(e)),We(this,pn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!B(this,_t))return;const{x:t,y:n}=$n(e),r={x:t-B(this,_t).x,y:n-B(this,_t).y};Ms(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){B(this,pn)&&(clearTimeout(B(this,pn)),We(this,_t,void 0),We(this,pn,void 0))}};pn=new WeakMap;_t=new WeakMap;var yn=class{};yn.Delay=Gf;yn.Distance=Kf;var Xs=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&Yt(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new yn.Delay({value:250,tolerance:5})]:sf(i)&&!e.defaultPrevented?[new yn.Delay({value:200,tolerance:0})]:[new yn.Delay({value:200,tolerance:10}),new yn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!Yt(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=$h(r);return i===t.element?!1:!!i}}),gn,ji=class extends jn{constructor(e,t){super(e),this.manager=e,this.options=t,ue(this,gn,new Set),this.listeners=new Lc,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:n,coordinates:r}=this.latest;!n||!r||this.manager.actions.move({event:n,to:r})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(e,t,n=this.options){const{activationConstraints:r=Xs.activationConstraints}=n??{};return typeof r=="function"?r(e,t):r}bind(e,t=this.options){return nt(()=>{var n;const r=new AbortController,{signal:i}=r,s=a=>{rf(a)&&this.handlePointerDown(a,e,t)};let o=[(n=e.handle)!=null?n:e.element];t?.activatorElements&&(Array.isArray(t.activatorElements)?o=t.activatorElements:o=t.activatorElements(e));for(const a of o)a&&(Jf(a.ownerDocument.defaultView),a.addEventListener("pointerdown",s,{signal:i}));return()=>r.abort()})}handlePointerDown(e,t,n){if(this.disabled||!e.isPrimary||e.button!==0||!Yt(e.target)||t.disabled||Bf(e)||!this.manager.dragOperation.status.idle)return;const{preventActivation:r=Xs.preventActivation}=n??{};if(r?.(e,t))return;const{target:i}=e,s=Tt(i)&&i.draggable&&i.getAttribute("draggable")==="true",o=Cn(t.element),{x:a,y:l}=$n(e);this.initialCoordinates={x:a*o.scaleX+o.x,y:l*o.scaleY+o.y};const c=this.activationConstraints(e,t,n);e.sensor=this;const u=new mh(c,g=>this.handleStart(t,g));u.signal.onabort=()=>this.handleCancel(e),u.onEvent(e),this.controller=u;const d=Ts(),p=this.listeners.bind(d,[{type:"pointermove",listener:g=>this.handlePointerMove(g,t)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:s?this.handleCancel:_r,options:{capture:!0}}]),h=()=>{p(),this.initialCoordinates=void 0};B(this,gn).add(h)}handlePointerMove(e,t){var n,r;if(((n=this.controller)==null?void 0:n.activated)===!1){(r=this.controller)==null||r.onEvent(e);return}if(this.manager.dragOperation.status.dragging){const i=$n(e),s=Cn(t.element);i.x=i.x*s.scaleX+s.x,i.y=i.y*s.scaleY+s.y,e.preventDefault(),e.stopPropagation(),this.latest.event=e,this.latest.coordinates=i,bi.schedule(this.handleMove)}}handlePointerUp(e){const{status:t}=this.manager.dragOperation;if(!t.idle){e.preventDefault(),e.stopPropagation();const n=!t.initialized;this.manager.actions.stop({event:e,canceled:n})}this.cleanup()}handleKeyDown(e){e.key==="Escape"&&(e.preventDefault(),this.handleCancel(e))}handleStart(e,t){const{manager:n,initialCoordinates:r}=this;if(!r||!n.dragOperation.status.idle||t.defaultPrevented)return;if(n.actions.start({coordinates:r,event:t,source:e}).signal.aborted)return this.cleanup();t.preventDefault();const i=Fn(t.target).body;try{i.setPointerCapture(t.pointerId)}catch{this.handleCancel(t);return}const s=Yt(t.target)?[t.target,i]:i,o=this.listeners.bind(s,[{type:"touchmove",listener:_r,options:{passive:!1}},{type:"click",listener:_r},{type:"contextmenu",listener:_r},{type:"keydown",listener:this.handleKeyDown}]);B(this,gn).add(o)}handleCancel(e){const{dragOperation:t}=this.manager;t.status.initialized&&this.manager.actions.stop({event:e,canceled:!0}),this.cleanup()}cleanup(){const{controller:e}=this;this.controller=void 0,e&&!e.signal.aborted&&e.abort(),this.latest={event:void 0,coordinates:void 0},B(this,gn).forEach(t=>t()),B(this,gn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};gn=new WeakMap;ji.configure=Er(ji);ji.defaults=Xs;var Vs=ji;function Bf(e){return"sensor"in e}function _r(e){e.preventDefault()}function Zf(){}var Ia=new WeakSet;function Jf(e){!e||Ia.has(e)||(e.addEventListener("touchmove",Zf,{capture:!1,passive:!1}),Ia.add(e))}var kn={modifiers:[],plugins:[Sf,md,$f,Bo,Vf],sensors:[Vs,vd]},bd=class extends yh{constructor(e={}){const t=lt(e.plugins,kn.plugins),n=lt(e.sensors,kn.sensors),r=lt(e.modifiers,kn.modifiers);super(Xo(Sr({},e),{plugins:[Yf,Pr,Li,...t],sensors:n,modifiers:r}))}},yd,xd,Ks,Et,ea,ta,Fi=class extends(Ks=ft,xd=[H],yd=[H],Ks){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=Zc(n,["element","effects","handle"]);super(Sr({effects:()=>[...i(),()=>{var a,l;const{manager:c}=this;if(!c)return;const u=((l=(a=this.sensors)==null?void 0:a.map(br))!=null?l:[...c.sensors]).map(d=>{const p=d instanceof jn?d:c.registry.register(d.plugin),h=d instanceof jn?void 0:d.options;return p.bind(this,h)});return function(){u.forEach(d=>d())}}]},o),t),ue(this,ea,me(Et,8,this)),me(Et,11,this),ue(this,ta,me(Et,12,this)),me(Et,15,this),this.element=r,this.handle=s}};Et=_n(Ks);ea=new WeakMap;ta=new WeakMap;rt(Et,4,"handle",xd,Fi,ea);rt(Et,4,"element",yd,Fi,ta);Jt(Et,Fi);var wd,kd,Gs,At,na,ts,Sd,jd,vr,ra,Ni=class extends(Gs=pt,kd=[H],wd=[H],Gs){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=Zc(n,["element","effects"]);const{collisionDetector:o=Vc}=s,a=c=>{const{manager:u,element:d}=this;if(!d||c===null){this.shape=void 0;return}if(!u)return;const p=new ut(d),h=q(()=>this.shape);return p&&h?.equals(p)?h:(this.shape=p,p)},l=Dn(!1);super(Xo(Sr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:c,manager:u}=this;if(!u)return;const{dragOperation:d}=u,{source:p}=d;l.value=!!(p&&d.status.initialized&&c&&!this.disabled&&this.accepts(p))},()=>{const{element:c}=this;if(l.value&&c){const u=new Wh(c,a);return()=>{u.disconnect(),this.shape=void 0}}},()=>{var c;if((c=this.manager)!=null&&c.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),ue(this,vr),ue(this,na,me(At,8,this)),me(At,11,this),ue(this,ra,me(At,12,this)),me(At,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){We(this,vr,e,jd)}get element(){var e;return(e=this.proxy)!=null?e:B(this,vr,Sd)}};At=_n(Gs);na=new WeakMap;vr=new WeakSet;ra=new WeakMap;ts=rt(At,20,"#element",kd,vr,na),Sd=ts.get,jd=ts.set;rt(At,4,"proxy",wd,Ni,ra);Jt(At,Ni);function Qf(e){return e!=null&&typeof e=="object"&&"current"in e}function Sn(e){var t;if(e!=null)return Qf(e)?(t=e.current)!=null?t:void 0:e}var ep=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",qn=ep?S.useLayoutEffect:S.useEffect;function tp(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function $d(e,t){const n=S.useRef(new Map),r=tp();return qn(()=>{if(!e){n.current.clear();return}return nt(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[l]=a,c=q(()=>a[1]),u=e[l];c!==u&&(s=!0,n.current.set(l,u),o=(i=t?.(l,c,u))!=null?i:!1)}s&&(o?queueMicrotask(()=>Ou.flushSync(r)):r())})},[e]),S.useMemo(()=>e&&new Proxy(e,{get(i,s){const o=i[s];return n.current.set(s,o),o}}),[e])}function np(e,t){e()}function rn(e){const t=S.useRef(e);return qn(()=>{t.current=e},[e]),t}function ie(e,t,n=S.useEffect,r=Object.is){const i=S.useRef(e);n(()=>{const s=i.current;r(e,s)||(i.current=e,t(e,s))},[t,e])}function ai(e,t){const n=S.useRef(Sn(e));qn(()=>{const r=Sn(e);r!==n.current&&(n.current=r,t(r))})}var rp=Object.defineProperty,ip=Object.defineProperties,sp=Object.getOwnPropertyDescriptors,$i=Object.getOwnPropertySymbols,Od=Object.prototype.hasOwnProperty,Cd=Object.prototype.propertyIsEnumerable,za=(e,t,n)=>t in e?rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,op=(e,t)=>{for(var n in t||(t={}))Od.call(t,n)&&za(e,n,t[n]);if($i)for(var n of $i(t))Cd.call(t,n)&&za(e,n,t[n]);return e},ap=(e,t)=>ip(e,sp(t)),lp=(e,t)=>{var n={};for(var r in e)Od.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&$i)for(var r of $i(e))t.indexOf(r)<0&&Cd.call(e,r)&&(n[r]=e[r]);return n},cp=new bd,Md=S.createContext(cp),dp=S.memo(S.forwardRef(({children:e},t)=>{const[n,r]=S.useState(0),i=S.useRef(null),s=S.useRef(null),o=S.useMemo(()=>({renderer:{get rendering(){var a;return(a=i.current)!=null?a:Promise.resolve()}},trackRendering(a){i.current||(i.current=new Promise(l=>{s.current=l})),S.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return qn(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),ns=[void 0,ot];function up(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,c=lp(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=S.useRef(null),{plugins:d,modifiers:p,sensors:h}=c,g=lt(d,kn.plugins),b=lt(h,kn.sensors),w=lt(p,kn.modifiers),v=rn(i),f=rn(s),y=rn(a),x=rn(o),k=rn(l),M=rn(r),$=hp(()=>{var A;return(A=c.manager)!=null?A:new bd(c)});return S.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:A,trackRendering:T}=u.current,{monitor:O}=$;$.renderer=A;const I=[O.addEventListener("beforedragstart",E=>{const P=v.current;P&&T(()=>P(E,$))}),O.addEventListener("dragstart",E=>{var P;return(P=f.current)==null?void 0:P.call(f,E,$)}),O.addEventListener("dragover",E=>{const P=y.current;P&&T(()=>P(E,$))}),O.addEventListener("dragmove",E=>{const P=x.current;P&&T(()=>P(E,$))}),O.addEventListener("dragend",E=>{const P=k.current;P&&T(()=>P(E,$))}),O.addEventListener("collision",E=>{var P;return(P=M.current)==null?void 0:P.call(M,E,$)})];return()=>I.forEach(E=>E())},[$]),ie(g,()=>$&&($.plugins=g),...ns),ie(b,()=>$&&($.sensors=b),...ns),ie(w,()=>$&&($.modifiers=w),...ns),m.jsxs(Md.Provider,{value:$,children:[m.jsx(dp,{ref:u,children:n}),n]})}function hp(e){const t=S.useRef(null);return t.current||(t.current=e()),S.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function fp(){return S.useContext(Md)}function Ed(e){var t;const n=(t=fp())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),qn(r.register,[n,r]),r}var pp=Object.create,Ad=Object.defineProperty,gp=Object.getOwnPropertyDescriptor,Dd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),_i=e=>{throw TypeError(e)},mp=(e,t,n)=>t in e?Ad(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vp=e=>{var t;return[,,,pp((t=e?.[Dd("metadata")])!=null?t:null)]},Td=["class","method","getter","setter","accessor","field","value","get","set"],Pd=e=>e!==void 0&&typeof e!="function"?_i("Function expected"):e,bp=(e,t,n,r,i)=>({kind:Td[e],name:t,metadata:r,addInitializer:s=>n._?_i("Already initialized"):i.push(Pd(s||null))}),yp=(e,t)=>mp(t,Dd("metadata"),e[3]),xp=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},Rd=(e,t,n,r,i,s)=>{for(var o,a,l,c,u=t&7,d=!1,p=!1,h=2,g=Td[u+5],b=e[h]||(e[h]=[]),w=(i=i.prototype,gp(i,n)),v=r.length-1;v>=0;v--)l=bp(u,n,a={},e[3],b),l.static=d,l.private=p,c=l.access={has:f=>n in f},c.get=f=>f[n],o=(0,r[v])(w[g],l),a._=1,Pd(o)&&(w[g]=o);return w&&Ad(i,n,w),i},Wd=(e,t,n)=>t.has(e)||_i("Cannot "+n),wp=(e,t,n)=>(Wd(e,t,"read from private field"),t.get(e)),kp=(e,t,n)=>t.has(e)?_i("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Sp=(e,t,n,r)=>(Wd(e,t,"write to private field"),t.set(e,n),n),Ht=class Bs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Bs(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Bs(t,n)}},Id,zd,Zs,li,Rr,ia=class extends(Zs=Bt,zd=[ce],Id=[ce],Zs){constructor(e){const t=Ht.from(e);super(t,(n,r)=>Ht.equals(n,r)),xp(Rr,5,this),kp(this,li,0),this.velocity={x:0,y:0}}get delta(){return Ht.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=Ht.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-wp(this,li),o=a=>Math.round(a/s*100);oe(()=>{Sp(this,li,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Ht.from(e)),this.velocity={x:0,y:0}}};Rr=vp(Zs);li=new WeakMap;Rd(Rr,2,"delta",zd,ia);Rd(Rr,2,"direction",Id,ia);yp(Rr,ia);var Ld=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ld||{});Object.values(Ld);var jp=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Ht.distance(t.shape.center,n);return{id:r,value:1/i,type:Ln.PointerIntersection,priority:zn.High}}return null},$p=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=Ht.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:Ln.ShapeIntersection,priority:zn.Normal}}return null},Op=e=>{var t;return(t=jp(e))!=null?t:$p(e)};function Cp(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=Ed(u=>new Ni(ap(op({},e),{register:!1,element:Sn(i)}),u)),c=$d(l);return ie(s,()=>l.id=s),ai(i,u=>l.element=u),ie(o,()=>l.accept=o,void 0,ot),ie(t,()=>l.collisionDetector=t??Op),ie(n,()=>n&&(l.data=n)),ie(r,()=>l.disabled=r===!0),ie(a,()=>l.type=a),{droppable:c,get isDropTarget(){return c.isDropTarget},ref:S.useCallback(u=>{var d,p;!u&&(d=l.element)!=null&&d.isConnected&&!((p=l.manager)!=null&&p.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function Mp(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of s.filters??[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],i=new Set;for(const s of e.localGivens??[])i.add(s.name),r.push({name:s.name,...s.label===void 0?{}:{label:s.label},type:s.type,...s.suggest?{field:s.suggest.dimension}:{},origin:"dashboard",local:s,boundTiles:n.get(s.name)??0});for(const s of t)i.has(s.name)||(i.add(s.name),r.push({...s,origin:"model",boundTiles:n.get(s.name)??0}));for(const[s,o]of n)i.has(s)||r.push({name:s,origin:"model",boundTiles:o});return r}function Oi(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Ep(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function ci(e,t){const n=Ep(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const i=new Set(["date","timestamp"]);return i.has(n)?i.has(r):n===r}function La(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function Ap(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Dp=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Tp(e,t){const n=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",r=/^[A-Z_]/.test(n)?n:`F_${n}`,i=new Set(t);if(!i.has(r))return r;for(let s=2;;s++)if(!i.has(`${r}_${s}`))return`${r}_${s}`}const Fa=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"Since a date",hint:"A date picker; tiles keep rows on or after it"}];function qr(e){const t=e.label.trim()||e.name,n=e.field.split(".").at(-1)??e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const Js=e=>e.declaration.kind==="reference";function Pp(e,t){return e.tiles.map(n=>{const r=(n.filters??[]).find(i=>i.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:Oi(t.type)!==void 0?{op:Oi(t.type)}:{}}})}function Rp(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Js(s))return;const o=(s.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function Wp(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function Ip(e,t){for(const r of e.tiles){const i=(r.filters??[]).filter(s=>s.given!==t);i.length>0?r.filters=i:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const zp=Kt(m.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),Lp=Kt(m.jsx("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"})),Fp=Kt(m.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),Np=Kt(m.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),Qs=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),rs=Qs?"⌘":"Ctrl+",_p=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function qp(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=Qs?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!_p(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!Qs&&s&&o==="y"){r.preventDefault(),i.redo();return}if(s&&o==="s"){r.preventDefault(),i.save?.();return}!s&&!r.altKey&&!r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight")&&(r.preventDefault(),i.nudge(r.key==="ArrowRight"?1:-1))}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[])}function Hp({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:l,onSettings:c}){const{theme:u}=tt();return m.jsxs(fl,{left:m.jsx(oo,{size:"medium",variant:"outlined",icon:m.jsx(Lp,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:u.border,color:u.tileTitle,"& .MuiChip-icon":{color:"inherit"},"& .MuiChip-label":{fontSize:"0.875rem"}}}),children:[l&&m.jsx(ge,{startIcon:m.jsx(ml,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),m.jsx(ge,{startIcon:m.jsx(zp,{}),onClick:d=>c(d.currentTarget),children:"Settings"}),m.jsx(hs,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),m.jsx(xn,{title:`Undo (${rs}Z)`,children:m.jsx("span",{children:m.jsx(fs,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:m.jsx(Np,{fontSize:"small"})})})}),m.jsx(xn,{title:`Redo (${rs}⇧Z)`,children:m.jsx("span",{children:m.jsx(fs,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:m.jsx(Fp,{fontSize:"small"})})})}),o&&m.jsx(m.Fragment,{children:m.jsx(xn,{title:i?`Save (${rs}S)`:"",children:m.jsx("span",{children:m.jsx(ge,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,startIcon:!i&&!s?m.jsx(gl,{}):void 0,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&m.jsxs(m.Fragment,{children:[m.jsx(hs,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const Up=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Hr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Na(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Up.includes(n))return n}}const Yp=1;function Fd(e,t,n){const r=[];for(const i of e??[]){const s=i.name,o=i.kind;if(typeof s=="string"){if(o==="dimension"||o==="measure"){const a=i.type?.kind;r.push({name:t+s,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=i.schema?.fields;r.push(...Fd(a,`${t}${s}.`,n-1))}}}return r}function Xp(e){const t=new Map;for(const n of e.sourceInfos??[]){let r;try{r=typeof n=="string"?JSON.parse(n):n}catch{continue}const i=r;i?.name&&t.set(i.name,Fd(i.schema?.fields,"",Yp))}return t}function _a(e,t){return!e||t===void 0?void 0:e.sources.find(n=>n.name===t)?.fields.filter(n=>n.kind==="dimension")}const Vp=e=>(e??"").startsWith("dashboards/"),Kp=e=>e.modelPath??e.path??"";function Gp(e){const t=[],n=new Set;for(const r of e){const i=Kp(r);if(Vp(i))continue;const s=Xp(r);for(const o of r.sources??[]){const a=o.name;if(!a||n.has(a))continue;n.add(a);const l=(o.givens??[]).map(c=>c.name).filter(c=>typeof c=="string");t.push({name:a,modelPath:i,...Hr(o.annotations)?{description:Hr(o.annotations)}:{},views:(o.views??[]).filter(c=>typeof c.name=="string").map(c=>({name:c.name,...Hr(c.annotations)?{description:Hr(c.annotations)}:{},...Na(c.annotations)?{chart:Na(c.annotations)}:{}})),givens:l,fields:s.get(a)??[]})}}return{sources:t}}const vt=e=>`${e.source}.${e.name}`;function Bp(e,t){if(!t)return[];const n=new Set;for(const r of e.sources)n.add(r.base);for(const r of e.imports)if(r.kind==="names")for(const i of r.names)n.add(i);return t.sources.filter(r=>n.has(r.name))}function Zp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=tt(),a=S.useMemo(()=>Bp(t,n),[t,n]),[l,c]=S.useState(""),[u,d]=S.useState(""),[p,h]=S.useState(""),[g,b]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(c(t.sources[0]?.base??a[0]?.name??""),d(""),h(""),b(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(v=>v.name===l);return m.jsx(Ai,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:m.jsxs(m.Fragment,{children:[m.jsx(ge,{onClick:i,children:"Cancel"}),m.jsx(ge,{variant:"contained",disabled:!(l!==""&&u!==""),onClick:()=>s({base:l,view:u,...p.trim()?{label:p.trim()}:{},colspan:g}),children:"Add tile"})]}),children:m.jsx(le,{sx:{gap:2,pt:1},children:a.length===0?m.jsx(Q,{variant:"body2",sx:{color:o.tileTitle},children:n?"This dashboard imports no source by name, so there is nothing to put a tile on. Import a source in the file first.":"The package's sources are still loading."}):m.jsxs(m.Fragment,{children:[m.jsx(De,{select:!0,size:"small",label:"Source",value:l,onChange:v=>{c(v.target.value),d("")},inputProps:{"aria-label":"Source"},children:a.map(v=>m.jsxs(yt,{value:v.name,children:[v.name,v.description&&m.jsx(Q,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:v.description})]},v.name))}),m.jsxs(de,{children:[m.jsx(Q,{variant:"subtitle2",sx:{mb:.5},children:"View"}),m.jsxs(vu,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(v=>m.jsxs(bu,{selected:u===v.name,onClick:()=>d(v.name),"aria-label":`View ${v.name}`,children:[m.jsx(bl,{primary:v.name,secondary:v.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),v.chart&&m.jsx(oo,{size:"small",variant:"outlined",label:v.chart.replace(/_chart$/,"")})]},v.name)),w&&w.views.length===0&&m.jsx(Q,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),m.jsxs(le,{direction:"row",sx:{gap:1.5},children:[m.jsx(De,{size:"small",label:"Title",placeholder:"Uses the view's name",value:p,onChange:v=>h(v.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),m.jsx(De,{size:"small",type:"number",label:`Width (of ${r})`,value:g,onChange:v=>b(Math.min(Math.max(Number(v.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const qa=4e3;function Jp(e,t){const n=e.split(`
|
|
69
|
-
`),r=t.split(`
|
|
70
|
-
`);if(n.length>qa||r.length>qa)return[...n.map(l=>({kind:"del",text:l})),...r.map(l=>({kind:"add",text:l}))];const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let l=n.length-1;l>=0;l--)for(let c=r.length-1;c>=0;c--)i[l][c]=n[l]===r[c]?i[l+1][c+1]+1:Math.max(i[l+1][c],i[l][c+1]);const s=[];let o=0,a=0;for(;o<n.length&&a<r.length;)n[o]===r[a]?(s.push({kind:"same",text:n[o]}),o++,a++):i[o+1][a]>=i[o][a+1]?s.push({kind:"del",text:n[o++]}):s.push({kind:"add",text:r[a++]});for(;o<n.length;)s.push({kind:"del",text:n[o++]});for(;a<r.length;)s.push({kind:"add",text:r[a++]});return s}function Qp(e,t=3){const n=new Array(e.length).fill(!1);e.forEach((s,o)=>{if(s.kind!=="same")for(let a=Math.max(0,o-t);a<=Math.min(e.length-1,o+t);a++)n[a]=!0});const r=[];let i=0;return e.forEach((s,o)=>{n[o]?(i>0&&r.push({kind:"fold",count:i}),i=0,r.push(s)):i++}),i>0&&r.push({kind:"fold",count:i}),r}function eg({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=tt(),o=S.useMemo(()=>e?Qp(Jp(t,n)):[],[e,t,n]),a=o.filter(c=>c.kind==="add").length,l=o.filter(c=>c.kind==="del").length;return m.jsx(Ai,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:m.jsxs(m.Fragment,{children:["A tile was added or removed, which moves declarations. Lines the builder does not own — comments, other Malloy — are left where they were; check they still read right."," ",m.jsxs(de,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",l]})]}),actions:m.jsxs(m.Fragment,{children:[m.jsx(ge,{onClick:i,children:"Keep editing"}),m.jsx(ge,{variant:"contained",onClick:r,children:"Save this"})]}),children:m.jsx(de,{component:"pre","aria-label":"File changes",sx:{m:0,px:2,py:1,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.6,overflowX:"auto",bgcolor:s.background,color:s.foreground},children:o.map((c,u)=>c.kind==="fold"?m.jsx(de,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${c.count} unchanged line${c.count===1?"":"s"}`},u):m.jsxs(de,{component:"span",sx:{display:"block",mx:-2,px:2,whiteSpace:"pre",bgcolor:c.kind==="add"?"rgba(46, 125, 91, 0.16)":c.kind==="del"?"rgba(168, 41, 31, 0.14)":"transparent",textDecoration:c.kind==="del"?"line-through":"none",opacity:c.kind==="del"?.8:1},children:[c.kind==="add"?"+ ":c.kind==="del"?"− ":" ",c.text]},u))})})}const is="self";function tg({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=tt(),[l,c]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(g=>g.source===n.name);c((n.dimensions??[]).map(g=>{const b=h.find(w=>w.name===g.name);return{name:g.name,expression:g.expression,to:b?.to??[],given:b?.given??""}}))},[e,n,t]);const u=(h,g)=>c(b=>b.map((w,v)=>{if(v!==h)return w;const f={...w};return g(f),f})),d=[is,...i.filter(h=>h!==is)],p=h=>h===is?"This dashboard":h;return m.jsx(Ai,{open:e,onClose:s,title:"Clickable cells",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:m.jsxs(m.Fragment,{children:[m.jsx(ge,{onClick:s,children:"Cancel"}),m.jsx(ge,{variant:"contained",onClick:()=>{n&&(o(l.filter(h=>h.to.length>0).map(h=>({source:n.name,name:h.name,expression:h.expression,to:h.to,...h.given?{given:h.given}:{}}))),s())},disabled:l.length===0,children:"Apply"})]}),children:m.jsx(le,{sx:{gap:2,pt:1},children:l.length===0?m.jsx(Q,{variant:"body2",sx:{color:a.tileTitle},children:n?m.jsxs(m.Fragment,{children:[m.jsx(de,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",m.jsx(de,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((h,g)=>m.jsxs(de,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[m.jsxs(de,{sx:{minWidth:0,pt:.75},children:[m.jsx(Q,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:h.name}),m.jsxs(Q,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.expression,children:["is ",h.expression]})]}),m.jsx(De,{select:!0,size:"small",label:"Clicks go to",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:b=>b.length===0?"Not clickable":b.map(p).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:b=>u(g,w=>{const v=b.target.value;w.to=Array.isArray(v)?v:String(v).split(",").filter(Boolean)}),children:d.map(b=>m.jsxs(yt,{value:b,children:[m.jsx(ps,{size:"small",checked:h.to.includes(b),sx:{p:0,mr:1}}),m.jsx(bl,{primary:p(b)})]},b))}),m.jsxs(De,{select:!0,size:"small",label:"Sets the control",value:h.given,disabled:h.to.length===0,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:h.given===""?`Named ${h.name}, like the dimension`:void 0,onChange:b=>u(g,w=>{w.given=b.target.value}),children:[m.jsx(yt,{value:"",children:m.jsx("em",{children:"Same name as the dimension"})}),r.map(b=>m.jsx(yt,{value:b,children:b},b))]})]},h.name))})})}const Nd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function ng({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[c,u]=S.useState({kind:"new"}),[d,p]=S.useState(""),[h,g]=S.useState("select"),[b,w]=S.useState(""),[v,f]=S.useState(""),[y,x]=S.useState([]),[k,M]=S.useState(!1),$=C=>t.sources.find(R=>R.name===C.source)?.base??C.source;S.useEffect(()=>{if(e)if(n){u({kind:"existing",name:n.name}),p(n.label??"");const C=Pp(t,n);x(C);const R=C.filter(j=>j.include),Y=new Set(R.map(j=>j.field));f(Y.size===1?R[0].field:n.field??""),M(Y.size>1)}else u({kind:"new"}),p(""),g("select"),f(""),w(new Date().toISOString().slice(0,10)),x(t.tiles.map(C=>({include:Js(C),field:""}))),M(!1)},[e,n,t]);const A=S.useMemo(()=>[...(t.localGivens??[]).map(C=>C.name),...r.map(C=>C.name)],[t,r]),T=S.useMemo(()=>v.trim()?Tp(v.trim(),A):"",[v,A]),O=c.kind==="existing"?n??r.find(C=>C.name===c.name):T?{name:T,type:qr({name:T,label:d,kind:h,field:v}).type}:void 0,I=O?.type!==void 0&&!O.type.startsWith("filter<"),E=y.find(C=>C.include)?.op??Oi(O?.type),P=(C,R)=>x(Y=>Y.map((j,D)=>D===C?{...j,...R}:j)),Z=C=>x(R=>R.map(Y=>({...Y,op:C}))),G=C=>{const R=Oi(C);x(Y=>Y.map(({op:j,...D})=>R?{...D,op:R}:D))},xe=C=>{u({kind:"existing",name:C.name}),f(C.field??""),G(C.type)},ze=C=>{g(C),G(qr({name:"X",label:d,kind:C,field:v}).type)},re=t.tiles.map(Js),_e=re.filter(Boolean).length,Ke=y.filter((C,R)=>C.include&&re[R]).length,we=t.tiles.filter((C,R)=>(y[R]?.include??!1)&&re[R]),Ge=we.length>0?we:t.tiles.filter((C,R)=>re[R]),qe=S.useMemo(()=>{const C=new Map;let R=!1;for(const Y of Ge){const j=i?.(Y);if(j){R=!0;for(const D of j)C.has(D.name)||C.set(D.name,D)}}return R?[...C.values()]:void 0},[y,t.tiles,i]),Le=(()=>{const C=v.trim();for(const R of we){const Y=i?.(R);if(!Y||Y.some(j=>j.name===C))return $(R)}return we[0]?$(we[0]):t.sources[0]?.base})(),He=C=>x(R=>R.map((Y,j)=>({...Y,include:C&&re[j]}))),ke=S.useMemo(()=>k?y:y.map(C=>({...C,field:v})),[k,y,v]),ee=C=>{for(const R of Ge){const Y=i?.(R)?.find(j=>j.name===C.trim());if(Y?.type)return Y.type}},W=C=>ci(O?.type,C.type),N=(C,R)=>{if(C.trim()==="")return"Pick the field this filter compares.";const Y=R?i?.(R):void 0;if(!Y)return;const j=Y.find(D=>D.name===C.trim());if(!j)return`Not a field of ${R?$(R):"the tiles' source"}.`;if(j.type&&!ci(O?.type,j.type))return`${C.trim()} is ${La(j.type)}; this filter compares ${La(O?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},Se=C=>{if(f(C),l||c.kind!=="new")return;const R=ee(C),Y=qr({name:"X",label:d,kind:h,field:C}).type;R&&!ci(Y,R)&&ze(Ap(R))},te=ke.map((C,R)=>C.include&&re[R]?N(C.field,t.tiles[R]):void 0),Fe=te.every(C=>C===void 0),V=!k&&Ke>0?we.map(C=>N(v,C)).find(Boolean):void 0,it=O!==void 0&&Fe&&(c.kind==="existing"||v.trim()!==""&&T!==""),Oe=()=>{if(!(!O||!it))if(c.kind==="new")s(O.name,ke,qr({name:O.name,label:d.trim()||Nd(O.name),kind:h,field:v.trim(),...Le?{source:Le}:{},...b?{dateDefault:b}:{}}));else if(n?.origin==="dashboard"&&n.local){const C=d.trim(),R=C!==(n.local.label??"");s(O.name,ke,R?{...n.local,...C?{label:C}:{}}:void 0)}else s(O.name,ke)},mt=l&&a.origin==="model";return{editing:l,shown:a,fromModel:mt,source:c,setSource:u,label:d,setLabel:p,kind:h,dateDefault:b,setDateDefault:w,field:v,rows:y,setRows:x,perTile:k,setPerTile:M,newName:T,target:O,valueTyped:I,commonOp:E,setRow:P,setCommonOp:Z,pickExisting:xe,pickKind:ze,bindable:re,bindableCount:_e,included:Ke,commonFields:qe,setAll:He,accepts:W,pickField:Se,rowProblems:te,commonProblem:V,canApply:it,apply:Oe}}function Ha({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:l,autoFocus:c,placeholder:u,sx:d}){const p=S.useMemo(()=>(n??[]).filter(g=>r?.(g)??!0).map(g=>g.name),[n,r]),h=S.useMemo(()=>new Map((n??[]).map(g=>[g.name,g.type])),[n]);return m.jsx(ju,{freeSolo:!0,size:"small",options:p,inputValue:e,onInputChange:(g,b)=>t(b),value:e,onChange:(g,b)=>t(typeof b=="string"?b:""),disabled:l,disableClearable:!0,renderOption:(g,b)=>S.createElement("li",{...g,key:b},m.jsx(Q,{variant:"body2",sx:{flex:1},children:b}),h.get(b)&&m.jsx(Q,{variant:"caption",sx:{opacity:.6},children:h.get(b)?.replace(/_type$/,"")})),renderInput:g=>m.jsx(De,{...g,label:i,placeholder:u,autoFocus:c,error:o,helperText:a,inputProps:{...g.inputProps,"aria-label":s}}),sx:d})}function rg({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:l}=tt(),{editing:c,shown:u,fromModel:d,source:p,setSource:h,label:g,setLabel:b,kind:w,dateDefault:v,setDateDefault:f,field:y,rows:x,setRows:k,perTile:M,setPerTile:$,newName:A,target:T,valueTyped:O,commonOp:I,setRow:E,setCommonOp:P,pickExisting:Z,pickKind:G,bindable:xe,bindableCount:ze,included:re,commonFields:_e,setAll:Ke,accepts:we,pickField:Ge,rowProblems:qe,commonProblem:Le,canApply:He,apply:ke}=ng({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),ee=(W,N,Se)=>m.jsx(De,{select:!0,size:"small",label:"Compares",value:W??">=",onChange:te=>N(te.target.value),inputProps:{"aria-label":Se},sx:{width:130},children:Dp.filter(te=>te.op!=="~").map(te=>m.jsx(yt,{value:te.op,children:te.label},te.op))});return m.jsx(Ai,{open:e,onClose:s,title:c?u.label??u.name:"Add a filter",description:c?m.jsxs(m.Fragment,{children:[m.jsxs(de,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",u.name]}),d?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A control on the page, and the tiles it filters.",actions:m.jsxs(m.Fragment,{children:[c&&m.jsx(ge,{color:"error",onClick:()=>a(u.name),"aria-label":`Remove control ${u.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),m.jsx(ge,{onClick:s,children:"Cancel"}),m.jsx(xn,{title:He||T===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx(ge,{variant:"contained",onClick:ke,disabled:!He,children:c?"Apply":"Add filter"})})})]}),children:m.jsxs(le,{sx:{gap:2.5,pt:1},children:[!c&&r.length>0&&m.jsxs(Cu,{exclusive:!0,size:"small",value:p.kind,onChange:(W,N)=>{N==="new"?h({kind:"new"}):N==="existing"&&r[0]&&Z(r[0])},"aria-label":"Where the filter comes from",children:[m.jsx(ha,{value:"new",children:"New in this dashboard"}),m.jsx(ha,{value:"existing",children:"From the model"})]}),!c&&p.kind==="existing"?m.jsx(De,{select:!0,size:"small",label:"Control",value:p.name,onChange:W=>{const N=r.find(Se=>Se.name===W.target.value);N&&Z(N)},children:r.map(W=>m.jsxs(yt,{value:W.name,children:[W.label??W.name,m.jsxs(Q,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",W.name]})]},W.name))}):null,m.jsxs(le,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!M&&m.jsx(Ha,{value:y,onChange:Ge,fields:_e,accepts:we,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!c,error:Le!==void 0,helperText:Le??(!c&&A?`Declared as $${A}`:void 0),sx:{flex:1,minWidth:200}}),!d&&m.jsx(De,{size:"small",label:"Label",placeholder:A?Nd(A):"",value:g,onChange:W=>b(W.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),O&&!M&&ee(I,P,"Comparison")]}),!c&&p.kind==="new"&&m.jsxs(le,{direction:"row",sx:{gap:1.5},children:[m.jsx(De,{select:!0,size:"small",label:"Control",value:w,onChange:W=>G(W.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:W=>Fa.find(N=>N.kind===W)?.label??String(W)}},sx:{flex:1},children:Fa.map(W=>m.jsxs(yt,{value:W.kind,children:[W.label,m.jsx(Q,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:W.hint})]},W.kind))}),w==="date"&&m.jsx(De,{size:"small",type:"date",label:"Starts at",value:v,onChange:W=>f(W.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),m.jsxs(de,{children:[m.jsxs(le,{direction:"row",sx:{alignItems:"center",gap:.5},children:[m.jsx(ps,{size:"small",checked:ze>0&&re===ze,indeterminate:re>0&&re<ze,disabled:ze===0,onChange:W=>Ke(W.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsxs(Q,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",re," of ",t.tiles.length," tiles"]}),m.jsx(ge,{size:"small",onClick:()=>{M||k(W=>W.map(N=>({...N,field:y}))),$(W=>!W)},children:M?"Same field for all":"Adjust per tile"})]}),m.jsx(le,{sx:{gap:M?1:0},children:t.tiles.map((W,N)=>{const Se=x[N],te=W.label??W.name,Fe=M?qe[N]:void 0;return m.jsxs(le,{direction:"row",sx:{gap:1,alignItems:M?"flex-start":"center",opacity:xe[N]?1:.6},children:[m.jsx(ps,{size:"small",disabled:!xe[N],checked:(Se?.include??!1)&&xe[N],inputProps:{"aria-label":`Filter ${te}`},onChange:V=>E(N,{include:V.target.checked})}),m.jsx(Q,{variant:"body2",sx:{flex:1,minWidth:0,pt:M?1:0},noWrap:!0,children:te}),xe[N]?M&&m.jsxs(m.Fragment,{children:[O&&ee(Se?.op,V=>E(N,{op:V}),`Comparison for ${te}`),m.jsx(Ha,{value:Se?.field??"",onChange:V=>E(N,{field:V}),fields:i?.(W),accepts:we,label:"Field",ariaLabel:`Field for ${te}`,disabled:!Se?.include,error:Fe!==void 0,helperText:Fe,sx:{width:220}})]}):m.jsx(xn,{title:W.declaration.kind==="inherited"?"Declared on its source, which this dashboard does not write.":"Its query is written out here rather than named, so a filter cannot be added to it.",children:m.jsx(Q,{variant:"caption",sx:{color:l.tileTitle},children:W.declaration.kind==="inherited"?"From the model":"Inline query"})})]},`${W.source}.${W.name}`)})}),re===0&&m.jsx(Q,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}function _d(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const l=structuredClone(a);return o(l),l}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const ig=e=>({title:e.title,...e.description===void 0?{}:{description:e.description},...e.columns===void 0?{}:{columns:e.columns},...e.autorun===void 0?{}:{autorun:e.autorun}}),ss=[2,3,4,6,8,12,16,24];function sg({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=tt(),{draft:s,patch:o,close:a}=_d(t,e!==null,r,n),l=s?.columns!==void 0&&!ss.includes(s.columns)?[...ss,s.columns].sort((c,u)=>c-u):ss;return m.jsx(vl,{open:e!==null&&s!==void 0,anchorEl:e,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:380,p:2}}},children:s&&m.jsxs(le,{sx:{gap:1.5},children:[m.jsx(Q,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),m.jsx(De,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:c=>o(u=>{u.title=c.target.value})}),m.jsx(De,{size:"small",label:"Description",multiline:!0,minRows:3,maxRows:10,value:s.description??"",helperText:"Markdown. A blank line starts a new paragraph.",inputProps:{"aria-label":"Dashboard description"},onChange:c=>o(u=>{const d=c.target.value;d.trim()===""?delete u.description:u.description=d})}),m.jsxs(De,{select:!0,size:"small",label:"Grid width",value:s.columns??"",helperText:"Columns across the page. Tiles are placed in these.",inputProps:{"aria-label":"Grid width"},onChange:c=>o(u=>{const d=Number(c.target.value);d?u.columns=d:delete u.columns}),children:[m.jsx(yt,{value:"",children:"Default (2)"}),l.map(c=>m.jsx(yt,{value:c,children:c},c))]}),m.jsx(gu,{control:m.jsx(mu,{size:"small",checked:s.autorun!==!1,slotProps:{input:{"aria-label":"Run as controls change"}},onChange:c=>o(u=>{c.target.checked?delete u.autorun:u.autorun=!1})}),label:m.jsxs(Q,{variant:"body2",children:["Run as controls change",m.jsx(Q,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const og=Kt(m.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function ag({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=tt();return m.jsx(m.Fragment,{children:m.jsxs(le,{sx:{gap:1},children:[m.jsxs(le,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[m.jsx(og,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),m.jsx(Q,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&m.jsx(Q,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const l=n(a.name,a.type);return m.jsx(xn,{title:l.length>0?`$${a.name} · cannot filter on: ${l.join(", ")}`:`$${a.name} · ${a.origin==="dashboard"?"declared here":"from the model"} · ${a.boundTiles} of ${t} tiles`,children:m.jsx(oo,{size:"small",label:a.label??a.name,"aria-label":`Edit filter ${a.name}`,color:l.length>0?"warning":"default",variant:a.origin==="dashboard"?"filled":"outlined",onClick:()=>r(a),sx:{opacity:a.boundTiles===0?.6:1,cursor:"pointer",transition:"opacity 120ms"}})},a.name)}),m.jsx(de,{sx:{ml:"auto"},children:m.jsx(pl,{label:"Filter",icon:m.jsx(ml,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const lg=(e,t)=>e.map((n,r)=>{const i=t[r]??!1;if(i===(n.break??!1))return n;const s={...n};return i?s.break=!0:delete s.break,s}),cg=(e,t,n)=>{const r=[...e],[i]=r.splice(t,1);if(!i)return[...e];const s=r[t];i.break&&s&&!s.break&&(r[t]={...s,break:!0});const o={...i};return delete o.break,r.splice(n,0,o),r},qd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),Hd=e=>`gap.${e}`,dg=(e,t)=>{const n=[];let r=0;e.forEach((s,o)=>{const a=Math.min(s.colspan??1,t),l=o===0||s.break===!0||r+a>t;l&&o>0&&r<t&&n.push({kind:"gap",after:vt(e[o-1]),colspan:t-r}),l&&(r=0),n.push(qd(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:vt(i),colspan:t-r}),n};var ug=Object.create,Ud=Object.defineProperty,hg=Object.defineProperties,fg=Object.getOwnPropertyDescriptor,pg=Object.getOwnPropertyDescriptors,Ci=Object.getOwnPropertySymbols,Yd=Object.prototype.hasOwnProperty,Xd=Object.prototype.propertyIsEnumerable,gg=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Wr=e=>{throw TypeError(e)},eo=(e,t,n)=>t in e?Ud(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,os=(e,t)=>{for(var n in t||(t={}))Yd.call(t,n)&&eo(e,n,t[n]);if(Ci)for(var n of Ci(t))Xd.call(t,n)&&eo(e,n,t[n]);return e},as=(e,t)=>hg(e,pg(t)),mg=(e,t)=>{var n={};for(var r in e)Yd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ci)for(var r of Ci(e))t.indexOf(r)<0&&Xd.call(e,r)&&(n[r]=e[r]);return n},vg=e=>{var t;return[,,,ug((t=void 0)!=null?t:null)]},Vd=["class","method","getter","setter","accessor","field","value","get","set"],ar=e=>e!==void 0&&typeof e!="function"?Wr("Function expected"):e,bg=(e,t,n,r,i)=>({kind:Vd[e],name:t,metadata:r,addInitializer:s=>n._?Wr("Already initialized"):i.push(ar(s||null))}),yg=(e,t)=>eo(t,gg("metadata"),e[3]),Ur=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Kd=(e,t,n,r,i,s)=>{for(var o,a,l,c,u,d=t&7,p=!1,h=!1,g=e.length+1,b=Vd[d+5],w=e[g-1]=[],v=e[g]||(e[g]=[]),f=(i=i.prototype,fg({get[n](){return lr(this,s)},set[n](x){return qt(this,s,x)}},n)),y=r.length-1;y>=0;y--)c=bg(d,n,l={},e[3],v),c.static=p,c.private=h,u=c.access={has:x=>n in x},u.get=x=>x[n],u.set=(x,k)=>x[n]=k,a=(0,r[y])({get:f.get,set:f.set},c),l._=1,a===void 0?ar(a)&&(f[b]=a):typeof a!="object"||a===null?Wr("Object expected"):(ar(o=a.get)&&(f.get=o),ar(o=a.set)&&(f.set=o),ar(o=a.init)&&w.unshift(o));return f&&Ud(i,n,f),i},Gd=(e,t,n)=>t.has(e)||Wr("Cannot "+n),lr=(e,t,n)=>(Gd(e,t,"read from private field"),t.get(e)),Kn=(e,t,n)=>t.has(e)?Wr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qt=(e,t,n,r)=>(Gd(e,t,"write to private field"),t.set(e,n),n);function Ut(e){return e instanceof aa||e instanceof Qd}var Yr=10,xg=class extends Te{constructor(e){super(e);const t=nt(()=>{const{dragOperation:r}=e;if(kr(r.activatorEvent)&&Ut(r.source)&&r.status.initialized){const i=e.registry.plugins.get(Pr);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(r,i)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:s}=i;if(!kr(r.nativeEvent)||!Ut(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:c}=r;if(!c)return;const u=wg(c),{source:d,target:p}=s,{center:h}=s.shape.current,g=[],b=[];oe(()=>{for(const k of l.droppables){const{id:M}=k;if(!k.accepts(d)||M===p?.id&&Ut(k)||!k.element)continue;let $=k.shape;const A=new ut(k.element,{getBoundingClientRect:T=>xr(T,void 0,.2)});!A.height||!A.width||(u=="down"&&h.y+Yr<A.center.y||u=="up"&&h.y-Yr>A.center.y||u=="left"&&h.x-Yr>A.center.x||u=="right"&&h.x+Yr<A.center.x)&&(g.push(k),k.shape=A,b.push(()=>k.shape=$))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(g,lf);oe(()=>b.forEach(k=>k()));const[v]=w;if(!v)return;const{id:f}=v,{index:y,group:x}=d.sortable;o.setDropTarget(f).then(()=>{const{source:k,target:M,shape:$}=s;if(!k||!Ut(k)||!$)return;const{index:A,group:T,target:O}=k.sortable,I=y!==A||x!==T,E=I?O:M?.element;if(!E)return;Yc(E);const P=new ut(E);if(!P)return;const Z=ht.delta(P,ht.from($.current.boundingRectangle),k.alignment);o.move({by:Z}),I?o.setDropTarget(k.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function wg(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}var kg=Object.defineProperty,Sg=Object.defineProperties,jg=Object.getOwnPropertyDescriptors,Ua=Object.getOwnPropertySymbols,$g=Object.prototype.hasOwnProperty,Og=Object.prototype.propertyIsEnumerable,Ya=(e,t,n)=>t in e?kg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))$g.call(t,n)&&Ya(e,n,t[n]);if(Ua)for(var n of Ua(t))Og.call(t,n)&&Ya(e,n,t[n]);return e},on=(e,t)=>Sg(e,jg(t));function Cg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Xr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ls(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Mg(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(f,y)=>f===y||f!==null&&typeof f=="object"&&"id"in f&&f.id===y;if(Array.isArray(e)){const f=e.findIndex(x=>l(x,s.id)),y=e.findIndex(x=>l(x,o.id));if(f===-1||y===-1){if(ls(s)){const x=s.initialIndex,k=s.index;return x===k||x<0||x>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,x,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const x=s.index;if(x!==f)return n(e,f,x)}return n(e,f,y)}const c=Object.entries(e);let u=-1,d,p=-1,h;for(const[f,y]of c)if(u===-1&&(u=y.findIndex(x=>l(x,s.id)),u!==-1&&(d=f)),p===-1&&(p=y.findIndex(x=>l(x,o.id)),p!==-1&&(h=f)),u!==-1&&p!==-1)break;if(u===-1&&ls(s)){const f=s.initialGroup==null?void 0:Xr(e,s.initialGroup),y=s.initialIndex,x=s.group==null?void 0:Xr(e,s.group),k=s.index;if(f==null||x==null||f===x&&y===k)return"preventDefault"in t&&t.preventDefault(),e;if(f===x)return on(sn({},e),{[f]:n(e[f],y,k)});const M=e[f][y];return on(sn({},e),{[f]:[...e[f].slice(0,y),...e[f].slice(y+1)],[x]:[...e[x].slice(0,k),M,...e[x].slice(k)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,b=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(h==null){const f=Xr(e,o.id);if(f!=null){const y=o.shape&&b.y>o.shape.center.y?e[f].length:0;h=f,p=y}}if(d==null||h==null||d===h&&u===p){if(d!=null&&d===h&&u===p&&ls(s)){const f=s.group==null?void 0:Xr(e,s.group),y=s.group!=null&&f!==d,x=s.index!==u;if(y||x){const k=s.group==null?d:f;if(k!=null){if(d===k)return on(sn({},e),{[d]:n(e[d],u,s.index)});const M=e[d][u];return on(sn({},e),{[d]:[...e[d].slice(0,u),...e[d].slice(u+1)],[k]:[...e[k].slice(0,s.index),M,...e[k].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===h)return on(sn({},e),{[d]:n(e[d],u,p)});const w=o.shape&&Math.round(b.y)>Math.round(o.shape.center.y)?1:0,v=e[d][u];return on(sn({},e),{[d]:[...e[d].slice(0,u),...e[d].slice(u+1)],[h]:[...e[h].slice(0,p+w),v,...e[h].slice(p+w)]})}function Eg(e,t){return Mg(e,t,Cg)}function Xa(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Va(e,t,n){var r;for(const[i,s]of t)for(const o of s){const a=e.get(o.id);if(o.index!==a||o.group!==i||!((r=n.get(i))!=null&&r.has(o)))return!0}return!1}var Ka="__default__",Ag=class extends Te{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof aa){const{sortable:s}=i,{group:o}=s;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(s)}return r},n=[e.monitor.addEventListener("dragover",(r,i)=>{if(this.disabled)return;const{dragOperation:s}=i,{source:o,target:a}=s;if(!Ut(o)||!Ut(a)||o.sortable===a.sortable)return;const l=t(),c=Xa(l),u=o.sortable.group===a.sortable.group,d=l.get(o.sortable.group),p=u?d:l.get(a.sortable.group);!d||!p||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var h,g;const b=t();if(Va(c,l,b))return;const w=o.sortable.element,v=a.sortable.element;if(!v||!w||!u&&a.id===o.sortable.group)return;const f=Vr(d),y=u?f:Vr(p),x=(h=o.sortable.group)!=null?h:Ka,k=(g=a.sortable.group)!=null?g:Ka,M={[x]:f,[k]:y},$=Eg(M,r);if(M===$)return;const A=$[k].indexOf(o.sortable),T=$[k].indexOf(a.sortable);i.collisionObserver.disable(),Ga(w,A,v,T),oe(()=>{for(const[O,I]of $[x].entries())I.index=O;if(!u)for(const[O,I]of $[k].entries())I.group=a.sortable.group,I.index=O}),i.actions.setDropTarget(o.id).then(()=>i.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,i)=>{if(!r.canceled)return;const{dragOperation:s}=i,{source:o}=s;Ut(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=Xa(a),c=a.get(o.sortable.initialGroup);c&&i.renderer.rendering.then(()=>{const u=t();if(Va(l,a,u))return;const d=Vr(c),p=Vr(c,Tg),h=o.sortable.element,g=p.indexOf(o.sortable),b=d[g],w=b?.element;!b||!w||!h||(Ga(h,b.index,w,o.index),oe(()=>{for(const v of a.values()){const f=Array.from(v).values();for(const y of f)y.index=y.initialIndex,y.group=y.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Ga(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function Dg(e,t){return e.index-t.index}function Tg(e,t){return e.initialIndex-t.initialIndex}function Vr(e,t=Dg){return Array.from(e).sort(t)}var Ba=[xg,Ag],Bd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function Za(e){var t,n;return typeof e=="boolean"?{draggable:e,droppable:e}:{draggable:(t=e?.draggable)!=null?t:!1,droppable:(n=e?.droppable)!=null?n:!1}}var Kr=new Uu,Zd,Jd,Dt,sa,cr,dr,oa,mn;Jd=[H],Zd=[H];var qi=class{constructor(e,t){Kn(this,sa,Ur(Dt,8,this)),Ur(Dt,11,this),Kn(this,cr),Kn(this,dr),Kn(this,oa,Ur(Dt,12,this)),Ur(Dt,15,this),Kn(this,mn),this.register=()=>(oe(()=>{var g,b;(g=this.manager)==null||g.registry.register(this.droppable),(b=this.manager)==null||b.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{oe(()=>{var g,b;(g=this.manager)==null||g.registry.unregister(this.droppable),(b=this.manager)==null||b.registry.unregister(this.draggable)})},this.destroy=()=>{oe(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:l,transition:c=Bd,plugins:u}=n,d=mg(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const p=lt(u,Ba),h=Za(i);this.droppable=new aa(as(os({},d),{disabled:h.droppable}),t,this),this.draggable=new Qd(as(os({},d),{disabled:h.draggable,plugins:p,effects:()=>[()=>{var g,b,w;const v=(g=this.manager)==null?void 0:g.dragOperation.status;v?.initializing&&this.id===((w=(b=this.manager)==null?void 0:b.dragOperation.source)==null?void 0:w.id)&&Kr.clear(this.manager),v?.dragging&&Kr.set(this.manager,this.id,q(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:g,group:b,manager:w}=this,v=lr(this,dr),f=lr(this,cr);(g!==v||b!==f)&&(qt(this,dr,g),qt(this,cr,b),this.animate())},()=>{var g,b;const{target:w}=this,{isDragSource:v}=this.draggable;((b=(g=this.draggable.pluginConfig(Bo))==null?void 0:g.feedback)!=null?b:"default")==="move"&&v&&(this.droppable.disabled=!w)},...r()],type:l,sensors:a}),t,this),qt(this,mn,d.element),this.manager=t,this.index=o,qt(this,dr,o),this.group=s,qt(this,cr,s),this.type=l,this.transition=c}get initialIndex(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){q(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:i}=this;if(!i)return;for(const u of i.getAnimations())"transitionProperty"in u&&(u.transitionProperty==="transform"||u.transitionProperty==="translate"||u.transitionProperty==="scale")&&u.cancel();const s=this.refreshShape();if(!s)return;const o={x:n.boundingRectangle.left-s.boundingRectangle.left,y:n.boundingRectangle.top-s.boundingRectangle.top},{translate:a}=gt(i),l=Ma(i,a,!1),c=Ma(i,a);if(o.x||o.y){const u=qo(Ve(i))?as(os({},t),{duration:0}):t;Xc({element:i,keyframes:{translate:[`${l.x+o.x}px ${l.y+o.y}px ${l.z}`,`${c.x}px ${c.y}px ${c.z}`]},options:u}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){oe(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){oe(()=>{const t=lr(this,mn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),qt(this,mn,e)})}get element(){var e,t;const n=lr(this,mn);if(n)return(t=(e=Ps.get(n))!=null?e:n)!=null?t:this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){const{disabled:e}=this.draggable,{disabled:t}=this.droppable;return e===t?e:{draggable:e,droppable:t}}set plugins(e){this.draggable.plugins=lt(e,Ba)}set disabled(e){const t=Za(e);oe(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){oe(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??Vc}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){oe(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};Dt=vg();sa=new WeakMap;cr=new WeakMap;dr=new WeakMap;oa=new WeakMap;mn=new WeakMap;Kd(Dt,4,"index",Jd,qi,sa);Kd(Dt,4,"group",Zd,qi,oa);yg(Dt,qi);var Qd=class extends Fi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},aa=class extends Ni{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Pg=Object.defineProperty,Rg=Object.defineProperties,Wg=Object.getOwnPropertyDescriptors,Ja=Object.getOwnPropertySymbols,Ig=Object.prototype.hasOwnProperty,zg=Object.prototype.propertyIsEnumerable,Qa=(e,t,n)=>t in e?Pg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cs=(e,t)=>{for(var n in t||(t={}))Ig.call(t,n)&&Qa(e,n,t[n]);if(Ja)for(var n of Ja(t))zg.call(t,n)&&Qa(e,n,t[n]);return e},Lg=(e,t)=>Rg(e,Wg(t));function Fg(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:l,group:c,disabled:u,modifiers:d,sensors:p,target:h,type:g,plugins:b}=e,w=cs(cs({},Bd),e.transition),v=Ed(y=>new qi(Lg(cs({},e),{transition:w,register:!1,handle:Sn(a),element:Sn(o),target:Sn(h)}),y)),f=$d(v,Ng);return ie(i,()=>v.id=i),qn(()=>{oe(()=>{v.group=c,v.index=l})},[v,c,l]),ie(g,()=>v.type=g),ie(t,()=>v.accept=t,void 0,ot),ie(s,()=>s&&(v.data=s)),ie(l,()=>{var y;(y=v.manager)!=null&&y.dragOperation.status.idle&&w?.idle&&v.refreshShape()},np),ai(a,y=>v.handle=y),ai(o,y=>v.element=y),ai(h,y=>v.target=y),ie(u,()=>v.disabled=u??!1,void 0,ot),ie(p,()=>v.sensors=p,void 0,ot),ie(n,()=>v.collisionDetector=n),ie(r,()=>v.collisionPriority=r),ie(b,()=>v.plugins=b,void 0,ot),ie(w,()=>v.transition=w,void 0,ot),ie(d,()=>v.modifiers=d,void 0,ot),ie(e.alignment,()=>v.alignment=e.alignment),{sortable:f,get isDragging(){return f.isDragging},get isDropping(){return f.isDropping},get isDragSource(){return f.isDragSource},get isDropTarget(){return f.isDropTarget},handleRef:S.useCallback(y=>{v.handle=y??void 0},[v]),ref:S.useCallback(y=>{var x,k;!y&&(x=v.element)!=null&&x.isConnected&&!((k=v.manager)!=null&&k.dragOperation.status.idle)||(v.element=y??void 0)},[v]),sourceRef:S.useCallback(y=>{var x,k;!y&&(x=v.source)!=null&&x.isConnected&&!((k=v.manager)!=null&&k.dragOperation.status.idle)||(v.source=y??void 0)},[v]),targetRef:S.useCallback(y=>{var x,k;!y&&(x=v.target)!=null&&x.isConnected&&!((k=v.manager)!=null&&k.dragOperation.status.idle)||(v.target=y??void 0)},[v])}}function Ng(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const to="tile",eu="gap",_g='[role="separator"]',qg=[Vs.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Vs.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(_g)!==null}),vd],Hg=e=>[...e,Bo.configure({feedback:"clone"})];function Ug({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=Fg({id:e,index:t,type:to,accept:to,collisionDetector:Uo,plugins:Hg});return m.jsx(m.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function Yg({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=Cp({id:e,type:eu,accept:to,collisionDetector:Uo,data:{after:t}});return m.jsx(m.Fragment,{children:n({ref:r,isDropTarget:i})})}const Xg=Kt(m.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),Vg=Kt(m.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}));function Kg({tile:e,index:t,selected:n,menuOpen:r,resizeSpan:i,columns:s,onSelect:o,onOpenMenu:a,onResizeStart:l,onResizeMove:c,onResizeEnd:u,children:d}){const{theme:p}=tt();return m.jsx(Ug,{id:vt(e),index:t,children:({ref:h,handleRef:g,isDragSource:b})=>m.jsxs(de,{ref:h,onClick:o,onPointerDown:w=>{w.button===0&&o()},"aria-label":`Tile ${e.name}`,"aria-current":n,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",borderRadius:1,outline:n?`2px solid ${p.drillLink}`:"2px solid transparent",outlineOffset:2,transition:"outline-color 120ms, opacity 120ms, box-shadow 120ms","&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.22)"},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${p.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?p.drillLink:p.border,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[d,m.jsx(de,{ref:g,className:"builder-affordance","aria-label":`Move ${e.label??e.name}`,sx:{position:"absolute",top:"2px",left:"2px",display:"grid",placeItems:"center",width:"22px",height:"22px",borderRadius:"4px",cursor:"grab",touchAction:"none",zIndex:2,color:p.tileTitle,bgcolor:p.tile,opacity:b||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${p.drillLink}`,outlineOffset:1}},children:m.jsx(Xg,{sx:{fontSize:16}})}),i===void 0&&m.jsx(fs,{className:"builder-affordance",size:"small","aria-label":`Settings for ${e.label??e.name}`,onClick:w=>{w.stopPropagation(),a(w.currentTarget)},sx:{position:"absolute",top:"2px",right:"2px",width:22,height:22,zIndex:2,color:p.tileTitle,bgcolor:p.tile,opacity:n||r?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:p.tile}},children:m.jsx(Vg,{sx:{fontSize:16}})}),i!==void 0&&m.jsxs(de,{"aria-hidden":!0,sx:{position:"absolute",top:"6px",right:"6px",px:.75,py:.25,borderRadius:"4px",bgcolor:p.drillLink,color:p.tile,fontSize:11,fontVariantNumeric:"tabular-nums",zIndex:4,pointerEvents:"none"},children:[i," of ",s," ·"," ",Math.round(i/s*100),"%"]}),e.declaration.kind!=="inherited"&&m.jsx(de,{className:"builder-affordance",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label??e.name}`,onPointerDown:l,onPointerMove:c,onPointerUp:u,onPointerCancel:u,sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:1,opacity:i!==void 0||n?1:0,transition:"opacity 120ms","&:hover":{opacity:1},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:p.drillLink}}})]})})}function Gg({tile:e}){const{theme:t}=tt();return m.jsxs(fu,{sx:{minHeight:140},children:[m.jsx(pu,{title:e.label??e.name,subtitle:e.subtitle}),m.jsxs(Q,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function Bg({after:e}){const{theme:t}=tt();return m.jsx(Yg,{id:Hd(e),after:e,children:({ref:n,isDropTarget:r})=>m.jsx(de,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.drillLink}`,bgcolor:r?t.tile:"transparent",opacity:r?.95:.4,transition:"opacity 120ms, background-color 120ms"}})})}function Zg({columns:e}){const{theme:t}=tt();return m.jsx(de,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${Zr}px`},children:Array.from({length:e},(n,r)=>m.jsx(de,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var Jg=Object.defineProperty,Qg=Object.defineProperties,em=Object.getOwnPropertyDescriptors,el=Object.getOwnPropertySymbols,tm=Object.prototype.hasOwnProperty,nm=Object.prototype.propertyIsEnumerable,tl=(e,t,n)=>t in e?Jg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,an=(e,t)=>{for(var n in t||(t={}))tm.call(t,n)&&tl(e,n,t[n]);if(el)for(var n of el(t))nm.call(t,n)&&tl(e,n,t[n]);return e},ln=(e,t)=>Qg(e,em(t));function rm(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Gr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ds(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function im(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(f,y)=>f===y||f!==null&&typeof f=="object"&&"id"in f&&f.id===y;if(Array.isArray(e)){const f=e.findIndex(x=>l(x,s.id)),y=e.findIndex(x=>l(x,o.id));if(f===-1||y===-1){if(ds(s)){const x=s.initialIndex,k=s.index;return x===k||x<0||x>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,x,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const x=s.index;if(x!==f)return n(e,f,x)}return n(e,f,y)}const c=Object.entries(e);let u=-1,d,p=-1,h;for(const[f,y]of c)if(u===-1&&(u=y.findIndex(x=>l(x,s.id)),u!==-1&&(d=f)),p===-1&&(p=y.findIndex(x=>l(x,o.id)),p!==-1&&(h=f)),u!==-1&&p!==-1)break;if(u===-1&&ds(s)){const f=s.initialGroup==null?void 0:Gr(e,s.initialGroup),y=s.initialIndex,x=s.group==null?void 0:Gr(e,s.group),k=s.index;if(f==null||x==null||f===x&&y===k)return"preventDefault"in t&&t.preventDefault(),e;if(f===x)return ln(an({},e),{[f]:n(e[f],y,k)});const M=e[f][y];return ln(an({},e),{[f]:[...e[f].slice(0,y),...e[f].slice(y+1)],[x]:[...e[x].slice(0,k),M,...e[x].slice(k)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,b=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(h==null){const f=Gr(e,o.id);if(f!=null){const y=o.shape&&b.y>o.shape.center.y?e[f].length:0;h=f,p=y}}if(d==null||h==null||d===h&&u===p){if(d!=null&&d===h&&u===p&&ds(s)){const f=s.group==null?void 0:Gr(e,s.group),y=s.group!=null&&f!==d,x=s.index!==u;if(y||x){const k=s.group==null?d:f;if(k!=null){if(d===k)return ln(an({},e),{[d]:n(e[d],u,s.index)});const M=e[d][u];return ln(an({},e),{[d]:[...e[d].slice(0,u),...e[d].slice(u+1)],[k]:[...e[k].slice(0,s.index),M,...e[k].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===h)return ln(an({},e),{[d]:n(e[d],u,p)});const w=o.shape&&Math.round(b.y)>Math.round(o.shape.center.y)?1:0,v=e[d][u];return ln(an({},e),{[d]:[...e[d].slice(0,u),...e[d].slice(u+1)],[h]:[...e[h].slice(0,p+w),v,...e[h].slice(p+w)]})}function sm(e,t){return im(e,t,rm)}function om({tiles:e,commit:t,onLanded:n}){const[r,i]=S.useState(void 0),s=S.useRef(void 0),[o,a]=S.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),s.current=e},onDragOver:l=>{const{source:c,target:u}=l.operation;if(!c||!u)return;const d=s.current??e;let p;if(u.type===eu){const{after:h}=u.data,g=d.findIndex(w=>vt(w)===c.id);if(g<0||h===c.id)return;const b=d.filter((w,v)=>v!==g).findIndex(w=>vt(w)===h)+1;p=cg(d,g,b)}else{const h=d.map(vt),g=sm(h,l);if(g.every((w,v)=>w===h[v]))return;const b=new Map(d.map(w=>[vt(w),w]));p=lg(g.map(w=>b.get(w)),e.map(w=>w.break??!1))}s.current=p,i(p)},onDragEnd:l=>{a(!1);const c=s.current;if(s.current=void 0,i(void 0),l.canceled||!c)return;t(c);const u=c.findIndex(d=>vt(d)===l.operation.source?.id);u>=0&&n(u)}}}const nl=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function am({tiles:e,columns:t,onStart:n,commit:r}){const[i,s]=S.useState(void 0),o=S.useRef(null);return{resize:i,gridBox:o,startResize:(a,l)=>{const c=o.current?.getBoundingClientRect(),u=a.currentTarget.parentElement?.getBoundingClientRect();!c||!u||(a.stopPropagation(),a.preventDefault(),a.currentTarget.setPointerCapture(a.pointerId),nl(!0),n(l),s({index:l,span:e[l]?.colspan??1,left:u.left,track:(c.width-Zr*(t-1))/t}))},onResize:a=>{if(!i)return;const l=a.clientX-i.left,c=Math.round((l+Zr)/(i.track+Zr)),u=Math.min(Math.max(c,1),t);u!==i.span&&s({...i,span:u})},endResize:a=>{if(a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId),nl(!1),!i)return;const{index:l,span:c}=i;s(void 0),r(l,c)}}}function lm({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=tt(),{draft:l,patch:c,close:u,discard:d}=_d(t,e!==null,r,n),p=l!==void 0&&l.declaration.kind!=="inherited";return m.jsx(vl,{open:e!==null&&l!==void 0,anchorEl:e,onClose:u,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:l&&m.jsxs(le,{sx:{gap:1.5},children:[m.jsxs(Q,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[l.source," → ",l.name]}),p?m.jsxs(m.Fragment,{children:[m.jsx(De,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:h=>c(g=>{const b=h.target.value;b===""?delete g.label:g.label=b})}),m.jsx(De,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:h=>c(g=>{const b=h.target.value;b===""?delete g.subtitle:g.subtitle=b})}),m.jsxs(le,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[m.jsx(Q,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([h,g])=>{const b=Math.max(1,Math.round(s/g)),w=(l.colspan??1)===b;return m.jsx(ge,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${h}`,"aria-pressed":w,onClick:()=>c(v=>{v.colspan=b}),sx:{minWidth:40,px:1},children:h},h)})]})]}):m.jsx(Q,{variant:"body2",sx:{color:a.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),m.jsx(hs,{}),m.jsxs(le,{direction:"row",sx:{justifyContent:"space-between"},children:[p?m.jsx(ge,{size:"small",onClick:()=>{u(),o()},children:"Clickable cells…"}):m.jsx("span",{}),m.jsx(ge,{color:"error",size:"small",onClick:()=>{d(),i()},children:"Remove tile"})]})]})})}const no=e=>e.ok===!1;function Vt(e,t){let n=t;for(let i=t-1;i>=0;i--){const s=e[i].trim();if(s==="")break;if(s.startsWith("#")||s.startsWith("//"))n=i;else break}const r=[];for(let i=n;i<t;i++){const s=e[i].trim();s.startsWith("#")&&!s.startsWith("##")&&r.push({line:i,text:s})}return{start:n,tags:r}}const ro=e=>e.map(t=>t.text);function cm(e){const t=[],n=[];for(const r of e){const i=r.trim();if(i.startsWith('##"'))t.push(i.slice(3).trim());else{if(i.startsWith("##!"))continue;i.startsWith("##")&&n.push(i)}}return{description:t.length>0?t.join(`
|
|
71
|
-
`):void 0,artifact:n}}function dm(e,t){return new RegExp(`source:\\s*${t}\\s+is\\s+([A-Za-z_][A-Za-z0-9_.]*)`).exec(e)?.[1]}function um(e,t){const n=new RegExp(`view:\\s*${t}\\s+is\\s+([A-Za-z_][A-Za-z0-9_.]*)\\s*(\\+\\s*\\{[\\s\\S]*\\})?`).exec(e);if(n)return{kind:"reference",from:n[1],refinement:n[2]?.trim()};if(new RegExp(`view:\\s*${t}\\s+is\\s*\\{`).test(e))return{kind:"inline"}}const tu=/where:\s*([A-Za-z_][A-Za-z0-9_.]*)\s*(~|>=|<=|!=|=|>|<)\s*\$([A-Za-z_][A-Za-z0-9_]*)/g;function hm(e){if(!e)return;const t=[];for(const n of e.matchAll(tu))t.push({field:n[1],given:n[3],...n[2]==="~"?{}:{op:n[2]}});return t.length>0?t:void 0}function fm(e,t){const n=[];for(const r of yl(e).values()){const i=/^([A-Z_][A-Z0-9_]*)\s*::\s*(\S+)\s+is\s+(.+)$/.exec(r.declaration);i&&n.push({name:i[1],type:i[2],default:i[3].trim(),...pm(t(ro(Vt(e,r.line).tags)).tag)})}return n.length>0?n:void 0}function pm(e){if(!e)return{};const t=e.tag("suggest"),n=t?.text("dimension"),r=e.numeric("range_min"),i=e.numeric("range_max");return{...e.text("label")===void 0?{}:{label:e.text("label")},...e.text("description")===void 0?{}:{description:e.text("description")},...e.text("control")===void 0?{}:{control:e.text("control")},...t&&n?{suggest:{...t.text("source")===void 0?{}:{source:t.text("source")},...t.text("query")===void 0?{}:{query:t.text("query")},dimension:n}}:{},...r===void 0?{}:{rangeMin:r},...i===void 0?{}:{rangeMax:i}}}function gm(e){const t=e.search(/tiles\s*=\s*\[/);if(t<0)return[];const n=e.indexOf("[",t),r=e.indexOf("]",n);return r<0?[]:[...e.slice(n+1,r).matchAll(/"([^"]+)"/g)].map(i=>i[1])}async function io(e){const{Malloy:t}=await ua(async()=>{const{Malloy:x}=await import("./index-9jIrTEvL.js").then(k=>k.i);return{Malloy:x}},__vite__mapDeps([0,1,2,3,4])),{parseAnnotation:n}=await ua(async()=>{const{parseAnnotation:x}=await import("./index-BU0_UiMu.js").then(k=>k.i);return{parseAnnotation:x}},__vite__mapDeps([5,1,2,3])),r=e.split(`
|
|
72
|
-
`);let i;try{i=t.parse({source:e}).symbols}catch(x){return{ok:!1,reason:`This file is not valid Malloy: ${x}`}}const{description:s,artifact:o}=cm(r),a=o.find(x=>x.includes("artifact"));if(a===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};const l=n([a.replace(/^##\s*/,"# ")]).tag,c=l?.tag("artifact"),u=gm(a);if(u.length===0)return{ok:!1,reason:"The `## artifact` tag names no tiles, so there is nothing to lay out."};const d=[],p=[],h=[],g=new Map;for(const x of i){if(x.type==="import"){const O=(x.children??[]).filter(I=>I.type==="import_item").map(I=>String(I.name));d.push(O.length>0?{kind:"names",names:O,from:String(x.name)}:{kind:"all",from:String(x.name)});continue}if(x.type!=="explore")continue;const k=String(x.name),M=r[x.range.start.line]??"",$=dm(M,k);if($===void 0)return{ok:!1,reason:`Could not read what source \`${k}\` extends.`,line:x.range.start.line+1};p.push({name:k,base:$});const A=us(r,k,"view"),T=us(r,k,"dimension");T.size>0&&(p[p.length-1].dimensions=[...T].map(([O,I])=>({name:O,expression:I.rest})));for(const[O,I]of T){const{tags:E}=Vt(r,I.line),P=n(ro(E)).tag?.tag("drill");if(!P)continue;const Z=P.textArray("to")??[P.text("to")??""];h.push({source:k,name:O,expression:I.rest,to:Z.filter(Boolean),...P.text("given")?{given:P.text("given")}:{}})}g.set(k,A)}const b=[];for(const x of u){const k=hu(x);if(!k)return{ok:!1,reason:`The tile \`${x}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:M,view:$}=k,A=g.get(M)?.get($)?.line;if(A===void 0){b.push({name:$,source:M,declaration:{kind:"inherited"}});continue}const T=um(r[A],$);if(T===void 0)return{ok:!1,reason:`Could not read what view \`${$}\` is declared from.`,line:A+1};const{tags:O}=Vt(r,A),I=n(ro(O)).tag,E=T.kind==="reference"?hm(T.refinement):void 0;b.push({name:$,source:M,declaration:T.kind==="reference"?{kind:"reference",from:T.from}:{kind:"inline"},...E?{filters:E}:{},...I?.text("label")?{label:I.text("label")}:{},...I?.text("subtitle")?{subtitle:I.text("subtitle")}:{},...I?.numeric("colspan")!==void 0?{colspan:I.numeric("colspan")}:{},...I?.has("break")?{break:!0}:{},...I?.has("borderless")?{borderless:!0}:{}})}const w=fm(r,n),v={},f=c?.tag("givens");for(const x of Object.keys(f?.dict??{})){const k=f?.text(x);k!==void 0&&(v[x]=k)}const y=l?.tag("dashboard")?.numeric("columns");return{ok:!0,document:{title:c?.text("title")??"",...s?{description:s}:{},...y===void 0?{}:{columns:y},...c?.has("autorun")?{autorun:c.isTrue("autorun")}:{},imports:d,sources:p,...w?{localGivens:w}:{},...Object.keys(v).length>0?{startingGivens:v}:{},...h.length>0?{drills:h}:{},tiles:b}}}const rl=e=>e.ok===!1;function ye(e){const t=n=>{if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){const r={};for(const i of Object.keys(n).sort())r[i]=t(n[i]);return r}return n};return JSON.stringify(t(e))}function mm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
73
|
-
`&&t.push(n+1);return t}function vm(e,t){let n=e;for(const r of[...t].sort((i,s)=>s.start-i.start))n=n.slice(0,r.start)+r.text+n.slice(r.end);return n}function nu(e){const t=[];return e.colspan!==void 0&&t.push(`# colspan=${e.colspan}`),e.break&&t.push("# break"),e.borderless&&t.push("# borderless"),e.label!==void 0&&t.push(`# label=${An(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${An(e.subtitle)}`),t}function di(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const bm=new Set(["colspan","break","borderless","label","subtitle"]),ym=new Set(["label","description","control","suggest","range_min","range_max"]),xm=(e,t)=>ye(e.imports)===ye(t.imports);function il(e){const t=[];if(e.label!==void 0&&t.push(`label=${An(e.label)}`),e.description!==void 0&&t.push(`description=${An(e.description)}`),e.control!==void 0&&t.push(`control=${e.control}`),e.suggest){const n=e.suggest.source!==void 0?`source=${e.suggest.source}`:e.suggest.query!==void 0?`query=${e.suggest.query}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${e.suggest.dimension} }`)}return e.rangeMin!==void 0&&t.push(`range_min=${e.rangeMin}`),e.rangeMax!==void 0&&t.push(`range_max=${e.rangeMax}`),t.length>0?`# ${t.join(" ")}`:void 0}const sl=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function Mi(e,t){let n=0,r=!1;for(let i=t;i<e.length;i++){for(const s of e[i])s==="{"?(n++,r=!0):s==="}"&&n--;if(r&&n<=0||!r&&i===t)return i}return e.length-1}const ol=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function wm(e,t,n){const r=e.findIndex(o=>new RegExp(`\\bsource:\\s*${ol(t)}\\s+is\\b`).test(o));if(r<0)return-1;const i=Mi(e,r),s=new RegExp(`\\bview:\\s*${ol(n)}\\s+is\\b`);for(let o=r;o<=i;o++)if(s.test(e[o]))return o;return-1}function al(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(t=>`"${t}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Ei=e=>`${e.source}.${e.name}`,An=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,so=e=>ye([e.name,e.source,e.declaration]),bt=so,ll=e=>ye(e.tiles.map(bt));function km(e,t){const n=new Set(e.tiles.map(bt)),r=new Set(t.tiles.map(bt)),i=e.tiles.filter(u=>!r.has(bt(u))),s=t.tiles.filter(u=>!n.has(bt(u))),o=i.length>0||s.length>0||ll(e)!==ll(t);for(const u of s)if(u.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${u.name}\` is ${u.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const a=new Map(e.sources.map(u=>[u.name,u])),l=new Set(e.imports.flatMap(u=>u.kind==="names"?u.names:[]));for(const u of e.sources)l.add(u.base);const c=t.sources.filter(u=>!a.has(u.name));for(const u of e.sources){const d=t.sources.find(p=>p.name===u.name);if(!d||d.base!==u.base)return{ok:!1,reason:`The source \`${u.name}\` cannot be changed or removed here.`}}for(const u of c){if(!s.some(d=>d.source===u.name))return{ok:!1,reason:`A new source \`${u.name}\` needs a tile on it.`};if(!l.has(u.base))return{ok:!1,reason:`\`${u.base}\` is not imported by name in this file, so a tile cannot be put on it. The builder does not add imports: import { ${u.base} } from the model first.`}}return xm(e,t)?{currentKeys:n,nextKeys:r,removedTiles:i,addedTiles:s,newSources:c,currentSources:a,reordered:o}:{ok:!1,reason:"The dashboard's imports cannot be changed here."}}function Sm(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const l=gs(t);if(l<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const c=[...t[l].matchAll(/"([^"]+)"/g)].map(g=>g[1]),u=new Map;for(const g of c){const b=g.split("->").map(w=>w.trim());b.length===2&&u.set(`${b[0]}->${b[1]}`,g)}const d=r.tiles.map(g=>u.get(`${g.source}->${g.name}`)??(o.has(bt(g))&&!s.has(bt(g))?`${g.source} -> ${g.name}`:void 0));if(d.some(g=>g===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const p=`tiles=[${d.map(g=>`"${g}"`).join(", ")}]`,h=t[l].replace(/tiles\s*=\s*\[[\s\S]*?\]/,p);h!==t[l]&&a.push({...n(l),text:`${h}
|
|
74
|
-
`})}}function jm(e){const{lines:t,wholeLine:n,current:r,next:i,edits:s}=e;if(r.title!==i.title||r.autorun!==i.autorun||r.columns!==i.columns||ye(r.startingGivens)!==ye(i.startingGivens)){const o=gs(t);if(o<0)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=s.find(b=>b.start===n(o).start&&b.end===n(o).end);let l=a?a.text.replace(/\n$/,""):t[o];const c=l.indexOf("artifact"),u=l.indexOf("{",c);let d=0,p=-1;for(let b=u;b<l.length;b++)if(l[b]==="{")d++;else if(l[b]==="}"&&--d===0){p=b;break}if(u<0||p<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let h=l.slice(u+1,p);const g=(b,w)=>{const v=new RegExp(`\\s*\\b${b}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);w===void 0?h=h.replace(v,""):v.test(h)?h=h.replace(v,` ${b}=${w}`):h=`${h.replace(/\s+$/,"")} ${b}=${w} `};if(r.title!==i.title&&g("title",i.title?An(i.title):void 0),r.autorun!==i.autorun&&g("autorun",i.autorun===void 0?void 0:String(i.autorun)),ye(r.startingGivens)!==ye(i.startingGivens)){h=h.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const b=Object.entries(i.startingGivens??{});b.length>0&&(h=`${h.replace(/\s+$/,"")} givens { ${b.map(([w,v])=>`${w}=${An(v)}`).join(" ")} }`)}h=h.replace(/\s{2,}/g," "),l=`${l.slice(0,u+1)}${h.startsWith(" ")?h:` ${h}`}${h.endsWith(" ")?"":" "}${l.slice(p)}`,r.columns!==i.columns&&(l=l.replace(/\s*dashboard\s*\{[^}]*\}/,""),i.columns!==void 0&&(l=`${l.trimEnd()} dashboard { columns=${i.columns} }`)),a?a.text=`${l}
|
|
75
|
-
`:s.push({...n(o),text:`${l}
|
|
76
|
-
`})}if(r.description!==i.description){const o=t.map((l,c)=>l.trim().startsWith('##"')?c:-1).filter(l=>l>=0),a=(i.description??"").split(`
|
|
77
|
-
`).map(l=>l.trim()===""?'##"':`##" ${l.trim()}`).join(`
|
|
78
|
-
`);if(o.length>0){const l=o[0],c=o[o.length-1];s.push({start:n(l).start,end:n(c).end,text:i.description===void 0?"":`${a}
|
|
79
|
-
`})}else if(i.description!==void 0){const l=gs(t),c=n(l).start;s.push({start:c,end:c,text:`${a}
|
|
80
|
-
`})}}}function $m(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o}=e,a=new Map((i.localGivens??[]).map(p=>[p.name,p])),l=new Map((s.localGivens??[]).map(p=>[p.name,p])),c=yl(t),u=new Set;for(const[p,h]of a){const g=l.get(p);if(g!==void 0&&ye(g)===ye(h))continue;const b=c.get(p);if(b===void 0)return{ok:!1,reason:`Could not find where the given \`${p}\` is declared.`};const{tags:w}=Vt(t,b.line),v=g===void 0?w:w.filter(k=>{const M=di(k.text);return M!==void 0&&ym.has(M)});for(const k of v)o.push({...n(k.line),text:""}),u.add(k.line);if(g===void 0){o.push({...n(b.line),text:""}),u.add(b.line);const k=Math.min(b.line,...w.map(O=>O.line)),M=b.blockHeader??k,$=(t[b.line+1]??"x").trim()==="",A=M===0||t[M-1].trim()==="",T=b.blockHeader===void 0||![...c.values()].some(O=>O.blockHeader===b.blockHeader&&O.line>b.line&&l.has([...c.entries()].find(([,I])=>I===O)?.[0]??""));$&&A&&T&&!u.has(b.line+1)&&(o.push({...n(b.line+1),text:""}),u.add(b.line+1));continue}const f=r(b.line),y=il(g),x=g.type!==h.type||g.default!==h.default?b.blockHeader===void 0?sl(g):`${g.name} :: ${g.type} is ${g.default}`:t[b.line].trim();o.push({...n(b.line),text:(y?`${f}${y}
|
|
81
|
-
`:"")+`${f}${x}
|
|
82
|
-
`})}for(const[p,h]of c)h.blockHeader===void 0||l.has(p)||![...c.values()].some(g=>g.blockHeader===h.blockHeader&&!u.has(g.line))&&!u.has(h.blockHeader)&&(o.push({...n(h.blockHeader),text:""}),u.add(h.blockHeader));const d=[...l.values()].filter(p=>!a.has(p.name));if(d.length>0){const p=Math.max(-1,...[...c.values()].map(v=>v.line)),h=(()=>{let v=-1;for(let f=0;f<t.length;f++){const y=t[f].trim();(y.startsWith("import ")||v>=0&&/^}\s*from\s/.test(y))&&(v=f)}return v})(),g=p>=0?p:h,b=d.map(v=>{const f=il(v);return(f?`${f}
|
|
83
|
-
`:"")+`${sl(v)}
|
|
84
|
-
`}).join(`
|
|
85
|
-
`),w=g>=0?n(g).end:n(0).end;o.push({start:w,end:w,text:`
|
|
86
|
-
${b}`}),t.some(v=>v.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
|
|
87
|
-
`})}}function Om(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o}=e,a=new Map((i.drills??[]).map(c=>[Ei(c),c])),l=new Map((s.drills??[]).map(c=>[Ei(c),c]));for(const c of new Set([...a.keys(),...l.keys()])){const u=a.get(c),d=l.get(c);if(u&&d&&ye(u)===ye(d))continue;const p=d??u;if(d&&d.to.length===0)return{ok:!1,reason:`The drill on \`${c}\` names no destination.`};const h=us(t,p.source,"dimension").get(p.name);if(h===void 0)return{ok:!1,reason:`\`${p.name}\` is not a dimension \`${p.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:g}=Vt(t,h.line),b=g.find(v=>/^#\s*drill\b/.test(v.text)),w=r(h.line);if(d===void 0)b&&o.push({...n(b.line),text:""});else if(b)o.push({...n(b.line),text:`${w}${al(d)}
|
|
88
|
-
`});else{const v=n(h.line).start;o.push({start:v,end:v,text:`${w}${al(d)}
|
|
89
|
-
`})}}}function Cm(e){const{lines:t,wholeLine:n,removedTiles:r,edits:i}=e;for(const s of r){if(s.declaration.kind==="inherited")continue;const o=ms(t,"view",s.name);if(o<0)return{ok:!1,reason:`Could not find where \`${s.name}\` is declared.`};const a=Mi(t,o),{tags:l}=Vt(t,o),c=Math.min(o,...l.map(d=>d.line));for(const d of l)i.push({...n(d.line),text:""});i.push({start:n(o).start,end:n(a).end,text:""});const u=c===0?"":t[c-1].trim();(t[a+1]??"x").trim()===""&&(c===0||u===""||u.endsWith("{"))&&i.push({...n(a+1),text:""})}}function Mm(e){const{sourceText:t,lines:n,wholeLine:r,current:i,addedTiles:s,newSources:o,currentSources:a,edits:l}=e,c=new Map;for(const p of s){const h=c.get(p.source)??[];h.push(p),c.set(p.source,h)}const u=(p,h)=>{const g=p.declaration.kind==="reference"?p.declaration.from:p.name,b=(p.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...nu(p).map(w=>`${h}${w}`),`${h}view: ${p.name} is ${g}${b?` + { ${b} }`:""}`].join(`
|
|
90
|
-
`)};let d=-1;for(const p of i.sources){const h=ms(n,"source",p.name);h>=0&&(d=Math.max(d,Mi(n,h)))}for(const[p,h]of c)if(a.has(p)){const g=ms(n,"source",p);if(g<0)return{ok:!1,reason:`Could not find where the source \`${p}\` is declared.`};const b=Mi(n,g);let w=" ";for(let y=g+1;y<b;y++){const x=/^(\s+)view:/.exec(n[y]);if(x){w=x[1];break}}const v=r(b).start,f=(n[b-1]??"").trim()==="";l.push({start:v,end:v,text:(f?"":`
|
|
91
|
-
`)+h.map(y=>u(y,w)).join(`
|
|
92
|
-
|
|
93
|
-
`)+`
|
|
94
|
-
`})}else{const g=o.find(y=>y.name===p);if(!g)return{ok:!1,reason:`The tile's source \`${p}\` is not declared.`};const b=`
|
|
95
|
-
source: ${g.name} is ${g.base} extend {
|
|
96
|
-
`+h.map(y=>u(y," ")).join(`
|
|
97
|
-
|
|
98
|
-
`)+`
|
|
99
|
-
}
|
|
100
|
-
`;let w=d;if(w<0)for(let y=0;y<n.length;y++){const x=n[y].trim();(/^(import\s|given:|}\s*from\s)/.test(x)||/^[A-Z_]+\s*::/.test(x))&&(w=y)}const v=w>=0?r(w).end:t.length,f=v===t.length&&!t.endsWith(`
|
|
101
|
-
`)?`
|
|
102
|
-
`:"";l.push({start:v,end:v,text:f+b}),d=w}}function Em(e){const{lines:t,starts:n,wholeLine:r,indentOf:i,current:s,next:o,edits:a}=e,l=new Map(s.tiles.map(c=>[bt(c),c]));for(const c of o.tiles){const u=l.get(bt(c));if(u===void 0||ye(u)===ye(c))continue;if(c.declaration.kind==="inherited")return{ok:!1,reason:`\`${c.source} -> ${c.name}\` is declared on its source, not in this dashboard, so its presentation cannot be changed here.`};const d=wm(t,c.source,c.name);if(d<0)return{ok:!1,reason:`Could not find where \`${c.name}\` is declared inside \`${c.source}\`.`};const{tags:p}=Vt(t,d),h=i(d),g=nu(c),b=new Map(g.map($=>[di($)??$,$])),w=new Set;for(const $ of p){const A=di($.text);if(A===void 0||!bm.has(A))continue;const T=b.get(A);if(T===void 0){a.push({...r($.line),text:""});continue}w.add(A),T!==$.text&&a.push({...r($.line),text:`${h}${T}
|
|
103
|
-
`})}const v=g.filter($=>!w.has(di($)??$));if(v.length>0){const $=n[d];a.push({start:$,end:$,text:v.map(A=>`${h}${A}
|
|
104
|
-
`).join("")})}const f=(/\+\s*\{([\s\S]*)\}\s*$/.exec(t[d])?.[1]??"").replace(tu,"").replace(/\s*,\s*,\s*/g,", ").replace(/^[\s,;]+|[\s,;]+$/g,""),y=(c.filters??[]).map($=>`where: ${$.field} ${$.op??"~"} $${$.given}`),x=[...f?[f]:[],...y],k=t[d].replace(/\s*\+\s*\{[\s\S]*\}\s*$/,""),M=x.length===0?k:`${k} + { ${x.join(", ")} }`;M!==t[d]&&a.push({...r(d),text:`${M}
|
|
105
|
-
`})}}async function cl(e,t){const n=await io(e);if(no(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=km(r,t);if("reason"in i)return i;const s=e.split(`
|
|
106
|
-
`),o=mm(e),a=g=>({start:o[g],end:g+1<o.length?o[g+1]:e.length}),l=g=>/^\s*/.exec(s[g])?.[0]??"",c=[],u={...i,sourceText:e,lines:s,starts:o,wholeLine:a,indentOf:l,current:r,next:t,edits:c};for(const g of[Sm,jm,$m,Om,Cm,Mm,Em]){const b=g(u);if(b)return b}const d=g=>{const{drills:b,localGivens:w,...v}=g,f=g.tiles.map(y=>{if(y.filters?.length)return y;const{filters:x,...k}=y;return k});return{...v,tiles:f,...b?.length?{drills:[...b].sort((y,x)=>Ei(y).localeCompare(Ei(x)))}:{},...w?.length?{localGivens:w}:{}}};if(c.length===0)return ye(d(r))!==ye(d(t))?{ok:!1,reason:"The edit did not produce the dashboard that was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:e};const p=vm(e,c),h=await io(p);return no(h)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${h.reason}`}:ye(d(h.document))!==ye(d(t))?{ok:!1,reason:"The edit did not produce the dashboard that was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:p}}function Am(e){const[t,n]=S.useState({stack:[e.document],index:0}),[r,i]=S.useState(e.source),[s,o]=S.useState(void 0),[a,l]=S.useState(e.document),c=t.stack[t.index],u=S.useCallback(v=>{o(void 0),n(f=>{const y=structuredClone(f.stack[f.index]);if(v(y),JSON.stringify(y)===JSON.stringify(f.stack[f.index]))return f;const x=[...f.stack.slice(0,f.index+1),y].slice(-100);return{stack:x,index:x.length-1}})},[]),d=S.useCallback(()=>{o(void 0),n(v=>v.index>0?{...v,index:v.index-1}:v)},[]),p=S.useCallback(()=>{o(void 0),n(v=>v.index<v.stack.length-1?{...v,index:v.index+1}:v)},[]),h=S.useCallback(async()=>{const v=await cl(r,c);if(rl(v))return o(v.reason),{ok:!1,reason:v.reason};try{await e.onSave?.(v.source)}catch(f){const y=`Could not save: ${f}`;return o(y),{ok:!1,reason:y}}return i(v.source),l(c),o(void 0),{ok:!0}},[c,e,r]),g=S.useMemo(()=>JSON.stringify(c)!==JSON.stringify(a),[c,a]),b=S.useMemo(()=>{const v=new Set(a.tiles.map(so)),f=new Set(c.tiles.map(so));return[...v].some(y=>!f.has(y))||[...f].some(y=>!v.has(y))},[c,a]),w=S.useCallback(async()=>{const v=await cl(r,c);return rl(v)?{ok:!1,reason:v.reason}:{ok:!0,source:v.source}},[c,r]);return{document:c,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:g,...s===void 0?{}:{error:s},update:u,undo:d,redo:p,save:h,preview:w,structural:b}}function Dm({source:e,document:t,onSave:n,onChange:r,onDirtyChange:i,renderTile:s,controls:o,givens:a,catalog:l,toolbar:c,dashboards:u,onEvent:d,savesTo:p="package"}){const h=Am({source:e,document:t,...n?{onSave:n}:{}}),[g,b]=S.useState(void 0),[w,v]=S.useState(!1),f=h.document.columns??su,{resize:y,gridBox:x,startResize:k,onResize:M,endResize:$}=am({tiles:h.document.tiles,columns:f,onStart:b,commit:(j,D)=>h.update(z=>{z.tiles[j].colspan=D})}),{dragging:A,preview:T,onDragStart:O,onDragOver:I,onDragEnd:E}=om({tiles:h.document.tiles,commit:j=>h.update(D=>{D.tiles=j}),onLanded:b}),[P,Z]=S.useState(void 0),[G,xe]=S.useState(void 0),[ze,re]=S.useState(!1),[_e,Ke]=S.useState(void 0),[we,Ge]=S.useState(null),[qe,Le]=S.useState(void 0);S.useEffect(()=>{r?.(h.document)},[h.document,r]),S.useEffect(()=>{i?.(h.dirty)},[h.dirty,i]);const He=S.useMemo(()=>ig(h.document),[h.document]),ke=S.useMemo(()=>{const j=new Set((t.localGivens??[]).map(D=>D.name));return(a??[]).filter(D=>!j.has(D.name))},[t,a]),ee=S.useMemo(()=>Mp(h.document,ke),[h.document,ke]),W=S.useMemo(()=>new Map(h.document.sources.map(j=>[j.name,_a(l,j.base)])),[l,h.document.sources]),N=S.useCallback(j=>W.get(j.source)??_a(l,j.source),[W,l]),Se=(j,D)=>{const z=[];for(const K of h.document.tiles){const st=N(K);if(!st)continue;const ve=new Map(st.map(Ce=>[Ce.name,Ce.type]));for(const Ce of K.filters??[])Ce.given===j&&(!ve.has(Ce.field)||!ci(D,ve.get(Ce.field)))&&z.push(`${Ce.field} on ${K.label??K.name} (${h.document.sources.find(Me=>Me.name===K.source)?.base??K.source})`)}return z},te=S.useMemo(()=>ee.filter(j=>j.origin==="model"&&j.boundTiles===0),[ee]),Fe=S.useCallback(()=>{Le(void 0),v(!0);const j=vn(),{structural:D}=h,z=h.document.tiles.length;h.save().then(K=>{K.ok===!0?d?.({type:"dashboard.saved",tiles:z,structural:D,where:p,durationMs:vn()-j}):d?.({type:"dashboard.save_refused",reason:K.reason})}).finally(()=>v(!1))},[h,d,p]),V=S.useCallback(()=>{if(!(!n||!h.dirty||w)){if(!h.structural){Fe();return}h.preview().then(j=>{j.ok?Le({before:h.source,after:j.source}):Fe()})}},[n,h,w,Fe]),it=j=>{re(!1),h.update(D=>{let z=D.sources.find(ve=>ve.base===j.base);if(!z){const ve=new Set(D.sources.map(Me=>Me.name));let Ce=`${j.base}_tiles`;for(let Me=2;ve.has(Ce);Me++)Ce=`${j.base}_tiles_${Me}`;z={name:Ce,base:j.base},D.sources.push(z)}const K=new Set(D.tiles.filter(ve=>ve.source===z.name).map(ve=>ve.name));let st=`${j.view}_tile`;for(let ve=2;K.has(st);ve++)st=`${j.view}_tile_${ve}`;D.tiles.push({name:st,source:z.name,declaration:{kind:"reference",from:j.view},colspan:j.colspan,...j.label?{label:j.label}:{}})}),b(h.document.tiles.length)},Oe=j=>{xe(void 0),b(void 0),h.update(D=>{D.tiles.splice(j,1)})};qp(S.useMemo(()=>({undo:h.undo,redo:h.redo,...n?{save:V}:{},escape:()=>{!G&&!P&&b(void 0)},nudge:j=>{if(g===void 0)return;const D=h.document.tiles[g];if(!D||D.declaration.kind==="inherited")return;const z=Math.min(Math.max((D.colspan??1)+j,1),f);z!==(D.colspan??1)&&h.update(K=>{K.tiles[g].colspan=z})}}),[h,n,V,G,P,g,f]));const mt=(j,D,z)=>{Z(void 0),h.update(K=>{z&&Wp(K,z),Rp(K,j,D)})},C=j=>{Z(void 0),h.update(D=>Ip(D,j))},R=(()=>{const j=h.document.tiles;return y!==void 0?j.map((D,z)=>z===y.index?{...D,colspan:y.span}:D):T??j})(),Y=A?dg(R,f):R.map(qd);return m.jsxs(le,{sx:{gap:0},children:[m.jsx(Hp,{canUndo:h.canUndo,canRedo:h.canRedo,onUndo:h.undo,onRedo:h.redo,dirty:h.dirty,saving:w,...n?{onSave:V}:{},...c?{actions:c}:{},...l?{onAddTile:()=>re(!0)}:{},onSettings:Ge}),m.jsxs(le,{sx:{gap:2,px:"4px",pb:"4px"},children:[m.jsx(ou,{title:h.document.title||"Untitled dashboard",...h.document.description?{description:h.document.description}:{}}),m.jsx(ag,{controls:ee,tileCount:h.document.tiles.length,unknownFieldsOf:Se,onEdit:j=>Z({control:j}),onAdd:()=>Z({}),children:o}),h.error&&m.jsx(cn,{severity:"warning",children:h.error}),m.jsx(up,{sensors:qg,onDragStart:O,onDragOver:I,onDragEnd:E,children:m.jsxs(de,{ref:x,sx:{position:"relative"},children:[(y!==void 0||A)&&m.jsx(Zg,{columns:f}),m.jsx(au,{tiles:Y,columns:f,keyOf:j=>j.kind==="gap"?Hd(j.after):vt(j.tile),renderTile:j=>{if(j.kind==="gap")return m.jsx(Bg,{after:j.after});const{tile:D,index:z}=j;return m.jsx(Kg,{tile:D,index:z,selected:z===g,menuOpen:G?.index===z,resizeSpan:y?.index===z?y.span:void 0,columns:f,onSelect:()=>b(z),onOpenMenu:K=>{b(z),xe({anchor:K,index:z})},onResizeStart:K=>k(K,z),onResizeMove:M,onResizeEnd:$,children:s?s(D):m.jsx(Gg,{tile:D})})}})]})}),m.jsx(rg,{open:P!==void 0,document:h.document,...P?.control?{control:P.control}:{},available:te,...l?{fieldsFor:N}:{},onClose:()=>Z(void 0),onApply:mt,onRemove:C}),m.jsx(lm,{anchor:G?.anchor??null,tile:G===void 0?void 0:h.document.tiles[G.index],onClose:()=>xe(void 0),onCommit:j=>{const D=G?.index;D!==void 0&&h.update(z=>{z.tiles[D]=j})},onRemove:()=>{G!==void 0&&Oe(G.index)},columns:f,onDrills:()=>{G!==void 0&&Ke(h.document.tiles[G.index]?.source)}}),m.jsx(tg,{open:_e!==void 0,document:h.document,source:h.document.sources.find(j=>j.name===_e),givenNames:ee.map(j=>j.name),dashboards:u??[],onClose:()=>Ke(void 0),onApply:j=>h.update(D=>{const z=[...(D.drills??[]).filter(K=>K.source!==_e),...j];z.length===0?delete D.drills:D.drills=z})}),m.jsx(sg,{anchor:we,settings:He,onClose:()=>Ge(null),onCommit:j=>h.update(D=>{D.title=j.title,j.description===void 0?delete D.description:D.description=j.description,j.columns===void 0?delete D.columns:D.columns=j.columns,j.autorun===void 0?delete D.autorun:D.autorun=j.autorun})}),m.jsx(Zp,{open:ze,document:h.document,catalog:l,columns:f,onClose:()=>re(!1),onAdd:it}),m.jsx(eg,{open:qe!==void 0,before:qe?.before??"",after:qe?.after??"",onConfirm:Fe,onClose:()=>Le(void 0)})]})]})}function Tm(e,t){const n=new Set;for(const s of e.tiles)for(const o of s.filters??[])n.add(o.given);const r=[],i=new Set;for(const s of e.localGivens??[])n.has(s.name)&&(i.add(s.name),r.push(Pm(s)));for(const s of t)s.name===void 0||i.has(s.name)||!n.has(s.name)||(i.add(s.name),r.push(s));return r}function Pm(e){return{name:e.name,type:e.type,default:e.default,...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description},...e.control===void 0?{}:{control:e.control},...e.suggest?{suggest:{...e.suggest.source===void 0?{}:{source:e.suggest.source},...e.suggest.query===void 0?{}:{query:e.suggest.query},dimension:e.suggest.dimension}}:{},...e.rangeMin===void 0?{}:{rangeMin:e.rangeMin},...e.rangeMax===void 0?{}:{rangeMax:e.rangeMax}}}function Rm(e,t,n,r=new Map){if(t.declaration.kind!=="reference")return{expression:`${t.source} -> ${t.name}`,givenNames:t.declaration.kind==="inherited"?void 0:[]};const i=t.source,s=new Map((e.localGivens??[]).map(c=>[c.name,c.type])),o=[],a=[];for(const c of t.filters??[]){const u=`where: ${c.field} ${c.op??"~"}`;if(n.has(c.given)){o.push(c.given),a.push(`${u} $${c.given}`);continue}if(!s.has(c.given))continue;const d=$u(r.get(c.given),s.get(c.given));d!==void 0&&a.push(`${u} ${d}`)}const l=a.join(", ");return{expression:`${i} -> ${t.declaration.from}`+(l?` + { ${l} }`:""),givenNames:o}}async function Wm(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}const dl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function _m({environmentName:e,packageName:t,dashboardName:n,onExit:r,onEvent:i,onDirtyChange:s}){const{apiClients:o,mutable:a}=hl(),l=lu(),c=S.useRef(vn()),u=S.useRef(i);u.current=i;const d=S.useRef(s);d.current=s;const p=cu()?.documentStorage,h=`dashboards/${n}.malloy`,g=Br({queryKey:["dashboard-editor-model",e,t,h],queryFn:()=>o.models.getModel(e,t,h)}),b=g.data?.data?.sourceText,[w,v]=S.useState(void 0),[f,y]=S.useState(void 0),[x,k]=S.useState(p===void 0),[M,$]=S.useState(!1),[A,T]=S.useState(void 0);S.useEffect(()=>{if(!p)return;let _=!1;return T(void 0),(async()=>{try{const Ee=await p.listWorkspaces(!1),Be=Ee.find(fe=>fe.authoritative)??Ee.find(fe=>fe.writeable);if(_)return;if(v(Be),Be!==void 0){const fe=await p.getDocument(dl(Be.name,e,t,h)).catch(he=>{if(!da(he))throw he});if(_)return;y(fe),$(fe!==void 0)}}catch(Ee){if(_)return;T(ul(Ee))}_||k(!0)})(),()=>{_=!0}},[p,e,t,h]);const O=w?.authoritative===!0,I=O&&A!==void 0,[E,P]=S.useState(void 0),Z=(O||E===!0)&&f!==void 0,[G,xe]=S.useState(void 0),[ze,re]=S.useState(void 0),_e=S.useRef(void 0),Ke=S.useRef(void 0),[we,Ge]=S.useState(void 0),qe=g.dataUpdatedAt,Le=S.useRef(qe);Le.current=qe;const He=we!==void 0&&we.onFetch===qe?we.text:b,ke=S.useRef(He);ke.current=He;const ee=Z?f:He,[W,N]=S.useState(!1),[Se,te]=S.useState(void 0),[Fe,V]=S.useState(void 0),it=ee!==void 0&&ee!==Fe,Oe=G?.source,mt=it&&W&&Oe!==void 0&&ee!==Se,C=mt?Oe:it?ee:Oe??ee,R=mt?ee:void 0,Y=S.useRef(Oe);Y.current=Oe;const j=S.useRef(ee);j.current=ee;const D=S.useRef("package");D.current=Z?O?"record":"draft":"package",S.useEffect(()=>{if(C===void 0||!x||I||C===Y.current)return;let _=!1;const Ee=ke.current,Be=j.current;return io(C).then(fe=>{if(!_){if(no(fe)){const he=fe.line?`${fe.reason} (line ${fe.line})`:fe.reason;re(he),u.current?.({type:"dashboard.open_refused",reason:he});return}re(void 0),_e.current=void 0,Ke.current=Ee,Ge(void 0),te(void 0),V(Be),xe(he=>({source:C,document:fe.document,generation:(he?.generation??0)+1})),u.current?.({type:"dashboard.opened",from:D.current,tiles:fe.document.tiles.length,durationMs:vn()-c.current})}}),()=>{_=!0}},[C,x,I]);const z=w===void 0?void 0:dl(w.name,e,t,h),K=S.useCallback(async _=>{if(!p||!z)throw new Error("This host keeps no documents, so there is nowhere to save.");await p.saveDocument(z,_),xe(Ee=>Ee&&{...Ee,source:_}),y(_),(O||E===!0)&&V(_),O||P(Ee=>Ee??!1)},[p,z,O,E]),[st,ve]=S.useState(void 0),Ce=S.useCallback(async _=>{const Ee=Ke.current,Be=_e.current??(Ee===void 0?void 0:await Wm(Ee));if(Be===void 0)throw new Error("The package file is still loading; try again.");let fe;try{fe=await o.models.updateModelSource(e,t,h,{source:_,expectedHash:Be})}catch(he){throw l.invalidateQueries({queryKey:["dashboard-editor-model",e,t,h]}),new Error(Lm(he))}if(xe(he=>he&&{...he,source:_}),Ge({text:_,onFetch:Le.current}),V(_),_e.current=fe.data.contentHash,ve(void 0),p&&z)try{await p.deleteDocument(z),y(void 0),$(!1)}catch(he){da(he)?(y(void 0),$(!1)):ve(ul(he))}P(!1),await l.invalidateQueries({queryKey:["dashboard-editor-model",e,t,h]});for(const he of["dashboard-editor-manifest","dashboards","dashboard"])l.invalidateQueries({queryKey:[he]})},[o,e,t,h,p,z,l]),Me=O?"host":a?"package":"browser",Hn=w?.writeable===!0,Qt=A===void 0?O?p&&z&&Hn?K:void 0:a?Ce:p&&z&&Hn?K:void 0:void 0,en=w?.name,Ir=S.useCallback(_=>{u.current?.(_.type==="dashboard.saved"&&_.where!=="package"&&en!==void 0?{..._,workspace:en}:_)},[en]),Un=S.useCallback(_=>{N(_),d.current?.(_)},[]),Yn=_=>{c.current=vn(),te(_?f:He),P(_)},Hi=()=>{c.current=vn(),te(R)};return g.isError?m.jsx(du,{error:g.error,context:"Opening the dashboard"}):!b||!x?m.jsxs(le,{sx:{gap:2},children:[m.jsx(fl,{}),m.jsx(uu,{text:"Opening the dashboard…"})]}):I?m.jsxs(cn,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",A]}):ze?m.jsxs(cn,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",ze]}):m.jsxs(le,{sx:{gap:2},children:[!O&&M&&f!==void 0&&f!==b&&E===void 0&&m.jsx(cn,{severity:"info",action:m.jsxs(le,{direction:"row",sx:{gap:1},children:[m.jsx(ge,{size:"small",onClick:()=>Yn(!0),children:"Resume"}),m.jsx(ge,{size:"small",onClick:()=>Yn(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),R!==void 0&&m.jsx(cn,{severity:"warning",action:m.jsx(ge,{size:"small",onClick:Hi,children:"Load it"}),children:Me==="package"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":Me==="host"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them."}),st!==void 0&&m.jsxs(cn,{severity:"warning",children:["The file was saved into the package, but the copy kept beside it could not be cleared, so it will be offered again:"," ",st]}),G&&m.jsx(zm,{environmentName:e,packageName:t,modelPath:h,slug:n,opened:G,onSave:Qt,onDirtyChange:Un,savesTo:Me,...i?{onEvent:Ir}:{},toolbar:r&&m.jsx(pl,{label:"Done editing",icon:m.jsx(gl,{}),onClick:r}),note:Im({authoritative:O,mutable:a,...w?{workspace:w}:{},...A!==void 0?{readFailure:A}:{}})},G.generation)]})}function Im({authoritative:e,mutable:t,workspace:n,readFailure:r}){return r!==void 0?`The saved copy could not be read, so Save is off: ${r}`:e&&n?n.writeable?n.description:`${n.description}: you cannot save into it.`:t?"Save writes the file into the package.":n?`${n.description}: this server does not take writes.`:"This server does not take writes."}function zm({environmentName:e,packageName:t,modelPath:n,slug:r,opened:i,onSave:s,onDirtyChange:o,onEvent:a,savesTo:l,toolbar:c,note:u}){const{apiClients:d}=hl(),{data:p,isSuccess:h}=Br({queryKey:["dashboard-editor-manifest",e,t,r],queryFn:()=>d.dashboards.getDashboard(e,t,r,void 0)}),g=p?.data,{data:b}=Br({queryKey:["dashboard-editor-dashboards",e,t],queryFn:()=>d.dashboards.listDashboards(e,t,void 0)}),w=S.useMemo(()=>(b?.data??[]).map(E=>E.name).filter(E=>!!E&&E!==r),[b,r]),v=S.useMemo(()=>{const E=n.slice(0,n.lastIndexOf("/")+1),P=new Set;for(const Z of i.document.imports){const G=new URL(Z.from,`https://malloy.invalid/${E}`);P.add(G.pathname.slice(1))}return[...P]},[i.document.imports,n]),{data:f}=Br({queryKey:["dashboard-editor-catalog",e,t,...v],queryFn:async()=>{const E=await Promise.all(v.map(P=>d.models.getModel(e,t,P).then(Z=>Z.data)));return Gp(E)},enabled:v.length>0}),[y,x]=S.useState(i.document);S.useEffect(()=>x(i.document),[i.document]);const k=S.useMemo(()=>g?.givens??[],[g]),M=S.useMemo(()=>new Set(k.map(E=>E.name).filter(E=>E!==void 0)),[k]),$=S.useMemo(()=>Tm(y,k),[y,k]),{declaredTypes:A,applied:T,panel:O}=yu({specs:$,loaded:h,startingValues:g?.startingGivens,documentKey:`${e}/${t}/${r}/edit`,autorun:g?.autorun!==!1,environmentName:e,packageName:t,modelPath:g?.path,documentName:r}),I=S.useMemo(()=>function(E){const P=Rm(y,E,M,T);return m.jsx(xu,{environmentName:e,packageName:t,modelPath:n,tile:P.expression,label:E.label??ku(`${E.source} -> ${E.name}`),subtitle:E.subtitle,borderless:E.borderless,givens:T,declaredTypes:A,givenNames:P.givenNames,height:wu})},[y,M,e,t,n,T,A]);return m.jsxs(le,{sx:{gap:1},children:[m.jsx(Dm,{source:i.source,document:i.document,renderTile:I,givens:$.filter(E=>E.name!==void 0).map(E=>({name:E.name,...E.label?{label:E.label}:{},...E.type?{type:E.type}:{},...E.suggest?.dimension?{field:E.suggest.dimension}:{}})),onChange:x,onDirtyChange:o,...f?{catalog:f}:{},dashboards:w,...a?{onEvent:a}:{},toolbar:c,controls:h?m.jsx(Su,{...O,layout:"bar"}):void 0,...s?{onSave:s}:{},savesTo:l}),m.jsx(de,{sx:{px:.5},children:m.jsx(Q,{variant:"caption",sx:{opacity:.7},children:u})})]})}function ul(e){return e instanceof Error?e.message:String(e)}function Lm(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}typeof globalThis.process>"u"?globalThis.process={env:{}}:fa===void 0&&(fa={});export{Dm as DashboardBuilder,_m as DashboardEditor,Gp as buildCatalog,io as readDashboardDocument,no as readFailed,cl as spliceDashboardDocument,rl as spliceFailed};
|