@malloy-publisher/sdk 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{RenderedResult-DZj-FnOJ.es.js → RenderedResult-BHuJpdSn.es.js} +2 -2
- package/dist/{RenderedResult-BrvrMDAP.cjs.js → RenderedResult-Bw7EQc42.cjs.js} +1 -1
- package/dist/ServerProvider-B0dUY8be.cjs.js +1 -0
- package/dist/{ServerProvider-B_bPAsu2.es.js → ServerProvider-CQy4jVYK.es.js} +1394 -1051
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +412 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +125 -114
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -3
- package/dist/index.cjs.js +9 -9
- package/dist/index.es.js +2112 -2063
- package/dist/{useCompiledDocument-x0B2RAH3.es.js → useCompiledDocument-1dgF5CC9.es.js} +2 -2
- package/dist/{useCompiledDocument-oocN5cGE.cjs.js → useCompiledDocument-BKyRnXmA.cjs.js} +2 -2
- package/package.json +1 -1
- package/src/components/Package/ContentTypeIcon.tsx +16 -3
- package/src/components/Package/Package.agents.spec.tsx +76 -0
- package/src/components/Package/Package.tsx +44 -1
- package/dist/ServerProvider-DuEOzwPc.cjs.js +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";var rl=Object.create;var ro=Object.defineProperty;var sl=Object.getOwnPropertyDescriptor;var ol=Object.getOwnPropertyNames;var al=Object.getPrototypeOf,il=Object.prototype.hasOwnProperty;var ll=(e,r,u,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let d of ol(r))!il.call(e,d)&&d!==u&&ro(e,d,{get:()=>r[d],enumerable:!(s=sl(r,d))||s.enumerable});return e};var cl=(e,r,u)=>(u=e!=null?rl(al(e)):{},ll(r||!e||!e.__esModule?ro(u,"default",{value:e,enumerable:!0}):u,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),S=require("@mui/material"),I=require("react"),o=require("./useCompiledDocument-oocN5cGE.cjs.js"),B=require("./ServerProvider-DuEOzwPc.cjs.js"),Sr=require("@tanstack/react-query"),Jn=require("@mui/system"),wt=require("@mui/icons-material"),qo=require("./text-entry-BJwltZiy.cjs.js"),en=require("./RenderedResult-BrvrMDAP.cjs.js"),gr=require("react-router-dom");function ul(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const u in e)if(u!=="default"){const s=Object.getOwnPropertyDescriptor(e,u);Object.defineProperty(r,u,s.get?s:{enumerable:!0,get:()=>e[u]})}}return r.default=e,Object.freeze(r)}const he=ul(I),dl=o.createSvgIcon(n.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}));function hl({label:e,href:r,onClick:u}){const s=d=>{const c=d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||d.button!==0;r!==void 0&&c||(d.preventDefault(),u(d))};return n.jsxs(S.Link,{...r===void 0?{component:"button",type:"button"}:{href:r},onClick:s,underline:"none","aria-label":`Back to ${e}`,sx:{display:"inline-flex",alignItems:"center",gap:.5,cursor:"pointer",color:"text.secondary",fontSize:"0.875rem",mb:2,border:0,p:0,background:"none",font:"inherit","&:hover":{color:"primary.main"}},children:[n.jsx(dl,{sx:{fontSize:18}}),"Back to ",e]})}const zo="(max-width:599.95px)";function Ho(){return S.useMediaQuery(zo,{noSsr:!0})}function Vo(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(zo).matches}function fl({children:e}){const[r]=I.useState(Vo),[u,s]=I.useState(!1);return!r||u?n.jsx(n.Fragment,{children:e}):n.jsxs(S.Stack,{sx:{alignItems:"flex-start",gap:1.5,py:3},children:[n.jsx(S.Typography,{variant:"h6",children:"Editing works best on a larger screen"}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"The editor is built for a wider window. You can still try it here."}),n.jsx(S.Button,{variant:"outlined",onClick:()=>s(!0),children:"Edit anyway"})]})}function pl(){const e=gr.useNavigate();return(r,u)=>{if(!u||!u.metaKey&&!u.ctrlKey&&!u.shiftKey&&u.button!==1){e(r);return}const s=new URL(r,window.location.href).href;(u.metaKey||u.ctrlKey||u.button===1||u.shiftKey)&&window.open(s,"_blank")}}const ml=e=>{const r=he.useRef({});return he.useEffect(()=>{r.current=e}),r.current};function gl(){const[e]=gr.useSearchParams(),r=gr.useNavigate(),u=gr.useLocation(),s=I.useMemo(()=>Object.fromEntries(e.entries()),[e]),d=I.useRef(new Set),c=I.useCallback((l,m)=>{const p=new Set([...m,...d.current]);d.current=new Set([...d.current,...Object.keys(l),...m]);const h=new URLSearchParams(u.search);for(const g of p)Object.prototype.hasOwnProperty.call(l,g)||h.delete(g);for(const[g,v]of Object.entries(l))h.set(g,v);r({search:h.toString(),hash:u.hash},{replace:!0})},[r,u]);return{params:s,onGivensChange:c}}const Bo=o.createSvgIcon(n.jsx("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3z"})),yl="publisher:resize";function xl(e){return typeof e=="object"&&e!==null&&e.type===yl&&typeof e.height=="number"}function Uo(e){return e.replace(/\/api\/v0\/?$/,"")}function Go({server:e,environmentName:r,packageName:u,path:s}){const d=s.startsWith("public/")?s.slice(7):s;return`${Uo(e)}/environments/${encodeURIComponent(r)}/packages/${encodeURIComponent(u)}/`+d}function bl(e){try{const{environmentName:r,packageName:u,modelPath:s}=o.parseResourceUri(e);return!r||!u||!s?null:{environmentName:r,packageName:u,dataAppPath:s}}catch{return null}}function vl({resourceUri:e}){const{server:r,apiClients:u}=B.useServer(),s=bl(e),d=s?.environmentName??"",c=s?.packageName??"",l=s?.dataAppPath??"",m=I.useMemo(()=>Go({server:r,environmentName:d,packageName:c,path:l}),[r,d,c,l]),h=o.useQueryWithApiError({queryKey:["data-apps",d,c],queryFn:()=>u.dataApps.listDataApps(d,c),enabled:!!s}).data?.data?.find(w=>w.path===l),g=h?.title??l,v=h?.fit==="viewport",x=I.useRef(null),[y,C]=I.useState(120);return I.useEffect(()=>{if(v)return;function w(k){xl(k.data)&&k.source===x.current?.contentWindow&&k.data.height>0&&C(Math.ceil(k.data.height))}return window.addEventListener("message",w),()=>window.removeEventListener("message",w)},[v]),s?n.jsxs(S.Box,{sx:{p:3,...v?{height:"100%",display:"flex",flexDirection:"column"}:{maxWidth:1600,mx:"auto"}},children:[n.jsxs(S.Stack,{direction:"row",alignItems:"baseline",spacing:1,sx:{mb:1,flexShrink:0},children:[n.jsx(S.Typography,{variant:"h6",sx:{fontWeight:"fontWeightMedium",letterSpacing:"-0.025em"},children:g}),n.jsx(S.Typography,{variant:"caption",color:"text.secondary",sx:{fontFamily:B.MONO_FONT_FAMILY},children:l}),n.jsx(S.Box,{sx:{flex:1}}),n.jsx(S.Tooltip,{title:"Open standalone in new tab",children:n.jsx(S.IconButton,{size:"small",href:m,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",sx:{color:"text.secondary"},children:n.jsx(Bo,{fontSize:"small"})})})]}),n.jsx(S.Box,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,overflow:"hidden",backgroundColor:"background.paper",...v?{flex:1,minHeight:0}:{}},children:n.jsx("iframe",{ref:x,src:m,title:g,sandbox:"allow-scripts allow-same-origin allow-forms",style:{display:"block",width:"100%",height:v?"100%":y,border:0}})})]}):n.jsxs(S.Box,{sx:{p:3,maxWidth:1600,mx:"auto"},children:[n.jsx(S.Typography,{variant:"h6",sx:{fontWeight:"fontWeightMedium"},children:"Can't open data app"}),n.jsxs(S.Typography,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["This data app link is missing an environment, package, or path:",n.jsx(S.Box,{component:"span",sx:{fontFamily:B.MONO_FONT_FAMILY,ml:1},children:e})]})]})}function It({title:e,count:r,description:u,action:s,children:d}){const c=I.useId();return n.jsxs(S.Box,{component:"section","aria-labelledby":c,sx:{mb:4},children:[n.jsxs(S.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:u?0:1,minHeight:40},children:[n.jsxs(S.Stack,{direction:"row",alignItems:"baseline",spacing:1,children:[n.jsx(S.Typography,{id:c,variant:"h6",sx:{fontWeight:600,letterSpacing:"-0.025em",lineHeight:1.2},children:e}),r!==void 0&&n.jsxs(S.Typography,{variant:"caption",color:"text.secondary",children:["(",r,")"]})]}),s]}),u&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:u}),n.jsx(S.Box,{children:d})]})}function Sl({resourceUri:e}){const{environmentName:r}=o.parseResourceUri(e),{apiClients:u}=B.useServer(),[s,d]=I.useState(!1),c=90,{data:l,isSuccess:m,isError:p,error:h}=o.useQueryWithApiError({queryKey:["about",r],queryFn:()=>u.environments.getEnvironment(r,!1)}),g=l?.data?.readme||"",v=g.split(/\s+/),x=v.length>c,y=v.slice(0,c).join(" ");return n.jsxs(n.Fragment,{children:[!m&&!p&&n.jsx(o.Loading,{text:"Fetching About..."}),m&&g&&n.jsxs(It,{title:"Readme",children:[n.jsx(o.Prose,{variant:"caption",children:s||!x?g:y}),x&&n.jsx(S.Box,{sx:{mt:1},children:n.jsx(o.SecondaryButton,{label:s?"Read less":"Read more",onClick:()=>d(!s)})})]}),p&&n.jsx(o.ApiErrorDisplay,{error:h,context:`${r} > About`})]})}function wl(e={}){const{autoHideDuration:r=null,disableWindowBlurListener:u=!1,onClose:s,open:d,resumeHideDuration:c}=e,l=o.useTimeout();he.useEffect(()=>{if(!d)return;function O(M){M.defaultPrevented||M.key==="Escape"&&s?.(M,"escapeKeyDown")}return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O)}},[d,s]);const m=o.useEventCallback((O,M)=>{s?.(O,M)}),p=o.useEventCallback(O=>{!s||O==null||l.start(O,()=>{m(null,"timeout")})});he.useEffect(()=>(d&&p(r),l.clear),[d,r,p,l]);const h=O=>{s?.(O,"clickaway")},g=l.clear,v=he.useCallback(()=>{r!=null&&p(c??r*.5)},[r,c,p]),x=O=>M=>{const j=O.onBlur;j?.(M),v()},y=O=>M=>{const j=O.onFocus;j?.(M),g()},C=O=>M=>{const j=O.onMouseEnter;j?.(M),g()},w=O=>M=>{const j=O.onMouseLeave;j?.(M),v()};return he.useEffect(()=>{if(!u&&d)return window.addEventListener("focus",v),window.addEventListener("blur",g),()=>{window.removeEventListener("focus",v),window.removeEventListener("blur",g)}},[u,d,v,g]),{getRootProps:(O={})=>{const M={...o.extractEventHandlers(e),...o.extractEventHandlers(O)};return{role:"presentation",...O,...M,onBlur:x(M),onFocus:y(M),onMouseEnter:C(M),onMouseLeave:w(M)}},onClickAway:h}}function so(e){return e.substring(2).toLowerCase()}function Cl(e,r){return r.documentElement.clientWidth<e.clientX||r.documentElement.clientHeight<e.clientY}function kl(e){const{children:r,disableReactTree:u=!1,mouseEvent:s="onClick",onClickAway:d,touchEvent:c="onTouchEnd"}=e,l=he.useRef(!1),m=he.useRef(null),p=he.useRef(!1),h=he.useRef(!1);he.useEffect(()=>(setTimeout(()=>{p.current=!0},0),()=>{p.current=!1}),[]);const g=o.useForkRef(o.getReactElementRef(r),m),v=o.useEventCallback(C=>{const w=h.current;h.current=!1;const k=o.ownerDocument(m.current);if(!p.current||!m.current||"clientX"in C&&Cl(C,k))return;if(l.current){l.current=!1;return}let O;C.composedPath?O=C.composedPath().includes(m.current):O=!k.documentElement.contains(C.target)||m.current.contains(C.target),!O&&(u||!w)&&d(C)}),x=C=>w=>{h.current=!0;const k=r.props[C];k&&k(w)},y={ref:g};return c!==!1&&(y[c]=x(c)),he.useEffect(()=>{if(c!==!1){const C=so(c),w=o.ownerDocument(m.current),k=()=>{l.current=!0};return w.addEventListener(C,v),w.addEventListener("touchmove",k),()=>{w.removeEventListener(C,v),w.removeEventListener("touchmove",k)}}},[v,c]),s!==!1&&(y[s]=x(s)),he.useEffect(()=>{if(s!==!1){const C=so(s),w=o.ownerDocument(m.current);return w.addEventListener(C,v),()=>{w.removeEventListener(C,v)}}},[v,s]),he.cloneElement(r,y)}function Tl(e){return o.generateUtilityClass("MuiSnackbarContent",e)}o.generateUtilityClasses("MuiSnackbarContent",["root","message","action"]);const Ol=e=>{const{classes:r}=e,u={root:["root"],action:["action"],message:["message"]};return o.composeClasses(u,Tl,r)},Ml=o.styled(o.Paper,{name:"MuiSnackbarContent",slot:"Root"})(o.memoTheme(({theme:e})=>{const r=e.palette.mode==="light"?.8:.98;return{...e.typography.body2,color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(o.emphasize(e.palette.background.default,r)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:o.emphasize(e.palette.background.default,r),display:"flex",alignItems:"center",flexWrap:"wrap",padding:"6px 16px",flexGrow:1,[e.breakpoints.up("sm")]:{flexGrow:"initial",minWidth:288}}})),jl=o.styled("div",{name:"MuiSnackbarContent",slot:"Message"})({padding:"8px 0"}),Dl=o.styled("div",{name:"MuiSnackbarContent",slot:"Action"})({display:"flex",alignItems:"center",marginLeft:"auto",paddingLeft:16,marginRight:-8}),El=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiSnackbarContent"}),{action:d,className:c,message:l,role:m="alert",...p}=s,h=s,g=Ol(h);return n.jsxs(Ml,{role:m,elevation:6,className:o.clsx(g.root,c),ownerState:h,ref:u,...p,children:[n.jsx(jl,{className:g.message,ownerState:h,children:l}),d?n.jsx(Dl,{className:g.action,ownerState:h,children:d}):null]})});function Il(e){return o.generateUtilityClass("MuiSnackbar",e)}o.generateUtilityClasses("MuiSnackbar",["root","anchorOriginTopCenter","anchorOriginBottomCenter","anchorOriginTopRight","anchorOriginBottomRight","anchorOriginTopLeft","anchorOriginBottomLeft"]);const Nl=e=>{const{classes:r,anchorOrigin:u}=e,s={root:["root",`anchorOrigin${o.capitalize(u.vertical)}${o.capitalize(u.horizontal)}`]};return o.composeClasses(s,Il,r)},Fl=o.styled("div",{name:"MuiSnackbar",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.root,r[`anchorOrigin${o.capitalize(u.anchorOrigin.vertical)}${o.capitalize(u.anchorOrigin.horizontal)}`]]}})(o.memoTheme(({theme:e})=>({zIndex:(e.vars||e).zIndex.snackbar,position:"fixed",display:"flex",left:8,right:8,justifyContent:"center",alignItems:"center",variants:[{props:({ownerState:r})=>r.anchorOrigin.vertical==="top",style:{top:8,[e.breakpoints.up("sm")]:{top:24}}},{props:({ownerState:r})=>r.anchorOrigin.vertical!=="top",style:{bottom:8,[e.breakpoints.up("sm")]:{bottom:24}}},{props:({ownerState:r})=>r.anchorOrigin.horizontal==="left",style:{justifyContent:"flex-start",[e.breakpoints.up("sm")]:{left:24,right:"auto"}}},{props:({ownerState:r})=>r.anchorOrigin.horizontal==="right",style:{justifyContent:"flex-end",[e.breakpoints.up("sm")]:{right:24,left:"auto"}}},{props:({ownerState:r})=>r.anchorOrigin.horizontal==="center",style:{[e.breakpoints.up("sm")]:{left:"50%",right:"auto",transform:"translateX(-50%)"}}}]}))),Al=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiSnackbar"}),d=o.useTheme(),c={enter:d.transitions.duration.enteringScreen,exit:d.transitions.duration.leavingScreen},{action:l,anchorOrigin:{vertical:m,horizontal:p}={vertical:"bottom",horizontal:"left"},autoHideDuration:h=null,children:g,className:v,ClickAwayListenerProps:x,ContentProps:y,disableWindowBlurListener:C=!1,message:w,onBlur:k,onClose:O,onFocus:M,onMouseEnter:j,onMouseLeave:E,open:$,resumeHideDuration:U,slots:P={},slotProps:K={},TransitionComponent:A,transitionDuration:L=c,TransitionProps:{onEnter:V,onExited:N,..._}={},...Q}=s,re={...s,anchorOrigin:{vertical:m,horizontal:p},autoHideDuration:h,disableWindowBlurListener:C,TransitionComponent:A,transitionDuration:L},ee=Nl(re),{getRootProps:te,onClickAway:Z}=wl({...re}),[ae,H]=he.useState(!0),J=we=>{H(!0),N&&N(we)},se=(we,Te)=>{H(!1),V&&V(we,Te)},xe={slots:{transition:A,...P},slotProps:{content:y,clickAwayListener:x,transition:_,...K}},[$e,oe]=o.useSlot("root",{ref:u,className:[ee.root,v],elementType:Fl,getSlotProps:te,externalForwardedProps:{...xe,...Q},ownerState:re}),[le,{ownerState:Ne,...q}]=o.useSlot("clickAwayListener",{elementType:kl,externalForwardedProps:xe,getSlotProps:we=>({onClickAway:(...Te)=>{const Re=Te[0];we.onClickAway?.(...Te),!Re?.defaultMuiPrevented&&Z(...Te)}}),ownerState:re}),[X,ge]=o.useSlot("content",{elementType:El,shouldForwardComponentProp:!0,externalForwardedProps:xe,additionalProps:{message:w,action:l},ownerState:re}),[Se,Ee]=o.useSlot("transition",{elementType:o.Grow,externalForwardedProps:xe,getSlotProps:we=>({onEnter:(...Te)=>{we.onEnter?.(...Te),se(...Te)},onExited:(...Te)=>{we.onExited?.(...Te),J(...Te)}}),additionalProps:{appear:!0,in:$,timeout:L,direction:m==="top"?"down":"up"},ownerState:re});return!$&&ae?null:n.jsx(le,{...q,...P.clickAwayListener&&{ownerState:Ne},children:n.jsx($e,{...oe,children:n.jsx(Se,{...Ee,children:g||n.jsx(X,{...ge})})})})});let Xr;function Rl(e){Xr=e}function oo(e){if(Xr)try{Xr(e)}catch{}}function Pt(e,r,u){return(async s=>{const d=Date.now();try{const c=await u(s);return oo({type:"console.mutation",resource:e,action:r,ok:!0,durationMs:Date.now()-d}),c}catch(c){throw oo({type:"console.mutation",resource:e,action:r,ok:!1,durationMs:Date.now()-d,reason:c instanceof Error?c.message:"An unknown error occurred"}),c}})}function wn({mutationFn:e,success:r,invalidates:u,closeDialog:s,resource:d,action:c}){const l=Sr.useQueryClient(),[m,p]=I.useState(""),h=o.useMutationWithApiError({mutationFn:Pt(d,c,e),onSuccess(){s();for(const g of u)l.invalidateQueries({queryKey:g});p(r)},onError(g){p(g instanceof Error?g.message:"An unknown error occurred")}});return{mutate:h.mutate,isPending:h.isPending,notice:n.jsx(Al,{open:m!=="",autoHideDuration:6e3,onClose:()=>p(""),message:m})}}const Yo="https://docs.malloydata.dev/documentation",$r=`${Yo}/user_guides/publishing`,vn="https://github.com/malloydata/publisher/blob/main/docs",$t={docsHome:`${Yo}/`,publishing:`${$r}/publishing`,explorer:`${$r}/explorer`,mcpAgents:`${$r}/mcp_agents`,surfaces:`${vn}/choosing-a-surface.md`,dashboards:`${vn}/dashboards.md`,dataApps:`${vn}/html-data-apps.md`,givens:`${vn}/givens.md`,materialization:`${vn}/materialization.md`,connections:`${vn}/connections.md`};function $l({resourceUri:e}){const[r,u]=I.useState(!1),{apiClients:s}=B.useServer(),{environmentName:d}=o.parseResourceUri(e),c=wn({mutationFn(m){return s.packages.createPackage(d,{name:m.name,description:m.description,location:m.location})},success:"Package created",invalidates:[["packages",d]],closeDialog:()=>u(!1),resource:"package",action:"create"}),l=m=>{m.preventDefault();const p=new FormData(m.currentTarget),h=p.get("name")?.toString(),g=p.get("description")?.toString(),v=p.get("location")?.toString();c.mutate({name:h,description:g,location:v})};return n.jsxs(n.Fragment,{children:[n.jsx(o.AddButton,{label:"Package",onClick:()=>u(!0)}),n.jsx(o.AppDialog,{open:r,onClose:()=>u(!1),title:"New package",description:n.jsxs(n.Fragment,{children:["A package is a directory of Malloy models and their data. Give its location as a GitHub, S3 or GCS URL, or an absolute path the server can read; see the"," ",n.jsx(S.Box,{component:"a",href:$t.publishing,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary"},children:"package format"}),"."]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(S.Button,{disabled:c.isPending,onClick:()=>u(!1),children:"Cancel"}),n.jsx(S.Button,{type:"submit",form:"package-form",variant:"contained",loading:c.isPending,children:"Create package"})]}),children:n.jsx("form",{onSubmit:l,id:"package-form",children:n.jsxs(S.Stack,{sx:{gap:2},children:[n.jsx(S.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),n.jsx(S.TextField,{id:"description",name:"description",label:"Description",multiline:!0,rows:3,fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),n.jsx(S.TextField,{id:"location",name:"location",label:"Location",type:"text",placeholder:"e.g. s3://my-bucket/my-package.zip",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}})]})})}),c.notice]})}const Pl=o.createSvgIcon(n.jsx("path",{d:"M2 20h20v-4H2zm2-3h2v2H4zM2 4v4h20V4zm4 3H4V5h2zm-4 7h20v-4H2zm2-3h2v2H4z"}));function wr({icon:e,tint:r,label:u,mono:s,description:d,rightLabel:c,trailingAction:l,onClick:m,ariaLabel:p}){const h=!!m,g=v=>{m&&(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),m(v))};return n.jsxs(S.Box,{onClick:m,onKeyDown:h?g:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,"aria-label":p,sx:v=>({display:"flex",alignItems:"center",gap:1.5,py:1,px:1,mx:-1,cursor:h?"pointer":"default",borderRadius:1.5,transition:"background-color 0.1s","&:hover":h?{backgroundColor:v.palette.mode==="dark"?"rgba(255, 255, 255, 0.08)":"grey.100"}:void 0,"&:focus-visible":h?{outline:"2px solid",outlineColor:"primary.main",outlineOffset:2}:void 0}),children:[n.jsx(S.Box,{sx:{width:32,height:32,borderRadius:1,bgcolor:r,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),n.jsxs(S.Box,{sx:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:1.5},children:[n.jsx(S.Typography,{variant:"body2",sx:{...s?{fontFamily:B.MONO_FONT_FAMILY}:{},flexShrink:0,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),d&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d})]}),c&&n.jsx(S.Typography,{variant:"caption",color:"text.secondary",sx:{flexShrink:0},children:c}),l&&n.jsx(S.Box,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:l})]})}const Zo=o.createSvgIcon(n.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"})),Ll=o.generateUtilityClasses("MuiBox",["root"]),_l=o.createTheme(),Ae=Jn.createBox({themeId:o.THEME_ID,defaultTheme:_l,defaultClassName:Ll.root,generateClassName:o.ClassNameGenerator.generate}),Cr=Jn.createStack({createStyledComponent:o.styled("div",{name:"MuiStack",slot:"Root"}),useThemeProps:e=>o.useDefaultProps({props:e,name:"MuiStack"})}),ao=o.generateUtilityClasses("MuiDivider",["root","absolute","fullWidth","inset","middle","flexItem","light","vertical","withChildren","withChildrenVertical","textAlignRight","textAlignLeft","wrapper","wrapperVertical"]);function Wl(e){return o.generateUtilityClass("MuiListItemIcon",e)}const io=o.generateUtilityClasses("MuiListItemIcon",["root","alignItemsFlexStart"]),ql=e=>{const{alignItems:r,classes:u}=e,s={root:["root",r==="flex-start"&&"alignItemsFlexStart"]};return o.composeClasses(s,Wl,u)},zl=o.styled("div",{name:"MuiListItemIcon",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.root,u.alignItems==="flex-start"&&r.alignItemsFlexStart]}})(o.memoTheme(({theme:e})=>({minWidth:56,color:(e.vars||e).palette.action.active,flexShrink:0,display:"inline-flex",variants:[{props:{alignItems:"flex-start"},style:{marginTop:8}}]}))),os=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiListItemIcon"}),{className:d,...c}=s,l=he.useContext(o.ListContext),m={...s,alignItems:l.alignItems},p=ql(m);return n.jsx(zl,{className:o.clsx(p.root,d),ownerState:m,ref:u,...c})});function Hl(e){return o.generateUtilityClass("MuiListItemText",e)}const Sn=o.generateUtilityClasses("MuiListItemText",["root","multiline","dense","inset","primary","secondary"]),Vl=e=>{const{classes:r,inset:u,primary:s,secondary:d,dense:c}=e,l={root:["root",u&&"inset",c&&"dense",s&&d&&"multiline"],primary:["primary"],secondary:["secondary"]};return o.composeClasses(l,Hl,r)},Bl=o.styled("div",{name:"MuiListItemText",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[{[`& .${Sn.primary}`]:r.primary},{[`& .${Sn.secondary}`]:r.secondary},r.root,u.inset&&r.inset,u.primary&&u.secondary&&r.multiline,u.dense&&r.dense]}})({flex:"1 1 auto",minWidth:0,marginTop:4,marginBottom:4,[`.${o.typographyClasses.root}:where(& .${Sn.primary})`]:{display:"block"},[`.${o.typographyClasses.root}:where(& .${Sn.secondary})`]:{display:"block"},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),as=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiListItemText"}),{children:d,className:c,disableTypography:l=!1,inset:m=!1,primary:p,primaryTypographyProps:h,secondary:g,secondaryTypographyProps:v,slots:x={},slotProps:y={},...C}=s,{dense:w}=he.useContext(o.ListContext);let k=p??d,O=g;const M={...s,disableTypography:l,inset:m,primary:!!k,secondary:!!O,dense:w},j=Vl(M),E={slots:x,slotProps:{primary:h,secondary:v,...y}},[$,U]=o.useSlot("root",{className:o.clsx(j.root,c),elementType:Bl,externalForwardedProps:{...E,...C},ownerState:M,ref:u}),[P,K]=o.useSlot("primary",{className:j.primary,elementType:o.Typography,externalForwardedProps:E,ownerState:M}),[A,L]=o.useSlot("secondary",{className:j.secondary,elementType:o.Typography,externalForwardedProps:E,ownerState:M});return k!=null&&k.type!==o.Typography&&!l&&(k=n.jsx(P,{variant:w?"body2":"body1",component:K?.variant?void 0:"span",...K,children:k})),O!=null&&O.type!==o.Typography&&!l&&(O=n.jsx(A,{variant:"body2",color:"textSecondary",...L,children:O})),n.jsxs($,{...U,children:[k,O]})});function Ul(e){return o.generateUtilityClass("MuiMenuItem",e)}const Ln=o.generateUtilityClasses("MuiMenuItem",["root","focusVisible","dense","disabled","divider","gutters","selected"]),Gl=(e,r)=>{const{ownerState:u}=e;return[r.root,u.dense&&r.dense,u.divider&&r.divider,!u.disableGutters&&r.gutters]},Yl=e=>{const{disabled:r,dense:u,divider:s,disableGutters:d,selected:c,classes:l}=e,m={root:["root",u&&"dense",r&&"disabled",!d&&"gutters",s&&"divider",c&&"selected"]},p=o.composeClasses(m,Ul,l);return{...l,...p}},Zl=o.styled(o.ButtonBase,{shouldForwardProp:e=>o.rootShouldForwardProp(e)||e==="classes",name:"MuiMenuItem",slot:"Root",overridesResolver:Gl})(o.memoTheme(({theme:e})=>({...e.typography.body1,display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",minHeight:48,paddingTop:6,paddingBottom:6,boxSizing:"border-box",whiteSpace:"nowrap","&:hover":{textDecoration:"none",backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${Ln.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${Ln.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${Ln.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${Ln.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${Ln.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${ao.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${ao.inset}`]:{marginLeft:52},[`& .${Sn.root}`]:{marginTop:0,marginBottom:0},[`& .${Sn.inset}`]:{paddingLeft:36},[`& .${io.root}`]:{minWidth:36},variants:[{props:({ownerState:r})=>!r.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:r})=>r.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:r})=>!r.dense,style:{[e.breakpoints.up("sm")]:{minHeight:"auto"}}},{props:({ownerState:r})=>r.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${io.root} svg`]:{fontSize:"1.25rem"}}}]}))),He=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiMenuItem"}),{autoFocus:d=!1,component:c="li",dense:l=!1,divider:m=!1,disableGutters:p=!1,focusVisibleClassName:h,role:g="menuitem",tabIndex:v,className:x,...y}=s,C=he.useContext(o.ListContext),w=he.useMemo(()=>({dense:l||C.dense||!1,disableGutters:p}),[C.dense,l,p]),k=he.useRef(null);o.useEnhancedEffect(()=>{d&&k.current&&k.current.focus()},[d]);const O={...s,dense:w.dense,divider:m,disableGutters:p},M=Yl(s),j=o.useForkRef(k,u);let E;return s.disabled||(E=v!==void 0?v:-1),n.jsx(o.ListContext.Provider,{value:w,children:n.jsx(Zl,{ref:j,role:g,tabIndex:E,component:c,focusVisibleClassName:o.clsx(M.focusVisible,h),className:o.clsx(M.root,x),...y,ownerState:O,classes:M})})}),Lt={postgres:[{label:"Host",name:"host",type:"text",required:!1},{label:"Port",name:"port",type:"number",required:!1},{label:"Database Name",name:"databaseName",type:"text",required:!1},{label:"User Name",name:"userName",type:"text",required:!1},{label:"Password",name:"password",type:"password",required:!1},{label:"Connection String",name:"connectionString",type:"text",required:!1}],bigquery:[{label:"Project ID",name:"defaultProjectId",type:"text",required:!1},{label:"Billing Project ID",name:"billingProjectId",type:"text",required:!1},{label:"Location",name:"location",type:"text",required:!1},{label:"Service Account Key JSON",name:"serviceAccountKeyJson",type:"text",required:!0},{label:"Maximum Bytes Billed",name:"maximumBytesBilled",type:"text",required:!1},{label:"Query Timeout Milliseconds",name:"queryTimeoutMilliseconds",type:"text",required:!1}],snowflake:[{label:"Account",name:"account",type:"text",required:!0},{label:"Username",name:"username",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Role",name:"role",type:"text",required:!1},{label:"Warehouse",name:"warehouse",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"Response Timeout Milliseconds",name:"responseTimeoutMilliseconds",type:"text",required:!1},{label:"Private Key",name:"privateKey",type:"password",required:!1},{label:"Private Key Passphrase",name:"privateKeyPass",type:"password",required:!1}],trino:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Catalog",name:"catalog",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Peaka Key",name:"peakaKey",type:"password",required:!1}],databricks:[{label:"Host",name:"host",type:"text",required:!0},{label:"HTTP Path",name:"path",type:"text",required:!0},{label:"Access Token",name:"token",type:"password",required:!1},{label:"OAuth Client ID",name:"oauthClientId",type:"text",required:!1},{label:"OAuth Client Secret",name:"oauthClientSecret",type:"password",required:!1},{label:"Default Catalog",name:"defaultCatalog",type:"text",required:!1},{label:"Default Schema",name:"defaultSchema",type:"text",required:!1}],mysql:[{label:"Host",name:"host",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Database",name:"database",type:"text",required:!0}],duckdb:[],motherduck:[{label:"Access Token",name:"accessToken",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1}],ducklake:[],publisher:[]},Kn={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",trino:"trinoConnection",databricks:"databricksConnection",mysql:"mysqlConnection",duckdb:"duckdbConnection",motherduck:"motherduckConnection",ducklake:"ducklakeConnection",publisher:"publisherConnection"},Ko=Object.values(B.ConnectionTypeEnum).filter(e=>e!==B.ConnectionTypeEnum.Publisher),Qr={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",gcs:"gcsConnection",s3:"s3Connection",azure:"azureConnection"},er=[{label:"Credential Provider",name:"provider",type:"text",required:!1,selectOptions:[{label:"Access key pair",value:"config"},{label:"Host credential chain",value:"credential_chain"}]},{label:"Access Key ID",name:"accessKeyId",type:"text",required:!1,visibleWhen:{field:"provider",value:"config"}},{label:"Secret Access Key",name:"secretAccessKey",type:"password",required:!1,visibleWhen:{field:"provider",value:"config"}},{label:"Credential Chain",name:"chain",type:"text",required:!1,visibleWhen:{field:"provider",value:"credential_chain"}},{label:"Region",name:"region",type:"text",required:!1},{label:"Endpoint",name:"endpoint",type:"text",required:!1},{label:"Session Token",name:"sessionToken",type:"password",required:!1,visibleWhen:{field:"provider",value:"config"}}],tr=[{label:"Key ID",name:"keyId",type:"text",required:!0},{label:"Secret",name:"secret",type:"password",required:!0}],Kl=[{label:"Auth Type",name:"authType",type:"text",required:!0,selectOptions:[{label:"SAS Token",value:"sas_token"},{label:"Service Principal (SPN)",value:"service_principal"}]},{label:"SAS URL (e.g. https://account.blob.core.windows.net/container/file.parquet?sp=r&st=...)",name:"sasUrl",type:"text",required:!1,visibleWhen:{field:"authType",value:"sas_token"}},{label:"Tenant ID",name:"tenantId",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Client ID",name:"clientId",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Client Secret",name:"clientSecret",type:"password",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Account Name",name:"accountName",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"File URL (e.g. abfss://container/path/file.parquet)",name:"fileUrl",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}}];function br(e){return e==="postgres"||e==="bigquery"||e==="snowflake"?Lt[e]||[]:e==="s3"?er:e==="gcs"?tr:e==="azure"?Kl:[]}function Xl({onSubmit:e,isSubmitting:r}){const[u,s]=I.useState(!1),[d,c]=I.useState("postgres"),[l,m]=I.useState([]),[p,h]=I.useState("postgres"),[g,v]=I.useState("s3"),[x,y]=I.useState("config"),C=()=>{s(!0)},w=()=>{s(!1),m([]),c("postgres"),h("postgres"),v("s3"),y("config")},k=async E=>{E.preventDefault();const $=new FormData(E.currentTarget),U=$.get("name")?.toString(),P=$.get("type")?.toString(),K=Lt[P];if(!U)throw new Error("Name is required");if(!P)throw new Error("Type is required");let A;if(P==="ducklake"){const L={};if(p==="postgres"){const _=Lt.postgres,Q={};if(_.forEach(re=>{const ee=$.get(`ducklake_pg_${re.name}`)?.toString();ee&&(Q[re.name]=ee)}),Object.keys(Q).length===0)throw new Error("DuckLake requires catalog connection");L.postgresConnection=Q}const V=$.get("ducklake_bucketUrl")?.toString();if(!V)throw new Error("DuckLake requires a bucket URL");const N={bucketUrl:V};if(g==="s3"){const _={};if(er.forEach(Q=>{const re=$.get(`ducklake_s3_${Q.name}`)?.toString();re&&(_[Q.name]=re)}),_.provider==="credential_chain")delete _.accessKeyId,delete _.secretAccessKey,delete _.sessionToken;else{if(delete _.chain,!_.accessKeyId)throw new Error("S3 Access Key ID is required");if(!_.secretAccessKey)throw new Error("S3 Secret Access Key is required")}Object.keys(_).length>0&&(N.s3Connection=_)}else if(g==="gcs"){const _={};if(tr.forEach(Q=>{const re=$.get(`ducklake_gcs_${Q.name}`)?.toString();re&&(_[Q.name]=re)}),!_.keyId)throw new Error("GCS Key ID is required");if(!_.secret)throw new Error("GCS Secret is required");Object.keys(_).length>0&&(N.gcsConnection=_)}A={name:U,type:P,ducklakeConnection:{catalog:L,storage:N}}}else if(P==="duckdb"){if(l.length===0)throw new Error("DuckDB connection must have at least one attached database");const L=l.map((V,N)=>{const _=V.dbType,Q=$.get(`attachedDb_${N}_name`)?.toString();if(!Q)throw new Error(`Attached database at index ${N} must have a name`);const re={name:Q,type:_},ee=br(_);if(ee&&ee.length>0){const te={};if(ee.forEach(ae=>{const H=$.get(`attachedDb_${N}_${ae.name}`)?.toString();H&&(te[ae.name]=H)}),_==="s3"){if(te.provider==="credential_chain")delete te.accessKeyId,delete te.secretAccessKey,delete te.sessionToken;else if(delete te.chain,!te.accessKeyId||!te.secretAccessKey)throw new Error(`Attached database "${Q}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`)}const Z=Qr[_];Z&&(re[Z]=te)}return re});A={name:U,type:P,duckdbConnection:{attachedDatabases:L}}}else{const L={};if(K.forEach(V=>{const N=$.get(V.name)?.toString();N&&(L[V.name]=N)}),P==="postgres"){if(!!!L.connectionString?.trim()){const N=["host","port","databaseName","userName","password"];for(const _ of N)if(!L[_])throw new Error(`${K.find(Q=>Q.name===_)?.label||_} is required`)}}else if(P==="bigquery"){if(!L.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(P==="snowflake"){if(!L.account)throw new Error("Account is required");if(!L.username)throw new Error("Username is required");if(!L.warehouse)throw new Error("Warehouse is required");if(!L.password&&!L.privateKey)throw new Error("Either password or private key is required")}else if(P==="trino"){if(!L.server)throw new Error("Server is required");if(!L.user)throw new Error("User is required");if(L.server.trim().startsWith("https://")&&!L.password&&!L.peakaKey)throw new Error("Password is required for HTTPS connections (or use Peaka Key)")}else if(P==="mysql"){const V=["host","port","database","user","password"];for(const N of V)if(!L[N])throw new Error(`${K.find(_=>_.name===N)?.label||N} is required`)}else if(P==="motherduck"){if(!L.accessToken)throw new Error("Access Token is required")}else if(P==="databricks"){if(!L.host)throw new Error("Host is required");if(!L.path)throw new Error("HTTP Path is required");const V=L.oauthClientId&&L.oauthClientSecret;if(!L.token&&!V)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}A={name:U,type:P,[Kn[P]]:L}}await e(A),w()},O=()=>{m([...l,{name:"",dbType:"postgres"}])},M=E=>{m(l.filter(($,U)=>U!==E))},j=(E,$)=>{const U=[...l];U[E]={...U[E],dbType:$},m(U)};return n.jsxs(I.Fragment,{children:[n.jsx(o.AddButton,{label:"Connection",onClick:C}),n.jsx(o.AppDialog,{open:u,onClose:w,title:"New connection",description:"Add a connection so packages in this environment can query your database with Malloy.",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:r,onClick:w,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"connection-form",variant:"contained",loading:r,children:"Create connection"})]}),children:n.jsx("form",{onSubmit:k,id:"connection-form",children:n.jsxs(Cr,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small"}),n.jsx(o.TextField,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:d,select:!0,onChange:E=>c(E.target.value),children:Ko.map(E=>n.jsx(He,{value:E,children:E},E))}),d==="ducklake"?n.jsxs(Ae,{sx:{mt:2},children:[n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsx(o.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),n.jsx(o.TextField,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:p,select:!0,onChange:E=>h(E.target.value),children:n.jsx(He,{value:"postgres",children:"PostgreSQL"})}),p==="postgres"&&n.jsx(n.Fragment,{children:Lt.postgres.map(E=>n.jsx(o.TextField,{id:`ducklake_pg_${E.name}`,name:`ducklake_pg_${E.name}`,label:E.label,type:E.type,fullWidth:!0,size:"small"},`pg_${E.name}`))})]}),n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsx(o.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),n.jsxs(o.TextField,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:g,select:!0,onChange:E=>v(E.target.value),children:[n.jsx(He,{value:"s3",children:"S3"}),n.jsx(He,{value:"gcs",children:"GCS"})]}),n.jsx(o.TextField,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:g==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small"}),g==="s3"&&n.jsxs(n.Fragment,{children:[n.jsx(o.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),er.filter(E=>E.visibleWhen?x===E.visibleWhen.value:!0).map(E=>n.jsx(o.TextField,{id:`ducklake_s3_${E.name}`,name:`ducklake_s3_${E.name}`,label:E.label,type:E.selectOptions?void 0:E.type,fullWidth:!0,size:"small",required:E.required,select:!!E.selectOptions,defaultValue:E.selectOptions?x:void 0,onChange:E.name==="provider"?$=>y($.target.value):void 0,placeholder:E.name==="region"?"us-east-1":void 0,children:E.selectOptions?.map($=>n.jsx(He,{value:$.value,children:$.label},$.value))},`s3_${E.name}`))]}),g==="gcs"&&n.jsxs(n.Fragment,{children:[n.jsx(o.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),tr.map(E=>n.jsx(o.TextField,{id:`ducklake_gcs_${E.name}`,name:`ducklake_gcs_${E.name}`,label:E.label,type:E.type,fullWidth:!0,size:"small",required:E.required},`gcs_${E.name}`))]})]})]}):d==="duckdb"?n.jsxs(Ae,{sx:{mt:2},children:[n.jsxs(Ae,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.jsx(o.Typography,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),n.jsx(o.SecondaryButton,{label:"Database",icon:n.jsx(o.AddIcon,{}),onClick:O,ariaLabel:"Add database"})]}),l.length===0&&n.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),l.map((E,$)=>{const U=br(E.dbType);return n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsxs(Ae,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.jsxs(o.Typography,{variant:"subtitle2",children:["Database ",$+1]}),n.jsx(o.IconButton,{onClick:()=>M($),size:"small",color:"error",children:n.jsx(Zo,{fontSize:"small"})})]}),n.jsx(o.TextField,{required:!0,id:`attachedDb_${$}_name`,name:`attachedDb_${$}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:E.name}),n.jsx(o.TextField,{id:`attachedDb_${$}_type`,name:`attachedDb_${$}_type`,label:"Database Type",fullWidth:!0,size:"small",value:E.dbType,select:!0,onChange:P=>j($,P.target.value),children:Object.values(B.AttachedDatabaseTypeEnum).map(P=>n.jsx(He,{value:P,children:P},P))}),U.filter(P=>P.visibleWhen?(E[P.visibleWhen.field]||U.find(A=>A.name===P.visibleWhen?.field)?.selectOptions?.[0]?.value)===P.visibleWhen.value:!0).map(P=>n.jsx(o.TextField,{id:`attachedDb_${$}_${P.name}`,name:`attachedDb_${$}_${P.name}`,label:P.label,type:P.selectOptions?void 0:P.type,fullWidth:!0,size:"small",required:P.required,select:!!P.selectOptions,defaultValue:P.selectOptions?.[0]?.value,onChange:P.selectOptions?K=>{const A=[...l];A[$]={...A[$],[P.name]:K.target.value},m(A)}:void 0,children:P.selectOptions?.map(K=>n.jsx(He,{value:K.value,children:K.label},K.value))},P.name))]},$)})]}):Lt[d].map(E=>n.jsx(o.TextField,{id:E.name,name:E.name,label:E.label,type:E.type,fullWidth:!0,size:"small",required:E.required},E.name))]})})})]})}function Ql({connection:e,onCloseDialog:r,isMutating:u,onDelete:s}){const[d,c]=I.useState(!1),l=()=>{c(!0)},m=()=>{c(!1),r()};return n.jsxs(I.Fragment,{children:[n.jsxs(He,{"aria-label":`Delete connection ${e?.name??""}`.trim(),onClick:p=>{p.stopPropagation(),l()},sx:{color:"error.main"},children:[n.jsx(os,{sx:{color:"inherit"},children:n.jsx(wt.Delete,{fontSize:"small"})}),n.jsx(as,{children:"Delete"})]}),n.jsx(o.AppDialog,{open:d,onClose:m,title:"Delete connection",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{onClick:m,children:"Cancel"}),n.jsx(o.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>s(),loading:u,children:"Delete connection"})]}),children:n.jsxs(o.Typography,{variant:"body2",children:["Delete ",n.jsx("strong",{children:e.name}),"? Packages that query through it stop working, and this cannot be undone."]})})]})}const lo=new Set(["password","connectionString","privateKey","privateKeyPass","serviceAccountKeyJson","token","oauthClientSecret","accessToken","peakaKey","secret","secretAccessKey","sessionToken","clientSecret","sasUrl"]);function co(e){const r=e.duckdbConnection?.attachedDatabases;return!r||r.length===0?[]:r.map(u=>({name:u.name||"",dbType:u.type||"postgres"}))}function uo(e){const r=e.ducklakeConnection;return r&&r.storage?.gcsConnection?"gcs":"s3"}function Jl({connection:e,onSubmit:r,isSubmitting:u,onCloseDialog:s}){const[d,c]=I.useState(!1),[l,m]=I.useState(e.type),p=I.useMemo(()=>new Set(e.withheldFields??[]),[e.withheldFields]),[h,g]=I.useState(()=>co(e)),[v,x]=I.useState("postgres"),[y,C]=I.useState(()=>uo(e)),[w,k]=I.useState(()=>e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),O=()=>{g(co(e)),m(e.type),k(e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),x("postgres"),C(uo(e)),c(!0)},M=()=>{c(!1),s?.()},j=async A=>{A.preventDefault();const L=new FormData(A.currentTarget),V=L.get("name")?.toString(),N=L.get("type")?.toString(),_=Lt[N];if(!V)throw new Error("Name is required");if(!N)throw new Error("Type is required");let Q;if(N==="ducklake"){const re={};if(v==="postgres"){const Z=Lt.postgres,ae={};if(Z.forEach(H=>{const J=L.get(`ducklake_pg_${H.name}`)?.toString();J&&(ae[H.name]=J)}),Object.keys(ae).length===0)throw new Error("DuckLake requires catalog connection");re.postgresConnection=ae}const ee=L.get("ducklake_bucketUrl")?.toString();if(!ee)throw new Error("DuckLake requires a bucket URL");const te={bucketUrl:ee};if(y==="s3"){const Z={};er.forEach(H=>{const J=L.get(`ducklake_s3_${H.name}`)?.toString();J&&(Z[H.name]=J)});const ae=e.ducklakeConnection?.storage?.s3Connection;if(ae&&(!Z.provider&&ae.provider&&(Z.provider=ae.provider),!Z.chain&&ae.chain&&(Z.chain=ae.chain),!Z.accessKeyId&&ae.accessKeyId&&(Z.accessKeyId=ae.accessKeyId)),Z.provider==="credential_chain")delete Z.accessKeyId,delete Z.secretAccessKey,delete Z.sessionToken;else if(delete Z.chain,!Z.accessKeyId)throw new Error("S3 Access Key ID is required");Object.keys(Z).length>0&&(te.s3Connection=Z)}else if(y==="gcs"){const Z={};tr.forEach(H=>{const J=L.get(`ducklake_gcs_${H.name}`)?.toString();J&&(Z[H.name]=J)});const ae=e.ducklakeConnection?.storage?.gcsConnection;if(ae&&!Z.keyId&&ae.keyId&&(Z.keyId=ae.keyId),!Z.keyId)throw new Error("GCS Key ID is required");Object.keys(Z).length>0&&(te.gcsConnection=Z)}Q={name:V,type:N,ducklakeConnection:{catalog:re,storage:te}}}else if(N==="duckdb"){if(h.length===0)throw new Error("DuckDB connection must have at least one attached database");const re=h.map((ee,te)=>{const Z=ee.dbType,ae=L.get(`attachedDb_${te}_name`)?.toString();if(!ae)throw new Error(`Attached database at index ${te} must have a name`);const H={name:ae,type:Z},J=br(Z);if(J&&J.length>0){const se={};if(J.forEach($e=>{const oe=L.get(`attachedDb_${te}_${$e.name}`)?.toString();oe&&(se[$e.name]=oe)}),Z==="s3"){if(se.provider==="credential_chain")delete se.accessKeyId,delete se.secretAccessKey,delete se.sessionToken;else if(delete se.chain,!se.accessKeyId||!se.secretAccessKey)throw new Error(`Attached database "${ae}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`)}const xe=Qr[Z];xe&&(H[xe]=se)}return H});Q={name:V,type:N,duckdbConnection:{attachedDatabases:re}}}else{const re=e[Kn[N]]||{},ee={};if(_.forEach(te=>{const Z=L.get(te.name)?.toString(),ae=re[te.name];Z?ee[te.name]=Z:lo.has(te.name)||(Z!==void 0?ee[te.name]=Z:ae&&(ee[te.name]=ae))}),N==="postgres"){const te=["host","port","databaseName","userName"],Z=p.has("postgresConnection.connectionString");if(!(!!ee.connectionString?.trim()||Z)){const H=te;for(const J of H)if(!ee[J])throw new Error(`${_.find(se=>se.name===J)?.label||J} is required`)}}else if(N==="snowflake"){if(!ee.account)throw new Error("Account is required");if(!ee.username)throw new Error("Username is required");if(!ee.warehouse)throw new Error("Warehouse is required")}else if(N==="trino"){if(!ee.server)throw new Error("Server is required");if(!ee.user)throw new Error("User is required")}else if(N==="mysql"){const te=["host","port","database","user"];for(const Z of te)if(!ee[Z])throw new Error(`${_.find(ae=>ae.name===Z)?.label||Z} is required`)}else if(N==="databricks"){if(!ee.host)throw new Error("Host is required");if(!ee.path)throw new Error("HTTP Path is required")}Q={name:V,type:N,[Kn[N]]:ee}}await r(Q),M()},E=()=>{g([...h,{name:"",dbType:"postgres"}])},$=A=>{g(h.filter((L,V)=>V!==A))},U=(A,L)=>{const V=[...h];V[A]={...V[A],dbType:L},g(V)},P=(A,L)=>{const V=e.duckdbConnection?.attachedDatabases;if(!V||!V[A])return"";const N=V[A],_=Qr[N.type||""];return _&&N[_]?N[_][L]??"":""},K=A=>{const L=e.ducklakeConnection;if(!L)return"";if(A.startsWith("pg_")){const V=A.replace("pg_","");return L.catalog?.postgresConnection?.[V]??""}if(A==="bucketUrl")return L.storage?.bucketUrl??"";if(A.startsWith("s3_")){const V=A.replace("s3_","");return L.storage?.s3Connection?.[V]??""}if(A.startsWith("gcs_")){const V=A.replace("gcs_","");return L.storage?.gcsConnection?.[V]??""}return""};return n.jsxs(I.Fragment,{children:[n.jsxs(He,{"aria-label":`Edit connection ${e?.name??""}`.trim(),onClick:A=>{A.preventDefault(),A.stopPropagation(),O()},children:[n.jsx(os,{children:n.jsx(wt.Edit,{fontSize:"small"})}),n.jsx(as,{children:"Edit"})]}),n.jsx(o.AppDialog,{open:d,onClose:M,title:"Edit connection",description:"Change how packages in this environment reach your database.",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:u,onClick:M,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"connection-form",variant:"contained",loading:u,children:"Save changes"})]}),children:n.jsx("form",{onSubmit:j,id:"connection-form",children:n.jsxs(Cr,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",defaultValue:e.name}),n.jsx(o.TextField,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:l,select:!0,onChange:A=>m(A.target.value),children:Ko.map(A=>n.jsx(He,{value:A,children:A},A))}),l==="ducklake"?n.jsxs(Ae,{sx:{mt:2},children:[n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsx(o.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),n.jsx(o.TextField,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:v,select:!0,onChange:A=>x(A.target.value),children:n.jsx(He,{value:"postgres",children:"PostgreSQL"})}),v==="postgres"&&n.jsx(n.Fragment,{children:Lt.postgres.map(A=>n.jsx(o.TextField,{id:`ducklake_pg_${A.name}`,name:`ducklake_pg_${A.name}`,label:A.label,type:A.type,fullWidth:!0,size:"small",defaultValue:K(`pg_${A.name}`)},`pg_${A.name}`))})]}),n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsx(o.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),n.jsxs(o.TextField,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:y,select:!0,onChange:A=>C(A.target.value),children:[n.jsx(He,{value:"s3",children:"S3"}),n.jsx(He,{value:"gcs",children:"GCS"})]}),n.jsx(o.TextField,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:y==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small",defaultValue:K("bucketUrl")}),y==="s3"&&n.jsxs(n.Fragment,{children:[n.jsx(o.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),er.filter(A=>A.visibleWhen?w===A.visibleWhen.value:!0).map(A=>n.jsx(o.TextField,{id:`ducklake_s3_${A.name}`,name:`ducklake_s3_${A.name}`,label:A.label,type:A.selectOptions?void 0:A.type,fullWidth:!0,size:"small",required:A.required&&A.name!=="secretAccessKey",select:!!A.selectOptions,defaultValue:A.selectOptions?w:K(`s3_${A.name}`),onChange:A.name==="provider"?L=>k(L.target.value):void 0,placeholder:A.name==="region"?"us-east-1":A.name==="secretAccessKey"&&p.has("ducklakeConnection.storage.s3Connection.secretAccessKey")?"Leave empty to keep existing":void 0,children:A.selectOptions?.map(L=>n.jsx(He,{value:L.value,children:L.label},L.value))},`s3_${A.name}`))]}),y==="gcs"&&n.jsxs(n.Fragment,{children:[n.jsx(o.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),tr.map(A=>n.jsx(o.TextField,{id:`ducklake_gcs_${A.name}`,name:`ducklake_gcs_${A.name}`,label:A.label,type:A.type,fullWidth:!0,size:"small",required:A.required&&A.name!=="secret",defaultValue:K(`gcs_${A.name}`),placeholder:A.name==="secret"&&p.has("ducklakeConnection.storage.gcsConnection.secret")?"Leave empty to keep existing":void 0},`gcs_${A.name}`))]})]})]}):l==="duckdb"?n.jsxs(Ae,{sx:{mt:2},children:[n.jsxs(Ae,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.jsx(o.Typography,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),n.jsx(o.SecondaryButton,{label:"Database",icon:n.jsx(o.AddIcon,{}),onClick:E,ariaLabel:"Add database"})]}),h.length===0&&n.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),h.map((A,L)=>{const V=br(A.dbType);return n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsxs(Ae,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.jsxs(o.Typography,{variant:"subtitle2",children:["Database ",L+1]}),n.jsx(o.IconButton,{"aria-label":`Remove attached database ${L+1}`,onClick:()=>$(L),size:"small",color:"error",children:n.jsx(Zo,{fontSize:"small"})})]}),n.jsx(o.TextField,{required:!0,id:`attachedDb_${L}_name`,name:`attachedDb_${L}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:A.name}),n.jsx(o.TextField,{id:`attachedDb_${L}_type`,name:`attachedDb_${L}_type`,label:"Database Type",fullWidth:!0,size:"small",value:A.dbType,select:!0,onChange:N=>U(L,N.target.value),children:Object.values(B.AttachedDatabaseTypeEnum).map(N=>n.jsx(He,{value:N,children:N},N))}),V.filter(N=>N.visibleWhen?(A[N.visibleWhen.field]||P(L,N.visibleWhen.field)||V.find(Q=>Q.name===N.visibleWhen?.field)?.selectOptions?.[0]?.value)===N.visibleWhen.value:!0).map(N=>n.jsx(o.TextField,{id:`attachedDb_${L}_${N.name}`,name:`attachedDb_${L}_${N.name}`,label:N.label,type:N.selectOptions?void 0:N.type,fullWidth:!0,size:"small",required:N.required,select:!!N.selectOptions,defaultValue:P(L,N.name)||N.selectOptions?.[0]?.value,onChange:N.selectOptions?_=>{const Q=[...h];Q[L]={...Q[L],[N.name]:_.target.value},g(Q)}:void 0,children:N.selectOptions?.map(_=>n.jsx(He,{value:_.value,children:_.label},_.value))},N.name))]},L)})]}):Lt[l].map(A=>{const L=e?.[Kn[l]??""]?.[A.name??""]??"",V=A.type==="password"||lo.has(A.name),N=p.has(`${Kn[l]??""}.${A.name}`);return n.jsx(o.TextField,{id:A.name,name:A.name,label:A.label,type:A.type,fullWidth:!0,size:"small",required:A.required&&!V&&!L,defaultValue:L,placeholder:N?"Leave empty to keep existing":void 0,helperText:V?N?"Stored value is not shown. Leave empty to keep it.":"No value stored.":void 0},A.name)})]})})})]})}function ho(e,r){return!e||e.type!=="duckdb"?!1:(e.duckdbConnection?.attachedDatabases||[]).some(s=>s.type==="azure"&&s.name===r)}function ec(e){return e.startsWith("gs://")||e.startsWith("s3://")||e.startsWith("https://")||e.startsWith("abfss://")||e.startsWith("az://")}function Xo({connectionName:e,resourceUri:r,schema:u,connection:s}){const{apiClients:d}=B.useServer(),{environmentName:c}=o.parseResourceUri(r),[l,m]=I.useState(null),[p,h]=I.useState(u||null),[g,v]=I.useState(!1),{data:x,isError:y,isLoading:C,error:w}=o.useQueryWithApiError({queryKey:["schemas",c,e],queryFn:()=>d.connections.listSchemas(c,e)}),k=x?.data||[];return n.jsxs(S.Grid,{container:!0,spacing:1,children:[!u&&n.jsx(S.Grid,{size:{xs:12,md:4},children:n.jsxs(S.Paper,{sx:{p:1,m:0},children:[n.jsxs(S.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:0},children:[n.jsx(S.Typography,{variant:"overline",fontWeight:"bold",children:"Table Paths"}),n.jsx(S.FormControlLabel,{control:n.jsx(S.Switch,{checked:g,onChange:O=>v(O.target.checked)}),label:"Hidden Schemas"})]}),n.jsx(S.Divider,{sx:{mt:"2px"}}),n.jsxs(S.Box,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[C&&n.jsx(o.Loading,{text:"Loading schemas..."}),y&&n.jsx(o.ApiErrorDisplay,{error:w,context:`${c} > ${e} > Schemas`}),!C&&!y&&k.length===0&&n.jsx(S.Typography,{variant:"body2",children:"No Schemas"}),!C&&!y&&k.length>0&&n.jsx(S.List,{dense:!0,disablePadding:!0,children:k.map(O=>{const M=O.name;if(O.isHidden&&!g)return null;const E=p===M;return n.jsx(S.ListItemButton,{selected:E,onClick:()=>{h(M),m(null)},children:n.jsx(S.ListItemText,{primary:M})},M)})})]})]})}),n.jsx(S.Grid,{size:{xs:12,md:u?6:4},children:p&&n.jsx(S.Paper,{sx:{p:1,m:0},children:n.jsx(rc,{connectionName:e,schemaName:p,onTableSelect:O=>{m(O)},resourceUri:r,connection:s})})}),n.jsx(S.Grid,{size:{xs:12,md:u?6:4},children:p&&l&&n.jsx(tc,{environmentName:c,connectionName:e,schemaName:p,tableResource:l})})]})}function tc({environmentName:e,connectionName:r,schemaName:u,tableResource:s}){const{apiClients:d}=B.useServer(),{data:c,isLoading:l,isError:m,error:p}=o.useQueryWithApiError({queryKey:["connectionTableDetail",e,r,u,s],queryFn:()=>d.connections.getTable(e,r,u,s),enabled:!!u&&!!s}),h={resource:c?.data?.resource??s,columns:c?.data?.columns??[]};return n.jsxs(S.Paper,{sx:{p:1,m:0},children:[m&&n.jsx(o.ApiErrorDisplay,{error:p,context:`${e} > ${r} > ${u} > ${s}`}),!m&&n.jsx(nc,{table:h,loading:l})]})}function nc({table:e,loading:r}){return r?n.jsx(o.Loading,{text:"Loading columns..."}):n.jsxs(n.Fragment,{children:[n.jsxs(S.Typography,{variant:"overline",fontWeight:"bold",sx:{display:"block",wordBreak:"break-all"},children:[e.resource.includes("://")||/\.(parquet|csv|json|tsv|ndjson)$/i.test(e.resource)?"File":"Table",": ",e.resource]}),n.jsx(S.Divider,{}),n.jsx(S.Box,{sx:{mt:"10px",maxHeight:"600px",overflowY:"auto"},children:n.jsx(S.TableContainer,{children:n.jsxs(S.Table,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[n.jsx(S.TableHead,{children:n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:"NAME"}),n.jsx(S.TableCell,{children:"TYPE"})]})}),n.jsx(S.TableBody,{children:e.columns?.sort((u,s)=>u.name.localeCompare(s.name))?.map(u=>n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:u.name}),n.jsx(S.TableCell,{children:u.type})]},u.name))})]})})})]})}function rc({connectionName:e,schemaName:r,onTableSelect:u,resourceUri:s,connection:d}){const{environmentName:c}=o.parseResourceUri(s),{apiClients:l}=B.useServer(),[m,p]=I.useState(""),{data:h,isSuccess:g,isError:v,error:x,isLoading:y}=o.useQueryWithApiError({queryKey:["tablesInSchema",c,e,r],queryFn:()=>l.connections.listTables(c,e,r)}),C=ho(d,r),w=O=>C?O:O.split(".").pop()||O,k=g&&h?.data?h.data.filter(O=>w(O.resource).toLowerCase().includes(m.toLowerCase())).sort((O,M)=>w(O.resource).localeCompare(w(M.resource))):[];return n.jsxs(n.Fragment,{children:[n.jsx(S.Typography,{variant:"overline",fontWeight:"bold",children:ec(r)||ho(d,r)?`Files in ${r}`:`Tables in ${r}`}),n.jsx(S.Divider,{}),n.jsx(S.Box,{sx:{mt:1,mb:1},children:n.jsx(S.TextField,{size:"small",fullWidth:!0,placeholder:"Search tables...",value:m,onChange:O=>p(O.target.value),variant:"outlined"})}),n.jsx(S.Divider,{}),n.jsxs(S.Box,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[y&&n.jsx(o.Loading,{text:"Fetching Tables..."}),v&&n.jsx(o.ApiErrorDisplay,{error:x,context:`${c} > ${e} > ${r}`}),g&&k.length===0&&n.jsx(S.Typography,{variant:"body2",children:"No Tables"}),g&&h?.data&&h.data.length>0&&n.jsx(S.List,{dense:!0,disablePadding:!0,children:k.map(O=>{let M=w(O.resource);return!C&&O.resource.includes("://")&&(M=O.resource.split("/").pop()||O.resource),n.jsx(S.ListItemButton,{onClick:()=>u(O.resource),children:n.jsx(S.ListItemText,{primary:M,secondary:O.columns.length>0?`${O.columns.length} columns`:void 0})},O.resource)})})]})]})}const sc={bigquery:"BigQuery",snowflake:"Snowflake",postgres:"PostgreSQL",mysql:"MySQL",trino:"Trino",databricks:"Databricks",duckdb:"DuckDB",ducklake:"DuckLake",s3:"S3",gcs:"GCS",azure:"Azure"};function oc(e){return e?sc[e]??e:""}function ac({resourceUri:e}){const{apiClients:r,mutable:u}=B.useServer(),s=Sr.useQueryClient(),{environmentName:d}=o.parseResourceUri(e),[c,l]=I.useState(""),[m,p]=I.useState(null),h=o.encodeResourceUri({environmentName:d,connectionName:m}),{data:g,isSuccess:v,isError:x,error:y}=o.useQueryWithApiError({queryKey:["connections",d],queryFn:()=>r.connections.listConnections(d)}),C=o.useMutationWithApiError({mutationFn:Pt("connection","create",j=>r.environments.updateEnvironment(d,{name:d,connections:[...g.data,j]})),onSuccess(){l("Connection added successfully"),s.invalidateQueries({queryKey:["connections",d]})},onError(j){l(j.message)}}),w=o.useMutationWithApiError({mutationFn:Pt("connection","update",j=>r.environments.updateEnvironment(d,{name:d,connections:g.data.map(E=>E.name===j.name?j:E)})),onSuccess(j,E){l(`Connection ${E.name} updated successfully`),s.invalidateQueries({queryKey:["connections",d]})},onError(j){l(j.message)}}),k=o.useMutationWithApiError({mutationFn:Pt("connection","delete",j=>{if(!j.name)throw new Error("Cannot delete a connection with no name");return r.connections.deleteConnection(d,j.name)}),onSuccess(j,E){l(`Connection ${E.name} deleted successfully`),s.invalidateQueries({queryKey:["connections",d]})},onError(j){l(j.message)}}),O=v?[...g.data].sort((j,E)=>(j.name??"").localeCompare(E.name??"")):[],M=C.isPending||w.isPending||k.isPending;return n.jsxs(It,{title:"Connections",...v?{count:O.length}:{},description:"Database connections available to packages in this environment",...u&&v?{action:n.jsx(Xl,{onSubmit:j=>C.mutateAsync(j),isSubmitting:C.isPending})}:{},children:[!v&&!x&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"Fetching Connections..."}),x&&n.jsx(o.ApiErrorDisplay,{error:y,context:`${d} > Connections`}),v&&O.length===0&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"No connections yet."}),v&&O.length>0&&n.jsx(S.Stack,{children:O.map(j=>n.jsx(ic,{connection:j,mutable:u,isMutating:M,onOpenExplorer:()=>p(j.name??null),onEdit:E=>w.mutateAsync(E),onDelete:E=>k.mutateAsync(E)},j.name))}),n.jsx(S.Snackbar,{open:c!=="",autoHideDuration:6e3,onClose:()=>l(""),message:c}),n.jsx(o.AppDialog,{open:m!==null,onClose:()=>p(null),maxWidth:"lg",title:`Connection explorer: ${m??""}`,showClose:!0,children:m&&n.jsx(Xo,{resourceUri:h,connectionName:m,connection:g?.data?.find(j=>j.name===m)})})]})}function ic({connection:e,mutable:r,isMutating:u,onOpenExplorer:s,onEdit:d,onDelete:c}){const[l,m]=I.useState(null),p=!!l,h=v=>{v.stopPropagation(),m(v.currentTarget)},g=()=>m(null);return n.jsx(wr,{icon:n.jsx(Pl,{sx:{fontSize:18}}),tint:B.SURFACE_TINT.connection,label:e.name??"",ariaLabel:e.name??"",description:oc(e.type),onClick:s,...r?{trailingAction:n.jsxs(n.Fragment,{children:[n.jsx(S.IconButton,{size:"small",onClick:h,"aria-label":`Connection actions for ${e.name??""}`.trim(),children:n.jsx(wt.MoreVert,{fontSize:"small"})}),n.jsxs(S.Menu,{anchorEl:l,open:p,onClose:g,onClick:v=>v.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[n.jsx(Jl,{connection:e,onSubmit:d,isSubmitting:u,onCloseDialog:g}),n.jsx(Ql,{connection:e,onCloseDialog:g,isMutating:u,onDelete:()=>c(e)})]})]})}:{}})}const lc=o.createSvgIcon([n.jsx("path",{d:"M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2m-1 18H5V9h14zm1-13H4V4h16z"},"0"),n.jsx("path",{d:"M9 12h6v2H9z"},"1")]);function cc({resourceUri:e,onCloseDialog:r}){const[u,s]=I.useState(!1),{apiClients:d}=B.useServer(),c=()=>{s(!0)},l=()=>{s(!1),r()},{environmentName:m,packageName:p}=o.parseResourceUri(e),h=wn({mutationFn:()=>d.packages.deletePackage(m,p),success:"Package deleted",invalidates:[["packages",m]],closeDialog:l,resource:"package",action:"delete"});return n.jsxs(I.Fragment,{children:[n.jsxs(S.MenuItem,{onClick:c,children:[n.jsx(S.ListItemIcon,{children:n.jsx(wt.Delete,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Delete"})]}),n.jsx(o.AppDialog,{open:u,onClose:l,title:"Delete package",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{onClick:l,children:"Cancel"}),n.jsx(o.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>h.mutate(),loading:h.isPending,children:"Delete package"})]}),children:n.jsxs(o.Typography,{variant:"body2",children:["Delete ",n.jsx("strong",{children:p}),"? The package stops being served and this cannot be undone."]})}),h.notice]})}function uc({package:e,resourceUri:r,onCloseDialog:u}){const[s,d]=I.useState(!1),{apiClients:c}=B.useServer(),l=()=>{d(!0)},m=()=>{d(!1),u()},{packageName:p,environmentName:h}=o.parseResourceUri(r),g=wn({mutationFn(x){return c.packages.updatePackage(h,p,{name:p,description:x.description})},success:"Package updated",invalidates:[["packages",h]],closeDialog:m,resource:"package",action:"update"}),v=x=>{x.preventDefault();const C=new FormData(x.currentTarget).get("description")?.toString();g.mutate({description:C})};return n.jsxs(I.Fragment,{children:[n.jsxs(S.MenuItem,{onClick:l,children:[n.jsx(S.ListItemIcon,{children:n.jsx(wt.Edit,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Edit"})]}),n.jsx(o.AppDialog,{open:s,onClose:m,title:"Edit package",description:`What ${e.name} is, for the people who open it.`,actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:g.isPending,onClick:m,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"package-form",variant:"contained",loading:g.isPending,children:"Save changes"})]}),children:n.jsx("form",{onSubmit:v,id:"package-form",children:n.jsxs(S.Stack,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",disabled:!0,type:"text",fullWidth:!0,size:"small",defaultValue:e.name,InputLabelProps:{shrink:!0}}),n.jsx(o.TextField,{id:"description",name:"description",label:"Description",multiline:!0,fullWidth:!0,rows:4,size:"small",defaultValue:e.description,InputLabelProps:{shrink:!0}})]})})}),g.notice]})}function Qo({onSelectPackage:e,resourceUri:r}){const{apiClients:u}=B.useServer(),{environmentName:s}=o.parseResourceUri(r),{data:d,isSuccess:c,isError:l,error:m}=o.useQueryWithApiError({queryKey:["packages",s],queryFn:()=>u.packages.listPackages(s)});if(l)return n.jsx(o.ApiErrorDisplay,{error:m,context:`${s} > Packages`});if(!c)return n.jsx(o.Loading,{text:"Fetching Packages..."});const p=[...d.data].sort((h,g)=>h.name.localeCompare(g.name));return n.jsx(S.Stack,{children:p.map(h=>{const g=o.encodeResourceUri({environmentName:s,packageName:h.name});return n.jsx(dc,{pkg:h,packageResourceUri:g,onSelectPackage:e},h.name)})})}function dc({pkg:e,packageResourceUri:r,onSelectPackage:u}){const{mutable:s}=B.useServer(),[d,c]=I.useState(null),l=!!d,m=h=>{h.stopPropagation(),c(h.currentTarget)},p=()=>c(null);return n.jsx(wr,{icon:n.jsx(lc,{sx:{fontSize:18}}),tint:B.SURFACE_TINT.package,label:e.name,ariaLabel:e.name,...e.description?{description:e.description}:{},onClick:h=>u(e.name,h),...s?{trailingAction:n.jsxs(n.Fragment,{children:[n.jsx(S.IconButton,{size:"small",onClick:m,"aria-label":`Package actions for ${e.name}`,children:n.jsx(wt.MoreVert,{fontSize:"small"})}),n.jsxs(S.Menu,{anchorEl:d,open:l,onClose:p,onClick:h=>h.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[n.jsx(uc,{package:e,resourceUri:r,onCloseDialog:p}),n.jsx(cc,{resourceUri:r,onCloseDialog:p})]})]})}:{}})}function hc({onSelectPackage:e,resourceUri:r}){const{apiClients:u,mutable:s}=B.useServer(),{environmentName:d}=o.parseResourceUri(r),c=o.useQueryWithApiError({queryKey:["packages",d],queryFn:()=>u.packages.listPackages(d)});return I.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"})},[]),n.jsxs(S.Container,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[n.jsxs(S.Box,{sx:{mb:4},children:[n.jsx(S.Typography,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:d}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"Manage packages and database connections in this environment. Open a package to explore its models and notebooks."})]}),n.jsx(It,{title:"Packages",...c.isSuccess?{count:c.data.data.length}:{},description:"Published packages available for use in this environment",...s?{action:n.jsx($l,{resourceUri:r})}:{},children:n.jsx(Qo,{onSelectPackage:e,resourceUri:r})}),n.jsx(ac,{resourceUri:r}),n.jsx(Sl,{resourceUri:r})]})}function fo({array1:e,array2:r,parser:u=s=>s}){return e&&r&&e.length===r.length&&e.every((s,d)=>u(s)===u(r[d]))}function po(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function fc(e={}){const{ignoreAccents:r=!0,ignoreCase:u=!0,limit:s,matchFrom:d="any",stringify:c,trim:l=!1}=e;return(m,{inputValue:p,getOptionLabel:h})=>{let g=l?p.trim():p;u&&(g=g.toLowerCase()),r&&(g=po(g));const v=g?m.filter(x=>{let y=(c||h)(x);return u&&(y=y.toLowerCase()),r&&(y=po(y)),d==="start"?y.startsWith(g):y.includes(g)}):m;return typeof s=="number"?v.slice(0,s):v}}const pc=fc(),mo=5,mc=e=>e.current!==null&&e.current.parentElement?.contains(document.activeElement),gc=[];function go(e,r,u,s){if(r||e==null||s)return"";const d=u(e);return typeof d=="string"?d:""}function yc(e){const{unstable_isActiveElementInListbox:r=mc,unstable_classNamePrefix:u="Mui",autoComplete:s=!1,autoHighlight:d=!1,autoSelect:c=!1,blurOnSelect:l=!1,clearOnBlur:m=!e.freeSolo,clearOnEscape:p=!1,componentName:h="useAutocomplete",defaultValue:g=e.multiple?gc:null,disableClearable:v=!1,disableCloseOnSelect:x=!1,disabled:y,disabledItemsFocusable:C=!1,disableListWrap:w=!1,filterOptions:k=pc,filterSelectedOptions:O=!1,freeSolo:M=!1,getOptionDisabled:j,getOptionKey:E,getOptionLabel:$=z=>z.label??z,groupBy:U,handleHomeEndKeys:P=!e.freeSolo,id:K,includeInputInList:A=!1,inputValue:L,isOptionEqualToValue:V=(z,W)=>z===W,multiple:N=!1,onChange:_,onClose:Q,onHighlightChange:re,onInputChange:ee,onOpen:te,open:Z,openOnFocus:ae=!1,options:H,readOnly:J=!1,renderValue:se,selectOnFocus:xe=!e.freeSolo,value:$e}=e,oe=o.useId(K);let le=$;le=z=>{const W=$(z);return typeof W!="string"?String(W):W};const Ne=he.useRef(!1),q=he.useRef(!0),X=he.useRef(null),ge=he.useRef(null),[Se,Ee]=he.useState(null),[we,Te]=he.useState(-1),Re=d?0:-1,Fe=he.useRef(Re),Ye=he.useRef(go(g??$e,N,le)).current,[ie,Qe]=o.useControlled({controlled:$e,default:g,name:h}),[ye,We]=o.useControlled({controlled:L,default:Ye,name:h,state:"inputValue"}),[ct,Nt]=he.useState(!1),gt=he.useCallback((z,W,ne)=>{if(!(N?ie.length<W.length:W!==null)&&!m)return;const Y=go(W,N,le,se);ye!==Y&&(We(Y),ee&&ee(z,Y,ne))},[le,ye,N,ee,We,m,ie,se]),[Ze,ut]=o.useControlled({controlled:Z,default:!1,name:h,state:"open"}),[pe,st]=he.useState(!0),nn=!N&&ie!=null&&ye===le(ie),Ge=Ze&&!J,ce=Ge?k(H.filter(z=>!(O&&(N?ie:[ie]).some(W=>W!==null&&V(z,W)))),{inputValue:nn&&pe?"":ye,getOptionLabel:le}):[],Je=ml({filteredOptions:ce,value:ie,inputValue:ye});he.useEffect(()=>{const z=ie!==Je.value;ct&&!z||M&&!z||gt(null,ie,"reset")},[ie,gt,ct,Je.value,M]);const qe=Ze&&ce.length>0&&!J,tt=o.useEventCallback(z=>{if(z===-1)X.current.focus();else{const W=se?"data-item-index":"data-tag-index";Se.querySelector(`[${W}="${z}"]`).focus()}});he.useEffect(()=>{N&&we>ie.length-1&&(Te(-1),tt(-1))},[ie,N,we,tt]);function dt(z,W){if(!ge.current||z<0||z>=ce.length)return-1;let ne=z;for(;;){const de=ge.current.querySelector(`[data-option-index="${ne}"]`),Y=C?!1:!de||de.disabled||de.getAttribute("aria-disabled")==="true";if(de&&de.hasAttribute("tabindex")&&!Y)return ne;if(W==="next"?ne=(ne+1)%ce.length:ne=(ne-1+ce.length)%ce.length,ne===z)return-1}}const ot=o.useEventCallback(({event:z,index:W,reason:ne})=>{if(Fe.current=W,W===-1?X.current.removeAttribute("aria-activedescendant"):X.current.setAttribute("aria-activedescendant",`${oe}-option-${W}`),re&&["mouse","keyboard","touch"].includes(ne)&&re(z,W===-1?null:ce[W],ne),!ge.current)return;const de=ge.current.querySelector(`[role="option"].${u}-focused`);de&&(de.classList.remove(`${u}-focused`),de.classList.remove(`${u}-focusVisible`));let Y=ge.current;if(ge.current.getAttribute("role")!=="listbox"&&(Y=ge.current.parentElement.querySelector('[role="listbox"]')),!Y)return;if(W===-1){Y.scrollTop=0;return}const je=ge.current.querySelector(`[data-option-index="${W}"]`);if(je&&(je.classList.add(`${u}-focused`),ne==="keyboard"&&je.classList.add(`${u}-focusVisible`),Y.scrollHeight>Y.clientHeight&&ne!=="mouse"&&ne!=="touch")){const Ie=je,at=Y.clientHeight+Y.scrollTop,cn=Ie.offsetTop+Ie.offsetHeight;cn>at?Y.scrollTop=cn-Y.clientHeight:Ie.offsetTop-Ie.offsetHeight*(U?1.3:0)<Y.scrollTop&&(Y.scrollTop=Ie.offsetTop-Ie.offsetHeight*(U?1.3:0))}}),nt=o.useEventCallback(({event:z,diff:W,direction:ne="next",reason:de})=>{if(!Ge)return;const je=dt((()=>{const Ie=ce.length-1;if(W==="reset")return Re;if(W==="start")return 0;if(W==="end")return Ie;const at=Fe.current+W;return at<0?at===-1&&A?-1:w&&Fe.current!==-1||Math.abs(W)>1?0:Ie:at>Ie?at===Ie+1&&A?-1:w||Math.abs(W)>1?Ie:0:at})(),ne);if(ot({index:je,reason:de,event:z}),s&&W!=="reset")if(je===-1)X.current.value=ye;else{const Ie=le(ce[je]);X.current.value=Ie,Ie.toLowerCase().indexOf(ye.toLowerCase())===0&&ye.length>0&&X.current.setSelectionRange(ye.length,Ie.length)}}),rn=!fo({array1:Je.filteredOptions,array2:ce,parser:le}),Cn=()=>{const z=(W,ne)=>{const de=W?le(W):"",Y=ne?le(ne):"";return de===Y};if(Fe.current!==-1&&!fo({array1:Je.filteredOptions,array2:ce,parser:le})&&Je.inputValue===ye&&(N?ie.length===Je.value.length&&Je.value.every((W,ne)=>le(ie[ne])===le(W)):z(Je.value,ie))){const W=Je.filteredOptions[Fe.current];if(W)return ce.findIndex(ne=>le(ne)===le(W))}return-1},Ft=he.useCallback(()=>{if(!Ge)return;const z=Cn();if(z!==-1){Fe.current=z;return}const W=N?ie[0]:ie;if(ce.length===0||W==null){nt({diff:"reset"});return}if(ge.current){if(W!=null){const ne=ce[Fe.current];if(N&&ne&&ie.findIndex(Y=>V(ne,Y))!==-1)return;const de=ce.findIndex(Y=>V(Y,W));de===-1?nt({diff:"reset"}):ot({index:de});return}if(Fe.current>=ce.length-1){ot({index:ce.length-1});return}ot({index:Fe.current})}},[ce.length,N?!1:ie,O,nt,ot,Ge,ye,N]),Ct=o.useEventCallback(z=>{o.setRef(ge,z),z&&Ft()});he.useEffect(()=>{rn&&Ft()},[Ft,rn]);const ze=z=>{Ze||(ut(!0),st(!0),te&&te(z))},kt=(z,W)=>{Ze&&(ut(!1),Q&&Q(z,W))},ht=(z,W,ne,de)=>{if(N){if(ie.length===W.length&&ie.every((Y,je)=>Y===W[je]))return}else if(ie===W)return;_&&_(z,W,ne,de),Qe(W)},ft=he.useRef(!1),yt=(z,W,ne="selectOption",de="options")=>{let Y=ne,je=W;if(N){je=Array.isArray(ie)?ie.slice():[];const Ie=je.findIndex(at=>V(W,at));Ie===-1?je.push(W):de!=="freeSolo"&&(je.splice(Ie,1),Y="removeOption")}gt(z,je,Y),ht(z,je,Y,{option:W}),!x&&(!z||!z.ctrlKey&&!z.metaKey)&&kt(z,Y),(l===!0||l==="touch"&&ft.current||l==="mouse"&&!ft.current)&&X.current.blur()};function sn(z,W){if(z===-1)return-1;let ne=z;for(;;){if(W==="next"&&ne===ie.length||W==="previous"&&ne===-1)return-1;const de=se?"data-item-index":"data-tag-index",Y=Se.querySelector(`[${de}="${ne}"]`);if(!Y||!Y.hasAttribute("tabindex")||Y.disabled||Y.getAttribute("aria-disabled")==="true")ne+=W==="next"?1:-1;else return ne}}const Tt=(z,W)=>{if(!N)return;ye===""&&kt(z,"toggleInput");let ne=we;we===-1?ye===""&&W==="previous"&&(ne=ie.length-1):(ne+=W==="next"?1:-1,ne<0&&(ne=0),ne===ie.length&&(ne=-1)),ne=sn(ne,W),Te(ne),tt(ne)},Ht=z=>{Ne.current=!0,We(""),ee&&ee(z,"","clear"),ht(z,N?[]:null,"clear")},on=z=>W=>{if(z.onKeyDown&&z.onKeyDown(W),!W.defaultMuiPrevented&&(we!==-1&&!["ArrowLeft","ArrowRight"].includes(W.key)&&(Te(-1),tt(-1)),W.which!==229))switch(W.key){case"Home":Ge&&P&&(W.preventDefault(),nt({diff:"start",direction:"next",reason:"keyboard",event:W}));break;case"End":Ge&&P&&(W.preventDefault(),nt({diff:"end",direction:"previous",reason:"keyboard",event:W}));break;case"PageUp":W.preventDefault(),nt({diff:-mo,direction:"previous",reason:"keyboard",event:W}),ze(W);break;case"PageDown":W.preventDefault(),nt({diff:mo,direction:"next",reason:"keyboard",event:W}),ze(W);break;case"ArrowDown":W.preventDefault(),nt({diff:1,direction:"next",reason:"keyboard",event:W}),ze(W);break;case"ArrowUp":W.preventDefault(),nt({diff:-1,direction:"previous",reason:"keyboard",event:W}),ze(W);break;case"ArrowLeft":!N&&se?tt(0):Tt(W,"previous");break;case"ArrowRight":!N&&se?tt(-1):Tt(W,"next");break;case"Enter":if(Fe.current!==-1&&Ge){const ne=ce[Fe.current],de=j?j(ne):!1;if(W.preventDefault(),de)return;yt(W,ne,"selectOption"),s&&X.current.setSelectionRange(X.current.value.length,X.current.value.length)}else M&&ye!==""&&nn===!1&&(N&&W.preventDefault(),yt(W,ye,"createOption","freeSolo"));break;case"Escape":Ge?(W.preventDefault(),W.stopPropagation(),kt(W,"escape")):p&&(ye!==""||N&&ie.length>0||se)&&(W.preventDefault(),W.stopPropagation(),Ht(W));break;case"Backspace":if(N&&!J&&ye===""&&ie.length>0){const ne=we===-1?ie.length-1:we,de=ie.slice();de.splice(ne,1),ht(W,de,"removeOption",{option:ie[ne]})}!N&&se&&!J&&(Qe(null),tt(-1));break;case"Delete":if(N&&!J&&ye===""&&ie.length>0&&we!==-1){const ne=we,de=ie.slice();de.splice(ne,1),ht(W,de,"removeOption",{option:ie[ne]})}!N&&se&&!J&&(Qe(null),tt(-1));break}},Me=z=>{Nt(!0),ae&&!Ne.current&&ze(z)},Ue=z=>{if(r(ge)){X.current.focus();return}Nt(!1),q.current=!0,Ne.current=!1,c&&Fe.current!==-1&&Ge?yt(z,ce[Fe.current],"blur"):c&&M&&ye!==""?yt(z,ye,"blur","freeSolo"):m&>(z,ie,"blur"),kt(z,"blur")},_t=z=>{const W=z.target.value;ye!==W&&(We(W),st(!1),ee&&ee(z,W,"input")),W===""?!v&&!N&&ht(z,null,"clear"):ze(z)},an=z=>{const W=Number(z.currentTarget.getAttribute("data-option-index"));Fe.current!==W&&ot({event:z,index:W,reason:"mouse"})},Ke=z=>{ot({event:z,index:Number(z.currentTarget.getAttribute("data-option-index")),reason:"touch"}),ft.current=!0},Vt=z=>{const W=Number(z.currentTarget.getAttribute("data-option-index"));yt(z,ce[W],"selectOption"),ft.current=!1},ln=z=>W=>{const ne=ie.slice();ne.splice(z,1),ht(W,ne,"removeOption",{option:ie[z]})},Wt=z=>{ht(z,null,"removeOption",{option:ie})},Pe=z=>{Ze?kt(z,"toggleInput"):ze(z)},Le=z=>{z.currentTarget.contains(z.target)&&z.target.getAttribute("id")!==oe&&z.preventDefault()},xt=z=>{z.currentTarget.contains(z.target)&&(X.current.focus(),xe&&q.current&&X.current.selectionEnd-X.current.selectionStart===0&&X.current.select(),q.current=!1)},Bt=z=>{!y&&(ye===""||!Ze)&&Pe(z)};let qt=M&&ye.length>0;qt=qt||(N?ie.length>0:ie!==null);let Ut=ce;return U&&(Ut=ce.reduce((z,W,ne)=>{const de=U(W);return z.length>0&&z[z.length-1].group===de?z[z.length-1].options.push(W):z.push({key:ne,index:ne,group:de,options:[W]}),z},[])),y&&ct&&Ue(),{getRootProps:(z={})=>({...z,onKeyDown:on(z),onMouseDown:Le,onClick:xt}),getInputLabelProps:()=>({id:`${oe}-label`,htmlFor:oe}),getInputProps:()=>({id:oe,value:ye,onBlur:Ue,onFocus:Me,onChange:_t,onMouseDown:Bt,"aria-activedescendant":Ge?"":null,"aria-autocomplete":s?"both":"list","aria-controls":qe?`${oe}-listbox`:void 0,"aria-expanded":qe,autoComplete:"off",ref:X,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:y}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:Ht}),getItemProps:({index:z=0}={})=>({...N&&{key:z},...se?{"data-item-index":z}:{"data-tag-index":z},tabIndex:-1,...!J&&{onDelete:N?ln(z):Wt}}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:Pe}),getTagProps:({index:z})=>({key:z,"data-tag-index":z,tabIndex:-1,...!J&&{onDelete:ln(z)}}),getListboxProps:()=>({role:"listbox",id:`${oe}-listbox`,"aria-labelledby":`${oe}-label`,ref:Ct,onMouseDown:z=>{z.preventDefault()}}),getOptionProps:({index:z,option:W})=>{const ne=(N?ie:[ie]).some(Y=>Y!=null&&V(W,Y)),de=j?j(W):!1;return{key:E?.(W)??le(W),tabIndex:-1,role:"option",id:`${oe}-option-${z}`,onMouseMove:an,onClick:Vt,onTouchStart:Ke,"data-option-index":z,"aria-disabled":de,"aria-selected":ne}},id:oe,inputValue:ye,value:ie,dirty:qt,expanded:Ge&&Se,popupOpen:Ge,focused:ct||we!==-1,anchorEl:Se,setAnchorEl:Ee,focusedItem:we,focusedTag:we,groupedOptions:Ut}}function xc(e){return o.generateUtilityClass("MuiListSubheader",e)}o.generateUtilityClasses("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);const bc=e=>{const{classes:r,color:u,disableGutters:s,inset:d,disableSticky:c}=e,l={root:["root",u!=="default"&&`color${o.capitalize(u)}`,!s&&"gutters",d&&"inset",!c&&"sticky"]};return o.composeClasses(l,xc,r)},vc=o.styled("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.root,u.color!=="default"&&r[`color${o.capitalize(u.color)}`],!u.disableGutters&&r.gutters,u.inset&&r.inset,!u.disableSticky&&r.sticky]}})(o.memoTheme(({theme:e})=>({boxSizing:"border-box",lineHeight:"48px",listStyle:"none",color:(e.vars||e).palette.text.secondary,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(14),variants:[{props:{color:"primary"},style:{color:(e.vars||e).palette.primary.main}},{props:{color:"inherit"},style:{color:"inherit"}},{props:({ownerState:r})=>!r.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:r})=>r.inset,style:{paddingLeft:72}},{props:({ownerState:r})=>!r.disableSticky,style:{position:"sticky",top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper}}]}))),Jr=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiListSubheader"}),{className:d,color:c="default",component:l="li",disableGutters:m=!1,disableSticky:p=!1,inset:h=!1,...g}=s,v={...s,color:c,component:l,disableGutters:m,disableSticky:p,inset:h},x=bc(v);return n.jsx(vc,{as:l,className:o.clsx(x.root,d),ref:u,ownerState:v,...g})});Jr&&(Jr.muiSkipListHighlight=!0);const Sc=o.createSvgIcon(n.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}));function wc(e){return o.generateUtilityClass("MuiAutocomplete",e)}const ve=o.generateUtilityClasses("MuiAutocomplete",["root","expanded","fullWidth","focused","focusVisible","tag","tagSizeSmall","tagSizeMedium","hasPopupIcon","hasClearIcon","inputRoot","input","inputFocused","endAdornment","clearIndicator","popupIndicator","popupIndicatorOpen","popper","popperDisablePortal","paper","listbox","loading","noOptions","option","groupLabel","groupUl"]);var yo,xo;const Cc=e=>{const{classes:r,disablePortal:u,expanded:s,focused:d,fullWidth:c,hasClearIcon:l,hasPopupIcon:m,inputFocused:p,popupOpen:h,size:g}=e,v={root:["root",s&&"expanded",d&&"focused",c&&"fullWidth",l&&"hasClearIcon",m&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",p&&"inputFocused"],tag:["tag",`tagSize${o.capitalize(g)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",h&&"popupIndicatorOpen"],popper:["popper",u&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return o.composeClasses(v,wc,r)},kc=o.styled("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e,{fullWidth:s,hasClearIcon:d,hasPopupIcon:c,inputFocused:l,size:m}=u;return[{[`& .${ve.tag}`]:r.tag},{[`& .${ve.tag}`]:r[`tagSize${o.capitalize(m)}`]},{[`& .${ve.inputRoot}`]:r.inputRoot},{[`& .${ve.input}`]:r.input},{[`& .${ve.input}`]:l&&r.inputFocused},r.root,s&&r.fullWidth,c&&r.hasPopupIcon,d&&r.hasClearIcon]}})({[`&.${ve.focused} .${ve.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${ve.clearIndicator}`]:{visibility:"visible"}},[`& .${ve.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${ve.inputRoot}`]:{[`.${ve.hasPopupIcon}&, .${ve.hasClearIcon}&`]:{paddingRight:30},[`.${ve.hasPopupIcon}.${ve.hasClearIcon}&`]:{paddingRight:56},[`& .${ve.input}`]:{width:0,minWidth:30}},[`& .${o.inputClasses.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${o.inputClasses.root}.${o.inputBaseClasses.sizeSmall}`]:{[`& .${o.inputClasses.input}`]:{padding:"2px 4px 3px 0"}},[`& .${o.outlinedInputClasses.root}`]:{padding:9,[`.${ve.hasPopupIcon}&, .${ve.hasClearIcon}&`]:{paddingRight:39},[`.${ve.hasPopupIcon}.${ve.hasClearIcon}&`]:{paddingRight:65},[`& .${ve.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${ve.endAdornment}`]:{right:9}},[`& .${o.outlinedInputClasses.root}.${o.inputBaseClasses.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${ve.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${o.filledInputClasses.root}`]:{paddingTop:19,paddingLeft:8,[`.${ve.hasPopupIcon}&, .${ve.hasClearIcon}&`]:{paddingRight:39},[`.${ve.hasPopupIcon}.${ve.hasClearIcon}&`]:{paddingRight:65},[`& .${o.filledInputClasses.input}`]:{padding:"7px 4px"},[`& .${ve.endAdornment}`]:{right:9}},[`& .${o.filledInputClasses.root}.${o.inputBaseClasses.sizeSmall}`]:{paddingBottom:1,[`& .${o.filledInputClasses.input}`]:{padding:"2.5px 4px"}},[`& .${o.inputBaseClasses.hiddenLabel}`]:{paddingTop:8},[`& .${o.filledInputClasses.root}.${o.inputBaseClasses.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${ve.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${o.filledInputClasses.root}.${o.inputBaseClasses.hiddenLabel}.${o.inputBaseClasses.sizeSmall}`]:{[`& .${ve.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${ve.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${ve.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${ve.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${ve.inputRoot}`]:{flexWrap:"wrap"}}}]}),Tc=o.styled("div",{name:"MuiAutocomplete",slot:"EndAdornment"})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),Oc=o.styled(o.IconButton,{name:"MuiAutocomplete",slot:"ClearIndicator"})({marginRight:-2,padding:4,visibility:"hidden"}),Mc=o.styled(o.IconButton,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.popupIndicator,u.popupOpen&&r.popupIndicatorOpen]}})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),jc=o.styled(o.Popper,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[{[`& .${ve.option}`]:r.option},r.popper,u.disablePortal&&r.popperDisablePortal]}})(o.memoTheme(({theme:e})=>({zIndex:(e.vars||e).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]}))),Dc=o.styled(o.Paper,{name:"MuiAutocomplete",slot:"Paper"})(o.memoTheme(({theme:e})=>({...e.typography.body1,overflow:"auto"}))),Ec=o.styled("div",{name:"MuiAutocomplete",slot:"Loading"})(o.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),Ic=o.styled("div",{name:"MuiAutocomplete",slot:"NoOptions"})(o.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),Nc=o.styled("ul",{name:"MuiAutocomplete",slot:"Listbox"})(o.memoTheme(({theme:e})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${ve.option}`]:{minHeight:48,display:"flex",overflow:"hidden",justifyContent:"flex-start",alignItems:"center",cursor:"pointer",paddingTop:6,boxSizing:"border-box",outline:"0",WebkitTapHighlightColor:"transparent",paddingBottom:6,paddingLeft:16,paddingRight:16,[e.breakpoints.up("sm")]:{minHeight:"auto"},[`&.${ve.focused}`]:{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},'&[aria-disabled="true"]':{opacity:(e.vars||e).palette.action.disabledOpacity,pointerEvents:"none"},[`&.${ve.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},'&[aria-selected="true"]':{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${ve.focused}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${ve.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}}}}))),Fc=o.styled(Jr,{name:"MuiAutocomplete",slot:"GroupLabel"})(o.memoTheme(({theme:e})=>({backgroundColor:(e.vars||e).palette.background.paper,top:-8}))),Ac=o.styled("ul",{name:"MuiAutocomplete",slot:"GroupUl"})({padding:0,[`& .${ve.option}`]:{paddingLeft:24}}),es=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiAutocomplete"}),{autoComplete:d=!1,autoHighlight:c=!1,autoSelect:l=!1,blurOnSelect:m=!1,ChipProps:p,className:h,clearIcon:g=yo||(yo=n.jsx(Sc,{fontSize:"small"})),clearOnBlur:v=!s.freeSolo,clearOnEscape:x=!1,clearText:y="Clear",closeText:C="Close",componentsProps:w,defaultValue:k=s.multiple?[]:null,disableClearable:O=!1,disableCloseOnSelect:M=!1,disabled:j=!1,disabledItemsFocusable:E=!1,disableListWrap:$=!1,disablePortal:U=!1,filterOptions:P,filterSelectedOptions:K=!1,forcePopupIcon:A="auto",freeSolo:L=!1,fullWidth:V=!1,getLimitTagsText:N=Ce=>`+${Ce}`,getOptionDisabled:_,getOptionKey:Q,getOptionLabel:re,isOptionEqualToValue:ee,groupBy:te,handleHomeEndKeys:Z=!s.freeSolo,id:ae,includeInputInList:H=!1,inputValue:J,limitTags:se=-1,ListboxComponent:xe,ListboxProps:$e,loading:oe=!1,loadingText:le="Loading…",multiple:Ne=!1,noOptionsText:q="No options",onChange:X,onClose:ge,onHighlightChange:Se,onInputChange:Ee,onOpen:we,open:Te,openOnFocus:Re=!1,openText:Fe="Open",options:Ye,PaperComponent:ie,PopperComponent:Qe,popupIcon:ye=xo||(xo=n.jsx(o.ArrowDropDownIcon,{})),readOnly:We=!1,renderGroup:ct,renderInput:Nt,renderOption:gt,renderTags:Ze,renderValue:ut,selectOnFocus:pe=!s.freeSolo,size:st="medium",slots:nn={},slotProps:Ge={},value:ce,...Je}=s,{getRootProps:qe,getInputProps:tt,getInputLabelProps:dt,getPopupIndicatorProps:ot,getClearProps:nt,getItemProps:rn,getListboxProps:Cn,getOptionProps:Ft,value:Ct,dirty:ze,expanded:kt,id:ht,popupOpen:ft,focused:yt,focusedItem:sn,anchorEl:Tt,setAnchorEl:Ht,inputValue:on,groupedOptions:Me}=yc({...s,componentName:"Autocomplete"}),Ue=!O&&!j&&ze&&!We,_t=(!L||A===!0)&&A!==!1,{onMouseDown:an}=tt(),{ref:Ke,...Vt}=Cn(),Wt=re||(Ce=>Ce.label??Ce),Pe={...s,disablePortal:U,expanded:kt,focused:yt,fullWidth:V,getOptionLabel:Wt,hasClearIcon:Ue,hasPopupIcon:_t,inputFocused:sn===-1,popupOpen:ft,size:st},Le=Cc(Pe),xt={slots:{paper:ie,popper:Qe,...nn},slotProps:{chip:p,listbox:$e,...w,...Ge}},[Bt,qt]=o.useSlot("listbox",{elementType:Nc,externalForwardedProps:xt,ownerState:Pe,className:Le.listbox,additionalProps:Vt,ref:Ke}),[Ut,z]=o.useSlot("paper",{elementType:o.Paper,externalForwardedProps:xt,ownerState:Pe,className:Le.paper}),[W,ne]=o.useSlot("popper",{elementType:o.Popper,externalForwardedProps:xt,ownerState:Pe,className:Le.popper,additionalProps:{disablePortal:U,style:{width:Tt?Tt.clientWidth:null},role:"presentation",anchorEl:Tt,open:ft}});let de;const Y=Ce=>({className:Le.tag,disabled:j,...rn(Ce)});if(Ne?Ct.length>0&&(Ze?de=Ze(Ct,Y,Pe):ut?de=ut(Ct,Y,Pe):de=Ct.map((Ce,Ot)=>{const{key:et,...At}=Y({index:Ot});return n.jsx(o.Chip,{label:Wt(Ce),size:st,...At,...xt.slotProps.chip},et)})):ut&&Ct!=null&&(de=ut(Ct,Y,Pe)),se>-1&&Array.isArray(de)){const Ce=de.length-se;!yt&&Ce>0&&(de=de.splice(0,se),de.push(n.jsx("span",{className:Le.tag,children:N(Ce)},de.length)))}const Ie=ct||(Ce=>n.jsxs("li",{children:[n.jsx(Fc,{className:Le.groupLabel,ownerState:Pe,component:"div",children:Ce.group}),n.jsx(Ac,{className:Le.groupUl,ownerState:Pe,children:Ce.children})]},Ce.key)),cn=gt||((Ce,Ot)=>{const{key:et,...At}=Ce;return n.jsx("li",{...At,children:Wt(Ot)},et)}),kn=(Ce,Ot)=>{const et=Ft({option:Ce,index:Ot});return cn({...et,className:Le.option},Ce,{selected:et["aria-selected"],index:Ot,inputValue:on},Pe)},Tn=xt.slotProps.clearIndicator,rr=xt.slotProps.popupIndicator;return n.jsxs(he.Fragment,{children:[n.jsx(kc,{ref:u,className:o.clsx(Le.root,h),ownerState:Pe,...qe(Je),children:Nt({id:ht,disabled:j,fullWidth:!0,size:st==="small"?"small":void 0,InputLabelProps:dt(),InputProps:{ref:Ht,className:Le.inputRoot,startAdornment:de,onMouseDown:Ce=>{Ce.target===Ce.currentTarget&&an(Ce)},...(Ue||_t)&&{endAdornment:n.jsxs(Tc,{className:Le.endAdornment,ownerState:Pe,children:[Ue?n.jsx(Oc,{...nt(),"aria-label":y,title:y,ownerState:Pe,...Tn,className:o.clsx(Le.clearIndicator,Tn?.className),children:g}):null,_t?n.jsx(Mc,{...ot(),disabled:j,"aria-label":ft?C:Fe,title:ft?C:Fe,ownerState:Pe,...rr,className:o.clsx(Le.popupIndicator,rr?.className),children:ye}):null]})}},inputProps:{className:Le.input,disabled:j,readOnly:We,...tt()}})}),Tt?n.jsx(jc,{as:W,...ne,children:n.jsxs(Dc,{as:Ut,...z,children:[oe&&Me.length===0?n.jsx(Ec,{className:Le.loading,ownerState:Pe,children:le}):null,Me.length===0&&!L&&!oe?n.jsx(Ic,{className:Le.noOptions,ownerState:Pe,role:"presentation",onMouseDown:Ce=>{Ce.preventDefault()},children:q}):null,Me.length>0?n.jsx(Bt,{as:xe,...qt,children:Me.map((Ce,Ot)=>te?Ie({key:Ce.key,group:Ce.group,children:Ce.options.map((et,At)=>kn(et,Ce.index+At))}):kn(Ce,Ot))}):null]})}):null]})});o.dayjs.extend(o.utc);function Pr(e){switch(e){case"Star":return["Equals","Contains"];case"MinMax":return["Equals","Less Than","Greater Than","Between"];case"DateMinMax":return["Equals","Before","After","Between"];case"Retrieval":return["Semantic Search"];case"Boolean":return["Equals"];case"NONE":default:return[]}}function Rc(e){return e==="DateMinMax"}function Lr(e){return e==="Between"}function $c({spec:e,values:r,selection:u,onChange:s,retrievalFn:d}){const c=()=>u?.matchType?u.matchType:e.defaultMatchType?e.defaultMatchType:e.filterType==="DateMinMax"?"Between":Pr(e.filterType)[0]||"Equals",[l,m]=I.useState(c()),[p,h]=I.useState(u?.value??""),[g,v]=I.useState(u?.value2??""),[x,y]=I.useState([]),[C,w]=I.useState(!1),[k,O]=I.useState(""),[M,j]=I.useState(!1),[E,$]=I.useState(!1),U=I.useRef(null),P=I.useRef(0),[K,A]=I.useState(!1);I.useEffect(()=>{if(e.filterType!=="Retrieval"||!d)return;const H=k.trim();if(H.length<=2){y([]),j(!1);return}return U.current&&clearTimeout(U.current),U.current=setTimeout(async()=>{P.current+=1;const J=P.current;w(!0);try{const se=await d(H,e);J===P.current&&y(se)}catch(se){J===P.current&&(console.error("Retrieval failed",se),y([]))}finally{J===P.current&&(w(!1),j(!0))}},500),()=>{U.current&&clearTimeout(U.current)}},[k,e,d]),I.useEffect(()=>{u===null?(h(""),v(""),m(e.defaultMatchType??(e.filterType==="DateMinMax"?"Between":Pr(e.filterType)[0]||"Equals"))):u&&(m(u.matchType),h(u.value??""),v(u.value2??""))},[u,e.filterType,e.defaultMatchType]);const L=Pr(e.filterType),V=Rc(e.filterType),N=Lr(l),_=V&&r.length>=2&&r[0].value instanceof Date?o.dayjs.utc(r[0].value):void 0,Q=V&&r.length>=2&&r[1].value instanceof Date?o.dayjs.utc(r[1].value):void 0,re=e.filterType==="MinMax"&&r.length>=2&&typeof r[0].value=="number"?r[0].value:void 0,ee=e.filterType==="MinMax"&&r.length>=2&&typeof r[1].value=="number"?r[1].value:void 0;if(L.length===0)return null;const te=H=>{const J=H.target.value;m(J),Lr(J)||v(""),p&&s({dimensionName:e.dimensionName,source:e.source,filterName:e.filterName,matchType:J,value:p,...Lr(J)&&g&&{value2:g}})},Z=(H,J)=>{h(H??""),J!==void 0&&v(J??"");const se=Array.isArray(H)&&H.length===0;s(!se&&H!==""&&H!==null&&H!==void 0?{dimensionName:e.dimensionName,source:e.source,filterName:e.filterName,matchType:l,value:H,...N&&J&&{value2:J}}:null)},ae=()=>{h(""),v(""),s(null)};return n.jsxs(Ae,{sx:{display:"flex",flexDirection:"column",gap:1.5,fontSize:"0.75rem","& .MuiInputBase-root":{fontSize:"0.75rem"},"& .MuiInputBase-input":{padding:"6px 10px"},"& .MuiSelect-select":{padding:"6px 10px !important"},"& .MuiAutocomplete-input":{padding:"0 !important"},"& .MuiAutocomplete-root .MuiInputBase-root":{padding:"5px 10px",minHeight:"29.5px",boxSizing:"border-box",flexWrap:"wrap"},"& .MuiChip-root":{height:"16px",margin:"0 2px 0 0"},"& .MuiChip-label":{fontSize:"0.7rem",padding:"0 6px"},"& .MuiChip-deleteIcon":{fontSize:"14px",margin:"0 2px 0 -4px"},"& .MuiInputLabel-root":{fontSize:"0.75rem",transform:"translate(10px, 6px) scale(1)"},"& .MuiInputLabel-shrink":{fontSize:"0.85rem",transform:"translate(14px, -9px) scale(0.75)"},"& .MuiOutlinedInput-notchedOutline legend":{fontSize:"0.65rem"},"& .MuiFormHelperText-root":{fontSize:"0.65rem",marginTop:"2px"},"& .MuiSvgIcon-root":{fontSize:"1.25rem"}},children:[n.jsxs(Ae,{sx:{fontWeight:600,color:e.required&&!u?"error.main":"text.primary"},children:[e.label??e.dimensionName,e.required&&n.jsx(Ae,{component:"span",sx:{color:u?"text.secondary":"error.main",fontWeight:400,fontSize:"0.7rem",ml:.5},children:"(required)"})]}),e.filterType!=="Boolean"&&!e.defaultMatchType&&L.length>1&&n.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[n.jsx(o.InputLabel,{children:"Match Type"}),n.jsx(o.Select,{value:l,label:"Match Type",onChange:te,MenuProps:{PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}},children:L.map(H=>n.jsx(He,{value:H,children:H},H))})]}),e.filterType==="Star"&&l==="Equals"&&n.jsx(es,{multiple:!0,size:"small",options:r,getOptionLabel:H=>typeof H=="string"?H:typeof H=="object"&&H!==null&&"value"in H?String(H.value):String(H),value:Array.isArray(p)?p.map(H=>r.find(J=>J.value===H)||H):p?[r.find(H=>H.value===p)||p]:[],onChange:(H,J)=>{const se=J.map(xe=>typeof xe=="string"?xe:xe&&typeof xe=="object"&&"value"in xe?xe.value:xe);Z(se)},noOptionsText:"No matches found",renderInput:H=>n.jsx(o.TextField,{...H,size:"small",label:"Values",placeholder:"Select values..."}),freeSolo:!e.values||e.values.length===0,slotProps:{paper:{sx:{"& .MuiAutocomplete-option":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}}}),e.filterType==="Star"&&l==="Contains"&&n.jsx(o.TextField,{size:"small",label:"Search Text",value:p,onChange:H=>h(H.target.value),onBlur:()=>Z(p),onKeyDown:H=>{H.key==="Enter"&&Z(p)},placeholder:"Enter text to search...",fullWidth:!0}),e.filterType==="Boolean"&&n.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[n.jsx(o.InputLabel,{children:"Value"}),n.jsxs(o.Select,{value:p===!0?"true":p===!1?"false":"",label:"Value",onChange:H=>{const J=H.target.value;J==="true"?Z(!0):J==="false"?Z(!1):ae()},MenuProps:{PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}},children:[n.jsx(He,{value:"",children:n.jsx("em",{children:"Blank"})}),n.jsx(He,{value:"true",children:"True"}),n.jsx(He,{value:"false",children:"False"})]})]}),e.filterType==="Retrieval"&&l==="Semantic Search"&&n.jsx(es,{multiple:!0,size:"small",options:x,loading:C,getOptionLabel:H=>typeof H=="string"?H:typeof H=="object"&&H!==null&&"value"in H?String(H.value):String(H),value:Array.isArray(p)?p.map(H=>x.find(se=>se.value===H)||{value:H}):p?[{value:p}]:[],onInputChange:(H,J)=>{O(J)},onChange:(H,J)=>{const se=J.map(xe=>typeof xe=="string"?xe:xe&&typeof xe=="object"&&"value"in xe?xe.value:xe);Z(se)},noOptionsText:k.trim().length<=2?"Type at least 3 characters to search":"No matches found",renderInput:H=>n.jsx(o.TextField,{...H,size:"small",label:"Search Values",placeholder:"Type to search...",onFocus:()=>$(!0),onBlur:()=>$(!1),helperText:E&&!C&&M&&x.length===0?"No matches found":void 0,InputProps:{...H.InputProps,endAdornment:n.jsxs(n.Fragment,{children:[C?n.jsx(o.CircularProgress,{color:"inherit",size:20}):null,H.InputProps.endAdornment]})}}),freeSolo:!0,filterOptions:H=>H,slotProps:{paper:{sx:{"& .MuiAutocomplete-option":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}}}),e.filterType==="MinMax"&&!N&&n.jsx(o.TextField,{size:"small",type:"number",label:"Value",value:p,onChange:H=>Z(parseFloat(H.target.value)||""),onFocus:()=>A(!0),onBlur:()=>A(!1),placeholder:"Enter number...",fullWidth:!0,inputProps:{min:re,max:ee},helperText:K&&re!==void 0&&ee!==void 0?`Valid range: [${re} - ${ee}]`:void 0}),e.filterType==="MinMax"&&N&&n.jsxs(Ae,{sx:{display:"flex",flexDirection:"column",gap:1},children:[n.jsxs(Ae,{sx:{display:"flex",gap:1,alignItems:"center"},children:[n.jsx(o.TextField,{size:"small",type:"number",label:"From",value:p,onChange:H=>Z(parseFloat(H.target.value)||"",g),onFocus:()=>A(!0),onBlur:()=>A(!1),placeholder:"Min...",fullWidth:!0,inputProps:{min:re,max:g||ee}}),n.jsx(Ae,{children:"to"}),n.jsx(o.TextField,{size:"small",type:"number",label:"To",value:g,onChange:H=>Z(p,parseFloat(H.target.value)||""),onFocus:()=>A(!0),onBlur:()=>A(!1),placeholder:"Max...",fullWidth:!0,inputProps:{min:p||re,max:ee}})]}),K&&re!==void 0&&ee!==void 0&&n.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:-.5,ml:1.5},children:["Valid range: [",re," - ",ee,"]"]})]}),V&&!N&&n.jsx(o.LocalizationProvider,{dateAdapter:o.AdapterDayjs,children:n.jsx(o.DatePicker,{label:"Date",value:p instanceof Date?o.dayjs.utc(p):null,onChange:H=>{H===null?Z(null):H.isValid()&&Z(H.utc().toDate())},timezone:"UTC",minDate:p instanceof Date?void 0:_,maxDate:p instanceof Date?void 0:Q,referenceDate:l==="After"&&_?_:void 0,slotProps:{textField:{size:"small",fullWidth:!0,sx:{minWidth:150},onFocus:()=>A(!0),onBlur:()=>A(!1),helperText:K&&_&&Q?`Valid range: [${_.format("YYYY-MM-DD")} - ${Q.format("YYYY-MM-DD")}]`:void 0},openPickerButton:{sx:{backgroundColor:"transparent"}}}})}),V&&N&&n.jsx(o.LocalizationProvider,{dateAdapter:o.AdapterDayjs,children:n.jsxs(Ae,{sx:{display:"flex",flexDirection:"column",gap:1},children:[n.jsxs(Ae,{sx:{display:"flex",gap:1,alignItems:"center"},children:[n.jsx(Ae,{sx:{flex:1,minWidth:0},children:n.jsx(o.DatePicker,{label:"From",value:p instanceof Date?o.dayjs.utc(p):null,onChange:H=>{H===null?Z(null,g):H.isValid()&&Z(H.utc().toDate(),g)},timezone:"UTC",minDate:p instanceof Date?void 0:_,maxDate:g instanceof Date?o.dayjs.utc(g):p instanceof Date?void 0:Q,referenceDate:_,slotProps:{textField:{size:"small",fullWidth:!0,onFocus:()=>A(!0),onBlur:()=>A(!1)},openPickerButton:{sx:{backgroundColor:"transparent"}}}})}),n.jsx(Ae,{children:"to"}),n.jsx(Ae,{sx:{flex:1,minWidth:0},children:n.jsx(o.DatePicker,{label:"To",value:g instanceof Date?o.dayjs.utc(g):null,onChange:H=>{H===null?Z(p,null):H.isValid()&&Z(p,H.utc().toDate())},timezone:"UTC",minDate:p instanceof Date?o.dayjs.utc(p):g instanceof Date?void 0:_,maxDate:g instanceof Date?void 0:Q,referenceDate:p instanceof Date?o.dayjs.utc(p):_,slotProps:{textField:{size:"small",fullWidth:!0,onFocus:()=>A(!0),onBlur:()=>A(!1)},openPickerButton:{sx:{backgroundColor:"transparent"}}}})})]}),K&&_&&Q&&n.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:-.5,ml:1.5},children:["Valid range: [",_.format("YYYY-MM-DD")," -"," ",Q.format("YYYY-MM-DD"),"]"]})]})})]})}function Pc(e){const r=new Set,u=e.schema?.fields;if(!u)return r;for(const s of u)"kind"in s&&s.kind==="join"&&s.name&&r.add(s.name);return r}function Lc(e){if(!e)return null;for(const r of e)if(r.startsWith("##(filters)")){const u=r.slice(11).trim();try{const s=JSON.parse(u);if(Array.isArray(s)){const d=[];for(const c of s)if(typeof c=="string"){const l=c.indexOf(".");l>0&&l<c.length-1&&d.push({source:c.substring(0,l),dimension:c.substring(l+1)})}if(d.length>0)return{filters:d}}}catch(s){console.error(`Failed to parse "${r}" annotation:`,s)}}return null}function Jo(e){if(e.startsWith("#(filter)")){const r=e.slice(9).trim();try{const u=JSON.parse(r);if(u.type)return u}catch(u){console.error(`Failed to parse "${e}" annotation:`,u)}}return null}function _c(e){const r=e.match(/^#\s*label\s*=\s*"([^"]+)"/);return r?r[1]:null}function Wc(e){const r=new Map;let u="";for(const s of e)if(s.type==="code"){if(!u&&s.text){const c=s.text.split(`
|
|
2
|
-
`).map(l=>l.trim()).find(l=>l.startsWith("import "))?.match(/['"]([^'"\n]+)['"]/);c&&(u=c[1])}if(s.newSources&&s.newSources.length>0)for(const d of s.newSources)try{const c=JSON.parse(d);c.name&&r.set(c.name,c)}catch(c){console.error("Failed to parse SourceInfo:",c)}}return{sourceInfoMap:r,modelPath:u}}function qc(e,r,u){const s=[];for(const{source:d,dimension:c}of r){const l=e.get(d);if(!l){console.warn(`Source "${d}" not found in notebook sources`),s.push({source:d,model:u,dimensionName:c,filterType:"Star"});continue}const m=l.schema?.fields;if(!m){s.push({source:d,model:u,dimensionName:c,filterType:"Star"});continue}const p=m.find(v=>v.name===c);if(!p){console.warn(`Dimension "${c}" not found in source "${d}"`),s.push({source:d,model:u,dimensionName:c,filterType:"Star"});continue}let h="Star",g;if("annotations"in p&&p.annotations){for(const v of p.annotations)if(v.value){const x=
|
|
1
|
+
"use strict";var rl=Object.create;var so=Object.defineProperty;var sl=Object.getOwnPropertyDescriptor;var ol=Object.getOwnPropertyNames;var al=Object.getPrototypeOf,il=Object.prototype.hasOwnProperty;var ll=(e,r,u,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let d of ol(r))!il.call(e,d)&&d!==u&&so(e,d,{get:()=>r[d],enumerable:!(s=sl(r,d))||s.enumerable});return e};var cl=(e,r,u)=>(u=e!=null?rl(al(e)):{},ll(r||!e||!e.__esModule?so(u,"default",{value:e,enumerable:!0}):u,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),S=require("@mui/material"),I=require("react"),o=require("./useCompiledDocument-BKyRnXmA.cjs.js"),B=require("./ServerProvider-B0dUY8be.cjs.js"),Sr=require("@tanstack/react-query"),Jn=require("@mui/system"),Ct=require("@mui/icons-material"),zo=require("./text-entry-BJwltZiy.cjs.js"),en=require("./RenderedResult-Bw7EQc42.cjs.js"),gr=require("react-router-dom");function ul(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const u in e)if(u!=="default"){const s=Object.getOwnPropertyDescriptor(e,u);Object.defineProperty(r,u,s.get?s:{enumerable:!0,get:()=>e[u]})}}return r.default=e,Object.freeze(r)}const he=ul(I),dl=o.createSvgIcon(n.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}));function hl({label:e,href:r,onClick:u}){const s=d=>{const c=d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||d.button!==0;r!==void 0&&c||(d.preventDefault(),u(d))};return n.jsxs(S.Link,{...r===void 0?{component:"button",type:"button"}:{href:r},onClick:s,underline:"none","aria-label":`Back to ${e}`,sx:{display:"inline-flex",alignItems:"center",gap:.5,cursor:"pointer",color:"text.secondary",fontSize:"0.875rem",mb:2,border:0,p:0,background:"none",font:"inherit","&:hover":{color:"primary.main"}},children:[n.jsx(dl,{sx:{fontSize:18}}),"Back to ",e]})}const Ho="(max-width:599.95px)";function Vo(){return S.useMediaQuery(Ho,{noSsr:!0})}function Bo(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Ho).matches}function fl({children:e}){const[r]=I.useState(Bo),[u,s]=I.useState(!1);return!r||u?n.jsx(n.Fragment,{children:e}):n.jsxs(S.Stack,{sx:{alignItems:"flex-start",gap:1.5,py:3},children:[n.jsx(S.Typography,{variant:"h6",children:"Editing works best on a larger screen"}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"The editor is built for a wider window. You can still try it here."}),n.jsx(S.Button,{variant:"outlined",onClick:()=>s(!0),children:"Edit anyway"})]})}function pl(){const e=gr.useNavigate();return(r,u)=>{if(!u||!u.metaKey&&!u.ctrlKey&&!u.shiftKey&&u.button!==1){e(r);return}const s=new URL(r,window.location.href).href;(u.metaKey||u.ctrlKey||u.button===1||u.shiftKey)&&window.open(s,"_blank")}}const ml=e=>{const r=he.useRef({});return he.useEffect(()=>{r.current=e}),r.current};function gl(){const[e]=gr.useSearchParams(),r=gr.useNavigate(),u=gr.useLocation(),s=I.useMemo(()=>Object.fromEntries(e.entries()),[e]),d=I.useRef(new Set),c=I.useCallback((l,m)=>{const p=new Set([...m,...d.current]);d.current=new Set([...d.current,...Object.keys(l),...m]);const h=new URLSearchParams(u.search);for(const g of p)Object.prototype.hasOwnProperty.call(l,g)||h.delete(g);for(const[g,v]of Object.entries(l))h.set(g,v);r({search:h.toString(),hash:u.hash},{replace:!0})},[r,u]);return{params:s,onGivensChange:c}}const Uo=o.createSvgIcon(n.jsx("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3z"})),yl="publisher:resize";function xl(e){return typeof e=="object"&&e!==null&&e.type===yl&&typeof e.height=="number"}function Go(e){return e.replace(/\/api\/v0\/?$/,"")}function Yo({server:e,environmentName:r,packageName:u,path:s}){const d=s.startsWith("public/")?s.slice(7):s;return`${Go(e)}/environments/${encodeURIComponent(r)}/packages/${encodeURIComponent(u)}/`+d}function bl(e){try{const{environmentName:r,packageName:u,modelPath:s}=o.parseResourceUri(e);return!r||!u||!s?null:{environmentName:r,packageName:u,dataAppPath:s}}catch{return null}}function vl({resourceUri:e}){const{server:r,apiClients:u}=B.useServer(),s=bl(e),d=s?.environmentName??"",c=s?.packageName??"",l=s?.dataAppPath??"",m=I.useMemo(()=>Yo({server:r,environmentName:d,packageName:c,path:l}),[r,d,c,l]),h=o.useQueryWithApiError({queryKey:["data-apps",d,c],queryFn:()=>u.dataApps.listDataApps(d,c),enabled:!!s}).data?.data?.find(w=>w.path===l),g=h?.title??l,v=h?.fit==="viewport",x=I.useRef(null),[y,C]=I.useState(120);return I.useEffect(()=>{if(v)return;function w(k){xl(k.data)&&k.source===x.current?.contentWindow&&k.data.height>0&&C(Math.ceil(k.data.height))}return window.addEventListener("message",w),()=>window.removeEventListener("message",w)},[v]),s?n.jsxs(S.Box,{sx:{p:3,...v?{height:"100%",display:"flex",flexDirection:"column"}:{maxWidth:1600,mx:"auto"}},children:[n.jsxs(S.Stack,{direction:"row",alignItems:"baseline",spacing:1,sx:{mb:1,flexShrink:0},children:[n.jsx(S.Typography,{variant:"h6",sx:{fontWeight:"fontWeightMedium",letterSpacing:"-0.025em"},children:g}),n.jsx(S.Typography,{variant:"caption",color:"text.secondary",sx:{fontFamily:B.MONO_FONT_FAMILY},children:l}),n.jsx(S.Box,{sx:{flex:1}}),n.jsx(S.Tooltip,{title:"Open standalone in new tab",children:n.jsx(S.IconButton,{size:"small",href:m,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",sx:{color:"text.secondary"},children:n.jsx(Uo,{fontSize:"small"})})})]}),n.jsx(S.Box,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,overflow:"hidden",backgroundColor:"background.paper",...v?{flex:1,minHeight:0}:{}},children:n.jsx("iframe",{ref:x,src:m,title:g,sandbox:"allow-scripts allow-same-origin allow-forms",style:{display:"block",width:"100%",height:v?"100%":y,border:0}})})]}):n.jsxs(S.Box,{sx:{p:3,maxWidth:1600,mx:"auto"},children:[n.jsx(S.Typography,{variant:"h6",sx:{fontWeight:"fontWeightMedium"},children:"Can't open data app"}),n.jsxs(S.Typography,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["This data app link is missing an environment, package, or path:",n.jsx(S.Box,{component:"span",sx:{fontFamily:B.MONO_FONT_FAMILY,ml:1},children:e})]})]})}function wt({title:e,count:r,description:u,action:s,children:d}){const c=I.useId();return n.jsxs(S.Box,{component:"section","aria-labelledby":c,sx:{mb:4},children:[n.jsxs(S.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:u?0:1,minHeight:40},children:[n.jsxs(S.Stack,{direction:"row",alignItems:"baseline",spacing:1,children:[n.jsx(S.Typography,{id:c,variant:"h6",sx:{fontWeight:600,letterSpacing:"-0.025em",lineHeight:1.2},children:e}),r!==void 0&&n.jsxs(S.Typography,{variant:"caption",color:"text.secondary",children:["(",r,")"]})]}),s]}),u&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:u}),n.jsx(S.Box,{children:d})]})}function Sl({resourceUri:e}){const{environmentName:r}=o.parseResourceUri(e),{apiClients:u}=B.useServer(),[s,d]=I.useState(!1),c=90,{data:l,isSuccess:m,isError:p,error:h}=o.useQueryWithApiError({queryKey:["about",r],queryFn:()=>u.environments.getEnvironment(r,!1)}),g=l?.data?.readme||"",v=g.split(/\s+/),x=v.length>c,y=v.slice(0,c).join(" ");return n.jsxs(n.Fragment,{children:[!m&&!p&&n.jsx(o.Loading,{text:"Fetching About..."}),m&&g&&n.jsxs(wt,{title:"Readme",children:[n.jsx(o.Prose,{variant:"caption",children:s||!x?g:y}),x&&n.jsx(S.Box,{sx:{mt:1},children:n.jsx(o.SecondaryButton,{label:s?"Read less":"Read more",onClick:()=>d(!s)})})]}),p&&n.jsx(o.ApiErrorDisplay,{error:h,context:`${r} > About`})]})}function wl(e={}){const{autoHideDuration:r=null,disableWindowBlurListener:u=!1,onClose:s,open:d,resumeHideDuration:c}=e,l=o.useTimeout();he.useEffect(()=>{if(!d)return;function O(M){M.defaultPrevented||M.key==="Escape"&&s?.(M,"escapeKeyDown")}return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O)}},[d,s]);const m=o.useEventCallback((O,M)=>{s?.(O,M)}),p=o.useEventCallback(O=>{!s||O==null||l.start(O,()=>{m(null,"timeout")})});he.useEffect(()=>(d&&p(r),l.clear),[d,r,p,l]);const h=O=>{s?.(O,"clickaway")},g=l.clear,v=he.useCallback(()=>{r!=null&&p(c??r*.5)},[r,c,p]),x=O=>M=>{const j=O.onBlur;j?.(M),v()},y=O=>M=>{const j=O.onFocus;j?.(M),g()},C=O=>M=>{const j=O.onMouseEnter;j?.(M),g()},w=O=>M=>{const j=O.onMouseLeave;j?.(M),v()};return he.useEffect(()=>{if(!u&&d)return window.addEventListener("focus",v),window.addEventListener("blur",g),()=>{window.removeEventListener("focus",v),window.removeEventListener("blur",g)}},[u,d,v,g]),{getRootProps:(O={})=>{const M={...o.extractEventHandlers(e),...o.extractEventHandlers(O)};return{role:"presentation",...O,...M,onBlur:x(M),onFocus:y(M),onMouseEnter:C(M),onMouseLeave:w(M)}},onClickAway:h}}function oo(e){return e.substring(2).toLowerCase()}function Cl(e,r){return r.documentElement.clientWidth<e.clientX||r.documentElement.clientHeight<e.clientY}function kl(e){const{children:r,disableReactTree:u=!1,mouseEvent:s="onClick",onClickAway:d,touchEvent:c="onTouchEnd"}=e,l=he.useRef(!1),m=he.useRef(null),p=he.useRef(!1),h=he.useRef(!1);he.useEffect(()=>(setTimeout(()=>{p.current=!0},0),()=>{p.current=!1}),[]);const g=o.useForkRef(o.getReactElementRef(r),m),v=o.useEventCallback(C=>{const w=h.current;h.current=!1;const k=o.ownerDocument(m.current);if(!p.current||!m.current||"clientX"in C&&Cl(C,k))return;if(l.current){l.current=!1;return}let O;C.composedPath?O=C.composedPath().includes(m.current):O=!k.documentElement.contains(C.target)||m.current.contains(C.target),!O&&(u||!w)&&d(C)}),x=C=>w=>{h.current=!0;const k=r.props[C];k&&k(w)},y={ref:g};return c!==!1&&(y[c]=x(c)),he.useEffect(()=>{if(c!==!1){const C=oo(c),w=o.ownerDocument(m.current),k=()=>{l.current=!0};return w.addEventListener(C,v),w.addEventListener("touchmove",k),()=>{w.removeEventListener(C,v),w.removeEventListener("touchmove",k)}}},[v,c]),s!==!1&&(y[s]=x(s)),he.useEffect(()=>{if(s!==!1){const C=oo(s),w=o.ownerDocument(m.current);return w.addEventListener(C,v),()=>{w.removeEventListener(C,v)}}},[v,s]),he.cloneElement(r,y)}function Tl(e){return o.generateUtilityClass("MuiSnackbarContent",e)}o.generateUtilityClasses("MuiSnackbarContent",["root","message","action"]);const Ol=e=>{const{classes:r}=e,u={root:["root"],action:["action"],message:["message"]};return o.composeClasses(u,Tl,r)},Ml=o.styled(o.Paper,{name:"MuiSnackbarContent",slot:"Root"})(o.memoTheme(({theme:e})=>{const r=e.palette.mode==="light"?.8:.98;return{...e.typography.body2,color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(o.emphasize(e.palette.background.default,r)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:o.emphasize(e.palette.background.default,r),display:"flex",alignItems:"center",flexWrap:"wrap",padding:"6px 16px",flexGrow:1,[e.breakpoints.up("sm")]:{flexGrow:"initial",minWidth:288}}})),jl=o.styled("div",{name:"MuiSnackbarContent",slot:"Message"})({padding:"8px 0"}),Dl=o.styled("div",{name:"MuiSnackbarContent",slot:"Action"})({display:"flex",alignItems:"center",marginLeft:"auto",paddingLeft:16,marginRight:-8}),El=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiSnackbarContent"}),{action:d,className:c,message:l,role:m="alert",...p}=s,h=s,g=Ol(h);return n.jsxs(Ml,{role:m,elevation:6,className:o.clsx(g.root,c),ownerState:h,ref:u,...p,children:[n.jsx(jl,{className:g.message,ownerState:h,children:l}),d?n.jsx(Dl,{className:g.action,ownerState:h,children:d}):null]})});function Il(e){return o.generateUtilityClass("MuiSnackbar",e)}o.generateUtilityClasses("MuiSnackbar",["root","anchorOriginTopCenter","anchorOriginBottomCenter","anchorOriginTopRight","anchorOriginBottomRight","anchorOriginTopLeft","anchorOriginBottomLeft"]);const Nl=e=>{const{classes:r,anchorOrigin:u}=e,s={root:["root",`anchorOrigin${o.capitalize(u.vertical)}${o.capitalize(u.horizontal)}`]};return o.composeClasses(s,Il,r)},Fl=o.styled("div",{name:"MuiSnackbar",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.root,r[`anchorOrigin${o.capitalize(u.anchorOrigin.vertical)}${o.capitalize(u.anchorOrigin.horizontal)}`]]}})(o.memoTheme(({theme:e})=>({zIndex:(e.vars||e).zIndex.snackbar,position:"fixed",display:"flex",left:8,right:8,justifyContent:"center",alignItems:"center",variants:[{props:({ownerState:r})=>r.anchorOrigin.vertical==="top",style:{top:8,[e.breakpoints.up("sm")]:{top:24}}},{props:({ownerState:r})=>r.anchorOrigin.vertical!=="top",style:{bottom:8,[e.breakpoints.up("sm")]:{bottom:24}}},{props:({ownerState:r})=>r.anchorOrigin.horizontal==="left",style:{justifyContent:"flex-start",[e.breakpoints.up("sm")]:{left:24,right:"auto"}}},{props:({ownerState:r})=>r.anchorOrigin.horizontal==="right",style:{justifyContent:"flex-end",[e.breakpoints.up("sm")]:{right:24,left:"auto"}}},{props:({ownerState:r})=>r.anchorOrigin.horizontal==="center",style:{[e.breakpoints.up("sm")]:{left:"50%",right:"auto",transform:"translateX(-50%)"}}}]}))),Al=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiSnackbar"}),d=o.useTheme(),c={enter:d.transitions.duration.enteringScreen,exit:d.transitions.duration.leavingScreen},{action:l,anchorOrigin:{vertical:m,horizontal:p}={vertical:"bottom",horizontal:"left"},autoHideDuration:h=null,children:g,className:v,ClickAwayListenerProps:x,ContentProps:y,disableWindowBlurListener:C=!1,message:w,onBlur:k,onClose:O,onFocus:M,onMouseEnter:j,onMouseLeave:E,open:R,resumeHideDuration:U,slots:P={},slotProps:K={},TransitionComponent:A,transitionDuration:L=c,TransitionProps:{onEnter:V,onExited:N,...W}={},...X}=s,ne={...s,anchorOrigin:{vertical:m,horizontal:p},autoHideDuration:h,disableWindowBlurListener:C,TransitionComponent:A,transitionDuration:L},J=Nl(ne),{getRootProps:ee,onClickAway:Z}=wl({...ne}),[ae,H]=he.useState(!0),Q=be=>{H(!0),N&&N(be)},re=(be,Oe)=>{H(!1),V&&V(be,Oe)},ve={slots:{transition:A,...P},slotProps:{content:y,clickAwayListener:x,transition:W,...K}},[Re,se]=o.useSlot("root",{ref:u,className:[J.root,v],elementType:Fl,getSlotProps:ee,externalForwardedProps:{...ve,...X},ownerState:ne}),[ie,{ownerState:Ne,...xe}]=o.useSlot("clickAwayListener",{elementType:kl,externalForwardedProps:ve,getSlotProps:be=>({onClickAway:(...Oe)=>{const $e=Oe[0];be.onClickAway?.(...Oe),!$e?.defaultMuiPrevented&&Z(...Oe)}}),ownerState:ne}),[_,oe]=o.useSlot("content",{elementType:El,shouldForwardComponentProp:!0,externalForwardedProps:ve,additionalProps:{message:w,action:l},ownerState:ne}),[ge,Te]=o.useSlot("transition",{elementType:o.Grow,externalForwardedProps:ve,getSlotProps:be=>({onEnter:(...Oe)=>{be.onEnter?.(...Oe),re(...Oe)},onExited:(...Oe)=>{be.onExited?.(...Oe),Q(...Oe)}}),additionalProps:{appear:!0,in:R,timeout:L,direction:m==="top"?"down":"up"},ownerState:ne});return!R&&ae?null:n.jsx(ie,{...xe,...P.clickAwayListener&&{ownerState:Ne},children:n.jsx(Re,{...se,children:n.jsx(ge,{...Te,children:g||n.jsx(_,{...oe})})})})});let Xr;function $l(e){Xr=e}function ao(e){if(Xr)try{Xr(e)}catch{}}function Pt(e,r,u){return(async s=>{const d=Date.now();try{const c=await u(s);return ao({type:"console.mutation",resource:e,action:r,ok:!0,durationMs:Date.now()-d}),c}catch(c){throw ao({type:"console.mutation",resource:e,action:r,ok:!1,durationMs:Date.now()-d,reason:c instanceof Error?c.message:"An unknown error occurred"}),c}})}function Cn({mutationFn:e,success:r,invalidates:u,closeDialog:s,resource:d,action:c}){const l=Sr.useQueryClient(),[m,p]=I.useState(""),h=o.useMutationWithApiError({mutationFn:Pt(d,c,e),onSuccess(){s();for(const g of u)l.invalidateQueries({queryKey:g});p(r)},onError(g){p(g instanceof Error?g.message:"An unknown error occurred")}});return{mutate:h.mutate,isPending:h.isPending,notice:n.jsx(Al,{open:m!=="",autoHideDuration:6e3,onClose:()=>p(""),message:m})}}const Zo="https://docs.malloydata.dev/documentation",Rr=`${Zo}/user_guides/publishing`,vn="https://github.com/malloydata/publisher/blob/main/docs",Rt={docsHome:`${Zo}/`,publishing:`${Rr}/publishing`,explorer:`${Rr}/explorer`,mcpAgents:`${Rr}/mcp_agents`,surfaces:`${vn}/choosing-a-surface.md`,dashboards:`${vn}/dashboards.md`,dataApps:`${vn}/html-data-apps.md`,givens:`${vn}/givens.md`,materialization:`${vn}/materialization.md`,connections:`${vn}/connections.md`};function Rl({resourceUri:e}){const[r,u]=I.useState(!1),{apiClients:s}=B.useServer(),{environmentName:d}=o.parseResourceUri(e),c=Cn({mutationFn(m){return s.packages.createPackage(d,{name:m.name,description:m.description,location:m.location})},success:"Package created",invalidates:[["packages",d]],closeDialog:()=>u(!1),resource:"package",action:"create"}),l=m=>{m.preventDefault();const p=new FormData(m.currentTarget),h=p.get("name")?.toString(),g=p.get("description")?.toString(),v=p.get("location")?.toString();c.mutate({name:h,description:g,location:v})};return n.jsxs(n.Fragment,{children:[n.jsx(o.AddButton,{label:"Package",onClick:()=>u(!0)}),n.jsx(o.AppDialog,{open:r,onClose:()=>u(!1),title:"New package",description:n.jsxs(n.Fragment,{children:["A package is a directory of Malloy models and their data. Give its location as a GitHub, S3 or GCS URL, or an absolute path the server can read; see the"," ",n.jsx(S.Box,{component:"a",href:Rt.publishing,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary"},children:"package format"}),"."]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(S.Button,{disabled:c.isPending,onClick:()=>u(!1),children:"Cancel"}),n.jsx(S.Button,{type:"submit",form:"package-form",variant:"contained",loading:c.isPending,children:"Create package"})]}),children:n.jsx("form",{onSubmit:l,id:"package-form",children:n.jsxs(S.Stack,{sx:{gap:2},children:[n.jsx(S.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),n.jsx(S.TextField,{id:"description",name:"description",label:"Description",multiline:!0,rows:3,fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),n.jsx(S.TextField,{id:"location",name:"location",label:"Location",type:"text",placeholder:"e.g. s3://my-bucket/my-package.zip",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}})]})})}),c.notice]})}const Pl=o.createSvgIcon(n.jsx("path",{d:"M2 20h20v-4H2zm2-3h2v2H4zM2 4v4h20V4zm4 3H4V5h2zm-4 7h20v-4H2zm2-3h2v2H4z"}));function wr({icon:e,tint:r,label:u,mono:s,description:d,rightLabel:c,trailingAction:l,onClick:m,ariaLabel:p}){const h=!!m,g=v=>{m&&(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),m(v))};return n.jsxs(S.Box,{onClick:m,onKeyDown:h?g:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,"aria-label":p,sx:v=>({display:"flex",alignItems:"center",gap:1.5,py:1,px:1,mx:-1,cursor:h?"pointer":"default",borderRadius:1.5,transition:"background-color 0.1s","&:hover":h?{backgroundColor:v.palette.mode==="dark"?"rgba(255, 255, 255, 0.08)":"grey.100"}:void 0,"&:focus-visible":h?{outline:"2px solid",outlineColor:"primary.main",outlineOffset:2}:void 0}),children:[n.jsx(S.Box,{sx:{width:32,height:32,borderRadius:1,bgcolor:r,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),n.jsxs(S.Box,{sx:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:1.5},children:[n.jsx(S.Typography,{variant:"body2",sx:{...s?{fontFamily:B.MONO_FONT_FAMILY}:{},flexShrink:0,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),d&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d})]}),c&&n.jsx(S.Typography,{variant:"caption",color:"text.secondary",sx:{flexShrink:0},children:c}),l&&n.jsx(S.Box,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:l})]})}const Ko=o.createSvgIcon(n.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"})),Ll=o.generateUtilityClasses("MuiBox",["root"]),_l=o.createTheme(),Ae=Jn.createBox({themeId:o.THEME_ID,defaultTheme:_l,defaultClassName:Ll.root,generateClassName:o.ClassNameGenerator.generate}),Cr=Jn.createStack({createStyledComponent:o.styled("div",{name:"MuiStack",slot:"Root"}),useThemeProps:e=>o.useDefaultProps({props:e,name:"MuiStack"})}),io=o.generateUtilityClasses("MuiDivider",["root","absolute","fullWidth","inset","middle","flexItem","light","vertical","withChildren","withChildrenVertical","textAlignRight","textAlignLeft","wrapper","wrapperVertical"]);function Wl(e){return o.generateUtilityClass("MuiListItemIcon",e)}const lo=o.generateUtilityClasses("MuiListItemIcon",["root","alignItemsFlexStart"]),ql=e=>{const{alignItems:r,classes:u}=e,s={root:["root",r==="flex-start"&&"alignItemsFlexStart"]};return o.composeClasses(s,Wl,u)},zl=o.styled("div",{name:"MuiListItemIcon",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.root,u.alignItems==="flex-start"&&r.alignItemsFlexStart]}})(o.memoTheme(({theme:e})=>({minWidth:56,color:(e.vars||e).palette.action.active,flexShrink:0,display:"inline-flex",variants:[{props:{alignItems:"flex-start"},style:{marginTop:8}}]}))),os=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiListItemIcon"}),{className:d,...c}=s,l=he.useContext(o.ListContext),m={...s,alignItems:l.alignItems},p=ql(m);return n.jsx(zl,{className:o.clsx(p.root,d),ownerState:m,ref:u,...c})});function Hl(e){return o.generateUtilityClass("MuiListItemText",e)}const wn=o.generateUtilityClasses("MuiListItemText",["root","multiline","dense","inset","primary","secondary"]),Vl=e=>{const{classes:r,inset:u,primary:s,secondary:d,dense:c}=e,l={root:["root",u&&"inset",c&&"dense",s&&d&&"multiline"],primary:["primary"],secondary:["secondary"]};return o.composeClasses(l,Hl,r)},Bl=o.styled("div",{name:"MuiListItemText",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[{[`& .${wn.primary}`]:r.primary},{[`& .${wn.secondary}`]:r.secondary},r.root,u.inset&&r.inset,u.primary&&u.secondary&&r.multiline,u.dense&&r.dense]}})({flex:"1 1 auto",minWidth:0,marginTop:4,marginBottom:4,[`.${o.typographyClasses.root}:where(& .${wn.primary})`]:{display:"block"},[`.${o.typographyClasses.root}:where(& .${wn.secondary})`]:{display:"block"},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),as=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiListItemText"}),{children:d,className:c,disableTypography:l=!1,inset:m=!1,primary:p,primaryTypographyProps:h,secondary:g,secondaryTypographyProps:v,slots:x={},slotProps:y={},...C}=s,{dense:w}=he.useContext(o.ListContext);let k=p??d,O=g;const M={...s,disableTypography:l,inset:m,primary:!!k,secondary:!!O,dense:w},j=Vl(M),E={slots:x,slotProps:{primary:h,secondary:v,...y}},[R,U]=o.useSlot("root",{className:o.clsx(j.root,c),elementType:Bl,externalForwardedProps:{...E,...C},ownerState:M,ref:u}),[P,K]=o.useSlot("primary",{className:j.primary,elementType:o.Typography,externalForwardedProps:E,ownerState:M}),[A,L]=o.useSlot("secondary",{className:j.secondary,elementType:o.Typography,externalForwardedProps:E,ownerState:M});return k!=null&&k.type!==o.Typography&&!l&&(k=n.jsx(P,{variant:w?"body2":"body1",component:K?.variant?void 0:"span",...K,children:k})),O!=null&&O.type!==o.Typography&&!l&&(O=n.jsx(A,{variant:"body2",color:"textSecondary",...L,children:O})),n.jsxs(R,{...U,children:[k,O]})});function Ul(e){return o.generateUtilityClass("MuiMenuItem",e)}const _n=o.generateUtilityClasses("MuiMenuItem",["root","focusVisible","dense","disabled","divider","gutters","selected"]),Gl=(e,r)=>{const{ownerState:u}=e;return[r.root,u.dense&&r.dense,u.divider&&r.divider,!u.disableGutters&&r.gutters]},Yl=e=>{const{disabled:r,dense:u,divider:s,disableGutters:d,selected:c,classes:l}=e,m={root:["root",u&&"dense",r&&"disabled",!d&&"gutters",s&&"divider",c&&"selected"]},p=o.composeClasses(m,Ul,l);return{...l,...p}},Zl=o.styled(o.ButtonBase,{shouldForwardProp:e=>o.rootShouldForwardProp(e)||e==="classes",name:"MuiMenuItem",slot:"Root",overridesResolver:Gl})(o.memoTheme(({theme:e})=>({...e.typography.body1,display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",minHeight:48,paddingTop:6,paddingBottom:6,boxSizing:"border-box",whiteSpace:"nowrap","&:hover":{textDecoration:"none",backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${_n.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${_n.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${_n.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${_n.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${_n.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${io.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${io.inset}`]:{marginLeft:52},[`& .${wn.root}`]:{marginTop:0,marginBottom:0},[`& .${wn.inset}`]:{paddingLeft:36},[`& .${lo.root}`]:{minWidth:36},variants:[{props:({ownerState:r})=>!r.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:r})=>r.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:r})=>!r.dense,style:{[e.breakpoints.up("sm")]:{minHeight:"auto"}}},{props:({ownerState:r})=>r.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${lo.root} svg`]:{fontSize:"1.25rem"}}}]}))),He=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiMenuItem"}),{autoFocus:d=!1,component:c="li",dense:l=!1,divider:m=!1,disableGutters:p=!1,focusVisibleClassName:h,role:g="menuitem",tabIndex:v,className:x,...y}=s,C=he.useContext(o.ListContext),w=he.useMemo(()=>({dense:l||C.dense||!1,disableGutters:p}),[C.dense,l,p]),k=he.useRef(null);o.useEnhancedEffect(()=>{d&&k.current&&k.current.focus()},[d]);const O={...s,dense:w.dense,divider:m,disableGutters:p},M=Yl(s),j=o.useForkRef(k,u);let E;return s.disabled||(E=v!==void 0?v:-1),n.jsx(o.ListContext.Provider,{value:w,children:n.jsx(Zl,{ref:j,role:g,tabIndex:E,component:c,focusVisibleClassName:o.clsx(M.focusVisible,h),className:o.clsx(M.root,x),...y,ownerState:O,classes:M})})}),Lt={postgres:[{label:"Host",name:"host",type:"text",required:!1},{label:"Port",name:"port",type:"number",required:!1},{label:"Database Name",name:"databaseName",type:"text",required:!1},{label:"User Name",name:"userName",type:"text",required:!1},{label:"Password",name:"password",type:"password",required:!1},{label:"Connection String",name:"connectionString",type:"text",required:!1}],bigquery:[{label:"Project ID",name:"defaultProjectId",type:"text",required:!1},{label:"Billing Project ID",name:"billingProjectId",type:"text",required:!1},{label:"Location",name:"location",type:"text",required:!1},{label:"Service Account Key JSON",name:"serviceAccountKeyJson",type:"text",required:!0},{label:"Maximum Bytes Billed",name:"maximumBytesBilled",type:"text",required:!1},{label:"Query Timeout Milliseconds",name:"queryTimeoutMilliseconds",type:"text",required:!1}],snowflake:[{label:"Account",name:"account",type:"text",required:!0},{label:"Username",name:"username",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Role",name:"role",type:"text",required:!1},{label:"Warehouse",name:"warehouse",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"Response Timeout Milliseconds",name:"responseTimeoutMilliseconds",type:"text",required:!1},{label:"Private Key",name:"privateKey",type:"password",required:!1},{label:"Private Key Passphrase",name:"privateKeyPass",type:"password",required:!1}],trino:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Catalog",name:"catalog",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Peaka Key",name:"peakaKey",type:"password",required:!1}],databricks:[{label:"Host",name:"host",type:"text",required:!0},{label:"HTTP Path",name:"path",type:"text",required:!0},{label:"Access Token",name:"token",type:"password",required:!1},{label:"OAuth Client ID",name:"oauthClientId",type:"text",required:!1},{label:"OAuth Client Secret",name:"oauthClientSecret",type:"password",required:!1},{label:"Default Catalog",name:"defaultCatalog",type:"text",required:!1},{label:"Default Schema",name:"defaultSchema",type:"text",required:!1}],mysql:[{label:"Host",name:"host",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Database",name:"database",type:"text",required:!0}],duckdb:[],motherduck:[{label:"Access Token",name:"accessToken",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1}],ducklake:[],publisher:[]},Kn={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",trino:"trinoConnection",databricks:"databricksConnection",mysql:"mysqlConnection",duckdb:"duckdbConnection",motherduck:"motherduckConnection",ducklake:"ducklakeConnection",publisher:"publisherConnection"},Xo=Object.values(B.ConnectionTypeEnum).filter(e=>e!==B.ConnectionTypeEnum.Publisher),Qr={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",gcs:"gcsConnection",s3:"s3Connection",azure:"azureConnection"},er=[{label:"Credential Provider",name:"provider",type:"text",required:!1,selectOptions:[{label:"Access key pair",value:"config"},{label:"Host credential chain",value:"credential_chain"}]},{label:"Access Key ID",name:"accessKeyId",type:"text",required:!1,visibleWhen:{field:"provider",value:"config"}},{label:"Secret Access Key",name:"secretAccessKey",type:"password",required:!1,visibleWhen:{field:"provider",value:"config"}},{label:"Credential Chain",name:"chain",type:"text",required:!1,visibleWhen:{field:"provider",value:"credential_chain"}},{label:"Region",name:"region",type:"text",required:!1},{label:"Endpoint",name:"endpoint",type:"text",required:!1},{label:"Session Token",name:"sessionToken",type:"password",required:!1,visibleWhen:{field:"provider",value:"config"}}],tr=[{label:"Key ID",name:"keyId",type:"text",required:!0},{label:"Secret",name:"secret",type:"password",required:!0}],Kl=[{label:"Auth Type",name:"authType",type:"text",required:!0,selectOptions:[{label:"SAS Token",value:"sas_token"},{label:"Service Principal (SPN)",value:"service_principal"}]},{label:"SAS URL (e.g. https://account.blob.core.windows.net/container/file.parquet?sp=r&st=...)",name:"sasUrl",type:"text",required:!1,visibleWhen:{field:"authType",value:"sas_token"}},{label:"Tenant ID",name:"tenantId",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Client ID",name:"clientId",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Client Secret",name:"clientSecret",type:"password",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"Account Name",name:"accountName",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}},{label:"File URL (e.g. abfss://container/path/file.parquet)",name:"fileUrl",type:"text",required:!1,visibleWhen:{field:"authType",value:"service_principal"}}];function br(e){return e==="postgres"||e==="bigquery"||e==="snowflake"?Lt[e]||[]:e==="s3"?er:e==="gcs"?tr:e==="azure"?Kl:[]}function Xl({onSubmit:e,isSubmitting:r}){const[u,s]=I.useState(!1),[d,c]=I.useState("postgres"),[l,m]=I.useState([]),[p,h]=I.useState("postgres"),[g,v]=I.useState("s3"),[x,y]=I.useState("config"),C=()=>{s(!0)},w=()=>{s(!1),m([]),c("postgres"),h("postgres"),v("s3"),y("config")},k=async E=>{E.preventDefault();const R=new FormData(E.currentTarget),U=R.get("name")?.toString(),P=R.get("type")?.toString(),K=Lt[P];if(!U)throw new Error("Name is required");if(!P)throw new Error("Type is required");let A;if(P==="ducklake"){const L={};if(p==="postgres"){const W=Lt.postgres,X={};if(W.forEach(ne=>{const J=R.get(`ducklake_pg_${ne.name}`)?.toString();J&&(X[ne.name]=J)}),Object.keys(X).length===0)throw new Error("DuckLake requires catalog connection");L.postgresConnection=X}const V=R.get("ducklake_bucketUrl")?.toString();if(!V)throw new Error("DuckLake requires a bucket URL");const N={bucketUrl:V};if(g==="s3"){const W={};if(er.forEach(X=>{const ne=R.get(`ducklake_s3_${X.name}`)?.toString();ne&&(W[X.name]=ne)}),W.provider==="credential_chain")delete W.accessKeyId,delete W.secretAccessKey,delete W.sessionToken;else{if(delete W.chain,!W.accessKeyId)throw new Error("S3 Access Key ID is required");if(!W.secretAccessKey)throw new Error("S3 Secret Access Key is required")}Object.keys(W).length>0&&(N.s3Connection=W)}else if(g==="gcs"){const W={};if(tr.forEach(X=>{const ne=R.get(`ducklake_gcs_${X.name}`)?.toString();ne&&(W[X.name]=ne)}),!W.keyId)throw new Error("GCS Key ID is required");if(!W.secret)throw new Error("GCS Secret is required");Object.keys(W).length>0&&(N.gcsConnection=W)}A={name:U,type:P,ducklakeConnection:{catalog:L,storage:N}}}else if(P==="duckdb"){if(l.length===0)throw new Error("DuckDB connection must have at least one attached database");const L=l.map((V,N)=>{const W=V.dbType,X=R.get(`attachedDb_${N}_name`)?.toString();if(!X)throw new Error(`Attached database at index ${N} must have a name`);const ne={name:X,type:W},J=br(W);if(J&&J.length>0){const ee={};if(J.forEach(ae=>{const H=R.get(`attachedDb_${N}_${ae.name}`)?.toString();H&&(ee[ae.name]=H)}),W==="s3"){if(ee.provider==="credential_chain")delete ee.accessKeyId,delete ee.secretAccessKey,delete ee.sessionToken;else if(delete ee.chain,!ee.accessKeyId||!ee.secretAccessKey)throw new Error(`Attached database "${X}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`)}const Z=Qr[W];Z&&(ne[Z]=ee)}return ne});A={name:U,type:P,duckdbConnection:{attachedDatabases:L}}}else{const L={};if(K.forEach(V=>{const N=R.get(V.name)?.toString();N&&(L[V.name]=N)}),P==="postgres"){if(!!!L.connectionString?.trim()){const N=["host","port","databaseName","userName","password"];for(const W of N)if(!L[W])throw new Error(`${K.find(X=>X.name===W)?.label||W} is required`)}}else if(P==="bigquery"){if(!L.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(P==="snowflake"){if(!L.account)throw new Error("Account is required");if(!L.username)throw new Error("Username is required");if(!L.warehouse)throw new Error("Warehouse is required");if(!L.password&&!L.privateKey)throw new Error("Either password or private key is required")}else if(P==="trino"){if(!L.server)throw new Error("Server is required");if(!L.user)throw new Error("User is required");if(L.server.trim().startsWith("https://")&&!L.password&&!L.peakaKey)throw new Error("Password is required for HTTPS connections (or use Peaka Key)")}else if(P==="mysql"){const V=["host","port","database","user","password"];for(const N of V)if(!L[N])throw new Error(`${K.find(W=>W.name===N)?.label||N} is required`)}else if(P==="motherduck"){if(!L.accessToken)throw new Error("Access Token is required")}else if(P==="databricks"){if(!L.host)throw new Error("Host is required");if(!L.path)throw new Error("HTTP Path is required");const V=L.oauthClientId&&L.oauthClientSecret;if(!L.token&&!V)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}A={name:U,type:P,[Kn[P]]:L}}await e(A),w()},O=()=>{m([...l,{name:"",dbType:"postgres"}])},M=E=>{m(l.filter((R,U)=>U!==E))},j=(E,R)=>{const U=[...l];U[E]={...U[E],dbType:R},m(U)};return n.jsxs(I.Fragment,{children:[n.jsx(o.AddButton,{label:"Connection",onClick:C}),n.jsx(o.AppDialog,{open:u,onClose:w,title:"New connection",description:"Add a connection so packages in this environment can query your database with Malloy.",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:r,onClick:w,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"connection-form",variant:"contained",loading:r,children:"Create connection"})]}),children:n.jsx("form",{onSubmit:k,id:"connection-form",children:n.jsxs(Cr,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small"}),n.jsx(o.TextField,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:d,select:!0,onChange:E=>c(E.target.value),children:Xo.map(E=>n.jsx(He,{value:E,children:E},E))}),d==="ducklake"?n.jsxs(Ae,{sx:{mt:2},children:[n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsx(o.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),n.jsx(o.TextField,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:p,select:!0,onChange:E=>h(E.target.value),children:n.jsx(He,{value:"postgres",children:"PostgreSQL"})}),p==="postgres"&&n.jsx(n.Fragment,{children:Lt.postgres.map(E=>n.jsx(o.TextField,{id:`ducklake_pg_${E.name}`,name:`ducklake_pg_${E.name}`,label:E.label,type:E.type,fullWidth:!0,size:"small"},`pg_${E.name}`))})]}),n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsx(o.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),n.jsxs(o.TextField,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:g,select:!0,onChange:E=>v(E.target.value),children:[n.jsx(He,{value:"s3",children:"S3"}),n.jsx(He,{value:"gcs",children:"GCS"})]}),n.jsx(o.TextField,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:g==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small"}),g==="s3"&&n.jsxs(n.Fragment,{children:[n.jsx(o.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),er.filter(E=>E.visibleWhen?x===E.visibleWhen.value:!0).map(E=>n.jsx(o.TextField,{id:`ducklake_s3_${E.name}`,name:`ducklake_s3_${E.name}`,label:E.label,type:E.selectOptions?void 0:E.type,fullWidth:!0,size:"small",required:E.required,select:!!E.selectOptions,defaultValue:E.selectOptions?x:void 0,onChange:E.name==="provider"?R=>y(R.target.value):void 0,placeholder:E.name==="region"?"us-east-1":void 0,children:E.selectOptions?.map(R=>n.jsx(He,{value:R.value,children:R.label},R.value))},`s3_${E.name}`))]}),g==="gcs"&&n.jsxs(n.Fragment,{children:[n.jsx(o.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),tr.map(E=>n.jsx(o.TextField,{id:`ducklake_gcs_${E.name}`,name:`ducklake_gcs_${E.name}`,label:E.label,type:E.type,fullWidth:!0,size:"small",required:E.required},`gcs_${E.name}`))]})]})]}):d==="duckdb"?n.jsxs(Ae,{sx:{mt:2},children:[n.jsxs(Ae,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.jsx(o.Typography,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),n.jsx(o.SecondaryButton,{label:"Database",icon:n.jsx(o.AddIcon,{}),onClick:O,ariaLabel:"Add database"})]}),l.length===0&&n.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),l.map((E,R)=>{const U=br(E.dbType);return n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsxs(Ae,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.jsxs(o.Typography,{variant:"subtitle2",children:["Database ",R+1]}),n.jsx(o.IconButton,{onClick:()=>M(R),size:"small",color:"error",children:n.jsx(Ko,{fontSize:"small"})})]}),n.jsx(o.TextField,{required:!0,id:`attachedDb_${R}_name`,name:`attachedDb_${R}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:E.name}),n.jsx(o.TextField,{id:`attachedDb_${R}_type`,name:`attachedDb_${R}_type`,label:"Database Type",fullWidth:!0,size:"small",value:E.dbType,select:!0,onChange:P=>j(R,P.target.value),children:Object.values(B.AttachedDatabaseTypeEnum).map(P=>n.jsx(He,{value:P,children:P},P))}),U.filter(P=>P.visibleWhen?(E[P.visibleWhen.field]||U.find(A=>A.name===P.visibleWhen?.field)?.selectOptions?.[0]?.value)===P.visibleWhen.value:!0).map(P=>n.jsx(o.TextField,{id:`attachedDb_${R}_${P.name}`,name:`attachedDb_${R}_${P.name}`,label:P.label,type:P.selectOptions?void 0:P.type,fullWidth:!0,size:"small",required:P.required,select:!!P.selectOptions,defaultValue:P.selectOptions?.[0]?.value,onChange:P.selectOptions?K=>{const A=[...l];A[R]={...A[R],[P.name]:K.target.value},m(A)}:void 0,children:P.selectOptions?.map(K=>n.jsx(He,{value:K.value,children:K.label},K.value))},P.name))]},R)})]}):Lt[d].map(E=>n.jsx(o.TextField,{id:E.name,name:E.name,label:E.label,type:E.type,fullWidth:!0,size:"small",required:E.required},E.name))]})})})]})}function Ql({connection:e,onCloseDialog:r,isMutating:u,onDelete:s}){const[d,c]=I.useState(!1),l=()=>{c(!0)},m=()=>{c(!1),r()};return n.jsxs(I.Fragment,{children:[n.jsxs(He,{"aria-label":`Delete connection ${e?.name??""}`.trim(),onClick:p=>{p.stopPropagation(),l()},sx:{color:"error.main"},children:[n.jsx(os,{sx:{color:"inherit"},children:n.jsx(Ct.Delete,{fontSize:"small"})}),n.jsx(as,{children:"Delete"})]}),n.jsx(o.AppDialog,{open:d,onClose:m,title:"Delete connection",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{onClick:m,children:"Cancel"}),n.jsx(o.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>s(),loading:u,children:"Delete connection"})]}),children:n.jsxs(o.Typography,{variant:"body2",children:["Delete ",n.jsx("strong",{children:e.name}),"? Packages that query through it stop working, and this cannot be undone."]})})]})}const co=new Set(["password","connectionString","privateKey","privateKeyPass","serviceAccountKeyJson","token","oauthClientSecret","accessToken","peakaKey","secret","secretAccessKey","sessionToken","clientSecret","sasUrl"]);function uo(e){const r=e.duckdbConnection?.attachedDatabases;return!r||r.length===0?[]:r.map(u=>({name:u.name||"",dbType:u.type||"postgres"}))}function ho(e){const r=e.ducklakeConnection;return r&&r.storage?.gcsConnection?"gcs":"s3"}function Jl({connection:e,onSubmit:r,isSubmitting:u,onCloseDialog:s}){const[d,c]=I.useState(!1),[l,m]=I.useState(e.type),p=I.useMemo(()=>new Set(e.withheldFields??[]),[e.withheldFields]),[h,g]=I.useState(()=>uo(e)),[v,x]=I.useState("postgres"),[y,C]=I.useState(()=>ho(e)),[w,k]=I.useState(()=>e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),O=()=>{g(uo(e)),m(e.type),k(e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),x("postgres"),C(ho(e)),c(!0)},M=()=>{c(!1),s?.()},j=async A=>{A.preventDefault();const L=new FormData(A.currentTarget),V=L.get("name")?.toString(),N=L.get("type")?.toString(),W=Lt[N];if(!V)throw new Error("Name is required");if(!N)throw new Error("Type is required");let X;if(N==="ducklake"){const ne={};if(v==="postgres"){const Z=Lt.postgres,ae={};if(Z.forEach(H=>{const Q=L.get(`ducklake_pg_${H.name}`)?.toString();Q&&(ae[H.name]=Q)}),Object.keys(ae).length===0)throw new Error("DuckLake requires catalog connection");ne.postgresConnection=ae}const J=L.get("ducklake_bucketUrl")?.toString();if(!J)throw new Error("DuckLake requires a bucket URL");const ee={bucketUrl:J};if(y==="s3"){const Z={};er.forEach(H=>{const Q=L.get(`ducklake_s3_${H.name}`)?.toString();Q&&(Z[H.name]=Q)});const ae=e.ducklakeConnection?.storage?.s3Connection;if(ae&&(!Z.provider&&ae.provider&&(Z.provider=ae.provider),!Z.chain&&ae.chain&&(Z.chain=ae.chain),!Z.accessKeyId&&ae.accessKeyId&&(Z.accessKeyId=ae.accessKeyId)),Z.provider==="credential_chain")delete Z.accessKeyId,delete Z.secretAccessKey,delete Z.sessionToken;else if(delete Z.chain,!Z.accessKeyId)throw new Error("S3 Access Key ID is required");Object.keys(Z).length>0&&(ee.s3Connection=Z)}else if(y==="gcs"){const Z={};tr.forEach(H=>{const Q=L.get(`ducklake_gcs_${H.name}`)?.toString();Q&&(Z[H.name]=Q)});const ae=e.ducklakeConnection?.storage?.gcsConnection;if(ae&&!Z.keyId&&ae.keyId&&(Z.keyId=ae.keyId),!Z.keyId)throw new Error("GCS Key ID is required");Object.keys(Z).length>0&&(ee.gcsConnection=Z)}X={name:V,type:N,ducklakeConnection:{catalog:ne,storage:ee}}}else if(N==="duckdb"){if(h.length===0)throw new Error("DuckDB connection must have at least one attached database");const ne=h.map((J,ee)=>{const Z=J.dbType,ae=L.get(`attachedDb_${ee}_name`)?.toString();if(!ae)throw new Error(`Attached database at index ${ee} must have a name`);const H={name:ae,type:Z},Q=br(Z);if(Q&&Q.length>0){const re={};if(Q.forEach(Re=>{const se=L.get(`attachedDb_${ee}_${Re.name}`)?.toString();se&&(re[Re.name]=se)}),Z==="s3"){if(re.provider==="credential_chain")delete re.accessKeyId,delete re.secretAccessKey,delete re.sessionToken;else if(delete re.chain,!re.accessKeyId||!re.secretAccessKey)throw new Error(`Attached database "${ae}" requires an S3 Access Key ID and Secret Access Key, or Credential Provider set to the host credential chain`)}const ve=Qr[Z];ve&&(H[ve]=re)}return H});X={name:V,type:N,duckdbConnection:{attachedDatabases:ne}}}else{const ne=e[Kn[N]]||{},J={};if(W.forEach(ee=>{const Z=L.get(ee.name)?.toString(),ae=ne[ee.name];Z?J[ee.name]=Z:co.has(ee.name)||(Z!==void 0?J[ee.name]=Z:ae&&(J[ee.name]=ae))}),N==="postgres"){const ee=["host","port","databaseName","userName"],Z=p.has("postgresConnection.connectionString");if(!(!!J.connectionString?.trim()||Z)){const H=ee;for(const Q of H)if(!J[Q])throw new Error(`${W.find(re=>re.name===Q)?.label||Q} is required`)}}else if(N==="snowflake"){if(!J.account)throw new Error("Account is required");if(!J.username)throw new Error("Username is required");if(!J.warehouse)throw new Error("Warehouse is required")}else if(N==="trino"){if(!J.server)throw new Error("Server is required");if(!J.user)throw new Error("User is required")}else if(N==="mysql"){const ee=["host","port","database","user"];for(const Z of ee)if(!J[Z])throw new Error(`${W.find(ae=>ae.name===Z)?.label||Z} is required`)}else if(N==="databricks"){if(!J.host)throw new Error("Host is required");if(!J.path)throw new Error("HTTP Path is required")}X={name:V,type:N,[Kn[N]]:J}}await r(X),M()},E=()=>{g([...h,{name:"",dbType:"postgres"}])},R=A=>{g(h.filter((L,V)=>V!==A))},U=(A,L)=>{const V=[...h];V[A]={...V[A],dbType:L},g(V)},P=(A,L)=>{const V=e.duckdbConnection?.attachedDatabases;if(!V||!V[A])return"";const N=V[A],W=Qr[N.type||""];return W&&N[W]?N[W][L]??"":""},K=A=>{const L=e.ducklakeConnection;if(!L)return"";if(A.startsWith("pg_")){const V=A.replace("pg_","");return L.catalog?.postgresConnection?.[V]??""}if(A==="bucketUrl")return L.storage?.bucketUrl??"";if(A.startsWith("s3_")){const V=A.replace("s3_","");return L.storage?.s3Connection?.[V]??""}if(A.startsWith("gcs_")){const V=A.replace("gcs_","");return L.storage?.gcsConnection?.[V]??""}return""};return n.jsxs(I.Fragment,{children:[n.jsxs(He,{"aria-label":`Edit connection ${e?.name??""}`.trim(),onClick:A=>{A.preventDefault(),A.stopPropagation(),O()},children:[n.jsx(os,{children:n.jsx(Ct.Edit,{fontSize:"small"})}),n.jsx(as,{children:"Edit"})]}),n.jsx(o.AppDialog,{open:d,onClose:M,title:"Edit connection",description:"Change how packages in this environment reach your database.",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:u,onClick:M,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"connection-form",variant:"contained",loading:u,children:"Save changes"})]}),children:n.jsx("form",{onSubmit:j,id:"connection-form",children:n.jsxs(Cr,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",defaultValue:e.name}),n.jsx(o.TextField,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:l,select:!0,onChange:A=>m(A.target.value),children:Xo.map(A=>n.jsx(He,{value:A,children:A},A))}),l==="ducklake"?n.jsxs(Ae,{sx:{mt:2},children:[n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsx(o.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),n.jsx(o.TextField,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:v,select:!0,onChange:A=>x(A.target.value),children:n.jsx(He,{value:"postgres",children:"PostgreSQL"})}),v==="postgres"&&n.jsx(n.Fragment,{children:Lt.postgres.map(A=>n.jsx(o.TextField,{id:`ducklake_pg_${A.name}`,name:`ducklake_pg_${A.name}`,label:A.label,type:A.type,fullWidth:!0,size:"small",defaultValue:K(`pg_${A.name}`)},`pg_${A.name}`))})]}),n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsx(o.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),n.jsxs(o.TextField,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:y,select:!0,onChange:A=>C(A.target.value),children:[n.jsx(He,{value:"s3",children:"S3"}),n.jsx(He,{value:"gcs",children:"GCS"})]}),n.jsx(o.TextField,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:y==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small",defaultValue:K("bucketUrl")}),y==="s3"&&n.jsxs(n.Fragment,{children:[n.jsx(o.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),er.filter(A=>A.visibleWhen?w===A.visibleWhen.value:!0).map(A=>n.jsx(o.TextField,{id:`ducklake_s3_${A.name}`,name:`ducklake_s3_${A.name}`,label:A.label,type:A.selectOptions?void 0:A.type,fullWidth:!0,size:"small",required:A.required&&A.name!=="secretAccessKey",select:!!A.selectOptions,defaultValue:A.selectOptions?w:K(`s3_${A.name}`),onChange:A.name==="provider"?L=>k(L.target.value):void 0,placeholder:A.name==="region"?"us-east-1":A.name==="secretAccessKey"&&p.has("ducklakeConnection.storage.s3Connection.secretAccessKey")?"Leave empty to keep existing":void 0,children:A.selectOptions?.map(L=>n.jsx(He,{value:L.value,children:L.label},L.value))},`s3_${A.name}`))]}),y==="gcs"&&n.jsxs(n.Fragment,{children:[n.jsx(o.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),tr.map(A=>n.jsx(o.TextField,{id:`ducklake_gcs_${A.name}`,name:`ducklake_gcs_${A.name}`,label:A.label,type:A.type,fullWidth:!0,size:"small",required:A.required&&A.name!=="secret",defaultValue:K(`gcs_${A.name}`),placeholder:A.name==="secret"&&p.has("ducklakeConnection.storage.gcsConnection.secret")?"Leave empty to keep existing":void 0},`gcs_${A.name}`))]})]})]}):l==="duckdb"?n.jsxs(Ae,{sx:{mt:2},children:[n.jsxs(Ae,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.jsx(o.Typography,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),n.jsx(o.SecondaryButton,{label:"Database",icon:n.jsx(o.AddIcon,{}),onClick:E,ariaLabel:"Add database"})]}),h.length===0&&n.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),h.map((A,L)=>{const V=br(A.dbType);return n.jsxs(Ae,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[n.jsxs(Ae,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[n.jsxs(o.Typography,{variant:"subtitle2",children:["Database ",L+1]}),n.jsx(o.IconButton,{"aria-label":`Remove attached database ${L+1}`,onClick:()=>R(L),size:"small",color:"error",children:n.jsx(Ko,{fontSize:"small"})})]}),n.jsx(o.TextField,{required:!0,id:`attachedDb_${L}_name`,name:`attachedDb_${L}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:A.name}),n.jsx(o.TextField,{id:`attachedDb_${L}_type`,name:`attachedDb_${L}_type`,label:"Database Type",fullWidth:!0,size:"small",value:A.dbType,select:!0,onChange:N=>U(L,N.target.value),children:Object.values(B.AttachedDatabaseTypeEnum).map(N=>n.jsx(He,{value:N,children:N},N))}),V.filter(N=>N.visibleWhen?(A[N.visibleWhen.field]||P(L,N.visibleWhen.field)||V.find(X=>X.name===N.visibleWhen?.field)?.selectOptions?.[0]?.value)===N.visibleWhen.value:!0).map(N=>n.jsx(o.TextField,{id:`attachedDb_${L}_${N.name}`,name:`attachedDb_${L}_${N.name}`,label:N.label,type:N.selectOptions?void 0:N.type,fullWidth:!0,size:"small",required:N.required,select:!!N.selectOptions,defaultValue:P(L,N.name)||N.selectOptions?.[0]?.value,onChange:N.selectOptions?W=>{const X=[...h];X[L]={...X[L],[N.name]:W.target.value},g(X)}:void 0,children:N.selectOptions?.map(W=>n.jsx(He,{value:W.value,children:W.label},W.value))},N.name))]},L)})]}):Lt[l].map(A=>{const L=e?.[Kn[l]??""]?.[A.name??""]??"",V=A.type==="password"||co.has(A.name),N=p.has(`${Kn[l]??""}.${A.name}`);return n.jsx(o.TextField,{id:A.name,name:A.name,label:A.label,type:A.type,fullWidth:!0,size:"small",required:A.required&&!V&&!L,defaultValue:L,placeholder:N?"Leave empty to keep existing":void 0,helperText:V?N?"Stored value is not shown. Leave empty to keep it.":"No value stored.":void 0},A.name)})]})})})]})}function fo(e,r){return!e||e.type!=="duckdb"?!1:(e.duckdbConnection?.attachedDatabases||[]).some(s=>s.type==="azure"&&s.name===r)}function ec(e){return e.startsWith("gs://")||e.startsWith("s3://")||e.startsWith("https://")||e.startsWith("abfss://")||e.startsWith("az://")}function Qo({connectionName:e,resourceUri:r,schema:u,connection:s}){const{apiClients:d}=B.useServer(),{environmentName:c}=o.parseResourceUri(r),[l,m]=I.useState(null),[p,h]=I.useState(u||null),[g,v]=I.useState(!1),{data:x,isError:y,isLoading:C,error:w}=o.useQueryWithApiError({queryKey:["schemas",c,e],queryFn:()=>d.connections.listSchemas(c,e)}),k=x?.data||[];return n.jsxs(S.Grid,{container:!0,spacing:1,children:[!u&&n.jsx(S.Grid,{size:{xs:12,md:4},children:n.jsxs(S.Paper,{sx:{p:1,m:0},children:[n.jsxs(S.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:0},children:[n.jsx(S.Typography,{variant:"overline",fontWeight:"bold",children:"Table Paths"}),n.jsx(S.FormControlLabel,{control:n.jsx(S.Switch,{checked:g,onChange:O=>v(O.target.checked)}),label:"Hidden Schemas"})]}),n.jsx(S.Divider,{sx:{mt:"2px"}}),n.jsxs(S.Box,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[C&&n.jsx(o.Loading,{text:"Loading schemas..."}),y&&n.jsx(o.ApiErrorDisplay,{error:w,context:`${c} > ${e} > Schemas`}),!C&&!y&&k.length===0&&n.jsx(S.Typography,{variant:"body2",children:"No Schemas"}),!C&&!y&&k.length>0&&n.jsx(S.List,{dense:!0,disablePadding:!0,children:k.map(O=>{const M=O.name;if(O.isHidden&&!g)return null;const E=p===M;return n.jsx(S.ListItemButton,{selected:E,onClick:()=>{h(M),m(null)},children:n.jsx(S.ListItemText,{primary:M})},M)})})]})]})}),n.jsx(S.Grid,{size:{xs:12,md:u?6:4},children:p&&n.jsx(S.Paper,{sx:{p:1,m:0},children:n.jsx(rc,{connectionName:e,schemaName:p,onTableSelect:O=>{m(O)},resourceUri:r,connection:s})})}),n.jsx(S.Grid,{size:{xs:12,md:u?6:4},children:p&&l&&n.jsx(tc,{environmentName:c,connectionName:e,schemaName:p,tableResource:l})})]})}function tc({environmentName:e,connectionName:r,schemaName:u,tableResource:s}){const{apiClients:d}=B.useServer(),{data:c,isLoading:l,isError:m,error:p}=o.useQueryWithApiError({queryKey:["connectionTableDetail",e,r,u,s],queryFn:()=>d.connections.getTable(e,r,u,s),enabled:!!u&&!!s}),h={resource:c?.data?.resource??s,columns:c?.data?.columns??[]};return n.jsxs(S.Paper,{sx:{p:1,m:0},children:[m&&n.jsx(o.ApiErrorDisplay,{error:p,context:`${e} > ${r} > ${u} > ${s}`}),!m&&n.jsx(nc,{table:h,loading:l})]})}function nc({table:e,loading:r}){return r?n.jsx(o.Loading,{text:"Loading columns..."}):n.jsxs(n.Fragment,{children:[n.jsxs(S.Typography,{variant:"overline",fontWeight:"bold",sx:{display:"block",wordBreak:"break-all"},children:[e.resource.includes("://")||/\.(parquet|csv|json|tsv|ndjson)$/i.test(e.resource)?"File":"Table",": ",e.resource]}),n.jsx(S.Divider,{}),n.jsx(S.Box,{sx:{mt:"10px",maxHeight:"600px",overflowY:"auto"},children:n.jsx(S.TableContainer,{children:n.jsxs(S.Table,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[n.jsx(S.TableHead,{children:n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:"NAME"}),n.jsx(S.TableCell,{children:"TYPE"})]})}),n.jsx(S.TableBody,{children:e.columns?.sort((u,s)=>u.name.localeCompare(s.name))?.map(u=>n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:u.name}),n.jsx(S.TableCell,{children:u.type})]},u.name))})]})})})]})}function rc({connectionName:e,schemaName:r,onTableSelect:u,resourceUri:s,connection:d}){const{environmentName:c}=o.parseResourceUri(s),{apiClients:l}=B.useServer(),[m,p]=I.useState(""),{data:h,isSuccess:g,isError:v,error:x,isLoading:y}=o.useQueryWithApiError({queryKey:["tablesInSchema",c,e,r],queryFn:()=>l.connections.listTables(c,e,r)}),C=fo(d,r),w=O=>C?O:O.split(".").pop()||O,k=g&&h?.data?h.data.filter(O=>w(O.resource).toLowerCase().includes(m.toLowerCase())).sort((O,M)=>w(O.resource).localeCompare(w(M.resource))):[];return n.jsxs(n.Fragment,{children:[n.jsx(S.Typography,{variant:"overline",fontWeight:"bold",children:ec(r)||fo(d,r)?`Files in ${r}`:`Tables in ${r}`}),n.jsx(S.Divider,{}),n.jsx(S.Box,{sx:{mt:1,mb:1},children:n.jsx(S.TextField,{size:"small",fullWidth:!0,placeholder:"Search tables...",value:m,onChange:O=>p(O.target.value),variant:"outlined"})}),n.jsx(S.Divider,{}),n.jsxs(S.Box,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[y&&n.jsx(o.Loading,{text:"Fetching Tables..."}),v&&n.jsx(o.ApiErrorDisplay,{error:x,context:`${c} > ${e} > ${r}`}),g&&k.length===0&&n.jsx(S.Typography,{variant:"body2",children:"No Tables"}),g&&h?.data&&h.data.length>0&&n.jsx(S.List,{dense:!0,disablePadding:!0,children:k.map(O=>{let M=w(O.resource);return!C&&O.resource.includes("://")&&(M=O.resource.split("/").pop()||O.resource),n.jsx(S.ListItemButton,{onClick:()=>u(O.resource),children:n.jsx(S.ListItemText,{primary:M,secondary:O.columns.length>0?`${O.columns.length} columns`:void 0})},O.resource)})})]})]})}const sc={bigquery:"BigQuery",snowflake:"Snowflake",postgres:"PostgreSQL",mysql:"MySQL",trino:"Trino",databricks:"Databricks",duckdb:"DuckDB",ducklake:"DuckLake",s3:"S3",gcs:"GCS",azure:"Azure"};function oc(e){return e?sc[e]??e:""}function ac({resourceUri:e}){const{apiClients:r,mutable:u}=B.useServer(),s=Sr.useQueryClient(),{environmentName:d}=o.parseResourceUri(e),[c,l]=I.useState(""),[m,p]=I.useState(null),h=o.encodeResourceUri({environmentName:d,connectionName:m}),{data:g,isSuccess:v,isError:x,error:y}=o.useQueryWithApiError({queryKey:["connections",d],queryFn:()=>r.connections.listConnections(d)}),C=o.useMutationWithApiError({mutationFn:Pt("connection","create",j=>r.environments.updateEnvironment(d,{name:d,connections:[...g.data,j]})),onSuccess(){l("Connection added successfully"),s.invalidateQueries({queryKey:["connections",d]})},onError(j){l(j.message)}}),w=o.useMutationWithApiError({mutationFn:Pt("connection","update",j=>r.environments.updateEnvironment(d,{name:d,connections:g.data.map(E=>E.name===j.name?j:E)})),onSuccess(j,E){l(`Connection ${E.name} updated successfully`),s.invalidateQueries({queryKey:["connections",d]})},onError(j){l(j.message)}}),k=o.useMutationWithApiError({mutationFn:Pt("connection","delete",j=>{if(!j.name)throw new Error("Cannot delete a connection with no name");return r.connections.deleteConnection(d,j.name)}),onSuccess(j,E){l(`Connection ${E.name} deleted successfully`),s.invalidateQueries({queryKey:["connections",d]})},onError(j){l(j.message)}}),O=v?[...g.data].sort((j,E)=>(j.name??"").localeCompare(E.name??"")):[],M=C.isPending||w.isPending||k.isPending;return n.jsxs(wt,{title:"Connections",...v?{count:O.length}:{},description:"Database connections available to packages in this environment",...u&&v?{action:n.jsx(Xl,{onSubmit:j=>C.mutateAsync(j),isSubmitting:C.isPending})}:{},children:[!v&&!x&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"Fetching Connections..."}),x&&n.jsx(o.ApiErrorDisplay,{error:y,context:`${d} > Connections`}),v&&O.length===0&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"No connections yet."}),v&&O.length>0&&n.jsx(S.Stack,{children:O.map(j=>n.jsx(ic,{connection:j,mutable:u,isMutating:M,onOpenExplorer:()=>p(j.name??null),onEdit:E=>w.mutateAsync(E),onDelete:E=>k.mutateAsync(E)},j.name))}),n.jsx(S.Snackbar,{open:c!=="",autoHideDuration:6e3,onClose:()=>l(""),message:c}),n.jsx(o.AppDialog,{open:m!==null,onClose:()=>p(null),maxWidth:"lg",title:`Connection explorer: ${m??""}`,showClose:!0,children:m&&n.jsx(Qo,{resourceUri:h,connectionName:m,connection:g?.data?.find(j=>j.name===m)})})]})}function ic({connection:e,mutable:r,isMutating:u,onOpenExplorer:s,onEdit:d,onDelete:c}){const[l,m]=I.useState(null),p=!!l,h=v=>{v.stopPropagation(),m(v.currentTarget)},g=()=>m(null);return n.jsx(wr,{icon:n.jsx(Pl,{sx:{fontSize:18}}),tint:B.SURFACE_TINT.connection,label:e.name??"",ariaLabel:e.name??"",description:oc(e.type),onClick:s,...r?{trailingAction:n.jsxs(n.Fragment,{children:[n.jsx(S.IconButton,{size:"small",onClick:h,"aria-label":`Connection actions for ${e.name??""}`.trim(),children:n.jsx(Ct.MoreVert,{fontSize:"small"})}),n.jsxs(S.Menu,{anchorEl:l,open:p,onClose:g,onClick:v=>v.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[n.jsx(Jl,{connection:e,onSubmit:d,isSubmitting:u,onCloseDialog:g}),n.jsx(Ql,{connection:e,onCloseDialog:g,isMutating:u,onDelete:()=>c(e)})]})]})}:{}})}const lc=o.createSvgIcon([n.jsx("path",{d:"M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2m-1 18H5V9h14zm1-13H4V4h16z"},"0"),n.jsx("path",{d:"M9 12h6v2H9z"},"1")]);function cc({resourceUri:e,onCloseDialog:r}){const[u,s]=I.useState(!1),{apiClients:d}=B.useServer(),c=()=>{s(!0)},l=()=>{s(!1),r()},{environmentName:m,packageName:p}=o.parseResourceUri(e),h=Cn({mutationFn:()=>d.packages.deletePackage(m,p),success:"Package deleted",invalidates:[["packages",m]],closeDialog:l,resource:"package",action:"delete"});return n.jsxs(I.Fragment,{children:[n.jsxs(S.MenuItem,{onClick:c,children:[n.jsx(S.ListItemIcon,{children:n.jsx(Ct.Delete,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Delete"})]}),n.jsx(o.AppDialog,{open:u,onClose:l,title:"Delete package",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{onClick:l,children:"Cancel"}),n.jsx(o.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>h.mutate(),loading:h.isPending,children:"Delete package"})]}),children:n.jsxs(o.Typography,{variant:"body2",children:["Delete ",n.jsx("strong",{children:p}),"? The package stops being served and this cannot be undone."]})}),h.notice]})}function uc({package:e,resourceUri:r,onCloseDialog:u}){const[s,d]=I.useState(!1),{apiClients:c}=B.useServer(),l=()=>{d(!0)},m=()=>{d(!1),u()},{packageName:p,environmentName:h}=o.parseResourceUri(r),g=Cn({mutationFn(x){return c.packages.updatePackage(h,p,{name:p,description:x.description})},success:"Package updated",invalidates:[["packages",h]],closeDialog:m,resource:"package",action:"update"}),v=x=>{x.preventDefault();const C=new FormData(x.currentTarget).get("description")?.toString();g.mutate({description:C})};return n.jsxs(I.Fragment,{children:[n.jsxs(S.MenuItem,{onClick:l,children:[n.jsx(S.ListItemIcon,{children:n.jsx(Ct.Edit,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Edit"})]}),n.jsx(o.AppDialog,{open:s,onClose:m,title:"Edit package",description:`What ${e.name} is, for the people who open it.`,actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:g.isPending,onClick:m,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"package-form",variant:"contained",loading:g.isPending,children:"Save changes"})]}),children:n.jsx("form",{onSubmit:v,id:"package-form",children:n.jsxs(S.Stack,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",disabled:!0,type:"text",fullWidth:!0,size:"small",defaultValue:e.name,InputLabelProps:{shrink:!0}}),n.jsx(o.TextField,{id:"description",name:"description",label:"Description",multiline:!0,fullWidth:!0,rows:4,size:"small",defaultValue:e.description,InputLabelProps:{shrink:!0}})]})})}),g.notice]})}function Jo({onSelectPackage:e,resourceUri:r}){const{apiClients:u}=B.useServer(),{environmentName:s}=o.parseResourceUri(r),{data:d,isSuccess:c,isError:l,error:m}=o.useQueryWithApiError({queryKey:["packages",s],queryFn:()=>u.packages.listPackages(s)});if(l)return n.jsx(o.ApiErrorDisplay,{error:m,context:`${s} > Packages`});if(!c)return n.jsx(o.Loading,{text:"Fetching Packages..."});const p=[...d.data].sort((h,g)=>h.name.localeCompare(g.name));return n.jsx(S.Stack,{children:p.map(h=>{const g=o.encodeResourceUri({environmentName:s,packageName:h.name});return n.jsx(dc,{pkg:h,packageResourceUri:g,onSelectPackage:e},h.name)})})}function dc({pkg:e,packageResourceUri:r,onSelectPackage:u}){const{mutable:s}=B.useServer(),[d,c]=I.useState(null),l=!!d,m=h=>{h.stopPropagation(),c(h.currentTarget)},p=()=>c(null);return n.jsx(wr,{icon:n.jsx(lc,{sx:{fontSize:18}}),tint:B.SURFACE_TINT.package,label:e.name,ariaLabel:e.name,...e.description?{description:e.description}:{},onClick:h=>u(e.name,h),...s?{trailingAction:n.jsxs(n.Fragment,{children:[n.jsx(S.IconButton,{size:"small",onClick:m,"aria-label":`Package actions for ${e.name}`,children:n.jsx(Ct.MoreVert,{fontSize:"small"})}),n.jsxs(S.Menu,{anchorEl:d,open:l,onClose:p,onClick:h=>h.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[n.jsx(uc,{package:e,resourceUri:r,onCloseDialog:p}),n.jsx(cc,{resourceUri:r,onCloseDialog:p})]})]})}:{}})}function hc({onSelectPackage:e,resourceUri:r}){const{apiClients:u,mutable:s}=B.useServer(),{environmentName:d}=o.parseResourceUri(r),c=o.useQueryWithApiError({queryKey:["packages",d],queryFn:()=>u.packages.listPackages(d)});return I.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"})},[]),n.jsxs(S.Container,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[n.jsxs(S.Box,{sx:{mb:4},children:[n.jsx(S.Typography,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:d}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"Manage packages and database connections in this environment. Open a package to explore its models and notebooks."})]}),n.jsx(wt,{title:"Packages",...c.isSuccess?{count:c.data.data.length}:{},description:"Published packages available for use in this environment",...s?{action:n.jsx(Rl,{resourceUri:r})}:{},children:n.jsx(Jo,{onSelectPackage:e,resourceUri:r})}),n.jsx(ac,{resourceUri:r}),n.jsx(Sl,{resourceUri:r})]})}function po({array1:e,array2:r,parser:u=s=>s}){return e&&r&&e.length===r.length&&e.every((s,d)=>u(s)===u(r[d]))}function mo(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function fc(e={}){const{ignoreAccents:r=!0,ignoreCase:u=!0,limit:s,matchFrom:d="any",stringify:c,trim:l=!1}=e;return(m,{inputValue:p,getOptionLabel:h})=>{let g=l?p.trim():p;u&&(g=g.toLowerCase()),r&&(g=mo(g));const v=g?m.filter(x=>{let y=(c||h)(x);return u&&(y=y.toLowerCase()),r&&(y=mo(y)),d==="start"?y.startsWith(g):y.includes(g)}):m;return typeof s=="number"?v.slice(0,s):v}}const pc=fc(),go=5,mc=e=>e.current!==null&&e.current.parentElement?.contains(document.activeElement),gc=[];function yo(e,r,u,s){if(r||e==null||s)return"";const d=u(e);return typeof d=="string"?d:""}function yc(e){const{unstable_isActiveElementInListbox:r=mc,unstable_classNamePrefix:u="Mui",autoComplete:s=!1,autoHighlight:d=!1,autoSelect:c=!1,blurOnSelect:l=!1,clearOnBlur:m=!e.freeSolo,clearOnEscape:p=!1,componentName:h="useAutocomplete",defaultValue:g=e.multiple?gc:null,disableClearable:v=!1,disableCloseOnSelect:x=!1,disabled:y,disabledItemsFocusable:C=!1,disableListWrap:w=!1,filterOptions:k=pc,filterSelectedOptions:O=!1,freeSolo:M=!1,getOptionDisabled:j,getOptionKey:E,getOptionLabel:R=z=>z.label??z,groupBy:U,handleHomeEndKeys:P=!e.freeSolo,id:K,includeInputInList:A=!1,inputValue:L,isOptionEqualToValue:V=(z,q)=>z===q,multiple:N=!1,onChange:W,onClose:X,onHighlightChange:ne,onInputChange:J,onOpen:ee,open:Z,openOnFocus:ae=!1,options:H,readOnly:Q=!1,renderValue:re,selectOnFocus:ve=!e.freeSolo,value:Re}=e,se=o.useId(K);let ie=R;ie=z=>{const q=R(z);return typeof q!="string"?String(q):q};const Ne=he.useRef(!1),xe=he.useRef(!0),_=he.useRef(null),oe=he.useRef(null),[ge,Te]=he.useState(null),[be,Oe]=he.useState(-1),$e=d?0:-1,Fe=he.useRef($e),Ye=he.useRef(yo(g??Re,N,ie)).current,[le,Qe]=o.useControlled({controlled:Re,default:g,name:h}),[ye,We]=o.useControlled({controlled:L,default:Ye,name:h,state:"inputValue"}),[ct,Nt]=he.useState(!1),gt=he.useCallback((z,q,te)=>{if(!(N?le.length<q.length:q!==null)&&!m)return;const Y=yo(q,N,ie,re);ye!==Y&&(We(Y),J&&J(z,Y,te))},[ie,ye,N,J,We,m,le,re]),[Ze,ut]=o.useControlled({controlled:Z,default:!1,name:h,state:"open"}),[pe,st]=he.useState(!0),nn=!N&&le!=null&&ye===ie(le),Ge=Ze&&!Q,ce=Ge?k(H.filter(z=>!(O&&(N?le:[le]).some(q=>q!==null&&V(z,q)))),{inputValue:nn&&pe?"":ye,getOptionLabel:ie}):[],Je=ml({filteredOptions:ce,value:le,inputValue:ye});he.useEffect(()=>{const z=le!==Je.value;ct&&!z||M&&!z||gt(null,le,"reset")},[le,gt,ct,Je.value,M]);const qe=Ze&&ce.length>0&&!Q,tt=o.useEventCallback(z=>{if(z===-1)_.current.focus();else{const q=re?"data-item-index":"data-tag-index";ge.querySelector(`[${q}="${z}"]`).focus()}});he.useEffect(()=>{N&&be>le.length-1&&(Oe(-1),tt(-1))},[le,N,be,tt]);function dt(z,q){if(!oe.current||z<0||z>=ce.length)return-1;let te=z;for(;;){const de=oe.current.querySelector(`[data-option-index="${te}"]`),Y=C?!1:!de||de.disabled||de.getAttribute("aria-disabled")==="true";if(de&&de.hasAttribute("tabindex")&&!Y)return te;if(q==="next"?te=(te+1)%ce.length:te=(te-1+ce.length)%ce.length,te===z)return-1}}const ot=o.useEventCallback(({event:z,index:q,reason:te})=>{if(Fe.current=q,q===-1?_.current.removeAttribute("aria-activedescendant"):_.current.setAttribute("aria-activedescendant",`${se}-option-${q}`),ne&&["mouse","keyboard","touch"].includes(te)&&ne(z,q===-1?null:ce[q],te),!oe.current)return;const de=oe.current.querySelector(`[role="option"].${u}-focused`);de&&(de.classList.remove(`${u}-focused`),de.classList.remove(`${u}-focusVisible`));let Y=oe.current;if(oe.current.getAttribute("role")!=="listbox"&&(Y=oe.current.parentElement.querySelector('[role="listbox"]')),!Y)return;if(q===-1){Y.scrollTop=0;return}const De=oe.current.querySelector(`[data-option-index="${q}"]`);if(De&&(De.classList.add(`${u}-focused`),te==="keyboard"&&De.classList.add(`${u}-focusVisible`),Y.scrollHeight>Y.clientHeight&&te!=="mouse"&&te!=="touch")){const Ie=De,at=Y.clientHeight+Y.scrollTop,cn=Ie.offsetTop+Ie.offsetHeight;cn>at?Y.scrollTop=cn-Y.clientHeight:Ie.offsetTop-Ie.offsetHeight*(U?1.3:0)<Y.scrollTop&&(Y.scrollTop=Ie.offsetTop-Ie.offsetHeight*(U?1.3:0))}}),nt=o.useEventCallback(({event:z,diff:q,direction:te="next",reason:de})=>{if(!Ge)return;const De=dt((()=>{const Ie=ce.length-1;if(q==="reset")return $e;if(q==="start")return 0;if(q==="end")return Ie;const at=Fe.current+q;return at<0?at===-1&&A?-1:w&&Fe.current!==-1||Math.abs(q)>1?0:Ie:at>Ie?at===Ie+1&&A?-1:w||Math.abs(q)>1?Ie:0:at})(),te);if(ot({index:De,reason:de,event:z}),s&&q!=="reset")if(De===-1)_.current.value=ye;else{const Ie=ie(ce[De]);_.current.value=Ie,Ie.toLowerCase().indexOf(ye.toLowerCase())===0&&ye.length>0&&_.current.setSelectionRange(ye.length,Ie.length)}}),rn=!po({array1:Je.filteredOptions,array2:ce,parser:ie}),kn=()=>{const z=(q,te)=>{const de=q?ie(q):"",Y=te?ie(te):"";return de===Y};if(Fe.current!==-1&&!po({array1:Je.filteredOptions,array2:ce,parser:ie})&&Je.inputValue===ye&&(N?le.length===Je.value.length&&Je.value.every((q,te)=>ie(le[te])===ie(q)):z(Je.value,le))){const q=Je.filteredOptions[Fe.current];if(q)return ce.findIndex(te=>ie(te)===ie(q))}return-1},Ft=he.useCallback(()=>{if(!Ge)return;const z=kn();if(z!==-1){Fe.current=z;return}const q=N?le[0]:le;if(ce.length===0||q==null){nt({diff:"reset"});return}if(oe.current){if(q!=null){const te=ce[Fe.current];if(N&&te&&le.findIndex(Y=>V(te,Y))!==-1)return;const de=ce.findIndex(Y=>V(Y,q));de===-1?nt({diff:"reset"}):ot({index:de});return}if(Fe.current>=ce.length-1){ot({index:ce.length-1});return}ot({index:Fe.current})}},[ce.length,N?!1:le,O,nt,ot,Ge,ye,N]),kt=o.useEventCallback(z=>{o.setRef(oe,z),z&&Ft()});he.useEffect(()=>{rn&&Ft()},[Ft,rn]);const ze=z=>{Ze||(ut(!0),st(!0),ee&&ee(z))},Tt=(z,q)=>{Ze&&(ut(!1),X&&X(z,q))},ht=(z,q,te,de)=>{if(N){if(le.length===q.length&&le.every((Y,De)=>Y===q[De]))return}else if(le===q)return;W&&W(z,q,te,de),Qe(q)},ft=he.useRef(!1),yt=(z,q,te="selectOption",de="options")=>{let Y=te,De=q;if(N){De=Array.isArray(le)?le.slice():[];const Ie=De.findIndex(at=>V(q,at));Ie===-1?De.push(q):de!=="freeSolo"&&(De.splice(Ie,1),Y="removeOption")}gt(z,De,Y),ht(z,De,Y,{option:q}),!x&&(!z||!z.ctrlKey&&!z.metaKey)&&Tt(z,Y),(l===!0||l==="touch"&&ft.current||l==="mouse"&&!ft.current)&&_.current.blur()};function sn(z,q){if(z===-1)return-1;let te=z;for(;;){if(q==="next"&&te===le.length||q==="previous"&&te===-1)return-1;const de=re?"data-item-index":"data-tag-index",Y=ge.querySelector(`[${de}="${te}"]`);if(!Y||!Y.hasAttribute("tabindex")||Y.disabled||Y.getAttribute("aria-disabled")==="true")te+=q==="next"?1:-1;else return te}}const Ot=(z,q)=>{if(!N)return;ye===""&&Tt(z,"toggleInput");let te=be;be===-1?ye===""&&q==="previous"&&(te=le.length-1):(te+=q==="next"?1:-1,te<0&&(te=0),te===le.length&&(te=-1)),te=sn(te,q),Oe(te),tt(te)},Ht=z=>{Ne.current=!0,We(""),J&&J(z,"","clear"),ht(z,N?[]:null,"clear")},on=z=>q=>{if(z.onKeyDown&&z.onKeyDown(q),!q.defaultMuiPrevented&&(be!==-1&&!["ArrowLeft","ArrowRight"].includes(q.key)&&(Oe(-1),tt(-1)),q.which!==229))switch(q.key){case"Home":Ge&&P&&(q.preventDefault(),nt({diff:"start",direction:"next",reason:"keyboard",event:q}));break;case"End":Ge&&P&&(q.preventDefault(),nt({diff:"end",direction:"previous",reason:"keyboard",event:q}));break;case"PageUp":q.preventDefault(),nt({diff:-go,direction:"previous",reason:"keyboard",event:q}),ze(q);break;case"PageDown":q.preventDefault(),nt({diff:go,direction:"next",reason:"keyboard",event:q}),ze(q);break;case"ArrowDown":q.preventDefault(),nt({diff:1,direction:"next",reason:"keyboard",event:q}),ze(q);break;case"ArrowUp":q.preventDefault(),nt({diff:-1,direction:"previous",reason:"keyboard",event:q}),ze(q);break;case"ArrowLeft":!N&&re?tt(0):Ot(q,"previous");break;case"ArrowRight":!N&&re?tt(-1):Ot(q,"next");break;case"Enter":if(Fe.current!==-1&&Ge){const te=ce[Fe.current],de=j?j(te):!1;if(q.preventDefault(),de)return;yt(q,te,"selectOption"),s&&_.current.setSelectionRange(_.current.value.length,_.current.value.length)}else M&&ye!==""&&nn===!1&&(N&&q.preventDefault(),yt(q,ye,"createOption","freeSolo"));break;case"Escape":Ge?(q.preventDefault(),q.stopPropagation(),Tt(q,"escape")):p&&(ye!==""||N&&le.length>0||re)&&(q.preventDefault(),q.stopPropagation(),Ht(q));break;case"Backspace":if(N&&!Q&&ye===""&&le.length>0){const te=be===-1?le.length-1:be,de=le.slice();de.splice(te,1),ht(q,de,"removeOption",{option:le[te]})}!N&&re&&!Q&&(Qe(null),tt(-1));break;case"Delete":if(N&&!Q&&ye===""&&le.length>0&&be!==-1){const te=be,de=le.slice();de.splice(te,1),ht(q,de,"removeOption",{option:le[te]})}!N&&re&&!Q&&(Qe(null),tt(-1));break}},je=z=>{Nt(!0),ae&&!Ne.current&&ze(z)},Ue=z=>{if(r(oe)){_.current.focus();return}Nt(!1),xe.current=!0,Ne.current=!1,c&&Fe.current!==-1&&Ge?yt(z,ce[Fe.current],"blur"):c&&M&&ye!==""?yt(z,ye,"blur","freeSolo"):m&>(z,le,"blur"),Tt(z,"blur")},_t=z=>{const q=z.target.value;ye!==q&&(We(q),st(!1),J&&J(z,q,"input")),q===""?!v&&!N&&ht(z,null,"clear"):ze(z)},an=z=>{const q=Number(z.currentTarget.getAttribute("data-option-index"));Fe.current!==q&&ot({event:z,index:q,reason:"mouse"})},Ke=z=>{ot({event:z,index:Number(z.currentTarget.getAttribute("data-option-index")),reason:"touch"}),ft.current=!0},Vt=z=>{const q=Number(z.currentTarget.getAttribute("data-option-index"));yt(z,ce[q],"selectOption"),ft.current=!1},ln=z=>q=>{const te=le.slice();te.splice(z,1),ht(q,te,"removeOption",{option:le[z]})},Wt=z=>{ht(z,null,"removeOption",{option:le})},Pe=z=>{Ze?Tt(z,"toggleInput"):ze(z)},Le=z=>{z.currentTarget.contains(z.target)&&z.target.getAttribute("id")!==se&&z.preventDefault()},xt=z=>{z.currentTarget.contains(z.target)&&(_.current.focus(),ve&&xe.current&&_.current.selectionEnd-_.current.selectionStart===0&&_.current.select(),xe.current=!1)},Bt=z=>{!y&&(ye===""||!Ze)&&Pe(z)};let qt=M&&ye.length>0;qt=qt||(N?le.length>0:le!==null);let Ut=ce;return U&&(Ut=ce.reduce((z,q,te)=>{const de=U(q);return z.length>0&&z[z.length-1].group===de?z[z.length-1].options.push(q):z.push({key:te,index:te,group:de,options:[q]}),z},[])),y&&ct&&Ue(),{getRootProps:(z={})=>({...z,onKeyDown:on(z),onMouseDown:Le,onClick:xt}),getInputLabelProps:()=>({id:`${se}-label`,htmlFor:se}),getInputProps:()=>({id:se,value:ye,onBlur:Ue,onFocus:je,onChange:_t,onMouseDown:Bt,"aria-activedescendant":Ge?"":null,"aria-autocomplete":s?"both":"list","aria-controls":qe?`${se}-listbox`:void 0,"aria-expanded":qe,autoComplete:"off",ref:_,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:y}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:Ht}),getItemProps:({index:z=0}={})=>({...N&&{key:z},...re?{"data-item-index":z}:{"data-tag-index":z},tabIndex:-1,...!Q&&{onDelete:N?ln(z):Wt}}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:Pe}),getTagProps:({index:z})=>({key:z,"data-tag-index":z,tabIndex:-1,...!Q&&{onDelete:ln(z)}}),getListboxProps:()=>({role:"listbox",id:`${se}-listbox`,"aria-labelledby":`${se}-label`,ref:kt,onMouseDown:z=>{z.preventDefault()}}),getOptionProps:({index:z,option:q})=>{const te=(N?le:[le]).some(Y=>Y!=null&&V(q,Y)),de=j?j(q):!1;return{key:E?.(q)??ie(q),tabIndex:-1,role:"option",id:`${se}-option-${z}`,onMouseMove:an,onClick:Vt,onTouchStart:Ke,"data-option-index":z,"aria-disabled":de,"aria-selected":te}},id:se,inputValue:ye,value:le,dirty:qt,expanded:Ge&&ge,popupOpen:Ge,focused:ct||be!==-1,anchorEl:ge,setAnchorEl:Te,focusedItem:be,focusedTag:be,groupedOptions:Ut}}function xc(e){return o.generateUtilityClass("MuiListSubheader",e)}o.generateUtilityClasses("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);const bc=e=>{const{classes:r,color:u,disableGutters:s,inset:d,disableSticky:c}=e,l={root:["root",u!=="default"&&`color${o.capitalize(u)}`,!s&&"gutters",d&&"inset",!c&&"sticky"]};return o.composeClasses(l,xc,r)},vc=o.styled("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.root,u.color!=="default"&&r[`color${o.capitalize(u.color)}`],!u.disableGutters&&r.gutters,u.inset&&r.inset,!u.disableSticky&&r.sticky]}})(o.memoTheme(({theme:e})=>({boxSizing:"border-box",lineHeight:"48px",listStyle:"none",color:(e.vars||e).palette.text.secondary,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(14),variants:[{props:{color:"primary"},style:{color:(e.vars||e).palette.primary.main}},{props:{color:"inherit"},style:{color:"inherit"}},{props:({ownerState:r})=>!r.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:r})=>r.inset,style:{paddingLeft:72}},{props:({ownerState:r})=>!r.disableSticky,style:{position:"sticky",top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper}}]}))),Jr=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiListSubheader"}),{className:d,color:c="default",component:l="li",disableGutters:m=!1,disableSticky:p=!1,inset:h=!1,...g}=s,v={...s,color:c,component:l,disableGutters:m,disableSticky:p,inset:h},x=bc(v);return n.jsx(vc,{as:l,className:o.clsx(x.root,d),ref:u,ownerState:v,...g})});Jr&&(Jr.muiSkipListHighlight=!0);const Sc=o.createSvgIcon(n.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}));function wc(e){return o.generateUtilityClass("MuiAutocomplete",e)}const we=o.generateUtilityClasses("MuiAutocomplete",["root","expanded","fullWidth","focused","focusVisible","tag","tagSizeSmall","tagSizeMedium","hasPopupIcon","hasClearIcon","inputRoot","input","inputFocused","endAdornment","clearIndicator","popupIndicator","popupIndicatorOpen","popper","popperDisablePortal","paper","listbox","loading","noOptions","option","groupLabel","groupUl"]);var xo,bo;const Cc=e=>{const{classes:r,disablePortal:u,expanded:s,focused:d,fullWidth:c,hasClearIcon:l,hasPopupIcon:m,inputFocused:p,popupOpen:h,size:g}=e,v={root:["root",s&&"expanded",d&&"focused",c&&"fullWidth",l&&"hasClearIcon",m&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",p&&"inputFocused"],tag:["tag",`tagSize${o.capitalize(g)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",h&&"popupIndicatorOpen"],popper:["popper",u&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return o.composeClasses(v,wc,r)},kc=o.styled("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e,{fullWidth:s,hasClearIcon:d,hasPopupIcon:c,inputFocused:l,size:m}=u;return[{[`& .${we.tag}`]:r.tag},{[`& .${we.tag}`]:r[`tagSize${o.capitalize(m)}`]},{[`& .${we.inputRoot}`]:r.inputRoot},{[`& .${we.input}`]:r.input},{[`& .${we.input}`]:l&&r.inputFocused},r.root,s&&r.fullWidth,c&&r.hasPopupIcon,d&&r.hasClearIcon]}})({[`&.${we.focused} .${we.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${we.clearIndicator}`]:{visibility:"visible"}},[`& .${we.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${we.inputRoot}`]:{[`.${we.hasPopupIcon}&, .${we.hasClearIcon}&`]:{paddingRight:30},[`.${we.hasPopupIcon}.${we.hasClearIcon}&`]:{paddingRight:56},[`& .${we.input}`]:{width:0,minWidth:30}},[`& .${o.inputClasses.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${o.inputClasses.root}.${o.inputBaseClasses.sizeSmall}`]:{[`& .${o.inputClasses.input}`]:{padding:"2px 4px 3px 0"}},[`& .${o.outlinedInputClasses.root}`]:{padding:9,[`.${we.hasPopupIcon}&, .${we.hasClearIcon}&`]:{paddingRight:39},[`.${we.hasPopupIcon}.${we.hasClearIcon}&`]:{paddingRight:65},[`& .${we.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${we.endAdornment}`]:{right:9}},[`& .${o.outlinedInputClasses.root}.${o.inputBaseClasses.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${we.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${o.filledInputClasses.root}`]:{paddingTop:19,paddingLeft:8,[`.${we.hasPopupIcon}&, .${we.hasClearIcon}&`]:{paddingRight:39},[`.${we.hasPopupIcon}.${we.hasClearIcon}&`]:{paddingRight:65},[`& .${o.filledInputClasses.input}`]:{padding:"7px 4px"},[`& .${we.endAdornment}`]:{right:9}},[`& .${o.filledInputClasses.root}.${o.inputBaseClasses.sizeSmall}`]:{paddingBottom:1,[`& .${o.filledInputClasses.input}`]:{padding:"2.5px 4px"}},[`& .${o.inputBaseClasses.hiddenLabel}`]:{paddingTop:8},[`& .${o.filledInputClasses.root}.${o.inputBaseClasses.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${we.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${o.filledInputClasses.root}.${o.inputBaseClasses.hiddenLabel}.${o.inputBaseClasses.sizeSmall}`]:{[`& .${we.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${we.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${we.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${we.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${we.inputRoot}`]:{flexWrap:"wrap"}}}]}),Tc=o.styled("div",{name:"MuiAutocomplete",slot:"EndAdornment"})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),Oc=o.styled(o.IconButton,{name:"MuiAutocomplete",slot:"ClearIndicator"})({marginRight:-2,padding:4,visibility:"hidden"}),Mc=o.styled(o.IconButton,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.popupIndicator,u.popupOpen&&r.popupIndicatorOpen]}})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),jc=o.styled(o.Popper,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[{[`& .${we.option}`]:r.option},r.popper,u.disablePortal&&r.popperDisablePortal]}})(o.memoTheme(({theme:e})=>({zIndex:(e.vars||e).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]}))),Dc=o.styled(o.Paper,{name:"MuiAutocomplete",slot:"Paper"})(o.memoTheme(({theme:e})=>({...e.typography.body1,overflow:"auto"}))),Ec=o.styled("div",{name:"MuiAutocomplete",slot:"Loading"})(o.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),Ic=o.styled("div",{name:"MuiAutocomplete",slot:"NoOptions"})(o.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),Nc=o.styled("ul",{name:"MuiAutocomplete",slot:"Listbox"})(o.memoTheme(({theme:e})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${we.option}`]:{minHeight:48,display:"flex",overflow:"hidden",justifyContent:"flex-start",alignItems:"center",cursor:"pointer",paddingTop:6,boxSizing:"border-box",outline:"0",WebkitTapHighlightColor:"transparent",paddingBottom:6,paddingLeft:16,paddingRight:16,[e.breakpoints.up("sm")]:{minHeight:"auto"},[`&.${we.focused}`]:{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},'&[aria-disabled="true"]':{opacity:(e.vars||e).palette.action.disabledOpacity,pointerEvents:"none"},[`&.${we.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},'&[aria-selected="true"]':{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${we.focused}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${we.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}}}}))),Fc=o.styled(Jr,{name:"MuiAutocomplete",slot:"GroupLabel"})(o.memoTheme(({theme:e})=>({backgroundColor:(e.vars||e).palette.background.paper,top:-8}))),Ac=o.styled("ul",{name:"MuiAutocomplete",slot:"GroupUl"})({padding:0,[`& .${we.option}`]:{paddingLeft:24}}),es=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiAutocomplete"}),{autoComplete:d=!1,autoHighlight:c=!1,autoSelect:l=!1,blurOnSelect:m=!1,ChipProps:p,className:h,clearIcon:g=xo||(xo=n.jsx(Sc,{fontSize:"small"})),clearOnBlur:v=!s.freeSolo,clearOnEscape:x=!1,clearText:y="Clear",closeText:C="Close",componentsProps:w,defaultValue:k=s.multiple?[]:null,disableClearable:O=!1,disableCloseOnSelect:M=!1,disabled:j=!1,disabledItemsFocusable:E=!1,disableListWrap:R=!1,disablePortal:U=!1,filterOptions:P,filterSelectedOptions:K=!1,forcePopupIcon:A="auto",freeSolo:L=!1,fullWidth:V=!1,getLimitTagsText:N=Ce=>`+${Ce}`,getOptionDisabled:W,getOptionKey:X,getOptionLabel:ne,isOptionEqualToValue:J,groupBy:ee,handleHomeEndKeys:Z=!s.freeSolo,id:ae,includeInputInList:H=!1,inputValue:Q,limitTags:re=-1,ListboxComponent:ve,ListboxProps:Re,loading:se=!1,loadingText:ie="Loading…",multiple:Ne=!1,noOptionsText:xe="No options",onChange:_,onClose:oe,onHighlightChange:ge,onInputChange:Te,onOpen:be,open:Oe,openOnFocus:$e=!1,openText:Fe="Open",options:Ye,PaperComponent:le,PopperComponent:Qe,popupIcon:ye=bo||(bo=n.jsx(o.ArrowDropDownIcon,{})),readOnly:We=!1,renderGroup:ct,renderInput:Nt,renderOption:gt,renderTags:Ze,renderValue:ut,selectOnFocus:pe=!s.freeSolo,size:st="medium",slots:nn={},slotProps:Ge={},value:ce,...Je}=s,{getRootProps:qe,getInputProps:tt,getInputLabelProps:dt,getPopupIndicatorProps:ot,getClearProps:nt,getItemProps:rn,getListboxProps:kn,getOptionProps:Ft,value:kt,dirty:ze,expanded:Tt,id:ht,popupOpen:ft,focused:yt,focusedItem:sn,anchorEl:Ot,setAnchorEl:Ht,inputValue:on,groupedOptions:je}=yc({...s,componentName:"Autocomplete"}),Ue=!O&&!j&&ze&&!We,_t=(!L||A===!0)&&A!==!1,{onMouseDown:an}=tt(),{ref:Ke,...Vt}=kn(),Wt=ne||(Ce=>Ce.label??Ce),Pe={...s,disablePortal:U,expanded:Tt,focused:yt,fullWidth:V,getOptionLabel:Wt,hasClearIcon:Ue,hasPopupIcon:_t,inputFocused:sn===-1,popupOpen:ft,size:st},Le=Cc(Pe),xt={slots:{paper:le,popper:Qe,...nn},slotProps:{chip:p,listbox:Re,...w,...Ge}},[Bt,qt]=o.useSlot("listbox",{elementType:Nc,externalForwardedProps:xt,ownerState:Pe,className:Le.listbox,additionalProps:Vt,ref:Ke}),[Ut,z]=o.useSlot("paper",{elementType:o.Paper,externalForwardedProps:xt,ownerState:Pe,className:Le.paper}),[q,te]=o.useSlot("popper",{elementType:o.Popper,externalForwardedProps:xt,ownerState:Pe,className:Le.popper,additionalProps:{disablePortal:U,style:{width:Ot?Ot.clientWidth:null},role:"presentation",anchorEl:Ot,open:ft}});let de;const Y=Ce=>({className:Le.tag,disabled:j,...rn(Ce)});if(Ne?kt.length>0&&(Ze?de=Ze(kt,Y,Pe):ut?de=ut(kt,Y,Pe):de=kt.map((Ce,Mt)=>{const{key:et,...At}=Y({index:Mt});return n.jsx(o.Chip,{label:Wt(Ce),size:st,...At,...xt.slotProps.chip},et)})):ut&&kt!=null&&(de=ut(kt,Y,Pe)),re>-1&&Array.isArray(de)){const Ce=de.length-re;!yt&&Ce>0&&(de=de.splice(0,re),de.push(n.jsx("span",{className:Le.tag,children:N(Ce)},de.length)))}const Ie=ct||(Ce=>n.jsxs("li",{children:[n.jsx(Fc,{className:Le.groupLabel,ownerState:Pe,component:"div",children:Ce.group}),n.jsx(Ac,{className:Le.groupUl,ownerState:Pe,children:Ce.children})]},Ce.key)),cn=gt||((Ce,Mt)=>{const{key:et,...At}=Ce;return n.jsx("li",{...At,children:Wt(Mt)},et)}),Tn=(Ce,Mt)=>{const et=Ft({option:Ce,index:Mt});return cn({...et,className:Le.option},Ce,{selected:et["aria-selected"],index:Mt,inputValue:on},Pe)},On=xt.slotProps.clearIndicator,rr=xt.slotProps.popupIndicator;return n.jsxs(he.Fragment,{children:[n.jsx(kc,{ref:u,className:o.clsx(Le.root,h),ownerState:Pe,...qe(Je),children:Nt({id:ht,disabled:j,fullWidth:!0,size:st==="small"?"small":void 0,InputLabelProps:dt(),InputProps:{ref:Ht,className:Le.inputRoot,startAdornment:de,onMouseDown:Ce=>{Ce.target===Ce.currentTarget&&an(Ce)},...(Ue||_t)&&{endAdornment:n.jsxs(Tc,{className:Le.endAdornment,ownerState:Pe,children:[Ue?n.jsx(Oc,{...nt(),"aria-label":y,title:y,ownerState:Pe,...On,className:o.clsx(Le.clearIndicator,On?.className),children:g}):null,_t?n.jsx(Mc,{...ot(),disabled:j,"aria-label":ft?C:Fe,title:ft?C:Fe,ownerState:Pe,...rr,className:o.clsx(Le.popupIndicator,rr?.className),children:ye}):null]})}},inputProps:{className:Le.input,disabled:j,readOnly:We,...tt()}})}),Ot?n.jsx(jc,{as:q,...te,children:n.jsxs(Dc,{as:Ut,...z,children:[se&&je.length===0?n.jsx(Ec,{className:Le.loading,ownerState:Pe,children:ie}):null,je.length===0&&!L&&!se?n.jsx(Ic,{className:Le.noOptions,ownerState:Pe,role:"presentation",onMouseDown:Ce=>{Ce.preventDefault()},children:xe}):null,je.length>0?n.jsx(Bt,{as:ve,...qt,children:je.map((Ce,Mt)=>ee?Ie({key:Ce.key,group:Ce.group,children:Ce.options.map((et,At)=>Tn(et,Ce.index+At))}):Tn(Ce,Mt))}):null]})}):null]})});o.dayjs.extend(o.utc);function Pr(e){switch(e){case"Star":return["Equals","Contains"];case"MinMax":return["Equals","Less Than","Greater Than","Between"];case"DateMinMax":return["Equals","Before","After","Between"];case"Retrieval":return["Semantic Search"];case"Boolean":return["Equals"];case"NONE":default:return[]}}function $c(e){return e==="DateMinMax"}function Lr(e){return e==="Between"}function Rc({spec:e,values:r,selection:u,onChange:s,retrievalFn:d}){const c=()=>u?.matchType?u.matchType:e.defaultMatchType?e.defaultMatchType:e.filterType==="DateMinMax"?"Between":Pr(e.filterType)[0]||"Equals",[l,m]=I.useState(c()),[p,h]=I.useState(u?.value??""),[g,v]=I.useState(u?.value2??""),[x,y]=I.useState([]),[C,w]=I.useState(!1),[k,O]=I.useState(""),[M,j]=I.useState(!1),[E,R]=I.useState(!1),U=I.useRef(null),P=I.useRef(0),[K,A]=I.useState(!1);I.useEffect(()=>{if(e.filterType!=="Retrieval"||!d)return;const H=k.trim();if(H.length<=2){y([]),j(!1);return}return U.current&&clearTimeout(U.current),U.current=setTimeout(async()=>{P.current+=1;const Q=P.current;w(!0);try{const re=await d(H,e);Q===P.current&&y(re)}catch(re){Q===P.current&&(console.error("Retrieval failed",re),y([]))}finally{Q===P.current&&(w(!1),j(!0))}},500),()=>{U.current&&clearTimeout(U.current)}},[k,e,d]),I.useEffect(()=>{u===null?(h(""),v(""),m(e.defaultMatchType??(e.filterType==="DateMinMax"?"Between":Pr(e.filterType)[0]||"Equals"))):u&&(m(u.matchType),h(u.value??""),v(u.value2??""))},[u,e.filterType,e.defaultMatchType]);const L=Pr(e.filterType),V=$c(e.filterType),N=Lr(l),W=V&&r.length>=2&&r[0].value instanceof Date?o.dayjs.utc(r[0].value):void 0,X=V&&r.length>=2&&r[1].value instanceof Date?o.dayjs.utc(r[1].value):void 0,ne=e.filterType==="MinMax"&&r.length>=2&&typeof r[0].value=="number"?r[0].value:void 0,J=e.filterType==="MinMax"&&r.length>=2&&typeof r[1].value=="number"?r[1].value:void 0;if(L.length===0)return null;const ee=H=>{const Q=H.target.value;m(Q),Lr(Q)||v(""),p&&s({dimensionName:e.dimensionName,source:e.source,filterName:e.filterName,matchType:Q,value:p,...Lr(Q)&&g&&{value2:g}})},Z=(H,Q)=>{h(H??""),Q!==void 0&&v(Q??"");const re=Array.isArray(H)&&H.length===0;s(!re&&H!==""&&H!==null&&H!==void 0?{dimensionName:e.dimensionName,source:e.source,filterName:e.filterName,matchType:l,value:H,...N&&Q&&{value2:Q}}:null)},ae=()=>{h(""),v(""),s(null)};return n.jsxs(Ae,{sx:{display:"flex",flexDirection:"column",gap:1.5,fontSize:"0.75rem","& .MuiInputBase-root":{fontSize:"0.75rem"},"& .MuiInputBase-input":{padding:"6px 10px"},"& .MuiSelect-select":{padding:"6px 10px !important"},"& .MuiAutocomplete-input":{padding:"0 !important"},"& .MuiAutocomplete-root .MuiInputBase-root":{padding:"5px 10px",minHeight:"29.5px",boxSizing:"border-box",flexWrap:"wrap"},"& .MuiChip-root":{height:"16px",margin:"0 2px 0 0"},"& .MuiChip-label":{fontSize:"0.7rem",padding:"0 6px"},"& .MuiChip-deleteIcon":{fontSize:"14px",margin:"0 2px 0 -4px"},"& .MuiInputLabel-root":{fontSize:"0.75rem",transform:"translate(10px, 6px) scale(1)"},"& .MuiInputLabel-shrink":{fontSize:"0.85rem",transform:"translate(14px, -9px) scale(0.75)"},"& .MuiOutlinedInput-notchedOutline legend":{fontSize:"0.65rem"},"& .MuiFormHelperText-root":{fontSize:"0.65rem",marginTop:"2px"},"& .MuiSvgIcon-root":{fontSize:"1.25rem"}},children:[n.jsxs(Ae,{sx:{fontWeight:600,color:e.required&&!u?"error.main":"text.primary"},children:[e.label??e.dimensionName,e.required&&n.jsx(Ae,{component:"span",sx:{color:u?"text.secondary":"error.main",fontWeight:400,fontSize:"0.7rem",ml:.5},children:"(required)"})]}),e.filterType!=="Boolean"&&!e.defaultMatchType&&L.length>1&&n.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[n.jsx(o.InputLabel,{children:"Match Type"}),n.jsx(o.Select,{value:l,label:"Match Type",onChange:ee,MenuProps:{PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}},children:L.map(H=>n.jsx(He,{value:H,children:H},H))})]}),e.filterType==="Star"&&l==="Equals"&&n.jsx(es,{multiple:!0,size:"small",options:r,getOptionLabel:H=>typeof H=="string"?H:typeof H=="object"&&H!==null&&"value"in H?String(H.value):String(H),value:Array.isArray(p)?p.map(H=>r.find(Q=>Q.value===H)||H):p?[r.find(H=>H.value===p)||p]:[],onChange:(H,Q)=>{const re=Q.map(ve=>typeof ve=="string"?ve:ve&&typeof ve=="object"&&"value"in ve?ve.value:ve);Z(re)},noOptionsText:"No matches found",renderInput:H=>n.jsx(o.TextField,{...H,size:"small",label:"Values",placeholder:"Select values..."}),freeSolo:!e.values||e.values.length===0,slotProps:{paper:{sx:{"& .MuiAutocomplete-option":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}}}),e.filterType==="Star"&&l==="Contains"&&n.jsx(o.TextField,{size:"small",label:"Search Text",value:p,onChange:H=>h(H.target.value),onBlur:()=>Z(p),onKeyDown:H=>{H.key==="Enter"&&Z(p)},placeholder:"Enter text to search...",fullWidth:!0}),e.filterType==="Boolean"&&n.jsxs(o.FormControl,{size:"small",fullWidth:!0,children:[n.jsx(o.InputLabel,{children:"Value"}),n.jsxs(o.Select,{value:p===!0?"true":p===!1?"false":"",label:"Value",onChange:H=>{const Q=H.target.value;Q==="true"?Z(!0):Q==="false"?Z(!1):ae()},MenuProps:{PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}},children:[n.jsx(He,{value:"",children:n.jsx("em",{children:"Blank"})}),n.jsx(He,{value:"true",children:"True"}),n.jsx(He,{value:"false",children:"False"})]})]}),e.filterType==="Retrieval"&&l==="Semantic Search"&&n.jsx(es,{multiple:!0,size:"small",options:x,loading:C,getOptionLabel:H=>typeof H=="string"?H:typeof H=="object"&&H!==null&&"value"in H?String(H.value):String(H),value:Array.isArray(p)?p.map(H=>x.find(re=>re.value===H)||{value:H}):p?[{value:p}]:[],onInputChange:(H,Q)=>{O(Q)},onChange:(H,Q)=>{const re=Q.map(ve=>typeof ve=="string"?ve:ve&&typeof ve=="object"&&"value"in ve?ve.value:ve);Z(re)},noOptionsText:k.trim().length<=2?"Type at least 3 characters to search":"No matches found",renderInput:H=>n.jsx(o.TextField,{...H,size:"small",label:"Search Values",placeholder:"Type to search...",onFocus:()=>R(!0),onBlur:()=>R(!1),helperText:E&&!C&&M&&x.length===0?"No matches found":void 0,InputProps:{...H.InputProps,endAdornment:n.jsxs(n.Fragment,{children:[C?n.jsx(o.CircularProgress,{color:"inherit",size:20}):null,H.InputProps.endAdornment]})}}),freeSolo:!0,filterOptions:H=>H,slotProps:{paper:{sx:{"& .MuiAutocomplete-option":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}}}),e.filterType==="MinMax"&&!N&&n.jsx(o.TextField,{size:"small",type:"number",label:"Value",value:p,onChange:H=>Z(parseFloat(H.target.value)||""),onFocus:()=>A(!0),onBlur:()=>A(!1),placeholder:"Enter number...",fullWidth:!0,inputProps:{min:ne,max:J},helperText:K&&ne!==void 0&&J!==void 0?`Valid range: [${ne} - ${J}]`:void 0}),e.filterType==="MinMax"&&N&&n.jsxs(Ae,{sx:{display:"flex",flexDirection:"column",gap:1},children:[n.jsxs(Ae,{sx:{display:"flex",gap:1,alignItems:"center"},children:[n.jsx(o.TextField,{size:"small",type:"number",label:"From",value:p,onChange:H=>Z(parseFloat(H.target.value)||"",g),onFocus:()=>A(!0),onBlur:()=>A(!1),placeholder:"Min...",fullWidth:!0,inputProps:{min:ne,max:g||J}}),n.jsx(Ae,{children:"to"}),n.jsx(o.TextField,{size:"small",type:"number",label:"To",value:g,onChange:H=>Z(p,parseFloat(H.target.value)||""),onFocus:()=>A(!0),onBlur:()=>A(!1),placeholder:"Max...",fullWidth:!0,inputProps:{min:p||ne,max:J}})]}),K&&ne!==void 0&&J!==void 0&&n.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:-.5,ml:1.5},children:["Valid range: [",ne," - ",J,"]"]})]}),V&&!N&&n.jsx(o.LocalizationProvider,{dateAdapter:o.AdapterDayjs,children:n.jsx(o.DatePicker,{label:"Date",value:p instanceof Date?o.dayjs.utc(p):null,onChange:H=>{H===null?Z(null):H.isValid()&&Z(H.utc().toDate())},timezone:"UTC",minDate:p instanceof Date?void 0:W,maxDate:p instanceof Date?void 0:X,referenceDate:l==="After"&&W?W:void 0,slotProps:{textField:{size:"small",fullWidth:!0,sx:{minWidth:150},onFocus:()=>A(!0),onBlur:()=>A(!1),helperText:K&&W&&X?`Valid range: [${W.format("YYYY-MM-DD")} - ${X.format("YYYY-MM-DD")}]`:void 0},openPickerButton:{sx:{backgroundColor:"transparent"}}}})}),V&&N&&n.jsx(o.LocalizationProvider,{dateAdapter:o.AdapterDayjs,children:n.jsxs(Ae,{sx:{display:"flex",flexDirection:"column",gap:1},children:[n.jsxs(Ae,{sx:{display:"flex",gap:1,alignItems:"center"},children:[n.jsx(Ae,{sx:{flex:1,minWidth:0},children:n.jsx(o.DatePicker,{label:"From",value:p instanceof Date?o.dayjs.utc(p):null,onChange:H=>{H===null?Z(null,g):H.isValid()&&Z(H.utc().toDate(),g)},timezone:"UTC",minDate:p instanceof Date?void 0:W,maxDate:g instanceof Date?o.dayjs.utc(g):p instanceof Date?void 0:X,referenceDate:W,slotProps:{textField:{size:"small",fullWidth:!0,onFocus:()=>A(!0),onBlur:()=>A(!1)},openPickerButton:{sx:{backgroundColor:"transparent"}}}})}),n.jsx(Ae,{children:"to"}),n.jsx(Ae,{sx:{flex:1,minWidth:0},children:n.jsx(o.DatePicker,{label:"To",value:g instanceof Date?o.dayjs.utc(g):null,onChange:H=>{H===null?Z(p,null):H.isValid()&&Z(p,H.utc().toDate())},timezone:"UTC",minDate:p instanceof Date?o.dayjs.utc(p):g instanceof Date?void 0:W,maxDate:g instanceof Date?void 0:X,referenceDate:p instanceof Date?o.dayjs.utc(p):W,slotProps:{textField:{size:"small",fullWidth:!0,onFocus:()=>A(!0),onBlur:()=>A(!1)},openPickerButton:{sx:{backgroundColor:"transparent"}}}})})]}),K&&W&&X&&n.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{mt:-.5,ml:1.5},children:["Valid range: [",W.format("YYYY-MM-DD")," -"," ",X.format("YYYY-MM-DD"),"]"]})]})})]})}function Pc(e){const r=new Set,u=e.schema?.fields;if(!u)return r;for(const s of u)"kind"in s&&s.kind==="join"&&s.name&&r.add(s.name);return r}function Lc(e){if(!e)return null;for(const r of e)if(r.startsWith("##(filters)")){const u=r.slice(11).trim();try{const s=JSON.parse(u);if(Array.isArray(s)){const d=[];for(const c of s)if(typeof c=="string"){const l=c.indexOf(".");l>0&&l<c.length-1&&d.push({source:c.substring(0,l),dimension:c.substring(l+1)})}if(d.length>0)return{filters:d}}}catch(s){console.error(`Failed to parse "${r}" annotation:`,s)}}return null}function ea(e){if(e.startsWith("#(filter)")){const r=e.slice(9).trim();try{const u=JSON.parse(r);if(u.type)return u}catch(u){console.error(`Failed to parse "${e}" annotation:`,u)}}return null}function _c(e){const r=e.match(/^#\s*label\s*=\s*"([^"]+)"/);return r?r[1]:null}function Wc(e){const r=new Map;let u="";for(const s of e)if(s.type==="code"){if(!u&&s.text){const c=s.text.split(`
|
|
2
|
+
`).map(l=>l.trim()).find(l=>l.startsWith("import "))?.match(/['"]([^'"\n]+)['"]/);c&&(u=c[1])}if(s.newSources&&s.newSources.length>0)for(const d of s.newSources)try{const c=JSON.parse(d);c.name&&r.set(c.name,c)}catch(c){console.error("Failed to parse SourceInfo:",c)}}return{sourceInfoMap:r,modelPath:u}}function qc(e,r,u){const s=[];for(const{source:d,dimension:c}of r){const l=e.get(d);if(!l){console.warn(`Source "${d}" not found in notebook sources`),s.push({source:d,model:u,dimensionName:c,filterType:"Star"});continue}const m=l.schema?.fields;if(!m){s.push({source:d,model:u,dimensionName:c,filterType:"Star"});continue}const p=m.find(v=>v.name===c);if(!p){console.warn(`Dimension "${c}" not found in source "${d}"`),s.push({source:d,model:u,dimensionName:c,filterType:"Star"});continue}let h="Star",g;if("annotations"in p&&p.annotations){for(const v of p.annotations)if(v.value){const x=ea(v.value);x&&(h=x.type);const y=_c(v.value);y&&(g=y)}}s.push({source:d,model:u,dimensionName:c,filterType:h,label:g})}return s}function zc(e,r,u){return e.length===0?"":e.map(d=>{const{dimensionName:c,source:l,matchType:m,value:p,value2:h}=d,v=l&&l!==u?`\`${l}\`.\`${c}\``:`\`${c}\``,x=p instanceof Date,y=(C,w=!1)=>C==null?"null":w&&C instanceof Date?`@${C.getFullYear()}-${String(C.getMonth()+1).padStart(2,"0")}-${String(C.getDate()).padStart(2,"0")}`:typeof C=="string"?`'${o.escapeMalloyString(C)}'`:typeof C=="boolean"?C?"true":"false":String(C);switch(m){case"Equals":case"Semantic Search":return Array.isArray(p)&&p.length>0?`(${p.map(w=>`${v} = ${y(w,x)}`).join(" or ")})`:`${v} = ${y(p,x)}`;case"Contains":return typeof p=="string"?`${v} ~ f'%${o.escapeMalloyString(p)}%'`:`${v} = ${y(p)}`;case"After":case"Greater Than":return`${v} > ${y(p,x)}`;case"Before":case"Less Than":return`${v} < ${y(p,x)}`;case"Between":return h!==void 0?`${v} >= ${y(p,x)} and ${v} <= ${y(h,x)}`:`${v} >= ${y(p,x)}`;default:return""}}).filter(d=>d.length>0).join(" and ")}function Hc(e){const r=e.match(/run\s*:\s*(\w+)\s*->/);if(r)return r[1];const u=e.match(/^\s*(\w+)\s*->/m);return u?u[1]:null}function Vc(e,r){return`${e.trimEnd()} + {where: ${r}}`}const Bc=o.createSvgIcon(n.jsx("path",{d:"m9.17 6 2 2H20v10H4V6zM10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"})),ta=e=>{if(!e)return"Explore semantic models, run queries, and build reports";const r=e.replace(/^#+\s+/gm,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/`([^`]+)`/g,"$1").trim(),s=r.split(/\n\s*\n/)[1]||r;if(s.length<=120)return s;const d=s.substring(0,120).split(" ");return d.pop(),d.join(" ")+"..."},na=(e,r)=>{const u=(e.readme||void 0)?.split(`
|
|
3
3
|
`)??[];return u.length===0&&(u.push(`# ${e.name}`),u.push("")),(e.readme?.length??0)>0&&r?u.splice(2,1,r):r&&u.push(r),u.join(`
|
|
4
|
-
`)};function bo(){const[e,r]=I.useState(!1),{apiClients:u}=B.useServer(),s=()=>{r(!0)},d=()=>{r(!1)},c=wn({mutationFn(m){return u.environments.createEnvironment({name:m.name,readme:ta({name:m.name,readme:""},m.description)})},success:"Environment created",invalidates:[["environments"]],closeDialog:d,resource:"environment",action:"create"}),l=async m=>{m.preventDefault();const p=new FormData(m.currentTarget),h=p.get("name")?.toString(),g=p.get("description")?.toString();if(!h)throw new Error("Name is required");c.mutate({name:h,description:g})};return n.jsxs(I.Fragment,{children:[n.jsx(o.AddButton,{label:"Environment",onClick:s}),n.jsx(o.AppDialog,{open:e,onClose:d,title:"New environment",description:"An environment holds packages and the connections they query through.",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:c.isPending,onClick:d,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"environment-form",variant:"contained",loading:c.isPending,children:"Create environment"})]}),children:n.jsx("form",{onSubmit:l,id:"environment-form",children:n.jsxs(Cr,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),n.jsx(o.TextField,{id:"description",name:"description",label:"Description",placeholder:"Explore semantic models, run queries, and build reports",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}})]})})}),c.notice]})}function Uc({environment:e,onCloseDialog:r}){const[u,s]=I.useState(!1),{apiClients:d}=B.useServer(),c=()=>{s(!0)},l=()=>{s(!1),r()},m=wn({mutationFn:()=>d.environments.deleteEnvironment(e.name),success:"Environment deleted",invalidates:[["environments"]],closeDialog:l,resource:"environment",action:"delete"});return n.jsxs(I.Fragment,{children:[n.jsxs(S.MenuItem,{onClick:c,children:[n.jsx(S.ListItemIcon,{children:n.jsx(wt.Delete,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Delete"})]}),n.jsx(o.AppDialog,{open:u,onClose:l,title:"Delete environment",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{onClick:l,children:"Cancel"}),n.jsx(o.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>m.mutate(),loading:m.isPending,children:"Delete environment"})]}),children:n.jsxs(o.Typography,{variant:"body2",children:["Delete ",n.jsx("strong",{children:e.name}),"? Its packages stop being served and this cannot be undone."]})}),m.notice]})}function Gc({environment:e,onCloseDialog:r}){const[u,s]=I.useState(!1),{apiClients:d}=B.useServer(),c=()=>{s(!0)},l=()=>{s(!1),r()},m=wn({mutationFn(h){return d.environments.updateEnvironment(e.name,{name:e.name,readme:ta({name:e.name,readme:e.readme},h.description)})},success:"Environment updated",invalidates:[["environments"]],closeDialog:l,resource:"environment",action:"update"}),p=h=>{h.preventDefault();const v=new FormData(h.currentTarget).get("description")?.toString();m.mutate({description:v})};return n.jsxs(I.Fragment,{children:[n.jsxs(S.MenuItem,{onClick:c,children:[n.jsx(S.ListItemIcon,{children:n.jsx(wt.Edit,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Edit"})]}),n.jsx(o.AppDialog,{open:u,onClose:l,title:"Edit environment",description:"What this environment is, for the people who open it.",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:m.isPending,onClick:l,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"environment-form",variant:"contained",loading:m.isPending,children:"Save changes"})]}),children:n.jsx("form",{onSubmit:p,id:"environment-form",children:n.jsxs(Cr,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",disabled:!0,type:"text",fullWidth:!0,size:"small",defaultValue:e.name,InputLabelProps:{shrink:!0}}),n.jsx(o.TextField,{id:"description",name:"description",label:"Description",type:"text",fullWidth:!0,size:"small",defaultValue:ea(e.readme),InputLabelProps:{shrink:!0}})]})})}),m.notice]})}const Yc=[{title:"Model",body:"An agent writes what the data means in Malloy — sources, joins, measures — from a warehouse or a file, and validates each edit without a restart.",href:$t.publishing},{title:"Analyze",body:"Claude, Cursor, Codex or an agent you build asks over MCP; applications and BI tools use REST. Every question runs against the model, never the raw tables.",href:$t.mcpAgents},{title:"Surface",body:"Reports declared in Malloy, laid out as a grid or read top to bottom, and no-build HTML data apps, all shipped inside the package, plus this Console for browsing them.",href:$t.surfaces},{title:"Govern",body:"Runtime parameters, row-level filters and per-source gates are declared in the model, so every surface reads the same rules rather than writing its own.",href:$t.givens},{title:"Optimize",body:"One annotation materializes an expensive source into a table, and another rolls a measure up to a coarser grain, rebuilt on demand or on a schedule.",href:$t.materialization},{title:"Run anywhere",body:"DuckDB is built in for CSV, Parquet, JSON and Excel; BigQuery, Snowflake, Postgres, Databricks, MotherDuck and more connect by configuration.",href:$t.connections}];function Zc({href:e,children:r}){return n.jsx(S.Box,{component:"a",href:e,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary",textDecoration:"underline"},children:r})}function Kc({onClickEnvironment:e}){const{apiClients:r,mutable:u}=B.useServer(),{data:s,isSuccess:d,isError:c,error:l}=o.useQueryWithApiError({queryKey:["environments"],queryFn:()=>r.environments.listEnvironments()});if(c)return n.jsx(o.ApiErrorDisplay,{error:l,context:"Environments List"});if(!d)return n.jsx(o.Loading,{text:"Loading environments..."});const m=s.data??[];return n.jsxs(S.Container,{maxWidth:"md",sx:{py:6},children:[n.jsxs(S.Box,{sx:{mb:5},children:[n.jsx(S.Typography,{variant:"h3",component:"h1",sx:{fontWeight:500,letterSpacing:"-0.025em",mb:1},children:"Publisher"}),n.jsx(S.Typography,{variant:"body1",color:"text.secondary",sx:{mb:3},children:"The analytics engine for Malloy."}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{maxWidth:720,lineHeight:1.6},children:"One data model, served over MCP and REST to AI agents, applications and BI tools. Write down what your data means — the sources, the joins, the measures, who may see what — and every surface asks the same model, so the same question returns the same numbers tomorrow."})]}),n.jsx(S.Grid,{container:!0,spacing:4,sx:{mb:5},children:Yc.map(p=>n.jsx(S.Grid,{size:{xs:12,sm:6},children:n.jsxs(S.Stack,{spacing:1,children:[n.jsx(S.Typography,{variant:"body2",component:"a",href:p.href,target:"_blank",rel:"noopener noreferrer",sx:{fontWeight:500,color:"text.primary",textDecoration:"none","&:hover":{textDecoration:"underline"}},children:p.title}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{lineHeight:1.6},children:p.body})]})},p.title))}),n.jsx(S.Divider,{sx:{my:4}}),m.length>0?n.jsx(It,{title:"Environments",count:m.length,description:"Published environments available on this server",...u?{action:n.jsx(bo,{})}:{},children:n.jsx(S.Stack,{children:m.map(p=>n.jsx(Xc,{environment:p,...e?{onClickEnvironment:e}:{}},p.name))})}):n.jsxs(S.Box,{sx:{mb:4},children:[n.jsx(S.Typography,{variant:"h5",sx:{fontWeight:500,letterSpacing:"-0.025em",mb:1},children:"Get started"}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{mb:3,maxWidth:600},children:"Create your first Malloy environment to start exploring semantic models and building data experiences."}),u?n.jsx(bo,{}):n.jsx(S.Button,{variant:"contained",color:"primary",href:$t.publishing,target:"_blank",rel:"noopener noreferrer",children:"Learn how to create models"})]}),n.jsx(S.Divider,{sx:{my:4}}),n.jsxs(S.Typography,{variant:"body2",color:"text.secondary",sx:{maxWidth:720,lineHeight:1.6,mt:2},children:["Join the"," ",n.jsx(Zc,{href:"https://join.slack.com/t/malloy-community/shared_invite/zt-1kgfwgi5g-CrsdaRqs81QY67QW0~t_uw",children:"Malloy Slack community"})," ","to ask questions, share ideas, and contribute."]})]})}function Xc({environment:e,onClickEnvironment:r}){const{mutable:u}=B.useServer(),[s,d]=I.useState(null),c=!!s,l=ea(e.readme),m=h=>{h.stopPropagation(),d(h.currentTarget)},p=()=>d(null);return n.jsx(wr,{icon:n.jsx(Bc,{sx:{fontSize:18}}),tint:B.SURFACE_TINT.environment,label:e.name??"",ariaLabel:e.name??"",...l?{description:l}:{},...e.name&&r?{onClick:h=>r(`/${e.name}/`,h)}:{},...u?{trailingAction:n.jsxs(n.Fragment,{children:[n.jsx(S.IconButton,{size:"small",onClick:m,"aria-label":`Environment actions for ${e.name}`,children:n.jsx(wt.MoreVert,{fontSize:"small"})}),n.jsxs(S.Menu,{anchorEl:s,open:c,onClose:p,onClick:h=>h.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[n.jsx(Gc,{environment:e,onCloseDialog:p}),n.jsx(Uc,{environment:e,onCloseDialog:p})]})]})}:{}})}var Kt={},it={},_n={},Xt={},_r={},vo;function Qc(){return vo||(vo=1,Object.defineProperty(_r,"__esModule",{value:!0})),_r}var Wn={},qn={},So;function tn(){if(So)return qn;So=1,Object.defineProperty(qn,"__esModule",{value:!0}),qn.CronField=void 0;let e=class na{#e=!1;#n=!1;#o=!1;#s=[];options={rawValue:""};static get min(){throw new Error("min must be overridden")}static get max(){throw new Error("max must be overridden")}static get chars(){return Object.freeze([])}static get validChars(){return/^[?,*\dH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}static get constraints(){return{min:this.min,max:this.max,chars:this.chars,validChars:this.validChars}}constructor(u,s={rawValue:""}){if(!Array.isArray(u))throw new Error(`${this.constructor.name} Validation error, values is not an array`);if(!(u.length>0))throw new Error(`${this.constructor.name} Validation error, values contains no values`);this.options={...s,rawValue:s.rawValue??""},this.#s=u.sort(na.sorter),this.#o=this.options.wildcard!==void 0?this.options.wildcard:this.#r(),this.#e=this.options.rawValue.includes("L")||u.includes("L"),this.#n=this.options.rawValue.includes("?")||u.includes("?")}get min(){return this.constructor.min}get max(){return this.constructor.max}get chars(){return this.constructor.chars}get hasLastChar(){return this.#e}get hasQuestionMarkChar(){return this.#n}get isWildcard(){return this.#o}get values(){return this.#s}static sorter(u,s){const d=typeof u=="number",c=typeof s=="number";return d&&c?u-s:!d&&!c?u.localeCompare(s):d?-1:1}static findNearestValueInList(u,s,d){if(d){for(let c=u.length-1;c>=0;c--)if(u[c]<s)return u[c];return null}for(let c=0;c<u.length;c++)if(u[c]>s)return u[c];return null}findNearestValue(u,s){return this.constructor.findNearestValueInList(this.values,u,s)}serialize(){return{wildcard:this.#o,values:this.#s}}validate(){let u;const s=this.chars.length>0?` or chars ${this.chars.join("")}`:"",d=p=>h=>new RegExp(`^\\d{0,2}${h}$`).test(p),c=p=>(u=p,typeof p=="number"?p>=this.min&&p<=this.max:this.chars.some(d(p)));if(!this.#s.every(c))throw new Error(`${this.constructor.name} Validation error, got value ${u} expected range ${this.min}-${this.max}${s}`);const m=this.#s.find((p,h)=>this.#s.indexOf(p)!==h);if(m)throw new Error(`${this.constructor.name} Validation error, duplicate values found: ${m}`)}#r(){return this.options.rawValue.length>0?["*","?"].includes(this.options.rawValue):Array.from({length:this.max-this.min+1},(u,s)=>s+this.min).every(u=>this.#s.includes(u))}};return qn.CronField=e,qn}var wo;function Jc(){if(wo)return Wn;wo=1,Object.defineProperty(Wn,"__esModule",{value:!0}),Wn.CronDayOfMonth=void 0;const e=tn(),r=1,u=31,s=Object.freeze(["L"]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}static get validChars(){return/^[?,*\dLH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}};return Wn.CronDayOfMonth=d,Wn}var zn={},Co;function eu(){if(Co)return zn;Co=1,Object.defineProperty(zn,"__esModule",{value:!0}),zn.CronDayOfWeek=void 0;const e=tn(),r=0,u=7,s=Object.freeze(["L"]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}static get validChars(){return/^[?,*\dLH#/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}get nthDay(){return this.options.nthDayOfWeek??0}};return zn.CronDayOfWeek=d,zn}var Hn={},ko;function tu(){if(ko)return Hn;ko=1,Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.CronHour=void 0;const e=tn(),r=0,u=23,s=Object.freeze([]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}};return Hn.CronHour=d,Hn}var Vn={},To;function nu(){if(To)return Vn;To=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.CronMinute=void 0;const e=tn(),r=0,u=59,s=Object.freeze([]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}};return Vn.CronMinute=d,Vn}var Bn={},Wr={},rt={},Oo;function ru(){if(Oo)return rt;Oo=1,Object.defineProperty(rt,"__esModule",{value:!0});class e extends Error{}class r extends e{constructor(t){super(`Invalid DateTime: ${t.toMessage()}`)}}class u extends e{constructor(t){super(`Invalid Interval: ${t.toMessage()}`)}}class s extends e{constructor(t){super(`Invalid Duration: ${t.toMessage()}`)}}class d extends e{}class c extends e{constructor(t){super(`Invalid unit ${t}`)}}class l extends e{}class m extends e{constructor(){super("Zone is an abstract class")}}const p="numeric",h="short",g="long",v={year:p,month:p,day:p},x={year:p,month:h,day:p},y={year:p,month:h,day:p,weekday:h},C={year:p,month:g,day:p},w={year:p,month:g,day:p,weekday:g},k={hour:p,minute:p},O={hour:p,minute:p,second:p},M={hour:p,minute:p,second:p,timeZoneName:h},j={hour:p,minute:p,second:p,timeZoneName:g},E={hour:p,minute:p,hourCycle:"h23"},$={hour:p,minute:p,second:p,hourCycle:"h23"},U={hour:p,minute:p,second:p,hourCycle:"h23",timeZoneName:h},P={hour:p,minute:p,second:p,hourCycle:"h23",timeZoneName:g},K={year:p,month:p,day:p,hour:p,minute:p},A={year:p,month:p,day:p,hour:p,minute:p,second:p},L={year:p,month:h,day:p,hour:p,minute:p},V={year:p,month:h,day:p,hour:p,minute:p,second:p},N={year:p,month:h,day:p,weekday:h,hour:p,minute:p},_={year:p,month:g,day:p,hour:p,minute:p,timeZoneName:h},Q={year:p,month:g,day:p,hour:p,minute:p,second:p,timeZoneName:h},re={year:p,month:g,day:p,weekday:g,hour:p,minute:p,timeZoneName:g},ee={year:p,month:g,day:p,weekday:g,hour:p,minute:p,second:p,timeZoneName:g};class te{get type(){throw new m}get name(){throw new m}get ianaName(){return this.name}get isUniversal(){throw new m}offsetName(t,a){throw new m}formatOffset(t,a){throw new m}offset(t){throw new m}equals(t){throw new m}get isValid(){throw new m}}let Z=null;class ae extends te{static get instance(){return Z===null&&(Z=new ae),Z}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(t,{format:a,locale:f}){return ms(t,a,f)}formatOffset(t,a){return jn(this.offset(t),a)}offset(t){return-new Date(t).getTimezoneOffset()}equals(t){return t.type==="system"}get isValid(){return!0}}const H=new Map;function J(i){let t=H.get(i);return t===void 0&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),H.set(i,t)),t}const se={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function xe(i,t){const a=i.format(t).replace(/\u200E/g,""),f=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(a),[,b,T,D,F,R,G,ue]=f;return[D,b,T,F,R,G,ue]}function $e(i,t){const a=i.formatToParts(t),f=[];for(let b=0;b<a.length;b++){const{type:T,value:D}=a[b],F=se[T];T==="era"?f[F]=D:Y(F)||(f[F]=parseInt(D,10))}return f}const oe=new Map;class le extends te{static create(t){let a=oe.get(t);return a===void 0&&oe.set(t,a=new le(t)),a}static resetCache(){oe.clear(),H.clear()}static isValidSpecifier(t){return this.isValidZone(t)}static isValidZone(t){if(!t)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=le.isValidZone(t)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(t,{format:a,locale:f}){return ms(t,a,f,this.name)}formatOffset(t,a){return jn(this.offset(t),a)}offset(t){if(!this.valid)return NaN;const a=new Date(t);if(isNaN(a))return NaN;const f=J(this.name);let[b,T,D,F,R,G,ue]=f.formatToParts?$e(f,a):xe(f,a);F==="BC"&&(b=-Math.abs(b)+1);const De=or({year:b,month:T,day:D,hour:R===24?0:R,minute:G,second:ue,millisecond:0});let fe=+a;const Be=fe%1e3;return fe-=Be>=0?Be:1e3+Be,(De-fe)/(60*1e3)}equals(t){return t.type==="iana"&&t.name===this.name}get isValid(){return this.valid}}let Ne={};function q(i,t={}){const a=JSON.stringify([i,t]);let f=Ne[a];return f||(f=new Intl.ListFormat(i,t),Ne[a]=f),f}const X=new Map;function ge(i,t={}){const a=JSON.stringify([i,t]);let f=X.get(a);return f===void 0&&(f=new Intl.DateTimeFormat(i,t),X.set(a,f)),f}const Se=new Map;function Ee(i,t={}){const a=JSON.stringify([i,t]);let f=Se.get(a);return f===void 0&&(f=new Intl.NumberFormat(i,t),Se.set(a,f)),f}const we=new Map;function Te(i,t={}){const{base:a,...f}=t,b=JSON.stringify([i,f]);let T=we.get(b);return T===void 0&&(T=new Intl.RelativeTimeFormat(i,t),we.set(b,T)),T}let Re=null;function Fe(){return Re||(Re=new Intl.DateTimeFormat().resolvedOptions().locale,Re)}const Ye=new Map;function ie(i){let t=Ye.get(i);return t===void 0&&(t=new Intl.DateTimeFormat(i).resolvedOptions(),Ye.set(i,t)),t}const Qe=new Map;function ye(i){let t=Qe.get(i);if(!t){const a=new Intl.Locale(i);t="getWeekInfo"in a?a.getWeekInfo():a.weekInfo,"minimalDays"in t||(t={...Ge,...t}),Qe.set(i,t)}return t}function We(i){const t=i.indexOf("-x-");t!==-1&&(i=i.substring(0,t));const a=i.indexOf("-u-");if(a===-1)return[i];{let f,b;try{f=ge(i).resolvedOptions(),b=i}catch{const R=i.substring(0,a);f=ge(R).resolvedOptions(),b=R}const{numberingSystem:T,calendar:D}=f;return[b,T,D]}}function ct(i,t,a){return(a||t)&&(i.includes("-u-")||(i+="-u"),a&&(i+=`-ca-${a}`),t&&(i+=`-nu-${t}`)),i}function Nt(i){const t=[];for(let a=1;a<=12;a++){const f=me.utc(2009,a,1);t.push(i(f))}return t}function gt(i){const t=[];for(let a=1;a<=7;a++){const f=me.utc(2016,11,13+a);t.push(i(f))}return t}function Ze(i,t,a,f){const b=i.listingMode();return b==="error"?null:b==="en"?a(t):f(t)}function ut(i){return i.numberingSystem&&i.numberingSystem!=="latn"?!1:i.numberingSystem==="latn"||!i.locale||i.locale.startsWith("en")||ie(i.locale).numberingSystem==="latn"}class pe{constructor(t,a,f){this.padTo=f.padTo||0,this.floor=f.floor||!1;const{padTo:b,floor:T,...D}=f;if(!a||Object.keys(D).length>0){const F={useGrouping:!1,...f};f.padTo>0&&(F.minimumIntegerDigits=f.padTo),this.inf=Ee(t,F)}}format(t){if(this.inf){const a=this.floor?Math.floor(t):t;return this.inf.format(a)}else{const a=this.floor?Math.floor(t):Tr(t,3);return Ve(a,this.padTo)}}}class st{constructor(t,a,f){this.opts=f,this.originalZone=void 0;let b;if(this.opts.timeZone)this.dt=t;else if(t.zone.type==="fixed"){const D=-1*(t.offset/60),F=D>=0?`Etc/GMT+${D}`:`Etc/GMT${D}`;t.offset!==0&&le.create(F).valid?(b=F,this.dt=t):(b="UTC",this.dt=t.offset===0?t:t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone)}else t.zone.type==="system"?this.dt=t:t.zone.type==="iana"?(this.dt=t,b=t.zone.name):(b="UTC",this.dt=t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone);const T={...this.opts};T.timeZone=T.timeZone||b,this.dtf=ge(a,T)}format(){return this.originalZone?this.formatToParts().map(({value:t})=>t).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const t=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?t.map(a=>{if(a.type==="timeZoneName"){const f=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...a,value:f}}else return a}):t}resolvedOptions(){return this.dtf.resolvedOptions()}}class nn{constructor(t,a,f){this.opts={style:"long",...f},!a&&kn()&&(this.rtf=Te(t,f))}format(t,a){return this.rtf?this.rtf.format(t,a):Ha(a,t,this.opts.numeric,this.opts.style!=="long")}formatToParts(t,a){return this.rtf?this.rtf.formatToParts(t,a):[]}}const Ge={firstDay:1,minimalDays:4,weekend:[6,7]};class ce{static fromOpts(t){return ce.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,a,f,b,T=!1){const D=t||Me.defaultLocale,F=D||(T?"en-US":Fe()),R=a||Me.defaultNumberingSystem,G=f||Me.defaultOutputCalendar,ue=At(b)||Me.defaultWeekSettings;return new ce(F,R,G,ue,D)}static resetCache(){Re=null,X.clear(),Se.clear(),we.clear(),Ye.clear(),Qe.clear()}static fromObject({locale:t,numberingSystem:a,outputCalendar:f,weekSettings:b}={}){return ce.create(t,a,f,b)}constructor(t,a,f,b,T){const[D,F,R]=We(t);this.locale=D,this.numberingSystem=a||F||null,this.outputCalendar=f||R||null,this.weekSettings=b,this.intl=ct(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=T,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=ut(this)),this.fastNumbersCached}listingMode(){const t=this.isEnglish(),a=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return t&&a?"en":"intl"}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:ce.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,At(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(t={}){return this.clone({...t,defaultToEN:!0})}redefaultToSystem(t={}){return this.clone({...t,defaultToEN:!1})}months(t,a=!1){return Ze(this,t,xs,()=>{const f=this.intl==="ja"||this.intl.startsWith("ja-");a&=!f;const b=a?{month:t,day:"numeric"}:{month:t},T=a?"format":"standalone";if(!this.monthsCache[T][t]){const D=f?F=>this.dtFormatter(F,b).format():F=>this.extract(F,b,"month");this.monthsCache[T][t]=Nt(D)}return this.monthsCache[T][t]})}weekdays(t,a=!1){return Ze(this,t,Ss,()=>{const f=a?{weekday:t,year:"numeric",month:"long",day:"numeric"}:{weekday:t},b=a?"format":"standalone";return this.weekdaysCache[b][t]||(this.weekdaysCache[b][t]=gt(T=>this.extract(T,f,"weekday"))),this.weekdaysCache[b][t]})}meridiems(){return Ze(this,void 0,()=>ws,()=>{if(!this.meridiemCache){const t={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[me.utc(2016,11,13,9),me.utc(2016,11,13,19)].map(a=>this.extract(a,t,"dayperiod"))}return this.meridiemCache})}eras(t){return Ze(this,t,Cs,()=>{const a={era:t};return this.eraCache[t]||(this.eraCache[t]=[me.utc(-40,1,1),me.utc(2017,1,1)].map(f=>this.extract(f,a,"era"))),this.eraCache[t]})}extract(t,a,f){const b=this.dtFormatter(t,a),T=b.formatToParts(),D=T.find(F=>F.type.toLowerCase()===f);return D?D.value:null}numberFormatter(t={}){return new pe(this.intl,t.forceSimple||this.fastNumbers,t)}dtFormatter(t,a={}){return new st(t,this.intl,a)}relFormatter(t={}){return new nn(this.intl,this.isEnglish(),t)}listFormatter(t={}){return q(this.intl,t)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||ie(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Tn()?ye(this.locale):Ge}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(t){return this.locale===t.locale&&this.numberingSystem===t.numberingSystem&&this.outputCalendar===t.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Je=null;class qe extends te{static get utcInstance(){return Je===null&&(Je=new qe(0)),Je}static instance(t){return t===0?qe.utcInstance:new qe(t)}static parseSpecifier(t){if(t){const a=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(a)return new qe(ar(a[1],a[2]))}return null}constructor(t){super(),this.fixed=t}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${jn(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${jn(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(t,a){return jn(this.fixed,a)}get isUniversal(){return!0}offset(){return this.fixed}equals(t){return t.type==="fixed"&&t.fixed===this.fixed}get isValid(){return!0}}class tt extends te{constructor(t){super(),this.zoneName=t}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function dt(i,t){if(Y(i)||i===null)return t;if(i instanceof te)return i;if(at(i)){const a=i.toLowerCase();return a==="default"?t:a==="local"||a==="system"?ae.instance:a==="utc"||a==="gmt"?qe.utcInstance:qe.parseSpecifier(a)||le.create(i)}else return je(i)?qe.instance(i):typeof i=="object"&&"offset"in i&&typeof i.offset=="function"?i:new tt(i)}const ot={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},nt={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},rn=ot.hanidec.replace(/[\[|\]]/g,"").split("");function Cn(i){let t=parseInt(i,10);if(isNaN(t)){t="";for(let a=0;a<i.length;a++){const f=i.charCodeAt(a);if(i[a].search(ot.hanidec)!==-1)t+=rn.indexOf(i[a]);else for(const b in nt){const[T,D]=nt[b];f>=T&&f<=D&&(t+=f-T)}}return parseInt(t,10)}else return t}const Ft=new Map;function Ct(){Ft.clear()}function ze({numberingSystem:i},t=""){const a=i||"latn";let f=Ft.get(a);f===void 0&&(f=new Map,Ft.set(a,f));let b=f.get(t);return b===void 0&&(b=new RegExp(`${ot[a]}${t}`),f.set(t,b)),b}let kt=()=>Date.now(),ht="system",ft=null,yt=null,sn=null,Tt=60,Ht,on=null;class Me{static get now(){return kt}static set now(t){kt=t}static set defaultZone(t){ht=t}static get defaultZone(){return dt(ht,ae.instance)}static get defaultLocale(){return ft}static set defaultLocale(t){ft=t}static get defaultNumberingSystem(){return yt}static set defaultNumberingSystem(t){yt=t}static get defaultOutputCalendar(){return sn}static set defaultOutputCalendar(t){sn=t}static get defaultWeekSettings(){return on}static set defaultWeekSettings(t){on=At(t)}static get twoDigitCutoffYear(){return Tt}static set twoDigitCutoffYear(t){Tt=t%100}static get throwOnInvalid(){return Ht}static set throwOnInvalid(t){Ht=t}static resetCaches(){ce.resetCache(),le.resetCache(),me.resetCache(),Ct()}}class Ue{constructor(t,a){this.reason=t,this.explanation=a}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const _t=[0,31,59,90,120,151,181,212,243,273,304,334],an=[0,31,60,91,121,152,182,213,244,274,305,335];function Ke(i,t){return new Ue("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${i}, which is invalid`)}function Vt(i,t,a){const f=new Date(Date.UTC(i,t-1,a));i<100&&i>=0&&f.setUTCFullYear(f.getUTCFullYear()-1900);const b=f.getUTCDay();return b===0?7:b}function ln(i,t,a){return a+(On(i)?an:_t)[t-1]}function Wt(i,t){const a=On(i)?an:_t,f=a.findIndex(T=>T<t),b=t-a[f];return{month:f+1,day:b}}function Pe(i,t){return(i-t+7)%7+1}function Le(i,t=4,a=1){const{year:f,month:b,day:T}=i,D=ln(f,b,T),F=Pe(Vt(f,b,T),a);let R=Math.floor((D-F+14-t)/7),G;return R<1?(G=f-1,R=Mn(G,t,a)):R>Mn(f,t,a)?(G=f+1,R=1):G=f,{weekYear:G,weekNumber:R,weekday:F,...lr(i)}}function xt(i,t=4,a=1){const{weekYear:f,weekNumber:b,weekday:T}=i,D=Pe(Vt(f,1,t),a),F=un(f);let R=b*7+T-D-7+t,G;R<1?(G=f-1,R+=un(G)):R>F?(G=f+1,R-=un(f)):G=f;const{month:ue,day:be}=Wt(G,R);return{year:G,month:ue,day:be,...lr(i)}}function Bt(i){const{year:t,month:a,day:f}=i,b=ln(t,a,f);return{year:t,ordinal:b,...lr(i)}}function qt(i){const{year:t,ordinal:a}=i,{month:f,day:b}=Wt(t,a);return{year:t,month:f,day:b,...lr(i)}}function Ut(i,t){if(!Y(i.localWeekday)||!Y(i.localWeekNumber)||!Y(i.localWeekYear)){if(!Y(i.weekday)||!Y(i.weekNumber)||!Y(i.weekYear))throw new d("Cannot mix locale-based week fields with ISO-based week fields");return Y(i.localWeekday)||(i.weekday=i.localWeekday),Y(i.localWeekNumber)||(i.weekNumber=i.localWeekNumber),Y(i.localWeekYear)||(i.weekYear=i.localWeekYear),delete i.localWeekday,delete i.localWeekNumber,delete i.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function z(i,t=4,a=1){const f=Ie(i.weekYear),b=pt(i.weekNumber,1,Mn(i.weekYear,t,a)),T=pt(i.weekday,1,7);return f?b?T?!1:Ke("weekday",i.weekday):Ke("week",i.weekNumber):Ke("weekYear",i.weekYear)}function W(i){const t=Ie(i.year),a=pt(i.ordinal,1,un(i.year));return t?a?!1:Ke("ordinal",i.ordinal):Ke("year",i.year)}function ne(i){const t=Ie(i.year),a=pt(i.month,1,12),f=pt(i.day,1,sr(i.year,i.month));return t?a?f?!1:Ke("day",i.day):Ke("month",i.month):Ke("year",i.year)}function de(i){const{hour:t,minute:a,second:f,millisecond:b}=i,T=pt(t,0,23)||t===24&&a===0&&f===0&&b===0,D=pt(a,0,59),F=pt(f,0,59),R=pt(b,0,999);return T?D?F?R?!1:Ke("millisecond",b):Ke("second",f):Ke("minute",a):Ke("hour",t)}function Y(i){return typeof i>"u"}function je(i){return typeof i=="number"}function Ie(i){return typeof i=="number"&&i%1===0}function at(i){return typeof i=="string"}function cn(i){return Object.prototype.toString.call(i)==="[object Date]"}function kn(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Tn(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function rr(i){return Array.isArray(i)?i:[i]}function Ce(i,t,a){if(i.length!==0)return i.reduce((f,b)=>{const T=[t(b),b];return f&&a(f[0],T[0])===f[0]?f:T},null)[1]}function Ot(i,t){return t.reduce((a,f)=>(a[f]=i[f],a),{})}function et(i,t){return Object.prototype.hasOwnProperty.call(i,t)}function At(i){if(i==null)return null;if(typeof i!="object")throw new l("Week settings must be an object");if(!pt(i.firstDay,1,7)||!pt(i.minimalDays,1,7)||!Array.isArray(i.weekend)||i.weekend.some(t=>!pt(t,1,7)))throw new l("Invalid week settings");return{firstDay:i.firstDay,minimalDays:i.minimalDays,weekend:Array.from(i.weekend)}}function pt(i,t,a){return Ie(i)&&i>=t&&i<=a}function Na(i,t){return i-t*Math.floor(i/t)}function Ve(i,t=2){const a=i<0;let f;return a?f="-"+(""+-i).padStart(t,"0"):f=(""+i).padStart(t,"0"),f}function zt(i){if(!(Y(i)||i===null||i===""))return parseInt(i,10)}function Gt(i){if(!(Y(i)||i===null||i===""))return parseFloat(i)}function kr(i){if(!(Y(i)||i===null||i==="")){const t=parseFloat("0."+i)*1e3;return Math.floor(t)}}function Tr(i,t,a="round"){const f=10**t;switch(a){case"expand":return i>0?Math.ceil(i*f)/f:Math.floor(i*f)/f;case"trunc":return Math.trunc(i*f)/f;case"round":return Math.round(i*f)/f;case"floor":return Math.floor(i*f)/f;case"ceil":return Math.ceil(i*f)/f;default:throw new RangeError(`Value rounding ${a} is out of range`)}}function On(i){return i%4===0&&(i%100!==0||i%400===0)}function un(i){return On(i)?366:365}function sr(i,t){const a=Na(t-1,12)+1,f=i+(t-a)/12;return a===2?On(f)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][a-1]}function or(i){let t=Date.UTC(i.year,i.month-1,i.day,i.hour,i.minute,i.second,i.millisecond);return i.year<100&&i.year>=0&&(t=new Date(t),t.setUTCFullYear(i.year,i.month-1,i.day)),+t}function ps(i,t,a){return-Pe(Vt(i,1,t),a)+t-1}function Mn(i,t=4,a=1){const f=ps(i,t,a),b=ps(i+1,t,a);return(un(i)-f+b)/7}function Or(i){return i>99?i:i>Me.twoDigitCutoffYear?1900+i:2e3+i}function ms(i,t,a,f=null){const b=new Date(i),T={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};f&&(T.timeZone=f);const D={timeZoneName:t,...T},F=new Intl.DateTimeFormat(a,D).formatToParts(b).find(R=>R.type.toLowerCase()==="timezonename");return F?F.value:null}function ar(i,t){let a=parseInt(i,10);Number.isNaN(a)&&(a=0);const f=parseInt(t,10)||0,b=a<0||Object.is(a,-0)?-f:f;return a*60+b}function gs(i){const t=Number(i);if(typeof i=="boolean"||i===""||!Number.isFinite(t))throw new l(`Invalid unit value ${i}`);return t}function ir(i,t){const a={};for(const f in i)if(et(i,f)){const b=i[f];if(b==null)continue;a[t(f)]=gs(b)}return a}function jn(i,t){const a=Math.trunc(Math.abs(i/60)),f=Math.trunc(Math.abs(i%60)),b=i>=0?"+":"-";switch(t){case"short":return`${b}${Ve(a,2)}:${Ve(f,2)}`;case"narrow":return`${b}${a}${f>0?`:${f}`:""}`;case"techie":return`${b}${Ve(a,2)}${Ve(f,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function lr(i){return Ot(i,["hour","minute","second","millisecond"])}const Fa=["January","February","March","April","May","June","July","August","September","October","November","December"],ys=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Aa=["J","F","M","A","M","J","J","A","S","O","N","D"];function xs(i){switch(i){case"narrow":return[...Aa];case"short":return[...ys];case"long":return[...Fa];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const bs=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],vs=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Ra=["M","T","W","T","F","S","S"];function Ss(i){switch(i){case"narrow":return[...Ra];case"short":return[...vs];case"long":return[...bs];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const ws=["AM","PM"],$a=["Before Christ","Anno Domini"],Pa=["BC","AD"],La=["B","A"];function Cs(i){switch(i){case"narrow":return[...La];case"short":return[...Pa];case"long":return[...$a];default:return null}}function _a(i){return ws[i.hour<12?0:1]}function Wa(i,t){return Ss(t)[i.weekday-1]}function qa(i,t){return xs(t)[i.month-1]}function za(i,t){return Cs(t)[i.year<0?0:1]}function Ha(i,t,a="always",f=!1){const b={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},T=["hours","minutes","seconds"].indexOf(i)===-1;if(a==="auto"&&T){const be=i==="days";switch(t){case 1:return be?"tomorrow":`next ${b[i][0]}`;case-1:return be?"yesterday":`last ${b[i][0]}`;case 0:return be?"today":`this ${b[i][0]}`}}const D=Object.is(t,-0)||t<0,F=Math.abs(t),R=F===1,G=b[i],ue=f?R?G[1]:G[2]||G[1]:R?b[i][0]:i;return D?`${F} ${ue} ago`:`in ${F} ${ue}`}function ks(i,t){let a="";for(const f of i)f.literal?a+=f.val:a+=t(f.val);return a}const Va={D:v,DD:x,DDD:C,DDDD:w,t:k,tt:O,ttt:M,tttt:j,T:E,TT:$,TTT:U,TTTT:P,f:K,ff:L,fff:_,ffff:re,F:A,FF:V,FFF:Q,FFFF:ee};class Xe{static create(t,a={}){return new Xe(t,a)}static parseFormat(t){let a=null,f="",b=!1;const T=[];for(let D=0;D<t.length;D++){const F=t.charAt(D);F==="'"?((f.length>0||b)&&T.push({literal:b||/^\s+$/.test(f),val:f===""?"'":f}),a=null,f="",b=!b):b||F===a?f+=F:(f.length>0&&T.push({literal:/^\s+$/.test(f),val:f}),f=F,a=F)}return f.length>0&&T.push({literal:b||/^\s+$/.test(f),val:f}),T}static macroTokenToFormatOpts(t){return Va[t]}constructor(t,a){this.opts=a,this.loc=t,this.systemLoc=null}formatWithSystemDefault(t,a){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(t,{...this.opts,...a}).format()}dtFormatter(t,a={}){return this.loc.dtFormatter(t,{...this.opts,...a})}formatDateTime(t,a){return this.dtFormatter(t,a).format()}formatDateTimeParts(t,a){return this.dtFormatter(t,a).formatToParts()}formatInterval(t,a){return this.dtFormatter(t.start,a).dtf.formatRange(t.start.toJSDate(),t.end.toJSDate())}resolvedOptions(t,a){return this.dtFormatter(t,a).resolvedOptions()}num(t,a=0,f=void 0){if(this.opts.forceSimple)return Ve(t,a);const b={...this.opts};return a>0&&(b.padTo=a),f&&(b.signDisplay=f),this.loc.numberFormatter(b).format(t)}formatDateTimeFromString(t,a){const f=this.loc.listingMode()==="en",b=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",T=(fe,Be)=>this.loc.extract(t,fe,Be),D=fe=>t.isOffsetFixed&&t.offset===0&&fe.allowZ?"Z":t.isValid?t.zone.formatOffset(t.ts,fe.format):"",F=()=>f?_a(t):T({hour:"numeric",hourCycle:"h12"},"dayperiod"),R=(fe,Be)=>f?qa(t,fe):T(Be?{month:fe}:{month:fe,day:"numeric"},"month"),G=(fe,Be)=>f?Wa(t,fe):T(Be?{weekday:fe}:{weekday:fe,month:"long",day:"numeric"},"weekday"),ue=fe=>{const Be=Xe.macroTokenToFormatOpts(fe);return Be?this.formatWithSystemDefault(t,Be):fe},be=fe=>f?za(t,fe):T({era:fe},"era"),De=fe=>{switch(fe){case"S":return this.num(t.millisecond);case"u":case"SSS":return this.num(t.millisecond,3);case"s":return this.num(t.second);case"ss":return this.num(t.second,2);case"uu":return this.num(Math.floor(t.millisecond/10),2);case"uuu":return this.num(Math.floor(t.millisecond/100));case"m":return this.num(t.minute);case"mm":return this.num(t.minute,2);case"h":return this.num(t.hour%12===0?12:t.hour%12);case"hh":return this.num(t.hour%12===0?12:t.hour%12,2);case"H":return this.num(t.hour);case"HH":return this.num(t.hour,2);case"Z":return D({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return D({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return D({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return t.zone.offsetName(t.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return t.zone.offsetName(t.ts,{format:"long",locale:this.loc.locale});case"z":return t.zoneName;case"a":return F();case"d":return b?T({day:"numeric"},"day"):this.num(t.day);case"dd":return b?T({day:"2-digit"},"day"):this.num(t.day,2);case"c":return this.num(t.weekday);case"ccc":return G("short",!0);case"cccc":return G("long",!0);case"ccccc":return G("narrow",!0);case"E":return this.num(t.weekday);case"EEE":return G("short",!1);case"EEEE":return G("long",!1);case"EEEEE":return G("narrow",!1);case"L":return b?T({month:"numeric",day:"numeric"},"month"):this.num(t.month);case"LL":return b?T({month:"2-digit",day:"numeric"},"month"):this.num(t.month,2);case"LLL":return R("short",!0);case"LLLL":return R("long",!0);case"LLLLL":return R("narrow",!0);case"M":return b?T({month:"numeric"},"month"):this.num(t.month);case"MM":return b?T({month:"2-digit"},"month"):this.num(t.month,2);case"MMM":return R("short",!1);case"MMMM":return R("long",!1);case"MMMMM":return R("narrow",!1);case"y":return b?T({year:"numeric"},"year"):this.num(t.year);case"yy":return b?T({year:"2-digit"},"year"):this.num(t.year.toString().slice(-2),2);case"yyyy":return b?T({year:"numeric"},"year"):this.num(t.year,4);case"yyyyyy":return b?T({year:"numeric"},"year"):this.num(t.year,6);case"G":return be("short");case"GG":return be("long");case"GGGGG":return be("narrow");case"kk":return this.num(t.weekYear.toString().slice(-2),2);case"kkkk":return this.num(t.weekYear,4);case"W":return this.num(t.weekNumber);case"WW":return this.num(t.weekNumber,2);case"n":return this.num(t.localWeekNumber);case"nn":return this.num(t.localWeekNumber,2);case"ii":return this.num(t.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(t.localWeekYear,4);case"o":return this.num(t.ordinal);case"ooo":return this.num(t.ordinal,3);case"q":return this.num(t.quarter);case"qq":return this.num(t.quarter,2);case"X":return this.num(Math.floor(t.ts/1e3));case"x":return this.num(t.ts);default:return ue(fe)}};return ks(Xe.parseFormat(a),De)}formatDurationFromString(t,a){const f=this.opts.signMode==="negativeLargestOnly"?-1:1,b=ue=>{switch(ue[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},T=(ue,be)=>De=>{const fe=b(De);if(fe){const Be=be.isNegativeDuration&&fe!==be.largestUnit?f:1;let vt;return this.opts.signMode==="negativeLargestOnly"&&fe!==be.largestUnit?vt="never":this.opts.signMode==="all"?vt="always":vt="auto",this.num(ue.get(fe)*Be,De.length,vt)}else return De},D=Xe.parseFormat(a),F=D.reduce((ue,{literal:be,val:De})=>be?ue:ue.concat(De),[]),R=t.shiftTo(...F.map(b).filter(ue=>ue)),G={isNegativeDuration:R<0,largestUnit:Object.keys(R.values)[0]};return ks(D,T(R,G))}}const Ts=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function dn(...i){const t=i.reduce((a,f)=>a+f.source,"");return RegExp(`^${t}$`)}function hn(...i){return t=>i.reduce(([a,f,b],T)=>{const[D,F,R]=T(t,b);return[{...a,...D},F||f,R]},[{},null,1]).slice(0,2)}function fn(i,...t){if(i==null)return[null,null];for(const[a,f]of t){const b=a.exec(i);if(b)return f(b)}return[null,null]}function Os(...i){return(t,a)=>{const f={};let b;for(b=0;b<i.length;b++)f[i[b]]=zt(t[a+b]);return[f,null,a+b]}}const Ms=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Ba=`(?:${Ms.source}?(?:\\[(${Ts.source})\\])?)?`,Mr=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,js=RegExp(`${Mr.source}${Ba}`),jr=RegExp(`(?:[Tt]${js.source})?`),Ua=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Ga=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Ya=/(\d{4})-?(\d{3})/,Za=Os("weekYear","weekNumber","weekDay"),Ka=Os("year","ordinal"),Xa=/(\d{4})-(\d\d)-(\d\d)/,Ds=RegExp(`${Mr.source} ?(?:${Ms.source}|(${Ts.source}))?`),Qa=RegExp(`(?: ${Ds.source})?`);function pn(i,t,a){const f=i[t];return Y(f)?a:zt(f)}function Ja(i,t){return[{year:pn(i,t),month:pn(i,t+1,1),day:pn(i,t+2,1)},null,t+3]}function mn(i,t){return[{hours:pn(i,t,0),minutes:pn(i,t+1,0),seconds:pn(i,t+2,0),milliseconds:kr(i[t+3])},null,t+4]}function Dn(i,t){const a=!i[t]&&!i[t+1],f=ar(i[t+1],i[t+2]),b=a?null:qe.instance(f);return[{},b,t+3]}function En(i,t){const a=i[t]?le.create(i[t]):null;return[{},a,t+1]}const ei=RegExp(`^T?${Mr.source}$`),ti=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function ni(i){const[t,a,f,b,T,D,F,R,G]=i,ue=t[0]==="-",be=R&&R[0]==="-",De=(fe,Be=!1)=>fe!==void 0&&(Be||fe&&ue)?-fe:fe;return[{years:De(Gt(a)),months:De(Gt(f)),weeks:De(Gt(b)),days:De(Gt(T)),hours:De(Gt(D)),minutes:De(Gt(F)),seconds:De(Gt(R),R==="-0"),milliseconds:De(kr(G),be)}]}const ri={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Dr(i,t,a,f,b,T,D){const F={year:t.length===2?Or(zt(t)):zt(t),month:ys.indexOf(a)+1,day:zt(f),hour:zt(b),minute:zt(T)};return D&&(F.second=zt(D)),i&&(F.weekday=i.length>3?bs.indexOf(i)+1:vs.indexOf(i)+1),F}const si=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function oi(i){const[,t,a,f,b,T,D,F,R,G,ue,be]=i,De=Dr(t,b,f,a,T,D,F);let fe;return R?fe=ri[R]:G?fe=0:fe=ar(ue,be),[De,new qe(fe)]}function ai(i){return i.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const ii=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,li=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,ci=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Es(i){const[,t,a,f,b,T,D,F]=i;return[Dr(t,b,f,a,T,D,F),qe.utcInstance]}function ui(i){const[,t,a,f,b,T,D,F]=i;return[Dr(t,F,a,f,b,T,D),qe.utcInstance]}const di=dn(Ua,jr),hi=dn(Ga,jr),fi=dn(Ya,jr),pi=dn(js),Is=hn(Ja,mn,Dn,En),mi=hn(Za,mn,Dn,En),gi=hn(Ka,mn,Dn,En),yi=hn(mn,Dn,En);function xi(i){return fn(i,[di,Is],[hi,mi],[fi,gi],[pi,yi])}function bi(i){return fn(ai(i),[si,oi])}function vi(i){return fn(i,[ii,Es],[li,Es],[ci,ui])}function Si(i){return fn(i,[ti,ni])}const wi=hn(mn);function Ci(i){return fn(i,[ei,wi])}const ki=dn(Xa,Qa),Ti=dn(Ds),Oi=hn(mn,Dn,En);function Mi(i){return fn(i,[ki,Is],[Ti,Oi])}const Ns="Invalid Duration",Fs={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},ji={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...Fs},mt=146097/400,gn=146097/4800,Di={years:{quarters:4,months:12,weeks:mt/7,days:mt,hours:mt*24,minutes:mt*24*60,seconds:mt*24*60*60,milliseconds:mt*24*60*60*1e3},quarters:{months:3,weeks:mt/28,days:mt/4,hours:mt*24/4,minutes:mt*24*60/4,seconds:mt*24*60*60/4,milliseconds:mt*24*60*60*1e3/4},months:{weeks:gn/7,days:gn,hours:gn*24,minutes:gn*24*60,seconds:gn*24*60*60,milliseconds:gn*24*60*60*1e3},...Fs},Yt=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Ei=Yt.slice(0).reverse();function Rt(i,t,a=!1){const f={values:a?t.values:{...i.values,...t.values||{}},loc:i.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||i.conversionAccuracy,matrix:t.matrix||i.matrix};return new ke(f)}function As(i,t){var a;let f=(a=t.milliseconds)!=null?a:0;for(const b of Ei.slice(1))t[b]&&(f+=t[b]*i[b].milliseconds);return f}function Rs(i,t){const a=As(i,t)<0?-1:1;Yt.reduceRight((f,b)=>{if(Y(t[b]))return f;if(f){const T=t[f]*a,D=i[b][f],F=Math.floor(T/D);t[b]+=F*a,t[f]-=F*D*a}return b},null),Yt.reduce((f,b)=>{if(Y(t[b]))return f;if(f){const T=t[f]%1;t[f]-=T,t[b]+=T*i[f][b]}return b},null)}function $s(i){const t={};for(const[a,f]of Object.entries(i))f!==0&&(t[a]=f);return t}class ke{constructor(t){const a=t.conversionAccuracy==="longterm"||!1;let f=a?Di:ji;t.matrix&&(f=t.matrix),this.values=t.values,this.loc=t.loc||ce.create(),this.conversionAccuracy=a?"longterm":"casual",this.invalid=t.invalid||null,this.matrix=f,this.isLuxonDuration=!0}static fromMillis(t,a){return ke.fromObject({milliseconds:t},a)}static fromObject(t,a={}){if(t==null||typeof t!="object")throw new l(`Duration.fromObject: argument expected to be an object, got ${t===null?"null":typeof t}`);return new ke({values:ir(t,ke.normalizeUnit),loc:ce.fromObject(a),conversionAccuracy:a.conversionAccuracy,matrix:a.matrix})}static fromDurationLike(t){if(je(t))return ke.fromMillis(t);if(ke.isDuration(t))return t;if(typeof t=="object")return ke.fromObject(t);throw new l(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,a){const[f]=Si(t);return f?ke.fromObject(f,a):ke.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,a){const[f]=Ci(t);return f?ke.fromObject(f,a):ke.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,a=null){if(!t)throw new l("need to specify a reason the Duration is invalid");const f=t instanceof Ue?t:new Ue(t,a);if(Me.throwOnInvalid)throw new s(f);return new ke({invalid:f})}static normalizeUnit(t){const a={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[t&&t.toLowerCase()];if(!a)throw new c(t);return a}static isDuration(t){return t&&t.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(t,a={}){const f={...a,floor:a.round!==!1&&a.floor!==!1};return this.isValid?Xe.create(this.loc,f).formatDurationFromString(this,t):Ns}toHuman(t={}){if(!this.isValid)return Ns;const a=t.showZeros!==!1,f=Yt.map(b=>{const T=this.values[b];return Y(T)||T===0&&!a?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...t,unit:b.slice(0,-1)}).format(T)}).filter(b=>b);return this.loc.listFormatter({type:"conjunction",style:t.listStyle||"narrow",...t}).format(f)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let t="P";return this.years!==0&&(t+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(t+=this.months+this.quarters*3+"M"),this.weeks!==0&&(t+=this.weeks+"W"),this.days!==0&&(t+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(t+="T"),this.hours!==0&&(t+=this.hours+"H"),this.minutes!==0&&(t+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(t+=Tr(this.seconds+this.milliseconds/1e3,3)+"S"),t==="P"&&(t+="T0S"),t}toISOTime(t={}){if(!this.isValid)return null;const a=this.toMillis();return a<0||a>=864e5?null:(t={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...t,includeOffset:!1},me.fromMillis(a,{zone:"UTC"}).toISOTime(t))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?As(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;const a=ke.fromDurationLike(t),f={};for(const b of Yt)(et(a.values,b)||et(this.values,b))&&(f[b]=a.get(b)+this.get(b));return Rt(this,{values:f},!0)}minus(t){if(!this.isValid)return this;const a=ke.fromDurationLike(t);return this.plus(a.negate())}mapUnits(t){if(!this.isValid)return this;const a={};for(const f of Object.keys(this.values))a[f]=gs(t(this.values[f],f));return Rt(this,{values:a},!0)}get(t){return this[ke.normalizeUnit(t)]}set(t){if(!this.isValid)return this;const a={...this.values,...ir(t,ke.normalizeUnit)};return Rt(this,{values:a})}reconfigure({locale:t,numberingSystem:a,conversionAccuracy:f,matrix:b}={}){const D={loc:this.loc.clone({locale:t,numberingSystem:a}),matrix:b,conversionAccuracy:f};return Rt(this,D)}as(t){return this.isValid?this.shiftTo(t).get(t):NaN}normalize(){if(!this.isValid)return this;const t=this.toObject();return Rs(this.matrix,t),Rt(this,{values:t},!0)}rescale(){if(!this.isValid)return this;const t=$s(this.normalize().shiftToAll().toObject());return Rt(this,{values:t},!0)}shiftTo(...t){if(!this.isValid)return this;if(t.length===0)return this;t=t.map(D=>ke.normalizeUnit(D));const a={},f={},b=this.toObject();let T;for(const D of Yt)if(t.indexOf(D)>=0){T=D;let F=0;for(const G in f)F+=this.matrix[G][D]*f[G],f[G]=0;je(b[D])&&(F+=b[D]);const R=Math.trunc(F);a[D]=R,f[D]=(F*1e3-R*1e3)/1e3}else je(b[D])&&(f[D]=b[D]);for(const D in f)f[D]!==0&&(a[T]+=D===T?f[D]:f[D]/this.matrix[T][D]);return Rs(this.matrix,a),Rt(this,{values:a},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const t={};for(const a of Object.keys(this.values))t[a]=this.values[a]===0?0:-this.values[a];return Rt(this,{values:t},!0)}removeZeros(){if(!this.isValid)return this;const t=$s(this.values);return Rt(this,{values:t},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(t){if(!this.isValid||!t.isValid||!this.loc.equals(t.loc))return!1;function a(f,b){return f===void 0||f===0?b===void 0||b===0:f===b}for(const f of Yt)if(!a(this.values[f],t.values[f]))return!1;return!0}}const yn="Invalid Interval";function Ii(i,t){return!i||!i.isValid?_e.invalid("missing or invalid start"):!t||!t.isValid?_e.invalid("missing or invalid end"):t<i?_e.invalid("end before start",`The end of an interval must be after its start, but you had start=${i.toISO()} and end=${t.toISO()}`):null}class _e{constructor(t){this.s=t.start,this.e=t.end,this.invalid=t.invalid||null,this.isLuxonInterval=!0}static invalid(t,a=null){if(!t)throw new l("need to specify a reason the Interval is invalid");const f=t instanceof Ue?t:new Ue(t,a);if(Me.throwOnInvalid)throw new u(f);return new _e({invalid:f})}static fromDateTimes(t,a){const f=An(t),b=An(a),T=Ii(f,b);return T??new _e({start:f,end:b})}static after(t,a){const f=ke.fromDurationLike(a),b=An(t);return _e.fromDateTimes(b,b.plus(f))}static before(t,a){const f=ke.fromDurationLike(a),b=An(t);return _e.fromDateTimes(b.minus(f),b)}static fromISO(t,a){const[f,b]=(t||"").split("/",2);if(f&&b){let T,D;try{T=me.fromISO(f,a),D=T.isValid}catch{D=!1}let F,R;try{F=me.fromISO(b,a),R=F.isValid}catch{R=!1}if(D&&R)return _e.fromDateTimes(T,F);if(D){const G=ke.fromISO(b,a);if(G.isValid)return _e.after(T,G)}else if(R){const G=ke.fromISO(f,a);if(G.isValid)return _e.before(F,G)}}return _e.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(t){return t&&t.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(t="milliseconds"){return this.isValid?this.toDuration(t).get(t):NaN}count(t="milliseconds",a){if(!this.isValid)return NaN;const f=this.start.startOf(t,a);let b;return a!=null&&a.useLocaleWeeks?b=this.end.reconfigure({locale:f.locale}):b=this.end,b=b.startOf(t,a),Math.floor(b.diff(f,t).get(t))+(b.valueOf()!==this.end.valueOf())}hasSame(t){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,t):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(t){return this.isValid?this.s>t:!1}isBefore(t){return this.isValid?this.e<=t:!1}contains(t){return this.isValid?this.s<=t&&this.e>t:!1}set({start:t,end:a}={}){return this.isValid?_e.fromDateTimes(t||this.s,a||this.e):this}splitAt(...t){if(!this.isValid)return[];const a=t.map(An).filter(D=>this.contains(D)).sort((D,F)=>D.toMillis()-F.toMillis()),f=[];let{s:b}=this,T=0;for(;b<this.e;){const D=a[T]||this.e,F=+D>+this.e?this.e:D;f.push(_e.fromDateTimes(b,F)),b=F,T+=1}return f}splitBy(t){const a=ke.fromDurationLike(t);if(!this.isValid||!a.isValid||a.as("milliseconds")===0)return[];let{s:f}=this,b=1,T;const D=[];for(;f<this.e;){const F=this.start.plus(a.mapUnits(R=>R*b));T=+F>+this.e?this.e:F,D.push(_e.fromDateTimes(f,T)),f=T,b+=1}return D}divideEqually(t){return this.isValid?this.splitBy(this.length()/t).slice(0,t):[]}overlaps(t){return this.e>t.s&&this.s<t.e}abutsStart(t){return this.isValid?+this.e==+t.s:!1}abutsEnd(t){return this.isValid?+t.e==+this.s:!1}engulfs(t){return this.isValid?this.s<=t.s&&this.e>=t.e:!1}equals(t){return!this.isValid||!t.isValid?!1:this.s.equals(t.s)&&this.e.equals(t.e)}intersection(t){if(!this.isValid)return this;const a=this.s>t.s?this.s:t.s,f=this.e<t.e?this.e:t.e;return a>=f?null:_e.fromDateTimes(a,f)}union(t){if(!this.isValid)return this;const a=this.s<t.s?this.s:t.s,f=this.e>t.e?this.e:t.e;return _e.fromDateTimes(a,f)}static merge(t){const[a,f]=t.sort((b,T)=>b.s-T.s).reduce(([b,T],D)=>T?T.overlaps(D)||T.abutsStart(D)?[b,T.union(D)]:[b.concat([T]),D]:[b,D],[[],null]);return f&&a.push(f),a}static xor(t){let a=null,f=0;const b=[],T=t.map(R=>[{time:R.s,type:"s"},{time:R.e,type:"e"}]),D=Array.prototype.concat(...T),F=D.sort((R,G)=>R.time-G.time);for(const R of F)f+=R.type==="s"?1:-1,f===1?a=R.time:(a&&+a!=+R.time&&b.push(_e.fromDateTimes(a,R.time)),a=null);return _e.merge(b)}difference(...t){return _e.xor([this].concat(t)).map(a=>this.intersection(a)).filter(a=>a&&!a.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:yn}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(t=v,a={}){return this.isValid?Xe.create(this.s.loc.clone(a),t).formatInterval(this):yn}toISO(t){return this.isValid?`${this.s.toISO(t)}/${this.e.toISO(t)}`:yn}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:yn}toISOTime(t){return this.isValid?`${this.s.toISOTime(t)}/${this.e.toISOTime(t)}`:yn}toFormat(t,{separator:a=" – "}={}){return this.isValid?`${this.s.toFormat(t)}${a}${this.e.toFormat(t)}`:yn}toDuration(t,a){return this.isValid?this.e.diff(this.s,t,a):ke.invalid(this.invalidReason)}mapEndpoints(t){return _e.fromDateTimes(t(this.s),t(this.e))}}class In{static hasDST(t=Me.defaultZone){const a=me.now().setZone(t).set({month:12});return!t.isUniversal&&a.offset!==a.set({month:6}).offset}static isValidIANAZone(t){return le.isValidZone(t)}static normalizeZone(t){return dt(t,Me.defaultZone)}static getStartOfWeek({locale:t=null,locObj:a=null}={}){return(a||ce.create(t)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:t=null,locObj:a=null}={}){return(a||ce.create(t)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:t=null,locObj:a=null}={}){return(a||ce.create(t)).getWeekendDays().slice()}static months(t="long",{locale:a=null,numberingSystem:f=null,locObj:b=null,outputCalendar:T="gregory"}={}){return(b||ce.create(a,f,T)).months(t)}static monthsFormat(t="long",{locale:a=null,numberingSystem:f=null,locObj:b=null,outputCalendar:T="gregory"}={}){return(b||ce.create(a,f,T)).months(t,!0)}static weekdays(t="long",{locale:a=null,numberingSystem:f=null,locObj:b=null}={}){return(b||ce.create(a,f,null)).weekdays(t)}static weekdaysFormat(t="long",{locale:a=null,numberingSystem:f=null,locObj:b=null}={}){return(b||ce.create(a,f,null)).weekdays(t,!0)}static meridiems({locale:t=null}={}){return ce.create(t).meridiems()}static eras(t="short",{locale:a=null}={}){return ce.create(a,null,"gregory").eras(t)}static features(){return{relative:kn(),localeWeek:Tn()}}}function Ps(i,t){const a=b=>b.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),f=a(t)-a(i);return Math.floor(ke.fromMillis(f).as("days"))}function Ni(i,t,a){const f=[["years",(R,G)=>G.year-R.year],["quarters",(R,G)=>G.quarter-R.quarter+(G.year-R.year)*4],["months",(R,G)=>G.month-R.month+(G.year-R.year)*12],["weeks",(R,G)=>{const ue=Ps(R,G);return(ue-ue%7)/7}],["days",Ps]],b={},T=i;let D,F;for(const[R,G]of f)a.indexOf(R)>=0&&(D=R,b[R]=G(i,t),F=T.plus(b),F>t?(b[R]--,i=T.plus(b),i>t&&(F=i,b[R]--,i=T.plus(b))):i=F);return[i,b,F,D]}function Fi(i,t,a,f){let[b,T,D,F]=Ni(i,t,a);const R=t-b,G=a.filter(be=>["hours","minutes","seconds","milliseconds"].indexOf(be)>=0);G.length===0&&(D<t&&(D=b.plus({[F]:1})),D!==b&&(T[F]=(T[F]||0)+R/(D-b)));const ue=ke.fromObject(T,f);return G.length>0?ke.fromMillis(R,f).shiftTo(...G).plus(ue):ue}const Ai="missing Intl.DateTimeFormat.formatToParts support";function Oe(i,t=a=>a){return{regex:i,deser:([a])=>t(Cn(a))}}const Ls="[ ]",_s=new RegExp(Ls,"g");function Ri(i){return i.replace(/\./g,"\\.?").replace(_s,Ls)}function Ws(i){return i.replace(/\./g,"").replace(_s," ").toLowerCase()}function bt(i,t){return i===null?null:{regex:RegExp(i.map(Ri).join("|")),deser:([a])=>i.findIndex(f=>Ws(a)===Ws(f))+t}}function qs(i,t){return{regex:i,deser:([,a,f])=>ar(a,f),groups:t}}function cr(i){return{regex:i,deser:([t])=>t}}function $i(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Pi(i,t){const a=ze(t),f=ze(t,"{2}"),b=ze(t,"{3}"),T=ze(t,"{4}"),D=ze(t,"{6}"),F=ze(t,"{1,2}"),R=ze(t,"{1,3}"),G=ze(t,"{1,6}"),ue=ze(t,"{1,9}"),be=ze(t,"{2,4}"),De=ze(t,"{4,6}"),fe=Mt=>({regex:RegExp($i(Mt.val)),deser:([bn])=>bn,literal:!0}),vt=(Mt=>{if(i.literal)return fe(Mt);switch(Mt.val){case"G":return bt(t.eras("short"),0);case"GG":return bt(t.eras("long"),0);case"y":return Oe(G);case"yy":return Oe(be,Or);case"yyyy":return Oe(T);case"yyyyy":return Oe(De);case"yyyyyy":return Oe(D);case"M":return Oe(F);case"MM":return Oe(f);case"MMM":return bt(t.months("short",!0),1);case"MMMM":return bt(t.months("long",!0),1);case"L":return Oe(F);case"LL":return Oe(f);case"LLL":return bt(t.months("short",!1),1);case"LLLL":return bt(t.months("long",!1),1);case"d":return Oe(F);case"dd":return Oe(f);case"o":return Oe(R);case"ooo":return Oe(b);case"HH":return Oe(f);case"H":return Oe(F);case"hh":return Oe(f);case"h":return Oe(F);case"mm":return Oe(f);case"m":return Oe(F);case"q":return Oe(F);case"qq":return Oe(f);case"s":return Oe(F);case"ss":return Oe(f);case"S":return Oe(R);case"SSS":return Oe(b);case"u":return cr(ue);case"uu":return cr(F);case"uuu":return Oe(a);case"a":return bt(t.meridiems(),0);case"kkkk":return Oe(T);case"kk":return Oe(be,Or);case"W":return Oe(F);case"WW":return Oe(f);case"E":case"c":return Oe(a);case"EEE":return bt(t.weekdays("short",!1),1);case"EEEE":return bt(t.weekdays("long",!1),1);case"ccc":return bt(t.weekdays("short",!0),1);case"cccc":return bt(t.weekdays("long",!0),1);case"Z":case"ZZ":return qs(new RegExp(`([+-]${F.source})(?::(${f.source}))?`),2);case"ZZZ":return qs(new RegExp(`([+-]${F.source})(${f.source})?`),2);case"z":return cr(/[a-z_+-/]{1,256}?/i);case" ":return cr(/[^\S\n\r]/);default:return fe(Mt)}})(i)||{invalidReason:Ai};return vt.token=i,vt}const Li={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function _i(i,t,a){const{type:f,value:b}=i;if(f==="literal"){const R=/^\s+$/.test(b);return{literal:!R,val:R?" ":b}}const T=t[f];let D=f;f==="hour"&&(t.hour12!=null?D=t.hour12?"hour12":"hour24":t.hourCycle!=null?t.hourCycle==="h11"||t.hourCycle==="h12"?D="hour12":D="hour24":D=a.hour12?"hour12":"hour24");let F=Li[D];if(typeof F=="object"&&(F=F[T]),F)return{literal:!1,val:F}}function Wi(i){return[`^${i.map(a=>a.regex).reduce((a,f)=>`${a}(${f.source})`,"")}$`,i]}function qi(i,t,a){const f=i.match(t);if(f){const b={};let T=1;for(const D in a)if(et(a,D)){const F=a[D],R=F.groups?F.groups+1:1;!F.literal&&F.token&&(b[F.token.val[0]]=F.deser(f.slice(T,T+R))),T+=R}return[f,b]}else return[f,{}]}function zi(i){const t=T=>{switch(T){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let a=null,f;return Y(i.z)||(a=le.create(i.z)),Y(i.Z)||(a||(a=new qe(i.Z)),f=i.Z),Y(i.q)||(i.M=(i.q-1)*3+1),Y(i.h)||(i.h<12&&i.a===1?i.h+=12:i.h===12&&i.a===0&&(i.h=0)),i.G===0&&i.y&&(i.y=-i.y),Y(i.u)||(i.S=kr(i.u)),[Object.keys(i).reduce((T,D)=>{const F=t(D);return F&&(T[F]=i[D]),T},{}),a,f]}let Er=null;function Hi(){return Er||(Er=me.fromMillis(1555555555555)),Er}function Vi(i,t){if(i.literal)return i;const a=Xe.macroTokenToFormatOpts(i.val),f=Bs(a,t);return f==null||f.includes(void 0)?i:f}function zs(i,t){return Array.prototype.concat(...i.map(a=>Vi(a,t)))}class Hs{constructor(t,a){if(this.locale=t,this.format=a,this.tokens=zs(Xe.parseFormat(a),t),this.units=this.tokens.map(f=>Pi(f,t)),this.disqualifyingUnit=this.units.find(f=>f.invalidReason),!this.disqualifyingUnit){const[f,b]=Wi(this.units);this.regex=RegExp(f,"i"),this.handlers=b}}explainFromTokens(t){if(this.isValid){const[a,f]=qi(t,this.regex,this.handlers),[b,T,D]=f?zi(f):[null,null,void 0];if(et(f,"a")&&et(f,"H"))throw new d("Can't include meridiem when specifying 24-hour format");return{input:t,tokens:this.tokens,regex:this.regex,rawMatches:a,matches:f,result:b,zone:T,specificOffset:D}}else return{input:t,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function Vs(i,t,a){return new Hs(i,a).explainFromTokens(t)}function Bi(i,t,a){const{result:f,zone:b,specificOffset:T,invalidReason:D}=Vs(i,t,a);return[f,b,T,D]}function Bs(i,t){if(!i)return null;const f=Xe.create(t,i).dtFormatter(Hi()),b=f.formatToParts(),T=f.resolvedOptions();return b.map(D=>_i(D,i,T))}const Ir="Invalid DateTime",Us=864e13;function Nn(i){return new Ue("unsupported zone",`the zone "${i.name}" is not supported`)}function Nr(i){return i.weekData===null&&(i.weekData=Le(i.c)),i.weekData}function Fr(i){return i.localWeekData===null&&(i.localWeekData=Le(i.c,i.loc.getMinDaysInFirstWeek(),i.loc.getStartOfWeek())),i.localWeekData}function Zt(i,t){const a={ts:i.ts,zone:i.zone,c:i.c,o:i.o,loc:i.loc,invalid:i.invalid};return new me({...a,...t,old:a})}function Gs(i,t,a){let f=i-t*60*1e3;const b=a.offset(f);if(t===b)return[f,t];f-=(b-t)*60*1e3;const T=a.offset(f);return b===T?[f,b]:[i-Math.min(b,T)*60*1e3,Math.max(b,T)]}function ur(i,t){i+=t*60*1e3;const a=new Date(i);return{year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds()}}function dr(i,t,a){return Gs(or(i),t,a)}function Ys(i,t){const a=i.o,f=i.c.year+Math.trunc(t.years),b=i.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,T={...i.c,year:f,month:b,day:Math.min(i.c.day,sr(f,b))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},D=ke.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),F=or(T);let[R,G]=Gs(F,a,i.zone);return D!==0&&(R+=D,G=i.zone.offset(R)),{ts:R,o:G}}function xn(i,t,a,f,b,T){const{setZone:D,zone:F}=a;if(i&&Object.keys(i).length!==0||t){const R=t||F,G=me.fromObject(i,{...a,zone:R,specificOffset:T});return D?G:G.setZone(F)}else return me.invalid(new Ue("unparsable",`the input "${b}" can't be parsed as ${f}`))}function hr(i,t,a=!0){return i.isValid?Xe.create(ce.create("en-US"),{allowZ:a,forceSimple:!0}).formatDateTimeFromString(i,t):null}function Ar(i,t,a){const f=i.c.year>9999||i.c.year<0;let b="";if(f&&i.c.year>=0&&(b+="+"),b+=Ve(i.c.year,f?6:4),a==="year")return b;if(t){if(b+="-",b+=Ve(i.c.month),a==="month")return b;b+="-"}else if(b+=Ve(i.c.month),a==="month")return b;return b+=Ve(i.c.day),b}function Zs(i,t,a,f,b,T,D){let F=!a||i.c.millisecond!==0||i.c.second!==0,R="";switch(D){case"day":case"month":case"year":break;default:if(R+=Ve(i.c.hour),D==="hour")break;if(t){if(R+=":",R+=Ve(i.c.minute),D==="minute")break;F&&(R+=":",R+=Ve(i.c.second))}else{if(R+=Ve(i.c.minute),D==="minute")break;F&&(R+=Ve(i.c.second))}if(D==="second")break;F&&(!f||i.c.millisecond!==0)&&(R+=".",R+=Ve(i.c.millisecond,3))}return b&&(i.isOffsetFixed&&i.offset===0&&!T?R+="Z":i.o<0?(R+="-",R+=Ve(Math.trunc(-i.o/60)),R+=":",R+=Ve(Math.trunc(-i.o%60))):(R+="+",R+=Ve(Math.trunc(i.o/60)),R+=":",R+=Ve(Math.trunc(i.o%60)))),T&&(R+="["+i.zone.ianaName+"]"),R}const Ks={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Ui={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Gi={ordinal:1,hour:0,minute:0,second:0,millisecond:0},fr=["year","month","day","hour","minute","second","millisecond"],Yi=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Zi=["year","ordinal","hour","minute","second","millisecond"];function pr(i){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[i.toLowerCase()];if(!t)throw new c(i);return t}function Xs(i){switch(i.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return pr(i)}}function Ki(i){if(Fn===void 0&&(Fn=Me.now()),i.type!=="iana")return i.offset(Fn);const t=i.name;let a=Rr.get(t);return a===void 0&&(a=i.offset(Fn),Rr.set(t,a)),a}function Qs(i,t){const a=dt(t.zone,Me.defaultZone);if(!a.isValid)return me.invalid(Nn(a));const f=ce.fromObject(t);let b,T;if(Y(i.year))b=Me.now();else{for(const R of fr)Y(i[R])&&(i[R]=Ks[R]);const D=ne(i)||de(i);if(D)return me.invalid(D);const F=Ki(a);[b,T]=dr(i,F,a)}return new me({ts:b,zone:a,loc:f,o:T})}function Js(i,t,a){const f=Y(a.round)?!0:a.round,b=Y(a.rounding)?"trunc":a.rounding,T=(F,R)=>(F=Tr(F,f||a.calendary?0:2,a.calendary?"round":b),t.loc.clone(a).relFormatter(a).format(F,R)),D=F=>a.calendary?t.hasSame(i,F)?0:t.startOf(F).diff(i.startOf(F),F).get(F):t.diff(i,F).get(F);if(a.unit)return T(D(a.unit),a.unit);for(const F of a.units){const R=D(F);if(Math.abs(R)>=1)return T(R,F)}return T(i>t?-0:0,a.units[a.units.length-1])}function eo(i){let t={},a;return i.length>0&&typeof i[i.length-1]=="object"?(t=i[i.length-1],a=Array.from(i).slice(0,i.length-1)):a=Array.from(i),[t,a]}let Fn;const Rr=new Map;class me{constructor(t){const a=t.zone||Me.defaultZone;let f=t.invalid||(Number.isNaN(t.ts)?new Ue("invalid input"):null)||(a.isValid?null:Nn(a));this.ts=Y(t.ts)?Me.now():t.ts;let b=null,T=null;if(!f)if(t.old&&t.old.ts===this.ts&&t.old.zone.equals(a))[b,T]=[t.old.c,t.old.o];else{const F=je(t.o)&&!t.old?t.o:a.offset(this.ts);b=ur(this.ts,F),f=Number.isNaN(b.year)?new Ue("invalid input"):null,b=f?null:b,T=f?null:F}this._zone=a,this.loc=t.loc||ce.create(),this.invalid=f,this.weekData=null,this.localWeekData=null,this.c=b,this.o=T,this.isLuxonDateTime=!0}static now(){return new me({})}static local(){const[t,a]=eo(arguments),[f,b,T,D,F,R,G]=a;return Qs({year:f,month:b,day:T,hour:D,minute:F,second:R,millisecond:G},t)}static utc(){const[t,a]=eo(arguments),[f,b,T,D,F,R,G]=a;return t.zone=qe.utcInstance,Qs({year:f,month:b,day:T,hour:D,minute:F,second:R,millisecond:G},t)}static fromJSDate(t,a={}){const f=cn(t)?t.valueOf():NaN;if(Number.isNaN(f))return me.invalid("invalid input");const b=dt(a.zone,Me.defaultZone);return b.isValid?new me({ts:f,zone:b,loc:ce.fromObject(a)}):me.invalid(Nn(b))}static fromMillis(t,a={}){if(je(t))return t<-Us||t>Us?me.invalid("Timestamp out of range"):new me({ts:t,zone:dt(a.zone,Me.defaultZone),loc:ce.fromObject(a)});throw new l(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,a={}){if(je(t))return new me({ts:t*1e3,zone:dt(a.zone,Me.defaultZone),loc:ce.fromObject(a)});throw new l("fromSeconds requires a numerical input")}static fromObject(t,a={}){t=t||{};const f=dt(a.zone,Me.defaultZone);if(!f.isValid)return me.invalid(Nn(f));const b=ce.fromObject(a),T=ir(t,Xs),{minDaysInFirstWeek:D,startOfWeek:F}=Ut(T,b),R=Me.now(),G=Y(a.specificOffset)?f.offset(R):a.specificOffset,ue=!Y(T.ordinal),be=!Y(T.year),De=!Y(T.month)||!Y(T.day),fe=be||De,Be=T.weekYear||T.weekNumber;if((fe||ue)&&Be)throw new d("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(De&&ue)throw new d("Can't mix ordinal dates with month/day");const vt=Be||T.weekday&&!fe;let Mt,bn,Rn=ur(R,G);vt?(Mt=Yi,bn=Ui,Rn=Le(Rn,D,F)):ue?(Mt=Zi,bn=Gi,Rn=Bt(Rn)):(Mt=fr,bn=Ks);let to=!1;for(const Pn of Mt){const nl=T[Pn];Y(nl)?to?T[Pn]=bn[Pn]:T[Pn]=Rn[Pn]:to=!0}const Qi=vt?z(T,D,F):ue?W(T):ne(T),no=Qi||de(T);if(no)return me.invalid(no);const Ji=vt?xt(T,D,F):ue?qt(T):T,[el,tl]=dr(Ji,G,f),$n=new me({ts:el,zone:f,o:tl,loc:b});return T.weekday&&fe&&t.weekday!==$n.weekday?me.invalid("mismatched weekday",`you can't specify both a weekday of ${T.weekday} and a date of ${$n.toISO()}`):$n.isValid?$n:me.invalid($n.invalid)}static fromISO(t,a={}){const[f,b]=xi(t);return xn(f,b,a,"ISO 8601",t)}static fromRFC2822(t,a={}){const[f,b]=bi(t);return xn(f,b,a,"RFC 2822",t)}static fromHTTP(t,a={}){const[f,b]=vi(t);return xn(f,b,a,"HTTP",a)}static fromFormat(t,a,f={}){if(Y(t)||Y(a))throw new l("fromFormat requires an input string and a format");const{locale:b=null,numberingSystem:T=null}=f,D=ce.fromOpts({locale:b,numberingSystem:T,defaultToEN:!0}),[F,R,G,ue]=Bi(D,t,a);return ue?me.invalid(ue):xn(F,R,f,`format ${a}`,t,G)}static fromString(t,a,f={}){return me.fromFormat(t,a,f)}static fromSQL(t,a={}){const[f,b]=Mi(t);return xn(f,b,a,"SQL",t)}static invalid(t,a=null){if(!t)throw new l("need to specify a reason the DateTime is invalid");const f=t instanceof Ue?t:new Ue(t,a);if(Me.throwOnInvalid)throw new r(f);return new me({invalid:f})}static isDateTime(t){return t&&t.isLuxonDateTime||!1}static parseFormatForOpts(t,a={}){const f=Bs(t,ce.fromObject(a));return f?f.map(b=>b?b.val:null).join(""):null}static expandFormat(t,a={}){return zs(Xe.parseFormat(t),ce.fromObject(a)).map(b=>b.val).join("")}static resetCache(){Fn=void 0,Rr.clear()}get(t){return this[t]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Nr(this).weekYear:NaN}get weekNumber(){return this.isValid?Nr(this).weekNumber:NaN}get weekday(){return this.isValid?Nr(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Fr(this).weekday:NaN}get localWeekNumber(){return this.isValid?Fr(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Fr(this).weekYear:NaN}get ordinal(){return this.isValid?Bt(this.c).ordinal:NaN}get monthShort(){return this.isValid?In.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?In.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?In.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?In.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const t=864e5,a=6e4,f=or(this.c),b=this.zone.offset(f-t),T=this.zone.offset(f+t),D=this.zone.offset(f-b*a),F=this.zone.offset(f-T*a);if(D===F)return[this];const R=f-D*a,G=f-F*a,ue=ur(R,D),be=ur(G,F);return ue.hour===be.hour&&ue.minute===be.minute&&ue.second===be.second&&ue.millisecond===be.millisecond?[Zt(this,{ts:R}),Zt(this,{ts:G})]:[this]}get isInLeapYear(){return On(this.year)}get daysInMonth(){return sr(this.year,this.month)}get daysInYear(){return this.isValid?un(this.year):NaN}get weeksInWeekYear(){return this.isValid?Mn(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Mn(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(t={}){const{locale:a,numberingSystem:f,calendar:b}=Xe.create(this.loc.clone(t),t).resolvedOptions(this);return{locale:a,numberingSystem:f,outputCalendar:b}}toUTC(t=0,a={}){return this.setZone(qe.instance(t),a)}toLocal(){return this.setZone(Me.defaultZone)}setZone(t,{keepLocalTime:a=!1,keepCalendarTime:f=!1}={}){if(t=dt(t,Me.defaultZone),t.equals(this.zone))return this;if(t.isValid){let b=this.ts;if(a||f){const T=t.offset(this.ts),D=this.toObject();[b]=dr(D,T,t)}return Zt(this,{ts:b,zone:t})}else return me.invalid(Nn(t))}reconfigure({locale:t,numberingSystem:a,outputCalendar:f}={}){const b=this.loc.clone({locale:t,numberingSystem:a,outputCalendar:f});return Zt(this,{loc:b})}setLocale(t){return this.reconfigure({locale:t})}set(t){if(!this.isValid)return this;const a=ir(t,Xs),{minDaysInFirstWeek:f,startOfWeek:b}=Ut(a,this.loc),T=!Y(a.weekYear)||!Y(a.weekNumber)||!Y(a.weekday),D=!Y(a.ordinal),F=!Y(a.year),R=!Y(a.month)||!Y(a.day),G=F||R,ue=a.weekYear||a.weekNumber;if((G||D)&&ue)throw new d("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(R&&D)throw new d("Can't mix ordinal dates with month/day");let be;T?be=xt({...Le(this.c,f,b),...a},f,b):Y(a.ordinal)?(be={...this.toObject(),...a},Y(a.day)&&(be.day=Math.min(sr(be.year,be.month),be.day))):be=qt({...Bt(this.c),...a});const[De,fe]=dr(be,this.o,this.zone);return Zt(this,{ts:De,o:fe})}plus(t){if(!this.isValid)return this;const a=ke.fromDurationLike(t);return Zt(this,Ys(this,a))}minus(t){if(!this.isValid)return this;const a=ke.fromDurationLike(t).negate();return Zt(this,Ys(this,a))}startOf(t,{useLocaleWeeks:a=!1}={}){if(!this.isValid)return this;const f={},b=ke.normalizeUnit(t);switch(b){case"years":f.month=1;case"quarters":case"months":f.day=1;case"weeks":case"days":f.hour=0;case"hours":f.minute=0;case"minutes":f.second=0;case"seconds":f.millisecond=0;break}if(b==="weeks")if(a){const T=this.loc.getStartOfWeek(),{weekday:D}=this;D<T&&(f.weekNumber=this.weekNumber-1),f.weekday=T}else f.weekday=1;if(b==="quarters"){const T=Math.ceil(this.month/3);f.month=(T-1)*3+1}return this.set(f)}endOf(t,a){return this.isValid?this.plus({[t]:1}).startOf(t,a).minus(1):this}toFormat(t,a={}){return this.isValid?Xe.create(this.loc.redefaultToEN(a)).formatDateTimeFromString(this,t):Ir}toLocaleString(t=v,a={}){return this.isValid?Xe.create(this.loc.clone(a),t).formatDateTime(this):Ir}toLocaleParts(t={}){return this.isValid?Xe.create(this.loc.clone(t),t).formatDateTimeParts(this):[]}toISO({format:t="extended",suppressSeconds:a=!1,suppressMilliseconds:f=!1,includeOffset:b=!0,extendedZone:T=!1,precision:D="milliseconds"}={}){if(!this.isValid)return null;D=pr(D);const F=t==="extended";let R=Ar(this,F,D);return fr.indexOf(D)>=3&&(R+="T"),R+=Zs(this,F,a,f,b,T,D),R}toISODate({format:t="extended",precision:a="day"}={}){return this.isValid?Ar(this,t==="extended",pr(a)):null}toISOWeekDate(){return hr(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:t=!1,suppressSeconds:a=!1,includeOffset:f=!0,includePrefix:b=!1,extendedZone:T=!1,format:D="extended",precision:F="milliseconds"}={}){return this.isValid?(F=pr(F),(b&&fr.indexOf(F)>=3?"T":"")+Zs(this,D==="extended",a,t,f,T,F)):null}toRFC2822(){return hr(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return hr(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Ar(this,!0):null}toSQLTime({includeOffset:t=!0,includeZone:a=!1,includeOffsetSpace:f=!0}={}){let b="HH:mm:ss.SSS";return(a||t)&&(f&&(b+=" "),a?b+="z":t&&(b+="ZZ")),hr(this,b,!0)}toSQL(t={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(t)}`:null}toString(){return this.isValid?this.toISO():Ir}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(t={}){if(!this.isValid)return{};const a={...this.c};return t.includeConfig&&(a.outputCalendar=this.outputCalendar,a.numberingSystem=this.loc.numberingSystem,a.locale=this.loc.locale),a}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(t,a="milliseconds",f={}){if(!this.isValid||!t.isValid)return ke.invalid("created by diffing an invalid DateTime");const b={locale:this.locale,numberingSystem:this.numberingSystem,...f},T=rr(a).map(ke.normalizeUnit),D=t.valueOf()>this.valueOf(),F=D?this:t,R=D?t:this,G=Fi(F,R,T,b);return D?G.negate():G}diffNow(t="milliseconds",a={}){return this.diff(me.now(),t,a)}until(t){return this.isValid?_e.fromDateTimes(this,t):this}hasSame(t,a,f){if(!this.isValid)return!1;const b=t.valueOf(),T=this.setZone(t.zone,{keepLocalTime:!0});return T.startOf(a,f)<=b&&b<=T.endOf(a,f)}equals(t){return this.isValid&&t.isValid&&this.valueOf()===t.valueOf()&&this.zone.equals(t.zone)&&this.loc.equals(t.loc)}toRelative(t={}){if(!this.isValid)return null;const a=t.base||me.fromObject({},{zone:this.zone}),f=t.padding?this<a?-t.padding:t.padding:0;let b=["years","months","days","hours","minutes","seconds"],T=t.unit;return Array.isArray(t.unit)&&(b=t.unit,T=void 0),Js(a,this.plus(f),{...t,numeric:"always",units:b,unit:T})}toRelativeCalendar(t={}){return this.isValid?Js(t.base||me.fromObject({},{zone:this.zone}),this,{...t,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...t){if(!t.every(me.isDateTime))throw new l("min requires all arguments be DateTimes");return Ce(t,a=>a.valueOf(),Math.min)}static max(...t){if(!t.every(me.isDateTime))throw new l("max requires all arguments be DateTimes");return Ce(t,a=>a.valueOf(),Math.max)}static fromFormatExplain(t,a,f={}){const{locale:b=null,numberingSystem:T=null}=f,D=ce.fromOpts({locale:b,numberingSystem:T,defaultToEN:!0});return Vs(D,t,a)}static fromStringExplain(t,a,f={}){return me.fromFormatExplain(t,a,f)}static buildFormatParser(t,a={}){const{locale:f=null,numberingSystem:b=null}=a,T=ce.fromOpts({locale:f,numberingSystem:b,defaultToEN:!0});return new Hs(T,t)}static fromFormatParser(t,a,f={}){if(Y(t)||Y(a))throw new l("fromFormatParser requires an input string and a format parser");const{locale:b=null,numberingSystem:T=null}=f,D=ce.fromOpts({locale:b,numberingSystem:T,defaultToEN:!0});if(!D.equals(a.locale))throw new l(`fromFormatParser called with a locale of ${D}, but the format parser was created for ${a.locale}`);const{result:F,zone:R,specificOffset:G,invalidReason:ue}=a.explainFromTokens(t);return ue?me.invalid(ue):xn(F,R,f,`format ${a.format}`,t,G)}static get DATE_SHORT(){return v}static get DATE_MED(){return x}static get DATE_MED_WITH_WEEKDAY(){return y}static get DATE_FULL(){return C}static get DATE_HUGE(){return w}static get TIME_SIMPLE(){return k}static get TIME_WITH_SECONDS(){return O}static get TIME_WITH_SHORT_OFFSET(){return M}static get TIME_WITH_LONG_OFFSET(){return j}static get TIME_24_SIMPLE(){return E}static get TIME_24_WITH_SECONDS(){return $}static get TIME_24_WITH_SHORT_OFFSET(){return U}static get TIME_24_WITH_LONG_OFFSET(){return P}static get DATETIME_SHORT(){return K}static get DATETIME_SHORT_WITH_SECONDS(){return A}static get DATETIME_MED(){return L}static get DATETIME_MED_WITH_SECONDS(){return V}static get DATETIME_MED_WITH_WEEKDAY(){return N}static get DATETIME_FULL(){return _}static get DATETIME_FULL_WITH_SECONDS(){return Q}static get DATETIME_HUGE(){return re}static get DATETIME_HUGE_WITH_SECONDS(){return ee}}function An(i){if(me.isDateTime(i))return i;if(i&&i.valueOf&&je(i.valueOf()))return me.fromJSDate(i);if(i&&typeof i=="object")return me.fromObject(i);throw new l(`Unknown datetime argument: ${i}, of type ${typeof i}`)}const Xi="3.7.2";return rt.DateTime=me,rt.Duration=ke,rt.FixedOffsetZone=qe,rt.IANAZone=le,rt.Info=In,rt.Interval=_e,rt.InvalidZone=tt,rt.Settings=Me,rt.SystemZone=ae,rt.VERSION=Xi,rt.Zone=te,rt}var Mo;function is(){return Mo||(Mo=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CronDate=e.DAYS_IN_MONTH=e.DateMathOp=e.TimeUnit=void 0;const r=ru();var u;(function(c){c.Second="Second",c.Minute="Minute",c.Hour="Hour",c.Day="Day",c.Month="Month",c.Year="Year"})(u||(e.TimeUnit=u={}));var s;(function(c){c.Add="Add",c.Subtract="Subtract"})(s||(e.DateMathOp=s={})),e.DAYS_IN_MONTH=Object.freeze([31,29,31,30,31,30,31,31,30,31,30,31]);class d{#e;#n=null;#o=null;constructor(l,m){const p={zone:m};if(l?l instanceof d?(this.#e=l.#e,this.#n=l.#n,this.#o=l.#o):l instanceof Date?this.#e=r.DateTime.fromJSDate(l,p):typeof l=="number"?this.#e=r.DateTime.fromMillis(l,p):(this.#e=r.DateTime.fromISO(l,p),this.#e.isValid||(this.#e=r.DateTime.fromRFC2822(l,p)),this.#e.isValid||(this.#e=r.DateTime.fromSQL(l,p)),this.#e.isValid||(this.#e=r.DateTime.fromFormat(l,"EEE, d MMM yyyy HH:mm:ss",p))):this.#e=r.DateTime.local(),!this.#e.isValid)throw new Error(`CronDate: unhandled timestamp: ${l}`);m&&m!==this.#e.zoneName&&(this.#e=this.#e.setZone(m))}static#s(l){return l%4===0&&l%100!==0||l%400===0}get dstStart(){return this.#n}set dstStart(l){this.#n=l}get dstEnd(){return this.#o}set dstEnd(l){this.#o=l}addYear(){this.#e=this.#e.plus({years:1})}addMonth(){this.#e=this.#e.plus({months:1}).startOf("month")}addDay(){this.#e=this.#e.plus({days:1}).startOf("day")}addHour(){this.#e=this.#e.plus({hours:1}).startOf("hour")}addMinute(){this.#e=this.#e.plus({minutes:1}).startOf("minute")}addSecond(){this.#e=this.#e.plus({seconds:1})}subtractYear(){this.#e=this.#e.minus({years:1})}subtractMonth(){this.#e=this.#e.minus({months:1}).endOf("month").startOf("second")}subtractDay(){this.#e=this.#e.minus({days:1}).endOf("day").startOf("second")}subtractHour(){this.#e=this.#e.minus({hours:1}).endOf("hour").startOf("second")}subtractMinute(){this.#e=this.#e.minus({minutes:1}).endOf("minute").startOf("second")}subtractSecond(){this.#e=this.#e.minus({seconds:1})}addUnit(l){switch(l){case u.Year:return this.addYear();case u.Month:return this.addMonth();case u.Day:return this.addDay();case u.Hour:return this.addHour();case u.Minute:return this.addMinute();case u.Second:return this.addSecond()}}subtractUnit(l){switch(l){case u.Year:return this.subtractYear();case u.Month:return this.subtractMonth();case u.Day:return this.subtractDay();case u.Hour:return this.subtractHour();case u.Minute:return this.subtractMinute();case u.Second:return this.subtractSecond()}}invokeDateOperation(l,m){if(l===s.Add){this.addUnit(m);return}if(l===s.Subtract){this.subtractUnit(m);return}throw new Error(`Invalid verb: ${l}`)}getDate(){return this.#e.day}getFullYear(){return this.#e.year}getDay(){const l=this.#e.weekday;return l===7?0:l}getMonth(){return this.#e.month-1}getHours(){return this.#e.hour}getMinutes(){return this.#e.minute}getSeconds(){return this.#e.second}getMilliseconds(){return this.#e.millisecond}getUTCOffset(){return this.#e.offset}setStartOfDay(){this.#e=this.#e.startOf("day")}setEndOfDay(){this.#e=this.#e.endOf("day")}getTime(){return this.#e.valueOf()}getUTCDate(){return this.#r().day}getUTCFullYear(){return this.#r().year}getUTCDay(){const l=this.#r().weekday;return l===7?0:l}getUTCMonth(){return this.#r().month-1}getUTCHours(){return this.#r().hour}getUTCMinutes(){return this.#r().minute}getUTCSeconds(){return this.#r().second}toISOString(){return this.#e.toUTC().toISO()}toJSON(){return this.#e.toJSON()}setDate(l){this.#e=this.#e.set({day:l})}setFullYear(l){this.#e=this.#e.set({year:l})}setDay(l){this.#e=this.#e.set({weekday:l})}setMonth(l){this.#e=this.#e.set({month:l+1})}setHours(l){this.#e=this.#e.set({hour:l})}setMinutes(l){this.#e=this.#e.set({minute:l})}setSeconds(l){this.#e=this.#e.set({second:l})}setMilliseconds(l){this.#e=this.#e.set({millisecond:l})}toString(){return this.toDate().toString()}toDate(){return this.#e.toJSDate()}isLastDayOfMonth(){const{day:l,month:m}=this.#e;if(m===2){const p=d.#s(this.#e.year);return l===e.DAYS_IN_MONTH[m-1]-(p?0:1)}return l===e.DAYS_IN_MONTH[m-1]}isLastWeekdayOfMonth(){const{day:l,month:m}=this.#e;let p;return m===2?p=e.DAYS_IN_MONTH[m-1]-(d.#s(this.#e.year)?0:1):p=e.DAYS_IN_MONTH[m-1],l>p-7}applyDateOperation(l,m,p){if(m===u.Month||m===u.Day){this.invokeDateOperation(l,m);return}const h=this.getHours();this.invokeDateOperation(l,m);const g=this.getHours(),v=g-h;v===2?p!==24&&(this.dstStart=h+1):v===0&&this.getMinutes()===0&&this.getSeconds()===0&&p!==24&&(this.dstEnd=g)}#r(){return this.#e.toUTC()}}e.CronDate=d,e.default=d})(Wr)),Wr}var jo;function su(){if(jo)return Bn;jo=1,Object.defineProperty(Bn,"__esModule",{value:!0}),Bn.CronMonth=void 0;const e=is(),r=tn(),u=1,s=12,d=Object.freeze([]);let c=class extends r.CronField{static get min(){return u}static get max(){return s}static get chars(){return d}static get daysInMonth(){return e.DAYS_IN_MONTH}constructor(m,p){super(m,p),this.validate()}get values(){return super.values}};return Bn.CronMonth=c,Bn}var Un={},Do;function ou(){if(Do)return Un;Do=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.CronSecond=void 0;const e=tn(),r=0,u=59,s=Object.freeze([]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}};return Un.CronSecond=d,Un}var Eo;function ls(){return Eo||(Eo=1,(function(e){var r=Xt&&Xt.__createBinding||(Object.create?(function(s,d,c,l){l===void 0&&(l=c);var m=Object.getOwnPropertyDescriptor(d,c);(!m||("get"in m?!d.__esModule:m.writable||m.configurable))&&(m={enumerable:!0,get:function(){return d[c]}}),Object.defineProperty(s,l,m)}):(function(s,d,c,l){l===void 0&&(l=c),s[l]=d[c]})),u=Xt&&Xt.__exportStar||function(s,d){for(var c in s)c!=="default"&&!Object.prototype.hasOwnProperty.call(d,c)&&r(d,s,c)};Object.defineProperty(e,"__esModule",{value:!0}),u(Qc(),e),u(Jc(),e),u(eu(),e),u(tn(),e),u(tu(),e),u(nu(),e),u(su(),e),u(ou(),e)})(Xt)),Xt}var Io;function ra(){if(Io)return _n;Io=1,Object.defineProperty(_n,"__esModule",{value:!0}),_n.CronFieldCollection=void 0;const e=ls();let r=class Xn{#e;#n;#o;#s;#r;#t;static from(s,d){return new Xn({second:this.resolveField(e.CronSecond,s.second,d.second),minute:this.resolveField(e.CronMinute,s.minute,d.minute),hour:this.resolveField(e.CronHour,s.hour,d.hour),dayOfMonth:this.resolveField(e.CronDayOfMonth,s.dayOfMonth,d.dayOfMonth),month:this.resolveField(e.CronMonth,s.month,d.month),dayOfWeek:this.resolveField(e.CronDayOfWeek,s.dayOfWeek,d.dayOfWeek)})}static resolveField(s,d,c){return c?c instanceof e.CronField?c:new s(c):d}constructor({second:s,minute:d,hour:c,dayOfMonth:l,month:m,dayOfWeek:p}){if(!s)throw new Error("Validation error, Field second is missing");if(!d)throw new Error("Validation error, Field minute is missing");if(!c)throw new Error("Validation error, Field hour is missing");if(!l)throw new Error("Validation error, Field dayOfMonth is missing");if(!m)throw new Error("Validation error, Field month is missing");if(!p)throw new Error("Validation error, Field dayOfWeek is missing");if(m.values.length===1&&!l.hasLastChar&&p.isWildcard&&!(parseInt(l.values[0],10)<=e.CronMonth.daysInMonth[m.values[0]-1]))throw new Error("Invalid explicit day of month definition");this.#e=s,this.#n=d,this.#o=c,this.#r=m,this.#t=p,this.#s=l}get second(){return this.#e}get minute(){return this.#n}get hour(){return this.#o}get dayOfMonth(){return this.#s}get month(){return this.#r}get dayOfWeek(){return this.#t}static compactField(s){if(s.length===0)return[];const d=[];let c;return s.forEach((l,m,p)=>{if(c===void 0){c={start:l,count:1};return}const h=p[m-1]||c.start,g=p[m+1];if(l==="L"||l==="W"){d.push(c),d.push({start:l,count:1}),c=void 0;return}if(c.step===void 0&&g!==void 0){const v=l-h,x=g-l;if(v<=x){c={...c,count:2,end:l,step:v};return}c.step=1}l-(c.end??0)===c.step?(c.count++,c.end=l):(c.count===1?d.push({start:c.start,count:1}):c.count===2?(d.push({start:c.start,count:1}),d.push({start:c.end??h,count:1})):d.push(c),c={start:l,count:1})}),c&&d.push(c),d}static#c(s,d,c){const l=d.step;return l?l===1&&d.start===s.min&&d.end&&d.end>=c?s.hasQuestionMarkChar?"?":"*":l!==1&&d.start===s.min&&d.end&&d.end>=c-l+1?`*/${l}`:null:null}static#l(s,d){const c=s.step;if(c===1)return`${s.start}-${s.end}`;const l=s.start===0?s.count-1:s.count;if(!c)throw new Error("Unexpected range step");if(!s.end)throw new Error("Unexpected range end");if(c*l>s.end){const m=(h,g)=>{if(typeof s.start!="number")throw new Error("Unexpected range start");return g%c===0?s.start+g:null};if(typeof s.start!="number")throw new Error("Unexpected range start");const p={length:s.end-s.start+1};return Array.from(p,m).filter(h=>h!==null).join(",")}return s.end===d-c+1?`${s.start}/${c}`:`${s.start}-${s.end}/${c}`}stringifyField(s){let d=s.max,c=s.values;if(s instanceof e.CronDayOfWeek){d=6;const m=this.#t.values;c=m[m.length-1]===7?m.slice(0,-1):m}s instanceof e.CronDayOfMonth&&(d=this.#r.values.length===1?e.CronMonth.daysInMonth[this.#r.values[0]-1]:s.max);const l=Xn.compactField(c);if(l.length===1){const m=Xn.#c(s,l[0],d);if(m)return m}return l.map(m=>{const p=m.count===1?m.start.toString():Xn.#l(m,d);return s instanceof e.CronDayOfWeek&&s.nthDay>0?`${p}#${s.nthDay}`:p}).join(",")}stringify(s=!1){const d=[];return s&&d.push(this.stringifyField(this.#e)),d.push(this.stringifyField(this.#n),this.stringifyField(this.#o),this.stringifyField(this.#s),this.stringifyField(this.#r),this.stringifyField(this.#t)),d.join(" ")}serialize(){return{second:this.#e.serialize(),minute:this.#n.serialize(),hour:this.#o.serialize(),dayOfMonth:this.#s.serialize(),month:this.#r.serialize(),dayOfWeek:this.#t.serialize()}}};return _n.CronFieldCollection=r,_n}var qr={},No;function sa(){return No||(No=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CronExpression=e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE=e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE=void 0;const r=is();e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE="Out of the time span range",e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE="Invalid expression, loop limit exceeded";const u=1e4;class s{#e;#n;#o;#s;#r;#t;#c=null;#l=!1;constructor(c,l){this.#e=l,this.#n=l.tz,this.#s=l.startDate?new r.CronDate(l.startDate,this.#n):null,this.#r=l.endDate?new r.CronDate(l.endDate,this.#n):null;let m=l.currentDate??l.startDate;if(m){const p=new r.CronDate(m,this.#n);this.#s&&p.getTime()<this.#s.getTime()?m=this.#s:this.#r&&p.getTime()>this.#r.getTime()&&(m=this.#r)}this.#o=new r.CronDate(m,this.#n),this.#t=c}get fields(){return this.#t}static fieldsToExpression(c,l){return new s(c,l||{})}static#a(c,l){return l.some(m=>m===c)}#i(c,l){return c[l?c.length-1:0]}#d(c){const l=`${c.getFullYear()}-${c.getMonth()+1}-${c.getDate()}`;if(this.#c===l)return this.#l;const m=new r.CronDate(c);m.setStartOfDay();const p=new r.CronDate(c);return p.setEndOfDay(),this.#c=l,this.#l=m.getUTCOffset()!==p.getUTCOffset(),this.#l}#h(c,l,m){const p=this.#t.second.values,h=c.getSeconds(),g=this.#t.second.findNearestValue(h,m);if(g!==null){c.setSeconds(g);return}c.applyDateOperation(l,r.TimeUnit.Minute,this.#t.hour.values.length),c.setSeconds(this.#i(p,m))}#p(c,l,m){const p=this.#t.minute.values,h=this.#t.second.values,g=c.getMinutes(),v=this.#t.minute.findNearestValue(g,m);if(v!==null){c.setMinutes(v),c.setSeconds(this.#i(h,m));return}c.applyDateOperation(l,r.TimeUnit.Hour,this.#t.hour.values.length),c.setMinutes(this.#i(p,m)),c.setSeconds(this.#i(h,m))}static#m(c,l){const m=l.isLastWeekdayOfMonth();return c.some(p=>{const h=parseInt(p.toString().charAt(0),10)%7;if(Number.isNaN(h))throw new Error(`Invalid last weekday of the month expression: ${p}`);return l.getDay()===h&&m})}next(){return this.#u()}prev(){return this.#u(!0)}hasNext(){const c=this.#o;try{return this.#u(),!0}catch{return!1}finally{this.#o=c}}hasPrev(){const c=this.#o;try{return this.#u(!0),!0}catch{return!1}finally{this.#o=c}}take(c){const l=[];if(c>=0)for(let m=0;m<c;m++)try{l.push(this.next())}catch{return l}else for(let m=0;m>c;m--)try{l.push(this.prev())}catch{return l}return l}reset(c){this.#o=new r.CronDate(c||this.#e.currentDate,this.#n)}stringify(c=!1){return this.#t.stringify(c)}includesDate(c){const{second:l,minute:m,hour:p,month:h}=this.#t,g=new r.CronDate(c,this.#n);return!(!l.values.includes(g.getSeconds())||!m.values.includes(g.getMinutes())||!p.values.includes(g.getHours())||!h.values.includes(g.getMonth()+1)||!this.#f(g)||this.#t.dayOfWeek.nthDay>0&&Math.ceil(g.getDate()/7)!==this.#t.dayOfWeek.nthDay)}toString(){return this.#e.expression||this.stringify(!0)}#f(c){const l=this.#t.dayOfMonth.isWildcard,m=!l,p=this.#t.dayOfWeek.isWildcard,h=!p,g=s.#a(c.getDate(),this.#t.dayOfMonth.values)||this.#t.dayOfMonth.hasLastChar&&c.isLastDayOfMonth(),v=s.#a(c.getDay(),this.#t.dayOfWeek.values)||this.#t.dayOfWeek.hasLastChar&&s.#m(this.#t.dayOfWeek.values,c);return!!(m&&h&&(g||v)||g&&!h||l&&!p&&v)}#g(c,l,m){const p=this.#t.hour.values,h=p,g=c.getHours(),v=s.#a(g,p),x=c.dstEnd===g;if(c.dstStart!==null&&c.dstStart===g-1&&s.#a(c.dstStart,p))return!0;if(x&&!m)return c.dstEnd=null,c.applyDateOperation(r.DateMathOp.Add,r.TimeUnit.Hour,h.length),!1;if(v)return!0;c.dstStart=null;const y=this.#t.hour.findNearestValue(g,m);if(y===null)return c.applyDateOperation(l,r.TimeUnit.Day,h.length),!1;if(this.#d(c)){const C=m?g-y:y-g;for(let w=0;w<C&&(c.applyDateOperation(l,r.TimeUnit.Hour,h.length),!(!m&&c.getHours()>=y||m&&c.getHours()<=y));w++);}else c.setHours(y);return c.setMinutes(this.#i(this.#t.minute.values,m)),c.setSeconds(this.#i(this.#t.second.values,m)),!1}#y(c){if(!this.#s&&!this.#r)return;const l=c.getTime();if(this.#s&&l<this.#s.getTime())throw new Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE);if(this.#r&&l>this.#r.getTime())throw new Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE)}#u(c=!1){const l=c?r.DateMathOp.Subtract:r.DateMathOp.Add,m=new r.CronDate(this.#o),p=m.getTime();let h=0;for(;++h<u;){if(this.#y(m),!this.#f(m)){m.applyDateOperation(l,r.TimeUnit.Day,this.#t.hour.values.length);continue}if(!(this.#t.dayOfWeek.nthDay<=0||Math.ceil(m.getDate()/7)===this.#t.dayOfWeek.nthDay)){m.applyDateOperation(l,r.TimeUnit.Day,this.#t.hour.values.length);continue}if(!s.#a(m.getMonth()+1,this.#t.month.values)){m.applyDateOperation(l,r.TimeUnit.Month,this.#t.hour.values.length);continue}if(this.#g(m,l,c)){if(!s.#a(m.getMinutes(),this.#t.minute.values)){this.#p(m,l,c);continue}if(!s.#a(m.getSeconds(),this.#t.second.values)){this.#h(m,l,c);continue}if(p===m.getTime()){(l==="Add"||m.getMilliseconds()===0)&&m.applyDateOperation(l,r.TimeUnit.Second,this.#t.hour.values.length);continue}break}}if(h>u)throw new Error(e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE);return m.getMilliseconds()!==0&&m.setMilliseconds(0),this.#o=m,m}[Symbol.iterator](){return{next:()=>{try{return{value:this.#u(),done:!1}}catch{return{value:void 0,done:!0}}}}}}e.CronExpression=s,e.default=s})(qr)),qr}var mr={},Fo;function au(){if(Fo)return mr;Fo=1,Object.defineProperty(mr,"__esModule",{value:!0}),mr.seededRandom=u;function e(s){let d=2166136261;for(let c=0;c<s.length;c++)d^=s.charCodeAt(c),d=Math.imul(d,16777619);return()=>d>>>0}function r(s){return()=>{let d=s+=1831565813;return d=Math.imul(d^d>>>15,d|1),d^=d+Math.imul(d^d>>>7,d|61),((d^d>>>14)>>>0)/4294967296}}function u(s){const d=s?e(s)():Math.floor(Math.random()*1e10);return r(d)}return mr}var Ao;function ts(){if(Ao)return it;Ao=1,Object.defineProperty(it,"__esModule",{value:!0}),it.CronExpressionParser=it.DayOfWeek=it.Months=it.CronUnit=it.PredefinedExpressions=void 0;const e=ra(),r=sa(),u=au(),s=ls();var d;(function(h){h["@yearly"]="0 0 0 1 1 *",h["@annually"]="0 0 0 1 1 *",h["@monthly"]="0 0 0 1 * *",h["@weekly"]="0 0 0 * * 0",h["@daily"]="0 0 0 * * *",h["@hourly"]="0 0 * * * *",h["@minutely"]="0 * * * * *",h["@secondly"]="* * * * * *",h["@weekdays"]="0 0 0 * * 1-5",h["@weekends"]="0 0 0 * * 0,6"})(d||(it.PredefinedExpressions=d={}));var c;(function(h){h.Second="Second",h.Minute="Minute",h.Hour="Hour",h.DayOfMonth="DayOfMonth",h.Month="Month",h.DayOfWeek="DayOfWeek"})(c||(it.CronUnit=c={}));var l;(function(h){h[h.jan=1]="jan",h[h.feb=2]="feb",h[h.mar=3]="mar",h[h.apr=4]="apr",h[h.may=5]="may",h[h.jun=6]="jun",h[h.jul=7]="jul",h[h.aug=8]="aug",h[h.sep=9]="sep",h[h.oct=10]="oct",h[h.nov=11]="nov",h[h.dec=12]="dec"})(l||(it.Months=l={}));var m;(function(h){h[h.sun=0]="sun",h[h.mon=1]="mon",h[h.tue=2]="tue",h[h.wed=3]="wed",h[h.thu=4]="thu",h[h.fri=5]="fri",h[h.sat=6]="sat"})(m||(it.DayOfWeek=m={}));let p=class lt{static parse(g,v={}){const{strict:x=!1,hashSeed:y}=v,C=(0,u.seededRandom)(y);g=d[g]||g;const w=lt.#e(g,x);if(!(w.dayOfMonth==="*"||w.dayOfWeek==="*"||!x))throw new Error("Cannot use both dayOfMonth and dayOfWeek together in strict mode!");const k=lt.#n(c.Second,w.second,s.CronSecond.constraints,C),O=lt.#n(c.Minute,w.minute,s.CronMinute.constraints,C),M=lt.#n(c.Hour,w.hour,s.CronHour.constraints,C),j=lt.#n(c.Month,w.month,s.CronMonth.constraints,C),E=lt.#n(c.DayOfMonth,w.dayOfMonth,s.CronDayOfMonth.constraints,C),{dayOfWeek:$,nthDayOfWeek:U}=lt.#d(w.dayOfWeek),P=lt.#n(c.DayOfWeek,$,s.CronDayOfWeek.constraints,C),K=new e.CronFieldCollection({second:new s.CronSecond(k,{rawValue:w.second}),minute:new s.CronMinute(O,{rawValue:w.minute}),hour:new s.CronHour(M,{rawValue:w.hour}),dayOfMonth:new s.CronDayOfMonth(E,{rawValue:w.dayOfMonth}),month:new s.CronMonth(j,{rawValue:w.month}),dayOfWeek:new s.CronDayOfWeek(P,{rawValue:w.dayOfWeek,nthDayOfWeek:U})});return new r.CronExpression(K,{...v,expression:g})}static#e(g,v){if(v&&!g.length)throw new Error("Invalid cron expression");g=g||"0 * * * * *";const x=g.trim().split(/\s+/);if(v&&x.length<6)throw new Error("Invalid cron expression, expected 6 fields");if(x.length>6)throw new Error("Invalid cron expression, too many fields");const y=["*","*","*","*","*","0"];x.length<y.length&&x.unshift(...y.slice(x.length));const[C,w,k,O,M,j]=x;return{second:C,minute:w,hour:k,dayOfMonth:O,month:M,dayOfWeek:j}}static#n(g,v,x,y){if((g===c.Month||g===c.DayOfWeek)&&(v=v.replace(/[a-z]{3}/gi,C=>{C=C.toLowerCase();const w=l[C]||m[C];if(w===void 0)throw new Error(`Validation error, cannot resolve alias "${C}"`);return w.toString()})),!x.validChars.test(v))throw new Error(`Invalid characters, got value: ${v}`);return v=this.#o(v,x),v=this.#s(v,x,y),this.#r(g,v,x)}static#o(g,v){return g.replace(/[*?]/g,v.min+"-"+v.max)}static#s(g,v,x){const y=x();return g.replace(/H(?:\((\d+)-(\d+)\))?(?:\/(\d+))?/g,(C,w,k,O)=>{if(w&&k&&O){const M=parseInt(w,10),j=parseInt(k,10),E=parseInt(O,10);if(M>j)throw new Error(`Invalid range: ${M}-${j}, min > max`);if(E<=0)throw new Error(`Invalid step: ${E}, must be positive`);const $=Math.max(M,v.min),U=Math.floor(y*E),P=[];for(let K=Math.floor($/E)*E+U;K<=j;K+=E)K>=$&&P.push(K);return P.join(",")}else if(w&&k){const M=parseInt(w,10),j=parseInt(k,10);if(M>j)throw new Error(`Invalid range: ${M}-${j}, min > max`);return String(Math.floor(y*(j-M+1))+M)}else if(O){const M=parseInt(O,10);if(M<=0)throw new Error(`Invalid step: ${M}, must be positive`);const j=Math.floor(y*M),E=[];for(let $=Math.floor(v.min/M)*M+j;$<=v.max;$+=M)$>=v.min&&E.push($);return E.join(",")}else return String(Math.floor(y*(v.max-v.min+1)+v.min))})}static#r(g,v,x){const y=[];function C(k,O){if(Array.isArray(k))y.push(...k);else if(lt.#h(O,k))y.push(k);else{const M=parseInt(k.toString(),10);if(!(M>=O.min&&M<=O.max))throw new Error(`Constraint error, got value ${k} expected range ${O.min}-${O.max}`);y.push(g===c.DayOfWeek?M%7:k)}}return v.split(",").forEach(k=>{if(!(k.length>0))throw new Error("Invalid list value format");C(lt.#t(g,k,x),x)}),y}static#t(g,v,x){const y=v.split("/");if(y.length>2)throw new Error(`Invalid repeat: ${v}`);return y.length===2?(y[0].includes("-")||(y[0]=`${y[0]}-${x.max}`),lt.#i(g,y[0],parseInt(y[1],10),x)):lt.#i(g,v,1,x)}static#c(g,v,x){if(!(!isNaN(g)&&!isNaN(v)&&g>=x.min&&v<=x.max))throw new Error(`Constraint error, got range ${g}-${v} expected range ${x.min}-${x.max}`);if(g>v)throw new Error(`Invalid range: ${g}-${v}, min(${g}) > max(${v})`)}static#l(g){if(!(!isNaN(g)&&g>0))throw new Error(`Constraint error, cannot repeat at every ${g} time.`)}static#a(g,v,x,y){const C=[];g===c.DayOfWeek&&x%7===0&&C.push(0);for(let w=v;w<=x;w+=y)C.indexOf(w)===-1&&C.push(w);return C}static#i(g,v,x,y){const C=v.split("-");if(C.length<=1)return isNaN(+v)?v:+v;const[w,k]=C.map(O=>parseInt(O,10));return this.#c(w,k,y),this.#l(x),this.#a(g,w,k,x)}static#d(g){const v=g.split("#");if(v.length<=1)return{dayOfWeek:v[0]};const x=+v[v.length-1],y=g.match(/([,-/])/);if(y!==null)throw new Error(`Constraint error, invalid dayOfWeek \`#\` and \`${y?.[0]}\` special characters are incompatible`);if(!(v.length<=2&&!isNaN(x)&&x>=1&&x<=5))throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return{dayOfWeek:v[0],nthDayOfWeek:x}}static#h(g,v){return g.chars.some(x=>v.toString().includes(x))}};return it.CronExpressionParser=p,it}var St={};const iu={},lu=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"})),Ro=o.getAugmentedNamespace(lu);var $o;function cu(){if($o)return St;$o=1;var e=St&&St.__createBinding||(Object.create?(function(c,l,m,p){p===void 0&&(p=m);var h=Object.getOwnPropertyDescriptor(l,m);(!h||("get"in h?!l.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return l[m]}}),Object.defineProperty(c,p,h)}):(function(c,l,m,p){p===void 0&&(p=m),c[p]=l[m]})),r=St&&St.__setModuleDefault||(Object.create?(function(c,l){Object.defineProperty(c,"default",{enumerable:!0,value:l})}):function(c,l){c.default=l}),u=St&&St.__importStar||(function(){var c=function(l){return c=Object.getOwnPropertyNames||function(m){var p=[];for(var h in m)Object.prototype.hasOwnProperty.call(m,h)&&(p[p.length]=h);return p},c(l)};return function(l){if(l&&l.__esModule)return l;var m={};if(l!=null)for(var p=c(l),h=0;h<p.length;h++)p[h]!=="default"&&e(m,l,p[h]);return r(m,l),m}})();Object.defineProperty(St,"__esModule",{value:!0}),St.CronFileParser=void 0;const s=ts();let d=class yr{static async parseFile(l){const{readFile:m}=await Promise.resolve().then(()=>u(Ro)),p=await m(l,"utf8");return yr.#e(p)}static parseFileSync(l){const{readFileSync:m}=Ro,p=m(l,"utf8");return yr.#e(p)}static#e(l){const m=l.split(`
|
|
5
|
-
`),p={variables:{},expressions:[],errors:{}};for(const h of m){const g=h.trim();if(g.length===0||g.startsWith("#"))continue;const v=g.match(/^(.*)=(.*)$/);if(v){const[,x,y]=v;p.variables[x]=y.replace(/["']/g,"");continue}try{const x=yr.#n(g);p.expressions.push(x.interval)}catch(x){p.errors[g]=x}}return p}static#n(l){const m=l.split(" ");return{interval:s.CronExpressionParser.parse(m.slice(0,5).join(" ")),command:m.slice(5,m.length)}}};return St.CronFileParser=d,St}var Po;function uu(){return Po||(Po=1,(function(e){var r=Kt&&Kt.__createBinding||(Object.create?(function(h,g,v,x){x===void 0&&(x=v);var y=Object.getOwnPropertyDescriptor(g,v);(!y||("get"in y?!g.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return g[v]}}),Object.defineProperty(h,x,y)}):(function(h,g,v,x){x===void 0&&(x=v),h[x]=g[v]})),u=Kt&&Kt.__exportStar||function(h,g){for(var v in h)v!=="default"&&!Object.prototype.hasOwnProperty.call(g,v)&&r(g,h,v)};Object.defineProperty(e,"__esModule",{value:!0}),e.CronFileParser=e.CronExpressionParser=e.CronExpression=e.CronFieldCollection=e.CronDate=void 0;const s=ts();var d=is();Object.defineProperty(e,"CronDate",{enumerable:!0,get:function(){return d.CronDate}});var c=ra();Object.defineProperty(e,"CronFieldCollection",{enumerable:!0,get:function(){return c.CronFieldCollection}});var l=sa();Object.defineProperty(e,"CronExpression",{enumerable:!0,get:function(){return l.CronExpression}});var m=ts();Object.defineProperty(e,"CronExpressionParser",{enumerable:!0,get:function(){return m.CronExpressionParser}});var p=cu();Object.defineProperty(e,"CronFileParser",{enumerable:!0,get:function(){return p.CronFileParser}}),u(ls(),e),e.default=s.CronExpressionParser})(Kt)),Kt}var du=uu(),zr={exports:{}},Lo;function hu(){return Lo||(Lo=1,(function(e,r){(function(s,d){e.exports=d()})(globalThis,()=>(()=>{var u={949:((l,m,p)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.CronParser=void 0;var h=p(515),g=(function(){function v(x,y,C){y===void 0&&(y=!0),C===void 0&&(C=!1),this.expression=x,this.dayOfWeekStartIndexZero=y,this.monthStartIndexZero=C}return v.prototype.parse=function(){var x,y,C=(x=this.expression)!==null&&x!==void 0?x:"";if(C==="@reboot")return y=["@reboot","","","","","",""],y;if(C.startsWith("@")){var w=this.parseSpecial(this.expression);y=this.extractParts(w)}else y=this.extractParts(this.expression);return this.normalize(y),this.validate(y),y},v.prototype.parseSpecial=function(x){var y={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},C=y[x];if(!C)throw new Error("Unknown special expression.");return C},v.prototype.extractParts=function(x){if(!this.expression)throw new Error("cron expression is empty");for(var y=x.trim().split(/[ ]+/),C=0;C<y.length;C++)if(y[C].includes(",")){var w=y[C].split(",").map(function(O){return O.trim()}).filter(function(O){return O!==""}).map(function(O){return isNaN(Number(O))?O:Number(O)}).filter(function(O){return O!==null&&O!==""});w.length===0&&w.push("*"),w.sort(function(O,M){return O!==null&&M!==null?O-M:0}),y[C]=w.map(function(O){return O!==null?O.toString():""}).join(",")}if(y.length<5)throw new Error("Expression has only ".concat(y.length," part").concat(y.length==1?"":"s",". At least 5 parts are required."));if(y.length==5)y.unshift(""),y.push("");else if(y.length==6){var k=/\d{4}$/.test(y[5])||y[4]=="?"||y[2]=="?";k?y.unshift(""):y.push("")}else if(y.length>7)throw new Error("Expression has ".concat(y.length," parts; too many!"));return y},v.prototype.normalize=function(x){var y=this;if(x[3]=x[3].replace("?","*"),x[5]=x[5].replace("?","*"),x[2]=x[2].replace("?","*"),x[0].indexOf("0/")==0&&(x[0]=x[0].replace("0/","*/")),x[1].indexOf("0/")==0&&(x[1]=x[1].replace("0/","*/")),x[2].indexOf("0/")==0&&(x[2]=x[2].replace("0/","*/")),x[3].indexOf("1/")==0&&(x[3]=x[3].replace("1/","*/")),x[4].indexOf("1/")==0&&(x[4]=x[4].replace("1/","*/")),x[6].indexOf("1/")==0&&(x[6]=x[6].replace("1/","*/")),x[5]=x[5].replace(/(^\d)|([^#/\s]\d)/g,function($){var U=$.replace(/\D/,""),P=U;return y.dayOfWeekStartIndexZero?U=="7"&&(P="0"):P=(parseInt(U)-1).toString(),$.replace(U,P)}),x[5]=="L"&&(x[5]="6"),x[3]=="?"&&(x[3]="*"),x[3].indexOf("W")>-1&&(x[3].indexOf(",")>-1||x[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var C={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var w in C)x[5]=x[5].replace(new RegExp(w,"gi"),C[w].toString());x[4]=x[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function($){var U=$.replace(/\D/,""),P=U;return y.monthStartIndexZero&&(P=(parseInt(U)+1).toString()),$.replace(U,P)});var k={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var O in k)x[4]=x[4].replace(new RegExp(O,"gi"),k[O].toString());x[0]=="0"&&(x[0]=""),!/\*|\-|\,|\//.test(x[2])&&(/\*|\//.test(x[1])||/\*|\//.test(x[0]))&&(x[2]+="-".concat(x[2]));for(var M=0;M<x.length;M++)if(x[M].indexOf(",")!=-1&&(x[M]=x[M].split(",").filter(function($){return $!==""}).join(",")||"*"),x[M]=="*/1"&&(x[M]="*"),x[M].indexOf("/")>-1&&!/^\*|\-|\,/.test(x[M])){var j=null;switch(M){case 4:j="12";break;case 5:j="6";break;case 6:j="9999";break;default:j=null;break}if(j!==null){var E=x[M].split("/");x[M]="".concat(E[0],"-").concat(j,"/").concat(E[1])}}},v.prototype.validate=function(x){var y="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(x[0],y),this.validateOnlyExpectedCharactersFound(x[1],y),this.validateOnlyExpectedCharactersFound(x[2],y),this.validateOnlyExpectedCharactersFound(x[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(x[4],y),this.validateOnlyExpectedCharactersFound(x[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(x[6],y),this.validateAnyRanges(x)},v.prototype.validateAnyRanges=function(x){h.default.secondRange(x[0]),h.default.minuteRange(x[1]),h.default.hourRange(x[2]),h.default.dayOfMonthRange(x[3]),h.default.monthRange(x[4],this.monthStartIndexZero),h.default.dayOfWeekRange(x[5],this.dayOfWeekStartIndexZero)},v.prototype.validateOnlyExpectedCharactersFound=function(x,y){var C=x.match(new RegExp("[^".concat(y,"]+"),"gi"));if(C&&C.length)throw new Error("Expression contains invalid values: '".concat(C.toString(),"'"))},v})();m.CronParser=g}),333:((l,m,p)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.ExpressionDescriptor=void 0;var h=p(823),g=p(949),v=(function(){function x(y,C){if(this.expression=y,this.options=C,this.expressionParts=new Array(5),!this.options.locale&&x.defaultLocale&&(this.options.locale=x.defaultLocale),!x.locales[this.options.locale]){var w=Object.keys(x.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(w,"'.")),this.options.locale=w}this.i18n=x.locales[this.options.locale],C.use24HourTimeFormat===void 0&&(C.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return x.toString=function(y,C){var w=C===void 0?{}:C,k=w.throwExceptionOnParseError,O=k===void 0?!0:k,M=w.verbose,j=M===void 0?!1:M,E=w.dayOfWeekStartIndexZero,$=E===void 0?!0:E,U=w.monthStartIndexZero,P=U===void 0?!1:U,K=w.use24HourTimeFormat,A=w.locale,L=A===void 0?null:A,V={throwExceptionOnParseError:O,verbose:j,dayOfWeekStartIndexZero:$,monthStartIndexZero:P,use24HourTimeFormat:K,locale:L};V.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var N=new x(y,V);return N.getFullDescription()},x.initialize=function(y,C){C===void 0&&(C="en"),x.specialCharacters=["/","-",",","*"],x.defaultLocale=C,y.load(x.locales)},x.prototype.getFullDescription=function(){var y,C,w="";try{var k=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=k.parse(),this.expressionParts[0]==="@reboot")return((C=(y=this.i18n).atReboot)===null||C===void 0?void 0:C.call(y))||"Run once, at startup";var O=this.getTimeOfDayDescription(),M=this.getDayOfMonthDescription(),j=this.getMonthDescription(),E=this.getDayOfWeekDescription(),$=this.getYearDescription();w+=O+M+E+j+$,w=this.transformVerbosity(w,!!this.options.verbose),w=w.charAt(0).toLocaleUpperCase()+w.substr(1)}catch(U){if(!this.options.throwExceptionOnParseError)w=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(U)}return w},x.prototype.getTimeOfDayDescription=function(){var y=this.expressionParts[0],C=this.expressionParts[1],w=this.expressionParts[2],k="";if(!h.StringUtilities.containsAny(C,x.specialCharacters)&&!h.StringUtilities.containsAny(w,x.specialCharacters)&&!h.StringUtilities.containsAny(y,x.specialCharacters))k+=this.i18n.atSpace()+this.formatTime(w,C,y);else if(!y&&C.indexOf("-")>-1&&!(C.indexOf(",")>-1)&&!(C.indexOf("/")>-1)&&!h.StringUtilities.containsAny(w,x.specialCharacters)){var O=C.split("-");k+=h.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(w,O[0],""),this.formatTime(w,O[1],""))}else if(!y&&w.indexOf(",")>-1&&w.indexOf("-")==-1&&w.indexOf("/")==-1&&!h.StringUtilities.containsAny(C,x.specialCharacters)){var M=w.split(",");k+=this.i18n.at();for(var j=0;j<M.length;j++)k+=" ",k+=this.formatTime(M[j],C,""),j<M.length-2&&(k+=","),j==M.length-2&&(k+=this.i18n.spaceAnd())}else{var E=this.getSecondsDescription(),$=this.getMinutesDescription(),U=this.getHoursDescription();if(k+=E,k&&$&&(k+=", "),k+=$,$===U)return k;k&&U&&(k+=", "),k+=U}return k},x.prototype.getSecondsDescription=function(){var y=this,C=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(w){return w},function(w){return h.StringUtilities.format(y.i18n.everyX0Seconds(w),w)},function(w){return y.i18n.secondsX0ThroughX1PastTheMinute()},function(w){return w=="0"?"":parseInt(w)<20?y.i18n.atX0SecondsPastTheMinute(w):y.i18n.atX0SecondsPastTheMinuteGt20()||y.i18n.atX0SecondsPastTheMinute(w)});return C},x.prototype.getMinutesDescription=function(){var y=this,C=this.expressionParts[0],w=this.expressionParts[2],k=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(O){return O},function(O){return h.StringUtilities.format(y.i18n.everyX0Minutes(O),O)},function(O){return y.i18n.minutesX0ThroughX1PastTheHour()},function(O){try{return O=="0"&&w.indexOf("/")==-1&&C==""?y.i18n.everyHour():parseInt(O)<20?y.i18n.atX0MinutesPastTheHour(O):y.i18n.atX0MinutesPastTheHourGt20()||y.i18n.atX0MinutesPastTheHour(O)}catch{return y.i18n.atX0MinutesPastTheHour(O)}});return k},x.prototype.getHoursDescription=function(){var y=this,C=this.expressionParts[2],w=0,k=[];C.split("/")[0].split(",").forEach(function(j){var E=j.split("-");E.length===2&&k.push({value:E[1],index:w+1}),w+=E.length});var O=0,M=this.getSegmentDescription(C,this.i18n.everyHour(),function(j){var E=k.find(function(U){return U.value===j&&U.index===O}),$=E&&y.expressionParts[1]!=="0";return O++,$?y.formatTime(j,"59",""):y.formatTime(j,"0","")},function(j){return h.StringUtilities.format(y.i18n.everyX0Hours(j),j)},function(j){return y.i18n.betweenX0AndX1()},function(j){return y.i18n.atX0()});return M},x.prototype.getDayOfWeekDescription=function(){var y=this,C=this.i18n.daysOfTheWeek(),w=null;return this.expressionParts[5]=="*"?w="":w=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(k,O){var M=k;k.indexOf("#")>-1?M=k.substring(0,k.indexOf("#")):k.indexOf("L")>-1&&(M=M.replace("L",""));var j=parseInt(M),E=y.i18n.daysOfTheWeekInCase?y.i18n.daysOfTheWeekInCase(O)[j]:C[j];if(k.indexOf("#")>-1){var $=null,U=k.substring(k.indexOf("#")+1),P=k.substring(0,k.indexOf("#"));switch(U){case"1":$=y.i18n.first(P);break;case"2":$=y.i18n.second(P);break;case"3":$=y.i18n.third(P);break;case"4":$=y.i18n.fourth(P);break;case"5":$=y.i18n.fifth(P);break}E=$+" "+E}return E},function(k){return parseInt(k)==1?"":h.StringUtilities.format(y.i18n.commaEveryX0DaysOfTheWeek(k),k)},function(k){var O=k.substring(0,k.indexOf("-")),M=y.expressionParts[3]!="*";return M?y.i18n.commaAndX0ThroughX1(O):y.i18n.commaX0ThroughX1(O)},function(k){var O=null;if(k.indexOf("#")>-1){var M=k.substring(k.indexOf("#")+1),j=k.substring(0,k.indexOf("#"));O=y.i18n.commaOnThe(M,j).trim()+y.i18n.spaceX0OfTheMonth()}else if(k.indexOf("L")>-1)O=y.i18n.commaOnTheLastX0OfTheMonth(k.replace("L",""));else{var E=y.expressionParts[3]!="*";O=E?y.i18n.commaAndOnX0():y.i18n.commaOnlyOnX0(k)}return O}),w},x.prototype.getMonthDescription=function(){var y=this,C=this.i18n.monthsOfTheYear(),w=this.getSegmentDescription(this.expressionParts[4],"",function(k,O){return O&&y.i18n.monthsOfTheYearInCase?y.i18n.monthsOfTheYearInCase(O)[parseInt(k)-1]:C[parseInt(k)-1]},function(k){return parseInt(k)==1?"":h.StringUtilities.format(y.i18n.commaEveryX0Months(k),k)},function(k){return y.i18n.commaMonthX0ThroughMonthX1()||y.i18n.commaX0ThroughX1()},function(k){return y.i18n.commaOnlyInMonthX0?y.i18n.commaOnlyInMonthX0():y.i18n.commaOnlyInX0()});return w},x.prototype.getDayOfMonthDescription=function(){var y=this,C=null,w=this.expressionParts[3];switch(w){case"L":C=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":C=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var k=w.match(/(\d{1,2}W)|(W\d{1,2})/);if(k){var O=parseInt(k[0].replace("W","")),M=O==1?this.i18n.firstWeekday():h.StringUtilities.format(this.i18n.weekdayNearestDayX0(),O.toString());C=h.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),M);break}else{var j=w.match(/L-(\d{1,2})/);if(j){var E=j[1];C=h.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(E),E);break}else{if(w=="*"&&this.expressionParts[5]!="*")return"";C=this.getSegmentDescription(w,this.i18n.commaEveryDay(),function($){return $=="L"?y.i18n.lastDay():y.i18n.dayX0?h.StringUtilities.format(y.i18n.dayX0(),$):$},function($){return $=="1"?y.i18n.commaEveryDay():y.i18n.commaEveryX0Days($)},function($){return y.i18n.commaBetweenDayX0AndX1OfTheMonth($)},function($){return y.i18n.commaOnDayX0OfTheMonth($)})}break}}return C},x.prototype.getYearDescription=function(){var y=this,C=this.getSegmentDescription(this.expressionParts[6],"",function(w){return/^\d+$/.test(w)?new Date(parseInt(w),1).getFullYear().toString():w},function(w){return h.StringUtilities.format(y.i18n.commaEveryX0Years(w),w)},function(w){return y.i18n.commaYearX0ThroughYearX1()||y.i18n.commaX0ThroughX1()},function(w){return y.i18n.commaOnlyInYearX0?y.i18n.commaOnlyInYearX0():y.i18n.commaOnlyInX0()});return C},x.prototype.getSegmentDescription=function(y,C,w,k,O,M){var j=null,E=y.indexOf("/")>-1,$=y.indexOf("-")>-1,U=y.indexOf(",")>-1;if(!y)j="";else if(y==="*")j=C;else if(!E&&!$&&!U)j=h.StringUtilities.format(M(y),w(y));else if(U){for(var P=y.split(","),K="",A=0;A<P.length;A++)if(A>0&&P.length>2&&(K+=",",A<P.length-1&&(K+=" ")),A>0&&P.length>1&&(A==P.length-1||P.length==2)&&(K+="".concat(this.i18n.spaceAnd()," ")),P[A].indexOf("/")>-1||P[A].indexOf("-")>-1){var L=P[A].indexOf("-")>-1&&P[A].indexOf("/")==-1,V=this.getSegmentDescription(P[A],C,w,k,L?this.i18n.commaX0ThroughX1:O,M);L&&(V=V.replace(", ","")),K+=V}else E?K+=this.getSegmentDescription(P[A],C,w,k,O,M):K+=w(P[A]);E?j=K:j=h.StringUtilities.format(M(y),K)}else if(E){var P=y.split("/");if(j=h.StringUtilities.format(k(P[1]),P[1]),P[0].indexOf("-")>-1){var N=this.generateRangeSegmentDescription(P[0],O,w);N.indexOf(", ")!=0&&(j+=", "),j+=N}else if(P[0].indexOf("*")==-1){var _=h.StringUtilities.format(M(P[0]),w(P[0]));_=_.replace(", ",""),j+=h.StringUtilities.format(this.i18n.commaStartingX0(),_)}}else $&&(j=this.generateRangeSegmentDescription(y,O,w));return j},x.prototype.generateRangeSegmentDescription=function(y,C,w){var k="",O=y.split("-"),M=w(O[0],1),j=w(O[1],2),E=C(y);return k+=h.StringUtilities.format(E,M,j),k},x.prototype.formatTime=function(y,C,w){var k=0,O=0,M=parseInt(y)+k,j=parseInt(C)+O;j>=60?(j-=60,M+=1):j<0&&(j+=60,M-=1),M>=24?M=M-24:M<0&&(M=24+M);var E="",$=!1;this.options.use24HourTimeFormat||($=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),E=$?"".concat(this.getPeriod(M)," "):" ".concat(this.getPeriod(M)),M>12&&(M-=12),M===0&&(M=12));var U="";return w&&(U=":".concat(("00"+w).substring(w.length))),"".concat($?E:"").concat(("00"+M.toString()).substring(M.toString().length),":").concat(("00"+j.toString()).substring(j.toString().length)).concat(U).concat($?"":E)},x.prototype.transformVerbosity=function(y,C){if(!C&&(y=y.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),y=y.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),y=y.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),y=y.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var w=0,k=Object.entries(this.i18n.conciseVerbosityReplacements());w<k.length;w++){var O=k[w],M=O[0],j=O[1];y=y.replace(new RegExp(M,"g"),j)}return y},x.prototype.getPeriod=function(y){return y>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},x.locales={},x})();m.ExpressionDescriptor=v}),747:((l,m,p)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.enLocaleLoader=void 0;var h=p(486),g=(function(){function v(){}return v.prototype.load=function(x){x.en=new h.en},v})();m.enLocaleLoader=g}),486:((l,m)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.en=void 0;var p=(function(){function h(){}return h.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},h.prototype.atX0MinutesPastTheHourGt20=function(){return null},h.prototype.commaMonthX0ThroughMonthX1=function(){return null},h.prototype.commaYearX0ThroughYearX1=function(){return null},h.prototype.use24HourTimeFormatByDefault=function(){return!1},h.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},h.prototype.everyMinute=function(){return"every minute"},h.prototype.everyHour=function(){return"every hour"},h.prototype.atSpace=function(){return"At "},h.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},h.prototype.at=function(){return"At"},h.prototype.spaceAnd=function(){return" and"},h.prototype.everySecond=function(){return"every second"},h.prototype.everyX0Seconds=function(){return"every %s seconds"},h.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},h.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},h.prototype.everyX0Minutes=function(){return"every %s minutes"},h.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},h.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},h.prototype.everyX0Hours=function(){return"every %s hours"},h.prototype.betweenX0AndX1=function(){return"between %s and %s"},h.prototype.atX0=function(){return"at %s"},h.prototype.commaEveryDay=function(){return", every day"},h.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},h.prototype.commaX0ThroughX1=function(){return", %s through %s"},h.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},h.prototype.first=function(){return"first"},h.prototype.second=function(){return"second"},h.prototype.third=function(){return"third"},h.prototype.fourth=function(){return"fourth"},h.prototype.fifth=function(){return"fifth"},h.prototype.commaOnThe=function(){return", on the "},h.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},h.prototype.lastDay=function(){return"the last day"},h.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},h.prototype.commaOnlyOnX0=function(){return", only on %s"},h.prototype.commaAndOnX0=function(){return", and on %s"},h.prototype.commaEveryX0Months=function(){return", every %s months"},h.prototype.commaOnlyInX0=function(){return", only in %s"},h.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},h.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},h.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},h.prototype.firstWeekday=function(){return"first weekday"},h.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},h.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},h.prototype.commaEveryX0Days=function(){return", every %s days"},h.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},h.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},h.prototype.commaEveryHour=function(){return", every hour"},h.prototype.commaEveryX0Years=function(){return", every %s years"},h.prototype.commaStartingX0=function(){return", starting %s"},h.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},h.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},h.prototype.atReboot=function(){return"Run once, at startup"},h})();m.en=p}),515:((l,m)=>{Object.defineProperty(m,"__esModule",{value:!0});function p(g,v){if(!g)throw new Error(v)}var h=(function(){function g(){}return g.secondRange=function(v){for(var x=v.split(","),y=0;y<x.length;y++)if(!isNaN(parseInt(x[y],10))){var C=parseInt(x[y],10);p(C>=0&&C<=59,"seconds part must be >= 0 and <= 59")}},g.minuteRange=function(v){for(var x=v.split(","),y=0;y<x.length;y++)if(!isNaN(parseInt(x[y],10))){var C=parseInt(x[y],10);p(C>=0&&C<=59,"minutes part must be >= 0 and <= 59")}},g.hourRange=function(v){for(var x=v.split(","),y=0;y<x.length;y++)if(!isNaN(parseInt(x[y],10))){var C=parseInt(x[y],10);p(C>=0&&C<=23,"hours part must be >= 0 and <= 23")}},g.dayOfMonthRange=function(v){for(var x=v.split(","),y=0;y<x.length;y++)if(!isNaN(parseInt(x[y],10))){var C=parseInt(x[y],10);p(C>=1&&C<=31,"DOM part must be >= 1 and <= 31")}},g.monthRange=function(v,x){for(var y=v.split(","),C=0;C<y.length;C++)if(!isNaN(parseInt(y[C],10))){var w=parseInt(y[C],10);p(w>=1&&w<=12,x?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},g.dayOfWeekRange=function(v,x){for(var y=v.split(","),C=0;C<y.length;C++)if(!isNaN(parseInt(y[C],10))){var w=parseInt(y[C],10);p(w>=0&&w<=6,x?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},g})();m.default=h}),823:((l,m)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.StringUtilities=void 0;var p=(function(){function h(){}return h.format=function(g){for(var v=[],x=1;x<arguments.length;x++)v[x-1]=arguments[x];return g.replace(/%s/g,function(y){return v.shift()})},h.containsAny=function(g,v){return v.some(function(x){return g.indexOf(x)>-1})},h})();m.StringUtilities=p})},s={};function d(l){var m=s[l];if(m!==void 0)return m.exports;var p=s[l]={exports:{}};return u[l](p,p.exports,d),p.exports}var c={};return(()=>{var l=c;Object.defineProperty(l,"__esModule",{value:!0}),l.toString=void 0;var m=d(333),p=d(747);m.ExpressionDescriptor.initialize(new p.enLocaleLoader),l.default=m.ExpressionDescriptor;var h=m.ExpressionDescriptor.toString;l.toString=h})(),c})())})(zr)),zr.exports}var fu=hu();const pu=o.getDefaultExportFromCjs(fu),mu=new Set(["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC","SUN","MON","TUE","WED","THU","FRI","SAT"]);function gu(e){for(const r of e.trim().split(/\s+/)){if(/[#?]/.test(r))return!1;for(const u of r.split(/[,\-/]/))if(!(u===""||u==="*")&&/[A-Za-z]/.test(u)&&!mu.has(u.toUpperCase()))return!1}return!0}function oa(e){const r=(e??"").trim();if(r.split(/\s+/).filter(Boolean).length!==5)return{valid:!1,description:"",nextRun:null,error:"Expected a 5-field UNIX cron: minute hour day-of-month month day-of-week."};if(!gu(r))return{valid:!1,description:"",nextRun:null,error:"Unsupported cron syntax: L, W, #, and ? extensions are not allowed (plain 5-field UNIX cron only)."};try{const u=pu.toString(r,{use24HourTimeFormat:!0,verbose:!1}),s=du.CronExpressionParser.parse(r,{tz:"UTC"}).next().toDate();return{valid:!0,description:u,nextRun:s}}catch(u){return{valid:!1,description:"",nextRun:null,error:u instanceof Error?u.message:"Invalid cron expression."}}}function aa(e){return e?e.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC":"—"}function yu({onSubmit:e,isSubmitting:r,disabled:u,disabledReason:s}){const[d,c]=I.useState(!1),[l,m]=I.useState(!1),p=()=>c(!1),h=async()=>{try{await e({forceRefresh:l}),c(!1)}catch{}},g=n.jsx("span",{children:n.jsx(o.AddButton,{label:"Materialization",onClick:()=>c(!0),disabled:u})});return n.jsxs(n.Fragment,{children:[u&&s?n.jsx(S.Tooltip,{title:s,children:g}):g,n.jsx(o.AppDialog,{open:d,onClose:p,title:"New materialization",description:"Compile the package, build a table for every persist source, and load them so queries serve from the tables.",actions:n.jsxs(n.Fragment,{children:[n.jsx(S.Button,{onClick:p,children:"Cancel"}),n.jsx(S.Button,{variant:"contained",loading:r,onClick:h,children:"Materialize"})]}),children:n.jsx(S.FormGroup,{children:n.jsx(S.FormControlLabel,{control:n.jsx(S.Switch,{checked:l,onChange:v=>m(v.target.checked)}),label:"Force refresh (rebuild even if unchanged)"})})})]})}function xr({children:e}){return n.jsx(S.Typography,{variant:"caption",component:"h6",sx:{display:"block",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:"text.secondary",mb:1},children:e})}function vr(e){return e===B.MaterializationStatus.Pending||e===B.MaterializationStatus.ManifestRowsReady}function xu(e){return e===B.MaterializationStatus.ManifestFileReady||e===B.MaterializationStatus.Failed||e===B.MaterializationStatus.Cancelled}function ia(e){switch(e){case B.MaterializationStatus.ManifestFileReady:return"Done";case B.MaterializationStatus.Failed:return"Failed";case B.MaterializationStatus.Cancelled:return"Cancelled";case B.MaterializationStatus.Pending:case B.MaterializationStatus.ManifestRowsReady:return"Pending";default:return"Unknown"}}function ns(e){switch(e){case B.MaterializationStatus.ManifestRowsReady:return"info";case B.MaterializationStatus.ManifestFileReady:return"success";case B.MaterializationStatus.Failed:return"error";case B.MaterializationStatus.Cancelled:return"warning";case B.MaterializationStatus.Pending:default:return"default"}}function bu(e){const r=Object.values(cs(e).refusedSources??{}).map(s=>({name:s.name,message:s.message})),u=Object.values(e.manifest?.failures??{}).filter(s=>s.refused).map(s=>({name:s.sourceName??s.sourceEntityId,message:s.reason}));return[...r,...u].sort((s,d)=>s.name.localeCompare(d.name))}function la(e,r){const u=[`${e.sourcesBuilt??0} built`,`${e.sourcesReused??0} reused`];return e.sourcesRefused&&u.push(`${e.sourcesRefused} refused`),u.join(r)}function cs(e){return e.metadata??{}}function vu(e){return e.trigger==="SCHEDULER"?"Scheduled":"Manual"}function ca(e,r){if(!e)return"-";const u=new Date(e).getTime(),s=r?new Date(r).getTime():Date.now(),d=Math.max(0,s-u);if(d<1e3)return`${d}ms`;const c=Math.round(d/1e3);if(c<60)return`${c}s`;const l=Math.floor(c/60),m=c%60;if(l<60)return`${l}m ${m}s`;const p=Math.floor(l/60),h=l%60;return`${p}h ${h}m`}function rs(e){if(!e)return"—";const r=new Date(e);return Number.isNaN(r.getTime())?"—":r.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Su(e){if(!e)return"-";const r=new Date(e).getTime(),u=Math.round((Date.now()-r)/1e3);if(u<60)return"just now";const s=Math.floor(u/60);if(s<60)return`${s}m ago`;const d=Math.floor(s/60);return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`}function wu({entries:e,builtAt:r}){const u=Object.entries(e??{});return n.jsxs(S.Box,{children:[n.jsxs(S.Stack,{direction:"row",alignItems:"baseline",justifyContent:"space-between",children:[n.jsx(xr,{children:"Build manifest"}),r&&n.jsxs(S.Typography,{variant:"caption",color:"text.secondary",children:["Built ",rs(r)]})]}),u.length===0?n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:"No materialized tables yet."}):n.jsxs(S.Table,{size:"small",children:[n.jsx(S.TableHead,{children:n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:"Source"}),n.jsx(S.TableCell,{children:"Table name"}),n.jsx(S.TableCell,{children:"Connection"}),n.jsx(S.TableCell,{children:"Realization"}),n.jsx(S.TableCell,{align:"right",children:"Rows"})]})}),n.jsx(S.TableBody,{children:u.map(([s,d])=>n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:d.sourceName??s}),n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:d.physicalTableName??"-"}),n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:d.connectionName??"-"}),n.jsx(S.TableCell,{children:d.realization??"-"}),n.jsx(S.TableCell,{align:"right",children:d.rowCount??"-"})]},s))})]})]})}function ua({meta:e}){const r=e.trigger==="SCHEDULER";return n.jsx(S.Tooltip,{title:r?"Fired by the materialization schedule":"Triggered manually",children:n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:vu(e)})})}function Cu({materialization:e,buildPlan:r,onClose:u}){const s=e?cs(e):{},d=e?bu(e):[],c=Object.values(r?.sources??{});return n.jsx(S.Dialog,{open:e!==null,onClose:u,maxWidth:"md",fullWidth:!0,"aria-labelledby":"materialization-detail-title",children:e&&n.jsxs(n.Fragment,{children:[n.jsxs(S.DialogTitle,{sx:{pr:6,pb:1.5},id:"materialization-detail-title",children:[n.jsxs(S.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{mb:.75},children:[n.jsx(S.Chip,{size:"small",label:ia(e.status),color:ns(e.status),variant:vr(e.status)?"filled":"outlined"}),n.jsx(ua,{meta:s})]}),n.jsx(S.Typography,{variant:"subtitle1",sx:{fontWeight:600},children:e.packageName??"Materialization"}),n.jsx(S.Typography,{variant:"caption",color:"text.secondary",sx:{fontFamily:B.MONO_FONT_FAMILY,wordBreak:"break-all"},children:e.id}),n.jsx(S.IconButton,{"aria-label":"close",onClick:u,sx:{position:"absolute",right:8,top:8},children:n.jsx(o.CloseIcon,{fontSize:"small"})})]}),n.jsxs(S.DialogContent,{dividers:!0,children:[n.jsxs(S.Box,{sx:{bgcolor:"action.hover",borderRadius:2,p:2,mb:3,display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:2},children:[n.jsx(Gn,{label:"Started",value:rs(e.startedAt??e.createdAt)}),n.jsx(Gn,{label:"Completed",value:rs(e.completedAt)}),n.jsx(Gn,{label:"Duration",value:ca(e.startedAt,e.completedAt)}),n.jsx(Gn,{label:"Sources",value:la(s," · ")}),n.jsx(Gn,{label:"Force refresh",value:s.forceRefresh?"Yes":"No"})]}),e.error&&n.jsxs(S.Box,{sx:{borderRadius:2,p:2,mb:3,border:"1px solid",borderColor:"error.main"},children:[n.jsx(xr,{children:n.jsx(S.Box,{component:"span",sx:{color:"error.main"},children:"Error"})}),n.jsx(S.Typography,{variant:"body2",sx:{fontFamily:B.MONO_FONT_FAMILY,whiteSpace:"pre-wrap"},children:e.error})]}),d.length>0&&n.jsxs(S.Box,{sx:{borderRadius:2,p:2,mb:3,border:"1px solid",borderColor:"warning.main"},children:[n.jsx(xr,{children:n.jsx(S.Box,{component:"span",sx:{color:"warning.main"},children:"Refused sources"})}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"Not built, because materializing them would be unsafe. They serve live until the model changes."}),d.map(l=>n.jsxs(S.Box,{sx:{mt:1},children:[n.jsx(S.Typography,{variant:"body2",sx:{fontFamily:B.MONO_FONT_FAMILY},children:l.name}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap"},children:l.message})]},l.name))]}),n.jsxs(S.Box,{sx:{mb:3},children:[n.jsx(xr,{children:"Build plan"}),c.length===0?n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:"This package has no persist sources."}):n.jsxs(S.Table,{size:"small",children:[n.jsx(S.TableHead,{children:n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:"Source"}),n.jsx(S.TableCell,{children:"Connection"}),n.jsx(S.TableCell,{children:"Dialect"}),n.jsx(S.TableCell,{align:"right",children:"Columns"}),n.jsx(S.TableCell,{children:"Source Entity ID"})]})}),n.jsx(S.TableBody,{children:c.map(l=>n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:l.name}),n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:l.connectionName}),n.jsx(S.TableCell,{children:l.dialect??"-"}),n.jsx(S.TableCell,{align:"right",children:l.columns?.length??0}),n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY,fontSize:"0.75rem",wordBreak:"break-all",maxWidth:220},children:l.sourceEntityId})]},l.sourceID))})]})]}),n.jsx(wu,{entries:e.manifest?.entries,builtAt:e.manifest?.builtAt})]})]})})}function Gn({label:e,value:r}){return n.jsxs(S.Box,{children:[n.jsx(S.Typography,{variant:"caption",color:"text.secondary",display:"block",children:e}),n.jsx(S.Typography,{variant:"body2",children:r})]})}const ku=o.createSvgIcon(n.jsx("path",{d:"M6 6h12v12H6z"}));function Tu(e){return o.generateUtilityClass("PrivateSwitchBase",e)}o.generateUtilityClasses("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const Ou=e=>{const{classes:r,checked:u,disabled:s,edge:d}=e,c={root:["root",u&&"checked",s&&"disabled",d&&`edge${o.capitalize(d)}`],input:["input"]};return o.composeClasses(c,Tu,r)},Mu=o.styled(o.ButtonBase,{name:"MuiSwitchBase"})({padding:9,borderRadius:"50%",variants:[{props:{edge:"start",size:"small"},style:{marginLeft:-3}},{props:({edge:e,ownerState:r})=>e==="start"&&r.size!=="small",style:{marginLeft:-12}},{props:{edge:"end",size:"small"},style:{marginRight:-3}},{props:({edge:e,ownerState:r})=>e==="end"&&r.size!=="small",style:{marginRight:-12}}]}),ju=o.styled("input",{name:"MuiSwitchBase",shouldForwardProp:o.rootShouldForwardProp})({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),Du=he.forwardRef(function(r,u){const{autoFocus:s,checked:d,checkedIcon:c,defaultChecked:l,disabled:m,disableFocusRipple:p=!1,edge:h=!1,icon:g,id:v,inputProps:x,inputRef:y,name:C,onBlur:w,onChange:k,onFocus:O,readOnly:M,required:j=!1,tabIndex:E,type:$,value:U,slots:P={},slotProps:K={},...A}=r,[L,V]=o.useControlled({controlled:d,default:!!l,name:"SwitchBase",state:"checked"}),N=o.useFormControl(),_=oe=>{O&&O(oe),N&&N.onFocus&&N.onFocus(oe)},Q=oe=>{w&&w(oe),N&&N.onBlur&&N.onBlur(oe)},re=oe=>{if(oe.nativeEvent.defaultPrevented)return;const le=oe.target.checked;V(le),k&&k(oe,le)};let ee=m;N&&typeof ee>"u"&&(ee=N.disabled);const te=$==="checkbox"||$==="radio",Z={...r,checked:L,disabled:ee,disableFocusRipple:p,edge:h},ae=Ou(Z),H={slots:P,slotProps:{input:x,...K}},[J,se]=o.useSlot("root",{ref:u,elementType:Mu,className:ae.root,shouldForwardComponentProp:!0,externalForwardedProps:{...H,component:"span",...A},getSlotProps:oe=>({...oe,onFocus:le=>{oe.onFocus?.(le),_(le)},onBlur:le=>{oe.onBlur?.(le),Q(le)}}),ownerState:Z,additionalProps:{centerRipple:!0,focusRipple:!p,disabled:ee,role:void 0,tabIndex:null}}),[xe,$e]=o.useSlot("input",{ref:y,elementType:ju,className:ae.input,externalForwardedProps:H,getSlotProps:oe=>({...oe,onChange:le=>{oe.onChange?.(le),re(le)}}),ownerState:Z,additionalProps:{autoFocus:s,checked:d,defaultChecked:l,disabled:ee,id:te?v:void 0,name:C,readOnly:M,required:j,tabIndex:E,type:$,...$==="checkbox"&&U===void 0?{}:{value:U}}});return n.jsxs(J,{...se,children:[n.jsx(xe,{...$e}),L?c:g]})}),Eu=o.createSvgIcon(n.jsx("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"})),Iu=o.createSvgIcon(n.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})),Nu=o.createSvgIcon(n.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"}));function Fu(e){return o.generateUtilityClass("MuiCheckbox",e)}const Hr=o.generateUtilityClasses("MuiCheckbox",["root","checked","disabled","indeterminate","colorPrimary","colorSecondary","sizeSmall","sizeMedium"]),Au=e=>{const{classes:r,indeterminate:u,color:s,size:d}=e,c={root:["root",u&&"indeterminate",`color${o.capitalize(s)}`,`size${o.capitalize(d)}`]},l=o.composeClasses(c,Fu,r);return{...r,...l}},Ru=o.styled(Du,{shouldForwardProp:e=>o.rootShouldForwardProp(e)||e==="classes",name:"MuiCheckbox",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.root,u.indeterminate&&r.indeterminate,r[`size${o.capitalize(u.size)}`],u.color!=="default"&&r[`color${o.capitalize(u.color)}`]]}})(o.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,variants:[{props:{color:"default",disableRipple:!1},style:{"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity)}}},...Object.entries(e.palette).filter(o.createSimplePaletteValueFilter()).map(([r])=>({props:{color:r,disableRipple:!1},style:{"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[r].main,(e.vars||e).palette.action.hoverOpacity)}}})),...Object.entries(e.palette).filter(o.createSimplePaletteValueFilter()).map(([r])=>({props:{color:r},style:{[`&.${Hr.checked}, &.${Hr.indeterminate}`]:{color:(e.vars||e).palette[r].main},[`&.${Hr.disabled}`]:{color:(e.vars||e).palette.action.disabled}}})),{props:{disableRipple:!1},style:{"&:hover":{"@media (hover: none)":{backgroundColor:"transparent"}}}}]}))),$u=n.jsx(Iu,{}),Pu=n.jsx(Eu,{}),Lu=n.jsx(Nu,{}),_u=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiCheckbox"}),{checkedIcon:d=$u,color:c="primary",icon:l=Pu,indeterminate:m=!1,indeterminateIcon:p=Lu,inputProps:h,size:g="medium",disableRipple:v=!1,className:x,slots:y={},slotProps:C={},...w}=s,k=m?p:l,O=m?p:d,M={...s,disableRipple:v,color:c,indeterminate:m,size:g},j=Au(M),E=C.input??h,[$,U]=o.useSlot("root",{ref:u,elementType:Ru,className:o.clsx(j.root,x),shouldForwardComponentProp:!0,externalForwardedProps:{slots:y,slotProps:C,...w},ownerState:M,additionalProps:{type:"checkbox",icon:he.cloneElement(k,{fontSize:k.props.fontSize??g}),checkedIcon:he.cloneElement(O,{fontSize:O.props.fontSize??g}),disableRipple:v,slots:y,slotProps:{input:o.mergeSlotProps(typeof E=="function"?E(M):E,{"data-indeterminate":m})}}});return n.jsx($,{...U,classes:j})});function Wu(e){return o.generateUtilityClass("MuiFormControlLabel",e)}const Qn=o.generateUtilityClasses("MuiFormControlLabel",["root","labelPlacementStart","labelPlacementTop","labelPlacementBottom","disabled","label","error","required","asterisk"]),qu=e=>{const{classes:r,disabled:u,labelPlacement:s,error:d,required:c}=e,l={root:["root",u&&"disabled",`labelPlacement${o.capitalize(s)}`,d&&"error",c&&"required"],label:["label",u&&"disabled"],asterisk:["asterisk",d&&"error"]};return o.composeClasses(l,Wu,r)},zu=o.styled("label",{name:"MuiFormControlLabel",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[{[`& .${Qn.label}`]:r.label},r.root,r[`labelPlacement${o.capitalize(u.labelPlacement)}`]]}})(o.memoTheme(({theme:e})=>({display:"inline-flex",alignItems:"center",cursor:"pointer",verticalAlign:"middle",WebkitTapHighlightColor:"transparent",marginLeft:-11,marginRight:16,[`&.${Qn.disabled}`]:{cursor:"default"},[`& .${Qn.label}`]:{[`&.${Qn.disabled}`]:{color:(e.vars||e).palette.text.disabled}},variants:[{props:{labelPlacement:"start"},style:{flexDirection:"row-reverse",marginRight:-11}},{props:{labelPlacement:"top"},style:{flexDirection:"column-reverse"}},{props:{labelPlacement:"bottom"},style:{flexDirection:"column"}},{props:({labelPlacement:r})=>r==="start"||r==="top"||r==="bottom",style:{marginLeft:16}}]}))),Hu=o.styled("span",{name:"MuiFormControlLabel",slot:"Asterisk"})(o.memoTheme(({theme:e})=>({[`&.${Qn.error}`]:{color:(e.vars||e).palette.error.main}}))),Vu=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiFormControlLabel"}),{checked:d,className:c,componentsProps:l={},control:m,disabled:p,disableTypography:h,inputRef:g,label:v,labelPlacement:x="end",name:y,onChange:C,required:w,slots:k={},slotProps:O={},value:M,...j}=s,E=o.useFormControl(),$=p??m.props.disabled??E?.disabled,U=w??m.props.required,P={disabled:$,required:U};["checked","name","onChange","value","inputRef"].forEach(re=>{typeof m.props[re]>"u"&&typeof s[re]<"u"&&(P[re]=s[re])});const K=o.formControlState({props:s,muiFormControl:E,states:["error"]}),A={...s,disabled:$,labelPlacement:x,required:U,error:K.error},L=qu(A),V={slots:k,slotProps:{...l,...O}},[N,_]=o.useSlot("typography",{elementType:o.Typography,externalForwardedProps:V,ownerState:A});let Q=v;return Q!=null&&Q.type!==o.Typography&&!h&&(Q=n.jsx(N,{component:"span",..._,className:o.clsx(L.label,_?.className),children:Q})),n.jsxs(zu,{className:o.clsx(L.root,c),ownerState:A,ref:u,...j,children:[he.cloneElement(m,P),U?n.jsxs("div",{children:[Q,n.jsxs(Hu,{ownerState:A,"aria-hidden":!0,className:L.asterisk,children:[" ","*"]})]}):Q]})});function Bu({materialization:e,onCloseDialog:r,isMutating:u,onDelete:s}){const[d,c]=I.useState(!1),[l,m]=I.useState(!1),p=()=>c(!0),h=()=>{c(!1),m(!1),r()};return n.jsxs(I.Fragment,{children:[n.jsxs(He,{"aria-label":`Delete materialization ${e?.id??""}`.trim(),onClick:g=>{g.stopPropagation(),p()},sx:{color:"error.main"},children:[n.jsx(os,{sx:{color:"inherit"},children:n.jsx(wt.Delete,{fontSize:"small"})}),n.jsx(as,{children:"Delete"})]}),n.jsxs(o.AppDialog,{open:d,onClose:h,title:"Delete materialization",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{onClick:h,children:"Cancel"}),n.jsx(o.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>s(l),loading:u,children:"Delete run"})]}),children:[n.jsx(o.Typography,{variant:"body2",children:"Delete this run's record? This cannot be undone."}),n.jsx(Vu,{control:n.jsx(_u,{checked:l,onChange:g=>m(g.target.checked)}),label:"Also drop the materialized tables this run produced"})]})]})}function Uu({materializations:e,mutable:r,isMutating:u,onStop:s,onDelete:d,onViewDetails:c}){return e.length===0?n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{py:1,fontStyle:"italic"},children:"No materializations yet."}):n.jsxs(S.Table,{size:"small",sx:{"& td, & th":{borderColor:"divider"},"& td:first-of-type, & th:first-of-type":{pl:0},"& td:last-of-type, & th:last-of-type":{pr:0},"& th":{color:"text.secondary",fontWeight:600}},children:[n.jsx(S.TableHead,{children:n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:"Status"}),n.jsx(S.TableCell,{children:"Trigger"}),n.jsx(S.TableCell,{children:"Started"}),n.jsx(S.TableCell,{children:"Duration"}),n.jsx(S.TableCell,{children:"Sources"}),n.jsx(S.TableCell,{align:"right",children:"Actions"})]})}),n.jsx(S.TableBody,{children:e.map(l=>n.jsx(Gu,{materialization:l,mutable:r,isMutating:u,onStop:s,onDelete:d,onViewDetails:c},l.id))})]})}function Gu({materialization:e,mutable:r,isMutating:u,onStop:s,onDelete:d,onViewDetails:c}){const[l,m]=I.useState(null),p=!!l,h=()=>m(null),g=cs(e),v=g.sourcesBuilt!==void 0||g.sourcesReused!==void 0?la(g,", "):"-",x=vr(e.status),y=xu(e.status),C=e.error??void 0,w=r&&(x||y);return n.jsxs(S.TableRow,{hover:!0,sx:{cursor:"pointer","&:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"-2px"}},onClick:()=>c(e),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),c(e))},role:"button",tabIndex:0,"aria-label":`View materialization ${e.id??""} details`.trim(),children:[n.jsx(S.TableCell,{children:n.jsxs(S.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[n.jsx(S.Typography,{variant:"body2",sx:{fontWeight:500,color:ns(e.status)==="default"?"text.primary":`${ns(e.status)}.main`},children:ia(e.status)}),C&&n.jsx(S.Tooltip,{title:C,children:n.jsx(o.InfoOutlinedIcon,{fontSize:"small",color:"error"})})]})}),n.jsx(S.TableCell,{children:n.jsx(ua,{meta:g})}),n.jsx(S.TableCell,{children:Su(e.startedAt??e.createdAt)}),n.jsx(S.TableCell,{children:ca(e.startedAt,e.completedAt)}),n.jsx(S.TableCell,{children:v}),n.jsx(S.TableCell,{align:"right",onClick:k=>k.stopPropagation(),children:w&&n.jsxs(n.Fragment,{children:[n.jsx(S.IconButton,{size:"small","aria-label":`Materialization actions for ${e.id??""}`.trim(),onClick:k=>m(k.currentTarget),children:n.jsx(wt.MoreVert,{fontSize:"small"})}),n.jsxs(S.Menu,{anchorEl:l,open:p,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[r&&x&&n.jsxs(S.MenuItem,{"aria-label":`Stop materialization ${e.id??""}`.trim(),disabled:u,onClick:()=>{h(),s(e)},children:[n.jsx(S.ListItemIcon,{children:n.jsx(ku,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Stop"})]}),r&&y&&n.jsx(Bu,{materialization:e,isMutating:u,onCloseDialog:h,onDelete:k=>d(e,k)})]})]})})]})}const Yu=o.createSvgIcon(n.jsx("path",{d:"m11.99 18.54-7.37-5.73L3 14.07l9 7 9-7-1.63-1.27zM12 16l7.36-5.73L21 9l-9-7-9 7 1.63 1.27zm0-11.47L17.74 9 12 13.47 6.26 9z"})),Zu={package:"Materialized artifacts are shared across versions",version:"Materialized artifacts are per published version"};function Ku({scope:e,disabled:r,disabledReason:u,isSubmitting:s,onChange:d}){const[c,l]=I.useState(null),m=async p=>{l(null),p!==e&&await d(p).catch(()=>{})};return n.jsxs(n.Fragment,{children:[n.jsx(o.SecondaryButton,{label:"Scope",icon:n.jsx(Yu,{}),onClick:p=>l(p.currentTarget),disabled:r||s,...u?{disabledReason:u}:{},ariaHasPopup:"menu",ariaLabel:`Scope: ${e}`}),n.jsx(S.Menu,{anchorEl:c,open:!!c,onClose:()=>l(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:["package","version"].map(p=>n.jsxs(S.MenuItem,{selected:p===e,onClick:()=>void m(p),children:[n.jsx(S.ListItemIcon,{sx:{minWidth:32},children:p===e&&n.jsx(o.CheckIcon,{fontSize:"small"})}),n.jsx(S.ListItemText,{primary:p,secondary:Zu[p]})]},p))})]})}const Xu=o.createSvgIcon([n.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),n.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")]),_o="0 6 * * *";function Qu({currentSchedule:e,isSubmitting:r,disabled:u,disabledReason:s,onSubmit:d}){const[c,l]=I.useState(!1),[m,p]=I.useState(e??_o),h=()=>{p(e??_o),l(!0)},g=()=>l(!1),v=oa(m),x=async y=>{try{await d(y),l(!1)}catch{}};return n.jsxs(n.Fragment,{children:[n.jsx(o.SecondaryButton,{label:"Schedule",icon:n.jsx(Xu,{}),onClick:h,disabled:u,...s?{disabledReason:s}:{},ariaHasPopup:"dialog",ariaLabel:e?"Edit schedule":"Set schedule"}),n.jsxs(o.AppDialog,{open:c,onClose:g,title:e?"Edit schedule":"Set schedule",description:"The publisher rebuilds this package's materializations on this cadence: a 5-field UNIX cron, in UTC. In a hosted deployment the change takes effect on your next publish.",actions:n.jsxs(n.Fragment,{children:[e&&n.jsx(S.Button,{color:"error",loading:r,onClick:()=>x(null),sx:{mr:"auto"},children:"Clear schedule"}),n.jsx(S.Button,{onClick:g,children:"Cancel"}),n.jsx(S.Button,{variant:"contained",loading:r,disabled:!v.valid,onClick:()=>x(m.trim()),children:"Save schedule"})]}),children:[n.jsx(S.TextField,{autoFocus:!0,fullWidth:!0,size:"small",label:"Cron expression",value:m,onChange:y=>p(y.target.value),error:m.trim()!==""&&!v.valid,helperText:v.valid?`${v.description} · next run ${aa(v.nextRun)}`:v.error,slotProps:{htmlInput:{style:{fontFamily:B.MONO_FONT_FAMILY}}}}),n.jsxs(S.Alert,{severity:"info",children:["A schedule runs only on version-scoped packages, so saving one sets ",n.jsx("code",{children:"scope: version"})," for this package."]})]})]})}const Ju=3e3;function da({resourceUri:e}){const{apiClients:r,mutable:u}=B.useServer(),s=Sr.useQueryClient(),{environmentName:d,packageName:c}=o.parseResourceUri(e),[l,m]=I.useState(""),[p,h]=I.useState(null);if(!c)throw new Error("Materializations requires a package in the resource URI");const g=o.useQueryWithApiError({queryKey:["materializations",d,c],queryFn:()=>r.materializations.listMaterializations(d,c),refetchInterval:_=>(_.state.data?.data??[]).some(ee=>vr(ee.status))?Ju:!1}),v=o.useQueryWithApiError({queryKey:["package",d,c],queryFn:()=>r.packages.getPackage(d,c)}),x=()=>s.invalidateQueries({queryKey:["materializations",d,c]}),y=o.useMutationWithApiError({mutationFn:Pt("materialization","create",_=>r.materializations.createMaterialization(d,c,{forceRefresh:_.forceRefresh})),onSuccess(){m("Materialization requested"),x()},onError(_){m(_.message),x()}}),C=o.useMutationWithApiError({mutationFn:Pt("materialization","update",_=>r.materializations.materializationAction(d,c,_.id,B.MaterializationActionActionEnum.Stop)),onSuccess(){m("Materialization stopped"),x()},onError(_){m(_.message)}}),w=o.useMutationWithApiError({mutationFn:Pt("materialization","delete",({materialization:_,dropTables:Q})=>r.materializations.deleteMaterialization(d,c,_.id,Q)),onSuccess(){m("Materialization deleted"),x()},onError(_){m(_.message)}}),k=v.data?.data,O=o.useMutationWithApiError({mutationFn:Pt("schedule","update",_=>r.packages.updatePackage(d,c,{name:c,description:k?.description,..._?{scope:B.PackageScopeEnum.Version}:{},materialization:{schedule:_}})),onSuccess(_,Q){m(Q?"Schedule updated":"Schedule cleared"),s.invalidateQueries({queryKey:["package",d,c]})},onError(_){m(_.message)}}),M=o.useMutationWithApiError({mutationFn:Pt("scope","update",_=>r.packages.updatePackage(d,c,{name:c,description:k?.description,scope:_})),onSuccess(){m("Scope updated"),s.invalidateQueries({queryKey:["package",d,c]})},onError(_){m(_.message)}}),j=g.data?.data??[],E=j.find(_=>_.id===p)??null,$=j.some(_=>vr(_.status)),U=y.isPending||C.isPending||w.isPending,P=k?.materialization?.schedule??null,K=k?.scope===B.PackageScopeEnum.Version?"version":"package",A=!!k?.manifestLocation,L=!!k?.materialization?.freshness,V=P?oa(P):null,N=A?"Control-plane managed: refresh is driven by the control plane, not the built-in scheduler.":[V?V.valid?`${V.description} (${P}), next run ${aa(V.nextRun)}`:`Unrecognized cron expression (${P})`:L?"Refreshed by a freshness policy; a cron schedule does not apply":"On demand only, no schedule set",`scope: ${K}`].join(" · ");return n.jsxs(n.Fragment,{children:[n.jsxs(It,{title:"Materializations",count:g.isSuccess?j.length:void 0,action:u&&n.jsxs(S.Stack,{direction:"row",spacing:1,alignItems:"center",children:[!A&&n.jsx(Ku,{scope:K,disabled:!!P,disabledReason:"A schedule requires version scope. Clear the schedule to change it.",isSubmitting:M.isPending,onChange:_=>M.mutateAsync(_==="version"?B.PackageScopeEnum.Version:B.PackageScopeEnum.Package)}),!A&&n.jsx(Qu,{currentSchedule:P,isSubmitting:O.isPending,disabled:L,disabledReason:"This package declares a freshness policy; a schedule and freshness are mutually exclusive.",onSubmit:_=>O.mutateAsync(_)}),n.jsx(yu,{onSubmit:_=>y.mutateAsync(_),isSubmitting:y.isPending,disabled:$,disabledReason:"A materialization is already pending or running for this package."})]}),children:[v.isSuccess&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:N}),g.isError&&n.jsx(o.ApiErrorDisplay,{error:g.error,context:`${d} > ${c} > Materializations`}),!g.isSuccess&&!g.isError&&n.jsx(o.Loading,{text:"Loading materializations..."}),g.isSuccess&&n.jsx(Uu,{materializations:j,mutable:u,isMutating:U,onStop:_=>C.mutate(_),onDelete:(_,Q)=>w.mutate({materialization:_,dropTables:Q}),onViewDetails:_=>h(_.id??null)})]}),n.jsx(Cu,{materialization:E,buildPlan:v.data?.data?.buildPlan??null,onClose:()=>h(null)}),n.jsx(S.Snackbar,{open:l!=="",autoHideDuration:6e3,onClose:()=>m(""),message:l})]})}const ha=o.createSvgIcon(n.jsx("path",{d:"M17 7h-4v2h4c1.65 0 3 1.35 3 3s-1.35 3-3 3h-4v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5m-6 8H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4zm-3-4h8v2H8z"})),nr=o.createSvgIcon(n.jsx("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"})),ed=o.createSvgIcon(n.jsx("path",{d:"M8 5v14l11-7z"})),Vr={scopeName:"source.malloy",patterns:[{include:"#malloy-language"}],repository:{"malloy-language":{patterns:[{include:"#sql-string"},{include:"#comments"},{include:"#tags"},{include:"#strings"},{include:"#numbers"},{include:"#keywords"},{include:"#properties"},{include:"#functions"},{include:"#datetimes"},{include:"#identifiers-quoted"},{include:"#types"},{include:"#constants"},{include:"#timeframes"},{include:"#identifiers-unquoted"}]},"malloy-matched":{begin:"{",end:"}",patterns:[{include:"#malloy-matched"},{include:"#malloy-language"}]},"malloy-in-sql":{begin:"%{",name:"source.malloy-in-sql",end:"}%?",patterns:[{include:"#malloy-matched"},{include:"#malloy-language"}]},"sql-string":{patterns:[{begin:'(\\b[A-Za-z_][A-Za-z_0-9]*)(\\s*\\.\\s*)(sql)(\\s*\\(\\s*)(""")',end:'"""',beginCaptures:{1:{name:"variable.other"},3:{name:"keyword.control.sql"},5:{name:"punctuation.sql-block.open"}},endCaptures:{0:{name:"punctuation.sql-block.close"}},name:"source.sql",patterns:[{include:"#malloy-in-sql"},{include:"source.sql"}]}]},functions:{patterns:[{match:"(?i)\\b(count)(\\s*\\()(distinct)",captures:{1:{name:"entity.name.function"},3:{name:"entity.name.function.modifier"}}},{match:"(?i)\\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE|UNGROUPED)(\\s*\\()",captures:{1:{name:"entity.name.function"}}},{match:"(?i)\\b([a-zA-Z_][a-zA-Z_0-9]*)(\\s*\\()",captures:{1:{name:"entity.name.function"}}},{match:"(?i)\\b([a-zA-Z_][a-zA-Z_0-9]*)(!)(timestamp|number|string|boolean|date)?(\\s*\\()",captures:{1:{name:"entity.name.function"},3:{name:"entity.name.type"}}}]},datetimes:{patterns:[{match:"(?i)@[0-9]{4}-[0-9]{2}-[0-9]{2}[ T][0-9]{2}:[0-9]{2}((:[0-9]{2})(([\\.,][0-9]+)(\\[[A-Za-z_/]+\\])?)?)?",name:"constant.numeric.timestamp"},{match:"(?i)@[0-9]{4}(-Q[1-4]|-[0-9]{2}(-[0-9]{2}(-WK)?)?)?",name:"constant.numeric.date"}]},"identifiers-quoted":{patterns:[{match:"`[^`]*`",name:"variable.other.quoted"}]},"identifiers-unquoted":{patterns:[{match:"(?i)\\b[A-Za-z_][A-Za-z_0-9]*\\b",name:"variable.other"}]},timeframes:{patterns:[{match:"(?i)\\b((year|quarter|month|week|day|hour|minute|second)s?)\\b",name:"keyword.other.timeframe"},{match:"(?i)\\b(day_of_year|day_of_month)\\b",name:"keyword.other.timeframe"}]},comments:{patterns:[{begin:"/\\*",end:"\\*/",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"comment.block"},{begin:"//",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{begin:"--",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-hyphen"}]},tags:{patterns:[{match:"##\\n",name:"string.quoted",captures:{0:{name:"string.quoted"}}},{begin:'#"',end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{match:"#\\n",name:"string.quoted",captures:{0:{name:"string.quoted"}}},{begin:"#\\s",end:"\\n",beginCaptures:{0:{name:"support.type.property-name.json"}},name:"comment.line.double-slash",patterns:[{include:"#tag-values"}]},{begin:"##\\s",end:"\\n",beginCaptures:{0:{name:"support.type.property-name.json"}},name:"comment.line.double-slash",patterns:[{include:"#tag-values"}]},{begin:"#",end:"\\n",beginCaptures:{0:{name:"string.quoted"}},name:"string.quoted"}],repository:{"tag-values":{name:"support.type.property-name.json",match:'(-)?((?:[^\\s=#]+)|(?:"[^#]+"))(?:\\s*(=)\\s*((?:[^\\s=#]+)|(?:"[^#]+")))?',captures:{1:{name:"keyword.control.negate"},2:{name:"support.type.property-name.json"},3:{name:"keyword.operator.comparison.ts"},4:{name:"string.quoted"}}}}},strings:{patterns:[{begin:"'",end:"'",beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.single",patterns:[{include:"#escapes"}]},{begin:'"',end:'"',beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.double",patterns:[{include:"#escapes"}]},{begin:'"""',end:'"""',beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.triple"},{begin:"(?i)[r|/]'",end:"'",name:"string.regexp",patterns:[{include:"#regex-escapes"}]}],repository:{escapes:{name:"constant.character.escape",match:"\\\\(u[A-Fa-f0-9]{4}|.)",captures:{0:{name:"constant.character.escape"}}},"regex-escapes":{name:"constant.character.escape",match:"\\\\.",captures:{0:{name:"constant.character.escape"}}}}},numbers:{match:"(?i)(\\b((0|[1-9][0-9]*)(E[+-]?[0-9]+|\\.[0-9]*)?)|\\.[0-9]+)",name:"constant.numeric"},constants:{patterns:[{match:"(?i)\\bnull\\b",name:"constant.language.null"},{match:"(?i)\\btrue\\b",name:"constant.language.true"},{match:"(?i)\\bfalse\\b",name:"constant.language.false"}]},types:{patterns:[{match:"(?i)\\bstring\\b",name:"entity.name.type.string"},{match:"(?i)\\bnumber\\b",name:"entity.name.type.number"},{match:"(?i)\\bdate\\b",name:"entity.name.type.date"},{match:"(?i)\\btimestamp\\b",name:"entity.name.type.timestamp"},{match:"(?i)\\bboolean\\b",name:"entity.name.type.boolean"}]},properties:{patterns:[{match:"(?i)\\baccept\\b",name:"keyword.control.accept"},{match:"(?i)\\bselect\\b",name:"keyword.control.select"},{match:"(?i)\\bconnection\\b",name:"keyword.control.connection"},{match:"(?i)\\brun\\b",name:"keyword.control.run"},{match:"(?i)\\bextend\\b",name:"keyword.control.extend"},{match:"(?i)\\brefine\\b",name:"keyword.control.refine"},{match:"(?i)\\baggregate\\b",name:"keyword.control.aggregate"},{match:"(?i)\\bsample\\b",name:"keyword.control.sample"},{match:"(?i)\\bcalculate\\b",name:"keyword.control.calculate"},{match:"(?i)\\btimezone\\b",name:"keyword.control.timezone"},{match:"(?i)\\bdimension\\b",name:"keyword.control.dimension"},{match:"(?i)\\bexcept\\b",name:"keyword.control.except"},{match:"(?i)\\bsource\\b",name:"keyword.control.source"},{match:"(?i)\\bgroup_by\\b",name:"keyword.control.group_by"},{match:"(?i)\\bhaving\\b",name:"keyword.control.having"},{match:"(?i)\\bindex\\b",name:"keyword.control.index"},{match:"(?i)\\bjoin_one\\b",name:"keyword.control.join_one"},{match:"(?i)\\bwith\\b",name:"keyword.control.with"},{match:"(?i)\\bjoin_many\\b",name:"keyword.control.join_many"},{match:"(?i)\\bjoin_cross\\b",name:"keyword.control.join_cross"},{match:"(?i)\\blimit\\b",name:"keyword.control.limit"},{match:"(?i)\\bmeasure\\b",name:"keyword.control.measure"},{match:"(?i)\\bnest\\b",name:"keyword.control.nest"},{match:"(?i)\\border_by\\b",name:"keyword.control.order_by"},{match:"(?i)\\bpartition_by\\b",name:"keyword.control.partition_by"},{match:"(?i)\\bprimary_key\\b",name:"keyword.control.primary_key"},{match:"(?i)\\bproject\\b",name:"keyword.control.project"},{match:"(?i)\\bquery\\b",name:"keyword.control.query"},{match:"(?i)\\brename\\b",name:"keyword.control.rename"},{match:"(?i)\\btop\\b",name:"keyword.control.top"},{match:"(?i)\\bview\\b",name:"keyword.control.view"},{match:"(?i)\\bwhere\\b",name:"keyword.control.where"},{match:"(?i)\\bdeclare\\b",name:"keyword.control.declare"}]},keywords:{patterns:[{match:"(?i)\\bis\\b",name:"keyword.control.is"},{match:"(?i)\\bon\\b",name:"keyword.control.on"},{match:"(?i)\\bnot\\b",name:"keyword.other.not"},{match:"(?i)\\bor\\b",name:"keyword.other.or"},{match:"(?i)\\bdesc\\b",name:"keyword.control.desc"},{match:"(?i)\\bby\\b",name:"keyword.control.by"},{match:"(?i)\\band\\b",name:"keyword.other.and"},{match:"(?i)\\basc\\b",name:"keyword.control.asc"},{match:"(?i)\\bfor\\b",name:"keyword.other.for"},{match:"(?i)\\belse\\b",name:"keyword.other.else"},{match:"(?i)\\bto\\b",name:"keyword.other.to"},{match:"(?i)\\bwhen\\b",name:"keyword.other.when"},{match:"(?i)\\bpick\\b",name:"keyword.other.pick"},{match:"(?i)\\bimport\\b",name:"keyword.control.import"}]}}},td={...Vr,patterns:[...Vr.patterns,{include:"#docvar"}],repository:{...Vr.repository,docvar:{patterns:[{match:"\\<\\<[^(\\>\\>)]*\\>\\>",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"markup.italic.markdown"}]}}},nd={name:"Malloy SQL",scopeName:"source.malloy-sql",patterns:[{include:"#malloysql-sql"}],repository:{"malloysql-sql":{beginCaptures:{0:{name:"entity.other.attribute.malloy-sql"},1:{name:"entity.other.attribute.malloy-sql"},3:{name:"comment.line.double-slash"}},name:"meta.embedded.block.malloysql.sql",patterns:[{include:"#comments"},{begin:"%{",end:"}%",beginCaptures:{0:{name:"punctuation.definition.malloy-sql"}},endCaptures:{0:{name:"punctuation.definition.malloy-sql"}},name:"meta.embedded.block.malloy",patterns:[{include:"source.malloy"}]},{include:"source.sql"}]},comments:{patterns:[{begin:"/\\*",end:"\\*/",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"comment.block"},{begin:"//",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{begin:"--",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-hyphen"}]}}},rd="github-light",sd="github-dark";let Br;function od(){return Br||(Br=(async()=>{const[{createHighlighterCore:e},{createOnigurumaEngine:r},{default:u},{default:s},{default:d},{default:c},{default:l}]=await Promise.all([Promise.resolve().then(()=>require("./core-8NVBCLZh.cjs.js")),Promise.resolve().then(()=>require("./engine-oniguruma-BkproSVE.cjs.js")),Promise.resolve().then(()=>require("./sql-BqWZrLHB.cjs.js")),Promise.resolve().then(()=>require("./json-y-J1j5EW.cjs.js")),Promise.resolve().then(()=>require("./typescript-BqvpT6pB.cjs.js")),Promise.resolve().then(()=>require("./github-light-BFTOhCbz.cjs.js")),Promise.resolve().then(()=>require("./github-dark-BKL9xNgN.cjs.js"))]);return e({engine:r(Promise.resolve().then(()=>require("./wasm-Dw4u1m6u.cjs.js"))),themes:[c,l],langs:[u,s,d,{name:"malloy",scopeName:"source.malloy",embeddedLangs:["sql"],...td},{name:"malloysql",scopeName:"source.malloy-sql",embeddedLangs:["sql"],...nd}]})})()),Br}async function fa(e,r,u="light"){return(await od()).codeToHtml(e,{lang:r,theme:u==="dark"?sd:rd})}function pa({open:e,onClose:r,result:u,title:s="Results",renderLogs:d,drill:c}){return n.jsx(o.AppDialog,{open:e,onClose:r,title:s,maxWidth:!1,showClose:!0,children:n.jsx(S.Box,{sx:{height:"70vh",overflow:"auto"},children:n.jsx(o.ResultContainer,{result:u,maxHeight:o.RESULTS_DIALOG_MAX_HEIGHT,maxResultSize:1e6,renderLogs:d,drill:c})})})}function ad({queryName:e,annotations:r,resourceUri:u,runOnDemand:s=!1,maxResultSize:d=0}){const[c,l]=I.useState(),[m,p]=I.useState(!1),[h,g]=I.useState(!1),{packageName:v,environmentName:x,versionId:y,modelPath:C}=o.parseResourceUri(u),w=!s||h,k=o.useQueryResult({environmentName:x,packageName:v,modelPath:C,versionId:y,queryName:e},{enabled:w}),O=k.data,{mode:M}=B.usePublisherTheme();return I.useEffect(()=>{if(r&&r.length>0){const j=r.map(E=>`// ${E}`).join(`
|
|
6
|
-
`);fa(j,"typescript",M).then(E=>{l(E)})}},[r,M]),n.jsxs(S.Box,{children:[c&&n.jsx(S.Box,{sx:{marginBottom:"16px"},children:n.jsx(S.Typography,{fontSize:"12px",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},children:n.jsx("div",{className:"content",dangerouslySetInnerHTML:{__html:c}})})}),n.jsxs(S.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[n.jsx(S.Typography,{variant:"body2",sx:{fontSize:"15px",fontWeight:600,color:"text.primary",px:2,py:1,bgcolor:"action.hover",borderRadius:1.5,border:1,borderColor:"divider"},children:e}),n.jsx(o.FloatingIconButton,{"aria-label":"Expand results",onClick:()=>p(!0),children:n.jsx(nr,{})})]}),n.jsxs(B.CleanMetricCard,{sx:{position:"relative"},children:[s&&!h&&n.jsxs(S.Box,{sx:{padding:"40px 20px",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"Click Run to execute the query"}),n.jsx(S.Button,{variant:"contained",startIcon:n.jsx(ed,{}),onClick:()=>g(!0),children:"Run Query"})]}),w&&n.jsx(o.ResultPanel,{state:k,context:e,maxHeight:o.MODEL_CELL_MAX_HEIGHT,maxResultSize:d})]}),n.jsx(pa,{open:m,onClose:()=>p(!1),result:O?.data?.result||"",renderLogs:O?.data?.renderLogs,title:`Query: ${e}`})]})}function id(e){return e!=null}function ld(e,r){const u=[],s=[];for(const c of e){if(c.name===void 0||id(r.get(c.name)))continue;if(c.default==null){u.push(c.name);continue}const l=o.renderGivenDefault(c.type??"string",c.default);l&&s.push(`${c.name} = ${l}`)}const d={missing:u};return s.length>0&&(d.defaultsNote=s.length===1?`Ran with the default ${s[0]}`:`Ran with defaults ${s.join(", ")}`),d}function cd(e){return e.length===1?`This source may need a value for the given ${e[0]}. Set it in the parameters above.`:`This source may need values for the givens ${e.join(", ")}. Set them in the parameters above.`}function ma({sourceAndPaths:e,selectedSourceIndex:r,existingQuery:u,onQueryChange:s,onSourceChange:d,resourceUri:c,givens:l,gate:m}){return I.useEffect(()=>{d&&d(r)},[r,d]),n.jsx(B.StyledCardMedia,{children:n.jsxs(Jn.Stack,{spacing:2,component:"section",children:[n.jsx(dd,{sourceAndPath:e[r],existingQuery:u,onChange:p=>{s&&s(p)},resourceUri:c,givens:l,gate:m}),n.jsx(Jn.Box,{height:"5px"})]})})}function Ur(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function ud({sourceAndPath:e,onChange:r,existingQuery:u,explorerComponents:s,QueryBuilder:d,resourceUri:c,givens:l,gate:m}){const[p,h]=I.useState(u||Ur()),[g,v]=I.useState(void 0);I.useEffect(()=>{u&&h(u)},[u]);const[x,y]=I.useState([]),{MalloyExplorerProvider:C,QueryPanel:w,ResizableCollapsiblePanel:k,ResultPanel:O,SourcePanel:M}=s;I.useEffect(()=>{r&&r(p)},[r,p]);const{environmentName:j,packageName:E,versionId:$}=o.parseResourceUri(c),{apiClients:U}=B.useServer(),P=I.useRef(void 0),K=o.useMutationWithApiError({mutationFn:()=>{P.current=m,v({executionState:"running",query:p?.malloyQuery,queryResolutionStartMillis:Date.now(),onCancel:()=>{K.reset(),v(void 0)},response:{}});const N=typeof p?.malloyQuery=="string"?p.malloyQuery:new d.ASTQuery({source:e.sourceInfo,query:p?.malloyQuery}).toMalloy();return h({...p,query:N}),U.models.executeQueryModel(j,E,e.modelPath,{query:N,sourceName:void 0,queryName:void 0,versionId:$,...l&&Object.keys(l).length>0?{givens:l}:{}})},onSuccess:N=>{if(N){const _=JSON.parse(N.data.result);h({...p,malloyResult:_});const Q=P.current;v(re=>re?{...re,executionState:"finished",response:{result:_,...Q?.defaultsNote?{messages:[{severity:"INFO",title:Q.defaultsNote}]}:{}}}:void 0)}},onError:N=>{console.error("Query execution error:",N);const _=N?.data?.message??N?.message??"The query could not be run.",Q=[{severity:"ERROR",title:_}],re=P.current?.missing??[];(N?.status===403||/Access denied for source/i.test(_))&&re.length>0&&Q.push({severity:"WARN",title:cd(re)}),v(te=>te?{...te,executionState:"finished",response:{messages:Q}}:void 0)}}),[A,L]=I.useState(e.sourceInfo.name);I.useEffect(()=>{A!==e.sourceInfo.name&&(L(e.sourceInfo.name),h(Ur()),v(void 0))},[e,A]);const V=I.useCallback(N=>{h({...p,malloyQuery:N,malloyResult:void 0})},[p]);return A!==e.sourceInfo.name?n.jsx("div",{children:"Loading..."}):n.jsx(B.StyledExplorerContent,{sx:{border:"1px solid #e0e0e0",borderRadius:"8px",overflow:"hidden"},children:n.jsx(C,{source:e.sourceInfo,query:p?.malloyQuery,topValues:[],onFocusedNestViewPathChange:y,focusedNestViewPath:x,onQueryChange:V,children:n.jsxs("div",{style:{display:"flex",height:"100%",overflowY:"auto"},children:[n.jsx(k,{isInitiallyExpanded:!0,initialWidth:180,minWidth:180,icon:"database",title:e.sourceInfo.name,children:n.jsx(M,{onRefresh:()=>h(Ur())})}),n.jsx(k,{isInitiallyExpanded:!0,initialWidth:280,minWidth:280,icon:"filterSliders",title:"Query",children:n.jsx(w,{runQuery:()=>{console.log(`running query with: ${p?.malloyQuery}`);try{K.mutate()}catch(N){console.error("Error running query:",N)}}})}),n.jsx(O,{source:e.sourceInfo,draftQuery:p?.malloyQuery,setDraftQuery:N=>h({...p,malloyQuery:N}),submittedQuery:g,options:{showRawQuery:!0}})]})})},e.sourceInfo.name)}function dd(e){const[r,u]=I.useState(null),[s,d]=I.useState(null),[c,l]=I.useState(!0);return I.useEffect(()=>{let m=!0;return Promise.all([import("@malloydata/malloy-explorer"),o.loadQueryBuilder()]).then(([p,h])=>{m&&(u(p),d(h),l(!1))}).catch(p=>{console.error("Failed to load Malloy components:",p),m&&l(!1)}),()=>{m=!1}},[]),c||!r||!s?n.jsx(B.StyledExplorerPage,{children:n.jsx(B.StyledExplorerContent,{children:n.jsx(Jn.Box,{sx:{alignItems:"center",justifyContent:"center",height:"200px",color:"text.secondary"},children:"Loading explorer..."})})}):n.jsx(ud,{...e,explorerComponents:r,QueryBuilder:s,resourceUri:e.resourceUri})}function us(e,r=!0){const{modelPath:u,environmentName:s,packageName:d,versionId:c}=o.parseResourceUri(e),{apiClients:l}=B.useServer();return o.useQueryWithApiError({queryKey:["package",s,d,u,c],queryFn:async()=>(await l.models.getModel(s,d,u,c)).data,enabled:r})}function ds({data:e,onChange:r,existingQuery:u,initialSelectedSourceIndex:s=0,onSourceChange:d,resourceUri:c,givens:l,onGivensChange:m,startingGivens:p}){const[h,g]=I.useState(s);I.useEffect(()=>{g(s)},[s]);const{data:v,isError:x,isLoading:y,error:C}=us(c,!e),{environmentName:w,packageName:k,modelPath:O,versionId:M}=o.parseResourceUri(c),j=e||v,E=I.useMemo(()=>j?.givens??[],[j]),$=o.useDocumentControls({specs:E,loaded:!!j,params:l,onGivensChange:m,startingValues:p,documentKey:c,autorun:!0,environmentName:w??"",packageName:k??"",modelPath:O,versionId:M,documentName:O}),U=I.useMemo(()=>o.givensToRequest($.applied,$.declaredTypes),[$.applied,$.declaredTypes]),P=I.useMemo(()=>ld(E,$.applied),[E,$.applied]);if(y&&!e)return n.jsx(o.Loading,{text:"Fetching Model..."});if(x&&!e)return console.log("error",C),n.jsx(o.ApiErrorDisplay,{error:C,context:`ModelExplorer > ${O}`});if(!j)return n.jsx(o.Loading,{text:o.LOADING_COPY.loading});const K=(j?.sourceInfos||[]).map((L,V)=>{try{return JSON.parse(L)?.name||`Source ${V+1}`}catch{return`Source ${V+1}`}}),A=K[h]||"";return n.jsxs(B.StyledCard,{variant:"outlined",children:[n.jsx(B.StyledCardContent,{children:n.jsx(S.Stack,{sx:{flexDirection:"row"},children:n.jsx(es,{size:"small",id:"size-small-standard",disablePortal:!0,options:K,value:A,onChange:(L,V)=>{if(!V)return;const N=K.indexOf(V);N>=0&&(g(N),d?.(N))},renderInput:L=>n.jsx(o.TextField,{...L}),style:{width:350,marginTop:"3px",marginLeft:"6px",marginBottom:"8px"}})})}),n.jsx(o.GivensPanel,{...$.panel}),n.jsx(B.StyledCardMedia,{children:n.jsxs(S.Stack,{spacing:2,component:"section",children:[Array.isArray(j.sourceInfos)&&j.sourceInfos.length>0&&n.jsx(ma,{sourceAndPaths:j.sourceInfos.map(L=>({sourceInfo:JSON.parse(L),modelPath:O})),selectedSourceIndex:h,existingQuery:u,onQueryChange:r,resourceUri:c,givens:U,gate:P}),n.jsx(S.Box,{height:"5px"})]})})]})}function hs({open:e,onClose:r,resourceUri:u,data:s,title:d="Data Sources",hasValidImport:c=!0,existingQuery:l,initialSelectedSourceIndex:m,onChange:p,onSourceChange:h,givens:g,onGivensChange:v,startingGivens:x}){return n.jsxs(S.Dialog,{open:e,onClose:r,fullScreen:!0,children:[n.jsxs(S.DialogTitle,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[d,n.jsx(S.IconButton,{onClick:r,sx:{color:"text.secondary"},children:n.jsx(o.CloseIcon,{})})]}),n.jsx(S.DialogContent,{children:c?n.jsx(ds,{resourceUri:u,data:s,existingQuery:l,initialSelectedSourceIndex:m,onChange:p,onSourceChange:h,givens:g,onGivensChange:v,startingGivens:x}):n.jsx("div",{children:"No valid import statement found in cell"})})]})}function hd({onChange:e,resourceUri:r,runOnDemand:u=!1,maxResultSize:s=0,givens:d,onGivensChange:c}){const{modelPath:l}=o.parseResourceUri(r),{data:m,isError:p,isLoading:h,error:g}=us(r),[v,x]=I.useState(!1),[y,C]=I.useState(),[w,k]=I.useState(0),[O,M]=I.useState(""),[j,E]=I.useState({}),$=d??j,U=c??(N=>E(N)),P=m?.modelDef,K=I.useMemo(()=>{if(!P)return!1;try{const N=JSON.parse(P);return Array.isArray(N.imports)&&N.imports.length>0}catch{return!1}},[P]);if(h)return n.jsx(o.Loading,{text:"Fetching Model..."});if(p)return console.log("error",g),n.jsx(o.ApiErrorDisplay,{error:g,context:`Model > ${l}`});const A=N=>{C(N),e&&e(N)},L=N=>{k(N)},V=()=>{const N=window.location.href;navigator.clipboard.writeText(N).then(()=>M("URL copied to clipboard!")).catch(()=>M("Failed to copy URL"))};return n.jsxs(n.Fragment,{children:[n.jsxs(S.Box,{sx:{position:"relative",maxWidth:"1200px",margin:"0 auto",paddingTop:"24px"},children:[Array.isArray(m?.sourceInfos)&&m.sourceInfos.length>0&&n.jsxs(S.Stack,{spacing:2,component:"section",children:[n.jsxs(S.Box,{sx:{padding:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx(S.Typography,{variant:"h1",sx:{fontSize:"28px",fontWeight:"600",color:"#1a1a1a",marginBottom:"8px",marginTop:"0",paddingLeft:"0"},children:"Sources"}),n.jsx(S.Tooltip,{title:"Copy link",children:n.jsx(S.IconButton,{size:"small","aria-label":"Copy link",onClick:V,sx:{color:"text.secondary"},children:n.jsx(ha,{fontSize:"small"})})})]}),n.jsx(ds,{data:m,onChange:A,onSourceChange:L,existingQuery:y,initialSelectedSourceIndex:w,resourceUri:r,givens:$,onGivensChange:U}),n.jsx(o.FloatingIconButton,{"aria-label":"Expand results",sx:{position:"absolute",top:"90px",right:"4px",zIndex:2},onClick:()=>x(!0),children:n.jsx(nr,{})})]}),m?.queries?.length>0&&n.jsxs(S.Stack,{spacing:2,component:"section",sx:{marginTop:"24px"},children:[n.jsx(S.Box,{sx:{padding:"0 0 16px 0"},children:n.jsx(S.Typography,{variant:"h2",sx:{fontSize:"24px",fontWeight:"600",color:"#1a1a1a",marginBottom:"0",marginTop:"8px",paddingLeft:"0"},children:"Named Queries"})}),m.queries.map(N=>n.jsx(ad,{queryName:N.name,annotations:N.annotations,resourceUri:r,runOnDemand:u,maxResultSize:s},N.name))]}),(!Array.isArray(m?.sourceInfos)||m.sourceInfos.length===0)&&!(m?.queries&&m.queries.length>0)&&n.jsxs(S.Box,{sx:{textAlign:"center",py:6},children:[n.jsx(S.Typography,{variant:"body1",sx:{color:"text.secondary",marginBottom:"8px"},children:"This model exposes no sources or queries."}),K&&n.jsxs(S.Typography,{variant:"body2",color:"text.secondary",children:["It imports other files but re-exports nothing. Add"," ",n.jsxs("code",{children:["export ","{ source_name }"]})," to surface imported sources here."]})]}),n.jsx(hs,{open:v,onClose:()=>x(!1),resourceUri:r,data:m,title:`Model: ${l.split("/").pop()}`,existingQuery:y,initialSelectedSourceIndex:w,onChange:A,onSourceChange:L,givens:$,onGivensChange:U})]}),n.jsx(S.Snackbar,{open:O!=="",autoHideDuration:6e3,onClose:()=>M(""),message:O})]})}function ga(e){return I.useMemo(()=>{if(!e?.sources?.length)return[];const r=new Map;for(const u of e.sources)if(u.givens?.length)for(const s of u.givens)s.name&&!r.has(s.name)&&r.set(s.name,s);return Array.from(r.values())},[e])}const fd=400;function pd(e){return e.kind?e.kind==="query":e.type==="code"}const ya=e=>e.proseLines!==void 0;function fs({text:e,proseLines:r}){return(e??"").split(`
|
|
7
|
-
`).filter((u,s)=>!r?.some(([d,c])=>s>=d&&s<=c))}function md(e){if(ya(e)||e.caption!==void 0)return e.caption;const r=[];for(const u of
|
|
4
|
+
`)};function vo(){const[e,r]=I.useState(!1),{apiClients:u}=B.useServer(),s=()=>{r(!0)},d=()=>{r(!1)},c=Cn({mutationFn(m){return u.environments.createEnvironment({name:m.name,readme:na({name:m.name,readme:""},m.description)})},success:"Environment created",invalidates:[["environments"]],closeDialog:d,resource:"environment",action:"create"}),l=async m=>{m.preventDefault();const p=new FormData(m.currentTarget),h=p.get("name")?.toString(),g=p.get("description")?.toString();if(!h)throw new Error("Name is required");c.mutate({name:h,description:g})};return n.jsxs(I.Fragment,{children:[n.jsx(o.AddButton,{label:"Environment",onClick:s}),n.jsx(o.AppDialog,{open:e,onClose:d,title:"New environment",description:"An environment holds packages and the connections they query through.",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:c.isPending,onClick:d,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"environment-form",variant:"contained",loading:c.isPending,children:"Create environment"})]}),children:n.jsx("form",{onSubmit:l,id:"environment-form",children:n.jsxs(Cr,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),n.jsx(o.TextField,{id:"description",name:"description",label:"Description",placeholder:"Explore semantic models, run queries, and build reports",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}})]})})}),c.notice]})}function Uc({environment:e,onCloseDialog:r}){const[u,s]=I.useState(!1),{apiClients:d}=B.useServer(),c=()=>{s(!0)},l=()=>{s(!1),r()},m=Cn({mutationFn:()=>d.environments.deleteEnvironment(e.name),success:"Environment deleted",invalidates:[["environments"]],closeDialog:l,resource:"environment",action:"delete"});return n.jsxs(I.Fragment,{children:[n.jsxs(S.MenuItem,{onClick:c,children:[n.jsx(S.ListItemIcon,{children:n.jsx(Ct.Delete,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Delete"})]}),n.jsx(o.AppDialog,{open:u,onClose:l,title:"Delete environment",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{onClick:l,children:"Cancel"}),n.jsx(o.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>m.mutate(),loading:m.isPending,children:"Delete environment"})]}),children:n.jsxs(o.Typography,{variant:"body2",children:["Delete ",n.jsx("strong",{children:e.name}),"? Its packages stop being served and this cannot be undone."]})}),m.notice]})}function Gc({environment:e,onCloseDialog:r}){const[u,s]=I.useState(!1),{apiClients:d}=B.useServer(),c=()=>{s(!0)},l=()=>{s(!1),r()},m=Cn({mutationFn(h){return d.environments.updateEnvironment(e.name,{name:e.name,readme:na({name:e.name,readme:e.readme},h.description)})},success:"Environment updated",invalidates:[["environments"]],closeDialog:l,resource:"environment",action:"update"}),p=h=>{h.preventDefault();const v=new FormData(h.currentTarget).get("description")?.toString();m.mutate({description:v})};return n.jsxs(I.Fragment,{children:[n.jsxs(S.MenuItem,{onClick:c,children:[n.jsx(S.ListItemIcon,{children:n.jsx(Ct.Edit,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Edit"})]}),n.jsx(o.AppDialog,{open:u,onClose:l,title:"Edit environment",description:"What this environment is, for the people who open it.",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{disabled:m.isPending,onClick:l,children:"Cancel"}),n.jsx(o.Button,{type:"submit",form:"environment-form",variant:"contained",loading:m.isPending,children:"Save changes"})]}),children:n.jsx("form",{onSubmit:p,id:"environment-form",children:n.jsxs(Cr,{sx:{gap:2},children:[n.jsx(o.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",disabled:!0,type:"text",fullWidth:!0,size:"small",defaultValue:e.name,InputLabelProps:{shrink:!0}}),n.jsx(o.TextField,{id:"description",name:"description",label:"Description",type:"text",fullWidth:!0,size:"small",defaultValue:ta(e.readme),InputLabelProps:{shrink:!0}})]})})}),m.notice]})}const Yc=[{title:"Model",body:"An agent writes what the data means in Malloy — sources, joins, measures — from a warehouse or a file, and validates each edit without a restart.",href:Rt.publishing},{title:"Analyze",body:"Claude, Cursor, Codex or an agent you build asks over MCP; applications and BI tools use REST. Every question runs against the model, never the raw tables.",href:Rt.mcpAgents},{title:"Surface",body:"Reports declared in Malloy, laid out as a grid or read top to bottom, and no-build HTML data apps, all shipped inside the package, plus this Console for browsing them.",href:Rt.surfaces},{title:"Govern",body:"Runtime parameters, row-level filters and per-source gates are declared in the model, so every surface reads the same rules rather than writing its own.",href:Rt.givens},{title:"Optimize",body:"One annotation materializes an expensive source into a table, and another rolls a measure up to a coarser grain, rebuilt on demand or on a schedule.",href:Rt.materialization},{title:"Run anywhere",body:"DuckDB is built in for CSV, Parquet, JSON and Excel; BigQuery, Snowflake, Postgres, Databricks, MotherDuck and more connect by configuration.",href:Rt.connections}];function Zc({href:e,children:r}){return n.jsx(S.Box,{component:"a",href:e,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary",textDecoration:"underline"},children:r})}function Kc({onClickEnvironment:e}){const{apiClients:r,mutable:u}=B.useServer(),{data:s,isSuccess:d,isError:c,error:l}=o.useQueryWithApiError({queryKey:["environments"],queryFn:()=>r.environments.listEnvironments()});if(c)return n.jsx(o.ApiErrorDisplay,{error:l,context:"Environments List"});if(!d)return n.jsx(o.Loading,{text:"Loading environments..."});const m=s.data??[];return n.jsxs(S.Container,{maxWidth:"md",sx:{py:6},children:[n.jsxs(S.Box,{sx:{mb:5},children:[n.jsx(S.Typography,{variant:"h3",component:"h1",sx:{fontWeight:500,letterSpacing:"-0.025em",mb:1},children:"Publisher"}),n.jsx(S.Typography,{variant:"body1",color:"text.secondary",sx:{mb:3},children:"The analytics engine for Malloy."}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{maxWidth:720,lineHeight:1.6},children:"One data model, served over MCP and REST to AI agents, applications and BI tools. Write down what your data means — the sources, the joins, the measures, who may see what — and every surface asks the same model, so the same question returns the same numbers tomorrow."})]}),n.jsx(S.Grid,{container:!0,spacing:4,sx:{mb:5},children:Yc.map(p=>n.jsx(S.Grid,{size:{xs:12,sm:6},children:n.jsxs(S.Stack,{spacing:1,children:[n.jsx(S.Typography,{variant:"body2",component:"a",href:p.href,target:"_blank",rel:"noopener noreferrer",sx:{fontWeight:500,color:"text.primary",textDecoration:"none","&:hover":{textDecoration:"underline"}},children:p.title}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{lineHeight:1.6},children:p.body})]})},p.title))}),n.jsx(S.Divider,{sx:{my:4}}),m.length>0?n.jsx(wt,{title:"Environments",count:m.length,description:"Published environments available on this server",...u?{action:n.jsx(vo,{})}:{},children:n.jsx(S.Stack,{children:m.map(p=>n.jsx(Xc,{environment:p,...e?{onClickEnvironment:e}:{}},p.name))})}):n.jsxs(S.Box,{sx:{mb:4},children:[n.jsx(S.Typography,{variant:"h5",sx:{fontWeight:500,letterSpacing:"-0.025em",mb:1},children:"Get started"}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{mb:3,maxWidth:600},children:"Create your first Malloy environment to start exploring semantic models and building data experiences."}),u?n.jsx(vo,{}):n.jsx(S.Button,{variant:"contained",color:"primary",href:Rt.publishing,target:"_blank",rel:"noopener noreferrer",children:"Learn how to create models"})]}),n.jsx(S.Divider,{sx:{my:4}}),n.jsxs(S.Typography,{variant:"body2",color:"text.secondary",sx:{maxWidth:720,lineHeight:1.6,mt:2},children:["Join the"," ",n.jsx(Zc,{href:"https://join.slack.com/t/malloy-community/shared_invite/zt-1kgfwgi5g-CrsdaRqs81QY67QW0~t_uw",children:"Malloy Slack community"})," ","to ask questions, share ideas, and contribute."]})]})}function Xc({environment:e,onClickEnvironment:r}){const{mutable:u}=B.useServer(),[s,d]=I.useState(null),c=!!s,l=ta(e.readme),m=h=>{h.stopPropagation(),d(h.currentTarget)},p=()=>d(null);return n.jsx(wr,{icon:n.jsx(Bc,{sx:{fontSize:18}}),tint:B.SURFACE_TINT.environment,label:e.name??"",ariaLabel:e.name??"",...l?{description:l}:{},...e.name&&r?{onClick:h=>r(`/${e.name}/`,h)}:{},...u?{trailingAction:n.jsxs(n.Fragment,{children:[n.jsx(S.IconButton,{size:"small",onClick:m,"aria-label":`Environment actions for ${e.name}`,children:n.jsx(Ct.MoreVert,{fontSize:"small"})}),n.jsxs(S.Menu,{anchorEl:s,open:c,onClose:p,onClick:h=>h.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[n.jsx(Gc,{environment:e,onCloseDialog:p}),n.jsx(Uc,{environment:e,onCloseDialog:p})]})]})}:{}})}var Kt={},it={},Wn={},Xt={},_r={},So;function Qc(){return So||(So=1,Object.defineProperty(_r,"__esModule",{value:!0})),_r}var qn={},zn={},wo;function tn(){if(wo)return zn;wo=1,Object.defineProperty(zn,"__esModule",{value:!0}),zn.CronField=void 0;let e=class ra{#e=!1;#n=!1;#o=!1;#s=[];options={rawValue:""};static get min(){throw new Error("min must be overridden")}static get max(){throw new Error("max must be overridden")}static get chars(){return Object.freeze([])}static get validChars(){return/^[?,*\dH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}static get constraints(){return{min:this.min,max:this.max,chars:this.chars,validChars:this.validChars}}constructor(u,s={rawValue:""}){if(!Array.isArray(u))throw new Error(`${this.constructor.name} Validation error, values is not an array`);if(!(u.length>0))throw new Error(`${this.constructor.name} Validation error, values contains no values`);this.options={...s,rawValue:s.rawValue??""},this.#s=u.sort(ra.sorter),this.#o=this.options.wildcard!==void 0?this.options.wildcard:this.#r(),this.#e=this.options.rawValue.includes("L")||u.includes("L"),this.#n=this.options.rawValue.includes("?")||u.includes("?")}get min(){return this.constructor.min}get max(){return this.constructor.max}get chars(){return this.constructor.chars}get hasLastChar(){return this.#e}get hasQuestionMarkChar(){return this.#n}get isWildcard(){return this.#o}get values(){return this.#s}static sorter(u,s){const d=typeof u=="number",c=typeof s=="number";return d&&c?u-s:!d&&!c?u.localeCompare(s):d?-1:1}static findNearestValueInList(u,s,d){if(d){for(let c=u.length-1;c>=0;c--)if(u[c]<s)return u[c];return null}for(let c=0;c<u.length;c++)if(u[c]>s)return u[c];return null}findNearestValue(u,s){return this.constructor.findNearestValueInList(this.values,u,s)}serialize(){return{wildcard:this.#o,values:this.#s}}validate(){let u;const s=this.chars.length>0?` or chars ${this.chars.join("")}`:"",d=p=>h=>new RegExp(`^\\d{0,2}${h}$`).test(p),c=p=>(u=p,typeof p=="number"?p>=this.min&&p<=this.max:this.chars.some(d(p)));if(!this.#s.every(c))throw new Error(`${this.constructor.name} Validation error, got value ${u} expected range ${this.min}-${this.max}${s}`);const m=this.#s.find((p,h)=>this.#s.indexOf(p)!==h);if(m)throw new Error(`${this.constructor.name} Validation error, duplicate values found: ${m}`)}#r(){return this.options.rawValue.length>0?["*","?"].includes(this.options.rawValue):Array.from({length:this.max-this.min+1},(u,s)=>s+this.min).every(u=>this.#s.includes(u))}};return zn.CronField=e,zn}var Co;function Jc(){if(Co)return qn;Co=1,Object.defineProperty(qn,"__esModule",{value:!0}),qn.CronDayOfMonth=void 0;const e=tn(),r=1,u=31,s=Object.freeze(["L"]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}static get validChars(){return/^[?,*\dLH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}};return qn.CronDayOfMonth=d,qn}var Hn={},ko;function eu(){if(ko)return Hn;ko=1,Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.CronDayOfWeek=void 0;const e=tn(),r=0,u=7,s=Object.freeze(["L"]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}static get validChars(){return/^[?,*\dLH#/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}get nthDay(){return this.options.nthDayOfWeek??0}};return Hn.CronDayOfWeek=d,Hn}var Vn={},To;function tu(){if(To)return Vn;To=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.CronHour=void 0;const e=tn(),r=0,u=23,s=Object.freeze([]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}};return Vn.CronHour=d,Vn}var Bn={},Oo;function nu(){if(Oo)return Bn;Oo=1,Object.defineProperty(Bn,"__esModule",{value:!0}),Bn.CronMinute=void 0;const e=tn(),r=0,u=59,s=Object.freeze([]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}};return Bn.CronMinute=d,Bn}var Un={},Wr={},rt={},Mo;function ru(){if(Mo)return rt;Mo=1,Object.defineProperty(rt,"__esModule",{value:!0});class e extends Error{}class r extends e{constructor(t){super(`Invalid DateTime: ${t.toMessage()}`)}}class u extends e{constructor(t){super(`Invalid Interval: ${t.toMessage()}`)}}class s extends e{constructor(t){super(`Invalid Duration: ${t.toMessage()}`)}}class d extends e{}class c extends e{constructor(t){super(`Invalid unit ${t}`)}}class l extends e{}class m extends e{constructor(){super("Zone is an abstract class")}}const p="numeric",h="short",g="long",v={year:p,month:p,day:p},x={year:p,month:h,day:p},y={year:p,month:h,day:p,weekday:h},C={year:p,month:g,day:p},w={year:p,month:g,day:p,weekday:g},k={hour:p,minute:p},O={hour:p,minute:p,second:p},M={hour:p,minute:p,second:p,timeZoneName:h},j={hour:p,minute:p,second:p,timeZoneName:g},E={hour:p,minute:p,hourCycle:"h23"},R={hour:p,minute:p,second:p,hourCycle:"h23"},U={hour:p,minute:p,second:p,hourCycle:"h23",timeZoneName:h},P={hour:p,minute:p,second:p,hourCycle:"h23",timeZoneName:g},K={year:p,month:p,day:p,hour:p,minute:p},A={year:p,month:p,day:p,hour:p,minute:p,second:p},L={year:p,month:h,day:p,hour:p,minute:p},V={year:p,month:h,day:p,hour:p,minute:p,second:p},N={year:p,month:h,day:p,weekday:h,hour:p,minute:p},W={year:p,month:g,day:p,hour:p,minute:p,timeZoneName:h},X={year:p,month:g,day:p,hour:p,minute:p,second:p,timeZoneName:h},ne={year:p,month:g,day:p,weekday:g,hour:p,minute:p,timeZoneName:g},J={year:p,month:g,day:p,weekday:g,hour:p,minute:p,second:p,timeZoneName:g};class ee{get type(){throw new m}get name(){throw new m}get ianaName(){return this.name}get isUniversal(){throw new m}offsetName(t,a){throw new m}formatOffset(t,a){throw new m}offset(t){throw new m}equals(t){throw new m}get isValid(){throw new m}}let Z=null;class ae extends ee{static get instance(){return Z===null&&(Z=new ae),Z}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(t,{format:a,locale:f}){return gs(t,a,f)}formatOffset(t,a){return Dn(this.offset(t),a)}offset(t){return-new Date(t).getTimezoneOffset()}equals(t){return t.type==="system"}get isValid(){return!0}}const H=new Map;function Q(i){let t=H.get(i);return t===void 0&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),H.set(i,t)),t}const re={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ve(i,t){const a=i.format(t).replace(/\u200E/g,""),f=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(a),[,b,T,D,F,$,G,ue]=f;return[D,b,T,F,$,G,ue]}function Re(i,t){const a=i.formatToParts(t),f=[];for(let b=0;b<a.length;b++){const{type:T,value:D}=a[b],F=re[T];T==="era"?f[F]=D:Y(F)||(f[F]=parseInt(D,10))}return f}const se=new Map;class ie extends ee{static create(t){let a=se.get(t);return a===void 0&&se.set(t,a=new ie(t)),a}static resetCache(){se.clear(),H.clear()}static isValidSpecifier(t){return this.isValidZone(t)}static isValidZone(t){if(!t)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=ie.isValidZone(t)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(t,{format:a,locale:f}){return gs(t,a,f,this.name)}formatOffset(t,a){return Dn(this.offset(t),a)}offset(t){if(!this.valid)return NaN;const a=new Date(t);if(isNaN(a))return NaN;const f=Q(this.name);let[b,T,D,F,$,G,ue]=f.formatToParts?Re(f,a):ve(f,a);F==="BC"&&(b=-Math.abs(b)+1);const Ee=or({year:b,month:T,day:D,hour:$===24?0:$,minute:G,second:ue,millisecond:0});let fe=+a;const Be=fe%1e3;return fe-=Be>=0?Be:1e3+Be,(Ee-fe)/(60*1e3)}equals(t){return t.type==="iana"&&t.name===this.name}get isValid(){return this.valid}}let Ne={};function xe(i,t={}){const a=JSON.stringify([i,t]);let f=Ne[a];return f||(f=new Intl.ListFormat(i,t),Ne[a]=f),f}const _=new Map;function oe(i,t={}){const a=JSON.stringify([i,t]);let f=_.get(a);return f===void 0&&(f=new Intl.DateTimeFormat(i,t),_.set(a,f)),f}const ge=new Map;function Te(i,t={}){const a=JSON.stringify([i,t]);let f=ge.get(a);return f===void 0&&(f=new Intl.NumberFormat(i,t),ge.set(a,f)),f}const be=new Map;function Oe(i,t={}){const{base:a,...f}=t,b=JSON.stringify([i,f]);let T=be.get(b);return T===void 0&&(T=new Intl.RelativeTimeFormat(i,t),be.set(b,T)),T}let $e=null;function Fe(){return $e||($e=new Intl.DateTimeFormat().resolvedOptions().locale,$e)}const Ye=new Map;function le(i){let t=Ye.get(i);return t===void 0&&(t=new Intl.DateTimeFormat(i).resolvedOptions(),Ye.set(i,t)),t}const Qe=new Map;function ye(i){let t=Qe.get(i);if(!t){const a=new Intl.Locale(i);t="getWeekInfo"in a?a.getWeekInfo():a.weekInfo,"minimalDays"in t||(t={...Ge,...t}),Qe.set(i,t)}return t}function We(i){const t=i.indexOf("-x-");t!==-1&&(i=i.substring(0,t));const a=i.indexOf("-u-");if(a===-1)return[i];{let f,b;try{f=oe(i).resolvedOptions(),b=i}catch{const $=i.substring(0,a);f=oe($).resolvedOptions(),b=$}const{numberingSystem:T,calendar:D}=f;return[b,T,D]}}function ct(i,t,a){return(a||t)&&(i.includes("-u-")||(i+="-u"),a&&(i+=`-ca-${a}`),t&&(i+=`-nu-${t}`)),i}function Nt(i){const t=[];for(let a=1;a<=12;a++){const f=me.utc(2009,a,1);t.push(i(f))}return t}function gt(i){const t=[];for(let a=1;a<=7;a++){const f=me.utc(2016,11,13+a);t.push(i(f))}return t}function Ze(i,t,a,f){const b=i.listingMode();return b==="error"?null:b==="en"?a(t):f(t)}function ut(i){return i.numberingSystem&&i.numberingSystem!=="latn"?!1:i.numberingSystem==="latn"||!i.locale||i.locale.startsWith("en")||le(i.locale).numberingSystem==="latn"}class pe{constructor(t,a,f){this.padTo=f.padTo||0,this.floor=f.floor||!1;const{padTo:b,floor:T,...D}=f;if(!a||Object.keys(D).length>0){const F={useGrouping:!1,...f};f.padTo>0&&(F.minimumIntegerDigits=f.padTo),this.inf=Te(t,F)}}format(t){if(this.inf){const a=this.floor?Math.floor(t):t;return this.inf.format(a)}else{const a=this.floor?Math.floor(t):Tr(t,3);return Ve(a,this.padTo)}}}class st{constructor(t,a,f){this.opts=f,this.originalZone=void 0;let b;if(this.opts.timeZone)this.dt=t;else if(t.zone.type==="fixed"){const D=-1*(t.offset/60),F=D>=0?`Etc/GMT+${D}`:`Etc/GMT${D}`;t.offset!==0&&ie.create(F).valid?(b=F,this.dt=t):(b="UTC",this.dt=t.offset===0?t:t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone)}else t.zone.type==="system"?this.dt=t:t.zone.type==="iana"?(this.dt=t,b=t.zone.name):(b="UTC",this.dt=t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone);const T={...this.opts};T.timeZone=T.timeZone||b,this.dtf=oe(a,T)}format(){return this.originalZone?this.formatToParts().map(({value:t})=>t).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const t=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?t.map(a=>{if(a.type==="timeZoneName"){const f=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...a,value:f}}else return a}):t}resolvedOptions(){return this.dtf.resolvedOptions()}}class nn{constructor(t,a,f){this.opts={style:"long",...f},!a&&Tn()&&(this.rtf=Oe(t,f))}format(t,a){return this.rtf?this.rtf.format(t,a):Ha(a,t,this.opts.numeric,this.opts.style!=="long")}formatToParts(t,a){return this.rtf?this.rtf.formatToParts(t,a):[]}}const Ge={firstDay:1,minimalDays:4,weekend:[6,7]};class ce{static fromOpts(t){return ce.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,a,f,b,T=!1){const D=t||je.defaultLocale,F=D||(T?"en-US":Fe()),$=a||je.defaultNumberingSystem,G=f||je.defaultOutputCalendar,ue=At(b)||je.defaultWeekSettings;return new ce(F,$,G,ue,D)}static resetCache(){$e=null,_.clear(),ge.clear(),be.clear(),Ye.clear(),Qe.clear()}static fromObject({locale:t,numberingSystem:a,outputCalendar:f,weekSettings:b}={}){return ce.create(t,a,f,b)}constructor(t,a,f,b,T){const[D,F,$]=We(t);this.locale=D,this.numberingSystem=a||F||null,this.outputCalendar=f||$||null,this.weekSettings=b,this.intl=ct(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=T,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=ut(this)),this.fastNumbersCached}listingMode(){const t=this.isEnglish(),a=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return t&&a?"en":"intl"}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:ce.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,At(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(t={}){return this.clone({...t,defaultToEN:!0})}redefaultToSystem(t={}){return this.clone({...t,defaultToEN:!1})}months(t,a=!1){return Ze(this,t,bs,()=>{const f=this.intl==="ja"||this.intl.startsWith("ja-");a&=!f;const b=a?{month:t,day:"numeric"}:{month:t},T=a?"format":"standalone";if(!this.monthsCache[T][t]){const D=f?F=>this.dtFormatter(F,b).format():F=>this.extract(F,b,"month");this.monthsCache[T][t]=Nt(D)}return this.monthsCache[T][t]})}weekdays(t,a=!1){return Ze(this,t,ws,()=>{const f=a?{weekday:t,year:"numeric",month:"long",day:"numeric"}:{weekday:t},b=a?"format":"standalone";return this.weekdaysCache[b][t]||(this.weekdaysCache[b][t]=gt(T=>this.extract(T,f,"weekday"))),this.weekdaysCache[b][t]})}meridiems(){return Ze(this,void 0,()=>Cs,()=>{if(!this.meridiemCache){const t={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[me.utc(2016,11,13,9),me.utc(2016,11,13,19)].map(a=>this.extract(a,t,"dayperiod"))}return this.meridiemCache})}eras(t){return Ze(this,t,ks,()=>{const a={era:t};return this.eraCache[t]||(this.eraCache[t]=[me.utc(-40,1,1),me.utc(2017,1,1)].map(f=>this.extract(f,a,"era"))),this.eraCache[t]})}extract(t,a,f){const b=this.dtFormatter(t,a),T=b.formatToParts(),D=T.find(F=>F.type.toLowerCase()===f);return D?D.value:null}numberFormatter(t={}){return new pe(this.intl,t.forceSimple||this.fastNumbers,t)}dtFormatter(t,a={}){return new st(t,this.intl,a)}relFormatter(t={}){return new nn(this.intl,this.isEnglish(),t)}listFormatter(t={}){return xe(this.intl,t)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||le(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:On()?ye(this.locale):Ge}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(t){return this.locale===t.locale&&this.numberingSystem===t.numberingSystem&&this.outputCalendar===t.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Je=null;class qe extends ee{static get utcInstance(){return Je===null&&(Je=new qe(0)),Je}static instance(t){return t===0?qe.utcInstance:new qe(t)}static parseSpecifier(t){if(t){const a=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(a)return new qe(ar(a[1],a[2]))}return null}constructor(t){super(),this.fixed=t}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Dn(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Dn(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(t,a){return Dn(this.fixed,a)}get isUniversal(){return!0}offset(){return this.fixed}equals(t){return t.type==="fixed"&&t.fixed===this.fixed}get isValid(){return!0}}class tt extends ee{constructor(t){super(),this.zoneName=t}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function dt(i,t){if(Y(i)||i===null)return t;if(i instanceof ee)return i;if(at(i)){const a=i.toLowerCase();return a==="default"?t:a==="local"||a==="system"?ae.instance:a==="utc"||a==="gmt"?qe.utcInstance:qe.parseSpecifier(a)||ie.create(i)}else return De(i)?qe.instance(i):typeof i=="object"&&"offset"in i&&typeof i.offset=="function"?i:new tt(i)}const ot={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},nt={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},rn=ot.hanidec.replace(/[\[|\]]/g,"").split("");function kn(i){let t=parseInt(i,10);if(isNaN(t)){t="";for(let a=0;a<i.length;a++){const f=i.charCodeAt(a);if(i[a].search(ot.hanidec)!==-1)t+=rn.indexOf(i[a]);else for(const b in nt){const[T,D]=nt[b];f>=T&&f<=D&&(t+=f-T)}}return parseInt(t,10)}else return t}const Ft=new Map;function kt(){Ft.clear()}function ze({numberingSystem:i},t=""){const a=i||"latn";let f=Ft.get(a);f===void 0&&(f=new Map,Ft.set(a,f));let b=f.get(t);return b===void 0&&(b=new RegExp(`${ot[a]}${t}`),f.set(t,b)),b}let Tt=()=>Date.now(),ht="system",ft=null,yt=null,sn=null,Ot=60,Ht,on=null;class je{static get now(){return Tt}static set now(t){Tt=t}static set defaultZone(t){ht=t}static get defaultZone(){return dt(ht,ae.instance)}static get defaultLocale(){return ft}static set defaultLocale(t){ft=t}static get defaultNumberingSystem(){return yt}static set defaultNumberingSystem(t){yt=t}static get defaultOutputCalendar(){return sn}static set defaultOutputCalendar(t){sn=t}static get defaultWeekSettings(){return on}static set defaultWeekSettings(t){on=At(t)}static get twoDigitCutoffYear(){return Ot}static set twoDigitCutoffYear(t){Ot=t%100}static get throwOnInvalid(){return Ht}static set throwOnInvalid(t){Ht=t}static resetCaches(){ce.resetCache(),ie.resetCache(),me.resetCache(),kt()}}class Ue{constructor(t,a){this.reason=t,this.explanation=a}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const _t=[0,31,59,90,120,151,181,212,243,273,304,334],an=[0,31,60,91,121,152,182,213,244,274,305,335];function Ke(i,t){return new Ue("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${i}, which is invalid`)}function Vt(i,t,a){const f=new Date(Date.UTC(i,t-1,a));i<100&&i>=0&&f.setUTCFullYear(f.getUTCFullYear()-1900);const b=f.getUTCDay();return b===0?7:b}function ln(i,t,a){return a+(Mn(i)?an:_t)[t-1]}function Wt(i,t){const a=Mn(i)?an:_t,f=a.findIndex(T=>T<t),b=t-a[f];return{month:f+1,day:b}}function Pe(i,t){return(i-t+7)%7+1}function Le(i,t=4,a=1){const{year:f,month:b,day:T}=i,D=ln(f,b,T),F=Pe(Vt(f,b,T),a);let $=Math.floor((D-F+14-t)/7),G;return $<1?(G=f-1,$=jn(G,t,a)):$>jn(f,t,a)?(G=f+1,$=1):G=f,{weekYear:G,weekNumber:$,weekday:F,...lr(i)}}function xt(i,t=4,a=1){const{weekYear:f,weekNumber:b,weekday:T}=i,D=Pe(Vt(f,1,t),a),F=un(f);let $=b*7+T-D-7+t,G;$<1?(G=f-1,$+=un(G)):$>F?(G=f+1,$-=un(f)):G=f;const{month:ue,day:Se}=Wt(G,$);return{year:G,month:ue,day:Se,...lr(i)}}function Bt(i){const{year:t,month:a,day:f}=i,b=ln(t,a,f);return{year:t,ordinal:b,...lr(i)}}function qt(i){const{year:t,ordinal:a}=i,{month:f,day:b}=Wt(t,a);return{year:t,month:f,day:b,...lr(i)}}function Ut(i,t){if(!Y(i.localWeekday)||!Y(i.localWeekNumber)||!Y(i.localWeekYear)){if(!Y(i.weekday)||!Y(i.weekNumber)||!Y(i.weekYear))throw new d("Cannot mix locale-based week fields with ISO-based week fields");return Y(i.localWeekday)||(i.weekday=i.localWeekday),Y(i.localWeekNumber)||(i.weekNumber=i.localWeekNumber),Y(i.localWeekYear)||(i.weekYear=i.localWeekYear),delete i.localWeekday,delete i.localWeekNumber,delete i.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function z(i,t=4,a=1){const f=Ie(i.weekYear),b=pt(i.weekNumber,1,jn(i.weekYear,t,a)),T=pt(i.weekday,1,7);return f?b?T?!1:Ke("weekday",i.weekday):Ke("week",i.weekNumber):Ke("weekYear",i.weekYear)}function q(i){const t=Ie(i.year),a=pt(i.ordinal,1,un(i.year));return t?a?!1:Ke("ordinal",i.ordinal):Ke("year",i.year)}function te(i){const t=Ie(i.year),a=pt(i.month,1,12),f=pt(i.day,1,sr(i.year,i.month));return t?a?f?!1:Ke("day",i.day):Ke("month",i.month):Ke("year",i.year)}function de(i){const{hour:t,minute:a,second:f,millisecond:b}=i,T=pt(t,0,23)||t===24&&a===0&&f===0&&b===0,D=pt(a,0,59),F=pt(f,0,59),$=pt(b,0,999);return T?D?F?$?!1:Ke("millisecond",b):Ke("second",f):Ke("minute",a):Ke("hour",t)}function Y(i){return typeof i>"u"}function De(i){return typeof i=="number"}function Ie(i){return typeof i=="number"&&i%1===0}function at(i){return typeof i=="string"}function cn(i){return Object.prototype.toString.call(i)==="[object Date]"}function Tn(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function On(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function rr(i){return Array.isArray(i)?i:[i]}function Ce(i,t,a){if(i.length!==0)return i.reduce((f,b)=>{const T=[t(b),b];return f&&a(f[0],T[0])===f[0]?f:T},null)[1]}function Mt(i,t){return t.reduce((a,f)=>(a[f]=i[f],a),{})}function et(i,t){return Object.prototype.hasOwnProperty.call(i,t)}function At(i){if(i==null)return null;if(typeof i!="object")throw new l("Week settings must be an object");if(!pt(i.firstDay,1,7)||!pt(i.minimalDays,1,7)||!Array.isArray(i.weekend)||i.weekend.some(t=>!pt(t,1,7)))throw new l("Invalid week settings");return{firstDay:i.firstDay,minimalDays:i.minimalDays,weekend:Array.from(i.weekend)}}function pt(i,t,a){return Ie(i)&&i>=t&&i<=a}function Na(i,t){return i-t*Math.floor(i/t)}function Ve(i,t=2){const a=i<0;let f;return a?f="-"+(""+-i).padStart(t,"0"):f=(""+i).padStart(t,"0"),f}function zt(i){if(!(Y(i)||i===null||i===""))return parseInt(i,10)}function Gt(i){if(!(Y(i)||i===null||i===""))return parseFloat(i)}function kr(i){if(!(Y(i)||i===null||i==="")){const t=parseFloat("0."+i)*1e3;return Math.floor(t)}}function Tr(i,t,a="round"){const f=10**t;switch(a){case"expand":return i>0?Math.ceil(i*f)/f:Math.floor(i*f)/f;case"trunc":return Math.trunc(i*f)/f;case"round":return Math.round(i*f)/f;case"floor":return Math.floor(i*f)/f;case"ceil":return Math.ceil(i*f)/f;default:throw new RangeError(`Value rounding ${a} is out of range`)}}function Mn(i){return i%4===0&&(i%100!==0||i%400===0)}function un(i){return Mn(i)?366:365}function sr(i,t){const a=Na(t-1,12)+1,f=i+(t-a)/12;return a===2?Mn(f)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][a-1]}function or(i){let t=Date.UTC(i.year,i.month-1,i.day,i.hour,i.minute,i.second,i.millisecond);return i.year<100&&i.year>=0&&(t=new Date(t),t.setUTCFullYear(i.year,i.month-1,i.day)),+t}function ms(i,t,a){return-Pe(Vt(i,1,t),a)+t-1}function jn(i,t=4,a=1){const f=ms(i,t,a),b=ms(i+1,t,a);return(un(i)-f+b)/7}function Or(i){return i>99?i:i>je.twoDigitCutoffYear?1900+i:2e3+i}function gs(i,t,a,f=null){const b=new Date(i),T={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};f&&(T.timeZone=f);const D={timeZoneName:t,...T},F=new Intl.DateTimeFormat(a,D).formatToParts(b).find($=>$.type.toLowerCase()==="timezonename");return F?F.value:null}function ar(i,t){let a=parseInt(i,10);Number.isNaN(a)&&(a=0);const f=parseInt(t,10)||0,b=a<0||Object.is(a,-0)?-f:f;return a*60+b}function ys(i){const t=Number(i);if(typeof i=="boolean"||i===""||!Number.isFinite(t))throw new l(`Invalid unit value ${i}`);return t}function ir(i,t){const a={};for(const f in i)if(et(i,f)){const b=i[f];if(b==null)continue;a[t(f)]=ys(b)}return a}function Dn(i,t){const a=Math.trunc(Math.abs(i/60)),f=Math.trunc(Math.abs(i%60)),b=i>=0?"+":"-";switch(t){case"short":return`${b}${Ve(a,2)}:${Ve(f,2)}`;case"narrow":return`${b}${a}${f>0?`:${f}`:""}`;case"techie":return`${b}${Ve(a,2)}${Ve(f,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function lr(i){return Mt(i,["hour","minute","second","millisecond"])}const Fa=["January","February","March","April","May","June","July","August","September","October","November","December"],xs=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Aa=["J","F","M","A","M","J","J","A","S","O","N","D"];function bs(i){switch(i){case"narrow":return[...Aa];case"short":return[...xs];case"long":return[...Fa];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const vs=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ss=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],$a=["M","T","W","T","F","S","S"];function ws(i){switch(i){case"narrow":return[...$a];case"short":return[...Ss];case"long":return[...vs];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Cs=["AM","PM"],Ra=["Before Christ","Anno Domini"],Pa=["BC","AD"],La=["B","A"];function ks(i){switch(i){case"narrow":return[...La];case"short":return[...Pa];case"long":return[...Ra];default:return null}}function _a(i){return Cs[i.hour<12?0:1]}function Wa(i,t){return ws(t)[i.weekday-1]}function qa(i,t){return bs(t)[i.month-1]}function za(i,t){return ks(t)[i.year<0?0:1]}function Ha(i,t,a="always",f=!1){const b={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},T=["hours","minutes","seconds"].indexOf(i)===-1;if(a==="auto"&&T){const Se=i==="days";switch(t){case 1:return Se?"tomorrow":`next ${b[i][0]}`;case-1:return Se?"yesterday":`last ${b[i][0]}`;case 0:return Se?"today":`this ${b[i][0]}`}}const D=Object.is(t,-0)||t<0,F=Math.abs(t),$=F===1,G=b[i],ue=f?$?G[1]:G[2]||G[1]:$?b[i][0]:i;return D?`${F} ${ue} ago`:`in ${F} ${ue}`}function Ts(i,t){let a="";for(const f of i)f.literal?a+=f.val:a+=t(f.val);return a}const Va={D:v,DD:x,DDD:C,DDDD:w,t:k,tt:O,ttt:M,tttt:j,T:E,TT:R,TTT:U,TTTT:P,f:K,ff:L,fff:W,ffff:ne,F:A,FF:V,FFF:X,FFFF:J};class Xe{static create(t,a={}){return new Xe(t,a)}static parseFormat(t){let a=null,f="",b=!1;const T=[];for(let D=0;D<t.length;D++){const F=t.charAt(D);F==="'"?((f.length>0||b)&&T.push({literal:b||/^\s+$/.test(f),val:f===""?"'":f}),a=null,f="",b=!b):b||F===a?f+=F:(f.length>0&&T.push({literal:/^\s+$/.test(f),val:f}),f=F,a=F)}return f.length>0&&T.push({literal:b||/^\s+$/.test(f),val:f}),T}static macroTokenToFormatOpts(t){return Va[t]}constructor(t,a){this.opts=a,this.loc=t,this.systemLoc=null}formatWithSystemDefault(t,a){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(t,{...this.opts,...a}).format()}dtFormatter(t,a={}){return this.loc.dtFormatter(t,{...this.opts,...a})}formatDateTime(t,a){return this.dtFormatter(t,a).format()}formatDateTimeParts(t,a){return this.dtFormatter(t,a).formatToParts()}formatInterval(t,a){return this.dtFormatter(t.start,a).dtf.formatRange(t.start.toJSDate(),t.end.toJSDate())}resolvedOptions(t,a){return this.dtFormatter(t,a).resolvedOptions()}num(t,a=0,f=void 0){if(this.opts.forceSimple)return Ve(t,a);const b={...this.opts};return a>0&&(b.padTo=a),f&&(b.signDisplay=f),this.loc.numberFormatter(b).format(t)}formatDateTimeFromString(t,a){const f=this.loc.listingMode()==="en",b=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",T=(fe,Be)=>this.loc.extract(t,fe,Be),D=fe=>t.isOffsetFixed&&t.offset===0&&fe.allowZ?"Z":t.isValid?t.zone.formatOffset(t.ts,fe.format):"",F=()=>f?_a(t):T({hour:"numeric",hourCycle:"h12"},"dayperiod"),$=(fe,Be)=>f?qa(t,fe):T(Be?{month:fe}:{month:fe,day:"numeric"},"month"),G=(fe,Be)=>f?Wa(t,fe):T(Be?{weekday:fe}:{weekday:fe,month:"long",day:"numeric"},"weekday"),ue=fe=>{const Be=Xe.macroTokenToFormatOpts(fe);return Be?this.formatWithSystemDefault(t,Be):fe},Se=fe=>f?za(t,fe):T({era:fe},"era"),Ee=fe=>{switch(fe){case"S":return this.num(t.millisecond);case"u":case"SSS":return this.num(t.millisecond,3);case"s":return this.num(t.second);case"ss":return this.num(t.second,2);case"uu":return this.num(Math.floor(t.millisecond/10),2);case"uuu":return this.num(Math.floor(t.millisecond/100));case"m":return this.num(t.minute);case"mm":return this.num(t.minute,2);case"h":return this.num(t.hour%12===0?12:t.hour%12);case"hh":return this.num(t.hour%12===0?12:t.hour%12,2);case"H":return this.num(t.hour);case"HH":return this.num(t.hour,2);case"Z":return D({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return D({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return D({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return t.zone.offsetName(t.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return t.zone.offsetName(t.ts,{format:"long",locale:this.loc.locale});case"z":return t.zoneName;case"a":return F();case"d":return b?T({day:"numeric"},"day"):this.num(t.day);case"dd":return b?T({day:"2-digit"},"day"):this.num(t.day,2);case"c":return this.num(t.weekday);case"ccc":return G("short",!0);case"cccc":return G("long",!0);case"ccccc":return G("narrow",!0);case"E":return this.num(t.weekday);case"EEE":return G("short",!1);case"EEEE":return G("long",!1);case"EEEEE":return G("narrow",!1);case"L":return b?T({month:"numeric",day:"numeric"},"month"):this.num(t.month);case"LL":return b?T({month:"2-digit",day:"numeric"},"month"):this.num(t.month,2);case"LLL":return $("short",!0);case"LLLL":return $("long",!0);case"LLLLL":return $("narrow",!0);case"M":return b?T({month:"numeric"},"month"):this.num(t.month);case"MM":return b?T({month:"2-digit"},"month"):this.num(t.month,2);case"MMM":return $("short",!1);case"MMMM":return $("long",!1);case"MMMMM":return $("narrow",!1);case"y":return b?T({year:"numeric"},"year"):this.num(t.year);case"yy":return b?T({year:"2-digit"},"year"):this.num(t.year.toString().slice(-2),2);case"yyyy":return b?T({year:"numeric"},"year"):this.num(t.year,4);case"yyyyyy":return b?T({year:"numeric"},"year"):this.num(t.year,6);case"G":return Se("short");case"GG":return Se("long");case"GGGGG":return Se("narrow");case"kk":return this.num(t.weekYear.toString().slice(-2),2);case"kkkk":return this.num(t.weekYear,4);case"W":return this.num(t.weekNumber);case"WW":return this.num(t.weekNumber,2);case"n":return this.num(t.localWeekNumber);case"nn":return this.num(t.localWeekNumber,2);case"ii":return this.num(t.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(t.localWeekYear,4);case"o":return this.num(t.ordinal);case"ooo":return this.num(t.ordinal,3);case"q":return this.num(t.quarter);case"qq":return this.num(t.quarter,2);case"X":return this.num(Math.floor(t.ts/1e3));case"x":return this.num(t.ts);default:return ue(fe)}};return Ts(Xe.parseFormat(a),Ee)}formatDurationFromString(t,a){const f=this.opts.signMode==="negativeLargestOnly"?-1:1,b=ue=>{switch(ue[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},T=(ue,Se)=>Ee=>{const fe=b(Ee);if(fe){const Be=Se.isNegativeDuration&&fe!==Se.largestUnit?f:1;let vt;return this.opts.signMode==="negativeLargestOnly"&&fe!==Se.largestUnit?vt="never":this.opts.signMode==="all"?vt="always":vt="auto",this.num(ue.get(fe)*Be,Ee.length,vt)}else return Ee},D=Xe.parseFormat(a),F=D.reduce((ue,{literal:Se,val:Ee})=>Se?ue:ue.concat(Ee),[]),$=t.shiftTo(...F.map(b).filter(ue=>ue)),G={isNegativeDuration:$<0,largestUnit:Object.keys($.values)[0]};return Ts(D,T($,G))}}const Os=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function dn(...i){const t=i.reduce((a,f)=>a+f.source,"");return RegExp(`^${t}$`)}function hn(...i){return t=>i.reduce(([a,f,b],T)=>{const[D,F,$]=T(t,b);return[{...a,...D},F||f,$]},[{},null,1]).slice(0,2)}function fn(i,...t){if(i==null)return[null,null];for(const[a,f]of t){const b=a.exec(i);if(b)return f(b)}return[null,null]}function Ms(...i){return(t,a)=>{const f={};let b;for(b=0;b<i.length;b++)f[i[b]]=zt(t[a+b]);return[f,null,a+b]}}const js=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Ba=`(?:${js.source}?(?:\\[(${Os.source})\\])?)?`,Mr=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Ds=RegExp(`${Mr.source}${Ba}`),jr=RegExp(`(?:[Tt]${Ds.source})?`),Ua=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Ga=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Ya=/(\d{4})-?(\d{3})/,Za=Ms("weekYear","weekNumber","weekDay"),Ka=Ms("year","ordinal"),Xa=/(\d{4})-(\d\d)-(\d\d)/,Es=RegExp(`${Mr.source} ?(?:${js.source}|(${Os.source}))?`),Qa=RegExp(`(?: ${Es.source})?`);function pn(i,t,a){const f=i[t];return Y(f)?a:zt(f)}function Ja(i,t){return[{year:pn(i,t),month:pn(i,t+1,1),day:pn(i,t+2,1)},null,t+3]}function mn(i,t){return[{hours:pn(i,t,0),minutes:pn(i,t+1,0),seconds:pn(i,t+2,0),milliseconds:kr(i[t+3])},null,t+4]}function En(i,t){const a=!i[t]&&!i[t+1],f=ar(i[t+1],i[t+2]),b=a?null:qe.instance(f);return[{},b,t+3]}function In(i,t){const a=i[t]?ie.create(i[t]):null;return[{},a,t+1]}const ei=RegExp(`^T?${Mr.source}$`),ti=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function ni(i){const[t,a,f,b,T,D,F,$,G]=i,ue=t[0]==="-",Se=$&&$[0]==="-",Ee=(fe,Be=!1)=>fe!==void 0&&(Be||fe&&ue)?-fe:fe;return[{years:Ee(Gt(a)),months:Ee(Gt(f)),weeks:Ee(Gt(b)),days:Ee(Gt(T)),hours:Ee(Gt(D)),minutes:Ee(Gt(F)),seconds:Ee(Gt($),$==="-0"),milliseconds:Ee(kr(G),Se)}]}const ri={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Dr(i,t,a,f,b,T,D){const F={year:t.length===2?Or(zt(t)):zt(t),month:xs.indexOf(a)+1,day:zt(f),hour:zt(b),minute:zt(T)};return D&&(F.second=zt(D)),i&&(F.weekday=i.length>3?vs.indexOf(i)+1:Ss.indexOf(i)+1),F}const si=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function oi(i){const[,t,a,f,b,T,D,F,$,G,ue,Se]=i,Ee=Dr(t,b,f,a,T,D,F);let fe;return $?fe=ri[$]:G?fe=0:fe=ar(ue,Se),[Ee,new qe(fe)]}function ai(i){return i.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const ii=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,li=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,ci=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Is(i){const[,t,a,f,b,T,D,F]=i;return[Dr(t,b,f,a,T,D,F),qe.utcInstance]}function ui(i){const[,t,a,f,b,T,D,F]=i;return[Dr(t,F,a,f,b,T,D),qe.utcInstance]}const di=dn(Ua,jr),hi=dn(Ga,jr),fi=dn(Ya,jr),pi=dn(Ds),Ns=hn(Ja,mn,En,In),mi=hn(Za,mn,En,In),gi=hn(Ka,mn,En,In),yi=hn(mn,En,In);function xi(i){return fn(i,[di,Ns],[hi,mi],[fi,gi],[pi,yi])}function bi(i){return fn(ai(i),[si,oi])}function vi(i){return fn(i,[ii,Is],[li,Is],[ci,ui])}function Si(i){return fn(i,[ti,ni])}const wi=hn(mn);function Ci(i){return fn(i,[ei,wi])}const ki=dn(Xa,Qa),Ti=dn(Es),Oi=hn(mn,En,In);function Mi(i){return fn(i,[ki,Ns],[Ti,Oi])}const Fs="Invalid Duration",As={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},ji={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...As},mt=146097/400,gn=146097/4800,Di={years:{quarters:4,months:12,weeks:mt/7,days:mt,hours:mt*24,minutes:mt*24*60,seconds:mt*24*60*60,milliseconds:mt*24*60*60*1e3},quarters:{months:3,weeks:mt/28,days:mt/4,hours:mt*24/4,minutes:mt*24*60/4,seconds:mt*24*60*60/4,milliseconds:mt*24*60*60*1e3/4},months:{weeks:gn/7,days:gn,hours:gn*24,minutes:gn*24*60,seconds:gn*24*60*60,milliseconds:gn*24*60*60*1e3},...As},Yt=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Ei=Yt.slice(0).reverse();function $t(i,t,a=!1){const f={values:a?t.values:{...i.values,...t.values||{}},loc:i.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||i.conversionAccuracy,matrix:t.matrix||i.matrix};return new ke(f)}function $s(i,t){var a;let f=(a=t.milliseconds)!=null?a:0;for(const b of Ei.slice(1))t[b]&&(f+=t[b]*i[b].milliseconds);return f}function Rs(i,t){const a=$s(i,t)<0?-1:1;Yt.reduceRight((f,b)=>{if(Y(t[b]))return f;if(f){const T=t[f]*a,D=i[b][f],F=Math.floor(T/D);t[b]+=F*a,t[f]-=F*D*a}return b},null),Yt.reduce((f,b)=>{if(Y(t[b]))return f;if(f){const T=t[f]%1;t[f]-=T,t[b]+=T*i[f][b]}return b},null)}function Ps(i){const t={};for(const[a,f]of Object.entries(i))f!==0&&(t[a]=f);return t}class ke{constructor(t){const a=t.conversionAccuracy==="longterm"||!1;let f=a?Di:ji;t.matrix&&(f=t.matrix),this.values=t.values,this.loc=t.loc||ce.create(),this.conversionAccuracy=a?"longterm":"casual",this.invalid=t.invalid||null,this.matrix=f,this.isLuxonDuration=!0}static fromMillis(t,a){return ke.fromObject({milliseconds:t},a)}static fromObject(t,a={}){if(t==null||typeof t!="object")throw new l(`Duration.fromObject: argument expected to be an object, got ${t===null?"null":typeof t}`);return new ke({values:ir(t,ke.normalizeUnit),loc:ce.fromObject(a),conversionAccuracy:a.conversionAccuracy,matrix:a.matrix})}static fromDurationLike(t){if(De(t))return ke.fromMillis(t);if(ke.isDuration(t))return t;if(typeof t=="object")return ke.fromObject(t);throw new l(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,a){const[f]=Si(t);return f?ke.fromObject(f,a):ke.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,a){const[f]=Ci(t);return f?ke.fromObject(f,a):ke.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,a=null){if(!t)throw new l("need to specify a reason the Duration is invalid");const f=t instanceof Ue?t:new Ue(t,a);if(je.throwOnInvalid)throw new s(f);return new ke({invalid:f})}static normalizeUnit(t){const a={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[t&&t.toLowerCase()];if(!a)throw new c(t);return a}static isDuration(t){return t&&t.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(t,a={}){const f={...a,floor:a.round!==!1&&a.floor!==!1};return this.isValid?Xe.create(this.loc,f).formatDurationFromString(this,t):Fs}toHuman(t={}){if(!this.isValid)return Fs;const a=t.showZeros!==!1,f=Yt.map(b=>{const T=this.values[b];return Y(T)||T===0&&!a?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...t,unit:b.slice(0,-1)}).format(T)}).filter(b=>b);return this.loc.listFormatter({type:"conjunction",style:t.listStyle||"narrow",...t}).format(f)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let t="P";return this.years!==0&&(t+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(t+=this.months+this.quarters*3+"M"),this.weeks!==0&&(t+=this.weeks+"W"),this.days!==0&&(t+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(t+="T"),this.hours!==0&&(t+=this.hours+"H"),this.minutes!==0&&(t+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(t+=Tr(this.seconds+this.milliseconds/1e3,3)+"S"),t==="P"&&(t+="T0S"),t}toISOTime(t={}){if(!this.isValid)return null;const a=this.toMillis();return a<0||a>=864e5?null:(t={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...t,includeOffset:!1},me.fromMillis(a,{zone:"UTC"}).toISOTime(t))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?$s(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;const a=ke.fromDurationLike(t),f={};for(const b of Yt)(et(a.values,b)||et(this.values,b))&&(f[b]=a.get(b)+this.get(b));return $t(this,{values:f},!0)}minus(t){if(!this.isValid)return this;const a=ke.fromDurationLike(t);return this.plus(a.negate())}mapUnits(t){if(!this.isValid)return this;const a={};for(const f of Object.keys(this.values))a[f]=ys(t(this.values[f],f));return $t(this,{values:a},!0)}get(t){return this[ke.normalizeUnit(t)]}set(t){if(!this.isValid)return this;const a={...this.values,...ir(t,ke.normalizeUnit)};return $t(this,{values:a})}reconfigure({locale:t,numberingSystem:a,conversionAccuracy:f,matrix:b}={}){const D={loc:this.loc.clone({locale:t,numberingSystem:a}),matrix:b,conversionAccuracy:f};return $t(this,D)}as(t){return this.isValid?this.shiftTo(t).get(t):NaN}normalize(){if(!this.isValid)return this;const t=this.toObject();return Rs(this.matrix,t),$t(this,{values:t},!0)}rescale(){if(!this.isValid)return this;const t=Ps(this.normalize().shiftToAll().toObject());return $t(this,{values:t},!0)}shiftTo(...t){if(!this.isValid)return this;if(t.length===0)return this;t=t.map(D=>ke.normalizeUnit(D));const a={},f={},b=this.toObject();let T;for(const D of Yt)if(t.indexOf(D)>=0){T=D;let F=0;for(const G in f)F+=this.matrix[G][D]*f[G],f[G]=0;De(b[D])&&(F+=b[D]);const $=Math.trunc(F);a[D]=$,f[D]=(F*1e3-$*1e3)/1e3}else De(b[D])&&(f[D]=b[D]);for(const D in f)f[D]!==0&&(a[T]+=D===T?f[D]:f[D]/this.matrix[T][D]);return Rs(this.matrix,a),$t(this,{values:a},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const t={};for(const a of Object.keys(this.values))t[a]=this.values[a]===0?0:-this.values[a];return $t(this,{values:t},!0)}removeZeros(){if(!this.isValid)return this;const t=Ps(this.values);return $t(this,{values:t},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(t){if(!this.isValid||!t.isValid||!this.loc.equals(t.loc))return!1;function a(f,b){return f===void 0||f===0?b===void 0||b===0:f===b}for(const f of Yt)if(!a(this.values[f],t.values[f]))return!1;return!0}}const yn="Invalid Interval";function Ii(i,t){return!i||!i.isValid?_e.invalid("missing or invalid start"):!t||!t.isValid?_e.invalid("missing or invalid end"):t<i?_e.invalid("end before start",`The end of an interval must be after its start, but you had start=${i.toISO()} and end=${t.toISO()}`):null}class _e{constructor(t){this.s=t.start,this.e=t.end,this.invalid=t.invalid||null,this.isLuxonInterval=!0}static invalid(t,a=null){if(!t)throw new l("need to specify a reason the Interval is invalid");const f=t instanceof Ue?t:new Ue(t,a);if(je.throwOnInvalid)throw new u(f);return new _e({invalid:f})}static fromDateTimes(t,a){const f=$n(t),b=$n(a),T=Ii(f,b);return T??new _e({start:f,end:b})}static after(t,a){const f=ke.fromDurationLike(a),b=$n(t);return _e.fromDateTimes(b,b.plus(f))}static before(t,a){const f=ke.fromDurationLike(a),b=$n(t);return _e.fromDateTimes(b.minus(f),b)}static fromISO(t,a){const[f,b]=(t||"").split("/",2);if(f&&b){let T,D;try{T=me.fromISO(f,a),D=T.isValid}catch{D=!1}let F,$;try{F=me.fromISO(b,a),$=F.isValid}catch{$=!1}if(D&&$)return _e.fromDateTimes(T,F);if(D){const G=ke.fromISO(b,a);if(G.isValid)return _e.after(T,G)}else if($){const G=ke.fromISO(f,a);if(G.isValid)return _e.before(F,G)}}return _e.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(t){return t&&t.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(t="milliseconds"){return this.isValid?this.toDuration(t).get(t):NaN}count(t="milliseconds",a){if(!this.isValid)return NaN;const f=this.start.startOf(t,a);let b;return a!=null&&a.useLocaleWeeks?b=this.end.reconfigure({locale:f.locale}):b=this.end,b=b.startOf(t,a),Math.floor(b.diff(f,t).get(t))+(b.valueOf()!==this.end.valueOf())}hasSame(t){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,t):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(t){return this.isValid?this.s>t:!1}isBefore(t){return this.isValid?this.e<=t:!1}contains(t){return this.isValid?this.s<=t&&this.e>t:!1}set({start:t,end:a}={}){return this.isValid?_e.fromDateTimes(t||this.s,a||this.e):this}splitAt(...t){if(!this.isValid)return[];const a=t.map($n).filter(D=>this.contains(D)).sort((D,F)=>D.toMillis()-F.toMillis()),f=[];let{s:b}=this,T=0;for(;b<this.e;){const D=a[T]||this.e,F=+D>+this.e?this.e:D;f.push(_e.fromDateTimes(b,F)),b=F,T+=1}return f}splitBy(t){const a=ke.fromDurationLike(t);if(!this.isValid||!a.isValid||a.as("milliseconds")===0)return[];let{s:f}=this,b=1,T;const D=[];for(;f<this.e;){const F=this.start.plus(a.mapUnits($=>$*b));T=+F>+this.e?this.e:F,D.push(_e.fromDateTimes(f,T)),f=T,b+=1}return D}divideEqually(t){return this.isValid?this.splitBy(this.length()/t).slice(0,t):[]}overlaps(t){return this.e>t.s&&this.s<t.e}abutsStart(t){return this.isValid?+this.e==+t.s:!1}abutsEnd(t){return this.isValid?+t.e==+this.s:!1}engulfs(t){return this.isValid?this.s<=t.s&&this.e>=t.e:!1}equals(t){return!this.isValid||!t.isValid?!1:this.s.equals(t.s)&&this.e.equals(t.e)}intersection(t){if(!this.isValid)return this;const a=this.s>t.s?this.s:t.s,f=this.e<t.e?this.e:t.e;return a>=f?null:_e.fromDateTimes(a,f)}union(t){if(!this.isValid)return this;const a=this.s<t.s?this.s:t.s,f=this.e>t.e?this.e:t.e;return _e.fromDateTimes(a,f)}static merge(t){const[a,f]=t.sort((b,T)=>b.s-T.s).reduce(([b,T],D)=>T?T.overlaps(D)||T.abutsStart(D)?[b,T.union(D)]:[b.concat([T]),D]:[b,D],[[],null]);return f&&a.push(f),a}static xor(t){let a=null,f=0;const b=[],T=t.map($=>[{time:$.s,type:"s"},{time:$.e,type:"e"}]),D=Array.prototype.concat(...T),F=D.sort(($,G)=>$.time-G.time);for(const $ of F)f+=$.type==="s"?1:-1,f===1?a=$.time:(a&&+a!=+$.time&&b.push(_e.fromDateTimes(a,$.time)),a=null);return _e.merge(b)}difference(...t){return _e.xor([this].concat(t)).map(a=>this.intersection(a)).filter(a=>a&&!a.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:yn}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(t=v,a={}){return this.isValid?Xe.create(this.s.loc.clone(a),t).formatInterval(this):yn}toISO(t){return this.isValid?`${this.s.toISO(t)}/${this.e.toISO(t)}`:yn}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:yn}toISOTime(t){return this.isValid?`${this.s.toISOTime(t)}/${this.e.toISOTime(t)}`:yn}toFormat(t,{separator:a=" – "}={}){return this.isValid?`${this.s.toFormat(t)}${a}${this.e.toFormat(t)}`:yn}toDuration(t,a){return this.isValid?this.e.diff(this.s,t,a):ke.invalid(this.invalidReason)}mapEndpoints(t){return _e.fromDateTimes(t(this.s),t(this.e))}}class Nn{static hasDST(t=je.defaultZone){const a=me.now().setZone(t).set({month:12});return!t.isUniversal&&a.offset!==a.set({month:6}).offset}static isValidIANAZone(t){return ie.isValidZone(t)}static normalizeZone(t){return dt(t,je.defaultZone)}static getStartOfWeek({locale:t=null,locObj:a=null}={}){return(a||ce.create(t)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:t=null,locObj:a=null}={}){return(a||ce.create(t)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:t=null,locObj:a=null}={}){return(a||ce.create(t)).getWeekendDays().slice()}static months(t="long",{locale:a=null,numberingSystem:f=null,locObj:b=null,outputCalendar:T="gregory"}={}){return(b||ce.create(a,f,T)).months(t)}static monthsFormat(t="long",{locale:a=null,numberingSystem:f=null,locObj:b=null,outputCalendar:T="gregory"}={}){return(b||ce.create(a,f,T)).months(t,!0)}static weekdays(t="long",{locale:a=null,numberingSystem:f=null,locObj:b=null}={}){return(b||ce.create(a,f,null)).weekdays(t)}static weekdaysFormat(t="long",{locale:a=null,numberingSystem:f=null,locObj:b=null}={}){return(b||ce.create(a,f,null)).weekdays(t,!0)}static meridiems({locale:t=null}={}){return ce.create(t).meridiems()}static eras(t="short",{locale:a=null}={}){return ce.create(a,null,"gregory").eras(t)}static features(){return{relative:Tn(),localeWeek:On()}}}function Ls(i,t){const a=b=>b.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),f=a(t)-a(i);return Math.floor(ke.fromMillis(f).as("days"))}function Ni(i,t,a){const f=[["years",($,G)=>G.year-$.year],["quarters",($,G)=>G.quarter-$.quarter+(G.year-$.year)*4],["months",($,G)=>G.month-$.month+(G.year-$.year)*12],["weeks",($,G)=>{const ue=Ls($,G);return(ue-ue%7)/7}],["days",Ls]],b={},T=i;let D,F;for(const[$,G]of f)a.indexOf($)>=0&&(D=$,b[$]=G(i,t),F=T.plus(b),F>t?(b[$]--,i=T.plus(b),i>t&&(F=i,b[$]--,i=T.plus(b))):i=F);return[i,b,F,D]}function Fi(i,t,a,f){let[b,T,D,F]=Ni(i,t,a);const $=t-b,G=a.filter(Se=>["hours","minutes","seconds","milliseconds"].indexOf(Se)>=0);G.length===0&&(D<t&&(D=b.plus({[F]:1})),D!==b&&(T[F]=(T[F]||0)+$/(D-b)));const ue=ke.fromObject(T,f);return G.length>0?ke.fromMillis($,f).shiftTo(...G).plus(ue):ue}const Ai="missing Intl.DateTimeFormat.formatToParts support";function Me(i,t=a=>a){return{regex:i,deser:([a])=>t(kn(a))}}const _s="[ ]",Ws=new RegExp(_s,"g");function $i(i){return i.replace(/\./g,"\\.?").replace(Ws,_s)}function qs(i){return i.replace(/\./g,"").replace(Ws," ").toLowerCase()}function bt(i,t){return i===null?null:{regex:RegExp(i.map($i).join("|")),deser:([a])=>i.findIndex(f=>qs(a)===qs(f))+t}}function zs(i,t){return{regex:i,deser:([,a,f])=>ar(a,f),groups:t}}function cr(i){return{regex:i,deser:([t])=>t}}function Ri(i){return i.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Pi(i,t){const a=ze(t),f=ze(t,"{2}"),b=ze(t,"{3}"),T=ze(t,"{4}"),D=ze(t,"{6}"),F=ze(t,"{1,2}"),$=ze(t,"{1,3}"),G=ze(t,"{1,6}"),ue=ze(t,"{1,9}"),Se=ze(t,"{2,4}"),Ee=ze(t,"{4,6}"),fe=jt=>({regex:RegExp(Ri(jt.val)),deser:([bn])=>bn,literal:!0}),vt=(jt=>{if(i.literal)return fe(jt);switch(jt.val){case"G":return bt(t.eras("short"),0);case"GG":return bt(t.eras("long"),0);case"y":return Me(G);case"yy":return Me(Se,Or);case"yyyy":return Me(T);case"yyyyy":return Me(Ee);case"yyyyyy":return Me(D);case"M":return Me(F);case"MM":return Me(f);case"MMM":return bt(t.months("short",!0),1);case"MMMM":return bt(t.months("long",!0),1);case"L":return Me(F);case"LL":return Me(f);case"LLL":return bt(t.months("short",!1),1);case"LLLL":return bt(t.months("long",!1),1);case"d":return Me(F);case"dd":return Me(f);case"o":return Me($);case"ooo":return Me(b);case"HH":return Me(f);case"H":return Me(F);case"hh":return Me(f);case"h":return Me(F);case"mm":return Me(f);case"m":return Me(F);case"q":return Me(F);case"qq":return Me(f);case"s":return Me(F);case"ss":return Me(f);case"S":return Me($);case"SSS":return Me(b);case"u":return cr(ue);case"uu":return cr(F);case"uuu":return Me(a);case"a":return bt(t.meridiems(),0);case"kkkk":return Me(T);case"kk":return Me(Se,Or);case"W":return Me(F);case"WW":return Me(f);case"E":case"c":return Me(a);case"EEE":return bt(t.weekdays("short",!1),1);case"EEEE":return bt(t.weekdays("long",!1),1);case"ccc":return bt(t.weekdays("short",!0),1);case"cccc":return bt(t.weekdays("long",!0),1);case"Z":case"ZZ":return zs(new RegExp(`([+-]${F.source})(?::(${f.source}))?`),2);case"ZZZ":return zs(new RegExp(`([+-]${F.source})(${f.source})?`),2);case"z":return cr(/[a-z_+-/]{1,256}?/i);case" ":return cr(/[^\S\n\r]/);default:return fe(jt)}})(i)||{invalidReason:Ai};return vt.token=i,vt}const Li={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function _i(i,t,a){const{type:f,value:b}=i;if(f==="literal"){const $=/^\s+$/.test(b);return{literal:!$,val:$?" ":b}}const T=t[f];let D=f;f==="hour"&&(t.hour12!=null?D=t.hour12?"hour12":"hour24":t.hourCycle!=null?t.hourCycle==="h11"||t.hourCycle==="h12"?D="hour12":D="hour24":D=a.hour12?"hour12":"hour24");let F=Li[D];if(typeof F=="object"&&(F=F[T]),F)return{literal:!1,val:F}}function Wi(i){return[`^${i.map(a=>a.regex).reduce((a,f)=>`${a}(${f.source})`,"")}$`,i]}function qi(i,t,a){const f=i.match(t);if(f){const b={};let T=1;for(const D in a)if(et(a,D)){const F=a[D],$=F.groups?F.groups+1:1;!F.literal&&F.token&&(b[F.token.val[0]]=F.deser(f.slice(T,T+$))),T+=$}return[f,b]}else return[f,{}]}function zi(i){const t=T=>{switch(T){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let a=null,f;return Y(i.z)||(a=ie.create(i.z)),Y(i.Z)||(a||(a=new qe(i.Z)),f=i.Z),Y(i.q)||(i.M=(i.q-1)*3+1),Y(i.h)||(i.h<12&&i.a===1?i.h+=12:i.h===12&&i.a===0&&(i.h=0)),i.G===0&&i.y&&(i.y=-i.y),Y(i.u)||(i.S=kr(i.u)),[Object.keys(i).reduce((T,D)=>{const F=t(D);return F&&(T[F]=i[D]),T},{}),a,f]}let Er=null;function Hi(){return Er||(Er=me.fromMillis(1555555555555)),Er}function Vi(i,t){if(i.literal)return i;const a=Xe.macroTokenToFormatOpts(i.val),f=Us(a,t);return f==null||f.includes(void 0)?i:f}function Hs(i,t){return Array.prototype.concat(...i.map(a=>Vi(a,t)))}class Vs{constructor(t,a){if(this.locale=t,this.format=a,this.tokens=Hs(Xe.parseFormat(a),t),this.units=this.tokens.map(f=>Pi(f,t)),this.disqualifyingUnit=this.units.find(f=>f.invalidReason),!this.disqualifyingUnit){const[f,b]=Wi(this.units);this.regex=RegExp(f,"i"),this.handlers=b}}explainFromTokens(t){if(this.isValid){const[a,f]=qi(t,this.regex,this.handlers),[b,T,D]=f?zi(f):[null,null,void 0];if(et(f,"a")&&et(f,"H"))throw new d("Can't include meridiem when specifying 24-hour format");return{input:t,tokens:this.tokens,regex:this.regex,rawMatches:a,matches:f,result:b,zone:T,specificOffset:D}}else return{input:t,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function Bs(i,t,a){return new Vs(i,a).explainFromTokens(t)}function Bi(i,t,a){const{result:f,zone:b,specificOffset:T,invalidReason:D}=Bs(i,t,a);return[f,b,T,D]}function Us(i,t){if(!i)return null;const f=Xe.create(t,i).dtFormatter(Hi()),b=f.formatToParts(),T=f.resolvedOptions();return b.map(D=>_i(D,i,T))}const Ir="Invalid DateTime",Gs=864e13;function Fn(i){return new Ue("unsupported zone",`the zone "${i.name}" is not supported`)}function Nr(i){return i.weekData===null&&(i.weekData=Le(i.c)),i.weekData}function Fr(i){return i.localWeekData===null&&(i.localWeekData=Le(i.c,i.loc.getMinDaysInFirstWeek(),i.loc.getStartOfWeek())),i.localWeekData}function Zt(i,t){const a={ts:i.ts,zone:i.zone,c:i.c,o:i.o,loc:i.loc,invalid:i.invalid};return new me({...a,...t,old:a})}function Ys(i,t,a){let f=i-t*60*1e3;const b=a.offset(f);if(t===b)return[f,t];f-=(b-t)*60*1e3;const T=a.offset(f);return b===T?[f,b]:[i-Math.min(b,T)*60*1e3,Math.max(b,T)]}function ur(i,t){i+=t*60*1e3;const a=new Date(i);return{year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds()}}function dr(i,t,a){return Ys(or(i),t,a)}function Zs(i,t){const a=i.o,f=i.c.year+Math.trunc(t.years),b=i.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,T={...i.c,year:f,month:b,day:Math.min(i.c.day,sr(f,b))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},D=ke.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),F=or(T);let[$,G]=Ys(F,a,i.zone);return D!==0&&($+=D,G=i.zone.offset($)),{ts:$,o:G}}function xn(i,t,a,f,b,T){const{setZone:D,zone:F}=a;if(i&&Object.keys(i).length!==0||t){const $=t||F,G=me.fromObject(i,{...a,zone:$,specificOffset:T});return D?G:G.setZone(F)}else return me.invalid(new Ue("unparsable",`the input "${b}" can't be parsed as ${f}`))}function hr(i,t,a=!0){return i.isValid?Xe.create(ce.create("en-US"),{allowZ:a,forceSimple:!0}).formatDateTimeFromString(i,t):null}function Ar(i,t,a){const f=i.c.year>9999||i.c.year<0;let b="";if(f&&i.c.year>=0&&(b+="+"),b+=Ve(i.c.year,f?6:4),a==="year")return b;if(t){if(b+="-",b+=Ve(i.c.month),a==="month")return b;b+="-"}else if(b+=Ve(i.c.month),a==="month")return b;return b+=Ve(i.c.day),b}function Ks(i,t,a,f,b,T,D){let F=!a||i.c.millisecond!==0||i.c.second!==0,$="";switch(D){case"day":case"month":case"year":break;default:if($+=Ve(i.c.hour),D==="hour")break;if(t){if($+=":",$+=Ve(i.c.minute),D==="minute")break;F&&($+=":",$+=Ve(i.c.second))}else{if($+=Ve(i.c.minute),D==="minute")break;F&&($+=Ve(i.c.second))}if(D==="second")break;F&&(!f||i.c.millisecond!==0)&&($+=".",$+=Ve(i.c.millisecond,3))}return b&&(i.isOffsetFixed&&i.offset===0&&!T?$+="Z":i.o<0?($+="-",$+=Ve(Math.trunc(-i.o/60)),$+=":",$+=Ve(Math.trunc(-i.o%60))):($+="+",$+=Ve(Math.trunc(i.o/60)),$+=":",$+=Ve(Math.trunc(i.o%60)))),T&&($+="["+i.zone.ianaName+"]"),$}const Xs={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Ui={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Gi={ordinal:1,hour:0,minute:0,second:0,millisecond:0},fr=["year","month","day","hour","minute","second","millisecond"],Yi=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Zi=["year","ordinal","hour","minute","second","millisecond"];function pr(i){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[i.toLowerCase()];if(!t)throw new c(i);return t}function Qs(i){switch(i.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return pr(i)}}function Ki(i){if(An===void 0&&(An=je.now()),i.type!=="iana")return i.offset(An);const t=i.name;let a=$r.get(t);return a===void 0&&(a=i.offset(An),$r.set(t,a)),a}function Js(i,t){const a=dt(t.zone,je.defaultZone);if(!a.isValid)return me.invalid(Fn(a));const f=ce.fromObject(t);let b,T;if(Y(i.year))b=je.now();else{for(const $ of fr)Y(i[$])&&(i[$]=Xs[$]);const D=te(i)||de(i);if(D)return me.invalid(D);const F=Ki(a);[b,T]=dr(i,F,a)}return new me({ts:b,zone:a,loc:f,o:T})}function eo(i,t,a){const f=Y(a.round)?!0:a.round,b=Y(a.rounding)?"trunc":a.rounding,T=(F,$)=>(F=Tr(F,f||a.calendary?0:2,a.calendary?"round":b),t.loc.clone(a).relFormatter(a).format(F,$)),D=F=>a.calendary?t.hasSame(i,F)?0:t.startOf(F).diff(i.startOf(F),F).get(F):t.diff(i,F).get(F);if(a.unit)return T(D(a.unit),a.unit);for(const F of a.units){const $=D(F);if(Math.abs($)>=1)return T($,F)}return T(i>t?-0:0,a.units[a.units.length-1])}function to(i){let t={},a;return i.length>0&&typeof i[i.length-1]=="object"?(t=i[i.length-1],a=Array.from(i).slice(0,i.length-1)):a=Array.from(i),[t,a]}let An;const $r=new Map;class me{constructor(t){const a=t.zone||je.defaultZone;let f=t.invalid||(Number.isNaN(t.ts)?new Ue("invalid input"):null)||(a.isValid?null:Fn(a));this.ts=Y(t.ts)?je.now():t.ts;let b=null,T=null;if(!f)if(t.old&&t.old.ts===this.ts&&t.old.zone.equals(a))[b,T]=[t.old.c,t.old.o];else{const F=De(t.o)&&!t.old?t.o:a.offset(this.ts);b=ur(this.ts,F),f=Number.isNaN(b.year)?new Ue("invalid input"):null,b=f?null:b,T=f?null:F}this._zone=a,this.loc=t.loc||ce.create(),this.invalid=f,this.weekData=null,this.localWeekData=null,this.c=b,this.o=T,this.isLuxonDateTime=!0}static now(){return new me({})}static local(){const[t,a]=to(arguments),[f,b,T,D,F,$,G]=a;return Js({year:f,month:b,day:T,hour:D,minute:F,second:$,millisecond:G},t)}static utc(){const[t,a]=to(arguments),[f,b,T,D,F,$,G]=a;return t.zone=qe.utcInstance,Js({year:f,month:b,day:T,hour:D,minute:F,second:$,millisecond:G},t)}static fromJSDate(t,a={}){const f=cn(t)?t.valueOf():NaN;if(Number.isNaN(f))return me.invalid("invalid input");const b=dt(a.zone,je.defaultZone);return b.isValid?new me({ts:f,zone:b,loc:ce.fromObject(a)}):me.invalid(Fn(b))}static fromMillis(t,a={}){if(De(t))return t<-Gs||t>Gs?me.invalid("Timestamp out of range"):new me({ts:t,zone:dt(a.zone,je.defaultZone),loc:ce.fromObject(a)});throw new l(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,a={}){if(De(t))return new me({ts:t*1e3,zone:dt(a.zone,je.defaultZone),loc:ce.fromObject(a)});throw new l("fromSeconds requires a numerical input")}static fromObject(t,a={}){t=t||{};const f=dt(a.zone,je.defaultZone);if(!f.isValid)return me.invalid(Fn(f));const b=ce.fromObject(a),T=ir(t,Qs),{minDaysInFirstWeek:D,startOfWeek:F}=Ut(T,b),$=je.now(),G=Y(a.specificOffset)?f.offset($):a.specificOffset,ue=!Y(T.ordinal),Se=!Y(T.year),Ee=!Y(T.month)||!Y(T.day),fe=Se||Ee,Be=T.weekYear||T.weekNumber;if((fe||ue)&&Be)throw new d("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(Ee&&ue)throw new d("Can't mix ordinal dates with month/day");const vt=Be||T.weekday&&!fe;let jt,bn,Rn=ur($,G);vt?(jt=Yi,bn=Ui,Rn=Le(Rn,D,F)):ue?(jt=Zi,bn=Gi,Rn=Bt(Rn)):(jt=fr,bn=Xs);let no=!1;for(const Ln of jt){const nl=T[Ln];Y(nl)?no?T[Ln]=bn[Ln]:T[Ln]=Rn[Ln]:no=!0}const Qi=vt?z(T,D,F):ue?q(T):te(T),ro=Qi||de(T);if(ro)return me.invalid(ro);const Ji=vt?xt(T,D,F):ue?qt(T):T,[el,tl]=dr(Ji,G,f),Pn=new me({ts:el,zone:f,o:tl,loc:b});return T.weekday&&fe&&t.weekday!==Pn.weekday?me.invalid("mismatched weekday",`you can't specify both a weekday of ${T.weekday} and a date of ${Pn.toISO()}`):Pn.isValid?Pn:me.invalid(Pn.invalid)}static fromISO(t,a={}){const[f,b]=xi(t);return xn(f,b,a,"ISO 8601",t)}static fromRFC2822(t,a={}){const[f,b]=bi(t);return xn(f,b,a,"RFC 2822",t)}static fromHTTP(t,a={}){const[f,b]=vi(t);return xn(f,b,a,"HTTP",a)}static fromFormat(t,a,f={}){if(Y(t)||Y(a))throw new l("fromFormat requires an input string and a format");const{locale:b=null,numberingSystem:T=null}=f,D=ce.fromOpts({locale:b,numberingSystem:T,defaultToEN:!0}),[F,$,G,ue]=Bi(D,t,a);return ue?me.invalid(ue):xn(F,$,f,`format ${a}`,t,G)}static fromString(t,a,f={}){return me.fromFormat(t,a,f)}static fromSQL(t,a={}){const[f,b]=Mi(t);return xn(f,b,a,"SQL",t)}static invalid(t,a=null){if(!t)throw new l("need to specify a reason the DateTime is invalid");const f=t instanceof Ue?t:new Ue(t,a);if(je.throwOnInvalid)throw new r(f);return new me({invalid:f})}static isDateTime(t){return t&&t.isLuxonDateTime||!1}static parseFormatForOpts(t,a={}){const f=Us(t,ce.fromObject(a));return f?f.map(b=>b?b.val:null).join(""):null}static expandFormat(t,a={}){return Hs(Xe.parseFormat(t),ce.fromObject(a)).map(b=>b.val).join("")}static resetCache(){An=void 0,$r.clear()}get(t){return this[t]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Nr(this).weekYear:NaN}get weekNumber(){return this.isValid?Nr(this).weekNumber:NaN}get weekday(){return this.isValid?Nr(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Fr(this).weekday:NaN}get localWeekNumber(){return this.isValid?Fr(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Fr(this).weekYear:NaN}get ordinal(){return this.isValid?Bt(this.c).ordinal:NaN}get monthShort(){return this.isValid?Nn.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Nn.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Nn.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Nn.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const t=864e5,a=6e4,f=or(this.c),b=this.zone.offset(f-t),T=this.zone.offset(f+t),D=this.zone.offset(f-b*a),F=this.zone.offset(f-T*a);if(D===F)return[this];const $=f-D*a,G=f-F*a,ue=ur($,D),Se=ur(G,F);return ue.hour===Se.hour&&ue.minute===Se.minute&&ue.second===Se.second&&ue.millisecond===Se.millisecond?[Zt(this,{ts:$}),Zt(this,{ts:G})]:[this]}get isInLeapYear(){return Mn(this.year)}get daysInMonth(){return sr(this.year,this.month)}get daysInYear(){return this.isValid?un(this.year):NaN}get weeksInWeekYear(){return this.isValid?jn(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?jn(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(t={}){const{locale:a,numberingSystem:f,calendar:b}=Xe.create(this.loc.clone(t),t).resolvedOptions(this);return{locale:a,numberingSystem:f,outputCalendar:b}}toUTC(t=0,a={}){return this.setZone(qe.instance(t),a)}toLocal(){return this.setZone(je.defaultZone)}setZone(t,{keepLocalTime:a=!1,keepCalendarTime:f=!1}={}){if(t=dt(t,je.defaultZone),t.equals(this.zone))return this;if(t.isValid){let b=this.ts;if(a||f){const T=t.offset(this.ts),D=this.toObject();[b]=dr(D,T,t)}return Zt(this,{ts:b,zone:t})}else return me.invalid(Fn(t))}reconfigure({locale:t,numberingSystem:a,outputCalendar:f}={}){const b=this.loc.clone({locale:t,numberingSystem:a,outputCalendar:f});return Zt(this,{loc:b})}setLocale(t){return this.reconfigure({locale:t})}set(t){if(!this.isValid)return this;const a=ir(t,Qs),{minDaysInFirstWeek:f,startOfWeek:b}=Ut(a,this.loc),T=!Y(a.weekYear)||!Y(a.weekNumber)||!Y(a.weekday),D=!Y(a.ordinal),F=!Y(a.year),$=!Y(a.month)||!Y(a.day),G=F||$,ue=a.weekYear||a.weekNumber;if((G||D)&&ue)throw new d("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if($&&D)throw new d("Can't mix ordinal dates with month/day");let Se;T?Se=xt({...Le(this.c,f,b),...a},f,b):Y(a.ordinal)?(Se={...this.toObject(),...a},Y(a.day)&&(Se.day=Math.min(sr(Se.year,Se.month),Se.day))):Se=qt({...Bt(this.c),...a});const[Ee,fe]=dr(Se,this.o,this.zone);return Zt(this,{ts:Ee,o:fe})}plus(t){if(!this.isValid)return this;const a=ke.fromDurationLike(t);return Zt(this,Zs(this,a))}minus(t){if(!this.isValid)return this;const a=ke.fromDurationLike(t).negate();return Zt(this,Zs(this,a))}startOf(t,{useLocaleWeeks:a=!1}={}){if(!this.isValid)return this;const f={},b=ke.normalizeUnit(t);switch(b){case"years":f.month=1;case"quarters":case"months":f.day=1;case"weeks":case"days":f.hour=0;case"hours":f.minute=0;case"minutes":f.second=0;case"seconds":f.millisecond=0;break}if(b==="weeks")if(a){const T=this.loc.getStartOfWeek(),{weekday:D}=this;D<T&&(f.weekNumber=this.weekNumber-1),f.weekday=T}else f.weekday=1;if(b==="quarters"){const T=Math.ceil(this.month/3);f.month=(T-1)*3+1}return this.set(f)}endOf(t,a){return this.isValid?this.plus({[t]:1}).startOf(t,a).minus(1):this}toFormat(t,a={}){return this.isValid?Xe.create(this.loc.redefaultToEN(a)).formatDateTimeFromString(this,t):Ir}toLocaleString(t=v,a={}){return this.isValid?Xe.create(this.loc.clone(a),t).formatDateTime(this):Ir}toLocaleParts(t={}){return this.isValid?Xe.create(this.loc.clone(t),t).formatDateTimeParts(this):[]}toISO({format:t="extended",suppressSeconds:a=!1,suppressMilliseconds:f=!1,includeOffset:b=!0,extendedZone:T=!1,precision:D="milliseconds"}={}){if(!this.isValid)return null;D=pr(D);const F=t==="extended";let $=Ar(this,F,D);return fr.indexOf(D)>=3&&($+="T"),$+=Ks(this,F,a,f,b,T,D),$}toISODate({format:t="extended",precision:a="day"}={}){return this.isValid?Ar(this,t==="extended",pr(a)):null}toISOWeekDate(){return hr(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:t=!1,suppressSeconds:a=!1,includeOffset:f=!0,includePrefix:b=!1,extendedZone:T=!1,format:D="extended",precision:F="milliseconds"}={}){return this.isValid?(F=pr(F),(b&&fr.indexOf(F)>=3?"T":"")+Ks(this,D==="extended",a,t,f,T,F)):null}toRFC2822(){return hr(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return hr(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?Ar(this,!0):null}toSQLTime({includeOffset:t=!0,includeZone:a=!1,includeOffsetSpace:f=!0}={}){let b="HH:mm:ss.SSS";return(a||t)&&(f&&(b+=" "),a?b+="z":t&&(b+="ZZ")),hr(this,b,!0)}toSQL(t={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(t)}`:null}toString(){return this.isValid?this.toISO():Ir}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(t={}){if(!this.isValid)return{};const a={...this.c};return t.includeConfig&&(a.outputCalendar=this.outputCalendar,a.numberingSystem=this.loc.numberingSystem,a.locale=this.loc.locale),a}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(t,a="milliseconds",f={}){if(!this.isValid||!t.isValid)return ke.invalid("created by diffing an invalid DateTime");const b={locale:this.locale,numberingSystem:this.numberingSystem,...f},T=rr(a).map(ke.normalizeUnit),D=t.valueOf()>this.valueOf(),F=D?this:t,$=D?t:this,G=Fi(F,$,T,b);return D?G.negate():G}diffNow(t="milliseconds",a={}){return this.diff(me.now(),t,a)}until(t){return this.isValid?_e.fromDateTimes(this,t):this}hasSame(t,a,f){if(!this.isValid)return!1;const b=t.valueOf(),T=this.setZone(t.zone,{keepLocalTime:!0});return T.startOf(a,f)<=b&&b<=T.endOf(a,f)}equals(t){return this.isValid&&t.isValid&&this.valueOf()===t.valueOf()&&this.zone.equals(t.zone)&&this.loc.equals(t.loc)}toRelative(t={}){if(!this.isValid)return null;const a=t.base||me.fromObject({},{zone:this.zone}),f=t.padding?this<a?-t.padding:t.padding:0;let b=["years","months","days","hours","minutes","seconds"],T=t.unit;return Array.isArray(t.unit)&&(b=t.unit,T=void 0),eo(a,this.plus(f),{...t,numeric:"always",units:b,unit:T})}toRelativeCalendar(t={}){return this.isValid?eo(t.base||me.fromObject({},{zone:this.zone}),this,{...t,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...t){if(!t.every(me.isDateTime))throw new l("min requires all arguments be DateTimes");return Ce(t,a=>a.valueOf(),Math.min)}static max(...t){if(!t.every(me.isDateTime))throw new l("max requires all arguments be DateTimes");return Ce(t,a=>a.valueOf(),Math.max)}static fromFormatExplain(t,a,f={}){const{locale:b=null,numberingSystem:T=null}=f,D=ce.fromOpts({locale:b,numberingSystem:T,defaultToEN:!0});return Bs(D,t,a)}static fromStringExplain(t,a,f={}){return me.fromFormatExplain(t,a,f)}static buildFormatParser(t,a={}){const{locale:f=null,numberingSystem:b=null}=a,T=ce.fromOpts({locale:f,numberingSystem:b,defaultToEN:!0});return new Vs(T,t)}static fromFormatParser(t,a,f={}){if(Y(t)||Y(a))throw new l("fromFormatParser requires an input string and a format parser");const{locale:b=null,numberingSystem:T=null}=f,D=ce.fromOpts({locale:b,numberingSystem:T,defaultToEN:!0});if(!D.equals(a.locale))throw new l(`fromFormatParser called with a locale of ${D}, but the format parser was created for ${a.locale}`);const{result:F,zone:$,specificOffset:G,invalidReason:ue}=a.explainFromTokens(t);return ue?me.invalid(ue):xn(F,$,f,`format ${a.format}`,t,G)}static get DATE_SHORT(){return v}static get DATE_MED(){return x}static get DATE_MED_WITH_WEEKDAY(){return y}static get DATE_FULL(){return C}static get DATE_HUGE(){return w}static get TIME_SIMPLE(){return k}static get TIME_WITH_SECONDS(){return O}static get TIME_WITH_SHORT_OFFSET(){return M}static get TIME_WITH_LONG_OFFSET(){return j}static get TIME_24_SIMPLE(){return E}static get TIME_24_WITH_SECONDS(){return R}static get TIME_24_WITH_SHORT_OFFSET(){return U}static get TIME_24_WITH_LONG_OFFSET(){return P}static get DATETIME_SHORT(){return K}static get DATETIME_SHORT_WITH_SECONDS(){return A}static get DATETIME_MED(){return L}static get DATETIME_MED_WITH_SECONDS(){return V}static get DATETIME_MED_WITH_WEEKDAY(){return N}static get DATETIME_FULL(){return W}static get DATETIME_FULL_WITH_SECONDS(){return X}static get DATETIME_HUGE(){return ne}static get DATETIME_HUGE_WITH_SECONDS(){return J}}function $n(i){if(me.isDateTime(i))return i;if(i&&i.valueOf&&De(i.valueOf()))return me.fromJSDate(i);if(i&&typeof i=="object")return me.fromObject(i);throw new l(`Unknown datetime argument: ${i}, of type ${typeof i}`)}const Xi="3.7.2";return rt.DateTime=me,rt.Duration=ke,rt.FixedOffsetZone=qe,rt.IANAZone=ie,rt.Info=Nn,rt.Interval=_e,rt.InvalidZone=tt,rt.Settings=je,rt.SystemZone=ae,rt.VERSION=Xi,rt.Zone=ee,rt}var jo;function is(){return jo||(jo=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CronDate=e.DAYS_IN_MONTH=e.DateMathOp=e.TimeUnit=void 0;const r=ru();var u;(function(c){c.Second="Second",c.Minute="Minute",c.Hour="Hour",c.Day="Day",c.Month="Month",c.Year="Year"})(u||(e.TimeUnit=u={}));var s;(function(c){c.Add="Add",c.Subtract="Subtract"})(s||(e.DateMathOp=s={})),e.DAYS_IN_MONTH=Object.freeze([31,29,31,30,31,30,31,31,30,31,30,31]);class d{#e;#n=null;#o=null;constructor(l,m){const p={zone:m};if(l?l instanceof d?(this.#e=l.#e,this.#n=l.#n,this.#o=l.#o):l instanceof Date?this.#e=r.DateTime.fromJSDate(l,p):typeof l=="number"?this.#e=r.DateTime.fromMillis(l,p):(this.#e=r.DateTime.fromISO(l,p),this.#e.isValid||(this.#e=r.DateTime.fromRFC2822(l,p)),this.#e.isValid||(this.#e=r.DateTime.fromSQL(l,p)),this.#e.isValid||(this.#e=r.DateTime.fromFormat(l,"EEE, d MMM yyyy HH:mm:ss",p))):this.#e=r.DateTime.local(),!this.#e.isValid)throw new Error(`CronDate: unhandled timestamp: ${l}`);m&&m!==this.#e.zoneName&&(this.#e=this.#e.setZone(m))}static#s(l){return l%4===0&&l%100!==0||l%400===0}get dstStart(){return this.#n}set dstStart(l){this.#n=l}get dstEnd(){return this.#o}set dstEnd(l){this.#o=l}addYear(){this.#e=this.#e.plus({years:1})}addMonth(){this.#e=this.#e.plus({months:1}).startOf("month")}addDay(){this.#e=this.#e.plus({days:1}).startOf("day")}addHour(){this.#e=this.#e.plus({hours:1}).startOf("hour")}addMinute(){this.#e=this.#e.plus({minutes:1}).startOf("minute")}addSecond(){this.#e=this.#e.plus({seconds:1})}subtractYear(){this.#e=this.#e.minus({years:1})}subtractMonth(){this.#e=this.#e.minus({months:1}).endOf("month").startOf("second")}subtractDay(){this.#e=this.#e.minus({days:1}).endOf("day").startOf("second")}subtractHour(){this.#e=this.#e.minus({hours:1}).endOf("hour").startOf("second")}subtractMinute(){this.#e=this.#e.minus({minutes:1}).endOf("minute").startOf("second")}subtractSecond(){this.#e=this.#e.minus({seconds:1})}addUnit(l){switch(l){case u.Year:return this.addYear();case u.Month:return this.addMonth();case u.Day:return this.addDay();case u.Hour:return this.addHour();case u.Minute:return this.addMinute();case u.Second:return this.addSecond()}}subtractUnit(l){switch(l){case u.Year:return this.subtractYear();case u.Month:return this.subtractMonth();case u.Day:return this.subtractDay();case u.Hour:return this.subtractHour();case u.Minute:return this.subtractMinute();case u.Second:return this.subtractSecond()}}invokeDateOperation(l,m){if(l===s.Add){this.addUnit(m);return}if(l===s.Subtract){this.subtractUnit(m);return}throw new Error(`Invalid verb: ${l}`)}getDate(){return this.#e.day}getFullYear(){return this.#e.year}getDay(){const l=this.#e.weekday;return l===7?0:l}getMonth(){return this.#e.month-1}getHours(){return this.#e.hour}getMinutes(){return this.#e.minute}getSeconds(){return this.#e.second}getMilliseconds(){return this.#e.millisecond}getUTCOffset(){return this.#e.offset}setStartOfDay(){this.#e=this.#e.startOf("day")}setEndOfDay(){this.#e=this.#e.endOf("day")}getTime(){return this.#e.valueOf()}getUTCDate(){return this.#r().day}getUTCFullYear(){return this.#r().year}getUTCDay(){const l=this.#r().weekday;return l===7?0:l}getUTCMonth(){return this.#r().month-1}getUTCHours(){return this.#r().hour}getUTCMinutes(){return this.#r().minute}getUTCSeconds(){return this.#r().second}toISOString(){return this.#e.toUTC().toISO()}toJSON(){return this.#e.toJSON()}setDate(l){this.#e=this.#e.set({day:l})}setFullYear(l){this.#e=this.#e.set({year:l})}setDay(l){this.#e=this.#e.set({weekday:l})}setMonth(l){this.#e=this.#e.set({month:l+1})}setHours(l){this.#e=this.#e.set({hour:l})}setMinutes(l){this.#e=this.#e.set({minute:l})}setSeconds(l){this.#e=this.#e.set({second:l})}setMilliseconds(l){this.#e=this.#e.set({millisecond:l})}toString(){return this.toDate().toString()}toDate(){return this.#e.toJSDate()}isLastDayOfMonth(){const{day:l,month:m}=this.#e;if(m===2){const p=d.#s(this.#e.year);return l===e.DAYS_IN_MONTH[m-1]-(p?0:1)}return l===e.DAYS_IN_MONTH[m-1]}isLastWeekdayOfMonth(){const{day:l,month:m}=this.#e;let p;return m===2?p=e.DAYS_IN_MONTH[m-1]-(d.#s(this.#e.year)?0:1):p=e.DAYS_IN_MONTH[m-1],l>p-7}applyDateOperation(l,m,p){if(m===u.Month||m===u.Day){this.invokeDateOperation(l,m);return}const h=this.getHours();this.invokeDateOperation(l,m);const g=this.getHours(),v=g-h;v===2?p!==24&&(this.dstStart=h+1):v===0&&this.getMinutes()===0&&this.getSeconds()===0&&p!==24&&(this.dstEnd=g)}#r(){return this.#e.toUTC()}}e.CronDate=d,e.default=d})(Wr)),Wr}var Do;function su(){if(Do)return Un;Do=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.CronMonth=void 0;const e=is(),r=tn(),u=1,s=12,d=Object.freeze([]);let c=class extends r.CronField{static get min(){return u}static get max(){return s}static get chars(){return d}static get daysInMonth(){return e.DAYS_IN_MONTH}constructor(m,p){super(m,p),this.validate()}get values(){return super.values}};return Un.CronMonth=c,Un}var Gn={},Eo;function ou(){if(Eo)return Gn;Eo=1,Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.CronSecond=void 0;const e=tn(),r=0,u=59,s=Object.freeze([]);let d=class extends e.CronField{static get min(){return r}static get max(){return u}static get chars(){return s}constructor(l,m){super(l,m),this.validate()}get values(){return super.values}};return Gn.CronSecond=d,Gn}var Io;function ls(){return Io||(Io=1,(function(e){var r=Xt&&Xt.__createBinding||(Object.create?(function(s,d,c,l){l===void 0&&(l=c);var m=Object.getOwnPropertyDescriptor(d,c);(!m||("get"in m?!d.__esModule:m.writable||m.configurable))&&(m={enumerable:!0,get:function(){return d[c]}}),Object.defineProperty(s,l,m)}):(function(s,d,c,l){l===void 0&&(l=c),s[l]=d[c]})),u=Xt&&Xt.__exportStar||function(s,d){for(var c in s)c!=="default"&&!Object.prototype.hasOwnProperty.call(d,c)&&r(d,s,c)};Object.defineProperty(e,"__esModule",{value:!0}),u(Qc(),e),u(Jc(),e),u(eu(),e),u(tn(),e),u(tu(),e),u(nu(),e),u(su(),e),u(ou(),e)})(Xt)),Xt}var No;function sa(){if(No)return Wn;No=1,Object.defineProperty(Wn,"__esModule",{value:!0}),Wn.CronFieldCollection=void 0;const e=ls();let r=class Xn{#e;#n;#o;#s;#r;#t;static from(s,d){return new Xn({second:this.resolveField(e.CronSecond,s.second,d.second),minute:this.resolveField(e.CronMinute,s.minute,d.minute),hour:this.resolveField(e.CronHour,s.hour,d.hour),dayOfMonth:this.resolveField(e.CronDayOfMonth,s.dayOfMonth,d.dayOfMonth),month:this.resolveField(e.CronMonth,s.month,d.month),dayOfWeek:this.resolveField(e.CronDayOfWeek,s.dayOfWeek,d.dayOfWeek)})}static resolveField(s,d,c){return c?c instanceof e.CronField?c:new s(c):d}constructor({second:s,minute:d,hour:c,dayOfMonth:l,month:m,dayOfWeek:p}){if(!s)throw new Error("Validation error, Field second is missing");if(!d)throw new Error("Validation error, Field minute is missing");if(!c)throw new Error("Validation error, Field hour is missing");if(!l)throw new Error("Validation error, Field dayOfMonth is missing");if(!m)throw new Error("Validation error, Field month is missing");if(!p)throw new Error("Validation error, Field dayOfWeek is missing");if(m.values.length===1&&!l.hasLastChar&&p.isWildcard&&!(parseInt(l.values[0],10)<=e.CronMonth.daysInMonth[m.values[0]-1]))throw new Error("Invalid explicit day of month definition");this.#e=s,this.#n=d,this.#o=c,this.#r=m,this.#t=p,this.#s=l}get second(){return this.#e}get minute(){return this.#n}get hour(){return this.#o}get dayOfMonth(){return this.#s}get month(){return this.#r}get dayOfWeek(){return this.#t}static compactField(s){if(s.length===0)return[];const d=[];let c;return s.forEach((l,m,p)=>{if(c===void 0){c={start:l,count:1};return}const h=p[m-1]||c.start,g=p[m+1];if(l==="L"||l==="W"){d.push(c),d.push({start:l,count:1}),c=void 0;return}if(c.step===void 0&&g!==void 0){const v=l-h,x=g-l;if(v<=x){c={...c,count:2,end:l,step:v};return}c.step=1}l-(c.end??0)===c.step?(c.count++,c.end=l):(c.count===1?d.push({start:c.start,count:1}):c.count===2?(d.push({start:c.start,count:1}),d.push({start:c.end??h,count:1})):d.push(c),c={start:l,count:1})}),c&&d.push(c),d}static#c(s,d,c){const l=d.step;return l?l===1&&d.start===s.min&&d.end&&d.end>=c?s.hasQuestionMarkChar?"?":"*":l!==1&&d.start===s.min&&d.end&&d.end>=c-l+1?`*/${l}`:null:null}static#l(s,d){const c=s.step;if(c===1)return`${s.start}-${s.end}`;const l=s.start===0?s.count-1:s.count;if(!c)throw new Error("Unexpected range step");if(!s.end)throw new Error("Unexpected range end");if(c*l>s.end){const m=(h,g)=>{if(typeof s.start!="number")throw new Error("Unexpected range start");return g%c===0?s.start+g:null};if(typeof s.start!="number")throw new Error("Unexpected range start");const p={length:s.end-s.start+1};return Array.from(p,m).filter(h=>h!==null).join(",")}return s.end===d-c+1?`${s.start}/${c}`:`${s.start}-${s.end}/${c}`}stringifyField(s){let d=s.max,c=s.values;if(s instanceof e.CronDayOfWeek){d=6;const m=this.#t.values;c=m[m.length-1]===7?m.slice(0,-1):m}s instanceof e.CronDayOfMonth&&(d=this.#r.values.length===1?e.CronMonth.daysInMonth[this.#r.values[0]-1]:s.max);const l=Xn.compactField(c);if(l.length===1){const m=Xn.#c(s,l[0],d);if(m)return m}return l.map(m=>{const p=m.count===1?m.start.toString():Xn.#l(m,d);return s instanceof e.CronDayOfWeek&&s.nthDay>0?`${p}#${s.nthDay}`:p}).join(",")}stringify(s=!1){const d=[];return s&&d.push(this.stringifyField(this.#e)),d.push(this.stringifyField(this.#n),this.stringifyField(this.#o),this.stringifyField(this.#s),this.stringifyField(this.#r),this.stringifyField(this.#t)),d.join(" ")}serialize(){return{second:this.#e.serialize(),minute:this.#n.serialize(),hour:this.#o.serialize(),dayOfMonth:this.#s.serialize(),month:this.#r.serialize(),dayOfWeek:this.#t.serialize()}}};return Wn.CronFieldCollection=r,Wn}var qr={},Fo;function oa(){return Fo||(Fo=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CronExpression=e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE=e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE=void 0;const r=is();e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE="Out of the time span range",e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE="Invalid expression, loop limit exceeded";const u=1e4;class s{#e;#n;#o;#s;#r;#t;#c=null;#l=!1;constructor(c,l){this.#e=l,this.#n=l.tz,this.#s=l.startDate?new r.CronDate(l.startDate,this.#n):null,this.#r=l.endDate?new r.CronDate(l.endDate,this.#n):null;let m=l.currentDate??l.startDate;if(m){const p=new r.CronDate(m,this.#n);this.#s&&p.getTime()<this.#s.getTime()?m=this.#s:this.#r&&p.getTime()>this.#r.getTime()&&(m=this.#r)}this.#o=new r.CronDate(m,this.#n),this.#t=c}get fields(){return this.#t}static fieldsToExpression(c,l){return new s(c,l||{})}static#a(c,l){return l.some(m=>m===c)}#i(c,l){return c[l?c.length-1:0]}#d(c){const l=`${c.getFullYear()}-${c.getMonth()+1}-${c.getDate()}`;if(this.#c===l)return this.#l;const m=new r.CronDate(c);m.setStartOfDay();const p=new r.CronDate(c);return p.setEndOfDay(),this.#c=l,this.#l=m.getUTCOffset()!==p.getUTCOffset(),this.#l}#h(c,l,m){const p=this.#t.second.values,h=c.getSeconds(),g=this.#t.second.findNearestValue(h,m);if(g!==null){c.setSeconds(g);return}c.applyDateOperation(l,r.TimeUnit.Minute,this.#t.hour.values.length),c.setSeconds(this.#i(p,m))}#p(c,l,m){const p=this.#t.minute.values,h=this.#t.second.values,g=c.getMinutes(),v=this.#t.minute.findNearestValue(g,m);if(v!==null){c.setMinutes(v),c.setSeconds(this.#i(h,m));return}c.applyDateOperation(l,r.TimeUnit.Hour,this.#t.hour.values.length),c.setMinutes(this.#i(p,m)),c.setSeconds(this.#i(h,m))}static#m(c,l){const m=l.isLastWeekdayOfMonth();return c.some(p=>{const h=parseInt(p.toString().charAt(0),10)%7;if(Number.isNaN(h))throw new Error(`Invalid last weekday of the month expression: ${p}`);return l.getDay()===h&&m})}next(){return this.#u()}prev(){return this.#u(!0)}hasNext(){const c=this.#o;try{return this.#u(),!0}catch{return!1}finally{this.#o=c}}hasPrev(){const c=this.#o;try{return this.#u(!0),!0}catch{return!1}finally{this.#o=c}}take(c){const l=[];if(c>=0)for(let m=0;m<c;m++)try{l.push(this.next())}catch{return l}else for(let m=0;m>c;m--)try{l.push(this.prev())}catch{return l}return l}reset(c){this.#o=new r.CronDate(c||this.#e.currentDate,this.#n)}stringify(c=!1){return this.#t.stringify(c)}includesDate(c){const{second:l,minute:m,hour:p,month:h}=this.#t,g=new r.CronDate(c,this.#n);return!(!l.values.includes(g.getSeconds())||!m.values.includes(g.getMinutes())||!p.values.includes(g.getHours())||!h.values.includes(g.getMonth()+1)||!this.#f(g)||this.#t.dayOfWeek.nthDay>0&&Math.ceil(g.getDate()/7)!==this.#t.dayOfWeek.nthDay)}toString(){return this.#e.expression||this.stringify(!0)}#f(c){const l=this.#t.dayOfMonth.isWildcard,m=!l,p=this.#t.dayOfWeek.isWildcard,h=!p,g=s.#a(c.getDate(),this.#t.dayOfMonth.values)||this.#t.dayOfMonth.hasLastChar&&c.isLastDayOfMonth(),v=s.#a(c.getDay(),this.#t.dayOfWeek.values)||this.#t.dayOfWeek.hasLastChar&&s.#m(this.#t.dayOfWeek.values,c);return!!(m&&h&&(g||v)||g&&!h||l&&!p&&v)}#g(c,l,m){const p=this.#t.hour.values,h=p,g=c.getHours(),v=s.#a(g,p),x=c.dstEnd===g;if(c.dstStart!==null&&c.dstStart===g-1&&s.#a(c.dstStart,p))return!0;if(x&&!m)return c.dstEnd=null,c.applyDateOperation(r.DateMathOp.Add,r.TimeUnit.Hour,h.length),!1;if(v)return!0;c.dstStart=null;const y=this.#t.hour.findNearestValue(g,m);if(y===null)return c.applyDateOperation(l,r.TimeUnit.Day,h.length),!1;if(this.#d(c)){const C=m?g-y:y-g;for(let w=0;w<C&&(c.applyDateOperation(l,r.TimeUnit.Hour,h.length),!(!m&&c.getHours()>=y||m&&c.getHours()<=y));w++);}else c.setHours(y);return c.setMinutes(this.#i(this.#t.minute.values,m)),c.setSeconds(this.#i(this.#t.second.values,m)),!1}#y(c){if(!this.#s&&!this.#r)return;const l=c.getTime();if(this.#s&&l<this.#s.getTime())throw new Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE);if(this.#r&&l>this.#r.getTime())throw new Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE)}#u(c=!1){const l=c?r.DateMathOp.Subtract:r.DateMathOp.Add,m=new r.CronDate(this.#o),p=m.getTime();let h=0;for(;++h<u;){if(this.#y(m),!this.#f(m)){m.applyDateOperation(l,r.TimeUnit.Day,this.#t.hour.values.length);continue}if(!(this.#t.dayOfWeek.nthDay<=0||Math.ceil(m.getDate()/7)===this.#t.dayOfWeek.nthDay)){m.applyDateOperation(l,r.TimeUnit.Day,this.#t.hour.values.length);continue}if(!s.#a(m.getMonth()+1,this.#t.month.values)){m.applyDateOperation(l,r.TimeUnit.Month,this.#t.hour.values.length);continue}if(this.#g(m,l,c)){if(!s.#a(m.getMinutes(),this.#t.minute.values)){this.#p(m,l,c);continue}if(!s.#a(m.getSeconds(),this.#t.second.values)){this.#h(m,l,c);continue}if(p===m.getTime()){(l==="Add"||m.getMilliseconds()===0)&&m.applyDateOperation(l,r.TimeUnit.Second,this.#t.hour.values.length);continue}break}}if(h>u)throw new Error(e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE);return m.getMilliseconds()!==0&&m.setMilliseconds(0),this.#o=m,m}[Symbol.iterator](){return{next:()=>{try{return{value:this.#u(),done:!1}}catch{return{value:void 0,done:!0}}}}}}e.CronExpression=s,e.default=s})(qr)),qr}var mr={},Ao;function au(){if(Ao)return mr;Ao=1,Object.defineProperty(mr,"__esModule",{value:!0}),mr.seededRandom=u;function e(s){let d=2166136261;for(let c=0;c<s.length;c++)d^=s.charCodeAt(c),d=Math.imul(d,16777619);return()=>d>>>0}function r(s){return()=>{let d=s+=1831565813;return d=Math.imul(d^d>>>15,d|1),d^=d+Math.imul(d^d>>>7,d|61),((d^d>>>14)>>>0)/4294967296}}function u(s){const d=s?e(s)():Math.floor(Math.random()*1e10);return r(d)}return mr}var $o;function ts(){if($o)return it;$o=1,Object.defineProperty(it,"__esModule",{value:!0}),it.CronExpressionParser=it.DayOfWeek=it.Months=it.CronUnit=it.PredefinedExpressions=void 0;const e=sa(),r=oa(),u=au(),s=ls();var d;(function(h){h["@yearly"]="0 0 0 1 1 *",h["@annually"]="0 0 0 1 1 *",h["@monthly"]="0 0 0 1 * *",h["@weekly"]="0 0 0 * * 0",h["@daily"]="0 0 0 * * *",h["@hourly"]="0 0 * * * *",h["@minutely"]="0 * * * * *",h["@secondly"]="* * * * * *",h["@weekdays"]="0 0 0 * * 1-5",h["@weekends"]="0 0 0 * * 0,6"})(d||(it.PredefinedExpressions=d={}));var c;(function(h){h.Second="Second",h.Minute="Minute",h.Hour="Hour",h.DayOfMonth="DayOfMonth",h.Month="Month",h.DayOfWeek="DayOfWeek"})(c||(it.CronUnit=c={}));var l;(function(h){h[h.jan=1]="jan",h[h.feb=2]="feb",h[h.mar=3]="mar",h[h.apr=4]="apr",h[h.may=5]="may",h[h.jun=6]="jun",h[h.jul=7]="jul",h[h.aug=8]="aug",h[h.sep=9]="sep",h[h.oct=10]="oct",h[h.nov=11]="nov",h[h.dec=12]="dec"})(l||(it.Months=l={}));var m;(function(h){h[h.sun=0]="sun",h[h.mon=1]="mon",h[h.tue=2]="tue",h[h.wed=3]="wed",h[h.thu=4]="thu",h[h.fri=5]="fri",h[h.sat=6]="sat"})(m||(it.DayOfWeek=m={}));let p=class lt{static parse(g,v={}){const{strict:x=!1,hashSeed:y}=v,C=(0,u.seededRandom)(y);g=d[g]||g;const w=lt.#e(g,x);if(!(w.dayOfMonth==="*"||w.dayOfWeek==="*"||!x))throw new Error("Cannot use both dayOfMonth and dayOfWeek together in strict mode!");const k=lt.#n(c.Second,w.second,s.CronSecond.constraints,C),O=lt.#n(c.Minute,w.minute,s.CronMinute.constraints,C),M=lt.#n(c.Hour,w.hour,s.CronHour.constraints,C),j=lt.#n(c.Month,w.month,s.CronMonth.constraints,C),E=lt.#n(c.DayOfMonth,w.dayOfMonth,s.CronDayOfMonth.constraints,C),{dayOfWeek:R,nthDayOfWeek:U}=lt.#d(w.dayOfWeek),P=lt.#n(c.DayOfWeek,R,s.CronDayOfWeek.constraints,C),K=new e.CronFieldCollection({second:new s.CronSecond(k,{rawValue:w.second}),minute:new s.CronMinute(O,{rawValue:w.minute}),hour:new s.CronHour(M,{rawValue:w.hour}),dayOfMonth:new s.CronDayOfMonth(E,{rawValue:w.dayOfMonth}),month:new s.CronMonth(j,{rawValue:w.month}),dayOfWeek:new s.CronDayOfWeek(P,{rawValue:w.dayOfWeek,nthDayOfWeek:U})});return new r.CronExpression(K,{...v,expression:g})}static#e(g,v){if(v&&!g.length)throw new Error("Invalid cron expression");g=g||"0 * * * * *";const x=g.trim().split(/\s+/);if(v&&x.length<6)throw new Error("Invalid cron expression, expected 6 fields");if(x.length>6)throw new Error("Invalid cron expression, too many fields");const y=["*","*","*","*","*","0"];x.length<y.length&&x.unshift(...y.slice(x.length));const[C,w,k,O,M,j]=x;return{second:C,minute:w,hour:k,dayOfMonth:O,month:M,dayOfWeek:j}}static#n(g,v,x,y){if((g===c.Month||g===c.DayOfWeek)&&(v=v.replace(/[a-z]{3}/gi,C=>{C=C.toLowerCase();const w=l[C]||m[C];if(w===void 0)throw new Error(`Validation error, cannot resolve alias "${C}"`);return w.toString()})),!x.validChars.test(v))throw new Error(`Invalid characters, got value: ${v}`);return v=this.#o(v,x),v=this.#s(v,x,y),this.#r(g,v,x)}static#o(g,v){return g.replace(/[*?]/g,v.min+"-"+v.max)}static#s(g,v,x){const y=x();return g.replace(/H(?:\((\d+)-(\d+)\))?(?:\/(\d+))?/g,(C,w,k,O)=>{if(w&&k&&O){const M=parseInt(w,10),j=parseInt(k,10),E=parseInt(O,10);if(M>j)throw new Error(`Invalid range: ${M}-${j}, min > max`);if(E<=0)throw new Error(`Invalid step: ${E}, must be positive`);const R=Math.max(M,v.min),U=Math.floor(y*E),P=[];for(let K=Math.floor(R/E)*E+U;K<=j;K+=E)K>=R&&P.push(K);return P.join(",")}else if(w&&k){const M=parseInt(w,10),j=parseInt(k,10);if(M>j)throw new Error(`Invalid range: ${M}-${j}, min > max`);return String(Math.floor(y*(j-M+1))+M)}else if(O){const M=parseInt(O,10);if(M<=0)throw new Error(`Invalid step: ${M}, must be positive`);const j=Math.floor(y*M),E=[];for(let R=Math.floor(v.min/M)*M+j;R<=v.max;R+=M)R>=v.min&&E.push(R);return E.join(",")}else return String(Math.floor(y*(v.max-v.min+1)+v.min))})}static#r(g,v,x){const y=[];function C(k,O){if(Array.isArray(k))y.push(...k);else if(lt.#h(O,k))y.push(k);else{const M=parseInt(k.toString(),10);if(!(M>=O.min&&M<=O.max))throw new Error(`Constraint error, got value ${k} expected range ${O.min}-${O.max}`);y.push(g===c.DayOfWeek?M%7:k)}}return v.split(",").forEach(k=>{if(!(k.length>0))throw new Error("Invalid list value format");C(lt.#t(g,k,x),x)}),y}static#t(g,v,x){const y=v.split("/");if(y.length>2)throw new Error(`Invalid repeat: ${v}`);return y.length===2?(y[0].includes("-")||(y[0]=`${y[0]}-${x.max}`),lt.#i(g,y[0],parseInt(y[1],10),x)):lt.#i(g,v,1,x)}static#c(g,v,x){if(!(!isNaN(g)&&!isNaN(v)&&g>=x.min&&v<=x.max))throw new Error(`Constraint error, got range ${g}-${v} expected range ${x.min}-${x.max}`);if(g>v)throw new Error(`Invalid range: ${g}-${v}, min(${g}) > max(${v})`)}static#l(g){if(!(!isNaN(g)&&g>0))throw new Error(`Constraint error, cannot repeat at every ${g} time.`)}static#a(g,v,x,y){const C=[];g===c.DayOfWeek&&x%7===0&&C.push(0);for(let w=v;w<=x;w+=y)C.indexOf(w)===-1&&C.push(w);return C}static#i(g,v,x,y){const C=v.split("-");if(C.length<=1)return isNaN(+v)?v:+v;const[w,k]=C.map(O=>parseInt(O,10));return this.#c(w,k,y),this.#l(x),this.#a(g,w,k,x)}static#d(g){const v=g.split("#");if(v.length<=1)return{dayOfWeek:v[0]};const x=+v[v.length-1],y=g.match(/([,-/])/);if(y!==null)throw new Error(`Constraint error, invalid dayOfWeek \`#\` and \`${y?.[0]}\` special characters are incompatible`);if(!(v.length<=2&&!isNaN(x)&&x>=1&&x<=5))throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return{dayOfWeek:v[0],nthDayOfWeek:x}}static#h(g,v){return g.chars.some(x=>v.toString().includes(x))}};return it.CronExpressionParser=p,it}var St={};const iu={},lu=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"})),Ro=o.getAugmentedNamespace(lu);var Po;function cu(){if(Po)return St;Po=1;var e=St&&St.__createBinding||(Object.create?(function(c,l,m,p){p===void 0&&(p=m);var h=Object.getOwnPropertyDescriptor(l,m);(!h||("get"in h?!l.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return l[m]}}),Object.defineProperty(c,p,h)}):(function(c,l,m,p){p===void 0&&(p=m),c[p]=l[m]})),r=St&&St.__setModuleDefault||(Object.create?(function(c,l){Object.defineProperty(c,"default",{enumerable:!0,value:l})}):function(c,l){c.default=l}),u=St&&St.__importStar||(function(){var c=function(l){return c=Object.getOwnPropertyNames||function(m){var p=[];for(var h in m)Object.prototype.hasOwnProperty.call(m,h)&&(p[p.length]=h);return p},c(l)};return function(l){if(l&&l.__esModule)return l;var m={};if(l!=null)for(var p=c(l),h=0;h<p.length;h++)p[h]!=="default"&&e(m,l,p[h]);return r(m,l),m}})();Object.defineProperty(St,"__esModule",{value:!0}),St.CronFileParser=void 0;const s=ts();let d=class yr{static async parseFile(l){const{readFile:m}=await Promise.resolve().then(()=>u(Ro)),p=await m(l,"utf8");return yr.#e(p)}static parseFileSync(l){const{readFileSync:m}=Ro,p=m(l,"utf8");return yr.#e(p)}static#e(l){const m=l.split(`
|
|
5
|
+
`),p={variables:{},expressions:[],errors:{}};for(const h of m){const g=h.trim();if(g.length===0||g.startsWith("#"))continue;const v=g.match(/^(.*)=(.*)$/);if(v){const[,x,y]=v;p.variables[x]=y.replace(/["']/g,"");continue}try{const x=yr.#n(g);p.expressions.push(x.interval)}catch(x){p.errors[g]=x}}return p}static#n(l){const m=l.split(" ");return{interval:s.CronExpressionParser.parse(m.slice(0,5).join(" ")),command:m.slice(5,m.length)}}};return St.CronFileParser=d,St}var Lo;function uu(){return Lo||(Lo=1,(function(e){var r=Kt&&Kt.__createBinding||(Object.create?(function(h,g,v,x){x===void 0&&(x=v);var y=Object.getOwnPropertyDescriptor(g,v);(!y||("get"in y?!g.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return g[v]}}),Object.defineProperty(h,x,y)}):(function(h,g,v,x){x===void 0&&(x=v),h[x]=g[v]})),u=Kt&&Kt.__exportStar||function(h,g){for(var v in h)v!=="default"&&!Object.prototype.hasOwnProperty.call(g,v)&&r(g,h,v)};Object.defineProperty(e,"__esModule",{value:!0}),e.CronFileParser=e.CronExpressionParser=e.CronExpression=e.CronFieldCollection=e.CronDate=void 0;const s=ts();var d=is();Object.defineProperty(e,"CronDate",{enumerable:!0,get:function(){return d.CronDate}});var c=sa();Object.defineProperty(e,"CronFieldCollection",{enumerable:!0,get:function(){return c.CronFieldCollection}});var l=oa();Object.defineProperty(e,"CronExpression",{enumerable:!0,get:function(){return l.CronExpression}});var m=ts();Object.defineProperty(e,"CronExpressionParser",{enumerable:!0,get:function(){return m.CronExpressionParser}});var p=cu();Object.defineProperty(e,"CronFileParser",{enumerable:!0,get:function(){return p.CronFileParser}}),u(ls(),e),e.default=s.CronExpressionParser})(Kt)),Kt}var du=uu(),zr={exports:{}},_o;function hu(){return _o||(_o=1,(function(e,r){(function(s,d){e.exports=d()})(globalThis,()=>(()=>{var u={949:((l,m,p)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.CronParser=void 0;var h=p(515),g=(function(){function v(x,y,C){y===void 0&&(y=!0),C===void 0&&(C=!1),this.expression=x,this.dayOfWeekStartIndexZero=y,this.monthStartIndexZero=C}return v.prototype.parse=function(){var x,y,C=(x=this.expression)!==null&&x!==void 0?x:"";if(C==="@reboot")return y=["@reboot","","","","","",""],y;if(C.startsWith("@")){var w=this.parseSpecial(this.expression);y=this.extractParts(w)}else y=this.extractParts(this.expression);return this.normalize(y),this.validate(y),y},v.prototype.parseSpecial=function(x){var y={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},C=y[x];if(!C)throw new Error("Unknown special expression.");return C},v.prototype.extractParts=function(x){if(!this.expression)throw new Error("cron expression is empty");for(var y=x.trim().split(/[ ]+/),C=0;C<y.length;C++)if(y[C].includes(",")){var w=y[C].split(",").map(function(O){return O.trim()}).filter(function(O){return O!==""}).map(function(O){return isNaN(Number(O))?O:Number(O)}).filter(function(O){return O!==null&&O!==""});w.length===0&&w.push("*"),w.sort(function(O,M){return O!==null&&M!==null?O-M:0}),y[C]=w.map(function(O){return O!==null?O.toString():""}).join(",")}if(y.length<5)throw new Error("Expression has only ".concat(y.length," part").concat(y.length==1?"":"s",". At least 5 parts are required."));if(y.length==5)y.unshift(""),y.push("");else if(y.length==6){var k=/\d{4}$/.test(y[5])||y[4]=="?"||y[2]=="?";k?y.unshift(""):y.push("")}else if(y.length>7)throw new Error("Expression has ".concat(y.length," parts; too many!"));return y},v.prototype.normalize=function(x){var y=this;if(x[3]=x[3].replace("?","*"),x[5]=x[5].replace("?","*"),x[2]=x[2].replace("?","*"),x[0].indexOf("0/")==0&&(x[0]=x[0].replace("0/","*/")),x[1].indexOf("0/")==0&&(x[1]=x[1].replace("0/","*/")),x[2].indexOf("0/")==0&&(x[2]=x[2].replace("0/","*/")),x[3].indexOf("1/")==0&&(x[3]=x[3].replace("1/","*/")),x[4].indexOf("1/")==0&&(x[4]=x[4].replace("1/","*/")),x[6].indexOf("1/")==0&&(x[6]=x[6].replace("1/","*/")),x[5]=x[5].replace(/(^\d)|([^#/\s]\d)/g,function(R){var U=R.replace(/\D/,""),P=U;return y.dayOfWeekStartIndexZero?U=="7"&&(P="0"):P=(parseInt(U)-1).toString(),R.replace(U,P)}),x[5]=="L"&&(x[5]="6"),x[3]=="?"&&(x[3]="*"),x[3].indexOf("W")>-1&&(x[3].indexOf(",")>-1||x[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var C={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var w in C)x[5]=x[5].replace(new RegExp(w,"gi"),C[w].toString());x[4]=x[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(R){var U=R.replace(/\D/,""),P=U;return y.monthStartIndexZero&&(P=(parseInt(U)+1).toString()),R.replace(U,P)});var k={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var O in k)x[4]=x[4].replace(new RegExp(O,"gi"),k[O].toString());x[0]=="0"&&(x[0]=""),!/\*|\-|\,|\//.test(x[2])&&(/\*|\//.test(x[1])||/\*|\//.test(x[0]))&&(x[2]+="-".concat(x[2]));for(var M=0;M<x.length;M++)if(x[M].indexOf(",")!=-1&&(x[M]=x[M].split(",").filter(function(R){return R!==""}).join(",")||"*"),x[M]=="*/1"&&(x[M]="*"),x[M].indexOf("/")>-1&&!/^\*|\-|\,/.test(x[M])){var j=null;switch(M){case 4:j="12";break;case 5:j="6";break;case 6:j="9999";break;default:j=null;break}if(j!==null){var E=x[M].split("/");x[M]="".concat(E[0],"-").concat(j,"/").concat(E[1])}}},v.prototype.validate=function(x){var y="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(x[0],y),this.validateOnlyExpectedCharactersFound(x[1],y),this.validateOnlyExpectedCharactersFound(x[2],y),this.validateOnlyExpectedCharactersFound(x[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(x[4],y),this.validateOnlyExpectedCharactersFound(x[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(x[6],y),this.validateAnyRanges(x)},v.prototype.validateAnyRanges=function(x){h.default.secondRange(x[0]),h.default.minuteRange(x[1]),h.default.hourRange(x[2]),h.default.dayOfMonthRange(x[3]),h.default.monthRange(x[4],this.monthStartIndexZero),h.default.dayOfWeekRange(x[5],this.dayOfWeekStartIndexZero)},v.prototype.validateOnlyExpectedCharactersFound=function(x,y){var C=x.match(new RegExp("[^".concat(y,"]+"),"gi"));if(C&&C.length)throw new Error("Expression contains invalid values: '".concat(C.toString(),"'"))},v})();m.CronParser=g}),333:((l,m,p)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.ExpressionDescriptor=void 0;var h=p(823),g=p(949),v=(function(){function x(y,C){if(this.expression=y,this.options=C,this.expressionParts=new Array(5),!this.options.locale&&x.defaultLocale&&(this.options.locale=x.defaultLocale),!x.locales[this.options.locale]){var w=Object.keys(x.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(w,"'.")),this.options.locale=w}this.i18n=x.locales[this.options.locale],C.use24HourTimeFormat===void 0&&(C.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return x.toString=function(y,C){var w=C===void 0?{}:C,k=w.throwExceptionOnParseError,O=k===void 0?!0:k,M=w.verbose,j=M===void 0?!1:M,E=w.dayOfWeekStartIndexZero,R=E===void 0?!0:E,U=w.monthStartIndexZero,P=U===void 0?!1:U,K=w.use24HourTimeFormat,A=w.locale,L=A===void 0?null:A,V={throwExceptionOnParseError:O,verbose:j,dayOfWeekStartIndexZero:R,monthStartIndexZero:P,use24HourTimeFormat:K,locale:L};V.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var N=new x(y,V);return N.getFullDescription()},x.initialize=function(y,C){C===void 0&&(C="en"),x.specialCharacters=["/","-",",","*"],x.defaultLocale=C,y.load(x.locales)},x.prototype.getFullDescription=function(){var y,C,w="";try{var k=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=k.parse(),this.expressionParts[0]==="@reboot")return((C=(y=this.i18n).atReboot)===null||C===void 0?void 0:C.call(y))||"Run once, at startup";var O=this.getTimeOfDayDescription(),M=this.getDayOfMonthDescription(),j=this.getMonthDescription(),E=this.getDayOfWeekDescription(),R=this.getYearDescription();w+=O+M+E+j+R,w=this.transformVerbosity(w,!!this.options.verbose),w=w.charAt(0).toLocaleUpperCase()+w.substr(1)}catch(U){if(!this.options.throwExceptionOnParseError)w=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(U)}return w},x.prototype.getTimeOfDayDescription=function(){var y=this.expressionParts[0],C=this.expressionParts[1],w=this.expressionParts[2],k="";if(!h.StringUtilities.containsAny(C,x.specialCharacters)&&!h.StringUtilities.containsAny(w,x.specialCharacters)&&!h.StringUtilities.containsAny(y,x.specialCharacters))k+=this.i18n.atSpace()+this.formatTime(w,C,y);else if(!y&&C.indexOf("-")>-1&&!(C.indexOf(",")>-1)&&!(C.indexOf("/")>-1)&&!h.StringUtilities.containsAny(w,x.specialCharacters)){var O=C.split("-");k+=h.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(w,O[0],""),this.formatTime(w,O[1],""))}else if(!y&&w.indexOf(",")>-1&&w.indexOf("-")==-1&&w.indexOf("/")==-1&&!h.StringUtilities.containsAny(C,x.specialCharacters)){var M=w.split(",");k+=this.i18n.at();for(var j=0;j<M.length;j++)k+=" ",k+=this.formatTime(M[j],C,""),j<M.length-2&&(k+=","),j==M.length-2&&(k+=this.i18n.spaceAnd())}else{var E=this.getSecondsDescription(),R=this.getMinutesDescription(),U=this.getHoursDescription();if(k+=E,k&&R&&(k+=", "),k+=R,R===U)return k;k&&U&&(k+=", "),k+=U}return k},x.prototype.getSecondsDescription=function(){var y=this,C=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(w){return w},function(w){return h.StringUtilities.format(y.i18n.everyX0Seconds(w),w)},function(w){return y.i18n.secondsX0ThroughX1PastTheMinute()},function(w){return w=="0"?"":parseInt(w)<20?y.i18n.atX0SecondsPastTheMinute(w):y.i18n.atX0SecondsPastTheMinuteGt20()||y.i18n.atX0SecondsPastTheMinute(w)});return C},x.prototype.getMinutesDescription=function(){var y=this,C=this.expressionParts[0],w=this.expressionParts[2],k=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(O){return O},function(O){return h.StringUtilities.format(y.i18n.everyX0Minutes(O),O)},function(O){return y.i18n.minutesX0ThroughX1PastTheHour()},function(O){try{return O=="0"&&w.indexOf("/")==-1&&C==""?y.i18n.everyHour():parseInt(O)<20?y.i18n.atX0MinutesPastTheHour(O):y.i18n.atX0MinutesPastTheHourGt20()||y.i18n.atX0MinutesPastTheHour(O)}catch{return y.i18n.atX0MinutesPastTheHour(O)}});return k},x.prototype.getHoursDescription=function(){var y=this,C=this.expressionParts[2],w=0,k=[];C.split("/")[0].split(",").forEach(function(j){var E=j.split("-");E.length===2&&k.push({value:E[1],index:w+1}),w+=E.length});var O=0,M=this.getSegmentDescription(C,this.i18n.everyHour(),function(j){var E=k.find(function(U){return U.value===j&&U.index===O}),R=E&&y.expressionParts[1]!=="0";return O++,R?y.formatTime(j,"59",""):y.formatTime(j,"0","")},function(j){return h.StringUtilities.format(y.i18n.everyX0Hours(j),j)},function(j){return y.i18n.betweenX0AndX1()},function(j){return y.i18n.atX0()});return M},x.prototype.getDayOfWeekDescription=function(){var y=this,C=this.i18n.daysOfTheWeek(),w=null;return this.expressionParts[5]=="*"?w="":w=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(k,O){var M=k;k.indexOf("#")>-1?M=k.substring(0,k.indexOf("#")):k.indexOf("L")>-1&&(M=M.replace("L",""));var j=parseInt(M),E=y.i18n.daysOfTheWeekInCase?y.i18n.daysOfTheWeekInCase(O)[j]:C[j];if(k.indexOf("#")>-1){var R=null,U=k.substring(k.indexOf("#")+1),P=k.substring(0,k.indexOf("#"));switch(U){case"1":R=y.i18n.first(P);break;case"2":R=y.i18n.second(P);break;case"3":R=y.i18n.third(P);break;case"4":R=y.i18n.fourth(P);break;case"5":R=y.i18n.fifth(P);break}E=R+" "+E}return E},function(k){return parseInt(k)==1?"":h.StringUtilities.format(y.i18n.commaEveryX0DaysOfTheWeek(k),k)},function(k){var O=k.substring(0,k.indexOf("-")),M=y.expressionParts[3]!="*";return M?y.i18n.commaAndX0ThroughX1(O):y.i18n.commaX0ThroughX1(O)},function(k){var O=null;if(k.indexOf("#")>-1){var M=k.substring(k.indexOf("#")+1),j=k.substring(0,k.indexOf("#"));O=y.i18n.commaOnThe(M,j).trim()+y.i18n.spaceX0OfTheMonth()}else if(k.indexOf("L")>-1)O=y.i18n.commaOnTheLastX0OfTheMonth(k.replace("L",""));else{var E=y.expressionParts[3]!="*";O=E?y.i18n.commaAndOnX0():y.i18n.commaOnlyOnX0(k)}return O}),w},x.prototype.getMonthDescription=function(){var y=this,C=this.i18n.monthsOfTheYear(),w=this.getSegmentDescription(this.expressionParts[4],"",function(k,O){return O&&y.i18n.monthsOfTheYearInCase?y.i18n.monthsOfTheYearInCase(O)[parseInt(k)-1]:C[parseInt(k)-1]},function(k){return parseInt(k)==1?"":h.StringUtilities.format(y.i18n.commaEveryX0Months(k),k)},function(k){return y.i18n.commaMonthX0ThroughMonthX1()||y.i18n.commaX0ThroughX1()},function(k){return y.i18n.commaOnlyInMonthX0?y.i18n.commaOnlyInMonthX0():y.i18n.commaOnlyInX0()});return w},x.prototype.getDayOfMonthDescription=function(){var y=this,C=null,w=this.expressionParts[3];switch(w){case"L":C=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":C=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var k=w.match(/(\d{1,2}W)|(W\d{1,2})/);if(k){var O=parseInt(k[0].replace("W","")),M=O==1?this.i18n.firstWeekday():h.StringUtilities.format(this.i18n.weekdayNearestDayX0(),O.toString());C=h.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),M);break}else{var j=w.match(/L-(\d{1,2})/);if(j){var E=j[1];C=h.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(E),E);break}else{if(w=="*"&&this.expressionParts[5]!="*")return"";C=this.getSegmentDescription(w,this.i18n.commaEveryDay(),function(R){return R=="L"?y.i18n.lastDay():y.i18n.dayX0?h.StringUtilities.format(y.i18n.dayX0(),R):R},function(R){return R=="1"?y.i18n.commaEveryDay():y.i18n.commaEveryX0Days(R)},function(R){return y.i18n.commaBetweenDayX0AndX1OfTheMonth(R)},function(R){return y.i18n.commaOnDayX0OfTheMonth(R)})}break}}return C},x.prototype.getYearDescription=function(){var y=this,C=this.getSegmentDescription(this.expressionParts[6],"",function(w){return/^\d+$/.test(w)?new Date(parseInt(w),1).getFullYear().toString():w},function(w){return h.StringUtilities.format(y.i18n.commaEveryX0Years(w),w)},function(w){return y.i18n.commaYearX0ThroughYearX1()||y.i18n.commaX0ThroughX1()},function(w){return y.i18n.commaOnlyInYearX0?y.i18n.commaOnlyInYearX0():y.i18n.commaOnlyInX0()});return C},x.prototype.getSegmentDescription=function(y,C,w,k,O,M){var j=null,E=y.indexOf("/")>-1,R=y.indexOf("-")>-1,U=y.indexOf(",")>-1;if(!y)j="";else if(y==="*")j=C;else if(!E&&!R&&!U)j=h.StringUtilities.format(M(y),w(y));else if(U){for(var P=y.split(","),K="",A=0;A<P.length;A++)if(A>0&&P.length>2&&(K+=",",A<P.length-1&&(K+=" ")),A>0&&P.length>1&&(A==P.length-1||P.length==2)&&(K+="".concat(this.i18n.spaceAnd()," ")),P[A].indexOf("/")>-1||P[A].indexOf("-")>-1){var L=P[A].indexOf("-")>-1&&P[A].indexOf("/")==-1,V=this.getSegmentDescription(P[A],C,w,k,L?this.i18n.commaX0ThroughX1:O,M);L&&(V=V.replace(", ","")),K+=V}else E?K+=this.getSegmentDescription(P[A],C,w,k,O,M):K+=w(P[A]);E?j=K:j=h.StringUtilities.format(M(y),K)}else if(E){var P=y.split("/");if(j=h.StringUtilities.format(k(P[1]),P[1]),P[0].indexOf("-")>-1){var N=this.generateRangeSegmentDescription(P[0],O,w);N.indexOf(", ")!=0&&(j+=", "),j+=N}else if(P[0].indexOf("*")==-1){var W=h.StringUtilities.format(M(P[0]),w(P[0]));W=W.replace(", ",""),j+=h.StringUtilities.format(this.i18n.commaStartingX0(),W)}}else R&&(j=this.generateRangeSegmentDescription(y,O,w));return j},x.prototype.generateRangeSegmentDescription=function(y,C,w){var k="",O=y.split("-"),M=w(O[0],1),j=w(O[1],2),E=C(y);return k+=h.StringUtilities.format(E,M,j),k},x.prototype.formatTime=function(y,C,w){var k=0,O=0,M=parseInt(y)+k,j=parseInt(C)+O;j>=60?(j-=60,M+=1):j<0&&(j+=60,M-=1),M>=24?M=M-24:M<0&&(M=24+M);var E="",R=!1;this.options.use24HourTimeFormat||(R=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),E=R?"".concat(this.getPeriod(M)," "):" ".concat(this.getPeriod(M)),M>12&&(M-=12),M===0&&(M=12));var U="";return w&&(U=":".concat(("00"+w).substring(w.length))),"".concat(R?E:"").concat(("00"+M.toString()).substring(M.toString().length),":").concat(("00"+j.toString()).substring(j.toString().length)).concat(U).concat(R?"":E)},x.prototype.transformVerbosity=function(y,C){if(!C&&(y=y.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),y=y.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),y=y.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),y=y.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var w=0,k=Object.entries(this.i18n.conciseVerbosityReplacements());w<k.length;w++){var O=k[w],M=O[0],j=O[1];y=y.replace(new RegExp(M,"g"),j)}return y},x.prototype.getPeriod=function(y){return y>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},x.locales={},x})();m.ExpressionDescriptor=v}),747:((l,m,p)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.enLocaleLoader=void 0;var h=p(486),g=(function(){function v(){}return v.prototype.load=function(x){x.en=new h.en},v})();m.enLocaleLoader=g}),486:((l,m)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.en=void 0;var p=(function(){function h(){}return h.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},h.prototype.atX0MinutesPastTheHourGt20=function(){return null},h.prototype.commaMonthX0ThroughMonthX1=function(){return null},h.prototype.commaYearX0ThroughYearX1=function(){return null},h.prototype.use24HourTimeFormatByDefault=function(){return!1},h.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},h.prototype.everyMinute=function(){return"every minute"},h.prototype.everyHour=function(){return"every hour"},h.prototype.atSpace=function(){return"At "},h.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},h.prototype.at=function(){return"At"},h.prototype.spaceAnd=function(){return" and"},h.prototype.everySecond=function(){return"every second"},h.prototype.everyX0Seconds=function(){return"every %s seconds"},h.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},h.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},h.prototype.everyX0Minutes=function(){return"every %s minutes"},h.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},h.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},h.prototype.everyX0Hours=function(){return"every %s hours"},h.prototype.betweenX0AndX1=function(){return"between %s and %s"},h.prototype.atX0=function(){return"at %s"},h.prototype.commaEveryDay=function(){return", every day"},h.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},h.prototype.commaX0ThroughX1=function(){return", %s through %s"},h.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},h.prototype.first=function(){return"first"},h.prototype.second=function(){return"second"},h.prototype.third=function(){return"third"},h.prototype.fourth=function(){return"fourth"},h.prototype.fifth=function(){return"fifth"},h.prototype.commaOnThe=function(){return", on the "},h.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},h.prototype.lastDay=function(){return"the last day"},h.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},h.prototype.commaOnlyOnX0=function(){return", only on %s"},h.prototype.commaAndOnX0=function(){return", and on %s"},h.prototype.commaEveryX0Months=function(){return", every %s months"},h.prototype.commaOnlyInX0=function(){return", only in %s"},h.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},h.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},h.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},h.prototype.firstWeekday=function(){return"first weekday"},h.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},h.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},h.prototype.commaEveryX0Days=function(){return", every %s days"},h.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},h.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},h.prototype.commaEveryHour=function(){return", every hour"},h.prototype.commaEveryX0Years=function(){return", every %s years"},h.prototype.commaStartingX0=function(){return", starting %s"},h.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},h.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},h.prototype.atReboot=function(){return"Run once, at startup"},h})();m.en=p}),515:((l,m)=>{Object.defineProperty(m,"__esModule",{value:!0});function p(g,v){if(!g)throw new Error(v)}var h=(function(){function g(){}return g.secondRange=function(v){for(var x=v.split(","),y=0;y<x.length;y++)if(!isNaN(parseInt(x[y],10))){var C=parseInt(x[y],10);p(C>=0&&C<=59,"seconds part must be >= 0 and <= 59")}},g.minuteRange=function(v){for(var x=v.split(","),y=0;y<x.length;y++)if(!isNaN(parseInt(x[y],10))){var C=parseInt(x[y],10);p(C>=0&&C<=59,"minutes part must be >= 0 and <= 59")}},g.hourRange=function(v){for(var x=v.split(","),y=0;y<x.length;y++)if(!isNaN(parseInt(x[y],10))){var C=parseInt(x[y],10);p(C>=0&&C<=23,"hours part must be >= 0 and <= 23")}},g.dayOfMonthRange=function(v){for(var x=v.split(","),y=0;y<x.length;y++)if(!isNaN(parseInt(x[y],10))){var C=parseInt(x[y],10);p(C>=1&&C<=31,"DOM part must be >= 1 and <= 31")}},g.monthRange=function(v,x){for(var y=v.split(","),C=0;C<y.length;C++)if(!isNaN(parseInt(y[C],10))){var w=parseInt(y[C],10);p(w>=1&&w<=12,x?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},g.dayOfWeekRange=function(v,x){for(var y=v.split(","),C=0;C<y.length;C++)if(!isNaN(parseInt(y[C],10))){var w=parseInt(y[C],10);p(w>=0&&w<=6,x?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},g})();m.default=h}),823:((l,m)=>{Object.defineProperty(m,"__esModule",{value:!0}),m.StringUtilities=void 0;var p=(function(){function h(){}return h.format=function(g){for(var v=[],x=1;x<arguments.length;x++)v[x-1]=arguments[x];return g.replace(/%s/g,function(y){return v.shift()})},h.containsAny=function(g,v){return v.some(function(x){return g.indexOf(x)>-1})},h})();m.StringUtilities=p})},s={};function d(l){var m=s[l];if(m!==void 0)return m.exports;var p=s[l]={exports:{}};return u[l](p,p.exports,d),p.exports}var c={};return(()=>{var l=c;Object.defineProperty(l,"__esModule",{value:!0}),l.toString=void 0;var m=d(333),p=d(747);m.ExpressionDescriptor.initialize(new p.enLocaleLoader),l.default=m.ExpressionDescriptor;var h=m.ExpressionDescriptor.toString;l.toString=h})(),c})())})(zr)),zr.exports}var fu=hu();const pu=o.getDefaultExportFromCjs(fu),mu=new Set(["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC","SUN","MON","TUE","WED","THU","FRI","SAT"]);function gu(e){for(const r of e.trim().split(/\s+/)){if(/[#?]/.test(r))return!1;for(const u of r.split(/[,\-/]/))if(!(u===""||u==="*")&&/[A-Za-z]/.test(u)&&!mu.has(u.toUpperCase()))return!1}return!0}function cs(e){const r=(e??"").trim();if(r.split(/\s+/).filter(Boolean).length!==5)return{valid:!1,description:"",nextRun:null,error:"Expected a 5-field UNIX cron: minute hour day-of-month month day-of-week."};if(!gu(r))return{valid:!1,description:"",nextRun:null,error:"Unsupported cron syntax: L, W, #, and ? extensions are not allowed (plain 5-field UNIX cron only)."};try{const u=pu.toString(r,{use24HourTimeFormat:!0,verbose:!1}),s=du.CronExpressionParser.parse(r,{tz:"UTC"}).next().toDate();return{valid:!0,description:u,nextRun:s}}catch(u){return{valid:!1,description:"",nextRun:null,error:u instanceof Error?u.message:"Invalid cron expression."}}}function aa(e){return e?e.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC":"—"}function yu({onSubmit:e,isSubmitting:r,disabled:u,disabledReason:s}){const[d,c]=I.useState(!1),[l,m]=I.useState(!1),p=()=>c(!1),h=async()=>{try{await e({forceRefresh:l}),c(!1)}catch{}},g=n.jsx("span",{children:n.jsx(o.AddButton,{label:"Materialization",onClick:()=>c(!0),disabled:u})});return n.jsxs(n.Fragment,{children:[u&&s?n.jsx(S.Tooltip,{title:s,children:g}):g,n.jsx(o.AppDialog,{open:d,onClose:p,title:"New materialization",description:"Compile the package, build a table for every persist source, and load them so queries serve from the tables.",actions:n.jsxs(n.Fragment,{children:[n.jsx(S.Button,{onClick:p,children:"Cancel"}),n.jsx(S.Button,{variant:"contained",loading:r,onClick:h,children:"Materialize"})]}),children:n.jsx(S.FormGroup,{children:n.jsx(S.FormControlLabel,{control:n.jsx(S.Switch,{checked:l,onChange:v=>m(v.target.checked)}),label:"Force refresh (rebuild even if unchanged)"})})})]})}function xr({children:e}){return n.jsx(S.Typography,{variant:"caption",component:"h6",sx:{display:"block",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:"text.secondary",mb:1},children:e})}function vr(e){return e===B.MaterializationStatus.Pending||e===B.MaterializationStatus.ManifestRowsReady}function xu(e){return e===B.MaterializationStatus.ManifestFileReady||e===B.MaterializationStatus.Failed||e===B.MaterializationStatus.Cancelled}function ia(e){switch(e){case B.MaterializationStatus.ManifestFileReady:return"Done";case B.MaterializationStatus.Failed:return"Failed";case B.MaterializationStatus.Cancelled:return"Cancelled";case B.MaterializationStatus.Pending:case B.MaterializationStatus.ManifestRowsReady:return"Pending";default:return"Unknown"}}function ns(e){switch(e){case B.MaterializationStatus.ManifestRowsReady:return"info";case B.MaterializationStatus.ManifestFileReady:return"success";case B.MaterializationStatus.Failed:return"error";case B.MaterializationStatus.Cancelled:return"warning";case B.MaterializationStatus.Pending:default:return"default"}}function bu(e){const r=Object.values(us(e).refusedSources??{}).map(s=>({name:s.name,message:s.message})),u=Object.values(e.manifest?.failures??{}).filter(s=>s.refused).map(s=>({name:s.sourceName??s.sourceEntityId,message:s.reason}));return[...r,...u].sort((s,d)=>s.name.localeCompare(d.name))}function la(e,r){const u=[`${e.sourcesBuilt??0} built`,`${e.sourcesReused??0} reused`];return e.sourcesRefused&&u.push(`${e.sourcesRefused} refused`),u.join(r)}function us(e){return e.metadata??{}}function vu(e){return e.trigger==="SCHEDULER"?"Scheduled":"Manual"}function ca(e,r){if(!e)return"-";const u=new Date(e).getTime(),s=r?new Date(r).getTime():Date.now(),d=Math.max(0,s-u);if(d<1e3)return`${d}ms`;const c=Math.round(d/1e3);if(c<60)return`${c}s`;const l=Math.floor(c/60),m=c%60;if(l<60)return`${l}m ${m}s`;const p=Math.floor(l/60),h=l%60;return`${p}h ${h}m`}function rs(e){if(!e)return"—";const r=new Date(e);return Number.isNaN(r.getTime())?"—":r.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Su(e){if(!e)return"-";const r=new Date(e).getTime(),u=Math.round((Date.now()-r)/1e3);if(u<60)return"just now";const s=Math.floor(u/60);if(s<60)return`${s}m ago`;const d=Math.floor(s/60);return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`}function wu({entries:e,builtAt:r}){const u=Object.entries(e??{});return n.jsxs(S.Box,{children:[n.jsxs(S.Stack,{direction:"row",alignItems:"baseline",justifyContent:"space-between",children:[n.jsx(xr,{children:"Build manifest"}),r&&n.jsxs(S.Typography,{variant:"caption",color:"text.secondary",children:["Built ",rs(r)]})]}),u.length===0?n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:"No materialized tables yet."}):n.jsxs(S.Table,{size:"small",children:[n.jsx(S.TableHead,{children:n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:"Source"}),n.jsx(S.TableCell,{children:"Table name"}),n.jsx(S.TableCell,{children:"Connection"}),n.jsx(S.TableCell,{children:"Realization"}),n.jsx(S.TableCell,{align:"right",children:"Rows"})]})}),n.jsx(S.TableBody,{children:u.map(([s,d])=>n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:d.sourceName??s}),n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:d.physicalTableName??"-"}),n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:d.connectionName??"-"}),n.jsx(S.TableCell,{children:d.realization??"-"}),n.jsx(S.TableCell,{align:"right",children:d.rowCount??"-"})]},s))})]})]})}function ua({meta:e}){const r=e.trigger==="SCHEDULER";return n.jsx(S.Tooltip,{title:r?"Fired by the materialization schedule":"Triggered manually",children:n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:vu(e)})})}function Cu({materialization:e,buildPlan:r,onClose:u}){const s=e?us(e):{},d=e?bu(e):[],c=Object.values(r?.sources??{});return n.jsx(S.Dialog,{open:e!==null,onClose:u,maxWidth:"md",fullWidth:!0,"aria-labelledby":"materialization-detail-title",children:e&&n.jsxs(n.Fragment,{children:[n.jsxs(S.DialogTitle,{sx:{pr:6,pb:1.5},id:"materialization-detail-title",children:[n.jsxs(S.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{mb:.75},children:[n.jsx(S.Chip,{size:"small",label:ia(e.status),color:ns(e.status),variant:vr(e.status)?"filled":"outlined"}),n.jsx(ua,{meta:s})]}),n.jsx(S.Typography,{variant:"subtitle1",sx:{fontWeight:600},children:e.packageName??"Materialization"}),n.jsx(S.Typography,{variant:"caption",color:"text.secondary",sx:{fontFamily:B.MONO_FONT_FAMILY,wordBreak:"break-all"},children:e.id}),n.jsx(S.IconButton,{"aria-label":"close",onClick:u,sx:{position:"absolute",right:8,top:8},children:n.jsx(o.CloseIcon,{fontSize:"small"})})]}),n.jsxs(S.DialogContent,{dividers:!0,children:[n.jsxs(S.Box,{sx:{bgcolor:"action.hover",borderRadius:2,p:2,mb:3,display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:2},children:[n.jsx(Yn,{label:"Started",value:rs(e.startedAt??e.createdAt)}),n.jsx(Yn,{label:"Completed",value:rs(e.completedAt)}),n.jsx(Yn,{label:"Duration",value:ca(e.startedAt,e.completedAt)}),n.jsx(Yn,{label:"Sources",value:la(s," · ")}),n.jsx(Yn,{label:"Force refresh",value:s.forceRefresh?"Yes":"No"})]}),e.error&&n.jsxs(S.Box,{sx:{borderRadius:2,p:2,mb:3,border:"1px solid",borderColor:"error.main"},children:[n.jsx(xr,{children:n.jsx(S.Box,{component:"span",sx:{color:"error.main"},children:"Error"})}),n.jsx(S.Typography,{variant:"body2",sx:{fontFamily:B.MONO_FONT_FAMILY,whiteSpace:"pre-wrap"},children:e.error})]}),d.length>0&&n.jsxs(S.Box,{sx:{borderRadius:2,p:2,mb:3,border:"1px solid",borderColor:"warning.main"},children:[n.jsx(xr,{children:n.jsx(S.Box,{component:"span",sx:{color:"warning.main"},children:"Refused sources"})}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"Not built, because materializing them would be unsafe. They serve live until the model changes."}),d.map(l=>n.jsxs(S.Box,{sx:{mt:1},children:[n.jsx(S.Typography,{variant:"body2",sx:{fontFamily:B.MONO_FONT_FAMILY},children:l.name}),n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap"},children:l.message})]},l.name))]}),n.jsxs(S.Box,{sx:{mb:3},children:[n.jsx(xr,{children:"Build plan"}),c.length===0?n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:"This package has no persist sources."}):n.jsxs(S.Table,{size:"small",children:[n.jsx(S.TableHead,{children:n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:"Source"}),n.jsx(S.TableCell,{children:"Connection"}),n.jsx(S.TableCell,{children:"Dialect"}),n.jsx(S.TableCell,{align:"right",children:"Columns"}),n.jsx(S.TableCell,{children:"Source Entity ID"})]})}),n.jsx(S.TableBody,{children:c.map(l=>n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:l.name}),n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY},children:l.connectionName}),n.jsx(S.TableCell,{children:l.dialect??"-"}),n.jsx(S.TableCell,{align:"right",children:l.columns?.length??0}),n.jsx(S.TableCell,{sx:{fontFamily:B.MONO_FONT_FAMILY,fontSize:"0.75rem",wordBreak:"break-all",maxWidth:220},children:l.sourceEntityId})]},l.sourceID))})]})]}),n.jsx(wu,{entries:e.manifest?.entries,builtAt:e.manifest?.builtAt})]})]})})}function Yn({label:e,value:r}){return n.jsxs(S.Box,{children:[n.jsx(S.Typography,{variant:"caption",color:"text.secondary",display:"block",children:e}),n.jsx(S.Typography,{variant:"body2",children:r})]})}const ku=o.createSvgIcon(n.jsx("path",{d:"M6 6h12v12H6z"}));function Tu(e){return o.generateUtilityClass("PrivateSwitchBase",e)}o.generateUtilityClasses("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const Ou=e=>{const{classes:r,checked:u,disabled:s,edge:d}=e,c={root:["root",u&&"checked",s&&"disabled",d&&`edge${o.capitalize(d)}`],input:["input"]};return o.composeClasses(c,Tu,r)},Mu=o.styled(o.ButtonBase,{name:"MuiSwitchBase"})({padding:9,borderRadius:"50%",variants:[{props:{edge:"start",size:"small"},style:{marginLeft:-3}},{props:({edge:e,ownerState:r})=>e==="start"&&r.size!=="small",style:{marginLeft:-12}},{props:{edge:"end",size:"small"},style:{marginRight:-3}},{props:({edge:e,ownerState:r})=>e==="end"&&r.size!=="small",style:{marginRight:-12}}]}),ju=o.styled("input",{name:"MuiSwitchBase",shouldForwardProp:o.rootShouldForwardProp})({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),Du=he.forwardRef(function(r,u){const{autoFocus:s,checked:d,checkedIcon:c,defaultChecked:l,disabled:m,disableFocusRipple:p=!1,edge:h=!1,icon:g,id:v,inputProps:x,inputRef:y,name:C,onBlur:w,onChange:k,onFocus:O,readOnly:M,required:j=!1,tabIndex:E,type:R,value:U,slots:P={},slotProps:K={},...A}=r,[L,V]=o.useControlled({controlled:d,default:!!l,name:"SwitchBase",state:"checked"}),N=o.useFormControl(),W=se=>{O&&O(se),N&&N.onFocus&&N.onFocus(se)},X=se=>{w&&w(se),N&&N.onBlur&&N.onBlur(se)},ne=se=>{if(se.nativeEvent.defaultPrevented)return;const ie=se.target.checked;V(ie),k&&k(se,ie)};let J=m;N&&typeof J>"u"&&(J=N.disabled);const ee=R==="checkbox"||R==="radio",Z={...r,checked:L,disabled:J,disableFocusRipple:p,edge:h},ae=Ou(Z),H={slots:P,slotProps:{input:x,...K}},[Q,re]=o.useSlot("root",{ref:u,elementType:Mu,className:ae.root,shouldForwardComponentProp:!0,externalForwardedProps:{...H,component:"span",...A},getSlotProps:se=>({...se,onFocus:ie=>{se.onFocus?.(ie),W(ie)},onBlur:ie=>{se.onBlur?.(ie),X(ie)}}),ownerState:Z,additionalProps:{centerRipple:!0,focusRipple:!p,disabled:J,role:void 0,tabIndex:null}}),[ve,Re]=o.useSlot("input",{ref:y,elementType:ju,className:ae.input,externalForwardedProps:H,getSlotProps:se=>({...se,onChange:ie=>{se.onChange?.(ie),ne(ie)}}),ownerState:Z,additionalProps:{autoFocus:s,checked:d,defaultChecked:l,disabled:J,id:ee?v:void 0,name:C,readOnly:M,required:j,tabIndex:E,type:R,...R==="checkbox"&&U===void 0?{}:{value:U}}});return n.jsxs(Q,{...re,children:[n.jsx(ve,{...Re}),L?c:g]})}),Eu=o.createSvgIcon(n.jsx("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"})),Iu=o.createSvgIcon(n.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"})),Nu=o.createSvgIcon(n.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"}));function Fu(e){return o.generateUtilityClass("MuiCheckbox",e)}const Hr=o.generateUtilityClasses("MuiCheckbox",["root","checked","disabled","indeterminate","colorPrimary","colorSecondary","sizeSmall","sizeMedium"]),Au=e=>{const{classes:r,indeterminate:u,color:s,size:d}=e,c={root:["root",u&&"indeterminate",`color${o.capitalize(s)}`,`size${o.capitalize(d)}`]},l=o.composeClasses(c,Fu,r);return{...r,...l}},$u=o.styled(Du,{shouldForwardProp:e=>o.rootShouldForwardProp(e)||e==="classes",name:"MuiCheckbox",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[r.root,u.indeterminate&&r.indeterminate,r[`size${o.capitalize(u.size)}`],u.color!=="default"&&r[`color${o.capitalize(u.color)}`]]}})(o.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,variants:[{props:{color:"default",disableRipple:!1},style:{"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity)}}},...Object.entries(e.palette).filter(o.createSimplePaletteValueFilter()).map(([r])=>({props:{color:r,disableRipple:!1},style:{"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[r].main,(e.vars||e).palette.action.hoverOpacity)}}})),...Object.entries(e.palette).filter(o.createSimplePaletteValueFilter()).map(([r])=>({props:{color:r},style:{[`&.${Hr.checked}, &.${Hr.indeterminate}`]:{color:(e.vars||e).palette[r].main},[`&.${Hr.disabled}`]:{color:(e.vars||e).palette.action.disabled}}})),{props:{disableRipple:!1},style:{"&:hover":{"@media (hover: none)":{backgroundColor:"transparent"}}}}]}))),Ru=n.jsx(Iu,{}),Pu=n.jsx(Eu,{}),Lu=n.jsx(Nu,{}),_u=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiCheckbox"}),{checkedIcon:d=Ru,color:c="primary",icon:l=Pu,indeterminate:m=!1,indeterminateIcon:p=Lu,inputProps:h,size:g="medium",disableRipple:v=!1,className:x,slots:y={},slotProps:C={},...w}=s,k=m?p:l,O=m?p:d,M={...s,disableRipple:v,color:c,indeterminate:m,size:g},j=Au(M),E=C.input??h,[R,U]=o.useSlot("root",{ref:u,elementType:$u,className:o.clsx(j.root,x),shouldForwardComponentProp:!0,externalForwardedProps:{slots:y,slotProps:C,...w},ownerState:M,additionalProps:{type:"checkbox",icon:he.cloneElement(k,{fontSize:k.props.fontSize??g}),checkedIcon:he.cloneElement(O,{fontSize:O.props.fontSize??g}),disableRipple:v,slots:y,slotProps:{input:o.mergeSlotProps(typeof E=="function"?E(M):E,{"data-indeterminate":m})}}});return n.jsx(R,{...U,classes:j})});function Wu(e){return o.generateUtilityClass("MuiFormControlLabel",e)}const Qn=o.generateUtilityClasses("MuiFormControlLabel",["root","labelPlacementStart","labelPlacementTop","labelPlacementBottom","disabled","label","error","required","asterisk"]),qu=e=>{const{classes:r,disabled:u,labelPlacement:s,error:d,required:c}=e,l={root:["root",u&&"disabled",`labelPlacement${o.capitalize(s)}`,d&&"error",c&&"required"],label:["label",u&&"disabled"],asterisk:["asterisk",d&&"error"]};return o.composeClasses(l,Wu,r)},zu=o.styled("label",{name:"MuiFormControlLabel",slot:"Root",overridesResolver:(e,r)=>{const{ownerState:u}=e;return[{[`& .${Qn.label}`]:r.label},r.root,r[`labelPlacement${o.capitalize(u.labelPlacement)}`]]}})(o.memoTheme(({theme:e})=>({display:"inline-flex",alignItems:"center",cursor:"pointer",verticalAlign:"middle",WebkitTapHighlightColor:"transparent",marginLeft:-11,marginRight:16,[`&.${Qn.disabled}`]:{cursor:"default"},[`& .${Qn.label}`]:{[`&.${Qn.disabled}`]:{color:(e.vars||e).palette.text.disabled}},variants:[{props:{labelPlacement:"start"},style:{flexDirection:"row-reverse",marginRight:-11}},{props:{labelPlacement:"top"},style:{flexDirection:"column-reverse"}},{props:{labelPlacement:"bottom"},style:{flexDirection:"column"}},{props:({labelPlacement:r})=>r==="start"||r==="top"||r==="bottom",style:{marginLeft:16}}]}))),Hu=o.styled("span",{name:"MuiFormControlLabel",slot:"Asterisk"})(o.memoTheme(({theme:e})=>({[`&.${Qn.error}`]:{color:(e.vars||e).palette.error.main}}))),Vu=he.forwardRef(function(r,u){const s=o.useDefaultProps({props:r,name:"MuiFormControlLabel"}),{checked:d,className:c,componentsProps:l={},control:m,disabled:p,disableTypography:h,inputRef:g,label:v,labelPlacement:x="end",name:y,onChange:C,required:w,slots:k={},slotProps:O={},value:M,...j}=s,E=o.useFormControl(),R=p??m.props.disabled??E?.disabled,U=w??m.props.required,P={disabled:R,required:U};["checked","name","onChange","value","inputRef"].forEach(ne=>{typeof m.props[ne]>"u"&&typeof s[ne]<"u"&&(P[ne]=s[ne])});const K=o.formControlState({props:s,muiFormControl:E,states:["error"]}),A={...s,disabled:R,labelPlacement:x,required:U,error:K.error},L=qu(A),V={slots:k,slotProps:{...l,...O}},[N,W]=o.useSlot("typography",{elementType:o.Typography,externalForwardedProps:V,ownerState:A});let X=v;return X!=null&&X.type!==o.Typography&&!h&&(X=n.jsx(N,{component:"span",...W,className:o.clsx(L.label,W?.className),children:X})),n.jsxs(zu,{className:o.clsx(L.root,c),ownerState:A,ref:u,...j,children:[he.cloneElement(m,P),U?n.jsxs("div",{children:[X,n.jsxs(Hu,{ownerState:A,"aria-hidden":!0,className:L.asterisk,children:[" ","*"]})]}):X]})});function Bu({materialization:e,onCloseDialog:r,isMutating:u,onDelete:s}){const[d,c]=I.useState(!1),[l,m]=I.useState(!1),p=()=>c(!0),h=()=>{c(!1),m(!1),r()};return n.jsxs(I.Fragment,{children:[n.jsxs(He,{"aria-label":`Delete materialization ${e?.id??""}`.trim(),onClick:g=>{g.stopPropagation(),p()},sx:{color:"error.main"},children:[n.jsx(os,{sx:{color:"inherit"},children:n.jsx(Ct.Delete,{fontSize:"small"})}),n.jsx(as,{children:"Delete"})]}),n.jsxs(o.AppDialog,{open:d,onClose:h,title:"Delete materialization",actions:n.jsxs(n.Fragment,{children:[n.jsx(o.Button,{onClick:h,children:"Cancel"}),n.jsx(o.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>s(l),loading:u,children:"Delete run"})]}),children:[n.jsx(o.Typography,{variant:"body2",children:"Delete this run's record? This cannot be undone."}),n.jsx(Vu,{control:n.jsx(_u,{checked:l,onChange:g=>m(g.target.checked)}),label:"Also drop the materialized tables this run produced"})]})]})}function Uu({materializations:e,mutable:r,isMutating:u,onStop:s,onDelete:d,onViewDetails:c}){return e.length===0?n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{py:1,fontStyle:"italic"},children:"No materializations yet."}):n.jsxs(S.Table,{size:"small",sx:{"& td, & th":{borderColor:"divider"},"& td:first-of-type, & th:first-of-type":{pl:0},"& td:last-of-type, & th:last-of-type":{pr:0},"& th":{color:"text.secondary",fontWeight:600}},children:[n.jsx(S.TableHead,{children:n.jsxs(S.TableRow,{children:[n.jsx(S.TableCell,{children:"Status"}),n.jsx(S.TableCell,{children:"Trigger"}),n.jsx(S.TableCell,{children:"Started"}),n.jsx(S.TableCell,{children:"Duration"}),n.jsx(S.TableCell,{children:"Sources"}),n.jsx(S.TableCell,{align:"right",children:"Actions"})]})}),n.jsx(S.TableBody,{children:e.map(l=>n.jsx(Gu,{materialization:l,mutable:r,isMutating:u,onStop:s,onDelete:d,onViewDetails:c},l.id))})]})}function Gu({materialization:e,mutable:r,isMutating:u,onStop:s,onDelete:d,onViewDetails:c}){const[l,m]=I.useState(null),p=!!l,h=()=>m(null),g=us(e),v=g.sourcesBuilt!==void 0||g.sourcesReused!==void 0?la(g,", "):"-",x=vr(e.status),y=xu(e.status),C=e.error??void 0,w=r&&(x||y);return n.jsxs(S.TableRow,{hover:!0,sx:{cursor:"pointer","&:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"-2px"}},onClick:()=>c(e),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),c(e))},role:"button",tabIndex:0,"aria-label":`View materialization ${e.id??""} details`.trim(),children:[n.jsx(S.TableCell,{children:n.jsxs(S.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[n.jsx(S.Typography,{variant:"body2",sx:{fontWeight:500,color:ns(e.status)==="default"?"text.primary":`${ns(e.status)}.main`},children:ia(e.status)}),C&&n.jsx(S.Tooltip,{title:C,children:n.jsx(o.InfoOutlinedIcon,{fontSize:"small",color:"error"})})]})}),n.jsx(S.TableCell,{children:n.jsx(ua,{meta:g})}),n.jsx(S.TableCell,{children:Su(e.startedAt??e.createdAt)}),n.jsx(S.TableCell,{children:ca(e.startedAt,e.completedAt)}),n.jsx(S.TableCell,{children:v}),n.jsx(S.TableCell,{align:"right",onClick:k=>k.stopPropagation(),children:w&&n.jsxs(n.Fragment,{children:[n.jsx(S.IconButton,{size:"small","aria-label":`Materialization actions for ${e.id??""}`.trim(),onClick:k=>m(k.currentTarget),children:n.jsx(Ct.MoreVert,{fontSize:"small"})}),n.jsxs(S.Menu,{anchorEl:l,open:p,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[r&&x&&n.jsxs(S.MenuItem,{"aria-label":`Stop materialization ${e.id??""}`.trim(),disabled:u,onClick:()=>{h(),s(e)},children:[n.jsx(S.ListItemIcon,{children:n.jsx(ku,{fontSize:"small"})}),n.jsx(S.ListItemText,{children:"Stop"})]}),r&&y&&n.jsx(Bu,{materialization:e,isMutating:u,onCloseDialog:h,onDelete:k=>d(e,k)})]})]})})]})}const Yu=o.createSvgIcon(n.jsx("path",{d:"m11.99 18.54-7.37-5.73L3 14.07l9 7 9-7-1.63-1.27zM12 16l7.36-5.73L21 9l-9-7-9 7 1.63 1.27zm0-11.47L17.74 9 12 13.47 6.26 9z"})),Zu={package:"Materialized artifacts are shared across versions",version:"Materialized artifacts are per published version"};function Ku({scope:e,disabled:r,disabledReason:u,isSubmitting:s,onChange:d}){const[c,l]=I.useState(null),m=async p=>{l(null),p!==e&&await d(p).catch(()=>{})};return n.jsxs(n.Fragment,{children:[n.jsx(o.SecondaryButton,{label:"Scope",icon:n.jsx(Yu,{}),onClick:p=>l(p.currentTarget),disabled:r||s,...u?{disabledReason:u}:{},ariaHasPopup:"menu",ariaLabel:`Scope: ${e}`}),n.jsx(S.Menu,{anchorEl:c,open:!!c,onClose:()=>l(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:["package","version"].map(p=>n.jsxs(S.MenuItem,{selected:p===e,onClick:()=>void m(p),children:[n.jsx(S.ListItemIcon,{sx:{minWidth:32},children:p===e&&n.jsx(o.CheckIcon,{fontSize:"small"})}),n.jsx(S.ListItemText,{primary:p,secondary:Zu[p]})]},p))})]})}const Xu=o.createSvgIcon([n.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),n.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")]),Wo="0 6 * * *";function Qu({currentSchedule:e,isSubmitting:r,disabled:u,disabledReason:s,onSubmit:d}){const[c,l]=I.useState(!1),[m,p]=I.useState(e??Wo),h=()=>{p(e??Wo),l(!0)},g=()=>l(!1),v=cs(m),x=async y=>{try{await d(y),l(!1)}catch{}};return n.jsxs(n.Fragment,{children:[n.jsx(o.SecondaryButton,{label:"Schedule",icon:n.jsx(Xu,{}),onClick:h,disabled:u,...s?{disabledReason:s}:{},ariaHasPopup:"dialog",ariaLabel:e?"Edit schedule":"Set schedule"}),n.jsxs(o.AppDialog,{open:c,onClose:g,title:e?"Edit schedule":"Set schedule",description:"The publisher rebuilds this package's materializations on this cadence: a 5-field UNIX cron, in UTC. In a hosted deployment the change takes effect on your next publish.",actions:n.jsxs(n.Fragment,{children:[e&&n.jsx(S.Button,{color:"error",loading:r,onClick:()=>x(null),sx:{mr:"auto"},children:"Clear schedule"}),n.jsx(S.Button,{onClick:g,children:"Cancel"}),n.jsx(S.Button,{variant:"contained",loading:r,disabled:!v.valid,onClick:()=>x(m.trim()),children:"Save schedule"})]}),children:[n.jsx(S.TextField,{autoFocus:!0,fullWidth:!0,size:"small",label:"Cron expression",value:m,onChange:y=>p(y.target.value),error:m.trim()!==""&&!v.valid,helperText:v.valid?`${v.description} · next run ${aa(v.nextRun)}`:v.error,slotProps:{htmlInput:{style:{fontFamily:B.MONO_FONT_FAMILY}}}}),n.jsxs(S.Alert,{severity:"info",children:["A schedule runs only on version-scoped packages, so saving one sets ",n.jsx("code",{children:"scope: version"})," for this package."]})]})]})}const Ju=3e3;function da({resourceUri:e}){const{apiClients:r,mutable:u}=B.useServer(),s=Sr.useQueryClient(),{environmentName:d,packageName:c}=o.parseResourceUri(e),[l,m]=I.useState(""),[p,h]=I.useState(null);if(!c)throw new Error("Materializations requires a package in the resource URI");const g=o.useQueryWithApiError({queryKey:["materializations",d,c],queryFn:()=>r.materializations.listMaterializations(d,c),refetchInterval:W=>(W.state.data?.data??[]).some(J=>vr(J.status))?Ju:!1}),v=o.useQueryWithApiError({queryKey:["package",d,c],queryFn:()=>r.packages.getPackage(d,c)}),x=()=>s.invalidateQueries({queryKey:["materializations",d,c]}),y=o.useMutationWithApiError({mutationFn:Pt("materialization","create",W=>r.materializations.createMaterialization(d,c,{forceRefresh:W.forceRefresh})),onSuccess(){m("Materialization requested"),x()},onError(W){m(W.message),x()}}),C=o.useMutationWithApiError({mutationFn:Pt("materialization","update",W=>r.materializations.materializationAction(d,c,W.id,B.MaterializationActionActionEnum.Stop)),onSuccess(){m("Materialization stopped"),x()},onError(W){m(W.message)}}),w=o.useMutationWithApiError({mutationFn:Pt("materialization","delete",({materialization:W,dropTables:X})=>r.materializations.deleteMaterialization(d,c,W.id,X)),onSuccess(){m("Materialization deleted"),x()},onError(W){m(W.message)}}),k=v.data?.data,O=o.useMutationWithApiError({mutationFn:Pt("schedule","update",W=>r.packages.updatePackage(d,c,{name:c,description:k?.description,...W?{scope:B.PackageScopeEnum.Version}:{},materialization:{schedule:W}})),onSuccess(W,X){m(X?"Schedule updated":"Schedule cleared"),s.invalidateQueries({queryKey:["package",d,c]})},onError(W){m(W.message)}}),M=o.useMutationWithApiError({mutationFn:Pt("scope","update",W=>r.packages.updatePackage(d,c,{name:c,description:k?.description,scope:W})),onSuccess(){m("Scope updated"),s.invalidateQueries({queryKey:["package",d,c]})},onError(W){m(W.message)}}),j=g.data?.data??[],E=j.find(W=>W.id===p)??null,R=j.some(W=>vr(W.status)),U=y.isPending||C.isPending||w.isPending,P=k?.materialization?.schedule??null,K=k?.scope===B.PackageScopeEnum.Version?"version":"package",A=!!k?.manifestLocation,L=!!k?.materialization?.freshness,V=P?cs(P):null,N=A?"Control-plane managed: refresh is driven by the control plane, not the built-in scheduler.":[V?V.valid?`${V.description} (${P}), next run ${aa(V.nextRun)}`:`Unrecognized cron expression (${P})`:L?"Refreshed by a freshness policy; a cron schedule does not apply":"On demand only, no schedule set",`scope: ${K}`].join(" · ");return n.jsxs(n.Fragment,{children:[n.jsxs(wt,{title:"Materializations",count:g.isSuccess?j.length:void 0,action:u&&n.jsxs(S.Stack,{direction:"row",spacing:1,alignItems:"center",children:[!A&&n.jsx(Ku,{scope:K,disabled:!!P,disabledReason:"A schedule requires version scope. Clear the schedule to change it.",isSubmitting:M.isPending,onChange:W=>M.mutateAsync(W==="version"?B.PackageScopeEnum.Version:B.PackageScopeEnum.Package)}),!A&&n.jsx(Qu,{currentSchedule:P,isSubmitting:O.isPending,disabled:L,disabledReason:"This package declares a freshness policy; a schedule and freshness are mutually exclusive.",onSubmit:W=>O.mutateAsync(W)}),n.jsx(yu,{onSubmit:W=>y.mutateAsync(W),isSubmitting:y.isPending,disabled:R,disabledReason:"A materialization is already pending or running for this package."})]}),children:[v.isSuccess&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:N}),g.isError&&n.jsx(o.ApiErrorDisplay,{error:g.error,context:`${d} > ${c} > Materializations`}),!g.isSuccess&&!g.isError&&n.jsx(o.Loading,{text:"Loading materializations..."}),g.isSuccess&&n.jsx(Uu,{materializations:j,mutable:u,isMutating:U,onStop:W=>C.mutate(W),onDelete:(W,X)=>w.mutate({materialization:W,dropTables:X}),onViewDetails:W=>h(W.id??null)})]}),n.jsx(Cu,{materialization:E,buildPlan:v.data?.data?.buildPlan??null,onClose:()=>h(null)}),n.jsx(S.Snackbar,{open:l!=="",autoHideDuration:6e3,onClose:()=>m(""),message:l})]})}const ha=o.createSvgIcon(n.jsx("path",{d:"M17 7h-4v2h4c1.65 0 3 1.35 3 3s-1.35 3-3 3h-4v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5m-6 8H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4zm-3-4h8v2H8z"})),nr=o.createSvgIcon(n.jsx("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"})),ed=o.createSvgIcon(n.jsx("path",{d:"M8 5v14l11-7z"})),Vr={scopeName:"source.malloy",patterns:[{include:"#malloy-language"}],repository:{"malloy-language":{patterns:[{include:"#sql-string"},{include:"#comments"},{include:"#tags"},{include:"#strings"},{include:"#numbers"},{include:"#keywords"},{include:"#properties"},{include:"#functions"},{include:"#datetimes"},{include:"#identifiers-quoted"},{include:"#types"},{include:"#constants"},{include:"#timeframes"},{include:"#identifiers-unquoted"}]},"malloy-matched":{begin:"{",end:"}",patterns:[{include:"#malloy-matched"},{include:"#malloy-language"}]},"malloy-in-sql":{begin:"%{",name:"source.malloy-in-sql",end:"}%?",patterns:[{include:"#malloy-matched"},{include:"#malloy-language"}]},"sql-string":{patterns:[{begin:'(\\b[A-Za-z_][A-Za-z_0-9]*)(\\s*\\.\\s*)(sql)(\\s*\\(\\s*)(""")',end:'"""',beginCaptures:{1:{name:"variable.other"},3:{name:"keyword.control.sql"},5:{name:"punctuation.sql-block.open"}},endCaptures:{0:{name:"punctuation.sql-block.close"}},name:"source.sql",patterns:[{include:"#malloy-in-sql"},{include:"source.sql"}]}]},functions:{patterns:[{match:"(?i)\\b(count)(\\s*\\()(distinct)",captures:{1:{name:"entity.name.function"},3:{name:"entity.name.function.modifier"}}},{match:"(?i)\\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE|UNGROUPED)(\\s*\\()",captures:{1:{name:"entity.name.function"}}},{match:"(?i)\\b([a-zA-Z_][a-zA-Z_0-9]*)(\\s*\\()",captures:{1:{name:"entity.name.function"}}},{match:"(?i)\\b([a-zA-Z_][a-zA-Z_0-9]*)(!)(timestamp|number|string|boolean|date)?(\\s*\\()",captures:{1:{name:"entity.name.function"},3:{name:"entity.name.type"}}}]},datetimes:{patterns:[{match:"(?i)@[0-9]{4}-[0-9]{2}-[0-9]{2}[ T][0-9]{2}:[0-9]{2}((:[0-9]{2})(([\\.,][0-9]+)(\\[[A-Za-z_/]+\\])?)?)?",name:"constant.numeric.timestamp"},{match:"(?i)@[0-9]{4}(-Q[1-4]|-[0-9]{2}(-[0-9]{2}(-WK)?)?)?",name:"constant.numeric.date"}]},"identifiers-quoted":{patterns:[{match:"`[^`]*`",name:"variable.other.quoted"}]},"identifiers-unquoted":{patterns:[{match:"(?i)\\b[A-Za-z_][A-Za-z_0-9]*\\b",name:"variable.other"}]},timeframes:{patterns:[{match:"(?i)\\b((year|quarter|month|week|day|hour|minute|second)s?)\\b",name:"keyword.other.timeframe"},{match:"(?i)\\b(day_of_year|day_of_month)\\b",name:"keyword.other.timeframe"}]},comments:{patterns:[{begin:"/\\*",end:"\\*/",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"comment.block"},{begin:"//",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{begin:"--",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-hyphen"}]},tags:{patterns:[{match:"##\\n",name:"string.quoted",captures:{0:{name:"string.quoted"}}},{begin:'#"',end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{match:"#\\n",name:"string.quoted",captures:{0:{name:"string.quoted"}}},{begin:"#\\s",end:"\\n",beginCaptures:{0:{name:"support.type.property-name.json"}},name:"comment.line.double-slash",patterns:[{include:"#tag-values"}]},{begin:"##\\s",end:"\\n",beginCaptures:{0:{name:"support.type.property-name.json"}},name:"comment.line.double-slash",patterns:[{include:"#tag-values"}]},{begin:"#",end:"\\n",beginCaptures:{0:{name:"string.quoted"}},name:"string.quoted"}],repository:{"tag-values":{name:"support.type.property-name.json",match:'(-)?((?:[^\\s=#]+)|(?:"[^#]+"))(?:\\s*(=)\\s*((?:[^\\s=#]+)|(?:"[^#]+")))?',captures:{1:{name:"keyword.control.negate"},2:{name:"support.type.property-name.json"},3:{name:"keyword.operator.comparison.ts"},4:{name:"string.quoted"}}}}},strings:{patterns:[{begin:"'",end:"'",beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.single",patterns:[{include:"#escapes"}]},{begin:'"',end:'"',beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.double",patterns:[{include:"#escapes"}]},{begin:'"""',end:'"""',beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.triple"},{begin:"(?i)[r|/]'",end:"'",name:"string.regexp",patterns:[{include:"#regex-escapes"}]}],repository:{escapes:{name:"constant.character.escape",match:"\\\\(u[A-Fa-f0-9]{4}|.)",captures:{0:{name:"constant.character.escape"}}},"regex-escapes":{name:"constant.character.escape",match:"\\\\.",captures:{0:{name:"constant.character.escape"}}}}},numbers:{match:"(?i)(\\b((0|[1-9][0-9]*)(E[+-]?[0-9]+|\\.[0-9]*)?)|\\.[0-9]+)",name:"constant.numeric"},constants:{patterns:[{match:"(?i)\\bnull\\b",name:"constant.language.null"},{match:"(?i)\\btrue\\b",name:"constant.language.true"},{match:"(?i)\\bfalse\\b",name:"constant.language.false"}]},types:{patterns:[{match:"(?i)\\bstring\\b",name:"entity.name.type.string"},{match:"(?i)\\bnumber\\b",name:"entity.name.type.number"},{match:"(?i)\\bdate\\b",name:"entity.name.type.date"},{match:"(?i)\\btimestamp\\b",name:"entity.name.type.timestamp"},{match:"(?i)\\bboolean\\b",name:"entity.name.type.boolean"}]},properties:{patterns:[{match:"(?i)\\baccept\\b",name:"keyword.control.accept"},{match:"(?i)\\bselect\\b",name:"keyword.control.select"},{match:"(?i)\\bconnection\\b",name:"keyword.control.connection"},{match:"(?i)\\brun\\b",name:"keyword.control.run"},{match:"(?i)\\bextend\\b",name:"keyword.control.extend"},{match:"(?i)\\brefine\\b",name:"keyword.control.refine"},{match:"(?i)\\baggregate\\b",name:"keyword.control.aggregate"},{match:"(?i)\\bsample\\b",name:"keyword.control.sample"},{match:"(?i)\\bcalculate\\b",name:"keyword.control.calculate"},{match:"(?i)\\btimezone\\b",name:"keyword.control.timezone"},{match:"(?i)\\bdimension\\b",name:"keyword.control.dimension"},{match:"(?i)\\bexcept\\b",name:"keyword.control.except"},{match:"(?i)\\bsource\\b",name:"keyword.control.source"},{match:"(?i)\\bgroup_by\\b",name:"keyword.control.group_by"},{match:"(?i)\\bhaving\\b",name:"keyword.control.having"},{match:"(?i)\\bindex\\b",name:"keyword.control.index"},{match:"(?i)\\bjoin_one\\b",name:"keyword.control.join_one"},{match:"(?i)\\bwith\\b",name:"keyword.control.with"},{match:"(?i)\\bjoin_many\\b",name:"keyword.control.join_many"},{match:"(?i)\\bjoin_cross\\b",name:"keyword.control.join_cross"},{match:"(?i)\\blimit\\b",name:"keyword.control.limit"},{match:"(?i)\\bmeasure\\b",name:"keyword.control.measure"},{match:"(?i)\\bnest\\b",name:"keyword.control.nest"},{match:"(?i)\\border_by\\b",name:"keyword.control.order_by"},{match:"(?i)\\bpartition_by\\b",name:"keyword.control.partition_by"},{match:"(?i)\\bprimary_key\\b",name:"keyword.control.primary_key"},{match:"(?i)\\bproject\\b",name:"keyword.control.project"},{match:"(?i)\\bquery\\b",name:"keyword.control.query"},{match:"(?i)\\brename\\b",name:"keyword.control.rename"},{match:"(?i)\\btop\\b",name:"keyword.control.top"},{match:"(?i)\\bview\\b",name:"keyword.control.view"},{match:"(?i)\\bwhere\\b",name:"keyword.control.where"},{match:"(?i)\\bdeclare\\b",name:"keyword.control.declare"}]},keywords:{patterns:[{match:"(?i)\\bis\\b",name:"keyword.control.is"},{match:"(?i)\\bon\\b",name:"keyword.control.on"},{match:"(?i)\\bnot\\b",name:"keyword.other.not"},{match:"(?i)\\bor\\b",name:"keyword.other.or"},{match:"(?i)\\bdesc\\b",name:"keyword.control.desc"},{match:"(?i)\\bby\\b",name:"keyword.control.by"},{match:"(?i)\\band\\b",name:"keyword.other.and"},{match:"(?i)\\basc\\b",name:"keyword.control.asc"},{match:"(?i)\\bfor\\b",name:"keyword.other.for"},{match:"(?i)\\belse\\b",name:"keyword.other.else"},{match:"(?i)\\bto\\b",name:"keyword.other.to"},{match:"(?i)\\bwhen\\b",name:"keyword.other.when"},{match:"(?i)\\bpick\\b",name:"keyword.other.pick"},{match:"(?i)\\bimport\\b",name:"keyword.control.import"}]}}},td={...Vr,patterns:[...Vr.patterns,{include:"#docvar"}],repository:{...Vr.repository,docvar:{patterns:[{match:"\\<\\<[^(\\>\\>)]*\\>\\>",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"markup.italic.markdown"}]}}},nd={name:"Malloy SQL",scopeName:"source.malloy-sql",patterns:[{include:"#malloysql-sql"}],repository:{"malloysql-sql":{beginCaptures:{0:{name:"entity.other.attribute.malloy-sql"},1:{name:"entity.other.attribute.malloy-sql"},3:{name:"comment.line.double-slash"}},name:"meta.embedded.block.malloysql.sql",patterns:[{include:"#comments"},{begin:"%{",end:"}%",beginCaptures:{0:{name:"punctuation.definition.malloy-sql"}},endCaptures:{0:{name:"punctuation.definition.malloy-sql"}},name:"meta.embedded.block.malloy",patterns:[{include:"source.malloy"}]},{include:"source.sql"}]},comments:{patterns:[{begin:"/\\*",end:"\\*/",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"comment.block"},{begin:"//",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{begin:"--",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-hyphen"}]}}},rd="github-light",sd="github-dark";let Br;function od(){return Br||(Br=(async()=>{const[{createHighlighterCore:e},{createOnigurumaEngine:r},{default:u},{default:s},{default:d},{default:c},{default:l}]=await Promise.all([Promise.resolve().then(()=>require("./core-8NVBCLZh.cjs.js")),Promise.resolve().then(()=>require("./engine-oniguruma-BkproSVE.cjs.js")),Promise.resolve().then(()=>require("./sql-BqWZrLHB.cjs.js")),Promise.resolve().then(()=>require("./json-y-J1j5EW.cjs.js")),Promise.resolve().then(()=>require("./typescript-BqvpT6pB.cjs.js")),Promise.resolve().then(()=>require("./github-light-BFTOhCbz.cjs.js")),Promise.resolve().then(()=>require("./github-dark-BKL9xNgN.cjs.js"))]);return e({engine:r(Promise.resolve().then(()=>require("./wasm-Dw4u1m6u.cjs.js"))),themes:[c,l],langs:[u,s,d,{name:"malloy",scopeName:"source.malloy",embeddedLangs:["sql"],...td},{name:"malloysql",scopeName:"source.malloy-sql",embeddedLangs:["sql"],...nd}]})})()),Br}async function fa(e,r,u="light"){return(await od()).codeToHtml(e,{lang:r,theme:u==="dark"?sd:rd})}function pa({open:e,onClose:r,result:u,title:s="Results",renderLogs:d,drill:c}){return n.jsx(o.AppDialog,{open:e,onClose:r,title:s,maxWidth:!1,showClose:!0,children:n.jsx(S.Box,{sx:{height:"70vh",overflow:"auto"},children:n.jsx(o.ResultContainer,{result:u,maxHeight:o.RESULTS_DIALOG_MAX_HEIGHT,maxResultSize:1e6,renderLogs:d,drill:c})})})}function ad({queryName:e,annotations:r,resourceUri:u,runOnDemand:s=!1,maxResultSize:d=0}){const[c,l]=I.useState(),[m,p]=I.useState(!1),[h,g]=I.useState(!1),{packageName:v,environmentName:x,versionId:y,modelPath:C}=o.parseResourceUri(u),w=!s||h,k=o.useQueryResult({environmentName:x,packageName:v,modelPath:C,versionId:y,queryName:e},{enabled:w}),O=k.data,{mode:M}=B.usePublisherTheme();return I.useEffect(()=>{if(r&&r.length>0){const j=r.map(E=>`// ${E}`).join(`
|
|
6
|
+
`);fa(j,"typescript",M).then(E=>{l(E)})}},[r,M]),n.jsxs(S.Box,{children:[c&&n.jsx(S.Box,{sx:{marginBottom:"16px"},children:n.jsx(S.Typography,{fontSize:"12px",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},children:n.jsx("div",{className:"content",dangerouslySetInnerHTML:{__html:c}})})}),n.jsxs(S.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[n.jsx(S.Typography,{variant:"body2",sx:{fontSize:"15px",fontWeight:600,color:"text.primary",px:2,py:1,bgcolor:"action.hover",borderRadius:1.5,border:1,borderColor:"divider"},children:e}),n.jsx(o.FloatingIconButton,{"aria-label":"Expand results",onClick:()=>p(!0),children:n.jsx(nr,{})})]}),n.jsxs(B.CleanMetricCard,{sx:{position:"relative"},children:[s&&!h&&n.jsxs(S.Box,{sx:{padding:"40px 20px",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:"Click Run to execute the query"}),n.jsx(S.Button,{variant:"contained",startIcon:n.jsx(ed,{}),onClick:()=>g(!0),children:"Run Query"})]}),w&&n.jsx(o.ResultPanel,{state:k,context:e,maxHeight:o.MODEL_CELL_MAX_HEIGHT,maxResultSize:d})]}),n.jsx(pa,{open:m,onClose:()=>p(!1),result:O?.data?.result||"",renderLogs:O?.data?.renderLogs,title:`Query: ${e}`})]})}function id(e){return e!=null}function ld(e,r){const u=[],s=[];for(const c of e){if(c.name===void 0||id(r.get(c.name)))continue;if(c.default==null){u.push(c.name);continue}const l=o.renderGivenDefault(c.type??"string",c.default);l&&s.push(`${c.name} = ${l}`)}const d={missing:u};return s.length>0&&(d.defaultsNote=s.length===1?`Ran with the default ${s[0]}`:`Ran with defaults ${s.join(", ")}`),d}function cd(e){return e.length===1?`This source may need a value for the given ${e[0]}. Set it in the parameters above.`:`This source may need values for the givens ${e.join(", ")}. Set them in the parameters above.`}function ma({sourceAndPaths:e,selectedSourceIndex:r,existingQuery:u,onQueryChange:s,onSourceChange:d,resourceUri:c,givens:l,gate:m}){return I.useEffect(()=>{d&&d(r)},[r,d]),n.jsx(B.StyledCardMedia,{children:n.jsxs(Jn.Stack,{spacing:2,component:"section",children:[n.jsx(dd,{sourceAndPath:e[r],existingQuery:u,onChange:p=>{s&&s(p)},resourceUri:c,givens:l,gate:m}),n.jsx(Jn.Box,{height:"5px"})]})})}function Ur(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function ud({sourceAndPath:e,onChange:r,existingQuery:u,explorerComponents:s,QueryBuilder:d,resourceUri:c,givens:l,gate:m}){const[p,h]=I.useState(u||Ur()),[g,v]=I.useState(void 0);I.useEffect(()=>{u&&h(u)},[u]);const[x,y]=I.useState([]),{MalloyExplorerProvider:C,QueryPanel:w,ResizableCollapsiblePanel:k,ResultPanel:O,SourcePanel:M}=s;I.useEffect(()=>{r&&r(p)},[r,p]);const{environmentName:j,packageName:E,versionId:R}=o.parseResourceUri(c),{apiClients:U}=B.useServer(),P=I.useRef(void 0),K=o.useMutationWithApiError({mutationFn:()=>{P.current=m,v({executionState:"running",query:p?.malloyQuery,queryResolutionStartMillis:Date.now(),onCancel:()=>{K.reset(),v(void 0)},response:{}});const N=typeof p?.malloyQuery=="string"?p.malloyQuery:new d.ASTQuery({source:e.sourceInfo,query:p?.malloyQuery}).toMalloy();return h({...p,query:N}),U.models.executeQueryModel(j,E,e.modelPath,{query:N,sourceName:void 0,queryName:void 0,versionId:R,...l&&Object.keys(l).length>0?{givens:l}:{}})},onSuccess:N=>{if(N){const W=JSON.parse(N.data.result);h({...p,malloyResult:W});const X=P.current;v(ne=>ne?{...ne,executionState:"finished",response:{result:W,...X?.defaultsNote?{messages:[{severity:"INFO",title:X.defaultsNote}]}:{}}}:void 0)}},onError:N=>{console.error("Query execution error:",N);const W=N?.data?.message??N?.message??"The query could not be run.",X=[{severity:"ERROR",title:W}],ne=P.current?.missing??[];(N?.status===403||/Access denied for source/i.test(W))&&ne.length>0&&X.push({severity:"WARN",title:cd(ne)}),v(ee=>ee?{...ee,executionState:"finished",response:{messages:X}}:void 0)}}),[A,L]=I.useState(e.sourceInfo.name);I.useEffect(()=>{A!==e.sourceInfo.name&&(L(e.sourceInfo.name),h(Ur()),v(void 0))},[e,A]);const V=I.useCallback(N=>{h({...p,malloyQuery:N,malloyResult:void 0})},[p]);return A!==e.sourceInfo.name?n.jsx("div",{children:"Loading..."}):n.jsx(B.StyledExplorerContent,{sx:{border:"1px solid #e0e0e0",borderRadius:"8px",overflow:"hidden"},children:n.jsx(C,{source:e.sourceInfo,query:p?.malloyQuery,topValues:[],onFocusedNestViewPathChange:y,focusedNestViewPath:x,onQueryChange:V,children:n.jsxs("div",{style:{display:"flex",height:"100%",overflowY:"auto"},children:[n.jsx(k,{isInitiallyExpanded:!0,initialWidth:180,minWidth:180,icon:"database",title:e.sourceInfo.name,children:n.jsx(M,{onRefresh:()=>h(Ur())})}),n.jsx(k,{isInitiallyExpanded:!0,initialWidth:280,minWidth:280,icon:"filterSliders",title:"Query",children:n.jsx(w,{runQuery:()=>{console.log(`running query with: ${p?.malloyQuery}`);try{K.mutate()}catch(N){console.error("Error running query:",N)}}})}),n.jsx(O,{source:e.sourceInfo,draftQuery:p?.malloyQuery,setDraftQuery:N=>h({...p,malloyQuery:N}),submittedQuery:g,options:{showRawQuery:!0}})]})})},e.sourceInfo.name)}function dd(e){const[r,u]=I.useState(null),[s,d]=I.useState(null),[c,l]=I.useState(!0);return I.useEffect(()=>{let m=!0;return Promise.all([import("@malloydata/malloy-explorer"),o.loadQueryBuilder()]).then(([p,h])=>{m&&(u(p),d(h),l(!1))}).catch(p=>{console.error("Failed to load Malloy components:",p),m&&l(!1)}),()=>{m=!1}},[]),c||!r||!s?n.jsx(B.StyledExplorerPage,{children:n.jsx(B.StyledExplorerContent,{children:n.jsx(Jn.Box,{sx:{alignItems:"center",justifyContent:"center",height:"200px",color:"text.secondary"},children:"Loading explorer..."})})}):n.jsx(ud,{...e,explorerComponents:r,QueryBuilder:s,resourceUri:e.resourceUri})}function ds(e,r=!0){const{modelPath:u,environmentName:s,packageName:d,versionId:c}=o.parseResourceUri(e),{apiClients:l}=B.useServer();return o.useQueryWithApiError({queryKey:["package",s,d,u,c],queryFn:async()=>(await l.models.getModel(s,d,u,c)).data,enabled:r})}function hs({data:e,onChange:r,existingQuery:u,initialSelectedSourceIndex:s=0,onSourceChange:d,resourceUri:c,givens:l,onGivensChange:m,startingGivens:p}){const[h,g]=I.useState(s);I.useEffect(()=>{g(s)},[s]);const{data:v,isError:x,isLoading:y,error:C}=ds(c,!e),{environmentName:w,packageName:k,modelPath:O,versionId:M}=o.parseResourceUri(c),j=e||v,E=I.useMemo(()=>j?.givens??[],[j]),R=o.useDocumentControls({specs:E,loaded:!!j,params:l,onGivensChange:m,startingValues:p,documentKey:c,autorun:!0,environmentName:w??"",packageName:k??"",modelPath:O,versionId:M,documentName:O}),U=I.useMemo(()=>o.givensToRequest(R.applied,R.declaredTypes),[R.applied,R.declaredTypes]),P=I.useMemo(()=>ld(E,R.applied),[E,R.applied]);if(y&&!e)return n.jsx(o.Loading,{text:"Fetching Model..."});if(x&&!e)return console.log("error",C),n.jsx(o.ApiErrorDisplay,{error:C,context:`ModelExplorer > ${O}`});if(!j)return n.jsx(o.Loading,{text:o.LOADING_COPY.loading});const K=(j?.sourceInfos||[]).map((L,V)=>{try{return JSON.parse(L)?.name||`Source ${V+1}`}catch{return`Source ${V+1}`}}),A=K[h]||"";return n.jsxs(B.StyledCard,{variant:"outlined",children:[n.jsx(B.StyledCardContent,{children:n.jsx(S.Stack,{sx:{flexDirection:"row"},children:n.jsx(es,{size:"small",id:"size-small-standard",disablePortal:!0,options:K,value:A,onChange:(L,V)=>{if(!V)return;const N=K.indexOf(V);N>=0&&(g(N),d?.(N))},renderInput:L=>n.jsx(o.TextField,{...L}),style:{width:350,marginTop:"3px",marginLeft:"6px",marginBottom:"8px"}})})}),n.jsx(o.GivensPanel,{...R.panel}),n.jsx(B.StyledCardMedia,{children:n.jsxs(S.Stack,{spacing:2,component:"section",children:[Array.isArray(j.sourceInfos)&&j.sourceInfos.length>0&&n.jsx(ma,{sourceAndPaths:j.sourceInfos.map(L=>({sourceInfo:JSON.parse(L),modelPath:O})),selectedSourceIndex:h,existingQuery:u,onQueryChange:r,resourceUri:c,givens:U,gate:P}),n.jsx(S.Box,{height:"5px"})]})})]})}function fs({open:e,onClose:r,resourceUri:u,data:s,title:d="Data Sources",hasValidImport:c=!0,existingQuery:l,initialSelectedSourceIndex:m,onChange:p,onSourceChange:h,givens:g,onGivensChange:v,startingGivens:x}){return n.jsxs(S.Dialog,{open:e,onClose:r,fullScreen:!0,children:[n.jsxs(S.DialogTitle,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[d,n.jsx(S.IconButton,{onClick:r,sx:{color:"text.secondary"},children:n.jsx(o.CloseIcon,{})})]}),n.jsx(S.DialogContent,{children:c?n.jsx(hs,{resourceUri:u,data:s,existingQuery:l,initialSelectedSourceIndex:m,onChange:p,onSourceChange:h,givens:g,onGivensChange:v,startingGivens:x}):n.jsx("div",{children:"No valid import statement found in cell"})})]})}function hd({onChange:e,resourceUri:r,runOnDemand:u=!1,maxResultSize:s=0,givens:d,onGivensChange:c}){const{modelPath:l}=o.parseResourceUri(r),{data:m,isError:p,isLoading:h,error:g}=ds(r),[v,x]=I.useState(!1),[y,C]=I.useState(),[w,k]=I.useState(0),[O,M]=I.useState(""),[j,E]=I.useState({}),R=d??j,U=c??(N=>E(N)),P=m?.modelDef,K=I.useMemo(()=>{if(!P)return!1;try{const N=JSON.parse(P);return Array.isArray(N.imports)&&N.imports.length>0}catch{return!1}},[P]);if(h)return n.jsx(o.Loading,{text:"Fetching Model..."});if(p)return console.log("error",g),n.jsx(o.ApiErrorDisplay,{error:g,context:`Model > ${l}`});const A=N=>{C(N),e&&e(N)},L=N=>{k(N)},V=()=>{const N=window.location.href;navigator.clipboard.writeText(N).then(()=>M("URL copied to clipboard!")).catch(()=>M("Failed to copy URL"))};return n.jsxs(n.Fragment,{children:[n.jsxs(S.Box,{sx:{position:"relative",maxWidth:"1200px",margin:"0 auto",paddingTop:"24px"},children:[Array.isArray(m?.sourceInfos)&&m.sourceInfos.length>0&&n.jsxs(S.Stack,{spacing:2,component:"section",children:[n.jsxs(S.Box,{sx:{padding:"0 0 16px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsx(S.Typography,{variant:"h1",sx:{fontSize:"28px",fontWeight:"600",color:"#1a1a1a",marginBottom:"8px",marginTop:"0",paddingLeft:"0"},children:"Sources"}),n.jsx(S.Tooltip,{title:"Copy link",children:n.jsx(S.IconButton,{size:"small","aria-label":"Copy link",onClick:V,sx:{color:"text.secondary"},children:n.jsx(ha,{fontSize:"small"})})})]}),n.jsx(hs,{data:m,onChange:A,onSourceChange:L,existingQuery:y,initialSelectedSourceIndex:w,resourceUri:r,givens:R,onGivensChange:U}),n.jsx(o.FloatingIconButton,{"aria-label":"Expand results",sx:{position:"absolute",top:"90px",right:"4px",zIndex:2},onClick:()=>x(!0),children:n.jsx(nr,{})})]}),m?.queries?.length>0&&n.jsxs(S.Stack,{spacing:2,component:"section",sx:{marginTop:"24px"},children:[n.jsx(S.Box,{sx:{padding:"0 0 16px 0"},children:n.jsx(S.Typography,{variant:"h2",sx:{fontSize:"24px",fontWeight:"600",color:"#1a1a1a",marginBottom:"0",marginTop:"8px",paddingLeft:"0"},children:"Named Queries"})}),m.queries.map(N=>n.jsx(ad,{queryName:N.name,annotations:N.annotations,resourceUri:r,runOnDemand:u,maxResultSize:s},N.name))]}),(!Array.isArray(m?.sourceInfos)||m.sourceInfos.length===0)&&!(m?.queries&&m.queries.length>0)&&n.jsxs(S.Box,{sx:{textAlign:"center",py:6},children:[n.jsx(S.Typography,{variant:"body1",sx:{color:"text.secondary",marginBottom:"8px"},children:"This model exposes no sources or queries."}),K&&n.jsxs(S.Typography,{variant:"body2",color:"text.secondary",children:["It imports other files but re-exports nothing. Add"," ",n.jsxs("code",{children:["export ","{ source_name }"]})," to surface imported sources here."]})]}),n.jsx(fs,{open:v,onClose:()=>x(!1),resourceUri:r,data:m,title:`Model: ${l.split("/").pop()}`,existingQuery:y,initialSelectedSourceIndex:w,onChange:A,onSourceChange:L,givens:R,onGivensChange:U})]}),n.jsx(S.Snackbar,{open:O!=="",autoHideDuration:6e3,onClose:()=>M(""),message:O})]})}function ga(e){return I.useMemo(()=>{if(!e?.sources?.length)return[];const r=new Map;for(const u of e.sources)if(u.givens?.length)for(const s of u.givens)s.name&&!r.has(s.name)&&r.set(s.name,s);return Array.from(r.values())},[e])}const fd=400;function pd(e){return e.kind?e.kind==="query":e.type==="code"}const ya=e=>e.proseLines!==void 0;function ps({text:e,proseLines:r}){return(e??"").split(`
|
|
7
|
+
`).filter((u,s)=>!r?.some(([d,c])=>s>=d&&s<=c))}function md(e){if(ya(e)||e.caption!==void 0)return e.caption;const r=[];for(const u of ps(e)){const s=u.trim();if(!s.startsWith("//")){if(!s.startsWith("#"))break;s.startsWith('#"')&&r.push(s.slice(2).trim())}}return r.length>0?r.join(" "):void 0}function gd(e){return ya(e)?ps(e).join(`
|
|
8
8
|
`):e.text.split(`
|
|
9
9
|
`).filter(r=>!r.trimStart().startsWith("##")).join(`
|
|
10
10
|
`)}function yd(e){const r=e.codeLine!==void 0?(e.text.split(`
|
|
11
|
-
`)[e.codeLine]??"").trim():fs(e).map(d=>d.trim()).find(d=>d&&!d.startsWith("#")&&!d.startsWith("//"))??"",u=/^(source|query|given|type):?\s+([A-Za-z_]\w*)/.exec(r);if(u)return`${u[1]}: ${u[2]}`;const s=/^(import|export)\b/.exec(r);return s?s[1]:r}const xd=o.createSvgIcon(n.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),bd=o.createSvgIcon(n.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"})),vd=o.createSvgIcon(n.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}));function Sd({cell:e,resourceUri:r,showCopyLink:u,maxResultSize:s,isExecuting:d,pendingRerun:c,onNavigate:l,onDrillSelf:m,canDrillSelf:p,onDrillNavigate:h,givens:g,givenSpecs:v}){const[x,y]=I.useState(!1),[C,w]=I.useState(!1),[k,O]=I.useState(),[M,j]=I.useState(!1),[E,$]=I.useState(!1),U=I.useId(),[P,K]=I.useState(""),{environmentName:A,packageName:L,modelPath:V}=o.parseResourceUri(r),N={environmentName:A,packageName:L,sourcePath:V,onNavigate:l},{drill:_,drillMenu:Q}=o.useDrill({onNavigate:h,onSelf:m,canSelf:p,selfLabel:"Filter this report"}),re=/import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/,ee=/import\s*(?:\{[^}]*\}\s*from\s*)?['"`]([^'"`]+)['"`]/,te=!!e.text&&(re.test(e.text)||ee.test(e.text)),Z=()=>{if(!e.newSources||e.newSources.length===0)return 0;let oe=[],le="";if(e.text){const Ne=e.text.match(re);Ne&&(oe=Ne[1].split(",").map(X=>X.trim()));const q=e.text.match(ee);q&&(le=q[1].trim())}for(let Ne=0;Ne<e.newSources.length;Ne++)try{const q=JSON.parse(e.newSources[Ne]);if(oe.length>0&&oe.includes(q.name)||le&&le===q.path)return Ne}catch{continue}return 0},ae=I.useMemo(()=>e.newSources&&e.newSources.length>0?{sourceInfos:e.newSources,resource:r,givens:v}:void 0,[e.newSources,r,v]),{mode:H}=B.usePublisherTheme();I.useEffect(()=>{e.type==="code"&&fa(gd(e),"malloy",H).then(oe=>{O(oe)})},[e,H]);const J=e.kind==="query"?md(e):void 0,se=e.markdown?n.jsx(o.Prose,{variant:"document",links:N,children:e.markdown}):null,xe=()=>{const oe=window.location.href;navigator.clipboard.writeText(oe).then(()=>K("URL copied to clipboard!")).catch(()=>K("Failed to copy URL"))},$e=n.jsx(o.AppDialog,{open:x,onClose:()=>y(!1),title:"Malloy code",maxWidth:"lg",showClose:!0,children:n.jsx(S.Box,{sx:oe=>({border:`1px solid ${oe.palette.divider}`,borderRadius:"8px",padding:"16px",fontFamily:B.MONO_FONT_FAMILY,fontSize:"14px",lineHeight:"1.5",overflow:"auto",maxHeight:"70vh",backgroundColor:oe.palette.background.paper,color:oe.palette.text.primary}),children:n.jsx("pre",{className:"code-display",style:{margin:0},dangerouslySetInnerHTML:{__html:k}})})});return e.type==="markdown"&&n.jsx(S.Box,{children:n.jsxs(S.Box,{children:[u?n.jsxs(S.Stack,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[n.jsx(o.Prose,{variant:"document",links:N,children:e.text}),n.jsx(S.Tooltip,{title:"Copy link",children:n.jsx(S.IconButton,{"aria-label":"Copy link",onClick:xe,sx:{color:"text.secondary",mt:"18px"},children:n.jsx(ha,{sx:{fontSize:"24px"}})})})]}):n.jsx(o.Prose,{variant:"document",links:N,children:e.text}),n.jsx(S.Snackbar,{open:P!=="",autoHideDuration:6e3,onClose:()=>K(""),message:P})]})})||e.kind==="definition"&&n.jsxs(S.Box,{children:[se,n.jsxs(S.Box,{component:"button",type:"button","aria-expanded":E,"aria-controls":U,onClick:()=>$(oe=>!oe),sx:{display:"flex",alignItems:"center",gap:"4px",p:0,border:0,background:"none",cursor:"pointer",fontFamily:B.MONO_FONT_FAMILY,fontSize:"13px",color:"text.secondary"},children:[E?n.jsx(bd,{fontSize:"small"}):n.jsx(xd,{fontSize:"small"}),yd(e)]}),E&&n.jsx(B.CleanMetricCard,{id:U,sx:{mt:1,padding:"12px 24px"},children:n.jsx("pre",{className:"code-display",style:{margin:0,overflow:"auto"},dangerouslySetInnerHTML:{__html:k??""}})})]})||e.type==="code"&&n.jsxs(S.Box,{children:[se,J&&n.jsx(S.Typography,{variant:"body2",sx:{color:"text.secondary",mb:1},children:J}),e.newSources&&e.newSources.length>0&&n.jsx(S.Stack,{sx:{flexDirection:"column",gap:"8px",marginBottom:"2px"},children:n.jsx(B.CleanMetricCard,{sx:{position:"relative",padding:"0"},children:n.jsxs(S.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"24px",paddingRight:"8px"},children:[k&&n.jsx("span",{dangerouslySetInnerHTML:{__html:k},style:{fontFamily:B.MONO_FONT_FAMILY,fontSize:"14px",flex:1,marginRight:"8px"}}),te&&n.jsx(o.FloatingIconButton,{"aria-label":"Data sources",sx:{flexShrink:0},onClick:()=>j(!0),children:n.jsx(nr,{})})]})})}),n.jsx(hs,{open:M,onClose:()=>j(!1),title:"Data Sources",hasValidImport:te,resourceUri:r,data:ae,initialSelectedSourceIndex:Z(),startingGivens:g}),$e,n.jsx(pa,{open:C,onClose:()=>w(!1),result:e.result||"",title:"Results",drill:_}),d&&!e.result&&!e.error&&!te&&!(e.newSources&&e.newSources.length>0)&&n.jsx(B.CleanMetricCard,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:n.jsx(S.CircularProgress,{size:32})}),!e.result&&e.error&&n.jsx(o.ErrorDetailAlert,{summary:"This cell could not be run.",detail:e.error}),e.result&&c&&n.jsx(S.LinearProgress,{"aria-label":"Re-run pending",sx:{mb:1,height:2,borderRadius:1}}),e.result&&n.jsxs(B.CleanMetricCard,{sx:{position:"relative"},children:[n.jsx(S.Box,{sx:{paddingTop:"24px"},children:n.jsx(o.ResultContainer,{result:e.result,maxHeight:o.NOTEBOOK_CELL_MAX_HEIGHT,maxResultSize:s,drill:_})}),Q,n.jsxs(S.Stack,{sx:{position:"absolute",top:"-12px",right:"8px",flexDirection:"row",gap:"8px",alignItems:"center",zIndex:2},children:[n.jsx(o.FloatingIconButton,{"aria-label":"Malloy code",onClick:oe=>{oe.stopPropagation(),y(!0)},children:n.jsx(vd,{})}),n.jsx(o.FloatingIconButton,{"aria-label":"Expand results",onClick:()=>w(!0),children:n.jsx(nr,{})})]})]})]})}function wd({ready:e,lastRunKey:r,pendingKey:u,runKey:s,documentKey:d}){if(!e)return{cancelPending:u!==void 0,dispatch:"none"};const c=u!==void 0&&u!==s;if(r===s)return{cancelPending:c,dispatch:"none"};if(u===s)return{cancelPending:c,dispatch:"none"};const l=r===null||!r.startsWith(`${d}|`);return{cancelPending:c,dispatch:l?"now":"settle"}}const Cd=4;function kd(e){const r=e?.response?.data?.message;return typeof r=="string"&&r!==""?r:e instanceof Error&&e.message!==""?e.message:"The server did not say why."}function xa({resourceUri:e,maxResultSize:r=0,givens:u,onGivensChange:s,onNavigate:d,onDrillNavigate:c,notebook:l,error:m,runCell:p}){const{environmentName:h,packageName:g,versionId:v,modelPath:x}=o.parseResourceUri(e),y=l!==void 0,C=!y&&!!m,[w,k]=I.useState([]),[O,M]=I.useState(!1),[j,E]=I.useState(!1),$=I.useRef(void 0),[U,P]=I.useState(null),K=ga(l),A=l?.autorun!==!1,L=o.useReportEvents(),V=o.useDocumentControls({specs:K,loaded:y,startingValues:l?.startingGivens,params:u,onGivensChange:s,documentKey:e,autorun:A,environmentName:h,packageName:g,modelPath:x,versionId:v,documentName:x}),{applied:N,declaredTypes:_,canSelf:Q,onSelf:re}=V,ee=I.useCallback(q=>{const X=o.givensToRequest(q,_);return Object.keys(X).length>0?JSON.stringify(X):void 0},[_]),te=I.useMemo(()=>o.givensToParams(N,_),[N,_]),Z=I.useRef(0),ae=I.useRef(null),H=I.useRef(null),J=I.useRef(void 0);I.useEffect(()=>()=>{ae.current?.abort(),H.current=null,clearTimeout(J.current?.timer),J.current=void 0},[]);const se=I.useCallback(async(q=new Map)=>{if(!y||!l?.notebookCells)return;const X=++Z.current;ae.current?.abort();const ge=new AbortController;ae.current=ge,k(l.notebookCells.map(Se=>({...Se}))),M(!0),P(null);try{const Se=[];for(let we=0;we<l.notebookCells.length;we++){const Te=l.notebookCells[we];if(!pd(Te))continue;const Re=we,Fe=async()=>{try{const Ye=await p({cell:Te,index:Re,givens:q,declaredTypes:_,signal:ge.signal});if(Z.current!==X)return;const ie=Ye.result,Qe=Te.newSources||Ye.newSources;k(ye=>{const We=[...ye];return We[Re]||(We[Re]={...Te}),We[Re]={...We[Re],result:ie,newSources:Qe},We})}catch(Ye){if(ge.signal.aborted||Z.current!==X)return;L.emit({type:"report.query_failed",tile:Re,category:o.failureCategory(Ye)}),L.listening||console.error(`Error executing cell ${Re}:`,Ye);const ie=kd(Ye);k(Qe=>{const ye=[...Qe];return ye[Re]||(ye[Re]={...Te}),ye[Re]={...ye[Re],error:ie},ye})}};Se.push(Fe)}const Ee=[];for(const we of Se){const Te=we().then(()=>{Ee.splice(Ee.indexOf(Te),1)});Ee.push(Te),Ee.length>=Cd&&await Promise.race(Ee)}await Promise.all(Ee)}catch(Se){if(ge.signal.aborted||Z.current!==X)return;L.emit({type:"report.query_failed",category:o.failureCategory(Se)}),L.listening||console.error("Error executing notebook cells:",Se),P(Se)}finally{Z.current===X&&(M(!1),ae.current=null)}},[y,l,_,p,L]),xe=I.useRef(0),$e=I.useRef(void 0);$e.current!==l&&($e.current=l,xe.current+=1);const oe=xe.current;I.useEffect(()=>{const q=`${e}|${oe}`,X=`${q}|${ee(N)??""}`;$.current!==void 0&&$.current!==q&&(ae.current?.abort(),ae.current=null),$.current=q;const ge=wd({ready:y&&!!l?.notebookCells,lastRunKey:H.current,pendingKey:J.current?.key,runKey:X,documentKey:q});if(ge.cancelPending&&(clearTimeout(J.current?.timer),J.current=void 0,E(!1)),ge.dispatch==="none")return;const Se=()=>{J.current=void 0,E(!1),H.current=X,se(N)};if(ge.dispatch==="now"){Se();return}E(!0),J.current={key:X,timer:setTimeout(Se,fd)}},[y,l,oe,e,N,ee,se]);const le=w.length>0?w:l?.notebookCells||[],Ne=l?.format==="malloy"?le.findIndex(q=>q.type==="markdown"):0;return n.jsx(B.CleanNotebookContainer,{children:n.jsx(B.CleanNotebookSection,{children:n.jsxs(S.Stack,{spacing:3,component:"section",children:[n.jsx(o.GivensPanel,{...V.panel}),!y&&!C&&n.jsx(o.Loading,{text:o.LOADING_COPY.opening("report")}),y&&le.map((q,X)=>n.jsx(Sd,{cell:q,showCopyLink:X===Ne,resourceUri:e,maxResultSize:r,isExecuting:O,givens:te,givenSpecs:K,pendingRerun:j,onNavigate:d,onDrillNavigate:c,onDrillSelf:K.length>0?re:void 0,canDrillSelf:Q},X)),C&&m?.status===404&&n.jsxs(S.Typography,{variant:"body2",sx:{color:"text.secondary"},children:[n.jsx("code",{children:`${h} > ${g} > ${x}`})," ","not found."]}),C&&m?.status!==404&&n.jsx(o.ApiErrorDisplay,{error:m,context:`${h} > ${g} > ${x}`}),U&&n.jsx(o.ApiErrorDisplay,{error:{message:U.message,status:500,name:"ExecutionError"},context:"Notebook Execution"})]})})})}function Td({notebook:e,...r}){const{apiClients:u}=B.useServer(),{environmentName:s,packageName:d,versionId:c,modelPath:l}=o.parseResourceUri(r.resourceUri),[m,p]=I.useState(!1);I.useEffect(()=>p(!0),[]);const h=I.useCallback(async({cell:g,givens:v,declaredTypes:x,signal:y})=>({result:(await u.models.executeQueryModel(s,d,l,{query:g.text,givens:o.givensToRequest(v,x),versionId:c},void 0,{signal:y})).data.result}),[u.models,s,d,l,c]);return n.jsx(xa,{...r,notebook:m?e:void 0,runCell:h})}function ba({manifest:e,environmentName:r,packageName:u,versionId:s,documentName:d,givens:c,onGivensChange:l,onDrillNavigate:m,maxResultSize:p}){const{title:h,description:g}=e;return n.jsx(B.CleanNotebookContainer,{children:n.jsxs(B.CleanNotebookSection,{children:[(h||g)&&n.jsx(S.Box,{sx:{mb:2},children:n.jsx(o.DashboardProse,{chrome:"none",title:h??"",...g?{description:g}:{}})}),n.jsx(o.DashboardView,{manifest:e,environmentName:r,packageName:u,versionId:s,documentName:d,givens:c,onGivensChange:l,onNavigate:m,maxResultSize:p,chrome:"none",controlsLayout:"panel"})]})})}function va({resourceUri:e,path:r,givens:u,onGivensChange:s,onNavigate:d,onLinkNavigate:c,height:l,maxResultSize:m,onEvent:p,chrome:h}){const g=o.parseResourceUri(e),{apiClients:v}=B.useServer(),x=g.environmentName??"",y=g.packageName??"",C=g.versionId,w=!!g.environmentName&&!!g.packageName,{data:k,isSuccess:O,isError:M,error:j}=o.useQueryWithApiError({queryKey:["report",x,y,C,r],queryFn:async({signal:N})=>(await v.reports.getReport(x,y,r,C,{signal:N})).data,enabled:w&&r!==""}),E=k?k.notebook?"linear":k.layout:void 0,$=o.useReportEmitter({path:r,layout:E},p),U=`${e}|${r}`,P=I.useRef(void 0),K=I.useRef({key:U,at:o.now()});K.current.key!==U&&(K.current={key:U,at:o.now()}),I.useEffect(()=>{P.current!==U&&(w?M?(P.current=U,$.emit({type:"report.load_failed",surface:"view",category:o.failureCategory(j)})):k?.notebook?.format==="malloynb"?(P.current=U,$.emit({type:"report.load_failed",surface:"view",category:"unsupported"})):O&&k&&(P.current=U,$.emit({type:"report.opened",surface:"view",from:"package",tiles:k.notebook?k.notebook.notebookCells?.length??0:k.tiles?.length??0,durationMs:o.now()-K.current.at})):(P.current=U,$.emit({type:"report.load_failed",surface:"view",category:"invalid"})))},[U,w,M,j,O,k,$]);const A=I.useCallback((N,_)=>{const Q=d?.(N,_);Q&&$.emit({type:"report.drill",to:"report",outcome:Q})},[d,$]),L=d?A:void 0;if(!w)return n.jsxs(S.Alert,{severity:"error",children:["A report resource URI must name an environment and a package. Received: ",e]});if(M)return n.jsx(o.ApiErrorDisplay,{context:`${x} > ${y} > ${r}`,error:j});if(!O||!k)return n.jsx(o.Loading,{text:o.LOADING_COPY.opening("report")});if(k.notebook?.format==="malloynb")return n.jsxs(S.Alert,{severity:"info",children:[r," is a .malloynb notebook, which Report does not run: render it with Notebook."]});let V;return k.notebook?V=n.jsx(Td,{resourceUri:o.encodeResourceUri({environmentName:x,packageName:y,versionId:C,modelPath:r}),notebook:k.notebook,maxResultSize:m,givens:u,onGivensChange:s,onNavigate:c,onDrillNavigate:L}):k.layout==="linear"?V=n.jsx(ba,{manifest:k,environmentName:x,packageName:y,versionId:C,documentName:r,givens:u,onGivensChange:s,onDrillNavigate:L,maxResultSize:m}):V=n.jsx(o.DashboardView,{manifest:k,environmentName:x,packageName:y,versionId:C,documentName:r,givens:u,onGivensChange:s,onNavigate:L,height:l,maxResultSize:m,chrome:h}),n.jsx(o.ReportEventsContext.Provider,{value:$,children:V})}const Od={linear:"Linear: read top to bottom",grid:"Grid: tiles side by side"};function Sa({open:e,layout:r,kind:u,allowLayoutChange:s,allowKindChange:d,environmentName:c,packageName:l,versionId:m,models:p,modelsLoading:h=!1,modelsError:g,onRetryModels:v,target:x,savedAs:y,onClose:C,onCreated:w,onEvent:k}){const O=r??(u?o.layoutOfKind(u):"linear"),M=s??d??!0,[j,E]=I.useState(O),[$,U]=I.useState(void 0),[P,K]=I.useState(""),[A,L]=I.useState(""),[V,N]=I.useState(""),[_,Q]=I.useState(!1),[re,ee]=I.useState(!1),[te,Z]=I.useState(!1),[ae,H]=I.useState(void 0),J=g!=null,{choices:se,isLoading:xe,isSuccess:$e,failed:oe,retry:le,canRetry:Ne}=o.useDocumentChoices({environmentName:c,packageName:l,...m!==void 0?{versionId:m}:{},models:p,enabled:e&&p.length>0}),q=I.useMemo(()=>se.get(P)??[],[se,P]),X=q.find(pe=>`${pe.source}::${pe.view}`===A);I.useEffect(()=>{e&&E(O)},[e,O]),I.useEffect(()=>{if(!e)return;const pe=[...se.keys()];P===""&&pe.length>0&&K(pe[0])},[e,se,P]),I.useEffect(()=>{!e||q.length===0||A!==""||L(`${q[0].source}::${q[0].view}`)},[e,q,A]),I.useEffect(()=>{!e||_||X===void 0||N(X.view.replace(/_/g," "))},[e,_,X]),I.useEffect(()=>{e||(K(""),L(""),N(""),Q(!1),U(void 0),ee(!1),H(void 0))},[e]);const ge=I.useMemo(()=>{if(V.trim()!=="")for(let pe=1;pe<=o.MAX_SLUG_ATTEMPTS;pe++){const st=o.reportPathForTitle(V,pe);if(!x.existing?.includes(st))return st}},[V,x]),Se=$?.trim(),Ee=Se===void 0||Se===""?void 0:Se.endsWith(".malloy")?Se:`${Se}.malloy`,we=Ee??ge,Te=Ee===void 0?void 0:o.reportPathProblem(Ee)??(x.existing?.includes(Ee)?`${Ee} already exists; choose another location.`:void 0),Fe=(X===void 0?void 0:o.newDocumentProblem({title:V,modelPath:P,source:X.source,view:X.view}))??(V.trim()!==""&&we===void 0?"No free file name for this title; choose another.":void 0),Ye=Fe!==void 0&&(re||V.trim()!==""),ie=h||xe,Qe=se.size===0&&(J||oe.length>0),ye=ie?"Loading model views":Qe?"Couldn't read the model views to start from":se.size===0?"No model view to start from yet":X===void 0?"Pick a view to start from":void 0,We="report",ct=te?`Creating ${We}…`:`Create ${We}`,Nt="First query",gt=A!==""&&X===void 0&&q.length>0,Ze=async()=>{if(!(ye!==void 0||X===void 0||te)){if(Fe!==void 0||Te!==void 0){ee(!0);return}Z(!0),H(void 0);try{const pe=await o.createDocument({layout:j,...Ee!==void 0?{path:Ee}:{},document:{title:V,modelPath:P,source:X.source,view:X.view},target:x,...k?{onEvent:k}:{}});w(pe)}catch(pe){const st=pe.response?.data?.message;H(st??(pe instanceof Error?pe.message:String(pe)))}finally{Z(!1)}}},ut=pe=>n.jsx(S.Button,{color:"inherit",size:"small",onClick:pe,children:"Retry"});return n.jsx(o.AppDialog,{open:e,onClose:te?()=>{}:C,title:`New ${We}`,description:"A report is a Malloy file in the package that lays out text and queries, as a grid or top to bottom. Pick what its first query shows; the rest is the builder.",actions:n.jsxs(n.Fragment,{children:[n.jsx(S.Button,{onClick:C,disabled:te,children:"Cancel"}),n.jsx(S.Tooltip,{title:te?"":ye??"",children:n.jsx("span",{children:n.jsx(S.Button,{variant:"contained",disabled:te||ye!==void 0,"aria-label":!te&&ye!==void 0?`${ct}: ${ye}`:ct,onClick:()=>void Ze(),children:ct})})})]}),children:n.jsxs(S.Stack,{sx:{gap:2,pt:1},children:[J?n.jsx(S.Alert,{severity:"error",action:v&&qo.canRetryRequest(g)?ut(v):void 0,children:"Couldn't read this package's models, so no view is listed to start from."}):p.length===0?!h&&n.jsxs(S.Alert,{severity:"info",children:["This package has no models yet. Add a .malloy file that declares a source with a view, then create a ",We," from it."]}):oe.length>0?n.jsxs(S.Alert,{severity:"warning",action:Ne?ut(le):void 0,children:["Couldn't read ",oe.join(", "),", so"," ",oe.length===1?"its":"their"," views aren't listed."]}):$e&&se.size===0&&n.jsxs(S.Alert,{severity:"info",children:["A ",We," starts from a view of a source, and no model in this package declares one yet. Add a view to a source in a model file and this list fills in."]}),M&&n.jsx(S.TextField,{select:!0,size:"small",label:"Layout",value:j,disabled:te,onChange:pe=>E(pe.target.value),inputProps:{"aria-label":"Layout"},helperText:"Switch it any time in the builder.",children:["linear","grid"].map(pe=>n.jsx(S.MenuItem,{value:pe,children:Od[pe]},pe))}),n.jsx(S.TextField,{select:!0,size:"small",label:"Model",value:se.has(P)?P:"",disabled:se.size===0||te,onChange:pe=>{K(pe.target.value),L("")},inputProps:{"aria-label":"Model"},helperText:ie?"Reading the package's models…":se.size===1?"The only model with a view to start from.":"Models with a view to start from.",children:[...se.keys()].map(pe=>n.jsx(S.MenuItem,{value:pe,children:pe},pe))}),n.jsx(S.TextField,{select:!0,size:"small",label:Nt,value:X?A:"",disabled:q.length===0||te,onChange:pe=>L(pe.target.value),inputProps:{"aria-label":Nt},error:gt,helperText:gt?"The view you picked is no longer in this model; pick another.":q.length===1?"The only view this model offers; more are added in the builder.":"A view of a source; more are added in the builder.",children:q.map(pe=>n.jsxs(S.MenuItem,{value:`${pe.source}::${pe.view}`,children:[pe.source," → ",pe.view]},`${pe.source}::${pe.view}`))}),n.jsx(S.TextField,{size:"small",label:"Title",value:V,disabled:te,onChange:pe=>{Q(!0),N(pe.target.value)},inputProps:{"aria-label":"Report title"},error:Ye,helperText:Ye?Fe:x.route==="package"?"Names the file too, unless you type a location.":y??`Saved as a new ${We} in the host's store, and opened in the builder.`}),n.jsx(S.TextField,{size:"small",label:"Location",value:$??ge??"",placeholder:"report.malloy",disabled:te,onChange:pe=>U(pe.target.value),inputProps:{"aria-label":"Location"},error:Te!==void 0,helperText:Te??(we?`Written as ${we} in the package, and opened in the builder.`:"A path in the package; the package root by default.")}),ae&&n.jsx(S.Alert,{severity:"error",children:ae})]})})}const Md=o.createSvgIcon(n.jsx("path",{d:"M21 11h-1.5v-.5h-2v3h2V13H21v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1zM8 10v5H6.5v-1.5h-2V15H3v-5c0-.55.45-1 1-1h3c.55 0 1 .45 1 1m-1.5.5h-2V12h2zm7 1.5c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1h-4V9h4c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1M11 10.5v.75h2v-.75zm2 2.25h-2v.75h2z"})),jd=o.createSvgIcon(n.jsx("path",{d:"M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 18H4V10h16zm0-13H4V5h16z"})),Dd=o.createSvgIcon(n.jsx("path",{d:"M15 4v2h3v12h-3v2h5V4zM4 20h5v-2H6V6h3V4H4z"})),Ed=o.createSvgIcon(n.jsx("path",{d:"M4 7v2c0 .55-.45 1-1 1H2v4h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h3v-2H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h3V4H7C5.35 4 4 5.35 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-3v2h3c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-3v2h3c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-4z"})),Id=o.createSvgIcon(n.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"})),Nd=o.createSvgIcon(n.jsx("path",{d:"M20 10V8h-4V4h-2v4h-4V4H8v4H4v2h4v4H4v2h4v4h2v-4h4v4h2v-4h4v-2h-4v-4zm-6 4h-4v-4h4z"})),Fd=o.createSvgIcon(n.jsx("path",{d:"M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6m0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4m0-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"})),Ad=o.createSvgIcon(n.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33V7h3.33zM19 17h-3.33V7H19z"})),wa={dashboard:B.PALETTE.blue,report:B.PALETTE.violet,model:B.PALETTE.cyan,dataApp:B.PALETTE.pink,data:B.PALETTE.lime,materialization:B.PALETTE.amber};function Ca({type:e,size:r=18,sx:u,...s}){return n.jsx(o.SvgIcon,{...s,viewBox:"0 0 24 24",sx:{width:r,height:r,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...u},children:Rd[e]()})}const Rd={report:$d,model:Pd,data:Ld,materialization:_d,dataApp:qd,dashboard:Wd};function $d(){return n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M14 3 H6 a2 2 0 0 0 -2 2 v14 a2 2 0 0 0 2 2 h12 a2 2 0 0 0 2 -2 V9 z"}),n.jsx("path",{d:"M14 3 v4 a2 2 0 0 0 2 2 h4"}),n.jsx("path",{d:"M8 17 v-3"}),n.jsx("path",{d:"M12 17 v-6"}),n.jsx("path",{d:"M16 17 v-4"})]})}function Pd(){return n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3 L4 7 v10 l8 4 l8 -4 V7 z"}),n.jsx("path",{d:"M4 7 l8 4 l8 -4"}),n.jsx("path",{d:"M12 11 v10"})]})}function Ld(){return n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),n.jsx("path",{d:"M3.5 9.5 H20.5"}),n.jsx("path",{d:"M9.5 3.5 V20.5"})]})}function _d(){return n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3 L21 7.5 L12 12 L3 7.5 Z"}),n.jsx("path",{d:"M3 12 L12 16.5 L21 12"}),n.jsx("path",{d:"M3 16.5 L12 21 L21 16.5"})]})}function Wd(){return n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),n.jsx("path",{d:"M3.5 9.5 H20.5"}),n.jsx("path",{d:"M12 9.5 V20.5"}),n.jsx("path",{d:"M12 15 H20.5"})]})}function qd(){return n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2"}),n.jsx("path",{d:"M3.5 9.5 H20.5"}),n.jsx("path",{d:"M7 13.5 H17"}),n.jsx("path",{d:"M7 16.5 H13"})]})}function ka(e){return e>=1e9?`${(e/1e9).toFixed(1)} B rows`:e>=1e6?`${(e/1e6).toFixed(1)} M rows`:e>=1e3?`${(e/1e3).toFixed(1)} K rows`:`${e} rows`}const zd=12;function Hd(e){const r=e?.trim().toLowerCase()??"";if(r.startsWith("array")||r.endsWith("[]"))return Dd;if(r.startsWith("record")||r.startsWith("struct"))return Ed;switch(r.split(/[\s(<]/)[0]){case"string":return Md;case"number":return Nd;case"date":return jd;case"timestamp":case"timestamptz":return Id;case"boolean":return Fd;default:return Ad}}function Vd({column:e}){const r=Hd(e.type);return n.jsxs(S.Box,{component:"li",sx:u=>({display:"flex",alignItems:"center",gap:1.25,px:1,py:.625,borderRadius:1,transition:"background-color 0.1s","&:hover":{backgroundColor:u.palette.mode==="dark"?"rgba(255, 255, 255, 0.06)":u.palette.grey[100]}}),children:[n.jsx(r,{"aria-hidden":!0,sx:{fontSize:18,color:"primary.main",flexShrink:0}}),n.jsxs(S.Box,{sx:{display:"flex",alignItems:"baseline",gap:1,minWidth:0,flex:1},children:[n.jsx(S.Typography,{component:"span",sx:{fontFamily:B.MONO_FONT_FAMILY,fontSize:"0.8125rem",fontWeight:500,color:"text.primary",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),e.type&&n.jsx(S.Typography,{component:"span",variant:"caption",color:"text.secondary",sx:{flexShrink:0,maxWidth:"50%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.type})]})]})}function Bd({database:e,onClose:r}){const u=e!==null,[s,d]=I.useState(e);e!==null&&e!==s&&d(e);const[c,l]=I.useState(""),[m,p]=I.useState(s?.path);m!==s?.path&&(p(s?.path),l(""));const h=I.useId(),g=s?.path??"",v=g.split("/").pop()||g,x=g.slice(0,Math.max(0,g.length-v.length-1)),y=s?.info?.rowCount,C=[x,y===void 0?null:ka(y)].filter(Boolean).join(" · "),w=I.useMemo(()=>s?.info?.columns??[],[s]),k=c.trim().toLowerCase(),O=I.useMemo(()=>k?w.filter(M=>M.name?.toLowerCase().includes(k)||M.type?.toLowerCase().includes(k)):w,[w,k]);return n.jsxs(o.AppDialog,{open:u,onClose:r,showClose:!0,title:n.jsxs(S.Stack,{direction:"row",alignItems:"center",spacing:1.5,sx:{minWidth:0},children:[n.jsx(S.Box,{"aria-hidden":!0,sx:{width:32,height:32,borderRadius:1,bgcolor:wa.data,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n.jsx(Ca,{type:"data",size:18})}),n.jsxs(S.Box,{sx:{minWidth:0},children:[n.jsx(S.Typography,{component:"span",noWrap:!0,title:g,sx:{display:"block",fontFamily:B.MONO_FONT_FAMILY,fontSize:"1rem",fontWeight:600,letterSpacing:0,lineHeight:1.4},children:v||"Columns"}),C&&n.jsx(S.Typography,{component:"span",variant:"caption",color:"text.secondary",noWrap:!0,sx:{display:"block",lineHeight:1.4},children:C})]})]}),children:[s?.error&&n.jsx(S.Alert,{severity:"error",variant:"outlined",children:s.error}),s&&!s.error&&n.jsxs(S.Box,{component:"section","aria-labelledby":h,sx:{display:"flex",flexDirection:"column",border:"1px solid",borderColor:"divider",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",mb:2},children:[n.jsxs(S.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{px:1.5,py:1,minHeight:44,borderBottom:"1px solid",borderColor:"divider"},children:[n.jsxs(S.Typography,{id:h,component:"h3",sx:{fontSize:"0.875rem",fontWeight:600},children:["Columns",n.jsxs(S.Typography,{component:"span",variant:"caption",color:"text.secondary",sx:{ml:.75,fontVariantNumeric:"tabular-nums"},children:["· ",k?`${O.length} of `:"",w.length]})]}),w.length>zd&&n.jsx(S.InputBase,{value:c,onChange:M=>l(M.target.value),placeholder:"Filter columns",inputProps:{"aria-label":"Filter columns"},startAdornment:n.jsx(S.InputAdornment,{position:"start",children:n.jsx(nr,{sx:{fontSize:16,color:"text.secondary"}})}),sx:{ml:"auto !important",width:200,fontSize:"0.8125rem",px:1,py:.25,border:"1px solid",borderColor:"divider",borderRadius:1.5,"&.Mui-focused":{borderColor:"primary.main"}}})]}),n.jsx(S.Box,{sx:{overflowY:"auto",maxHeight:420,px:.75,py:.75},children:O.length===0?n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic",px:1,py:1},children:k?"No columns match":"No columns"}):n.jsx(S.Box,{component:"ul","aria-labelledby":h,sx:{listStyle:"none",m:0,p:0},children:O.map((M,j)=>n.jsx(Vd,{column:M},`${M.name}-${j}`))})})]})]})}const Ud="README.malloynb",Gd=e=>!!e&&!e.includes("/")&&o.documentSlug(e)?.toLowerCase()==="readme";function Yd({onClickPackageFile:e,onOpenDocument:r,resourceUri:u,onEvent:s}){const{apiClients:d,server:c,mutable:l}=B.useServer(),m=Sr.useQueryClient(),p=e??(q=>{window.location.href=q}),{environmentName:h,packageName:g,versionId:v}=o.parseResourceUri(u),x=r??((q,X)=>{const ge=q.mode==="edit"?o.reportEditRoute(h,g,q.path):o.reportRoute(h,g,q.path);X?p(ge,X):p(ge)}),[y,C]=I.useState(null),[w,k]=I.useState(!1),O=Ho(),M=o.useOptionalDocumentStorage()?.documentStorage,[j,E]=I.useState([]),[$,U]=I.useState({state:M?"pending":"ready"}),P=I.useCallback(async()=>{if(!M)return;let q;try{q=await M.listWorkspaces(!1)}catch{U({state:"failed"});return}U({state:"ready",chosen:o.chooseWorkspace(q)});const X=[],ge=o.draftKey(h,g,"");for(const Se of q.filter(Ee=>Ee.writeable))for(const Ee of await M.listDocuments(Se))Ee.path.startsWith(ge)&&X.push({locator:Ee,where:Se.description});E(X)},[M,h,g]);I.useEffect(()=>{P()},[P]);const K=q=>q.path.slice(o.draftKey(h,g,"").length),A=o.useQueryWithApiError({queryKey:["package",h,g,v],queryFn:()=>d.packages.getPackage(h,g,v,!1)}),L=o.useReportListing(h,g,v),V=o.useQueryWithApiError({queryKey:["models",h,g,v],queryFn:()=>d.models.listModels(h,g,v)}),N=o.useQueryWithApiError({queryKey:["databases",h,g,v],queryFn:()=>d.databases.listDatabases(h,g,v)}),Q=o.useQueryWithApiError({queryKey:["data-apps",h,g],queryFn:async()=>{try{return await d.dataApps.listDataApps(h,g)}catch(q){const X=q?.response?.status;if(X===404||X===void 0)return{data:[]};throw q}}}).data?.data??[],re=L.reports.filter(q=>!!q.path),ee=Zd(re),te=new Set(re.map(q=>q.path).filter(q=>q!==void 0)),Z=(V.data?.data??[]).slice().filter(q=>!te.has(q.path)).sort((q,X)=>q.path.localeCompare(X.path)),ae=(N.data?.data??[]).slice().sort((q,X)=>q.path.localeCompare(X.path)),H=$.state==="ready"?o.createRoute({authoritative:$.chosen?.authoritative===!0,mutable:l,canStore:$.chosen?.writeable===!0,...v===void 0?{}:{versionId:v}}):void 0,J=L.settled&&(V.isSuccess||V.isError),se=H!==void 0&&J,xe=se&&!O,$e=I.useMemo(()=>{if(!se)return;const q=[...L.reports.flatMap(X=>X.path?[X.path]:[]),...(V.data?.data??[]).flatMap(X=>X.path?[X.path]:[])];if(H==="storage"&&M&&$.state==="ready")return $.chosen?{route:H,storage:M,workspace:$.chosen,environmentName:h,packageName:g,existing:q}:void 0;if(H==="package")return{route:H,existing:q,write:async(X,ge)=>{await d.models.updateModelSource(h,g,X,{source:ge})}}},[se,H,M,$,h,g,d,L.reports,V.data]),oe=A.data?.data?.description??"",le=(re.find(q=>q.path===Ud)??re.find(q=>Gd(q.path)))?.path,Ne=!L.settled;return A.isError?n.jsx(o.ApiErrorDisplay,{error:A.error,context:`${h} > ${g}`}):n.jsxs(S.Container,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[n.jsxs(S.Box,{sx:{mb:4},children:[n.jsx(S.Typography,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:g}),oe&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:oe})]}),Ne&&n.jsx(o.Loading,{text:"Loading package..."}),$e&&n.jsx(Sa,{open:w,layout:"linear",environmentName:h,packageName:g,...v!==void 0?{versionId:v}:{},models:Z.map(q=>q.path).filter(q=>typeof q=="string"&&q.endsWith(".malloy")&&!te.has(q)),modelsLoading:V.isPending,...V.isError?{modelsError:V.error}:{},onRetryModels:()=>void V.refetch(),target:$e,...s?{onEvent:s}:{},onClose:()=>k(!1),onCreated:q=>{k(!1),o.invalidateReportQueries(m,h,g),m.invalidateQueries({queryKey:["models"]}),x({path:q.path,layout:q.layout,slug:q.slug,mode:"edit"})}}),!Ne&&n.jsxs(n.Fragment,{children:[L.isError&&n.jsx(S.Box,{sx:{mb:4},children:n.jsx(S.Alert,{severity:"warning",action:n.jsx(S.Button,{color:"inherit",size:"small",onClick:()=>void L.refetch(),children:"Retry"}),children:"Could not list this package's reports, so any it has are missing from this page."})}),(ee.length>0||se)&&n.jsxs(It,{title:"Reports",count:ee.length,...xe?{action:n.jsx(S.Button,{variant:"outlined",size:"small",onClick:()=>k(!0),children:"New report"})}:{},children:[ee.length===0&&n.jsx(Gr,{label:"No reports yet",...xe?{action:{label:"New report",onClick:()=>k(!0)}}:{}}),ee.map(q=>n.jsx(Yn,{type:q.layout==="grid"?"dashboard":"report",label:q.label,rightLabel:q.layout,...q.secondary===void 0?{}:{description:q.secondary},onClick:X=>q.path.endsWith(".malloynb")?p(`/${h}/${g}/${q.path}`,X):x({path:q.path,layout:q.layout,slug:q.slug,mode:"view"},X)},q.path))]}),j.length>0&&n.jsx(It,{title:"Drafts",count:j.length,children:j.map(({locator:q,where:X})=>n.jsx(Yn,{type:q.type==="grid"?"dashboard":"report",label:K(q),rightLabel:X,onClick:ge=>x({path:K(q),layout:q.type,slug:o.documentSlug(K(q))??"",mode:"edit"},ge),trailingAction:n.jsx(S.Tooltip,{title:"Delete this draft",children:n.jsx(S.IconButton,{size:"small","aria-label":`Delete draft ${K(q)}`,onClick:ge=>{ge.stopPropagation(),M?.deleteDocument(q).then(P)},children:n.jsx(o.DeleteOutlineIcon,{fontSize:"small"})})})},`${q.workspace}:${q.path}`))}),Q.length>0&&n.jsx(It,{title:"Apps",count:Q.length,children:Q.map(q=>{const X=!!q.title&&q.title!==q.path,ge=`${Uo(c)}${q.resource}`;return n.jsx(Yn,{type:"dataApp",label:X?q.title:q.path,rightLabel:X?q.path:void 0,onClick:Se=>{e?e(`/${h}/${g}/data-apps/${q.path}`,Se):Se&&(Se.metaKey||Se.ctrlKey)?window.open(ge,"_blank"):window.location.href=ge},trailingAction:n.jsx(S.Tooltip,{title:"Open standalone in new tab",children:n.jsx(S.IconButton,{size:"small",href:ge,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",onClick:Se=>Se.stopPropagation(),sx:{color:"text.secondary"},children:n.jsx(Bo,{fontSize:"small"})})})},q.path)})}),n.jsxs(It,{title:"Models",count:Z.length,children:[Z.map(q=>n.jsx(Yn,{type:"model",label:q.path,onClick:X=>p(`/${h}/${g}/${q.path}`,X)},q.path)),Z.length===0&&n.jsx(Gr,{label:"No models"})]}),n.jsxs(It,{title:"Data",count:ae.length,children:[ae.map(q=>n.jsx(Yn,{type:"data",label:q.path,rightLabel:q.info?ka(q.info.rowCount):"Unreadable",onClick:()=>C(q)},q.path)),ae.length===0&&n.jsx(Gr,{label:"No data files"})]}),n.jsx(da,{resourceUri:u}),le&&n.jsx(S.Box,{sx:{mt:6},children:n.jsx(va,{resourceUri:o.encodeResourceUri({environmentName:h,packageName:g,versionId:v}),path:le,onLinkNavigate:p})})]}),n.jsx(Bd,{database:y,onClose:()=>C(null)})]})}function Yn({type:e,label:r,description:u,rightLabel:s,onClick:d,trailingAction:c}){return n.jsx(wr,{icon:n.jsx(Ca,{type:e}),tint:wa[e],label:r,mono:!0,...u===void 0?{}:{description:u},...s===void 0?{}:{rightLabel:s},...d===void 0?{}:{onClick:d},...c===void 0?{}:{trailingAction:c}})}function Zd(e){const r=e.map(s=>({path:s.path??"",layout:o.listedLayout(s),slug:o.documentSlug(s.path)??s.path??"",title:s.title})),u=new Map;for(const s of r)u.set(s.slug,(u.get(s.slug)??0)+1);return r.map(({title:s,...d})=>{const c=!!s&&s!==d.slug&&s!==d.path,l=(u.get(d.slug)??0)>1,m=c?s:d.path.endsWith(".malloynb")?d.path:d.slug;return{...d,label:m,secondary:m!==d.path&&(c||l||d.path.includes("/"))?d.path:void 0}}).sort((s,d)=>s.label.localeCompare(d.label)||s.path.localeCompare(d.path))}function Gr({label:e,action:r}){return n.jsxs(S.Stack,{direction:"row",sx:{alignItems:"center",gap:1,py:1},children:[n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:e}),r&&n.jsx(S.Button,{size:"small",onClick:r.onClick,children:r.label})]})}const Wo=/^publisher:document:(dashboard|notebook):(.+)$/;function Kd(e,r){const u=[];for(let s=0;s<e.length;s++){const d=e.key(s);d!==null&&Wo.test(d)&&u.push(d)}for(const s of u){const[,d,c]=Wo.exec(s),l=e.getItem(s);l!==null&&r(c,o.layoutOfKind(d),l)&&e.removeItem(s)}}const Yr={name:"Local",description:"Stored in this browser only",writeable:!0},ss="publisher:report:",Qt=e=>`${ss}${e}`;function Zn(e){const r=localStorage.getItem(e);if(r!==null)try{const u=JSON.parse(r);if(typeof u.content=="string"&&(u.type==="grid"||u.type==="linear"))return{type:u.type,content:u.content}}catch{}}const Zr=(e,r)=>localStorage.setItem(Qt(e),JSON.stringify(r));class Xd{migrated=!1;migrate(){this.migrated||(this.migrated=!0,Kd(localStorage,(r,u,s)=>Zn(Qt(r))!==void 0?!1:(Zr(r,{type:u,content:s}),!0)))}async listWorkspaces(r){return[Yr]}async listDocuments(r,u){if(r.name!==Yr.name)return[];this.migrate();const s=[];for(let d=0;d<localStorage.length;d++){const c=localStorage.key(d);if(c===null||!c.startsWith(ss))continue;const l=Zn(c);l&&(u===void 0||l.type===u)&&s.push({workspace:Yr.name,type:l.type,path:c.slice(ss.length)})}return s}async getDocument(r){this.migrate();const u=Zn(Qt(r.path));if(u===void 0)throw Kr(r);return u.content}async getDocumentType(r){this.migrate();const u=Zn(Qt(r.path));if(u===void 0)throw Kr(r);return u.type}async saveDocument(r,u){this.migrate(),Zr(r.path,{type:r.type,content:u})}async deleteDocument(r){if(this.migrate(),Zn(Qt(r.path))===void 0)throw Kr(r);localStorage.removeItem(Qt(r.path))}async moveDocument(r,u){const s=await this.getDocument(r);Zr(u.path,{type:u.type,content:s}),u.path!==r.path&&localStorage.removeItem(Qt(r.path))}}function Kr(e){return new o.DocumentNotFoundError(`No report at ${e.workspace}/${e.path}`)}async function Qd(e,r,u,s){const d=o.chooseWorkspace(await e.listWorkspaces(!1));if(!d)return;const c=o.draftKey(r,u,s);if(e.getDocumentType)try{return await e.getDocumentType({workspace:d.name,path:c})}catch(l){if(o.isDocumentNotFound(l))return;throw l}return(await e.listDocuments(d)).find(l=>l.path===c)?.type}function Jd(e,r,u,s=!0){const d=o.useOptionalDocumentStorage()?.documentStorage,c=s&&d!==void 0,[l,m]=I.useState(),p=o.draftKey(e,r,u);return I.useEffect(()=>{if(!c||!d)return;let h=!1;return Qd(d,e,r,u).catch(()=>{}).then(g=>{h||m({key:p,layout:g})}),()=>{h=!0}},[c,d,e,r,u,p]),c?l?.key===p?{layout:l.layout,settled:!0}:{layout:void 0,settled:!1}:{layout:void 0,settled:!0}}function Ta(e){const{environmentName:r,packageName:u}=o.parseResourceUri(e.resourceUri);if(!r||!u)throw new Error("Environment and Package name must be provided for query embedding.");return JSON.stringify({...e})}function eh({embeddedQueryResult:e}){const{query:r,sourceName:u,queryName:s,resourceUri:d,height:c}=JSON.parse(e),{modelPath:l}=o.parseResourceUri(d);if(!l||!r&&(!s||!u)||typeof l!="string")throw new Error("Invalid embedded query result: "+e);return n.jsx(Oa,{query:r,sourceName:u,queryName:s,resourceUri:d,height:c})}function Oa({query:e,sourceName:r,queryName:u,resourceUri:s,height:d=400}){const{modelPath:c,environmentName:l,packageName:m,versionId:p}=o.parseResourceUri(s);if(!l||!m)throw new Error("No environment or package name provided. A resource URI must be provided.");const h=o.useQueryResult({environmentName:l,packageName:m,modelPath:c,versionId:p,query:e,sourceName:r,queryName:u});return n.jsx(o.ResultPanel,{state:h,context:`${l} > ${m} > ${c}`,maxHeight:d})}function th({resourceUri:e,dashboard:r,givens:u,onGivensChange:s,onNavigate:d,height:c,maxResultSize:l,onEvent:m,chrome:p}){const h=o.parseResourceUri(e),{apiClients:g}=B.useServer(),v=h.environmentName??"",x=h.packageName??"",y=h.versionId,C=!!h.environmentName&&!!h.packageName,{data:w,isSuccess:k,isError:O,error:M}=o.useQueryWithApiError({queryKey:["dashboard",v,x,y,r],queryFn:()=>g.dashboards.getDashboard(v,x,r,y),enabled:C}),j=w?.data,E=o.useReportEmitter({path:j?.path??r,layout:"grid"},m);return C?O?n.jsx(o.ApiErrorDisplay,{context:`${v} > ${x} > ${r}`,error:M}):!k||!j?n.jsx(o.Loading,{text:o.LOADING_COPY.opening("report")}):n.jsx(o.ReportEventsContext.Provider,{value:E,children:n.jsx(o.DashboardView,{manifest:j,environmentName:v,packageName:x,versionId:y,documentName:r,givens:u,onGivensChange:s,onNavigate:d,height:c,maxResultSize:l,chrome:p})}):n.jsxs(S.Alert,{severity:"error",children:["A dashboard resource URI must name an environment and a package. Received: ",e]})}function Ma(e){const{apiClients:r}=B.useServer(),{environmentName:u,packageName:s,versionId:d,modelPath:c}=o.parseResourceUri(e);return o.useQueryWithApiError({queryKey:[e],queryFn:async()=>(await r.notebooks.getNotebook(u,s,c,d)).data})}function nh(e){const{apiClients:r}=B.useServer(),{environmentName:u,packageName:s,versionId:d,modelPath:c}=o.parseResourceUri(e.resourceUri),l=Ma(e.resourceUri),m=I.useCallback(async({index:p,givens:h,declaredTypes:g,signal:v})=>{const x=o.givensToRequest(h,g);return(await r.notebooks.executeNotebookCell(u,s,c,p,d,void 0,void 0,Object.keys(x).length>0?JSON.stringify(x):void 0,{signal:v})).data},[r.notebooks,u,s,c,d]);return n.jsx(xa,{...e,notebook:l.isSuccess?l.data:void 0,error:l.isError?l.error:void 0,runCell:m})}function rh(e){const{data:r}=Ma(e.resourceUri);if(r?.dashboard){const{environmentName:u,packageName:s,versionId:d,modelPath:c}=o.parseResourceUri(e.resourceUri);return n.jsx(ba,{manifest:r.dashboard,environmentName:u,packageName:s,versionId:d,documentName:c,givens:e.givens,onGivensChange:e.onGivensChange,onDrillNavigate:e.onDrillNavigate,maxResultSize:e.maxResultSize})}return n.jsx(nh,{...e})}function ja(e,r,u="grid"){const s=r.filter(c=>!!c.path).filter(c=>o.documentSlug(c.path)===e),d=s.filter(c=>o.listedLayout(c)===u);return d.length===1?{found:o.locatedReport(d[0])}:s.length===1?{found:o.locatedReport(s[0])}:s.length===0?{missing:!0}:{ambiguous:s.map(c=>c.path).sort()}}const sh=/^(dashboards|notebooks)\/([^/]+)$/;function oh(e){const r=sh.exec(e);if(r)return{name:r[2],prefer:r[1]==="dashboards"?"grid":"linear"}}const ah=(e,r,u,s)=>`/${e}/${r}/${u}s/${encodeURIComponent(s)}`;function ih({kind:e,slug:r,reports:u}){const s=ja(r,u,o.layoutOfKind(e));return"found"in s?s.found:void 0}function lh(e,r){return`${e}:${r}`}function Jt(e){return lh(e.source,e.filterName??e.dimensionName)}function jt(e,r=!1){return e==null?"null":r?e instanceof Date?`@${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`:`@${e}`:typeof e=="string"?`'${o.escapeMalloyString(e)}'`:typeof e=="number"?String(e):typeof e=="boolean"?e?"true":"false":String(e)}function ch(e){const{dimensionName:r,matchType:u,value:s,value2:d}=e,c=`\`${r}\``,l=s instanceof Date;switch(u){case"Equals":case"Semantic Search":return Array.isArray(s)&&s.length>0?`(${s.map(p=>`${c} = ${jt(p,l)}`).join(" or ")})`:Array.isArray(s)?"":`${c} = ${jt(s,l)}`;case"Contains":return typeof s=="string"?`${c} ~ f'%${o.escapeMalloyString(s)}%'`:Array.isArray(s)?"":`${c} = ${jt(s)}`;case"After":return Array.isArray(s)?"":`${c} > ${jt(s,l)}`;case"Before":return Array.isArray(s)?"":`${c} < ${jt(s,l)}`;case"Greater Than":return Array.isArray(s)?"":`${c} > ${jt(s)}`;case"Less Than":return Array.isArray(s)?"":`${c} < ${jt(s)}`;case"Between":return Array.isArray(s)?"":d!==void 0?`${c} >= ${jt(s,l)} and ${c} <= ${jt(d,l)}`:`${c} >= ${jt(s,l)}`;default:return""}}function uh(e){const r=new Map;for(const u of e){const s=`${u.source}|${u.model}`,d=r.get(s)||[];d.push(u),r.set(s,d)}return r}function dh(e,r,u,s){const d=r.filter(h=>(h.filterType==="Star"||h.filterType==="MinMax"||h.filterType==="DateMinMax")&&!h.values);if(d.length===0)return"";const l=[...new Set(d.map(h=>h.dimensionName))].map(h=>`\`${h}\``).join(", "),m=s?.filter(h=>h.source===e)||[],p=m.length>0?m.map(h=>ch(h)).filter(h=>h.length>0).join(" and "):"";return`
|
|
11
|
+
`)[e.codeLine]??"").trim():ps(e).map(d=>d.trim()).find(d=>d&&!d.startsWith("#")&&!d.startsWith("//"))??"",u=/^(source|query|given|type):?\s+([A-Za-z_]\w*)/.exec(r);if(u)return`${u[1]}: ${u[2]}`;const s=/^(import|export)\b/.exec(r);return s?s[1]:r}const xd=o.createSvgIcon(n.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),bd=o.createSvgIcon(n.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"})),vd=o.createSvgIcon(n.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}));function Sd({cell:e,resourceUri:r,showCopyLink:u,maxResultSize:s,isExecuting:d,pendingRerun:c,onNavigate:l,onDrillSelf:m,canDrillSelf:p,onDrillNavigate:h,givens:g,givenSpecs:v}){const[x,y]=I.useState(!1),[C,w]=I.useState(!1),[k,O]=I.useState(),[M,j]=I.useState(!1),[E,R]=I.useState(!1),U=I.useId(),[P,K]=I.useState(""),{environmentName:A,packageName:L,modelPath:V}=o.parseResourceUri(r),N={environmentName:A,packageName:L,sourcePath:V,onNavigate:l},{drill:W,drillMenu:X}=o.useDrill({onNavigate:h,onSelf:m,canSelf:p,selfLabel:"Filter this report"}),ne=/import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/,J=/import\s*(?:\{[^}]*\}\s*from\s*)?['"`]([^'"`]+)['"`]/,ee=!!e.text&&(ne.test(e.text)||J.test(e.text)),Z=()=>{if(!e.newSources||e.newSources.length===0)return 0;let se=[],ie="";if(e.text){const Ne=e.text.match(ne);Ne&&(se=Ne[1].split(",").map(_=>_.trim()));const xe=e.text.match(J);xe&&(ie=xe[1].trim())}for(let Ne=0;Ne<e.newSources.length;Ne++)try{const xe=JSON.parse(e.newSources[Ne]);if(se.length>0&&se.includes(xe.name)||ie&&ie===xe.path)return Ne}catch{continue}return 0},ae=I.useMemo(()=>e.newSources&&e.newSources.length>0?{sourceInfos:e.newSources,resource:r,givens:v}:void 0,[e.newSources,r,v]),{mode:H}=B.usePublisherTheme();I.useEffect(()=>{e.type==="code"&&fa(gd(e),"malloy",H).then(se=>{O(se)})},[e,H]);const Q=e.kind==="query"?md(e):void 0,re=e.markdown?n.jsx(o.Prose,{variant:"document",links:N,children:e.markdown}):null,ve=()=>{const se=window.location.href;navigator.clipboard.writeText(se).then(()=>K("URL copied to clipboard!")).catch(()=>K("Failed to copy URL"))},Re=n.jsx(o.AppDialog,{open:x,onClose:()=>y(!1),title:"Malloy code",maxWidth:"lg",showClose:!0,children:n.jsx(S.Box,{sx:se=>({border:`1px solid ${se.palette.divider}`,borderRadius:"8px",padding:"16px",fontFamily:B.MONO_FONT_FAMILY,fontSize:"14px",lineHeight:"1.5",overflow:"auto",maxHeight:"70vh",backgroundColor:se.palette.background.paper,color:se.palette.text.primary}),children:n.jsx("pre",{className:"code-display",style:{margin:0},dangerouslySetInnerHTML:{__html:k}})})});return e.type==="markdown"&&n.jsx(S.Box,{children:n.jsxs(S.Box,{children:[u?n.jsxs(S.Stack,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[n.jsx(o.Prose,{variant:"document",links:N,children:e.text}),n.jsx(S.Tooltip,{title:"Copy link",children:n.jsx(S.IconButton,{"aria-label":"Copy link",onClick:ve,sx:{color:"text.secondary",mt:"18px"},children:n.jsx(ha,{sx:{fontSize:"24px"}})})})]}):n.jsx(o.Prose,{variant:"document",links:N,children:e.text}),n.jsx(S.Snackbar,{open:P!=="",autoHideDuration:6e3,onClose:()=>K(""),message:P})]})})||e.kind==="definition"&&n.jsxs(S.Box,{children:[re,n.jsxs(S.Box,{component:"button",type:"button","aria-expanded":E,"aria-controls":U,onClick:()=>R(se=>!se),sx:{display:"flex",alignItems:"center",gap:"4px",p:0,border:0,background:"none",cursor:"pointer",fontFamily:B.MONO_FONT_FAMILY,fontSize:"13px",color:"text.secondary"},children:[E?n.jsx(bd,{fontSize:"small"}):n.jsx(xd,{fontSize:"small"}),yd(e)]}),E&&n.jsx(B.CleanMetricCard,{id:U,sx:{mt:1,padding:"12px 24px"},children:n.jsx("pre",{className:"code-display",style:{margin:0,overflow:"auto"},dangerouslySetInnerHTML:{__html:k??""}})})]})||e.type==="code"&&n.jsxs(S.Box,{children:[re,Q&&n.jsx(S.Typography,{variant:"body2",sx:{color:"text.secondary",mb:1},children:Q}),e.newSources&&e.newSources.length>0&&n.jsx(S.Stack,{sx:{flexDirection:"column",gap:"8px",marginBottom:"2px"},children:n.jsx(B.CleanMetricCard,{sx:{position:"relative",padding:"0"},children:n.jsxs(S.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"24px",paddingRight:"8px"},children:[k&&n.jsx("span",{dangerouslySetInnerHTML:{__html:k},style:{fontFamily:B.MONO_FONT_FAMILY,fontSize:"14px",flex:1,marginRight:"8px"}}),ee&&n.jsx(o.FloatingIconButton,{"aria-label":"Data sources",sx:{flexShrink:0},onClick:()=>j(!0),children:n.jsx(nr,{})})]})})}),n.jsx(fs,{open:M,onClose:()=>j(!1),title:"Data Sources",hasValidImport:ee,resourceUri:r,data:ae,initialSelectedSourceIndex:Z(),startingGivens:g}),Re,n.jsx(pa,{open:C,onClose:()=>w(!1),result:e.result||"",title:"Results",drill:W}),d&&!e.result&&!e.error&&!ee&&!(e.newSources&&e.newSources.length>0)&&n.jsx(B.CleanMetricCard,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:n.jsx(S.CircularProgress,{size:32})}),!e.result&&e.error&&n.jsx(o.ErrorDetailAlert,{summary:"This cell could not be run.",detail:e.error}),e.result&&c&&n.jsx(S.LinearProgress,{"aria-label":"Re-run pending",sx:{mb:1,height:2,borderRadius:1}}),e.result&&n.jsxs(B.CleanMetricCard,{sx:{position:"relative"},children:[n.jsx(S.Box,{sx:{paddingTop:"24px"},children:n.jsx(o.ResultContainer,{result:e.result,maxHeight:o.NOTEBOOK_CELL_MAX_HEIGHT,maxResultSize:s,drill:W})}),X,n.jsxs(S.Stack,{sx:{position:"absolute",top:"-12px",right:"8px",flexDirection:"row",gap:"8px",alignItems:"center",zIndex:2},children:[n.jsx(o.FloatingIconButton,{"aria-label":"Malloy code",onClick:se=>{se.stopPropagation(),y(!0)},children:n.jsx(vd,{})}),n.jsx(o.FloatingIconButton,{"aria-label":"Expand results",onClick:()=>w(!0),children:n.jsx(nr,{})})]})]})]})}function wd({ready:e,lastRunKey:r,pendingKey:u,runKey:s,documentKey:d}){if(!e)return{cancelPending:u!==void 0,dispatch:"none"};const c=u!==void 0&&u!==s;if(r===s)return{cancelPending:c,dispatch:"none"};if(u===s)return{cancelPending:c,dispatch:"none"};const l=r===null||!r.startsWith(`${d}|`);return{cancelPending:c,dispatch:l?"now":"settle"}}const Cd=4;function kd(e){const r=e?.response?.data?.message;return typeof r=="string"&&r!==""?r:e instanceof Error&&e.message!==""?e.message:"The server did not say why."}function xa({resourceUri:e,maxResultSize:r=0,givens:u,onGivensChange:s,onNavigate:d,onDrillNavigate:c,notebook:l,error:m,runCell:p}){const{environmentName:h,packageName:g,versionId:v,modelPath:x}=o.parseResourceUri(e),y=l!==void 0,C=!y&&!!m,[w,k]=I.useState([]),[O,M]=I.useState(!1),[j,E]=I.useState(!1),R=I.useRef(void 0),[U,P]=I.useState(null),K=ga(l),A=l?.autorun!==!1,L=o.useReportEvents(),V=o.useDocumentControls({specs:K,loaded:y,startingValues:l?.startingGivens,params:u,onGivensChange:s,documentKey:e,autorun:A,environmentName:h,packageName:g,modelPath:x,versionId:v,documentName:x}),{applied:N,declaredTypes:W,canSelf:X,onSelf:ne}=V,J=I.useCallback(xe=>{const _=o.givensToRequest(xe,W);return Object.keys(_).length>0?JSON.stringify(_):void 0},[W]),ee=I.useMemo(()=>o.givensToParams(N,W),[N,W]),Z=I.useRef(0),ae=I.useRef(null),H=I.useRef(null),Q=I.useRef(void 0);I.useEffect(()=>()=>{ae.current?.abort(),H.current=null,clearTimeout(Q.current?.timer),Q.current=void 0},[]);const re=I.useCallback(async(xe=new Map)=>{if(!y||!l?.notebookCells)return;const _=++Z.current;ae.current?.abort();const oe=new AbortController;ae.current=oe,k(l.notebookCells.map(ge=>({...ge}))),M(!0),P(null);try{const ge=[];for(let be=0;be<l.notebookCells.length;be++){const Oe=l.notebookCells[be];if(!pd(Oe))continue;const $e=be,Fe=async()=>{try{const Ye=await p({cell:Oe,index:$e,givens:xe,declaredTypes:W,signal:oe.signal});if(Z.current!==_)return;const le=Ye.result,Qe=Oe.newSources||Ye.newSources;k(ye=>{const We=[...ye];return We[$e]||(We[$e]={...Oe}),We[$e]={...We[$e],result:le,newSources:Qe},We})}catch(Ye){if(oe.signal.aborted||Z.current!==_)return;L.emit({type:"report.query_failed",tile:$e,category:o.failureCategory(Ye)}),L.listening||console.error(`Error executing cell ${$e}:`,Ye);const le=kd(Ye);k(Qe=>{const ye=[...Qe];return ye[$e]||(ye[$e]={...Oe}),ye[$e]={...ye[$e],error:le},ye})}};ge.push(Fe)}const Te=[];for(const be of ge){const Oe=be().then(()=>{Te.splice(Te.indexOf(Oe),1)});Te.push(Oe),Te.length>=Cd&&await Promise.race(Te)}await Promise.all(Te)}catch(ge){if(oe.signal.aborted||Z.current!==_)return;L.emit({type:"report.query_failed",category:o.failureCategory(ge)}),L.listening||console.error("Error executing notebook cells:",ge),P(ge)}finally{Z.current===_&&(M(!1),ae.current=null)}},[y,l,W,p,L]),ve=I.useRef(0),Re=I.useRef(void 0);Re.current!==l&&(Re.current=l,ve.current+=1);const se=ve.current;I.useEffect(()=>{const xe=`${e}|${se}`,_=`${xe}|${J(N)??""}`;R.current!==void 0&&R.current!==xe&&(ae.current?.abort(),ae.current=null),R.current=xe;const oe=wd({ready:y&&!!l?.notebookCells,lastRunKey:H.current,pendingKey:Q.current?.key,runKey:_,documentKey:xe});if(oe.cancelPending&&(clearTimeout(Q.current?.timer),Q.current=void 0,E(!1)),oe.dispatch==="none")return;const ge=()=>{Q.current=void 0,E(!1),H.current=_,re(N)};if(oe.dispatch==="now"){ge();return}E(!0),Q.current={key:_,timer:setTimeout(ge,fd)}},[y,l,se,e,N,J,re]);const ie=w.length>0?w:l?.notebookCells||[],Ne=l?.format==="malloy"?ie.findIndex(xe=>xe.type==="markdown"):0;return n.jsx(B.CleanNotebookContainer,{children:n.jsx(B.CleanNotebookSection,{children:n.jsxs(S.Stack,{spacing:3,component:"section",children:[n.jsx(o.GivensPanel,{...V.panel}),!y&&!C&&n.jsx(o.Loading,{text:o.LOADING_COPY.opening("report")}),y&&ie.map((xe,_)=>n.jsx(Sd,{cell:xe,showCopyLink:_===Ne,resourceUri:e,maxResultSize:r,isExecuting:O,givens:ee,givenSpecs:K,pendingRerun:j,onNavigate:d,onDrillNavigate:c,onDrillSelf:K.length>0?ne:void 0,canDrillSelf:X},_)),C&&m?.status===404&&n.jsxs(S.Typography,{variant:"body2",sx:{color:"text.secondary"},children:[n.jsx("code",{children:`${h} > ${g} > ${x}`})," ","not found."]}),C&&m?.status!==404&&n.jsx(o.ApiErrorDisplay,{error:m,context:`${h} > ${g} > ${x}`}),U&&n.jsx(o.ApiErrorDisplay,{error:{message:U.message,status:500,name:"ExecutionError"},context:"Notebook Execution"})]})})})}function Td({notebook:e,...r}){const{apiClients:u}=B.useServer(),{environmentName:s,packageName:d,versionId:c,modelPath:l}=o.parseResourceUri(r.resourceUri),[m,p]=I.useState(!1);I.useEffect(()=>p(!0),[]);const h=I.useCallback(async({cell:g,givens:v,declaredTypes:x,signal:y})=>({result:(await u.models.executeQueryModel(s,d,l,{query:g.text,givens:o.givensToRequest(v,x),versionId:c},void 0,{signal:y})).data.result}),[u.models,s,d,l,c]);return n.jsx(xa,{...r,notebook:m?e:void 0,runCell:h})}function ba({manifest:e,environmentName:r,packageName:u,versionId:s,documentName:d,givens:c,onGivensChange:l,onDrillNavigate:m,maxResultSize:p}){const{title:h,description:g}=e;return n.jsx(B.CleanNotebookContainer,{children:n.jsxs(B.CleanNotebookSection,{children:[(h||g)&&n.jsx(S.Box,{sx:{mb:2},children:n.jsx(o.DashboardProse,{chrome:"none",title:h??"",...g?{description:g}:{}})}),n.jsx(o.DashboardView,{manifest:e,environmentName:r,packageName:u,versionId:s,documentName:d,givens:c,onGivensChange:l,onNavigate:m,maxResultSize:p,chrome:"none",controlsLayout:"panel"})]})})}function va({resourceUri:e,path:r,givens:u,onGivensChange:s,onNavigate:d,onLinkNavigate:c,height:l,maxResultSize:m,onEvent:p,chrome:h}){const g=o.parseResourceUri(e),{apiClients:v}=B.useServer(),x=g.environmentName??"",y=g.packageName??"",C=g.versionId,w=!!g.environmentName&&!!g.packageName,{data:k,isSuccess:O,isError:M,error:j}=o.useQueryWithApiError({queryKey:["report",x,y,C,r],queryFn:async({signal:N})=>(await v.reports.getReport(x,y,r,C,{signal:N})).data,enabled:w&&r!==""}),E=k?k.notebook?"linear":k.layout:void 0,R=o.useReportEmitter({path:r,layout:E},p),U=`${e}|${r}`,P=I.useRef(void 0),K=I.useRef({key:U,at:o.now()});K.current.key!==U&&(K.current={key:U,at:o.now()}),I.useEffect(()=>{P.current!==U&&(w?M?(P.current=U,R.emit({type:"report.load_failed",surface:"view",category:o.failureCategory(j)})):k?.notebook?.format==="malloynb"?(P.current=U,R.emit({type:"report.load_failed",surface:"view",category:"unsupported"})):O&&k&&(P.current=U,R.emit({type:"report.opened",surface:"view",from:"package",tiles:k.notebook?k.notebook.notebookCells?.length??0:k.tiles?.length??0,durationMs:o.now()-K.current.at})):(P.current=U,R.emit({type:"report.load_failed",surface:"view",category:"invalid"})))},[U,w,M,j,O,k,R]);const A=I.useCallback((N,W)=>{const X=d?.(N,W);X&&R.emit({type:"report.drill",to:"report",outcome:X})},[d,R]),L=d?A:void 0;if(!w)return n.jsxs(S.Alert,{severity:"error",children:["A report resource URI must name an environment and a package. Received: ",e]});if(M)return n.jsx(o.ApiErrorDisplay,{context:`${x} > ${y} > ${r}`,error:j});if(!O||!k)return n.jsx(o.Loading,{text:o.LOADING_COPY.opening("report")});if(k.notebook?.format==="malloynb")return n.jsxs(S.Alert,{severity:"info",children:[r," is a .malloynb notebook, which Report does not run: render it with Notebook."]});let V;return k.notebook?V=n.jsx(Td,{resourceUri:o.encodeResourceUri({environmentName:x,packageName:y,versionId:C,modelPath:r}),notebook:k.notebook,maxResultSize:m,givens:u,onGivensChange:s,onNavigate:c,onDrillNavigate:L}):k.layout==="linear"?V=n.jsx(ba,{manifest:k,environmentName:x,packageName:y,versionId:C,documentName:r,givens:u,onGivensChange:s,onDrillNavigate:L,maxResultSize:m}):V=n.jsx(o.DashboardView,{manifest:k,environmentName:x,packageName:y,versionId:C,documentName:r,givens:u,onGivensChange:s,onNavigate:L,height:l,maxResultSize:m,chrome:h}),n.jsx(o.ReportEventsContext.Provider,{value:R,children:V})}const Od={linear:"Linear: read top to bottom",grid:"Grid: tiles side by side"};function Sa({open:e,layout:r,kind:u,allowLayoutChange:s,allowKindChange:d,environmentName:c,packageName:l,versionId:m,models:p,modelsLoading:h=!1,modelsError:g,onRetryModels:v,target:x,savedAs:y,onClose:C,onCreated:w,onEvent:k}){const O=r??(u?o.layoutOfKind(u):"linear"),M=s??d??!0,[j,E]=I.useState(O),[R,U]=I.useState(void 0),[P,K]=I.useState(""),[A,L]=I.useState(""),[V,N]=I.useState(""),[W,X]=I.useState(!1),[ne,J]=I.useState(!1),[ee,Z]=I.useState(!1),[ae,H]=I.useState(void 0),Q=g!=null,{choices:re,isLoading:ve,isSuccess:Re,failed:se,retry:ie,canRetry:Ne}=o.useDocumentChoices({environmentName:c,packageName:l,...m!==void 0?{versionId:m}:{},models:p,enabled:e&&p.length>0}),xe=I.useMemo(()=>re.get(P)??[],[re,P]),_=xe.find(pe=>`${pe.source}::${pe.view}`===A);I.useEffect(()=>{e&&E(O)},[e,O]),I.useEffect(()=>{if(!e)return;const pe=[...re.keys()];P===""&&pe.length>0&&K(pe[0])},[e,re,P]),I.useEffect(()=>{!e||xe.length===0||A!==""||L(`${xe[0].source}::${xe[0].view}`)},[e,xe,A]),I.useEffect(()=>{!e||W||_===void 0||N(_.view.replace(/_/g," "))},[e,W,_]),I.useEffect(()=>{e||(K(""),L(""),N(""),X(!1),U(void 0),J(!1),H(void 0))},[e]);const oe=I.useMemo(()=>{if(V.trim()!=="")for(let pe=1;pe<=o.MAX_SLUG_ATTEMPTS;pe++){const st=o.reportPathForTitle(V,pe);if(!x.existing?.includes(st))return st}},[V,x]),ge=R?.trim(),Te=ge===void 0||ge===""?void 0:ge.endsWith(".malloy")?ge:`${ge}.malloy`,be=Te??oe,Oe=Te===void 0?void 0:o.reportPathProblem(Te)??(x.existing?.includes(Te)?`${Te} already exists; choose another location.`:void 0),Fe=(_===void 0?void 0:o.newDocumentProblem({title:V,modelPath:P,source:_.source,view:_.view}))??(V.trim()!==""&&be===void 0?"No free file name for this title; choose another.":void 0),Ye=Fe!==void 0&&(ne||V.trim()!==""),le=h||ve,Qe=re.size===0&&(Q||se.length>0),ye=le?"Loading model views":Qe?"Couldn't read the model views to start from":re.size===0?"No model view to start from yet":_===void 0?"Pick a view to start from":void 0,We="report",ct=ee?`Creating ${We}…`:`Create ${We}`,Nt="First query",gt=A!==""&&_===void 0&&xe.length>0,Ze=async()=>{if(!(ye!==void 0||_===void 0||ee)){if(Fe!==void 0||Oe!==void 0){J(!0);return}Z(!0),H(void 0);try{const pe=await o.createDocument({layout:j,...Te!==void 0?{path:Te}:{},document:{title:V,modelPath:P,source:_.source,view:_.view},target:x,...k?{onEvent:k}:{}});w(pe)}catch(pe){const st=pe.response?.data?.message;H(st??(pe instanceof Error?pe.message:String(pe)))}finally{Z(!1)}}},ut=pe=>n.jsx(S.Button,{color:"inherit",size:"small",onClick:pe,children:"Retry"});return n.jsx(o.AppDialog,{open:e,onClose:ee?()=>{}:C,title:`New ${We}`,description:"A report is a Malloy file in the package that lays out text and queries, as a grid or top to bottom. Pick what its first query shows; the rest is the builder.",actions:n.jsxs(n.Fragment,{children:[n.jsx(S.Button,{onClick:C,disabled:ee,children:"Cancel"}),n.jsx(S.Tooltip,{title:ee?"":ye??"",children:n.jsx("span",{children:n.jsx(S.Button,{variant:"contained",disabled:ee||ye!==void 0,"aria-label":!ee&&ye!==void 0?`${ct}: ${ye}`:ct,onClick:()=>void Ze(),children:ct})})})]}),children:n.jsxs(S.Stack,{sx:{gap:2,pt:1},children:[Q?n.jsx(S.Alert,{severity:"error",action:v&&zo.canRetryRequest(g)?ut(v):void 0,children:"Couldn't read this package's models, so no view is listed to start from."}):p.length===0?!h&&n.jsxs(S.Alert,{severity:"info",children:["This package has no models yet. Add a .malloy file that declares a source with a view, then create a ",We," from it."]}):se.length>0?n.jsxs(S.Alert,{severity:"warning",action:Ne?ut(ie):void 0,children:["Couldn't read ",se.join(", "),", so"," ",se.length===1?"its":"their"," views aren't listed."]}):Re&&re.size===0&&n.jsxs(S.Alert,{severity:"info",children:["A ",We," starts from a view of a source, and no model in this package declares one yet. Add a view to a source in a model file and this list fills in."]}),M&&n.jsx(S.TextField,{select:!0,size:"small",label:"Layout",value:j,disabled:ee,onChange:pe=>E(pe.target.value),inputProps:{"aria-label":"Layout"},helperText:"Switch it any time in the builder.",children:["linear","grid"].map(pe=>n.jsx(S.MenuItem,{value:pe,children:Od[pe]},pe))}),n.jsx(S.TextField,{select:!0,size:"small",label:"Model",value:re.has(P)?P:"",disabled:re.size===0||ee,onChange:pe=>{K(pe.target.value),L("")},inputProps:{"aria-label":"Model"},helperText:le?"Reading the package's models…":re.size===1?"The only model with a view to start from.":"Models with a view to start from.",children:[...re.keys()].map(pe=>n.jsx(S.MenuItem,{value:pe,children:pe},pe))}),n.jsx(S.TextField,{select:!0,size:"small",label:Nt,value:_?A:"",disabled:xe.length===0||ee,onChange:pe=>L(pe.target.value),inputProps:{"aria-label":Nt},error:gt,helperText:gt?"The view you picked is no longer in this model; pick another.":xe.length===1?"The only view this model offers; more are added in the builder.":"A view of a source; more are added in the builder.",children:xe.map(pe=>n.jsxs(S.MenuItem,{value:`${pe.source}::${pe.view}`,children:[pe.source," → ",pe.view]},`${pe.source}::${pe.view}`))}),n.jsx(S.TextField,{size:"small",label:"Title",value:V,disabled:ee,onChange:pe=>{X(!0),N(pe.target.value)},inputProps:{"aria-label":"Report title"},error:Ye,helperText:Ye?Fe:x.route==="package"?"Names the file too, unless you type a location.":y??`Saved as a new ${We} in the host's store, and opened in the builder.`}),n.jsx(S.TextField,{size:"small",label:"Location",value:R??oe??"",placeholder:"report.malloy",disabled:ee,onChange:pe=>U(pe.target.value),inputProps:{"aria-label":"Location"},error:Oe!==void 0,helperText:Oe??(be?`Written as ${be} in the package, and opened in the builder.`:"A path in the package; the package root by default.")}),ae&&n.jsx(S.Alert,{severity:"error",children:ae})]})})}const Md=o.createSvgIcon(n.jsx("path",{d:"M21 11h-1.5v-.5h-2v3h2V13H21v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1zM8 10v5H6.5v-1.5h-2V15H3v-5c0-.55.45-1 1-1h3c.55 0 1 .45 1 1m-1.5.5h-2V12h2zm7 1.5c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1h-4V9h4c.55 0 1 .45 1 1v1c0 .55-.45 1-1 1M11 10.5v.75h2v-.75zm2 2.25h-2v.75h2z"})),jd=o.createSvgIcon(n.jsx("path",{d:"M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 18H4V10h16zm0-13H4V5h16z"})),Dd=o.createSvgIcon(n.jsx("path",{d:"M15 4v2h3v12h-3v2h5V4zM4 20h5v-2H6V6h3V4H4z"})),Ed=o.createSvgIcon(n.jsx("path",{d:"M4 7v2c0 .55-.45 1-1 1H2v4h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h3v-2H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h3V4H7C5.35 4 4 5.35 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-3v2h3c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-3v2h3c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-4z"})),Id=o.createSvgIcon(n.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"})),Nd=o.createSvgIcon(n.jsx("path",{d:"M20 10V8h-4V4h-2v4h-4V4H8v4H4v2h4v4H4v2h4v4h2v-4h4v4h2v-4h4v-2h-4v-4zm-6 4h-4v-4h4z"})),Fd=o.createSvgIcon(n.jsx("path",{d:"M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6m0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4m0-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"})),Ad=o.createSvgIcon(n.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33V7h3.33zM19 17h-3.33V7H19z"})),wa={dashboard:B.PALETTE.blue,report:B.PALETTE.violet,model:B.PALETTE.cyan,dataApp:B.PALETTE.pink,data:B.PALETTE.lime,materialization:B.PALETTE.amber,agent:B.PALETTE.red};function Ca({type:e,size:r=18,sx:u,...s}){return n.jsx(o.SvgIcon,{...s,viewBox:"0 0 24 24",sx:{width:r,height:r,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...u},children:$d[e]()})}const $d={report:Rd,model:Pd,data:Ld,materialization:_d,dataApp:zd,dashboard:Wd,agent:qd};function Rd(){return n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M14 3 H6 a2 2 0 0 0 -2 2 v14 a2 2 0 0 0 2 2 h12 a2 2 0 0 0 2 -2 V9 z"}),n.jsx("path",{d:"M14 3 v4 a2 2 0 0 0 2 2 h4"}),n.jsx("path",{d:"M8 17 v-3"}),n.jsx("path",{d:"M12 17 v-6"}),n.jsx("path",{d:"M16 17 v-4"})]})}function Pd(){return n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3 L4 7 v10 l8 4 l8 -4 V7 z"}),n.jsx("path",{d:"M4 7 l8 4 l8 -4"}),n.jsx("path",{d:"M12 11 v10"})]})}function Ld(){return n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),n.jsx("path",{d:"M3.5 9.5 H20.5"}),n.jsx("path",{d:"M9.5 3.5 V20.5"})]})}function _d(){return n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3 L21 7.5 L12 12 L3 7.5 Z"}),n.jsx("path",{d:"M3 12 L12 16.5 L21 12"}),n.jsx("path",{d:"M3 16.5 L12 21 L21 16.5"})]})}function Wd(){return n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),n.jsx("path",{d:"M3.5 9.5 H20.5"}),n.jsx("path",{d:"M12 9.5 V20.5"}),n.jsx("path",{d:"M12 15 H20.5"})]})}function qd(){return n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"8",r:"3.5"}),n.jsx("path",{d:"M5 20 a7 7 0 0 1 14 0"})]})}function zd(){return n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2"}),n.jsx("path",{d:"M3.5 9.5 H20.5"}),n.jsx("path",{d:"M7 13.5 H17"}),n.jsx("path",{d:"M7 16.5 H13"})]})}function ka(e){return e>=1e9?`${(e/1e9).toFixed(1)} B rows`:e>=1e6?`${(e/1e6).toFixed(1)} M rows`:e>=1e3?`${(e/1e3).toFixed(1)} K rows`:`${e} rows`}const Hd=12;function Vd(e){const r=e?.trim().toLowerCase()??"";if(r.startsWith("array")||r.endsWith("[]"))return Dd;if(r.startsWith("record")||r.startsWith("struct"))return Ed;switch(r.split(/[\s(<]/)[0]){case"string":return Md;case"number":return Nd;case"date":return jd;case"timestamp":case"timestamptz":return Id;case"boolean":return Fd;default:return Ad}}function Bd({column:e}){const r=Vd(e.type);return n.jsxs(S.Box,{component:"li",sx:u=>({display:"flex",alignItems:"center",gap:1.25,px:1,py:.625,borderRadius:1,transition:"background-color 0.1s","&:hover":{backgroundColor:u.palette.mode==="dark"?"rgba(255, 255, 255, 0.06)":u.palette.grey[100]}}),children:[n.jsx(r,{"aria-hidden":!0,sx:{fontSize:18,color:"primary.main",flexShrink:0}}),n.jsxs(S.Box,{sx:{display:"flex",alignItems:"baseline",gap:1,minWidth:0,flex:1},children:[n.jsx(S.Typography,{component:"span",sx:{fontFamily:B.MONO_FONT_FAMILY,fontSize:"0.8125rem",fontWeight:500,color:"text.primary",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),e.type&&n.jsx(S.Typography,{component:"span",variant:"caption",color:"text.secondary",sx:{flexShrink:0,maxWidth:"50%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.type})]})]})}function Ud({database:e,onClose:r}){const u=e!==null,[s,d]=I.useState(e);e!==null&&e!==s&&d(e);const[c,l]=I.useState(""),[m,p]=I.useState(s?.path);m!==s?.path&&(p(s?.path),l(""));const h=I.useId(),g=s?.path??"",v=g.split("/").pop()||g,x=g.slice(0,Math.max(0,g.length-v.length-1)),y=s?.info?.rowCount,C=[x,y===void 0?null:ka(y)].filter(Boolean).join(" · "),w=I.useMemo(()=>s?.info?.columns??[],[s]),k=c.trim().toLowerCase(),O=I.useMemo(()=>k?w.filter(M=>M.name?.toLowerCase().includes(k)||M.type?.toLowerCase().includes(k)):w,[w,k]);return n.jsxs(o.AppDialog,{open:u,onClose:r,showClose:!0,title:n.jsxs(S.Stack,{direction:"row",alignItems:"center",spacing:1.5,sx:{minWidth:0},children:[n.jsx(S.Box,{"aria-hidden":!0,sx:{width:32,height:32,borderRadius:1,bgcolor:wa.data,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:n.jsx(Ca,{type:"data",size:18})}),n.jsxs(S.Box,{sx:{minWidth:0},children:[n.jsx(S.Typography,{component:"span",noWrap:!0,title:g,sx:{display:"block",fontFamily:B.MONO_FONT_FAMILY,fontSize:"1rem",fontWeight:600,letterSpacing:0,lineHeight:1.4},children:v||"Columns"}),C&&n.jsx(S.Typography,{component:"span",variant:"caption",color:"text.secondary",noWrap:!0,sx:{display:"block",lineHeight:1.4},children:C})]})]}),children:[s?.error&&n.jsx(S.Alert,{severity:"error",variant:"outlined",children:s.error}),s&&!s.error&&n.jsxs(S.Box,{component:"section","aria-labelledby":h,sx:{display:"flex",flexDirection:"column",border:"1px solid",borderColor:"divider",borderRadius:2,bgcolor:"background.paper",overflow:"hidden",mb:2},children:[n.jsxs(S.Stack,{direction:"row",alignItems:"center",spacing:1,sx:{px:1.5,py:1,minHeight:44,borderBottom:"1px solid",borderColor:"divider"},children:[n.jsxs(S.Typography,{id:h,component:"h3",sx:{fontSize:"0.875rem",fontWeight:600},children:["Columns",n.jsxs(S.Typography,{component:"span",variant:"caption",color:"text.secondary",sx:{ml:.75,fontVariantNumeric:"tabular-nums"},children:["· ",k?`${O.length} of `:"",w.length]})]}),w.length>Hd&&n.jsx(S.InputBase,{value:c,onChange:M=>l(M.target.value),placeholder:"Filter columns",inputProps:{"aria-label":"Filter columns"},startAdornment:n.jsx(S.InputAdornment,{position:"start",children:n.jsx(nr,{sx:{fontSize:16,color:"text.secondary"}})}),sx:{ml:"auto !important",width:200,fontSize:"0.8125rem",px:1,py:.25,border:"1px solid",borderColor:"divider",borderRadius:1.5,"&.Mui-focused":{borderColor:"primary.main"}}})]}),n.jsx(S.Box,{sx:{overflowY:"auto",maxHeight:420,px:.75,py:.75},children:O.length===0?n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic",px:1,py:1},children:k?"No columns match":"No columns"}):n.jsx(S.Box,{component:"ul","aria-labelledby":h,sx:{listStyle:"none",m:0,p:0},children:O.map((M,j)=>n.jsx(Bd,{column:M},`${M.name}-${j}`))})})]})]})}const Gd="README.malloynb",Yd=e=>!!e&&!e.includes("/")&&o.documentSlug(e)?.toLowerCase()==="readme";function Zd({onClickPackageFile:e,onOpenDocument:r,resourceUri:u,onEvent:s}){const{apiClients:d,server:c,mutable:l}=B.useServer(),m=Sr.useQueryClient(),p=e??(_=>{window.location.href=_}),{environmentName:h,packageName:g,versionId:v}=o.parseResourceUri(u),x=r??((_,oe)=>{const ge=_.mode==="edit"?o.reportEditRoute(h,g,_.path):o.reportRoute(h,g,_.path);oe?p(ge,oe):p(ge)}),[y,C]=I.useState(null),[w,k]=I.useState(!1),O=Vo(),M=o.useOptionalDocumentStorage()?.documentStorage,[j,E]=I.useState([]),[R,U]=I.useState({state:M?"pending":"ready"}),P=I.useCallback(async()=>{if(!M)return;let _;try{_=await M.listWorkspaces(!1)}catch{U({state:"failed"});return}U({state:"ready",chosen:o.chooseWorkspace(_)});const oe=[],ge=o.draftKey(h,g,"");for(const Te of _.filter(be=>be.writeable))for(const be of await M.listDocuments(Te))be.path.startsWith(ge)&&oe.push({locator:be,where:Te.description});E(oe)},[M,h,g]);I.useEffect(()=>{P()},[P]);const K=_=>_.path.slice(o.draftKey(h,g,"").length),A=o.useQueryWithApiError({queryKey:["package",h,g,v],queryFn:()=>d.packages.getPackage(h,g,v,!1)}),L=o.useReportListing(h,g,v),V=o.useQueryWithApiError({queryKey:["models",h,g,v],queryFn:()=>d.models.listModels(h,g,v)}),N=o.useQueryWithApiError({queryKey:["databases",h,g,v],queryFn:()=>d.databases.listDatabases(h,g,v)}),X=o.useQueryWithApiError({queryKey:["data-apps",h,g],queryFn:async()=>{try{return await d.dataApps.listDataApps(h,g)}catch(_){const oe=_?.response?.status;if(oe===404||oe===void 0)return{data:[]};throw _}}}).data?.data??[],ne=L.reports.filter(_=>!!_.path),J=Xd(ne),ee=new Set(ne.map(_=>_.path).filter(_=>_!==void 0)),Z=(V.data?.data??[]).slice().filter(_=>!ee.has(_.path)).sort((_,oe)=>_.path.localeCompare(oe.path)),ae=(N.data?.data??[]).slice().sort((_,oe)=>_.path.localeCompare(oe.path)),H=R.state==="ready"?o.createRoute({authoritative:R.chosen?.authoritative===!0,mutable:l,canStore:R.chosen?.writeable===!0,...v===void 0?{}:{versionId:v}}):void 0,Q=L.settled&&(V.isSuccess||V.isError),re=H!==void 0&&Q,ve=re&&!O,Re=I.useMemo(()=>{if(!re)return;const _=[...L.reports.flatMap(oe=>oe.path?[oe.path]:[]),...(V.data?.data??[]).flatMap(oe=>oe.path?[oe.path]:[])];if(H==="storage"&&M&&R.state==="ready")return R.chosen?{route:H,storage:M,workspace:R.chosen,environmentName:h,packageName:g,existing:_}:void 0;if(H==="package")return{route:H,existing:_,write:async(oe,ge)=>{await d.models.updateModelSource(h,g,oe,{source:ge})}}},[re,H,M,R,h,g,d,L.reports,V.data]),se=A.data?.data?.description??"",ie=A.data?.data?.agents??[],Ne=(ne.find(_=>_.path===Gd)??ne.find(_=>Yd(_.path)))?.path,xe=!L.settled;return A.isError?n.jsx(o.ApiErrorDisplay,{error:A.error,context:`${h} > ${g}`}):n.jsxs(S.Container,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[n.jsxs(S.Box,{sx:{mb:4},children:[n.jsx(S.Typography,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:g}),se&&n.jsx(S.Typography,{variant:"body2",color:"text.secondary",children:se})]}),xe&&n.jsx(o.Loading,{text:"Loading package..."}),Re&&n.jsx(Sa,{open:w,layout:"linear",environmentName:h,packageName:g,...v!==void 0?{versionId:v}:{},models:Z.map(_=>_.path).filter(_=>typeof _=="string"&&_.endsWith(".malloy")&&!ee.has(_)),modelsLoading:V.isPending,...V.isError?{modelsError:V.error}:{},onRetryModels:()=>void V.refetch(),target:Re,...s?{onEvent:s}:{},onClose:()=>k(!1),onCreated:_=>{k(!1),o.invalidateReportQueries(m,h,g),m.invalidateQueries({queryKey:["models"]}),x({path:_.path,layout:_.layout,slug:_.slug,mode:"edit"})}}),!xe&&n.jsxs(n.Fragment,{children:[L.isError&&n.jsx(S.Box,{sx:{mb:4},children:n.jsx(S.Alert,{severity:"warning",action:n.jsx(S.Button,{color:"inherit",size:"small",onClick:()=>void L.refetch(),children:"Retry"}),children:"Could not list this package's reports, so any it has are missing from this page."})}),(J.length>0||re)&&n.jsxs(wt,{title:"Reports",count:J.length,...ve?{action:n.jsx(S.Button,{variant:"outlined",size:"small",onClick:()=>k(!0),children:"New report"})}:{},children:[J.length===0&&n.jsx(Gr,{label:"No reports yet",...ve?{action:{label:"New report",onClick:()=>k(!0)}}:{}}),J.map(_=>n.jsx(Sn,{type:_.layout==="grid"?"dashboard":"report",label:_.label,rightLabel:_.layout,..._.secondary===void 0?{}:{description:_.secondary},onClick:oe=>_.path.endsWith(".malloynb")?p(`/${h}/${g}/${_.path}`,oe):x({path:_.path,layout:_.layout,slug:_.slug,mode:"view"},oe)},_.path))]}),j.length>0&&n.jsx(wt,{title:"Drafts",count:j.length,children:j.map(({locator:_,where:oe})=>n.jsx(Sn,{type:_.type==="grid"?"dashboard":"report",label:K(_),rightLabel:oe,onClick:ge=>x({path:K(_),layout:_.type,slug:o.documentSlug(K(_))??"",mode:"edit"},ge),trailingAction:n.jsx(S.Tooltip,{title:"Delete this draft",children:n.jsx(S.IconButton,{size:"small","aria-label":`Delete draft ${K(_)}`,onClick:ge=>{ge.stopPropagation(),M?.deleteDocument(_).then(P)},children:n.jsx(o.DeleteOutlineIcon,{fontSize:"small"})})})},`${_.workspace}:${_.path}`))}),X.length>0&&n.jsx(wt,{title:"Apps",count:X.length,children:X.map(_=>{const oe=!!_.title&&_.title!==_.path,ge=`${Go(c)}${_.resource}`;return n.jsx(Sn,{type:"dataApp",label:oe?_.title:_.path,rightLabel:oe?_.path:void 0,onClick:Te=>{e?e(`/${h}/${g}/data-apps/${_.path}`,Te):Te&&(Te.metaKey||Te.ctrlKey)?window.open(ge,"_blank"):window.location.href=ge},trailingAction:n.jsx(S.Tooltip,{title:"Open standalone in new tab",children:n.jsx(S.IconButton,{size:"small",href:ge,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",onClick:Te=>Te.stopPropagation(),sx:{color:"text.secondary"},children:n.jsx(Uo,{fontSize:"small"})})})},_.path)})}),n.jsxs(wt,{title:"Models",count:Z.length,children:[Z.map(_=>n.jsx(Sn,{type:"model",label:_.path,onClick:oe=>p(`/${h}/${g}/${_.path}`,oe)},_.path)),Z.length===0&&n.jsx(Gr,{label:"No models"})]}),ie.length>0&&n.jsx(wt,{title:"Agents",count:ie.length,description:"Declared in publisher.json. Name one in an agent session to work as it. Schedules are listed only; nothing runs them yet.",children:ie.map(_=>n.jsx(Kd,{agent:_},_.name))}),n.jsxs(wt,{title:"Data",count:ae.length,children:[ae.map(_=>n.jsx(Sn,{type:"data",label:_.path,rightLabel:_.info?ka(_.info.rowCount):"Unreadable",onClick:()=>C(_)},_.path)),ae.length===0&&n.jsx(Gr,{label:"No data files"})]}),n.jsx(da,{resourceUri:u}),Ne&&n.jsx(S.Box,{sx:{mt:6},children:n.jsx(va,{resourceUri:o.encodeResourceUri({environmentName:h,packageName:g,versionId:v}),path:Ne,onLinkNavigate:p})})]}),n.jsx(Ud,{database:y,onClose:()=>C(null)})]})}function Sn({type:e,label:r,description:u,rightLabel:s,onClick:d,trailingAction:c}){return n.jsx(wr,{icon:n.jsx(Ca,{type:e}),tint:wa[e],label:r,mono:!0,...u===void 0?{}:{description:u},...s===void 0?{}:{rightLabel:s},...d===void 0?{}:{onClick:d},...c===void 0?{}:{trailingAction:c}})}function Kd({agent:e}){return n.jsxs(n.Fragment,{children:[n.jsx(Sn,{type:"agent",label:e.name??"",...e.description?{description:e.description}:{},...e.model&&e.model!=="inherit"?{rightLabel:e.model}:{}}),(e.schedules??[]).map(r=>{const u=cs(r.cron??"");return n.jsxs(S.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",ml:6,mb:.5},children:[u.valid?u.description:r.cron," (UTC), task"," ",r.task,". Not run yet."]},`${r.cron}|${r.task}`)})]})}function Xd(e){const r=e.map(s=>({path:s.path??"",layout:o.listedLayout(s),slug:o.documentSlug(s.path)??s.path??"",title:s.title})),u=new Map;for(const s of r)u.set(s.slug,(u.get(s.slug)??0)+1);return r.map(({title:s,...d})=>{const c=!!s&&s!==d.slug&&s!==d.path,l=(u.get(d.slug)??0)>1,m=c?s:d.path.endsWith(".malloynb")?d.path:d.slug;return{...d,label:m,secondary:m!==d.path&&(c||l||d.path.includes("/"))?d.path:void 0}}).sort((s,d)=>s.label.localeCompare(d.label)||s.path.localeCompare(d.path))}function Gr({label:e,action:r}){return n.jsxs(S.Stack,{direction:"row",sx:{alignItems:"center",gap:1,py:1},children:[n.jsx(S.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:e}),r&&n.jsx(S.Button,{size:"small",onClick:r.onClick,children:r.label})]})}const qo=/^publisher:document:(dashboard|notebook):(.+)$/;function Qd(e,r){const u=[];for(let s=0;s<e.length;s++){const d=e.key(s);d!==null&&qo.test(d)&&u.push(d)}for(const s of u){const[,d,c]=qo.exec(s),l=e.getItem(s);l!==null&&r(c,o.layoutOfKind(d),l)&&e.removeItem(s)}}const Yr={name:"Local",description:"Stored in this browser only",writeable:!0},ss="publisher:report:",Qt=e=>`${ss}${e}`;function Zn(e){const r=localStorage.getItem(e);if(r!==null)try{const u=JSON.parse(r);if(typeof u.content=="string"&&(u.type==="grid"||u.type==="linear"))return{type:u.type,content:u.content}}catch{}}const Zr=(e,r)=>localStorage.setItem(Qt(e),JSON.stringify(r));class Jd{migrated=!1;migrate(){this.migrated||(this.migrated=!0,Qd(localStorage,(r,u,s)=>Zn(Qt(r))!==void 0?!1:(Zr(r,{type:u,content:s}),!0)))}async listWorkspaces(r){return[Yr]}async listDocuments(r,u){if(r.name!==Yr.name)return[];this.migrate();const s=[];for(let d=0;d<localStorage.length;d++){const c=localStorage.key(d);if(c===null||!c.startsWith(ss))continue;const l=Zn(c);l&&(u===void 0||l.type===u)&&s.push({workspace:Yr.name,type:l.type,path:c.slice(ss.length)})}return s}async getDocument(r){this.migrate();const u=Zn(Qt(r.path));if(u===void 0)throw Kr(r);return u.content}async getDocumentType(r){this.migrate();const u=Zn(Qt(r.path));if(u===void 0)throw Kr(r);return u.type}async saveDocument(r,u){this.migrate(),Zr(r.path,{type:r.type,content:u})}async deleteDocument(r){if(this.migrate(),Zn(Qt(r.path))===void 0)throw Kr(r);localStorage.removeItem(Qt(r.path))}async moveDocument(r,u){const s=await this.getDocument(r);Zr(u.path,{type:u.type,content:s}),u.path!==r.path&&localStorage.removeItem(Qt(r.path))}}function Kr(e){return new o.DocumentNotFoundError(`No report at ${e.workspace}/${e.path}`)}async function eh(e,r,u,s){const d=o.chooseWorkspace(await e.listWorkspaces(!1));if(!d)return;const c=o.draftKey(r,u,s);if(e.getDocumentType)try{return await e.getDocumentType({workspace:d.name,path:c})}catch(l){if(o.isDocumentNotFound(l))return;throw l}return(await e.listDocuments(d)).find(l=>l.path===c)?.type}function th(e,r,u,s=!0){const d=o.useOptionalDocumentStorage()?.documentStorage,c=s&&d!==void 0,[l,m]=I.useState(),p=o.draftKey(e,r,u);return I.useEffect(()=>{if(!c||!d)return;let h=!1;return eh(d,e,r,u).catch(()=>{}).then(g=>{h||m({key:p,layout:g})}),()=>{h=!0}},[c,d,e,r,u,p]),c?l?.key===p?{layout:l.layout,settled:!0}:{layout:void 0,settled:!1}:{layout:void 0,settled:!0}}function Ta(e){const{environmentName:r,packageName:u}=o.parseResourceUri(e.resourceUri);if(!r||!u)throw new Error("Environment and Package name must be provided for query embedding.");return JSON.stringify({...e})}function nh({embeddedQueryResult:e}){const{query:r,sourceName:u,queryName:s,resourceUri:d,height:c}=JSON.parse(e),{modelPath:l}=o.parseResourceUri(d);if(!l||!r&&(!s||!u)||typeof l!="string")throw new Error("Invalid embedded query result: "+e);return n.jsx(Oa,{query:r,sourceName:u,queryName:s,resourceUri:d,height:c})}function Oa({query:e,sourceName:r,queryName:u,resourceUri:s,height:d=400}){const{modelPath:c,environmentName:l,packageName:m,versionId:p}=o.parseResourceUri(s);if(!l||!m)throw new Error("No environment or package name provided. A resource URI must be provided.");const h=o.useQueryResult({environmentName:l,packageName:m,modelPath:c,versionId:p,query:e,sourceName:r,queryName:u});return n.jsx(o.ResultPanel,{state:h,context:`${l} > ${m} > ${c}`,maxHeight:d})}function rh({resourceUri:e,dashboard:r,givens:u,onGivensChange:s,onNavigate:d,height:c,maxResultSize:l,onEvent:m,chrome:p}){const h=o.parseResourceUri(e),{apiClients:g}=B.useServer(),v=h.environmentName??"",x=h.packageName??"",y=h.versionId,C=!!h.environmentName&&!!h.packageName,{data:w,isSuccess:k,isError:O,error:M}=o.useQueryWithApiError({queryKey:["dashboard",v,x,y,r],queryFn:()=>g.dashboards.getDashboard(v,x,r,y),enabled:C}),j=w?.data,E=o.useReportEmitter({path:j?.path??r,layout:"grid"},m);return C?O?n.jsx(o.ApiErrorDisplay,{context:`${v} > ${x} > ${r}`,error:M}):!k||!j?n.jsx(o.Loading,{text:o.LOADING_COPY.opening("report")}):n.jsx(o.ReportEventsContext.Provider,{value:E,children:n.jsx(o.DashboardView,{manifest:j,environmentName:v,packageName:x,versionId:y,documentName:r,givens:u,onGivensChange:s,onNavigate:d,height:c,maxResultSize:l,chrome:p})}):n.jsxs(S.Alert,{severity:"error",children:["A dashboard resource URI must name an environment and a package. Received: ",e]})}function Ma(e){const{apiClients:r}=B.useServer(),{environmentName:u,packageName:s,versionId:d,modelPath:c}=o.parseResourceUri(e);return o.useQueryWithApiError({queryKey:[e],queryFn:async()=>(await r.notebooks.getNotebook(u,s,c,d)).data})}function sh(e){const{apiClients:r}=B.useServer(),{environmentName:u,packageName:s,versionId:d,modelPath:c}=o.parseResourceUri(e.resourceUri),l=Ma(e.resourceUri),m=I.useCallback(async({index:p,givens:h,declaredTypes:g,signal:v})=>{const x=o.givensToRequest(h,g);return(await r.notebooks.executeNotebookCell(u,s,c,p,d,void 0,void 0,Object.keys(x).length>0?JSON.stringify(x):void 0,{signal:v})).data},[r.notebooks,u,s,c,d]);return n.jsx(xa,{...e,notebook:l.isSuccess?l.data:void 0,error:l.isError?l.error:void 0,runCell:m})}function oh(e){const{data:r}=Ma(e.resourceUri);if(r?.dashboard){const{environmentName:u,packageName:s,versionId:d,modelPath:c}=o.parseResourceUri(e.resourceUri);return n.jsx(ba,{manifest:r.dashboard,environmentName:u,packageName:s,versionId:d,documentName:c,givens:e.givens,onGivensChange:e.onGivensChange,onDrillNavigate:e.onDrillNavigate,maxResultSize:e.maxResultSize})}return n.jsx(sh,{...e})}function ja(e,r,u="grid"){const s=r.filter(c=>!!c.path).filter(c=>o.documentSlug(c.path)===e),d=s.filter(c=>o.listedLayout(c)===u);return d.length===1?{found:o.locatedReport(d[0])}:s.length===1?{found:o.locatedReport(s[0])}:s.length===0?{missing:!0}:{ambiguous:s.map(c=>c.path).sort()}}const ah=/^(dashboards|notebooks)\/([^/]+)$/;function ih(e){const r=ah.exec(e);if(r)return{name:r[2],prefer:r[1]==="dashboards"?"grid":"linear"}}const lh=(e,r,u,s)=>`/${e}/${r}/${u}s/${encodeURIComponent(s)}`;function ch({kind:e,slug:r,reports:u}){const s=ja(r,u,o.layoutOfKind(e));return"found"in s?s.found:void 0}function uh(e,r){return`${e}:${r}`}function Jt(e){return uh(e.source,e.filterName??e.dimensionName)}function Dt(e,r=!1){return e==null?"null":r?e instanceof Date?`@${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`:`@${e}`:typeof e=="string"?`'${o.escapeMalloyString(e)}'`:typeof e=="number"?String(e):typeof e=="boolean"?e?"true":"false":String(e)}function dh(e){const{dimensionName:r,matchType:u,value:s,value2:d}=e,c=`\`${r}\``,l=s instanceof Date;switch(u){case"Equals":case"Semantic Search":return Array.isArray(s)&&s.length>0?`(${s.map(p=>`${c} = ${Dt(p,l)}`).join(" or ")})`:Array.isArray(s)?"":`${c} = ${Dt(s,l)}`;case"Contains":return typeof s=="string"?`${c} ~ f'%${o.escapeMalloyString(s)}%'`:Array.isArray(s)?"":`${c} = ${Dt(s)}`;case"After":return Array.isArray(s)?"":`${c} > ${Dt(s,l)}`;case"Before":return Array.isArray(s)?"":`${c} < ${Dt(s,l)}`;case"Greater Than":return Array.isArray(s)?"":`${c} > ${Dt(s)}`;case"Less Than":return Array.isArray(s)?"":`${c} < ${Dt(s)}`;case"Between":return Array.isArray(s)?"":d!==void 0?`${c} >= ${Dt(s,l)} and ${c} <= ${Dt(d,l)}`:`${c} >= ${Dt(s,l)}`;default:return""}}function hh(e){const r=new Map;for(const u of e){const s=`${u.source}|${u.model}`,d=r.get(s)||[];d.push(u),r.set(s,d)}return r}function fh(e,r,u,s){const d=r.filter(h=>(h.filterType==="Star"||h.filterType==="MinMax"||h.filterType==="DateMinMax")&&!h.values);if(d.length===0)return"";const l=[...new Set(d.map(h=>h.dimensionName))].map(h=>`\`${h}\``).join(", "),m=s?.filter(h=>h.source===e)||[],p=m.length>0?m.map(h=>dh(h)).filter(h=>h.length>0).join(" and "):"";return`
|
|
12
12
|
run: ${e} -> {
|
|
13
13
|
${p?`where: ${p}`:""}
|
|
14
14
|
index: ${l}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
limit: ${u}
|
|
20
20
|
}
|
|
21
|
-
`}function
|
|
21
|
+
`}function ph(e,r){const u=new Map;for(const g of r){const v=Jt(g);u.set(v,[])}const s=JSON.parse(e),d=s.schema.fields,c=new Map;d.forEach((g,v)=>{c.set(g.name,v)});const l=g=>{if(!g)return null;switch(g.kind){case"string_cell":return g.string_value??null;case"number_cell":return g.number_value??null;case"boolean_cell":return g.boolean_value??null;case"null_cell":return null;default:return console.log("Unknown cell kind: "+g.kind),null}},p=(s.data?.array_value||[]).map(g=>{const v={};return g.kind==="record_cell"&&g.record_value&&g.record_value.forEach((x,y)=>{const C=d[y]?.name;if(C){const w=l(x);C==="fieldName"&&typeof w=="string"?v.fieldName=w:C==="fieldPath"&&typeof w=="string"?v.fieldPath=w:C==="fieldType"&&typeof w=="string"?v.fieldType=w:C==="fieldValue"&&typeof w=="string"?v.fieldValue=w:C==="weight"&&typeof w=="number"&&(v.weight=w)}}),v}),h=p.length===0||p.every(g=>!g.fieldName);for(const g of r){if(g.filterType==="NONE"||g.filterType==="Retrieval")continue;const v=p.filter(y=>{const C=y.fieldName||"",w=y.fieldPath||"";if(C===g.dimensionName||w===g.dimensionName||C.toLowerCase()===g.dimensionName.toLowerCase()||w.toLowerCase()===g.dimensionName.toLowerCase())return!0;const k=w.split(".").pop()||"";return k===g.dimensionName||k.toLowerCase()===g.dimensionName.toLowerCase()});if(v.length===0)continue;const x=Jt(g);if(g.filterType==="Star"){const y=v.filter(C=>C.fieldType==="string").map(C=>({value:C.fieldValue??"",count:C.weight})).sort((C,w)=>(w.count??0)-(C.count??0));u.set(x,y)}else if(g.filterType==="MinMax"){console.log("MinMax dimensionEntries: "+JSON.stringify(v,null,2)),console.log("All MinMax dimension entries fieldTypes:",v.map(C=>C.fieldType));const y=v.find(C=>C.fieldType==="number");if(console.log("numericEntry: "+JSON.stringify(y,null,2)),y?.fieldValue){const C=y.fieldValue,w=C.split(" to ");if(console.log("rangeParts: "+w),w.length===2){const k=[{value:parseFloat(w[0])},{value:parseFloat(w[1])}];u.set(x,k)}else console.warn(`Could not parse numeric range for ${g.dimensionName}: ${C}`)}else console.warn(`No numeric entry found for ${g.dimensionName}. Available entries:`,v)}else if(g.filterType==="DateMinMax"){const y=v.find(C=>C.fieldType==="date"||C.fieldType==="timestamp"||C.fieldType==="string");if(console.log("dateEntry: "+JSON.stringify(y,null,2)),console.log("All date dimension entries fieldTypes:",v.map(C=>C.fieldType)),y?.fieldValue){const C=y.fieldValue,w=C.split(" to ");if(console.log("date rangeParts: "+w),w.length===2){const k=[{value:new Date(w[0].trim())},{value:new Date(w[1].trim())}];u.set(x,k)}else console.warn(`Could not parse date range for ${g.dimensionName}: ${C}`)}else console.warn(`No date entry found for ${g.dimensionName}. Available entries:`,v)}}return{values:u,noRowsMatchedFilter:h}}function Da(e){const{environment:r,package:u,dimensionSpecs:s,versionId:d,enabled:c=!0,indexLimit:l=1e4,activeFilters:m=[]}=e,p=I.useMemo(()=>hh(s),[s]),h=I.useMemo(()=>{const w=[];for(const[k,O]of p){const[M,j]=k.split("|"),E=fh(M,O,l,m);E?w.push({key:k,source:M,model:j,query:E,specs:O}):console.log("No query for source: ",M,"model: ",j)}return w},[p,l,m]),g=I.useMemo(()=>c&&h.length>0&&s.some(w=>w.filterType==="Star"||w.filterType==="MinMax"||w.filterType==="DateMinMax"),[c,h,s]),{apiClients:v}=B.useServer(),x=o.useQueryWithApiError({queryKey:["dimensionalFilter",r,u,s,d,m],queryFn:async({signal:w})=>{if(!g){const j=new Map;for(const E of s){const R=Jt(E);j.set(R,[])}return{values:j,noRowsMatchedFilter:!1}}const k=await Promise.all(h.map(async j=>{const E=await v.models.executeQueryModel(r,u,j.model,{query:j.query,versionId:d,bypassFilters:!0},void 0,{signal:w});return{config:j,result:ph(E.data.result,j.specs)}})),O=new Map;let M=!1;for(const{result:j}of k){for(const[E,R]of j.values)O.set(E,R);j.noRowsMatchedFilter&&(M=!0)}return{values:O,noRowsMatchedFilter:M}},enabled:g,staleTime:300*1e3,placeholderData:w=>w}),y=x.data?.values;return{data:I.useMemo(()=>{const w=new Map;for(const k of s){const O=Jt(k);k.values?w.set(O,k.values.map(M=>({value:M}))):w.set(O,[])}if(y)for(const[k,O]of y)O.length>0&&w.set(k,O);return w},[s,y]),noRowsMatchedFilter:x.data?.noRowsMatchedFilter??!1,isLoading:g?x.isPending:!1,isError:g?x.isError:!1,error:g?x.error:null,refetch:x.refetch}}function Et(e,r=!1){return e==null?"null":r?e instanceof Date?`@${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`:`@${e}`:typeof e=="string"?`'${o.escapeMalloyString(e)}'`:typeof e=="number"?String(e):typeof e=="boolean"?e?"true":"false":String(e)}function mh(e){const{dimensionName:r,matchType:u,value:s,value2:d}=e,c=`\`${r}\``,l=s instanceof Date;switch(u){case"Equals":case"Semantic Search":return Array.isArray(s)&&s.length>0?`(${s.map(p=>`${c} = ${Et(p,l)}`).join(" or ")})`:Array.isArray(s)?"":`${c} = ${Et(s,l)}`;case"Contains":return typeof s=="string"?`${c} ~ f'%${o.escapeMalloyString(s)}%'`:Array.isArray(s)?"":`${c} = ${Et(s)}`;case"After":return Array.isArray(s)?"":`${c} > ${Et(s,l)}`;case"Before":return Array.isArray(s)?"":`${c} < ${Et(s,l)}`;case"Greater Than":return Array.isArray(s)?"":`${c} > ${Et(s)}`;case"Less Than":return Array.isArray(s)?"":`${c} < ${Et(s)}`;case"Between":return Array.isArray(s)?"":d!==void 0?`${c} >= ${Et(s,l)} and ${c} <= ${Et(d,l)}`:`${c} >= ${Et(s,l)}`;default:return""}}function Ea(e){const{dimensionSpecs:r}=e,[u,s]=I.useState(()=>{const h=new Map;return r.forEach(g=>{const v=Jt(g);h.set(v,{spec:g,selection:null})}),h});I.useEffect(()=>{s(h=>{const g=new Map;return r.forEach(v=>{const x=Jt(v),y=h.get(x);g.set(x,{spec:v,selection:y?.selection??null})}),g})},[r]);const d=I.useCallback((h,g)=>{s(v=>{const x=new Map(v),y=x.get(h);return y&&x.set(h,{...y,selection:g}),x})},[]),c=I.useCallback(h=>{d(h,null)},[d]),l=I.useCallback(()=>{s(h=>{const g=new Map(h);return g.forEach((v,x)=>{g.set(x,{...v,selection:null})}),g})},[]),m=I.useCallback(()=>{const h=[];return u.forEach(g=>{g.selection&&h.push(g.selection)}),h},[u]),p=I.useCallback(()=>{const h=m();if(h.length===0)return"";const g=h.map(v=>mh(v)).filter(v=>v.length>0);return g.length===0?"":`where ${g.join(" and ")}`},[m]);return{filterStates:u,updateFilter:d,clearFilter:c,clearAllFilters:l,getActiveFilters:m,generateWhereClause:p}}function It(e,r=!1){return e==null?"null":r?e instanceof Date?`@${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`:`@${e}`:typeof e=="string"?`'${o.escapeMalloyString(e)}'`:typeof e=="number"?String(e):typeof e=="boolean"?e?"true":"false":String(e)}function gh(e){const{dimensionName:r,matchType:u,value:s,value2:d}=e,c=`\`${r}\``,l=s instanceof Date;switch(u){case"Equals":case"Semantic Search":return Array.isArray(s)&&s.length>0?`(${s.map(p=>`${c} = ${It(p,l)}`).join(" or ")})`:Array.isArray(s)?"":`${c} = ${It(s,l)}`;case"Contains":return typeof s=="string"?`${c} ~ f'%${o.escapeMalloyString(s)}%'`:Array.isArray(s)?"":`${c} = ${It(s)}`;case"After":return Array.isArray(s)?"":`${c} > ${It(s,l)}`;case"Before":return Array.isArray(s)?"":`${c} < ${It(s,l)}`;case"Greater Than":return Array.isArray(s)?"":`${c} > ${It(s)}`;case"Less Than":return Array.isArray(s)?"":`${c} < ${It(s)}`;case"Between":return Array.isArray(s)?"":d!==void 0?`${c} >= ${It(s,l)} and ${c} <= ${It(d,l)}`:`${c} >= ${It(s,l)}`;default:return""}}function yh(e){if(e.length===0)return"";const r=e.map(u=>gh(u)).filter(u=>u.length>0);return r.length===0?"":r.join(" and ")}function xh(e,r,u,s=1e3){const d=yh(r),l=u&&u.length>0?`group_by: ${u.map(m=>`\`${m}\``).join(", ")}`:"select: *";return d?`
|
|
22
22
|
run: ${e} -> {
|
|
23
23
|
where: ${d}
|
|
24
24
|
${l}
|
|
@@ -29,4 +29,4 @@
|
|
|
29
29
|
${l}
|
|
30
30
|
limit: ${s}
|
|
31
31
|
}
|
|
32
|
-
`}function Ia(e){const{environment:r,package:u,model:s,source:d,filterSelections:c,fields:l,limit:m=1e3}=e,[p,h]=I.useState(null),g=I.useMemo(()=>
|
|
32
|
+
`}function Ia(e){const{environment:r,package:u,model:s,source:d,filterSelections:c,fields:l,limit:m=1e3}=e,[p,h]=I.useState(null),g=I.useMemo(()=>xh(d,c,l,m),[d,c,l,m]),v=I.useMemo(()=>o.encodeResourceUri({environmentName:r,packageName:u,modelPath:s}),[r,u,s]),x=c.length>0,y=I.useCallback(()=>{if(!x){h(null);return}const C=Ta({resourceUri:v,query:g});h(C)},[x,v,g]);return{embeddedQueryResult:p,queryString:g,resourceUri:v,executeQuery:y,canExecute:x}}function bh(e,r=5e3){const u=e.dimensionSpecs[0]?.source??"",s=e.dimensionSpecs[0]?.model??"",{filterStates:d,updateFilter:c,clearAllFilters:l,getActiveFilters:m}=Ea({dimensionSpecs:e.dimensionSpecs}),p=I.useMemo(()=>m(),[d,m]),{data:h,noRowsMatchedFilter:g,isLoading:v,isError:x,error:y,refetch:C}=Da({environment:e.environment,package:e.package,indexLimit:e.indexLimit,dimensionSpecs:e.dimensionSpecs,versionId:e.versionId,activeFilters:p}),w=v&&!h,{embeddedQueryResult:k,queryString:O,executeQuery:M,canExecute:j}=Ia({environment:e.environment,package:e.package,model:s,source:u,filterSelections:p,limit:r,fields:e.selectFields});return{filterStates:d,updateFilter:c,clearAllFilters:l,activeFilters:p,data:h,noRowsMatchedFilter:g,isLoading:v,isInitialLoading:w,isError:x,error:y,refetch:C,embeddedQueryResult:k,queryString:O,executeQuery:M,canExecute:j}}function vh({modelPath:e,query:r,sourceName:u,queryName:s,enabled:d=!0,resourceUri:c}){const{environmentName:l,packageName:m,versionId:p}=o.parseResourceUri(c),{apiClients:h}=B.useServer(),{data:g,isSuccess:v,isError:x,error:y,isLoading:C}=o.useQueryWithApiError({queryKey:["rawQueryData",l,m,e,p,r,u,s],queryFn:({signal:k})=>h.models.executeQueryModel(l,m,e,{query:r,sourceName:u,queryName:s,versionId:p},void 0,{signal:k}),enabled:d});return{data:v&&g?.data?.result?(()=>{try{return JSON.parse(g.data.result).data?.array_value||[]}catch(k){return console.error("Failed to parse query result:",k),[]}})():[],isSuccess:v,isError:x,error:y,isLoading:C}}exports.AddButton=o.AddButton;exports.ApiErrorDisplay=o.ApiErrorDisplay;exports.AppDialog=o.AppDialog;exports.DRILL_SELF=o.DRILL_SELF;exports.DashboardTile=o.DashboardTile;exports.DashboardView=o.DashboardView;exports.DocumentNotFoundError=o.DocumentNotFoundError;exports.DocumentStorageProvider=o.DocumentStorageProvider;exports.GivenInput=o.GivenInput;exports.GivensPanel=o.GivensPanel;exports.INITIAL_RENDER_HEIGHT=o.INITIAL_RENDER_HEIGHT;exports.LOADING_COPY=o.LOADING_COPY;exports.Loading=o.Loading;exports.MODEL_CELL_MAX_HEIGHT=o.MODEL_CELL_MAX_HEIGHT;exports.MOTION_FAST=o.MOTION_FAST;exports.NOTEBOOK_CELL_MAX_HEIGHT=o.NOTEBOOK_CELL_MAX_HEIGHT;exports.Prose=o.Prose;exports.REPORT_EDIT_PARAM=o.REPORT_EDIT_PARAM;exports.RESTRICTED_NOTICE=o.RESTRICTED_NOTICE;exports.RESULTS_DIALOG_MAX_HEIGHT=o.RESULTS_DIALOG_MAX_HEIGHT;exports.ResultContainer=o.ResultContainer;exports.ResultPanel=o.ResultPanel;exports.STICKY_CONTROLS_Z=o.STICKY_CONTROLS_Z;exports.SecondaryButton=o.SecondaryButton;exports.TILE_MAX_HEIGHT=o.TILE_MAX_HEIGHT;exports.TILE_MIN_HEIGHT=o.TILE_MIN_HEIGHT;exports.TileCard=o.TileCard;exports.TileFilterTag=o.TileFilterTag;exports.TileHeading=o.TileHeading;exports.UNCAPPED_CONTAINER_HEIGHT=o.UNCAPPED_CONTAINER_HEIGHT;exports.UnsavedChangesDialog=o.UnsavedChangesDialog;exports.buildTableCssVars=o.buildTableCssVars;exports.contentNodeDepth=o.contentNodeDepth;exports.dangerTextColor=o.dangerTextColor;exports.documentPreamble=o.documentPreamble;exports.documentSlug=o.documentSlug;exports.drillDestinations=o.drillDestinations;exports.drillValueToFilter=o.drillValueToFilter;exports.encodeDrillValue=o.encodeDrillValue;exports.encodeResourceUri=o.encodeResourceUri;exports.humanizeSlug=o.humanizeSlug;exports.initialResultHeight=o.initialResultHeight;exports.isDocumentNotFound=o.isDocumentNotFound;exports.isDrillTargetPath=o.isDrillTargetPath;exports.locateReport=o.locateReport;exports.measureContentHeight=o.measureContentHeight;exports.parseResourceUri=o.parseResourceUri;exports.queryResultKey=o.queryResultKey;exports.reducedMotionSx=o.reducedMotionSx;exports.remeasuresAfterReady=o.remeasuresAfterReady;exports.reportEditRoute=o.reportEditRoute;exports.reportRoute=o.reportRoute;exports.reportRoutePath=o.reportRoutePath;exports.resolveDrill=o.resolveDrill;exports.resolveDrillTarget=o.resolveDrillTarget;exports.resolveResultHeight=o.resolveResultHeight;exports.resultSizing=o.resultSizing;exports.scrollBehavior=o.scrollBehavior;exports.tileIgnoredFilterLabels=o.tileIgnoredFilterLabels;exports.useCompiledDocument=o.useCompiledDocument;exports.useDocumentControls=o.useDocumentControls;exports.useDocumentLocation=o.useDocumentLocation;exports.useDocumentStorage=o.useDocumentStorage;exports.useDrill=o.useDrill;exports.useDrillSelf=o.useDrillSelf;exports.useGivensState=o.useGivensState;exports.useOptionalDocumentStorage=o.useOptionalDocumentStorage;exports.useQueryResult=o.useQueryResult;exports.useReportListing=o.useReportListing;exports.useSuggestOptions=o.useSuggestOptions;exports.visibleWithoutHoverSx=o.visibleWithoutHoverSx;exports.withPreamble=o.withPreamble;exports.DEFAULT_THEME=B.DEFAULT_THEME;exports.MONO_FONT_FAMILY=B.MONO_FONT_FAMILY;exports.PALETTE=B.PALETTE;exports.SURFACE_TINT=B.SURFACE_TINT;exports.ServerProvider=B.ServerProvider;exports.ThemeProvider=B.ThemeProvider;exports.accentFor=B.accentFor;exports.contrastRatio=B.contrastRatio;exports.resolveMode=B.resolveMode;exports.resolveTheme=B.resolveTheme;exports.usePublisherTheme=B.usePublisherTheme;exports.useServer=B.useServer;exports.canRetryRequest=zo.canRetryRequest;exports.DRILL_CELL_CLASS=en.DRILL_CELL_CLASS;exports.RenderedResult=en.RenderedResult;exports.buildMalloyExplicitTheme=en.buildMalloyExplicitTheme;exports.buildVegaThemeOverride=en.buildVegaThemeOverride;exports.drillableFieldNames=en.drillableFieldNames;exports.markDrillableCells=en.markDrillableCells;exports.readChartAnnotations=en.readChartAnnotations;exports.BackLink=hl;exports.BrowserDocumentStorage=Jd;exports.ConnectionExplorer=Qo;exports.DOC_LINKS=Rt;exports.Dashboard=rh;exports.DataAppViewer=vl;exports.DimensionFilter=Rc;exports.EmbeddedQueryResult=nh;exports.Environment=hc;exports.Home=Kc;exports.Materializations=da;exports.Model=hd;exports.ModelExplorer=hs;exports.ModelExplorerDialog=fs;exports.NarrowEditGate=fl;exports.NewDocumentDialog=Sa;exports.Notebook=oh;exports.Package=Zd;exports.Packages=Jo;exports.QueryResult=Oa;exports.Report=va;exports.SourcesExplorer=ma;exports.createEmbeddedQueryResult=Ta;exports.documentRoute=lh;exports.extractDimensionSpecs=qc;exports.extractSourceFromQuery=Hc;exports.generateFilterClause=zc;exports.getDimensionKey=Jt;exports.getJoinedSources=Pc;exports.injectWhereClause=Vc;exports.isNarrowScreen=Bo;exports.legacyAliasOf=ih;exports.locateDocument=ch;exports.locateReportByName=ja;exports.packageFileUrl=Yo;exports.parseAllSourceInfos=Wc;exports.parseDimensionFilterAnnotation=ea;exports.parseNotebookFilterAnnotation=Lc;exports.setConsoleEventHandler=$l;exports.useDimensionFilters=Ea;exports.useDimensionFiltersFromSpec=bh;exports.useDimensionFiltersQuery=Ia;exports.useDimensionalFilterRangeData=Da;exports.useDraftLayout=th;exports.useGivenUrlParams=gl;exports.useModelData=ds;exports.useModelGivens=ga;exports.useNarrowScreen=Vo;exports.useRawQueryData=vh;exports.useRouterClickHandler=pl;
|