@malloy-publisher/app 0.9.5 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{r as S,aX as Uf,aY as Gf,j as y,ap as xe,ay as lt,T as ue,aD as Ee,aZ as Pr,a_ as Kf,N as vc,aw as Yf,a$ as wt,b0 as Xf,b1 as fi,b2 as Vf,b3 as Zf,b4 as Qf,_ as bc,b5 as Jf,b6 as eh,b7 as jn,R as Qe,F as Ae,b8 as th,b9 as Ji,ba as nh,K as en,G as Us,bb as Lt,bc as ut,bd as rh,be as yc,aC as es,a8 as ih,bf as sh,bg as xc,bh as wc,bi as kc,bj as oh,bk as ah,bl as lh,a5 as ch,bm as dh,bn as uh,bo as fh,bp as Sc,bq as hh,br as ph,bs as mh,bt as gh,aQ as $c,bu as vh,bv as jc,bw as ts,bx as Cc,by as Oc,bz as bh,bA as yh,bB as xh,bC as wh,ar as et,bD as Ec,bE as nl,H as Ei,I as kh,bF as Sh,bG as Rr,av as Nt,bH as Gs,bI as Tc,bJ as Mc,as as $h,W as Fo,bK as _o,bL as jh,bM as Ch,bN as qo,bO as Oh,aI as Eh,bP as Th,bQ as Mh,bR as Ah,bS as Bt,bT as rl,S as Dh,bU as Ih,L as Ph,U as Rh,bV as Bo,bW as Lh,bX as Nh,bY as Ac,bZ as Wh,aF as zh}from"./index-BIqIsMFr.js";import{b_ as lx,b$ as cx,c0 as dx,c1 as ux,c2 as fx,c3 as hx,c4 as px,c5 as mx,c6 as gx,c7 as vx,c8 as bx}from"./index-BIqIsMFr.js";import{T as Dc,a as Ti}from"./ToggleButtonGroup-BKiI79mw.js";var il={};const Fh={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function _h(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this view's details":n==="unlisted"?"Not a view the catalog lists, so its shape is unknown":void 0,i=s=>{if(t!==s){if(s==="big_value")return e?.aggregateOnly===!0?void 0:r??"Needs a view with only totals (no group by)";if(s==="shape_map"||s==="segment_map")return e?.chart===s?void 0:r??"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(s=>{const o=i(s);return{value:s,label:Fh[s],...o?{disabled:!0,reason:o}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Ks({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:i,onOpen:s,onChange:o,variant:a="standard"}){const c=_h(t,e,n),u=S.useId();return y.jsx(et,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:i!==void 0,onChange:l=>{const d=l.target.value;c.find(h=>h.value===d)?.disabled||o(d)},helperText:i,FormHelperTextProps:{id:u},SelectProps:{...s?{onOpen:s}:{},renderValue:l=>c.find(d=>d.value===l)?.label??String(l),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...i?{"aria-describedby":u}:{}}},sx:{minWidth:140},children:c.map(l=>y.jsx(Nt,{value:l.value,disabled:l.value==="custom"||l.disabled===!0,children:y.jsx(Fo,{primary:l.label,...l.reason?{secondary:l.reason}:{}})},l.value))})}function qh({sources:e,source:t,view:n,onSource:r,onView:i}){const{theme:s}=Qe(),o=e.find(a=>a.name===t);return y.jsxs(y.Fragment,{children:[y.jsx(et,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>y.jsxs(Nt,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),y.jsxs(Ae,{children:[y.jsx(ue,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(Ph,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:"min(280px, 30vh)",overflowY:"auto",border:s.border,borderRadius:1},children:[(o?.views??[]).map(a=>y.jsxs(Rh,{selected:n===a.name,onClick:()=>i(a.name),"aria-label":`View ${a.name}`,children:[y.jsx(Fo,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&y.jsx(Us,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&y.jsx(ue,{variant:"body2",sx:{p:1.5,color:s.tileTitle},children:"This source declares no views."})]})]})]})}function Bh({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o}){const{theme:a}=Qe(),c=S.useMemo(()=>n?.sources??[],[n]),[u,l]=S.useState("query"),[d,h]=S.useState(""),[f,m]=S.useState(""),[g,x]=S.useState(""),[w,p]=S.useState("default"),[v,b]=S.useState(Math.ceil(r/2));S.useEffect(()=>{if(!e)return;l("query");const $=O=>c.some(z=>z.name===O&&z.views.length>0);h(t.sources.map(O=>O.base).find($)??c.find(O=>O.views.length>0)?.name??""),m(""),x(""),p("default"),b(Math.ceil(r/2))},[e,t,c,r]);const k=d!==""&&f!=="",D=[d,f].filter($=>$!==""&&!_o($)).map($=>`"${$}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],M=c.find($=>$.name===d),A=M?.views.find($=>$.name===f);return y.jsx(es,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of a source in this package.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:i,children:"Cancel"}),y.jsx(Ee,{variant:"contained",disabled:u==="query"&&(!k||D!==void 0),onClick:()=>u==="text"?o():s({base:d,modelPath:M?.modelPath??"",...M?.exporters?{exporters:M.exporters}:{},view:f,...g.trim()?{label:g.trim()}:{},...w!=="default"?{chart:w,...A?{chartCarried:A.chart?[A.chart]:[]}:{}}:{},colspan:v}),children:u==="text"?"Add text":"Add tile"})]}),children:y.jsxs(xe,{sx:{gap:2,pt:1},children:[y.jsxs(Dc,{size:"small",exclusive:!0,value:u,"aria-label":"Tile type",onChange:($,O)=>{O!==null&&l(O)},children:[y.jsx(Ti,{value:"query",sx:{px:1.5},children:"Query"}),y.jsx(Ti,{value:"text",sx:{px:1.5},children:"Text"})]}),u==="text"?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:"A text tile holds markdown: a heading, a paragraph, a list. It is added empty, and written on the tile itself."}):c.length===0?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}):y.jsxs(y.Fragment,{children:[y.jsx(qh,{sources:c,source:d,view:f,onSource:$=>{h($),m("")},onView:$=>{m($),p("default")}}),D&&y.jsx(ue,{variant:"body2",color:"error",children:D}),y.jsx(Ks,{state:w,view:A,cellLabel:"new tile",variant:"outlined",...A?{}:{disabledReason:"Pick a view to choose its chart."},onChange:$=>p($)}),y.jsx(xe,{direction:"row",sx:{gap:1.5},children:y.jsx(et,{size:"small",label:"Title",placeholder:"Uses the view's name",value:g,onChange:$=>x($.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}})})]})]})})}const Re=e=>e.kind==="text",be=e=>e.kind!=="text",Vr=e=>be(e)?e.label??e.name:e.name,ze=e=>Re(e)?`text.${e.name}`:`${e.source}.${e.name}`,ws="self";function Hh({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Qe(),[c,u]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const f=(t.drills??[]).filter(m=>m.source===n.name);u((n.dimensions??[]).map(m=>{const g=f.find(x=>x.name===m.name);return{name:m.name,expression:m.expression,to:g?.to??[],given:g?.given??""}}))},[e,n,t]);const l=(f,m)=>u(g=>g.map((x,w)=>{if(w!==f)return x;const p={...x};return m(p),p})),d=[ws,...i.filter(f=>f!==ws)],h=f=>f===ws?"This dashboard":f;return y.jsx(es,{open:e,onClose:s,title:"Drill",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:s,children:"Cancel"}),y.jsx(Ee,{variant:"contained",onClick:()=>{n&&(o(c.filter(f=>f.to.length>0).map(f=>({source:n.name,name:f.name,expression:f.expression,to:f.to,...f.given?{given:f.given}:{}}))),s())},disabled:c.length===0,children:"Apply"})]}),children:y.jsx(xe,{sx:{gap:2,pt:1},children:c.length===0?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(Ae,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",y.jsx(Ae,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):c.map((f,m)=>y.jsxs(Ae,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(Ae,{sx:{minWidth:0,pt:.75},children:[y.jsx(ue,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:f.name}),y.jsxs(ue,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:f.expression,children:["is ",f.expression]})]}),y.jsx(et,{select:!0,size:"small",label:"Clicks go to",value:f.to,inputProps:{"aria-label":`Where ${f.name} goes`},SelectProps:{multiple:!0,renderValue:g=>g.length===0?"Not clickable":g.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:g=>l(m,x=>{const w=g.target.value;x.to=Array.isArray(w)?w:String(w).split(",").filter(Boolean)}),children:d.map(g=>y.jsxs(Nt,{value:g,children:[y.jsx(Gs,{size:"small",checked:f.to.includes(g),sx:{p:0,mr:1}}),y.jsx(Fo,{primary:h(g)})]},g))}),y.jsxs(et,{select:!0,size:"small",label:"Sets the filter",value:f.given,disabled:f.to.length===0,inputProps:{"aria-label":`Control ${f.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:f.given===""?`Named ${f.name}, like the dimension`:void 0,onChange:g=>l(m,x=>{x.given=g.target.value}),children:[y.jsx(Nt,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(g=>y.jsx(Nt,{value:g,children:g},g))]})]},f.name))})})}function Uh(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of be(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 Mi(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Gh(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function hi(e,t){const n=Gh(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 sl(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 Kh(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Yh=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Xh(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=Ac(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 ol=[{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 Zr(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 Ys=e=>be(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function Vh(e,t){return e.tiles.map(n=>{const r=(be(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}:Mi(t.type)!==void 0?{op:Mi(t.type)}:{}}})}function Zh(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Ys(s))return;const o=(s.filters??[]).filter(c=>c.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function Qh(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function Jh(e,t){for(const r of e.tiles){if(!be(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 Ic=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function ep({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,c=a!==void 0,[u,l]=S.useState({kind:"new"}),[d,h]=S.useState(""),[f,m]=S.useState("select"),[g,x]=S.useState(""),[w,p]=S.useState(""),[v,b]=S.useState([]),[k,D]=S.useState(!1),[M,A]=S.useState(!1),$=P=>t.sources.find(H=>H.name===P.source)?.base??P.source;S.useEffect(()=>{if(e)if(A(n!==void 0),n){l({kind:"existing",name:n.name}),h(n.label??"");const P=Vh(t,n);b(P);const H=P.filter(me=>me.include),oe=new Set(H.map(me=>me.field));p(oe.size===1?H[0].field:n.field??""),D(oe.size>1)}else l({kind:"new"}),h(""),m("select"),p(""),x(new Date().toISOString().slice(0,10)),b(t.tiles.map(P=>({include:Ys(P),field:""}))),D(!1)},[e,n,t]);const O=S.useMemo(()=>[...(t.localGivens??[]).map(P=>P.name),...r.map(P=>P.name)],[t,r]),z=S.useMemo(()=>w.trim()?Xh(w.trim(),O):"",[w,O]),I=u.kind==="existing"?n??r.find(P=>P.name===u.name):z?{name:z,type:Zr({name:z,label:d,kind:f,field:w}).type}:void 0,W=I?.type!==void 0&&!I.type.startsWith("filter<"),G=v.find(P=>P.include)?.op??Mi(I?.type),q=(P,H)=>{A(!0),b(oe=>oe.map((me,Fe)=>Fe===P?{...me,...H}:me))},U=P=>{A(!0),b(H=>H.map(oe=>({...oe,op:P})))},K=P=>{const H=Mi(P);b(oe=>oe.map(({op:me,...Fe})=>H?{...Fe,op:H}:Fe))},V=P=>{A(!0),l({kind:"existing",name:P.name}),p(P.field??""),K(P.type)},re=P=>{A(!0),m(P),K(Zr({name:"X",label:d,kind:P,field:w}).type)},T=t.tiles.map(Ys),_=T.filter(Boolean).length,R=v.filter((P,H)=>P.include&&T[H]).length,N=t.tiles.filter((P,H)=>(v[H]?.include??!1)&&T[H]&&be(P)),F=N.length>0?N:t.tiles.filter((P,H)=>T[H]&&be(P)),ee=S.useMemo(()=>{const P=new Map;let H=!1;for(const oe of F){const me=i?.(oe);if(me){H=!0;for(const Fe of me)P.has(Fe.name)||P.set(Fe.name,Fe)}}return H?[...P.values()]:void 0},[v,t.tiles,i]),J=(()=>{const P=w.trim();for(const H of N){const oe=i?.(H);if(!oe||oe.some(me=>me.name===P))return $(H)}return N[0]?$(N[0]):t.sources[0]?.base})(),C=P=>{A(!0),b(H=>H.map((oe,me)=>({...oe,include:P&&T[me]})))},j=S.useMemo(()=>k?v:v.map(P=>({...P,field:w})),[k,v,w]),E=P=>{for(const H of F){const oe=i?.(H)?.find(me=>me.name===P.trim());if(oe?.type)return oe.type}},Z=P=>hi(I?.type,P.type),B=(P,H)=>{if(P.trim()==="")return"Pick the field this filter compares.";const oe=H?i?.(H):void 0;if(!oe)return;const me=oe.find(Fe=>Fe.name===P.trim());if(!me)return`Not a field of ${H?$(H):"the tiles' source"}.`;if(me.type&&!hi(I?.type,me.type))return`${P.trim()} is ${sl(me.type)}; this filter compares ${sl(I?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},te=P=>{if(A(!0),p(P),c||u.kind!=="new")return;const H=E(P),oe=Zr({name:"X",label:d,kind:f,field:P}).type;H&&!hi(oe,H)&&re(Kh(H))},X=P=>{const H=t.tiles[P];return H&&be(H)?H:void 0},ne=j.map((P,H)=>P.include&&T[H]?B(P.field,X(H)):void 0),Q=ne.every(P=>P===void 0),pe=M?ne:ne.map(()=>{}),L=M&&!k&&R>0?N.map(P=>B(w,P)).find(Boolean):void 0,ae=I!==void 0&&Q&&(u.kind==="existing"||w.trim()!==""&&z!==""),fe=()=>{if(!(!I||!ae))if(u.kind==="new")s(I.name,j,Zr({name:I.name,label:d.trim()||Ic(I.name),kind:f,field:w.trim(),...J?{source:J}:{},...g?{dateDefault:g}:{}}));else if(n?.origin==="dashboard"&&n.local){const P=d.trim(),H=P!==(n.local.label??"");s(I.name,j,H?{...n.local,...P?{label:P}:{}}:void 0)}else s(I.name,j)},Y=c&&a.origin==="model";return{editing:c,shown:a,fromModel:Y,source:u,setSource:l,label:d,setLabel:h,kind:f,dateDefault:g,setDateDefault:x,field:w,rows:v,setRows:b,perTile:k,setPerTile:D,newName:z,target:I,valueTyped:W,commonOp:G,setRow:q,setCommonOp:U,pickExisting:V,pickKind:re,bindable:T,bindableCount:_,included:R,commonFields:ee,setAll:C,accepts:Z,pickField:te,rowProblems:pe,commonProblem:L,canApply:ae,apply:fe}}function al({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:c,autoFocus:u,placeholder:l,sx:d}){const h=S.useMemo(()=>(n??[]).filter(m=>r?.(m)??!0).map(m=>m.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(m=>[m.name,m.type])),[n]);return y.jsx(Ih,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(m,g)=>t(g),value:e,onChange:(m,g)=>t(typeof g=="string"?g:""),disabled:c,disableClearable:!0,renderOption:(m,g)=>S.createElement("li",{...m,key:g},y.jsx(ue,{variant:"body2",sx:{flex:1},children:g}),f.get(g)&&y.jsx(ue,{variant:"caption",sx:{opacity:.6},children:f.get(g)?.replace(/_type$/,"")})),renderInput:m=>y.jsx(et,{...m,label:i,placeholder:l,autoFocus:u,error:o,helperText:a,inputProps:{...m.inputProps,"aria-label":s}}),sx:d})}const ll=e=>e&&be(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this dashboard does not write."};function tp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:c}=Qe(),{editing:u,shown:l,fromModel:d,source:h,setSource:f,label:m,setLabel:g,kind:x,dateDefault:w,setDateDefault:p,field:v,rows:b,setRows:k,perTile:D,setPerTile:M,newName:A,target:$,valueTyped:O,commonOp:z,setRow:I,setCommonOp:W,pickExisting:G,pickKind:q,bindable:U,bindableCount:K,included:V,commonFields:re,setAll:T,accepts:_,pickField:R,rowProblems:N,commonProblem:F,canApply:ee,apply:J}=ep({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),C=(j,E,Z)=>y.jsx(et,{select:!0,size:"small",label:"Compares",value:j??">=",onChange:B=>E(B.target.value),inputProps:{"aria-label":Z},sx:{width:130},children:Yh.filter(B=>B.op!=="~").map(B=>y.jsx(Nt,{value:B.op,children:B.label},B.op))});return y.jsx(es,{open:e,onClose:s,title:u?l.label??l.name:"Add a filter",description:u?y.jsxs(y.Fragment,{children:[y.jsxs(Ae,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",l.name]}),d?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A filter on the page, and the tiles it filters.",actions:y.jsxs(y.Fragment,{children:[u&&y.jsx(Ee,{color:"error",startIcon:y.jsx(Mc,{}),onClick:()=>a(l.name),sx:j=>({mr:"auto",color:Tc(j)}),children:"Remove filter"}),y.jsx(Ee,{onClick:s,children:"Cancel"}),y.jsx(en,{title:ee||$===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(Ee,{variant:"contained",onClick:J,disabled:!ee,children:u?"Apply":"Add filter"})})})]}),children:y.jsxs(xe,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&y.jsxs(Dc,{exclusive:!0,size:"small",value:h.kind,onChange:(j,E)=>{E==="new"?f({kind:"new"}):E==="existing"&&r[0]&&G(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(Ti,{value:"new",children:"New in this dashboard"}),y.jsx(Ti,{value:"existing",children:"From the model"})]}),!u&&h.kind==="existing"?y.jsx(et,{select:!0,size:"small",label:"Filter",value:h.name,onChange:j=>{const E=r.find(Z=>Z.name===j.target.value);E&&G(E)},children:r.map(j=>y.jsxs(Nt,{value:j.name,children:[j.label??j.name,y.jsxs(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",j.name]})]},j.name))}):null,y.jsxs(xe,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!D&&y.jsx(al,{value:v,onChange:R,fields:re,accepts:_,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:F!==void 0,helperText:F??(!u&&A?`Declared as $${A}`:void 0),sx:{flex:1,minWidth:200}}),!d&&y.jsx(et,{size:"small",label:"Label",placeholder:A?Ic(A):"",value:m,onChange:j=>g(j.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),O&&!D&&C(z,W,"Comparison")]}),!u&&h.kind==="new"&&y.jsxs(xe,{direction:"row",sx:{gap:1.5},children:[y.jsx(et,{select:!0,size:"small",label:"Filter kind",value:x,onChange:j=>q(j.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:j=>ol.find(E=>E.kind===j)?.label??String(j)}},sx:{flex:1},children:ol.map(j=>y.jsxs(Nt,{value:j.kind,children:[j.label,y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:j.hint})]},j.kind))}),x==="date"&&y.jsx(et,{size:"small",type:"date",label:"Starts at",value:w,onChange:j=>p(j.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(Ae,{children:[y.jsxs(xe,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(Gs,{size:"small",checked:K>0&&V===K,indeterminate:V>0&&V<K,disabled:K===0,onChange:j=>T(j.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(ue,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",V," of ",t.tiles.length," tiles"]}),y.jsx(Ee,{size:"small",onClick:()=>{D||k(j=>j.map(E=>({...E,field:v}))),M(j=>!j)},children:D?"Same field for all":"Adjust per tile"})]}),y.jsx(xe,{sx:{gap:D?1:0},children:t.tiles.map((j,E)=>{if(!be(j))return null;const Z=b[E],B=j.label??j.name,te=D?N[E]:void 0;return y.jsxs(xe,{direction:"row",sx:{gap:1,alignItems:D?"flex-start":"center",opacity:U[E]?1:.6},children:[y.jsx(Gs,{size:"small",disabled:!U[E],checked:(Z?.include??!1)&&U[E],inputProps:{"aria-label":`Filter ${B}`},onChange:X=>I(E,{include:X.target.checked})}),y.jsx(ue,{variant:"body2",sx:{flex:1,minWidth:0,pt:D?1:0},noWrap:!0,children:B}),U[E]?D&&y.jsxs(y.Fragment,{children:[O&&C(Z?.op,X=>I(E,{op:X}),`Comparison for ${B}`),y.jsx(al,{value:Z?.field??"",onChange:X=>I(E,{field:X}),fields:i?.(j),accepts:_,label:"Field",ariaLabel:`Field for ${B}`,disabled:!Z?.include,error:te!==void 0,helperText:te,sx:{width:220}})]}):y.jsx(en,{title:ll(t.tiles[E]).reason,children:y.jsx(ue,{variant:"caption",sx:{color:c.tileTitle},children:ll(t.tiles[E]).label})})]},`${j.source}.${j.name}`)})}),V===0&&y.jsx(ue,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}const np=Rr(y.jsx("path",{d:"M11.71 17.99C8.53 17.84 6 15.22 6 12c0-3.31 2.69-6 6-6 3.22 0 5.84 2.53 5.99 5.71l-2.1-.63C15.48 9.31 13.89 8 12 8c-2.21 0-4 1.79-4 4 0 1.89 1.31 3.48 3.08 3.89zM22 12c0 .3-.01.6-.04.9l-1.97-.59c.01-.1.01-.21.01-.31 0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8c.1 0 .21 0 .31-.01l.59 1.97c-.3.03-.6.04-.9.04-5.52 0-10-4.48-10-10S6.48 2 12 2s10 4.48 10 10m-3.77 4.26L22 15l-10-3 3 10 1.26-3.77 4.27 4.27 1.98-1.98z"}));function Pc(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const c=structuredClone(a);return o(c),c}),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 rp=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.`,ip="This tile's view is declared on its source, so its chart is set in the model.";function sp({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,removeBlocked:s,onDrills:o,view:a}){const c=S.useId(),{theme:u}=Qe(),{draft:l,apply:d,close:h,discard:f}=Pc(t,e!==null,r,n),m=l!==void 0&&be(l)?l:void 0,g=m!==void 0&&m.declaration.kind!=="inherited",x=v=>d(b=>{be(b)&&v(b)}),w=S.useRef(void 0),p=e!==null;return S.useEffect(()=>{p&&(w.current=t&&be(t)?t.chart:void 0)},[p]),y.jsx($h,{open:e!==null&&l!==void 0,anchorEl:e,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:l&&y.jsxs(xe,{sx:{gap:1.5},children:[y.jsx(ue,{variant:"overline",sx:{color:u.tileTitle,lineHeight:1.5},children:m?`${m.source} → ${m.name}`:`Text · ${l.name}`}),m&&g&&y.jsx(y.Fragment,{children:y.jsx(Ks,{state:m.chart??"default",view:a,cellLabel:`${m.source} ${m.name}`,...m.chart==="custom"?{disabledReason:rp(m.chartLines)}:{},onChange:v=>x(b=>{const k=w.current;v===(k??"default")?(k===void 0?delete b.chart:b.chart=k,delete b.chartCarried):(b.chart=v,a?b.chartCarried=a.chart?[a.chart]:[]:delete b.chartCarried)})})}),m&&!g&&y.jsxs(y.Fragment,{children:[y.jsx(ue,{variant:"body2",sx:{color:u.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),y.jsx(Ks,{state:"default",view:a,cellLabel:`${m.source} ${m.name}`,disabledReason:ip,onChange:()=>{}})]}),m?.declaration.kind==="opaque"&&y.jsxs(ue,{variant:"body2",sx:{color:u.tileTitle},children:["Its body is ",m.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),y.jsxs(xe,{direction:"row",sx:{justifyContent:"space-between"},children:[g?y.jsx(Ee,{size:"small",startIcon:y.jsx(np,{}),"aria-haspopup":"dialog",onClick:()=>{h(),o()},children:"Drill"}):y.jsx("span",{}),y.jsx(Ee,{color:"error",size:"small",startIcon:y.jsx(Mc,{}),"aria-disabled":s!==void 0||void 0,"aria-describedby":s!==void 0?c:void 0,disableRipple:s!==void 0,sx:v=>({color:Tc(v),...s!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{s===void 0&&(f(),i())},children:"Delete"})]}),s!==void 0&&y.jsx(ue,{id:c,variant:"caption",sx:{color:u.tileTitle},children:s})]})})}function op({editor:e,catalog:t,columns:n,dashboards:r,bindings:i,tiles:s,drillSource:o,setDrillSource:a,confirmConversion:c,exitDialog:u}){const{filterDialog:l,setFilterDialog:d}=i,{menu:h,setMenu:f}=s,m=h===void 0?void 0:e.document.tiles[h.index],g=m&&be(m)?m:void 0,x=(()=>{if(!g||!t)return;const w=e.document.sources.find(v=>v.name===g.source)?.base??g.source,p=g.declaration.kind==="reference"?g.declaration.from:g.name;return t.sources.find(v=>v.name===w)?.views.find(v=>v.name===p)})();return y.jsxs(y.Fragment,{children:[y.jsx(tp,{open:l!==void 0,document:e.document,...l?.control?{control:l.control}:{},available:i.available,...t?{fieldsFor:i.fieldsFor}:{},onClose:()=>d(void 0),onApply:i.applyFilter,onRemove:i.dropControl}),y.jsx(sp,{anchor:h?.anchor??null,tile:h===void 0?void 0:e.document.tiles[h.index],onClose:()=>f(void 0),onCommit:w=>{const p=h?.index;p!==void 0&&e.update(v=>{v.tiles[p]=w})},onRemove:()=>{h!==void 0&&s.removeTile(h.index)},...e.document.tiles.length===1&&e.saved.tiles.length>0?{removeBlocked:"A saved dashboard needs at least one tile."}:{},view:x,onDrills:()=>{a(g?.source)}}),y.jsx(Hh,{open:o!==void 0,document:e.document,source:e.document.sources.find(w=>w.name===o),givenNames:i.controlList.map(w=>w.name),dashboards:r??[],onClose:()=>a(void 0),onApply:w=>e.update(p=>{const v=[...(p.drills??[]).filter(b=>b.source!==o),...w];v.length===0?delete p.drills:p.drills=v})}),y.jsx(es,{open:c!==void 0,onClose:()=>c?.stop(),title:"Convert this notebook?",description:"Saving rewrites this notebook in the tile layout. The builder cannot take that back; the file's history in your repository can.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:()=>c?.stop(),children:"Cancel"}),y.jsx(Ee,{variant:"contained",onClick:()=>c?.go(),children:"Convert and save"})]}),children:null}),y.jsx(ih,{...u}),y.jsx(Bh,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText})]})}var ap=Symbol.for("preact-signals");function ns(){if(St>1)St--;else{var e,t=!1;for((function(){var i=Di;for(Di=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}})();gr!==void 0;){var n=gr;for(gr=void 0,Ai++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Lc(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(Ai=0,St--,t)throw e}}function je(e){if(St>0)return e();Xs=++lp,St++;try{return e()}finally{ns()}}var mr,ye=void 0;function le(e){var t=ye,n=mr;ye=void 0,mr=void 0;try{return e()}finally{ye=t,mr=n}}var gr=void 0,St=0,Ai=0,lp=0,Xs=0,Di=void 0,Ii=0;function Rc(e){if(ye!==void 0){var t=e.n;if(t===void 0||t.t!==ye)return t={i:0,S:e,p:ye.s,n:void 0,t:ye,e:void 0,x:void 0,r:t},ye.s!==void 0&&(ye.s.n=t),ye.s=t,e.n=t,32&ye.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=ye.s,t.n=void 0,ye.s.n=t,ye.s=t),t}}function Ge(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}Ge.prototype.brand=ap;Ge.prototype.h=function(){return!0};Ge.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:le(function(){var r;(r=t.W)==null||r.call(t)}))};Ge.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&&le(function(){var i;(i=t.Z)==null||i.call(t)}))}};Ge.prototype.subscribe=function(e){var t=this;return ot(function(){var n=t.value;le(function(){return e(n)})},{name:"sub"})};Ge.prototype.valueOf=function(){return this.value};Ge.prototype.toString=function(){return this.value+""};Ge.prototype.toJSON=function(){return this.value};Ge.prototype.peek=function(){var e=this;return le(function(){return e.value})};Object.defineProperty(Ge.prototype,"value",{get:function(){var e=Rc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ai>100)throw new Error("Cycle detected");(function(n){St!==0&&Ai===0&&n.l!==Xs&&(n.l=Xs,Di={S:n,v:n.v,i:n.i,o:Di})})(this),this.v=e,this.i++,Ii++,St++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ns()}}}});function Ln(e,t){return new Ge(e,t)}function Lc(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 Nc(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 Wc(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 sn(e,t){Ge.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Ii-1,this.f=4}sn.prototype=new Ge;sn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ii))return!0;if(this.g=Ii,this.f|=1,this.i>0&&!Lc(this))return this.f&=-2,!0;var e=ye;try{Nc(this),ye=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 ye=e,Wc(this),this.f&=-2,!0};sn.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)}Ge.prototype.S.call(this,e)};sn.prototype.U=function(e){if(this.t!==void 0&&(Ge.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)}};sn.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(sn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Rc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function cl(e,t){return new sn(e,t)}function zc(e){var t=e.m;if(e.m=void 0,typeof t=="function"){St++;var n=ye;ye=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ho(e),r}finally{ye=n,ns()}}}function Ho(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,zc(e)}function cp(e){if(ye!==this)throw new Error("Out-of-order effect");Wc(this),ye=e,this.f&=-2,8&this.f&&Ho(this),ns()}function Nn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,mr&&mr.push(this)}Nn.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()}};Nn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,zc(this),Nc(this),St++;var e=ye;return ye=this,cp.bind(this,e)};Nn.prototype.N=function(){2&this.f||(this.f|=2,this.u=gr,gr=this)};Nn.prototype.d=function(){this.f|=8,1&this.f||Ho(this)};Nn.prototype.dispose=function(){this.d()};function ot(e,t){var n=new Nn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var dp=Object.create,Uo=Object.defineProperty,up=Object.defineProperties,fp=Object.getOwnPropertyDescriptor,hp=Object.getOwnPropertyDescriptors,dl=Object.getOwnPropertySymbols,pp=Object.prototype.hasOwnProperty,mp=Object.prototype.propertyIsEnumerable,gp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Wn=e=>{throw TypeError(e)},Vs=(e,t,n)=>t in e?Uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vp=(e,t)=>{for(var n in t||(t={}))pp.call(t,n)&&Vs(e,n,t[n]);if(dl)for(var n of dl(t))mp.call(t,n)&&Vs(e,n,t[n]);return e},bp=(e,t)=>up(e,hp(t)),ul=(e,t)=>Uo(e,"name",{value:t,configurable:!0}),yp=e=>{var t;return[,,,dp((t=void 0)!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],Jn=e=>e!==void 0&&typeof e!="function"?Wn("Function expected"):e,xp=(e,t,n,r,i)=>({kind:Fc[e],name:t,metadata:r,addInitializer:s=>n._?Wn("Already initialized"):i.push(Jn(s||null))}),_c=(e,t)=>Vs(t,gp("metadata"),e[3]),qt=(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},zn=(e,t,n,r,i,s)=>{var o,a,c,u,l,d=t&7,h=!!(t&8),f=!!(t&16),m=d>3?e.length+1:d?h?1:2:0,g=Fc[d+5],x=d>3&&(e[m-1]=[]),w=e[m]||(e[m]=[]),p=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&fp(d<4?i:{get[n](){return tt(this,s)},set[n](b){return At(this,s,b)}},n));d?f&&d<4&&ul(s,(d>2?"set ":d>1?"get ":"")+n):ul(i,n);for(var v=r.length-1;v>=0;v--)u=xp(d,n,c={},e[3],w),d&&(u.static=h,u.private=f,l=u.access={has:f?b=>wp(i,b):b=>n in b},d^3&&(l.get=f?b=>(d^1?tt:kp)(b,i,d^4?s:p.get):b=>b[n]),d>2&&(l.set=f?(b,k)=>At(b,i,k,d^4?s:p.set):(b,k)=>b[n]=k)),a=(0,r[v])(d?d<4?f?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),c._=1,d^4||a===void 0?Jn(a)&&(d>4?x.unshift(a):d?f?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Wn("Object expected"):(Jn(o=a.get)&&(p.get=o),Jn(o=a.set)&&(p.set=o),Jn(o=a.init)&&x.unshift(o));return d||_c(e,i),p&&Uo(i,n,p),f?d^4?s:p:i},Go=(e,t,n)=>t.has(e)||Wn("Cannot "+n),wp=(e,t)=>Object(t)!==t?Wn('Cannot use the "in" operator on this value'):e.has(t),tt=(e,t,n)=>(Go(e,t,"read from private field"),n?n.call(e):t.get(e)),er=(e,t,n)=>t.has(e)?Wn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),At=(e,t,n,r)=>(Go(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),kp=(e,t,n)=>(Go(e,t,"access private method"),n);function Zs(e,t){if(t){let n;return cl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return cl(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 ce({get:e},t){return{init(n){return Ln(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Oe(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Zs(e.bind(this)),n.set(this,r)),r.value}}function ks(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,bp(vp({},i),{enumerable:e}))})}}function Lr(...e){const t=e.map(n=>ot(n));return()=>t.forEach(n=>n())}var qc,Bc,Hc,Uc,Gc,Kc,Be,Ko,Ss,Qs,Js,_e,Yo,$s,Yc,eo,Xo,js,to,no;Kc=[ce],Gc=[ce],Uc=[ce],Hc=[ks()],Bc=[ks()],qc=[ks()];var on=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,qt(Be,5,this),er(this,_e),er(this,Ko,qt(Be,8,this)),qt(Be,11,this),er(this,Yo,qt(Be,12,this)),qt(Be,15,this),er(this,Xo,qt(Be,16,this)),qt(Be,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return tt(this,_e,to)}get initial(){return tt(this,_e,Qs)}get previous(){return tt(this,_e,Yc)}set current(e){const t=le(()=>tt(this,_e,to));e&&t&&this.equals(t,e)||je(()=>{tt(this,_e,Qs)||At(this,_e,e,Js),At(this,_e,t,eo),At(this,_e,e,no)})}reset(e=this.defaultValue){je(()=>{At(this,_e,void 0,eo),At(this,_e,e,Js),At(this,_e,e,no)})}};Be=yp();Ko=new WeakMap;_e=new WeakSet;Yo=new WeakMap;Xo=new WeakMap;Ss=zn(Be,20,"#initial",Kc,_e,Ko),Qs=Ss.get,Js=Ss.set;$s=zn(Be,20,"#previous",Gc,_e,Yo),Yc=$s.get,eo=$s.set;js=zn(Be,20,"#current",Uc,_e,Xo),to=js.get,no=js.set;zn(Be,2,"current",Hc,on);zn(Be,2,"initial",Bc,on);zn(Be,2,"previous",qc,on);_c(Be,on);function Cs(e){return le(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Ht,Sp=class{constructor(){er(this,Ht,new WeakMap)}get(e,t){var n;return e?(n=tt(this,Ht).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return tt(this,Ht).has(e)||tt(this,Ht).set(e,new Map),(r=tt(this,Ht).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=tt(this,Ht).get(e))==null?void 0:t.clear():void 0}};Ht=new WeakMap;var $p=Object.create,Xc=Object.defineProperty,jp=Object.getOwnPropertyDescriptor,fl=Object.getOwnPropertySymbols,Cp=Object.prototype.hasOwnProperty,Op=Object.prototype.propertyIsEnumerable,Vc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),rs=e=>{throw TypeError(e)},hl=Math.pow,ro=(e,t,n)=>t in e?Xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ep=(e,t)=>{for(var n in t||(t={}))Cp.call(t,n)&&ro(e,n,t[n]);if(fl)for(var n of fl(t))Op.call(t,n)&&ro(e,n,t[n]);return e},Tp=e=>{var t;return[,,,$p((t=e?.[Vc("metadata")])!=null?t:null)]},Zc=["class","method","getter","setter","accessor","field","value","get","set"],Qc=e=>e!==void 0&&typeof e!="function"?rs("Function expected"):e,Mp=(e,t,n,r,i)=>({kind:Zc[e],name:t,metadata:r,addInitializer:s=>n._?rs("Already initialized"):i.push(Qc(s||null))}),Ap=(e,t)=>ro(t,Vc("metadata"),e[3]),Dp=(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},Jc=(e,t,n,r,i,s)=>{for(var o,a,c,u,l=t&7,d=!1,h=!1,f=2,m=Zc[l+5],g=e[f]||(e[f]=[]),x=(i=i.prototype,jp(i,n)),w=r.length-1;w>=0;w--)c=Mp(l,n,a={},e[3],g),c.static=d,c.private=h,u=c.access={has:p=>n in p},u.get=p=>p[n],o=(0,r[w])(x[m],c),a._=1,Qc(o)&&(x[m]=o);return x&&Xc(i,n,x),i},ed=(e,t,n)=>t.has(e)||rs("Cannot "+n),Ip=(e,t,n)=>(ed(e,t,"read from private field"),t.get(e)),Pp=(e,t,n)=>t.has(e)?rs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Rp=(e,t,n,r)=>(ed(e,t,"write to private field"),t.set(e,n),n),nt=class io{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new io(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 io(t,n)}},gt=class Ut{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,c=new Ut(i+t,r+n,s,o);return c.scale=Ep({},a),c}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new nt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ut))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 Ut?Lp(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 Ut(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],c=o==="x"?s.left:s.top,u=o==="x"?s.width:s.height;return a=="start"?c:a=="end"?c+u:c+u/2};return nt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Ut.from(t).intersectionRatio(Ut.from(n))}};function Lp(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 td,nd,so,pi,Nr,is=class extends(so=on,nd=[Oe],td=[Oe],so){constructor(e){const t=nt.from(e);super(t,(n,r)=>nt.equals(n,r)),Dp(Nr,5,this),Pp(this,pi,0),this.velocity={x:0,y:0}}get delta(){return nt.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=nt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Ip(this,pi),o=a=>Math.round(a/s*100);je(()=>{Rp(this,pi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(nt.from(e)),this.velocity={x:0,y:0}}};Nr=Tp(so);pi=new WeakMap;Jc(Nr,2,"delta",nd,is);Jc(Nr,2,"direction",td,is);Ap(Nr,is);function oo({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(hl(r,2)+hl(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 rd=(e=>(e.Horizontal="x",e.Vertical="y",e))(rd||{}),id=Object.values(rd),Np=Object.create,Vo=Object.defineProperty,Wp=Object.defineProperties,zp=Object.getOwnPropertyDescriptor,Fp=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,sd=Object.prototype.hasOwnProperty,od=Object.prototype.propertyIsEnumerable,ad=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Fn=e=>{throw TypeError(e)},ao=(e,t,n)=>t in e?Vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zo=(e,t)=>{for(var n in t||(t={}))sd.call(t,n)&&ao(e,n,t[n]);if(Pi)for(var n of Pi(t))od.call(t,n)&&ao(e,n,t[n]);return e},Qo=(e,t)=>Wp(e,Fp(t)),pl=(e,t)=>Vo(e,"name",{value:t,configurable:!0}),ld=(e,t)=>{var n={};for(var r in e)sd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Pi)for(var r of Pi(e))t.indexOf(r)<0&&od.call(e,r)&&(n[r]=e[r]);return n},_n=e=>{var t;return[,,,Np((t=e?.[ad("metadata")])!=null?t:null)]},cd=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?Fn("Function expected"):e,_p=(e,t,n,r,i)=>({kind:cd[e],name:t,metadata:r,addInitializer:s=>n._?Fn("Already initialized"):i.push(tr(s||null))}),an=(e,t)=>ao(t,ad("metadata"),e[3]),se=(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},de=(e,t,n,r,i,s)=>{var o,a,c,u,l,d=t&7,h=!!(t&8),f=!!(t&16),m=d>3?e.length+1:d?h?1:2:0,g=cd[d+5],x=d>3&&(e[m-1]=[]),w=e[m]||(e[m]=[]),p=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&zp(d<4?i:{get[n](){return Ce(this,s)},set[n](b){return Ze(this,s,b)}},n));d?f&&d<4&&pl(s,(d>2?"set ":d>1?"get ":"")+n):pl(i,n);for(var v=r.length-1;v>=0;v--)u=_p(d,n,c={},e[3],w),d&&(u.static=h,u.private=f,l=u.access={has:f?b=>qp(i,b):b=>n in b},d^3&&(l.get=f?b=>(d^1?Ce:dd)(b,i,d^4?s:p.get):b=>b[n]),d>2&&(l.set=f?(b,k)=>Ze(b,i,k,d^4?s:p.set):(b,k)=>b[n]=k)),a=(0,r[v])(d?d<4?f?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),c._=1,d^4||a===void 0?tr(a)&&(d>4?x.unshift(a):d?f?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Fn("Object expected"):(tr(o=a.get)&&(p.get=o),tr(o=a.set)&&(p.set=o),tr(o=a.init)&&x.unshift(o));return d||an(e,i),p&&Vo(i,n,p),f?d^4?s:p:i},Jo=(e,t,n)=>t.has(e)||Fn("Cannot "+n),qp=(e,t)=>Object(t)!==t?Fn('Cannot use the "in" operator on this value'):e.has(t),Ce=(e,t,n)=>(Jo(e,t,"read from private field"),n?n.call(e):t.get(e)),he=(e,t,n)=>t.has(e)?Fn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ze=(e,t,n,r)=>(Jo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),dd=(e,t,n)=>(Jo(e,t,"access private method"),n);function ud(e,t){return{plugin:e,options:t}}function Wr(e){return t=>ud(e,t)}function kr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var fd,Sr,ea,mi;fd=[ce];var qe=class{constructor(e,t){this.manager=e,this.options=t,he(this,ea,se(Sr,8,this,!1)),se(Sr,11,this),he(this,mi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return le(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=ot(e.bind(this));return Ce(this,mi).add(t),t}destroy(){Ce(this,mi).forEach(e=>e())}static configure(e){return ud(this,e)}};Sr=_n(null);ea=new WeakMap;mi=new WeakMap;de(Sr,4,"disabled",fd,qe,ea);an(Sr,qe);var zr=class extends qe{},gi,Os=class{constructor(e){this.manager=e,this.instances=new Map,he(this,gi,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(kr).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 Ce(this,gi))if(!n.includes(r)){if(r.prototype instanceof zr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);Ze(this,gi,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()}};gi=new WeakMap;function Bp(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Qr=[],gn,vn,Hp=class extends qe{constructor(e){super(e),he(this,gn),he(this,vn),this.computeCollisions=this.computeCollisions.bind(this),Ze(this,vn,Ln(Qr)),this.destroy=Lr(()=>{const t=this.computeCollisions(),n=le(()=>this.manager.dragOperation.position.current);if(t!==Qr){const r=Ce(this,gn);if(Ze(this,gn,n),r&&n.x==r.x&&n.y==r.y)return}else Ze(this,gn,void 0);Ce(this,vn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){le(()=>{e?Ce(this,vn).value=this.computeCollisions():Ze(this,gn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Qr;const a=[],c=[];for(const u of e??n.droppables){if(u.disabled||i&&!u.accepts(i))continue;const l=t??u.collisionDetector;if(!l)continue;c.push(u),u.shape;const d=le(()=>l({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return c.length===0?Qr:(a.sort(Bp),a)}get collisions(){return Ce(this,vn).value}};gn=new WeakMap;vn=new WeakMap;var hd,pd,md,ta,gd,dt,na,Sn,ra,ia;md=[ce],pd=[ce],hd=[ce];var jt=class Gt{constructor(t,n){he(this,na,se(dt,8,this)),se(dt,11,this),he(this,Sn),he(this,ra,se(dt,12,this)),se(dt,15,this),he(this,ia,se(dt,16,this)),se(dt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let c=i;Ze(this,Sn,Ln(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var u;return[()=>{const{id:l,manager:d}=this;if(l!==c)return c=l,d?.registry.register(this),()=>d?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},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=Ce(this,Sn).value;return(n=(t=Gt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=Gt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Ce(this,Sn).peek();t!==i&&(Gt.pendingIdChanges||(Gt.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return dd(s=Gt,ta,gd).call(s)})),Gt.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)}};dt=_n(null);ta=new WeakSet;gd=function(){const e=jt.pendingIdChanges;jt.pendingIdChanges=null,e&&je(()=>{for(const[t,n]of e)Ce(t,Sn).value=n})};na=new WeakMap;Sn=new WeakMap;ra=new WeakMap;ia=new WeakMap;de(dt,4,"manager",md,jt,na);de(dt,4,"data",pd,jt,ra);de(dt,4,"disabled",hd,jt,ia);he(jt,ta);an(dt,jt);jt.pendingIdChanges=null;var ss=jt,ml=class{constructor(){this.map=Ln(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,c]of n)if(c===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=Lr(...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}},vd,bd,yd,xd,wd,kd,lo,He,sa,oa,aa,vt=class extends(lo=ss,kd=[ce],wd=[ce],xd=[ce],yd=[Oe],bd=[Oe],vd=[Oe],lo){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,c=ld(n,["modifiers","type","sensors","plugins","effects"]);super(Qo(Zo({},c),{effects:()=>{var u;return[...(u=a?.())!=null?u:[],()=>{const{manager:l,plugins:d}=this;if(!(!l||!d))for(const h of d){const{plugin:f}=kr(h);l.registry.plugins.register(f)}}]}}),t),se(He,5,this),he(this,sa,se(He,8,this)),se(He,11,this),he(this,oa,se(He,12,this)),se(He,15,this),he(this,aa,se(He,16,this,this.isDragSource?"dragging":"idle")),se(He,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=c.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=kr(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}};He=_n(lo);sa=new WeakMap;oa=new WeakMap;aa=new WeakMap;de(He,4,"type",kd,vt,sa);de(He,4,"modifiers",wd,vt,oa);de(He,4,"status",xd,vt,aa);de(He,2,"isDropping",yd,vt);de(He,2,"isDragging",bd,vt);de(He,2,"isDragSource",vd,vt);an(He,vt);var Sd,$d,jd,Cd,Od,Ed,co,Ie,la,ca,da,ua,fa,bt=class extends(co=ss,Ed=[ce],Od=[ce],Cd=[ce],jd=[ce],$d=[ce],Sd=[Oe],co){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=ld(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),se(Ie,5,this),he(this,la,se(Ie,8,this)),se(Ie,11,this),he(this,ca,se(Ie,12,this)),se(Ie,15,this),he(this,da,se(Ie,16,this)),se(Ie,19,this),he(this,ua,se(Ie,20,this)),se(Ie,23,this),he(this,fa,se(Ie,24,this)),se(Ie,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}};Ie=_n(co);la=new WeakMap;ca=new WeakMap;da=new WeakMap;ua=new WeakMap;fa=new WeakMap;de(Ie,4,"accept",Ed,bt,la);de(Ie,4,"type",Od,bt,ca);de(Ie,4,"collisionDetector",Cd,bt,da);de(Ie,4,"collisionPriority",jd,bt,ua);de(Ie,4,"shape",$d,bt,fa);de(Ie,2,"isDropTarget",Sd,bt);an(Ie,bt);var Up=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)}},Gp=class extends Up{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function vi(e,t=!0){let n=!1;return Qo(Zo({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Kp=class extends zr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=Lr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||ss.pendingIdChanges)return;const o=vi({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;le(()=>{var c;a?.id!==((c=e.dragOperation.target)==null?void 0:c.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},qn=(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))(qn||{}),Bn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Bn||{}),Td,Md,Ad,Dd,Id,Pd,Rd,st,ha;Rd=[ce],Pd=[Oe],Id=[Oe],Dd=[Oe],Ad=[Oe],Md=[Oe],Td=[Oe];var Ot=class{constructor(){se(st,5,this),he(this,ha,se(st,8,this,"idle")),se(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=_n(null);ha=new WeakMap;de(st,4,"value",Rd,Ot,ha);de(st,2,"current",Pd,Ot);de(st,2,"idle",Id,Ot);de(st,2,"initializing",Dd,Ot);de(st,2,"initialized",Ad,Ot);de(st,2,"dragging",Md,Ot);de(st,2,"dropped",Td,Ot);an(st,Ot);var Yp=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 le(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=vi({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return le(()=>{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;je(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=vi({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"&&je(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return le(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=vi({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,c,u,l,d;if(o.defaultPrevented)return;const h=(d=e.to)!=null?d:{x:r.position.current.x+((c=(a=e.by)==null?void 0:a.x)!=null?c:0),y:r.position.current.y+((l=(u=e.by)==null?void 0:u.y)!=null?l:0)};r.position.current=h})})}stop(e={}){return le(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const c={resume:()=>{},abort:()=>{}};return s=new Promise((u,l)=>{c.resume=u,c.abort=l}),c};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const c=le(()=>{var l;return((l=r.source)==null?void 0:l.status)==="dropping"}),u=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(c){const{source:l}=r,d=ot(()=>{l?.status==="idle"&&(d(),u())})}else this.manager.renderer.rendering.then(u)})};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()})}},Mn=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Xp=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)}},bi,Ld=class{constructor(e){this.options=e,he(this,bi)}set controller(e){Ze(this,bi,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ce(this,bi))==null||t.activate(e)}};bi=new WeakMap;var gl=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Vp=class{constructor(e){this.draggables=new ml,this.droppables=new ml,this.plugins=new Os(e),this.sensors=new Os(e),this.modifiers=new Os(e)}register(e,t){if(e instanceof vt)return this.draggables.register(e.id,e);if(e instanceof bt)return this.droppables.register(e.id,e);if(e.prototype instanceof gl)return this.modifiers.register(e,t);if(e.prototype instanceof Mn)return this.sensors.register(e,t);if(e.prototype instanceof qe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof ss)return e instanceof vt?this.draggables.unregister(e.id,e):e instanceof bt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof gl)return this.modifiers.unregister(e);if(e.prototype instanceof Mn)return this.sensors.unregister(e);if(e.prototype instanceof qe)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()}},Nd,Wd,zd,Fd,_d,qd,Bd,Hd,Ud,nr,yi,bn,$e,pa,ma,ga,va,ba,rr;Ud=[Oe],Hd=[ce],Bd=[ce],qd=[ce],_d=[ce],Fd=[ce],zd=[Oe],Wd=[Oe],Nd=[Oe];var ht=class{constructor(e){se($e,5,this),he(this,nr),he(this,yi),he(this,bn,new on(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Ot,he(this,pa,se($e,8,this,!1)),se($e,11,this),he(this,ma,se($e,12,this,null)),se($e,15,this),he(this,ga,se($e,16,this,null)),se($e,19,this),he(this,va,se($e,20,this,null)),se($e,23,this),he(this,ba,se($e,24,this,[])),se($e,27,this),this.position=new is({x:0,y:0}),he(this,rr,{x:0,y:0}),Ze(this,nr,e)}get shape(){const{current:e,initial:t,previous:n}=Ce(this,bn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ce(this,bn).current=e:Ce(this,bn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ce(this,nr).registry.draggables.get(t);return n&&Ze(this,yi,n),(e=n??Ce(this,yi))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ce(this,nr).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(Qo(Zo({},this.snapshot()),{transform:n}));return Ze(this,rr,n),n}snapshot(){return le(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ce(this,rr),shape:this.shape?Cs(this.shape):null,position:Cs(this.position),status:Cs(this.status),canceled:this.canceled}))}reset(){je(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ce(this,bn).reset(),this.position.reset({x:0,y:0}),Ze(this,rr,{x:0,y:0}),this.modifiers=[]})}};$e=_n(null);nr=new WeakMap;yi=new WeakMap;bn=new WeakMap;pa=new WeakMap;ma=new WeakMap;ga=new WeakMap;va=new WeakMap;ba=new WeakMap;rr=new WeakMap;de($e,2,"shape",Ud,ht);de($e,4,"canceled",Hd,ht,pa);de($e,4,"activatorEvent",Bd,ht,ma);de($e,4,"sourceIdentifier",qd,ht,ga);de($e,4,"targetIdentifier",_d,ht,va);de($e,4,"modifiers",Fd,ht,ba);de($e,2,"source",zd,ht);de($e,2,"target",Wd,ht);de($e,2,"transform",Nd,ht);an($e,ht);var Zp={get rendering(){return Promise.resolve()}};function ft(e,t){return typeof e=="function"?e(t):e??t}var Qp=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(d=>d.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=ft(n.plugins,[]),i=ft(n.sensors,[]),s=ft(n.modifiers,[]),o=(t=n.renderer)!=null?t:Zp,a=new Gp(this),c=new Vp(this);this.registry=c,this.monitor=a,this.renderer=o,this.actions=new Yp(this),this.dragOperation=new ht(this),this.collisionObserver=new Hp(this),this.plugins=[Kp,...r],this.modifiers=s,this.sensors=i;const{destroy:u}=this,l=Lr(()=>{var d,h,f;const m=le(()=>this.dragOperation.modifiers),g=this.modifiers;for(const x of m)g.includes(x)||x.destroy();this.dragOperation.modifiers=(f=(h=(d=this.dragOperation.source)==null?void 0:d.modifiers)==null?void 0:h.map(x=>{const{plugin:w,options:p}=kr(x);return new w(this,p)}))!=null?f:g});this.destroy=()=>{l(),u()}}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}},Gd=e=>{throw TypeError(e)},ya=(e,t,n)=>t.has(e)||Gd("Cannot "+n),ie=(e,t,n)=>(ya(e,t,"read from private field"),t.get(e)),Ke=(e,t,n)=>t.has(e)?Gd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ve=(e,t,n,r)=>(ya(e,t,"write to private field"),t.set(e,n),n),Kd=(e,t,n)=>(ya(e,t,"access private method"),n);function os(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Yd(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(os(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function as(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 xa(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Fr(e){return"nodeType"in e}function Je(e){var t,n,r;return e?xa(e)?e:Fr(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 wa(e){const{Document:t}=Je(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function zt(e){return!e||xa(e)?!1:e instanceof Je(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Xd(e){return e instanceof Je(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Hn(e){return e?xa(e)?e.document:Fr(e)?wa(e)?e:zt(e)||Xd(e)?e.ownerDocument:document:document:document}function Jp(e){var t,n,r,i;const{documentElement:s}=Hn(e),o=Je(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,c=(n=o?.height)!=null?n:s.clientHeight,u=(r=o?.offsetTop)!=null?r:0,l=(i=o?.offsetLeft)!=null?i:0;return{top:u,left:l,right:l+a,bottom:u+c,width:a,height:c}}function em(e,t){if(tm(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function tm(e){return e.tagName==="DETAILS"}function $r(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let c=t;const{ownerDocument:u}=e,l=(r=u.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==u.documentElement;){if(!em(d)){const v=d.getBoundingClientRect(),b=n*(v.bottom-v.top),k=n*(v.right-v.left),D=n*(v.bottom-v.top),M=n*(v.right-v.left);c={top:Math.max(c.top,v.top-b),right:Math.min(c.right,v.right+k),bottom:Math.min(c.bottom,v.bottom+D),left:Math.max(c.left,v.left-M),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top}d=d.parentElement}const h=l.visualViewport,f=(i=h?.offsetTop)!=null?i:0,m=(s=h?.offsetLeft)!=null?s:0,g=(o=h?.width)!=null?o:l.innerWidth,x=(a=h?.height)!=null?a:l.innerHeight,w=n*x,p=n*g;return c={top:Math.max(c.top,f-w),right:Math.min(c.right,m+g+p),bottom:Math.min(c.bottom,f+x+w),left:Math.max(c.left,m-p),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top,c.width<0&&(c.width=0),c.height<0&&(c.height=0),c}function An(e){return{x:e.clientX,y:e.clientY}}var Vd=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 ka(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Zd(){var e,t;const n=ka()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Sa(e){return!e||!Fr(e)?!1:e instanceof Je(e).ShadowRoot}function Ri(e){if(e&&Fr(e)){let t=e.getRootNode();if(Sa(t)||t instanceof Document)return t}return Hn(e)}function $a(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function nm(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];vl(i)&&vl(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),bl(i)&&bl(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function vl(e){return"value"in e}function bl(e){return e.tagName==="CANVAS"}function Qd(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(rm(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Qd(i,{x:t-s,y:n-o})}}return r}function rm(e){return e?.tagName==="IFRAME"}var fo=new WeakMap;function im(e){return e.closest(`
1
+ import{r as S,aX as Uf,aY as Gf,j as y,ap as xe,ay as lt,T as ue,aD as Ee,aZ as Pr,a_ as Kf,N as vc,aw as Yf,a$ as wt,b0 as Xf,b1 as fi,b2 as Vf,b3 as Zf,b4 as Qf,_ as bc,b5 as Jf,b6 as eh,b7 as jn,R as Qe,F as Ae,b8 as th,b9 as Ji,ba as nh,K as en,G as Us,bb as Lt,bc as ut,bd as rh,be as yc,aC as es,a8 as ih,bf as sh,bg as xc,bh as wc,bi as kc,bj as oh,bk as ah,bl as lh,a5 as ch,bm as dh,bn as uh,bo as fh,bp as Sc,bq as hh,br as ph,bs as mh,bt as gh,aQ as $c,bu as vh,bv as jc,bw as ts,bx as Cc,by as Oc,bz as bh,bA as yh,bB as xh,bC as wh,ar as et,bD as Ec,bE as nl,H as Ei,I as kh,bF as Sh,bG as Rr,av as Nt,bH as Gs,bI as Tc,bJ as Mc,as as $h,W as Fo,bK as _o,bL as jh,bM as Ch,bN as qo,bO as Oh,aI as Eh,bP as Th,bQ as Mh,bR as Ah,bS as Bt,bT as rl,S as Dh,bU as Ih,L as Ph,U as Rh,bV as Bo,bW as Lh,bX as Nh,bY as Ac,bZ as Wh,aF as zh}from"./index-hnA8HjeH.js";import{b_ as lx,b$ as cx,c0 as dx,c1 as ux,c2 as fx,c3 as hx,c4 as px,c5 as mx,c6 as gx,c7 as vx,c8 as bx}from"./index-hnA8HjeH.js";import{T as Dc,a as Ti}from"./ToggleButtonGroup-Bwj7gIJm.js";var il={};const Fh={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function _h(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this view's details":n==="unlisted"?"Not a view the catalog lists, so its shape is unknown":void 0,i=s=>{if(t!==s){if(s==="big_value")return e?.aggregateOnly===!0?void 0:r??"Needs a view with only totals (no group by)";if(s==="shape_map"||s==="segment_map")return e?.chart===s?void 0:r??"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(s=>{const o=i(s);return{value:s,label:Fh[s],...o?{disabled:!0,reason:o}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Ks({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:i,onOpen:s,onChange:o,variant:a="standard"}){const c=_h(t,e,n),u=S.useId();return y.jsx(et,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:i!==void 0,onChange:l=>{const d=l.target.value;c.find(h=>h.value===d)?.disabled||o(d)},helperText:i,FormHelperTextProps:{id:u},SelectProps:{...s?{onOpen:s}:{},renderValue:l=>c.find(d=>d.value===l)?.label??String(l),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...i?{"aria-describedby":u}:{}}},sx:{minWidth:140},children:c.map(l=>y.jsx(Nt,{value:l.value,disabled:l.value==="custom"||l.disabled===!0,children:y.jsx(Fo,{primary:l.label,...l.reason?{secondary:l.reason}:{}})},l.value))})}function qh({sources:e,source:t,view:n,onSource:r,onView:i}){const{theme:s}=Qe(),o=e.find(a=>a.name===t);return y.jsxs(y.Fragment,{children:[y.jsx(et,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>y.jsxs(Nt,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),y.jsxs(Ae,{children:[y.jsx(ue,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(Ph,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:"min(280px, 30vh)",overflowY:"auto",border:s.border,borderRadius:1},children:[(o?.views??[]).map(a=>y.jsxs(Rh,{selected:n===a.name,onClick:()=>i(a.name),"aria-label":`View ${a.name}`,children:[y.jsx(Fo,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&y.jsx(Us,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&y.jsx(ue,{variant:"body2",sx:{p:1.5,color:s.tileTitle},children:"This source declares no views."})]})]})]})}function Bh({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o}){const{theme:a}=Qe(),c=S.useMemo(()=>n?.sources??[],[n]),[u,l]=S.useState("query"),[d,h]=S.useState(""),[f,m]=S.useState(""),[g,x]=S.useState(""),[w,p]=S.useState("default"),[v,b]=S.useState(Math.ceil(r/2));S.useEffect(()=>{if(!e)return;l("query");const $=O=>c.some(z=>z.name===O&&z.views.length>0);h(t.sources.map(O=>O.base).find($)??c.find(O=>O.views.length>0)?.name??""),m(""),x(""),p("default"),b(Math.ceil(r/2))},[e,t,c,r]);const k=d!==""&&f!=="",D=[d,f].filter($=>$!==""&&!_o($)).map($=>`"${$}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],M=c.find($=>$.name===d),A=M?.views.find($=>$.name===f);return y.jsx(es,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of a source in this package.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:i,children:"Cancel"}),y.jsx(Ee,{variant:"contained",disabled:u==="query"&&(!k||D!==void 0),onClick:()=>u==="text"?o():s({base:d,modelPath:M?.modelPath??"",...M?.exporters?{exporters:M.exporters}:{},view:f,...g.trim()?{label:g.trim()}:{},...w!=="default"?{chart:w,...A?{chartCarried:A.chart?[A.chart]:[]}:{}}:{},colspan:v}),children:u==="text"?"Add text":"Add tile"})]}),children:y.jsxs(xe,{sx:{gap:2,pt:1},children:[y.jsxs(Dc,{size:"small",exclusive:!0,value:u,"aria-label":"Tile type",onChange:($,O)=>{O!==null&&l(O)},children:[y.jsx(Ti,{value:"query",sx:{px:1.5},children:"Query"}),y.jsx(Ti,{value:"text",sx:{px:1.5},children:"Text"})]}),u==="text"?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:"A text tile holds markdown: a heading, a paragraph, a list. It is added empty, and written on the tile itself."}):c.length===0?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}):y.jsxs(y.Fragment,{children:[y.jsx(qh,{sources:c,source:d,view:f,onSource:$=>{h($),m("")},onView:$=>{m($),p("default")}}),D&&y.jsx(ue,{variant:"body2",color:"error",children:D}),y.jsx(Ks,{state:w,view:A,cellLabel:"new tile",variant:"outlined",...A?{}:{disabledReason:"Pick a view to choose its chart."},onChange:$=>p($)}),y.jsx(xe,{direction:"row",sx:{gap:1.5},children:y.jsx(et,{size:"small",label:"Title",placeholder:"Uses the view's name",value:g,onChange:$=>x($.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}})})]})]})})}const Re=e=>e.kind==="text",be=e=>e.kind!=="text",Vr=e=>be(e)?e.label??e.name:e.name,ze=e=>Re(e)?`text.${e.name}`:`${e.source}.${e.name}`,ws="self";function Hh({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Qe(),[c,u]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const f=(t.drills??[]).filter(m=>m.source===n.name);u((n.dimensions??[]).map(m=>{const g=f.find(x=>x.name===m.name);return{name:m.name,expression:m.expression,to:g?.to??[],given:g?.given??""}}))},[e,n,t]);const l=(f,m)=>u(g=>g.map((x,w)=>{if(w!==f)return x;const p={...x};return m(p),p})),d=[ws,...i.filter(f=>f!==ws)],h=f=>f===ws?"This dashboard":f;return y.jsx(es,{open:e,onClose:s,title:"Drill",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:s,children:"Cancel"}),y.jsx(Ee,{variant:"contained",onClick:()=>{n&&(o(c.filter(f=>f.to.length>0).map(f=>({source:n.name,name:f.name,expression:f.expression,to:f.to,...f.given?{given:f.given}:{}}))),s())},disabled:c.length===0,children:"Apply"})]}),children:y.jsx(xe,{sx:{gap:2,pt:1},children:c.length===0?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(Ae,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",y.jsx(Ae,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):c.map((f,m)=>y.jsxs(Ae,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(Ae,{sx:{minWidth:0,pt:.75},children:[y.jsx(ue,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:f.name}),y.jsxs(ue,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:f.expression,children:["is ",f.expression]})]}),y.jsx(et,{select:!0,size:"small",label:"Clicks go to",value:f.to,inputProps:{"aria-label":`Where ${f.name} goes`},SelectProps:{multiple:!0,renderValue:g=>g.length===0?"Not clickable":g.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:g=>l(m,x=>{const w=g.target.value;x.to=Array.isArray(w)?w:String(w).split(",").filter(Boolean)}),children:d.map(g=>y.jsxs(Nt,{value:g,children:[y.jsx(Gs,{size:"small",checked:f.to.includes(g),sx:{p:0,mr:1}}),y.jsx(Fo,{primary:h(g)})]},g))}),y.jsxs(et,{select:!0,size:"small",label:"Sets the filter",value:f.given,disabled:f.to.length===0,inputProps:{"aria-label":`Control ${f.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:f.given===""?`Named ${f.name}, like the dimension`:void 0,onChange:g=>l(m,x=>{x.given=g.target.value}),children:[y.jsx(Nt,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(g=>y.jsx(Nt,{value:g,children:g},g))]})]},f.name))})})}function Uh(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of be(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 Mi(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Gh(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function hi(e,t){const n=Gh(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 sl(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 Kh(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Yh=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Xh(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=Ac(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 ol=[{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 Zr(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 Ys=e=>be(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function Vh(e,t){return e.tiles.map(n=>{const r=(be(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}:Mi(t.type)!==void 0?{op:Mi(t.type)}:{}}})}function Zh(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Ys(s))return;const o=(s.filters??[]).filter(c=>c.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function Qh(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function Jh(e,t){for(const r of e.tiles){if(!be(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 Ic=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function ep({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,c=a!==void 0,[u,l]=S.useState({kind:"new"}),[d,h]=S.useState(""),[f,m]=S.useState("select"),[g,x]=S.useState(""),[w,p]=S.useState(""),[v,b]=S.useState([]),[k,D]=S.useState(!1),[M,A]=S.useState(!1),$=P=>t.sources.find(H=>H.name===P.source)?.base??P.source;S.useEffect(()=>{if(e)if(A(n!==void 0),n){l({kind:"existing",name:n.name}),h(n.label??"");const P=Vh(t,n);b(P);const H=P.filter(me=>me.include),oe=new Set(H.map(me=>me.field));p(oe.size===1?H[0].field:n.field??""),D(oe.size>1)}else l({kind:"new"}),h(""),m("select"),p(""),x(new Date().toISOString().slice(0,10)),b(t.tiles.map(P=>({include:Ys(P),field:""}))),D(!1)},[e,n,t]);const O=S.useMemo(()=>[...(t.localGivens??[]).map(P=>P.name),...r.map(P=>P.name)],[t,r]),z=S.useMemo(()=>w.trim()?Xh(w.trim(),O):"",[w,O]),I=u.kind==="existing"?n??r.find(P=>P.name===u.name):z?{name:z,type:Zr({name:z,label:d,kind:f,field:w}).type}:void 0,W=I?.type!==void 0&&!I.type.startsWith("filter<"),G=v.find(P=>P.include)?.op??Mi(I?.type),q=(P,H)=>{A(!0),b(oe=>oe.map((me,Fe)=>Fe===P?{...me,...H}:me))},U=P=>{A(!0),b(H=>H.map(oe=>({...oe,op:P})))},K=P=>{const H=Mi(P);b(oe=>oe.map(({op:me,...Fe})=>H?{...Fe,op:H}:Fe))},V=P=>{A(!0),l({kind:"existing",name:P.name}),p(P.field??""),K(P.type)},re=P=>{A(!0),m(P),K(Zr({name:"X",label:d,kind:P,field:w}).type)},T=t.tiles.map(Ys),_=T.filter(Boolean).length,R=v.filter((P,H)=>P.include&&T[H]).length,N=t.tiles.filter((P,H)=>(v[H]?.include??!1)&&T[H]&&be(P)),F=N.length>0?N:t.tiles.filter((P,H)=>T[H]&&be(P)),ee=S.useMemo(()=>{const P=new Map;let H=!1;for(const oe of F){const me=i?.(oe);if(me){H=!0;for(const Fe of me)P.has(Fe.name)||P.set(Fe.name,Fe)}}return H?[...P.values()]:void 0},[v,t.tiles,i]),J=(()=>{const P=w.trim();for(const H of N){const oe=i?.(H);if(!oe||oe.some(me=>me.name===P))return $(H)}return N[0]?$(N[0]):t.sources[0]?.base})(),C=P=>{A(!0),b(H=>H.map((oe,me)=>({...oe,include:P&&T[me]})))},j=S.useMemo(()=>k?v:v.map(P=>({...P,field:w})),[k,v,w]),E=P=>{for(const H of F){const oe=i?.(H)?.find(me=>me.name===P.trim());if(oe?.type)return oe.type}},Z=P=>hi(I?.type,P.type),B=(P,H)=>{if(P.trim()==="")return"Pick the field this filter compares.";const oe=H?i?.(H):void 0;if(!oe)return;const me=oe.find(Fe=>Fe.name===P.trim());if(!me)return`Not a field of ${H?$(H):"the tiles' source"}.`;if(me.type&&!hi(I?.type,me.type))return`${P.trim()} is ${sl(me.type)}; this filter compares ${sl(I?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},te=P=>{if(A(!0),p(P),c||u.kind!=="new")return;const H=E(P),oe=Zr({name:"X",label:d,kind:f,field:P}).type;H&&!hi(oe,H)&&re(Kh(H))},X=P=>{const H=t.tiles[P];return H&&be(H)?H:void 0},ne=j.map((P,H)=>P.include&&T[H]?B(P.field,X(H)):void 0),Q=ne.every(P=>P===void 0),pe=M?ne:ne.map(()=>{}),L=M&&!k&&R>0?N.map(P=>B(w,P)).find(Boolean):void 0,ae=I!==void 0&&Q&&(u.kind==="existing"||w.trim()!==""&&z!==""),fe=()=>{if(!(!I||!ae))if(u.kind==="new")s(I.name,j,Zr({name:I.name,label:d.trim()||Ic(I.name),kind:f,field:w.trim(),...J?{source:J}:{},...g?{dateDefault:g}:{}}));else if(n?.origin==="dashboard"&&n.local){const P=d.trim(),H=P!==(n.local.label??"");s(I.name,j,H?{...n.local,...P?{label:P}:{}}:void 0)}else s(I.name,j)},Y=c&&a.origin==="model";return{editing:c,shown:a,fromModel:Y,source:u,setSource:l,label:d,setLabel:h,kind:f,dateDefault:g,setDateDefault:x,field:w,rows:v,setRows:b,perTile:k,setPerTile:D,newName:z,target:I,valueTyped:W,commonOp:G,setRow:q,setCommonOp:U,pickExisting:V,pickKind:re,bindable:T,bindableCount:_,included:R,commonFields:ee,setAll:C,accepts:Z,pickField:te,rowProblems:pe,commonProblem:L,canApply:ae,apply:fe}}function al({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:c,autoFocus:u,placeholder:l,sx:d}){const h=S.useMemo(()=>(n??[]).filter(m=>r?.(m)??!0).map(m=>m.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(m=>[m.name,m.type])),[n]);return y.jsx(Ih,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(m,g)=>t(g),value:e,onChange:(m,g)=>t(typeof g=="string"?g:""),disabled:c,disableClearable:!0,renderOption:(m,g)=>S.createElement("li",{...m,key:g},y.jsx(ue,{variant:"body2",sx:{flex:1},children:g}),f.get(g)&&y.jsx(ue,{variant:"caption",sx:{opacity:.6},children:f.get(g)?.replace(/_type$/,"")})),renderInput:m=>y.jsx(et,{...m,label:i,placeholder:l,autoFocus:u,error:o,helperText:a,inputProps:{...m.inputProps,"aria-label":s}}),sx:d})}const ll=e=>e&&be(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this dashboard does not write."};function tp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:c}=Qe(),{editing:u,shown:l,fromModel:d,source:h,setSource:f,label:m,setLabel:g,kind:x,dateDefault:w,setDateDefault:p,field:v,rows:b,setRows:k,perTile:D,setPerTile:M,newName:A,target:$,valueTyped:O,commonOp:z,setRow:I,setCommonOp:W,pickExisting:G,pickKind:q,bindable:U,bindableCount:K,included:V,commonFields:re,setAll:T,accepts:_,pickField:R,rowProblems:N,commonProblem:F,canApply:ee,apply:J}=ep({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),C=(j,E,Z)=>y.jsx(et,{select:!0,size:"small",label:"Compares",value:j??">=",onChange:B=>E(B.target.value),inputProps:{"aria-label":Z},sx:{width:130},children:Yh.filter(B=>B.op!=="~").map(B=>y.jsx(Nt,{value:B.op,children:B.label},B.op))});return y.jsx(es,{open:e,onClose:s,title:u?l.label??l.name:"Add a filter",description:u?y.jsxs(y.Fragment,{children:[y.jsxs(Ae,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",l.name]}),d?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A filter on the page, and the tiles it filters.",actions:y.jsxs(y.Fragment,{children:[u&&y.jsx(Ee,{color:"error",startIcon:y.jsx(Mc,{}),onClick:()=>a(l.name),sx:j=>({mr:"auto",color:Tc(j)}),children:"Remove filter"}),y.jsx(Ee,{onClick:s,children:"Cancel"}),y.jsx(en,{title:ee||$===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(Ee,{variant:"contained",onClick:J,disabled:!ee,children:u?"Apply":"Add filter"})})})]}),children:y.jsxs(xe,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&y.jsxs(Dc,{exclusive:!0,size:"small",value:h.kind,onChange:(j,E)=>{E==="new"?f({kind:"new"}):E==="existing"&&r[0]&&G(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(Ti,{value:"new",children:"New in this dashboard"}),y.jsx(Ti,{value:"existing",children:"From the model"})]}),!u&&h.kind==="existing"?y.jsx(et,{select:!0,size:"small",label:"Filter",value:h.name,onChange:j=>{const E=r.find(Z=>Z.name===j.target.value);E&&G(E)},children:r.map(j=>y.jsxs(Nt,{value:j.name,children:[j.label??j.name,y.jsxs(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",j.name]})]},j.name))}):null,y.jsxs(xe,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!D&&y.jsx(al,{value:v,onChange:R,fields:re,accepts:_,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:F!==void 0,helperText:F??(!u&&A?`Declared as $${A}`:void 0),sx:{flex:1,minWidth:200}}),!d&&y.jsx(et,{size:"small",label:"Label",placeholder:A?Ic(A):"",value:m,onChange:j=>g(j.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),O&&!D&&C(z,W,"Comparison")]}),!u&&h.kind==="new"&&y.jsxs(xe,{direction:"row",sx:{gap:1.5},children:[y.jsx(et,{select:!0,size:"small",label:"Filter kind",value:x,onChange:j=>q(j.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:j=>ol.find(E=>E.kind===j)?.label??String(j)}},sx:{flex:1},children:ol.map(j=>y.jsxs(Nt,{value:j.kind,children:[j.label,y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:j.hint})]},j.kind))}),x==="date"&&y.jsx(et,{size:"small",type:"date",label:"Starts at",value:w,onChange:j=>p(j.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(Ae,{children:[y.jsxs(xe,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(Gs,{size:"small",checked:K>0&&V===K,indeterminate:V>0&&V<K,disabled:K===0,onChange:j=>T(j.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(ue,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",V," of ",t.tiles.length," tiles"]}),y.jsx(Ee,{size:"small",onClick:()=>{D||k(j=>j.map(E=>({...E,field:v}))),M(j=>!j)},children:D?"Same field for all":"Adjust per tile"})]}),y.jsx(xe,{sx:{gap:D?1:0},children:t.tiles.map((j,E)=>{if(!be(j))return null;const Z=b[E],B=j.label??j.name,te=D?N[E]:void 0;return y.jsxs(xe,{direction:"row",sx:{gap:1,alignItems:D?"flex-start":"center",opacity:U[E]?1:.6},children:[y.jsx(Gs,{size:"small",disabled:!U[E],checked:(Z?.include??!1)&&U[E],inputProps:{"aria-label":`Filter ${B}`},onChange:X=>I(E,{include:X.target.checked})}),y.jsx(ue,{variant:"body2",sx:{flex:1,minWidth:0,pt:D?1:0},noWrap:!0,children:B}),U[E]?D&&y.jsxs(y.Fragment,{children:[O&&C(Z?.op,X=>I(E,{op:X}),`Comparison for ${B}`),y.jsx(al,{value:Z?.field??"",onChange:X=>I(E,{field:X}),fields:i?.(j),accepts:_,label:"Field",ariaLabel:`Field for ${B}`,disabled:!Z?.include,error:te!==void 0,helperText:te,sx:{width:220}})]}):y.jsx(en,{title:ll(t.tiles[E]).reason,children:y.jsx(ue,{variant:"caption",sx:{color:c.tileTitle},children:ll(t.tiles[E]).label})})]},`${j.source}.${j.name}`)})}),V===0&&y.jsx(ue,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}const np=Rr(y.jsx("path",{d:"M11.71 17.99C8.53 17.84 6 15.22 6 12c0-3.31 2.69-6 6-6 3.22 0 5.84 2.53 5.99 5.71l-2.1-.63C15.48 9.31 13.89 8 12 8c-2.21 0-4 1.79-4 4 0 1.89 1.31 3.48 3.08 3.89zM22 12c0 .3-.01.6-.04.9l-1.97-.59c.01-.1.01-.21.01-.31 0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8c.1 0 .21 0 .31-.01l.59 1.97c-.3.03-.6.04-.9.04-5.52 0-10-4.48-10-10S6.48 2 12 2s10 4.48 10 10m-3.77 4.26L22 15l-10-3 3 10 1.26-3.77 4.27 4.27 1.98-1.98z"}));function Pc(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const c=structuredClone(a);return o(c),c}),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 rp=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.`,ip="This tile's view is declared on its source, so its chart is set in the model.";function sp({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,removeBlocked:s,onDrills:o,view:a}){const c=S.useId(),{theme:u}=Qe(),{draft:l,apply:d,close:h,discard:f}=Pc(t,e!==null,r,n),m=l!==void 0&&be(l)?l:void 0,g=m!==void 0&&m.declaration.kind!=="inherited",x=v=>d(b=>{be(b)&&v(b)}),w=S.useRef(void 0),p=e!==null;return S.useEffect(()=>{p&&(w.current=t&&be(t)?t.chart:void 0)},[p]),y.jsx($h,{open:e!==null&&l!==void 0,anchorEl:e,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:l&&y.jsxs(xe,{sx:{gap:1.5},children:[y.jsx(ue,{variant:"overline",sx:{color:u.tileTitle,lineHeight:1.5},children:m?`${m.source} → ${m.name}`:`Text · ${l.name}`}),m&&g&&y.jsx(y.Fragment,{children:y.jsx(Ks,{state:m.chart??"default",view:a,cellLabel:`${m.source} ${m.name}`,...m.chart==="custom"?{disabledReason:rp(m.chartLines)}:{},onChange:v=>x(b=>{const k=w.current;v===(k??"default")?(k===void 0?delete b.chart:b.chart=k,delete b.chartCarried):(b.chart=v,a?b.chartCarried=a.chart?[a.chart]:[]:delete b.chartCarried)})})}),m&&!g&&y.jsxs(y.Fragment,{children:[y.jsx(ue,{variant:"body2",sx:{color:u.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),y.jsx(Ks,{state:"default",view:a,cellLabel:`${m.source} ${m.name}`,disabledReason:ip,onChange:()=>{}})]}),m?.declaration.kind==="opaque"&&y.jsxs(ue,{variant:"body2",sx:{color:u.tileTitle},children:["Its body is ",m.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),y.jsxs(xe,{direction:"row",sx:{justifyContent:"space-between"},children:[g?y.jsx(Ee,{size:"small",startIcon:y.jsx(np,{}),"aria-haspopup":"dialog",onClick:()=>{h(),o()},children:"Drill"}):y.jsx("span",{}),y.jsx(Ee,{color:"error",size:"small",startIcon:y.jsx(Mc,{}),"aria-disabled":s!==void 0||void 0,"aria-describedby":s!==void 0?c:void 0,disableRipple:s!==void 0,sx:v=>({color:Tc(v),...s!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{s===void 0&&(f(),i())},children:"Delete"})]}),s!==void 0&&y.jsx(ue,{id:c,variant:"caption",sx:{color:u.tileTitle},children:s})]})})}function op({editor:e,catalog:t,columns:n,dashboards:r,bindings:i,tiles:s,drillSource:o,setDrillSource:a,confirmConversion:c,exitDialog:u}){const{filterDialog:l,setFilterDialog:d}=i,{menu:h,setMenu:f}=s,m=h===void 0?void 0:e.document.tiles[h.index],g=m&&be(m)?m:void 0,x=(()=>{if(!g||!t)return;const w=e.document.sources.find(v=>v.name===g.source)?.base??g.source,p=g.declaration.kind==="reference"?g.declaration.from:g.name;return t.sources.find(v=>v.name===w)?.views.find(v=>v.name===p)})();return y.jsxs(y.Fragment,{children:[y.jsx(tp,{open:l!==void 0,document:e.document,...l?.control?{control:l.control}:{},available:i.available,...t?{fieldsFor:i.fieldsFor}:{},onClose:()=>d(void 0),onApply:i.applyFilter,onRemove:i.dropControl}),y.jsx(sp,{anchor:h?.anchor??null,tile:h===void 0?void 0:e.document.tiles[h.index],onClose:()=>f(void 0),onCommit:w=>{const p=h?.index;p!==void 0&&e.update(v=>{v.tiles[p]=w})},onRemove:()=>{h!==void 0&&s.removeTile(h.index)},...e.document.tiles.length===1&&e.saved.tiles.length>0?{removeBlocked:"A saved dashboard needs at least one tile."}:{},view:x,onDrills:()=>{a(g?.source)}}),y.jsx(Hh,{open:o!==void 0,document:e.document,source:e.document.sources.find(w=>w.name===o),givenNames:i.controlList.map(w=>w.name),dashboards:r??[],onClose:()=>a(void 0),onApply:w=>e.update(p=>{const v=[...(p.drills??[]).filter(b=>b.source!==o),...w];v.length===0?delete p.drills:p.drills=v})}),y.jsx(es,{open:c!==void 0,onClose:()=>c?.stop(),title:"Convert this notebook?",description:"Saving rewrites this notebook in the tile layout. The builder cannot take that back; the file's history in your repository can.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:()=>c?.stop(),children:"Cancel"}),y.jsx(Ee,{variant:"contained",onClick:()=>c?.go(),children:"Convert and save"})]}),children:null}),y.jsx(ih,{...u}),y.jsx(Bh,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText})]})}var ap=Symbol.for("preact-signals");function ns(){if(St>1)St--;else{var e,t=!1;for((function(){var i=Di;for(Di=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}})();gr!==void 0;){var n=gr;for(gr=void 0,Ai++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Lc(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(Ai=0,St--,t)throw e}}function je(e){if(St>0)return e();Xs=++lp,St++;try{return e()}finally{ns()}}var mr,ye=void 0;function le(e){var t=ye,n=mr;ye=void 0,mr=void 0;try{return e()}finally{ye=t,mr=n}}var gr=void 0,St=0,Ai=0,lp=0,Xs=0,Di=void 0,Ii=0;function Rc(e){if(ye!==void 0){var t=e.n;if(t===void 0||t.t!==ye)return t={i:0,S:e,p:ye.s,n:void 0,t:ye,e:void 0,x:void 0,r:t},ye.s!==void 0&&(ye.s.n=t),ye.s=t,e.n=t,32&ye.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=ye.s,t.n=void 0,ye.s.n=t,ye.s=t),t}}function Ge(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}Ge.prototype.brand=ap;Ge.prototype.h=function(){return!0};Ge.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:le(function(){var r;(r=t.W)==null||r.call(t)}))};Ge.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&&le(function(){var i;(i=t.Z)==null||i.call(t)}))}};Ge.prototype.subscribe=function(e){var t=this;return ot(function(){var n=t.value;le(function(){return e(n)})},{name:"sub"})};Ge.prototype.valueOf=function(){return this.value};Ge.prototype.toString=function(){return this.value+""};Ge.prototype.toJSON=function(){return this.value};Ge.prototype.peek=function(){var e=this;return le(function(){return e.value})};Object.defineProperty(Ge.prototype,"value",{get:function(){var e=Rc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ai>100)throw new Error("Cycle detected");(function(n){St!==0&&Ai===0&&n.l!==Xs&&(n.l=Xs,Di={S:n,v:n.v,i:n.i,o:Di})})(this),this.v=e,this.i++,Ii++,St++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ns()}}}});function Ln(e,t){return new Ge(e,t)}function Lc(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 Nc(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 Wc(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 sn(e,t){Ge.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Ii-1,this.f=4}sn.prototype=new Ge;sn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ii))return!0;if(this.g=Ii,this.f|=1,this.i>0&&!Lc(this))return this.f&=-2,!0;var e=ye;try{Nc(this),ye=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 ye=e,Wc(this),this.f&=-2,!0};sn.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)}Ge.prototype.S.call(this,e)};sn.prototype.U=function(e){if(this.t!==void 0&&(Ge.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)}};sn.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(sn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Rc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function cl(e,t){return new sn(e,t)}function zc(e){var t=e.m;if(e.m=void 0,typeof t=="function"){St++;var n=ye;ye=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ho(e),r}finally{ye=n,ns()}}}function Ho(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,zc(e)}function cp(e){if(ye!==this)throw new Error("Out-of-order effect");Wc(this),ye=e,this.f&=-2,8&this.f&&Ho(this),ns()}function Nn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,mr&&mr.push(this)}Nn.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()}};Nn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,zc(this),Nc(this),St++;var e=ye;return ye=this,cp.bind(this,e)};Nn.prototype.N=function(){2&this.f||(this.f|=2,this.u=gr,gr=this)};Nn.prototype.d=function(){this.f|=8,1&this.f||Ho(this)};Nn.prototype.dispose=function(){this.d()};function ot(e,t){var n=new Nn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var dp=Object.create,Uo=Object.defineProperty,up=Object.defineProperties,fp=Object.getOwnPropertyDescriptor,hp=Object.getOwnPropertyDescriptors,dl=Object.getOwnPropertySymbols,pp=Object.prototype.hasOwnProperty,mp=Object.prototype.propertyIsEnumerable,gp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Wn=e=>{throw TypeError(e)},Vs=(e,t,n)=>t in e?Uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vp=(e,t)=>{for(var n in t||(t={}))pp.call(t,n)&&Vs(e,n,t[n]);if(dl)for(var n of dl(t))mp.call(t,n)&&Vs(e,n,t[n]);return e},bp=(e,t)=>up(e,hp(t)),ul=(e,t)=>Uo(e,"name",{value:t,configurable:!0}),yp=e=>{var t;return[,,,dp((t=void 0)!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],Jn=e=>e!==void 0&&typeof e!="function"?Wn("Function expected"):e,xp=(e,t,n,r,i)=>({kind:Fc[e],name:t,metadata:r,addInitializer:s=>n._?Wn("Already initialized"):i.push(Jn(s||null))}),_c=(e,t)=>Vs(t,gp("metadata"),e[3]),qt=(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},zn=(e,t,n,r,i,s)=>{var o,a,c,u,l,d=t&7,h=!!(t&8),f=!!(t&16),m=d>3?e.length+1:d?h?1:2:0,g=Fc[d+5],x=d>3&&(e[m-1]=[]),w=e[m]||(e[m]=[]),p=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&fp(d<4?i:{get[n](){return tt(this,s)},set[n](b){return At(this,s,b)}},n));d?f&&d<4&&ul(s,(d>2?"set ":d>1?"get ":"")+n):ul(i,n);for(var v=r.length-1;v>=0;v--)u=xp(d,n,c={},e[3],w),d&&(u.static=h,u.private=f,l=u.access={has:f?b=>wp(i,b):b=>n in b},d^3&&(l.get=f?b=>(d^1?tt:kp)(b,i,d^4?s:p.get):b=>b[n]),d>2&&(l.set=f?(b,k)=>At(b,i,k,d^4?s:p.set):(b,k)=>b[n]=k)),a=(0,r[v])(d?d<4?f?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),c._=1,d^4||a===void 0?Jn(a)&&(d>4?x.unshift(a):d?f?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Wn("Object expected"):(Jn(o=a.get)&&(p.get=o),Jn(o=a.set)&&(p.set=o),Jn(o=a.init)&&x.unshift(o));return d||_c(e,i),p&&Uo(i,n,p),f?d^4?s:p:i},Go=(e,t,n)=>t.has(e)||Wn("Cannot "+n),wp=(e,t)=>Object(t)!==t?Wn('Cannot use the "in" operator on this value'):e.has(t),tt=(e,t,n)=>(Go(e,t,"read from private field"),n?n.call(e):t.get(e)),er=(e,t,n)=>t.has(e)?Wn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),At=(e,t,n,r)=>(Go(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),kp=(e,t,n)=>(Go(e,t,"access private method"),n);function Zs(e,t){if(t){let n;return cl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return cl(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 ce({get:e},t){return{init(n){return Ln(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Oe(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Zs(e.bind(this)),n.set(this,r)),r.value}}function ks(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,bp(vp({},i),{enumerable:e}))})}}function Lr(...e){const t=e.map(n=>ot(n));return()=>t.forEach(n=>n())}var qc,Bc,Hc,Uc,Gc,Kc,Be,Ko,Ss,Qs,Js,_e,Yo,$s,Yc,eo,Xo,js,to,no;Kc=[ce],Gc=[ce],Uc=[ce],Hc=[ks()],Bc=[ks()],qc=[ks()];var on=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,qt(Be,5,this),er(this,_e),er(this,Ko,qt(Be,8,this)),qt(Be,11,this),er(this,Yo,qt(Be,12,this)),qt(Be,15,this),er(this,Xo,qt(Be,16,this)),qt(Be,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return tt(this,_e,to)}get initial(){return tt(this,_e,Qs)}get previous(){return tt(this,_e,Yc)}set current(e){const t=le(()=>tt(this,_e,to));e&&t&&this.equals(t,e)||je(()=>{tt(this,_e,Qs)||At(this,_e,e,Js),At(this,_e,t,eo),At(this,_e,e,no)})}reset(e=this.defaultValue){je(()=>{At(this,_e,void 0,eo),At(this,_e,e,Js),At(this,_e,e,no)})}};Be=yp();Ko=new WeakMap;_e=new WeakSet;Yo=new WeakMap;Xo=new WeakMap;Ss=zn(Be,20,"#initial",Kc,_e,Ko),Qs=Ss.get,Js=Ss.set;$s=zn(Be,20,"#previous",Gc,_e,Yo),Yc=$s.get,eo=$s.set;js=zn(Be,20,"#current",Uc,_e,Xo),to=js.get,no=js.set;zn(Be,2,"current",Hc,on);zn(Be,2,"initial",Bc,on);zn(Be,2,"previous",qc,on);_c(Be,on);function Cs(e){return le(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Ht,Sp=class{constructor(){er(this,Ht,new WeakMap)}get(e,t){var n;return e?(n=tt(this,Ht).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return tt(this,Ht).has(e)||tt(this,Ht).set(e,new Map),(r=tt(this,Ht).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=tt(this,Ht).get(e))==null?void 0:t.clear():void 0}};Ht=new WeakMap;var $p=Object.create,Xc=Object.defineProperty,jp=Object.getOwnPropertyDescriptor,fl=Object.getOwnPropertySymbols,Cp=Object.prototype.hasOwnProperty,Op=Object.prototype.propertyIsEnumerable,Vc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),rs=e=>{throw TypeError(e)},hl=Math.pow,ro=(e,t,n)=>t in e?Xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ep=(e,t)=>{for(var n in t||(t={}))Cp.call(t,n)&&ro(e,n,t[n]);if(fl)for(var n of fl(t))Op.call(t,n)&&ro(e,n,t[n]);return e},Tp=e=>{var t;return[,,,$p((t=e?.[Vc("metadata")])!=null?t:null)]},Zc=["class","method","getter","setter","accessor","field","value","get","set"],Qc=e=>e!==void 0&&typeof e!="function"?rs("Function expected"):e,Mp=(e,t,n,r,i)=>({kind:Zc[e],name:t,metadata:r,addInitializer:s=>n._?rs("Already initialized"):i.push(Qc(s||null))}),Ap=(e,t)=>ro(t,Vc("metadata"),e[3]),Dp=(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},Jc=(e,t,n,r,i,s)=>{for(var o,a,c,u,l=t&7,d=!1,h=!1,f=2,m=Zc[l+5],g=e[f]||(e[f]=[]),x=(i=i.prototype,jp(i,n)),w=r.length-1;w>=0;w--)c=Mp(l,n,a={},e[3],g),c.static=d,c.private=h,u=c.access={has:p=>n in p},u.get=p=>p[n],o=(0,r[w])(x[m],c),a._=1,Qc(o)&&(x[m]=o);return x&&Xc(i,n,x),i},ed=(e,t,n)=>t.has(e)||rs("Cannot "+n),Ip=(e,t,n)=>(ed(e,t,"read from private field"),t.get(e)),Pp=(e,t,n)=>t.has(e)?rs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Rp=(e,t,n,r)=>(ed(e,t,"write to private field"),t.set(e,n),n),nt=class io{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new io(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 io(t,n)}},gt=class Ut{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,c=new Ut(i+t,r+n,s,o);return c.scale=Ep({},a),c}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new nt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ut))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 Ut?Lp(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 Ut(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],c=o==="x"?s.left:s.top,u=o==="x"?s.width:s.height;return a=="start"?c:a=="end"?c+u:c+u/2};return nt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Ut.from(t).intersectionRatio(Ut.from(n))}};function Lp(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 td,nd,so,pi,Nr,is=class extends(so=on,nd=[Oe],td=[Oe],so){constructor(e){const t=nt.from(e);super(t,(n,r)=>nt.equals(n,r)),Dp(Nr,5,this),Pp(this,pi,0),this.velocity={x:0,y:0}}get delta(){return nt.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=nt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Ip(this,pi),o=a=>Math.round(a/s*100);je(()=>{Rp(this,pi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(nt.from(e)),this.velocity={x:0,y:0}}};Nr=Tp(so);pi=new WeakMap;Jc(Nr,2,"delta",nd,is);Jc(Nr,2,"direction",td,is);Ap(Nr,is);function oo({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(hl(r,2)+hl(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 rd=(e=>(e.Horizontal="x",e.Vertical="y",e))(rd||{}),id=Object.values(rd),Np=Object.create,Vo=Object.defineProperty,Wp=Object.defineProperties,zp=Object.getOwnPropertyDescriptor,Fp=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,sd=Object.prototype.hasOwnProperty,od=Object.prototype.propertyIsEnumerable,ad=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Fn=e=>{throw TypeError(e)},ao=(e,t,n)=>t in e?Vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zo=(e,t)=>{for(var n in t||(t={}))sd.call(t,n)&&ao(e,n,t[n]);if(Pi)for(var n of Pi(t))od.call(t,n)&&ao(e,n,t[n]);return e},Qo=(e,t)=>Wp(e,Fp(t)),pl=(e,t)=>Vo(e,"name",{value:t,configurable:!0}),ld=(e,t)=>{var n={};for(var r in e)sd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Pi)for(var r of Pi(e))t.indexOf(r)<0&&od.call(e,r)&&(n[r]=e[r]);return n},_n=e=>{var t;return[,,,Np((t=e?.[ad("metadata")])!=null?t:null)]},cd=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?Fn("Function expected"):e,_p=(e,t,n,r,i)=>({kind:cd[e],name:t,metadata:r,addInitializer:s=>n._?Fn("Already initialized"):i.push(tr(s||null))}),an=(e,t)=>ao(t,ad("metadata"),e[3]),se=(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},de=(e,t,n,r,i,s)=>{var o,a,c,u,l,d=t&7,h=!!(t&8),f=!!(t&16),m=d>3?e.length+1:d?h?1:2:0,g=cd[d+5],x=d>3&&(e[m-1]=[]),w=e[m]||(e[m]=[]),p=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&zp(d<4?i:{get[n](){return Ce(this,s)},set[n](b){return Ze(this,s,b)}},n));d?f&&d<4&&pl(s,(d>2?"set ":d>1?"get ":"")+n):pl(i,n);for(var v=r.length-1;v>=0;v--)u=_p(d,n,c={},e[3],w),d&&(u.static=h,u.private=f,l=u.access={has:f?b=>qp(i,b):b=>n in b},d^3&&(l.get=f?b=>(d^1?Ce:dd)(b,i,d^4?s:p.get):b=>b[n]),d>2&&(l.set=f?(b,k)=>Ze(b,i,k,d^4?s:p.set):(b,k)=>b[n]=k)),a=(0,r[v])(d?d<4?f?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),c._=1,d^4||a===void 0?tr(a)&&(d>4?x.unshift(a):d?f?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Fn("Object expected"):(tr(o=a.get)&&(p.get=o),tr(o=a.set)&&(p.set=o),tr(o=a.init)&&x.unshift(o));return d||an(e,i),p&&Vo(i,n,p),f?d^4?s:p:i},Jo=(e,t,n)=>t.has(e)||Fn("Cannot "+n),qp=(e,t)=>Object(t)!==t?Fn('Cannot use the "in" operator on this value'):e.has(t),Ce=(e,t,n)=>(Jo(e,t,"read from private field"),n?n.call(e):t.get(e)),he=(e,t,n)=>t.has(e)?Fn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ze=(e,t,n,r)=>(Jo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),dd=(e,t,n)=>(Jo(e,t,"access private method"),n);function ud(e,t){return{plugin:e,options:t}}function Wr(e){return t=>ud(e,t)}function kr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var fd,Sr,ea,mi;fd=[ce];var qe=class{constructor(e,t){this.manager=e,this.options=t,he(this,ea,se(Sr,8,this,!1)),se(Sr,11,this),he(this,mi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return le(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=ot(e.bind(this));return Ce(this,mi).add(t),t}destroy(){Ce(this,mi).forEach(e=>e())}static configure(e){return ud(this,e)}};Sr=_n(null);ea=new WeakMap;mi=new WeakMap;de(Sr,4,"disabled",fd,qe,ea);an(Sr,qe);var zr=class extends qe{},gi,Os=class{constructor(e){this.manager=e,this.instances=new Map,he(this,gi,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(kr).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 Ce(this,gi))if(!n.includes(r)){if(r.prototype instanceof zr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);Ze(this,gi,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()}};gi=new WeakMap;function Bp(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Qr=[],gn,vn,Hp=class extends qe{constructor(e){super(e),he(this,gn),he(this,vn),this.computeCollisions=this.computeCollisions.bind(this),Ze(this,vn,Ln(Qr)),this.destroy=Lr(()=>{const t=this.computeCollisions(),n=le(()=>this.manager.dragOperation.position.current);if(t!==Qr){const r=Ce(this,gn);if(Ze(this,gn,n),r&&n.x==r.x&&n.y==r.y)return}else Ze(this,gn,void 0);Ce(this,vn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){le(()=>{e?Ce(this,vn).value=this.computeCollisions():Ze(this,gn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Qr;const a=[],c=[];for(const u of e??n.droppables){if(u.disabled||i&&!u.accepts(i))continue;const l=t??u.collisionDetector;if(!l)continue;c.push(u),u.shape;const d=le(()=>l({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return c.length===0?Qr:(a.sort(Bp),a)}get collisions(){return Ce(this,vn).value}};gn=new WeakMap;vn=new WeakMap;var hd,pd,md,ta,gd,dt,na,Sn,ra,ia;md=[ce],pd=[ce],hd=[ce];var jt=class Gt{constructor(t,n){he(this,na,se(dt,8,this)),se(dt,11,this),he(this,Sn),he(this,ra,se(dt,12,this)),se(dt,15,this),he(this,ia,se(dt,16,this)),se(dt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let c=i;Ze(this,Sn,Ln(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var u;return[()=>{const{id:l,manager:d}=this;if(l!==c)return c=l,d?.registry.register(this),()=>d?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},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=Ce(this,Sn).value;return(n=(t=Gt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=Gt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Ce(this,Sn).peek();t!==i&&(Gt.pendingIdChanges||(Gt.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return dd(s=Gt,ta,gd).call(s)})),Gt.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)}};dt=_n(null);ta=new WeakSet;gd=function(){const e=jt.pendingIdChanges;jt.pendingIdChanges=null,e&&je(()=>{for(const[t,n]of e)Ce(t,Sn).value=n})};na=new WeakMap;Sn=new WeakMap;ra=new WeakMap;ia=new WeakMap;de(dt,4,"manager",md,jt,na);de(dt,4,"data",pd,jt,ra);de(dt,4,"disabled",hd,jt,ia);he(jt,ta);an(dt,jt);jt.pendingIdChanges=null;var ss=jt,ml=class{constructor(){this.map=Ln(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,c]of n)if(c===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=Lr(...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}},vd,bd,yd,xd,wd,kd,lo,He,sa,oa,aa,vt=class extends(lo=ss,kd=[ce],wd=[ce],xd=[ce],yd=[Oe],bd=[Oe],vd=[Oe],lo){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,c=ld(n,["modifiers","type","sensors","plugins","effects"]);super(Qo(Zo({},c),{effects:()=>{var u;return[...(u=a?.())!=null?u:[],()=>{const{manager:l,plugins:d}=this;if(!(!l||!d))for(const h of d){const{plugin:f}=kr(h);l.registry.plugins.register(f)}}]}}),t),se(He,5,this),he(this,sa,se(He,8,this)),se(He,11,this),he(this,oa,se(He,12,this)),se(He,15,this),he(this,aa,se(He,16,this,this.isDragSource?"dragging":"idle")),se(He,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=c.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=kr(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}};He=_n(lo);sa=new WeakMap;oa=new WeakMap;aa=new WeakMap;de(He,4,"type",kd,vt,sa);de(He,4,"modifiers",wd,vt,oa);de(He,4,"status",xd,vt,aa);de(He,2,"isDropping",yd,vt);de(He,2,"isDragging",bd,vt);de(He,2,"isDragSource",vd,vt);an(He,vt);var Sd,$d,jd,Cd,Od,Ed,co,Ie,la,ca,da,ua,fa,bt=class extends(co=ss,Ed=[ce],Od=[ce],Cd=[ce],jd=[ce],$d=[ce],Sd=[Oe],co){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=ld(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),se(Ie,5,this),he(this,la,se(Ie,8,this)),se(Ie,11,this),he(this,ca,se(Ie,12,this)),se(Ie,15,this),he(this,da,se(Ie,16,this)),se(Ie,19,this),he(this,ua,se(Ie,20,this)),se(Ie,23,this),he(this,fa,se(Ie,24,this)),se(Ie,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}};Ie=_n(co);la=new WeakMap;ca=new WeakMap;da=new WeakMap;ua=new WeakMap;fa=new WeakMap;de(Ie,4,"accept",Ed,bt,la);de(Ie,4,"type",Od,bt,ca);de(Ie,4,"collisionDetector",Cd,bt,da);de(Ie,4,"collisionPriority",jd,bt,ua);de(Ie,4,"shape",$d,bt,fa);de(Ie,2,"isDropTarget",Sd,bt);an(Ie,bt);var Up=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)}},Gp=class extends Up{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function vi(e,t=!0){let n=!1;return Qo(Zo({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Kp=class extends zr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=Lr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||ss.pendingIdChanges)return;const o=vi({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;le(()=>{var c;a?.id!==((c=e.dragOperation.target)==null?void 0:c.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},qn=(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))(qn||{}),Bn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Bn||{}),Td,Md,Ad,Dd,Id,Pd,Rd,st,ha;Rd=[ce],Pd=[Oe],Id=[Oe],Dd=[Oe],Ad=[Oe],Md=[Oe],Td=[Oe];var Ot=class{constructor(){se(st,5,this),he(this,ha,se(st,8,this,"idle")),se(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=_n(null);ha=new WeakMap;de(st,4,"value",Rd,Ot,ha);de(st,2,"current",Pd,Ot);de(st,2,"idle",Id,Ot);de(st,2,"initializing",Dd,Ot);de(st,2,"initialized",Ad,Ot);de(st,2,"dragging",Md,Ot);de(st,2,"dropped",Td,Ot);an(st,Ot);var Yp=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 le(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=vi({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return le(()=>{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;je(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=vi({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"&&je(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return le(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=vi({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,c,u,l,d;if(o.defaultPrevented)return;const h=(d=e.to)!=null?d:{x:r.position.current.x+((c=(a=e.by)==null?void 0:a.x)!=null?c:0),y:r.position.current.y+((l=(u=e.by)==null?void 0:u.y)!=null?l:0)};r.position.current=h})})}stop(e={}){return le(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const c={resume:()=>{},abort:()=>{}};return s=new Promise((u,l)=>{c.resume=u,c.abort=l}),c};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const c=le(()=>{var l;return((l=r.source)==null?void 0:l.status)==="dropping"}),u=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(c){const{source:l}=r,d=ot(()=>{l?.status==="idle"&&(d(),u())})}else this.manager.renderer.rendering.then(u)})};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()})}},Mn=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Xp=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)}},bi,Ld=class{constructor(e){this.options=e,he(this,bi)}set controller(e){Ze(this,bi,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ce(this,bi))==null||t.activate(e)}};bi=new WeakMap;var gl=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Vp=class{constructor(e){this.draggables=new ml,this.droppables=new ml,this.plugins=new Os(e),this.sensors=new Os(e),this.modifiers=new Os(e)}register(e,t){if(e instanceof vt)return this.draggables.register(e.id,e);if(e instanceof bt)return this.droppables.register(e.id,e);if(e.prototype instanceof gl)return this.modifiers.register(e,t);if(e.prototype instanceof Mn)return this.sensors.register(e,t);if(e.prototype instanceof qe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof ss)return e instanceof vt?this.draggables.unregister(e.id,e):e instanceof bt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof gl)return this.modifiers.unregister(e);if(e.prototype instanceof Mn)return this.sensors.unregister(e);if(e.prototype instanceof qe)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()}},Nd,Wd,zd,Fd,_d,qd,Bd,Hd,Ud,nr,yi,bn,$e,pa,ma,ga,va,ba,rr;Ud=[Oe],Hd=[ce],Bd=[ce],qd=[ce],_d=[ce],Fd=[ce],zd=[Oe],Wd=[Oe],Nd=[Oe];var ht=class{constructor(e){se($e,5,this),he(this,nr),he(this,yi),he(this,bn,new on(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Ot,he(this,pa,se($e,8,this,!1)),se($e,11,this),he(this,ma,se($e,12,this,null)),se($e,15,this),he(this,ga,se($e,16,this,null)),se($e,19,this),he(this,va,se($e,20,this,null)),se($e,23,this),he(this,ba,se($e,24,this,[])),se($e,27,this),this.position=new is({x:0,y:0}),he(this,rr,{x:0,y:0}),Ze(this,nr,e)}get shape(){const{current:e,initial:t,previous:n}=Ce(this,bn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ce(this,bn).current=e:Ce(this,bn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ce(this,nr).registry.draggables.get(t);return n&&Ze(this,yi,n),(e=n??Ce(this,yi))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ce(this,nr).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(Qo(Zo({},this.snapshot()),{transform:n}));return Ze(this,rr,n),n}snapshot(){return le(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ce(this,rr),shape:this.shape?Cs(this.shape):null,position:Cs(this.position),status:Cs(this.status),canceled:this.canceled}))}reset(){je(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ce(this,bn).reset(),this.position.reset({x:0,y:0}),Ze(this,rr,{x:0,y:0}),this.modifiers=[]})}};$e=_n(null);nr=new WeakMap;yi=new WeakMap;bn=new WeakMap;pa=new WeakMap;ma=new WeakMap;ga=new WeakMap;va=new WeakMap;ba=new WeakMap;rr=new WeakMap;de($e,2,"shape",Ud,ht);de($e,4,"canceled",Hd,ht,pa);de($e,4,"activatorEvent",Bd,ht,ma);de($e,4,"sourceIdentifier",qd,ht,ga);de($e,4,"targetIdentifier",_d,ht,va);de($e,4,"modifiers",Fd,ht,ba);de($e,2,"source",zd,ht);de($e,2,"target",Wd,ht);de($e,2,"transform",Nd,ht);an($e,ht);var Zp={get rendering(){return Promise.resolve()}};function ft(e,t){return typeof e=="function"?e(t):e??t}var Qp=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(d=>d.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=ft(n.plugins,[]),i=ft(n.sensors,[]),s=ft(n.modifiers,[]),o=(t=n.renderer)!=null?t:Zp,a=new Gp(this),c=new Vp(this);this.registry=c,this.monitor=a,this.renderer=o,this.actions=new Yp(this),this.dragOperation=new ht(this),this.collisionObserver=new Hp(this),this.plugins=[Kp,...r],this.modifiers=s,this.sensors=i;const{destroy:u}=this,l=Lr(()=>{var d,h,f;const m=le(()=>this.dragOperation.modifiers),g=this.modifiers;for(const x of m)g.includes(x)||x.destroy();this.dragOperation.modifiers=(f=(h=(d=this.dragOperation.source)==null?void 0:d.modifiers)==null?void 0:h.map(x=>{const{plugin:w,options:p}=kr(x);return new w(this,p)}))!=null?f:g});this.destroy=()=>{l(),u()}}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}},Gd=e=>{throw TypeError(e)},ya=(e,t,n)=>t.has(e)||Gd("Cannot "+n),ie=(e,t,n)=>(ya(e,t,"read from private field"),t.get(e)),Ke=(e,t,n)=>t.has(e)?Gd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ve=(e,t,n,r)=>(ya(e,t,"write to private field"),t.set(e,n),n),Kd=(e,t,n)=>(ya(e,t,"access private method"),n);function os(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Yd(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(os(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function as(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 xa(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Fr(e){return"nodeType"in e}function Je(e){var t,n,r;return e?xa(e)?e:Fr(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 wa(e){const{Document:t}=Je(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function zt(e){return!e||xa(e)?!1:e instanceof Je(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Xd(e){return e instanceof Je(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Hn(e){return e?xa(e)?e.document:Fr(e)?wa(e)?e:zt(e)||Xd(e)?e.ownerDocument:document:document:document}function Jp(e){var t,n,r,i;const{documentElement:s}=Hn(e),o=Je(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,c=(n=o?.height)!=null?n:s.clientHeight,u=(r=o?.offsetTop)!=null?r:0,l=(i=o?.offsetLeft)!=null?i:0;return{top:u,left:l,right:l+a,bottom:u+c,width:a,height:c}}function em(e,t){if(tm(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function tm(e){return e.tagName==="DETAILS"}function $r(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let c=t;const{ownerDocument:u}=e,l=(r=u.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==u.documentElement;){if(!em(d)){const v=d.getBoundingClientRect(),b=n*(v.bottom-v.top),k=n*(v.right-v.left),D=n*(v.bottom-v.top),M=n*(v.right-v.left);c={top:Math.max(c.top,v.top-b),right:Math.min(c.right,v.right+k),bottom:Math.min(c.bottom,v.bottom+D),left:Math.max(c.left,v.left-M),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top}d=d.parentElement}const h=l.visualViewport,f=(i=h?.offsetTop)!=null?i:0,m=(s=h?.offsetLeft)!=null?s:0,g=(o=h?.width)!=null?o:l.innerWidth,x=(a=h?.height)!=null?a:l.innerHeight,w=n*x,p=n*g;return c={top:Math.max(c.top,f-w),right:Math.min(c.right,m+g+p),bottom:Math.min(c.bottom,f+x+w),left:Math.max(c.left,m-p),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top,c.width<0&&(c.width=0),c.height<0&&(c.height=0),c}function An(e){return{x:e.clientX,y:e.clientY}}var Vd=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 ka(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Zd(){var e,t;const n=ka()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Sa(e){return!e||!Fr(e)?!1:e instanceof Je(e).ShadowRoot}function Ri(e){if(e&&Fr(e)){let t=e.getRootNode();if(Sa(t)||t instanceof Document)return t}return Hn(e)}function $a(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function nm(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];vl(i)&&vl(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),bl(i)&&bl(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function vl(e){return"value"in e}function bl(e){return e.tagName==="CANVAS"}function Qd(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(rm(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Qd(i,{x:t-s,y:n-o})}}return r}function rm(e){return e?.tagName==="IFRAME"}var fo=new WeakMap;function im(e){return e.closest(`
2
2
  input:not([disabled]),
3
3
  select:not([disabled]),
4
4
  textarea:not([disabled]),
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-BIqIsMFr.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-hnA8HjeH.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.9.5",
4
+ "version": "0.9.7",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -41,7 +41,7 @@
41
41
  "test:playwright:headed": "bunx playwright test --config=playwright.config.ts --headed"
42
42
  },
43
43
  "dependencies": {
44
- "@malloy-publisher/sdk": "^0.9.5",
44
+ "@malloy-publisher/sdk": "^0.9.7",
45
45
  "@mui/icons-material": "^7.0.2",
46
46
  "@mui/material": "^7.0.2",
47
47
  "@tanstack/react-query": "^5.59.16",