@malloy-publisher/app 0.18.2 → 0.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/api-doc.yaml +46 -11
  2. package/dist/assets/{EnvironmentPage-CsFUI8IX.js → EnvironmentPage-BxNqq3cN.js} +1 -1
  3. package/dist/assets/{HomePage-B_FVtnN-.js → HomePage-B4iN5rso.js} +1 -1
  4. package/dist/assets/{MainPage-wFF9nPEr.js → MainPage-DGiMH0eU.js} +1 -1
  5. package/dist/assets/{ModelPage-CxenqDcz.js → ModelPage-BJmyMnQo.js} +2 -2
  6. package/dist/assets/{PackagePage-dcF6vrvw.js → PackagePage-D2Pay_Xy.js} +1 -1
  7. package/dist/assets/{PackageSplatRoute-CASBZk0k.js → PackageSplatRoute-CQ7PxhkD.js} +2 -2
  8. package/dist/assets/{RenderedResult--fYcsY1h.es-DzOt5Lwv.js → RenderedResult-BEJ_GMaW.es-DS2oXAjc.js} +1 -1
  9. package/dist/assets/{RouteError-CUIolYwb.js → RouteError-BysHaT0t.js} +1 -1
  10. package/dist/assets/{ThemeEditorPage-DgU2YYq6.js → ThemeEditorPage-BFyTBbqA.js} +1 -1
  11. package/dist/assets/{ToggleButtonGroup-Dmr-hVlD.js → ToggleButtonGroup-eURRljZv.js} +1 -1
  12. package/dist/assets/{documentRoutes-Drv-WDwO.js → documentRoutes-DgTzGqfC.js} +1 -1
  13. package/dist/assets/{editPageMounted-C5yJiIVi.js → editPageMounted-CWBeAIbE.js} +2 -2
  14. package/dist/assets/{index-BSyL0zds.js → index-CCLHq9po.js} +15 -15
  15. package/dist/assets/{index-Dtw4eTxH.js → index-D4DhR2vg.js} +1 -1
  16. package/dist/assets/{index-BIoSdsU9.js → index-N8X9kVzc.js} +1 -1
  17. package/dist/assets/{index-DxF3kMLJ.js → index-We9Zzxmt.js} +1 -1
  18. package/dist/assets/{index.es-CX9m4CBD.js → index.es-D_O2KdNW.js} +1 -1
  19. package/dist/assets/usePackageLinkNavigate-CllycPZP.js +1 -0
  20. package/dist/assets/{usePackageRoute-wJGaZEiY.js → usePackageRoute-DEUbQLf3.js} +1 -1
  21. package/dist/index.html +1 -1
  22. package/package.json +2 -2
  23. package/dist/assets/usePackageLinkNavigate-qNjcXPcY.js +0 -1
@@ -1,4 +1,4 @@
1
- import{X as id,R as _e,aO as cn,aP as Cs,r as S,j as m,ad as ft,az as rt,L as Ot,K as $n,aQ as nr,a2 as De,aR as wa,aS as vi,aT as Xn,aU as ep,aV as sd,aW as rn,aX as tp,aY as np,aZ as mo,a_ as rp,T as pe,a1 as ht,a$ as ip,b0 as sp,b1 as op,O as ka,ak as ap,b2 as Qt,b3 as lp,b4 as Sa,b5 as cp,b6 as od,b7 as ad,b8 as dp,b9 as up,a0 as go,ba as hp,bb as fp,bc as vo,aF as ld,B as cd,bd as nt,I as B,aj as Xe,be as mt,bf as $a,W as Bt,bg as pp,bh as pt,bi as Il,bj as Gr,bk as dd,bl as mp,bm as ja,bn as gp,bo as vp,bp as xp,bq as bp,br as yp,bs as wp,bt as ud,bu as kp,bv as Sp,bw as hd,bx as fd,by as pd,bz as $p,bA as jp,bB as Mp,bC as Ep,bD as Cp,bE as Tp,bF as Op,bG as Dp,F as Ap,bH as Pp,bI as Rp,bJ as xo,bK as bo,bL as Nl,bM as Ip,bN as Np,bO as Wp,bP as Qn,bQ as Lp,bR as zp,bS as Fp,bT as Bp,bU as _p,bV as md,bW as Ma,bX as qp,bY as Hp,bZ as gd,b_ as Up,b$ as Vp,c0 as Kp,c1 as Ts,c2 as ns,c3 as Gp,c4 as Yp,c5 as rs,c6 as Xp,c7 as kn,c8 as Qp,c9 as Zp,ca as vd,cb as Jp,cc as em,ap as Ea,af as Zt,cd as tm,ce as yo,cf as nm,cg as rm,ch as xd,V as bd,ci as im,cj as sm,ck as Os,cl as om,cm as wo,cn as am,co as lm,cp as cm,cq as yd,cr as dm,G as um,cs as hm,ct as fm,cu as pm,cv as mm,cw as gm,cx as vm,cy as xm,cz as Ca,cA as bm,cB as ym,cC as wd,cD as wm,cE as km,cF as Sm,cG as Ta,cH as $m,cI as jm,cJ as Mm,cK as Pn,cL as kd,cM as Wl,cN as Ll,cO as Vs,cP as Em,S as Cm,cQ as Tm,cR as Om,cS as Dm,cT as Sd,cU as Am,cV as Pm,as as Rm}from"./index-BSyL0zds.js";import{cW as Ww,cX as Lw,cY as zw,cZ as Fw,c_ as Bw,c$ as _w,d0 as qw,d1 as Hw,d2 as Uw,d3 as Vw,d4 as Kw}from"./index-BSyL0zds.js";import{T as $d,a as ko}from"./ToggleButtonGroup-Dmr-hVlD.js";var zl={};const $e=e=>e.kind==="text",oe=e=>e.kind!=="text",Mr=e=>oe(e)?e.label??e.name:e.name,vt=e=>e.declaration.kind==="query"?e.name:`${e.source} -> ${e.name}`,cr=e=>e.declaration.kind==="inherited"||e.declaration.kind==="query",ue=e=>$e(e)?`text.${e.name}`:e.declaration.kind==="query"?`query.${e.name}`:`${e.source}.${e.name}`,Fl=".malloy-big-value, .malloy-table",Im=e=>e.querySelector(Fl)!==null&&![...e.querySelectorAll(".malloy-chart")].some(t=>t.closest(Fl)===null),is=(e,t)=>$e(e)?Gp:t&&Im(t)?Yp:rs,ii=e=>e.rowspan??ja[$e(e)?"text":"query"];function sn(e,t){if(e.row===void 0||e.col===void 0)return;const n=Math.min(e.colspan??1,t);return{row:e.row,col:Math.min(e.col,t-n+1),colspan:n,rowspan:ii(e)}}const si=(e,t)=>e.col<t.col+t.colspan&&t.col<e.col+e.colspan&&e.row<t.row+t.rowspan&&t.row<e.row+e.rowspan;function Kn(e){return e.map((t,n)=>({tile:t,index:n})).sort((t,n)=>(t.tile.row??1/0)-(n.tile.row??1/0)||(t.tile.col??1/0)-(n.tile.col??1/0)||t.index-n.index).map(({tile:t})=>t)}function Ht(e,t,n){const r=e.map(a=>({...a})),i=[],s=a=>{const d=sn(r[a],t);d&&(r[a].col=d.col,i.push(d))};n!==void 0&&s(n);const o=r.map((a,d)=>({tile:a,index:d})).filter(({index:a,tile:d})=>a!==n&&d.row!==void 0).sort((a,d)=>(a.tile.row??0)-(d.tile.row??0)||(a.tile.col??0)-(d.tile.col??0)||a.index-d.index);for(const{index:a}of o){const d=sn(r[a],t);if(d){for(;;){const f=i.filter(c=>si(d,c));if(f.length===0)break;d.row=Math.max(...f.map(c=>c.row+c.rowspan))}r[a].row=d.row,s(a)}}return r}function Nm(e,t,n,r){const i=e.flatMap((d,f)=>{const c=f===t?void 0:sn(d,r);return c?[c]:[]}),s=Math.max(1,...i.map(d=>d.row+d.rowspan)),o={...e[t],...n,row:Math.min(n.row,s)},a=sn(o,r);if(a){for(;;){const d=i.filter(f=>f.row<a.row&&si(a,f));if(d.length===0)break;a.row=Math.max(...d.map(f=>f.row+f.rowspan))}o.row=a.row}return Ht(e.map((d,f)=>f===t?o:d),r,t)}const ss=(e,t)=>(e-pt*(t-1))/t,jd=ns+pt;function Md(e,t,n,r,i){const s=Math.min(n,r),o=Math.round(e/(i+pt))+1;return{row:Math.max(1,Math.round(t/jd)+1),col:Math.min(Math.max(o,1),r-s+1)}}function Ed(e,t,n,r){const i=e.map((s,o)=>{if(s.row!==void 0&&s.col!==void 0)return s;const a=t[o];if(!a)return s;const{break:d,...f}=s,c=s.colspan??Math.max(1,Math.round((a.width+pt)/(r+pt))),l=Md(a.left,a.top,c,n,r),u=(a.top+a.height+pt)/jd,p=$e(s)?Math.ceil(u-.02):Math.round(u);return{...f,...l,colspan:c,rowspan:s.rowspan??Math.max(is(s),p-l.row+1)}});return Ht(i,n)}function Bl(e,t,n){const r=e.flatMap((s,o)=>{const a=o===t?void 0:sn(s,n);return a?[a]:[]});if(r.length===0)return[...e];const i=Math.max(...r.map(s=>s.row+s.rowspan));return e.map((s,o)=>o===t?{...s,row:i,col:1}:s)}function Cd(e,t){const n=e.map(s=>({...s})),r=[],i=n.map((s,o)=>({tile:s,index:o})).filter(({tile:s})=>s.row!==void 0&&s.col!==void 0).sort((s,o)=>(s.tile.row??0)-(o.tile.row??0)||(s.tile.col??0)-(o.tile.col??0)||s.index-o.index);for(const{index:s}of i){const o=sn(n[s],t);if(o){for(;o.row>1&&!r.some(a=>si({...o,row:o.row-1},a));)o.row-=1;n[s].row=o.row,n[s].col=o.col,r.push(o)}}return n}const Wm=(e,t)=>Cd(e,t).some((n,r)=>n.row!==e[r].row||n.col!==e[r].col);function Lm(e){return Kn(e).map(t=>{const{row:n,col:r,...i}=t;return i})}const zm=(e,t,n)=>e.map((r,i)=>i===t?{...r,...n}:r);function _l(e,t,n,r,i){const s=sn(e[t],i);if(!s)return[...e];const o={row:Math.max(1,s.row+n),col:Math.min(Math.max(1,s.col+r),i-s.colspan+1)};if(o.row===s.row&&o.col===s.col)return[...e];const a={...s,...o},d=e.flatMap((p,g)=>{const v=g===t?void 0:sn(p,i);return v&&si(a,v)&&!si(s,v)?[{i:g,other:v}]:[]}),f=d.length===1?d[0]:void 0;if(!f)return Ht(zm(e,t,o),i,t);const{i:c,other:l}=f,u=e.map(p=>({...p}));return n>0?(u[c].row=s.row,u[t].row=s.row+l.rowspan):n<0?(u[t].row=l.row,u[c].row=l.row+s.rowspan):r>0?(u[c].col=s.col,u[t].col=s.col+l.colspan):(u[t].col=l.col,u[c].col=l.col+s.colspan),Ht(u,i,t)}const Td=(e,t)=>e?.col===void 0?t:Math.max(1,t-e.col+1);function Fm(e){return $e(e)||e.rowspan===void 0?e:Os(e.chart)&&e.chart!=="big_value"&&e.rowspan<rs?{...e,rowspan:rs}:e}const Od=mt(m.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),Dd=mt(m.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),Bm=mt(m.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}));function Ad(e){const{theme:t}=_e(),n=t.ui,[r,i]=S.useState(null),{status:s,draftKeptAt:o,discard:a,restored:d,dismissRestored:f}=e,c=d!==void 0&&!d.pending&&s==="unsaved"?d:void 0,l=s==="saved"?"Saved":s==="saving"?"Saving…":o!==void 0?"Draft saved":"Unsaved changes",u=c?`Restored your unsaved edits from ${So(c.savedAt)}`:void 0,p=s==="unsaved"&&o!==void 0?"Your edits are kept in this browser. Done saves them to the report.":e.saveTarget,g=a!==void 0&&s==="unsaved",v=()=>{i(null),c&&f?.()},b=x=>({display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:.75,minWidth:132,height:n.size.control,px:1,borderRadius:n.radius.control,font:"inherit",...n.type.control,whiteSpace:"nowrap",color:s==="saved"?x.palette.text.secondary:x.palette.text.primary,transition:`color ${nt}, background-color ${nt}`,...g?{"&:hover":{bgcolor:x.palette.action.hover}}:{}}),w=m.jsxs(m.Fragment,{children:[m.jsx(B,{component:"span","aria-hidden":!0,sx:{width:16,height:16,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:s==="saved"?m.jsx(Ts,{sx:{fontSize:16}}):m.jsx(B,{component:"span","data-restored":c?"true":void 0,sx:x=>({width:7,height:7,borderRadius:"50%",bgcolor:c?t.accent:s==="saving"||o!==void 0?x.palette.text.disabled:x.palette.warning.main,transition:`background-color ${nt}`})})}),m.jsx(B,{component:"span","aria-hidden":!0,children:l}),m.jsx(wa,{"aria-hidden":!0,sx:{fontSize:16,ml:-.25,visibility:g?"visible":"hidden"}})]}),h=m.jsx(B,{component:"span",role:"status","aria-live":"polite",sx:_m,children:u?`${l}. ${u}.`:l});return m.jsxs(m.Fragment,{children:[h,m.jsx(Ot,{title:u??p,describeChild:!0,children:g?m.jsx(cd,{className:rt.saveStatus,"aria-label":l,...u?{"aria-description":u}:{},"aria-haspopup":"menu","aria-expanded":r!==null,onClick:x=>i(x.currentTarget),sx:b,children:w}):m.jsx(B,{component:"span",className:rt.saveStatus,sx:b,children:w})}),m.jsxs(Xn,{className:rt.menu,anchorEl:r,open:r!==null,onClose:v,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:-4,horizontal:"left"},slotProps:{paper:{sx:{minWidth:240,borderRadius:n.radius.menu,border:`1px solid ${cn(t.cardBorder)}`,boxShadow:n.shadow.menu}}},MenuListProps:{dense:!0,sx:{py:.5}},children:[(u!==void 0||o!==void 0)&&m.jsx(B,{component:"li",role:"presentation",sx:{px:1.75,pt:.75,pb:1,...n.type.caption,color:"text.secondary"},children:u??`Kept in this browser at ${So(o)}`}),m.jsxs(Xe,{onClick:()=>{i(null),a?.()},sx:{mx:.5,borderRadius:n.radius.control,gap:1.25,color:"error.main","&.Mui-focusVisible":{outline:"none",bgcolor:"action.hover"}},children:[m.jsx(Bm,{fontSize:"small"}),"Discard edits"]})]})]})}function So(e){const t=new Date(e);return new Date().toDateString()===t.toDateString()?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const _m={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},$o=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),Sn=$o?"⌘":"Ctrl+",ql=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},Ks=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function qm(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e});const[n,r]=S.useState(!1);S.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),S.useEffect(()=>{const i=s=>{const o=t.current;if(o.paused)return;const a=$o?s.metaKey:s.ctrlKey,d=s.key.toLowerCase();if(s.key==="Escape"){if(ql(s.target)||Ks(s.target))return;o.escape();return}if(ql(s.target)){if(a&&d==="s"){if(s.preventDefault(),!o.save||Ks(s.target))return;s.target.blur(),r(!0)}return}if(Ks(s.target)){a&&d==="s"&&s.preventDefault();return}if(a&&d==="z"){s.preventDefault(),s.shiftKey?o.redo():o.undo();return}if(!$o&&a&&d==="y"){s.preventDefault(),o.redo();return}if(a&&d==="s"){s.preventDefault(),o.save?.();return}if(o.move&&s.altKey&&!a&&!s.shiftKey){const f=s.key==="ArrowLeft"?[0,-1]:s.key==="ArrowRight"?[0,1]:s.key==="ArrowUp"?[-1,0]:s.key==="ArrowDown"?[1,0]:void 0;if(f&&o.move(f[0],f[1])){s.preventDefault();return}}o.nudge&&!a&&!s.altKey&&!s.shiftKey&&(s.key==="ArrowLeft"||s.key==="ArrowRight")&&(s.preventDefault(),o.nudge(s.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[])}const Yr=(e,t,n=$a)=>({height:n.size.control,minHeight:n.size.control,px:1.5,borderRadius:n.radius.control,boxShadow:"none",...n.type.control,"&:hover":{boxShadow:"none"},"& .MuiButton-startIcon":{mr:.5,"& svg":{fontSize:18}},"&.MuiButton-outlined":{borderColor:e,"&:hover":{borderColor:t}}}),oi=(e=$a)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),os={height:20,alignSelf:"center",mx:.5,my:0},as=(e,t=$a)=>({height:t.size.control,boxSizing:"border-box",borderRadius:t.radius.control,border:`1px solid ${e}`,overflow:"hidden",bgcolor:"background.paper","& .MuiToggleButton-root":{border:"none",borderRadius:"0 !important",m:"0 !important",px:1.5,py:0,height:"100%",...t.type.control,color:"text.secondary","& + .MuiToggleButton-root":{borderLeft:`1px solid ${e}`},"&:hover":{bgcolor:"action.hover"},"&.Mui-selected, &.Mui-selected:hover":{bgcolor:"action.selected",color:"text.primary"}}}),jo={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function Hm({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,savesTo:a="package",saveLabel:d,saveButton:f,actions:c,onAddTile:l,arrange:u,onExit:p,saveStatus:g}){const{theme:v}=_e(),b=cn(v.cardBorder),w=Cs(v.cardBorder,v.tileTitle);return m.jsxs(ft,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[u,l&&m.jsx(De,{variant:"outlined",startIcon:m.jsx(vi,{}),onClick:l,"aria-label":"Add tile",sx:Yr(b,w,v.ui),children:"Tile"}),l&&m.jsx(nr,{orientation:"vertical",sx:os}),m.jsx(Ot,{title:`Undo (${Sn}Z)`,children:m.jsx("span",{children:m.jsx($n,{"aria-label":"Undo",disabled:!e,onClick:n,sx:oi(v.ui),children:m.jsx(Dd,{fontSize:"small"})})})}),m.jsx(Ot,{title:`Redo (${Sn}⇧Z)`,children:m.jsx("span",{children:m.jsx($n,{"aria-label":"Redo",disabled:!t,onClick:r,sx:oi(v.ui),children:m.jsx(Od,{fontSize:"small"})})})}),(c||o||p)&&m.jsx(nr,{orientation:"vertical",sx:os}),c,o&&g&&m.jsx(Ad,{...g}),o?m.jsx(Ot,{title:i?`Save (${Sn}S) · ${d??jo[a]}`:d??jo[a],children:m.jsx("span",{children:m.jsx(De,{ref:f,variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{...Yr(b,w,v.ui),minWidth:88},children:s?"Saving…":i?"Save":"Saved"})})}):null,o&&m.jsx(B,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:s?"Saving":i?"Unsaved changes":"All changes saved"}),p&&m.jsx(um,{label:"Close",icon:m.jsx(Ts,{}),onClick:p})]})}const Um=e=>`This view has no field for the x-axis: ${e.toLowerCase()} needs a group by, such as a date or a category`,Hl={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map",combo_chart:"Bar and line"};function Pd(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this tile's details":n==="unlisted"?"Not in the model's list, so its shape is unknown":void 0,i=e?.shape,s=o=>{if(t===o)return;if(o==="big_value")return e?.aggregateOnly===!0?void 0:i&&i.groupBys>0?"This view has a group by, so it is more than one row; big numbers need a view of totals only":r??"Needs results that are only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a map chart set in the model";if(e?.chart===o)return;if(!i)return o==="combo_chart"?r??"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line":void 0;const a=`A ${Hl[o].toLowerCase()} chart`;switch(Am(o,i)){case"no_x_axis":return Um(a);case"combo_totals":return`A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has ${i.totals}`;case"no_y_axis":return`This view has no total for the y-axis: ${a.toLowerCase()} needs at least one aggregate`;default:return}};return[{value:"default",label:"Default",hint:"As set in the model"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map","combo_chart"].map(o=>{const a=s(o);return{value:o,label:Hl[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Ul(e){return e.description??Om(e.name)}const Vm={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",combo_chart:"a bar and line chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},Ci=(e,t)=>`${e}\0${t}`;function Km({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o,renderPreview:a}){const{theme:d}=_e(),f=d.ui,c=cn(d.cardBorder),l=S.useMemo(()=>n?.sources??[],[n]),[u,p]=S.useState(""),[g,v]=S.useState(),[b,w]=S.useState(""),[h,x]=S.useState("default"),y=S.useRef(null),k=S.useMemo(()=>{const P=new Set(t.sources.map(F=>F.base));return[...l].sort((F,E)=>Number(P.has(E.name))-Number(P.has(F.name)))},[l,t]),C=k.filter(P=>P.views.length>0),$=k.filter(P=>P.views.length===0),T=S.useMemo(()=>new Map(C.flatMap(P=>P.views.map(F=>[Ci(P.name,F.name),{source:P,view:F,key:Ci(P.name,F.name)}]))),[C]),j=S.useMemo(()=>C.map(P=>({key:P.name,label:P.name,...P.description?{detail:P.description}:{},entries:P.views.map(F=>({key:Ci(P.name,F.name),name:F.name,title:Ul(F),...F.chart?{chart:F.chart}:{}}))})),[C]),M=g===void 0?void 0:T.get(g);S.useEffect(()=>{if(!e)return;p(""),w(""),x("default");const P=C[0]?.views[0];v(P&&C[0]?Ci(C[0].name,P.name):void 0)},[e]);const I=M?[M.source.name,M.view.name].filter(P=>!wo(P)).map(P=>`"${P}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,W=M!==void 0&&I===void 0,A=M?Ul(M.view):"",z=h!=="default"&&M?{chart:h,chartCarried:M.view.chart?[M.view.chart]:[]}:{},_=(P=M)=>{if(!P||![P.source.name,P.view.name].every(wo))return;const F=P.key===M?.key,E=Pm(Math.ceil(r/2),r);s({base:P.source.name,modelPath:P.source.modelPath,...P.source.exporters?{exporters:P.source.exporters}:{},view:P.view.name,...F&&b.trim()?{label:b.trim()}:{},...F?z:{},...E!==void 0?{colspan:E}:{}})},q=M?Pd(M.view,h).filter(P=>P.value!=="custom"&&P.disabled!==!0):[];return m.jsx(Ea,{className:`${rt.dialog} ${rt.addTileDialog}`,open:e,onClose:i,maxWidth:"md",initialFocus:y,title:"Add a tile",description:"Pick what the tile shows from the model. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx(De,{onClick:o,sx:{mr:"auto"},children:"Add text instead"}),m.jsx(De,{onClick:i,children:"Cancel"}),m.jsx(De,{variant:"contained",disabled:!W,onClick:()=>_(),children:"Add tile"})]}),children:m.jsxs(B,{sx:{mx:-3,mb:-1,borderTop:`1px solid ${c}`,borderBottom:`1px solid ${c}`,display:"grid",gridTemplateColumns:{xs:"1fr",md:"320px minmax(0, 1fr)"},height:{md:460}},children:[m.jsx(B,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(am,{groups:j,query:u,onQuery:p,picked:M?.key,onPick:P=>{v(P),x("default")},onTake:P=>_(T.get(P)),searchRef:y,empty:m.jsx(pe,{variant:"body2",sx:{color:d.tileTitle,p:2},children:n?"This package's models have nothing to put on a tile yet.":"The package's sources are still loading."}),footer:$.length>0&&m.jsxs(pe,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",$.map(P=>P.name).join(", "),"."]})})}),m.jsx(B,{sx:P=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${P.palette.text.primary} 3%, ${P.palette.background.paper})`}),children:M?m.jsxs(m.Fragment,{children:[m.jsx(B,{"aria-label":"Preview",role:"region",sx:P=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:f.radius.tile,border:`1px solid ${c}`,bgcolor:P.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${P.palette.background.paper})`}}),children:a?m.jsx(B,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:M.source.name,modelPath:M.source.modelPath,view:M.view.name,label:b.trim()||A,...h!=="default"?z:{},givens:M.source.givens})}):m.jsxs(B,{sx:P=>({flex:1,border:`1px solid ${c}`,borderRadius:f.radius.tile,bgcolor:P.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(lm,{chart:M.view.chart}),m.jsxs(pe,{variant:"body2",children:[M.source.name," → ",M.view.name]})]})}),m.jsx(Zt,{size:"small",label:"Title",placeholder:A,value:b,onChange:P=>w(P.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs(B,{children:[m.jsx(pe,{component:"div",sx:{...f.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx($d,{size:"small",exclusive:!0,value:h,"aria-label":"Chart",onChange:(P,F)=>{F!==null&&x(F)},sx:{...as(c,f),"& .MuiToggleButton-root":{...as(c,f)["& .MuiToggleButton-root"],textTransform:"none"}},children:q.map(P=>m.jsx(ko,{value:P.value,children:P.label},P.value))}),m.jsx(pe,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:M.view.chart?`The model sets ${Vm[M.view.chart]??"a chart"}.`:"The model sets no chart, so it shows as a table."})]}),I&&m.jsx(pe,{variant:"body2",color:"error",children:I})]}):m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}function Gm(e,t,{modelPath:n,textHeld:r,widths:i,insertAt:s}){t.modelPath&&!r&&(e.imports=Em(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const o=Rd(e,t.base),a=Mo(e,o.name,t.view);e.tiles.splice(s??e.tiles.length,0,{name:a,source:o.name,declaration:{kind:"reference",from:t.view},...i&&t.colspan!==void 0?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function Rd(e,t,{unscoped:n=!1}={}){const r=e.sources.find(a=>a.base===t&&(!n||!a.scopedBy?.length));if(r)return r;const i=new Set(e.sources.map(a=>a.name));let s=`${t}_tiles`;for(let a=2;i.has(s);a++)s=`${t}_tiles_${a}`;const o={name:s,base:t};return e.sources.push(o),o}function Mo(e,t,n){const r=new Set(e.tiles.filter(oe).filter(s=>s.source===t).map(s=>s.name));let i=`${n}_tile`;for(let s=2;r.has(i);s++)i=`${n}_tile_${s}`;return i}function ls(e){switch(e.declaration.kind){case"inline":return"Its query is written in this file, and the builder does not copy a query's body.";case"opaque":return`Its query is ${e.declaration.why}, which the builder does not copy.`;case"query":return"It names a query, and a copy could not be told apart from it: the builder writes nothing about such a tile but its place.";default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function Ym(e,t){const n=e.tiles[t];if(!n||!oe(n)||ls(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:s,...o}=structuredClone(n);r={...o,name:Mo(e,n.source,n.declaration.from)}}else{const s=e.sources.find(o=>o.name===n.source)??Rd(e,n.source,{unscoped:!0});r={name:Mo(e,s.name,n.name),source:s.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}const i=n.row!==void 0&&n.col!==void 0;return i&&(r={...r,row:(n.row??1)+ii(n),col:n.col,...n.rowspan!==void 0?{rowspan:n.rowspan}:{}}),e.tiles.splice(t+1,0,r),i&&(e.tiles=Ht(e.tiles,e.columns??Xp,t+1)),t+1}const Ti="self";function Xm({open:e,document:t,source:n,givenNames:r,dashboards:i,tileLabel:s,onClose:o,onApply:a}){const{theme:d}=_e(),f=d.ui,[c,l]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(x=>x.source===n.name);l((n.dimensions??[]).map(x=>{const y=h.find(k=>k.name===x.name);return{name:x.name,expression:x.expression,to:y?.to??[],given:y?.given??""}}))},[e,n,t]);const u=(h,x)=>l(y=>y.map((k,C)=>{if(C!==h)return k;const $={...k};return x($),$})),p=[Ti,...i.filter(h=>h!==Ti)],g=h=>h===Ti?"This report":h,v=()=>{n&&(a(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}:{}}))),o())},b=cn(d.cardBorder),w=(h,x)=>u(h,y=>{x?y.to=y.lastTo?.length?y.lastTo:[Ti]:(y.lastTo=y.to,y.to=[])});return m.jsx(Ea,{className:`${rt.dialog} ${rt.clickableCellsDialog}`,open:e,onClose:o,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[s&&m.jsxs(B,{component:"span",sx:{fontWeight:f.type.label.fontWeight},children:[s," ·"," "]}),"A click on a table cell sets a filter to its value, on this report or on the one it opens. Bars, lines and points on a chart do not respond to a click. Clicks work in the report, not while you edit it."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx(De,{onClick:o,children:"Cancel"}),m.jsx(De,{variant:"contained",onClick:v,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx(pe,{variant:"body2",sx:{color:d.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx(B,{component:"code",children:n.name})," declares no dimensions of its own in this file. A click is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",m.jsx(B,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx(B,{role:"list","aria-label":"Dimensions",children:c.map((h,x)=>{const y=h.to.length>0;return m.jsxs(B,{role:"listitem",sx:{display:"grid",gridTemplateColumns:{xs:"auto minmax(0, 1fr)",sm:"auto minmax(0, 0.9fr) minmax(0, 1.6fr)"},alignItems:"center",columnGap:1.5,rowGap:1,py:1.25,borderTop:x===0?"none":`1px solid ${b}`},children:[m.jsx(om,{size:"small",checked:y,onChange:k=>w(x,k.target.checked),slotProps:{input:{"aria-label":`${h.name} is clickable`}}}),m.jsxs(B,{sx:{minWidth:0},children:[m.jsx(B,{sx:{...f.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Qm(h.name)}),m.jsxs(B,{title:h.expression,sx:{...f.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[h.name," is ",h.expression]})]}),y?m.jsxs(ft,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...f.type.control},children:[m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx(Zt,{select:!0,size:"small",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:k=>k.map(g).join(", ")},onChange:k=>u(x,C=>{const $=k.target.value,T=Array.isArray($)?$:String($).split(",").filter(Boolean);T.length===0&&(C.lastTo=C.to),C.to=T}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:p.map(k=>m.jsxs(Xe,{value:k,children:[m.jsx(yo,{size:"small",checked:h.to.includes(k),sx:{p:0,mr:1}}),m.jsx(Bt,{primary:g(k)})]},k))}),m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs(Zt,{select:!0,size:"small",value:h.given,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0,renderValue:k=>k===""?h.name:String(k)},onChange:k=>u(x,C=>{C.given=k.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx(Xe,{value:"",children:m.jsx(Bt,{primary:h.name,secondary:"Named like the dimension"})}),r.map(k=>m.jsx(Xe,{value:k,children:k},k))]})]}):m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},h.name)})})})}function Qm(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const Zm=mt(m.jsx("path",{d:"M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 13-4-4h8z"})),Jm=mt(m.jsx("path",{d:"M11 7H2v2h9zm0 8H2v2h9zm5.34-4L12.8 7.46l1.41-1.41 2.12 2.12 4.24-4.24L22 5.34zm0 8-3.54-3.54 1.41-1.41 2.12 2.12 4.24-4.24L22 13.34z"})),eg=mt(m.jsx("path",{d:"M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V10h14zm0-12H5V6h14zm-7 5h5v5h-5z"})),tg=mt(m.jsx("path",{d:"M19.5 9.5c-1.03 0-1.9.62-2.29 1.5h-2.92c-.39-.88-1.26-1.5-2.29-1.5s-1.9.62-2.29 1.5H6.79c-.39-.88-1.26-1.5-2.29-1.5C3.12 9.5 2 10.62 2 12s1.12 2.5 2.5 2.5c1.03 0 1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5s1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5 1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5"})),ng=mt(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),rg=mt(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function ig(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of oe(s)?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 cs(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function sg(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Xr(e,t){const n=sg(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 Eo(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 og(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const ag=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function lg(e,t){const n=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",r=/^[A-Z_]/.test(n)?n:`F_${n}`,i=Sd(r)?r:`${r}_FILTER`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const cg=[{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:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Or(e){const t=e.label.trim()||e.name,n=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 Co=e=>oe(e)&&!cr(e)&&e.declaration.kind!=="opaque";function dg(e,t){return e.tiles.map(n=>{const r=(oe(n)?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}:cs(t.type)!==void 0?{op:cs(t.type)}:{}}})}function ug(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Co(s))return;const o=(s.filters??[]).filter(d=>d.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 hg(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 fg(e,t){for(const r of e.tiles){if(!oe(r))continue;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 To=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function pg({open:e,document:t,control:n,available:r,takenNames:i=[],fieldsFor:s,onApply:o}){const a=S.useRef(n);e&&(a.current=n);const d=e?n:a.current,f=d!==void 0,[c,l]=S.useState({kind:"new"}),[u,p]=S.useState(""),[g,v]=S.useState("select"),[b,w]=S.useState(""),[h,x]=S.useState(""),[y,k]=S.useState([]),[C,$]=S.useState(!1),[T,j]=S.useState(!1),M=D=>t.sources.find(L=>L.name===D.source)?.base??D.source;S.useEffect(()=>{if(e)if(j(n!==void 0),n){l({kind:"existing",name:n.name}),p(n.label??"");const D=dg(t,n);k(D);const L=D.filter(V=>V.include),U=new Set(L.map(V=>V.field));x(U.size===1?L[0].field:n.field??""),$(U.size>1)}else l({kind:"new"}),p(""),v("select"),x(""),w(new Date().toISOString().slice(0,10)),k(t.tiles.map(D=>({include:Co(D),field:""}))),$(!1)},[e,n,t]);const I=S.useMemo(()=>[...(t.localGivens??[]).map(D=>D.name),...r.map(D=>D.name),...i],[t,r,i]),W=S.useMemo(()=>h.trim()?lg(h.trim(),I):"",[h,I]),A=c.kind==="existing"?n??r.find(D=>D.name===c.name):W?{name:W,type:Or({name:W,label:u,kind:g,field:h}).type}:void 0,z=A?.type!==void 0&&!A.type.startsWith("filter<"),_=y.find(D=>D.include)?.op??cs(A?.type),q=(D,L)=>{j(!0),k(U=>U.map((V,we)=>we===D?{...V,...L}:V))},P=D=>{j(!0),k(L=>L.map(U=>({...U,op:D})))},F=D=>{const L=cs(D);k(U=>U.map(({op:V,...we})=>L?{...we,op:L}:we))},E=D=>{j(!0),l({kind:"existing",name:D.name}),x(D.field??""),F(D.type)},O=D=>{j(!0),v(D),F(Or({name:"X",label:u,kind:D,field:h}).type)},N=t.tiles.map(Co),H=N.filter(Boolean).length,K=y.filter((D,L)=>D.include&&N[L]).length,Y=t.tiles.filter((D,L)=>(y[L]?.include??!1)&&N[L]&&oe(D)),te=Y.length>0?Y:t.tiles.filter((D,L)=>N[L]&&oe(D)),xe=S.useMemo(()=>{const D=new Map;let L=!1;for(const U of te){const V=s?.(U);if(V){L=!0;for(const we of V)D.has(we.name)||D.set(we.name,we)}}return L?[...D.values()]:void 0},[y,t.tiles,s]),me=(()=>{const D=h.trim();for(const L of Y){const U=s?.(L);if(!U||U.some(V=>V.name===D))return M(L)}return Y[0]?M(Y[0]):t.sources[0]?.base})(),ne=D=>{j(!0),k(L=>L.map((U,V)=>({...U,include:D&&N[V]})))},Ee=S.useMemo(()=>C?y:y.map(D=>({...D,field:h})),[C,y,h]),J=D=>{for(const L of te){const U=s?.(L)?.find(V=>V.name===D.trim());if(U?.type)return U.type}},Ve=D=>Xr(A?.type,D.type),Ae=(D,L)=>{if(D.trim()==="")return"Pick the field this filter compares.";const U=L?s?.(L):void 0;if(!U)return;const V=U.find(we=>we.name===D.trim());if(!V)return`Not a field of ${L?M(L):"the tiles' source"}.`;if(V.type&&!Xr(A?.type,V.type))return`${D.trim()} is ${Eo(V.type)}; this filter compares ${Eo(A?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},G=D=>{if(j(!0),x(D),f||c.kind!=="new")return;const L=J(D),U=Or({name:"X",label:u,kind:g,field:D}).type;L&&!Xr(U,L)&&O(og(L))},ye=D=>{const L=t.tiles[D];return L&&oe(L)?L:void 0},be=Ee.map((D,L)=>D.include&&N[L]?Ae(D.field,ye(L)):void 0),re=be.every(D=>D===void 0),Pe=T?be:be.map(()=>{}),Ke=T&&!C&&K>0?Y.map(D=>Ae(h,D)).find(Boolean):void 0,Re=A!==void 0&&re&&(c.kind==="existing"||h.trim()!==""&&W!==""),Qe=()=>{if(!(!A||!Re))if(c.kind==="new")o(A.name,Ee,Or({name:A.name,label:u.trim()||To(A.name),kind:g,field:h.trim(),...me?{source:me}:{},...b?{dateDefault:b}:{}}));else if(n?.origin==="dashboard"&&n.local){const D=u.trim(),L=D!==(n.local.label??"");o(A.name,Ee,L?{...n.local,...D?{label:D}:{}}:void 0)}else o(A.name,Ee)},Ze=f&&d.origin==="model";return{editing:f,shown:d,fromModel:Ze,source:c,setSource:l,label:u,setLabel:p,kind:g,dateDefault:b,setDateDefault:w,field:h,rows:y,setRows:k,perTile:C,setPerTile:$,newName:W,target:A,valueTyped:z,commonOp:_,setRow:q,setCommonOp:P,pickExisting:E,pickKind:O,bindable:N,bindableCount:H,included:K,commonFields:xe,setAll:ne,accepts:Ve,pickField:G,rowProblems:Pe,commonProblem:Ke,canApply:Re,apply:Qe}}function Vl({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:d,autoFocus:f,placeholder:c,inputRef:l,sx:u}){const p=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),g=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return m.jsx(Tm,{freeSolo:!0,size:"small",options:p,inputValue:e,onInputChange:(v,b)=>t(b),value:e,onChange:(v,b)=>t(typeof b=="string"?b:""),disabled:d,disableClearable:!0,renderOption:(v,b)=>S.createElement("li",{...v,key:b},m.jsx(Gl,{type:g.get(b)}),m.jsx(pe,{variant:"body2",sx:{flex:1,ml:1},children:b})),renderInput:v=>m.jsx(Zt,{...v,label:i,placeholder:c,autoFocus:f,...l?{inputRef:l}:{},error:o,helperText:a,InputLabelProps:{...v.InputLabelProps,shrink:!0},InputProps:{...v.InputProps,startAdornment:g.get(e.trim())?m.jsx(B,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(Gl,{type:g.get(e.trim())})}):void 0},inputProps:{...v.inputProps,"aria-label":s}}),sx:u})}const mg=e=>e&&oe(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:e&&oe(e)&&e.declaration.kind==="query"?{label:"Not bindable",reason:"It names a query, whose filters live in that query's own definition."}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function gg({open:e,document:t,control:n,available:r,takenNames:i,fieldsFor:s,onClose:o,onApply:a,onRemove:d}){const{theme:f}=_e(),c=f.ui,{editing:l,shown:u,fromModel:p,source:g,setSource:v,label:b,setLabel:w,kind:h,dateDefault:x,setDateDefault:y,field:k,rows:C,setRows:$,perTile:T,setPerTile:j,newName:M,target:I,valueTyped:W,commonOp:A,setRow:z,setCommonOp:_,pickExisting:q,pickKind:P,bindable:F,bindableCount:E,included:O,commonFields:N,setAll:H,accepts:K,pickField:Y,rowProblems:te,commonProblem:xe,canApply:me,apply:ne}=pg({open:e,document:t,control:n,available:r,...i?{takenNames:i}:{},fieldsFor:s,onApply:a}),Ee=S.useRef(null),J=cn(f.cardBorder),Ve=Cs(f.cardBorder,f.tileTitle),[Ae,G]=S.useState(!1),[ye,be]=S.useState(!1);S.useEffect(()=>{e?be(!0):G(!1)},[e]),S.useEffect(()=>{ye&&(be(!1),G(l&&O<E))},[ye]),S.useEffect(()=>{T&&G(!0)},[T]);const re=N?.find(D=>D.name===k.trim())?.type,Pe=D=>{if(!re)return;const L=Or({name:"X",label:b,kind:D,field:k}).type;return Xr(L,re)?void 0:`${k.trim()} is ${Eo(re)}, which this control cannot filter.`},Ke=b.trim()||(M?To(M):"Filter"),Re=h==="number"?"Any":h==="date"?x?new Date(`${x}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",Qe={...as(J,c),alignSelf:"flex-start","& .MuiToggleButton-root":{...as(J,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ze=(D,L,U)=>m.jsx(Zt,{select:!0,size:"small",label:"Compares",value:D??">=",onChange:V=>L(V.target.value),inputProps:{"aria-label":U},sx:{width:130},children:ag.filter(V=>V.op!=="~").map(V=>m.jsx(Xe,{value:V.op,children:V.label},V.op))});return m.jsx(Ea,{className:`${rt.dialog} ${rt.filterDialog}`,open:e,onClose:o,...l?{}:{initialFocus:Ee},title:l?u.label??u.name:"Add a filter",description:l?m.jsxs(m.Fragment,{children:[m.jsxs(B,{component:"span",sx:{fontFamily:c.font.mono},children:["$",u.name]}),p?" · declared in the model, so its label and options are set there":" · declared in this report"]}):"A filter on the page, and the tiles it filters.",actions:m.jsxs(m.Fragment,{children:[l&&m.jsx(De,{color:"error",startIcon:m.jsx(rm,{}),onClick:()=>d(u.name),sx:D=>({mr:"auto",color:nm(D)}),children:"Remove filter"}),m.jsx(De,{onClick:o,children:"Cancel"}),m.jsx(Ot,{title:me||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx(De,{variant:"contained",onClick:ne,disabled:!me,children:l?"Apply":"Add filter"})})})]}),children:m.jsxs(ft,{sx:{gap:2.5,pt:1},children:[!l&&r.length>0&&m.jsxs($d,{exclusive:!0,size:"small",value:g.kind,onChange:(D,L)=>{L==="new"?v({kind:"new"}):L==="existing"&&r[0]&&q(r[0])},"aria-label":"Where the filter comes from",sx:Qe,children:[m.jsx(ko,{value:"new",children:"New in this report"}),m.jsx(ko,{value:"existing",children:"From the model"})]}),!l&&g.kind==="existing"?m.jsx(Zt,{select:!0,size:"small",label:"Filter",value:g.name,onChange:D=>{const L=r.find(U=>U.name===D.target.value);L&&q(L)},children:r.map(D=>m.jsxs(Xe,{value:D.name,children:[D.label??D.name,m.jsxs(pe,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",D.name]})]},D.name))}):null,m.jsxs(B,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:p?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!T&&m.jsx(Vl,{value:k,onChange:Y,fields:N,accepts:K,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:Ee,error:xe!==void 0,helperText:xe??(!l&&M?`Declared as $${M}`:void 0)}),!p&&m.jsx(Zt,{size:"small",label:"Label",placeholder:M?To(M):"",value:b,onChange:D=>w(D.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),W&&!T&&Ze(A,_,"Comparison"),!l&&g.kind==="new"&&m.jsxs(B,{children:[m.jsx(Kl,{children:"Control"}),m.jsx(B,{role:"radiogroup","aria-label":"Filter kind",sx:{display:"grid",gridTemplateColumns:{xs:"repeat(3, minmax(0, 1fr))",sm:"repeat(5, minmax(0, 1fr))"},gap:1},children:cg.map(D=>{const L=D.kind===h,U=Pe(D.kind);return m.jsx(Ot,{title:U??D.hint,describeChild:!0,children:m.jsxs(cd,{role:"radio","aria-checked":L,"aria-label":D.label,"aria-disabled":U!==void 0,onClick:()=>{U===void 0&&P(D.kind)},sx:V=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${L?f.accent:J}`,boxShadow:L?`0 0 0 1px ${f.accent}`:"none",bgcolor:L?`color-mix(in srgb, ${f.accent} 6%, ${V.palette.background.paper})`:V.palette.background.paper,color:L?f.accent:V.palette.text.secondary,opacity:U?.45:1,cursor:U?"default":"pointer",transition:`border-color ${nt}, background-color ${nt}`,"&:hover":U||L?{}:{borderColor:Ve}}),children:[m.jsx(xg,{kind:D.kind}),m.jsx(B,{component:"span",sx:{...c.type.caption,fontWeight:L?600:500,color:L?f.accent:"text.primary",textAlign:"center"},children:vg[D.kind]})]})},D.kind)})}),h==="date"&&m.jsx(Zt,{size:"small",type:"date",label:"Starts at",value:x,onChange:D=>y(D.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs(B,{sx:{border:`1px solid ${J}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs(ft,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(rg,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs(pe,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx(B,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:O===E&&E>0?`Applies to all ${O} tile${O===1?"":"s"}`:`Applies to ${O} of ${E} tile${E===1?"":"s"}`}),!T&&k.trim()!==""&&O>0&&m.jsxs(B,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx(B,{component:"span",sx:{...c.type.code},children:k.trim()})]})]}),!T&&m.jsx(De,{size:"small","aria-expanded":Ae,onClick:()=>G(D=>!D),children:Ae?"Done choosing":"Choose tiles"})]}),m.jsx(tm,{in:Ae,unmountOnExit:!0,children:m.jsxs(B,{sx:{borderTop:`1px solid ${J}`,px:.5,pb:1},children:[m.jsxs(ft,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx(yo,{size:"small",checked:E>0&&O===E,indeterminate:O>0&&O<E,disabled:E===0,onChange:D=>H(D.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx(pe,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx(De,{size:"small",onClick:()=>{T||$(D=>D.map(L=>({...L,field:k}))),j(D=>!D)},children:T?"Same field for all":"Adjust per tile"})]}),m.jsx(ft,{sx:{gap:T?1:0},children:t.tiles.map((D,L)=>{if(!oe(D))return null;const U=C[L],V=D.label??D.name,we=T?te[L]:void 0;return m.jsxs(ft,{direction:"row",sx:{gap:1,alignItems:T?"flex-start":"center",opacity:F[L]?1:.6},children:[m.jsx(yo,{size:"small",disabled:!F[L],checked:(U?.include??!1)&&F[L],inputProps:{"aria-label":`Filter ${V}`},onChange:je=>z(L,{include:je.target.checked})}),m.jsx(pe,{variant:"body2",sx:{flex:1,minWidth:0,pt:T?1:0},noWrap:!0,children:V}),F[L]?T&&m.jsxs(m.Fragment,{children:[W&&Ze(U?.op,je=>z(L,{op:je}),`Comparison for ${V}`),m.jsx(Vl,{value:U?.field??"",onChange:je=>z(L,{field:je}),fields:s?.(D),accepts:K,label:"Field",ariaLabel:`Field for ${V}`,disabled:!U?.include,error:we!==void 0,helperText:we,sx:{width:220,pr:1}})]}):m.jsx(pe,{variant:"caption",sx:{color:f.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:mg(t.tiles[L]).reason})]},ue(D))})})]})})]}),O===0&&m.jsx(pe,{variant:"caption",sx:{color:"warning.main",display:"block",mt:-1.5},children:"No tile is ticked, so this control will not appear on the report."}),!p&&m.jsxs(B,{children:[m.jsx(Kl,{children:"Preview"}),m.jsx(B,{sx:D=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:D.palette.action.hover}),children:m.jsxs(B,{"aria-hidden":!0,sx:D=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${J}`,bgcolor:D.palette.background.paper,...c.type.control}),children:[m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:Ke}),m.jsx(B,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:Re}),m.jsx(wa,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function Kl({children:e}){const t=_e().theme.ui;return m.jsx(pe,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const vg={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function xg({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(Zm,{sx:t});case"multiselect":return m.jsx(Jm,{sx:t});case"text":return m.jsx(ng,{sx:t});case"number":return m.jsx(tg,{sx:t});case"date":return m.jsx(eg,{sx:t})}}function Gl({type:e}){const t=e?.replace(/_type$/,""),n=t==="string"?"Abc":t==="number"?"#":t==="date"||t==="timestamp"?"Date":t==="boolean"?"T/F":void 0,r=_e().theme.ui;return n?m.jsx(B,{component:"span","aria-hidden":!0,sx:i=>({fontFamily:r.font.mono,fontSize:10,fontWeight:r.type.label.fontWeight,color:i.palette.text.secondary,bgcolor:i.palette.action.hover,borderRadius:"4px",px:.5,py:.25,minWidth:22,textAlign:"center",flex:"none"}),children:n}):null}const Yl=mt(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function Id(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const d=structuredClone(a);return o(d),d}),apply:o=>{if(i===void 0)return;const a=structuredClone(i);o(a),s(a),JSON.stringify(a)!==JSON.stringify(e)&&n(a)},close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const bg=e=>e&&e.length===1?`This tile's chart line (${e[0]}) is not one the builder models, so its chart cannot be changed here.`:`This tile has ${e?.length??"several"} chart lines${e?` (${e.join(" and ")})`:""}, so its chart cannot be changed here.`,yg=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),wg="Its chart's bars, lines and points do not respond to a click; show it as a table to click its cells.",kg="Declared on its source, so its chart is set in the model.",Sg="It names a query, so its chart is set where that query is declared.";function $g({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:i,onDuplicate:s,duplicateBlocked:o,view:a,viewStatus:d}){const{theme:f}=_e(),c=f.ui,{draft:l,apply:u,patch:p,close:g}=Id(t,e!==null,r,n),[v,b]=S.useState(void 0),w=l!==void 0&&oe(l)?l:void 0,h=w!==void 0&&!cr(w),x=E=>u(O=>{oe(O)&&E(O)}),y=S.useRef(void 0),k=S.useRef(null),C=e!==null;S.useEffect(()=>{C?y.current=t&&oe(t)?t.chart:void 0:b(void 0)},[C]);const $=w?.chart??"default",T=Pd(a,$,d),j=w?w.declaration.kind==="query"?Sg:h?w.chart==="custom"?bg(w.chartLines):void 0:kg:void 0,M=E=>x(O=>{const N=y.current;E===(N??"default")?(N===void 0?delete O.chart:O.chart=N,delete O.chartCarried):(O.chart=E,a?O.chartCarried=a.chart?[a.chart]:[]:delete O.chartCarried)}),I=h?i?void 0:"Its source declares no dimension a click could filter by.":void 0,W=$==="default"?a?.chart:$,A=W!==void 0&&yg.has(W)?wg:void 0,z=E=>O=>b({kind:E,anchor:O.currentTarget}),_=j??(W===void 0||!jg.has(W)?"Only a bar, line, scatter or bar and line chart has a color to set.":void 0),q=Array.from(new Set(f.series.map(xd).filter(E=>E!==void 0))).slice(0,8),P=E=>x(O=>{E===void 0?delete O.color:O.color=E.toLowerCase()}),F=(E,O,N)=>m.jsxs(m.Fragment,{children:[m.jsx(Bt,{primary:E,...N?{secondary:N}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),O&&m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",ml:2},children:O})]});return m.jsxs(m.Fragment,{children:[m.jsxs(Xn,{className:rt.menu,open:e!==null&&l!==void 0,anchorEl:e,onClose:g,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":w?vt(w):"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:c.radius.menu,border:`1px solid ${cn(f.cardBorder)}`,boxShadow:c.shadow.menu}}},children:[w&&m.jsxs(Xe,{"aria-haspopup":"menu","aria-expanded":v?.kind==="chart",disabled:j!==void 0,onClick:z("chart"),onKeyDown:E=>{E.key==="ArrowRight"&&j===void 0&&b({kind:"chart",anchor:E.currentTarget})},children:[F("Chart",j?void 0:T.find(E=>E.value===$)?.label,j),m.jsx(Yl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),w&&j===void 0&&m.jsxs(Xe,{"aria-haspopup":"menu","aria-expanded":v?.kind==="color",disabled:_!==void 0,onClick:z("color"),onKeyDown:E=>{E.key==="ArrowRight"&&_===void 0&&b({kind:"color",anchor:E.currentTarget})},children:[F("Color",_?void 0:w.color??"Theme",_),!_&&m.jsx(Gs,{color:w.color??f.series[0],trailing:!0}),m.jsx(Yl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),h&&m.jsx(Xe,{"aria-haspopup":"dialog",disabled:I!==void 0,onClick:()=>{g(),i?.()},children:F("Clickable cells…",void 0,I??A)}),w&&s&&m.jsx(Xe,{disabled:o!==void 0,onClick:()=>{g(),s()},children:F("Duplicate",void 0,o)}),w?.declaration.kind==="opaque"&&m.jsxs(pe,{variant:"body2",sx:{color:f.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",w.declaration.why,", so a filter has no single place to go."]}),w&&m.jsx(nr,{}),w&&m.jsx(B,{"aria-hidden":!0,sx:{px:2,py:.5,...c.type.code,color:"text.secondary"},children:vt(w).replace("->","→")})]}),m.jsx(Xn,{className:rt.menu,open:v?.kind==="chart",anchorEl:v?.anchor??null,onClose:()=>b(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:E=>{E.key==="ArrowLeft"&&(E.preventDefault(),b(void 0))}},children:T.filter(E=>E.value!=="custom").map(E=>m.jsxs(Xe,{role:"menuitemradio","aria-checked":E.value===$,disabled:E.disabled===!0,onClick:()=>{M(E.value),b(void 0)},children:[m.jsx(Bt,{primary:E.label,...E.reason??E.hint?{secondary:E.reason??E.hint}:{}}),E.value===$&&m.jsx(bd,{sx:{minWidth:0,ml:2},children:m.jsx(Ts,{fontSize:"small",sx:{color:f.accent}})})]},E.value))}),m.jsxs(Xn,{className:rt.menu,open:v?.kind==="color",anchorEl:v?.anchor??null,onClose:()=>b(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,"aria-label":"Color",onKeyDown:E=>{E.key==="ArrowLeft"&&(E.preventDefault(),b(void 0))}},children:[m.jsxs(Xe,{role:"menuitemradio","aria-checked":w?.color===void 0,onClick:()=>{P(void 0),b(void 0)},children:[m.jsx(Gs,{color:f.series[0]}),m.jsx(Bt,{primary:"Theme",secondary:"The page's own colors"}),w?.color===void 0&&m.jsx(Xl,{color:f.accent})]}),q.map(E=>m.jsxs(Xe,{role:"menuitemradio","aria-checked":w?.color===E.toLowerCase(),onClick:()=>{P(E),b(void 0)},children:[m.jsx(Gs,{color:E}),m.jsx(Bt,{primary:E.toLowerCase()}),w?.color===E.toLowerCase()&&m.jsx(Xl,{color:f.accent})]},E)),m.jsx(nr,{}),m.jsxs(Xe,{component:"label","aria-checked":w?.color!==void 0&&!q.some(E=>E.toLowerCase()===w.color),role:"menuitemradio",onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),k.current?.click())},children:[m.jsx("input",{ref:k,type:"color","aria-label":"Other color",value:w?.color??Mg(f.series[0]),onChange:E=>{const O=E.target.value;im(O)&&p(N=>{oe(N)&&(N.color=O.toLowerCase())})},style:{width:18,height:18,padding:0,border:"none",background:"none",marginRight:12}}),m.jsx(Bt,{primary:"Other color…"})]})]})]})}const jg=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Mg=e=>(e&&xd(e))??"#000000";function Gs({color:e,trailing:t=!1}){return m.jsx(B,{"aria-hidden":!0,"data-swatch":t?"trailing":"leading",sx:{width:14,height:14,borderRadius:"3px",bgcolor:e,border:"1px solid rgba(0,0,0,0.15)",...t?{ml:1}:{mr:1.5},flex:"none"}})}function Xl({color:e}){return m.jsx(bd,{sx:{minWidth:0,ml:2},children:m.jsx(Ts,{fontSize:"small",sx:{color:e}})})}const Ds=e=>e.label??sm(vt(e));function Eg({editor:e,catalog:t,columns:n,dashboards:r,bindings:i,tiles:s,drillSource:o,setDrillSource:a,exitDialog:d,renderViewPreview:f,takenGivenNames:c}){const{filterDialog:l,setFilterDialog:u}=i,{menu:p,setMenu:g}=s,[v,b]=S.useState(),w=p===void 0?void 0:e.document.tiles[p.index],h=w&&oe(w)?w:void 0,x=(()=>{if(!h||!t)return;const y=t.documentViews?.get(h.source??"")?.get(h.name);if(y&&e.document.sources.some($=>$.name===h.source))return y;if(h.declaration.kind==="inline"||h.declaration.kind==="opaque")return;const k=e.document.sources.find($=>$.name===h.source)?.base??h.source,C=h.declaration.kind==="reference"?h.declaration.from:h.name;return t.sources.find($=>$.name===k)?.views.find($=>$.name===C)})();return m.jsxs(m.Fragment,{children:[m.jsx(gg,{open:l!==void 0,document:e.document,...l?.control?{control:l.control}:{},available:i.available,...c?{takenNames:c}:{},...t?{fieldsFor:i.fieldsFor}:{},onClose:()=>u(void 0),onApply:i.applyFilter,onRemove:i.dropControl}),m.jsx($g,{anchor:p?.anchor??null,tile:p===void 0?void 0:e.document.tiles[p.index],onClose:()=>g(void 0),onCommit:y=>{const k=p?.index;if(k===void 0)return;const C=Fm(y);e.update($=>{$.tiles[k]=C,C!==y&&rn($.tiles)&&($.tiles=Ht($.tiles,n,k))})},view:x,...x===void 0&&h?{viewStatus:t?"unlisted":"loading"}:{},onDuplicate:()=>{p&&s.duplicate(p.index)},...h&&ls(h)!==void 0?{duplicateBlocked:ls(h)}:{},...(e.document.sources.find(y=>y.name===h?.source)?.dimensions?.length??0)>0?{onDrills:()=>{b(h?Ds(h):void 0),a(h?.source)}}:{}}),m.jsx(Xm,{open:o!==void 0,document:e.document,source:e.document.sources.find(y=>y.name===o),givenNames:i.controlList.map(y=>y.name),dashboards:r??[],...v?{tileLabel:v}:{},onClose:()=>a(void 0),onApply:y=>e.update(k=>{const C=[...(k.drills??[]).filter($=>$.source!==o),...y];C.length===0?delete k.drills:k.drills=C})}),m.jsx(gp,{...d}),m.jsx(Km,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText,...f?{renderPreview:f}:{}})]})}var Cg=Symbol.for("preact-signals");function As(){if(_t>1)_t--;else{var e,t=!1;for((function(){var i=us;for(us=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}})();Zr!==void 0;){var n=Zr;for(Zr=void 0,ds++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Wd(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(ds=0,_t--,t)throw e}}function Oe(e){if(_t>0)return e();Oo=++Tg,_t++;try{return e()}finally{As()}}var Qr,ke=void 0;function ie(e){var t=ke,n=Qr;ke=void 0,Qr=void 0;try{return e()}finally{ke=t,Qr=n}}var Zr=void 0,_t=0,ds=0,Tg=0,Oo=0,us=void 0,hs=0;function Nd(e){if(ke!==void 0){var t=e.n;if(t===void 0||t.t!==ke)return t={i:0,S:e,p:ke.s,n:void 0,t:ke,e:void 0,x:void 0,r:t},ke.s!==void 0&&(ke.s.n=t),ke.s=t,e.n=t,32&ke.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=ke.s,t.n=void 0,ke.s.n=t,ke.s=t),t}}function dt(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}dt.prototype.brand=Cg;dt.prototype.h=function(){return!0};dt.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:ie(function(){var r;(r=t.W)==null||r.call(t)}))};dt.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&&ie(function(){var i;(i=t.Z)==null||i.call(t)}))}};dt.prototype.subscribe=function(e){var t=this;return $t(function(){var n=t.value;ie(function(){return e(n)})},{name:"sub"})};dt.prototype.valueOf=function(){return this.value};dt.prototype.toString=function(){return this.value+""};dt.prototype.toJSON=function(){return this.value};dt.prototype.peek=function(){var e=this;return ie(function(){return e.value})};Object.defineProperty(dt.prototype,"value",{get:function(){var e=Nd(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ds>100)throw new Error("Cycle detected");(function(n){_t!==0&&ds===0&&n.l!==Oo&&(n.l=Oo,us={S:n,v:n.v,i:n.i,o:us})})(this),this.v=e,this.i++,hs++,_t++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{As()}}}});function dr(e,t){return new dt(e,t)}function Wd(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 Ld(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 zd(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 En(e,t){dt.call(this,void 0,t),this.x=e,this.s=void 0,this.g=hs-1,this.f=4}En.prototype=new dt;En.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===hs))return!0;if(this.g=hs,this.f|=1,this.i>0&&!Wd(this))return this.f&=-2,!0;var e=ke;try{Ld(this),ke=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 ke=e,zd(this),this.f&=-2,!0};En.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)}dt.prototype.S.call(this,e)};En.prototype.U=function(e){if(this.t!==void 0&&(dt.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)}};En.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(En.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Nd(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Ql(e,t){return new En(e,t)}function Fd(e){var t=e.m;if(e.m=void 0,typeof t=="function"){_t++;var n=ke;ke=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Oa(e),r}finally{ke=n,As()}}}function Oa(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Fd(e)}function Og(e){if(ke!==this)throw new Error("Out-of-order effect");zd(this),ke=e,this.f&=-2,8&this.f&&Oa(this),As()}function ur(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Qr&&Qr.push(this)}ur.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()}};ur.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Fd(this),Ld(this),_t++;var e=ke;return ke=this,Og.bind(this,e)};ur.prototype.N=function(){2&this.f||(this.f|=2,this.u=Zr,Zr=this)};ur.prototype.d=function(){this.f|=8,1&this.f||Oa(this)};ur.prototype.dispose=function(){this.d()};function $t(e,t){var n=new ur(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Dg=Object.create,Da=Object.defineProperty,Ag=Object.defineProperties,Pg=Object.getOwnPropertyDescriptor,Rg=Object.getOwnPropertyDescriptors,Zl=Object.getOwnPropertySymbols,Ig=Object.prototype.hasOwnProperty,Ng=Object.prototype.propertyIsEnumerable,Wg=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),hr=e=>{throw TypeError(e)},Do=(e,t,n)=>t in e?Da(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Lg=(e,t)=>{for(var n in t||(t={}))Ig.call(t,n)&&Do(e,n,t[n]);if(Zl)for(var n of Zl(t))Ng.call(t,n)&&Do(e,n,t[n]);return e},zg=(e,t)=>Ag(e,Rg(t)),Jl=(e,t)=>Da(e,"name",{value:t,configurable:!0}),Fg=e=>{var t;return[,,,Dg((t=void 0)!=null?t:null)]},Bd=["class","method","getter","setter","accessor","field","value","get","set"],Dr=e=>e!==void 0&&typeof e!="function"?hr("Function expected"):e,Bg=(e,t,n,r,i)=>({kind:Bd[e],name:t,metadata:r,addInitializer:s=>n._?hr("Already initialized"):i.push(Dr(s||null))}),_d=(e,t)=>Do(t,Wg("metadata"),e[3]),un=(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},fr=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=Bd[l+5],b=l>3&&(e[g-1]=[]),w=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&Pg(l<4?i:{get[n](){return yt(this,s)},set[n](y){return Xt(this,s,y)}},n));l?p&&l<4&&Jl(s,(l>2?"set ":l>1?"get ":"")+n):Jl(i,n);for(var x=r.length-1;x>=0;x--)f=Bg(l,n,d={},e[3],w),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>_g(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?yt:qg)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,k)=>Xt(y,i,k,l^4?s:h.set):(y,k)=>y[n]=k)),a=(0,r[x])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?Dr(a)&&(l>4?b.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?hr("Object expected"):(Dr(o=a.get)&&(h.get=o),Dr(o=a.set)&&(h.set=o),Dr(o=a.init)&&b.unshift(o));return l||_d(e,i),h&&Da(i,n,h),p?l^4?s:h:i},Aa=(e,t,n)=>t.has(e)||hr("Cannot "+n),_g=(e,t)=>Object(t)!==t?hr('Cannot use the "in" operator on this value'):e.has(t),yt=(e,t,n)=>(Aa(e,t,"read from private field"),n?n.call(e):t.get(e)),Ar=(e,t,n)=>t.has(e)?hr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xt=(e,t,n,r)=>(Aa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),qg=(e,t,n)=>(Aa(e,t,"access private method"),n);function Ao(e,t){if(t){let n;return Ql(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Ql(e)}function Ct(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((n,r)=>!Ct(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!Ct(e[i],t[i]))}return!1}function se({get:e},t){return{init(n){return dr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function We(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Ao(e.bind(this)),n.set(this,r)),r.value}}function Ys(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,zg(Lg({},i),{enumerable:e}))})}}function xi(...e){const t=e.map(n=>$t(n));return()=>t.forEach(n=>n())}var qd,Hd,Ud,Vd,Kd,Gd,ot,Pa,Xs,Po,Ro,tt,Ra,Qs,Yd,Io,Ia,Zs,No,Wo;Gd=[se],Kd=[se],Vd=[se],Ud=[Ys()],Hd=[Ys()],qd=[Ys()];var Cn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,un(ot,5,this),Ar(this,tt),Ar(this,Pa,un(ot,8,this)),un(ot,11,this),Ar(this,Ra,un(ot,12,this)),un(ot,15,this),Ar(this,Ia,un(ot,16,this)),un(ot,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return yt(this,tt,No)}get initial(){return yt(this,tt,Po)}get previous(){return yt(this,tt,Yd)}set current(e){const t=ie(()=>yt(this,tt,No));e&&t&&this.equals(t,e)||Oe(()=>{yt(this,tt,Po)||Xt(this,tt,e,Ro),Xt(this,tt,t,Io),Xt(this,tt,e,Wo)})}reset(e=this.defaultValue){Oe(()=>{Xt(this,tt,void 0,Io),Xt(this,tt,e,Ro),Xt(this,tt,e,Wo)})}};ot=Fg();Pa=new WeakMap;tt=new WeakSet;Ra=new WeakMap;Ia=new WeakMap;Xs=fr(ot,20,"#initial",Gd,tt,Pa),Po=Xs.get,Ro=Xs.set;Qs=fr(ot,20,"#previous",Kd,tt,Ra),Yd=Qs.get,Io=Qs.set;Zs=fr(ot,20,"#current",Vd,tt,Ia),No=Zs.get,Wo=Zs.set;fr(ot,2,"current",Ud,Cn);fr(ot,2,"initial",Hd,Cn);fr(ot,2,"previous",qd,Cn);_d(ot,Cn);function Js(e){return ie(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var hn,Hg=class{constructor(){Ar(this,hn,new WeakMap)}get(e,t){var n;return e?(n=yt(this,hn).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return yt(this,hn).has(e)||yt(this,hn).set(e,new Map),(r=yt(this,hn).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=yt(this,hn).get(e))==null?void 0:t.clear():void 0}};hn=new WeakMap;var Ug=Object.create,Xd=Object.defineProperty,Vg=Object.getOwnPropertyDescriptor,ec=Object.getOwnPropertySymbols,Kg=Object.prototype.hasOwnProperty,Gg=Object.prototype.propertyIsEnumerable,Qd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ps=e=>{throw TypeError(e)},tc=Math.pow,Lo=(e,t,n)=>t in e?Xd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yg=(e,t)=>{for(var n in t||(t={}))Kg.call(t,n)&&Lo(e,n,t[n]);if(ec)for(var n of ec(t))Gg.call(t,n)&&Lo(e,n,t[n]);return e},Xg=e=>{var t;return[,,,Ug((t=e?.[Qd("metadata")])!=null?t:null)]},Zd=["class","method","getter","setter","accessor","field","value","get","set"],Jd=e=>e!==void 0&&typeof e!="function"?Ps("Function expected"):e,Qg=(e,t,n,r,i)=>({kind:Zd[e],name:t,metadata:r,addInitializer:s=>n._?Ps("Already initialized"):i.push(Jd(s||null))}),Zg=(e,t)=>Lo(t,Qd("metadata"),e[3]),Jg=(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},eu=(e,t,n,r,i,s)=>{for(var o,a,d,f,c=t&7,l=!1,u=!1,p=2,g=Zd[c+5],v=e[p]||(e[p]=[]),b=(i=i.prototype,Vg(i,n)),w=r.length-1;w>=0;w--)d=Qg(c,n,a={},e[3],v),d.static=l,d.private=u,f=d.access={has:h=>n in h},f.get=h=>h[n],o=(0,r[w])(b[g],d),a._=1,Jd(o)&&(b[g]=o);return b&&Xd(i,n,b),i},tu=(e,t,n)=>t.has(e)||Ps("Cannot "+n),ev=(e,t,n)=>(tu(e,t,"read from private field"),t.get(e)),tv=(e,t,n)=>t.has(e)?Ps("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),nv=(e,t,n,r)=>(tu(e,t,"write to private field"),t.set(e,n),n),wt=class zo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new zo(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 zo(t,n)}},Nt=class fn{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,d=new fn(i+t,r+n,s,o);return d.scale=Yg({},a),d}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 wt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof fn))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 fn?rv(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 fn(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],d=o==="x"?s.left:s.top,f=o==="x"?s.width:s.height;return a=="start"?d:a=="end"?d+f:d+f/2};return wt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return fn.from(t).intersectionRatio(fn.from(n))}};function rv(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 nu,ru,Fo,_i,bi,Rs=class extends(Fo=Cn,ru=[We],nu=[We],Fo){constructor(e){const t=wt.from(e);super(t,(n,r)=>wt.equals(n,r)),Jg(bi,5,this),tv(this,_i,0),this.velocity={x:0,y:0}}get delta(){return wt.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=wt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-ev(this,_i),o=a=>Math.round(a/s*100);Oe(()=>{nv(this,_i,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(wt.from(e)),this.velocity={x:0,y:0}}};bi=Xg(Fo);_i=new WeakMap;eu(bi,2,"delta",ru,Rs);eu(bi,2,"direction",nu,Rs);Zg(bi,Rs);function Bo({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(tc(r,2)+tc(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 iu=(e=>(e.Horizontal="x",e.Vertical="y",e))(iu||{}),su=Object.values(iu),iv=Object.create,Na=Object.defineProperty,sv=Object.defineProperties,ov=Object.getOwnPropertyDescriptor,av=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertySymbols,ou=Object.prototype.hasOwnProperty,au=Object.prototype.propertyIsEnumerable,lu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),pr=e=>{throw TypeError(e)},_o=(e,t,n)=>t in e?Na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wa=(e,t)=>{for(var n in t||(t={}))ou.call(t,n)&&_o(e,n,t[n]);if(fs)for(var n of fs(t))au.call(t,n)&&_o(e,n,t[n]);return e},La=(e,t)=>sv(e,av(t)),nc=(e,t)=>Na(e,"name",{value:t,configurable:!0}),cu=(e,t)=>{var n={};for(var r in e)ou.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fs)for(var r of fs(e))t.indexOf(r)<0&&au.call(e,r)&&(n[r]=e[r]);return n},mr=e=>{var t;return[,,,iv((t=e?.[lu("metadata")])!=null?t:null)]},du=["class","method","getter","setter","accessor","field","value","get","set"],Pr=e=>e!==void 0&&typeof e!="function"?pr("Function expected"):e,lv=(e,t,n,r,i)=>({kind:du[e],name:t,metadata:r,addInitializer:s=>n._?pr("Already initialized"):i.push(Pr(s||null))}),Tn=(e,t)=>_o(t,lu("metadata"),e[3]),Z=(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},ae=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=du[l+5],b=l>3&&(e[g-1]=[]),w=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&ov(l<4?i:{get[n](){return Ne(this,s)},set[n](y){return xt(this,s,y)}},n));l?p&&l<4&&nc(s,(l>2?"set ":l>1?"get ":"")+n):nc(i,n);for(var x=r.length-1;x>=0;x--)f=lv(l,n,d={},e[3],w),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>cv(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?Ne:uu)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,k)=>xt(y,i,k,l^4?s:h.set):(y,k)=>y[n]=k)),a=(0,r[x])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?Pr(a)&&(l>4?b.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?pr("Object expected"):(Pr(o=a.get)&&(h.get=o),Pr(o=a.set)&&(h.set=o),Pr(o=a.init)&&b.unshift(o));return l||Tn(e,i),h&&Na(i,n,h),p?l^4?s:h:i},za=(e,t,n)=>t.has(e)||pr("Cannot "+n),cv=(e,t)=>Object(t)!==t?pr('Cannot use the "in" operator on this value'):e.has(t),Ne=(e,t,n)=>(za(e,t,"read from private field"),n?n.call(e):t.get(e)),fe=(e,t,n)=>t.has(e)?pr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xt=(e,t,n,r)=>(za(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),uu=(e,t,n)=>(za(e,t,"access private method"),n);function hu(e,t){return{plugin:e,options:t}}function yi(e){return t=>hu(e,t)}function ai(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var fu,li,Fa,qi;fu=[se];var it=class{constructor(e,t){this.manager=e,this.options=t,fe(this,Fa,Z(li,8,this,!1)),Z(li,11,this),fe(this,qi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return ie(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=$t(e.bind(this));return Ne(this,qi).add(t),t}destroy(){Ne(this,qi).forEach(e=>e())}static configure(e){return hu(this,e)}};li=mr(null);Fa=new WeakMap;qi=new WeakMap;ae(li,4,"disabled",fu,it,Fa);Tn(li,it);var wi=class extends it{},Hi,eo=class{constructor(e){this.manager=e,this.instances=new Map,fe(this,Hi,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ai).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 Ne(this,Hi))if(!n.includes(r)){if(r.prototype instanceof wi)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);xt(this,Hi,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()}};Hi=new WeakMap;function dv(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Oi=[],Fn,Bn,uv=class extends it{constructor(e){super(e),fe(this,Fn),fe(this,Bn),this.computeCollisions=this.computeCollisions.bind(this),xt(this,Bn,dr(Oi)),this.destroy=xi(()=>{const t=this.computeCollisions(),n=ie(()=>this.manager.dragOperation.position.current);if(t!==Oi){const r=Ne(this,Fn);if(xt(this,Fn,n),r&&n.x==r.x&&n.y==r.y)return}else xt(this,Fn,void 0);Ne(this,Bn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){ie(()=>{e?Ne(this,Bn).value=this.computeCollisions():xt(this,Fn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Oi;const a=[],d=[];for(const f of e??n.droppables){if(f.disabled||i&&!f.accepts(i))continue;const c=t??f.collisionDetector;if(!c)continue;d.push(f),f.shape;const l=ie(()=>c({droppable:f,dragOperation:r}));l&&(f.collisionPriority!=null&&(l.priority=f.collisionPriority),a.push(l))}return d.length===0?Oi:(a.sort(dv),a)}get collisions(){return Ne(this,Bn).value}};Fn=new WeakMap;Bn=new WeakMap;var pu,mu,gu,Ba,vu,Tt,_a,Gn,qa,Ha;gu=[se],mu=[se],pu=[se];var Ut=class pn{constructor(t,n){fe(this,_a,Z(Tt,8,this)),Z(Tt,11,this),fe(this,Gn),fe(this,qa,Z(Tt,12,this)),Z(Tt,15,this),fe(this,Ha,Z(Tt,16,this)),Z(Tt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let d=i;xt(this,Gn,dr(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var f;return[()=>{const{id:c,manager:l}=this;if(c!==d)return d=c,l?.registry.register(this),()=>l?.registry.unregister(this)},...(f=r?.())!=null?f:[]]},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=Ne(this,Gn).value;return(n=(t=pn.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=pn.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Ne(this,Gn).peek();t!==i&&(pn.pendingIdChanges||(pn.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return uu(s=pn,Ba,vu).call(s)})),pn.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)}};Tt=mr(null);Ba=new WeakSet;vu=function(){const e=Ut.pendingIdChanges;Ut.pendingIdChanges=null,e&&Oe(()=>{for(const[t,n]of e)Ne(t,Gn).value=n})};_a=new WeakMap;Gn=new WeakMap;qa=new WeakMap;Ha=new WeakMap;ae(Tt,4,"manager",gu,Ut,_a);ae(Tt,4,"data",mu,Ut,qa);ae(Tt,4,"disabled",pu,Ut,Ha);fe(Ut,Ba);Tn(Tt,Ut);Ut.pendingIdChanges=null;var Is=Ut,rc=class{constructor(){this.map=dr(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,d]of n)if(d===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=xi(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},xu,bu,yu,wu,ku,Su,qo,at,Ua,Va,Ka,Wt=class extends(qo=Is,Su=[se],ku=[se],wu=[se],yu=[We],bu=[We],xu=[We],qo){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,d=cu(n,["modifiers","type","sensors","plugins","effects"]);super(La(Wa({},d),{effects:()=>{var f;return[...(f=a?.())!=null?f:[],()=>{const{manager:c,plugins:l}=this;if(!(!c||!l))for(const u of l){const{plugin:p}=ai(u);c.registry.plugins.register(p)}}]}}),t),Z(at,5,this),fe(this,Ua,Z(at,8,this)),Z(at,11,this),fe(this,Va,Z(at,12,this)),Z(at,15,this),fe(this,Ka,Z(at,16,this,this.isDragSource?"dragging":"idle")),Z(at,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=d.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=ai(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.source)==null?void 0:t.id)===this.id}};at=mr(qo);Ua=new WeakMap;Va=new WeakMap;Ka=new WeakMap;ae(at,4,"type",Su,Wt,Ua);ae(at,4,"modifiers",ku,Wt,Va);ae(at,4,"status",wu,Wt,Ka);ae(at,2,"isDropping",yu,Wt);ae(at,2,"isDragging",bu,Wt);ae(at,2,"isDragSource",xu,Wt);Tn(at,Wt);var $u,ju,Mu,Eu,Cu,Tu,Ho,He,Ga,Ya,Xa,Qa,Za,Lt=class extends(Ho=Is,Tu=[se],Cu=[se],Eu=[se],Mu=[se],ju=[se],$u=[We],Ho){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=cu(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),Z(He,5,this),fe(this,Ga,Z(He,8,this)),Z(He,11,this),fe(this,Ya,Z(He,12,this)),Z(He,15,this),fe(this,Xa,Z(He,16,this)),Z(He,19,this),fe(this,Qa,Z(He,20,this)),Z(He,23,this),fe(this,Za,Z(He,24,this)),Z(He,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=s,this.type=o}accepts(e){const{accept:t}=this;return t?typeof t=="function"?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.target)==null?void 0:t.id)===this.id}};He=mr(Ho);Ga=new WeakMap;Ya=new WeakMap;Xa=new WeakMap;Qa=new WeakMap;Za=new WeakMap;ae(He,4,"accept",Tu,Lt,Ga);ae(He,4,"type",Cu,Lt,Ya);ae(He,4,"collisionDetector",Eu,Lt,Xa);ae(He,4,"collisionPriority",Mu,Lt,Qa);ae(He,4,"shape",ju,Lt,Za);ae(He,2,"isDropTarget",$u,Lt);Tn(He,Lt);var hv=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)}},fv=class extends hv{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Ui(e,t=!0){let n=!1;return La(Wa({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var pv=class extends wi{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=xi(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Is.pendingIdChanges)return;const o=Ui({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;ie(()=>{var d;a?.id!==((d=e.dragOperation.target)==null?void 0:d.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},gr=(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))(gr||{}),vr=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(vr||{}),Ou,Du,Au,Pu,Ru,Iu,Nu,St,Ja;Nu=[se],Iu=[We],Ru=[We],Pu=[We],Au=[We],Du=[We],Ou=[We];var Kt=class{constructor(){Z(St,5,this),fe(this,Ja,Z(St,8,this,"idle")),Z(St,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}};St=mr(null);Ja=new WeakMap;ae(St,4,"value",Nu,Kt,Ja);ae(St,2,"current",Iu,Kt);ae(St,2,"idle",Ru,Kt);ae(St,2,"initializing",Pu,Kt);ae(St,2,"initialized",Au,Kt);ae(St,2,"dragging",Du,Kt);ae(St,2,"dropped",Ou,Kt);Tn(St,Kt);var mv=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 ie(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Ui({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return ie(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const n=new AbortController,{event:r,coordinates:i}=e;Oe(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=Ui({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",s),s.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set("initializing"),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;const{status:o}=t;o.current==="initializing"&&Oe(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return ie(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Ui({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,d,f,c,l;if(o.defaultPrevented)return;const u=(l=e.to)!=null?l:{x:r.position.current.x+((d=(a=e.by)==null?void 0:a.x)!=null?d:0),y:r.position.current.y+((c=(f=e.by)==null?void 0:f.y)!=null?c:0)};r.position.current=u})})}stop(e={}){return ie(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const d={resume:()=>{},abort:()=>{}};return s=new Promise((f,c)=>{d.resume=f,d.abort=c}),d};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const d=ie(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),f=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(d){const{source:c}=r,l=$t(()=>{c?.status==="idle"&&(l(),f())})}else this.manager.renderer.rendering.then(f)})};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()})}},rr=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}},gv=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)}},Vi,Wu=class{constructor(e){this.options=e,fe(this,Vi)}set controller(e){xt(this,Vi,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ne(this,Vi))==null||t.activate(e)}};Vi=new WeakMap;var ic=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},vv=class{constructor(e){this.draggables=new rc,this.droppables=new rc,this.plugins=new eo(e),this.sensors=new eo(e),this.modifiers=new eo(e)}register(e,t){if(e instanceof Wt)return this.draggables.register(e.id,e);if(e instanceof Lt)return this.droppables.register(e.id,e);if(e.prototype instanceof ic)return this.modifiers.register(e,t);if(e.prototype instanceof rr)return this.sensors.register(e,t);if(e.prototype instanceof it)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Is)return e instanceof Wt?this.draggables.unregister(e.id,e):e instanceof Lt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ic)return this.modifiers.unregister(e);if(e.prototype instanceof rr)return this.sensors.unregister(e);if(e.prototype instanceof it)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()}},Lu,zu,Fu,Bu,_u,qu,Hu,Uu,Vu,Rr,Ki,_n,Te,el,tl,nl,rl,il,Ir;Vu=[We],Uu=[se],Hu=[se],qu=[se],_u=[se],Bu=[se],Fu=[We],zu=[We],Lu=[We];var Pt=class{constructor(e){Z(Te,5,this),fe(this,Rr),fe(this,Ki),fe(this,_n,new Cn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Kt,fe(this,el,Z(Te,8,this,!1)),Z(Te,11,this),fe(this,tl,Z(Te,12,this,null)),Z(Te,15,this),fe(this,nl,Z(Te,16,this,null)),Z(Te,19,this),fe(this,rl,Z(Te,20,this,null)),Z(Te,23,this),fe(this,il,Z(Te,24,this,[])),Z(Te,27,this),this.position=new Rs({x:0,y:0}),fe(this,Ir,{x:0,y:0}),xt(this,Rr,e)}get shape(){const{current:e,initial:t,previous:n}=Ne(this,_n);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ne(this,_n).current=e:Ne(this,_n).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ne(this,Rr).registry.draggables.get(t);return n&&xt(this,Ki,n),(e=n??Ne(this,Ki))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ne(this,Rr).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(La(Wa({},this.snapshot()),{transform:n}));return xt(this,Ir,n),n}snapshot(){return ie(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ne(this,Ir),shape:this.shape?Js(this.shape):null,position:Js(this.position),status:Js(this.status),canceled:this.canceled}))}reset(){Oe(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ne(this,_n).reset(),this.position.reset({x:0,y:0}),xt(this,Ir,{x:0,y:0}),this.modifiers=[]})}};Te=mr(null);Rr=new WeakMap;Ki=new WeakMap;_n=new WeakMap;el=new WeakMap;tl=new WeakMap;nl=new WeakMap;rl=new WeakMap;il=new WeakMap;Ir=new WeakMap;ae(Te,2,"shape",Vu,Pt);ae(Te,4,"canceled",Uu,Pt,el);ae(Te,4,"activatorEvent",Hu,Pt,tl);ae(Te,4,"sourceIdentifier",qu,Pt,nl);ae(Te,4,"targetIdentifier",_u,Pt,rl);ae(Te,4,"modifiers",Bu,Pt,il);ae(Te,2,"source",Fu,Pt);ae(Te,2,"target",zu,Pt);ae(Te,2,"transform",Lu,Pt);Tn(Te,Pt);var xv={get rendering(){return Promise.resolve()}};function At(e,t){return typeof e=="function"?e(t):e??t}var bv=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(l=>l.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=At(n.plugins,[]),i=At(n.sensors,[]),s=At(n.modifiers,[]),o=(t=n.renderer)!=null?t:xv,a=new fv(this),d=new vv(this);this.registry=d,this.monitor=a,this.renderer=o,this.actions=new mv(this),this.dragOperation=new Pt(this),this.collisionObserver=new uv(this),this.plugins=[pv,...r],this.modifiers=s,this.sensors=i;const{destroy:f}=this,c=xi(()=>{var l,u,p;const g=ie(()=>this.dragOperation.modifiers),v=this.modifiers;for(const b of g)v.includes(b)||b.destroy();this.dragOperation.modifiers=(p=(u=(l=this.dragOperation.source)==null?void 0:l.modifiers)==null?void 0:u.map(b=>{const{plugin:w,options:h}=ai(b);return new w(this,h)}))!=null?p:v});this.destroy=()=>{c(),f()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Ku=e=>{throw TypeError(e)},sl=(e,t,n)=>t.has(e)||Ku("Cannot "+n),Q=(e,t,n)=>(sl(e,t,"read from private field"),t.get(e)),ut=(e,t,n)=>t.has(e)?Ku("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),gt=(e,t,n,r)=>(sl(e,t,"write to private field"),t.set(e,n),n),Gu=(e,t,n)=>(sl(e,t,"access private method"),n);function Ns(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Yu(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(Ns(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function Ws(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 ol(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ki(e){return"nodeType"in e}function bt(e){var t,n,r;return e?ol(e)?e:ki(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 al(e){const{Document:t}=bt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function on(e){return!e||ol(e)?!1:e instanceof bt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Xu(e){return e instanceof bt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function xr(e){return e?ol(e)?e.document:ki(e)?al(e)?e:on(e)||Xu(e)?e.ownerDocument:document:document:document}function yv(e){var t,n,r,i;const{documentElement:s}=xr(e),o=bt(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,d=(n=o?.height)!=null?n:s.clientHeight,f=(r=o?.offsetTop)!=null?r:0,c=(i=o?.offsetLeft)!=null?i:0;return{top:f,left:c,right:c+a,bottom:f+d,width:a,height:d}}function wv(e,t){if(kv(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function kv(e){return e.tagName==="DETAILS"}function ci(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let d=t;const{ownerDocument:f}=e,c=(r=f.defaultView)!=null?r:window;let l=e.parentElement;for(;l&&l!==f.documentElement;){if(!wv(l)){const x=l.getBoundingClientRect(),y=n*(x.bottom-x.top),k=n*(x.right-x.left),C=n*(x.bottom-x.top),$=n*(x.right-x.left);d={top:Math.max(d.top,x.top-y),right:Math.min(d.right,x.right+k),bottom:Math.min(d.bottom,x.bottom+C),left:Math.max(d.left,x.left-$),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top}l=l.parentElement}const u=c.visualViewport,p=(i=u?.offsetTop)!=null?i:0,g=(s=u?.offsetLeft)!=null?s:0,v=(o=u?.width)!=null?o:c.innerWidth,b=(a=u?.height)!=null?a:c.innerHeight,w=n*b,h=n*v;return d={top:Math.max(d.top,p-w),right:Math.min(d.right,g+v+h),bottom:Math.min(d.bottom,p+b+w),left:Math.max(d.left,g-h),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top,d.width<0&&(d.width=0),d.height<0&&(d.height=0),d}function ir(e){return{x:e.clientX,y:e.clientY}}var Qu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Uo(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(...Uo(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(...Uo(i.document,t))}}catch{}return n}function ll(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Zu(){var e,t;const n=ll()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function cl(e){return!e||!ki(e)?!1:e instanceof bt(e).ShadowRoot}function ps(e){if(e&&ki(e)){let t=e.getRootNode();if(cl(t)||t instanceof Document)return t}return xr(e)}function dl(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Sv(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,s)=>{const o=r[s];sc(i)&&sc(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),oc(i)&&oc(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function sc(e){return"value"in e}function oc(e){return e.tagName==="CANVAS"}function Ju(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if($v(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Ju(i,{x:t-s,y:n-o})}}return r}function $v(e){return e?.tagName==="IFRAME"}var Vo=new WeakMap;function jv(e){return e.closest(`
1
+ import{X as id,R as _e,aO as cn,aP as Cs,r as S,j as m,ad as ft,az as rt,L as Ot,K as $n,aQ as nr,a2 as De,aR as wa,aS as vi,aT as Xn,aU as ep,aV as sd,aW as rn,aX as tp,aY as np,aZ as mo,a_ as rp,T as pe,a1 as ht,a$ as ip,b0 as sp,b1 as op,O as ka,ak as ap,b2 as Qt,b3 as lp,b4 as Sa,b5 as cp,b6 as od,b7 as ad,b8 as dp,b9 as up,a0 as go,ba as hp,bb as fp,bc as vo,aF as ld,B as cd,bd as nt,I as B,aj as Xe,be as mt,bf as $a,W as Bt,bg as pp,bh as pt,bi as Il,bj as Gr,bk as dd,bl as mp,bm as ja,bn as gp,bo as vp,bp as xp,bq as bp,br as yp,bs as wp,bt as ud,bu as kp,bv as Sp,bw as hd,bx as fd,by as pd,bz as $p,bA as jp,bB as Mp,bC as Ep,bD as Cp,bE as Tp,bF as Op,bG as Dp,F as Ap,bH as Pp,bI as Rp,bJ as xo,bK as bo,bL as Nl,bM as Ip,bN as Np,bO as Wp,bP as Qn,bQ as Lp,bR as zp,bS as Fp,bT as Bp,bU as _p,bV as md,bW as Ma,bX as qp,bY as Hp,bZ as gd,b_ as Up,b$ as Vp,c0 as Kp,c1 as Ts,c2 as ns,c3 as Gp,c4 as Yp,c5 as rs,c6 as Xp,c7 as kn,c8 as Qp,c9 as Zp,ca as vd,cb as Jp,cc as em,ap as Ea,af as Zt,cd as tm,ce as yo,cf as nm,cg as rm,ch as xd,V as bd,ci as im,cj as sm,ck as Os,cl as om,cm as wo,cn as am,co as lm,cp as cm,cq as yd,cr as dm,G as um,cs as hm,ct as fm,cu as pm,cv as mm,cw as gm,cx as vm,cy as xm,cz as Ca,cA as bm,cB as ym,cC as wd,cD as wm,cE as km,cF as Sm,cG as Ta,cH as $m,cI as jm,cJ as Mm,cK as Pn,cL as kd,cM as Wl,cN as Ll,cO as Vs,cP as Em,S as Cm,cQ as Tm,cR as Om,cS as Dm,cT as Sd,cU as Am,cV as Pm,as as Rm}from"./index-CCLHq9po.js";import{cW as Ww,cX as Lw,cY as zw,cZ as Fw,c_ as Bw,c$ as _w,d0 as qw,d1 as Hw,d2 as Uw,d3 as Vw,d4 as Kw}from"./index-CCLHq9po.js";import{T as $d,a as ko}from"./ToggleButtonGroup-eURRljZv.js";var zl={};const $e=e=>e.kind==="text",oe=e=>e.kind!=="text",Mr=e=>oe(e)?e.label??e.name:e.name,vt=e=>e.declaration.kind==="query"?e.name:`${e.source} -> ${e.name}`,cr=e=>e.declaration.kind==="inherited"||e.declaration.kind==="query",ue=e=>$e(e)?`text.${e.name}`:e.declaration.kind==="query"?`query.${e.name}`:`${e.source}.${e.name}`,Fl=".malloy-big-value, .malloy-table",Im=e=>e.querySelector(Fl)!==null&&![...e.querySelectorAll(".malloy-chart")].some(t=>t.closest(Fl)===null),is=(e,t)=>$e(e)?Gp:t&&Im(t)?Yp:rs,ii=e=>e.rowspan??ja[$e(e)?"text":"query"];function sn(e,t){if(e.row===void 0||e.col===void 0)return;const n=Math.min(e.colspan??1,t);return{row:e.row,col:Math.min(e.col,t-n+1),colspan:n,rowspan:ii(e)}}const si=(e,t)=>e.col<t.col+t.colspan&&t.col<e.col+e.colspan&&e.row<t.row+t.rowspan&&t.row<e.row+e.rowspan;function Kn(e){return e.map((t,n)=>({tile:t,index:n})).sort((t,n)=>(t.tile.row??1/0)-(n.tile.row??1/0)||(t.tile.col??1/0)-(n.tile.col??1/0)||t.index-n.index).map(({tile:t})=>t)}function Ht(e,t,n){const r=e.map(a=>({...a})),i=[],s=a=>{const d=sn(r[a],t);d&&(r[a].col=d.col,i.push(d))};n!==void 0&&s(n);const o=r.map((a,d)=>({tile:a,index:d})).filter(({index:a,tile:d})=>a!==n&&d.row!==void 0).sort((a,d)=>(a.tile.row??0)-(d.tile.row??0)||(a.tile.col??0)-(d.tile.col??0)||a.index-d.index);for(const{index:a}of o){const d=sn(r[a],t);if(d){for(;;){const f=i.filter(c=>si(d,c));if(f.length===0)break;d.row=Math.max(...f.map(c=>c.row+c.rowspan))}r[a].row=d.row,s(a)}}return r}function Nm(e,t,n,r){const i=e.flatMap((d,f)=>{const c=f===t?void 0:sn(d,r);return c?[c]:[]}),s=Math.max(1,...i.map(d=>d.row+d.rowspan)),o={...e[t],...n,row:Math.min(n.row,s)},a=sn(o,r);if(a){for(;;){const d=i.filter(f=>f.row<a.row&&si(a,f));if(d.length===0)break;a.row=Math.max(...d.map(f=>f.row+f.rowspan))}o.row=a.row}return Ht(e.map((d,f)=>f===t?o:d),r,t)}const ss=(e,t)=>(e-pt*(t-1))/t,jd=ns+pt;function Md(e,t,n,r,i){const s=Math.min(n,r),o=Math.round(e/(i+pt))+1;return{row:Math.max(1,Math.round(t/jd)+1),col:Math.min(Math.max(o,1),r-s+1)}}function Ed(e,t,n,r){const i=e.map((s,o)=>{if(s.row!==void 0&&s.col!==void 0)return s;const a=t[o];if(!a)return s;const{break:d,...f}=s,c=s.colspan??Math.max(1,Math.round((a.width+pt)/(r+pt))),l=Md(a.left,a.top,c,n,r),u=(a.top+a.height+pt)/jd,p=$e(s)?Math.ceil(u-.02):Math.round(u);return{...f,...l,colspan:c,rowspan:s.rowspan??Math.max(is(s),p-l.row+1)}});return Ht(i,n)}function Bl(e,t,n){const r=e.flatMap((s,o)=>{const a=o===t?void 0:sn(s,n);return a?[a]:[]});if(r.length===0)return[...e];const i=Math.max(...r.map(s=>s.row+s.rowspan));return e.map((s,o)=>o===t?{...s,row:i,col:1}:s)}function Cd(e,t){const n=e.map(s=>({...s})),r=[],i=n.map((s,o)=>({tile:s,index:o})).filter(({tile:s})=>s.row!==void 0&&s.col!==void 0).sort((s,o)=>(s.tile.row??0)-(o.tile.row??0)||(s.tile.col??0)-(o.tile.col??0)||s.index-o.index);for(const{index:s}of i){const o=sn(n[s],t);if(o){for(;o.row>1&&!r.some(a=>si({...o,row:o.row-1},a));)o.row-=1;n[s].row=o.row,n[s].col=o.col,r.push(o)}}return n}const Wm=(e,t)=>Cd(e,t).some((n,r)=>n.row!==e[r].row||n.col!==e[r].col);function Lm(e){return Kn(e).map(t=>{const{row:n,col:r,...i}=t;return i})}const zm=(e,t,n)=>e.map((r,i)=>i===t?{...r,...n}:r);function _l(e,t,n,r,i){const s=sn(e[t],i);if(!s)return[...e];const o={row:Math.max(1,s.row+n),col:Math.min(Math.max(1,s.col+r),i-s.colspan+1)};if(o.row===s.row&&o.col===s.col)return[...e];const a={...s,...o},d=e.flatMap((p,g)=>{const v=g===t?void 0:sn(p,i);return v&&si(a,v)&&!si(s,v)?[{i:g,other:v}]:[]}),f=d.length===1?d[0]:void 0;if(!f)return Ht(zm(e,t,o),i,t);const{i:c,other:l}=f,u=e.map(p=>({...p}));return n>0?(u[c].row=s.row,u[t].row=s.row+l.rowspan):n<0?(u[t].row=l.row,u[c].row=l.row+s.rowspan):r>0?(u[c].col=s.col,u[t].col=s.col+l.colspan):(u[t].col=l.col,u[c].col=l.col+s.colspan),Ht(u,i,t)}const Td=(e,t)=>e?.col===void 0?t:Math.max(1,t-e.col+1);function Fm(e){return $e(e)||e.rowspan===void 0?e:Os(e.chart)&&e.chart!=="big_value"&&e.rowspan<rs?{...e,rowspan:rs}:e}const Od=mt(m.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),Dd=mt(m.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),Bm=mt(m.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}));function Ad(e){const{theme:t}=_e(),n=t.ui,[r,i]=S.useState(null),{status:s,draftKeptAt:o,discard:a,restored:d,dismissRestored:f}=e,c=d!==void 0&&!d.pending&&s==="unsaved"?d:void 0,l=s==="saved"?"Saved":s==="saving"?"Saving…":o!==void 0?"Draft saved":"Unsaved changes",u=c?`Restored your unsaved edits from ${So(c.savedAt)}`:void 0,p=s==="unsaved"&&o!==void 0?"Your edits are kept in this browser. Done saves them to the report.":e.saveTarget,g=a!==void 0&&s==="unsaved",v=()=>{i(null),c&&f?.()},b=x=>({display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:.75,minWidth:132,height:n.size.control,px:1,borderRadius:n.radius.control,font:"inherit",...n.type.control,whiteSpace:"nowrap",color:s==="saved"?x.palette.text.secondary:x.palette.text.primary,transition:`color ${nt}, background-color ${nt}`,...g?{"&:hover":{bgcolor:x.palette.action.hover}}:{}}),w=m.jsxs(m.Fragment,{children:[m.jsx(B,{component:"span","aria-hidden":!0,sx:{width:16,height:16,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:s==="saved"?m.jsx(Ts,{sx:{fontSize:16}}):m.jsx(B,{component:"span","data-restored":c?"true":void 0,sx:x=>({width:7,height:7,borderRadius:"50%",bgcolor:c?t.accent:s==="saving"||o!==void 0?x.palette.text.disabled:x.palette.warning.main,transition:`background-color ${nt}`})})}),m.jsx(B,{component:"span","aria-hidden":!0,children:l}),m.jsx(wa,{"aria-hidden":!0,sx:{fontSize:16,ml:-.25,visibility:g?"visible":"hidden"}})]}),h=m.jsx(B,{component:"span",role:"status","aria-live":"polite",sx:_m,children:u?`${l}. ${u}.`:l});return m.jsxs(m.Fragment,{children:[h,m.jsx(Ot,{title:u??p,describeChild:!0,children:g?m.jsx(cd,{className:rt.saveStatus,"aria-label":l,...u?{"aria-description":u}:{},"aria-haspopup":"menu","aria-expanded":r!==null,onClick:x=>i(x.currentTarget),sx:b,children:w}):m.jsx(B,{component:"span",className:rt.saveStatus,sx:b,children:w})}),m.jsxs(Xn,{className:rt.menu,anchorEl:r,open:r!==null,onClose:v,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:-4,horizontal:"left"},slotProps:{paper:{sx:{minWidth:240,borderRadius:n.radius.menu,border:`1px solid ${cn(t.cardBorder)}`,boxShadow:n.shadow.menu}}},MenuListProps:{dense:!0,sx:{py:.5}},children:[(u!==void 0||o!==void 0)&&m.jsx(B,{component:"li",role:"presentation",sx:{px:1.75,pt:.75,pb:1,...n.type.caption,color:"text.secondary"},children:u??`Kept in this browser at ${So(o)}`}),m.jsxs(Xe,{onClick:()=>{i(null),a?.()},sx:{mx:.5,borderRadius:n.radius.control,gap:1.25,color:"error.main","&.Mui-focusVisible":{outline:"none",bgcolor:"action.hover"}},children:[m.jsx(Bm,{fontSize:"small"}),"Discard edits"]})]})]})}function So(e){const t=new Date(e);return new Date().toDateString()===t.toDateString()?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const _m={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},$o=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),Sn=$o?"⌘":"Ctrl+",ql=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},Ks=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function qm(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e});const[n,r]=S.useState(!1);S.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),S.useEffect(()=>{const i=s=>{const o=t.current;if(o.paused)return;const a=$o?s.metaKey:s.ctrlKey,d=s.key.toLowerCase();if(s.key==="Escape"){if(ql(s.target)||Ks(s.target))return;o.escape();return}if(ql(s.target)){if(a&&d==="s"){if(s.preventDefault(),!o.save||Ks(s.target))return;s.target.blur(),r(!0)}return}if(Ks(s.target)){a&&d==="s"&&s.preventDefault();return}if(a&&d==="z"){s.preventDefault(),s.shiftKey?o.redo():o.undo();return}if(!$o&&a&&d==="y"){s.preventDefault(),o.redo();return}if(a&&d==="s"){s.preventDefault(),o.save?.();return}if(o.move&&s.altKey&&!a&&!s.shiftKey){const f=s.key==="ArrowLeft"?[0,-1]:s.key==="ArrowRight"?[0,1]:s.key==="ArrowUp"?[-1,0]:s.key==="ArrowDown"?[1,0]:void 0;if(f&&o.move(f[0],f[1])){s.preventDefault();return}}o.nudge&&!a&&!s.altKey&&!s.shiftKey&&(s.key==="ArrowLeft"||s.key==="ArrowRight")&&(s.preventDefault(),o.nudge(s.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[])}const Yr=(e,t,n=$a)=>({height:n.size.control,minHeight:n.size.control,px:1.5,borderRadius:n.radius.control,boxShadow:"none",...n.type.control,"&:hover":{boxShadow:"none"},"& .MuiButton-startIcon":{mr:.5,"& svg":{fontSize:18}},"&.MuiButton-outlined":{borderColor:e,"&:hover":{borderColor:t}}}),oi=(e=$a)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),os={height:20,alignSelf:"center",mx:.5,my:0},as=(e,t=$a)=>({height:t.size.control,boxSizing:"border-box",borderRadius:t.radius.control,border:`1px solid ${e}`,overflow:"hidden",bgcolor:"background.paper","& .MuiToggleButton-root":{border:"none",borderRadius:"0 !important",m:"0 !important",px:1.5,py:0,height:"100%",...t.type.control,color:"text.secondary","& + .MuiToggleButton-root":{borderLeft:`1px solid ${e}`},"&:hover":{bgcolor:"action.hover"},"&.Mui-selected, &.Mui-selected:hover":{bgcolor:"action.selected",color:"text.primary"}}}),jo={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function Hm({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,savesTo:a="package",saveLabel:d,saveButton:f,actions:c,onAddTile:l,arrange:u,onExit:p,saveStatus:g}){const{theme:v}=_e(),b=cn(v.cardBorder),w=Cs(v.cardBorder,v.tileTitle);return m.jsxs(ft,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[u,l&&m.jsx(De,{variant:"outlined",startIcon:m.jsx(vi,{}),onClick:l,"aria-label":"Add tile",sx:Yr(b,w,v.ui),children:"Tile"}),l&&m.jsx(nr,{orientation:"vertical",sx:os}),m.jsx(Ot,{title:`Undo (${Sn}Z)`,children:m.jsx("span",{children:m.jsx($n,{"aria-label":"Undo",disabled:!e,onClick:n,sx:oi(v.ui),children:m.jsx(Dd,{fontSize:"small"})})})}),m.jsx(Ot,{title:`Redo (${Sn}⇧Z)`,children:m.jsx("span",{children:m.jsx($n,{"aria-label":"Redo",disabled:!t,onClick:r,sx:oi(v.ui),children:m.jsx(Od,{fontSize:"small"})})})}),(c||o||p)&&m.jsx(nr,{orientation:"vertical",sx:os}),c,o&&g&&m.jsx(Ad,{...g}),o?m.jsx(Ot,{title:i?`Save (${Sn}S) · ${d??jo[a]}`:d??jo[a],children:m.jsx("span",{children:m.jsx(De,{ref:f,variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{...Yr(b,w,v.ui),minWidth:88},children:s?"Saving…":i?"Save":"Saved"})})}):null,o&&m.jsx(B,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:s?"Saving":i?"Unsaved changes":"All changes saved"}),p&&m.jsx(um,{label:"Close",icon:m.jsx(Ts,{}),onClick:p})]})}const Um=e=>`This view has no field for the x-axis: ${e.toLowerCase()} needs a group by, such as a date or a category`,Hl={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map",combo_chart:"Bar and line"};function Pd(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this tile's details":n==="unlisted"?"Not in the model's list, so its shape is unknown":void 0,i=e?.shape,s=o=>{if(t===o)return;if(o==="big_value")return e?.aggregateOnly===!0?void 0:i&&i.groupBys>0?"This view has a group by, so it is more than one row; big numbers need a view of totals only":r??"Needs results that are only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a map chart set in the model";if(e?.chart===o)return;if(!i)return o==="combo_chart"?r??"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line":void 0;const a=`A ${Hl[o].toLowerCase()} chart`;switch(Am(o,i)){case"no_x_axis":return Um(a);case"combo_totals":return`A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has ${i.totals}`;case"no_y_axis":return`This view has no total for the y-axis: ${a.toLowerCase()} needs at least one aggregate`;default:return}};return[{value:"default",label:"Default",hint:"As set in the model"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map","combo_chart"].map(o=>{const a=s(o);return{value:o,label:Hl[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Ul(e){return e.description??Om(e.name)}const Vm={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",combo_chart:"a bar and line chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},Ci=(e,t)=>`${e}\0${t}`;function Km({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o,renderPreview:a}){const{theme:d}=_e(),f=d.ui,c=cn(d.cardBorder),l=S.useMemo(()=>n?.sources??[],[n]),[u,p]=S.useState(""),[g,v]=S.useState(),[b,w]=S.useState(""),[h,x]=S.useState("default"),y=S.useRef(null),k=S.useMemo(()=>{const P=new Set(t.sources.map(F=>F.base));return[...l].sort((F,E)=>Number(P.has(E.name))-Number(P.has(F.name)))},[l,t]),C=k.filter(P=>P.views.length>0),$=k.filter(P=>P.views.length===0),T=S.useMemo(()=>new Map(C.flatMap(P=>P.views.map(F=>[Ci(P.name,F.name),{source:P,view:F,key:Ci(P.name,F.name)}]))),[C]),j=S.useMemo(()=>C.map(P=>({key:P.name,label:P.name,...P.description?{detail:P.description}:{},entries:P.views.map(F=>({key:Ci(P.name,F.name),name:F.name,title:Ul(F),...F.chart?{chart:F.chart}:{}}))})),[C]),M=g===void 0?void 0:T.get(g);S.useEffect(()=>{if(!e)return;p(""),w(""),x("default");const P=C[0]?.views[0];v(P&&C[0]?Ci(C[0].name,P.name):void 0)},[e]);const I=M?[M.source.name,M.view.name].filter(P=>!wo(P)).map(P=>`"${P}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,W=M!==void 0&&I===void 0,A=M?Ul(M.view):"",z=h!=="default"&&M?{chart:h,chartCarried:M.view.chart?[M.view.chart]:[]}:{},_=(P=M)=>{if(!P||![P.source.name,P.view.name].every(wo))return;const F=P.key===M?.key,E=Pm(Math.ceil(r/2),r);s({base:P.source.name,modelPath:P.source.modelPath,...P.source.exporters?{exporters:P.source.exporters}:{},view:P.view.name,...F&&b.trim()?{label:b.trim()}:{},...F?z:{},...E!==void 0?{colspan:E}:{}})},q=M?Pd(M.view,h).filter(P=>P.value!=="custom"&&P.disabled!==!0):[];return m.jsx(Ea,{className:`${rt.dialog} ${rt.addTileDialog}`,open:e,onClose:i,maxWidth:"md",initialFocus:y,title:"Add a tile",description:"Pick what the tile shows from the model. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx(De,{onClick:o,sx:{mr:"auto"},children:"Add text instead"}),m.jsx(De,{onClick:i,children:"Cancel"}),m.jsx(De,{variant:"contained",disabled:!W,onClick:()=>_(),children:"Add tile"})]}),children:m.jsxs(B,{sx:{mx:-3,mb:-1,borderTop:`1px solid ${c}`,borderBottom:`1px solid ${c}`,display:"grid",gridTemplateColumns:{xs:"1fr",md:"320px minmax(0, 1fr)"},height:{md:460}},children:[m.jsx(B,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(am,{groups:j,query:u,onQuery:p,picked:M?.key,onPick:P=>{v(P),x("default")},onTake:P=>_(T.get(P)),searchRef:y,empty:m.jsx(pe,{variant:"body2",sx:{color:d.tileTitle,p:2},children:n?"This package's models have nothing to put on a tile yet.":"The package's sources are still loading."}),footer:$.length>0&&m.jsxs(pe,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",$.map(P=>P.name).join(", "),"."]})})}),m.jsx(B,{sx:P=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${P.palette.text.primary} 3%, ${P.palette.background.paper})`}),children:M?m.jsxs(m.Fragment,{children:[m.jsx(B,{"aria-label":"Preview",role:"region",sx:P=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:f.radius.tile,border:`1px solid ${c}`,bgcolor:P.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${P.palette.background.paper})`}}),children:a?m.jsx(B,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:M.source.name,modelPath:M.source.modelPath,view:M.view.name,label:b.trim()||A,...h!=="default"?z:{},givens:M.source.givens})}):m.jsxs(B,{sx:P=>({flex:1,border:`1px solid ${c}`,borderRadius:f.radius.tile,bgcolor:P.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(lm,{chart:M.view.chart}),m.jsxs(pe,{variant:"body2",children:[M.source.name," → ",M.view.name]})]})}),m.jsx(Zt,{size:"small",label:"Title",placeholder:A,value:b,onChange:P=>w(P.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs(B,{children:[m.jsx(pe,{component:"div",sx:{...f.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx($d,{size:"small",exclusive:!0,value:h,"aria-label":"Chart",onChange:(P,F)=>{F!==null&&x(F)},sx:{...as(c,f),"& .MuiToggleButton-root":{...as(c,f)["& .MuiToggleButton-root"],textTransform:"none"}},children:q.map(P=>m.jsx(ko,{value:P.value,children:P.label},P.value))}),m.jsx(pe,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:M.view.chart?`The model sets ${Vm[M.view.chart]??"a chart"}.`:"The model sets no chart, so it shows as a table."})]}),I&&m.jsx(pe,{variant:"body2",color:"error",children:I})]}):m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}function Gm(e,t,{modelPath:n,textHeld:r,widths:i,insertAt:s}){t.modelPath&&!r&&(e.imports=Em(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const o=Rd(e,t.base),a=Mo(e,o.name,t.view);e.tiles.splice(s??e.tiles.length,0,{name:a,source:o.name,declaration:{kind:"reference",from:t.view},...i&&t.colspan!==void 0?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function Rd(e,t,{unscoped:n=!1}={}){const r=e.sources.find(a=>a.base===t&&(!n||!a.scopedBy?.length));if(r)return r;const i=new Set(e.sources.map(a=>a.name));let s=`${t}_tiles`;for(let a=2;i.has(s);a++)s=`${t}_tiles_${a}`;const o={name:s,base:t};return e.sources.push(o),o}function Mo(e,t,n){const r=new Set(e.tiles.filter(oe).filter(s=>s.source===t).map(s=>s.name));let i=`${n}_tile`;for(let s=2;r.has(i);s++)i=`${n}_tile_${s}`;return i}function ls(e){switch(e.declaration.kind){case"inline":return"Its query is written in this file, and the builder does not copy a query's body.";case"opaque":return`Its query is ${e.declaration.why}, which the builder does not copy.`;case"query":return"It names a query, and a copy could not be told apart from it: the builder writes nothing about such a tile but its place.";default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function Ym(e,t){const n=e.tiles[t];if(!n||!oe(n)||ls(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:s,...o}=structuredClone(n);r={...o,name:Mo(e,n.source,n.declaration.from)}}else{const s=e.sources.find(o=>o.name===n.source)??Rd(e,n.source,{unscoped:!0});r={name:Mo(e,s.name,n.name),source:s.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}const i=n.row!==void 0&&n.col!==void 0;return i&&(r={...r,row:(n.row??1)+ii(n),col:n.col,...n.rowspan!==void 0?{rowspan:n.rowspan}:{}}),e.tiles.splice(t+1,0,r),i&&(e.tiles=Ht(e.tiles,e.columns??Xp,t+1)),t+1}const Ti="self";function Xm({open:e,document:t,source:n,givenNames:r,dashboards:i,tileLabel:s,onClose:o,onApply:a}){const{theme:d}=_e(),f=d.ui,[c,l]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(x=>x.source===n.name);l((n.dimensions??[]).map(x=>{const y=h.find(k=>k.name===x.name);return{name:x.name,expression:x.expression,to:y?.to??[],given:y?.given??""}}))},[e,n,t]);const u=(h,x)=>l(y=>y.map((k,C)=>{if(C!==h)return k;const $={...k};return x($),$})),p=[Ti,...i.filter(h=>h!==Ti)],g=h=>h===Ti?"This report":h,v=()=>{n&&(a(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}:{}}))),o())},b=cn(d.cardBorder),w=(h,x)=>u(h,y=>{x?y.to=y.lastTo?.length?y.lastTo:[Ti]:(y.lastTo=y.to,y.to=[])});return m.jsx(Ea,{className:`${rt.dialog} ${rt.clickableCellsDialog}`,open:e,onClose:o,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[s&&m.jsxs(B,{component:"span",sx:{fontWeight:f.type.label.fontWeight},children:[s," ·"," "]}),"A click on a table cell sets a filter to its value, on this report or on the one it opens. Bars, lines and points on a chart do not respond to a click. Clicks work in the report, not while you edit it."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx(De,{onClick:o,children:"Cancel"}),m.jsx(De,{variant:"contained",onClick:v,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx(pe,{variant:"body2",sx:{color:d.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx(B,{component:"code",children:n.name})," declares no dimensions of its own in this file. A click is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",m.jsx(B,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx(B,{role:"list","aria-label":"Dimensions",children:c.map((h,x)=>{const y=h.to.length>0;return m.jsxs(B,{role:"listitem",sx:{display:"grid",gridTemplateColumns:{xs:"auto minmax(0, 1fr)",sm:"auto minmax(0, 0.9fr) minmax(0, 1.6fr)"},alignItems:"center",columnGap:1.5,rowGap:1,py:1.25,borderTop:x===0?"none":`1px solid ${b}`},children:[m.jsx(om,{size:"small",checked:y,onChange:k=>w(x,k.target.checked),slotProps:{input:{"aria-label":`${h.name} is clickable`}}}),m.jsxs(B,{sx:{minWidth:0},children:[m.jsx(B,{sx:{...f.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Qm(h.name)}),m.jsxs(B,{title:h.expression,sx:{...f.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[h.name," is ",h.expression]})]}),y?m.jsxs(ft,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...f.type.control},children:[m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx(Zt,{select:!0,size:"small",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:k=>k.map(g).join(", ")},onChange:k=>u(x,C=>{const $=k.target.value,T=Array.isArray($)?$:String($).split(",").filter(Boolean);T.length===0&&(C.lastTo=C.to),C.to=T}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:p.map(k=>m.jsxs(Xe,{value:k,children:[m.jsx(yo,{size:"small",checked:h.to.includes(k),sx:{p:0,mr:1}}),m.jsx(Bt,{primary:g(k)})]},k))}),m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs(Zt,{select:!0,size:"small",value:h.given,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0,renderValue:k=>k===""?h.name:String(k)},onChange:k=>u(x,C=>{C.given=k.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx(Xe,{value:"",children:m.jsx(Bt,{primary:h.name,secondary:"Named like the dimension"})}),r.map(k=>m.jsx(Xe,{value:k,children:k},k))]})]}):m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},h.name)})})})}function Qm(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const Zm=mt(m.jsx("path",{d:"M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 13-4-4h8z"})),Jm=mt(m.jsx("path",{d:"M11 7H2v2h9zm0 8H2v2h9zm5.34-4L12.8 7.46l1.41-1.41 2.12 2.12 4.24-4.24L22 5.34zm0 8-3.54-3.54 1.41-1.41 2.12 2.12 4.24-4.24L22 13.34z"})),eg=mt(m.jsx("path",{d:"M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V10h14zm0-12H5V6h14zm-7 5h5v5h-5z"})),tg=mt(m.jsx("path",{d:"M19.5 9.5c-1.03 0-1.9.62-2.29 1.5h-2.92c-.39-.88-1.26-1.5-2.29-1.5s-1.9.62-2.29 1.5H6.79c-.39-.88-1.26-1.5-2.29-1.5C3.12 9.5 2 10.62 2 12s1.12 2.5 2.5 2.5c1.03 0 1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5s1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5 1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5"})),ng=mt(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),rg=mt(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function ig(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of oe(s)?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 cs(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function sg(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Xr(e,t){const n=sg(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 Eo(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 og(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const ag=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function lg(e,t){const n=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",r=/^[A-Z_]/.test(n)?n:`F_${n}`,i=Sd(r)?r:`${r}_FILTER`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const cg=[{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:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Or(e){const t=e.label.trim()||e.name,n=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 Co=e=>oe(e)&&!cr(e)&&e.declaration.kind!=="opaque";function dg(e,t){return e.tiles.map(n=>{const r=(oe(n)?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}:cs(t.type)!==void 0?{op:cs(t.type)}:{}}})}function ug(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Co(s))return;const o=(s.filters??[]).filter(d=>d.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 hg(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 fg(e,t){for(const r of e.tiles){if(!oe(r))continue;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 To=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function pg({open:e,document:t,control:n,available:r,takenNames:i=[],fieldsFor:s,onApply:o}){const a=S.useRef(n);e&&(a.current=n);const d=e?n:a.current,f=d!==void 0,[c,l]=S.useState({kind:"new"}),[u,p]=S.useState(""),[g,v]=S.useState("select"),[b,w]=S.useState(""),[h,x]=S.useState(""),[y,k]=S.useState([]),[C,$]=S.useState(!1),[T,j]=S.useState(!1),M=D=>t.sources.find(L=>L.name===D.source)?.base??D.source;S.useEffect(()=>{if(e)if(j(n!==void 0),n){l({kind:"existing",name:n.name}),p(n.label??"");const D=dg(t,n);k(D);const L=D.filter(V=>V.include),U=new Set(L.map(V=>V.field));x(U.size===1?L[0].field:n.field??""),$(U.size>1)}else l({kind:"new"}),p(""),v("select"),x(""),w(new Date().toISOString().slice(0,10)),k(t.tiles.map(D=>({include:Co(D),field:""}))),$(!1)},[e,n,t]);const I=S.useMemo(()=>[...(t.localGivens??[]).map(D=>D.name),...r.map(D=>D.name),...i],[t,r,i]),W=S.useMemo(()=>h.trim()?lg(h.trim(),I):"",[h,I]),A=c.kind==="existing"?n??r.find(D=>D.name===c.name):W?{name:W,type:Or({name:W,label:u,kind:g,field:h}).type}:void 0,z=A?.type!==void 0&&!A.type.startsWith("filter<"),_=y.find(D=>D.include)?.op??cs(A?.type),q=(D,L)=>{j(!0),k(U=>U.map((V,we)=>we===D?{...V,...L}:V))},P=D=>{j(!0),k(L=>L.map(U=>({...U,op:D})))},F=D=>{const L=cs(D);k(U=>U.map(({op:V,...we})=>L?{...we,op:L}:we))},E=D=>{j(!0),l({kind:"existing",name:D.name}),x(D.field??""),F(D.type)},O=D=>{j(!0),v(D),F(Or({name:"X",label:u,kind:D,field:h}).type)},N=t.tiles.map(Co),H=N.filter(Boolean).length,K=y.filter((D,L)=>D.include&&N[L]).length,Y=t.tiles.filter((D,L)=>(y[L]?.include??!1)&&N[L]&&oe(D)),te=Y.length>0?Y:t.tiles.filter((D,L)=>N[L]&&oe(D)),xe=S.useMemo(()=>{const D=new Map;let L=!1;for(const U of te){const V=s?.(U);if(V){L=!0;for(const we of V)D.has(we.name)||D.set(we.name,we)}}return L?[...D.values()]:void 0},[y,t.tiles,s]),me=(()=>{const D=h.trim();for(const L of Y){const U=s?.(L);if(!U||U.some(V=>V.name===D))return M(L)}return Y[0]?M(Y[0]):t.sources[0]?.base})(),ne=D=>{j(!0),k(L=>L.map((U,V)=>({...U,include:D&&N[V]})))},Ee=S.useMemo(()=>C?y:y.map(D=>({...D,field:h})),[C,y,h]),J=D=>{for(const L of te){const U=s?.(L)?.find(V=>V.name===D.trim());if(U?.type)return U.type}},Ve=D=>Xr(A?.type,D.type),Ae=(D,L)=>{if(D.trim()==="")return"Pick the field this filter compares.";const U=L?s?.(L):void 0;if(!U)return;const V=U.find(we=>we.name===D.trim());if(!V)return`Not a field of ${L?M(L):"the tiles' source"}.`;if(V.type&&!Xr(A?.type,V.type))return`${D.trim()} is ${Eo(V.type)}; this filter compares ${Eo(A?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},G=D=>{if(j(!0),x(D),f||c.kind!=="new")return;const L=J(D),U=Or({name:"X",label:u,kind:g,field:D}).type;L&&!Xr(U,L)&&O(og(L))},ye=D=>{const L=t.tiles[D];return L&&oe(L)?L:void 0},be=Ee.map((D,L)=>D.include&&N[L]?Ae(D.field,ye(L)):void 0),re=be.every(D=>D===void 0),Pe=T?be:be.map(()=>{}),Ke=T&&!C&&K>0?Y.map(D=>Ae(h,D)).find(Boolean):void 0,Re=A!==void 0&&re&&(c.kind==="existing"||h.trim()!==""&&W!==""),Qe=()=>{if(!(!A||!Re))if(c.kind==="new")o(A.name,Ee,Or({name:A.name,label:u.trim()||To(A.name),kind:g,field:h.trim(),...me?{source:me}:{},...b?{dateDefault:b}:{}}));else if(n?.origin==="dashboard"&&n.local){const D=u.trim(),L=D!==(n.local.label??"");o(A.name,Ee,L?{...n.local,...D?{label:D}:{}}:void 0)}else o(A.name,Ee)},Ze=f&&d.origin==="model";return{editing:f,shown:d,fromModel:Ze,source:c,setSource:l,label:u,setLabel:p,kind:g,dateDefault:b,setDateDefault:w,field:h,rows:y,setRows:k,perTile:C,setPerTile:$,newName:W,target:A,valueTyped:z,commonOp:_,setRow:q,setCommonOp:P,pickExisting:E,pickKind:O,bindable:N,bindableCount:H,included:K,commonFields:xe,setAll:ne,accepts:Ve,pickField:G,rowProblems:Pe,commonProblem:Ke,canApply:Re,apply:Qe}}function Vl({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:d,autoFocus:f,placeholder:c,inputRef:l,sx:u}){const p=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),g=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return m.jsx(Tm,{freeSolo:!0,size:"small",options:p,inputValue:e,onInputChange:(v,b)=>t(b),value:e,onChange:(v,b)=>t(typeof b=="string"?b:""),disabled:d,disableClearable:!0,renderOption:(v,b)=>S.createElement("li",{...v,key:b},m.jsx(Gl,{type:g.get(b)}),m.jsx(pe,{variant:"body2",sx:{flex:1,ml:1},children:b})),renderInput:v=>m.jsx(Zt,{...v,label:i,placeholder:c,autoFocus:f,...l?{inputRef:l}:{},error:o,helperText:a,InputLabelProps:{...v.InputLabelProps,shrink:!0},InputProps:{...v.InputProps,startAdornment:g.get(e.trim())?m.jsx(B,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(Gl,{type:g.get(e.trim())})}):void 0},inputProps:{...v.inputProps,"aria-label":s}}),sx:u})}const mg=e=>e&&oe(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:e&&oe(e)&&e.declaration.kind==="query"?{label:"Not bindable",reason:"It names a query, whose filters live in that query's own definition."}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function gg({open:e,document:t,control:n,available:r,takenNames:i,fieldsFor:s,onClose:o,onApply:a,onRemove:d}){const{theme:f}=_e(),c=f.ui,{editing:l,shown:u,fromModel:p,source:g,setSource:v,label:b,setLabel:w,kind:h,dateDefault:x,setDateDefault:y,field:k,rows:C,setRows:$,perTile:T,setPerTile:j,newName:M,target:I,valueTyped:W,commonOp:A,setRow:z,setCommonOp:_,pickExisting:q,pickKind:P,bindable:F,bindableCount:E,included:O,commonFields:N,setAll:H,accepts:K,pickField:Y,rowProblems:te,commonProblem:xe,canApply:me,apply:ne}=pg({open:e,document:t,control:n,available:r,...i?{takenNames:i}:{},fieldsFor:s,onApply:a}),Ee=S.useRef(null),J=cn(f.cardBorder),Ve=Cs(f.cardBorder,f.tileTitle),[Ae,G]=S.useState(!1),[ye,be]=S.useState(!1);S.useEffect(()=>{e?be(!0):G(!1)},[e]),S.useEffect(()=>{ye&&(be(!1),G(l&&O<E))},[ye]),S.useEffect(()=>{T&&G(!0)},[T]);const re=N?.find(D=>D.name===k.trim())?.type,Pe=D=>{if(!re)return;const L=Or({name:"X",label:b,kind:D,field:k}).type;return Xr(L,re)?void 0:`${k.trim()} is ${Eo(re)}, which this control cannot filter.`},Ke=b.trim()||(M?To(M):"Filter"),Re=h==="number"?"Any":h==="date"?x?new Date(`${x}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",Qe={...as(J,c),alignSelf:"flex-start","& .MuiToggleButton-root":{...as(J,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ze=(D,L,U)=>m.jsx(Zt,{select:!0,size:"small",label:"Compares",value:D??">=",onChange:V=>L(V.target.value),inputProps:{"aria-label":U},sx:{width:130},children:ag.filter(V=>V.op!=="~").map(V=>m.jsx(Xe,{value:V.op,children:V.label},V.op))});return m.jsx(Ea,{className:`${rt.dialog} ${rt.filterDialog}`,open:e,onClose:o,...l?{}:{initialFocus:Ee},title:l?u.label??u.name:"Add a filter",description:l?m.jsxs(m.Fragment,{children:[m.jsxs(B,{component:"span",sx:{fontFamily:c.font.mono},children:["$",u.name]}),p?" · declared in the model, so its label and options are set there":" · declared in this report"]}):"A filter on the page, and the tiles it filters.",actions:m.jsxs(m.Fragment,{children:[l&&m.jsx(De,{color:"error",startIcon:m.jsx(rm,{}),onClick:()=>d(u.name),sx:D=>({mr:"auto",color:nm(D)}),children:"Remove filter"}),m.jsx(De,{onClick:o,children:"Cancel"}),m.jsx(Ot,{title:me||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx(De,{variant:"contained",onClick:ne,disabled:!me,children:l?"Apply":"Add filter"})})})]}),children:m.jsxs(ft,{sx:{gap:2.5,pt:1},children:[!l&&r.length>0&&m.jsxs($d,{exclusive:!0,size:"small",value:g.kind,onChange:(D,L)=>{L==="new"?v({kind:"new"}):L==="existing"&&r[0]&&q(r[0])},"aria-label":"Where the filter comes from",sx:Qe,children:[m.jsx(ko,{value:"new",children:"New in this report"}),m.jsx(ko,{value:"existing",children:"From the model"})]}),!l&&g.kind==="existing"?m.jsx(Zt,{select:!0,size:"small",label:"Filter",value:g.name,onChange:D=>{const L=r.find(U=>U.name===D.target.value);L&&q(L)},children:r.map(D=>m.jsxs(Xe,{value:D.name,children:[D.label??D.name,m.jsxs(pe,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",D.name]})]},D.name))}):null,m.jsxs(B,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:p?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!T&&m.jsx(Vl,{value:k,onChange:Y,fields:N,accepts:K,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:Ee,error:xe!==void 0,helperText:xe??(!l&&M?`Declared as $${M}`:void 0)}),!p&&m.jsx(Zt,{size:"small",label:"Label",placeholder:M?To(M):"",value:b,onChange:D=>w(D.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),W&&!T&&Ze(A,_,"Comparison"),!l&&g.kind==="new"&&m.jsxs(B,{children:[m.jsx(Kl,{children:"Control"}),m.jsx(B,{role:"radiogroup","aria-label":"Filter kind",sx:{display:"grid",gridTemplateColumns:{xs:"repeat(3, minmax(0, 1fr))",sm:"repeat(5, minmax(0, 1fr))"},gap:1},children:cg.map(D=>{const L=D.kind===h,U=Pe(D.kind);return m.jsx(Ot,{title:U??D.hint,describeChild:!0,children:m.jsxs(cd,{role:"radio","aria-checked":L,"aria-label":D.label,"aria-disabled":U!==void 0,onClick:()=>{U===void 0&&P(D.kind)},sx:V=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${L?f.accent:J}`,boxShadow:L?`0 0 0 1px ${f.accent}`:"none",bgcolor:L?`color-mix(in srgb, ${f.accent} 6%, ${V.palette.background.paper})`:V.palette.background.paper,color:L?f.accent:V.palette.text.secondary,opacity:U?.45:1,cursor:U?"default":"pointer",transition:`border-color ${nt}, background-color ${nt}`,"&:hover":U||L?{}:{borderColor:Ve}}),children:[m.jsx(xg,{kind:D.kind}),m.jsx(B,{component:"span",sx:{...c.type.caption,fontWeight:L?600:500,color:L?f.accent:"text.primary",textAlign:"center"},children:vg[D.kind]})]})},D.kind)})}),h==="date"&&m.jsx(Zt,{size:"small",type:"date",label:"Starts at",value:x,onChange:D=>y(D.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs(B,{sx:{border:`1px solid ${J}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs(ft,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(rg,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs(pe,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx(B,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:O===E&&E>0?`Applies to all ${O} tile${O===1?"":"s"}`:`Applies to ${O} of ${E} tile${E===1?"":"s"}`}),!T&&k.trim()!==""&&O>0&&m.jsxs(B,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx(B,{component:"span",sx:{...c.type.code},children:k.trim()})]})]}),!T&&m.jsx(De,{size:"small","aria-expanded":Ae,onClick:()=>G(D=>!D),children:Ae?"Done choosing":"Choose tiles"})]}),m.jsx(tm,{in:Ae,unmountOnExit:!0,children:m.jsxs(B,{sx:{borderTop:`1px solid ${J}`,px:.5,pb:1},children:[m.jsxs(ft,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx(yo,{size:"small",checked:E>0&&O===E,indeterminate:O>0&&O<E,disabled:E===0,onChange:D=>H(D.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx(pe,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx(De,{size:"small",onClick:()=>{T||$(D=>D.map(L=>({...L,field:k}))),j(D=>!D)},children:T?"Same field for all":"Adjust per tile"})]}),m.jsx(ft,{sx:{gap:T?1:0},children:t.tiles.map((D,L)=>{if(!oe(D))return null;const U=C[L],V=D.label??D.name,we=T?te[L]:void 0;return m.jsxs(ft,{direction:"row",sx:{gap:1,alignItems:T?"flex-start":"center",opacity:F[L]?1:.6},children:[m.jsx(yo,{size:"small",disabled:!F[L],checked:(U?.include??!1)&&F[L],inputProps:{"aria-label":`Filter ${V}`},onChange:je=>z(L,{include:je.target.checked})}),m.jsx(pe,{variant:"body2",sx:{flex:1,minWidth:0,pt:T?1:0},noWrap:!0,children:V}),F[L]?T&&m.jsxs(m.Fragment,{children:[W&&Ze(U?.op,je=>z(L,{op:je}),`Comparison for ${V}`),m.jsx(Vl,{value:U?.field??"",onChange:je=>z(L,{field:je}),fields:s?.(D),accepts:K,label:"Field",ariaLabel:`Field for ${V}`,disabled:!U?.include,error:we!==void 0,helperText:we,sx:{width:220,pr:1}})]}):m.jsx(pe,{variant:"caption",sx:{color:f.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:mg(t.tiles[L]).reason})]},ue(D))})})]})})]}),O===0&&m.jsx(pe,{variant:"caption",sx:{color:"warning.main",display:"block",mt:-1.5},children:"No tile is ticked, so this control will not appear on the report."}),!p&&m.jsxs(B,{children:[m.jsx(Kl,{children:"Preview"}),m.jsx(B,{sx:D=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:D.palette.action.hover}),children:m.jsxs(B,{"aria-hidden":!0,sx:D=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${J}`,bgcolor:D.palette.background.paper,...c.type.control}),children:[m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:Ke}),m.jsx(B,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:Re}),m.jsx(wa,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function Kl({children:e}){const t=_e().theme.ui;return m.jsx(pe,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const vg={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function xg({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(Zm,{sx:t});case"multiselect":return m.jsx(Jm,{sx:t});case"text":return m.jsx(ng,{sx:t});case"number":return m.jsx(tg,{sx:t});case"date":return m.jsx(eg,{sx:t})}}function Gl({type:e}){const t=e?.replace(/_type$/,""),n=t==="string"?"Abc":t==="number"?"#":t==="date"||t==="timestamp"?"Date":t==="boolean"?"T/F":void 0,r=_e().theme.ui;return n?m.jsx(B,{component:"span","aria-hidden":!0,sx:i=>({fontFamily:r.font.mono,fontSize:10,fontWeight:r.type.label.fontWeight,color:i.palette.text.secondary,bgcolor:i.palette.action.hover,borderRadius:"4px",px:.5,py:.25,minWidth:22,textAlign:"center",flex:"none"}),children:n}):null}const Yl=mt(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function Id(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const d=structuredClone(a);return o(d),d}),apply:o=>{if(i===void 0)return;const a=structuredClone(i);o(a),s(a),JSON.stringify(a)!==JSON.stringify(e)&&n(a)},close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const bg=e=>e&&e.length===1?`This tile's chart line (${e[0]}) is not one the builder models, so its chart cannot be changed here.`:`This tile has ${e?.length??"several"} chart lines${e?` (${e.join(" and ")})`:""}, so its chart cannot be changed here.`,yg=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),wg="Its chart's bars, lines and points do not respond to a click; show it as a table to click its cells.",kg="Declared on its source, so its chart is set in the model.",Sg="It names a query, so its chart is set where that query is declared.";function $g({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:i,onDuplicate:s,duplicateBlocked:o,view:a,viewStatus:d}){const{theme:f}=_e(),c=f.ui,{draft:l,apply:u,patch:p,close:g}=Id(t,e!==null,r,n),[v,b]=S.useState(void 0),w=l!==void 0&&oe(l)?l:void 0,h=w!==void 0&&!cr(w),x=E=>u(O=>{oe(O)&&E(O)}),y=S.useRef(void 0),k=S.useRef(null),C=e!==null;S.useEffect(()=>{C?y.current=t&&oe(t)?t.chart:void 0:b(void 0)},[C]);const $=w?.chart??"default",T=Pd(a,$,d),j=w?w.declaration.kind==="query"?Sg:h?w.chart==="custom"?bg(w.chartLines):void 0:kg:void 0,M=E=>x(O=>{const N=y.current;E===(N??"default")?(N===void 0?delete O.chart:O.chart=N,delete O.chartCarried):(O.chart=E,a?O.chartCarried=a.chart?[a.chart]:[]:delete O.chartCarried)}),I=h?i?void 0:"Its source declares no dimension a click could filter by.":void 0,W=$==="default"?a?.chart:$,A=W!==void 0&&yg.has(W)?wg:void 0,z=E=>O=>b({kind:E,anchor:O.currentTarget}),_=j??(W===void 0||!jg.has(W)?"Only a bar, line, scatter or bar and line chart has a color to set.":void 0),q=Array.from(new Set(f.series.map(xd).filter(E=>E!==void 0))).slice(0,8),P=E=>x(O=>{E===void 0?delete O.color:O.color=E.toLowerCase()}),F=(E,O,N)=>m.jsxs(m.Fragment,{children:[m.jsx(Bt,{primary:E,...N?{secondary:N}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),O&&m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",ml:2},children:O})]});return m.jsxs(m.Fragment,{children:[m.jsxs(Xn,{className:rt.menu,open:e!==null&&l!==void 0,anchorEl:e,onClose:g,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":w?vt(w):"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:c.radius.menu,border:`1px solid ${cn(f.cardBorder)}`,boxShadow:c.shadow.menu}}},children:[w&&m.jsxs(Xe,{"aria-haspopup":"menu","aria-expanded":v?.kind==="chart",disabled:j!==void 0,onClick:z("chart"),onKeyDown:E=>{E.key==="ArrowRight"&&j===void 0&&b({kind:"chart",anchor:E.currentTarget})},children:[F("Chart",j?void 0:T.find(E=>E.value===$)?.label,j),m.jsx(Yl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),w&&j===void 0&&m.jsxs(Xe,{"aria-haspopup":"menu","aria-expanded":v?.kind==="color",disabled:_!==void 0,onClick:z("color"),onKeyDown:E=>{E.key==="ArrowRight"&&_===void 0&&b({kind:"color",anchor:E.currentTarget})},children:[F("Color",_?void 0:w.color??"Theme",_),!_&&m.jsx(Gs,{color:w.color??f.series[0],trailing:!0}),m.jsx(Yl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),h&&m.jsx(Xe,{"aria-haspopup":"dialog",disabled:I!==void 0,onClick:()=>{g(),i?.()},children:F("Clickable cells…",void 0,I??A)}),w&&s&&m.jsx(Xe,{disabled:o!==void 0,onClick:()=>{g(),s()},children:F("Duplicate",void 0,o)}),w?.declaration.kind==="opaque"&&m.jsxs(pe,{variant:"body2",sx:{color:f.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",w.declaration.why,", so a filter has no single place to go."]}),w&&m.jsx(nr,{}),w&&m.jsx(B,{"aria-hidden":!0,sx:{px:2,py:.5,...c.type.code,color:"text.secondary"},children:vt(w).replace("->","→")})]}),m.jsx(Xn,{className:rt.menu,open:v?.kind==="chart",anchorEl:v?.anchor??null,onClose:()=>b(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:E=>{E.key==="ArrowLeft"&&(E.preventDefault(),b(void 0))}},children:T.filter(E=>E.value!=="custom").map(E=>m.jsxs(Xe,{role:"menuitemradio","aria-checked":E.value===$,disabled:E.disabled===!0,onClick:()=>{M(E.value),b(void 0)},children:[m.jsx(Bt,{primary:E.label,...E.reason??E.hint?{secondary:E.reason??E.hint}:{}}),E.value===$&&m.jsx(bd,{sx:{minWidth:0,ml:2},children:m.jsx(Ts,{fontSize:"small",sx:{color:f.accent}})})]},E.value))}),m.jsxs(Xn,{className:rt.menu,open:v?.kind==="color",anchorEl:v?.anchor??null,onClose:()=>b(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,"aria-label":"Color",onKeyDown:E=>{E.key==="ArrowLeft"&&(E.preventDefault(),b(void 0))}},children:[m.jsxs(Xe,{role:"menuitemradio","aria-checked":w?.color===void 0,onClick:()=>{P(void 0),b(void 0)},children:[m.jsx(Gs,{color:f.series[0]}),m.jsx(Bt,{primary:"Theme",secondary:"The page's own colors"}),w?.color===void 0&&m.jsx(Xl,{color:f.accent})]}),q.map(E=>m.jsxs(Xe,{role:"menuitemradio","aria-checked":w?.color===E.toLowerCase(),onClick:()=>{P(E),b(void 0)},children:[m.jsx(Gs,{color:E}),m.jsx(Bt,{primary:E.toLowerCase()}),w?.color===E.toLowerCase()&&m.jsx(Xl,{color:f.accent})]},E)),m.jsx(nr,{}),m.jsxs(Xe,{component:"label","aria-checked":w?.color!==void 0&&!q.some(E=>E.toLowerCase()===w.color),role:"menuitemradio",onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),k.current?.click())},children:[m.jsx("input",{ref:k,type:"color","aria-label":"Other color",value:w?.color??Mg(f.series[0]),onChange:E=>{const O=E.target.value;im(O)&&p(N=>{oe(N)&&(N.color=O.toLowerCase())})},style:{width:18,height:18,padding:0,border:"none",background:"none",marginRight:12}}),m.jsx(Bt,{primary:"Other color…"})]})]})]})}const jg=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Mg=e=>(e&&xd(e))??"#000000";function Gs({color:e,trailing:t=!1}){return m.jsx(B,{"aria-hidden":!0,"data-swatch":t?"trailing":"leading",sx:{width:14,height:14,borderRadius:"3px",bgcolor:e,border:"1px solid rgba(0,0,0,0.15)",...t?{ml:1}:{mr:1.5},flex:"none"}})}function Xl({color:e}){return m.jsx(bd,{sx:{minWidth:0,ml:2},children:m.jsx(Ts,{fontSize:"small",sx:{color:e}})})}const Ds=e=>e.label??sm(vt(e));function Eg({editor:e,catalog:t,columns:n,dashboards:r,bindings:i,tiles:s,drillSource:o,setDrillSource:a,exitDialog:d,renderViewPreview:f,takenGivenNames:c}){const{filterDialog:l,setFilterDialog:u}=i,{menu:p,setMenu:g}=s,[v,b]=S.useState(),w=p===void 0?void 0:e.document.tiles[p.index],h=w&&oe(w)?w:void 0,x=(()=>{if(!h||!t)return;const y=t.documentViews?.get(h.source??"")?.get(h.name);if(y&&e.document.sources.some($=>$.name===h.source))return y;if(h.declaration.kind==="inline"||h.declaration.kind==="opaque")return;const k=e.document.sources.find($=>$.name===h.source)?.base??h.source,C=h.declaration.kind==="reference"?h.declaration.from:h.name;return t.sources.find($=>$.name===k)?.views.find($=>$.name===C)})();return m.jsxs(m.Fragment,{children:[m.jsx(gg,{open:l!==void 0,document:e.document,...l?.control?{control:l.control}:{},available:i.available,...c?{takenNames:c}:{},...t?{fieldsFor:i.fieldsFor}:{},onClose:()=>u(void 0),onApply:i.applyFilter,onRemove:i.dropControl}),m.jsx($g,{anchor:p?.anchor??null,tile:p===void 0?void 0:e.document.tiles[p.index],onClose:()=>g(void 0),onCommit:y=>{const k=p?.index;if(k===void 0)return;const C=Fm(y);e.update($=>{$.tiles[k]=C,C!==y&&rn($.tiles)&&($.tiles=Ht($.tiles,n,k))})},view:x,...x===void 0&&h?{viewStatus:t?"unlisted":"loading"}:{},onDuplicate:()=>{p&&s.duplicate(p.index)},...h&&ls(h)!==void 0?{duplicateBlocked:ls(h)}:{},...(e.document.sources.find(y=>y.name===h?.source)?.dimensions?.length??0)>0?{onDrills:()=>{b(h?Ds(h):void 0),a(h?.source)}}:{}}),m.jsx(Xm,{open:o!==void 0,document:e.document,source:e.document.sources.find(y=>y.name===o),givenNames:i.controlList.map(y=>y.name),dashboards:r??[],...v?{tileLabel:v}:{},onClose:()=>a(void 0),onApply:y=>e.update(k=>{const C=[...(k.drills??[]).filter($=>$.source!==o),...y];C.length===0?delete k.drills:k.drills=C})}),m.jsx(gp,{...d}),m.jsx(Km,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText,...f?{renderPreview:f}:{}})]})}var Cg=Symbol.for("preact-signals");function As(){if(_t>1)_t--;else{var e,t=!1;for((function(){var i=us;for(us=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}})();Zr!==void 0;){var n=Zr;for(Zr=void 0,ds++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Wd(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(ds=0,_t--,t)throw e}}function Oe(e){if(_t>0)return e();Oo=++Tg,_t++;try{return e()}finally{As()}}var Qr,ke=void 0;function ie(e){var t=ke,n=Qr;ke=void 0,Qr=void 0;try{return e()}finally{ke=t,Qr=n}}var Zr=void 0,_t=0,ds=0,Tg=0,Oo=0,us=void 0,hs=0;function Nd(e){if(ke!==void 0){var t=e.n;if(t===void 0||t.t!==ke)return t={i:0,S:e,p:ke.s,n:void 0,t:ke,e:void 0,x:void 0,r:t},ke.s!==void 0&&(ke.s.n=t),ke.s=t,e.n=t,32&ke.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=ke.s,t.n=void 0,ke.s.n=t,ke.s=t),t}}function dt(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}dt.prototype.brand=Cg;dt.prototype.h=function(){return!0};dt.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:ie(function(){var r;(r=t.W)==null||r.call(t)}))};dt.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&&ie(function(){var i;(i=t.Z)==null||i.call(t)}))}};dt.prototype.subscribe=function(e){var t=this;return $t(function(){var n=t.value;ie(function(){return e(n)})},{name:"sub"})};dt.prototype.valueOf=function(){return this.value};dt.prototype.toString=function(){return this.value+""};dt.prototype.toJSON=function(){return this.value};dt.prototype.peek=function(){var e=this;return ie(function(){return e.value})};Object.defineProperty(dt.prototype,"value",{get:function(){var e=Nd(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ds>100)throw new Error("Cycle detected");(function(n){_t!==0&&ds===0&&n.l!==Oo&&(n.l=Oo,us={S:n,v:n.v,i:n.i,o:us})})(this),this.v=e,this.i++,hs++,_t++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{As()}}}});function dr(e,t){return new dt(e,t)}function Wd(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 Ld(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 zd(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 En(e,t){dt.call(this,void 0,t),this.x=e,this.s=void 0,this.g=hs-1,this.f=4}En.prototype=new dt;En.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===hs))return!0;if(this.g=hs,this.f|=1,this.i>0&&!Wd(this))return this.f&=-2,!0;var e=ke;try{Ld(this),ke=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 ke=e,zd(this),this.f&=-2,!0};En.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)}dt.prototype.S.call(this,e)};En.prototype.U=function(e){if(this.t!==void 0&&(dt.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)}};En.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(En.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Nd(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Ql(e,t){return new En(e,t)}function Fd(e){var t=e.m;if(e.m=void 0,typeof t=="function"){_t++;var n=ke;ke=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Oa(e),r}finally{ke=n,As()}}}function Oa(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Fd(e)}function Og(e){if(ke!==this)throw new Error("Out-of-order effect");zd(this),ke=e,this.f&=-2,8&this.f&&Oa(this),As()}function ur(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Qr&&Qr.push(this)}ur.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()}};ur.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Fd(this),Ld(this),_t++;var e=ke;return ke=this,Og.bind(this,e)};ur.prototype.N=function(){2&this.f||(this.f|=2,this.u=Zr,Zr=this)};ur.prototype.d=function(){this.f|=8,1&this.f||Oa(this)};ur.prototype.dispose=function(){this.d()};function $t(e,t){var n=new ur(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Dg=Object.create,Da=Object.defineProperty,Ag=Object.defineProperties,Pg=Object.getOwnPropertyDescriptor,Rg=Object.getOwnPropertyDescriptors,Zl=Object.getOwnPropertySymbols,Ig=Object.prototype.hasOwnProperty,Ng=Object.prototype.propertyIsEnumerable,Wg=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),hr=e=>{throw TypeError(e)},Do=(e,t,n)=>t in e?Da(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Lg=(e,t)=>{for(var n in t||(t={}))Ig.call(t,n)&&Do(e,n,t[n]);if(Zl)for(var n of Zl(t))Ng.call(t,n)&&Do(e,n,t[n]);return e},zg=(e,t)=>Ag(e,Rg(t)),Jl=(e,t)=>Da(e,"name",{value:t,configurable:!0}),Fg=e=>{var t;return[,,,Dg((t=void 0)!=null?t:null)]},Bd=["class","method","getter","setter","accessor","field","value","get","set"],Dr=e=>e!==void 0&&typeof e!="function"?hr("Function expected"):e,Bg=(e,t,n,r,i)=>({kind:Bd[e],name:t,metadata:r,addInitializer:s=>n._?hr("Already initialized"):i.push(Dr(s||null))}),_d=(e,t)=>Do(t,Wg("metadata"),e[3]),un=(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},fr=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=Bd[l+5],b=l>3&&(e[g-1]=[]),w=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&Pg(l<4?i:{get[n](){return yt(this,s)},set[n](y){return Xt(this,s,y)}},n));l?p&&l<4&&Jl(s,(l>2?"set ":l>1?"get ":"")+n):Jl(i,n);for(var x=r.length-1;x>=0;x--)f=Bg(l,n,d={},e[3],w),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>_g(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?yt:qg)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,k)=>Xt(y,i,k,l^4?s:h.set):(y,k)=>y[n]=k)),a=(0,r[x])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?Dr(a)&&(l>4?b.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?hr("Object expected"):(Dr(o=a.get)&&(h.get=o),Dr(o=a.set)&&(h.set=o),Dr(o=a.init)&&b.unshift(o));return l||_d(e,i),h&&Da(i,n,h),p?l^4?s:h:i},Aa=(e,t,n)=>t.has(e)||hr("Cannot "+n),_g=(e,t)=>Object(t)!==t?hr('Cannot use the "in" operator on this value'):e.has(t),yt=(e,t,n)=>(Aa(e,t,"read from private field"),n?n.call(e):t.get(e)),Ar=(e,t,n)=>t.has(e)?hr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xt=(e,t,n,r)=>(Aa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),qg=(e,t,n)=>(Aa(e,t,"access private method"),n);function Ao(e,t){if(t){let n;return Ql(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Ql(e)}function Ct(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((n,r)=>!Ct(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!Ct(e[i],t[i]))}return!1}function se({get:e},t){return{init(n){return dr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function We(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Ao(e.bind(this)),n.set(this,r)),r.value}}function Ys(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,zg(Lg({},i),{enumerable:e}))})}}function xi(...e){const t=e.map(n=>$t(n));return()=>t.forEach(n=>n())}var qd,Hd,Ud,Vd,Kd,Gd,ot,Pa,Xs,Po,Ro,tt,Ra,Qs,Yd,Io,Ia,Zs,No,Wo;Gd=[se],Kd=[se],Vd=[se],Ud=[Ys()],Hd=[Ys()],qd=[Ys()];var Cn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,un(ot,5,this),Ar(this,tt),Ar(this,Pa,un(ot,8,this)),un(ot,11,this),Ar(this,Ra,un(ot,12,this)),un(ot,15,this),Ar(this,Ia,un(ot,16,this)),un(ot,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return yt(this,tt,No)}get initial(){return yt(this,tt,Po)}get previous(){return yt(this,tt,Yd)}set current(e){const t=ie(()=>yt(this,tt,No));e&&t&&this.equals(t,e)||Oe(()=>{yt(this,tt,Po)||Xt(this,tt,e,Ro),Xt(this,tt,t,Io),Xt(this,tt,e,Wo)})}reset(e=this.defaultValue){Oe(()=>{Xt(this,tt,void 0,Io),Xt(this,tt,e,Ro),Xt(this,tt,e,Wo)})}};ot=Fg();Pa=new WeakMap;tt=new WeakSet;Ra=new WeakMap;Ia=new WeakMap;Xs=fr(ot,20,"#initial",Gd,tt,Pa),Po=Xs.get,Ro=Xs.set;Qs=fr(ot,20,"#previous",Kd,tt,Ra),Yd=Qs.get,Io=Qs.set;Zs=fr(ot,20,"#current",Vd,tt,Ia),No=Zs.get,Wo=Zs.set;fr(ot,2,"current",Ud,Cn);fr(ot,2,"initial",Hd,Cn);fr(ot,2,"previous",qd,Cn);_d(ot,Cn);function Js(e){return ie(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var hn,Hg=class{constructor(){Ar(this,hn,new WeakMap)}get(e,t){var n;return e?(n=yt(this,hn).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return yt(this,hn).has(e)||yt(this,hn).set(e,new Map),(r=yt(this,hn).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=yt(this,hn).get(e))==null?void 0:t.clear():void 0}};hn=new WeakMap;var Ug=Object.create,Xd=Object.defineProperty,Vg=Object.getOwnPropertyDescriptor,ec=Object.getOwnPropertySymbols,Kg=Object.prototype.hasOwnProperty,Gg=Object.prototype.propertyIsEnumerable,Qd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ps=e=>{throw TypeError(e)},tc=Math.pow,Lo=(e,t,n)=>t in e?Xd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yg=(e,t)=>{for(var n in t||(t={}))Kg.call(t,n)&&Lo(e,n,t[n]);if(ec)for(var n of ec(t))Gg.call(t,n)&&Lo(e,n,t[n]);return e},Xg=e=>{var t;return[,,,Ug((t=e?.[Qd("metadata")])!=null?t:null)]},Zd=["class","method","getter","setter","accessor","field","value","get","set"],Jd=e=>e!==void 0&&typeof e!="function"?Ps("Function expected"):e,Qg=(e,t,n,r,i)=>({kind:Zd[e],name:t,metadata:r,addInitializer:s=>n._?Ps("Already initialized"):i.push(Jd(s||null))}),Zg=(e,t)=>Lo(t,Qd("metadata"),e[3]),Jg=(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},eu=(e,t,n,r,i,s)=>{for(var o,a,d,f,c=t&7,l=!1,u=!1,p=2,g=Zd[c+5],v=e[p]||(e[p]=[]),b=(i=i.prototype,Vg(i,n)),w=r.length-1;w>=0;w--)d=Qg(c,n,a={},e[3],v),d.static=l,d.private=u,f=d.access={has:h=>n in h},f.get=h=>h[n],o=(0,r[w])(b[g],d),a._=1,Jd(o)&&(b[g]=o);return b&&Xd(i,n,b),i},tu=(e,t,n)=>t.has(e)||Ps("Cannot "+n),ev=(e,t,n)=>(tu(e,t,"read from private field"),t.get(e)),tv=(e,t,n)=>t.has(e)?Ps("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),nv=(e,t,n,r)=>(tu(e,t,"write to private field"),t.set(e,n),n),wt=class zo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new zo(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 zo(t,n)}},Nt=class fn{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,d=new fn(i+t,r+n,s,o);return d.scale=Yg({},a),d}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 wt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof fn))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 fn?rv(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 fn(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],d=o==="x"?s.left:s.top,f=o==="x"?s.width:s.height;return a=="start"?d:a=="end"?d+f:d+f/2};return wt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return fn.from(t).intersectionRatio(fn.from(n))}};function rv(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 nu,ru,Fo,_i,bi,Rs=class extends(Fo=Cn,ru=[We],nu=[We],Fo){constructor(e){const t=wt.from(e);super(t,(n,r)=>wt.equals(n,r)),Jg(bi,5,this),tv(this,_i,0),this.velocity={x:0,y:0}}get delta(){return wt.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=wt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-ev(this,_i),o=a=>Math.round(a/s*100);Oe(()=>{nv(this,_i,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(wt.from(e)),this.velocity={x:0,y:0}}};bi=Xg(Fo);_i=new WeakMap;eu(bi,2,"delta",ru,Rs);eu(bi,2,"direction",nu,Rs);Zg(bi,Rs);function Bo({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(tc(r,2)+tc(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 iu=(e=>(e.Horizontal="x",e.Vertical="y",e))(iu||{}),su=Object.values(iu),iv=Object.create,Na=Object.defineProperty,sv=Object.defineProperties,ov=Object.getOwnPropertyDescriptor,av=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertySymbols,ou=Object.prototype.hasOwnProperty,au=Object.prototype.propertyIsEnumerable,lu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),pr=e=>{throw TypeError(e)},_o=(e,t,n)=>t in e?Na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wa=(e,t)=>{for(var n in t||(t={}))ou.call(t,n)&&_o(e,n,t[n]);if(fs)for(var n of fs(t))au.call(t,n)&&_o(e,n,t[n]);return e},La=(e,t)=>sv(e,av(t)),nc=(e,t)=>Na(e,"name",{value:t,configurable:!0}),cu=(e,t)=>{var n={};for(var r in e)ou.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fs)for(var r of fs(e))t.indexOf(r)<0&&au.call(e,r)&&(n[r]=e[r]);return n},mr=e=>{var t;return[,,,iv((t=e?.[lu("metadata")])!=null?t:null)]},du=["class","method","getter","setter","accessor","field","value","get","set"],Pr=e=>e!==void 0&&typeof e!="function"?pr("Function expected"):e,lv=(e,t,n,r,i)=>({kind:du[e],name:t,metadata:r,addInitializer:s=>n._?pr("Already initialized"):i.push(Pr(s||null))}),Tn=(e,t)=>_o(t,lu("metadata"),e[3]),Z=(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},ae=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=du[l+5],b=l>3&&(e[g-1]=[]),w=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&ov(l<4?i:{get[n](){return Ne(this,s)},set[n](y){return xt(this,s,y)}},n));l?p&&l<4&&nc(s,(l>2?"set ":l>1?"get ":"")+n):nc(i,n);for(var x=r.length-1;x>=0;x--)f=lv(l,n,d={},e[3],w),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>cv(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?Ne:uu)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,k)=>xt(y,i,k,l^4?s:h.set):(y,k)=>y[n]=k)),a=(0,r[x])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?Pr(a)&&(l>4?b.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?pr("Object expected"):(Pr(o=a.get)&&(h.get=o),Pr(o=a.set)&&(h.set=o),Pr(o=a.init)&&b.unshift(o));return l||Tn(e,i),h&&Na(i,n,h),p?l^4?s:h:i},za=(e,t,n)=>t.has(e)||pr("Cannot "+n),cv=(e,t)=>Object(t)!==t?pr('Cannot use the "in" operator on this value'):e.has(t),Ne=(e,t,n)=>(za(e,t,"read from private field"),n?n.call(e):t.get(e)),fe=(e,t,n)=>t.has(e)?pr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xt=(e,t,n,r)=>(za(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),uu=(e,t,n)=>(za(e,t,"access private method"),n);function hu(e,t){return{plugin:e,options:t}}function yi(e){return t=>hu(e,t)}function ai(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var fu,li,Fa,qi;fu=[se];var it=class{constructor(e,t){this.manager=e,this.options=t,fe(this,Fa,Z(li,8,this,!1)),Z(li,11,this),fe(this,qi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return ie(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=$t(e.bind(this));return Ne(this,qi).add(t),t}destroy(){Ne(this,qi).forEach(e=>e())}static configure(e){return hu(this,e)}};li=mr(null);Fa=new WeakMap;qi=new WeakMap;ae(li,4,"disabled",fu,it,Fa);Tn(li,it);var wi=class extends it{},Hi,eo=class{constructor(e){this.manager=e,this.instances=new Map,fe(this,Hi,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ai).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 Ne(this,Hi))if(!n.includes(r)){if(r.prototype instanceof wi)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);xt(this,Hi,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()}};Hi=new WeakMap;function dv(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Oi=[],Fn,Bn,uv=class extends it{constructor(e){super(e),fe(this,Fn),fe(this,Bn),this.computeCollisions=this.computeCollisions.bind(this),xt(this,Bn,dr(Oi)),this.destroy=xi(()=>{const t=this.computeCollisions(),n=ie(()=>this.manager.dragOperation.position.current);if(t!==Oi){const r=Ne(this,Fn);if(xt(this,Fn,n),r&&n.x==r.x&&n.y==r.y)return}else xt(this,Fn,void 0);Ne(this,Bn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){ie(()=>{e?Ne(this,Bn).value=this.computeCollisions():xt(this,Fn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Oi;const a=[],d=[];for(const f of e??n.droppables){if(f.disabled||i&&!f.accepts(i))continue;const c=t??f.collisionDetector;if(!c)continue;d.push(f),f.shape;const l=ie(()=>c({droppable:f,dragOperation:r}));l&&(f.collisionPriority!=null&&(l.priority=f.collisionPriority),a.push(l))}return d.length===0?Oi:(a.sort(dv),a)}get collisions(){return Ne(this,Bn).value}};Fn=new WeakMap;Bn=new WeakMap;var pu,mu,gu,Ba,vu,Tt,_a,Gn,qa,Ha;gu=[se],mu=[se],pu=[se];var Ut=class pn{constructor(t,n){fe(this,_a,Z(Tt,8,this)),Z(Tt,11,this),fe(this,Gn),fe(this,qa,Z(Tt,12,this)),Z(Tt,15,this),fe(this,Ha,Z(Tt,16,this)),Z(Tt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let d=i;xt(this,Gn,dr(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var f;return[()=>{const{id:c,manager:l}=this;if(c!==d)return d=c,l?.registry.register(this),()=>l?.registry.unregister(this)},...(f=r?.())!=null?f:[]]},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=Ne(this,Gn).value;return(n=(t=pn.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=pn.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Ne(this,Gn).peek();t!==i&&(pn.pendingIdChanges||(pn.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return uu(s=pn,Ba,vu).call(s)})),pn.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)}};Tt=mr(null);Ba=new WeakSet;vu=function(){const e=Ut.pendingIdChanges;Ut.pendingIdChanges=null,e&&Oe(()=>{for(const[t,n]of e)Ne(t,Gn).value=n})};_a=new WeakMap;Gn=new WeakMap;qa=new WeakMap;Ha=new WeakMap;ae(Tt,4,"manager",gu,Ut,_a);ae(Tt,4,"data",mu,Ut,qa);ae(Tt,4,"disabled",pu,Ut,Ha);fe(Ut,Ba);Tn(Tt,Ut);Ut.pendingIdChanges=null;var Is=Ut,rc=class{constructor(){this.map=dr(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,d]of n)if(d===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=xi(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},xu,bu,yu,wu,ku,Su,qo,at,Ua,Va,Ka,Wt=class extends(qo=Is,Su=[se],ku=[se],wu=[se],yu=[We],bu=[We],xu=[We],qo){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,d=cu(n,["modifiers","type","sensors","plugins","effects"]);super(La(Wa({},d),{effects:()=>{var f;return[...(f=a?.())!=null?f:[],()=>{const{manager:c,plugins:l}=this;if(!(!c||!l))for(const u of l){const{plugin:p}=ai(u);c.registry.plugins.register(p)}}]}}),t),Z(at,5,this),fe(this,Ua,Z(at,8,this)),Z(at,11,this),fe(this,Va,Z(at,12,this)),Z(at,15,this),fe(this,Ka,Z(at,16,this,this.isDragSource?"dragging":"idle")),Z(at,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=d.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=ai(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.source)==null?void 0:t.id)===this.id}};at=mr(qo);Ua=new WeakMap;Va=new WeakMap;Ka=new WeakMap;ae(at,4,"type",Su,Wt,Ua);ae(at,4,"modifiers",ku,Wt,Va);ae(at,4,"status",wu,Wt,Ka);ae(at,2,"isDropping",yu,Wt);ae(at,2,"isDragging",bu,Wt);ae(at,2,"isDragSource",xu,Wt);Tn(at,Wt);var $u,ju,Mu,Eu,Cu,Tu,Ho,He,Ga,Ya,Xa,Qa,Za,Lt=class extends(Ho=Is,Tu=[se],Cu=[se],Eu=[se],Mu=[se],ju=[se],$u=[We],Ho){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=cu(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),Z(He,5,this),fe(this,Ga,Z(He,8,this)),Z(He,11,this),fe(this,Ya,Z(He,12,this)),Z(He,15,this),fe(this,Xa,Z(He,16,this)),Z(He,19,this),fe(this,Qa,Z(He,20,this)),Z(He,23,this),fe(this,Za,Z(He,24,this)),Z(He,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=s,this.type=o}accepts(e){const{accept:t}=this;return t?typeof t=="function"?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.target)==null?void 0:t.id)===this.id}};He=mr(Ho);Ga=new WeakMap;Ya=new WeakMap;Xa=new WeakMap;Qa=new WeakMap;Za=new WeakMap;ae(He,4,"accept",Tu,Lt,Ga);ae(He,4,"type",Cu,Lt,Ya);ae(He,4,"collisionDetector",Eu,Lt,Xa);ae(He,4,"collisionPriority",Mu,Lt,Qa);ae(He,4,"shape",ju,Lt,Za);ae(He,2,"isDropTarget",$u,Lt);Tn(He,Lt);var hv=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)}},fv=class extends hv{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Ui(e,t=!0){let n=!1;return La(Wa({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var pv=class extends wi{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=xi(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Is.pendingIdChanges)return;const o=Ui({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;ie(()=>{var d;a?.id!==((d=e.dragOperation.target)==null?void 0:d.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},gr=(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))(gr||{}),vr=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(vr||{}),Ou,Du,Au,Pu,Ru,Iu,Nu,St,Ja;Nu=[se],Iu=[We],Ru=[We],Pu=[We],Au=[We],Du=[We],Ou=[We];var Kt=class{constructor(){Z(St,5,this),fe(this,Ja,Z(St,8,this,"idle")),Z(St,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}};St=mr(null);Ja=new WeakMap;ae(St,4,"value",Nu,Kt,Ja);ae(St,2,"current",Iu,Kt);ae(St,2,"idle",Ru,Kt);ae(St,2,"initializing",Pu,Kt);ae(St,2,"initialized",Au,Kt);ae(St,2,"dragging",Du,Kt);ae(St,2,"dropped",Ou,Kt);Tn(St,Kt);var mv=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 ie(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Ui({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return ie(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const n=new AbortController,{event:r,coordinates:i}=e;Oe(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=Ui({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",s),s.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set("initializing"),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;const{status:o}=t;o.current==="initializing"&&Oe(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return ie(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Ui({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,d,f,c,l;if(o.defaultPrevented)return;const u=(l=e.to)!=null?l:{x:r.position.current.x+((d=(a=e.by)==null?void 0:a.x)!=null?d:0),y:r.position.current.y+((c=(f=e.by)==null?void 0:f.y)!=null?c:0)};r.position.current=u})})}stop(e={}){return ie(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const d={resume:()=>{},abort:()=>{}};return s=new Promise((f,c)=>{d.resume=f,d.abort=c}),d};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const d=ie(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),f=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(d){const{source:c}=r,l=$t(()=>{c?.status==="idle"&&(l(),f())})}else this.manager.renderer.rendering.then(f)})};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()})}},rr=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}},gv=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)}},Vi,Wu=class{constructor(e){this.options=e,fe(this,Vi)}set controller(e){xt(this,Vi,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ne(this,Vi))==null||t.activate(e)}};Vi=new WeakMap;var ic=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},vv=class{constructor(e){this.draggables=new rc,this.droppables=new rc,this.plugins=new eo(e),this.sensors=new eo(e),this.modifiers=new eo(e)}register(e,t){if(e instanceof Wt)return this.draggables.register(e.id,e);if(e instanceof Lt)return this.droppables.register(e.id,e);if(e.prototype instanceof ic)return this.modifiers.register(e,t);if(e.prototype instanceof rr)return this.sensors.register(e,t);if(e.prototype instanceof it)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Is)return e instanceof Wt?this.draggables.unregister(e.id,e):e instanceof Lt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ic)return this.modifiers.unregister(e);if(e.prototype instanceof rr)return this.sensors.unregister(e);if(e.prototype instanceof it)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()}},Lu,zu,Fu,Bu,_u,qu,Hu,Uu,Vu,Rr,Ki,_n,Te,el,tl,nl,rl,il,Ir;Vu=[We],Uu=[se],Hu=[se],qu=[se],_u=[se],Bu=[se],Fu=[We],zu=[We],Lu=[We];var Pt=class{constructor(e){Z(Te,5,this),fe(this,Rr),fe(this,Ki),fe(this,_n,new Cn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Kt,fe(this,el,Z(Te,8,this,!1)),Z(Te,11,this),fe(this,tl,Z(Te,12,this,null)),Z(Te,15,this),fe(this,nl,Z(Te,16,this,null)),Z(Te,19,this),fe(this,rl,Z(Te,20,this,null)),Z(Te,23,this),fe(this,il,Z(Te,24,this,[])),Z(Te,27,this),this.position=new Rs({x:0,y:0}),fe(this,Ir,{x:0,y:0}),xt(this,Rr,e)}get shape(){const{current:e,initial:t,previous:n}=Ne(this,_n);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ne(this,_n).current=e:Ne(this,_n).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ne(this,Rr).registry.draggables.get(t);return n&&xt(this,Ki,n),(e=n??Ne(this,Ki))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ne(this,Rr).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(La(Wa({},this.snapshot()),{transform:n}));return xt(this,Ir,n),n}snapshot(){return ie(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ne(this,Ir),shape:this.shape?Js(this.shape):null,position:Js(this.position),status:Js(this.status),canceled:this.canceled}))}reset(){Oe(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ne(this,_n).reset(),this.position.reset({x:0,y:0}),xt(this,Ir,{x:0,y:0}),this.modifiers=[]})}};Te=mr(null);Rr=new WeakMap;Ki=new WeakMap;_n=new WeakMap;el=new WeakMap;tl=new WeakMap;nl=new WeakMap;rl=new WeakMap;il=new WeakMap;Ir=new WeakMap;ae(Te,2,"shape",Vu,Pt);ae(Te,4,"canceled",Uu,Pt,el);ae(Te,4,"activatorEvent",Hu,Pt,tl);ae(Te,4,"sourceIdentifier",qu,Pt,nl);ae(Te,4,"targetIdentifier",_u,Pt,rl);ae(Te,4,"modifiers",Bu,Pt,il);ae(Te,2,"source",Fu,Pt);ae(Te,2,"target",zu,Pt);ae(Te,2,"transform",Lu,Pt);Tn(Te,Pt);var xv={get rendering(){return Promise.resolve()}};function At(e,t){return typeof e=="function"?e(t):e??t}var bv=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(l=>l.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=At(n.plugins,[]),i=At(n.sensors,[]),s=At(n.modifiers,[]),o=(t=n.renderer)!=null?t:xv,a=new fv(this),d=new vv(this);this.registry=d,this.monitor=a,this.renderer=o,this.actions=new mv(this),this.dragOperation=new Pt(this),this.collisionObserver=new uv(this),this.plugins=[pv,...r],this.modifiers=s,this.sensors=i;const{destroy:f}=this,c=xi(()=>{var l,u,p;const g=ie(()=>this.dragOperation.modifiers),v=this.modifiers;for(const b of g)v.includes(b)||b.destroy();this.dragOperation.modifiers=(p=(u=(l=this.dragOperation.source)==null?void 0:l.modifiers)==null?void 0:u.map(b=>{const{plugin:w,options:h}=ai(b);return new w(this,h)}))!=null?p:v});this.destroy=()=>{c(),f()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Ku=e=>{throw TypeError(e)},sl=(e,t,n)=>t.has(e)||Ku("Cannot "+n),Q=(e,t,n)=>(sl(e,t,"read from private field"),t.get(e)),ut=(e,t,n)=>t.has(e)?Ku("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),gt=(e,t,n,r)=>(sl(e,t,"write to private field"),t.set(e,n),n),Gu=(e,t,n)=>(sl(e,t,"access private method"),n);function Ns(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Yu(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(Ns(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function Ws(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 ol(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ki(e){return"nodeType"in e}function bt(e){var t,n,r;return e?ol(e)?e:ki(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 al(e){const{Document:t}=bt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function on(e){return!e||ol(e)?!1:e instanceof bt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Xu(e){return e instanceof bt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function xr(e){return e?ol(e)?e.document:ki(e)?al(e)?e:on(e)||Xu(e)?e.ownerDocument:document:document:document}function yv(e){var t,n,r,i;const{documentElement:s}=xr(e),o=bt(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,d=(n=o?.height)!=null?n:s.clientHeight,f=(r=o?.offsetTop)!=null?r:0,c=(i=o?.offsetLeft)!=null?i:0;return{top:f,left:c,right:c+a,bottom:f+d,width:a,height:d}}function wv(e,t){if(kv(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function kv(e){return e.tagName==="DETAILS"}function ci(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let d=t;const{ownerDocument:f}=e,c=(r=f.defaultView)!=null?r:window;let l=e.parentElement;for(;l&&l!==f.documentElement;){if(!wv(l)){const x=l.getBoundingClientRect(),y=n*(x.bottom-x.top),k=n*(x.right-x.left),C=n*(x.bottom-x.top),$=n*(x.right-x.left);d={top:Math.max(d.top,x.top-y),right:Math.min(d.right,x.right+k),bottom:Math.min(d.bottom,x.bottom+C),left:Math.max(d.left,x.left-$),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top}l=l.parentElement}const u=c.visualViewport,p=(i=u?.offsetTop)!=null?i:0,g=(s=u?.offsetLeft)!=null?s:0,v=(o=u?.width)!=null?o:c.innerWidth,b=(a=u?.height)!=null?a:c.innerHeight,w=n*b,h=n*v;return d={top:Math.max(d.top,p-w),right:Math.min(d.right,g+v+h),bottom:Math.min(d.bottom,p+b+w),left:Math.max(d.left,g-h),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top,d.width<0&&(d.width=0),d.height<0&&(d.height=0),d}function ir(e){return{x:e.clientX,y:e.clientY}}var Qu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Uo(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(...Uo(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(...Uo(i.document,t))}}catch{}return n}function ll(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Zu(){var e,t;const n=ll()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function cl(e){return!e||!ki(e)?!1:e instanceof bt(e).ShadowRoot}function ps(e){if(e&&ki(e)){let t=e.getRootNode();if(cl(t)||t instanceof Document)return t}return xr(e)}function dl(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Sv(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,s)=>{const o=r[s];sc(i)&&sc(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),oc(i)&&oc(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function sc(e){return"value"in e}function oc(e){return e.tagName==="CANVAS"}function Ju(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if($v(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Ju(i,{x:t-s,y:n-o})}}return r}function $v(e){return e?.tagName==="IFRAME"}var Vo=new WeakMap;function jv(e){return e.closest(`
2
2
  input:not([disabled]),
3
3
  select:not([disabled]),
4
4
  textarea:not([disabled]),
@@ -0,0 +1 @@
1
+ import{E as u,r as c}from"./index-CCLHq9po.js";import{w as e}from"./usePackageRoute-DEUbQLf3.js";function p(t,a,r){const s=u();return c.useCallback((o,i)=>s(e(o,t,a,r),i),[s,t,a,r])}export{p as u};
@@ -1 +1 @@
1
- import{C as f,a9 as p}from"./index-BSyL0zds.js";const $=/^(latest|[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?)$/,m="latest",l=e=>$.test(e),g=e=>{const n=e.indexOf("/"),o=n===-1?e:e.slice(0,n);if(l(o))return{segment:o,rest:n===-1?"":e.slice(n+1)}},h=e=>e===void 0||e===m?void 0:e,I=(e,n,o)=>`/${encodeURIComponent(e)}/${encodeURIComponent(n)}${o===void 0?"":`/${encodeURIComponent(o)}`}`,E=(e,n,o,t)=>{if(t===void 0)return e;const i=[`/${encodeURIComponent(n)}/${encodeURIComponent(o)}`,`/${n}/${o}`];for(const s of i){if(e!==s&&!e.startsWith(`${s}/`))continue;const r=e.slice(s.length).replace(/^\//,"");return`${I(n,o,t)}${r===""?"":`/${r}`}`}return e};function R(e={}){const n=f(),o=n.environmentName,t=n.packageName,i=n["*"],s=i===void 0?void 0:g(i),{versions:r,isPending:d,isError:v,refetch:u}=p(o??"",t??"",{enabled:e.always===!0||s!==void 0}),a=r.length>0,c=s&&a?s:void 0;return{environmentName:o,packageName:t,versionSegment:c?.segment,versionId:h(c?.segment),path:c?c.rest:i,versioned:a,deciding:s!==void 0&&d,undecided:s!==void 0&&v,retry:u,writable:!a&&!d&&!v}}export{m as L,I as p,R as u,h as v,E as w};
1
+ import{C as f,a9 as p}from"./index-CCLHq9po.js";const $=/^(latest|[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?)$/,m="latest",l=e=>$.test(e),g=e=>{const n=e.indexOf("/"),o=n===-1?e:e.slice(0,n);if(l(o))return{segment:o,rest:n===-1?"":e.slice(n+1)}},h=e=>e===void 0||e===m?void 0:e,I=(e,n,o)=>`/${encodeURIComponent(e)}/${encodeURIComponent(n)}${o===void 0?"":`/${encodeURIComponent(o)}`}`,E=(e,n,o,t)=>{if(t===void 0)return e;const i=[`/${encodeURIComponent(n)}/${encodeURIComponent(o)}`,`/${n}/${o}`];for(const s of i){if(e!==s&&!e.startsWith(`${s}/`))continue;const r=e.slice(s.length).replace(/^\//,"");return`${I(n,o,t)}${r===""?"":`/${r}`}`}return e};function R(e={}){const n=f(),o=n.environmentName,t=n.packageName,i=n["*"],s=i===void 0?void 0:g(i),{versions:r,isPending:d,isError:v,refetch:u}=p(o??"",t??"",{enabled:e.always===!0||s!==void 0}),a=r.length>0,c=s&&a?s:void 0;return{environmentName:o,packageName:t,versionSegment:c?.segment,versionId:h(c?.segment),path:c?c.rest:i,versioned:a,deciding:s!==void 0&&d,undecided:s!==void 0&&v,retry:u,writable:!a&&!d&&!v}}export{m as L,I as p,R as u,h as v,E as w};
package/dist/index.html CHANGED
@@ -16,7 +16,7 @@ SPDX-License-Identifier: MIT
16
16
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
17
17
  />
18
18
  <title>Malloy Publisher</title>
19
- <script type="module" crossorigin src="/assets/index-BSyL0zds.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-CCLHq9po.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-DUqldpo0.css">
21
21
  </head>
22
22
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@malloy-publisher/app",
3
3
  "description": "Malloy Publisher Console (the built-in web UI)",
4
- "version": "0.18.2",
4
+ "version": "0.18.4",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -42,7 +42,7 @@
42
42
  "test:playwright:headed": "bunx playwright test --config=playwright.config.ts --headed"
43
43
  },
44
44
  "dependencies": {
45
- "@malloy-publisher/sdk": "^0.18.2",
45
+ "@malloy-publisher/sdk": "^0.18.4",
46
46
  "@modelcontextprotocol/ext-apps": "1.7.5",
47
47
  "@mui/icons-material": "^7.0.2",
48
48
  "@mui/material": "^7.0.2",
@@ -1 +0,0 @@
1
- import{E as u,r as c}from"./index-BSyL0zds.js";import{w as e}from"./usePackageRoute-wJGaZEiY.js";function p(t,a,r){const s=u();return c.useCallback((o,i)=>s(e(o,t,a,r),i),[s,t,a,r])}export{p as u};