@malloy-publisher/app 0.9.11 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-doc.yaml +259 -4
- package/dist/assets/EnvironmentPage-BxJoHBPQ.js +1 -0
- package/dist/assets/HomePage-CtB5QVol.js +1 -0
- package/dist/assets/{MainPage-BpE_5WuW.js → MainPage-1nhjUUzl.js} +1 -1
- package/dist/assets/{ModelPage-ftyDI1tw.js → ModelPage-D8aucAvE.js} +2 -2
- package/dist/assets/{PackagePage-QGnFwlHu.js → PackagePage-DBSA4TbT.js} +1 -1
- package/dist/assets/{RenderedResult-Cmx8sX8d.es-du-Qe1x0.js → RenderedResult-DnBtf-cI.es-DalkcU9E.js} +2 -2
- package/dist/assets/{RouteError-zM4SSZaU.js → RouteError-BVLp9Ogi.js} +1 -1
- package/dist/assets/{ThemeEditorPage-DhZJXGJm.js → ThemeEditorPage-D6bvkrka.js} +1 -1
- package/dist/assets/{ToggleButtonGroup-TKxhg0Mg.js → ToggleButtonGroup-CWY9-__R.js} +1 -1
- package/dist/assets/{documentRoutes-D4TbSIi5.js → documentRoutes-QL_YE88h.js} +1 -1
- package/dist/assets/{editPageMounted-0kzl2sgg.js → editPageMounted-BT7ByBX-.js} +2 -2
- package/dist/assets/{index-Bzi4YH8Y.js → index-BRzP9bJe.js} +1 -1
- package/dist/assets/{index-CS4mmuDD.js → index-CHfG8VAW.js} +1 -1
- package/dist/assets/{index-B-qJVEXn.js → index-DM7_2PYo.js} +1 -1
- package/dist/assets/index-Dgqan3mQ.js +481 -0
- package/dist/assets/index.es-BBmXDZRJ.js +143 -0
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/assets/EnvironmentPage-tIGzymgb.js +0 -1
- package/dist/assets/HomePage-7QkNvQ_3.js +0 -1
- package/dist/assets/index-gQEuz0Cg.js +0 -480
- package/dist/assets/index.es-B3P9tIm3.js +0 -143
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import{g as tf,b as nf,r as S,u as rf,b6 as sf,k as of,i as af,b7 as lf,l as cf,j as m,f as df,h as uf,s as ea,m as hf,t as gl,Z as ff,V as He,b8 as Yt,b9 as ds,aD as tt,ae as Ze,L as kt,K as Bn,ba as Nr,ak as Me,bb as ta,bc as Yr,bd as zi,be as pf,bf as mf,bg as gf,bh as vf,bi as bf,T as pe,as as it,bj as xf,bk as yf,bl as wf,O as na,aK as kf,bm as Lt,bn as Sf,bo as ra,bp as $f,bq as Cc,br as Ec,bs as jf,bt as Mf,a0 as Xs,bu as Cf,bv as Ef,bw as vl,bx as di,aX as Oc,B as Dc,by as Fe,I as B,aJ as vt,bz as ot,bA as ia,bB as Of,bC as Wn,bD as Df,ag as Tf,bE as Af,bF as Rf,bG as Pf,bH as If,bI as Wf,bJ as Tc,bK as Nf,bL as zf,bM as Ac,bN as Rc,bO as Pc,bP as Lf,bQ as Ff,bR as Bf,bS as _f,bT as Hf,bU as qf,bV as Uf,bW as Vf,bX as Gf,F as Kf,bY as Yf,bZ as Xf,b_ as Js,b$ as Zs,c0 as bl,c1 as Jf,c2 as Zf,c3 as Qf,c4 as ep,c5 as cn,c6 as tp,c7 as np,c8 as rp,c9 as Ic,ca as sa,cb as ip,cc as sp,cd as Wc,ce as op,cf as ap,cg as lp,ch as oa,ci as Ut,cj as cp,ck as dp,cl as Nc,cm as up,cn as hp,aP as aa,aF as Ft,co as Qs,cp as fp,cq as pp,Y as Li,X as mp,cr as gp,cs as vp,ct as eo,cu as bp,cv as xp,cw as yp,cx as zc,cy as wp,G as kp,cz as Sp,cA as $p,cB as jp,cC as Mp,cD as la,cE as Cp,cF as ca,aT as Ep,cG as Op,cH as Dp,cI as Tp,cJ as Ap,cK as Rp,cL as xn,cM as xl,cN as yl,cO as Es,cP as Pp,S as Ip,cQ as Wp,cR as Np,cS as zp,cT as Lp,cU as Lc,aj as Fp}from"./index-Dgqan3mQ.js";import{cV as D0,cW as T0,cX as A0,cY as R0,cZ as P0,c_ as I0,c$ as W0,d0 as N0,d1 as z0,d2 as L0,d3 as F0}from"./index-Dgqan3mQ.js";import{T as Fc,a as to}from"./ToggleButtonGroup-CWY9-__R.js";function Bp(e){return tf("MuiCollapse",e)}nf("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const _p=e=>{const{orientation:t,classes:n}=e,r={root:["root",`${t}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${t}`],wrapperInner:["wrapperInner",`${t}`]};return uf(r,Bp,n)},Hp=ea("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[n.orientation],n.state==="entered"&&t.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&t.hidden]}})(hf(({theme:e})=>({height:0,overflow:"hidden",transition:e.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:e.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:t})=>t.state==="exited"&&!t.in&&t.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),qp=ea("div",{name:"MuiCollapse",slot:"Wrapper"})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),Up=ea("div",{name:"MuiCollapse",slot:"WrapperInner"})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),no=S.forwardRef(function(t,n){const r=rf({props:t,name:"MuiCollapse"}),{addEndListener:i,children:s,className:o,collapsedSize:a="0px",component:d,easing:f,in:c,onEnter:l,onEntered:u,onEntering:p,onExit:g,onExited:v,onExiting:x,orientation:k="vertical",style:h,timeout:b=sf.standard,TransitionComponent:y=of,...w}=r,$={...r,orientation:k,collapsedSize:a},M=_p($),T=af(),j=lf(),O=S.useRef(null),P=S.useRef(),R=typeof a=="number"?`${a}px`:a,A=k==="horizontal",z=A?"width":"height",q=S.useRef(null),U=cf(n,q),D=H=>Z=>{if(H){const ee=q.current;Z===void 0?H(ee):H(ee,Z)}},N=()=>O.current?O.current[A?"clientWidth":"clientHeight"]:0,F=D((H,Z)=>{O.current&&A&&(O.current.style.position="absolute"),H.style[z]=R,l&&l(H,Z)}),W=D((H,Z)=>{const ee=N();O.current&&A&&(O.current.style.position="");const{duration:Q,easing:ce}=gl({style:h,timeout:b,easing:f},{mode:"enter"});if(b==="auto"){const xe=T.transitions.getAutoHeightDuration(ee);H.style.transitionDuration=`${xe}ms`,P.current=xe}else H.style.transitionDuration=typeof Q=="string"?Q:`${Q}ms`;H.style[z]=`${ee}px`,H.style.transitionTimingFunction=ce,p&&p(H,Z)}),_=D((H,Z)=>{H.style[z]="auto",u&&u(H,Z)}),Y=D(H=>{H.style[z]=`${N()}px`,g&&g(H)}),G=D(v),le=D(H=>{const Z=N(),{duration:ee,easing:Q}=gl({style:h,timeout:b,easing:f},{mode:"exit"});if(b==="auto"){const ce=T.transitions.getAutoHeightDuration(Z);H.style.transitionDuration=`${ce}ms`,P.current=ce}else H.style.transitionDuration=typeof ee=="string"?ee:`${ee}ms`;H.style[z]=R,H.style.transitionTimingFunction=Q,x&&x(H)}),V=H=>{b==="auto"&&j.start(P.current||0,H),i&&i(q.current,H)};return m.jsx(y,{in:c,onEnter:F,onEntered:_,onEntering:W,onExit:Y,onExited:G,onExiting:le,addEndListener:V,nodeRef:q,timeout:b==="auto"?null:b,...w,children:(H,{ownerState:Z,...ee})=>m.jsx(Hp,{as:d,className:df(M.root,o,{entered:M.entered,exited:!c&&R==="0px"&&M.hidden}[H]),style:{[A?"minWidth":"minHeight"]:R,...h},ref:U,ownerState:{...$,state:H},...ee,children:m.jsx(qp,{ownerState:{...$,state:H},className:M.wrapper,ref:O,children:m.jsx(Up,{ownerState:{...$,state:H},className:M.wrapperInner,children:s})})})})});no&&(no.muiSupportAuto=!0);var wl={};const Bc=ot(m.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),_c=ot(m.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),Vp=ot(m.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}));function Hc(e){const{theme:t}=He(),n=t.ui,[r,i]=S.useState(null),{status:s,draftKeptAt:o,discard:a,restored:d,dismissRestored:f}=e,c=d!==void 0&&!d.pending&&s==="unsaved"?d:void 0,l=s==="saved"?"Saved":s==="saving"?"Saving…":o!==void 0?"Draft saved":"Unsaved changes",u=c?`Restored your unsaved edits from ${ro(c.savedAt)}`:void 0,p=s==="unsaved"&&o!==void 0?"Your edits are kept in this browser. Done saves them to the report.":e.saveTarget,g=a!==void 0&&s==="unsaved",v=()=>{i(null),c&&f?.()},x=b=>({display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:.75,minWidth:132,height:n.size.control,px:1,borderRadius:n.radius.control,font:"inherit",...n.type.control,whiteSpace:"nowrap",color:s==="saved"?b.palette.text.secondary:b.palette.text.primary,transition:`color ${Fe}, background-color ${Fe}`,...g?{"&:hover":{bgcolor:b.palette.action.hover}}:{}}),k=m.jsxs(m.Fragment,{children:[m.jsx(B,{component:"span","aria-hidden":!0,sx:{width:16,height:16,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:s==="saved"?m.jsx(oa,{sx:{fontSize:16}}):m.jsx(B,{component:"span","data-restored":c?"true":void 0,sx:b=>({width:7,height:7,borderRadius:"50%",bgcolor:c?t.accent:s==="saving"||o!==void 0?b.palette.text.disabled:b.palette.warning.main,transition:`background-color ${Fe}`})})}),m.jsx(B,{component:"span","aria-hidden":!0,children:l}),m.jsx(ta,{"aria-hidden":!0,sx:{fontSize:16,ml:-.25,visibility:g?"visible":"hidden"}})]}),h=m.jsx(B,{component:"span",role:"status","aria-live":"polite",sx:Gp,children:u?`${l}. ${u}.`:l});return m.jsxs(m.Fragment,{children:[h,m.jsx(kt,{title:u??p,describeChild:!0,children:g?m.jsx(Dc,{className:Ze.saveStatus,"aria-label":l,...u?{"aria-description":u}:{},"aria-haspopup":"menu","aria-expanded":r!==null,onClick:b=>i(b.currentTarget),sx:x,children:k}):m.jsx(B,{component:"span",className:Ze.saveStatus,sx:x,children:k})}),m.jsxs(zi,{className:Ze.menu,anchorEl:r,open:r!==null,onClose:v,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:-4,horizontal:"left"},slotProps:{paper:{sx:{minWidth:240,borderRadius:n.radius.menu,border:`1px solid ${Yt(t.cardBorder)}`,boxShadow:n.shadow.menu}}},MenuListProps:{dense:!0,sx:{py:.5}},children:[(u!==void 0||o!==void 0)&&m.jsx(B,{component:"li",role:"presentation",sx:{px:1.75,pt:.75,pb:1,...n.type.caption,color:"text.secondary"},children:u??`Kept in this browser at ${ro(o)}`}),m.jsxs(vt,{onClick:()=>{i(null),a?.()},sx:{mx:.5,borderRadius:n.radius.control,gap:1.25,color:"error.main","&.Mui-focusVisible":{outline:"none",bgcolor:"action.hover"}},children:[m.jsx(Vp,{fontSize:"small"}),"Discard edits"]})]})]})}function ro(e){const t=new Date(e);return new Date().toDateString()===t.toDateString()?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const Gp={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},io=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),dn=io?"⌘":"Ctrl+",kl=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},Os=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function Kp(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e});const[n,r]=S.useState(!1);S.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),S.useEffect(()=>{const i=s=>{const o=t.current;if(o.paused)return;const a=io?s.metaKey:s.ctrlKey,d=s.key.toLowerCase();if(s.key==="Escape"){if(kl(s.target)||Os(s.target))return;o.escape();return}if(kl(s.target)){if(a&&d==="s"){if(s.preventDefault(),!o.save||Os(s.target))return;s.target.blur(),r(!0)}return}if(Os(s.target)){a&&d==="s"&&s.preventDefault();return}if(a&&d==="z"){s.preventDefault(),s.shiftKey?o.redo():o.undo();return}if(!io&&a&&d==="y"){s.preventDefault(),o.redo();return}if(a&&d==="s"){s.preventDefault(),o.save?.();return}o.nudge&&!a&&!s.altKey&&!s.shiftKey&&(s.key==="ArrowLeft"||s.key==="ArrowRight")&&(s.preventDefault(),o.nudge(s.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[])}const Er=(e,t,n=ia)=>({height:n.size.control,minHeight:n.size.control,px:1.5,borderRadius:n.radius.control,boxShadow:"none",...n.type.control,"&:hover":{boxShadow:"none"},"& .MuiButton-startIcon":{mr:.5,"& svg":{fontSize:18}},"&.MuiButton-outlined":{borderColor:e,"&:hover":{borderColor:t}}}),Fi=(e=ia)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),Bi={height:20,alignSelf:"center",mx:.5,my:0},_i=(e,t=ia)=>({height:t.size.control,boxSizing:"border-box",borderRadius:t.radius.control,border:`1px solid ${e}`,overflow:"hidden",bgcolor:"background.paper","& .MuiToggleButton-root":{border:"none",borderRadius:"0 !important",m:"0 !important",px:1.5,py:0,height:"100%",...t.type.control,color:"text.secondary","& + .MuiToggleButton-root":{borderLeft:`1px solid ${e}`},"&:hover":{bgcolor:"action.hover"},"&.Mui-selected, &.Mui-selected:hover":{bgcolor:"action.selected",color:"text.primary"}}}),so={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function Yp({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,savesTo:a="package",saveLabel:d,saveButton:f,actions:c,onAddTile:l,onExit:u,saveStatus:p}){const{theme:g}=He(),v=Yt(g.cardBorder),x=ds(g.cardBorder,g.tileTitle);return m.jsxs(tt,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[l&&m.jsx(Me,{variant:"outlined",startIcon:m.jsx(Yr,{}),onClick:l,"aria-label":"Add tile",sx:Er(v,x,g.ui),children:"Tile"}),l&&m.jsx(Nr,{orientation:"vertical",sx:Bi}),m.jsx(kt,{title:`Undo (${dn}Z)`,children:m.jsx("span",{children:m.jsx(Bn,{"aria-label":"Undo",disabled:!e,onClick:n,sx:Fi(g.ui),children:m.jsx(_c,{fontSize:"small"})})})}),m.jsx(kt,{title:`Redo (${dn}⇧Z)`,children:m.jsx("span",{children:m.jsx(Bn,{"aria-label":"Redo",disabled:!t,onClick:r,sx:Fi(g.ui),children:m.jsx(Bc,{fontSize:"small"})})})}),(c||o||u)&&m.jsx(Nr,{orientation:"vertical",sx:Bi}),c,o&&p&&m.jsx(Hc,{...p}),o?m.jsx(kt,{title:i?`Save (${dn}S) · ${d??so[a]}`:d??so[a],children:m.jsx("span",{children:m.jsx(Me,{ref:f,variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{...Er(v,x,g.ui),minWidth:88},children:s?"Saving…":i?"Save":"Saved"})})}):null,o&&m.jsx(B,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:s?"Saving":i?"Unsaved changes":"All changes saved"}),u&&m.jsx(kp,{label:"Close",icon:m.jsx(oa,{}),onClick:u})]})}const Xp={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function qc(e,t,n){const r=i=>{if(t!==i){if(i==="big_value")return e?.aggregateOnly===!0?void 0:"Needs a view with only totals (no group by)";if(i==="shape_map"||i==="segment_map")return e?.chart===i?void 0:"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(i=>{const s=r(i);return{value:i,label:Xp[i],...s?{disabled:!0,reason:s}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Sl(e){return e.description??Np(e.name)}const Jp={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},ui=(e,t)=>`${e}\0${t}`;function Zp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o,renderPreview:a}){const{theme:d}=He(),f=d.ui,c=Yt(d.cardBorder),l=S.useMemo(()=>n?.sources??[],[n]),[u,p]=S.useState(""),[g,v]=S.useState(),[x,k]=S.useState(""),[h,b]=S.useState("default"),y=S.useRef(null),w=S.useMemo(()=>{const D=new Set(t.sources.map(N=>N.base));return[...l].sort((N,F)=>Number(D.has(F.name))-Number(D.has(N.name)))},[l,t]),$=w.filter(D=>D.views.length>0),M=w.filter(D=>D.views.length===0),T=S.useMemo(()=>new Map($.flatMap(D=>D.views.map(N=>[ui(D.name,N.name),{source:D,view:N,key:ui(D.name,N.name)}]))),[$]),j=S.useMemo(()=>$.map(D=>({key:D.name,label:D.name,...D.description?{detail:D.description}:{},entries:D.views.map(N=>({key:ui(D.name,N.name),name:N.name,title:Sl(N),...N.chart?{chart:N.chart}:{}}))})),[$]),O=g===void 0?void 0:T.get(g);S.useEffect(()=>{if(!e)return;p(""),k(""),b("default");const D=$[0]?.views[0];v(D&&$[0]?ui($[0].name,D.name):void 0)},[e]);const P=O?[O.source.name,O.view.name].filter(D=>!eo(D)).map(D=>`"${D}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,R=O!==void 0&&P===void 0,A=O?Sl(O.view):"",z=h!=="default"&&O?{chart:h,chartCarried:O.view.chart?[O.view.chart]:[]}:{},q=(D=O)=>{if(!D||![D.source.name,D.view.name].every(eo))return;const N=D.key===O?.key;s({base:D.source.name,modelPath:D.source.modelPath,...D.source.exporters?{exporters:D.source.exporters}:{},view:D.view.name,...N&&x.trim()?{label:x.trim()}:{},...N?z:{},colspan:Math.ceil(r/2)})},U=O?qc(O.view,h).filter(D=>D.value!=="custom"&&D.disabled!==!0):[];return m.jsx(aa,{className:`${Ze.dialog} ${Ze.addTileDialog}`,open:e,onClose:i,maxWidth:"md",initialFocus:y,title:"Add a tile",description:"Pick a view from this package. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx(Me,{onClick:o,sx:{mr:"auto"},children:"Add text instead"}),m.jsx(Me,{onClick:i,children:"Cancel"}),m.jsx(Me,{variant:"contained",disabled:!R,onClick:()=>q(),children:"Add tile"})]}),children:m.jsxs(B,{sx:{mx:-3,mb:-1,borderTop:`1px solid ${c}`,borderBottom:`1px solid ${c}`,display:"grid",gridTemplateColumns:{xs:"1fr",md:"320px minmax(0, 1fr)"},height:{md:460}},children:[m.jsx(B,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(bp,{groups:j,query:u,onQuery:p,picked:O?.key,onPick:D=>{v(D),b("default")},onTake:D=>q(T.get(D)),searchRef:y,empty:m.jsx(pe,{variant:"body2",sx:{color:d.tileTitle,p:2},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}),footer:M.length>0&&m.jsxs(pe,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",M.map(D=>D.name).join(", "),"."]})})}),m.jsx(B,{sx:D=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${D.palette.text.primary} 3%, ${D.palette.background.paper})`}),children:O?m.jsxs(m.Fragment,{children:[m.jsx(B,{"aria-label":"Preview",role:"region",sx:D=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:f.radius.tile,border:`1px solid ${c}`,bgcolor:D.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${D.palette.background.paper})`}}),children:a?m.jsx(B,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:O.source.name,modelPath:O.source.modelPath,view:O.view.name,label:x.trim()||A,...h!=="default"?z:{},givens:O.source.givens})}):m.jsxs(B,{sx:D=>({flex:1,border:`1px solid ${c}`,borderRadius:f.radius.tile,bgcolor:D.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(xp,{chart:O.view.chart}),m.jsxs(pe,{variant:"body2",children:[O.source.name," → ",O.view.name]})]})}),m.jsx(Ft,{size:"small",label:"Title",placeholder:A,value:x,onChange:D=>k(D.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs(B,{children:[m.jsx(pe,{component:"div",sx:{...f.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx(Fc,{size:"small",exclusive:!0,value:h,"aria-label":"Chart",onChange:(D,N)=>{N!==null&&b(N)},sx:{..._i(c,f),"& .MuiToggleButton-root":{..._i(c,f)["& .MuiToggleButton-root"],textTransform:"none"}},children:U.map(D=>m.jsx(to,{value:D.value,children:D.label},D.value))}),m.jsx(pe,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:O.view.chart?`The view declares ${Jp[O.view.chart]??"a chart"}.`:"The view declares no chart, so it shows as a table."})]}),P&&m.jsx(pe,{variant:"body2",color:"error",children:P})]}):m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}const De=e=>e.kind==="text",ae=e=>e.kind!=="text",lr=e=>ae(e)?e.label??e.name:e.name,Ne=e=>De(e)?`text.${e.name}`:`${e.source}.${e.name}`;function Qp(e,t,{modelPath:n,textHeld:r,widths:i,insertAt:s}){t.modelPath&&!r&&(e.imports=Pp(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const o=Uc(e,t.base),a=oo(e,o.name,t.view);e.tiles.splice(s??e.tiles.length,0,{name:a,source:o.name,declaration:{kind:"reference",from:t.view},...i?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function Uc(e,t,{unscoped:n=!1}={}){const r=e.sources.find(a=>a.base===t&&(!n||!a.scopedBy?.length));if(r)return r;const i=new Set(e.sources.map(a=>a.name));let s=`${t}_tiles`;for(let a=2;i.has(s);a++)s=`${t}_tiles_${a}`;const o={name:s,base:t};return e.sources.push(o),o}function oo(e,t,n){const r=new Set(e.tiles.filter(ae).filter(s=>s.source===t).map(s=>s.name));let i=`${n}_tile`;for(let s=2;r.has(i);s++)i=`${n}_tile_${s}`;return i}function Hi(e){switch(e.declaration.kind){case"inline":return"Its query is written in this file, and the builder does not copy a query's body.";case"opaque":return`Its query is ${e.declaration.why}, which the builder does not copy.`;default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function em(e,t){const n=e.tiles[t];if(!n||!ae(n)||Hi(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:i,...s}=structuredClone(n);r={...s,name:oo(e,n.source,n.declaration.from)}}else{const i=e.sources.find(s=>s.name===n.source)??Uc(e,n.source,{unscoped:!0});r={name:oo(e,i.name,n.name),source:i.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}return e.tiles.splice(t+1,0,r),t+1}const hi="self";function tm({open:e,document:t,source:n,givenNames:r,dashboards:i,tileLabel:s,onClose:o,onApply:a}){const{theme:d}=He(),f=d.ui,[c,l]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(b=>b.source===n.name);l((n.dimensions??[]).map(b=>{const y=h.find(w=>w.name===b.name);return{name:b.name,expression:b.expression,to:y?.to??[],given:y?.given??""}}))},[e,n,t]);const u=(h,b)=>l(y=>y.map((w,$)=>{if($!==h)return w;const M={...w};return b(M),M})),p=[hi,...i.filter(h=>h!==hi)],g=h=>h===hi?"This report":h,v=()=>{n&&(a(c.filter(h=>h.to.length>0).map(h=>({source:n.name,name:h.name,expression:h.expression,to:h.to,...h.given?{given:h.given}:{}}))),o())},x=Yt(d.cardBorder),k=(h,b)=>u(h,y=>{b?y.to=y.lastTo?.length?y.lastTo:[hi]:(y.lastTo=y.to,y.to=[])});return m.jsx(aa,{className:`${Ze.dialog} ${Ze.clickableCellsDialog}`,open:e,onClose:o,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[s&&m.jsxs(B,{component:"span",sx:{fontWeight:f.type.label.fontWeight},children:[s," ·"," "]}),"A click on a cell sets a filter to its value, on this report or on the one it opens."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx(Me,{onClick:o,children:"Cancel"}),m.jsx(Me,{variant:"contained",onClick:v,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx(pe,{variant:"body2",sx:{color:d.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx(B,{component:"code",children:n.name})," declares no dimensions of its own in this file. A click is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",m.jsx(B,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx(B,{role:"list","aria-label":"Dimensions",children:c.map((h,b)=>{const y=h.to.length>0;return m.jsxs(B,{role:"listitem",sx:{display:"grid",gridTemplateColumns:{xs:"auto minmax(0, 1fr)",sm:"auto minmax(0, 0.9fr) minmax(0, 1.6fr)"},alignItems:"center",columnGap:1.5,rowGap:1,py:1.25,borderTop:b===0?"none":`1px solid ${x}`},children:[m.jsx(vp,{size:"small",checked:y,onChange:w=>k(b,w.target.checked),slotProps:{input:{"aria-label":`${h.name} is clickable`}}}),m.jsxs(B,{sx:{minWidth:0},children:[m.jsx(B,{sx:{...f.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:nm(h.name)}),m.jsxs(B,{title:h.expression,sx:{...f.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[h.name," is ",h.expression]})]}),y?m.jsxs(tt,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...f.type.control},children:[m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx(Ft,{select:!0,size:"small",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.map(g).join(", ")},onChange:w=>u(b,$=>{const M=w.target.value,T=Array.isArray(M)?M:String(M).split(",").filter(Boolean);T.length===0&&($.lastTo=$.to),$.to=T}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:p.map(w=>m.jsxs(vt,{value:w,children:[m.jsx(Qs,{size:"small",checked:h.to.includes(w),sx:{p:0,mr:1}}),m.jsx(Li,{primary:g(w)})]},w))}),m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs(Ft,{select:!0,size:"small",value:h.given,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0,renderValue:w=>w===""?h.name:String(w)},onChange:w=>u(b,$=>{$.given=w.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx(vt,{value:"",children:m.jsx(Li,{primary:h.name,secondary:"Named like the dimension"})}),r.map(w=>m.jsx(vt,{value:w,children:w},w))]})]}):m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},h.name)})})})}function nm(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const rm=ot(m.jsx("path",{d:"M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 13-4-4h8z"})),im=ot(m.jsx("path",{d:"M11 7H2v2h9zm0 8H2v2h9zm5.34-4L12.8 7.46l1.41-1.41 2.12 2.12 4.24-4.24L22 5.34zm0 8-3.54-3.54 1.41-1.41 2.12 2.12 4.24-4.24L22 13.34z"})),sm=ot(m.jsx("path",{d:"M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V10h14zm0-12H5V6h14zm-7 5h5v5h-5z"})),om=ot(m.jsx("path",{d:"M19.5 9.5c-1.03 0-1.9.62-2.29 1.5h-2.92c-.39-.88-1.26-1.5-2.29-1.5s-1.9.62-2.29 1.5H6.79c-.39-.88-1.26-1.5-2.29-1.5C3.12 9.5 2 10.62 2 12s1.12 2.5 2.5 2.5c1.03 0 1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5s1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5 1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5"})),am=ot(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),lm=ot(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function cm(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of ae(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 qi(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function dm(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Or(e,t){const n=dm(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 ao(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 um(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const hm=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function fm(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=Lc(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 pm=[{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 ur(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 lo=e=>ae(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function mm(e,t){return e.tiles.map(n=>{const r=(ae(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}:qi(t.type)!==void 0?{op:qi(t.type)}:{}}})}function gm(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!lo(s))return;const o=(s.filters??[]).filter(d=>d.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function vm(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 bm(e,t){for(const r of e.tiles){if(!ae(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 co=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function xm({open:e,document:t,control:n,available:r,takenNames:i=[],fieldsFor:s,onApply:o}){const a=S.useRef(n);e&&(a.current=n);const d=e?n:a.current,f=d!==void 0,[c,l]=S.useState({kind:"new"}),[u,p]=S.useState(""),[g,v]=S.useState("select"),[x,k]=S.useState(""),[h,b]=S.useState(""),[y,w]=S.useState([]),[$,M]=S.useState(!1),[T,j]=S.useState(!1),O=E=>t.sources.find(I=>I.name===E.source)?.base??E.source;S.useEffect(()=>{if(e)if(j(n!==void 0),n){l({kind:"existing",name:n.name}),p(n.label??"");const E=mm(t,n);w(E);const I=E.filter(L=>L.include),C=new Set(I.map(L=>L.field));b(C.size===1?I[0].field:n.field??""),M(C.size>1)}else l({kind:"new"}),p(""),v("select"),b(""),k(new Date().toISOString().slice(0,10)),w(t.tiles.map(E=>({include:lo(E),field:""}))),M(!1)},[e,n,t]);const P=S.useMemo(()=>[...(t.localGivens??[]).map(E=>E.name),...r.map(E=>E.name),...i],[t,r,i]),R=S.useMemo(()=>h.trim()?fm(h.trim(),P):"",[h,P]),A=c.kind==="existing"?n??r.find(E=>E.name===c.name):R?{name:R,type:ur({name:R,label:u,kind:g,field:h}).type}:void 0,z=A?.type!==void 0&&!A.type.startsWith("filter<"),q=y.find(E=>E.include)?.op??qi(A?.type),U=(E,I)=>{j(!0),w(C=>C.map((L,ue)=>ue===E?{...L,...I}:L))},D=E=>{j(!0),w(I=>I.map(C=>({...C,op:E})))},N=E=>{const I=qi(E);w(C=>C.map(({op:L,...ue})=>I?{...ue,op:I}:ue))},F=E=>{j(!0),l({kind:"existing",name:E.name}),b(E.field??""),N(E.type)},W=E=>{j(!0),v(E),N(ur({name:"X",label:u,kind:E,field:h}).type)},_=t.tiles.map(lo),Y=_.filter(Boolean).length,G=y.filter((E,I)=>E.include&&_[I]).length,le=t.tiles.filter((E,I)=>(y[I]?.include??!1)&&_[I]&&ae(E)),V=le.length>0?le:t.tiles.filter((E,I)=>_[I]&&ae(E)),H=S.useMemo(()=>{const E=new Map;let I=!1;for(const C of V){const L=s?.(C);if(L){I=!0;for(const ue of L)E.has(ue.name)||E.set(ue.name,ue)}}return I?[...E.values()]:void 0},[y,t.tiles,s]),Z=(()=>{const E=h.trim();for(const I of le){const C=s?.(I);if(!C||C.some(L=>L.name===E))return O(I)}return le[0]?O(le[0]):t.sources[0]?.base})(),ee=E=>{j(!0),w(I=>I.map((C,L)=>({...C,include:E&&_[L]})))},Q=S.useMemo(()=>$?y:y.map(E=>({...E,field:h})),[$,y,h]),ce=E=>{for(const I of V){const C=s?.(I)?.find(L=>L.name===E.trim());if(C?.type)return C.type}},xe=E=>Or(A?.type,E.type),me=(E,I)=>{if(E.trim()==="")return"Pick the field this filter compares.";const C=I?s?.(I):void 0;if(!C)return;const L=C.find(ue=>ue.name===E.trim());if(!L)return`Not a field of ${I?O(I):"the tiles' source"}.`;if(L.type&&!Or(A?.type,L.type))return`${E.trim()} is ${ao(L.type)}; this filter compares ${ao(A?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},te=E=>{if(j(!0),b(E),f||c.kind!=="new")return;const I=ce(E),C=ur({name:"X",label:u,kind:g,field:E}).type;I&&!Or(C,I)&&W(um(I))},fe=E=>{const I=t.tiles[E];return I&&ae(I)?I:void 0},de=Q.map((E,I)=>E.include&&_[I]?me(E.field,fe(I)):void 0),ge=de.every(E=>E===void 0),Pe=T?de:de.map(()=>{}),Ve=T&&!$&&G>0?le.map(E=>me(h,E)).find(Boolean):void 0,Ge=A!==void 0&&ge&&(c.kind==="existing"||h.trim()!==""&&R!==""),Ke=()=>{if(!(!A||!Ge))if(c.kind==="new")o(A.name,Q,ur({name:A.name,label:u.trim()||co(A.name),kind:g,field:h.trim(),...Z?{source:Z}:{},...x?{dateDefault:x}:{}}));else if(n?.origin==="dashboard"&&n.local){const E=u.trim(),I=E!==(n.local.label??"");o(A.name,Q,I?{...n.local,...E?{label:E}:{}}:void 0)}else o(A.name,Q)},Ie=f&&d.origin==="model";return{editing:f,shown:d,fromModel:Ie,source:c,setSource:l,label:u,setLabel:p,kind:g,dateDefault:x,setDateDefault:k,field:h,rows:y,setRows:w,perTile:$,setPerTile:M,newName:R,target:A,valueTyped:z,commonOp:q,setRow:U,setCommonOp:D,pickExisting:F,pickKind:W,bindable:_,bindableCount:Y,included:G,commonFields:H,setAll:ee,accepts:xe,pickField:te,rowProblems:Pe,commonProblem:Ve,canApply:Ge,apply:Ke}}function $l({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:d,autoFocus:f,placeholder:c,inputRef:l,sx:u}){const p=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),g=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return m.jsx(Wp,{freeSolo:!0,size:"small",options:p,inputValue:e,onInputChange:(v,x)=>t(x),value:e,onChange:(v,x)=>t(typeof x=="string"?x:""),disabled:d,disableClearable:!0,renderOption:(v,x)=>S.createElement("li",{...v,key:x},m.jsx(Ml,{type:g.get(x)}),m.jsx(pe,{variant:"body2",sx:{flex:1,ml:1},children:x})),renderInput:v=>m.jsx(Ft,{...v,label:i,placeholder:c,autoFocus:f,...l?{inputRef:l}:{},error:o,helperText:a,InputLabelProps:{...v.InputLabelProps,shrink:!0},InputProps:{...v.InputProps,startAdornment:g.get(e.trim())?m.jsx(B,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(Ml,{type:g.get(e.trim())})}):void 0},inputProps:{...v.inputProps,"aria-label":s}}),sx:u})}const ym=e=>e&&ae(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 report does not write."};function wm({open:e,document:t,control:n,available:r,takenNames:i,fieldsFor:s,onClose:o,onApply:a,onRemove:d}){const{theme:f}=He(),c=f.ui,{editing:l,shown:u,fromModel:p,source:g,setSource:v,label:x,setLabel:k,kind:h,dateDefault:b,setDateDefault:y,field:w,rows:$,setRows:M,perTile:T,setPerTile:j,newName:O,target:P,valueTyped:R,commonOp:A,setRow:z,setCommonOp:q,pickExisting:U,pickKind:D,bindable:N,bindableCount:F,included:W,commonFields:_,setAll:Y,accepts:G,pickField:le,rowProblems:V,commonProblem:H,canApply:Z,apply:ee}=xm({open:e,document:t,control:n,available:r,...i?{takenNames:i}:{},fieldsFor:s,onApply:a}),Q=S.useRef(null),ce=Yt(f.cardBorder),xe=ds(f.cardBorder,f.tileTitle),[me,te]=S.useState(!1),[fe,de]=S.useState(!1);S.useEffect(()=>{e?de(!0):te(!1)},[e]),S.useEffect(()=>{fe&&(de(!1),te(l&&W<F))},[fe]),S.useEffect(()=>{T&&te(!0)},[T]);const ge=_?.find(E=>E.name===w.trim())?.type,Pe=E=>{if(!ge)return;const I=ur({name:"X",label:x,kind:E,field:w}).type;return Or(I,ge)?void 0:`${w.trim()} is ${ao(ge)}, which this control cannot filter.`},Ve=x.trim()||(O?co(O):"Filter"),Ge=h==="number"?"Any":h==="date"?b?new Date(`${b}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",Ke={..._i(ce,c),alignSelf:"flex-start","& .MuiToggleButton-root":{..._i(ce,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ie=(E,I,C)=>m.jsx(Ft,{select:!0,size:"small",label:"Compares",value:E??">=",onChange:L=>I(L.target.value),inputProps:{"aria-label":C},sx:{width:130},children:hm.filter(L=>L.op!=="~").map(L=>m.jsx(vt,{value:L.op,children:L.label},L.op))});return m.jsx(aa,{className:`${Ze.dialog} ${Ze.filterDialog}`,open:e,onClose:o,...l?{}:{initialFocus:Q},title:l?u.label??u.name:"Add a filter",description:l?m.jsxs(m.Fragment,{children:[m.jsxs(B,{component:"span",sx:{fontFamily:c.font.mono},children:["$",u.name]}),p?" · declared in the model, so its label and options are set there":" · declared in this report"]}):"A filter on the page, and the tiles it filters.",actions:m.jsxs(m.Fragment,{children:[l&&m.jsx(Me,{color:"error",startIcon:m.jsx(pp,{}),onClick:()=>d(u.name),sx:E=>({mr:"auto",color:fp(E)}),children:"Remove filter"}),m.jsx(Me,{onClick:o,children:"Cancel"}),m.jsx(kt,{title:Z||P===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx(Me,{variant:"contained",onClick:ee,disabled:!Z,children:l?"Apply":"Add filter"})})})]}),children:m.jsxs(tt,{sx:{gap:2.5,pt:1},children:[!l&&r.length>0&&m.jsxs(Fc,{exclusive:!0,size:"small",value:g.kind,onChange:(E,I)=>{I==="new"?v({kind:"new"}):I==="existing"&&r[0]&&U(r[0])},"aria-label":"Where the filter comes from",sx:Ke,children:[m.jsx(to,{value:"new",children:"New in this report"}),m.jsx(to,{value:"existing",children:"From the model"})]}),!l&&g.kind==="existing"?m.jsx(Ft,{select:!0,size:"small",label:"Filter",value:g.name,onChange:E=>{const I=r.find(C=>C.name===E.target.value);I&&U(I)},children:r.map(E=>m.jsxs(vt,{value:E.name,children:[E.label??E.name,m.jsxs(pe,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",E.name]})]},E.name))}):null,m.jsxs(B,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:p?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!T&&m.jsx($l,{value:w,onChange:le,fields:_,accepts:G,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:Q,error:H!==void 0,helperText:H??(!l&&O?`Declared as $${O}`:void 0)}),!p&&m.jsx(Ft,{size:"small",label:"Label",placeholder:O?co(O):"",value:x,onChange:E=>k(E.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),R&&!T&&Ie(A,q,"Comparison"),!l&&g.kind==="new"&&m.jsxs(B,{children:[m.jsx(jl,{children:"Control"}),m.jsx(B,{role:"radiogroup","aria-label":"Filter kind",sx:{display:"grid",gridTemplateColumns:{xs:"repeat(3, minmax(0, 1fr))",sm:"repeat(5, minmax(0, 1fr))"},gap:1},children:pm.map(E=>{const I=E.kind===h,C=Pe(E.kind);return m.jsx(kt,{title:C??E.hint,describeChild:!0,children:m.jsxs(Dc,{role:"radio","aria-checked":I,"aria-label":E.label,"aria-disabled":C!==void 0,onClick:()=>{C===void 0&&D(E.kind)},sx:L=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${I?f.accent:ce}`,boxShadow:I?`0 0 0 1px ${f.accent}`:"none",bgcolor:I?`color-mix(in srgb, ${f.accent} 6%, ${L.palette.background.paper})`:L.palette.background.paper,color:I?f.accent:L.palette.text.secondary,opacity:C?.45:1,cursor:C?"default":"pointer",transition:`border-color ${Fe}, background-color ${Fe}`,"&:hover":C||I?{}:{borderColor:xe}}),children:[m.jsx(Sm,{kind:E.kind}),m.jsx(B,{component:"span",sx:{...c.type.caption,fontWeight:I?600:500,color:I?f.accent:"text.primary",textAlign:"center"},children:km[E.kind]})]})},E.kind)})}),h==="date"&&m.jsx(Ft,{size:"small",type:"date",label:"Starts at",value:b,onChange:E=>y(E.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs(B,{sx:{border:`1px solid ${ce}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs(tt,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(lm,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs(pe,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx(B,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:W===F&&F>0?`Applies to all ${W} tile${W===1?"":"s"}`:`Applies to ${W} of ${F} tile${F===1?"":"s"}`}),!T&&w.trim()!==""&&W>0&&m.jsxs(B,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx(B,{component:"span",sx:{...c.type.code},children:w.trim()})]})]}),!T&&m.jsx(Me,{size:"small","aria-expanded":me,onClick:()=>te(E=>!E),children:me?"Done choosing":"Choose tiles"})]}),m.jsx(no,{in:me,unmountOnExit:!0,children:m.jsxs(B,{sx:{borderTop:`1px solid ${ce}`,px:.5,pb:1},children:[m.jsxs(tt,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx(Qs,{size:"small",checked:F>0&&W===F,indeterminate:W>0&&W<F,disabled:F===0,onChange:E=>Y(E.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx(pe,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx(Me,{size:"small",onClick:()=>{T||M(E=>E.map(I=>({...I,field:w}))),j(E=>!E)},children:T?"Same field for all":"Adjust per tile"})]}),m.jsx(tt,{sx:{gap:T?1:0},children:t.tiles.map((E,I)=>{if(!ae(E))return null;const C=$[I],L=E.label??E.name,ue=T?V[I]:void 0;return m.jsxs(tt,{direction:"row",sx:{gap:1,alignItems:T?"flex-start":"center",opacity:N[I]?1:.6},children:[m.jsx(Qs,{size:"small",disabled:!N[I],checked:(C?.include??!1)&&N[I],inputProps:{"aria-label":`Filter ${L}`},onChange:K=>z(I,{include:K.target.checked})}),m.jsx(pe,{variant:"body2",sx:{flex:1,minWidth:0,pt:T?1:0},noWrap:!0,children:L}),N[I]?T&&m.jsxs(m.Fragment,{children:[R&&Ie(C?.op,K=>z(I,{op:K}),`Comparison for ${L}`),m.jsx($l,{value:C?.field??"",onChange:K=>z(I,{field:K}),fields:s?.(E),accepts:G,label:"Field",ariaLabel:`Field for ${L}`,disabled:!C?.include,error:ue!==void 0,helperText:ue,sx:{width:220,pr:1}})]}):m.jsx(pe,{variant:"caption",sx:{color:f.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:ym(t.tiles[I]).reason})]},`${E.source}.${E.name}`)})})]})})]}),W===0&&m.jsx(pe,{variant:"caption",sx:{color:"warning.main",display:"block",mt:-1.5},children:"No tile is ticked, so this control will not appear on the report."}),!p&&m.jsxs(B,{children:[m.jsx(jl,{children:"Preview"}),m.jsx(B,{sx:E=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:E.palette.action.hover}),children:m.jsxs(B,{"aria-hidden":!0,sx:E=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${ce}`,bgcolor:E.palette.background.paper,...c.type.control}),children:[m.jsx(B,{component:"span",sx:{color:"text.secondary"},children:Ve}),m.jsx(B,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:Ge}),m.jsx(ta,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function jl({children:e}){const t=He().theme.ui;return m.jsx(pe,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const km={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function Sm({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(rm,{sx:t});case"multiselect":return m.jsx(im,{sx:t});case"text":return m.jsx(am,{sx:t});case"number":return m.jsx(om,{sx:t});case"date":return m.jsx(sm,{sx:t})}}function Ml({type:e}){const t=e?.replace(/_type$/,""),n=t==="string"?"Abc":t==="number"?"#":t==="date"||t==="timestamp"?"Date":t==="boolean"?"T/F":void 0,r=He().theme.ui;return n?m.jsx(B,{component:"span","aria-hidden":!0,sx:i=>({fontFamily:r.font.mono,fontSize:10,fontWeight:r.type.label.fontWeight,color:i.palette.text.secondary,bgcolor:i.palette.action.hover,borderRadius:"4px",px:.5,py:.25,minWidth:22,textAlign:"center",flex:"none"}),children:n}):null}const $m=ot(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function Vc(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const d=structuredClone(a);return o(d),d}),apply:o=>{if(i===void 0)return;const a=structuredClone(i);o(a),s(a),JSON.stringify(a)!==JSON.stringify(e)&&n(a)},close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const jm=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.`,Mm="Declared on its source, so its chart is set in the model.";function Cm({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:i,onDuplicate:s,duplicateBlocked:o,view:a}){const{theme:d}=He(),f=d.ui,{draft:c,apply:l,close:u}=Vc(t,e!==null,r,n),[p,g]=S.useState(void 0),v=c!==void 0&&ae(c)?c:void 0,x=v!==void 0&&v.declaration.kind!=="inherited",k=P=>l(R=>{ae(R)&&P(R)}),h=S.useRef(void 0),b=e!==null;S.useEffect(()=>{b?h.current=t&&ae(t)?t.chart:void 0:g(void 0)},[b]);const y=v?.chart??"default",w=qc(a,y),$=v?x?v.chart==="custom"?jm(v.chartLines):void 0:Mm:void 0,M=P=>k(R=>{const A=h.current;P===(A??"default")?(A===void 0?delete R.chart:R.chart=A,delete R.chartCarried):(R.chart=P,a?R.chartCarried=a.chart?[a.chart]:[]:delete R.chartCarried)}),T=x?i?void 0:"Its source declares no dimension a click could filter by.":void 0,j=P=>R=>g({kind:P,anchor:R.currentTarget}),O=(P,R,A)=>m.jsxs(m.Fragment,{children:[m.jsx(Li,{primary:P,...A?{secondary:A}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),R&&m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",ml:2},children:R})]});return m.jsxs(m.Fragment,{children:[m.jsxs(zi,{className:Ze.menu,open:e!==null&&c!==void 0,anchorEl:e,onClose:u,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":v?`${v.source} ${v.name}`:"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:f.radius.menu,border:`1px solid ${Yt(d.cardBorder)}`,boxShadow:f.shadow.menu}}},children:[v&&m.jsxs(vt,{"aria-haspopup":"menu","aria-expanded":p?.kind==="chart",disabled:$!==void 0,onClick:j("chart"),onKeyDown:P=>{P.key==="ArrowRight"&&$===void 0&&g({kind:"chart",anchor:P.currentTarget})},children:[O("Chart",$?void 0:w.find(P=>P.value===y)?.label,$),m.jsx($m,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),x&&m.jsx(vt,{"aria-haspopup":"dialog",disabled:T!==void 0,onClick:()=>{u(),i?.()},children:O("Clickable cells…",void 0,T)}),v&&s&&m.jsx(vt,{disabled:o!==void 0,onClick:()=>{u(),s()},children:O("Duplicate",void 0,o)}),v?.declaration.kind==="opaque"&&m.jsxs(pe,{variant:"body2",sx:{color:d.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",v.declaration.why,", so a filter has no single place to go."]}),v&&m.jsx(Nr,{}),v&&m.jsxs(B,{"aria-hidden":!0,sx:{px:2,py:.5,...f.type.code,color:"text.secondary"},children:[v.source," → ",v.name]})]}),m.jsx(zi,{className:Ze.menu,open:p?.kind==="chart",anchorEl:p?.anchor??null,onClose:()=>g(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:P=>{P.key==="ArrowLeft"&&(P.preventDefault(),g(void 0))}},children:w.filter(P=>P.value!=="custom").map(P=>m.jsxs(vt,{role:"menuitemradio","aria-checked":P.value===y,disabled:P.disabled===!0,onClick:()=>{M(P.value),g(void 0)},children:[m.jsx(Li,{primary:P.label,...P.reason?{secondary:P.reason}:{}}),P.value===y&&m.jsx(mp,{sx:{minWidth:0,ml:2},children:m.jsx(oa,{fontSize:"small",sx:{color:d.accent}})})]},P.value))})]})}const Nn=e=>e.label??gp(`${e.source} -> ${e.name}`);function Em({editor:e,catalog:t,columns:n,dashboards:r,bindings:i,tiles:s,drillSource:o,setDrillSource:a,exitDialog:d,renderViewPreview:f,takenGivenNames:c}){const{filterDialog:l,setFilterDialog:u}=i,{menu:p,setMenu:g}=s,[v,x]=S.useState(),k=p===void 0?void 0:e.document.tiles[p.index],h=k&&ae(k)?k:void 0,b=(()=>{if(!h||!t)return;const y=e.document.sources.find($=>$.name===h.source)?.base??h.source,w=h.declaration.kind==="reference"?h.declaration.from:h.name;return t.sources.find($=>$.name===y)?.views.find($=>$.name===w)})();return m.jsxs(m.Fragment,{children:[m.jsx(wm,{open:l!==void 0,document:e.document,...l?.control?{control:l.control}:{},available:i.available,...c?{takenNames:c}:{},...t?{fieldsFor:i.fieldsFor}:{},onClose:()=>u(void 0),onApply:i.applyFilter,onRemove:i.dropControl}),m.jsx(Cm,{anchor:p?.anchor??null,tile:p===void 0?void 0:e.document.tiles[p.index],onClose:()=>g(void 0),onCommit:y=>{const w=p?.index;w!==void 0&&e.update($=>{$.tiles[w]=y})},view:b,onDuplicate:()=>{p&&s.duplicate(p.index)},...h&&Hi(h)!==void 0?{duplicateBlocked:Hi(h)}:{},...(e.document.sources.find(y=>y.name===h?.source)?.dimensions?.length??0)>0?{onDrills:()=>{x(h?Nn(h):void 0),a(h?.source)}}:{}}),m.jsx(tm,{open:o!==void 0,document:e.document,source:e.document.sources.find(y=>y.name===o),givenNames:i.controlList.map(y=>y.name),dashboards:r??[],...v?{tileLabel:v}:{},onClose:()=>a(void 0),onApply:y=>e.update(w=>{const $=[...(w.drills??[]).filter(M=>M.source!==o),...y];$.length===0?delete w.drills:w.drills=$})}),m.jsx(Tf,{...d}),m.jsx(Zp,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText,...f?{renderPreview:f}:{}})]})}var Om=Symbol.for("preact-signals");function us(){if(Et>1)Et--;else{var e,t=!1;for((function(){var i=Vi;for(Vi=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();Tr!==void 0;){var n=Tr;for(Tr=void 0,Ui++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Kc(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(Ui=0,Et--,t)throw e}}function je(e){if(Et>0)return e();uo=++Dm,Et++;try{return e()}finally{us()}}var Dr,ye=void 0;function re(e){var t=ye,n=Dr;ye=void 0,Dr=void 0;try{return e()}finally{ye=t,Dr=n}}var Tr=void 0,Et=0,Ui=0,Dm=0,uo=0,Vi=void 0,Gi=0;function Gc(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 Qe(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}Qe.prototype.brand=Om;Qe.prototype.h=function(){return!0};Qe.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:re(function(){var r;(r=t.W)==null||r.call(t)}))};Qe.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&&re(function(){var i;(i=t.Z)==null||i.call(t)}))}};Qe.prototype.subscribe=function(e){var t=this;return ft(function(){var n=t.value;re(function(){return e(n)})},{name:"sub"})};Qe.prototype.valueOf=function(){return this.value};Qe.prototype.toString=function(){return this.value+""};Qe.prototype.toJSON=function(){return this.value};Qe.prototype.peek=function(){var e=this;return re(function(){return e.value})};Object.defineProperty(Qe.prototype,"value",{get:function(){var e=Gc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ui>100)throw new Error("Cycle detected");(function(n){Et!==0&&Ui===0&&n.l!==uo&&(n.l=uo,Vi={S:n,v:n.v,i:n.i,o:Vi})})(this),this.v=e,this.i++,Gi++,Et++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{us()}}}});function Kn(e,t){return new Qe(e,t)}function Kc(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 Yc(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 Xc(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 fn(e,t){Qe.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Gi-1,this.f=4}fn.prototype=new Qe;fn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Gi))return!0;if(this.g=Gi,this.f|=1,this.i>0&&!Kc(this))return this.f&=-2,!0;var e=ye;try{Yc(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,Xc(this),this.f&=-2,!0};fn.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)}Qe.prototype.S.call(this,e)};fn.prototype.U=function(e){if(this.t!==void 0&&(Qe.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)}};fn.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(fn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Gc(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 fn(e,t)}function Jc(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Et++;var n=ye;ye=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,da(e),r}finally{ye=n,us()}}}function da(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Jc(e)}function Tm(e){if(ye!==this)throw new Error("Out-of-order effect");Xc(this),ye=e,this.f&=-2,8&this.f&&da(this),us()}function Yn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Dr&&Dr.push(this)}Yn.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()}};Yn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Jc(this),Yc(this),Et++;var e=ye;return ye=this,Tm.bind(this,e)};Yn.prototype.N=function(){2&this.f||(this.f|=2,this.u=Tr,Tr=this)};Yn.prototype.d=function(){this.f|=8,1&this.f||da(this)};Yn.prototype.dispose=function(){this.d()};function ft(e,t){var n=new Yn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Am=Object.create,ua=Object.defineProperty,Rm=Object.defineProperties,Pm=Object.getOwnPropertyDescriptor,Im=Object.getOwnPropertyDescriptors,El=Object.getOwnPropertySymbols,Wm=Object.prototype.hasOwnProperty,Nm=Object.prototype.propertyIsEnumerable,zm=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Xn=e=>{throw TypeError(e)},ho=(e,t,n)=>t in e?ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Lm=(e,t)=>{for(var n in t||(t={}))Wm.call(t,n)&&ho(e,n,t[n]);if(El)for(var n of El(t))Nm.call(t,n)&&ho(e,n,t[n]);return e},Fm=(e,t)=>Rm(e,Im(t)),Ol=(e,t)=>ua(e,"name",{value:t,configurable:!0}),Bm=e=>{var t;return[,,,Am((t=void 0)!=null?t:null)]},Zc=["class","method","getter","setter","accessor","field","value","get","set"],hr=e=>e!==void 0&&typeof e!="function"?Xn("Function expected"):e,_m=(e,t,n,r,i)=>({kind:Zc[e],name:t,metadata:r,addInitializer:s=>n._?Xn("Already initialized"):i.push(hr(s||null))}),Qc=(e,t)=>ho(t,zm("metadata"),e[3]),Jt=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Jn=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=Zc[l+5],x=l>3&&(e[g-1]=[]),k=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&Pm(l<4?i:{get[n](){return lt(this,s)},set[n](y){return zt(this,s,y)}},n));l?p&&l<4&&Ol(s,(l>2?"set ":l>1?"get ":"")+n):Ol(i,n);for(var b=r.length-1;b>=0;b--)f=_m(l,n,d={},e[3],k),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>Hm(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?lt:qm)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,w)=>zt(y,i,w,l^4?s:h.set):(y,w)=>y[n]=w)),a=(0,r[b])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?hr(a)&&(l>4?x.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?Xn("Object expected"):(hr(o=a.get)&&(h.get=o),hr(o=a.set)&&(h.set=o),hr(o=a.init)&&x.unshift(o));return l||Qc(e,i),h&&ua(i,n,h),p?l^4?s:h:i},ha=(e,t,n)=>t.has(e)||Xn("Cannot "+n),Hm=(e,t)=>Object(t)!==t?Xn('Cannot use the "in" operator on this value'):e.has(t),lt=(e,t,n)=>(ha(e,t,"read from private field"),n?n.call(e):t.get(e)),fr=(e,t,n)=>t.has(e)?Xn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),zt=(e,t,n,r)=>(ha(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),qm=(e,t,n)=>(ha(e,t,"access private method"),n);function fo(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 mt(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)=>!mt(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=>!mt(e[i],t[i]))}return!1}function ie({get:e},t){return{init(n){return Kn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ee(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=fo(e.bind(this)),n.set(this,r)),r.value}}function Ds(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,Fm(Lm({},i),{enumerable:e}))})}}function Xr(...e){const t=e.map(n=>ft(n));return()=>t.forEach(n=>n())}var ed,td,nd,rd,id,sd,Ye,fa,Ts,po,mo,qe,pa,As,od,go,ma,Rs,vo,bo;sd=[ie],id=[ie],rd=[ie],nd=[Ds()],td=[Ds()],ed=[Ds()];var pn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Jt(Ye,5,this),fr(this,qe),fr(this,fa,Jt(Ye,8,this)),Jt(Ye,11,this),fr(this,pa,Jt(Ye,12,this)),Jt(Ye,15,this),fr(this,ma,Jt(Ye,16,this)),Jt(Ye,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return lt(this,qe,vo)}get initial(){return lt(this,qe,po)}get previous(){return lt(this,qe,od)}set current(e){const t=re(()=>lt(this,qe,vo));e&&t&&this.equals(t,e)||je(()=>{lt(this,qe,po)||zt(this,qe,e,mo),zt(this,qe,t,go),zt(this,qe,e,bo)})}reset(e=this.defaultValue){je(()=>{zt(this,qe,void 0,go),zt(this,qe,e,mo),zt(this,qe,e,bo)})}};Ye=Bm();fa=new WeakMap;qe=new WeakSet;pa=new WeakMap;ma=new WeakMap;Ts=Jn(Ye,20,"#initial",sd,qe,fa),po=Ts.get,mo=Ts.set;As=Jn(Ye,20,"#previous",id,qe,pa),od=As.get,go=As.set;Rs=Jn(Ye,20,"#current",rd,qe,ma),vo=Rs.get,bo=Rs.set;Jn(Ye,2,"current",nd,pn);Jn(Ye,2,"initial",td,pn);Jn(Ye,2,"previous",ed,pn);Qc(Ye,pn);function Ps(e){return re(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Zt,Um=class{constructor(){fr(this,Zt,new WeakMap)}get(e,t){var n;return e?(n=lt(this,Zt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return lt(this,Zt).has(e)||lt(this,Zt).set(e,new Map),(r=lt(this,Zt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=lt(this,Zt).get(e))==null?void 0:t.clear():void 0}};Zt=new WeakMap;var Vm=Object.create,ad=Object.defineProperty,Gm=Object.getOwnPropertyDescriptor,Dl=Object.getOwnPropertySymbols,Km=Object.prototype.hasOwnProperty,Ym=Object.prototype.propertyIsEnumerable,ld=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),hs=e=>{throw TypeError(e)},Tl=Math.pow,xo=(e,t,n)=>t in e?ad(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xm=(e,t)=>{for(var n in t||(t={}))Km.call(t,n)&&xo(e,n,t[n]);if(Dl)for(var n of Dl(t))Ym.call(t,n)&&xo(e,n,t[n]);return e},Jm=e=>{var t;return[,,,Vm((t=e?.[ld("metadata")])!=null?t:null)]},cd=["class","method","getter","setter","accessor","field","value","get","set"],dd=e=>e!==void 0&&typeof e!="function"?hs("Function expected"):e,Zm=(e,t,n,r,i)=>({kind:cd[e],name:t,metadata:r,addInitializer:s=>n._?hs("Already initialized"):i.push(dd(s||null))}),Qm=(e,t)=>xo(t,ld("metadata"),e[3]),eg=(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},ud=(e,t,n,r,i,s)=>{for(var o,a,d,f,c=t&7,l=!1,u=!1,p=2,g=cd[c+5],v=e[p]||(e[p]=[]),x=(i=i.prototype,Gm(i,n)),k=r.length-1;k>=0;k--)d=Zm(c,n,a={},e[3],v),d.static=l,d.private=u,f=d.access={has:h=>n in h},f.get=h=>h[n],o=(0,r[k])(x[g],d),a._=1,dd(o)&&(x[g]=o);return x&&ad(i,n,x),i},hd=(e,t,n)=>t.has(e)||hs("Cannot "+n),tg=(e,t,n)=>(hd(e,t,"read from private field"),t.get(e)),ng=(e,t,n)=>t.has(e)?hs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rg=(e,t,n,r)=>(hd(e,t,"write to private field"),t.set(e,n),n),ct=class yo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new yo(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 yo(t,n)}},$t=class Qt{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,d=new Qt(i+t,r+n,s,o);return d.scale=Xm({},a),d}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new ct((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Qt))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 Qt?ig(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 Qt(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],d=o==="x"?s.left:s.top,f=o==="x"?s.width:s.height;return a=="start"?d:a=="end"?d+f:d+f/2};return ct.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Qt.from(t).intersectionRatio(Qt.from(n))}};function ig(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 fd,pd,wo,$i,Jr,fs=class extends(wo=pn,pd=[Ee],fd=[Ee],wo){constructor(e){const t=ct.from(e);super(t,(n,r)=>ct.equals(n,r)),eg(Jr,5,this),ng(this,$i,0),this.velocity={x:0,y:0}}get delta(){return ct.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=ct.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-tg(this,$i),o=a=>Math.round(a/s*100);je(()=>{rg(this,$i,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(ct.from(e)),this.velocity={x:0,y:0}}};Jr=Jm(wo);$i=new WeakMap;ud(Jr,2,"delta",pd,fs);ud(Jr,2,"direction",fd,fs);Qm(Jr,fs);function ko({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(Tl(r,2)+Tl(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 md=(e=>(e.Horizontal="x",e.Vertical="y",e))(md||{}),gd=Object.values(md),sg=Object.create,ga=Object.defineProperty,og=Object.defineProperties,ag=Object.getOwnPropertyDescriptor,lg=Object.getOwnPropertyDescriptors,Ki=Object.getOwnPropertySymbols,vd=Object.prototype.hasOwnProperty,bd=Object.prototype.propertyIsEnumerable,xd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},So=(e,t,n)=>t in e?ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,va=(e,t)=>{for(var n in t||(t={}))vd.call(t,n)&&So(e,n,t[n]);if(Ki)for(var n of Ki(t))bd.call(t,n)&&So(e,n,t[n]);return e},ba=(e,t)=>og(e,lg(t)),Al=(e,t)=>ga(e,"name",{value:t,configurable:!0}),yd=(e,t)=>{var n={};for(var r in e)vd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ki)for(var r of Ki(e))t.indexOf(r)<0&&bd.call(e,r)&&(n[r]=e[r]);return n},Qn=e=>{var t;return[,,,sg((t=e?.[xd("metadata")])!=null?t:null)]},wd=["class","method","getter","setter","accessor","field","value","get","set"],pr=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,cg=(e,t,n,r,i)=>({kind:wd[e],name:t,metadata:r,addInitializer:s=>n._?Zn("Already initialized"):i.push(pr(s||null))}),mn=(e,t)=>So(t,xd("metadata"),e[3]),J=(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},se=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=wd[l+5],x=l>3&&(e[g-1]=[]),k=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&ag(l<4?i:{get[n](){return Ce(this,s)},set[n](y){return st(this,s,y)}},n));l?p&&l<4&&Al(s,(l>2?"set ":l>1?"get ":"")+n):Al(i,n);for(var b=r.length-1;b>=0;b--)f=cg(l,n,d={},e[3],k),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>dg(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?Ce:kd)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,w)=>st(y,i,w,l^4?s:h.set):(y,w)=>y[n]=w)),a=(0,r[b])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?pr(a)&&(l>4?x.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?Zn("Object expected"):(pr(o=a.get)&&(h.get=o),pr(o=a.set)&&(h.set=o),pr(o=a.init)&&x.unshift(o));return l||mn(e,i),h&&ga(i,n,h),p?l^4?s:h:i},xa=(e,t,n)=>t.has(e)||Zn("Cannot "+n),dg=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),Ce=(e,t,n)=>(xa(e,t,"read from private field"),n?n.call(e):t.get(e)),he=(e,t,n)=>t.has(e)?Zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(xa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),kd=(e,t,n)=>(xa(e,t,"access private method"),n);function Sd(e,t){return{plugin:e,options:t}}function Zr(e){return t=>Sd(e,t)}function zr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var $d,Lr,ya,ji;$d=[ie];var Ue=class{constructor(e,t){this.manager=e,this.options=t,he(this,ya,J(Lr,8,this,!1)),J(Lr,11,this),he(this,ji,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return re(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=ft(e.bind(this));return Ce(this,ji).add(t),t}destroy(){Ce(this,ji).forEach(e=>e())}static configure(e){return Sd(this,e)}};Lr=Qn(null);ya=new WeakMap;ji=new WeakMap;se(Lr,4,"disabled",$d,Ue,ya);mn(Lr,Ue);var Qr=class extends Ue{},Mi,Is=class{constructor(e){this.manager=e,this.instances=new Map,he(this,Mi,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(zr).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,Mi))if(!n.includes(r)){if(r.prototype instanceof Qr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);st(this,Mi,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()}};Mi=new WeakMap;function ug(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var fi=[],Mn,Cn,hg=class extends Ue{constructor(e){super(e),he(this,Mn),he(this,Cn),this.computeCollisions=this.computeCollisions.bind(this),st(this,Cn,Kn(fi)),this.destroy=Xr(()=>{const t=this.computeCollisions(),n=re(()=>this.manager.dragOperation.position.current);if(t!==fi){const r=Ce(this,Mn);if(st(this,Mn,n),r&&n.x==r.x&&n.y==r.y)return}else st(this,Mn,void 0);Ce(this,Cn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){re(()=>{e?Ce(this,Cn).value=this.computeCollisions():st(this,Mn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return fi;const a=[],d=[];for(const f of e??n.droppables){if(f.disabled||i&&!f.accepts(i))continue;const c=t??f.collisionDetector;if(!c)continue;d.push(f),f.shape;const l=re(()=>c({droppable:f,dragOperation:r}));l&&(f.collisionPriority!=null&&(l.priority=f.collisionPriority),a.push(l))}return d.length===0?fi:(a.sort(ug),a)}get collisions(){return Ce(this,Cn).value}};Mn=new WeakMap;Cn=new WeakMap;var jd,Md,Cd,wa,Ed,gt,ka,Rn,Sa,$a;Cd=[ie],Md=[ie],jd=[ie];var Dt=class en{constructor(t,n){he(this,ka,J(gt,8,this)),J(gt,11,this),he(this,Rn),he(this,Sa,J(gt,12,this)),J(gt,15,this),he(this,$a,J(gt,16,this)),J(gt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let d=i;st(this,Rn,Kn(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var f;return[()=>{const{id:c,manager:l}=this;if(c!==d)return d=c,l?.registry.register(this),()=>l?.registry.unregister(this)},...(f=r?.())!=null?f:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=Ce(this,Rn).value;return(n=(t=en.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=en.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Ce(this,Rn).peek();t!==i&&(en.pendingIdChanges||(en.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return kd(s=en,wa,Ed).call(s)})),en.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)}};gt=Qn(null);wa=new WeakSet;Ed=function(){const e=Dt.pendingIdChanges;Dt.pendingIdChanges=null,e&&je(()=>{for(const[t,n]of e)Ce(t,Rn).value=n})};ka=new WeakMap;Rn=new WeakMap;Sa=new WeakMap;$a=new WeakMap;se(gt,4,"manager",Cd,Dt,ka);se(gt,4,"data",Md,Dt,Sa);se(gt,4,"disabled",jd,Dt,$a);he(Dt,wa);mn(gt,Dt);Dt.pendingIdChanges=null;var ps=Dt,Rl=class{constructor(){this.map=Kn(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,d]of n)if(d===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=Xr(...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}},Od,Dd,Td,Ad,Rd,Pd,$o,Xe,ja,Ma,Ca,jt=class extends($o=ps,Pd=[ie],Rd=[ie],Ad=[ie],Td=[Ee],Dd=[Ee],Od=[Ee],$o){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,d=yd(n,["modifiers","type","sensors","plugins","effects"]);super(ba(va({},d),{effects:()=>{var f;return[...(f=a?.())!=null?f:[],()=>{const{manager:c,plugins:l}=this;if(!(!c||!l))for(const u of l){const{plugin:p}=zr(u);c.registry.plugins.register(p)}}]}}),t),J(Xe,5,this),he(this,ja,J(Xe,8,this)),J(Xe,11,this),he(this,Ma,J(Xe,12,this)),J(Xe,15,this),he(this,Ca,J(Xe,16,this,this.isDragSource?"dragging":"idle")),J(Xe,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=d.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=zr(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}};Xe=Qn($o);ja=new WeakMap;Ma=new WeakMap;Ca=new WeakMap;se(Xe,4,"type",Pd,jt,ja);se(Xe,4,"modifiers",Rd,jt,Ma);se(Xe,4,"status",Ad,jt,Ca);se(Xe,2,"isDropping",Td,jt);se(Xe,2,"isDragging",Dd,jt);se(Xe,2,"isDragSource",Od,jt);mn(Xe,jt);var Id,Wd,Nd,zd,Ld,Fd,jo,We,Ea,Oa,Da,Ta,Aa,Mt=class extends(jo=ps,Fd=[ie],Ld=[ie],zd=[ie],Nd=[ie],Wd=[ie],Id=[Ee],jo){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=yd(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),J(We,5,this),he(this,Ea,J(We,8,this)),J(We,11,this),he(this,Oa,J(We,12,this)),J(We,15,this),he(this,Da,J(We,16,this)),J(We,19,this),he(this,Ta,J(We,20,this)),J(We,23,this),he(this,Aa,J(We,24,this)),J(We,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}};We=Qn(jo);Ea=new WeakMap;Oa=new WeakMap;Da=new WeakMap;Ta=new WeakMap;Aa=new WeakMap;se(We,4,"accept",Fd,Mt,Ea);se(We,4,"type",Ld,Mt,Oa);se(We,4,"collisionDetector",zd,Mt,Da);se(We,4,"collisionPriority",Nd,Mt,Ta);se(We,4,"shape",Wd,Mt,Aa);se(We,2,"isDropTarget",Id,Mt);mn(We,Mt);var fg=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)}},pg=class extends fg{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Ci(e,t=!0){let n=!1;return ba(va({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var mg=class extends Qr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=Xr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||ps.pendingIdChanges)return;const o=Ci({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;re(()=>{var d;a?.id!==((d=e.dragOperation.target)==null?void 0:d.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},er=(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))(er||{}),tr=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(tr||{}),Bd,_d,Hd,qd,Ud,Vd,Gd,ht,Ra;Gd=[ie],Vd=[Ee],Ud=[Ee],qd=[Ee],Hd=[Ee],_d=[Ee],Bd=[Ee];var At=class{constructor(){J(ht,5,this),he(this,Ra,J(ht,8,this,"idle")),J(ht,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}};ht=Qn(null);Ra=new WeakMap;se(ht,4,"value",Gd,At,Ra);se(ht,2,"current",Vd,At);se(ht,2,"idle",Ud,At);se(ht,2,"initializing",qd,At);se(ht,2,"initialized",Hd,At);se(ht,2,"dragging",_d,At);se(ht,2,"dropped",Bd,At);mn(ht,At);var gg=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 re(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Ci({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return re(()=>{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=Ci({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 re(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Ci({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,d,f,c,l;if(o.defaultPrevented)return;const u=(l=e.to)!=null?l:{x:r.position.current.x+((d=(a=e.by)==null?void 0:a.x)!=null?d:0),y:r.position.current.y+((c=(f=e.by)==null?void 0:f.y)!=null?c:0)};r.position.current=u})})}stop(e={}){return re(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const d={resume:()=>{},abort:()=>{}};return s=new Promise((f,c)=>{d.resume=f,d.abort=c}),d};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const d=re(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),f=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(d){const{source:c}=r,l=ft(()=>{c?.status==="idle"&&(l(),f())})}else this.manager.renderer.rendering.then(f)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),s?s.then(a).catch(()=>r.reset()):a()})}},_n=class extends Ue{constructor(e,t){super(e,t),this.manager=e,this.options=t}},vg=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)}},Ei,Kd=class{constructor(e){this.options=e,he(this,Ei)}set controller(e){st(this,Ei,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ce(this,Ei))==null||t.activate(e)}};Ei=new WeakMap;var Pl=class extends Ue{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},bg=class{constructor(e){this.draggables=new Rl,this.droppables=new Rl,this.plugins=new Is(e),this.sensors=new Is(e),this.modifiers=new Is(e)}register(e,t){if(e instanceof jt)return this.draggables.register(e.id,e);if(e instanceof Mt)return this.droppables.register(e.id,e);if(e.prototype instanceof Pl)return this.modifiers.register(e,t);if(e.prototype instanceof _n)return this.sensors.register(e,t);if(e.prototype instanceof Ue)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof ps)return e instanceof jt?this.draggables.unregister(e.id,e):e instanceof Mt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Pl)return this.modifiers.unregister(e);if(e.prototype instanceof _n)return this.sensors.unregister(e);if(e.prototype instanceof Ue)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()}},Yd,Xd,Jd,Zd,Qd,eu,tu,nu,ru,mr,Oi,En,$e,Pa,Ia,Wa,Na,za,gr;ru=[Ee],nu=[ie],tu=[ie],eu=[ie],Qd=[ie],Zd=[ie],Jd=[Ee],Xd=[Ee],Yd=[Ee];var yt=class{constructor(e){J($e,5,this),he(this,mr),he(this,Oi),he(this,En,new pn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new At,he(this,Pa,J($e,8,this,!1)),J($e,11,this),he(this,Ia,J($e,12,this,null)),J($e,15,this),he(this,Wa,J($e,16,this,null)),J($e,19,this),he(this,Na,J($e,20,this,null)),J($e,23,this),he(this,za,J($e,24,this,[])),J($e,27,this),this.position=new fs({x:0,y:0}),he(this,gr,{x:0,y:0}),st(this,mr,e)}get shape(){const{current:e,initial:t,previous:n}=Ce(this,En);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ce(this,En).current=e:Ce(this,En).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ce(this,mr).registry.draggables.get(t);return n&&st(this,Oi,n),(e=n??Ce(this,Oi))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ce(this,mr).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(ba(va({},this.snapshot()),{transform:n}));return st(this,gr,n),n}snapshot(){return re(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ce(this,gr),shape:this.shape?Ps(this.shape):null,position:Ps(this.position),status:Ps(this.status),canceled:this.canceled}))}reset(){je(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ce(this,En).reset(),this.position.reset({x:0,y:0}),st(this,gr,{x:0,y:0}),this.modifiers=[]})}};$e=Qn(null);mr=new WeakMap;Oi=new WeakMap;En=new WeakMap;Pa=new WeakMap;Ia=new WeakMap;Wa=new WeakMap;Na=new WeakMap;za=new WeakMap;gr=new WeakMap;se($e,2,"shape",ru,yt);se($e,4,"canceled",nu,yt,Pa);se($e,4,"activatorEvent",tu,yt,Ia);se($e,4,"sourceIdentifier",eu,yt,Wa);se($e,4,"targetIdentifier",Qd,yt,Na);se($e,4,"modifiers",Zd,yt,za);se($e,2,"source",Jd,yt);se($e,2,"target",Xd,yt);se($e,2,"transform",Yd,yt);mn($e,yt);var xg={get rendering(){return Promise.resolve()}};function xt(e,t){return typeof e=="function"?e(t):e??t}var yg=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(l=>l.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=xt(n.plugins,[]),i=xt(n.sensors,[]),s=xt(n.modifiers,[]),o=(t=n.renderer)!=null?t:xg,a=new pg(this),d=new bg(this);this.registry=d,this.monitor=a,this.renderer=o,this.actions=new gg(this),this.dragOperation=new yt(this),this.collisionObserver=new hg(this),this.plugins=[mg,...r],this.modifiers=s,this.sensors=i;const{destroy:f}=this,c=Xr(()=>{var l,u,p;const g=re(()=>this.dragOperation.modifiers),v=this.modifiers;for(const x of g)v.includes(x)||x.destroy();this.dragOperation.modifiers=(p=(u=(l=this.dragOperation.source)==null?void 0:l.modifiers)==null?void 0:u.map(x=>{const{plugin:k,options:h}=zr(x);return new k(this,h)}))!=null?p:v});this.destroy=()=>{c(),f()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},iu=e=>{throw TypeError(e)},La=(e,t,n)=>t.has(e)||iu("Cannot "+n),X=(e,t,n)=>(La(e,t,"read from private field"),t.get(e)),et=(e,t,n)=>t.has(e)?iu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(La(e,t,"write to private field"),t.set(e,n),n),su=(e,t,n)=>(La(e,t,"access private method"),n);function ms(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function ou(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(ms(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function gs(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 Fa(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ei(e){return"nodeType"in e}function at(e){var t,n,r;return e?Fa(e)?e:ei(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 Ba(e){const{Document:t}=at(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Vt(e){return!e||Fa(e)?!1:e instanceof at(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function au(e){return e instanceof at(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function nr(e){return e?Fa(e)?e.document:ei(e)?Ba(e)?e:Vt(e)||au(e)?e.ownerDocument:document:document:document}function wg(e){var t,n,r,i;const{documentElement:s}=nr(e),o=at(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,d=(n=o?.height)!=null?n:s.clientHeight,f=(r=o?.offsetTop)!=null?r:0,c=(i=o?.offsetLeft)!=null?i:0;return{top:f,left:c,right:c+a,bottom:f+d,width:a,height:d}}function kg(e,t){if(Sg(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function Sg(e){return e.tagName==="DETAILS"}function Fr(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let d=t;const{ownerDocument:f}=e,c=(r=f.defaultView)!=null?r:window;let l=e.parentElement;for(;l&&l!==f.documentElement;){if(!kg(l)){const b=l.getBoundingClientRect(),y=n*(b.bottom-b.top),w=n*(b.right-b.left),$=n*(b.bottom-b.top),M=n*(b.right-b.left);d={top:Math.max(d.top,b.top-y),right:Math.min(d.right,b.right+w),bottom:Math.min(d.bottom,b.bottom+$),left:Math.max(d.left,b.left-M),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top}l=l.parentElement}const u=c.visualViewport,p=(i=u?.offsetTop)!=null?i:0,g=(s=u?.offsetLeft)!=null?s:0,v=(o=u?.width)!=null?o:c.innerWidth,x=(a=u?.height)!=null?a:c.innerHeight,k=n*x,h=n*v;return d={top:Math.max(d.top,p-k),right:Math.min(d.right,g+v+h),bottom:Math.min(d.bottom,p+x+k),left:Math.max(d.left,g-h),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top,d.width<0&&(d.width=0),d.height<0&&(d.height=0),d}function Hn(e){return{x:e.clientX,y:e.clientY}}var lu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Mo(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(...Mo(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(...Mo(i.document,t))}}catch{}return n}function _a(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function cu(){var e,t;const n=_a()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Ha(e){return!e||!ei(e)?!1:e instanceof at(e).ShadowRoot}function Yi(e){if(e&&ei(e)){let t=e.getRootNode();if(Ha(t)||t instanceof Document)return t}return nr(e)}function qa(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function $g(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];Il(i)&&Il(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Wl(i)&&Wl(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function Il(e){return"value"in e}function Wl(e){return e.tagName==="CANVAS"}function du(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(jg(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return du(i,{x:t-s,y:n-o})}}return r}function jg(e){return e?.tagName==="IFRAME"}var Co=new WeakMap;function Mg(e){return e.closest(`
|
|
2
|
+
input:not([disabled]),
|
|
3
|
+
select:not([disabled]),
|
|
4
|
+
textarea:not([disabled]),
|
|
5
|
+
button:not([disabled]),
|
|
6
|
+
a[href],
|
|
7
|
+
[contenteditable]:not([contenteditable="false"])
|
|
8
|
+
`)}var uu=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];for(const o of n)for(const a of r){const{type:d,listener:f,options:c}=a,l=[o,a];o.addEventListener(d,f,c),this.entries.add(l),i.push(l)}const s=this.entries;return function(){for(const o of i){const[a,{type:d,listener:f,options:c}]=o;a.removeEventListener(d,f,c),s.delete(o)}}}};function qn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Cg(e){const t=new Set;let n=qn(e);for(;n;)t.add(n),n=qn(n);return t}function Eg(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function hu(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=Eg(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function Og(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function Dg(e,t=e.getBoundingClientRect()){const{width:n,height:r}=Fr(e,t);return n>0&&r>0}var Tg=lu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},Di,Ag=class extends Tg{constructor(e){super(t=>{if(!X(this,Di)){rt(this,Di,!0);return}e(t,this)}),et(this,Di,!1)}};Di=new WeakMap;var Nl=Array.from({length:100},(e,t)=>t/100),fu=75,tn,Xi,Wt,nn,vr,_e,Ar,br,Ji,pu,mu,gu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,et(this,Ji),this.disconnect=()=>{var s,o,a;rt(this,Ar,!0),(s=X(this,Wt))==null||s.disconnect(),(o=X(this,nn))==null||o.disconnect(),X(this,vr).disconnect(),(a=X(this,_e))==null||a.remove()},et(this,tn,!0),et(this,Xi),et(this,Wt),et(this,nn),et(this,vr),et(this,_e),et(this,Ar,!1),et(this,br,hu(()=>{var s,o,a;const{element:d}=this;if((s=X(this,nn))==null||s.disconnect(),X(this,Ar)||!X(this,tn)||!d.isConnected)return;const f=(o=d.ownerDocument)!=null?o:document,{innerHeight:c,innerWidth:l}=(a=f.defaultView)!=null?a:window,u=d.getBoundingClientRect(),p=Fr(d,u),{top:g,left:v,bottom:x,right:k}=p,h=-Math.floor(g),b=-Math.floor(v),y=-Math.floor(l-k),w=-Math.floor(c-x),$=`${h}px ${y}px ${w}px ${b}px`;this.boundingClientRect=u,rt(this,nn,new IntersectionObserver(M=>{const[T]=M,{intersectionRect:j}=T;(T.intersectionRatio!==1?T.intersectionRatio:$t.intersectionRatio(j,Fr(d)))!==1&&X(this,br).call(this)},{threshold:Nl,rootMargin:$,root:f})),X(this,nn).observe(d),su(this,Ji,pu).call(this)},fu)),this.boundingClientRect=e.getBoundingClientRect(),rt(this,tn,Dg(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(rt(this,_e,document.createElement("div")),X(this,_e).style.background="rgba(0,0,0,0.15)",X(this,_e).style.position="fixed",X(this,_e).style.pointerEvents="none",i.body.appendChild(X(this,_e))),rt(this,vr,new IntersectionObserver(s=>{var o,a;const d=s[s.length-1],{boundingClientRect:f,isIntersecting:c}=d,{width:l,height:u}=f,p=X(this,tn);rt(this,tn,c),!(!l&&!u)&&(p&&!c?((o=X(this,nn))==null||o.disconnect(),this.callback(null),(a=X(this,Wt))==null||a.disconnect(),rt(this,Wt,void 0),X(this,_e)&&(X(this,_e).style.visibility="hidden")):X(this,br).call(this),c&&!X(this,Wt)&&(rt(this,Wt,new Ag(X(this,br))),X(this,Wt).observe(e)))},{threshold:Nl,root:i})),X(this,tn)&&!n.skipInitial&&this.callback(this.boundingClientRect),X(this,vr).observe(e)}};tn=new WeakMap;Xi=new WeakMap;Wt=new WeakMap;nn=new WeakMap;vr=new WeakMap;_e=new WeakMap;Ar=new WeakMap;br=new WeakMap;Ji=new WeakSet;pu=function(){X(this,Ar)||(su(this,Ji,mu).call(this),!Og(this.boundingClientRect,X(this,Xi))&&(this.callback(this.boundingClientRect),rt(this,Xi,this.boundingClientRect)))};mu=function(){if(X(this,_e)){const{top:e,left:t,width:n,height:r}=Fr(this.element);X(this,_e).style.overflow="hidden",X(this,_e).style.visibility="visible",X(this,_e).style.top=`${Math.floor(e)}px`,X(this,_e).style.left=`${Math.floor(t)}px`,X(this,_e).style.width=`${Math.floor(n)}px`,X(this,_e).style.height=`${Math.floor(r)}px`}};var pi=new WeakMap,mi=new WeakMap;function Rg(e,t){let n=pi.get(e);return n||(n={disconnect:new gu(e,r=>{const i=pi.get(e);i&&i.callbacks.forEach(s=>s(r))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),pi.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(pi.delete(e),n.disconnect())}}function Pg(e,t){const n=new Set;for(const r of e){const i=Rg(r,t);n.add(i)}return()=>n.forEach(r=>r())}function Ig(e,t){var n;const r=e.ownerDocument;if(!mi.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",d=>a.forEach(f=>f(d)),{capture:!0,passive:!0,signal:o.signal}),mi.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=mi.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),mi.delete(r))})}var xr,yr,Ti,Eo,Wg=class{constructor(e,t,n){this.callback=t,et(this,xr),et(this,yr,!1),et(this,Ti),et(this,Eo,hu(o=>{if(!X(this,yr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of X(this,Ti))if(o.target.contains(a)){this.callback(X(this,xr).boundingClientRect);break}}},fu));const r=Cg(e),i=Pg(r,t),s=Ig(e,X(this,Eo));rt(this,Ti,r),rt(this,xr,new gu(e,t,n)),this.disconnect=()=>{X(this,yr)||(rt(this,yr,!0),i(),s(),X(this,xr).disconnect())}}};xr=new WeakMap;yr=new WeakMap;Ti=new WeakMap;Eo=new WeakMap;function Oo(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function zn(e){try{Oo(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function zl(e){return!lu||!e?!1:e===nr(e).scrollingElement}function vu(e){var t,n;const r=at(e),i=zl(e)?wg(e):gs(e),s=r.visualViewport,o=zl(e)?{height:(t=s?.height)!=null?t:r.innerHeight,width:(n=s?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},d=a.current.y<=0,f=a.current.x<=0,c=a.current.y>=a.max.y,l=a.current.x>=a.max.x;return{rect:i,position:a,isTop:d,isLeft:f,isBottom:c,isRight:l}}function Ng(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=vu(e),{x:a,y:d}=t??{x:0,y:0},f=!n&&o.current.y+d>0,c=!r&&o.current.y+d<o.max.y,l=!i&&o.current.x+a>0,u=!s&&o.current.x+a<o.max.x;return{top:f,bottom:c,left:l,right:u,x:l||u,y:f||c}}var Ua=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},Zi=new Ua(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),zg=new Ua(e=>setTimeout(e,50)),Qi=new Map,Lg=Qi.clear.bind(Qi);function Ct(e,t=!1){if(!t)return Ll(e);let n=Qi.get(e);return n||(n=Ll(e),Qi.set(e,n),zg.schedule(Lg),n)}function Ll(e){return at(e).getComputedStyle(e)}function Fg(e,t=Ct(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Bg(e,t=Ct(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const i=t[r];return typeof i=="string"?n.test(i):!1})}var _g={excludeElement:!0,escapeShadowDOM:!0};function Do(e,t=_g){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Ba(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Ha(a))return o(a.host);if(!Vt(a))return au(a)?o(a.parentElement):s;if(s.has(a))return s;const d=Ct(a,!0);if(r&&a===e||Bg(a,d)&&s.add(a),Fg(a,d)){const{scrollingElement:f}=a.ownerDocument;return f&&s.add(f),s}return o(a.parentNode)}return e?o(e):s}function Un(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=qn(e);for(;r;){if(r===t)return n;const i=gs(r),{x:s,y:o}=Hg(r,i);n.x=n.x+i.left,n.y=n.y+i.top,n.scaleX=n.scaleX*s,n.scaleY=n.scaleY*o,r=qn(r)}return n}function Hg(e,t=gs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Vt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=Ct(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function qg(e){if(!e||e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function Br(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function vs(e){var t,n,r,i,s,o,a,d,f;const{scale:c,transform:l,translate:u}=e,p=qg(c),g=Br(u),v=Ug(l);if(!v&&!p&&!g)return null;const x={x:(t=p?.x)!=null?t:1,y:(n=p?.y)!=null?n:1},k={x:(r=g?.x)!=null?r:0,y:(i=g?.y)!=null?i:0},h={x:(s=v?.x)!=null?s:0,y:(o=v?.y)!=null?o:0,scaleX:(a=v?.scaleX)!=null?a:1,scaleY:(d=v?.scaleY)!=null?d:1};return{x:k.x+h.x,y:k.y+h.y,z:(f=g?.z)!=null?f:0,scaleX:x.x*h.scaleX,scaleY:x.y*h.scaleY}}function Ug(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var dt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(dt||{}),Vg={x:.2,y:.2},Gg={x:10,y:10};function Kg(e,t,n,r=25,i=Vg,s=Gg){const{x:o,y:a}=t,{rect:d,isTop:f,isBottom:c,isLeft:l,isRight:u}=vu(e),p=Un(e),g=Ct(e,!0),v=vs(g),x=v!==null?v?.scaleX<0:!1,k=v!==null?v?.scaleY<0:!1,h=new $t(d.left*p.scaleX+p.x,d.top*p.scaleY+p.y,d.width*p.scaleX,d.height*p.scaleY),b={x:0,y:0},y={x:0,y:0},w={height:h.height*i.y,width:h.width*i.x};return w.height>0&&(!f||k&&!c)&&a<=h.top+w.height&&n?.y!==1&&o>=h.left-s.x&&o<=h.right+s.x?(b.y=k?1:-1,y.y=r*Math.abs((h.top+w.height-a)/w.height)):w.height>0&&(!c||k&&!f)&&a>=h.bottom-w.height&&n?.y!==-1&&o>=h.left-s.x&&o<=h.right+s.x&&(b.y=k?-1:1,y.y=r*Math.abs((h.bottom-w.height-a)/w.height)),w.width>0&&(!u||x&&!l)&&o>=h.right-w.width&&n?.x!==-1&&a>=h.top-s.y&&a<=h.bottom+s.y?(b.x=x?-1:1,y.x=r*Math.abs((h.right-w.width-o)/w.width)):w.width>0&&(!l||x&&!u)&&o<=h.left+w.width&&n?.x!==1&&a>=h.top-s.y&&a<=h.bottom+s.y&&(b.x=x?1:-1,y.x=r*Math.abs((h.left+w.width-o)/w.width)),{direction:b,speed:y}}function bu(e,{block:t="nearest",inline:n="nearest"}={}){if(!Vt(e))return;const r=Do(e),i=[];for(const s of r){if(!Vt(s))continue;const{top:o,left:a}=Yg(e,s);let d=o,f=a;for(const c of i)d-=c.scrollTop,f-=c.scrollLeft;if(t!=="none"){const c=d<s.scrollTop,l=d+e.offsetHeight>s.scrollTop+s.clientHeight;c!==l&&(t==="center"?s.scrollTop=d-s.clientHeight/2+e.offsetHeight/2:c?s.scrollTop=d:s.scrollTop=d+e.offsetHeight-s.clientHeight)}if(n!=="none"){const c=f<s.scrollLeft,l=f+e.offsetWidth>s.scrollLeft+s.clientWidth;c!==l&&(n==="center"?s.scrollLeft=f-s.clientWidth/2+e.offsetWidth/2:c?s.scrollLeft=f:s.scrollLeft=f+e.offsetWidth-s.clientWidth)}i.push(s)}}function Fl(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Vt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function Yg(e,t){const n=Fl(e),r=Fl(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Xg(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),d=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),f=r?e.width*r:e.width,c=i?e.height*i:e.height;return{width:f,height:c,top:d,right:a+f,bottom:d+c,left:a}}function Jg(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left-s-(1-r)*parseFloat(n),d=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),f=r?e.width/r:e.width,c=i?e.height/i:e.height;return{width:f,height:c,top:d,right:a+f,bottom:d+c,left:a}}function xu({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Bl(e,t=Ct(e).translate,n=!0){if(n){const r=ou(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=Br(i);if(s)return s}}}if(t){const r=Br(t);if(r)return r}return{x:0,y:0,z:0}}var Zg=new Ua(e=>setTimeout(e,0)),Rr=new Map,Qg=Rr.clear.bind(Rr);function ev(e){const t=e.ownerDocument;let n=Rr.get(t);if(n)return n;n=t.getAnimations(),Rr.set(t,n),Zg.schedule(Qg);const r=n.filter(i=>ms(i.effect)&&i.effect.target===e);return Rr.set(e,r),n}function tv(e,t){const n=ev(e).filter(r=>{var i,s;if(ms(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))==null||s)return r.effect.getKeyframes().some(a=>{for(const d of t.properties)if(a[d])return!0})}}).map(r=>{const{effect:i,currentTime:s}=r,o=i?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof s=="number"&&s<o)return r.currentTime=o,()=>{r.currentTime=s}});if(n.length>0)return()=>n.forEach(r=>r?.())}var St=class extends $t{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=Un(e),ignoreTransforms:a,getBoundingClientRect:d=gs}=t,f=tv(e,{properties:["transform","translate","scale","width","height"],isValidTarget:w=>(w!==e||_a())&&w.contains(e)}),c=d(e);let{top:l,left:u,width:p,height:g}=c,v;const x=Ct(e),k=vs(x),h={x:(n=k?.scaleX)!=null?n:1,y:(r=k?.scaleY)!=null?r:1},b=nv(e,x);f?.(),k&&(v=Jg(c,k,x.transformOrigin),(a||b)&&(l=v.top,u=v.left,p=v.width,g=v.height));const y={width:(i=v?.width)!=null?i:p,height:(s=v?.height)!=null?s:g};if(b&&!a&&v){const w=Xg(v,b,x.transformOrigin);l=w.top,u=w.left,p=w.width,g=w.height,h.x=b.scaleX,h.y=b.scaleY}o&&(a||(u*=o.scaleX,p*=o.scaleX,l*=o.scaleY,g*=o.scaleY),u+=o.x,l+=o.y),super(u,l,p,g),this.scale=h,this.intrinsicWidth=y.width,this.intrinsicHeight=y.height}};function nv(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const d=ms(a.effect)?a.effect.getKeyframes():[],f=d[d.length-1];if(!f)continue;const{transform:c,translate:l,scale:u}=f;typeof c=="string"&&c&&(r=c,o=!0),typeof l=="string"&&l&&(i=l,o=!0),typeof u=="string"&&u&&(s=u,o=!0)}return o?vs({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function Pr(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var rv=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(Pr(n))for(const[r,i]of Object.entries(e)){const s=`${t}${r}`;this.initial.has(s)||this.initial.set(s,n.style.getPropertyValue(s)),n.style.setProperty(s,typeof i=="string"?i:`${i}px`)}}remove(e,t=""){const{element:n}=this;if(Pr(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(Pr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function un(e){return e?e instanceof at(e).Element||ei(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function _r(e){if(!e)return!1;const{KeyboardEvent:t}=at(e.target);return e instanceof t}function iv(e){if(!e)return!1;const{PointerEvent:t}=at(e.target);return e instanceof t}function sv(e){if(!un(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||ov(e)}function ov(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Ws={};function To(e){const t=Ws[e]==null?0:Ws[e]+1;return Ws[e]=t,`${e}-${t}`}var Va=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=ct.distance(t.shape.center,n);return{id:r,value:1/i,type:tr.PointerIntersection,priority:er.High}}return null},av=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=ct.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:tr.ShapeIntersection,priority:er.Normal}}return null},yu=e=>{var t;return(t=Va(e))!=null?t:av(e)},lv=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?$t.from(r.current.boundingRectangle).corners:void 0,o=$t.from(n.shape.boundingRectangle).corners.reduce((a,d,f)=>{var c;return a+ct.distance(ct.from(d),(c=s?.[f])!=null?c:i.current)},0)/4;return{id:n.id,value:1/o,type:tr.Collision,priority:er.Normal}},cv=Object.create,Ga=Object.defineProperty,dv=Object.defineProperties,uv=Object.getOwnPropertyDescriptor,hv=Object.getOwnPropertyDescriptors,es=Object.getOwnPropertySymbols,wu=Object.prototype.hasOwnProperty,ku=Object.prototype.propertyIsEnumerable,Su=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),rr=e=>{throw TypeError(e)},Ao=(e,t,n)=>t in e?Ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hr=(e,t)=>{for(var n in t||(t={}))wu.call(t,n)&&Ao(e,n,t[n]);if(es)for(var n of es(t))ku.call(t,n)&&Ao(e,n,t[n]);return e},Ka=(e,t)=>dv(e,hv(t)),_l=(e,t)=>Ga(e,"name",{value:t,configurable:!0}),$u=(e,t)=>{var n={};for(var r in e)wu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&es)for(var r of es(e))t.indexOf(r)<0&&ku.call(e,r)&&(n[r]=e[r]);return n},ir=e=>{var t;return[,,,cv((t=e?.[Su("metadata")])!=null?t:null)]},ju=["class","method","getter","setter","accessor","field","value","get","set"],wr=e=>e!==void 0&&typeof e!="function"?rr("Function expected"):e,fv=(e,t,n,r,i)=>({kind:ju[e],name:t,metadata:r,addInitializer:s=>n._?rr("Already initialized"):i.push(wr(s||null))}),gn=(e,t)=>Ao(t,Su("metadata"),e[3]),ze=(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},pt=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=ju[l+5],x=l>3&&(e[g-1]=[]),k=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&uv(l<4?i:{get[n](){return ve(this,s)},set[n](y){return Je(this,s,y)}},n));l?p&&l<4&&_l(s,(l>2?"set ":l>1?"get ":"")+n):_l(i,n);for(var b=r.length-1;b>=0;b--)f=fv(l,n,d={},e[3],k),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>pv(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?ve:hn)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,w)=>Je(y,i,w,l^4?s:h.set):(y,w)=>y[n]=w)),a=(0,r[b])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?wr(a)&&(l>4?x.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?rr("Object expected"):(wr(o=a.get)&&(h.get=o),wr(o=a.set)&&(h.set=o),wr(o=a.init)&&x.unshift(o));return l||gn(e,i),h&&Ga(i,n,h),p?l^4?s:h:i},Ya=(e,t,n)=>t.has(e)||rr("Cannot "+n),pv=(e,t)=>Object(t)!==t?rr('Cannot use the "in" operator on this value'):e.has(t),ve=(e,t,n)=>(Ya(e,t,"read from private field"),n?n.call(e):t.get(e)),Te=(e,t,n)=>t.has(e)?rr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Je=(e,t,n,r)=>(Ya(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),hn=(e,t,n)=>(Ya(e,t,"access private method"),n),Hl={role:"button",roleDescription:"draggable"},mv="dnd-kit-description",gv="dnd-kit-announcement",vv={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},bv={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function xv(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function yv(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function wv(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var kv=["dragover","dragmove"],Sv=class extends Ue{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=mv,announcement:i=gv}={},announcements:s=bv,screenReaderInstructions:o=vv,debounce:a=500}=t??{},d=n?`${r}-${n}`:To(r),f=n?`${i}-${n}`:To(i);let c,l,u,p;const g=(w=p)=>{!u||!w||u?.nodeValue!==w&&(u.nodeValue=w)},v=()=>Zi.schedule(g),x=$v(v,a),k=Object.entries(s).map(([w,$])=>this.manager.monitor.addEventListener(w,(M,T)=>{const j=u;if(!j)return;const O=$?.(M,T);O&&j.nodeValue!==O&&(p=O,kv.includes(w)?x():(v(),x.cancel()))})),h=()=>{let w=[];c?.isConnected||(c=yv(d,o.draggable),w.push(c)),l?.isConnected||(l=wv(f),u=document.createTextNode(""),l.appendChild(u),w.push(l)),w.length>0&&document.body.append(...w)},b=new Set;function y(){for(const w of b)w()}this.registerEffect(()=>{var w;b.clear();for(const $ of this.manager.registry.draggables.value){const M=(w=$.handle)!=null?w:$.element;if(M){(!c||!l)&&b.add(h),(!xv(M)||_a())&&!M.hasAttribute("tabindex")&&b.add(()=>M.setAttribute("tabindex","0")),!M.hasAttribute("role")&&M.tagName.toLowerCase()!=="button"&&b.add(()=>M.setAttribute("role",Hl.role)),M.hasAttribute("aria-roledescription")||b.add(()=>M.setAttribute("aria-roledescription",Hl.roleDescription)),M.hasAttribute("aria-describedby")||b.add(()=>M.setAttribute("aria-describedby",d));for(const j of["aria-pressed","aria-grabbed"]){const O=String($.isDragging);M.getAttribute(j)!==O&&b.add(()=>M.setAttribute(j,O))}const T=String($.disabled);M.getAttribute("aria-disabled")!==T&&b.add(()=>M.setAttribute("aria-disabled",T))}}b.size>0&&Zi.schedule(y)}),this.destroy=()=>{super.destroy(),c?.remove(),l?.remove(),k.forEach(w=>w())}}};function $v(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var ts=new Map,Mu,Cu,Eu,Ou,Ro,Ir,Ot,Xa,Vn,Du,Tu,Au,Ru,Gt=class extends(Ro=Qr,Ou=[ie],Eu=[Ee],Cu=[Ee],Mu=[Ee],Ro){constructor(e,t){super(e,t),ze(Ot,5,this),Te(this,Vn),Te(this,Ir,new Set),Te(this,Xa,ze(Ot,8,this,new Set)),ze(Ot,11,this),this.registerEffect(hn(this,Vn,Du))}register(e){return ve(this,Ir).add(e),()=>{ve(this,Ir).delete(e)}}addRoot(e){return re(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{re(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return Yi((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return Yi((e=t?.element)!=null?e:null)}get roots(){const{status:e}=this.manager.dragOperation;if(e.initializing||e.initialized){const t=[this.sourceRoot,this.targetRoot].filter(n=>n!=null);return new Set([...t,...this.additionalRoots])}return new Set}};Ot=ir(Ro);Ir=new WeakMap;Xa=new WeakMap;Vn=new WeakSet;Du=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of ve(this,Ir))t.push(hn(this,Vn,Tu).call(this,n,r));return()=>{for(const n of t)n()}};Tu=function(e,t){let n=ts.get(e);n||(n=new Map,ts.set(e,n));let r=n.get(t);if(!r){const s=Ba(e)?hn(this,Vn,Au).call(this,e,n,t):hn(this,Vn,Ru).call(this,e,n,t);if(!s)return()=>{};r=s,n.set(t,r)}r.refCount++;let i=!1;return()=>{i||(i=!0,r.refCount--,r.refCount===0&&r.cleanup())}};Au=function(e,t,n){var r;const i=e.createElement("style"),{nonce:s}=(r=this.options)!=null?r:{};s&&i.setAttribute("nonce",s),i.textContent=n,e.head.prepend(i);const o=new MutationObserver(a=>{for(const d of a)for(const f of Array.from(d.removedNodes))if(f===i){e.head.prepend(i);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),i.remove(),t.delete(n),t.size===0&&ts.delete(e)}}};Ru=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:i}=r??{};if(!i)return null;const s=new i;return s.replaceSync(n),e.adoptedStyleSheets.push(s),{refCount:0,cleanup:()=>{var o;if(Ha(e)&&(o=e.host)!=null&&o.isConnected){const a=e.adoptedStyleSheets.indexOf(s);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&ts.delete(e)}}};pt(Ot,4,"additionalRoots",Ou,Gt,Xa);pt(Ot,2,"sourceRoot",Eu,Gt);pt(Ot,2,"targetRoot",Cu,Gt);pt(Ot,2,"roots",Mu,Gt);gn(Ot,Gt);Gt.configure=Zr(Gt);var bs=Gt,jv=class extends Ue{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(bs),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},ti="data-dnd-",Po=`${ti}dropping`,Be="--dnd-",wt=`${ti}dragging`,ns=`${ti}placeholder`,Mv=[wt,ns,"popover","aria-pressed","aria-grabbing"],Cv=["view-transition-name"],Ev=`
|
|
9
|
+
:is(:root,:host) [${wt}] {
|
|
10
|
+
position: fixed !important;
|
|
11
|
+
pointer-events: none !important;
|
|
12
|
+
touch-action: none;
|
|
13
|
+
z-index: calc(infinity);
|
|
14
|
+
will-change: translate;
|
|
15
|
+
top: var(${Be}top, 0px) !important;
|
|
16
|
+
left: var(${Be}left, 0px) !important;
|
|
17
|
+
right: unset !important;
|
|
18
|
+
bottom: unset !important;
|
|
19
|
+
width: var(${Be}width, auto);
|
|
20
|
+
max-width: var(${Be}width, auto);
|
|
21
|
+
height: var(${Be}height, auto);
|
|
22
|
+
max-height: var(${Be}height, auto);
|
|
23
|
+
transform: var(${Be}transform, none) !important;
|
|
24
|
+
transition: var(${Be}transition) !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:is(:root,:host) [${ns}] {
|
|
28
|
+
transition: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:is(:root,:host) [${ns}='hidden'] {
|
|
32
|
+
visibility: hidden;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[${wt}] * {
|
|
36
|
+
pointer-events: none !important;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[${wt}]:not([${Po}]) {
|
|
40
|
+
translate: var(${Be}translate) !important;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[${wt}][style*='${Be}scale'] {
|
|
44
|
+
scale: var(${Be}scale) !important;
|
|
45
|
+
transform-origin: var(${Be}transform-origin) !important;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@layer dnd-kit {
|
|
49
|
+
:where([${wt}][popover]) {
|
|
50
|
+
overflow: visible;
|
|
51
|
+
background: unset;
|
|
52
|
+
border: unset;
|
|
53
|
+
margin: unset;
|
|
54
|
+
padding: unset;
|
|
55
|
+
color: inherit;
|
|
56
|
+
|
|
57
|
+
&:is(input, button) {
|
|
58
|
+
border: revert;
|
|
59
|
+
background: revert;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
[${wt}]::backdrop, [${ti}overlay]:not([${wt}]) {
|
|
64
|
+
display: none;
|
|
65
|
+
visibility: hidden;
|
|
66
|
+
}
|
|
67
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Ov(e,t="hidden"){return re(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=Dv(n,r.registry.droppables),s=[],o=$g(n),{remove:a}=o;return Tv(i,o,s),Av(o,t),o.remove=()=>{s.forEach(d=>d()),a.call(o)},o})}function Dv(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${ti}${To("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function Tv(e,t,n){for(const[r,i]of e){if(!r.element)continue;const s=`[${i}]`,o=t.matches(s)?t:t.querySelector(s);if(r.element.removeAttribute(i),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(i),Co.set(a,o),n.push(()=>{Co.delete(a),r.proxy=void 0})}}function Av(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(ns,t)}function Pu(e,t){return e===t?!0:qn(e)===qn(t)}function ql(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&un(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>zn(t))}function Io(e){return e.tagName==="TR"}function Rv(e,t,n){const r=new MutationObserver(i=>{let s=!1;for(const o of i){if(o.target!==e){s=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||Mv.includes(a))continue;const d=e.getAttribute(a);if(a==="style"){if(Pr(e)&&Pr(t)){const f=e.style;for(const c of Array.from(t.style))f.getPropertyValue(c)===""&&t.style.removeProperty(c);for(const c of Array.from(f)){if(Cv.includes(c)||c.startsWith(Be))continue;const l=f.getPropertyValue(c);t.style.setProperty(c,l)}}}else d!==null?t.setAttribute(a,d):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function Pv(e,t,n){const r=new MutationObserver(i=>{for(const s of i)if(s.addedNodes.length!==0)for(const o of Array.from(s.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),zn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),zn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),zn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Iv(e){return new ResizeObserver(()=>{var t,n,r;const i=new St(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-i.width)*s.x+e.delta.x,a=(e.height-i.height)*s.y+e.delta.y,d=cu();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+d.y,left:e.left+o+d.x},Be),(n=e.getElementMutationObserver())==null||n.takeRecords(),Io(e.element)&&Io(e.placeholder)){const v=Array.from(e.element.cells),x=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(v.map(k=>k.style.width));for(const[k,h]of v.entries()){const b=x[k];h.style.width=`${b.getBoundingClientRect().width}px`}}const f=(r=e.getTranslate())!=null?r:{x:0,y:0},c=e.left+o+d.x+f.x,l=e.top+a+d.y+f.y,u=i.width-e.widthOffset,p=i.height-e.heightOffset,g=e.frameTransform;e.dragOperation.shape=new $t(c*g.scaleX+g.x,l*g.scaleY+g.y,u*g.scaleX,p*g.scaleY)})}var Wv=250,Nv="ease";function zv(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const h=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(h).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Wv,easing:a=Nv}=s??{};zn(e.feedbackElement);const[,d]=(t=ou(e.feedbackElement,h=>"translate"in h))!=null?t:[];d?.pause();const f=(n=e.placeholder)!=null?n:e.element,c={frameTransform:Pu(e.feedbackElement,f)?null:void 0},l=new St(e.feedbackElement,c),u=(r=Br(Ct(e.feedbackElement).translate))!=null?r:e.translate,p=new St(f,c),g=$t.delta(l,p,e.alignment),v={x:u.x-g.x,y:u.y-g.y},x=Math.round(l.intrinsicHeight)!==Math.round(p.intrinsicHeight)?{minHeight:[`${l.intrinsicHeight}px`,`${p.intrinsicHeight}px`],maxHeight:[`${l.intrinsicHeight}px`,`${p.intrinsicHeight}px`]}:{},k=Math.round(l.intrinsicWidth)!==Math.round(p.intrinsicWidth)?{minWidth:[`${l.intrinsicWidth}px`,`${p.intrinsicWidth}px`],maxWidth:[`${l.intrinsicWidth}px`,`${p.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Be),e.feedbackElement.setAttribute(Po,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),xu({element:e.feedbackElement,keyframes:Ka(Hr(Hr({},x),k),{translate:[`${u.x}px ${u.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:qa(at(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Po),d?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Iu,Wo,qr,Ja,Ai,Wu,Nu,Gn=class extends(Wo=Ue,Iu=[ie],Wo){constructor(e,t){super(e,t),Te(this,Ai),Te(this,Ja,ze(qr,8,this)),ze(qr,11,this),this.state={initial:{},current:{}};const n=e.registry.plugins.get(bs),r=n?.register(Ev);if(r){const i=this.destroy.bind(this);this.destroy=()=>{r(),i()}}this.registerEffect(hn(this,Ai,Wu).bind(this,n)),this.registerEffect(hn(this,Ai,Nu))}};qr=ir(Wo);Ja=new WeakMap;Ai=new WeakSet;Wu=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Yi(t);if(n)return e.addRoot(n)};Nu=function(){var e,t,n,r,i,s,o;const{state:a,manager:d,options:f}=this,{dragOperation:c}=d,{position:l,source:u,status:p}=c;if(p.idle){a.current={},a.initial={};return}if(!u)return;const{element:g}=u,v=u.pluginConfig(Gn),x=(t=(e=v?.feedback)!=null?e:f?.feedback)!=null?t:"default",k=typeof x=="function"?x(u,d):x;if(!g||k==="none"||!p.initialized||p.initializing)return;const{initial:h}=a,b=(n=this.overlay)!=null?n:g,y=Un(b),w=Un(g),$=!Pu(g,b),M=new St(g,{frameTransform:$?w:null,ignoreTransforms:!$}),T={x:w.scaleX/y.scaleX,y:w.scaleY/y.scaleY};let{width:j,height:O,top:P,left:R}=M;$&&(j=j/T.x,O=O/T.y);const A=new rv(b),z=Ct(g),{transition:q,translate:U,boxSizing:D,paddingBlockStart:N,paddingBlockEnd:F,paddingInlineStart:W,paddingInlineEnd:_,borderInlineStartWidth:Y,borderInlineEndWidth:G,borderBlockStartWidth:le,borderBlockEndWidth:V}=z,H=q.split(",").filter(be=>!/^\s*(transform|translate|scale)\b/.test(be)).join(","),Z=vs(z),ee=z.transform,Q=k==="clone",ce=D==="content-box",xe=ce?parseInt(W)+parseInt(_)+parseInt(Y)+parseInt(G):0,me=ce?parseInt(N)+parseInt(F)+parseInt(le)+parseInt(V):0,te=k!=="move"&&!this.overlay?Ov(u,Q?"clone":"hidden"):null,fe=re(()=>_r(d.dragOperation.activatorEvent));if(!h.translate){if(this.overlay&&Z)h.translate={x:Z.x,y:Z.y};else if(U!=="none"){const be=Br(U);be&&(h.translate=be)}}if(!h.transformOrigin){const be=re(()=>l.current),Le=R+((r=Z?.x)!=null?r:0),nt=P+((i=Z?.y)!=null?i:0);h.transformOrigin={x:(be.x-Le*y.scaleX-y.x)/(j*y.scaleX),y:(be.y-nt*y.scaleY-y.y)/(O*y.scaleY)}}const{transformOrigin:de}=h,ge=P*y.scaleY+y.y,Pe=R*y.scaleX+y.x;if(!h.coordinates&&(h.coordinates={x:Pe,y:ge},T.x!==1||T.y!==1)){const{scaleX:be,scaleY:Le}=w,{x:nt,y:It}=de;h.coordinates.x+=(j*be-j)*nt,h.coordinates.y+=(O*Le-O)*It}h.dimensions||(h.dimensions={width:j,height:O}),h.frameTransform||(h.frameTransform=y);const Ve={x:h.coordinates.x-Pe,y:h.coordinates.y-ge},Ge={width:(h.dimensions.width*h.frameTransform.scaleX-j*y.scaleX)*de.x,height:(h.dimensions.height*h.frameTransform.scaleY-O*y.scaleY)*de.y},Ke={x:Ve.x/y.scaleX+Ge.width,y:Ve.y/y.scaleY+Ge.height},Ie={left:R+Ke.x,top:P+Ke.y};b.setAttribute(wt,"true");const E=re(()=>c.transform),I=(s=h.translate)!=null?s:{x:0,y:0},C=E.x*y.scaleX+I.x,L=E.y*y.scaleY+I.y,ue=cu();A.set({width:j-xe,height:O-me,top:Ie.top+ue.y,left:Ie.left+ue.x,translate:`${C}px ${L}px 0`,transform:this.overlay?"none":ee,transition:H?`${H}, translate 0ms linear`:"translate 0ms linear",scale:$?`${T.x} ${T.y}`:"","transform-origin":`${de.x*100}% ${de.y*100}%`},Be),te&&(g.insertAdjacentElement("afterend",te),f?.rootElement&&(typeof f.rootElement=="function"?f.rootElement(u):f.rootElement).appendChild(g)),Oo(b)&&(b.hasAttribute("popover")||b.setAttribute("popover","manual"),zn(b),b.addEventListener("beforetoggle",ql));let K,oe,ne;const Ae=Iv({placeholder:te,element:g,feedbackElement:b,frameTransform:y,transformOrigin:de,width:j,height:O,top:P,left:R,widthOffset:xe,heightOffset:me,delta:Ke,styles:A,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>K,getSavedCellWidths:()=>ne,setSavedCellWidths:be=>{ne=be}}),Rt=new St(b);re(()=>c.shape=Rt);const Pt=at(b),vn=be=>{this.manager.actions.stop({event:be})},ai=qa(Pt);fe&&Pt.addEventListener("resize",vn),re(()=>u.status)==="idle"&&requestAnimationFrame(()=>u.status="dragging"),te&&(Ae.observe(te),K=Rv(g,te,Q),oe=Pv(g,te,b));const li=(o=d.dragOperation.source)==null?void 0:o.id,Ss=()=>{var be;if(!fe||li==null)return;const Le=d.registry.draggables.get(li),nt=(be=Le?.handle)!=null?be:Le?.element;Vt(nt)&&nt.focus()},Xt=()=>{K?.disconnect(),oe?.disconnect(),Ae.disconnect(),Pt.removeEventListener("resize",vn),Oo(b)&&(b.removeEventListener("beforetoggle",ql),b.removeAttribute("popover")),b.removeAttribute(wt),A.reset();const be=()=>{var Le;if(ne&&Io(g)){const js=Array.from(g.cells);for(const[ci,bn]of js.entries())bn.style.width=(Le=ne[ci])!=null?Le:""}u.status="idle";const nt=a.current.translate!=null,It=c.status.dragging;te&&(!It&&nt||te.parentElement!==b.parentElement)&&b.isConnected&&te.replaceWith(b),te?.remove()};b===this.overlay?setTimeout(be,0):be()},$s=f?.dropAnimation,fl=this,Qh=Xr(()=>{var be,Le,nt;const{transform:It,status:js}=c;if(!(!It.x&&!It.y&&!a.current.translate)&&js.dragging){const ci=(be=h.translate)!=null?be:{x:0,y:0},bn={x:It.x/y.scaleX+ci.x,y:It.y/y.scaleY+ci.y},pl=a.current.translate,ef=re(()=>c.modifiers),Ms=re(()=>{var ar;return(ar=c.shape)==null?void 0:ar.current}),Cs=f?.keyboardTransition,ml=fe&&!ai&&Cs!==null?`${(Le=Cs?.duration)!=null?Le:250}ms ${(nt=Cs?.easing)!=null?nt:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(A.set({transition:H?`${H}, translate ${ml}`:`translate ${ml}`,translate:`${bn.x}px ${bn.y}px 0`},Be),K?.takeRecords(),Ms&&Ms!==Rt&&pl&&!ef.length){const ar=ct.delta(bn,pl);c.shape=$t.from(Ms.boundingRectangle).translate(ar.x*y.scaleX,ar.y*y.scaleY)}else c.shape=new St(b);a.current.translate=bn}},function(){if(c.status.dropped){this.dispose(),u.status="dropping";const be=v?.dropAnimation!==void 0?v.dropAnimation:fl.dropAnimation!==void 0?fl.dropAnimation:$s;let Le=a.current.translate;const nt=Le!=null;if(!Le&&g!==b&&(Le={x:0,y:0}),!Le||be===null){Xt();return}d.renderer.rendering.then(()=>{zv({source:u,element:g,feedbackElement:b,placeholder:te,translate:Le,moved:nt,transition:q,alignment:u.alignment,styles:A,animation:be??void 0,getElementMutationObserver:()=>K,cleanup:Xt,restoreFocus:Ss})})}});return()=>{Xt(),Qh()}};pt(qr,4,"overlay",Iu,Gn,Ja);gn(qr,Gn);Gn.configure=Zr(Gn);var Za=Gn,cr=!0,Lv=!1,zu,Lu,Fu,Bu,Bt,Qa,el;Bu=(Fu=[ie],dt.Forward),Lu=(zu=[ie],dt.Reverse);var Ur=class{constructor(){Te(this,Qa,ze(Bt,8,this,cr)),ze(Bt,11,this),Te(this,el,ze(Bt,12,this,cr)),ze(Bt,15,this)}isLocked(e){return e===dt.Idle?!1:e==null?this[dt.Forward]===cr&&this[dt.Reverse]===cr:this[e]===cr}unlock(e){e!==dt.Idle&&(this[e]=Lv)}};Bt=ir(null);Qa=new WeakMap;el=new WeakMap;pt(Bt,4,Bu,Fu,Ur,Qa);pt(Bt,4,Lu,zu,Ur,el);gn(Bt,Ur);var Fv=[dt.Forward,dt.Reverse],Ul=class{constructor(){this.x=new Ur,this.y=new Ur}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Bv=class extends Ue{constructor(e){super(e);const t=Kn(new Ul);let n=null;this.signal=t,ft(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ul;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:Vl(i.x,n.x),y:Vl(i.y,n.y)},o=t.peek();je(()=>{for(const a of gd)for(const d of Fv)s[a]===d&&o[a].unlock(d);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Vl(e,t){return Math.sign(e-t)}var _u,No,Vr,tl,Nt,zo,ni=class extends(No=Qr,_u=[ie],No){constructor(e){super(e),Te(this,tl,ze(Vr,8,this,!1)),ze(Vr,11,this),Te(this,Nt),Te(this,zo,()=>{if(!ve(this,Nt))return;const{element:s,by:o}=ve(this,Nt);o.y&&(s.scrollTop+=o.y),o.x&&(s.scrollLeft+=o.x)}),this.scroll=(s,o)=>{var a;if(this.disabled)return!1;const d=this.getScrollableElements();if(!d)return Je(this,Nt,void 0),!1;const{position:f}=this.manager.dragOperation,c=f?.current;if(c){const{by:l}=s??{},u=l?{x:Gl(l.x),y:Gl(l.y)}:void 0,p=u?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const g of d){const v=Ng(g,l);if(v.x||v.y){const{speed:x,direction:k}=Kg(g,c,u,o?.acceleration,o?.threshold);if(p)for(const h of gd)p[h].isLocked(k[h])&&(x[h]=0,k[h]=0);if(k.x||k.y){const{x:h,y:b}=l??k,y=h*x.x,w=b*x.y;if(y||w){const $=(a=ve(this,Nt))==null?void 0:a.by;if(this.autoScrolling&&$&&($.x&&!y||$.y&&!w))continue;return Je(this,Nt,{element:g,by:{x:y,y:w}}),Zi.schedule(ve(this,zo)),!0}}}}}return Je(this,Nt,void 0),!1};let t=null,n=null;const r=fo(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=du(Yi(o?.element),s.current);return a&&(t=a),a??t}),i=fo(()=>{const s=r.value,{documentElement:o}=nr(s);if(!s||s===o){const{target:a}=e.dragOperation,d=a?.element;if(d){const f=Do(d,{excludeElement:!1});return n=f,f}}if(s){const a=Do(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},mt);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new Bv(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!_r(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};Vr=ir(No);tl=new WeakMap;Nt=new WeakMap;zo=new WeakMap;pt(Vr,4,"autoScrolling",_u,ni,tl);gn(Vr,ni);function Gl(e){return e>0?dt.Forward:e<0?dt.Reverse:dt.Idle}var _v=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},Hv=new _v(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),qv=10,Lo=class extends Ue{constructor(e,t){super(e,t);const n=e.registry.plugins.get(ni);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=ft(()=>{var r,i,s;if(this.disabled)return;const{position:o,status:a}=e.dragOperation;if(a.dragging){const d={acceleration:(r=this.options)==null?void 0:r.acceleration,threshold:typeof((i=this.options)==null?void 0:i.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(s=this.options)==null?void 0:s.threshold};if(n.scroll(void 0,d)){n.autoScrolling=!0;const f=setInterval(()=>Hv.schedule(()=>n.scroll(void 0,d)),qv);return()=>{clearInterval(f)}}else n.autoScrolling=!1}})}};Lo.configure=Zr(Lo);var Hu=Lo,Kl={capture:!0,passive:!0},kr,Uv=class extends Qr{constructor(e){super(e),Te(this,kr),this.handleScroll=()=>{ve(this,kr)==null&&Je(this,kr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Je(this,kr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=ft(()=>{var n,r,i;if(t.status.dragging){const s=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return s.addEventListener("scroll",this.handleScroll,Kl),()=>{s.removeEventListener("scroll",this.handleScroll,Kl)}}})}};kr=new WeakMap;var Vv="* { user-select: none !important; -webkit-user-select: none !important; }",Gv=class extends Ue{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(bs),n=t?.register(Vv);if(this.destroy=ft(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return Ns(),document.addEventListener("selectionchange",Ns,{capture:!0}),()=>{document.removeEventListener("selectionchange",Ns,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function Ns(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var Sr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),On,rs=class extends _n{constructor(e,t){super(e),this.manager=e,this.options=t,Te(this,On,[]),this.listeners=new uu,this.handleSourceKeyDown=(n,r,i)=>{if(this.disabled||n.defaultPrevented||!un(n.target)||r.disabled)return;const{keyboardCodes:s=Sr.keyboardCodes,preventActivation:o=Sr.preventActivation}=i??{};s.start.includes(n.code)&&this.manager.dragOperation.status.idle&&(o?.(n,r)||this.handleStart(n,r,i))}}bind(e,t=this.options){return ft(()=>{var n;const r=(n=e.handle)!=null?n:e.element,i=s=>{_r(s)&&this.handleSourceKeyDown(s,e,t)};if(r)return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}})}handleStart(e,t,n){const{element:r}=t;if(!r)throw new Error("Source draggable does not have an associated element");e.preventDefault(),e.stopImmediatePropagation(),bu(r);const{center:i}=new St(r);if(this.manager.actions.start({event:e,coordinates:{x:i.x,y:i.y},source:t}).signal.aborted)return this.cleanup();this.sideEffects();const s=nr(r),o=[this.listeners.bind(s,[{type:"keydown",listener:a=>this.handleKeyDown(a,t,n),options:{capture:!0}}])];ve(this,On).push(...o)}handleKeyDown(e,t,n){const{keyboardCodes:r=Sr.keyboardCodes}=n??{};if(yn(e,[...r.end,...r.cancel])){e.preventDefault();const i=yn(e,r.cancel);this.handleEnd(e,i);return}yn(e,r.up)?this.handleMove("up",e):yn(e,r.down)&&this.handleMove("down",e),yn(e,r.left)?this.handleMove("left",e):yn(e,r.right)&&this.handleMove("right",e)}handleEnd(e,t){this.manager.actions.stop({event:e,canceled:t}),this.cleanup()}handleMove(e,t){var n,r;const{shape:i}=this.manager.dragOperation,s=t.shiftKey?5:1;let o={x:0,y:0},a=(r=(n=this.options)==null?void 0:n.offset)!=null?r:Sr.offset;if(typeof a=="number"&&(a={x:a,y:a}),!!i){switch(e){case"up":o={x:0,y:-a.y*s};break;case"down":o={x:0,y:a.y*s};break;case"left":o={x:-a.x*s,y:0};break;case"right":o={x:a.x*s,y:0};break}(o.x||o.y)&&(t.preventDefault(),this.manager.actions.move({event:t,by:o}))}}sideEffects(){const e=this.manager.registry.plugins.get(Hu);e?.disabled===!1&&(e.disable(),ve(this,On).push(()=>{e.enable()}))}cleanup(){ve(this,On).forEach(e=>e()),Je(this,On,[])}destroy(){this.cleanup(),this.listeners.clear()}};On=new WeakMap;rs.configure=Zr(rs);rs.defaults=Sr;var qu=rs;function yn(e,t){return t.includes(e.code)}var rn,Kv=class extends Kd{constructor(){super(...arguments),Te(this,rn)}onEvent(e){switch(e.type){case"pointerdown":Je(this,rn,Hn(e));break;case"pointermove":if(!ve(this,rn))return;const{x:t,y:n}=Hn(e),r={x:t-ve(this,rn).x,y:n-ve(this,rn).y},{tolerance:i}=this.options;if(i&&ko(r,i)){this.abort();return}ko(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Je(this,rn,void 0)}};rn=new WeakMap;var Dn,sn,Yv=class extends Kd{constructor(){super(...arguments),Te(this,Dn),Te(this,sn)}onEvent(e){switch(e.type){case"pointerdown":Je(this,sn,Hn(e)),Je(this,Dn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!ve(this,sn))return;const{x:t,y:n}=Hn(e),r={x:t-ve(this,sn).x,y:n-ve(this,sn).y};ko(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){ve(this,Dn)&&(clearTimeout(ve(this,Dn)),Je(this,sn,void 0),Je(this,Dn,void 0))}};Dn=new WeakMap;sn=new WeakMap;var Pn=class{};Pn.Delay=Yv;Pn.Distance=Kv;var Fo=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&un(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new Pn.Delay({value:250,tolerance:5})]:sv(i)&&!e.defaultPrevented?[new Pn.Delay({value:200,tolerance:0})]:[new Pn.Delay({value:200,tolerance:10}),new Pn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!un(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=Mg(r);return i===t.element?!1:!!i}}),Tn,is=class extends _n{constructor(e,t){super(e),this.manager=e,this.options=t,Te(this,Tn,new Set),this.listeners=new uu,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:n,coordinates:r}=this.latest;!n||!r||this.manager.actions.move({event:n,to:r})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(e,t,n=this.options){const{activationConstraints:r=Fo.activationConstraints}=n??{};return typeof r=="function"?r(e,t):r}bind(e,t=this.options){return ft(()=>{var n;const r=new AbortController,{signal:i}=r,s=a=>{iv(a)&&this.handlePointerDown(a,e,t)};let o=[(n=e.handle)!=null?n:e.element];t?.activatorElements&&(Array.isArray(t.activatorElements)?o=t.activatorElements:o=t.activatorElements(e));for(const a of o)a&&(Zv(a.ownerDocument.defaultView),a.addEventListener("pointerdown",s,{signal:i}));return()=>r.abort()})}handlePointerDown(e,t,n){if(this.disabled||!e.isPrimary||e.button!==0||!un(e.target)||t.disabled||Xv(e)||!this.manager.dragOperation.status.idle)return;const{preventActivation:r=Fo.preventActivation}=n??{};if(r?.(e,t))return;const{target:i}=e,s=Vt(i)&&i.draggable&&i.getAttribute("draggable")==="true",o=Un(t.element),{x:a,y:d}=Hn(e);this.initialCoordinates={x:a*o.scaleX+o.x,y:d*o.scaleY+o.y};const f=this.activationConstraints(e,t,n);e.sensor=this;const c=new vg(f,g=>this.handleStart(t,g));c.signal.onabort=()=>this.handleCancel(e),c.onEvent(e),this.controller=c;const l=Mo(),u=this.listeners.bind(l,[{type:"pointermove",listener:g=>this.handlePointerMove(g,t)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:s?this.handleCancel:gi,options:{capture:!0}}]),p=()=>{u(),this.initialCoordinates=void 0};ve(this,Tn).add(p)}handlePointerMove(e,t){var n,r;if(((n=this.controller)==null?void 0:n.activated)===!1){(r=this.controller)==null||r.onEvent(e);return}if(this.manager.dragOperation.status.dragging){const i=Hn(e),s=Un(t.element);i.x=i.x*s.scaleX+s.x,i.y=i.y*s.scaleY+s.y,e.preventDefault(),e.stopPropagation(),this.latest.event=e,this.latest.coordinates=i,Zi.schedule(this.handleMove)}}handlePointerUp(e){const{status:t}=this.manager.dragOperation;if(!t.idle){e.preventDefault(),e.stopPropagation();const n=!t.initialized;this.manager.actions.stop({event:e,canceled:n})}this.cleanup()}handleKeyDown(e){e.key==="Escape"&&(e.preventDefault(),this.handleCancel(e))}handleStart(e,t){const{manager:n,initialCoordinates:r}=this;if(!r||!n.dragOperation.status.idle||t.defaultPrevented)return;if(n.actions.start({coordinates:r,event:t,source:e}).signal.aborted)return this.cleanup();t.preventDefault();const i=nr(t.target).body;try{i.setPointerCapture(t.pointerId)}catch{this.handleCancel(t);return}const s=un(t.target)?[t.target,i]:i,o=this.listeners.bind(s,[{type:"touchmove",listener:gi,options:{passive:!1}},{type:"click",listener:gi},{type:"contextmenu",listener:gi},{type:"keydown",listener:this.handleKeyDown}]);ve(this,Tn).add(o)}handleCancel(e){const{dragOperation:t}=this.manager;t.status.initialized&&this.manager.actions.stop({event:e,canceled:!0}),this.cleanup()}cleanup(){const{controller:e}=this;this.controller=void 0,e&&!e.signal.aborted&&e.abort(),this.latest={event:void 0,coordinates:void 0},ve(this,Tn).forEach(t=>t()),ve(this,Tn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};Tn=new WeakMap;is.configure=Zr(is);is.defaults=Fo;var Bo=is;function Xv(e){return"sensor"in e}function gi(e){e.preventDefault()}function Jv(){}var Yl=new WeakSet;function Zv(e){!e||Yl.has(e)||(e.addEventListener("touchmove",Jv,{capture:!1,passive:!1}),Yl.add(e))}var Ln={modifiers:[],plugins:[Sv,Hu,jv,Za,Gv],sensors:[Bo,qu]},Uu=class extends yg{constructor(e={}){const t=xt(e.plugins,Ln.plugins),n=xt(e.sensors,Ln.sensors),r=xt(e.modifiers,Ln.modifiers);super(Ka(Hr({},e),{plugins:[Uv,ni,bs,...t],sensors:n,modifiers:r}))}},Vu,Gu,_o,_t,nl,rl,xs=class extends(_o=jt,Gu=[ie],Vu=[ie],_o){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=$u(n,["element","effects","handle"]);super(Hr({effects:()=>[...i(),()=>{var a,d;const{manager:f}=this;if(!f)return;const c=((d=(a=this.sensors)==null?void 0:a.map(zr))!=null?d:[...f.sensors]).map(l=>{const u=l instanceof _n?l:f.registry.register(l.plugin),p=l instanceof _n?void 0:l.options;return u.bind(this,p)});return function(){c.forEach(l=>l())}}]},o),t),Te(this,nl,ze(_t,8,this)),ze(_t,11,this),Te(this,rl,ze(_t,12,this)),ze(_t,15,this),this.element=r,this.handle=s}};_t=ir(_o);nl=new WeakMap;rl=new WeakMap;pt(_t,4,"handle",Gu,xs,nl);pt(_t,4,"element",Vu,xs,rl);gn(_t,xs);var Ku,Yu,Ho,Ht,il,zs,Xu,Ju,Wr,sl,ys=class extends(Ho=Mt,Yu=[ie],Ku=[ie],Ho){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=$u(n,["element","effects"]);const{collisionDetector:o=yu}=s,a=f=>{const{manager:c,element:l}=this;if(!l||f===null){this.shape=void 0;return}if(!c)return;const u=new St(l),p=re(()=>this.shape);return u&&p?.equals(u)?p:(this.shape=u,u)},d=Kn(!1);super(Ka(Hr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:f,manager:c}=this;if(!c)return;const{dragOperation:l}=c,{source:u}=l;d.value=!!(u&&l.status.initialized&&f&&!this.disabled&&this.accepts(u))},()=>{const{element:f}=this;if(d.value&&f){const c=new Wg(f,a);return()=>{c.disconnect(),this.shape=void 0}}},()=>{var f;if((f=this.manager)!=null&&f.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),Te(this,Wr),Te(this,il,ze(Ht,8,this)),ze(Ht,11,this),Te(this,sl,ze(Ht,12,this)),ze(Ht,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Je(this,Wr,e,Ju)}get element(){var e;return(e=this.proxy)!=null?e:ve(this,Wr,Xu)}};Ht=ir(Ho);il=new WeakMap;Wr=new WeakSet;sl=new WeakMap;zs=pt(Ht,20,"#element",Yu,Wr,il),Xu=zs.get,Ju=zs.set;pt(Ht,4,"proxy",Ku,ys,sl);gn(Ht,ys);function Qv(e){return e!=null&&typeof e=="object"&&"current"in e}function Fn(e){var t;if(e!=null)return Qv(e)?(t=e.current)!=null?t:void 0:e}var eb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",sr=eb?S.useLayoutEffect:S.useEffect;function tb(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function Zu(e,t){const n=S.useRef(new Map),r=tb();return sr(()=>{if(!e){n.current.clear();return}return ft(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[d]=a,f=re(()=>a[1]),c=e[d];f!==c&&(s=!0,n.current.set(d,c),o=(i=t?.(d,f,c))!=null?i:!1)}s&&(o?queueMicrotask(()=>Fp.flushSync(r)):r())})},[e]),S.useMemo(()=>e&&new Proxy(e,{get(i,s){const o=i[s];return n.current.set(s,o),o}}),[e])}function nb(e,t){e()}function wn(e){const t=S.useRef(e);return sr(()=>{t.current=e},[e]),t}function Se(e,t,n=S.useEffect,r=Object.is){const i=S.useRef(e);n(()=>{const s=i.current;r(e,s)||(i.current=e,t(e,s))},[t,e])}function Ri(e,t){const n=S.useRef(Fn(e));sr(()=>{const r=Fn(e);r!==n.current&&(n.current=r,t(r))})}var rb=Object.defineProperty,ib=Object.defineProperties,sb=Object.getOwnPropertyDescriptors,ss=Object.getOwnPropertySymbols,Qu=Object.prototype.hasOwnProperty,eh=Object.prototype.propertyIsEnumerable,Xl=(e,t,n)=>t in e?rb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ob=(e,t)=>{for(var n in t||(t={}))Qu.call(t,n)&&Xl(e,n,t[n]);if(ss)for(var n of ss(t))eh.call(t,n)&&Xl(e,n,t[n]);return e},ab=(e,t)=>ib(e,sb(t)),lb=(e,t)=>{var n={};for(var r in e)Qu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ss)for(var r of ss(e))t.indexOf(r)<0&&eh.call(e,r)&&(n[r]=e[r]);return n},cb=new Uu,th=S.createContext(cb),db=S.memo(S.forwardRef(({children:e},t)=>{const[n,r]=S.useState(0),i=S.useRef(null),s=S.useRef(null),o=S.useMemo(()=>({renderer:{get rendering(){var a;return(a=i.current)!=null?a:Promise.resolve()}},trackRendering(a){i.current||(i.current=new Promise(d=>{s.current=d})),S.startTransition(()=>{a(),r(d=>d+1)})}}),[]);return sr(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),Ls=[void 0,mt];function ub(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:d}=t,f=lb(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=S.useRef(null),{plugins:l,modifiers:u,sensors:p}=f,g=xt(l,Ln.plugins),v=xt(p,Ln.sensors),x=xt(u,Ln.modifiers),k=wn(i),h=wn(s),b=wn(a),y=wn(o),w=wn(d),$=wn(r),M=hb(()=>{var T;return(T=f.manager)!=null?T:new Uu(f)});return S.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:T,trackRendering:j}=c.current,{monitor:O}=M;M.renderer=T;const P=[O.addEventListener("beforedragstart",R=>{const A=k.current;A&&j(()=>A(R,M))}),O.addEventListener("dragstart",R=>{var A;return(A=h.current)==null?void 0:A.call(h,R,M)}),O.addEventListener("dragover",R=>{const A=b.current;A&&j(()=>A(R,M))}),O.addEventListener("dragmove",R=>{const A=y.current;A&&j(()=>A(R,M))}),O.addEventListener("dragend",R=>{const A=w.current;A&&j(()=>A(R,M))}),O.addEventListener("collision",R=>{var A;return(A=$.current)==null?void 0:A.call($,R,M)})];return()=>P.forEach(R=>R())},[M]),Se(g,()=>M&&(M.plugins=g),...Ls),Se(v,()=>M&&(M.sensors=v),...Ls),Se(x,()=>M&&(M.modifiers=x),...Ls),m.jsxs(th.Provider,{value:M,children:[m.jsx(db,{ref:c,children:n}),n]})}function hb(e){const t=S.useRef(null);return t.current||(t.current=e()),S.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function fb(){return S.useContext(th)}function nh(e){var t;const n=(t=fb())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),sr(r.register,[n,r]),r}var pb=Object.create,rh=Object.defineProperty,mb=Object.getOwnPropertyDescriptor,ih=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ws=e=>{throw TypeError(e)},gb=(e,t,n)=>t in e?rh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vb=e=>{var t;return[,,,pb((t=e?.[ih("metadata")])!=null?t:null)]},sh=["class","method","getter","setter","accessor","field","value","get","set"],oh=e=>e!==void 0&&typeof e!="function"?ws("Function expected"):e,bb=(e,t,n,r,i)=>({kind:sh[e],name:t,metadata:r,addInitializer:s=>n._?ws("Already initialized"):i.push(oh(s||null))}),xb=(e,t)=>gb(t,ih("metadata"),e[3]),yb=(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},ah=(e,t,n,r,i,s)=>{for(var o,a,d,f,c=t&7,l=!1,u=!1,p=2,g=sh[c+5],v=e[p]||(e[p]=[]),x=(i=i.prototype,mb(i,n)),k=r.length-1;k>=0;k--)d=bb(c,n,a={},e[3],v),d.static=l,d.private=u,f=d.access={has:h=>n in h},f.get=h=>h[n],o=(0,r[k])(x[g],d),a._=1,oh(o)&&(x[g]=o);return x&&rh(i,n,x),i},lh=(e,t,n)=>t.has(e)||ws("Cannot "+n),wb=(e,t,n)=>(lh(e,t,"read from private field"),t.get(e)),kb=(e,t,n)=>t.has(e)?ws("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Sb=(e,t,n,r)=>(lh(e,t,"write to private field"),t.set(e,n),n),an=class qo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new qo(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 qo(t,n)}},ch,dh,Uo,Pi,ri,ol=class extends(Uo=pn,dh=[Ee],ch=[Ee],Uo){constructor(e){const t=an.from(e);super(t,(n,r)=>an.equals(n,r)),yb(ri,5,this),kb(this,Pi,0),this.velocity={x:0,y:0}}get delta(){return an.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=an.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-wb(this,Pi),o=a=>Math.round(a/s*100);je(()=>{Sb(this,Pi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(an.from(e)),this.velocity={x:0,y:0}}};ri=vb(Uo);Pi=new WeakMap;ah(ri,2,"delta",dh,ol);ah(ri,2,"direction",ch,ol);xb(ri,ol);var uh=(e=>(e.Horizontal="x",e.Vertical="y",e))(uh||{});Object.values(uh);var $b=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=an.distance(t.shape.center,n);return{id:r,value:1/i,type:tr.PointerIntersection,priority:er.High}}return null},jb=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=an.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:tr.ShapeIntersection,priority:er.Normal}}return null},Mb=e=>{var t;return(t=$b(e))!=null?t:jb(e)};function Cb(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,d=nh(c=>new ys(ab(ob({},e),{register:!1,element:Fn(i)}),c)),f=Zu(d);return Se(s,()=>d.id=s),Ri(i,c=>d.element=c),Se(o,()=>d.accept=o,void 0,mt),Se(t,()=>d.collisionDetector=t??Mb),Se(n,()=>n&&(d.data=n)),Se(r,()=>d.disabled=r===!0),Se(a,()=>d.type=a),{droppable:f,get isDropTarget(){return f.isDropTarget},ref:S.useCallback(c=>{var l,u;!c&&(l=d.element)!=null&&l.isConnected&&!((u=d.manager)!=null&&u.dragOperation.status.idle)||(d.element=c??void 0)},[d])}}const hh=(e,t="line")=>{const[n,r]=t==="line"?["6px","2px"]:["10px","6px"];return{cursor:"text",borderRadius:t==="line"?"4px":"6px",mx:`-${n}`,px:n,my:`-${r}`,py:r,transition:`background-color ${Fe}`,...Ut,"&:hover":{bgcolor:"action.hover"},"&:focus-visible":{outline:`2px solid ${e.accent}`,outlineOffset:-2}}},fh=S.createContext(void 0);function ph(e,t){const n=S.useContext(fh),r=S.useRef(t);r.current=t,S.useEffect(()=>{if(!n||!e)return;const s=()=>r.current();return n.commitRef.current=s,()=>{n.commitRef.current===s&&(n.commitRef.current=void 0)}},[n,e]);const i=S.useRef(!1);S.useLayoutEffect(()=>{!e&&!i.current||(i.current=e,n?.setDirty(e))},[n,e]),S.useLayoutEffect(()=>()=>{i.current&&n?.setDirty(!1)},[n])}function Vo({value:e,placeholder:t,ariaLabel:n,onCommit:r,faintWhenEmpty:i=!1}){const{theme:s}=He(),[o,a]=S.useState(void 0),d=S.useRef(!1),f=()=>{d.current||o===void 0||(a(void 0),o!==e&&r(o))};ph(o!==void 0&&o!==e,()=>(f(),!0));const c=()=>{d.current=!1,a(e)};if(o===void 0){const l=e==="",u=l&&i;return m.jsx(B,{component:"button",type:"button",className:u?"builder-affordance":void 0,onClick:c,onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c())},sx:[{all:"unset",boxSizing:"border-box",font:"inherit",color:"inherit",display:"inline-block",maxWidth:"100%",...l&&{fontStyle:"italic",opacity:u?0:.6}},hh(s)],children:l?t:e})}return m.jsx(zc,{autoFocus:!0,fullWidth:!0,value:o,placeholder:t,inputProps:{"aria-label":n},onFocus:l=>l.target.select(),onChange:l=>a(l.target.value),onKeyDown:l=>{l.key==="Enter"&&!l.nativeEvent.isComposing?f():l.key==="Escape"&&(d.current=!0,a(void 0))},onBlur:f,sx:{font:"inherit",color:"inherit",p:0,"& input":{p:0}}})}const Eb=(e,t)=>e.map((n,r)=>{const i=t[r]??!1;if(i===(n.break??!1))return n;const s={...n};return i?s.break=!0:delete s.break,s}),Ob=(e,t,n)=>{const r=[...e],[i]=r.splice(t,1);if(!i)return[...e];const s=r[t];i.break&&s&&!s.break&&(r[t]={...s,break:!0});const o={...i};return delete o.break,r.splice(n,0,o),r},mh=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),gh=e=>`gap.${e}`,Db=(e,t)=>{const n=[];let r=0;e.forEach((s,o)=>{const a=Math.min(s.colspan??1,t),d=o===0||s.break===!0||r+a>t;d&&o>0&&r<t&&n.push({kind:"gap",after:Ne(e[o-1]),colspan:t-r}),d&&(r=0),n.push(mh(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:Ne(i),colspan:t-r}),n};var Tb=Object.create,vh=Object.defineProperty,Ab=Object.defineProperties,Rb=Object.getOwnPropertyDescriptor,Pb=Object.getOwnPropertyDescriptors,os=Object.getOwnPropertySymbols,bh=Object.prototype.hasOwnProperty,xh=Object.prototype.propertyIsEnumerable,Ib=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ii=e=>{throw TypeError(e)},Go=(e,t,n)=>t in e?vh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fs=(e,t)=>{for(var n in t||(t={}))bh.call(t,n)&&Go(e,n,t[n]);if(os)for(var n of os(t))xh.call(t,n)&&Go(e,n,t[n]);return e},Bs=(e,t)=>Ab(e,Pb(t)),Wb=(e,t)=>{var n={};for(var r in e)bh.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&os)for(var r of os(e))t.indexOf(r)<0&&xh.call(e,r)&&(n[r]=e[r]);return n},Nb=e=>{var t;return[,,,Tb((t=void 0)!=null?t:null)]},yh=["class","method","getter","setter","accessor","field","value","get","set"],$r=e=>e!==void 0&&typeof e!="function"?ii("Function expected"):e,zb=(e,t,n,r,i)=>({kind:yh[e],name:t,metadata:r,addInitializer:s=>n._?ii("Already initialized"):i.push($r(s||null))}),Lb=(e,t)=>Go(t,Ib("metadata"),e[3]),vi=(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},wh=(e,t,n,r,i,s)=>{for(var o,a,d,f,c,l=t&7,u=!1,p=!1,g=e.length+1,v=yh[l+5],x=e[g-1]=[],k=e[g]||(e[g]=[]),h=(i=i.prototype,Rb({get[n](){return jr(this,s)},set[n](y){return on(this,s,y)}},n)),b=r.length-1;b>=0;b--)f=zb(l,n,d={},e[3],k),f.static=u,f.private=p,c=f.access={has:y=>n in y},c.get=y=>y[n],c.set=(y,w)=>y[n]=w,a=(0,r[b])({get:h.get,set:h.set},f),d._=1,a===void 0?$r(a)&&(h[v]=a):typeof a!="object"||a===null?ii("Object expected"):($r(o=a.get)&&(h.get=o),$r(o=a.set)&&(h.set=o),$r(o=a.init)&&x.unshift(o));return h&&vh(i,n,h),i},kh=(e,t,n)=>t.has(e)||ii("Cannot "+n),jr=(e,t,n)=>(kh(e,t,"read from private field"),t.get(e)),dr=(e,t,n)=>t.has(e)?ii("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),on=(e,t,n,r)=>(kh(e,t,"write to private field"),t.set(e,n),n);function ln(e){return e instanceof cl||e instanceof Mh}var bi=10,Fb=class extends Ue{constructor(e){super(e);const t=ft(()=>{const{dragOperation:r}=e;if(_r(r.activatorEvent)&&ln(r.source)&&r.status.initialized){const i=e.registry.plugins.get(ni);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(r,i)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:s}=i;if(!_r(r.nativeEvent)||!ln(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:d}=i,{by:f}=r;if(!f)return;const c=Bb(f),{source:l,target:u}=s,{center:p}=s.shape.current,g=[],v=[];je(()=>{for(const w of d.droppables){const{id:$}=w;if(!w.accepts(l)||$===u?.id&&ln(w)||!w.element)continue;let M=w.shape;const T=new St(w.element,{getBoundingClientRect:j=>Fr(j,void 0,.2)});!T.height||!T.width||(c=="down"&&p.y+bi<T.center.y||c=="up"&&p.y-bi>T.center.y||c=="left"&&p.x-bi>T.center.x||c=="right"&&p.x+bi<T.center.x)&&(g.push(w),w.shape=T,v.push(()=>w.shape=M))}}),r.preventDefault(),a.disable();const x=a.computeCollisions(g,lv);je(()=>v.forEach(w=>w()));const[k]=x;if(!k)return;const{id:h}=k,{index:b,group:y}=l.sortable;o.setDropTarget(h).then(()=>{const{source:w,target:$,shape:M}=s;if(!w||!ln(w)||!M)return;const{index:T,group:j,target:O}=w.sortable,P=b!==T||y!==j,R=P?O:$?.element;if(!R)return;bu(R);const A=new St(R);if(!A)return;const z=$t.delta(A,$t.from(M.current.boundingRectangle),w.alignment);o.move({by:z}),P?o.setDropTarget(w.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Bb(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}var _b=Object.defineProperty,Hb=Object.defineProperties,qb=Object.getOwnPropertyDescriptors,Jl=Object.getOwnPropertySymbols,Ub=Object.prototype.hasOwnProperty,Vb=Object.prototype.propertyIsEnumerable,Zl=(e,t,n)=>t in e?_b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kn=(e,t)=>{for(var n in t||(t={}))Ub.call(t,n)&&Zl(e,n,t[n]);if(Jl)for(var n of Jl(t))Vb.call(t,n)&&Zl(e,n,t[n]);return e},Sn=(e,t)=>Hb(e,qb(t));function Gb(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function xi(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function _s(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Kb(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const d=(h,b)=>h===b||h!==null&&typeof h=="object"&&"id"in h&&h.id===b;if(Array.isArray(e)){const h=e.findIndex(y=>d(y,s.id)),b=e.findIndex(y=>d(y,o.id));if(h===-1||b===-1){if(_s(s)){const y=s.initialIndex,w=s.index;return y===w||y<0||y>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,y,w)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const y=s.index;if(y!==h)return n(e,h,y)}return n(e,h,b)}const f=Object.entries(e);let c=-1,l,u=-1,p;for(const[h,b]of f)if(c===-1&&(c=b.findIndex(y=>d(y,s.id)),c!==-1&&(l=h)),u===-1&&(u=b.findIndex(y=>d(y,o.id)),u!==-1&&(p=h)),c!==-1&&u!==-1)break;if(c===-1&&_s(s)){const h=s.initialGroup==null?void 0:xi(e,s.initialGroup),b=s.initialIndex,y=s.group==null?void 0:xi(e,s.group),w=s.index;if(h==null||y==null||h===y&&b===w)return"preventDefault"in t&&t.preventDefault(),e;if(h===y)return Sn(kn({},e),{[h]:n(e[h],b,w)});const $=e[h][b];return Sn(kn({},e),{[h]:[...e[h].slice(0,b),...e[h].slice(b+1)],[y]:[...e[y].slice(0,w),$,...e[y].slice(w)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,v=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(p==null){const h=xi(e,o.id);if(h!=null){const b=o.shape&&v.y>o.shape.center.y?e[h].length:0;p=h,u=b}}if(l==null||p==null||l===p&&c===u){if(l!=null&&l===p&&c===u&&_s(s)){const h=s.group==null?void 0:xi(e,s.group),b=s.group!=null&&h!==l,y=s.index!==c;if(b||y){const w=s.group==null?l:h;if(w!=null){if(l===w)return Sn(kn({},e),{[l]:n(e[l],c,s.index)});const $=e[l][c];return Sn(kn({},e),{[l]:[...e[l].slice(0,c),...e[l].slice(c+1)],[w]:[...e[w].slice(0,s.index),$,...e[w].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(l===p)return Sn(kn({},e),{[l]:n(e[l],c,u)});const x=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,k=e[l][c];return Sn(kn({},e),{[l]:[...e[l].slice(0,c),...e[l].slice(c+1)],[p]:[...e[p].slice(0,u+x),k,...e[p].slice(u+x)]})}function Yb(e,t){return Kb(e,t,Gb)}function Ql(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function ec(e,t,n){var r;for(const[i,s]of t)for(const o of s){const a=e.get(o.id);if(o.index!==a||o.group!==i||!((r=n.get(i))!=null&&r.has(o)))return!0}return!1}var tc="__default__",Xb=class extends Ue{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof cl){const{sortable:s}=i,{group:o}=s;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(s)}return r},n=[e.monitor.addEventListener("dragover",(r,i)=>{if(this.disabled)return;const{dragOperation:s}=i,{source:o,target:a}=s;if(!ln(o)||!ln(a)||o.sortable===a.sortable)return;const d=t(),f=Ql(d),c=o.sortable.group===a.sortable.group,l=d.get(o.sortable.group),u=c?l:d.get(a.sortable.group);!l||!u||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var p,g;const v=t();if(ec(f,d,v))return;const x=o.sortable.element,k=a.sortable.element;if(!k||!x||!c&&a.id===o.sortable.group)return;const h=yi(l),b=c?h:yi(u),y=(p=o.sortable.group)!=null?p:tc,w=(g=a.sortable.group)!=null?g:tc,$={[y]:h,[w]:b},M=Yb($,r);if($===M)return;const T=M[w].indexOf(o.sortable),j=M[w].indexOf(a.sortable);i.collisionObserver.disable(),nc(x,T,k,j),je(()=>{for(const[O,P]of M[y].entries())P.index=O;if(!c)for(const[O,P]of M[w].entries())P.group=a.sortable.group,P.index=O}),i.actions.setDropTarget(o.id).then(()=>i.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,i)=>{if(!r.canceled)return;const{dragOperation:s}=i,{source:o}=s;ln(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),d=Ql(a),f=a.get(o.sortable.initialGroup);f&&i.renderer.rendering.then(()=>{const c=t();if(ec(d,a,c))return;const l=yi(f),u=yi(f,Zb),p=o.sortable.element,g=u.indexOf(o.sortable),v=l[g],x=v?.element;!v||!x||!p||(nc(p,v.index,x,o.index),je(()=>{for(const k of a.values()){const h=Array.from(k).values();for(const b of h)b.index=b.initialIndex,b.group=b.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function nc(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function Jb(e,t){return e.index-t.index}function Zb(e,t){return e.initialIndex-t.initialIndex}function yi(e,t=Jb){return Array.from(e).sort(t)}var rc=[Fb,Xb],Sh={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function ic(e){var t,n;return typeof e=="boolean"?{draggable:e,droppable:e}:{draggable:(t=e?.draggable)!=null?t:!1,droppable:(n=e?.droppable)!=null?n:!1}}var wi=new Um,$h,jh,qt,al,Mr,Cr,ll,An;jh=[ie],$h=[ie];var ks=class{constructor(e,t){dr(this,al,vi(qt,8,this)),vi(qt,11,this),dr(this,Mr),dr(this,Cr),dr(this,ll,vi(qt,12,this)),vi(qt,15,this),dr(this,An),this.register=()=>(je(()=>{var g,v;(g=this.manager)==null||g.registry.register(this.droppable),(v=this.manager)==null||v.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{je(()=>{var g,v;(g=this.manager)==null||g.registry.unregister(this.droppable),(v=this.manager)==null||v.registry.unregister(this.draggable)})},this.destroy=()=>{je(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:d,transition:f=Sh,plugins:c}=n,l=Wb(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const u=xt(c,rc),p=ic(i);this.droppable=new cl(Bs(Fs({},l),{disabled:p.droppable}),t,this),this.draggable=new Mh(Bs(Fs({},l),{disabled:p.draggable,plugins:u,effects:()=>[()=>{var g,v,x;const k=(g=this.manager)==null?void 0:g.dragOperation.status;k?.initializing&&this.id===((x=(v=this.manager)==null?void 0:v.dragOperation.source)==null?void 0:x.id)&&wi.clear(this.manager),k?.dragging&&wi.set(this.manager,this.id,re(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:g,group:v,manager:x}=this,k=jr(this,Cr),h=jr(this,Mr);(g!==k||v!==h)&&(on(this,Cr,g),on(this,Mr,v),this.animate())},()=>{var g,v;const{target:x}=this,{isDragSource:k}=this.draggable;((v=(g=this.draggable.pluginConfig(Za))==null?void 0:g.feedback)!=null?v:"default")==="move"&&k&&(this.droppable.disabled=!x)},...r()],type:d,sensors:a}),t,this),on(this,An,l.element),this.manager=t,this.index=o,on(this,Cr,o),this.group=s,on(this,Mr,s),this.type=d,this.transition=f}get initialIndex(){var e,t;return(t=(e=wi.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=wi.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){re(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:i}=this;if(!i)return;for(const c of i.getAnimations())"transitionProperty"in c&&(c.transitionProperty==="transform"||c.transitionProperty==="translate"||c.transitionProperty==="scale")&&c.cancel();const s=this.refreshShape();if(!s)return;const o={x:n.boundingRectangle.left-s.boundingRectangle.left,y:n.boundingRectangle.top-s.boundingRectangle.top},{translate:a}=Ct(i),d=Bl(i,a,!1),f=Bl(i,a);if(o.x||o.y){const c=qa(at(i))?Bs(Fs({},t),{duration:0}):t;xu({element:i,keyframes:{translate:[`${d.x+o.x}px ${d.y+o.y}px ${d.z}`,`${f.x}px ${f.y}px ${f.z}`]},options:c}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){je(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){je(()=>{const t=jr(this,An),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),on(this,An,e)})}get element(){var e,t;const n=jr(this,An);if(n)return(t=(e=Co.get(n))!=null?e:n)!=null?t:this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){const{disabled:e}=this.draggable,{disabled:t}=this.droppable;return e===t?e:{draggable:e,droppable:t}}set plugins(e){this.draggable.plugins=xt(e,rc)}set disabled(e){const t=ic(e);je(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){je(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??yu}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){je(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};qt=Nb();al=new WeakMap;Mr=new WeakMap;Cr=new WeakMap;ll=new WeakMap;An=new WeakMap;wh(qt,4,"index",jh,ks,al);wh(qt,4,"group",$h,ks,ll);Lb(qt,ks);var Mh=class extends xs{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},cl=class extends ys{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Qb=Object.defineProperty,ex=Object.defineProperties,tx=Object.getOwnPropertyDescriptors,sc=Object.getOwnPropertySymbols,nx=Object.prototype.hasOwnProperty,rx=Object.prototype.propertyIsEnumerable,oc=(e,t,n)=>t in e?Qb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hs=(e,t)=>{for(var n in t||(t={}))nx.call(t,n)&&oc(e,n,t[n]);if(sc)for(var n of sc(t))rx.call(t,n)&&oc(e,n,t[n]);return e},ix=(e,t)=>ex(e,tx(t));function sx(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:d,group:f,disabled:c,modifiers:l,sensors:u,target:p,type:g,plugins:v}=e,x=Hs(Hs({},Sh),e.transition),k=nh(b=>new ks(ix(Hs({},e),{transition:x,register:!1,handle:Fn(a),element:Fn(o),target:Fn(p)}),b)),h=Zu(k,ox);return Se(i,()=>k.id=i),sr(()=>{je(()=>{k.group=f,k.index=d})},[k,f,d]),Se(g,()=>k.type=g),Se(t,()=>k.accept=t,void 0,mt),Se(s,()=>s&&(k.data=s)),Se(d,()=>{var b;(b=k.manager)!=null&&b.dragOperation.status.idle&&x?.idle&&k.refreshShape()},nb),Ri(a,b=>k.handle=b),Ri(o,b=>k.element=b),Ri(p,b=>k.target=b),Se(c,()=>k.disabled=c??!1,void 0,mt),Se(u,()=>k.sensors=u,void 0,mt),Se(n,()=>k.collisionDetector=n),Se(r,()=>k.collisionPriority=r),Se(v,()=>k.plugins=v,void 0,mt),Se(x,()=>k.transition=x,void 0,mt),Se(l,()=>k.modifiers=l,void 0,mt),Se(e.alignment,()=>k.alignment=e.alignment),{sortable:h,get isDragging(){return h.isDragging},get isDropping(){return h.isDropping},get isDragSource(){return h.isDragSource},get isDropTarget(){return h.isDropTarget},handleRef:S.useCallback(b=>{k.handle=b??void 0},[k]),ref:S.useCallback(b=>{var y,w;!b&&(y=k.element)!=null&&y.isConnected&&!((w=k.manager)!=null&&w.dragOperation.status.idle)||(k.element=b??void 0)},[k]),sourceRef:S.useCallback(b=>{var y,w;!b&&(y=k.source)!=null&&y.isConnected&&!((w=k.manager)!=null&&w.dragOperation.status.idle)||(k.source=b??void 0)},[k]),targetRef:S.useCallback(b=>{var y,w;!b&&(y=k.target)!=null&&y.isConnected&&!((w=k.manager)!=null&&w.dragOperation.status.idle)||(k.target=b??void 0)},[k])}}function ox(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Ko="tile",Ch="gap",ax=[Bo.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>e.target instanceof Element&&e.target.closest(`[${Eh}], ${lx}`)!==null||(Bo.defaults.preventActivation?.(e,t)??!1)}),qu],Eh="data-no-drag",lx=".malloy-render, .malloy-table",cx=e=>[...e,Za.configure({feedback:"clone"})];function dx({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=sx({id:e,index:t,type:Ko,accept:Ko,collisionDetector:Va,plugins:cx});return m.jsx(m.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function ux({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=Cb({id:e,type:Ch,accept:Ko,collisionDetector:Va,data:{after:t}});return m.jsx(m.Fragment,{children:n({ref:r,isDropTarget:i})})}const Oh=e=>e.ok===!1,Re=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),or=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,ke={sourceDefinition:e=>Re(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>Re(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>Re(e,"VIEW","subQueryDefList"),defDimension:e=>Re(e,"defList","DIMENSION"),exploreProperties:e=>Re(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>Re(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>Re(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>Re(e,"WHERE","filterClauseList"),givenDef:e=>Re(e,"givenNameDef"),givenStatement:e=>Re(e,"GIVEN","givenDefList"),importStatement:e=>Re(e,"IMPORT","importURL"),vArrow:e=>Re(e,"ARROW","vExpr","segExpr"),segRefine:e=>Re(e,"PLUS","segExpr"),segOps:e=>Re(e,"queryProperties"),segField:e=>Re(e,"fieldPath")&&!Re(e,"segExpr"),segParen:e=>Re(e,"OPAREN","CPAREN","vExpr"),compare:e=>Re(e,"fieldExpr","compareOp"),givenRef:e=>Re(e,"GIVEN_REF")};function hx(e){const t=new Int32Array([...e].length+1);let n=0;for(let r=0;r<e.length;)t[n++]=r,r+=e.codePointAt(r)>65535?2:1;return t[n]=e.length,t}function fx(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
68
|
+
`&&t.push(n+1);return t}function Dh(e,t){const n=[];for(let r=0;r<(t.childCount??0);r++){const i=t.getChild(r);if(!or(i))continue;const s=Oe(i,"docAnnotations");if(s)for(const o of Kt(s,"docAnnotation")){const a=e.text_(o);a!==void 0&&n.push(a.replace(/\r?\n\|##[^\n]*\n?$/,""))}}return n}class Th{constructor(t){this.text=t,this.map=hx(t),this.lineStarts=fx(t)}map;lineStarts;commentLines=new Set;proseLines=new Set;blocks=[];span(t){if(!or(t))return;const n=t.start,r=t.stop;if(!n||!r)return;const i=this.map[n.startIndex],s=this.map[r.stopIndex+1];if(!(i===void 0||s===void 0||s<i))return{start:i,end:s}}terminal(t){const n=t?.symbol;if(!n)return;const r=this.map[n.startIndex],i=this.map[n.stopIndex+1];if(!(r===void 0||i===void 0||i<r))return{start:r,end:i}}utf16(t){return this.map[t]}text_(t){const n=this.span(t);return n&&this.text.slice(n.start,n.end)}line(t){let n=0,r=this.lineStarts.length-1;for(;n<r;){const i=n+r+1>>1;this.lineStarts[i]<=t?n=i:r=i-1}return n}positioned(t){const n=this.span(t);return n&&{span:n,line:this.line(n.start)}}indentAt(t){const n=this.lineStarts[this.line(t)];return/^[ \t]*/.exec(this.text.slice(n))?.[0]??""}}function si(e,t,n=[]){or(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)si(e.getChild(r),t,n);return n}const px=e=>Re(e,"OCURLY","CCURLY");function Gr(e,t){const n=[],r=i=>{if(or(i)){if(t(i)){n.push(i);return}if(!px(i))for(let s=0;s<(i.childCount??0);s++)r(i.getChild(s))}};for(let i=0;i<(e.childCount??0);i++)r(e.getChild(i));return n}const Oe=(e,t)=>e[t]?.call(e),Kt=(e,t)=>e[t]?.call(e)??[];function mx(e,t){if(!ke.compare(t)||(t.childCount??0)!==3)return;const n=t.getChild(2);if(!ke.givenRef(n))return;const r=e.text_(t.getChild(0)),i=e.text_(t.getChild(1)),s=e.text_(n)??"";if(!(r===void 0||i===void 0))return{field:r,op:i.trim(),given:s.replace(/^\$/,"")}}function Ah(e,t){const n=e.positioned(t);if(!n)return;const r=Oe(t,"filterClauseList"),i=[];for(const s of r?Kt(r,"fieldExpr"):[]){const o=e.positioned(s);if(!o)continue;const a=si(s,ke.givenRef).map(d=>e.text_(d)).filter(d=>d!==void 0).map(d=>d.replace(/^\$/,""));i.push({...o,givens:a,binding:mx(e,s)})}return{...n,clauses:i}}function Yo(e,t){const n=e.span(t);if(!n)return;const r=[],i=[];for(const f of Gr(t,ke.queryStatement)){const c=e.positioned(f);c&&r.push(c);const l=Oe(f,"whereStatement");if(l&&ke.whereStatement(l)){const u=Ah(e,l);u&&i.push(u)}}const s=n.start+1,o=n.end-1,a=!e.text.slice(n.start,n.end).includes(`
|
|
69
|
+
`),d=r.length?e.indentAt(r[0].span.start):e.indentAt(n.start)+" ";return{span:n,openEnd:s,closeStart:o,statements:r,wheres:i,indent:d,oneLine:a}}function dl(e,t,n){const r=[],i=e.line(t.start),s=e.line(n);for(let o=i;o<s;o++){if(e.commentLines.has(o)||e.proseLines.has(o))continue;const a=e.text.slice(e.lineStarts[o],e.lineStarts[o+1]??e.text.length).trim();a.startsWith("#")&&!a.startsWith("##")&&r.push({line:o,text:a})}return r}function gx(e,t){const n=Oe(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=ke.vArrow(t);if(ke.segOps(n)){const i=Oe(n,"queryProperties"),s=i&&Yo(e,i);return s?{kind:"inline",stage:s,...r?{pipeline:!0}:{}}:{kind:"unsupported",why:"an unreadable body"}}if(r)return{kind:"unsupported",why:"a `->` pipeline from a named view"};if(ke.segField(n)){const i=e.span(n);return i?{kind:"reference",from:e.text.slice(i.start,i.end),fromSpan:i}:{kind:"unsupported",why:"an unreadable name"}}if(ke.segRefine(n)){const i=Kt(n,"segExpr"),s=i[0],o=i[i.length-1];let a=s;for(;ke.segRefine(a);){const u=Kt(a,"segExpr");if(u.some(p=>ke.segOps(p)||ke.segParen(p)))return{kind:"unsupported",why:"a chained refinement"};a=u[0]}if(a&&ke.segParen(a))return{kind:"unsupported",why:"a parenthesized expression"};if(!a||!ke.segField(a))return{kind:"unsupported",why:"a `{ … } + { … }` compound refinement"};const d=e.span(s);if(!d||!o)return{kind:"unsupported",why:"an unreadable refinement"};if(!ke.segOps(o)){const u=e.span(n);return u?{kind:"reference",from:e.text.slice(u.start,u.end),fromSpan:u}:{kind:"unsupported",why:"an unreadable refinement"}}const f=e.text.slice(d.start,d.end),c=Oe(o,"queryProperties"),l=c&&Yo(e,c);return l?{kind:"reference",from:f,fromSpan:d,refinement:l}:{kind:"reference",from:f,fromSpan:d}}return{kind:"unsupported",why:"a parenthesized expression"}}function vx(e,t){const n=[];for(const r of Gr(t,ke.defExploreQuery)){const i=e.span(r),s=Oe(r,"subQueryDefList");if(!i||!s)continue;const o=Kt(s,"exploreQueryDef").filter(ke.exploreQueryDef),a=e.terminal(Oe(r,"VIEW"));for(const d of o){const f=e.span(d),c=Oe(d,"exploreQueryNameDef"),l=e.text_(c),u=Oe(d,"vExpr");!f||!l||!u||n.push({name:l,span:f,line:e.line(f.start),statement:i,tags:dl(e,i,a?.start??f.start),siblings:o.length,body:gx(e,u)})}}return n}function bx(e,t){const n=[];for(const r of Gr(t,ke.defDimension)){const i=e.span(r),s=Oe(r,"defList");if(!i||!s)continue;const o=e.terminal(Oe(r,"DIMENSION"));for(const a of Kt(s,"fieldDef")){const d=e.span(a),f=e.text_(Oe(a,"fieldNameDef"))?.trim(),c=e.text_(Oe(a,"fieldExpr"))?.trim();!d||!f||c===void 0||n.push({name:f,expression:c,span:d,line:e.line(d.start),statement:i,tags:dl(e,i,o?.start??d.start)})}}return n}function xx(e,t){const n=[];for(const r of si(t,ke.sourceDefinition)){const i=e.span(r),s=e.text_(Oe(r,"sourceNameDef")),o=Oe(r,"sqExplore");if(!i||!s||!o)continue;const a=e.span(o),d=a?e.text.slice(a.start,a.end):"",f=(/^\s*(`[^`]*`|[A-Za-z_][A-Za-z0-9_.]*)/.exec(d)?.[1]??"").trim(),c=Gr(o,ke.exploreProperties)[0],l=c&&Yo(e,c),u={start:e.lineStarts[e.line(i.start)],end:i.end},p=[];if(c)for(const g of Gr(c,ke.whereStatement)){const v=Ah(e,g);v&&p.push(v)}n.push({name:s,base:f,span:i,line:e.line(i.start),statement:u,...l?{properties:l}:{},views:c?vx(e,c):[],dimensions:c?bx(e,c):[],wheres:p})}return n}function yx(e,t){const n=[];for(const r of si(t,ke.givenStatement)){const i=e.terminal(Oe(r,"GIVEN")),s=Oe(r,"givenDefList"),o=i?e.line(i.start):void 0;for(const a of s?Kt(s,"givenDef"):[]){const d=e.span(a),f=e.span(Oe(a,"givenNameDef")),c=f&&e.text.slice(f.start,f.end);if(!d||!f||!c)continue;const l={start:f.start,end:d.end},u=e.line(l.start);n.push({name:c,declaration:e.text.slice(l.start,l.end),span:l,line:u,statement:{start:e.lineStarts[u],end:l.end},tags:dl(e,d,l.start),...o!==void 0&&o!==u?{blockHeader:o}:{}})}}return n}function wx(e,t){const n=[];for(const r of si(t,ke.importStatement)){const i=e.span(r),s=e.text_(Oe(r,"importURL"));if(!i||s===void 0)continue;const o=Oe(r,"importSelect"),a=o?Kt(o,"importItem").map(d=>e.text_(d)).filter(d=>d!==void 0).map(d=>d.trim()):void 0;n.push({from:s.replace(/^['"]|['"]$/g,""),...a&&a.length>0?{names:a}:{},span:i,line:e.line(i.start),statement:i})}return n}async function Rh(e){let t;try{t=await ul(e,"file://dashboard-builder.malloy")}catch(u){return{ok:!1,reason:`Malloy could not read this file: ${u}`}}const n=t.problems.filter(u=>u.code==="syntax-error");if(n.length>0)return{ok:!1,reason:`This file has a Malloy syntax error, so it cannot be edited here: ${n[0].message??"unknown"}`};const r=t.parse,i=r?.root;if(!i||!or(i)||typeof i.getChild!="function")return{ok:!1,reason:`This build of Malloy does not expose a parse tree the builder can read (malloy ${r?.malloyVersion??"unknown"}), so editing is off.`};const s=r?.tokenStream??{},o=typeof s.getTokens=="function"?s.getTokens():void 0;if(!o||typeof s.tokenSource?.vocabulary?.getSymbolicName!="function"||o.length===0&&e.trim()!=="")return{ok:!1,reason:`This build of Malloy does not expose a token stream the builder can read (malloy ${r?.malloyVersion??"unknown"}), so it cannot tell a comment from code and editing is off.`};const a=new Th(e),d=kx(a,s);a.commentLines=d.lines;const f=e.split(`
|
|
70
|
+
`),c=u=>d.lines.has(u);a.proseLines=Op(f,c),a.blocks=Dp(f,c).filter(([u])=>!f[u].trimStart().startsWith("##"));const l=xx(a,i);return l.length===0&&/^\s*source:/m.test(e)?{ok:!1,reason:`The builder could not locate this file's sources in Malloy's parse tree (malloy ${r?.malloyVersion??"unknown"}), so editing is off.`}:{ok:!0,parsed:{text:e,lineStarts:a.lineStarts,imports:wx(a,i),sources:l,givens:yx(a,i),textBlocks:$x(a,s),modelNotes:Dh(a,i),trailingComment:u=>d.trailing.get(u),comments:d.all,commentLine:u=>d.lines.has(u),proseLine:u=>a.proseLines.has(u),commentIn:u=>d.all.find(p=>p.start>=u.start&&p.start<u.end),blockStart:u=>Sx(a,d.lines,u)}}}async function ul(e,t){const{MalloyTranslator:n}=await ap(),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function kx(e,t){const n=new Map,r=new Set,i=[],s=t.tokenSource?.vocabulary;for(const c of t.getTokens?.()??[]){const l=s?.getSymbolicName(c.type);if(l!=="COMMENT_TO_EOL"&&l!=="BLOCK_COMMENT")continue;const u=e.utf16(c.startIndex);let p=e.utf16(c.stopIndex+1);if(!(u===void 0||p===void 0||p<u)){for(;p>u&&(e.text[p-1]===`
|
|
71
|
+
`||e.text[p-1]==="\r");)p--;i.push({start:u,end:p})}}const o=[...i].sort((c,l)=>c.start-l.start);let a="",d=0;for(const c of o)a+=e.text.slice(d,Math.max(d,c.start)),a+=e.text.slice(Math.max(d,c.start),Math.max(d,c.end)).replace(/[^\n\r]/g," "),d=Math.max(d,c.end);a+=e.text.slice(d);const f=c=>a.slice(e.lineStarts[c],e.lineStarts[c+1]??a.length);for(const c of i){const l=e.line(c.start),u=e.line(c.end-1);for(let v=l;v<=u;v++)f(v).trim()===""&&r.add(v);const p=a.slice(e.lineStarts[l],c.start).trim(),g=a.slice(c.end,e.lineStarts[u+1]??a.length).trim();p!==""&&g===""&&n.set(u,c)}return{trailing:n,lines:r,all:i}}function Sx(e,t,n){const r=s=>e.text.slice(e.lineStarts[s],e.lineStarts[s+1]??e.text.length).trim();let i=n;for(let s=n-1;s>=0;s--){const o=r(s),a=e.blocks.find(([,d])=>d===s);if(a){i=s=a[0];continue}if(o===""&&!t.has(s))break;if(o.startsWith("#")||t.has(s))i=s;else break}return i}function $x(e,t){const n=t.getTokens?.()??[],r=t.tokenSource?.vocabulary,i=a=>r?.getSymbolicName(a.type),s=a=>e.text.slice(e.utf16(a.startIndex)??0,e.utf16(a.stopIndex+1)??e.text.length),o=[];for(let a=0;a<n.length;a++){if(i(n[a])!=="DOC_BLOCK_ANNOTATION_BEGIN")continue;const d=zp(s(n[a]).replace(/\r?\n$/,""));if(!d)continue;const f=[];let c=a+1;for(;i(n[c]??n[a])==="BLOCK_ANNOTATION_TEXT";c++)f.push(s(n[c]));const l=n[c];if(!l||i(l)!=="BLOCK_ANNOTATION_END")continue;const u=e.line(e.utf16(n[a].startIndex)??0),p=e.utf16(l.stopIndex+1)??e.text.length,g=d.name===void 0&&d.rest?[`${d.rest}
|
|
72
|
+
`]:[];o.push({...d.name===void 0?{}:{name:d.name},route:d.route,body:[...g,...f].join("").replace(/\r\n?/g,`
|
|
73
|
+
`).replace(/\n$/,""),span:{start:e.lineStarts[u],end:p},line:u}),a=c}return o}function Ph(e,t){for(let n=t+1;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==='"')return n;return e.length}function Ih(e){let t=0,n=0;for(let r=0;r<e.length;r++){const i=e[r];if(i==='"')r=Ph(e,r);else if(i==="{"||i==="[")t++===0&&n++;else if(i==="}"||i==="]")t--;else if(n===1&&t===1&&e.startsWith("tiles",r)&&!/[A-Za-z0-9_]/.test(e[r-1]??" ")){const s=/^tiles\s*=\s*\[/.exec(e.slice(r));if(s)return jx(e,r+s[0].length-1)}}}function jx(e,t){const n=[];let r=0,i=t+1;const s=o=>{const a=e.slice(i,o),d=a.length-a.trimStart().length,f=a.trim();f!==""&&n.push({text:f,span:{start:i+d,end:i+d+f.length}})};for(let o=t+1;o<e.length;o++){const a=e[o];if(a==='"')o=Ph(e,o);else if(a==="{"||a==="[")r++;else if(a==="}")r--;else if(a==="]"){if(r===0)return s(o),{open:t,close:o,entries:n};r--}else a===","&&r===0&&(s(o),i=o+1)}}function Mx(e,t){const n=e[t];if(n==="`"){for(let r=t+1;r<e.length;r++)if(e[r]==="\\")r++;else{if(e[r]==="`")return r+1;if(e[r]===`
|
|
74
|
+
`)return e.length}return e.length}if(e.startsWith("<<<",t)){let r=t+3;for(;;){const i=e.indexOf(`
|
|
75
|
+
`,r),s=i===-1?e.length:i;if(e.slice(r,s).trim()===">>>")return s;if(i===-1)return e.length;r=i+1}}if(n==='"'||n==="'"){const r=n.repeat(3);if(e.startsWith(r,t)){for(let i=t+3;i<e.length;i++)if(e[i]==="\\")i++;else if(e.startsWith(r,i))return i+3;return e.length}for(let i=t+1;i<e.length;i++)if(e[i]==="\\")i++;else{if(e[i]===n)return i+1;if(e[i]===`
|
|
76
|
+
`)return i}return e.length}return t}function Cx(e){const t=/^([ \t]*)f(['"])((?:\\.|(?!\2)[^\\])*)\2/;let n="",r=0;for(;r<e.length;){const i=Mx(e,r);if(i>r){n+=e.slice(r,i),r=i;continue}const s=e[r];if(/[=[,]/.test(s)){const o=t.exec(e.slice(r+1));if(o){const a=o[3].replace(/\\/g,"\\\\").replace(/"/g,'\\"');n+=`${s}${o[1]}"f'${a}'"`,r+=1+o[0].length;continue}}n+=s,r+=1}return n}function Wh(e,t){const n=e(t);if(n.log.length===0)return{tag:n.tag,errors:[]};const r=t.map(s=>{if(e([s]).log.length===0)return s;const o=Cx(s);return e([o]).log.length===0?o:s}),i=e(r);return{tag:i.tag,errors:i.log.map(s=>s.message)}}const ac=(e,t)=>{try{return e.text(t)}catch{return}},Ex=e=>/^##\|?(?:[ \t\r\n]|$)/.test(e),Ox=e=>`\`kind=${e}\` is no longer read, so this file is not a report. Fix: remove \`kind=${e}\` and write \`layout=grid\` or \`layout=linear\`.`,Dx=e=>`\`layout=${e}\` is not a layout Publisher knows (grid, linear), and the tag lists no tiles, so this file is not a report. Fix: write \`layout=grid\` or \`layout=linear\`, and list the tiles in \`tiles=[…]\`.`,Tx="A linear report written as `run:` cells is no longer read, so this file is not a report. Fix: list its tiles in `tiles=[…]` (a text tile per prose block, a query tile per view), or remove the `## artifact` tag.";function Nh(e,t){const n=e.filter(Ex).filter(c=>!c.includes("@env.")).map(Wc),{tag:r,errors:i}=n.length>0?Wh(t,n):{tag:void 0,errors:[]},s=r?.tag("artifact");if(!s)return e.some(lp)?{status:"unparsed",errors:i}:{status:"none"};const o=ac(s,"kind");if(o!==void 0)return{status:"kind-removed",kind:o};const a=ac(s,"layout"),d=s.has("tiles");if(d&&s.array("tiles")===void 0)return{status:"unparsed",errors:i};const f=a==="grid"||a==="linear"?a:d||r?.tag("dashboard")!==void 0?"grid":"linear";return f==="linear"&&!d?a!==void 0&&a!=="grid"&&a!=="linear"?{status:"cells-removed",unknownLayout:a}:{status:"cells-removed"}:{status:"report",layout:f}}async function S0(e){const{parseAnnotation:t}=await Oc();let n=[];try{const r=(await ul(e,"file://report.malloy")).parse?.root;r&&or(r)&&typeof r.getChild=="function"&&(n=Dh(new Th(e),r))}catch{n=[]}return Nh(n,t)}const Xo=e=>e.ok===!1;function oi(e,t,n){const r=e.blockStart(n),i=[],s=[];for(let o=r;o<n;o++){if(e.commentLine(o))continue;if(e.proseLine(o)){s.push(o);continue}const a=t[o].trim();a.startsWith("#")&&!a.startsWith("##")&&i.push({line:o,text:a})}return{start:r,tags:i,prose:s}}const as=e=>e.map(t=>t.text);function lc(e){const t=as(e),n=Tp(t);return n===void 0?{}:n==="custom"?{chart:n,chartLines:Ap(t)}:{chart:n}}function Ax(e){if(!e)return;const t=[];for(const n of e.wheres)for(const r of n.clauses){if(!r.binding)continue;const{field:i,op:s,given:o}=r.binding;t.push({field:Rp(i),given:o,...s==="~"?{}:{op:s}})}return t.length>0?t:void 0}function Rx(e,t,n){const r=[];for(const i of e.givens){const s=/^([A-Za-z_][A-Za-z0-9_]*)\s*::\s*(\S+)\s+is\s+([\s\S]+)$/.exec(i.declaration);s&&r.push({name:s[1],type:s[2],default:s[3].trim(),...Px(n(as(oi(e,t,i.line).tags)).tag)})}return r.length>0?r:void 0}function Px(e){if(!e)return{};const t=e.tag("suggest"),n=t?.text("dimension"),r=e.numeric("range_min"),i=e.numeric("range_max");return{...e.text("label")===void 0?{}:{label:e.text("label")},...e.text("description")===void 0?{}:{description:e.text("description")},...e.text("control")===void 0?{}:{control:e.text("control")},...t&&n?{suggest:{...t.text("source")===void 0?{}:{source:t.text("source")},...t.text("query")===void 0?{}:{query:t.text("query")},dimension:n}}:{},...r===void 0?{}:{rangeMin:r},...i===void 0?{}:{rangeMax:i}}}function qs(e,t){const n=e?.text(t)?.trim();if(n===void 0||!/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(n))return;const r=Number(n);return Number.isInteger(r)&&r>=1?r:void 0}const Ix=/^"((?:[^"\\]|\\.)+)"$/,Wx=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/;async function Jo(e,t,n=!1){try{return await Nx(e)}catch(r){return{ok:!1,reason:`A value in this file's tags cannot be read (${r instanceof Error?r.message:String(r)}), so it cannot be opened in the builder.`}}}async function Nx(e){const{parseAnnotation:t}=await Oc(),n=rp(e),r=await Rh(e);if(Oh(r))return{ok:!1,reason:r.reason,...r.line?{line:r.line}:{}};const i=r.parsed,s=Ic(n).text,o=Nh(i.modelNotes,t);if(o.status==="none")return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a report."};if(o.status==="unparsed")return{ok:!1,reason:`The \`## artifact\` tag does not parse${o.errors[0]?`: ${o.errors[0]}`:"."}`};if(o.status==="kind-removed")return{ok:!1,reason:Ox(o.kind)};if(o.status==="cells-removed")return{ok:!1,reason:o.unknownLayout!==void 0?Dx(o.unknownLayout):Tx};const a=o.layout,d=sa(n);if(d===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a report."};if(!ip(d.text))return{ok:!1,reason:sp,line:d.from+1};const{tag:f,errors:c}=Wh(t,[Wc(d.text)]),l=f?.tag("artifact"),u=Ih(d.text);if(u===void 0)return c.length>0?{ok:!1,reason:`The \`## artifact\` tag does not parse: ${c[0]}`}:{ok:!1,reason:"The `## artifact` tag has no `tiles=[…]` list the builder can read."};const p=i.imports.map($=>$.names?{kind:"names",names:$.names,from:$.from}:{kind:"all",from:$.from}),g=[],v=[],x=new Map;for(const $ of i.sources){const M={name:$.name,base:$.base};$.dimensions.length>0&&(M.dimensions=$.dimensions.map(j=>({name:j.name,expression:j.expression})));const T=new Set($.wheres.flatMap(j=>j.clauses.flatMap(O=>O.givens)));T.size>0&&(M.scopedBy=Array.from(T)),g.push(M);for(const j of $.dimensions){const O=t(as(oi(i,n,j.line).tags)).tag?.tag("drill");if(!O)continue;const P=O.textArray("to")??[O.text("to")??""];v.push({source:$.name,name:j.name,expression:j.expression,to:P.filter(Boolean),...O.text("given")?{given:O.text("given")}:{}})}x.set($.name,new Map($.views.map(j=>[j.name,j])))}const k=[];for(const{text:$}of u.entries){const M=Ix.exec($),T=M?void 0:Wx.exec($)?.[1];if(T!==void 0){const D=t([`# ${$}`]).tag?.tag(T);if(D?.text("kind")!=="text")return{ok:!1,reason:`The tile \`${$}\` is neither a quoted \`source -> view\` expression nor a \`${T} { kind=text }\` entry, which are the only forms the builder can lay out.`};if(k.some(F=>De(F)&&F.name===T))return{ok:!1,reason:`Two text tiles are named \`${T}\`, so the builder cannot tell them apart.`};const N=qs(D,"colspan");k.push({kind:"text",name:T,markdown:i.textBlocks.find(F=>F.name===T)?.body??"",...N===void 0?{}:{colspan:N},...D.has("break")?{break:!0}:{}});continue}const j=M?.[1]??$,O=M?op(j):void 0;if(!O)return{ok:!1,reason:`The tile \`${j}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:P,view:R}=O,A=x.get(P)?.get(R);if(A===void 0){k.push({name:R,source:P,declaration:{kind:"inherited"}});continue}const z=t(as(A.tags)).tag,q=A.body.kind==="reference"?{kind:"reference",from:A.body.from}:A.body.kind==="inline"?{kind:"inline"}:void 0;if(q===void 0){k.push({name:R,source:P,declaration:{kind:"opaque",why:A.body.kind==="unsupported"?A.body.why:"unreadable"},...z?.text("label")?{label:z.text("label")}:{},...z?.text("subtitle")?{subtitle:z.text("subtitle")}:{},...z?.numeric("colspan")!==void 0?{colspan:z.numeric("colspan")}:{},...lc(A.tags),...z?.has("break")?{break:!0}:{},...z?.has("borderless")?{borderless:!0}:{}});continue}const U=Ax(A.body.kind==="reference"?A.body.refinement:A.body.kind==="inline"?A.body.stage:void 0);k.push({name:R,source:P,declaration:q,...U?{filters:U}:{},...z?.text("label")?{label:z.text("label")}:{},...z?.text("subtitle")?{subtitle:z.text("subtitle")}:{},...z?.numeric("colspan")!==void 0?{colspan:z.numeric("colspan")}:{},...lc(A.tags),...z?.has("break")?{break:!0}:{},...z?.has("borderless")?{borderless:!0}:{}})}const h=Rx(i,n,t),b={},y=l?.tag("givens");for(const $ of Object.keys(y?.dict??{})){const M=y?.text($);M!==void 0&&(b[$]=M)}const w=f?.tag("dashboard")?.has("columns")?qs(f.tag("dashboard"),"columns"):l?.array("tiles")?qs(l,"dashboard_columns"):void 0;return{ok:!0,document:{layout:a,title:l?.text("title")??"",...s?{description:s}:{},...w===void 0?{}:{columns:w},...l?.has("autorun")?{autorun:l.isTrue("autorun")}:{},imports:p,sources:g,...h?{localGivens:h}:{},...Object.keys(b).length>0?{startingGivens:b}:{},...v.length>0?{drills:v}:{},tiles:k}}}const Zo=e=>e.ok===!1;async function cc(e){const{problems:t}=await ul(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}function we(e){const t=n=>{if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){const r={};for(const i of Object.keys(n).sort())r[i]=t(n[i]);return r}return n};return JSON.stringify(t(e))}function zh(e){return e.replace(/^(?:[ \t]*\r?\n)+/,"").trimEnd()}function zx(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
77
|
+
`&&t.push(n+1);return t}function Lx(e,t){let n=e;const r=t.map((i,s)=>({edit:i,index:s}));for(const{edit:i}of r.sort((s,o)=>o.edit.start-s.edit.start||o.edit.end-s.edit.end||o.index-s.index))n=n.slice(0,i.start)+i.text+n.slice(i.end);return n}const Lh=e=>e==="none"||ca(e)?e:void 0;function Fh(e,t=!0){const n=[];e.colspan!==void 0&&n.push(`# colspan=${e.colspan}`),e.break&&n.push("# break"),e.borderless&&n.push("# borderless"),e.label!==void 0&&n.push(`# label=${bt(e.label)}`),e.subtitle!==void 0&&n.push(`# subtitle=${bt(e.subtitle)}`);const r=t?Lh(e.chart):void 0;return r!==void 0&&n.push(cn(r,e.chartCarried)),n}function Ii(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Fx=new Set(["colspan","break","borderless","label","subtitle"]),Bx=new Set(["label","description","control","suggest","range_min","range_max"]);function dc(e){const t=[];if(e.label!==void 0&&t.push(`label=${bt(e.label)}`),e.description!==void 0&&t.push(`description=${bt(e.description)}`),e.control!==void 0&&t.push(`control=${e.control}`),e.suggest){const n=e.suggest.source!==void 0?`source=${e.suggest.source}`:e.suggest.query!==void 0?`query=${bt(e.suggest.query)}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${bt(e.suggest.dimension)} }`)}return e.rangeMin!==void 0&&t.push(`range_min=${e.rangeMin}`),e.rangeMax!==void 0&&t.push(`range_max=${e.rangeMax}`),t.length>0?`# ${t.join(" ")}`:void 0}const uc=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function _x(e,t,n){const r=e.sources.find(i=>i.name===t)?.views.find(i=>i.name===n);return r?r.line:-1}function hc(e){const t=n=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)?n:bt(n);return`# drill { to=${e.to.length===1?t(e.to[0]):`[${e.to.map(bt).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const ls=e=>`${e.source}.${e.name}`,bt=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Qo=e=>De(e)?we(["text",e.name]):we([e.name,e.source,e.declaration]),ut=Qo,fc=e=>we(e.tiles.map(ut));function Hx(e,t,n){const r=new Set(e.tiles.map(ut)),i=new Set(t.tiles.map(ut)),s=e.tiles.filter(u=>!i.has(ut(u))),o=t.tiles.filter(u=>!r.has(ut(u))),a=s.length>0||o.length>0||fc(e)!==fc(t);for(const u of o)if(ae(u)&&u.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${u.name}\` is ${u.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const d=new Map(e.sources.map(u=>[u.name,u])),f=new Set(t.imports.flatMap(u=>u.kind==="names"?u.names:[]));for(const u of e.sources)f.add(u.base);const c=t.imports.some(u=>u.kind==="all"),l=t.sources.filter(u=>!d.has(u.name));for(const u of e.sources){const p=t.sources.find(g=>g.name===u.name);if(!p||p.base!==u.base)return{ok:!1,reason:`The source \`${u.name}\` cannot be changed or removed here.`}}for(const u of l){if(!o.some(p=>ae(p)&&p.source===u.name))return{ok:!1,reason:`A new source \`${u.name}\` needs a tile on it.`};if(!f.has(u.base)&&!c&&!n?.includes(u.base))return{ok:!1,reason:`\`${u.base}\` is not imported in this file, so a tile cannot be put on it.`}}return{currentKeys:r,nextKeys:i,removedTiles:s,addedTiles:o,newSources:l,currentSources:d,reordered:a}}const pc=(e,t)=>e.colspan!==t.colspan||!!e.break!=!!t.break;function qx(e){let t="";for(let n=0;n<e.length;n++){if(e[n]!=='"'){t+=e[n];continue}const r=Kr(e,n);t+="x".repeat(Math.min(r,e.length-1)-n+1),n=r}return t}function mc(e,t){if(t===void 0)return`${e.name} { kind=text${e.colspan===void 0?"":` colspan=${e.colspan}`}${e.break?" break":""} }`;const n=qx(t),r=n.indexOf("{"),i=n.lastIndexOf("}");let s=t.slice(r+1,i),o=n.slice(r+1,i);const a=f=>{const c=f.exec(o);c&&(s=s.slice(0,c.index)+s.slice(c.index+c[0].length),o=o.slice(0,c.index)+o.slice(c.index+c[0].length))};a(/\s*\bcolspan\s*=\s*[^\s}]+/),a(/\s*\bbreak\b(?!\s*=)/);const d=[s.trim(),e.colspan===void 0?"":`colspan=${e.colspan}`,e.break?"break":""].filter(Boolean);return`${t.slice(0,r)}{ ${d.join(" ")} }${t.slice(i+1)}`}function Ux(e){const{lines:t,wholeLine:n,current:r,next:i,reordered:s,currentKeys:o,nextKeys:a,edits:d}=e,f=new Map(r.tiles.filter(De).map(h=>[h.name,h])),c=i.tiles.filter(De).some(h=>{const b=f.get(h.name);return b!==void 0&&pc(b,h)});if(!s&&!c)return;const l=sa(t);if(!l)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const u=l.text,p=Ih(u);if(!p)return{ok:!1,reason:"Could not read the `tiles=[…]` list to rewrite it."};if(a.size===0&&o.size>0)return{ok:!1,reason:"A grid report with no tiles is not served, so the last tile cannot be removed. Add another tile first."};const g=new Map;for(const{text:h}of p.entries){const b=/^"((?:[^"\\]|\\.)+)"$/.exec(h);if(b){const w=b[1].split("->").map($=>$.trim());w.length===2&&g.set(`${w[0]}->${w[1]}`,h);continue}const y=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/.exec(h)?.[1];y!==void 0&&g.set(`text.${y}`,h)}const v=i.tiles.map(h=>{const b=!o.has(ut(h));if(De(h)){const y=g.get(`text.${h.name}`);return y!==void 0?f.has(h.name)&&!pc(f.get(h.name),h)?y:mc(h,y):b?mc(h):void 0}return g.get(`${h.source}->${h.name}`)??(b?`"${h.source} -> ${h.name}"`:void 0)});if(v.some(h=>h===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const x=u.slice(0,p.open).search(/tiles\s*=\s*$/),k=`${u.slice(0,x)}tiles=[${Vx(u,p,v)}]${u.slice(p.close+1)}`;k!==u&&d.push({...Bh(n,l),text:`${k}
|
|
78
|
+
`})}function Bh(e,t){return{start:e(t.from).start,end:e(t.block?t.to-1:t.from).end}}function Vx(e,t,n){const r=t.entries[0],i=t.entries[t.entries.length-1];if(!r||!/\n/.test(e.slice(t.open,t.close)))return n.join(", ");const s=e.slice(t.open+1,r.span.start),o=e.slice(i.span.end,t.close),a=s.slice(s.lastIndexOf(`
|
|
79
|
+
`)),d=t.entries.length>1?e.slice(r.span.end,t.entries[1].span.start):`,${a.startsWith(`
|
|
80
|
+
`)?a:" "}`;return`${s}${n.join(d)}${o}`}function Gx(e,t){let n=0,r=0;for(let i=0;i<e.length;i++){const s=e[i];if(s==='"')i=Kr(e,i);else if(s==="{"||s==="[")n++===0&&r++;else if(s==="}"||s==="]")n--;else if(r===1&&n===1&&e.startsWith(t,i)&&!/[A-Za-z0-9_]/.test(e[i-1]??" ")){const o=/^\s*=\s*/.exec(e.slice(i+t.length));if(!o)continue;const a=i+t.length+o[0].length,d=e[a]==='"'?Kr(e,a)+1:a+(/^[^\s}]*/.exec(e.slice(a))?.[0].length??0),f=i-(/\s*$/.exec(e.slice(0,i))?.[0].length??0);return e.slice(0,f)+e.slice(d)}}return e}function Kx(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==='"')n=Kr(e,n);else if(r==="{"||r==="[")t++;else if(r==="}"||r==="]")t--;else if(t===0&&e.startsWith("dashboard",n)&&!/[A-Za-z0-9_]/.test(e[n-1]??" ")){const i=/^dashboard\s*\{/.exec(e.slice(n));if(!i)continue;let s=1,o=n+i[0].length;for(;o<e.length&&s>0;o++)e[o]==='"'?o=Kr(e,o):e[o]==="{"?s++:e[o]==="}"&&s--;const a=n-(/\s*$/.exec(e.slice(0,n))?.[0].length??0);return e.slice(0,a)+e.slice(o)}}return e}function Kr(e,t){for(let n=t+1;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==='"')return n;return e.length}function Yx(e){const{lines:t,wholeLine:n,current:r,next:i,edits:s}=e;if(r.layout!==i.layout||r.title!==i.title||r.autorun!==i.autorun||r.columns!==i.columns||we(r.startingGivens)!==we(i.startingGivens)){const o=sa(t);if(!o)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=Bh(n,o),d=s.find(b=>b.start===a.start&&b.end===a.end);let f=d?d.text.replace(/\n$/,""):o.text;const c=r.layout!==i.layout,l=f.indexOf("artifact"),u=f.indexOf("{",l);let p=0,g=-1;for(let b=u;b<f.length;b++)if(f[b]==="{")p++;else if(f[b]==="}"&&--p===0){g=b;break}if(u<0||g<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let v=f.slice(u+1,g);const x=o.block?`
|
|
81
|
+
${/\n([ \t]+)\S/.exec(v)?.[1]??" "}`:" ",k=b=>o.block?`${v.trimEnd()}${x}${b}
|
|
82
|
+
`:`${v.trimEnd()} ${b} `,h=(b,y)=>{const w=new RegExp(`${o.block?"[ \\t]*":"\\s*"}\\b${b}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);if(y===void 0){const $=new RegExp(`
|
|
83
|
+
${w.source}[ \\t]*(?=
|
|
84
|
+
)`);v=v.replace(o.block&&$.test(v)?$:w,"")}else w.test(v)?v=v.replace(w,$=>`${o.block?$.slice(0,$.length-$.trimStart().length):" "}${b}=${y}`):v=k(`${b}=${y}`)};if(c&&h("layout",i.layout),r.title!==i.title&&h("title",i.title?bt(i.title):void 0),r.autorun!==i.autorun&&h("autorun",i.autorun===void 0?void 0:String(i.autorun)),we(r.startingGivens)!==we(i.startingGivens)){v=v.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const b=Object.entries(i.startingGivens??{});b.length>0&&(v=k(`givens { ${b.map(([y,w])=>`${y}=${bt(w)}`).join(" ")} }`))}o.block?f=`${f.slice(0,u+1)}${v}${f.slice(g)}`:(v=v.replace(/\s{2,}/g," "),f=`${f.slice(0,u+1)}${v.startsWith(" ")?v:` ${v}`}${v.endsWith(" ")?"":" "}${f.slice(g)}`),r.columns!==i.columns&&(f=Gx(f,"dashboard_columns"),f=Kx(f),i.columns!==void 0&&(f=`${f.trimEnd()} dashboard { columns=${i.columns} }`)),d?d.text=`${f}
|
|
85
|
+
`:s.push({...a,text:`${f}
|
|
86
|
+
`})}if(r.description!==i.description){const{read:o,blankAbove:a,below:d,belowBlock:f,inBlock:c}=Ic(t);if(c||i.description===void 0&&f)return{ok:!1,reason:"The description is written in a `##|\"` block, which the builder cannot edit in place. Change it in the file's text."};const l=zh(i.description??"").split(`
|
|
87
|
+
`).map(v=>v.trim()===""?'##"':`##" ${v.trim()}`).join(`
|
|
88
|
+
`),u=o.length>0&&o[0]<xl(t),p=i.description===void 0,g=u?[...o.slice(1),...p?d:[]]:[...o,...a];for(const v of g)s.push({...n(v),text:""});if(u)s.push({...n(o[0]),text:i.description===void 0?"":`${l}
|
|
89
|
+
`});else if(i.description!==void 0){const v=n(xl(t)).start;s.push({start:v,end:v,text:`${l}
|
|
90
|
+
`})}}}function Xx(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,d=new Map((i.localGivens??[]).map(p=>[p.name,p])),f=new Map((s.localGivens??[]).map(p=>[p.name,p])),c=new Map(a.givens.map(p=>[p.name,p])),l=new Set;for(const[p,g]of d){const v=f.get(p);if(v!==void 0&&we(v)===we(g))continue;const x=c.get(p);if(x===void 0)return{ok:!1,reason:`Could not find where the given \`${p}\` is declared.`};const{tags:k,prose:h}=oi(a,t,x.line),b=[...(v===void 0?k:k.filter(T=>{const j=Ii(T.text);return j!==void 0&&Bx.has(j)})).map(T=>T.line),...v===void 0?h:[]];for(const T of b)o.push({...n(T),text:""}),l.add(T);const y=Tt(a,x.span.end-1);if(v===void 0){o.push({start:n(x.line).start,end:n(y).end,text:""});for(let A=x.line;A<=y;A++)l.add(A);const T=Math.min(x.line,...b),j=x.blockHeader??T,O=(t[y+1]??"x").trim()==="",P=j===0||t[j-1].trim()==="",R=x.blockHeader===void 0||![...c.values()].some(A=>A.blockHeader===x.blockHeader&&A.line>x.line&&f.has([...c.entries()].find(([,z])=>z===A)?.[0]??""));O&&P&&R&&!l.has(y+1)&&(o.push({...n(y+1),text:""}),l.add(y+1));continue}const w=r(x.line),$=dc(v),M=v.type!==g.type||v.default!==g.default?x.blockHeader===void 0?uc(v):`${v.name} :: ${v.type} is ${v.default}`:t.slice(x.line,y+1).join(`
|
|
91
|
+
`).trim();o.push({start:n(x.line).start,end:n(y).end,text:($?`${w}${$}
|
|
92
|
+
`:"")+`${w}${M}
|
|
93
|
+
`})}for(const[p,g]of c)g.blockHeader===void 0||f.has(p)||![...c.values()].some(v=>v.blockHeader===g.blockHeader&&!l.has(v.line))&&!l.has(g.blockHeader)&&(o.push({...n(g.blockHeader),text:""}),l.add(g.blockHeader));const u=[...f.values()].filter(p=>!d.has(p.name));if(u.length>0){const p=Math.max(-1,...[...c.values()].map(h=>h.line)),g=(()=>{let h=-1;for(let b=0;b<t.length;b++){const y=t[b].trim();(y.startsWith("import ")||h>=0&&/^}\s*from\s/.test(y))&&(h=b)}return h})(),v=p>=0?p:g,x=u.map(h=>{const b=dc(h);return(b?`${b}
|
|
94
|
+
`:"")+`${uc(h)}
|
|
95
|
+
`}).join(`
|
|
96
|
+
`),k=v>=0?n(v).end:n(0).end;o.push({start:k,end:k,text:`
|
|
97
|
+
${x}`}),t.some(h=>h.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
|
|
98
|
+
`})}}const gc=(e,t)=>`import { ${e.join(", ")} } from ${bt(t)}`;function Jx(e){const{parsed:t,current:n,next:r,edits:i,wholeLine:s}=e,o=l=>we(l.imports.flatMap(u=>u.kind==="all"?[u.from]:[]).sort());if(o(n)!==o(r))return{ok:!1,reason:"A whole-file `import` cannot be changed here."};if(we(n.imports)===we(r.imports))return;const a=r.imports.flatMap(l=>l.kind==="names"?[{...l,claimed:!1}]:[]),d=new Set([...r.sources.map(l=>l.base),...r.tiles.filter(ae).map(l=>l.source)]),f=t.imports.map((l,u)=>({statement:l,entry:n.imports[u]}));for(const{statement:l,entry:u}of f){if(!u||u.kind!=="names")continue;const p=a.find(h=>!h.claimed&&h.from===u.from);p&&(p.claimed=!0);const g=p?.names??[],v=u.names.filter(h=>!g.includes(h)).find(h=>d.has(h));if(v!==void 0)return{ok:!1,reason:`\`${v}\` is still read by a tile, so its import cannot be removed.`};if(we(g)===we(u.names))continue;const x=g.length===0?hl(t,l.statement):l.statement,k=t.commentIn(x);if(k)return{ok:!1,reason:`Changing this import would also remove the comment inside it (\`${t.text.slice(k.start,k.end).trim()}\`), so nothing was written. Delete it in the file first.`};i.push({...x,text:g.length===0?"":gc(g,u.from)})}const c=a.filter(l=>!l.claimed);if(c.length>0){const l=t.imports.at(-1);if(!l)return{ok:!1,reason:"This file has no `import` to put a source beside. Import its first source in the file."};const u=s(Tt(t,l.statement.end-1)).end;i.push({start:u,end:u,text:c.map(p=>`${gc(p.names,p.from)}
|
|
99
|
+
`).join("")})}}function Zx(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,d=new Map((i.drills??[]).map(c=>[ls(c),c])),f=new Map((s.drills??[]).map(c=>[ls(c),c]));for(const c of new Set([...d.keys(),...f.keys()])){const l=d.get(c),u=f.get(c);if(l&&u&&we(l)===we(u))continue;const p=u??l;if(u&&u.to.length===0)return{ok:!1,reason:`The drill on \`${c}\` names no destination.`};const g=a.sources.find(h=>h.name===p.source)?.dimensions.find(h=>h.name===p.name);if(g===void 0)return{ok:!1,reason:`\`${p.name}\` is not a dimension \`${p.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:v}=oi(a,t,g.line),x=v.find(h=>/^#\s*drill\b/.test(h.text)),k=r(g.line);if(u===void 0)x&&o.push({...n(x.line),text:""});else if(x)o.push({...n(x.line),text:`${k}${hc(u)}
|
|
100
|
+
`});else{const h=n(g.line).start;o.push({start:h,end:h,text:`${k}${hc(u)}
|
|
101
|
+
`})}}}function Qx(e){const{lines:t,wholeLine:n,removedTiles:r,edits:i,parsed:s}=e;for(const o of r){if(De(o)||o.declaration.kind==="inherited")continue;const a=_h(e,o);if(!a)return{ok:!1,reason:`Could not find where \`${o.name}\` is declared.`};if(a.siblings>1)return{ok:!1,reason:`\`${o.name}\` is one of several views declared by a single \`view:\` statement, which the builder does not restructure.`};const d=Tt(s,a.statement.start),f=Tt(s,a.statement.end-1),c=s.trailingComment(f),l=c&&c.start>=a.statement.end?c.end:a.statement.end;if(s.text.slice(s.lineStarts[d],a.statement.start).trim()!==""||s.text.slice(l,n(f).end).trim()!==""){i.push({...hl(s,a.statement),text:""});continue}i.push({start:s.lineStarts[d],end:n(f).end,text:""});const u=d===0?"":t[d-1].trim();(t[f+1]??"x").trim()===""&&(d===0||u===""||u.endsWith("{"))&&i.push({...n(f+1),text:""})}}function ey(e){const{sourceText:t,lines:n,wholeLine:r,addedTiles:i,newSources:s,currentSources:o,edits:a,parsed:d}=e,f=new Map;for(const u of i){if(De(u))continue;const p=f.get(u.source)??[];p.push(u),f.set(u.source,p)}const c=(u,p)=>{const g=u.declaration.kind==="reference"?u.declaration.from:u.name,v=(u.filters??[]).map(x=>`where: ${la(x.field)} ${x.op??"~"} $${x.given}`).join(", ");return[...Fh(u).map(x=>`${p}${x}`),`${p}view: ${u.name} is ${g}${v?` + { ${v} }`:""}`].join(`
|
|
102
|
+
`)};let l=-1;for(const u of d.sources)l=Math.max(l,Tt(d,u.span.end-1));for(const[u,p]of f)if(o.has(u)){const g=d.sources.find(y=>y.name===u);if(!g)return{ok:!1,reason:`Could not find where the source \`${u}\` is declared.`};if(!g.properties)return{ok:!1,reason:`\`${u}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const v=g.line,x=Tt(d,g.properties.closeStart);let k=" ";for(let y=v+1;y<x;y++){const w=/^(\s+)view:/.exec(n[y]);if(w){k=w[1];break}}const h=r(x).start,b=(n[x-1]??"").trim()==="";a.push({start:h,end:h,text:(b?"":`
|
|
103
|
+
`)+p.map(y=>c(y,k)).join(`
|
|
104
|
+
|
|
105
|
+
`)+`
|
|
106
|
+
`})}else{const g=s.find(b=>b.name===u);if(!g)return{ok:!1,reason:`The tile's source \`${u}\` is not declared.`};const v=`
|
|
107
|
+
source: ${g.name} is ${g.base} extend {
|
|
108
|
+
`+p.map(b=>c(b," ")).join(`
|
|
109
|
+
|
|
110
|
+
`)+`
|
|
111
|
+
}
|
|
112
|
+
`;let x=l;if(x<0)for(let b=0;b<n.length;b++){const y=n[b].trim();(/^(import\s|given:|}\s*from\s)/.test(y)||/^[A-Z_]+\s*::/.test(y))&&(x=b)}const k=x>=0?r(x).end:t.length,h=k===t.length&&!t.endsWith(`
|
|
113
|
+
`)?`
|
|
114
|
+
`:"";a.push({start:k,end:k,text:h+v}),l=x}}function ty(e){const{lines:t,starts:n,wholeLine:r,indentOf:i,current:s,next:o,edits:a,parsed:d}=e,f=new Map(s.tiles.map(c=>[ut(c),c]));for(const c of o.tiles){const l=f.get(ut(c));if(l===void 0||De(c)||De(l)||we(cs(l))===we(cs(c)))continue;if(c.declaration.kind==="inherited")return{ok:!1,reason:`\`${c.source} -> ${c.name}\` is declared on its source, not in this report, so its presentation cannot be changed here.`};const u=_x(d,c.source,c.name);if(u<0)return{ok:!1,reason:`Could not find where \`${c.name}\` is declared inside \`${c.source}\`.`};const{tags:p}=oi(d,t,u),g=i(u),v=Fh(c,!1),x=new Map(v.map(j=>[Ii(j)??j,j])),k=new Set,h=Lh(c.chart),b=vc(l)!==vc(c);if(b){const j=p.filter(R=>yl(R.text)),O=p.filter(R=>Es(R.text)),P=l.chart==="custom"?p.filter(R=>Es(R.text)||yl(R.text)):j.length>0?j:O.length>1?O:[];if(P.length>0)return{ok:!1,reason:`\`${c.source} -> ${c.name}\` has a chart line the builder does not model (${P.map(R=>R.text).join(" and ")}), so its chart cannot be changed here.`}}let y=!1;for(const j of p){if(b&&Es(j.text)){h===void 0?a.push({...r(j.line),text:""}):j.text!==cn(h,c.chartCarried)&&a.push({...r(j.line),text:`${g}${cn(h,c.chartCarried)}
|
|
115
|
+
`}),y=!0;continue}const O=Ii(j.text);if(O===void 0||!Fx.has(O))continue;const P=x.get(O);if(P===void 0){a.push({...r(j.line),text:""});continue}k.add(O),P!==j.text&&a.push({...r(j.line),text:`${g}${P}
|
|
116
|
+
`})}const w=v.filter(j=>!k.has(Ii(j)??j));if(b&&h!==void 0&&!y&&w.push(cn(h,c.chartCarried)),w.length>0){const j=n[u];a.push({start:j,end:j,text:w.map(O=>`${g}${O}
|
|
117
|
+
`).join("")})}if(we(l.filters)===we(c.filters))continue;const $=_h(e,c);if(!$)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if($.body.kind==="reference"){const j=ly(e,c,$);if(j)return j;continue}if($.body.kind!=="inline")return{ok:!1,reason:`\`${c.name}\`'s body is ${$.body.why}, so there is no single first stage to write its filter into.`};const M=Hh(c.filters,$.body.stage);if(M)return qh(c.name,M.given);const T=Uh(e,c,$.body.stage);if(T)return T}}const vc=e=>e.chart==="default"?void 0:e.chart,cs=e=>{const{chartLines:t,chartCarried:n,...r}=e;if(r.chart!=="default")return r;const{chart:i,...s}=r;return s};function ny(e,t){const n=new Map(e.tiles.map(r=>[ut(r),r]));return{...t,tiles:t.tiles.map(r=>{const i=n.get(ut(r));return ae(r)&&r.chart===void 0&&i&&ae(i)&&i.chart!==void 0?{...r,chart:i.chart}:r})}}function Wi(e){if(e.includes("\r"))return"Text uses plain line breaks; a carriage return cannot be written.";if(/^\|##/m.test(e))return"A line starting with `|##` would close the text early. Indent that line or reword it."}function ry(e,t,n){if(n.has(e.name))return`Two text tiles are named \`${e.name}\`, so they could not be told apart.`;if(n.add(e.name),t===void 0&&!Lp(e.name))return`The text tile name ${JSON.stringify(e.name)} must be a bare word.`;if(t===void 0||e.markdown!==t.markdown){const r=Wi(e.markdown);if(r)return r}if(e.colspan!==void 0&&e.colspan!==t?.colspan&&!(Number.isInteger(e.colspan)&&e.colspan>=1))return"A text tile's width is a whole number of columns, 1 or more."}const Us=e=>`##|(markdown) ${e.name}
|
|
118
|
+
${e.markdown===""?"":`${e.markdown}
|
|
119
|
+
`}|##
|
|
120
|
+
`;function iy(e){const{sourceText:t,lines:n,wholeLine:r,current:i,next:s,parsed:o,edits:a}=e,d=new Map(i.tiles.filter(De).map(p=>[p.name,p])),f=s.tiles.filter(De),c=p=>o.textBlocks.find(g=>g.name===p),l=new Set(f.map(p=>p.name));for(const p of d.keys()){const g=l.has(p)?void 0:c(p);if(!g)continue;const v=Tt(o,g.span.end-1);a.push({...g.span,text:""});const x=r(v+1),k=g.line===0||n[g.line-1].trim()==="";x.end>x.start&&n[v+1].trim()===""&&k?a.push({...x,text:""}):g.line>0&&k&&t.slice(g.span.end).trim()===""&&a.push({...r(g.line-1),text:""})}const u=[];for(const p of f){const g=d.get(p.name),v=c(p.name);if(g===void 0){if(v)return{ok:!1,reason:`A block named \`${p.name}\` is already in this file, so a new text tile cannot take that name.`};u.push(Us(p))}else g.markdown!==p.markdown&&(v?a.push({...v.span,text:Us(p)}):u.push(Us(p)))}if(u.length>0){const p=o.textBlocks.filter(h=>h.name===void 0||l.has(h.name)),g=p[p.length-1],v=o.sources.find(h=>h.name.endsWith("_tiles"));if(g){const h=g.span.end,b=t.slice(h);a.push({start:h,end:h,text:`
|
|
121
|
+
${u.join(`
|
|
122
|
+
`)}${b===""||b.startsWith(`
|
|
123
|
+
`)?"":`
|
|
124
|
+
`}`});return}if(v){const h=e.starts[o.blockStart(v.line)],b=h===0||t.slice(0,h).endsWith(`
|
|
125
|
+
|
|
126
|
+
`);a.push({start:h,end:h,text:`${b?"":`
|
|
127
|
+
`}${u.join(`
|
|
128
|
+
`)}
|
|
129
|
+
`});return}const x=t.length,k=t===""||t.endsWith(`
|
|
130
|
+
|
|
131
|
+
`)?"":t.endsWith(`
|
|
132
|
+
`)?`
|
|
133
|
+
`:`
|
|
134
|
+
|
|
135
|
+
`;a.push({start:x,end:x,text:k+u.join(`
|
|
136
|
+
`)})}}const ki=(e,t=eo)=>t(e)?void 0:`The name ${JSON.stringify(e)} cannot be written as a Malloy name.`;function sy(e,t){const n=new Map(e.tiles.map(o=>[ut(o),o]));if(t.layout==="linear"&&t.columns!==void 0&&t.columns!==e.columns)return"A linear report is one column, so its width is not written.";const r=new Set;for(const o of t.tiles){const a=n.get(ut(o));if(De(o)){const l=ry(o,a&&De(a)?a:void 0,r);if(l)return l;continue}const d=a&&ae(a)?a:void 0;if(a&&!d)continue;const f=o.chart;if(f!==void 0&&f!=="default"&&f!=="none"&&!ca(f)&&!(f==="custom"&&d?.chart==="custom"))return`"${String(f)}" is not a chart this editor writes.`;const c=new Set(d?.filters?.map(l=>l.field));for(const l of o.filters??[])if(!c.has(l.field)&&/[\r\n]/.test(l.field))return"A filter field is one line.";if(a===void 0){const l=[o.name,o.source];o.declaration.kind==="reference"&&l.push(o.declaration.from);for(const u of l){const p=ki(u);if(p)return p}}for(const l of["label","subtitle"]){const u=o[l];if(u===void 0||u===d?.[l])continue;const p=xn(`tile ${l}`,u);if(p)return p}}const i=new Set(e.sources.map(o=>o.name));for(const o of t.sources)if(!i.has(o.name))for(const a of[o.name,o.base]){const d=ki(a);if(d)return d}if(t.description!==e.description)for(const o of(t.description??"").split(/\r?\n/)){const a=xn("description line",o);if(a)return a}if(t.title!==e.title){const o=xn("title",t.title);if(o)return o}const s=new Map((e.localGivens??[]).map(o=>[o.name,o]));for(const o of t.localGivens??[]){const a=s.get(o.name);if(a===void 0){const f=ki(o.name,Lc);if(f)return f}const d=o.suggest?.source;if(d!==void 0&&d!==a?.suggest?.source){const f=ki(d);if(f)return`The suggest source is not a name. ${f}`}for(const f of["query","dimension"]){const c=o.suggest?.[f];if(c===void 0||c===a?.suggest?.[f])continue;const l=xn(`suggest ${f}`,c);if(l)return l}for(const f of["label","description"]){const c=o[f];if(c===void 0||c===s.get(o.name)?.[f])continue;const l=xn(`given ${f}`,c);if(l)return l}}for(const[o,a]of Object.entries(t.startingGivens??{})){if(a===e.startingGivens?.[o])continue;const d=xn(`starting value for ${o}`,a);if(d)return d}}const Tt=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function _h(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function Hh(e,t){if(!t)return;const n=new Set;for(const r of t.wheres)for(const i of r.clauses)if(!i.binding)for(const s of i.givens)n.add(s);return(e??[]).find(r=>n.has(r.given))}function qh(e,t){return{ok:!1,reason:`\`${e}\` already filters on \`$${t}\` in a \`where:\` the builder does not manage, so binding it again would filter on it twice. Edit that \`where:\` in the file instead.`}}const Ni=e=>`where: ${la(e.field)} ${e.op??"~"} $${e.given}`;function bc(e,t,n){return{ok:!1,reason:`Removing a filter from \`${e}\` would also remove the comment written beside it (\`${t.text.slice(n.start,n.end).trim()}\`), so nothing was written. Delete it in the file first.`}}function oy(e,t,n){const r=e.commentIn(n);if(r)return r;const i=e.trailingComment(Tt(e,t.end-1));return i&&i.start>=t.end&&e.text.slice(t.end,i.start).trim()===""?i:void 0}function ay(e,t){const n=e[t].span;return t+1<e.length?{start:n.start,end:e[t+1].span.start}:t>0?{start:e[t-1].span.end,end:n.end}:n}function hl(e,t){const n=e.lineStarts[e.lineStarts.findLastIndex(a=>a<=t.start)],r=e.text.slice(n,t.start),i=e.text.indexOf(`
|
|
137
|
+
`,t.end),s=e.text.slice(t.end,i<0?void 0:i);if(r.trim()===""&&s.trim()==="")return{start:n,end:i<0?e.text.length:i+1};if(r.trim()===""){const a=/^\s*/.exec(s)?.[0].length??0;return{start:t.start,end:t.end+a}}const o=r.replace(/[\s,]*$/,"");return{start:n+o.length,end:t.end}}function Uh(e,t,n){const{parsed:r,edits:i}=e,s=new Map((t.filters??[]).map(u=>[u.given,u])),o=new Set;let a;for(const u of n.wheres){const p=u.clauses.map((v,x)=>({clause:v,index:x})).filter(({clause:v})=>v.binding!==void 0);if(p.length===0)continue;const g=p.filter(({clause:v})=>s.has(v.binding.given));for(const{clause:v}of p)o.add(v.binding.given);if(g.length===0&&p.length===u.clauses.length){const v=hl(r,u.span),x=oy(r,u.span,v);if(x)return bc(t.name,r,x);i.push({...v,text:""});continue}g.length>0&&(a=u.span);for(let v=p.length-1;v>=0;v--){const{clause:x,index:k}=p[v],h=s.get(x.binding.given);if(!h){const y=ay(u.clauses,k),w=r.commentIn(y);if(w)return bc(t.name,r,w);i.push({...y,text:""});continue}const b=Ni(h).replace(/^where:\s*/,"");b!==r.text.slice(x.span.start,x.span.end)&&i.push({...x.span,text:b})}}const d=(t.filters??[]).filter(u=>!o.has(u.given));if(d.length===0)return;let f=a?.end??(n.statements.length>0?n.statements[n.statements.length-1].span.end:n.openEnd);if(!n.oneLine){const u=r.trailingComment(Tt(r,f));u&&u.start>=f&&(f=u.end)}const c=a!==void 0&&!/,\s*$/.test(r.text.slice(0,f))?", ":" ",l=n.oneLine?`${c}${d.map(Ni).join(", ")}`:d.map(u=>`
|
|
138
|
+
${n.indent}${Ni(u)}`).join("");i.push({start:f,end:f,text:l})}function ly(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:i,refinement:s}=n.body,o=Hh(t.filters,s);if(o)return qh(t.name,o.given);const a=t.filters??[];if(!s){if(a.length===0)return;const c=` + { ${a.map(Ni).join(", ")} }`;r.push({start:i.end,end:i.end,text:c});return}const d=s.wheres.some(c=>c.clauses.some(l=>!l.binding)),f=s.statements.some(c=>!s.wheres.some(l=>l.span.start===c.span.start));if(a.length===0&&!d&&!f){const c={start:i.end,end:s.span.end},l=e.parsed.commentIn(c);if(l)return{ok:!1,reason:`Removing the last filter from \`${t.name}\` would also remove the comment beside its refinement (\`${e.parsed.text.slice(l.start,l.end).trim()}\`), so nothing was written. Delete it in the file first, or edit the refinement there.`};r.push({...c,text:""});return}return Uh(e,t,s)}async function cy(e,t,n={}){if(!(e.includes(`\r
|
|
139
|
+
`)&&!/(?<!\r)\n/.test(e)))return xc(e,t,n);const r=await xc(e.replace(/\r\n/g,`
|
|
140
|
+
`),t,n);return Zo(r)?r:{...r,source:r.source.replace(/\n/g,`\r
|
|
141
|
+
`)}}async function xc(e,t,n){const r=await Jo(e);if(Xo(r))return{ok:!1,reason:`Cannot edit a file that will not open: ${r.reason}`};const i=r.document,s=ny(i,t),o=Hx(i,s,n.visibleSources);if("reason"in o)return o;const a=sy(i,s);if(a)return{ok:!1,reason:a};const d=await Rh(e);if(Oh(d))return{ok:!1,reason:`Cannot edit a file that will not open: ${d.reason}`};const f=e.split(`
|
|
142
|
+
`),c=zx(e),l=h=>({start:c[h],end:h+1<c.length?c[h+1]:e.length}),u=h=>/^\s*/.exec(f[h])?.[0]??"",p=[],g={...o,sourceText:e,parsed:d.parsed,lines:f,starts:c,wholeLine:l,indentOf:u,current:i,next:s,edits:p};for(const h of[Ux,Yx,Jx,Xx,Zx,Qx,ey,ty,iy]){const b=h(g);if(b)return b}const v=h=>{const{drills:b,localGivens:y,description:w,...$}=h,M=h.tiles.map(T=>{if(De(T))return T;if(T.filters?.length)return cs(T);const{filters:j,...O}=T;return cs(O)});return{...$,...w===void 0?{}:{description:zh(w)},tiles:M,...b?.length?{drills:[...b].sort((T,j)=>ls(T).localeCompare(ls(j)))}:{},...y?.length?{localGivens:y}:{}}};if(p.length===0)return we(v(i))!==we(v(s))?{ok:!1,reason:"No part of this edit was recognized, so nothing was written. Your changes are still here."}:{ok:!0,source:e};const x=Lx(e,p);if((await cc(e)).length===0){const h=await cc(x);if(h.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${h[0]}). Your changes are still here.`}}const k=await Jo(x);return Xo(k)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${k.reason}`}:we(v(k.document))!==we(v(s))?{ok:!1,reason:"What was written did not read back as what was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:x}}function Vh({markdown:e,placeholder:t,onCommit:n,variant:r="document"}){const{theme:i}=He(),s=i.ui,o=S.useId(),[a,d]=S.useState(!1),f=S.useMemo(()=>a?{text:e}:void 0,[a,e]),{draft:c,patch:l,close:u,discard:p}=Vc(f,a,y=>n(y.text),()=>d(!1)),g=a&&c!==void 0&&c.text!==e,v=c!==void 0&&c.text!==e?Wi(c.text):void 0;ph(g,()=>v!==void 0?!1:(u(),!0));const x=S.useRef(!1);S.useEffect(()=>{a||(x.current=!1)},[a]);const k=S.useCallback(y=>{!y||x.current||(x.current=!0,y.setSelectionRange(y.value.length,y.value.length))},[]);if(!a||c===void 0){const y=e.trim()?Wi(e):void 0;return m.jsxs(B,{role:"button",tabIndex:0,onClick:w=>{w.target.closest("a")?w.preventDefault():d(!0)},onKeyDown:w=>{w.target===w.currentTarget&&(w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),d(!0)))},sx:[{minHeight:24},hh(i,"prose")],children:[e.trim()?m.jsx(yp,{variant:r,children:e}):m.jsx(pe,{variant:"body2",sx:{color:i.tileTitle,opacity:.6,fontStyle:"italic"},children:t}),y&&m.jsx(pe,{variant:"caption",color:"error",role:"alert",children:y})]})}const h=c.text!==e?Wi(c.text):void 0,b=()=>{h===void 0&&u()};return m.jsxs(B,{sx:{position:"relative",mx:"-10px",px:"10px",my:"-6px",py:"6px"},children:[m.jsx(zc,{multiline:!0,autoFocus:!0,minRows:2,fullWidth:!0,value:c.text,placeholder:t,error:h!==void 0,inputRef:k,inputProps:{"aria-label":"Markdown","aria-describedby":o,...h!==void 0?{"aria-invalid":!0}:{}},onChange:y=>l(w=>{w.text=y.target.value}),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),p(),d(!1)):y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),b())},onBlur:()=>u(),sx:{p:0,...s.type.prose,color:"inherit",maxWidth:wp,"& textarea":{p:0}}}),h!==void 0&&m.jsx(pe,{variant:"caption",color:"error",role:"alert",children:h}),m.jsxs(pe,{id:o,variant:"caption",sx:{display:"block",textAlign:"right",mt:.5,color:"text.secondary",pointerEvents:"none"},children:["Markdown · ",dn,"↩ done · Esc cancels"]})]})}const dy="Write markdown: # heading, **bold**, - list";function uy({tile:e,onChange:t}){return m.jsx(Tc,{sx:{overflow:"visible"},children:m.jsx(Vh,{markdown:e.markdown,placeholder:dy,onCommit:t})})}const hy={"1/2":"Half","1/3":"A third","2/3":"Two-thirds","1/4":"A quarter","3/4":"Three-quarters"},Gh=(e,t)=>t===0?e:Gh(t,e%t);function fy(e,t){const n=`${e} of ${t}`;if(e>=t)return`${n} · Full width`;const r=Gh(e,t),i=hy[`${e/r}/${t/r}`];return i?`${n} · ${i}`:n}function py({tile:e,index:t,selected:n,flash:r=!1,menuOpen:i,bare:s=!1,onInsertAfter:o,onSelect:a,onOpenMenu:d,onRemove:f,removeBlocked:c,resizing:l=!1,width:u,onResizeStart:p,onResizeMove:g,onResizeEnd:v,children:x}){const{theme:k}=He(),h=k.ui;return m.jsx(dx,{id:Ne(e),index:t,children:({ref:b,handleRef:y})=>m.jsxs(B,{ref:b,onClick:a,onPointerDown:w=>{w.button===0&&a()},role:"group",className:Ze.builderTile,"aria-label":`Tile ${e.name}`,"aria-current":n,onFocus:a,"data-tile-key":Ne(e),"data-flash":r||void 0,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",...Kh(k,{selected:n,flash:r,bare:s}),...!s&&{[`& .${hp}`]:{pr:"36px"}},"&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:k.shadow.drag},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${k.accent}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},...cp,...n&&{[`& .${up}`]:{opacity:1}},"@media (hover: none)":{"& .builder-affordance":{opacity:1}}},children:[x,m.jsx(B,{ref:y,"aria-label":`Move ${lr(e)}`,sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}}),m.jsx(dp,{label:`Remove ${lr(e)}`,onRemove:f,...c?{disabledReason:c}:{},inset:s?Nc:0}),!De(e)&&m.jsx(Bn,{className:"builder-affordance",size:"small","aria-label":`Settings for ${lr(e)}`,onClick:w=>{w.stopPropagation(),d(w.currentTarget)},sx:{position:"absolute",top:s?0:`${yc}px`,right:s?0:`${yc}px`,borderRadius:h.radius.control,width:28,height:28,zIndex:2,color:"text.secondary",bgcolor:"action.hover",opacity:n||i?1:0,transition:`opacity ${Fe}`,...Ut,"&:hover":{opacity:1,bgcolor:"action.selected"}},children:m.jsx(by,{})}),p&&m.jsx(B,{className:`builder-affordance ${Ze.widthHandle}`,[Eh]:"",role:"separator",tabIndex:u?0:-1,"aria-orientation":"vertical","aria-label":`Width of ${lr(e)}`,...u?{"aria-valuenow":u.span,"aria-valuemin":1,"aria-valuemax":u.columns,"aria-valuetext":`${u.span} of ${u.columns} columns`}:{},onKeyDown:w=>{if(!u)return;const $=w.key==="ArrowRight"?u.span+1:w.key==="ArrowLeft"?u.span-1:w.key==="Home"?1:w.key==="End"?u.columns:void 0;$!==void 0&&(w.preventDefault(),w.stopPropagation(),u.onStep(Math.min(Math.max($,1),u.columns)))},onPointerDown:p,onPointerMove:g,onPointerUp:v,onPointerCancel:v,onClick:w=>w.stopPropagation(),sx:w=>({position:"absolute",top:0,bottom:0,right:"-8px",width:"16px",cursor:"col-resize",touchAction:"none",zIndex:2,opacity:l||n?1:0,transition:`opacity ${Fe}`,...Ut,"&:hover":{opacity:1},"&:focus-visible":{opacity:1,outline:`2px solid ${k.accent}`,outlineOffset:1,borderRadius:"3px"},"&::before":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"12px",height:"40px",boxSizing:"border-box",borderRadius:h.radius.control,border:`1px solid ${l?k.accent:Yt(k.cardBorder)}`,bgcolor:w.palette.background.paper,boxShadow:"0 1px 2px rgba(16, 24, 40, 0.10), 0 2px 6px rgba(16, 24, 40, 0.08)",transition:`border-color ${Fe}`},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"5px",height:"16px",borderLeft:`1.5px solid ${l?k.accent:w.palette.text.secondary}`,borderRight:`1.5px solid ${l?k.accent:w.palette.text.secondary}`,boxSizing:"border-box",opacity:l?1:.7},"&:hover::before":{borderColor:k.accent},"&:hover::after":{borderColor:k.accent,opacity:1}}),children:l&&u&&m.jsx(B,{"aria-hidden":!0,sx:w=>({position:"absolute",top:"50%",right:"50%",transform:"translateY(calc(-100% - 28px))",px:1,py:.5,borderRadius:h.radius.control,bgcolor:w.palette.text.primary,color:w.palette.background.paper,...h.type.label,whiteSpace:"nowrap",pointerEvents:"none"}),children:fy(u.span,u.columns)})}),o&&m.jsx(Bn,{className:"builder-affordance",size:"small","aria-label":`Insert tile after ${lr(e)}`,onClick:w=>{w.stopPropagation(),o()},sx:{position:"absolute",bottom:`-${Wn/2+12}px`,left:"50%",transform:"translateX(-50%)",width:24,height:24,zIndex:3,color:k.tileTitle,bgcolor:k.tile,border:k.cardBorder,opacity:0,transition:`opacity ${Fe}`,...Ut,"&:hover, &:focus-visible":{opacity:1,bgcolor:k.tile}},children:m.jsx(Yr,{sx:{fontSize:14}})})]})})}const yc=14,Vs=7,Kh=(e,{selected:t,flash:n=!1,bare:r=!1,ringOffset:i=Nc})=>{const s=e.ui,o=t||n?e.accent:"transparent",a=n?`0 0 0 6px color-mix(in srgb, ${e.accent} 25%, transparent)`:t?`0 0 0 4px color-mix(in srgb, ${e.accent} 14%, transparent)`:void 0,d=`outline-color ${Fe}, border-color ${Fe}, opacity ${Fe}, box-shadow ${Fe}`;return r?{borderRadius:1,"&::before":{content:'""',position:"absolute",inset:typeof i=="number"?`${-i}px`:`${-i.y}px ${-i.x}px`,borderRadius:1,border:`2px solid ${o}`,...a&&{boxShadow:a},pointerEvents:"none",transition:d,...Ut}}:{borderRadius:s.radius.tile,"& > .MuiPaper-root":{transition:d,...Ut,...(t||n)&&{borderColor:e.accent,boxShadow:`0 0 0 1px ${e.accent}${a?`, ${a}`:""}`}},transition:d,...Ut,"&:hover":{boxShadow:e.shadow.lift,...!(t||n)&&{"& > .MuiPaper-root":{borderColor:ds(e.cardBorder,e.tileTitle)}}}}};function my({tile:e,heading:t,note:n,chrome:r="card"}){const{theme:i}=He();return m.jsxs(Js,{chrome:r,children:[m.jsx(Zs,{title:t?.title??Nn(e),subtitle:t?t.subtitle:e.subtitle}),n&&m.jsx(pe,{variant:"body2",sx:{color:i.tileTitle,py:2},children:n}),m.jsxs(pe,{variant:"caption",sx:{display:"block",color:i.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function gy({after:e}){const{theme:t}=He();return m.jsx(ux,{id:gh(e),after:e,children:({ref:n,isDropTarget:r})=>m.jsx(B,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.accent}`,bgcolor:r?`color-mix(in srgb, ${t.accent} 12%, transparent)`:"transparent",opacity:r?.95:.4,transition:`opacity ${Fe}, background-color ${Fe}`,...Ut}})})}function vy({columns:e}){const{theme:t}=He();return m.jsx(B,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${Wn}px`},children:Array.from({length:e},(n,r)=>m.jsx(B,{sx:{bgcolor:t.accent,opacity:.06,borderRadius:"3px"}},r))})}function by(){return m.jsxs(Ip,{sx:{fontSize:18},viewBox:"0 0 24 24",children:[m.jsx("circle",{cx:"3.5",cy:"12",r:"2"}),m.jsx("circle",{cx:"12",cy:"12",r:"2"}),m.jsx("circle",{cx:"20.5",cy:"12",r:"2"})]})}function xy({editor:e,reorder:t,resizing:n,gridBox:r,defaultSpan:i=1,rules:s,canAdd:o,selected:a,flash:d,menuIndex:f,onSelect:c,onOpenMenu:l,onRemove:u,removeBlocked:p,openAdd:g,editTile:v,renderTile:x}){const{dragging:k,preview:h,onDragStart:b,onDragOver:y,onDragEnd:w}=t,{columns:$}=s,{resize:M,startResize:T,onResize:j,endResize:O}=n,P=U=>U.colspan===void 0?{...U,colspan:i}:U,R=(M!==void 0?e.document.tiles.map((U,D)=>D===M.index?{...U,colspan:M.span}:U):h??e.document.tiles).map(P),A=e.document.tiles.length===0,z=k||M!==void 0?Db(R,$):R.map(mh),q=U=>yy(U,Nn(U),v);return m.jsxs(m.Fragment,{children:[m.jsx(ub,{sensors:ax,onDragStart:b,onDragOver:y,onDragEnd:w,children:m.jsxs(B,{ref:r,sx:{position:"relative"},children:[s.widths&&(k||M!==void 0)&&m.jsx(vy,{columns:$}),m.jsx(Df,{tiles:z,columns:$,rowGapPx:Wn,keyOf:U=>U.kind==="gap"?gh(U.after):Ne(U.tile),renderTile:U=>{if(U.kind==="gap")return m.jsx(gy,{after:U.after});const{tile:D,index:N}=U;return m.jsx(py,{tile:D,index:N,selected:N===a,flash:Ne(D)===d,menuOpen:f===N,bare:De(D),...s.insertBetween&&o&&N<e.document.tiles.length-1?{onInsertAfter:()=>g(N+1)}:{},...s.widths&&wy(D)?{resizing:M?.index===N,width:{span:D.colspan??1,columns:$,onStep:F=>{F!==(D.colspan??1)&&e.update(W=>{const _=W.tiles[N];_&&(_.colspan=F)})}},onResizeStart:F=>T(F,N),onResizeMove:j,onResizeEnd:O}:{},onSelect:()=>c(N),onOpenMenu:F=>l(F,N),onRemove:()=>u(N),...p?{removeBlocked:p}:{},children:De(D)?m.jsx(uy,{tile:D,onChange:F=>v(Ne(D),W=>{De(W)&&(W.markdown=F)})}):x?x(D,q(D),"card"):m.jsx(my,{tile:D,heading:q(D)})})}})]})}),s.insertBetween&&o&&!A&&m.jsx(Me,{size:"small",startIcon:m.jsx(Yr,{}),"aria-label":"Add tile at the end",onClick:()=>g(),sx:{alignSelf:"center"},children:"Add tile"})]})}const yy=(e,t,n)=>{if(e.declaration.kind==="inherited")return;const r=Ne(e),i=s=>o=>n(r,a=>{ae(a)&&(o===""?delete a[s]:a[s]=o)});return{title:m.jsx(Vo,{value:e.label??"",placeholder:t,ariaLabel:"Tile title",onCommit:i("label")}),subtitle:m.jsx(Vo,{value:e.subtitle??"",placeholder:"Add a subtitle",ariaLabel:"Tile subtitle",faintWhenEmpty:!0,onCommit:i("subtitle")})}},wy=e=>De(e)||e.declaration.kind!=="inherited",ky={x:12,y:6};function Sy({editor:e,documentSlug:t,actions:n,descriptionSelected:r,selectDescription:i}){const{theme:s}=He();return m.jsx(Wf,{actions:n,title:m.jsx(Vo,{value:e.document.title,placeholder:t??"Untitled report",ariaLabel:"Report title",onCommit:o=>e.update(a=>{a.title=o})}),description:m.jsx(B,{role:"group","aria-label":"Description","aria-current":r,onPointerDown:i,onFocus:i,children:m.jsx(Tc,{sx:{position:"relative",overflow:"visible",...Kh(s,{selected:r,bare:!0,ringOffset:ky})},children:m.jsx(Vh,{markdown:e.document.description??"",placeholder:"Add a description",onCommit:o=>e.update(a=>{o.trim()===""?delete a.description:a.description=o})})})})})}const $y=({size:e,path:t,layout:n,savesTo:r,onEvent:i})=>{const{emit:s}=Cc({path:t,layout:n},i);return{size:e,saved:({size:o,structural:a,durationMs:d})=>s({type:"report.saved",tiles:o,structural:a,where:r,durationMs:d}),refused:o=>s({type:"report.save_refused",reason:o}),undone:({size:o,structural:a,durationMs:d})=>s({type:"report.save_undone",tiles:o,structural:a,where:r,durationMs:d}),undoRefused:o=>s({type:"report.save_undo_refused",reason:o})}};function jy(e,t){const n=S.useRef(t);n.current=t;const r=S.useRef(e);r.current=e;const i=S.useMemo(()=>({save:()=>n.current.save?.(),undo:()=>n.current.undo(),redo:()=>n.current.redo(),addTile:()=>n.current.add.tile?.(),addText:()=>n.current.add.text?.(),addFilter:()=>n.current.add.filter?.(),exit:()=>n.current.exit?.(),done:()=>n.current.done?.(),discard:()=>n.current.discard?.(),restore:()=>n.current.restore?.(),dismissRestored:()=>n.current.dismissRestored?.()}),[]),{status:s,saveTarget:o,canUndo:a,canRedo:d,add:{filterUnavailable:f}}=t,c=t.save!==void 0,l=t.add.tile!==void 0,u=t.add.text!==void 0,p=t.add.filter!==void 0,g=t.exit!==void 0,v=t.done!==void 0,x=t.discard!==void 0,{draftKeptAt:k}=t,h=t.restored?.savedAt,b=t.restored?.stale??!1,y=t.restored?.pending??!1,w=t.restore!==void 0,$=t.dismissRestored!==void 0,M=S.useMemo(()=>({status:s,saveTarget:o,...c?{save:i.save}:{},canUndo:a,undo:i.undo,canRedo:d,redo:i.redo,add:{...l?{tile:i.addTile}:{},...u?{text:i.addText}:{},...p?{filter:i.addFilter}:{},...f!==void 0?{filterUnavailable:f}:{}},...g?{exit:i.exit}:{},...v?{done:i.done}:{},...k!==void 0?{draftKeptAt:k}:{},...x?{discard:i.discard}:{},...h!==void 0?{restored:{savedAt:h,stale:b,pending:y}}:{},...w?{restore:i.restore}:{},...$?{dismissRestored:i.dismissRestored}:{}}),[i,s,o,c,a,d,l,u,p,f,g,v,k,x,h,b,y,w,$]);S.useEffect(()=>{r.current?.(M)},[M,e!==void 0]),S.useEffect(()=>()=>r.current?.(void 0),[])}function My({controls:e,unknownFieldsOf:t,onEdit:n,onAdd:r,addDisabledReason:i,onRemove:s,fixedFilters:o,onOpenModel:a,startingValues:d,onStartingValue:f,children:c}){const l=c!=null,u=S.useMemo(()=>{const p=new Map(e.map(g=>[g.name,g]));return{stateOf:g=>{const v=o?.get(g);if(v!==void 0){const{modelPath:h}=v;return{origin:"model",fixed:v.reason,...h!==void 0&&a?{openModel:()=>a(h)}:{}}}const x=p.get(g);if(!x)return;const k=t(x.name,x.type);return{origin:x.origin,...k.length>0?{problem:`Cannot filter on ${k.join(", ")}: a tile it applies to has no such field.`}:{}}},unrendered:l?e.filter(g=>g.boundTiles===0&&!o?.has(g.name)).map(g=>({name:g.name,label:g.label??g.name})):[],onEdit:g=>{const v=p.get(g);v&&n(v)},onRemove:s,onAdd:r,...i!==void 0?{addDisabledReason:i}:{},...f?{startingValueOf:g=>d?.[g],setStartingValue:f}:{}}},[e,t,l,n,s,r,i,o,a,d,f]);return m.jsx(Af,{children:m.jsx(Rf.Provider,{value:u,children:l?c:m.jsxs(tt,{direction:"row",role:"group","aria-label":"Filters",useFlexGap:!0,sx:{flexWrap:"wrap",alignItems:"center",gap:1},children:[e.map(p=>m.jsx(Pf,{name:p.name,label:p.label??p.name,unused:p.boundTiles===0},p.name)),m.jsx(If,{})]})})})}function Cy(e,t){const n=new Map(e.tiles.map((r,i)=>[Ne(r),{tile:r,index:i}]));for(const[r,i]of t.tiles.entries()){const s=n.get(Ne(i));if(!s||s.index!==r||JSON.stringify(s.tile)!==JSON.stringify(i))return Ne(i)}}function Ey({editor:e,gridBox:t}){const[n,r]=S.useState(void 0),i=typeof n=="object"?n.tile:void 0,s=n==="description",o=S.useCallback(x=>r(k=>typeof k=="object"&&k.tile===x?k:{tile:x}),[]),a=S.useCallback(()=>r(x=>x==="description"?x:void 0),[]),d=S.useCallback(()=>r("description"),[]),f=S.useCallback(()=>r(void 0),[]),c=n!==void 0;S.useEffect(()=>{if(!c)return;const x=k=>{const h=k.target;h instanceof Element&&h!==document.documentElement&&h.closest(Oy)===null&&f()};return document.addEventListener("pointerdown",x,!0),()=>document.removeEventListener("pointerdown",x,!0)},[c,f]);const[l,u]=S.useState(void 0),p=S.useRef(!1),g=S.useRef(e.document);S.useEffect(()=>{const x=g.current;if(g.current=e.document,!p.current)return;p.current=!1;const k=Cy(x,e.document);k!==void 0&&(u(k),Array.from(t.current?.querySelectorAll("[data-tile-key]")??[]).find(h=>h.dataset.tileKey===k)?.scrollIntoView?.({block:"nearest",behavior:Of()}))},[e.document,t]),S.useEffect(()=>{if(l===void 0)return;const x=setTimeout(()=>u(void 0),1500);return()=>clearTimeout(x)},[l]);const v=S.useMemo(()=>({...e,undo:()=>{p.current=!0,e.undo()},redo:()=>{p.current=!0,e.redo()}}),[e]);return{selected:i,descriptionSelected:s,selectTile:o,deselectTile:a,selectDescription:d,clearSelection:f,flash:l,stepEditor:v}}const Oy=["[data-tile-key]",'[role="group"][aria-label="Description"]','[role="toolbar"][aria-label="Report builder"]','[aria-label="Builder actions"]',".MuiPopover-root",".MuiPopper-root",".MuiDialog-root",".MuiModal-root",'[role="menu"]','[role="dialog"]','[role="listbox"]','[role="tooltip"]'].join(", ");function Dy({dirty:e,saving:t,canSave:n,save:r,onExit:i}){const[s,o]=S.useState("idle"),[a,d]=S.useState(!1),f=S.useRef(r);f.current=r;const c=S.useRef(i);c.current=i;const l=S.useRef(0),u=S.useCallback(async()=>{const v=++l.current;d(!1),o("saving");try{await f.current()}catch{l.current===v&&o("idle");return}l.current===v&&d(!0)},[]);S.useEffect(()=>{if(s==="waiting"){if(t)return;e?u():(o("idle"),c.current())}else if(s==="saving"){if(!a||t)return;o("idle"),e||c.current()}},[s,a,t,e,u]);const p=S.useCallback(()=>{s==="idle"&&(e?o("asking"):c.current())},[s,e]),g=S.useCallback(()=>{s==="idle"&&(e?n?t?o("waiting"):u():o("asking"):c.current())},[s,e,n,t,u]);return{requestExit:p,saveAndExit:g,finishing:s==="saving"||s==="waiting",dialog:{open:s==="asking",canSave:n,onKeepEditing:()=>{s==="asking"&&o("idle")},onDiscard:()=>{s==="asking"&&(o("idle"),c.current())},onSaveAndExit:()=>{s==="asking"&&(t?o("waiting"):u())}}}}function Ty({editor:e,onSave:t,onDirtyChange:n,onExit:r,onChange:i,extraDirty:s=!1,keepsEdits:o=!1,report:a,unit:d,prepare:f,shortcuts:c}){const[l,u]=S.useState(!1),[p,g]=S.useState(!1),v=S.useRef(null),x=S.useRef(a);x.current=a;const k=e.dirty||s,h=(e.edited??e.dirty)||s,b=o?s:h;S.useEffect(()=>{i?.(e.document)},[e.document,i]),S.useLayoutEffect(()=>{n?.(h,b)},[h,b,n]);const y=S.useRef(n);y.current=n,S.useEffect(()=>()=>y.current?.(!1,!1),[]);const w=S.useRef(d);w.current=d,S.useEffect(()=>{g(!1)},[e.document]);const $=S.useCallback(()=>{u(!0),g(!1);const D=Lt(),{structural:N}=e,F=x.current.size;return e.save().then(W=>{W.ok===!0?x.current.saved({size:F,structural:N,durationMs:Lt()-D}):x.current.refused(W.reason)}).finally(()=>u(!1))},[e]),M=S.useRef(!1),T=S.useRef(!1);S.useEffect(()=>{!T.current||l||(T.current=!1,v.current?.focus())},[p,l]);const j=S.useCallback(()=>{if(!t||l||M.current||!e.canUndoSave)return;M.current=!0,u(!0);const D=Lt(),N=e.lastSave?.structural??!1,F=x.current.size;return e.undoSave().then(W=>{W.ok===!0?(T.current=!0,g(!0),x.current.undone({size:F,structural:N,durationMs:Lt()-D})):x.current.undoRefused(W.reason)}).finally(()=>{M.current=!1,u(!1)})},[t,l,e]),O=S.useCallback(()=>{if(!(!t||!e.dirty||l))return $()},[t,e,l,$]),P=S.useRef(O);P.current=O;const R=S.useCallback(()=>{const D=()=>P.current();return f?f(D):D()},[f]),A=Dy({dirty:h,saving:l,canSave:!!t,save:R,onExit:()=>r?.()});Kp(S.useMemo(()=>({...c,undo:e.undo,redo:e.redo,...t?{save:R}:{},paused:A.dialog.open}),[c,e,t,R,A.dialog.open]));const z=!!t&&!l&&e.canUndoSave,q=e.lastSave,U={canUndo:e.canUndo,canRedo:e.canRedo,onUndo:e.undo,onRedo:e.redo,dirty:k,saving:l,saveButton:v,...t?{onSave:R}:{},...r?{onExit:A.requestExit}:{}};return{saving:l,save:R,exitGuard:A,...r?{done:A.saveAndExit}:{},undoSave:j,canUndoSave:z,lastSave:q,toolbarProps:U}}const Ay=1;function Yh(e,t,n){const r=[];for(const i of e??[]){const s=i.name,o=i.kind;if(typeof s=="string"){if(o==="dimension"||o==="measure"){const a=i.type?.kind;r.push({name:t+s,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=i.schema?.fields;r.push(...Yh(a,`${t}${s}.`,n-1))}}}return r}function Ry(e){const t=new Map;for(const n of Xh(e))t.set(n.name,Yh(n.schema?.fields,"",Ay));return t}function Xh(e){const t=[];for(const n of e.sourceInfos??[])try{const r=typeof n=="string"?JSON.parse(n):n;r?.name&&t.push(r)}catch{continue}return t}const Py=e=>(e.annotations??[]).some(t=>{const n=t.value??"";return n.startsWith("#(malloy)")&&Ep.parseTag(n.slice(9)).tag?.has("calculation")===!0});function Iy(e){const t=new Map;for(const n of Xh(e)){const r=new Set;for(const i of n.schema?.fields??[]){if(i.kind!=="view"||typeof i.name!="string")continue;const s=i.schema?.fields;s&&s.length>0&&s.every(Py)&&r.add(i.name)}t.set(n.name,r)}return t}function wc(e,t){return!e||t===void 0?void 0:e.sources.find(n=>n.name===t)?.fields.filter(n=>n.kind==="dimension")}const kc=(e,t)=>e!==void 0&&t.has(e),Sc=e=>e.path||e.modelPath||"";function Wy(e,t=new Set){const n=[],r=new Set,i=new Map,s=new Map,o=new Map;for(const a of e){const d=Sc(a);if(kc(d,t))continue;const f=Ef(a.modelInfo);s.set(a,f);for(const{name:c}of a.sources??[])c&&o.set(c,[...o.get(c)??[],d]);for(const c of f)i.set(c,[...i.get(c)??[],d])}for(const a of e){const d=Sc(a);if(kc(d,t))continue;const f=Ry(a),c=Iy(a);for(const l of a.sources??[]){const u=l.name;if(!u||!s.get(a)?.has(u)||r.has(u))continue;r.add(u);const p=(l.givens??[]).map(g=>g.name).filter(g=>typeof g=="string");n.push({name:u,modelPath:d,exporters:i.get(u)??[d],visibleIn:o.get(u)??[d],...di(l.annotations)?{description:di(l.annotations)}:{},views:(l.views??[]).filter(g=>typeof g.name=="string").map(g=>({name:g.name,...di(g.annotations)?{description:di(g.annotations)}:{},...vl(g.annotations)?{chart:vl(g.annotations)}:{},...c.get(u)?.has(g.name)?{aggregateOnly:!0}:{}})),givens:p,fields:f.get(u)??[]})}}return{sources:n}}function Ny({editor:e,opened:t,givens:n,catalog:r}){const[i,s]=S.useState(void 0),o=S.useMemo(()=>{const u=new Set((t.localGivens??[]).map(p=>p.name));return(n??[]).filter(p=>!u.has(p.name))},[t,n]),a=S.useMemo(()=>cm(e.document,o),[e.document,o]),d=S.useMemo(()=>new Map(e.document.sources.map(u=>[u.name,wc(r,u.base)])),[r,e.document.sources]),f=S.useCallback(u=>d.get(u.source)??wc(r,u.source),[d,r]),c=(u,p)=>{const g=[];for(const v of e.document.tiles){if(!ae(v))continue;const x=f(v);if(!x)continue;const k=new Map(x.map(h=>[h.name,h.type]));for(const h of v.filters??[])h.given===u&&(!k.has(h.field)||!Or(p,k.get(h.field)))&&g.push(`${h.field} on ${v.label??v.name} (${e.document.sources.find(b=>b.name===v.source)?.base??v.source})`)}return g},l=S.useMemo(()=>a.filter(u=>u.origin==="model"&&u.boundTiles===0),[a]);return{filterDialog:i,setFilterDialog:s,controlList:a,fieldsFor:f,unknownFieldsOf:c,available:l,applyFilter:(u,p,g)=>{s(void 0),e.update(v=>{g&&vm(v,g),gm(v,u,p)})},dropControl:u=>{s(void 0),e.update(p=>bm(p,u))}}}function zy(e){const{splice:t,onSave:n,structural:r,clearsHistory:i}=e,[s,o]=S.useState({stack:[e.document],index:0}),[a,d]=S.useState(e.source),[f,c]=S.useState(void 0),[l,u]=S.useState(e.document),[p,g]=S.useState(e.replaces),[v,x]=S.useState(!1),k=s.stack[s.index],h=S.useRef(s);h.current=s;const b=S.useRef(!1),[y,w]=S.useState(!1),$=W=>{b.current=W,w(W)},[M,T]=S.useState(void 0),j=S.useCallback(W=>{c(void 0),o(_=>{const Y=structuredClone(_.stack[_.index]);if(W(Y),JSON.stringify(Y)===JSON.stringify(_.stack[_.index]))return _;const G=[..._.stack.slice(0,_.index+1),Y].slice(-100);return{stack:G,index:G.length-1}})},[]),O=S.useCallback(()=>{c(void 0),o(W=>W.index>0?{...W,index:W.index-1}:W)},[]),P=S.useCallback(()=>{c(void 0),o(W=>W.index<W.stack.length-1?{...W,index:W.index+1}:W)},[]),R=S.useCallback(async(W,_)=>{try{return await t(W,_)}catch(Y){return{ok:!1,reason:`Could not build the file: ${Y instanceof Error?Y.message:String(Y)}`}}},[t]),A=S.useCallback(async()=>{if(b.current)return{ok:!1,reason:"A save is still being written."};const W={source:a,saved:l,history:h.current,replacing:p,unwritten:v},_=i?.(l,k)??!1,Y=r?.(l,k)??!1;$(!0);try{const G=await R(a,k);if(Zo(G))return c(G.reason),{ok:!1,reason:G.reason};try{await n?.(G.source,{purpose:"save",document:k})}catch(V){const H=`Could not save: ${V instanceof Error?V.message:String(V)}`;return c(H),{ok:!1,reason:H}}d(G.source),u(k),g(void 0),x(!1);const le=_?{stack:[k],index:0}:W.history;return o(V=>V===W.history?le:_?{stack:[V.stack[V.index]],index:0}:V),T(n?{before:W,after:le,lastSave:{before:p??a,after:G.source,structural:Y,clearsHistory:_}}:void 0),c(void 0),{ok:!0}}finally{$(!1)}},[k,R,n,a,l,p,v,i,r]),z=S.useCallback(async()=>{if(b.current)return{ok:!1,reason:"A save is still being written."};if(!n||M===void 0||M.after!==h.current)return{ok:!1,reason:"There is no save to undo."};const{before:W}=M;$(!0);try{await n(W.replacing??W.source,{purpose:"undo",document:W.saved})}catch(_){const Y=`Could not undo the save: ${_ instanceof Error?_.message:String(_)}`;return c(Y),{ok:!1,reason:Y}}finally{$(!1)}return d(W.source),u(W.saved),g(W.replacing),x(W.unwritten||W.replacing!==void 0),o(_=>_===M.after?W.history:_),T(void 0),c(void 0),{ok:!0}},[n,M]),q=S.useMemo(()=>v||JSON.stringify(k)!==JSON.stringify(l),[k,l,v]),U=S.useMemo(()=>r?.(l,k)??!1,[k,l,r]),D=S.useMemo(()=>i?.(l,k)??!1,[k,l,i]),N=M!==void 0&&M.after===s,F=S.useCallback(async()=>{const W=await R(a,k);return Zo(W)?{ok:!1,reason:W.reason}:{ok:!0,source:W.source}},[k,R,a]);return{document:k,saved:l,source:a,canUndo:s.index>0,canRedo:s.index<s.stack.length-1,dirty:q,edited:q,...f===void 0?{}:{error:f},update:j,undo:O,redo:P,save:A,preview:F,structural:U,clearsHistory:D,canUndoSave:N&&!y&&n!==void 0,...N?{lastSave:M.lastSave}:{},undoSave:z}}const Ly=(e,t)=>{const n=new Set(e.tiles.map(Qo)),r=new Set(t.tiles.map(Qo));return[...n].some(i=>!r.has(i))||[...r].some(i=>!n.has(i))};function Fy(e){const{visibleSources:t,...n}=e,r=S.useCallback((i,s)=>cy(i,s,t?{visibleSources:t}:{}),[t]);return zy({...n,splice:r,structural:Ly})}function By({editorDirty:e}){const[t,n]=S.useState(!1),r=S.useRef(void 0),i=S.useRef(void 0),s=S.useMemo(()=>({setDirty:n,commitRef:r}),[]),o=S.useCallback(a=>{if(!r.current)return a();if(r.current())return new Promise(d=>{i.current=()=>d(a())})},[]);return S.useEffect(()=>{if(t||!i.current)return;const a=i.current;i.current=void 0,a()},[t,e]),{draftDirty:t,openDraft:s,prepare:o}}function _y({editor:e,rules:t,modelPath:n,textHeld:r,selectTile:i,deselectTile:s}){const[o,a]=S.useState(void 0),[d,f]=S.useState(!1),[c,l]=S.useState(void 0),u=h=>{l(h),f(!0)},p=()=>f(!1),g=h=>{f(!1),e.update(b=>Qp(b,h,{modelPath:n,textHeld:r,widths:t.widths,insertAt:c})),i(c??e.document.tiles.length)},v=()=>k(c),x=()=>k(void 0),k=h=>{f(!1),e.update(b=>{const y=new Set(b.tiles.filter(De).map($=>$.name));let w=1;for(;y.has(`text_${w}`);)w++;b.tiles.splice(h??b.tiles.length,0,{kind:"text",name:`text_${w}`,markdown:"",...t.widths?{colspan:t.columns}:{}})}),i(h??e.document.tiles.length)};return{menu:o,setMenu:a,addingTile:d,openAdd:u,closeAdd:p,addTile:g,addText:v,appendText:x,editTile:(h,b)=>e.update(y=>{const w=y.tiles.find($=>Ne($)===h);w&&b(w)}),removeTile:h=>{a(void 0),s(),e.update(b=>{b.tiles.splice(h,1)})},duplicate:h=>{a(void 0);const b=e.document.tiles[h],y=b&&ae(b)&&Hi(b)===void 0?h+1:void 0;e.update(w=>{em(w,h)}),y!==void 0&&i(y)}}}var Hy=Object.defineProperty,qy=Object.defineProperties,Uy=Object.getOwnPropertyDescriptors,$c=Object.getOwnPropertySymbols,Vy=Object.prototype.hasOwnProperty,Gy=Object.prototype.propertyIsEnumerable,jc=(e,t,n)=>t in e?Hy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$n=(e,t)=>{for(var n in t||(t={}))Vy.call(t,n)&&jc(e,n,t[n]);if($c)for(var n of $c(t))Gy.call(t,n)&&jc(e,n,t[n]);return e},jn=(e,t)=>qy(e,Uy(t));function Ky(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Si(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function Gs(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Yy(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const d=(h,b)=>h===b||h!==null&&typeof h=="object"&&"id"in h&&h.id===b;if(Array.isArray(e)){const h=e.findIndex(y=>d(y,s.id)),b=e.findIndex(y=>d(y,o.id));if(h===-1||b===-1){if(Gs(s)){const y=s.initialIndex,w=s.index;return y===w||y<0||y>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,y,w)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const y=s.index;if(y!==h)return n(e,h,y)}return n(e,h,b)}const f=Object.entries(e);let c=-1,l,u=-1,p;for(const[h,b]of f)if(c===-1&&(c=b.findIndex(y=>d(y,s.id)),c!==-1&&(l=h)),u===-1&&(u=b.findIndex(y=>d(y,o.id)),u!==-1&&(p=h)),c!==-1&&u!==-1)break;if(c===-1&&Gs(s)){const h=s.initialGroup==null?void 0:Si(e,s.initialGroup),b=s.initialIndex,y=s.group==null?void 0:Si(e,s.group),w=s.index;if(h==null||y==null||h===y&&b===w)return"preventDefault"in t&&t.preventDefault(),e;if(h===y)return jn($n({},e),{[h]:n(e[h],b,w)});const $=e[h][b];return jn($n({},e),{[h]:[...e[h].slice(0,b),...e[h].slice(b+1)],[y]:[...e[y].slice(0,w),$,...e[y].slice(w)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,v=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(p==null){const h=Si(e,o.id);if(h!=null){const b=o.shape&&v.y>o.shape.center.y?e[h].length:0;p=h,u=b}}if(l==null||p==null||l===p&&c===u){if(l!=null&&l===p&&c===u&&Gs(s)){const h=s.group==null?void 0:Si(e,s.group),b=s.group!=null&&h!==l,y=s.index!==c;if(b||y){const w=s.group==null?l:h;if(w!=null){if(l===w)return jn($n({},e),{[l]:n(e[l],c,s.index)});const $=e[l][c];return jn($n({},e),{[l]:[...e[l].slice(0,c),...e[l].slice(c+1)],[w]:[...e[w].slice(0,s.index),$,...e[w].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(l===p)return jn($n({},e),{[l]:n(e[l],c,u)});const x=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,k=e[l][c];return jn($n({},e),{[l]:[...e[l].slice(0,c),...e[l].slice(c+1)],[p]:[...e[p].slice(0,u+x),k,...e[p].slice(u+x)]})}function Xy(e,t){return Yy(e,t,Ky)}function Jy({tiles:e,commit:t,onLanded:n}){const[r,i]=S.useState(void 0),s=S.useRef(void 0),[o,a]=S.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),s.current=e},onDragOver:d=>{const{source:f,target:c}=d.operation;if(!f||!c)return;const l=s.current??e;let u;if(c.type===Ch){const{after:p}=c.data,g=l.findIndex(x=>Ne(x)===f.id);if(g<0||p===f.id)return;const v=l.filter((x,k)=>k!==g).findIndex(x=>Ne(x)===p)+1;u=Ob(l,g,v)}else{const p=l.map(Ne),g=Xy(p,d);if(g.every((x,k)=>x===p[k]))return;const v=new Map(l.map(x=>[Ne(x),x]));u=Eb(g.map(x=>v.get(x)),e.map(x=>x.break??!1))}s.current=u,i(u)},onDragEnd:d=>{a(!1);const f=s.current;if(s.current=void 0,i(void 0),d.canceled||!f)return;t(f);const c=f.findIndex(l=>Ne(l)===d.operation.source?.id);c>=0&&n(c)}}}const Ks=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Zy({tiles:e,columns:t,gridBox:n,onStart:r,commit:i}){const[s,o]=S.useState(void 0),a=S.useRef(void 0),d=f=>{a.current=f,o(f)};return S.useEffect(()=>()=>Ks(!1),[]),{resize:s,startResize:(f,c)=>{const l=n.current?.getBoundingClientRect(),u=f.currentTarget.parentElement?.getBoundingClientRect();if(!l||!u)return;f.stopPropagation(),f.preventDefault(),f.currentTarget.setPointerCapture(f.pointerId),Ks(!0),r(c);const p=e[c]?.colspan??1;d({index:c,span:p,from:p,left:u.left,track:(l.width-Wn*(t-1))/t})},onResize:f=>{const c=a.current;if(!c)return;const l=f.clientX-c.left,u=Math.round((l+Wn)/(c.track+Wn)),p=Math.min(Math.max(u,1),t);p!==c.span&&d({...c,span:p})},endResize:f=>{f.currentTarget.hasPointerCapture(f.pointerId)&&f.currentTarget.releasePointerCapture(f.pointerId),Ks(!1);const c=a.current;if(!c)return;const{index:l,span:u,from:p}=c;d(void 0),!(f.type==="pointercancel"||u===p)&&i(l,u)}}}function Jh({source:e,document:t,onSave:n,onChange:r,onDirtyChange:i,onExit:s,renderTile:o,renderViewPreview:a,controls:d,givens:f,catalog:c,toolbar:l,dashboards:u,onEvent:p,savesTo:g="package",saveLabel:v,replaces:x,modelPath:k,visibleSources:h,addFilterDisabledReason:b,fixedFilters:y,onOpenModel:w,takenGivenNames:$,onControlsChange:M,draftKey:T}){const j=Fy({source:e,document:t,...n?{onSave:n}:{},...x!==void 0?{replaces:x}:{},...h?{visibleSources:h}:{}}),O=pf(T,j,e),P=S.useRef(null),{selected:R,descriptionSelected:A,selectTile:z,deselectTile:q,selectDescription:U,clearSelection:D,flash:N,stepEditor:F}=Ey({editor:j,gridBox:P}),W=mf(j.document.layout,j.document.columns),{columns:_}=W,Y=k?.split("/").at(-1)?.replace(/\.malloy$/,""),G=Jy({tiles:j.document.tiles,commit:K=>j.update(oe=>{oe.tiles=K}),onLanded:z}),{dragging:le}=G,V=gf(P,_),H=S.useMemo(()=>j.document.tiles.map(K=>K.colspan===void 0?{...K,colspan:V}:K),[j.document.tiles,V]),Z=Zy({tiles:H,columns:_,gridBox:P,onStart:z,commit:(K,oe)=>j.update(ne=>{const Ae=ne.tiles[K];Ae&&(Ae.colspan=oe)})}),ee=_y({editor:j,rules:W,modelPath:k,textHeld:h!==void 0,selectTile:z,deselectTile:q}),{menu:Q,addingTile:ce,openAdd:xe}=ee,me=Ny({editor:j,opened:t,givens:f,catalog:c}),{filterDialog:te,setFilterDialog:fe}=me,[de,ge]=S.useState(void 0),{draftDirty:Pe,openDraft:Ve,prepare:Ge}=By({editorDirty:j.dirty}),Ke=S.useMemo(()=>({escape:()=>{!Q&&!te&&!ce&&de===void 0&&D()},nudge:K=>{if(le||R===void 0||!W.widths)return;const oe=j.document.tiles[R];if(!oe||ae(oe)&&oe.declaration.kind==="inherited")return;const ne=vf(oe.colspan??V,K,_);ne!==(oe.colspan??V)&&j.update(Ae=>{Ae.tiles[R].colspan=ne})}}),[V,j,Q,te,ce,de,D,R,_,W,le]),Ie=Ty({editor:F,extraDirty:Pe,keepsEdits:T!==void 0&&O.keeping,prepare:Ge,unit:{name:"tile",count:K=>K.tiles.length},onSave:n,onDirtyChange:i,onExit:s,onChange:r,shortcuts:Ke,report:$y({size:j.document.tiles.length,path:k??"",layout:j.document.layout,savesTo:g,onEvent:p})}),E=j.document.tiles.length===0,{toolbarProps:I}=Ie,C=O.restored,L={status:Ie.saving?"saving":I.dirty?"unsaved":"saved",saveTarget:v??so[g],...O.keptAt!==void 0?{draftKeptAt:O.keptAt}:{},...(I.dirty||C?.pending)&&T!==void 0?{discard:O.discard}:{},...C?{restored:C}:{},...C&&!C.pending?{dismissRestored:O.dismissRestored}:{}};jy(M,{...L,...I.onSave?{save:I.onSave}:{},canUndo:I.canUndo,undo:I.onUndo,canRedo:I.canRedo,redo:I.onRedo,add:{...c?{tile:()=>ee.openAdd()}:{},text:ee.appendText,...b!==void 0?{filterUnavailable:b}:E?{filterUnavailable:"Add a tile before a filter."}:{filter:()=>fe({})}},...I.onExit?{exit:I.onExit}:{},...Ie.done?{done:Ie.done}:{},...C?.pending?{restore:O.restoreOffered}:{}});const ue=M?void 0:m.jsx(Yp,{...Ie.toolbarProps,...l?{actions:l}:{},...c?{onAddTile:()=>xe()}:{},savesTo:g,...v?{saveLabel:v}:{},...T!==void 0&&I.onSave?{saveStatus:L}:{}});return m.jsx(fh.Provider,{value:Ve,children:m.jsx(tt,{className:Ze.builder,"data-saves-to":g,sx:{gap:0,mx:`-${Vs}px`},children:m.jsxs(bf,{layout:W.layout,sx:{px:`${Vs}px`,pb:`${Vs}px`},header:m.jsx(Sy,{editor:j,documentSlug:Y,actions:ue,descriptionSelected:A,selectDescription:U}),controls:E?void 0:m.jsx(My,{controls:me.controlList,unknownFieldsOf:me.unknownFieldsOf,onEdit:K=>fe({control:K}),onAdd:()=>fe({}),...b?{addDisabledReason:b}:{},onRemove:me.dropControl,...y?{fixedFilters:y}:{},...w?{onOpenModel:w}:{},...j.document.startingGivens?{startingValues:j.document.startingGivens}:{},onStartingValue:(K,oe)=>j.update(ne=>{const Ae={...ne.startingGivens??{}};oe===void 0?delete Ae[K]:Ae[K]=oe,Object.keys(Ae).length>0?ne.startingGivens=Ae:delete ne.startingGivens}),children:d}),children:[E&&m.jsxs(tt,{sx:{alignItems:"flex-start",gap:1,py:3,px:2,border:1,borderStyle:"dashed",borderColor:"divider",borderRadius:1},children:[m.jsx(pe,{variant:"body2",children:"This report is not served until it has a tile."}),c&&m.jsx(Me,{size:"small",startIcon:m.jsx(Yr,{}),onClick:()=>xe(),children:"Add tile"})]}),C?.pending&&m.jsx(it,{severity:"warning",action:m.jsxs(m.Fragment,{children:[m.jsx(Me,{color:"inherit",size:"small",onClick:O.restoreOffered,children:"Restore them"}),m.jsx(Me,{color:"inherit",size:"small",onClick:O.discard,children:"Discard"})]}),children:`You have unsaved edits from ${ro(C.savedAt)}, made before this report changed. Restoring them replaces the current version.`}),j.error&&m.jsx(it,{severity:"warning",children:j.error}),m.jsx(xy,{editor:j,reorder:G,resizing:Z,gridBox:P,defaultSpan:V,rules:W,canAdd:!!c,selected:R,flash:N,menuIndex:Q?.index,onSelect:z,onOpenMenu:(K,oe)=>{z(oe),ee.setMenu({anchor:K,index:oe})},onRemove:ee.removeTile,...j.document.tiles.length===1&&j.saved.tiles.length>0?{removeBlocked:"A saved report needs at least one tile."}:{},openAdd:xe,editTile:ee.editTile,...o?{renderTile:o}:{}}),m.jsx(Em,{editor:j,catalog:c,columns:_,dashboards:u,bindings:me,tiles:ee,drillSource:de,setDrillSource:ge,exitDialog:Ie.exitGuard.dialog,...a?{renderViewPreview:a}:{},...$?{takenGivenNames:$}:{}})]})})})}const Qy=ot(m.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"})),e0=ot(m.jsx("path",{d:"M9 17H7v-7h2zm4 0h-2V7h2zm4 0h-2v-4h2zm2.5 2.1h-15V5h15zm0-16.1h-15c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2"})),t0=ot(m.jsx("path",{d:"M3 18h12v-2H3zM3 6v2h18V6zm0 7h18v-2H3z"}));function $0({controls:e,onDone:t}){const n=t??e?.exit,r=ff("(max-width: 599.95px)"),{theme:i}=He(),s=Yt(i.cardBorder),o=ds(i.cardBorder,i.tileTitle),[a,d]=S.useState(null),f=e?.save!==void 0&&e.status!=="saved",c=e?.done??n,l=f&&e?.done===void 0,u=e?.add,p=u!==void 0&&(u.tile!==void 0||u.text!==void 0||u.filter!==void 0||u.filterUnavailable!==void 0),g=v=>()=>{d(null),v?.()};return m.jsxs(tt,{direction:"row",role:"toolbar",className:Ze.builderBar,"aria-label":"Report builder",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[e&&m.jsxs(m.Fragment,{children:[e.save&&m.jsx(Hc,{...e}),!r&&m.jsxs(m.Fragment,{children:[m.jsx(kt,{title:`Undo (${dn}Z)`,children:m.jsx("span",{children:m.jsx(Bn,{"aria-label":"Undo",disabled:!e.canUndo,onClick:e.undo,sx:Fi(i.ui),children:m.jsx(_c,{fontSize:"small"})})})}),m.jsx(kt,{title:`Redo (${dn}⇧Z)`,children:m.jsx("span",{children:m.jsx(Bn,{"aria-label":"Redo",disabled:!e.canRedo,onClick:e.redo,sx:Fi(i.ui),children:m.jsx(Bc,{fontSize:"small"})})})}),p&&m.jsx(Nr,{orientation:"vertical",sx:Bi}),p&&m.jsxs(m.Fragment,{children:[m.jsx(Me,{variant:"outlined",startIcon:m.jsx(Yr,{}),endIcon:m.jsx(ta,{}),"aria-haspopup":"menu","aria-expanded":a!==null,onClick:v=>d(v.currentTarget),sx:{...Er(s,o),"& .MuiButton-endIcon":{ml:.25,"& svg":{fontSize:16}}},children:"Add"}),m.jsxs(zi,{anchorEl:a,open:a!==null,onClose:()=>d(null),disableRestoreFocus:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:-6,horizontal:"right"},slotProps:{paper:{sx:n0(s,i.ui)}},MenuListProps:{sx:{p:.5}},children:[u?.tile&&m.jsx(Ys,{icon:m.jsx(e0,{}),title:"Tile",detail:"A view from the model",onClick:g(u.tile)}),u?.text&&m.jsx(Ys,{icon:m.jsx(t0,{}),title:"Text",detail:"Prose between the tiles",onClick:g(u.text)}),(u?.filter||u?.filterUnavailable)&&m.jsx(Ys,{icon:m.jsx(Qy,{}),title:"Filter",detail:u.filterUnavailable??"A control the tiles read",disabled:u.filter===void 0,onClick:g(u.filter)})]})]})]})]}),(c||l)&&e&&m.jsx(Nr,{orientation:"vertical",sx:Bi}),c&&m.jsx(kt,{enterDelay:800,enterNextDelay:800,title:e?.done&&f?`Saves your edits, then shows the report · ${e.saveTarget}`:"",children:m.jsx("span",{children:m.jsx(Me,{variant:l?"outlined":"contained",disableElevation:!0,disabled:e?.status==="saving",onClick:c,sx:{...Er(s,o,i.ui),width:92},children:e?.done&&e.status==="saving"?"Saving…":"Done"})})}),e?.save&&l&&m.jsx(kt,{title:`Save (${dn}S) · ${e.saveTarget}`,children:m.jsx("span",{children:m.jsx(Me,{variant:"contained",disableElevation:!0,disabled:e.status==="saving",onClick:e.save,sx:{...Er(s,o,i.ui),minWidth:72},children:e.status==="saving"?"Saving…":"Save"})})})]})}const n0=(e,t)=>({minWidth:260,mt:.5,borderRadius:t.radius.menu,border:`1px solid ${e}`,boxShadow:t.shadow.menu});function Ys({icon:e,title:t,detail:n,disabled:r=!1,onClick:i}){const{theme:s}=He(),o=s.ui;return m.jsxs(vt,{onClick:i,disabled:r,sx:a=>({gap:1.5,px:1.25,py:1,borderRadius:o.radius.control,alignItems:"center","& .add-icon":{width:32,height:32,flex:"none",borderRadius:o.radius.tile,display:"flex",alignItems:"center",justifyContent:"center",color:a.palette.text.secondary,bgcolor:a.palette.action.hover,transition:`color ${Fe}, background-color ${Fe}`,"& svg":{fontSize:18}},"&:hover .add-icon, &.Mui-focusVisible .add-icon":{color:s.accent,bgcolor:`color-mix(in srgb, ${s.accent} 10%, ${a.palette.background.paper})`},"&.Mui-focusVisible":{outline:"none",bgcolor:a.palette.action.hover},"&.Mui-disabled":{opacity:1},"&.Mui-disabled .add-text":{opacity:.5},"&.Mui-disabled .add-icon":{opacity:.5}}),children:[m.jsx(B,{className:"add-icon","aria-hidden":!0,children:e}),m.jsxs(B,{className:"add-text",sx:{minWidth:0},children:[m.jsx(B,{sx:{...o.type.control,fontWeight:o.type.label.fontWeight,lineHeight:1.3},children:t}),m.jsx(B,{sx:{...o.type.caption,color:"text.secondary",whiteSpace:"normal",maxWidth:220},children:n})]})]})}function r0(e,t,n=new Set){const r=new Set;for(const o of e.tiles)for(const a of ae(o)?o.filters??[]:[])r.add(a.given);const i=[],s=new Set;for(const o of e.localGivens??[])r.has(o.name)&&(s.add(o.name),i.push(Mp(o)));for(const o of t)o.name===void 0||s.has(o.name)||!(r.has(o.name)||n.has(o.name))||(s.add(o.name),i.push(o));return i}function i0(e,t,n){const r=new Map;for(const s of t.tiles)ae(s)&&r.set(In(`${s.source} -> ${s.name}`),new Set((s.filters??[]).map(o=>o.given)));const i=new Set;for(const s of e.tiles){if(!ae(s))continue;const o=In(`${s.source} -> ${s.name}`),a=r.get(o);for(const d of n.get(o)??[])a?.has(d)||i.add(d)}return i}function s0(e){const t=e?.trim();if(!(!t||/^f(['"])\1$/.test(t)))return t}function o0(e){return e.kind==="inline"?!0:e.kind==="opaque"&&(e.why.includes("compound")||e.why.includes("pipeline"))}function In(e){return e.split("->").map(t=>t.trim().replace(/\s+/g," ")).join(" -> ").replace(/\s+/g," ")}function a0(e,t,n,r=new Map,i){if(t.declaration.kind==="inherited")return{expression:`${t.source} -> ${t.name}`,givenNames:void 0,reads:i&&[...i]};const s=t.source,o=t.declaration.kind==="reference"?t.declaration.from:t.name,a=new Map((e.localGivens??[]).map(x=>[x.name,x.type])),d=new Map((e.localGivens??[]).map(x=>[x.name,x.default])),f=e.sources.find(x=>x.name===s)?.scopedBy??[],c=new Set([...f,...i??[]].filter(x=>n.has(x))),l=new Set([...f,...i??[]]),u=[];for(const x of t.filters??[]){const k=`where: ${la(x.field)} ${x.op??"~"}`;if(n.has(x.given)){c.add(x.given),l.add(x.given),u.push(`${k} $${x.given}`);continue}if(!a.has(x.given))continue;l.add(x.given);const h=Cp(r.get(x.given),a.get(x.given))??s0(d.get(x.given));h!==void 0&&u.push(`${k} ${h}`)}const p=u.join(", "),g=t.chart,v=g==="none"||ca(g)?cn(g,t.chartCarried):g==="custom"&&t.chartLines?.length?t.chartLines.join(`
|
|
143
|
+
`):g==="default"&&o0(t.declaration)?cn("none"):void 0;return{...v?{annotation:v}:{},expression:`${s} -> ${o}`+(p?` + { ${p} }`:""),givenNames:Array.from(c),reads:i||l.size>0?Array.from(l):void 0}}function l0({environmentName:e,packageName:t,versionId:n,modelPath:r,reports:i,reportsSettled:s}){const{apiClients:o,server:a}=na(),{data:d}=ra({queryKey:["report-editor-models",e,t,n],queryFn:async()=>(await o.models.listModels(e,t,n)).data.flatMap(g=>g.path&&!g.error?[g.path]:[])}),f=S.useMemo(()=>new Set([r,...i.flatMap(g=>g.path?[g.path]:[])]),[i,r]),c=S.useMemo(()=>s?(d??[]).filter(g=>!f.has(g)):[],[d,f,s]),l=jp({queries:c.map(g=>({queryKey:["report-editor-model",e,t,g,n,a],queryFn:async()=>(await o.models.getModel(e,t,g,n)).data,retry:!1}))}),u=d!==void 0&&s&&l.every(g=>g.isSuccess||g.isError),p=l.map(g=>g.dataUpdatedAt).join();return S.useMemo(()=>u?Wy(l.flatMap((g,v)=>g.data?[{...g.data,path:c[v]}]:[]),f):void 0,[u,c,p,f])}const c0={};function d0({textSource:e,environmentName:t,packageName:n,modelPath:r,versionId:i,opened:s,replaces:o,onSave:a,onDirtyChange:d,onExit:f,onOpenModel:c,onControlsChange:l,draftKey:u,onEvent:p,savesTo:g,saveLabel:v,note:x}){const{apiClients:k}=na(),[h,b]=S.useState(s.document.tiles.length>0);S.useEffect(()=>b(s.document.tiles.length>0),[s.generation,s.document]);const{data:y,isSuccess:w,isError:$}=ra({...qf(k,{environmentName:t,packageName:n,path:r,versionId:i},Uf),enabled:h&&!e}),M=e?.modelPath??r,T=h0(s.source,e?.compileSource),j=Vf({environmentName:t,packageName:n,modelPath:M,source:T.text??s.source,...e?.givens?{givens:e.givens}:{}},{enabled:e!==void 0&&T.text!==void 0}),O=j.data?.document,P=e?j.isSuccess?O?.manifest??c0:void 0:y,R=e?j.isSuccess:w,A=e?j.isError||T.problem!==void 0:$,z=e?Gf(O?.cells):void 0,q=(j.data?.result.problems??[]).filter(C=>C.severity==="error"),U=S.useMemo(()=>new Set(e?.hiddenGivens??[]),[e]),D=e?.givens,N=S.useMemo(()=>new Set((P?.tiles??[]).flatMap(C=>C.restricted&&C.query?[In(C.query)]:[])),[P]),{reports:F,settled:W}=Kf(t,n,i),_=S.useMemo(()=>F.map(C=>C.path).filter(C=>!!C&&C!==r&&C.endsWith(".malloy")).map(C=>C.replace(/\.malloy$/,"")),[F,r]),Y=l0({environmentName:t,packageName:n,...i!==void 0?{versionId:i}:{},modelPath:r,reports:F,reportsSettled:W}),G=S.useMemo(()=>e?(Y?.sources??[]).filter(C=>(C.visibleIn??C.exporters??[C.modelPath]).includes(M)).map(C=>C.name):void 0,[Y,e,M]),le=S.useMemo(()=>Y&&G?{sources:Y.sources.filter(C=>G.includes(C.name))}:Y,[Y,G]),[V,H]=S.useState(s.document);S.useEffect(()=>H(s.document),[s.document]);const Z=S.useMemo(()=>a&&(async(C,L)=>{await a(C,L.document.layout),g==="package"&&b(L.document.tiles.length>0)}),[a,g]),ee=S.useMemo(()=>(P?.givens??[]).filter(C=>!(e&&C.secure===!0)&&!(C.name!==void 0&&U.has(C.name))),[P,U,e]),Q=S.useMemo(()=>new Set([...ee.map(C=>C.name).filter(C=>C!==void 0),...Object.keys(D??{})]),[ee,D]),ce=S.useMemo(()=>new Map((P?.tiles??[]).flatMap(C=>C.kind!=="text"&&C.query&&C.givenNames?[[In(C.query),C.givenNames]]:[])),[P]),xe=S.useMemo(()=>i0(V,s.document,ce),[V,s.document,ce]),me=S.useMemo(()=>r0(V,ee,xe),[V,ee,xe]),te=S.useMemo(()=>{const C=new Set(V.tiles.flatMap(ne=>ae(ne)?(ne.filters??[]).map(Ae=>Ae.given):[])),L=new Set((V.localGivens??[]).map(ne=>ne.name)),ue=[...new Set(V.imports.map(ne=>ne.from))],K=ue.length===1?f0(r,ue[0]):ue.length===0&&e?e.modelPath:void 0,oe=ne=>{const Ae=V.sources.filter(Rt=>Rt.scopedBy?.includes(ne)).map(Rt=>Rt.name);return Ae.length>0?{reason:`Applied to every tile on ${Ae.join(", ")} by this report's own source. Edit the file to change it.`}:L.has(ne)?{reason:"Read by a query in this report the builder cannot edit. Edit the file to change it."}:K!==void 0?{reason:`Set in the model ${K}. Edit the model to change it.`,modelPath:K}:{reason:"Set in a model this report imports. Edit the model to change it."}};return new Map([...xe].filter(ne=>!C.has(ne)).map(ne=>[ne,oe(ne)]))},[V,xe,e,r]),{declaredTypes:fe,applied:de,panel:ge}=Yf({specs:me,loaded:R,startingValues:P?.startingGivens,documentKey:`${t}/${n}/${i??""}/${r}/edit`,autorun:P?.autorun!==!1,environmentName:t,packageName:n,modelPath:e?M:P?.path,versionId:i,documentName:r,...z!==void 0?{preamble:z}:{},...D?{hostGivens:D}:{}}),Pe=S.useMemo(()=>Xf(me,de,D),[me,de,D]),Ve=S.useMemo(()=>Object.fromEntries(Object.entries(D??{}).filter(([C])=>!fe.has(C))),[D,fe]),Ge=!h||R||A,Ke=e!==void 0&&(T.problem!==void 0||j.isError||q.length>0),Ie=S.useMemo(()=>new Map(s.document.tiles.map(C=>[Ne(C),C])),[s.document]),E=S.useMemo(()=>function(C,L,ue="card"){if(Ke)return m.jsxs(Js,{chrome:ue,children:[m.jsx(Zs,{title:L?.title??Nn(C),subtitle:L?L.subtitle:C.subtitle}),m.jsx(pe,{variant:"body2",sx:{color:"text.secondary",py:1},children:"Not run: this document did not compile."})]});if(!Ge)return m.jsxs(Js,{chrome:ue,children:[m.jsx(Zs,{title:L?.title??Nn(C),subtitle:L?L.subtitle:C.subtitle}),m.jsx(Xs,{text:"Running…"})]});const K=ce.get(In(`${C.source} -> ${C.name}`)),oe=z===void 0&&K!==void 0&&u0(Ie.get(Ne(C)),C)?{expression:`${C.source} -> ${C.name}`,givenNames:[...K],reads:[...K]}:a0(V,C,Q,de,K);return m.jsx(bl,{environmentName:t,packageName:n,versionId:i,modelPath:M,...z!==void 0?{preamble:z}:{},...N.has(In(`${C.source} -> ${C.name}`))?{restricted:!0}:{},tile:oe.expression,...oe.annotation?{annotation:oe.annotation}:{},label:Nn(C),chrome:ue,subtitle:C.subtitle,...L?{heading:L}:{},borderless:C.borderless,givens:de,hostGivens:Ve,declaredTypes:fe,givenNames:oe.givenNames,...(()=>{const ne=Qf(Pe,oe.reads??oe.givenNames);return ne.length>0?{waitingFor:ep(ne)}:{}})(),ignoredFilters:Zf(oe.reads,me),height:Jf})},[V,Ie,Ge,Ke,Pe,Q,ce,t,n,i,M,z,N,de,Ve,fe,me]),I=S.useMemo(()=>function(C){return m.jsx(bl,{environmentName:t,packageName:n,versionId:i,modelPath:C.modelPath,tile:`${C.base} -> ${C.view}`,...C.chart?{annotation:cn(C.chart,C.chartCarried)}:{},label:C.label,borderless:!0,givens:de,hostGivens:Ve,declaredTypes:fe,givenNames:C.givens,height:200})},[t,n,i,de,Ve,fe]);return m.jsxs(tt,{sx:{gap:1},children:[e&&q.length>0&&m.jsxs(it,{severity:"error",children:["The server could not compile this document:"," ",q.map(C=>C.message).join("; ")]}),Pe.length>0&&!Ke&&m.jsx(it,{severity:"info",children:tp(Pe)}),e&&T.problem!==void 0&&m.jsxs(it,{severity:"error",children:["This document could not be prepared to compile:"," ",T.problem]}),e&&j.isError&&m.jsxs(it,{severity:"error",children:["The server could not compile this document:"," ",j.error?.message]}),m.jsx(Jh,{...e&&!e.compileSource?{addFilterDisabledReason:"This document holds no given: of its own. Bind a filter the model offers from its chip."}:{},source:s.source,document:s.document,fixedFilters:te,...e?.takenGivenNames?{takenGivenNames:e.takenGivenNames}:{},renderTile:E,renderViewPreview:I,givens:me.filter(C=>C.name!==void 0).map(C=>({name:C.name,...C.label?{label:C.label}:{},...C.type?{type:C.type}:{},...C.suggest?.dimension?{field:C.suggest.dimension}:{}})),onChange:H,onDirtyChange:d,...f?{onExit:f}:{},...c?{onOpenModel:c}:{},...l?{onControlsChange:l}:{},...u!==void 0?{draftKey:u}:{},...le?{catalog:le}:{},dashboards:_,...p?{onEvent:p}:{},controls:R?m.jsx(np,{...ge,layout:"bar"}):void 0,...Z?{onSave:Z}:{},savesTo:g,...v?{saveLabel:v}:{},...o!==void 0?{replaces:o}:{},modelPath:r,...e?{visibleSources:G}:{}}),m.jsx(B,{sx:{px:.5},children:m.jsx(pe,{variant:"caption",sx:{opacity:.7},children:x})})]})}function u0(e,t){return e!==void 0&&JSON.stringify(Mc(e))===JSON.stringify(Mc(t))}function Mc(e){const{label:t,subtitle:n,colspan:r,break:i,borderless:s,...o}=e;return o}function h0(e,t){const n=S.useRef(t);n.current=t;const r=t!==void 0,[i,s]=S.useState();return S.useEffect(()=>{if(!r)return;let o=!0;return Promise.resolve().then(()=>n.current(e)).then(a=>{o&&s({from:e,text:a})},a=>{o&&s({from:e,problem:a instanceof Error?a.message:String(a)})}),()=>{o=!1}},[e,r]),r?i?.from!==e?{}:i.problem!==void 0?{problem:i.problem}:{text:i.text}:{text:e}}function f0(e,t){const n=e.split("/").slice(0,-1);for(const r of t.split("/"))r===".."?n.pop():r!=="."&&r!==""&&n.push(r);return n.join("/")}function p0({storage:e,layout:t,notebook:n,environmentName:r,packageName:i,modelPath:s}){const[o,a]=S.useState(void 0),[d,f]=S.useState(void 0),[c,l]=S.useState(e===void 0),[u,p]=S.useState(!1),[g,v]=S.useState(void 0);return S.useEffect(()=>{if(!e)return;let x=!1;return v(void 0),(async()=>{try{const k=zf(await e.listWorkspaces(!1));if(x)return;if(a(k),k!==void 0&&(!n||k.authoritative)){const h=await e.getDocument(Ac(t,k.name,r,i,s)).catch(b=>{if(!Rc(b))throw b});if(x)return;f(h),p(h!==void 0)}}catch(k){if(x)return;v(Pc(k))}x||l(!0)})(),()=>{x=!0}},[e,t,n,r,i,s]),{workspace:o,draft:d,setDraft:f,draftChecked:c,offered:u,setOffered:p,readFailure:g}}const m0=(e,t)=>t!==void 0&&!/\bline \d+/i.test(e)?`${e} (line ${t})`:e;async function g0(e){const t=await Jo(e);return Xo(t)?{ok:!1,reason:m0(t.reason,t.line)}:{ok:!0,document:t.document}}const v0="a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` report to edit it here.",b0="the server did not send this notebook's text, so there is nothing here to edit. Fix: edit the file in the package.";function x0({workspace:e,draft:t,draftChecked:n,readFailure:r,packageText:i,fetchedAt:s,packageSettled:o,modelPath:a,layout:d,notebook:f,noun:c,legacyFormat:l,textHeld:u,startedAt:p,onEventRef:g}){const v=S.useRef({path:a,layout:d});v.current={path:a,layout:d};const x=S.useRef((te,fe)=>{try{g.current?.(Lf(te,{...v.current,...fe?{layout:fe}:{}}))}catch{}}),k=e?.authoritative===!0,h=k&&r!==void 0,[b,y]=S.useState(void 0),w=(k||b===!0)&&t!==void 0,[$,M]=S.useState(void 0),[T,j]=S.useState(l?v0:void 0),O=S.useRef(void 0),P=S.useRef(void 0),[R,A]=S.useState(void 0),z=S.useRef(s);z.current=s;const q=R!==void 0&&R.onFetch===s?R.text:i,U=S.useRef(q);U.current=q;const D=w?t:q,[N,F]=S.useState(!1),[W,_]=S.useState(void 0),[Y,G]=S.useState(void 0),le=D!==void 0&&D!==Y,V=$?.source,H=le&&(N||!k&&t!==void 0&&V===t&&t!==q)&&V!==void 0&&D!==W,Z=H?V:le?D:V??D,ee=H?D:void 0,Q=S.useRef(V);Q.current=V;const ce=S.useRef(D);ce.current=D;const xe=S.useRef("package");xe.current=w?k?"record":"draft":"package",S.useEffect(()=>{if(Z===void 0||!n||h||Z===Q.current)return;let te=!1;const fe=U.current,de=ce.current;return g0(Z).then(ge=>{if(!te){if(ge.ok===!1){j(ge.reason),x.current({type:"report.load_failed",surface:"edit",category:"invalid"});return}j(void 0),O.current=void 0,P.current=fe,A(void 0),_(void 0),G(de),M(Pe=>({source:Z,document:ge.document,...fe!==void 0?{packageText:fe}:{},generation:(Pe?.generation??0)+1})),x.current({type:"report.opened",surface:"edit",from:xe.current,tiles:ge.document.tiles.length,durationMs:Lt()-p.current},ge.document.layout)}}).catch(ge=>{if(te)return;const Pe=`Could not read the ${c}: ${ge instanceof Error?ge.message:String(ge)}`;j(Pe),x.current({type:"report.load_failed",surface:"edit",category:Ec(ge)})}),()=>{te=!0}},[Z,a,n,h,f,c,u,p]),S.useEffect(()=>{l&&x.current({type:"report.load_failed",surface:"edit",category:"unsupported"})},[l]),S.useEffect(()=>{!u||!n||$||r!==void 0||(k?t===void 0&&j("the host's storage has no document at this location."):j("a document held as text needs a storage whose workspace is authoritative. Fix: mark the workspace that keeps it `authoritative`."))},[u,n,$,r,k,t]);const me=f&&!u&&!$&&n&&!w&&o&&i===void 0;return S.useEffect(()=>{me&&(j(b0),x.current({type:"report.load_failed",surface:"edit",category:"forbidden"}))},[me]),{authoritative:k,blockedOnRecord:h,resume:b,setResume:y,fromDraft:w,opened:$,setOpened:M,openError:T,savedHashRef:O,packageBaseRef:P,setWrote:A,fetchedAtRef:z,setDirty:F,setSeen:G,held:ee,choose:te=>{p.current=Lt(),_(te?t:q),y(te)},acceptHeld:()=>{p.current=Lt(),_(ee)}}}function y0({storage:e,workspace:t,layout:n,notebook:r,environmentName:i,packageName:s,modelPath:o,versionId:a,apiClients:d,queryClient:f,mutable:c,textHeld:l,readFailure:u,authoritative:p,resume:g,setResume:v,setOpened:x,setDraft:k,setOffered:h,setSeen:b,setWrote:y,savedHashRef:w,packageBaseRef:$,fetchedAtRef:M}){const T=S.useCallback(F=>t===void 0?void 0:Ac(F,t.name,i,s,o),[t,i,s,o]),j=T(n),O=S.useCallback(async(F,W=n)=>{const _=T(W);if(!e||!_)throw new Error("This host keeps no documents, so there is nowhere to save.");await e.saveDocument(_,F),x(Y=>Y&&{...Y,source:F}),k(F),(p||g===!0)&&b(F),p||v(Y=>Y??!1)},[e,T,n,p,g,x,k,b,v]),[P,R]=S.useState(void 0),A=S.useCallback(async F=>{const W=await Ff(w.current,$.current);if(W===void 0)throw new Error("The package file is still loading; try again.");const _=["dashboard-editor-model",i,s,o,a,r];await Bf({apiClients:d,queryClient:f,environmentName:i,packageName:s,modelPath:o,source:F,expectedHash:W,invalidateOnError:[_],afterWrite:async Y=>{if(x(G=>G&&{...G,source:F}),y({text:F,onFetch:M.current}),b(F),w.current=Y,R(void 0),e&&j)try{await e.deleteDocument(j),k(void 0),h(!1)}catch(G){Rc(G)?(k(void 0),h(!1)):R(Pc(G))}v(!1)},invalidate:[{queryKey:_,wait:!0},{queryKey:$p({environmentName:i,packageName:s,versionId:a,modelPath:o})}]}),_f(f,i,s,o)},[d,i,s,o,a,r,e,j,f,w,$,M,x,y,b,k,h,v]),z=t?.writeable===!0,q=c===!0&&!l,{savesTo:U,pinnedPackageSave:D,writer:N}=Sp({authoritative:p,mutable:q,...a!==void 0?{versionId:a}:{},canStore:!!e&&!!j&&z&&(!r||p),readFailed:u!==void 0});return{save:N==="storage"?O:N==="package"?A:void 0,savesTo:U,writer:N,pinnedPackageSave:D,takesWrites:q,supersedeFailure:P}}function Zh(e){const{onEvent:t,loading:n,onDirtyChange:r,onExit:i,onOpenModel:s,onControlsChange:o,keepDraft:a,kind:d,path:f,textSource:c}=e,l=e.layout??(d?xf(d):"grid"),u=l==="linear",p=c!==void 0,{environmentName:g,packageName:v,versionId:x,namesBoth:k}=yf(e),h=("resourceUri"in e?e.dashboard:e.dashboardName)??wf(f)??"",b="report",{apiClients:y,mutable:w,isLoadingStatus:$,server:M}=na(),T=kf(),j=S.useRef(Lt()),O=S.useRef(t);O.current=t;const P=S.useRef(r);P.current=r;const R=Sf()?.documentStorage,A=f??Nf(d??"dashboard",h),z=/\.malloynb$/i.test(A)||u&&/\.malloynb$/i.test(h),q=ra({queryKey:["dashboard-editor-model",g,v,A,x,u],queryFn:()=>y.models.getModel(g,v,A,x,u?!0:void 0),enabled:k&&!z&&!p}),U=q.data?.data?.sourceText,{workspace:D,draft:N,setDraft:F,draftChecked:W,offered:_,setOffered:Y,readFailure:G}=p0({storage:R,layout:l,notebook:u,environmentName:g,packageName:v,modelPath:A}),{authoritative:le,blockedOnRecord:V,resume:H,setResume:Z,fromDraft:ee,opened:Q,setOpened:ce,openError:xe,savedHashRef:me,packageBaseRef:te,setWrote:fe,fetchedAtRef:de,setDirty:ge,setSeen:Pe,held:Ve,choose:Ge,acceptHeld:Ke}=x0({workspace:D,draft:N,draftChecked:W,readFailure:G,packageText:U,fetchedAt:q.dataUpdatedAt,packageSettled:q.isSuccess&&!q.isFetching,modelPath:A,layout:l,notebook:u,noun:b,legacyFormat:z,textHeld:p,startedAt:j,onEventRef:O}),{save:Ie,savesTo:E,writer:I,pinnedPackageSave:C,takesWrites:L,supersedeFailure:ue}=y0({storage:R,workspace:D,layout:l,notebook:u,environmentName:g,packageName:v,modelPath:A,versionId:x,apiClients:y,queryClient:T,mutable:w,textHeld:p,readFailure:G,authoritative:le,resume:H,setResume:Z,setOpened:ce,setDraft:F,setOffered:Y,setSeen:Pe,setWrote:fe,savedHashRef:me,packageBaseRef:te,fetchedAtRef:de}),K=D?.name,oe=S.useCallback(Xt=>{O.current?.($f(Xt,K))},[K]),ne=q.isError&&!Q,Ae=S.useRef(!1);S.useEffect(()=>{!ne||Ae.current||(Ae.current=!0,Cc({path:A,layout:l},O.current).emit({type:"report.load_failed",surface:"edit",category:Ec(q.error)}))},[ne,q.error,A,l]);const Rt=S.useCallback((Xt,$s)=>{ge(Xt),P.current?.($s)},[ge]),Pt=a?Hf({server:M,environmentName:g,packageName:v,versionId:x,path:f??h}):void 0,vn=E==="host"&&D?.description?D.description:void 0,ai=!le&&!p&&w===void 0?$?"Checking whether this server takes writes.":"This server did not say whether it takes writes, so Save is off.":jf({authoritative:le,mutable:L,pinnedPackageSave:C,...D?{workspace:D}:{},...G!==void 0?{readFailure:G}:{},...x!==void 0?{versionId:x}:{}}),li=E==="package"&&L===!0&&!C&&G===void 0||ai===vn?"":ai;if(!k&&"resourceUri"in e)return m.jsxs(it,{severity:"error",sx:{m:2},children:["A ",b," resource URI must name an environment and a package. Received: ",e.resourceUri]});if(xe)return m.jsxs(it,{severity:"error",sx:{m:2},children:["This ",b," cannot be opened in the builder: ",xe]});if(q.isError&&!Q)return m.jsx(Mf,{error:q.error,context:`Opening the ${b}`});if(!Q&&(!(p||U)||!W))return n??m.jsx(Xs,{text:`Opening the ${b}…`});if(V)return m.jsxs(it,{severity:"error",sx:{m:2},children:["This ",b," cannot be opened: ",G]});const Ss=N!==void 0&&N!==U;return m.jsxs(tt,{sx:{gap:2},children:[q.isError&&m.jsxs(it,{severity:"warning",children:["The ",b," could not be re-read from the server:"," ",q.error?.message,". Your edits are still here."]}),!u&&!le&&_&&Ss&&H===void 0&&m.jsx(it,{severity:"info",action:m.jsxs(tt,{direction:"row",sx:{gap:1},children:[m.jsx(Me,{size:"small",onClick:()=>Ge(!0),children:"Resume"}),m.jsx(Me,{size:"small",onClick:()=>Ge(!1),children:"Start from the package"})]}),children:"You have edits to this report saved in this browser that the package does not have."}),Ve!==void 0&&m.jsx(it,{severity:"warning",action:m.jsx(Me,{size:"small",onClick:()=>{Pt!==void 0&&Cf(Pt),Ke()},children:"Load it"}),children:E==="package"?"This report changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":E==="host"?"This report changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this report changed since you opened it. Your edits are still here; loading the new version replaces them."}),ue!==void 0&&m.jsxs(it,{severity:"warning",children:["The file was saved into the package, but the copy kept beside it could not be cleared, so it will be offered again:"," ",ue]}),!Q&&(n??m.jsx(Xs,{text:`Opening the ${b}…`})),Q&&m.jsx(d0,{environmentName:g,packageName:v,modelPath:A,...c?{textSource:c}:{},slug:h,...x!==void 0?{versionId:x}:{},opened:Q,...ee&&I==="package"&&Q.packageText!==void 0?{replaces:Q.packageText}:{},onSave:Ie,onDirtyChange:Rt,...i?{onExit:i}:{},...s?{onOpenModel:s}:{},...o?{onControlsChange:o}:{},...Pt!==void 0?{draftKey:Pt}:{},savesTo:E,...vn?{saveLabel:vn}:{},...t?{onEvent:oe}:{},note:li},Q.generation)]})}const j0=Zh,M0=Jh;function C0(e){const{onEvent:t,onDirtyChange:n,onExit:r,path:i}=e,s="resourceUri"in e?{resourceUri:e.resourceUri,dashboard:e.notebook}:{environmentName:e.environmentName,packageName:e.packageName,dashboardName:e.notebookName};return m.jsx(Zh,{...s,kind:"notebook",...t?{onEvent:t}:{},...n?{onDirtyChange:n}:{},...r?{onExit:r}:{},...i!==void 0?{path:i}:{}})}typeof globalThis.process>"u"?globalThis.process={env:{}}:wl===void 0&&(wl={});export{$0 as BuilderBar,M0 as DashboardBuilder,j0 as DashboardEditor,D0 as MAX_SLUG_ATTEMPTS,C0 as NotebookEditor,Jh as ReportBuilder,Zh as ReportEditor,Wy as buildCatalog,T0 as createDocument,A0 as createRoute,Ac as locatorFor,R0 as newDashboardSource,P0 as newDocumentProblem,I0 as newNotebookSource,Jo as readDashboardDocument,Xo as readFailed,S0 as readReportTagOfText,W0 as reportPathFor,N0 as reportPathForTitle,z0 as slugFor,L0 as slugOrFallback,cy as spliceDashboardDocument,Zo as spliceFailed,F0 as useDocumentChoices};
|