@malloy-publisher/sdk 0.16.0 → 0.17.0
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-vyM2wQbC.es.js → RenderedResult-BcEDcw0V.es.js} +19 -19
- package/dist/{RenderedResult-DTM9o4Ql.cjs.js → RenderedResult-uT2oc6ke.cjs.js} +1 -1
- package/dist/ServerProvider-DDRwHiPz.cjs.js +1 -0
- package/dist/{ServerProvider-lAZ5ZdQS.es.js → ServerProvider-vmEUjlEu.es.js} +296 -285
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +286 -212
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +30 -29
- package/dist/index.cjs.js +5 -5
- package/dist/index.es.js +13 -5
- package/dist/{useCompiledDocument-2huaKTJN.cjs.js → useCompiledDocument-h5-Kc1Zh.cjs.js} +4 -4
- package/dist/{useCompiledDocument-CSXZufFO.es.js → useCompiledDocument-rOwDSK_s.es.js} +6 -2
- package/package.json +1 -1
- package/src/components/Dashboard/DashboardTile.spec.tsx +2 -1
- package/src/components/Dashboard/DownloadRowsCsv.tsx +2 -0
- package/src/components/Dashboard/RowsDialog.actions.spec.tsx +2 -1
- package/src/components/ModelViewer/useRunQuery.spec.ts +2 -2
- package/src/components/ModelViewer/useRunQuery.ts +2 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +2 -0
- package/src/hooks/useQueryResult.ts +2 -0
- package/src/hooks/useRawQueryData.ts +2 -0
- package/src/hooks/useSuggestOptions.ts +2 -0
- package/dist/ServerProvider-DpOy4_Kf.cjs.js +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var Gu=Object.create;var Si=Object.defineProperty;var Yu=Object.getOwnPropertyDescriptor;var Ku=Object.getOwnPropertyNames;var Qu=Object.getPrototypeOf,Zu=Object.prototype.hasOwnProperty;var Xu=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Ku(n))!Zu.call(e,i)&&i!==r&&Si(e,i,{get:()=>n[i],enumerable:!(o=Yu(n,i))||o.enumerable});return e};var ki=(e,n,r)=>(r=e!=null?Gu(Qu(e)):{},Xu(n||!e||!e.__esModule?Si(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("@mui/material"),j=require("react"),c=require("./useCompiledDocument-2huaKTJN.cjs.js"),q=require("./ServerProvider-DpOy4_Kf.cjs.js"),yt=require("@tanstack/react-query"),wr=require("@mui/system"),Pt=require("@mui/icons-material"),Ju=require("@malloydata/malloy-tag"),oo=require("./text-entry-BJwltZiy.cjs.js"),fn=require("./RenderedResult-DTM9o4Ql.cjs.js"),ed=require("@malloydata/malloy-filter"),Gr=require("react-router-dom");function td(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const Ce=td(j),nd=c.createSvgIcon(t.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}));function rd({label:e,href:n,onClick:r}){const o=i=>{const l=i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||i.button!==0;n!==void 0&&l||(i.preventDefault(),r(i))};return t.jsxs(p.Link,{...n===void 0?{component:"button",type:"button"}:{href:n},onClick:o,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:[t.jsx(nd,{sx:{fontSize:18}}),"Back to ",e]})}const Aa="(max-width:599.95px)";function Fa(){return p.useMediaQuery(Aa,{noSsr:!0})}function Ra(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Aa).matches}function sd({children:e}){const[n]=j.useState(Ra),[r,o]=j.useState(!1);return!n||r?t.jsx(t.Fragment,{children:e}):t.jsxs(p.Stack,{sx:{alignItems:"flex-start",gap:1.5,py:3},children:[t.jsx(p.Typography,{variant:"h6",children:"Editing works best on a larger screen"}),t.jsx(p.Typography,{variant:"body2",color:"text.secondary",children:"The editor is built for a wider window. You can still try it here."}),t.jsx(p.Button,{variant:"outlined",onClick:()=>o(!0),children:"Edit anyway"})]})}function od(){const e=Gr.useNavigate();return(n,r)=>{if(!r||!r.metaKey&&!r.ctrlKey&&!r.shiftKey&&r.button!==1){e(n);return}const o=new URL(n,window.location.href).href;(r.metaKey||r.ctrlKey||r.button===1||r.shiftKey)&&window.open(o,"_blank")}}function Na(e,n){return e.flatMap(({filter:r})=>{if(r.kind!=="literal_equality"||r.expression.kind!=="field_reference")return[];const o=id(r.value,n);return o===void 0?[]:[{field:r.expression.name,label:o,expression:r.expression}]})}function La(e,n){switch(e.kind){case"string_literal":return`'${c.escapeMalloyString(e.string_value)}'`;case"number_literal":return e.string_value!==void 0?/^-?\d+(\.\d+)?$/.test(e.string_value)?e.string_value:void 0:Number.isFinite(e.number_value)?String(e.number_value):void 0;case"boolean_literal":return String(e.boolean_value);case"date_literal":{const r=_a(e.date_value);return r&&`@${r[0]}-${r[1]}-${r[2]}`}case"timestamp_literal":{const r=za(e.timestamp_value,n);return r&&`@${r[0]}-${r[1]}-${r[2]} ${r[3]}:${r[4]}:${r[5]}${Pa(e.timestamp_value)}`}default:return}}function id(e,n){switch(e.kind){case"string_literal":return e.string_value;case"null_literal":return"null";case"date_literal":{const r=_a(e.date_value);return r&&Ci([...r,"00","00","00"],e.granularity??"day")}case"timestamp_literal":{const r=za(e.timestamp_value,n);return r&&Ci(r,e.granularity??"second")+(e.granularity===void 0?Pa(e.timestamp_value):"")}default:return La(e)}}function _a(e){const n=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);return n?[n[1],n[2],n[3]]:void 0}function Pa(e){const n=/:\d{2}\.(\d+)/.exec(e)?.[1]?.replace(/0+$/,"");return n?`.${n}`:""}function za(e,n){const r=new Date(e);if(Number.isNaN(r.getTime()))return;let o;try{o=new Intl.DateTimeFormat("en-US",{timeZone:n??"UTC",hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(r)}catch{return}const i=l=>o.find(a=>a.type===l)?.value??"";return[i("year").padStart(4,"0"),i("month"),i("day"),i("hour"),i("minute"),i("second")]}function Ci([e,n,r,o,i,l],a){switch(a){case"year":return e;case"quarter":return`${e}-Q${Math.floor((Number(n)-1)/3)+1}`;case"month":return`${e}-${n}`;case"week":case"day":return`${e}-${n}-${r}`;case"hour":return`${e}-${n}-${r} ${o}`;case"minute":return`${e}-${n}-${r} ${o}:${i}`;default:return`${e}-${n}-${r} ${o}:${i}:${l}`}}const ad="drill_metadata_corrected",Zr=e=>e,Rn=e=>{try{return e?.()}catch{return}},Wa=e=>Rn(e.isBasic?.bind(e))===!0&&Rn(e.wasDimension?.bind(e))===!0,ld=e=>[e.isString,e.isNumber,e.isBoolean,e.isTime].some(n=>Rn(n?.bind(e))===!0);function Xr(e){const n=e.metadataTag?.text("drill_expression","code");return n===void 0||n.trim()===""?void 0:n}function qa(e){const n=[];for(let r=e.parent;r;r=r.parent)n.push(r);return n}function Ba(e){const n=qa(e),o=(n[n.length-1]??e).metadataTag,i=o?.text("source","name");if(!i||!o?.array||o.array("source","parameters")!==void 0||o.has?.(ad)!==!0)return;const l=[];for(const d of[...n].reverse())if(Rn(d.isArray?.bind(d))===!0){if(d.metadataTag?.has?.("drillable")!==!0)return;for(const u of d.metadataTag?.array?.("drill_filters")??[]){const h=u.text("code");if(!h)return;l.push(h)}}const a=o?.text("query_name");return{source:i,filters:l,...a&&!a.startsWith("__")?{queryName:a}:{}}}function Er(e){const n=new Set;for(const r of qa(e))for(const o of r.fields??[])Wa(o)&&n.add(o);return[...n]}function Va(e){const n=new Set(Er(e).filter(r=>Rn(r.isTime?.bind(r))===!0).map(r=>Rn(r.getEffectiveQueryTimezone?.bind(r))));return n.size>1?null:[...n][0]}function ji(e){return!Wa(e)||Xr(e)===void 0||Ba(e)===void 0||Va(e)===null?!1:Er(e).every(n=>Xr(n)!==void 0&&n.drillStableExpression!==void 0&&ld(n))}function cd(e,n){const r=Er(e),o=[],i=new Set;for(const l of n){if(l.kind==="drill")continue;const{filter:a}=l;if(a.kind!=="literal_equality")return;const d=JSON.stringify(a.expression),u=r.find(y=>JSON.stringify(y.drillStableExpression)===d),h=u&&Xr(u);if(u===void 0||h===void 0)return;o.push({code:h,value:a.value}),i.add(u)}return r.every(l=>i.has(l))&&o.length>0?o:void 0}const ud=360;function Us(e){return e?e.getLabel?.()??e.tag?.text("label")??Zr(e).metadataTag?.text("label")??e.name:""}function dd(e,n){const r=e.drillClauses?Na(e.drillClauses,e.timezone):[];if(r.length===0)return`${Us(n)}: ${e.label}`;const o=Er(Zr(n));return r.map(i=>{const l=JSON.stringify(i.expression),a=o.find(d=>JSON.stringify(d.drillStableExpression)===l);return`${a?Us(a):i.field}: ${i.label}`}).join(", ")}function io({onNavigate:e,onSelf:n,destinationTitle:r,canSelf:o,onRows:i}){const[l,a]=j.useState(null),d=j.useCallback((S,T)=>S.filter(O=>O===c.DRILL_SELF?n!==void 0&&(o?.(T)??!0):e!==void 0),[e,n,o]),u=j.useCallback((S,T,O)=>{if(T===c.DRILL_SELF){n?.(S.given,S.rawValue);return}e?.({path:T,dashboard:T,givens:{[S.given]:S.value}},O)},[e,n]),h=j.useCallback(S=>{if(!i||S.noRows||S.isHeader||!S.field)return;const T=Zr(S.field);if(!ji(T))return;const O=Ba(T);if(O===void 0)return;const M=S.drillClauses;let E;if(M!==void 0){const P=cd(T,M);if(P===void 0)return;E={dimensions:P}}else{const P=Xr(T);if(P===void 0||Er(T).length!==1||c.drillValueToFilter(S.value)===void 0||typeof S.value=="number"&&Number.isInteger(S.value)&&!Number.isSafeInteger(S.value))return;E={code:P}}const R=Va(T)??void 0;return{field:S.field.name,rawValue:S.value,label:c.drillValueLabel(S.value),target:O,...E,...S.context===void 0?{}:{context:S.context},...M===void 0?{}:{drillClauses:M},...R===void 0?{}:{timezone:R}}},[i]),y=j.useCallback(S=>{const T=c.resolveDrill(S),O=h(S),M=T?Array.from(new Set(d(T.to,T.given))).sort((P,A)=>+(A===c.DRILL_SELF)-+(P===c.DRILL_SELF)):[],E=`${Us(S.field)}: ${T?.label??c.drillValueLabel(S.value)}`,R=M.map(P=>({key:`to:${P}`,label:P===c.DRILL_SELF?`Filter to ${E}`:`Open ${r?.(P)??c.humanizeSlug(P.split("/").pop()??P)} (${E})`,run:()=>{T&&u(T,P,S.event)}}));O&&S.field&&R.push({key:"rows",label:`Show rows (${dd(O,S.field)})`,run:()=>i?.(O)}),R.length!==0&&a({items:R,top:S.event?.clientY??0,left:S.event?.clientX??0})},[u,d,i,h,r]),b=j.useCallback(S=>d(c.drillDestinations(S),c.drillGivenName(S)).length>0,[d]),x=j.useCallback(S=>i!==void 0&&ji(Zr(S)),[i]),v=j.useMemo(()=>({onClick:y,canDrill:S=>b(S)||x(S)}),[y,b,x]),k=j.useCallback((S,T)=>({canDrill:O=>b(O)||T&&x(O),onClick:O=>y({...O,...S===void 0?{}:{context:S},...T?{}:{noRows:!0}})}),[y,b,x]),C=j.useCallback(()=>a(null),[]);return{drill:v,bindingFor:k,drillMenu:t.jsx(p.Menu,{open:l!==null,onClose:C,anchorReference:"anchorPosition",anchorPosition:{top:l?.top??0,left:l?.left??0},children:(l?.items??[]).map(S=>t.jsx(p.MenuItem,{title:S.label,"aria-label":S.label,onClick:()=>{C(),S.run()},sx:{maxWidth:ud},children:t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.label})},S.key))})}}const hd=e=>{const n=Ce.useRef({});return Ce.useEffect(()=>{n.current=e}),n.current};function fd(){const[e]=Gr.useSearchParams(),n=Gr.useNavigate(),r=Gr.useLocation(),o=j.useMemo(()=>Object.fromEntries(e.entries()),[e]),i=j.useRef(new Set),l=j.useRef(null),a=j.useCallback(h=>{const y=l.current,b=new URLSearchParams(y?.key===r.key?y.search:r.search);h(b);const x=b.toString();l.current={key:r.key,search:x},n({search:x,hash:r.hash},{replace:!0})},[n,r]),d=j.useCallback((h,y)=>{const b=new Set([...y,...i.current]);i.current=new Set([...i.current,...Object.keys(h),...y]),a(x=>{for(const v of b)Object.prototype.hasOwnProperty.call(h,v)||x.delete(v);for(const[v,k]of Object.entries(h))x.set(v,k)})},[a]),u=j.useCallback((h,y)=>a(b=>{y===void 0?b.delete(h):b.set(h,y)}),[a]);return{params:o,onGivensChange:d,setParam:u}}const md=c.createSvgIcon(t.jsx("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}));function fr(e){return/^[=+\-@\t\r]/.test(e)?`'${e}`:e}function mr(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function pd(e){if(e===void 0)return"";switch(e.kind){case"null_cell":return"";case"number_cell":return e.string_value??String(e.number_value);case"boolean_cell":return e.boolean_value?"true":"false";case"date_cell":return e.date_value;case"timestamp_cell":return e.timestamp_value;case"string_cell":return mr(fr(e.string_value));case"json_cell":return mr(fr(e.json_value));case"sql_native_cell":return mr(fr(e.sql_native_value));default:return mr(fr(JSON.stringify(e)))}}function Ha(e){const n=e.data;return n?.kind!=="array_cell"?[]:n.array_value.flatMap(r=>r.kind==="record_cell"?[r.record_value]:[])}function gd(e){const n=e.schema.fields;return`\uFEFF${[n.map(o=>mr(fr(o.name))).join(","),...Ha(e).map(o=>n.map((i,l)=>pd(o[l])).join(","))].join(`\r
|
|
1
|
+
"use strict";var Gu=Object.create;var Si=Object.defineProperty;var Yu=Object.getOwnPropertyDescriptor;var Ku=Object.getOwnPropertyNames;var Qu=Object.getPrototypeOf,Zu=Object.prototype.hasOwnProperty;var Xu=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Ku(n))!Zu.call(e,i)&&i!==r&&Si(e,i,{get:()=>n[i],enumerable:!(o=Yu(n,i))||o.enumerable});return e};var ki=(e,n,r)=>(r=e!=null?Gu(Qu(e)):{},Xu(n||!e||!e.__esModule?Si(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("@mui/material"),j=require("react"),c=require("./useCompiledDocument-h5-Kc1Zh.cjs.js"),q=require("./ServerProvider-DDRwHiPz.cjs.js"),yt=require("@tanstack/react-query"),wr=require("@mui/system"),Pt=require("@mui/icons-material"),Ju=require("@malloydata/malloy-tag"),oo=require("./text-entry-BJwltZiy.cjs.js"),fn=require("./RenderedResult-uT2oc6ke.cjs.js"),ed=require("@malloydata/malloy-filter"),Gr=require("react-router-dom");function td(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const Ce=td(j),nd=c.createSvgIcon(t.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}));function rd({label:e,href:n,onClick:r}){const o=i=>{const l=i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||i.button!==0;n!==void 0&&l||(i.preventDefault(),r(i))};return t.jsxs(p.Link,{...n===void 0?{component:"button",type:"button"}:{href:n},onClick:o,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:[t.jsx(nd,{sx:{fontSize:18}}),"Back to ",e]})}const Aa="(max-width:599.95px)";function Fa(){return p.useMediaQuery(Aa,{noSsr:!0})}function Ra(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Aa).matches}function sd({children:e}){const[n]=j.useState(Ra),[r,o]=j.useState(!1);return!n||r?t.jsx(t.Fragment,{children:e}):t.jsxs(p.Stack,{sx:{alignItems:"flex-start",gap:1.5,py:3},children:[t.jsx(p.Typography,{variant:"h6",children:"Editing works best on a larger screen"}),t.jsx(p.Typography,{variant:"body2",color:"text.secondary",children:"The editor is built for a wider window. You can still try it here."}),t.jsx(p.Button,{variant:"outlined",onClick:()=>o(!0),children:"Edit anyway"})]})}function od(){const e=Gr.useNavigate();return(n,r)=>{if(!r||!r.metaKey&&!r.ctrlKey&&!r.shiftKey&&r.button!==1){e(n);return}const o=new URL(n,window.location.href).href;(r.metaKey||r.ctrlKey||r.button===1||r.shiftKey)&&window.open(o,"_blank")}}function Na(e,n){return e.flatMap(({filter:r})=>{if(r.kind!=="literal_equality"||r.expression.kind!=="field_reference")return[];const o=id(r.value,n);return o===void 0?[]:[{field:r.expression.name,label:o,expression:r.expression}]})}function La(e,n){switch(e.kind){case"string_literal":return`'${c.escapeMalloyString(e.string_value)}'`;case"number_literal":return e.string_value!==void 0?/^-?\d+(\.\d+)?$/.test(e.string_value)?e.string_value:void 0:Number.isFinite(e.number_value)?String(e.number_value):void 0;case"boolean_literal":return String(e.boolean_value);case"date_literal":{const r=_a(e.date_value);return r&&`@${r[0]}-${r[1]}-${r[2]}`}case"timestamp_literal":{const r=za(e.timestamp_value,n);return r&&`@${r[0]}-${r[1]}-${r[2]} ${r[3]}:${r[4]}:${r[5]}${Pa(e.timestamp_value)}`}default:return}}function id(e,n){switch(e.kind){case"string_literal":return e.string_value;case"null_literal":return"null";case"date_literal":{const r=_a(e.date_value);return r&&Ci([...r,"00","00","00"],e.granularity??"day")}case"timestamp_literal":{const r=za(e.timestamp_value,n);return r&&Ci(r,e.granularity??"second")+(e.granularity===void 0?Pa(e.timestamp_value):"")}default:return La(e)}}function _a(e){const n=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);return n?[n[1],n[2],n[3]]:void 0}function Pa(e){const n=/:\d{2}\.(\d+)/.exec(e)?.[1]?.replace(/0+$/,"");return n?`.${n}`:""}function za(e,n){const r=new Date(e);if(Number.isNaN(r.getTime()))return;let o;try{o=new Intl.DateTimeFormat("en-US",{timeZone:n??"UTC",hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(r)}catch{return}const i=l=>o.find(a=>a.type===l)?.value??"";return[i("year").padStart(4,"0"),i("month"),i("day"),i("hour"),i("minute"),i("second")]}function Ci([e,n,r,o,i,l],a){switch(a){case"year":return e;case"quarter":return`${e}-Q${Math.floor((Number(n)-1)/3)+1}`;case"month":return`${e}-${n}`;case"week":case"day":return`${e}-${n}-${r}`;case"hour":return`${e}-${n}-${r} ${o}`;case"minute":return`${e}-${n}-${r} ${o}:${i}`;default:return`${e}-${n}-${r} ${o}:${i}:${l}`}}const ad="drill_metadata_corrected",Zr=e=>e,Rn=e=>{try{return e?.()}catch{return}},Wa=e=>Rn(e.isBasic?.bind(e))===!0&&Rn(e.wasDimension?.bind(e))===!0,ld=e=>[e.isString,e.isNumber,e.isBoolean,e.isTime].some(n=>Rn(n?.bind(e))===!0);function Xr(e){const n=e.metadataTag?.text("drill_expression","code");return n===void 0||n.trim()===""?void 0:n}function qa(e){const n=[];for(let r=e.parent;r;r=r.parent)n.push(r);return n}function Ba(e){const n=qa(e),o=(n[n.length-1]??e).metadataTag,i=o?.text("source","name");if(!i||!o?.array||o.array("source","parameters")!==void 0||o.has?.(ad)!==!0)return;const l=[];for(const d of[...n].reverse())if(Rn(d.isArray?.bind(d))===!0){if(d.metadataTag?.has?.("drillable")!==!0)return;for(const u of d.metadataTag?.array?.("drill_filters")??[]){const h=u.text("code");if(!h)return;l.push(h)}}const a=o?.text("query_name");return{source:i,filters:l,...a&&!a.startsWith("__")?{queryName:a}:{}}}function Er(e){const n=new Set;for(const r of qa(e))for(const o of r.fields??[])Wa(o)&&n.add(o);return[...n]}function Va(e){const n=new Set(Er(e).filter(r=>Rn(r.isTime?.bind(r))===!0).map(r=>Rn(r.getEffectiveQueryTimezone?.bind(r))));return n.size>1?null:[...n][0]}function ji(e){return!Wa(e)||Xr(e)===void 0||Ba(e)===void 0||Va(e)===null?!1:Er(e).every(n=>Xr(n)!==void 0&&n.drillStableExpression!==void 0&&ld(n))}function cd(e,n){const r=Er(e),o=[],i=new Set;for(const l of n){if(l.kind==="drill")continue;const{filter:a}=l;if(a.kind!=="literal_equality")return;const d=JSON.stringify(a.expression),u=r.find(y=>JSON.stringify(y.drillStableExpression)===d),h=u&&Xr(u);if(u===void 0||h===void 0)return;o.push({code:h,value:a.value}),i.add(u)}return r.every(l=>i.has(l))&&o.length>0?o:void 0}const ud=360;function Us(e){return e?e.getLabel?.()??e.tag?.text("label")??Zr(e).metadataTag?.text("label")??e.name:""}function dd(e,n){const r=e.drillClauses?Na(e.drillClauses,e.timezone):[];if(r.length===0)return`${Us(n)}: ${e.label}`;const o=Er(Zr(n));return r.map(i=>{const l=JSON.stringify(i.expression),a=o.find(d=>JSON.stringify(d.drillStableExpression)===l);return`${a?Us(a):i.field}: ${i.label}`}).join(", ")}function io({onNavigate:e,onSelf:n,destinationTitle:r,canSelf:o,onRows:i}){const[l,a]=j.useState(null),d=j.useCallback((S,T)=>S.filter(O=>O===c.DRILL_SELF?n!==void 0&&(o?.(T)??!0):e!==void 0),[e,n,o]),u=j.useCallback((S,T,O)=>{if(T===c.DRILL_SELF){n?.(S.given,S.rawValue);return}e?.({path:T,dashboard:T,givens:{[S.given]:S.value}},O)},[e,n]),h=j.useCallback(S=>{if(!i||S.noRows||S.isHeader||!S.field)return;const T=Zr(S.field);if(!ji(T))return;const O=Ba(T);if(O===void 0)return;const M=S.drillClauses;let E;if(M!==void 0){const P=cd(T,M);if(P===void 0)return;E={dimensions:P}}else{const P=Xr(T);if(P===void 0||Er(T).length!==1||c.drillValueToFilter(S.value)===void 0||typeof S.value=="number"&&Number.isInteger(S.value)&&!Number.isSafeInteger(S.value))return;E={code:P}}const R=Va(T)??void 0;return{field:S.field.name,rawValue:S.value,label:c.drillValueLabel(S.value),target:O,...E,...S.context===void 0?{}:{context:S.context},...M===void 0?{}:{drillClauses:M},...R===void 0?{}:{timezone:R}}},[i]),y=j.useCallback(S=>{const T=c.resolveDrill(S),O=h(S),M=T?Array.from(new Set(d(T.to,T.given))).sort((P,A)=>+(A===c.DRILL_SELF)-+(P===c.DRILL_SELF)):[],E=`${Us(S.field)}: ${T?.label??c.drillValueLabel(S.value)}`,R=M.map(P=>({key:`to:${P}`,label:P===c.DRILL_SELF?`Filter to ${E}`:`Open ${r?.(P)??c.humanizeSlug(P.split("/").pop()??P)} (${E})`,run:()=>{T&&u(T,P,S.event)}}));O&&S.field&&R.push({key:"rows",label:`Show rows (${dd(O,S.field)})`,run:()=>i?.(O)}),R.length!==0&&a({items:R,top:S.event?.clientY??0,left:S.event?.clientX??0})},[u,d,i,h,r]),b=j.useCallback(S=>d(c.drillDestinations(S),c.drillGivenName(S)).length>0,[d]),x=j.useCallback(S=>i!==void 0&&ji(Zr(S)),[i]),v=j.useMemo(()=>({onClick:y,canDrill:S=>b(S)||x(S)}),[y,b,x]),k=j.useCallback((S,T)=>({canDrill:O=>b(O)||T&&x(O),onClick:O=>y({...O,...S===void 0?{}:{context:S},...T?{}:{noRows:!0}})}),[y,b,x]),C=j.useCallback(()=>a(null),[]);return{drill:v,bindingFor:k,drillMenu:t.jsx(p.Menu,{open:l!==null,onClose:C,anchorReference:"anchorPosition",anchorPosition:{top:l?.top??0,left:l?.left??0},children:(l?.items??[]).map(S=>t.jsx(p.MenuItem,{title:S.label,"aria-label":S.label,onClick:()=>{C(),S.run()},sx:{maxWidth:ud},children:t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.label})},S.key))})}}const hd=e=>{const n=Ce.useRef({});return Ce.useEffect(()=>{n.current=e}),n.current};function fd(){const[e]=Gr.useSearchParams(),n=Gr.useNavigate(),r=Gr.useLocation(),o=j.useMemo(()=>Object.fromEntries(e.entries()),[e]),i=j.useRef(new Set),l=j.useRef(null),a=j.useCallback(h=>{const y=l.current,b=new URLSearchParams(y?.key===r.key?y.search:r.search);h(b);const x=b.toString();l.current={key:r.key,search:x},n({search:x,hash:r.hash},{replace:!0})},[n,r]),d=j.useCallback((h,y)=>{const b=new Set([...y,...i.current]);i.current=new Set([...i.current,...Object.keys(h),...y]),a(x=>{for(const v of b)Object.prototype.hasOwnProperty.call(h,v)||x.delete(v);for(const[v,k]of Object.entries(h))x.set(v,k)})},[a]),u=j.useCallback((h,y)=>a(b=>{y===void 0?b.delete(h):b.set(h,y)}),[a]);return{params:o,onGivensChange:d,setParam:u}}const md=c.createSvgIcon(t.jsx("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}));function fr(e){return/^[=+\-@\t\r]/.test(e)?`'${e}`:e}function mr(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function pd(e){if(e===void 0)return"";switch(e.kind){case"null_cell":return"";case"number_cell":return e.string_value??String(e.number_value);case"boolean_cell":return e.boolean_value?"true":"false";case"date_cell":return e.date_value;case"timestamp_cell":return e.timestamp_value;case"string_cell":return mr(fr(e.string_value));case"json_cell":return mr(fr(e.json_value));case"sql_native_cell":return mr(fr(e.sql_native_value));default:return mr(fr(JSON.stringify(e)))}}function Ha(e){const n=e.data;return n?.kind!=="array_cell"?[]:n.array_value.flatMap(r=>r.kind==="record_cell"?[r.record_value]:[])}function gd(e){const n=e.schema.fields;return`\uFEFF${[n.map(o=>mr(fr(o.name))).join(","),...Ha(e).map(o=>n.map((i,l)=>pd(o[l])).join(","))].join(`\r
|
|
2
2
|
`)}\r
|
|
3
|
-
`}function yd(e,n){return[e,"rows",...n].join("_").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").replace(/^[_.]+|[_.]+$/g,"").slice(0,120)||"rows"}function xd(e,n,r){return r==="server_default"&&n!==void 0&&e>=n?n:void 0}const Ti="Download the rows behind this value as CSV, up to the server's row limit",vd=4e4;function bd(e,n){const r=URL.createObjectURL(new Blob([e],{type:"text/csv;charset=utf-8"})),o=document.createElement("a");o.href=r,o.download=n,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),vd)}function wd(e){const r=e?.response?.data?.message;return typeof r=="string"&&r!==""?r:e instanceof Error&&e.message!==""?e.message:"The request failed."}function Ua({query:e,preamble:n,environmentName:r,packageName:o,modelPath:i,versionId:l,givens:a,fileName:d}){const{apiClients:u}=q.useServer(),[h,y]=j.useState(!1),[b,x]=j.useState(Ti),[v,k]=j.useState(void 0),C=j.useRef(void 0);j.useEffect(()=>()=>C.current?.abort(),[]);const S=async()=>{C.current?.abort();const T=new AbortController;C.current=T,y(!0),k(void 0);try{const O=await u.models.executeQueryModel(r,o,i,{query:n===void 0?e:c.withPreamble(n,e),givens:a,versionId:l},void 0,{signal:T.signal});if(T.signal.aborted)return;const M=O.data,E=JSON.parse(M.result??"{}"),R=xd(Ha(E).length,M.queryRowLimit,M.queryRowLimitSource);x(R===void 0?Ti:`First ${R} rows: the server's row limit, so there may be more`),bd(gd(E),R===void 0?`${d}.csv`:`${d}_first_${R}_rows_server_limit.csv`)}catch(O){if(T.signal.aborted)return;k(`Download failed: ${wd(O)}`)}finally{C.current===T&&(C.current=void 0,y(!1))}};return t.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[v&&t.jsx(p.Typography,{role:"alert",variant:"caption",color:"error",sx:{maxWidth:320},children:v}),t.jsx(p.Tooltip,{title:b,children:t.jsx("span",{children:t.jsx(p.Button,{size:"small",startIcon:t.jsx(md,{fontSize:"small"}),onClick:()=>void S(),disabled:h,children:"Download CSV"})})})]})}const Ga=200;function Sd(e){const{target:n}=e;if(n!==void 0&&!(e.dimensions===void 0&&e.code===void 0))return{...e,target:n}}function Oi(e,n=Ga){const r=Cd(e);if(r===void 0)return;const o=[...e.target.filters,...r].join(", "),i=e.timezone?`timezone: '${c.escapeMalloyString(e.timezone)}'; `:"",l=n===null?"":`; limit: ${n}`,a=kd(e.target.source);if(a!==void 0)return`run: ${a} -> { ${i}where: ${o}; select: *${l} }`}function kd(e){return oo.isBareName(e)?e:e.includes("`")?void 0:`\`${e}\``}function js(e){return/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(e)?e:`(${e})`}function Cd(e){if(e.dimensions){const r=[];for(const{code:o,value:i}of e.dimensions){if(i.kind==="null_literal"){r.push(`${js(o)} is null`);continue}const l=La(i,e.timezone);if(l===void 0)return;r.push(`${js(o)} = ${l}`)}return r}const n=c.malloyLiteral(e.rawValue);return e.code!==void 0&&n?[`${js(e.code)} = ${n}`]:void 0}const jd="This value cannot be written as a filter, so its rows cannot be fetched.";function Mi(e){const n=e.drillClauses?Na(e.drillClauses,e.timezone):[];return n.length>0?n:[{field:e.field,label:e.label}]}function Td({request:e,environmentName:n,packageName:r,versionId:o,modelPath:i,preamble:l,givens:a,onClose:d,onDone:u,actions:h}){const{theme:y}=q.usePublisherTheme(),b=e?Oi(e):void 0,x=e?Oi(e,null):void 0,v=e&&x!==void 0?{query:x,...l===void 0?{}:{preamble:l},environmentName:n,packageName:r,modelPath:i,...o===void 0?{}:{versionId:o},givens:a,fileName:yd(e.target.source,Mi(e).map(k=>k.label))}:void 0;return t.jsxs(p.Dialog,{open:e!==void 0,onClose:d,maxWidth:"lg",fullWidth:!0,children:[t.jsxs(p.DialogTitle,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",pb:.5},children:[t.jsxs(p.Box,{children:[e?t.jsxs(t.Fragment,{children:["Rows where"," ",Mi(e).map((k,C)=>t.jsxs(j.Fragment,{children:[C>0&&" and ",t.jsx(p.Box,{component:"code",sx:{fontSize:"0.9em"},children:k.field})," ","is ",k.label]},C))]}):"Rows",t.jsx(p.Typography,{component:"div",variant:"caption",sx:{color:y.tileTitle,mt:.25},children:e?`The first ${Ga} rows of ${e.target.source} behind this value, with the tile's own filters and the controls applied.`:""})]}),t.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:1,ml:1},children:[v&&(h?h(v):t.jsx(Ua,{...v})),t.jsx(p.IconButton,{onClick:d,"aria-label":"Close",size:"small",sx:{color:"text.secondary"},children:t.jsx(c.CloseIcon,{fontSize:"small"})})]})]}),t.jsxs(p.DialogContent,{dividers:!0,sx:{p:0,minHeight:240},children:[b===void 0&&e&&t.jsx(p.Typography,{variant:"body2",sx:{p:2},children:jd}),b!==void 0&&t.jsx(Od,{query:l===void 0?b:c.withPreamble(l,b),environmentName:n,packageName:r,...o===void 0?{}:{versionId:o},modelPath:i,givens:a,...u?{onDone:u}:{}})]}),t.jsxs(p.DialogActions,{sx:{px:3,py:1.5},children:[b!==void 0&&t.jsx(p.Typography,{variant:"caption",sx:{mr:"auto",color:y.tileTitle,fontFamily:y.ui.font.mono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:b,children:b}),t.jsx(p.Button,{onClick:d,children:"Close"})]})]})}function Od({query:e,environmentName:n,packageName:r,versionId:o,modelPath:i,givens:l,onDone:a}){const d=c.useQueryResult({environmentName:n,packageName:r,modelPath:i,...o===void 0?{}:{versionId:o},query:e,givens:l}),{isSuccess:u,isError:h}=d,y=j.useRef(void 0);return j.useEffect(()=>{y.current=c.now()},[e]),j.useEffect(()=>{y.current===void 0||!u&&!h||(a?.(u,c.now()-y.current),y.current=void 0)},[u,h,a]),t.jsx(p.Box,{sx:{p:1},children:t.jsx(c.ResultPanel,{state:d,context:e})})}function rs({manifest:e,environmentName:n,packageName:r,versionId:o,documentName:i,givens:l,onGivensChange:a,onNavigate:d,height:u,maxResultSize:h,controlsLayout:y="bar",preamble:b,runModelPath:x,hiddenGivens:v,literalReads:k,onLinkNavigate:C,actions:S,rowsActions:T}){const O=j.useMemo(()=>C?{environmentName:n,packageName:r,sourcePath:e.path??i,onNavigate:C}:void 0,[n,r,e.path,i,C]),M=j.useMemo(()=>(e.givens??[]).filter(oe=>!(b!==void 0&&oe.secure===!0)&&!(oe.name!==void 0&&v?.includes(oe.name))),[e,v,b]),E=j.useMemo(()=>l===void 0?void 0:Object.fromEntries(Object.entries(l).filter(([,oe])=>typeof oe=="string")),[l]),R=c.useDocumentControls({specs:M,loaded:!0,startingValues:e.startingGivens,params:E,onGivensChange:a,documentKey:`${n}/${r}/${o??""}/${i}`,autorun:e.autorun!==!1,environmentName:n,packageName:r,modelPath:x??e.path,versionId:o,documentName:i,...b!==void 0?{preamble:b}:{},...l?{hostGivens:l}:{}}),{applied:P,declaredTypes:A,canSelf:H,onSelf:D}=R,L=c.useReportEvents(),U=j.useMemo(()=>{const oe=new Set((e.tiles??[]).flatMap(K=>K.givenNames??[]));return Object.fromEntries(Object.entries(l??{}).filter(([K])=>oe.has(K)&&!A.has(K)))},[e,l,A]),[$,W]=j.useState(void 0),Q=j.useCallback(oe=>{const K=Sd(oe);K!==void 0&&W(K)},[]),te=j.useMemo(()=>c.withHostGivens(c.givensToRequest(P,A),U),[P,A,U]),{reports:ee}=c.useReportListing(n,r,o,d!==void 0),G=j.useCallback(oe=>{const K=c.resolveDrillTarget(oe,ee);if(K.kind!=="path")return;const le=K.report.path;return ee.find(be=>be.path===le)?.title||void 0},[ee]),{bindingFor:Z,drillMenu:ae}=io({onNavigate:d,onSelf:D,canSelf:H,onRows:Q,destinationTitle:G}),z=j.useCallback((oe,K)=>Z(oe,K!==!0),[Z]),{columns:re,layout:se,tileMaxHeight:ne,tableMaxHeight:Ie}=c.layoutRules(e.layout,e.dashboardColumns),de=j.useMemo(()=>c.missingRequiredGivens(M,P,l),[M,P,l]);if(e.error)return t.jsx(c.ReportPage,{layout:se,header:t.jsx(Ei,{manifest:e,links:O,actions:S}),children:t.jsx(p.Alert,{severity:"error",children:e.error})});const pe=x??e.path,De=e.tiles??[],Le=c.isPlaced(De);return t.jsxs(c.ReportPage,{layout:se,header:t.jsx(Ei,{manifest:e,links:O,actions:S}),controls:M.length>0?t.jsx(c.StickyControls,{children:t.jsx(c.GivensPanel,{...R.panel,layout:y})}):void 0,children:[de.length>0&&t.jsx(p.Alert,{severity:"info",children:c.requiredPrompt(de)}),pe===void 0?t.jsx(p.Alert,{severity:"error",children:"This dashboard has no model path, so there is nothing to run."}):De.length>0?t.jsx(c.DashboardGrid,{tiles:De,columns:re,minTilePx:c.MIN_TILE_PX,rowGapPx:c.GRID_GAP_PX,keyOf:(oe,K)=>`${K}:${oe.kind==="text"?`text:${oe.name}`:oe.query}`,renderTile:(oe,K)=>oe.kind==="text"||oe.query===void 0?t.jsx(p.Box,{sx:oe.rowspan!==void 0||Le?{minHeight:0,overflow:"auto"}:void 0,children:t.jsx(Md,{markdown:oe.markdown??"",links:O})}):t.jsx(c.DashboardTile,{index:K,environmentName:n,packageName:r,versionId:o,modelPath:pe,tile:oe.query,label:oe.label,subtitle:oe.subtitle,borderless:oe.borderless,givens:P,hostGivens:U,declaredTypes:A,givenNames:oe.givenNames,height:oe.rowspan!==void 0||Le?c.tileHeightPx(oe.rowspan??c.PLACED_DEFAULT_ROWSPAN.query):se==="grid"?u??ne:ne,tableMaxHeight:Ie,fixedHeight:oe.rowspan!==void 0||Le,maxResultSize:h,drill:z(oe.query,oe.restricted),ignoredFilters:c.tileIgnoredFilterLabels(oe.givenNames&&(oe.query&&k?.[oe.query]?[...oe.givenNames,...k[oe.query]]:oe.givenNames),M),...b!==void 0?{preamble:b,restricted:oe.restricted}:{},...(()=>{const le=c.waitingOn(de,oe.givenNames);return le.length>0?{waitingFor:c.waitingText(le)}:{}})()})}):t.jsx(p.Alert,{severity:"warning",children:"This dashboard names neither a query nor any tiles."}),ae,pe!==void 0&&t.jsx(Td,{request:$,environmentName:n,packageName:r,...o===void 0?{}:{versionId:o},modelPath:pe,...b===void 0?{}:{preamble:b},givens:te,...T===void 0?{}:{actions:T},onClose:()=>W(void 0),onDone:(oe,K)=>{$&&L.emit({type:"report.rows_shown",source:$.target.source,view:$.target.queryName??"",field:$.field,ok:oe,durationMs:K})}})]})}function Md({markdown:e,links:n}){return t.jsx(c.TextTileFrame,{children:t.jsx(c.Prose,{variant:"document",links:n,children:e})})}function Ei({manifest:e,links:n,actions:r}){return t.jsx(c.ReportHeader,{title:e.title??e.name,actions:r,description:e.description?t.jsx(c.TextTileFrame,{children:t.jsx(c.Prose,{variant:"document",links:n,children:e.description})}):void 0})}const Ya=c.createSvgIcon(t.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"})),Ed="publisher:resize";function Id(e){return typeof e=="object"&&e!==null&&e.type===Ed&&typeof e.height=="number"}function Ka(e){return e.replace(/\/api\/v0\/?$/,"")}function Qa({server:e,environmentName:n,packageName:r,path:o,versionId:i}){const l=o.startsWith("public/")?o.slice(7):o,a=`${Ka(e)}/environments/${encodeURIComponent(n)}/packages/${encodeURIComponent(r)}/`+l;return i===void 0?a:`${a}${a.includes("?")?"&":"?"}versionId=${encodeURIComponent(i)}`}function Dd(e){try{const{environmentName:n,packageName:r,modelPath:o,versionId:i}=c.parseResourceUri(e);return!n||!r||!o?null:{environmentName:n,packageName:r,dataAppPath:o,versionId:i}}catch{return null}}function $d({resourceUri:e}){const{server:n,apiClients:r}=q.useServer(),o=Dd(e),i=o?.environmentName??"",l=o?.packageName??"",a=o?.dataAppPath??"",d=o?.versionId,u=j.useMemo(()=>Qa({server:n,environmentName:i,packageName:l,path:a,...d!==void 0?{versionId:d}:{}}),[n,i,l,a,d]),y=c.useQueryWithApiError({queryKey:["data-apps",i,l,d],queryFn:()=>r.dataApps.listDataApps(i,l,d),enabled:!!o}).data?.data?.find(S=>S.path===a),b=y?.title??a,x=y?.fit==="viewport",v=j.useRef(null),[k,C]=j.useState(120);return j.useEffect(()=>{if(x)return;function S(T){Id(T.data)&&T.source===v.current?.contentWindow&&T.data.height>0&&C(Math.ceil(T.data.height))}return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[x]),o?t.jsxs(p.Box,{sx:{p:3,...x?{height:"100%",display:"flex",flexDirection:"column"}:{maxWidth:1600,mx:"auto"}},children:[t.jsxs(p.Stack,{direction:"row",alignItems:"baseline",spacing:1,sx:{mb:1,flexShrink:0},children:[t.jsx(p.Typography,{variant:"h6",sx:{fontWeight:"fontWeightMedium",letterSpacing:"-0.025em"},children:b}),t.jsx(p.Typography,{variant:"caption",color:"text.secondary",sx:{fontFamily:q.MONO_FONT_FAMILY},children:a}),t.jsx(p.Box,{sx:{flex:1}}),t.jsx(p.Tooltip,{title:"Open standalone in new tab",children:t.jsx(p.IconButton,{size:"small",href:u,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",sx:{color:"text.secondary"},children:t.jsx(Ya,{fontSize:"small"})})})]}),t.jsx(p.Box,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,overflow:"hidden",backgroundColor:"background.paper",...x?{flex:1,minHeight:0}:{}},children:t.jsx("iframe",{ref:v,src:u,title:b,sandbox:"allow-scripts allow-same-origin allow-forms",style:{display:"block",width:"100%",height:x?"100%":k,border:0}})})]}):t.jsxs(p.Box,{sx:{p:3,maxWidth:1600,mx:"auto"},children:[t.jsx(p.Typography,{variant:"h6",sx:{fontWeight:"fontWeightMedium"},children:"Can't open data app"}),t.jsxs(p.Typography,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["This data app link is missing an environment, package, or path:",t.jsx(p.Box,{component:"span",sx:{fontFamily:q.MONO_FONT_FAMILY,ml:1},children:e})]})]})}function _t({title:e,count:n,description:r,action:o,children:i}){const l=j.useId();return t.jsxs(p.Box,{component:"section","aria-labelledby":l,sx:{mb:4},children:[t.jsxs(p.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:r?0:1,minHeight:40},children:[t.jsxs(p.Stack,{direction:"row",alignItems:"baseline",spacing:1,children:[t.jsx(p.Typography,{id:l,variant:"h6",sx:{fontWeight:600,letterSpacing:"-0.025em",lineHeight:1.2},children:e}),n!==void 0&&t.jsxs(p.Typography,{variant:"caption",color:"text.secondary",children:["(",n,")"]})]}),o]}),r&&t.jsx(p.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:r}),t.jsx(p.Box,{children:i})]})}function Ad({resourceUri:e}){const{environmentName:n}=c.parseResourceUri(e),{apiClients:r}=q.useServer(),[o,i]=j.useState(!1),l=90,{data:a,isSuccess:d,isError:u,error:h}=c.useQueryWithApiError({queryKey:["about",n],queryFn:()=>r.environments.getEnvironment(n,!1)}),y=a?.data?.readme||"",b=y.split(/\s+/),x=b.length>l,v=b.slice(0,l).join(" ");return t.jsxs(t.Fragment,{children:[!d&&!u&&t.jsx(c.Loading,{text:"Fetching About..."}),d&&y&&t.jsxs(_t,{title:"Readme",children:[t.jsx(c.Prose,{variant:"caption",children:o||!x?y:v}),x&&t.jsx(p.Box,{sx:{mt:1},children:t.jsx(c.SecondaryButton,{label:o?"Read less":"Read more",onClick:()=>i(!o)})})]}),u&&t.jsx(c.ApiErrorDisplay,{error:h,context:`${n} > About`})]})}function Fd(e={}){const{autoHideDuration:n=null,disableWindowBlurListener:r=!1,onClose:o,open:i,resumeHideDuration:l}=e,a=c.useTimeout();Ce.useEffect(()=>{if(!i)return;function T(O){O.defaultPrevented||O.key==="Escape"&&o?.(O,"escapeKeyDown")}return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[i,o]);const d=c.useEventCallback((T,O)=>{o?.(T,O)}),u=c.useEventCallback(T=>{!o||T==null||a.start(T,()=>{d(null,"timeout")})});Ce.useEffect(()=>(i&&u(n),a.clear),[i,n,u,a]);const h=T=>{o?.(T,"clickaway")},y=a.clear,b=Ce.useCallback(()=>{n!=null&&u(l??n*.5)},[n,l,u]),x=T=>O=>{const M=T.onBlur;M?.(O),b()},v=T=>O=>{const M=T.onFocus;M?.(O),y()},k=T=>O=>{const M=T.onMouseEnter;M?.(O),y()},C=T=>O=>{const M=T.onMouseLeave;M?.(O),b()};return Ce.useEffect(()=>{if(!r&&i)return window.addEventListener("focus",b),window.addEventListener("blur",y),()=>{window.removeEventListener("focus",b),window.removeEventListener("blur",y)}},[r,i,b,y]),{getRootProps:(T={})=>{const O={...c.extractEventHandlers(e),...c.extractEventHandlers(T)};return{role:"presentation",...T,...O,onBlur:x(O),onFocus:v(O),onMouseEnter:k(O),onMouseLeave:C(O)}},onClickAway:h}}function Ii(e){return e.substring(2).toLowerCase()}function Rd(e,n){return n.documentElement.clientWidth<e.clientX||n.documentElement.clientHeight<e.clientY}function Nd(e){const{children:n,disableReactTree:r=!1,mouseEvent:o="onClick",onClickAway:i,touchEvent:l="onTouchEnd"}=e,a=Ce.useRef(!1),d=Ce.useRef(null),u=Ce.useRef(!1),h=Ce.useRef(!1);Ce.useEffect(()=>(setTimeout(()=>{u.current=!0},0),()=>{u.current=!1}),[]);const y=c.useForkRef(c.getReactElementRef(n),d),b=c.useEventCallback(k=>{const C=h.current;h.current=!1;const S=c.ownerDocument(d.current);if(!u.current||!d.current||"clientX"in k&&Rd(k,S))return;if(a.current){a.current=!1;return}let T;k.composedPath?T=k.composedPath().includes(d.current):T=!S.documentElement.contains(k.target)||d.current.contains(k.target),!T&&(r||!C)&&i(k)}),x=k=>C=>{h.current=!0;const S=n.props[k];S&&S(C)},v={ref:y};return l!==!1&&(v[l]=x(l)),Ce.useEffect(()=>{if(l!==!1){const k=Ii(l),C=c.ownerDocument(d.current),S=()=>{a.current=!0};return C.addEventListener(k,b),C.addEventListener("touchmove",S),()=>{C.removeEventListener(k,b),C.removeEventListener("touchmove",S)}}},[b,l]),o!==!1&&(v[o]=x(o)),Ce.useEffect(()=>{if(o!==!1){const k=Ii(o),C=c.ownerDocument(d.current);return C.addEventListener(k,b),()=>{C.removeEventListener(k,b)}}},[b,o]),Ce.cloneElement(n,v)}function Ld(e){return c.generateUtilityClass("MuiSnackbarContent",e)}c.generateUtilityClasses("MuiSnackbarContent",["root","message","action"]);const _d=e=>{const{classes:n}=e,r={root:["root"],action:["action"],message:["message"]};return c.composeClasses(r,Ld,n)},Pd=c.styled(c.Paper,{name:"MuiSnackbarContent",slot:"Root"})(c.memoTheme(({theme:e})=>{const n=e.palette.mode==="light"?.8:.98;return{...e.typography.body2,color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(c.emphasize(e.palette.background.default,n)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:c.emphasize(e.palette.background.default,n),display:"flex",alignItems:"center",flexWrap:"wrap",padding:"6px 16px",flexGrow:1,[e.breakpoints.up("sm")]:{flexGrow:"initial",minWidth:288}}})),zd=c.styled("div",{name:"MuiSnackbarContent",slot:"Message"})({padding:"8px 0"}),Wd=c.styled("div",{name:"MuiSnackbarContent",slot:"Action"})({display:"flex",alignItems:"center",marginLeft:"auto",paddingLeft:16,marginRight:-8}),qd=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiSnackbarContent"}),{action:i,className:l,message:a,role:d="alert",...u}=o,h=o,y=_d(h);return t.jsxs(Pd,{role:d,elevation:6,className:c.clsx(y.root,l),ownerState:h,ref:r,...u,children:[t.jsx(zd,{className:y.message,ownerState:h,children:a}),i?t.jsx(Wd,{className:y.action,ownerState:h,children:i}):null]})});function Bd(e){return c.generateUtilityClass("MuiSnackbar",e)}c.generateUtilityClasses("MuiSnackbar",["root","anchorOriginTopCenter","anchorOriginBottomCenter","anchorOriginTopRight","anchorOriginBottomRight","anchorOriginTopLeft","anchorOriginBottomLeft"]);const Vd=e=>{const{classes:n,anchorOrigin:r}=e,o={root:["root",`anchorOrigin${c.capitalize(r.vertical)}${c.capitalize(r.horizontal)}`]};return c.composeClasses(o,Bd,n)},Hd=c.styled("div",{name:"MuiSnackbar",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[n.root,n[`anchorOrigin${c.capitalize(r.anchorOrigin.vertical)}${c.capitalize(r.anchorOrigin.horizontal)}`]]}})(c.memoTheme(({theme:e})=>({zIndex:(e.vars||e).zIndex.snackbar,position:"fixed",display:"flex",left:8,right:8,justifyContent:"center",alignItems:"center",variants:[{props:({ownerState:n})=>n.anchorOrigin.vertical==="top",style:{top:8,[e.breakpoints.up("sm")]:{top:24}}},{props:({ownerState:n})=>n.anchorOrigin.vertical!=="top",style:{bottom:8,[e.breakpoints.up("sm")]:{bottom:24}}},{props:({ownerState:n})=>n.anchorOrigin.horizontal==="left",style:{justifyContent:"flex-start",[e.breakpoints.up("sm")]:{left:24,right:"auto"}}},{props:({ownerState:n})=>n.anchorOrigin.horizontal==="right",style:{justifyContent:"flex-end",[e.breakpoints.up("sm")]:{right:24,left:"auto"}}},{props:({ownerState:n})=>n.anchorOrigin.horizontal==="center",style:{[e.breakpoints.up("sm")]:{left:"50%",right:"auto",transform:"translateX(-50%)"}}}]}))),Ud=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiSnackbar"}),i=c.useTheme(),l={enter:i.transitions.duration.enteringScreen,exit:i.transitions.duration.leavingScreen},{action:a,anchorOrigin:{vertical:d,horizontal:u}={vertical:"bottom",horizontal:"left"},autoHideDuration:h=null,children:y,className:b,ClickAwayListenerProps:x,ContentProps:v,disableWindowBlurListener:k=!1,message:C,onBlur:S,onClose:T,onFocus:O,onMouseEnter:M,onMouseLeave:E,open:R,resumeHideDuration:P,slots:A={},slotProps:H={},TransitionComponent:D,transitionDuration:L=l,TransitionProps:{onEnter:U,onExited:$,...W}={},...Q}=o,te={...o,anchorOrigin:{vertical:d,horizontal:u},autoHideDuration:h,disableWindowBlurListener:k,TransitionComponent:D,transitionDuration:L},ee=Vd(te),{getRootProps:G,onClickAway:Z}=Fd({...te}),[ae,z]=Ce.useState(!0),re=ge=>{z(!0),$&&$(ge)},se=(ge,ue)=>{z(!1),U&&U(ge,ue)},ne={slots:{transition:D,...A},slotProps:{content:v,clickAwayListener:x,transition:W,...H}},[Ie,de]=c.useSlot("root",{ref:r,className:[ee.root,b],elementType:Hd,getSlotProps:G,externalForwardedProps:{...ne,...Q},ownerState:te}),[pe,{ownerState:De,...Le}]=c.useSlot("clickAwayListener",{elementType:Nd,externalForwardedProps:ne,getSlotProps:ge=>({onClickAway:(...ue)=>{const ye=ue[0];ge.onClickAway?.(...ue),!ye?.defaultMuiPrevented&&Z(...ue)}}),ownerState:te}),[oe,K]=c.useSlot("content",{elementType:qd,shouldForwardComponentProp:!0,externalForwardedProps:ne,additionalProps:{message:C,action:a},ownerState:te}),[le,be]=c.useSlot("transition",{elementType:c.Grow,externalForwardedProps:ne,getSlotProps:ge=>({onEnter:(...ue)=>{ge.onEnter?.(...ue),se(...ue)},onExited:(...ue)=>{ge.onExited?.(...ue),re(...ue)}}),additionalProps:{appear:!0,in:R,timeout:L,direction:d==="top"?"down":"up"},ownerState:te});return!R&&ae?null:t.jsx(pe,{...Le,...A.clickAwayListener&&{ownerState:De},children:t.jsx(Ie,{...de,children:t.jsx(le,{...be,children:y||t.jsx(oe,{...K})})})})});let Gs;function Gd(e){Gs=e}function Di(e){if(Gs)try{Gs(e)}catch{}}function Ht(e,n,r){return(async o=>{const i=Date.now();try{const l=await r(o);return Di({type:"console.mutation",resource:e,action:n,ok:!0,durationMs:Date.now()-i}),l}catch(l){throw Di({type:"console.mutation",resource:e,action:n,ok:!1,durationMs:Date.now()-i,reason:l instanceof Error?l.message:"An unknown error occurred"}),l}})}function _n({mutationFn:e,success:n,invalidates:r,closeDialog:o,resource:i,action:l}){const a=yt.useQueryClient(),[d,u]=j.useState(""),h=c.useMutationWithApiError({mutationFn:Ht(i,l,e),onSuccess(){o();for(const y of r)a.invalidateQueries({queryKey:y});u(n)},onError(y){u(y instanceof Error?y.message:"An unknown error occurred")}});return{mutate:h.mutate,isPending:h.isPending,notice:t.jsx(Ud,{open:d!=="",autoHideDuration:6e3,onClose:()=>u(""),message:d})}}const Za="https://docs.malloydata.dev/documentation",Ts=`${Za}/user_guides/publishing`,In="https://github.com/malloydata/publisher/blob/main/docs",Vt={docsHome:`${Za}/`,publishing:`${Ts}/publishing`,explorer:`${Ts}/explorer`,mcpAgents:`${Ts}/mcp_agents`,surfaces:`${In}/choosing-a-surface.md`,dashboards:`${In}/dashboards.md`,dataApps:`${In}/html-data-apps.md`,givens:`${In}/givens.md`,materialization:`${In}/materialization.md`,connections:`${In}/connections.md`};function Yd({resourceUri:e}){const[n,r]=j.useState(!1),{apiClients:o}=q.useServer(),{environmentName:i}=c.parseResourceUri(e),l=_n({mutationFn(d){return o.packages.createPackage(i,{name:d.name,description:d.description,location:d.location})},success:"Package created",invalidates:[["packages",i]],closeDialog:()=>r(!1),resource:"package",action:"create"}),a=d=>{d.preventDefault();const u=new FormData(d.currentTarget),h=u.get("name")?.toString(),y=u.get("description")?.toString(),b=u.get("location")?.toString();l.mutate({name:h,description:y,location:b})};return t.jsxs(t.Fragment,{children:[t.jsx(c.AddButton,{label:"Package",onClick:()=>r(!0)}),t.jsx(c.AppDialog,{open:n,onClose:()=>r(!1),title:"New package",description:t.jsxs(t.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"," ",t.jsx(p.Box,{component:"a",href:Vt.publishing,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary"},children:"package format"}),"."]}),actions:t.jsxs(t.Fragment,{children:[t.jsx(p.Button,{disabled:l.isPending,onClick:()=>r(!1),children:"Cancel"}),t.jsx(p.Button,{type:"submit",form:"package-form",variant:"contained",loading:l.isPending,children:"Create package"})]}),children:t.jsx("form",{onSubmit:a,id:"package-form",children:t.jsxs(p.Stack,{sx:{gap:2},children:[t.jsx(p.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),t.jsx(p.TextField,{id:"description",name:"description",label:"Description",multiline:!0,rows:3,fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),t.jsx(p.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}})]})})}),l.notice]})}const Kd=c.createSvgIcon(t.jsx("path",{d:"M2 20h20v-4H2zm2-3h2v2H4zM2 4v4h20V4zm4 3H4V5h2zm-4 7h20v-4H2zm2-3h2v2H4z"}));function ss({icon:e,tint:n,label:r,mono:o,description:i,rightLabel:l,trailingAction:a,onClick:d,ariaLabel:u}){const h=!!d,y=b=>{d&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),d(b))};return t.jsxs(p.Box,{onClick:d,onKeyDown:h?y:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,"aria-label":u,sx:b=>({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:b.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:[t.jsx(p.Box,{sx:{width:32,height:32,borderRadius:1,bgcolor:n,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),t.jsxs(p.Box,{sx:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:1.5},children:[t.jsx(p.Typography,{variant:"body2",sx:{...o?{fontFamily:q.MONO_FONT_FAMILY}:{},flexShrink:0,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),i&&t.jsx(p.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})]}),l&&t.jsx(p.Typography,{variant:"caption",color:"text.secondary",sx:{flexShrink:0},children:l}),a&&t.jsx(p.Box,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:a})]})}const Xa=c.createSvgIcon(t.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"})),Qd=c.generateUtilityClasses("MuiBox",["root"]),Zd=c.createTheme(),Ye=wr.createBox({themeId:c.THEME_ID,defaultTheme:Zd,defaultClassName:Qd.root,generateClassName:c.ClassNameGenerator.generate}),os=wr.createStack({createStyledComponent:c.styled("div",{name:"MuiStack",slot:"Root"}),useThemeProps:e=>c.useDefaultProps({props:e,name:"MuiStack"})}),$i=c.generateUtilityClasses("MuiDivider",["root","absolute","fullWidth","inset","middle","flexItem","light","vertical","withChildren","withChildrenVertical","textAlignRight","textAlignLeft","wrapper","wrapperVertical"]);function Xd(e){return c.generateUtilityClass("MuiListItemIcon",e)}const Ai=c.generateUtilityClasses("MuiListItemIcon",["root","alignItemsFlexStart"]),Jd=e=>{const{alignItems:n,classes:r}=e,o={root:["root",n==="flex-start"&&"alignItemsFlexStart"]};return c.composeClasses(o,Xd,r)},eh=c.styled("div",{name:"MuiListItemIcon",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[n.root,r.alignItems==="flex-start"&&n.alignItemsFlexStart]}})(c.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}}]}))),ao=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiListItemIcon"}),{className:i,...l}=o,a=Ce.useContext(c.ListContext),d={...o,alignItems:a.alignItems},u=Jd(d);return t.jsx(eh,{className:c.clsx(u.root,i),ownerState:d,ref:r,...l})});function th(e){return c.generateUtilityClass("MuiListItemText",e)}const $n=c.generateUtilityClasses("MuiListItemText",["root","multiline","dense","inset","primary","secondary"]),nh=e=>{const{classes:n,inset:r,primary:o,secondary:i,dense:l}=e,a={root:["root",r&&"inset",l&&"dense",o&&i&&"multiline"],primary:["primary"],secondary:["secondary"]};return c.composeClasses(a,th,n)},rh=c.styled("div",{name:"MuiListItemText",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[{[`& .${$n.primary}`]:n.primary},{[`& .${$n.secondary}`]:n.secondary},n.root,r.inset&&n.inset,r.primary&&r.secondary&&n.multiline,r.dense&&n.dense]}})({flex:"1 1 auto",minWidth:0,marginTop:4,marginBottom:4,[`.${c.typographyClasses.root}:where(& .${$n.primary})`]:{display:"block"},[`.${c.typographyClasses.root}:where(& .${$n.secondary})`]:{display:"block"},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),lo=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiListItemText"}),{children:i,className:l,disableTypography:a=!1,inset:d=!1,primary:u,primaryTypographyProps:h,secondary:y,secondaryTypographyProps:b,slots:x={},slotProps:v={},...k}=o,{dense:C}=Ce.useContext(c.ListContext);let S=u??i,T=y;const O={...o,disableTypography:a,inset:d,primary:!!S,secondary:!!T,dense:C},M=nh(O),E={slots:x,slotProps:{primary:h,secondary:b,...v}},[R,P]=c.useSlot("root",{className:c.clsx(M.root,l),elementType:rh,externalForwardedProps:{...E,...k},ownerState:O,ref:r}),[A,H]=c.useSlot("primary",{className:M.primary,elementType:c.Typography,externalForwardedProps:E,ownerState:O}),[D,L]=c.useSlot("secondary",{className:M.secondary,elementType:c.Typography,externalForwardedProps:E,ownerState:O});return S!=null&&S.type!==c.Typography&&!a&&(S=t.jsx(A,{variant:C?"body2":"body1",component:H?.variant?void 0:"span",...H,children:S})),T!=null&&T.type!==c.Typography&&!a&&(T=t.jsx(D,{variant:"body2",color:"textSecondary",...L,children:T})),t.jsxs(R,{...P,children:[S,T]})});function sh(e){return c.generateUtilityClass("MuiMenuItem",e)}const er=c.generateUtilityClasses("MuiMenuItem",["root","focusVisible","dense","disabled","divider","gutters","selected"]),oh=(e,n)=>{const{ownerState:r}=e;return[n.root,r.dense&&n.dense,r.divider&&n.divider,!r.disableGutters&&n.gutters]},ih=e=>{const{disabled:n,dense:r,divider:o,disableGutters:i,selected:l,classes:a}=e,d={root:["root",r&&"dense",n&&"disabled",!i&&"gutters",o&&"divider",l&&"selected"]},u=c.composeClasses(d,sh,a);return{...a,...u}},ah=c.styled(c.ButtonBase,{shouldForwardProp:e=>c.rootShouldForwardProp(e)||e==="classes",name:"MuiMenuItem",slot:"Root",overridesResolver:oh})(c.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"}},[`&.${er.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${er.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${er.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)}},[`&.${er.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${er.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${$i.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${$i.inset}`]:{marginLeft:52},[`& .${$n.root}`]:{marginTop:0,marginBottom:0},[`& .${$n.inset}`]:{paddingLeft:36},[`& .${Ai.root}`]:{minWidth:36},variants:[{props:({ownerState:n})=>!n.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:n})=>n.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:n})=>!n.dense,style:{[e.breakpoints.up("sm")]:{minHeight:"auto"}}},{props:({ownerState:n})=>n.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${Ai.root} svg`]:{fontSize:"1.25rem"}}}]}))),tt=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiMenuItem"}),{autoFocus:i=!1,component:l="li",dense:a=!1,divider:d=!1,disableGutters:u=!1,focusVisibleClassName:h,role:y="menuitem",tabIndex:b,className:x,...v}=o,k=Ce.useContext(c.ListContext),C=Ce.useMemo(()=>({dense:a||k.dense||!1,disableGutters:u}),[k.dense,a,u]),S=Ce.useRef(null);c.useEnhancedEffect(()=>{i&&S.current&&S.current.focus()},[i]);const T={...o,dense:C.dense,divider:d,disableGutters:u},O=ih(o),M=c.useForkRef(S,r);let E;return o.disabled||(E=b!==void 0?b:-1),t.jsx(c.ListContext.Provider,{value:C,children:t.jsx(ah,{ref:M,role:y,tabIndex:E,component:l,focusVisibleClassName:c.clsx(O.focusVisible,h),className:c.clsx(O.root,x),...v,ownerState:T,classes:O})})}),Gt={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},{label:"Database Metadata",name:"dbmeta",type:"text",required:!1,selectOptions:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}],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}],sqlserver:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Database",name:"database",type:"text",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Encrypt",name:"encrypt",type:"text",required:!1,selectOptions:[{label:"Yes",value:"true"},{label:"No",value:"false"}]},{label:"Trust server certificate",name:"trustServerCertificate",type:"text",required:!1,selectOptions:[{label:"No",value:"false"},{label:"Yes",value:"true"}]},{label:"Host name in certificate",name:"hostNameInCertificate",type:"text",required:!1},{label:"Instance name",name:"instanceName",type:"text",required:!1}],duckdb:[],motherduck:[{label:"Access Token",name:"accessToken",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1}],ducklake:[],publisher:[]},pr={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",trino:"trinoConnection",databricks:"databricksConnection",mysql:"mysqlConnection",sqlserver:"sqlserverConnection",duckdb:"duckdbConnection",motherduck:"motherduckConnection",ducklake:"ducklakeConnection",publisher:"publisherConnection"},lh={bigquery:{dbmeta:"boolean"},sqlserver:{port:"integer",encrypt:"boolean",trustServerCertificate:"boolean"}},ch={sqlserver:["hostNameInCertificate","instanceName"]};function Ja(e,n){const r=lh[e],o=ch[e];if(!r&&!o)return n;const i={...n};for(const l of o??[])i[l]===""&&delete i[l];for(const[l,a]of Object.entries(r??{})){const d=n[l];if(d!==void 0){if(d===""){delete i[l];continue}if(a==="integer"){const u=Number(d);Number.isInteger(u)&&(i[l]=u)}else(d==="true"||d==="false")&&(i[l]=d==="true")}}return i}const el=Object.values(q.ConnectionTypeEnum).filter(e=>e!==q.ConnectionTypeEnum.Publisher),Ys={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",gcs:"gcsConnection",s3:"s3Connection",azure:"azureConnection"},Sr=[{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"}}],kr=[{label:"Key ID",name:"keyId",type:"text",required:!0},{label:"Secret",name:"secret",type:"password",required:!0}],uh=[{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 Jr(e){return e==="postgres"||e==="bigquery"||e==="snowflake"?Gt[e]||[]:e==="s3"?Sr:e==="gcs"?kr:e==="azure"?uh:[]}function dh({onSubmit:e,isSubmitting:n}){const[r,o]=j.useState(!1),[i,l]=j.useState("postgres"),[a,d]=j.useState([]),[u,h]=j.useState("postgres"),[y,b]=j.useState("s3"),[x,v]=j.useState("config"),k=()=>{o(!0)},C=()=>{o(!1),d([]),l("postgres"),h("postgres"),b("s3"),v("config")},S=async E=>{E.preventDefault();const R=new FormData(E.currentTarget),P=R.get("name")?.toString(),A=R.get("type")?.toString(),H=Gt[A];if(!P)throw new Error("Name is required");if(!A)throw new Error("Type is required");let D;if(A==="ducklake"){const L={};if(u==="postgres"){const W=Gt.postgres,Q={};if(W.forEach(te=>{const ee=R.get(`ducklake_pg_${te.name}`)?.toString();ee&&(Q[te.name]=ee)}),Object.keys(Q).length===0)throw new Error("DuckLake requires catalog connection");L.postgresConnection=Q}const U=R.get("ducklake_bucketUrl")?.toString();if(!U)throw new Error("DuckLake requires a bucket URL");const $={bucketUrl:U};if(y==="s3"){const W={};if(Sr.forEach(Q=>{const te=R.get(`ducklake_s3_${Q.name}`)?.toString();te&&(W[Q.name]=te)}),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&&($.s3Connection=W)}else if(y==="gcs"){const W={};if(kr.forEach(Q=>{const te=R.get(`ducklake_gcs_${Q.name}`)?.toString();te&&(W[Q.name]=te)}),!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&&($.gcsConnection=W)}D={name:P,type:A,ducklakeConnection:{catalog:L,storage:$}}}else if(A==="duckdb"){if(a.length===0)throw new Error("DuckDB connection must have at least one attached database");const L=a.map((U,$)=>{const W=U.dbType,Q=R.get(`attachedDb_${$}_name`)?.toString();if(!Q)throw new Error(`Attached database at index ${$} must have a name`);const te={name:Q,type:W},ee=Jr(W);if(ee&&ee.length>0){const G={};if(ee.forEach(ae=>{const z=R.get(`attachedDb_${$}_${ae.name}`)?.toString();z&&(G[ae.name]=z)}),W==="s3"){if(G.provider==="credential_chain")delete G.accessKeyId,delete G.secretAccessKey,delete G.sessionToken;else if(delete G.chain,!G.accessKeyId||!G.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=Ys[W];Z&&(te[Z]=G)}return te});D={name:P,type:A,duckdbConnection:{attachedDatabases:L}}}else{const L={};if(H.forEach(U=>{const $=R.get(U.name)?.toString();$&&(L[U.name]=$)}),A==="postgres"){if(!!!L.connectionString?.trim()){const $=["host","port","databaseName","userName","password"];for(const W of $)if(!L[W])throw new Error(`${H.find(Q=>Q.name===W)?.label||W} is required`)}}else if(A==="bigquery"){if(!L.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(A==="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(A==="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(A==="mysql"){const U=["host","port","database","user","password"];for(const $ of U)if(!L[$])throw new Error(`${H.find(W=>W.name===$)?.label||$} is required`)}else if(A==="sqlserver"){const U=["server","database","user","password"];if(!L.instanceName&&!L.port)throw new Error("Port is required unless an instance name is given");for(const $ of U)if(!L[$])throw new Error(`${H.find(W=>W.name===$)?.label||$} is required`)}else if(A==="motherduck"){if(!L.accessToken)throw new Error("Access Token is required")}else if(A==="databricks"){if(!L.host)throw new Error("Host is required");if(!L.path)throw new Error("HTTP Path is required");const U=L.oauthClientId&&L.oauthClientSecret;if(!L.token&&!U)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}D={name:P,type:A,[pr[A]]:Ja(A,L)}}await e(D),C()},T=()=>{d([...a,{name:"",dbType:"postgres"}])},O=E=>{d(a.filter((R,P)=>P!==E))},M=(E,R)=>{const P=[...a];P[E]={...P[E],dbType:R},d(P)};return t.jsxs(j.Fragment,{children:[t.jsx(c.AddButton,{label:"Connection",onClick:k}),t.jsx(c.AppDialog,{open:r,onClose:C,title:"New connection",description:"Add a connection so packages in this environment can query your database with Malloy.",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{disabled:n,onClick:C,children:"Cancel"}),t.jsx(c.Button,{type:"submit",form:"connection-form",variant:"contained",loading:n,children:"Create connection"})]}),children:t.jsx("form",{onSubmit:S,id:"connection-form",children:t.jsxs(os,{sx:{gap:2},children:[t.jsx(c.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small"}),t.jsx(c.TextField,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:i,select:!0,onChange:E=>l(E.target.value),children:el.map(E=>t.jsx(tt,{value:E,children:E},E))}),i==="ducklake"?t.jsxs(Ye,{sx:{mt:2},children:[t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsx(c.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),t.jsx(c.TextField,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:u,select:!0,onChange:E=>h(E.target.value),children:t.jsx(tt,{value:"postgres",children:"PostgreSQL"})}),u==="postgres"&&t.jsx(t.Fragment,{children:Gt.postgres.map(E=>t.jsx(c.TextField,{id:`ducklake_pg_${E.name}`,name:`ducklake_pg_${E.name}`,label:E.label,type:E.type,fullWidth:!0,size:"small"},`pg_${E.name}`))})]}),t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsx(c.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),t.jsxs(c.TextField,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:y,select:!0,onChange:E=>b(E.target.value),children:[t.jsx(tt,{value:"s3",children:"S3"}),t.jsx(tt,{value:"gcs",children:"GCS"})]}),t.jsx(c.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"}),y==="s3"&&t.jsxs(t.Fragment,{children:[t.jsx(c.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Sr.filter(E=>E.visibleWhen?x===E.visibleWhen.value:!0).map(E=>t.jsx(c.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=>v(R.target.value):void 0,placeholder:E.name==="region"?"us-east-1":void 0,children:E.selectOptions?.map(R=>t.jsx(tt,{value:R.value,children:R.label},R.value))},`s3_${E.name}`))]}),y==="gcs"&&t.jsxs(t.Fragment,{children:[t.jsx(c.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),kr.map(E=>t.jsx(c.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}`))]})]})]}):i==="duckdb"?t.jsxs(Ye,{sx:{mt:2},children:[t.jsxs(Ye,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[t.jsx(c.Typography,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),t.jsx(c.SecondaryButton,{label:"Database",icon:t.jsx(c.AddIcon,{}),onClick:T,ariaLabel:"Add database"})]}),a.length===0&&t.jsx(c.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),a.map((E,R)=>{const P=Jr(E.dbType);return t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsxs(Ye,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[t.jsxs(c.Typography,{variant:"subtitle2",children:["Database ",R+1]}),t.jsx(c.IconButton,{onClick:()=>O(R),size:"small",color:"error",children:t.jsx(Xa,{fontSize:"small"})})]}),t.jsx(c.TextField,{required:!0,id:`attachedDb_${R}_name`,name:`attachedDb_${R}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:E.name}),t.jsx(c.TextField,{id:`attachedDb_${R}_type`,name:`attachedDb_${R}_type`,label:"Database Type",fullWidth:!0,size:"small",value:E.dbType,select:!0,onChange:A=>M(R,A.target.value),children:Object.values(q.AttachedDatabaseTypeEnum).map(A=>t.jsx(tt,{value:A,children:A},A))}),P.filter(A=>A.visibleWhen?(E[A.visibleWhen.field]||P.find(D=>D.name===A.visibleWhen?.field)?.selectOptions?.[0]?.value)===A.visibleWhen.value:!0).map(A=>t.jsx(c.TextField,{id:`attachedDb_${R}_${A.name}`,name:`attachedDb_${R}_${A.name}`,label:A.label,type:A.selectOptions?void 0:A.type,fullWidth:!0,size:"small",required:A.required,select:!!A.selectOptions,defaultValue:A.selectOptions?.[0]?.value,onChange:A.selectOptions?H=>{const D=[...a];D[R]={...D[R],[A.name]:H.target.value},d(D)}:void 0,children:A.selectOptions?.map(H=>t.jsx(tt,{value:H.value,children:H.label},H.value))},A.name))]},R)})]}):Gt[i].map(E=>t.jsx(c.TextField,{id:E.name,name:E.name,label:E.label,type:E.type,fullWidth:!0,size:"small",required:E.required,select:!!E.selectOptions,defaultValue:E.selectOptions?E.selectOptions[0]?.value:void 0,children:E.selectOptions?.map(R=>t.jsx(tt,{value:R.value,children:R.label},R.value))},E.name))]})})})]})}function hh({connection:e,onCloseDialog:n,isMutating:r,onDelete:o}){const[i,l]=j.useState(!1),a=()=>{l(!0)},d=()=>{l(!1),n()};return t.jsxs(j.Fragment,{children:[t.jsxs(tt,{"aria-label":`Delete connection ${e?.name??""}`.trim(),onClick:u=>{u.stopPropagation(),a()},sx:{color:"error.main"},children:[t.jsx(ao,{sx:{color:"inherit"},children:t.jsx(Pt.Delete,{fontSize:"small"})}),t.jsx(lo,{children:"Delete"})]}),t.jsx(c.AppDialog,{open:i,onClose:d,title:"Delete connection",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{onClick:d,children:"Cancel"}),t.jsx(c.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>o(),loading:r,children:"Delete connection"})]}),children:t.jsxs(c.Typography,{variant:"body2",children:["Delete ",t.jsx("strong",{children:e.name}),"? Packages that query through it stop working, and this cannot be undone."]})})]})}const Fi=new Set(["password","connectionString","privateKey","privateKeyPass","serviceAccountKeyJson","token","oauthClientSecret","accessToken","peakaKey","secret","secretAccessKey","sessionToken","clientSecret","sasUrl"]);function Ri(e){const n=e.duckdbConnection?.attachedDatabases;return!n||n.length===0?[]:n.map(r=>({name:r.name||"",dbType:r.type||"postgres"}))}function Ni(e){const n=e.ducklakeConnection;return n&&n.storage?.gcsConnection?"gcs":"s3"}function fh({connection:e,onSubmit:n,isSubmitting:r,onCloseDialog:o}){const[i,l]=j.useState(!1),[a,d]=j.useState(e.type),u=j.useMemo(()=>new Set(e.withheldFields??[]),[e.withheldFields]),[h,y]=j.useState(()=>Ri(e)),[b,x]=j.useState("postgres"),[v,k]=j.useState(()=>Ni(e)),[C,S]=j.useState(()=>e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),T=()=>{y(Ri(e)),d(e.type),S(e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),x("postgres"),k(Ni(e)),l(!0)},O=()=>{l(!1),o?.()},M=async D=>{D.preventDefault();const L=new FormData(D.currentTarget),U=L.get("name")?.toString(),$=L.get("type")?.toString(),W=Gt[$];if(!U)throw new Error("Name is required");if(!$)throw new Error("Type is required");let Q;if($==="ducklake"){const te={};if(b==="postgres"){const Z=Gt.postgres,ae={};if(Z.forEach(z=>{const re=L.get(`ducklake_pg_${z.name}`)?.toString();re&&(ae[z.name]=re)}),Object.keys(ae).length===0)throw new Error("DuckLake requires catalog connection");te.postgresConnection=ae}const ee=L.get("ducklake_bucketUrl")?.toString();if(!ee)throw new Error("DuckLake requires a bucket URL");const G={bucketUrl:ee};if(v==="s3"){const Z={};Sr.forEach(z=>{const re=L.get(`ducklake_s3_${z.name}`)?.toString();re&&(Z[z.name]=re)});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&&(G.s3Connection=Z)}else if(v==="gcs"){const Z={};kr.forEach(z=>{const re=L.get(`ducklake_gcs_${z.name}`)?.toString();re&&(Z[z.name]=re)});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&&(G.gcsConnection=Z)}Q={name:U,type:$,ducklakeConnection:{catalog:te,storage:G}}}else if($==="duckdb"){if(h.length===0)throw new Error("DuckDB connection must have at least one attached database");const te=h.map((ee,G)=>{const Z=ee.dbType,ae=L.get(`attachedDb_${G}_name`)?.toString();if(!ae)throw new Error(`Attached database at index ${G} must have a name`);const z={name:ae,type:Z},re=Jr(Z);if(re&&re.length>0){const se={};if(re.forEach(Ie=>{const de=L.get(`attachedDb_${G}_${Ie.name}`)?.toString();de&&(se[Ie.name]=de)}),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 ne=Ys[Z];ne&&(z[ne]=se)}return z});Q={name:U,type:$,duckdbConnection:{attachedDatabases:te}}}else{const te=e[pr[$]]||{},ee={};if(W.forEach(G=>{const Z=L.get(G.name)?.toString(),ae=te[G.name];Z?ee[G.name]=Z:Fi.has(G.name)||(Z!==void 0?ee[G.name]=Z:ae&&(ee[G.name]=ae))}),$==="postgres"){const G=["host","port","databaseName","userName"],Z=u.has("postgresConnection.connectionString");if(!(!!ee.connectionString?.trim()||Z)){const z=G;for(const re of z)if(!ee[re])throw new Error(`${W.find(se=>se.name===re)?.label||re} is required`)}}else if($==="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($==="trino"){if(!ee.server)throw new Error("Server is required");if(!ee.user)throw new Error("User is required")}else if($==="mysql"){const G=["host","port","database","user"];for(const Z of G)if(!ee[Z])throw new Error(`${W.find(ae=>ae.name===Z)?.label||Z} is required`)}else if($==="sqlserver"){const G=["server","database","user"];if(!ee.instanceName&&!ee.port)throw new Error("Port is required unless an instance name is given");for(const Z of G)if(!ee[Z])throw new Error(`${W.find(ae=>ae.name===Z)?.label||Z} is required`)}else if($==="databricks"){if(!ee.host)throw new Error("Host is required");if(!ee.path)throw new Error("HTTP Path is required")}Q={name:U,type:$,[pr[$]]:Ja($,ee)}}await n(Q),O()},E=()=>{y([...h,{name:"",dbType:"postgres"}])},R=D=>{y(h.filter((L,U)=>U!==D))},P=(D,L)=>{const U=[...h];U[D]={...U[D],dbType:L},y(U)},A=(D,L)=>{const U=e.duckdbConnection?.attachedDatabases;if(!U||!U[D])return"";const $=U[D],W=Ys[$.type||""];return W&&$[W]?$[W][L]??"":""},H=D=>{const L=e.ducklakeConnection;if(!L)return"";if(D.startsWith("pg_")){const U=D.replace("pg_","");return L.catalog?.postgresConnection?.[U]??""}if(D==="bucketUrl")return L.storage?.bucketUrl??"";if(D.startsWith("s3_")){const U=D.replace("s3_","");return L.storage?.s3Connection?.[U]??""}if(D.startsWith("gcs_")){const U=D.replace("gcs_","");return L.storage?.gcsConnection?.[U]??""}return""};return t.jsxs(j.Fragment,{children:[t.jsxs(tt,{"aria-label":`Edit connection ${e?.name??""}`.trim(),onClick:D=>{D.preventDefault(),D.stopPropagation(),T()},children:[t.jsx(ao,{children:t.jsx(Pt.Edit,{fontSize:"small"})}),t.jsx(lo,{children:"Edit"})]}),t.jsx(c.AppDialog,{open:i,onClose:O,title:"Edit connection",description:"Change how packages in this environment reach your database.",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{disabled:r,onClick:O,children:"Cancel"}),t.jsx(c.Button,{type:"submit",form:"connection-form",variant:"contained",loading:r,children:"Save changes"})]}),children:t.jsx("form",{onSubmit:M,id:"connection-form",children:t.jsxs(os,{sx:{gap:2},children:[t.jsx(c.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",defaultValue:e.name}),t.jsx(c.TextField,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:a,select:!0,onChange:D=>d(D.target.value),children:el.map(D=>t.jsx(tt,{value:D,children:D},D))}),a==="ducklake"?t.jsxs(Ye,{sx:{mt:2},children:[t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsx(c.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),t.jsx(c.TextField,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:b,select:!0,onChange:D=>x(D.target.value),children:t.jsx(tt,{value:"postgres",children:"PostgreSQL"})}),b==="postgres"&&t.jsx(t.Fragment,{children:Gt.postgres.map(D=>t.jsx(c.TextField,{id:`ducklake_pg_${D.name}`,name:`ducklake_pg_${D.name}`,label:D.label,type:D.type,fullWidth:!0,size:"small",defaultValue:H(`pg_${D.name}`)},`pg_${D.name}`))})]}),t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsx(c.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),t.jsxs(c.TextField,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:v,select:!0,onChange:D=>k(D.target.value),children:[t.jsx(tt,{value:"s3",children:"S3"}),t.jsx(tt,{value:"gcs",children:"GCS"})]}),t.jsx(c.TextField,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:v==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small",defaultValue:H("bucketUrl")}),v==="s3"&&t.jsxs(t.Fragment,{children:[t.jsx(c.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Sr.filter(D=>D.visibleWhen?C===D.visibleWhen.value:!0).map(D=>t.jsx(c.TextField,{id:`ducklake_s3_${D.name}`,name:`ducklake_s3_${D.name}`,label:D.label,type:D.selectOptions?void 0:D.type,fullWidth:!0,size:"small",required:D.required&&D.name!=="secretAccessKey",select:!!D.selectOptions,defaultValue:D.selectOptions?C:H(`s3_${D.name}`),onChange:D.name==="provider"?L=>S(L.target.value):void 0,placeholder:D.name==="region"?"us-east-1":D.name==="secretAccessKey"&&u.has("ducklakeConnection.storage.s3Connection.secretAccessKey")?"Leave empty to keep existing":void 0,children:D.selectOptions?.map(L=>t.jsx(tt,{value:L.value,children:L.label},L.value))},`s3_${D.name}`))]}),v==="gcs"&&t.jsxs(t.Fragment,{children:[t.jsx(c.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),kr.map(D=>t.jsx(c.TextField,{id:`ducklake_gcs_${D.name}`,name:`ducklake_gcs_${D.name}`,label:D.label,type:D.type,fullWidth:!0,size:"small",required:D.required&&D.name!=="secret",defaultValue:H(`gcs_${D.name}`),placeholder:D.name==="secret"&&u.has("ducklakeConnection.storage.gcsConnection.secret")?"Leave empty to keep existing":void 0},`gcs_${D.name}`))]})]})]}):a==="duckdb"?t.jsxs(Ye,{sx:{mt:2},children:[t.jsxs(Ye,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[t.jsx(c.Typography,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),t.jsx(c.SecondaryButton,{label:"Database",icon:t.jsx(c.AddIcon,{}),onClick:E,ariaLabel:"Add database"})]}),h.length===0&&t.jsx(c.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((D,L)=>{const U=Jr(D.dbType);return t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsxs(Ye,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[t.jsxs(c.Typography,{variant:"subtitle2",children:["Database ",L+1]}),t.jsx(c.IconButton,{"aria-label":`Remove attached database ${L+1}`,onClick:()=>R(L),size:"small",color:"error",children:t.jsx(Xa,{fontSize:"small"})})]}),t.jsx(c.TextField,{required:!0,id:`attachedDb_${L}_name`,name:`attachedDb_${L}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:D.name}),t.jsx(c.TextField,{id:`attachedDb_${L}_type`,name:`attachedDb_${L}_type`,label:"Database Type",fullWidth:!0,size:"small",value:D.dbType,select:!0,onChange:$=>P(L,$.target.value),children:Object.values(q.AttachedDatabaseTypeEnum).map($=>t.jsx(tt,{value:$,children:$},$))}),U.filter($=>$.visibleWhen?(D[$.visibleWhen.field]||A(L,$.visibleWhen.field)||U.find(Q=>Q.name===$.visibleWhen?.field)?.selectOptions?.[0]?.value)===$.visibleWhen.value:!0).map($=>t.jsx(c.TextField,{id:`attachedDb_${L}_${$.name}`,name:`attachedDb_${L}_${$.name}`,label:$.label,type:$.selectOptions?void 0:$.type,fullWidth:!0,size:"small",required:$.required,select:!!$.selectOptions,defaultValue:A(L,$.name)||$.selectOptions?.[0]?.value,onChange:$.selectOptions?W=>{const Q=[...h];Q[L]={...Q[L],[$.name]:W.target.value},y(Q)}:void 0,children:$.selectOptions?.map(W=>t.jsx(tt,{value:W.value,children:W.label},W.value))},$.name))]},L)})]}):Gt[a].map(D=>{const L=e?.[pr[a]??""]?.[D.name??""]??"",U=D.type==="password"||Fi.has(D.name),$=u.has(`${pr[a]??""}.${D.name}`),W=D.selectOptions?L===""||L===void 0?D.selectOptions[0]?.value:String(L):void 0;return t.jsx(c.TextField,{id:D.name,name:D.name,label:D.label,type:D.type,fullWidth:!0,size:"small",required:D.required&&!U&&!L,select:!!D.selectOptions,defaultValue:D.selectOptions?W:L,placeholder:$?"Leave empty to keep existing":void 0,helperText:U?$?"Stored value is not shown. Leave empty to keep it.":"No value stored.":void 0,children:D.selectOptions?.map(Q=>t.jsx(tt,{value:Q.value,children:Q.label},Q.value))},D.name)})]})})})]})}function Li(e,n){return!e||e.type!=="duckdb"?!1:(e.duckdbConnection?.attachedDatabases||[]).some(o=>o.type==="azure"&&o.name===n)}function mh(e){return e.startsWith("gs://")||e.startsWith("s3://")||e.startsWith("https://")||e.startsWith("abfss://")||e.startsWith("az://")}function tl({connectionName:e,resourceUri:n,schema:r,connection:o}){const{apiClients:i}=q.useServer(),{environmentName:l}=c.parseResourceUri(n),[a,d]=j.useState(null),[u,h]=j.useState(r||null),[y,b]=j.useState(!1),{data:x,isError:v,isLoading:k,error:C}=c.useQueryWithApiError({queryKey:["schemas",l,e],queryFn:()=>i.connections.listSchemas(l,e)}),S=x?.data||[];return t.jsxs(p.Grid,{container:!0,spacing:1,children:[!r&&t.jsx(p.Grid,{size:{xs:12,md:4},children:t.jsxs(p.Paper,{sx:{p:1,m:0},children:[t.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:0},children:[t.jsx(p.Typography,{variant:"overline",fontWeight:"bold",children:"Table Paths"}),t.jsx(p.FormControlLabel,{control:t.jsx(p.Switch,{checked:y,onChange:T=>b(T.target.checked)}),label:"Hidden Schemas"})]}),t.jsx(p.Divider,{sx:{mt:"2px"}}),t.jsxs(p.Box,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[k&&t.jsx(c.Loading,{text:"Loading schemas..."}),v&&t.jsx(c.ApiErrorDisplay,{error:C,context:`${l} > ${e} > Schemas`}),!k&&!v&&S.length===0&&t.jsx(p.Typography,{variant:"body2",children:"No Schemas"}),!k&&!v&&S.length>0&&t.jsx(p.List,{dense:!0,disablePadding:!0,children:S.map(T=>{const O=T.name;if(T.isHidden&&!y)return null;const E=u===O;return t.jsx(p.ListItemButton,{selected:E,onClick:()=>{h(O),d(null)},children:t.jsx(p.ListItemText,{primary:O})},O)})})]})]})}),t.jsx(p.Grid,{size:{xs:12,md:r?6:4},children:u&&t.jsx(p.Paper,{sx:{p:1,m:0},children:t.jsx(yh,{connectionName:e,schemaName:u,onTableSelect:T=>{d(T)},resourceUri:n,connection:o})})}),t.jsx(p.Grid,{size:{xs:12,md:r?6:4},children:u&&a&&t.jsx(ph,{environmentName:l,connectionName:e,schemaName:u,tableResource:a})})]})}function ph({environmentName:e,connectionName:n,schemaName:r,tableResource:o}){const{apiClients:i}=q.useServer(),{data:l,isLoading:a,isError:d,error:u}=c.useQueryWithApiError({queryKey:["connectionTableDetail",e,n,r,o],queryFn:()=>i.connections.getTable(e,n,r,o),enabled:!!r&&!!o}),h={resource:l?.data?.resource??o,columns:l?.data?.columns??[]};return t.jsxs(p.Paper,{sx:{p:1,m:0},children:[d&&t.jsx(c.ApiErrorDisplay,{error:u,context:`${e} > ${n} > ${r} > ${o}`}),!d&&t.jsx(gh,{table:h,loading:a})]})}function gh({table:e,loading:n}){return n?t.jsx(c.Loading,{text:"Loading columns..."}):t.jsxs(t.Fragment,{children:[t.jsxs(p.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]}),t.jsx(p.Divider,{}),t.jsx(p.Box,{sx:{mt:"10px",maxHeight:"600px",overflowY:"auto"},children:t.jsx(p.TableContainer,{children:t.jsxs(p.Table,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[t.jsx(p.TableHead,{children:t.jsxs(p.TableRow,{children:[t.jsx(p.TableCell,{children:"NAME"}),t.jsx(p.TableCell,{children:"TYPE"})]})}),t.jsx(p.TableBody,{children:e.columns?.sort((r,o)=>r.name.localeCompare(o.name))?.map(r=>t.jsxs(p.TableRow,{children:[t.jsx(p.TableCell,{children:r.name}),t.jsx(p.TableCell,{children:r.type})]},r.name))})]})})})]})}function yh({connectionName:e,schemaName:n,onTableSelect:r,resourceUri:o,connection:i}){const{environmentName:l}=c.parseResourceUri(o),{apiClients:a}=q.useServer(),[d,u]=j.useState(""),{data:h,isSuccess:y,isError:b,error:x,isLoading:v}=c.useQueryWithApiError({queryKey:["tablesInSchema",l,e,n],queryFn:()=>a.connections.listTables(l,e,n)}),k=Li(i,n),C=T=>k?T:T.split(".").pop()||T,S=y&&h?.data?h.data.filter(T=>C(T.resource).toLowerCase().includes(d.toLowerCase())).sort((T,O)=>C(T.resource).localeCompare(C(O.resource))):[];return t.jsxs(t.Fragment,{children:[t.jsx(p.Typography,{variant:"overline",fontWeight:"bold",children:mh(n)||Li(i,n)?`Files in ${n}`:`Tables in ${n}`}),t.jsx(p.Divider,{}),t.jsx(p.Box,{sx:{mt:1,mb:1},children:t.jsx(p.TextField,{size:"small",fullWidth:!0,placeholder:"Search tables...",value:d,onChange:T=>u(T.target.value),variant:"outlined"})}),t.jsx(p.Divider,{}),t.jsxs(p.Box,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[v&&t.jsx(c.Loading,{text:"Fetching Tables..."}),b&&t.jsx(c.ApiErrorDisplay,{error:x,context:`${l} > ${e} > ${n}`}),y&&S.length===0&&t.jsx(p.Typography,{variant:"body2",children:"No Tables"}),y&&h?.data&&h.data.length>0&&t.jsx(p.List,{dense:!0,disablePadding:!0,children:S.map(T=>{let O=C(T.resource);return!k&&T.resource.includes("://")&&(O=T.resource.split("/").pop()||T.resource),t.jsx(p.ListItemButton,{onClick:()=>r(T.resource),children:t.jsx(p.ListItemText,{primary:O,secondary:T.columns.length>0?`${T.columns.length} columns`:void 0})},T.resource)})})]})]})}const xh={bigquery:"BigQuery",snowflake:"Snowflake",postgres:"PostgreSQL",mysql:"MySQL",sqlserver:"SQL Server",trino:"Trino",databricks:"Databricks",duckdb:"DuckDB",ducklake:"DuckLake",s3:"S3",gcs:"GCS",azure:"Azure"};function vh(e){return e?xh[e]??e:""}function bh({resourceUri:e}){const{apiClients:n,mutable:r}=q.useServer(),o=yt.useQueryClient(),{environmentName:i}=c.parseResourceUri(e),[l,a]=j.useState(""),[d,u]=j.useState(null),h=c.encodeResourceUri({environmentName:i,connectionName:d}),{data:y,isSuccess:b,isError:x,error:v}=c.useQueryWithApiError({queryKey:["connections",i],queryFn:()=>n.connections.listConnections(i)}),k=c.useMutationWithApiError({mutationFn:Ht("connection","create",M=>n.environments.updateEnvironment(i,{name:i,connections:[...y.data,M]})),onSuccess(){a("Connection added successfully"),o.invalidateQueries({queryKey:["connections",i]})},onError(M){a(M.message)}}),C=c.useMutationWithApiError({mutationFn:Ht("connection","update",M=>n.environments.updateEnvironment(i,{name:i,connections:y.data.map(E=>E.name===M.name?M:E)})),onSuccess(M,E){a(`Connection ${E.name} updated successfully`),o.invalidateQueries({queryKey:["connections",i]})},onError(M){a(M.message)}}),S=c.useMutationWithApiError({mutationFn:Ht("connection","delete",M=>{if(!M.name)throw new Error("Cannot delete a connection with no name");return n.connections.deleteConnection(i,M.name)}),onSuccess(M,E){a(`Connection ${E.name} deleted successfully`),o.invalidateQueries({queryKey:["connections",i]})},onError(M){a(M.message)}}),T=b?[...y.data].sort((M,E)=>(M.name??"").localeCompare(E.name??"")):[],O=k.isPending||C.isPending||S.isPending;return t.jsxs(_t,{title:"Connections",...b?{count:T.length}:{},description:"Database connections available to packages in this environment",...r&&b?{action:t.jsx(dh,{onSubmit:M=>k.mutateAsync(M),isSubmitting:k.isPending})}:{},children:[!b&&!x&&t.jsx(p.Typography,{variant:"body2",color:"text.secondary",children:"Fetching Connections..."}),x&&t.jsx(c.ApiErrorDisplay,{error:v,context:`${i} > Connections`}),b&&T.length===0&&t.jsx(p.Typography,{variant:"body2",color:"text.secondary",children:"No connections yet."}),b&&T.length>0&&t.jsx(p.Stack,{children:T.map(M=>t.jsx(wh,{connection:M,mutable:r,isMutating:O,onOpenExplorer:()=>u(M.name??null),onEdit:E=>C.mutateAsync(E),onDelete:E=>S.mutateAsync(E)},M.name))}),t.jsx(p.Snackbar,{open:l!=="",autoHideDuration:6e3,onClose:()=>a(""),message:l}),t.jsx(c.AppDialog,{open:d!==null,onClose:()=>u(null),maxWidth:"lg",title:`Connection explorer: ${d??""}`,showClose:!0,children:d&&t.jsx(tl,{resourceUri:h,connectionName:d,connection:y?.data?.find(M=>M.name===d)})})]})}function wh({connection:e,mutable:n,isMutating:r,onOpenExplorer:o,onEdit:i,onDelete:l}){const[a,d]=j.useState(null),u=!!a,h=b=>{b.stopPropagation(),d(b.currentTarget)},y=()=>d(null);return t.jsx(ss,{icon:t.jsx(Kd,{sx:{fontSize:18}}),tint:q.SURFACE_TINT.connection,label:e.name??"",ariaLabel:e.name??"",description:vh(e.type),onClick:o,...n?{trailingAction:t.jsxs(t.Fragment,{children:[t.jsx(p.IconButton,{size:"small",onClick:h,"aria-label":`Connection actions for ${e.name??""}`.trim(),children:t.jsx(Pt.MoreVert,{fontSize:"small"})}),t.jsxs(p.Menu,{anchorEl:a,open:u,onClose:y,onClick:b=>b.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[t.jsx(fh,{connection:e,onSubmit:i,isSubmitting:r,onCloseDialog:y}),t.jsx(hh,{connection:e,onCloseDialog:y,isMutating:r,onDelete:()=>l(e)})]})]})}:{}})}const Sh=c.createSvgIcon([t.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"),t.jsx("path",{d:"M9 12h6v2H9z"},"1")]);function kh({resourceUri:e,onCloseDialog:n}){const[r,o]=j.useState(!1),{apiClients:i}=q.useServer(),l=()=>{o(!0)},a=()=>{o(!1),n()},{environmentName:d,packageName:u}=c.parseResourceUri(e),h=_n({mutationFn:()=>i.packages.deletePackage(d,u),success:"Package deleted",invalidates:[["packages",d]],closeDialog:a,resource:"package",action:"delete"});return t.jsxs(j.Fragment,{children:[t.jsxs(p.MenuItem,{onClick:l,children:[t.jsx(p.ListItemIcon,{children:t.jsx(Pt.Delete,{fontSize:"small"})}),t.jsx(p.ListItemText,{children:"Delete"})]}),t.jsx(c.AppDialog,{open:r,onClose:a,title:"Delete package",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{onClick:a,children:"Cancel"}),t.jsx(c.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>h.mutate(),loading:h.isPending,children:"Delete package"})]}),children:t.jsxs(c.Typography,{variant:"body2",children:["Delete ",t.jsx("strong",{children:u}),"? The package stops being served and this cannot be undone."]})}),h.notice]})}function Ch({package:e,resourceUri:n,onCloseDialog:r}){const[o,i]=j.useState(!1),{apiClients:l}=q.useServer(),a=()=>{i(!0)},d=()=>{i(!1),r()},{packageName:u,environmentName:h}=c.parseResourceUri(n),y=_n({mutationFn(x){return l.packages.updatePackage(h,u,{name:u,description:x.description})},success:"Package updated",invalidates:[["packages",h]],closeDialog:d,resource:"package",action:"update"}),b=x=>{x.preventDefault();const k=new FormData(x.currentTarget).get("description")?.toString();y.mutate({description:k})};return t.jsxs(j.Fragment,{children:[t.jsxs(p.MenuItem,{onClick:a,children:[t.jsx(p.ListItemIcon,{children:t.jsx(Pt.Edit,{fontSize:"small"})}),t.jsx(p.ListItemText,{children:"Edit"})]}),t.jsx(c.AppDialog,{open:o,onClose:d,title:"Edit package",description:`What ${e.name} is, for the people who open it.`,actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{disabled:y.isPending,onClick:d,children:"Cancel"}),t.jsx(c.Button,{type:"submit",form:"package-form",variant:"contained",loading:y.isPending,children:"Save changes"})]}),children:t.jsx("form",{onSubmit:b,id:"package-form",children:t.jsxs(p.Stack,{sx:{gap:2},children:[t.jsx(c.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}}),t.jsx(c.TextField,{id:"description",name:"description",label:"Description",multiline:!0,fullWidth:!0,rows:4,size:"small",defaultValue:e.description,InputLabelProps:{shrink:!0}})]})})}),y.notice]})}function nl({onSelectPackage:e,resourceUri:n}){const{apiClients:r}=q.useServer(),{environmentName:o}=c.parseResourceUri(n),{data:i,isSuccess:l,isError:a,error:d}=c.useQueryWithApiError({queryKey:["packages",o],queryFn:()=>r.packages.listPackages(o)});if(a)return t.jsx(c.ApiErrorDisplay,{error:d,context:`${o} > Packages`});if(!l)return t.jsx(c.Loading,{text:"Fetching Packages..."});const u=[...i.data].sort((h,y)=>h.name.localeCompare(y.name));return t.jsx(p.Stack,{children:u.map(h=>{const y=c.encodeResourceUri({environmentName:o,packageName:h.name});return t.jsx(jh,{pkg:h,packageResourceUri:y,onSelectPackage:e},h.name)})})}function jh({pkg:e,packageResourceUri:n,onSelectPackage:r}){const{mutable:o}=q.useServer(),i=e.versionId!==void 0||e.latestVersion!==void 0,[l,a]=j.useState(null),d=!!l,u=y=>{y.stopPropagation(),a(y.currentTarget)},h=()=>a(null);return t.jsx(ss,{icon:t.jsx(Sh,{sx:{fontSize:18}}),tint:q.SURFACE_TINT.package,label:e.name,ariaLabel:e.name,...e.description?{description:e.description}:{},onClick:y=>r(e.name,y),...o?{trailingAction:t.jsxs(t.Fragment,{children:[t.jsx(p.IconButton,{size:"small",onClick:u,"aria-label":`Package actions for ${e.name}`,children:t.jsx(Pt.MoreVert,{fontSize:"small"})}),t.jsxs(p.Menu,{anchorEl:l,open:d,onClose:h,onClick:y=>y.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[!i&&t.jsx(Ch,{package:e,resourceUri:n,onCloseDialog:h}),t.jsx(kh,{resourceUri:n,onCloseDialog:h})]})]})}:{}})}function Th({onSelectPackage:e,resourceUri:n}){const{apiClients:r,mutable:o}=q.useServer(),{environmentName:i}=c.parseResourceUri(n),l=c.useQueryWithApiError({queryKey:["packages",i],queryFn:()=>r.packages.listPackages(i)});return j.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"})},[]),t.jsxs(p.Container,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[t.jsxs(p.Box,{sx:{mb:4},children:[t.jsx(p.Typography,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:i}),t.jsx(p.Typography,{variant:"body2",color:"text.secondary",children:"Manage packages and database connections in this environment. Open a package to explore its models and notebooks."})]}),t.jsx(_t,{title:"Packages",...l.isSuccess?{count:l.data.data.length}:{},description:"Published packages available for use in this environment",...o?{action:t.jsx(Yd,{resourceUri:n})}:{},children:t.jsx(nl,{onSelectPackage:e,resourceUri:n})}),t.jsx(bh,{resourceUri:n}),t.jsx(Ad,{resourceUri:n})]})}function _i({array1:e,array2:n,parser:r=o=>o}){return e&&n&&e.length===n.length&&e.every((o,i)=>r(o)===r(n[i]))}function Pi(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Oh(e={}){const{ignoreAccents:n=!0,ignoreCase:r=!0,limit:o,matchFrom:i="any",stringify:l,trim:a=!1}=e;return(d,{inputValue:u,getOptionLabel:h})=>{let y=a?u.trim():u;r&&(y=y.toLowerCase()),n&&(y=Pi(y));const b=y?d.filter(x=>{let v=(l||h)(x);return r&&(v=v.toLowerCase()),n&&(v=Pi(v)),i==="start"?v.startsWith(y):v.includes(y)}):d;return typeof o=="number"?b.slice(0,o):b}}const Mh=Oh(),zi=5,Eh=e=>e.current!==null&&e.current.parentElement?.contains(document.activeElement),Ih=[];function Wi(e,n,r,o){if(n||e==null||o)return"";const i=r(e);return typeof i=="string"?i:""}function Dh(e){const{unstable_isActiveElementInListbox:n=Eh,unstable_classNamePrefix:r="Mui",autoComplete:o=!1,autoHighlight:i=!1,autoSelect:l=!1,blurOnSelect:a=!1,clearOnBlur:d=!e.freeSolo,clearOnEscape:u=!1,componentName:h="useAutocomplete",defaultValue:y=e.multiple?Ih:null,disableClearable:b=!1,disableCloseOnSelect:x=!1,disabled:v,disabledItemsFocusable:k=!1,disableListWrap:C=!1,filterOptions:S=Mh,filterSelectedOptions:T=!1,freeSolo:O=!1,getOptionDisabled:M,getOptionKey:E,getOptionLabel:R=V=>V.label??V,groupBy:P,handleHomeEndKeys:A=!e.freeSolo,id:H,includeInputInList:D=!1,inputValue:L,isOptionEqualToValue:U=(V,B)=>V===B,multiple:$=!1,onChange:W,onClose:Q,onHighlightChange:te,onInputChange:ee,onOpen:G,open:Z,openOnFocus:ae=!1,options:z,readOnly:re=!1,renderValue:se,selectOnFocus:ne=!e.freeSolo,value:Ie}=e,de=c.useId(H);let pe=R;pe=V=>{const B=R(V);return typeof B!="string"?String(B):B};const De=Ce.useRef(!1),Le=Ce.useRef(!0),oe=Ce.useRef(null),K=Ce.useRef(null),[le,be]=Ce.useState(null),[ge,ue]=Ce.useState(-1),ye=i?0:-1,$e=Ce.useRef(ye),ze=Ce.useRef(Wi(y??Ie,$,pe)).current,[me,Y]=c.useControlled({controlled:Ie,default:y,name:h}),[ie,Oe]=c.useControlled({controlled:L,default:ze,name:h,state:"inputValue"}),[Fe,at]=Ce.useState(!1),Me=Ce.useCallback((V,B,ce)=>{if(!($?me.length<B.length:B!==null)&&!d)return;const J=Wi(B,$,pe,se);ie!==J&&(Oe(J),ee&&ee(V,J,ce))},[pe,ie,$,ee,Oe,d,me,se]),[lt,xt]=c.useControlled({controlled:Z,default:!1,name:h,state:"open"}),[vt,Ot]=Ce.useState(!0),pt=!$&&me!=null&&ie===pe(me),Ke=lt&&!re,he=Ke?S(z.filter(V=>!(T&&($?me:[me]).some(B=>B!==null&&U(V,B)))),{inputValue:pt&&vt?"":ie,getOptionLabel:pe}):[],Qe=hd({filteredOptions:he,value:me,inputValue:ie});Ce.useEffect(()=>{const V=me!==Qe.value;Fe&&!V||O&&!V||Me(null,me,"reset")},[me,Me,Fe,Qe.value,O]);const qe=lt&&he.length>0&&!re,ct=c.useEventCallback(V=>{if(V===-1)oe.current.focus();else{const B=se?"data-item-index":"data-tag-index";le.querySelector(`[${B}="${V}"]`).focus()}});Ce.useEffect(()=>{$&&ge>me.length-1&&(ue(-1),ct(-1))},[me,$,ge,ct]);function ut(V,B){if(!K.current||V<0||V>=he.length)return-1;let ce=V;for(;;){const ve=K.current.querySelector(`[data-option-index="${ce}"]`),J=k?!1:!ve||ve.disabled||ve.getAttribute("aria-disabled")==="true";if(ve&&ve.hasAttribute("tabindex")&&!J)return ce;if(B==="next"?ce=(ce+1)%he.length:ce=(ce-1+he.length)%he.length,ce===V)return-1}}const Ze=c.useEventCallback(({event:V,index:B,reason:ce})=>{if($e.current=B,B===-1?oe.current.removeAttribute("aria-activedescendant"):oe.current.setAttribute("aria-activedescendant",`${de}-option-${B}`),te&&["mouse","keyboard","touch"].includes(ce)&&te(V,B===-1?null:he[B],ce),!K.current)return;const ve=K.current.querySelector(`[role="option"].${r}-focused`);ve&&(ve.classList.remove(`${r}-focused`),ve.classList.remove(`${r}-focusVisible`));let J=K.current;if(K.current.getAttribute("role")!=="listbox"&&(J=K.current.parentElement.querySelector('[role="listbox"]')),!J)return;if(B===-1){J.scrollTop=0;return}const Ve=K.current.querySelector(`[data-option-index="${B}"]`);if(Ve&&(Ve.classList.add(`${r}-focused`),ce==="keyboard"&&Ve.classList.add(`${r}-focusVisible`),J.scrollHeight>J.clientHeight&&ce!=="mouse"&&ce!=="touch")){const Ge=Ve,Ct=J.clientHeight+J.scrollTop,vn=Ge.offsetTop+Ge.offsetHeight;vn>Ct?J.scrollTop=vn-J.clientHeight:Ge.offsetTop-Ge.offsetHeight*(P?1.3:0)<J.scrollTop&&(J.scrollTop=Ge.offsetTop-Ge.offsetHeight*(P?1.3:0))}}),fe=c.useEventCallback(({event:V,diff:B,direction:ce="next",reason:ve})=>{if(!Ke)return;const Ve=ut((()=>{const Ge=he.length-1;if(B==="reset")return ye;if(B==="start")return 0;if(B==="end")return Ge;const Ct=$e.current+B;return Ct<0?Ct===-1&&D?-1:C&&$e.current!==-1||Math.abs(B)>1?0:Ge:Ct>Ge?Ct===Ge+1&&D?-1:C||Math.abs(B)>1?Ge:0:Ct})(),ce);if(Ze({index:Ve,reason:ve,event:V}),o&&B!=="reset")if(Ve===-1)oe.current.value=ie;else{const Ge=pe(he[Ve]);oe.current.value=Ge,Ge.toLowerCase().indexOf(ie.toLowerCase())===0&&ie.length>0&&oe.current.setSelectionRange(ie.length,Ge.length)}}),Ue=!_i({array1:Qe.filteredOptions,array2:he,parser:pe}),bt=()=>{const V=(B,ce)=>{const ve=B?pe(B):"",J=ce?pe(ce):"";return ve===J};if($e.current!==-1&&!_i({array1:Qe.filteredOptions,array2:he,parser:pe})&&Qe.inputValue===ie&&($?me.length===Qe.value.length&&Qe.value.every((B,ce)=>pe(me[ce])===pe(B)):V(Qe.value,me))){const B=Qe.filteredOptions[$e.current];if(B)return he.findIndex(ce=>pe(ce)===pe(B))}return-1},ke=Ce.useCallback(()=>{if(!Ke)return;const V=bt();if(V!==-1){$e.current=V;return}const B=$?me[0]:me;if(he.length===0||B==null){fe({diff:"reset"});return}if(K.current){if(B!=null){const ce=he[$e.current];if($&&ce&&me.findIndex(J=>U(ce,J))!==-1)return;const ve=he.findIndex(J=>U(J,B));ve===-1?fe({diff:"reset"}):Ze({index:ve});return}if($e.current>=he.length-1){Ze({index:he.length-1});return}Ze({index:$e.current})}},[he.length,$?!1:me,T,fe,Ze,Ke,ie,$]),Ne=c.useEventCallback(V=>{c.setRef(K,V),V&&ke()});Ce.useEffect(()=>{Ue&&ke()},[ke,Ue]);const Ee=V=>{lt||(xt(!0),Ot(!0),G&&G(V))},Be=(V,B)=>{lt&&(xt(!1),Q&&Q(V,B))},ht=(V,B,ce,ve)=>{if($){if(me.length===B.length&&me.every((J,Ve)=>J===B[Ve]))return}else if(me===B)return;W&&W(V,B,ce,ve),Y(B)},We=Ce.useRef(!1),nt=(V,B,ce="selectOption",ve="options")=>{let J=ce,Ve=B;if($){Ve=Array.isArray(me)?me.slice():[];const Ge=Ve.findIndex(Ct=>U(B,Ct));Ge===-1?Ve.push(B):ve!=="freeSolo"&&(Ve.splice(Ge,1),J="removeOption")}Me(V,Ve,J),ht(V,Ve,J,{option:B}),!x&&(!V||!V.ctrlKey&&!V.metaKey)&&Be(V,J),(a===!0||a==="touch"&&We.current||a==="mouse"&&!We.current)&&oe.current.blur()};function Mt(V,B){if(V===-1)return-1;let ce=V;for(;;){if(B==="next"&&ce===me.length||B==="previous"&&ce===-1)return-1;const ve=se?"data-item-index":"data-tag-index",J=le.querySelector(`[${ve}="${ce}"]`);if(!J||!J.hasAttribute("tabindex")||J.disabled||J.getAttribute("aria-disabled")==="true")ce+=B==="next"?1:-1;else return ce}}const kt=(V,B)=>{if(!$)return;ie===""&&Be(V,"toggleInput");let ce=ge;ge===-1?ie===""&&B==="previous"&&(ce=me.length-1):(ce+=B==="next"?1:-1,ce<0&&(ce=0),ce===me.length&&(ce=-1)),ce=Mt(ce,B),ue(ce),ct(ce)},At=V=>{De.current=!0,Oe(""),ee&&ee(V,"","clear"),ht(V,$?[]:null,"clear")},gn=V=>B=>{if(V.onKeyDown&&V.onKeyDown(B),!B.defaultMuiPrevented&&(ge!==-1&&!["ArrowLeft","ArrowRight"].includes(B.key)&&(ue(-1),ct(-1)),B.which!==229))switch(B.key){case"Home":Ke&&A&&(B.preventDefault(),fe({diff:"start",direction:"next",reason:"keyboard",event:B}));break;case"End":Ke&&A&&(B.preventDefault(),fe({diff:"end",direction:"previous",reason:"keyboard",event:B}));break;case"PageUp":B.preventDefault(),fe({diff:-zi,direction:"previous",reason:"keyboard",event:B}),Ee(B);break;case"PageDown":B.preventDefault(),fe({diff:zi,direction:"next",reason:"keyboard",event:B}),Ee(B);break;case"ArrowDown":B.preventDefault(),fe({diff:1,direction:"next",reason:"keyboard",event:B}),Ee(B);break;case"ArrowUp":B.preventDefault(),fe({diff:-1,direction:"previous",reason:"keyboard",event:B}),Ee(B);break;case"ArrowLeft":!$&&se?ct(0):kt(B,"previous");break;case"ArrowRight":!$&&se?ct(-1):kt(B,"next");break;case"Enter":if($e.current!==-1&&Ke){const ce=he[$e.current],ve=M?M(ce):!1;if(B.preventDefault(),ve)return;nt(B,ce,"selectOption"),o&&oe.current.setSelectionRange(oe.current.value.length,oe.current.value.length)}else O&&ie!==""&&pt===!1&&($&&B.preventDefault(),nt(B,ie,"createOption","freeSolo"));break;case"Escape":Ke?(B.preventDefault(),B.stopPropagation(),Be(B,"escape")):u&&(ie!==""||$&&me.length>0||se)&&(B.preventDefault(),B.stopPropagation(),At(B));break;case"Backspace":if($&&!re&&ie===""&&me.length>0){const ce=ge===-1?me.length-1:ge,ve=me.slice();ve.splice(ce,1),ht(B,ve,"removeOption",{option:me[ce]})}!$&&se&&!re&&(Y(null),ct(-1));break;case"Delete":if($&&!re&&ie===""&&me.length>0&&ge!==-1){const ce=ge,ve=me.slice();ve.splice(ce,1),ht(B,ve,"removeOption",{option:me[ce]})}!$&&se&&!re&&(Y(null),ct(-1));break}},Pe=V=>{at(!0),ae&&!De.current&&Ee(V)},dt=V=>{if(n(K)){oe.current.focus();return}at(!1),Le.current=!0,De.current=!1,l&&$e.current!==-1&&Ke?nt(V,he[$e.current],"blur"):l&&O&&ie!==""?nt(V,ie,"blur","freeSolo"):d&&Me(V,me,"blur"),Be(V,"blur")},Kt=V=>{const B=V.target.value;ie!==B&&(Oe(B),Ot(!1),ee&&ee(V,B,"input")),B===""?!b&&!$&&ht(V,null,"clear"):Ee(V)},yn=V=>{const B=Number(V.currentTarget.getAttribute("data-option-index"));$e.current!==B&&Ze({event:V,index:B,reason:"mouse"})},ft=V=>{Ze({event:V,index:Number(V.currentTarget.getAttribute("data-option-index")),reason:"touch"}),We.current=!0},en=V=>{const B=Number(V.currentTarget.getAttribute("data-option-index"));nt(V,he[B],"selectOption"),We.current=!1},xn=V=>B=>{const ce=me.slice();ce.splice(V,1),ht(B,ce,"removeOption",{option:me[V]})},Qt=V=>{ht(V,null,"removeOption",{option:me})},Xe=V=>{lt?Be(V,"toggleInput"):Ee(V)},Je=V=>{V.currentTarget.contains(V.target)&&V.target.getAttribute("id")!==de&&V.preventDefault()},Ft=V=>{V.currentTarget.contains(V.target)&&(oe.current.focus(),ne&&Le.current&&oe.current.selectionEnd-oe.current.selectionStart===0&&oe.current.select(),Le.current=!1)},tn=V=>{!v&&(ie===""||!lt)&&Xe(V)};let Zt=O&&ie.length>0;Zt=Zt||($?me.length>0:me!==null);let nn=he;return P&&(nn=he.reduce((V,B,ce)=>{const ve=P(B);return V.length>0&&V[V.length-1].group===ve?V[V.length-1].options.push(B):V.push({key:ce,index:ce,group:ve,options:[B]}),V},[])),v&&Fe&&dt(),{getRootProps:(V={})=>({...V,onKeyDown:gn(V),onMouseDown:Je,onClick:Ft}),getInputLabelProps:()=>({id:`${de}-label`,htmlFor:de}),getInputProps:()=>({id:de,value:ie,onBlur:dt,onFocus:Pe,onChange:Kt,onMouseDown:tn,"aria-activedescendant":Ke?"":null,"aria-autocomplete":o?"both":"list","aria-controls":qe?`${de}-listbox`:void 0,"aria-expanded":qe,autoComplete:"off",ref:oe,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:v}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:At}),getItemProps:({index:V=0}={})=>({...$&&{key:V},...se?{"data-item-index":V}:{"data-tag-index":V},tabIndex:-1,...!re&&{onDelete:$?xn(V):Qt}}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:Xe}),getTagProps:({index:V})=>({key:V,"data-tag-index":V,tabIndex:-1,...!re&&{onDelete:xn(V)}}),getListboxProps:()=>({role:"listbox",id:`${de}-listbox`,"aria-labelledby":`${de}-label`,ref:Ne,onMouseDown:V=>{V.preventDefault()}}),getOptionProps:({index:V,option:B})=>{const ce=($?me:[me]).some(J=>J!=null&&U(B,J)),ve=M?M(B):!1;return{key:E?.(B)??pe(B),tabIndex:-1,role:"option",id:`${de}-option-${V}`,onMouseMove:yn,onClick:en,onTouchStart:ft,"data-option-index":V,"aria-disabled":ve,"aria-selected":ce}},id:de,inputValue:ie,value:me,dirty:Zt,expanded:Ke&&le,popupOpen:Ke,focused:Fe||ge!==-1,anchorEl:le,setAnchorEl:be,focusedItem:ge,focusedTag:ge,groupedOptions:nn}}function $h(e){return c.generateUtilityClass("MuiListSubheader",e)}c.generateUtilityClasses("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);const Ah=e=>{const{classes:n,color:r,disableGutters:o,inset:i,disableSticky:l}=e,a={root:["root",r!=="default"&&`color${c.capitalize(r)}`,!o&&"gutters",i&&"inset",!l&&"sticky"]};return c.composeClasses(a,$h,n)},Fh=c.styled("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[n.root,r.color!=="default"&&n[`color${c.capitalize(r.color)}`],!r.disableGutters&&n.gutters,r.inset&&n.inset,!r.disableSticky&&n.sticky]}})(c.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:n})=>!n.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:n})=>n.inset,style:{paddingLeft:72}},{props:({ownerState:n})=>!n.disableSticky,style:{position:"sticky",top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper}}]}))),Ks=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiListSubheader"}),{className:i,color:l="default",component:a="li",disableGutters:d=!1,disableSticky:u=!1,inset:h=!1,...y}=o,b={...o,color:l,component:a,disableGutters:d,disableSticky:u,inset:h},x=Ah(b);return t.jsx(Fh,{as:a,className:c.clsx(x.root,i),ref:r,ownerState:b,...y})});Ks&&(Ks.muiSkipListHighlight=!0);const Rh=c.createSvgIcon(t.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 Nh(e){return c.generateUtilityClass("MuiAutocomplete",e)}const Te=c.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 qi,Bi;const Lh=e=>{const{classes:n,disablePortal:r,expanded:o,focused:i,fullWidth:l,hasClearIcon:a,hasPopupIcon:d,inputFocused:u,popupOpen:h,size:y}=e,b={root:["root",o&&"expanded",i&&"focused",l&&"fullWidth",a&&"hasClearIcon",d&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",u&&"inputFocused"],tag:["tag",`tagSize${c.capitalize(y)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",h&&"popupIndicatorOpen"],popper:["popper",r&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return c.composeClasses(b,Nh,n)},_h=c.styled("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e,{fullWidth:o,hasClearIcon:i,hasPopupIcon:l,inputFocused:a,size:d}=r;return[{[`& .${Te.tag}`]:n.tag},{[`& .${Te.tag}`]:n[`tagSize${c.capitalize(d)}`]},{[`& .${Te.inputRoot}`]:n.inputRoot},{[`& .${Te.input}`]:n.input},{[`& .${Te.input}`]:a&&n.inputFocused},n.root,o&&n.fullWidth,l&&n.hasPopupIcon,i&&n.hasClearIcon]}})({[`&.${Te.focused} .${Te.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${Te.clearIndicator}`]:{visibility:"visible"}},[`& .${Te.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${Te.inputRoot}`]:{[`.${Te.hasPopupIcon}&, .${Te.hasClearIcon}&`]:{paddingRight:30},[`.${Te.hasPopupIcon}.${Te.hasClearIcon}&`]:{paddingRight:56},[`& .${Te.input}`]:{width:0,minWidth:30}},[`& .${c.inputClasses.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${c.inputClasses.root}.${c.inputBaseClasses.sizeSmall}`]:{[`& .${c.inputClasses.input}`]:{padding:"2px 4px 3px 0"}},[`& .${c.outlinedInputClasses.root}`]:{padding:9,[`.${Te.hasPopupIcon}&, .${Te.hasClearIcon}&`]:{paddingRight:39},[`.${Te.hasPopupIcon}.${Te.hasClearIcon}&`]:{paddingRight:65},[`& .${Te.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${Te.endAdornment}`]:{right:9}},[`& .${c.outlinedInputClasses.root}.${c.inputBaseClasses.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${Te.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${c.filledInputClasses.root}`]:{paddingTop:19,paddingLeft:8,[`.${Te.hasPopupIcon}&, .${Te.hasClearIcon}&`]:{paddingRight:39},[`.${Te.hasPopupIcon}.${Te.hasClearIcon}&`]:{paddingRight:65},[`& .${c.filledInputClasses.input}`]:{padding:"7px 4px"},[`& .${Te.endAdornment}`]:{right:9}},[`& .${c.filledInputClasses.root}.${c.inputBaseClasses.sizeSmall}`]:{paddingBottom:1,[`& .${c.filledInputClasses.input}`]:{padding:"2.5px 4px"}},[`& .${c.inputBaseClasses.hiddenLabel}`]:{paddingTop:8},[`& .${c.filledInputClasses.root}.${c.inputBaseClasses.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${Te.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${c.filledInputClasses.root}.${c.inputBaseClasses.hiddenLabel}.${c.inputBaseClasses.sizeSmall}`]:{[`& .${Te.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${Te.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${Te.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${Te.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${Te.inputRoot}`]:{flexWrap:"wrap"}}}]}),Ph=c.styled("div",{name:"MuiAutocomplete",slot:"EndAdornment"})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),zh=c.styled(c.IconButton,{name:"MuiAutocomplete",slot:"ClearIndicator"})({marginRight:-2,padding:4,visibility:"hidden"}),Wh=c.styled(c.IconButton,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[n.popupIndicator,r.popupOpen&&n.popupIndicatorOpen]}})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),qh=c.styled(c.Popper,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[{[`& .${Te.option}`]:n.option},n.popper,r.disablePortal&&n.popperDisablePortal]}})(c.memoTheme(({theme:e})=>({zIndex:(e.vars||e).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]}))),Bh=c.styled(c.Paper,{name:"MuiAutocomplete",slot:"Paper"})(c.memoTheme(({theme:e})=>({...e.typography.body1,overflow:"auto"}))),Vh=c.styled("div",{name:"MuiAutocomplete",slot:"Loading"})(c.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),Hh=c.styled("div",{name:"MuiAutocomplete",slot:"NoOptions"})(c.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),Uh=c.styled("ul",{name:"MuiAutocomplete",slot:"Listbox"})(c.memoTheme(({theme:e})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${Te.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"},[`&.${Te.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"},[`&.${Te.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),[`&.${Te.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}},[`&.${Te.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}}}}))),Gh=c.styled(Ks,{name:"MuiAutocomplete",slot:"GroupLabel"})(c.memoTheme(({theme:e})=>({backgroundColor:(e.vars||e).palette.background.paper,top:-8}))),Yh=c.styled("ul",{name:"MuiAutocomplete",slot:"GroupUl"})({padding:0,[`& .${Te.option}`]:{paddingLeft:24}}),Qs=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiAutocomplete"}),{autoComplete:i=!1,autoHighlight:l=!1,autoSelect:a=!1,blurOnSelect:d=!1,ChipProps:u,className:h,clearIcon:y=qi||(qi=t.jsx(Rh,{fontSize:"small"})),clearOnBlur:b=!o.freeSolo,clearOnEscape:x=!1,clearText:v="Clear",closeText:k="Close",componentsProps:C,defaultValue:S=o.multiple?[]:null,disableClearable:T=!1,disableCloseOnSelect:O=!1,disabled:M=!1,disabledItemsFocusable:E=!1,disableListWrap:R=!1,disablePortal:P=!1,filterOptions:A,filterSelectedOptions:H=!1,forcePopupIcon:D="auto",freeSolo:L=!1,fullWidth:U=!1,getLimitTagsText:$=Ae=>`+${Ae}`,getOptionDisabled:W,getOptionKey:Q,getOptionLabel:te,isOptionEqualToValue:ee,groupBy:G,handleHomeEndKeys:Z=!o.freeSolo,id:ae,includeInputInList:z=!1,inputValue:re,limitTags:se=-1,ListboxComponent:ne,ListboxProps:Ie,loading:de=!1,loadingText:pe="Loading…",multiple:De=!1,noOptionsText:Le="No options",onChange:oe,onClose:K,onHighlightChange:le,onInputChange:be,onOpen:ge,open:ue,openOnFocus:ye=!1,openText:$e="Open",options:ze,PaperComponent:me,PopperComponent:Y,popupIcon:ie=Bi||(Bi=t.jsx(c.ArrowDropDownIcon,{})),readOnly:Oe=!1,renderGroup:Fe,renderInput:at,renderOption:Me,renderTags:lt,renderValue:xt,selectOnFocus:vt=!o.freeSolo,size:Ot="medium",slots:pt={},slotProps:Ke={},value:he,...Qe}=o,{getRootProps:qe,getInputProps:ct,getInputLabelProps:ut,getPopupIndicatorProps:Ze,getClearProps:fe,getItemProps:Ue,getListboxProps:bt,getOptionProps:ke,value:Ne,dirty:Ee,expanded:Be,id:ht,popupOpen:We,focused:nt,focusedItem:Mt,anchorEl:kt,setAnchorEl:At,inputValue:gn,groupedOptions:Pe}=Dh({...o,componentName:"Autocomplete"}),dt=!T&&!M&&Ee&&!Oe,Kt=(!L||D===!0)&&D!==!1,{onMouseDown:yn}=ct(),{ref:ft,...en}=bt(),Qt=te||(Ae=>Ae.label??Ae),Xe={...o,disablePortal:P,expanded:Be,focused:nt,fullWidth:U,getOptionLabel:Qt,hasClearIcon:dt,hasPopupIcon:Kt,inputFocused:Mt===-1,popupOpen:We,size:Ot},Je=Lh(Xe),Ft={slots:{paper:me,popper:Y,...pt},slotProps:{chip:u,listbox:Ie,...C,...Ke}},[tn,Zt]=c.useSlot("listbox",{elementType:Uh,externalForwardedProps:Ft,ownerState:Xe,className:Je.listbox,additionalProps:en,ref:ft}),[nn,V]=c.useSlot("paper",{elementType:c.Paper,externalForwardedProps:Ft,ownerState:Xe,className:Je.paper}),[B,ce]=c.useSlot("popper",{elementType:c.Popper,externalForwardedProps:Ft,ownerState:Xe,className:Je.popper,additionalProps:{disablePortal:P,style:{width:kt?kt.clientWidth:null},role:"presentation",anchorEl:kt,open:We}});let ve;const J=Ae=>({className:Je.tag,disabled:M,...Ue(Ae)});if(De?Ne.length>0&&(lt?ve=lt(Ne,J,Xe):xt?ve=xt(Ne,J,Xe):ve=Ne.map((Ae,zt)=>{const{key:gt,...qt}=J({index:zt});return t.jsx(c.Chip,{label:Qt(Ae),size:Ot,...qt,...Ft.slotProps.chip},gt)})):xt&&Ne!=null&&(ve=xt(Ne,J,Xe)),se>-1&&Array.isArray(ve)){const Ae=ve.length-se;!nt&&Ae>0&&(ve=ve.splice(0,se),ve.push(t.jsx("span",{className:Je.tag,children:$(Ae)},ve.length)))}const Ge=Fe||(Ae=>t.jsxs("li",{children:[t.jsx(Gh,{className:Je.groupLabel,ownerState:Xe,component:"div",children:Ae.group}),t.jsx(Yh,{className:Je.groupUl,ownerState:Xe,children:Ae.children})]},Ae.key)),vn=Me||((Ae,zt)=>{const{key:gt,...qt}=Ae;return t.jsx("li",{...qt,children:Qt(zt)},gt)}),zn=(Ae,zt)=>{const gt=ke({option:Ae,index:zt});return vn({...gt,className:Je.option},Ae,{selected:gt["aria-selected"],index:zt,inputValue:gn},Xe)},Wn=Ft.slotProps.clearIndicator,Dr=Ft.slotProps.popupIndicator;return t.jsxs(Ce.Fragment,{children:[t.jsx(_h,{ref:r,className:c.clsx(Je.root,h),ownerState:Xe,...qe(Qe),children:at({id:ht,disabled:M,fullWidth:!0,size:Ot==="small"?"small":void 0,InputLabelProps:ut(),InputProps:{ref:At,className:Je.inputRoot,startAdornment:ve,onMouseDown:Ae=>{Ae.target===Ae.currentTarget&&yn(Ae)},...(dt||Kt)&&{endAdornment:t.jsxs(Ph,{className:Je.endAdornment,ownerState:Xe,children:[dt?t.jsx(zh,{...fe(),"aria-label":v,title:v,ownerState:Xe,...Wn,className:c.clsx(Je.clearIndicator,Wn?.className),children:y}):null,Kt?t.jsx(Wh,{...Ze(),disabled:M,"aria-label":We?k:$e,title:We?k:$e,ownerState:Xe,...Dr,className:c.clsx(Je.popupIndicator,Dr?.className),children:ie}):null]})}},inputProps:{className:Je.input,disabled:M,readOnly:Oe,...ct()}})}),kt?t.jsx(qh,{as:B,...ce,children:t.jsxs(Bh,{as:nn,...V,children:[de&&Pe.length===0?t.jsx(Vh,{className:Je.loading,ownerState:Xe,children:pe}):null,Pe.length===0&&!L&&!de?t.jsx(Hh,{className:Je.noOptions,ownerState:Xe,role:"presentation",onMouseDown:Ae=>{Ae.preventDefault()},children:Le}):null,Pe.length>0?t.jsx(tn,{as:ne,...Zt,children:Pe.map((Ae,zt)=>G?Ge({key:Ae.key,group:Ae.group,children:Ae.options.map((gt,qt)=>zn(gt,Ae.index+qt))}):zn(Ae,zt))}):null]})}):null]})});c.dayjs.extend(c.utc);function Os(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 Kh(e){return e==="DateMinMax"}function Ms(e){return e==="Between"}function Qh({spec:e,values:n,selection:r,onChange:o,retrievalFn:i}){const l=()=>r?.matchType?r.matchType:e.defaultMatchType?e.defaultMatchType:e.filterType==="DateMinMax"?"Between":Os(e.filterType)[0]||"Equals",[a,d]=j.useState(l()),[u,h]=j.useState(r?.value??""),[y,b]=j.useState(r?.value2??""),[x,v]=j.useState([]),[k,C]=j.useState(!1),[S,T]=j.useState(""),[O,M]=j.useState(!1),[E,R]=j.useState(!1),P=j.useRef(null),A=j.useRef(0),[H,D]=j.useState(!1);j.useEffect(()=>{if(e.filterType!=="Retrieval"||!i)return;const z=S.trim();if(z.length<=2){v([]),M(!1);return}return P.current&&clearTimeout(P.current),P.current=setTimeout(async()=>{A.current+=1;const re=A.current;C(!0);try{const se=await i(z,e);re===A.current&&v(se)}catch(se){re===A.current&&(console.error("Retrieval failed",se),v([]))}finally{re===A.current&&(C(!1),M(!0))}},500),()=>{P.current&&clearTimeout(P.current)}},[S,e,i]),j.useEffect(()=>{r===null?(h(""),b(""),d(e.defaultMatchType??(e.filterType==="DateMinMax"?"Between":Os(e.filterType)[0]||"Equals"))):r&&(d(r.matchType),h(r.value??""),b(r.value2??""))},[r,e.filterType,e.defaultMatchType]);const L=Os(e.filterType),U=Kh(e.filterType),$=Ms(a),W=U&&n.length>=2&&n[0].value instanceof Date?c.dayjs.utc(n[0].value):void 0,Q=U&&n.length>=2&&n[1].value instanceof Date?c.dayjs.utc(n[1].value):void 0,te=e.filterType==="MinMax"&&n.length>=2&&typeof n[0].value=="number"?n[0].value:void 0,ee=e.filterType==="MinMax"&&n.length>=2&&typeof n[1].value=="number"?n[1].value:void 0;if(L.length===0)return null;const G=z=>{const re=z.target.value;d(re),Ms(re)||b(""),u&&o({dimensionName:e.dimensionName,source:e.source,filterName:e.filterName,matchType:re,value:u,...Ms(re)&&y&&{value2:y}})},Z=(z,re)=>{h(z??""),re!==void 0&&b(re??"");const se=Array.isArray(z)&&z.length===0;o(!se&&z!==""&&z!==null&&z!==void 0?{dimensionName:e.dimensionName,source:e.source,filterName:e.filterName,matchType:a,value:z,...$&&re&&{value2:re}}:null)},ae=()=>{h(""),b(""),o(null)};return t.jsxs(Ye,{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:[t.jsxs(Ye,{sx:{fontWeight:600,color:e.required&&!r?"error.main":"text.primary"},children:[e.label??e.dimensionName,e.required&&t.jsx(Ye,{component:"span",sx:{color:r?"text.secondary":"error.main",fontWeight:400,fontSize:"0.7rem",ml:.5},children:"(required)"})]}),e.filterType!=="Boolean"&&!e.defaultMatchType&&L.length>1&&t.jsxs(c.FormControl,{size:"small",fullWidth:!0,children:[t.jsx(c.InputLabel,{children:"Match Type"}),t.jsx(c.Select,{value:a,label:"Match Type",onChange:G,MenuProps:{PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}},children:L.map(z=>t.jsx(tt,{value:z,children:z},z))})]}),e.filterType==="Star"&&a==="Equals"&&t.jsx(Qs,{multiple:!0,size:"small",options:n,getOptionLabel:z=>typeof z=="string"?z:typeof z=="object"&&z!==null&&"value"in z?String(z.value):String(z),value:Array.isArray(u)?u.map(z=>n.find(re=>re.value===z)||z):u?[n.find(z=>z.value===u)||u]:[],onChange:(z,re)=>{const se=re.map(ne=>typeof ne=="string"?ne:ne&&typeof ne=="object"&&"value"in ne?ne.value:ne);Z(se)},noOptionsText:"No matches found",renderInput:z=>t.jsx(c.TextField,{...z,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"&&a==="Contains"&&t.jsx(c.TextField,{size:"small",label:"Search Text",value:u,onChange:z=>h(z.target.value),onBlur:()=>Z(u),onKeyDown:z=>{z.key==="Enter"&&Z(u)},placeholder:"Enter text to search...",fullWidth:!0}),e.filterType==="Boolean"&&t.jsxs(c.FormControl,{size:"small",fullWidth:!0,children:[t.jsx(c.InputLabel,{children:"Value"}),t.jsxs(c.Select,{value:u===!0?"true":u===!1?"false":"",label:"Value",onChange:z=>{const re=z.target.value;re==="true"?Z(!0):re==="false"?Z(!1):ae()},MenuProps:{PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}},children:[t.jsx(tt,{value:"",children:t.jsx("em",{children:"Blank"})}),t.jsx(tt,{value:"true",children:"True"}),t.jsx(tt,{value:"false",children:"False"})]})]}),e.filterType==="Retrieval"&&a==="Semantic Search"&&t.jsx(Qs,{multiple:!0,size:"small",options:x,loading:k,getOptionLabel:z=>typeof z=="string"?z:typeof z=="object"&&z!==null&&"value"in z?String(z.value):String(z),value:Array.isArray(u)?u.map(z=>x.find(se=>se.value===z)||{value:z}):u?[{value:u}]:[],onInputChange:(z,re)=>{T(re)},onChange:(z,re)=>{const se=re.map(ne=>typeof ne=="string"?ne:ne&&typeof ne=="object"&&"value"in ne?ne.value:ne);Z(se)},noOptionsText:S.trim().length<=2?"Type at least 3 characters to search":"No matches found",renderInput:z=>t.jsx(c.TextField,{...z,size:"small",label:"Search Values",placeholder:"Type to search...",onFocus:()=>R(!0),onBlur:()=>R(!1),helperText:E&&!k&&O&&x.length===0?"No matches found":void 0,InputProps:{...z.InputProps,endAdornment:t.jsxs(t.Fragment,{children:[k?t.jsx(c.CircularProgress,{color:"inherit",size:20}):null,z.InputProps.endAdornment]})}}),freeSolo:!0,filterOptions:z=>z,slotProps:{paper:{sx:{"& .MuiAutocomplete-option":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}}}),e.filterType==="MinMax"&&!$&&t.jsx(c.TextField,{size:"small",type:"number",label:"Value",value:u,onChange:z=>Z(parseFloat(z.target.value)||""),onFocus:()=>D(!0),onBlur:()=>D(!1),placeholder:"Enter number...",fullWidth:!0,inputProps:{min:te,max:ee},helperText:H&&te!==void 0&&ee!==void 0?`Valid range: [${te} - ${ee}]`:void 0}),e.filterType==="MinMax"&&$&&t.jsxs(Ye,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(Ye,{sx:{display:"flex",gap:1,alignItems:"center"},children:[t.jsx(c.TextField,{size:"small",type:"number",label:"From",value:u,onChange:z=>Z(parseFloat(z.target.value)||"",y),onFocus:()=>D(!0),onBlur:()=>D(!1),placeholder:"Min...",fullWidth:!0,inputProps:{min:te,max:y||ee}}),t.jsx(Ye,{children:"to"}),t.jsx(c.TextField,{size:"small",type:"number",label:"To",value:y,onChange:z=>Z(u,parseFloat(z.target.value)||""),onFocus:()=>D(!0),onBlur:()=>D(!1),placeholder:"Max...",fullWidth:!0,inputProps:{min:u||te,max:ee}})]}),H&&te!==void 0&&ee!==void 0&&t.jsxs(c.Typography,{variant:"caption",color:"text.secondary",sx:{mt:-.5,ml:1.5},children:["Valid range: [",te," - ",ee,"]"]})]}),U&&!$&&t.jsx(c.LocalizationProvider,{dateAdapter:c.AdapterDayjs,children:t.jsx(c.DatePicker,{label:"Date",value:u instanceof Date?c.dayjs.utc(u):null,onChange:z=>{z===null?Z(null):z.isValid()&&Z(z.utc().toDate())},timezone:"UTC",minDate:u instanceof Date?void 0:W,maxDate:u instanceof Date?void 0:Q,referenceDate:a==="After"&&W?W:void 0,slotProps:{textField:{size:"small",fullWidth:!0,sx:{minWidth:150},onFocus:()=>D(!0),onBlur:()=>D(!1),helperText:H&&W&&Q?`Valid range: [${W.format("YYYY-MM-DD")} - ${Q.format("YYYY-MM-DD")}]`:void 0},openPickerButton:{sx:{backgroundColor:"transparent"}}}})}),U&&$&&t.jsx(c.LocalizationProvider,{dateAdapter:c.AdapterDayjs,children:t.jsxs(Ye,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(Ye,{sx:{display:"flex",gap:1,alignItems:"center"},children:[t.jsx(Ye,{sx:{flex:1,minWidth:0},children:t.jsx(c.DatePicker,{label:"From",value:u instanceof Date?c.dayjs.utc(u):null,onChange:z=>{z===null?Z(null,y):z.isValid()&&Z(z.utc().toDate(),y)},timezone:"UTC",minDate:u instanceof Date?void 0:W,maxDate:y instanceof Date?c.dayjs.utc(y):u instanceof Date?void 0:Q,referenceDate:W,slotProps:{textField:{size:"small",fullWidth:!0,onFocus:()=>D(!0),onBlur:()=>D(!1)},openPickerButton:{sx:{backgroundColor:"transparent"}}}})}),t.jsx(Ye,{children:"to"}),t.jsx(Ye,{sx:{flex:1,minWidth:0},children:t.jsx(c.DatePicker,{label:"To",value:y instanceof Date?c.dayjs.utc(y):null,onChange:z=>{z===null?Z(u,null):z.isValid()&&Z(u,z.utc().toDate())},timezone:"UTC",minDate:u instanceof Date?c.dayjs.utc(u):y instanceof Date?void 0:W,maxDate:y instanceof Date?void 0:Q,referenceDate:u instanceof Date?c.dayjs.utc(u):W,slotProps:{textField:{size:"small",fullWidth:!0,onFocus:()=>D(!0),onBlur:()=>D(!1)},openPickerButton:{sx:{backgroundColor:"transparent"}}}})})]}),H&&W&&Q&&t.jsxs(c.Typography,{variant:"caption",color:"text.secondary",sx:{mt:-.5,ml:1.5},children:["Valid range: [",W.format("YYYY-MM-DD")," -"," ",Q.format("YYYY-MM-DD"),"]"]})]})})]})}function is(e,n){const{matchType:r,value:o,value2:i}=n;if(Array.isArray(o))return r!=="Equals"&&r!=="Semantic Search"||o.length===0?"":`(${o.map(a=>`${e} = ${c.formatMalloyValue(a)}`).join(" or ")})`;switch(r){case"Equals":case"Semantic Search":return`${e} = ${c.formatMalloyValue(o)}`;case"Contains":if(typeof o=="string"){const l=ed.StringFilterExpression.unparse({operator:"contains",values:[o]});return`${e} ~ ${c.malloyFilterLiteral(l)}`}return`${e} = ${c.formatMalloyValue(o)}`;case"After":case"Greater Than":return`${e} > ${c.formatMalloyValue(o)}`;case"Before":case"Less Than":return`${e} < ${c.formatMalloyValue(o)}`;case"Between":return i!==void 0?`${e} >= ${c.formatMalloyValue(o)} and ${e} <= ${c.formatMalloyValue(i)}`:`${e} >= ${c.formatMalloyValue(o)}`;default:return""}}function Zh(e){const n=new Set,r=e.schema?.fields;if(!r)return n;for(const o of r)"kind"in o&&o.kind==="join"&&o.name&&n.add(o.name);return n}function Xh(e){if(!e)return null;for(const n of e)if(n.startsWith("##(filters)")){const r=n.slice(11).trim();try{const o=JSON.parse(r);if(Array.isArray(o)){const i=[];for(const l of o)if(typeof l=="string"){const a=l.indexOf(".");a>0&&a<l.length-1&&i.push({source:l.substring(0,a),dimension:l.substring(a+1)})}if(i.length>0)return{filters:i}}}catch(o){console.error(`Failed to parse "${n}" annotation:`,o)}}return null}function rl(e){if(e.startsWith("#(filter)")){const n=e.slice(9).trim();try{const r=JSON.parse(n);if(r.type)return r}catch(r){console.error(`Failed to parse "${e}" annotation:`,r)}}return null}function Jh(e){const n=e.match(/^#\s*label\s*=\s*"([^"]+)"/);return n?n[1]:null}function ef(e){const n=new Map;let r="";for(const o of e)if(o.type==="code"){if(!r&&o.text){const l=o.text.split(`
|
|
3
|
+
`}function yd(e,n){return[e,"rows",...n].join("_").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").replace(/^[_.]+|[_.]+$/g,"").slice(0,120)||"rows"}function xd(e,n,r){return r==="server_default"&&n!==void 0&&e>=n?n:void 0}const Ti="Download the rows behind this value as CSV, up to the server's row limit",vd=4e4;function bd(e,n){const r=URL.createObjectURL(new Blob([e],{type:"text/csv;charset=utf-8"})),o=document.createElement("a");o.href=r,o.download=n,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),vd)}function wd(e){const r=e?.response?.data?.message;return typeof r=="string"&&r!==""?r:e instanceof Error&&e.message!==""?e.message:"The request failed."}function Ua({query:e,preamble:n,environmentName:r,packageName:o,modelPath:i,versionId:l,givens:a,fileName:d}){const{apiClients:u}=q.useServer(),[h,y]=j.useState(!1),[b,x]=j.useState(Ti),[v,k]=j.useState(void 0),C=j.useRef(void 0);j.useEffect(()=>()=>C.current?.abort(),[]);const S=async()=>{C.current?.abort();const T=new AbortController;C.current=T,y(!0),k(void 0);try{const O=await u.models.executeQueryModel(r,o,i,{query:n===void 0?e:c.withPreamble(n,e),givens:a,versionId:l},void 0,void 0,{signal:T.signal});if(T.signal.aborted)return;const M=O.data,E=JSON.parse(M.result??"{}"),R=xd(Ha(E).length,M.queryRowLimit,M.queryRowLimitSource);x(R===void 0?Ti:`First ${R} rows: the server's row limit, so there may be more`),bd(gd(E),R===void 0?`${d}.csv`:`${d}_first_${R}_rows_server_limit.csv`)}catch(O){if(T.signal.aborted)return;k(`Download failed: ${wd(O)}`)}finally{C.current===T&&(C.current=void 0,y(!1))}};return t.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[v&&t.jsx(p.Typography,{role:"alert",variant:"caption",color:"error",sx:{maxWidth:320},children:v}),t.jsx(p.Tooltip,{title:b,children:t.jsx("span",{children:t.jsx(p.Button,{size:"small",startIcon:t.jsx(md,{fontSize:"small"}),onClick:()=>void S(),disabled:h,children:"Download CSV"})})})]})}const Ga=200;function Sd(e){const{target:n}=e;if(n!==void 0&&!(e.dimensions===void 0&&e.code===void 0))return{...e,target:n}}function Oi(e,n=Ga){const r=Cd(e);if(r===void 0)return;const o=[...e.target.filters,...r].join(", "),i=e.timezone?`timezone: '${c.escapeMalloyString(e.timezone)}'; `:"",l=n===null?"":`; limit: ${n}`,a=kd(e.target.source);if(a!==void 0)return`run: ${a} -> { ${i}where: ${o}; select: *${l} }`}function kd(e){return oo.isBareName(e)?e:e.includes("`")?void 0:`\`${e}\``}function js(e){return/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(e)?e:`(${e})`}function Cd(e){if(e.dimensions){const r=[];for(const{code:o,value:i}of e.dimensions){if(i.kind==="null_literal"){r.push(`${js(o)} is null`);continue}const l=La(i,e.timezone);if(l===void 0)return;r.push(`${js(o)} = ${l}`)}return r}const n=c.malloyLiteral(e.rawValue);return e.code!==void 0&&n?[`${js(e.code)} = ${n}`]:void 0}const jd="This value cannot be written as a filter, so its rows cannot be fetched.";function Mi(e){const n=e.drillClauses?Na(e.drillClauses,e.timezone):[];return n.length>0?n:[{field:e.field,label:e.label}]}function Td({request:e,environmentName:n,packageName:r,versionId:o,modelPath:i,preamble:l,givens:a,onClose:d,onDone:u,actions:h}){const{theme:y}=q.usePublisherTheme(),b=e?Oi(e):void 0,x=e?Oi(e,null):void 0,v=e&&x!==void 0?{query:x,...l===void 0?{}:{preamble:l},environmentName:n,packageName:r,modelPath:i,...o===void 0?{}:{versionId:o},givens:a,fileName:yd(e.target.source,Mi(e).map(k=>k.label))}:void 0;return t.jsxs(p.Dialog,{open:e!==void 0,onClose:d,maxWidth:"lg",fullWidth:!0,children:[t.jsxs(p.DialogTitle,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",pb:.5},children:[t.jsxs(p.Box,{children:[e?t.jsxs(t.Fragment,{children:["Rows where"," ",Mi(e).map((k,C)=>t.jsxs(j.Fragment,{children:[C>0&&" and ",t.jsx(p.Box,{component:"code",sx:{fontSize:"0.9em"},children:k.field})," ","is ",k.label]},C))]}):"Rows",t.jsx(p.Typography,{component:"div",variant:"caption",sx:{color:y.tileTitle,mt:.25},children:e?`The first ${Ga} rows of ${e.target.source} behind this value, with the tile's own filters and the controls applied.`:""})]}),t.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:1,ml:1},children:[v&&(h?h(v):t.jsx(Ua,{...v})),t.jsx(p.IconButton,{onClick:d,"aria-label":"Close",size:"small",sx:{color:"text.secondary"},children:t.jsx(c.CloseIcon,{fontSize:"small"})})]})]}),t.jsxs(p.DialogContent,{dividers:!0,sx:{p:0,minHeight:240},children:[b===void 0&&e&&t.jsx(p.Typography,{variant:"body2",sx:{p:2},children:jd}),b!==void 0&&t.jsx(Od,{query:l===void 0?b:c.withPreamble(l,b),environmentName:n,packageName:r,...o===void 0?{}:{versionId:o},modelPath:i,givens:a,...u?{onDone:u}:{}})]}),t.jsxs(p.DialogActions,{sx:{px:3,py:1.5},children:[b!==void 0&&t.jsx(p.Typography,{variant:"caption",sx:{mr:"auto",color:y.tileTitle,fontFamily:y.ui.font.mono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:b,children:b}),t.jsx(p.Button,{onClick:d,children:"Close"})]})]})}function Od({query:e,environmentName:n,packageName:r,versionId:o,modelPath:i,givens:l,onDone:a}){const d=c.useQueryResult({environmentName:n,packageName:r,modelPath:i,...o===void 0?{}:{versionId:o},query:e,givens:l}),{isSuccess:u,isError:h}=d,y=j.useRef(void 0);return j.useEffect(()=>{y.current=c.now()},[e]),j.useEffect(()=>{y.current===void 0||!u&&!h||(a?.(u,c.now()-y.current),y.current=void 0)},[u,h,a]),t.jsx(p.Box,{sx:{p:1},children:t.jsx(c.ResultPanel,{state:d,context:e})})}function rs({manifest:e,environmentName:n,packageName:r,versionId:o,documentName:i,givens:l,onGivensChange:a,onNavigate:d,height:u,maxResultSize:h,controlsLayout:y="bar",preamble:b,runModelPath:x,hiddenGivens:v,literalReads:k,onLinkNavigate:C,actions:S,rowsActions:T}){const O=j.useMemo(()=>C?{environmentName:n,packageName:r,sourcePath:e.path??i,onNavigate:C}:void 0,[n,r,e.path,i,C]),M=j.useMemo(()=>(e.givens??[]).filter(oe=>!(b!==void 0&&oe.secure===!0)&&!(oe.name!==void 0&&v?.includes(oe.name))),[e,v,b]),E=j.useMemo(()=>l===void 0?void 0:Object.fromEntries(Object.entries(l).filter(([,oe])=>typeof oe=="string")),[l]),R=c.useDocumentControls({specs:M,loaded:!0,startingValues:e.startingGivens,params:E,onGivensChange:a,documentKey:`${n}/${r}/${o??""}/${i}`,autorun:e.autorun!==!1,environmentName:n,packageName:r,modelPath:x??e.path,versionId:o,documentName:i,...b!==void 0?{preamble:b}:{},...l?{hostGivens:l}:{}}),{applied:P,declaredTypes:A,canSelf:H,onSelf:D}=R,L=c.useReportEvents(),U=j.useMemo(()=>{const oe=new Set((e.tiles??[]).flatMap(K=>K.givenNames??[]));return Object.fromEntries(Object.entries(l??{}).filter(([K])=>oe.has(K)&&!A.has(K)))},[e,l,A]),[$,W]=j.useState(void 0),Q=j.useCallback(oe=>{const K=Sd(oe);K!==void 0&&W(K)},[]),te=j.useMemo(()=>c.withHostGivens(c.givensToRequest(P,A),U),[P,A,U]),{reports:ee}=c.useReportListing(n,r,o,d!==void 0),G=j.useCallback(oe=>{const K=c.resolveDrillTarget(oe,ee);if(K.kind!=="path")return;const le=K.report.path;return ee.find(be=>be.path===le)?.title||void 0},[ee]),{bindingFor:Z,drillMenu:ae}=io({onNavigate:d,onSelf:D,canSelf:H,onRows:Q,destinationTitle:G}),z=j.useCallback((oe,K)=>Z(oe,K!==!0),[Z]),{columns:re,layout:se,tileMaxHeight:ne,tableMaxHeight:Ie}=c.layoutRules(e.layout,e.dashboardColumns),de=j.useMemo(()=>c.missingRequiredGivens(M,P,l),[M,P,l]);if(e.error)return t.jsx(c.ReportPage,{layout:se,header:t.jsx(Ei,{manifest:e,links:O,actions:S}),children:t.jsx(p.Alert,{severity:"error",children:e.error})});const pe=x??e.path,De=e.tiles??[],Le=c.isPlaced(De);return t.jsxs(c.ReportPage,{layout:se,header:t.jsx(Ei,{manifest:e,links:O,actions:S}),controls:M.length>0?t.jsx(c.StickyControls,{children:t.jsx(c.GivensPanel,{...R.panel,layout:y})}):void 0,children:[de.length>0&&t.jsx(p.Alert,{severity:"info",children:c.requiredPrompt(de)}),pe===void 0?t.jsx(p.Alert,{severity:"error",children:"This dashboard has no model path, so there is nothing to run."}):De.length>0?t.jsx(c.DashboardGrid,{tiles:De,columns:re,minTilePx:c.MIN_TILE_PX,rowGapPx:c.GRID_GAP_PX,keyOf:(oe,K)=>`${K}:${oe.kind==="text"?`text:${oe.name}`:oe.query}`,renderTile:(oe,K)=>oe.kind==="text"||oe.query===void 0?t.jsx(p.Box,{sx:oe.rowspan!==void 0||Le?{minHeight:0,overflow:"auto"}:void 0,children:t.jsx(Md,{markdown:oe.markdown??"",links:O})}):t.jsx(c.DashboardTile,{index:K,environmentName:n,packageName:r,versionId:o,modelPath:pe,tile:oe.query,label:oe.label,subtitle:oe.subtitle,borderless:oe.borderless,givens:P,hostGivens:U,declaredTypes:A,givenNames:oe.givenNames,height:oe.rowspan!==void 0||Le?c.tileHeightPx(oe.rowspan??c.PLACED_DEFAULT_ROWSPAN.query):se==="grid"?u??ne:ne,tableMaxHeight:Ie,fixedHeight:oe.rowspan!==void 0||Le,maxResultSize:h,drill:z(oe.query,oe.restricted),ignoredFilters:c.tileIgnoredFilterLabels(oe.givenNames&&(oe.query&&k?.[oe.query]?[...oe.givenNames,...k[oe.query]]:oe.givenNames),M),...b!==void 0?{preamble:b,restricted:oe.restricted}:{},...(()=>{const le=c.waitingOn(de,oe.givenNames);return le.length>0?{waitingFor:c.waitingText(le)}:{}})()})}):t.jsx(p.Alert,{severity:"warning",children:"This dashboard names neither a query nor any tiles."}),ae,pe!==void 0&&t.jsx(Td,{request:$,environmentName:n,packageName:r,...o===void 0?{}:{versionId:o},modelPath:pe,...b===void 0?{}:{preamble:b},givens:te,...T===void 0?{}:{actions:T},onClose:()=>W(void 0),onDone:(oe,K)=>{$&&L.emit({type:"report.rows_shown",source:$.target.source,view:$.target.queryName??"",field:$.field,ok:oe,durationMs:K})}})]})}function Md({markdown:e,links:n}){return t.jsx(c.TextTileFrame,{children:t.jsx(c.Prose,{variant:"document",links:n,children:e})})}function Ei({manifest:e,links:n,actions:r}){return t.jsx(c.ReportHeader,{title:e.title??e.name,actions:r,description:e.description?t.jsx(c.TextTileFrame,{children:t.jsx(c.Prose,{variant:"document",links:n,children:e.description})}):void 0})}const Ya=c.createSvgIcon(t.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"})),Ed="publisher:resize";function Id(e){return typeof e=="object"&&e!==null&&e.type===Ed&&typeof e.height=="number"}function Ka(e){return e.replace(/\/api\/v0\/?$/,"")}function Qa({server:e,environmentName:n,packageName:r,path:o,versionId:i}){const l=o.startsWith("public/")?o.slice(7):o,a=`${Ka(e)}/environments/${encodeURIComponent(n)}/packages/${encodeURIComponent(r)}/`+l;return i===void 0?a:`${a}${a.includes("?")?"&":"?"}versionId=${encodeURIComponent(i)}`}function Dd(e){try{const{environmentName:n,packageName:r,modelPath:o,versionId:i}=c.parseResourceUri(e);return!n||!r||!o?null:{environmentName:n,packageName:r,dataAppPath:o,versionId:i}}catch{return null}}function $d({resourceUri:e}){const{server:n,apiClients:r}=q.useServer(),o=Dd(e),i=o?.environmentName??"",l=o?.packageName??"",a=o?.dataAppPath??"",d=o?.versionId,u=j.useMemo(()=>Qa({server:n,environmentName:i,packageName:l,path:a,...d!==void 0?{versionId:d}:{}}),[n,i,l,a,d]),y=c.useQueryWithApiError({queryKey:["data-apps",i,l,d],queryFn:()=>r.dataApps.listDataApps(i,l,d),enabled:!!o}).data?.data?.find(S=>S.path===a),b=y?.title??a,x=y?.fit==="viewport",v=j.useRef(null),[k,C]=j.useState(120);return j.useEffect(()=>{if(x)return;function S(T){Id(T.data)&&T.source===v.current?.contentWindow&&T.data.height>0&&C(Math.ceil(T.data.height))}return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[x]),o?t.jsxs(p.Box,{sx:{p:3,...x?{height:"100%",display:"flex",flexDirection:"column"}:{maxWidth:1600,mx:"auto"}},children:[t.jsxs(p.Stack,{direction:"row",alignItems:"baseline",spacing:1,sx:{mb:1,flexShrink:0},children:[t.jsx(p.Typography,{variant:"h6",sx:{fontWeight:"fontWeightMedium",letterSpacing:"-0.025em"},children:b}),t.jsx(p.Typography,{variant:"caption",color:"text.secondary",sx:{fontFamily:q.MONO_FONT_FAMILY},children:a}),t.jsx(p.Box,{sx:{flex:1}}),t.jsx(p.Tooltip,{title:"Open standalone in new tab",children:t.jsx(p.IconButton,{size:"small",href:u,target:"_blank",rel:"noopener noreferrer","aria-label":"Open standalone in new tab",sx:{color:"text.secondary"},children:t.jsx(Ya,{fontSize:"small"})})})]}),t.jsx(p.Box,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,overflow:"hidden",backgroundColor:"background.paper",...x?{flex:1,minHeight:0}:{}},children:t.jsx("iframe",{ref:v,src:u,title:b,sandbox:"allow-scripts allow-same-origin allow-forms",style:{display:"block",width:"100%",height:x?"100%":k,border:0}})})]}):t.jsxs(p.Box,{sx:{p:3,maxWidth:1600,mx:"auto"},children:[t.jsx(p.Typography,{variant:"h6",sx:{fontWeight:"fontWeightMedium"},children:"Can't open data app"}),t.jsxs(p.Typography,{variant:"body2",color:"text.secondary",sx:{mt:1},children:["This data app link is missing an environment, package, or path:",t.jsx(p.Box,{component:"span",sx:{fontFamily:q.MONO_FONT_FAMILY,ml:1},children:e})]})]})}function _t({title:e,count:n,description:r,action:o,children:i}){const l=j.useId();return t.jsxs(p.Box,{component:"section","aria-labelledby":l,sx:{mb:4},children:[t.jsxs(p.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:r?0:1,minHeight:40},children:[t.jsxs(p.Stack,{direction:"row",alignItems:"baseline",spacing:1,children:[t.jsx(p.Typography,{id:l,variant:"h6",sx:{fontWeight:600,letterSpacing:"-0.025em",lineHeight:1.2},children:e}),n!==void 0&&t.jsxs(p.Typography,{variant:"caption",color:"text.secondary",children:["(",n,")"]})]}),o]}),r&&t.jsx(p.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:r}),t.jsx(p.Box,{children:i})]})}function Ad({resourceUri:e}){const{environmentName:n}=c.parseResourceUri(e),{apiClients:r}=q.useServer(),[o,i]=j.useState(!1),l=90,{data:a,isSuccess:d,isError:u,error:h}=c.useQueryWithApiError({queryKey:["about",n],queryFn:()=>r.environments.getEnvironment(n,!1)}),y=a?.data?.readme||"",b=y.split(/\s+/),x=b.length>l,v=b.slice(0,l).join(" ");return t.jsxs(t.Fragment,{children:[!d&&!u&&t.jsx(c.Loading,{text:"Fetching About..."}),d&&y&&t.jsxs(_t,{title:"Readme",children:[t.jsx(c.Prose,{variant:"caption",children:o||!x?y:v}),x&&t.jsx(p.Box,{sx:{mt:1},children:t.jsx(c.SecondaryButton,{label:o?"Read less":"Read more",onClick:()=>i(!o)})})]}),u&&t.jsx(c.ApiErrorDisplay,{error:h,context:`${n} > About`})]})}function Fd(e={}){const{autoHideDuration:n=null,disableWindowBlurListener:r=!1,onClose:o,open:i,resumeHideDuration:l}=e,a=c.useTimeout();Ce.useEffect(()=>{if(!i)return;function T(O){O.defaultPrevented||O.key==="Escape"&&o?.(O,"escapeKeyDown")}return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[i,o]);const d=c.useEventCallback((T,O)=>{o?.(T,O)}),u=c.useEventCallback(T=>{!o||T==null||a.start(T,()=>{d(null,"timeout")})});Ce.useEffect(()=>(i&&u(n),a.clear),[i,n,u,a]);const h=T=>{o?.(T,"clickaway")},y=a.clear,b=Ce.useCallback(()=>{n!=null&&u(l??n*.5)},[n,l,u]),x=T=>O=>{const M=T.onBlur;M?.(O),b()},v=T=>O=>{const M=T.onFocus;M?.(O),y()},k=T=>O=>{const M=T.onMouseEnter;M?.(O),y()},C=T=>O=>{const M=T.onMouseLeave;M?.(O),b()};return Ce.useEffect(()=>{if(!r&&i)return window.addEventListener("focus",b),window.addEventListener("blur",y),()=>{window.removeEventListener("focus",b),window.removeEventListener("blur",y)}},[r,i,b,y]),{getRootProps:(T={})=>{const O={...c.extractEventHandlers(e),...c.extractEventHandlers(T)};return{role:"presentation",...T,...O,onBlur:x(O),onFocus:v(O),onMouseEnter:k(O),onMouseLeave:C(O)}},onClickAway:h}}function Ii(e){return e.substring(2).toLowerCase()}function Rd(e,n){return n.documentElement.clientWidth<e.clientX||n.documentElement.clientHeight<e.clientY}function Nd(e){const{children:n,disableReactTree:r=!1,mouseEvent:o="onClick",onClickAway:i,touchEvent:l="onTouchEnd"}=e,a=Ce.useRef(!1),d=Ce.useRef(null),u=Ce.useRef(!1),h=Ce.useRef(!1);Ce.useEffect(()=>(setTimeout(()=>{u.current=!0},0),()=>{u.current=!1}),[]);const y=c.useForkRef(c.getReactElementRef(n),d),b=c.useEventCallback(k=>{const C=h.current;h.current=!1;const S=c.ownerDocument(d.current);if(!u.current||!d.current||"clientX"in k&&Rd(k,S))return;if(a.current){a.current=!1;return}let T;k.composedPath?T=k.composedPath().includes(d.current):T=!S.documentElement.contains(k.target)||d.current.contains(k.target),!T&&(r||!C)&&i(k)}),x=k=>C=>{h.current=!0;const S=n.props[k];S&&S(C)},v={ref:y};return l!==!1&&(v[l]=x(l)),Ce.useEffect(()=>{if(l!==!1){const k=Ii(l),C=c.ownerDocument(d.current),S=()=>{a.current=!0};return C.addEventListener(k,b),C.addEventListener("touchmove",S),()=>{C.removeEventListener(k,b),C.removeEventListener("touchmove",S)}}},[b,l]),o!==!1&&(v[o]=x(o)),Ce.useEffect(()=>{if(o!==!1){const k=Ii(o),C=c.ownerDocument(d.current);return C.addEventListener(k,b),()=>{C.removeEventListener(k,b)}}},[b,o]),Ce.cloneElement(n,v)}function Ld(e){return c.generateUtilityClass("MuiSnackbarContent",e)}c.generateUtilityClasses("MuiSnackbarContent",["root","message","action"]);const _d=e=>{const{classes:n}=e,r={root:["root"],action:["action"],message:["message"]};return c.composeClasses(r,Ld,n)},Pd=c.styled(c.Paper,{name:"MuiSnackbarContent",slot:"Root"})(c.memoTheme(({theme:e})=>{const n=e.palette.mode==="light"?.8:.98;return{...e.typography.body2,color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(c.emphasize(e.palette.background.default,n)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:c.emphasize(e.palette.background.default,n),display:"flex",alignItems:"center",flexWrap:"wrap",padding:"6px 16px",flexGrow:1,[e.breakpoints.up("sm")]:{flexGrow:"initial",minWidth:288}}})),zd=c.styled("div",{name:"MuiSnackbarContent",slot:"Message"})({padding:"8px 0"}),Wd=c.styled("div",{name:"MuiSnackbarContent",slot:"Action"})({display:"flex",alignItems:"center",marginLeft:"auto",paddingLeft:16,marginRight:-8}),qd=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiSnackbarContent"}),{action:i,className:l,message:a,role:d="alert",...u}=o,h=o,y=_d(h);return t.jsxs(Pd,{role:d,elevation:6,className:c.clsx(y.root,l),ownerState:h,ref:r,...u,children:[t.jsx(zd,{className:y.message,ownerState:h,children:a}),i?t.jsx(Wd,{className:y.action,ownerState:h,children:i}):null]})});function Bd(e){return c.generateUtilityClass("MuiSnackbar",e)}c.generateUtilityClasses("MuiSnackbar",["root","anchorOriginTopCenter","anchorOriginBottomCenter","anchorOriginTopRight","anchorOriginBottomRight","anchorOriginTopLeft","anchorOriginBottomLeft"]);const Vd=e=>{const{classes:n,anchorOrigin:r}=e,o={root:["root",`anchorOrigin${c.capitalize(r.vertical)}${c.capitalize(r.horizontal)}`]};return c.composeClasses(o,Bd,n)},Hd=c.styled("div",{name:"MuiSnackbar",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[n.root,n[`anchorOrigin${c.capitalize(r.anchorOrigin.vertical)}${c.capitalize(r.anchorOrigin.horizontal)}`]]}})(c.memoTheme(({theme:e})=>({zIndex:(e.vars||e).zIndex.snackbar,position:"fixed",display:"flex",left:8,right:8,justifyContent:"center",alignItems:"center",variants:[{props:({ownerState:n})=>n.anchorOrigin.vertical==="top",style:{top:8,[e.breakpoints.up("sm")]:{top:24}}},{props:({ownerState:n})=>n.anchorOrigin.vertical!=="top",style:{bottom:8,[e.breakpoints.up("sm")]:{bottom:24}}},{props:({ownerState:n})=>n.anchorOrigin.horizontal==="left",style:{justifyContent:"flex-start",[e.breakpoints.up("sm")]:{left:24,right:"auto"}}},{props:({ownerState:n})=>n.anchorOrigin.horizontal==="right",style:{justifyContent:"flex-end",[e.breakpoints.up("sm")]:{right:24,left:"auto"}}},{props:({ownerState:n})=>n.anchorOrigin.horizontal==="center",style:{[e.breakpoints.up("sm")]:{left:"50%",right:"auto",transform:"translateX(-50%)"}}}]}))),Ud=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiSnackbar"}),i=c.useTheme(),l={enter:i.transitions.duration.enteringScreen,exit:i.transitions.duration.leavingScreen},{action:a,anchorOrigin:{vertical:d,horizontal:u}={vertical:"bottom",horizontal:"left"},autoHideDuration:h=null,children:y,className:b,ClickAwayListenerProps:x,ContentProps:v,disableWindowBlurListener:k=!1,message:C,onBlur:S,onClose:T,onFocus:O,onMouseEnter:M,onMouseLeave:E,open:R,resumeHideDuration:P,slots:A={},slotProps:H={},TransitionComponent:D,transitionDuration:L=l,TransitionProps:{onEnter:U,onExited:$,...W}={},...Q}=o,te={...o,anchorOrigin:{vertical:d,horizontal:u},autoHideDuration:h,disableWindowBlurListener:k,TransitionComponent:D,transitionDuration:L},ee=Vd(te),{getRootProps:G,onClickAway:Z}=Fd({...te}),[ae,z]=Ce.useState(!0),re=ge=>{z(!0),$&&$(ge)},se=(ge,ue)=>{z(!1),U&&U(ge,ue)},ne={slots:{transition:D,...A},slotProps:{content:v,clickAwayListener:x,transition:W,...H}},[Ie,de]=c.useSlot("root",{ref:r,className:[ee.root,b],elementType:Hd,getSlotProps:G,externalForwardedProps:{...ne,...Q},ownerState:te}),[pe,{ownerState:De,...Le}]=c.useSlot("clickAwayListener",{elementType:Nd,externalForwardedProps:ne,getSlotProps:ge=>({onClickAway:(...ue)=>{const ye=ue[0];ge.onClickAway?.(...ue),!ye?.defaultMuiPrevented&&Z(...ue)}}),ownerState:te}),[oe,K]=c.useSlot("content",{elementType:qd,shouldForwardComponentProp:!0,externalForwardedProps:ne,additionalProps:{message:C,action:a},ownerState:te}),[le,be]=c.useSlot("transition",{elementType:c.Grow,externalForwardedProps:ne,getSlotProps:ge=>({onEnter:(...ue)=>{ge.onEnter?.(...ue),se(...ue)},onExited:(...ue)=>{ge.onExited?.(...ue),re(...ue)}}),additionalProps:{appear:!0,in:R,timeout:L,direction:d==="top"?"down":"up"},ownerState:te});return!R&&ae?null:t.jsx(pe,{...Le,...A.clickAwayListener&&{ownerState:De},children:t.jsx(Ie,{...de,children:t.jsx(le,{...be,children:y||t.jsx(oe,{...K})})})})});let Gs;function Gd(e){Gs=e}function Di(e){if(Gs)try{Gs(e)}catch{}}function Ht(e,n,r){return(async o=>{const i=Date.now();try{const l=await r(o);return Di({type:"console.mutation",resource:e,action:n,ok:!0,durationMs:Date.now()-i}),l}catch(l){throw Di({type:"console.mutation",resource:e,action:n,ok:!1,durationMs:Date.now()-i,reason:l instanceof Error?l.message:"An unknown error occurred"}),l}})}function _n({mutationFn:e,success:n,invalidates:r,closeDialog:o,resource:i,action:l}){const a=yt.useQueryClient(),[d,u]=j.useState(""),h=c.useMutationWithApiError({mutationFn:Ht(i,l,e),onSuccess(){o();for(const y of r)a.invalidateQueries({queryKey:y});u(n)},onError(y){u(y instanceof Error?y.message:"An unknown error occurred")}});return{mutate:h.mutate,isPending:h.isPending,notice:t.jsx(Ud,{open:d!=="",autoHideDuration:6e3,onClose:()=>u(""),message:d})}}const Za="https://docs.malloydata.dev/documentation",Ts=`${Za}/user_guides/publishing`,In="https://github.com/malloydata/publisher/blob/main/docs",Vt={docsHome:`${Za}/`,publishing:`${Ts}/publishing`,explorer:`${Ts}/explorer`,mcpAgents:`${Ts}/mcp_agents`,surfaces:`${In}/choosing-a-surface.md`,dashboards:`${In}/dashboards.md`,dataApps:`${In}/html-data-apps.md`,givens:`${In}/givens.md`,materialization:`${In}/materialization.md`,connections:`${In}/connections.md`};function Yd({resourceUri:e}){const[n,r]=j.useState(!1),{apiClients:o}=q.useServer(),{environmentName:i}=c.parseResourceUri(e),l=_n({mutationFn(d){return o.packages.createPackage(i,{name:d.name,description:d.description,location:d.location})},success:"Package created",invalidates:[["packages",i]],closeDialog:()=>r(!1),resource:"package",action:"create"}),a=d=>{d.preventDefault();const u=new FormData(d.currentTarget),h=u.get("name")?.toString(),y=u.get("description")?.toString(),b=u.get("location")?.toString();l.mutate({name:h,description:y,location:b})};return t.jsxs(t.Fragment,{children:[t.jsx(c.AddButton,{label:"Package",onClick:()=>r(!0)}),t.jsx(c.AppDialog,{open:n,onClose:()=>r(!1),title:"New package",description:t.jsxs(t.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"," ",t.jsx(p.Box,{component:"a",href:Vt.publishing,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary"},children:"package format"}),"."]}),actions:t.jsxs(t.Fragment,{children:[t.jsx(p.Button,{disabled:l.isPending,onClick:()=>r(!1),children:"Cancel"}),t.jsx(p.Button,{type:"submit",form:"package-form",variant:"contained",loading:l.isPending,children:"Create package"})]}),children:t.jsx("form",{onSubmit:a,id:"package-form",children:t.jsxs(p.Stack,{sx:{gap:2},children:[t.jsx(p.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),t.jsx(p.TextField,{id:"description",name:"description",label:"Description",multiline:!0,rows:3,fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),t.jsx(p.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}})]})})}),l.notice]})}const Kd=c.createSvgIcon(t.jsx("path",{d:"M2 20h20v-4H2zm2-3h2v2H4zM2 4v4h20V4zm4 3H4V5h2zm-4 7h20v-4H2zm2-3h2v2H4z"}));function ss({icon:e,tint:n,label:r,mono:o,description:i,rightLabel:l,trailingAction:a,onClick:d,ariaLabel:u}){const h=!!d,y=b=>{d&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),d(b))};return t.jsxs(p.Box,{onClick:d,onKeyDown:h?y:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,"aria-label":u,sx:b=>({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:b.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:[t.jsx(p.Box,{sx:{width:32,height:32,borderRadius:1,bgcolor:n,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),t.jsxs(p.Box,{sx:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:1.5},children:[t.jsx(p.Typography,{variant:"body2",sx:{...o?{fontFamily:q.MONO_FONT_FAMILY}:{},flexShrink:0,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),i&&t.jsx(p.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})]}),l&&t.jsx(p.Typography,{variant:"caption",color:"text.secondary",sx:{flexShrink:0},children:l}),a&&t.jsx(p.Box,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:a})]})}const Xa=c.createSvgIcon(t.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"})),Qd=c.generateUtilityClasses("MuiBox",["root"]),Zd=c.createTheme(),Ye=wr.createBox({themeId:c.THEME_ID,defaultTheme:Zd,defaultClassName:Qd.root,generateClassName:c.ClassNameGenerator.generate}),os=wr.createStack({createStyledComponent:c.styled("div",{name:"MuiStack",slot:"Root"}),useThemeProps:e=>c.useDefaultProps({props:e,name:"MuiStack"})}),$i=c.generateUtilityClasses("MuiDivider",["root","absolute","fullWidth","inset","middle","flexItem","light","vertical","withChildren","withChildrenVertical","textAlignRight","textAlignLeft","wrapper","wrapperVertical"]);function Xd(e){return c.generateUtilityClass("MuiListItemIcon",e)}const Ai=c.generateUtilityClasses("MuiListItemIcon",["root","alignItemsFlexStart"]),Jd=e=>{const{alignItems:n,classes:r}=e,o={root:["root",n==="flex-start"&&"alignItemsFlexStart"]};return c.composeClasses(o,Xd,r)},eh=c.styled("div",{name:"MuiListItemIcon",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[n.root,r.alignItems==="flex-start"&&n.alignItemsFlexStart]}})(c.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}}]}))),ao=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiListItemIcon"}),{className:i,...l}=o,a=Ce.useContext(c.ListContext),d={...o,alignItems:a.alignItems},u=Jd(d);return t.jsx(eh,{className:c.clsx(u.root,i),ownerState:d,ref:r,...l})});function th(e){return c.generateUtilityClass("MuiListItemText",e)}const $n=c.generateUtilityClasses("MuiListItemText",["root","multiline","dense","inset","primary","secondary"]),nh=e=>{const{classes:n,inset:r,primary:o,secondary:i,dense:l}=e,a={root:["root",r&&"inset",l&&"dense",o&&i&&"multiline"],primary:["primary"],secondary:["secondary"]};return c.composeClasses(a,th,n)},rh=c.styled("div",{name:"MuiListItemText",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[{[`& .${$n.primary}`]:n.primary},{[`& .${$n.secondary}`]:n.secondary},n.root,r.inset&&n.inset,r.primary&&r.secondary&&n.multiline,r.dense&&n.dense]}})({flex:"1 1 auto",minWidth:0,marginTop:4,marginBottom:4,[`.${c.typographyClasses.root}:where(& .${$n.primary})`]:{display:"block"},[`.${c.typographyClasses.root}:where(& .${$n.secondary})`]:{display:"block"},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),lo=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiListItemText"}),{children:i,className:l,disableTypography:a=!1,inset:d=!1,primary:u,primaryTypographyProps:h,secondary:y,secondaryTypographyProps:b,slots:x={},slotProps:v={},...k}=o,{dense:C}=Ce.useContext(c.ListContext);let S=u??i,T=y;const O={...o,disableTypography:a,inset:d,primary:!!S,secondary:!!T,dense:C},M=nh(O),E={slots:x,slotProps:{primary:h,secondary:b,...v}},[R,P]=c.useSlot("root",{className:c.clsx(M.root,l),elementType:rh,externalForwardedProps:{...E,...k},ownerState:O,ref:r}),[A,H]=c.useSlot("primary",{className:M.primary,elementType:c.Typography,externalForwardedProps:E,ownerState:O}),[D,L]=c.useSlot("secondary",{className:M.secondary,elementType:c.Typography,externalForwardedProps:E,ownerState:O});return S!=null&&S.type!==c.Typography&&!a&&(S=t.jsx(A,{variant:C?"body2":"body1",component:H?.variant?void 0:"span",...H,children:S})),T!=null&&T.type!==c.Typography&&!a&&(T=t.jsx(D,{variant:"body2",color:"textSecondary",...L,children:T})),t.jsxs(R,{...P,children:[S,T]})});function sh(e){return c.generateUtilityClass("MuiMenuItem",e)}const er=c.generateUtilityClasses("MuiMenuItem",["root","focusVisible","dense","disabled","divider","gutters","selected"]),oh=(e,n)=>{const{ownerState:r}=e;return[n.root,r.dense&&n.dense,r.divider&&n.divider,!r.disableGutters&&n.gutters]},ih=e=>{const{disabled:n,dense:r,divider:o,disableGutters:i,selected:l,classes:a}=e,d={root:["root",r&&"dense",n&&"disabled",!i&&"gutters",o&&"divider",l&&"selected"]},u=c.composeClasses(d,sh,a);return{...a,...u}},ah=c.styled(c.ButtonBase,{shouldForwardProp:e=>c.rootShouldForwardProp(e)||e==="classes",name:"MuiMenuItem",slot:"Root",overridesResolver:oh})(c.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"}},[`&.${er.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${er.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${er.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)}},[`&.${er.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${er.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${$i.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${$i.inset}`]:{marginLeft:52},[`& .${$n.root}`]:{marginTop:0,marginBottom:0},[`& .${$n.inset}`]:{paddingLeft:36},[`& .${Ai.root}`]:{minWidth:36},variants:[{props:({ownerState:n})=>!n.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:n})=>n.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:"padding-box"}},{props:({ownerState:n})=>!n.dense,style:{[e.breakpoints.up("sm")]:{minHeight:"auto"}}},{props:({ownerState:n})=>n.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${Ai.root} svg`]:{fontSize:"1.25rem"}}}]}))),tt=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiMenuItem"}),{autoFocus:i=!1,component:l="li",dense:a=!1,divider:d=!1,disableGutters:u=!1,focusVisibleClassName:h,role:y="menuitem",tabIndex:b,className:x,...v}=o,k=Ce.useContext(c.ListContext),C=Ce.useMemo(()=>({dense:a||k.dense||!1,disableGutters:u}),[k.dense,a,u]),S=Ce.useRef(null);c.useEnhancedEffect(()=>{i&&S.current&&S.current.focus()},[i]);const T={...o,dense:C.dense,divider:d,disableGutters:u},O=ih(o),M=c.useForkRef(S,r);let E;return o.disabled||(E=b!==void 0?b:-1),t.jsx(c.ListContext.Provider,{value:C,children:t.jsx(ah,{ref:M,role:y,tabIndex:E,component:l,focusVisibleClassName:c.clsx(O.focusVisible,h),className:c.clsx(O.root,x),...v,ownerState:T,classes:O})})}),Gt={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},{label:"Database Metadata",name:"dbmeta",type:"text",required:!1,selectOptions:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}],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}],sqlserver:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Database",name:"database",type:"text",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Encrypt",name:"encrypt",type:"text",required:!1,selectOptions:[{label:"Yes",value:"true"},{label:"No",value:"false"}]},{label:"Trust server certificate",name:"trustServerCertificate",type:"text",required:!1,selectOptions:[{label:"No",value:"false"},{label:"Yes",value:"true"}]},{label:"Host name in certificate",name:"hostNameInCertificate",type:"text",required:!1},{label:"Instance name",name:"instanceName",type:"text",required:!1}],duckdb:[],motherduck:[{label:"Access Token",name:"accessToken",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1}],ducklake:[],publisher:[]},pr={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",trino:"trinoConnection",databricks:"databricksConnection",mysql:"mysqlConnection",sqlserver:"sqlserverConnection",duckdb:"duckdbConnection",motherduck:"motherduckConnection",ducklake:"ducklakeConnection",publisher:"publisherConnection"},lh={bigquery:{dbmeta:"boolean"},sqlserver:{port:"integer",encrypt:"boolean",trustServerCertificate:"boolean"}},ch={sqlserver:["hostNameInCertificate","instanceName"]};function Ja(e,n){const r=lh[e],o=ch[e];if(!r&&!o)return n;const i={...n};for(const l of o??[])i[l]===""&&delete i[l];for(const[l,a]of Object.entries(r??{})){const d=n[l];if(d!==void 0){if(d===""){delete i[l];continue}if(a==="integer"){const u=Number(d);Number.isInteger(u)&&(i[l]=u)}else(d==="true"||d==="false")&&(i[l]=d==="true")}}return i}const el=Object.values(q.ConnectionTypeEnum).filter(e=>e!==q.ConnectionTypeEnum.Publisher),Ys={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",gcs:"gcsConnection",s3:"s3Connection",azure:"azureConnection"},Sr=[{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"}}],kr=[{label:"Key ID",name:"keyId",type:"text",required:!0},{label:"Secret",name:"secret",type:"password",required:!0}],uh=[{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 Jr(e){return e==="postgres"||e==="bigquery"||e==="snowflake"?Gt[e]||[]:e==="s3"?Sr:e==="gcs"?kr:e==="azure"?uh:[]}function dh({onSubmit:e,isSubmitting:n}){const[r,o]=j.useState(!1),[i,l]=j.useState("postgres"),[a,d]=j.useState([]),[u,h]=j.useState("postgres"),[y,b]=j.useState("s3"),[x,v]=j.useState("config"),k=()=>{o(!0)},C=()=>{o(!1),d([]),l("postgres"),h("postgres"),b("s3"),v("config")},S=async E=>{E.preventDefault();const R=new FormData(E.currentTarget),P=R.get("name")?.toString(),A=R.get("type")?.toString(),H=Gt[A];if(!P)throw new Error("Name is required");if(!A)throw new Error("Type is required");let D;if(A==="ducklake"){const L={};if(u==="postgres"){const W=Gt.postgres,Q={};if(W.forEach(te=>{const ee=R.get(`ducklake_pg_${te.name}`)?.toString();ee&&(Q[te.name]=ee)}),Object.keys(Q).length===0)throw new Error("DuckLake requires catalog connection");L.postgresConnection=Q}const U=R.get("ducklake_bucketUrl")?.toString();if(!U)throw new Error("DuckLake requires a bucket URL");const $={bucketUrl:U};if(y==="s3"){const W={};if(Sr.forEach(Q=>{const te=R.get(`ducklake_s3_${Q.name}`)?.toString();te&&(W[Q.name]=te)}),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&&($.s3Connection=W)}else if(y==="gcs"){const W={};if(kr.forEach(Q=>{const te=R.get(`ducklake_gcs_${Q.name}`)?.toString();te&&(W[Q.name]=te)}),!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&&($.gcsConnection=W)}D={name:P,type:A,ducklakeConnection:{catalog:L,storage:$}}}else if(A==="duckdb"){if(a.length===0)throw new Error("DuckDB connection must have at least one attached database");const L=a.map((U,$)=>{const W=U.dbType,Q=R.get(`attachedDb_${$}_name`)?.toString();if(!Q)throw new Error(`Attached database at index ${$} must have a name`);const te={name:Q,type:W},ee=Jr(W);if(ee&&ee.length>0){const G={};if(ee.forEach(ae=>{const z=R.get(`attachedDb_${$}_${ae.name}`)?.toString();z&&(G[ae.name]=z)}),W==="s3"){if(G.provider==="credential_chain")delete G.accessKeyId,delete G.secretAccessKey,delete G.sessionToken;else if(delete G.chain,!G.accessKeyId||!G.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=Ys[W];Z&&(te[Z]=G)}return te});D={name:P,type:A,duckdbConnection:{attachedDatabases:L}}}else{const L={};if(H.forEach(U=>{const $=R.get(U.name)?.toString();$&&(L[U.name]=$)}),A==="postgres"){if(!!!L.connectionString?.trim()){const $=["host","port","databaseName","userName","password"];for(const W of $)if(!L[W])throw new Error(`${H.find(Q=>Q.name===W)?.label||W} is required`)}}else if(A==="bigquery"){if(!L.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(A==="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(A==="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(A==="mysql"){const U=["host","port","database","user","password"];for(const $ of U)if(!L[$])throw new Error(`${H.find(W=>W.name===$)?.label||$} is required`)}else if(A==="sqlserver"){const U=["server","database","user","password"];if(!L.instanceName&&!L.port)throw new Error("Port is required unless an instance name is given");for(const $ of U)if(!L[$])throw new Error(`${H.find(W=>W.name===$)?.label||$} is required`)}else if(A==="motherduck"){if(!L.accessToken)throw new Error("Access Token is required")}else if(A==="databricks"){if(!L.host)throw new Error("Host is required");if(!L.path)throw new Error("HTTP Path is required");const U=L.oauthClientId&&L.oauthClientSecret;if(!L.token&&!U)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}D={name:P,type:A,[pr[A]]:Ja(A,L)}}await e(D),C()},T=()=>{d([...a,{name:"",dbType:"postgres"}])},O=E=>{d(a.filter((R,P)=>P!==E))},M=(E,R)=>{const P=[...a];P[E]={...P[E],dbType:R},d(P)};return t.jsxs(j.Fragment,{children:[t.jsx(c.AddButton,{label:"Connection",onClick:k}),t.jsx(c.AppDialog,{open:r,onClose:C,title:"New connection",description:"Add a connection so packages in this environment can query your database with Malloy.",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{disabled:n,onClick:C,children:"Cancel"}),t.jsx(c.Button,{type:"submit",form:"connection-form",variant:"contained",loading:n,children:"Create connection"})]}),children:t.jsx("form",{onSubmit:S,id:"connection-form",children:t.jsxs(os,{sx:{gap:2},children:[t.jsx(c.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small"}),t.jsx(c.TextField,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:i,select:!0,onChange:E=>l(E.target.value),children:el.map(E=>t.jsx(tt,{value:E,children:E},E))}),i==="ducklake"?t.jsxs(Ye,{sx:{mt:2},children:[t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsx(c.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),t.jsx(c.TextField,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:u,select:!0,onChange:E=>h(E.target.value),children:t.jsx(tt,{value:"postgres",children:"PostgreSQL"})}),u==="postgres"&&t.jsx(t.Fragment,{children:Gt.postgres.map(E=>t.jsx(c.TextField,{id:`ducklake_pg_${E.name}`,name:`ducklake_pg_${E.name}`,label:E.label,type:E.type,fullWidth:!0,size:"small"},`pg_${E.name}`))})]}),t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsx(c.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),t.jsxs(c.TextField,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:y,select:!0,onChange:E=>b(E.target.value),children:[t.jsx(tt,{value:"s3",children:"S3"}),t.jsx(tt,{value:"gcs",children:"GCS"})]}),t.jsx(c.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"}),y==="s3"&&t.jsxs(t.Fragment,{children:[t.jsx(c.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Sr.filter(E=>E.visibleWhen?x===E.visibleWhen.value:!0).map(E=>t.jsx(c.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=>v(R.target.value):void 0,placeholder:E.name==="region"?"us-east-1":void 0,children:E.selectOptions?.map(R=>t.jsx(tt,{value:R.value,children:R.label},R.value))},`s3_${E.name}`))]}),y==="gcs"&&t.jsxs(t.Fragment,{children:[t.jsx(c.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),kr.map(E=>t.jsx(c.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}`))]})]})]}):i==="duckdb"?t.jsxs(Ye,{sx:{mt:2},children:[t.jsxs(Ye,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[t.jsx(c.Typography,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),t.jsx(c.SecondaryButton,{label:"Database",icon:t.jsx(c.AddIcon,{}),onClick:T,ariaLabel:"Add database"})]}),a.length===0&&t.jsx(c.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),a.map((E,R)=>{const P=Jr(E.dbType);return t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsxs(Ye,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[t.jsxs(c.Typography,{variant:"subtitle2",children:["Database ",R+1]}),t.jsx(c.IconButton,{onClick:()=>O(R),size:"small",color:"error",children:t.jsx(Xa,{fontSize:"small"})})]}),t.jsx(c.TextField,{required:!0,id:`attachedDb_${R}_name`,name:`attachedDb_${R}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:E.name}),t.jsx(c.TextField,{id:`attachedDb_${R}_type`,name:`attachedDb_${R}_type`,label:"Database Type",fullWidth:!0,size:"small",value:E.dbType,select:!0,onChange:A=>M(R,A.target.value),children:Object.values(q.AttachedDatabaseTypeEnum).map(A=>t.jsx(tt,{value:A,children:A},A))}),P.filter(A=>A.visibleWhen?(E[A.visibleWhen.field]||P.find(D=>D.name===A.visibleWhen?.field)?.selectOptions?.[0]?.value)===A.visibleWhen.value:!0).map(A=>t.jsx(c.TextField,{id:`attachedDb_${R}_${A.name}`,name:`attachedDb_${R}_${A.name}`,label:A.label,type:A.selectOptions?void 0:A.type,fullWidth:!0,size:"small",required:A.required,select:!!A.selectOptions,defaultValue:A.selectOptions?.[0]?.value,onChange:A.selectOptions?H=>{const D=[...a];D[R]={...D[R],[A.name]:H.target.value},d(D)}:void 0,children:A.selectOptions?.map(H=>t.jsx(tt,{value:H.value,children:H.label},H.value))},A.name))]},R)})]}):Gt[i].map(E=>t.jsx(c.TextField,{id:E.name,name:E.name,label:E.label,type:E.type,fullWidth:!0,size:"small",required:E.required,select:!!E.selectOptions,defaultValue:E.selectOptions?E.selectOptions[0]?.value:void 0,children:E.selectOptions?.map(R=>t.jsx(tt,{value:R.value,children:R.label},R.value))},E.name))]})})})]})}function hh({connection:e,onCloseDialog:n,isMutating:r,onDelete:o}){const[i,l]=j.useState(!1),a=()=>{l(!0)},d=()=>{l(!1),n()};return t.jsxs(j.Fragment,{children:[t.jsxs(tt,{"aria-label":`Delete connection ${e?.name??""}`.trim(),onClick:u=>{u.stopPropagation(),a()},sx:{color:"error.main"},children:[t.jsx(ao,{sx:{color:"inherit"},children:t.jsx(Pt.Delete,{fontSize:"small"})}),t.jsx(lo,{children:"Delete"})]}),t.jsx(c.AppDialog,{open:i,onClose:d,title:"Delete connection",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{onClick:d,children:"Cancel"}),t.jsx(c.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>o(),loading:r,children:"Delete connection"})]}),children:t.jsxs(c.Typography,{variant:"body2",children:["Delete ",t.jsx("strong",{children:e.name}),"? Packages that query through it stop working, and this cannot be undone."]})})]})}const Fi=new Set(["password","connectionString","privateKey","privateKeyPass","serviceAccountKeyJson","token","oauthClientSecret","accessToken","peakaKey","secret","secretAccessKey","sessionToken","clientSecret","sasUrl"]);function Ri(e){const n=e.duckdbConnection?.attachedDatabases;return!n||n.length===0?[]:n.map(r=>({name:r.name||"",dbType:r.type||"postgres"}))}function Ni(e){const n=e.ducklakeConnection;return n&&n.storage?.gcsConnection?"gcs":"s3"}function fh({connection:e,onSubmit:n,isSubmitting:r,onCloseDialog:o}){const[i,l]=j.useState(!1),[a,d]=j.useState(e.type),u=j.useMemo(()=>new Set(e.withheldFields??[]),[e.withheldFields]),[h,y]=j.useState(()=>Ri(e)),[b,x]=j.useState("postgres"),[v,k]=j.useState(()=>Ni(e)),[C,S]=j.useState(()=>e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),T=()=>{y(Ri(e)),d(e.type),S(e.ducklakeConnection?.storage?.s3Connection?.provider??"config"),x("postgres"),k(Ni(e)),l(!0)},O=()=>{l(!1),o?.()},M=async D=>{D.preventDefault();const L=new FormData(D.currentTarget),U=L.get("name")?.toString(),$=L.get("type")?.toString(),W=Gt[$];if(!U)throw new Error("Name is required");if(!$)throw new Error("Type is required");let Q;if($==="ducklake"){const te={};if(b==="postgres"){const Z=Gt.postgres,ae={};if(Z.forEach(z=>{const re=L.get(`ducklake_pg_${z.name}`)?.toString();re&&(ae[z.name]=re)}),Object.keys(ae).length===0)throw new Error("DuckLake requires catalog connection");te.postgresConnection=ae}const ee=L.get("ducklake_bucketUrl")?.toString();if(!ee)throw new Error("DuckLake requires a bucket URL");const G={bucketUrl:ee};if(v==="s3"){const Z={};Sr.forEach(z=>{const re=L.get(`ducklake_s3_${z.name}`)?.toString();re&&(Z[z.name]=re)});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&&(G.s3Connection=Z)}else if(v==="gcs"){const Z={};kr.forEach(z=>{const re=L.get(`ducklake_gcs_${z.name}`)?.toString();re&&(Z[z.name]=re)});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&&(G.gcsConnection=Z)}Q={name:U,type:$,ducklakeConnection:{catalog:te,storage:G}}}else if($==="duckdb"){if(h.length===0)throw new Error("DuckDB connection must have at least one attached database");const te=h.map((ee,G)=>{const Z=ee.dbType,ae=L.get(`attachedDb_${G}_name`)?.toString();if(!ae)throw new Error(`Attached database at index ${G} must have a name`);const z={name:ae,type:Z},re=Jr(Z);if(re&&re.length>0){const se={};if(re.forEach(Ie=>{const de=L.get(`attachedDb_${G}_${Ie.name}`)?.toString();de&&(se[Ie.name]=de)}),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 ne=Ys[Z];ne&&(z[ne]=se)}return z});Q={name:U,type:$,duckdbConnection:{attachedDatabases:te}}}else{const te=e[pr[$]]||{},ee={};if(W.forEach(G=>{const Z=L.get(G.name)?.toString(),ae=te[G.name];Z?ee[G.name]=Z:Fi.has(G.name)||(Z!==void 0?ee[G.name]=Z:ae&&(ee[G.name]=ae))}),$==="postgres"){const G=["host","port","databaseName","userName"],Z=u.has("postgresConnection.connectionString");if(!(!!ee.connectionString?.trim()||Z)){const z=G;for(const re of z)if(!ee[re])throw new Error(`${W.find(se=>se.name===re)?.label||re} is required`)}}else if($==="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($==="trino"){if(!ee.server)throw new Error("Server is required");if(!ee.user)throw new Error("User is required")}else if($==="mysql"){const G=["host","port","database","user"];for(const Z of G)if(!ee[Z])throw new Error(`${W.find(ae=>ae.name===Z)?.label||Z} is required`)}else if($==="sqlserver"){const G=["server","database","user"];if(!ee.instanceName&&!ee.port)throw new Error("Port is required unless an instance name is given");for(const Z of G)if(!ee[Z])throw new Error(`${W.find(ae=>ae.name===Z)?.label||Z} is required`)}else if($==="databricks"){if(!ee.host)throw new Error("Host is required");if(!ee.path)throw new Error("HTTP Path is required")}Q={name:U,type:$,[pr[$]]:Ja($,ee)}}await n(Q),O()},E=()=>{y([...h,{name:"",dbType:"postgres"}])},R=D=>{y(h.filter((L,U)=>U!==D))},P=(D,L)=>{const U=[...h];U[D]={...U[D],dbType:L},y(U)},A=(D,L)=>{const U=e.duckdbConnection?.attachedDatabases;if(!U||!U[D])return"";const $=U[D],W=Ys[$.type||""];return W&&$[W]?$[W][L]??"":""},H=D=>{const L=e.ducklakeConnection;if(!L)return"";if(D.startsWith("pg_")){const U=D.replace("pg_","");return L.catalog?.postgresConnection?.[U]??""}if(D==="bucketUrl")return L.storage?.bucketUrl??"";if(D.startsWith("s3_")){const U=D.replace("s3_","");return L.storage?.s3Connection?.[U]??""}if(D.startsWith("gcs_")){const U=D.replace("gcs_","");return L.storage?.gcsConnection?.[U]??""}return""};return t.jsxs(j.Fragment,{children:[t.jsxs(tt,{"aria-label":`Edit connection ${e?.name??""}`.trim(),onClick:D=>{D.preventDefault(),D.stopPropagation(),T()},children:[t.jsx(ao,{children:t.jsx(Pt.Edit,{fontSize:"small"})}),t.jsx(lo,{children:"Edit"})]}),t.jsx(c.AppDialog,{open:i,onClose:O,title:"Edit connection",description:"Change how packages in this environment reach your database.",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{disabled:r,onClick:O,children:"Cancel"}),t.jsx(c.Button,{type:"submit",form:"connection-form",variant:"contained",loading:r,children:"Save changes"})]}),children:t.jsx("form",{onSubmit:M,id:"connection-form",children:t.jsxs(os,{sx:{gap:2},children:[t.jsx(c.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",defaultValue:e.name}),t.jsx(c.TextField,{id:"type",name:"type",label:"Connection Type",fullWidth:!0,size:"small",value:a,select:!0,onChange:D=>d(D.target.value),children:el.map(D=>t.jsx(tt,{value:D,children:D},D))}),a==="ducklake"?t.jsxs(Ye,{sx:{mt:2},children:[t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsx(c.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),t.jsx(c.TextField,{id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,size:"small",value:b,select:!0,onChange:D=>x(D.target.value),children:t.jsx(tt,{value:"postgres",children:"PostgreSQL"})}),b==="postgres"&&t.jsx(t.Fragment,{children:Gt.postgres.map(D=>t.jsx(c.TextField,{id:`ducklake_pg_${D.name}`,name:`ducklake_pg_${D.name}`,label:D.label,type:D.type,fullWidth:!0,size:"small",defaultValue:H(`pg_${D.name}`)},`pg_${D.name}`))})]}),t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsx(c.Typography,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),t.jsxs(c.TextField,{id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,size:"small",value:v,select:!0,onChange:D=>k(D.target.value),children:[t.jsx(tt,{value:"s3",children:"S3"}),t.jsx(tt,{value:"gcs",children:"GCS"})]}),t.jsx(c.TextField,{required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:v==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,size:"small",defaultValue:H("bucketUrl")}),v==="s3"&&t.jsxs(t.Fragment,{children:[t.jsx(c.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Sr.filter(D=>D.visibleWhen?C===D.visibleWhen.value:!0).map(D=>t.jsx(c.TextField,{id:`ducklake_s3_${D.name}`,name:`ducklake_s3_${D.name}`,label:D.label,type:D.selectOptions?void 0:D.type,fullWidth:!0,size:"small",required:D.required&&D.name!=="secretAccessKey",select:!!D.selectOptions,defaultValue:D.selectOptions?C:H(`s3_${D.name}`),onChange:D.name==="provider"?L=>S(L.target.value):void 0,placeholder:D.name==="region"?"us-east-1":D.name==="secretAccessKey"&&u.has("ducklakeConnection.storage.s3Connection.secretAccessKey")?"Leave empty to keep existing":void 0,children:D.selectOptions?.map(L=>t.jsx(tt,{value:L.value,children:L.label},L.value))},`s3_${D.name}`))]}),v==="gcs"&&t.jsxs(t.Fragment,{children:[t.jsx(c.Typography,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),kr.map(D=>t.jsx(c.TextField,{id:`ducklake_gcs_${D.name}`,name:`ducklake_gcs_${D.name}`,label:D.label,type:D.type,fullWidth:!0,size:"small",required:D.required&&D.name!=="secret",defaultValue:H(`gcs_${D.name}`),placeholder:D.name==="secret"&&u.has("ducklakeConnection.storage.gcsConnection.secret")?"Leave empty to keep existing":void 0},`gcs_${D.name}`))]})]})]}):a==="duckdb"?t.jsxs(Ye,{sx:{mt:2},children:[t.jsxs(Ye,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[t.jsx(c.Typography,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),t.jsx(c.SecondaryButton,{label:"Database",icon:t.jsx(c.AddIcon,{}),onClick:E,ariaLabel:"Add database"})]}),h.length===0&&t.jsx(c.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((D,L)=>{const U=Jr(D.dbType);return t.jsxs(Ye,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[t.jsxs(Ye,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[t.jsxs(c.Typography,{variant:"subtitle2",children:["Database ",L+1]}),t.jsx(c.IconButton,{"aria-label":`Remove attached database ${L+1}`,onClick:()=>R(L),size:"small",color:"error",children:t.jsx(Xa,{fontSize:"small"})})]}),t.jsx(c.TextField,{required:!0,id:`attachedDb_${L}_name`,name:`attachedDb_${L}_name`,label:"Database Name",type:"text",fullWidth:!0,size:"small",defaultValue:D.name}),t.jsx(c.TextField,{id:`attachedDb_${L}_type`,name:`attachedDb_${L}_type`,label:"Database Type",fullWidth:!0,size:"small",value:D.dbType,select:!0,onChange:$=>P(L,$.target.value),children:Object.values(q.AttachedDatabaseTypeEnum).map($=>t.jsx(tt,{value:$,children:$},$))}),U.filter($=>$.visibleWhen?(D[$.visibleWhen.field]||A(L,$.visibleWhen.field)||U.find(Q=>Q.name===$.visibleWhen?.field)?.selectOptions?.[0]?.value)===$.visibleWhen.value:!0).map($=>t.jsx(c.TextField,{id:`attachedDb_${L}_${$.name}`,name:`attachedDb_${L}_${$.name}`,label:$.label,type:$.selectOptions?void 0:$.type,fullWidth:!0,size:"small",required:$.required,select:!!$.selectOptions,defaultValue:A(L,$.name)||$.selectOptions?.[0]?.value,onChange:$.selectOptions?W=>{const Q=[...h];Q[L]={...Q[L],[$.name]:W.target.value},y(Q)}:void 0,children:$.selectOptions?.map(W=>t.jsx(tt,{value:W.value,children:W.label},W.value))},$.name))]},L)})]}):Gt[a].map(D=>{const L=e?.[pr[a]??""]?.[D.name??""]??"",U=D.type==="password"||Fi.has(D.name),$=u.has(`${pr[a]??""}.${D.name}`),W=D.selectOptions?L===""||L===void 0?D.selectOptions[0]?.value:String(L):void 0;return t.jsx(c.TextField,{id:D.name,name:D.name,label:D.label,type:D.type,fullWidth:!0,size:"small",required:D.required&&!U&&!L,select:!!D.selectOptions,defaultValue:D.selectOptions?W:L,placeholder:$?"Leave empty to keep existing":void 0,helperText:U?$?"Stored value is not shown. Leave empty to keep it.":"No value stored.":void 0,children:D.selectOptions?.map(Q=>t.jsx(tt,{value:Q.value,children:Q.label},Q.value))},D.name)})]})})})]})}function Li(e,n){return!e||e.type!=="duckdb"?!1:(e.duckdbConnection?.attachedDatabases||[]).some(o=>o.type==="azure"&&o.name===n)}function mh(e){return e.startsWith("gs://")||e.startsWith("s3://")||e.startsWith("https://")||e.startsWith("abfss://")||e.startsWith("az://")}function tl({connectionName:e,resourceUri:n,schema:r,connection:o}){const{apiClients:i}=q.useServer(),{environmentName:l}=c.parseResourceUri(n),[a,d]=j.useState(null),[u,h]=j.useState(r||null),[y,b]=j.useState(!1),{data:x,isError:v,isLoading:k,error:C}=c.useQueryWithApiError({queryKey:["schemas",l,e],queryFn:()=>i.connections.listSchemas(l,e)}),S=x?.data||[];return t.jsxs(p.Grid,{container:!0,spacing:1,children:[!r&&t.jsx(p.Grid,{size:{xs:12,md:4},children:t.jsxs(p.Paper,{sx:{p:1,m:0},children:[t.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:0},children:[t.jsx(p.Typography,{variant:"overline",fontWeight:"bold",children:"Table Paths"}),t.jsx(p.FormControlLabel,{control:t.jsx(p.Switch,{checked:y,onChange:T=>b(T.target.checked)}),label:"Hidden Schemas"})]}),t.jsx(p.Divider,{sx:{mt:"2px"}}),t.jsxs(p.Box,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[k&&t.jsx(c.Loading,{text:"Loading schemas..."}),v&&t.jsx(c.ApiErrorDisplay,{error:C,context:`${l} > ${e} > Schemas`}),!k&&!v&&S.length===0&&t.jsx(p.Typography,{variant:"body2",children:"No Schemas"}),!k&&!v&&S.length>0&&t.jsx(p.List,{dense:!0,disablePadding:!0,children:S.map(T=>{const O=T.name;if(T.isHidden&&!y)return null;const E=u===O;return t.jsx(p.ListItemButton,{selected:E,onClick:()=>{h(O),d(null)},children:t.jsx(p.ListItemText,{primary:O})},O)})})]})]})}),t.jsx(p.Grid,{size:{xs:12,md:r?6:4},children:u&&t.jsx(p.Paper,{sx:{p:1,m:0},children:t.jsx(yh,{connectionName:e,schemaName:u,onTableSelect:T=>{d(T)},resourceUri:n,connection:o})})}),t.jsx(p.Grid,{size:{xs:12,md:r?6:4},children:u&&a&&t.jsx(ph,{environmentName:l,connectionName:e,schemaName:u,tableResource:a})})]})}function ph({environmentName:e,connectionName:n,schemaName:r,tableResource:o}){const{apiClients:i}=q.useServer(),{data:l,isLoading:a,isError:d,error:u}=c.useQueryWithApiError({queryKey:["connectionTableDetail",e,n,r,o],queryFn:()=>i.connections.getTable(e,n,r,o),enabled:!!r&&!!o}),h={resource:l?.data?.resource??o,columns:l?.data?.columns??[]};return t.jsxs(p.Paper,{sx:{p:1,m:0},children:[d&&t.jsx(c.ApiErrorDisplay,{error:u,context:`${e} > ${n} > ${r} > ${o}`}),!d&&t.jsx(gh,{table:h,loading:a})]})}function gh({table:e,loading:n}){return n?t.jsx(c.Loading,{text:"Loading columns..."}):t.jsxs(t.Fragment,{children:[t.jsxs(p.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]}),t.jsx(p.Divider,{}),t.jsx(p.Box,{sx:{mt:"10px",maxHeight:"600px",overflowY:"auto"},children:t.jsx(p.TableContainer,{children:t.jsxs(p.Table,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[t.jsx(p.TableHead,{children:t.jsxs(p.TableRow,{children:[t.jsx(p.TableCell,{children:"NAME"}),t.jsx(p.TableCell,{children:"TYPE"})]})}),t.jsx(p.TableBody,{children:e.columns?.sort((r,o)=>r.name.localeCompare(o.name))?.map(r=>t.jsxs(p.TableRow,{children:[t.jsx(p.TableCell,{children:r.name}),t.jsx(p.TableCell,{children:r.type})]},r.name))})]})})})]})}function yh({connectionName:e,schemaName:n,onTableSelect:r,resourceUri:o,connection:i}){const{environmentName:l}=c.parseResourceUri(o),{apiClients:a}=q.useServer(),[d,u]=j.useState(""),{data:h,isSuccess:y,isError:b,error:x,isLoading:v}=c.useQueryWithApiError({queryKey:["tablesInSchema",l,e,n],queryFn:()=>a.connections.listTables(l,e,n)}),k=Li(i,n),C=T=>k?T:T.split(".").pop()||T,S=y&&h?.data?h.data.filter(T=>C(T.resource).toLowerCase().includes(d.toLowerCase())).sort((T,O)=>C(T.resource).localeCompare(C(O.resource))):[];return t.jsxs(t.Fragment,{children:[t.jsx(p.Typography,{variant:"overline",fontWeight:"bold",children:mh(n)||Li(i,n)?`Files in ${n}`:`Tables in ${n}`}),t.jsx(p.Divider,{}),t.jsx(p.Box,{sx:{mt:1,mb:1},children:t.jsx(p.TextField,{size:"small",fullWidth:!0,placeholder:"Search tables...",value:d,onChange:T=>u(T.target.value),variant:"outlined"})}),t.jsx(p.Divider,{}),t.jsxs(p.Box,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[v&&t.jsx(c.Loading,{text:"Fetching Tables..."}),b&&t.jsx(c.ApiErrorDisplay,{error:x,context:`${l} > ${e} > ${n}`}),y&&S.length===0&&t.jsx(p.Typography,{variant:"body2",children:"No Tables"}),y&&h?.data&&h.data.length>0&&t.jsx(p.List,{dense:!0,disablePadding:!0,children:S.map(T=>{let O=C(T.resource);return!k&&T.resource.includes("://")&&(O=T.resource.split("/").pop()||T.resource),t.jsx(p.ListItemButton,{onClick:()=>r(T.resource),children:t.jsx(p.ListItemText,{primary:O,secondary:T.columns.length>0?`${T.columns.length} columns`:void 0})},T.resource)})})]})]})}const xh={bigquery:"BigQuery",snowflake:"Snowflake",postgres:"PostgreSQL",mysql:"MySQL",sqlserver:"SQL Server",trino:"Trino",databricks:"Databricks",duckdb:"DuckDB",ducklake:"DuckLake",s3:"S3",gcs:"GCS",azure:"Azure"};function vh(e){return e?xh[e]??e:""}function bh({resourceUri:e}){const{apiClients:n,mutable:r}=q.useServer(),o=yt.useQueryClient(),{environmentName:i}=c.parseResourceUri(e),[l,a]=j.useState(""),[d,u]=j.useState(null),h=c.encodeResourceUri({environmentName:i,connectionName:d}),{data:y,isSuccess:b,isError:x,error:v}=c.useQueryWithApiError({queryKey:["connections",i],queryFn:()=>n.connections.listConnections(i)}),k=c.useMutationWithApiError({mutationFn:Ht("connection","create",M=>n.environments.updateEnvironment(i,{name:i,connections:[...y.data,M]})),onSuccess(){a("Connection added successfully"),o.invalidateQueries({queryKey:["connections",i]})},onError(M){a(M.message)}}),C=c.useMutationWithApiError({mutationFn:Ht("connection","update",M=>n.environments.updateEnvironment(i,{name:i,connections:y.data.map(E=>E.name===M.name?M:E)})),onSuccess(M,E){a(`Connection ${E.name} updated successfully`),o.invalidateQueries({queryKey:["connections",i]})},onError(M){a(M.message)}}),S=c.useMutationWithApiError({mutationFn:Ht("connection","delete",M=>{if(!M.name)throw new Error("Cannot delete a connection with no name");return n.connections.deleteConnection(i,M.name)}),onSuccess(M,E){a(`Connection ${E.name} deleted successfully`),o.invalidateQueries({queryKey:["connections",i]})},onError(M){a(M.message)}}),T=b?[...y.data].sort((M,E)=>(M.name??"").localeCompare(E.name??"")):[],O=k.isPending||C.isPending||S.isPending;return t.jsxs(_t,{title:"Connections",...b?{count:T.length}:{},description:"Database connections available to packages in this environment",...r&&b?{action:t.jsx(dh,{onSubmit:M=>k.mutateAsync(M),isSubmitting:k.isPending})}:{},children:[!b&&!x&&t.jsx(p.Typography,{variant:"body2",color:"text.secondary",children:"Fetching Connections..."}),x&&t.jsx(c.ApiErrorDisplay,{error:v,context:`${i} > Connections`}),b&&T.length===0&&t.jsx(p.Typography,{variant:"body2",color:"text.secondary",children:"No connections yet."}),b&&T.length>0&&t.jsx(p.Stack,{children:T.map(M=>t.jsx(wh,{connection:M,mutable:r,isMutating:O,onOpenExplorer:()=>u(M.name??null),onEdit:E=>C.mutateAsync(E),onDelete:E=>S.mutateAsync(E)},M.name))}),t.jsx(p.Snackbar,{open:l!=="",autoHideDuration:6e3,onClose:()=>a(""),message:l}),t.jsx(c.AppDialog,{open:d!==null,onClose:()=>u(null),maxWidth:"lg",title:`Connection explorer: ${d??""}`,showClose:!0,children:d&&t.jsx(tl,{resourceUri:h,connectionName:d,connection:y?.data?.find(M=>M.name===d)})})]})}function wh({connection:e,mutable:n,isMutating:r,onOpenExplorer:o,onEdit:i,onDelete:l}){const[a,d]=j.useState(null),u=!!a,h=b=>{b.stopPropagation(),d(b.currentTarget)},y=()=>d(null);return t.jsx(ss,{icon:t.jsx(Kd,{sx:{fontSize:18}}),tint:q.SURFACE_TINT.connection,label:e.name??"",ariaLabel:e.name??"",description:vh(e.type),onClick:o,...n?{trailingAction:t.jsxs(t.Fragment,{children:[t.jsx(p.IconButton,{size:"small",onClick:h,"aria-label":`Connection actions for ${e.name??""}`.trim(),children:t.jsx(Pt.MoreVert,{fontSize:"small"})}),t.jsxs(p.Menu,{anchorEl:a,open:u,onClose:y,onClick:b=>b.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[t.jsx(fh,{connection:e,onSubmit:i,isSubmitting:r,onCloseDialog:y}),t.jsx(hh,{connection:e,onCloseDialog:y,isMutating:r,onDelete:()=>l(e)})]})]})}:{}})}const Sh=c.createSvgIcon([t.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"),t.jsx("path",{d:"M9 12h6v2H9z"},"1")]);function kh({resourceUri:e,onCloseDialog:n}){const[r,o]=j.useState(!1),{apiClients:i}=q.useServer(),l=()=>{o(!0)},a=()=>{o(!1),n()},{environmentName:d,packageName:u}=c.parseResourceUri(e),h=_n({mutationFn:()=>i.packages.deletePackage(d,u),success:"Package deleted",invalidates:[["packages",d]],closeDialog:a,resource:"package",action:"delete"});return t.jsxs(j.Fragment,{children:[t.jsxs(p.MenuItem,{onClick:l,children:[t.jsx(p.ListItemIcon,{children:t.jsx(Pt.Delete,{fontSize:"small"})}),t.jsx(p.ListItemText,{children:"Delete"})]}),t.jsx(c.AppDialog,{open:r,onClose:a,title:"Delete package",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{onClick:a,children:"Cancel"}),t.jsx(c.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>h.mutate(),loading:h.isPending,children:"Delete package"})]}),children:t.jsxs(c.Typography,{variant:"body2",children:["Delete ",t.jsx("strong",{children:u}),"? The package stops being served and this cannot be undone."]})}),h.notice]})}function Ch({package:e,resourceUri:n,onCloseDialog:r}){const[o,i]=j.useState(!1),{apiClients:l}=q.useServer(),a=()=>{i(!0)},d=()=>{i(!1),r()},{packageName:u,environmentName:h}=c.parseResourceUri(n),y=_n({mutationFn(x){return l.packages.updatePackage(h,u,{name:u,description:x.description})},success:"Package updated",invalidates:[["packages",h]],closeDialog:d,resource:"package",action:"update"}),b=x=>{x.preventDefault();const k=new FormData(x.currentTarget).get("description")?.toString();y.mutate({description:k})};return t.jsxs(j.Fragment,{children:[t.jsxs(p.MenuItem,{onClick:a,children:[t.jsx(p.ListItemIcon,{children:t.jsx(Pt.Edit,{fontSize:"small"})}),t.jsx(p.ListItemText,{children:"Edit"})]}),t.jsx(c.AppDialog,{open:o,onClose:d,title:"Edit package",description:`What ${e.name} is, for the people who open it.`,actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{disabled:y.isPending,onClick:d,children:"Cancel"}),t.jsx(c.Button,{type:"submit",form:"package-form",variant:"contained",loading:y.isPending,children:"Save changes"})]}),children:t.jsx("form",{onSubmit:b,id:"package-form",children:t.jsxs(p.Stack,{sx:{gap:2},children:[t.jsx(c.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}}),t.jsx(c.TextField,{id:"description",name:"description",label:"Description",multiline:!0,fullWidth:!0,rows:4,size:"small",defaultValue:e.description,InputLabelProps:{shrink:!0}})]})})}),y.notice]})}function nl({onSelectPackage:e,resourceUri:n}){const{apiClients:r}=q.useServer(),{environmentName:o}=c.parseResourceUri(n),{data:i,isSuccess:l,isError:a,error:d}=c.useQueryWithApiError({queryKey:["packages",o],queryFn:()=>r.packages.listPackages(o)});if(a)return t.jsx(c.ApiErrorDisplay,{error:d,context:`${o} > Packages`});if(!l)return t.jsx(c.Loading,{text:"Fetching Packages..."});const u=[...i.data].sort((h,y)=>h.name.localeCompare(y.name));return t.jsx(p.Stack,{children:u.map(h=>{const y=c.encodeResourceUri({environmentName:o,packageName:h.name});return t.jsx(jh,{pkg:h,packageResourceUri:y,onSelectPackage:e},h.name)})})}function jh({pkg:e,packageResourceUri:n,onSelectPackage:r}){const{mutable:o}=q.useServer(),i=e.versionId!==void 0||e.latestVersion!==void 0,[l,a]=j.useState(null),d=!!l,u=y=>{y.stopPropagation(),a(y.currentTarget)},h=()=>a(null);return t.jsx(ss,{icon:t.jsx(Sh,{sx:{fontSize:18}}),tint:q.SURFACE_TINT.package,label:e.name,ariaLabel:e.name,...e.description?{description:e.description}:{},onClick:y=>r(e.name,y),...o?{trailingAction:t.jsxs(t.Fragment,{children:[t.jsx(p.IconButton,{size:"small",onClick:u,"aria-label":`Package actions for ${e.name}`,children:t.jsx(Pt.MoreVert,{fontSize:"small"})}),t.jsxs(p.Menu,{anchorEl:l,open:d,onClose:h,onClick:y=>y.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[!i&&t.jsx(Ch,{package:e,resourceUri:n,onCloseDialog:h}),t.jsx(kh,{resourceUri:n,onCloseDialog:h})]})]})}:{}})}function Th({onSelectPackage:e,resourceUri:n}){const{apiClients:r,mutable:o}=q.useServer(),{environmentName:i}=c.parseResourceUri(n),l=c.useQueryWithApiError({queryKey:["packages",i],queryFn:()=>r.packages.listPackages(i)});return j.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"})},[]),t.jsxs(p.Container,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[t.jsxs(p.Box,{sx:{mb:4},children:[t.jsx(p.Typography,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:i}),t.jsx(p.Typography,{variant:"body2",color:"text.secondary",children:"Manage packages and database connections in this environment. Open a package to explore its models and notebooks."})]}),t.jsx(_t,{title:"Packages",...l.isSuccess?{count:l.data.data.length}:{},description:"Published packages available for use in this environment",...o?{action:t.jsx(Yd,{resourceUri:n})}:{},children:t.jsx(nl,{onSelectPackage:e,resourceUri:n})}),t.jsx(bh,{resourceUri:n}),t.jsx(Ad,{resourceUri:n})]})}function _i({array1:e,array2:n,parser:r=o=>o}){return e&&n&&e.length===n.length&&e.every((o,i)=>r(o)===r(n[i]))}function Pi(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Oh(e={}){const{ignoreAccents:n=!0,ignoreCase:r=!0,limit:o,matchFrom:i="any",stringify:l,trim:a=!1}=e;return(d,{inputValue:u,getOptionLabel:h})=>{let y=a?u.trim():u;r&&(y=y.toLowerCase()),n&&(y=Pi(y));const b=y?d.filter(x=>{let v=(l||h)(x);return r&&(v=v.toLowerCase()),n&&(v=Pi(v)),i==="start"?v.startsWith(y):v.includes(y)}):d;return typeof o=="number"?b.slice(0,o):b}}const Mh=Oh(),zi=5,Eh=e=>e.current!==null&&e.current.parentElement?.contains(document.activeElement),Ih=[];function Wi(e,n,r,o){if(n||e==null||o)return"";const i=r(e);return typeof i=="string"?i:""}function Dh(e){const{unstable_isActiveElementInListbox:n=Eh,unstable_classNamePrefix:r="Mui",autoComplete:o=!1,autoHighlight:i=!1,autoSelect:l=!1,blurOnSelect:a=!1,clearOnBlur:d=!e.freeSolo,clearOnEscape:u=!1,componentName:h="useAutocomplete",defaultValue:y=e.multiple?Ih:null,disableClearable:b=!1,disableCloseOnSelect:x=!1,disabled:v,disabledItemsFocusable:k=!1,disableListWrap:C=!1,filterOptions:S=Mh,filterSelectedOptions:T=!1,freeSolo:O=!1,getOptionDisabled:M,getOptionKey:E,getOptionLabel:R=V=>V.label??V,groupBy:P,handleHomeEndKeys:A=!e.freeSolo,id:H,includeInputInList:D=!1,inputValue:L,isOptionEqualToValue:U=(V,B)=>V===B,multiple:$=!1,onChange:W,onClose:Q,onHighlightChange:te,onInputChange:ee,onOpen:G,open:Z,openOnFocus:ae=!1,options:z,readOnly:re=!1,renderValue:se,selectOnFocus:ne=!e.freeSolo,value:Ie}=e,de=c.useId(H);let pe=R;pe=V=>{const B=R(V);return typeof B!="string"?String(B):B};const De=Ce.useRef(!1),Le=Ce.useRef(!0),oe=Ce.useRef(null),K=Ce.useRef(null),[le,be]=Ce.useState(null),[ge,ue]=Ce.useState(-1),ye=i?0:-1,$e=Ce.useRef(ye),ze=Ce.useRef(Wi(y??Ie,$,pe)).current,[me,Y]=c.useControlled({controlled:Ie,default:y,name:h}),[ie,Oe]=c.useControlled({controlled:L,default:ze,name:h,state:"inputValue"}),[Fe,at]=Ce.useState(!1),Me=Ce.useCallback((V,B,ce)=>{if(!($?me.length<B.length:B!==null)&&!d)return;const J=Wi(B,$,pe,se);ie!==J&&(Oe(J),ee&&ee(V,J,ce))},[pe,ie,$,ee,Oe,d,me,se]),[lt,xt]=c.useControlled({controlled:Z,default:!1,name:h,state:"open"}),[vt,Ot]=Ce.useState(!0),pt=!$&&me!=null&&ie===pe(me),Ke=lt&&!re,he=Ke?S(z.filter(V=>!(T&&($?me:[me]).some(B=>B!==null&&U(V,B)))),{inputValue:pt&&vt?"":ie,getOptionLabel:pe}):[],Qe=hd({filteredOptions:he,value:me,inputValue:ie});Ce.useEffect(()=>{const V=me!==Qe.value;Fe&&!V||O&&!V||Me(null,me,"reset")},[me,Me,Fe,Qe.value,O]);const qe=lt&&he.length>0&&!re,ct=c.useEventCallback(V=>{if(V===-1)oe.current.focus();else{const B=se?"data-item-index":"data-tag-index";le.querySelector(`[${B}="${V}"]`).focus()}});Ce.useEffect(()=>{$&&ge>me.length-1&&(ue(-1),ct(-1))},[me,$,ge,ct]);function ut(V,B){if(!K.current||V<0||V>=he.length)return-1;let ce=V;for(;;){const ve=K.current.querySelector(`[data-option-index="${ce}"]`),J=k?!1:!ve||ve.disabled||ve.getAttribute("aria-disabled")==="true";if(ve&&ve.hasAttribute("tabindex")&&!J)return ce;if(B==="next"?ce=(ce+1)%he.length:ce=(ce-1+he.length)%he.length,ce===V)return-1}}const Ze=c.useEventCallback(({event:V,index:B,reason:ce})=>{if($e.current=B,B===-1?oe.current.removeAttribute("aria-activedescendant"):oe.current.setAttribute("aria-activedescendant",`${de}-option-${B}`),te&&["mouse","keyboard","touch"].includes(ce)&&te(V,B===-1?null:he[B],ce),!K.current)return;const ve=K.current.querySelector(`[role="option"].${r}-focused`);ve&&(ve.classList.remove(`${r}-focused`),ve.classList.remove(`${r}-focusVisible`));let J=K.current;if(K.current.getAttribute("role")!=="listbox"&&(J=K.current.parentElement.querySelector('[role="listbox"]')),!J)return;if(B===-1){J.scrollTop=0;return}const Ve=K.current.querySelector(`[data-option-index="${B}"]`);if(Ve&&(Ve.classList.add(`${r}-focused`),ce==="keyboard"&&Ve.classList.add(`${r}-focusVisible`),J.scrollHeight>J.clientHeight&&ce!=="mouse"&&ce!=="touch")){const Ge=Ve,Ct=J.clientHeight+J.scrollTop,vn=Ge.offsetTop+Ge.offsetHeight;vn>Ct?J.scrollTop=vn-J.clientHeight:Ge.offsetTop-Ge.offsetHeight*(P?1.3:0)<J.scrollTop&&(J.scrollTop=Ge.offsetTop-Ge.offsetHeight*(P?1.3:0))}}),fe=c.useEventCallback(({event:V,diff:B,direction:ce="next",reason:ve})=>{if(!Ke)return;const Ve=ut((()=>{const Ge=he.length-1;if(B==="reset")return ye;if(B==="start")return 0;if(B==="end")return Ge;const Ct=$e.current+B;return Ct<0?Ct===-1&&D?-1:C&&$e.current!==-1||Math.abs(B)>1?0:Ge:Ct>Ge?Ct===Ge+1&&D?-1:C||Math.abs(B)>1?Ge:0:Ct})(),ce);if(Ze({index:Ve,reason:ve,event:V}),o&&B!=="reset")if(Ve===-1)oe.current.value=ie;else{const Ge=pe(he[Ve]);oe.current.value=Ge,Ge.toLowerCase().indexOf(ie.toLowerCase())===0&&ie.length>0&&oe.current.setSelectionRange(ie.length,Ge.length)}}),Ue=!_i({array1:Qe.filteredOptions,array2:he,parser:pe}),bt=()=>{const V=(B,ce)=>{const ve=B?pe(B):"",J=ce?pe(ce):"";return ve===J};if($e.current!==-1&&!_i({array1:Qe.filteredOptions,array2:he,parser:pe})&&Qe.inputValue===ie&&($?me.length===Qe.value.length&&Qe.value.every((B,ce)=>pe(me[ce])===pe(B)):V(Qe.value,me))){const B=Qe.filteredOptions[$e.current];if(B)return he.findIndex(ce=>pe(ce)===pe(B))}return-1},ke=Ce.useCallback(()=>{if(!Ke)return;const V=bt();if(V!==-1){$e.current=V;return}const B=$?me[0]:me;if(he.length===0||B==null){fe({diff:"reset"});return}if(K.current){if(B!=null){const ce=he[$e.current];if($&&ce&&me.findIndex(J=>U(ce,J))!==-1)return;const ve=he.findIndex(J=>U(J,B));ve===-1?fe({diff:"reset"}):Ze({index:ve});return}if($e.current>=he.length-1){Ze({index:he.length-1});return}Ze({index:$e.current})}},[he.length,$?!1:me,T,fe,Ze,Ke,ie,$]),Ne=c.useEventCallback(V=>{c.setRef(K,V),V&&ke()});Ce.useEffect(()=>{Ue&&ke()},[ke,Ue]);const Ee=V=>{lt||(xt(!0),Ot(!0),G&&G(V))},Be=(V,B)=>{lt&&(xt(!1),Q&&Q(V,B))},ht=(V,B,ce,ve)=>{if($){if(me.length===B.length&&me.every((J,Ve)=>J===B[Ve]))return}else if(me===B)return;W&&W(V,B,ce,ve),Y(B)},We=Ce.useRef(!1),nt=(V,B,ce="selectOption",ve="options")=>{let J=ce,Ve=B;if($){Ve=Array.isArray(me)?me.slice():[];const Ge=Ve.findIndex(Ct=>U(B,Ct));Ge===-1?Ve.push(B):ve!=="freeSolo"&&(Ve.splice(Ge,1),J="removeOption")}Me(V,Ve,J),ht(V,Ve,J,{option:B}),!x&&(!V||!V.ctrlKey&&!V.metaKey)&&Be(V,J),(a===!0||a==="touch"&&We.current||a==="mouse"&&!We.current)&&oe.current.blur()};function Mt(V,B){if(V===-1)return-1;let ce=V;for(;;){if(B==="next"&&ce===me.length||B==="previous"&&ce===-1)return-1;const ve=se?"data-item-index":"data-tag-index",J=le.querySelector(`[${ve}="${ce}"]`);if(!J||!J.hasAttribute("tabindex")||J.disabled||J.getAttribute("aria-disabled")==="true")ce+=B==="next"?1:-1;else return ce}}const kt=(V,B)=>{if(!$)return;ie===""&&Be(V,"toggleInput");let ce=ge;ge===-1?ie===""&&B==="previous"&&(ce=me.length-1):(ce+=B==="next"?1:-1,ce<0&&(ce=0),ce===me.length&&(ce=-1)),ce=Mt(ce,B),ue(ce),ct(ce)},At=V=>{De.current=!0,Oe(""),ee&&ee(V,"","clear"),ht(V,$?[]:null,"clear")},gn=V=>B=>{if(V.onKeyDown&&V.onKeyDown(B),!B.defaultMuiPrevented&&(ge!==-1&&!["ArrowLeft","ArrowRight"].includes(B.key)&&(ue(-1),ct(-1)),B.which!==229))switch(B.key){case"Home":Ke&&A&&(B.preventDefault(),fe({diff:"start",direction:"next",reason:"keyboard",event:B}));break;case"End":Ke&&A&&(B.preventDefault(),fe({diff:"end",direction:"previous",reason:"keyboard",event:B}));break;case"PageUp":B.preventDefault(),fe({diff:-zi,direction:"previous",reason:"keyboard",event:B}),Ee(B);break;case"PageDown":B.preventDefault(),fe({diff:zi,direction:"next",reason:"keyboard",event:B}),Ee(B);break;case"ArrowDown":B.preventDefault(),fe({diff:1,direction:"next",reason:"keyboard",event:B}),Ee(B);break;case"ArrowUp":B.preventDefault(),fe({diff:-1,direction:"previous",reason:"keyboard",event:B}),Ee(B);break;case"ArrowLeft":!$&&se?ct(0):kt(B,"previous");break;case"ArrowRight":!$&&se?ct(-1):kt(B,"next");break;case"Enter":if($e.current!==-1&&Ke){const ce=he[$e.current],ve=M?M(ce):!1;if(B.preventDefault(),ve)return;nt(B,ce,"selectOption"),o&&oe.current.setSelectionRange(oe.current.value.length,oe.current.value.length)}else O&&ie!==""&&pt===!1&&($&&B.preventDefault(),nt(B,ie,"createOption","freeSolo"));break;case"Escape":Ke?(B.preventDefault(),B.stopPropagation(),Be(B,"escape")):u&&(ie!==""||$&&me.length>0||se)&&(B.preventDefault(),B.stopPropagation(),At(B));break;case"Backspace":if($&&!re&&ie===""&&me.length>0){const ce=ge===-1?me.length-1:ge,ve=me.slice();ve.splice(ce,1),ht(B,ve,"removeOption",{option:me[ce]})}!$&&se&&!re&&(Y(null),ct(-1));break;case"Delete":if($&&!re&&ie===""&&me.length>0&&ge!==-1){const ce=ge,ve=me.slice();ve.splice(ce,1),ht(B,ve,"removeOption",{option:me[ce]})}!$&&se&&!re&&(Y(null),ct(-1));break}},Pe=V=>{at(!0),ae&&!De.current&&Ee(V)},dt=V=>{if(n(K)){oe.current.focus();return}at(!1),Le.current=!0,De.current=!1,l&&$e.current!==-1&&Ke?nt(V,he[$e.current],"blur"):l&&O&&ie!==""?nt(V,ie,"blur","freeSolo"):d&&Me(V,me,"blur"),Be(V,"blur")},Kt=V=>{const B=V.target.value;ie!==B&&(Oe(B),Ot(!1),ee&&ee(V,B,"input")),B===""?!b&&!$&&ht(V,null,"clear"):Ee(V)},yn=V=>{const B=Number(V.currentTarget.getAttribute("data-option-index"));$e.current!==B&&Ze({event:V,index:B,reason:"mouse"})},ft=V=>{Ze({event:V,index:Number(V.currentTarget.getAttribute("data-option-index")),reason:"touch"}),We.current=!0},en=V=>{const B=Number(V.currentTarget.getAttribute("data-option-index"));nt(V,he[B],"selectOption"),We.current=!1},xn=V=>B=>{const ce=me.slice();ce.splice(V,1),ht(B,ce,"removeOption",{option:me[V]})},Qt=V=>{ht(V,null,"removeOption",{option:me})},Xe=V=>{lt?Be(V,"toggleInput"):Ee(V)},Je=V=>{V.currentTarget.contains(V.target)&&V.target.getAttribute("id")!==de&&V.preventDefault()},Ft=V=>{V.currentTarget.contains(V.target)&&(oe.current.focus(),ne&&Le.current&&oe.current.selectionEnd-oe.current.selectionStart===0&&oe.current.select(),Le.current=!1)},tn=V=>{!v&&(ie===""||!lt)&&Xe(V)};let Zt=O&&ie.length>0;Zt=Zt||($?me.length>0:me!==null);let nn=he;return P&&(nn=he.reduce((V,B,ce)=>{const ve=P(B);return V.length>0&&V[V.length-1].group===ve?V[V.length-1].options.push(B):V.push({key:ce,index:ce,group:ve,options:[B]}),V},[])),v&&Fe&&dt(),{getRootProps:(V={})=>({...V,onKeyDown:gn(V),onMouseDown:Je,onClick:Ft}),getInputLabelProps:()=>({id:`${de}-label`,htmlFor:de}),getInputProps:()=>({id:de,value:ie,onBlur:dt,onFocus:Pe,onChange:Kt,onMouseDown:tn,"aria-activedescendant":Ke?"":null,"aria-autocomplete":o?"both":"list","aria-controls":qe?`${de}-listbox`:void 0,"aria-expanded":qe,autoComplete:"off",ref:oe,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:v}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:At}),getItemProps:({index:V=0}={})=>({...$&&{key:V},...se?{"data-item-index":V}:{"data-tag-index":V},tabIndex:-1,...!re&&{onDelete:$?xn(V):Qt}}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:Xe}),getTagProps:({index:V})=>({key:V,"data-tag-index":V,tabIndex:-1,...!re&&{onDelete:xn(V)}}),getListboxProps:()=>({role:"listbox",id:`${de}-listbox`,"aria-labelledby":`${de}-label`,ref:Ne,onMouseDown:V=>{V.preventDefault()}}),getOptionProps:({index:V,option:B})=>{const ce=($?me:[me]).some(J=>J!=null&&U(B,J)),ve=M?M(B):!1;return{key:E?.(B)??pe(B),tabIndex:-1,role:"option",id:`${de}-option-${V}`,onMouseMove:yn,onClick:en,onTouchStart:ft,"data-option-index":V,"aria-disabled":ve,"aria-selected":ce}},id:de,inputValue:ie,value:me,dirty:Zt,expanded:Ke&&le,popupOpen:Ke,focused:Fe||ge!==-1,anchorEl:le,setAnchorEl:be,focusedItem:ge,focusedTag:ge,groupedOptions:nn}}function $h(e){return c.generateUtilityClass("MuiListSubheader",e)}c.generateUtilityClasses("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);const Ah=e=>{const{classes:n,color:r,disableGutters:o,inset:i,disableSticky:l}=e,a={root:["root",r!=="default"&&`color${c.capitalize(r)}`,!o&&"gutters",i&&"inset",!l&&"sticky"]};return c.composeClasses(a,$h,n)},Fh=c.styled("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[n.root,r.color!=="default"&&n[`color${c.capitalize(r.color)}`],!r.disableGutters&&n.gutters,r.inset&&n.inset,!r.disableSticky&&n.sticky]}})(c.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:n})=>!n.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:n})=>n.inset,style:{paddingLeft:72}},{props:({ownerState:n})=>!n.disableSticky,style:{position:"sticky",top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper}}]}))),Ks=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiListSubheader"}),{className:i,color:l="default",component:a="li",disableGutters:d=!1,disableSticky:u=!1,inset:h=!1,...y}=o,b={...o,color:l,component:a,disableGutters:d,disableSticky:u,inset:h},x=Ah(b);return t.jsx(Fh,{as:a,className:c.clsx(x.root,i),ref:r,ownerState:b,...y})});Ks&&(Ks.muiSkipListHighlight=!0);const Rh=c.createSvgIcon(t.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 Nh(e){return c.generateUtilityClass("MuiAutocomplete",e)}const Te=c.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 qi,Bi;const Lh=e=>{const{classes:n,disablePortal:r,expanded:o,focused:i,fullWidth:l,hasClearIcon:a,hasPopupIcon:d,inputFocused:u,popupOpen:h,size:y}=e,b={root:["root",o&&"expanded",i&&"focused",l&&"fullWidth",a&&"hasClearIcon",d&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",u&&"inputFocused"],tag:["tag",`tagSize${c.capitalize(y)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",h&&"popupIndicatorOpen"],popper:["popper",r&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return c.composeClasses(b,Nh,n)},_h=c.styled("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(e,n)=>{const{ownerState:r}=e,{fullWidth:o,hasClearIcon:i,hasPopupIcon:l,inputFocused:a,size:d}=r;return[{[`& .${Te.tag}`]:n.tag},{[`& .${Te.tag}`]:n[`tagSize${c.capitalize(d)}`]},{[`& .${Te.inputRoot}`]:n.inputRoot},{[`& .${Te.input}`]:n.input},{[`& .${Te.input}`]:a&&n.inputFocused},n.root,o&&n.fullWidth,l&&n.hasPopupIcon,i&&n.hasClearIcon]}})({[`&.${Te.focused} .${Te.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${Te.clearIndicator}`]:{visibility:"visible"}},[`& .${Te.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${Te.inputRoot}`]:{[`.${Te.hasPopupIcon}&, .${Te.hasClearIcon}&`]:{paddingRight:30},[`.${Te.hasPopupIcon}.${Te.hasClearIcon}&`]:{paddingRight:56},[`& .${Te.input}`]:{width:0,minWidth:30}},[`& .${c.inputClasses.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${c.inputClasses.root}.${c.inputBaseClasses.sizeSmall}`]:{[`& .${c.inputClasses.input}`]:{padding:"2px 4px 3px 0"}},[`& .${c.outlinedInputClasses.root}`]:{padding:9,[`.${Te.hasPopupIcon}&, .${Te.hasClearIcon}&`]:{paddingRight:39},[`.${Te.hasPopupIcon}.${Te.hasClearIcon}&`]:{paddingRight:65},[`& .${Te.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${Te.endAdornment}`]:{right:9}},[`& .${c.outlinedInputClasses.root}.${c.inputBaseClasses.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${Te.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${c.filledInputClasses.root}`]:{paddingTop:19,paddingLeft:8,[`.${Te.hasPopupIcon}&, .${Te.hasClearIcon}&`]:{paddingRight:39},[`.${Te.hasPopupIcon}.${Te.hasClearIcon}&`]:{paddingRight:65},[`& .${c.filledInputClasses.input}`]:{padding:"7px 4px"},[`& .${Te.endAdornment}`]:{right:9}},[`& .${c.filledInputClasses.root}.${c.inputBaseClasses.sizeSmall}`]:{paddingBottom:1,[`& .${c.filledInputClasses.input}`]:{padding:"2.5px 4px"}},[`& .${c.inputBaseClasses.hiddenLabel}`]:{paddingTop:8},[`& .${c.filledInputClasses.root}.${c.inputBaseClasses.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${Te.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${c.filledInputClasses.root}.${c.inputBaseClasses.hiddenLabel}.${c.inputBaseClasses.sizeSmall}`]:{[`& .${Te.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${Te.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${Te.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${Te.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${Te.inputRoot}`]:{flexWrap:"wrap"}}}]}),Ph=c.styled("div",{name:"MuiAutocomplete",slot:"EndAdornment"})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),zh=c.styled(c.IconButton,{name:"MuiAutocomplete",slot:"ClearIndicator"})({marginRight:-2,padding:4,visibility:"hidden"}),Wh=c.styled(c.IconButton,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[n.popupIndicator,r.popupOpen&&n.popupIndicatorOpen]}})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),qh=c.styled(c.Popper,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(e,n)=>{const{ownerState:r}=e;return[{[`& .${Te.option}`]:n.option},n.popper,r.disablePortal&&n.popperDisablePortal]}})(c.memoTheme(({theme:e})=>({zIndex:(e.vars||e).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]}))),Bh=c.styled(c.Paper,{name:"MuiAutocomplete",slot:"Paper"})(c.memoTheme(({theme:e})=>({...e.typography.body1,overflow:"auto"}))),Vh=c.styled("div",{name:"MuiAutocomplete",slot:"Loading"})(c.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),Hh=c.styled("div",{name:"MuiAutocomplete",slot:"NoOptions"})(c.memoTheme(({theme:e})=>({color:(e.vars||e).palette.text.secondary,padding:"14px 16px"}))),Uh=c.styled("ul",{name:"MuiAutocomplete",slot:"Listbox"})(c.memoTheme(({theme:e})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${Te.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"},[`&.${Te.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"},[`&.${Te.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),[`&.${Te.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}},[`&.${Te.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}}}}))),Gh=c.styled(Ks,{name:"MuiAutocomplete",slot:"GroupLabel"})(c.memoTheme(({theme:e})=>({backgroundColor:(e.vars||e).palette.background.paper,top:-8}))),Yh=c.styled("ul",{name:"MuiAutocomplete",slot:"GroupUl"})({padding:0,[`& .${Te.option}`]:{paddingLeft:24}}),Qs=Ce.forwardRef(function(n,r){const o=c.useDefaultProps({props:n,name:"MuiAutocomplete"}),{autoComplete:i=!1,autoHighlight:l=!1,autoSelect:a=!1,blurOnSelect:d=!1,ChipProps:u,className:h,clearIcon:y=qi||(qi=t.jsx(Rh,{fontSize:"small"})),clearOnBlur:b=!o.freeSolo,clearOnEscape:x=!1,clearText:v="Clear",closeText:k="Close",componentsProps:C,defaultValue:S=o.multiple?[]:null,disableClearable:T=!1,disableCloseOnSelect:O=!1,disabled:M=!1,disabledItemsFocusable:E=!1,disableListWrap:R=!1,disablePortal:P=!1,filterOptions:A,filterSelectedOptions:H=!1,forcePopupIcon:D="auto",freeSolo:L=!1,fullWidth:U=!1,getLimitTagsText:$=Ae=>`+${Ae}`,getOptionDisabled:W,getOptionKey:Q,getOptionLabel:te,isOptionEqualToValue:ee,groupBy:G,handleHomeEndKeys:Z=!o.freeSolo,id:ae,includeInputInList:z=!1,inputValue:re,limitTags:se=-1,ListboxComponent:ne,ListboxProps:Ie,loading:de=!1,loadingText:pe="Loading…",multiple:De=!1,noOptionsText:Le="No options",onChange:oe,onClose:K,onHighlightChange:le,onInputChange:be,onOpen:ge,open:ue,openOnFocus:ye=!1,openText:$e="Open",options:ze,PaperComponent:me,PopperComponent:Y,popupIcon:ie=Bi||(Bi=t.jsx(c.ArrowDropDownIcon,{})),readOnly:Oe=!1,renderGroup:Fe,renderInput:at,renderOption:Me,renderTags:lt,renderValue:xt,selectOnFocus:vt=!o.freeSolo,size:Ot="medium",slots:pt={},slotProps:Ke={},value:he,...Qe}=o,{getRootProps:qe,getInputProps:ct,getInputLabelProps:ut,getPopupIndicatorProps:Ze,getClearProps:fe,getItemProps:Ue,getListboxProps:bt,getOptionProps:ke,value:Ne,dirty:Ee,expanded:Be,id:ht,popupOpen:We,focused:nt,focusedItem:Mt,anchorEl:kt,setAnchorEl:At,inputValue:gn,groupedOptions:Pe}=Dh({...o,componentName:"Autocomplete"}),dt=!T&&!M&&Ee&&!Oe,Kt=(!L||D===!0)&&D!==!1,{onMouseDown:yn}=ct(),{ref:ft,...en}=bt(),Qt=te||(Ae=>Ae.label??Ae),Xe={...o,disablePortal:P,expanded:Be,focused:nt,fullWidth:U,getOptionLabel:Qt,hasClearIcon:dt,hasPopupIcon:Kt,inputFocused:Mt===-1,popupOpen:We,size:Ot},Je=Lh(Xe),Ft={slots:{paper:me,popper:Y,...pt},slotProps:{chip:u,listbox:Ie,...C,...Ke}},[tn,Zt]=c.useSlot("listbox",{elementType:Uh,externalForwardedProps:Ft,ownerState:Xe,className:Je.listbox,additionalProps:en,ref:ft}),[nn,V]=c.useSlot("paper",{elementType:c.Paper,externalForwardedProps:Ft,ownerState:Xe,className:Je.paper}),[B,ce]=c.useSlot("popper",{elementType:c.Popper,externalForwardedProps:Ft,ownerState:Xe,className:Je.popper,additionalProps:{disablePortal:P,style:{width:kt?kt.clientWidth:null},role:"presentation",anchorEl:kt,open:We}});let ve;const J=Ae=>({className:Je.tag,disabled:M,...Ue(Ae)});if(De?Ne.length>0&&(lt?ve=lt(Ne,J,Xe):xt?ve=xt(Ne,J,Xe):ve=Ne.map((Ae,zt)=>{const{key:gt,...qt}=J({index:zt});return t.jsx(c.Chip,{label:Qt(Ae),size:Ot,...qt,...Ft.slotProps.chip},gt)})):xt&&Ne!=null&&(ve=xt(Ne,J,Xe)),se>-1&&Array.isArray(ve)){const Ae=ve.length-se;!nt&&Ae>0&&(ve=ve.splice(0,se),ve.push(t.jsx("span",{className:Je.tag,children:$(Ae)},ve.length)))}const Ge=Fe||(Ae=>t.jsxs("li",{children:[t.jsx(Gh,{className:Je.groupLabel,ownerState:Xe,component:"div",children:Ae.group}),t.jsx(Yh,{className:Je.groupUl,ownerState:Xe,children:Ae.children})]},Ae.key)),vn=Me||((Ae,zt)=>{const{key:gt,...qt}=Ae;return t.jsx("li",{...qt,children:Qt(zt)},gt)}),zn=(Ae,zt)=>{const gt=ke({option:Ae,index:zt});return vn({...gt,className:Je.option},Ae,{selected:gt["aria-selected"],index:zt,inputValue:gn},Xe)},Wn=Ft.slotProps.clearIndicator,Dr=Ft.slotProps.popupIndicator;return t.jsxs(Ce.Fragment,{children:[t.jsx(_h,{ref:r,className:c.clsx(Je.root,h),ownerState:Xe,...qe(Qe),children:at({id:ht,disabled:M,fullWidth:!0,size:Ot==="small"?"small":void 0,InputLabelProps:ut(),InputProps:{ref:At,className:Je.inputRoot,startAdornment:ve,onMouseDown:Ae=>{Ae.target===Ae.currentTarget&&yn(Ae)},...(dt||Kt)&&{endAdornment:t.jsxs(Ph,{className:Je.endAdornment,ownerState:Xe,children:[dt?t.jsx(zh,{...fe(),"aria-label":v,title:v,ownerState:Xe,...Wn,className:c.clsx(Je.clearIndicator,Wn?.className),children:y}):null,Kt?t.jsx(Wh,{...Ze(),disabled:M,"aria-label":We?k:$e,title:We?k:$e,ownerState:Xe,...Dr,className:c.clsx(Je.popupIndicator,Dr?.className),children:ie}):null]})}},inputProps:{className:Je.input,disabled:M,readOnly:Oe,...ct()}})}),kt?t.jsx(qh,{as:B,...ce,children:t.jsxs(Bh,{as:nn,...V,children:[de&&Pe.length===0?t.jsx(Vh,{className:Je.loading,ownerState:Xe,children:pe}):null,Pe.length===0&&!L&&!de?t.jsx(Hh,{className:Je.noOptions,ownerState:Xe,role:"presentation",onMouseDown:Ae=>{Ae.preventDefault()},children:Le}):null,Pe.length>0?t.jsx(tn,{as:ne,...Zt,children:Pe.map((Ae,zt)=>G?Ge({key:Ae.key,group:Ae.group,children:Ae.options.map((gt,qt)=>zn(gt,Ae.index+qt))}):zn(Ae,zt))}):null]})}):null]})});c.dayjs.extend(c.utc);function Os(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 Kh(e){return e==="DateMinMax"}function Ms(e){return e==="Between"}function Qh({spec:e,values:n,selection:r,onChange:o,retrievalFn:i}){const l=()=>r?.matchType?r.matchType:e.defaultMatchType?e.defaultMatchType:e.filterType==="DateMinMax"?"Between":Os(e.filterType)[0]||"Equals",[a,d]=j.useState(l()),[u,h]=j.useState(r?.value??""),[y,b]=j.useState(r?.value2??""),[x,v]=j.useState([]),[k,C]=j.useState(!1),[S,T]=j.useState(""),[O,M]=j.useState(!1),[E,R]=j.useState(!1),P=j.useRef(null),A=j.useRef(0),[H,D]=j.useState(!1);j.useEffect(()=>{if(e.filterType!=="Retrieval"||!i)return;const z=S.trim();if(z.length<=2){v([]),M(!1);return}return P.current&&clearTimeout(P.current),P.current=setTimeout(async()=>{A.current+=1;const re=A.current;C(!0);try{const se=await i(z,e);re===A.current&&v(se)}catch(se){re===A.current&&(console.error("Retrieval failed",se),v([]))}finally{re===A.current&&(C(!1),M(!0))}},500),()=>{P.current&&clearTimeout(P.current)}},[S,e,i]),j.useEffect(()=>{r===null?(h(""),b(""),d(e.defaultMatchType??(e.filterType==="DateMinMax"?"Between":Os(e.filterType)[0]||"Equals"))):r&&(d(r.matchType),h(r.value??""),b(r.value2??""))},[r,e.filterType,e.defaultMatchType]);const L=Os(e.filterType),U=Kh(e.filterType),$=Ms(a),W=U&&n.length>=2&&n[0].value instanceof Date?c.dayjs.utc(n[0].value):void 0,Q=U&&n.length>=2&&n[1].value instanceof Date?c.dayjs.utc(n[1].value):void 0,te=e.filterType==="MinMax"&&n.length>=2&&typeof n[0].value=="number"?n[0].value:void 0,ee=e.filterType==="MinMax"&&n.length>=2&&typeof n[1].value=="number"?n[1].value:void 0;if(L.length===0)return null;const G=z=>{const re=z.target.value;d(re),Ms(re)||b(""),u&&o({dimensionName:e.dimensionName,source:e.source,filterName:e.filterName,matchType:re,value:u,...Ms(re)&&y&&{value2:y}})},Z=(z,re)=>{h(z??""),re!==void 0&&b(re??"");const se=Array.isArray(z)&&z.length===0;o(!se&&z!==""&&z!==null&&z!==void 0?{dimensionName:e.dimensionName,source:e.source,filterName:e.filterName,matchType:a,value:z,...$&&re&&{value2:re}}:null)},ae=()=>{h(""),b(""),o(null)};return t.jsxs(Ye,{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:[t.jsxs(Ye,{sx:{fontWeight:600,color:e.required&&!r?"error.main":"text.primary"},children:[e.label??e.dimensionName,e.required&&t.jsx(Ye,{component:"span",sx:{color:r?"text.secondary":"error.main",fontWeight:400,fontSize:"0.7rem",ml:.5},children:"(required)"})]}),e.filterType!=="Boolean"&&!e.defaultMatchType&&L.length>1&&t.jsxs(c.FormControl,{size:"small",fullWidth:!0,children:[t.jsx(c.InputLabel,{children:"Match Type"}),t.jsx(c.Select,{value:a,label:"Match Type",onChange:G,MenuProps:{PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}},children:L.map(z=>t.jsx(tt,{value:z,children:z},z))})]}),e.filterType==="Star"&&a==="Equals"&&t.jsx(Qs,{multiple:!0,size:"small",options:n,getOptionLabel:z=>typeof z=="string"?z:typeof z=="object"&&z!==null&&"value"in z?String(z.value):String(z),value:Array.isArray(u)?u.map(z=>n.find(re=>re.value===z)||z):u?[n.find(z=>z.value===u)||u]:[],onChange:(z,re)=>{const se=re.map(ne=>typeof ne=="string"?ne:ne&&typeof ne=="object"&&"value"in ne?ne.value:ne);Z(se)},noOptionsText:"No matches found",renderInput:z=>t.jsx(c.TextField,{...z,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"&&a==="Contains"&&t.jsx(c.TextField,{size:"small",label:"Search Text",value:u,onChange:z=>h(z.target.value),onBlur:()=>Z(u),onKeyDown:z=>{z.key==="Enter"&&Z(u)},placeholder:"Enter text to search...",fullWidth:!0}),e.filterType==="Boolean"&&t.jsxs(c.FormControl,{size:"small",fullWidth:!0,children:[t.jsx(c.InputLabel,{children:"Value"}),t.jsxs(c.Select,{value:u===!0?"true":u===!1?"false":"",label:"Value",onChange:z=>{const re=z.target.value;re==="true"?Z(!0):re==="false"?Z(!1):ae()},MenuProps:{PaperProps:{sx:{"& .MuiMenuItem-root":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}},children:[t.jsx(tt,{value:"",children:t.jsx("em",{children:"Blank"})}),t.jsx(tt,{value:"true",children:"True"}),t.jsx(tt,{value:"false",children:"False"})]})]}),e.filterType==="Retrieval"&&a==="Semantic Search"&&t.jsx(Qs,{multiple:!0,size:"small",options:x,loading:k,getOptionLabel:z=>typeof z=="string"?z:typeof z=="object"&&z!==null&&"value"in z?String(z.value):String(z),value:Array.isArray(u)?u.map(z=>x.find(se=>se.value===z)||{value:z}):u?[{value:u}]:[],onInputChange:(z,re)=>{T(re)},onChange:(z,re)=>{const se=re.map(ne=>typeof ne=="string"?ne:ne&&typeof ne=="object"&&"value"in ne?ne.value:ne);Z(se)},noOptionsText:S.trim().length<=2?"Type at least 3 characters to search":"No matches found",renderInput:z=>t.jsx(c.TextField,{...z,size:"small",label:"Search Values",placeholder:"Type to search...",onFocus:()=>R(!0),onBlur:()=>R(!1),helperText:E&&!k&&O&&x.length===0?"No matches found":void 0,InputProps:{...z.InputProps,endAdornment:t.jsxs(t.Fragment,{children:[k?t.jsx(c.CircularProgress,{color:"inherit",size:20}):null,z.InputProps.endAdornment]})}}),freeSolo:!0,filterOptions:z=>z,slotProps:{paper:{sx:{"& .MuiAutocomplete-option":{fontSize:"0.75rem",minHeight:"auto",padding:"4px 10px"}}}}}),e.filterType==="MinMax"&&!$&&t.jsx(c.TextField,{size:"small",type:"number",label:"Value",value:u,onChange:z=>Z(parseFloat(z.target.value)||""),onFocus:()=>D(!0),onBlur:()=>D(!1),placeholder:"Enter number...",fullWidth:!0,inputProps:{min:te,max:ee},helperText:H&&te!==void 0&&ee!==void 0?`Valid range: [${te} - ${ee}]`:void 0}),e.filterType==="MinMax"&&$&&t.jsxs(Ye,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(Ye,{sx:{display:"flex",gap:1,alignItems:"center"},children:[t.jsx(c.TextField,{size:"small",type:"number",label:"From",value:u,onChange:z=>Z(parseFloat(z.target.value)||"",y),onFocus:()=>D(!0),onBlur:()=>D(!1),placeholder:"Min...",fullWidth:!0,inputProps:{min:te,max:y||ee}}),t.jsx(Ye,{children:"to"}),t.jsx(c.TextField,{size:"small",type:"number",label:"To",value:y,onChange:z=>Z(u,parseFloat(z.target.value)||""),onFocus:()=>D(!0),onBlur:()=>D(!1),placeholder:"Max...",fullWidth:!0,inputProps:{min:u||te,max:ee}})]}),H&&te!==void 0&&ee!==void 0&&t.jsxs(c.Typography,{variant:"caption",color:"text.secondary",sx:{mt:-.5,ml:1.5},children:["Valid range: [",te," - ",ee,"]"]})]}),U&&!$&&t.jsx(c.LocalizationProvider,{dateAdapter:c.AdapterDayjs,children:t.jsx(c.DatePicker,{label:"Date",value:u instanceof Date?c.dayjs.utc(u):null,onChange:z=>{z===null?Z(null):z.isValid()&&Z(z.utc().toDate())},timezone:"UTC",minDate:u instanceof Date?void 0:W,maxDate:u instanceof Date?void 0:Q,referenceDate:a==="After"&&W?W:void 0,slotProps:{textField:{size:"small",fullWidth:!0,sx:{minWidth:150},onFocus:()=>D(!0),onBlur:()=>D(!1),helperText:H&&W&&Q?`Valid range: [${W.format("YYYY-MM-DD")} - ${Q.format("YYYY-MM-DD")}]`:void 0},openPickerButton:{sx:{backgroundColor:"transparent"}}}})}),U&&$&&t.jsx(c.LocalizationProvider,{dateAdapter:c.AdapterDayjs,children:t.jsxs(Ye,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(Ye,{sx:{display:"flex",gap:1,alignItems:"center"},children:[t.jsx(Ye,{sx:{flex:1,minWidth:0},children:t.jsx(c.DatePicker,{label:"From",value:u instanceof Date?c.dayjs.utc(u):null,onChange:z=>{z===null?Z(null,y):z.isValid()&&Z(z.utc().toDate(),y)},timezone:"UTC",minDate:u instanceof Date?void 0:W,maxDate:y instanceof Date?c.dayjs.utc(y):u instanceof Date?void 0:Q,referenceDate:W,slotProps:{textField:{size:"small",fullWidth:!0,onFocus:()=>D(!0),onBlur:()=>D(!1)},openPickerButton:{sx:{backgroundColor:"transparent"}}}})}),t.jsx(Ye,{children:"to"}),t.jsx(Ye,{sx:{flex:1,minWidth:0},children:t.jsx(c.DatePicker,{label:"To",value:y instanceof Date?c.dayjs.utc(y):null,onChange:z=>{z===null?Z(u,null):z.isValid()&&Z(u,z.utc().toDate())},timezone:"UTC",minDate:u instanceof Date?c.dayjs.utc(u):y instanceof Date?void 0:W,maxDate:y instanceof Date?void 0:Q,referenceDate:u instanceof Date?c.dayjs.utc(u):W,slotProps:{textField:{size:"small",fullWidth:!0,onFocus:()=>D(!0),onBlur:()=>D(!1)},openPickerButton:{sx:{backgroundColor:"transparent"}}}})})]}),H&&W&&Q&&t.jsxs(c.Typography,{variant:"caption",color:"text.secondary",sx:{mt:-.5,ml:1.5},children:["Valid range: [",W.format("YYYY-MM-DD")," -"," ",Q.format("YYYY-MM-DD"),"]"]})]})})]})}function is(e,n){const{matchType:r,value:o,value2:i}=n;if(Array.isArray(o))return r!=="Equals"&&r!=="Semantic Search"||o.length===0?"":`(${o.map(a=>`${e} = ${c.formatMalloyValue(a)}`).join(" or ")})`;switch(r){case"Equals":case"Semantic Search":return`${e} = ${c.formatMalloyValue(o)}`;case"Contains":if(typeof o=="string"){const l=ed.StringFilterExpression.unparse({operator:"contains",values:[o]});return`${e} ~ ${c.malloyFilterLiteral(l)}`}return`${e} = ${c.formatMalloyValue(o)}`;case"After":case"Greater Than":return`${e} > ${c.formatMalloyValue(o)}`;case"Before":case"Less Than":return`${e} < ${c.formatMalloyValue(o)}`;case"Between":return i!==void 0?`${e} >= ${c.formatMalloyValue(o)} and ${e} <= ${c.formatMalloyValue(i)}`:`${e} >= ${c.formatMalloyValue(o)}`;default:return""}}function Zh(e){const n=new Set,r=e.schema?.fields;if(!r)return n;for(const o of r)"kind"in o&&o.kind==="join"&&o.name&&n.add(o.name);return n}function Xh(e){if(!e)return null;for(const n of e)if(n.startsWith("##(filters)")){const r=n.slice(11).trim();try{const o=JSON.parse(r);if(Array.isArray(o)){const i=[];for(const l of o)if(typeof l=="string"){const a=l.indexOf(".");a>0&&a<l.length-1&&i.push({source:l.substring(0,a),dimension:l.substring(a+1)})}if(i.length>0)return{filters:i}}}catch(o){console.error(`Failed to parse "${n}" annotation:`,o)}}return null}function rl(e){if(e.startsWith("#(filter)")){const n=e.slice(9).trim();try{const r=JSON.parse(n);if(r.type)return r}catch(r){console.error(`Failed to parse "${e}" annotation:`,r)}}return null}function Jh(e){const n=e.match(/^#\s*label\s*=\s*"([^"]+)"/);return n?n[1]:null}function ef(e){const n=new Map;let r="";for(const o of e)if(o.type==="code"){if(!r&&o.text){const l=o.text.split(`
|
|
4
4
|
`).map(a=>a.trim()).find(a=>a.startsWith("import "))?.match(/['"]([^'"\n]+)['"]/);l&&(r=l[1])}if(o.newSources&&o.newSources.length>0)for(const i of o.newSources)try{const l=JSON.parse(i);l.name&&n.set(l.name,l)}catch(l){console.error("Failed to parse SourceInfo:",l)}}return{sourceInfoMap:n,modelPath:r}}function tf(e,n,r){const o=[];for(const{source:i,dimension:l}of n){const a=e.get(i);if(!a){console.warn(`Source "${i}" not found in notebook sources`),o.push({source:i,model:r,dimensionName:l,filterType:"Star"});continue}const d=a.schema?.fields;if(!d){o.push({source:i,model:r,dimensionName:l,filterType:"Star"});continue}const u=d.find(b=>b.name===l);if(!u){console.warn(`Dimension "${l}" not found in source "${i}"`),o.push({source:i,model:r,dimensionName:l,filterType:"Star"});continue}let h="Star",y;if("annotations"in u&&u.annotations){for(const b of u.annotations)if(b.value){const x=rl(b.value);x&&(h=x.type);const v=Jh(b.value);v&&(y=v)}}o.push({source:i,model:r,dimensionName:l,filterType:h,label:y})}return o}function nf(e,n,r){return e.length===0?"":e.map(i=>{const{dimensionName:l,source:a}=i,u=a&&a!==r?`\`${a}\`.\`${l}\``:`\`${l}\``;return is(u,i)}).filter(i=>i.length>0).join(" and ")}function rf(e){const n=e.match(/run\s*:\s*(\w+)\s*->/);if(n)return n[1];const r=e.match(/^\s*(\w+)\s*->/m);return r?r[1]:null}function sf(e,n){return`${e.trimEnd()} + {where: ${n}}`}const of=c.createSvgIcon(t.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"})),sl=e=>{if(!e)return"Explore semantic models, run queries, and build reports";const n=e.replace(/^#+\s+/gm,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/`([^`]+)`/g,"$1").trim(),o=n.split(/\n\s*\n/)[1]||n;if(o.length<=120)return o;const i=o.substring(0,120).split(" ");return i.pop(),i.join(" ")+"..."},ol=(e,n)=>{const r=(e.readme||void 0)?.split(`
|
|
5
5
|
`)??[];return r.length===0&&(r.push(`# ${e.name}`),r.push("")),(e.readme?.length??0)>0&&n?r.splice(2,1,n):n&&r.push(n),r.join(`
|
|
6
6
|
`)};function Vi(){const[e,n]=j.useState(!1),{apiClients:r}=q.useServer(),o=()=>{n(!0)},i=()=>{n(!1)},l=_n({mutationFn(d){return r.environments.createEnvironment({name:d.name,readme:ol({name:d.name,readme:""},d.description)})},success:"Environment created",invalidates:[["environments"]],closeDialog:i,resource:"environment",action:"create"}),a=async d=>{d.preventDefault();const u=new FormData(d.currentTarget),h=u.get("name")?.toString(),y=u.get("description")?.toString();if(!h)throw new Error("Name is required");l.mutate({name:h,description:y})};return t.jsxs(j.Fragment,{children:[t.jsx(c.AddButton,{label:"Environment",onClick:o}),t.jsx(c.AppDialog,{open:e,onClose:i,title:"New environment",description:"An environment holds packages and the connections they query through.",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{disabled:l.isPending,onClick:i,children:"Cancel"}),t.jsx(c.Button,{type:"submit",form:"environment-form",variant:"contained",loading:l.isPending,children:"Create environment"})]}),children:t.jsx("form",{onSubmit:a,id:"environment-form",children:t.jsxs(os,{sx:{gap:2},children:[t.jsx(c.TextField,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Name",type:"text",fullWidth:!0,size:"small",InputLabelProps:{shrink:!0}}),t.jsx(c.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}})]})})}),l.notice]})}function af({environment:e,onCloseDialog:n}){const[r,o]=j.useState(!1),{apiClients:i}=q.useServer(),l=()=>{o(!0)},a=()=>{o(!1),n()},d=_n({mutationFn:()=>i.environments.deleteEnvironment(e.name),success:"Environment deleted",invalidates:[["environments"]],closeDialog:a,resource:"environment",action:"delete"});return t.jsxs(j.Fragment,{children:[t.jsxs(p.MenuItem,{onClick:l,children:[t.jsx(p.ListItemIcon,{children:t.jsx(Pt.Delete,{fontSize:"small"})}),t.jsx(p.ListItemText,{children:"Delete"})]}),t.jsx(c.AppDialog,{open:r,onClose:a,title:"Delete environment",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{onClick:a,children:"Cancel"}),t.jsx(c.Button,{variant:"contained",color:"error",autoFocus:!0,onClick:()=>d.mutate(),loading:d.isPending,children:"Delete environment"})]}),children:t.jsxs(c.Typography,{variant:"body2",children:["Delete ",t.jsx("strong",{children:e.name}),"? Its packages stop being served and this cannot be undone."]})}),d.notice]})}function lf({environment:e,onCloseDialog:n}){const[r,o]=j.useState(!1),{apiClients:i}=q.useServer(),l=()=>{o(!0)},a=()=>{o(!1),n()},d=_n({mutationFn(h){return i.environments.updateEnvironment(e.name,{name:e.name,readme:ol({name:e.name,readme:e.readme},h.description)})},success:"Environment updated",invalidates:[["environments"]],closeDialog:a,resource:"environment",action:"update"}),u=h=>{h.preventDefault();const b=new FormData(h.currentTarget).get("description")?.toString();d.mutate({description:b})};return t.jsxs(j.Fragment,{children:[t.jsxs(p.MenuItem,{onClick:l,children:[t.jsx(p.ListItemIcon,{children:t.jsx(Pt.Edit,{fontSize:"small"})}),t.jsx(p.ListItemText,{children:"Edit"})]}),t.jsx(c.AppDialog,{open:r,onClose:a,title:"Edit environment",description:"What this environment is, for the people who open it.",actions:t.jsxs(t.Fragment,{children:[t.jsx(c.Button,{disabled:d.isPending,onClick:a,children:"Cancel"}),t.jsx(c.Button,{type:"submit",form:"environment-form",variant:"contained",loading:d.isPending,children:"Save changes"})]}),children:t.jsx("form",{onSubmit:u,id:"environment-form",children:t.jsxs(os,{sx:{gap:2},children:[t.jsx(c.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}}),t.jsx(c.TextField,{id:"description",name:"description",label:"Description",type:"text",fullWidth:!0,size:"small",defaultValue:sl(e.readme),InputLabelProps:{shrink:!0}})]})})}),d.notice]})}const cf=[{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:Vt.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:Vt.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:Vt.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:Vt.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:Vt.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:Vt.connections}];function uf({href:e,children:n}){return t.jsx(p.Box,{component:"a",href:e,target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary",textDecoration:"underline"},children:n})}function df({onClickEnvironment:e}){const{apiClients:n,mutable:r}=q.useServer(),{data:o,isSuccess:i,isError:l,error:a}=c.useQueryWithApiError({queryKey:["environments"],queryFn:()=>n.environments.listEnvironments()});if(l)return t.jsx(c.ApiErrorDisplay,{error:a,context:"Environments List"});if(!i)return t.jsx(c.Loading,{text:"Loading environments..."});const d=o.data??[];return t.jsxs(p.Container,{maxWidth:"md",sx:{py:6},children:[t.jsxs(p.Box,{sx:{mb:5},children:[t.jsx(p.Typography,{variant:"h3",component:"h1",sx:{fontWeight:500,letterSpacing:"-0.025em",mb:1},children:"Publisher"}),t.jsx(p.Typography,{variant:"body1",color:"text.secondary",sx:{mb:3},children:"The analytics engine for Malloy."}),t.jsx(p.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."})]}),t.jsx(p.Grid,{container:!0,spacing:4,sx:{mb:5},children:cf.map(u=>t.jsx(p.Grid,{size:{xs:12,sm:6},children:t.jsxs(p.Stack,{spacing:1,children:[t.jsx(p.Typography,{variant:"body2",component:"a",href:u.href,target:"_blank",rel:"noopener noreferrer",sx:{fontWeight:500,color:"text.primary",textDecoration:"none","&:hover":{textDecoration:"underline"}},children:u.title}),t.jsx(p.Typography,{variant:"body2",color:"text.secondary",sx:{lineHeight:1.6},children:u.body})]})},u.title))}),t.jsx(p.Divider,{sx:{my:4}}),d.length>0?t.jsx(_t,{title:"Environments",count:d.length,description:"Published environments available on this server",...r?{action:t.jsx(Vi,{})}:{},children:t.jsx(p.Stack,{children:d.map(u=>t.jsx(hf,{environment:u,...e?{onClickEnvironment:e}:{}},u.name))})}):t.jsxs(p.Box,{sx:{mb:4},children:[t.jsx(p.Typography,{variant:"h5",sx:{fontWeight:500,letterSpacing:"-0.025em",mb:1},children:"Get started"}),t.jsx(p.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."}),r?t.jsx(Vi,{}):t.jsx(p.Button,{variant:"contained",color:"primary",href:Vt.publishing,target:"_blank",rel:"noopener noreferrer",children:"Learn how to create models"})]}),t.jsx(p.Divider,{sx:{my:4}}),t.jsxs(p.Typography,{variant:"body2",color:"text.secondary",sx:{maxWidth:720,lineHeight:1.6,mt:2},children:["Join the"," ",t.jsx(uf,{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 hf({environment:e,onClickEnvironment:n}){const{mutable:r}=q.useServer(),[o,i]=j.useState(null),l=!!o,a=sl(e.readme),d=h=>{h.stopPropagation(),i(h.currentTarget)},u=()=>i(null);return t.jsx(ss,{icon:t.jsx(of,{sx:{fontSize:18}}),tint:q.SURFACE_TINT.environment,label:e.name??"",ariaLabel:e.name??"",...a?{description:a}:{},...e.name&&n?{onClick:h=>n(`/${e.name}/`,h)}:{},...r?{trailingAction:t.jsxs(t.Fragment,{children:[t.jsx(p.IconButton,{size:"small",onClick:d,"aria-label":`Environment actions for ${e.name}`,children:t.jsx(Pt.MoreVert,{fontSize:"small"})}),t.jsxs(p.Menu,{anchorEl:o,open:l,onClose:u,onClick:h=>h.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[t.jsx(lf,{environment:e,onCloseDialog:u}),t.jsx(af,{environment:e,onCloseDialog:u})]})]})}:{}})}var an={},jt={},tr={},ln={},Es={},Hi;function ff(){return Hi||(Hi=1,Object.defineProperty(Es,"__esModule",{value:!0})),Es}var nr={},rr={},Ui;function mn(){if(Ui)return rr;Ui=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.CronField=void 0;let e=class il{#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(r,o={rawValue:""}){if(!Array.isArray(r))throw new Error(`${this.constructor.name} Validation error, values is not an array`);if(!(r.length>0))throw new Error(`${this.constructor.name} Validation error, values contains no values`);this.options={...o,rawValue:o.rawValue??""},this.#s=r.sort(il.sorter),this.#o=this.options.wildcard!==void 0?this.options.wildcard:this.#r(),this.#e=this.options.rawValue.includes("L")||r.includes("L"),this.#n=this.options.rawValue.includes("?")||r.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(r,o){const i=typeof r=="number",l=typeof o=="number";return i&&l?r-o:!i&&!l?r.localeCompare(o):i?-1:1}static findNearestValueInList(r,o,i){if(i){for(let l=r.length-1;l>=0;l--)if(r[l]<o)return r[l];return null}for(let l=0;l<r.length;l++)if(r[l]>o)return r[l];return null}findNearestValue(r,o){return this.constructor.findNearestValueInList(this.values,r,o)}serialize(){return{wildcard:this.#o,values:this.#s}}validate(){let r;const o=this.chars.length>0?` or chars ${this.chars.join("")}`:"",i=u=>h=>new RegExp(`^\\d{0,2}${h}$`).test(u),l=u=>(r=u,typeof u=="number"?u>=this.min&&u<=this.max:this.chars.some(i(u)));if(!this.#s.every(l))throw new Error(`${this.constructor.name} Validation error, got value ${r} expected range ${this.min}-${this.max}${o}`);const d=this.#s.find((u,h)=>this.#s.indexOf(u)!==h);if(d)throw new Error(`${this.constructor.name} Validation error, duplicate values found: ${d}`)}#r(){return this.options.rawValue.length>0?["*","?"].includes(this.options.rawValue):Array.from({length:this.max-this.min+1},(r,o)=>o+this.min).every(r=>this.#s.includes(r))}};return rr.CronField=e,rr}var Gi;function mf(){if(Gi)return nr;Gi=1,Object.defineProperty(nr,"__esModule",{value:!0}),nr.CronDayOfMonth=void 0;const e=mn(),n=1,r=31,o=Object.freeze(["L"]);let i=class extends e.CronField{static get min(){return n}static get max(){return r}static get chars(){return o}static get validChars(){return/^[?,*\dLH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(a,d){super(a,d),this.validate()}get values(){return super.values}};return nr.CronDayOfMonth=i,nr}var sr={},Yi;function pf(){if(Yi)return sr;Yi=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.CronDayOfWeek=void 0;const e=mn(),n=0,r=7,o=Object.freeze(["L"]);let i=class extends e.CronField{static get min(){return n}static get max(){return r}static get chars(){return o}static get validChars(){return/^[?,*\dLH#/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/}constructor(a,d){super(a,d),this.validate()}get values(){return super.values}get nthDay(){return this.options.nthDayOfWeek??0}};return sr.CronDayOfWeek=i,sr}var or={},Ki;function gf(){if(Ki)return or;Ki=1,Object.defineProperty(or,"__esModule",{value:!0}),or.CronHour=void 0;const e=mn(),n=0,r=23,o=Object.freeze([]);let i=class extends e.CronField{static get min(){return n}static get max(){return r}static get chars(){return o}constructor(a,d){super(a,d),this.validate()}get values(){return super.values}};return or.CronHour=i,or}var ir={},Qi;function yf(){if(Qi)return ir;Qi=1,Object.defineProperty(ir,"__esModule",{value:!0}),ir.CronMinute=void 0;const e=mn(),n=0,r=59,o=Object.freeze([]);let i=class extends e.CronField{static get min(){return n}static get max(){return r}static get chars(){return o}constructor(a,d){super(a,d),this.validate()}get values(){return super.values}};return ir.CronMinute=i,ir}var ar={},Is={},wt={},Zi;function xf(){if(Zi)return wt;Zi=1,Object.defineProperty(wt,"__esModule",{value:!0});class e extends Error{}class n extends e{constructor(s){super(`Invalid DateTime: ${s.toMessage()}`)}}class r extends e{constructor(s){super(`Invalid Interval: ${s.toMessage()}`)}}class o extends e{constructor(s){super(`Invalid Duration: ${s.toMessage()}`)}}class i extends e{}class l extends e{constructor(s){super(`Invalid unit ${s}`)}}class a extends e{}class d extends e{constructor(){super("Zone is an abstract class")}}const u="numeric",h="short",y="long",b={year:u,month:u,day:u},x={year:u,month:h,day:u},v={year:u,month:h,day:u,weekday:h},k={year:u,month:y,day:u},C={year:u,month:y,day:u,weekday:y},S={hour:u,minute:u},T={hour:u,minute:u,second:u},O={hour:u,minute:u,second:u,timeZoneName:h},M={hour:u,minute:u,second:u,timeZoneName:y},E={hour:u,minute:u,hourCycle:"h23"},R={hour:u,minute:u,second:u,hourCycle:"h23"},P={hour:u,minute:u,second:u,hourCycle:"h23",timeZoneName:h},A={hour:u,minute:u,second:u,hourCycle:"h23",timeZoneName:y},H={year:u,month:u,day:u,hour:u,minute:u},D={year:u,month:u,day:u,hour:u,minute:u,second:u},L={year:u,month:h,day:u,hour:u,minute:u},U={year:u,month:h,day:u,hour:u,minute:u,second:u},$={year:u,month:h,day:u,weekday:h,hour:u,minute:u},W={year:u,month:y,day:u,hour:u,minute:u,timeZoneName:h},Q={year:u,month:y,day:u,hour:u,minute:u,second:u,timeZoneName:h},te={year:u,month:y,day:u,weekday:y,hour:u,minute:u,timeZoneName:y},ee={year:u,month:y,day:u,weekday:y,hour:u,minute:u,second:u,timeZoneName:y};class G{get type(){throw new d}get name(){throw new d}get ianaName(){return this.name}get isUniversal(){throw new d}offsetName(s,f){throw new d}formatOffset(s,f){throw new d}offset(s){throw new d}equals(s){throw new d}get isValid(){throw new d}}let Z=null;class ae extends G{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(s,{format:f,locale:g}){return Fo(s,f,g)}formatOffset(s,f){return Vn(this.offset(s),f)}offset(s){return-new Date(s).getTimezoneOffset()}equals(s){return s.type==="system"}get isValid(){return!0}}const z=new Map;function re(m){let s=z.get(m);return s===void 0&&(s=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:m,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),z.set(m,s)),s}const se={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function ne(m,s){const f=m.format(s).replace(/\u200E/g,""),g=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(f),[,w,I,F,N,_,X,xe]=g;return[F,w,I,N,_,X,xe]}function Ie(m,s){const f=m.formatToParts(s),g=[];for(let w=0;w<f.length;w++){const{type:I,value:F}=f[w],N=se[I];I==="era"?g[N]=F:J(N)||(g[N]=parseInt(F,10))}return g}const de=new Map;class pe extends G{static create(s){let f=de.get(s);return f===void 0&&de.set(s,f=new pe(s)),f}static resetCache(){de.clear(),z.clear()}static isValidSpecifier(s){return this.isValidZone(s)}static isValidZone(s){if(!s)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:s}).format(),!0}catch{return!1}}constructor(s){super(),this.zoneName=s,this.valid=pe.isValidZone(s)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(s,{format:f,locale:g}){return Fo(s,f,g,this.name)}formatOffset(s,f){return Vn(this.offset(s),f)}offset(s){if(!this.valid)return NaN;const f=new Date(s);if(isNaN(f))return NaN;const g=re(this.name);let[w,I,F,N,_,X,xe]=g.formatToParts?Ie(g,f):ne(g,f);N==="BC"&&(w=-Math.abs(w)+1);const He=Ar({year:w,month:I,day:F,hour:_===24?0:_,minute:X,second:xe,millisecond:0});let we=+f;const it=we%1e3;return we-=it>=0?it:1e3+it,(He-we)/(60*1e3)}equals(s){return s.type==="iana"&&s.name===this.name}get isValid(){return this.valid}}let De={};function Le(m,s={}){const f=JSON.stringify([m,s]);let g=De[f];return g||(g=new Intl.ListFormat(m,s),De[f]=g),g}const oe=new Map;function K(m,s={}){const f=JSON.stringify([m,s]);let g=oe.get(f);return g===void 0&&(g=new Intl.DateTimeFormat(m,s),oe.set(f,g)),g}const le=new Map;function be(m,s={}){const f=JSON.stringify([m,s]);let g=le.get(f);return g===void 0&&(g=new Intl.NumberFormat(m,s),le.set(f,g)),g}const ge=new Map;function ue(m,s={}){const{base:f,...g}=s,w=JSON.stringify([m,g]);let I=ge.get(w);return I===void 0&&(I=new Intl.RelativeTimeFormat(m,s),ge.set(w,I)),I}let ye=null;function $e(){return ye||(ye=new Intl.DateTimeFormat().resolvedOptions().locale,ye)}const ze=new Map;function me(m){let s=ze.get(m);return s===void 0&&(s=new Intl.DateTimeFormat(m).resolvedOptions(),ze.set(m,s)),s}const Y=new Map;function ie(m){let s=Y.get(m);if(!s){const f=new Intl.Locale(m);s="getWeekInfo"in f?f.getWeekInfo():f.weekInfo,"minimalDays"in s||(s={...Ke,...s}),Y.set(m,s)}return s}function Oe(m){const s=m.indexOf("-x-");s!==-1&&(m=m.substring(0,s));const f=m.indexOf("-u-");if(f===-1)return[m];{let g,w;try{g=K(m).resolvedOptions(),w=m}catch{const _=m.substring(0,f);g=K(_).resolvedOptions(),w=_}const{numberingSystem:I,calendar:F}=g;return[w,I,F]}}function Fe(m,s,f){return(f||s)&&(m.includes("-u-")||(m+="-u"),f&&(m+=`-ca-${f}`),s&&(m+=`-nu-${s}`)),m}function at(m){const s=[];for(let f=1;f<=12;f++){const g=Se.utc(2009,f,1);s.push(m(g))}return s}function Me(m){const s=[];for(let f=1;f<=7;f++){const g=Se.utc(2016,11,13+f);s.push(m(g))}return s}function lt(m,s,f,g){const w=m.listingMode();return w==="error"?null:w==="en"?f(s):g(s)}function xt(m){return m.numberingSystem&&m.numberingSystem!=="latn"?!1:m.numberingSystem==="latn"||!m.locale||m.locale.startsWith("en")||me(m.locale).numberingSystem==="latn"}class vt{constructor(s,f,g){this.padTo=g.padTo||0,this.floor=g.floor||!1;const{padTo:w,floor:I,...F}=g;if(!f||Object.keys(F).length>0){const N={useGrouping:!1,...g};g.padTo>0&&(N.minimumIntegerDigits=g.padTo),this.inf=be(s,N)}}format(s){if(this.inf){const f=this.floor?Math.floor(s):s;return this.inf.format(f)}else{const f=this.floor?Math.floor(s):ms(s,3);return ot(f,this.padTo)}}}class Ot{constructor(s,f,g){this.opts=g,this.originalZone=void 0;let w;if(this.opts.timeZone)this.dt=s;else if(s.zone.type==="fixed"){const F=-1*(s.offset/60),N=F>=0?`Etc/GMT+${F}`:`Etc/GMT${F}`;s.offset!==0&&pe.create(N).valid?(w=N,this.dt=s):(w="UTC",this.dt=s.offset===0?s:s.setZone("UTC").plus({minutes:s.offset}),this.originalZone=s.zone)}else s.zone.type==="system"?this.dt=s:s.zone.type==="iana"?(this.dt=s,w=s.zone.name):(w="UTC",this.dt=s.setZone("UTC").plus({minutes:s.offset}),this.originalZone=s.zone);const I={...this.opts};I.timeZone=I.timeZone||w,this.dtf=K(f,I)}format(){return this.originalZone?this.formatToParts().map(({value:s})=>s).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const s=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?s.map(f=>{if(f.type==="timeZoneName"){const g=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...f,value:g}}else return f}):s}resolvedOptions(){return this.dtf.resolvedOptions()}}class pt{constructor(s,f,g){this.opts={style:"long",...g},!f&&zn()&&(this.rtf=ue(s,g))}format(s,f){return this.rtf?this.rtf.format(s,f):Ac(f,s,this.opts.numeric,this.opts.style!=="long")}formatToParts(s,f){return this.rtf?this.rtf.formatToParts(s,f):[]}}const Ke={firstDay:1,minimalDays:4,weekend:[6,7]};class he{static fromOpts(s){return he.create(s.locale,s.numberingSystem,s.outputCalendar,s.weekSettings,s.defaultToEN)}static create(s,f,g,w,I=!1){const F=s||Pe.defaultLocale,N=F||(I?"en-US":$e()),_=f||Pe.defaultNumberingSystem,X=g||Pe.defaultOutputCalendar,xe=qt(w)||Pe.defaultWeekSettings;return new he(N,_,X,xe,F)}static resetCache(){ye=null,oe.clear(),le.clear(),ge.clear(),ze.clear(),Y.clear()}static fromObject({locale:s,numberingSystem:f,outputCalendar:g,weekSettings:w}={}){return he.create(s,f,g,w)}constructor(s,f,g,w,I){const[F,N,_]=Oe(s);this.locale=F,this.numberingSystem=f||N||null,this.outputCalendar=g||_||null,this.weekSettings=w,this.intl=Fe(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=I,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=xt(this)),this.fastNumbersCached}listingMode(){const s=this.isEnglish(),f=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return s&&f?"en":"intl"}clone(s){return!s||Object.getOwnPropertyNames(s).length===0?this:he.create(s.locale||this.specifiedLocale,s.numberingSystem||this.numberingSystem,s.outputCalendar||this.outputCalendar,qt(s.weekSettings)||this.weekSettings,s.defaultToEN||!1)}redefaultToEN(s={}){return this.clone({...s,defaultToEN:!0})}redefaultToSystem(s={}){return this.clone({...s,defaultToEN:!1})}months(s,f=!1){return lt(this,s,Lo,()=>{const g=this.intl==="ja"||this.intl.startsWith("ja-");f&=!g;const w=f?{month:s,day:"numeric"}:{month:s},I=f?"format":"standalone";if(!this.monthsCache[I][s]){const F=g?N=>this.dtFormatter(N,w).format():N=>this.extract(N,w,"month");this.monthsCache[I][s]=at(F)}return this.monthsCache[I][s]})}weekdays(s,f=!1){return lt(this,s,zo,()=>{const g=f?{weekday:s,year:"numeric",month:"long",day:"numeric"}:{weekday:s},w=f?"format":"standalone";return this.weekdaysCache[w][s]||(this.weekdaysCache[w][s]=Me(I=>this.extract(I,g,"weekday"))),this.weekdaysCache[w][s]})}meridiems(){return lt(this,void 0,()=>Wo,()=>{if(!this.meridiemCache){const s={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[Se.utc(2016,11,13,9),Se.utc(2016,11,13,19)].map(f=>this.extract(f,s,"dayperiod"))}return this.meridiemCache})}eras(s){return lt(this,s,qo,()=>{const f={era:s};return this.eraCache[s]||(this.eraCache[s]=[Se.utc(-40,1,1),Se.utc(2017,1,1)].map(g=>this.extract(g,f,"era"))),this.eraCache[s]})}extract(s,f,g){const w=this.dtFormatter(s,f),I=w.formatToParts(),F=I.find(N=>N.type.toLowerCase()===g);return F?F.value:null}numberFormatter(s={}){return new vt(this.intl,s.forceSimple||this.fastNumbers,s)}dtFormatter(s,f={}){return new Ot(s,this.intl,f)}relFormatter(s={}){return new pt(this.intl,this.isEnglish(),s)}listFormatter(s={}){return Le(this.intl,s)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||me(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Wn()?ie(this.locale):Ke}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(s){return this.locale===s.locale&&this.numberingSystem===s.numberingSystem&&this.outputCalendar===s.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let Qe=null;class qe extends G{static get utcInstance(){return Qe===null&&(Qe=new qe(0)),Qe}static instance(s){return s===0?qe.utcInstance:new qe(s)}static parseSpecifier(s){if(s){const f=s.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(f)return new qe(Fr(f[1],f[2]))}return null}constructor(s){super(),this.fixed=s}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Vn(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Vn(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(s,f){return Vn(this.fixed,f)}get isUniversal(){return!0}offset(){return this.fixed}equals(s){return s.type==="fixed"&&s.fixed===this.fixed}get isValid(){return!0}}class ct extends G{constructor(s){super(),this.zoneName=s}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 ut(m,s){if(J(m)||m===null)return s;if(m instanceof G)return m;if(Ct(m)){const f=m.toLowerCase();return f==="default"?s:f==="local"||f==="system"?ae.instance:f==="utc"||f==="gmt"?qe.utcInstance:qe.parseSpecifier(f)||pe.create(m)}else return Ve(m)?qe.instance(m):typeof m=="object"&&"offset"in m&&typeof m.offset=="function"?m:new ct(m)}const Ze={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},fe={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]},Ue=Ze.hanidec.replace(/[\[|\]]/g,"").split("");function bt(m){let s=parseInt(m,10);if(isNaN(s)){s="";for(let f=0;f<m.length;f++){const g=m.charCodeAt(f);if(m[f].search(Ze.hanidec)!==-1)s+=Ue.indexOf(m[f]);else for(const w in fe){const[I,F]=fe[w];g>=I&&g<=F&&(s+=g-I)}}return parseInt(s,10)}else return s}const ke=new Map;function Ne(){ke.clear()}function Ee({numberingSystem:m},s=""){const f=m||"latn";let g=ke.get(f);g===void 0&&(g=new Map,ke.set(f,g));let w=g.get(s);return w===void 0&&(w=new RegExp(`${Ze[f]}${s}`),g.set(s,w)),w}let Be=()=>Date.now(),ht="system",We=null,nt=null,Mt=null,kt=60,At,gn=null;class Pe{static get now(){return Be}static set now(s){Be=s}static set defaultZone(s){ht=s}static get defaultZone(){return ut(ht,ae.instance)}static get defaultLocale(){return We}static set defaultLocale(s){We=s}static get defaultNumberingSystem(){return nt}static set defaultNumberingSystem(s){nt=s}static get defaultOutputCalendar(){return Mt}static set defaultOutputCalendar(s){Mt=s}static get defaultWeekSettings(){return gn}static set defaultWeekSettings(s){gn=qt(s)}static get twoDigitCutoffYear(){return kt}static set twoDigitCutoffYear(s){kt=s%100}static get throwOnInvalid(){return At}static set throwOnInvalid(s){At=s}static resetCaches(){he.resetCache(),pe.resetCache(),Se.resetCache(),Ne()}}class dt{constructor(s,f){this.reason=s,this.explanation=f}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const Kt=[0,31,59,90,120,151,181,212,243,273,304,334],yn=[0,31,60,91,121,152,182,213,244,274,305,335];function ft(m,s){return new dt("unit out of range",`you specified ${s} (of type ${typeof s}) as a ${m}, which is invalid`)}function en(m,s,f){const g=new Date(Date.UTC(m,s-1,f));m<100&&m>=0&&g.setUTCFullYear(g.getUTCFullYear()-1900);const w=g.getUTCDay();return w===0?7:w}function xn(m,s,f){return f+(qn(m)?yn:Kt)[s-1]}function Qt(m,s){const f=qn(m)?yn:Kt,g=f.findIndex(I=>I<s),w=s-f[g];return{month:g+1,day:w}}function Xe(m,s){return(m-s+7)%7+1}function Je(m,s=4,f=1){const{year:g,month:w,day:I}=m,F=xn(g,w,I),N=Xe(en(g,w,I),f);let _=Math.floor((F-N+14-s)/7),X;return _<1?(X=g-1,_=Bn(X,s,f)):_>Bn(g,s,f)?(X=g+1,_=1):X=g,{weekYear:X,weekNumber:_,weekday:N,...Nr(m)}}function Ft(m,s=4,f=1){const{weekYear:g,weekNumber:w,weekday:I}=m,F=Xe(en(g,1,s),f),N=bn(g);let _=w*7+I-F-7+s,X;_<1?(X=g-1,_+=bn(X)):_>N?(X=g+1,_-=bn(g)):X=g;const{month:xe,day:je}=Qt(X,_);return{year:X,month:xe,day:je,...Nr(m)}}function tn(m){const{year:s,month:f,day:g}=m,w=xn(s,f,g);return{year:s,ordinal:w,...Nr(m)}}function Zt(m){const{year:s,ordinal:f}=m,{month:g,day:w}=Qt(s,f);return{year:s,month:g,day:w,...Nr(m)}}function nn(m,s){if(!J(m.localWeekday)||!J(m.localWeekNumber)||!J(m.localWeekYear)){if(!J(m.weekday)||!J(m.weekNumber)||!J(m.weekYear))throw new i("Cannot mix locale-based week fields with ISO-based week fields");return J(m.localWeekday)||(m.weekday=m.localWeekday),J(m.localWeekNumber)||(m.weekNumber=m.localWeekNumber),J(m.localWeekYear)||(m.weekYear=m.localWeekYear),delete m.localWeekday,delete m.localWeekNumber,delete m.localWeekYear,{minDaysInFirstWeek:s.getMinDaysInFirstWeek(),startOfWeek:s.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function V(m,s=4,f=1){const g=Ge(m.weekYear),w=Et(m.weekNumber,1,Bn(m.weekYear,s,f)),I=Et(m.weekday,1,7);return g?w?I?!1:ft("weekday",m.weekday):ft("week",m.weekNumber):ft("weekYear",m.weekYear)}function B(m){const s=Ge(m.year),f=Et(m.ordinal,1,bn(m.year));return s?f?!1:ft("ordinal",m.ordinal):ft("year",m.year)}function ce(m){const s=Ge(m.year),f=Et(m.month,1,12),g=Et(m.day,1,$r(m.year,m.month));return s?f?g?!1:ft("day",m.day):ft("month",m.month):ft("year",m.year)}function ve(m){const{hour:s,minute:f,second:g,millisecond:w}=m,I=Et(s,0,23)||s===24&&f===0&&g===0&&w===0,F=Et(f,0,59),N=Et(g,0,59),_=Et(w,0,999);return I?F?N?_?!1:ft("millisecond",w):ft("second",g):ft("minute",f):ft("hour",s)}function J(m){return typeof m>"u"}function Ve(m){return typeof m=="number"}function Ge(m){return typeof m=="number"&&m%1===0}function Ct(m){return typeof m=="string"}function vn(m){return Object.prototype.toString.call(m)==="[object Date]"}function zn(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Wn(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function Dr(m){return Array.isArray(m)?m:[m]}function Ae(m,s,f){if(m.length!==0)return m.reduce((g,w)=>{const I=[s(w),w];return g&&f(g[0],I[0])===g[0]?g:I},null)[1]}function zt(m,s){return s.reduce((f,g)=>(f[g]=m[g],f),{})}function gt(m,s){return Object.prototype.hasOwnProperty.call(m,s)}function qt(m){if(m==null)return null;if(typeof m!="object")throw new a("Week settings must be an object");if(!Et(m.firstDay,1,7)||!Et(m.minimalDays,1,7)||!Array.isArray(m.weekend)||m.weekend.some(s=>!Et(s,1,7)))throw new a("Invalid week settings");return{firstDay:m.firstDay,minimalDays:m.minimalDays,weekend:Array.from(m.weekend)}}function Et(m,s,f){return Ge(m)&&m>=s&&m<=f}function Sc(m,s){return m-s*Math.floor(m/s)}function ot(m,s=2){const f=m<0;let g;return f?g="-"+(""+-m).padStart(s,"0"):g=(""+m).padStart(s,"0"),g}function Xt(m){if(!(J(m)||m===null||m===""))return parseInt(m,10)}function rn(m){if(!(J(m)||m===null||m===""))return parseFloat(m)}function fs(m){if(!(J(m)||m===null||m==="")){const s=parseFloat("0."+m)*1e3;return Math.floor(s)}}function ms(m,s,f="round"){const g=10**s;switch(f){case"expand":return m>0?Math.ceil(m*g)/g:Math.floor(m*g)/g;case"trunc":return Math.trunc(m*g)/g;case"round":return Math.round(m*g)/g;case"floor":return Math.floor(m*g)/g;case"ceil":return Math.ceil(m*g)/g;default:throw new RangeError(`Value rounding ${f} is out of range`)}}function qn(m){return m%4===0&&(m%100!==0||m%400===0)}function bn(m){return qn(m)?366:365}function $r(m,s){const f=Sc(s-1,12)+1,g=m+(s-f)/12;return f===2?qn(g)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][f-1]}function Ar(m){let s=Date.UTC(m.year,m.month-1,m.day,m.hour,m.minute,m.second,m.millisecond);return m.year<100&&m.year>=0&&(s=new Date(s),s.setUTCFullYear(m.year,m.month-1,m.day)),+s}function Ao(m,s,f){return-Xe(en(m,1,s),f)+s-1}function Bn(m,s=4,f=1){const g=Ao(m,s,f),w=Ao(m+1,s,f);return(bn(m)-g+w)/7}function ps(m){return m>99?m:m>Pe.twoDigitCutoffYear?1900+m:2e3+m}function Fo(m,s,f,g=null){const w=new Date(m),I={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};g&&(I.timeZone=g);const F={timeZoneName:s,...I},N=new Intl.DateTimeFormat(f,F).formatToParts(w).find(_=>_.type.toLowerCase()==="timezonename");return N?N.value:null}function Fr(m,s){let f=parseInt(m,10);Number.isNaN(f)&&(f=0);const g=parseInt(s,10)||0,w=f<0||Object.is(f,-0)?-g:g;return f*60+w}function Ro(m){const s=Number(m);if(typeof m=="boolean"||m===""||!Number.isFinite(s))throw new a(`Invalid unit value ${m}`);return s}function Rr(m,s){const f={};for(const g in m)if(gt(m,g)){const w=m[g];if(w==null)continue;f[s(g)]=Ro(w)}return f}function Vn(m,s){const f=Math.trunc(Math.abs(m/60)),g=Math.trunc(Math.abs(m%60)),w=m>=0?"+":"-";switch(s){case"short":return`${w}${ot(f,2)}:${ot(g,2)}`;case"narrow":return`${w}${f}${g>0?`:${g}`:""}`;case"techie":return`${w}${ot(f,2)}${ot(g,2)}`;default:throw new RangeError(`Value format ${s} is out of range for property format`)}}function Nr(m){return zt(m,["hour","minute","second","millisecond"])}const kc=["January","February","March","April","May","June","July","August","September","October","November","December"],No=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Cc=["J","F","M","A","M","J","J","A","S","O","N","D"];function Lo(m){switch(m){case"narrow":return[...Cc];case"short":return[...No];case"long":return[...kc];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 _o=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Po=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],jc=["M","T","W","T","F","S","S"];function zo(m){switch(m){case"narrow":return[...jc];case"short":return[...Po];case"long":return[..._o];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Wo=["AM","PM"],Tc=["Before Christ","Anno Domini"],Oc=["BC","AD"],Mc=["B","A"];function qo(m){switch(m){case"narrow":return[...Mc];case"short":return[...Oc];case"long":return[...Tc];default:return null}}function Ec(m){return Wo[m.hour<12?0:1]}function Ic(m,s){return zo(s)[m.weekday-1]}function Dc(m,s){return Lo(s)[m.month-1]}function $c(m,s){return qo(s)[m.year<0?0:1]}function Ac(m,s,f="always",g=!1){const w={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."]},I=["hours","minutes","seconds"].indexOf(m)===-1;if(f==="auto"&&I){const je=m==="days";switch(s){case 1:return je?"tomorrow":`next ${w[m][0]}`;case-1:return je?"yesterday":`last ${w[m][0]}`;case 0:return je?"today":`this ${w[m][0]}`}}const F=Object.is(s,-0)||s<0,N=Math.abs(s),_=N===1,X=w[m],xe=g?_?X[1]:X[2]||X[1]:_?w[m][0]:m;return F?`${N} ${xe} ago`:`in ${N} ${xe}`}function Bo(m,s){let f="";for(const g of m)g.literal?f+=g.val:f+=s(g.val);return f}const Fc={D:b,DD:x,DDD:k,DDDD:C,t:S,tt:T,ttt:O,tttt:M,T:E,TT:R,TTT:P,TTTT:A,f:H,ff:L,fff:W,ffff:te,F:D,FF:U,FFF:Q,FFFF:ee};class mt{static create(s,f={}){return new mt(s,f)}static parseFormat(s){let f=null,g="",w=!1;const I=[];for(let F=0;F<s.length;F++){const N=s.charAt(F);N==="'"?((g.length>0||w)&&I.push({literal:w||/^\s+$/.test(g),val:g===""?"'":g}),f=null,g="",w=!w):w||N===f?g+=N:(g.length>0&&I.push({literal:/^\s+$/.test(g),val:g}),g=N,f=N)}return g.length>0&&I.push({literal:w||/^\s+$/.test(g),val:g}),I}static macroTokenToFormatOpts(s){return Fc[s]}constructor(s,f){this.opts=f,this.loc=s,this.systemLoc=null}formatWithSystemDefault(s,f){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(s,{...this.opts,...f}).format()}dtFormatter(s,f={}){return this.loc.dtFormatter(s,{...this.opts,...f})}formatDateTime(s,f){return this.dtFormatter(s,f).format()}formatDateTimeParts(s,f){return this.dtFormatter(s,f).formatToParts()}formatInterval(s,f){return this.dtFormatter(s.start,f).dtf.formatRange(s.start.toJSDate(),s.end.toJSDate())}resolvedOptions(s,f){return this.dtFormatter(s,f).resolvedOptions()}num(s,f=0,g=void 0){if(this.opts.forceSimple)return ot(s,f);const w={...this.opts};return f>0&&(w.padTo=f),g&&(w.signDisplay=g),this.loc.numberFormatter(w).format(s)}formatDateTimeFromString(s,f){const g=this.loc.listingMode()==="en",w=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",I=(we,it)=>this.loc.extract(s,we,it),F=we=>s.isOffsetFixed&&s.offset===0&&we.allowZ?"Z":s.isValid?s.zone.formatOffset(s.ts,we.format):"",N=()=>g?Ec(s):I({hour:"numeric",hourCycle:"h12"},"dayperiod"),_=(we,it)=>g?Dc(s,we):I(it?{month:we}:{month:we,day:"numeric"},"month"),X=(we,it)=>g?Ic(s,we):I(it?{weekday:we}:{weekday:we,month:"long",day:"numeric"},"weekday"),xe=we=>{const it=mt.macroTokenToFormatOpts(we);return it?this.formatWithSystemDefault(s,it):we},je=we=>g?$c(s,we):I({era:we},"era"),He=we=>{switch(we){case"S":return this.num(s.millisecond);case"u":case"SSS":return this.num(s.millisecond,3);case"s":return this.num(s.second);case"ss":return this.num(s.second,2);case"uu":return this.num(Math.floor(s.millisecond/10),2);case"uuu":return this.num(Math.floor(s.millisecond/100));case"m":return this.num(s.minute);case"mm":return this.num(s.minute,2);case"h":return this.num(s.hour%12===0?12:s.hour%12);case"hh":return this.num(s.hour%12===0?12:s.hour%12,2);case"H":return this.num(s.hour);case"HH":return this.num(s.hour,2);case"Z":return F({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return F({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return F({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return s.zone.offsetName(s.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return s.zone.offsetName(s.ts,{format:"long",locale:this.loc.locale});case"z":return s.zoneName;case"a":return N();case"d":return w?I({day:"numeric"},"day"):this.num(s.day);case"dd":return w?I({day:"2-digit"},"day"):this.num(s.day,2);case"c":return this.num(s.weekday);case"ccc":return X("short",!0);case"cccc":return X("long",!0);case"ccccc":return X("narrow",!0);case"E":return this.num(s.weekday);case"EEE":return X("short",!1);case"EEEE":return X("long",!1);case"EEEEE":return X("narrow",!1);case"L":return w?I({month:"numeric",day:"numeric"},"month"):this.num(s.month);case"LL":return w?I({month:"2-digit",day:"numeric"},"month"):this.num(s.month,2);case"LLL":return _("short",!0);case"LLLL":return _("long",!0);case"LLLLL":return _("narrow",!0);case"M":return w?I({month:"numeric"},"month"):this.num(s.month);case"MM":return w?I({month:"2-digit"},"month"):this.num(s.month,2);case"MMM":return _("short",!1);case"MMMM":return _("long",!1);case"MMMMM":return _("narrow",!1);case"y":return w?I({year:"numeric"},"year"):this.num(s.year);case"yy":return w?I({year:"2-digit"},"year"):this.num(s.year.toString().slice(-2),2);case"yyyy":return w?I({year:"numeric"},"year"):this.num(s.year,4);case"yyyyyy":return w?I({year:"numeric"},"year"):this.num(s.year,6);case"G":return je("short");case"GG":return je("long");case"GGGGG":return je("narrow");case"kk":return this.num(s.weekYear.toString().slice(-2),2);case"kkkk":return this.num(s.weekYear,4);case"W":return this.num(s.weekNumber);case"WW":return this.num(s.weekNumber,2);case"n":return this.num(s.localWeekNumber);case"nn":return this.num(s.localWeekNumber,2);case"ii":return this.num(s.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(s.localWeekYear,4);case"o":return this.num(s.ordinal);case"ooo":return this.num(s.ordinal,3);case"q":return this.num(s.quarter);case"qq":return this.num(s.quarter,2);case"X":return this.num(Math.floor(s.ts/1e3));case"x":return this.num(s.ts);default:return xe(we)}};return Bo(mt.parseFormat(f),He)}formatDurationFromString(s,f){const g=this.opts.signMode==="negativeLargestOnly"?-1:1,w=xe=>{switch(xe[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}},I=(xe,je)=>He=>{const we=w(He);if(we){const it=je.isNegativeDuration&&we!==je.largestUnit?g:1;let Nt;return this.opts.signMode==="negativeLargestOnly"&&we!==je.largestUnit?Nt="never":this.opts.signMode==="all"?Nt="always":Nt="auto",this.num(xe.get(we)*it,He.length,Nt)}else return He},F=mt.parseFormat(f),N=F.reduce((xe,{literal:je,val:He})=>je?xe:xe.concat(He),[]),_=s.shiftTo(...N.map(w).filter(xe=>xe)),X={isNegativeDuration:_<0,largestUnit:Object.keys(_.values)[0]};return Bo(F,I(_,X))}}const Vo=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function wn(...m){const s=m.reduce((f,g)=>f+g.source,"");return RegExp(`^${s}$`)}function Sn(...m){return s=>m.reduce(([f,g,w],I)=>{const[F,N,_]=I(s,w);return[{...f,...F},N||g,_]},[{},null,1]).slice(0,2)}function kn(m,...s){if(m==null)return[null,null];for(const[f,g]of s){const w=f.exec(m);if(w)return g(w)}return[null,null]}function Ho(...m){return(s,f)=>{const g={};let w;for(w=0;w<m.length;w++)g[m[w]]=Xt(s[f+w]);return[g,null,f+w]}}const Uo=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Rc=`(?:${Uo.source}?(?:\\[(${Vo.source})\\])?)?`,gs=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Go=RegExp(`${gs.source}${Rc}`),ys=RegExp(`(?:[Tt]${Go.source})?`),Nc=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Lc=/(\d{4})-?W(\d\d)(?:-?(\d))?/,_c=/(\d{4})-?(\d{3})/,Pc=Ho("weekYear","weekNumber","weekDay"),zc=Ho("year","ordinal"),Wc=/(\d{4})-(\d\d)-(\d\d)/,Yo=RegExp(`${gs.source} ?(?:${Uo.source}|(${Vo.source}))?`),qc=RegExp(`(?: ${Yo.source})?`);function Cn(m,s,f){const g=m[s];return J(g)?f:Xt(g)}function Bc(m,s){return[{year:Cn(m,s),month:Cn(m,s+1,1),day:Cn(m,s+2,1)},null,s+3]}function jn(m,s){return[{hours:Cn(m,s,0),minutes:Cn(m,s+1,0),seconds:Cn(m,s+2,0),milliseconds:fs(m[s+3])},null,s+4]}function Hn(m,s){const f=!m[s]&&!m[s+1],g=Fr(m[s+1],m[s+2]),w=f?null:qe.instance(g);return[{},w,s+3]}function Un(m,s){const f=m[s]?pe.create(m[s]):null;return[{},f,s+1]}const Vc=RegExp(`^T?${gs.source}$`),Hc=/^-?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 Uc(m){const[s,f,g,w,I,F,N,_,X]=m,xe=s[0]==="-",je=_&&_[0]==="-",He=(we,it=!1)=>we!==void 0&&(it||we&&xe)?-we:we;return[{years:He(rn(f)),months:He(rn(g)),weeks:He(rn(w)),days:He(rn(I)),hours:He(rn(F)),minutes:He(rn(N)),seconds:He(rn(_),_==="-0"),milliseconds:He(fs(X),je)}]}const Gc={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function xs(m,s,f,g,w,I,F){const N={year:s.length===2?ps(Xt(s)):Xt(s),month:No.indexOf(f)+1,day:Xt(g),hour:Xt(w),minute:Xt(I)};return F&&(N.second=Xt(F)),m&&(N.weekday=m.length>3?_o.indexOf(m)+1:Po.indexOf(m)+1),N}const Yc=/^(?:(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 Kc(m){const[,s,f,g,w,I,F,N,_,X,xe,je]=m,He=xs(s,w,g,f,I,F,N);let we;return _?we=Gc[_]:X?we=0:we=Fr(xe,je),[He,new qe(we)]}function Qc(m){return m.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const Zc=/^(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$/,Xc=/^(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$/,Jc=/^(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 Ko(m){const[,s,f,g,w,I,F,N]=m;return[xs(s,w,g,f,I,F,N),qe.utcInstance]}function eu(m){const[,s,f,g,w,I,F,N]=m;return[xs(s,N,f,g,w,I,F),qe.utcInstance]}const tu=wn(Nc,ys),nu=wn(Lc,ys),ru=wn(_c,ys),su=wn(Go),Qo=Sn(Bc,jn,Hn,Un),ou=Sn(Pc,jn,Hn,Un),iu=Sn(zc,jn,Hn,Un),au=Sn(jn,Hn,Un);function lu(m){return kn(m,[tu,Qo],[nu,ou],[ru,iu],[su,au])}function cu(m){return kn(Qc(m),[Yc,Kc])}function uu(m){return kn(m,[Zc,Ko],[Xc,Ko],[Jc,eu])}function du(m){return kn(m,[Hc,Uc])}const hu=Sn(jn);function fu(m){return kn(m,[Vc,hu])}const mu=wn(Wc,qc),pu=wn(Yo),gu=Sn(jn,Hn,Un);function yu(m){return kn(m,[mu,Qo],[pu,gu])}const Zo="Invalid Duration",Xo={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}},xu={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},...Xo},It=146097/400,Tn=146097/4800,vu={years:{quarters:4,months:12,weeks:It/7,days:It,hours:It*24,minutes:It*24*60,seconds:It*24*60*60,milliseconds:It*24*60*60*1e3},quarters:{months:3,weeks:It/28,days:It/4,hours:It*24/4,minutes:It*24*60/4,seconds:It*24*60*60/4,milliseconds:It*24*60*60*1e3/4},months:{weeks:Tn/7,days:Tn,hours:Tn*24,minutes:Tn*24*60,seconds:Tn*24*60*60,milliseconds:Tn*24*60*60*1e3},...Xo},sn=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],bu=sn.slice(0).reverse();function Bt(m,s,f=!1){const g={values:f?s.values:{...m.values,...s.values||{}},loc:m.loc.clone(s.loc),conversionAccuracy:s.conversionAccuracy||m.conversionAccuracy,matrix:s.matrix||m.matrix};return new Re(g)}function Jo(m,s){var f;let g=(f=s.milliseconds)!=null?f:0;for(const w of bu.slice(1))s[w]&&(g+=s[w]*m[w].milliseconds);return g}function ei(m,s){const f=Jo(m,s)<0?-1:1;sn.reduceRight((g,w)=>{if(J(s[w]))return g;if(g){const I=s[g]*f,F=m[w][g],N=Math.floor(I/F);s[w]+=N*f,s[g]-=N*F*f}return w},null),sn.reduce((g,w)=>{if(J(s[w]))return g;if(g){const I=s[g]%1;s[g]-=I,s[w]+=I*m[g][w]}return w},null)}function ti(m){const s={};for(const[f,g]of Object.entries(m))g!==0&&(s[f]=g);return s}class Re{constructor(s){const f=s.conversionAccuracy==="longterm"||!1;let g=f?vu:xu;s.matrix&&(g=s.matrix),this.values=s.values,this.loc=s.loc||he.create(),this.conversionAccuracy=f?"longterm":"casual",this.invalid=s.invalid||null,this.matrix=g,this.isLuxonDuration=!0}static fromMillis(s,f){return Re.fromObject({milliseconds:s},f)}static fromObject(s,f={}){if(s==null||typeof s!="object")throw new a(`Duration.fromObject: argument expected to be an object, got ${s===null?"null":typeof s}`);return new Re({values:Rr(s,Re.normalizeUnit),loc:he.fromObject(f),conversionAccuracy:f.conversionAccuracy,matrix:f.matrix})}static fromDurationLike(s){if(Ve(s))return Re.fromMillis(s);if(Re.isDuration(s))return s;if(typeof s=="object")return Re.fromObject(s);throw new a(`Unknown duration argument ${s} of type ${typeof s}`)}static fromISO(s,f){const[g]=du(s);return g?Re.fromObject(g,f):Re.invalid("unparsable",`the input "${s}" can't be parsed as ISO 8601`)}static fromISOTime(s,f){const[g]=fu(s);return g?Re.fromObject(g,f):Re.invalid("unparsable",`the input "${s}" can't be parsed as ISO 8601`)}static invalid(s,f=null){if(!s)throw new a("need to specify a reason the Duration is invalid");const g=s instanceof dt?s:new dt(s,f);if(Pe.throwOnInvalid)throw new o(g);return new Re({invalid:g})}static normalizeUnit(s){const f={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"}[s&&s.toLowerCase()];if(!f)throw new l(s);return f}static isDuration(s){return s&&s.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(s,f={}){const g={...f,floor:f.round!==!1&&f.floor!==!1};return this.isValid?mt.create(this.loc,g).formatDurationFromString(this,s):Zo}toHuman(s={}){if(!this.isValid)return Zo;const f=s.showZeros!==!1,g=sn.map(w=>{const I=this.values[w];return J(I)||I===0&&!f?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...s,unit:w.slice(0,-1)}).format(I)}).filter(w=>w);return this.loc.listFormatter({type:"conjunction",style:s.listStyle||"narrow",...s}).format(g)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let s="P";return this.years!==0&&(s+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(s+=this.months+this.quarters*3+"M"),this.weeks!==0&&(s+=this.weeks+"W"),this.days!==0&&(s+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(s+="T"),this.hours!==0&&(s+=this.hours+"H"),this.minutes!==0&&(s+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(s+=ms(this.seconds+this.milliseconds/1e3,3)+"S"),s==="P"&&(s+="T0S"),s}toISOTime(s={}){if(!this.isValid)return null;const f=this.toMillis();return f<0||f>=864e5?null:(s={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...s,includeOffset:!1},Se.fromMillis(f,{zone:"UTC"}).toISOTime(s))}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?Jo(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(s){if(!this.isValid)return this;const f=Re.fromDurationLike(s),g={};for(const w of sn)(gt(f.values,w)||gt(this.values,w))&&(g[w]=f.get(w)+this.get(w));return Bt(this,{values:g},!0)}minus(s){if(!this.isValid)return this;const f=Re.fromDurationLike(s);return this.plus(f.negate())}mapUnits(s){if(!this.isValid)return this;const f={};for(const g of Object.keys(this.values))f[g]=Ro(s(this.values[g],g));return Bt(this,{values:f},!0)}get(s){return this[Re.normalizeUnit(s)]}set(s){if(!this.isValid)return this;const f={...this.values,...Rr(s,Re.normalizeUnit)};return Bt(this,{values:f})}reconfigure({locale:s,numberingSystem:f,conversionAccuracy:g,matrix:w}={}){const F={loc:this.loc.clone({locale:s,numberingSystem:f}),matrix:w,conversionAccuracy:g};return Bt(this,F)}as(s){return this.isValid?this.shiftTo(s).get(s):NaN}normalize(){if(!this.isValid)return this;const s=this.toObject();return ei(this.matrix,s),Bt(this,{values:s},!0)}rescale(){if(!this.isValid)return this;const s=ti(this.normalize().shiftToAll().toObject());return Bt(this,{values:s},!0)}shiftTo(...s){if(!this.isValid)return this;if(s.length===0)return this;s=s.map(F=>Re.normalizeUnit(F));const f={},g={},w=this.toObject();let I;for(const F of sn)if(s.indexOf(F)>=0){I=F;let N=0;for(const X in g)N+=this.matrix[X][F]*g[X],g[X]=0;Ve(w[F])&&(N+=w[F]);const _=Math.trunc(N);f[F]=_,g[F]=(N*1e3-_*1e3)/1e3}else Ve(w[F])&&(g[F]=w[F]);for(const F in g)g[F]!==0&&(f[I]+=F===I?g[F]:g[F]/this.matrix[I][F]);return ei(this.matrix,f),Bt(this,{values:f},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const s={};for(const f of Object.keys(this.values))s[f]=this.values[f]===0?0:-this.values[f];return Bt(this,{values:s},!0)}removeZeros(){if(!this.isValid)return this;const s=ti(this.values);return Bt(this,{values:s},!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(s){if(!this.isValid||!s.isValid||!this.loc.equals(s.loc))return!1;function f(g,w){return g===void 0||g===0?w===void 0||w===0:g===w}for(const g of sn)if(!f(this.values[g],s.values[g]))return!1;return!0}}const On="Invalid Interval";function wu(m,s){return!m||!m.isValid?et.invalid("missing or invalid start"):!s||!s.isValid?et.invalid("missing or invalid end"):s<m?et.invalid("end before start",`The end of an interval must be after its start, but you had start=${m.toISO()} and end=${s.toISO()}`):null}class et{constructor(s){this.s=s.start,this.e=s.end,this.invalid=s.invalid||null,this.isLuxonInterval=!0}static invalid(s,f=null){if(!s)throw new a("need to specify a reason the Interval is invalid");const g=s instanceof dt?s:new dt(s,f);if(Pe.throwOnInvalid)throw new r(g);return new et({invalid:g})}static fromDateTimes(s,f){const g=Qn(s),w=Qn(f),I=wu(g,w);return I??new et({start:g,end:w})}static after(s,f){const g=Re.fromDurationLike(f),w=Qn(s);return et.fromDateTimes(w,w.plus(g))}static before(s,f){const g=Re.fromDurationLike(f),w=Qn(s);return et.fromDateTimes(w.minus(g),w)}static fromISO(s,f){const[g,w]=(s||"").split("/",2);if(g&&w){let I,F;try{I=Se.fromISO(g,f),F=I.isValid}catch{F=!1}let N,_;try{N=Se.fromISO(w,f),_=N.isValid}catch{_=!1}if(F&&_)return et.fromDateTimes(I,N);if(F){const X=Re.fromISO(w,f);if(X.isValid)return et.after(I,X)}else if(_){const X=Re.fromISO(g,f);if(X.isValid)return et.before(N,X)}}return et.invalid("unparsable",`the input "${s}" can't be parsed as ISO 8601`)}static isInterval(s){return s&&s.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(s="milliseconds"){return this.isValid?this.toDuration(s).get(s):NaN}count(s="milliseconds",f){if(!this.isValid)return NaN;const g=this.start.startOf(s,f);let w;return f!=null&&f.useLocaleWeeks?w=this.end.reconfigure({locale:g.locale}):w=this.end,w=w.startOf(s,f),Math.floor(w.diff(g,s).get(s))+(w.valueOf()!==this.end.valueOf())}hasSame(s){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,s):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(s){return this.isValid?this.s>s:!1}isBefore(s){return this.isValid?this.e<=s:!1}contains(s){return this.isValid?this.s<=s&&this.e>s:!1}set({start:s,end:f}={}){return this.isValid?et.fromDateTimes(s||this.s,f||this.e):this}splitAt(...s){if(!this.isValid)return[];const f=s.map(Qn).filter(F=>this.contains(F)).sort((F,N)=>F.toMillis()-N.toMillis()),g=[];let{s:w}=this,I=0;for(;w<this.e;){const F=f[I]||this.e,N=+F>+this.e?this.e:F;g.push(et.fromDateTimes(w,N)),w=N,I+=1}return g}splitBy(s){const f=Re.fromDurationLike(s);if(!this.isValid||!f.isValid||f.as("milliseconds")===0)return[];let{s:g}=this,w=1,I;const F=[];for(;g<this.e;){const N=this.start.plus(f.mapUnits(_=>_*w));I=+N>+this.e?this.e:N,F.push(et.fromDateTimes(g,I)),g=I,w+=1}return F}divideEqually(s){return this.isValid?this.splitBy(this.length()/s).slice(0,s):[]}overlaps(s){return this.e>s.s&&this.s<s.e}abutsStart(s){return this.isValid?+this.e==+s.s:!1}abutsEnd(s){return this.isValid?+s.e==+this.s:!1}engulfs(s){return this.isValid?this.s<=s.s&&this.e>=s.e:!1}equals(s){return!this.isValid||!s.isValid?!1:this.s.equals(s.s)&&this.e.equals(s.e)}intersection(s){if(!this.isValid)return this;const f=this.s>s.s?this.s:s.s,g=this.e<s.e?this.e:s.e;return f>=g?null:et.fromDateTimes(f,g)}union(s){if(!this.isValid)return this;const f=this.s<s.s?this.s:s.s,g=this.e>s.e?this.e:s.e;return et.fromDateTimes(f,g)}static merge(s){const[f,g]=s.sort((w,I)=>w.s-I.s).reduce(([w,I],F)=>I?I.overlaps(F)||I.abutsStart(F)?[w,I.union(F)]:[w.concat([I]),F]:[w,F],[[],null]);return g&&f.push(g),f}static xor(s){let f=null,g=0;const w=[],I=s.map(_=>[{time:_.s,type:"s"},{time:_.e,type:"e"}]),F=Array.prototype.concat(...I),N=F.sort((_,X)=>_.time-X.time);for(const _ of N)g+=_.type==="s"?1:-1,g===1?f=_.time:(f&&+f!=+_.time&&w.push(et.fromDateTimes(f,_.time)),f=null);return et.merge(w)}difference(...s){return et.xor([this].concat(s)).map(f=>this.intersection(f)).filter(f=>f&&!f.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:On}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(s=b,f={}){return this.isValid?mt.create(this.s.loc.clone(f),s).formatInterval(this):On}toISO(s){return this.isValid?`${this.s.toISO(s)}/${this.e.toISO(s)}`:On}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:On}toISOTime(s){return this.isValid?`${this.s.toISOTime(s)}/${this.e.toISOTime(s)}`:On}toFormat(s,{separator:f=" – "}={}){return this.isValid?`${this.s.toFormat(s)}${f}${this.e.toFormat(s)}`:On}toDuration(s,f){return this.isValid?this.e.diff(this.s,s,f):Re.invalid(this.invalidReason)}mapEndpoints(s){return et.fromDateTimes(s(this.s),s(this.e))}}class Gn{static hasDST(s=Pe.defaultZone){const f=Se.now().setZone(s).set({month:12});return!s.isUniversal&&f.offset!==f.set({month:6}).offset}static isValidIANAZone(s){return pe.isValidZone(s)}static normalizeZone(s){return ut(s,Pe.defaultZone)}static getStartOfWeek({locale:s=null,locObj:f=null}={}){return(f||he.create(s)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:s=null,locObj:f=null}={}){return(f||he.create(s)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:s=null,locObj:f=null}={}){return(f||he.create(s)).getWeekendDays().slice()}static months(s="long",{locale:f=null,numberingSystem:g=null,locObj:w=null,outputCalendar:I="gregory"}={}){return(w||he.create(f,g,I)).months(s)}static monthsFormat(s="long",{locale:f=null,numberingSystem:g=null,locObj:w=null,outputCalendar:I="gregory"}={}){return(w||he.create(f,g,I)).months(s,!0)}static weekdays(s="long",{locale:f=null,numberingSystem:g=null,locObj:w=null}={}){return(w||he.create(f,g,null)).weekdays(s)}static weekdaysFormat(s="long",{locale:f=null,numberingSystem:g=null,locObj:w=null}={}){return(w||he.create(f,g,null)).weekdays(s,!0)}static meridiems({locale:s=null}={}){return he.create(s).meridiems()}static eras(s="short",{locale:f=null}={}){return he.create(f,null,"gregory").eras(s)}static features(){return{relative:zn(),localeWeek:Wn()}}}function ni(m,s){const f=w=>w.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),g=f(s)-f(m);return Math.floor(Re.fromMillis(g).as("days"))}function Su(m,s,f){const g=[["years",(_,X)=>X.year-_.year],["quarters",(_,X)=>X.quarter-_.quarter+(X.year-_.year)*4],["months",(_,X)=>X.month-_.month+(X.year-_.year)*12],["weeks",(_,X)=>{const xe=ni(_,X);return(xe-xe%7)/7}],["days",ni]],w={},I=m;let F,N;for(const[_,X]of g)f.indexOf(_)>=0&&(F=_,w[_]=X(m,s),N=I.plus(w),N>s?(w[_]--,m=I.plus(w),m>s&&(N=m,w[_]--,m=I.plus(w))):m=N);return[m,w,N,F]}function ku(m,s,f,g){let[w,I,F,N]=Su(m,s,f);const _=s-w,X=f.filter(je=>["hours","minutes","seconds","milliseconds"].indexOf(je)>=0);X.length===0&&(F<s&&(F=w.plus({[N]:1})),F!==w&&(I[N]=(I[N]||0)+_/(F-w)));const xe=Re.fromObject(I,g);return X.length>0?Re.fromMillis(_,g).shiftTo(...X).plus(xe):xe}const Cu="missing Intl.DateTimeFormat.formatToParts support";function _e(m,s=f=>f){return{regex:m,deser:([f])=>s(bt(f))}}const ri="[ ]",si=new RegExp(ri,"g");function ju(m){return m.replace(/\./g,"\\.?").replace(si,ri)}function oi(m){return m.replace(/\./g,"").replace(si," ").toLowerCase()}function Rt(m,s){return m===null?null:{regex:RegExp(m.map(ju).join("|")),deser:([f])=>m.findIndex(g=>oi(f)===oi(g))+s}}function ii(m,s){return{regex:m,deser:([,f,g])=>Fr(f,g),groups:s}}function Lr(m){return{regex:m,deser:([s])=>s}}function Tu(m){return m.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Ou(m,s){const f=Ee(s),g=Ee(s,"{2}"),w=Ee(s,"{3}"),I=Ee(s,"{4}"),F=Ee(s,"{6}"),N=Ee(s,"{1,2}"),_=Ee(s,"{1,3}"),X=Ee(s,"{1,6}"),xe=Ee(s,"{1,9}"),je=Ee(s,"{2,4}"),He=Ee(s,"{4,6}"),we=Wt=>({regex:RegExp(Tu(Wt.val)),deser:([En])=>En,literal:!0}),Nt=(Wt=>{if(m.literal)return we(Wt);switch(Wt.val){case"G":return Rt(s.eras("short"),0);case"GG":return Rt(s.eras("long"),0);case"y":return _e(X);case"yy":return _e(je,ps);case"yyyy":return _e(I);case"yyyyy":return _e(He);case"yyyyyy":return _e(F);case"M":return _e(N);case"MM":return _e(g);case"MMM":return Rt(s.months("short",!0),1);case"MMMM":return Rt(s.months("long",!0),1);case"L":return _e(N);case"LL":return _e(g);case"LLL":return Rt(s.months("short",!1),1);case"LLLL":return Rt(s.months("long",!1),1);case"d":return _e(N);case"dd":return _e(g);case"o":return _e(_);case"ooo":return _e(w);case"HH":return _e(g);case"H":return _e(N);case"hh":return _e(g);case"h":return _e(N);case"mm":return _e(g);case"m":return _e(N);case"q":return _e(N);case"qq":return _e(g);case"s":return _e(N);case"ss":return _e(g);case"S":return _e(_);case"SSS":return _e(w);case"u":return Lr(xe);case"uu":return Lr(N);case"uuu":return _e(f);case"a":return Rt(s.meridiems(),0);case"kkkk":return _e(I);case"kk":return _e(je,ps);case"W":return _e(N);case"WW":return _e(g);case"E":case"c":return _e(f);case"EEE":return Rt(s.weekdays("short",!1),1);case"EEEE":return Rt(s.weekdays("long",!1),1);case"ccc":return Rt(s.weekdays("short",!0),1);case"cccc":return Rt(s.weekdays("long",!0),1);case"Z":case"ZZ":return ii(new RegExp(`([+-]${N.source})(?::(${g.source}))?`),2);case"ZZZ":return ii(new RegExp(`([+-]${N.source})(${g.source})?`),2);case"z":return Lr(/[a-z_+-/]{1,256}?/i);case" ":return Lr(/[^\S\n\r]/);default:return we(Wt)}})(m)||{invalidReason:Cu};return Nt.token=m,Nt}const Mu={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 Eu(m,s,f){const{type:g,value:w}=m;if(g==="literal"){const _=/^\s+$/.test(w);return{literal:!_,val:_?" ":w}}const I=s[g];let F=g;g==="hour"&&(s.hour12!=null?F=s.hour12?"hour12":"hour24":s.hourCycle!=null?s.hourCycle==="h11"||s.hourCycle==="h12"?F="hour12":F="hour24":F=f.hour12?"hour12":"hour24");let N=Mu[F];if(typeof N=="object"&&(N=N[I]),N)return{literal:!1,val:N}}function Iu(m){return[`^${m.map(f=>f.regex).reduce((f,g)=>`${f}(${g.source})`,"")}$`,m]}function Du(m,s,f){const g=m.match(s);if(g){const w={};let I=1;for(const F in f)if(gt(f,F)){const N=f[F],_=N.groups?N.groups+1:1;!N.literal&&N.token&&(w[N.token.val[0]]=N.deser(g.slice(I,I+_))),I+=_}return[g,w]}else return[g,{}]}function $u(m){const s=I=>{switch(I){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 f=null,g;return J(m.z)||(f=pe.create(m.z)),J(m.Z)||(f||(f=new qe(m.Z)),g=m.Z),J(m.q)||(m.M=(m.q-1)*3+1),J(m.h)||(m.h<12&&m.a===1?m.h+=12:m.h===12&&m.a===0&&(m.h=0)),m.G===0&&m.y&&(m.y=-m.y),J(m.u)||(m.S=fs(m.u)),[Object.keys(m).reduce((I,F)=>{const N=s(F);return N&&(I[N]=m[F]),I},{}),f,g]}let vs=null;function Au(){return vs||(vs=Se.fromMillis(1555555555555)),vs}function Fu(m,s){if(m.literal)return m;const f=mt.macroTokenToFormatOpts(m.val),g=ui(f,s);return g==null||g.includes(void 0)?m:g}function ai(m,s){return Array.prototype.concat(...m.map(f=>Fu(f,s)))}class li{constructor(s,f){if(this.locale=s,this.format=f,this.tokens=ai(mt.parseFormat(f),s),this.units=this.tokens.map(g=>Ou(g,s)),this.disqualifyingUnit=this.units.find(g=>g.invalidReason),!this.disqualifyingUnit){const[g,w]=Iu(this.units);this.regex=RegExp(g,"i"),this.handlers=w}}explainFromTokens(s){if(this.isValid){const[f,g]=Du(s,this.regex,this.handlers),[w,I,F]=g?$u(g):[null,null,void 0];if(gt(g,"a")&>(g,"H"))throw new i("Can't include meridiem when specifying 24-hour format");return{input:s,tokens:this.tokens,regex:this.regex,rawMatches:f,matches:g,result:w,zone:I,specificOffset:F}}else return{input:s,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function ci(m,s,f){return new li(m,f).explainFromTokens(s)}function Ru(m,s,f){const{result:g,zone:w,specificOffset:I,invalidReason:F}=ci(m,s,f);return[g,w,I,F]}function ui(m,s){if(!m)return null;const g=mt.create(s,m).dtFormatter(Au()),w=g.formatToParts(),I=g.resolvedOptions();return w.map(F=>Eu(F,m,I))}const bs="Invalid DateTime",di=864e13;function Yn(m){return new dt("unsupported zone",`the zone "${m.name}" is not supported`)}function ws(m){return m.weekData===null&&(m.weekData=Je(m.c)),m.weekData}function Ss(m){return m.localWeekData===null&&(m.localWeekData=Je(m.c,m.loc.getMinDaysInFirstWeek(),m.loc.getStartOfWeek())),m.localWeekData}function on(m,s){const f={ts:m.ts,zone:m.zone,c:m.c,o:m.o,loc:m.loc,invalid:m.invalid};return new Se({...f,...s,old:f})}function hi(m,s,f){let g=m-s*60*1e3;const w=f.offset(g);if(s===w)return[g,s];g-=(w-s)*60*1e3;const I=f.offset(g);return w===I?[g,w]:[m-Math.min(w,I)*60*1e3,Math.max(w,I)]}function _r(m,s){m+=s*60*1e3;const f=new Date(m);return{year:f.getUTCFullYear(),month:f.getUTCMonth()+1,day:f.getUTCDate(),hour:f.getUTCHours(),minute:f.getUTCMinutes(),second:f.getUTCSeconds(),millisecond:f.getUTCMilliseconds()}}function Pr(m,s,f){return hi(Ar(m),s,f)}function fi(m,s){const f=m.o,g=m.c.year+Math.trunc(s.years),w=m.c.month+Math.trunc(s.months)+Math.trunc(s.quarters)*3,I={...m.c,year:g,month:w,day:Math.min(m.c.day,$r(g,w))+Math.trunc(s.days)+Math.trunc(s.weeks)*7},F=Re.fromObject({years:s.years-Math.trunc(s.years),quarters:s.quarters-Math.trunc(s.quarters),months:s.months-Math.trunc(s.months),weeks:s.weeks-Math.trunc(s.weeks),days:s.days-Math.trunc(s.days),hours:s.hours,minutes:s.minutes,seconds:s.seconds,milliseconds:s.milliseconds}).as("milliseconds"),N=Ar(I);let[_,X]=hi(N,f,m.zone);return F!==0&&(_+=F,X=m.zone.offset(_)),{ts:_,o:X}}function Mn(m,s,f,g,w,I){const{setZone:F,zone:N}=f;if(m&&Object.keys(m).length!==0||s){const _=s||N,X=Se.fromObject(m,{...f,zone:_,specificOffset:I});return F?X:X.setZone(N)}else return Se.invalid(new dt("unparsable",`the input "${w}" can't be parsed as ${g}`))}function zr(m,s,f=!0){return m.isValid?mt.create(he.create("en-US"),{allowZ:f,forceSimple:!0}).formatDateTimeFromString(m,s):null}function ks(m,s,f){const g=m.c.year>9999||m.c.year<0;let w="";if(g&&m.c.year>=0&&(w+="+"),w+=ot(m.c.year,g?6:4),f==="year")return w;if(s){if(w+="-",w+=ot(m.c.month),f==="month")return w;w+="-"}else if(w+=ot(m.c.month),f==="month")return w;return w+=ot(m.c.day),w}function mi(m,s,f,g,w,I,F){let N=!f||m.c.millisecond!==0||m.c.second!==0,_="";switch(F){case"day":case"month":case"year":break;default:if(_+=ot(m.c.hour),F==="hour")break;if(s){if(_+=":",_+=ot(m.c.minute),F==="minute")break;N&&(_+=":",_+=ot(m.c.second))}else{if(_+=ot(m.c.minute),F==="minute")break;N&&(_+=ot(m.c.second))}if(F==="second")break;N&&(!g||m.c.millisecond!==0)&&(_+=".",_+=ot(m.c.millisecond,3))}return w&&(m.isOffsetFixed&&m.offset===0&&!I?_+="Z":m.o<0?(_+="-",_+=ot(Math.trunc(-m.o/60)),_+=":",_+=ot(Math.trunc(-m.o%60))):(_+="+",_+=ot(Math.trunc(m.o/60)),_+=":",_+=ot(Math.trunc(m.o%60)))),I&&(_+="["+m.zone.ianaName+"]"),_}const pi={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Nu={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Lu={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Wr=["year","month","day","hour","minute","second","millisecond"],_u=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Pu=["year","ordinal","hour","minute","second","millisecond"];function qr(m){const s={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"}[m.toLowerCase()];if(!s)throw new l(m);return s}function gi(m){switch(m.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return qr(m)}}function zu(m){if(Kn===void 0&&(Kn=Pe.now()),m.type!=="iana")return m.offset(Kn);const s=m.name;let f=Cs.get(s);return f===void 0&&(f=m.offset(Kn),Cs.set(s,f)),f}function yi(m,s){const f=ut(s.zone,Pe.defaultZone);if(!f.isValid)return Se.invalid(Yn(f));const g=he.fromObject(s);let w,I;if(J(m.year))w=Pe.now();else{for(const _ of Wr)J(m[_])&&(m[_]=pi[_]);const F=ce(m)||ve(m);if(F)return Se.invalid(F);const N=zu(f);[w,I]=Pr(m,N,f)}return new Se({ts:w,zone:f,loc:g,o:I})}function xi(m,s,f){const g=J(f.round)?!0:f.round,w=J(f.rounding)?"trunc":f.rounding,I=(N,_)=>(N=ms(N,g||f.calendary?0:2,f.calendary?"round":w),s.loc.clone(f).relFormatter(f).format(N,_)),F=N=>f.calendary?s.hasSame(m,N)?0:s.startOf(N).diff(m.startOf(N),N).get(N):s.diff(m,N).get(N);if(f.unit)return I(F(f.unit),f.unit);for(const N of f.units){const _=F(N);if(Math.abs(_)>=1)return I(_,N)}return I(m>s?-0:0,f.units[f.units.length-1])}function vi(m){let s={},f;return m.length>0&&typeof m[m.length-1]=="object"?(s=m[m.length-1],f=Array.from(m).slice(0,m.length-1)):f=Array.from(m),[s,f]}let Kn;const Cs=new Map;class Se{constructor(s){const f=s.zone||Pe.defaultZone;let g=s.invalid||(Number.isNaN(s.ts)?new dt("invalid input"):null)||(f.isValid?null:Yn(f));this.ts=J(s.ts)?Pe.now():s.ts;let w=null,I=null;if(!g)if(s.old&&s.old.ts===this.ts&&s.old.zone.equals(f))[w,I]=[s.old.c,s.old.o];else{const N=Ve(s.o)&&!s.old?s.o:f.offset(this.ts);w=_r(this.ts,N),g=Number.isNaN(w.year)?new dt("invalid input"):null,w=g?null:w,I=g?null:N}this._zone=f,this.loc=s.loc||he.create(),this.invalid=g,this.weekData=null,this.localWeekData=null,this.c=w,this.o=I,this.isLuxonDateTime=!0}static now(){return new Se({})}static local(){const[s,f]=vi(arguments),[g,w,I,F,N,_,X]=f;return yi({year:g,month:w,day:I,hour:F,minute:N,second:_,millisecond:X},s)}static utc(){const[s,f]=vi(arguments),[g,w,I,F,N,_,X]=f;return s.zone=qe.utcInstance,yi({year:g,month:w,day:I,hour:F,minute:N,second:_,millisecond:X},s)}static fromJSDate(s,f={}){const g=vn(s)?s.valueOf():NaN;if(Number.isNaN(g))return Se.invalid("invalid input");const w=ut(f.zone,Pe.defaultZone);return w.isValid?new Se({ts:g,zone:w,loc:he.fromObject(f)}):Se.invalid(Yn(w))}static fromMillis(s,f={}){if(Ve(s))return s<-di||s>di?Se.invalid("Timestamp out of range"):new Se({ts:s,zone:ut(f.zone,Pe.defaultZone),loc:he.fromObject(f)});throw new a(`fromMillis requires a numerical input, but received a ${typeof s} with value ${s}`)}static fromSeconds(s,f={}){if(Ve(s))return new Se({ts:s*1e3,zone:ut(f.zone,Pe.defaultZone),loc:he.fromObject(f)});throw new a("fromSeconds requires a numerical input")}static fromObject(s,f={}){s=s||{};const g=ut(f.zone,Pe.defaultZone);if(!g.isValid)return Se.invalid(Yn(g));const w=he.fromObject(f),I=Rr(s,gi),{minDaysInFirstWeek:F,startOfWeek:N}=nn(I,w),_=Pe.now(),X=J(f.specificOffset)?g.offset(_):f.specificOffset,xe=!J(I.ordinal),je=!J(I.year),He=!J(I.month)||!J(I.day),we=je||He,it=I.weekYear||I.weekNumber;if((we||xe)&&it)throw new i("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(He&&xe)throw new i("Can't mix ordinal dates with month/day");const Nt=it||I.weekday&&!we;let Wt,En,Zn=_r(_,X);Nt?(Wt=_u,En=Nu,Zn=Je(Zn,F,N)):xe?(Wt=Pu,En=Lu,Zn=tn(Zn)):(Wt=Wr,En=pi);let bi=!1;for(const Jn of Wt){const Uu=I[Jn];J(Uu)?bi?I[Jn]=En[Jn]:I[Jn]=Zn[Jn]:bi=!0}const qu=Nt?V(I,F,N):xe?B(I):ce(I),wi=qu||ve(I);if(wi)return Se.invalid(wi);const Bu=Nt?Ft(I,F,N):xe?Zt(I):I,[Vu,Hu]=Pr(Bu,X,g),Xn=new Se({ts:Vu,zone:g,o:Hu,loc:w});return I.weekday&&we&&s.weekday!==Xn.weekday?Se.invalid("mismatched weekday",`you can't specify both a weekday of ${I.weekday} and a date of ${Xn.toISO()}`):Xn.isValid?Xn:Se.invalid(Xn.invalid)}static fromISO(s,f={}){const[g,w]=lu(s);return Mn(g,w,f,"ISO 8601",s)}static fromRFC2822(s,f={}){const[g,w]=cu(s);return Mn(g,w,f,"RFC 2822",s)}static fromHTTP(s,f={}){const[g,w]=uu(s);return Mn(g,w,f,"HTTP",f)}static fromFormat(s,f,g={}){if(J(s)||J(f))throw new a("fromFormat requires an input string and a format");const{locale:w=null,numberingSystem:I=null}=g,F=he.fromOpts({locale:w,numberingSystem:I,defaultToEN:!0}),[N,_,X,xe]=Ru(F,s,f);return xe?Se.invalid(xe):Mn(N,_,g,`format ${f}`,s,X)}static fromString(s,f,g={}){return Se.fromFormat(s,f,g)}static fromSQL(s,f={}){const[g,w]=yu(s);return Mn(g,w,f,"SQL",s)}static invalid(s,f=null){if(!s)throw new a("need to specify a reason the DateTime is invalid");const g=s instanceof dt?s:new dt(s,f);if(Pe.throwOnInvalid)throw new n(g);return new Se({invalid:g})}static isDateTime(s){return s&&s.isLuxonDateTime||!1}static parseFormatForOpts(s,f={}){const g=ui(s,he.fromObject(f));return g?g.map(w=>w?w.val:null).join(""):null}static expandFormat(s,f={}){return ai(mt.parseFormat(s),he.fromObject(f)).map(w=>w.val).join("")}static resetCache(){Kn=void 0,Cs.clear()}get(s){return this[s]}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?ws(this).weekYear:NaN}get weekNumber(){return this.isValid?ws(this).weekNumber:NaN}get weekday(){return this.isValid?ws(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Ss(this).weekday:NaN}get localWeekNumber(){return this.isValid?Ss(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Ss(this).weekYear:NaN}get ordinal(){return this.isValid?tn(this.c).ordinal:NaN}get monthShort(){return this.isValid?Gn.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Gn.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Gn.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Gn.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 s=864e5,f=6e4,g=Ar(this.c),w=this.zone.offset(g-s),I=this.zone.offset(g+s),F=this.zone.offset(g-w*f),N=this.zone.offset(g-I*f);if(F===N)return[this];const _=g-F*f,X=g-N*f,xe=_r(_,F),je=_r(X,N);return xe.hour===je.hour&&xe.minute===je.minute&&xe.second===je.second&&xe.millisecond===je.millisecond?[on(this,{ts:_}),on(this,{ts:X})]:[this]}get isInLeapYear(){return qn(this.year)}get daysInMonth(){return $r(this.year,this.month)}get daysInYear(){return this.isValid?bn(this.year):NaN}get weeksInWeekYear(){return this.isValid?Bn(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Bn(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(s={}){const{locale:f,numberingSystem:g,calendar:w}=mt.create(this.loc.clone(s),s).resolvedOptions(this);return{locale:f,numberingSystem:g,outputCalendar:w}}toUTC(s=0,f={}){return this.setZone(qe.instance(s),f)}toLocal(){return this.setZone(Pe.defaultZone)}setZone(s,{keepLocalTime:f=!1,keepCalendarTime:g=!1}={}){if(s=ut(s,Pe.defaultZone),s.equals(this.zone))return this;if(s.isValid){let w=this.ts;if(f||g){const I=s.offset(this.ts),F=this.toObject();[w]=Pr(F,I,s)}return on(this,{ts:w,zone:s})}else return Se.invalid(Yn(s))}reconfigure({locale:s,numberingSystem:f,outputCalendar:g}={}){const w=this.loc.clone({locale:s,numberingSystem:f,outputCalendar:g});return on(this,{loc:w})}setLocale(s){return this.reconfigure({locale:s})}set(s){if(!this.isValid)return this;const f=Rr(s,gi),{minDaysInFirstWeek:g,startOfWeek:w}=nn(f,this.loc),I=!J(f.weekYear)||!J(f.weekNumber)||!J(f.weekday),F=!J(f.ordinal),N=!J(f.year),_=!J(f.month)||!J(f.day),X=N||_,xe=f.weekYear||f.weekNumber;if((X||F)&&xe)throw new i("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(_&&F)throw new i("Can't mix ordinal dates with month/day");let je;I?je=Ft({...Je(this.c,g,w),...f},g,w):J(f.ordinal)?(je={...this.toObject(),...f},J(f.day)&&(je.day=Math.min($r(je.year,je.month),je.day))):je=Zt({...tn(this.c),...f});const[He,we]=Pr(je,this.o,this.zone);return on(this,{ts:He,o:we})}plus(s){if(!this.isValid)return this;const f=Re.fromDurationLike(s);return on(this,fi(this,f))}minus(s){if(!this.isValid)return this;const f=Re.fromDurationLike(s).negate();return on(this,fi(this,f))}startOf(s,{useLocaleWeeks:f=!1}={}){if(!this.isValid)return this;const g={},w=Re.normalizeUnit(s);switch(w){case"years":g.month=1;case"quarters":case"months":g.day=1;case"weeks":case"days":g.hour=0;case"hours":g.minute=0;case"minutes":g.second=0;case"seconds":g.millisecond=0;break}if(w==="weeks")if(f){const I=this.loc.getStartOfWeek(),{weekday:F}=this;F<I&&(g.weekNumber=this.weekNumber-1),g.weekday=I}else g.weekday=1;if(w==="quarters"){const I=Math.ceil(this.month/3);g.month=(I-1)*3+1}return this.set(g)}endOf(s,f){return this.isValid?this.plus({[s]:1}).startOf(s,f).minus(1):this}toFormat(s,f={}){return this.isValid?mt.create(this.loc.redefaultToEN(f)).formatDateTimeFromString(this,s):bs}toLocaleString(s=b,f={}){return this.isValid?mt.create(this.loc.clone(f),s).formatDateTime(this):bs}toLocaleParts(s={}){return this.isValid?mt.create(this.loc.clone(s),s).formatDateTimeParts(this):[]}toISO({format:s="extended",suppressSeconds:f=!1,suppressMilliseconds:g=!1,includeOffset:w=!0,extendedZone:I=!1,precision:F="milliseconds"}={}){if(!this.isValid)return null;F=qr(F);const N=s==="extended";let _=ks(this,N,F);return Wr.indexOf(F)>=3&&(_+="T"),_+=mi(this,N,f,g,w,I,F),_}toISODate({format:s="extended",precision:f="day"}={}){return this.isValid?ks(this,s==="extended",qr(f)):null}toISOWeekDate(){return zr(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:s=!1,suppressSeconds:f=!1,includeOffset:g=!0,includePrefix:w=!1,extendedZone:I=!1,format:F="extended",precision:N="milliseconds"}={}){return this.isValid?(N=qr(N),(w&&Wr.indexOf(N)>=3?"T":"")+mi(this,F==="extended",f,s,g,I,N)):null}toRFC2822(){return zr(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return zr(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?ks(this,!0):null}toSQLTime({includeOffset:s=!0,includeZone:f=!1,includeOffsetSpace:g=!0}={}){let w="HH:mm:ss.SSS";return(f||s)&&(g&&(w+=" "),f?w+="z":s&&(w+="ZZ")),zr(this,w,!0)}toSQL(s={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(s)}`:null}toString(){return this.isValid?this.toISO():bs}[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(s={}){if(!this.isValid)return{};const f={...this.c};return s.includeConfig&&(f.outputCalendar=this.outputCalendar,f.numberingSystem=this.loc.numberingSystem,f.locale=this.loc.locale),f}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(s,f="milliseconds",g={}){if(!this.isValid||!s.isValid)return Re.invalid("created by diffing an invalid DateTime");const w={locale:this.locale,numberingSystem:this.numberingSystem,...g},I=Dr(f).map(Re.normalizeUnit),F=s.valueOf()>this.valueOf(),N=F?this:s,_=F?s:this,X=ku(N,_,I,w);return F?X.negate():X}diffNow(s="milliseconds",f={}){return this.diff(Se.now(),s,f)}until(s){return this.isValid?et.fromDateTimes(this,s):this}hasSame(s,f,g){if(!this.isValid)return!1;const w=s.valueOf(),I=this.setZone(s.zone,{keepLocalTime:!0});return I.startOf(f,g)<=w&&w<=I.endOf(f,g)}equals(s){return this.isValid&&s.isValid&&this.valueOf()===s.valueOf()&&this.zone.equals(s.zone)&&this.loc.equals(s.loc)}toRelative(s={}){if(!this.isValid)return null;const f=s.base||Se.fromObject({},{zone:this.zone}),g=s.padding?this<f?-s.padding:s.padding:0;let w=["years","months","days","hours","minutes","seconds"],I=s.unit;return Array.isArray(s.unit)&&(w=s.unit,I=void 0),xi(f,this.plus(g),{...s,numeric:"always",units:w,unit:I})}toRelativeCalendar(s={}){return this.isValid?xi(s.base||Se.fromObject({},{zone:this.zone}),this,{...s,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...s){if(!s.every(Se.isDateTime))throw new a("min requires all arguments be DateTimes");return Ae(s,f=>f.valueOf(),Math.min)}static max(...s){if(!s.every(Se.isDateTime))throw new a("max requires all arguments be DateTimes");return Ae(s,f=>f.valueOf(),Math.max)}static fromFormatExplain(s,f,g={}){const{locale:w=null,numberingSystem:I=null}=g,F=he.fromOpts({locale:w,numberingSystem:I,defaultToEN:!0});return ci(F,s,f)}static fromStringExplain(s,f,g={}){return Se.fromFormatExplain(s,f,g)}static buildFormatParser(s,f={}){const{locale:g=null,numberingSystem:w=null}=f,I=he.fromOpts({locale:g,numberingSystem:w,defaultToEN:!0});return new li(I,s)}static fromFormatParser(s,f,g={}){if(J(s)||J(f))throw new a("fromFormatParser requires an input string and a format parser");const{locale:w=null,numberingSystem:I=null}=g,F=he.fromOpts({locale:w,numberingSystem:I,defaultToEN:!0});if(!F.equals(f.locale))throw new a(`fromFormatParser called with a locale of ${F}, but the format parser was created for ${f.locale}`);const{result:N,zone:_,specificOffset:X,invalidReason:xe}=f.explainFromTokens(s);return xe?Se.invalid(xe):Mn(N,_,g,`format ${f.format}`,s,X)}static get DATE_SHORT(){return b}static get DATE_MED(){return x}static get DATE_MED_WITH_WEEKDAY(){return v}static get DATE_FULL(){return k}static get DATE_HUGE(){return C}static get TIME_SIMPLE(){return S}static get TIME_WITH_SECONDS(){return T}static get TIME_WITH_SHORT_OFFSET(){return O}static get TIME_WITH_LONG_OFFSET(){return M}static get TIME_24_SIMPLE(){return E}static get TIME_24_WITH_SECONDS(){return R}static get TIME_24_WITH_SHORT_OFFSET(){return P}static get TIME_24_WITH_LONG_OFFSET(){return A}static get DATETIME_SHORT(){return H}static get DATETIME_SHORT_WITH_SECONDS(){return D}static get DATETIME_MED(){return L}static get DATETIME_MED_WITH_SECONDS(){return U}static get DATETIME_MED_WITH_WEEKDAY(){return $}static get DATETIME_FULL(){return W}static get DATETIME_FULL_WITH_SECONDS(){return Q}static get DATETIME_HUGE(){return te}static get DATETIME_HUGE_WITH_SECONDS(){return ee}}function Qn(m){if(Se.isDateTime(m))return m;if(m&&m.valueOf&&Ve(m.valueOf()))return Se.fromJSDate(m);if(m&&typeof m=="object")return Se.fromObject(m);throw new a(`Unknown datetime argument: ${m}, of type ${typeof m}`)}const Wu="3.7.2";return wt.DateTime=Se,wt.Duration=Re,wt.FixedOffsetZone=qe,wt.IANAZone=pe,wt.Info=Gn,wt.Interval=et,wt.InvalidZone=ct,wt.Settings=Pe,wt.SystemZone=ae,wt.VERSION=Wu,wt.Zone=G,wt}var Xi;function co(){return Xi||(Xi=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CronDate=e.DAYS_IN_MONTH=e.DateMathOp=e.TimeUnit=void 0;const n=xf();var r;(function(l){l.Second="Second",l.Minute="Minute",l.Hour="Hour",l.Day="Day",l.Month="Month",l.Year="Year"})(r||(e.TimeUnit=r={}));var o;(function(l){l.Add="Add",l.Subtract="Subtract"})(o||(e.DateMathOp=o={})),e.DAYS_IN_MONTH=Object.freeze([31,29,31,30,31,30,31,31,30,31,30,31]);class i{#e;#n=null;#o=null;constructor(a,d){const u={zone:d};if(a?a instanceof i?(this.#e=a.#e,this.#n=a.#n,this.#o=a.#o):a instanceof Date?this.#e=n.DateTime.fromJSDate(a,u):typeof a=="number"?this.#e=n.DateTime.fromMillis(a,u):(this.#e=n.DateTime.fromISO(a,u),this.#e.isValid||(this.#e=n.DateTime.fromRFC2822(a,u)),this.#e.isValid||(this.#e=n.DateTime.fromSQL(a,u)),this.#e.isValid||(this.#e=n.DateTime.fromFormat(a,"EEE, d MMM yyyy HH:mm:ss",u))):this.#e=n.DateTime.local(),!this.#e.isValid)throw new Error(`CronDate: unhandled timestamp: ${a}`);d&&d!==this.#e.zoneName&&(this.#e=this.#e.setZone(d))}static#s(a){return a%4===0&&a%100!==0||a%400===0}get dstStart(){return this.#n}set dstStart(a){this.#n=a}get dstEnd(){return this.#o}set dstEnd(a){this.#o=a}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(a){switch(a){case r.Year:return this.addYear();case r.Month:return this.addMonth();case r.Day:return this.addDay();case r.Hour:return this.addHour();case r.Minute:return this.addMinute();case r.Second:return this.addSecond()}}subtractUnit(a){switch(a){case r.Year:return this.subtractYear();case r.Month:return this.subtractMonth();case r.Day:return this.subtractDay();case r.Hour:return this.subtractHour();case r.Minute:return this.subtractMinute();case r.Second:return this.subtractSecond()}}invokeDateOperation(a,d){if(a===o.Add){this.addUnit(d);return}if(a===o.Subtract){this.subtractUnit(d);return}throw new Error(`Invalid verb: ${a}`)}getDate(){return this.#e.day}getFullYear(){return this.#e.year}getDay(){const a=this.#e.weekday;return a===7?0:a}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 a=this.#r().weekday;return a===7?0:a}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(a){this.#e=this.#e.set({day:a})}setFullYear(a){this.#e=this.#e.set({year:a})}setDay(a){this.#e=this.#e.set({weekday:a})}setMonth(a){this.#e=this.#e.set({month:a+1})}setHours(a){this.#e=this.#e.set({hour:a})}setMinutes(a){this.#e=this.#e.set({minute:a})}setSeconds(a){this.#e=this.#e.set({second:a})}setMilliseconds(a){this.#e=this.#e.set({millisecond:a})}toString(){return this.toDate().toString()}toDate(){return this.#e.toJSDate()}isLastDayOfMonth(){const{day:a,month:d}=this.#e;if(d===2){const u=i.#s(this.#e.year);return a===e.DAYS_IN_MONTH[d-1]-(u?0:1)}return a===e.DAYS_IN_MONTH[d-1]}isLastWeekdayOfMonth(){const{day:a,month:d}=this.#e;let u;return d===2?u=e.DAYS_IN_MONTH[d-1]-(i.#s(this.#e.year)?0:1):u=e.DAYS_IN_MONTH[d-1],a>u-7}applyDateOperation(a,d,u){if(d===r.Month||d===r.Day){this.invokeDateOperation(a,d);return}const h=this.getHours();this.invokeDateOperation(a,d);const y=this.getHours(),b=y-h;b===2?u!==24&&(this.dstStart=h+1):b===0&&this.getMinutes()===0&&this.getSeconds()===0&&u!==24&&(this.dstEnd=y)}#r(){return this.#e.toUTC()}}e.CronDate=i,e.default=i})(Is)),Is}var Ji;function vf(){if(Ji)return ar;Ji=1,Object.defineProperty(ar,"__esModule",{value:!0}),ar.CronMonth=void 0;const e=co(),n=mn(),r=1,o=12,i=Object.freeze([]);let l=class extends n.CronField{static get min(){return r}static get max(){return o}static get chars(){return i}static get daysInMonth(){return e.DAYS_IN_MONTH}constructor(d,u){super(d,u),this.validate()}get values(){return super.values}};return ar.CronMonth=l,ar}var lr={},ea;function bf(){if(ea)return lr;ea=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.CronSecond=void 0;const e=mn(),n=0,r=59,o=Object.freeze([]);let i=class extends e.CronField{static get min(){return n}static get max(){return r}static get chars(){return o}constructor(a,d){super(a,d),this.validate()}get values(){return super.values}};return lr.CronSecond=i,lr}var ta;function uo(){return ta||(ta=1,(function(e){var n=ln&&ln.__createBinding||(Object.create?(function(o,i,l,a){a===void 0&&(a=l);var d=Object.getOwnPropertyDescriptor(i,l);(!d||("get"in d?!i.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return i[l]}}),Object.defineProperty(o,a,d)}):(function(o,i,l,a){a===void 0&&(a=l),o[a]=i[l]})),r=ln&&ln.__exportStar||function(o,i){for(var l in o)l!=="default"&&!Object.prototype.hasOwnProperty.call(i,l)&&n(i,o,l)};Object.defineProperty(e,"__esModule",{value:!0}),r(ff(),e),r(mf(),e),r(pf(),e),r(mn(),e),r(gf(),e),r(yf(),e),r(vf(),e),r(bf(),e)})(ln)),ln}var na;function al(){if(na)return tr;na=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.CronFieldCollection=void 0;const e=uo();let n=class gr{#e;#n;#o;#s;#r;#t;static from(o,i){return new gr({second:this.resolveField(e.CronSecond,o.second,i.second),minute:this.resolveField(e.CronMinute,o.minute,i.minute),hour:this.resolveField(e.CronHour,o.hour,i.hour),dayOfMonth:this.resolveField(e.CronDayOfMonth,o.dayOfMonth,i.dayOfMonth),month:this.resolveField(e.CronMonth,o.month,i.month),dayOfWeek:this.resolveField(e.CronDayOfWeek,o.dayOfWeek,i.dayOfWeek)})}static resolveField(o,i,l){return l?l instanceof e.CronField?l:new o(l):i}constructor({second:o,minute:i,hour:l,dayOfMonth:a,month:d,dayOfWeek:u}){if(!o)throw new Error("Validation error, Field second is missing");if(!i)throw new Error("Validation error, Field minute is missing");if(!l)throw new Error("Validation error, Field hour is missing");if(!a)throw new Error("Validation error, Field dayOfMonth is missing");if(!d)throw new Error("Validation error, Field month is missing");if(!u)throw new Error("Validation error, Field dayOfWeek is missing");if(d.values.length===1&&!a.hasLastChar&&u.isWildcard&&!(parseInt(a.values[0],10)<=e.CronMonth.daysInMonth[d.values[0]-1]))throw new Error("Invalid explicit day of month definition");this.#e=o,this.#n=i,this.#o=l,this.#r=d,this.#t=u,this.#s=a}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(o){if(o.length===0)return[];const i=[];let l;return o.forEach((a,d,u)=>{if(l===void 0){l={start:a,count:1};return}const h=u[d-1]||l.start,y=u[d+1];if(a==="L"||a==="W"){i.push(l),i.push({start:a,count:1}),l=void 0;return}if(l.step===void 0&&y!==void 0){const b=a-h,x=y-a;if(b<=x){l={...l,count:2,end:a,step:b};return}l.step=1}a-(l.end??0)===l.step?(l.count++,l.end=a):(l.count===1?i.push({start:l.start,count:1}):l.count===2?(i.push({start:l.start,count:1}),i.push({start:l.end??h,count:1})):i.push(l),l={start:a,count:1})}),l&&i.push(l),i}static#c(o,i,l){const a=i.step;return a?a===1&&i.start===o.min&&i.end&&i.end>=l?o.hasQuestionMarkChar?"?":"*":a!==1&&i.start===o.min&&i.end&&i.end>=l-a+1?`*/${a}`:null:null}static#l(o,i){const l=o.step;if(l===1)return`${o.start}-${o.end}`;const a=o.start===0?o.count-1:o.count;if(!l)throw new Error("Unexpected range step");if(!o.end)throw new Error("Unexpected range end");if(l*a>o.end){const d=(h,y)=>{if(typeof o.start!="number")throw new Error("Unexpected range start");return y%l===0?o.start+y:null};if(typeof o.start!="number")throw new Error("Unexpected range start");const u={length:o.end-o.start+1};return Array.from(u,d).filter(h=>h!==null).join(",")}return o.end===i-l+1?`${o.start}/${l}`:`${o.start}-${o.end}/${l}`}stringifyField(o){let i=o.max,l=o.values;if(o instanceof e.CronDayOfWeek){i=6;const d=this.#t.values;l=d[d.length-1]===7?d.slice(0,-1):d}o instanceof e.CronDayOfMonth&&(i=this.#r.values.length===1?e.CronMonth.daysInMonth[this.#r.values[0]-1]:o.max);const a=gr.compactField(l);if(a.length===1){const d=gr.#c(o,a[0],i);if(d)return d}return a.map(d=>{const u=d.count===1?d.start.toString():gr.#l(d,i);return o instanceof e.CronDayOfWeek&&o.nthDay>0?`${u}#${o.nthDay}`:u}).join(",")}stringify(o=!1){const i=[];return o&&i.push(this.stringifyField(this.#e)),i.push(this.stringifyField(this.#n),this.stringifyField(this.#o),this.stringifyField(this.#s),this.stringifyField(this.#r),this.stringifyField(this.#t)),i.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 tr.CronFieldCollection=n,tr}var Ds={},ra;function ll(){return ra||(ra=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 n=co();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 r=1e4;class o{#e;#n;#o;#s;#r;#t;#c=null;#l=!1;constructor(l,a){this.#e=a,this.#n=a.tz,this.#s=a.startDate?new n.CronDate(a.startDate,this.#n):null,this.#r=a.endDate?new n.CronDate(a.endDate,this.#n):null;let d=a.currentDate??a.startDate;if(d){const u=new n.CronDate(d,this.#n);this.#s&&u.getTime()<this.#s.getTime()?d=this.#s:this.#r&&u.getTime()>this.#r.getTime()&&(d=this.#r)}this.#o=new n.CronDate(d,this.#n),this.#t=l}get fields(){return this.#t}static fieldsToExpression(l,a){return new o(l,a||{})}static#i(l,a){return a.some(d=>d===l)}#a(l,a){return l[a?l.length-1:0]}#d(l){const a=`${l.getFullYear()}-${l.getMonth()+1}-${l.getDate()}`;if(this.#c===a)return this.#l;const d=new n.CronDate(l);d.setStartOfDay();const u=new n.CronDate(l);return u.setEndOfDay(),this.#c=a,this.#l=d.getUTCOffset()!==u.getUTCOffset(),this.#l}#h(l,a,d){const u=this.#t.second.values,h=l.getSeconds(),y=this.#t.second.findNearestValue(h,d);if(y!==null){l.setSeconds(y);return}l.applyDateOperation(a,n.TimeUnit.Minute,this.#t.hour.values.length),l.setSeconds(this.#a(u,d))}#m(l,a,d){const u=this.#t.minute.values,h=this.#t.second.values,y=l.getMinutes(),b=this.#t.minute.findNearestValue(y,d);if(b!==null){l.setMinutes(b),l.setSeconds(this.#a(h,d));return}l.applyDateOperation(a,n.TimeUnit.Hour,this.#t.hour.values.length),l.setMinutes(this.#a(u,d)),l.setSeconds(this.#a(h,d))}static#p(l,a){const d=a.isLastWeekdayOfMonth();return l.some(u=>{const h=parseInt(u.toString().charAt(0),10)%7;if(Number.isNaN(h))throw new Error(`Invalid last weekday of the month expression: ${u}`);return a.getDay()===h&&d})}next(){return this.#u()}prev(){return this.#u(!0)}hasNext(){const l=this.#o;try{return this.#u(),!0}catch{return!1}finally{this.#o=l}}hasPrev(){const l=this.#o;try{return this.#u(!0),!0}catch{return!1}finally{this.#o=l}}take(l){const a=[];if(l>=0)for(let d=0;d<l;d++)try{a.push(this.next())}catch{return a}else for(let d=0;d>l;d--)try{a.push(this.prev())}catch{return a}return a}reset(l){this.#o=new n.CronDate(l||this.#e.currentDate,this.#n)}stringify(l=!1){return this.#t.stringify(l)}includesDate(l){const{second:a,minute:d,hour:u,month:h}=this.#t,y=new n.CronDate(l,this.#n);return!(!a.values.includes(y.getSeconds())||!d.values.includes(y.getMinutes())||!u.values.includes(y.getHours())||!h.values.includes(y.getMonth()+1)||!this.#f(y)||this.#t.dayOfWeek.nthDay>0&&Math.ceil(y.getDate()/7)!==this.#t.dayOfWeek.nthDay)}toString(){return this.#e.expression||this.stringify(!0)}#f(l){const a=this.#t.dayOfMonth.isWildcard,d=!a,u=this.#t.dayOfWeek.isWildcard,h=!u,y=o.#i(l.getDate(),this.#t.dayOfMonth.values)||this.#t.dayOfMonth.hasLastChar&&l.isLastDayOfMonth(),b=o.#i(l.getDay(),this.#t.dayOfWeek.values)||this.#t.dayOfWeek.hasLastChar&&o.#p(this.#t.dayOfWeek.values,l);return!!(d&&h&&(y||b)||y&&!h||a&&!u&&b)}#g(l,a,d){const u=this.#t.hour.values,h=u,y=l.getHours(),b=o.#i(y,u),x=l.dstEnd===y;if(l.dstStart!==null&&l.dstStart===y-1&&o.#i(l.dstStart,u))return!0;if(x&&!d)return l.dstEnd=null,l.applyDateOperation(n.DateMathOp.Add,n.TimeUnit.Hour,h.length),!1;if(b)return!0;l.dstStart=null;const v=this.#t.hour.findNearestValue(y,d);if(v===null)return l.applyDateOperation(a,n.TimeUnit.Day,h.length),!1;if(this.#d(l)){const k=d?y-v:v-y;for(let C=0;C<k&&(l.applyDateOperation(a,n.TimeUnit.Hour,h.length),!(!d&&l.getHours()>=v||d&&l.getHours()<=v));C++);}else l.setHours(v);return l.setMinutes(this.#a(this.#t.minute.values,d)),l.setSeconds(this.#a(this.#t.second.values,d)),!1}#y(l){if(!this.#s&&!this.#r)return;const a=l.getTime();if(this.#s&&a<this.#s.getTime())throw new Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE);if(this.#r&&a>this.#r.getTime())throw new Error(e.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE)}#u(l=!1){const a=l?n.DateMathOp.Subtract:n.DateMathOp.Add,d=new n.CronDate(this.#o),u=d.getTime();let h=0;for(;++h<r;){if(this.#y(d),!this.#f(d)){d.applyDateOperation(a,n.TimeUnit.Day,this.#t.hour.values.length);continue}if(!(this.#t.dayOfWeek.nthDay<=0||Math.ceil(d.getDate()/7)===this.#t.dayOfWeek.nthDay)){d.applyDateOperation(a,n.TimeUnit.Day,this.#t.hour.values.length);continue}if(!o.#i(d.getMonth()+1,this.#t.month.values)){d.applyDateOperation(a,n.TimeUnit.Month,this.#t.hour.values.length);continue}if(this.#g(d,a,l)){if(!o.#i(d.getMinutes(),this.#t.minute.values)){this.#m(d,a,l);continue}if(!o.#i(d.getSeconds(),this.#t.second.values)){this.#h(d,a,l);continue}if(u===d.getTime()){(a==="Add"||d.getMilliseconds()===0)&&d.applyDateOperation(a,n.TimeUnit.Second,this.#t.hour.values.length);continue}break}}if(h>r)throw new Error(e.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE);return d.getMilliseconds()!==0&&d.setMilliseconds(0),this.#o=d,d}[Symbol.iterator](){return{next:()=>{try{return{value:this.#u(),done:!1}}catch{return{value:void 0,done:!0}}}}}}e.CronExpression=o,e.default=o})(Ds)),Ds}var Br={},sa;function wf(){if(sa)return Br;sa=1,Object.defineProperty(Br,"__esModule",{value:!0}),Br.seededRandom=r;function e(o){let i=2166136261;for(let l=0;l<o.length;l++)i^=o.charCodeAt(l),i=Math.imul(i,16777619);return()=>i>>>0}function n(o){return()=>{let i=o+=1831565813;return i=Math.imul(i^i>>>15,i|1),i^=i+Math.imul(i^i>>>7,i|61),((i^i>>>14)>>>0)/4294967296}}function r(o){const i=o?e(o)():Math.floor(Math.random()*1e10);return n(i)}return Br}var oa;function Zs(){if(oa)return jt;oa=1,Object.defineProperty(jt,"__esModule",{value:!0}),jt.CronExpressionParser=jt.DayOfWeek=jt.Months=jt.CronUnit=jt.PredefinedExpressions=void 0;const e=al(),n=ll(),r=wf(),o=uo();var i;(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"})(i||(jt.PredefinedExpressions=i={}));var l;(function(h){h.Second="Second",h.Minute="Minute",h.Hour="Hour",h.DayOfMonth="DayOfMonth",h.Month="Month",h.DayOfWeek="DayOfWeek"})(l||(jt.CronUnit=l={}));var a;(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"})(a||(jt.Months=a={}));var d;(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"})(d||(jt.DayOfWeek=d={}));let u=class Tt{static parse(y,b={}){const{strict:x=!1,hashSeed:v}=b,k=(0,r.seededRandom)(v);y=i[y]||y;const C=Tt.#e(y,x);if(!(C.dayOfMonth==="*"||C.dayOfWeek==="*"||!x))throw new Error("Cannot use both dayOfMonth and dayOfWeek together in strict mode!");const S=Tt.#n(l.Second,C.second,o.CronSecond.constraints,k),T=Tt.#n(l.Minute,C.minute,o.CronMinute.constraints,k),O=Tt.#n(l.Hour,C.hour,o.CronHour.constraints,k),M=Tt.#n(l.Month,C.month,o.CronMonth.constraints,k),E=Tt.#n(l.DayOfMonth,C.dayOfMonth,o.CronDayOfMonth.constraints,k),{dayOfWeek:R,nthDayOfWeek:P}=Tt.#d(C.dayOfWeek),A=Tt.#n(l.DayOfWeek,R,o.CronDayOfWeek.constraints,k),H=new e.CronFieldCollection({second:new o.CronSecond(S,{rawValue:C.second}),minute:new o.CronMinute(T,{rawValue:C.minute}),hour:new o.CronHour(O,{rawValue:C.hour}),dayOfMonth:new o.CronDayOfMonth(E,{rawValue:C.dayOfMonth}),month:new o.CronMonth(M,{rawValue:C.month}),dayOfWeek:new o.CronDayOfWeek(A,{rawValue:C.dayOfWeek,nthDayOfWeek:P})});return new n.CronExpression(H,{...b,expression:y})}static#e(y,b){if(b&&!y.length)throw new Error("Invalid cron expression");y=y||"0 * * * * *";const x=y.trim().split(/\s+/);if(b&&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 v=["*","*","*","*","*","0"];x.length<v.length&&x.unshift(...v.slice(x.length));const[k,C,S,T,O,M]=x;return{second:k,minute:C,hour:S,dayOfMonth:T,month:O,dayOfWeek:M}}static#n(y,b,x,v){if((y===l.Month||y===l.DayOfWeek)&&(b=b.replace(/[a-z]{3}/gi,k=>{k=k.toLowerCase();const C=a[k]||d[k];if(C===void 0)throw new Error(`Validation error, cannot resolve alias "${k}"`);return C.toString()})),!x.validChars.test(b))throw new Error(`Invalid characters, got value: ${b}`);return b=this.#o(b,x),b=this.#s(b,x,v),this.#r(y,b,x)}static#o(y,b){return y.replace(/[*?]/g,b.min+"-"+b.max)}static#s(y,b,x){const v=x();return y.replace(/H(?:\((\d+)-(\d+)\))?(?:\/(\d+))?/g,(k,C,S,T)=>{if(C&&S&&T){const O=parseInt(C,10),M=parseInt(S,10),E=parseInt(T,10);if(O>M)throw new Error(`Invalid range: ${O}-${M}, min > max`);if(E<=0)throw new Error(`Invalid step: ${E}, must be positive`);const R=Math.max(O,b.min),P=Math.floor(v*E),A=[];for(let H=Math.floor(R/E)*E+P;H<=M;H+=E)H>=R&&A.push(H);return A.join(",")}else if(C&&S){const O=parseInt(C,10),M=parseInt(S,10);if(O>M)throw new Error(`Invalid range: ${O}-${M}, min > max`);return String(Math.floor(v*(M-O+1))+O)}else if(T){const O=parseInt(T,10);if(O<=0)throw new Error(`Invalid step: ${O}, must be positive`);const M=Math.floor(v*O),E=[];for(let R=Math.floor(b.min/O)*O+M;R<=b.max;R+=O)R>=b.min&&E.push(R);return E.join(",")}else return String(Math.floor(v*(b.max-b.min+1)+b.min))})}static#r(y,b,x){const v=[];function k(S,T){if(Array.isArray(S))v.push(...S);else if(Tt.#h(T,S))v.push(S);else{const O=parseInt(S.toString(),10);if(!(O>=T.min&&O<=T.max))throw new Error(`Constraint error, got value ${S} expected range ${T.min}-${T.max}`);v.push(y===l.DayOfWeek?O%7:S)}}return b.split(",").forEach(S=>{if(!(S.length>0))throw new Error("Invalid list value format");k(Tt.#t(y,S,x),x)}),v}static#t(y,b,x){const v=b.split("/");if(v.length>2)throw new Error(`Invalid repeat: ${b}`);return v.length===2?(v[0].includes("-")||(v[0]=`${v[0]}-${x.max}`),Tt.#a(y,v[0],parseInt(v[1],10),x)):Tt.#a(y,b,1,x)}static#c(y,b,x){if(!(!isNaN(y)&&!isNaN(b)&&y>=x.min&&b<=x.max))throw new Error(`Constraint error, got range ${y}-${b} expected range ${x.min}-${x.max}`);if(y>b)throw new Error(`Invalid range: ${y}-${b}, min(${y}) > max(${b})`)}static#l(y){if(!(!isNaN(y)&&y>0))throw new Error(`Constraint error, cannot repeat at every ${y} time.`)}static#i(y,b,x,v){const k=[];y===l.DayOfWeek&&x%7===0&&k.push(0);for(let C=b;C<=x;C+=v)k.indexOf(C)===-1&&k.push(C);return k}static#a(y,b,x,v){const k=b.split("-");if(k.length<=1)return isNaN(+b)?b:+b;const[C,S]=k.map(T=>parseInt(T,10));return this.#c(C,S,v),this.#l(x),this.#i(y,C,S,x)}static#d(y){const b=y.split("#");if(b.length<=1)return{dayOfWeek:b[0]};const x=+b[b.length-1],v=y.match(/([,-/])/);if(v!==null)throw new Error(`Constraint error, invalid dayOfWeek \`#\` and \`${v?.[0]}\` special characters are incompatible`);if(!(b.length<=2&&!isNaN(x)&&x>=1&&x<=5))throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return{dayOfWeek:b[0],nthDayOfWeek:x}}static#h(y,b){return y.chars.some(x=>b.toString().includes(x))}};return jt.CronExpressionParser=u,jt}var Lt={};const Sf={},kf=Object.freeze(Object.defineProperty({__proto__:null,default:Sf},Symbol.toStringTag,{value:"Module"})),ia=c.getAugmentedNamespace(kf);var aa;function Cf(){if(aa)return Lt;aa=1;var e=Lt&&Lt.__createBinding||(Object.create?(function(l,a,d,u){u===void 0&&(u=d);var h=Object.getOwnPropertyDescriptor(a,d);(!h||("get"in h?!a.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return a[d]}}),Object.defineProperty(l,u,h)}):(function(l,a,d,u){u===void 0&&(u=d),l[u]=a[d]})),n=Lt&&Lt.__setModuleDefault||(Object.create?(function(l,a){Object.defineProperty(l,"default",{enumerable:!0,value:a})}):function(l,a){l.default=a}),r=Lt&&Lt.__importStar||(function(){var l=function(a){return l=Object.getOwnPropertyNames||function(d){var u=[];for(var h in d)Object.prototype.hasOwnProperty.call(d,h)&&(u[u.length]=h);return u},l(a)};return function(a){if(a&&a.__esModule)return a;var d={};if(a!=null)for(var u=l(a),h=0;h<u.length;h++)u[h]!=="default"&&e(d,a,u[h]);return n(d,a),d}})();Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.CronFileParser=void 0;const o=Zs();let i=class Yr{static async parseFile(a){const{readFile:d}=await Promise.resolve().then(()=>r(ia)),u=await d(a,"utf8");return Yr.#e(u)}static parseFileSync(a){const{readFileSync:d}=ia,u=d(a,"utf8");return Yr.#e(u)}static#e(a){const d=a.split(`
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
`),i=o.findIndex(d=>!d.trim().startsWith("#"));if(i<0)return r;const l=o[i];if(/^\s*view\s*:/.test(l))return ka(o,i).join(`
|
|
25
25
|
`);const a=pn(e);return new RegExp(`^\\s*${a}\\s+is\\b`).test(l)?(o[i]=l.replace(/^(\s*)/,"$1view: "),ka(o,i).join(`
|
|
26
26
|
`)):r}function ka(e,n){const r=e.slice(n+1).filter(i=>i.trim()!=="");if(r.length===0)return e;const o=Math.min(...r.map(i=>i.length-i.trimStart().length));return o===0?e:e.map((i,l)=>l<=n?i:i.slice(Math.min(o,i.length-i.trimStart().length)))}function wo(e){return e.kind==="dimension"&&e.indexed===!0}function So(e){return!!e&&(e.loading||!!e.code||!!e.inheritedFrom||!!e.error)}function Ap(e,n){const r=[],o=[];for(const i of e){const l=n(i);(!!l&&!l.loading&&(!!l.code||!!l.error)||wo(i)?r:o).push(i)}return o.length===0||r.length===0?e:[...r,...o]}function Fp(e,n){return n.includes(`
|
|
27
|
-
`)||e.scrollWidth>e.clientWidth}const Rp={dimension:ql,measure:Wl,calculate:hp,view:zl,join:mp};function Np(e){switch(e){case"dimension":case"measure":case"calculate":case"view":return va(e).main;case"column":return va("dimension").main;case"join":return An.brown.main}}function Lp(e){const n=e?.trim().toLowerCase()??"";if(!n)return;if(n.startsWith("array"))return gp;if(n.startsWith("record")||/\bfields?\b/.test(n))return yp;switch(n.split(/[\s·<]/)[0]){case"string":return dp;case"number":return Wl;case"date":return fp;case"timestamp":case"timestamptz":return kp;case"boolean":return jp;default:return}}const _p=16;function ko({kind:e,dataType:n}){const r=e==="dimension"||e==="measure"||e==="calculate"||e==="column"?Lp(n):void 0;return t.jsx(p.Box,{component:"span","aria-hidden":!0,"data-row-glyph":e,sx:{display:"inline-flex",alignSelf:"center",flexShrink:0,color:Np(e)},children:j.createElement(r??Rp[e==="column"?"dimension":e],{size:_p})})}function Co(e,n){return(n?e.givensBySource?.get(n):void 0)??e.givens}function Ul(e,n){if(!e.givenValues||!n)return e;const r=new Set(n.map(i=>i.name)),o=Object.entries(e.givenValues).filter(([i])=>r.has(i));return{...e,givenValues:o.length>0?Object.fromEntries(o):void 0}}function Pp({run:e,modelPath:n,query:r,enabled:o}){const{server:i,apiClients:l}=q.useServer(),a=yt.useQuery({...Gl({server:i,apiClients:l,run:e,modelPath:n,query:r}),enabled:o,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return{result:a.data?.data.result,isSuccess:a.isSuccess,isLoading:a.isLoading,isFetching:a.isFetching,isError:a.isError,error:a.error,refetch:a.refetch}}function jo(e,n,r,o){return["model-viewer-run",e,n.projectName,n.packageName,r,n.versionId??"",o,yo(n.givenValues),...n.includeHiddenFilesAndSources?["off-surface"]:[]]}function Gl({server:e,apiClients:n,run:r,modelPath:o,query:i}){const l=yo(r.givenValues)===""?void 0:r.givenValues;return{queryKey:jo(e,r,o,i),queryFn:async({signal:a})=>{const d=performance.now(),u=()=>Math.round(performance.now()-d);try{const h=await n.models.executeQueryModel(r.projectName,r.packageName,o,{query:i,versionId:r.versionId,...l&&{givens:l},...r.queryMetadata&&{queryMetadata:{...r.queryMetadata}}},r.includeHiddenFilesAndSources?!0:void 0,{signal:a});return r.onQueryRun?.({outcome:"success",durationMs:u()}),h}catch(h){throw a?.aborted||r.onQueryRun?.({outcome:"error",durationMs:u()}),h}},staleTime:1/0,retry:!1}}const Rs=12,zp=5*6e4;function Wp(e){const n=us(e);return n===void 0?!1:n>=400&&n<500&&n!==401&&n!==408&&n!==429}function qp(e){if(!e)return[];const{data:n}=JSON.parse(e);return n?.kind!=="array_cell"?[]:n.array_value.flatMap(r=>{if(r.kind!=="record_cell")return[];const o=r.record_value[0];if(!o)return[];switch(o.kind){case"string_cell":return[o.string_value];case"number_cell":return[String(o.number_value)];case"boolean_cell":return[String(o.boolean_value)];case"date_cell":return[o.date_value];case"timestamp_cell":return[o.timestamp_value];default:return[]}})}function Bp({run:e,modelPath:n,sourceName:r,field:o,fetchSamples:i,generation:l}){const{server:a,apiClients:d}=q.useServer(),u=o?.kind==="dimension"&&o.indexed===!0,h=Co(e,r),y=u&&!i?Fl(h,e.requiredFiltersBySource?.get(r),e.givenValues):void 0,b=y?.kind==="blocked"?y.reason:void 0,x=u&&!b?o.name:void 0,v=yt.useQuery({...Gl({server:a,apiClients:d,run:Ul(e,h),modelPath:n,query:c.sampleValuesQuery(r,x??"",Rs)}),enabled:!!x&&!i,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),k=yt.useQuery({queryKey:["model-viewer-samples",a,e.projectName,e.packageName,e.versionId??"",n,r,x,l??"host"],enabled:!!x&&!!i,staleTime:zp,retry:!1,refetchOnWindowFocus:!1,queryFn:async({signal:T})=>{try{const O=await i({modelPath:n,sourceName:r,fieldName:x,limit:Rs,signal:T}),M=Array.isArray(O)?{values:O}:O;return{...M,values:M.values.slice(0,Rs)}}catch(O){if(Wp(O))return{values:[]};throw O}}}),C=i?k:v,S=i?k.data:v.data&&{values:qp(v.data.data.result)};return{samples:S?.values??[],total:S?.total,unavailable:b??S?.unavailable,loading:!!x&&C.isPending,failed:C.isError}}function Vp({children:e}){return t.jsx(p.Box,{component:"span",sx:{fontFamily:Dt,fontSize:St.caption,color:"text.primary",bgcolor:rt.background.muted,border:"1px solid",borderColor:"divider",borderRadius:1,padding:"2px 8px"},children:e})}function Hp({run:e,fetchSamples:n,modelPath:r,sourceName:o,field:i,generation:l}){const{samples:a,total:d,unavailable:u,loading:h,failed:y}=Bp({run:e,fetchSamples:n,modelPath:r,sourceName:o,field:i,generation:l});return t.jsxs(p.Box,{"data-testid":"model-viewer-values",sx:{fontSize:St.small},children:[t.jsx(p.Box,{component:"div",sx:{color:ls,fontSize:St.caption,mb:"6px"},children:d!=null?`The most common of ${d.toLocaleString()} ${d===1?"value":"values"}`:"The most common values"}),h?t.jsx(p.CircularProgress,{size:12,sx:{color:"text.secondary"}}):u?t.jsx(p.Box,{component:"span","data-testid":"model-viewer-values-unavailable",sx:{color:"text.secondary"},children:u}):y?t.jsx(p.Box,{component:"span",sx:{fontStyle:"italic",color:"text.secondary"},children:"Sample values couldn't be loaded."}):a.length===0?t.jsx(p.Box,{component:"span",sx:{fontStyle:"italic",color:"text.secondary"},children:"No values found."}):t.jsx(p.Box,{sx:{display:"flex",flexWrap:"wrap",gap:"6px"},children:a.map(b=>t.jsx(Vp,{children:b},b))})]})}const Ns={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"}]}}},Up={...Ns,patterns:[...Ns.patterns,{include:"#docvar"}],repository:{...Ns.repository,docvar:{patterns:[{match:"\\<\\<[^(\\>\\>)]*\\>\\>",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"markup.italic.markdown"}]}}},Gp={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"}]}}},Yp="github-light",Kp="github-dark";let Ls;function Qp(){return Ls||(Ls=(async()=>{const[{createHighlighterCore:e},{createOnigurumaEngine:n},{default:r},{default:o},{default:i},{default:l},{default:a}]=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:n(Promise.resolve().then(()=>require("./wasm-Dw4u1m6u.cjs.js"))),themes:[l,a],langs:[r,o,i,{name:"malloy",scopeName:"source.malloy",embeddedLangs:["sql"],...Up},{name:"malloysql",scopeName:"source.malloy-sql",embeddedLangs:["sql"],...Gp}]})})()),Ls}async function To(e,n,r="light"){return(await Qp()).codeToHtml(e,{lang:n,theme:r==="dark"?Kp:Yp})}function Mr({code:e,testId:n,framed:r=!0}){const{mode:o}=q.usePublisherTheme(),[i,l]=j.useState(void 0);return j.useEffect(()=>{let a=!0;return To(e,"malloy",o).then(d=>a&&l(d)).catch(()=>a&&l(void 0)),()=>{a=!1}},[e,o]),t.jsx(p.Box,{"data-testid":n,sx:{fontFamily:Dt,fontSize:"0.75rem",overflowX:"auto","& pre":{m:0,background:"transparent !important"},...r&&{border:"1px solid",borderColor:"divider",borderRadius:1,px:1.5,py:1,bgcolor:"background.default"}},children:i?t.jsx("div",{dangerouslySetInnerHTML:{__html:i}}):t.jsx(p.Box,{component:"pre",sx:{whiteSpace:"pre"},children:e})})}function hs({message:e,onRetry:n,severity:r="error"}){return t.jsx(p.Alert,{severity:r,action:n&&t.jsx(p.Button,{color:"inherit",size:"small",onClick:n,children:"Retry"}),children:e})}function Yl(e){const n=e?.response?.data?.message;return typeof n=="string"&&n?n:void 0}function Kl(e,n){const r=Yl(n);return r?`${e}: ${r}`:`${e}.`}function Zp(e){const n=us(e);return!(n===400||n===401||n===403||n===404||n===422)}function Xp({query:e,error:n,onRetry:r,testId:o,forbiddenMessage:i}){const l=i!==void 0&&us(n)===403;return t.jsxs(p.Box,{"data-testid":o,sx:{display:"flex",flexDirection:"column",gap:1},children:[e&&t.jsx(Mr,{code:e,testId:"query-failure-code"}),t.jsx(hs,{message:l?i:Kl("Query failed",n),onRetry:r&&Zp(n)?r:void 0})]})}const Ca=j.forwardRef(function(n,r){return t.jsx(p.Button,{ref:r,variant:"contained",size:"small",disableElevation:!0,...n,sx:{textTransform:"none",...n.sx}})}),Jp=j.forwardRef(function(n,r){return t.jsx(p.Button,{ref:r,variant:"outlined",size:"small",color:"inherit",...n,sx:{textTransform:"none",borderRadius:999,borderColor:"divider",color:"text.secondary",...n.sx}})}),yr=10,eg="clamp(340px, 40%, 520px)";function tg({field:e,run:n,modelPath:r,sourceName:o,fieldCode:i,joined:l=!1}){const[a,d]=bo(),{fetchSamples:u,samplesGeneration:h,renderFieldStatus:y,renderFieldAction:b,renderFieldDetail:x}=cs(),v={modelPath:r,sourceName:o,field:e,joined:l},k=y?.(v),C=b?.(v),S=e.doc?void 0:i?.columnDoc,T=e.doc??S,O=So(i),M=j.useContext(vo),E=j.useMemo(()=>dn(i?.code,M),[i?.code,M]),R=wo(e)&&!l&&!!n,P=[...O?["code"]:[],...R?["values"]:[],...E.length>0?["givens"]:[]],A=$=>P.includes($),H=e.kind==="measure"?"measure":e.kind==="calculate"?"calculate":"dimension",D=P.length>0?t.jsxs(p.Box,{"data-testid":"model-viewer-field-card",sx:{...Pn,"& > * + *":{borderTop:1,borderColor:"divider"}},children:[A("code")&&(i?.loading?t.jsx(p.Box,{sx:{p:jr,display:"flex"},children:t.jsx(p.CircularProgress,{size:12,sx:{color:"text.secondary"}})}):i?.code?t.jsx(Mr,{testId:"model-viewer-definition",code:Dp(e.name,i.code),framed:!1}):i?.inheritedFrom?t.jsx(Mr,{testId:"model-viewer-definition",code:`${i.inheritedFrom.fromTable?"// A column of the table this source reads, as it is":"// Passed through from the query this source is built on"}
|
|
27
|
+
`)||e.scrollWidth>e.clientWidth}const Rp={dimension:ql,measure:Wl,calculate:hp,view:zl,join:mp};function Np(e){switch(e){case"dimension":case"measure":case"calculate":case"view":return va(e).main;case"column":return va("dimension").main;case"join":return An.brown.main}}function Lp(e){const n=e?.trim().toLowerCase()??"";if(!n)return;if(n.startsWith("array"))return gp;if(n.startsWith("record")||/\bfields?\b/.test(n))return yp;switch(n.split(/[\s·<]/)[0]){case"string":return dp;case"number":return Wl;case"date":return fp;case"timestamp":case"timestamptz":return kp;case"boolean":return jp;default:return}}const _p=16;function ko({kind:e,dataType:n}){const r=e==="dimension"||e==="measure"||e==="calculate"||e==="column"?Lp(n):void 0;return t.jsx(p.Box,{component:"span","aria-hidden":!0,"data-row-glyph":e,sx:{display:"inline-flex",alignSelf:"center",flexShrink:0,color:Np(e)},children:j.createElement(r??Rp[e==="column"?"dimension":e],{size:_p})})}function Co(e,n){return(n?e.givensBySource?.get(n):void 0)??e.givens}function Ul(e,n){if(!e.givenValues||!n)return e;const r=new Set(n.map(i=>i.name)),o=Object.entries(e.givenValues).filter(([i])=>r.has(i));return{...e,givenValues:o.length>0?Object.fromEntries(o):void 0}}function Pp({run:e,modelPath:n,query:r,enabled:o}){const{server:i,apiClients:l}=q.useServer(),a=yt.useQuery({...Gl({server:i,apiClients:l,run:e,modelPath:n,query:r}),enabled:o,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return{result:a.data?.data.result,isSuccess:a.isSuccess,isLoading:a.isLoading,isFetching:a.isFetching,isError:a.isError,error:a.error,refetch:a.refetch}}function jo(e,n,r,o){return["model-viewer-run",e,n.projectName,n.packageName,r,n.versionId??"",o,yo(n.givenValues),...n.includeHiddenFilesAndSources?["off-surface"]:[]]}function Gl({server:e,apiClients:n,run:r,modelPath:o,query:i}){const l=yo(r.givenValues)===""?void 0:r.givenValues;return{queryKey:jo(e,r,o,i),queryFn:async({signal:a})=>{const d=performance.now(),u=()=>Math.round(performance.now()-d);try{const h=await n.models.executeQueryModel(r.projectName,r.packageName,o,{query:i,versionId:r.versionId,...l&&{givens:l},...r.queryMetadata&&{queryMetadata:{...r.queryMetadata}}},r.includeHiddenFilesAndSources?!0:void 0,void 0,{signal:a});return r.onQueryRun?.({outcome:"success",durationMs:u()}),h}catch(h){throw a?.aborted||r.onQueryRun?.({outcome:"error",durationMs:u()}),h}},staleTime:1/0,retry:!1}}const Rs=12,zp=5*6e4;function Wp(e){const n=us(e);return n===void 0?!1:n>=400&&n<500&&n!==401&&n!==408&&n!==429}function qp(e){if(!e)return[];const{data:n}=JSON.parse(e);return n?.kind!=="array_cell"?[]:n.array_value.flatMap(r=>{if(r.kind!=="record_cell")return[];const o=r.record_value[0];if(!o)return[];switch(o.kind){case"string_cell":return[o.string_value];case"number_cell":return[String(o.number_value)];case"boolean_cell":return[String(o.boolean_value)];case"date_cell":return[o.date_value];case"timestamp_cell":return[o.timestamp_value];default:return[]}})}function Bp({run:e,modelPath:n,sourceName:r,field:o,fetchSamples:i,generation:l}){const{server:a,apiClients:d}=q.useServer(),u=o?.kind==="dimension"&&o.indexed===!0,h=Co(e,r),y=u&&!i?Fl(h,e.requiredFiltersBySource?.get(r),e.givenValues):void 0,b=y?.kind==="blocked"?y.reason:void 0,x=u&&!b?o.name:void 0,v=yt.useQuery({...Gl({server:a,apiClients:d,run:Ul(e,h),modelPath:n,query:c.sampleValuesQuery(r,x??"",Rs)}),enabled:!!x&&!i,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),k=yt.useQuery({queryKey:["model-viewer-samples",a,e.projectName,e.packageName,e.versionId??"",n,r,x,l??"host"],enabled:!!x&&!!i,staleTime:zp,retry:!1,refetchOnWindowFocus:!1,queryFn:async({signal:T})=>{try{const O=await i({modelPath:n,sourceName:r,fieldName:x,limit:Rs,signal:T}),M=Array.isArray(O)?{values:O}:O;return{...M,values:M.values.slice(0,Rs)}}catch(O){if(Wp(O))return{values:[]};throw O}}}),C=i?k:v,S=i?k.data:v.data&&{values:qp(v.data.data.result)};return{samples:S?.values??[],total:S?.total,unavailable:b??S?.unavailable,loading:!!x&&C.isPending,failed:C.isError}}function Vp({children:e}){return t.jsx(p.Box,{component:"span",sx:{fontFamily:Dt,fontSize:St.caption,color:"text.primary",bgcolor:rt.background.muted,border:"1px solid",borderColor:"divider",borderRadius:1,padding:"2px 8px"},children:e})}function Hp({run:e,fetchSamples:n,modelPath:r,sourceName:o,field:i,generation:l}){const{samples:a,total:d,unavailable:u,loading:h,failed:y}=Bp({run:e,fetchSamples:n,modelPath:r,sourceName:o,field:i,generation:l});return t.jsxs(p.Box,{"data-testid":"model-viewer-values",sx:{fontSize:St.small},children:[t.jsx(p.Box,{component:"div",sx:{color:ls,fontSize:St.caption,mb:"6px"},children:d!=null?`The most common of ${d.toLocaleString()} ${d===1?"value":"values"}`:"The most common values"}),h?t.jsx(p.CircularProgress,{size:12,sx:{color:"text.secondary"}}):u?t.jsx(p.Box,{component:"span","data-testid":"model-viewer-values-unavailable",sx:{color:"text.secondary"},children:u}):y?t.jsx(p.Box,{component:"span",sx:{fontStyle:"italic",color:"text.secondary"},children:"Sample values couldn't be loaded."}):a.length===0?t.jsx(p.Box,{component:"span",sx:{fontStyle:"italic",color:"text.secondary"},children:"No values found."}):t.jsx(p.Box,{sx:{display:"flex",flexWrap:"wrap",gap:"6px"},children:a.map(b=>t.jsx(Vp,{children:b},b))})]})}const Ns={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"}]}}},Up={...Ns,patterns:[...Ns.patterns,{include:"#docvar"}],repository:{...Ns.repository,docvar:{patterns:[{match:"\\<\\<[^(\\>\\>)]*\\>\\>",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"markup.italic.markdown"}]}}},Gp={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"}]}}},Yp="github-light",Kp="github-dark";let Ls;function Qp(){return Ls||(Ls=(async()=>{const[{createHighlighterCore:e},{createOnigurumaEngine:n},{default:r},{default:o},{default:i},{default:l},{default:a}]=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:n(Promise.resolve().then(()=>require("./wasm-Dw4u1m6u.cjs.js"))),themes:[l,a],langs:[r,o,i,{name:"malloy",scopeName:"source.malloy",embeddedLangs:["sql"],...Up},{name:"malloysql",scopeName:"source.malloy-sql",embeddedLangs:["sql"],...Gp}]})})()),Ls}async function To(e,n,r="light"){return(await Qp()).codeToHtml(e,{lang:n,theme:r==="dark"?Kp:Yp})}function Mr({code:e,testId:n,framed:r=!0}){const{mode:o}=q.usePublisherTheme(),[i,l]=j.useState(void 0);return j.useEffect(()=>{let a=!0;return To(e,"malloy",o).then(d=>a&&l(d)).catch(()=>a&&l(void 0)),()=>{a=!1}},[e,o]),t.jsx(p.Box,{"data-testid":n,sx:{fontFamily:Dt,fontSize:"0.75rem",overflowX:"auto","& pre":{m:0,background:"transparent !important"},...r&&{border:"1px solid",borderColor:"divider",borderRadius:1,px:1.5,py:1,bgcolor:"background.default"}},children:i?t.jsx("div",{dangerouslySetInnerHTML:{__html:i}}):t.jsx(p.Box,{component:"pre",sx:{whiteSpace:"pre"},children:e})})}function hs({message:e,onRetry:n,severity:r="error"}){return t.jsx(p.Alert,{severity:r,action:n&&t.jsx(p.Button,{color:"inherit",size:"small",onClick:n,children:"Retry"}),children:e})}function Yl(e){const n=e?.response?.data?.message;return typeof n=="string"&&n?n:void 0}function Kl(e,n){const r=Yl(n);return r?`${e}: ${r}`:`${e}.`}function Zp(e){const n=us(e);return!(n===400||n===401||n===403||n===404||n===422)}function Xp({query:e,error:n,onRetry:r,testId:o,forbiddenMessage:i}){const l=i!==void 0&&us(n)===403;return t.jsxs(p.Box,{"data-testid":o,sx:{display:"flex",flexDirection:"column",gap:1},children:[e&&t.jsx(Mr,{code:e,testId:"query-failure-code"}),t.jsx(hs,{message:l?i:Kl("Query failed",n),onRetry:r&&Zp(n)?r:void 0})]})}const Ca=j.forwardRef(function(n,r){return t.jsx(p.Button,{ref:r,variant:"contained",size:"small",disableElevation:!0,...n,sx:{textTransform:"none",...n.sx}})}),Jp=j.forwardRef(function(n,r){return t.jsx(p.Button,{ref:r,variant:"outlined",size:"small",color:"inherit",...n,sx:{textTransform:"none",borderRadius:999,borderColor:"divider",color:"text.secondary",...n.sx}})}),yr=10,eg="clamp(340px, 40%, 520px)";function tg({field:e,run:n,modelPath:r,sourceName:o,fieldCode:i,joined:l=!1}){const[a,d]=bo(),{fetchSamples:u,samplesGeneration:h,renderFieldStatus:y,renderFieldAction:b,renderFieldDetail:x}=cs(),v={modelPath:r,sourceName:o,field:e,joined:l},k=y?.(v),C=b?.(v),S=e.doc?void 0:i?.columnDoc,T=e.doc??S,O=So(i),M=j.useContext(vo),E=j.useMemo(()=>dn(i?.code,M),[i?.code,M]),R=wo(e)&&!l&&!!n,P=[...O?["code"]:[],...R?["values"]:[],...E.length>0?["givens"]:[]],A=$=>P.includes($),H=e.kind==="measure"?"measure":e.kind==="calculate"?"calculate":"dimension",D=P.length>0?t.jsxs(p.Box,{"data-testid":"model-viewer-field-card",sx:{...Pn,"& > * + *":{borderTop:1,borderColor:"divider"}},children:[A("code")&&(i?.loading?t.jsx(p.Box,{sx:{p:jr,display:"flex"},children:t.jsx(p.CircularProgress,{size:12,sx:{color:"text.secondary"}})}):i?.code?t.jsx(Mr,{testId:"model-viewer-definition",code:Dp(e.name,i.code),framed:!1}):i?.inheritedFrom?t.jsx(Mr,{testId:"model-viewer-definition",code:`${i.inheritedFrom.fromTable?"// A column of the table this source reads, as it is":"// Passed through from the query this source is built on"}
|
|
28
28
|
${i.inheritedFrom.code}`,framed:!1}):t.jsx(p.Box,{sx:{p:1},children:t.jsx(hs,{message:"Couldn't load this model's code right now."})})),A("values")&&n&&t.jsx(p.Box,{sx:{p:jr},children:t.jsx(Hp,{run:n,fetchSamples:u,generation:h,modelPath:r,sourceName:o,field:e})}),A("givens")&&t.jsx(go,{givens:E,framed:!1})]}):void 0,L=x?x(v,D):D,U=L!=null&&L!==!1;return t.jsxs(p.Box,{"data-testid":"model-viewer-field-row","data-name":e.name,sx:a&&U?{pb:1.25}:void 0,children:[t.jsx(Oo,{glyph:t.jsx(ko,{kind:H,dataType:e.dataType}),name:e.name,typeLabel:e.dataType,typeTip:e.typeTip,typeAsChip:!0,stackPills:!0,doc:T,generatedDoc:!!S,open:a,expandable:U,onToggle:()=>d($=>!$),descriptors:t.jsx(wl,{givens:E}),pills:k,action:C}),U&&t.jsx(p.Collapse,{in:a,timeout:"auto",unmountOnExit:!0,children:t.jsx(p.Box,{"data-testid":"model-viewer-field-detail",sx:{mx:`${yr}px`,mt:"2px",display:"flex",flexDirection:"column",gap:1.5},children:L})})]})}function Oo({glyph:e,name:n,typeLabel:r,typeAsChip:o=!1,stackPills:i=!1,typeTip:l,descriptors:a,pills:d,action:u,trailing:h,doc:y,generatedDoc:b=!1,open:x,expandable:v,onToggle:k}){const C=j.useId(),S=T=>{if(!v||T.target.closest("[data-row-action]"))return;const O=T.target.closest("button, a, [role='button']");O&&!O.hasAttribute("data-field-toggle")||k()};return t.jsxs(p.Box,{onClick:S,sx:{display:"flex",alignItems:x?"flex-start":"center",borderRadius:1.5,transition:"background 0.1s",cursor:v?"pointer":"default",...v?{"&:hover":{bgcolor:rt.background.muted},"&:hover [data-pill-tone='quiet']":{bgcolor:rt.background.strong}}:{}},children:[t.jsxs(p.Box,{sx:{display:"flex",flexDirection:i?"column":"row",alignItems:i?"stretch":"center",minWidth:0,flexShrink:0,width:{md:eg},overflow:{md:"hidden"}},children:[t.jsxs(p.Box,{component:v?"button":"div",type:v?"button":void 0,"aria-expanded":v?x:void 0,"aria-describedby":i?C:void 0,"data-field-toggle":v?"":void 0,sx:{appearance:"none",border:"none",background:"none",font:"inherit",color:"inherit",textAlign:"left",minWidth:0,px:`${yr}px`,py:"6px",borderRadius:1.5,...Tr,display:"flex",alignItems:"baseline",gap:"8px",flexWrap:i?"nowrap":"wrap",rowGap:"4px",cursor:v?"pointer":"default"},children:[e,t.jsxs(p.Box,{component:"span",sx:{display:"contents","& > *":{flexShrink:0},...i?{"& > *:first-of-type":{flexShrink:1,minWidth:0}}:{}},children:[t.jsx(p.Box,{component:"span",title:n,sx:{...Hm,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),r&&(o?t.jsx(p.Tooltip,{title:l?t.jsx(p.Box,{sx:{whiteSpace:"pre-line"},children:l}):"",children:t.jsx($t,{voice:"token",tone:"quiet",sx:{alignSelf:"center"},children:r})}):t.jsx(p.Box,{component:"span",sx:Al,children:r})),a]}),!i&&d]}),i?t.jsxs(p.Box,{id:C,sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px",px:`${yr}px`,pb:"6px",mt:"-2px","&:empty":{display:"none"}},children:[d,u&&t.jsx(p.Box,{component:"span","data-row-action":"",sx:{display:"inline-flex"},children:u})]}):u&&t.jsx(p.Box,{component:"span","data-row-action":"",sx:{display:"inline-flex"},children:u})]}),y&&t.jsxs(p.Box,{component:"span","data-testid":"model-viewer-field-doc",onMouseEnter:T=>{const O=T.currentTarget;O.title=!x&&Fp(O,y)?y:""},sx:{flex:1,minWidth:0,ml:1,pr:`${yr}px`,py:x?"6px":0,fontSize:St.small,color:ls,...x?{whiteSpace:"pre-line"}:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},children:[b&&t.jsx($t,{voice:"state",tone:"quiet","data-testid":"model-viewer-field-doc-generated",sx:{mr:.75,verticalAlign:"baseline"},children:"Generated"}),x?y:y.split(`
|
|
29
29
|
`)[0]]}),h&&t.jsx(p.Box,{sx:{ml:"auto",flexShrink:0,pl:1,pr:`${yr}px`,display:"inline-flex",alignItems:"center",height:32},children:h})]})}const ng=480;function rg({run:e,modelPath:n,query:r,sourceName:o,givens:i,givensUnknown:l,mode:a="result",renderCode:d,onShownChange:u}){const h=yo(e.givenValues),[y,b]=j.useState(a==="result"?h:null);a==="result"&&y===null&&b(h);const x=y!==null&&y!==h,v=o?e.requiredFiltersBySource?.get(o):void 0,[k,C]=j.useState(null),S=k===h,T=j.useMemo(()=>Fl(i??Co(e,o),v,e.givenValues,i?l:o?e.unknownGivensBySource?.get(o):void 0,S,i?"query":"source"),[e,o,i,l,v,S]),{result:O,isSuccess:M,isError:E,error:R,refetch:P}=Pp({run:e,modelPath:n,query:r,enabled:y===h&&T.kind!=="blocked"});y!==null&&y!==h&&O!==void 0&&b(h);const A=Qr(e.accessBySource,o),H=Dm(o,A),D=()=>x?b(h):void P(),[L,U]=j.useState(null);O!==void 0&&(L?.givensKey!==h||L.result!==O)&&U({result:O,givensKey:h});const $=T.kind==="blocked"?void 0:O!==void 0?{result:O,givensKey:h}:x&&L?{result:L.result,givensKey:L.givensKey}:void 0,W=$?.result,Q=j.useMemo(()=>$m(A,W),[A,W]),te=$?.givensKey??"";j.useEffect(()=>{if(u){if(W===void 0)return u(void 0);u({result:W,givensKey:te})}},[u,W,te]);const ee=a==="result"&&T.kind!=="blocked";return j.useEffect(()=>{ee&&c.warmMalloyRenderer()},[ee]),t.jsx(p.Box,{"data-testid":"model-viewer-run-result","data-mode":a,children:a==="code"?d?.():T.kind==="blocked"?t.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,flexWrap:"wrap"},children:[t.jsx(un,{"data-testid":"model-viewer-run-blocked",children:T.reason}),T.canRunAnyway&&t.jsx(Ca,{size:"small",onClick:()=>{C(h),b(h)},children:"Run anyway"})]}):E&&!x?t.jsx(Xp,{query:r,error:R,onRetry:()=>void P(),forbiddenMessage:H}):M&&!O&&!x?t.jsx(xr,{message:"The query returned no result."}):t.jsxs(p.Box,{"data-testid":"model-viewer-result-card",sx:{...Pn,p:jr,overflowX:"auto"},children:[x&&t.jsxs(p.Box,{"data-testid":"model-viewer-run-stale",sx:{display:"flex",alignItems:"center",gap:1.5,flexWrap:"wrap",mb:1},children:[t.jsx(un,{children:"The given values changed since this ran."}),t.jsx(Ca,{size:"small",onClick:D,"aria-label":"Run with these values",children:"Run"})]}),T.kind==="noted"&&W&&!x&&t.jsx(Cr,{"data-testid":"model-viewer-run-defaults",component:"div",sx:{mb:1},children:T.note}),!(x&&!W)&&(W===void 0?t.jsx(c.Loading,{text:c.LOADING_COPY.running}):t.jsx(c.ResultContainer,{result:W,maxHeight:ng,maxResultSize:e.maxResultSize})),Q&&t.jsx(Cr,{"data-testid":"model-viewer-run-filtered",component:"div",sx:{mt:1},children:Q})]})})}function sg(e){return{p:"3px",borderRadius:1,color:e?"text.primary":"text.secondary",bgcolor:e?rt.background.strong:"transparent","&:hover":{bgcolor:e?rt.background.strong:rt.background.muted,color:"text.primary"},"&.Mui-disabled":{color:"text.disabled"}}}function og({value:e,options:n,onChange:r,"aria-label":o}){return t.jsx(p.Box,{role:"group","aria-label":o,sx:{display:"inline-flex",gap:"2px"},children:n.map(i=>{const l=i.value===e,a=i.disabled===!0;return t.jsx(p.Tooltip,{title:a?i.disabledReason??i.label:i.label,children:t.jsx("span",{style:{display:"inline-flex"},children:t.jsx(p.IconButton,{size:"small",role:"button","aria-pressed":l,"aria-label":a?i.disabledReason??i.label:i.label,disabled:a,onClick:()=>r(i.value),sx:sg(l),children:i.icon})})},i.value)})})}const ig=["result","givens","fields","code","values","access"],ag={result:{icon:t.jsx(zl,{size:14}),label:"Result"},fields:{icon:t.jsx(bp,{size:14}),label:"Fields"},code:{icon:t.jsx(pp,{size:14}),label:"Code"},values:{icon:t.jsx(Cp,{size:14}),label:"Values"},givens:{icon:t.jsx(Tp,{size:14}),label:"Givens"},access:{icon:t.jsx(Sp,{size:14}),label:"Access"}};function Ql(e,n){const r=ig.filter(a=>e.includes(a)),[o,i]=j.useState(void 0),l=o!==void 0&&r.includes(o)?o:n!==void 0&&r.includes(n)?n:r[0];return{layers:r,layer:l,setLayer:i}}function Zl({layers:e,value:n,onChange:r,"aria-label":o,disabledReasons:i}){return e.length<2||n===void 0?null:t.jsx(og,{"aria-label":o,value:n,onChange:r,options:e.map(l=>{const a=i?.[l];return{value:l,...ag[l],...a?{disabled:!0,disabledReason:a}:{}}})})}function Xl({field:e,modelPath:n,sourceName:r,fieldCode:o,run:i,runQuery:l,runGivens:a,runGivensUnknown:d}){const u=l??c.viewRunQuery(r,e.name),h=a??(i&&Co(i,r)),y=j.useMemo(()=>i&&Ul(i,h),[i,h]),b=l?"query":"view",[x,v]=bo(),[k,C]=j.useState(void 0),S=So(o),T=j.useContext(vo),{renderRunActions:O}=cs(),{server:M}=q.useServer(),E=j.useMemo(()=>dn(o?.code,T),[o?.code,T]),{chartNames:R,tagsInFull:P}=j.useMemo(()=>{const W=e.tags??[],Q=Xf(W),te=Q.length>0?Q:W;return{chartNames:te,tagsInFull:W.join(" ")===te.join(" ")?void 0:W.map(ee=>`# ${ee}`).join(`
|
|
30
30
|
`)}},[e.tags]),A=["result","code",...E.length>0?["givens"]:[]],{layers:H,layer:D,setLayer:L}=Ql(A,i?"result":"code"),U=D??"code",$=()=>U==="givens"?t.jsx(go,{givens:E}):o?.loading?t.jsx(p.CircularProgress,{size:12,sx:{color:"text.secondary"}}):o?.code?t.jsx(Mr,{testId:"model-viewer-definition",code:l?o.code:$p(e.name,o.code)}):o?.error?t.jsx(hs,{message:"Couldn't load this model's code right now."}):t.jsx(xr,{message:`No Malloy code to show for this ${b}.`});return t.jsxs(p.Box,{"data-testid":"model-viewer-view-row","data-name":e.name,sx:x?{pb:1.5}:void 0,children:[t.jsx(Oo,{glyph:t.jsx(ko,{kind:"view"}),name:e.name,doc:e.doc,open:x,expandable:!0,onToggle:()=>v(W=>!W),trailing:x&&t.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:"2px"},children:[t.jsx(Zl,{"aria-label":`Show for ${e.name}`,layers:H,value:U,onChange:L,disabledReasons:{result:i?void 0:`This ${b} can't be run here`,code:S?void 0:`No Malloy code to show for this ${b}`}}),y&&O?.({kind:l?"query":"view",modelPath:n,sourceName:l?"":r,name:e.name,query:u,givens:y.givenValues,queryKey:jo(M,y,n,u),shown:k})]}),descriptors:t.jsxs(t.Fragment,{children:[R.map(W=>{const Q=t.jsx($t,{voice:"token",tone:"quiet",sx:{alignSelf:"center"},children:W},W);return P?t.jsx(p.Tooltip,{title:P,slotProps:{tooltip:{sx:{whiteSpace:"pre-line",fontFamily:Dt}}},children:Q},W):Q}),t.jsx(wl,{givens:E})]})}),t.jsx(p.Collapse,{in:x,timeout:"auto",mountOnEnter:!0,children:t.jsx(p.Box,{"data-testid":"model-viewer-view-card",sx:{mx:"10px",mt:1,minWidth:0},children:t.jsx(p.Box,{sx:{minWidth:0,overflowX:"auto"},children:y?t.jsx(rg,{run:y,modelPath:n,query:u,sourceName:r||void 0,givens:a,givensUnknown:d,mode:U==="result"?"result":"code",renderCode:$,onShownChange:C}):$()})})})]})}function lg({queries:e,sourceText:n,modelPath:r,run:o}){const{parsed:i,pending:l}=Vl(n,e.length>0),a=j.useMemo(()=>e.map(u=>{const h=Ip(i,u.name),y=u.sourceName||!o?.givens||l?void 0:wm(h,o.givens,o.givensBySource,o.unknownGivensBySource);return{query:u,field:{name:u.name,kind:"view",doc:u.doc,tags:u.tags},code:{code:h,loading:l},runGivens:y?.givens,runGivensUnknown:y?.unknown}}),[e,i,l,o?.givens,o?.givensBySource,o?.unknownGivensBySource]),d=ns({noun:["query","queries"]});return t.jsx(Ln,{label:"Queries",count:e.length,testId:"model-viewer-queries",action:d.action,children:t.jsx(Or.Provider,{value:d.command,children:a.map(({query:u,field:h,code:y,runGivens:b,runGivensUnknown:x})=>t.jsx(Xl,{field:h,modelPath:r,sourceName:u.sourceName??"",fieldCode:y,run:o,runQuery:c.namedQueryRunQuery(u.name),runGivens:b,runGivensUnknown:x},u.name))})})}function Jl(e){const{entities:n,loading:r,error:o,columnDescriptions:i,declarations:l,declarationsLoading:a}=e;return d=>{const u=n?.get(d.name),h=l?.get(d.name);if(!u&&!r&&h&&h.kind===d.kind)return{code:h.code,loading:!1,error:!1,inherited:!1};if(!u&&!r&&!o&&a)return{loading:!0,error:!1,inherited:!1};const y=u?.fieldType==="column";return{code:y?void 0:u?.code??void 0,inheritedFrom:y&&u?.code?{code:u.code,fromTable:!!u.table||u.code!==d.name}:void 0,loading:!o&&r,error:o,inherited:y,columnDoc:y?i?.get(d.name):void 0}}}const ja=200;function br({label:e,noun:n,items:r,run:o,modelPath:i,sourceName:l,getFieldCode:a,level:d}){const{showField:u}=cs(),h=j.useMemo(()=>u?r.filter(O=>u({modelPath:i,sourceName:l,field:O,joined:d==="h3"})):r,[r,u,i,l,d]),[y,b]=j.useState(!1),x=h.some(O=>wo(O)&&d!=="h3"||So(a?.(O))),{command:v,action:k}=ns({noun:n,disabledReason:x?void 0:`None of these ${n[1]} has anything to show`}),C=d!=="h3"?k:void 0,S=j.useMemo(()=>a?Ap(h,a):h,[h,a]),T=y||S.length<=ja?S:S.slice(0,ja);return t.jsx(Ln,{label:e,count:h.length,level:d,action:C,children:t.jsx(Or.Provider,{value:v,children:t.jsxs(p.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px"},children:[T.map(O=>t.jsx(tg,{field:O,run:o,modelPath:i,sourceName:l,fieldCode:a?.(O),joined:d==="h3"},O.name)),T.length<S.length&&t.jsxs(p.Button,{size:"small",onClick:()=>b(!0),sx:{alignSelf:"flex-start",textTransform:"none"},children:["Show all ",S.length.toLocaleString()," ",n[1]]})]})})})}function cg(e,n){const r=new Map;if(!e||!n)return r;const o=new Map;for(const l of e.symbols)l.type==="explore"&&o.set(Mo(l.name),l);const i=new Set;for(let l=n;l&&!i.has(l);){i.add(l);const a=o.get(l);if(!a)break;for(const[d,u]of dg(e.lines,a))r.has(d)||r.set(d,u);l=vg(ds(e.lines,a.range))}return r}const Ta=/^\s*(view|measure|dimension)\s*:\s*$/,ug=/^`?([A-Za-z_]\w*)`?\s+is\b/;function dg(e,n){const r=new Map;let o,i=n.range.start;for(const a of n.children){const d=ds(e,{start:i,end:a.range.start});o=gg(d)??o,i=a.range.end;const u=hg(a,o);if(!u)continue;const h=fg(e,a,u);if(!h)continue;const y=Mo(a.name);r.set(y,r.has(y)?null:h)}const l=new Map;for(const[a,d]of r)d&&l.set(a,d);return l}function hg(e,n){if(e.type==="query")return n==="view"?"view":void 0;if(e.type==="field"&&(n==="dimension"||n==="measure"))return n}function fg(e,n,r){const o=ds(e,n.range).split(`
|
|
@@ -45,7 +45,7 @@ ${i.inheritedFrom.code}`,framed:!1}):t.jsx(p.Box,{sx:{p:1},children:t.jsx(hs,{me
|
|
|
45
45
|
|
|
46
46
|
limit: ${r}
|
|
47
47
|
}
|
|
48
|
-
`}function dx(e,n){const r=new Map;for(const y of n){const b=hn(y);r.set(b,[])}const o=JSON.parse(e),i=o.schema.fields,l=new Map;i.forEach((y,b)=>{l.set(y.name,b)});const a=y=>{if(!y)return null;switch(y.kind){case"string_cell":return y.string_value??null;case"number_cell":return y.number_value??null;case"boolean_cell":return y.boolean_value??null;case"null_cell":return null;default:return console.log("Unknown cell kind: "+y.kind),null}},u=(o.data?.array_value||[]).map(y=>{const b={};return y.kind==="record_cell"&&y.record_value&&y.record_value.forEach((x,v)=>{const k=i[v]?.name;if(k){const C=a(x);k==="fieldName"&&typeof C=="string"?b.fieldName=C:k==="fieldPath"&&typeof C=="string"?b.fieldPath=C:k==="fieldType"&&typeof C=="string"?b.fieldType=C:k==="fieldValue"&&typeof C=="string"?b.fieldValue=C:k==="weight"&&typeof C=="number"&&(b.weight=C)}}),b}),h=u.length===0||u.every(y=>!y.fieldName);for(const y of n){if(y.filterType==="NONE"||y.filterType==="Retrieval")continue;const b=u.filter(v=>{const k=v.fieldName||"",C=v.fieldPath||"";if(k===y.dimensionName||C===y.dimensionName||k.toLowerCase()===y.dimensionName.toLowerCase()||C.toLowerCase()===y.dimensionName.toLowerCase())return!0;const S=C.split(".").pop()||"";return S===y.dimensionName||S.toLowerCase()===y.dimensionName.toLowerCase()});if(b.length===0)continue;const x=hn(y);if(y.filterType==="Star"){const v=b.filter(k=>k.fieldType==="string").map(k=>({value:k.fieldValue??"",count:k.weight})).sort((k,C)=>(C.count??0)-(k.count??0));r.set(x,v)}else if(y.filterType==="MinMax"){console.log("MinMax dimensionEntries: "+JSON.stringify(b,null,2)),console.log("All MinMax dimension entries fieldTypes:",b.map(k=>k.fieldType));const v=b.find(k=>k.fieldType==="number");if(console.log("numericEntry: "+JSON.stringify(v,null,2)),v?.fieldValue){const k=v.fieldValue,C=k.split(" to ");if(console.log("rangeParts: "+C),C.length===2){const S=[{value:parseFloat(C[0])},{value:parseFloat(C[1])}];r.set(x,S)}else console.warn(`Could not parse numeric range for ${y.dimensionName}: ${k}`)}else console.warn(`No numeric entry found for ${y.dimensionName}. Available entries:`,b)}else if(y.filterType==="DateMinMax"){const v=b.find(k=>k.fieldType==="date"||k.fieldType==="timestamp"||k.fieldType==="string");if(console.log("dateEntry: "+JSON.stringify(v,null,2)),console.log("All date dimension entries fieldTypes:",b.map(k=>k.fieldType)),v?.fieldValue){const k=v.fieldValue,C=k.split(" to ");if(console.log("date rangeParts: "+C),C.length===2){const S=[{value:new Date(C[0].trim())},{value:new Date(C[1].trim())}];r.set(x,S)}else console.warn(`Could not parse date range for ${y.dimensionName}: ${k}`)}else console.warn(`No date entry found for ${y.dimensionName}. Available entries:`,b)}}return{values:r,noRowsMatchedFilter:h}}function vc(e){const{environment:n,package:r,dimensionSpecs:o,versionId:i,enabled:l=!0,indexLimit:a=1e4,activeFilters:d=[]}=e,u=j.useMemo(()=>cx(o),[o]),h=j.useMemo(()=>{const C=[];for(const[S,T]of u){const[O,M]=S.split("|"),E=ux(O,T,a,d);E?C.push({key:S,source:O,model:M,query:E,specs:T}):console.log("No query for source: ",O,"model: ",M)}return C},[u,a,d]),y=j.useMemo(()=>l&&h.length>0&&o.some(C=>C.filterType==="Star"||C.filterType==="MinMax"||C.filterType==="DateMinMax"),[l,h,o]),{apiClients:b}=q.useServer(),x=c.useQueryWithApiError({queryKey:["dimensionalFilter",n,r,o,i,d],queryFn:async({signal:C})=>{if(!y){const M=new Map;for(const E of o){const R=hn(E);M.set(R,[])}return{values:M,noRowsMatchedFilter:!1}}const S=await Promise.all(h.map(async M=>{const E=await b.models.executeQueryModel(n,r,M.model,{query:M.query,versionId:i,bypassFilters:!0},void 0,{signal:C});return{config:M,result:dx(E.data.result,M.specs)}})),T=new Map;let O=!1;for(const{result:M}of S){for(const[E,R]of M.values)T.set(E,R);M.noRowsMatchedFilter&&(O=!0)}return{values:T,noRowsMatchedFilter:O}},enabled:y,staleTime:300*1e3,placeholderData:C=>C}),v=x.data?.values;return{data:j.useMemo(()=>{const C=new Map;for(const S of o){const T=hn(S);S.values?C.set(T,S.values.map(O=>({value:O}))):C.set(T,[])}if(v)for(const[S,T]of v)T.length>0&&C.set(S,T);return C},[o,v]),noRowsMatchedFilter:x.data?.noRowsMatchedFilter??!1,isLoading:y?x.isPending:!1,isError:y?x.isError:!1,error:y?x.error:null,refetch:x.refetch}}function hx(e){return is(`\`${e.dimensionName}\``,e)}function bc(e){const{dimensionSpecs:n}=e,[r,o]=j.useState(()=>{const h=new Map;return n.forEach(y=>{const b=hn(y);h.set(b,{spec:y,selection:null})}),h});j.useEffect(()=>{o(h=>{const y=new Map;return n.forEach(b=>{const x=hn(b),v=h.get(x);y.set(x,{spec:b,selection:v?.selection??null})}),y})},[n]);const i=j.useCallback((h,y)=>{o(b=>{const x=new Map(b),v=x.get(h);return v&&x.set(h,{...v,selection:y}),x})},[]),l=j.useCallback(h=>{i(h,null)},[i]),a=j.useCallback(()=>{o(h=>{const y=new Map(h);return y.forEach((b,x)=>{y.set(x,{...b,selection:null})}),y})},[]),d=j.useCallback(()=>{const h=[];return r.forEach(y=>{y.selection&&h.push(y.selection)}),h},[r]),u=j.useCallback(()=>{const h=d();if(h.length===0)return"";const y=h.map(b=>hx(b)).filter(b=>b.length>0);return y.length===0?"":`where ${y.join(" and ")}`},[d]);return{filterStates:r,updateFilter:i,clearFilter:l,clearAllFilters:a,getActiveFilters:d,generateWhereClause:u}}function fx(e){return is(`\`${e.dimensionName}\``,e)}function mx(e){if(e.length===0)return"";const n=e.map(r=>fx(r)).filter(r=>r.length>0);return n.length===0?"":n.join(" and ")}function px(e,n,r,o=1e3){const i=mx(n),a=r&&r.length>0?`group_by: ${r.map(d=>`\`${d}\``).join(", ")}`:"select: *";return i?`
|
|
48
|
+
`}function dx(e,n){const r=new Map;for(const y of n){const b=hn(y);r.set(b,[])}const o=JSON.parse(e),i=o.schema.fields,l=new Map;i.forEach((y,b)=>{l.set(y.name,b)});const a=y=>{if(!y)return null;switch(y.kind){case"string_cell":return y.string_value??null;case"number_cell":return y.number_value??null;case"boolean_cell":return y.boolean_value??null;case"null_cell":return null;default:return console.log("Unknown cell kind: "+y.kind),null}},u=(o.data?.array_value||[]).map(y=>{const b={};return y.kind==="record_cell"&&y.record_value&&y.record_value.forEach((x,v)=>{const k=i[v]?.name;if(k){const C=a(x);k==="fieldName"&&typeof C=="string"?b.fieldName=C:k==="fieldPath"&&typeof C=="string"?b.fieldPath=C:k==="fieldType"&&typeof C=="string"?b.fieldType=C:k==="fieldValue"&&typeof C=="string"?b.fieldValue=C:k==="weight"&&typeof C=="number"&&(b.weight=C)}}),b}),h=u.length===0||u.every(y=>!y.fieldName);for(const y of n){if(y.filterType==="NONE"||y.filterType==="Retrieval")continue;const b=u.filter(v=>{const k=v.fieldName||"",C=v.fieldPath||"";if(k===y.dimensionName||C===y.dimensionName||k.toLowerCase()===y.dimensionName.toLowerCase()||C.toLowerCase()===y.dimensionName.toLowerCase())return!0;const S=C.split(".").pop()||"";return S===y.dimensionName||S.toLowerCase()===y.dimensionName.toLowerCase()});if(b.length===0)continue;const x=hn(y);if(y.filterType==="Star"){const v=b.filter(k=>k.fieldType==="string").map(k=>({value:k.fieldValue??"",count:k.weight})).sort((k,C)=>(C.count??0)-(k.count??0));r.set(x,v)}else if(y.filterType==="MinMax"){console.log("MinMax dimensionEntries: "+JSON.stringify(b,null,2)),console.log("All MinMax dimension entries fieldTypes:",b.map(k=>k.fieldType));const v=b.find(k=>k.fieldType==="number");if(console.log("numericEntry: "+JSON.stringify(v,null,2)),v?.fieldValue){const k=v.fieldValue,C=k.split(" to ");if(console.log("rangeParts: "+C),C.length===2){const S=[{value:parseFloat(C[0])},{value:parseFloat(C[1])}];r.set(x,S)}else console.warn(`Could not parse numeric range for ${y.dimensionName}: ${k}`)}else console.warn(`No numeric entry found for ${y.dimensionName}. Available entries:`,b)}else if(y.filterType==="DateMinMax"){const v=b.find(k=>k.fieldType==="date"||k.fieldType==="timestamp"||k.fieldType==="string");if(console.log("dateEntry: "+JSON.stringify(v,null,2)),console.log("All date dimension entries fieldTypes:",b.map(k=>k.fieldType)),v?.fieldValue){const k=v.fieldValue,C=k.split(" to ");if(console.log("date rangeParts: "+C),C.length===2){const S=[{value:new Date(C[0].trim())},{value:new Date(C[1].trim())}];r.set(x,S)}else console.warn(`Could not parse date range for ${y.dimensionName}: ${k}`)}else console.warn(`No date entry found for ${y.dimensionName}. Available entries:`,b)}}return{values:r,noRowsMatchedFilter:h}}function vc(e){const{environment:n,package:r,dimensionSpecs:o,versionId:i,enabled:l=!0,indexLimit:a=1e4,activeFilters:d=[]}=e,u=j.useMemo(()=>cx(o),[o]),h=j.useMemo(()=>{const C=[];for(const[S,T]of u){const[O,M]=S.split("|"),E=ux(O,T,a,d);E?C.push({key:S,source:O,model:M,query:E,specs:T}):console.log("No query for source: ",O,"model: ",M)}return C},[u,a,d]),y=j.useMemo(()=>l&&h.length>0&&o.some(C=>C.filterType==="Star"||C.filterType==="MinMax"||C.filterType==="DateMinMax"),[l,h,o]),{apiClients:b}=q.useServer(),x=c.useQueryWithApiError({queryKey:["dimensionalFilter",n,r,o,i,d],queryFn:async({signal:C})=>{if(!y){const M=new Map;for(const E of o){const R=hn(E);M.set(R,[])}return{values:M,noRowsMatchedFilter:!1}}const S=await Promise.all(h.map(async M=>{const E=await b.models.executeQueryModel(n,r,M.model,{query:M.query,versionId:i,bypassFilters:!0},void 0,void 0,{signal:C});return{config:M,result:dx(E.data.result,M.specs)}})),T=new Map;let O=!1;for(const{result:M}of S){for(const[E,R]of M.values)T.set(E,R);M.noRowsMatchedFilter&&(O=!0)}return{values:T,noRowsMatchedFilter:O}},enabled:y,staleTime:300*1e3,placeholderData:C=>C}),v=x.data?.values;return{data:j.useMemo(()=>{const C=new Map;for(const S of o){const T=hn(S);S.values?C.set(T,S.values.map(O=>({value:O}))):C.set(T,[])}if(v)for(const[S,T]of v)T.length>0&&C.set(S,T);return C},[o,v]),noRowsMatchedFilter:x.data?.noRowsMatchedFilter??!1,isLoading:y?x.isPending:!1,isError:y?x.isError:!1,error:y?x.error:null,refetch:x.refetch}}function hx(e){return is(`\`${e.dimensionName}\``,e)}function bc(e){const{dimensionSpecs:n}=e,[r,o]=j.useState(()=>{const h=new Map;return n.forEach(y=>{const b=hn(y);h.set(b,{spec:y,selection:null})}),h});j.useEffect(()=>{o(h=>{const y=new Map;return n.forEach(b=>{const x=hn(b),v=h.get(x);y.set(x,{spec:b,selection:v?.selection??null})}),y})},[n]);const i=j.useCallback((h,y)=>{o(b=>{const x=new Map(b),v=x.get(h);return v&&x.set(h,{...v,selection:y}),x})},[]),l=j.useCallback(h=>{i(h,null)},[i]),a=j.useCallback(()=>{o(h=>{const y=new Map(h);return y.forEach((b,x)=>{y.set(x,{...b,selection:null})}),y})},[]),d=j.useCallback(()=>{const h=[];return r.forEach(y=>{y.selection&&h.push(y.selection)}),h},[r]),u=j.useCallback(()=>{const h=d();if(h.length===0)return"";const y=h.map(b=>hx(b)).filter(b=>b.length>0);return y.length===0?"":`where ${y.join(" and ")}`},[d]);return{filterStates:r,updateFilter:i,clearFilter:l,clearAllFilters:a,getActiveFilters:d,generateWhereClause:u}}function fx(e){return is(`\`${e.dimensionName}\``,e)}function mx(e){if(e.length===0)return"";const n=e.map(r=>fx(r)).filter(r=>r.length>0);return n.length===0?"":n.join(" and ")}function px(e,n,r,o=1e3){const i=mx(n),a=r&&r.length>0?`group_by: ${r.map(d=>`\`${d}\``).join(", ")}`:"select: *";return i?`
|
|
49
49
|
run: ${e} -> {
|
|
50
50
|
where: ${i}
|
|
51
51
|
${a}
|
|
@@ -56,4 +56,4 @@ ${i.inheritedFrom.code}`,framed:!1}):t.jsx(p.Box,{sx:{p:1},children:t.jsx(hs,{me
|
|
|
56
56
|
${a}
|
|
57
57
|
limit: ${o}
|
|
58
58
|
}
|
|
59
|
-
`}function wc(e){const{environment:n,package:r,model:o,source:i,filterSelections:l,fields:a,limit:d=1e3,versionId:u}=e,[h,y]=j.useState(null),b=j.useMemo(()=>px(i,l,a,d),[i,l,a,d]),x=j.useMemo(()=>c.encodeResourceUri({environmentName:n,packageName:r,modelPath:o,versionId:u}),[n,r,o,u]),v=l.length>0,k=j.useCallback(()=>{if(!v){y(null);return}const C=mc({resourceUri:x,query:b});y(C)},[v,x,b]);return{embeddedQueryResult:h,queryString:b,resourceUri:x,executeQuery:k,canExecute:v}}function gx(e,n=5e3){const r=e.dimensionSpecs[0]?.source??"",o=e.dimensionSpecs[0]?.model??"",{filterStates:i,updateFilter:l,clearAllFilters:a,getActiveFilters:d}=bc({dimensionSpecs:e.dimensionSpecs}),u=j.useMemo(()=>d(),[i,d]),{data:h,noRowsMatchedFilter:y,isLoading:b,isError:x,error:v,refetch:k}=vc({environment:e.environment,package:e.package,indexLimit:e.indexLimit,dimensionSpecs:e.dimensionSpecs,versionId:e.versionId,activeFilters:u}),C=b&&!h,{embeddedQueryResult:S,queryString:T,executeQuery:O,canExecute:M}=wc({environment:e.environment,package:e.package,model:o,source:r,filterSelections:u,limit:n,fields:e.selectFields,versionId:e.versionId});return{filterStates:i,updateFilter:l,clearAllFilters:a,activeFilters:u,data:h,noRowsMatchedFilter:y,isLoading:b,isInitialLoading:C,isError:x,error:v,refetch:k,embeddedQueryResult:S,queryString:T,executeQuery:O,canExecute:M}}function yx({modelPath:e,query:n,sourceName:r,queryName:o,enabled:i=!0,resourceUri:l}){const{environmentName:a,packageName:d,versionId:u}=c.parseResourceUri(l),{apiClients:h}=q.useServer(),{data:y,isSuccess:b,isError:x,error:v,isLoading:k}=c.useQueryWithApiError({queryKey:["rawQueryData",a,d,e,u,n,r,o],queryFn:({signal:S})=>h.models.executeQueryModel(a,d,e,{query:n,sourceName:r,queryName:o,versionId:u},void 0,{signal:S}),enabled:i});return{data:b&&y?.data?.result?(()=>{try{return JSON.parse(y.data.result).data?.array_value||[]}catch(S){return console.error("Failed to parse query result:",S),[]}})():[],isSuccess:b,isError:x,error:v,isLoading:k}}exports.AddButton=c.AddButton;exports.ApiErrorDisplay=c.ApiErrorDisplay;exports.AppDialog=c.AppDialog;exports.DRILL_SELF=c.DRILL_SELF;exports.DashboardTile=c.DashboardTile;exports.DocumentNotFoundError=c.DocumentNotFoundError;exports.DocumentStorageProvider=c.DocumentStorageProvider;exports.GivenInput=c.GivenInput;exports.GivensPanel=c.GivensPanel;exports.INITIAL_RENDER_HEIGHT=c.INITIAL_RENDER_HEIGHT;exports.LOADING_COPY=c.LOADING_COPY;exports.Loading=c.Loading;exports.MODEL_CELL_MAX_HEIGHT=c.MODEL_CELL_MAX_HEIGHT;exports.MOTION_FAST=c.MOTION_FAST;exports.NOTEBOOK_CELL_MAX_HEIGHT=c.NOTEBOOK_CELL_MAX_HEIGHT;exports.Prose=c.Prose;exports.REPORT_EDIT_PARAM=c.REPORT_EDIT_PARAM;exports.RESTRICTED_NOTICE=c.RESTRICTED_NOTICE;exports.RESULTS_DIALOG_MAX_HEIGHT=c.RESULTS_DIALOG_MAX_HEIGHT;exports.ResultContainer=c.ResultContainer;exports.ResultPanel=c.ResultPanel;exports.STICKY_CONTROLS_Z=c.STICKY_CONTROLS_Z;exports.STICKY_TOP_VAR=c.STICKY_TOP_VAR;exports.SecondaryButton=c.SecondaryButton;exports.TILE_MAX_HEIGHT=c.TILE_MAX_HEIGHT;exports.TILE_MIN_HEIGHT=c.TILE_MIN_HEIGHT;exports.TileCard=c.TileCard;exports.TileFilterTag=c.TileFilterTag;exports.TileHeading=c.TileHeading;exports.UNCAPPED_CONTAINER_HEIGHT=c.UNCAPPED_CONTAINER_HEIGHT;exports.UnsavedChangesDialog=c.UnsavedChangesDialog;exports.buildTableCssVars=c.buildTableCssVars;exports.clearReportDraft=c.clearReportDraft;exports.contentNodeDepth=c.contentNodeDepth;exports.dangerTextColor=c.dangerTextColor;exports.documentPreamble=c.documentPreamble;exports.documentSlug=c.documentSlug;exports.draftStorageAvailable=c.draftStorageAvailable;exports.drillDestinations=c.drillDestinations;exports.drillValueToFilter=c.drillValueToFilter;exports.encodeDrillValue=c.encodeDrillValue;exports.encodeResourceUri=c.encodeResourceUri;exports.humanizeSlug=c.humanizeSlug;exports.initialResultHeight=c.initialResultHeight;exports.isDocumentNotFound=c.isDocumentNotFound;exports.isDrillTargetPath=c.isDrillTargetPath;exports.localGivenSpec=c.localGivenSpec;exports.locateReport=c.locateReport;exports.malloyIdentifier=c.malloyIdentifier;exports.malloyLiteral=c.malloyLiteral;exports.measureContentHeight=c.measureContentHeight;exports.parseResourceUri=c.parseResourceUri;exports.queryResultKey=c.queryResultKey;exports.reducedMotionSx=c.reducedMotionSx;exports.remeasuresAfterReady=c.remeasuresAfterReady;exports.reportClasses=c.reportClasses;exports.reportDraftKey=c.reportDraftKey;exports.reportEditRoute=c.reportEditRoute;exports.reportRoute=c.reportRoute;exports.reportRoutePath=c.reportRoutePath;exports.resolveDrill=c.resolveDrill;exports.resolveDrillTarget=c.resolveDrillTarget;exports.resolveResultHeight=c.resolveResultHeight;exports.resultSizing=c.resultSizing;exports.scrollBehavior=c.scrollBehavior;exports.tileIgnoredFilterLabels=c.tileIgnoredFilterLabels;exports.useCompiledDocument=c.useCompiledDocument;exports.useDocumentControls=c.useDocumentControls;exports.useDocumentLocation=c.useDocumentLocation;exports.useDocumentStorage=c.useDocumentStorage;exports.useDrillSelf=c.useDrillSelf;exports.useGivensState=c.useGivensState;exports.useOptionalDocumentStorage=c.useOptionalDocumentStorage;exports.useQueryResult=c.useQueryResult;exports.useReportListing=c.useReportListing;exports.useSuggestOptions=c.useSuggestOptions;exports.visibleWithoutHoverSx=c.visibleWithoutHoverSx;exports.withPreamble=c.withPreamble;exports.DEFAULT_THEME=q.DEFAULT_THEME;exports.DEFAULT_UI=q.DEFAULT_UI;exports.MONO_FONT_FAMILY=q.MONO_FONT_FAMILY;exports.PALETTE=q.PALETTE;exports.SURFACE_TINT=q.SURFACE_TINT;exports.ServerProvider=q.ServerProvider;exports.ThemeProvider=q.ThemeProvider;exports.accentFor=q.accentFor;exports.contrastRatio=q.contrastRatio;exports.mergeUi=q.mergeUi;exports.resolveMode=q.resolveMode;exports.resolveTheme=q.resolveTheme;exports.usePublisherTheme=q.usePublisherTheme;exports.useServer=q.useServer;exports.canRetryRequest=oo.canRetryRequest;exports.DRILL_CELL_CLASS=fn.DRILL_CELL_CLASS;exports.RenderedResult=fn.RenderedResult;exports.buildMalloyExplicitTheme=fn.buildMalloyExplicitTheme;exports.buildVegaThemeOverride=fn.buildVegaThemeOverride;exports.drillableFieldNames=fn.drillableFieldNames;exports.markDrillableCells=fn.markDrillableCells;exports.readChartAnnotations=fn.readChartAnnotations;exports.BackLink=rd;exports.BrowserDocumentStorage=By;exports.ConnectionExplorer=tl;exports.DOC_LINKS=Vt;exports.Dashboard=Gy;exports.DashboardView=rs;exports.DataAppViewer=$d;exports.DimensionFilter=Qh;exports.DownloadRowsCsv=Ua;exports.EmbeddedQueryResult=Uy;exports.Environment=Th;exports.Home=df;exports.Materializations=gl;exports.Model=ay;exports.ModelExplorer=Io;exports.ModelExplorerDialog=Do;exports.ModelViewer=nc;exports.NarrowEditGate=sd;exports.NewDocumentDialog=ic;exports.Notebook=rx;exports.Package=Py;exports.Packages=nl;exports.QueryResult=pc;exports.Report=oc;exports.SourcesExplorer=sc;exports.VersionSwitch=fc;exports.createEmbeddedQueryResult=mc;exports.documentRoute=ix;exports.extractDimensionSpecs=tf;exports.extractSourceFromQuery=rf;exports.generateFilterClause=nf;exports.getDimensionKey=hn;exports.getJoinedSources=Zh;exports.groupEntitiesBySource=kl;exports.injectWhereClause=sf;exports.isNarrowScreen=Ra;exports.legacyAliasOf=ox;exports.locateDocument=ax;exports.locateReportByName=xc;exports.modelQueryKey=tc;exports.packageFileUrl=Qa;exports.packageVersionsQueryKey=$o;exports.parseAllSourceInfos=ef;exports.parseDimensionFilterAnnotation=rl;exports.parseNotebookFilterAnnotation=Xh;exports.runQueryKey=jo;exports.setConsoleEventHandler=Gd;exports.useDimensionFilters=bc;exports.useDimensionFiltersFromSpec=gx;exports.useDimensionFiltersQuery=wc;exports.useDimensionalFilterRangeData=vc;exports.useDraftLayout=Hy;exports.useDrill=io;exports.useGivenUrlParams=fd;exports.useInvalidatePackage=hc;exports.useModelData=Eo;exports.useModelGivens=gc;exports.useNarrowScreen=Fa;exports.usePackageVersions=dc;exports.useRawQueryData=yx;exports.useRouterClickHandler=od;
|
|
59
|
+
`}function wc(e){const{environment:n,package:r,model:o,source:i,filterSelections:l,fields:a,limit:d=1e3,versionId:u}=e,[h,y]=j.useState(null),b=j.useMemo(()=>px(i,l,a,d),[i,l,a,d]),x=j.useMemo(()=>c.encodeResourceUri({environmentName:n,packageName:r,modelPath:o,versionId:u}),[n,r,o,u]),v=l.length>0,k=j.useCallback(()=>{if(!v){y(null);return}const C=mc({resourceUri:x,query:b});y(C)},[v,x,b]);return{embeddedQueryResult:h,queryString:b,resourceUri:x,executeQuery:k,canExecute:v}}function gx(e,n=5e3){const r=e.dimensionSpecs[0]?.source??"",o=e.dimensionSpecs[0]?.model??"",{filterStates:i,updateFilter:l,clearAllFilters:a,getActiveFilters:d}=bc({dimensionSpecs:e.dimensionSpecs}),u=j.useMemo(()=>d(),[i,d]),{data:h,noRowsMatchedFilter:y,isLoading:b,isError:x,error:v,refetch:k}=vc({environment:e.environment,package:e.package,indexLimit:e.indexLimit,dimensionSpecs:e.dimensionSpecs,versionId:e.versionId,activeFilters:u}),C=b&&!h,{embeddedQueryResult:S,queryString:T,executeQuery:O,canExecute:M}=wc({environment:e.environment,package:e.package,model:o,source:r,filterSelections:u,limit:n,fields:e.selectFields,versionId:e.versionId});return{filterStates:i,updateFilter:l,clearAllFilters:a,activeFilters:u,data:h,noRowsMatchedFilter:y,isLoading:b,isInitialLoading:C,isError:x,error:v,refetch:k,embeddedQueryResult:S,queryString:T,executeQuery:O,canExecute:M}}function yx({modelPath:e,query:n,sourceName:r,queryName:o,enabled:i=!0,resourceUri:l}){const{environmentName:a,packageName:d,versionId:u}=c.parseResourceUri(l),{apiClients:h}=q.useServer(),{data:y,isSuccess:b,isError:x,error:v,isLoading:k}=c.useQueryWithApiError({queryKey:["rawQueryData",a,d,e,u,n,r,o],queryFn:({signal:S})=>h.models.executeQueryModel(a,d,e,{query:n,sourceName:r,queryName:o,versionId:u},void 0,void 0,{signal:S}),enabled:i});return{data:b&&y?.data?.result?(()=>{try{return JSON.parse(y.data.result).data?.array_value||[]}catch(S){return console.error("Failed to parse query result:",S),[]}})():[],isSuccess:b,isError:x,error:v,isLoading:k}}exports.AddButton=c.AddButton;exports.ApiErrorDisplay=c.ApiErrorDisplay;exports.AppDialog=c.AppDialog;exports.DRILL_SELF=c.DRILL_SELF;exports.DashboardTile=c.DashboardTile;exports.DocumentNotFoundError=c.DocumentNotFoundError;exports.DocumentStorageProvider=c.DocumentStorageProvider;exports.GivenInput=c.GivenInput;exports.GivensPanel=c.GivensPanel;exports.INITIAL_RENDER_HEIGHT=c.INITIAL_RENDER_HEIGHT;exports.LOADING_COPY=c.LOADING_COPY;exports.Loading=c.Loading;exports.MODEL_CELL_MAX_HEIGHT=c.MODEL_CELL_MAX_HEIGHT;exports.MOTION_FAST=c.MOTION_FAST;exports.NOTEBOOK_CELL_MAX_HEIGHT=c.NOTEBOOK_CELL_MAX_HEIGHT;exports.Prose=c.Prose;exports.REPORT_EDIT_PARAM=c.REPORT_EDIT_PARAM;exports.RESTRICTED_NOTICE=c.RESTRICTED_NOTICE;exports.RESULTS_DIALOG_MAX_HEIGHT=c.RESULTS_DIALOG_MAX_HEIGHT;exports.ResultContainer=c.ResultContainer;exports.ResultPanel=c.ResultPanel;exports.STICKY_CONTROLS_Z=c.STICKY_CONTROLS_Z;exports.STICKY_TOP_VAR=c.STICKY_TOP_VAR;exports.SecondaryButton=c.SecondaryButton;exports.TILE_MAX_HEIGHT=c.TILE_MAX_HEIGHT;exports.TILE_MIN_HEIGHT=c.TILE_MIN_HEIGHT;exports.TileCard=c.TileCard;exports.TileFilterTag=c.TileFilterTag;exports.TileHeading=c.TileHeading;exports.UNCAPPED_CONTAINER_HEIGHT=c.UNCAPPED_CONTAINER_HEIGHT;exports.UnsavedChangesDialog=c.UnsavedChangesDialog;exports.buildTableCssVars=c.buildTableCssVars;exports.clearReportDraft=c.clearReportDraft;exports.contentNodeDepth=c.contentNodeDepth;exports.dangerTextColor=c.dangerTextColor;exports.documentPreamble=c.documentPreamble;exports.documentSlug=c.documentSlug;exports.draftStorageAvailable=c.draftStorageAvailable;exports.drillDestinations=c.drillDestinations;exports.drillValueToFilter=c.drillValueToFilter;exports.encodeDrillValue=c.encodeDrillValue;exports.encodeResourceUri=c.encodeResourceUri;exports.humanizeSlug=c.humanizeSlug;exports.initialResultHeight=c.initialResultHeight;exports.isDocumentNotFound=c.isDocumentNotFound;exports.isDrillTargetPath=c.isDrillTargetPath;exports.localGivenSpec=c.localGivenSpec;exports.locateReport=c.locateReport;exports.malloyIdentifier=c.malloyIdentifier;exports.malloyLiteral=c.malloyLiteral;exports.measureContentHeight=c.measureContentHeight;exports.parseResourceUri=c.parseResourceUri;exports.queryResultKey=c.queryResultKey;exports.reducedMotionSx=c.reducedMotionSx;exports.remeasuresAfterReady=c.remeasuresAfterReady;exports.reportClasses=c.reportClasses;exports.reportDraftKey=c.reportDraftKey;exports.reportEditRoute=c.reportEditRoute;exports.reportRoute=c.reportRoute;exports.reportRoutePath=c.reportRoutePath;exports.resolveDrill=c.resolveDrill;exports.resolveDrillTarget=c.resolveDrillTarget;exports.resolveResultHeight=c.resolveResultHeight;exports.resultSizing=c.resultSizing;exports.scrollBehavior=c.scrollBehavior;exports.tileIgnoredFilterLabels=c.tileIgnoredFilterLabels;exports.useCompiledDocument=c.useCompiledDocument;exports.useDocumentControls=c.useDocumentControls;exports.useDocumentLocation=c.useDocumentLocation;exports.useDocumentStorage=c.useDocumentStorage;exports.useDrillSelf=c.useDrillSelf;exports.useGivensState=c.useGivensState;exports.useOptionalDocumentStorage=c.useOptionalDocumentStorage;exports.useQueryResult=c.useQueryResult;exports.useReportListing=c.useReportListing;exports.useSuggestOptions=c.useSuggestOptions;exports.visibleWithoutHoverSx=c.visibleWithoutHoverSx;exports.withPreamble=c.withPreamble;exports.DEFAULT_THEME=q.DEFAULT_THEME;exports.DEFAULT_UI=q.DEFAULT_UI;exports.MONO_FONT_FAMILY=q.MONO_FONT_FAMILY;exports.PALETTE=q.PALETTE;exports.SURFACE_TINT=q.SURFACE_TINT;exports.ServerProvider=q.ServerProvider;exports.ThemeProvider=q.ThemeProvider;exports.accentFor=q.accentFor;exports.contrastRatio=q.contrastRatio;exports.mergeUi=q.mergeUi;exports.resolveMode=q.resolveMode;exports.resolveTheme=q.resolveTheme;exports.usePublisherTheme=q.usePublisherTheme;exports.useServer=q.useServer;exports.canRetryRequest=oo.canRetryRequest;exports.DRILL_CELL_CLASS=fn.DRILL_CELL_CLASS;exports.RenderedResult=fn.RenderedResult;exports.buildMalloyExplicitTheme=fn.buildMalloyExplicitTheme;exports.buildVegaThemeOverride=fn.buildVegaThemeOverride;exports.drillableFieldNames=fn.drillableFieldNames;exports.markDrillableCells=fn.markDrillableCells;exports.readChartAnnotations=fn.readChartAnnotations;exports.BackLink=rd;exports.BrowserDocumentStorage=By;exports.ConnectionExplorer=tl;exports.DOC_LINKS=Vt;exports.Dashboard=Gy;exports.DashboardView=rs;exports.DataAppViewer=$d;exports.DimensionFilter=Qh;exports.DownloadRowsCsv=Ua;exports.EmbeddedQueryResult=Uy;exports.Environment=Th;exports.Home=df;exports.Materializations=gl;exports.Model=ay;exports.ModelExplorer=Io;exports.ModelExplorerDialog=Do;exports.ModelViewer=nc;exports.NarrowEditGate=sd;exports.NewDocumentDialog=ic;exports.Notebook=rx;exports.Package=Py;exports.Packages=nl;exports.QueryResult=pc;exports.Report=oc;exports.SourcesExplorer=sc;exports.VersionSwitch=fc;exports.createEmbeddedQueryResult=mc;exports.documentRoute=ix;exports.extractDimensionSpecs=tf;exports.extractSourceFromQuery=rf;exports.generateFilterClause=nf;exports.getDimensionKey=hn;exports.getJoinedSources=Zh;exports.groupEntitiesBySource=kl;exports.injectWhereClause=sf;exports.isNarrowScreen=Ra;exports.legacyAliasOf=ox;exports.locateDocument=ax;exports.locateReportByName=xc;exports.modelQueryKey=tc;exports.packageFileUrl=Qa;exports.packageVersionsQueryKey=$o;exports.parseAllSourceInfos=ef;exports.parseDimensionFilterAnnotation=rl;exports.parseNotebookFilterAnnotation=Xh;exports.runQueryKey=jo;exports.setConsoleEventHandler=Gd;exports.useDimensionFilters=bc;exports.useDimensionFiltersFromSpec=gx;exports.useDimensionFiltersQuery=wc;exports.useDimensionalFilterRangeData=vc;exports.useDraftLayout=Hy;exports.useDrill=io;exports.useGivenUrlParams=fd;exports.useInvalidatePackage=hc;exports.useModelData=Eo;exports.useModelGivens=gc;exports.useNarrowScreen=Fa;exports.usePackageVersions=dc;exports.useRawQueryData=yx;exports.useRouterClickHandler=od;
|