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