@malloy-publisher/sdk 0.4.0 → 0.4.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.
@@ -1,52 +1,52 @@
1
- "use strict";var Cd=Object.create;var Ho=Object.defineProperty;var Id=Object.getOwnPropertyDescriptor;var jd=Object.getOwnPropertyNames;var Ad=Object.getPrototypeOf,Rd=Object.prototype.hasOwnProperty;var Ld=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jd(t))!Rd.call(e,i)&&i!==n&&Ho(e,i,{get:()=>t[i],enumerable:!(r=Id(t,i))||r.enumerable});return e};var Ko=(e,t,n)=>(n=e!=null?Cd(Ad(e)):{},Ld(t||!e||!e.__esModule?Ho(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),S=require("react"),zd=require("react-dom"),k=require("@mui/material"),j=require("../DocumentStorageProvider-DGPQEd_l.cjs.js"),Pe=require("../ServerProvider-Cc489A3f.cjs.js"),Wd=require("@tanstack/react-query");var Fd=Symbol.for("preact-signals");function hi(){if(lt>1)lt--;else{var e,t=!1;for((function(){var i=qr;for(qr=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}})();Xn!==void 0;){var n=Xn;for(Xn=void 0,Kr++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ga(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(Kr=0,lt--,t)throw e}}function oe(e){if(lt>0)return e();Ui=++Bd,lt++;try{return e()}finally{hi()}}var Un,te=void 0;function N(e){var t=te,n=Un;te=void 0,Un=void 0;try{return e()}finally{te=t,Un=n}}var Xn=void 0,lt=0,Kr=0,Bd=0,Ui=0,qr=void 0,Ur=0;function Na(e){if(te!==void 0){var t=e.n;if(t===void 0||t.t!==te)return t={i:0,S:e,p:te.s,n:void 0,t:te,e:void 0,x:void 0,r:t},te.s!==void 0&&(te.s.n=t),te.s=t,e.n=t,32&te.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=te.s,t.n=void 0,te.s.n=t,te.s=t),t}}function Oe(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}Oe.prototype.brand=Fd;Oe.prototype.h=function(){return!0};Oe.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:N(function(){var r;(r=t.W)==null||r.call(t)}))};Oe.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&&N(function(){var i;(i=t.Z)==null||i.call(t)}))}};Oe.prototype.subscribe=function(e){var t=this;return Be(function(){var n=t.value;N(function(){return e(n)})},{name:"sub"})};Oe.prototype.valueOf=function(){return this.value};Oe.prototype.toString=function(){return this.value+""};Oe.prototype.toJSON=function(){return this.value};Oe.prototype.peek=function(){var e=this;return N(function(){return e.value})};Object.defineProperty(Oe.prototype,"value",{get:function(){var e=Na(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Kr>100)throw new Error("Cycle detected");(function(n){lt!==0&&Kr===0&&n.l!==Ui&&(n.l=Ui,qr={S:n,v:n.v,i:n.i,o:qr})})(this),this.v=e,this.i++,Ur++,lt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{hi()}}}});function vn(e,t){return new Oe(e,t)}function Ga(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 Va(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 Ha(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 zt(e,t){Oe.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Ur-1,this.f=4}zt.prototype=new Oe;zt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ur))return!0;if(this.g=Ur,this.f|=1,this.i>0&&!Ga(this))return this.f&=-2,!0;var e=te;try{Va(this),te=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 te=e,Ha(this),this.f&=-2,!0};zt.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)}Oe.prototype.S.call(this,e)};zt.prototype.U=function(e){if(this.t!==void 0&&(Oe.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)}};zt.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(zt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Na(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function qo(e,t){return new zt(e,t)}function Ka(e){var t=e.m;if(e.m=void 0,typeof t=="function"){lt++;var n=te;te=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ls(e),r}finally{te=n,hi()}}}function Ls(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ka(e)}function Nd(e){if(te!==this)throw new Error("Out-of-order effect");Ha(this),te=e,this.f&=-2,8&this.f&&Ls(this),hi()}function mn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Un&&Un.push(this)}mn.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()}};mn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ka(this),Va(this),lt++;var e=te;return te=this,Nd.bind(this,e)};mn.prototype.N=function(){2&this.f||(this.f|=2,this.u=Xn,Xn=this)};mn.prototype.d=function(){this.f|=8,1&this.f||Ls(this)};mn.prototype.dispose=function(){this.d()};function Be(e,t){var n=new mn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Gd=Object.create,zs=Object.defineProperty,Vd=Object.defineProperties,Hd=Object.getOwnPropertyDescriptor,Kd=Object.getOwnPropertyDescriptors,Uo=Object.getOwnPropertySymbols,qd=Object.prototype.hasOwnProperty,Ud=Object.prototype.propertyIsEnumerable,Xd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),yn=e=>{throw TypeError(e)},Xi=(e,t,n)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yd=(e,t)=>{for(var n in t||(t={}))qd.call(t,n)&&Xi(e,n,t[n]);if(Uo)for(var n of Uo(t))Ud.call(t,n)&&Xi(e,n,t[n]);return e},Zd=(e,t)=>Vd(e,Kd(t)),Xo=(e,t)=>zs(e,"name",{value:t,configurable:!0}),Jd=e=>{var t;return[,,,Gd((t=void 0)!=null?t:null)]},qa=["class","method","getter","setter","accessor","field","value","get","set"],Cn=e=>e!==void 0&&typeof e!="function"?yn("Function expected"):e,Qd=(e,t,n,r,i)=>({kind:qa[e],name:t,metadata:r,addInitializer:s=>n._?yn("Already initialized"):i.push(Cn(s||null))}),Ua=(e,t)=>Xi(t,Xd("metadata"),e[3]),St=(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},bn=(e,t,n,r,i,s)=>{var o,a,c,d,u,l=t&7,f=!!(t&8),g=!!(t&16),h=l>3?e.length+1:l?f?1:2:0,m=qa[l+5],w=l>3&&(e[h-1]=[]),b=e[h]||(e[h]=[]),v=l&&(!g&&!f&&(i=i.prototype),l<5&&(l>3||!g)&&Hd(l<4?i:{get[n](){return Le(this,s)},set[n](x){return vt(this,s,x)}},n));l?g&&l<4&&Xo(s,(l>2?"set ":l>1?"get ":"")+n):Xo(i,n);for(var p=r.length-1;p>=0;p--)d=Qd(l,n,c={},e[3],b),l&&(d.static=f,d.private=g,u=d.access={has:g?x=>eu(i,x):x=>n in x},l^3&&(u.get=g?x=>(l^1?Le:tu)(x,i,l^4?s:v.get):x=>x[n]),l>2&&(u.set=g?(x,_)=>vt(x,i,_,l^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(l?l<4?g?s:v[m]:l>4?void 0:{get:v.get,set:v.set}:i,d),c._=1,l^4||a===void 0?Cn(a)&&(l>4?w.unshift(a):l?g?s=a:v[m]=a:i=a):typeof a!="object"||a===null?yn("Object expected"):(Cn(o=a.get)&&(v.get=o),Cn(o=a.set)&&(v.set=o),Cn(o=a.init)&&w.unshift(o));return l||Ua(e,i),v&&zs(i,n,v),g?l^4?s:v:i},Ws=(e,t,n)=>t.has(e)||yn("Cannot "+n),eu=(e,t)=>Object(t)!==t?yn('Cannot use the "in" operator on this value'):e.has(t),Le=(e,t,n)=>(Ws(e,t,"read from private field"),n?n.call(e):t.get(e)),In=(e,t,n)=>t.has(e)?yn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),vt=(e,t,n,r)=>(Ws(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),tu=(e,t,n)=>(Ws(e,t,"access private method"),n);function Yi(e,t){if(t){let n;return qo(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return qo(e)}function Ke(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((r,i)=>!Ke(r,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(s=>!Ke(e[s],t[s]))}return!1}function G({get:e},t){return{init(n){return vn(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=Yi(e.bind(this)),n.set(this,r)),r.value}}function Pi(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,Zd(Yd({},i),{enumerable:e}))})}}function dr(...e){const t=e.map(n=>Be(n));return()=>t.forEach(n=>n())}var Xa,Ya,Za,Ja,Qa,el,ke,Fs,Mi,Zi,Ji,be,Bs,Ci,tl,Qi,Ns,Ii,es,ts;el=[G],Qa=[G],Ja=[G],Za=[Pi()],Ya=[Pi()],Xa=[Pi()];var Wt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,St(ke,5,this),In(this,be),In(this,Fs,St(ke,8,this)),St(ke,11,this),In(this,Bs,St(ke,12,this)),St(ke,15,this),In(this,Ns,St(ke,16,this)),St(ke,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Le(this,be,es)}get initial(){return Le(this,be,Zi)}get previous(){return Le(this,be,tl)}set current(e){const t=N(()=>Le(this,be,es));e&&t&&this.equals(t,e)||oe(()=>{Le(this,be,Zi)||vt(this,be,e,Ji),vt(this,be,t,Qi),vt(this,be,e,ts)})}reset(e=this.defaultValue){oe(()=>{vt(this,be,void 0,Qi),vt(this,be,e,Ji),vt(this,be,e,ts)})}};ke=Jd();Fs=new WeakMap;be=new WeakSet;Bs=new WeakMap;Ns=new WeakMap;Mi=bn(ke,20,"#initial",el,be,Fs),Zi=Mi.get,Ji=Mi.set;Ci=bn(ke,20,"#previous",Qa,be,Bs),tl=Ci.get,Qi=Ci.set;Ii=bn(ke,20,"#current",Ja,be,Ns),es=Ii.get,ts=Ii.set;bn(ke,2,"current",Za,Wt);bn(ke,2,"initial",Ya,Wt);bn(ke,2,"previous",Xa,Wt);Ua(ke,Wt);function ji(e){return N(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var $t,nu=class{constructor(){In(this,$t,new WeakMap)}get(e,t){var n;return e?(n=Le(this,$t).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Le(this,$t).has(e)||Le(this,$t).set(e,new Map),(r=Le(this,$t).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Le(this,$t).get(e))==null?void 0:t.clear():void 0}};$t=new WeakMap;var ru=Object.create,nl=Object.defineProperty,iu=Object.getOwnPropertyDescriptor,Yo=Object.getOwnPropertySymbols,su=Object.prototype.hasOwnProperty,ou=Object.prototype.propertyIsEnumerable,rl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),pi=e=>{throw TypeError(e)},Zo=Math.pow,ns=(e,t,n)=>t in e?nl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,au=(e,t)=>{for(var n in t||(t={}))su.call(t,n)&&ns(e,n,t[n]);if(Yo)for(var n of Yo(t))ou.call(t,n)&&ns(e,n,t[n]);return e},lu=e=>{var t;return[,,,ru((t=e?.[rl("metadata")])!=null?t:null)]},il=["class","method","getter","setter","accessor","field","value","get","set"],sl=e=>e!==void 0&&typeof e!="function"?pi("Function expected"):e,cu=(e,t,n,r,i)=>({kind:il[e],name:t,metadata:r,addInitializer:s=>n._?pi("Already initialized"):i.push(sl(s||null))}),du=(e,t)=>ns(t,rl("metadata"),e[3]),uu=(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},ol=(e,t,n,r,i,s)=>{for(var o,a,c,d,u=t&7,l=!1,f=!1,g=2,h=il[u+5],m=e[g]||(e[g]=[]),w=(i=i.prototype,iu(i,n)),b=r.length-1;b>=0;b--)c=cu(u,n,a={},e[3],m),c.static=l,c.private=f,d=c.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[b])(w[h],c),a._=1,sl(o)&&(w[h]=o);return w&&nl(i,n,w),i},al=(e,t,n)=>t.has(e)||pi("Cannot "+n),fu=(e,t,n)=>(al(e,t,"read from private field"),t.get(e)),hu=(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),pu=(e,t,n,r)=>(al(e,t,"write to private field"),t.set(e,n),n),ze=class rs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new rs(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 rs(t,n)}},tt=class Ot{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 Ot(i+t,r+n,s,o);return c.scale=au({},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 ze((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ot))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 Ot?gu(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 Ot(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 ze.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Ot.from(t).intersectionRatio(Ot.from(n))}};function gu(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 ll,cl,is,Ir,ur,gi=class extends(is=Wt,cl=[le],ll=[le],is){constructor(t){const n=ze.from(t);super(n,(r,i)=>ze.equals(r,i)),uu(ur,5,this),hu(this,Ir,0),this.velocity={x:0,y:0}}get delta(){return ze.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=ze.from(t),i={x:r.x-n.x,y:r.y-n.y},s=Date.now(),o=s-fu(this,Ir),a=c=>Math.round(c/o*100);oe(()=>{pu(this,Ir,s),this.velocity={x:a(i.x),y:a(i.y)},super.current=r})}reset(t=this.defaultValue){super.reset(ze.from(t)),this.velocity={x:0,y:0}}};ur=lu(is);Ir=new WeakMap;ol(ur,2,"delta",cl,gi);ol(ur,2,"direction",ll,gi);du(ur,gi);function ss({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(Zo(r,2)+Zo(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 dl=(e=>(e.Horizontal="x",e.Vertical="y",e))(dl||{}),ul=Object.values(dl),vu=Object.create,Gs=Object.defineProperty,mu=Object.defineProperties,yu=Object.getOwnPropertyDescriptor,bu=Object.getOwnPropertyDescriptors,Xr=Object.getOwnPropertySymbols,fl=Object.prototype.hasOwnProperty,hl=Object.prototype.propertyIsEnumerable,pl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),xn=e=>{throw TypeError(e)},os=(e,t,n)=>t in e?Gs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vs=(e,t)=>{for(var n in t||(t={}))fl.call(t,n)&&os(e,n,t[n]);if(Xr)for(var n of Xr(t))hl.call(t,n)&&os(e,n,t[n]);return e},Hs=(e,t)=>mu(e,bu(t)),Jo=(e,t)=>Gs(e,"name",{value:t,configurable:!0}),gl=(e,t)=>{var n={};for(var r in e)fl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Xr)for(var r of Xr(e))t.indexOf(r)<0&&hl.call(e,r)&&(n[r]=e[r]);return n},_n=e=>{var t;return[,,,vu((t=e?.[pl("metadata")])!=null?t:null)]},vl=["class","method","getter","setter","accessor","field","value","get","set"],jn=e=>e!==void 0&&typeof e!="function"?xn("Function expected"):e,xu=(e,t,n,r,i)=>({kind:vl[e],name:t,metadata:r,addInitializer:s=>n._?xn("Already initialized"):i.push(jn(s||null))}),Ft=(e,t)=>os(t,pl("metadata"),e[3]),B=(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},V=(e,t,n,r,i,s)=>{var o,a,c,d,u,l=t&7,f=!!(t&8),g=!!(t&16),h=l>3?e.length+1:l?f?1:2:0,m=vl[l+5],w=l>3&&(e[h-1]=[]),b=e[h]||(e[h]=[]),v=l&&(!g&&!f&&(i=i.prototype),l<5&&(l>3||!g)&&yu(l<4?i:{get[n](){return ae(this,s)},set[n](x){return Ae(this,s,x)}},n));l?g&&l<4&&Jo(s,(l>2?"set ":l>1?"get ":"")+n):Jo(i,n);for(var p=r.length-1;p>=0;p--)d=xu(l,n,c={},e[3],b),l&&(d.static=f,d.private=g,u=d.access={has:g?x=>_u(i,x):x=>n in x},l^3&&(u.get=g?x=>(l^1?ae:ml)(x,i,l^4?s:v.get):x=>x[n]),l>2&&(u.set=g?(x,_)=>Ae(x,i,_,l^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(l?l<4?g?s:v[m]:l>4?void 0:{get:v.get,set:v.set}:i,d),c._=1,l^4||a===void 0?jn(a)&&(l>4?w.unshift(a):l?g?s=a:v[m]=a:i=a):typeof a!="object"||a===null?xn("Object expected"):(jn(o=a.get)&&(v.get=o),jn(o=a.set)&&(v.set=o),jn(o=a.init)&&w.unshift(o));return l||Ft(e,i),v&&Gs(i,n,v),g?l^4?s:v:i},Ks=(e,t,n)=>t.has(e)||xn("Cannot "+n),_u=(e,t)=>Object(t)!==t?xn('Cannot use the "in" operator on this value'):e.has(t),ae=(e,t,n)=>(Ks(e,t,"read from private field"),n?n.call(e):t.get(e)),q=(e,t,n)=>t.has(e)?xn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ae=(e,t,n,r)=>(Ks(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ml=(e,t,n)=>(Ks(e,t,"access private method"),n);function yl(e,t){return{plugin:e,options:t}}function fr(e){return t=>yl(e,t)}function tr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var bl,nr,qs,jr;bl=[G];var xe=class{constructor(e,t){this.manager=e,this.options=t,q(this,qs,B(nr,8,this,!1)),B(nr,11,this),q(this,jr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return N(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Be(e.bind(this));return ae(this,jr).add(t),t}destroy(){ae(this,jr).forEach(e=>e())}static configure(e){return yl(this,e)}};nr=_n(null);qs=new WeakMap;jr=new WeakMap;V(nr,4,"disabled",bl,xe,qs);Ft(nr,xe);var hr=class extends xe{},Ar,Ai=class{constructor(e){this.manager=e,this.instances=new Map,q(this,Ar,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(tr).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of ae(this,Ar))if(!n.includes(r)){if(r.prototype instanceof hr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);Ae(this,Ar,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()}};Ar=new WeakMap;function wu(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var _r=[],Yt,Zt,ku=class extends xe{constructor(e){super(e),q(this,Yt),q(this,Zt),this.computeCollisions=this.computeCollisions.bind(this),Ae(this,Zt,vn(_r)),this.destroy=dr(()=>{const t=this.computeCollisions(),n=N(()=>this.manager.dragOperation.position.current);if(t!==_r){const r=ae(this,Yt);if(Ae(this,Yt,n),r&&n.x==r.x&&n.y==r.y)return}else Ae(this,Yt,void 0);ae(this,Zt).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){N(()=>{e?ae(this,Zt).value=this.computeCollisions():Ae(this,Yt,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return _r;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=N(()=>u({droppable:d,dragOperation:r}));l&&(d.collisionPriority!=null&&(l.priority=d.collisionPriority),a.push(l))}return c.length===0?_r:(a.sort(wu),a)}get collisions(){return ae(this,Zt).value}};Yt=new WeakMap;Zt=new WeakMap;var xl,_l,wl,Us,kl,qe,Xs,rn,Ys,Zs;wl=[G],_l=[G],xl=[G];var dt=class Tt{constructor(t,n){q(this,Xs,B(qe,8,this)),B(qe,11,this),q(this,rn),q(this,Ys,B(qe,12,this)),B(qe,15,this),q(this,Zs,B(qe,16,this)),B(qe,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let c=i;Ae(this,rn,vn(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=ae(this,rn).value;return(n=(t=Tt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=Tt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:ae(this,rn).peek();t!==i&&(Tt.pendingIdChanges||(Tt.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return ml(s=Tt,Us,kl).call(s)})),Tt.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)}};qe=_n(null);Us=new WeakSet;kl=function(){const e=dt.pendingIdChanges;dt.pendingIdChanges=null,e&&oe(()=>{for(const[t,n]of e)ae(t,rn).value=n})};Xs=new WeakMap;rn=new WeakMap;Ys=new WeakMap;Zs=new WeakMap;V(qe,4,"manager",wl,dt,Xs);V(qe,4,"data",_l,dt,Ys);V(qe,4,"disabled",xl,dt,Zs);q(dt,Us);Ft(qe,dt);dt.pendingIdChanges=null;var vi=dt,Qo=class{constructor(){this.map=vn(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;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),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=dr(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),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){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Sl,$l,Ol,Tl,Dl,El,as,Se,Js,Qs,eo,nt=class extends(as=vi,El=[G],Dl=[G],Tl=[G],Ol=[le],$l=[le],Sl=[le],as){constructor(t,n){var r=t,{modifiers:i,type:s,sensors:o,plugins:a,effects:c}=r,d=gl(r,["modifiers","type","sensors","plugins","effects"]);super(Hs(Vs({},d),{effects:()=>{var u;return[...(u=c?.())!=null?u:[],()=>{const{manager:l,plugins:f}=this;if(!(!l||!f))for(const g of f){const{plugin:h}=tr(g);l.registry.plugins.register(h)}}]}}),n),B(Se,5,this),q(this,Js,B(Se,8,this)),B(Se,11,this),q(this,Qs,B(Se,12,this)),B(Se,15,this),q(this,eo,B(Se,16,this,this.isDragSource?"dragging":"idle")),B(Se,19,this),this.type=s,this.sensors=o,this.modifiers=i,this.alignment=d.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=tr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};Se=_n(as);Js=new WeakMap;Qs=new WeakMap;eo=new WeakMap;V(Se,4,"type",El,nt,Js);V(Se,4,"modifiers",Dl,nt,Qs);V(Se,4,"status",Tl,nt,eo);V(Se,2,"isDropping",Ol,nt);V(Se,2,"isDragging",$l,nt);V(Se,2,"isDragSource",Sl,nt);Ft(Se,nt);var Pl,Ml,Cl,Il,jl,Al,ls,ue,to,no,ro,io,so,rt=class extends(ls=vi,Al=[G],jl=[G],Il=[G],Cl=[G],Ml=[G],Pl=[le],ls){constructor(t,n){var r=t,{accept:i,collisionDetector:s,collisionPriority:o,type:a}=r,c=gl(r,["accept","collisionDetector","collisionPriority","type"]);super(c,n),B(ue,5,this),q(this,to,B(ue,8,this)),B(ue,11,this),q(this,no,B(ue,12,this)),B(ue,15,this),q(this,ro,B(ue,16,this)),B(ue,19,this),q(this,io,B(ue,20,this)),B(ue,23,this),q(this,so,B(ue,24,this)),B(ue,27,this),this.accept=i,this.collisionDetector=s,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};ue=_n(ls);to=new WeakMap;no=new WeakMap;ro=new WeakMap;io=new WeakMap;so=new WeakMap;V(ue,4,"accept",Al,rt,to);V(ue,4,"type",jl,rt,no);V(ue,4,"collisionDetector",Il,rt,ro);V(ue,4,"collisionPriority",Cl,rt,io);V(ue,4,"shape",Ml,rt,so);V(ue,2,"isDropTarget",Pl,rt);Ft(ue,rt);var Su=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)}},$u=class extends Su{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Rr(e,t=!0){let n=!1;return Hs(Vs({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Ou=class extends hr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=dr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||vi.pendingIdChanges)return;const o=Rr({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;N(()=>{var c;a?.id!==((c=e.dragOperation.target)==null?void 0:c.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},wn=(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))(wn||{}),kn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(kn||{}),Rl,Ll,zl,Wl,Fl,Bl,Nl,Fe,oo;Nl=[G],Bl=[le],Fl=[le],Wl=[le],zl=[le],Ll=[le],Rl=[le];var ut=class{constructor(){B(Fe,5,this),q(this,oo,B(Fe,8,this,"idle")),B(Fe,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}};Fe=_n(null);oo=new WeakMap;V(Fe,4,"value",Nl,ut,oo);V(Fe,2,"current",Bl,ut);V(Fe,2,"idle",Fl,ut);V(Fe,2,"initializing",Wl,ut);V(Fe,2,"initialized",zl,ut);V(Fe,2,"dragging",Ll,ut);V(Fe,2,"dropped",Rl,ut);Ft(Fe,ut);var Tu=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 N(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Rr({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return N(()=>{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 r=new AbortController,{event:i,coordinates:s}=e;oe(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=i??null,t.position.reset(s)});const o=Rr({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&oe(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:i,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return N(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Rr({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 N(()=>{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=N(()=>{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=Be(()=>{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()})}},cn=class extends xe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Du=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)}},Lr,Gl=class{constructor(e){this.options=e,q(this,Lr)}set controller(e){Ae(this,Lr,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=ae(this,Lr))==null||t.activate(e)}};Lr=new WeakMap;var ea=class extends xe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Eu=class{constructor(e){this.draggables=new Qo,this.droppables=new Qo,this.plugins=new Ai(e),this.sensors=new Ai(e),this.modifiers=new Ai(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 ea)return this.modifiers.register(e,t);if(e.prototype instanceof cn)return this.sensors.register(e,t);if(e.prototype instanceof xe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof vi)return e instanceof nt?this.draggables.unregister(e.id,e):e instanceof rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ea)return this.modifiers.unregister(e);if(e.prototype instanceof cn)return this.sensors.unregister(e);if(e.prototype instanceof xe)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()}},Vl,Hl,Kl,ql,Ul,Xl,Yl,Zl,Jl,An,zr,Jt,se,ao,lo,co,uo,fo,Rn;Jl=[le],Zl=[G],Yl=[G],Xl=[G],Ul=[G],ql=[G],Kl=[le],Hl=[le],Vl=[le];var Xe=class{constructor(e){B(se,5,this),q(this,An),q(this,zr),q(this,Jt,new Wt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new ut,q(this,ao,B(se,8,this,!1)),B(se,11,this),q(this,lo,B(se,12,this,null)),B(se,15,this),q(this,co,B(se,16,this,null)),B(se,19,this),q(this,uo,B(se,20,this,null)),B(se,23,this),q(this,fo,B(se,24,this,[])),B(se,27,this),this.position=new gi({x:0,y:0}),q(this,Rn,{x:0,y:0}),Ae(this,An,e)}get shape(){const{current:e,initial:t,previous:n}=ae(this,Jt);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?ae(this,Jt).current=e:ae(this,Jt).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=ae(this,An).registry.draggables.get(t);return n&&Ae(this,zr,n),(e=n??ae(this,zr))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=ae(this,An).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(Hs(Vs({},this.snapshot()),{transform:n}));return Ae(this,Rn,n),n}snapshot(){return N(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:ae(this,Rn),shape:this.shape?ji(this.shape):null,position:ji(this.position),status:ji(this.status),canceled:this.canceled}))}reset(){oe(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,ae(this,Jt).reset(),this.position.reset({x:0,y:0}),Ae(this,Rn,{x:0,y:0}),this.modifiers=[]})}};se=_n(null);An=new WeakMap;zr=new WeakMap;Jt=new WeakMap;ao=new WeakMap;lo=new WeakMap;co=new WeakMap;uo=new WeakMap;fo=new WeakMap;Rn=new WeakMap;V(se,2,"shape",Jl,Xe);V(se,4,"canceled",Zl,Xe,ao);V(se,4,"activatorEvent",Yl,Xe,lo);V(se,4,"sourceIdentifier",Xl,Xe,co);V(se,4,"targetIdentifier",Ul,Xe,uo);V(se,4,"modifiers",ql,Xe,fo);V(se,2,"source",Kl,Xe);V(se,2,"target",Hl,Xe);V(se,2,"transform",Vl,Xe);Ft(se,Xe);var Pu={get rendering(){return Promise.resolve()}};function Ue(e,t){return typeof e=="function"?e(t):e??t}var Mu=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(f=>f.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},i=Ue(r.plugins,[]),s=Ue(r.sensors,[]),o=Ue(r.modifiers,[]),a=(n=r.renderer)!=null?n:Pu,c=new $u(this),d=new Eu(this);this.registry=d,this.monitor=c,this.renderer=a,this.actions=new Tu(this),this.dragOperation=new Xe(this),this.collisionObserver=new ku(this),this.plugins=[Ou,...i],this.modifiers=o,this.sensors=s;const{destroy:u}=this,l=dr(()=>{var f,g,h;const m=N(()=>this.dragOperation.modifiers),w=this.modifiers;for(const b of m)w.includes(b)||b.destroy();this.dragOperation.modifiers=(h=(g=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:g.map(b=>{const{plugin:v,options:p}=tr(b);return new v(this,p)}))!=null?h:w});this.destroy=()=>{l(),u()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},Ql=e=>{throw TypeError(e)},ho=(e,t,n)=>t.has(e)||Ql("Cannot "+n),F=(e,t,n)=>(ho(e,t,"read from private field"),t.get(e)),Ee=(e,t,n)=>t.has(e)?Ql("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),je=(e,t,n,r)=>(ho(e,t,"write to private field"),t.set(e,n),n),ec=(e,t,n)=>(ho(e,t,"access private method"),n);function mi(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function tc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,a=(mi(s)?s.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],i])}return r}function yi(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 po(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function pr(e){return"nodeType"in e}function Re(e){var t,n,r;return e?po(e)?e:pr(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 go(e){const{Document:t}=Re(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function _t(e){return!e||po(e)?!1:e instanceof Re(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function nc(e){return e instanceof Re(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Sn(e){return e?po(e)?e.document:pr(e)?go(e)?e:_t(e)||nc(e)?e.ownerDocument:document:document:document}function Cu(e){var t,n,r,i;const{documentElement:s}=Sn(e),o=Re(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 Iu(e,t){if(ju(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function ju(e){return e.tagName==="DETAILS"}function rr(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(!Iu(l)){const p=l.getBoundingClientRect(),x=n*(p.bottom-p.top),_=n*(p.right-p.left),$=n*(p.bottom-p.top),T=n*(p.right-p.left);c={top:Math.max(c.top,p.top-x),right:Math.min(c.right,p.right+_),bottom:Math.min(c.bottom,p.bottom+$),left:Math.max(c.left,p.left-T),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top}l=l.parentElement}const f=u.visualViewport,g=(i=f?.offsetTop)!=null?i:0,h=(s=f?.offsetLeft)!=null?s:0,m=(o=f?.width)!=null?o:u.innerWidth,w=(a=f?.height)!=null?a:u.innerHeight,b=n*w,v=n*m;return c={top:Math.max(c.top,g-b),right:Math.min(c.right,h+m+v),bottom:Math.min(c.bottom,g+w+b),left:Math.max(c.left,h-v),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 dn(e){return{x:e.clientX,y:e.clientY}}var rc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function cs(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(...cs(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(...cs(i.document,t))}}catch{}return n}function vo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function ic(){var e,t;const n=vo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function mo(e){return!e||!pr(e)?!1:e instanceof Re(e).ShadowRoot}function Yr(e){if(e&&pr(e)){let t=e.getRootNode();if(mo(t))return t;if(t instanceof Document)return t}return Sn(e)}function yo(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Au(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((s,o)=>{const a=r[o];if(ta(s)&&ta(a)&&(s.type!=="file"&&(s.value=a.value),s.type==="radio"&&s.name&&(s.name=`Cloned__${s.name}`)),na(s)&&na(a)&&a.width>0&&a.height>0){const c=s.getContext("2d");c?.drawImage(a,0,0)}}),n}function ta(e){return"value"in e}function na(e){return e.tagName==="CANVAS"}function sc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Ru(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return sc(i,{x:t-s,y:n-o})}}return r}function Ru(e){return e?.tagName==="IFRAME"}var ds=new WeakMap;function Lu(e){return e.closest(`
1
+ "use strict";var Id=Object.create;var Xo=Object.defineProperty;var jd=Object.getOwnPropertyDescriptor;var Ad=Object.getOwnPropertyNames;var Rd=Object.getPrototypeOf,Ld=Object.prototype.hasOwnProperty;var zd=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ad(t))!Ld.call(e,i)&&i!==n&&Xo(e,i,{get:()=>t[i],enumerable:!(r=jd(t,i))||r.enumerable});return e};var Yo=(e,t,n)=>(n=e!=null?Id(Rd(e)):{},zd(t||!e||!e.__esModule?Xo(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),S=require("react"),Wd=require("react-dom"),k=require("@mui/material"),j=require("../DocumentStorage-CMyLifsz.cjs.js"),Le=require("../ServerProvider-Cc489A3f.cjs.js"),Fd=require("@tanstack/react-query");var Bd=Symbol.for("preact-signals");function Si(){if(gt>1)gt--;else{var e,t=!1;for((function(){var i=ii;for(ii=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}})();rr!==void 0;){var n=rr;for(rr=void 0,ri++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ua(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(ri=0,gt--,t)throw e}}function ae(e){if(gt>0)return e();rs=++Nd,gt++;try{return e()}finally{Si()}}var nr,re=void 0;function H(e){var t=re,n=nr;re=void 0,nr=void 0;try{return e()}finally{re=t,nr=n}}var rr=void 0,gt=0,ri=0,Nd=0,rs=0,ii=void 0,si=0;function qa(e){if(re!==void 0){var t=e.n;if(t===void 0||t.t!==re)return t={i:0,S:e,p:re.s,n:void 0,t:re,e:void 0,x:void 0,r:t},re.s!==void 0&&(re.s.n=t),re.s=t,e.n=t,32&re.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=re.s,t.n=void 0,re.s.n=t,re.s=t),t}}function Me(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}Me.prototype.brand=Bd;Me.prototype.h=function(){return!0};Me.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:H(function(){var r;(r=t.W)==null||r.call(t)}))};Me.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&&H(function(){var i;(i=t.Z)==null||i.call(t)}))}};Me.prototype.subscribe=function(e){var t=this;return Qe(function(){var n=t.value;H(function(){return e(n)})},{name:"sub"})};Me.prototype.valueOf=function(){return this.value};Me.prototype.toString=function(){return this.value+""};Me.prototype.toJSON=function(){return this.value};Me.prototype.peek=function(){var e=this;return H(function(){return e.value})};Object.defineProperty(Me.prototype,"value",{get:function(){var e=qa(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ri>100)throw new Error("Cycle detected");(function(n){gt!==0&&ri===0&&n.l!==rs&&(n.l=rs,ii={S:n,v:n.v,i:n.i,o:ii})})(this),this.v=e,this.i++,si++,gt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Si()}}}});function wn(e,t){return new Me(e,t)}function Ua(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 Xa(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 Ya(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Gt(e,t){Me.call(this,void 0,t),this.x=e,this.s=void 0,this.g=si-1,this.f=4}Gt.prototype=new Me;Gt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===si))return!0;if(this.g=si,this.f|=1,this.i>0&&!Ua(this))return this.f&=-2,!0;var e=re;try{Xa(this),re=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 re=e,Ya(this),this.f&=-2,!0};Gt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Me.prototype.S.call(this,e)};Gt.prototype.U=function(e){if(this.t!==void 0&&(Me.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Gt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Gt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=qa(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Zo(e,t){return new Gt(e,t)}function Za(e){var t=e.m;if(e.m=void 0,typeof t=="function"){gt++;var n=re;re=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ks(e),r}finally{re=n,Si()}}}function Ks(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Za(e)}function Gd(e){if(re!==this)throw new Error("Out-of-order effect");Ya(this),re=e,this.f&=-2,8&this.f&&Ks(this),Si()}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,nr&&nr.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,Za(this),Xa(this),gt++;var e=re;return re=this,Gd.bind(this,e)};kn.prototype.N=function(){2&this.f||(this.f|=2,this.u=rr,rr=this)};kn.prototype.d=function(){this.f|=8,1&this.f||Ks(this)};kn.prototype.dispose=function(){this.d()};function Qe(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 Vd=Object.create,qs=Object.defineProperty,Hd=Object.defineProperties,Kd=Object.getOwnPropertyDescriptor,qd=Object.getOwnPropertyDescriptors,Qo=Object.getOwnPropertySymbols,Ud=Object.prototype.hasOwnProperty,Xd=Object.prototype.propertyIsEnumerable,Yd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Sn=e=>{throw TypeError(e)},is=(e,t,n)=>t in e?qs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zd=(e,t)=>{for(var n in t||(t={}))Ud.call(t,n)&&is(e,n,t[n]);if(Qo)for(var n of Qo(t))Xd.call(t,n)&&is(e,n,t[n]);return e},Qd=(e,t)=>Hd(e,qd(t)),Jo=(e,t)=>qs(e,"name",{value:t,configurable:!0}),Jd=e=>{var t;return[,,,Vd((t=void 0)!=null?t:null)]},Qa=["class","method","getter","setter","accessor","field","value","get","set"],Fn=e=>e!==void 0&&typeof e!="function"?Sn("Function expected"):e,eu=(e,t,n,r,i)=>({kind:Qa[e],name:t,metadata:r,addInitializer:s=>n._?Sn("Already initialized"):i.push(Fn(s||null))}),Ja=(e,t)=>is(t,Yd("metadata"),e[3]),Dt=(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},$n=(e,t,n,r,i,s)=>{var o,a,l,d,u,c=t&7,h=!!(t&8),f=!!(t&16),g=c>3?e.length+1:c?h?1:2:0,m=Qa[c+5],w=c>3&&(e[g-1]=[]),b=e[g]||(e[g]=[]),v=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&Kd(c<4?i:{get[n](){return Ue(this,s)},set[n](x){return wt(this,s,x)}},n));c?f&&c<4&&Jo(s,(c>2?"set ":c>1?"get ":"")+n):Jo(i,n);for(var p=r.length-1;p>=0;p--)d=eu(c,n,l={},e[3],b),c&&(d.static=h,d.private=f,u=d.access={has:f?x=>tu(i,x):x=>n in x},c^3&&(u.get=f?x=>(c^1?Ue:nu)(x,i,c^4?s:v.get):x=>x[n]),c>2&&(u.set=f?(x,_)=>wt(x,i,_,c^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(c?c<4?f?s:v[m]:c>4?void 0:{get:v.get,set:v.set}:i,d),l._=1,c^4||a===void 0?Fn(a)&&(c>4?w.unshift(a):c?f?s=a:v[m]=a:i=a):typeof a!="object"||a===null?Sn("Object expected"):(Fn(o=a.get)&&(v.get=o),Fn(o=a.set)&&(v.set=o),Fn(o=a.init)&&w.unshift(o));return c||Ja(e,i),v&&qs(i,n,v),f?c^4?s:v:i},Us=(e,t,n)=>t.has(e)||Sn("Cannot "+n),tu=(e,t)=>Object(t)!==t?Sn('Cannot use the "in" operator on this value'):e.has(t),Ue=(e,t,n)=>(Us(e,t,"read from private field"),n?n.call(e):t.get(e)),Bn=(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),wt=(e,t,n,r)=>(Us(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),nu=(e,t,n)=>(Us(e,t,"access private method"),n);function ss(e,t){if(t){let n;return Zo(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Zo(e)}function nt(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((r,i)=>!nt(r,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(s=>!nt(e[s],t[s]))}return!1}function K({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 ce(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=ss(e.bind(this)),n.set(this,r)),r.value}}function Wi(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,Qd(Zd({},i),{enumerable:e}))})}}function yr(...e){const t=e.map(n=>Qe(n));return()=>t.forEach(n=>n())}var el,tl,nl,rl,il,sl,De,Xs,Fi,os,as,Te,Ys,Bi,ol,ls,Zs,Ni,cs,ds;sl=[K],il=[K],rl=[K],nl=[Wi()],tl=[Wi()],el=[Wi()];var Vt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Dt(De,5,this),Bn(this,Te),Bn(this,Xs,Dt(De,8,this)),Dt(De,11,this),Bn(this,Ys,Dt(De,12,this)),Dt(De,15,this),Bn(this,Zs,Dt(De,16,this)),Dt(De,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Ue(this,Te,cs)}get initial(){return Ue(this,Te,os)}get previous(){return Ue(this,Te,ol)}set current(e){const t=H(()=>Ue(this,Te,cs));e&&t&&this.equals(t,e)||ae(()=>{Ue(this,Te,os)||wt(this,Te,e,as),wt(this,Te,t,ls),wt(this,Te,e,ds)})}reset(e=this.defaultValue){ae(()=>{wt(this,Te,void 0,ls),wt(this,Te,e,as),wt(this,Te,e,ds)})}};De=Jd();Xs=new WeakMap;Te=new WeakSet;Ys=new WeakMap;Zs=new WeakMap;Fi=$n(De,20,"#initial",sl,Te,Xs),os=Fi.get,as=Fi.set;Bi=$n(De,20,"#previous",il,Te,Ys),ol=Bi.get,ls=Bi.set;Ni=$n(De,20,"#current",rl,Te,Zs),cs=Ni.get,ds=Ni.set;$n(De,2,"current",nl,Vt);$n(De,2,"initial",tl,Vt);$n(De,2,"previous",el,Vt);Ja(De,Vt);function Gi(e){return H(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Pt,ru=class{constructor(){Bn(this,Pt,new WeakMap)}get(e,t){var n;return e?(n=Ue(this,Pt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Ue(this,Pt).has(e)||Ue(this,Pt).set(e,new Map),(r=Ue(this,Pt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Ue(this,Pt).get(e))==null?void 0:t.clear():void 0}};Pt=new WeakMap;var iu=Object.create,al=Object.defineProperty,su=Object.getOwnPropertyDescriptor,ea=Object.getOwnPropertySymbols,ou=Object.prototype.hasOwnProperty,au=Object.prototype.propertyIsEnumerable,ll=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),$i=e=>{throw TypeError(e)},ta=Math.pow,us=(e,t,n)=>t in e?al(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lu=(e,t)=>{for(var n in t||(t={}))ou.call(t,n)&&us(e,n,t[n]);if(ea)for(var n of ea(t))au.call(t,n)&&us(e,n,t[n]);return e},cu=e=>{var t;return[,,,iu((t=e?.[ll("metadata")])!=null?t:null)]},cl=["class","method","getter","setter","accessor","field","value","get","set"],dl=e=>e!==void 0&&typeof e!="function"?$i("Function expected"):e,du=(e,t,n,r,i)=>({kind:cl[e],name:t,metadata:r,addInitializer:s=>n._?$i("Already initialized"):i.push(dl(s||null))}),uu=(e,t)=>us(t,ll("metadata"),e[3]),fu=(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},ul=(e,t,n,r,i,s)=>{for(var o,a,l,d,u=t&7,c=!1,h=!1,f=2,g=cl[u+5],m=e[f]||(e[f]=[]),w=(i=i.prototype,su(i,n)),b=r.length-1;b>=0;b--)l=du(u,n,a={},e[3],m),l.static=c,l.private=h,d=l.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[b])(w[g],l),a._=1,dl(o)&&(w[g]=o);return w&&al(i,n,w),i},fl=(e,t,n)=>t.has(e)||$i("Cannot "+n),hu=(e,t,n)=>(fl(e,t,"read from private field"),t.get(e)),pu=(e,t,n)=>t.has(e)?$i("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),gu=(e,t,n,r)=>(fl(e,t,"write to private field"),t.set(e,n),n),Xe=class fs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new fs(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 fs(t,n)}},lt=class Ct{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,l=new Ct(i+t,r+n,s,o);return l.scale=lu({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new Xe((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ct))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 Ct?vu(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 Ct(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],l=o==="x"?s.left:s.top,d=o==="x"?s.width:s.height;return a=="start"?l:a=="end"?l+d:l+d/2};return Xe.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Ct.from(t).intersectionRatio(Ct.from(n))}};function vu(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 hl,pl,hs,Vr,br,Oi=class extends(hs=Vt,pl=[ce],hl=[ce],hs){constructor(t){const n=Xe.from(t);super(n,(r,i)=>Xe.equals(r,i)),fu(br,5,this),pu(this,Vr,0),this.velocity={x:0,y:0}}get delta(){return Xe.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Xe.from(t),i={x:r.x-n.x,y:r.y-n.y},s=Date.now(),o=s-hu(this,Vr),a=l=>Math.round(l/o*100);ae(()=>{gu(this,Vr,s),this.velocity={x:a(i.x),y:a(i.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Xe.from(t)),this.velocity={x:0,y:0}}};br=cu(hs);Vr=new WeakMap;ul(br,2,"delta",pl,Oi);ul(br,2,"direction",hl,Oi);uu(br,Oi);function ps({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(ta(r,2)+ta(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 gl=(e=>(e.Horizontal="x",e.Vertical="y",e))(gl||{}),vl=Object.values(gl),mu=Object.create,Qs=Object.defineProperty,yu=Object.defineProperties,bu=Object.getOwnPropertyDescriptor,xu=Object.getOwnPropertyDescriptors,oi=Object.getOwnPropertySymbols,ml=Object.prototype.hasOwnProperty,yl=Object.prototype.propertyIsEnumerable,bl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),On=e=>{throw TypeError(e)},gs=(e,t,n)=>t in e?Qs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Js=(e,t)=>{for(var n in t||(t={}))ml.call(t,n)&&gs(e,n,t[n]);if(oi)for(var n of oi(t))yl.call(t,n)&&gs(e,n,t[n]);return e},eo=(e,t)=>yu(e,xu(t)),na=(e,t)=>Qs(e,"name",{value:t,configurable:!0}),xl=(e,t)=>{var n={};for(var r in e)ml.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&oi)for(var r of oi(e))t.indexOf(r)<0&&yl.call(e,r)&&(n[r]=e[r]);return n},Tn=e=>{var t;return[,,,mu((t=e?.[bl("metadata")])!=null?t:null)]},_l=["class","method","getter","setter","accessor","field","value","get","set"],Nn=e=>e!==void 0&&typeof e!="function"?On("Function expected"):e,_u=(e,t,n,r,i)=>({kind:_l[e],name:t,metadata:r,addInitializer:s=>n._?On("Already initialized"):i.push(Nn(s||null))}),Ht=(e,t)=>gs(t,bl("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,l,d,u,c=t&7,h=!!(t&8),f=!!(t&16),g=c>3?e.length+1:c?h?1:2:0,m=_l[c+5],w=c>3&&(e[g-1]=[]),b=e[g]||(e[g]=[]),v=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&bu(c<4?i:{get[n](){return le(this,s)},set[n](x){return Ve(this,s,x)}},n));c?f&&c<4&&na(s,(c>2?"set ":c>1?"get ":"")+n):na(i,n);for(var p=r.length-1;p>=0;p--)d=_u(c,n,l={},e[3],b),c&&(d.static=h,d.private=f,u=d.access={has:f?x=>wu(i,x):x=>n in x},c^3&&(u.get=f?x=>(c^1?le:wl)(x,i,c^4?s:v.get):x=>x[n]),c>2&&(u.set=f?(x,_)=>Ve(x,i,_,c^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(c?c<4?f?s:v[m]:c>4?void 0:{get:v.get,set:v.set}:i,d),l._=1,c^4||a===void 0?Nn(a)&&(c>4?w.unshift(a):c?f?s=a:v[m]=a:i=a):typeof a!="object"||a===null?On("Object expected"):(Nn(o=a.get)&&(v.get=o),Nn(o=a.set)&&(v.set=o),Nn(o=a.init)&&w.unshift(o));return c||Ht(e,i),v&&Qs(i,n,v),f?c^4?s:v:i},to=(e,t,n)=>t.has(e)||On("Cannot "+n),wu=(e,t)=>Object(t)!==t?On('Cannot use the "in" operator on this value'):e.has(t),le=(e,t,n)=>(to(e,t,"read from private field"),n?n.call(e):t.get(e)),Z=(e,t,n)=>t.has(e)?On("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ve=(e,t,n,r)=>(to(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),wl=(e,t,n)=>(to(e,t,"access private method"),n);function kl(e,t){return{plugin:e,options:t}}function xr(e){return t=>kl(e,t)}function cr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Sl,dr,no,Hr;Sl=[K];var Ee=class{constructor(e,t){this.manager=e,this.options=t,Z(this,no,N(dr,8,this,!1)),N(dr,11,this),Z(this,Hr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return H(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Qe(e.bind(this));return le(this,Hr).add(t),t}destroy(){le(this,Hr).forEach(e=>e())}static configure(e){return kl(this,e)}};dr=Tn(null);no=new WeakMap;Hr=new WeakMap;q(dr,4,"disabled",Sl,Ee,no);Ht(dr,Ee);var _r=class extends Ee{},Kr,Vi=class{constructor(e){this.manager=e,this.instances=new Map,Z(this,Kr,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(cr).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 le(this,Kr))if(!n.includes(r)){if(r.prototype instanceof _r)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);Ve(this,Kr,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()}};Kr=new WeakMap;function ku(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Mr=[],nn,rn,Su=class extends Ee{constructor(e){super(e),Z(this,nn),Z(this,rn),this.computeCollisions=this.computeCollisions.bind(this),Ve(this,rn,wn(Mr)),this.destroy=yr(()=>{const t=this.computeCollisions(),n=H(()=>this.manager.dragOperation.position.current);if(t!==Mr){const r=le(this,nn);if(Ve(this,nn,n),r&&n.x==r.x&&n.y==r.y)return}else Ve(this,nn,void 0);le(this,rn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){H(()=>{e?le(this,rn).value=this.computeCollisions():Ve(this,nn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Mr;const a=[],l=[];for(const d of e??n.droppables){if(d.disabled||i&&!d.accepts(i))continue;const u=t??d.collisionDetector;if(!u)continue;l.push(d),d.shape;const c=H(()=>u({droppable:d,dragOperation:r}));c&&(d.collisionPriority!=null&&(c.priority=d.collisionPriority),a.push(c))}return l.length===0?Mr:(a.sort(ku),a)}get collisions(){return le(this,rn).value}};nn=new WeakMap;rn=new WeakMap;var $l,Ol,Tl,ro,El,rt,io,dn,so,oo;Tl=[K],Ol=[K],$l=[K];var mt=class Mt{constructor(t,n){Z(this,io,N(rt,8,this)),N(rt,11,this),Z(this,dn),Z(this,so,N(rt,12,this)),N(rt,15,this),Z(this,oo,N(rt,16,this)),N(rt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let l=i;Ve(this,dn,wn(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var d;return[()=>{const{id:u,manager:c}=this;if(u!==l)return l=u,c?.registry.register(this),()=>c?.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=le(this,dn).value;return(n=(t=Mt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=Mt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:le(this,dn).peek();t!==i&&(Mt.pendingIdChanges||(Mt.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return wl(s=Mt,ro,El).call(s)})),Mt.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)}};rt=Tn(null);ro=new WeakSet;El=function(){const e=mt.pendingIdChanges;mt.pendingIdChanges=null,e&&ae(()=>{for(const[t,n]of e)le(t,dn).value=n})};io=new WeakMap;dn=new WeakMap;so=new WeakMap;oo=new WeakMap;q(rt,4,"manager",Tl,mt,io);q(rt,4,"data",Ol,mt,so);q(rt,4,"disabled",$l,mt,oo);Z(mt,ro);Ht(rt,mt);mt.pendingIdChanges=null;var Ti=mt,ra=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;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const s=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=yr(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),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){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Dl,Pl,Cl,Ml,Il,jl,vs,Pe,ao,lo,co,ct=class extends(vs=Ti,jl=[K],Il=[K],Ml=[K],Cl=[ce],Pl=[ce],Dl=[ce],vs){constructor(t,n){var r=t,{modifiers:i,type:s,sensors:o,plugins:a,effects:l}=r,d=xl(r,["modifiers","type","sensors","plugins","effects"]);super(eo(Js({},d),{effects:()=>{var u;return[...(u=l?.())!=null?u:[],()=>{const{manager:c,plugins:h}=this;if(!(!c||!h))for(const f of h){const{plugin:g}=cr(f);c.registry.plugins.register(g)}}]}}),n),N(Pe,5,this),Z(this,ao,N(Pe,8,this)),N(Pe,11,this),Z(this,lo,N(Pe,12,this)),N(Pe,15,this),Z(this,co,N(Pe,16,this,this.isDragSource?"dragging":"idle")),N(Pe,19,this),this.type=s,this.sensors=o,this.modifiers=i,this.alignment=d.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=cr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};Pe=Tn(vs);ao=new WeakMap;lo=new WeakMap;co=new WeakMap;q(Pe,4,"type",jl,ct,ao);q(Pe,4,"modifiers",Il,ct,lo);q(Pe,4,"status",Ml,ct,co);q(Pe,2,"isDropping",Cl,ct);q(Pe,2,"isDragging",Pl,ct);q(Pe,2,"isDragSource",Dl,ct);Ht(Pe,ct);var Al,Rl,Ll,zl,Wl,Fl,ms,he,uo,fo,ho,po,go,dt=class extends(ms=Ti,Fl=[K],Wl=[K],zl=[K],Ll=[K],Rl=[K],Al=[ce],ms){constructor(t,n){var r=t,{accept:i,collisionDetector:s,collisionPriority:o,type:a}=r,l=xl(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),N(he,5,this),Z(this,uo,N(he,8,this)),N(he,11,this),Z(this,fo,N(he,12,this)),N(he,15,this),Z(this,ho,N(he,16,this)),N(he,19,this),Z(this,po,N(he,20,this)),N(he,23,this),Z(this,go,N(he,24,this)),N(he,27,this),this.accept=i,this.collisionDetector=s,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};he=Tn(ms);uo=new WeakMap;fo=new WeakMap;ho=new WeakMap;po=new WeakMap;go=new WeakMap;q(he,4,"accept",Fl,dt,uo);q(he,4,"type",Wl,dt,fo);q(he,4,"collisionDetector",zl,dt,ho);q(he,4,"collisionPriority",Ll,dt,po);q(he,4,"shape",Rl,dt,go);q(he,2,"isDropTarget",Al,dt);Ht(he,dt);var $u=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)}},Ou=class extends $u{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function qr(e,t=!0){let n=!1;return eo(Js({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Tu=class extends _r{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=yr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Ti.pendingIdChanges)return;const o=qr({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;H(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},En=(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))(En||{}),Dn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Dn||{}),Bl,Nl,Gl,Vl,Hl,Kl,ql,Ze,vo;ql=[K],Kl=[ce],Hl=[ce],Vl=[ce],Gl=[ce],Nl=[ce],Bl=[ce];var yt=class{constructor(){N(Ze,5,this),Z(this,vo,N(Ze,8,this,"idle")),N(Ze,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}};Ze=Tn(null);vo=new WeakMap;q(Ze,4,"value",ql,yt,vo);q(Ze,2,"current",Kl,yt);q(Ze,2,"idle",Hl,yt);q(Ze,2,"initializing",Vl,yt);q(Ze,2,"initialized",Gl,yt);q(Ze,2,"dragging",Nl,yt);q(Ze,2,"dropped",Bl,yt);Ht(Ze,yt);var Eu=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 H(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=qr({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return H(()=>{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 r=new AbortController,{event:i,coordinates:s}=e;ae(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=i??null,t.position.reset(s)});const o=qr({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&ae(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:i,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return H(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=qr({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,d,u,c;if(o.defaultPrevented)return;const h=(c=e.to)!=null?c:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((u=(d=e.by)==null?void 0:d.y)!=null?u:0)};r.position.current=h})})}stop(e={}){return H(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const l={resume:()=>{},abort:()=>{}};return s=new Promise((d,u)=>{l.resume=d,l.abort=u}),l};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=H(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),d=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,c=Qe(()=>{u?.status==="idle"&&(c(),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()})}},gn=class extends Ee{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Du=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)}},Ur,Ul=class{constructor(e){this.options=e,Z(this,Ur)}set controller(e){Ve(this,Ur,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=le(this,Ur))==null||t.activate(e)}};Ur=new WeakMap;var ia=class extends Ee{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Pu=class{constructor(e){this.draggables=new ra,this.droppables=new ra,this.plugins=new Vi(e),this.sensors=new Vi(e),this.modifiers=new Vi(e)}register(e,t){if(e instanceof ct)return this.draggables.register(e.id,e);if(e instanceof dt)return this.droppables.register(e.id,e);if(e.prototype instanceof ia)return this.modifiers.register(e,t);if(e.prototype instanceof gn)return this.sensors.register(e,t);if(e.prototype instanceof Ee)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Ti)return e instanceof ct?this.draggables.unregister(e.id,e):e instanceof dt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ia)return this.modifiers.unregister(e);if(e.prototype instanceof gn)return this.sensors.unregister(e);if(e.prototype instanceof Ee)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()}},Xl,Yl,Zl,Ql,Jl,ec,tc,nc,rc,Gn,Xr,sn,oe,mo,yo,bo,xo,_o,Vn;rc=[ce],nc=[K],tc=[K],ec=[K],Jl=[K],Ql=[K],Zl=[ce],Yl=[ce],Xl=[ce];var st=class{constructor(e){N(oe,5,this),Z(this,Gn),Z(this,Xr),Z(this,sn,new Vt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new yt,Z(this,mo,N(oe,8,this,!1)),N(oe,11,this),Z(this,yo,N(oe,12,this,null)),N(oe,15,this),Z(this,bo,N(oe,16,this,null)),N(oe,19,this),Z(this,xo,N(oe,20,this,null)),N(oe,23,this),Z(this,_o,N(oe,24,this,[])),N(oe,27,this),this.position=new Oi({x:0,y:0}),Z(this,Vn,{x:0,y:0}),Ve(this,Gn,e)}get shape(){const{current:e,initial:t,previous:n}=le(this,sn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?le(this,sn).current=e:le(this,sn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=le(this,Gn).registry.draggables.get(t);return n&&Ve(this,Xr,n),(e=n??le(this,Xr))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=le(this,Gn).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(eo(Js({},this.snapshot()),{transform:n}));return Ve(this,Vn,n),n}snapshot(){return H(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:le(this,Vn),shape:this.shape?Gi(this.shape):null,position:Gi(this.position),status:Gi(this.status),canceled:this.canceled}))}reset(){ae(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,le(this,sn).reset(),this.position.reset({x:0,y:0}),Ve(this,Vn,{x:0,y:0}),this.modifiers=[]})}};oe=Tn(null);Gn=new WeakMap;Xr=new WeakMap;sn=new WeakMap;mo=new WeakMap;yo=new WeakMap;bo=new WeakMap;xo=new WeakMap;_o=new WeakMap;Vn=new WeakMap;q(oe,2,"shape",rc,st);q(oe,4,"canceled",nc,st,mo);q(oe,4,"activatorEvent",tc,st,yo);q(oe,4,"sourceIdentifier",ec,st,bo);q(oe,4,"targetIdentifier",Jl,st,xo);q(oe,4,"modifiers",Ql,st,_o);q(oe,2,"source",Zl,st);q(oe,2,"target",Yl,st);q(oe,2,"transform",Xl,st);Ht(oe,st);var Cu={get rendering(){return Promise.resolve()}};function it(e,t){return typeof e=="function"?e(t):e??t}var Mu=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(h=>h.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},i=it(r.plugins,[]),s=it(r.sensors,[]),o=it(r.modifiers,[]),a=(n=r.renderer)!=null?n:Cu,l=new Ou(this),d=new Pu(this);this.registry=d,this.monitor=l,this.renderer=a,this.actions=new Eu(this),this.dragOperation=new st(this),this.collisionObserver=new Su(this),this.plugins=[Tu,...i],this.modifiers=o,this.sensors=s;const{destroy:u}=this,c=yr(()=>{var h,f,g;const m=H(()=>this.dragOperation.modifiers),w=this.modifiers;for(const b of m)w.includes(b)||b.destroy();this.dragOperation.modifiers=(g=(f=(h=this.dragOperation.source)==null?void 0:h.modifiers)==null?void 0:f.map(b=>{const{plugin:v,options:p}=cr(b);return new v(this,p)}))!=null?g:w});this.destroy=()=>{c(),u()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},ic=e=>{throw TypeError(e)},wo=(e,t,n)=>t.has(e)||ic("Cannot "+n),B=(e,t,n)=>(wo(e,t,"read from private field"),t.get(e)),Re=(e,t,n)=>t.has(e)?ic("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ge=(e,t,n,r)=>(wo(e,t,"write to private field"),t.set(e,n),n),sc=(e,t,n)=>(wo(e,t,"access private method"),n);function Ei(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function oc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,a=(Ei(s)?s.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],i])}return r}function Di(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 ko(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function wr(e){return"nodeType"in e}function He(e){var t,n,r;return e?ko(e)?e:wr(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 So(e){const{Document:t}=He(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Tt(e){return!e||ko(e)?!1:e instanceof He(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function ac(e){return e instanceof He(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Pn(e){return e?ko(e)?e.document:wr(e)?So(e)?e:Tt(e)||ac(e)?e.ownerDocument:document:document:document}function Iu(e){var t,n,r,i;const{documentElement:s}=Pn(e),o=He(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,l=(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+l,width:a,height:l}}function ju(e,t){if(Au(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function Au(e){return e.tagName==="DETAILS"}function ur(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let l=t;const{ownerDocument:d}=e,u=(r=d.defaultView)!=null?r:window;let c=e.parentElement;for(;c&&c!==d.documentElement;){if(!ju(c)){const p=c.getBoundingClientRect(),x=n*(p.bottom-p.top),_=n*(p.right-p.left),O=n*(p.bottom-p.top),T=n*(p.right-p.left);l={top:Math.max(l.top,p.top-x),right:Math.min(l.right,p.right+_),bottom:Math.min(l.bottom,p.bottom+O),left:Math.max(l.left,p.left-T),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}c=c.parentElement}const h=u.visualViewport,f=(i=h?.offsetTop)!=null?i:0,g=(s=h?.offsetLeft)!=null?s:0,m=(o=h?.width)!=null?o:u.innerWidth,w=(a=h?.height)!=null?a:u.innerHeight,b=n*w,v=n*m;return l={top:Math.max(l.top,f-b),right:Math.min(l.right,g+m+v),bottom:Math.min(l.bottom,f+w+b),left:Math.max(l.left,g-v),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function vn(e){return{x:e.clientX,y:e.clientY}}var lc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ys(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(...ys(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(...ys(i.document,t))}}catch{}return n}function $o(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function cc(){var e,t;const n=$o()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Oo(e){return!e||!wr(e)?!1:e instanceof He(e).ShadowRoot}function ai(e){if(e&&wr(e)){let t=e.getRootNode();if(Oo(t))return t;if(t instanceof Document)return t}return Pn(e)}function To(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ru(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((s,o)=>{const a=r[o];if(sa(s)&&sa(a)&&(s.type!=="file"&&(s.value=a.value),s.type==="radio"&&s.name&&(s.name=`Cloned__${s.name}`)),oa(s)&&oa(a)&&a.width>0&&a.height>0){const l=s.getContext("2d");l?.drawImage(a,0,0)}}),n}function sa(e){return"value"in e}function oa(e){return e.tagName==="CANVAS"}function dc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Lu(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 Lu(e){return e?.tagName==="IFRAME"}var bs=new WeakMap;function zu(e){return e.closest(`
2
2
  input:not([disabled]),
3
3
  select:not([disabled]),
4
4
  textarea:not([disabled]),
5
5
  button:not([disabled]),
6
6
  a[href],
7
7
  [contenteditable]:not([contenteditable="false"])
8
- `)}var oc=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 a of i){const[c,{type:d,listener:u,options:l}]=a;c.removeEventListener(d,u,l),s.delete(a)}}}};function un(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function zu(e){const t=new Set;let n=un(e);for(;n;)t.add(n),n=un(n);return t}function Wu(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function ac(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=Wu(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function Fu(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 Bu(e,t=e.getBoundingClientRect()){const{width:n,height:r}=rr(e,t);return n>0&&r>0}var Nu=rc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},Wr,Gu=class extends Nu{constructor(e){super(t=>{if(!F(this,Wr)){je(this,Wr,!0);return}e(t,this)}),Ee(this,Wr,!1)}};Wr=new WeakMap;var ra=Array.from({length:100},(e,t)=>t/100),lc=75,Dt,Zr,pt,Et,Ln,ve,Yn,zn,Jr,cc,dc,uc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ee(this,Jr),this.disconnect=()=>{var s,o,a;je(this,Yn,!0),(s=F(this,pt))==null||s.disconnect(),(o=F(this,Et))==null||o.disconnect(),F(this,Ln).disconnect(),(a=F(this,ve))==null||a.remove()},Ee(this,Dt,!0),Ee(this,Zr),Ee(this,pt),Ee(this,Et),Ee(this,Ln),Ee(this,ve),Ee(this,Yn,!1),Ee(this,zn,ac(()=>{var s,o,a;const{element:c}=this;if((s=F(this,Et))==null||s.disconnect(),F(this,Yn)||!F(this,Dt)||!c.isConnected)return;const d=(o=c.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:l}=(a=d.defaultView)!=null?a:window,f=c.getBoundingClientRect(),g=rr(c,f),{top:h,left:m,bottom:w,right:b}=g,v=-Math.floor(h),p=-Math.floor(m),x=-Math.floor(l-b),_=-Math.floor(u-w),$=`${v}px ${x}px ${_}px ${p}px`;this.boundingClientRect=f,je(this,Et,new IntersectionObserver(T=>{const[D]=T,{intersectionRect:I}=D;(D.intersectionRatio!==1?D.intersectionRatio:tt.intersectionRatio(I,rr(c)))!==1&&F(this,zn).call(this)},{threshold:ra,rootMargin:$,root:d})),F(this,Et).observe(c),ec(this,Jr,cc).call(this)},lc)),this.boundingClientRect=e.getBoundingClientRect(),je(this,Dt,Bu(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(je(this,ve,document.createElement("div")),F(this,ve).style.background="rgba(0,0,0,0.15)",F(this,ve).style.position="fixed",F(this,ve).style.pointerEvents="none",i.body.appendChild(F(this,ve))),je(this,Ln,new IntersectionObserver(s=>{var o,a;const c=s[s.length-1],{boundingClientRect:d,isIntersecting:u}=c,{width:l,height:f}=d,g=F(this,Dt);je(this,Dt,u),!(!l&&!f)&&(g&&!u?((o=F(this,Et))==null||o.disconnect(),this.callback(null),(a=F(this,pt))==null||a.disconnect(),je(this,pt,void 0),F(this,ve)&&(F(this,ve).style.visibility="hidden")):F(this,zn).call(this),u&&!F(this,pt)&&(je(this,pt,new Gu(F(this,zn))),F(this,pt).observe(e)))},{threshold:ra,root:i})),F(this,Dt)&&!n.skipInitial&&this.callback(this.boundingClientRect),F(this,Ln).observe(e)}};Dt=new WeakMap;Zr=new WeakMap;pt=new WeakMap;Et=new WeakMap;Ln=new WeakMap;ve=new WeakMap;Yn=new WeakMap;zn=new WeakMap;Jr=new WeakSet;cc=function(){F(this,Yn)||(ec(this,Jr,dc).call(this),!Fu(this.boundingClientRect,F(this,Zr))&&(this.callback(this.boundingClientRect),je(this,Zr,this.boundingClientRect)))};dc=function(){if(F(this,ve)){const{top:e,left:t,width:n,height:r}=rr(this.element);F(this,ve).style.overflow="hidden",F(this,ve).style.visibility="visible",F(this,ve).style.top=`${Math.floor(e)}px`,F(this,ve).style.left=`${Math.floor(t)}px`,F(this,ve).style.width=`${Math.floor(n)}px`,F(this,ve).style.height=`${Math.floor(r)}px`}};var wr=new WeakMap,kr=new WeakMap;function Vu(e,t){let n=wr.get(e);return n||(n={disconnect:new uc(e,i=>{const s=wr.get(e);s&&s.callbacks.forEach(o=>o(i))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),wr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(wr.delete(e),n.disconnect())}}function Hu(e,t){const n=new Set;for(const r of e){const i=Vu(r,t);n.add(i)}return()=>n.forEach(r=>r())}function Ku(e,t){var n;const r=e.ownerDocument;if(!kr.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}),kr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=kr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),kr.delete(r))})}var Wn,Fn,Fr,us,qu=class{constructor(e,t,n){this.callback=t,Ee(this,Wn),Ee(this,Fn,!1),Ee(this,Fr),Ee(this,us,ac(o=>{if(!F(this,Fn)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of F(this,Fr))if(o.target.contains(a)){this.callback(F(this,Wn).boundingClientRect);break}}},lc));const r=zu(e),i=Hu(r,t),s=Ku(e,F(this,us));je(this,Fr,r),je(this,Wn,new uc(e,t,n)),this.disconnect=()=>{F(this,Fn)||(je(this,Fn,!0),i(),s(),F(this,Wn).disconnect())}}};Wn=new WeakMap;Fn=new WeakMap;Fr=new WeakMap;us=new WeakMap;function fs(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function on(e){try{fs(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ia(e){return!rc||!e?!1:e===Sn(e).scrollingElement}function fc(e){var t,n;const r=Re(e),i=ia(e)?Cu(e):yi(e),s=r.visualViewport,o=ia(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 Uu(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=fc(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 bo=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const i of n)i();for(const i of r)i()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},Qr=new bo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Xu=new bo(e=>setTimeout(e,50)),ei=new Map,Yu=ei.clear.bind(ei);function it(e,t=!1){if(!t)return sa(e);let n=ei.get(e);return n||(n=sa(e),ei.set(e,n),Xu.schedule(Yu),n)}function sa(e){return Re(e).getComputedStyle(e)}function Zu(e,t=it(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Ju(e,t=it(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=t[i];return typeof s=="string"?n.test(s):!1})}var Qu={excludeElement:!0,escapeShadowDOM:!0};function hs(e,t=Qu){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(go(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&mo(a))return o(a.host);if(!_t(a))return nc(a)?o(a.parentElement):s;if(s.has(a))return s;const c=it(a,!0);if(r&&a===e||Ju(a,c)&&s.add(a),Zu(a,c)){const{scrollingElement:d}=a.ownerDocument;return d&&s.add(d),s}return o(a.parentNode)}return e?o(e):s}function fn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=un(e);for(;r;){if(r===t)return n;const i=yi(r),{x:s,y:o}=ef(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=un(r)}return n}function ef(e,t=yi(e)){const n=Math.round(t.width),r=Math.round(t.height);if(_t(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=it(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function tf(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 ir(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 bi(e){var t,n,r,i,s,o,a,c,d;const{scale:u,transform:l,translate:f}=e,g=tf(u),h=ir(f),m=nf(l);if(!m&&!g&&!h)return null;const w={x:(t=g?.x)!=null?t:1,y:(n=g?.y)!=null?n:1},b={x:(r=h?.x)!=null?r:0,y:(i=h?.y)!=null?i:0},v={x:(s=m?.x)!=null?s:0,y:(o=m?.y)!=null?o:0,scaleX:(a=m?.scaleX)!=null?a:1,scaleY:(c=m?.scaleY)!=null?c:1};return{x:b.x+v.x,y:b.y+v.y,z:(d=h?.z)!=null?d:0,scaleX:w.x*v.scaleX,scaleY:w.y*v.scaleY}}function nf(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 We=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(We||{}),rf={x:.2,y:.2},sf={x:10,y:10};function of(e,t,n,r=25,i=rf,s=sf){const{x:o,y:a}=t,{rect:c,isTop:d,isBottom:u,isLeft:l,isRight:f}=fc(e),g=fn(e),h=it(e,!0),m=bi(h),w=m!==null?m?.scaleX<0:!1,b=m!==null?m?.scaleY<0:!1,v=new tt(c.left*g.scaleX+g.x,c.top*g.scaleY+g.y,c.width*g.scaleX,c.height*g.scaleY),p={x:0,y:0},x={x:0,y:0},_={height:v.height*i.y,width:v.width*i.x};return _.height>0&&(!d||b&&!u)&&a<=v.top+_.height&&n?.y!==1&&o>=v.left-s.x&&o<=v.right+s.x?(p.y=b?1:-1,x.y=r*Math.abs((v.top+_.height-a)/_.height)):_.height>0&&(!u||b&&!d)&&a>=v.bottom-_.height&&n?.y!==-1&&o>=v.left-s.x&&o<=v.right+s.x&&(p.y=b?-1:1,x.y=r*Math.abs((v.bottom-_.height-a)/_.height)),_.width>0&&(!f||w&&!l)&&o>=v.right-_.width&&n?.x!==-1&&a>=v.top-s.y&&a<=v.bottom+s.y?(p.x=w?-1:1,x.x=r*Math.abs((v.right-_.width-o)/_.width)):_.width>0&&(!l||w&&!f)&&o<=v.left+_.width&&n?.x!==1&&a>=v.top-s.y&&a<=v.bottom+s.y&&(p.x=w?1:-1,x.x=r*Math.abs((v.left+_.width-o)/_.width)),{direction:p,speed:x}}function hc(e,{block:t="nearest",inline:n="nearest"}={}){if(!_t(e))return;const r=hs(e),i=[];for(const s of r){if(!_t(s))continue;const{top:o,left:a}=af(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 oa(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!_t(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function af(e,t){const n=oa(e),r=oa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function lf(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 cf(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 pc({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function aa(e,t=it(e).translate,n=!0){if(n){const r=tc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=ir(i);if(s)return s}}}if(t){const r=ir(t);if(r)return r}return{x:0,y:0,z:0}}var df=new bo(e=>setTimeout(e,0)),Zn=new Map,uf=Zn.clear.bind(Zn);function ff(e){const t=e.ownerDocument;let n=Zn.get(t);if(n)return n;n=t.getAnimations(),Zn.set(t,n),df.schedule(uf);const r=n.filter(i=>mi(i.effect)&&i.effect.target===e);return Zn.set(e,r),n}function hf(e,t){const n=ff(e).filter(r=>{var i,s;if(mi(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))!=null?s:!0)return r.effect.getKeyframes().some(c=>{for(const d of t.properties)if(c[d])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=fn(e),ignoreTransforms:a,getBoundingClientRect:c=yi}=t,d=hf(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||vo())&&_.contains(e)}),u=c(e);let{top:l,left:f,width:g,height:h}=u,m;const w=it(e),b=bi(w),v={x:(n=b?.scaleX)!=null?n:1,y:(r=b?.scaleY)!=null?r:1},p=pf(e,w);d?.(),b&&(m=cf(u,b,w.transformOrigin),(a||p)&&(l=m.top,f=m.left,g=m.width,h=m.height));const x={width:(i=m?.width)!=null?i:g,height:(s=m?.height)!=null?s:h};if(p&&!a&&m){const _=lf(m,p,w.transformOrigin);l=_.top,f=_.left,g=_.width,h=_.height,v.x=p.scaleX,v.y=p.scaleY}o&&(a||(f*=o.scaleX,g*=o.scaleX,l*=o.scaleY,h*=o.scaleY),f+=o.x,l+=o.y),super(f,l,g,h),this.scale=v,this.intrinsicWidth=x.width,this.intrinsicHeight=x.height}};function pf(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=mi(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?bi({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function Jn(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 gf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(Jn(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(Jn(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(Jn(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function At(e){return e?e instanceof Re(e).Element||pr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function sr(e){if(!e)return!1;const{KeyboardEvent:t}=Re(e.target);return e instanceof t}function vf(e){if(!e)return!1;const{PointerEvent:t}=Re(e.target);return e instanceof t}function mf(e){if(!At(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||yf(e)}function yf(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Ri={};function ps(e){const t=Ri[e]==null?0:Ri[e]+1;return Ri[e]=t,`${e}-${t}`}var xo=({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=ze.distance(t.shape.center,n);return{id:r,value:1/i,type:kn.PointerIntersection,priority:wn.High}}return null},bf=({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=ze.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:kn.ShapeIntersection,priority:wn.Normal}}return null},gc=e=>{var t;return(t=xo(e))!=null?t:bf(e)},xf=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,a=tt.from(n.shape.boundingRectangle).corners.reduce((c,d,u)=>{var l;return c+ze.distance(ze.from(d),(l=s?.[u])!=null?l:i.current)},0)/4;return{id:n.id,value:1/a,type:kn.Collision,priority:wn.Normal}},_f=Object.create,_o=Object.defineProperty,wf=Object.defineProperties,kf=Object.getOwnPropertyDescriptor,Sf=Object.getOwnPropertyDescriptors,ti=Object.getOwnPropertySymbols,vc=Object.prototype.hasOwnProperty,mc=Object.prototype.propertyIsEnumerable,yc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),$n=e=>{throw TypeError(e)},gs=(e,t,n)=>t in e?_o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,or=(e,t)=>{for(var n in t||(t={}))vc.call(t,n)&&gs(e,n,t[n]);if(ti)for(var n of ti(t))mc.call(t,n)&&gs(e,n,t[n]);return e},wo=(e,t)=>wf(e,Sf(t)),la=(e,t)=>_o(e,"name",{value:t,configurable:!0}),bc=(e,t)=>{var n={};for(var r in e)vc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ti)for(var r of ti(e))t.indexOf(r)<0&&mc.call(e,r)&&(n[r]=e[r]);return n},On=e=>{var t;return[,,,_f((t=e?.[yc("metadata")])!=null?t:null)]},xc=["class","method","getter","setter","accessor","field","value","get","set"],Bn=e=>e!==void 0&&typeof e!="function"?$n("Function expected"):e,$f=(e,t,n,r,i)=>({kind:xc[e],name:t,metadata:r,addInitializer:s=>n._?$n("Already initialized"):i.push(Bn(s||null))}),Bt=(e,t)=>gs(t,yc("metadata"),e[3]),fe=(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},Ne=(e,t,n,r,i,s)=>{var o,a,c,d,u,l=t&7,f=!!(t&8),g=!!(t&16),h=l>3?e.length+1:l?f?1:2:0,m=xc[l+5],w=l>3&&(e[h-1]=[]),b=e[h]||(e[h]=[]),v=l&&(!g&&!f&&(i=i.prototype),l<5&&(l>3||!g)&&kf(l<4?i:{get[n](){return Q(this,s)},set[n](x){return $e(this,s,x)}},n));l?g&&l<4&&la(s,(l>2?"set ":l>1?"get ":"")+n):la(i,n);for(var p=r.length-1;p>=0;p--)d=$f(l,n,c={},e[3],b),l&&(d.static=f,d.private=g,u=d.access={has:g?x=>Of(i,x):x=>n in x},l^3&&(u.get=g?x=>(l^1?Q:Rt)(x,i,l^4?s:v.get):x=>x[n]),l>2&&(u.set=g?(x,_)=>$e(x,i,_,l^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(l?l<4?g?s:v[m]:l>4?void 0:{get:v.get,set:v.set}:i,d),c._=1,l^4||a===void 0?Bn(a)&&(l>4?w.unshift(a):l?g?s=a:v[m]=a:i=a):typeof a!="object"||a===null?$n("Object expected"):(Bn(o=a.get)&&(v.get=o),Bn(o=a.set)&&(v.set=o),Bn(o=a.init)&&w.unshift(o));return l||Bt(e,i),v&&_o(i,n,v),g?l^4?s:v:i},ko=(e,t,n)=>t.has(e)||$n("Cannot "+n),Of=(e,t)=>Object(t)!==t?$n('Cannot use the "in" operator on this value'):e.has(t),Q=(e,t,n)=>(ko(e,t,"read from private field"),n?n.call(e):t.get(e)),ce=(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),$e=(e,t,n,r)=>(ko(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Rt=(e,t,n)=>(ko(e,t,"access private method"),n),ca={role:"button",roleDescription:"draggable"},Tf="dnd-kit-description",Df="dnd-kit-announcement",Ef={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."},Pf={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 Mf(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Cf(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function If(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 jf=["dragover","dragmove"],Af=class extends xe{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Tf,announcement:i=Df}={},announcements:s=Pf,screenReaderInstructions:o=Ef,debounce:a=500}=t??{},c=n?`${r}-${n}`:ps(r),d=n?`${i}-${n}`:ps(i);let u,l,f,g;const h=(_=g)=>{!f||!_||f?.nodeValue!==_&&(f.nodeValue=_)},m=()=>Qr.schedule(h),w=Rf(m,a),b=Object.entries(s).map(([_,$])=>this.manager.monitor.addEventListener(_,(T,D)=>{const I=f;if(!I)return;const C=$?.(T,D);C&&I.nodeValue!==C&&(g=C,jf.includes(_)?w():(m(),w.cancel()))})),v=()=>{let _=[];u?.isConnected||(u=Cf(c,o.draggable),_.push(u)),l?.isConnected||(l=If(d),f=document.createTextNode(""),l.appendChild(f),_.push(l)),_.length>0&&document.body.append(..._)},p=new Set;function x(){for(const _ of p)_()}this.registerEffect(()=>{var _;p.clear();for(const $ of this.manager.registry.draggables.value){const T=(_=$.handle)!=null?_:$.element;if(T){(!u||!l)&&p.add(v),(!Mf(T)||vo())&&!T.hasAttribute("tabindex")&&p.add(()=>T.setAttribute("tabindex","0")),!T.hasAttribute("role")&&T.tagName.toLowerCase()!=="button"&&p.add(()=>T.setAttribute("role",ca.role)),T.hasAttribute("aria-roledescription")||p.add(()=>T.setAttribute("aria-roledescription",ca.roleDescription)),T.hasAttribute("aria-describedby")||p.add(()=>T.setAttribute("aria-describedby",c));for(const I of["aria-pressed","aria-grabbed"]){const C=String($.isDragging);T.getAttribute(I)!==C&&p.add(()=>T.setAttribute(I,C))}const D=String($.disabled);T.getAttribute("aria-disabled")!==D&&p.add(()=>T.setAttribute("aria-disabled",D))}}p.size>0&&Qr.schedule(x)}),this.destroy=()=>{super.destroy(),u?.remove(),l?.remove(),b.forEach(_=>_())}}};function Rf(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var ni=new Map,_c,wc,kc,Sc,vs,Qn,ct,So,hn,$c,Oc,Tc,Dc,wt=class extends(vs=hr,Sc=[G],kc=[le],wc=[le],_c=[le],vs){constructor(t,n){super(t,n),fe(ct,5,this),ce(this,hn),ce(this,Qn,new Set),ce(this,So,fe(ct,8,this,new Set)),fe(ct,11,this),this.registerEffect(Rt(this,hn,$c))}register(t){return Q(this,Qn).add(t),()=>{Q(this,Qn).delete(t)}}addRoot(t){return N(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{N(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return Yr((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return Yr((t=n?.element)!=null?t:null)}get roots(){const{status:t}=this.manager.dragOperation;if(t.initializing||t.initialized){const n=[this.sourceRoot,this.targetRoot].filter(r=>r!=null);return new Set([...n,...this.additionalRoots])}return new Set}};ct=On(vs);Qn=new WeakMap;So=new WeakMap;hn=new WeakSet;$c=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Q(this,Qn))t.push(Rt(this,hn,Oc).call(this,n,r));return()=>{for(const n of t)n()}};Oc=function(e,t){let n=ni.get(e);n||(n=new Map,ni.set(e,n));let r=n.get(t);if(!r){const s=go(e)?Rt(this,hn,Tc).call(this,e,n,t):Rt(this,hn,Dc).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())}};Tc=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&&ni.delete(e)}}};Dc=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(mo(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&&ni.delete(e)}}};Ne(ct,4,"additionalRoots",Sc,wt,So);Ne(ct,2,"sourceRoot",kc,wt);Ne(ct,2,"targetRoot",wc,wt);Ne(ct,2,"roots",_c,wt);Bt(ct,wt);wt.configure=fr(wt);var xi=wt,Lf=class extends xe{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(xi),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},gr="data-dnd-",ms=`${gr}dropping`,ge="--dnd-",Qe=`${gr}dragging`,ri=`${gr}placeholder`,zf=[Qe,ri,"popover","aria-pressed","aria-grabbing"],Wf=["view-transition-name"],Ff=`
9
- :is(:root,:host) [${Qe}] {
8
+ `)}var uc=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];for(const o of n)for(const a of r){const{type:l,listener:d,options:u}=a,c=[o,a];o.addEventListener(l,d,u),this.entries.add(c),i.push(c)}const s=this.entries;return function(){for(const a of i){const[l,{type:d,listener:u,options:c}]=a;l.removeEventListener(d,u,c),s.delete(a)}}}};function mn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Wu(e){const t=new Set;let n=mn(e);for(;n;)t.add(n),n=mn(n);return t}function Fu(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function fc(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=Fu(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function Bu(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 Nu(e,t=e.getBoundingClientRect()){const{width:n,height:r}=ur(e,t);return n>0&&r>0}var Gu=lc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},Yr,Vu=class extends Gu{constructor(e){super(t=>{if(!B(this,Yr)){Ge(this,Yr,!0);return}e(t,this)}),Re(this,Yr,!1)}};Yr=new WeakMap;var aa=Array.from({length:100},(e,t)=>t/100),hc=75,It,li,xt,jt,Hn,ke,ir,Kn,ci,pc,gc,vc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Re(this,ci),this.disconnect=()=>{var s,o,a;Ge(this,ir,!0),(s=B(this,xt))==null||s.disconnect(),(o=B(this,jt))==null||o.disconnect(),B(this,Hn).disconnect(),(a=B(this,ke))==null||a.remove()},Re(this,It,!0),Re(this,li),Re(this,xt),Re(this,jt),Re(this,Hn),Re(this,ke),Re(this,ir,!1),Re(this,Kn,fc(()=>{var s,o,a;const{element:l}=this;if((s=B(this,jt))==null||s.disconnect(),B(this,ir)||!B(this,It)||!l.isConnected)return;const d=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:c}=(a=d.defaultView)!=null?a:window,h=l.getBoundingClientRect(),f=ur(l,h),{top:g,left:m,bottom:w,right:b}=f,v=-Math.floor(g),p=-Math.floor(m),x=-Math.floor(c-b),_=-Math.floor(u-w),O=`${v}px ${x}px ${_}px ${p}px`;this.boundingClientRect=h,Ge(this,jt,new IntersectionObserver(T=>{const[E]=T,{intersectionRect:I}=E;(E.intersectionRatio!==1?E.intersectionRatio:lt.intersectionRatio(I,ur(l)))!==1&&B(this,Kn).call(this)},{threshold:aa,rootMargin:O,root:d})),B(this,jt).observe(l),sc(this,ci,pc).call(this)},hc)),this.boundingClientRect=e.getBoundingClientRect(),Ge(this,It,Nu(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(Ge(this,ke,document.createElement("div")),B(this,ke).style.background="rgba(0,0,0,0.15)",B(this,ke).style.position="fixed",B(this,ke).style.pointerEvents="none",i.body.appendChild(B(this,ke))),Ge(this,Hn,new IntersectionObserver(s=>{var o,a;const l=s[s.length-1],{boundingClientRect:d,isIntersecting:u}=l,{width:c,height:h}=d,f=B(this,It);Ge(this,It,u),!(!c&&!h)&&(f&&!u?((o=B(this,jt))==null||o.disconnect(),this.callback(null),(a=B(this,xt))==null||a.disconnect(),Ge(this,xt,void 0),B(this,ke)&&(B(this,ke).style.visibility="hidden")):B(this,Kn).call(this),u&&!B(this,xt)&&(Ge(this,xt,new Vu(B(this,Kn))),B(this,xt).observe(e)))},{threshold:aa,root:i})),B(this,It)&&!n.skipInitial&&this.callback(this.boundingClientRect),B(this,Hn).observe(e)}};It=new WeakMap;li=new WeakMap;xt=new WeakMap;jt=new WeakMap;Hn=new WeakMap;ke=new WeakMap;ir=new WeakMap;Kn=new WeakMap;ci=new WeakSet;pc=function(){B(this,ir)||(sc(this,ci,gc).call(this),!Bu(this.boundingClientRect,B(this,li))&&(this.callback(this.boundingClientRect),Ge(this,li,this.boundingClientRect)))};gc=function(){if(B(this,ke)){const{top:e,left:t,width:n,height:r}=ur(this.element);B(this,ke).style.overflow="hidden",B(this,ke).style.visibility="visible",B(this,ke).style.top=`${Math.floor(e)}px`,B(this,ke).style.left=`${Math.floor(t)}px`,B(this,ke).style.width=`${Math.floor(n)}px`,B(this,ke).style.height=`${Math.floor(r)}px`}};var Ir=new WeakMap,jr=new WeakMap;function Hu(e,t){let n=Ir.get(e);return n||(n={disconnect:new vc(e,i=>{const s=Ir.get(e);s&&s.callbacks.forEach(o=>o(i))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Ir.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Ir.delete(e),n.disconnect())}}function Ku(e,t){const n=new Set;for(const r of e){const i=Hu(r,t);n.add(i)}return()=>n.forEach(r=>r())}function qu(e,t){var n;const r=e.ownerDocument;if(!jr.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",l=>a.forEach(d=>d(l)),{capture:!0,passive:!0,signal:o.signal}),jr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=jr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),jr.delete(r))})}var qn,Un,Zr,xs,Uu=class{constructor(e,t,n){this.callback=t,Re(this,qn),Re(this,Un,!1),Re(this,Zr),Re(this,xs,fc(o=>{if(!B(this,Un)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of B(this,Zr))if(o.target.contains(a)){this.callback(B(this,qn).boundingClientRect);break}}},hc));const r=Wu(e),i=Ku(r,t),s=qu(e,B(this,xs));Ge(this,Zr,r),Ge(this,qn,new vc(e,t,n)),this.disconnect=()=>{B(this,Un)||(Ge(this,Un,!0),i(),s(),B(this,qn).disconnect())}}};qn=new WeakMap;Un=new WeakMap;Zr=new WeakMap;xs=new WeakMap;function _s(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function fn(e){try{_s(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function la(e){return!lc||!e?!1:e===Pn(e).scrollingElement}function mc(e){var t,n;const r=He(e),i=la(e)?Iu(e):Di(e),s=r.visualViewport,o=la(e)?{height:(t=s?.height)!=null?t:r.innerHeight,width:(n=s?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=a.current.y<=0,d=a.current.x<=0,u=a.current.y>=a.max.y,c=a.current.x>=a.max.x;return{rect:i,position:a,isTop:l,isLeft:d,isBottom:u,isRight:c}}function Xu(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=mc(e),{x:a,y:l}=t??{x:0,y:0},d=!n&&o.current.y+l>0,u=!r&&o.current.y+l<o.max.y,c=!i&&o.current.x+a>0,h=!s&&o.current.x+a<o.max.x;return{top:d,bottom:u,left:c,right:h,x:c||h,y:d||u}}var Eo=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const i of n)i();for(const i of r)i()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},di=new Eo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Yu=new Eo(e=>setTimeout(e,50)),ui=new Map,Zu=ui.clear.bind(ui);function ut(e,t=!1){if(!t)return ca(e);let n=ui.get(e);return n||(n=ca(e),ui.set(e,n),Yu.schedule(Zu),n)}function ca(e){return He(e).getComputedStyle(e)}function Qu(e,t=ut(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Ju(e,t=ut(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=t[i];return typeof s=="string"?n.test(s):!1})}var ef={excludeElement:!0,escapeShadowDOM:!0};function ws(e,t=ef){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(So(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Oo(a))return o(a.host);if(!Tt(a))return ac(a)?o(a.parentElement):s;if(s.has(a))return s;const l=ut(a,!0);if(r&&a===e||Ju(a,l)&&s.add(a),Qu(a,l)){const{scrollingElement:d}=a.ownerDocument;return d&&s.add(d),s}return o(a.parentNode)}return e?o(e):s}function yn(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=Di(r),{x:s,y:o}=tf(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 tf(e,t=Di(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Tt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=ut(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function nf(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 fr(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 Pi(e){var t,n,r,i,s,o,a,l,d;const{scale:u,transform:c,translate:h}=e,f=nf(u),g=fr(h),m=rf(c);if(!m&&!f&&!g)return null;const w={x:(t=f?.x)!=null?t:1,y:(n=f?.y)!=null?n:1},b={x:(r=g?.x)!=null?r:0,y:(i=g?.y)!=null?i:0},v={x:(s=m?.x)!=null?s:0,y:(o=m?.y)!=null?o:0,scaleX:(a=m?.scaleX)!=null?a:1,scaleY:(l=m?.scaleY)!=null?l:1};return{x:b.x+v.x,y:b.y+v.y,z:(d=g?.z)!=null?d:0,scaleX:w.x*v.scaleX,scaleY:w.y*v.scaleY}}function rf(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 Ye=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Ye||{}),sf={x:.2,y:.2},of={x:10,y:10};function af(e,t,n,r=25,i=sf,s=of){const{x:o,y:a}=t,{rect:l,isTop:d,isBottom:u,isLeft:c,isRight:h}=mc(e),f=yn(e),g=ut(e,!0),m=Pi(g),w=m!==null?m?.scaleX<0:!1,b=m!==null?m?.scaleY<0:!1,v=new lt(l.left*f.scaleX+f.x,l.top*f.scaleY+f.y,l.width*f.scaleX,l.height*f.scaleY),p={x:0,y:0},x={x:0,y:0},_={height:v.height*i.y,width:v.width*i.x};return _.height>0&&(!d||b&&!u)&&a<=v.top+_.height&&n?.y!==1&&o>=v.left-s.x&&o<=v.right+s.x?(p.y=b?1:-1,x.y=r*Math.abs((v.top+_.height-a)/_.height)):_.height>0&&(!u||b&&!d)&&a>=v.bottom-_.height&&n?.y!==-1&&o>=v.left-s.x&&o<=v.right+s.x&&(p.y=b?-1:1,x.y=r*Math.abs((v.bottom-_.height-a)/_.height)),_.width>0&&(!h||w&&!c)&&o>=v.right-_.width&&n?.x!==-1&&a>=v.top-s.y&&a<=v.bottom+s.y?(p.x=w?-1:1,x.x=r*Math.abs((v.right-_.width-o)/_.width)):_.width>0&&(!c||w&&!h)&&o<=v.left+_.width&&n?.x!==1&&a>=v.top-s.y&&a<=v.bottom+s.y&&(p.x=w?1:-1,x.x=r*Math.abs((v.left+_.width-o)/_.width)),{direction:p,speed:x}}function yc(e,{block:t="nearest",inline:n="nearest"}={}){if(!Tt(e))return;const r=ws(e),i=[];for(const s of r){if(!Tt(s))continue;const{top:o,left:a}=lf(e,s);let l=o,d=a;for(const u of i)l-=u.scrollTop,d-=u.scrollLeft;if(t!=="none"){const u=l<s.scrollTop,c=l+e.offsetHeight>s.scrollTop+s.clientHeight;u!==c&&(t==="center"?s.scrollTop=l-s.clientHeight/2+e.offsetHeight/2:u?s.scrollTop=l:s.scrollTop=l+e.offsetHeight-s.clientHeight)}if(n!=="none"){const u=d<s.scrollLeft,c=d+e.offsetWidth>s.scrollLeft+s.clientWidth;u!==c&&(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 da(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Tt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function lf(e,t){const n=da(e),r=da(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function cf(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),l=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width*r:e.width,u=i?e.height*i:e.height;return{width:d,height:u,top:l,right:a+d,bottom:l+u,left:a}}function df(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left-s-(1-r)*parseFloat(n),l=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width/r:e.width,u=i?e.height/i:e.height;return{width:d,height:u,top:l,right:a+d,bottom:l+u,left:a}}function bc({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function ua(e,t=ut(e).translate,n=!0){if(n){const r=oc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=fr(i);if(s)return s}}}if(t){const r=fr(t);if(r)return r}return{x:0,y:0,z:0}}var uf=new Eo(e=>setTimeout(e,0)),sr=new Map,ff=sr.clear.bind(sr);function hf(e){const t=e.ownerDocument;let n=sr.get(t);if(n)return n;n=t.getAnimations(),sr.set(t,n),uf.schedule(ff);const r=n.filter(i=>Ei(i.effect)&&i.effect.target===e);return sr.set(e,r),n}function pf(e,t){const n=hf(e).filter(r=>{var i,s;if(Ei(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))!=null?s:!0)return r.effect.getKeyframes().some(l=>{for(const d of t.properties)if(l[d])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 at=class extends lt{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=yn(e),ignoreTransforms:a,getBoundingClientRect:l=Di}=t,d=pf(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||$o())&&_.contains(e)}),u=l(e);let{top:c,left:h,width:f,height:g}=u,m;const w=ut(e),b=Pi(w),v={x:(n=b?.scaleX)!=null?n:1,y:(r=b?.scaleY)!=null?r:1},p=gf(e,w);d?.(),b&&(m=df(u,b,w.transformOrigin),(a||p)&&(c=m.top,h=m.left,f=m.width,g=m.height));const x={width:(i=m?.width)!=null?i:f,height:(s=m?.height)!=null?s:g};if(p&&!a&&m){const _=cf(m,p,w.transformOrigin);c=_.top,h=_.left,f=_.width,g=_.height,v.x=p.scaleX,v.y=p.scaleY}o&&(a||(h*=o.scaleX,f*=o.scaleX,c*=o.scaleY,g*=o.scaleY),h+=o.x,c+=o.y),super(h,c,f,g),this.scale=v,this.intrinsicWidth=x.width,this.intrinsicHeight=x.height}};function gf(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=Ei(a.effect)?a.effect.getKeyframes():[],d=l[l.length-1];if(!d)continue;const{transform:u,translate:c,scale:h}=d;typeof u=="string"&&u&&(r=u,o=!0),typeof c=="string"&&c&&(i=c,o=!0),typeof h=="string"&&h&&(s=h,o=!0)}return o?Pi({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function or(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 vf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(or(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(or(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(or(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Ft(e){return e?e instanceof He(e).Element||wr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function hr(e){if(!e)return!1;const{KeyboardEvent:t}=He(e.target);return e instanceof t}function mf(e){if(!e)return!1;const{PointerEvent:t}=He(e.target);return e instanceof t}function yf(e){if(!Ft(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||bf(e)}function bf(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Hi={};function ks(e){const t=Hi[e]==null?0:Hi[e]+1;return Hi[e]=t,`${e}-${t}`}var Do=({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=Xe.distance(t.shape.center,n);return{id:r,value:1/i,type:Dn.PointerIntersection,priority:En.High}}return null},xf=({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=Xe.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:Dn.ShapeIntersection,priority:En.Normal}}return null},xc=e=>{var t;return(t=Do(e))!=null?t:xf(e)},_f=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?lt.from(r.current.boundingRectangle).corners:void 0,a=lt.from(n.shape.boundingRectangle).corners.reduce((l,d,u)=>{var c;return l+Xe.distance(Xe.from(d),(c=s?.[u])!=null?c:i.current)},0)/4;return{id:n.id,value:1/a,type:Dn.Collision,priority:En.Normal}},wf=Object.create,Po=Object.defineProperty,kf=Object.defineProperties,Sf=Object.getOwnPropertyDescriptor,$f=Object.getOwnPropertyDescriptors,fi=Object.getOwnPropertySymbols,_c=Object.prototype.hasOwnProperty,wc=Object.prototype.propertyIsEnumerable,kc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Cn=e=>{throw TypeError(e)},Ss=(e,t,n)=>t in e?Po(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pr=(e,t)=>{for(var n in t||(t={}))_c.call(t,n)&&Ss(e,n,t[n]);if(fi)for(var n of fi(t))wc.call(t,n)&&Ss(e,n,t[n]);return e},Co=(e,t)=>kf(e,$f(t)),fa=(e,t)=>Po(e,"name",{value:t,configurable:!0}),Sc=(e,t)=>{var n={};for(var r in e)_c.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&&wc.call(e,r)&&(n[r]=e[r]);return n},Mn=e=>{var t;return[,,,wf((t=e?.[kc("metadata")])!=null?t:null)]},$c=["class","method","getter","setter","accessor","field","value","get","set"],Xn=e=>e!==void 0&&typeof e!="function"?Cn("Function expected"):e,Of=(e,t,n,r,i)=>({kind:$c[e],name:t,metadata:r,addInitializer:s=>n._?Cn("Already initialized"):i.push(Xn(s||null))}),Kt=(e,t)=>Ss(t,kc("metadata"),e[3]),pe=(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},Je=(e,t,n,r,i,s)=>{var o,a,l,d,u,c=t&7,h=!!(t&8),f=!!(t&16),g=c>3?e.length+1:c?h?1:2:0,m=$c[c+5],w=c>3&&(e[g-1]=[]),b=e[g]||(e[g]=[]),v=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&Sf(c<4?i:{get[n](){return te(this,s)},set[n](x){return Ce(this,s,x)}},n));c?f&&c<4&&fa(s,(c>2?"set ":c>1?"get ":"")+n):fa(i,n);for(var p=r.length-1;p>=0;p--)d=Of(c,n,l={},e[3],b),c&&(d.static=h,d.private=f,u=d.access={has:f?x=>Tf(i,x):x=>n in x},c^3&&(u.get=f?x=>(c^1?te:Bt)(x,i,c^4?s:v.get):x=>x[n]),c>2&&(u.set=f?(x,_)=>Ce(x,i,_,c^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(c?c<4?f?s:v[m]:c>4?void 0:{get:v.get,set:v.set}:i,d),l._=1,c^4||a===void 0?Xn(a)&&(c>4?w.unshift(a):c?f?s=a:v[m]=a:i=a):typeof a!="object"||a===null?Cn("Object expected"):(Xn(o=a.get)&&(v.get=o),Xn(o=a.set)&&(v.set=o),Xn(o=a.init)&&w.unshift(o));return c||Kt(e,i),v&&Po(i,n,v),f?c^4?s:v:i},Mo=(e,t,n)=>t.has(e)||Cn("Cannot "+n),Tf=(e,t)=>Object(t)!==t?Cn('Cannot use the "in" operator on this value'):e.has(t),te=(e,t,n)=>(Mo(e,t,"read from private field"),n?n.call(e):t.get(e)),de=(e,t,n)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ce=(e,t,n,r)=>(Mo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Bt=(e,t,n)=>(Mo(e,t,"access private method"),n),ha={role:"button",roleDescription:"draggable"},Ef="dnd-kit-description",Df="dnd-kit-announcement",Pf={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."},Cf={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 Mf(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function If(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function jf(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 Af=["dragover","dragmove"],Rf=class extends Ee{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Ef,announcement:i=Df}={},announcements:s=Cf,screenReaderInstructions:o=Pf,debounce:a=500}=t??{},l=n?`${r}-${n}`:ks(r),d=n?`${i}-${n}`:ks(i);let u,c,h,f;const g=(_=f)=>{!h||!_||h?.nodeValue!==_&&(h.nodeValue=_)},m=()=>di.schedule(g),w=Lf(m,a),b=Object.entries(s).map(([_,O])=>this.manager.monitor.addEventListener(_,(T,E)=>{const I=h;if(!I)return;const D=O?.(T,E);D&&I.nodeValue!==D&&(f=D,Af.includes(_)?w():(m(),w.cancel()))})),v=()=>{let _=[];u?.isConnected||(u=If(l,o.draggable),_.push(u)),c?.isConnected||(c=jf(d),h=document.createTextNode(""),c.appendChild(h),_.push(c)),_.length>0&&document.body.append(..._)},p=new Set;function x(){for(const _ of p)_()}this.registerEffect(()=>{var _;p.clear();for(const O of this.manager.registry.draggables.value){const T=(_=O.handle)!=null?_:O.element;if(T){(!u||!c)&&p.add(v),(!Mf(T)||$o())&&!T.hasAttribute("tabindex")&&p.add(()=>T.setAttribute("tabindex","0")),!T.hasAttribute("role")&&T.tagName.toLowerCase()!=="button"&&p.add(()=>T.setAttribute("role",ha.role)),T.hasAttribute("aria-roledescription")||p.add(()=>T.setAttribute("aria-roledescription",ha.roleDescription)),T.hasAttribute("aria-describedby")||p.add(()=>T.setAttribute("aria-describedby",l));for(const I of["aria-pressed","aria-grabbed"]){const D=String(O.isDragging);T.getAttribute(I)!==D&&p.add(()=>T.setAttribute(I,D))}const E=String(O.disabled);T.getAttribute("aria-disabled")!==E&&p.add(()=>T.setAttribute("aria-disabled",E))}}p.size>0&&di.schedule(x)}),this.destroy=()=>{super.destroy(),u?.remove(),c?.remove(),b.forEach(_=>_())}}};function Lf(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var hi=new Map,Oc,Tc,Ec,Dc,$s,ar,vt,Io,bn,Pc,Cc,Mc,Ic,Et=class extends($s=_r,Dc=[K],Ec=[ce],Tc=[ce],Oc=[ce],$s){constructor(t,n){super(t,n),pe(vt,5,this),de(this,bn),de(this,ar,new Set),de(this,Io,pe(vt,8,this,new Set)),pe(vt,11,this),this.registerEffect(Bt(this,bn,Pc))}register(t){return te(this,ar).add(t),()=>{te(this,ar).delete(t)}}addRoot(t){return H(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{H(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return ai((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return ai((t=n?.element)!=null?t:null)}get roots(){const{status:t}=this.manager.dragOperation;if(t.initializing||t.initialized){const n=[this.sourceRoot,this.targetRoot].filter(r=>r!=null);return new Set([...n,...this.additionalRoots])}return new Set}};vt=Mn($s);ar=new WeakMap;Io=new WeakMap;bn=new WeakSet;Pc=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of te(this,ar))t.push(Bt(this,bn,Cc).call(this,n,r));return()=>{for(const n of t)n()}};Cc=function(e,t){let n=hi.get(e);n||(n=new Map,hi.set(e,n));let r=n.get(t);if(!r){const s=So(e)?Bt(this,bn,Mc).call(this,e,n,t):Bt(this,bn,Ic).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())}};Mc=function(e,t,n){var r;const i=e.createElement("style"),{nonce:s}=(r=this.options)!=null?r:{};s&&i.setAttribute("nonce",s),i.textContent=n,e.head.prepend(i);const o=new MutationObserver(a=>{for(const l of a)for(const d of Array.from(l.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&&hi.delete(e)}}};Ic=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(Oo(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&&hi.delete(e)}}};Je(vt,4,"additionalRoots",Dc,Et,Io);Je(vt,2,"sourceRoot",Ec,Et);Je(vt,2,"targetRoot",Tc,Et);Je(vt,2,"roots",Oc,Et);Kt(vt,Et);Et.configure=xr(Et);var Ci=Et,zf=class extends Ee{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Ci),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},kr="data-dnd-",Os=`${kr}dropping`,we="--dnd-",ot=`${kr}dragging`,pi=`${kr}placeholder`,Wf=[ot,pi,"popover","aria-pressed","aria-grabbing"],Ff=["view-transition-name"],Bf=`
9
+ :is(:root,:host) [${ot}] {
10
10
  position: fixed !important;
11
11
  pointer-events: none !important;
12
12
  touch-action: none;
13
13
  z-index: calc(infinity);
14
14
  will-change: translate;
15
- top: var(${ge}top, 0px) !important;
16
- left: var(${ge}left, 0px) !important;
15
+ top: var(${we}top, 0px) !important;
16
+ left: var(${we}left, 0px) !important;
17
17
  right: unset !important;
18
18
  bottom: unset !important;
19
- width: var(${ge}width, auto);
20
- max-width: var(${ge}width, auto);
21
- height: var(${ge}height, auto);
22
- max-height: var(${ge}height, auto);
23
- transform: var(${ge}transform, none) !important;
24
- transition: var(${ge}transition) !important;
19
+ width: var(${we}width, auto);
20
+ max-width: var(${we}width, auto);
21
+ height: var(${we}height, auto);
22
+ max-height: var(${we}height, auto);
23
+ transform: var(${we}transform, none) !important;
24
+ transition: var(${we}transition) !important;
25
25
  }
26
26
 
27
- :is(:root,:host) [${ri}] {
27
+ :is(:root,:host) [${pi}] {
28
28
  transition: none;
29
29
  }
30
30
 
31
- :is(:root,:host) [${ri}='hidden'] {
31
+ :is(:root,:host) [${pi}='hidden'] {
32
32
  visibility: hidden;
33
33
  }
34
34
 
35
- [${Qe}] * {
35
+ [${ot}] * {
36
36
  pointer-events: none !important;
37
37
  }
38
38
 
39
- [${Qe}]:not([${ms}]) {
40
- translate: var(${ge}translate) !important;
39
+ [${ot}]:not([${Os}]) {
40
+ translate: var(${we}translate) !important;
41
41
  }
42
42
 
43
- [${Qe}][style*='${ge}scale'] {
44
- scale: var(${ge}scale) !important;
45
- transform-origin: var(${ge}transform-origin) !important;
43
+ [${ot}][style*='${we}scale'] {
44
+ scale: var(${we}scale) !important;
45
+ transform-origin: var(${we}transform-origin) !important;
46
46
  }
47
47
 
48
48
  @layer dnd-kit {
49
- :where([${Qe}][popover]) {
49
+ :where([${ot}][popover]) {
50
50
  overflow: visible;
51
51
  background: unset;
52
52
  border: unset;
@@ -60,46 +60,46 @@
60
60
  }
61
61
  }
62
62
  }
63
- [${Qe}]::backdrop, [${gr}overlay]:not([${Qe}]) {
63
+ [${ot}]::backdrop, [${kr}overlay]:not([${ot}]) {
64
64
  display: none;
65
65
  visibility: hidden;
66
66
  }
67
- `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Bf(e,t="hidden"){return N(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=Nf(n,r.registry.droppables),s=[],o=Au(n),{remove:a}=o;return Gf(i,o,s),Vf(o,t),o.remove=()=>{s.forEach(c=>c()),a.call(o)},o})}function Nf(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${gr}${ps("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function Gf(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),ds.set(a,o),n.push(()=>{ds.delete(a),r.proxy=void 0})}}function Vf(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(ri,t)}function Ec(e,t){return e===t?!0:un(e)===un(t)}function da(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&At(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>on(t))}function ys(e){return e.tagName==="TR"}function Hf(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-")||zf.includes(a))continue;const c=e.getAttribute(a);if(a==="style"){if(Jn(e)&&Jn(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(Wf.includes(u)||u.startsWith(ge))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 Kf(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),on(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),on(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),on(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function qf(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=ic();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},ge),(n=e.getElementMutationObserver())==null||n.takeRecords(),ys(e.element)&&ys(e.placeholder)){const m=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(m.map(b=>b.style.width));for(const[b,v]of m.entries()){const p=w[b];v.style.width=`${p.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,g=i.height-e.heightOffset,h=e.frameTransform;e.dragOperation.shape=new tt(u*h.scaleX+h.x,l*h.scaleY+h.y,f*h.scaleX,g*h.scaleY)})}var Uf=250,Xf="ease";function Yf(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const v=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(v).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Uf,easing:a=Xf}=s??{};on(e.feedbackElement);const[,c]=(t=tc(e.feedbackElement,v=>"translate"in v))!=null?t:[];c?.pause();const d=(n=e.placeholder)!=null?n:e.element,u={frameTransform:Ec(e.feedbackElement,d)?null:void 0},l=new et(e.feedbackElement,u),f=(r=ir(it(e.feedbackElement).translate))!=null?r:e.translate,g=new et(d,u),h=tt.delta(l,g,e.alignment),m={x:f.x-h.x,y:f.y-h.y},w=Math.round(l.intrinsicHeight)!==Math.round(g.intrinsicHeight)?{minHeight:[`${l.intrinsicHeight}px`,`${g.intrinsicHeight}px`],maxHeight:[`${l.intrinsicHeight}px`,`${g.intrinsicHeight}px`]}:{},b=Math.round(l.intrinsicWidth)!==Math.round(g.intrinsicWidth)?{minWidth:[`${l.intrinsicWidth}px`,`${g.intrinsicWidth}px`],maxWidth:[`${l.intrinsicWidth}px`,`${g.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},ge),e.feedbackElement.setAttribute(ms,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),pc({element:e.feedbackElement,keyframes:wo(or(or({},w),b),{translate:[`${f.x}px ${f.y}px 0`,`${m.x}px ${m.y}px 0`]}),options:{duration:yo(Re(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(ms),c?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Pc,bs,ar,$o,Br,Mc,Cc,pn=class extends(bs=xe,Pc=[G],bs){constructor(t,n){super(t,n),ce(this,Br),ce(this,$o,fe(ar,8,this)),fe(ar,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(xi),i=r?.register(Ff);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}this.registerEffect(Rt(this,Br,Mc).bind(this,r)),this.registerEffect(Rt(this,Br,Cc))}};ar=On(bs);$o=new WeakMap;Br=new WeakSet;Mc=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Yr(t);if(n)return e.addRoot(n)};Cc=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:g}=u;if(g.idle){a.current={},a.initial={};return}if(!f)return;const{element:h}=f,m=f.pluginConfig(pn),w=(t=(e=m?.feedback)!=null?e:d?.feedback)!=null?t:"default",b=typeof w=="function"?w(f,c):w;if(!h||b==="none"||!g.initialized||g.initializing)return;const{initial:v}=a,p=(n=this.overlay)!=null?n:h,x=fn(p),_=fn(h),$=!Ec(h,p),T=new et(h,{frameTransform:$?_:null,ignoreTransforms:!$}),D={x:_.scaleX/x.scaleX,y:_.scaleY/x.scaleY};let{width:I,height:C,top:P,left:A}=T;$&&(I=I/D.x,C=C/D.y);const R=new gf(p),U=it(h),{transition:Te,translate:De,boxSizing:me,paddingBlockStart:X,paddingBlockEnd:Ye,paddingInlineStart:Ze,paddingInlineEnd:ye,borderInlineStartWidth:Me,borderInlineEndWidth:Ge,borderBlockStartWidth:Y,borderBlockEndWidth:ee}=U,H=Te.split(",").filter(Z=>!/^\s*(transform|translate|scale)\b/.test(Z)).join(","),he=bi(U),W=U.transform,K=b==="clone",_e=me==="content-box",ne=_e?parseInt(Ze)+parseInt(ye)+parseInt(Me)+parseInt(Ge):0,Ve=_e?parseInt(X)+parseInt(Ye)+parseInt(Y)+parseInt(ee):0,re=b!=="move"&&!this.overlay?Bf(f,K?"clone":"hidden"):null,ft=N(()=>sr(c.dragOperation.activatorEvent));if(!v.translate){if(this.overlay&&he)v.translate={x:he.x,y:he.y};else if(De!=="none"){const Z=ir(De);Z&&(v.translate=Z)}}if(!v.transformOrigin){const Z=N(()=>l.current),de=A+((r=he?.x)!=null?r:0),Ie=P+((i=he?.y)!=null?i:0);v.transformOrigin={x:(Z.x-de*x.scaleX-x.x)/(I*x.scaleX),y:(Z.y-Ie*x.scaleY-x.y)/(C*x.scaleY)}}const{transformOrigin:Je}=v,Nt=P*x.scaleY+x.y,M=A*x.scaleX+x.x;if(!v.coordinates&&(v.coordinates={x:M,y:Nt},D.x!==1||D.y!==1)){const{scaleX:Z,scaleY:de}=_,{x:Ie,y:ht}=Je;v.coordinates.x+=(I*Z-I)*Ie,v.coordinates.y+=(C*de-C)*ht}v.dimensions||(v.dimensions={width:I,height:C}),v.frameTransform||(v.frameTransform=x);const L={x:v.coordinates.x-M,y:v.coordinates.y-Nt},O={width:(v.dimensions.width*v.frameTransform.scaleX-I*x.scaleX)*Je.x,height:(v.dimensions.height*v.frameTransform.scaleY-C*x.scaleY)*Je.y},E={x:L.x/x.scaleX+O.width,y:L.y/x.scaleY+O.height},z={left:A+E.x,top:P+E.y};p.setAttribute(Qe,"true");const J=N(()=>u.transform),He=(s=v.translate)!=null?s:{x:0,y:0},we=J.x*x.scaleX+He.x,Ce=J.y*x.scaleY+He.y,st=ic();R.set({width:I-ne,height:C-Ve,top:z.top+st.y,left:z.left+st.x,translate:`${we}px ${Ce}px 0`,transform:this.overlay?"none":W,transition:H?`${H}, translate 0ms linear`:"translate 0ms linear",scale:$?`${D.x} ${D.y}`:"","transform-origin":`${Je.x*100}% ${Je.y*100}%`},ge),re&&(h.insertAdjacentElement("afterend",re),d?.rootElement&&(typeof d.rootElement=="function"?d.rootElement(f):d.rootElement).appendChild(h)),fs(p)&&(p.hasAttribute("popover")||p.setAttribute("popover","manual"),on(p),p.addEventListener("beforetoggle",da));let kt,$i,br;const zo=qf({placeholder:re,element:h,feedbackElement:p,frameTransform:x,transformOrigin:Je,width:I,height:C,top:P,left:A,widthOffset:ne,heightOffset:Ve,delta:E,styles:R,dragOperation:u,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>kt,getSavedCellWidths:()=>br,setSavedCellWidths:Z=>{br=Z}}),Wo=new et(p);N(()=>u.shape=Wo);const Oi=Re(p),Fo=Z=>{this.manager.actions.stop({event:Z})},Td=yo(Oi);ft&&Oi.addEventListener("resize",Fo),N(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),re&&(zo.observe(re),kt=Hf(h,re,K),$i=Kf(h,re,p));const Bo=(o=c.dragOperation.source)==null?void 0:o.id,Dd=()=>{var Z;if(!ft||Bo==null)return;const de=c.registry.draggables.get(Bo),Ie=(Z=de?.handle)!=null?Z:de?.element;_t(Ie)&&Ie.focus()},Ti=()=>{kt?.disconnect(),$i?.disconnect(),zo.disconnect(),Oi.removeEventListener("resize",Fo),fs(p)&&(p.removeEventListener("beforetoggle",da),p.removeAttribute("popover")),p.removeAttribute(Qe),R.reset();const Z=()=>{var de;if(br&&ys(h)){const Di=Array.from(h.cells);for(const[xr,Gt]of Di.entries())Gt.style.width=(de=br[xr])!=null?de:""}f.status="idle";const Ie=a.current.translate!=null,ht=u.status.dragging;re&&(!ht&&Ie||re.parentElement!==p.parentElement)&&p.isConnected&&re.replaceWith(p),re?.remove()};p===this.overlay?setTimeout(Z,0):Z()},Ed=d?.dropAnimation,No=this,Pd=dr(()=>{var Z,de,Ie;const{transform:ht,status:Di}=u;if(!(!ht.x&&!ht.y&&!a.current.translate)&&Di.dragging){const xr=(Z=v.translate)!=null?Z:{x:0,y:0},Gt={x:ht.x/x.scaleX+xr.x,y:ht.y/x.scaleY+xr.y},Go=a.current.translate,Md=N(()=>u.modifiers),Ei=N(()=>{var En;return(En=u.shape)==null?void 0:En.current}),Dn=d?.keyboardTransition,Vo=ft&&!Td&&Dn!==null?`${(de=Dn?.duration)!=null?de:250}ms ${(Ie=Dn?.easing)!=null?Ie:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(R.set({transition:H?`${H}, translate ${Vo}`:`translate ${Vo}`,translate:`${Gt.x}px ${Gt.y}px 0`},ge),kt?.takeRecords(),Ei&&Ei!==Wo&&Go&&!Md.length){const En=ze.delta(Gt,Go);u.shape=tt.from(Ei.boundingRectangle).translate(En.x*x.scaleX,En.y*x.scaleY)}else u.shape=new et(p);a.current.translate=Gt}},function(){if(u.status.dropped){this.dispose(),f.status="dropping";const Z=m?.dropAnimation!==void 0?m.dropAnimation:No.dropAnimation!==void 0?No.dropAnimation:Ed;let de=a.current.translate;const Ie=de!=null;if(!de&&h!==p&&(de={x:0,y:0}),!de||Z===null){Ti();return}c.renderer.rendering.then(()=>{Yf({source:f,element:h,feedbackElement:p,placeholder:re,translate:de,moved:Ie,transition:Te,alignment:f.alignment,styles:R,animation:Z??void 0,getElementMutationObserver:()=>kt,cleanup:Ti,restoreFocus:Dd})})}});return()=>{Ti(),Pd()}};Ne(ar,4,"overlay",Pc,pn,$o);Bt(ar,pn);pn.configure=fr(pn);var Oo=pn,Pn=!0,Zf=!1,Ic,jc,Ac,Rc,mt,To,Do;Rc=(Ac=[G],We.Forward),jc=(Ic=[G],We.Reverse);var lr=class{constructor(){ce(this,To,fe(mt,8,this,Pn)),fe(mt,11,this),ce(this,Do,fe(mt,12,this,Pn)),fe(mt,15,this)}isLocked(e){return e===We.Idle?!1:e==null?this[We.Forward]===Pn&&this[We.Reverse]===Pn:this[e]===Pn}unlock(e){e!==We.Idle&&(this[e]=Zf)}};mt=On(null);To=new WeakMap;Do=new WeakMap;Ne(mt,4,Rc,Ac,lr,To);Ne(mt,4,jc,Ic,lr,Do);Bt(mt,lr);var Jf=[We.Forward,We.Reverse],ua=class{constructor(){this.x=new lr,this.y=new lr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Qf=class extends xe{constructor(e){super(e);const t=vn(new ua);let n=null;this.signal=t,Be(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new ua;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:fa(i.x,n.x),y:fa(i.y,n.y)},o=t.peek();oe(()=>{for(const a of ul)for(const c of Jf)s[a]===c&&o[a].unlock(c);t.value=o})}n=i})}get current(){return this.signal.peek()}};function fa(e,t){return Math.sign(e-t)}var Lc,xs,cr,Eo,gt,_s,vr=class extends(xs=hr,Lc=[G],xs){constructor(e){super(e),ce(this,Eo,fe(cr,8,this,!1)),fe(cr,11,this),ce(this,gt),ce(this,_s,()=>{if(!Q(this,gt))return;const{element:s,by:o}=Q(this,gt);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 $e(this,gt,void 0),!1;const{position:d}=this.manager.dragOperation,u=d?.current;if(u){const{by:l}=s??{},f=l?{x:ha(l.x),y:ha(l.y)}:void 0,g=f?void 0:this.scrollIntentTracker.current;if(g?.isLocked())return!1;for(const h of c){const m=Uu(h,l);if(m.x||m.y){const{speed:w,direction:b}=of(h,u,f,o?.acceleration,o?.threshold);if(g)for(const v of ul)g[v].isLocked(b[v])&&(w[v]=0,b[v]=0);if(b.x||b.y){const{x:v,y:p}=l??b,x=v*w.x,_=p*w.y;if(x||_){const $=(a=Q(this,gt))==null?void 0:a.by;if(this.autoScrolling&&$&&($.x&&!x||$.y&&!_))continue;return $e(this,gt,{element:h,by:{x,y:_}}),Qr.schedule(Q(this,_s)),!0}}}}}return $e(this,gt,void 0),!1};let t=null,n=null;const r=Yi(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=sc(Yr(o?.element),s.current);return a&&(t=a),a??t}),i=Yi(()=>{const s=r.value,{documentElement:o}=Sn(s);if(!s||s===o){const{target:a}=e.dragOperation,c=a?.element;if(c){const d=hs(c,{excludeElement:!1});return n=d,d}}if(s){const a=hs(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},Ke);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new Qf(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!sr(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};cr=On(xs);Eo=new WeakMap;gt=new WeakMap;_s=new WeakMap;Ne(cr,4,"autoScrolling",Lc,vr,Eo);Bt(cr,vr);function ha(e){return e>0?We.Forward:e<0?We.Reverse:We.Idle}var eh=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))}},th=new eh(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),nh=10,ws=class extends xe{constructor(t,n){super(t,n);const r=t.registry.plugins.get(vr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=Be(()=>{var i,s,o;if(this.disabled)return;const{position:a,status:c}=t.dragOperation;if(c.dragging){const d={acceleration:(i=this.options)==null?void 0:i.acceleration,threshold:typeof((s=this.options)==null?void 0:s.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,d)){r.autoScrolling=!0;const l=setInterval(()=>th.schedule(()=>r.scroll(void 0,d)),nh);return()=>{clearInterval(l)}}else r.autoScrolling=!1}})}};ws.configure=fr(ws);var zc=ws,pa={capture:!0,passive:!0},Nn,rh=class extends hr{constructor(e){super(e),ce(this,Nn),this.handleScroll=()=>{Q(this,Nn)==null&&$e(this,Nn,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),$e(this,Nn,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Be(()=>{var n,r,i;if(t.status.dragging){const o=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return o.addEventListener("scroll",this.handleScroll,pa),()=>{o.removeEventListener("scroll",this.handleScroll,pa)}}})}};Nn=new WeakMap;var ih="* { user-select: none !important; -webkit-user-select: none !important; }",sh=class extends xe{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(xi),n=t?.register(ih);if(this.destroy=Be(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return Li(),document.addEventListener("selectionchange",Li,{capture:!0}),()=>{document.removeEventListener("selectionchange",Li,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function Li(){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}}),Qt,ii=class extends cn{constructor(t,n){super(t),this.manager=t,this.options=n,ce(this,Qt,[]),this.listeners=new oc,this.handleSourceKeyDown=(r,i,s)=>{if(this.disabled||r.defaultPrevented||!At(r.target)||i.disabled)return;const{keyboardCodes:o=Gn.keyboardCodes,preventActivation:a=Gn.preventActivation}=s??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,i)||this.handleStart(r,i,s))}}bind(t,n=this.options){return Be(()=>{var i;const s=(i=t.handle)!=null?i:t.element,o=a=>{sr(a)&&this.handleSourceKeyDown(a,t,n)};if(s)return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:i}=n;if(!i)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),hc(i);const{center:s}=new et(i);if(this.manager.actions.start({event:t,coordinates:{x:s.x,y:s.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=Sn(i),c=[this.listeners.bind(a,[{type:"keydown",listener:d=>this.handleKeyDown(d,n,r),options:{capture:!0}}])];Q(this,Qt).push(...c)}handleKeyDown(t,n,r){const{keyboardCodes:i=Gn.keyboardCodes}=r??{};if(Vt(t,[...i.end,...i.cancel])){t.preventDefault();const s=Vt(t,i.cancel);this.handleEnd(t,s);return}Vt(t,i.up)?this.handleMove("up",t):Vt(t,i.down)&&this.handleMove("down",t),Vt(t,i.left)?this.handleMove("left",t):Vt(t,i.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,i;const{shape:s}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},c=(i=(r=this.options)==null?void 0:r.offset)!=null?i:Gn.offset;if(typeof c=="number"&&(c={x:c,y:c}),!!s){switch(t){case"up":a={x:0,y:-c.y*o};break;case"down":a={x:0,y:c.y*o};break;case"left":a={x:-c.x*o,y:0};break;case"right":a={x:c.x*o,y:0};break}(a.x||a.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:a}))}}sideEffects(){const t=this.manager.registry.plugins.get(zc);t?.disabled===!1&&(t.disable(),Q(this,Qt).push(()=>{t.enable()}))}cleanup(){Q(this,Qt).forEach(t=>t()),$e(this,Qt,[])}destroy(){this.cleanup(),this.listeners.clear()}};Qt=new WeakMap;ii.configure=fr(ii);ii.defaults=Gn;var Wc=ii;function Vt(e,t){return t.includes(e.code)}var Pt,oh=class extends Gl{constructor(){super(...arguments),ce(this,Pt)}onEvent(e){switch(e.type){case"pointerdown":$e(this,Pt,dn(e));break;case"pointermove":if(!Q(this,Pt))return;const{x:t,y:n}=dn(e),r={x:t-Q(this,Pt).x,y:n-Q(this,Pt).y},{tolerance:i}=this.options;if(i&&ss(r,i)){this.abort();return}ss(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){$e(this,Pt,void 0)}};Pt=new WeakMap;var en,Mt,ah=class extends Gl{constructor(){super(...arguments),ce(this,en),ce(this,Mt)}onEvent(e){switch(e.type){case"pointerdown":$e(this,Mt,dn(e)),$e(this,en,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Q(this,Mt))return;const{x:t,y:n}=dn(e),r={x:t-Q(this,Mt).x,y:n-Q(this,Mt).y};ss(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Q(this,en)&&(clearTimeout(Q(this,en)),$e(this,Mt,void 0),$e(this,en,void 0))}};en=new WeakMap;Mt=new WeakMap;var sn=class{};sn.Delay=ah;sn.Distance=oh;var ks=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&At(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new sn.Delay({value:250,tolerance:5})]:mf(i)&&!e.defaultPrevented?[new sn.Delay({value:200,tolerance:0})]:[new sn.Delay({value:200,tolerance:10}),new sn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!At(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=Lu(r);return i===t.element?!1:!!i}}),tn,si=class extends cn{constructor(t,n){super(t),this.manager=t,this.options=n,ce(this,tn,new Set),this.listeners=new oc,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:i}=this.latest;!r||!i||this.manager.actions.move({event:r,to:i})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:i=ks.activationConstraints}=r??{};return typeof i=="function"?i(t,n):i}bind(t,n=this.options){return Be(()=>{var i;const s=new AbortController,{signal:o}=s,a=d=>{vf(d)&&this.handlePointerDown(d,t,n)};let c=[(i=t.handle)!=null?i:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?c=n.activatorElements:c=n.activatorElements(t));for(const d of c)d&&(dh(d.ownerDocument.defaultView),d.addEventListener("pointerdown",a,{signal:o}));return()=>s.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!At(t.target)||n.disabled||lh(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:i=ks.preventActivation}=r??{};if(i?.(t,n))return;const{target:s}=t,o=_t(s)&&s.draggable&&s.getAttribute("draggable")==="true",a=fn(n.element),{x:c,y:d}=dn(t);this.initialCoordinates={x:c*a.scaleX+a.x,y:d*a.scaleY+a.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const l=new Du(u,m=>this.handleStart(n,m));l.signal.onabort=()=>this.handleCancel(t),l.onEvent(t),this.controller=l;const f=cs(),g=this.listeners.bind(f,[{type:"pointermove",listener:m=>this.handlePointerMove(m,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Sr,options:{capture:!0}}]),h=()=>{g(),this.initialCoordinates=void 0};Q(this,tn).add(h)}handlePointerMove(t,n){var r,i;if(((r=this.controller)==null?void 0:r.activated)===!1){(i=this.controller)==null||i.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const s=dn(t),o=fn(n.element);s.x=s.x*o.scaleX+o.x,s.y=s.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=s,Qr.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:i}=this;if(!i||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:i,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=Sn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const c=At(n.target)?[n.target,a]:a,d=this.listeners.bind(c,[{type:"touchmove",listener:Sr,options:{passive:!1}},{type:"click",listener:Sr},{type:"contextmenu",listener:Sr},{type:"keydown",listener:this.handleKeyDown}]);Q(this,tn).add(d)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){const{controller:t}=this;this.controller=void 0,t&&!t.signal.aborted&&t.abort(),this.latest={event:void 0,coordinates:void 0},Q(this,tn).forEach(n=>n()),Q(this,tn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};tn=new WeakMap;si.configure=fr(si);si.defaults=ks;var Ss=si;function lh(e){return"sensor"in e}function Sr(e){e.preventDefault()}function ch(){}var ga=new WeakSet;function dh(e){!e||ga.has(e)||(e.addEventListener("touchmove",ch,{capture:!1,passive:!1}),ga.add(e))}var an={modifiers:[],plugins:[Af,zc,Lf,Oo,sh],sensors:[Ss,Wc]},Fc=class extends Mu{constructor(e={}){const t=Ue(e.plugins,an.plugins),n=Ue(e.sensors,an.sensors),r=Ue(e.modifiers,an.modifiers);super(wo(or({},e),{plugins:[rh,vr,xi,...t],sensors:n,modifiers:r}))}},Bc,Nc,$s,yt,Po,Mo,_i=class extends($s=nt,Nc=[G],Bc=[G],$s){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=bc(n,["element","effects","handle"]);super(or({effects:()=>[...i(),()=>{var a,c;const{manager:d}=this;if(!d)return;const l=((c=(a=this.sensors)==null?void 0:a.map(tr))!=null?c:[...d.sensors]).map(f=>{const g=f instanceof cn?f:d.registry.register(f.plugin),h=f instanceof cn?void 0:f.options;return g.bind(this,h)});return function(){l.forEach(g=>g())}}]},o),t),ce(this,Po,fe(yt,8,this)),fe(yt,11,this),ce(this,Mo,fe(yt,12,this)),fe(yt,15,this),this.element=r,this.handle=s}};yt=On($s);Po=new WeakMap;Mo=new WeakMap;Ne(yt,4,"handle",Nc,_i,Po);Ne(yt,4,"element",Bc,_i,Mo);Bt(yt,_i);var Gc,Vc,Os,bt,Co,zi,Hc,Kc,er,Io,wi=class extends(Os=rt,Vc=[G],Gc=[G],Os){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=bc(n,["element","effects"]);const{collisionDetector:o=gc}=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),g=N(()=>this.shape);return f&&g?.equals(f)?g:(this.shape=f,f)},c=vn(!1);super(wo(or({},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 qu(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,er),ce(this,Co,fe(bt,8,this)),fe(bt,11,this),ce(this,Io,fe(bt,12,this)),fe(bt,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){$e(this,er,e,Kc)}get element(){var e;return(e=this.proxy)!=null?e:Q(this,er,Hc)}};bt=On(Os);Co=new WeakMap;er=new WeakSet;Io=new WeakMap;zi=Ne(bt,20,"#element",Vc,er,Co),Hc=zi.get,Kc=zi.set;Ne(bt,4,"proxy",Gc,wi,Io);Bt(bt,wi);function uh(e){return e!=null&&typeof e=="object"&&"current"in e}function ln(e){var t;if(e!=null)return uh(e)?(t=e.current)!=null?t:void 0:e}var fh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Tn=fh?S.useLayoutEffect:S.useEffect;function hh(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function qc(e,t){const n=S.useRef(new Map),r=hh();return Tn(()=>{if(!e){n.current.clear();return}return Be(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[c]=a,d=N(()=>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(()=>zd.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 ph(e,t){e()}function Ht(e){const t=S.useRef(e);return Tn(()=>{t.current=e},[e]),t}function ie(e,t,n=S.useEffect,r=Object.is){const i=S.useRef(e);n(()=>{const s=i.current;r(e,s)||(i.current=e,t(e,s))},[t,e])}function Nr(e,t){const n=S.useRef(ln(e));Tn(()=>{const r=ln(e);r!==n.current&&(n.current=r,t(r))})}var gh=Object.defineProperty,vh=Object.defineProperties,mh=Object.getOwnPropertyDescriptors,oi=Object.getOwnPropertySymbols,Uc=Object.prototype.hasOwnProperty,Xc=Object.prototype.propertyIsEnumerable,va=(e,t,n)=>t in e?gh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yh=(e,t)=>{for(var n in t||(t={}))Uc.call(t,n)&&va(e,n,t[n]);if(oi)for(var n of oi(t))Xc.call(t,n)&&va(e,n,t[n]);return e},bh=(e,t)=>vh(e,mh(t)),xh=(e,t)=>{var n={};for(var r in e)Uc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&oi)for(var r of oi(e))t.indexOf(r)<0&&Xc.call(e,r)&&(n[r]=e[r]);return n},_h=new Fc,Yc=S.createContext(_h),wh=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 Tn(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),Wi=[void 0,Ke];function kh(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:c}=t,d=xh(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=S.useRef(null),{plugins:l,modifiers:f,sensors:g}=d,h=Ue(l,an.plugins),m=Ue(g,an.sensors),w=Ue(f,an.modifiers),b=Ht(i),v=Ht(s),p=Ht(a),x=Ht(o),_=Ht(c),$=Ht(r),T=Sh(()=>{var D;return(D=d.manager)!=null?D:new Fc(d)});return S.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:D,trackRendering:I}=u.current,{monitor:C}=T;T.renderer=D;const P=[C.addEventListener("beforedragstart",A=>{const R=b.current;R&&I(()=>R(A,T))}),C.addEventListener("dragstart",A=>{var R;return(R=v.current)==null?void 0:R.call(v,A,T)}),C.addEventListener("dragover",A=>{const R=p.current;R&&I(()=>R(A,T))}),C.addEventListener("dragmove",A=>{const R=x.current;R&&I(()=>R(A,T))}),C.addEventListener("dragend",A=>{const R=_.current;R&&I(()=>R(A,T))}),C.addEventListener("collision",A=>{var R;return(R=$.current)==null?void 0:R.call($,A,T)})];return()=>P.forEach(A=>A())},[T]),ie(h,()=>T&&(T.plugins=h),...Wi),ie(m,()=>T&&(T.sensors=m),...Wi),ie(w,()=>T&&(T.modifiers=w),...Wi),y.jsxs(Yc.Provider,{value:T,children:[y.jsx(wh,{ref:u,children:n}),n]})}function Sh(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 $h(){return S.useContext(Yc)}function Zc(e){var t;const n=(t=$h())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Tn(r.register,[n,r]),r}var Oh=Object.create,Jc=Object.defineProperty,Th=Object.getOwnPropertyDescriptor,Qc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ki=e=>{throw TypeError(e)},Dh=(e,t,n)=>t in e?Jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Eh=e=>{var t;return[,,,Oh((t=e?.[Qc("metadata")])!=null?t:null)]},ed=["class","method","getter","setter","accessor","field","value","get","set"],td=e=>e!==void 0&&typeof e!="function"?ki("Function expected"):e,Ph=(e,t,n,r,i)=>({kind:ed[e],name:t,metadata:r,addInitializer:s=>n._?ki("Already initialized"):i.push(td(s||null))}),Mh=(e,t)=>Dh(t,Qc("metadata"),e[3]),Ch=(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},nd=(e,t,n,r,i,s)=>{for(var o,a,c,d,u=t&7,l=!1,f=!1,g=2,h=ed[u+5],m=e[g]||(e[g]=[]),w=(i=i.prototype,Th(i,n)),b=r.length-1;b>=0;b--)c=Ph(u,n,a={},e[3],m),c.static=l,c.private=f,d=c.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[b])(w[h],c),a._=1,td(o)&&(w[h]=o);return w&&Jc(i,n,w),i},rd=(e,t,n)=>t.has(e)||ki("Cannot "+n),Ih=(e,t,n)=>(rd(e,t,"read from private field"),t.get(e)),jh=(e,t,n)=>t.has(e)?ki("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ah=(e,t,n,r)=>(rd(e,t,"write to private field"),t.set(e,n),n),It=class Ts{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ts(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 Ts(t,n)}},id,sd,Ds,Gr,mr,jo=class extends(Ds=Wt,sd=[le],id=[le],Ds){constructor(e){const t=It.from(e);super(t,(n,r)=>It.equals(n,r)),Ch(mr,5,this),jh(this,Gr,0),this.velocity={x:0,y:0}}get delta(){return It.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=It.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Ih(this,Gr),o=a=>Math.round(a/s*100);oe(()=>{Ah(this,Gr,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(It.from(e)),this.velocity={x:0,y:0}}};mr=Eh(Ds);Gr=new WeakMap;nd(mr,2,"delta",sd,jo);nd(mr,2,"direction",id,jo);Mh(mr,jo);var od=(e=>(e.Horizontal="x",e.Vertical="y",e))(od||{});Object.values(od);var Rh=({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=It.distance(t.shape.center,n);return{id:r,value:1/i,type:kn.PointerIntersection,priority:wn.High}}return null},Lh=({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=It.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:kn.ShapeIntersection,priority:wn.Normal}}return null},zh=e=>{var t;return(t=Rh(e))!=null?t:Lh(e)};function Wh(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,c=Zc(u=>new wi(bh(yh({},e),{register:!1,element:ln(i)}),u)),d=qc(c);return ie(s,()=>c.id=s),Nr(i,u=>c.element=u),ie(o,()=>c.accept=o,void 0,Ke),ie(t,()=>c.collisionDetector=t??zh),ie(n,()=>n&&(c.data=n)),ie(r,()=>c.disabled=r===!0),ie(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 Fh(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 ai(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Bh(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Vr(e,t){const n=Bh(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 ma(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 Nh(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Gh=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Vh(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",i=/^[A-Z_]/.test(r)?r:`F_${r}`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const ya=[{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 $r(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 Es=e=>e.declaration.kind==="reference";function Hh(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}:ai(t.type)!==void 0?{op:ai(t.type)}:{}}})}function Kh(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Es(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 qh(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 Uh(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 Xh=j.createSvgIcon(y.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),Yh=j.createSvgIcon(y.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"})),Zh=j.createSvgIcon(y.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"})),Jh=j.createSvgIcon(y.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"})),Ps=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),Fi=Ps?"⌘":"Ctrl+",Qh=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function ep(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=Ps?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!Qh(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!Ps&&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 tp({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:c,onSettings:d}){const{theme:u}=Pe.usePublisherTheme();return y.jsxs(j.DashboardBar,{left:y.jsx(k.Chip,{size:"medium",variant:"outlined",icon:y.jsx(Yh,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:u.border,color:u.tileTitle,"& .MuiChip-icon":{color:"inherit"},"& .MuiChip-label":{fontSize:"0.875rem"}}}),children:[c&&y.jsx(k.Button,{startIcon:y.jsx(j.AddIcon,{}),onClick:c,"aria-label":"Add tile",children:"Tile"}),y.jsx(k.Button,{startIcon:y.jsx(Xh,{}),onClick:l=>d(l.currentTarget),children:"Settings"}),y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(k.Tooltip,{title:`Undo (${Fi}Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:y.jsx(Jh,{fontSize:"small"})})})}),y.jsx(k.Tooltip,{title:`Redo (${Fi}⇧Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:y.jsx(Zh,{fontSize:"small"})})})}),o&&y.jsx(y.Fragment,{children:y.jsx(k.Tooltip,{title:i?`Save (${Fi}S)`:"",children:y.jsx("span",{children:y.jsx(k.Button,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,startIcon:!i&&!s?y.jsx(j.CheckIcon,{}):void 0,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&y.jsxs(y.Fragment,{children:[y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const np=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Or(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function ba(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&np.includes(n))return n}}const rp=1;function ad(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(...ad(a,`${t}${s}.`,n-1))}}}return r}function ip(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,ad(i.schema?.fields,"",rp))}return t}function xa(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const sp=e=>(e??"").startsWith("dashboards/"),op=e=>e.modelPath??e.path??"";function ld(e){const t=[],n=new Set;for(const r of e){const i=op(r);if(sp(i))continue;const s=ip(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,...Or(o.annotations)?{description:Or(o.annotations)}:{},views:(o.views??[]).filter(d=>typeof d.name=="string").map(d=>({name:d.name,...Or(d.annotations)?{description:Or(d.annotations)}:{},...ba(d.annotations)?{chart:ba(d.annotations)}:{}})),givens:c,fields:s.get(a)??[]})}}return{sources:t}}const ot=e=>`${e.source}.${e.name}`;function ap(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 lp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=Pe.usePublisherTheme(),a=S.useMemo(()=>ap(t,n),[t,n]),[c,d]=S.useState(""),[u,l]=S.useState(""),[f,g]=S.useState(""),[h,m]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(d(t.sources[0]?.base??a[0]?.name??""),l(""),g(""),m(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(v=>v.name===c),b=c!==""&&u!=="";return y.jsx(j.AppDialog,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",disabled:!b,onClick:()=>s({base:c,view:u,...f.trim()?{label:f.trim()}:{},colspan:h}),children:"Add tile"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:a.length===0?y.jsx(k.Typography,{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."}):y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Source",value:c,onChange:v=>{d(v.target.value),l("")},inputProps:{"aria-label":"Source"},children:a.map(v=>y.jsxs(k.MenuItem,{value:v.name,children:[v.name,v.description&&y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:v.description})]},v.name))}),y.jsxs(k.Box,{children:[y.jsx(k.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(k.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(v=>y.jsxs(k.ListItemButton,{selected:u===v.name,onClick:()=>l(v.name),"aria-label":`View ${v.name}`,children:[y.jsx(k.ListItemText,{primary:v.name,secondary:v.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),v.chart&&y.jsx(k.Chip,{size:"small",variant:"outlined",label:v.chart.replace(/_chart$/,"")})]},v.name)),w&&w.views.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:f,onChange:v=>g(v.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),y.jsx(k.TextField,{size:"small",type:"number",label:`Width (of ${r})`,value:h,onChange:v=>m(Math.min(Math.max(Number(v.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const _a=4e3;function cp(e,t){const n=e.split(`
67
+ `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Nf(e,t="hidden"){return H(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=Gf(n,r.registry.droppables),s=[],o=Ru(n),{remove:a}=o;return Vf(i,o,s),Hf(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function Gf(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${kr}${ks("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function Vf(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),bs.set(a,o),n.push(()=>{bs.delete(a),r.proxy=void 0})}}function Hf(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(pi,t)}function jc(e,t){return e===t?!0:mn(e)===mn(t)}function pa(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Ft(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>fn(t))}function Ts(e){return e.tagName==="TR"}function Kf(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-")||Wf.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(or(e)&&or(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(Ff.includes(u)||u.startsWith(we))continue;const c=d.getPropertyValue(u);t.style.setProperty(u,c)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function qf(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),fn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),fn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),fn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Uf(e){return new ResizeObserver(()=>{var t,n,r;const i=new at(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-i.width)*s.x+e.delta.x,a=(e.height-i.height)*s.y+e.delta.y,l=cc();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},we),(n=e.getElementMutationObserver())==null||n.takeRecords(),Ts(e.element)&&Ts(e.placeholder)){const m=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(m.map(b=>b.style.width));for(const[b,v]of m.entries()){const p=w[b];v.style.width=`${p.getBoundingClientRect().width}px`}}const d=(r=e.getTranslate())!=null?r:{x:0,y:0},u=e.left+o+l.x+d.x,c=e.top+a+l.y+d.y,h=i.width-e.widthOffset,f=i.height-e.heightOffset,g=e.frameTransform;e.dragOperation.shape=new lt(u*g.scaleX+g.x,c*g.scaleY+g.y,h*g.scaleX,f*g.scaleY)})}var Xf=250,Yf="ease";function Zf(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const v=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(v).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Xf,easing:a=Yf}=s??{};fn(e.feedbackElement);const[,l]=(t=oc(e.feedbackElement,v=>"translate"in v))!=null?t:[];l?.pause();const d=(n=e.placeholder)!=null?n:e.element,u={frameTransform:jc(e.feedbackElement,d)?null:void 0},c=new at(e.feedbackElement,u),h=(r=fr(ut(e.feedbackElement).translate))!=null?r:e.translate,f=new at(d,u),g=lt.delta(c,f,e.alignment),m={x:h.x-g.x,y:h.y-g.y},w=Math.round(c.intrinsicHeight)!==Math.round(f.intrinsicHeight)?{minHeight:[`${c.intrinsicHeight}px`,`${f.intrinsicHeight}px`],maxHeight:[`${c.intrinsicHeight}px`,`${f.intrinsicHeight}px`]}:{},b=Math.round(c.intrinsicWidth)!==Math.round(f.intrinsicWidth)?{minWidth:[`${c.intrinsicWidth}px`,`${f.intrinsicWidth}px`],maxWidth:[`${c.intrinsicWidth}px`,`${f.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},we),e.feedbackElement.setAttribute(Os,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),bc({element:e.feedbackElement,keyframes:Co(pr(pr({},w),b),{translate:[`${h.x}px ${h.y}px 0`,`${m.x}px ${m.y}px 0`]}),options:{duration:To(He(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Os),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Ac,Es,gr,jo,Qr,Rc,Lc,xn=class extends(Es=Ee,Ac=[K],Es){constructor(t,n){super(t,n),de(this,Qr),de(this,jo,pe(gr,8,this)),pe(gr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Ci),i=r?.register(Bf);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}this.registerEffect(Bt(this,Qr,Rc).bind(this,r)),this.registerEffect(Bt(this,Qr,Lc))}};gr=Mn(Es);jo=new WeakMap;Qr=new WeakSet;Rc=function(e){const{overlay:t}=this;if(!t||!e)return;const n=ai(t);if(n)return e.addRoot(n)};Lc=function(){var e,t,n,r,i,s,o;const{state:a,manager:l,options:d}=this,{dragOperation:u}=l,{position:c,source:h,status:f}=u;if(f.idle){a.current={},a.initial={};return}if(!h)return;const{element:g}=h,m=h.pluginConfig(xn),w=(t=(e=m?.feedback)!=null?e:d?.feedback)!=null?t:"default",b=typeof w=="function"?w(h,l):w;if(!g||b==="none"||!f.initialized||f.initializing)return;const{initial:v}=a,p=(n=this.overlay)!=null?n:g,x=yn(p),_=yn(g),O=!jc(g,p),T=new at(g,{frameTransform:O?_:null,ignoreTransforms:!O}),E={x:_.scaleX/x.scaleX,y:_.scaleY/x.scaleY};let{width:I,height:D,top:L,left:M}=T;O&&(I=I/E.x,D=D/E.y);const A=new vf(p),Q=ut(g),{transition:J,translate:ye,boxSizing:Ie,paddingBlockStart:ie,paddingBlockEnd:ze,paddingInlineStart:Ke,paddingInlineEnd:be,borderInlineStartWidth:qe,borderInlineEndWidth:We,borderBlockStartWidth:je,borderBlockEndWidth:Fe}=Q,xe=J.split(",").filter(W=>!/^\s*(transform|translate|scale)\b/.test(W)).join(","),ee=Pi(Q),z=Q.transform,V=b==="clone",_e=Ie==="content-box",ne=_e?parseInt(Ke)+parseInt(be)+parseInt(qe)+parseInt(We):0,Ae=_e?parseInt(ie)+parseInt(ze)+parseInt(je)+parseInt(Fe):0,X=b!=="move"&&!this.overlay?Nf(h,V?"clone":"hidden"):null,et=H(()=>hr(l.dragOperation.activatorEvent));if(!v.translate){if(this.overlay&&ee)v.translate={x:ee.x,y:ee.y};else if(ye!=="none"){const W=fr(ye);W&&(v.translate=W)}}if(!v.transformOrigin){const W=H(()=>c.current),ue=M+((r=ee?.x)!=null?r:0),Ne=L+((i=ee?.y)!=null?i:0);v.transformOrigin={x:(W.x-ue*x.scaleX-x.x)/(I*x.scaleX),y:(W.y-Ne*x.scaleY-x.y)/(D*x.scaleY)}}const{transformOrigin:Se}=v,ft=L*x.scaleY+x.y,P=M*x.scaleX+x.x;if(!v.coordinates&&(v.coordinates={x:P,y:ft},E.x!==1||E.y!==1)){const{scaleX:W,scaleY:ue}=_,{x:Ne,y:bt}=Se;v.coordinates.x+=(I*W-I)*Ne,v.coordinates.y+=(D*ue-D)*bt}v.dimensions||(v.dimensions={width:I,height:D}),v.frameTransform||(v.frameTransform=x);const R={x:v.coordinates.x-P,y:v.coordinates.y-ft},U={width:(v.dimensions.width*v.frameTransform.scaleX-I*x.scaleX)*Se.x,height:(v.dimensions.height*v.frameTransform.scaleY-D*x.scaleY)*Se.y},$={x:R.x/x.scaleX+U.width,y:R.y/x.scaleY+U.height},C={left:M+$.x,top:L+$.y};p.setAttribute(ot,"true");const F=H(()=>u.transform),Y=(s=v.translate)!=null?s:{x:0,y:0},Be=F.x*x.scaleX+Y.x,ge=F.y*x.scaleY+Y.y,$e=cc();A.set({width:I-ne,height:D-Ae,top:C.top+$e.y,left:C.left+$e.x,translate:`${Be}px ${ge}px 0`,transform:this.overlay?"none":z,transition:xe?`${xe}, translate 0ms linear`:"translate 0ms linear",scale:O?`${E.x} ${E.y}`:"","transform-origin":`${Se.x*100}% ${Se.y*100}%`},we),X&&(g.insertAdjacentElement("afterend",X),d?.rootElement&&(typeof d.rootElement=="function"?d.rootElement(h):d.rootElement).appendChild(g)),_s(p)&&(p.hasAttribute("popover")||p.setAttribute("popover","manual"),fn(p),p.addEventListener("beforetoggle",pa));let ve,qt,jn;const Tr=Uf({placeholder:X,element:g,feedbackElement:p,frameTransform:x,transformOrigin:Se,width:I,height:D,top:L,left:M,widthOffset:ne,heightOffset:Ae,delta:$,styles:A,dragOperation:u,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>ve,getSavedCellWidths:()=>jn,setSavedCellWidths:W=>{jn=W}}),Ut=new at(p);H(()=>u.shape=Ut);const An=He(p),Er=W=>{this.manager.actions.stop({event:W})},Dr=To(An);et&&An.addEventListener("resize",Er),H(()=>h.status)==="idle"&&requestAnimationFrame(()=>h.status="dragging"),X&&(Tr.observe(X),ve=Kf(g,X,V),qt=qf(g,X,p));const Pr=(o=l.dragOperation.source)==null?void 0:o.id,Ri=()=>{var W;if(!et||Pr==null)return;const ue=l.registry.draggables.get(Pr),Ne=(W=ue?.handle)!=null?W:ue?.element;Tt(Ne)&&Ne.focus()},G=()=>{ve?.disconnect(),qt?.disconnect(),Tr.disconnect(),An.removeEventListener("resize",Er),_s(p)&&(p.removeEventListener("beforetoggle",pa),p.removeAttribute("popover")),p.removeAttribute(ot),A.reset();const W=()=>{var ue;if(jn&&Ts(g)){const Li=Array.from(g.cells);for(const[Cr,Xt]of Li.entries())Xt.style.width=(ue=jn[Cr])!=null?ue:""}h.status="idle";const Ne=a.current.translate!=null,bt=u.status.dragging;X&&(!bt&&Ne||X.parentElement!==p.parentElement)&&p.isConnected&&X.replaceWith(p),X?.remove()};p===this.overlay?setTimeout(W,0):W()},Oe=d?.dropAnimation,tt=this,fe=yr(()=>{var W,ue,Ne;const{transform:bt,status:Li}=u;if(!(!bt.x&&!bt.y&&!a.current.translate)&&Li.dragging){const Cr=(W=v.translate)!=null?W:{x:0,y:0},Xt={x:bt.x/x.scaleX+Cr.x,y:bt.y/x.scaleY+Cr.y},qo=a.current.translate,Md=H(()=>u.modifiers),zi=H(()=>{var Ln;return(Ln=u.shape)==null?void 0:Ln.current}),Rn=d?.keyboardTransition,Uo=et&&!Dr&&Rn!==null?`${(ue=Rn?.duration)!=null?ue:250}ms ${(Ne=Rn?.easing)!=null?Ne:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(A.set({transition:xe?`${xe}, translate ${Uo}`:`translate ${Uo}`,translate:`${Xt.x}px ${Xt.y}px 0`},we),ve?.takeRecords(),zi&&zi!==Ut&&qo&&!Md.length){const Ln=Xe.delta(Xt,qo);u.shape=lt.from(zi.boundingRectangle).translate(Ln.x*x.scaleX,Ln.y*x.scaleY)}else u.shape=new at(p);a.current.translate=Xt}},function(){if(u.status.dropped){this.dispose(),h.status="dropping";const W=m?.dropAnimation!==void 0?m.dropAnimation:tt.dropAnimation!==void 0?tt.dropAnimation:Oe;let ue=a.current.translate;const Ne=ue!=null;if(!ue&&g!==p&&(ue={x:0,y:0}),!ue||W===null){G();return}l.renderer.rendering.then(()=>{Zf({source:h,element:g,feedbackElement:p,placeholder:X,translate:ue,moved:Ne,transition:J,alignment:h.alignment,styles:A,animation:W??void 0,getElementMutationObserver:()=>ve,cleanup:G,restoreFocus:Ri})})}});return()=>{G(),fe()}};Je(gr,4,"overlay",Ac,xn,jo);Kt(gr,xn);xn.configure=xr(xn);var Ao=xn,zn=!0,Qf=!1,zc,Wc,Fc,Bc,kt,Ro,Lo;Bc=(Fc=[K],Ye.Forward),Wc=(zc=[K],Ye.Reverse);var vr=class{constructor(){de(this,Ro,pe(kt,8,this,zn)),pe(kt,11,this),de(this,Lo,pe(kt,12,this,zn)),pe(kt,15,this)}isLocked(e){return e===Ye.Idle?!1:e==null?this[Ye.Forward]===zn&&this[Ye.Reverse]===zn:this[e]===zn}unlock(e){e!==Ye.Idle&&(this[e]=Qf)}};kt=Mn(null);Ro=new WeakMap;Lo=new WeakMap;Je(kt,4,Bc,Fc,vr,Ro);Je(kt,4,Wc,zc,vr,Lo);Kt(kt,vr);var Jf=[Ye.Forward,Ye.Reverse],ga=class{constructor(){this.x=new vr,this.y=new vr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},eh=class extends Ee{constructor(e){super(e);const t=wn(new ga);let n=null;this.signal=t,Qe(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new ga;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:va(i.x,n.x),y:va(i.y,n.y)},o=t.peek();ae(()=>{for(const a of vl)for(const l of Jf)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function va(e,t){return Math.sign(e-t)}var Nc,Ds,mr,zo,_t,Ps,Sr=class extends(Ds=_r,Nc=[K],Ds){constructor(e){super(e),de(this,zo,pe(mr,8,this,!1)),pe(mr,11,this),de(this,_t),de(this,Ps,()=>{if(!te(this,_t))return;const{element:s,by:o}=te(this,_t);o.y&&(s.scrollTop+=o.y),o.x&&(s.scrollLeft+=o.x)}),this.scroll=(s,o)=>{var a;if(this.disabled)return!1;const l=this.getScrollableElements();if(!l)return Ce(this,_t,void 0),!1;const{position:d}=this.manager.dragOperation,u=d?.current;if(u){const{by:c}=s??{},h=c?{x:ma(c.x),y:ma(c.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f?.isLocked())return!1;for(const g of l){const m=Xu(g,c);if(m.x||m.y){const{speed:w,direction:b}=af(g,u,h,o?.acceleration,o?.threshold);if(f)for(const v of vl)f[v].isLocked(b[v])&&(w[v]=0,b[v]=0);if(b.x||b.y){const{x:v,y:p}=c??b,x=v*w.x,_=p*w.y;if(x||_){const O=(a=te(this,_t))==null?void 0:a.by;if(this.autoScrolling&&O&&(O.x&&!x||O.y&&!_))continue;return Ce(this,_t,{element:g,by:{x,y:_}}),di.schedule(te(this,Ps)),!0}}}}}return Ce(this,_t,void 0),!1};let t=null,n=null;const r=ss(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=dc(ai(o?.element),s.current);return a&&(t=a),a??t}),i=ss(()=>{const s=r.value,{documentElement:o}=Pn(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const d=ws(l,{excludeElement:!1});return n=d,d}}if(s){const a=ws(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},nt);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new eh(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!hr(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};mr=Mn(Ds);zo=new WeakMap;_t=new WeakMap;Ps=new WeakMap;Je(mr,4,"autoScrolling",Nc,Sr,zo);Kt(mr,Sr);function ma(e){return e>0?Ye.Forward:e<0?Ye.Reverse:Ye.Idle}var th=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))}},nh=new th(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),rh=10,Cs=class extends Ee{constructor(t,n){super(t,n);const r=t.registry.plugins.get(Sr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=Qe(()=>{var i,s,o;if(this.disabled)return;const{position:a,status:l}=t.dragOperation;if(l.dragging){const d={acceleration:(i=this.options)==null?void 0:i.acceleration,threshold:typeof((s=this.options)==null?void 0:s.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,d)){r.autoScrolling=!0;const c=setInterval(()=>nh.schedule(()=>r.scroll(void 0,d)),rh);return()=>{clearInterval(c)}}else r.autoScrolling=!1}})}};Cs.configure=xr(Cs);var Gc=Cs,ya={capture:!0,passive:!0},Yn,ih=class extends _r{constructor(e){super(e),de(this,Yn),this.handleScroll=()=>{te(this,Yn)==null&&Ce(this,Yn,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Ce(this,Yn,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Qe(()=>{var n,r,i;if(t.status.dragging){const o=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return o.addEventListener("scroll",this.handleScroll,ya),()=>{o.removeEventListener("scroll",this.handleScroll,ya)}}})}};Yn=new WeakMap;var sh="* { user-select: none !important; -webkit-user-select: none !important; }",oh=class extends Ee{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Ci),n=t?.register(sh);if(this.destroy=Qe(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return Ki(),document.addEventListener("selectionchange",Ki,{capture:!0}),()=>{document.removeEventListener("selectionchange",Ki,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function Ki(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var Zn=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}}),on,gi=class extends gn{constructor(t,n){super(t),this.manager=t,this.options=n,de(this,on,[]),this.listeners=new uc,this.handleSourceKeyDown=(r,i,s)=>{if(this.disabled||r.defaultPrevented||!Ft(r.target)||i.disabled)return;const{keyboardCodes:o=Zn.keyboardCodes,preventActivation:a=Zn.preventActivation}=s??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,i)||this.handleStart(r,i,s))}}bind(t,n=this.options){return Qe(()=>{var i;const s=(i=t.handle)!=null?i:t.element,o=a=>{hr(a)&&this.handleSourceKeyDown(a,t,n)};if(s)return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:i}=n;if(!i)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),yc(i);const{center:s}=new at(i);if(this.manager.actions.start({event:t,coordinates:{x:s.x,y:s.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=Pn(i),l=[this.listeners.bind(a,[{type:"keydown",listener:d=>this.handleKeyDown(d,n,r),options:{capture:!0}}])];te(this,on).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:i=Zn.keyboardCodes}=r??{};if(Yt(t,[...i.end,...i.cancel])){t.preventDefault();const s=Yt(t,i.cancel);this.handleEnd(t,s);return}Yt(t,i.up)?this.handleMove("up",t):Yt(t,i.down)&&this.handleMove("down",t),Yt(t,i.left)?this.handleMove("left",t):Yt(t,i.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,i;const{shape:s}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},l=(i=(r=this.options)==null?void 0:r.offset)!=null?i:Zn.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!s){switch(t){case"up":a={x:0,y:-l.y*o};break;case"down":a={x:0,y:l.y*o};break;case"left":a={x:-l.x*o,y:0};break;case"right":a={x:l.x*o,y:0};break}(a.x||a.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:a}))}}sideEffects(){const t=this.manager.registry.plugins.get(Gc);t?.disabled===!1&&(t.disable(),te(this,on).push(()=>{t.enable()}))}cleanup(){te(this,on).forEach(t=>t()),Ce(this,on,[])}destroy(){this.cleanup(),this.listeners.clear()}};on=new WeakMap;gi.configure=xr(gi);gi.defaults=Zn;var Vc=gi;function Yt(e,t){return t.includes(e.code)}var At,ah=class extends Ul{constructor(){super(...arguments),de(this,At)}onEvent(e){switch(e.type){case"pointerdown":Ce(this,At,vn(e));break;case"pointermove":if(!te(this,At))return;const{x:t,y:n}=vn(e),r={x:t-te(this,At).x,y:n-te(this,At).y},{tolerance:i}=this.options;if(i&&ps(r,i)){this.abort();return}ps(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Ce(this,At,void 0)}};At=new WeakMap;var an,Rt,lh=class extends Ul{constructor(){super(...arguments),de(this,an),de(this,Rt)}onEvent(e){switch(e.type){case"pointerdown":Ce(this,Rt,vn(e)),Ce(this,an,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!te(this,Rt))return;const{x:t,y:n}=vn(e),r={x:t-te(this,Rt).x,y:n-te(this,Rt).y};ps(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){te(this,an)&&(clearTimeout(te(this,an)),Ce(this,Rt,void 0),Ce(this,an,void 0))}};an=new WeakMap;Rt=new WeakMap;var un=class{};un.Delay=lh;un.Distance=ah;var Ms=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&Ft(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new un.Delay({value:250,tolerance:5})]:yf(i)&&!e.defaultPrevented?[new un.Delay({value:200,tolerance:0})]:[new un.Delay({value:200,tolerance:10}),new un.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!Ft(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=zu(r);return i===t.element?!1:!!i}}),ln,vi=class extends gn{constructor(t,n){super(t),this.manager=t,this.options=n,de(this,ln,new Set),this.listeners=new uc,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:i}=this.latest;!r||!i||this.manager.actions.move({event:r,to:i})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:i=Ms.activationConstraints}=r??{};return typeof i=="function"?i(t,n):i}bind(t,n=this.options){return Qe(()=>{var i;const s=new AbortController,{signal:o}=s,a=d=>{mf(d)&&this.handlePointerDown(d,t,n)};let l=[(i=t.handle)!=null?i:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const d of l)d&&(uh(d.ownerDocument.defaultView),d.addEventListener("pointerdown",a,{signal:o}));return()=>s.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!Ft(t.target)||n.disabled||ch(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:i=Ms.preventActivation}=r??{};if(i?.(t,n))return;const{target:s}=t,o=Tt(s)&&s.draggable&&s.getAttribute("draggable")==="true",a=yn(n.element),{x:l,y:d}=vn(t);this.initialCoordinates={x:l*a.scaleX+a.x,y:d*a.scaleY+a.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const c=new Du(u,m=>this.handleStart(n,m));c.signal.onabort=()=>this.handleCancel(t),c.onEvent(t),this.controller=c;const h=ys(),f=this.listeners.bind(h,[{type:"pointermove",listener:m=>this.handlePointerMove(m,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Ar,options:{capture:!0}}]),g=()=>{f(),this.initialCoordinates=void 0};te(this,ln).add(g)}handlePointerMove(t,n){var r,i;if(((r=this.controller)==null?void 0:r.activated)===!1){(i=this.controller)==null||i.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const s=vn(t),o=yn(n.element);s.x=s.x*o.scaleX+o.x,s.y=s.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=s,di.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:i}=this;if(!i||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:i,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=Pn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const l=Ft(n.target)?[n.target,a]:a,d=this.listeners.bind(l,[{type:"touchmove",listener:Ar,options:{passive:!1}},{type:"click",listener:Ar},{type:"contextmenu",listener:Ar},{type:"keydown",listener:this.handleKeyDown}]);te(this,ln).add(d)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){const{controller:t}=this;this.controller=void 0,t&&!t.signal.aborted&&t.abort(),this.latest={event:void 0,coordinates:void 0},te(this,ln).forEach(n=>n()),te(this,ln).clear()}destroy(){this.cleanup(),this.listeners.clear()}};ln=new WeakMap;vi.configure=xr(vi);vi.defaults=Ms;var Is=vi;function ch(e){return"sensor"in e}function Ar(e){e.preventDefault()}function dh(){}var ba=new WeakSet;function uh(e){!e||ba.has(e)||(e.addEventListener("touchmove",dh,{capture:!1,passive:!1}),ba.add(e))}var hn={modifiers:[],plugins:[Rf,Gc,zf,Ao,oh],sensors:[Is,Vc]},Hc=class extends Mu{constructor(e={}){const t=it(e.plugins,hn.plugins),n=it(e.sensors,hn.sensors),r=it(e.modifiers,hn.modifiers);super(Co(pr({},e),{plugins:[ih,Sr,Ci,...t],sensors:n,modifiers:r}))}},Kc,qc,js,St,Wo,Fo,Mi=class extends(js=ct,qc=[K],Kc=[K],js){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=Sc(n,["element","effects","handle"]);super(pr({effects:()=>[...i(),()=>{var a,l;const{manager:d}=this;if(!d)return;const c=((l=(a=this.sensors)==null?void 0:a.map(cr))!=null?l:[...d.sensors]).map(h=>{const f=h instanceof gn?h:d.registry.register(h.plugin),g=h instanceof gn?void 0:h.options;return f.bind(this,g)});return function(){c.forEach(f=>f())}}]},o),t),de(this,Wo,pe(St,8,this)),pe(St,11,this),de(this,Fo,pe(St,12,this)),pe(St,15,this),this.element=r,this.handle=s}};St=Mn(js);Wo=new WeakMap;Fo=new WeakMap;Je(St,4,"handle",qc,Mi,Wo);Je(St,4,"element",Kc,Mi,Fo);Kt(St,Mi);var Uc,Xc,As,$t,Bo,qi,Yc,Zc,lr,No,Ii=class extends(As=dt,Xc=[K],Uc=[K],As){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=Sc(n,["element","effects"]);const{collisionDetector:o=xc}=s,a=d=>{const{manager:u,element:c}=this;if(!c||d===null){this.shape=void 0;return}if(!u)return;const h=new at(c),f=H(()=>this.shape);return h&&f?.equals(h)?f:(this.shape=h,h)},l=wn(!1);super(Co(pr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:d,manager:u}=this;if(!u)return;const{dragOperation:c}=u,{source:h}=c;l.value=!!(h&&c.status.initialized&&d&&!this.disabled&&this.accepts(h))},()=>{const{element:d}=this;if(l.value&&d){const u=new Uu(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),de(this,lr),de(this,Bo,pe($t,8,this)),pe($t,11,this),de(this,No,pe($t,12,this)),pe($t,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Ce(this,lr,e,Zc)}get element(){var e;return(e=this.proxy)!=null?e:te(this,lr,Yc)}};$t=Mn(As);Bo=new WeakMap;lr=new WeakSet;No=new WeakMap;qi=Je($t,20,"#element",Xc,lr,Bo),Yc=qi.get,Zc=qi.set;Je($t,4,"proxy",Uc,Ii,No);Kt($t,Ii);function fh(e){return e!=null&&typeof e=="object"&&"current"in e}function pn(e){var t;if(e!=null)return fh(e)?(t=e.current)!=null?t:void 0:e}var hh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",In=hh?S.useLayoutEffect:S.useEffect;function ph(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function Qc(e,t){const n=S.useRef(new Map),r=ph();return In(()=>{if(!e){n.current.clear();return}return Qe(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[l]=a,d=H(()=>a[1]),u=e[l];d!==u&&(s=!0,n.current.set(l,u),o=(i=t?.(l,d,u))!=null?i:!1)}s&&(o?queueMicrotask(()=>Wd.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 gh(e,t){e()}function Zt(e){const t=S.useRef(e);return In(()=>{t.current=e},[e]),t}function se(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 Jr(e,t){const n=S.useRef(pn(e));In(()=>{const r=pn(e);r!==n.current&&(n.current=r,t(r))})}var vh=Object.defineProperty,mh=Object.defineProperties,yh=Object.getOwnPropertyDescriptors,mi=Object.getOwnPropertySymbols,Jc=Object.prototype.hasOwnProperty,ed=Object.prototype.propertyIsEnumerable,xa=(e,t,n)=>t in e?vh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bh=(e,t)=>{for(var n in t||(t={}))Jc.call(t,n)&&xa(e,n,t[n]);if(mi)for(var n of mi(t))ed.call(t,n)&&xa(e,n,t[n]);return e},xh=(e,t)=>mh(e,yh(t)),_h=(e,t)=>{var n={};for(var r in e)Jc.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&&ed.call(e,r)&&(n[r]=e[r]);return n},wh=new Hc,td=S.createContext(wh),kh=S.memo(S.forwardRef(({children:e},t)=>{const[n,r]=S.useState(0),i=S.useRef(null),s=S.useRef(null),o=S.useMemo(()=>({renderer:{get rendering(){var a;return(a=i.current)!=null?a:Promise.resolve()}},trackRendering(a){i.current||(i.current=new Promise(l=>{s.current=l})),S.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return In(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),Ui=[void 0,nt];function Sh(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,d=_h(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=S.useRef(null),{plugins:c,modifiers:h,sensors:f}=d,g=it(c,hn.plugins),m=it(f,hn.sensors),w=it(h,hn.modifiers),b=Zt(i),v=Zt(s),p=Zt(a),x=Zt(o),_=Zt(l),O=Zt(r),T=$h(()=>{var E;return(E=d.manager)!=null?E:new Hc(d)});return S.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:E,trackRendering:I}=u.current,{monitor:D}=T;T.renderer=E;const L=[D.addEventListener("beforedragstart",M=>{const A=b.current;A&&I(()=>A(M,T))}),D.addEventListener("dragstart",M=>{var A;return(A=v.current)==null?void 0:A.call(v,M,T)}),D.addEventListener("dragover",M=>{const A=p.current;A&&I(()=>A(M,T))}),D.addEventListener("dragmove",M=>{const A=x.current;A&&I(()=>A(M,T))}),D.addEventListener("dragend",M=>{const A=_.current;A&&I(()=>A(M,T))}),D.addEventListener("collision",M=>{var A;return(A=O.current)==null?void 0:A.call(O,M,T)})];return()=>L.forEach(M=>M())},[T]),se(g,()=>T&&(T.plugins=g),...Ui),se(m,()=>T&&(T.sensors=m),...Ui),se(w,()=>T&&(T.modifiers=w),...Ui),y.jsxs(td.Provider,{value:T,children:[y.jsx(kh,{ref:u,children:n}),n]})}function $h(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 Oh(){return S.useContext(td)}function nd(e){var t;const n=(t=Oh())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),In(r.register,[n,r]),r}var Th=Object.create,rd=Object.defineProperty,Eh=Object.getOwnPropertyDescriptor,id=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ji=e=>{throw TypeError(e)},Dh=(e,t,n)=>t in e?rd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ph=e=>{var t;return[,,,Th((t=e?.[id("metadata")])!=null?t:null)]},sd=["class","method","getter","setter","accessor","field","value","get","set"],od=e=>e!==void 0&&typeof e!="function"?ji("Function expected"):e,Ch=(e,t,n,r,i)=>({kind:sd[e],name:t,metadata:r,addInitializer:s=>n._?ji("Already initialized"):i.push(od(s||null))}),Mh=(e,t)=>Dh(t,id("metadata"),e[3]),Ih=(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},ad=(e,t,n,r,i,s)=>{for(var o,a,l,d,u=t&7,c=!1,h=!1,f=2,g=sd[u+5],m=e[f]||(e[f]=[]),w=(i=i.prototype,Eh(i,n)),b=r.length-1;b>=0;b--)l=Ch(u,n,a={},e[3],m),l.static=c,l.private=h,d=l.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[b])(w[g],l),a._=1,od(o)&&(w[g]=o);return w&&rd(i,n,w),i},ld=(e,t,n)=>t.has(e)||ji("Cannot "+n),jh=(e,t,n)=>(ld(e,t,"read from private field"),t.get(e)),Ah=(e,t,n)=>t.has(e)?ji("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Rh=(e,t,n,r)=>(ld(e,t,"write to private field"),t.set(e,n),n),zt=class Rs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Rs(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 Rs(t,n)}},cd,dd,Ls,ei,$r,Go=class extends(Ls=Vt,dd=[ce],cd=[ce],Ls){constructor(e){const t=zt.from(e);super(t,(n,r)=>zt.equals(n,r)),Ih($r,5,this),Ah(this,ei,0),this.velocity={x:0,y:0}}get delta(){return zt.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=zt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-jh(this,ei),o=a=>Math.round(a/s*100);ae(()=>{Rh(this,ei,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(zt.from(e)),this.velocity={x:0,y:0}}};$r=Ph(Ls);ei=new WeakMap;ad($r,2,"delta",dd,Go);ad($r,2,"direction",cd,Go);Mh($r,Go);var ud=(e=>(e.Horizontal="x",e.Vertical="y",e))(ud||{});Object.values(ud);var Lh=({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=zt.distance(t.shape.center,n);return{id:r,value:1/i,type:Dn.PointerIntersection,priority:En.High}}return null},zh=({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=zt.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:Dn.ShapeIntersection,priority:En.Normal}}return null},Wh=e=>{var t;return(t=Lh(e))!=null?t:zh(e)};function Fh(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=nd(u=>new Ii(xh(bh({},e),{register:!1,element:pn(i)}),u)),d=Qc(l);return se(s,()=>l.id=s),Jr(i,u=>l.element=u),se(o,()=>l.accept=o,void 0,nt),se(t,()=>l.collisionDetector=t??Wh),se(n,()=>n&&(l.data=n)),se(r,()=>l.disabled=r===!0),se(a,()=>l.type=a),{droppable:d,get isDropTarget(){return d.isDropTarget},ref:S.useCallback(u=>{var c,h;!u&&((c=l.element)!=null&&c.isConnected)&&!((h=l.manager)!=null&&h.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}function Bh(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 yi(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Nh(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function ti(e,t){const n=Nh(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 _a(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 Gh(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Vh=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Hh(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",i=/^[A-Z_]/.test(r)?r:`F_${r}`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const wa=[{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 Rr(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 zs=e=>e.declaration.kind==="reference";function Kh(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}:yi(t.type)!==void 0?{op:yi(t.type)}:{}}})}function qh(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!zs(s))return;const o=(s.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function Uh(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 Xh(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 Yh=j.createSvgIcon(y.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),Zh=j.createSvgIcon(y.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"})),Qh=j.createSvgIcon(y.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"})),Jh=j.createSvgIcon(y.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"})),Ws=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),Xi=Ws?"⌘":"Ctrl+",ep=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function tp(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=Ws?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!ep(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!Ws&&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 np({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:l,onSettings:d}){const{theme:u}=Le.usePublisherTheme();return y.jsxs(j.DashboardBar,{left:y.jsx(k.Chip,{size:"medium",variant:"outlined",icon:y.jsx(Zh,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:u.border,color:u.tileTitle,"& .MuiChip-icon":{color:"inherit"},"& .MuiChip-label":{fontSize:"0.875rem"}}}),children:[l&&y.jsx(k.Button,{startIcon:y.jsx(j.AddIcon,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),y.jsx(k.Button,{startIcon:y.jsx(Yh,{}),onClick:c=>d(c.currentTarget),children:"Settings"}),y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(k.Tooltip,{title:`Undo (${Xi}Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:y.jsx(Jh,{fontSize:"small"})})})}),y.jsx(k.Tooltip,{title:`Redo (${Xi}⇧Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:y.jsx(Qh,{fontSize:"small"})})})}),o&&y.jsx(y.Fragment,{children:y.jsx(k.Tooltip,{title:i?`Save (${Xi}S)`:"",children:y.jsx("span",{children:y.jsx(k.Button,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,startIcon:!i&&!s?y.jsx(j.CheckIcon,{}):void 0,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&y.jsxs(y.Fragment,{children:[y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const rp=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Lr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function ka(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&rp.includes(n))return n}}const ip=1;function fd(e,t,n){const r=[];for(const i of e??[]){const s=i.name,o=i.kind;if(typeof s=="string"){if(o==="dimension"||o==="measure"){const a=i.type?.kind;r.push({name:t+s,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=i.schema?.fields;r.push(...fd(a,`${t}${s}.`,n-1))}}}return r}function sp(e){const t=new Map;for(const n of e.sourceInfos??[]){let r;try{r=typeof n=="string"?JSON.parse(n):n}catch{continue}const i=r;i?.name&&t.set(i.name,fd(i.schema?.fields,"",ip))}return t}function Sa(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const op=e=>(e??"").startsWith("dashboards/"),ap=e=>e.modelPath??e.path??"";function hd(e){const t=[],n=new Set;for(const r of e){const i=ap(r);if(op(i))continue;const s=sp(r);for(const o of r.sources??[]){const a=o.name;if(!a||n.has(a))continue;n.add(a);const l=(o.givens??[]).map(d=>d.name).filter(d=>typeof d=="string");t.push({name:a,modelPath:i,...Lr(o.annotations)?{description:Lr(o.annotations)}:{},views:(o.views??[]).filter(d=>typeof d.name=="string").map(d=>({name:d.name,...Lr(d.annotations)?{description:Lr(d.annotations)}:{},...ka(d.annotations)?{chart:ka(d.annotations)}:{}})),givens:l,fields:s.get(a)??[]})}}return{sources:t}}const ht=e=>`${e.source}.${e.name}`;function lp(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 cp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=Le.usePublisherTheme(),a=S.useMemo(()=>lp(t,n),[t,n]),[l,d]=S.useState(""),[u,c]=S.useState(""),[h,f]=S.useState(""),[g,m]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(d(t.sources[0]?.base??a[0]?.name??""),c(""),f(""),m(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(v=>v.name===l),b=l!==""&&u!=="";return y.jsx(j.AppDialog,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",disabled:!b,onClick:()=>s({base:l,view:u,...h.trim()?{label:h.trim()}:{},colspan:g}),children:"Add tile"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:a.length===0?y.jsx(k.Typography,{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."}):y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Source",value:l,onChange:v=>{d(v.target.value),c("")},inputProps:{"aria-label":"Source"},children:a.map(v=>y.jsxs(k.MenuItem,{value:v.name,children:[v.name,v.description&&y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:v.description})]},v.name))}),y.jsxs(k.Box,{children:[y.jsx(k.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(k.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(v=>y.jsxs(k.ListItemButton,{selected:u===v.name,onClick:()=>c(v.name),"aria-label":`View ${v.name}`,children:[y.jsx(k.ListItemText,{primary:v.name,secondary:v.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),v.chart&&y.jsx(k.Chip,{size:"small",variant:"outlined",label:v.chart.replace(/_chart$/,"")})]},v.name)),w&&w.views.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:h,onChange:v=>f(v.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),y.jsx(k.TextField,{size:"small",type:"number",label:`Width (of ${r})`,value:g,onChange:v=>m(Math.min(Math.max(Number(v.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const $a=4e3;function dp(e,t){const n=e.split(`
68
68
  `),r=t.split(`
69
- `);if(n.length>_a||r.length>_a)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 dp(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 up({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=Pe.usePublisherTheme(),o=S.useMemo(()=>e?dp(cp(t,n)):[],[e,t,n]),a=o.filter(d=>d.kind==="add").length,c=o.filter(d=>d.kind==="del").length;return y.jsx(j.AppDialog,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:y.jsxs(y.Fragment,{children:["A tile was added or removed, which moves declarations. Lines the builder does not own — comments, other Malloy — are left where they were; check they still read right."," ",y.jsxs(k.Box,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",c]})]}),actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Keep editing"}),y.jsx(k.Button,{variant:"contained",onClick:r,children:"Save this"})]}),children:y.jsx(k.Box,{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"?y.jsx(k.Box,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${d.count} unchanged line${d.count===1?"":"s"}`},u):y.jsxs(k.Box,{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))})})}const Bi="self";function fp({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Pe.usePublisherTheme(),[c,d]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(m=>m.source===n.name);d((n.dimensions??[]).map(m=>{const w=h.find(b=>b.name===m.name);return{name:m.name,expression:m.expression,to:w?.to??[],given:w?.given??""}}))},[e,n,t]);const u=(h,m)=>d(w=>w.map((b,v)=>{if(v!==h)return b;const p={...b};return m(p),p})),l=[Bi,...i.filter(h=>h!==Bi)],f=h=>h===Bi?"This dashboard":h,g=()=>{n&&(o(c.filter(h=>h.to.length>0).map(h=>({source:n.name,name:h.name,expression:h.expression,to:h.to,...h.given?{given:h.given}:{}}))),s())};return y.jsx(j.AppDialog,{open:e,onClose:s,title:"Clickable cells",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",onClick:g,disabled:c.length===0,children:"Apply"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:c.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(k.Box,{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"," ",y.jsx(k.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):c.map((h,m)=>y.jsxs(k.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(k.Box,{sx:{minWidth:0,pt:.75},children:[y.jsx(k.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:h.name}),y.jsxs(k.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.expression,children:["is ",h.expression]})]}),y.jsx(k.TextField,{select:!0,size:"small",label:"Clicks go to",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.length===0?"Not clickable":w.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:w=>u(m,b=>{const v=w.target.value;b.to=Array.isArray(v)?v:String(v).split(",").filter(Boolean)}),children:l.map(w=>y.jsxs(k.MenuItem,{value:w,children:[y.jsx(k.Checkbox,{size:"small",checked:h.to.includes(w),sx:{p:0,mr:1}}),y.jsx(k.ListItemText,{primary:f(w)})]},w))}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Sets the control",value:h.given,disabled:h.to.length===0,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:h.given===""?`Named ${h.name}, like the dimension`:void 0,onChange:w=>u(m,b=>{b.given=w.target.value}),children:[y.jsx(k.MenuItem,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(w=>y.jsx(k.MenuItem,{value:w,children:w},w))]})]},h.name))})})}const cd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function hp({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(""),[g,h]=S.useState("select"),[m,w]=S.useState(""),[b,v]=S.useState(""),[p,x]=S.useState([]),[_,$]=S.useState(!1),T=M=>t.sources.find(L=>L.name===M.source)?.base??M.source;S.useEffect(()=>{if(e)if(n){u({kind:"existing",name:n.name}),f(n.label??"");const M=Hh(t,n);x(M);const L=M.filter(E=>E.include),O=new Set(L.map(E=>E.field));v(O.size===1?L[0].field:n.field??""),$(O.size>1)}else u({kind:"new"}),f(""),h("select"),v(""),w(new Date().toISOString().slice(0,10)),x(t.tiles.map(M=>({include:Es(M),field:""}))),$(!1)},[e,n,t]);const D=S.useMemo(()=>[...(t.localGivens??[]).map(M=>M.name),...r.map(M=>M.name)],[t,r]),I=S.useMemo(()=>b.trim()?Vh(b.trim(),D):"",[b,D]),C=d.kind==="existing"?n??r.find(M=>M.name===d.name):I?{name:I,type:$r({name:I,label:l,kind:g,field:b}).type}:void 0,P=C?.type!==void 0&&!C.type.startsWith("filter<"),A=p.find(M=>M.include)?.op??ai(C?.type),R=(M,L)=>x(O=>O.map((E,z)=>z===M?{...E,...L}:E)),U=M=>x(L=>L.map(O=>({...O,op:M}))),Te=M=>{const L=ai(M);x(O=>O.map(({op:E,...z})=>L?{...z,op:L}:z))},De=M=>{u({kind:"existing",name:M.name}),v(M.field??""),Te(M.type)},me=M=>{h(M),Te($r({name:"X",label:l,kind:M,field:b}).type)},X=t.tiles.map(Es),Ye=X.filter(Boolean).length,Ze=p.filter((M,L)=>M.include&&X[L]).length,ye=t.tiles.filter((M,L)=>(p[L]?.include??!1)&&X[L]),Me=ye.length>0?ye:t.tiles.filter((M,L)=>X[L]),Ge=S.useMemo(()=>{const M=new Map;let L=!1;for(const O of Me){const E=i?.(O);if(E){L=!0;for(const z of E)M.has(z.name)||M.set(z.name,z)}}return L?[...M.values()]:void 0},[p,t.tiles,i]),Y=(()=>{const M=b.trim();for(const L of ye){const O=i?.(L);if(!O||O.some(E=>E.name===M))return T(L)}return ye[0]?T(ye[0]):t.sources[0]?.base})(),ee=M=>x(L=>L.map((O,E)=>({...O,include:M&&X[E]}))),H=S.useMemo(()=>_?p:p.map(M=>({...M,field:b})),[_,p,b]),he=M=>{for(const L of Me){const O=i?.(L)?.find(E=>E.name===M.trim());if(O?.type)return O.type}},W=M=>Vr(C?.type,M.type),K=(M,L)=>{if(M.trim()==="")return"Pick the field this filter compares.";const O=L?i?.(L):void 0;if(!O)return;const E=O.find(z=>z.name===M.trim());if(!E)return`Not a field of ${L?T(L):"the tiles' source"}.`;if(E.type&&!Vr(C?.type,E.type))return`${M.trim()} is ${ma(E.type)}; this filter compares ${ma(C?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},_e=M=>{if(v(M),c||d.kind!=="new")return;const L=he(M),O=$r({name:"X",label:l,kind:g,field:M}).type;L&&!Vr(O,L)&&me(Nh(L))},ne=H.map((M,L)=>M.include&&X[L]?K(M.field,t.tiles[L]):void 0),Ve=ne.every(M=>M===void 0),re=!_&&Ze>0?ye.map(M=>K(b,M)).find(Boolean):void 0,ft=C!==void 0&&Ve&&(d.kind==="existing"||b.trim()!==""&&I!==""),Je=()=>{if(!(!C||!ft))if(d.kind==="new")s(C.name,H,$r({name:C.name,label:l.trim()||cd(C.name),kind:g,field:b.trim(),...Y?{source:Y}:{},...m?{dateDefault:m}:{}}));else if(n?.origin==="dashboard"&&n.local){const M=l.trim(),L=M!==(n.local.label??"");s(C.name,H,L?{...n.local,...M?{label:M}:{}}:void 0)}else s(C.name,H)},Nt=c&&a.origin==="model";return{editing:c,shown:a,fromModel:Nt,source:d,setSource:u,label:l,setLabel:f,kind:g,dateDefault:m,setDateDefault:w,field:b,rows:p,setRows:x,perTile:_,setPerTile:$,newName:I,target:C,valueTyped:P,commonOp:A,setRow:R,setCommonOp:U,pickExisting:De,pickKind:me,bindable:X,bindableCount:Ye,included:Ze,commonFields:Ge,setAll:ee,accepts:W,pickField:_e,rowProblems:ne,commonProblem:re,canApply:ft,apply:Je}}function wa({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(h=>r?.(h)??!0).map(h=>h.name),[n,r]),g=S.useMemo(()=>new Map((n??[]).map(h=>[h.name,h.type])),[n]);return y.jsx(k.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(h,m)=>t(m),value:e,onChange:(h,m)=>t(typeof m=="string"?m:""),disabled:c,disableClearable:!0,renderOption:(h,m)=>S.createElement("li",{...h,key:m},y.jsx(k.Typography,{variant:"body2",sx:{flex:1},children:m}),g.get(m)&&y.jsx(k.Typography,{variant:"caption",sx:{opacity:.6},children:g.get(m)?.replace(/_type$/,"")})),renderInput:h=>y.jsx(k.TextField,{...h,label:i,placeholder:u,autoFocus:d,error:o,helperText:a,inputProps:{...h.inputProps,"aria-label":s}}),sx:l})}function pp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:c}=Pe.usePublisherTheme(),{editing:d,shown:u,fromModel:l,source:f,setSource:g,label:h,setLabel:m,kind:w,dateDefault:b,setDateDefault:v,field:p,rows:x,setRows:_,perTile:$,setPerTile:T,newName:D,target:I,valueTyped:C,commonOp:P,setRow:A,setCommonOp:R,pickExisting:U,pickKind:Te,bindable:De,bindableCount:me,included:X,commonFields:Ye,setAll:Ze,accepts:ye,pickField:Me,rowProblems:Ge,commonProblem:Y,canApply:ee,apply:H}=hp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),he=(W,K,_e)=>y.jsx(k.TextField,{select:!0,size:"small",label:"Compares",value:W??">=",onChange:ne=>K(ne.target.value),inputProps:{"aria-label":_e},sx:{width:130},children:Gh.filter(ne=>ne.op!=="~").map(ne=>y.jsx(k.MenuItem,{value:ne.op,children:ne.label},ne.op))});return y.jsx(j.AppDialog,{open:e,onClose:s,title:d?u.label??u.name:"Add a filter",description:d?y.jsxs(y.Fragment,{children:[y.jsxs(k.Box,{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"]}):"A control on the page, and the tiles it filters.",actions:y.jsxs(y.Fragment,{children:[d&&y.jsx(k.Button,{color:"error",onClick:()=>a(u.name),"aria-label":`Remove control ${u.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Tooltip,{title:ee||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(k.Button,{variant:"contained",onClick:H,disabled:!ee,children:d?"Apply":"Add filter"})})})]}),children:y.jsxs(k.Stack,{sx:{gap:2.5,pt:1},children:[!d&&r.length>0&&y.jsxs(k.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:(W,K)=>{K==="new"?g({kind:"new"}):K==="existing"&&r[0]&&U(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(k.ToggleButton,{value:"new",children:"New in this dashboard"}),y.jsx(k.ToggleButton,{value:"existing",children:"From the model"})]}),!d&&f.kind==="existing"?y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:f.name,onChange:W=>{const K=r.find(_e=>_e.name===W.target.value);K&&U(K)},children:r.map(W=>y.jsxs(k.MenuItem,{value:W.name,children:[W.label??W.name,y.jsxs(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",W.name]})]},W.name))}):null,y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!$&&y.jsx(wa,{value:p,onChange:Me,fields:Ye,accepts:ye,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!d,error:Y!==void 0,helperText:Y??(!d&&D?`Declared as $${D}`:void 0),sx:{flex:1,minWidth:200}}),!l&&y.jsx(k.TextField,{size:"small",label:"Label",placeholder:D?cd(D):"",value:h,onChange:W=>m(W.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),C&&!$&&he(P,R,"Comparison")]}),!d&&f.kind==="new"&&y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:w,onChange:W=>Te(W.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:W=>ya.find(K=>K.kind===W)?.label??String(W)}},sx:{flex:1},children:ya.map(W=>y.jsxs(k.MenuItem,{value:W.kind,children:[W.label,y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:W.hint})]},W.kind))}),w==="date"&&y.jsx(k.TextField,{size:"small",type:"date",label:"Starts at",value:b,onChange:W=>v(W.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(k.Box,{children:[y.jsxs(k.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(k.Checkbox,{size:"small",checked:me>0&&X===me,indeterminate:X>0&&X<me,disabled:me===0,onChange:W=>Ze(W.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(k.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",X," of ",t.tiles.length," tiles"]}),y.jsx(k.Button,{size:"small",onClick:()=>{$||_(W=>W.map(K=>({...K,field:p}))),T(W=>!W)},children:$?"Same field for all":"Adjust per tile"})]}),y.jsx(k.Stack,{sx:{gap:$?1:0},children:t.tiles.map((W,K)=>{const _e=x[K],ne=W.label??W.name,Ve=$?Ge[K]:void 0;return y.jsxs(k.Stack,{direction:"row",sx:{gap:1,alignItems:$?"flex-start":"center",opacity:De[K]?1:.6},children:[y.jsx(k.Checkbox,{size:"small",disabled:!De[K],checked:(_e?.include??!1)&&De[K],inputProps:{"aria-label":`Filter ${ne}`},onChange:re=>A(K,{include:re.target.checked})}),y.jsx(k.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:$?1:0},noWrap:!0,children:ne}),De[K]?$&&y.jsxs(y.Fragment,{children:[C&&he(_e?.op,re=>A(K,{op:re}),`Comparison for ${ne}`),y.jsx(wa,{value:_e?.field??"",onChange:re=>A(K,{field:re}),fields:i?.(W),accepts:ye,label:"Field",ariaLabel:`Field for ${ne}`,disabled:!_e?.include,error:Ve!==void 0,helperText:Ve,sx:{width:220}})]}):y.jsx(k.Tooltip,{title:W.declaration.kind==="inherited"?"Declared on its source, which this dashboard does not write.":"Its query is written out here rather than named, so a filter cannot be added to it.",children:y.jsx(k.Typography,{variant:"caption",sx:{color:c.tileTitle},children:W.declaration.kind==="inherited"?"From the model":"Inline query"})})]},`${W.source}.${W.name}`)})}),X===0&&y.jsx(k.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}function dd(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:d=>s(u=>{if(u===void 0)return u;const l=structuredClone(u);return d(l),l}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const gp=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}}),Ni=[2,3,4,6,8,12,16,24];function vp({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=Pe.usePublisherTheme(),{draft:s,patch:o,close:a}=dd(t,e!==null,r,n),c=s?.columns!==void 0&&!Ni.includes(s.columns)?[...Ni,s.columns].sort((d,u)=>d-u):Ni;return y.jsx(k.Popover,{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&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsx(k.Typography,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),y.jsx(k.TextField,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:d=>o(u=>{u.title=d.target.value})}),y.jsx(k.TextField,{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})}),y.jsxs(k.TextField,{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:[y.jsx(k.MenuItem,{value:"",children:"Default (2)"}),c.map(d=>y.jsx(k.MenuItem,{value:d,children:d},d))]}),y.jsx(k.FormControlLabel,{control:y.jsx(k.Switch,{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:y.jsxs(k.Typography,{variant:"body2",children:["Run as controls change",y.jsx(k.Typography,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const mp=j.createSvgIcon(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function yp({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=Pe.usePublisherTheme();return y.jsx(y.Fragment,{children:y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsxs(k.Stack,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[y.jsx(mp,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),y.jsx(k.Typography,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const c=n(a.name,a.type);return y.jsx(k.Tooltip,{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:y.jsx(k.Chip,{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)}),y.jsx(k.Box,{sx:{ml:"auto"},children:y.jsx(j.SecondaryButton,{label:"Filter",icon:y.jsx(j.AddIcon,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const bp=(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}),xp=(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},ud=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),fd=e=>`gap.${e}`,_p=(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:ot(e[o-1]),colspan:t-r}),c&&(r=0),n.push(ud(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:ot(i),colspan:t-r}),n};var wp=Object.create,hd=Object.defineProperty,kp=Object.defineProperties,Sp=Object.getOwnPropertyDescriptor,$p=Object.getOwnPropertyDescriptors,li=Object.getOwnPropertySymbols,pd=Object.prototype.hasOwnProperty,gd=Object.prototype.propertyIsEnumerable,Op=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),yr=e=>{throw TypeError(e)},Ms=(e,t,n)=>t in e?hd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gi=(e,t)=>{for(var n in t||(t={}))pd.call(t,n)&&Ms(e,n,t[n]);if(li)for(var n of li(t))gd.call(t,n)&&Ms(e,n,t[n]);return e},Vi=(e,t)=>kp(e,$p(t)),Tp=(e,t)=>{var n={};for(var r in e)pd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&li)for(var r of li(e))t.indexOf(r)<0&&gd.call(e,r)&&(n[r]=e[r]);return n},Dp=e=>{var t;return[,,,wp((t=void 0)!=null?t:null)]},vd=["class","method","getter","setter","accessor","field","value","get","set"],Vn=e=>e!==void 0&&typeof e!="function"?yr("Function expected"):e,Ep=(e,t,n,r,i)=>({kind:vd[e],name:t,metadata:r,addInitializer:s=>n._?yr("Already initialized"):i.push(Vn(s||null))}),Pp=(e,t)=>Ms(t,Op("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},md=(e,t,n,r,i,s)=>{for(var o,a,c,d,u,l=t&7,f=!1,g=!1,h=e.length+1,m=vd[l+5],w=e[h-1]=[],b=e[h]||(e[h]=[]),v=(i=i.prototype,Sp({get[n](){return Hn(this,s)},set[n](x){return Ct(this,s,x)}},n)),p=r.length-1;p>=0;p--)d=Ep(l,n,c={},e[3],b),d.static=f,d.private=g,u=d.access={has:x=>n in x},u.get=x=>x[n],u.set=(x,_)=>x[n]=_,a=(0,r[p])({get:v.get,set:v.set},d),c._=1,a===void 0?Vn(a)&&(v[m]=a):typeof a!="object"||a===null?yr("Object expected"):(Vn(o=a.get)&&(v.get=o),Vn(o=a.set)&&(v.set=o),Vn(o=a.init)&&w.unshift(o));return v&&hd(i,n,v),i},yd=(e,t,n)=>t.has(e)||yr("Cannot "+n),Hn=(e,t,n)=>(yd(e,t,"read from private field"),t.get(e)),Mn=(e,t,n)=>t.has(e)?yr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ct=(e,t,n,r)=>(yd(e,t,"write to private field"),t.set(e,n),n);function jt(e){return e instanceof Lo||e instanceof wd}var Dr=10,Mp=class extends xe{constructor(e){super(e);const t=Be(()=>{const{dragOperation:r}=e;if(sr(r.activatorEvent)&&jt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(vr);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(!sr(r.nativeEvent)||!jt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:c}=i,{by:d}=r;if(!d)return;const u=Cp(d),{source:l,target:f}=s,{center:g}=s.shape.current,h=[],m=[];oe(()=>{for(const _ of c.droppables){const{id:$}=_;if(!_.accepts(l)||$===f?.id&&jt(_)||!_.element)continue;let T=_.shape;const D=new et(_.element,{getBoundingClientRect:I=>rr(I,void 0,.2)});!D.height||!D.width||(u=="down"&&g.y+Dr<D.center.y||u=="up"&&g.y-Dr>D.center.y||u=="left"&&g.x-Dr>D.center.x||u=="right"&&g.x+Dr<D.center.x)&&(h.push(_),_.shape=D,m.push(()=>_.shape=T))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(h,xf);oe(()=>m.forEach(_=>_()));const[b]=w;if(!b)return;const{id:v}=b,{index:p,group:x}=l.sortable;o.setDropTarget(v).then(()=>{const{source:_,target:$,shape:T}=s;if(!_||!jt(_)||!T)return;const{index:D,group:I,target:C}=_.sortable,P=p!==D||x!==I,A=P?C:$?.element;if(!A)return;hc(A);const R=new et(A);if(!R)return;const U=tt.delta(R,tt.from(T.current.boundingRectangle),_.alignment);o.move({by:U}),P?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Cp(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 Ip=Object.defineProperty,jp=Object.defineProperties,Ap=Object.getOwnPropertyDescriptors,ka=Object.getOwnPropertySymbols,Rp=Object.prototype.hasOwnProperty,Lp=Object.prototype.propertyIsEnumerable,Sa=(e,t,n)=>t in e?Ip(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kt=(e,t)=>{for(var n in t||(t={}))Rp.call(t,n)&&Sa(e,n,t[n]);if(ka)for(var n of ka(t))Lp.call(t,n)&&Sa(e,n,t[n]);return e},qt=(e,t)=>jp(e,Ap(t));function zp(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Er(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function Hi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Wp(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=(p,x)=>p===x||p!==null&&typeof p=="object"&&"id"in p&&p.id===x;if(Array.isArray(e)){const p=e.findIndex(_=>c(_,s.id)),x=e.findIndex(_=>c(_,o.id));if(p===-1||x===-1){if(Hi(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,x)}const d=Object.entries(e);let u=-1,l,f=-1,g;for(const[p,x]of d)if(u===-1&&(u=x.findIndex(_=>c(_,s.id)),u!==-1&&(l=p)),f===-1&&(f=x.findIndex(_=>c(_,o.id)),f!==-1&&(g=p)),u!==-1&&f!==-1)break;if(u===-1&&Hi(s)){const p=s.initialGroup==null?void 0:Er(e,s.initialGroup),x=s.initialIndex,_=s.group==null?void 0:Er(e,s.group),$=s.index;if(p==null||_==null||p===_&&x===$)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return qt(Kt({},e),{[p]:n(e[p],x,$)});const T=e[p][x];return qt(Kt({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[_]:[...e[_].slice(0,$),T,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:h}=s.manager,m=(i=(r=h.shape)==null?void 0:r.current.center)!=null?i:h.position.current;if(g==null){const p=Er(e,o.id);if(p!=null){const x=o.shape&&m.y>o.shape.center.y?e[p].length:0;g=p,f=x}}if(l==null||g==null||l===g&&u===f){if(l!=null&&l===g&&u===f&&Hi(s)){const p=s.group==null?void 0:Er(e,s.group),x=s.group!=null&&p!==l,_=s.index!==u;if(x||_){const $=s.group==null?l:p;if($!=null){if(l===$)return qt(Kt({},e),{[l]:n(e[l],u,s.index)});const T=e[l][u];return qt(Kt({},e),{[l]:[...e[l].slice(0,u),...e[l].slice(u+1)],[$]:[...e[$].slice(0,s.index),T,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(l===g)return qt(Kt({},e),{[l]:n(e[l],u,f)});const b=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[l][u];return qt(Kt({},e),{[l]:[...e[l].slice(0,u),...e[l].slice(u+1)],[g]:[...e[g].slice(0,f+b),v,...e[g].slice(f+b)]})}function Fp(e,t){return Wp(e,t,zp)}function $a(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Oa(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 Ta="__default__",Bp=class extends xe{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof Lo){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(!jt(o)||!jt(a)||o.sortable===a.sortable)return;const c=t(),d=$a(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 g,h;const m=t();if(Oa(d,c,m))return;const w=o.sortable.element,b=a.sortable.element;if(!b||!w||!u&&a.id===o.sortable.group)return;const v=Pr(l),p=u?v:Pr(f),x=(g=o.sortable.group)!=null?g:Ta,_=(h=a.sortable.group)!=null?h:Ta,$={[x]:v,[_]:p},T=Fp($,r);if($===T)return;const D=T[_].indexOf(o.sortable),I=T[_].indexOf(a.sortable);i.collisionObserver.disable(),Da(w,D,b,I),oe(()=>{for(const[C,P]of T[x].entries())P.index=C;if(!u)for(const[C,P]of T[_].entries())P.group=a.sortable.group,P.index=C}),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;jt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),c=$a(a),d=a.get(o.sortable.initialGroup);d&&i.renderer.rendering.then(()=>{const u=t();if(Oa(c,a,u))return;const l=Pr(d),f=Pr(d,Gp),g=o.sortable.element,h=f.indexOf(o.sortable),m=l[h],w=m?.element;!m||!w||!g||(Da(g,m.index,w,o.index),oe(()=>{for(const b of a.values()){const v=Array.from(b).values();for(const p of v)p.index=p.initialIndex,p.group=p.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Da(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function Np(e,t){return e.index-t.index}function Gp(e,t){return e.initialIndex-t.initialIndex}function Pr(e,t=Np){return Array.from(e).sort(t)}var Ea=[Mp,Bp],bd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function Pa(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 Mr=new nu,xd,_d,xt,Ao,Kn,qn,Ro,nn;_d=[G],xd=[G];var Si=class{constructor(e,t){Mn(this,Ao,Tr(xt,8,this)),Tr(xt,11,this),Mn(this,Kn),Mn(this,qn),Mn(this,Ro,Tr(xt,12,this)),Tr(xt,15,this),Mn(this,nn),this.register=()=>(oe(()=>{var h,m;(h=this.manager)==null||h.registry.register(this.droppable),(m=this.manager)==null||m.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{oe(()=>{var h,m;(h=this.manager)==null||h.registry.unregister(this.droppable),(m=this.manager)==null||m.registry.unregister(this.draggable)})},this.destroy=()=>{oe(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:c,transition:d=bd,plugins:u}=n,l=Tp(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=Ue(u,Ea),g=Pa(i);this.droppable=new Lo(Vi(Gi({},l),{disabled:g.droppable}),t,this),this.draggable=new wd(Vi(Gi({},l),{disabled:g.draggable,plugins:f,effects:()=>[()=>{var h,m,w;const b=(h=this.manager)==null?void 0:h.dragOperation.status;b?.initializing&&this.id===((w=(m=this.manager)==null?void 0:m.dragOperation.source)==null?void 0:w.id)&&Mr.clear(this.manager),b?.dragging&&Mr.set(this.manager,this.id,N(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:h,group:m,manager:w}=this,b=Hn(this,qn),v=Hn(this,Kn);(h!==b||m!==v)&&(Ct(this,qn,h),Ct(this,Kn,m),this.animate())},()=>{var h,m;const{target:w}=this,{isDragSource:b}=this.draggable;((m=(h=this.draggable.pluginConfig(Oo))==null?void 0:h.feedback)!=null?m:"default")==="move"&&b&&(this.droppable.disabled=!w)},...r()],type:c,sensors:a}),t,this),Ct(this,nn,l.element),this.manager=t,this.index=o,Ct(this,qn,o),this.group=s,Ct(this,Kn,s),this.type=c,this.transition=d}get initialIndex(){var e,t;return(t=(e=Mr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Mr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){N(()=>{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}=it(i),c=aa(i,a,!1),d=aa(i,a);if(o.x||o.y){const u=yo(Re(i))?Vi(Gi({},t),{duration:0}):t;pc({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){oe(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){oe(()=>{const t=Hn(this,nn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Ct(this,nn,e)})}get element(){var e,t;const n=Hn(this,nn);if(n)return(t=(e=ds.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=Ue(e,Ea)}set disabled(e){const t=Pa(e);oe(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){oe(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??gc}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){oe(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};xt=Dp();Ao=new WeakMap;Kn=new WeakMap;qn=new WeakMap;Ro=new WeakMap;nn=new WeakMap;md(xt,4,"index",_d,Si,Ao);md(xt,4,"group",xd,Si,Ro);Pp(xt,Si);var wd=class extends _i{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}},Lo=class extends wi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Vp=Object.defineProperty,Hp=Object.defineProperties,Kp=Object.getOwnPropertyDescriptors,Ma=Object.getOwnPropertySymbols,qp=Object.prototype.hasOwnProperty,Up=Object.prototype.propertyIsEnumerable,Ca=(e,t,n)=>t in e?Vp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ki=(e,t)=>{for(var n in t||(t={}))qp.call(t,n)&&Ca(e,n,t[n]);if(Ma)for(var n of Ma(t))Up.call(t,n)&&Ca(e,n,t[n]);return e},Xp=(e,t)=>Hp(e,Kp(t));function Yp(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:g,type:h,plugins:m}=e,w=Ki(Ki({},bd),e.transition),b=Zc(p=>new Si(Xp(Ki({},e),{transition:w,register:!1,handle:ln(a),element:ln(o),target:ln(g)}),p)),v=qc(b,Zp);return ie(i,()=>b.id=i),Tn(()=>{oe(()=>{b.group=d,b.index=c})},[b,d,c]),ie(h,()=>b.type=h),ie(t,()=>b.accept=t,void 0,Ke),ie(s,()=>s&&(b.data=s)),ie(c,()=>{var p;(p=b.manager)!=null&&p.dragOperation.status.idle&&w?.idle&&b.refreshShape()},ph),Nr(a,p=>b.handle=p),Nr(o,p=>b.element=p),Nr(g,p=>b.target=p),ie(u,()=>b.disabled=u??!1,void 0,Ke),ie(f,()=>b.sensors=f,void 0,Ke),ie(n,()=>b.collisionDetector=n),ie(r,()=>b.collisionPriority=r),ie(m,()=>b.plugins=m,void 0,Ke),ie(w,()=>b.transition=w,void 0,Ke),ie(l,()=>b.modifiers=l,void 0,Ke),ie(e.alignment,()=>b.alignment=e.alignment),{sortable:v,get isDragging(){return v.isDragging},get isDropping(){return v.isDropping},get isDragSource(){return v.isDragSource},get isDropTarget(){return v.isDropTarget},handleRef:S.useCallback(p=>{b.handle=p??void 0},[b]),ref:S.useCallback(p=>{var x,_;!p&&((x=b.element)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.element=p??void 0)},[b]),sourceRef:S.useCallback(p=>{var x,_;!p&&((x=b.source)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.source=p??void 0)},[b]),targetRef:S.useCallback(p=>{var x,_;!p&&((x=b.target)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.target=p??void 0)},[b])}}function Zp(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Cs="tile",kd="gap",Jp='[role="separator"]',Qp=[Ss.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Ss.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(Jp)!==null}),Wc],eg=e=>[...e,Oo.configure({feedback:"clone"})];function tg({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=Yp({id:e,index:t,type:Cs,accept:Cs,collisionDetector:xo,plugins:eg});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function ng({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=Wh({id:e,type:kd,accept:Cs,collisionDetector:xo,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const rg=j.createSvgIcon(y.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"})),ig=j.createSvgIcon(y.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 sg({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}=Pe.usePublisherTheme();return y.jsx(tg,{id:ot(e),index:t,children:({ref:g,handleRef:h,isDragSource:m})=>y.jsxs(k.Box,{ref:g,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,y.jsx(k.Box,{ref:h,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:m||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${f.drillLink}`,outlineOffset:1}},children:y.jsx(rg,{sx:{fontSize:16}})}),i===void 0&&y.jsx(k.IconButton,{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:y.jsx(ig,{sx:{fontSize:16}})}),i!==void 0&&y.jsxs(k.Box,{"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"&&y.jsx(k.Box,{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 og({tile:e}){const{theme:t}=Pe.usePublisherTheme();return y.jsxs(j.TileCard,{sx:{minHeight:140},children:[y.jsx(j.TileHeading,{title:e.label??e.name,subtitle:e.subtitle}),y.jsxs(k.Typography,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function ag({after:e}){const{theme:t}=Pe.usePublisherTheme();return y.jsx(ng,{id:fd(e),after:e,children:({ref:n,isDropTarget:r})=>y.jsx(k.Box,{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 lg({columns:e}){const{theme:t}=Pe.usePublisherTheme();return y.jsx(k.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${j.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>y.jsx(k.Box,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var cg=Object.defineProperty,dg=Object.defineProperties,ug=Object.getOwnPropertyDescriptors,Ia=Object.getOwnPropertySymbols,fg=Object.prototype.hasOwnProperty,hg=Object.prototype.propertyIsEnumerable,ja=(e,t,n)=>t in e?cg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ut=(e,t)=>{for(var n in t||(t={}))fg.call(t,n)&&ja(e,n,t[n]);if(Ia)for(var n of Ia(t))hg.call(t,n)&&ja(e,n,t[n]);return e},Xt=(e,t)=>dg(e,ug(t));function pg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Cr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function qi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function gg(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=(p,x)=>p===x||p!==null&&typeof p=="object"&&"id"in p&&p.id===x;if(Array.isArray(e)){const p=e.findIndex(_=>c(_,s.id)),x=e.findIndex(_=>c(_,o.id));if(p===-1||x===-1){if(qi(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,x)}const d=Object.entries(e);let u=-1,l,f=-1,g;for(const[p,x]of d)if(u===-1&&(u=x.findIndex(_=>c(_,s.id)),u!==-1&&(l=p)),f===-1&&(f=x.findIndex(_=>c(_,o.id)),f!==-1&&(g=p)),u!==-1&&f!==-1)break;if(u===-1&&qi(s)){const p=s.initialGroup==null?void 0:Cr(e,s.initialGroup),x=s.initialIndex,_=s.group==null?void 0:Cr(e,s.group),$=s.index;if(p==null||_==null||p===_&&x===$)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return Xt(Ut({},e),{[p]:n(e[p],x,$)});const T=e[p][x];return Xt(Ut({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[_]:[...e[_].slice(0,$),T,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:h}=s.manager,m=(i=(r=h.shape)==null?void 0:r.current.center)!=null?i:h.position.current;if(g==null){const p=Cr(e,o.id);if(p!=null){const x=o.shape&&m.y>o.shape.center.y?e[p].length:0;g=p,f=x}}if(l==null||g==null||l===g&&u===f){if(l!=null&&l===g&&u===f&&qi(s)){const p=s.group==null?void 0:Cr(e,s.group),x=s.group!=null&&p!==l,_=s.index!==u;if(x||_){const $=s.group==null?l:p;if($!=null){if(l===$)return Xt(Ut({},e),{[l]:n(e[l],u,s.index)});const T=e[l][u];return Xt(Ut({},e),{[l]:[...e[l].slice(0,u),...e[l].slice(u+1)],[$]:[...e[$].slice(0,s.index),T,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(l===g)return Xt(Ut({},e),{[l]:n(e[l],u,f)});const b=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[l][u];return Xt(Ut({},e),{[l]:[...e[l].slice(0,u),...e[l].slice(u+1)],[g]:[...e[g].slice(0,f+b),v,...e[g].slice(f+b)]})}function vg(e,t){return gg(e,t,pg)}function mg({tiles:e,commit:t,onLanded:n}){const[r,i]=S.useState(void 0),s=S.useRef(void 0),[o,a]=S.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),s.current=e},onDragOver:l=>{const{source:f,target:g}=l.operation;if(!f||!g)return;const h=s.current??e;let m;if(g.type===kd){const{after:w}=g.data,b=h.findIndex(x=>ot(x)===f.id);if(b<0||w===f.id)return;const p=h.filter((x,_)=>_!==b).findIndex(x=>ot(x)===w)+1;m=xp(h,b,p)}else{const w=h.map(ot),b=vg(w,l);if(b.every((p,x)=>p===w[x]))return;const v=new Map(h.map(p=>[ot(p),p]));m=bp(b.map(p=>v.get(p)),e.map(p=>p.break??!1))}s.current=m,i(m)},onDragEnd:l=>{a(!1);const f=s.current;if(s.current=void 0,i(void 0),l.canceled||!f)return;t(f);const g=f.findIndex(h=>ot(h)===l.operation.source?.id);g>=0&&n(g)}}}const Aa=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function yg({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:(u,l)=>{const f=o.current?.getBoundingClientRect(),g=u.currentTarget.parentElement?.getBoundingClientRect();!f||!g||(u.stopPropagation(),u.preventDefault(),u.currentTarget.setPointerCapture(u.pointerId),Aa(!0),n(l),s({index:l,span:e[l]?.colspan??1,left:g.left,track:(f.width-j.GRID_GAP_PX*(t-1))/t}))},onResize:u=>{if(!i)return;const l=u.clientX-i.left,f=Math.round((l+j.GRID_GAP_PX)/(i.track+j.GRID_GAP_PX)),g=Math.min(Math.max(f,1),t);g!==i.span&&s({...i,span:g})},endResize:u=>{if(u.currentTarget.hasPointerCapture(u.pointerId)&&u.currentTarget.releasePointerCapture(u.pointerId),Aa(!1),!i)return;const{index:l,span:f}=i;s(void 0),r(l,f)}}}function bg({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=Pe.usePublisherTheme(),{draft:c,patch:d,close:u,discard:l}=dd(t,e!==null,r,n),f=c!==void 0&&c.declaration.kind!=="inherited";return y.jsx(k.Popover,{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&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsxs(k.Typography,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[c.source," → ",c.name]}),f?y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{size:"small",label:"Title",value:c.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:g=>d(h=>{const m=g.target.value;m===""?delete h.label:h.label=m})}),y.jsx(k.TextField,{size:"small",label:"Subtitle",value:c.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:g=>d(h=>{const m=g.target.value;m===""?delete h.subtitle:h.subtitle=m})}),y.jsxs(k.Stack,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[y.jsx(k.Typography,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([g,h])=>{const m=Math.max(1,Math.round(s/h)),w=(c.colspan??1)===m;return y.jsx(k.Button,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${g}`,"aria-pressed":w,onClick:()=>d(b=>{b.colspan=m}),sx:{minWidth:40,px:1},children:g},g)})]})]}):y.jsx(k.Typography,{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."}),y.jsx(k.Divider,{}),y.jsxs(k.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[f?y.jsx(k.Button,{size:"small",onClick:()=>{u(),o()},children:"Clickable cells…"}):y.jsx("span",{}),y.jsx(k.Button,{color:"error",size:"small",onClick:()=>{l(),i()},children:"Remove tile"})]})]})})}const ci=e=>e.ok===!1;function Lt(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 Is=e=>e.map(t=>t.text);function xg(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(`
70
- `):void 0,artifact:n}}function _g(e,t){return new RegExp(`source:\\s*${t}\\s+is\\s+([A-Za-z_][A-Za-z0-9_.]*)`).exec(e)?.[1]}function wg(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 Sd=/where:\s*([A-Za-z_][A-Za-z0-9_.]*)\s*(~|>=|<=|!=|=|>|<)\s*\$([A-Za-z_][A-Za-z0-9_]*)/g;function kg(e){if(!e)return;const t=[];for(const n of e.matchAll(Sd))t.push({field:n[1],given:n[3],...n[2]==="~"?{}:{op:n[2]}});return t.length>0?t:void 0}function Sg(e,t){const n=[];for(const r of j.givenDeclarations(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(),...$g(t(Is(Lt(e,r.line).tags)).tag)})}return n.length>0?n:void 0}function $g(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 Og(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(s=>s[1])}async function di(e){const{Malloy:t}=await import("@malloydata/malloy"),{parseAnnotation:n}=await import("@malloydata/malloy-tag"),r=e.split(`
71
- `);let i;try{i=t.parse({source:e}).symbols}catch(x){return{ok:!1,reason:`This file is not valid Malloy: ${x}`}}const{description:s,artifact:o}=xg(r),a=o.find(x=>x.includes("artifact"));if(a===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};const c=n([a.replace(/^##\s*/,"# ")]).tag,d=c?.tag("artifact"),u=Og(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=[],g=[],h=new Map;for(const x of i){if(x.type==="import"){const C=(x.children??[]).filter(P=>P.type==="import_item").map(P=>String(P.name));l.push(C.length>0?{kind:"names",names:C,from:String(x.name)}:{kind:"all",from:String(x.name)});continue}if(x.type!=="explore")continue;const _=String(x.name),$=r[x.range.start.line]??"",T=_g($,_);if(T===void 0)return{ok:!1,reason:`Could not read what source \`${_}\` extends.`,line:x.range.start.line+1};f.push({name:_,base:T});const D=j.declarationsUnder(r,_,"view"),I=j.declarationsUnder(r,_,"dimension");I.size>0&&(f[f.length-1].dimensions=[...I].map(([C,P])=>({name:C,expression:P.rest})));for(const[C,P]of I){const{tags:A}=Lt(r,P.line),R=n(Is(A)).tag?.tag("drill");if(!R)continue;const U=R.textArray("to")??[R.text("to")??""];g.push({source:_,name:C,expression:P.rest,to:U.filter(Boolean),...R.text("given")?{given:R.text("given")}:{}})}h.set(_,D)}const m=[];for(const x of u){const _=j.tileSteps(x);if(!_)return{ok:!1,reason:`The tile \`${x}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:$,view:T}=_,D=h.get($)?.get(T)?.line;if(D===void 0){m.push({name:T,source:$,declaration:{kind:"inherited"}});continue}const I=wg(r[D],T);if(I===void 0)return{ok:!1,reason:`Could not read what view \`${T}\` is declared from.`,line:D+1};const{tags:C}=Lt(r,D),P=n(Is(C)).tag,A=I.kind==="reference"?kg(I.refinement):void 0;m.push({name:T,source:$,declaration:I.kind==="reference"?{kind:"reference",from:I.from}:{kind:"inline"},...A?{filters:A}:{},...P?.text("label")?{label:P.text("label")}:{},...P?.text("subtitle")?{subtitle:P.text("subtitle")}:{},...P?.numeric("colspan")!==void 0?{colspan:P.numeric("colspan")}:{},...P?.has("break")?{break:!0}:{},...P?.has("borderless")?{borderless:!0}:{}})}const w=Sg(r,n),b={},v=d?.tag("givens");for(const x of Object.keys(v?.dict??{})){const _=v?.text(x);_!==void 0&&(b[x]=_)}const p=c?.tag("dashboard")?.numeric("columns");return{ok:!0,document:{title:d?.text("title")??"",...s?{description:s}:{},...p===void 0?{}:{columns:p},...d?.has("autorun")?{autorun:d.isTrue("autorun")}:{},imports:l,sources:f,...w?{localGivens:w}:{},...Object.keys(b).length>0?{startingGivens:b}:{},...g.length>0?{drills:g}:{},tiles:m}}}const js=e=>e.ok===!1;function pe(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 Tg(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
72
- `&&t.push(n+1);return t}function Dg(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 $d(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=${gn(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${gn(e.subtitle)}`),t}function Hr(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Eg=new Set(["colspan","break","borderless","label","subtitle"]),Pg=new Set(["label","description","control","suggest","range_min","range_max"]),Mg=(e,t)=>pe(e.imports)===pe(t.imports);function Ra(e){const t=[];if(e.label!==void 0&&t.push(`label=${gn(e.label)}`),e.description!==void 0&&t.push(`description=${gn(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 La=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function ui(e,t){let n=0,r=!1;for(let i=t;i<e.length;i++){for(const s of e[i])s==="{"?(n++,r=!0):s==="}"&&n--;if(r&&n<=0||!r&&i===t)return i}return e.length-1}const za=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Cg(e,t,n){const r=e.findIndex(o=>new RegExp(`\\bsource:\\s*${za(t)}\\s+is\\b`).test(o));if(r<0)return-1;const i=ui(e,r),s=new RegExp(`\\bview:\\s*${za(n)}\\s+is\\b`);for(let o=r;o<=i;o++)if(s.test(e[o]))return o;return-1}function Wa(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const fi=e=>`${e.source}.${e.name}`,gn=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,As=e=>pe([e.name,e.source,e.declaration]),at=As,Fa=e=>pe(e.tiles.map(at));function Ig(e,t){const n=new Set(e.tiles.map(at)),r=new Set(t.tiles.map(at)),i=e.tiles.filter(l=>!r.has(at(l))),s=t.tiles.filter(l=>!n.has(at(l))),a=i.length>0||s.length>0||Fa(e)!==Fa(t);for(const l of s)if(l.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${l.name}\` is ${l.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const c=new Map(e.sources.map(l=>[l.name,l])),d=new Set(e.imports.flatMap(l=>l.kind==="names"?l.names:[]));for(const l of e.sources)d.add(l.base);const u=t.sources.filter(l=>!c.has(l.name));for(const l of e.sources){const f=t.sources.find(g=>g.name===l.name);if(!f||f.base!==l.base)return{ok:!1,reason:`The source \`${l.name}\` cannot be changed or removed here.`}}for(const l of u){if(!s.some(f=>f.source===l.name))return{ok:!1,reason:`A new source \`${l.name}\` needs a tile on it.`};if(!d.has(l.base))return{ok:!1,reason:`\`${l.base}\` is not imported by name in this file, so a tile cannot be put on it. The builder does not add imports: import { ${l.base} } from the model first.`}}return Mg(e,t)?{currentKeys:n,nextKeys:r,removedTiles:i,addedTiles:s,newSources:u,currentSources:c,reordered:a}:{ok:!1,reason:"The dashboard's imports cannot be changed here."}}function jg(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const c=j.artifactLine(t);if(c<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const d=[...t[c].matchAll(/"([^"]+)"/g)].map(h=>h[1]),u=new Map;for(const h of d){const m=h.split("->").map(w=>w.trim());m.length===2&&u.set(`${m[0]}->${m[1]}`,h)}const l=r.tiles.map(h=>u.get(`${h.source}->${h.name}`)??(o.has(at(h))&&!s.has(at(h))?`${h.source} -> ${h.name}`:void 0));if(l.some(h=>h===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const f=`tiles=[${l.map(h=>`"${h}"`).join(", ")}]`,g=t[c].replace(/tiles\s*=\s*\[[\s\S]*?\]/,f);g!==t[c]&&a.push({...n(c),text:`${g}
73
- `})}}function Ag(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||pe(r.startingGivens)!==pe(i.startingGivens)){const o=j.artifactLine(t);if(o<0)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=s.find(m=>m.start===n(o).start&&m.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 m=u;m<c.length;m++)if(c[m]==="{")l++;else if(c[m]==="}"&&--l===0){f=m;break}if(u<0||f<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let g=c.slice(u+1,f);const h=(m,w)=>{const b=new RegExp(`\\s*\\b${m}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);w===void 0?g=g.replace(b,""):b.test(g)?g=g.replace(b,` ${m}=${w}`):g=`${g.replace(/\s+$/,"")} ${m}=${w} `};if(r.title!==i.title&&h("title",i.title?gn(i.title):void 0),r.autorun!==i.autorun&&h("autorun",i.autorun===void 0?void 0:String(i.autorun)),pe(r.startingGivens)!==pe(i.startingGivens)){g=g.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const m=Object.entries(i.startingGivens??{});m.length>0&&(g=`${g.replace(/\s+$/,"")} givens { ${m.map(([w,b])=>`${w}=${gn(b)}`).join(" ")} }`)}g=g.replace(/\s{2,}/g," "),c=`${c.slice(0,u+1)}${g.startsWith(" ")?g:` ${g}`}${g.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}
74
- `:s.push({...n(o),text:`${c}
75
- `})}if(r.description!==i.description){const o=t.map((c,d)=>c.trim().startsWith('##"')?d:-1).filter(c=>c>=0),a=(i.description??"").split(`
76
- `).map(c=>c.trim()===""?'##"':`##" ${c.trim()}`).join(`
77
- `);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}
78
- `})}else if(i.description!==void 0){const c=j.artifactLine(t),d=n(c).start;s.push({start:d,end:d,text:`${a}
79
- `})}}}function Rg(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=j.givenDeclarations(t),u=new Set;for(const[f,g]of a){const h=c.get(f);if(h!==void 0&&pe(h)===pe(g))continue;const m=d.get(f);if(m===void 0)return{ok:!1,reason:`Could not find where the given \`${f}\` is declared.`};const{tags:w}=Lt(t,m.line),b=h===void 0?w:w.filter($=>{const T=Hr($.text);return T!==void 0&&Pg.has(T)});for(const $ of b)o.push({...n($.line),text:""}),u.add($.line);if(h===void 0){o.push({...n(m.line),text:""}),u.add(m.line);const $=Math.min(m.line,...w.map(P=>P.line)),T=m.blockHeader??$,D=(t[m.line+1]??"x").trim()==="",I=T===0||t[T-1].trim()==="",C=m.blockHeader===void 0||![...d.values()].some(P=>P.blockHeader===m.blockHeader&&P.line>m.line&&c.has([...d.entries()].find(([,A])=>A===P)?.[0]??""));D&&I&&C&&!u.has(m.line+1)&&(o.push({...n(m.line+1),text:""}),u.add(m.line+1));continue}const v=r(m.line),p=Ra(h),_=h.type!==g.type||h.default!==g.default?m.blockHeader===void 0?La(h):`${h.name} :: ${h.type} is ${h.default}`:t[m.line].trim();o.push({...n(m.line),text:(p?`${v}${p}
69
+ `);if(n.length>$a||r.length>$a)return[...n.map(l=>({kind:"del",text:l})),...r.map(l=>({kind:"add",text:l}))];const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let l=n.length-1;l>=0;l--)for(let d=r.length-1;d>=0;d--)i[l][d]=n[l]===r[d]?i[l+1][d+1]+1:Math.max(i[l+1][d],i[l][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 up(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 fp({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=Le.usePublisherTheme(),o=S.useMemo(()=>e?up(dp(t,n)):[],[e,t,n]),a=o.filter(d=>d.kind==="add").length,l=o.filter(d=>d.kind==="del").length;return y.jsx(j.AppDialog,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:y.jsxs(y.Fragment,{children:["A tile was added or removed, which moves declarations. Lines the builder does not own — comments, other Malloy — are left where they were; check they still read right."," ",y.jsxs(k.Box,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",l]})]}),actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Keep editing"}),y.jsx(k.Button,{variant:"contained",onClick:r,children:"Save this"})]}),children:y.jsx(k.Box,{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"?y.jsx(k.Box,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${d.count} unchanged line${d.count===1?"":"s"}`},u):y.jsxs(k.Box,{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))})})}const Yi="self";function hp({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Le.usePublisherTheme(),[l,d]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const g=(t.drills??[]).filter(m=>m.source===n.name);d((n.dimensions??[]).map(m=>{const w=g.find(b=>b.name===m.name);return{name:m.name,expression:m.expression,to:w?.to??[],given:w?.given??""}}))},[e,n,t]);const u=(g,m)=>d(w=>w.map((b,v)=>{if(v!==g)return b;const p={...b};return m(p),p})),c=[Yi,...i.filter(g=>g!==Yi)],h=g=>g===Yi?"This dashboard":g,f=()=>{n&&(o(l.filter(g=>g.to.length>0).map(g=>({source:n.name,name:g.name,expression:g.expression,to:g.to,...g.given?{given:g.given}:{}}))),s())};return y.jsx(j.AppDialog,{open:e,onClose:s,title:"Clickable cells",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",onClick:f,disabled:l.length===0,children:"Apply"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:l.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(k.Box,{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"," ",y.jsx(k.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((g,m)=>y.jsxs(k.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(k.Box,{sx:{minWidth:0,pt:.75},children:[y.jsx(k.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:g.name}),y.jsxs(k.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g.expression,children:["is ",g.expression]})]}),y.jsx(k.TextField,{select:!0,size:"small",label:"Clicks go to",value:g.to,inputProps:{"aria-label":`Where ${g.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.length===0?"Not clickable":w.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:w=>u(m,b=>{const v=w.target.value;b.to=Array.isArray(v)?v:String(v).split(",").filter(Boolean)}),children:c.map(w=>y.jsxs(k.MenuItem,{value:w,children:[y.jsx(k.Checkbox,{size:"small",checked:g.to.includes(w),sx:{p:0,mr:1}}),y.jsx(k.ListItemText,{primary:h(w)})]},w))}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Sets the control",value:g.given,disabled:g.to.length===0,inputProps:{"aria-label":`Control ${g.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:g.given===""?`Named ${g.name}, like the dimension`:void 0,onChange:w=>u(m,b=>{b.given=w.target.value}),children:[y.jsx(k.MenuItem,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(w=>y.jsx(k.MenuItem,{value:w,children:w},w))]})]},g.name))})})}const pd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function pp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[d,u]=S.useState({kind:"new"}),[c,h]=S.useState(""),[f,g]=S.useState("select"),[m,w]=S.useState(""),[b,v]=S.useState(""),[p,x]=S.useState([]),[_,O]=S.useState(!1),T=P=>t.sources.find(R=>R.name===P.source)?.base??P.source;S.useEffect(()=>{if(e)if(n){u({kind:"existing",name:n.name}),h(n.label??"");const P=Kh(t,n);x(P);const R=P.filter($=>$.include),U=new Set(R.map($=>$.field));v(U.size===1?R[0].field:n.field??""),O(U.size>1)}else u({kind:"new"}),h(""),g("select"),v(""),w(new Date().toISOString().slice(0,10)),x(t.tiles.map(P=>({include:zs(P),field:""}))),O(!1)},[e,n,t]);const E=S.useMemo(()=>[...(t.localGivens??[]).map(P=>P.name),...r.map(P=>P.name)],[t,r]),I=S.useMemo(()=>b.trim()?Hh(b.trim(),E):"",[b,E]),D=d.kind==="existing"?n??r.find(P=>P.name===d.name):I?{name:I,type:Rr({name:I,label:c,kind:f,field:b}).type}:void 0,L=D?.type!==void 0&&!D.type.startsWith("filter<"),M=p.find(P=>P.include)?.op??yi(D?.type),A=(P,R)=>x(U=>U.map(($,C)=>C===P?{...$,...R}:$)),Q=P=>x(R=>R.map(U=>({...U,op:P}))),J=P=>{const R=yi(P);x(U=>U.map(({op:$,...C})=>R?{...C,op:R}:C))},ye=P=>{u({kind:"existing",name:P.name}),v(P.field??""),J(P.type)},Ie=P=>{g(P),J(Rr({name:"X",label:c,kind:P,field:b}).type)},ie=t.tiles.map(zs),ze=ie.filter(Boolean).length,Ke=p.filter((P,R)=>P.include&&ie[R]).length,be=t.tiles.filter((P,R)=>(p[R]?.include??!1)&&ie[R]),qe=be.length>0?be:t.tiles.filter((P,R)=>ie[R]),We=S.useMemo(()=>{const P=new Map;let R=!1;for(const U of qe){const $=i?.(U);if($){R=!0;for(const C of $)P.has(C.name)||P.set(C.name,C)}}return R?[...P.values()]:void 0},[p,t.tiles,i]),je=(()=>{const P=b.trim();for(const R of be){const U=i?.(R);if(!U||U.some($=>$.name===P))return T(R)}return be[0]?T(be[0]):t.sources[0]?.base})(),Fe=P=>x(R=>R.map((U,$)=>({...U,include:P&&ie[$]}))),xe=S.useMemo(()=>_?p:p.map(P=>({...P,field:b})),[_,p,b]),ee=P=>{for(const R of qe){const U=i?.(R)?.find($=>$.name===P.trim());if(U?.type)return U.type}},z=P=>ti(D?.type,P.type),V=(P,R)=>{if(P.trim()==="")return"Pick the field this filter compares.";const U=R?i?.(R):void 0;if(!U)return;const $=U.find(C=>C.name===P.trim());if(!$)return`Not a field of ${R?T(R):"the tiles' source"}.`;if($.type&&!ti(D?.type,$.type))return`${P.trim()} is ${_a($.type)}; this filter compares ${_a(D?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},_e=P=>{if(v(P),l||d.kind!=="new")return;const R=ee(P),U=Rr({name:"X",label:c,kind:f,field:P}).type;R&&!ti(U,R)&&Ie(Gh(R))},ne=xe.map((P,R)=>P.include&&ie[R]?V(P.field,t.tiles[R]):void 0),Ae=ne.every(P=>P===void 0),X=!_&&Ke>0?be.map(P=>V(b,P)).find(Boolean):void 0,et=D!==void 0&&Ae&&(d.kind==="existing"||b.trim()!==""&&I!==""),Se=()=>{if(!(!D||!et))if(d.kind==="new")s(D.name,xe,Rr({name:D.name,label:c.trim()||pd(D.name),kind:f,field:b.trim(),...je?{source:je}:{},...m?{dateDefault:m}:{}}));else if(n?.origin==="dashboard"&&n.local){const P=c.trim(),R=P!==(n.local.label??"");s(D.name,xe,R?{...n.local,...P?{label:P}:{}}:void 0)}else s(D.name,xe)},ft=l&&a.origin==="model";return{editing:l,shown:a,fromModel:ft,source:d,setSource:u,label:c,setLabel:h,kind:f,dateDefault:m,setDateDefault:w,field:b,rows:p,setRows:x,perTile:_,setPerTile:O,newName:I,target:D,valueTyped:L,commonOp:M,setRow:A,setCommonOp:Q,pickExisting:ye,pickKind:Ie,bindable:ie,bindableCount:ze,included:Ke,commonFields:We,setAll:Fe,accepts:z,pickField:_e,rowProblems:ne,commonProblem:X,canApply:et,apply:Se}}function Oa({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:l,autoFocus:d,placeholder:u,sx:c}){const h=S.useMemo(()=>(n??[]).filter(g=>r?.(g)??!0).map(g=>g.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(g=>[g.name,g.type])),[n]);return y.jsx(k.Autocomplete,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(g,m)=>t(m),value:e,onChange:(g,m)=>t(typeof m=="string"?m:""),disabled:l,disableClearable:!0,renderOption:(g,m)=>S.createElement("li",{...g,key:m},y.jsx(k.Typography,{variant:"body2",sx:{flex:1},children:m}),f.get(m)&&y.jsx(k.Typography,{variant:"caption",sx:{opacity:.6},children:f.get(m)?.replace(/_type$/,"")})),renderInput:g=>y.jsx(k.TextField,{...g,label:i,placeholder:u,autoFocus:d,error:o,helperText:a,inputProps:{...g.inputProps,"aria-label":s}}),sx:c})}function gp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:l}=Le.usePublisherTheme(),{editing:d,shown:u,fromModel:c,source:h,setSource:f,label:g,setLabel:m,kind:w,dateDefault:b,setDateDefault:v,field:p,rows:x,setRows:_,perTile:O,setPerTile:T,newName:E,target:I,valueTyped:D,commonOp:L,setRow:M,setCommonOp:A,pickExisting:Q,pickKind:J,bindable:ye,bindableCount:Ie,included:ie,commonFields:ze,setAll:Ke,accepts:be,pickField:qe,rowProblems:We,commonProblem:je,canApply:Fe,apply:xe}=pp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),ee=(z,V,_e)=>y.jsx(k.TextField,{select:!0,size:"small",label:"Compares",value:z??">=",onChange:ne=>V(ne.target.value),inputProps:{"aria-label":_e},sx:{width:130},children:Vh.filter(ne=>ne.op!=="~").map(ne=>y.jsx(k.MenuItem,{value:ne.op,children:ne.label},ne.op))});return y.jsx(j.AppDialog,{open:e,onClose:s,title:d?u.label??u.name:"Add a filter",description:d?y.jsxs(y.Fragment,{children:[y.jsxs(k.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",u.name]}),c?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A control on the page, and the tiles it filters.",actions:y.jsxs(y.Fragment,{children:[d&&y.jsx(k.Button,{color:"error",onClick:()=>a(u.name),"aria-label":`Remove control ${u.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Tooltip,{title:Fe||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(k.Button,{variant:"contained",onClick:xe,disabled:!Fe,children:d?"Apply":"Add filter"})})})]}),children:y.jsxs(k.Stack,{sx:{gap:2.5,pt:1},children:[!d&&r.length>0&&y.jsxs(k.ToggleButtonGroup,{exclusive:!0,size:"small",value:h.kind,onChange:(z,V)=>{V==="new"?f({kind:"new"}):V==="existing"&&r[0]&&Q(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(k.ToggleButton,{value:"new",children:"New in this dashboard"}),y.jsx(k.ToggleButton,{value:"existing",children:"From the model"})]}),!d&&h.kind==="existing"?y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:h.name,onChange:z=>{const V=r.find(_e=>_e.name===z.target.value);V&&Q(V)},children:r.map(z=>y.jsxs(k.MenuItem,{value:z.name,children:[z.label??z.name,y.jsxs(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",z.name]})]},z.name))}):null,y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!O&&y.jsx(Oa,{value:p,onChange:qe,fields:ze,accepts:be,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!d,error:je!==void 0,helperText:je??(!d&&E?`Declared as $${E}`:void 0),sx:{flex:1,minWidth:200}}),!c&&y.jsx(k.TextField,{size:"small",label:"Label",placeholder:E?pd(E):"",value:g,onChange:z=>m(z.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),D&&!O&&ee(L,A,"Comparison")]}),!d&&h.kind==="new"&&y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:w,onChange:z=>J(z.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:z=>wa.find(V=>V.kind===z)?.label??String(z)}},sx:{flex:1},children:wa.map(z=>y.jsxs(k.MenuItem,{value:z.kind,children:[z.label,y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:z.hint})]},z.kind))}),w==="date"&&y.jsx(k.TextField,{size:"small",type:"date",label:"Starts at",value:b,onChange:z=>v(z.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(k.Box,{children:[y.jsxs(k.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(k.Checkbox,{size:"small",checked:Ie>0&&ie===Ie,indeterminate:ie>0&&ie<Ie,disabled:Ie===0,onChange:z=>Ke(z.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(k.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",ie," of ",t.tiles.length," tiles"]}),y.jsx(k.Button,{size:"small",onClick:()=>{O||_(z=>z.map(V=>({...V,field:p}))),T(z=>!z)},children:O?"Same field for all":"Adjust per tile"})]}),y.jsx(k.Stack,{sx:{gap:O?1:0},children:t.tiles.map((z,V)=>{const _e=x[V],ne=z.label??z.name,Ae=O?We[V]:void 0;return y.jsxs(k.Stack,{direction:"row",sx:{gap:1,alignItems:O?"flex-start":"center",opacity:ye[V]?1:.6},children:[y.jsx(k.Checkbox,{size:"small",disabled:!ye[V],checked:(_e?.include??!1)&&ye[V],inputProps:{"aria-label":`Filter ${ne}`},onChange:X=>M(V,{include:X.target.checked})}),y.jsx(k.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:O?1:0},noWrap:!0,children:ne}),ye[V]?O&&y.jsxs(y.Fragment,{children:[D&&ee(_e?.op,X=>M(V,{op:X}),`Comparison for ${ne}`),y.jsx(Oa,{value:_e?.field??"",onChange:X=>M(V,{field:X}),fields:i?.(z),accepts:be,label:"Field",ariaLabel:`Field for ${ne}`,disabled:!_e?.include,error:Ae!==void 0,helperText:Ae,sx:{width:220}})]}):y.jsx(k.Tooltip,{title:z.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:y.jsx(k.Typography,{variant:"caption",sx:{color:l.tileTitle},children:z.declaration.kind==="inherited"?"From the model":"Inline query"})})]},`${z.source}.${z.name}`)})}),ie===0&&y.jsx(k.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}function gd(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:d=>s(u=>{if(u===void 0)return u;const c=structuredClone(u);return d(c),c}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const vp=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 mp({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=Le.usePublisherTheme(),{draft:s,patch:o,close:a}=gd(t,e!==null,r,n),l=s?.columns!==void 0&&!Zi.includes(s.columns)?[...Zi,s.columns].sort((d,u)=>d-u):Zi;return y.jsx(k.Popover,{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&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsx(k.Typography,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),y.jsx(k.TextField,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:d=>o(u=>{u.title=d.target.value})}),y.jsx(k.TextField,{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 c=d.target.value;c.trim()===""?delete u.description:u.description=c})}),y.jsxs(k.TextField,{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 c=Number(d.target.value);c?u.columns=c:delete u.columns}),children:[y.jsx(k.MenuItem,{value:"",children:"Default (2)"}),l.map(d=>y.jsx(k.MenuItem,{value:d,children:d},d))]}),y.jsx(k.FormControlLabel,{control:y.jsx(k.Switch,{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:y.jsxs(k.Typography,{variant:"body2",children:["Run as controls change",y.jsx(k.Typography,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const yp=j.createSvgIcon(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function bp({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=Le.usePublisherTheme();return y.jsx(y.Fragment,{children:y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsxs(k.Stack,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[y.jsx(yp,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),y.jsx(k.Typography,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const l=n(a.name,a.type);return y.jsx(k.Tooltip,{title:l.length>0?`$${a.name} · cannot filter on: ${l.join(", ")}`:`$${a.name} · ${a.origin==="dashboard"?"declared here":"from the model"} · ${a.boundTiles} of ${t} tiles`,children:y.jsx(k.Chip,{size:"small",label:a.label??a.name,"aria-label":`Edit filter ${a.name}`,color:l.length>0?"warning":"default",variant:a.origin==="dashboard"?"filled":"outlined",onClick:()=>r(a),sx:{opacity:a.boundTiles===0?.6:1,cursor:"pointer",transition:"opacity 120ms"}})},a.name)}),y.jsx(k.Box,{sx:{ml:"auto"},children:y.jsx(j.SecondaryButton,{label:"Filter",icon:y.jsx(j.AddIcon,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const xp=(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}),_p=(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},vd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),md=e=>`gap.${e}`,wp=(e,t)=>{const n=[];let r=0;e.forEach((s,o)=>{const a=Math.min(s.colspan??1,t),l=o===0||s.break===!0||r+a>t;l&&o>0&&r<t&&n.push({kind:"gap",after:ht(e[o-1]),colspan:t-r}),l&&(r=0),n.push(vd(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:ht(i),colspan:t-r}),n};var kp=Object.create,yd=Object.defineProperty,Sp=Object.defineProperties,$p=Object.getOwnPropertyDescriptor,Op=Object.getOwnPropertyDescriptors,bi=Object.getOwnPropertySymbols,bd=Object.prototype.hasOwnProperty,xd=Object.prototype.propertyIsEnumerable,Tp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Or=e=>{throw TypeError(e)},Fs=(e,t,n)=>t in e?yd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qi=(e,t)=>{for(var n in t||(t={}))bd.call(t,n)&&Fs(e,n,t[n]);if(bi)for(var n of bi(t))xd.call(t,n)&&Fs(e,n,t[n]);return e},Ji=(e,t)=>Sp(e,Op(t)),Ep=(e,t)=>{var n={};for(var r in e)bd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&bi)for(var r of bi(e))t.indexOf(r)<0&&xd.call(e,r)&&(n[r]=e[r]);return n},Dp=e=>{var t;return[,,,kp((t=void 0)!=null?t:null)]},_d=["class","method","getter","setter","accessor","field","value","get","set"],Qn=e=>e!==void 0&&typeof e!="function"?Or("Function expected"):e,Pp=(e,t,n,r,i)=>({kind:_d[e],name:t,metadata:r,addInitializer:s=>n._?Or("Already initialized"):i.push(Qn(s||null))}),Cp=(e,t)=>Fs(t,Tp("metadata"),e[3]),zr=(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},wd=(e,t,n,r,i,s)=>{for(var o,a,l,d,u,c=t&7,h=!1,f=!1,g=e.length+1,m=_d[c+5],w=e[g-1]=[],b=e[g]||(e[g]=[]),v=(i=i.prototype,$p({get[n](){return Jn(this,s)},set[n](x){return Lt(this,s,x)}},n)),p=r.length-1;p>=0;p--)d=Pp(c,n,l={},e[3],b),d.static=h,d.private=f,u=d.access={has:x=>n in x},u.get=x=>x[n],u.set=(x,_)=>x[n]=_,a=(0,r[p])({get:v.get,set:v.set},d),l._=1,a===void 0?Qn(a)&&(v[m]=a):typeof a!="object"||a===null?Or("Object expected"):(Qn(o=a.get)&&(v.get=o),Qn(o=a.set)&&(v.set=o),Qn(o=a.init)&&w.unshift(o));return v&&yd(i,n,v),i},kd=(e,t,n)=>t.has(e)||Or("Cannot "+n),Jn=(e,t,n)=>(kd(e,t,"read from private field"),t.get(e)),Wn=(e,t,n)=>t.has(e)?Or("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Lt=(e,t,n,r)=>(kd(e,t,"write to private field"),t.set(e,n),n);function Wt(e){return e instanceof Ko||e instanceof Td}var Wr=10,Mp=class extends Ee{constructor(e){super(e);const t=Qe(()=>{const{dragOperation:r}=e;if(hr(r.activatorEvent)&&Wt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(Sr);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(!hr(r.nativeEvent)||!Wt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:d}=r;if(!d)return;const u=Ip(d),{source:c,target:h}=s,{center:f}=s.shape.current,g=[],m=[];ae(()=>{for(const _ of l.droppables){const{id:O}=_;if(!_.accepts(c)||O===h?.id&&Wt(_)||!_.element)continue;let T=_.shape;const E=new at(_.element,{getBoundingClientRect:I=>ur(I,void 0,.2)});!E.height||!E.width||(u=="down"&&f.y+Wr<E.center.y||u=="up"&&f.y-Wr>E.center.y||u=="left"&&f.x-Wr>E.center.x||u=="right"&&f.x+Wr<E.center.x)&&(g.push(_),_.shape=E,m.push(()=>_.shape=T))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(g,_f);ae(()=>m.forEach(_=>_()));const[b]=w;if(!b)return;const{id:v}=b,{index:p,group:x}=c.sortable;o.setDropTarget(v).then(()=>{const{source:_,target:O,shape:T}=s;if(!_||!Wt(_)||!T)return;const{index:E,group:I,target:D}=_.sortable,L=p!==E||x!==I,M=L?D:O?.element;if(!M)return;yc(M);const A=new at(M);if(!A)return;const Q=lt.delta(A,lt.from(T.current.boundingRectangle),_.alignment);o.move({by:Q}),L?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Ip(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 jp=Object.defineProperty,Ap=Object.defineProperties,Rp=Object.getOwnPropertyDescriptors,Ta=Object.getOwnPropertySymbols,Lp=Object.prototype.hasOwnProperty,zp=Object.prototype.propertyIsEnumerable,Ea=(e,t,n)=>t in e?jp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qt=(e,t)=>{for(var n in t||(t={}))Lp.call(t,n)&&Ea(e,n,t[n]);if(Ta)for(var n of Ta(t))zp.call(t,n)&&Ea(e,n,t[n]);return e},Jt=(e,t)=>Ap(e,Rp(t));function Wp(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Fr(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 Fp(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(p,x)=>p===x||p!==null&&typeof p=="object"&&"id"in p&&p.id===x;if(Array.isArray(e)){const p=e.findIndex(_=>l(_,s.id)),x=e.findIndex(_=>l(_,o.id));if(p===-1||x===-1){if(es(s)){const _=s.initialIndex,O=s.index;return _===O||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,O)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,x)}const d=Object.entries(e);let u=-1,c,h=-1,f;for(const[p,x]of d)if(u===-1&&(u=x.findIndex(_=>l(_,s.id)),u!==-1&&(c=p)),h===-1&&(h=x.findIndex(_=>l(_,o.id)),h!==-1&&(f=p)),u!==-1&&h!==-1)break;if(u===-1&&es(s)){const p=s.initialGroup==null?void 0:Fr(e,s.initialGroup),x=s.initialIndex,_=s.group==null?void 0:Fr(e,s.group),O=s.index;if(p==null||_==null||p===_&&x===O)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return Jt(Qt({},e),{[p]:n(e[p],x,O)});const T=e[p][x];return Jt(Qt({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[_]:[...e[_].slice(0,O),T,...e[_].slice(O)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,m=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(f==null){const p=Fr(e,o.id);if(p!=null){const x=o.shape&&m.y>o.shape.center.y?e[p].length:0;f=p,h=x}}if(c==null||f==null||c===f&&u===h){if(c!=null&&c===f&&u===h&&es(s)){const p=s.group==null?void 0:Fr(e,s.group),x=s.group!=null&&p!==c,_=s.index!==u;if(x||_){const O=s.group==null?c:p;if(O!=null){if(c===O)return Jt(Qt({},e),{[c]:n(e[c],u,s.index)});const T=e[c][u];return Jt(Qt({},e),{[c]:[...e[c].slice(0,u),...e[c].slice(u+1)],[O]:[...e[O].slice(0,s.index),T,...e[O].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===f)return Jt(Qt({},e),{[c]:n(e[c],u,h)});const b=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[c][u];return Jt(Qt({},e),{[c]:[...e[c].slice(0,u),...e[c].slice(u+1)],[f]:[...e[f].slice(0,h+b),v,...e[f].slice(h+b)]})}function Bp(e,t){return Fp(e,t,Wp)}function Da(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Pa(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 Ca="__default__",Np=class extends Ee{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof Ko){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(!Wt(o)||!Wt(a)||o.sortable===a.sortable)return;const l=t(),d=Da(l),u=o.sortable.group===a.sortable.group,c=l.get(o.sortable.group),h=u?c:l.get(a.sortable.group);!c||!h||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var f,g;const m=t();if(Pa(d,l,m))return;const w=o.sortable.element,b=a.sortable.element;if(!b||!w||!u&&a.id===o.sortable.group)return;const v=Br(c),p=u?v:Br(h),x=(f=o.sortable.group)!=null?f:Ca,_=(g=a.sortable.group)!=null?g:Ca,O={[x]:v,[_]:p},T=Bp(O,r);if(O===T)return;const E=T[_].indexOf(o.sortable),I=T[_].indexOf(a.sortable);i.collisionObserver.disable(),Ma(w,E,b,I),ae(()=>{for(const[D,L]of T[x].entries())L.index=D;if(!u)for(const[D,L]of T[_].entries())L.group=a.sortable.group,L.index=D}),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;Wt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=Da(a),d=a.get(o.sortable.initialGroup);d&&i.renderer.rendering.then(()=>{const u=t();if(Pa(l,a,u))return;const c=Br(d),h=Br(d,Vp),f=o.sortable.element,g=h.indexOf(o.sortable),m=c[g],w=m?.element;!m||!w||!f||(Ma(f,m.index,w,o.index),ae(()=>{for(const b of a.values()){const v=Array.from(b).values();for(const p of v)p.index=p.initialIndex,p.group=p.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Ma(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function Gp(e,t){return e.index-t.index}function Vp(e,t){return e.initialIndex-t.initialIndex}function Br(e,t=Gp){return Array.from(e).sort(t)}var Ia=[Mp,Np],Sd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function ja(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 Nr=new ru,$d,Od,Ot,Vo,er,tr,Ho,cn;Od=[K],$d=[K];var Ai=class{constructor(e,t){Wn(this,Vo,zr(Ot,8,this)),zr(Ot,11,this),Wn(this,er),Wn(this,tr),Wn(this,Ho,zr(Ot,12,this)),zr(Ot,15,this),Wn(this,cn),this.register=()=>(ae(()=>{var g,m;(g=this.manager)==null||g.registry.register(this.droppable),(m=this.manager)==null||m.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{ae(()=>{var g,m;(g=this.manager)==null||g.registry.unregister(this.droppable),(m=this.manager)==null||m.registry.unregister(this.draggable)})},this.destroy=()=>{ae(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:l,transition:d=Sd,plugins:u}=n,c=Ep(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const h=it(u,Ia),f=ja(i);this.droppable=new Ko(Ji(Qi({},c),{disabled:f.droppable}),t,this),this.draggable=new Td(Ji(Qi({},c),{disabled:f.draggable,plugins:h,effects:()=>[()=>{var g,m,w;const b=(g=this.manager)==null?void 0:g.dragOperation.status;b?.initializing&&this.id===((w=(m=this.manager)==null?void 0:m.dragOperation.source)==null?void 0:w.id)&&Nr.clear(this.manager),b?.dragging&&Nr.set(this.manager,this.id,H(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:g,group:m,manager:w}=this,b=Jn(this,tr),v=Jn(this,er);(g!==b||m!==v)&&(Lt(this,tr,g),Lt(this,er,m),this.animate())},()=>{var g,m;const{target:w}=this,{isDragSource:b}=this.draggable;((m=(g=this.draggable.pluginConfig(Ao))==null?void 0:g.feedback)!=null?m:"default")==="move"&&b&&(this.droppable.disabled=!w)},...r()],type:l,sensors:a}),t,this),Lt(this,cn,c.element),this.manager=t,this.index=o,Lt(this,tr,o),this.group=s,Lt(this,er,s),this.type=l,this.transition=d}get initialIndex(){var e,t;return(t=(e=Nr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Nr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){H(()=>{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}=ut(i),l=ua(i,a,!1),d=ua(i,a);if(o.x||o.y){const u=To(He(i))?Ji(Qi({},t),{duration:0}):t;bc({element:i,keyframes:{translate:[`${l.x+o.x}px ${l.y+o.y}px ${l.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){ae(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){ae(()=>{const t=Jn(this,cn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Lt(this,cn,e)})}get element(){var e,t;const n=Jn(this,cn);if(n)return(t=(e=bs.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=it(e,Ia)}set disabled(e){const t=ja(e);ae(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){ae(()=>{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??xc}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){ae(()=>{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)}};Ot=Dp();Vo=new WeakMap;er=new WeakMap;tr=new WeakMap;Ho=new WeakMap;cn=new WeakMap;wd(Ot,4,"index",Od,Ai,Vo);wd(Ot,4,"group",$d,Ai,Ho);Cp(Ot,Ai);var Td=class extends Mi{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}},Ko=class extends Ii{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Hp=Object.defineProperty,Kp=Object.defineProperties,qp=Object.getOwnPropertyDescriptors,Aa=Object.getOwnPropertySymbols,Up=Object.prototype.hasOwnProperty,Xp=Object.prototype.propertyIsEnumerable,Ra=(e,t,n)=>t in e?Hp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ts=(e,t)=>{for(var n in t||(t={}))Up.call(t,n)&&Ra(e,n,t[n]);if(Aa)for(var n of Aa(t))Xp.call(t,n)&&Ra(e,n,t[n]);return e},Yp=(e,t)=>Kp(e,qp(t));function Zp(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:l,group:d,disabled:u,modifiers:c,sensors:h,target:f,type:g,plugins:m}=e,w=ts(ts({},Sd),e.transition),b=nd(p=>new Ai(Yp(ts({},e),{transition:w,register:!1,handle:pn(a),element:pn(o),target:pn(f)}),p)),v=Qc(b,Qp);return se(i,()=>b.id=i),In(()=>{ae(()=>{b.group=d,b.index=l})},[b,d,l]),se(g,()=>b.type=g),se(t,()=>b.accept=t,void 0,nt),se(s,()=>s&&(b.data=s)),se(l,()=>{var p;(p=b.manager)!=null&&p.dragOperation.status.idle&&w?.idle&&b.refreshShape()},gh),Jr(a,p=>b.handle=p),Jr(o,p=>b.element=p),Jr(f,p=>b.target=p),se(u,()=>b.disabled=u??!1,void 0,nt),se(h,()=>b.sensors=h,void 0,nt),se(n,()=>b.collisionDetector=n),se(r,()=>b.collisionPriority=r),se(m,()=>b.plugins=m,void 0,nt),se(w,()=>b.transition=w,void 0,nt),se(c,()=>b.modifiers=c,void 0,nt),se(e.alignment,()=>b.alignment=e.alignment),{sortable:v,get isDragging(){return v.isDragging},get isDropping(){return v.isDropping},get isDragSource(){return v.isDragSource},get isDropTarget(){return v.isDropTarget},handleRef:S.useCallback(p=>{b.handle=p??void 0},[b]),ref:S.useCallback(p=>{var x,_;!p&&((x=b.element)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.element=p??void 0)},[b]),sourceRef:S.useCallback(p=>{var x,_;!p&&((x=b.source)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.source=p??void 0)},[b]),targetRef:S.useCallback(p=>{var x,_;!p&&((x=b.target)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.target=p??void 0)},[b])}}function Qp(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Bs="tile",Ed="gap",Jp='[role="separator"]',eg=[Is.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Is.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(Jp)!==null}),Vc],tg=e=>[...e,Ao.configure({feedback:"clone"})];function ng({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=Zp({id:e,index:t,type:Bs,accept:Bs,collisionDetector:Do,plugins:tg});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function rg({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=Fh({id:e,type:Ed,accept:Bs,collisionDetector:Do,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const ig=j.createSvgIcon(y.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"})),sg=j.createSvgIcon(y.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 og({tile:e,index:t,selected:n,menuOpen:r,resizeSpan:i,columns:s,onSelect:o,onOpenMenu:a,onResizeStart:l,onResizeMove:d,onResizeEnd:u,children:c}){const{theme:h}=Le.usePublisherTheme();return y.jsx(ng,{id:ht(e),index:t,children:({ref:f,handleRef:g,isDragSource:m})=>y.jsxs(k.Box,{ref:f,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 ${h.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 ${h.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?h.drillLink:h.border,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[c,y.jsx(k.Box,{ref:g,className:"builder-affordance","aria-label":`Move ${e.label??e.name}`,sx:{position:"absolute",top:"2px",left:"2px",display:"grid",placeItems:"center",width:"22px",height:"22px",borderRadius:"4px",cursor:"grab",touchAction:"none",zIndex:2,color:h.tileTitle,bgcolor:h.tile,opacity:m||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${h.drillLink}`,outlineOffset:1}},children:y.jsx(ig,{sx:{fontSize:16}})}),i===void 0&&y.jsx(k.IconButton,{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:h.tileTitle,bgcolor:h.tile,opacity:n||r?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:h.tile}},children:y.jsx(sg,{sx:{fontSize:16}})}),i!==void 0&&y.jsxs(k.Box,{"aria-hidden":!0,sx:{position:"absolute",top:"6px",right:"6px",px:.75,py:.25,borderRadius:"4px",bgcolor:h.drillLink,color:h.tile,fontSize:11,fontVariantNumeric:"tabular-nums",zIndex:4,pointerEvents:"none"},children:[i," of ",s," ·"," ",Math.round(i/s*100),"%"]}),e.declaration.kind!=="inherited"&&y.jsx(k.Box,{className:"builder-affordance",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label??e.name}`,onPointerDown:l,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:h.drillLink}}})]})})}function ag({tile:e}){const{theme:t}=Le.usePublisherTheme();return y.jsxs(j.TileCard,{sx:{minHeight:140},children:[y.jsx(j.TileHeading,{title:e.label??e.name,subtitle:e.subtitle}),y.jsxs(k.Typography,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function lg({after:e}){const{theme:t}=Le.usePublisherTheme();return y.jsx(rg,{id:md(e),after:e,children:({ref:n,isDropTarget:r})=>y.jsx(k.Box,{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 cg({columns:e}){const{theme:t}=Le.usePublisherTheme();return y.jsx(k.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${j.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>y.jsx(k.Box,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var dg=Object.defineProperty,ug=Object.defineProperties,fg=Object.getOwnPropertyDescriptors,La=Object.getOwnPropertySymbols,hg=Object.prototype.hasOwnProperty,pg=Object.prototype.propertyIsEnumerable,za=(e,t,n)=>t in e?dg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,en=(e,t)=>{for(var n in t||(t={}))hg.call(t,n)&&za(e,n,t[n]);if(La)for(var n of La(t))pg.call(t,n)&&za(e,n,t[n]);return e},tn=(e,t)=>ug(e,fg(t));function gg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Gr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ns(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function vg(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(p,x)=>p===x||p!==null&&typeof p=="object"&&"id"in p&&p.id===x;if(Array.isArray(e)){const p=e.findIndex(_=>l(_,s.id)),x=e.findIndex(_=>l(_,o.id));if(p===-1||x===-1){if(ns(s)){const _=s.initialIndex,O=s.index;return _===O||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,O)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,x)}const d=Object.entries(e);let u=-1,c,h=-1,f;for(const[p,x]of d)if(u===-1&&(u=x.findIndex(_=>l(_,s.id)),u!==-1&&(c=p)),h===-1&&(h=x.findIndex(_=>l(_,o.id)),h!==-1&&(f=p)),u!==-1&&h!==-1)break;if(u===-1&&ns(s)){const p=s.initialGroup==null?void 0:Gr(e,s.initialGroup),x=s.initialIndex,_=s.group==null?void 0:Gr(e,s.group),O=s.index;if(p==null||_==null||p===_&&x===O)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return tn(en({},e),{[p]:n(e[p],x,O)});const T=e[p][x];return tn(en({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[_]:[...e[_].slice(0,O),T,...e[_].slice(O)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,m=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(f==null){const p=Gr(e,o.id);if(p!=null){const x=o.shape&&m.y>o.shape.center.y?e[p].length:0;f=p,h=x}}if(c==null||f==null||c===f&&u===h){if(c!=null&&c===f&&u===h&&ns(s)){const p=s.group==null?void 0:Gr(e,s.group),x=s.group!=null&&p!==c,_=s.index!==u;if(x||_){const O=s.group==null?c:p;if(O!=null){if(c===O)return tn(en({},e),{[c]:n(e[c],u,s.index)});const T=e[c][u];return tn(en({},e),{[c]:[...e[c].slice(0,u),...e[c].slice(u+1)],[O]:[...e[O].slice(0,s.index),T,...e[O].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===f)return tn(en({},e),{[c]:n(e[c],u,h)});const b=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[c][u];return tn(en({},e),{[c]:[...e[c].slice(0,u),...e[c].slice(u+1)],[f]:[...e[f].slice(0,h+b),v,...e[f].slice(h+b)]})}function mg(e,t){return vg(e,t,gg)}function yg({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:h,target:f}=c.operation;if(!h||!f)return;const g=s.current??e;let m;if(f.type===Ed){const{after:w}=f.data,b=g.findIndex(x=>ht(x)===h.id);if(b<0||w===h.id)return;const p=g.filter((x,_)=>_!==b).findIndex(x=>ht(x)===w)+1;m=_p(g,b,p)}else{const w=g.map(ht),b=mg(w,c);if(b.every((p,x)=>p===w[x]))return;const v=new Map(g.map(p=>[ht(p),p]));m=xp(b.map(p=>v.get(p)),e.map(p=>p.break??!1))}s.current=m,i(m)},onDragEnd:c=>{a(!1);const h=s.current;if(s.current=void 0,i(void 0),c.canceled||!h)return;t(h);const f=h.findIndex(g=>ht(g)===c.operation.source?.id);f>=0&&n(f)}}}const Wa=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function bg({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:(u,c)=>{const h=o.current?.getBoundingClientRect(),f=u.currentTarget.parentElement?.getBoundingClientRect();!h||!f||(u.stopPropagation(),u.preventDefault(),u.currentTarget.setPointerCapture(u.pointerId),Wa(!0),n(c),s({index:c,span:e[c]?.colspan??1,left:f.left,track:(h.width-j.GRID_GAP_PX*(t-1))/t}))},onResize:u=>{if(!i)return;const c=u.clientX-i.left,h=Math.round((c+j.GRID_GAP_PX)/(i.track+j.GRID_GAP_PX)),f=Math.min(Math.max(h,1),t);f!==i.span&&s({...i,span:f})},endResize:u=>{if(u.currentTarget.hasPointerCapture(u.pointerId)&&u.currentTarget.releasePointerCapture(u.pointerId),Wa(!1),!i)return;const{index:c,span:h}=i;s(void 0),r(c,h)}}}function xg({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=Le.usePublisherTheme(),{draft:l,patch:d,close:u,discard:c}=gd(t,e!==null,r,n),h=l!==void 0&&l.declaration.kind!=="inherited";return y.jsx(k.Popover,{open:e!==null&&l!==void 0,anchorEl:e,onClose:u,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:l&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsxs(k.Typography,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[l.source," → ",l.name]}),h?y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:f=>d(g=>{const m=f.target.value;m===""?delete g.label:g.label=m})}),y.jsx(k.TextField,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:f=>d(g=>{const m=f.target.value;m===""?delete g.subtitle:g.subtitle=m})}),y.jsxs(k.Stack,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[y.jsx(k.Typography,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([f,g])=>{const m=Math.max(1,Math.round(s/g)),w=(l.colspan??1)===m;return y.jsx(k.Button,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${f}`,"aria-pressed":w,onClick:()=>d(b=>{b.colspan=m}),sx:{minWidth:40,px:1},children:f},f)})]})]}):y.jsx(k.Typography,{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."}),y.jsx(k.Divider,{}),y.jsxs(k.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[h?y.jsx(k.Button,{size:"small",onClick:()=>{u(),o()},children:"Clickable cells…"}):y.jsx("span",{}),y.jsx(k.Button,{color:"error",size:"small",onClick:()=>{c(),i()},children:"Remove tile"})]})]})})}const xi=e=>e.ok===!1;function Nt(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 Ns=e=>e.map(t=>t.text);function _g(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(`
70
+ `):void 0,artifact:n}}function wg(e,t){return new RegExp(`source:\\s*${t}\\s+is\\s+([A-Za-z_][A-Za-z0-9_.]*)`).exec(e)?.[1]}function kg(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 Dd=/where:\s*([A-Za-z_][A-Za-z0-9_.]*)\s*(~|>=|<=|!=|=|>|<)\s*\$([A-Za-z_][A-Za-z0-9_]*)/g;function Sg(e){if(!e)return;const t=[];for(const n of e.matchAll(Dd))t.push({field:n[1],given:n[3],...n[2]==="~"?{}:{op:n[2]}});return t.length>0?t:void 0}function $g(e,t){const n=[];for(const r of j.givenDeclarations(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(),...Og(t(Ns(Nt(e,r.line).tags)).tag)})}return n.length>0?n:void 0}function Og(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 Tg(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(s=>s[1])}async function _i(e){const{Malloy:t}=await import("@malloydata/malloy"),{parseAnnotation:n}=await import("@malloydata/malloy-tag"),r=e.split(`
71
+ `);let i;try{i=t.parse({source:e}).symbols}catch(x){return{ok:!1,reason:`This file is not valid Malloy: ${x}`}}const{description:s,artifact:o}=_g(r),a=o.find(x=>x.includes("artifact"));if(a===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};const l=n([a.replace(/^##\s*/,"# ")]).tag,d=l?.tag("artifact"),u=Tg(a);if(u.length===0)return{ok:!1,reason:"The `## artifact` tag names no tiles, so there is nothing to lay out."};const c=[],h=[],f=[],g=new Map;for(const x of i){if(x.type==="import"){const D=(x.children??[]).filter(L=>L.type==="import_item").map(L=>String(L.name));c.push(D.length>0?{kind:"names",names:D,from:String(x.name)}:{kind:"all",from:String(x.name)});continue}if(x.type!=="explore")continue;const _=String(x.name),O=r[x.range.start.line]??"",T=wg(O,_);if(T===void 0)return{ok:!1,reason:`Could not read what source \`${_}\` extends.`,line:x.range.start.line+1};h.push({name:_,base:T});const E=j.declarationsUnder(r,_,"view"),I=j.declarationsUnder(r,_,"dimension");I.size>0&&(h[h.length-1].dimensions=[...I].map(([D,L])=>({name:D,expression:L.rest})));for(const[D,L]of I){const{tags:M}=Nt(r,L.line),A=n(Ns(M)).tag?.tag("drill");if(!A)continue;const Q=A.textArray("to")??[A.text("to")??""];f.push({source:_,name:D,expression:L.rest,to:Q.filter(Boolean),...A.text("given")?{given:A.text("given")}:{}})}g.set(_,E)}const m=[];for(const x of u){const _=j.tileSteps(x);if(!_)return{ok:!1,reason:`The tile \`${x}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:O,view:T}=_,E=g.get(O)?.get(T)?.line;if(E===void 0){m.push({name:T,source:O,declaration:{kind:"inherited"}});continue}const I=kg(r[E],T);if(I===void 0)return{ok:!1,reason:`Could not read what view \`${T}\` is declared from.`,line:E+1};const{tags:D}=Nt(r,E),L=n(Ns(D)).tag,M=I.kind==="reference"?Sg(I.refinement):void 0;m.push({name:T,source:O,declaration:I.kind==="reference"?{kind:"reference",from:I.from}:{kind:"inline"},...M?{filters:M}:{},...L?.text("label")?{label:L.text("label")}:{},...L?.text("subtitle")?{subtitle:L.text("subtitle")}:{},...L?.numeric("colspan")!==void 0?{colspan:L.numeric("colspan")}:{},...L?.has("break")?{break:!0}:{},...L?.has("borderless")?{borderless:!0}:{}})}const w=$g(r,n),b={},v=d?.tag("givens");for(const x of Object.keys(v?.dict??{})){const _=v?.text(x);_!==void 0&&(b[x]=_)}const p=l?.tag("dashboard")?.numeric("columns");return{ok:!0,document:{title:d?.text("title")??"",...s?{description:s}:{},...p===void 0?{}:{columns:p},...d?.has("autorun")?{autorun:d.isTrue("autorun")}:{},imports:c,sources:h,...w?{localGivens:w}:{},...Object.keys(b).length>0?{startingGivens:b}:{},...f.length>0?{drills:f}:{},tiles:m}}}const Gs=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 Eg(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
72
+ `&&t.push(n+1);return t}function Dg(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 Pd(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=${_n(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${_n(e.subtitle)}`),t}function ni(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Pg=new Set(["colspan","break","borderless","label","subtitle"]),Cg=new Set(["label","description","control","suggest","range_min","range_max"]),Mg=(e,t)=>me(e.imports)===me(t.imports);function Fa(e){const t=[];if(e.label!==void 0&&t.push(`label=${_n(e.label)}`),e.description!==void 0&&t.push(`description=${_n(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 Ba=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function wi(e,t){let n=0,r=!1;for(let i=t;i<e.length;i++){for(const s of e[i])s==="{"?(n++,r=!0):s==="}"&&n--;if(r&&n<=0||!r&&i===t)return i}return e.length-1}const Na=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Ig(e,t,n){const r=e.findIndex(o=>new RegExp(`\\bsource:\\s*${Na(t)}\\s+is\\b`).test(o));if(r<0)return-1;const i=wi(e,r),s=new RegExp(`\\bview:\\s*${Na(n)}\\s+is\\b`);for(let o=r;o<=i;o++)if(s.test(e[o]))return o;return-1}function Ga(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const ki=e=>`${e.source}.${e.name}`,_n=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Vs=e=>me([e.name,e.source,e.declaration]),pt=Vs,Va=e=>me(e.tiles.map(pt));function jg(e,t){const n=new Set(e.tiles.map(pt)),r=new Set(t.tiles.map(pt)),i=e.tiles.filter(c=>!r.has(pt(c))),s=t.tiles.filter(c=>!n.has(pt(c))),a=i.length>0||s.length>0||Va(e)!==Va(t);for(const c of s)if(c.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${c.name}\` is ${c.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const l=new Map(e.sources.map(c=>[c.name,c])),d=new Set(e.imports.flatMap(c=>c.kind==="names"?c.names:[]));for(const c of e.sources)d.add(c.base);const u=t.sources.filter(c=>!l.has(c.name));for(const c of e.sources){const h=t.sources.find(f=>f.name===c.name);if(!h||h.base!==c.base)return{ok:!1,reason:`The source \`${c.name}\` cannot be changed or removed here.`}}for(const c of u){if(!s.some(h=>h.source===c.name))return{ok:!1,reason:`A new source \`${c.name}\` needs a tile on it.`};if(!d.has(c.base))return{ok:!1,reason:`\`${c.base}\` is not imported by name in this file, so a tile cannot be put on it. The builder does not add imports: import { ${c.base} } from the model first.`}}return Mg(e,t)?{currentKeys:n,nextKeys:r,removedTiles:i,addedTiles:s,newSources:u,currentSources:l,reordered:a}:{ok:!1,reason:"The dashboard's imports cannot be changed here."}}function Ag(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const l=j.artifactLine(t);if(l<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const d=[...t[l].matchAll(/"([^"]+)"/g)].map(g=>g[1]),u=new Map;for(const g of d){const m=g.split("->").map(w=>w.trim());m.length===2&&u.set(`${m[0]}->${m[1]}`,g)}const c=r.tiles.map(g=>u.get(`${g.source}->${g.name}`)??(o.has(pt(g))&&!s.has(pt(g))?`${g.source} -> ${g.name}`:void 0));if(c.some(g=>g===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const h=`tiles=[${c.map(g=>`"${g}"`).join(", ")}]`,f=t[l].replace(/tiles\s*=\s*\[[\s\S]*?\]/,h);f!==t[l]&&a.push({...n(l),text:`${f}
73
+ `})}}function Rg(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=j.artifactLine(t);if(o<0)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=s.find(m=>m.start===n(o).start&&m.end===n(o).end);let l=a?a.text.replace(/\n$/,""):t[o];const d=l.indexOf("artifact"),u=l.indexOf("{",d);let c=0,h=-1;for(let m=u;m<l.length;m++)if(l[m]==="{")c++;else if(l[m]==="}"&&--c===0){h=m;break}if(u<0||h<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let f=l.slice(u+1,h);const g=(m,w)=>{const b=new RegExp(`\\s*\\b${m}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);w===void 0?f=f.replace(b,""):b.test(f)?f=f.replace(b,` ${m}=${w}`):f=`${f.replace(/\s+$/,"")} ${m}=${w} `};if(r.title!==i.title&&g("title",i.title?_n(i.title):void 0),r.autorun!==i.autorun&&g("autorun",i.autorun===void 0?void 0:String(i.autorun)),me(r.startingGivens)!==me(i.startingGivens)){f=f.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const m=Object.entries(i.startingGivens??{});m.length>0&&(f=`${f.replace(/\s+$/,"")} givens { ${m.map(([w,b])=>`${w}=${_n(b)}`).join(" ")} }`)}f=f.replace(/\s{2,}/g," "),l=`${l.slice(0,u+1)}${f.startsWith(" ")?f:` ${f}`}${f.endsWith(" ")?"":" "}${l.slice(h)}`,r.columns!==i.columns&&(l=l.replace(/\s*dashboard\s*\{[^}]*\}/,""),i.columns!==void 0&&(l=`${l.trimEnd()} dashboard { columns=${i.columns} }`)),a?a.text=`${l}
74
+ `:s.push({...n(o),text:`${l}
75
+ `})}if(r.description!==i.description){const o=t.map((l,d)=>l.trim().startsWith('##"')?d:-1).filter(l=>l>=0),a=(i.description??"").split(`
76
+ `).map(l=>l.trim()===""?'##"':`##" ${l.trim()}`).join(`
77
+ `);if(o.length>0){const l=o[0],d=o[o.length-1];s.push({start:n(l).start,end:n(d).end,text:i.description===void 0?"":`${a}
78
+ `})}else if(i.description!==void 0){const l=j.artifactLine(t),d=n(l).start;s.push({start:d,end:d,text:`${a}
79
+ `})}}}function Lg(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o}=e,a=new Map((i.localGivens??[]).map(h=>[h.name,h])),l=new Map((s.localGivens??[]).map(h=>[h.name,h])),d=j.givenDeclarations(t),u=new Set;for(const[h,f]of a){const g=l.get(h);if(g!==void 0&&me(g)===me(f))continue;const m=d.get(h);if(m===void 0)return{ok:!1,reason:`Could not find where the given \`${h}\` is declared.`};const{tags:w}=Nt(t,m.line),b=g===void 0?w:w.filter(O=>{const T=ni(O.text);return T!==void 0&&Cg.has(T)});for(const O of b)o.push({...n(O.line),text:""}),u.add(O.line);if(g===void 0){o.push({...n(m.line),text:""}),u.add(m.line);const O=Math.min(m.line,...w.map(L=>L.line)),T=m.blockHeader??O,E=(t[m.line+1]??"x").trim()==="",I=T===0||t[T-1].trim()==="",D=m.blockHeader===void 0||![...d.values()].some(L=>L.blockHeader===m.blockHeader&&L.line>m.line&&l.has([...d.entries()].find(([,M])=>M===L)?.[0]??""));E&&I&&D&&!u.has(m.line+1)&&(o.push({...n(m.line+1),text:""}),u.add(m.line+1));continue}const v=r(m.line),p=Fa(g),_=g.type!==f.type||g.default!==f.default?m.blockHeader===void 0?Ba(g):`${g.name} :: ${g.type} is ${g.default}`:t[m.line].trim();o.push({...n(m.line),text:(p?`${v}${p}
80
80
  `:"")+`${v}${_}
81
- `})}for(const[f,g]of d){if(g.blockHeader===void 0||c.has(f))continue;![...d.values()].some(m=>m.blockHeader===g.blockHeader&&!u.has(m.line))&&!u.has(g.blockHeader)&&(o.push({...n(g.blockHeader),text:""}),u.add(g.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)),g=(()=>{let v=-1;for(let p=0;p<t.length;p++){const x=t[p].trim();(x.startsWith("import ")||v>=0&&/^}\s*from\s/.test(x))&&(v=p)}return v})(),h=f>=0?f:g,m=l.map(v=>{const p=Ra(v);return(p?`${p}
82
- `:"")+`${La(v)}
81
+ `})}for(const[h,f]of d){if(f.blockHeader===void 0||l.has(h))continue;![...d.values()].some(m=>m.blockHeader===f.blockHeader&&!u.has(m.line))&&!u.has(f.blockHeader)&&(o.push({...n(f.blockHeader),text:""}),u.add(f.blockHeader))}const c=[...l.values()].filter(h=>!a.has(h.name));if(c.length>0){const h=Math.max(-1,...[...d.values()].map(v=>v.line)),f=(()=>{let v=-1;for(let p=0;p<t.length;p++){const x=t[p].trim();(x.startsWith("import ")||v>=0&&/^}\s*from\s/.test(x))&&(v=p)}return v})(),g=h>=0?h:f,m=c.map(v=>{const p=Fa(v);return(p?`${p}
82
+ `:"")+`${Ba(v)}
83
83
  `}).join(`
84
- `),w=h>=0?n(h).end:n(0).end;o.push({start:w,end:w,text:`
84
+ `),w=g>=0?n(g).end:n(0).end;o.push({start:w,end:w,text:`
85
85
  ${m}`}),t.some(v=>v.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
86
- `})}}function Lg(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o}=e,a=new Map((i.drills??[]).map(d=>[fi(d),d])),c=new Map((s.drills??[]).map(d=>[fi(d),d]));for(const d of new Set([...a.keys(),...c.keys()])){const u=a.get(d),l=c.get(d);if(u&&l&&pe(u)===pe(l))continue;const f=l??u;if(l&&l.to.length===0)return{ok:!1,reason:`The drill on \`${d}\` names no destination.`};const g=j.declarationsUnder(t,f.source,"dimension").get(f.name);if(g===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:h}=Lt(t,g.line),m=h.find(b=>/^#\s*drill\b/.test(b.text)),w=r(g.line);if(l===void 0)m&&o.push({...n(m.line),text:""});else if(m)o.push({...n(m.line),text:`${w}${Wa(l)}
87
- `});else{const b=n(g.line).start;o.push({start:b,end:b,text:`${w}${Wa(l)}
88
- `})}}}function zg(e){const{lines:t,wholeLine:n,removedTiles:r,edits:i}=e;for(const s of r){if(s.declaration.kind==="inherited")continue;const o=j.declarationLine(t,"view",s.name);if(o<0)return{ok:!1,reason:`Could not find where \`${s.name}\` is declared.`};const a=ui(t,o),{tags:c}=Lt(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 Wg(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 g=d.get(f.source)??[];g.push(f),d.set(f.source,g)}const u=(f,g)=>{const h=f.declaration.kind==="reference"?f.declaration.from:f.name,m=(f.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...$d(f).map(w=>`${g}${w}`),`${g}view: ${f.name} is ${h}${m?` + { ${m} }`:""}`].join(`
89
- `)};let l=-1;for(const f of i.sources){const g=j.declarationLine(n,"source",f.name);g>=0&&(l=Math.max(l,ui(n,g)))}for(const[f,g]of d)if(a.has(f)){const h=j.declarationLine(n,"source",f);if(h<0)return{ok:!1,reason:`Could not find where the source \`${f}\` is declared.`};const m=ui(n,h);let w=" ";for(let p=h+1;p<m;p++){const x=/^(\s+)view:/.exec(n[p]);if(x){w=x[1];break}}const b=r(m).start,v=(n[m-1]??"").trim()==="";c.push({start:b,end:b,text:(v?"":`
90
- `)+g.map(p=>u(p,w)).join(`
86
+ `})}}function zg(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o}=e,a=new Map((i.drills??[]).map(d=>[ki(d),d])),l=new Map((s.drills??[]).map(d=>[ki(d),d]));for(const d of new Set([...a.keys(),...l.keys()])){const u=a.get(d),c=l.get(d);if(u&&c&&me(u)===me(c))continue;const h=c??u;if(c&&c.to.length===0)return{ok:!1,reason:`The drill on \`${d}\` names no destination.`};const f=j.declarationsUnder(t,h.source,"dimension").get(h.name);if(f===void 0)return{ok:!1,reason:`\`${h.name}\` is not a dimension \`${h.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:g}=Nt(t,f.line),m=g.find(b=>/^#\s*drill\b/.test(b.text)),w=r(f.line);if(c===void 0)m&&o.push({...n(m.line),text:""});else if(m)o.push({...n(m.line),text:`${w}${Ga(c)}
87
+ `});else{const b=n(f.line).start;o.push({start:b,end:b,text:`${w}${Ga(c)}
88
+ `})}}}function Wg(e){const{lines:t,wholeLine:n,removedTiles:r,edits:i}=e;for(const s of r){if(s.declaration.kind==="inherited")continue;const o=j.declarationLine(t,"view",s.name);if(o<0)return{ok:!1,reason:`Could not find where \`${s.name}\` is declared.`};const a=wi(t,o),{tags:l}=Nt(t,o),d=Math.min(o,...l.map(c=>c.line));for(const c of l)i.push({...n(c.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 Fg(e){const{sourceText:t,lines:n,wholeLine:r,current:i,addedTiles:s,newSources:o,currentSources:a,edits:l}=e,d=new Map;for(const h of s){const f=d.get(h.source)??[];f.push(h),d.set(h.source,f)}const u=(h,f)=>{const g=h.declaration.kind==="reference"?h.declaration.from:h.name,m=(h.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...Pd(h).map(w=>`${f}${w}`),`${f}view: ${h.name} is ${g}${m?` + { ${m} }`:""}`].join(`
89
+ `)};let c=-1;for(const h of i.sources){const f=j.declarationLine(n,"source",h.name);f>=0&&(c=Math.max(c,wi(n,f)))}for(const[h,f]of d)if(a.has(h)){const g=j.declarationLine(n,"source",h);if(g<0)return{ok:!1,reason:`Could not find where the source \`${h}\` is declared.`};const m=wi(n,g);let w=" ";for(let p=g+1;p<m;p++){const x=/^(\s+)view:/.exec(n[p]);if(x){w=x[1];break}}const b=r(m).start,v=(n[m-1]??"").trim()==="";l.push({start:b,end:b,text:(v?"":`
90
+ `)+f.map(p=>u(p,w)).join(`
91
91
 
92
92
  `)+`
93
- `})}else{const h=o.find(p=>p.name===f);if(!h)return{ok:!1,reason:`The tile's source \`${f}\` is not declared.`};const m=`
94
- source: ${h.name} is ${h.base} extend {
95
- `+g.map(p=>u(p," ")).join(`
93
+ `})}else{const g=o.find(p=>p.name===h);if(!g)return{ok:!1,reason:`The tile's source \`${h}\` is not declared.`};const m=`
94
+ source: ${g.name} is ${g.base} extend {
95
+ `+f.map(p=>u(p," ")).join(`
96
96
 
97
97
  `)+`
98
98
  }
99
- `;let w=l;if(w<0)for(let p=0;p<n.length;p++){const x=n[p].trim();(/^(import\s|given:|}\s*from\s)/.test(x)||/^[A-Z_]+\s*::/.test(x))&&(w=p)}const b=w>=0?r(w).end:t.length,v=b===t.length&&!t.endsWith(`
99
+ `;let w=c;if(w<0)for(let p=0;p<n.length;p++){const x=n[p].trim();(/^(import\s|given:|}\s*from\s)/.test(x)||/^[A-Z_]+\s*::/.test(x))&&(w=p)}const b=w>=0?r(w).end:t.length,v=b===t.length&&!t.endsWith(`
100
100
  `)?`
101
- `:"";c.push({start:b,end:b,text:v+m}),l=w}}function Fg(e){const{lines:t,starts:n,wholeLine:r,indentOf:i,current:s,next:o,edits:a}=e,c=new Map(s.tiles.map(d=>[at(d),d]));for(const d of o.tiles){const u=c.get(at(d));if(u===void 0||pe(u)===pe(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=Cg(t,d.source,d.name);if(l<0)return{ok:!1,reason:`Could not find where \`${d.name}\` is declared inside \`${d.source}\`.`};const{tags:f}=Lt(t,l),g=i(l),h=$d(d),m=new Map(h.map(D=>[Hr(D)??D,D])),w=new Set;for(const D of f){const I=Hr(D.text);if(I===void 0||!Eg.has(I))continue;const C=m.get(I);if(C===void 0){a.push({...r(D.line),text:""});continue}w.add(I),C!==D.text&&a.push({...r(D.line),text:`${g}${C}
102
- `})}const b=h.filter(D=>!w.has(Hr(D)??D));if(b.length>0){const D=n[l];a.push({start:D,end:D,text:b.map(I=>`${g}${I}
103
- `).join("")})}const p=(/\+\s*\{([\s\S]*)\}\s*$/.exec(t[l])?.[1]??"").replace(Sd,"").replace(/\s*,\s*,\s*/g,", ").replace(/^[\s,;]+|[\s,;]+$/g,""),x=(d.filters??[]).map(D=>`where: ${D.field} ${D.op??"~"} $${D.given}`),_=[...p?[p]:[],...x],$=t[l].replace(/\s*\+\s*\{[\s\S]*\}\s*$/,""),T=_.length===0?$:`${$} + { ${_.join(", ")} }`;T!==t[l]&&a.push({...r(l),text:`${T}
104
- `})}}async function Rs(e,t){const n=await di(e);if(ci(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=Ig(r,t);if("reason"in i)return i;const s=e.split(`
105
- `),o=Tg(e),a=h=>({start:o[h],end:h+1<o.length?o[h+1]:e.length}),c=h=>/^\s*/.exec(s[h])?.[0]??"",d=[],u={...i,sourceText:e,lines:s,starts:o,wholeLine:a,indentOf:c,current:r,next:t,edits:d};for(const h of[jg,Ag,Rg,Lg,zg,Wg,Fg]){const m=h(u);if(m)return m}const l=h=>{const{drills:m,localGivens:w,...b}=h,v=h.tiles.map(p=>{if(p.filters?.length)return p;const{filters:x,..._}=p;return _});return{...b,tiles:v,...m?.length?{drills:[...m].sort((p,x)=>fi(p).localeCompare(fi(x)))}:{},...w?.length?{localGivens:w}:{}}};if(d.length===0)return pe(l(r))!==pe(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=Dg(e,d),g=await di(f);return ci(g)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${g.reason}`}:pe(l(g.document))!==pe(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 Bg(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(b=>{o(void 0),n(v=>{const p=structuredClone(v.stack[v.index]);if(b(p),JSON.stringify(p)===JSON.stringify(v.stack[v.index]))return v;const _=[...v.stack.slice(0,v.index+1),p].slice(-100);return{stack:_,index:_.length-1}})},[]),l=S.useCallback(()=>{o(void 0),n(b=>b.index>0?{...b,index:b.index-1}:b)},[]),f=S.useCallback(()=>{o(void 0),n(b=>b.index<b.stack.length-1?{...b,index:b.index+1}:b)},[]),g=S.useCallback(async()=>{const b=await Rs(r,d);if(js(b))return o(b.reason),{ok:!1,reason:b.reason};try{await e.onSave?.(b.source)}catch(v){const p=`Could not save: ${v}`;return o(p),{ok:!1,reason:p}}return i(b.source),c(d),o(void 0),{ok:!0}},[d,e,r]),h=S.useMemo(()=>JSON.stringify(d)!==JSON.stringify(a),[d,a]),m=S.useMemo(()=>{const b=new Set(a.tiles.map(As)),v=new Set(d.tiles.map(As));return[...b].some(p=>!v.has(p))||[...v].some(p=>!b.has(p))},[d,a]),w=S.useCallback(async()=>{const b=await Rs(r,d);return js(b)?{ok:!1,reason:b.reason}:{ok:!0,source:b.source}},[d,r]);return{document:d,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:h,...s===void 0?{}:{error:s},update:u,undo:l,redo:f,save:g,preview:w,structural:m}}function Od({source:e,document:t,onSave:n,onChange:r,renderTile:i,controls:s,givens:o,catalog:a,toolbar:c,dashboards:d,onEvent:u,savesTo:l="package"}){const f=Bg({source:e,document:t,...n?{onSave:n}:{}}),[g,h]=S.useState(void 0),[m,w]=S.useState(!1),b=f.document.columns??j.DEFAULT_COLUMNS,{resize:v,gridBox:p,startResize:x,onResize:_,endResize:$}=yg({tiles:f.document.tiles,columns:b,onStart:h,commit:(O,E)=>f.update(z=>{z.tiles[O].colspan=E})}),{dragging:T,preview:D,onDragStart:I,onDragOver:C,onDragEnd:P}=mg({tiles:f.document.tiles,commit:O=>f.update(E=>{E.tiles=O}),onLanded:h}),[A,R]=S.useState(void 0),[U,Te]=S.useState(void 0),[De,me]=S.useState(!1),[X,Ye]=S.useState(void 0),[Ze,ye]=S.useState(null),[Me,Ge]=S.useState(void 0);S.useEffect(()=>{r?.(f.document)},[f.document,r]);const Y=S.useMemo(()=>gp(f.document),[f.document]),ee=S.useMemo(()=>{const O=new Set((t.localGivens??[]).map(E=>E.name));return(o??[]).filter(E=>!O.has(E.name))},[t,o]),H=S.useMemo(()=>Fh(f.document,ee),[f.document,ee]),he=S.useMemo(()=>new Map(f.document.sources.map(O=>[O.name,xa(a,O.base)])),[a,f.document.sources]),W=S.useCallback(O=>he.get(O.source)??xa(a,O.source),[he,a]),K=(O,E)=>{const z=[];for(const J of f.document.tiles){const He=W(J);if(!He)continue;const we=new Map(He.map(Ce=>[Ce.name,Ce.type]));for(const Ce of J.filters??[])Ce.given===O&&(!we.has(Ce.field)||!Vr(E,we.get(Ce.field)))&&z.push(`${Ce.field} on ${J.label??J.name} (${f.document.sources.find(st=>st.name===J.source)?.base??J.source})`)}return z},_e=S.useMemo(()=>H.filter(O=>O.origin==="model"&&O.boundTiles===0),[H]),ne=S.useCallback(()=>{Ge(void 0),w(!0);const O=j.now(),{structural:E}=f,z=f.document.tiles.length;f.save().then(J=>{J.ok===!0?u?.({type:"dashboard.saved",tiles:z,structural:E,where:l,durationMs:j.now()-O}):u?.({type:"dashboard.save_refused",reason:J.reason})}).finally(()=>w(!1))},[f,u,l]),Ve=S.useCallback(()=>{if(!(!n||!f.dirty||m)){if(!f.structural){ne();return}f.preview().then(O=>{O.ok?Ge({before:f.source,after:O.source}):ne()})}},[n,f,m,ne]),re=O=>{me(!1),f.update(E=>{let z=E.sources.find(we=>we.base===O.base);if(!z){const we=new Set(E.sources.map(st=>st.name));let Ce=`${O.base}_tiles`;for(let st=2;we.has(Ce);st++)Ce=`${O.base}_tiles_${st}`;z={name:Ce,base:O.base},E.sources.push(z)}const J=new Set(E.tiles.filter(we=>we.source===z.name).map(we=>we.name));let He=`${O.view}_tile`;for(let we=2;J.has(He);we++)He=`${O.view}_tile_${we}`;E.tiles.push({name:He,source:z.name,declaration:{kind:"reference",from:O.view},colspan:O.colspan,...O.label?{label:O.label}:{}})}),h(f.document.tiles.length)},ft=O=>{Te(void 0),h(void 0),f.update(E=>{E.tiles.splice(O,1)})};ep(S.useMemo(()=>({undo:f.undo,redo:f.redo,...n?{save:Ve}:{},escape:()=>{!U&&!A&&h(void 0)},nudge:O=>{if(g===void 0)return;const E=f.document.tiles[g];if(!E||E.declaration.kind==="inherited")return;const z=Math.min(Math.max((E.colspan??1)+O,1),b);z!==(E.colspan??1)&&f.update(J=>{J.tiles[g].colspan=z})}}),[f,n,Ve,U,A,g,b]));const Je=(O,E,z)=>{R(void 0),f.update(J=>{z&&qh(J,z),Kh(J,O,E)})},Nt=O=>{R(void 0),f.update(E=>Uh(E,O))},M=(()=>{const O=f.document.tiles;return v!==void 0?O.map((E,z)=>z===v.index?{...E,colspan:v.span}:E):D??O})(),L=T?_p(M,b):M.map(ud);return y.jsxs(k.Stack,{sx:{gap:0},children:[y.jsx(tp,{canUndo:f.canUndo,canRedo:f.canRedo,onUndo:f.undo,onRedo:f.redo,dirty:f.dirty,saving:m,...n?{onSave:Ve}:{},...c?{actions:c}:{},...a?{onAddTile:()=>me(!0)}:{},onSettings:ye}),y.jsxs(k.Stack,{sx:{gap:2,px:"4px",pb:"4px"},children:[y.jsx(j.DashboardProse,{title:f.document.title||"Untitled dashboard",...f.document.description?{description:f.document.description}:{}}),y.jsx(yp,{controls:H,tileCount:f.document.tiles.length,unknownFieldsOf:K,onEdit:O=>R({control:O}),onAdd:()=>R({}),children:s}),f.error&&y.jsx(k.Alert,{severity:"warning",children:f.error}),y.jsx(kh,{sensors:Qp,onDragStart:I,onDragOver:C,onDragEnd:P,children:y.jsxs(k.Box,{ref:p,sx:{position:"relative"},children:[(v!==void 0||T)&&y.jsx(lg,{columns:b}),y.jsx(j.DashboardGrid,{tiles:L,columns:b,keyOf:O=>O.kind==="gap"?fd(O.after):ot(O.tile),renderTile:O=>{if(O.kind==="gap")return y.jsx(ag,{after:O.after});const{tile:E,index:z}=O;return y.jsx(sg,{tile:E,index:z,selected:z===g,menuOpen:U?.index===z,resizeSpan:v?.index===z?v.span:void 0,columns:b,onSelect:()=>h(z),onOpenMenu:J=>{h(z),Te({anchor:J,index:z})},onResizeStart:J=>x(J,z),onResizeMove:_,onResizeEnd:$,children:i?i(E):y.jsx(og,{tile:E})})}})]})}),y.jsx(pp,{open:A!==void 0,document:f.document,...A?.control?{control:A.control}:{},available:_e,...a?{fieldsFor:W}:{},onClose:()=>R(void 0),onApply:Je,onRemove:Nt}),y.jsx(bg,{anchor:U?.anchor??null,tile:U===void 0?void 0:f.document.tiles[U.index],onClose:()=>Te(void 0),onCommit:O=>{const E=U?.index;E!==void 0&&f.update(z=>{z.tiles[E]=O})},onRemove:()=>{U!==void 0&&ft(U.index)},columns:b,onDrills:()=>{U!==void 0&&Ye(f.document.tiles[U.index]?.source)}}),y.jsx(fp,{open:X!==void 0,document:f.document,source:f.document.sources.find(O=>O.name===X),givenNames:H.map(O=>O.name),dashboards:d??[],onClose:()=>Ye(void 0),onApply:O=>f.update(E=>{const J=[...(E.drills??[]).filter(He=>He.source!==X),...O];J.length===0?delete E.drills:E.drills=J})}),y.jsx(vp,{anchor:Ze,settings:Y,onClose:()=>ye(null),onCommit:O=>f.update(E=>{E.title=O.title,O.description===void 0?delete E.description:E.description=O.description,O.columns===void 0?delete E.columns:E.columns=O.columns,O.autorun===void 0?delete E.autorun:E.autorun=O.autorun})}),y.jsx(lp,{open:De,document:f.document,catalog:a,columns:b,onClose:()=>me(!1),onAdd:re}),y.jsx(up,{open:Me!==void 0,before:Me?.before??"",after:Me?.after??"",onConfirm:ne,onClose:()=>Ge(void 0)})]})]})}function Ng(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(Gg(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 Gg(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 Vg(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=j.malloyLiteral(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}}async function Hg(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}const Ba=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function Kg({environmentName:e,packageName:t,dashboardName:n,onExit:r,onEvent:i}){const{apiClients:s,mutable:o}=Pe.useServer(),a=Wd.useQueryClient(),c=S.useRef(j.now()),d=S.useRef(i);d.current=i;const u=j.useOptionalDocumentStorage()?.documentStorage,l=`dashboards/${n}.malloy`,f=j.useQueryWithApiError({queryKey:["dashboard-editor-model",e,t,l],queryFn:()=>s.models.getModel(e,t,l)}),g=f.data?.data?.sourceText,[h,m]=S.useState(void 0);S.useEffect(()=>{if(g===void 0)return;let Y=!1;return Hg(g).then(ee=>{Y||m(ee)}),()=>{Y=!0}},[g]);const[w,b]=S.useState(void 0),[v,p]=S.useState(void 0),[x,_]=S.useState(u===void 0),[$,T]=S.useState(!1);S.useEffect(()=>{if(!u)return;let Y=!1;return(async()=>{const H=(await u.listWorkspaces(!0))[0]?.name;if(Y)return;if(b(H),H===void 0){_(!0);return}const he=await u.getDocument(Ba(H,e,t,l)).catch(()=>{});Y||(p(he),T(he!==void 0),_(!0))})(),()=>{Y=!0}},[u,e,t,l]);const[D,I]=S.useState(void 0),C=D===!0&&v!==void 0,P=C?v:g,A=S.useRef("package");A.current=C?"draft":"package";const[R,U]=S.useState(void 0),[Te,De]=S.useState(void 0),me=S.useRef(void 0);S.useEffect(()=>{if(P===void 0||P===me.current)return;let Y=!1;return di(P).then(ee=>{if(!Y){if(ci(ee)){const H=ee.line?`${ee.reason} (line ${ee.line})`:ee.reason;De(H),d.current?.({type:"dashboard.open_refused",reason:H});return}De(void 0),U(H=>({source:P,document:ee.document,generation:(H?.generation??0)+1})),d.current?.({type:"dashboard.opened",from:A.current,tiles:ee.document.tiles.length,durationMs:j.now()-c.current})}}),()=>{Y=!0}},[P]);const X=w===void 0?void 0:Ba(w,e,t,l),Ye=S.useCallback(async Y=>{if(!u||!X)throw new Error("This host keeps no documents, so there is nowhere to save.");await u.saveDocument(X,Y),p(Y),I(ee=>ee??!1)},[u,X]),Ze=S.useCallback(async Y=>{if(h===void 0)throw new Error("The package file is still loading; try again.");let ee;try{ee=await s.models.updateModelSource(e,t,l,{source:Y,expectedHash:h})}catch(H){throw new Error(Ug(H))}me.current=Y,m(ee.data.contentHash),u&&X&&(await u.deleteDocument(X).catch(()=>{}),p(void 0),T(!1)),I(H=>H??!1),await a.invalidateQueries({queryKey:["dashboard-editor-model",e,t,l]});for(const H of["dashboard-editor-manifest","dashboards","dashboard"])a.invalidateQueries({queryKey:[H]})},[s,e,t,l,h,u,X,a]),ye=o?Ze:u&&X?Ye:void 0,Me=Y=>{c.current=j.now(),I(Y)};if(f.isError)return y.jsx(j.ApiErrorDisplay,{error:f.error,context:"Opening the dashboard"});if(!g||!x)return y.jsxs(k.Stack,{sx:{gap:2},children:[y.jsx(j.DashboardBar,{}),y.jsx(j.Loading,{text:"Opening the dashboard…"})]});if(Te)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",Te]});const Ge=v!==void 0&&v!==g;return y.jsxs(k.Stack,{sx:{gap:2},children:[$&&Ge&&D===void 0&&y.jsx(k.Alert,{severity:"info",action:y.jsxs(k.Stack,{direction:"row",sx:{gap:1},children:[y.jsx(k.Button,{size:"small",onClick:()=>Me(!0),children:"Resume"}),y.jsx(k.Button,{size:"small",onClick:()=>Me(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),R&&y.jsx(qg,{environmentName:e,packageName:t,modelPath:l,slug:n,opened:R,onSave:ye,savesTo:o?"package":"browser",...i?{onEvent:i}:{},toolbar:r&&y.jsx(j.SecondaryButton,{label:"Done editing",icon:y.jsx(j.CheckIcon,{}),onClick:r}),note:o?"Save writes the file into the package.":u?"Saved in this browser: this server does not take writes.":"This server does not take writes."},R.generation)]})}function qg({environmentName:e,packageName:t,modelPath:n,slug:r,opened:i,onSave:s,onEvent:o,savesTo:a,toolbar:c,note:d}){const{apiClients:u}=Pe.useServer(),{data:l,isSuccess:f}=j.useQueryWithApiError({queryKey:["dashboard-editor-manifest",e,t,r],queryFn:()=>u.dashboards.getDashboard(e,t,r,void 0)}),g=l?.data,{data:h}=j.useQueryWithApiError({queryKey:["dashboard-editor-dashboards",e,t],queryFn:()=>u.dashboards.listDashboards(e,t,void 0)}),m=S.useMemo(()=>(h?.data??[]).map(P=>P.name).filter(P=>!!P&&P!==r),[h,r]),w=S.useMemo(()=>{const P=n.slice(0,n.lastIndexOf("/")+1),A=new Set;for(const R of i.document.imports){const U=new URL(R.from,`https://malloy.invalid/${P}`);A.add(U.pathname.slice(1))}return[...A]},[i.document.imports,n]),{data:b}=j.useQueryWithApiError({queryKey:["dashboard-editor-catalog",e,t,...w],queryFn:async()=>{const P=await Promise.all(w.map(A=>u.models.getModel(e,t,A).then(R=>R.data)));return ld(P)},enabled:w.length>0}),[v,p]=S.useState(i.document);S.useEffect(()=>p(i.document),[i.document]);const x=S.useMemo(()=>g?.givens??[],[g]),_=S.useMemo(()=>new Set(x.map(P=>P.name).filter(P=>P!==void 0)),[x]),$=S.useMemo(()=>Ng(v,x),[v,x]),{declaredTypes:T,applied:D,panel:I}=j.useDocumentControls({specs:$,loaded:f,startingValues:g?.startingGivens,documentKey:`${e}/${t}/${r}/edit`,autorun:g?.autorun!==!1,environmentName:e,packageName:t,modelPath:g?.path,documentName:r}),C=S.useMemo(()=>function(A){const R=Vg(v,A,_,D);return y.jsx(j.DashboardTile,{environmentName:e,packageName:t,modelPath:n,tile:R.expression,label:A.label??j.tileTitle(`${A.source} -> ${A.name}`),subtitle:A.subtitle,borderless:A.borderless,givens:D,declaredTypes:T,givenNames:R.givenNames,height:j.TILE_MAX_HEIGHT})},[v,_,e,t,n,D,T]);return y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsx(Od,{source:i.source,document:i.document,renderTile:C,givens:$.filter(P=>P.name!==void 0).map(P=>({name:P.name,...P.label?{label:P.label}:{},...P.type?{type:P.type}:{},...P.suggest?.dimension?{field:P.suggest.dimension}:{}})),onChange:p,...b?{catalog:b}:{},dashboards:m,...o?{onEvent:o}:{},toolbar:c,controls:f?y.jsx(j.GivensPanel,{...I,layout:"bar"}):void 0,...s?{onSave:s}:{},savesTo:a}),y.jsx(k.Box,{sx:{px:.5},children:y.jsx(k.Typography,{variant:"caption",sx:{opacity:.7},children:d})})]})}function Ug(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}typeof globalThis.process>"u"?globalThis.process={env:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.DashboardBuilder=Od;exports.DashboardEditor=Kg;exports.buildCatalog=ld;exports.readDashboardDocument=di;exports.readFailed=ci;exports.spliceDashboardDocument=Rs;exports.spliceFailed=js;
101
+ `:"";l.push({start:b,end:b,text:v+m}),c=w}}function Bg(e){const{lines:t,starts:n,wholeLine:r,indentOf:i,current:s,next:o,edits:a}=e,l=new Map(s.tiles.map(d=>[pt(d),d]));for(const d of o.tiles){const u=l.get(pt(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 c=Ig(t,d.source,d.name);if(c<0)return{ok:!1,reason:`Could not find where \`${d.name}\` is declared inside \`${d.source}\`.`};const{tags:h}=Nt(t,c),f=i(c),g=Pd(d),m=new Map(g.map(E=>[ni(E)??E,E])),w=new Set;for(const E of h){const I=ni(E.text);if(I===void 0||!Pg.has(I))continue;const D=m.get(I);if(D===void 0){a.push({...r(E.line),text:""});continue}w.add(I),D!==E.text&&a.push({...r(E.line),text:`${f}${D}
102
+ `})}const b=g.filter(E=>!w.has(ni(E)??E));if(b.length>0){const E=n[c];a.push({start:E,end:E,text:b.map(I=>`${f}${I}
103
+ `).join("")})}const p=(/\+\s*\{([\s\S]*)\}\s*$/.exec(t[c])?.[1]??"").replace(Dd,"").replace(/\s*,\s*,\s*/g,", ").replace(/^[\s,;]+|[\s,;]+$/g,""),x=(d.filters??[]).map(E=>`where: ${E.field} ${E.op??"~"} $${E.given}`),_=[...p?[p]:[],...x],O=t[c].replace(/\s*\+\s*\{[\s\S]*\}\s*$/,""),T=_.length===0?O:`${O} + { ${_.join(", ")} }`;T!==t[c]&&a.push({...r(c),text:`${T}
104
+ `})}}async function Hs(e,t){const n=await _i(e);if(xi(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=jg(r,t);if("reason"in i)return i;const s=e.split(`
105
+ `),o=Eg(e),a=g=>({start:o[g],end:g+1<o.length?o[g+1]:e.length}),l=g=>/^\s*/.exec(s[g])?.[0]??"",d=[],u={...i,sourceText:e,lines:s,starts:o,wholeLine:a,indentOf:l,current:r,next:t,edits:d};for(const g of[Ag,Rg,Lg,zg,Wg,Fg,Bg]){const m=g(u);if(m)return m}const c=g=>{const{drills:m,localGivens:w,...b}=g,v=g.tiles.map(p=>{if(p.filters?.length)return p;const{filters:x,..._}=p;return _});return{...b,tiles:v,...m?.length?{drills:[...m].sort((p,x)=>ki(p).localeCompare(ki(x)))}:{},...w?.length?{localGivens:w}:{}}};if(d.length===0)return me(c(r))!==me(c(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 h=Dg(e,d),f=await _i(h);return xi(f)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${f.reason}`}:me(c(f.document))!==me(c(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:h}}function Ng(e){const[t,n]=S.useState({stack:[e.document],index:0}),[r,i]=S.useState(e.source),[s,o]=S.useState(void 0),[a,l]=S.useState(e.document),d=t.stack[t.index],u=S.useCallback(b=>{o(void 0),n(v=>{const p=structuredClone(v.stack[v.index]);if(b(p),JSON.stringify(p)===JSON.stringify(v.stack[v.index]))return v;const _=[...v.stack.slice(0,v.index+1),p].slice(-100);return{stack:_,index:_.length-1}})},[]),c=S.useCallback(()=>{o(void 0),n(b=>b.index>0?{...b,index:b.index-1}:b)},[]),h=S.useCallback(()=>{o(void 0),n(b=>b.index<b.stack.length-1?{...b,index:b.index+1}:b)},[]),f=S.useCallback(async()=>{const b=await Hs(r,d);if(Gs(b))return o(b.reason),{ok:!1,reason:b.reason};try{await e.onSave?.(b.source)}catch(v){const p=`Could not save: ${v}`;return o(p),{ok:!1,reason:p}}return i(b.source),l(d),o(void 0),{ok:!0}},[d,e,r]),g=S.useMemo(()=>JSON.stringify(d)!==JSON.stringify(a),[d,a]),m=S.useMemo(()=>{const b=new Set(a.tiles.map(Vs)),v=new Set(d.tiles.map(Vs));return[...b].some(p=>!v.has(p))||[...v].some(p=>!b.has(p))},[d,a]),w=S.useCallback(async()=>{const b=await Hs(r,d);return Gs(b)?{ok:!1,reason:b.reason}:{ok:!0,source:b.source}},[d,r]);return{document:d,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:g,...s===void 0?{}:{error:s},update:u,undo:c,redo:h,save:f,preview:w,structural:m}}function Cd({source:e,document:t,onSave:n,onChange:r,onDirtyChange:i,renderTile:s,controls:o,givens:a,catalog:l,toolbar:d,dashboards:u,onEvent:c,savesTo:h="package"}){const f=Ng({source:e,document:t,...n?{onSave:n}:{}}),[g,m]=S.useState(void 0),[w,b]=S.useState(!1),v=f.document.columns??j.DEFAULT_COLUMNS,{resize:p,gridBox:x,startResize:_,onResize:O,endResize:T}=bg({tiles:f.document.tiles,columns:v,onStart:m,commit:($,C)=>f.update(F=>{F.tiles[$].colspan=C})}),{dragging:E,preview:I,onDragStart:D,onDragOver:L,onDragEnd:M}=yg({tiles:f.document.tiles,commit:$=>f.update(C=>{C.tiles=$}),onLanded:m}),[A,Q]=S.useState(void 0),[J,ye]=S.useState(void 0),[Ie,ie]=S.useState(!1),[ze,Ke]=S.useState(void 0),[be,qe]=S.useState(null),[We,je]=S.useState(void 0);S.useEffect(()=>{r?.(f.document)},[f.document,r]),S.useEffect(()=>{i?.(f.dirty)},[f.dirty,i]);const Fe=S.useMemo(()=>vp(f.document),[f.document]),xe=S.useMemo(()=>{const $=new Set((t.localGivens??[]).map(C=>C.name));return(a??[]).filter(C=>!$.has(C.name))},[t,a]),ee=S.useMemo(()=>Bh(f.document,xe),[f.document,xe]),z=S.useMemo(()=>new Map(f.document.sources.map($=>[$.name,Sa(l,$.base)])),[l,f.document.sources]),V=S.useCallback($=>z.get($.source)??Sa(l,$.source),[z,l]),_e=($,C)=>{const F=[];for(const Y of f.document.tiles){const Be=V(Y);if(!Be)continue;const ge=new Map(Be.map($e=>[$e.name,$e.type]));for(const $e of Y.filters??[])$e.given===$&&(!ge.has($e.field)||!ti(C,ge.get($e.field)))&&F.push(`${$e.field} on ${Y.label??Y.name} (${f.document.sources.find(ve=>ve.name===Y.source)?.base??Y.source})`)}return F},ne=S.useMemo(()=>ee.filter($=>$.origin==="model"&&$.boundTiles===0),[ee]),Ae=S.useCallback(()=>{je(void 0),b(!0);const $=j.now(),{structural:C}=f,F=f.document.tiles.length;f.save().then(Y=>{Y.ok===!0?c?.({type:"dashboard.saved",tiles:F,structural:C,where:h,durationMs:j.now()-$}):c?.({type:"dashboard.save_refused",reason:Y.reason})}).finally(()=>b(!1))},[f,c,h]),X=S.useCallback(()=>{if(!(!n||!f.dirty||w)){if(!f.structural){Ae();return}f.preview().then($=>{$.ok?je({before:f.source,after:$.source}):Ae()})}},[n,f,w,Ae]),et=$=>{ie(!1),f.update(C=>{let F=C.sources.find(ge=>ge.base===$.base);if(!F){const ge=new Set(C.sources.map(ve=>ve.name));let $e=`${$.base}_tiles`;for(let ve=2;ge.has($e);ve++)$e=`${$.base}_tiles_${ve}`;F={name:$e,base:$.base},C.sources.push(F)}const Y=new Set(C.tiles.filter(ge=>ge.source===F.name).map(ge=>ge.name));let Be=`${$.view}_tile`;for(let ge=2;Y.has(Be);ge++)Be=`${$.view}_tile_${ge}`;C.tiles.push({name:Be,source:F.name,declaration:{kind:"reference",from:$.view},colspan:$.colspan,...$.label?{label:$.label}:{}})}),m(f.document.tiles.length)},Se=$=>{ye(void 0),m(void 0),f.update(C=>{C.tiles.splice($,1)})};tp(S.useMemo(()=>({undo:f.undo,redo:f.redo,...n?{save:X}:{},escape:()=>{!J&&!A&&m(void 0)},nudge:$=>{if(g===void 0)return;const C=f.document.tiles[g];if(!C||C.declaration.kind==="inherited")return;const F=Math.min(Math.max((C.colspan??1)+$,1),v);F!==(C.colspan??1)&&f.update(Y=>{Y.tiles[g].colspan=F})}}),[f,n,X,J,A,g,v]));const ft=($,C,F)=>{Q(void 0),f.update(Y=>{F&&Uh(Y,F),qh(Y,$,C)})},P=$=>{Q(void 0),f.update(C=>Xh(C,$))},R=(()=>{const $=f.document.tiles;return p!==void 0?$.map((C,F)=>F===p.index?{...C,colspan:p.span}:C):I??$})(),U=E?wp(R,v):R.map(vd);return y.jsxs(k.Stack,{sx:{gap:0},children:[y.jsx(np,{canUndo:f.canUndo,canRedo:f.canRedo,onUndo:f.undo,onRedo:f.redo,dirty:f.dirty,saving:w,...n?{onSave:X}:{},...d?{actions:d}:{},...l?{onAddTile:()=>ie(!0)}:{},onSettings:qe}),y.jsxs(k.Stack,{sx:{gap:2,px:"4px",pb:"4px"},children:[y.jsx(j.DashboardProse,{title:f.document.title||"Untitled dashboard",...f.document.description?{description:f.document.description}:{}}),y.jsx(bp,{controls:ee,tileCount:f.document.tiles.length,unknownFieldsOf:_e,onEdit:$=>Q({control:$}),onAdd:()=>Q({}),children:o}),f.error&&y.jsx(k.Alert,{severity:"warning",children:f.error}),y.jsx(Sh,{sensors:eg,onDragStart:D,onDragOver:L,onDragEnd:M,children:y.jsxs(k.Box,{ref:x,sx:{position:"relative"},children:[(p!==void 0||E)&&y.jsx(cg,{columns:v}),y.jsx(j.DashboardGrid,{tiles:U,columns:v,keyOf:$=>$.kind==="gap"?md($.after):ht($.tile),renderTile:$=>{if($.kind==="gap")return y.jsx(lg,{after:$.after});const{tile:C,index:F}=$;return y.jsx(og,{tile:C,index:F,selected:F===g,menuOpen:J?.index===F,resizeSpan:p?.index===F?p.span:void 0,columns:v,onSelect:()=>m(F),onOpenMenu:Y=>{m(F),ye({anchor:Y,index:F})},onResizeStart:Y=>_(Y,F),onResizeMove:O,onResizeEnd:T,children:s?s(C):y.jsx(ag,{tile:C})})}})]})}),y.jsx(gp,{open:A!==void 0,document:f.document,...A?.control?{control:A.control}:{},available:ne,...l?{fieldsFor:V}:{},onClose:()=>Q(void 0),onApply:ft,onRemove:P}),y.jsx(xg,{anchor:J?.anchor??null,tile:J===void 0?void 0:f.document.tiles[J.index],onClose:()=>ye(void 0),onCommit:$=>{const C=J?.index;C!==void 0&&f.update(F=>{F.tiles[C]=$})},onRemove:()=>{J!==void 0&&Se(J.index)},columns:v,onDrills:()=>{J!==void 0&&Ke(f.document.tiles[J.index]?.source)}}),y.jsx(hp,{open:ze!==void 0,document:f.document,source:f.document.sources.find($=>$.name===ze),givenNames:ee.map($=>$.name),dashboards:u??[],onClose:()=>Ke(void 0),onApply:$=>f.update(C=>{const Y=[...(C.drills??[]).filter(Be=>Be.source!==ze),...$];Y.length===0?delete C.drills:C.drills=Y})}),y.jsx(mp,{anchor:be,settings:Fe,onClose:()=>qe(null),onCommit:$=>f.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})}),y.jsx(cp,{open:Ie,document:f.document,catalog:l,columns:v,onClose:()=>ie(!1),onAdd:et}),y.jsx(fp,{open:We!==void 0,before:We?.before??"",after:We?.after??"",onConfirm:Ae,onClose:()=>je(void 0)})]})]})}function Gg(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(Vg(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 Vg(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 Hg(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 c=j.malloyLiteral(r.get(d.given),s.get(d.given));c!==void 0&&a.push(`${u} ${c}`)}const l=a.join(", ");return{expression:`${i} -> ${t.declaration.from}`+(l?` + { ${l} }`:""),givenNames:o}}async function Kg(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}const Ha=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function qg({environmentName:e,packageName:t,dashboardName:n,onExit:r,onEvent:i,onDirtyChange:s}){const{apiClients:o,mutable:a}=Le.useServer(),l=Fd.useQueryClient(),d=S.useRef(j.now()),u=S.useRef(i);u.current=i;const c=S.useRef(s);c.current=s;const h=j.useOptionalDocumentStorage()?.documentStorage,f=`dashboards/${n}.malloy`,g=j.useQueryWithApiError({queryKey:["dashboard-editor-model",e,t,f],queryFn:()=>o.models.getModel(e,t,f)}),m=g.data?.data?.sourceText,[w,b]=S.useState(void 0),[v,p]=S.useState(void 0),[x,_]=S.useState(h===void 0),[O,T]=S.useState(!1),[E,I]=S.useState(void 0);S.useEffect(()=>{if(!h)return;let G=!1;return I(void 0),(async()=>{try{const Oe=await h.listWorkspaces(!1),tt=Oe.find(fe=>fe.authoritative)??Oe.find(fe=>fe.writeable);if(G)return;if(b(tt),tt!==void 0){const fe=await h.getDocument(Ha(tt.name,e,t,f)).catch(W=>{if(!j.isDocumentNotFound(W))throw W});if(G)return;p(fe),T(fe!==void 0)}}catch(Oe){if(G)return;I(Ka(Oe))}G||_(!0)})(),()=>{G=!0}},[h,e,t,f]);const D=w?.authoritative===!0,L=D&&E!==void 0,[M,A]=S.useState(void 0),Q=(D||M===!0)&&v!==void 0,[J,ye]=S.useState(void 0),[Ie,ie]=S.useState(void 0),ze=S.useRef(void 0),Ke=S.useRef(void 0),[be,qe]=S.useState(void 0),We=g.dataUpdatedAt,je=S.useRef(We);je.current=We;const Fe=be!==void 0&&be.onFetch===We?be.text:m,xe=S.useRef(Fe);xe.current=Fe;const ee=Q?v:Fe,[z,V]=S.useState(!1),[_e,ne]=S.useState(void 0),[Ae,X]=S.useState(void 0),et=ee!==void 0&&ee!==Ae,Se=J?.source,ft=et&&z&&Se!==void 0&&ee!==_e,P=ft?Se:et?ee:Se??ee,R=ft?ee:void 0,U=S.useRef(Se);U.current=Se;const $=S.useRef(ee);$.current=ee;const C=S.useRef("package");C.current=Q?D?"record":"draft":"package",S.useEffect(()=>{if(P===void 0||!x||L||P===U.current)return;let G=!1;const Oe=xe.current,tt=$.current;return _i(P).then(fe=>{if(!G){if(xi(fe)){const W=fe.line?`${fe.reason} (line ${fe.line})`:fe.reason;ie(W),u.current?.({type:"dashboard.open_refused",reason:W});return}ie(void 0),ze.current=void 0,Ke.current=Oe,qe(void 0),ne(void 0),X(tt),ye(W=>({source:P,document:fe.document,generation:(W?.generation??0)+1})),u.current?.({type:"dashboard.opened",from:C.current,tiles:fe.document.tiles.length,durationMs:j.now()-d.current})}}),()=>{G=!0}},[P,x,L]);const F=w===void 0?void 0:Ha(w.name,e,t,f),Y=S.useCallback(async G=>{if(!h||!F)throw new Error("This host keeps no documents, so there is nowhere to save.");await h.saveDocument(F,G),ye(Oe=>Oe&&{...Oe,source:G}),p(G),(D||M===!0)&&X(G),D||A(Oe=>Oe??!1)},[h,F,D,M]),[Be,ge]=S.useState(void 0),$e=S.useCallback(async G=>{const Oe=Ke.current,tt=ze.current??(Oe===void 0?void 0:await Kg(Oe));if(tt===void 0)throw new Error("The package file is still loading; try again.");let fe;try{fe=await o.models.updateModelSource(e,t,f,{source:G,expectedHash:tt})}catch(W){throw l.invalidateQueries({queryKey:["dashboard-editor-model",e,t,f]}),new Error(Yg(W))}if(ye(W=>W&&{...W,source:G}),qe({text:G,onFetch:je.current}),X(G),ze.current=fe.data.contentHash,ge(void 0),h&&F)try{await h.deleteDocument(F),p(void 0),T(!1)}catch(W){j.isDocumentNotFound(W)?(p(void 0),T(!1)):ge(Ka(W))}A(!1),await l.invalidateQueries({queryKey:["dashboard-editor-model",e,t,f]});for(const W of["dashboard-editor-manifest","dashboards","dashboard"])l.invalidateQueries({queryKey:[W]})},[o,e,t,f,h,F,l]),ve=D?"host":a?"package":"browser",qt=w?.writeable===!0,Tr=E===void 0?D?h&&F&&qt?Y:void 0:a?$e:h&&F&&qt?Y:void 0:void 0,Ut=w?.name,An=S.useCallback(G=>{u.current?.(G.type==="dashboard.saved"&&G.where!=="package"&&Ut!==void 0?{...G,workspace:Ut}:G)},[Ut]),Er=S.useCallback(G=>{V(G),c.current?.(G)},[]),Dr=G=>{d.current=j.now(),ne(G?v:Fe),A(G)},Pr=()=>{d.current=j.now(),ne(R)};if(g.isError)return y.jsx(j.ApiErrorDisplay,{error:g.error,context:"Opening the dashboard"});if(!m||!x)return y.jsxs(k.Stack,{sx:{gap:2},children:[y.jsx(j.DashboardBar,{}),y.jsx(j.Loading,{text:"Opening the dashboard…"})]});if(L)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",E]});if(Ie)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",Ie]});const Ri=v!==void 0&&v!==m;return y.jsxs(k.Stack,{sx:{gap:2},children:[!D&&O&&Ri&&M===void 0&&y.jsx(k.Alert,{severity:"info",action:y.jsxs(k.Stack,{direction:"row",sx:{gap:1},children:[y.jsx(k.Button,{size:"small",onClick:()=>Dr(!0),children:"Resume"}),y.jsx(k.Button,{size:"small",onClick:()=>Dr(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),R!==void 0&&y.jsx(k.Alert,{severity:"warning",action:y.jsx(k.Button,{size:"small",onClick:Pr,children:"Load it"}),children:ve==="package"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":ve==="host"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them."}),Be!==void 0&&y.jsxs(k.Alert,{severity:"warning",children:["The file was saved into the package, but the copy kept beside it could not be cleared, so it will be offered again:"," ",Be]}),J&&y.jsx(Xg,{environmentName:e,packageName:t,modelPath:f,slug:n,opened:J,onSave:Tr,onDirtyChange:Er,savesTo:ve,...i?{onEvent:An}:{},toolbar:r&&y.jsx(j.SecondaryButton,{label:"Done editing",icon:y.jsx(j.CheckIcon,{}),onClick:r}),note:Ug({authoritative:D,mutable:a,...w?{workspace:w}:{},...E!==void 0?{readFailure:E}:{}})},J.generation)]})}function Ug({authoritative:e,mutable:t,workspace:n,readFailure:r}){return r!==void 0?`The saved copy could not be read, so Save is off: ${r}`:e&&n?n.writeable?n.description:`${n.description}: you cannot save into it.`:t?"Save writes the file into the package.":n?`${n.description}: this server does not take writes.`:"This server does not take writes."}function Xg({environmentName:e,packageName:t,modelPath:n,slug:r,opened:i,onSave:s,onDirtyChange:o,onEvent:a,savesTo:l,toolbar:d,note:u}){const{apiClients:c}=Le.useServer(),{data:h,isSuccess:f}=j.useQueryWithApiError({queryKey:["dashboard-editor-manifest",e,t,r],queryFn:()=>c.dashboards.getDashboard(e,t,r,void 0)}),g=h?.data,{data:m}=j.useQueryWithApiError({queryKey:["dashboard-editor-dashboards",e,t],queryFn:()=>c.dashboards.listDashboards(e,t,void 0)}),w=S.useMemo(()=>(m?.data??[]).map(M=>M.name).filter(M=>!!M&&M!==r),[m,r]),b=S.useMemo(()=>{const M=n.slice(0,n.lastIndexOf("/")+1),A=new Set;for(const Q of i.document.imports){const J=new URL(Q.from,`https://malloy.invalid/${M}`);A.add(J.pathname.slice(1))}return[...A]},[i.document.imports,n]),{data:v}=j.useQueryWithApiError({queryKey:["dashboard-editor-catalog",e,t,...b],queryFn:async()=>{const M=await Promise.all(b.map(A=>c.models.getModel(e,t,A).then(Q=>Q.data)));return hd(M)},enabled:b.length>0}),[p,x]=S.useState(i.document);S.useEffect(()=>x(i.document),[i.document]);const _=S.useMemo(()=>g?.givens??[],[g]),O=S.useMemo(()=>new Set(_.map(M=>M.name).filter(M=>M!==void 0)),[_]),T=S.useMemo(()=>Gg(p,_),[p,_]),{declaredTypes:E,applied:I,panel:D}=j.useDocumentControls({specs:T,loaded:f,startingValues:g?.startingGivens,documentKey:`${e}/${t}/${r}/edit`,autorun:g?.autorun!==!1,environmentName:e,packageName:t,modelPath:g?.path,documentName:r}),L=S.useMemo(()=>function(A){const Q=Hg(p,A,O,I);return y.jsx(j.DashboardTile,{environmentName:e,packageName:t,modelPath:n,tile:Q.expression,label:A.label??j.tileTitle(`${A.source} -> ${A.name}`),subtitle:A.subtitle,borderless:A.borderless,givens:I,declaredTypes:E,givenNames:Q.givenNames,height:j.TILE_MAX_HEIGHT})},[p,O,e,t,n,I,E]);return y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsx(Cd,{source:i.source,document:i.document,renderTile:L,givens:T.filter(M=>M.name!==void 0).map(M=>({name:M.name,...M.label?{label:M.label}:{},...M.type?{type:M.type}:{},...M.suggest?.dimension?{field:M.suggest.dimension}:{}})),onChange:x,onDirtyChange:o,...v?{catalog:v}:{},dashboards:w,...a?{onEvent:a}:{},toolbar:d,controls:f?y.jsx(j.GivensPanel,{...D,layout:"bar"}):void 0,...s?{onSave:s}:{},savesTo:l}),y.jsx(k.Box,{sx:{px:.5},children:y.jsx(k.Typography,{variant:"caption",sx:{opacity:.7},children:u})})]})}function Ka(e){return e instanceof Error?e.message:String(e)}function Yg(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}typeof globalThis.process>"u"?globalThis.process={env:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.DashboardBuilder=Cd;exports.DashboardEditor=qg;exports.buildCatalog=hd;exports.readDashboardDocument=_i;exports.readFailed=xi;exports.spliceDashboardDocument=Hs;exports.spliceFailed=Gs;