@malloy-publisher/app 0.0.197 → 0.0.198
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-doc.yaml +3 -20
- package/dist/assets/{EnvironmentPage-BVkQH_xQ.js → EnvironmentPage-C7rtH4mC.js} +1 -1
- package/dist/assets/{HomePage-BgH9UkjK.js → HomePage-DwkH7OrS.js} +1 -1
- package/dist/assets/{MainPage-DiBxABem.js → MainPage-D38LtZDV.js} +1 -1
- package/dist/assets/{ModelPage-oS70fj83.js → ModelPage-DOol8Mz7.js} +1 -1
- package/dist/assets/{PackagePage-F_qLDAdv.js → PackagePage-0tgzA_kO.js} +1 -1
- package/dist/assets/{RouteError-WqpffppN.js → RouteError-BaMsOSly.js} +1 -1
- package/dist/assets/{WorkbookPage-_YmC-ebR.js → WorkbookPage-Cx4SePkx.js} +1 -1
- package/dist/assets/{core-B8L9xCYT.es-BcRLJTnC.js → core-CbsC6R_Y.es-Cwf6asf3.js} +1 -1
- package/dist/assets/{index-rg8Ok8nl.js → index-DL6BZTuw.js} +1 -1
- package/dist/assets/{index-C3XPaTaS.js → index-DNofXMxi.js} +1 -1
- package/dist/assets/{index-BMViiwtJ.js → index-U38AyjJL.js} +3 -3
- package/dist/assets/{index.umd-CCAfKkxY.js → index.umd-B68wGGkM.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-CbsC6R_Y.es-Cwf6asf3.js","assets/engine-oniguruma-C4vnmooL.es-jdkXmgTr.js","assets/index-DL6BZTuw.js","assets/index-DNofXMxi.js","assets/index.umd-B68wGGkM.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
function Gj(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const a=Object.getOwnPropertyDescriptor(r,o);a&&Object.defineProperty(e,o,a.get?a:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();var LTe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function NI(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function FTe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Xx={exports:{}},Jf={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -323,7 +323,7 @@ import {${t.sourceName}}" from '${t.modelPath}'"
|
|
|
323
323
|
- [ ] `),/^\d+.\s/.test(i)&&(T=`
|
|
324
324
|
`+(parseInt(i)+1)+". "),md(r,T)}else if(e.code&&e.code.toLowerCase()==="keyd"&&e.ctrlKey){Py(e);var M={start:r.selectionStart,end:r.selectionEnd},D=M;M=sh({text:r.value,selection:M});var R=r.value.slice(M.start,M.end);l.setSelectionRange({start:M.end,end:M.end}),md(r,`
|
|
325
325
|
`+R),l.setSelectionRange({start:D.start,end:D.end})}else e.code&&e.code.toLowerCase()==="arrowup"&&e.altKey?cP(e,-1):e.code&&e.code.toLowerCase()==="arrowdown"&&e.altKey&&cP(e,1)}var bhe=["prefixCls","onChange"],vhe=["markdown","commands","fullscreen","preview","highlightEnable","extraCommands","tabSize","defaultTabEnable","autoFocusEnd","textareaWarp","dispatch"];function xhe(e){var{prefixCls:t,onChange:n}=e,r=Vt(e,bhe),o=C.useContext(nf),{markdown:a,commands:i,fullscreen:l,preview:u,highlightEnable:d,extraCommands:f,tabSize:h,defaultTabEnable:y,autoFocusEnd:b,textareaWarp:v,dispatch:x}=o;Vt(o,vhe);var E=tt.useRef(null),S=tt.useRef(),A=tt.useRef({fullscreen:l,preview:u});C.useEffect(()=>{A.current={fullscreen:l,preview:u,highlightEnable:d}},[l,u,d]),C.useEffect(()=>{if(E.current&&x){var M=new lw(E.current);S.current=M,x({textarea:E.current,commandOrchestrator:M})}},[]),C.useEffect(()=>{if(b&&E.current&&v){E.current.focus();var M=E.current.value.length;E.current.setSelectionRange(M,M),setTimeout(()=>{v&&(v.scrollTop=v.scrollHeight),E.current&&(E.current.scrollTop=E.current.scrollHeight)},0)}},[v]);var T=M=>{yhe(M,h,y),l6(M,[...i||[],...f||[]],S.current,x,A.current)};return C.useEffect(()=>(E.current&&E.current.addEventListener("keydown",T),()=>{E.current&&E.current.removeEventListener("keydown",T)}),[]),g.jsx("textarea",ue({autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1},r,{ref:E,className:t+"-text-input "+(r.className?r.className:""),value:a,onChange:M=>{x&&x({markdown:M.target.value}),n&&n(M)}}))}var She=["prefixCls","className","onScroll","renderTextarea"];function Ehe(e){var t=e||{},{prefixCls:n,className:r,onScroll:o,renderTextarea:a}=t,i=Vt(t,She),{markdown:l,scrollTop:u,commands:d,extraCommands:f,dispatch:h}=C.useContext(nf),y=tt.useRef(null),b=tt.useRef(),v=tt.createRef();C.useEffect(()=>{var E={};v.current&&(E.textareaWarp=v.current||void 0,v.current.scrollTop=u||0),h&&h(ue({},E))},[]),C.useEffect(()=>{if(y.current&&h){var E=new lw(y.current);b.current=E,h({textarea:y.current,commandOrchestrator:E})}},[]);var x={WebkitTextFillColor:"initial",overflow:"auto"};return g.jsx("div",{ref:v,className:n+"-area "+(r||""),onScroll:o,children:g.jsx("div",{className:n+"-text",children:a?tt.cloneElement(a(ue({},i,{value:l,autoComplete:"off",autoCorrect:"off",spellCheck:"false",autoCapitalize:"off",className:n+"-text-input",style:{WebkitTextFillColor:"inherit",overflow:"auto"}}),{dispatch:h,onChange:i.onChange,shortcuts:l6,useContext:{commands:d,extraCommands:f,commandOrchestrator:b.current}}),{ref:y}):g.jsx(C.Fragment,{children:g.jsx(xhe,ue({prefixCls:n},i,{style:x}))})})})}function Che(e){var{prefixCls:t,groupName:n,commands:r,children:o}=e||{},{barPopup:a={}}=C.useContext(nf);return C.useMemo(()=>g.jsx("div",{className:t+"-toolbar-child "+(n&&a[n]?"active":""),onClick:i=>i.stopPropagation(),children:Array.isArray(r)?g.jsx(p6,ue({commands:r},e,{isChild:!0})):o}),[r,a,n,t])}function uP(e){var{prefixCls:t,overflow:n}=e,{fullscreen:r,preview:o,barPopup:a={},components:i,commandOrchestrator:l,dispatch:u}=C.useContext(nf),d=C.useRef("");function f(h,y){if(u){var b={barPopup:ue({},a)};h.keyCommand==="preview"&&(b.preview=h.value),h.keyCommand==="fullscreen"&&(b.fullscreen=!r),e.commands&&h.keyCommand==="group"?e.commands.forEach(v=>{y===v.groupName?b.barPopup[y]=!0:v.keyCommand&&(b.barPopup[v.groupName]=!1)}):(y||h.parent)&&Object.keys(b.barPopup||{}).forEach(v=>{b.barPopup[v]=!1}),Object.keys(b).length&&u(ue({},b)),l&&l.executeCommand(h)}}return C.useEffect(()=>{document&&n&&(r?document.body.style.overflow="hidden":(d.current||(d.current=window.getComputedStyle(document.body,null).overflow),document.body.style.overflow=d.current))},[r,d,n]),g.jsx("ul",{children:(e.commands||[]).map((h,y)=>{if(h.keyCommand==="divider")return g.jsx("li",ue({},h.liProps,{className:t+"-toolbar-divider"}),y);if(!h.keyCommand)return g.jsx(C.Fragment,{},y);var b=r&&h.keyCommand==="fullscreen"||h.keyCommand==="preview"&&o===h.value,v=h.children&&typeof h.children=="function"?h.children({getState:()=>l.getState(),textApi:l?l.textApi:void 0,close:()=>f({},h.groupName),execute:()=>f({execute:h.execute}),dispatch:u}):void 0,x=a&&o&&o==="preview"&&!/(preview|fullscreen)/.test(h.keyCommand),E=i?.toolbar||h.render,S=E&&typeof E=="function"?E(h,!!x,f,y):null;return g.jsxs("li",ue({},h.liProps,{className:b?"active":"",children:[S&&tt.isValidElement(S)&&S,!S&&!h.buttonProps&&h.icon,!S&&h.buttonProps&&tt.createElement("button",ue({type:"button",key:y,disabled:x,"data-name":h.name},h.buttonProps,{onClick:A=>{A.stopPropagation(),f(h,h.groupName)}}),h.icon),h.children&&g.jsx(Che,{overflow:n,groupName:h.groupName,prefixCls:t,children:v,commands:Array.isArray(h.children)?h.children:void 0})]}),y)})})}function p6(e){e===void 0&&(e={});var{prefixCls:t,isChild:n,className:r}=e,{commands:o,extraCommands:a}=C.useContext(nf);return g.jsxs("div",{className:t+"-toolbar "+r,children:[g.jsx(uP,ue({},e,{commands:e.commands||o||[]})),!n&&g.jsx(uP,ue({},e,{commands:a||[]}))]})}function dP(e){var{hideToolbar:t,toolbarBottom:n,placement:r,overflow:o,prefixCls:a}=e;if(t||r==="bottom"&&!n||r==="top"&&n)return null;var i=n?"bottom":"";return g.jsx(p6,{prefixCls:a,overflow:o,className:i})}var The=e=>{var{prefixCls:t,onChange:n}=e||{},r=C.useRef(null),o=C.useRef(),a=C.useRef(e.height);C.useEffect(()=>{a.current!==e.height&&(a.current=e.height)},[e.height]);function i(f){if(o.current){var h,y=f.clientY||((h=f.changedTouches[0])==null?void 0:h.clientY),b=o.current.height+y-o.current.dragY;b>=e.minHeight&&b<=e.maxHeight&&n&&n(o.current.height+(y-o.current.dragY))}}function l(){var f,h;o.current=void 0,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",l),(f=r.current)==null||f.removeEventListener("touchmove",i),(h=r.current)==null||h.removeEventListener("touchend",l)}function u(f){var h,y,b;f.preventDefault();var v=f.clientY||((h=f.changedTouches[0])==null?void 0:h.clientY);o.current={height:a.current,dragY:v},document.addEventListener("mousemove",i),document.addEventListener("mouseup",l),(y=r.current)==null||y.addEventListener("touchmove",i,{passive:!1}),(b=r.current)==null||b.addEventListener("touchend",l,{passive:!1})}C.useEffect(()=>{if(document){var f,h;(f=r.current)==null||f.addEventListener("touchstart",u,{passive:!1}),(h=r.current)==null||h.addEventListener("mousedown",u)}return()=>{if(document){var y;(y=r.current)==null||y.removeEventListener("touchstart",u),document.removeEventListener("mousemove",i)}}},[]);var d=C.useMemo(()=>g.jsx("svg",{viewBox:"0 0 512 512",height:"100%",children:g.jsx("path",{fill:"currentColor",d:"M304 256c0 26.5-21.5 48-48 48s-48-21.5-48-48 21.5-48 48-48 48 21.5 48 48zm120-48c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48zm-336 0c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z"})}),[]);return g.jsx("div",{className:t+"-bar",ref:r,children:d})},whe=["prefixCls","className","value","commands","commandsFilter","direction","extraCommands","height","enableScroll","visibleDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","autoFocusEnd","tabSize","defaultTabEnable","onChange","onStatistics","onHeightChange","hideToolbar","toolbarBottom","components","renderTextarea"];function khe(e){return e===void 0&&(e={}),Object.keys(e).forEach(t=>{e[t]=!1}),e}var Ahe=tt.forwardRef((e,t)=>{var n=e||{},{prefixCls:r="w-md-editor",className:o,value:a,commands:i=mhe(),commandsFilter:l,direction:u,extraCommands:d=ghe(),height:f=200,enableScroll:h=!0,visibleDragbar:y=typeof e.visiableDragbar=="boolean"?e.visiableDragbar:!0,highlightEnable:b=!0,preview:v="live",fullscreen:x=!1,overflow:E=!0,previewOptions:S={},textareaProps:A,maxHeight:T=1200,minHeight:M=100,autoFocus:D,autoFocusEnd:R=!1,tabSize:F=2,defaultTabEnable:B=!1,onChange:z,onStatistics:j,onHeightChange:U,hideToolbar:w,toolbarBottom:L=!1,components:I,renderTextarea:$}=n,_=Vt(n,whe),G=i.map(me=>l?l(me,!1):me).filter(Boolean),V=d.map(me=>l?l(me,!0):me).filter(Boolean),[Y,P]=C.useReducer(Lpe,{markdown:a,preview:v,components:I,height:f,minHeight:M,highlightEnable:b,tabSize:F,defaultTabEnable:B,scrollTop:0,scrollTopPreview:0,commands:G,extraCommands:V,fullscreen:x,barPopup:{}}),q=C.useRef(null),X=C.useRef(null),H=C.useRef(h);C.useImperativeHandle(t,()=>ue({},Y,{container:q.current,dispatch:P})),C.useMemo(()=>H.current=h,[h]),C.useEffect(()=>{var me={};q.current&&(me.container=q.current||void 0),me.markdown=a||"",me.barPopup={},P&&P(ue({},Y,me))},[]);var re=[o,"wmde-markdown-var",u?r+"-"+u:null,r,Y.preview?r+"-show-"+Y.preview:null,Y.fullscreen?r+"-fullscreen":null].filter(Boolean).join(" ").trim();C.useMemo(()=>a!==Y.markdown&&P({markdown:a||""}),[a,Y.markdown]),C.useMemo(()=>v!==Y.preview&&P({preview:v}),[v]),C.useMemo(()=>F!==Y.tabSize&&P({tabSize:F}),[F]),C.useMemo(()=>b!==Y.highlightEnable&&P({highlightEnable:b}),[b]),C.useMemo(()=>D!==Y.autoFocus&&P({autoFocus:D}),[D]),C.useMemo(()=>R!==Y.autoFocusEnd&&P({autoFocusEnd:R}),[R]),C.useMemo(()=>x!==Y.fullscreen&&P({fullscreen:x}),[x]),C.useMemo(()=>f!==Y.height&&P({height:f}),[f]),C.useMemo(()=>f!==Y.height&&U&&U(Y.height,f,Y),[f,U,Y]),C.useMemo(()=>i!==Y.commands&&P({commands:G}),[e.commands]),C.useMemo(()=>d!==Y.extraCommands&&P({extraCommands:V}),[e.extraCommands]);var Z=C.useRef(),K=C.useRef("preview"),ne=C.useRef(!1);C.useMemo(()=>{Z.current=Y.textareaWarp,Y.textareaWarp&&(Y.textareaWarp.addEventListener("mouseover",()=>{K.current="text"}),Y.textareaWarp.addEventListener("mouseleave",()=>{K.current="preview"}))},[Y.textareaWarp]);var ee=(me,ve)=>{if(H.current){var Ze=Z.current,je=X.current?X.current:void 0;if(ne.current||(K.current=ve,ne.current=!0),Ze&&je){var We=(Ze.scrollHeight-Ze.offsetHeight)/(je.scrollHeight-je.offsetHeight);me.target===Ze&&K.current==="text"&&(je.scrollTop=Ze.scrollTop/We),me.target===je&&K.current==="preview"&&(Ze.scrollTop=je.scrollTop*We);var ze=0;K.current==="text"?ze=Ze.scrollTop||0:K.current==="preview"&&(ze=je.scrollTop||0),P({scrollTop:ze})}}},fe=r+"-preview "+(S.className||""),de=me=>ee(me,"preview"),ce=C.useMemo(()=>g.jsx("div",{ref:X,className:fe,children:g.jsx(i6,ue({},S,{onScroll:de,source:Y.markdown||""}))}),[fe,S,Y.markdown]),xe=I?.preview&&I?.preview(Y.markdown||"",Y,P);xe&&tt.isValidElement(xe)&&(ce=g.jsx("div",{className:fe,ref:X,onScroll:de,children:xe}));var oe=ue({},_.style,{height:Y.height||"100%"}),le=()=>P({barPopup:ue({},khe(Y.barPopup))}),Be=me=>P({height:me}),De=me=>{if(z&&z(me.target.value,me,Y),A&&A.onChange&&A.onChange(me),Y.textarea&&Y.textarea instanceof HTMLTextAreaElement&&j){var ve=new lw(Y.textarea),Ze=ve.getState()||{};j(ue({},Ze,{lineCount:me.target.value.split(`
|
|
326
|
-
`).length,length:me.target.value.length}))}};return g.jsx(nf.Provider,{value:ue({},Y,{dispatch:P}),children:g.jsxs("div",ue({ref:q,className:re},_,{onClick:le,style:oe,children:[g.jsx(dP,{hideToolbar:w,toolbarBottom:L,prefixCls:r,overflow:E,placement:"top"}),g.jsxs("div",{className:r+"-content",children:[/(edit|live)/.test(Y.preview||"")&&g.jsx(Ehe,ue({className:r+"-input",prefixCls:r,autoFocus:D},A,{onChange:De,renderTextarea:I?.textarea||$,onScroll:me=>ee(me,"text")})),/(live|preview)/.test(Y.preview||"")&&ce]}),y&&!Y.fullscreen&&g.jsx(The,{prefixCls:r,height:Y.height,maxHeight:T,minHeight:M,onChange:Be}),g.jsx(dP,{hideToolbar:w,toolbarBottom:L,prefixCls:r,overflow:E,placement:"bottom"})]}))})}),h6=Ahe;h6.Markdown=i6;const uS={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"}]}}},Dhe={...uS,patterns:[...uS.patterns,{include:"#docvar"}],repository:{...uS.repository,docvar:{patterns:[{match:"\\<\\<[^(\\>\\>)]*\\>\\>",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"markup.italic.markdown"}]}}},Rhe={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"}]}}},Mhe="github-light";let dS;function Ohe(){return dS||(dS=(async()=>{const[{createHighlighterCore:e},{createOnigurumaEngine:t},{default:n},{default:r},{default:o},{default:a}]=await Promise.all([io(()=>import("./core-B8L9xCYT.es-BcRLJTnC.js"),__vite__mapDeps([0,1])),io(()=>import("./engine-oniguruma-C4vnmooL.es-jdkXmgTr.js"),[]),io(()=>import("./sql-DCkt643-.es-COK4E0Yg.js"),[]),io(()=>import("./json-71t8ZF9g.es-BQoSv7ci.js"),[]),io(()=>import("./typescript-buWNZFwO.es-Dj6nwHGl.js"),[]),io(()=>import("./github-light-JYsPkUQd.es-DAi9KRSo.js"),[])]);return e({engine:t(io(()=>import("./wasm-DQxwEHae.es-CG6Dc4jp.js"),[])),themes:[a],langs:[n,r,o,{name:"malloy",scopeName:"source.malloy",embeddedLangs:["sql"],...Dhe},{name:"malloysql",scopeName:"source.malloy-sql",embeddedLangs:["sql"],...Rhe}]})})()),dS}async function yb(e,t){return(await Ohe()).codeToHtml(e,{lang:t,theme:Mhe})}function bo(e){const{server:t}=cr(),n={...e,queryKey:[...e.queryKey,t],queryFn:async()=>{try{return await e.queryFn()}catch(r){if(r&&typeof r=="object"&&"response"in r){const o=r;if(o.response?.data){const a=new Error(o.response.data.message||o.message);throw a.status=o.response.status,a.data=o.response.data,a}}throw r}},retry:!1,throwOnError:!1};return SQ(n,gT)}function zi(e){const t={...e,mutationFn:async n=>{try{return await e.mutationFn(n)}catch(r){if(r&&typeof r=="object"&&"response"in r){const o=r;if(o.response?.data){const a=new Error(o.response.data.message||o.message);throw a.status=o.response.status,a.data=o.response.data,a}}throw r}},retry:!1,throwOnError:!1};return EQ(t,gT)}const Kr=e=>{const t=new URL(e),n={};if(t.protocol!=="publisher:")throw new Error(`Failed to parse resource URI: ${e}`);const r=(t.hostname+t.pathname).split("/");for(let o=0;o<r.length;o+=2){const a=r[o];a==="environments"?n.environmentName=decodeURI(r[o+1])||void 0:a==="packages"?n.packageName=decodeURI(r[o+1])||void 0:a==="connections"?n.connectionName=decodeURI(r[o+1])||void 0:a==="models"&&(n.modelPath=decodeURI(r.slice(o+1).join("/"))||void 0)}if(n.versionId=t.searchParams.get("versionId")||void 0,!n.environmentName)throw new Error(`Failed to parse resource URI: ${e}`);return n},cw=e=>{if(!e.environmentName)throw new Error(`Failed to encode resource URI, missing environment name: ${e}`);let t=`publisher://environments/${e.environmentName}`;return e.packageName&&(t+=`/packages/${e.packageName}`),e.connectionName&&(t+=`/connections/${e.connectionName}`),e.modelPath&&(t+=`/models/${e.modelPath}`),e.packageName&&e.versionId&&(t+=`?versionId=${e.versionId}`),t};function m6({sourceAndPaths:e,selectedSourceIndex:t,existingQuery:n,onQueryChange:r,onSourceChange:o,resourceUri:a}){return tt.useEffect(()=>{o&&o(t)},[t,o]),g.jsx(RT,{children:g.jsxs(Az,{spacing:2,component:"section",children:[g.jsx(Phe,{sourceAndPath:e[t],existingQuery:n,onChange:i=>{r&&r(i)},resourceUri:a}),g.jsx(k_,{height:"5px"})]})})}function Iy(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function Nhe({sourceAndPath:e,onChange:t,existingQuery:n,explorerComponents:r,QueryBuilder:o,resourceUri:a}){const[i,l]=tt.useState(n||Iy()),[u,d]=tt.useState(void 0);tt.useEffect(()=>{n&&l(n)},[n]);const[f,h]=tt.useState([]),{MalloyExplorerProvider:y,QueryPanel:b,ResizableCollapsiblePanel:v,ResultPanel:x,SourcePanel:E}=r;tt.useEffect(()=>{t&&t(i)},[t,i]);const{environmentName:S,packageName:A,versionId:T}=Kr(a),{apiClients:M}=cr(),D=zi({mutationFn:()=>{const z=typeof i?.malloyQuery=="string"?i.malloyQuery:new o.ASTQuery({source:e.sourceInfo,query:i?.malloyQuery}).toMalloy();return d({executionState:"running",query:i?.malloyQuery,queryResolutionStartMillis:Date.now(),onCancel:()=>{D.reset(),d(void 0)},response:{result:{}}}),l({...i,query:z}),M.models.executeQueryModel(S,A,e.modelPath,{query:z,sourceName:void 0,queryName:void 0,versionId:T})},onSuccess:z=>{if(z){const j=JSON.parse(z.data.result);l({...i,malloyResult:j}),d(U=>U?{...U,executionState:"finished",response:{result:j}}:void 0)}},onError:z=>{d(void 0),console.error("Query execution error:",z)}}),[R,F]=tt.useState(e.sourceInfo.name);tt.useEffect(()=>{R!==e.sourceInfo.name&&(F(e.sourceInfo.name),l(Iy()),d(void 0))},[e,R]);const B=tt.useCallback(z=>{l({...i,malloyQuery:z,malloyResult:void 0})},[i]);return R!==e.sourceInfo.name?g.jsx("div",{children:"Loading..."}):g.jsx(U3,{sx:{border:"1px solid #e0e0e0",borderRadius:"8px",overflow:"hidden"},children:g.jsx(y,{source:e.sourceInfo,query:i?.malloyQuery,topValues:[],onFocusedNestViewPathChange:h,focusedNestViewPath:f,onQueryChange:B,children:g.jsxs("div",{style:{display:"flex",height:"100%",overflowY:"auto"},children:[g.jsx(v,{isInitiallyExpanded:!0,initialWidth:180,minWidth:180,icon:"database",title:e.sourceInfo.name,children:g.jsx(E,{onRefresh:()=>l(Iy())})}),g.jsx(v,{isInitiallyExpanded:!0,initialWidth:280,minWidth:280,icon:"filterSliders",title:"Query",children:g.jsx(b,{runQuery:()=>{console.log(`running query with: ${i?.malloyQuery}`);try{D.mutate()}catch(z){console.error("Error running query:",z)}}})}),g.jsx(x,{source:e.sourceInfo,draftQuery:i?.malloyQuery,setDraftQuery:z=>l({...i,malloyQuery:z}),submittedQuery:u,options:{showRawQuery:!0}})]})})},e.sourceInfo.name)}function Phe(e){const[t,n]=C.useState(null),[r,o]=C.useState(null),[a,i]=C.useState(!0);return C.useEffect(()=>{let l=!0;return Promise.all([io(()=>import("./index-rg8Ok8nl.js"),__vite__mapDeps([2,3,4])),io(()=>import("./index-C3XPaTaS.js").then(u=>u.i),[])]).then(([u,d])=>{l&&(n(u),o(d),i(!1))}).catch(u=>{console.error("Failed to load Malloy components:",u),l&&i(!1)}),()=>{l=!1}},[]),a||!t||!r?g.jsx(one,{children:g.jsx(U3,{children:g.jsx(k_,{sx:{alignItems:"center",justifyContent:"center",height:"200px",color:"text.secondary"},children:"Loading explorer..."})})}):g.jsx(Nhe,{...e,explorerComponents:t,QueryBuilder:r,resourceUri:e.resourceUri})}function ya({text:e,size:t=20,color:n="primary",thickness:r=3.6,centered:o=!0,spacing:a=2,textVariant:i="body2"}){const l=g.jsxs(xt,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:a},children:[g.jsx(Kb,{size:t,color:n,thickness:r}),e&&g.jsx(ft,{variant:i,color:"text.secondary",children:e})]});return o?g.jsx(xt,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"200px",width:"100%"},children:l}):l}const Ihe=C.lazy(()=>Promise.resolve().then(()=>wTe));function _v({result:e,maxHeight:t,maxResultSize:n=0}){const r=C.useRef(null),[o,a]=C.useState(t),[i,l]=C.useState(!1);if(!e)return null;if(n>0&&e.length>n&&!i)return g.jsxs(xt,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,p:4,backgroundColor:"#fafafa",border:"1px solid",borderColor:"#e0e0e0",borderRadius:1},children:[g.jsx(DJ,{sx:{fontSize:48,color:"#757575"}}),g.jsx(ft,{variant:"h6",color:"text.secondary",align:"center",children:"Processing large results may cause browser performance issues. Proceed?"}),g.jsx(Ro,{variant:"contained",color:"primary",onClick:()=>l(!0),children:"Proceed"})]});const u=g.jsx(ya,{text:"Loading...",centered:!0,size:32}),d=Math.min(t,o);return g.jsx(xt,{ref:r,sx:{position:"relative",height:"auto",border:"0px",borderRadius:0,overflow:"hidden"},children:e&&g.jsx(C.Suspense,{fallback:u,children:g.jsx(Ihe,{result:e,height:d,onSizeChange:a})})})}function _he({cell:e,sourceAndPaths:t,resourceUri:n,onQueryChange:r,onSourceChange:o}){const a={query:e.value,malloyResult:e.result?JSON.parse(e.result):void 0,malloyQuery:e.queryInfo?JSON.parse(e.queryInfo):void 0},i=t.findIndex(l=>l.sourceInfo.name===e.sourceName);return g.jsx(m6,{resourceUri:n,sourceAndPaths:t,selectedSourceIndex:i>=0?i:0,existingQuery:a,onQueryChange:r,onSourceChange:o})}function Lhe({cell:e,editingMalloy:t,editingMarkdown:n,sourceAndPaths:r,resourceUri:o,onCellChange:a,onClose:i,onEdit:l,onDelete:u,addButtonCallback:d}){const[f,h]=C.useState(e.value),[y,b]=tt.useState(!1),[v,x]=tt.useState(!1),[E,S]=tt.useState(),[A]=tt.useState(),[T,M]=tt.useState(Iy()),[D,R]=tt.useState(!1),[F,B]=tt.useState(e.sourceName?r.findIndex(q=>q.sourceInfo.name===e.sourceName):0);C.useEffect(()=>{e.isMarkdown||yb(e.value,"malloy").then(q=>{S(q)})},[e]),tt.useEffect(()=>{document.documentElement.setAttribute("data-color-mode","light")});const[z,j]=C.useState(!1),U=()=>{u(),j(!1)},w=r.length===0,L=tt.useCallback(()=>{const q=r[F],X=q?.modelPath||e.modelPath||"",H=q?.sourceInfo.name||e.sourceName||"";a({...e,value:e.isMarkdown?f:T.query,result:T.malloyResult?JSON.stringify(T.malloyResult):void 0,queryInfo:T.malloyQuery?JSON.stringify(T.malloyQuery):void 0,sourceName:H,modelPath:X})},[e,f,T,a,F,r]),I=g.jsx(jo,{title:"Delete Cell",children:g.jsx(Cr,{size:"small",onClick:()=>j(!0),children:g.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m2 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14zM10 11v6M14 11v6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}),$=g.jsxs(ks,{open:z,onClose:()=>j(!1),children:[g.jsx(Ds,{children:"Confirm Delete"}),g.jsx(As,{children:g.jsx(ft,{children:"Are you sure you want to delete this cell?"})}),g.jsxs(eT,{children:[g.jsx(Ro,{onClick:()=>j(!1),children:"Cancel"}),g.jsx(Ro,{onClick:U,color:"error",children:"Delete"})]})]}),_=()=>{L(),i()},G=e.isMarkdown?g.jsxs(g.Fragment,{children:[n?g.jsx(jo,{title:"Save",children:g.jsx(Cr,{size:"small",onClick:_,children:g.jsx(Vg,{})})}):g.jsx(jo,{title:"Edit",children:g.jsx(Cr,{size:"small",onClick:l,children:g.jsx(NO,{})})}),!n&&I]}):g.jsxs(g.Fragment,{children:[!t&&g.jsx(jo,{title:y?"Hide Code":"View Code",children:g.jsx(Cr,{size:"small",onClick:()=>{b(!y)},children:g.jsx(W3,{})})}),!t&&e.result&&g.jsx(jo,{title:v?"Hide Embedding":"View Embedding",children:g.jsx(Cr,{size:"small",onClick:()=>{x(!v)},children:g.jsx(MT,{})})}),t&&g.jsx(jo,{title:"Save",children:g.jsx(Cr,{size:"small",onClick:_,children:g.jsx(Vg,{})})}),!t&&g.jsx(jo,{title:"Edit",children:g.jsx(Cr,{size:"small",onClick:l,children:g.jsx(NO,{})})}),!t&&I]}),V=t||n,Y=n?g.jsx(jo,{title:"Save",children:g.jsx(Cr,{size:"small",onClick:_,children:g.jsx(Vg,{})})}):t?g.jsx(jo,{title:"Save",children:g.jsx(Cr,{size:"small",onClick:_,children:g.jsx(Vg,{})})}):null,P=D&&g.jsx(xt,{sx:{position:"absolute",top:"4px",right:"4px",display:"flex",gap:"8px",backgroundColor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",padding:"2px 4px",boxShadow:1,zIndex:10},children:!V&&g.jsxs(g.Fragment,{children:[d(!0),d(!1),G]})||Y});return g.jsxs(sb,{sx:{position:"relative",marginTop:"5px",marginBottom:"5px",borderWidth:"1.5px",backgroundColor:"#fff",minHeight:"50px"},onMouseEnter:()=>R(!0),onMouseLeave:()=>{R(!1)},children:[P,e.isMarkdown?g.jsx(g.Fragment,{children:n?g.jsx(h6,{value:f,preview:"edit",autoFocus:!0,onChange:q=>{h(q),a({...e,value:q})},onBlur:()=>{L(),D||_()}}):g.jsx(xt,{sx:{px:.5,pt:0,mt:0,"& h1, & h2, & h3, & h4, & h5, & h6":{mt:.5,mb:.5},"& p":{mt:.5,mb:.5},"& ul, & ol":{mt:.5,mb:.5},"& li":{mt:0,mb:0},"& pre, & code":{mt:.5,mb:.5},"& blockquote":{mt:.5,mb:.5}},children:e.value?g.jsx(xt,{onClick:l,sx:{cursor:"pointer"},children:g.jsx(nb,{children:e.value})}):g.jsxs(xt,{onClick:l,sx:{cursor:"pointer"},children:[g.jsx(ft,{sx:{p:2,textAlign:"center",variant:"subtitle2",fontWeight:"medium"},children:"Markdown is empty"}),g.jsx(ft,{sx:{mb:2,textAlign:"center",variant:"body2"},children:"Click to edit."})]})})}):g.jsxs(g.Fragment,{children:[g.jsx(Gy,{in:v,timeout:"auto",unmountOnExit:!0,children:g.jsx(lo,{sx:{p:"10px",borderRadius:0,flexDirection:"row",justifyContent:"space-between"},children:g.jsx(ft,{component:"div",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},dangerouslySetInnerHTML:{__html:A}})})}),g.jsx(Gy,{in:y,timeout:"auto",unmountOnExit:!0,children:g.jsx(lo,{sx:{p:"10px",borderRadius:0,flexDirection:"row",justifyContent:"space-between"},children:g.jsx(ft,{component:"div",className:"content",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},dangerouslySetInnerHTML:{__html:E}})})}),t&&(w?g.jsxs(g.Fragment,{children:[g.jsx(ft,{sx:{p:2,textAlign:"center",variant:"subtitle2",fontWeight:"medium"},children:"No Model Imports"}),g.jsx(ft,{sx:{mb:2,textAlign:"center",variant:"body2"},children:"Please add a model import above."})]}):g.jsx(_he,{sourceAndPaths:r,resourceUri:o,onQueryChange:q=>{M(q)},onSourceChange:q=>{B(q)},cell:e})),!t&&e.result&&g.jsx(sb,{variant:"outlined",sx:{borderRadius:0},children:g.jsx(_v,{result:e.result,maxHeight:800})}),!t&&!e.result&&g.jsxs(xt,{onClick:l,sx:{cursor:"pointer"},children:[g.jsx(ft,{sx:{p:2,textAlign:"center",variant:"subtitle2",fontWeight:"medium"},children:"Explore is empty"}),g.jsx(ft,{sx:{mb:2,textAlign:"center",variant:"body2"},children:"Click to edit."})]})]}),z&&$]})}const g6=C.createContext(void 0);function Fhe({children:e,workbookStorage:t}){const n=C.useMemo(()=>({workbookStorage:t}),[t]);return g.jsx(g6.Provider,{value:n,children:e})}function Bhe(){const e=C.useContext(g6);if(!e)throw new Error("useWorkbookStorage must be used within a WorkbookStorageProvider");return e}const Ns=fr(g.jsx("path",{d:"M19 6.41 17.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"})),jhe=fr(g.jsx("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3zM7 9l1.41 1.41L11 7.83V16h2V7.83l2.59 2.58L17 9l-5-5z"}));function ba({error:e,context:t}){const n=e.data?.message||"Unknown Error";return g.jsxs(g.Fragment,{children:[t&&g.jsx(ft,{variant:"body2",sx:{p:"10px",m:"auto"},children:t}),g.jsx("pre",{style:{whiteSpace:"pre-wrap",color:"red",padding:"10px",margin:"auto"},children:n})]})}function $he({initialSelectedModels:e,onModelChange:t,resourceUri:n}){const{environmentName:r,packageName:o,versionId:a}=Kr(n),{apiClients:i}=cr(),{data:l,isLoading:u,isSuccess:d,isError:f,error:h}=bo({queryKey:["models",r,o,a],queryFn:()=>i.models.listModels(r,o,a)}),[y,b]=tt.useState(e||[]),[v,x]=tt.useState(null);tt.useEffect(()=>{b(e||[])},[e]);const E=T=>{const M=y.filter(D=>D!==T);b(M),t(M)},S=T=>{const M=[...y,T];b(M),t(M),x(null)};let A=[];return d&&l?.data&&(A=l.data.filter(T=>!y.includes(T.path)).map(T=>T.path)),f?g.jsx(ba,{error:h,context:`${r} > ${o} > Model Picker`}):g.jsxs(g.Fragment,{children:[g.jsxs(v5,{fullWidth:!0,children:[u&&g.jsx(ft,{children:"Loading..."}),g.jsxs(lo,{direction:"row",spacing:1,children:[y.map(T=>g.jsx(MW,{label:T,onDelete:()=>E(T),deleteIcon:g.jsx(Ns,{}),sx:{marginBottom:"5px"}},T)),g.jsx(Ro,{size:"small",startIcon:g.jsx(jhe,{}),onClick:T=>x(T.currentTarget),disabled:u||f||A.length===0,children:"Add Model"})]})]}),g.jsxs(Qh,{anchorEl:v,open:!!v,onClose:()=>x(null),children:[g.jsx(ft,{variant:"subtitle2",sx:{ml:1},children:"Models"}),g.jsx(Wi,{}),A.length===0?g.jsx(Ol,{disabled:!0,children:"No models available"}):A.map(T=>g.jsx(Ol,{onClick:()=>S(T),children:g.jsx(ft,{variant:"body2",children:T})},T))]})]})}function Uhe(){const e=ZI();return(t,n)=>{if(!n||!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.button!==1){e(t);return}const r=new URL(t,window.location.href).href;(n.metaKey||n.ctrlKey||n.button===1||n.shiftKey)&&window.open(r,"_blank")}}function gwe({workbookPath:e,resourceUri:t}){const n=Uhe(),{server:r,getAccessToken:o}=cr(),{apiClients:a}=cr(),{workbookStorage:i}=Bhe(),{environmentName:l,packageName:u}=Kr(t),[d,f]=tt.useState(void 0),[h,y]=tt.useState(void 0);if(!i)throw new Error("Workbook storage be provided via WorkbookStorageProvider");const[b,v]=tt.useState(),[x,E]=tt.useState(),[S,A]=tt.useState(),[T,M]=tt.useState([]),[D,R]=tt.useState(null),[F,B]=tt.useState(null),z=!!D,j=()=>{R(null),B(null)},U=(q,X)=>{b&&(v(b.insertCell(X,{isMarkdown:q,value:""})),q?A(X):E(X),j(),console.log("handleAddCell",q,X))},[w,L]=tt.useState(!1),I=()=>{L(!0)},$=async()=>{e&&i&&await i.deleteWorkbook(e).then(()=>{y(void 0),f(void 0)}).catch(q=>{y(`Error deleting workbook: ${q.message}`),f(void 0)}),L(!1),n(`/${l}/${u}`)},_=()=>{L(!1)},G=tt.useCallback(async()=>{if(!b){console.log("No workbook data ref");return}try{v(await b.saveWorkbook()),y(void 0),f("Workbook saved")}catch(q){y(`Error saving workbook: ${q.message}`),f(void 0)}},[b]);if(tt.useEffect(()=>{b&&(async()=>{const q=new Map(T.map(({modelPath:re,sourceInfos:Z})=>[re,Z])),X=[],H=[];for(const re of b.getModels())q.has(re)?X.push({modelPath:re,sourceInfos:q.get(re)}):(console.log("Fetching model from Publisher",re),H.push(a.models.getModel(l,u,re,void 0).then(Z=>({modelPath:re,sourceInfos:Z.data.sourceInfos.map(K=>JSON.parse(K))}))));if(H.length>0){const re=await Promise.all(H);M([...X,...re])}else M(X)})()},[o,b,u,l,r]),tt.useEffect(()=>{e&&Xp.loadWorkbook(i,e).then(q=>{v(q)})},[e,i]),!b)return g.jsx("div",{children:"Loading..."});const V=q=>{const X=[];for(const H of q)for(const re of H.sourceInfos)X.push({modelPath:H.modelPath,sourceInfo:re});return X},Y=(q,X)=>g.jsx(Ro,{size:"small",startIcon:g.jsx(DT,{}),onClick:()=>U(q,X),variant:"contained",sx:{backgroundColor:"#fff",color:H=>H.palette.mode==="dark"?H.palette.grey[100]:H.palette.grey[700],boxShadow:"none","&:hover":{backgroundColor:H=>H.palette.mode==="dark"?H.palette.grey[500]:H.palette.grey[300],boxShadow:"none"}},children:q?"Markdown":"Explore"}),P=g.jsxs(xt,{sx:{display:"flex",gap:1,justifyContent:"center",flex:2},children:[Y(!1,b.getCells().length),Y(!0,b.getCells().length)]});return g.jsxs(sb,{variant:"outlined",children:[g.jsxs($3,{children:[g.jsx(xt,{sx:{mb:2},children:g.jsx(xt,{sx:{minHeight:"24px"},children:h?g.jsx(ft,{color:"error",variant:"body2",children:h}):d?g.jsx(ft,{color:"success",variant:"body2",children:d}):g.jsx("span",{children:" "})})}),g.jsxs(Ku,{sx:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[g.jsxs(Ku,{direction:"row",spacing:1,alignItems:"center",children:[g.jsx(ft,{variant:"overline",sx:{fontSize:"13px",fontWeight:"bold",verticalAlign:"middle"},children:"Workbook"}),g.jsx(ft,{variant:"subtitle2",sx:{fontSize:"13px",fontWeight:"normal",verticalAlign:"middle",ml:1},children:`${e.workspace} > ${e.path}`})]}),g.jsxs(Ku,{sx:{display:"flex",flexDirection:"row",gap:1},children:[g.jsx(xt,{sx:{display:"flex",alignItems:"center",mt:1,mb:1},children:g.jsx(zhe,{workbookData:b})}),g.jsxs(xt,{sx:{display:"flex",alignItems:"center",mt:1,mb:1},children:[g.jsx(Ro,{color:"error",onClick:I,size:"small",children:"Delete"}),g.jsxs(ks,{open:w,onClose:_,children:[g.jsx(Ds,{children:"Delete Workbook"}),g.jsx(As,{children:g.jsxs(sG,{children:['Are you sure you want to delete the workbook "',e.path,'"? This action cannot be undone.']})}),g.jsxs(eT,{children:[g.jsx(Ro,{onClick:_,color:"primary",size:"small",children:"Cancel"}),g.jsx(Ro,{onClick:$,color:"error",autoFocus:!0,size:"small",children:"Delete"})]})]})]})]})]}),g.jsx(Wi,{}),g.jsxs(Ku,{sx:{display:"flex",flexDirection:"row",width:"100%",mt:2},children:[g.jsx(xt,{sx:{flex:1},children:g.jsx($he,{initialSelectedModels:b.getModels(),onModelChange:q=>{v(b.setModels(q)),G()},resourceUri:t})}),g.jsx(xt,{sx:{flex:1}})]})]}),g.jsx(RT,{children:g.jsxs(Ku,{children:[b.getCells().length===0&&g.jsxs(g.Fragment,{children:[g.jsx(ft,{sx:{textAlign:"center",p:2,variant:"subtitle2",fontWeight:"medium"},children:"Workbook is empty"}),g.jsx(ft,{variant:"body2",sx:{textAlign:"center",mb:2,variant:"body2"},children:"Click the + buttons to add a markdown or code cell."})]}),b.getCells().map((q,X)=>g.jsx(tt.Fragment,{children:g.jsx(Lhe,{cell:q,resourceUri:t,addButtonCallback:H=>Y(H,X),sourceAndPaths:V(T),editingMarkdown:S===X,editingMalloy:x===X,onDelete:()=>{v(b.deleteCell(X)),G()},onCellChange:H=>{v(b.setCell(X,H))},onEdit:()=>{q.isMarkdown?A(X):E(X)},onClose:()=>{q.isMarkdown?A(void 0):E(void 0),G()}},`${X}-${q.isMarkdown}-${e.workspace}-${e.path}`)},`${X}-${b.getCells().length}`)),P,g.jsxs(Qh,{anchorEl:D,open:z,onClose:j,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[g.jsx(Ol,{onClick:()=>U(!0,F??0),children:"Add Markdown"}),g.jsx(Ol,{onClick:()=>U(!1,F??0),children:"Add Malloy"})]}),g.jsx(Ku,{sx:{flexDirection:"row",justifyContent:"flex-end",p:1}})]})})]})}function zhe({workbookData:e}){const[t,n]=tt.useState(!1);return g.jsx(Ro,{color:"primary",onClick:async()=>{if(!e)return;const r=e.toMalloyWorkbook();try{await navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),1500)}catch{n(!1),alert("Failed to copy to clipboard")}},size:"small",children:t?"Copied!":"Export"})}const fP="Local";class Hhe{async listWorkspaces(t){return Promise.resolve([{name:fP,description:"Stored locally- only accessible to this browser",writeable:!0}])}async listWorkbooks(t){const n=[];for(let r=0;r<localStorage.length;r++){const o=localStorage.key(r);n.push({path:o,workspace:fP})}return n}async getWorkbook(t){const n=localStorage.getItem(t.path);if(n===null)throw new Error(`Notebook not found at path: ${t}`);return n}async deleteWorkbook(t){if(localStorage.getItem(t.path)===null)throw new Error(`Notebook not found at path: ${t}`);localStorage.removeItem(t.path)}async saveWorkbook(t,n){localStorage.setItem(t.path,n)}async moveWorkbook(t,n){const r=localStorage.getItem(t.path);if(r===null)throw new Error(`Notebook not found at path: ${t.path}`);localStorage.setItem(n.path,r),localStorage.removeItem(t.path)}}function Vhe({resourceUri:e}){const{environmentName:t}=Kr(e),{apiClients:n}=cr(),[r,o]=C.useState(!1),a=90,{data:i,isSuccess:l,isError:u,error:d}=bo({queryKey:["about",t],queryFn:()=>n.environments.getEnvironment(t,!1)}),f=i?.data?.readme||"",h=f.split(/\s+/),y=h.length>a,b=h.slice(0,a).join(" ");return g.jsxs(g.Fragment,{children:[!l&&!u&&g.jsx(ya,{text:"Fetching About..."}),l&&f&&g.jsx(z3,{children:g.jsxs(H3,{children:[g.jsx(V3,{children:"Readme"}),g.jsxs(xt,{sx:{mt:1,fontSize:"0.875rem",lineHeight:1.6},children:[g.jsx(nb,{options:{overrides:{h1:{component:"p",props:{style:{fontSize:"inherit",fontWeight:"italic"}}},h2:{component:"p",props:{style:{fontSize:"inherit",fontWeight:"italic"}}},h3:{component:"p",props:{style:{fontSize:"inherit",fontWeight:"italic"}}}}},children:r||!y?f:b}),y&&g.jsxs(xt,{sx:{mt:1},children:[" ",g.jsx(Ro,{variant:"text",size:"small",onClick:()=>o(!r),children:r?"Read less":"Read more"})]})]})]})}),u&&g.jsx(ba,{error:d,context:`${t} > About`})]})}function Whe({resourceUri:e}){const[t,n]=C.useState(!1),{apiClients:r}=cr(),o=Ls(),[a,i]=C.useState(""),{environmentName:l}=Kr(e),u=zi({async mutationFn(d){return r.packages.createPackage(l,{name:d.name,description:d.description,location:d.location})},onSuccess(){n(!1),i("Package created successfully"),o.invalidateQueries({queryKey:["packages",l]})},onError(d){i(d instanceof Error?d.message:"An unknown error occurred")}});return g.jsxs(g.Fragment,{children:[g.jsx(Ro,{onClick:()=>n(!0),variant:"contained",color:"primary",startIcon:g.jsx(kJ,{}),children:"Add Package"}),g.jsxs(ks,{open:t,onClose:()=>n(!1),maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:2}},children:[g.jsx(Ds,{sx:{fontSize:"1.25rem",fontWeight:600,letterSpacing:"-0.025em",pt:3,pb:1,px:3},children:"Create New Package"}),g.jsxs(As,{sx:{px:3,pb:0},children:[g.jsxs(xt,{sx:{mb:3},children:[g.jsx(ft,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"Create a new Malloy package to start exploring your data."}),g.jsx(ft,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The location can be a GitHub/S3/GCP URL containing a package (zipped or unzipped), or an absolute path to a directory the publisher server has access to."}),g.jsxs(ft,{variant:"body2",color:"text.secondary",children:["Make sure to conform to the"," ",g.jsx(xt,{component:"a",href:"https://github.com/malloydata/publisher/blob/main/README.md#architecture-overview",target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary",textDecoration:"underline"},children:"Malloy Package Format"}),"."]})]}),g.jsx("form",{onSubmit:d=>{d.preventDefault();const f=new FormData(d.currentTarget),h=f.get("name")?.toString(),y=f.get("description")?.toString(),b=f.get("location")?.toString();u.mutate({name:h,description:y,location:b})},id:"package-form",children:g.jsxs(lo,{spacing:2.5,children:[g.jsx(by,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Package Name",type:"text",fullWidth:!0,variant:"outlined",size:"small",InputLabelProps:{shrink:!0}}),g.jsx(by,{id:"description",name:"description",label:"Description",multiline:!0,rows:3,fullWidth:!0,variant:"outlined",size:"small",InputLabelProps:{shrink:!0}}),g.jsx(by,{id:"location",name:"location",label:"Location",type:"text",placeholder:"e.g. s3://my-bucket/my-package.zip",fullWidth:!0,variant:"outlined",size:"small",InputLabelProps:{shrink:!0}})]})})]}),g.jsxs(eT,{sx:{px:3,pt:2,pb:3,gap:1},children:[g.jsx(Ro,{variant:"outlined",disabled:u.isPending,onClick:()=>n(!1),children:"Cancel"}),g.jsx(Ro,{type:"submit",form:"package-form",variant:"contained",loading:u.isPending,children:"Save Changes"})]})]}),g.jsx(_s,{open:a!=="",autoHideDuration:6e3,onClose:()=>i(""),message:a})]})}const qhe=fr([g.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"),g.jsx("path",{d:"M9 12h6v2H9z"},"1")]),y6=Ie.oneOfType([Ie.func,Ie.object]);function pP(e){try{return e.matches(":focus-visible")}catch{}return!1}const hP={};function b6(e,t){const n=C.useRef(hP);return n.current===hP&&(n.current=e(t)),n}class bb{static create(){return new bb}static use(){const t=b6(bb.create).current,[n,r]=C.useState(!1);return t.shouldMount=n,t.setShouldMount=r,C.useEffect(t.mountEffect,[n]),t}constructor(){this.ref={current:null},this.mounted=null,this.didMount=!1,this.shouldMount=!1,this.setShouldMount=null}mount(){return this.mounted||(this.mounted=Yhe(),this.shouldMount=!0,this.setShouldMount(this.shouldMount)),this.mounted}mountEffect=()=>{this.shouldMount&&!this.didMount&&this.ref.current!==null&&(this.didMount=!0,this.mounted.resolve())};start(...t){this.mount().then(()=>this.ref.current?.start(...t))}stop(...t){this.mount().then(()=>this.ref.current?.stop(...t))}pulsate(...t){this.mount().then(()=>this.ref.current?.pulsate(...t))}}function Ghe(){return bb.use()}function Yhe(){let e,t;const n=new Promise((r,o)=>{e=r,t=o});return n.resolve=e,n.reject=t,n}function FE(e,t){return FE=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},FE(e,t)}function uw(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,FE(e,t)}function Khe(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Qhe(e,t){e.classList?e.classList.add(t):Khe(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function mP(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Xhe(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=mP(e.className,t):e.setAttribute("class",mP(e.className&&e.className.baseVal||"",t))}const gP={disabled:!1},vb=tt.createContext(null);var v6=function(e){return e.scrollTop},Hp="unmounted",mc="exited",gc="entering",od="entered",BE="exiting",mi=(function(e){uw(t,e);function t(r,o){var a;a=e.call(this,r,o)||this;var i=o,l=i&&!i.isMounting?r.enter:r.appear,u;return a.appearStatus=null,r.in?l?(u=mc,a.appearStatus=gc):u=od:r.unmountOnExit||r.mountOnEnter?u=Hp:u=mc,a.state={status:u},a.nextCallback=null,a}t.getDerivedStateFromProps=function(r,o){var a=r.in;return a&&o.status===Hp?{status:mc}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(r){var o=null;if(r!==this.props){var a=this.state.status;this.props.in?a!==gc&&a!==od&&(o=gc):(a===gc||a===od)&&(o=BE)}this.updateStatus(!1,o)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var r=this.props.timeout,o,a,i;return o=a=i=r,r!=null&&typeof r!="number"&&(o=r.exit,a=r.enter,i=r.appear!==void 0?r.appear:a),{exit:o,enter:a,appear:i}},n.updateStatus=function(r,o){if(r===void 0&&(r=!1),o!==null)if(this.cancelNextCallback(),o===gc){if(this.props.unmountOnExit||this.props.mountOnEnter){var a=this.props.nodeRef?this.props.nodeRef.current:El.findDOMNode(this);a&&v6(a)}this.performEnter(r)}else this.performExit();else this.props.unmountOnExit&&this.state.status===mc&&this.setState({status:Hp})},n.performEnter=function(r){var o=this,a=this.props.enter,i=this.context?this.context.isMounting:r,l=this.props.nodeRef?[i]:[El.findDOMNode(this),i],u=l[0],d=l[1],f=this.getTimeouts(),h=i?f.appear:f.enter;if(!r&&!a||gP.disabled){this.safeSetState({status:od},function(){o.props.onEntered(u)});return}this.props.onEnter(u,d),this.safeSetState({status:gc},function(){o.props.onEntering(u,d),o.onTransitionEnd(h,function(){o.safeSetState({status:od},function(){o.props.onEntered(u,d)})})})},n.performExit=function(){var r=this,o=this.props.exit,a=this.getTimeouts(),i=this.props.nodeRef?void 0:El.findDOMNode(this);if(!o||gP.disabled){this.safeSetState({status:mc},function(){r.props.onExited(i)});return}this.props.onExit(i),this.safeSetState({status:BE},function(){r.props.onExiting(i),r.onTransitionEnd(a.exit,function(){r.safeSetState({status:mc},function(){r.props.onExited(i)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(r,o){o=this.setNextCallback(o),this.setState(r,o)},n.setNextCallback=function(r){var o=this,a=!0;return this.nextCallback=function(i){a&&(a=!1,o.nextCallback=null,r(i))},this.nextCallback.cancel=function(){a=!1},this.nextCallback},n.onTransitionEnd=function(r,o){this.setNextCallback(o);var a=this.props.nodeRef?this.props.nodeRef.current:El.findDOMNode(this),i=r==null&&!this.props.addEndListener;if(!a||i){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var l=this.props.nodeRef?[this.nextCallback]:[a,this.nextCallback],u=l[0],d=l[1];this.props.addEndListener(u,d)}r!=null&&setTimeout(this.nextCallback,r)},n.render=function(){var r=this.state.status;if(r===Hp)return null;var o=this.props,a=o.children;o.in,o.mountOnEnter,o.unmountOnExit,o.appear,o.enter,o.exit,o.timeout,o.addEndListener,o.onEnter,o.onEntering,o.onEntered,o.onExit,o.onExiting,o.onExited,o.nodeRef;var i=Vt(o,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return tt.createElement(vb.Provider,{value:null},typeof a=="function"?a(r,i):tt.cloneElement(tt.Children.only(a),i))},t})(tt.Component);mi.contextType=vb;mi.propTypes={};function Ju(){}mi.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Ju,onEntering:Ju,onEntered:Ju,onExit:Ju,onExiting:Ju,onExited:Ju};mi.UNMOUNTED=Hp;mi.EXITED=mc;mi.ENTERING=gc;mi.ENTERED=od;mi.EXITING=BE;var Zhe=function(e,t){return e&&t&&t.split(" ").forEach(function(n){return Qhe(e,n)})},fS=function(e,t){return e&&t&&t.split(" ").forEach(function(n){return Xhe(e,n)})},dw=(function(e){uw(t,e);function t(){for(var r,o=arguments.length,a=new Array(o),i=0;i<o;i++)a[i]=arguments[i];return r=e.call.apply(e,[this].concat(a))||this,r.appliedClasses={appear:{},enter:{},exit:{}},r.onEnter=function(l,u){var d=r.resolveArguments(l,u),f=d[0],h=d[1];r.removeClasses(f,"exit"),r.addClass(f,h?"appear":"enter","base"),r.props.onEnter&&r.props.onEnter(l,u)},r.onEntering=function(l,u){var d=r.resolveArguments(l,u),f=d[0],h=d[1],y=h?"appear":"enter";r.addClass(f,y,"active"),r.props.onEntering&&r.props.onEntering(l,u)},r.onEntered=function(l,u){var d=r.resolveArguments(l,u),f=d[0],h=d[1],y=h?"appear":"enter";r.removeClasses(f,y),r.addClass(f,y,"done"),r.props.onEntered&&r.props.onEntered(l,u)},r.onExit=function(l){var u=r.resolveArguments(l),d=u[0];r.removeClasses(d,"appear"),r.removeClasses(d,"enter"),r.addClass(d,"exit","base"),r.props.onExit&&r.props.onExit(l)},r.onExiting=function(l){var u=r.resolveArguments(l),d=u[0];r.addClass(d,"exit","active"),r.props.onExiting&&r.props.onExiting(l)},r.onExited=function(l){var u=r.resolveArguments(l),d=u[0];r.removeClasses(d,"exit"),r.addClass(d,"exit","done"),r.props.onExited&&r.props.onExited(l)},r.resolveArguments=function(l,u){return r.props.nodeRef?[r.props.nodeRef.current,l]:[l,u]},r.getClassNames=function(l){var u=r.props.classNames,d=typeof u=="string",f=d&&u?u+"-":"",h=d?""+f+l:u[l],y=d?h+"-active":u[l+"Active"],b=d?h+"-done":u[l+"Done"];return{baseClassName:h,activeClassName:y,doneClassName:b}},r}var n=t.prototype;return n.addClass=function(r,o,a){var i=this.getClassNames(o)[a+"ClassName"],l=this.getClassNames("enter"),u=l.doneClassName;o==="appear"&&a==="done"&&u&&(i+=" "+u),a==="active"&&r&&v6(r),i&&(this.appliedClasses[o][a]=i,Zhe(r,i))},n.removeClasses=function(r,o){var a=this.appliedClasses[o],i=a.base,l=a.active,u=a.done;this.appliedClasses[o]={},i&&fS(r,i),l&&fS(r,l),u&&fS(r,u)},n.render=function(){var r=this.props;r.classNames;var o=Vt(r,["classNames"]);return tt.createElement(mi,ue({},o,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},t})(tt.Component);dw.defaultProps={classNames:""};dw.propTypes={};function Jhe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fw(e,t){var n=function(o){return t&&C.isValidElement(o)?t(o):o},r=Object.create(null);return e&&C.Children.map(e,function(o){return o}).forEach(function(o){r[o.key]=n(o)}),r}function eme(e,t){e=e||{},t=t||{};function n(f){return f in t?t[f]:e[f]}var r=Object.create(null),o=[];for(var a in e)a in t?o.length&&(r[a]=o,o=[]):o.push(a);var i,l={};for(var u in t){if(r[u])for(i=0;i<r[u].length;i++){var d=r[u][i];l[r[u][i]]=n(d)}l[u]=n(u)}for(i=0;i<o.length;i++)l[o[i]]=n(o[i]);return l}function wc(e,t,n){return n[t]!=null?n[t]:e.props[t]}function tme(e,t){return fw(e.children,function(n){return C.cloneElement(n,{onExited:t.bind(null,n),in:!0,appear:wc(n,"appear",e),enter:wc(n,"enter",e),exit:wc(n,"exit",e)})})}function nme(e,t,n){var r=fw(e.children),o=eme(t,r);return Object.keys(o).forEach(function(a){var i=o[a];if(C.isValidElement(i)){var l=a in t,u=a in r,d=t[a],f=C.isValidElement(d)&&!d.props.in;u&&(!l||f)?o[a]=C.cloneElement(i,{onExited:n.bind(null,i),in:!0,exit:wc(i,"exit",e),enter:wc(i,"enter",e)}):!u&&l&&!f?o[a]=C.cloneElement(i,{in:!1}):u&&l&&C.isValidElement(d)&&(o[a]=C.cloneElement(i,{onExited:n.bind(null,i),in:d.props.in,exit:wc(i,"exit",e),enter:wc(i,"enter",e)}))}}),o}var rme=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},ome={component:"div",childFactory:function(e){return e}},dm=(function(e){uw(t,e);function t(r,o){var a;a=e.call(this,r,o)||this;var i=a.handleExited.bind(Jhe(a));return a.state={contextValue:{isMounting:!0},handleExited:i,firstRender:!0},a}var n=t.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},t.getDerivedStateFromProps=function(r,o){var a=o.children,i=o.handleExited,l=o.firstRender;return{children:l?tme(r,i):nme(r,a,i),firstRender:!1}},n.handleExited=function(r,o){var a=fw(this.props.children);r.key in a||(r.props.onExited&&r.props.onExited(o),this.mounted&&this.setState(function(i){var l=ue({},i.children);return delete l[r.key],{children:l}}))},n.render=function(){var r=this.props,o=r.component,a=r.childFactory,i=Vt(r,["component","childFactory"]),l=this.state.contextValue,u=rme(this.state.children).map(a);return delete i.appear,delete i.enter,delete i.exit,o===null?tt.createElement(vb.Provider,{value:l},u):tt.createElement(vb.Provider,{value:l},tt.createElement(o,i,u))},t})(tt.Component);dm.propTypes={};dm.defaultProps=ome;const ame=[];function ime(e){C.useEffect(e,ame)}class pw{static create(){return new pw}currentId=null;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=null,n()},t)}clear=()=>{this.currentId!==null&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function hw(){const e=b6(pw.create).current;return ime(e.disposeEffect),e}function sme(e){const{className:t,classes:n,pulsate:r=!1,rippleX:o,rippleY:a,rippleSize:i,in:l,onExited:u,timeout:d}=e,[f,h]=C.useState(!1),y=pt(t,n.ripple,n.rippleVisible,r&&n.ripplePulsate),b={width:i,height:i,top:-(i/2)+a,left:-(i/2)+o},v=pt(n.child,f&&n.childLeaving,r&&n.childPulsate);return!l&&!f&&h(!0),C.useEffect(()=>{if(!l&&u!=null){const x=setTimeout(u,d);return()=>{clearTimeout(x)}}},[u,l,d]),g.jsx("span",{className:y,style:b,children:g.jsx("span",{className:v})})}const Fa=Ct("MuiTouchRipple",["root","ripple","rippleVisible","ripplePulsate","child","childLeaving","childPulsate"]),jE=550,lme=80,cme=Ki`
|
|
326
|
+
`).length,length:me.target.value.length}))}};return g.jsx(nf.Provider,{value:ue({},Y,{dispatch:P}),children:g.jsxs("div",ue({ref:q,className:re},_,{onClick:le,style:oe,children:[g.jsx(dP,{hideToolbar:w,toolbarBottom:L,prefixCls:r,overflow:E,placement:"top"}),g.jsxs("div",{className:r+"-content",children:[/(edit|live)/.test(Y.preview||"")&&g.jsx(Ehe,ue({className:r+"-input",prefixCls:r,autoFocus:D},A,{onChange:De,renderTextarea:I?.textarea||$,onScroll:me=>ee(me,"text")})),/(live|preview)/.test(Y.preview||"")&&ce]}),y&&!Y.fullscreen&&g.jsx(The,{prefixCls:r,height:Y.height,maxHeight:T,minHeight:M,onChange:Be}),g.jsx(dP,{hideToolbar:w,toolbarBottom:L,prefixCls:r,overflow:E,placement:"bottom"})]}))})}),h6=Ahe;h6.Markdown=i6;const uS={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"}]}}},Dhe={...uS,patterns:[...uS.patterns,{include:"#docvar"}],repository:{...uS.repository,docvar:{patterns:[{match:"\\<\\<[^(\\>\\>)]*\\>\\>",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"markup.italic.markdown"}]}}},Rhe={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"}]}}},Mhe="github-light";let dS;function Ohe(){return dS||(dS=(async()=>{const[{createHighlighterCore:e},{createOnigurumaEngine:t},{default:n},{default:r},{default:o},{default:a}]=await Promise.all([io(()=>import("./core-CbsC6R_Y.es-Cwf6asf3.js"),__vite__mapDeps([0,1])),io(()=>import("./engine-oniguruma-C4vnmooL.es-jdkXmgTr.js"),[]),io(()=>import("./sql-DCkt643-.es-COK4E0Yg.js"),[]),io(()=>import("./json-71t8ZF9g.es-BQoSv7ci.js"),[]),io(()=>import("./typescript-buWNZFwO.es-Dj6nwHGl.js"),[]),io(()=>import("./github-light-JYsPkUQd.es-DAi9KRSo.js"),[])]);return e({engine:t(io(()=>import("./wasm-DQxwEHae.es-CG6Dc4jp.js"),[])),themes:[a],langs:[n,r,o,{name:"malloy",scopeName:"source.malloy",embeddedLangs:["sql"],...Dhe},{name:"malloysql",scopeName:"source.malloy-sql",embeddedLangs:["sql"],...Rhe}]})})()),dS}async function yb(e,t){return(await Ohe()).codeToHtml(e,{lang:t,theme:Mhe})}function bo(e){const{server:t}=cr(),n={...e,queryKey:[...e.queryKey,t],queryFn:async()=>{try{return await e.queryFn()}catch(r){if(r&&typeof r=="object"&&"response"in r){const o=r;if(o.response?.data){const a=new Error(o.response.data.message||o.message);throw a.status=o.response.status,a.data=o.response.data,a}}throw r}},retry:!1,throwOnError:!1};return SQ(n,gT)}function zi(e){const t={...e,mutationFn:async n=>{try{return await e.mutationFn(n)}catch(r){if(r&&typeof r=="object"&&"response"in r){const o=r;if(o.response?.data){const a=new Error(o.response.data.message||o.message);throw a.status=o.response.status,a.data=o.response.data,a}}throw r}},retry:!1,throwOnError:!1};return EQ(t,gT)}const Kr=e=>{const t=new URL(e),n={};if(t.protocol!=="publisher:")throw new Error(`Failed to parse resource URI: ${e}`);const r=(t.hostname+t.pathname).split("/");for(let o=0;o<r.length;o+=2){const a=r[o];a==="environments"?n.environmentName=decodeURI(r[o+1])||void 0:a==="packages"?n.packageName=decodeURI(r[o+1])||void 0:a==="connections"?n.connectionName=decodeURI(r[o+1])||void 0:a==="models"&&(n.modelPath=decodeURI(r.slice(o+1).join("/"))||void 0)}if(n.versionId=t.searchParams.get("versionId")||void 0,!n.environmentName)throw new Error(`Failed to parse resource URI: ${e}`);return n},cw=e=>{if(!e.environmentName)throw new Error(`Failed to encode resource URI, missing environment name: ${e}`);let t=`publisher://environments/${e.environmentName}`;return e.packageName&&(t+=`/packages/${e.packageName}`),e.connectionName&&(t+=`/connections/${e.connectionName}`),e.modelPath&&(t+=`/models/${e.modelPath}`),e.packageName&&e.versionId&&(t+=`?versionId=${e.versionId}`),t};function m6({sourceAndPaths:e,selectedSourceIndex:t,existingQuery:n,onQueryChange:r,onSourceChange:o,resourceUri:a}){return tt.useEffect(()=>{o&&o(t)},[t,o]),g.jsx(RT,{children:g.jsxs(Az,{spacing:2,component:"section",children:[g.jsx(Phe,{sourceAndPath:e[t],existingQuery:n,onChange:i=>{r&&r(i)},resourceUri:a}),g.jsx(k_,{height:"5px"})]})})}function Iy(){return{query:void 0,malloyQuery:void 0,malloyResult:void 0}}function Nhe({sourceAndPath:e,onChange:t,existingQuery:n,explorerComponents:r,QueryBuilder:o,resourceUri:a}){const[i,l]=tt.useState(n||Iy()),[u,d]=tt.useState(void 0);tt.useEffect(()=>{n&&l(n)},[n]);const[f,h]=tt.useState([]),{MalloyExplorerProvider:y,QueryPanel:b,ResizableCollapsiblePanel:v,ResultPanel:x,SourcePanel:E}=r;tt.useEffect(()=>{t&&t(i)},[t,i]);const{environmentName:S,packageName:A,versionId:T}=Kr(a),{apiClients:M}=cr(),D=zi({mutationFn:()=>{const z=typeof i?.malloyQuery=="string"?i.malloyQuery:new o.ASTQuery({source:e.sourceInfo,query:i?.malloyQuery}).toMalloy();return d({executionState:"running",query:i?.malloyQuery,queryResolutionStartMillis:Date.now(),onCancel:()=>{D.reset(),d(void 0)},response:{result:{}}}),l({...i,query:z}),M.models.executeQueryModel(S,A,e.modelPath,{query:z,sourceName:void 0,queryName:void 0,versionId:T})},onSuccess:z=>{if(z){const j=JSON.parse(z.data.result);l({...i,malloyResult:j}),d(U=>U?{...U,executionState:"finished",response:{result:j}}:void 0)}},onError:z=>{d(void 0),console.error("Query execution error:",z)}}),[R,F]=tt.useState(e.sourceInfo.name);tt.useEffect(()=>{R!==e.sourceInfo.name&&(F(e.sourceInfo.name),l(Iy()),d(void 0))},[e,R]);const B=tt.useCallback(z=>{l({...i,malloyQuery:z,malloyResult:void 0})},[i]);return R!==e.sourceInfo.name?g.jsx("div",{children:"Loading..."}):g.jsx(U3,{sx:{border:"1px solid #e0e0e0",borderRadius:"8px",overflow:"hidden"},children:g.jsx(y,{source:e.sourceInfo,query:i?.malloyQuery,topValues:[],onFocusedNestViewPathChange:h,focusedNestViewPath:f,onQueryChange:B,children:g.jsxs("div",{style:{display:"flex",height:"100%",overflowY:"auto"},children:[g.jsx(v,{isInitiallyExpanded:!0,initialWidth:180,minWidth:180,icon:"database",title:e.sourceInfo.name,children:g.jsx(E,{onRefresh:()=>l(Iy())})}),g.jsx(v,{isInitiallyExpanded:!0,initialWidth:280,minWidth:280,icon:"filterSliders",title:"Query",children:g.jsx(b,{runQuery:()=>{console.log(`running query with: ${i?.malloyQuery}`);try{D.mutate()}catch(z){console.error("Error running query:",z)}}})}),g.jsx(x,{source:e.sourceInfo,draftQuery:i?.malloyQuery,setDraftQuery:z=>l({...i,malloyQuery:z}),submittedQuery:u,options:{showRawQuery:!0}})]})})},e.sourceInfo.name)}function Phe(e){const[t,n]=C.useState(null),[r,o]=C.useState(null),[a,i]=C.useState(!0);return C.useEffect(()=>{let l=!0;return Promise.all([io(()=>import("./index-DL6BZTuw.js"),__vite__mapDeps([2,3,4])),io(()=>import("./index-DNofXMxi.js").then(u=>u.i),[])]).then(([u,d])=>{l&&(n(u),o(d),i(!1))}).catch(u=>{console.error("Failed to load Malloy components:",u),l&&i(!1)}),()=>{l=!1}},[]),a||!t||!r?g.jsx(one,{children:g.jsx(U3,{children:g.jsx(k_,{sx:{alignItems:"center",justifyContent:"center",height:"200px",color:"text.secondary"},children:"Loading explorer..."})})}):g.jsx(Nhe,{...e,explorerComponents:t,QueryBuilder:r,resourceUri:e.resourceUri})}function ya({text:e,size:t=20,color:n="primary",thickness:r=3.6,centered:o=!0,spacing:a=2,textVariant:i="body2"}){const l=g.jsxs(xt,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:a},children:[g.jsx(Kb,{size:t,color:n,thickness:r}),e&&g.jsx(ft,{variant:i,color:"text.secondary",children:e})]});return o?g.jsx(xt,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"200px",width:"100%"},children:l}):l}const Ihe=C.lazy(()=>Promise.resolve().then(()=>wTe));function _v({result:e,maxHeight:t,maxResultSize:n=0}){const r=C.useRef(null),[o,a]=C.useState(t),[i,l]=C.useState(!1);if(!e)return null;if(n>0&&e.length>n&&!i)return g.jsxs(xt,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,p:4,backgroundColor:"#fafafa",border:"1px solid",borderColor:"#e0e0e0",borderRadius:1},children:[g.jsx(DJ,{sx:{fontSize:48,color:"#757575"}}),g.jsx(ft,{variant:"h6",color:"text.secondary",align:"center",children:"Processing large results may cause browser performance issues. Proceed?"}),g.jsx(Ro,{variant:"contained",color:"primary",onClick:()=>l(!0),children:"Proceed"})]});const u=g.jsx(ya,{text:"Loading...",centered:!0,size:32}),d=Math.min(t,o);return g.jsx(xt,{ref:r,sx:{position:"relative",height:"auto",border:"0px",borderRadius:0,overflow:"hidden"},children:e&&g.jsx(C.Suspense,{fallback:u,children:g.jsx(Ihe,{result:e,height:d,onSizeChange:a})})})}function _he({cell:e,sourceAndPaths:t,resourceUri:n,onQueryChange:r,onSourceChange:o}){const a={query:e.value,malloyResult:e.result?JSON.parse(e.result):void 0,malloyQuery:e.queryInfo?JSON.parse(e.queryInfo):void 0},i=t.findIndex(l=>l.sourceInfo.name===e.sourceName);return g.jsx(m6,{resourceUri:n,sourceAndPaths:t,selectedSourceIndex:i>=0?i:0,existingQuery:a,onQueryChange:r,onSourceChange:o})}function Lhe({cell:e,editingMalloy:t,editingMarkdown:n,sourceAndPaths:r,resourceUri:o,onCellChange:a,onClose:i,onEdit:l,onDelete:u,addButtonCallback:d}){const[f,h]=C.useState(e.value),[y,b]=tt.useState(!1),[v,x]=tt.useState(!1),[E,S]=tt.useState(),[A]=tt.useState(),[T,M]=tt.useState(Iy()),[D,R]=tt.useState(!1),[F,B]=tt.useState(e.sourceName?r.findIndex(q=>q.sourceInfo.name===e.sourceName):0);C.useEffect(()=>{e.isMarkdown||yb(e.value,"malloy").then(q=>{S(q)})},[e]),tt.useEffect(()=>{document.documentElement.setAttribute("data-color-mode","light")});const[z,j]=C.useState(!1),U=()=>{u(),j(!1)},w=r.length===0,L=tt.useCallback(()=>{const q=r[F],X=q?.modelPath||e.modelPath||"",H=q?.sourceInfo.name||e.sourceName||"";a({...e,value:e.isMarkdown?f:T.query,result:T.malloyResult?JSON.stringify(T.malloyResult):void 0,queryInfo:T.malloyQuery?JSON.stringify(T.malloyQuery):void 0,sourceName:H,modelPath:X})},[e,f,T,a,F,r]),I=g.jsx(jo,{title:"Delete Cell",children:g.jsx(Cr,{size:"small",onClick:()=>j(!0),children:g.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m2 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14zM10 11v6M14 11v6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}),$=g.jsxs(ks,{open:z,onClose:()=>j(!1),children:[g.jsx(Ds,{children:"Confirm Delete"}),g.jsx(As,{children:g.jsx(ft,{children:"Are you sure you want to delete this cell?"})}),g.jsxs(eT,{children:[g.jsx(Ro,{onClick:()=>j(!1),children:"Cancel"}),g.jsx(Ro,{onClick:U,color:"error",children:"Delete"})]})]}),_=()=>{L(),i()},G=e.isMarkdown?g.jsxs(g.Fragment,{children:[n?g.jsx(jo,{title:"Save",children:g.jsx(Cr,{size:"small",onClick:_,children:g.jsx(Vg,{})})}):g.jsx(jo,{title:"Edit",children:g.jsx(Cr,{size:"small",onClick:l,children:g.jsx(NO,{})})}),!n&&I]}):g.jsxs(g.Fragment,{children:[!t&&g.jsx(jo,{title:y?"Hide Code":"View Code",children:g.jsx(Cr,{size:"small",onClick:()=>{b(!y)},children:g.jsx(W3,{})})}),!t&&e.result&&g.jsx(jo,{title:v?"Hide Embedding":"View Embedding",children:g.jsx(Cr,{size:"small",onClick:()=>{x(!v)},children:g.jsx(MT,{})})}),t&&g.jsx(jo,{title:"Save",children:g.jsx(Cr,{size:"small",onClick:_,children:g.jsx(Vg,{})})}),!t&&g.jsx(jo,{title:"Edit",children:g.jsx(Cr,{size:"small",onClick:l,children:g.jsx(NO,{})})}),!t&&I]}),V=t||n,Y=n?g.jsx(jo,{title:"Save",children:g.jsx(Cr,{size:"small",onClick:_,children:g.jsx(Vg,{})})}):t?g.jsx(jo,{title:"Save",children:g.jsx(Cr,{size:"small",onClick:_,children:g.jsx(Vg,{})})}):null,P=D&&g.jsx(xt,{sx:{position:"absolute",top:"4px",right:"4px",display:"flex",gap:"8px",backgroundColor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",padding:"2px 4px",boxShadow:1,zIndex:10},children:!V&&g.jsxs(g.Fragment,{children:[d(!0),d(!1),G]})||Y});return g.jsxs(sb,{sx:{position:"relative",marginTop:"5px",marginBottom:"5px",borderWidth:"1.5px",backgroundColor:"#fff",minHeight:"50px"},onMouseEnter:()=>R(!0),onMouseLeave:()=>{R(!1)},children:[P,e.isMarkdown?g.jsx(g.Fragment,{children:n?g.jsx(h6,{value:f,preview:"edit",autoFocus:!0,onChange:q=>{h(q),a({...e,value:q})},onBlur:()=>{L(),D||_()}}):g.jsx(xt,{sx:{px:.5,pt:0,mt:0,"& h1, & h2, & h3, & h4, & h5, & h6":{mt:.5,mb:.5},"& p":{mt:.5,mb:.5},"& ul, & ol":{mt:.5,mb:.5},"& li":{mt:0,mb:0},"& pre, & code":{mt:.5,mb:.5},"& blockquote":{mt:.5,mb:.5}},children:e.value?g.jsx(xt,{onClick:l,sx:{cursor:"pointer"},children:g.jsx(nb,{children:e.value})}):g.jsxs(xt,{onClick:l,sx:{cursor:"pointer"},children:[g.jsx(ft,{sx:{p:2,textAlign:"center",variant:"subtitle2",fontWeight:"medium"},children:"Markdown is empty"}),g.jsx(ft,{sx:{mb:2,textAlign:"center",variant:"body2"},children:"Click to edit."})]})})}):g.jsxs(g.Fragment,{children:[g.jsx(Gy,{in:v,timeout:"auto",unmountOnExit:!0,children:g.jsx(lo,{sx:{p:"10px",borderRadius:0,flexDirection:"row",justifyContent:"space-between"},children:g.jsx(ft,{component:"div",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},dangerouslySetInnerHTML:{__html:A}})})}),g.jsx(Gy,{in:y,timeout:"auto",unmountOnExit:!0,children:g.jsx(lo,{sx:{p:"10px",borderRadius:0,flexDirection:"row",justifyContent:"space-between"},children:g.jsx(ft,{component:"div",className:"content",sx:{fontSize:"12px","& .line":{textWrap:"wrap"}},dangerouslySetInnerHTML:{__html:E}})})}),t&&(w?g.jsxs(g.Fragment,{children:[g.jsx(ft,{sx:{p:2,textAlign:"center",variant:"subtitle2",fontWeight:"medium"},children:"No Model Imports"}),g.jsx(ft,{sx:{mb:2,textAlign:"center",variant:"body2"},children:"Please add a model import above."})]}):g.jsx(_he,{sourceAndPaths:r,resourceUri:o,onQueryChange:q=>{M(q)},onSourceChange:q=>{B(q)},cell:e})),!t&&e.result&&g.jsx(sb,{variant:"outlined",sx:{borderRadius:0},children:g.jsx(_v,{result:e.result,maxHeight:800})}),!t&&!e.result&&g.jsxs(xt,{onClick:l,sx:{cursor:"pointer"},children:[g.jsx(ft,{sx:{p:2,textAlign:"center",variant:"subtitle2",fontWeight:"medium"},children:"Explore is empty"}),g.jsx(ft,{sx:{mb:2,textAlign:"center",variant:"body2"},children:"Click to edit."})]})]}),z&&$]})}const g6=C.createContext(void 0);function Fhe({children:e,workbookStorage:t}){const n=C.useMemo(()=>({workbookStorage:t}),[t]);return g.jsx(g6.Provider,{value:n,children:e})}function Bhe(){const e=C.useContext(g6);if(!e)throw new Error("useWorkbookStorage must be used within a WorkbookStorageProvider");return e}const Ns=fr(g.jsx("path",{d:"M19 6.41 17.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"})),jhe=fr(g.jsx("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3zM7 9l1.41 1.41L11 7.83V16h2V7.83l2.59 2.58L17 9l-5-5z"}));function ba({error:e,context:t}){const n=e.data?.message||"Unknown Error";return g.jsxs(g.Fragment,{children:[t&&g.jsx(ft,{variant:"body2",sx:{p:"10px",m:"auto"},children:t}),g.jsx("pre",{style:{whiteSpace:"pre-wrap",color:"red",padding:"10px",margin:"auto"},children:n})]})}function $he({initialSelectedModels:e,onModelChange:t,resourceUri:n}){const{environmentName:r,packageName:o,versionId:a}=Kr(n),{apiClients:i}=cr(),{data:l,isLoading:u,isSuccess:d,isError:f,error:h}=bo({queryKey:["models",r,o,a],queryFn:()=>i.models.listModels(r,o,a)}),[y,b]=tt.useState(e||[]),[v,x]=tt.useState(null);tt.useEffect(()=>{b(e||[])},[e]);const E=T=>{const M=y.filter(D=>D!==T);b(M),t(M)},S=T=>{const M=[...y,T];b(M),t(M),x(null)};let A=[];return d&&l?.data&&(A=l.data.filter(T=>!y.includes(T.path)).map(T=>T.path)),f?g.jsx(ba,{error:h,context:`${r} > ${o} > Model Picker`}):g.jsxs(g.Fragment,{children:[g.jsxs(v5,{fullWidth:!0,children:[u&&g.jsx(ft,{children:"Loading..."}),g.jsxs(lo,{direction:"row",spacing:1,children:[y.map(T=>g.jsx(MW,{label:T,onDelete:()=>E(T),deleteIcon:g.jsx(Ns,{}),sx:{marginBottom:"5px"}},T)),g.jsx(Ro,{size:"small",startIcon:g.jsx(jhe,{}),onClick:T=>x(T.currentTarget),disabled:u||f||A.length===0,children:"Add Model"})]})]}),g.jsxs(Qh,{anchorEl:v,open:!!v,onClose:()=>x(null),children:[g.jsx(ft,{variant:"subtitle2",sx:{ml:1},children:"Models"}),g.jsx(Wi,{}),A.length===0?g.jsx(Ol,{disabled:!0,children:"No models available"}):A.map(T=>g.jsx(Ol,{onClick:()=>S(T),children:g.jsx(ft,{variant:"body2",children:T})},T))]})]})}function Uhe(){const e=ZI();return(t,n)=>{if(!n||!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.button!==1){e(t);return}const r=new URL(t,window.location.href).href;(n.metaKey||n.ctrlKey||n.button===1||n.shiftKey)&&window.open(r,"_blank")}}function gwe({workbookPath:e,resourceUri:t}){const n=Uhe(),{server:r,getAccessToken:o}=cr(),{apiClients:a}=cr(),{workbookStorage:i}=Bhe(),{environmentName:l,packageName:u}=Kr(t),[d,f]=tt.useState(void 0),[h,y]=tt.useState(void 0);if(!i)throw new Error("Workbook storage be provided via WorkbookStorageProvider");const[b,v]=tt.useState(),[x,E]=tt.useState(),[S,A]=tt.useState(),[T,M]=tt.useState([]),[D,R]=tt.useState(null),[F,B]=tt.useState(null),z=!!D,j=()=>{R(null),B(null)},U=(q,X)=>{b&&(v(b.insertCell(X,{isMarkdown:q,value:""})),q?A(X):E(X),j(),console.log("handleAddCell",q,X))},[w,L]=tt.useState(!1),I=()=>{L(!0)},$=async()=>{e&&i&&await i.deleteWorkbook(e).then(()=>{y(void 0),f(void 0)}).catch(q=>{y(`Error deleting workbook: ${q.message}`),f(void 0)}),L(!1),n(`/${l}/${u}`)},_=()=>{L(!1)},G=tt.useCallback(async()=>{if(!b){console.log("No workbook data ref");return}try{v(await b.saveWorkbook()),y(void 0),f("Workbook saved")}catch(q){y(`Error saving workbook: ${q.message}`),f(void 0)}},[b]);if(tt.useEffect(()=>{b&&(async()=>{const q=new Map(T.map(({modelPath:re,sourceInfos:Z})=>[re,Z])),X=[],H=[];for(const re of b.getModels())q.has(re)?X.push({modelPath:re,sourceInfos:q.get(re)}):(console.log("Fetching model from Publisher",re),H.push(a.models.getModel(l,u,re,void 0).then(Z=>({modelPath:re,sourceInfos:Z.data.sourceInfos.map(K=>JSON.parse(K))}))));if(H.length>0){const re=await Promise.all(H);M([...X,...re])}else M(X)})()},[o,b,u,l,r]),tt.useEffect(()=>{e&&Xp.loadWorkbook(i,e).then(q=>{v(q)})},[e,i]),!b)return g.jsx("div",{children:"Loading..."});const V=q=>{const X=[];for(const H of q)for(const re of H.sourceInfos)X.push({modelPath:H.modelPath,sourceInfo:re});return X},Y=(q,X)=>g.jsx(Ro,{size:"small",startIcon:g.jsx(DT,{}),onClick:()=>U(q,X),variant:"contained",sx:{backgroundColor:"#fff",color:H=>H.palette.mode==="dark"?H.palette.grey[100]:H.palette.grey[700],boxShadow:"none","&:hover":{backgroundColor:H=>H.palette.mode==="dark"?H.palette.grey[500]:H.palette.grey[300],boxShadow:"none"}},children:q?"Markdown":"Explore"}),P=g.jsxs(xt,{sx:{display:"flex",gap:1,justifyContent:"center",flex:2},children:[Y(!1,b.getCells().length),Y(!0,b.getCells().length)]});return g.jsxs(sb,{variant:"outlined",children:[g.jsxs($3,{children:[g.jsx(xt,{sx:{mb:2},children:g.jsx(xt,{sx:{minHeight:"24px"},children:h?g.jsx(ft,{color:"error",variant:"body2",children:h}):d?g.jsx(ft,{color:"success",variant:"body2",children:d}):g.jsx("span",{children:" "})})}),g.jsxs(Ku,{sx:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[g.jsxs(Ku,{direction:"row",spacing:1,alignItems:"center",children:[g.jsx(ft,{variant:"overline",sx:{fontSize:"13px",fontWeight:"bold",verticalAlign:"middle"},children:"Workbook"}),g.jsx(ft,{variant:"subtitle2",sx:{fontSize:"13px",fontWeight:"normal",verticalAlign:"middle",ml:1},children:`${e.workspace} > ${e.path}`})]}),g.jsxs(Ku,{sx:{display:"flex",flexDirection:"row",gap:1},children:[g.jsx(xt,{sx:{display:"flex",alignItems:"center",mt:1,mb:1},children:g.jsx(zhe,{workbookData:b})}),g.jsxs(xt,{sx:{display:"flex",alignItems:"center",mt:1,mb:1},children:[g.jsx(Ro,{color:"error",onClick:I,size:"small",children:"Delete"}),g.jsxs(ks,{open:w,onClose:_,children:[g.jsx(Ds,{children:"Delete Workbook"}),g.jsx(As,{children:g.jsxs(sG,{children:['Are you sure you want to delete the workbook "',e.path,'"? This action cannot be undone.']})}),g.jsxs(eT,{children:[g.jsx(Ro,{onClick:_,color:"primary",size:"small",children:"Cancel"}),g.jsx(Ro,{onClick:$,color:"error",autoFocus:!0,size:"small",children:"Delete"})]})]})]})]})]}),g.jsx(Wi,{}),g.jsxs(Ku,{sx:{display:"flex",flexDirection:"row",width:"100%",mt:2},children:[g.jsx(xt,{sx:{flex:1},children:g.jsx($he,{initialSelectedModels:b.getModels(),onModelChange:q=>{v(b.setModels(q)),G()},resourceUri:t})}),g.jsx(xt,{sx:{flex:1}})]})]}),g.jsx(RT,{children:g.jsxs(Ku,{children:[b.getCells().length===0&&g.jsxs(g.Fragment,{children:[g.jsx(ft,{sx:{textAlign:"center",p:2,variant:"subtitle2",fontWeight:"medium"},children:"Workbook is empty"}),g.jsx(ft,{variant:"body2",sx:{textAlign:"center",mb:2,variant:"body2"},children:"Click the + buttons to add a markdown or code cell."})]}),b.getCells().map((q,X)=>g.jsx(tt.Fragment,{children:g.jsx(Lhe,{cell:q,resourceUri:t,addButtonCallback:H=>Y(H,X),sourceAndPaths:V(T),editingMarkdown:S===X,editingMalloy:x===X,onDelete:()=>{v(b.deleteCell(X)),G()},onCellChange:H=>{v(b.setCell(X,H))},onEdit:()=>{q.isMarkdown?A(X):E(X)},onClose:()=>{q.isMarkdown?A(void 0):E(void 0),G()}},`${X}-${q.isMarkdown}-${e.workspace}-${e.path}`)},`${X}-${b.getCells().length}`)),P,g.jsxs(Qh,{anchorEl:D,open:z,onClose:j,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[g.jsx(Ol,{onClick:()=>U(!0,F??0),children:"Add Markdown"}),g.jsx(Ol,{onClick:()=>U(!1,F??0),children:"Add Malloy"})]}),g.jsx(Ku,{sx:{flexDirection:"row",justifyContent:"flex-end",p:1}})]})})]})}function zhe({workbookData:e}){const[t,n]=tt.useState(!1);return g.jsx(Ro,{color:"primary",onClick:async()=>{if(!e)return;const r=e.toMalloyWorkbook();try{await navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),1500)}catch{n(!1),alert("Failed to copy to clipboard")}},size:"small",children:t?"Copied!":"Export"})}const fP="Local";class Hhe{async listWorkspaces(t){return Promise.resolve([{name:fP,description:"Stored locally- only accessible to this browser",writeable:!0}])}async listWorkbooks(t){const n=[];for(let r=0;r<localStorage.length;r++){const o=localStorage.key(r);n.push({path:o,workspace:fP})}return n}async getWorkbook(t){const n=localStorage.getItem(t.path);if(n===null)throw new Error(`Notebook not found at path: ${t}`);return n}async deleteWorkbook(t){if(localStorage.getItem(t.path)===null)throw new Error(`Notebook not found at path: ${t}`);localStorage.removeItem(t.path)}async saveWorkbook(t,n){localStorage.setItem(t.path,n)}async moveWorkbook(t,n){const r=localStorage.getItem(t.path);if(r===null)throw new Error(`Notebook not found at path: ${t.path}`);localStorage.setItem(n.path,r),localStorage.removeItem(t.path)}}function Vhe({resourceUri:e}){const{environmentName:t}=Kr(e),{apiClients:n}=cr(),[r,o]=C.useState(!1),a=90,{data:i,isSuccess:l,isError:u,error:d}=bo({queryKey:["about",t],queryFn:()=>n.environments.getEnvironment(t,!1)}),f=i?.data?.readme||"",h=f.split(/\s+/),y=h.length>a,b=h.slice(0,a).join(" ");return g.jsxs(g.Fragment,{children:[!l&&!u&&g.jsx(ya,{text:"Fetching About..."}),l&&f&&g.jsx(z3,{children:g.jsxs(H3,{children:[g.jsx(V3,{children:"Readme"}),g.jsxs(xt,{sx:{mt:1,fontSize:"0.875rem",lineHeight:1.6},children:[g.jsx(nb,{options:{overrides:{h1:{component:"p",props:{style:{fontSize:"inherit",fontWeight:"italic"}}},h2:{component:"p",props:{style:{fontSize:"inherit",fontWeight:"italic"}}},h3:{component:"p",props:{style:{fontSize:"inherit",fontWeight:"italic"}}}}},children:r||!y?f:b}),y&&g.jsxs(xt,{sx:{mt:1},children:[" ",g.jsx(Ro,{variant:"text",size:"small",onClick:()=>o(!r),children:r?"Read less":"Read more"})]})]})]})}),u&&g.jsx(ba,{error:d,context:`${t} > About`})]})}function Whe({resourceUri:e}){const[t,n]=C.useState(!1),{apiClients:r}=cr(),o=Ls(),[a,i]=C.useState(""),{environmentName:l}=Kr(e),u=zi({async mutationFn(d){return r.packages.createPackage(l,{name:d.name,description:d.description,location:d.location})},onSuccess(){n(!1),i("Package created successfully"),o.invalidateQueries({queryKey:["packages",l]})},onError(d){i(d instanceof Error?d.message:"An unknown error occurred")}});return g.jsxs(g.Fragment,{children:[g.jsx(Ro,{onClick:()=>n(!0),variant:"contained",color:"primary",startIcon:g.jsx(kJ,{}),children:"Add Package"}),g.jsxs(ks,{open:t,onClose:()=>n(!1),maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:2}},children:[g.jsx(Ds,{sx:{fontSize:"1.25rem",fontWeight:600,letterSpacing:"-0.025em",pt:3,pb:1,px:3},children:"Create New Package"}),g.jsxs(As,{sx:{px:3,pb:0},children:[g.jsxs(xt,{sx:{mb:3},children:[g.jsx(ft,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"Create a new Malloy package to start exploring your data."}),g.jsx(ft,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The location can be a GitHub/S3/GCP URL containing a package (zipped or unzipped), or an absolute path to a directory the publisher server has access to."}),g.jsxs(ft,{variant:"body2",color:"text.secondary",children:["Make sure to conform to the"," ",g.jsx(xt,{component:"a",href:"https://github.com/malloydata/publisher/blob/main/README.md#architecture-overview",target:"_blank",rel:"noopener noreferrer",sx:{color:"text.primary",textDecoration:"underline"},children:"Malloy Package Format"}),"."]})]}),g.jsx("form",{onSubmit:d=>{d.preventDefault();const f=new FormData(d.currentTarget),h=f.get("name")?.toString(),y=f.get("description")?.toString(),b=f.get("location")?.toString();u.mutate({name:h,description:y,location:b})},id:"package-form",children:g.jsxs(lo,{spacing:2.5,children:[g.jsx(by,{autoFocus:!0,required:!0,id:"name",name:"name",label:"Package Name",type:"text",fullWidth:!0,variant:"outlined",size:"small",InputLabelProps:{shrink:!0}}),g.jsx(by,{id:"description",name:"description",label:"Description",multiline:!0,rows:3,fullWidth:!0,variant:"outlined",size:"small",InputLabelProps:{shrink:!0}}),g.jsx(by,{id:"location",name:"location",label:"Location",type:"text",placeholder:"e.g. s3://my-bucket/my-package.zip",fullWidth:!0,variant:"outlined",size:"small",InputLabelProps:{shrink:!0}})]})})]}),g.jsxs(eT,{sx:{px:3,pt:2,pb:3,gap:1},children:[g.jsx(Ro,{variant:"outlined",disabled:u.isPending,onClick:()=>n(!1),children:"Cancel"}),g.jsx(Ro,{type:"submit",form:"package-form",variant:"contained",loading:u.isPending,children:"Save Changes"})]})]}),g.jsx(_s,{open:a!=="",autoHideDuration:6e3,onClose:()=>i(""),message:a})]})}const qhe=fr([g.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"),g.jsx("path",{d:"M9 12h6v2H9z"},"1")]),y6=Ie.oneOfType([Ie.func,Ie.object]);function pP(e){try{return e.matches(":focus-visible")}catch{}return!1}const hP={};function b6(e,t){const n=C.useRef(hP);return n.current===hP&&(n.current=e(t)),n}class bb{static create(){return new bb}static use(){const t=b6(bb.create).current,[n,r]=C.useState(!1);return t.shouldMount=n,t.setShouldMount=r,C.useEffect(t.mountEffect,[n]),t}constructor(){this.ref={current:null},this.mounted=null,this.didMount=!1,this.shouldMount=!1,this.setShouldMount=null}mount(){return this.mounted||(this.mounted=Yhe(),this.shouldMount=!0,this.setShouldMount(this.shouldMount)),this.mounted}mountEffect=()=>{this.shouldMount&&!this.didMount&&this.ref.current!==null&&(this.didMount=!0,this.mounted.resolve())};start(...t){this.mount().then(()=>this.ref.current?.start(...t))}stop(...t){this.mount().then(()=>this.ref.current?.stop(...t))}pulsate(...t){this.mount().then(()=>this.ref.current?.pulsate(...t))}}function Ghe(){return bb.use()}function Yhe(){let e,t;const n=new Promise((r,o)=>{e=r,t=o});return n.resolve=e,n.reject=t,n}function FE(e,t){return FE=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},FE(e,t)}function uw(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,FE(e,t)}function Khe(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Qhe(e,t){e.classList?e.classList.add(t):Khe(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function mP(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Xhe(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=mP(e.className,t):e.setAttribute("class",mP(e.className&&e.className.baseVal||"",t))}const gP={disabled:!1},vb=tt.createContext(null);var v6=function(e){return e.scrollTop},Hp="unmounted",mc="exited",gc="entering",od="entered",BE="exiting",mi=(function(e){uw(t,e);function t(r,o){var a;a=e.call(this,r,o)||this;var i=o,l=i&&!i.isMounting?r.enter:r.appear,u;return a.appearStatus=null,r.in?l?(u=mc,a.appearStatus=gc):u=od:r.unmountOnExit||r.mountOnEnter?u=Hp:u=mc,a.state={status:u},a.nextCallback=null,a}t.getDerivedStateFromProps=function(r,o){var a=r.in;return a&&o.status===Hp?{status:mc}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(r){var o=null;if(r!==this.props){var a=this.state.status;this.props.in?a!==gc&&a!==od&&(o=gc):(a===gc||a===od)&&(o=BE)}this.updateStatus(!1,o)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var r=this.props.timeout,o,a,i;return o=a=i=r,r!=null&&typeof r!="number"&&(o=r.exit,a=r.enter,i=r.appear!==void 0?r.appear:a),{exit:o,enter:a,appear:i}},n.updateStatus=function(r,o){if(r===void 0&&(r=!1),o!==null)if(this.cancelNextCallback(),o===gc){if(this.props.unmountOnExit||this.props.mountOnEnter){var a=this.props.nodeRef?this.props.nodeRef.current:El.findDOMNode(this);a&&v6(a)}this.performEnter(r)}else this.performExit();else this.props.unmountOnExit&&this.state.status===mc&&this.setState({status:Hp})},n.performEnter=function(r){var o=this,a=this.props.enter,i=this.context?this.context.isMounting:r,l=this.props.nodeRef?[i]:[El.findDOMNode(this),i],u=l[0],d=l[1],f=this.getTimeouts(),h=i?f.appear:f.enter;if(!r&&!a||gP.disabled){this.safeSetState({status:od},function(){o.props.onEntered(u)});return}this.props.onEnter(u,d),this.safeSetState({status:gc},function(){o.props.onEntering(u,d),o.onTransitionEnd(h,function(){o.safeSetState({status:od},function(){o.props.onEntered(u,d)})})})},n.performExit=function(){var r=this,o=this.props.exit,a=this.getTimeouts(),i=this.props.nodeRef?void 0:El.findDOMNode(this);if(!o||gP.disabled){this.safeSetState({status:mc},function(){r.props.onExited(i)});return}this.props.onExit(i),this.safeSetState({status:BE},function(){r.props.onExiting(i),r.onTransitionEnd(a.exit,function(){r.safeSetState({status:mc},function(){r.props.onExited(i)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(r,o){o=this.setNextCallback(o),this.setState(r,o)},n.setNextCallback=function(r){var o=this,a=!0;return this.nextCallback=function(i){a&&(a=!1,o.nextCallback=null,r(i))},this.nextCallback.cancel=function(){a=!1},this.nextCallback},n.onTransitionEnd=function(r,o){this.setNextCallback(o);var a=this.props.nodeRef?this.props.nodeRef.current:El.findDOMNode(this),i=r==null&&!this.props.addEndListener;if(!a||i){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var l=this.props.nodeRef?[this.nextCallback]:[a,this.nextCallback],u=l[0],d=l[1];this.props.addEndListener(u,d)}r!=null&&setTimeout(this.nextCallback,r)},n.render=function(){var r=this.state.status;if(r===Hp)return null;var o=this.props,a=o.children;o.in,o.mountOnEnter,o.unmountOnExit,o.appear,o.enter,o.exit,o.timeout,o.addEndListener,o.onEnter,o.onEntering,o.onEntered,o.onExit,o.onExiting,o.onExited,o.nodeRef;var i=Vt(o,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return tt.createElement(vb.Provider,{value:null},typeof a=="function"?a(r,i):tt.cloneElement(tt.Children.only(a),i))},t})(tt.Component);mi.contextType=vb;mi.propTypes={};function Ju(){}mi.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Ju,onEntering:Ju,onEntered:Ju,onExit:Ju,onExiting:Ju,onExited:Ju};mi.UNMOUNTED=Hp;mi.EXITED=mc;mi.ENTERING=gc;mi.ENTERED=od;mi.EXITING=BE;var Zhe=function(e,t){return e&&t&&t.split(" ").forEach(function(n){return Qhe(e,n)})},fS=function(e,t){return e&&t&&t.split(" ").forEach(function(n){return Xhe(e,n)})},dw=(function(e){uw(t,e);function t(){for(var r,o=arguments.length,a=new Array(o),i=0;i<o;i++)a[i]=arguments[i];return r=e.call.apply(e,[this].concat(a))||this,r.appliedClasses={appear:{},enter:{},exit:{}},r.onEnter=function(l,u){var d=r.resolveArguments(l,u),f=d[0],h=d[1];r.removeClasses(f,"exit"),r.addClass(f,h?"appear":"enter","base"),r.props.onEnter&&r.props.onEnter(l,u)},r.onEntering=function(l,u){var d=r.resolveArguments(l,u),f=d[0],h=d[1],y=h?"appear":"enter";r.addClass(f,y,"active"),r.props.onEntering&&r.props.onEntering(l,u)},r.onEntered=function(l,u){var d=r.resolveArguments(l,u),f=d[0],h=d[1],y=h?"appear":"enter";r.removeClasses(f,y),r.addClass(f,y,"done"),r.props.onEntered&&r.props.onEntered(l,u)},r.onExit=function(l){var u=r.resolveArguments(l),d=u[0];r.removeClasses(d,"appear"),r.removeClasses(d,"enter"),r.addClass(d,"exit","base"),r.props.onExit&&r.props.onExit(l)},r.onExiting=function(l){var u=r.resolveArguments(l),d=u[0];r.addClass(d,"exit","active"),r.props.onExiting&&r.props.onExiting(l)},r.onExited=function(l){var u=r.resolveArguments(l),d=u[0];r.removeClasses(d,"exit"),r.addClass(d,"exit","done"),r.props.onExited&&r.props.onExited(l)},r.resolveArguments=function(l,u){return r.props.nodeRef?[r.props.nodeRef.current,l]:[l,u]},r.getClassNames=function(l){var u=r.props.classNames,d=typeof u=="string",f=d&&u?u+"-":"",h=d?""+f+l:u[l],y=d?h+"-active":u[l+"Active"],b=d?h+"-done":u[l+"Done"];return{baseClassName:h,activeClassName:y,doneClassName:b}},r}var n=t.prototype;return n.addClass=function(r,o,a){var i=this.getClassNames(o)[a+"ClassName"],l=this.getClassNames("enter"),u=l.doneClassName;o==="appear"&&a==="done"&&u&&(i+=" "+u),a==="active"&&r&&v6(r),i&&(this.appliedClasses[o][a]=i,Zhe(r,i))},n.removeClasses=function(r,o){var a=this.appliedClasses[o],i=a.base,l=a.active,u=a.done;this.appliedClasses[o]={},i&&fS(r,i),l&&fS(r,l),u&&fS(r,u)},n.render=function(){var r=this.props;r.classNames;var o=Vt(r,["classNames"]);return tt.createElement(mi,ue({},o,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},t})(tt.Component);dw.defaultProps={classNames:""};dw.propTypes={};function Jhe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fw(e,t){var n=function(o){return t&&C.isValidElement(o)?t(o):o},r=Object.create(null);return e&&C.Children.map(e,function(o){return o}).forEach(function(o){r[o.key]=n(o)}),r}function eme(e,t){e=e||{},t=t||{};function n(f){return f in t?t[f]:e[f]}var r=Object.create(null),o=[];for(var a in e)a in t?o.length&&(r[a]=o,o=[]):o.push(a);var i,l={};for(var u in t){if(r[u])for(i=0;i<r[u].length;i++){var d=r[u][i];l[r[u][i]]=n(d)}l[u]=n(u)}for(i=0;i<o.length;i++)l[o[i]]=n(o[i]);return l}function wc(e,t,n){return n[t]!=null?n[t]:e.props[t]}function tme(e,t){return fw(e.children,function(n){return C.cloneElement(n,{onExited:t.bind(null,n),in:!0,appear:wc(n,"appear",e),enter:wc(n,"enter",e),exit:wc(n,"exit",e)})})}function nme(e,t,n){var r=fw(e.children),o=eme(t,r);return Object.keys(o).forEach(function(a){var i=o[a];if(C.isValidElement(i)){var l=a in t,u=a in r,d=t[a],f=C.isValidElement(d)&&!d.props.in;u&&(!l||f)?o[a]=C.cloneElement(i,{onExited:n.bind(null,i),in:!0,exit:wc(i,"exit",e),enter:wc(i,"enter",e)}):!u&&l&&!f?o[a]=C.cloneElement(i,{in:!1}):u&&l&&C.isValidElement(d)&&(o[a]=C.cloneElement(i,{onExited:n.bind(null,i),in:d.props.in,exit:wc(i,"exit",e),enter:wc(i,"enter",e)}))}}),o}var rme=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},ome={component:"div",childFactory:function(e){return e}},dm=(function(e){uw(t,e);function t(r,o){var a;a=e.call(this,r,o)||this;var i=a.handleExited.bind(Jhe(a));return a.state={contextValue:{isMounting:!0},handleExited:i,firstRender:!0},a}var n=t.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},t.getDerivedStateFromProps=function(r,o){var a=o.children,i=o.handleExited,l=o.firstRender;return{children:l?tme(r,i):nme(r,a,i),firstRender:!1}},n.handleExited=function(r,o){var a=fw(this.props.children);r.key in a||(r.props.onExited&&r.props.onExited(o),this.mounted&&this.setState(function(i){var l=ue({},i.children);return delete l[r.key],{children:l}}))},n.render=function(){var r=this.props,o=r.component,a=r.childFactory,i=Vt(r,["component","childFactory"]),l=this.state.contextValue,u=rme(this.state.children).map(a);return delete i.appear,delete i.enter,delete i.exit,o===null?tt.createElement(vb.Provider,{value:l},u):tt.createElement(vb.Provider,{value:l},tt.createElement(o,i,u))},t})(tt.Component);dm.propTypes={};dm.defaultProps=ome;const ame=[];function ime(e){C.useEffect(e,ame)}class pw{static create(){return new pw}currentId=null;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=null,n()},t)}clear=()=>{this.currentId!==null&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function hw(){const e=b6(pw.create).current;return ime(e.disposeEffect),e}function sme(e){const{className:t,classes:n,pulsate:r=!1,rippleX:o,rippleY:a,rippleSize:i,in:l,onExited:u,timeout:d}=e,[f,h]=C.useState(!1),y=pt(t,n.ripple,n.rippleVisible,r&&n.ripplePulsate),b={width:i,height:i,top:-(i/2)+a,left:-(i/2)+o},v=pt(n.child,f&&n.childLeaving,r&&n.childPulsate);return!l&&!f&&h(!0),C.useEffect(()=>{if(!l&&u!=null){const x=setTimeout(u,d);return()=>{clearTimeout(x)}}},[u,l,d]),g.jsx("span",{className:y,style:b,children:g.jsx("span",{className:v})})}const Fa=Ct("MuiTouchRipple",["root","ripple","rippleVisible","ripplePulsate","child","childLeaving","childPulsate"]),jE=550,lme=80,cme=Ki`
|
|
327
327
|
0% {
|
|
328
328
|
transform: scale(0);
|
|
329
329
|
opacity: 0.1;
|
|
@@ -448,4 +448,4 @@ import {${t.sourceName}}" from '${t.modelPath}'"
|
|
|
448
448
|
}
|
|
449
449
|
`}function XCe(e,t){const n=new Map;for(const d of t){const f=Pl(d);n.set(f,[])}const r=JSON.parse(e),o=r.schema.fields,a=new Map;o.forEach((d,f)=>{a.set(d.name,f)});const i=d=>{if(!d)return null;switch(d.kind){case"string_cell":return d.string_value??null;case"number_cell":return d.number_value??null;case"boolean_cell":return d.boolean_value??null;case"null_cell":return null;default:return console.log("Unknown cell kind: "+d.kind),null}},l=(r.data?.array_value||[]).map(d=>{const f={};return d.kind==="record_cell"&&d.record_value&&d.record_value.forEach((h,y)=>{const b=o[y]?.name;if(b){const v=i(h);b==="fieldName"&&typeof v=="string"?f.fieldName=v:b==="fieldPath"&&typeof v=="string"?f.fieldPath=v:b==="fieldType"&&typeof v=="string"?f.fieldType=v:b==="fieldValue"&&typeof v=="string"?f.fieldValue=v:b==="weight"&&typeof v=="number"&&(f.weight=v)}}),f}),u=l.length===0||l.every(d=>!d.fieldName);for(const d of t){if(d.filterType==="NONE"||d.filterType==="Retrieval")continue;const f=l.filter(y=>{const b=y.fieldName||"",v=y.fieldPath||"";if(b===d.dimensionName||v===d.dimensionName||b.toLowerCase()===d.dimensionName.toLowerCase()||v.toLowerCase()===d.dimensionName.toLowerCase())return!0;const x=v.split(".").pop()||"";return x===d.dimensionName||x.toLowerCase()===d.dimensionName.toLowerCase()});if(f.length===0)continue;const h=Pl(d);if(d.filterType==="Star"){const y=f.filter(b=>b.fieldType==="string").map(b=>({value:b.fieldValue??"",count:b.weight})).sort((b,v)=>(v.count??0)-(b.count??0));n.set(h,y)}else if(d.filterType==="MinMax"){console.log("MinMax dimensionEntries: "+JSON.stringify(f,null,2)),console.log("All MinMax dimension entries fieldTypes:",f.map(b=>b.fieldType));const y=f.find(b=>b.fieldType==="number");if(console.log("numericEntry: "+JSON.stringify(y,null,2)),y?.fieldValue){const b=y.fieldValue,v=b.split(" to ");if(console.log("rangeParts: "+v),v.length===2){const x=[{value:parseFloat(v[0])},{value:parseFloat(v[1])}];n.set(h,x)}else console.warn(`Could not parse numeric range for ${d.dimensionName}: ${b}`)}else console.warn(`No numeric entry found for ${d.dimensionName}. Available entries:`,f)}else if(d.filterType==="DateMinMax"){const y=f.find(b=>b.fieldType==="date"||b.fieldType==="timestamp"||b.fieldType==="string");if(console.log("dateEntry: "+JSON.stringify(y,null,2)),console.log("All date dimension entries fieldTypes:",f.map(b=>b.fieldType)),y?.fieldValue){const b=y.fieldValue,v=b.split(" to ");if(console.log("date rangeParts: "+v),v.length===2){const x=[{value:new Date(v[0].trim())},{value:new Date(v[1].trim())}];n.set(h,x)}else console.warn(`Could not parse date range for ${d.dimensionName}: ${b}`)}else console.warn(`No date entry found for ${d.dimensionName}. Available entries:`,f)}}return{values:n,noRowsMatchedFilter:u}}function ZCe(e){const{environment:t,package:n,dimensionSpecs:r,versionId:o,enabled:a=!0,indexLimit:i=1e4,activeFilters:l=[]}=e,u=C.useMemo(()=>KCe(r),[r]),d=C.useMemo(()=>{const v=[];for(const[x,E]of u){const[S,A]=x.split("|"),T=QCe(S,E,i,l);T?v.push({key:x,source:S,model:A,query:T,specs:E}):console.log("No query for source: ",S,"model: ",A)}return v},[u,i,l]),f=C.useMemo(()=>a&&d.length>0&&r.some(v=>v.filterType==="Star"||v.filterType==="MinMax"||v.filterType==="DateMinMax"),[a,d,r]),{apiClients:h}=cr(),y=bo({queryKey:["dimensionalFilter",t,n,r,o,l],queryFn:async()=>{if(!f){const S=new Map;for(const A of r){const T=Pl(A);S.set(T,[])}return{values:S,noRowsMatchedFilter:!1}}const v=await Promise.all(d.map(async S=>{const A=await h.models.executeQueryModel(t,n,S.model,{query:S.query,versionId:o,bypassFilters:!0});return{config:S,result:XCe(A.data.result,S.specs)}})),x=new Map;let E=!1;for(const{result:S}of v){for(const[A,T]of S.values)x.set(A,T);S.noRowsMatchedFilter&&(E=!0)}return{values:x,noRowsMatchedFilter:E}},enabled:f,staleTime:300*1e3,placeholderData:v=>v}),b=y.data?.values;return{data:C.useMemo(()=>{const v=new Map;for(const x of r){const E=Pl(x);x.values?v.set(E,x.values.map(S=>({value:S}))):v.set(E,[])}if(b)for(const[x,E]of b)E.length>0&&v.set(x,E);return v},[r,b]),noRowsMatchedFilter:y.data?.noRowsMatchedFilter??!1,isLoading:f?y.isPending:!1,isError:f?y.isError:!1,error:f?y.error:null,refetch:y.refetch}}function $F(e){return e.replace(/'/g,"\\'").replace(/\\/g,"\\\\")}function Di(e,t=!1){return e==null?"null":t?e instanceof Date?`@${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`:`@${e}`:typeof e=="string"?`'${$F(e)}'`:typeof e=="number"?String(e):typeof e=="boolean"?e?"true":"false":String(e)}function JCe(e){const{dimensionName:t,matchType:n,value:r,value2:o}=e,a=`\`${t}\``,i=r instanceof Date;switch(n){case"Equals":case"Semantic Search":return Array.isArray(r)&&r.length>0?`(${r.map(l=>`${a} = ${Di(l,i)}`).join(" or ")})`:Array.isArray(r)?"":`${a} = ${Di(r,i)}`;case"Contains":return typeof r=="string"?`${a} ~ f'%${$F(r)}%'`:Array.isArray(r)?"":`${a} = ${Di(r)}`;case"After":return Array.isArray(r)?"":`${a} > ${Di(r,i)}`;case"Before":return Array.isArray(r)?"":`${a} < ${Di(r,i)}`;case"Greater Than":return Array.isArray(r)?"":`${a} > ${Di(r)}`;case"Less Than":return Array.isArray(r)?"":`${a} < ${Di(r)}`;case"Between":return Array.isArray(r)?"":o!==void 0?`${a} >= ${Di(r,i)} and ${a} <= ${Di(o,i)}`:`${a} >= ${Di(r,i)}`;default:return""}}function eTe(e){const{dimensionSpecs:t}=e,[n,r]=C.useState(()=>{const d=new Map;return t.forEach(f=>{const h=Pl(f);d.set(h,{spec:f,selection:null})}),d});C.useEffect(()=>{r(d=>{const f=new Map;return t.forEach(h=>{const y=Pl(h),b=d.get(y);f.set(y,{spec:h,selection:b?.selection??null})}),f})},[t]);const o=C.useCallback((d,f)=>{r(h=>{const y=new Map(h),b=y.get(d);return b&&y.set(d,{...b,selection:f}),y})},[]),a=C.useCallback(d=>{o(d,null)},[o]),i=C.useCallback(()=>{r(d=>{const f=new Map(d);return f.forEach((h,y)=>{f.set(y,{...h,selection:null})}),f})},[]),l=C.useCallback(()=>{const d=[];return n.forEach(f=>{f.selection&&d.push(f.selection)}),d},[n]),u=C.useCallback(()=>{const d=l();if(d.length===0)return"";const f=d.map(h=>JCe(h)).filter(h=>h.length>0);return f.length===0?"":`where ${f.join(" and ")}`},[l]);return{filterStates:n,updateFilter:o,clearFilter:a,clearAllFilters:i,getActiveFilters:l,generateWhereClause:u}}const tTe=fr(g.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}));function nTe(e){const{environmentName:t,packageName:n}=Kr(e.resourceUri);if(!t||!n)throw new Error("Environment and Package name must be provided for query embedding.");return JSON.stringify({...e})}function rTe({cell:e,hideCodeCellIcon:t,hideEmbeddingIcon:n,resourceUri:r,index:o,maxResultSize:a,isExecuting:i}){const[l,u]=tt.useState(!1),[d,f]=tt.useState(!1),[h,y]=tt.useState(!1),[b,v]=tt.useState(),[x,E]=tt.useState(),[S,A]=tt.useState(!1),[T,M]=C.useState(""),D=/import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/,R=/import\s*(?:\{[^}]*\}\s*from\s*)?['"`]([^'"`]+)['"`]/,F=L=>L.split(`
|
|
450
450
|
`).filter(I=>!I.trimStart().startsWith("##")).join(`
|
|
451
|
-
`),B=!!e.text&&(D.test(e.text)||R.test(e.text)),z=()=>{if(!e.newSources||e.newSources.length===0)return 0;let L=[],I="";if(e.text){const $=e.text.match(D);$&&(L=$[1].split(",").map(G=>G.trim()));const _=e.text.match(R);_&&(I=_[1].trim())}for(let $=0;$<e.newSources.length;$++)try{const _=JSON.parse(e.newSources[$]);if(L.length>0&&L.includes(_.name)||I&&I===_.path)return $}catch{continue}return 0},j=e.newSources&&e.newSources.length>0?{sourceInfos:e.newSources,resource:r}:void 0,U=nTe({query:e.text,resourceUri:r});C.useEffect(()=>{e.type==="code"&&yb(F(e.text),"malloy").then(L=>{v(L)})},[e]),C.useEffect(()=>{yb(U,"typescript").then(L=>{E(L)})},[U]);const w=()=>{const L=window.location.href;navigator.clipboard.writeText(L).then(()=>M("URL copied to clipboard!")).catch(()=>M("Failed to copy URL"))};return e.type==="markdown"&&g.jsx(hE,{children:g.jsxs(xt,{sx:{"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:"600",color:"#1a1a1a",marginBottom:"8px",marginTop:"16px"},"& h1":{fontSize:"28px"},"& h2":{fontSize:"24px"},"& h3":{fontSize:"20px"},"& p":{color:"#333333",lineHeight:"1.7",marginBottom:"8px",fontSize:"16px"},"& ul, & ol":{color:"#333333",lineHeight:"1.7",marginBottom:"8px",fontSize:"16px"},"& li":{marginBottom:"4px"}},children:[o===0?g.jsxs(lo,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[g.jsx(nb,{children:e.text}),g.jsx(jo,{title:"Click to copy link",children:g.jsx(MT,{sx:{fontSize:"24px",color:"text.secondary",cursor:"pointer",marginTop:"26px"},onClick:w})})]}):g.jsx(nb,{children:e.text}),g.jsx(_s,{open:T!=="",autoHideDuration:6e3,onClose:()=>M(""),message:T})]})})||e.type==="code"&&g.jsxs(hE,{children:[(!t||!n&&e.result||e.newSources&&e.newSources.length>0)&&g.jsx(lo,{sx:{flexDirection:"column",gap:"8px",marginBottom:"2px"},children:e.newSources&&e.newSources.length>0&&g.jsx(ky,{sx:{position:"relative",padding:"0"},children:g.jsxs(xt,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"24px",paddingRight:"8px"},children:[b&&g.jsx("span",{dangerouslySetInnerHTML:{__html:b},style:{fontFamily:"monospace",fontSize:"14px",flex:1,marginRight:"8px"}}),B&&g.jsx(Cr,{sx:{backgroundColor:"rgba(255, 255, 255, 0.9)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},width:"32px",height:"32px",flexShrink:0},onClick:()=>A(!0),children:g.jsx(Fh,{sx:{fontSize:"18px",color:"text.secondary"}})})]})})}),g.jsx(BF,{open:S,onClose:()=>A(!1),title:"Data Sources",hasValidImport:B,resourceUri:r,data:j,initialSelectedSourceIndex:z()}),g.jsxs(ks,{open:l,onClose:()=>u(!1),maxWidth:"lg",fullWidth:!0,children:[g.jsxs(Ds,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:["Malloy Code",g.jsx(Cr,{onClick:()=>u(!1),sx:{color:"text.secondary"},children:g.jsx(Ns,{})})]}),g.jsx(As,{children:g.jsx(xt,{sx:{border:"1px solid #e0e0e0",borderRadius:"8px",padding:"16px",fontFamily:"monospace",fontSize:"14px",lineHeight:"1.5",overflow:"auto",maxHeight:"70vh",backgroundColor:"#ffffff"},children:g.jsx("pre",{className:"code-display",style:{margin:0},dangerouslySetInnerHTML:{__html:b}})})})]}),g.jsxs(ks,{open:d,onClose:()=>f(!1),maxWidth:"lg",fullWidth:!0,children:[g.jsxs(Ds,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:["Embeddable Code",g.jsx(Cr,{onClick:()=>f(!1),sx:{color:"text.secondary"},children:g.jsx(Ns,{})})]}),g.jsx(As,{children:g.jsxs(lo,{sx:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start"},children:[g.jsx(ft,{component:"div",sx:{fontSize:"12px",fontFamily:"monospace","& .line":{textWrap:"wrap"},flex:1},dangerouslySetInnerHTML:{__html:x}}),g.jsx(jo,{title:"Copy Embeddable Code",children:g.jsx(Cr,{sx:{width:"24px",height:"24px",marginLeft:"8px",color:"text.secondary"},onClick:()=>{navigator.clipboard.writeText(U)},children:g.jsx(tTe,{})})})]})})]}),g.jsx(_F,{open:h,onClose:()=>y(!1),result:e.result||"",title:"Results"}),i&&!e.result&&!B&&!(e.newSources&&e.newSources.length>0)&&g.jsx(ky,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:g.jsx(Kb,{size:32})}),e.result&&g.jsxs(ky,{sx:{position:"relative"},children:[g.jsx(xt,{sx:{paddingTop:"24px"},children:g.jsx(_v,{result:e.result,maxHeight:700,maxResultSize:a})}),g.jsxs(lo,{sx:{position:"absolute",top:"8px",right:"8px",flexDirection:"row",gap:"8px",alignItems:"center",zIndex:2},children:[!t&&g.jsx(Cr,{sx:{backgroundColor:"rgba(255, 255, 255, 0.9)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},width:"32px",height:"32px"},onClick:L=>{L.stopPropagation(),u(!0)},children:g.jsx(W3,{sx:{fontSize:"18px",color:"text.secondary"}})}),g.jsx(Cr,{sx:{backgroundColor:"rgba(255, 255, 255, 0.9)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},width:"32px",height:"32px"},onClick:()=>y(!0),children:g.jsx(Fh,{sx:{fontSize:"18px",color:"text.secondary"}})})]})]})]})}const oTe=4;function aTe({resourceUri:e,maxResultSize:t=0,retrievalFn:n}){const{apiClients:r}=cr(),{environmentName:o,packageName:a,versionId:i,modelPath:l}=Kr(e),{data:u,isSuccess:d,isError:f,error:h}=bo({queryKey:[e],queryFn:async()=>(await r.notebooks.getNotebook(o,a,l,i)).data}),[y,b]=C.useState([]),[v,x]=C.useState(!1),[E,S]=C.useState(null),A=C.useMemo(()=>u?ECe(u.annotations):null,[u]),T=C.useMemo(()=>u?.notebookCells?wCe(u.notebookCells):null,[u]),M=C.useMemo(()=>T?.sourceInfoMap??new Map,[T]),D=T?.modelPath??null,R=C.useMemo(()=>{const V=new Map;if(!u?.sources)return V;for(const Y of u.sources)if(Y.name&&Y.filters&&Y.filters.length>0){const P=Y.filters.filter(q=>!q.implicit);P.length>0&&V.set(Y.name,P)}return V},[u]),F=R.size>0,B=C.useMemo(()=>{if(F&&D){const V=[];for(const[Y,P]of R)for(const q of P??[]){if(!q.dimension||!q.type)continue;let X;const H=q.dimensionType;H==="boolean"?X="Boolean":H==="date"||H==="timestamp"||H==="timestamptz"?X="DateMinMax":H==="number"?X=q.type==="equal"||q.type==="in"?"Star":"MinMax":X={equal:"Star",in:"Star",like:"Star",greater_than:"MinMax",less_than:"MinMax"}[q.type]??"Star";const re={equal:"Equals",in:"Equals",like:"Contains",greater_than:X==="DateMinMax"?"After":"Greater Than",less_than:X==="DateMinMax"?"Before":"Less Than"}[q.type],Z=q.name!==q.dimension?q.name:void 0;V.push({source:Y,model:D,dimensionName:q.dimension,filterType:X,label:Z,filterName:q.name??q.dimension,defaultMatchType:re,required:q.required??!1})}return V}return!A||M.size===0||!D?[]:kCe(M,A.filters,D)},[F,R,A,M,D]),{filterStates:z,updateFilter:j,getActiveFilters:U}=eTe({dimensionSpecs:B}),w=C.useMemo(()=>U(),[z,U]);C.useMemo(()=>{const V=new Map;for(const Y of B){const P=Pl(Y);V.set(P,Y.source)}return V},[B]);const{data:L}=ZCe({environment:o,package:a,dimensionSpecs:B,versionId:i,enabled:B.length>0}),I=C.useCallback(V=>{if(V.length===0)return;const Y=q=>q instanceof Date?q.toISOString().slice(0,10):String(q),P={};for(const q of V){const X=q.filterName??q.dimensionName,H=q.value;Array.isArray(H)?P[X]=H.map(Y):H!=null&&(P[X]=Y(H))}return Object.keys(P).length>0?JSON.stringify(P):void 0},[]),$=C.useCallback(async(V=[])=>{if(!d||!u?.notebookCells)return;b(P=>P.length===0?u.notebookCells.map(q=>({...q})):P.map(q=>({...q,result:void 0}))),x(!0),S(null);const Y=F?I(V):void 0;try{const P=[];for(let X=0;X<u.notebookCells.length;X++){const H=u.notebookCells[X];if(H.type==="markdown")continue;const re=X,Z=async()=>{try{const K=(await r.notebooks.executeNotebookCell(o,a,l,re,i,Y)).data,ne=K.result,ee=H.newSources||K.newSources;b(fe=>{const de=[...fe];return de[re]||(de[re]={...H}),de[re]={...de[re],result:ne,newSources:ee},de})}catch(K){console.error(`Error executing cell ${re}:`,K)}};P.push(Z)}const q=[];for(const X of P){const H=X().then(()=>{q.splice(q.indexOf(H),1)});q.push(H),q.length>=oTe&&await Promise.race(q)}await Promise.all(q)}catch(P){console.error("Error executing notebook cells:",P),S(P)}finally{x(!1)}},[d,u,F,I,o,a,l,i,r.notebooks]);C.useEffect(()=>{!d||!u?.notebookCells||$([])},[d,u,$]);const _=C.useRef("");C.useEffect(()=>{const V=JSON.stringify(w.map(Y=>({dim:Y.dimensionName,type:Y.matchType,val:Y.value,val2:Y.value2})));if(V!==_.current){if(_.current===""&&w.length===0){_.current=V;return}_.current=V,v||$(w)}},[w,v,$]);const G=C.useCallback(V=>Y=>{j(V,Y)},[j]);return B.some(V=>V.filterType==="Retrieval"),g.jsx(nne,{children:g.jsx(rne,{children:g.jsxs(lo,{spacing:3,component:"section",children:[B.length>0&&L&&g.jsxs(Ts,{elevation:0,sx:{p:3,backgroundColor:"transparent",border:"none",boxShadow:"none"},children:[g.jsx(ft,{variant:"subtitle2",sx:{fontWeight:600,mb:2,color:"#333"},children:"Filters"}),g.jsx(xt,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(250px, 1fr))",gap:3},children:B.map(V=>{const Y=Pl(V),P=L.get(Y)||[],q=z.get(Y);return V.filterType==="Retrieval"&&!n?null:g.jsx(xt,{children:g.jsx(SCe,{spec:V,values:P,selection:q?.selection,onChange:G(Y),retrievalFn:n})},Y)})})]}),!d&&!f&&g.jsx(ya,{text:"Fetching Notebook..."}),d&&(y.length>0?y:u?.notebookCells||[]).map((V,Y)=>g.jsx(rTe,{cell:V,index:Y,resourceUri:e,maxResultSize:t,isExecuting:v},Y)),f&&h.status===404&&g.jsxs(ft,{variant:"body2",sx:{color:"text.secondary"},children:[g.jsx("code",{children:`${o} > ${a} > ${l}`})," ","not found."]}),f&&h.status!==404&&g.jsx(ba,{error:h,context:`${o} > ${a} > ${l}`}),E&&g.jsx(ba,{error:{message:E.message,status:500,name:"ExecutionError"},context:"Notebook Execution"})]})})})}const iTe=fr(g.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}));function xS({type:e,size:t=18,sx:n,...r}){return g.jsxs(ib,{...r,viewBox:"0 0 24 24",sx:{width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...n},children:[e==="report"&&g.jsx(sTe,{}),e==="model"&&g.jsx(lTe,{}),e==="data"&&g.jsx(cTe,{})]})}function sTe(){return g.jsxs(g.Fragment,{children:[g.jsx("path",{d:"M14 3 H6 a2 2 0 0 0 -2 2 v14 a2 2 0 0 0 2 2 h12 a2 2 0 0 0 2 -2 V9 z"}),g.jsx("path",{d:"M14 3 v4 a2 2 0 0 0 2 2 h4"}),g.jsx("path",{d:"M8 17 v-3"}),g.jsx("path",{d:"M12 17 v-6"}),g.jsx("path",{d:"M16 17 v-4"})]})}function lTe(){return g.jsxs(g.Fragment,{children:[g.jsx("path",{d:"M12 3 L4 7 v10 l8 4 l8 -4 V7 z"}),g.jsx("path",{d:"M4 7 l8 4 l8 -4"}),g.jsx("path",{d:"M12 11 v10"})]})}function cTe(){return g.jsxs(g.Fragment,{children:[g.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),g.jsx("path",{d:"M3.5 9.5 H20.5"}),g.jsx("path",{d:"M9.5 3.5 V20.5"})]})}const UF=fr(g.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"})),Ss={postgres:[{label:"Host",name:"host",type:"text",required:!1},{label:"Port",name:"port",type:"number",required:!1},{label:"Database Name",name:"databaseName",type:"text",required:!1},{label:"User Name",name:"userName",type:"text",required:!1},{label:"Password",name:"password",type:"password",required:!1},{label:"Connection String",name:"connectionString",type:"text",required:!1}],bigquery:[{label:"Project ID",name:"defaultProjectId",type:"text",required:!1},{label:"Billing Project ID",name:"billingProjectId",type:"text",required:!1},{label:"Location",name:"location",type:"text",required:!1},{label:"Service Account Key JSON",name:"serviceAccountKeyJson",type:"text",required:!0},{label:"Maximum Bytes Billed",name:"maximumBytesBilled",type:"text",required:!1},{label:"Query Timeout Milliseconds",name:"queryTimeoutMilliseconds",type:"text",required:!1}],snowflake:[{label:"Account",name:"account",type:"text",required:!0},{label:"Username",name:"username",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Role",name:"role",type:"text",required:!1},{label:"Warehouse",name:"warehouse",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"Response Timeout Milliseconds",name:"responseTimeoutMilliseconds",type:"text",required:!1},{label:"Private Key",name:"privateKey",type:"password",required:!1},{label:"Private Key Passphrase",name:"privateKeyPass",type:"password",required:!1}],trino:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Catalog",name:"catalog",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Peaka Key",name:"peakaKey",type:"password",required:!1}],databricks:[{label:"Host",name:"host",type:"text",required:!0},{label:"HTTP Path",name:"path",type:"text",required:!0},{label:"Access Token",name:"token",type:"password",required:!1},{label:"OAuth Client ID",name:"oauthClientId",type:"text",required:!1},{label:"OAuth Client Secret",name:"oauthClientSecret",type:"password",required:!1},{label:"Default Catalog",name:"defaultCatalog",type:"text",required:!1},{label:"Default Schema",name:"defaultSchema",type:"text",required:!1}],mysql:[{label:"Host",name:"host",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Database",name:"database",type:"text",required:!0}],duckdb:[],motherduck:[{label:"Access Token",name:"accessToken",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1}],ducklake:[]},Ly={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",trino:"trinoConnection",databricks:"databricksConnection",mysql:"mysqlConnection",duckdb:"duckdbConnection",motherduck:"motherduckConnection",ducklake:"ducklakeConnection"},oC={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",gcs:"gcsConnection",s3:"s3Connection",azure:"azureConnection"},Bh=[{label:"Access Key ID",name:"accessKeyId",type:"text",required:!0},{label:"Secret Access Key",name:"secretAccessKey",type:"password",required:!0},{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}],jh=[{label:"Key ID",name:"keyId",type:"text",required:!0},{label:"Secret",name:"secret",type:"password",required:!0}],uTe=[{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 Db(e){return e==="postgres"||e==="bigquery"||e==="snowflake"?Ss[e]||[]:e==="s3"?Bh:e==="gcs"?jh:e==="azure"?uTe:[]}function dTe({onSubmit:e,isSubmitting:t}){const[n,r]=C.useState(!1),[o,a]=C.useState("postgres"),[i,l]=C.useState([]),[u,d]=C.useState("postgres"),[f,h]=C.useState("s3"),y=()=>{r(!0)},b=()=>{r(!1),l([]),a("postgres"),d("postgres"),h("s3")},v=async A=>{A.preventDefault();const T=new FormData(A.currentTarget),M=T.get("name")?.toString(),D=T.get("type")?.toString(),R=Ss[D];if(!M)throw new Error("Name is required");if(!D)throw new Error("Type is required");let F;if(D==="ducklake"){const B={};if(u==="postgres"){const U=Ss.postgres,w={};if(U.forEach(L=>{const I=T.get(`ducklake_pg_${L.name}`)?.toString();I&&(w[L.name]=I)}),Object.keys(w).length===0)throw new Error("DuckLake requires catalog connection");B.postgresConnection=w}const z=T.get("ducklake_bucketUrl")?.toString();if(!z)throw new Error("DuckLake requires a bucket URL");const j={bucketUrl:z};if(f==="s3"){const U={};if(Bh.forEach(w=>{const L=T.get(`ducklake_s3_${w.name}`)?.toString();L&&(U[w.name]=L)}),!U.accessKeyId)throw new Error("S3 Access Key ID is required");if(!U.secretAccessKey)throw new Error("S3 Secret Access Key is required");Object.keys(U).length>0&&(j.s3Connection=U)}else if(f==="gcs"){const U={};if(jh.forEach(w=>{const L=T.get(`ducklake_gcs_${w.name}`)?.toString();L&&(U[w.name]=L)}),!U.keyId)throw new Error("GCS Key ID is required");if(!U.secret)throw new Error("GCS Secret is required");Object.keys(U).length>0&&(j.gcsConnection=U)}F={name:M,type:D,ducklakeConnection:{catalog:B,storage:j}}}else if(D==="duckdb"){if(i.length===0)throw new Error("DuckDB connection must have at least one attached database");const B=i.map((z,j)=>{const U=z.dbType,w=T.get(`attachedDb_${j}_name`)?.toString();if(!w)throw new Error(`Attached database at index ${j} must have a name`);const L={name:w,type:U},I=Db(U);if(I&&I.length>0){const $={};I.forEach(G=>{const V=T.get(`attachedDb_${j}_${G.name}`)?.toString();V&&($[G.name]=V)});const _=oC[U];_&&(L[_]=$)}return L});F={name:M,type:D,duckdbConnection:{attachedDatabases:B}}}else{const B={};if(R.forEach(z=>{const j=T.get(z.name)?.toString();j&&(B[z.name]=j)}),D==="postgres"){if(!B.connectionString?.trim()){const z=["host","port","databaseName","userName","password"];for(const j of z)if(!B[j])throw new Error(`${R.find(U=>U.name===j)?.label||j} is required`)}}else if(D==="bigquery"){if(!B.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(D==="snowflake"){if(!B.account)throw new Error("Account is required");if(!B.username)throw new Error("Username is required");if(!B.warehouse)throw new Error("Warehouse is required");if(!B.password&&!B.privateKey)throw new Error("Either password or private key is required")}else if(D==="trino"){if(!B.server)throw new Error("Server is required");if(!B.user)throw new Error("User is required");if(B.server.trim().startsWith("https://")&&!B.password&&!B.peakaKey)throw new Error("Password is required for HTTPS connections (or use Peaka Key)")}else if(D==="mysql"){const z=["host","port","database","user","password"];for(const j of z)if(!B[j])throw new Error(`${R.find(U=>U.name===j)?.label||j} is required`)}else if(D==="motherduck"){if(!B.accessToken)throw new Error("Access Token is required")}else if(D==="databricks"){if(!B.host)throw new Error("Host is required");if(!B.path)throw new Error("HTTP Path is required");const z=B.oauthClientId&&B.oauthClientSecret;if(!B.token&&!z)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}F={name:M,type:D,[Ly[D]]:B}}await e(F),b()},x=()=>{l([...i,{name:"",dbType:"postgres"}])},E=A=>{l(i.filter((T,M)=>M!==A))},S=(A,T)=>{const M=[...i];M[A]={...M[A],dbType:T},l(M)};return g.jsxs(tt.Fragment,{children:[g.jsx(Tr,{variant:"outlined",onClick:y,children:"Add Connection"}),g.jsxs(Bs,{open:n,onClose:b,children:[g.jsx($l,{children:"Create New Connection"}),g.jsxs(js,{children:[g.jsx(fm,{children:"Add a new connection to query your data database using Malloy."}),g.jsxs("form",{onSubmit:v,id:"connection-form",children:[g.jsx(mn,{autoFocus:!0,required:!0,margin:"dense",id:"name",name:"name",label:"Connection Name",type:"text",fullWidth:!0,variant:"standard"}),g.jsx(mn,{margin:"dense",id:"type",name:"type",label:"Connection Type",fullWidth:!0,variant:"standard",value:o,select:!0,onChange:A=>a(A.target.value),children:Object.values(d3).map(A=>g.jsx(mo,{value:A,children:A},A))}),o==="ducklake"?g.jsxs(dr,{sx:{mt:2},children:[g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsx(Jn,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),g.jsx(mn,{margin:"dense",id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,variant:"standard",value:u,select:!0,onChange:A=>d(A.target.value),children:g.jsx(mo,{value:"postgres",children:"PostgreSQL"})}),u==="postgres"&&g.jsx(g.Fragment,{children:Ss.postgres.map(A=>g.jsx(mn,{margin:"dense",id:`ducklake_pg_${A.name}`,name:`ducklake_pg_${A.name}`,label:A.label,type:A.type,fullWidth:!0,variant:"standard"},`pg_${A.name}`))})]}),g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsx(Jn,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),g.jsxs(mn,{margin:"dense",id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,variant:"standard",value:f,select:!0,onChange:A=>h(A.target.value),children:[g.jsx(mo,{value:"s3",children:"S3"}),g.jsx(mo,{value:"gcs",children:"GCS"})]}),g.jsx(mn,{margin:"dense",required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:f==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,variant:"standard"}),f==="s3"&&g.jsxs(g.Fragment,{children:[g.jsx(Jn,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Bh.map(A=>g.jsx(mn,{margin:"dense",id:`ducklake_s3_${A.name}`,name:`ducklake_s3_${A.name}`,label:A.label,type:A.type,fullWidth:!0,variant:"standard",required:A.required,placeholder:A.name==="region"?"us-east-1":void 0},`s3_${A.name}`))]}),f==="gcs"&&g.jsxs(g.Fragment,{children:[g.jsx(Jn,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),jh.map(A=>g.jsx(mn,{margin:"dense",id:`ducklake_gcs_${A.name}`,name:`ducklake_gcs_${A.name}`,label:A.label,type:A.type,fullWidth:!0,variant:"standard",required:A.required},`gcs_${A.name}`))]})]})]}):o==="duckdb"?g.jsxs(dr,{sx:{mt:2},children:[g.jsxs(dr,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[g.jsx(Jn,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),g.jsx(Tr,{startIcon:g.jsx(DT,{}),onClick:x,size:"small",variant:"outlined",children:"Add Database"})]}),i.length===0&&g.jsx(Jn,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),i.map((A,T)=>{const M=Db(A.dbType);return g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsxs(dr,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[g.jsxs(Jn,{variant:"subtitle2",children:["Database ",T+1]}),g.jsx(va,{onClick:()=>E(T),size:"small",color:"error",children:g.jsx(UF,{fontSize:"small"})})]}),g.jsx(mn,{margin:"dense",required:!0,id:`attachedDb_${T}_name`,name:`attachedDb_${T}_name`,label:"Database Name",type:"text",fullWidth:!0,variant:"standard",defaultValue:A.name}),g.jsx(mn,{margin:"dense",id:`attachedDb_${T}_type`,name:`attachedDb_${T}_type`,label:"Database Type",fullWidth:!0,variant:"standard",value:A.dbType,select:!0,onChange:D=>S(T,D.target.value),children:Object.values(u3).map(D=>g.jsx(mo,{value:D,children:D},D))}),M.filter(D=>D.visibleWhen?(A[D.visibleWhen.field]||M.find(R=>R.name===D.visibleWhen?.field)?.selectOptions?.[0]?.value)===D.visibleWhen.value:!0).map(D=>g.jsx(mn,{margin:"dense",id:`attachedDb_${T}_${D.name}`,name:`attachedDb_${T}_${D.name}`,label:D.label,type:D.selectOptions?void 0:D.type,fullWidth:!0,variant:"standard",required:D.required,select:!!D.selectOptions,defaultValue:D.selectOptions?.[0]?.value,onChange:D.selectOptions?R=>{const F=[...i];F[T]={...F[T],[D.name]:R.target.value},l(F)}:void 0,children:D.selectOptions?.map(R=>g.jsx(mo,{value:R.value,children:R.label},R.value))},D.name))]},T)})]}):Ss[o].map(A=>g.jsx(mn,{margin:"dense",id:A.name,name:A.name,label:A.label,type:A.type,fullWidth:!0,variant:"standard",required:A.required},A.name))]})]}),g.jsxs($s,{children:[g.jsx(Tr,{disabled:t,onClick:b,children:"Cancel"}),g.jsx(Tr,{type:"submit",form:"connection-form",loading:t,children:"Create Connection"})]})]})]})}function fTe({connection:e,onCloseDialog:t,isMutating:n,onDelete:r}){const[o,a]=C.useState(!1),[i,l]=C.useState(""),u=()=>{a(!0)},d=()=>{a(!1),t()};return g.jsxs(tt.Fragment,{children:[g.jsx(va,{"aria-label":`Delete connection ${e?.name??""}`.trim(),onClick:f=>{f.stopPropagation(),u()},children:g.jsx(vT,{})}),g.jsxs(Bs,{onClose:d,"aria-labelledby":"customized-dialog-title",open:o,children:[g.jsx($l,{sx:{m:0,p:2},id:"customized-dialog-title",children:"Delete Connection"}),g.jsx(va,{"aria-label":"close",onClick:d,sx:f=>({position:"absolute",right:8,top:8,color:f.palette.grey[500]}),children:g.jsx(Ns,{})}),g.jsx(js,{dividers:!0,children:g.jsxs(Jn,{gutterBottom:!0,children:['Are you sure you want to delete "',e.name,'"? This action cannot be undone.']})}),g.jsx($s,{children:g.jsx(Tr,{loading:n,variant:"contained",autoFocus:!0,onClick:()=>r(),color:"error",children:"Delete"})}),g.jsx(_s,{open:i!=="",autoHideDuration:6e3,onClose:()=>l(""),message:i})]})]})}function DI(e){const t=e.duckdbConnection?.attachedDatabases;return!t||t.length===0?[]:t.map(n=>({name:n.name||"",dbType:n.type||"postgres"}))}function RI(e){const t=e.ducklakeConnection;return t&&t.storage?.gcsConnection?"gcs":"s3"}function pTe({connection:e,onSubmit:t,isSubmitting:n}){const[r,o]=C.useState(!1),[a,i]=C.useState(e.type),[l,u]=C.useState(()=>DI(e)),[d,f]=C.useState("postgres"),[h,y]=C.useState(()=>RI(e)),b=()=>{u(DI(e)),i(e.type),f("postgres"),y(RI(e)),o(!0)},v=()=>{o(!1)},x=async D=>{D.preventDefault();const R=new FormData(D.currentTarget),F=R.get("name")?.toString(),B=R.get("type")?.toString(),z=Ss[B];if(!F)throw new Error("Name is required");if(!B)throw new Error("Type is required");let j;if(B==="ducklake"){const U={};if(d==="postgres"){const I=Ss.postgres,$={};if(I.forEach(_=>{const G=R.get(`ducklake_pg_${_.name}`)?.toString();G&&($[_.name]=G)}),Object.keys($).length===0)throw new Error("DuckLake requires catalog connection");U.postgresConnection=$}const w=R.get("ducklake_bucketUrl")?.toString();if(!w)throw new Error("DuckLake requires a bucket URL");const L={bucketUrl:w};if(h==="s3"){const I={};Bh.forEach(_=>{const G=R.get(`ducklake_s3_${_.name}`)?.toString();G&&(I[_.name]=G)});const $=e.ducklakeConnection?.storage?.s3Connection;if($&&(!I.accessKeyId&&$.accessKeyId&&(I.accessKeyId=$.accessKeyId),!I.secretAccessKey&&$.secretAccessKey&&(I.secretAccessKey=$.secretAccessKey)),!I.accessKeyId)throw new Error("S3 Access Key ID is required");if(!I.secretAccessKey)throw new Error("S3 Secret Access Key is required");Object.keys(I).length>0&&(L.s3Connection=I)}else if(h==="gcs"){const I={};jh.forEach(_=>{const G=R.get(`ducklake_gcs_${_.name}`)?.toString();G&&(I[_.name]=G)});const $=e.ducklakeConnection?.storage?.gcsConnection;if($&&(!I.keyId&&$.keyId&&(I.keyId=$.keyId),!I.secret&&$.secret&&(I.secret=$.secret)),!I.keyId)throw new Error("GCS Key ID is required");if(!I.secret)throw new Error("GCS Secret is required");Object.keys(I).length>0&&(L.gcsConnection=I)}j={name:F,type:B,ducklakeConnection:{catalog:U,storage:L}}}else if(B==="duckdb"){if(l.length===0)throw new Error("DuckDB connection must have at least one attached database");const U=l.map((w,L)=>{const I=w.dbType,$=R.get(`attachedDb_${L}_name`)?.toString();if(!$)throw new Error(`Attached database at index ${L} must have a name`);const _={name:$,type:I},G=Db(I);if(G&&G.length>0){const V={};G.forEach(P=>{const q=R.get(`attachedDb_${L}_${P.name}`)?.toString();q&&(V[P.name]=q)});const Y=oC[I];Y&&(_[Y]=V)}return _});j={name:F,type:B,duckdbConnection:{attachedDatabases:U}}}else{const U=e[Ly[B]]||{},w={};if(z.forEach(L=>{const I=R.get(L.name)?.toString(),$=U[L.name],_=L.type==="password"||L.name==="password"||L.name==="secretAccessKey"||L.name==="secret"||L.name==="accessToken"||L.name==="privateKey";I?w[L.name]=I:_&&$?w[L.name]=$:I!==void 0?w[L.name]=I:$&&(w[L.name]=$)}),B==="postgres"){if(!w.connectionString?.trim()){const L=["host","port","databaseName","userName","password"];for(const I of L)if(!w[I])throw new Error(`${z.find($=>$.name===I)?.label||I} is required`)}}else if(B==="bigquery"){if(!w.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(B==="snowflake"){if(!w.account)throw new Error("Account is required");if(!w.username)throw new Error("Username is required");if(!w.warehouse)throw new Error("Warehouse is required");if(!w.password&&!w.privateKey)throw new Error("Either password or private key is required")}else if(B==="trino"){if(!w.server)throw new Error("Server is required");if(!w.user)throw new Error("User is required");if(w.server.trim().startsWith("https://")&&!w.password&&!w.peakaKey)throw new Error("Password is required for HTTPS connections (or use Peaka Key)")}else if(B==="mysql"){const L=["host","port","database","user","password"];for(const I of L)if(!w[I])throw new Error(`${z.find($=>$.name===I)?.label||I} is required`)}else if(B==="motherduck"){if(!w.accessToken)throw new Error("Access Token is required")}else if(B==="databricks"){if(!w.host)throw new Error("Host is required");if(!w.path)throw new Error("HTTP Path is required");const L=w.oauthClientId&&w.oauthClientSecret;if(!w.token&&!L)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}j={name:F,type:B,[Ly[B]]:w}}await t(j),v()},E=()=>{u([...l,{name:"",dbType:"postgres"}])},S=D=>{u(l.filter((R,F)=>F!==D))},A=(D,R)=>{const F=[...l];F[D]={...F[D],dbType:R},u(F)},T=(D,R)=>{const F=e.duckdbConnection?.attachedDatabases;if(!F||!F[D])return"";const B=F[D],z=oC[B.type||""];return z&&B[z]?B[z][R]??"":""},M=D=>{const R=e.ducklakeConnection;if(!R)return"";if(D.startsWith("pg_")){const F=D.replace("pg_","");return R.catalog?.postgresConnection?.[F]??""}if(D==="bucketUrl")return R.storage?.bucketUrl??"";if(D.startsWith("s3_")){const F=D.replace("s3_","");return R.storage?.s3Connection?.[F]??""}if(D.startsWith("gcs_")){const F=D.replace("gcs_","");return R.storage?.gcsConnection?.[F]??""}return""};return g.jsxs(tt.Fragment,{children:[g.jsx(va,{"aria-label":`Edit connection ${e?.name??""}`.trim(),onClick:D=>{D.preventDefault(),D.stopPropagation(),b()},children:g.jsx(xT,{})}),g.jsxs(Bs,{open:r,onClose:v,children:[g.jsx($l,{onClick:D=>{D.stopPropagation()},children:"Edit Connection"}),g.jsxs(js,{onClick:D=>{D.stopPropagation()},children:[g.jsx(fm,{children:"Edit a connection to query your data database using Malloy."}),g.jsxs("form",{onSubmit:x,id:"connection-form",children:[g.jsx(mn,{autoFocus:!0,required:!0,margin:"dense",id:"name",name:"name",label:"Connection Name",type:"text",fullWidth:!0,variant:"standard",defaultValue:e.name}),g.jsx(mn,{margin:"dense",id:"type",name:"type",label:"Connection Type",fullWidth:!0,variant:"standard",value:a,select:!0,onChange:D=>i(D.target.value),children:Object.values(d3).map(D=>g.jsx(mo,{value:D,children:D},D))}),a==="ducklake"?g.jsxs(dr,{sx:{mt:2},children:[g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsx(Jn,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),g.jsx(mn,{margin:"dense",id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,variant:"standard",value:d,select:!0,onChange:D=>f(D.target.value),children:g.jsx(mo,{value:"postgres",children:"PostgreSQL"})}),d==="postgres"&&g.jsx(g.Fragment,{children:Ss.postgres.map(D=>g.jsx(mn,{margin:"dense",id:`ducklake_pg_${D.name}`,name:`ducklake_pg_${D.name}`,label:D.label,type:D.type,fullWidth:!0,variant:"standard",defaultValue:M(`pg_${D.name}`)},`pg_${D.name}`))})]}),g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsx(Jn,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),g.jsxs(mn,{margin:"dense",id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,variant:"standard",value:h,select:!0,onChange:D=>y(D.target.value),children:[g.jsx(mo,{value:"s3",children:"S3"}),g.jsx(mo,{value:"gcs",children:"GCS"})]}),g.jsx(mn,{margin:"dense",required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:h==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,variant:"standard",defaultValue:M("bucketUrl")}),h==="s3"&&g.jsxs(g.Fragment,{children:[g.jsx(Jn,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Bh.map(D=>g.jsx(mn,{margin:"dense",id:`ducklake_s3_${D.name}`,name:`ducklake_s3_${D.name}`,label:D.label,type:D.type,fullWidth:!0,variant:"standard",required:D.required&&D.name!=="secretAccessKey",defaultValue:M(`s3_${D.name}`),placeholder:D.name==="region"?"us-east-1":D.name==="secretAccessKey"?"Leave empty to keep existing":void 0},`s3_${D.name}`))]}),h==="gcs"&&g.jsxs(g.Fragment,{children:[g.jsx(Jn,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),jh.map(D=>g.jsx(mn,{margin:"dense",id:`ducklake_gcs_${D.name}`,name:`ducklake_gcs_${D.name}`,label:D.label,type:D.type,fullWidth:!0,variant:"standard",required:D.required&&D.name!=="secret",defaultValue:M(`gcs_${D.name}`),placeholder:D.name==="secret"?"Leave empty to keep existing":void 0},`gcs_${D.name}`))]})]})]}):a==="duckdb"?g.jsxs(dr,{sx:{mt:2},children:[g.jsxs(dr,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[g.jsx(Jn,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),g.jsx(Tr,{startIcon:g.jsx(DT,{}),onClick:E,size:"small",variant:"outlined",children:"Add Database"})]}),l.length===0&&g.jsx(Jn,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),l.map((D,R)=>{const F=Db(D.dbType);return g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsxs(dr,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[g.jsxs(Jn,{variant:"subtitle2",children:["Database ",R+1]}),g.jsx(va,{"aria-label":`Remove attached database ${R+1}`,onClick:()=>S(R),size:"small",color:"error",children:g.jsx(UF,{fontSize:"small"})})]}),g.jsx(mn,{margin:"dense",required:!0,id:`attachedDb_${R}_name`,name:`attachedDb_${R}_name`,label:"Database Name",type:"text",fullWidth:!0,variant:"standard",defaultValue:D.name}),g.jsx(mn,{margin:"dense",id:`attachedDb_${R}_type`,name:`attachedDb_${R}_type`,label:"Database Type",fullWidth:!0,variant:"standard",value:D.dbType,select:!0,onChange:B=>A(R,B.target.value),children:Object.values(u3).map(B=>g.jsx(mo,{value:B,children:B},B))}),F.filter(B=>B.visibleWhen?(D[B.visibleWhen.field]||T(R,B.visibleWhen.field)||F.find(z=>z.name===B.visibleWhen?.field)?.selectOptions?.[0]?.value)===B.visibleWhen.value:!0).map(B=>g.jsx(mn,{margin:"dense",id:`attachedDb_${R}_${B.name}`,name:`attachedDb_${R}_${B.name}`,label:B.label,type:B.selectOptions?void 0:B.type,fullWidth:!0,variant:"standard",required:B.required,select:!!B.selectOptions,defaultValue:T(R,B.name)||B.selectOptions?.[0]?.value,onChange:B.selectOptions?z=>{const j=[...l];j[R]={...j[R],[B.name]:z.target.value},u(j)}:void 0,children:B.selectOptions?.map(z=>g.jsx(mo,{value:z.value,children:z.label},z.value))},B.name))]},R)})]}):Ss[a].map(D=>{const R=e?.[Ly[a]??""]?.[D.name??""]??"",F=D.type==="password"||D.name==="password"||D.name==="secretAccessKey"||D.name==="secret"||D.name==="accessToken"||D.name==="privateKey";return g.jsx(mn,{margin:"dense",id:D.name,name:D.name,label:D.label,type:D.type,fullWidth:!0,variant:"standard",required:D.required&&!F&&!R,defaultValue:R,placeholder:F&&R?"Leave empty to keep existing":void 0},D.name)})]})]}),g.jsxs($s,{onClick:D=>{D.stopPropagation()},children:[g.jsx(Tr,{disabled:n,onClick:v,children:"Cancel"}),g.jsx(Tr,{type:"submit",form:"connection-form",loading:n,children:"Edit Connection"})]})]})]})}function MI(e,t){return!e||e.type!=="duckdb"?!1:(e.duckdbConnection?.attachedDatabases||[]).some(n=>n.type==="azure"&&n.name===t)}function hTe(e){return e.startsWith("gs://")||e.startsWith("s3://")||e.startsWith("https://")||e.startsWith("abfss://")||e.startsWith("az://")}function mTe({connectionName:e,resourceUri:t,schema:n,connection:r}){const{apiClients:o}=cr(),{environmentName:a}=Kr(t),[i,l]=tt.useState(null),[u,d]=tt.useState(n||null),[f,h]=tt.useState(!1),{data:y,isError:b,isLoading:v,error:x}=bo({queryKey:["schemas",a,e],queryFn:()=>o.connections.listSchemas(a,e)}),E=y?.data||[];return g.jsxs(Fi,{container:!0,spacing:1,children:[!n&&g.jsx(Fi,{size:{xs:12,md:4},children:g.jsxs(Ts,{sx:{p:1,m:0},children:[g.jsxs(xt,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:0},children:[g.jsx(ft,{variant:"overline",fontWeight:"bold",children:"Table Paths"}),g.jsx(TG,{control:g.jsx(pK,{checked:f,onChange:S=>h(S.target.checked)}),label:"Hidden Schemas"})]}),g.jsx(Wi,{sx:{mt:"2px"}}),g.jsxs(xt,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[v&&g.jsx(ya,{text:"Loading schemas..."}),b&&g.jsx(ba,{error:x,context:`${a} > ${e} > Schemas`}),!v&&!b&&E.length===0&&g.jsx(ft,{variant:"body2",children:"No Schemas"}),!v&&!b&&E.length>0&&g.jsx(rT,{dense:!0,disablePadding:!0,children:E.map(S=>{const A=S.name;return S.isHidden&&!f?null:g.jsx(x5,{selected:u===A,onClick:()=>{d(A),l(null)},children:g.jsx(Wd,{primary:A})},A)})})]})]})}),g.jsx(Fi,{size:{xs:12,md:n?6:4},children:u&&g.jsx(Ts,{sx:{p:1,m:0},children:g.jsx(bTe,{connectionName:e,schemaName:u,onTableSelect:S=>{l(S)},resourceUri:t,connection:r})})}),g.jsx(Fi,{size:{xs:12,md:n?6:4},children:u&&i&&g.jsx(gTe,{environmentName:a,connectionName:e,schemaName:u,tableResource:i})})]})}function gTe({environmentName:e,connectionName:t,schemaName:n,tableResource:r}){const{apiClients:o}=cr(),{data:a,isLoading:i,isError:l,error:u}=bo({queryKey:["connectionTableDetail",e,t,n,r],queryFn:()=>o.connections.getTable(e,t,n,r),enabled:!!n&&!!r}),d={resource:a?.data?.resource??r,columns:a?.data?.columns??[]};return g.jsxs(Ts,{sx:{p:1,m:0},children:[l&&g.jsx(ba,{error:u,context:`${e} > ${t} > ${n} > ${r}`}),!l&&g.jsx(yTe,{table:d,loading:i})]})}function yTe({table:e,loading:t}){return t?g.jsx(ya,{text:"Loading columns..."}):g.jsxs(g.Fragment,{children:[g.jsxs(ft,{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]}),g.jsx(Wi,{}),g.jsx(xt,{sx:{mt:"10px",maxHeight:"600px",overflowY:"auto"},children:g.jsx(DK,{children:g.jsxs(sT,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[g.jsx(D5,{children:g.jsxs(Ad,{children:[g.jsx(zo,{children:"NAME"}),g.jsx(zo,{children:"TYPE"})]})}),g.jsx(lT,{children:e.columns?.sort((n,r)=>n.name.localeCompare(r.name))?.map(n=>g.jsxs(Ad,{children:[g.jsx(zo,{children:n.name}),g.jsx(zo,{children:n.type})]},n.name))})]})})})]})}function bTe({connectionName:e,schemaName:t,onTableSelect:n,resourceUri:r,connection:o}){const{environmentName:a}=Kr(r),{apiClients:i}=cr(),[l,u]=C.useState(""),{data:d,isSuccess:f,isError:h,error:y,isLoading:b}=bo({queryKey:["tablesInSchema",a,e,t],queryFn:()=>i.connections.listTables(a,e,t)}),v=MI(o,t),x=S=>v?S:S.split(".").pop()||S,E=f&&d?.data?d.data.filter(S=>x(S.resource).toLowerCase().includes(l.toLowerCase())).sort((S,A)=>x(S.resource).localeCompare(x(A.resource))):[];return g.jsxs(g.Fragment,{children:[g.jsx(ft,{variant:"overline",fontWeight:"bold",children:hTe(t)||MI(o,t)?`Files in ${t}`:`Tables in ${t}`}),g.jsx(Wi,{}),g.jsx(xt,{sx:{mt:1,mb:1},children:g.jsx(by,{size:"small",fullWidth:!0,placeholder:"Search tables...",value:l,onChange:S=>u(S.target.value),variant:"outlined"})}),g.jsx(Wi,{}),g.jsxs(xt,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[b&&g.jsx(ya,{text:"Fetching Tables..."}),h&&g.jsx(ba,{error:y,context:`${a} > ${e} > ${t}`}),f&&E.length===0&&g.jsx(ft,{variant:"body2",children:"No Tables"}),f&&d?.data&&d.data.length>0&&g.jsx(rT,{dense:!0,disablePadding:!0,children:E.map(S=>{let A=x(S.resource);return!v&&S.resource.includes("://")&&(A=S.resource.split("/").pop()||S.resource),g.jsx(x5,{onClick:()=>n(S.resource),children:g.jsx(Wd,{primary:A,secondary:S.columns.length>0?`${S.columns.length} columns`:void 0})},S.resource)})})]})]})}function vTe({connection:e,onClick:t,onEdit:n,onDelete:r,isMutating:o,mutable:a,isAdding:i}){return g.jsxs(Ad,{sx:{"&:hover":{backgroundColor:i?void 0:"action.hover"}},children:[g.jsx(zo,{sx:{cursor:i?"default":"pointer",flexGrow:1,opacity:i?.5:1},onClick:i?void 0:t,children:g.jsxs(xt,{sx:{display:"flex",alignItems:"center",gap:1},children:[g.jsx(ft,{variant:"body2",children:e.name}),g.jsx(Fh,{sx:{fontSize:"1rem",color:"action.active",opacity:.7}})]})}),g.jsx(zo,{sx:{minWidth:"120px"},children:g.jsx(ft,{variant:"body2",children:e.type})}),a&&g.jsxs(zo,{sx:{minWidth:"120px"},children:[g.jsx(pTe,{connection:e,onSubmit:n,isSubmitting:o}),g.jsx(fTe,{connection:e,onCloseDialog:()=>{},isMutating:o,onDelete:()=>r(e)})]})]},e.name)}function xTe({resourceUri:e}){const{apiClients:t,mutable:n}=cr(),r=Ls(),{environmentName:o}=Kr(e),[a,i]=C.useState(""),[l,u]=C.useState(null),d=cw({environmentName:o,connectionName:l}),{data:f,isSuccess:h,isError:y,error:b}=bo({queryKey:["connections",o],queryFn:()=>t.connections.listConnections(o)}),v=T=>{u(T)},x=()=>{u(null)},E=zi({mutationFn:T=>t.environments.updateEnvironment(o,{name:o,connections:[...f.data,T]}),onSuccess(){i("Connection added successfully"),r.invalidateQueries({queryKey:["connections",o]})},onError(T){i(T.message)}}),S=zi({mutationFn:T=>t.environments.updateEnvironment(o,{name:o,connections:f.data.map(M=>M.name===T.name?T:M)}),onSuccess(T,M){i(`Connection ${M.name} updated successfully`),r.invalidateQueries({queryKey:["connections",o]})},onError(T){i(T.message)}}),A=zi({mutationFn:T=>t.environments.updateEnvironment(o,{name:o,connections:f.data.filter(M=>M.name!==T.name)}),onSuccess(T,M){i(`Connection ${M.name} deleted successfully`),r.invalidateQueries({queryKey:["connections",o]})},onError(T){i(T.message)}});return g.jsxs(g.Fragment,{children:[g.jsx(z3,{children:g.jsxs(H3,{children:[g.jsx(V3,{children:"Database Connections"}),g.jsxs(xt,{sx:{mb:1,maxHeight:"200px",overflowY:"auto"},children:[!h&&!y&&g.jsx(ft,{variant:"body2",sx:{m:"auto"},children:"Fetching Connections..."}),h&&f.data.length>0&&g.jsx(sT,{size:"small",sx:{borderCollapse:"collapse","& .MuiTableRow-root":{display:"flex",width:"100%"},"& .MuiTableCell-root":{borderBottom:"1px solid #e0e0e0",display:"flex",alignItems:"center"},"& .MuiTableRow-root:last-child .MuiTableCell-root":{borderBottom:"none"}},children:g.jsxs(lT,{children:[g.jsxs(Ad,{children:[g.jsx(zo,{sx:{flexGrow:1},children:g.jsx(ft,{variant:"body2",fontWeight:"500",color:"text.secondary",children:"Connection Name"})}),g.jsx(zo,{sx:{minWidth:"120px"},children:g.jsx(ft,{variant:"body2",fontWeight:"500",color:"text.secondary",children:"Type"})}),n&&g.jsx(zo,{sx:{minWidth:"120px"},children:g.jsx(ft,{variant:"body2",fontWeight:"500",color:"text.secondary",sx:{mx:"auto"},children:"Actions"})})]}),f.data.map(T=>g.jsx(vTe,{connection:T,onClick:()=>v(T.name),onEdit:M=>S.mutateAsync(M),onDelete:M=>{T.resource?i("Cannot delete this connection"):A.mutateAsync(M)},isMutating:E.isPending||S.isPending||A.isPending,mutable:n,isAdding:E.isPending},T.name))]})}),h&&f.data.length===0&&g.jsx(ft,{variant:"body2",children:"No Connections"}),y&&g.jsx(ba,{error:b,context:`${o} > Connections`})]}),n&&g.jsx(xt,{sx:{display:"flex",justifyContent:"flex-end"},children:g.jsx(dTe,{onSubmit:T=>E.mutateAsync(T),isSubmitting:E.isPending})})]})}),g.jsx(_s,{open:a!=="",autoHideDuration:6e3,onClose:()=>i(""),message:a}),g.jsxs(ks,{open:l!==null,onClose:x,maxWidth:"lg",fullWidth:!0,children:[g.jsxs(Ds,{children:["Connection Explorer: ",l,g.jsx(Cr,{"aria-label":"close",onClick:x,sx:{position:"absolute",right:8,top:8},children:g.jsx(xt,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:"X"})})]}),g.jsx(As,{children:l&&g.jsx(mTe,{resourceUri:d,connectionName:l,connection:f?.data?.find(T=>T.name===l)})})]})]})}const OI="README.malloynb";function xwe({onClickPackageFile:e,resourceUri:t,retrievalFn:n}){const{apiClients:r}=cr(),o=e??(D=>{window.location.href=D}),{environmentName:a,packageName:i,versionId:l}=Kr(t),[u,d]=C.useState(null),f=bo({queryKey:["package",a,i,l],queryFn:()=>r.packages.getPackage(a,i,l,!1)}),h=bo({queryKey:["notebooks",a,i,l],queryFn:()=>r.notebooks.listNotebooks(a,i,l)}),y=bo({queryKey:["models",a,i,l],queryFn:()=>r.models.listModels(a,i,l)}),b=bo({queryKey:["databases",a,i,l],queryFn:()=>r.databases.listDatabases(a,i,l)}),v=(h.data?.data??[]).slice().sort((D,R)=>D.path.localeCompare(R.path)),x=(y.data?.data??[]).slice().sort((D,R)=>D.path.localeCompare(R.path)),E=(b.data?.data??[]).slice().sort((D,R)=>D.path.localeCompare(R.path)),S=f.data?.data?.description??"",A=v.some(D=>D.path===OI),T=cw({environmentName:a,packageName:i,versionId:l,modelPath:OI}),M=!h.isSuccess&&!h.isError;return f.isError?g.jsx(ba,{error:f.error,context:`${a} > ${i}`}):g.jsxs(JC,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[g.jsxs(xt,{sx:{mb:4},children:[g.jsxs(GG,{onClick:D=>o(`/${a}/`,D),underline:"none",sx:{display:"inline-flex",alignItems:"center",gap:.5,cursor:"pointer",color:"text.secondary",fontSize:"0.875rem",mb:2,"&:hover":{color:"primary.main"}},children:[g.jsx(iTe,{sx:{fontSize:18}}),"Back to ",a]}),g.jsx(ft,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:i}),S&&g.jsx(ft,{variant:"body2",color:"text.secondary",children:S})]}),M&&g.jsx(ya,{text:"Loading package..."}),!M&&g.jsxs(g.Fragment,{children:[g.jsxs(SS,{title:"Governed Reports",count:v.length,children:[v.map(D=>g.jsx(ES,{icon:g.jsx(xS,{type:"report"}),tint:Rc.teal,label:D.path,onClick:R=>o(D.path,R)},D.path)),v.length===0&&g.jsx(CS,{label:"No notebooks"})]}),g.jsxs(SS,{title:"Semantic Models",count:x.length,children:[x.map(D=>g.jsx(ES,{icon:g.jsx(xS,{type:"model"}),tint:Rc.orange,label:D.path,onClick:R=>o(D.path,R)},D.path)),x.length===0&&g.jsx(CS,{label:"No models"})]}),g.jsxs(SS,{title:"Package Data",count:E.length,children:[E.map(D=>g.jsx(ES,{icon:g.jsx(xS,{type:"data"}),tint:Rc.darkBlue,label:D.path,rightLabel:STe(D.info.rowCount),onClick:()=>d(D)},D.path)),E.length===0&&g.jsx(CS,{label:"No data files"})]}),g.jsx(xt,{sx:{mb:4},children:g.jsx(xTe,{resourceUri:t})}),A&&g.jsx(xt,{sx:{mt:6},children:g.jsx(aTe,{resourceUri:T,retrievalFn:n})})]}),g.jsxs(ks,{open:u!==null,onClose:()=>d(null),maxWidth:"sm",fullWidth:!0,children:[g.jsxs(Ds,{sx:{pr:6},children:[u?.path,g.jsx(Cr,{"aria-label":"close",onClick:()=>d(null),sx:{position:"absolute",right:8,top:8},children:g.jsx(Ns,{fontSize:"small"})})]}),g.jsx(As,{children:u?.info?.columns&&g.jsxs(sT,{size:"small",children:[g.jsx(D5,{children:g.jsxs(Ad,{children:[g.jsx(zo,{children:"Column"}),g.jsx(zo,{children:"Type"})]})}),g.jsx(lT,{children:u.info.columns.map(D=>g.jsxs(Ad,{children:[g.jsx(zo,{component:"th",scope:"row",children:D.name}),g.jsx(zo,{children:D.type})]},D.name))})]})})]})]})}function SS({title:e,count:t,children:n}){return g.jsxs(xt,{sx:{mb:4},children:[g.jsxs(lo,{direction:"row",alignItems:"baseline",spacing:1,sx:{mb:1},children:[g.jsx(ft,{variant:"h6",sx:{fontWeight:600,letterSpacing:"-0.025em"},children:e}),g.jsxs(ft,{variant:"caption",color:"text.secondary",children:["(",t,")"]})]}),g.jsx(xt,{children:n})]})}function ES({icon:e,tint:t,label:n,rightLabel:r,onClick:o}){const a=!!o;return g.jsxs(xt,{onClick:o,onKeyDown:a?i=>{o&&(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),o(i))}:void 0,role:a?"button":void 0,tabIndex:a?0:void 0,sx:{display:"flex",alignItems:"center",gap:1.5,py:1,px:1,mx:-1,cursor:a?"pointer":"default",borderRadius:1.5,transition:"background-color 0.1s","&:hover":a?{backgroundColor:"grey.100"}:void 0,"&:focus-visible":a?{outline:"2px solid",outlineColor:"primary.main",outlineOffset:2}:void 0},children:[g.jsx(xt,{sx:{width:32,height:32,borderRadius:1,bgcolor:t,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),g.jsx(ft,{variant:"body2",sx:{fontFamily:tne,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),r&&g.jsx(ft,{variant:"caption",color:"text.secondary",sx:{flexShrink:0},children:r})]})}function CS({label:e}){return g.jsx(ft,{variant:"body2",color:"text.secondary",sx:{py:1,fontStyle:"italic"},children:e})}function STe(e){return e>=1e9?`${(e/1e9).toFixed(1)} B rows`:e>=1e6?`${(e/1e6).toFixed(1)} M rows`:e>=1e3?`${(e/1e3).toFixed(1)} K rows`:`${e} rows`}const ETe=async e=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:t}=await io(async()=>{const{MalloyRenderer:n}=await import("./index.umd-CCAfKkxY.js").then(r=>r.i);return{MalloyRenderer:n}},[]);return new t({onClick:e,onError:n=>{console.error("Error rendering visualization:",typeof n,n)}}).createViz()};function CTe({result:e,height:t,onDrill:n,onSizeChange:r}){const o=C.useRef(null),a=C.useRef(!1);return C.useLayoutEffect(()=>{if(!o.current||!e)return;let i=!0;const l=o.current;for(;l.firstChild;)l.removeChild(l.firstChild);a.current=!1;let u=null,d=null;const f=()=>{if(a.current||!i||!l.firstElementChild)return;const h=l.firstElementChild.firstElementChild;if(!h)return;const y=h.firstElementChild;let b=h.scrollHeight||h.offsetHeight||0;y&&h.classList.contains("malloy-dashboard")&&(b=y.scrollHeight||y.offsetHeight||0),b>0&&(a.current=!0,r&&r(b))};return ETe(n).then(h=>{if(i){u=new MutationObserver(()=>{d&&clearTimeout(d),d=setTimeout(()=>{f(),u?.disconnect()},100)}),u.observe(l,{childList:!0,subtree:!0,attributes:!0});try{h.setResult(JSON.parse(e)),h.render(l)}catch(y){console.error("Error rendering visualization:",y),u?.disconnect()}}}).catch(h=>{console.error("Failed to create renderer:",h)}),()=>{i=!1,u?.disconnect(),d&&clearTimeout(d)}},[e,n,r]),g.jsx("div",{ref:o,style:{width:"100%",height:t?`${t}px`:"400px"}})}function TTe(e){return typeof window>"u"?g.jsx(xt,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):g.jsx(C.Suspense,{fallback:g.jsx(xt,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:g.jsx(CTe,{...e})})}const wTe=Object.freeze(Object.defineProperty({__proto__:null,default:TTe},Symbol.toStringTag,{value:"Module"})),Pn={white:"#FFFFFF",offWhite:"#F8F8F6",grey:{light:"#E6E4E1",mid:"#91908F"},black:"#30302E",semantic:{success:{main:"#7A9461",light:"#E8EDDF",dark:"#5F7A4B"},warning:{main:"#B5943A",light:"#F3ECDA",dark:"#8E7430"},error:{main:"#BF6050",light:"#F2DDD9",dark:"#9C4D40"},info:{main:"#628698",light:"#DDE6EA",dark:"#4D6B79"}}},ay='"Inter", "Helvetica Neue", "Arial", sans-serif',Na={50:Pn.offWhite,100:"#F4F3F1",200:Pn.grey.light,300:"#D4D2CF",400:"#B3B1AF",500:Pn.grey.mid,600:"#73726F",700:"#555450",800:"#424140",900:Pn.black},Swe={headerHeight:56},TS="0 1px 3px rgba(0, 0, 0, 0.1)",kTe=Gb({cssVariables:{nativeColor:!0},palette:{mode:"light",primary:{main:Pn.black,light:Pn.grey.light,dark:Pn.black,contrastText:Pn.white},secondary:{main:Pn.grey.mid,light:Pn.grey.light,dark:Pn.black},grey:Na,success:Pn.semantic.success,warning:Pn.semantic.warning,error:Pn.semantic.error,info:Pn.semantic.info,background:{default:Pn.white,paper:Pn.white},text:{primary:Pn.black,secondary:Pn.grey.mid},divider:Pn.grey.light},typography:{fontFamily:ay,h1:{fontWeight:500,letterSpacing:"-0.025em"},h2:{fontWeight:500,letterSpacing:"-0.025em"},h3:{fontWeight:500,letterSpacing:"-0.025em"},h4:{fontWeight:500,letterSpacing:"-0.025em"},h5:{fontWeight:500,letterSpacing:"-0.025em"},h6:{fontWeight:500,letterSpacing:"-0.025em"},subtitle1:{fontWeight:500,letterSpacing:"-0.025em"},subtitle2:{fontWeight:500,letterSpacing:"-0.025em"},body1:{letterSpacing:"-0.025em"},body2:{letterSpacing:"-0.025em"},button:{fontWeight:500,letterSpacing:"-0.025em",textTransform:"none"}},shape:{borderRadius:4},components:{MuiButtonBase:{defaultProps:{disableRipple:!0,disableTouchRipple:!0}},MuiCssBaseline:{styleOverrides:{"*":{scrollbarWidth:"thin",scrollbarColor:`${Na[300]} ${Na[100]}`,"&::-webkit-scrollbar":{width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{background:Na[100],borderRadius:"4px"},"&::-webkit-scrollbar-thumb":{background:Na[300],borderRadius:"4px","&:hover":{background:Na[400]}},"&::-webkit-scrollbar-corner":{background:Na[100]}},"div[data-radix-popper-content-wrapper]":{zIndex:"1300 !important"}}},MuiButton:{styleOverrides:{root:{borderRadius:20,textTransform:"none",fontWeight:500,boxShadow:"none","&:hover":{boxShadow:TS}},contained:{"&:hover":{boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)"}}}},MuiCard:{styleOverrides:{root:{borderRadius:4,boxShadow:TS,border:"1px solid",borderColor:Pn.grey.light}}},MuiChip:{styleOverrides:{root:{borderRadius:4,fontWeight:500}}},MuiTextField:{styleOverrides:{root:{"& .MuiOutlinedInput-root":{borderRadius:4},"& .MuiInputLabel-outlined":{backgroundColor:"white",paddingLeft:4,paddingRight:4,"&.MuiInputLabel-shrink":{transform:"translate(14px, -9px) scale(0.75)"}}}}},MuiDialog:{styleOverrides:{paper:{borderRadius:4,boxShadow:"0px 20px 25px -5px rgba(0, 0, 0, 0.1), 0px 10px 10px -5px rgba(0, 0, 0, 0.04)"}}},MuiSelect:{styleOverrides:{select:{fontFamily:ay,fontSize:"0.875rem",color:Na[600]}}},MuiInputLabel:{styleOverrides:{root:{"&.MuiInputLabel-outlined":{backgroundColor:"white",paddingLeft:4,paddingRight:4}}}},MuiOutlinedInput:{styleOverrides:{notchedOutline:{border:"none"},root:{border:`1px solid ${Na[200]}`,borderRadius:8,transition:"border-color 120ms ease-in","&:hover":{borderColor:Na[300]},"&.Mui-focused":{borderColor:Na[400],outline:"none"}}}},MuiMenuItem:{styleOverrides:{root:{fontFamily:ay,fontSize:"0.875rem"}}},MuiInputBase:{styleOverrides:{root:{fontFamily:ay}}},MuiMenu:{styleOverrides:{paper:{borderRadius:4,boxShadow:"0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",border:`1px solid ${Pn.grey.light}`}}},MuiBreadcrumbs:{styleOverrides:{root:{"& .MuiBreadcrumbs-separator":{margin:"0 6px",color:Na[400]}}}},MuiDivider:{styleOverrides:{root:{borderColor:Pn.grey.light}},defaultProps:{sx:{my:1}}},MuiListItemButton:{styleOverrides:{root:{borderRadius:28,margin:"2px 8px",padding:"8px 16px","&:hover":{backgroundColor:Pn.offWhite},"&.Mui-selected":{backgroundColor:Pn.offWhite,color:Pn.black,"& .MuiListItemIcon-root":{color:Pn.black},"& .MuiListItemText-primary":{color:Pn.black},"&:hover":{backgroundColor:Pn.grey.light}}}}},MuiAppBar:{styleOverrides:{root:{backgroundColor:Pn.white,color:Pn.black,boxShadow:TS}}}}}),ATe=C.lazy(()=>io(()=>import("./HomePage-BgH9UkjK.js"),[])),DTe=C.lazy(()=>io(()=>import("./MainPage-DiBxABem.js"),[])),RTe=C.lazy(()=>io(()=>import("./ModelPage-oS70fj83.js"),[])),MTe=C.lazy(()=>io(()=>import("./PackagePage-F_qLDAdv.js"),[])),OTe=C.lazy(()=>io(()=>import("./EnvironmentPage-BVkQH_xQ.js"),[])),NTe=C.lazy(()=>io(()=>import("./RouteError-WqpffppN.js"),[])),PTe=C.lazy(()=>io(()=>import("./WorkbookPage-_YmC-ebR.js"),[])),ITe=(e="/",t,n)=>t9([{path:e,element:g.jsx(bZ,{children:g.jsx(Fhe,{workbookStorage:t,children:g.jsxs(sH,{theme:kTe,children:[g.jsx(Tq,{}),g.jsx(C.Suspense,{fallback:g.jsx(ya,{}),children:g.jsx(DTe,{headerProps:n})})]})})}),errorElement:g.jsx(NTe,{}),children:[{index:!0,element:g.jsx(ATe,{})},{path:":environmentName",element:g.jsx(OTe,{})},{path:":environmentName/:packageName",element:g.jsx(MTe,{})},{path:":environmentName/:packageName/*",element:g.jsx(RTe,{})},{path:":environmentName/:packageName/workbook/:workspace/:workbookPath",element:g.jsx(PTe,{})}]}]),_Te=ITe("/",new Hhe,void 0);n7.createRoot(document.getElementById("root")).render(g.jsx(C.StrictMode,{children:g.jsx(p9,{router:_Te})}));export{vwe as $,Ye as A,_c as B,Oo as C,ji as D,BS as E,BTe as F,xt as G,MW as H,Cr as I,Yc as J,rT as K,bwe as L,y5 as M,SQ as N,jo as O,Ts as P,x5 as Q,hh as R,Uhe as S,ft as T,rv as U,Wd as V,Swe as W,cr as X,jTe as Y,ya as Z,cw as _,ma as a,aTe as a0,xwe as a1,ywe as a2,T8 as a3,JC as a4,lo as a5,gwe as a6,eu as a7,am as a8,Jle as a9,WT as aa,Cv as ab,OT as ac,PT as ad,mN as ae,q3 as af,FTe as ag,LTe as ah,tt as ai,El as aj,Ob as ak,NI as al,Lt as b,_l as c,It as d,IS as e,Ft as f,kU as g,u5 as h,mt as i,g as j,_t as k,Is as l,Yt as m,ci as n,Nr as o,Qc as p,Cs as q,C as r,Ue as s,G_ as t,AC as u,xd as v,X_ as w,_C as x,hH as y,un as z};
|
|
451
|
+
`),B=!!e.text&&(D.test(e.text)||R.test(e.text)),z=()=>{if(!e.newSources||e.newSources.length===0)return 0;let L=[],I="";if(e.text){const $=e.text.match(D);$&&(L=$[1].split(",").map(G=>G.trim()));const _=e.text.match(R);_&&(I=_[1].trim())}for(let $=0;$<e.newSources.length;$++)try{const _=JSON.parse(e.newSources[$]);if(L.length>0&&L.includes(_.name)||I&&I===_.path)return $}catch{continue}return 0},j=e.newSources&&e.newSources.length>0?{sourceInfos:e.newSources,resource:r}:void 0,U=nTe({query:e.text,resourceUri:r});C.useEffect(()=>{e.type==="code"&&yb(F(e.text),"malloy").then(L=>{v(L)})},[e]),C.useEffect(()=>{yb(U,"typescript").then(L=>{E(L)})},[U]);const w=()=>{const L=window.location.href;navigator.clipboard.writeText(L).then(()=>M("URL copied to clipboard!")).catch(()=>M("Failed to copy URL"))};return e.type==="markdown"&&g.jsx(hE,{children:g.jsxs(xt,{sx:{"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:"600",color:"#1a1a1a",marginBottom:"8px",marginTop:"16px"},"& h1":{fontSize:"28px"},"& h2":{fontSize:"24px"},"& h3":{fontSize:"20px"},"& p":{color:"#333333",lineHeight:"1.7",marginBottom:"8px",fontSize:"16px"},"& ul, & ol":{color:"#333333",lineHeight:"1.7",marginBottom:"8px",fontSize:"16px"},"& li":{marginBottom:"4px"}},children:[o===0?g.jsxs(lo,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",children:[g.jsx(nb,{children:e.text}),g.jsx(jo,{title:"Click to copy link",children:g.jsx(MT,{sx:{fontSize:"24px",color:"text.secondary",cursor:"pointer",marginTop:"26px"},onClick:w})})]}):g.jsx(nb,{children:e.text}),g.jsx(_s,{open:T!=="",autoHideDuration:6e3,onClose:()=>M(""),message:T})]})})||e.type==="code"&&g.jsxs(hE,{children:[(!t||!n&&e.result||e.newSources&&e.newSources.length>0)&&g.jsx(lo,{sx:{flexDirection:"column",gap:"8px",marginBottom:"2px"},children:e.newSources&&e.newSources.length>0&&g.jsx(ky,{sx:{position:"relative",padding:"0"},children:g.jsxs(xt,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"24px",paddingRight:"8px"},children:[b&&g.jsx("span",{dangerouslySetInnerHTML:{__html:b},style:{fontFamily:"monospace",fontSize:"14px",flex:1,marginRight:"8px"}}),B&&g.jsx(Cr,{sx:{backgroundColor:"rgba(255, 255, 255, 0.9)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},width:"32px",height:"32px",flexShrink:0},onClick:()=>A(!0),children:g.jsx(Fh,{sx:{fontSize:"18px",color:"text.secondary"}})})]})})}),g.jsx(BF,{open:S,onClose:()=>A(!1),title:"Data Sources",hasValidImport:B,resourceUri:r,data:j,initialSelectedSourceIndex:z()}),g.jsxs(ks,{open:l,onClose:()=>u(!1),maxWidth:"lg",fullWidth:!0,children:[g.jsxs(Ds,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:["Malloy Code",g.jsx(Cr,{onClick:()=>u(!1),sx:{color:"text.secondary"},children:g.jsx(Ns,{})})]}),g.jsx(As,{children:g.jsx(xt,{sx:{border:"1px solid #e0e0e0",borderRadius:"8px",padding:"16px",fontFamily:"monospace",fontSize:"14px",lineHeight:"1.5",overflow:"auto",maxHeight:"70vh",backgroundColor:"#ffffff"},children:g.jsx("pre",{className:"code-display",style:{margin:0},dangerouslySetInnerHTML:{__html:b}})})})]}),g.jsxs(ks,{open:d,onClose:()=>f(!1),maxWidth:"lg",fullWidth:!0,children:[g.jsxs(Ds,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:["Embeddable Code",g.jsx(Cr,{onClick:()=>f(!1),sx:{color:"text.secondary"},children:g.jsx(Ns,{})})]}),g.jsx(As,{children:g.jsxs(lo,{sx:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start"},children:[g.jsx(ft,{component:"div",sx:{fontSize:"12px",fontFamily:"monospace","& .line":{textWrap:"wrap"},flex:1},dangerouslySetInnerHTML:{__html:x}}),g.jsx(jo,{title:"Copy Embeddable Code",children:g.jsx(Cr,{sx:{width:"24px",height:"24px",marginLeft:"8px",color:"text.secondary"},onClick:()=>{navigator.clipboard.writeText(U)},children:g.jsx(tTe,{})})})]})})]}),g.jsx(_F,{open:h,onClose:()=>y(!1),result:e.result||"",title:"Results"}),i&&!e.result&&!B&&!(e.newSources&&e.newSources.length>0)&&g.jsx(ky,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:g.jsx(Kb,{size:32})}),e.result&&g.jsxs(ky,{sx:{position:"relative"},children:[g.jsx(xt,{sx:{paddingTop:"24px"},children:g.jsx(_v,{result:e.result,maxHeight:700,maxResultSize:a})}),g.jsxs(lo,{sx:{position:"absolute",top:"8px",right:"8px",flexDirection:"row",gap:"8px",alignItems:"center",zIndex:2},children:[!t&&g.jsx(Cr,{sx:{backgroundColor:"rgba(255, 255, 255, 0.9)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},width:"32px",height:"32px"},onClick:L=>{L.stopPropagation(),u(!0)},children:g.jsx(W3,{sx:{fontSize:"18px",color:"text.secondary"}})}),g.jsx(Cr,{sx:{backgroundColor:"rgba(255, 255, 255, 0.9)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"},width:"32px",height:"32px"},onClick:()=>y(!0),children:g.jsx(Fh,{sx:{fontSize:"18px",color:"text.secondary"}})})]})]})]})}const oTe=4;function aTe({resourceUri:e,maxResultSize:t=0,retrievalFn:n}){const{apiClients:r}=cr(),{environmentName:o,packageName:a,versionId:i,modelPath:l}=Kr(e),{data:u,isSuccess:d,isError:f,error:h}=bo({queryKey:[e],queryFn:async()=>(await r.notebooks.getNotebook(o,a,l,i)).data}),[y,b]=C.useState([]),[v,x]=C.useState(!1),[E,S]=C.useState(null),A=C.useMemo(()=>u?ECe(u.annotations):null,[u]),T=C.useMemo(()=>u?.notebookCells?wCe(u.notebookCells):null,[u]),M=C.useMemo(()=>T?.sourceInfoMap??new Map,[T]),D=T?.modelPath??null,R=C.useMemo(()=>{const V=new Map;if(!u?.sources)return V;for(const Y of u.sources)if(Y.name&&Y.filters&&Y.filters.length>0){const P=Y.filters.filter(q=>!q.implicit);P.length>0&&V.set(Y.name,P)}return V},[u]),F=R.size>0,B=C.useMemo(()=>{if(F&&D){const V=[];for(const[Y,P]of R)for(const q of P??[]){if(!q.dimension||!q.type)continue;let X;const H=q.dimensionType;H==="boolean"?X="Boolean":H==="date"||H==="timestamp"||H==="timestamptz"?X="DateMinMax":H==="number"?X=q.type==="equal"||q.type==="in"?"Star":"MinMax":X={equal:"Star",in:"Star",like:"Star",greater_than:"MinMax",less_than:"MinMax"}[q.type]??"Star";const re={equal:"Equals",in:"Equals",like:"Contains",greater_than:X==="DateMinMax"?"After":"Greater Than",less_than:X==="DateMinMax"?"Before":"Less Than"}[q.type],Z=q.name!==q.dimension?q.name:void 0;V.push({source:Y,model:D,dimensionName:q.dimension,filterType:X,label:Z,filterName:q.name??q.dimension,defaultMatchType:re,required:q.required??!1})}return V}return!A||M.size===0||!D?[]:kCe(M,A.filters,D)},[F,R,A,M,D]),{filterStates:z,updateFilter:j,getActiveFilters:U}=eTe({dimensionSpecs:B}),w=C.useMemo(()=>U(),[z,U]);C.useMemo(()=>{const V=new Map;for(const Y of B){const P=Pl(Y);V.set(P,Y.source)}return V},[B]);const{data:L}=ZCe({environment:o,package:a,dimensionSpecs:B,versionId:i,enabled:B.length>0}),I=C.useCallback(V=>{if(V.length===0)return;const Y=q=>q instanceof Date?q.toISOString().slice(0,10):String(q),P={};for(const q of V){const X=q.filterName??q.dimensionName,H=q.value;Array.isArray(H)?P[X]=H.map(Y):H!=null&&(P[X]=Y(H))}return Object.keys(P).length>0?JSON.stringify(P):void 0},[]),$=C.useCallback(async(V=[])=>{if(!d||!u?.notebookCells)return;b(P=>P.length===0?u.notebookCells.map(q=>({...q})):P.map(q=>({...q,result:void 0}))),x(!0),S(null);const Y=F?I(V):void 0;try{const P=[];for(let X=0;X<u.notebookCells.length;X++){const H=u.notebookCells[X];if(H.type==="markdown")continue;const re=X,Z=async()=>{try{const K=(await r.notebooks.executeNotebookCell(o,a,l,re,i,Y)).data,ne=K.result,ee=H.newSources||K.newSources;b(fe=>{const de=[...fe];return de[re]||(de[re]={...H}),de[re]={...de[re],result:ne,newSources:ee},de})}catch(K){console.error(`Error executing cell ${re}:`,K)}};P.push(Z)}const q=[];for(const X of P){const H=X().then(()=>{q.splice(q.indexOf(H),1)});q.push(H),q.length>=oTe&&await Promise.race(q)}await Promise.all(q)}catch(P){console.error("Error executing notebook cells:",P),S(P)}finally{x(!1)}},[d,u,F,I,o,a,l,i,r.notebooks]);C.useEffect(()=>{!d||!u?.notebookCells||$([])},[d,u,$]);const _=C.useRef("");C.useEffect(()=>{const V=JSON.stringify(w.map(Y=>({dim:Y.dimensionName,type:Y.matchType,val:Y.value,val2:Y.value2})));if(V!==_.current){if(_.current===""&&w.length===0){_.current=V;return}_.current=V,v||$(w)}},[w,v,$]);const G=C.useCallback(V=>Y=>{j(V,Y)},[j]);return B.some(V=>V.filterType==="Retrieval"),g.jsx(nne,{children:g.jsx(rne,{children:g.jsxs(lo,{spacing:3,component:"section",children:[B.length>0&&L&&g.jsxs(Ts,{elevation:0,sx:{p:3,backgroundColor:"transparent",border:"none",boxShadow:"none"},children:[g.jsx(ft,{variant:"subtitle2",sx:{fontWeight:600,mb:2,color:"#333"},children:"Filters"}),g.jsx(xt,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(250px, 1fr))",gap:3},children:B.map(V=>{const Y=Pl(V),P=L.get(Y)||[],q=z.get(Y);return V.filterType==="Retrieval"&&!n?null:g.jsx(xt,{children:g.jsx(SCe,{spec:V,values:P,selection:q?.selection,onChange:G(Y),retrievalFn:n})},Y)})})]}),!d&&!f&&g.jsx(ya,{text:"Fetching Notebook..."}),d&&(y.length>0?y:u?.notebookCells||[]).map((V,Y)=>g.jsx(rTe,{cell:V,index:Y,resourceUri:e,maxResultSize:t,isExecuting:v},Y)),f&&h.status===404&&g.jsxs(ft,{variant:"body2",sx:{color:"text.secondary"},children:[g.jsx("code",{children:`${o} > ${a} > ${l}`})," ","not found."]}),f&&h.status!==404&&g.jsx(ba,{error:h,context:`${o} > ${a} > ${l}`}),E&&g.jsx(ba,{error:{message:E.message,status:500,name:"ExecutionError"},context:"Notebook Execution"})]})})})}const iTe=fr(g.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}));function xS({type:e,size:t=18,sx:n,...r}){return g.jsxs(ib,{...r,viewBox:"0 0 24 24",sx:{width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",...n},children:[e==="report"&&g.jsx(sTe,{}),e==="model"&&g.jsx(lTe,{}),e==="data"&&g.jsx(cTe,{})]})}function sTe(){return g.jsxs(g.Fragment,{children:[g.jsx("path",{d:"M14 3 H6 a2 2 0 0 0 -2 2 v14 a2 2 0 0 0 2 2 h12 a2 2 0 0 0 2 -2 V9 z"}),g.jsx("path",{d:"M14 3 v4 a2 2 0 0 0 2 2 h4"}),g.jsx("path",{d:"M8 17 v-3"}),g.jsx("path",{d:"M12 17 v-6"}),g.jsx("path",{d:"M16 17 v-4"})]})}function lTe(){return g.jsxs(g.Fragment,{children:[g.jsx("path",{d:"M12 3 L4 7 v10 l8 4 l8 -4 V7 z"}),g.jsx("path",{d:"M4 7 l8 4 l8 -4"}),g.jsx("path",{d:"M12 11 v10"})]})}function cTe(){return g.jsxs(g.Fragment,{children:[g.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2"}),g.jsx("path",{d:"M3.5 9.5 H20.5"}),g.jsx("path",{d:"M9.5 3.5 V20.5"})]})}const UF=fr(g.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"})),Ss={postgres:[{label:"Host",name:"host",type:"text",required:!1},{label:"Port",name:"port",type:"number",required:!1},{label:"Database Name",name:"databaseName",type:"text",required:!1},{label:"User Name",name:"userName",type:"text",required:!1},{label:"Password",name:"password",type:"password",required:!1},{label:"Connection String",name:"connectionString",type:"text",required:!1}],bigquery:[{label:"Project ID",name:"defaultProjectId",type:"text",required:!1},{label:"Billing Project ID",name:"billingProjectId",type:"text",required:!1},{label:"Location",name:"location",type:"text",required:!1},{label:"Service Account Key JSON",name:"serviceAccountKeyJson",type:"text",required:!0},{label:"Maximum Bytes Billed",name:"maximumBytesBilled",type:"text",required:!1},{label:"Query Timeout Milliseconds",name:"queryTimeoutMilliseconds",type:"text",required:!1}],snowflake:[{label:"Account",name:"account",type:"text",required:!0},{label:"Username",name:"username",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Role",name:"role",type:"text",required:!1},{label:"Warehouse",name:"warehouse",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"Response Timeout Milliseconds",name:"responseTimeoutMilliseconds",type:"text",required:!1},{label:"Private Key",name:"privateKey",type:"password",required:!1},{label:"Private Key Passphrase",name:"privateKeyPass",type:"password",required:!1}],trino:[{label:"Server",name:"server",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!1},{label:"Catalog",name:"catalog",type:"text",required:!1},{label:"Schema",name:"schema",type:"text",required:!1},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!1},{label:"Peaka Key",name:"peakaKey",type:"password",required:!1}],databricks:[{label:"Host",name:"host",type:"text",required:!0},{label:"HTTP Path",name:"path",type:"text",required:!0},{label:"Access Token",name:"token",type:"password",required:!1},{label:"OAuth Client ID",name:"oauthClientId",type:"text",required:!1},{label:"OAuth Client Secret",name:"oauthClientSecret",type:"password",required:!1},{label:"Default Catalog",name:"defaultCatalog",type:"text",required:!1},{label:"Default Schema",name:"defaultSchema",type:"text",required:!1}],mysql:[{label:"Host",name:"host",type:"text",required:!0},{label:"Port",name:"port",type:"number",required:!0},{label:"User",name:"user",type:"text",required:!0},{label:"Password",name:"password",type:"password",required:!0},{label:"Database",name:"database",type:"text",required:!0}],duckdb:[],motherduck:[{label:"Access Token",name:"accessToken",type:"text",required:!0},{label:"Database",name:"database",type:"text",required:!1}],ducklake:[]},Ly={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",trino:"trinoConnection",databricks:"databricksConnection",mysql:"mysqlConnection",duckdb:"duckdbConnection",motherduck:"motherduckConnection",ducklake:"ducklakeConnection"},oC={postgres:"postgresConnection",bigquery:"bigqueryConnection",snowflake:"snowflakeConnection",gcs:"gcsConnection",s3:"s3Connection",azure:"azureConnection"},Bh=[{label:"Access Key ID",name:"accessKeyId",type:"text",required:!0},{label:"Secret Access Key",name:"secretAccessKey",type:"password",required:!0},{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}],jh=[{label:"Key ID",name:"keyId",type:"text",required:!0},{label:"Secret",name:"secret",type:"password",required:!0}],uTe=[{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 Db(e){return e==="postgres"||e==="bigquery"||e==="snowflake"?Ss[e]||[]:e==="s3"?Bh:e==="gcs"?jh:e==="azure"?uTe:[]}function dTe({onSubmit:e,isSubmitting:t}){const[n,r]=C.useState(!1),[o,a]=C.useState("postgres"),[i,l]=C.useState([]),[u,d]=C.useState("postgres"),[f,h]=C.useState("s3"),y=()=>{r(!0)},b=()=>{r(!1),l([]),a("postgres"),d("postgres"),h("s3")},v=async A=>{A.preventDefault();const T=new FormData(A.currentTarget),M=T.get("name")?.toString(),D=T.get("type")?.toString(),R=Ss[D];if(!M)throw new Error("Name is required");if(!D)throw new Error("Type is required");let F;if(D==="ducklake"){const B={};if(u==="postgres"){const U=Ss.postgres,w={};if(U.forEach(L=>{const I=T.get(`ducklake_pg_${L.name}`)?.toString();I&&(w[L.name]=I)}),Object.keys(w).length===0)throw new Error("DuckLake requires catalog connection");B.postgresConnection=w}const z=T.get("ducklake_bucketUrl")?.toString();if(!z)throw new Error("DuckLake requires a bucket URL");const j={bucketUrl:z};if(f==="s3"){const U={};if(Bh.forEach(w=>{const L=T.get(`ducklake_s3_${w.name}`)?.toString();L&&(U[w.name]=L)}),!U.accessKeyId)throw new Error("S3 Access Key ID is required");if(!U.secretAccessKey)throw new Error("S3 Secret Access Key is required");Object.keys(U).length>0&&(j.s3Connection=U)}else if(f==="gcs"){const U={};if(jh.forEach(w=>{const L=T.get(`ducklake_gcs_${w.name}`)?.toString();L&&(U[w.name]=L)}),!U.keyId)throw new Error("GCS Key ID is required");if(!U.secret)throw new Error("GCS Secret is required");Object.keys(U).length>0&&(j.gcsConnection=U)}F={name:M,type:D,ducklakeConnection:{catalog:B,storage:j}}}else if(D==="duckdb"){if(i.length===0)throw new Error("DuckDB connection must have at least one attached database");const B=i.map((z,j)=>{const U=z.dbType,w=T.get(`attachedDb_${j}_name`)?.toString();if(!w)throw new Error(`Attached database at index ${j} must have a name`);const L={name:w,type:U},I=Db(U);if(I&&I.length>0){const $={};I.forEach(G=>{const V=T.get(`attachedDb_${j}_${G.name}`)?.toString();V&&($[G.name]=V)});const _=oC[U];_&&(L[_]=$)}return L});F={name:M,type:D,duckdbConnection:{attachedDatabases:B}}}else{const B={};if(R.forEach(z=>{const j=T.get(z.name)?.toString();j&&(B[z.name]=j)}),D==="postgres"){if(!B.connectionString?.trim()){const z=["host","port","databaseName","userName","password"];for(const j of z)if(!B[j])throw new Error(`${R.find(U=>U.name===j)?.label||j} is required`)}}else if(D==="bigquery"){if(!B.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(D==="snowflake"){if(!B.account)throw new Error("Account is required");if(!B.username)throw new Error("Username is required");if(!B.warehouse)throw new Error("Warehouse is required");if(!B.password&&!B.privateKey)throw new Error("Either password or private key is required")}else if(D==="trino"){if(!B.server)throw new Error("Server is required");if(!B.user)throw new Error("User is required");if(B.server.trim().startsWith("https://")&&!B.password&&!B.peakaKey)throw new Error("Password is required for HTTPS connections (or use Peaka Key)")}else if(D==="mysql"){const z=["host","port","database","user","password"];for(const j of z)if(!B[j])throw new Error(`${R.find(U=>U.name===j)?.label||j} is required`)}else if(D==="motherduck"){if(!B.accessToken)throw new Error("Access Token is required")}else if(D==="databricks"){if(!B.host)throw new Error("Host is required");if(!B.path)throw new Error("HTTP Path is required");const z=B.oauthClientId&&B.oauthClientSecret;if(!B.token&&!z)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}F={name:M,type:D,[Ly[D]]:B}}await e(F),b()},x=()=>{l([...i,{name:"",dbType:"postgres"}])},E=A=>{l(i.filter((T,M)=>M!==A))},S=(A,T)=>{const M=[...i];M[A]={...M[A],dbType:T},l(M)};return g.jsxs(tt.Fragment,{children:[g.jsx(Tr,{variant:"outlined",onClick:y,children:"Add Connection"}),g.jsxs(Bs,{open:n,onClose:b,children:[g.jsx($l,{children:"Create New Connection"}),g.jsxs(js,{children:[g.jsx(fm,{children:"Add a new connection to query your data database using Malloy."}),g.jsxs("form",{onSubmit:v,id:"connection-form",children:[g.jsx(mn,{autoFocus:!0,required:!0,margin:"dense",id:"name",name:"name",label:"Connection Name",type:"text",fullWidth:!0,variant:"standard"}),g.jsx(mn,{margin:"dense",id:"type",name:"type",label:"Connection Type",fullWidth:!0,variant:"standard",value:o,select:!0,onChange:A=>a(A.target.value),children:Object.values(d3).map(A=>g.jsx(mo,{value:A,children:A},A))}),o==="ducklake"?g.jsxs(dr,{sx:{mt:2},children:[g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsx(Jn,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),g.jsx(mn,{margin:"dense",id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,variant:"standard",value:u,select:!0,onChange:A=>d(A.target.value),children:g.jsx(mo,{value:"postgres",children:"PostgreSQL"})}),u==="postgres"&&g.jsx(g.Fragment,{children:Ss.postgres.map(A=>g.jsx(mn,{margin:"dense",id:`ducklake_pg_${A.name}`,name:`ducklake_pg_${A.name}`,label:A.label,type:A.type,fullWidth:!0,variant:"standard"},`pg_${A.name}`))})]}),g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsx(Jn,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),g.jsxs(mn,{margin:"dense",id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,variant:"standard",value:f,select:!0,onChange:A=>h(A.target.value),children:[g.jsx(mo,{value:"s3",children:"S3"}),g.jsx(mo,{value:"gcs",children:"GCS"})]}),g.jsx(mn,{margin:"dense",required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:f==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,variant:"standard"}),f==="s3"&&g.jsxs(g.Fragment,{children:[g.jsx(Jn,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Bh.map(A=>g.jsx(mn,{margin:"dense",id:`ducklake_s3_${A.name}`,name:`ducklake_s3_${A.name}`,label:A.label,type:A.type,fullWidth:!0,variant:"standard",required:A.required,placeholder:A.name==="region"?"us-east-1":void 0},`s3_${A.name}`))]}),f==="gcs"&&g.jsxs(g.Fragment,{children:[g.jsx(Jn,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),jh.map(A=>g.jsx(mn,{margin:"dense",id:`ducklake_gcs_${A.name}`,name:`ducklake_gcs_${A.name}`,label:A.label,type:A.type,fullWidth:!0,variant:"standard",required:A.required},`gcs_${A.name}`))]})]})]}):o==="duckdb"?g.jsxs(dr,{sx:{mt:2},children:[g.jsxs(dr,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[g.jsx(Jn,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),g.jsx(Tr,{startIcon:g.jsx(DT,{}),onClick:x,size:"small",variant:"outlined",children:"Add Database"})]}),i.length===0&&g.jsx(Jn,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),i.map((A,T)=>{const M=Db(A.dbType);return g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsxs(dr,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[g.jsxs(Jn,{variant:"subtitle2",children:["Database ",T+1]}),g.jsx(va,{onClick:()=>E(T),size:"small",color:"error",children:g.jsx(UF,{fontSize:"small"})})]}),g.jsx(mn,{margin:"dense",required:!0,id:`attachedDb_${T}_name`,name:`attachedDb_${T}_name`,label:"Database Name",type:"text",fullWidth:!0,variant:"standard",defaultValue:A.name}),g.jsx(mn,{margin:"dense",id:`attachedDb_${T}_type`,name:`attachedDb_${T}_type`,label:"Database Type",fullWidth:!0,variant:"standard",value:A.dbType,select:!0,onChange:D=>S(T,D.target.value),children:Object.values(u3).map(D=>g.jsx(mo,{value:D,children:D},D))}),M.filter(D=>D.visibleWhen?(A[D.visibleWhen.field]||M.find(R=>R.name===D.visibleWhen?.field)?.selectOptions?.[0]?.value)===D.visibleWhen.value:!0).map(D=>g.jsx(mn,{margin:"dense",id:`attachedDb_${T}_${D.name}`,name:`attachedDb_${T}_${D.name}`,label:D.label,type:D.selectOptions?void 0:D.type,fullWidth:!0,variant:"standard",required:D.required,select:!!D.selectOptions,defaultValue:D.selectOptions?.[0]?.value,onChange:D.selectOptions?R=>{const F=[...i];F[T]={...F[T],[D.name]:R.target.value},l(F)}:void 0,children:D.selectOptions?.map(R=>g.jsx(mo,{value:R.value,children:R.label},R.value))},D.name))]},T)})]}):Ss[o].map(A=>g.jsx(mn,{margin:"dense",id:A.name,name:A.name,label:A.label,type:A.type,fullWidth:!0,variant:"standard",required:A.required},A.name))]})]}),g.jsxs($s,{children:[g.jsx(Tr,{disabled:t,onClick:b,children:"Cancel"}),g.jsx(Tr,{type:"submit",form:"connection-form",loading:t,children:"Create Connection"})]})]})]})}function fTe({connection:e,onCloseDialog:t,isMutating:n,onDelete:r}){const[o,a]=C.useState(!1),[i,l]=C.useState(""),u=()=>{a(!0)},d=()=>{a(!1),t()};return g.jsxs(tt.Fragment,{children:[g.jsx(va,{"aria-label":`Delete connection ${e?.name??""}`.trim(),onClick:f=>{f.stopPropagation(),u()},children:g.jsx(vT,{})}),g.jsxs(Bs,{onClose:d,"aria-labelledby":"customized-dialog-title",open:o,children:[g.jsx($l,{sx:{m:0,p:2},id:"customized-dialog-title",children:"Delete Connection"}),g.jsx(va,{"aria-label":"close",onClick:d,sx:f=>({position:"absolute",right:8,top:8,color:f.palette.grey[500]}),children:g.jsx(Ns,{})}),g.jsx(js,{dividers:!0,children:g.jsxs(Jn,{gutterBottom:!0,children:['Are you sure you want to delete "',e.name,'"? This action cannot be undone.']})}),g.jsx($s,{children:g.jsx(Tr,{loading:n,variant:"contained",autoFocus:!0,onClick:()=>r(),color:"error",children:"Delete"})}),g.jsx(_s,{open:i!=="",autoHideDuration:6e3,onClose:()=>l(""),message:i})]})]})}function DI(e){const t=e.duckdbConnection?.attachedDatabases;return!t||t.length===0?[]:t.map(n=>({name:n.name||"",dbType:n.type||"postgres"}))}function RI(e){const t=e.ducklakeConnection;return t&&t.storage?.gcsConnection?"gcs":"s3"}function pTe({connection:e,onSubmit:t,isSubmitting:n}){const[r,o]=C.useState(!1),[a,i]=C.useState(e.type),[l,u]=C.useState(()=>DI(e)),[d,f]=C.useState("postgres"),[h,y]=C.useState(()=>RI(e)),b=()=>{u(DI(e)),i(e.type),f("postgres"),y(RI(e)),o(!0)},v=()=>{o(!1)},x=async D=>{D.preventDefault();const R=new FormData(D.currentTarget),F=R.get("name")?.toString(),B=R.get("type")?.toString(),z=Ss[B];if(!F)throw new Error("Name is required");if(!B)throw new Error("Type is required");let j;if(B==="ducklake"){const U={};if(d==="postgres"){const I=Ss.postgres,$={};if(I.forEach(_=>{const G=R.get(`ducklake_pg_${_.name}`)?.toString();G&&($[_.name]=G)}),Object.keys($).length===0)throw new Error("DuckLake requires catalog connection");U.postgresConnection=$}const w=R.get("ducklake_bucketUrl")?.toString();if(!w)throw new Error("DuckLake requires a bucket URL");const L={bucketUrl:w};if(h==="s3"){const I={};Bh.forEach(_=>{const G=R.get(`ducklake_s3_${_.name}`)?.toString();G&&(I[_.name]=G)});const $=e.ducklakeConnection?.storage?.s3Connection;if($&&(!I.accessKeyId&&$.accessKeyId&&(I.accessKeyId=$.accessKeyId),!I.secretAccessKey&&$.secretAccessKey&&(I.secretAccessKey=$.secretAccessKey)),!I.accessKeyId)throw new Error("S3 Access Key ID is required");if(!I.secretAccessKey)throw new Error("S3 Secret Access Key is required");Object.keys(I).length>0&&(L.s3Connection=I)}else if(h==="gcs"){const I={};jh.forEach(_=>{const G=R.get(`ducklake_gcs_${_.name}`)?.toString();G&&(I[_.name]=G)});const $=e.ducklakeConnection?.storage?.gcsConnection;if($&&(!I.keyId&&$.keyId&&(I.keyId=$.keyId),!I.secret&&$.secret&&(I.secret=$.secret)),!I.keyId)throw new Error("GCS Key ID is required");if(!I.secret)throw new Error("GCS Secret is required");Object.keys(I).length>0&&(L.gcsConnection=I)}j={name:F,type:B,ducklakeConnection:{catalog:U,storage:L}}}else if(B==="duckdb"){if(l.length===0)throw new Error("DuckDB connection must have at least one attached database");const U=l.map((w,L)=>{const I=w.dbType,$=R.get(`attachedDb_${L}_name`)?.toString();if(!$)throw new Error(`Attached database at index ${L} must have a name`);const _={name:$,type:I},G=Db(I);if(G&&G.length>0){const V={};G.forEach(P=>{const q=R.get(`attachedDb_${L}_${P.name}`)?.toString();q&&(V[P.name]=q)});const Y=oC[I];Y&&(_[Y]=V)}return _});j={name:F,type:B,duckdbConnection:{attachedDatabases:U}}}else{const U=e[Ly[B]]||{},w={};if(z.forEach(L=>{const I=R.get(L.name)?.toString(),$=U[L.name],_=L.type==="password"||L.name==="password"||L.name==="secretAccessKey"||L.name==="secret"||L.name==="accessToken"||L.name==="privateKey";I?w[L.name]=I:_&&$?w[L.name]=$:I!==void 0?w[L.name]=I:$&&(w[L.name]=$)}),B==="postgres"){if(!w.connectionString?.trim()){const L=["host","port","databaseName","userName","password"];for(const I of L)if(!w[I])throw new Error(`${z.find($=>$.name===I)?.label||I} is required`)}}else if(B==="bigquery"){if(!w.serviceAccountKeyJson)throw new Error("Service Account Key JSON is required")}else if(B==="snowflake"){if(!w.account)throw new Error("Account is required");if(!w.username)throw new Error("Username is required");if(!w.warehouse)throw new Error("Warehouse is required");if(!w.password&&!w.privateKey)throw new Error("Either password or private key is required")}else if(B==="trino"){if(!w.server)throw new Error("Server is required");if(!w.user)throw new Error("User is required");if(w.server.trim().startsWith("https://")&&!w.password&&!w.peakaKey)throw new Error("Password is required for HTTPS connections (or use Peaka Key)")}else if(B==="mysql"){const L=["host","port","database","user","password"];for(const I of L)if(!w[I])throw new Error(`${z.find($=>$.name===I)?.label||I} is required`)}else if(B==="motherduck"){if(!w.accessToken)throw new Error("Access Token is required")}else if(B==="databricks"){if(!w.host)throw new Error("Host is required");if(!w.path)throw new Error("HTTP Path is required");const L=w.oauthClientId&&w.oauthClientSecret;if(!w.token&&!L)throw new Error("Either Access Token or OAuth Client ID + Secret is required")}j={name:F,type:B,[Ly[B]]:w}}await t(j),v()},E=()=>{u([...l,{name:"",dbType:"postgres"}])},S=D=>{u(l.filter((R,F)=>F!==D))},A=(D,R)=>{const F=[...l];F[D]={...F[D],dbType:R},u(F)},T=(D,R)=>{const F=e.duckdbConnection?.attachedDatabases;if(!F||!F[D])return"";const B=F[D],z=oC[B.type||""];return z&&B[z]?B[z][R]??"":""},M=D=>{const R=e.ducklakeConnection;if(!R)return"";if(D.startsWith("pg_")){const F=D.replace("pg_","");return R.catalog?.postgresConnection?.[F]??""}if(D==="bucketUrl")return R.storage?.bucketUrl??"";if(D.startsWith("s3_")){const F=D.replace("s3_","");return R.storage?.s3Connection?.[F]??""}if(D.startsWith("gcs_")){const F=D.replace("gcs_","");return R.storage?.gcsConnection?.[F]??""}return""};return g.jsxs(tt.Fragment,{children:[g.jsx(va,{"aria-label":`Edit connection ${e?.name??""}`.trim(),onClick:D=>{D.preventDefault(),D.stopPropagation(),b()},children:g.jsx(xT,{})}),g.jsxs(Bs,{open:r,onClose:v,children:[g.jsx($l,{onClick:D=>{D.stopPropagation()},children:"Edit Connection"}),g.jsxs(js,{onClick:D=>{D.stopPropagation()},children:[g.jsx(fm,{children:"Edit a connection to query your data database using Malloy."}),g.jsxs("form",{onSubmit:x,id:"connection-form",children:[g.jsx(mn,{autoFocus:!0,required:!0,margin:"dense",id:"name",name:"name",label:"Connection Name",type:"text",fullWidth:!0,variant:"standard",defaultValue:e.name}),g.jsx(mn,{margin:"dense",id:"type",name:"type",label:"Connection Type",fullWidth:!0,variant:"standard",value:a,select:!0,onChange:D=>i(D.target.value),children:Object.values(d3).map(D=>g.jsx(mo,{value:D,children:D},D))}),a==="ducklake"?g.jsxs(dr,{sx:{mt:2},children:[g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsx(Jn,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Catalog"}),g.jsx(mn,{margin:"dense",id:"ducklake_catalogType",label:"Catalog Type",fullWidth:!0,variant:"standard",value:d,select:!0,onChange:D=>f(D.target.value),children:g.jsx(mo,{value:"postgres",children:"PostgreSQL"})}),d==="postgres"&&g.jsx(g.Fragment,{children:Ss.postgres.map(D=>g.jsx(mn,{margin:"dense",id:`ducklake_pg_${D.name}`,name:`ducklake_pg_${D.name}`,label:D.label,type:D.type,fullWidth:!0,variant:"standard",defaultValue:M(`pg_${D.name}`)},`pg_${D.name}`))})]}),g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsx(Jn,{variant:"subtitle2",sx:{mb:2},fontWeight:500,children:"Storage"}),g.jsxs(mn,{margin:"dense",id:"ducklake_storageType",label:"Storage Type",fullWidth:!0,variant:"standard",value:h,select:!0,onChange:D=>y(D.target.value),children:[g.jsx(mo,{value:"s3",children:"S3"}),g.jsx(mo,{value:"gcs",children:"GCS"})]}),g.jsx(mn,{margin:"dense",required:!0,id:"ducklake_bucketUrl",name:"ducklake_bucketUrl",label:h==="s3"?"Bucket URL (e.g. s3://my-bucket/path)":"Bucket URL (e.g. gs://my-bucket/path)",type:"text",fullWidth:!0,variant:"standard",defaultValue:M("bucketUrl")}),h==="s3"&&g.jsxs(g.Fragment,{children:[g.jsx(Jn,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"S3 Credentials"}),Bh.map(D=>g.jsx(mn,{margin:"dense",id:`ducklake_s3_${D.name}`,name:`ducklake_s3_${D.name}`,label:D.label,type:D.type,fullWidth:!0,variant:"standard",required:D.required&&D.name!=="secretAccessKey",defaultValue:M(`s3_${D.name}`),placeholder:D.name==="region"?"us-east-1":D.name==="secretAccessKey"?"Leave empty to keep existing":void 0},`s3_${D.name}`))]}),h==="gcs"&&g.jsxs(g.Fragment,{children:[g.jsx(Jn,{variant:"caption",sx:{mt:2,mb:1,display:"block"},color:"text.secondary",children:"GCS Credentials"}),jh.map(D=>g.jsx(mn,{margin:"dense",id:`ducklake_gcs_${D.name}`,name:`ducklake_gcs_${D.name}`,label:D.label,type:D.type,fullWidth:!0,variant:"standard",required:D.required&&D.name!=="secret",defaultValue:M(`gcs_${D.name}`),placeholder:D.name==="secret"?"Leave empty to keep existing":void 0},`gcs_${D.name}`))]})]})]}):a==="duckdb"?g.jsxs(dr,{sx:{mt:2},children:[g.jsxs(dr,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[g.jsx(Jn,{variant:"subtitle1",fontWeight:500,children:"Attached Databases"}),g.jsx(Tr,{startIcon:g.jsx(DT,{}),onClick:E,size:"small",variant:"outlined",children:"Add Database"})]}),l.length===0&&g.jsx(Jn,{variant:"body2",color:"text.secondary",sx:{mb:2},children:'DuckDB connections require at least one attached database. Click "Add Database" to get started.'}),l.map((D,R)=>{const F=Db(D.dbType);return g.jsxs(dr,{sx:{mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[g.jsxs(dr,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[g.jsxs(Jn,{variant:"subtitle2",children:["Database ",R+1]}),g.jsx(va,{"aria-label":`Remove attached database ${R+1}`,onClick:()=>S(R),size:"small",color:"error",children:g.jsx(UF,{fontSize:"small"})})]}),g.jsx(mn,{margin:"dense",required:!0,id:`attachedDb_${R}_name`,name:`attachedDb_${R}_name`,label:"Database Name",type:"text",fullWidth:!0,variant:"standard",defaultValue:D.name}),g.jsx(mn,{margin:"dense",id:`attachedDb_${R}_type`,name:`attachedDb_${R}_type`,label:"Database Type",fullWidth:!0,variant:"standard",value:D.dbType,select:!0,onChange:B=>A(R,B.target.value),children:Object.values(u3).map(B=>g.jsx(mo,{value:B,children:B},B))}),F.filter(B=>B.visibleWhen?(D[B.visibleWhen.field]||T(R,B.visibleWhen.field)||F.find(z=>z.name===B.visibleWhen?.field)?.selectOptions?.[0]?.value)===B.visibleWhen.value:!0).map(B=>g.jsx(mn,{margin:"dense",id:`attachedDb_${R}_${B.name}`,name:`attachedDb_${R}_${B.name}`,label:B.label,type:B.selectOptions?void 0:B.type,fullWidth:!0,variant:"standard",required:B.required,select:!!B.selectOptions,defaultValue:T(R,B.name)||B.selectOptions?.[0]?.value,onChange:B.selectOptions?z=>{const j=[...l];j[R]={...j[R],[B.name]:z.target.value},u(j)}:void 0,children:B.selectOptions?.map(z=>g.jsx(mo,{value:z.value,children:z.label},z.value))},B.name))]},R)})]}):Ss[a].map(D=>{const R=e?.[Ly[a]??""]?.[D.name??""]??"",F=D.type==="password"||D.name==="password"||D.name==="secretAccessKey"||D.name==="secret"||D.name==="accessToken"||D.name==="privateKey";return g.jsx(mn,{margin:"dense",id:D.name,name:D.name,label:D.label,type:D.type,fullWidth:!0,variant:"standard",required:D.required&&!F&&!R,defaultValue:R,placeholder:F&&R?"Leave empty to keep existing":void 0},D.name)})]})]}),g.jsxs($s,{onClick:D=>{D.stopPropagation()},children:[g.jsx(Tr,{disabled:n,onClick:v,children:"Cancel"}),g.jsx(Tr,{type:"submit",form:"connection-form",loading:n,children:"Edit Connection"})]})]})]})}function MI(e,t){return!e||e.type!=="duckdb"?!1:(e.duckdbConnection?.attachedDatabases||[]).some(n=>n.type==="azure"&&n.name===t)}function hTe(e){return e.startsWith("gs://")||e.startsWith("s3://")||e.startsWith("https://")||e.startsWith("abfss://")||e.startsWith("az://")}function mTe({connectionName:e,resourceUri:t,schema:n,connection:r}){const{apiClients:o}=cr(),{environmentName:a}=Kr(t),[i,l]=tt.useState(null),[u,d]=tt.useState(n||null),[f,h]=tt.useState(!1),{data:y,isError:b,isLoading:v,error:x}=bo({queryKey:["schemas",a,e],queryFn:()=>o.connections.listSchemas(a,e)}),E=y?.data||[];return g.jsxs(Fi,{container:!0,spacing:1,children:[!n&&g.jsx(Fi,{size:{xs:12,md:4},children:g.jsxs(Ts,{sx:{p:1,m:0},children:[g.jsxs(xt,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:0},children:[g.jsx(ft,{variant:"overline",fontWeight:"bold",children:"Table Paths"}),g.jsx(TG,{control:g.jsx(pK,{checked:f,onChange:S=>h(S.target.checked)}),label:"Hidden Schemas"})]}),g.jsx(Wi,{sx:{mt:"2px"}}),g.jsxs(xt,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[v&&g.jsx(ya,{text:"Loading schemas..."}),b&&g.jsx(ba,{error:x,context:`${a} > ${e} > Schemas`}),!v&&!b&&E.length===0&&g.jsx(ft,{variant:"body2",children:"No Schemas"}),!v&&!b&&E.length>0&&g.jsx(rT,{dense:!0,disablePadding:!0,children:E.map(S=>{const A=S.name;return S.isHidden&&!f?null:g.jsx(x5,{selected:u===A,onClick:()=>{d(A),l(null)},children:g.jsx(Wd,{primary:A})},A)})})]})]})}),g.jsx(Fi,{size:{xs:12,md:n?6:4},children:u&&g.jsx(Ts,{sx:{p:1,m:0},children:g.jsx(bTe,{connectionName:e,schemaName:u,onTableSelect:S=>{l(S)},resourceUri:t,connection:r})})}),g.jsx(Fi,{size:{xs:12,md:n?6:4},children:u&&i&&g.jsx(gTe,{environmentName:a,connectionName:e,schemaName:u,tableResource:i})})]})}function gTe({environmentName:e,connectionName:t,schemaName:n,tableResource:r}){const{apiClients:o}=cr(),{data:a,isLoading:i,isError:l,error:u}=bo({queryKey:["connectionTableDetail",e,t,n,r],queryFn:()=>o.connections.getTable(e,t,n,r),enabled:!!n&&!!r}),d={resource:a?.data?.resource??r,columns:a?.data?.columns??[]};return g.jsxs(Ts,{sx:{p:1,m:0},children:[l&&g.jsx(ba,{error:u,context:`${e} > ${t} > ${n} > ${r}`}),!l&&g.jsx(yTe,{table:d,loading:i})]})}function yTe({table:e,loading:t}){return t?g.jsx(ya,{text:"Loading columns..."}):g.jsxs(g.Fragment,{children:[g.jsxs(ft,{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]}),g.jsx(Wi,{}),g.jsx(xt,{sx:{mt:"10px",maxHeight:"600px",overflowY:"auto"},children:g.jsx(DK,{children:g.jsxs(sT,{size:"small",sx:{"& .MuiTableCell-root":{padding:"10px"}},children:[g.jsx(D5,{children:g.jsxs(Ad,{children:[g.jsx(zo,{children:"NAME"}),g.jsx(zo,{children:"TYPE"})]})}),g.jsx(lT,{children:e.columns?.sort((n,r)=>n.name.localeCompare(r.name))?.map(n=>g.jsxs(Ad,{children:[g.jsx(zo,{children:n.name}),g.jsx(zo,{children:n.type})]},n.name))})]})})})]})}function bTe({connectionName:e,schemaName:t,onTableSelect:n,resourceUri:r,connection:o}){const{environmentName:a}=Kr(r),{apiClients:i}=cr(),[l,u]=C.useState(""),{data:d,isSuccess:f,isError:h,error:y,isLoading:b}=bo({queryKey:["tablesInSchema",a,e,t],queryFn:()=>i.connections.listTables(a,e,t)}),v=MI(o,t),x=S=>v?S:S.split(".").pop()||S,E=f&&d?.data?d.data.filter(S=>x(S.resource).toLowerCase().includes(l.toLowerCase())).sort((S,A)=>x(S.resource).localeCompare(x(A.resource))):[];return g.jsxs(g.Fragment,{children:[g.jsx(ft,{variant:"overline",fontWeight:"bold",children:hTe(t)||MI(o,t)?`Files in ${t}`:`Tables in ${t}`}),g.jsx(Wi,{}),g.jsx(xt,{sx:{mt:1,mb:1},children:g.jsx(by,{size:"small",fullWidth:!0,placeholder:"Search tables...",value:l,onChange:S=>u(S.target.value),variant:"outlined"})}),g.jsx(Wi,{}),g.jsxs(xt,{sx:{mt:"2px",maxHeight:"600px",overflowY:"auto"},children:[b&&g.jsx(ya,{text:"Fetching Tables..."}),h&&g.jsx(ba,{error:y,context:`${a} > ${e} > ${t}`}),f&&E.length===0&&g.jsx(ft,{variant:"body2",children:"No Tables"}),f&&d?.data&&d.data.length>0&&g.jsx(rT,{dense:!0,disablePadding:!0,children:E.map(S=>{let A=x(S.resource);return!v&&S.resource.includes("://")&&(A=S.resource.split("/").pop()||S.resource),g.jsx(x5,{onClick:()=>n(S.resource),children:g.jsx(Wd,{primary:A,secondary:S.columns.length>0?`${S.columns.length} columns`:void 0})},S.resource)})})]})]})}function vTe({connection:e,onClick:t,onEdit:n,onDelete:r,isMutating:o,mutable:a,isAdding:i}){return g.jsxs(Ad,{sx:{"&:hover":{backgroundColor:i?void 0:"action.hover"}},children:[g.jsx(zo,{sx:{cursor:i?"default":"pointer",flexGrow:1,opacity:i?.5:1},onClick:i?void 0:t,children:g.jsxs(xt,{sx:{display:"flex",alignItems:"center",gap:1},children:[g.jsx(ft,{variant:"body2",children:e.name}),g.jsx(Fh,{sx:{fontSize:"1rem",color:"action.active",opacity:.7}})]})}),g.jsx(zo,{sx:{minWidth:"120px"},children:g.jsx(ft,{variant:"body2",children:e.type})}),a&&g.jsxs(zo,{sx:{minWidth:"120px"},children:[g.jsx(pTe,{connection:e,onSubmit:n,isSubmitting:o}),g.jsx(fTe,{connection:e,onCloseDialog:()=>{},isMutating:o,onDelete:()=>r(e)})]})]},e.name)}function xTe({resourceUri:e}){const{apiClients:t,mutable:n}=cr(),r=Ls(),{environmentName:o}=Kr(e),[a,i]=C.useState(""),[l,u]=C.useState(null),d=cw({environmentName:o,connectionName:l}),{data:f,isSuccess:h,isError:y,error:b}=bo({queryKey:["connections",o],queryFn:()=>t.connections.listConnections(o)}),v=T=>{u(T)},x=()=>{u(null)},E=zi({mutationFn:T=>t.environments.updateEnvironment(o,{name:o,connections:[...f.data,T]}),onSuccess(){i("Connection added successfully"),r.invalidateQueries({queryKey:["connections",o]})},onError(T){i(T.message)}}),S=zi({mutationFn:T=>t.environments.updateEnvironment(o,{name:o,connections:f.data.map(M=>M.name===T.name?T:M)}),onSuccess(T,M){i(`Connection ${M.name} updated successfully`),r.invalidateQueries({queryKey:["connections",o]})},onError(T){i(T.message)}}),A=zi({mutationFn:T=>t.environments.updateEnvironment(o,{name:o,connections:f.data.filter(M=>M.name!==T.name)}),onSuccess(T,M){i(`Connection ${M.name} deleted successfully`),r.invalidateQueries({queryKey:["connections",o]})},onError(T){i(T.message)}});return g.jsxs(g.Fragment,{children:[g.jsx(z3,{children:g.jsxs(H3,{children:[g.jsx(V3,{children:"Database Connections"}),g.jsxs(xt,{sx:{mb:1,maxHeight:"200px",overflowY:"auto"},children:[!h&&!y&&g.jsx(ft,{variant:"body2",sx:{m:"auto"},children:"Fetching Connections..."}),h&&f.data.length>0&&g.jsx(sT,{size:"small",sx:{borderCollapse:"collapse","& .MuiTableRow-root":{display:"flex",width:"100%"},"& .MuiTableCell-root":{borderBottom:"1px solid #e0e0e0",display:"flex",alignItems:"center"},"& .MuiTableRow-root:last-child .MuiTableCell-root":{borderBottom:"none"}},children:g.jsxs(lT,{children:[g.jsxs(Ad,{children:[g.jsx(zo,{sx:{flexGrow:1},children:g.jsx(ft,{variant:"body2",fontWeight:"500",color:"text.secondary",children:"Connection Name"})}),g.jsx(zo,{sx:{minWidth:"120px"},children:g.jsx(ft,{variant:"body2",fontWeight:"500",color:"text.secondary",children:"Type"})}),n&&g.jsx(zo,{sx:{minWidth:"120px"},children:g.jsx(ft,{variant:"body2",fontWeight:"500",color:"text.secondary",sx:{mx:"auto"},children:"Actions"})})]}),f.data.map(T=>g.jsx(vTe,{connection:T,onClick:()=>v(T.name),onEdit:M=>S.mutateAsync(M),onDelete:M=>{T.resource?i("Cannot delete this connection"):A.mutateAsync(M)},isMutating:E.isPending||S.isPending||A.isPending,mutable:n,isAdding:E.isPending},T.name))]})}),h&&f.data.length===0&&g.jsx(ft,{variant:"body2",children:"No Connections"}),y&&g.jsx(ba,{error:b,context:`${o} > Connections`})]}),n&&g.jsx(xt,{sx:{display:"flex",justifyContent:"flex-end"},children:g.jsx(dTe,{onSubmit:T=>E.mutateAsync(T),isSubmitting:E.isPending})})]})}),g.jsx(_s,{open:a!=="",autoHideDuration:6e3,onClose:()=>i(""),message:a}),g.jsxs(ks,{open:l!==null,onClose:x,maxWidth:"lg",fullWidth:!0,children:[g.jsxs(Ds,{children:["Connection Explorer: ",l,g.jsx(Cr,{"aria-label":"close",onClick:x,sx:{position:"absolute",right:8,top:8},children:g.jsx(xt,{sx:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:"X"})})]}),g.jsx(As,{children:l&&g.jsx(mTe,{resourceUri:d,connectionName:l,connection:f?.data?.find(T=>T.name===l)})})]})]})}const OI="README.malloynb";function xwe({onClickPackageFile:e,resourceUri:t,retrievalFn:n}){const{apiClients:r}=cr(),o=e??(D=>{window.location.href=D}),{environmentName:a,packageName:i,versionId:l}=Kr(t),[u,d]=C.useState(null),f=bo({queryKey:["package",a,i,l],queryFn:()=>r.packages.getPackage(a,i,l,!1)}),h=bo({queryKey:["notebooks",a,i,l],queryFn:()=>r.notebooks.listNotebooks(a,i,l)}),y=bo({queryKey:["models",a,i,l],queryFn:()=>r.models.listModels(a,i,l)}),b=bo({queryKey:["databases",a,i,l],queryFn:()=>r.databases.listDatabases(a,i,l)}),v=(h.data?.data??[]).slice().sort((D,R)=>D.path.localeCompare(R.path)),x=(y.data?.data??[]).slice().sort((D,R)=>D.path.localeCompare(R.path)),E=(b.data?.data??[]).slice().sort((D,R)=>D.path.localeCompare(R.path)),S=f.data?.data?.description??"",A=v.some(D=>D.path===OI),T=cw({environmentName:a,packageName:i,versionId:l,modelPath:OI}),M=!h.isSuccess&&!h.isError;return f.isError?g.jsx(ba,{error:f.error,context:`${a} > ${i}`}):g.jsxs(JC,{maxWidth:!1,sx:{maxWidth:1024,mx:"auto",px:3,py:6},children:[g.jsxs(xt,{sx:{mb:4},children:[g.jsxs(GG,{onClick:D=>o(`/${a}/`,D),underline:"none",sx:{display:"inline-flex",alignItems:"center",gap:.5,cursor:"pointer",color:"text.secondary",fontSize:"0.875rem",mb:2,"&:hover":{color:"primary.main"}},children:[g.jsx(iTe,{sx:{fontSize:18}}),"Back to ",a]}),g.jsx(ft,{variant:"h4",component:"h1",sx:{fontWeight:600,letterSpacing:"-0.025em",mb:.5},children:i}),S&&g.jsx(ft,{variant:"body2",color:"text.secondary",children:S})]}),M&&g.jsx(ya,{text:"Loading package..."}),!M&&g.jsxs(g.Fragment,{children:[g.jsxs(SS,{title:"Governed Reports",count:v.length,children:[v.map(D=>g.jsx(ES,{icon:g.jsx(xS,{type:"report"}),tint:Rc.teal,label:D.path,onClick:R=>o(D.path,R)},D.path)),v.length===0&&g.jsx(CS,{label:"No notebooks"})]}),g.jsxs(SS,{title:"Semantic Models",count:x.length,children:[x.map(D=>g.jsx(ES,{icon:g.jsx(xS,{type:"model"}),tint:Rc.orange,label:D.path,onClick:R=>o(D.path,R)},D.path)),x.length===0&&g.jsx(CS,{label:"No models"})]}),g.jsxs(SS,{title:"Package Data",count:E.length,children:[E.map(D=>g.jsx(ES,{icon:g.jsx(xS,{type:"data"}),tint:Rc.darkBlue,label:D.path,rightLabel:STe(D.info.rowCount),onClick:()=>d(D)},D.path)),E.length===0&&g.jsx(CS,{label:"No data files"})]}),g.jsx(xt,{sx:{mb:4},children:g.jsx(xTe,{resourceUri:t})}),A&&g.jsx(xt,{sx:{mt:6},children:g.jsx(aTe,{resourceUri:T,retrievalFn:n})})]}),g.jsxs(ks,{open:u!==null,onClose:()=>d(null),maxWidth:"sm",fullWidth:!0,children:[g.jsxs(Ds,{sx:{pr:6},children:[u?.path,g.jsx(Cr,{"aria-label":"close",onClick:()=>d(null),sx:{position:"absolute",right:8,top:8},children:g.jsx(Ns,{fontSize:"small"})})]}),g.jsx(As,{children:u?.info?.columns&&g.jsxs(sT,{size:"small",children:[g.jsx(D5,{children:g.jsxs(Ad,{children:[g.jsx(zo,{children:"Column"}),g.jsx(zo,{children:"Type"})]})}),g.jsx(lT,{children:u.info.columns.map(D=>g.jsxs(Ad,{children:[g.jsx(zo,{component:"th",scope:"row",children:D.name}),g.jsx(zo,{children:D.type})]},D.name))})]})})]})]})}function SS({title:e,count:t,children:n}){return g.jsxs(xt,{sx:{mb:4},children:[g.jsxs(lo,{direction:"row",alignItems:"baseline",spacing:1,sx:{mb:1},children:[g.jsx(ft,{variant:"h6",sx:{fontWeight:600,letterSpacing:"-0.025em"},children:e}),g.jsxs(ft,{variant:"caption",color:"text.secondary",children:["(",t,")"]})]}),g.jsx(xt,{children:n})]})}function ES({icon:e,tint:t,label:n,rightLabel:r,onClick:o}){const a=!!o;return g.jsxs(xt,{onClick:o,onKeyDown:a?i=>{o&&(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),o(i))}:void 0,role:a?"button":void 0,tabIndex:a?0:void 0,sx:{display:"flex",alignItems:"center",gap:1.5,py:1,px:1,mx:-1,cursor:a?"pointer":"default",borderRadius:1.5,transition:"background-color 0.1s","&:hover":a?{backgroundColor:"grey.100"}:void 0,"&:focus-visible":a?{outline:"2px solid",outlineColor:"primary.main",outlineOffset:2}:void 0},children:[g.jsx(xt,{sx:{width:32,height:32,borderRadius:1,bgcolor:t,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),g.jsx(ft,{variant:"body2",sx:{fontFamily:tne,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),r&&g.jsx(ft,{variant:"caption",color:"text.secondary",sx:{flexShrink:0},children:r})]})}function CS({label:e}){return g.jsx(ft,{variant:"body2",color:"text.secondary",sx:{py:1,fontStyle:"italic"},children:e})}function STe(e){return e>=1e9?`${(e/1e9).toFixed(1)} B rows`:e>=1e6?`${(e/1e6).toFixed(1)} M rows`:e>=1e3?`${(e/1e3).toFixed(1)} K rows`:`${e} rows`}const ETe=async e=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:t}=await io(async()=>{const{MalloyRenderer:n}=await import("./index.umd-B68wGGkM.js").then(r=>r.i);return{MalloyRenderer:n}},[]);return new t({onClick:e,onError:n=>{console.error("Error rendering visualization:",typeof n,n)}}).createViz()};function CTe({result:e,height:t,onDrill:n,onSizeChange:r}){const o=C.useRef(null),a=C.useRef(!1);return C.useLayoutEffect(()=>{if(!o.current||!e)return;let i=!0;const l=o.current;for(;l.firstChild;)l.removeChild(l.firstChild);a.current=!1;let u=null,d=null;const f=()=>{if(a.current||!i||!l.firstElementChild)return;const h=l.firstElementChild.firstElementChild;if(!h)return;const y=h.firstElementChild;let b=h.scrollHeight||h.offsetHeight||0;y&&h.classList.contains("malloy-dashboard")&&(b=y.scrollHeight||y.offsetHeight||0),b>0&&(a.current=!0,r&&r(b))};return ETe(n).then(h=>{if(i){u=new MutationObserver(()=>{d&&clearTimeout(d),d=setTimeout(()=>{f(),u?.disconnect()},100)}),u.observe(l,{childList:!0,subtree:!0,attributes:!0});try{h.setResult(JSON.parse(e)),h.render(l)}catch(y){console.error("Error rendering visualization:",y),u?.disconnect()}}}).catch(h=>{console.error("Failed to create renderer:",h)}),()=>{i=!1,u?.disconnect(),d&&clearTimeout(d)}},[e,n,r]),g.jsx("div",{ref:o,style:{width:"100%",height:t?`${t}px`:"400px"}})}function TTe(e){return typeof window>"u"?g.jsx(xt,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):g.jsx(C.Suspense,{fallback:g.jsx(xt,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:g.jsx(CTe,{...e})})}const wTe=Object.freeze(Object.defineProperty({__proto__:null,default:TTe},Symbol.toStringTag,{value:"Module"})),Pn={white:"#FFFFFF",offWhite:"#F8F8F6",grey:{light:"#E6E4E1",mid:"#91908F"},black:"#30302E",semantic:{success:{main:"#7A9461",light:"#E8EDDF",dark:"#5F7A4B"},warning:{main:"#B5943A",light:"#F3ECDA",dark:"#8E7430"},error:{main:"#BF6050",light:"#F2DDD9",dark:"#9C4D40"},info:{main:"#628698",light:"#DDE6EA",dark:"#4D6B79"}}},ay='"Inter", "Helvetica Neue", "Arial", sans-serif',Na={50:Pn.offWhite,100:"#F4F3F1",200:Pn.grey.light,300:"#D4D2CF",400:"#B3B1AF",500:Pn.grey.mid,600:"#73726F",700:"#555450",800:"#424140",900:Pn.black},Swe={headerHeight:56},TS="0 1px 3px rgba(0, 0, 0, 0.1)",kTe=Gb({cssVariables:{nativeColor:!0},palette:{mode:"light",primary:{main:Pn.black,light:Pn.grey.light,dark:Pn.black,contrastText:Pn.white},secondary:{main:Pn.grey.mid,light:Pn.grey.light,dark:Pn.black},grey:Na,success:Pn.semantic.success,warning:Pn.semantic.warning,error:Pn.semantic.error,info:Pn.semantic.info,background:{default:Pn.white,paper:Pn.white},text:{primary:Pn.black,secondary:Pn.grey.mid},divider:Pn.grey.light},typography:{fontFamily:ay,h1:{fontWeight:500,letterSpacing:"-0.025em"},h2:{fontWeight:500,letterSpacing:"-0.025em"},h3:{fontWeight:500,letterSpacing:"-0.025em"},h4:{fontWeight:500,letterSpacing:"-0.025em"},h5:{fontWeight:500,letterSpacing:"-0.025em"},h6:{fontWeight:500,letterSpacing:"-0.025em"},subtitle1:{fontWeight:500,letterSpacing:"-0.025em"},subtitle2:{fontWeight:500,letterSpacing:"-0.025em"},body1:{letterSpacing:"-0.025em"},body2:{letterSpacing:"-0.025em"},button:{fontWeight:500,letterSpacing:"-0.025em",textTransform:"none"}},shape:{borderRadius:4},components:{MuiButtonBase:{defaultProps:{disableRipple:!0,disableTouchRipple:!0}},MuiCssBaseline:{styleOverrides:{"*":{scrollbarWidth:"thin",scrollbarColor:`${Na[300]} ${Na[100]}`,"&::-webkit-scrollbar":{width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{background:Na[100],borderRadius:"4px"},"&::-webkit-scrollbar-thumb":{background:Na[300],borderRadius:"4px","&:hover":{background:Na[400]}},"&::-webkit-scrollbar-corner":{background:Na[100]}},"div[data-radix-popper-content-wrapper]":{zIndex:"1300 !important"}}},MuiButton:{styleOverrides:{root:{borderRadius:20,textTransform:"none",fontWeight:500,boxShadow:"none","&:hover":{boxShadow:TS}},contained:{"&:hover":{boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)"}}}},MuiCard:{styleOverrides:{root:{borderRadius:4,boxShadow:TS,border:"1px solid",borderColor:Pn.grey.light}}},MuiChip:{styleOverrides:{root:{borderRadius:4,fontWeight:500}}},MuiTextField:{styleOverrides:{root:{"& .MuiOutlinedInput-root":{borderRadius:4},"& .MuiInputLabel-outlined":{backgroundColor:"white",paddingLeft:4,paddingRight:4,"&.MuiInputLabel-shrink":{transform:"translate(14px, -9px) scale(0.75)"}}}}},MuiDialog:{styleOverrides:{paper:{borderRadius:4,boxShadow:"0px 20px 25px -5px rgba(0, 0, 0, 0.1), 0px 10px 10px -5px rgba(0, 0, 0, 0.04)"}}},MuiSelect:{styleOverrides:{select:{fontFamily:ay,fontSize:"0.875rem",color:Na[600]}}},MuiInputLabel:{styleOverrides:{root:{"&.MuiInputLabel-outlined":{backgroundColor:"white",paddingLeft:4,paddingRight:4}}}},MuiOutlinedInput:{styleOverrides:{notchedOutline:{border:"none"},root:{border:`1px solid ${Na[200]}`,borderRadius:8,transition:"border-color 120ms ease-in","&:hover":{borderColor:Na[300]},"&.Mui-focused":{borderColor:Na[400],outline:"none"}}}},MuiMenuItem:{styleOverrides:{root:{fontFamily:ay,fontSize:"0.875rem"}}},MuiInputBase:{styleOverrides:{root:{fontFamily:ay}}},MuiMenu:{styleOverrides:{paper:{borderRadius:4,boxShadow:"0px 10px 15px -3px rgba(0, 0, 0, 0.1), 0px 4px 6px -2px rgba(0, 0, 0, 0.05)",border:`1px solid ${Pn.grey.light}`}}},MuiBreadcrumbs:{styleOverrides:{root:{"& .MuiBreadcrumbs-separator":{margin:"0 6px",color:Na[400]}}}},MuiDivider:{styleOverrides:{root:{borderColor:Pn.grey.light}},defaultProps:{sx:{my:1}}},MuiListItemButton:{styleOverrides:{root:{borderRadius:28,margin:"2px 8px",padding:"8px 16px","&:hover":{backgroundColor:Pn.offWhite},"&.Mui-selected":{backgroundColor:Pn.offWhite,color:Pn.black,"& .MuiListItemIcon-root":{color:Pn.black},"& .MuiListItemText-primary":{color:Pn.black},"&:hover":{backgroundColor:Pn.grey.light}}}}},MuiAppBar:{styleOverrides:{root:{backgroundColor:Pn.white,color:Pn.black,boxShadow:TS}}}}}),ATe=C.lazy(()=>io(()=>import("./HomePage-DwkH7OrS.js"),[])),DTe=C.lazy(()=>io(()=>import("./MainPage-D38LtZDV.js"),[])),RTe=C.lazy(()=>io(()=>import("./ModelPage-DOol8Mz7.js"),[])),MTe=C.lazy(()=>io(()=>import("./PackagePage-0tgzA_kO.js"),[])),OTe=C.lazy(()=>io(()=>import("./EnvironmentPage-C7rtH4mC.js"),[])),NTe=C.lazy(()=>io(()=>import("./RouteError-BaMsOSly.js"),[])),PTe=C.lazy(()=>io(()=>import("./WorkbookPage-Cx4SePkx.js"),[])),ITe=(e="/",t,n)=>t9([{path:e,element:g.jsx(bZ,{children:g.jsx(Fhe,{workbookStorage:t,children:g.jsxs(sH,{theme:kTe,children:[g.jsx(Tq,{}),g.jsx(C.Suspense,{fallback:g.jsx(ya,{}),children:g.jsx(DTe,{headerProps:n})})]})})}),errorElement:g.jsx(NTe,{}),children:[{index:!0,element:g.jsx(ATe,{})},{path:":environmentName",element:g.jsx(OTe,{})},{path:":environmentName/:packageName",element:g.jsx(MTe,{})},{path:":environmentName/:packageName/*",element:g.jsx(RTe,{})},{path:":environmentName/:packageName/workbook/:workspace/:workbookPath",element:g.jsx(PTe,{})}]}]),_Te=ITe("/",new Hhe,void 0);n7.createRoot(document.getElementById("root")).render(g.jsx(C.StrictMode,{children:g.jsx(p9,{router:_Te})}));export{vwe as $,Ye as A,_c as B,Oo as C,ji as D,BS as E,BTe as F,xt as G,MW as H,Cr as I,Yc as J,rT as K,bwe as L,y5 as M,SQ as N,jo as O,Ts as P,x5 as Q,hh as R,Uhe as S,ft as T,rv as U,Wd as V,Swe as W,cr as X,jTe as Y,ya as Z,cw as _,ma as a,aTe as a0,xwe as a1,ywe as a2,T8 as a3,JC as a4,lo as a5,gwe as a6,eu as a7,am as a8,Jle as a9,WT as aa,Cv as ab,OT as ac,PT as ad,mN as ae,q3 as af,FTe as ag,LTe as ah,tt as ai,El as aj,Ob as ak,NI as al,Lt as b,_l as c,It as d,IS as e,Ft as f,kU as g,u5 as h,mt as i,g as j,_t as k,Is as l,Yt as m,ci as n,Nr as o,Qc as p,Cs as q,C as r,Ue as s,G_ as t,AC as u,xd as v,X_ as w,_C as x,hH as y,un as z};
|