@malloy-publisher/server 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/app/api-doc.yaml +727 -361
  2. package/dist/app/assets/EnvironmentPage-1dxk_vne.js +1 -0
  3. package/dist/app/assets/{HomePage-BM31X4Y8.js → HomePage-DOCeWyiv.js} +1 -1
  4. package/dist/app/assets/MainPage-Baqv8q6B.js +1 -0
  5. package/dist/app/assets/ModelPage-BuMKFY0Q.js +2 -0
  6. package/dist/app/assets/PackagePage-DMRAjKE6.js +1 -0
  7. package/dist/app/assets/{RenderedResult-CkUS04tl.es-CNz9JsEK.js → RenderedResult-DZj-FnOJ.es-8Pxk7Ln2.js} +2 -2
  8. package/dist/app/assets/{RouteError-DLJlCtRG.js → RouteError-CXf8Frkp.js} +1 -1
  9. package/dist/app/assets/{ThemeEditorPage-Ck4rJ1vv.js → ThemeEditorPage-BzjDFaw6.js} +1 -1
  10. package/dist/app/assets/ToggleButtonGroup-o0Gqmq5F.js +1 -0
  11. package/dist/app/assets/documentRoutes-B2MDvZ3y.js +1 -0
  12. package/dist/app/assets/{index-BcsfsLm3.js → index-Buv5Qzfs.js} +1 -1
  13. package/dist/app/assets/{index-D3HZqxOW.js → index-BuyzVBLU.js} +1 -1
  14. package/dist/app/assets/index-CDTd6FbM.js +483 -0
  15. package/dist/app/assets/{index-wawGd6k1.js → index-CvMqTqVr.js} +1 -1
  16. package/dist/app/assets/index.es-CECvOvgr.js +195 -0
  17. package/dist/app/index.html +1 -1
  18. package/dist/package_load_worker.mjs +15899 -17181
  19. package/dist/server.mjs +11292 -11153
  20. package/dist/sshcrypto-cqb52edz.node +0 -0
  21. package/package.json +1 -1
  22. package/dist/app/assets/EnvironmentPage-V6cQ_Kpr.js +0 -1
  23. package/dist/app/assets/MainPage-CQW3P4wB.js +0 -1
  24. package/dist/app/assets/ModelPage-dBHaHb6u.js +0 -2
  25. package/dist/app/assets/PackagePage-B-ruDCyR.js +0 -1
  26. package/dist/app/assets/ToggleButtonGroup-Bwj7gIJm.js +0 -1
  27. package/dist/app/assets/documentRoutes-DGm_-EUy.js +0 -1
  28. package/dist/app/assets/index-hnA8HjeH.js +0 -484
  29. package/dist/app/assets/index.es-B2kJpnhe.js +0 -195
@@ -1,195 +0,0 @@
1
- import{r as S,aX as Uf,aY as Gf,j as y,ap as xe,ay as lt,T as ue,aD as Ee,aZ as Pr,a_ as Kf,N as vc,aw as Yf,a$ as wt,b0 as Xf,b1 as fi,b2 as Vf,b3 as Zf,b4 as Qf,_ as bc,b5 as Jf,b6 as eh,b7 as jn,R as Qe,F as Ae,b8 as th,b9 as Ji,ba as nh,K as en,G as Us,bb as Lt,bc as ut,bd as rh,be as yc,aC as es,a8 as ih,bf as sh,bg as xc,bh as wc,bi as kc,bj as oh,bk as ah,bl as lh,a5 as ch,bm as dh,bn as uh,bo as fh,bp as Sc,bq as hh,br as ph,bs as mh,bt as gh,aQ as $c,bu as vh,bv as jc,bw as ts,bx as Cc,by as Oc,bz as bh,bA as yh,bB as xh,bC as wh,ar as et,bD as Ec,bE as nl,H as Ei,I as kh,bF as Sh,bG as Rr,av as Nt,bH as Gs,bI as Tc,bJ as Mc,as as $h,W as Fo,bK as _o,bL as jh,bM as Ch,bN as qo,bO as Oh,aI as Eh,bP as Th,bQ as Mh,bR as Ah,bS as Bt,bT as rl,S as Dh,bU as Ih,L as Ph,U as Rh,bV as Bo,bW as Lh,bX as Nh,bY as Ac,bZ as Wh,aF as zh}from"./index-hnA8HjeH.js";import{b_ as lx,b$ as cx,c0 as dx,c1 as ux,c2 as fx,c3 as hx,c4 as px,c5 as mx,c6 as gx,c7 as vx,c8 as bx}from"./index-hnA8HjeH.js";import{T as Dc,a as Ti}from"./ToggleButtonGroup-Bwj7gIJm.js";var il={};const Fh={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function _h(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this view's details":n==="unlisted"?"Not a view the catalog lists, so its shape is unknown":void 0,i=s=>{if(t!==s){if(s==="big_value")return e?.aggregateOnly===!0?void 0:r??"Needs a view with only totals (no group by)";if(s==="shape_map"||s==="segment_map")return e?.chart===s?void 0:r??"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(s=>{const o=i(s);return{value:s,label:Fh[s],...o?{disabled:!0,reason:o}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Ks({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:i,onOpen:s,onChange:o,variant:a="standard"}){const c=_h(t,e,n),u=S.useId();return y.jsx(et,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:i!==void 0,onChange:l=>{const d=l.target.value;c.find(h=>h.value===d)?.disabled||o(d)},helperText:i,FormHelperTextProps:{id:u},SelectProps:{...s?{onOpen:s}:{},renderValue:l=>c.find(d=>d.value===l)?.label??String(l),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...i?{"aria-describedby":u}:{}}},sx:{minWidth:140},children:c.map(l=>y.jsx(Nt,{value:l.value,disabled:l.value==="custom"||l.disabled===!0,children:y.jsx(Fo,{primary:l.label,...l.reason?{secondary:l.reason}:{}})},l.value))})}function qh({sources:e,source:t,view:n,onSource:r,onView:i}){const{theme:s}=Qe(),o=e.find(a=>a.name===t);return y.jsxs(y.Fragment,{children:[y.jsx(et,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>y.jsxs(Nt,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),y.jsxs(Ae,{children:[y.jsx(ue,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(Ph,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:"min(280px, 30vh)",overflowY:"auto",border:s.border,borderRadius:1},children:[(o?.views??[]).map(a=>y.jsxs(Rh,{selected:n===a.name,onClick:()=>i(a.name),"aria-label":`View ${a.name}`,children:[y.jsx(Fo,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&y.jsx(Us,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&y.jsx(ue,{variant:"body2",sx:{p:1.5,color:s.tileTitle},children:"This source declares no views."})]})]})]})}function Bh({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o}){const{theme:a}=Qe(),c=S.useMemo(()=>n?.sources??[],[n]),[u,l]=S.useState("query"),[d,h]=S.useState(""),[f,m]=S.useState(""),[g,x]=S.useState(""),[w,p]=S.useState("default"),[v,b]=S.useState(Math.ceil(r/2));S.useEffect(()=>{if(!e)return;l("query");const $=O=>c.some(z=>z.name===O&&z.views.length>0);h(t.sources.map(O=>O.base).find($)??c.find(O=>O.views.length>0)?.name??""),m(""),x(""),p("default"),b(Math.ceil(r/2))},[e,t,c,r]);const k=d!==""&&f!=="",D=[d,f].filter($=>$!==""&&!_o($)).map($=>`"${$}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],M=c.find($=>$.name===d),A=M?.views.find($=>$.name===f);return y.jsx(es,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of a source in this package.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:i,children:"Cancel"}),y.jsx(Ee,{variant:"contained",disabled:u==="query"&&(!k||D!==void 0),onClick:()=>u==="text"?o():s({base:d,modelPath:M?.modelPath??"",...M?.exporters?{exporters:M.exporters}:{},view:f,...g.trim()?{label:g.trim()}:{},...w!=="default"?{chart:w,...A?{chartCarried:A.chart?[A.chart]:[]}:{}}:{},colspan:v}),children:u==="text"?"Add text":"Add tile"})]}),children:y.jsxs(xe,{sx:{gap:2,pt:1},children:[y.jsxs(Dc,{size:"small",exclusive:!0,value:u,"aria-label":"Tile type",onChange:($,O)=>{O!==null&&l(O)},children:[y.jsx(Ti,{value:"query",sx:{px:1.5},children:"Query"}),y.jsx(Ti,{value:"text",sx:{px:1.5},children:"Text"})]}),u==="text"?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:"A text tile holds markdown: a heading, a paragraph, a list. It is added empty, and written on the tile itself."}):c.length===0?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}):y.jsxs(y.Fragment,{children:[y.jsx(qh,{sources:c,source:d,view:f,onSource:$=>{h($),m("")},onView:$=>{m($),p("default")}}),D&&y.jsx(ue,{variant:"body2",color:"error",children:D}),y.jsx(Ks,{state:w,view:A,cellLabel:"new tile",variant:"outlined",...A?{}:{disabledReason:"Pick a view to choose its chart."},onChange:$=>p($)}),y.jsx(xe,{direction:"row",sx:{gap:1.5},children:y.jsx(et,{size:"small",label:"Title",placeholder:"Uses the view's name",value:g,onChange:$=>x($.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}})})]})]})})}const Re=e=>e.kind==="text",be=e=>e.kind!=="text",Vr=e=>be(e)?e.label??e.name:e.name,ze=e=>Re(e)?`text.${e.name}`:`${e.source}.${e.name}`,ws="self";function Hh({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Qe(),[c,u]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const f=(t.drills??[]).filter(m=>m.source===n.name);u((n.dimensions??[]).map(m=>{const g=f.find(x=>x.name===m.name);return{name:m.name,expression:m.expression,to:g?.to??[],given:g?.given??""}}))},[e,n,t]);const l=(f,m)=>u(g=>g.map((x,w)=>{if(w!==f)return x;const p={...x};return m(p),p})),d=[ws,...i.filter(f=>f!==ws)],h=f=>f===ws?"This dashboard":f;return y.jsx(es,{open:e,onClose:s,title:"Drill",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:s,children:"Cancel"}),y.jsx(Ee,{variant:"contained",onClick:()=>{n&&(o(c.filter(f=>f.to.length>0).map(f=>({source:n.name,name:f.name,expression:f.expression,to:f.to,...f.given?{given:f.given}:{}}))),s())},disabled:c.length===0,children:"Apply"})]}),children:y.jsx(xe,{sx:{gap:2,pt:1},children:c.length===0?y.jsx(ue,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(Ae,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",y.jsx(Ae,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):c.map((f,m)=>y.jsxs(Ae,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(Ae,{sx:{minWidth:0,pt:.75},children:[y.jsx(ue,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:f.name}),y.jsxs(ue,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:f.expression,children:["is ",f.expression]})]}),y.jsx(et,{select:!0,size:"small",label:"Clicks go to",value:f.to,inputProps:{"aria-label":`Where ${f.name} goes`},SelectProps:{multiple:!0,renderValue:g=>g.length===0?"Not clickable":g.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:g=>l(m,x=>{const w=g.target.value;x.to=Array.isArray(w)?w:String(w).split(",").filter(Boolean)}),children:d.map(g=>y.jsxs(Nt,{value:g,children:[y.jsx(Gs,{size:"small",checked:f.to.includes(g),sx:{p:0,mr:1}}),y.jsx(Fo,{primary:h(g)})]},g))}),y.jsxs(et,{select:!0,size:"small",label:"Sets the filter",value:f.given,disabled:f.to.length===0,inputProps:{"aria-label":`Control ${f.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:f.given===""?`Named ${f.name}, like the dimension`:void 0,onChange:g=>l(m,x=>{x.given=g.target.value}),children:[y.jsx(Nt,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(g=>y.jsx(Nt,{value:g,children:g},g))]})]},f.name))})})}function Uh(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of be(s)?s.filters??[]:[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],i=new Set;for(const s of e.localGivens??[])i.add(s.name),r.push({name:s.name,...s.label===void 0?{}:{label:s.label},type:s.type,...s.suggest?{field:s.suggest.dimension}:{},origin:"dashboard",local:s,boundTiles:n.get(s.name)??0});for(const s of t)i.has(s.name)||(i.add(s.name),r.push({...s,origin:"model",boundTiles:n.get(s.name)??0}));for(const[s,o]of n)i.has(s)||r.push({name:s,origin:"model",boundTiles:o});return r}function Mi(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Gh(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function hi(e,t){const n=Gh(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const i=new Set(["date","timestamp"]);return i.has(n)?i.has(r):n===r}function sl(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function Kh(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Yh=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Xh(e,t){const n=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",r=/^[A-Z_]/.test(n)?n:`F_${n}`,i=Ac(r)?r:`${r}_FILTER`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const ol=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Zr(e){const t=e.label.trim()||e.name,n=e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const Ys=e=>be(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function Vh(e,t){return e.tiles.map(n=>{const r=(be(n)?n.filters??[]:[]).find(i=>i.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:Mi(t.type)!==void 0?{op:Mi(t.type)}:{}}})}function Zh(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Ys(s))return;const o=(s.filters??[]).filter(c=>c.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function Qh(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function Jh(e,t){for(const r of e.tiles){if(!be(r))continue;const i=(r.filters??[]).filter(s=>s.given!==t);i.length>0?r.filters=i:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const Ic=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function ep({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,c=a!==void 0,[u,l]=S.useState({kind:"new"}),[d,h]=S.useState(""),[f,m]=S.useState("select"),[g,x]=S.useState(""),[w,p]=S.useState(""),[v,b]=S.useState([]),[k,D]=S.useState(!1),[M,A]=S.useState(!1),$=P=>t.sources.find(H=>H.name===P.source)?.base??P.source;S.useEffect(()=>{if(e)if(A(n!==void 0),n){l({kind:"existing",name:n.name}),h(n.label??"");const P=Vh(t,n);b(P);const H=P.filter(me=>me.include),oe=new Set(H.map(me=>me.field));p(oe.size===1?H[0].field:n.field??""),D(oe.size>1)}else l({kind:"new"}),h(""),m("select"),p(""),x(new Date().toISOString().slice(0,10)),b(t.tiles.map(P=>({include:Ys(P),field:""}))),D(!1)},[e,n,t]);const O=S.useMemo(()=>[...(t.localGivens??[]).map(P=>P.name),...r.map(P=>P.name)],[t,r]),z=S.useMemo(()=>w.trim()?Xh(w.trim(),O):"",[w,O]),I=u.kind==="existing"?n??r.find(P=>P.name===u.name):z?{name:z,type:Zr({name:z,label:d,kind:f,field:w}).type}:void 0,W=I?.type!==void 0&&!I.type.startsWith("filter<"),G=v.find(P=>P.include)?.op??Mi(I?.type),q=(P,H)=>{A(!0),b(oe=>oe.map((me,Fe)=>Fe===P?{...me,...H}:me))},U=P=>{A(!0),b(H=>H.map(oe=>({...oe,op:P})))},K=P=>{const H=Mi(P);b(oe=>oe.map(({op:me,...Fe})=>H?{...Fe,op:H}:Fe))},V=P=>{A(!0),l({kind:"existing",name:P.name}),p(P.field??""),K(P.type)},re=P=>{A(!0),m(P),K(Zr({name:"X",label:d,kind:P,field:w}).type)},T=t.tiles.map(Ys),_=T.filter(Boolean).length,R=v.filter((P,H)=>P.include&&T[H]).length,N=t.tiles.filter((P,H)=>(v[H]?.include??!1)&&T[H]&&be(P)),F=N.length>0?N:t.tiles.filter((P,H)=>T[H]&&be(P)),ee=S.useMemo(()=>{const P=new Map;let H=!1;for(const oe of F){const me=i?.(oe);if(me){H=!0;for(const Fe of me)P.has(Fe.name)||P.set(Fe.name,Fe)}}return H?[...P.values()]:void 0},[v,t.tiles,i]),J=(()=>{const P=w.trim();for(const H of N){const oe=i?.(H);if(!oe||oe.some(me=>me.name===P))return $(H)}return N[0]?$(N[0]):t.sources[0]?.base})(),C=P=>{A(!0),b(H=>H.map((oe,me)=>({...oe,include:P&&T[me]})))},j=S.useMemo(()=>k?v:v.map(P=>({...P,field:w})),[k,v,w]),E=P=>{for(const H of F){const oe=i?.(H)?.find(me=>me.name===P.trim());if(oe?.type)return oe.type}},Z=P=>hi(I?.type,P.type),B=(P,H)=>{if(P.trim()==="")return"Pick the field this filter compares.";const oe=H?i?.(H):void 0;if(!oe)return;const me=oe.find(Fe=>Fe.name===P.trim());if(!me)return`Not a field of ${H?$(H):"the tiles' source"}.`;if(me.type&&!hi(I?.type,me.type))return`${P.trim()} is ${sl(me.type)}; this filter compares ${sl(I?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},te=P=>{if(A(!0),p(P),c||u.kind!=="new")return;const H=E(P),oe=Zr({name:"X",label:d,kind:f,field:P}).type;H&&!hi(oe,H)&&re(Kh(H))},X=P=>{const H=t.tiles[P];return H&&be(H)?H:void 0},ne=j.map((P,H)=>P.include&&T[H]?B(P.field,X(H)):void 0),Q=ne.every(P=>P===void 0),pe=M?ne:ne.map(()=>{}),L=M&&!k&&R>0?N.map(P=>B(w,P)).find(Boolean):void 0,ae=I!==void 0&&Q&&(u.kind==="existing"||w.trim()!==""&&z!==""),fe=()=>{if(!(!I||!ae))if(u.kind==="new")s(I.name,j,Zr({name:I.name,label:d.trim()||Ic(I.name),kind:f,field:w.trim(),...J?{source:J}:{},...g?{dateDefault:g}:{}}));else if(n?.origin==="dashboard"&&n.local){const P=d.trim(),H=P!==(n.local.label??"");s(I.name,j,H?{...n.local,...P?{label:P}:{}}:void 0)}else s(I.name,j)},Y=c&&a.origin==="model";return{editing:c,shown:a,fromModel:Y,source:u,setSource:l,label:d,setLabel:h,kind:f,dateDefault:g,setDateDefault:x,field:w,rows:v,setRows:b,perTile:k,setPerTile:D,newName:z,target:I,valueTyped:W,commonOp:G,setRow:q,setCommonOp:U,pickExisting:V,pickKind:re,bindable:T,bindableCount:_,included:R,commonFields:ee,setAll:C,accepts:Z,pickField:te,rowProblems:pe,commonProblem:L,canApply:ae,apply:fe}}function al({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:c,autoFocus:u,placeholder:l,sx:d}){const h=S.useMemo(()=>(n??[]).filter(m=>r?.(m)??!0).map(m=>m.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(m=>[m.name,m.type])),[n]);return y.jsx(Ih,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(m,g)=>t(g),value:e,onChange:(m,g)=>t(typeof g=="string"?g:""),disabled:c,disableClearable:!0,renderOption:(m,g)=>S.createElement("li",{...m,key:g},y.jsx(ue,{variant:"body2",sx:{flex:1},children:g}),f.get(g)&&y.jsx(ue,{variant:"caption",sx:{opacity:.6},children:f.get(g)?.replace(/_type$/,"")})),renderInput:m=>y.jsx(et,{...m,label:i,placeholder:l,autoFocus:u,error:o,helperText:a,inputProps:{...m.inputProps,"aria-label":s}}),sx:d})}const ll=e=>e&&be(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this dashboard does not write."};function tp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:c}=Qe(),{editing:u,shown:l,fromModel:d,source:h,setSource:f,label:m,setLabel:g,kind:x,dateDefault:w,setDateDefault:p,field:v,rows:b,setRows:k,perTile:D,setPerTile:M,newName:A,target:$,valueTyped:O,commonOp:z,setRow:I,setCommonOp:W,pickExisting:G,pickKind:q,bindable:U,bindableCount:K,included:V,commonFields:re,setAll:T,accepts:_,pickField:R,rowProblems:N,commonProblem:F,canApply:ee,apply:J}=ep({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),C=(j,E,Z)=>y.jsx(et,{select:!0,size:"small",label:"Compares",value:j??">=",onChange:B=>E(B.target.value),inputProps:{"aria-label":Z},sx:{width:130},children:Yh.filter(B=>B.op!=="~").map(B=>y.jsx(Nt,{value:B.op,children:B.label},B.op))});return y.jsx(es,{open:e,onClose:s,title:u?l.label??l.name:"Add a filter",description:u?y.jsxs(y.Fragment,{children:[y.jsxs(Ae,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",l.name]}),d?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A filter on the page, and the tiles it filters.",actions:y.jsxs(y.Fragment,{children:[u&&y.jsx(Ee,{color:"error",startIcon:y.jsx(Mc,{}),onClick:()=>a(l.name),sx:j=>({mr:"auto",color:Tc(j)}),children:"Remove filter"}),y.jsx(Ee,{onClick:s,children:"Cancel"}),y.jsx(en,{title:ee||$===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(Ee,{variant:"contained",onClick:J,disabled:!ee,children:u?"Apply":"Add filter"})})})]}),children:y.jsxs(xe,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&y.jsxs(Dc,{exclusive:!0,size:"small",value:h.kind,onChange:(j,E)=>{E==="new"?f({kind:"new"}):E==="existing"&&r[0]&&G(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(Ti,{value:"new",children:"New in this dashboard"}),y.jsx(Ti,{value:"existing",children:"From the model"})]}),!u&&h.kind==="existing"?y.jsx(et,{select:!0,size:"small",label:"Filter",value:h.name,onChange:j=>{const E=r.find(Z=>Z.name===j.target.value);E&&G(E)},children:r.map(j=>y.jsxs(Nt,{value:j.name,children:[j.label??j.name,y.jsxs(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",j.name]})]},j.name))}):null,y.jsxs(xe,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!D&&y.jsx(al,{value:v,onChange:R,fields:re,accepts:_,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:F!==void 0,helperText:F??(!u&&A?`Declared as $${A}`:void 0),sx:{flex:1,minWidth:200}}),!d&&y.jsx(et,{size:"small",label:"Label",placeholder:A?Ic(A):"",value:m,onChange:j=>g(j.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),O&&!D&&C(z,W,"Comparison")]}),!u&&h.kind==="new"&&y.jsxs(xe,{direction:"row",sx:{gap:1.5},children:[y.jsx(et,{select:!0,size:"small",label:"Filter kind",value:x,onChange:j=>q(j.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:j=>ol.find(E=>E.kind===j)?.label??String(j)}},sx:{flex:1},children:ol.map(j=>y.jsxs(Nt,{value:j.kind,children:[j.label,y.jsx(ue,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:j.hint})]},j.kind))}),x==="date"&&y.jsx(et,{size:"small",type:"date",label:"Starts at",value:w,onChange:j=>p(j.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(Ae,{children:[y.jsxs(xe,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(Gs,{size:"small",checked:K>0&&V===K,indeterminate:V>0&&V<K,disabled:K===0,onChange:j=>T(j.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(ue,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",V," of ",t.tiles.length," tiles"]}),y.jsx(Ee,{size:"small",onClick:()=>{D||k(j=>j.map(E=>({...E,field:v}))),M(j=>!j)},children:D?"Same field for all":"Adjust per tile"})]}),y.jsx(xe,{sx:{gap:D?1:0},children:t.tiles.map((j,E)=>{if(!be(j))return null;const Z=b[E],B=j.label??j.name,te=D?N[E]:void 0;return y.jsxs(xe,{direction:"row",sx:{gap:1,alignItems:D?"flex-start":"center",opacity:U[E]?1:.6},children:[y.jsx(Gs,{size:"small",disabled:!U[E],checked:(Z?.include??!1)&&U[E],inputProps:{"aria-label":`Filter ${B}`},onChange:X=>I(E,{include:X.target.checked})}),y.jsx(ue,{variant:"body2",sx:{flex:1,minWidth:0,pt:D?1:0},noWrap:!0,children:B}),U[E]?D&&y.jsxs(y.Fragment,{children:[O&&C(Z?.op,X=>I(E,{op:X}),`Comparison for ${B}`),y.jsx(al,{value:Z?.field??"",onChange:X=>I(E,{field:X}),fields:i?.(j),accepts:_,label:"Field",ariaLabel:`Field for ${B}`,disabled:!Z?.include,error:te!==void 0,helperText:te,sx:{width:220}})]}):y.jsx(en,{title:ll(t.tiles[E]).reason,children:y.jsx(ue,{variant:"caption",sx:{color:c.tileTitle},children:ll(t.tiles[E]).label})})]},`${j.source}.${j.name}`)})}),V===0&&y.jsx(ue,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}const np=Rr(y.jsx("path",{d:"M11.71 17.99C8.53 17.84 6 15.22 6 12c0-3.31 2.69-6 6-6 3.22 0 5.84 2.53 5.99 5.71l-2.1-.63C15.48 9.31 13.89 8 12 8c-2.21 0-4 1.79-4 4 0 1.89 1.31 3.48 3.08 3.89zM22 12c0 .3-.01.6-.04.9l-1.97-.59c.01-.1.01-.21.01-.31 0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8c.1 0 .21 0 .31-.01l.59 1.97c-.3.03-.6.04-.9.04-5.52 0-10-4.48-10-10S6.48 2 12 2s10 4.48 10 10m-3.77 4.26L22 15l-10-3 3 10 1.26-3.77 4.27 4.27 1.98-1.98z"}));function Pc(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const c=structuredClone(a);return o(c),c}),apply:o=>{if(i===void 0)return;const a=structuredClone(i);o(a),s(a),JSON.stringify(a)!==JSON.stringify(e)&&n(a)},close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const rp=e=>e&&e.length===1?`This tile's chart line (${e[0]}) is not one the builder models, so its chart cannot be changed here.`:`This tile has ${e?.length??"several"} chart lines${e?` (${e.join(" and ")})`:""}, so its chart cannot be changed here.`,ip="This tile's view is declared on its source, so its chart is set in the model.";function sp({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,removeBlocked:s,onDrills:o,view:a}){const c=S.useId(),{theme:u}=Qe(),{draft:l,apply:d,close:h,discard:f}=Pc(t,e!==null,r,n),m=l!==void 0&&be(l)?l:void 0,g=m!==void 0&&m.declaration.kind!=="inherited",x=v=>d(b=>{be(b)&&v(b)}),w=S.useRef(void 0),p=e!==null;return S.useEffect(()=>{p&&(w.current=t&&be(t)?t.chart:void 0)},[p]),y.jsx($h,{open:e!==null&&l!==void 0,anchorEl:e,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:l&&y.jsxs(xe,{sx:{gap:1.5},children:[y.jsx(ue,{variant:"overline",sx:{color:u.tileTitle,lineHeight:1.5},children:m?`${m.source} → ${m.name}`:`Text · ${l.name}`}),m&&g&&y.jsx(y.Fragment,{children:y.jsx(Ks,{state:m.chart??"default",view:a,cellLabel:`${m.source} ${m.name}`,...m.chart==="custom"?{disabledReason:rp(m.chartLines)}:{},onChange:v=>x(b=>{const k=w.current;v===(k??"default")?(k===void 0?delete b.chart:b.chart=k,delete b.chartCarried):(b.chart=v,a?b.chartCarried=a.chart?[a.chart]:[]:delete b.chartCarried)})})}),m&&!g&&y.jsxs(y.Fragment,{children:[y.jsx(ue,{variant:"body2",sx:{color:u.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),y.jsx(Ks,{state:"default",view:a,cellLabel:`${m.source} ${m.name}`,disabledReason:ip,onChange:()=>{}})]}),m?.declaration.kind==="opaque"&&y.jsxs(ue,{variant:"body2",sx:{color:u.tileTitle},children:["Its body is ",m.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),y.jsxs(xe,{direction:"row",sx:{justifyContent:"space-between"},children:[g?y.jsx(Ee,{size:"small",startIcon:y.jsx(np,{}),"aria-haspopup":"dialog",onClick:()=>{h(),o()},children:"Drill"}):y.jsx("span",{}),y.jsx(Ee,{color:"error",size:"small",startIcon:y.jsx(Mc,{}),"aria-disabled":s!==void 0||void 0,"aria-describedby":s!==void 0?c:void 0,disableRipple:s!==void 0,sx:v=>({color:Tc(v),...s!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{s===void 0&&(f(),i())},children:"Delete"})]}),s!==void 0&&y.jsx(ue,{id:c,variant:"caption",sx:{color:u.tileTitle},children:s})]})})}function op({editor:e,catalog:t,columns:n,dashboards:r,bindings:i,tiles:s,drillSource:o,setDrillSource:a,confirmConversion:c,exitDialog:u}){const{filterDialog:l,setFilterDialog:d}=i,{menu:h,setMenu:f}=s,m=h===void 0?void 0:e.document.tiles[h.index],g=m&&be(m)?m:void 0,x=(()=>{if(!g||!t)return;const w=e.document.sources.find(v=>v.name===g.source)?.base??g.source,p=g.declaration.kind==="reference"?g.declaration.from:g.name;return t.sources.find(v=>v.name===w)?.views.find(v=>v.name===p)})();return y.jsxs(y.Fragment,{children:[y.jsx(tp,{open:l!==void 0,document:e.document,...l?.control?{control:l.control}:{},available:i.available,...t?{fieldsFor:i.fieldsFor}:{},onClose:()=>d(void 0),onApply:i.applyFilter,onRemove:i.dropControl}),y.jsx(sp,{anchor:h?.anchor??null,tile:h===void 0?void 0:e.document.tiles[h.index],onClose:()=>f(void 0),onCommit:w=>{const p=h?.index;p!==void 0&&e.update(v=>{v.tiles[p]=w})},onRemove:()=>{h!==void 0&&s.removeTile(h.index)},...e.document.tiles.length===1&&e.saved.tiles.length>0?{removeBlocked:"A saved dashboard needs at least one tile."}:{},view:x,onDrills:()=>{a(g?.source)}}),y.jsx(Hh,{open:o!==void 0,document:e.document,source:e.document.sources.find(w=>w.name===o),givenNames:i.controlList.map(w=>w.name),dashboards:r??[],onClose:()=>a(void 0),onApply:w=>e.update(p=>{const v=[...(p.drills??[]).filter(b=>b.source!==o),...w];v.length===0?delete p.drills:p.drills=v})}),y.jsx(es,{open:c!==void 0,onClose:()=>c?.stop(),title:"Convert this notebook?",description:"Saving rewrites this notebook in the tile layout. The builder cannot take that back; the file's history in your repository can.",actions:y.jsxs(y.Fragment,{children:[y.jsx(Ee,{onClick:()=>c?.stop(),children:"Cancel"}),y.jsx(Ee,{variant:"contained",onClick:()=>c?.go(),children:"Convert and save"})]}),children:null}),y.jsx(ih,{...u}),y.jsx(Bh,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText})]})}var ap=Symbol.for("preact-signals");function ns(){if(St>1)St--;else{var e,t=!1;for((function(){var i=Di;for(Di=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();gr!==void 0;){var n=gr;for(gr=void 0,Ai++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Lc(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(Ai=0,St--,t)throw e}}function je(e){if(St>0)return e();Xs=++lp,St++;try{return e()}finally{ns()}}var mr,ye=void 0;function le(e){var t=ye,n=mr;ye=void 0,mr=void 0;try{return e()}finally{ye=t,mr=n}}var gr=void 0,St=0,Ai=0,lp=0,Xs=0,Di=void 0,Ii=0;function Rc(e){if(ye!==void 0){var t=e.n;if(t===void 0||t.t!==ye)return t={i:0,S:e,p:ye.s,n:void 0,t:ye,e:void 0,x:void 0,r:t},ye.s!==void 0&&(ye.s.n=t),ye.s=t,e.n=t,32&ye.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ye.s,t.n=void 0,ye.s.n=t,ye.s=t),t}}function Ge(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Ge.prototype.brand=ap;Ge.prototype.h=function(){return!0};Ge.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:le(function(){var r;(r=t.W)==null||r.call(t)}))};Ge.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&le(function(){var i;(i=t.Z)==null||i.call(t)}))}};Ge.prototype.subscribe=function(e){var t=this;return ot(function(){var n=t.value;le(function(){return e(n)})},{name:"sub"})};Ge.prototype.valueOf=function(){return this.value};Ge.prototype.toString=function(){return this.value+""};Ge.prototype.toJSON=function(){return this.value};Ge.prototype.peek=function(){var e=this;return le(function(){return e.value})};Object.defineProperty(Ge.prototype,"value",{get:function(){var e=Rc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ai>100)throw new Error("Cycle detected");(function(n){St!==0&&Ai===0&&n.l!==Xs&&(n.l=Xs,Di={S:n,v:n.v,i:n.i,o:Di})})(this),this.v=e,this.i++,Ii++,St++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ns()}}}});function Ln(e,t){return new Ge(e,t)}function Lc(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Nc(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Wc(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function sn(e,t){Ge.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Ii-1,this.f=4}sn.prototype=new Ge;sn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ii))return!0;if(this.g=Ii,this.f|=1,this.i>0&&!Lc(this))return this.f&=-2,!0;var e=ye;try{Nc(this),ye=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ye=e,Wc(this),this.f&=-2,!0};sn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Ge.prototype.S.call(this,e)};sn.prototype.U=function(e){if(this.t!==void 0&&(Ge.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};sn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(sn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Rc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function cl(e,t){return new sn(e,t)}function zc(e){var t=e.m;if(e.m=void 0,typeof t=="function"){St++;var n=ye;ye=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ho(e),r}finally{ye=n,ns()}}}function Ho(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,zc(e)}function cp(e){if(ye!==this)throw new Error("Out-of-order effect");Wc(this),ye=e,this.f&=-2,8&this.f&&Ho(this),ns()}function Nn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,mr&&mr.push(this)}Nn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Nn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,zc(this),Nc(this),St++;var e=ye;return ye=this,cp.bind(this,e)};Nn.prototype.N=function(){2&this.f||(this.f|=2,this.u=gr,gr=this)};Nn.prototype.d=function(){this.f|=8,1&this.f||Ho(this)};Nn.prototype.dispose=function(){this.d()};function ot(e,t){var n=new Nn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var dp=Object.create,Uo=Object.defineProperty,up=Object.defineProperties,fp=Object.getOwnPropertyDescriptor,hp=Object.getOwnPropertyDescriptors,dl=Object.getOwnPropertySymbols,pp=Object.prototype.hasOwnProperty,mp=Object.prototype.propertyIsEnumerable,gp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Wn=e=>{throw TypeError(e)},Vs=(e,t,n)=>t in e?Uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vp=(e,t)=>{for(var n in t||(t={}))pp.call(t,n)&&Vs(e,n,t[n]);if(dl)for(var n of dl(t))mp.call(t,n)&&Vs(e,n,t[n]);return e},bp=(e,t)=>up(e,hp(t)),ul=(e,t)=>Uo(e,"name",{value:t,configurable:!0}),yp=e=>{var t;return[,,,dp((t=void 0)!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],Jn=e=>e!==void 0&&typeof e!="function"?Wn("Function expected"):e,xp=(e,t,n,r,i)=>({kind:Fc[e],name:t,metadata:r,addInitializer:s=>n._?Wn("Already initialized"):i.push(Jn(s||null))}),_c=(e,t)=>Vs(t,gp("metadata"),e[3]),qt=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},zn=(e,t,n,r,i,s)=>{var o,a,c,u,l,d=t&7,h=!!(t&8),f=!!(t&16),m=d>3?e.length+1:d?h?1:2:0,g=Fc[d+5],x=d>3&&(e[m-1]=[]),w=e[m]||(e[m]=[]),p=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&fp(d<4?i:{get[n](){return tt(this,s)},set[n](b){return At(this,s,b)}},n));d?f&&d<4&&ul(s,(d>2?"set ":d>1?"get ":"")+n):ul(i,n);for(var v=r.length-1;v>=0;v--)u=xp(d,n,c={},e[3],w),d&&(u.static=h,u.private=f,l=u.access={has:f?b=>wp(i,b):b=>n in b},d^3&&(l.get=f?b=>(d^1?tt:kp)(b,i,d^4?s:p.get):b=>b[n]),d>2&&(l.set=f?(b,k)=>At(b,i,k,d^4?s:p.set):(b,k)=>b[n]=k)),a=(0,r[v])(d?d<4?f?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),c._=1,d^4||a===void 0?Jn(a)&&(d>4?x.unshift(a):d?f?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Wn("Object expected"):(Jn(o=a.get)&&(p.get=o),Jn(o=a.set)&&(p.set=o),Jn(o=a.init)&&x.unshift(o));return d||_c(e,i),p&&Uo(i,n,p),f?d^4?s:p:i},Go=(e,t,n)=>t.has(e)||Wn("Cannot "+n),wp=(e,t)=>Object(t)!==t?Wn('Cannot use the "in" operator on this value'):e.has(t),tt=(e,t,n)=>(Go(e,t,"read from private field"),n?n.call(e):t.get(e)),er=(e,t,n)=>t.has(e)?Wn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),At=(e,t,n,r)=>(Go(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),kp=(e,t,n)=>(Go(e,t,"access private method"),n);function Zs(e,t){if(t){let n;return cl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return cl(e)}function ct(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((n,r)=>!ct(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!ct(e[i],t[i]))}return!1}function ce({get:e},t){return{init(n){return Ln(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Oe(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Zs(e.bind(this)),n.set(this,r)),r.value}}function ks(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),i=Object.getOwnPropertyDescriptor(r,n.name);i&&Object.defineProperty(r,n.name,bp(vp({},i),{enumerable:e}))})}}function Lr(...e){const t=e.map(n=>ot(n));return()=>t.forEach(n=>n())}var qc,Bc,Hc,Uc,Gc,Kc,Be,Ko,Ss,Qs,Js,_e,Yo,$s,Yc,eo,Xo,js,to,no;Kc=[ce],Gc=[ce],Uc=[ce],Hc=[ks()],Bc=[ks()],qc=[ks()];var on=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,qt(Be,5,this),er(this,_e),er(this,Ko,qt(Be,8,this)),qt(Be,11,this),er(this,Yo,qt(Be,12,this)),qt(Be,15,this),er(this,Xo,qt(Be,16,this)),qt(Be,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return tt(this,_e,to)}get initial(){return tt(this,_e,Qs)}get previous(){return tt(this,_e,Yc)}set current(e){const t=le(()=>tt(this,_e,to));e&&t&&this.equals(t,e)||je(()=>{tt(this,_e,Qs)||At(this,_e,e,Js),At(this,_e,t,eo),At(this,_e,e,no)})}reset(e=this.defaultValue){je(()=>{At(this,_e,void 0,eo),At(this,_e,e,Js),At(this,_e,e,no)})}};Be=yp();Ko=new WeakMap;_e=new WeakSet;Yo=new WeakMap;Xo=new WeakMap;Ss=zn(Be,20,"#initial",Kc,_e,Ko),Qs=Ss.get,Js=Ss.set;$s=zn(Be,20,"#previous",Gc,_e,Yo),Yc=$s.get,eo=$s.set;js=zn(Be,20,"#current",Uc,_e,Xo),to=js.get,no=js.set;zn(Be,2,"current",Hc,on);zn(Be,2,"initial",Bc,on);zn(Be,2,"previous",qc,on);_c(Be,on);function Cs(e){return le(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Ht,Sp=class{constructor(){er(this,Ht,new WeakMap)}get(e,t){var n;return e?(n=tt(this,Ht).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return tt(this,Ht).has(e)||tt(this,Ht).set(e,new Map),(r=tt(this,Ht).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=tt(this,Ht).get(e))==null?void 0:t.clear():void 0}};Ht=new WeakMap;var $p=Object.create,Xc=Object.defineProperty,jp=Object.getOwnPropertyDescriptor,fl=Object.getOwnPropertySymbols,Cp=Object.prototype.hasOwnProperty,Op=Object.prototype.propertyIsEnumerable,Vc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),rs=e=>{throw TypeError(e)},hl=Math.pow,ro=(e,t,n)=>t in e?Xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ep=(e,t)=>{for(var n in t||(t={}))Cp.call(t,n)&&ro(e,n,t[n]);if(fl)for(var n of fl(t))Op.call(t,n)&&ro(e,n,t[n]);return e},Tp=e=>{var t;return[,,,$p((t=e?.[Vc("metadata")])!=null?t:null)]},Zc=["class","method","getter","setter","accessor","field","value","get","set"],Qc=e=>e!==void 0&&typeof e!="function"?rs("Function expected"):e,Mp=(e,t,n,r,i)=>({kind:Zc[e],name:t,metadata:r,addInitializer:s=>n._?rs("Already initialized"):i.push(Qc(s||null))}),Ap=(e,t)=>ro(t,Vc("metadata"),e[3]),Dp=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},Jc=(e,t,n,r,i,s)=>{for(var o,a,c,u,l=t&7,d=!1,h=!1,f=2,m=Zc[l+5],g=e[f]||(e[f]=[]),x=(i=i.prototype,jp(i,n)),w=r.length-1;w>=0;w--)c=Mp(l,n,a={},e[3],g),c.static=d,c.private=h,u=c.access={has:p=>n in p},u.get=p=>p[n],o=(0,r[w])(x[m],c),a._=1,Qc(o)&&(x[m]=o);return x&&Xc(i,n,x),i},ed=(e,t,n)=>t.has(e)||rs("Cannot "+n),Ip=(e,t,n)=>(ed(e,t,"read from private field"),t.get(e)),Pp=(e,t,n)=>t.has(e)?rs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Rp=(e,t,n,r)=>(ed(e,t,"write to private field"),t.set(e,n),n),nt=class io{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new io(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new io(t,n)}},gt=class Ut{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,c=new Ut(i+t,r+n,s,o);return c.scale=Ep({},a),c}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new nt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ut))return!1;const{left:n,top:r,width:i,height:s}=this;return n===t.left&&r===t.top&&i===t.width&&s===t.height}containsPoint(t){const{top:n,left:r,bottom:i,right:s}=this;return n<=t.y&&t.y<=i&&r<=t.x&&t.x<=s}intersectionArea(t){return t instanceof Ut?Lp(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new Ut(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],c=o==="x"?s.left:s.top,u=o==="x"?s.width:s.height;return a=="start"?c:a=="end"?c+u:c+u/2};return nt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Ut.from(t).intersectionRatio(Ut.from(n))}};function Lp(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;return r<i&&n<s?o*a:0}var td,nd,so,pi,Nr,is=class extends(so=on,nd=[Oe],td=[Oe],so){constructor(e){const t=nt.from(e);super(t,(n,r)=>nt.equals(n,r)),Dp(Nr,5,this),Pp(this,pi,0),this.velocity={x:0,y:0}}get delta(){return nt.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=nt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Ip(this,pi),o=a=>Math.round(a/s*100);je(()=>{Rp(this,pi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(nt.from(e)),this.velocity={x:0,y:0}}};Nr=Tp(so);pi=new WeakMap;Jc(Nr,2,"delta",nd,is);Jc(Nr,2,"direction",td,is);Ap(Nr,is);function oo({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(hl(r,2)+hl(i,2))>n:"x"in n&&"y"in n?r>n.x&&i>n.y:"x"in n?r>n.x:"y"in n?i>n.y:!1}var rd=(e=>(e.Horizontal="x",e.Vertical="y",e))(rd||{}),id=Object.values(rd),Np=Object.create,Vo=Object.defineProperty,Wp=Object.defineProperties,zp=Object.getOwnPropertyDescriptor,Fp=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,sd=Object.prototype.hasOwnProperty,od=Object.prototype.propertyIsEnumerable,ad=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Fn=e=>{throw TypeError(e)},ao=(e,t,n)=>t in e?Vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zo=(e,t)=>{for(var n in t||(t={}))sd.call(t,n)&&ao(e,n,t[n]);if(Pi)for(var n of Pi(t))od.call(t,n)&&ao(e,n,t[n]);return e},Qo=(e,t)=>Wp(e,Fp(t)),pl=(e,t)=>Vo(e,"name",{value:t,configurable:!0}),ld=(e,t)=>{var n={};for(var r in e)sd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Pi)for(var r of Pi(e))t.indexOf(r)<0&&od.call(e,r)&&(n[r]=e[r]);return n},_n=e=>{var t;return[,,,Np((t=e?.[ad("metadata")])!=null?t:null)]},cd=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?Fn("Function expected"):e,_p=(e,t,n,r,i)=>({kind:cd[e],name:t,metadata:r,addInitializer:s=>n._?Fn("Already initialized"):i.push(tr(s||null))}),an=(e,t)=>ao(t,ad("metadata"),e[3]),se=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},de=(e,t,n,r,i,s)=>{var o,a,c,u,l,d=t&7,h=!!(t&8),f=!!(t&16),m=d>3?e.length+1:d?h?1:2:0,g=cd[d+5],x=d>3&&(e[m-1]=[]),w=e[m]||(e[m]=[]),p=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&zp(d<4?i:{get[n](){return Ce(this,s)},set[n](b){return Ze(this,s,b)}},n));d?f&&d<4&&pl(s,(d>2?"set ":d>1?"get ":"")+n):pl(i,n);for(var v=r.length-1;v>=0;v--)u=_p(d,n,c={},e[3],w),d&&(u.static=h,u.private=f,l=u.access={has:f?b=>qp(i,b):b=>n in b},d^3&&(l.get=f?b=>(d^1?Ce:dd)(b,i,d^4?s:p.get):b=>b[n]),d>2&&(l.set=f?(b,k)=>Ze(b,i,k,d^4?s:p.set):(b,k)=>b[n]=k)),a=(0,r[v])(d?d<4?f?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),c._=1,d^4||a===void 0?tr(a)&&(d>4?x.unshift(a):d?f?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Fn("Object expected"):(tr(o=a.get)&&(p.get=o),tr(o=a.set)&&(p.set=o),tr(o=a.init)&&x.unshift(o));return d||an(e,i),p&&Vo(i,n,p),f?d^4?s:p:i},Jo=(e,t,n)=>t.has(e)||Fn("Cannot "+n),qp=(e,t)=>Object(t)!==t?Fn('Cannot use the "in" operator on this value'):e.has(t),Ce=(e,t,n)=>(Jo(e,t,"read from private field"),n?n.call(e):t.get(e)),he=(e,t,n)=>t.has(e)?Fn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ze=(e,t,n,r)=>(Jo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),dd=(e,t,n)=>(Jo(e,t,"access private method"),n);function ud(e,t){return{plugin:e,options:t}}function Wr(e){return t=>ud(e,t)}function kr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var fd,Sr,ea,mi;fd=[ce];var qe=class{constructor(e,t){this.manager=e,this.options=t,he(this,ea,se(Sr,8,this,!1)),se(Sr,11,this),he(this,mi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return le(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=ot(e.bind(this));return Ce(this,mi).add(t),t}destroy(){Ce(this,mi).forEach(e=>e())}static configure(e){return ud(this,e)}};Sr=_n(null);ea=new WeakMap;mi=new WeakMap;de(Sr,4,"disabled",fd,qe,ea);an(Sr,qe);var zr=class extends qe{},gi,Os=class{constructor(e){this.manager=e,this.instances=new Map,he(this,gi,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(kr).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of Ce(this,gi))if(!n.includes(r)){if(r.prototype instanceof zr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);Ze(this,gi,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};gi=new WeakMap;function Bp(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Qr=[],gn,vn,Hp=class extends qe{constructor(e){super(e),he(this,gn),he(this,vn),this.computeCollisions=this.computeCollisions.bind(this),Ze(this,vn,Ln(Qr)),this.destroy=Lr(()=>{const t=this.computeCollisions(),n=le(()=>this.manager.dragOperation.position.current);if(t!==Qr){const r=Ce(this,gn);if(Ze(this,gn,n),r&&n.x==r.x&&n.y==r.y)return}else Ze(this,gn,void 0);Ce(this,vn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){le(()=>{e?Ce(this,vn).value=this.computeCollisions():Ze(this,gn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Qr;const a=[],c=[];for(const u of e??n.droppables){if(u.disabled||i&&!u.accepts(i))continue;const l=t??u.collisionDetector;if(!l)continue;c.push(u),u.shape;const d=le(()=>l({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return c.length===0?Qr:(a.sort(Bp),a)}get collisions(){return Ce(this,vn).value}};gn=new WeakMap;vn=new WeakMap;var hd,pd,md,ta,gd,dt,na,Sn,ra,ia;md=[ce],pd=[ce],hd=[ce];var jt=class Gt{constructor(t,n){he(this,na,se(dt,8,this)),se(dt,11,this),he(this,Sn),he(this,ra,se(dt,12,this)),se(dt,15,this),he(this,ia,se(dt,16,this)),se(dt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let c=i;Ze(this,Sn,Ln(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var u;return[()=>{const{id:l,manager:d}=this;if(l!==c)return c=l,d?.registry.register(this),()=>d?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=Ce(this,Sn).value;return(n=(t=Gt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=Gt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Ce(this,Sn).peek();t!==i&&(Gt.pendingIdChanges||(Gt.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return dd(s=Gt,ta,gd).call(s)})),Gt.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};dt=_n(null);ta=new WeakSet;gd=function(){const e=jt.pendingIdChanges;jt.pendingIdChanges=null,e&&je(()=>{for(const[t,n]of e)Ce(t,Sn).value=n})};na=new WeakMap;Sn=new WeakMap;ra=new WeakMap;ia=new WeakMap;de(dt,4,"manager",md,jt,na);de(dt,4,"data",pd,jt,ra);de(dt,4,"disabled",hd,jt,ia);he(jt,ta);an(dt,jt);jt.pendingIdChanges=null;var ss=jt,ml=class{constructor(){this.map=Ln(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,c]of n)if(c===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=Lr(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},vd,bd,yd,xd,wd,kd,lo,He,sa,oa,aa,vt=class extends(lo=ss,kd=[ce],wd=[ce],xd=[ce],yd=[Oe],bd=[Oe],vd=[Oe],lo){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,c=ld(n,["modifiers","type","sensors","plugins","effects"]);super(Qo(Zo({},c),{effects:()=>{var u;return[...(u=a?.())!=null?u:[],()=>{const{manager:l,plugins:d}=this;if(!(!l||!d))for(const h of d){const{plugin:f}=kr(h);l.registry.plugins.register(f)}}]}}),t),se(He,5,this),he(this,sa,se(He,8,this)),se(He,11,this),he(this,oa,se(He,12,this)),se(He,15,this),he(this,aa,se(He,16,this,this.isDragSource?"dragging":"idle")),se(He,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=c.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=kr(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.source)==null?void 0:t.id)===this.id}};He=_n(lo);sa=new WeakMap;oa=new WeakMap;aa=new WeakMap;de(He,4,"type",kd,vt,sa);de(He,4,"modifiers",wd,vt,oa);de(He,4,"status",xd,vt,aa);de(He,2,"isDropping",yd,vt);de(He,2,"isDragging",bd,vt);de(He,2,"isDragSource",vd,vt);an(He,vt);var Sd,$d,jd,Cd,Od,Ed,co,Ie,la,ca,da,ua,fa,bt=class extends(co=ss,Ed=[ce],Od=[ce],Cd=[ce],jd=[ce],$d=[ce],Sd=[Oe],co){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=ld(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),se(Ie,5,this),he(this,la,se(Ie,8,this)),se(Ie,11,this),he(this,ca,se(Ie,12,this)),se(Ie,15,this),he(this,da,se(Ie,16,this)),se(Ie,19,this),he(this,ua,se(Ie,20,this)),se(Ie,23,this),he(this,fa,se(Ie,24,this)),se(Ie,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=s,this.type=o}accepts(e){const{accept:t}=this;return t?typeof t=="function"?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.target)==null?void 0:t.id)===this.id}};Ie=_n(co);la=new WeakMap;ca=new WeakMap;da=new WeakMap;ua=new WeakMap;fa=new WeakMap;de(Ie,4,"accept",Ed,bt,la);de(Ie,4,"type",Od,bt,ca);de(Ie,4,"collisionDetector",Cd,bt,da);de(Ie,4,"collisionPriority",jd,bt,ua);de(Ie,4,"shape",$d,bt,fa);de(Ie,2,"isDropTarget",Sd,bt);an(Ie,bt);var Up=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const i of r)i(...t)}},Gp=class extends Up{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function vi(e,t=!0){let n=!1;return Qo(Zo({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Kp=class extends zr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=Lr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||ss.pendingIdChanges)return;const o=vi({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;le(()=>{var c;a?.id!==((c=e.dragOperation.target)==null?void 0:c.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},qn=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(qn||{}),Bn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Bn||{}),Td,Md,Ad,Dd,Id,Pd,Rd,st,ha;Rd=[ce],Pd=[Oe],Id=[Oe],Dd=[Oe],Ad=[Oe],Md=[Oe],Td=[Oe];var Ot=class{constructor(){se(st,5,this),he(this,ha,se(st,8,this,"idle")),se(st,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};st=_n(null);ha=new WeakMap;de(st,4,"value",Rd,Ot,ha);de(st,2,"current",Pd,Ot);de(st,2,"idle",Id,Ot);de(st,2,"initializing",Dd,Ot);de(st,2,"initialized",Ad,Ot);de(st,2,"dragging",Md,Ot);de(st,2,"dropped",Td,Ot);an(st,Ot);var Yp=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return le(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=vi({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return le(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const n=new AbortController,{event:r,coordinates:i}=e;je(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=vi({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",s),s.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set("initializing"),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;const{status:o}=t;o.current==="initializing"&&je(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return le(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=vi({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,c,u,l,d;if(o.defaultPrevented)return;const h=(d=e.to)!=null?d:{x:r.position.current.x+((c=(a=e.by)==null?void 0:a.x)!=null?c:0),y:r.position.current.y+((l=(u=e.by)==null?void 0:u.y)!=null?l:0)};r.position.current=h})})}stop(e={}){return le(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const c={resume:()=>{},abort:()=>{}};return s=new Promise((u,l)=>{c.resume=u,c.abort=l}),c};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const c=le(()=>{var l;return((l=r.source)==null?void 0:l.status)==="dropping"}),u=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(c){const{source:l}=r,d=ot(()=>{l?.status==="idle"&&(d(),u())})}else this.manager.renderer.rendering.then(u)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),s?s.then(a).catch(()=>r.reset()):a()})}},Mn=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Xp=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},bi,Ld=class{constructor(e){this.options=e,he(this,bi)}set controller(e){Ze(this,bi,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ce(this,bi))==null||t.activate(e)}};bi=new WeakMap;var gl=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Vp=class{constructor(e){this.draggables=new ml,this.droppables=new ml,this.plugins=new Os(e),this.sensors=new Os(e),this.modifiers=new Os(e)}register(e,t){if(e instanceof vt)return this.draggables.register(e.id,e);if(e instanceof bt)return this.droppables.register(e.id,e);if(e.prototype instanceof gl)return this.modifiers.register(e,t);if(e.prototype instanceof Mn)return this.sensors.register(e,t);if(e.prototype instanceof qe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof ss)return e instanceof vt?this.draggables.unregister(e.id,e):e instanceof bt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof gl)return this.modifiers.unregister(e);if(e.prototype instanceof Mn)return this.sensors.unregister(e);if(e.prototype instanceof qe)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Nd,Wd,zd,Fd,_d,qd,Bd,Hd,Ud,nr,yi,bn,$e,pa,ma,ga,va,ba,rr;Ud=[Oe],Hd=[ce],Bd=[ce],qd=[ce],_d=[ce],Fd=[ce],zd=[Oe],Wd=[Oe],Nd=[Oe];var ht=class{constructor(e){se($e,5,this),he(this,nr),he(this,yi),he(this,bn,new on(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Ot,he(this,pa,se($e,8,this,!1)),se($e,11,this),he(this,ma,se($e,12,this,null)),se($e,15,this),he(this,ga,se($e,16,this,null)),se($e,19,this),he(this,va,se($e,20,this,null)),se($e,23,this),he(this,ba,se($e,24,this,[])),se($e,27,this),this.position=new is({x:0,y:0}),he(this,rr,{x:0,y:0}),Ze(this,nr,e)}get shape(){const{current:e,initial:t,previous:n}=Ce(this,bn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ce(this,bn).current=e:Ce(this,bn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ce(this,nr).registry.draggables.get(t);return n&&Ze(this,yi,n),(e=n??Ce(this,yi))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ce(this,nr).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(Qo(Zo({},this.snapshot()),{transform:n}));return Ze(this,rr,n),n}snapshot(){return le(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ce(this,rr),shape:this.shape?Cs(this.shape):null,position:Cs(this.position),status:Cs(this.status),canceled:this.canceled}))}reset(){je(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ce(this,bn).reset(),this.position.reset({x:0,y:0}),Ze(this,rr,{x:0,y:0}),this.modifiers=[]})}};$e=_n(null);nr=new WeakMap;yi=new WeakMap;bn=new WeakMap;pa=new WeakMap;ma=new WeakMap;ga=new WeakMap;va=new WeakMap;ba=new WeakMap;rr=new WeakMap;de($e,2,"shape",Ud,ht);de($e,4,"canceled",Hd,ht,pa);de($e,4,"activatorEvent",Bd,ht,ma);de($e,4,"sourceIdentifier",qd,ht,ga);de($e,4,"targetIdentifier",_d,ht,va);de($e,4,"modifiers",Fd,ht,ba);de($e,2,"source",zd,ht);de($e,2,"target",Wd,ht);de($e,2,"transform",Nd,ht);an($e,ht);var Zp={get rendering(){return Promise.resolve()}};function ft(e,t){return typeof e=="function"?e(t):e??t}var Qp=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(d=>d.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=ft(n.plugins,[]),i=ft(n.sensors,[]),s=ft(n.modifiers,[]),o=(t=n.renderer)!=null?t:Zp,a=new Gp(this),c=new Vp(this);this.registry=c,this.monitor=a,this.renderer=o,this.actions=new Yp(this),this.dragOperation=new ht(this),this.collisionObserver=new Hp(this),this.plugins=[Kp,...r],this.modifiers=s,this.sensors=i;const{destroy:u}=this,l=Lr(()=>{var d,h,f;const m=le(()=>this.dragOperation.modifiers),g=this.modifiers;for(const x of m)g.includes(x)||x.destroy();this.dragOperation.modifiers=(f=(h=(d=this.dragOperation.source)==null?void 0:d.modifiers)==null?void 0:h.map(x=>{const{plugin:w,options:p}=kr(x);return new w(this,p)}))!=null?f:g});this.destroy=()=>{l(),u()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Gd=e=>{throw TypeError(e)},ya=(e,t,n)=>t.has(e)||Gd("Cannot "+n),ie=(e,t,n)=>(ya(e,t,"read from private field"),t.get(e)),Ke=(e,t,n)=>t.has(e)?Gd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ve=(e,t,n,r)=>(ya(e,t,"write to private field"),t.set(e,n),n),Kd=(e,t,n)=>(ya(e,t,"access private method"),n);function os(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Yd(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(os(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function as(e){const{width:t,height:n,top:r,left:i,bottom:s,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:s,right:o}}function xa(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Fr(e){return"nodeType"in e}function Je(e){var t,n,r;return e?xa(e)?e:Fr(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function wa(e){const{Document:t}=Je(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function zt(e){return!e||xa(e)?!1:e instanceof Je(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Xd(e){return e instanceof Je(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Hn(e){return e?xa(e)?e.document:Fr(e)?wa(e)?e:zt(e)||Xd(e)?e.ownerDocument:document:document:document}function Jp(e){var t,n,r,i;const{documentElement:s}=Hn(e),o=Je(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,c=(n=o?.height)!=null?n:s.clientHeight,u=(r=o?.offsetTop)!=null?r:0,l=(i=o?.offsetLeft)!=null?i:0;return{top:u,left:l,right:l+a,bottom:u+c,width:a,height:c}}function em(e,t){if(tm(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function tm(e){return e.tagName==="DETAILS"}function $r(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let c=t;const{ownerDocument:u}=e,l=(r=u.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==u.documentElement;){if(!em(d)){const v=d.getBoundingClientRect(),b=n*(v.bottom-v.top),k=n*(v.right-v.left),D=n*(v.bottom-v.top),M=n*(v.right-v.left);c={top:Math.max(c.top,v.top-b),right:Math.min(c.right,v.right+k),bottom:Math.min(c.bottom,v.bottom+D),left:Math.max(c.left,v.left-M),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top}d=d.parentElement}const h=l.visualViewport,f=(i=h?.offsetTop)!=null?i:0,m=(s=h?.offsetLeft)!=null?s:0,g=(o=h?.width)!=null?o:l.innerWidth,x=(a=h?.height)!=null?a:l.innerHeight,w=n*x,p=n*g;return c={top:Math.max(c.top,f-w),right:Math.min(c.right,m+g+p),bottom:Math.min(c.bottom,f+x+w),left:Math.max(c.left,m-p),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top,c.width<0&&(c.width=0),c.height<0&&(c.height=0),c}function An(e){return{x:e.clientX,y:e.clientY}}var Vd=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function uo(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(...uo(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...uo(i.document,t))}}catch{}return n}function ka(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Zd(){var e,t;const n=ka()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Sa(e){return!e||!Fr(e)?!1:e instanceof Je(e).ShadowRoot}function Ri(e){if(e&&Fr(e)){let t=e.getRootNode();if(Sa(t)||t instanceof Document)return t}return Hn(e)}function $a(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function nm(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,s)=>{const o=r[s];vl(i)&&vl(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),bl(i)&&bl(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function vl(e){return"value"in e}function bl(e){return e.tagName==="CANVAS"}function Qd(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(rm(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Qd(i,{x:t-s,y:n-o})}}return r}function rm(e){return e?.tagName==="IFRAME"}var fo=new WeakMap;function im(e){return e.closest(`
2
- 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 Jd=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];for(const o of n)for(const a of r){const{type:c,listener:u,options:l}=a,d=[o,a];o.addEventListener(c,u,l),this.entries.add(d),i.push(d)}const s=this.entries;return function(){for(const o of i){const[a,{type:c,listener:u,options:l}]=o;a.removeEventListener(c,u,l),s.delete(o)}}}};function Dn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function sm(e){const t=new Set;let n=Dn(e);for(;n;)t.add(n),n=Dn(n);return t}function om(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function eu(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=om(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function am(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 lm(e,t=e.getBoundingClientRect()){const{width:n,height:r}=$r(e,t);return n>0&&r>0}var cm=Vd?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},xi,dm=class extends cm{constructor(e){super(t=>{if(!ie(this,xi)){Ve(this,xi,!0);return}e(t,this)}),Ke(this,xi,!1)}};xi=new WeakMap;var yl=Array.from({length:100},(e,t)=>t/100),tu=75,Kt,Li,Tt,Yt,ir,We,vr,sr,Ni,nu,ru,iu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ke(this,Ni),this.disconnect=()=>{var s,o,a;Ve(this,vr,!0),(s=ie(this,Tt))==null||s.disconnect(),(o=ie(this,Yt))==null||o.disconnect(),ie(this,ir).disconnect(),(a=ie(this,We))==null||a.remove()},Ke(this,Kt,!0),Ke(this,Li),Ke(this,Tt),Ke(this,Yt),Ke(this,ir),Ke(this,We),Ke(this,vr,!1),Ke(this,sr,eu(()=>{var s,o,a;const{element:c}=this;if((s=ie(this,Yt))==null||s.disconnect(),ie(this,vr)||!ie(this,Kt)||!c.isConnected)return;const u=(o=c.ownerDocument)!=null?o:document,{innerHeight:l,innerWidth:d}=(a=u.defaultView)!=null?a:window,h=c.getBoundingClientRect(),f=$r(c,h),{top:m,left:g,bottom:x,right:w}=f,p=-Math.floor(m),v=-Math.floor(g),b=-Math.floor(d-w),k=-Math.floor(l-x),D=`${p}px ${b}px ${k}px ${v}px`;this.boundingClientRect=h,Ve(this,Yt,new IntersectionObserver(M=>{const[A]=M,{intersectionRect:$}=A;(A.intersectionRatio!==1?A.intersectionRatio:gt.intersectionRatio($,$r(c)))!==1&&ie(this,sr).call(this)},{threshold:yl,rootMargin:D,root:u})),ie(this,Yt).observe(c),Kd(this,Ni,nu).call(this)},tu)),this.boundingClientRect=e.getBoundingClientRect(),Ve(this,Kt,lm(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(Ve(this,We,document.createElement("div")),ie(this,We).style.background="rgba(0,0,0,0.15)",ie(this,We).style.position="fixed",ie(this,We).style.pointerEvents="none",i.body.appendChild(ie(this,We))),Ve(this,ir,new IntersectionObserver(s=>{var o,a;const c=s[s.length-1],{boundingClientRect:u,isIntersecting:l}=c,{width:d,height:h}=u,f=ie(this,Kt);Ve(this,Kt,l),!(!d&&!h)&&(f&&!l?((o=ie(this,Yt))==null||o.disconnect(),this.callback(null),(a=ie(this,Tt))==null||a.disconnect(),Ve(this,Tt,void 0),ie(this,We)&&(ie(this,We).style.visibility="hidden")):ie(this,sr).call(this),l&&!ie(this,Tt)&&(Ve(this,Tt,new dm(ie(this,sr))),ie(this,Tt).observe(e)))},{threshold:yl,root:i})),ie(this,Kt)&&!n.skipInitial&&this.callback(this.boundingClientRect),ie(this,ir).observe(e)}};Kt=new WeakMap;Li=new WeakMap;Tt=new WeakMap;Yt=new WeakMap;ir=new WeakMap;We=new WeakMap;vr=new WeakMap;sr=new WeakMap;Ni=new WeakSet;nu=function(){ie(this,vr)||(Kd(this,Ni,ru).call(this),!am(this.boundingClientRect,ie(this,Li))&&(this.callback(this.boundingClientRect),Ve(this,Li,this.boundingClientRect)))};ru=function(){if(ie(this,We)){const{top:e,left:t,width:n,height:r}=$r(this.element);ie(this,We).style.overflow="hidden",ie(this,We).style.visibility="visible",ie(this,We).style.top=`${Math.floor(e)}px`,ie(this,We).style.left=`${Math.floor(t)}px`,ie(this,We).style.width=`${Math.floor(n)}px`,ie(this,We).style.height=`${Math.floor(r)}px`}};var Jr=new WeakMap,ei=new WeakMap;function um(e,t){let n=Jr.get(e);return n||(n={disconnect:new iu(e,r=>{const i=Jr.get(e);i&&i.callbacks.forEach(s=>s(r))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Jr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Jr.delete(e),n.disconnect())}}function fm(e,t){const n=new Set;for(const r of e){const i=um(r,t);n.add(i)}return()=>n.forEach(r=>r())}function hm(e,t){var n;const r=e.ownerDocument;if(!ei.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",c=>a.forEach(u=>u(c)),{capture:!0,passive:!0,signal:o.signal}),ei.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=ei.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),ei.delete(r))})}var or,ar,wi,ho,pm=class{constructor(e,t,n){this.callback=t,Ke(this,or),Ke(this,ar,!1),Ke(this,wi),Ke(this,ho,eu(o=>{if(!ie(this,ar)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of ie(this,wi))if(o.target.contains(a)){this.callback(ie(this,or).boundingClientRect);break}}},tu));const r=sm(e),i=fm(r,t),s=hm(e,ie(this,ho));Ve(this,wi,r),Ve(this,or,new iu(e,t,n)),this.disconnect=()=>{ie(this,ar)||(Ve(this,ar,!0),i(),s(),ie(this,or).disconnect())}}};or=new WeakMap;ar=new WeakMap;wi=new WeakMap;ho=new WeakMap;function po(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function Cn(e){try{po(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function xl(e){return!Vd||!e?!1:e===Hn(e).scrollingElement}function su(e){var t,n;const r=Je(e),i=xl(e)?Jp(e):as(e),s=r.visualViewport,o=xl(e)?{height:(t=s?.height)!=null?t:r.innerHeight,width:(n=s?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},c=a.current.y<=0,u=a.current.x<=0,l=a.current.y>=a.max.y,d=a.current.x>=a.max.x;return{rect:i,position:a,isTop:c,isLeft:u,isBottom:l,isRight:d}}function mm(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=su(e),{x:a,y:c}=t??{x:0,y:0},u=!n&&o.current.y+c>0,l=!r&&o.current.y+c<o.max.y,d=!i&&o.current.x+a>0,h=!s&&o.current.x+a<o.max.x;return{top:u,bottom:l,left:d,right:h,x:d||h,y:u||l}}var ja=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))}},Wi=new ja(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),gm=new ja(e=>setTimeout(e,50)),zi=new Map,vm=zi.clear.bind(zi);function yt(e,t=!1){if(!t)return wl(e);let n=zi.get(e);return n||(n=wl(e),zi.set(e,n),gm.schedule(vm),n)}function wl(e){return Je(e).getComputedStyle(e)}function bm(e,t=yt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function ym(e,t=yt(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 xm={excludeElement:!0,escapeShadowDOM:!0};function mo(e,t=xm){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(wa(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Sa(a))return o(a.host);if(!zt(a))return Xd(a)?o(a.parentElement):s;if(s.has(a))return s;const c=yt(a,!0);if(r&&a===e||ym(a,c)&&s.add(a),bm(a,c)){const{scrollingElement:u}=a.ownerDocument;return u&&s.add(u),s}return o(a.parentNode)}return e?o(e):s}function In(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Dn(e);for(;r;){if(r===t)return n;const i=as(r),{x:s,y:o}=wm(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=Dn(r)}return n}function wm(e,t=as(e)){const n=Math.round(t.width),r=Math.round(t.height);if(zt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=yt(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function km(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 jr(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 ls(e){var t,n,r,i,s,o,a,c,u;const{scale:l,transform:d,translate:h}=e,f=km(l),m=jr(h),g=Sm(d);if(!g&&!f&&!m)return null;const x={x:(t=f?.x)!=null?t:1,y:(n=f?.y)!=null?n:1},w={x:(r=m?.x)!=null?r:0,y:(i=m?.y)!=null?i:0},p={x:(s=g?.x)!=null?s:0,y:(o=g?.y)!=null?o:0,scaleX:(a=g?.scaleX)!=null?a:1,scaleY:(c=g?.scaleY)!=null?c:1};return{x:w.x+p.x,y:w.y+p.y,z:(u=m?.z)!=null?u:0,scaleX:x.x*p.scaleX,scaleY:x.y*p.scaleY}}function Sm(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 rt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(rt||{}),$m={x:.2,y:.2},jm={x:10,y:10};function Cm(e,t,n,r=25,i=$m,s=jm){const{x:o,y:a}=t,{rect:c,isTop:u,isBottom:l,isLeft:d,isRight:h}=su(e),f=In(e),m=yt(e,!0),g=ls(m),x=g!==null?g?.scaleX<0:!1,w=g!==null?g?.scaleY<0:!1,p=new gt(c.left*f.scaleX+f.x,c.top*f.scaleY+f.y,c.width*f.scaleX,c.height*f.scaleY),v={x:0,y:0},b={x:0,y:0},k={height:p.height*i.y,width:p.width*i.x};return k.height>0&&(!u||w&&!l)&&a<=p.top+k.height&&n?.y!==1&&o>=p.left-s.x&&o<=p.right+s.x?(v.y=w?1:-1,b.y=r*Math.abs((p.top+k.height-a)/k.height)):k.height>0&&(!l||w&&!u)&&a>=p.bottom-k.height&&n?.y!==-1&&o>=p.left-s.x&&o<=p.right+s.x&&(v.y=w?-1:1,b.y=r*Math.abs((p.bottom-k.height-a)/k.height)),k.width>0&&(!h||x&&!d)&&o>=p.right-k.width&&n?.x!==-1&&a>=p.top-s.y&&a<=p.bottom+s.y?(v.x=x?-1:1,b.x=r*Math.abs((p.right-k.width-o)/k.width)):k.width>0&&(!d||x&&!h)&&o<=p.left+k.width&&n?.x!==1&&a>=p.top-s.y&&a<=p.bottom+s.y&&(v.x=x?1:-1,b.x=r*Math.abs((p.left+k.width-o)/k.width)),{direction:v,speed:b}}function ou(e,{block:t="nearest",inline:n="nearest"}={}){if(!zt(e))return;const r=mo(e),i=[];for(const s of r){if(!zt(s))continue;const{top:o,left:a}=Om(e,s);let c=o,u=a;for(const l of i)c-=l.scrollTop,u-=l.scrollLeft;if(t!=="none"){const l=c<s.scrollTop,d=c+e.offsetHeight>s.scrollTop+s.clientHeight;l!==d&&(t==="center"?s.scrollTop=c-s.clientHeight/2+e.offsetHeight/2:l?s.scrollTop=c:s.scrollTop=c+e.offsetHeight-s.clientHeight)}if(n!=="none"){const l=u<s.scrollLeft,d=u+e.offsetWidth>s.scrollLeft+s.clientWidth;l!==d&&(n==="center"?s.scrollLeft=u-s.clientWidth/2+e.offsetWidth/2:l?s.scrollLeft=u:s.scrollLeft=u+e.offsetWidth-s.clientWidth)}i.push(s)}}function kl(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!zt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function Om(e,t){const n=kl(e),r=kl(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Em(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),c=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width*r:e.width,l=i?e.height*i:e.height;return{width:u,height:l,top:c,right:a+u,bottom:c+l,left:a}}function Tm(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left-s-(1-r)*parseFloat(n),c=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width/r:e.width,l=i?e.height/i:e.height;return{width:u,height:l,top:c,right:a+u,bottom:c+l,left:a}}function au({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Sl(e,t=yt(e).translate,n=!0){if(n){const r=Yd(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=jr(i);if(s)return s}}}if(t){const r=jr(t);if(r)return r}return{x:0,y:0,z:0}}var Mm=new ja(e=>setTimeout(e,0)),br=new Map,Am=br.clear.bind(br);function Dm(e){const t=e.ownerDocument;let n=br.get(t);if(n)return n;n=t.getAnimations(),br.set(t,n),Mm.schedule(Am);const r=n.filter(i=>os(i.effect)&&i.effect.target===e);return br.set(e,r),n}function Im(e,t){const n=Dm(e).filter(r=>{var i,s;if(os(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))==null||s)return r.effect.getKeyframes().some(a=>{for(const c of t.properties)if(a[c])return!0})}}).map(r=>{const{effect:i,currentTime:s}=r,o=i?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof s=="number"&&s<o)return r.currentTime=o,()=>{r.currentTime=s}});if(n.length>0)return()=>n.forEach(r=>r?.())}var mt=class extends gt{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=In(e),ignoreTransforms:a,getBoundingClientRect:c=as}=t,u=Im(e,{properties:["transform","translate","scale","width","height"],isValidTarget:k=>(k!==e||ka())&&k.contains(e)}),l=c(e);let{top:d,left:h,width:f,height:m}=l,g;const x=yt(e),w=ls(x),p={x:(n=w?.scaleX)!=null?n:1,y:(r=w?.scaleY)!=null?r:1},v=Pm(e,x);u?.(),w&&(g=Tm(l,w,x.transformOrigin),(a||v)&&(d=g.top,h=g.left,f=g.width,m=g.height));const b={width:(i=g?.width)!=null?i:f,height:(s=g?.height)!=null?s:m};if(v&&!a&&g){const k=Em(g,v,x.transformOrigin);d=k.top,h=k.left,f=k.width,m=k.height,p.x=v.scaleX,p.y=v.scaleY}o&&(a||(h*=o.scaleX,f*=o.scaleX,d*=o.scaleY,m*=o.scaleY),h+=o.x,d+=o.y),super(h,d,f,m),this.scale=p,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function Pm(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const c=os(a.effect)?a.effect.getKeyframes():[],u=c[c.length-1];if(!u)continue;const{transform:l,translate:d,scale:h}=u;typeof l=="string"&&l&&(r=l,o=!0),typeof d=="string"&&d&&(i=d,o=!0),typeof h=="string"&&h&&(s=h,o=!0)}return o?ls({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function yr(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 Rm=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(yr(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(yr(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(yr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function tn(e){return e?e instanceof Je(e).Element||Fr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function Cr(e){if(!e)return!1;const{KeyboardEvent:t}=Je(e.target);return e instanceof t}function Lm(e){if(!e)return!1;const{PointerEvent:t}=Je(e.target);return e instanceof t}function Nm(e){if(!tn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Wm(e)}function Wm(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Es={};function go(e){const t=Es[e]==null?0:Es[e]+1;return Es[e]=t,`${e}-${t}`}var Ca=({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=nt.distance(t.shape.center,n);return{id:r,value:1/i,type:Bn.PointerIntersection,priority:qn.High}}return null},zm=({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=nt.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:Bn.ShapeIntersection,priority:qn.Normal}}return null},lu=e=>{var t;return(t=Ca(e))!=null?t:zm(e)},Fm=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?gt.from(r.current.boundingRectangle).corners:void 0,o=gt.from(n.shape.boundingRectangle).corners.reduce((a,c,u)=>{var l;return a+nt.distance(nt.from(c),(l=s?.[u])!=null?l:i.current)},0)/4;return{id:n.id,value:1/o,type:Bn.Collision,priority:qn.Normal}},_m=Object.create,Oa=Object.defineProperty,qm=Object.defineProperties,Bm=Object.getOwnPropertyDescriptor,Hm=Object.getOwnPropertyDescriptors,Fi=Object.getOwnPropertySymbols,cu=Object.prototype.hasOwnProperty,du=Object.prototype.propertyIsEnumerable,uu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Un=e=>{throw TypeError(e)},vo=(e,t,n)=>t in e?Oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Or=(e,t)=>{for(var n in t||(t={}))cu.call(t,n)&&vo(e,n,t[n]);if(Fi)for(var n of Fi(t))du.call(t,n)&&vo(e,n,t[n]);return e},Ea=(e,t)=>qm(e,Hm(t)),$l=(e,t)=>Oa(e,"name",{value:t,configurable:!0}),fu=(e,t)=>{var n={};for(var r in e)cu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Fi)for(var r of Fi(e))t.indexOf(r)<0&&du.call(e,r)&&(n[r]=e[r]);return n},Gn=e=>{var t;return[,,,_m((t=e?.[uu("metadata")])!=null?t:null)]},hu=["class","method","getter","setter","accessor","field","value","get","set"],lr=e=>e!==void 0&&typeof e!="function"?Un("Function expected"):e,Um=(e,t,n,r,i)=>({kind:hu[e],name:t,metadata:r,addInitializer:s=>n._?Un("Already initialized"):i.push(lr(s||null))}),ln=(e,t)=>vo(t,uu("metadata"),e[3]),Pe=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},at=(e,t,n,r,i,s)=>{var o,a,c,u,l,d=t&7,h=!!(t&8),f=!!(t&16),m=d>3?e.length+1:d?h?1:2:0,g=hu[d+5],x=d>3&&(e[m-1]=[]),w=e[m]||(e[m]=[]),p=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&Bm(d<4?i:{get[n](){return ge(this,s)},set[n](b){return Ue(this,s,b)}},n));d?f&&d<4&&$l(s,(d>2?"set ":d>1?"get ":"")+n):$l(i,n);for(var v=r.length-1;v>=0;v--)u=Um(d,n,c={},e[3],w),d&&(u.static=h,u.private=f,l=u.access={has:f?b=>Gm(i,b):b=>n in b},d^3&&(l.get=f?b=>(d^1?ge:nn)(b,i,d^4?s:p.get):b=>b[n]),d>2&&(l.set=f?(b,k)=>Ue(b,i,k,d^4?s:p.set):(b,k)=>b[n]=k)),a=(0,r[v])(d?d<4?f?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),c._=1,d^4||a===void 0?lr(a)&&(d>4?x.unshift(a):d?f?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Un("Object expected"):(lr(o=a.get)&&(p.get=o),lr(o=a.set)&&(p.set=o),lr(o=a.init)&&x.unshift(o));return d||ln(e,i),p&&Oa(i,n,p),f?d^4?s:p:i},Ta=(e,t,n)=>t.has(e)||Un("Cannot "+n),Gm=(e,t)=>Object(t)!==t?Un('Cannot use the "in" operator on this value'):e.has(t),ge=(e,t,n)=>(Ta(e,t,"read from private field"),n?n.call(e):t.get(e)),Te=(e,t,n)=>t.has(e)?Un("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ue=(e,t,n,r)=>(Ta(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),nn=(e,t,n)=>(Ta(e,t,"access private method"),n),jl={role:"button",roleDescription:"draggable"},Km="dnd-kit-description",Ym="dnd-kit-announcement",Xm={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."},Vm={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 Zm(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Qm(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Jm(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 eg=["dragover","dragmove"],tg=class extends qe{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Km,announcement:i=Ym}={},announcements:s=Vm,screenReaderInstructions:o=Xm,debounce:a=500}=t??{},c=n?`${r}-${n}`:go(r),u=n?`${i}-${n}`:go(i);let l,d,h,f;const m=(k=f)=>{!h||!k||h?.nodeValue!==k&&(h.nodeValue=k)},g=()=>Wi.schedule(m),x=ng(g,a),w=Object.entries(s).map(([k,D])=>this.manager.monitor.addEventListener(k,(M,A)=>{const $=h;if(!$)return;const O=D?.(M,A);O&&$.nodeValue!==O&&(f=O,eg.includes(k)?x():(g(),x.cancel()))})),p=()=>{let k=[];l?.isConnected||(l=Qm(c,o.draggable),k.push(l)),d?.isConnected||(d=Jm(u),h=document.createTextNode(""),d.appendChild(h),k.push(d)),k.length>0&&document.body.append(...k)},v=new Set;function b(){for(const k of v)k()}this.registerEffect(()=>{var k;v.clear();for(const D of this.manager.registry.draggables.value){const M=(k=D.handle)!=null?k:D.element;if(M){(!l||!d)&&v.add(p),(!Zm(M)||ka())&&!M.hasAttribute("tabindex")&&v.add(()=>M.setAttribute("tabindex","0")),!M.hasAttribute("role")&&M.tagName.toLowerCase()!=="button"&&v.add(()=>M.setAttribute("role",jl.role)),M.hasAttribute("aria-roledescription")||v.add(()=>M.setAttribute("aria-roledescription",jl.roleDescription)),M.hasAttribute("aria-describedby")||v.add(()=>M.setAttribute("aria-describedby",c));for(const $ of["aria-pressed","aria-grabbed"]){const O=String(D.isDragging);M.getAttribute($)!==O&&v.add(()=>M.setAttribute($,O))}const A=String(D.disabled);M.getAttribute("aria-disabled")!==A&&v.add(()=>M.setAttribute("aria-disabled",A))}}v.size>0&&Wi.schedule(b)}),this.destroy=()=>{super.destroy(),l?.remove(),d?.remove(),w.forEach(k=>k())}}};function ng(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var _i=new Map,pu,mu,gu,vu,bo,xr,$t,Ma,Pn,bu,yu,xu,wu,Ft=class extends(bo=zr,vu=[ce],gu=[Oe],mu=[Oe],pu=[Oe],bo){constructor(e,t){super(e,t),Pe($t,5,this),Te(this,Pn),Te(this,xr,new Set),Te(this,Ma,Pe($t,8,this,new Set)),Pe($t,11,this),this.registerEffect(nn(this,Pn,bu))}register(e){return ge(this,xr).add(e),()=>{ge(this,xr).delete(e)}}addRoot(e){return le(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{le(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return Ri((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return Ri((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}};$t=Gn(bo);xr=new WeakMap;Ma=new WeakMap;Pn=new WeakSet;bu=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of ge(this,xr))t.push(nn(this,Pn,yu).call(this,n,r));return()=>{for(const n of t)n()}};yu=function(e,t){let n=_i.get(e);n||(n=new Map,_i.set(e,n));let r=n.get(t);if(!r){const s=wa(e)?nn(this,Pn,xu).call(this,e,n,t):nn(this,Pn,wu).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())}};xu=function(e,t,n){var r;const i=e.createElement("style"),{nonce:s}=(r=this.options)!=null?r:{};s&&i.setAttribute("nonce",s),i.textContent=n,e.head.prepend(i);const o=new MutationObserver(a=>{for(const c of a)for(const u of Array.from(c.removedNodes))if(u===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&&_i.delete(e)}}};wu=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(Sa(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&&_i.delete(e)}}};at($t,4,"additionalRoots",vu,Ft,Ma);at($t,2,"sourceRoot",gu,Ft);at($t,2,"targetRoot",mu,Ft);at($t,2,"roots",pu,Ft);ln($t,Ft);Ft.configure=Wr(Ft);var cs=Ft,rg=class extends qe{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(cs),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},_r="data-dnd-",yo=`${_r}dropping`,Ne="--dnd-",pt=`${_r}dragging`,qi=`${_r}placeholder`,ig=[pt,qi,"popover","aria-pressed","aria-grabbing"],sg=["view-transition-name"],og=`
9
- :is(:root,:host) [${pt}] {
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(${Ne}top, 0px) !important;
16
- left: var(${Ne}left, 0px) !important;
17
- right: unset !important;
18
- bottom: unset !important;
19
- width: var(${Ne}width, auto);
20
- max-width: var(${Ne}width, auto);
21
- height: var(${Ne}height, auto);
22
- max-height: var(${Ne}height, auto);
23
- transform: var(${Ne}transform, none) !important;
24
- transition: var(${Ne}transition) !important;
25
- }
26
-
27
- :is(:root,:host) [${qi}] {
28
- transition: none;
29
- }
30
-
31
- :is(:root,:host) [${qi}='hidden'] {
32
- visibility: hidden;
33
- }
34
-
35
- [${pt}] * {
36
- pointer-events: none !important;
37
- }
38
-
39
- [${pt}]:not([${yo}]) {
40
- translate: var(${Ne}translate) !important;
41
- }
42
-
43
- [${pt}][style*='${Ne}scale'] {
44
- scale: var(${Ne}scale) !important;
45
- transform-origin: var(${Ne}transform-origin) !important;
46
- }
47
-
48
- @layer dnd-kit {
49
- :where([${pt}][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
- [${pt}]::backdrop, [${_r}overlay]:not([${pt}]) {
64
- display: none;
65
- visibility: hidden;
66
- }
67
- `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function ag(e,t="hidden"){return le(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=lg(n,r.registry.droppables),s=[],o=nm(n),{remove:a}=o;return cg(i,o,s),dg(o,t),o.remove=()=>{s.forEach(c=>c()),a.call(o)},o})}function lg(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${_r}${go("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function cg(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),fo.set(a,o),n.push(()=>{fo.delete(a),r.proxy=void 0})}}function dg(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(qi,t)}function ku(e,t){return e===t?!0:Dn(e)===Dn(t)}function Cl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&tn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>Cn(t))}function xo(e){return e.tagName==="TR"}function ug(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-")||ig.includes(a))continue;const c=e.getAttribute(a);if(a==="style"){if(yr(e)&&yr(t)){const u=e.style;for(const l of Array.from(t.style))u.getPropertyValue(l)===""&&t.style.removeProperty(l);for(const l of Array.from(u)){if(sg.includes(l)||l.startsWith(Ne))continue;const d=u.getPropertyValue(l);t.style.setProperty(l,d)}}}else c!==null?t.setAttribute(a,c):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function fg(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),Cn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),Cn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),Cn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function hg(e){return new ResizeObserver(()=>{var t,n,r;const i=new mt(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-i.width)*s.x+e.delta.x,a=(e.height-i.height)*s.y+e.delta.y,c=Zd();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+c.y,left:e.left+o+c.x},Ne),(n=e.getElementMutationObserver())==null||n.takeRecords(),xo(e.element)&&xo(e.placeholder)){const g=Array.from(e.element.cells),x=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(g.map(w=>w.style.width));for(const[w,p]of g.entries()){const v=x[w];p.style.width=`${v.getBoundingClientRect().width}px`}}const u=(r=e.getTranslate())!=null?r:{x:0,y:0},l=e.left+o+c.x+u.x,d=e.top+a+c.y+u.y,h=i.width-e.widthOffset,f=i.height-e.heightOffset,m=e.frameTransform;e.dragOperation.shape=new gt(l*m.scaleX+m.x,d*m.scaleY+m.y,h*m.scaleX,f*m.scaleY)})}var pg=250,mg="ease";function gg(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const p=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(p).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=pg,easing:a=mg}=s??{};Cn(e.feedbackElement);const[,c]=(t=Yd(e.feedbackElement,p=>"translate"in p))!=null?t:[];c?.pause();const u=(n=e.placeholder)!=null?n:e.element,l={frameTransform:ku(e.feedbackElement,u)?null:void 0},d=new mt(e.feedbackElement,l),h=(r=jr(yt(e.feedbackElement).translate))!=null?r:e.translate,f=new mt(u,l),m=gt.delta(d,f,e.alignment),g={x:h.x-m.x,y:h.y-m.y},x=Math.round(d.intrinsicHeight)!==Math.round(f.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${f.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${f.intrinsicHeight}px`]}:{},w=Math.round(d.intrinsicWidth)!==Math.round(f.intrinsicWidth)?{minWidth:[`${d.intrinsicWidth}px`,`${f.intrinsicWidth}px`],maxWidth:[`${d.intrinsicWidth}px`,`${f.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Ne),e.feedbackElement.setAttribute(yo,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),au({element:e.feedbackElement,keyframes:Ea(Or(Or({},x),w),{translate:[`${h.x}px ${h.y}px 0`,`${g.x}px ${g.y}px 0`]}),options:{duration:$a(Je(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(yo),c?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Su,wo,Er,Aa,ki,$u,ju,Rn=class extends(wo=qe,Su=[ce],wo){constructor(e,t){super(e,t),Te(this,ki),Te(this,Aa,Pe(Er,8,this)),Pe(Er,11,this),this.state={initial:{},current:{}};const n=e.registry.plugins.get(cs),r=n?.register(og);if(r){const i=this.destroy.bind(this);this.destroy=()=>{r(),i()}}this.registerEffect(nn(this,ki,$u).bind(this,n)),this.registerEffect(nn(this,ki,ju))}};Er=Gn(wo);Aa=new WeakMap;ki=new WeakSet;$u=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Ri(t);if(n)return e.addRoot(n)};ju=function(){var e,t,n,r,i,s,o;const{state:a,manager:c,options:u}=this,{dragOperation:l}=c,{position:d,source:h,status:f}=l;if(f.idle){a.current={},a.initial={};return}if(!h)return;const{element:m}=h,g=h.pluginConfig(Rn),x=(t=(e=g?.feedback)!=null?e:u?.feedback)!=null?t:"default",w=typeof x=="function"?x(h,c):x;if(!m||w==="none"||!f.initialized||f.initializing)return;const{initial:p}=a,v=(n=this.overlay)!=null?n:m,b=In(v),k=In(m),D=!ku(m,v),M=new mt(m,{frameTransform:D?k:null,ignoreTransforms:!D}),A={x:k.scaleX/b.scaleX,y:k.scaleY/b.scaleY};let{width:$,height:O,top:z,left:I}=M;D&&($=$/A.x,O=O/A.y);const W=new Rm(v),G=yt(m),{transition:q,translate:U,boxSizing:K,paddingBlockStart:V,paddingBlockEnd:re,paddingInlineStart:T,paddingInlineEnd:_,borderInlineStartWidth:R,borderInlineEndWidth:N,borderBlockStartWidth:F,borderBlockEndWidth:ee}=G,J=q.split(",").filter(ve=>!/^\s*(transform|translate|scale)\b/.test(ve)).join(","),C=ls(G),j=G.transform,E=w==="clone",Z=K==="content-box",B=Z?parseInt(T)+parseInt(_)+parseInt(R)+parseInt(N):0,te=Z?parseInt(V)+parseInt(re)+parseInt(F)+parseInt(ee):0,X=w!=="move"&&!this.overlay?ag(h,E?"clone":"hidden"):null,ne=le(()=>Cr(c.dragOperation.activatorEvent));if(!p.translate){if(this.overlay&&C)p.translate={x:C.x,y:C.y};else if(U!=="none"){const ve=jr(U);ve&&(p.translate=ve)}}if(!p.transformOrigin){const ve=le(()=>d.current),Le=I+((r=C?.x)!=null?r:0),Ye=z+((i=C?.y)!=null?i:0);p.transformOrigin={x:(ve.x-Le*b.scaleX-b.x)/($*b.scaleX),y:(ve.y-Ye*b.scaleY-b.y)/(O*b.scaleY)}}const{transformOrigin:Q}=p,pe=z*b.scaleY+b.y,L=I*b.scaleX+b.x;if(!p.coordinates&&(p.coordinates={x:L,y:pe},A.x!==1||A.y!==1)){const{scaleX:ve,scaleY:Le}=k,{x:Ye,y:Et}=Q;p.coordinates.x+=($*ve-$)*Ye,p.coordinates.y+=(O*Le-O)*Et}p.dimensions||(p.dimensions={width:$,height:O}),p.frameTransform||(p.frameTransform=b);const ae={x:p.coordinates.x-L,y:p.coordinates.y-pe},fe={width:(p.dimensions.width*p.frameTransform.scaleX-$*b.scaleX)*Q.x,height:(p.dimensions.height*p.frameTransform.scaleY-O*b.scaleY)*Q.y},Y={x:ae.x/b.scaleX+fe.width,y:ae.y/b.scaleY+fe.height},P={left:I+Y.x,top:z+Y.y};v.setAttribute(pt,"true");const H=le(()=>l.transform),oe=(s=p.translate)!=null?s:{x:0,y:0},me=H.x*b.scaleX+oe.x,Fe=H.y*b.scaleY+oe.y,Yn=Zd();W.set({width:$-B,height:O-te,top:P.top+Yn.y,left:P.left+Yn.x,translate:`${me}px ${Fe}px 0`,transform:this.overlay?"none":j,transition:J?`${J}, translate 0ms linear`:"translate 0ms linear",scale:D?`${A.x} ${A.y}`:"","transform-origin":`${Q.x*100}% ${Q.y*100}%`},Ne),X&&(m.insertAdjacentElement("afterend",X),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(h):u.rootElement).appendChild(m)),po(v)&&(v.hasAttribute("popover")||v.setAttribute("popover","manual"),Cn(v),v.addEventListener("beforetoggle",Cl));let _t,Yr,xt;const Xa=hg({placeholder:X,element:m,feedbackElement:v,frameTransform:b,transformOrigin:Q,width:$,height:O,top:z,left:I,widthOffset:B,heightOffset:te,delta:Y,styles:W,dragOperation:l,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>_t,getSavedCellWidths:()=>xt,setSavedCellWidths:ve=>{xt=ve}}),Va=new mt(v);le(()=>l.shape=Va);const gs=Je(v),Za=ve=>{this.manager.actions.stop({event:ve})},Ff=$a(gs);ne&&gs.addEventListener("resize",Za),le(()=>h.status)==="idle"&&requestAnimationFrame(()=>h.status="dragging"),X&&(Xa.observe(X),_t=ug(m,X,E),Yr=fg(m,X,v));const Qa=(o=c.dragOperation.source)==null?void 0:o.id,_f=()=>{var ve;if(!ne||Qa==null)return;const Le=c.registry.draggables.get(Qa),Ye=(ve=Le?.handle)!=null?ve:Le?.element;zt(Ye)&&Ye.focus()},vs=()=>{_t?.disconnect(),Yr?.disconnect(),Xa.disconnect(),gs.removeEventListener("resize",Za),po(v)&&(v.removeEventListener("beforetoggle",Cl),v.removeAttribute("popover")),v.removeAttribute(pt),W.reset();const ve=()=>{var Le;if(xt&&xo(m)){const bs=Array.from(m.cells);for(const[Xr,cn]of bs.entries())cn.style.width=(Le=xt[Xr])!=null?Le:""}h.status="idle";const Ye=a.current.translate!=null,Et=l.status.dragging;X&&(!Et&&Ye||X.parentElement!==v.parentElement)&&v.isConnected&&X.replaceWith(v),X?.remove()};v===this.overlay?setTimeout(ve,0):ve()},qf=u?.dropAnimation,Ja=this,Bf=Lr(()=>{var ve,Le,Ye;const{transform:Et,status:bs}=l;if(!(!Et.x&&!Et.y&&!a.current.translate)&&bs.dragging){const Xr=(ve=p.translate)!=null?ve:{x:0,y:0},cn={x:Et.x/b.scaleX+Xr.x,y:Et.y/b.scaleY+Xr.y},el=a.current.translate,Hf=le(()=>l.modifiers),ys=le(()=>{var Xn;return(Xn=l.shape)==null?void 0:Xn.current}),xs=u?.keyboardTransition,tl=ne&&!Ff&&xs!==null?`${(Le=xs?.duration)!=null?Le:250}ms ${(Ye=xs?.easing)!=null?Ye:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(W.set({transition:J?`${J}, translate ${tl}`:`translate ${tl}`,translate:`${cn.x}px ${cn.y}px 0`},Ne),_t?.takeRecords(),ys&&ys!==Va&&el&&!Hf.length){const Xn=nt.delta(cn,el);l.shape=gt.from(ys.boundingRectangle).translate(Xn.x*b.scaleX,Xn.y*b.scaleY)}else l.shape=new mt(v);a.current.translate=cn}},function(){if(l.status.dropped){this.dispose(),h.status="dropping";const ve=g?.dropAnimation!==void 0?g.dropAnimation:Ja.dropAnimation!==void 0?Ja.dropAnimation:qf;let Le=a.current.translate;const Ye=Le!=null;if(!Le&&m!==v&&(Le={x:0,y:0}),!Le||ve===null){vs();return}c.renderer.rendering.then(()=>{gg({source:h,element:m,feedbackElement:v,placeholder:X,translate:Le,moved:Ye,transition:q,alignment:h.alignment,styles:W,animation:ve??void 0,getElementMutationObserver:()=>_t,cleanup:vs,restoreFocus:_f})})}});return()=>{vs(),Bf()}};at(Er,4,"overlay",Su,Rn,Aa);ln(Er,Rn);Rn.configure=Wr(Rn);var Da=Rn,Vn=!0,vg=!1,Cu,Ou,Eu,Tu,Dt,Ia,Pa;Tu=(Eu=[ce],rt.Forward),Ou=(Cu=[ce],rt.Reverse);var Tr=class{constructor(){Te(this,Ia,Pe(Dt,8,this,Vn)),Pe(Dt,11,this),Te(this,Pa,Pe(Dt,12,this,Vn)),Pe(Dt,15,this)}isLocked(e){return e===rt.Idle?!1:e==null?this[rt.Forward]===Vn&&this[rt.Reverse]===Vn:this[e]===Vn}unlock(e){e!==rt.Idle&&(this[e]=vg)}};Dt=Gn(null);Ia=new WeakMap;Pa=new WeakMap;at(Dt,4,Tu,Eu,Tr,Ia);at(Dt,4,Ou,Cu,Tr,Pa);ln(Dt,Tr);var bg=[rt.Forward,rt.Reverse],Ol=class{constructor(){this.x=new Tr,this.y=new Tr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},yg=class extends qe{constructor(e){super(e);const t=Ln(new Ol);let n=null;this.signal=t,ot(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ol;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:El(i.x,n.x),y:El(i.y,n.y)},o=t.peek();je(()=>{for(const a of id)for(const c of bg)s[a]===c&&o[a].unlock(c);t.value=o})}n=i})}get current(){return this.signal.peek()}};function El(e,t){return Math.sign(e-t)}var Mu,ko,Mr,Ra,Mt,So,qr=class extends(ko=zr,Mu=[ce],ko){constructor(e){super(e),Te(this,Ra,Pe(Mr,8,this,!1)),Pe(Mr,11,this),Te(this,Mt),Te(this,So,()=>{if(!ge(this,Mt))return;const{element:s,by:o}=ge(this,Mt);o.y&&(s.scrollTop+=o.y),o.x&&(s.scrollLeft+=o.x)}),this.scroll=(s,o)=>{var a;if(this.disabled)return!1;const c=this.getScrollableElements();if(!c)return Ue(this,Mt,void 0),!1;const{position:u}=this.manager.dragOperation,l=u?.current;if(l){const{by:d}=s??{},h=d?{x:Tl(d.x),y:Tl(d.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f?.isLocked())return!1;for(const m of c){const g=mm(m,d);if(g.x||g.y){const{speed:x,direction:w}=Cm(m,l,h,o?.acceleration,o?.threshold);if(f)for(const p of id)f[p].isLocked(w[p])&&(x[p]=0,w[p]=0);if(w.x||w.y){const{x:p,y:v}=d??w,b=p*x.x,k=v*x.y;if(b||k){const D=(a=ge(this,Mt))==null?void 0:a.by;if(this.autoScrolling&&D&&(D.x&&!b||D.y&&!k))continue;return Ue(this,Mt,{element:m,by:{x:b,y:k}}),Wi.schedule(ge(this,So)),!0}}}}}return Ue(this,Mt,void 0),!1};let t=null,n=null;const r=Zs(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=Qd(Ri(o?.element),s.current);return a&&(t=a),a??t}),i=Zs(()=>{const s=r.value,{documentElement:o}=Hn(s);if(!s||s===o){const{target:a}=e.dragOperation,c=a?.element;if(c){const u=mo(c,{excludeElement:!1});return n=u,u}}if(s){const a=mo(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},ct);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new yg(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!Cr(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};Mr=Gn(ko);Ra=new WeakMap;Mt=new WeakMap;So=new WeakMap;at(Mr,4,"autoScrolling",Mu,qr,Ra);ln(Mr,qr);function Tl(e){return e>0?rt.Forward:e<0?rt.Reverse:rt.Idle}var xg=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))}},wg=new xg(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),kg=10,$o=class extends qe{constructor(e,t){super(e,t);const n=e.registry.plugins.get(qr);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=ot(()=>{var r,i,s;if(this.disabled)return;const{position:o,status:a}=e.dragOperation;if(a.dragging){const c={acceleration:(r=this.options)==null?void 0:r.acceleration,threshold:typeof((i=this.options)==null?void 0:i.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(s=this.options)==null?void 0:s.threshold};if(n.scroll(void 0,c)){n.autoScrolling=!0;const u=setInterval(()=>wg.schedule(()=>n.scroll(void 0,c)),kg);return()=>{clearInterval(u)}}else n.autoScrolling=!1}})}};$o.configure=Wr($o);var Au=$o,Ml={capture:!0,passive:!0},cr,Sg=class extends zr{constructor(e){super(e),Te(this,cr),this.handleScroll=()=>{ge(this,cr)==null&&Ue(this,cr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Ue(this,cr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=ot(()=>{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,Ml),()=>{s.removeEventListener("scroll",this.handleScroll,Ml)}}})}};cr=new WeakMap;var $g="* { user-select: none !important; -webkit-user-select: none !important; }",jg=class extends qe{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(cs),n=t?.register($g);if(this.destroy=ot(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return Ts(),document.addEventListener("selectionchange",Ts,{capture:!0}),()=>{document.removeEventListener("selectionchange",Ts,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function Ts(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var dr=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}}),yn,Bi=class extends Mn{constructor(e,t){super(e),this.manager=e,this.options=t,Te(this,yn,[]),this.listeners=new Jd,this.handleSourceKeyDown=(n,r,i)=>{if(this.disabled||n.defaultPrevented||!tn(n.target)||r.disabled)return;const{keyboardCodes:s=dr.keyboardCodes,preventActivation:o=dr.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 ot(()=>{var n;const r=(n=e.handle)!=null?n:e.element,i=s=>{Cr(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(),ou(r);const{center:i}=new mt(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=Hn(r),o=[this.listeners.bind(s,[{type:"keydown",listener:a=>this.handleKeyDown(a,t,n),options:{capture:!0}}])];ge(this,yn).push(...o)}handleKeyDown(e,t,n){const{keyboardCodes:r=dr.keyboardCodes}=n??{};if(dn(e,[...r.end,...r.cancel])){e.preventDefault();const i=dn(e,r.cancel);this.handleEnd(e,i);return}dn(e,r.up)?this.handleMove("up",e):dn(e,r.down)&&this.handleMove("down",e),dn(e,r.left)?this.handleMove("left",e):dn(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:dr.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(Au);e?.disabled===!1&&(e.disable(),ge(this,yn).push(()=>{e.enable()}))}cleanup(){ge(this,yn).forEach(e=>e()),Ue(this,yn,[])}destroy(){this.cleanup(),this.listeners.clear()}};yn=new WeakMap;Bi.configure=Wr(Bi);Bi.defaults=dr;var Du=Bi;function dn(e,t){return t.includes(e.code)}var Xt,Cg=class extends Ld{constructor(){super(...arguments),Te(this,Xt)}onEvent(e){switch(e.type){case"pointerdown":Ue(this,Xt,An(e));break;case"pointermove":if(!ge(this,Xt))return;const{x:t,y:n}=An(e),r={x:t-ge(this,Xt).x,y:n-ge(this,Xt).y},{tolerance:i}=this.options;if(i&&oo(r,i)){this.abort();return}oo(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Ue(this,Xt,void 0)}};Xt=new WeakMap;var xn,Vt,Og=class extends Ld{constructor(){super(...arguments),Te(this,xn),Te(this,Vt)}onEvent(e){switch(e.type){case"pointerdown":Ue(this,Vt,An(e)),Ue(this,xn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!ge(this,Vt))return;const{x:t,y:n}=An(e),r={x:t-ge(this,Vt).x,y:n-ge(this,Vt).y};oo(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){ge(this,xn)&&(clearTimeout(ge(this,xn)),Ue(this,Vt,void 0),Ue(this,xn,void 0))}};xn=new WeakMap;Vt=new WeakMap;var $n=class{};$n.Delay=Og;$n.Distance=Cg;var jo=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&tn(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new $n.Delay({value:250,tolerance:5})]:Nm(i)&&!e.defaultPrevented?[new $n.Delay({value:200,tolerance:0})]:[new $n.Delay({value:200,tolerance:10}),new $n.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!tn(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=im(r);return i===t.element?!1:!!i}}),wn,Hi=class extends Mn{constructor(e,t){super(e),this.manager=e,this.options=t,Te(this,wn,new Set),this.listeners=new Jd,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=jo.activationConstraints}=n??{};return typeof r=="function"?r(e,t):r}bind(e,t=this.options){return ot(()=>{var n;const r=new AbortController,{signal:i}=r,s=a=>{Lm(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&&(Mg(a.ownerDocument.defaultView),a.addEventListener("pointerdown",s,{signal:i}));return()=>r.abort()})}handlePointerDown(e,t,n){if(this.disabled||!e.isPrimary||e.button!==0||!tn(e.target)||t.disabled||Eg(e)||!this.manager.dragOperation.status.idle)return;const{preventActivation:r=jo.preventActivation}=n??{};if(r?.(e,t))return;const{target:i}=e,s=zt(i)&&i.draggable&&i.getAttribute("draggable")==="true",o=In(t.element),{x:a,y:c}=An(e);this.initialCoordinates={x:a*o.scaleX+o.x,y:c*o.scaleY+o.y};const u=this.activationConstraints(e,t,n);e.sensor=this;const l=new Xp(u,m=>this.handleStart(t,m));l.signal.onabort=()=>this.handleCancel(e),l.onEvent(e),this.controller=l;const d=uo(),h=this.listeners.bind(d,[{type:"pointermove",listener:m=>this.handlePointerMove(m,t)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:s?this.handleCancel:ti,options:{capture:!0}}]),f=()=>{h(),this.initialCoordinates=void 0};ge(this,wn).add(f)}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=An(e),s=In(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,Wi.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=Hn(t.target).body;try{i.setPointerCapture(t.pointerId)}catch{this.handleCancel(t);return}const s=tn(t.target)?[t.target,i]:i,o=this.listeners.bind(s,[{type:"touchmove",listener:ti,options:{passive:!1}},{type:"click",listener:ti},{type:"contextmenu",listener:ti},{type:"keydown",listener:this.handleKeyDown}]);ge(this,wn).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},ge(this,wn).forEach(t=>t()),ge(this,wn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};wn=new WeakMap;Hi.configure=Wr(Hi);Hi.defaults=jo;var Co=Hi;function Eg(e){return"sensor"in e}function ti(e){e.preventDefault()}function Tg(){}var Al=new WeakSet;function Mg(e){!e||Al.has(e)||(e.addEventListener("touchmove",Tg,{capture:!1,passive:!1}),Al.add(e))}var On={modifiers:[],plugins:[tg,Au,rg,Da,jg],sensors:[Co,Du]},Iu=class extends Qp{constructor(e={}){const t=ft(e.plugins,On.plugins),n=ft(e.sensors,On.sensors),r=ft(e.modifiers,On.modifiers);super(Ea(Or({},e),{plugins:[Sg,qr,cs,...t],sensors:n,modifiers:r}))}},Pu,Ru,Oo,It,La,Na,ds=class extends(Oo=vt,Ru=[ce],Pu=[ce],Oo){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=fu(n,["element","effects","handle"]);super(Or({effects:()=>[...i(),()=>{var a,c;const{manager:u}=this;if(!u)return;const l=((c=(a=this.sensors)==null?void 0:a.map(kr))!=null?c:[...u.sensors]).map(d=>{const h=d instanceof Mn?d:u.registry.register(d.plugin),f=d instanceof Mn?void 0:d.options;return h.bind(this,f)});return function(){l.forEach(d=>d())}}]},o),t),Te(this,La,Pe(It,8,this)),Pe(It,11,this),Te(this,Na,Pe(It,12,this)),Pe(It,15,this),this.element=r,this.handle=s}};It=Gn(Oo);La=new WeakMap;Na=new WeakMap;at(It,4,"handle",Ru,ds,La);at(It,4,"element",Pu,ds,Na);ln(It,ds);var Lu,Nu,Eo,Pt,Wa,Ms,Wu,zu,wr,za,us=class extends(Eo=bt,Nu=[ce],Lu=[ce],Eo){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=fu(n,["element","effects"]);const{collisionDetector:o=lu}=s,a=u=>{const{manager:l,element:d}=this;if(!d||u===null){this.shape=void 0;return}if(!l)return;const h=new mt(d),f=le(()=>this.shape);return h&&f?.equals(h)?f:(this.shape=h,h)},c=Ln(!1);super(Ea(Or({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:u,manager:l}=this;if(!l)return;const{dragOperation:d}=l,{source:h}=d;c.value=!!(h&&d.status.initialized&&u&&!this.disabled&&this.accepts(h))},()=>{const{element:u}=this;if(c.value&&u){const l=new pm(u,a);return()=>{l.disconnect(),this.shape=void 0}}},()=>{var u;if((u=this.manager)!=null&&u.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),Te(this,wr),Te(this,Wa,Pe(Pt,8,this)),Pe(Pt,11,this),Te(this,za,Pe(Pt,12,this)),Pe(Pt,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Ue(this,wr,e,zu)}get element(){var e;return(e=this.proxy)!=null?e:ge(this,wr,Wu)}};Pt=Gn(Eo);Wa=new WeakMap;wr=new WeakSet;za=new WeakMap;Ms=at(Pt,20,"#element",Nu,wr,Wa),Wu=Ms.get,zu=Ms.set;at(Pt,4,"proxy",Lu,us,za);ln(Pt,us);function Ag(e){return e!=null&&typeof e=="object"&&"current"in e}function En(e){var t;if(e!=null)return Ag(e)?(t=e.current)!=null?t:void 0:e}var Dg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Kn=Dg?S.useLayoutEffect:S.useEffect;function Ig(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function Fu(e,t){const n=S.useRef(new Map),r=Ig();return Kn(()=>{if(!e){n.current.clear();return}return ot(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[c]=a,u=le(()=>a[1]),l=e[c];u!==l&&(s=!0,n.current.set(c,l),o=(i=t?.(c,u,l))!=null?i:!1)}s&&(o?queueMicrotask(()=>zh.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 Pg(e,t){e()}function un(e){const t=S.useRef(e);return Kn(()=>{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 Si(e,t){const n=S.useRef(En(e));Kn(()=>{const r=En(e);r!==n.current&&(n.current=r,t(r))})}var Rg=Object.defineProperty,Lg=Object.defineProperties,Ng=Object.getOwnPropertyDescriptors,Ui=Object.getOwnPropertySymbols,_u=Object.prototype.hasOwnProperty,qu=Object.prototype.propertyIsEnumerable,Dl=(e,t,n)=>t in e?Rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wg=(e,t)=>{for(var n in t||(t={}))_u.call(t,n)&&Dl(e,n,t[n]);if(Ui)for(var n of Ui(t))qu.call(t,n)&&Dl(e,n,t[n]);return e},zg=(e,t)=>Lg(e,Ng(t)),Fg=(e,t)=>{var n={};for(var r in e)_u.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ui)for(var r of Ui(e))t.indexOf(r)<0&&qu.call(e,r)&&(n[r]=e[r]);return n},_g=new Iu,Bu=S.createContext(_g),qg=S.memo(S.forwardRef(({children:e},t)=>{const[n,r]=S.useState(0),i=S.useRef(null),s=S.useRef(null),o=S.useMemo(()=>({renderer:{get rendering(){var a;return(a=i.current)!=null?a:Promise.resolve()}},trackRendering(a){i.current||(i.current=new Promise(c=>{s.current=c})),S.startTransition(()=>{a(),r(c=>c+1)})}}),[]);return Kn(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),As=[void 0,ct];function Bg(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:c}=t,u=Fg(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const l=S.useRef(null),{plugins:d,modifiers:h,sensors:f}=u,m=ft(d,On.plugins),g=ft(f,On.sensors),x=ft(h,On.modifiers),w=un(i),p=un(s),v=un(a),b=un(o),k=un(c),D=un(r),M=Hg(()=>{var A;return(A=u.manager)!=null?A:new Iu(u)});return S.useEffect(()=>{if(!l.current)throw new Error("Renderer not found");const{renderer:A,trackRendering:$}=l.current,{monitor:O}=M;M.renderer=A;const z=[O.addEventListener("beforedragstart",I=>{const W=w.current;W&&$(()=>W(I,M))}),O.addEventListener("dragstart",I=>{var W;return(W=p.current)==null?void 0:W.call(p,I,M)}),O.addEventListener("dragover",I=>{const W=v.current;W&&$(()=>W(I,M))}),O.addEventListener("dragmove",I=>{const W=b.current;W&&$(()=>W(I,M))}),O.addEventListener("dragend",I=>{const W=k.current;W&&$(()=>W(I,M))}),O.addEventListener("collision",I=>{var W;return(W=D.current)==null?void 0:W.call(D,I,M)})];return()=>z.forEach(I=>I())},[M]),Se(m,()=>M&&(M.plugins=m),...As),Se(g,()=>M&&(M.sensors=g),...As),Se(x,()=>M&&(M.modifiers=x),...As),y.jsxs(Bu.Provider,{value:M,children:[y.jsx(qg,{ref:l,children:n}),n]})}function Hg(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 Ug(){return S.useContext(Bu)}function Hu(e){var t;const n=(t=Ug())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Kn(r.register,[n,r]),r}var Gg=Object.create,Uu=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,Gu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),fs=e=>{throw TypeError(e)},Yg=(e,t,n)=>t in e?Uu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xg=e=>{var t;return[,,,Gg((t=e?.[Gu("metadata")])!=null?t:null)]},Ku=["class","method","getter","setter","accessor","field","value","get","set"],Yu=e=>e!==void 0&&typeof e!="function"?fs("Function expected"):e,Vg=(e,t,n,r,i)=>({kind:Ku[e],name:t,metadata:r,addInitializer:s=>n._?fs("Already initialized"):i.push(Yu(s||null))}),Zg=(e,t)=>Yg(t,Gu("metadata"),e[3]),Qg=(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},Xu=(e,t,n,r,i,s)=>{for(var o,a,c,u,l=t&7,d=!1,h=!1,f=2,m=Ku[l+5],g=e[f]||(e[f]=[]),x=(i=i.prototype,Kg(i,n)),w=r.length-1;w>=0;w--)c=Vg(l,n,a={},e[3],g),c.static=d,c.private=h,u=c.access={has:p=>n in p},u.get=p=>p[n],o=(0,r[w])(x[m],c),a._=1,Yu(o)&&(x[m]=o);return x&&Uu(i,n,x),i},Vu=(e,t,n)=>t.has(e)||fs("Cannot "+n),Jg=(e,t,n)=>(Vu(e,t,"read from private field"),t.get(e)),ev=(e,t,n)=>t.has(e)?fs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),tv=(e,t,n,r)=>(Vu(e,t,"write to private field"),t.set(e,n),n),Qt=class To{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new To(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 To(t,n)}},Zu,Qu,Mo,$i,Br,Fa=class extends(Mo=on,Qu=[Oe],Zu=[Oe],Mo){constructor(e){const t=Qt.from(e);super(t,(n,r)=>Qt.equals(n,r)),Qg(Br,5,this),ev(this,$i,0),this.velocity={x:0,y:0}}get delta(){return Qt.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=Qt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Jg(this,$i),o=a=>Math.round(a/s*100);je(()=>{tv(this,$i,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Qt.from(e)),this.velocity={x:0,y:0}}};Br=Xg(Mo);$i=new WeakMap;Xu(Br,2,"delta",Qu,Fa);Xu(Br,2,"direction",Zu,Fa);Zg(Br,Fa);var Ju=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ju||{});Object.values(Ju);var nv=({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=Qt.distance(t.shape.center,n);return{id:r,value:1/i,type:Bn.PointerIntersection,priority:qn.High}}return null},rv=({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=Qt.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:Bn.ShapeIntersection,priority:qn.Normal}}return null},iv=e=>{var t;return(t=nv(e))!=null?t:rv(e)};function sv(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,c=Hu(l=>new us(zg(Wg({},e),{register:!1,element:En(i)}),l)),u=Fu(c);return Se(s,()=>c.id=s),Si(i,l=>c.element=l),Se(o,()=>c.accept=o,void 0,ct),Se(t,()=>c.collisionDetector=t??iv),Se(n,()=>n&&(c.data=n)),Se(r,()=>c.disabled=r===!0),Se(a,()=>c.type=a),{droppable:u,get isDropTarget(){return u.isDropTarget},ref:S.useCallback(l=>{var d,h;!l&&(d=c.element)!=null&&d.isConnected&&!((h=c.manager)!=null&&h.dragOperation.status.idle)||(c.element=l??void 0)},[c])}}const Il=`url("data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>')}")`,ef=(e,t="line")=>{const n=[":is(p, h1, h2, h3, h4, h5, h6):first-child::after","> * > span:only-child::after"],r=o=>n.map(a=>`${o} ${a}`).join(", "),i=t==="line"?"&::after":r("&"),s=t==="line"?"&:hover::after, &:focus-visible::after":`${r("&:hover")}, ${r("&:focus-visible")}`;return{cursor:"text",borderRadius:"2px",[i]:{content:'""',display:"inline-block",width:"0.8em",height:"0.8em",ml:"0.4em",verticalAlign:"-0.05em",backgroundColor:"currentColor",maskImage:Il,WebkitMaskImage:Il,maskSize:"contain",WebkitMaskSize:"contain",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",opacity:.35,transition:`opacity ${ut}`,...Lt,pointerEvents:"none"},[s]:{opacity:.8},"&:focus-visible":{outline:`2px solid ${e.accent}`,outlineOffset:2}}},tf=S.createContext(void 0);function nf(e,t){const n=S.useContext(tf),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 Ao({value:e,placeholder:t,ariaLabel:n,onCommit:r,faintWhenEmpty:i=!1}){const{theme:s}=Qe(),[o,a]=S.useState(void 0),c=S.useRef(!1),u=()=>{c.current||o===void 0||(a(void 0),o!==e&&r(o))};nf(o!==void 0&&o!==e,()=>(u(),!0));const l=()=>{c.current=!1,a(e)};if(o===void 0){const d=e==="",h=d&&i;return y.jsx(Ae,{component:"button",type:"button",className:h?"builder-affordance":void 0,onClick:l,onKeyDown:f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),l())},sx:[{all:"unset",boxSizing:"border-box",font:"inherit",color:"inherit",display:"inline-block",maxWidth:"100%",...d&&{fontStyle:"italic",opacity:h?0:.6}},ef(s)],children:d?t:e})}return y.jsx(xh,{autoFocus:!0,fullWidth:!0,value:o,placeholder:t,inputProps:{"aria-label":n},onFocus:d=>d.target.select(),onChange:d=>a(d.target.value),onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing?u():d.key==="Escape"&&(c.current=!0,a(void 0))},onBlur:u,sx:{font:"inherit",color:"inherit",p:0,"& input":{p:0}}})}const ov=(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}),av=(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},rf=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),sf=e=>`gap.${e}`,lv=(e,t)=>{const n=[];let r=0;e.forEach((s,o)=>{const a=Math.min(s.colspan??1,t),c=o===0||s.break===!0||r+a>t;c&&o>0&&r<t&&n.push({kind:"gap",after:ze(e[o-1]),colspan:t-r}),c&&(r=0),n.push(rf(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:ze(i),colspan:t-r}),n};var cv=Object.create,of=Object.defineProperty,dv=Object.defineProperties,uv=Object.getOwnPropertyDescriptor,fv=Object.getOwnPropertyDescriptors,Gi=Object.getOwnPropertySymbols,af=Object.prototype.hasOwnProperty,lf=Object.prototype.propertyIsEnumerable,hv=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Hr=e=>{throw TypeError(e)},Do=(e,t,n)=>t in e?of(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ds=(e,t)=>{for(var n in t||(t={}))af.call(t,n)&&Do(e,n,t[n]);if(Gi)for(var n of Gi(t))lf.call(t,n)&&Do(e,n,t[n]);return e},Is=(e,t)=>dv(e,fv(t)),pv=(e,t)=>{var n={};for(var r in e)af.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Gi)for(var r of Gi(e))t.indexOf(r)<0&&lf.call(e,r)&&(n[r]=e[r]);return n},mv=e=>{var t;return[,,,cv((t=void 0)!=null?t:null)]},cf=["class","method","getter","setter","accessor","field","value","get","set"],ur=e=>e!==void 0&&typeof e!="function"?Hr("Function expected"):e,gv=(e,t,n,r,i)=>({kind:cf[e],name:t,metadata:r,addInitializer:s=>n._?Hr("Already initialized"):i.push(ur(s||null))}),vv=(e,t)=>Do(t,hv("metadata"),e[3]),ni=(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},df=(e,t,n,r,i,s)=>{for(var o,a,c,u,l,d=t&7,h=!1,f=!1,m=e.length+1,g=cf[d+5],x=e[m-1]=[],w=e[m]||(e[m]=[]),p=(i=i.prototype,uv({get[n](){return fr(this,s)},set[n](b){return Zt(this,s,b)}},n)),v=r.length-1;v>=0;v--)u=gv(d,n,c={},e[3],w),u.static=h,u.private=f,l=u.access={has:b=>n in b},l.get=b=>b[n],l.set=(b,k)=>b[n]=k,a=(0,r[v])({get:p.get,set:p.set},u),c._=1,a===void 0?ur(a)&&(p[g]=a):typeof a!="object"||a===null?Hr("Object expected"):(ur(o=a.get)&&(p.get=o),ur(o=a.set)&&(p.set=o),ur(o=a.init)&&x.unshift(o));return p&&of(i,n,p),i},uf=(e,t,n)=>t.has(e)||Hr("Cannot "+n),fr=(e,t,n)=>(uf(e,t,"read from private field"),t.get(e)),Zn=(e,t,n)=>t.has(e)?Hr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Zt=(e,t,n,r)=>(uf(e,t,"write to private field"),t.set(e,n),n);function Jt(e){return e instanceof Ba||e instanceof mf}var ri=10,bv=class extends qe{constructor(e){super(e);const t=ot(()=>{const{dragOperation:r}=e;if(Cr(r.activatorEvent)&&Jt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(qr);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(!Cr(r.nativeEvent)||!Jt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:c}=i,{by:u}=r;if(!u)return;const l=yv(u),{source:d,target:h}=s,{center:f}=s.shape.current,m=[],g=[];je(()=>{for(const k of c.droppables){const{id:D}=k;if(!k.accepts(d)||D===h?.id&&Jt(k)||!k.element)continue;let M=k.shape;const A=new mt(k.element,{getBoundingClientRect:$=>$r($,void 0,.2)});!A.height||!A.width||(l=="down"&&f.y+ri<A.center.y||l=="up"&&f.y-ri>A.center.y||l=="left"&&f.x-ri>A.center.x||l=="right"&&f.x+ri<A.center.x)&&(m.push(k),k.shape=A,g.push(()=>k.shape=M))}}),r.preventDefault(),a.disable();const x=a.computeCollisions(m,Fm);je(()=>g.forEach(k=>k()));const[w]=x;if(!w)return;const{id:p}=w,{index:v,group:b}=d.sortable;o.setDropTarget(p).then(()=>{const{source:k,target:D,shape:M}=s;if(!k||!Jt(k)||!M)return;const{index:A,group:$,target:O}=k.sortable,z=v!==A||b!==$,I=z?O:D?.element;if(!I)return;ou(I);const W=new mt(I);if(!W)return;const G=gt.delta(W,gt.from(M.current.boundingRectangle),k.alignment);o.move({by:G}),z?o.setDropTarget(k.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function yv(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 xv=Object.defineProperty,wv=Object.defineProperties,kv=Object.getOwnPropertyDescriptors,Pl=Object.getOwnPropertySymbols,Sv=Object.prototype.hasOwnProperty,$v=Object.prototype.propertyIsEnumerable,Rl=(e,t,n)=>t in e?xv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fn=(e,t)=>{for(var n in t||(t={}))Sv.call(t,n)&&Rl(e,n,t[n]);if(Pl)for(var n of Pl(t))$v.call(t,n)&&Rl(e,n,t[n]);return e},hn=(e,t)=>wv(e,kv(t));function jv(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function ii(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function Ps(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Cv(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const c=(p,v)=>p===v||p!==null&&typeof p=="object"&&"id"in p&&p.id===v;if(Array.isArray(e)){const p=e.findIndex(b=>c(b,s.id)),v=e.findIndex(b=>c(b,o.id));if(p===-1||v===-1){if(Ps(s)){const b=s.initialIndex,k=s.index;return b===k||b<0||b>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,b,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const b=s.index;if(b!==p)return n(e,p,b)}return n(e,p,v)}const u=Object.entries(e);let l=-1,d,h=-1,f;for(const[p,v]of u)if(l===-1&&(l=v.findIndex(b=>c(b,s.id)),l!==-1&&(d=p)),h===-1&&(h=v.findIndex(b=>c(b,o.id)),h!==-1&&(f=p)),l!==-1&&h!==-1)break;if(l===-1&&Ps(s)){const p=s.initialGroup==null?void 0:ii(e,s.initialGroup),v=s.initialIndex,b=s.group==null?void 0:ii(e,s.group),k=s.index;if(p==null||b==null||p===b&&v===k)return"preventDefault"in t&&t.preventDefault(),e;if(p===b)return hn(fn({},e),{[p]:n(e[p],v,k)});const D=e[p][v];return hn(fn({},e),{[p]:[...e[p].slice(0,v),...e[p].slice(v+1)],[b]:[...e[b].slice(0,k),D,...e[b].slice(k)]})}if(!s.manager)return e;const{dragOperation:m}=s.manager,g=(i=(r=m.shape)==null?void 0:r.current.center)!=null?i:m.position.current;if(f==null){const p=ii(e,o.id);if(p!=null){const v=o.shape&&g.y>o.shape.center.y?e[p].length:0;f=p,h=v}}if(d==null||f==null||d===f&&l===h){if(d!=null&&d===f&&l===h&&Ps(s)){const p=s.group==null?void 0:ii(e,s.group),v=s.group!=null&&p!==d,b=s.index!==l;if(v||b){const k=s.group==null?d:p;if(k!=null){if(d===k)return hn(fn({},e),{[d]:n(e[d],l,s.index)});const D=e[d][l];return hn(fn({},e),{[d]:[...e[d].slice(0,l),...e[d].slice(l+1)],[k]:[...e[k].slice(0,s.index),D,...e[k].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===f)return hn(fn({},e),{[d]:n(e[d],l,h)});const x=o.shape&&Math.round(g.y)>Math.round(o.shape.center.y)?1:0,w=e[d][l];return hn(fn({},e),{[d]:[...e[d].slice(0,l),...e[d].slice(l+1)],[f]:[...e[f].slice(0,h+x),w,...e[f].slice(h+x)]})}function Ov(e,t){return Cv(e,t,jv)}function Ll(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Nl(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 Wl="__default__",Ev=class extends qe{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof Ba){const{sortable:s}=i,{group:o}=s;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(s)}return r},n=[e.monitor.addEventListener("dragover",(r,i)=>{if(this.disabled)return;const{dragOperation:s}=i,{source:o,target:a}=s;if(!Jt(o)||!Jt(a)||o.sortable===a.sortable)return;const c=t(),u=Ll(c),l=o.sortable.group===a.sortable.group,d=c.get(o.sortable.group),h=l?d:c.get(a.sortable.group);!d||!h||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var f,m;const g=t();if(Nl(u,c,g))return;const x=o.sortable.element,w=a.sortable.element;if(!w||!x||!l&&a.id===o.sortable.group)return;const p=si(d),v=l?p:si(h),b=(f=o.sortable.group)!=null?f:Wl,k=(m=a.sortable.group)!=null?m:Wl,D={[b]:p,[k]:v},M=Ov(D,r);if(D===M)return;const A=M[k].indexOf(o.sortable),$=M[k].indexOf(a.sortable);i.collisionObserver.disable(),zl(x,A,w,$),je(()=>{for(const[O,z]of M[b].entries())z.index=O;if(!l)for(const[O,z]of M[k].entries())z.group=a.sortable.group,z.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;Jt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),c=Ll(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const l=t();if(Nl(c,a,l))return;const d=si(u),h=si(u,Mv),f=o.sortable.element,m=h.indexOf(o.sortable),g=d[m],x=g?.element;!g||!x||!f||(zl(f,g.index,x,o.index),je(()=>{for(const w of a.values()){const p=Array.from(w).values();for(const v of p)v.index=v.initialIndex,v.group=v.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function zl(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function Tv(e,t){return e.index-t.index}function Mv(e,t){return e.initialIndex-t.initialIndex}function si(e,t=Tv){return Array.from(e).sort(t)}var Fl=[bv,Ev],ff={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function _l(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 oi=new Sp,hf,pf,Rt,_a,hr,pr,qa,kn;pf=[ce],hf=[ce];var hs=class{constructor(e,t){Zn(this,_a,ni(Rt,8,this)),ni(Rt,11,this),Zn(this,hr),Zn(this,pr),Zn(this,qa,ni(Rt,12,this)),ni(Rt,15,this),Zn(this,kn),this.register=()=>(je(()=>{var m,g;(m=this.manager)==null||m.registry.register(this.droppable),(g=this.manager)==null||g.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{je(()=>{var m,g;(m=this.manager)==null||m.registry.unregister(this.droppable),(g=this.manager)==null||g.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:c,transition:u=ff,plugins:l}=n,d=pv(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const h=ft(l,Fl),f=_l(i);this.droppable=new Ba(Is(Ds({},d),{disabled:f.droppable}),t,this),this.draggable=new mf(Is(Ds({},d),{disabled:f.draggable,plugins:h,effects:()=>[()=>{var m,g,x;const w=(m=this.manager)==null?void 0:m.dragOperation.status;w?.initializing&&this.id===((x=(g=this.manager)==null?void 0:g.dragOperation.source)==null?void 0:x.id)&&oi.clear(this.manager),w?.dragging&&oi.set(this.manager,this.id,le(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:m,group:g,manager:x}=this,w=fr(this,pr),p=fr(this,hr);(m!==w||g!==p)&&(Zt(this,pr,m),Zt(this,hr,g),this.animate())},()=>{var m,g;const{target:x}=this,{isDragSource:w}=this.draggable;((g=(m=this.draggable.pluginConfig(Da))==null?void 0:m.feedback)!=null?g:"default")==="move"&&w&&(this.droppable.disabled=!x)},...r()],type:c,sensors:a}),t,this),Zt(this,kn,d.element),this.manager=t,this.index=o,Zt(this,pr,o),this.group=s,Zt(this,hr,s),this.type=c,this.transition=u}get initialIndex(){var e,t;return(t=(e=oi.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=oi.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){le(()=>{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 l of i.getAnimations())"transitionProperty"in l&&(l.transitionProperty==="transform"||l.transitionProperty==="translate"||l.transitionProperty==="scale")&&l.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}=yt(i),c=Sl(i,a,!1),u=Sl(i,a);if(o.x||o.y){const l=$a(Je(i))?Is(Ds({},t),{duration:0}):t;au({element:i,keyframes:{translate:[`${c.x+o.x}px ${c.y+o.y}px ${c.z}`,`${u.x}px ${u.y}px ${u.z}`]},options:l}).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=fr(this,kn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Zt(this,kn,e)})}get element(){var e,t;const n=fr(this,kn);if(n)return(t=(e=fo.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=ft(e,Fl)}set disabled(e){const t=_l(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??lu}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)}};Rt=mv();_a=new WeakMap;hr=new WeakMap;pr=new WeakMap;qa=new WeakMap;kn=new WeakMap;df(Rt,4,"index",pf,hs,_a);df(Rt,4,"group",hf,hs,qa);vv(Rt,hs);var mf=class extends ds{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}},Ba=class extends us{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Av=Object.defineProperty,Dv=Object.defineProperties,Iv=Object.getOwnPropertyDescriptors,ql=Object.getOwnPropertySymbols,Pv=Object.prototype.hasOwnProperty,Rv=Object.prototype.propertyIsEnumerable,Bl=(e,t,n)=>t in e?Av(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rs=(e,t)=>{for(var n in t||(t={}))Pv.call(t,n)&&Bl(e,n,t[n]);if(ql)for(var n of ql(t))Rv.call(t,n)&&Bl(e,n,t[n]);return e},Lv=(e,t)=>Dv(e,Iv(t));function Nv(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:c,group:u,disabled:l,modifiers:d,sensors:h,target:f,type:m,plugins:g}=e,x=Rs(Rs({},ff),e.transition),w=Hu(v=>new hs(Lv(Rs({},e),{transition:x,register:!1,handle:En(a),element:En(o),target:En(f)}),v)),p=Fu(w,Wv);return Se(i,()=>w.id=i),Kn(()=>{je(()=>{w.group=u,w.index=c})},[w,u,c]),Se(m,()=>w.type=m),Se(t,()=>w.accept=t,void 0,ct),Se(s,()=>s&&(w.data=s)),Se(c,()=>{var v;(v=w.manager)!=null&&v.dragOperation.status.idle&&x?.idle&&w.refreshShape()},Pg),Si(a,v=>w.handle=v),Si(o,v=>w.element=v),Si(f,v=>w.target=v),Se(l,()=>w.disabled=l??!1,void 0,ct),Se(h,()=>w.sensors=h,void 0,ct),Se(n,()=>w.collisionDetector=n),Se(r,()=>w.collisionPriority=r),Se(g,()=>w.plugins=g,void 0,ct),Se(x,()=>w.transition=x,void 0,ct),Se(d,()=>w.modifiers=d,void 0,ct),Se(e.alignment,()=>w.alignment=e.alignment),{sortable:p,get isDragging(){return p.isDragging},get isDropping(){return p.isDropping},get isDragSource(){return p.isDragSource},get isDropTarget(){return p.isDropTarget},handleRef:S.useCallback(v=>{w.handle=v??void 0},[w]),ref:S.useCallback(v=>{var b,k;!v&&(b=w.element)!=null&&b.isConnected&&!((k=w.manager)!=null&&k.dragOperation.status.idle)||(w.element=v??void 0)},[w]),sourceRef:S.useCallback(v=>{var b,k;!v&&(b=w.source)!=null&&b.isConnected&&!((k=w.manager)!=null&&k.dragOperation.status.idle)||(w.source=v??void 0)},[w]),targetRef:S.useCallback(v=>{var b,k;!v&&(b=w.target)!=null&&b.isConnected&&!((k=w.manager)!=null&&k.dragOperation.status.idle)||(w.target=v??void 0)},[w])}}function Wv(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Io="tile",gf="gap",zv=[Co.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>e.target instanceof Element&&e.target.closest(`[${vf}]`)!==null||(Co.defaults.preventActivation?.(e,t)??!1)}),Du],vf="data-no-drag",Fv=e=>[...e,Da.configure({feedback:"clone"})];function _v({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=Nv({id:e,index:t,type:Io,accept:Io,collisionDetector:Ca,plugins:Fv});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function qv({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=sv({id:e,type:gf,accept:Io,collisionDetector:Ca,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const bf=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"],yf=["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"],ps=e=>yf.includes(e),Po=new Set([...bf,"viz"]);function Wt(e){const t=e.trim();if(!/^#[ \t]/.test(t)||/[{=]/.test(t))return;const n=t.slice(1).trim().split(/[ \t]+/),r=[];let i;for(const s of n)if(s.startsWith("-")){if(i!==void 0)return;const o=s.slice(1);if(!Po.has(o))return;r.push(o)}else{if(i!==void 0||!Po.has(s))return;i=s}return{negated:r,...i!==void 0&&{pick:i}}}function Ar(e){const t=e.trim();return!/^#[ \t]/.test(t)||Wt(t)?!1:(t.replace(/"(?:[^"\\]|\\.)*"/g,'""').match(/[A-Za-z_]+/g)??[]).some(n=>Po.has(n))}function Tn(e,t){return["#",...yf.filter(n=>n!==e&&(t===void 0||t.includes(n))).map(n=>`-${n}`),"-viz",...e==="none"?[]:[e]].join(" ")}function Bv(e){return e.pick!==void 0?ps(e.pick)?e.pick:"custom":e.negated.includes("viz")?"none":"custom"}function Hv(e){if(e.length===0)return"default";if(e.length>1)return"custom";const t=Wt(e[0]);return t?Bv(t):"custom"}function Uv(e){const t=e.filter(n=>Wt(n));return e.some(Ar)?"custom":t.length===0?void 0:Hv(t)}const Gv=e=>e.filter(t=>Wt(t)||Ar(t)),xf=e=>e.ok===!1,Me=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Ur=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,ke={sourceDefinition:e=>Me(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>Me(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>Me(e,"VIEW","subQueryDefList"),defDimension:e=>Me(e,"defList","DIMENSION"),exploreProperties:e=>Me(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>Me(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>Me(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>Me(e,"WHERE","filterClauseList"),givenDef:e=>Me(e,"givenNameDef"),givenStatement:e=>Me(e,"GIVEN","givenDefList"),importStatement:e=>Me(e,"IMPORT","importURL"),vArrow:e=>Me(e,"ARROW","vExpr","segExpr"),segRefine:e=>Me(e,"PLUS","segExpr"),segOps:e=>Me(e,"queryProperties"),segField:e=>Me(e,"fieldPath")&&!Me(e,"segExpr"),segParen:e=>Me(e,"OPAREN","CPAREN","vExpr"),compare:e=>Me(e,"fieldExpr","compareOp"),givenRef:e=>Me(e,"GIVEN_REF")};function Kv(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 Yv(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
68
- `&&t.push(n+1);return t}class Ha{constructor(t){this.text=t,this.map=Kv(t),this.lineStarts=Yv(t)}map;lineStarts;commentLines=new Set;proseLines=new Set;blocks=[];span(t){if(!Ur(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 Gr(e,t,n=[]){Ur(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)Gr(e.getChild(r),t,n);return n}const Xv=e=>Me(e,"OCURLY","CCURLY");function Dr(e,t){const n=[],r=i=>{if(Ur(i)){if(t(i)){n.push(i);return}if(!Xv(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 De=(e,t)=>e[t]?.call(e),rn=(e,t)=>e[t]?.call(e)??[];function Vv(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 wf(e,t){const n=e.positioned(t);if(!n)return;const r=De(t,"filterClauseList"),i=[];for(const s of r?rn(r,"fieldExpr"):[]){const o=e.positioned(s);if(!o)continue;const a=Gr(s,ke.givenRef).map(c=>e.text_(c)).filter(c=>c!==void 0).map(c=>c.replace(/^\$/,""));i.push({...o,givens:a,binding:Vv(e,s)})}return{...n,clauses:i}}function Ro(e,t){const n=e.span(t);if(!n)return;const r=[],i=[];for(const u of Dr(t,ke.queryStatement)){const l=e.positioned(u);l&&r.push(l);const d=De(u,"whereStatement");if(d&&ke.whereStatement(d)){const h=wf(e,d);h&&i.push(h)}}const s=n.start+1,o=n.end-1,a=!e.text.slice(n.start,n.end).includes(`
69
- `),c=r.length?e.indentAt(r[0].span.start):e.indentAt(n.start)+" ";return{span:n,openEnd:s,closeStart:o,statements:r,wheres:i,indent:c,oneLine:a}}function Ua(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 Zv(e,t){const n=De(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=ke.vArrow(t);if(ke.segOps(n)){const i=De(n,"queryProperties"),s=i&&Ro(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=rn(n,"segExpr"),s=i[0],o=i[i.length-1];let a=s;for(;ke.segRefine(a);){const h=rn(a,"segExpr");if(h.some(f=>ke.segOps(f)||ke.segParen(f)))return{kind:"unsupported",why:"a chained refinement"};a=h[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 c=e.span(s);if(!c||!o)return{kind:"unsupported",why:"an unreadable refinement"};if(!ke.segOps(o)){const h=e.span(n);return h?{kind:"reference",from:e.text.slice(h.start,h.end),fromSpan:h}:{kind:"unsupported",why:"an unreadable refinement"}}const u=e.text.slice(c.start,c.end),l=De(o,"queryProperties"),d=l&&Ro(e,l);return d?{kind:"reference",from:u,fromSpan:c,refinement:d}:{kind:"reference",from:u,fromSpan:c}}return{kind:"unsupported",why:"a parenthesized expression"}}function Qv(e,t){const n=[];for(const r of Dr(t,ke.defExploreQuery)){const i=e.span(r),s=De(r,"subQueryDefList");if(!i||!s)continue;const o=rn(s,"exploreQueryDef").filter(ke.exploreQueryDef),a=e.terminal(De(r,"VIEW"));for(const c of o){const u=e.span(c),l=De(c,"exploreQueryNameDef"),d=e.text_(l),h=De(c,"vExpr");!u||!d||!h||n.push({name:d,span:u,line:e.line(u.start),statement:i,tags:Ua(e,i,a?.start??u.start),siblings:o.length,body:Zv(e,h)})}}return n}function Jv(e,t){const n=[];for(const r of Dr(t,ke.defDimension)){const i=e.span(r),s=De(r,"defList");if(!i||!s)continue;const o=e.terminal(De(r,"DIMENSION"));for(const a of rn(s,"fieldDef")){const c=e.span(a),u=e.text_(De(a,"fieldNameDef"))?.trim(),l=e.text_(De(a,"fieldExpr"))?.trim();!c||!u||l===void 0||n.push({name:u,expression:l,span:c,line:e.line(c.start),statement:i,tags:Ua(e,i,o?.start??c.start)})}}return n}function eb(e,t){const n=[];for(const r of Gr(t,ke.sourceDefinition)){const i=e.span(r),s=e.text_(De(r,"sourceNameDef")),o=De(r,"sqExplore");if(!i||!s||!o)continue;const a=e.span(o),c=a?e.text.slice(a.start,a.end):"",u=(/^\s*(`[^`]*`|[A-Za-z_][A-Za-z0-9_.]*)/.exec(c)?.[1]??"").trim(),l=Dr(o,ke.exploreProperties)[0],d=l&&Ro(e,l),h={start:e.lineStarts[e.line(i.start)],end:i.end},f=[];if(l)for(const m of Dr(l,ke.whereStatement)){const g=wf(e,m);g&&f.push(g)}n.push({name:s,base:u,span:i,line:e.line(i.start),statement:h,...d?{properties:d}:{},views:l?Qv(e,l):[],dimensions:l?Jv(e,l):[],wheres:f})}return n}function tb(e,t){const n=[];for(const r of Gr(t,ke.givenStatement)){const i=e.terminal(De(r,"GIVEN")),s=De(r,"givenDefList"),o=i?e.line(i.start):void 0;for(const a of s?rn(s,"givenDef"):[]){const c=e.span(a),u=e.span(De(a,"givenNameDef")),l=u&&e.text.slice(u.start,u.end);if(!c||!u||!l)continue;const d={start:u.start,end:c.end},h=e.line(d.start);n.push({name:l,declaration:e.text.slice(d.start,d.end),span:d,line:h,statement:{start:e.lineStarts[h],end:d.end},tags:Ua(e,c,d.start),...o!==void 0&&o!==h?{blockHeader:o}:{}})}}return n}function nb(e,t){const n=[];for(const r of Gr(t,ke.importStatement)){const i=e.span(r),s=e.text_(De(r,"importURL"));if(!i||s===void 0)continue;const o=De(r,"importSelect"),a=o?rn(o,"importItem").map(c=>e.text_(c)).filter(c=>c!==void 0).map(c=>c.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 kf(e){let t;try{t=await ms(e,"file://dashboard-builder.malloy")}catch(h){return{ok:!1,reason:`Malloy could not read this file: ${h}`}}const n=t.problems.filter(h=>h.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||!Ur(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 Ha(e),c=Ga(a,s);a.commentLines=c.lines;const u=e.split(`
70
- `),l=h=>c.lines.has(h);a.proseLines=Th(u,l),a.blocks=Mh(u,l).filter(([h])=>!u[h].trimStart().startsWith("##"));const d=eb(a,i);return d.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:nb(a,i),sources:d,givens:tb(a,i),textBlocks:ib(a,s),trailingComment:h=>c.trailing.get(h),comments:c.all,commentLine:h=>c.lines.has(h),proseLine:h=>a.proseLines.has(h),commentIn:h=>c.all.find(f=>f.start>=h.start&&f.start<h.end),blockStart:h=>rb(a,c.lines,h)}}}async function ms(e,t){const{MalloyTranslator:n}=await Bo(),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function Ga(e,t){const n=new Map,r=new Set,i=[],s=t.tokenSource?.vocabulary;for(const l of t.getTokens?.()??[]){const d=s?.getSymbolicName(l.type);if(d!=="COMMENT_TO_EOL"&&d!=="BLOCK_COMMENT")continue;const h=e.utf16(l.startIndex);let f=e.utf16(l.stopIndex+1);if(!(h===void 0||f===void 0||f<h)){for(;f>h&&(e.text[f-1]===`
71
- `||e.text[f-1]==="\r");)f--;i.push({start:h,end:f})}}const o=[...i].sort((l,d)=>l.start-d.start);let a="",c=0;for(const l of o)a+=e.text.slice(c,Math.max(c,l.start)),a+=e.text.slice(Math.max(c,l.start),Math.max(c,l.end)).replace(/[^\n\r]/g," "),c=Math.max(c,l.end);a+=e.text.slice(c);const u=l=>a.slice(e.lineStarts[l],e.lineStarts[l+1]??a.length);for(const l of i){const d=e.line(l.start),h=e.line(l.end-1);for(let g=d;g<=h;g++)u(g).trim()===""&&r.add(g);const f=a.slice(e.lineStarts[d],l.start).trim(),m=a.slice(l.end,e.lineStarts[h+1]??a.length).trim();f!==""&&m===""&&n.set(h,l)}return{trailing:n,lines:r,all:i}}function rb(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(([,c])=>c===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 ib(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 c=Lh(s(n[a]).replace(/\r?\n$/,""));if(!c)continue;const u=[];let l=a+1;for(;i(n[l]??n[a])==="BLOCK_ANNOTATION_TEXT";l++)u.push(s(n[l]));const d=n[l];if(!d||i(d)!=="BLOCK_ANNOTATION_END")continue;const h=e.line(e.utf16(n[a].startIndex)??0),f=e.utf16(d.stopIndex+1)??e.text.length,m=c.name===void 0&&c.rest?[`${c.rest}
72
- `]:[];o.push({...c.name===void 0?{}:{name:c.name},route:c.route,body:[...m,...u].join("").replace(/\r\n?/g,`
73
- `).replace(/\n$/,""),span:{start:e.lineStarts[h],end:f},line:h}),a=l}return o}function Sf(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 Ka(e){let t=0,n=0;for(let r=0;r<e.length;r++){const i=e[r];if(i==='"')r=Sf(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 sb(e,r+s[0].length-1)}}}function sb(e,t){const n=[];let r=0,i=t+1;const s=o=>{const a=e.slice(i,o),c=a.length-a.trimStart().length,u=a.trim();u!==""&&n.push({text:u,span:{start:i+c,end:i+c+u.length}})};for(let o=t+1;o<e.length;o++){const a=e[o];if(a==='"')o=Sf(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 ob(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 ab(e){const t=/^([ \t]*)f(['"])((?:\\.|(?!\2)[^\\])*)\2/;let n="",r=0;for(;r<e.length;){const i=ob(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 $f(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=ab(s);return e([o]).log.length===0?o:s}),i=e(r);return{tag:i.tag,errors:i.log.map(s=>s.message)}}const Ki=e=>e.ok===!1;function Kr(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 Yi=e=>e.map(t=>t.text);function Hl(e){const t=Yi(e),n=Uv(t);return n===void 0?{}:n==="custom"?{chart:n,chartLines:Gv(t)}:{chart:n}}function lb(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:Ah(i),given:o,...s==="~"?{}:{op:s}})}return t.length>0?t:void 0}function cb(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(),...db(n(Yi(Kr(e,t,i.line).tags)).tag)})}return r.length>0?r:void 0}function db(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 Ls(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 ub=/^"((?:[^"\\]|\\.)+)"$/,fb=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/;async function Xi(e,t,n=!1){try{return await hb(e,t,n)}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 hb(e,t,n){const{parseAnnotation:r}=await $c(),i=vh(e),s=await kf(e);if(xf(s))return{ok:!1,reason:s.reason,...s.line?{line:s.line}:{}};const o=s.parsed,a=jc(i).text,c=ts(i);if(c===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};if(!Cc(c.text))return{ok:!1,reason:Oc,line:c.from+1};const{tag:u,errors:l}=$f(r,[bh(c.text)]),d=u?.tag("artifact"),h=d?.text("kind"),f=d?.has("tiles")===!0||u?.tag("dashboard")!==void 0,m=h==="notebook"||h!=="dashboard"&&(n?!f:t?.startsWith("notebooks/"))?"notebook":void 0,g=Ka(c.text);if(g===void 0)return l.length>0?{ok:!1,reason:`The \`## artifact\` tag does not parse: ${l[0]}`}:m==="notebook"?{ok:!1,legacyNotebook:!0,reason:"This notebook is in the cell format, with no `tiles=[…]` list."}:{ok:!1,reason:"The `## artifact` tag has no `tiles=[…]` list the builder can read."};const x=o.imports.map($=>$.names?{kind:"names",names:$.names,from:$.from}:{kind:"all",from:$.from}),w=[],p=[],v=new Map;for(const $ of o.sources){const O={name:$.name,base:$.base};$.dimensions.length>0&&(O.dimensions=$.dimensions.map(I=>({name:I.name,expression:I.expression})));const z=new Set($.wheres.flatMap(I=>I.clauses.flatMap(W=>W.givens)));z.size>0&&(O.scopedBy=Array.from(z)),w.push(O);for(const I of $.dimensions){const W=r(Yi(Kr(o,i,I.line).tags)).tag?.tag("drill");if(!W)continue;const G=W.textArray("to")??[W.text("to")??""];p.push({source:$.name,name:I.name,expression:I.expression,to:G.filter(Boolean),...W.text("given")?{given:W.text("given")}:{}})}v.set($.name,new Map($.views.map(I=>[I.name,I])))}const b=[];for(const{text:$}of g.entries){const O=ub.exec($),z=O?void 0:fb.exec($)?.[1];if(z!==void 0){const T=r([`# ${$}`]).tag?.tag(z);if(T?.text("kind")!=="text")return{ok:!1,reason:`The tile \`${$}\` is neither a quoted \`source -> view\` expression nor a \`${z} { kind=text }\` entry, which are the only forms the builder can lay out.`};if(b.some(R=>Re(R)&&R.name===z))return{ok:!1,reason:`Two text tiles are named \`${z}\`, so the builder cannot tell them apart.`};const _=Ls(T,"colspan");b.push({kind:"text",name:z,markdown:o.textBlocks.find(R=>R.name===z)?.body??"",..._===void 0?{}:{colspan:_},...T.has("break")?{break:!0}:{}});continue}const I=O?.[1]??$,W=O?yh(I):void 0;if(!W)return{ok:!1,reason:`The tile \`${I}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:G,view:q}=W,U=v.get(G)?.get(q);if(U===void 0){b.push({name:q,source:G,declaration:{kind:"inherited"}});continue}const K=r(Yi(U.tags)).tag,V=U.body.kind==="reference"?{kind:"reference",from:U.body.from}:U.body.kind==="inline"?{kind:"inline"}:void 0;if(V===void 0){b.push({name:q,source:G,declaration:{kind:"opaque",why:U.body.kind==="unsupported"?U.body.why:"unreadable"},...K?.text("label")?{label:K.text("label")}:{},...K?.text("subtitle")?{subtitle:K.text("subtitle")}:{},...K?.numeric("colspan")!==void 0?{colspan:K.numeric("colspan")}:{},...Hl(U.tags),...K?.has("break")?{break:!0}:{},...K?.has("borderless")?{borderless:!0}:{}});continue}const re=lb(U.body.kind==="reference"?U.body.refinement:U.body.kind==="inline"?U.body.stage:void 0);b.push({name:q,source:G,declaration:V,...re?{filters:re}:{},...K?.text("label")?{label:K.text("label")}:{},...K?.text("subtitle")?{subtitle:K.text("subtitle")}:{},...K?.numeric("colspan")!==void 0?{colspan:K.numeric("colspan")}:{},...Hl(U.tags),...K?.has("break")?{break:!0}:{},...K?.has("borderless")?{borderless:!0}:{}})}const k=cb(o,i,r),D={},M=d?.tag("givens");for(const $ of Object.keys(M?.dict??{})){const O=M?.text($);O!==void 0&&(D[$]=O)}const A=u?.tag("dashboard")?.has("columns")?Ls(u.tag("dashboard"),"columns"):d?.array("tiles")?Ls(d,"dashboard_columns"):void 0;return{ok:!0,document:{...m?{kind:m}:{},title:d?.text("title")??"",...a?{description:a}:{},...A===void 0?{}:{columns:A},...d?.has("autorun")?{autorun:d.isTrue("autorun")}:{},imports:x,sources:w,...k?{localGivens:k}:{},...Object.keys(D).length>0?{startingGivens:D}:{},...p.length>0?{drills:p}:{},tiles:b}}}const Lo=e=>e.ok===!1;async function Ul(e){const{problems:t}=await ms(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 jf(e){return e.replace(/^(?:[ \t]*\r?\n)+/,"").trimEnd()}function pb(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
77
- `&&t.push(n+1);return t}function mb(e,t){let n=e;for(const r of[...t].sort((i,s)=>s.start-i.start||s.end-i.end))n=n.slice(0,r.start)+r.text+n.slice(r.end);return n}const Cf=e=>e==="none"||ps(e)?e:void 0;function Of(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=${kt(e.label)}`),e.subtitle!==void 0&&n.push(`# subtitle=${kt(e.subtitle)}`);const r=t?Cf(e.chart):void 0;return r!==void 0&&n.push(Tn(r,e.chartCarried)),n}function ji(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const gb=new Set(["colspan","break","borderless","label","subtitle"]),vb=new Set(["label","description","control","suggest","range_min","range_max"]),Xe=e=>e.kind??"dashboard";function Gl(e){const t=[];if(e.label!==void 0&&t.push(`label=${kt(e.label)}`),e.description!==void 0&&t.push(`description=${kt(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=${kt(e.suggest.query)}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${kt(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 Kl=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function bb(e,t,n){const r=e.sources.find(i=>i.name===t)?.views.find(i=>i.name===n);return r?r.line:-1}function Yl(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(t=>`"${t}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Vi=e=>`${e.source}.${e.name}`,kt=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,No=e=>Re(e)?we(["text",e.name]):we([e.name,e.source,e.declaration]),it=No,Xl=e=>we(e.tiles.map(it));function yb(e,t,n,r){if(Xe(e)!==Xe(t)&&!n)return{ok:!1,reason:"The document's kind is not changed by an ordinary edit; switch it with the explicit kind change."};const i=new Set(e.tiles.map(it)),s=new Set(t.tiles.map(it)),o=e.tiles.filter(f=>!s.has(it(f))),a=t.tiles.filter(f=>!i.has(it(f))),c=o.length>0||a.length>0||Xl(e)!==Xl(t);for(const f of a)if(be(f)&&f.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${f.name}\` is ${f.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const u=new Map(e.sources.map(f=>[f.name,f])),l=new Set(t.imports.flatMap(f=>f.kind==="names"?f.names:[]));for(const f of e.sources)l.add(f.base);const d=t.imports.some(f=>f.kind==="all"),h=t.sources.filter(f=>!u.has(f.name));for(const f of e.sources){const m=t.sources.find(g=>g.name===f.name);if(!m||m.base!==f.base)return{ok:!1,reason:`The source \`${f.name}\` cannot be changed or removed here.`}}for(const f of h){if(!a.some(m=>be(m)&&m.source===f.name))return{ok:!1,reason:`A new source \`${f.name}\` needs a tile on it.`};if(!l.has(f.base)&&!d&&!r?.includes(f.base))return{ok:!1,reason:`\`${f.base}\` is not imported in this file, so a tile cannot be put on it.`}}return{currentKeys:i,nextKeys:s,removedTiles:o,addedTiles:a,newSources:h,currentSources:u,reordered:c}}const Vl=(e,t)=>e.colspan!==t.colspan||!!e.break!=!!t.break;function xb(e){let t="";for(let n=0;n<e.length;n++){if(e[n]!=='"'){t+=e[n];continue}const r=Ir(e,n);t+="x".repeat(Math.min(r,e.length-1)-n+1),n=r}return t}function Zl(e,t){if(t===void 0)return`${e.name} { kind=text${e.colspan===void 0?"":` colspan=${e.colspan}`}${e.break?" break":""} }`;const n=xb(t),r=n.indexOf("{"),i=n.lastIndexOf("}");let s=t.slice(r+1,i),o=n.slice(r+1,i);const a=u=>{const l=u.exec(o);l&&(s=s.slice(0,l.index)+s.slice(l.index+l[0].length),o=o.slice(0,l.index)+o.slice(l.index+l[0].length))};a(/\s*\bcolspan\s*=\s*[^\s}]+/),a(/\s*\bbreak\b(?!\s*=)/);const c=[s.trim(),e.colspan===void 0?"":`colspan=${e.colspan}`,e.break?"break":""].filter(Boolean);return`${t.slice(0,r)}{ ${c.join(" ")} }${t.slice(i+1)}`}function wb(e){const{lines:t,wholeLine:n,current:r,next:i,reordered:s,currentKeys:o,nextKeys:a,edits:c}=e,u=new Map(r.tiles.filter(Re).map(p=>[p.name,p])),l=i.tiles.filter(Re).some(p=>{const v=u.get(p.name);return v!==void 0&&Vl(v,p)});if(!s&&!l)return;const d=ts(t);if(!d)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const h=d.text,f=Ka(h);if(!f)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 dashboard with no tiles is not served, so the last tile cannot be removed. Add another tile first."};const m=new Map;for(const{text:p}of f.entries){const v=/^"((?:[^"\\]|\\.)+)"$/.exec(p);if(v){const k=v[1].split("->").map(D=>D.trim());k.length===2&&m.set(`${k[0]}->${k[1]}`,p);continue}const b=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/.exec(p)?.[1];b!==void 0&&m.set(`text.${b}`,p)}const g=i.tiles.map(p=>{const v=!o.has(it(p));if(Re(p)){const b=m.get(`text.${p.name}`);return b!==void 0?u.has(p.name)&&!Vl(u.get(p.name),p)?b:Zl(p,b):v?Zl(p):void 0}return m.get(`${p.source}->${p.name}`)??(v?`"${p.source} -> ${p.name}"`:void 0)});if(g.some(p=>p===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const x=h.slice(0,f.open).search(/tiles\s*=\s*$/),w=`${h.slice(0,x)}tiles=[${kb(h,f,g)}]${h.slice(f.close+1)}`;w!==h&&c.push({...Ef(n,d),text:`${w}
78
- `})}function Ef(e,t){return{start:e(t.from).start,end:e(t.block?t.to-1:t.from).end}}function kb(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
- `)),c=t.entries.length>1?e.slice(r.span.end,t.entries[1].span.start):`,${a.startsWith(`
80
- `)?a:" "}`;return`${s}${n.join(c)}${o}`}function Ql(e,t){let n=0,r=0;for(let i=0;i<e.length;i++){const s=e[i];if(s==='"')i=Ir(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,c=e[a]==='"'?Ir(e,a)+1:a+(/^[^\s}]*/.exec(e.slice(a))?.[0].length??0),u=i-(/\s*$/.exec(e.slice(0,i))?.[0].length??0);return e.slice(0,u)+e.slice(c)}}return e}function Sb(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==='"')n=Ir(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=Ir(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 Ir(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 $b(e){const{lines:t,wholeLine:n,current:r,next:i,edits:s}=e;if(Xe(r)!==Xe(i)||r.title!==i.title||r.autorun!==i.autorun||r.columns!==i.columns||we(r.startingGivens)!==we(i.startingGivens)){const o=ts(t);if(!o)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=Ef(n,o),c=s.find(p=>p.start===a.start&&p.end===a.end);let u=c?c.text.replace(/\n$/,""):o.text;Xe(r)!==Xe(i)&&(u=Ql(u,"kind"));const l=u.indexOf("artifact"),d=u.indexOf("{",l);let h=0,f=-1;for(let p=d;p<u.length;p++)if(u[p]==="{")h++;else if(u[p]==="}"&&--h===0){f=p;break}if(d<0||f<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let m=u.slice(d+1,f);const g=o.block?`
81
- ${/\n([ \t]+)\S/.exec(m)?.[1]??" "}`:" ",x=p=>o.block?`${m.trimEnd()}${g}${p}
82
- `:`${m.trimEnd()} ${p} `,w=(p,v)=>{const b=new RegExp(`${o.block?"[ \\t]*":"\\s*"}\\b${p}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);if(v===void 0){const k=new RegExp(`
83
- ${b.source}[ \\t]*(?=
84
- )`);m=m.replace(o.block&&k.test(m)?k:b,"")}else b.test(m)?m=m.replace(b,k=>`${o.block?k.slice(0,k.length-k.trimStart().length):" "}${p}=${v}`):m=x(`${p}=${v}`)};if(Xe(r)!==Xe(i)&&Xe(i)==="notebook"?m=x("kind=notebook"):Xe(r)!==Xe(i)&&(e.explicitKind||!e.modelPath?.startsWith("dashboards/"))&&(m=x("kind=dashboard")),r.title!==i.title&&w("title",i.title?kt(i.title):void 0),r.autorun!==i.autorun&&w("autorun",i.autorun===void 0?void 0:String(i.autorun)),we(r.startingGivens)!==we(i.startingGivens)){m=m.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const p=Object.entries(i.startingGivens??{});p.length>0&&(m=x(`givens { ${p.map(([v,b])=>`${v}=${kt(b)}`).join(" ")} }`))}o.block?u=`${u.slice(0,d+1)}${m}${u.slice(f)}`:(m=m.replace(/\s{2,}/g," "),u=`${u.slice(0,d+1)}${m.startsWith(" ")?m:` ${m}`}${m.endsWith(" ")?"":" "}${u.slice(f)}`),r.columns!==i.columns&&(u=Ql(u,"dashboard_columns"),u=Sb(u),i.columns!==void 0&&(u=`${u.trimEnd()} dashboard { columns=${i.columns} }`)),c?c.text=`${u}
85
- `:s.push({...a,text:`${u}
86
- `})}if(r.description!==i.description){const{read:o,blankAbove:a,below:c,belowBlock:u,inBlock:l}=jc(t);if(l||i.description===void 0&&u)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 d=jf(i.description??"").split(`
87
- `).map(g=>g.trim()===""?'##"':`##" ${g.trim()}`).join(`
88
- `),h=o.length>0&&o[0]<rl(t),f=i.description===void 0,m=h?[...o.slice(1),...f?c:[]]:[...o,...a];for(const g of m)s.push({...n(g),text:""});if(h)s.push({...n(o[0]),text:i.description===void 0?"":`${d}
89
- `});else if(i.description!==void 0){const g=n(rl(t)).start;s.push({start:g,end:g,text:`${d}
90
- `})}}}function jb(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,c=new Map((i.localGivens??[]).map(f=>[f.name,f])),u=new Map((s.localGivens??[]).map(f=>[f.name,f])),l=new Map(a.givens.map(f=>[f.name,f])),d=new Set;for(const[f,m]of c){const g=u.get(f);if(g!==void 0&&we(g)===we(m))continue;const x=l.get(f);if(x===void 0)return{ok:!1,reason:`Could not find where the given \`${f}\` is declared.`};const{tags:w,prose:p}=Kr(a,t,x.line),v=[...(g===void 0?w:w.filter(A=>{const $=ji(A.text);return $!==void 0&&vb.has($)})).map(A=>A.line),...g===void 0?p:[]];for(const A of v)o.push({...n(A),text:""}),d.add(A);const b=Ct(a,x.span.end-1);if(g===void 0){o.push({start:n(x.line).start,end:n(b).end,text:""});for(let W=x.line;W<=b;W++)d.add(W);const A=Math.min(x.line,...v),$=x.blockHeader??A,O=(t[b+1]??"x").trim()==="",z=$===0||t[$-1].trim()==="",I=x.blockHeader===void 0||![...l.values()].some(W=>W.blockHeader===x.blockHeader&&W.line>x.line&&u.has([...l.entries()].find(([,G])=>G===W)?.[0]??""));O&&z&&I&&!d.has(b+1)&&(o.push({...n(b+1),text:""}),d.add(b+1));continue}const k=r(x.line),D=Gl(g),M=g.type!==m.type||g.default!==m.default?x.blockHeader===void 0?Kl(g):`${g.name} :: ${g.type} is ${g.default}`:t.slice(x.line,b+1).join(`
91
- `).trim();o.push({start:n(x.line).start,end:n(b).end,text:(D?`${k}${D}
92
- `:"")+`${k}${M}
93
- `})}for(const[f,m]of l)m.blockHeader===void 0||u.has(f)||![...l.values()].some(g=>g.blockHeader===m.blockHeader&&!d.has(g.line))&&!d.has(m.blockHeader)&&(o.push({...n(m.blockHeader),text:""}),d.add(m.blockHeader));const h=[...u.values()].filter(f=>!c.has(f.name));if(h.length>0){const f=Math.max(-1,...[...l.values()].map(p=>p.line)),m=(()=>{let p=-1;for(let v=0;v<t.length;v++){const b=t[v].trim();(b.startsWith("import ")||p>=0&&/^}\s*from\s/.test(b))&&(p=v)}return p})(),g=f>=0?f:m,x=h.map(p=>{const v=Gl(p);return(v?`${v}
94
- `:"")+`${Kl(p)}
95
- `}).join(`
96
- `),w=g>=0?n(g).end:n(0).end;o.push({start:w,end:w,text:`
97
- ${x}`}),t.some(p=>p.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
98
- `})}}const Jl=(e,t)=>`import { ${e.join(", ")} } from ${kt(t)}`;function Cb(e){const{parsed:t,current:n,next:r,edits:i,wholeLine:s}=e,o=d=>we(d.imports.flatMap(h=>h.kind==="all"?[h.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(d=>d.kind==="names"?[{...d,claimed:!1}]:[]),c=new Set([...r.sources.map(d=>d.base),...r.tiles.filter(be).map(d=>d.source)]),u=t.imports.map((d,h)=>({statement:d,entry:n.imports[h]}));for(const{statement:d,entry:h}of u){if(!h||h.kind!=="names")continue;const f=a.find(p=>!p.claimed&&p.from===h.from);f&&(f.claimed=!0);const m=f?.names??[],g=h.names.filter(p=>!m.includes(p)).find(p=>c.has(p));if(g!==void 0)return{ok:!1,reason:`\`${g}\` is still read by a tile, so its import cannot be removed.`};if(we(m)===we(h.names))continue;const x=m.length===0?Ya(t,d.statement):d.statement,w=t.commentIn(x);if(w)return{ok:!1,reason:`Changing this import would also remove the comment inside it (\`${t.text.slice(w.start,w.end).trim()}\`), so nothing was written. Delete it in the file first.`};i.push({...x,text:m.length===0?"":Jl(m,h.from)})}const l=a.filter(d=>!d.claimed);if(l.length>0){const d=t.imports.at(-1);if(!d)return{ok:!1,reason:"This file has no `import` to put a source beside. Import its first source in the file."};const h=s(Ct(t,d.statement.end-1)).end;i.push({start:h,end:h,text:l.map(f=>`${Jl(f.names,f.from)}
99
- `).join("")})}}function Ob(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,c=new Map((i.drills??[]).map(l=>[Vi(l),l])),u=new Map((s.drills??[]).map(l=>[Vi(l),l]));for(const l of new Set([...c.keys(),...u.keys()])){const d=c.get(l),h=u.get(l);if(d&&h&&we(d)===we(h))continue;const f=h??d;if(h&&h.to.length===0)return{ok:!1,reason:`The drill on \`${l}\` names no destination.`};const m=a.sources.find(p=>p.name===f.source)?.dimensions.find(p=>p.name===f.name);if(m===void 0)return{ok:!1,reason:`\`${f.name}\` is not a dimension \`${f.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:g}=Kr(a,t,m.line),x=g.find(p=>/^#\s*drill\b/.test(p.text)),w=r(m.line);if(h===void 0)x&&o.push({...n(x.line),text:""});else if(x)o.push({...n(x.line),text:`${w}${Yl(h)}
100
- `});else{const p=n(m.line).start;o.push({start:p,end:p,text:`${w}${Yl(h)}
101
- `})}}}function Eb(e){const{lines:t,wholeLine:n,removedTiles:r,edits:i,parsed:s}=e;for(const o of r){if(Re(o)||o.declaration.kind==="inherited")continue;const a=Tf(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 c=Ct(s,a.statement.start),u=Ct(s,a.statement.end-1),l=s.trailingComment(u),d=l&&l.start>=a.statement.end?l.end:a.statement.end;if(s.text.slice(s.lineStarts[c],a.statement.start).trim()!==""||s.text.slice(d,n(u).end).trim()!==""){i.push({...Ya(s,a.statement),text:""});continue}i.push({start:s.lineStarts[c],end:n(u).end,text:""});const h=c===0?"":t[c-1].trim();(t[u+1]??"x").trim()===""&&(c===0||h===""||h.endsWith("{"))&&i.push({...n(u+1),text:""})}}function Tb(e){const{sourceText:t,lines:n,wholeLine:r,addedTiles:i,newSources:s,currentSources:o,edits:a,parsed:c}=e,u=new Map;for(const h of i){if(Re(h))continue;const f=u.get(h.source)??[];f.push(h),u.set(h.source,f)}const l=(h,f)=>{const m=h.declaration.kind==="reference"?h.declaration.from:h.name,g=(h.filters??[]).map(x=>`where: ${qo(x.field)} ${x.op??"~"} $${x.given}`).join(", ");return[...Of(h).map(x=>`${f}${x}`),`${f}view: ${h.name} is ${m}${g?` + { ${g} }`:""}`].join(`
102
- `)};let d=-1;for(const h of c.sources)d=Math.max(d,Ct(c,h.span.end-1));for(const[h,f]of u)if(o.has(h)){const m=c.sources.find(b=>b.name===h);if(!m)return{ok:!1,reason:`Could not find where the source \`${h}\` is declared.`};if(!m.properties)return{ok:!1,reason:`\`${h}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const g=m.line,x=Ct(c,m.properties.closeStart);let w=" ";for(let b=g+1;b<x;b++){const k=/^(\s+)view:/.exec(n[b]);if(k){w=k[1];break}}const p=r(x).start,v=(n[x-1]??"").trim()==="";a.push({start:p,end:p,text:(v?"":`
103
- `)+f.map(b=>l(b,w)).join(`
104
-
105
- `)+`
106
- `})}else{const m=s.find(v=>v.name===h);if(!m)return{ok:!1,reason:`The tile's source \`${h}\` is not declared.`};const g=`
107
- source: ${m.name} is ${m.base} extend {
108
- `+f.map(v=>l(v," ")).join(`
109
-
110
- `)+`
111
- }
112
- `;let x=d;if(x<0)for(let v=0;v<n.length;v++){const b=n[v].trim();(/^(import\s|given:|}\s*from\s)/.test(b)||/^[A-Z_]+\s*::/.test(b))&&(x=v)}const w=x>=0?r(x).end:t.length,p=w===t.length&&!t.endsWith(`
113
- `)?`
114
- `:"";a.push({start:w,end:w,text:p+g}),d=x}}function Mb(e){const{lines:t,starts:n,wholeLine:r,indentOf:i,current:s,next:o,edits:a,parsed:c}=e,u=new Map(s.tiles.map(l=>[it(l),l]));for(const l of o.tiles){const d=u.get(it(l));if(d===void 0||Re(l)||Re(d)||we(Zi(d))===we(Zi(l)))continue;if(l.declaration.kind==="inherited")return{ok:!1,reason:`\`${l.source} -> ${l.name}\` is declared on its source, not in this dashboard, so its presentation cannot be changed here.`};const h=bb(c,l.source,l.name);if(h<0)return{ok:!1,reason:`Could not find where \`${l.name}\` is declared inside \`${l.source}\`.`};const{tags:f}=Kr(c,t,h),m=i(h),g=Of(l,!1),x=new Map(g.map($=>[ji($)??$,$])),w=new Set,p=Cf(l.chart),v=ec(d)!==ec(l);if(v){const $=f.filter(I=>Ar(I.text)),O=f.filter(I=>Wt(I.text)),z=d.chart==="custom"?f.filter(I=>Wt(I.text)||Ar(I.text)):$.length>0?$:O.length>1?O:[];if(z.length>0)return{ok:!1,reason:`\`${l.source} -> ${l.name}\` has a chart line the builder does not model (${z.map(I=>I.text).join(" and ")}), so its chart cannot be changed here.`}}let b=!1;for(const $ of f){if(v&&Wt($.text)){p===void 0?a.push({...r($.line),text:""}):$.text!==Tn(p,l.chartCarried)&&a.push({...r($.line),text:`${m}${Tn(p,l.chartCarried)}
115
- `}),b=!0;continue}const O=ji($.text);if(O===void 0||!gb.has(O))continue;const z=x.get(O);if(z===void 0){a.push({...r($.line),text:""});continue}w.add(O),z!==$.text&&a.push({...r($.line),text:`${m}${z}
116
- `})}const k=g.filter($=>!w.has(ji($)??$));if(v&&p!==void 0&&!b&&k.push(Tn(p,l.chartCarried)),k.length>0){const $=n[h];a.push({start:$,end:$,text:k.map(O=>`${m}${O}
117
- `).join("")})}if(we(d.filters)===we(l.filters))continue;const D=Tf(e,l);if(!D)return{ok:!1,reason:`Could not find \`${l.name}\`'s declaration to filter it.`};if(D.body.kind==="reference"){const $=Nb(e,l,D);if($)return $;continue}if(D.body.kind!=="inline")return{ok:!1,reason:`\`${l.name}\`'s body is ${D.body.why}, so there is no single first stage to write its filter into.`};const M=Mf(l.filters,D.body.stage);if(M)return Af(l.name,M.given);const A=Df(e,l,D.body.stage);if(A)return A}}const ec=e=>e.chart==="default"?void 0:e.chart,Zi=e=>{const{chartLines:t,chartCarried:n,...r}=e;if(r.chart!=="default")return r;const{chart:i,...s}=r;return s};function Ab(e,t){const n=new Map(e.tiles.map(r=>[it(r),r]));return{...t,tiles:t.tiles.map(r=>{const i=n.get(it(r));return be(r)&&r.chart===void 0&&i&&be(i)&&i.chart!==void 0?{...r,chart:i.chart}:r})}}function Ci(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 Db(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&&!Nh(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=Ci(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 Ns=e=>`##|(markdown) ${e.name}
118
- ${e.markdown===""?"":`${e.markdown}
119
- `}|##
120
- `;function Ib(e){const{sourceText:t,lines:n,wholeLine:r,current:i,next:s,parsed:o,edits:a}=e,c=new Map(i.tiles.filter(Re).map(f=>[f.name,f])),u=s.tiles.filter(Re),l=f=>o.textBlocks.find(m=>m.name===f),d=new Set(u.map(f=>f.name));for(const f of c.keys()){const m=d.has(f)?void 0:l(f);if(!m)continue;const g=Ct(o,m.span.end-1);a.push({...m.span,text:""});const x=r(g+1),w=m.line===0||n[m.line-1].trim()==="";x.end>x.start&&n[g+1].trim()===""&&w?a.push({...x,text:""}):m.line>0&&w&&t.slice(m.span.end).trim()===""&&a.push({...r(m.line-1),text:""})}const h=[];for(const f of u){const m=c.get(f.name),g=l(f.name);if(m===void 0){if(g)return{ok:!1,reason:`A block named \`${f.name}\` is already in this file, so a new text tile cannot take that name.`};h.push(Ns(f))}else m.markdown!==f.markdown&&(g?a.push({...g.span,text:Ns(f)}):h.push(Ns(f)))}if(h.length>0){const f=o.textBlocks.filter(p=>p.name===void 0||d.has(p.name)),m=f[f.length-1],g=o.sources.find(p=>p.name.endsWith("_tiles"));if(m){const p=m.span.end,v=t.slice(p);a.push({start:p,end:p,text:`
121
- ${h.join(`
122
- `)}${v===""||v.startsWith(`
123
- `)?"":`
124
- `}`});return}if(g){const p=e.starts[o.blockStart(g.line)],v=p===0||t.slice(0,p).endsWith(`
125
-
126
- `);a.push({start:p,end:p,text:`${v?"":`
127
- `}${h.join(`
128
- `)}
129
- `});return}const x=t.length,w=t===""||t.endsWith(`
130
-
131
- `)?"":t.endsWith(`
132
- `)?`
133
- `:`
134
-
135
- `;a.push({start:x,end:x,text:w+h.join(`
136
- `)})}}const ai=(e,t=_o)=>t(e)?void 0:`The name ${JSON.stringify(e)} cannot be written as a Malloy name.`;function Pb(e,t){const n=new Map(e.tiles.map(o=>[it(o),o]));if(Xe(t)==="notebook"&&t.columns!==void 0&&(Xe(e)!=="notebook"||t.columns!==e.columns))return"A notebook is one column, so its width is not written. Clear the width when switching a dashboard to a notebook.";const r=new Set;for(const o of t.tiles){const a=n.get(it(o));if(Re(o)){const d=Db(o,a&&Re(a)?a:void 0,r);if(d)return d;continue}const c=a&&be(a)?a:void 0;if(a&&!c)continue;const u=o.chart;if(u!==void 0&&u!=="default"&&u!=="none"&&!ps(u)&&!(u==="custom"&&c?.chart==="custom"))return`"${String(u)}" is not a chart this editor writes.`;const l=new Set(c?.filters?.map(d=>d.field));for(const d of o.filters??[])if(!l.has(d.field)&&/[\r\n]/.test(d.field))return"A filter field is one line.";if(a===void 0){const d=[o.name,o.source];o.declaration.kind==="reference"&&d.push(o.declaration.from);for(const h of d){const f=ai(h);if(f)return f}}for(const d of["label","subtitle"]){const h=o[d];if(h===void 0||h===c?.[d])continue;const f=Bt(`tile ${d}`,h);if(f)return f}}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 c=ai(a);if(c)return c}if(t.description!==e.description)for(const o of(t.description??"").split(/\r?\n/)){const a=Bt("description line",o);if(a)return a}if(t.title!==e.title){const o=Bt("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 u=ai(o.name,Ac);if(u)return u}const c=o.suggest?.source;if(c!==void 0&&c!==a?.suggest?.source){const u=ai(c);if(u)return`The suggest source is not a name. ${u}`}for(const u of["query","dimension"]){const l=o.suggest?.[u];if(l===void 0||l===a?.suggest?.[u])continue;const d=Bt(`suggest ${u}`,l);if(d)return d}for(const u of["label","description"]){const l=o[u];if(l===void 0||l===s.get(o.name)?.[u])continue;const d=Bt(`given ${u}`,l);if(d)return d}}for(const[o,a]of Object.entries(t.startingGivens??{})){if(a===e.startingGivens?.[o])continue;const c=Bt(`starting value for ${o}`,a);if(c)return c}}const Ct=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function Tf(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function Mf(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 Af(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 Oi=e=>`where: ${qo(e.field)} ${e.op??"~"} $${e.given}`;function tc(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 Rb(e,t,n){const r=e.commentIn(n);if(r)return r;const i=e.trailingComment(Ct(e,t.end-1));return i&&i.start>=t.end&&e.text.slice(t.end,i.start).trim()===""?i:void 0}function Lb(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 Ya(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 Df(e,t,n){const{parsed:r,edits:i}=e,s=new Map((t.filters??[]).map(h=>[h.given,h])),o=new Set;let a;for(const h of n.wheres){const f=h.clauses.map((g,x)=>({clause:g,index:x})).filter(({clause:g})=>g.binding!==void 0);if(f.length===0)continue;const m=f.filter(({clause:g})=>s.has(g.binding.given));for(const{clause:g}of f)o.add(g.binding.given);if(m.length===0&&f.length===h.clauses.length){const g=Ya(r,h.span),x=Rb(r,h.span,g);if(x)return tc(t.name,r,x);i.push({...g,text:""});continue}m.length>0&&(a=h.span);for(let g=f.length-1;g>=0;g--){const{clause:x,index:w}=f[g],p=s.get(x.binding.given);if(!p){const b=Lb(h.clauses,w),k=r.commentIn(b);if(k)return tc(t.name,r,k);i.push({...b,text:""});continue}const v=Oi(p).replace(/^where:\s*/,"");v!==r.text.slice(x.span.start,x.span.end)&&i.push({...x.span,text:v})}}const c=(t.filters??[]).filter(h=>!o.has(h.given));if(c.length===0)return;let u=a?.end??(n.statements.length>0?n.statements[n.statements.length-1].span.end:n.openEnd);if(!n.oneLine){const h=r.trailingComment(Ct(r,u));h&&h.start>=u&&(u=h.end)}const l=a!==void 0&&!/,\s*$/.test(r.text.slice(0,u))?", ":" ",d=n.oneLine?`${l}${c.map(Oi).join(", ")}`:c.map(h=>`
138
- ${n.indent}${Oi(h)}`).join("");i.push({start:u,end:u,text:d})}function Nb(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:i,refinement:s}=n.body,o=Mf(t.filters,s);if(o)return Af(t.name,o.given);const a=t.filters??[];if(!s){if(a.length===0)return;const l=` + { ${a.map(Oi).join(", ")} }`;r.push({start:i.end,end:i.end,text:l});return}const c=s.wheres.some(l=>l.clauses.some(d=>!d.binding)),u=s.statements.some(l=>!s.wheres.some(d=>d.span.start===l.span.start));if(a.length===0&&!c&&!u){const l={start:i.end,end:s.span.end},d=e.parsed.commentIn(l);if(d)return{ok:!1,reason:`Removing the last filter from \`${t.name}\` would also remove the comment beside its refinement (\`${e.parsed.text.slice(d.start,d.end).trim()}\`), so nothing was written. Delete it in the file first, or edit the refinement there.`};r.push({...l,text:""});return}return Df(e,t,s)}async function Wb(e,t,n={}){if(!(e.includes(`\r
139
- `)&&!/(?<!\r)\n/.test(e)))return nc(e,t,n);const r=await nc(e.replace(/\r\n/g,`
140
- `),t,n);return Lo(r)?r:{...r,source:r.source.replace(/\n/g,`\r
141
- `)}}async function nc(e,t,n){const r=await Xi(e,n.modelPath);if(Ki(r))return{ok:!1,reason:`Cannot edit a file that will not open: ${r.reason}`};const i=r.document,s=Ab(i,t),o=yb(i,s,n.changeKind===!0,n.visibleSources);if("reason"in o)return o;const a=Pb(i,s);if(a)return{ok:!1,reason:a};const c=await kf(e);if(xf(c))return{ok:!1,reason:`Cannot edit a file that will not open: ${c.reason}`};const u=e.split(`
142
- `),l=pb(e),d=p=>({start:l[p],end:p+1<l.length?l[p+1]:e.length}),h=p=>/^\s*/.exec(u[p])?.[0]??"",f=[],m={...o,sourceText:e,parsed:c.parsed,lines:u,starts:l,wholeLine:d,indentOf:h,current:i,next:s,edits:f,...n.modelPath!==void 0?{modelPath:n.modelPath}:{},...n.explicitKind?{explicitKind:!0}:{}};for(const p of[wb,$b,Cb,jb,Ob,Eb,Tb,Mb,Ib]){const v=p(m);if(v)return v}const g=p=>{const{drills:v,localGivens:b,kind:k,description:D,...M}=p,A=p.tiles.map($=>{if(Re($))return $;if($.filters?.length)return Zi($);const{filters:O,...z}=$;return Zi(z)});return{...M,...D===void 0?{}:{description:jf(D)},...k==="notebook"?{kind:k}:{},tiles:A,...v?.length?{drills:[...v].sort(($,O)=>Vi($).localeCompare(Vi(O)))}:{},...b?.length?{localGivens:b}:{}}};if(f.length===0)return we(g(i))!==we(g(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=mb(e,f);if((await Ul(e)).length===0){const p=await Ul(x);if(p.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${p[0]}). Your changes are still here.`}}const w=await Xi(x,n.modelPath);return Ki(w)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${w.reason}`}:we(g(w.document))!==we(g(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 If({markdown:e,placeholder:t,onCommit:n,variant:r="document"}){const{theme:i}=Qe(),[s,o]=S.useState(!1),a=S.useMemo(()=>s?{text:e}:void 0,[s,e]),{draft:c,patch:u,close:l,discard:d}=Pc(a,s,v=>n(v.text),()=>o(!1)),h=s&&c!==void 0&&c.text!==e,f=c!==void 0&&c.text!==e?Ci(c.text):void 0;nf(h,()=>f!==void 0?!1:(l(),!0));const m=S.useRef(null),g=S.useRef(!1);S.useEffect(()=>{s||(g.current=!1)},[s]);const x=S.useCallback(v=>{!v||g.current||(g.current=!0,v.setSelectionRange(v.value.length,v.value.length))},[]);if(!s||c===void 0){const v=e.trim()?Ci(e):void 0;return y.jsxs(Ae,{role:"button",tabIndex:0,onClick:b=>{b.target.closest("a")?b.preventDefault():o(!0)},onKeyDown:b=>{b.target===b.currentTarget&&(b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),o(!0)))},sx:[{minHeight:24},ef(i,"prose")],children:[e.trim()?y.jsx(wh,{variant:r,children:e}):y.jsx(ue,{variant:"body2",sx:{color:i.tileTitle,opacity:.6,fontStyle:"italic"},children:t}),v&&y.jsx(ue,{variant:"caption",color:"error",role:"alert",children:v})]})}const w=c.text!==e?Ci(c.text):void 0,p=()=>{w===void 0&&l()};return y.jsxs(xe,{spacing:1,children:[y.jsx(et,{multiline:!0,autoFocus:!0,minRows:3,maxRows:14,fullWidth:!0,value:c.text,placeholder:t,error:w!==void 0,helperText:w,inputRef:x,inputProps:{"aria-label":"Markdown"},onChange:v=>u(b=>{b.text=v.target.value}),onKeyDown:v=>{v.key==="Escape"?p():v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),p())},onBlur:v=>{v.relatedTarget instanceof Node&&m.current?.contains(v.relatedTarget)||l()}}),y.jsxs(xe,{ref:m,direction:"row",spacing:1,children:[y.jsx(Ee,{size:"small",variant:"outlined",disabled:w!==void 0,onClick:p,children:"Done"}),y.jsx(Ee,{size:"small",onMouseDown:v=>v.preventDefault(),onClick:()=>{d(),o(!1)},children:"Cancel"})]})]})}const zb="Write markdown: # heading, **bold**, - list";function Fb({tile:e,onChange:t,chrome:n="card"}){return y.jsx(Ji,{chrome:n,kind:"text",children:y.jsx(If,{markdown:e.markdown,placeholder:zb,onCommit:t})})}const Qi=e=>e.label??Ch(`${e.source} -> ${e.name}`);function _b({tile:e,index:t,selected:n,flash:r=!1,menuOpen:i,bare:s=!1,onInsertAfter:o,onSelect:a,onOpenMenu:c,resizing:u=!1,width:l,onResizeStart:d,onResizeMove:h,onResizeEnd:f,children:m}){const{theme:g}=Qe();return y.jsx(_v,{id:ze(e),index:t,children:({ref:x,handleRef:w})=>y.jsxs(Ae,{ref:x,onClick:a,onPointerDown:p=>{p.button===0&&a()},role:"group","aria-label":`Tile ${e.name}`,"aria-current":n,onFocus:a,"data-tile-key":ze(e),"data-flash":r||void 0,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",...Pf(g,{selected:n,flash:r,bare:s}),"&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:g.shadow.drag},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${g.accent}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"@media (hover: none)":{"& .builder-affordance":{opacity:1}}},children:[m,y.jsx(Ae,{ref:w,"aria-label":`Move ${Vr(e)}`,sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}}),y.jsx(Ei,{className:"builder-affordance",size:"small","aria-label":`Settings for ${Vr(e)}`,onClick:p=>{p.stopPropagation(),c(p.currentTarget)},sx:{position:"absolute",top:`${-((s?Ec+1:0)+12)}px`,right:s?0:"12px",border:g.cardBorder,borderRadius:1,width:28,height:24,zIndex:2,color:g.tileTitle,bgcolor:g.tile,opacity:n||i?.9:0,transition:`opacity ${ut}`,...Lt,"&:hover":{opacity:1,bgcolor:g.tile}},children:y.jsx(Ub,{})}),d&&y.jsx(Ae,{className:"builder-affordance",[vf]:"",role:"separator",tabIndex:l?0:-1,"aria-orientation":"vertical","aria-label":`Width of ${Vr(e)}`,...l?{"aria-valuenow":l.span,"aria-valuemin":1,"aria-valuemax":l.columns,"aria-valuetext":`${l.span} of ${l.columns} columns`}:{},onKeyDown:p=>{if(!l)return;const v=p.key==="ArrowRight"?l.span+1:p.key==="ArrowLeft"?l.span-1:p.key==="Home"?1:p.key==="End"?l.columns:void 0;v!==void 0&&(p.preventDefault(),p.stopPropagation(),l.onStep(Math.min(Math.max(v,1),l.columns)))},onPointerDown:d,onPointerMove:h,onPointerUp:f,onPointerCancel:f,onClick:p=>p.stopPropagation(),sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:2,opacity:u||n?1:0,transition:`opacity ${ut}`,...Lt,"&:hover":{opacity:1},"&:focus-visible":{opacity:1,outline:`2px solid ${g.accent}`,outlineOffset:1,borderRadius:"3px"},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:g.accent}}}),o&&y.jsx(Ei,{className:"builder-affordance",size:"small","aria-label":`Insert tile after ${Vr(e)}`,onClick:p=>{p.stopPropagation(),o()},sx:{position:"absolute",bottom:`-${(s?yc:jn)/2+12}px`,left:"50%",transform:"translateX(-50%)",width:24,height:24,zIndex:3,color:g.tileTitle,bgcolor:g.tile,border:g.cardBorder,opacity:0,transition:`opacity ${ut}`,...Lt,"&:hover, &:focus-visible":{opacity:1,bgcolor:g.tile}},children:y.jsx(Pr,{sx:{fontSize:14}})})]})})}const Ws=4,Pf=(e,{selected:t,flash:n=!1,bare:r=!1})=>{const i=t||n?e.accent:"transparent",s=t?e.accent:e.cardBorder.replace(/^1px solid /,""),o=`outline-color ${ut}, border-color ${ut}, opacity ${ut}, box-shadow ${ut}`;return r?{borderRadius:1,"&::before":{content:'""',position:"absolute",inset:`${-Ec}px`,borderRadius:1,border:`2px solid ${i}`,pointerEvents:"none",transition:o,...Lt},"&:hover::before":{borderColor:s}}:{borderRadius:1,outline:`2px solid ${i}`,outlineOffset:2,...n&&{boxShadow:`0 0 0 6px color-mix(in srgb, ${e.accent} 25%, transparent)`},transition:o,...Lt,"&:hover":{outlineColor:s,boxShadow:e.shadow.lift}}};function qb({tile:e,heading:t,note:n,chrome:r="card"}){const{theme:i}=Qe();return y.jsxs(Ji,{chrome:r,children:[y.jsx(Sc,{title:t?.title??Qi(e),subtitle:t?t.subtitle:e.subtitle}),n&&y.jsx(ue,{variant:"body2",sx:{color:i.tileTitle,py:2},children:n}),y.jsxs(ue,{variant:"caption",sx:{display:"block",color:i.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function Bb({after:e}){const{theme:t}=Qe();return y.jsx(qv,{id:sf(e),after:e,children:({ref:n,isDropTarget:r})=>y.jsx(Ae,{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 ${ut}, background-color ${ut}`,...Lt}})})}function Hb({columns:e}){const{theme:t}=Qe();return y.jsx(Ae,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${jn}px`},children:Array.from({length:e},(n,r)=>y.jsx(Ae,{sx:{borderLeft:`1px dashed ${t.accent}`,borderRight:r===e-1?`1px dashed ${t.accent}`:"none",opacity:.35}},r))})}function Ub(){return y.jsxs(Dh,{sx:{fontSize:18},viewBox:"0 0 24 24",children:[y.jsx("circle",{cx:"3.5",cy:"12",r:"2"}),y.jsx("circle",{cx:"12",cy:"12",r:"2"}),y.jsx("circle",{cx:"20.5",cy:"12",r:"2"})]})}function Gb({editor:e,reorder:t,resizing:n,gridBox:r,columns:i,notebook:s,chrome:o,canAdd:a,selected:c,flash:u,menuIndex:l,onSelect:d,onOpenMenu:h,openAdd:f,editTile:m,renderTile:g}){const{dragging:x,preview:w,onDragStart:p,onDragOver:v,onDragEnd:b}=t,{resize:k,startResize:D,onResize:M,endResize:A}=n,$=k!==void 0?e.document.tiles.map((W,G)=>G===k.index?{...W,colspan:k.span}:W):w??e.document.tiles,O=e.document.tiles.length===0,z=x?lv($,i):$.map(rf),I=W=>Kb(W,Qi(W),m);return y.jsxs(y.Fragment,{children:[y.jsx(Bg,{sensors:zv,onDragStart:p,onDragOver:v,onDragEnd:b,children:y.jsxs(Ae,{ref:r,sx:{position:"relative"},children:[!s&&(x||k!==void 0)&&y.jsx(Hb,{columns:i}),y.jsx(rh,{tiles:z,columns:i,rowGapPx:o==="none"?yc:jn,keyOf:W=>W.kind==="gap"?sf(W.after):ze(W.tile),renderTile:W=>{if(W.kind==="gap")return y.jsx(Bb,{after:W.after});const{tile:G,index:q}=W;return y.jsx(_b,{tile:G,index:q,selected:q===c,flash:ze(G)===u,menuOpen:l===q,bare:o==="none",...s&&a?{onInsertAfter:()=>f(q+1)}:{},...i>1&&Yb(G)?{resizing:k?.index===q,width:{span:G.colspan??1,columns:i,onStep:U=>{U!==(G.colspan??1)&&e.update(K=>{const V=K.tiles[q];V&&(V.colspan=U)})}},onResizeStart:U=>D(U,q),onResizeMove:M,onResizeEnd:A}:{},onSelect:()=>d(q),onOpenMenu:U=>h(U,q),children:Re(G)?y.jsx(Fb,{tile:G,chrome:o,onChange:U=>m(ze(G),K=>{Re(K)&&(K.markdown=U)})}):g&&!e.pendingOpen?g(G,I(G),o):y.jsx(qb,{tile:G,chrome:o,heading:I(G),...e.pendingOpen?{note:"Preview appears after you Save"}:{}})})}})]})}),s&&a&&!O&&y.jsx(Ee,{size:"small",startIcon:y.jsx(Pr,{}),"aria-label":"Add tile at the end",onClick:()=>f(),sx:{alignSelf:"center"},children:"Add tile"})]})}const Kb=(e,t,n)=>{if(e.declaration.kind==="inherited")return;const r=ze(e),i=s=>o=>n(r,a=>{be(a)&&(o===""?delete a[s]:a[s]=o)});return{title:y.jsx(Ao,{value:e.label??"",placeholder:t,ariaLabel:"Tile title",onCommit:i("label")}),subtitle:y.jsx(Ao,{value:e.subtitle??"",placeholder:"Add a subtitle",ariaLabel:"Tile subtitle",faintWhenEmpty:!0,onCommit:i("subtitle")})}},Yb=e=>Re(e)||e.declaration.kind!=="inherited";function Xb({editor:e,notebook:t,documentSlug:n,chrome:r,actions:i,descriptionSelected:s,selectDescription:o}){const{theme:a}=Qe();return y.jsxs(y.Fragment,{children:[y.jsxs(xe,{direction:"row",sx:{alignItems:"center",gap:2},children:[y.jsx(ue,{variant:"h5",sx:{flex:1,minWidth:0},children:y.jsx(Ao,{value:e.document.title,placeholder:n??(t?"Untitled notebook":"Untitled dashboard"),ariaLabel:t?"Notebook title":"Dashboard title",onCommit:c=>e.update(u=>{u.title=c})})}),y.jsx(Ae,{sx:{my:"-4px"},children:i})]}),y.jsx(Ae,{role:"group","aria-label":"Description","aria-current":s,onPointerDown:o,onFocus:o,sx:r==="none"?{my:`${th}px`}:void 0,children:y.jsx(Ji,{chrome:r,kind:"text",sx:{position:"relative",overflow:"visible",...Pf(a,{selected:s,bare:r==="none"})},children:y.jsx(If,{markdown:e.document.description??"",placeholder:"Add a description",onCommit:c=>e.update(u=>{c.trim()===""?delete u.description:u.description=c})})})})]})}const Vb=({size:e,notebook:t,savesTo:n,onEvent:r})=>({size:e,saved:({size:i,structural:s,durationMs:o,fromOpen:a})=>r?.(t?{type:"notebook.saved",cells:i,structural:s,converted:a,where:n,durationMs:o}:{type:"dashboard.saved",tiles:i,structural:s,where:n,durationMs:o}),refused:i=>r?.({type:t?"notebook.save_refused":"dashboard.save_refused",reason:i}),undone:({size:i,structural:s,durationMs:o})=>r?.(t?{type:"notebook.save_undone",cells:i,structural:s,where:n,durationMs:o}:{type:"dashboard.save_undone",tiles:i,structural:s,where:n,durationMs:o}),undoRefused:i=>r?.({type:t?"notebook.save_undo_refused":"dashboard.save_undo_refused",reason:i})}),Zb=Rr(y.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),Qb=Rr(y.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),Wo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),zs=Wo?"⌘":"Ctrl+",rc=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},Fs=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function Jb(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=Wo?s.metaKey:s.ctrlKey,c=s.key.toLowerCase();if(s.key==="Escape"){if(rc(s.target)||Fs(s.target))return;o.escape();return}if(rc(s.target)){if(a&&c==="s"){if(s.preventDefault(),!o.save||Fs(s.target))return;s.target.blur(),r(!0)}return}if(Fs(s.target)){a&&c==="s"&&s.preventDefault();return}if(a&&c==="z"){s.preventDefault(),s.shiftKey?o.redo():o.undo();return}if(!Wo&&a&&c==="y"){s.preventDefault(),o.redo();return}if(a&&c==="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 ic={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function ey({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,savesTo:a="package",saveLabel:c,saveButton:u,actions:l,onAddTile:d,onExit:h}){return y.jsxs(xe,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[d&&y.jsx(Ee,{startIcon:y.jsx(Pr,{}),onClick:d,"aria-label":"Add tile",children:"Tile"}),d&&y.jsx(nl,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(en,{title:`Undo (${zs}Z)`,children:y.jsx("span",{children:y.jsx(Ei,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:y.jsx(Qb,{fontSize:"small"})})})}),y.jsx(en,{title:`Redo (${zs}⇧Z)`,children:y.jsx("span",{children:y.jsx(Ei,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:y.jsx(Zb,{fontSize:"small"})})})}),(l||o||h)&&y.jsx(nl,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),l,o?y.jsx(en,{title:i?`Save (${zs}S) · ${c??ic[a]}`:c??ic[a],children:y.jsx("span",{children:y.jsx(Ee,{ref:u,variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{minWidth:124},children:s?"Saving…":i?"Save":"Saved"})})}):null,o&&y.jsx(Ae,{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"}),h&&y.jsx(kh,{label:"Close",icon:y.jsx(Sh,{}),onClick:h})]})}const ty=Rr(y.jsx("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"})),ny=Rr(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function ry({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,addDisabledReason:s,onRemove:o,children:a}){const{theme:c}=Qe();return y.jsx(y.Fragment,{children:y.jsxs(xe,{sx:{gap:1,position:"sticky",top:0,zIndex:nh,bgcolor:"background.default",pb:1},children:[y.jsx(xe,{direction:"row",sx:{gap:2,alignItems:"center",minHeight:32},children:y.jsxs(xe,{direction:"row",role:"group","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",flex:1,minWidth:0},children:[y.jsx(ny,{sx:{fontSize:18,color:c.tileTitle,opacity:.7}}),y.jsx(ue,{variant:"subtitle2",sx:{color:c.tileTitle,mr:.5},children:"Filters"}),e.length===0&&y.jsx(ue,{variant:"body2",sx:{color:c.tileTitle,opacity:.8},children:"None yet."}),e.map(u=>{const l=n(u.name,u.type);return y.jsx(en,{title:l.length>0?`$${u.name} · cannot filter on: ${l.join(", ")}`:`$${u.name} · ${u.origin==="dashboard"?"declared here":"from the model"} · ${u.boundTiles} of ${t} tiles`,children:y.jsx(Us,{size:"small",label:`${u.label??u.name}${u.boundTiles===0?" · unused":""}`,"aria-label":`Edit filter ${u.name}`,color:l.length>0?"warning":"default",variant:u.origin==="dashboard"?"filled":"outlined",onClick:()=>r(u),onDelete:()=>o(u.name),deleteIcon:y.jsx(ty,{"aria-label":`Remove filter ${u.name}`}),sx:{opacity:u.boundTiles===0?.6:1,cursor:"pointer",transition:`opacity ${ut}`,...Lt}})},u.name)}),y.jsx(en,{title:s??"",children:y.jsx("span",{children:y.jsx(Us,{component:"button",size:"small",variant:"outlined",icon:y.jsx(Pr,{}),label:"Filter","aria-label":"Add filter","aria-haspopup":"dialog",disabled:s!==void 0,onClick:()=>i(),sx:{cursor:"pointer",color:c.tileTitle,borderStyle:"dashed","& .MuiChip-icon":{color:"inherit",fontSize:16}}})})})]})}),a]})})}function iy(e,t){const n=new Map(e.tiles.map((r,i)=>[ze(r),{tile:r,index:i}]));for(const[r,i]of t.tiles.entries()){const s=n.get(ze(i));if(!s||s.index!==r||JSON.stringify(s.tile)!==JSON.stringify(i))return ze(i)}}function sy({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(g=>r(x=>typeof x=="object"&&x.tile===g?x:{tile:g}),[]),a=S.useCallback(()=>r(g=>g==="description"?g:void 0),[]),c=S.useCallback(()=>r("description"),[]),u=S.useCallback(()=>r(void 0),[]),[l,d]=S.useState(void 0),h=S.useRef(!1),f=S.useRef(e.document);S.useEffect(()=>{const g=f.current;if(f.current=e.document,!h.current)return;h.current=!1;const x=iy(g,e.document);x!==void 0&&(d(x),Array.from(t.current?.querySelectorAll("[data-tile-key]")??[]).find(w=>w.dataset.tileKey===x)?.scrollIntoView?.({block:"nearest",behavior:eh()}))},[e.document,t]),S.useEffect(()=>{if(l===void 0)return;const g=setTimeout(()=>d(void 0),1500);return()=>clearTimeout(g)},[l]);const m=S.useMemo(()=>({...e,undo:()=>{h.current=!0,e.undo()},redo:()=>{h.current=!0,e.redo()}}),[e]);return{selected:i,descriptionSelected:s,selectTile:o,deselectTile:a,selectDescription:c,clearSelection:u,flash:l,stepEditor:m}}function oy({dirty:e,saving:t,canSave:n,save:r,onExit:i}){const[s,o]=S.useState("idle"),[a,c]=S.useState(!1),u=S.useRef(r);u.current=r;const l=S.useRef(i);l.current=i;const d=S.useRef(0),h=S.useCallback(async()=>{const f=++d.current;c(!1),o("saving");try{await u.current()}catch{d.current===f&&o("idle");return}d.current===f&&c(!0)},[]);return S.useEffect(()=>{if(s==="waiting"){if(t)return;e?h():(o("idle"),l.current())}else if(s==="saving"){if(!a||t)return;o("idle"),e||l.current()}},[s,a,t,e,h]),{requestExit:S.useCallback(()=>{s==="idle"&&(e?o("asking"):l.current())},[s,e]),dialog:{open:s==="asking",canSave:n,onKeepEditing:()=>{s==="asking"&&o("idle")},onDiscard:()=>{s==="asking"&&(o("idle"),l.current())},onSaveAndExit:()=>{s==="asking"&&(t?o("waiting"):h())}}}}function ay({editor:e,onSave:t,onDirtyChange:n,onExit:r,onChange:i,extraDirty:s=!1,report:o,unit:a,prepare:c,shortcuts:u}){const[l,d]=S.useState(!1),[h,f]=S.useState(!1),m=S.useRef(null),g=S.useRef(o);g.current=o;const x=e.dirty||s,w=(e.edited??e.dirty)||s;S.useEffect(()=>{i?.(e.document)},[e.document,i]),S.useLayoutEffect(()=>{n?.(w)},[w,n]);const p=S.useRef(n);p.current=n,S.useEffect(()=>()=>p.current?.(!1),[]);const v=S.useRef(a);v.current=a,S.useEffect(()=>{f(!1)},[e.document]);const b=S.useCallback(()=>{d(!0),f(!1);const q=wt(),{structural:U}=e,K=e.pendingOpen??!1,V=g.current.size;return e.save().then(re=>{re.ok===!0?g.current.saved({size:V,structural:U,fromOpen:K,durationMs:wt()-q}):g.current.refused(re.reason)}).finally(()=>d(!1))},[e]),k=S.useRef(!1),D=S.useRef(!1);S.useEffect(()=>{!D.current||l||(D.current=!1,m.current?.focus())},[h,l]);const M=S.useCallback(()=>{if(!t||l||k.current||!e.canUndoSave)return;k.current=!0,d(!0);const q=wt(),U=e.lastSave?.structural??!1,K=g.current.size;return e.undoSave().then(V=>{V.ok===!0?(D.current=!0,f(!0),g.current.undone({size:K,structural:U,fromOpen:!1,durationMs:wt()-q})):g.current.undoRefused(V.reason)}).finally(()=>{k.current=!1,d(!1)})},[t,l,e]),A=S.useCallback(()=>{if(!(!t||!e.dirty||l))return b()},[t,e,l,b]),$=S.useRef(A);$.current=A;const O=S.useCallback(()=>{const q=()=>$.current();return c?c(q):q()},[c]),z=oy({dirty:w,saving:l,canSave:!!t,save:O,onExit:()=>r?.()});Jb(S.useMemo(()=>({...u,undo:e.undo,redo:e.redo,...t?{save:O}:{},paused:z.dialog.open}),[u,e,t,O,z.dialog.open]));const I=!!t&&!l&&e.canUndoSave,W=e.lastSave,G={canUndo:e.canUndo,canRedo:e.canRedo,onUndo:e.undo,onRedo:e.redo,dirty:x,saving:l,saveButton:m,...t?{onSave:O}:{},...r?{onExit:z.requestExit}:{}};return{saving:l,save:O,exitGuard:z,undoSave:M,canUndoSave:I,lastSave:W,toolbarProps:G}}function li(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function sc(e){for(const t of e??[]){const n=/^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(t.trim())?.[1];if(n&&bf.includes(n))return n}}const ly=1;function Rf(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(...Rf(a,`${t}${s}.`,n-1))}}}return r}function cy(e){const t=new Map;for(const n of Lf(e))t.set(n.name,Rf(n.schema?.fields,"",ly));return t}function Lf(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 dy=e=>(e.annotations??[]).some(t=>{const n=t.value??"";return n.startsWith("#(malloy)")&&Eh.parseTag(n.slice(9)).tag?.has("calculation")===!0});function uy(e){const t=new Map;for(const n of Lf(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(dy)&&r.add(i.name)}t.set(n.name,r)}return t}function oc(e,t){return!e||t===void 0?void 0:e.sources.find(n=>n.name===t)?.fields.filter(n=>n.kind==="dimension")}const zo=e=>(e??"").startsWith("dashboards/"),ac=e=>e.modelPath??e.path??"";function fy(e){const t=[],n=new Set,r=new Map,i=new Map,s=new Map;for(const o of e){const a=ac(o);if(zo(a))continue;const c=Jf(o.modelInfo);i.set(o,c);for(const{name:u}of o.sources??[])u&&s.set(u,[...s.get(u)??[],a]);for(const u of c)r.set(u,[...r.get(u)??[],a])}for(const o of e){const a=ac(o);if(zo(a))continue;const c=cy(o),u=uy(o);for(const l of o.sources??[]){const d=l.name;if(!d||!i.get(o)?.has(d)||n.has(d))continue;n.add(d);const h=(l.givens??[]).map(f=>f.name).filter(f=>typeof f=="string");t.push({name:d,modelPath:a,exporters:r.get(d)??[a],visibleIn:s.get(d)??[a],...li(l.annotations)?{description:li(l.annotations)}:{},views:(l.views??[]).filter(f=>typeof f.name=="string").map(f=>({name:f.name,...li(f.annotations)?{description:li(f.annotations)}:{},...sc(f.annotations)?{chart:sc(f.annotations)}:{},...u.get(d)?.has(f.name)?{aggregateOnly:!0}:{}})),givens:h,fields:c.get(d)??[]})}}return{sources:t}}function hy({editor:e,opened:t,givens:n,catalog:r}){const[i,s]=S.useState(void 0),o=S.useMemo(()=>{const h=new Set((t.localGivens??[]).map(f=>f.name));return(n??[]).filter(f=>!h.has(f.name))},[t,n]),a=S.useMemo(()=>Uh(e.document,o),[e.document,o]),c=S.useMemo(()=>new Map(e.document.sources.map(h=>[h.name,oc(r,h.base)])),[r,e.document.sources]),u=S.useCallback(h=>c.get(h.source)??oc(r,h.source),[c,r]),l=(h,f)=>{const m=[];for(const g of e.document.tiles){if(!be(g))continue;const x=u(g);if(!x)continue;const w=new Map(x.map(p=>[p.name,p.type]));for(const p of g.filters??[])p.given===h&&(!w.has(p.field)||!hi(f,w.get(p.field)))&&m.push(`${p.field} on ${g.label??g.name} (${e.document.sources.find(v=>v.name===g.source)?.base??g.source})`)}return m},d=S.useMemo(()=>a.filter(h=>h.origin==="model"&&h.boundTiles===0),[a]);return{filterDialog:i,setFilterDialog:s,controlList:a,fieldsFor:u,unknownFieldsOf:l,available:d,applyFilter:(h,f,m)=>{s(void 0),e.update(g=>{m&&Qh(g,m),Zh(g,h,f)})},dropControl:h=>{s(void 0),e.update(f=>Jh(f,h))}}}function py({pendingOpen:e,prepare:t}){const[n,r]=S.useState(void 0),i=S.useRef(e);i.current=e;const s=S.useCallback(o=>i.current?new Promise(a=>r({go:()=>{r(void 0),a(t(o))},stop:()=>{r(void 0),a()}})):t(o),[t]);return{confirmConversion:n,prepareSave:s}}function my(e){const{splice:t,onSave:n,structural:r,clearsHistory:i,opensDirty:s=!1}=e,[o,a]=S.useState({stack:[e.document],index:0}),[c,u]=S.useState(e.source),[l,d]=S.useState(void 0),[h,f]=S.useState(e.document),[m,g]=S.useState(s),[x,w]=S.useState(e.replaces),[p,v]=S.useState(!1),b=o.stack[o.index],k=S.useRef(o);k.current=o;const D=S.useRef(!1),[M,A]=S.useState(!1),$=N=>{D.current=N,A(N)},[O,z]=S.useState(void 0),I=S.useCallback(N=>{d(void 0),a(F=>{const ee=structuredClone(F.stack[F.index]);if(N(ee),JSON.stringify(ee)===JSON.stringify(F.stack[F.index]))return F;const J=[...F.stack.slice(0,F.index+1),ee].slice(-100);return{stack:J,index:J.length-1}})},[]),W=S.useCallback(()=>{d(void 0),a(N=>N.index>0?{...N,index:N.index-1}:N)},[]),G=S.useCallback(()=>{d(void 0),a(N=>N.index<N.stack.length-1?{...N,index:N.index+1}:N)},[]),q=S.useCallback(async(N,F)=>{try{return await t(N,F)}catch(ee){return{ok:!1,reason:`Could not build the file: ${ee instanceof Error?ee.message:String(ee)}`}}},[t]),U=S.useCallback(async()=>{if(D.current)return{ok:!1,reason:"A save is still being written."};const N={source:c,saved:h,history:k.current,pendingOpen:m,replacing:x,unwritten:p},F=i?.(h,b)??!1,ee=r?.(h,b)??!1;$(!0);try{const J=await q(c,b);if(Lo(J))return d(J.reason),{ok:!1,reason:J.reason};try{await n?.(J.source,{purpose:"save",document:b})}catch(j){const E=`Could not save: ${j instanceof Error?j.message:String(j)}`;return d(E),{ok:!1,reason:E}}u(J.source),f(b),g(!1),w(void 0),v(!1);const C=F?{stack:[b],index:0}:N.history;return a(j=>j===N.history?C:F?{stack:[j.stack[j.index]],index:0}:j),z(n?{before:N,after:C,lastSave:{before:x??c,after:J.source,structural:ee,clearsHistory:F}}:void 0),d(void 0),{ok:!0}}finally{$(!1)}},[b,q,n,c,h,m,x,p,i,r]),K=S.useCallback(async()=>{if(D.current)return{ok:!1,reason:"A save is still being written."};if(!n||O===void 0||O.after!==k.current)return{ok:!1,reason:"There is no save to undo."};const{before:N}=O;$(!0);try{await n(N.replacing??N.source,{purpose:"undo",document:N.saved})}catch(F){const ee=`Could not undo the save: ${F instanceof Error?F.message:String(F)}`;return d(ee),{ok:!1,reason:ee}}finally{$(!1)}return u(N.source),f(N.saved),g(N.pendingOpen),w(N.replacing),v(N.unwritten||N.replacing!==void 0),a(F=>F===O.after?N.history:F),z(void 0),d(void 0),{ok:!0}},[n,O]),V=S.useMemo(()=>p||JSON.stringify(b)!==JSON.stringify(h),[b,h,p]),re=S.useMemo(()=>r?.(h,b)??!1,[b,h,r]),T=S.useMemo(()=>i?.(h,b)??!1,[b,h,i]),_=O!==void 0&&O.after===o,R=S.useCallback(async()=>{const N=await q(c,b);return Lo(N)?{ok:!1,reason:N.reason}:{ok:!0,source:N.source}},[b,q,c]);return{document:b,saved:h,source:c,canUndo:o.index>0,canRedo:o.index<o.stack.length-1,dirty:V||m,edited:V,pendingOpen:m,...l===void 0?{}:{error:l},update:I,undo:W,redo:G,save:U,preview:R,structural:re,clearsHistory:T,canUndoSave:_&&!M&&n!==void 0,..._?{lastSave:O.lastSave}:{},undoSave:K}}const gy=(e,t)=>{const n=new Set(e.tiles.map(No)),r=new Set(t.tiles.map(No));return[...n].some(i=>!r.has(i))||[...r].some(i=>!n.has(i))};function vy(e){const{conversion:t,modelPath:n,explicitKind:r,visibleSources:i,...s}=e,o=t?.from,a=t?.to,c=S.useCallback((u,l)=>Wb(o!==void 0&&u===o?a:u,l,{changeKind:!0,...n!==void 0?{modelPath:n}:{},...r?{explicitKind:r}:{},...i?{visibleSources:i}:{}}),[o,a,n,r,i]);return my({...s,splice:c,structural:gy,opensDirty:t!==void 0})}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(c=>{i.current=()=>c(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}}const Nf="dashboards/document.malloy",Wf=e=>e.slice(0,e.lastIndexOf("/")+1),zf=(e,t)=>new URL(e,`https://malloy.invalid/${Wf(t)}`).pathname.slice(1);function yy(e,t){const n=Wf(t).split("/").filter(Boolean),r=e.split("/");let i=0;for(;i<n.length&&i<r.length-1&&n[i]===r[i];)i++;const s=n.length-i;return`${s===0?"./":"../".repeat(s)}${r.slice(i).join("/")}`}function xy(e,t,n,r=Nf,i=[n]){return e.sources.some(s=>s.base===t)?!0:e.imports.some(s=>s.kind==="names"?s.names.includes(t):i.includes(zf(s.from,r)))}function wy(e,t,n,r=Nf,i=[n]){const{imports:s}=e;if(xy(e,t,n,r,i))return s;const o=s.findIndex(a=>a.kind==="names"&&i.includes(zf(a.from,r)));return o<0?[...s,{kind:"names",names:[t],from:yy(n,r)}]:s.map((a,c)=>c===o&&a.kind==="names"?{...a,names:[...a.names,t]}:a)}function ky(e,t,{modelPath:n,textHeld:r,notebook:i,insertAt:s}){t.modelPath&&!r&&(e.imports=wy(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));let o=e.sources.find(u=>u.base===t.base);if(!o){const u=new Set(e.sources.map(d=>d.name));let l=`${t.base}_tiles`;for(let d=2;u.has(l);d++)l=`${t.base}_tiles_${d}`;o={name:l,base:t.base},e.sources.push(o)}const a=new Set(e.tiles.filter(be).filter(u=>u.source===o.name).map(u=>u.name));let c=`${t.view}_tile`;for(let u=2;a.has(c);u++)c=`${t.view}_tile_${u}`;e.tiles.splice(s??e.tiles.length,0,{name:c,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 Sy({editor:e,notebook:t,columns:n,modelPath:r,textHeld:i,selectTile:s,deselectTile:o}){const[a,c]=S.useState(void 0),[u,l]=S.useState(!1),[d,h]=S.useState(void 0);return{menu:a,setMenu:c,addingTile:u,openAdd:f=>{h(f),l(!0)},closeAdd:()=>l(!1),addTile:f=>{l(!1),e.update(m=>ky(m,f,{modelPath:r,textHeld:i,notebook:t,insertAt:d})),s(d??e.document.tiles.length)},addText:()=>{l(!1),e.update(f=>{const m=new Set(f.tiles.filter(Re).map(x=>x.name));let g=1;for(;m.has(`text_${g}`);)g++;f.tiles.splice(d??f.tiles.length,0,{kind:"text",name:`text_${g}`,markdown:"",...t?{}:{colspan:n}})}),s(d??e.document.tiles.length)},editTile:(f,m)=>e.update(g=>{const x=g.tiles.find(w=>ze(w)===f);x&&m(x)}),removeTile:f=>{c(void 0),o(),e.update(m=>{m.tiles.splice(f,1)})}}}var $y=Object.defineProperty,jy=Object.defineProperties,Cy=Object.getOwnPropertyDescriptors,lc=Object.getOwnPropertySymbols,Oy=Object.prototype.hasOwnProperty,Ey=Object.prototype.propertyIsEnumerable,cc=(e,t,n)=>t in e?$y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pn=(e,t)=>{for(var n in t||(t={}))Oy.call(t,n)&&cc(e,n,t[n]);if(lc)for(var n of lc(t))Ey.call(t,n)&&cc(e,n,t[n]);return e},mn=(e,t)=>jy(e,Cy(t));function Ty(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function ci(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 My(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const c=(p,v)=>p===v||p!==null&&typeof p=="object"&&"id"in p&&p.id===v;if(Array.isArray(e)){const p=e.findIndex(b=>c(b,s.id)),v=e.findIndex(b=>c(b,o.id));if(p===-1||v===-1){if(_s(s)){const b=s.initialIndex,k=s.index;return b===k||b<0||b>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,b,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const b=s.index;if(b!==p)return n(e,p,b)}return n(e,p,v)}const u=Object.entries(e);let l=-1,d,h=-1,f;for(const[p,v]of u)if(l===-1&&(l=v.findIndex(b=>c(b,s.id)),l!==-1&&(d=p)),h===-1&&(h=v.findIndex(b=>c(b,o.id)),h!==-1&&(f=p)),l!==-1&&h!==-1)break;if(l===-1&&_s(s)){const p=s.initialGroup==null?void 0:ci(e,s.initialGroup),v=s.initialIndex,b=s.group==null?void 0:ci(e,s.group),k=s.index;if(p==null||b==null||p===b&&v===k)return"preventDefault"in t&&t.preventDefault(),e;if(p===b)return mn(pn({},e),{[p]:n(e[p],v,k)});const D=e[p][v];return mn(pn({},e),{[p]:[...e[p].slice(0,v),...e[p].slice(v+1)],[b]:[...e[b].slice(0,k),D,...e[b].slice(k)]})}if(!s.manager)return e;const{dragOperation:m}=s.manager,g=(i=(r=m.shape)==null?void 0:r.current.center)!=null?i:m.position.current;if(f==null){const p=ci(e,o.id);if(p!=null){const v=o.shape&&g.y>o.shape.center.y?e[p].length:0;f=p,h=v}}if(d==null||f==null||d===f&&l===h){if(d!=null&&d===f&&l===h&&_s(s)){const p=s.group==null?void 0:ci(e,s.group),v=s.group!=null&&p!==d,b=s.index!==l;if(v||b){const k=s.group==null?d:p;if(k!=null){if(d===k)return mn(pn({},e),{[d]:n(e[d],l,s.index)});const D=e[d][l];return mn(pn({},e),{[d]:[...e[d].slice(0,l),...e[d].slice(l+1)],[k]:[...e[k].slice(0,s.index),D,...e[k].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===f)return mn(pn({},e),{[d]:n(e[d],l,h)});const x=o.shape&&Math.round(g.y)>Math.round(o.shape.center.y)?1:0,w=e[d][l];return mn(pn({},e),{[d]:[...e[d].slice(0,l),...e[d].slice(l+1)],[f]:[...e[f].slice(0,h+x),w,...e[f].slice(h+x)]})}function Ay(e,t){return My(e,t,Ty)}function Dy({tiles:e,commit:t,onLanded:n}){const[r,i]=S.useState(void 0),s=S.useRef(void 0),[o,a]=S.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),s.current=e},onDragOver:c=>{const{source:u,target:l}=c.operation;if(!u||!l)return;const d=s.current??e;let h;if(l.type===gf){const{after:f}=l.data,m=d.findIndex(x=>ze(x)===u.id);if(m<0||f===u.id)return;const g=d.filter((x,w)=>w!==m).findIndex(x=>ze(x)===f)+1;h=av(d,m,g)}else{const f=d.map(ze),m=Ay(f,c);if(m.every((x,w)=>x===f[w]))return;const g=new Map(d.map(x=>[ze(x),x]));h=ov(m.map(x=>g.get(x)),e.map(x=>x.break??!1))}s.current=h,i(h)},onDragEnd:c=>{a(!1);const u=s.current;if(s.current=void 0,i(void 0),c.canceled||!u)return;t(u);const l=u.findIndex(d=>ze(d)===c.operation.source?.id);l>=0&&n(l)}}}const qs=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Iy({tiles:e,columns:t,gridBox:n,onStart:r,commit:i}){const[s,o]=S.useState(void 0),a=S.useRef(void 0),c=u=>{a.current=u,o(u)};return S.useEffect(()=>()=>qs(!1),[]),{resize:s,startResize:(u,l)=>{const d=n.current?.getBoundingClientRect(),h=u.currentTarget.parentElement?.getBoundingClientRect();if(!d||!h)return;u.stopPropagation(),u.preventDefault(),u.currentTarget.setPointerCapture(u.pointerId),qs(!0),r(l);const f=e[l]?.colspan??1;c({index:l,span:f,from:f,left:h.left,track:(d.width-jn*(t-1))/t})},onResize:u=>{const l=a.current;if(!l)return;const d=u.clientX-l.left,h=Math.round((d+jn)/(l.track+jn)),f=Math.min(Math.max(h,1),t);f!==l.span&&c({...l,span:f})},endResize:u=>{u.currentTarget.hasPointerCapture(u.pointerId)&&u.currentTarget.releasePointerCapture(u.pointerId),qs(!1);const l=a.current;if(!l)return;const{index:d,span:h,from:f}=l;c(void 0),!(u.type==="pointercancel"||h===f)&&i(d,h)}}}function Py({source:e,document:t,onSave:n,onChange:r,onDirtyChange:i,onExit:s,renderTile:o,controls:a,givens:c,catalog:u,toolbar:l,dashboards:d,onEvent:h,conversion:f,savesTo:m="package",saveLabel:g,replaces:x,modelPath:w,explicitKind:p,visibleSources:v,addFilterDisabledReason:b}){const k=vy({source:e,document:t,...n?{onSave:n}:{},...f?{conversion:f}:{},...x!==void 0?{replaces:x}:{},...w!==void 0?{modelPath:w}:{},...p?{explicitKind:p}:{},...v?{visibleSources:v}:{}}),D=S.useRef(null),{selected:M,descriptionSelected:A,selectTile:$,deselectTile:O,selectDescription:z,clearSelection:I,flash:W,stepEditor:G}=sy({editor:k,gridBox:D}),q=k.document.kind==="notebook",U=q?1:k.document.columns??Uf,K=q?"none":"card",V=w?.split("/").at(-1)?.replace(/\.malloy$/,""),re=Dy({tiles:k.document.tiles,commit:Y=>k.update(P=>{P.tiles=Y}),onLanded:$}),{dragging:T}=re,_=Iy({tiles:k.document.tiles,columns:U,gridBox:D,onStart:$,commit:(Y,P)=>k.update(H=>{const oe=H.tiles[Y];oe&&(oe.colspan=P)})}),R=Sy({editor:k,notebook:q,columns:U,modelPath:w,textHeld:v!==void 0,selectTile:$,deselectTile:O}),{menu:N,addingTile:F,openAdd:ee}=R,J=hy({editor:k,opened:t,givens:c,catalog:u}),{filterDialog:C,setFilterDialog:j}=J,[E,Z]=S.useState(void 0),{draftDirty:B,openDraft:te,prepare:X}=by({editorDirty:k.dirty}),{confirmConversion:ne,prepareSave:Q}=py({pendingOpen:k.pendingOpen,prepare:X}),pe=S.useMemo(()=>({escape:()=>{!N&&!C&&!F&&E===void 0&&ne===void 0&&I()},nudge:Y=>{if(T||M===void 0||q)return;const P=k.document.tiles[M];if(!P||be(P)&&P.declaration.kind==="inherited")return;const H=Gf(P.colspan??1,Y,U);H!==(P.colspan??1)&&k.update(oe=>{oe.tiles[M].colspan=H})}}),[k,N,C,F,E,ne,I,M,U,q,T]),L=ay({editor:G,extraDirty:B,prepare:Q,unit:{name:"tile",count:Y=>Y.tiles.length},onSave:n,onDirtyChange:i,onExit:s,onChange:r,shortcuts:pe,report:Vb({size:k.document.tiles.length,notebook:q,savesTo:m,onEvent:h})}),ae=k.document.tiles.length===0,fe=y.jsx(ey,{...L.toolbarProps,...l?{actions:l}:{},...u?{onAddTile:()=>ee()}:{},savesTo:m,...g?{saveLabel:g}:{}});return y.jsx(tf.Provider,{value:te,children:y.jsx(xe,{sx:{gap:0,mx:`-${Ws}px`},children:y.jsxs(xe,{sx:{gap:2,px:`${Ws}px`,pb:`${Ws}px`},children:[k.pendingOpen&&y.jsx(lt,{severity:"info",children:"This notebook is in the cell format. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view."}),y.jsx(Xb,{editor:k,notebook:q,documentSlug:V,chrome:K,actions:fe,descriptionSelected:A,selectDescription:z}),ae?y.jsx(y.Fragment,{children:y.jsxs(xe,{sx:{alignItems:"flex-start",gap:1,py:3,px:2,border:1,borderStyle:"dashed",borderColor:"divider",borderRadius:1},children:[y.jsxs(ue,{variant:"body2",children:["This ",q?"notebook":"dashboard"," is not served until it has a tile."]}),u&&y.jsx(Ee,{size:"small",startIcon:y.jsx(Pr,{}),onClick:()=>ee(),children:"Add tile"})]})}):y.jsx(ry,{controls:J.controlList,tileCount:k.document.tiles.length,unknownFieldsOf:J.unknownFieldsOf,onEdit:Y=>j({control:Y}),onAdd:()=>j({}),...b?{addDisabledReason:b}:{},onRemove:J.dropControl,children:a}),k.error&&y.jsx(lt,{severity:"warning",children:k.error}),y.jsx(Gb,{editor:k,reorder:re,resizing:_,gridBox:D,columns:U,notebook:q,chrome:K,canAdd:!!u,selected:M,flash:W,menuIndex:N?.index,onSelect:$,onOpenMenu:(Y,P)=>{$(P),R.setMenu({anchor:Y,index:P})},openAdd:ee,editTile:R.editTile,...o?{renderTile:o}:{}}),y.jsx(op,{editor:k,catalog:u,columns:U,dashboards:d,bindings:J,tiles:R,drillSource:E,setDrillSource:Z,confirmConversion:ne,exitDialog:L.exitGuard.dialog})]})})})}function Ry(e,t){const n=new Set;for(const s of e.tiles)for(const o of be(s)?s.filters??[]:[])n.add(o.given);const r=[],i=new Set;for(const s of e.localGivens??[])n.has(s.name)&&(i.add(s.name),r.push(Ly(s)));for(const s of t)s.name===void 0||i.has(s.name)||!n.has(s.name)||(i.add(s.name),r.push(s));return r}function Ly(e){const t=Ny(e);return{name:e.name,type:e.type,...t===void 0?{}:{default:t},...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description},...e.control===void 0?{}:{control:e.control},...e.suggest?{suggest:{...e.suggest.source===void 0?{}:{source:e.suggest.source},...e.suggest.query===void 0?{}:{query:e.suggest.query},dimension:e.suggest.dimension}}:{},...e.rangeMin===void 0?{}:{rangeMin:e.rangeMin},...e.rangeMax===void 0?{}:{rangeMax:e.rangeMax}}}function Ny(e){if(!e.type?.startsWith("filter<"))return e.default;const t=e.default?.match(/^f(['"])([\s\S]*)\1$/)?.[2];return t===void 0?e.default:t===""?void 0:t}function Wy(e){return e.kind==="inline"?!0:e.kind==="opaque"&&(e.why.includes("compound")||e.why.includes("pipeline"))}function di(e){return e.split("->").map(t=>t.trim().replace(/\s+/g," ")).join(" -> ").replace(/\s+/g," ")}function zy(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(g=>[g.name,g.type])),c=e.sources.find(g=>g.name===s)?.scopedBy??[],u=new Set([...c,...i??[]].filter(g=>n.has(g))),l=new Set([...c,...i??[]]),d=[];for(const g of t.filters??[]){const x=`where: ${qo(g.field)} ${g.op??"~"}`;if(n.has(g.given)){u.add(g.given),l.add(g.given),d.push(`${x} $${g.given}`);continue}if(!a.has(g.given))continue;l.add(g.given);const w=Oh(r.get(g.given),a.get(g.given));w!==void 0&&d.push(`${x} ${w}`)}const h=d.join(", "),f=t.chart,m=f==="none"||ps(f)?Tn(f,t.chartCarried):f==="custom"&&t.chartLines?.length?t.chartLines.join(`
143
- `):f==="default"&&Wy(t.declaration)?Tn("none"):void 0;return{...m?{annotation:m}:{},expression:`${s} -> ${o}`+(h?` + { ${h} }`:""),givenNames:Array.from(u),reads:i||l.size>0?Array.from(l):void 0}}const Fy={};function _y({textSource:e,kind:t,modelGivens:n,environmentName:r,packageName:i,modelPath:s,slug:o,versionId:a,opened:c,replaces:u,onSave:l,onDirtyChange:d,onExit:h,onEvent:f,savesTo:m,saveLabel:g,note:x}){const{apiClients:w}=vc(),p=t==="notebook",[v,b]=S.useState(c.document.tiles.length>0);S.useEffect(()=>b(c.document.tiles.length>0),[c.generation,c.document]);const{data:k,isSuccess:D,isError:M}=fi({queryKey:["dashboard-editor-manifest",r,i,o,a,t],queryFn:async()=>{if(!p)return(await w.dashboards.getDashboard(r,i,o,a)).data;const L=(await w.notebooks.getNotebook(r,i,s,a)).data;return L.dashboard??{...L.startingGivens?{startingGivens:L.startingGivens}:{},...L.autorun===void 0?{}:{autorun:L.autorun}}},enabled:v&&!e}),A=e?.modelPath??s,$=dh({environmentName:r,packageName:i,modelPath:A,source:c.source,...e?.givens?{givens:e.givens}:{}},{enabled:e!==void 0}),O=$.data?.document,z=e?$.isSuccess?O?.manifest??Fy:void 0:k,I=e?$.isSuccess:D,W=e?$.isError:M,G=e?uh(O?.cells):void 0,q=($.data?.result.problems??[]).filter(L=>L.severity==="error"),U=S.useMemo(()=>new Set(e?.hiddenGivens??[]),[e]),K=e?.givens,V=S.useMemo(()=>new Set((z?.tiles??[]).flatMap(L=>L.restricted&&L.query?[di(L.query)]:[])),[z]),{data:re}=fi({queryKey:["dashboards",r,i,a],staleTime:6e4,queryFn:()=>w.dashboards.listDashboards(r,i,a),enabled:!p}),T=S.useMemo(()=>(re?.data??[]).map(L=>L.name).filter(L=>!!L&&L!==o),[re,o]),{data:_}=fi({queryKey:["dashboard-editor-catalog",r,i,a],queryFn:async()=>{const L=(await w.models.listModels(r,i,a)).data.filter(fe=>fe.path&&!fe.error&&!zo(fe.path)&&!fe.path.startsWith("notebooks/")),ae=(await Promise.allSettled(L.map(fe=>w.models.getModel(r,i,fe.path,a).then(Y=>Y.data)))).flatMap(fe=>fe.status==="fulfilled"?[fe.value]:[]);return fy(ae)}}),R=S.useMemo(()=>e?(_?.sources??[]).filter(L=>(L.visibleIn??L.exporters??[L.modelPath]).includes(A)).map(L=>L.name):void 0,[_,e,A]),N=S.useMemo(()=>_&&R?{sources:_.sources.filter(L=>R.includes(L.name))}:_,[_,R]),[F,ee]=S.useState(c.document);S.useEffect(()=>ee(c.document),[c.document]);const J=S.useMemo(()=>l&&m==="package"?async(L,ae)=>{await l(L),b(ae.document.tiles.length>0)}:l,[l,m]),C=S.useMemo(()=>(z?.givens??(c.conversion?n??[]:[])).filter(L=>!(e&&L.secure===!0)&&!(L.name!==void 0&&U.has(L.name))),[z,c.conversion,n,U,e]),j=S.useMemo(()=>new Set([...C.map(L=>L.name).filter(L=>L!==void 0),...Object.keys(K??{})]),[C,K]),E=S.useMemo(()=>Ry(F,C),[F,C]),{declaredTypes:Z,applied:B,panel:te}=fh({specs:E,loaded:I,startingValues:z?.startingGivens,documentKey:`${r}/${i}/${a??""}/${p?"notebook/":""}${o}/edit`,autorun:z?.autorun!==!1,environmentName:r,packageName:i,modelPath:e?A:z?.path,versionId:a,documentName:o,...G!==void 0?{preamble:G}:{},...K?{hostGivens:K}:{}}),X=S.useMemo(()=>Object.fromEntries(Object.entries(K??{}).filter(([L])=>!Z.has(L))),[K,Z]),ne=!v||I||W,Q=S.useMemo(()=>new Map((z?.tiles??[]).flatMap(L=>L.kind!=="text"&&L.query&&L.givenNames?[[di(L.query),L.givenNames]]:[])),[z]),pe=S.useMemo(()=>function(L,ae,fe="card"){if(!ne)return y.jsxs(Ji,{chrome:fe,children:[y.jsx(Sc,{title:ae?.title??Qi(L),subtitle:ae?ae.subtitle:L.subtitle}),y.jsx(bc,{text:"Running…"})]});const Y=zy(F,L,j,B,Q.get(di(`${L.source} -> ${L.name}`)));return y.jsx(hh,{environmentName:r,packageName:i,versionId:a,modelPath:A,...G!==void 0?{preamble:G}:{},...V.has(di(`${L.source} -> ${L.name}`))?{restricted:!0}:{},tile:Y.expression,...Y.annotation?{annotation:Y.annotation}:{},label:Qi(L),chrome:fe,subtitle:L.subtitle,...ae?{heading:ae}:{},borderless:L.borderless,givens:B,hostGivens:X,declaredTypes:Z,givenNames:Y.givenNames,ignoredFilters:mh(Y.reads,E),height:ph})},[F,ne,j,Q,r,i,a,A,G,V,B,X,Z,E]);return y.jsxs(xe,{sx:{gap:1},children:[e&&q.length>0&&y.jsxs(lt,{severity:"error",children:["The server could not compile this document:"," ",q.map(L=>L.message).join("; ")]}),e&&$.isError&&y.jsxs(lt,{severity:"error",children:["The server could not compile this document:"," ",$.error?.message]}),y.jsx(Py,{...e?{addFilterDisabledReason:"This document holds no given: of its own. Bind a filter the model offers from its chip."}:{},source:c.source,document:c.document,renderTile:pe,givens:E.filter(L=>L.name!==void 0).map(L=>({name:L.name,...L.label?{label:L.label}:{},...L.type?{type:L.type}:{},...L.suggest?.dimension?{field:L.suggest.dimension}:{}})),onChange:ee,onDirtyChange:d,...h?{onExit:h}:{},...c.conversion?{conversion:c.conversion}:{},...N?{catalog:N}:{},dashboards:T,...f?{onEvent:f}:{},controls:I?y.jsx(gh,{...te,layout:p?"panel":"bar"}):void 0,...J?{onSave:J}:{},savesTo:m,...g?{saveLabel:g}:{},...u!==void 0?{replaces:u}:{},modelPath:s,...e?{explicitKind:!0,visibleSources:R}:{}}),y.jsx(Ae,{sx:{px:.5},children:y.jsx(ue,{variant:"caption",sx:{opacity:.7},children:x})})]})}function qy({storage:e,kind:t,notebook:n,environmentName:r,packageName:i,modelPath:s}){const[o,a]=S.useState(void 0),[c,u]=S.useState(void 0),[l,d]=S.useState(e===void 0),[h,f]=S.useState(!1),[m,g]=S.useState(void 0);return S.useEffect(()=>{if(!e)return;let x=!1;return g(void 0),(async()=>{try{const w=sh(await e.listWorkspaces(!1));if(x)return;if(a(w),w!==void 0&&(!n||w.authoritative)){const p=await e.getDocument(xc(t,w.name,r,i,s)).catch(v=>{if(!wc(v))throw v});if(x)return;u(p),f(p!==void 0)}}catch(w){if(x)return;g(kc(w))}x||d(!0)})(),()=>{x=!0}},[e,t,n,r,i,s]),{workspace:o,draft:c,setDraft:u,draftChecked:l,offered:h,setOffered:f,readFailure:m}}const By=e=>e.ok===!1,Qn=(e,t)=>{const n=e[t];return typeof n=="function"?n.call(e):void 0},Hy=[["runStatement","run"],["docAnnotations","notes"],["importStatement","definition"],["defineSourceStatement","definition"],["defineQuery","definition"],["defineGivenStatement","definition"],["defineUserTypeStatement","definition"],["exportStatement","definition"]],Uy=/^[A-Za-z_][A-Za-z0-9_]*$/,Gy="file:///publisher-notebook-builder/notebook.malloy",ui=e=>e.replace(/\r\n?/g,`
144
- `);async function Ky(e){const t=(T,_)=>({ok:!1,refused:`Line ${T+1}: ${_}`,line:T+1}),n=/\r(?!\n)/.exec(e);if(n)return t(e.slice(0,n.index).split(`
145
- `).length-1,"a carriage return that is not part of a CRLF line ending, so the cells cannot be located. Fix: save the file with LF or CRLF line endings.");let r,i;try{r=await ms(e,Gy),i=await Bo()}catch(T){return t(0,`Malloy could not read this notebook: ${T}`)}const s=r.problems.find(T=>T.code==="syntax-error");if(s)return t(s.at?.range?.start?.line??0,`Malloy could not parse this notebook (${s.message??"unknown"}), so it cannot be edited here. Fix: correct the syntax on that line.`);const o=r.parse?.root,a=r.parse?.tokenStream,c=a?.tokenSource?.vocabulary,u=typeof a?.getTokens=="function"?a.getTokens():void 0;if(!o||typeof o.getChild!="function"||!a||!u||typeof c?.getSymbolicName!="function"||u.length===0&&e.trim()!=="")return{ok:!1,refused:"This build of Malloy does not expose a parse tree and token stream the notebook builder can read, so editing is off."};const l=T=>c.getSymbolicName(T.type),d=T=>i.routeOf({value:T.trimStart()}),h=T=>i.payloadOf({value:T}),f=T=>T==="markdown"||T==='"'||T==="text",m=T=>ui(h(T)).replace(/\n$/,""),g=(T,_)=>{const R=h(T).trim(),N=d(T)!=='"'&&Uy.test(R)?"":R;return ui([N&&`${N}
146
- `,..._].join("")).replace(/\n$/,"")},x=new Ha(e),w=Ga(x,a),p=T=>e.slice(x.utf16(T.startIndex),x.utf16(T.stopIndex+1)),v=T=>{const _=T.start?.startIndex,R=T.stop?.stopIndex,N=x.span(T);if(_===void 0||R===void 0||!N)return;let F=N.end;for(;F>N.start&&(e[F-1]===`
147
- `||e[F-1]==="\r");)F--;return{startCp:_,stopCp:R,...N,startLine:x.line(N.start),endLine:x.line(Math.max(N.start,F-1))}},b=T=>{let _=0,R=u.length;for(;_<R;){const N=_+R>>1;u[N].startIndex<T?_=N+1:R=N}return _},k=(T,_)=>{const R=[],N=[],F={lines:[],insertAt:x.utf16(T)};let ee=-2;for(let J=b(T);J<u.length;J++){const C=u[J];if(C.startIndex>_)break;if(C.channel!==0)continue;const j=l(C);if(j!=="ANNOTATION"&&j!=="BLOCK_ANNOTATION_BEGIN"){F.insertAt=x.lineStarts[x.line(x.utf16(C.startIndex))];break}const E=ui(p(C)),Z=[];if(j==="BLOCK_ANNOTATION_BEGIN"){for(;l(u[J+1]??C)==="BLOCK_ANNOTATION_TEXT";)Z.push(p(u[++J]));l(u[J+1]??C)==="BLOCK_ANNOTATION_END"&&J++}if(f(d(E))){const B=x.utf16(C.startIndex),te=x.lineStarts[x.line(B)],X=/^[ \t]*$/.test(e.slice(te,B));N.push({start:X?te:B,end:x.utf16(u[J].stopIndex+1)})}if(j==="ANNOTATION"){const B=E.replace(/\n$/,"");if(Wt(B)){const te=x.utf16(C.startIndex),X=x.lineStarts[x.line(te)];F.lines.push({span:{start:/^[ \t]*$/.test(e.slice(X,te))?X:te,end:x.utf16(C.stopIndex+1)},text:B})}else Ar(B)&&F.unmodelled===void 0&&(F.unmodelled=B.trim())}if(d(E)!=="markdown")ee=-2;else if(j==="BLOCK_ANNOTATION_BEGIN")R.push(g(E,Z)),ee=-2;else{const B=m(E);C.line===ee+1?R[R.length-1]+=`
148
- ${B}`:R.push(B),ee=C.line}}return{markdown:R.length>0?R.join(`
149
-
150
- `):void 0,prose:N,chart:F}},D=[],M=[],A=(T,_,R="remove it, or rewrite it as an import, source:, query:, given:, type: or export statement, a run:, or a `##(markdown)` / `##|(markdown)` prose note.")=>t(T,`${_}, which no notebook cell can hold, so the notebook cannot be edited here. Fix: ${R}`);for(let T=0;T<(o.childCount??0);T++){const _=o.getChild(T);if(!Ur(_)){const C=_?.symbol,j=C?l(C):void 0;if(C&&j==="EOF")continue;if(C&&j==="SEMI"){D.push([C.startIndex,C.stopIndex]);continue}return A((C?.line??1)-1,"a token outside any statement")}const R=v(_);if(!R)return A(0,"a statement with no readable range");const N=Hy.find(([C])=>Qn(_,C)!==void 0);if(!N&&Qn(_,"ignoredObjectAnnotations"))return A(R.startLine,"a # tag that annotates no statement","move the tag directly above its run:, or write trailing prose as a `##(markdown)` note.");if(!N){const C=e.slice(R.start,R.end).split(`
151
- `)[0];return A(R.startLine,`\`${C.trim()}\` is a statement the notebook reader does not recognize`)}D.push([R.startCp,R.stopCp]);const[F,ee]=N;if(ee!=="notes"){const{markdown:C,prose:j,chart:E}=k(R.startCp,R.stopCp);M.push({kind:"statement",run:ee==="run",...C!==void 0&&{markdown:C},prose:j,chart:E,startLine:R.startLine,endLine:R.endLine});continue}const J=Qn(_,F);for(const C of Qn(J,"docAnnotation")??[]){const j=v(C);if(!j)return A(R.startLine,"a note with no readable range");const E=Qn(C,"docBlockAnnotation")!==void 0,Z=u.filter(pe=>pe.startIndex>=j.startCp&&pe.stopIndex<=j.stopCp),B=Z.filter(pe=>l(pe)==="BLOCK_ANNOTATION_TEXT"),te=B[B.length-1]??Z[0],X=ui(E&&te?e.slice(j.start,x.utf16(te.stopIndex+1)).replace(/\r?\n$/,""):e.slice(j.start,j.end)),ne=d(X),Q=f(ne)?E?g(X.split(`
152
- `,1)[0],B.map(p)):m(X):void 0;M.push({kind:"note",note:{text:X,route:ne,...Q!==void 0&&{body:Q},block:E,startLine:j.startLine,endLine:j.endLine}})}}for(const T of u){if(l(T)!=="BLOCK_ANNOTATION_END")continue;const _=p(T).trimStart().replace(/^\|#{1,2}/,"").trim();if(_)return t(T.line-1,`the text after a block's closer (\`${_}\`) is not part of any cell, so the notebook cannot be edited here. Fix: put it on its own line, or inside the block.`)}let $=0;for(const T of u){if(T.channel!==0||l(T)==="EOF")continue;for(;$<D.length&&D[$][1]<T.startIndex;)$++;const[_,R]=D[$]??[1/0,-1/0];if(T.startIndex<_||T.stopIndex>R)return A(T.line-1,"a token outside any statement")}const O=M.findIndex(T=>T.kind==="note"&&Wh(T.note.text));if(O<0)return t(0,"this file has no ## artifact note, so it is not a notebook the builder can edit. Fix: add `## artifact { kind=notebook }` after the ##! line.");const z=M.findIndex((T,_)=>_<O&&T.kind==="statement");if(z>=0)return t(M[z].startLine,'a statement sits above the `## artifact` tag, where only `##!` flags, comments and `"` notes may. Fix: move it below the artifact tag.');for(let T=1;T<M.length;T++){const _=M[T-1],R=M[T],N=_.kind==="note"?_.note.endLine:_.endLine,F=R.kind==="note"?R.note.startLine:R.startLine;if(F<=N)return A(F,"a line holding two statements or notes","put each statement and note on its own line.")}const I=T=>x.lineStarts[T+1]??e.length,W=[];let G=-1,q=!0,U;M.forEach((T,_)=>{if(T.kind==="statement"){q=!1,U=void 0,W.push({cell:{kind:T.run?"query":"definition",...T.markdown!==void 0&&{markdown:T.markdown},...T.prose.length>0&&{prose:T.prose},...T.run&&{chart:T.chart},id:""},startLine:T.startLine,endLine:T.endLine});return}const{note:R}=T;if(!(_>O&&R.body!==void 0)){q&&(G=R.endLine),U=void 0;return}if(q=!1,!R.block&&U&&U.endLine+1===R.startLine){U.cell.markdown+=`
153
- ${R.body}`,U.endLine=R.endLine;return}const N={cell:{kind:"markdown",markdown:R.body,id:""},startLine:R.startLine,endLine:R.endLine};W.push(N),U=R.block?void 0:N});const K={start:0,end:I(G)};let V=G;const re=W.map(({cell:T,startLine:_,endLine:R},N)=>{let F=_;for(;F-1>V&&w.lines.has(F-1);)F--;return V=R,{...T,span:{start:x.lineStarts[F],end:I(R)},id:String(N)}});for(const T of[K,...re.map(_=>_.span)]){const _=w.all.find(R=>R.start<T.start&&R.end>T.start||R.start<T.end&&R.end>T.end);if(_)return A(x.line(_.start),"a comment that straddles a cell","start the comment on its own line.")}return{ok:!0,source:{text:e,header:K,cells:re}}}const Yy=e=>e.ok===!1,Xy=/^[A-Za-z_][A-Za-z0-9_]*$/,dc=/^query\s*:\s*([A-Za-z_][A-Za-z0-9_]*)\s+is\s+/,uc=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;function Bs(e){let t="",n=0;for(;n<e.length;){const r=e.slice(n,n+2);if(r==="//"||r==="--"){const i=e.indexOf(`
154
- `,n),s=i<0?e.length:i;t+=" ".repeat(s-n),n=s}else if(r==="/*"){const i=e.indexOf("*/",n+2),s=i<0?e.length:i+2;t+=e.slice(n,s).replace(/[^\n]/g," "),n=s}else if(e[n]==="'"||e[n]==='"'||e[n]==="`"){const i=e[n];let s=n+1;for(;s<e.length&&e[s]!==i;)s+=e[s]==="\\"?2:1;const o=Math.min(s,e.length);t+=i+e.slice(n+1,o).replace(/[^\n]/g," "),o<e.length&&(t+=i),n=o+1}else t+=e[n],n++}return t}function fc(e){const t=[];let n=0;for(let r=0;r<e.length;r++){const i=e[r];i==="{"||i==="("||i==="["?n++:i==="}"||i===")"||i==="]"?n--:n===0&&i==="-"&&e[r+1]===">"&&t.push(r)}return t}function hc(e,t,n){let r=e;for(const i of[...n].sort((s,o)=>o.start-s.start))r=r.slice(0,i.start-t)+r.slice(i.end-t);return r}function pc(e,t){const n=t.split(`
155
- `).map(r=>r.startsWith("|##")?` ${r}`:r).join(`
156
- `);return`##|(markdown) ${e}
157
- ${n===""?"":`${n}
158
- `}|##
159
- `}function Vy(e){return e.trim()===""?"":/^\s*(#|\/\/|--|\/\*)/.test(e)?` ${e.trimStart()}`:` ${e}`}function Zy(e){const t=(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),n=t.length>40?t.lastIndexOf("_",40):t.length,r=t.slice(0,n>0?n:40);return/^[a-z]/.test(r)&&_o(r)?r:void 0}async function Qy(e){const t=await Ky(e);if(By(t))return{ok:!1,refused:t.refused,line:t.line};const{header:n,cells:r}=t.source,i=(C,j)=>({ok:!1,refused:`Line ${C+1}: ${j}`,line:C+1}),s=e.slice(n.start,n.end).split(`
160
- `),o=ts(s);if(o&&!Cc(o.text))return i(o.from,Oc);if(!o||Ka(o.text))return i(Math.max(o?.from??0,0),"this notebook already lists its tiles, so there is nothing to convert.");const a=(await ms(e,"file:///publisher-notebook-builder/convert.malloy")).parse?.tokenStream,c=a?.tokenSource?.vocabulary,u=a?.getTokens?.()??[];if(typeof c?.getSymbolicName!="function")return i(0,"Malloy's token stream is not available.");const l=await Bo(),{parseAnnotation:d}=await $c(),h=C=>c.getSymbolicName(C.type),f=new Ha(e),m=Ga(f,a),g=C=>e.slice(f.utf16(C.startIndex),f.utf16(C.stopIndex+1)),x=C=>l.routeOf({value:C.trimStart()}),w=C=>l.payloadOf({value:C}),p=C=>C.replace(/\r\n?/g,`
161
- `),v=new Set(e.match(/[A-Za-z_][A-Za-z0-9_]*/g)),b=C=>{let j=C;for(let E=2;v.has(j);E++)j=`${C}_${E}`;return v.add(j),j},k=C=>{const j=u.filter(Q=>Q.channel===0&&f.utf16(Q.startIndex)>=C.span.start&&f.utf16(Q.stopIndex+1)<=C.span.end),E=[],Z=[],B=[];let te;for(let Q=0;Q<j.length;Q++){const pe=h(j[Q]);if(pe!=="ANNOTATION"&&pe!=="BLOCK_ANNOTATION_BEGIN"){te=j[Q];break}let L=Q;const ae=[];if(pe==="BLOCK_ANNOTATION_BEGIN"){for(;h(j[L+1]??j[Q])==="BLOCK_ANNOTATION_TEXT";)ae.push(g(j[++L]));h(j[L+1]??j[Q])==="BLOCK_ANNOTATION_END"&&L++}const fe=p(g(j[Q])),Y=x(fe),P=f.utf16(j[Q].startIndex),H=f.lineStarts[f.line(P)],oe={start:/^[ \t]*$/.test(e.slice(H,P))?H:P,end:f.utf16(j[L].stopIndex+1)};Y==="markdown"?E.push(oe):Y==='"'&&(Z.push(oe),B.push(pe==="ANNOTATION"?p(w(fe)).replace(/\n$/,"").trim():[p(w(fe.split(`
162
- `,1)[0])),...ae.map(p)].map(me=>me.trim()).filter(Boolean).join(" "))),Q=L}if(!te)return;const X=f.utf16(te.startIndex),ne=e.slice(C.span.start,C.span.end);return{cell:C,above:hc(e.slice(C.span.start,X),C.span.start,(C.kind==="query"?[...E,...Z]:E).filter(Q=>Q.end<=X)),statement:e.slice(X,C.span.end).trimEnd(),kept:hc(ne,C.span.start,E),...C.kind==="query"&&B.length>0&&{caption:B.join(" ")},line:f.line(X)}},D=new Map,M=new Map;for(const[C,j]of r.entries()){if(j.kind==="markdown")continue;const E=k(j);if(!E)return i(f.line(j.span.start),"a cell with no statement the converter can place.");M.set(C,E);const Z=dc.exec(E.statement);j.kind==="definition"&&Z&&D.set(Z[1],{expression:E.statement.slice(Z[0].length).trim(),cell:C})}const A=C=>{const j=/^run\s*:\s*/.exec(C.statement);if(!j)return i(C.line,"a run that is not `run: <query>`.");let E=C.statement.slice(j[0].length).trim();const Z=[];for(let Q=0;Q<10;Q++){const pe=Bs(E),L=/^[A-Za-z_][A-Za-z0-9_]*/.exec(pe)?.[0],ae=L?D.get(L):void 0;if(!L||!ae)break;const fe=E.slice(L.length).trim(),Y=pe.slice(L.length).trim();if(Y!==""&&!Y.startsWith("->")&&!Y.startsWith("+"))break;if(Y.startsWith("+")&&fc(Bs(ae.expression)).length!==1)return i(C.line,`\`${L} + { … }\` refines a query with more than one stage, which cannot become one view.`);Z.push(L);const P=/(\/\/|--)[^\n]*$/.test(ae.expression)?`
163
- `:" ";E=`${ae.expression}${fe===""?"":`${P}${fe}`}`}const B=Bs(E);if(D.has(/^[A-Za-z_][A-Za-z0-9_]*/.exec(B)?.[0]??""))return i(C.line,"this run names a query defined through more than 10 other queries, which the converter does not follow.");const te=fc(B);if(te.length===0)return i(C.line,"this run is not `source -> view`, so it cannot become a tile. Fix: write it as `run: <source> -> <view>`.");const X=E.slice(0,te[0]).trim();if(/\bextend\b/.test(B.slice(0,te[0])))return i(C.line,"this run extends its source inline before `->`, so it cannot become a tile. Fix: declare the extension with a `source:` statement and run that.");if(!Xy.test(X)&&!/^`[^`]+`$/.test(X))return i(C.line,"the source of this run is not a name, so it cannot become a tile. Fix: name it with a `source:` statement and run that.");const ne=E.slice(te[0]+2).trim();return ne===""?i(C.line,"this run has nothing after `->`."):{source:X,body:ne,used:Z}},$=new Map,O=[],z=new Set,I=new Map;let W=0,G=0;const q=new Map;for(const C of M.values()){if(C.cell.kind!=="query")continue;const j=A(C);if("ok"in j)return j;for(const E of j.used)q.set(E,(q.get(E)??0)+1)}const U=C=>q.get(C)===1&&(e.match(new RegExp(`\\b${C}\\b`,"g"))??[]).length===2,K=new Map;for(const[C,j]of r.entries()){if(j.kind==="markdown"){const Y=b(`text_${++W}`);O.push(`${Y} { kind=text }`);const P=m.all.filter(H=>H.start>=j.span.start&&H.end<=j.span.end).map(H=>`${e.slice(H.start,H.end)}
164
- `).join("");I.set(C,P+pc(Y,j.markdown??""));continue}const E=M.get(C);let Z="";if(j.markdown!==void 0){const Y=b(`text_${++W}`);O.push(`${Y} { kind=text }`),Z=`${pc(Y,j.markdown)}
165
- `}if(j.kind==="definition"){const Y=dc.exec(E.statement)?.[1];if(Y&&U(Y)){z.add(C),K.set(Y,E.above.split(`
166
- `).filter(P=>P.trim()!=="")),Z&&I.set(C,Z.replace(/\n$/,""));continue}I.set(C,`${Z}${E.kept}`);continue}const B=A(E),te=B.source.replace(/`/g,"").replace(/[^A-Za-z0-9_]+/g,"_").replace(/^(?=[0-9])/,"_");let X=$.get(B.source);X||(X={name:b(`${te}_tiles`),base:B.source,views:[]},$.set(B.source,X));const ne=[...B.used.flatMap(Y=>K.get(Y)??[]),...E.above.split(`
167
- `)].filter(Y=>Y.trim()!==""),Q=ne.filter(Y=>/^\s*#(?!["(|])/.test(Y)),pe=Q.length>0?$f(d,Q).tag:void 0,L=b(Zy(pe?.text("label")??E.caption)??`tile_${G+1}`);G++,O.push(`"${X.name} -> ${L}"`);const ae=ne.map(Vy);if(E.caption!==void 0){const Y=Bt("caption",E.caption)===void 0;Y&&!pe?.has("label")?ae.push(` # label=${uc(E.caption)}`):Y&&!pe?.has("subtitle")?ae.push(` # subtitle=${uc(E.caption)}`):ae.push(` #" ${E.caption}`)}const fe=B.body.split(`
168
- `).map((Y,P)=>P===0||Y.trim()===""?Y:` ${Y}`).join(`
169
- `);X.views.push([...ae,` view: ${L} is ${fe}`].join(`
170
- `)),z.add(C),Z&&I.set(C,Z.replace(/\n$/,""))}const V=(()=>{let C=0;const j=o.text;for(let E=j.indexOf("{");E<j.length;E++)if(j[E]==='"')for(E++;E<j.length&&j[E]!=='"';E++)j[E]==="\\"&&E++;else if(j[E]==="{")C++;else if(j[E]==="}"&&--C===0)return E;return-1})();if(V<0)return i(o.from,"the `## artifact { … }` tag never closes.");const re=O.length===0?`
171
- tiles=[]
172
- `:`
173
- tiles=[
174
- ${O.map(C=>` ${C}`).join(`,
175
- `)}
176
- ]
177
- `,T=`${o.text.slice(0,V).trimEnd().replace(/^##(?!\|)/,"##|")}${re}${o.text.slice(V)}`;s.splice(o.from,o.block?o.to-o.from:1,...(o.block?T:`${T}
178
- |##`).split(`
179
- `));const _=C=>{const j=C.text.split(`
180
- `),E=j.pop(),Z=[];let B=0;for(const te of j){const X=C.at[B]??-1,ne=m.all.some(Q=>X>=Q.start&&X<Q.end);(te.trim()!==""||Z.at(-1)?.trim()!==""||ne)&&Z.push(te),B+=te.length+1}return Z.map(te=>`${te}
181
- `).join("")+E},R={text:"",at:[]},N=(C,j)=>{R.text+=e.slice(C,j);for(let E=C;E<j;E++)R.at.push(E)};let F=s.join(`
182
- `),ee=n.end;for(const[C,j]of r.entries()){N(ee,j.span.start),ee=j.span.end;const E=I.get(C);E!==void 0&&(F+=_(R)+(E.endsWith(`
183
- `)?E:`${E}
184
- `),R.text="",R.at=[])}N(ee,e.length),F=`${F.trimEnd()}
185
- `+(R.text.trim()===""?"":_(R)),F=`${F.trimEnd()}
186
- `;const J=[...$.values()].map(C=>`source: ${C.name} is ${C.base} extend {
187
- ${C.views.join(`
188
-
189
- `)}
190
- }
191
- `);return J.length>0&&(F+=`
192
- ${J.join(`
193
- `)}`),e.includes(`\r
194
- `)&&(F=F.replace(/\r?\n/g,`\r
195
- `)),{ok:!0,text:F,tiles:O.length}}const Hs=(e,t)=>t!==void 0&&!/\bline \d+/i.test(e)?`${e} (line ${t})`:e;async function Jy(e,t,n=!1){const r=await Xi(e,t,n);if(!Ki(r))return{ok:!0,document:r.document};if(!r.legacyNotebook)return{ok:!1,reason:Hs(r.reason,r.line)};const i=await Qy(e);if(Yy(i))return{ok:!1,reason:Hs(i.refused,i.line)};const s=await Xi(i.text,t,n);return Ki(s)?{ok:!1,reason:`The converted notebook cannot be opened: ${Hs(s.reason,s.line)}`}:{ok:!0,document:s.document,conversion:{from:e,to:i.text}}}const mc="a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` notebook under notebooks/ to edit it here.",gc="the server did not send this notebook's text, so there is nothing here to edit. Fix: edit the file in the package.";function ex({workspace:e,draft:t,draftChecked:n,readFailure:r,packageText:i,fetchedAt:s,packageSettled:o,modelPath:a,notebook:c,noun:u,refusedEvent:l,legacyFormat:d,textHeld:h,startedAt:f,onEventRef:m}){const g=e?.authoritative===!0,x=g&&r!==void 0,[w,p]=S.useState(void 0),v=(g||w===!0)&&t!==void 0,[b,k]=S.useState(void 0),[D,M]=S.useState(d?mc:void 0),A=S.useRef(void 0),$=S.useRef(void 0),[O,z]=S.useState(void 0),I=S.useRef(s);I.current=s;const W=O!==void 0&&O.onFetch===s?O.text:i,G=S.useRef(W);G.current=W;const q=v?t:W,[U,K]=S.useState(!1),[V,re]=S.useState(void 0),[T,_]=S.useState(void 0),R=q!==void 0&&q!==T,N=b?.source,F=R&&(U||!g&&t!==void 0&&N===t&&t!==W)&&N!==void 0&&q!==V,ee=F?N:R?q:N??q,J=F?q:void 0,C=S.useRef(N);C.current=N;const j=S.useRef(q);j.current=q;const E=S.useRef("package");E.current=v?g?"record":"draft":"package",S.useEffect(()=>{if(ee===void 0||!n||x||ee===C.current)return;let B=!1;const te=G.current,X=j.current;return Jy(ee,a,h).then(ne=>{if(!B){if(ne.ok===!1){M(ne.reason),m.current?.({type:l,reason:ne.reason});return}M(void 0),A.current=void 0,$.current=te,z(void 0),re(void 0),_(X),k(Q=>({source:ee,document:ne.document,...ne.conversion?{conversion:ne.conversion}:{},...te!==void 0?{packageText:te}:{},generation:(Q?.generation??0)+1})),m.current?.(c||ne.document.kind==="notebook"?{type:"notebook.opened",from:E.current==="package"?"package":"record",cells:ne.document.tiles.length,durationMs:wt()-f.current}:{type:"dashboard.opened",from:E.current,tiles:ne.document.tiles.length,durationMs:wt()-f.current})}}).catch(ne=>{if(B)return;const Q=`Could not read the ${u}: ${ne instanceof Error?ne.message:String(ne)}`;M(Q),m.current?.({type:l,reason:Q})}),()=>{B=!0}},[ee,a,n,x,c,u,l,h,f,m]),S.useEffect(()=>{d&&m.current?.({type:"notebook.open_refused",reason:mc})},[d,m]),S.useEffect(()=>{!h||!n||b||r!==void 0||(g?t===void 0&&M("the host's storage has no document at this location."):M("a document held as text needs a storage whose workspace is authoritative. Fix: mark the workspace that keeps it `authoritative`."))},[h,n,b,r,g,t]);const Z=c&&!h&&!b&&n&&!v&&o&&i===void 0;return S.useEffect(()=>{Z&&(M(gc),m.current?.({type:"notebook.open_refused",reason:gc}))},[Z,m]),{authoritative:g,blockedOnRecord:x,resume:w,setResume:p,fromDraft:v,opened:b,setOpened:k,openError:D,savedHashRef:A,packageBaseRef:$,setWrote:z,fetchedAtRef:I,setDirty:K,setSeen:_,held:J,choose:B=>{f.current=wt(),re(B?t:W),p(B)},acceptHeld:()=>{f.current=wt(),re(J)}}}function tx({storage:e,workspace:t,kind:n,notebook:r,environmentName:i,packageName:s,modelPath:o,versionId:a,apiClients:c,queryClient:u,mutable:l,textHeld:d,readFailure:h,authoritative:f,resume:m,setResume:g,setOpened:x,setDraft:w,setOffered:p,setSeen:v,setWrote:b,savedHashRef:k,packageBaseRef:D,fetchedAtRef:M}){const A=t===void 0?void 0:xc(n,t.name,i,s,o),$=S.useCallback(async V=>{if(!e||!A)throw new Error("This host keeps no documents, so there is nowhere to save.");await e.saveDocument(A,V),x(re=>re&&{...re,source:V}),w(V),(f||m===!0)&&v(V),f||g(re=>re??!1)},[e,A,f,m,x,w,v,g]),[O,z]=S.useState(void 0),I=S.useCallback(async V=>{const re=await oh(k.current,D.current);if(re===void 0)throw new Error("The package file is still loading; try again.");const T=["dashboard-editor-model",i,s,o,a,r];await ah({apiClients:c,queryClient:u,environmentName:i,packageName:s,modelPath:o,source:V,expectedHash:re,invalidateOnError:[T],afterWrite:async _=>{if(x(R=>R&&{...R,source:V}),b({text:V,onFetch:M.current}),v(V),k.current=_,z(void 0),e&&A)try{await e.deleteDocument(A),w(void 0),p(!1)}catch(R){wc(R)?(w(void 0),p(!1)):z(kc(R))}g(!1)},invalidate:[{queryKey:T,wait:!0},{queryKey:lh({environmentName:i,packageName:s,versionId:a,modelPath:o})},{queryKey:["dashboard-editor-manifest"]},{queryKey:["dashboards"]},{queryKey:["dashboard"]},...r?[{queryKey:[ch({environmentName:i,packageName:s,modelPath:o})]}]:[]]})},[c,i,s,o,a,r,e,A,u,k,D,M,x,b,v,w,p,g]),W=t?.writeable===!0,G=l===!0&&!d,{savesTo:q,pinnedPackageSave:U,writer:K}=jh({authoritative:f,mutable:G,...a!==void 0?{versionId:a}:{},canStore:!!e&&!!A&&W&&(!r||f),readFailed:h!==void 0});return{save:K==="storage"?$:K==="package"?I:void 0,savesTo:q,writer:K,pinnedPackageSave:U,takesWrites:G,supersedeFailure:O}}function nx(e){const{onEvent:t,onDirtyChange:n,onExit:r,kind:i="dashboard",path:s,textSource:o}=e,a=i==="notebook",c=o!==void 0,{environmentName:u,packageName:l,versionId:d,namesBoth:h}=Kf(e),f="resourceUri"in e?e.dashboard:e.dashboardName,m=a?"notebook":"dashboard",g=a?"notebook.open_refused":"dashboard.open_refused",{apiClients:x,mutable:w,isLoadingStatus:p}=vc(),v=Yf(),b=S.useRef(wt()),k=S.useRef(t);k.current=t;const D=S.useRef(n);D.current=n;const M=Xf()?.documentStorage,A=a&&/\.malloynb$/i.test(f),$=s??`${i}s/${f}.malloy`,O=fi({queryKey:["dashboard-editor-model",u,l,$,d,a],queryFn:()=>x.models.getModel(u,l,$,d,a?!0:void 0),enabled:h&&!A&&!c}),z=O.data?.data?.sourceText,{workspace:I,draft:W,setDraft:G,draftChecked:q,offered:U,setOffered:K,readFailure:V}=qy({storage:M,kind:i,notebook:a,environmentName:u,packageName:l,modelPath:$}),{authoritative:re,blockedOnRecord:T,resume:_,setResume:R,fromDraft:N,opened:F,setOpened:ee,openError:J,savedHashRef:C,packageBaseRef:j,setWrote:E,fetchedAtRef:Z,setDirty:B,setSeen:te,held:X,choose:ne,acceptHeld:Q}=ex({workspace:I,draft:W,draftChecked:q,readFailure:V,packageText:z,fetchedAt:O.dataUpdatedAt,packageSettled:O.isSuccess&&!O.isFetching,modelPath:$,notebook:a,noun:m,refusedEvent:g,legacyFormat:A,textHeld:c,startedAt:b,onEventRef:k}),{save:pe,savesTo:L,writer:ae,pinnedPackageSave:fe,takesWrites:Y,supersedeFailure:P}=tx({storage:M,workspace:I,kind:i,notebook:a,environmentName:u,packageName:l,modelPath:$,versionId:d,apiClients:x,queryClient:v,mutable:w,textHeld:c,readFailure:V,authoritative:re,resume:_,setResume:R,setOpened:ee,setDraft:G,setOffered:K,setSeen:te,setWrote:E,savedHashRef:C,packageBaseRef:j,fetchedAtRef:Z}),H=I?.name,oe=S.useCallback(xt=>{k.current?.(Vf(xt,H))},[H]),me=S.useCallback(xt=>{B(xt),D.current?.(xt)},[B]),Fe=L==="host"&&I?.description?I.description:void 0,Yn=!re&&!c&&w===void 0?p?"Checking whether this server takes writes.":"This server did not say whether it takes writes, so Save is off.":Zf({authoritative:re,mutable:Y,pinnedPackageSave:fe,...I?{workspace:I}:{},...V!==void 0?{readFailure:V}:{},...d!==void 0?{versionId:d}:{}}),_t=Yn===Fe?"":Yn;if(!h&&"resourceUri"in e)return y.jsxs(lt,{severity:"error",sx:{m:2},children:["A ",m," resource URI must name an environment and a package. Received: ",e.resourceUri]});if(J)return y.jsxs(lt,{severity:"error",sx:{m:2},children:["This ",m," cannot be opened in the builder: ",J]});if(O.isError&&!F)return y.jsx(Qf,{error:O.error,context:`Opening the ${m}`});if(!F&&(!(c||z)||!q))return y.jsx(bc,{text:`Opening the ${m}…`});if(T)return y.jsxs(lt,{severity:"error",sx:{m:2},children:["This ",m," cannot be opened: ",V]});const Yr=W!==void 0&&W!==z;return y.jsxs(xe,{sx:{gap:2},children:[O.isError&&y.jsxs(lt,{severity:"warning",children:["The ",m," could not be re-read from the server:"," ",O.error?.message,". Your edits are still here."]}),!a&&!re&&U&&Yr&&_===void 0&&y.jsx(lt,{severity:"info",action:y.jsxs(xe,{direction:"row",sx:{gap:1},children:[y.jsx(Ee,{size:"small",onClick:()=>ne(!0),children:"Resume"}),y.jsx(Ee,{size:"small",onClick:()=>ne(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),X!==void 0&&y.jsx(lt,{severity:"warning",action:y.jsx(Ee,{size:"small",onClick:Q,children:"Load it"}),children:L==="package"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":L==="host"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them."}),P!==void 0&&y.jsxs(lt,{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:"," ",P]}),F&&y.jsx(_y,{kind:i,environmentName:u,packageName:l,modelPath:$,...o?{textSource:o}:{},slug:f,modelGivens:O.data?.data?.givens,...d!==void 0?{versionId:d}:{},opened:F,...N&&ae==="package"&&F.packageText!==void 0?{replaces:F.packageText}:{},onSave:pe,onDirtyChange:me,...r?{onExit:r}:{},savesTo:L,...Fe?{saveLabel:Fe}:{},...t?{onEvent:oe}:{},note:_t},F.generation)]})}function sx(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 y.jsx(nx,{...s,kind:"notebook",...t?{onEvent:t}:{},...n?{onDirtyChange:n}:{},...r?{onExit:r}:{},...i!==void 0?{path:i}:{}})}typeof globalThis.process>"u"?globalThis.process={env:{}}:il===void 0&&(il={});export{Py as DashboardBuilder,nx as DashboardEditor,lx as MAX_SLUG_ATTEMPTS,sx as NotebookEditor,fy as buildCatalog,cx as createDocument,dx as createRoute,ux as documentPathFor,fx as documentPathForTitle,xc as locatorFor,hx as newDashboardSource,px as newDocumentProblem,mx as newNotebookSource,Xi as readDashboardDocument,Ki as readFailed,gx as slugFor,vx as slugOrFallback,Wb as spliceDashboardDocument,Lo as spliceFailed,bx as useDocumentChoices};