@marimo-team/frontend 0.19.3-dev39 → 0.19.3-dev41
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/assets/{CellStatus-C99xWY-n.js → CellStatus-b7Yo2X9j.js} +1 -1
- package/dist/assets/{JsonOutput-vgVa8Uqm.js → JsonOutput-C8Eo1zBR.js} +5 -5
- package/dist/assets/{MarimoErrorOutput-BheMLw1Y.js → MarimoErrorOutput-CXBGzjO2.js} +2 -2
- package/dist/assets/{RenderHTML-BE1SeEPf.js → RenderHTML-SoetmcW2.js} +1 -1
- package/dist/assets/{add-cell-with-ai-BQ3faBMp.js → add-cell-with-ai-Csh7GHT3.js} +8 -8
- package/dist/assets/{add-database-form-Cd6r_tKJ.js → add-database-form-BBkiGMZ_.js} +2 -2
- package/dist/assets/{agent-panel-B6jmJILp.js → agent-panel-C5C18dfm.js} +4 -4
- package/dist/assets/{ai-model-dropdown-Dv-MPaCU.js → ai-model-dropdown-CrMTCgo7.js} +1 -1
- package/dist/assets/{app-config-button-Dc-Pr3EG.js → app-config-button-9izWmQ0X.js} +1 -1
- package/dist/assets/{cell-editor-6RFkGM2j.js → cell-editor-gOJZyTG_.js} +13 -13
- package/dist/assets/cell-link-BP7_Ns0N.js +1 -0
- package/dist/assets/{cells-Ba_KE9BT.js → cells-Cv9PtwL9.js} +42 -42
- package/dist/assets/{chat-components-gFovWg-D.js → chat-components-Be6BPrbT.js} +1 -1
- package/dist/assets/{chat-display-DnPj1KhL.js → chat-display-BRKfnhbm.js} +1 -1
- package/dist/assets/{chat-panel-47KIpqX3.js → chat-panel-BwP6HOKA.js} +2 -2
- package/dist/assets/client-CGOlSEYr.js +4 -0
- package/dist/assets/{column-preview-DhROBSPD.js → column-preview-MC6VOHbd.js} +1 -1
- package/dist/assets/{command-D-UJxuGK.js → command-n_oMaKjl.js} +1 -1
- package/dist/assets/{command-palette-6sH9E7Dw.js → command-palette-DfZNcw7W.js} +1 -1
- package/dist/assets/common-MUZIZluQ.js +1 -0
- package/dist/assets/{datasource-D4Z8tdLQ.js → datasource-CEsMStKs.js} +2 -2
- package/dist/assets/{dependency-graph-panel-xSFZomKN.js → dependency-graph-panel-CNTGbfLZ.js} +4 -4
- package/dist/assets/{documentation-panel-Dm3ob6Ir.js → documentation-panel-Cb9AHO2C.js} +1 -1
- package/dist/assets/{download-BjwKjWNy.js → download-24bI2vH0.js} +1 -1
- package/dist/assets/{edit-page-CZh8JbX5.js → edit-page-KoYkiOm1.js} +6 -6
- package/dist/assets/{error-panel-DMBUp0y7.js → error-panel-CpYH0GfR.js} +1 -1
- package/dist/assets/{es-CHi7dcFm.js → es-BITbuY9w.js} +1 -1
- package/dist/assets/{file-explorer-panel-DjUhUpSF.js → file-explorer-panel-CdA81LHh.js} +1 -1
- package/dist/assets/{floating-outline-ftqqU4Np.js → floating-outline-BbJ4ldyu.js} +1 -1
- package/dist/assets/{focus-DZZOzpQD.js → focus-D1y1tXyC.js} +1 -1
- package/dist/assets/{form-CnZqs8Bn.js → form-BAtvsPJL.js} +2 -2
- package/dist/assets/{globals-Dh1hxKNk.js → globals-C6OH39EA.js} +1 -1
- package/dist/assets/{home-page-BMu2cQgR.js → home-page-B_YprqxM.js} +2 -2
- package/dist/assets/{index-DTpgS0Hi.js → index-Bq3Xa2YC.js} +9 -9
- package/dist/assets/{kiosk-mode-lfj9N4vd.js → kiosk-mode-DfyjlR7p.js} +1 -1
- package/dist/assets/{layout-0e9X02ON.js → layout-9uQoV-6h.js} +3 -3
- package/dist/assets/{logs-panel-pc8_rMGL.js → logs-panel-svcirwjp.js} +1 -1
- package/dist/assets/{markdown-renderer-DOsqiCxS.js → markdown-renderer-DlVqlHOL.js} +2 -2
- package/dist/assets/mode-PeuS_Lp-.js +1 -0
- package/dist/assets/{name-cell-input-DwI5DL4H.js → name-cell-input-YMoA0SQj.js} +1 -1
- package/dist/assets/{outline-panel-BkVymtAn.js → outline-panel-RKJ5Mqrt.js} +1 -1
- package/dist/assets/{packages-panel-C2AcLZfz.js → packages-panel-BuiAGEBw.js} +1 -1
- package/dist/assets/{panels-Bw1r9qwY.js → panels-BKsZUDjc.js} +1 -1
- package/dist/assets/{process-output-C46Mdai2.js → process-output-KJWsSvCT.js} +1 -1
- package/dist/assets/{readonly-python-code-C5OixNOu.js → readonly-python-code-HPlG_YPX.js} +1 -1
- package/dist/assets/{run-page-gAREGgIk.js → run-page-CBDzVDX3.js} +1 -1
- package/dist/assets/scratchpad-panel-BcE_ovEU.js +1 -0
- package/dist/assets/{session-panel-BuxKOamF.js → session-panel-Cv14Ehfm.js} +1 -1
- package/dist/assets/{snippets-panel-B6_Edpel.js → snippets-panel-OAdQXQ93.js} +1 -1
- package/dist/assets/{state-CSQYiEJY.js → state-DYG6kYly.js} +1 -1
- package/dist/assets/state-xh6GqNrp.js +1 -0
- package/dist/assets/{switch-eOpIZoDX.js → switch-DPeh0R76.js} +1 -1
- package/dist/assets/{textarea-niGA0rfg.js → textarea-wbzgrXvB.js} +1 -1
- package/dist/assets/{tracing-DkpVk4o4.js → tracing-Bh3EJxAS.js} +1 -1
- package/dist/assets/{tracing-panel-BIncP1rT.js → tracing-panel-BzSQ7qvB.js} +2 -2
- package/dist/assets/{types-VIX1OCSW.js → types-B8Qb1FfB.js} +1 -1
- package/dist/assets/{useAddCell-B_xjsTBs.js → useAddCell-DBGvrN8K.js} +1 -1
- package/dist/assets/{useCellActionButton-Ds3zG2vC.js → useCellActionButton-BlS_HKk-.js} +1 -1
- package/dist/assets/useDeleteCell-BvQIJfpI.js +1 -0
- package/dist/assets/{useDependencyPanelTab-D-cjUX7M.js → useDependencyPanelTab-BqEhbPr2.js} +1 -1
- package/dist/assets/useInterval-BGPIviJp.js +1 -0
- package/dist/assets/{useNotebookActions-BR0qaiDG.js → useNotebookActions-D1Woz3AV.js} +1 -1
- package/dist/assets/useRunCells-B9Xr4tcH.js +1 -0
- package/dist/assets/useSplitCell-7xBW3b8-.js +1 -0
- package/dist/assets/utilities.esm-xahhGpny.js +3 -0
- package/dist/index.html +31 -31
- package/package.json +1 -1
- package/src/__mocks__/requests.ts +1 -0
- package/src/core/cells/cells.ts +2 -0
- package/src/core/export/__tests__/hooks.test.ts +504 -0
- package/src/core/export/hooks.ts +93 -4
- package/src/core/islands/bridge.ts +1 -0
- package/src/core/network/requests-lazy.ts +1 -0
- package/src/core/network/requests-network.ts +8 -0
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.tsx +1 -0
- package/src/core/network/types.ts +2 -0
- package/src/core/wasm/bridge.ts +1 -0
- package/src/hooks/__tests__/useInterval.test.tsx +104 -0
- package/src/hooks/useInterval.ts +32 -6
- package/dist/assets/cell-link--tfL3CA1.js +0 -1
- package/dist/assets/client-ptbakt_D.js +0 -4
- package/dist/assets/common-CTqesfI3.js +0 -1
- package/dist/assets/mode-BCyUhVQM.js +0 -1
- package/dist/assets/scratchpad-panel-CCfSlzxc.js +0 -1
- package/dist/assets/state-CW2XRi_v.js +0 -1
- package/dist/assets/useDeleteCell-BHcO82VK.js +0 -1
- package/dist/assets/useInterval-DpipYmgs.js +0 -1
- package/dist/assets/useRunCells-DNyvw4YU.js +0 -1
- package/dist/assets/useSplitCell-PfU2seYs.js +0 -1
- package/dist/assets/utilities.esm-B52GCDdx.js +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{s as G}from"./chunk-LvLJmgfZ.js";import{d as ye,f as ve,l as Ne,u as be}from"./useEvent-DlWF5OMa.js";import{t as we}from"./react-BGmjiNul.js";import{
|
|
1
|
+
import{s as G}from"./chunk-LvLJmgfZ.js";import{d as ye,f as ve,l as Ne,u as be}from"./useEvent-DlWF5OMa.js";import{t as we}from"./react-BGmjiNul.js";import{Fn as ke,Fr as Ie,Ir as K,J as $e,an as _e,pn as Fe,qr as Ae,w as Te,y as Ce}from"./cells-Cv9PtwL9.js";import{t as E}from"./compiler-runtime-DeeZ7FnK.js";import{t as Se}from"./invariant-C6yE60hi.js";import{r as Me}from"./utils-CJJIceVn.js";import{t as qe}from"./jsx-runtime-DN_bIXfG.js";import{r as X,t as $}from"./button-B8cGZzP5.js";import{t as Y}from"./cn-C1rgT0yh.js";import{t as H}from"./createLucideIcon-CW2xpJ57.js";import{_ as ze}from"./select-D9lTzMzP.js";import{a as Ee,p as Pe,r as Le,t as We}from"./dropdown-menu-BP4_BZLr.js";import{a as Ve,n as Be}from"./state-xh6GqNrp.js";import{c as Z,n as Qe}from"./datasource-CEsMStKs.js";import{a as De}from"./dist-RKnr9SNh.js";import{t as ee}from"./tooltip-CvjcEpZC.js";import{a as Oe,i as He,n as Ue,r as Je}from"./multi-map-CQd4MZr5.js";import{t as te}from"./kbd-Czc5z_04.js";import{t as A}from"./links-DNmjkr65.js";import{r as Re,t as Ge}from"./alert-BEdExd6A.js";import{o as Ke,t as Xe}from"./useInstallPackage-RldLPyJs.js";import{n as b}from"./cell-link-BP7_Ns0N.js";var Ye=H("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),T=H("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),re=H("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function Ze(r){let e=null,s=r.cursor();do s.name==="ExpressionStatement"&&(e=s.node);while(s.next());return e}function et(r){let e=r.split(`
|
|
2
2
|
`),s=" ",n=Ze(De.parse(r));if(!n)return["def _():",...U(e,s),`${s}return`,"","","_()"].join(`
|
|
3
3
|
`);let i=r.slice(0,n.from).trim(),l=r.slice(n.from).trim(),a=i.split(`
|
|
4
4
|
`),c=l.split(`
|
|
5
5
|
`);return["def _():",...U(a,s),`${s}return ${c[0]}`,...U(c.slice(1),s),"","","_()"].join(`
|
|
6
6
|
`)}function U(r,e){if(r.length===1&&r[0]==="")return[];let s=[];for(let n of r)n===""?s.push(""):s.push(e+n);return s}function tt(r,e){var s;if(r.type==="multiple-defs")return[{title:"Fix: Wrap in a function",description:"Make this cell's variables local by wrapping the cell in a function.",fixType:"manual",onFix:async n=>{Se(n.editor,"Editor is null");let i=et(n.editor.state.doc.toString());n.editor.dispatch({changes:{from:0,to:n.editor.state.doc.length,insert:i}})}}];if(r.type==="exception"&&r.exception_type==="NameError"){let n=(s=r.msg.match(/name '(.+)' is not defined/))==null?void 0:s[1];if(!n||!(n in se))return[];let i=rt(n);return[{title:`Fix: Add '${i}'`,description:"Add a new cell for the missing import",fixType:"manual",onFix:async l=>{l.addCodeBelow(i)}}]}return r.type==="sql-error"&&e.aiEnabled?[{title:"Fix with AI",description:"Fix the SQL statement",fixType:"ai",onFix:async n=>{var a;let i=Qe(n.cellId),l=`Fix the SQL statement: ${r.msg}.`;i&&(l+=`
|
|
7
|
-
Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function rt(r){let e=se[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var se={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},st=E(),nt=Ie("marimo:ai-autofix-mode","autofix",Fe);function lt(){let r=(0,st.c)(3),[e,s]=Ne(nt),n;return r[0]!==e||r[1]!==s?(n={fixMode:e,setFixMode:s},r[0]=e,r[1]=s,r[2]=n):n=r[2],n}var K=E(),t=G(qe(),1);const N=r=>{let e=(0,K.c)(21),{errors:s,cellId:n,className:i}=r,l=ve(),{createNewCell:a}=ke(),c=be(Me),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>tt(y,{aiEnabled:c}),e[3]=c,e[4]=x),o=s.flatMap(x),e[0]=c,e[1]=s,e[2]=o}else o=e[2];let m=o,p=ye(Be);if(m.length===0)return null;let d=m[0],f;e[5]!==n||e[6]!==a||e[7]!==d||e[8]!==p||e[9]!==l?(f=x=>{var w;let y=(w=l.get(Ce).cellHandles[n].current)==null?void 0:w.editorView;d.onFix({addCodeBelow:_=>{a({cellId:n,autoFocus:!1,before:!1,code:_})},editor:y,cellId:n,aiFix:{setAiCompletionCell:p,triggerFix:x}}),y==null||y.focus()},e[5]=n,e[6]=a,e[7]=d,e[8]=p,e[9]=l,e[10]=f):f=e[10];let u=f,j;e[11]===i?j=e[12]:(j=Y("my-2",i),e[11]=i,e[12]=j);let h;e[13]!==d.description||e[14]!==d.fixType||e[15]!==d.title||e[16]!==u?(h=d.fixType==="ai"?(0,t.jsx)(oe,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,t.jsx)(ee,{content:d.description,align:"start",children:(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,t.jsx)(Z,{className:"h-3 w-3 mr-2"}),d.title]})}),e[13]=d.description,e[14]=d.fixType,e[15]=d.title,e[16]=u,e[17]=h):h=e[17];let g;return e[18]!==j||e[19]!==h?(g=(0,t.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var ne=Ve,le=Z,ie="Suggest a prompt",ae="Fix with AI";const oe=r=>{let e=(0,K.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=r,{fixMode:l,setFixMode:a}=lt(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(ne,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ie:ae,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[o,m]}),e[2]=c,e[3]=o,e[4]=m,e[5]=p):p=e[5];let d;e[6]!==p||e[7]!==s?(d=(0,t.jsx)(ee,{content:s,align:"start",children:p}),e[6]=p,e[7]=s,e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(Pe,{asChild:!0,children:(0,t.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(ze,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let u;e[10]!==l||e[11]!==a?(u=()=>{a(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=a,e[12]=u):u=e[12];let j=l==="prompt"?"autofix":"prompt",h;e[13]===j?h=e[14]:(h=(0,t.jsx)(it,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,t.jsxs)(We,{children:[f,(0,t.jsx)(Le,{align:"end",className:"w-56",children:(0,t.jsx)(Ee,{className:"flex items-center gap-2",onClick:u,children:h})})]}),e[15]=u,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==d?(x=(0,t.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var it=r=>{let e=(0,K.c)(12),{mode:s}=r,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,t.jsx)(ne,{className:"h-4 w-4"}):(0,t.jsx)(le,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ie:ae,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),e[4]=a,e[5]=o);let m;e[6]!==c||e[7]!==o?(m=(0,t.jsxs)("div",{className:"flex flex-col",children:[c,o]}),e[6]=c,e[7]=o,e[8]=m):m=e[8];let p;return e[9]!==i||e[10]!==m?(p=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},ce=/(https?:\/\/\S+)/,at=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,de=/^data:image\//i,ot=["avatars.githubusercontent.com"];function me(r){return de.test(r)?[{type:"image",url:r}]:r.split(ce).filter(e=>e.trim()!=="").map(e=>ce.test(e)?at.test(e)||de.test(e)||ot.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var pe=E(),P=G(we(),1),ct=new Te;const R=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var ue=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function dt(r){ue.lastIndex=0;let e=ue.exec(r);if(!e)return null;let s=e.index+e[0].length,n=r.slice(s).split(/\s+/),i="",l=0;for(let c of n){let o=c.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let m=o.match(/^[\w,.[\]-]+/);if(m){i=m[0];break}break}if(!i)return null;let a=s+l+i.length;return{package:i,endIndex:a}}function k(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let s=me(r);return s.length===1&&s[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,t.jsx)(P.Fragment,{children:n.value},l)})})}var mt=r=>{let e=(0,pe.c)(6),{packages:s,children:n}=r,{handleInstallPackages:i}=Xe(),l;e[0]!==i||e[1]!==s?(l=c=>{i(s),c.preventDefault()},e[0]=i,e[1]=s,e[2]=l):l=e[2];let a;return e[3]!==n||e[4]!==l?(a=(0,t.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:n}),e[3]=n,e[4]=l,e[5]=a):a=e[5],a};const pt=r=>{if(!(r instanceof J.Text))return;let e=R(r.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let s=[],n=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=n.exec(e))!==null;){let c=i.index,o=dt(e.slice(c));o&&s.push({match:i,result:o})}if(s.length===0)return;let l=[],a=0;if(s.forEach((c,o)=>{let{match:m,result:p}=c,d=m.index,f=d+p.endIndex;if(a<d){let j=e.slice(a,d);l.push((0,t.jsx)(P.Fragment,{children:k(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,t.jsx)(mt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,t.jsx)(P.Fragment,{children:k(c,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},ut=r=>{if(!(r instanceof J.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let s=k(e);if(typeof s!="string")return(0,t.jsx)(t.Fragment,{children:s})},ht=(...r)=>e=>{for(let s of r){let n=s(e);if(n!==void 0)return n}},xt=(r,e)=>(0,t.jsx)("span",{children:_e(ct.ansi_to_html(r),{replace:s=>e(s)})}),ft=r=>{let e=(0,pe.c)(4),{text:s}=r,n;e[0]===s?n=e[1]:(n=xt(s,ht(pt,ut)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var he=E(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(Oe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Ke,{className:"mr-24 text-[0.84375rem]",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,t.jsxs)(He,{value:"item-1",className:"text-muted-foreground",children:[n,i]}),e[4]=n,e[5]=i,e[6]=l):l=e[6];let a;return e[7]!==r.className||e[8]!==l?(a=(0,t.jsx)(Ue,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=a):a=e[9],a};const jt=r=>{let e=(0,he.c)(31),{errors:s,cellId:n,className:i}=r,l=Ae(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(gt))a="Interrupted";else if(s.some(yt))a="An internal error occurred";else if(s.some(vt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(Nt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(bt))a="SQL error";else{let x;e[0]===s?x=e[1]:(x=s.find(wt),e[0]=s,e[1]=x);let y=x;y&&"exception_type"in y&&(a=y.exception_type)}let m,p,d,f,u,j;if(e[2]!==c||e[3]!==n||e[4]!==l||e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==a){let x=s.filter(kt),y=s.filter(It),w=s.filter($t),_=s.filter(_t),L=s.filter(Ft),C=s.filter(At),S=s.filter(Tt),W=s.filter(Ct),V=s.filter(St),B=s.filter(Mt),F=s.filter(qt),Q=s.filter(zt),D=s.filter(Et),M;e[15]===l?M=e[16]:(M=()=>{l.openApplication("scratchpad")},e[15]=l,e[16]=M);let xe=M,fe=()=>{let v=[];if(F.length>0||Q.length>0){let z=F.some(Pt),ge=!z&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),Q.map(Vt),z&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Je(l),children:[(0,t.jsx)(Ye,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),ge&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,t.jsx)(re,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),n&&(0,t.jsx)(N,{errors:[...F,...Q],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,t.jsx)("ul",{className:"list-disc",children:x.flatMap(Bt)}),n&&(0,t.jsx)(N,{errors:x,cellId:n}),(0,t.jsxs)(I,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,t.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,t.jsx)("ul",{className:"list-disc",children:y.flatMap(Qt)}),n&&(0,t.jsx)(N,{errors:y,cellId:n}),(0,t.jsxs)(I,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,t.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),w.length>0){let z=w[0].name;v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),w.map(Ot),n&&(0,t.jsx)(N,{errors:w,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I redefine variables?",children:[(0,t.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,t.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,t.jsxs)(te,{className:"inline",children:["_",z]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(I,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:xe,children:[(0,t.jsx)($e,{className:"h-3"}),(0,t.jsx)("span",{children:"Try the scratchpad"})]}),(0,t.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return _.length>0&&v.push((0,t.jsxs)("div",{children:[_.map(Ht),n&&(0,t.jsx)(N,{errors:_,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I use `import *`?",children:[(0,t.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,t.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,t.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Ut),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Kt),C.some(Rt)&&(0,t.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,t.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,t.jsxs)("ul",{children:[S.map(Gt),n&&(0,t.jsx)(N,{errors:S,cellId:n}),(0,t.jsx)(I,{children:S.some(Jt)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),W.length>0&&v.push((0,t.jsxs)("div",{children:[W.map(Xt),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"internal")),V.length>0&&v.push((0,t.jsxs)("div",{children:[V.map(Yt),n&&(0,t.jsx)(N,{errors:V,cellId:n})]},"ancestor-prevented")),B.length>0&&v.push((0,t.jsxs)("div",{children:[B.map(Zt),n&&(0,t.jsx)(N,{errors:B,cellId:n})]},"ancestor-stopped")),D.length>0&&v.push((0,t.jsxs)("div",{children:[D.map(er),n&&(0,t.jsx)(N,{errors:D,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,q;e[17]!==O||e[18]!==a?(q=(0,t.jsx)(Re,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=q):q=e[19];let je=q;m=Ge,f=c,e[20]===i?u=e[21]:(u=Y("border-none font-code text-sm text-[0.84375rem] px-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-4",i),e[20]=i,e[21]=u),j=je,p="flex flex-col gap-8",d=fe(),e[2]=c,e[3]=n,e[4]=l,e[5]=i,e[6]=s,e[7]=o,e[8]=a,e[9]=m,e[10]=p,e[11]=d,e[12]=f,e[13]=u,e[14]=j}else m=e[9],p=e[10],d=e[11],f=e[12],u=e[13],j=e[14];let h;e[22]!==p||e[23]!==d?(h=(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:p,children:d})}),e[22]=p,e[23]=d,e[24]=h):h=e[24];let g;return e[25]!==m||e[26]!==f||e[27]!==u||e[28]!==j||e[29]!==h?(g=(0,t.jsxs)(m,{variant:f,className:u,children:[j,h]}),e[25]=m,e[26]=f,e[27]=u,e[28]=j,e[29]=h,e[30]=g):g=e[30],g};function gt(r){return r.type==="interruption"}function yt(r){return r.type==="internal"}function vt(r){return r.type==="ancestor-prevented"}function Nt(r){return r.type==="ancestor-stopped"}function bt(r){return r.type==="sql-error"}function wt(r){return r.type==="exception"}function kt(r){return r.type==="setup-refs"}function It(r){return r.type==="cycle"}function $t(r){return r.type==="multiple-defs"}function _t(r){return r.type==="import-star"}function Ft(r){return r.type==="interruption"}function At(r){return r.type==="exception"}function Tt(r){return r.type==="strict-exception"}function Ct(r){return r.type==="internal"}function St(r){return r.type==="ancestor-prevented"}function Mt(r){return r.type==="ancestor-stopped"}function qt(r){return r.type==="syntax"}function zt(r){return r.type==="unknown"}function Et(r){return r.type==="sql-error"}function Pt(r){return r.msg.includes("!pip")}function Lt(r){return r.msg.includes("use os.subprocess")}function Wt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`syntax-${e}`)},`syntax-${e}`)}function Vt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`unknown-${e}`)},`unknown-${e}`)}function Bt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Qt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,t.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Dt(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(b,{cellId:r})},`cell-${e}`)}function Ot(r,e){return(0,t.jsxs)(P.Fragment,{children:[(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${r.name}' was also defined by:`}),(0,t.jsx)("ul",{className:"list-disc",children:r.cells.map(Dt)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ut(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Kt(r,e){return r.exception_type==="NameError"&&r.msg.startsWith("name 'mo'")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,t.jsx)(te,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):r.exception_type==="NameError"&&r.msg.startsWith("name '_")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,t.jsxs)(A,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),")."]}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,t.jsx)("li",{className:"my-2",children:r.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:k(r.msg,`exception-${e}`)}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[k(r.msg,`exception-${e}`),(0,t.jsx)(b,{cellId:r.raising_cell})]})},`exception-${e}`)}function Rt(r){return r.raising_cell!=null}function Gt(r,e){return(0,t.jsx)("li",{className:"my-2",children:r.blamed_cell==null?(0,t.jsx)("p",{children:r.msg}):(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function Jt(r){return r.blamed_cell!=null}function Xt(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function Yt(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(b,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Zt(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function er(r,e){return(0,t.jsx)("div",{className:"space-y-2 mt-2",children:(0,t.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.msg})},`sql-error-${e}`)}export{re as a,oe as i,ft as n,me as r,jt as t};
|
|
7
|
+
Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function rt(r){let e=se[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var se={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},st=E(),nt=Ae("marimo:ai-autofix-mode","autofix",Fe);function lt(){let r=(0,st.c)(3),[e,s]=Ne(nt),n;return r[0]!==e||r[1]!==s?(n={fixMode:e,setFixMode:s},r[0]=e,r[1]=s,r[2]=n):n=r[2],n}var J=E(),t=G(qe(),1);const N=r=>{let e=(0,J.c)(21),{errors:s,cellId:n,className:i}=r,l=ve(),{createNewCell:a}=Te(),c=be(Me),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>tt(y,{aiEnabled:c}),e[3]=c,e[4]=x),o=s.flatMap(x),e[0]=c,e[1]=s,e[2]=o}else o=e[2];let m=o,p=ye(Be);if(m.length===0)return null;let d=m[0],f;e[5]!==n||e[6]!==a||e[7]!==d||e[8]!==p||e[9]!==l?(f=x=>{var w;let y=(w=l.get(Ce).cellHandles[n].current)==null?void 0:w.editorView;d.onFix({addCodeBelow:_=>{a({cellId:n,autoFocus:!1,before:!1,code:_})},editor:y,cellId:n,aiFix:{setAiCompletionCell:p,triggerFix:x}}),y==null||y.focus()},e[5]=n,e[6]=a,e[7]=d,e[8]=p,e[9]=l,e[10]=f):f=e[10];let u=f,j;e[11]===i?j=e[12]:(j=Y("my-2",i),e[11]=i,e[12]=j);let h;e[13]!==d.description||e[14]!==d.fixType||e[15]!==d.title||e[16]!==u?(h=d.fixType==="ai"?(0,t.jsx)(oe,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,t.jsx)(ee,{content:d.description,align:"start",children:(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,t.jsx)(Z,{className:"h-3 w-3 mr-2"}),d.title]})}),e[13]=d.description,e[14]=d.fixType,e[15]=d.title,e[16]=u,e[17]=h):h=e[17];let g;return e[18]!==j||e[19]!==h?(g=(0,t.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var ne=Ve,le=Z,ie="Suggest a prompt",ae="Fix with AI";const oe=r=>{let e=(0,J.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=r,{fixMode:l,setFixMode:a}=lt(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(ne,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ie:ae,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[o,m]}),e[2]=c,e[3]=o,e[4]=m,e[5]=p):p=e[5];let d;e[6]!==p||e[7]!==s?(d=(0,t.jsx)(ee,{content:s,align:"start",children:p}),e[6]=p,e[7]=s,e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(Pe,{asChild:!0,children:(0,t.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(ze,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let u;e[10]!==l||e[11]!==a?(u=()=>{a(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=a,e[12]=u):u=e[12];let j=l==="prompt"?"autofix":"prompt",h;e[13]===j?h=e[14]:(h=(0,t.jsx)(it,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,t.jsxs)(We,{children:[f,(0,t.jsx)(Le,{align:"end",className:"w-56",children:(0,t.jsx)(Ee,{className:"flex items-center gap-2",onClick:u,children:h})})]}),e[15]=u,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==d?(x=(0,t.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var it=r=>{let e=(0,J.c)(12),{mode:s}=r,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,t.jsx)(ne,{className:"h-4 w-4"}):(0,t.jsx)(le,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ie:ae,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),e[4]=a,e[5]=o);let m;e[6]!==c||e[7]!==o?(m=(0,t.jsxs)("div",{className:"flex flex-col",children:[c,o]}),e[6]=c,e[7]=o,e[8]=m):m=e[8];let p;return e[9]!==i||e[10]!==m?(p=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},ce=/(https?:\/\/\S+)/,at=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,de=/^data:image\//i,ot=["avatars.githubusercontent.com"];function me(r){return de.test(r)?[{type:"image",url:r}]:r.split(ce).filter(e=>e.trim()!=="").map(e=>ce.test(e)?at.test(e)||de.test(e)||ot.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var pe=E(),P=G(we(),1),ct=new $e;const R=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var ue=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function dt(r){ue.lastIndex=0;let e=ue.exec(r);if(!e)return null;let s=e.index+e[0].length,n=r.slice(s).split(/\s+/),i="",l=0;for(let c of n){let o=c.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let m=o.match(/^[\w,.[\]-]+/);if(m){i=m[0];break}break}if(!i)return null;let a=s+l+i.length;return{package:i,endIndex:a}}function k(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let s=me(r);return s.length===1&&s[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,t.jsx)(P.Fragment,{children:n.value},l)})})}var mt=r=>{let e=(0,pe.c)(6),{packages:s,children:n}=r,{handleInstallPackages:i}=Xe(),l;e[0]!==i||e[1]!==s?(l=c=>{i(s),c.preventDefault()},e[0]=i,e[1]=s,e[2]=l):l=e[2];let a;return e[3]!==n||e[4]!==l?(a=(0,t.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:n}),e[3]=n,e[4]=l,e[5]=a):a=e[5],a};const pt=r=>{if(!(r instanceof K.Text))return;let e=R(r.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let s=[],n=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=n.exec(e))!==null;){let c=i.index,o=dt(e.slice(c));o&&s.push({match:i,result:o})}if(s.length===0)return;let l=[],a=0;if(s.forEach((c,o)=>{let{match:m,result:p}=c,d=m.index,f=d+p.endIndex;if(a<d){let j=e.slice(a,d);l.push((0,t.jsx)(P.Fragment,{children:k(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,t.jsx)(mt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,t.jsx)(P.Fragment,{children:k(c,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},ut=r=>{if(!(r instanceof K.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let s=k(e);if(typeof s!="string")return(0,t.jsx)(t.Fragment,{children:s})},ht=(...r)=>e=>{for(let s of r){let n=s(e);if(n!==void 0)return n}},xt=(r,e)=>(0,t.jsx)("span",{children:Ie(ct.ansi_to_html(r),{replace:s=>e(s)})}),ft=r=>{let e=(0,pe.c)(4),{text:s}=r,n;e[0]===s?n=e[1]:(n=xt(s,ht(pt,ut)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var he=E(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(Oe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Je,{className:"mr-24 text-[0.84375rem]",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,t.jsxs)(He,{value:"item-1",className:"text-muted-foreground",children:[n,i]}),e[4]=n,e[5]=i,e[6]=l):l=e[6];let a;return e[7]!==r.className||e[8]!==l?(a=(0,t.jsx)(Ue,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=a):a=e[9],a};const jt=r=>{let e=(0,he.c)(31),{errors:s,cellId:n,className:i}=r,l=_e(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(gt))a="Interrupted";else if(s.some(yt))a="An internal error occurred";else if(s.some(vt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(Nt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(bt))a="SQL error";else{let x;e[0]===s?x=e[1]:(x=s.find(wt),e[0]=s,e[1]=x);let y=x;y&&"exception_type"in y&&(a=y.exception_type)}let m,p,d,f,u,j;if(e[2]!==c||e[3]!==n||e[4]!==l||e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==a){let x=s.filter(kt),y=s.filter(It),w=s.filter($t),_=s.filter(_t),L=s.filter(Ft),C=s.filter(At),S=s.filter(Tt),W=s.filter(Ct),V=s.filter(St),B=s.filter(Mt),F=s.filter(qt),Q=s.filter(zt),D=s.filter(Et),M;e[15]===l?M=e[16]:(M=()=>{l.openApplication("scratchpad")},e[15]=l,e[16]=M);let xe=M,fe=()=>{let v=[];if(F.length>0||Q.length>0){let z=F.some(Pt),ge=!z&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),Q.map(Vt),z&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Ke(l),children:[(0,t.jsx)(Ye,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),ge&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,t.jsx)(re,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),n&&(0,t.jsx)(N,{errors:[...F,...Q],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,t.jsx)("ul",{className:"list-disc",children:x.flatMap(Bt)}),n&&(0,t.jsx)(N,{errors:x,cellId:n}),(0,t.jsxs)(I,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,t.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,t.jsx)("ul",{className:"list-disc",children:y.flatMap(Qt)}),n&&(0,t.jsx)(N,{errors:y,cellId:n}),(0,t.jsxs)(I,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,t.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),w.length>0){let z=w[0].name;v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),w.map(Ot),n&&(0,t.jsx)(N,{errors:w,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I redefine variables?",children:[(0,t.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,t.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,t.jsxs)(te,{className:"inline",children:["_",z]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(I,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:xe,children:[(0,t.jsx)(ke,{className:"h-3"}),(0,t.jsx)("span",{children:"Try the scratchpad"})]}),(0,t.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return _.length>0&&v.push((0,t.jsxs)("div",{children:[_.map(Ht),n&&(0,t.jsx)(N,{errors:_,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I use `import *`?",children:[(0,t.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,t.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,t.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(A,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Ut),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Jt),C.some(Rt)&&(0,t.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,t.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,t.jsxs)("ul",{children:[S.map(Gt),n&&(0,t.jsx)(N,{errors:S,cellId:n}),(0,t.jsx)(I,{children:S.some(Kt)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),W.length>0&&v.push((0,t.jsxs)("div",{children:[W.map(Xt),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"internal")),V.length>0&&v.push((0,t.jsxs)("div",{children:[V.map(Yt),n&&(0,t.jsx)(N,{errors:V,cellId:n})]},"ancestor-prevented")),B.length>0&&v.push((0,t.jsxs)("div",{children:[B.map(Zt),n&&(0,t.jsx)(N,{errors:B,cellId:n})]},"ancestor-stopped")),D.length>0&&v.push((0,t.jsxs)("div",{children:[D.map(er),n&&(0,t.jsx)(N,{errors:D,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,q;e[17]!==O||e[18]!==a?(q=(0,t.jsx)(Re,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=q):q=e[19];let je=q;m=Ge,f=c,e[20]===i?u=e[21]:(u=Y("border-none font-code text-sm text-[0.84375rem] px-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-4",i),e[20]=i,e[21]=u),j=je,p="flex flex-col gap-8",d=fe(),e[2]=c,e[3]=n,e[4]=l,e[5]=i,e[6]=s,e[7]=o,e[8]=a,e[9]=m,e[10]=p,e[11]=d,e[12]=f,e[13]=u,e[14]=j}else m=e[9],p=e[10],d=e[11],f=e[12],u=e[13],j=e[14];let h;e[22]!==p||e[23]!==d?(h=(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:p,children:d})}),e[22]=p,e[23]=d,e[24]=h):h=e[24];let g;return e[25]!==m||e[26]!==f||e[27]!==u||e[28]!==j||e[29]!==h?(g=(0,t.jsxs)(m,{variant:f,className:u,children:[j,h]}),e[25]=m,e[26]=f,e[27]=u,e[28]=j,e[29]=h,e[30]=g):g=e[30],g};function gt(r){return r.type==="interruption"}function yt(r){return r.type==="internal"}function vt(r){return r.type==="ancestor-prevented"}function Nt(r){return r.type==="ancestor-stopped"}function bt(r){return r.type==="sql-error"}function wt(r){return r.type==="exception"}function kt(r){return r.type==="setup-refs"}function It(r){return r.type==="cycle"}function $t(r){return r.type==="multiple-defs"}function _t(r){return r.type==="import-star"}function Ft(r){return r.type==="interruption"}function At(r){return r.type==="exception"}function Tt(r){return r.type==="strict-exception"}function Ct(r){return r.type==="internal"}function St(r){return r.type==="ancestor-prevented"}function Mt(r){return r.type==="ancestor-stopped"}function qt(r){return r.type==="syntax"}function zt(r){return r.type==="unknown"}function Et(r){return r.type==="sql-error"}function Pt(r){return r.msg.includes("!pip")}function Lt(r){return r.msg.includes("use os.subprocess")}function Wt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`syntax-${e}`)},`syntax-${e}`)}function Vt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`unknown-${e}`)},`unknown-${e}`)}function Bt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Qt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,t.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Dt(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(b,{cellId:r})},`cell-${e}`)}function Ot(r,e){return(0,t.jsxs)(P.Fragment,{children:[(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${r.name}' was also defined by:`}),(0,t.jsx)("ul",{className:"list-disc",children:r.cells.map(Dt)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ut(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Jt(r,e){return r.exception_type==="NameError"&&r.msg.startsWith("name 'mo'")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,t.jsx)(te,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):r.exception_type==="NameError"&&r.msg.startsWith("name '_")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,t.jsxs)(A,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(T,{size:"0.75rem",className:"inline"})]}),")."]}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,t.jsx)("li",{className:"my-2",children:r.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:k(r.msg,`exception-${e}`)}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[k(r.msg,`exception-${e}`),(0,t.jsx)(b,{cellId:r.raising_cell})]})},`exception-${e}`)}function Rt(r){return r.raising_cell!=null}function Gt(r,e){return(0,t.jsx)("li",{className:"my-2",children:r.blamed_cell==null?(0,t.jsx)("p",{children:r.msg}):(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function Kt(r){return r.blamed_cell!=null}function Xt(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function Yt(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(b,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Zt(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function er(r,e){return(0,t.jsx)("div",{className:"space-y-2 mt-2",children:(0,t.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.msg})},`sql-error-${e}`)}export{re as a,oe as i,ft as n,me as r,jt as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as v}from"./chunk-LvLJmgfZ.js";import{p as x,u as j}from"./useEvent-DlWF5OMa.js";import{t as _}from"./react-BGmjiNul.js";import{Fr as
|
|
1
|
+
import{s as v}from"./chunk-LvLJmgfZ.js";import{p as x,u as j}from"./useEvent-DlWF5OMa.js";import{t as _}from"./react-BGmjiNul.js";import{Fr as w,Ir as u}from"./cells-Cv9PtwL9.js";import{t as y}from"./compiler-runtime-DeeZ7FnK.js";import{o as N}from"./utils-CJJIceVn.js";import{t as R}from"./jsx-runtime-DN_bIXfG.js";import{t as z}from"./mode-PeuS_Lp-.js";import{t as C}from"./usePress-DTwIUo40.js";import{t as F}from"./copy-icon-jWsqdLn1.js";import{t as E}from"./purify.es-N-2faAGj.js";import{t as H}from"./useRunCells-B9Xr4tcH.js";var k=y(),m=v(_(),1),s=v(R(),1);const M=e=>{let t=(0,k.c)(16),r,a,i;t[0]===e?(r=t[1],a=t[2],i=t[3]):({href:a,children:r,...i}=e,t[0]=e,t[1]=r,t[2]=a,t[3]=i);let o=(0,m.useRef)(null),l;t[4]===a?l=t[5]:(l=()=>{let d=new URL(globalThis.location.href);d.hash=a,globalThis.history.pushState({},"",d.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let S=a.slice(1),A=document.getElementById(S);A&&A.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=a,t[5]=l);let n=l,c;t[6]===n?c=t[7]:(c={onPress:()=>{n()}},t[6]=n,t[7]=c);let{pressProps:b}=C(c),f;t[8]===n?f=t[9]:(f=d=>{d.preventDefault(),n()},t[8]=n,t[9]=f);let g=f,h;return t[10]!==r||t[11]!==g||t[12]!==a||t[13]!==b||t[14]!==i?(h=(0,s.jsx)("a",{ref:o,href:a,...b,onClick:g,...i,children:r}),t[10]=r,t[11]=g,t[12]=a,t[13]=b,t[14]=i,t[15]=h):h=t[15],h};var T=x(e=>{let t=e(H),r=e(N);if(t||r)return!1;let a=!0;try{a=z()==="read"}catch{return!0}return!a});function L(){return j(T)}var p="data-temp-href-target";E.addHook("beforeSanitizeAttributes",e=>{e.tagName==="A"&&(e.hasAttribute("target")||e.setAttribute("target","_self"),e.hasAttribute("target")&&e.setAttribute(p,e.getAttribute("target")||""))}),E.addHook("afterSanitizeAttributes",e=>{e.tagName==="A"&&e.hasAttribute(p)&&(e.setAttribute("target",e.getAttribute(p)||""),e.removeAttribute(p),e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer"))});function O(e){let t={USE_PROFILES:{html:!0,svg:!0,mathMl:!0},FORCE_BODY:!0,CUSTOM_ELEMENT_HANDLING:{tagNameCheck:/^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,attributeNameCheck:/^[A-Za-z][\w-]*$/},SAFE_FOR_XML:!e.includes("marimo-mermaid")};return E.sanitize(e,t)}var I=y(),D=e=>{if(e instanceof u.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return m.createElement(m.Fragment)},V=(e,t)=>{if(t instanceof u.Element&&t.name==="body"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,s.jsx)(s.Fragment,{children:r})}return}},W=(e,t)=>{if(t instanceof u.Element&&t.name==="html"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,s.jsx)(s.Fragment,{children:r})}return}},$=e=>{if(e instanceof u.Element&&e.attribs&&e.name==="iframe"){let t=document.createElement("iframe");return Object.entries(e.attribs).forEach(([r,a])=>{r.startsWith('"')&&r.endsWith('"')&&(r=r.slice(1,-1)),t.setAttribute(r,a)}),(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},P=e=>{if(e instanceof u.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!document.querySelector(`script[src="${t}"]`)){let r=document.createElement("script");r.src=t,document.head.append(r)}return(0,s.jsx)(s.Fragment,{})}},U=(e,t)=>{if(t instanceof u.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let a=null;return(0,m.isValidElement)(e)&&"props"in e&&(a=e.props.children),(0,s.jsx)(M,{href:r,...t.attribs,children:a})}}},Z=(e,t,r)=>{var a,i;if(t instanceof u.Element&&t.name==="div"&&((i=(a=t.attribs)==null?void 0:a.class)!=null&&i.includes("codehilite")))return(0,s.jsx)(B,{children:e},r)},B=e=>{let t=(0,I.c)(3),{children:r}=e,a=(0,m.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(F,{tooltip:!1,className:"p-1",value:()=>{var n;let l=(n=a.current)==null?void 0:n.firstChild;return l&&l.textContent||""}})}),t[0]=i):i=t[0];let o;return t[1]===r?o=t[2]:(o=(0,s.jsxs)("div",{className:"relative group codehilite-wrapper",ref:a,children:[r,i]}),t[1]=r,t[2]=o),o};const q=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,s.jsx)(G,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var G=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let a=L();return X({html:(0,m.useMemo)(()=>r||a?O(e):e,[e,r,a]),additionalReplacements:t})};function X({html:e,additionalReplacements:t=[]}){let r=[D,$,P,...t],a=[Z,U,V,W];return w(e,{replace:(i,o)=>{for(let l of r){let n=l(i,o);if(n)return n}return i},transform:(i,o,l)=>{for(let n of a){let c=n(i,o,l);if(c)return c}return i}})}export{q as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Un=Object.defineProperty;var Vn=(t,e,a)=>e in t?Un(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var $=(t,e,a)=>Vn(t,typeof e!="symbol"?e+"":e,a);import{s as ka,t as qn}from"./chunk-LvLJmgfZ.js";import{f as Rr,i as Nr,l as Bn,n as Wn,o as Jn,u as Kn}from"./useEvent-DlWF5OMa.js";import{t as Yn}from"./react-BGmjiNul.js";import{$n as
|
|
1
|
+
var Un=Object.defineProperty;var Vn=(t,e,a)=>e in t?Un(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var $=(t,e,a)=>Vn(t,typeof e!="symbol"?e+"":e,a);import{s as ka,t as qn}from"./chunk-LvLJmgfZ.js";import{f as Rr,i as Nr,l as Bn,n as Wn,o as Jn,u as Kn}from"./useEvent-DlWF5OMa.js";import{t as Yn}from"./react-BGmjiNul.js";import{$n as Hn,$r as Mr,Cr as Gn,Et as Pr,Gr as Qn,Vn as Xn,Vr as ei,Zn as ti,at as Ca,br as ai,ei as ri,er as jr,f as si,gn as ni,i as ii,jt as oi,mt as li,pn as di,qr as ui,w as $r,wn as ci,y as Ge}from"./cells-Cv9PtwL9.js";import{B as Te,D as pi,E as Lr,H as mi,I as It,J as Dr,L as ee,N as Zr,O as hi,P as Q,R as k,S as fi,T as de,V as Ue,W as Fr,b as Bt,k as N,w as Ve,x as Wt}from"./zod-Cg4WLWh2.js";import{t as Ea}from"./compiler-runtime-DeeZ7FnK.js";import{i as zr}from"./useLifecycle-CmDXEyIC.js";import{d as oe,s as gi}from"./hotkeys-uKX61F1_.js";import{o as yi}from"./config-DFDEcYvy.js";import{t as vi}from"./jsx-runtime-DN_bIXfG.js";import{t as Qe}from"./button-B8cGZzP5.js";import{t as Ur}from"./cn-C1rgT0yh.js";import{Bt as _i,Jt,St as Kt,Ut as Vr,Vt as bi,Xt as xi,at as qr,ct as wi,lt as Br,qt as Yt,rt as Ta,xt as ki}from"./dist-CAcX026F.js";import{t as Ci}from"./createReducer-DDa-hVe3.js";import{h as Ei,n as Ti,o as Ii,r as Si}from"./dist-DKNOF5xd.js";import{r as Oi,t as Ai}from"./requests-C0HaHO6a.js";import{t as Ia}from"./createLucideIcon-CW2xpJ57.js";import{t as Ri}from"./ai-model-dropdown-CrMTCgo7.js";import{h as Ni}from"./select-D9lTzMzP.js";import{f as Mi,n as Pi,u as Wr}from"./markdown-renderer-DlVqlHOL.js";import{a as Jr,c as ji,p as $i,r as Li,t as Di}from"./dropdown-menu-BP4_BZLr.js";import{t as Zi}from"./play-BJDBXApx.js";import{n as Fi}from"./spinner-C1czjtp7.js";import{a as zi}from"./state-xh6GqNrp.js";import{a as St,i as yt,o as Ot,r as vt,s as Ui,t as Vi}from"./datasource-CEsMStKs.js";import{a as qi}from"./dist-HGZzCB0y.js";import{t as Kr}from"./use-toast-Bzf3rpev.js";import{r as Bi}from"./useTheme-DfP1CWaW.js";import{t as Wi}from"./tooltip-CvjcEpZC.js";import{s as Ji}from"./popover-DtnzNVk-.js";import{a as Ki}from"./error-banner-DvT0IGDZ.js";import{n as Yi}from"./useRunCells-B9Xr4tcH.js";import{i as Sa}from"./cell-link-BP7_Ns0N.js";import{r as Hi,t as Gi}from"./es-BITbuY9w.js";import{n as Oa}from"./renderShortcut-D0Pei-OA.js";import{t as Qi}from"./process-output-KJWsSvCT.js";import{t as Xi}from"./blob-Dg_vNTSs.js";import{t as eo}from"./useDeleteCell-BvQIJfpI.js";import{r as to,t as ao}from"./esm-B3JckBtM.js";import{n as ro}from"./icons-D4lB4En9.js";var so=Ia("at-sign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]),no=Ia("send-horizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]),io=Ia("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),Yr="vercel.ai.error",oo=Symbol.for(Yr),Hr,Gr,Xe=class Pn extends(Gr=Error,Hr=oo,Gr){constructor({name:e,message:a,cause:r}){super(a),this[Hr]=!0,this.name=e,this.cause=r}static isInstance(e){return Pn.hasMarker(e,Yr)}static hasMarker(e,a){let r=Symbol.for(a);return typeof e=="object"&&!!e&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function Qr(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Xr="AI_InvalidArgumentError",es=`vercel.ai.error.${Xr}`,lo=Symbol.for(es),ts,as,uo=class extends(as=Xe,ts=lo,as){constructor({message:t,cause:e,argument:a}){super({name:Xr,message:t,cause:e}),this[ts]=!0,this.argument=a}static isInstance(t){return Xe.hasMarker(t,es)}},rs="AI_JSONParseError",ss=`vercel.ai.error.${rs}`,co=Symbol.for(ss),ns,is,os=class extends(is=Xe,ns=co,is){constructor({text:t,cause:e}){super({name:rs,message:`JSON parsing failed: Text: ${t}.
|
|
2
2
|
Error message: ${Qr(e)}`,cause:e}),this[ns]=!0,this.text=t}static isInstance(t){return Xe.hasMarker(t,ss)}},ls="AI_TypeValidationError",ds=`vercel.ai.error.${ls}`,po=Symbol.for(ds),us,cs,Ht=class Er extends(cs=Xe,us=po,cs){constructor({value:e,cause:a}){super({name:ls,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
3
3
|
Error message: ${Qr(a)}`,cause:a}),this[us]=!0,this.value=e}static isInstance(e){return Xe.hasMarker(e,ds)}static wrap({value:e,cause:a}){return Er.isInstance(a)&&a.value===e?a:new Er({value:e,cause:a})}},ps=class extends Error{constructor(t,e){super(t),this.name="ParseError",this.type=e.type,this.field=e.field,this.value=e.value,this.line=e.line}};function Aa(t){}function mo(t){if(typeof t=="function")throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:e=Aa,onError:a=Aa,onRetry:r=Aa,onComment:s}=t,n="",o=!0,i,l="",d="";function u(f){let c=o?f.replace(/^\xEF\xBB\xBF/,""):f,[m,_]=ho(`${n}${c}`);for(let E of m)p(E);n=_,o=!1}function p(f){if(f===""){h();return}if(f.startsWith(":")){s&&s(f.slice(f.startsWith(": ")?2:1));return}let c=f.indexOf(":");if(c!==-1){let m=f.slice(0,c),_=f[c+1]===" "?2:1;g(m,f.slice(c+_),f);return}g(f,"",f)}function g(f,c,m){switch(f){case"event":d=c;break;case"data":l=`${l}${c}
|
|
4
4
|
`;break;case"id":i=c.includes("\0")?void 0:c;break;case"retry":/^\d+$/.test(c)?r(parseInt(c,10)):a(new ps(`Invalid \`retry\` value: "${c}"`,{type:"invalid-retry",value:c,line:m}));break;default:a(new ps(`Unknown field "${f.length>20?`${f.slice(0,20)}\u2026`:f}"`,{type:"unknown-field",field:f,value:c,line:m}));break}}function h(){l.length>0&&e({id:i,event:d||void 0,data:l.endsWith(`
|
|
@@ -17,15 +17,15 @@ ${n}
|
|
|
17
17
|
|
|
18
18
|
`;return a.outputType==="text"&&a.processedContent?i+=`Output:
|
|
19
19
|
${a.processedContent}`:a.outputType==="media"&&(i+=`Media Output: Contains ${a.output.mimetype} content`,a.imageUrl&&(i+=`
|
|
20
|
-
Image URL: ${a.imageUrl}`)),St({type:this.contextType,data:o,details:i})}async getAttachments(e){let a=e[0].data.cellId,r=e[0].data.cellName;return Wd(e.map(s=>s.data.cellOutput),a,r)}};async function Wd(t,e,a){let r=t.filter(n=>n.shouldDownloadImage&&n.outputType==="media");if(r.length===0)return[];let s=r.flatMap(n=>{let o=document.getElementById(
|
|
20
|
+
Image URL: ${a.imageUrl}`)),St({type:this.contextType,data:o,details:i})}async getAttachments(e){let a=e[0].data.cellId,r=e[0].data.cellName;return Wd(e.map(s=>s.data.cellOutput),a,r)}};async function Wd(t,e,a){let r=t.filter(n=>n.shouldDownloadImage&&n.outputType==="media");if(r.length===0)return[];let s=r.flatMap(n=>{let o=document.getElementById(ri.create(e));return o?{cellId:e,cellName:a,mimetype:n.output.mimetype,element:o}:(oe.warn(`Output element not found for cell ${e}`),[])});try{return await Promise.all(s.map(async n=>({type:"file",filename:`${a}-output-screenshot`,mediaType:"image/png",url:await Gi(n.element)})))}catch(n){return oe.error("Error downloading cell output images:",n),[]}}function un(t){if(Wr(t))return null;let e=t.mimetype,a=qd(e,String(t.data))?"media":"text",r=Qi(t),s,n=!1;return a==="media"&&(typeof t.data=="string"&&t.data.startsWith("data:")||typeof t.data=="string"&&t.data.startsWith("http")?s=t.data:n=!0),{processedContent:r,imageUrl:s,shouldDownloadImage:n,outputType:a,output:t}}function cn(t,e,a){let{includeConsoleOutput:r=!1}=a||{},s=e.cellRuntime[t],n=e.cellData[t],o=e.cellIds.inOrderIds.indexOf(t),i=li(n.name,o),l;r&&(l=s.consoleOutputs.map(p=>un(p)).filter(p=>p!==null));let d,u=s.output;return u&&!Wr(u)&&(d=un(u)??void 0),{cellId:t,cellName:i,cellCode:n.code,cellOutput:d,consoleOutputs:l}}function Jd(t){return t.type==="setup-refs"?"The setup cell cannot have references":t.type==="cycle"?"This cell is in a cycle":t.type==="multiple-defs"?`The variable '${t.name}' was defined by another cell`:t.type==="import-star"||t.type==="ancestor-stopped"||t.type==="ancestor-prevented"||t.type==="exception"||t.type==="strict-exception"?t.msg:t.type==="interruption"?"This cell was interrupted and needs to be re-run":t.type==="syntax"||t.type==="unknown"||t.type==="sql-error"?t.msg:t.type==="internal"?t.msg||"An internal error occurred":(zr(t),"Unknown error")}var pn=new ci("error","errors"),Kd=class extends Ot{constructor(e){super();$(this,"title","Errors");$(this,"mentionPrefix","@");$(this,"contextType","error");this.store=e}getItems(){let e=this.store.get(ii);return e.length===0?[]:[{uri:this.asURI("all"),name:"Errors",type:this.contextType,data:{type:"all-errors",errors:e.map(a=>({cellId:a.cellId,cellName:a.cellName,errorData:a.output.data}))},description:"All errors in the notebook"}]}formatCompletion(e){return e.data.type==="all-errors"?{label:"@Errors",displayLabel:"Errors",detail:`${e.data.errors.length} ${pn.pluralize(e.data.errors.length)}`,type:"error",apply:"@Errors",section:yt.ERROR,info:()=>{let a=document.createElement("div");a.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let r=document.createElement("div");r.classList.add("flex","flex-col","gap-1");let s=document.createElement("div");s.classList.add("font-bold","text-base"),s.textContent="Errors",r.append(s);let n=document.createElement("div");return n.classList.add("text-sm","text-muted-foreground"),n.textContent=`${e.data.errors.length} ${pn.pluralize(e.data.errors.length)}`,r.append(n),a.append(r),a}}:{label:"Error",displayLabel:"Error",section:yt.ERROR}}formatContext(e){let{data:a}=e;return a.errors.map(r=>St({type:this.contextType,data:{name:r.cellName||`Cell ${r.cellId}`,description:r.errorData.map(s=>Jd(s)).join(`
|
|
21
21
|
`)}})).join(`
|
|
22
22
|
|
|
23
|
-
`)}};const mn=
|
|
23
|
+
`)}};const mn=Gn();var Yd={maxDepth:3,maxResults:20,defaultResultsLimit:5,includeDirectories:!1},Hd=class extends Ot{constructor(e,a=Yd){super();$(this,"title","Files");$(this,"mentionPrefix","#");$(this,"contextType","file");$(this,"searchFiles",async(e,a={})=>{let{maxDepth:r,maxResults:s,includeDirectories:n}={...this.config,...a};return(await this.apiRequests.sendSearchFiles({query:e,includeFiles:!0,includeDirectories:n,depth:r,limit:s})).files});this.apiRequests=e,this.config=a}createCompletionSource(){return async e=>{let a=e.matchBefore(/#[^\s#]*/);if(!a)return null;let r=a.text;if(!r.startsWith("#"))return null;let s=r.slice(1);if(s.length===0)return this.getDefaultCompletions(a);try{let n=(await this.searchFiles(s)||[]).map(o=>{let i={uri:this.asURI(o.path),name:o.name,type:this.contextType,description:o.isDirectory?"Directory":"File",data:{path:o.path,isDirectory:o.isDirectory}};return this.formatCompletion(i)});return{from:a.from,options:n}}catch(n){return oe.error("Failed to search files:",n),null}}}async getDefaultCompletions(e){try{for(let a of["py","md","csv"])try{let r=await this.searchFiles(a,{maxDepth:1,maxResults:5});if(r&&r.length>0){let s=r.map(n=>{let o={uri:this.asURI(n.path),name:n.name,type:this.contextType,description:n.isDirectory?"Directory":"File",data:{path:n.path,isDirectory:n.isDirectory}};return this.formatCompletion(o)});return{from:e.from,options:s}}}catch(r){oe.error("Failed to get default file completions:",r)}return{from:e.from,options:[]}}catch(a){return oe.error("Failed to get default file completions:",a),null}}getItems(){return[]}formatCompletion(e){let{data:a,name:r}=e,s=a.isDirectory?"\u{1F4C1}":"\u{1F4C4}";return{...this.createBasicCompletion(e),type:"file",section:yt.FILE,boost:a.isDirectory?vt.MEDIUM:vt.LOW,detail:a.path,displayLabel:`${s} ${r}`,apply:async(n,o,i,l)=>{var h;let d=(h=n.state.facet(mn))==null?void 0:h.addAttachment;if(!d){oe.warn("No addAttachment callback provided");return}let u=await this.apiRequests.sendFileDetails({path:a.path}).catch(b=>(Kr({title:"Failed to get file details",description:b.message}),null));if(!u)return;let p=u.mimeType||"text/plain",g;if(p.startsWith("text/")||p.includes("json")||p.includes("xml"))g=new Blob([u.contents||""],{type:p});else if(u.contents)try{g=await Xi(Pi(u.contents,p))}catch{g=new Blob([u.contents],{type:p})}else g=new Blob([""],{type:p});d(new File([g],r,{type:p})),n.dispatch({changes:{from:i,to:l,insert:""}}),Ii(n)},info:()=>{let n=document.createElement("div");n.classList.add("flex","flex-col","gap-1","p-2");let o=document.createElement("div");o.classList.add("font-bold"),o.textContent=r,n.append(o);let i=document.createElement("div");return i.classList.add("text-xs","text-muted-foreground"),i.textContent=a.path,n.append(i),n}}}formatContext(e){let{data:a,name:r}=e;return St({type:this.contextType,data:{name:r,path:a.path,isDirectory:a.isDirectory},details:a.isDirectory?"Directory containing files and subdirectories":"File"})}},Gd=class extends Ot{constructor(e){super();$(this,"title","Tables");$(this,"mentionPrefix","@");$(this,"contextType","data");this.tablesMap=e}getItems(){return[...this.tablesMap.entries()].map(([e,a])=>({uri:this.asURI(e),name:e,type:this.contextType,description:a.source==="memory"?"in-memory":a.source,data:a}))}formatContext(e){let{data:a}=e,{columns:r,source:s,num_rows:n,num_columns:o,name:i,variable_name:l}=a,d=[n==null?void 0:`${n} rows`,o==null?void 0:`${o} columns`].filter(Boolean).join(", "),u="";if(d&&(u+=`Shape: ${d}
|
|
24
24
|
`),l&&(u+=`Variable: ${l}
|
|
25
25
|
`),r&&r.length>0){u+=`Columns:
|
|
26
26
|
`;for(let p of r){let g=` ${p.name} (${p.type})`;if(p.sample_values&&p.sample_values.length>0){let h=p.sample_values.slice(0,3).map(b=>b===null?"null":String(b)).join(", ");g+=` - samples: [${h}]`}u+=`${g}
|
|
27
|
-
`}}return St({type:this.contextType,data:{name:i,source:s??"unknown"},details:u.trim()})}formatCompletion(e){let a=e.data.name,r=e.data;return{label:`@${a}`,displayLabel:a,detail:r.source==="memory"?"in-memory":r.source,boost:r.source_type==="local"?vt.LOCAL_TABLE:vt.REMOTE_TABLE,type:
|
|
28
|
-
`,r);if(s===-1){let d=t.slice(r+3),u=d.indexOf(" "),p=u===-1?d:d.slice(0,u),g=p==="markdown"?"markdown":p==="sql"?"sql":"python",h=u===-1?"":d.slice(u+1);h.trim()&&e.push({language:g,code:h.trim()});break}let n=t.slice(r+3,s).trim()||"";n=n==="markdown"?"markdown":n==="sql"?"sql":"python";let o=s+1,i=t.indexOf("```",o);if(i===-1){let d=t.slice(o).replace(/\n+$/,"");d.trim()&&e.push({language:n,code:d});break}let l=t.slice(o,i).replace(/\n+$/,"");l.trim()&&e.push({language:n,code:l}),a=i+3,r=t.indexOf("```",a)}return e.length===0&&e.push({language:"python",code:t}),e}var ou=Ea(),hn=()=>new Map,{valueAtom:Zt,useActions:fn,createActions:Bc,reducer:Wc}=Ci(hn,{addStagedCell:(t,e)=>{let{cellId:a,edit:r}=e;return new Map([...t,[a,r]])},removeStagedCell:(t,e)=>{let a=new Map(t);return a.delete(e),a},clearStagedCells:()=>hn()});function gn(t){let e=(0,ou.c)(27),{addStagedCell:a,removeStagedCell:r,clearStagedCells:s}=fn(),{createNewCell:n,updateCellCode:o}
|
|
27
|
+
`}}return St({type:this.contextType,data:{name:i,source:s??"unknown"},details:u.trim()})}formatCompletion(e){let a=e.data.name,r=e.data;return{label:`@${a}`,displayLabel:a,detail:r.source==="memory"?"in-memory":r.source,boost:r.source_type==="local"?vt.LOCAL_TABLE:vt.REMOTE_TABLE,type:jr(r),apply:`@${a}`,section:{name:jr(r)==="dataframe"?"Dataframe":"Table",rank:yt.TABLE.rank},info:()=>this.createTableInfoElement(a,r)}}createTableInfoElement(e,a){let r=document.createElement("div");r.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let s=document.createElement("div");s.classList.add("flex","flex-col","gap-1");let n=document.createElement("div");if(n.classList.add("font-bold","text-base"),n.textContent=e,s.append(n),a.source){let i=document.createElement("div");i.classList.add("text-xs","text-muted-foreground"),i.textContent=`Source: ${a.source}`,s.append(i)}r.append(s);let o=[a.num_rows==null?void 0:`${a.num_rows} rows`,a.num_columns==null?void 0:`${a.num_columns} columns`].filter(Boolean).join(", ");if(o){let i=document.createElement("div");i.classList.add("text-xs","bg-muted","px-2","py-1","rounded"),i.textContent=o,r.append(i)}if(a.columns&&a.columns.length>0){let i=document.createElement("div");i.classList.add("overflow-auto","max-h-60");let l=document.createElement("table");l.classList.add("w-full","text-xs","border-collapse");let d=l.insertRow();d.classList.add("bg-muted");let u=d.insertCell();u.classList.add("p-2","font-medium","text-left"),u.textContent="Column";let p=d.insertCell();p.classList.add("p-2","font-medium","text-left"),p.textContent="Type";let g=a.columns.some(b=>this.getItemMetadata(a,b)!==void 0),h;g&&(h=d.insertCell(),h.classList.add("p-2","font-medium","text-left"),h.textContent="Metadata"),a.columns.forEach((b,f)=>{let c=l.insertRow();c.classList.add(f%2==0?"bg-background":"bg-muted/30");let m=c.insertCell();m.classList.add("p-2","font-mono"),m.textContent=b.name;let _=c.insertCell();if(_.classList.add("p-2","text-muted-foreground"),_.textContent=b.type,g){let E=c.insertCell();E.classList.add("p-2");let C=this.getItemMetadata(a,b);C&&E.append(C)}}),i.append(l),r.append(i)}return r}getItemMetadata(e,a){var n,o;let r=(n=e.primary_keys)==null?void 0:n.includes(a.name),s=(o=e.indexes)==null?void 0:o.includes(a.name);if(r||s){let i=document.createElement("span");i.textContent=r?"PK":"IDX";let l=r?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200";return i.classList.add("text-xs","px-1.5","py-0.5","rounded-full","font-medium",...l.split(" ")),i}}},Qd=class extends Ot{constructor(e,a){super();$(this,"title","Variables");$(this,"mentionPrefix","@");$(this,"contextType","variable");this.variables=e,this.tablesMap=a}getItems(){let e=new Set(this.tablesMap.keys());return Object.entries(this.variables).flatMap(([a,r])=>e.has(a)?[]:[{uri:this.asURI(a),name:a,type:this.contextType,description:r.dataType??"",dataType:r.dataType,data:{variable:r}}])}formatCompletion(e){let{data:a}=e,{variable:r}=a;return{label:`@${r.name}`,displayLabel:r.name,detail:r.dataType??"",type:this.contextType,section:yt.VARIABLE,info:()=>oi(r)}}formatContext(e){let{data:a}=e,{variable:r}=a;return St({type:this.contextType,data:{name:r.name,dataType:r.dataType},details:r.value==null?void 0:JSON.stringify(r.value)})}};function mt(t){let e=t.get(Hn),a=t.get(ti),r=t.get(ni);return new Ui().register(new Gd(a)).register(new Qd(r,a)).register(new Kd(t)).register(new Bd(t)).register(new Vi(e.connectionsMap,a))}function Xd(){return new Hd(Ai())}const eu="@";function tu({input:t}){let e="";return t.includes("@")&&(e=ru(t),oe.debug("Included context",e)),{includeOtherCode:Pr(""),context:{plainText:e,schema:[],variables:[]}}}async function au({input:t}){let e="",a=[];if(t.includes("@")){let r=mt(Nr),s=r.parseAllContextIds(t);e=r.formatContextForAI(s);try{a=await r.getAttachmentsForContext(s),oe.debug("Included attachments",a.length)}catch(n){oe.error("Error getting attachments:",n)}}return{body:{includeOtherCode:Pr(""),context:{plainText:e,schema:[],variables:[]}},attachments:a}}function ru(t){let e=mt(Nr),a=e.parseAllContextIds(t);return e.formatContextForAI(a)}function su(t,e=[]){return a=>{let r=t.map(s=>a.matchBefore(s)).find(Boolean);return!r||r&&r.from===r.to&&!a.explicit?null:{from:r==null?void 0:r.from,options:[...e]}}}function nu(t){var e;if((e=t.current)!=null&&e.view){let a=t.current.view.state.selection.main.from;t.current.view.dispatch({changes:{from:a,to:a,insert:"@"},selection:{anchor:a+1,head:a+1}}),t.current.view.focus(),Ei(t.current.view)}}function iu(t){if(t.trim().length===0)return[];if(!t.includes("```"))return[{language:"python",code:t}];let e=[],a=0,r=t.indexOf("```",a);for(;r!==-1;){let s=t.indexOf(`
|
|
28
|
+
`,r);if(s===-1){let d=t.slice(r+3),u=d.indexOf(" "),p=u===-1?d:d.slice(0,u),g=p==="markdown"?"markdown":p==="sql"?"sql":"python",h=u===-1?"":d.slice(u+1);h.trim()&&e.push({language:g,code:h.trim()});break}let n=t.slice(r+3,s).trim()||"";n=n==="markdown"?"markdown":n==="sql"?"sql":"python";let o=s+1,i=t.indexOf("```",o);if(i===-1){let d=t.slice(o).replace(/\n+$/,"");d.trim()&&e.push({language:n,code:d});break}let l=t.slice(o,i).replace(/\n+$/,"");l.trim()&&e.push({language:n,code:l}),a=i+3,r=t.indexOf("```",a)}return e.length===0&&e.push({language:"python",code:t}),e}var ou=Ea(),hn=()=>new Map,{valueAtom:Zt,useActions:fn,createActions:Bc,reducer:Wc}=Ci(hn,{addStagedCell:(t,e)=>{let{cellId:a,edit:r}=e;return new Map([...t,[a,r]])},removeStagedCell:(t,e)=>{let a=new Map(t);return a.delete(e),a},clearStagedCells:()=>hn()});function gn(t){let e=(0,ou.c)(27),{addStagedCell:a,removeStagedCell:r,clearStagedCells:s}=fn(),{createNewCell:n,updateCellCode:o}=$r(),i=eo(),l=(0,A.useRef)(null),d;e[0]!==a||e[1]!==n?(d=C=>{let I=Mr.create();return a({cellId:I,edit:{type:"add_cell"}}),n({cellId:"__end__",code:C,before:!1,newCellId:I}),I},e[0]=a,e[1]=n,e[2]=d):d=e[2];let u=d,p;e[3]!==t||e[4]!==o?(p=C=>{let{cellId:I,code:P}=C;if(!t.get(Zt).has(I)){oe.error("Staged cell not found",{cellId:I});return}let D=si(I);D?Ca(D,P):o({cellId:I,code:P,formattingChange:!1})},e[3]=t,e[4]=o,e[5]=p):p=e[5];let g=p,h;e[6]!==i||e[7]!==r?(h=C=>{r(C),i({cellId:C})},e[6]=i,e[7]=r,e[8]=h):h=e[8];let b=h,f;e[9]!==s||e[10]!==i||e[11]!==t?(f=()=>{let C=t.get(Zt);for(let I of C.keys())i({cellId:I});s()},e[9]=s,e[10]=i,e[11]=t,e[12]=f):f=e[12];let c=f,m;e[13]!==a||e[14]!==n||e[15]!==u||e[16]!==g?(m=C=>{e:switch(C.type){case"text-start":l.current=new lu(u,g,a,n);break e;case"text-delta":if(!l.current){oe.error("Cell creation stream not found");return}l.current.stream(C);break e;case"text-end":case"finish":if(!l.current){oe.error("Cell creation stream not found");return}l.current.stop();break e;case"abort":case"error":case"tool-input-error":case"tool-output-error":oe.error("Error",C.type,{chunk:C});break e;case"start":case"start-step":case"finish-step":case"data-reasoning-signature":break e;case"message-metadata":case"tool-input-available":case"tool-output-available":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"file":case"source-document":case"source-url":case"tool-input-start":case"tool-input-delta":oe.debug(C.type,{chunk:C});break e;default:if(du(C)){oe.debug("Data chunk",{chunk:C});break e}zr(C)}},e[13]=a,e[14]=n,e[15]=u,e[16]=g,e[17]=m):m=e[17];let _=m,E;return e[18]!==a||e[19]!==s||e[20]!==u||e[21]!==c||e[22]!==b||e[23]!==_||e[24]!==r||e[25]!==g?(E={createStagedCell:u,updateStagedCell:g,addStagedCell:a,removeStagedCell:r,clearStagedCells:s,deleteStagedCell:b,deleteAllStagedCells:c,onStream:_},e[18]=a,e[19]=s,e[20]=u,e[21]=c,e[22]=b,e[23]=_,e[24]=r,e[25]=g,e[26]=E):E=e[26],E}var lu=class{constructor(t,e,a,r){$(this,"createdCells",[]);$(this,"buffer","");$(this,"hasMarimoImport",!1);this.onCreateCell=t,this.onUpdateCell=e,this.addStagedCell=a,this.createNewCell=r}stream(t){let e=t.delta;this.buffer+=e;let a=iu(this.buffer);for(let[r,s]of a.entries())if(r<this.createdCells.length){this.addMarimoImport(s.language);let n=this.createdCells[r];this.createdCells[r]={...n,cell:s},this.onUpdateCell({cellId:n.cellId,code:s.code,language:s.language})}else{let n=this.onCreateCell(s.code);this.createdCells.push({cellId:n,cell:s})}}addMarimoImport(t){var a;if(this.hasMarimoImport||t==="python")return;let e=Hi({autoInstantiate:!1,createNewCell:this.createNewCell,fromCellId:(a=this.createdCells[0])==null?void 0:a.cellId,before:!0});e&&this.addStagedCell({cellId:e,edit:{type:"add_cell"}}),this.hasMarimoImport=!0}stop(){this.buffer=""}};function du(t){return t.type.startsWith("data-")}var uu={baseDescription:"Perform editing operations on the current notebook. You should prefer to create new cells unless you need to edit existing cells. Call this tool multiple times to perform multiple edits. Separate code into logical individual cells to take advantage of the notebook's reactive execution model.",prerequisites:["If you are updating existing cells, you need the cellIds. If they are not known, call the lightweight_cell_map_tool to find out."],additionalInfo:`
|
|
29
29
|
Args:
|
|
30
30
|
edit (object): The editing operation to perform with the following structure:
|
|
31
31
|
- type: One of "update_cell", "add_cell", or "delete_cell"
|
|
@@ -49,7 +49,7 @@ Image URL: ${a.imageUrl}`)),St({type:this.contextType,data:o,details:i})}async g
|
|
|
49
49
|
- SQL cells: use mo.sql(f"""{content}""") function to insert content. If a database engine is specified, use mo.sql(f"""{content}""", engine=engine) instead.
|
|
50
50
|
|
|
51
51
|
Returns:
|
|
52
|
-
- A result object containing standard tool metadata.`},cu=Q({edit:Q({type:Bt(["update_cell","add_cell","delete_cell"]),code:k().optional(),position:Q({type:Bt(["relative","column_end","notebook_end"]).optional(),cellId:k().optional(),columnIndex:Zr().optional(),before:de().optional()})})}),pu=class{constructor(){$(this,"name","edit_notebook_tool");$(this,"description",uu);$(this,"schema",cu);$(this,"outputSchema",dn);$(this,"mode",["agent"]);$(this,"handler",async({edit:t},e)=>{let{addStagedCell:a,createNewCell:r,store:s}=e;switch(t.type){case"update_cell":{let{position:n,code:o}=t,i=n.cellId;if(i){if(!o)throw new we("Code is required for update_cell","CODE_REQUIRED_FOR_UPDATE_CELL",!0,"Provide the new code to update the cell")}else throw new we("Cell ID is required for update_cell","CELL_ID_REQUIRED_FOR_UPDATE_CELL",!0,"Provide a cell ID to update");let l=s.get(Ge);this.validateCellIdExists(i,l);let d=this.getCellEditorView(i,l);Sa(i);let u=s.get(Zt).get(i);if((u==null?void 0:u.type)==="add_cell"){Ca(d,o);break}let p=d.state.doc.toString();a({cellId:i,edit:{type:"update_cell",previousCode:(u==null?void 0:u.previousCode)??p}}),Ca(d,o);break}case"add_cell":{let{position:n,code:o}=t,i="__end__",l=!1,d=
|
|
52
|
+
- A result object containing standard tool metadata.`},cu=Q({edit:Q({type:Bt(["update_cell","add_cell","delete_cell"]),code:k().optional(),position:Q({type:Bt(["relative","column_end","notebook_end"]).optional(),cellId:k().optional(),columnIndex:Zr().optional(),before:de().optional()})})}),pu=class{constructor(){$(this,"name","edit_notebook_tool");$(this,"description",uu);$(this,"schema",cu);$(this,"outputSchema",dn);$(this,"mode",["agent"]);$(this,"handler",async({edit:t},e)=>{let{addStagedCell:a,createNewCell:r,store:s}=e;switch(t.type){case"update_cell":{let{position:n,code:o}=t,i=n.cellId;if(i){if(!o)throw new we("Code is required for update_cell","CODE_REQUIRED_FOR_UPDATE_CELL",!0,"Provide the new code to update the cell")}else throw new we("Cell ID is required for update_cell","CELL_ID_REQUIRED_FOR_UPDATE_CELL",!0,"Provide a cell ID to update");let l=s.get(Ge);this.validateCellIdExists(i,l);let d=this.getCellEditorView(i,l);Sa(i);let u=s.get(Zt).get(i);if((u==null?void 0:u.type)==="add_cell"){Ca(d,o);break}let p=d.state.doc.toString();a({cellId:i,edit:{type:"update_cell",previousCode:(u==null?void 0:u.previousCode)??p}}),Ca(d,o);break}case"add_cell":{let{position:n,code:o}=t,i="__end__",l=!1,d=Mr.create(),u=s.get(Ge);switch(n.type){case"relative":{let p=n.cellId;if(!p)throw new we("Cell ID is required for add_cell with relative position","TOOL_ERROR",!0,"Provide a cell ID to add the cell before");if(n.before===void 0)throw new we("Before is required for add_cell with relative position","TOOL_ERROR",!0,`Provide a boolean value for before, true to add before cell ${p}, false to add after the cell`);this.validateCellIdExists(p,u),i=p,l=n.before;break}case"column_end":if(!n.columnIndex)throw new we("Column index is required for add_cell with column_end position","TOOL_ERROR",!0,"Provide a column index to add the cell at the end of");i={type:"__end__",columnId:this.getColumnId(n.columnIndex,u)};break;case"notebook_end":break}r({cellId:i,before:l,code:o,newCellId:d}),a({cellId:d,edit:{type:"add_cell"}}),Sa(d);break}case"delete_cell":{let{position:n}=t,o=n.cellId;if(!o)throw new we("Cell ID is required for delete_cell","CELL_ID_REQUIRED_FOR_DELETE_CELL",!0,"Provide a cell ID to delete");let i=s.get(Ge);this.validateCellIdExists(o,i),a({cellId:o,edit:{type:"delete_cell",previousCode:this.getCellEditorView(o,i).state.doc.toString()}}),Sa(o);break}}return{status:"success",next_steps:["If you need to perform more edits, call this tool again.","You should use the lint notebook tool to check for errors and lint issues. Fix them by editing the notebook.","You should use the run stale cells tool to run the cells that have been edited or newly added. This allows you to see the output of the cells and fix any errors."]}})}validateCellIdExists(t,e){if(!e.cellIds.getColumns().some(a=>a.idSet.has(t)))throw new we("Cell not found","CELL_NOT_FOUND",!1,"Check which cells exist in the notebook")}getColumnId(t,e){let a=e.cellIds.getColumns();if(t<0||t>=a.length)throw new we("Column index is out of range","COLUMN_INDEX_OUT_OF_RANGE",!0,"Choose a column index between 0 and the number of columns in the notebook (0-based)");return a[t].id}getCellEditorView(t,e){let a=e.cellHandles[t].current;if(!(a!=null&&a.editorView))throw new we("Cell editor not found","CELL_EDITOR_NOT_FOUND",!1,"Internal error, ask the user to report this error");return a.editorView}},mu=200,hu=3e4,fu={baseDescription:"Run cells in the current notebook that are stale. Stale cells are cells that have been edited or newly added. You can run this tool after editing the notebook or when requested. The output of the ran cells will be returned alongside metadata."},yn=Q({type:N("file"),url:k(),mediaType:k()}),gu=class{constructor(t){$(this,"name","run_stale_cells_tool");$(this,"description",fu);$(this,"schema",Q({}));$(this,"outputSchema",dn.extend({cellsToOutput:It(k(),Q({consoleOutput:k().optional(),cellOutput:k().optional(),consoleAttachments:Ve(yn).optional(),cellAttachments:Ve(yn).optional()}).nullable()).optional()}));$(this,"mode",["agent"]);$(this,"handler",async(t,e)=>{let{prepareForRun:a,sendRun:r,store:s}=e,n=s.get(Ge),o=ai(n);if(o.length===0)return{status:"success",message:"No stale cells found."};if(await Yi({cellIds:o,sendRun:r,prepareForRun:a,notebook:n}),!await this.waitForCellsToFinish(s,o,hu,this.postExecutionDelay))return{status:"success",message:"No output was returned because some cells have not finished executing"};let i=s.get(Ge),l=new Map,d="",u=!1;for(let g of o){let h=cn(g,i,{includeConsoleOutput:!0}),b,f,c=h.cellOutput,m=h.consoleOutputs,_=m&&m.length>0;if(!c&&!_){l.set(g,null);continue}c&&(b=this.formatOutputString(c),this.outputHasErrors(c)&&(u=!0)),_&&(f=m.map(E=>this.formatOutputString(E)).join(`
|
|
53
53
|
`),d+="Console output represents the stdout or stderr of the cell (eg. print statements).",m.some(E=>this.outputHasErrors(E))&&(u=!0)),l.set(g,{cellOutput:b,consoleOutput:f})}if(l.size===0)return{status:"success",message:"Stale cells have been run. No output was returned."};let p=["Review the output of the cells. The CellId is the key of the result object.",u?"There are errors in the cells. Please fix them by using the edit notebook tool and the given CellIds.":"You may edit the notebook further with the given CellIds."];return{status:"success",cellsToOutput:Object.fromEntries(l),message:d===""?void 0:d,next_steps:p}});this.postExecutionDelay=(t==null?void 0:t.postExecutionDelay)??mu}outputHasErrors(t){let{output:e}=t;return e.mimetype==="application/vnd.marimo+error"||e.mimetype==="application/vnd.marimo+traceback"}formatOutputString(t){let e="",{outputType:a,processedContent:r,imageUrl:s,output:n}=t;return a==="text"?(e+=`Output:
|
|
54
54
|
`,r?e+=r:typeof n.data=="string"?e+=n.data:e+=JSON.stringify(n.data)):a==="media"&&(e+=`Media Output: Contains ${n.mimetype} content`,s&&(e+=`
|
|
55
55
|
Image URL: ${s}`)),e}async waitForCellsToFinish(t,e,a,r){let s=o=>e.every(i=>{let l=o.cellRuntime[i];return(l==null?void 0:l.status)!=="running"&&(l==null?void 0:l.status)!=="queued"}),n=async()=>(r>0&&await new Promise(o=>setTimeout(o,r)),!0);if(s(t.get(Ge)))return await n();try{return await Promise.race([Jn(Ge,s),new Promise((o,i)=>setTimeout(()=>i(Error("timeout")),a))]),await n()}catch{return!1}}};function yu(t){let e=t.baseDescription;return t.whenToUse&&(e+=`
|
|
@@ -71,7 +71,7 @@ Image URL: ${s}`)),e}async waitForCellsToFinish(t,e,a,r){let s=o=>e.every(i=>{le
|
|
|
71
71
|
- `)}`),t.additionalInfo&&(e+=`
|
|
72
72
|
|
|
73
73
|
## Additional info:
|
|
74
|
-
- ${t.additionalInfo}`),e}var vn,Ft;function vu(t,e,a,r,s){var n={};return Object.keys(r).forEach(function(o){n[o]=r[o]}),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=a.slice().reverse().reduce(function(o,i){return i(t,e,o)||o},n),s&&n.initializer!==void 0&&(n.value=n.initializer?n.initializer.call(s):void 0,n.initializer=void 0),n.initializer===void 0?(Object.defineProperty(t,e,n),null):n}const _r=new(vn=
|
|
74
|
+
- ${t.additionalInfo}`),e}var vn,Ft;function vu(t,e,a,r,s){var n={};return Object.keys(r).forEach(function(o){n[o]=r[o]}),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=a.slice().reverse().reduce(function(o,i){return i(t,e,o)||o},n),s&&n.initializer!==void 0&&(n.value=n.initializer?n.initializer.call(s):void 0,n.initializer=void 0),n.initializer===void 0?(Object.defineProperty(t,e,n),null):n}const _r=new(vn=Qn(),Ft=class{constructor(t=[]){$(this,"tools",new Map);this.tools=new Map(t.map(e=>[e.name,e]))}has(t){return this.tools.has(t)}getToolOrThrow(t){let e=this.tools.get(t);if(!e)throw Error(`Tool ${t} not found`);return e}async invoke(t,e,a){var i;let r=this.getToolOrThrow(t),s=r.handler,n=r.schema,o=r.outputSchema;try{let l=await n.safeParseAsync(e);if(l.error)throw new we(`Tool ${t} returned invalid input: ${Dr(l.error)}`,"INVALID_ARGUMENTS",!0,"Please check the arguments and try again.");let d=l.data,u=await s(d,a),p=await o.safeParseAsync(u);if(p.error){let g=Dr(p.error);throw Error(`Tool ${t} returned invalid output: ${g}`)}return{tool_name:t,result:p.data,error:null}}catch(l){return l instanceof we?{tool_name:t,result:null,error:l.toStructuredString()}:{tool_name:t,result:null,error:new we(l instanceof Error?l.message:String(l),"TOOL_ERROR",!1,"Check the error message and try again with valid arguments.",{args:e,errorType:((i=l==null?void 0:l.constructor)==null?void 0:i.name)??typeof l}).toStructuredString()}}}getToolSchemas(t){return[...this.tools.values()].filter(e=>e.mode.includes(t)).map(e=>({name:e.name,description:yu(e.description),parameters:Fr(e.schema),source:"frontend",mode:e.mode}))}},vu(Ft.prototype,"getToolSchemas",[vn],Object.getOwnPropertyDescriptor(Ft.prototype,"getToolSchemas"),Ft.prototype),Ft)([new pu,new gu]);function br(t,e){return new Promise(a=>{let r=new FileReader;r.readAsDataURL(t),r.onload=s=>{var n;if((n=s.target)!=null&&n.result){let o=s.target.result;a(e==="base64"?o.slice(o.indexOf(",")+1):o)}}})}function _u(t){return Promise.all(t.map(e=>br(e,"base64").then(a=>[e.name,a])))}function bu(t){return t.length>50?`${t.slice(0,50)}...`:t}async function xu(t){return await Promise.all(t.map(async e=>({type:"file",mediaType:e.type,filename:e.name,url:await br(e,"dataUrl")})))}function wu(t){if(t.length===0)return!1;let e=t.at(-1);if(!e||e.role!=="assistant"||!e.parts)return!1;let a=e.parts;return a.length===0?!1:a[a.length-1].type==="reasoning"}function _n(t){return t.map(e=>e.type==="text"?e.text:"").join(`
|
|
75
75
|
`)}async function bn(t){let e=await au({input:_n(t.flatMap(s=>s.parts))});function a(s,n){return n?{...s,parts:[...s.parts,...e.attachments]}:s}function r(s,n){let o=[...s.parts];return n&&o.push(...e.attachments),{id:s.id,role:s.role,content:_n(s.parts),parts:o}}return{...e.body,messages:t.map((s,n)=>r(s,n===t.length-1)),uiMessages:t.map((s,n)=>a(s,n===t.length-1))}}async function xn({invokeAiTool:t,addToolOutput:e,toolCall:a,toolContext:r}){try{if(_r.has(a.toolName)){let s=await _r.invoke(a.toolName,a.input,r);e({tool:a.toolName,toolCallId:a.toolCallId,output:s.result||s.error})}else{let s=await t({toolName:a.toolName,arguments:a.input??{}});e({tool:a.toolName,toolCallId:a.toolCallId,output:s.result||s.error})}}catch(s){oe.error("Tool call failed:",s),e({tool:a.toolName,toolCallId:a.toolCallId,output:`Error: ${s instanceof Error?s.message:String(s)}`})}}function ku(t){var i;if(t.length===0)return!1;let e=t[t.length-1],a=e.parts;if(a.length===0||e.role!=="assistant")return!1;let r=a.filter(l=>l.type.startsWith("tool-"));if(r.length===0)return!1;let s=r.every(l=>l.state==="output-available"),n=a[a.length-1],o=n.type==="text"&&((i=n.text)==null?void 0:i.trim().length)>0;return oe.warn("All tool calls completed: %s",s),s&&!o}function Cu(t){return bi.define({combine:e=>e[0]??t})}var wn=Cu({}),xr=Yt.define(),ba=Yt.define(),Eu=50,wr=Jt.define({create(){return{prompts:[],navigationIndex:-1,originalText:""}},update(t,e){var r,s;let a={...t};e.docChanged&&t.navigationIndex!==-1&&(e.effects.some(n=>n.is(ba)||n.is(xr))||(a.navigationIndex=-1,a.originalText=""));for(let n of e.effects)if(n.is(xr)){let o=n.value.trim();o&&(a.prompts=[o,...t.prompts.filter(i=>i!==o)].slice(0,Eu),(s=(r=e.state.facet(wn)).save)==null||s.call(r,a.prompts)),a.navigationIndex=-1,a.originalText=""}else n.is(ba)&&(a.navigationIndex=n.value.index,a.originalText=n.value.originalText);return a}}),Tu=t=>{let e=t.state.field(wr),a=t.state.doc;if(e.prompts.length===0)return!1;let r,s=e.originalText;if(e.navigationIndex===-1){if(a.length>0)return!1;r=0,s=a.toString()}else if(r=Math.min(e.navigationIndex+1,e.prompts.length-1),r===e.navigationIndex)return!1;let n=e.prompts[r];return t.dispatch({changes:{from:0,to:t.state.doc.length,insert:n},effects:ba.of({index:r,originalText:s})}),!0},Iu=t=>{let e=t.state.field(wr);if(e.navigationIndex===-1)return!1;let a,r;return e.navigationIndex===0?(a=e.originalText,r=-1):(r=e.navigationIndex-1,a=e.prompts[r]??""),t.dispatch({changes:{from:0,to:t.state.doc.length,insert:a},effects:ba.of({index:r,originalText:e.originalText})}),!0};const kn=t=>{let e=t.state.doc.toString();return e.trim()?(t.dispatch({effects:xr.of(e)}),!0):!1};function Su(t={}){let{storage:e,defaultKeymap:a=!0}=t,r=[wr.init(()=>{var s;return{prompts:((s=e==null?void 0:e.load)==null?void 0:s.call(e))??[],navigationIndex:-1,originalText:""}}),wn.of(e??{})];return a&&r.push(Kt.of([{key:"ArrowUp",run:Tu},{key:"ArrowDown",run:Iu}])),r}const kr=Yt.define(),Ke=Jt.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(kr)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}}),Ou=Jt.define({create(){return{onResourceClick:void 0,onResourceMouseOver:void 0,onResourceMouseOut:void 0,onPromptSubmit:void 0}},update(t){return t}}),Au=Yt.define();Jt.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(Au)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}});const Ru=(t,e)=>async a=>{let r=a.matchBefore(/@(\w+)?/);if(!r||r.from===r.to&&!a.explicit)return null;let s=await t();if(s.length===0)return null;let n=kr.of(new Map(s.map(i=>[i.uri,i])));a.view&&a.view.dispatch({effects:n});let o=s.map(i=>({label:`@${i.name}`,displayLabel:i.name,detail:i.uri,info:i.description||void 0,type:i.mimeType?"constant":"variable",boost:i.description?100:0,...e==null?void 0:e(i),apply:(l,d,u,p)=>{l.dispatch({changes:{from:u,to:p,insert:`@${i.uri} `}})}}));return{from:r.from,options:o}},Nu=/@[\w-]+:\/\/(?!\/)[^\s]+/;function st(t){return t.matchAll(new RegExp(Nu.source,"g"))}var Mu=class extends Br{constructor(e,a){super();$(this,"resource");$(this,"view");this.resource=e,this.view=a}eq(e){return e.resource.uri===this.resource.uri}toDOM(){let e=document.createElement("span");e.className="cm-resource-widget",e.textContent=`@${this.resource.name}`;let a=this.view.state.field(Ou,!1),r=a==null?void 0:a.onResourceClick,s=a==null?void 0:a.onResourceMouseOver,n=a==null?void 0:a.onResourceMouseOut;return r&&(e.style.cursor="pointer",e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),r(this.resource)})),s&&e.addEventListener("mouseover",o=>{o.preventDefault(),o.stopPropagation(),s(this.resource)}),n&&e.addEventListener("mouseout",o=>{o.preventDefault(),o.stopPropagation(),n(this.resource)}),e}},Pu=class extends Br{constructor(e,a){super();$(this,"uri");$(this,"view");this.uri=e,this.view=a}eq(e){return e.uri===this.uri}toDOM(){let e=document.createElement("span");return e.className="cm-not-found-resource-widget",e.textContent=`@${this.uri.split("://")[1]??this.uri}`,e}};function Cn(t){let e=t.state.field(Ke),a=[];for(let{from:r,to:s}of t.visibleRanges){let n=t.state.doc.sliceString(r,s);for(let o of st(n)){let i=r+o.index,l=o[0].slice(1),d=e.get(l);d?a.push(Ta.replace({widget:new Mu(d,t)}).range(i,i+o[0].length)):a.push(Ta.replace({widget:new Pu(l,t)}).range(i,i+o[0].length))}}return Ta.set(a)}const ju=wi.fromClass(class{constructor(t){$(this,"decorations");this.decorations=Cn(t)}update(t){(t.docChanged||t.viewportChanged||t.transactions.some(e=>e.effects.some(a=>a.is(kr))))&&(this.decorations=Cn(t.view))}},{decorations:t=>t.decorations});function $u(t){let e=document.createElement("div");e.className="cm-tooltip-cursor";let a=document.createElement("div");if(a.className="cm-tooltip-cursor-title",a.textContent=`${t.name} (${t.uri})`,e.appendChild(a),t.description){let r=document.createElement("div");r.className="cm-tooltip-cursor-description",r.textContent=t.description,e.appendChild(r)}if(t.mimeType){let r=document.createElement("div");r.className="cm-tooltip-cursor-mimetype",r.textContent=t.mimeType,e.appendChild(r)}return{dom:e}}function Lu(t,e,a,r=0){for(let s of st(t)){let n=r+s.index,o=n+s[0].length;if(e>=n&&e<=o){let i=s[0].slice(1),l=a.get(i);if(l)return{resource:l,start:n,end:o}}}return null}function Du(t){return ki((e,a)=>{let{from:r,text:s}=e.state.doc.lineAt(a),n=Lu(s,a,e.state.field(Ke),r);return n?{pos:n.start,end:n.end,above:!0,create(){return(t.createTooltip??$u)(n.resource)}}:null})}function Zu(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(st(n));if(o.length===0)return null;for(let i of o){let l=s.from+i.index,d=l+i[0].length,u=i[0].slice(1);if(e===d&&a.has(u))return{from:l,to:d,uri:u}}return null}function Fu(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e).to,n=r.sliceString(e,s),o=Array.from(st(n));if(o.length===0)return null;let i=o[0];if(!i||i.index!==0)return null;let l=e,d=e+i[0].length,u=i[0].slice(1);return a.has(u)?{from:l,to:d,uri:u}:null}function En(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(st(n));for(let i of o){let l=s.from+i.index,d=l+i[0].length,u=i[0].slice(1);if(e>l&&e<d&&a.has(u))return{from:l,to:d,uri:u}}return null}function zu(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,e),o=Array.from(st(n)),i=null;for(let l of o){let d=s.from+l.index,u=d+l[0].length,p=l[0].slice(1);a.has(p)&&u<=e&&(e>u?i=u:e===u&&(i=d))}return i}function Uu(t,e){let a=t.field(Ke),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(st(n));for(let i of o){let l=s.from+i.index,d=l+i[0].length,u=i[0].slice(1);if(a.has(u)&&l>=e){if(e<l)return l;if(e===l)return d}}return null}const Vu=_i.transactionFilter.of(t=>{var r;let e=t.annotation(xi.userEvent);if(!e)return t;let a=t.startState.selection.main;if(!a.empty)return t;if(e==="input.type"||e.startsWith("input")){if(t.changes.empty)return t;let s=t.startState.field(Ke),n=t.startState.doc,o=!1,i=0,l=[];if(t.changes.iterChanges((d,u,p,g,h)=>{let b=h.toString(),f=d;if(/^\s+$/.test(b)){l.push({from:d,to:u,insert:b});return}let c=n.lineAt(f),m=n.sliceString(c.from,c.to),_=Array.from(st(m)),E=!1,C=!1;for(let P of _){let D=c.from+P.index,M=D+P[0].length,H=P[0].slice(1);if(s.has(H)){if(f===D){let j=f>0?n.sliceString(f-1,f):"";j!==""&&j!==" "&&j!==`
|
|
76
76
|
`&&j!==" "&&(E=!0)}if(f===M){let j=f<n.length?n.sliceString(f,f+1):"";(j===""||j!==" "&&j!==`
|
|
77
77
|
`&&j!==" ")&&(C=!0)}}}let I=b;E&&(I=` ${I}`,i+=1),C&&(I=` ${I}`,i+=1),I!==b&&(o=!0),l.push({from:d,to:u,insert:I})}),o)return[{changes:l,selection:t.selection?{anchor:t.selection.main.anchor+i,head:t.selection.main.head+i}:void 0,scrollIntoView:t.scrollIntoView}]}if(e==="delete.backward"||e==="delete.forward"){let s=null;return e==="delete.backward"?s=Zu(t.startState,a.head):e==="delete.forward"&&(s=Fu(t.startState,a.head)),s?[{changes:{from:s.from,to:s.to,insert:""},selection:{anchor:s.from},scrollIntoView:!0}]:t}if((r=t.selection)!=null&&r.main.empty&&a.empty&&!e.startsWith("input")&&e!=="input.type"){let s=a.head,n=t.selection.main.head,o=null;if(n<s){let i=En(t.startState,s);o=i&&s>i.from?i.from:zu(t.startState,s)}else if(n>s){let i=En(t.startState,s);o=i&&s<i.to?i.to:Uu(t.startState,s)}if(o!==null&&o!==n)return[{selection:{anchor:o},scrollIntoView:!0}]}return t}),qu=qr.baseTheme({".cm-resource-widget":{background:"light-dark(rgba(86,156,214,0.08),rgba(86,156,214,0.18))",borderRadius:"4px",padding:"2px 4px",color:"light-dark(#2367a2,#7ecbff)",fontWeight:"500"},".cm-resource-widget:hover":{background:"light-dark(rgba(86,156,214,0.18),rgba(86,156,214,0.28))"},".cm-not-found-resource-widget":{background:"light-dark(rgba(151,151,151,0.08),rgba(151,151,151,0.18))",borderRadius:"4px",padding:"2px 4px",color:"light-dark(#b00020,#ff8080)",fontWeight:"500"}});var Tn="_none_",Bu=[{uri:"",name:"No resources",type:Tn,data:{}}],Wu={info:"Variables, dataframes, and tables will appear here.",apply:()=>{}};function Ju(t){let{language:e,store:a,onAddFiles:r}=t;return[e.data.of({autocomplete:Ru(async()=>{let s=mt(a).getAllItems();return s.length===0?Bu:s},s=>{var n;return s.type===Tn?Wu:((n=mt(a).getProvider(s.type))==null?void 0:n.formatCompletion(s))||{}})}),Vr.high(Kt.of([{key:"Tab",run:s=>Ti(s)}])),mn.of({addAttachment:s=>r==null?void 0:r([s])}),...r?[e.data.of({autocomplete:Xd().createCompletionSource()})]:[],ju,Vu,Ke.init(()=>{let s=mt(a).getAllItems();return new Map(s.map(n=>[n.uri,n]))}),qu,Du({createTooltip:s=>{let n=mt(a).getProvider(s.type);if(!n)return oe.warn("No provider found for resource",s),zt(s.description||s.name);let o=n.formatCompletion(s),i=s.description||s.name;if(!(o!=null&&o.info))return zt(i);if(typeof o.info=="string")return zt(o.info);let l=o.info(o);return l?"dom"in l?{dom:l.dom}:"then"in l?(oe.warn("info is a promise. This is not supported",l),zt(i)):{dom:l}:zt(i)}})]}function zt(t){let e=document.createElement("div");return e.innerHTML=t,{dom:e}}var Cr=Ea(),O=ka(vi(),1);const In=t=>{let{handleAcceptCompletion:e,handleDeclineCompletion:a,isLoading:r,hasCompletion:s}=t;return n=>{let o=gi()?n.metaKey:n.ctrlKey;o&&n.key==="Enter"&&!r&&s&&e(),(n.key==="Delete"||n.key==="Backspace")&&o&&n.shiftKey&&(a(),n.preventDefault(),n.stopPropagation())}},Ku=t=>{let e=(0,Cr.c)(9),{isLoading:a,onAccept:r,onDecline:s,runCell:n}=t,o;e[0]!==a||e[1]!==r||e[2]!==n?(o=(0,O.jsx)(Sn,{isLoading:a,onAccept:r,size:"xs",runCell:n}),e[0]=a,e[1]=r,e[2]=n,e[3]=o):o=e[3];let i;e[4]===s?i=e[5]:(i=(0,O.jsx)(On,{onDecline:s,size:"xs"}),e[4]=s,e[5]=i);let l;return e[6]!==o||e[7]!==i?(l=(0,O.jsxs)(O.Fragment,{children:[o,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8],l},Sn=t=>{let e=(0,Cr.c)(33),{isLoading:a,onAccept:r,multipleCompletions:s,size:n,buttonStyles:o,acceptShortcut:i,runCell:l,playButtonStyles:d,borderless:u}=t,p=s===void 0?!1:s,g=n===void 0?"sm":n,h=u===void 0?!1:u,b;e[0]!==r||e[1]!==l?(b=()=>{r(),l&&l()},e[0]=r,e[1]=l,e[2]=b):b=e[2];let f=b,c=p?"Accept all":"Accept";if(l){let C=`h-6 text-(--grass-11) bg-(--grass-3)/60
|
|
@@ -86,5 +86,5 @@ Image URL: ${s}`)),e}async waitForCellsToFinish(t,e,a,r){let s=o=>e.every(i=>{le
|
|
|
86
86
|
border-(--green-6) border hover:shadow-xs rounded px-3 ${o}`,_;e[24]===i?_=e[25]:(_=i&&(0,O.jsx)(Oa,{className:"ml-1 inline",shortcut:i}),e[24]=i,e[25]=_);let E;return e[26]!==a||e[27]!==r||e[28]!==g||e[29]!==m||e[30]!==_||e[31]!==c?(E=(0,O.jsxs)(Qe,{variant:"text",size:g,disabled:a,onClick:r,className:m,children:[c,_]}),e[26]=a,e[27]=r,e[28]=g,e[29]=m,e[30]=_,e[31]=c,e[32]=E):E=e[32],E},On=t=>{let e=(0,Cr.c)(8),{onDecline:a,multipleCompletions:r,size:s,className:n,declineShortcut:o,borderless:i}=t,l=r===void 0?!1:r,d=s===void 0?"sm":s,u=`h-6 text-(--red-10) bg-(--red-3)/60 hover:bg-(--red-3)
|
|
87
87
|
dark:bg-(--red-4)/80 dark:hover:bg-(--red-3) rounded px-3 font-semibold
|
|
88
88
|
active:bg-(--red-5) dark:active:bg-(--red-4)
|
|
89
|
-
border-(--red-6) border hover:shadow-xs ${(i===void 0?!1:i)&&"border-none rounded-md"} ${n}`,p=l&&" all",g;e[0]===o?g=e[1]:(g=o&&(0,O.jsx)(Oa,{className:"ml-1 inline",shortcut:o}),e[0]=o,e[1]=g);let h;return e[2]!==a||e[3]!==d||e[4]!==u||e[5]!==p||e[6]!==g?(h=(0,O.jsxs)(Qe,{variant:"text",size:d,onClick:a,className:u,children:["Reject",p,g]}),e[2]=a,e[3]=d,e[4]=u,e[5]=p,e[6]=g,e[7]=h):h=e[7],h};var Yu=class extends er{constructor(t,e){super(t),this.onChunkReceived=e}processResponseStream(t){let e=this.onChunkReceived;return super.processResponseStream(t).pipeThrough(new TransformStream({async transform(a,r){e(a),r.enqueue(a)}}))}},An=Ea(),Hu=
|
|
89
|
+
border-(--red-6) border hover:shadow-xs ${(i===void 0?!1:i)&&"border-none rounded-md"} ${n}`,p=l&&" all",g;e[0]===o?g=e[1]:(g=o&&(0,O.jsx)(Oa,{className:"ml-1 inline",shortcut:o}),e[0]=o,e[1]=g);let h;return e[2]!==a||e[3]!==d||e[4]!==u||e[5]!==p||e[6]!==g?(h=(0,O.jsxs)(Qe,{variant:"text",size:d,onClick:a,className:u,children:["Reject",p,g]}),e[2]=a,e[3]=d,e[4]=u,e[5]=p,e[6]=g,e[7]=h):h=e[7],h};var Yu=class extends er{constructor(t,e){super(t),this.onChunkReceived=e}processResponseStream(t){let e=this.onChunkReceived;return super.processResponseStream(t).pipeThrough(new TransformStream({async transform(a,r){e(a),r.enqueue(a)}}))}},An=Ea(),Hu=ui("marimo:ai-language","python",di),Rn="marimo:ai-prompt-history",Nn=new ei(Ve(k()),()=>[]);const Gu=t=>{let e=(0,An.c)(82),{onClose:a}=t,r=Rr(),[s,n]=(0,A.useState)(""),{deleteAllStagedCells:o,clearStagedCells:i,onStream:l,addStagedCell:d}=gn(r),[u,p]=Bn(Hu),g=yi(),{invokeAiTool:h,sendRun:b}=Oi(),f=Kn(Zt),c=(0,A.useRef)(null),{createNewCell:m,prepareForRun:_}=$r(),E;e[0]!==d||e[1]!==m||e[2]!==_||e[3]!==b||e[4]!==r?(E={store:r,addStagedCell:d,createNewCell:m,prepareForRun:_,sendRun:b},e[0]=d,e[1]=m,e[2]=_,e[3]=b,e[4]=r,e[5]=E):E=e[5];let C=E,I;if(e[6]!==u||e[7]!==l||e[8]!==g){let Ee;e[10]===u?Ee=e[11]:(Ee=async qt=>{let zn=await bn(qt.messages);return{body:{...qt,...zn,code:"",prompt:"",language:u}}},e[10]=u,e[11]=Ee);let He;e[12]===l?He=e[13]:(He=qt=>{l(qt)},e[12]=l,e[13]=He),I=new Yu({api:g.getAiURL("completion").toString(),headers:g.headers(),prepareSendMessagesRequest:Ee},He),e[6]=u,e[7]=l,e[8]=g,e[9]=I}else I=e[9];let{sendMessage:P,stop:D,status:M,addToolOutput:H}=ln({experimental_throttle:100,transport:I,onToolCall:async Ee=>{let{toolCall:He}=Ee;await xn({invokeAiTool:h,addToolOutput:j,toolCall:{toolName:He.toolName,toolCallId:He.toolCallId,input:He.input},toolContext:C})},onError:Qu}),j=H,F=M==="streaming"||M==="submitted",K=f.size>0,X;e[14]!==o||e[15]!==s||e[16]!==F||e[17]!==P?(X=()=>{var Ee;F||((Ee=c.current)!=null&&Ee.view&&kn(c.current.view),o(),P({text:s}))},e[14]=o,e[15]=s,e[16]=F,e[17]=P,e[18]=X):X=e[18];let W=X,J;e[19]===Symbol.for("react.memo_cache_sentinel")?(J=(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(ro,{className:"size-4 mr-2"}),"Python"]}),e[19]=J):J=e[19];let te=J,ie;e[20]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(Xn,{className:"size-4 mr-2"}),"SQL"]}),e[20]=ie):ie=e[20];let ae=ie,Ye=u==="python"?te:ae,ke;e[21]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,O.jsx)(Mi,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"}),e[21]=ke):ke=e[21];let ye;e[22]===Ye?ye=e[23]:(ye=(0,O.jsx)($i,{asChild:!0,children:(0,O.jsxs)(Qe,{variant:"text",className:"ml-2",size:"xs","data-testid":"language-button",children:[Ye,ke]})}),e[22]=Ye,e[23]=ye);let be,De;e[24]===Symbol.for("react.memo_cache_sentinel")?(be=(0,O.jsx)("div",{className:"px-2 py-1 font-semibold",children:"Select language"}),De=(0,O.jsx)(ji,{}),e[24]=be,e[25]=De):(be=e[24],De=e[25]);let Ne;e[26]===p?Ne=e[27]:(Ne=(0,O.jsx)(Jr,{onClick:()=>p("python"),children:te}),e[26]=p,e[27]=Ne);let Ce;e[28]===p?Ce=e[29]:(Ce=(0,O.jsx)(Jr,{onClick:()=>p("sql"),children:ae}),e[28]=p,e[29]=Ce);let Ze;e[30]!==Ne||e[31]!==Ce?(Ze=(0,O.jsxs)(Li,{align:"center",children:[be,De,Ne,Ce]}),e[30]=Ne,e[31]=Ce,e[32]=Ze):Ze=e[32];let nt;e[33]!==ye||e[34]!==Ze?(nt=(0,O.jsxs)(Di,{modal:!1,children:[ye,Ze]}),e[33]=ye,e[34]=Ze,e[35]=nt):nt=e[35];let Tt=nt,ht;e[36]!==i||e[37]!==a?(ht=()=>{i(),a()},e[36]=i,e[37]=a,e[38]=ht):ht=e[38];let Fe=ht,it;e[39]===o?it=e[40]:(it=()=>{o()},e[39]=o,e[40]=it);let B=it,U;e[41]===Symbol.for("react.memo_cache_sentinel")?(U=(0,O.jsx)(zi,{className:"size-4 text-(--blue-11) mr-2"}),e[41]=U):U=e[41];let G;e[42]!==o||e[43]!==a?(G=()=>{o(),a()},e[42]=o,e[43]=a,e[44]=G):G=e[44];let V;e[45]===Symbol.for("react.memo_cache_sentinel")?(V=Ee=>{n(Ee)},e[45]=V):V=e[45];let me;e[46]!==Fe||e[47]!==B||e[48]!==K||e[49]!==F?(me=In({handleAcceptCompletion:Fe,handleDeclineCompletion:B,isLoading:F,hasCompletion:K}),e[46]=Fe,e[47]=B,e[48]=K,e[49]=F,e[50]=me):me=e[50];let he;e[51]!==s||e[52]!==W||e[53]!==G||e[54]!==me?(he=(0,O.jsx)(Mn,{inputRef:c,onClose:G,value:s,onChange:V,onSubmit:W,onKeyDown:me}),e[51]=s,e[52]=W,e[53]=G,e[54]=me,e[55]=he):he=e[55];let re;e[56]!==F||e[57]!==D?(re=F&&(0,O.jsxs)(Qe,{"data-testid":"stop-completion-button",variant:"text",size:"sm",className:"mb-0",onClick:D,children:[(0,O.jsx)(Fi,{className:"animate-spin mr-1",size:14}),"Stop"]}),e[56]=F,e[57]=D,e[58]=re):re=e[58];let ne;e[59]===Symbol.for("react.memo_cache_sentinel")?(ne=(0,O.jsx)(no,{className:"size-4"}),e[59]=ne):ne=e[59];let ce;e[60]===W?ce=e[61]:(ce=(0,O.jsx)(Qe,{variant:"text",size:"sm",onClick:W,title:"Submit",children:ne}),e[60]=W,e[61]=ce);let ot;e[62]===Symbol.for("react.memo_cache_sentinel")?(ot=(0,O.jsx)(Ni,{className:"size-4"}),e[62]=ot):ot=e[62];let ze;e[63]===a?ze=e[64]:(ze=(0,O.jsx)(Qe,{variant:"text",size:"sm",className:"mb-0 px-1",onClick:a,children:ot}),e[63]=a,e[64]=ze);let lt;e[65]!==he||e[66]!==re||e[67]!==ce||e[68]!==ze?(lt=(0,O.jsxs)("div",{className:"flex items-center px-3",children:[U,he,re,ce,ze]}),e[65]=he,e[66]=re,e[67]=ce,e[68]=ze,e[69]=lt):lt=e[69];let le=lt,fe;e[70]===Symbol.for("react.memo_cache_sentinel")?(fe=Ur("flex flex-col w-full py-2"),e[70]=fe):fe=e[70];let Me;e[71]===K?Me=e[72]:(Me=!K&&(0,O.jsx)("span",{className:"text-xs text-muted-foreground px-3 flex flex-col gap-1 mt-2",children:(0,O.jsxs)("span",{children:["You can mention"," ",(0,O.jsx)("span",{className:"text-(--cyan-11)",children:"@dataframe"})," or"," ",(0,O.jsx)("span",{className:"text-(--cyan-11)",children:"@sql_table"})," to pull additional context such as column names. Code from other cells is automatically included."]})}),e[71]=K,e[72]=Me);let ft;e[73]===Symbol.for("react.memo_cache_sentinel")?(ft=(0,O.jsx)(Ri,{triggerClassName:"h-7 text-xs max-w-64",iconSize:"small",forRole:"edit"}),e[73]=ft):ft=e[73];let Pe;e[74]===Tt?Pe=e[75]:(Pe=(0,O.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[Tt,ft]}),e[74]=Tt,e[75]=Pe);let gt;e[76]!==Me||e[77]!==Pe?(gt=(0,O.jsxs)("div",{className:"flex flex-row justify-between -mt-1 ml-1 mr-3",children:[Me,Pe]}),e[76]=Me,e[77]=Pe,e[78]=gt):gt=e[78];let Vt;return e[79]!==le||e[80]!==gt?(Vt=(0,O.jsxs)("div",{className:fe,children:[le,gt]}),e[79]=le,e[80]=gt,e[81]=Vt):Vt=e[81],Vt},Mn=t=>{let e=(0,An.c)(35),{value:a,placeholder:r,inputRef:s,className:n,onChange:o,onSubmit:i,onKeyDown:l,onClose:d,onAddFiles:u,additionalCompletions:p,maxHeight:g}=t,h=i,b=d,f=Rr(),{theme:c}=Bi(),m;e[0]===p?m=e[1]:(m=ie=>p?su([p.triggerCompletionRegex],p.completions)(ie):null,e[0]=p,e[1]=m);let _=Wn(m),E,C,I,P;if(e[2]!==_||e[3]!==u||e[4]!==f){let ie=qi();e[9]===Symbol.for("react.memo_cache_sentinel")?(E=Si({}),e[9]=E):E=e[9],C=ie,I=Ju({language:ie.language,store:f,onAddFiles:u}),P=ie.language.data.of({autocomplete:_}),e[2]=_,e[3]=u,e[4]=f,e[5]=E,e[6]=C,e[7]=I,e[8]=P}else E=e[5],C=e[6],I=e[7],P=e[8];let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D=Su({storage:{load:Xu,save:ec}}),e[10]=D):D=e[10];let M;e[11]===Symbol.for("react.memo_cache_sentinel")?(M=to(),e[11]=M):M=e[11];let H;e[12]===h?H=e[13]:(H=Vr.highest(Kt.of([{preventDefault:!0,stopPropagation:!0,any:(ie,ae)=>{let Ye=ae.metaKey||ae.ctrlKey||ae.shiftKey;if(ae.key==="Enter"&&!Ye)return h(ae,ie.state.doc.toString()),ae.preventDefault(),ae.stopPropagation(),!0;if(ae.key==="Enter"&&ae.shiftKey){let ke=ie.state.selection.main.from;return ie.dispatch({changes:{from:ke,to:ke,insert:`
|
|
90
90
|
`},selection:{anchor:ke+1,head:ke+1}}),ae.preventDefault(),ae.stopPropagation(),!0}return!1}}])),e[12]=h,e[13]=H);let j;e[14]===b?j=e[15]:(j=Kt.of([{key:"Escape",preventDefault:!0,stopPropagation:!0,run:()=>(b(),!0)}]),e[14]=b,e[15]=j);let F;e[16]!==E||e[17]!==C||e[18]!==I||e[19]!==P||e[20]!==H||e[21]!==j?(F=[E,C,I,P,D,qr.lineWrapping,M,H,j],e[16]=E,e[17]=C,e[18]=I,e[19]=P,e[20]=H,e[21]=j,e[22]=F):F=e[22];let K=F,X;e[23]===n?X=e[24]:(X=Ur("flex-1 font-sans overflow-auto my-1",n),e[23]=n,e[24]=X);let W=c==="dark"?"dark":"light",J=r||"Generate with AI, @ to include context",te;return e[25]!==K||e[26]!==s||e[27]!==g||e[28]!==o||e[29]!==l||e[30]!==X||e[31]!==W||e[32]!==J||e[33]!==a?(te=(0,O.jsx)(ao,{ref:s,className:X,width:"100%",maxHeight:g,value:a,basicSetup:!1,extensions:K,onChange:o,onKeyDown:l,theme:W,placeholder:J}),e[25]=K,e[26]=s,e[27]=g,e[28]=o,e[29]=l,e[30]=X,e[31]=W,e[32]=J,e[33]=a,e[34]=te):te=e[34],te};function Qu(t){Kr({title:"Generate with AI failed",description:Ki(t)})}function Xu(){return Nn.get(Rn)}function ec(t){return Nn.set(Rn,t)}export{mt as C,ed as D,er as E,io as O,tu as S,Vd as T,Zt as _,On as a,eu as b,bn as c,xn as d,ku as f,_r as g,_u as h,Ku as i,so as k,xu as l,br as m,Mn as n,In as o,wu as p,Sn as r,kn as s,Gu as t,bu as u,fn as v,ln as w,nu as x,gn as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ue=Object.defineProperty;var Ke=(t,e,s)=>e in t?Ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var ne=(t,e,s)=>Ke(t,typeof e!="symbol"?e+"":e,s);import{s as me}from"./chunk-LvLJmgfZ.js";import{t as We}from"./react-BGmjiNul.js";import{
|
|
1
|
+
var Ue=Object.defineProperty;var Ke=(t,e,s)=>e in t?Ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var ne=(t,e,s)=>Ke(t,typeof e!="symbol"?e+"":e,s);import{s as me}from"./chunk-LvLJmgfZ.js";import{t as We}from"./react-BGmjiNul.js";import{bn as h,ft as He,w as Me}from"./cells-Cv9PtwL9.js";import{D as oe,P as p,R as d,T as v,_ as ue,i as Qe,k as m,m as Ge}from"./zod-Cg4WLWh2.js";import{t as be}from"./compiler-runtime-DeeZ7FnK.js";import{S as Ve}from"./_Uint8Array-BGESiCQL.js";import{r as re}from"./useLifecycle-CmDXEyIC.js";import{r as ze,t as Je}from"./_baseEach-BH6a1vAB.js";import{f as Ye}from"./hotkeys-uKX61F1_.js";import{t as Xe}from"./jsx-runtime-DN_bIXfG.js";import{t as ie}from"./button-B8cGZzP5.js";import{t as fe}from"./cn-C1rgT0yh.js";import{c as Ze,i as et,n as tt,r as st,s as nt,t as ot}from"./select-D9lTzMzP.js";import{t as rt}from"./circle-plus-D1IRnTdM.js";import{a as ae,c as ge,o as it,p as at,r as ct,t as lt}from"./dropdown-menu-BP4_BZLr.js";import{n as dt}from"./DeferredRequestRegistry-B3BENoUa.js";import{o as ht,r as pt}from"./input-B80Yt1uu.js";import{a as mt,c as ut,d as bt,g as ft,l as gt,o as yt,p as St,s as _t,u as wt}from"./textarea-wbzgrXvB.js";import{a as xt,c as $t,l as kt,n as Ct,r as At,t as jt}from"./dialog-CF5DtF1E.js";import{n as vt}from"./ImperativeModal-DVhvP4lH.js";import{t as Rt}from"./links-DNmjkr65.js";import{n as It}from"./useAsyncData-BJJJOr9W.js";import{o as Tt}from"./focus-D1y1tXyC.js";import{o as Dt,t as qt,u as i}from"./form-BAtvsPJL.js";import{t as Lt}from"./request-registry-CAqj3mAX.js";import{n as Pt,t as Nt}from"./write-secret-modal-hOetwavI.js";function Ft(t,e,s,o){for(var n=-1,a=t==null?0:t.length;++n<a;){var c=t[n];e(o,c,s(c),t)}return o}var Et=Ft;function Bt(t,e,s,o){return Je(t,function(n,a,c){e(o,n,s(n),c)}),o}var Ot=Bt;function Ut(t,e){return function(s,o){var n=Ve(s)?Et:Ot,a=e?e():{};return n(s,t,ze(o,2),a)}}var Kt=Ut(function(t,e,s){t[s?0:1].push(e)},function(){return[[],[]]});function $(){return d().optional().describe(i.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function ce(t,e){let s=d();return s=e?s.nonempty():s.optional(),s=s.describe(i.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function G(){return d().optional().describe(i.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function le(t,e){let s=d();return s=e?s.nonempty():s.optional(),s.describe(i.of({label:t||"URI",optionRegex:".*uri.*"}))}function x(t){return d().nonempty().describe(i.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function w(){return d().describe(i.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function Wt(){return d().describe(i.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function k(){return d().nonempty().describe(i.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function C(t){let e=Qe().describe(i.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function ye(){return v().default(!1).describe(i.of({label:"Read Only"}))}const Se=p({type:m("postgres"),host:x(),port:C(5432).optional(),database:w(),username:k(),password:$(),ssl:v().default(!1).describe(i.of({label:"Use SSL"}))}).describe(i.of({direction:"two-columns"})),_e=p({type:m("mysql"),host:x(),port:C(3306),database:w(),username:k(),password:$(),ssl:v().default(!1).describe(i.of({label:"Use SSL"}))}).describe(i.of({direction:"two-columns"})),we=p({type:m("sqlite"),database:w().describe(i.of({label:"Database Path"}))}).describe(i.of({direction:"two-columns"})),xe=p({type:m("duckdb"),database:w().describe(i.of({label:"Database Path"})),read_only:ye()}).describe(i.of({direction:"two-columns"})),$e=p({type:m("motherduck"),database:w().default("my_db").describe(i.of({label:"Database Name"})),token:ce()}).describe(i.of({direction:"two-columns"})),ke=p({type:m("snowflake"),account:d().nonempty().describe(i.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:d().optional().describe(i.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:w(),schema:d().optional().describe(i.of({label:"Schema",optionRegex:".*snowflake.*"})),username:k(),password:$(),role:d().optional().describe(i.of({label:"Role"}))}).describe(i.of({direction:"two-columns"})),Ce=p({type:m("bigquery"),project:d().nonempty().describe(i.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:d().nonempty().describe(i.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:d().describe(i.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(i.of({direction:"two-columns"})),Ae=p({type:m("clickhouse_connect"),host:x(),port:C(8123).optional(),username:k(),password:$(),secure:v().default(!1).describe(i.of({label:"Use HTTPs"}))}).describe(i.of({direction:"two-columns"})),je=p({type:m("timeplus"),host:x().default("localhost"),port:C(8123).optional(),username:k().default("default"),password:$().default("")}).describe(i.of({direction:"two-columns"})),ve=p({type:m("chdb"),database:w().describe(i.of({label:"Database Path"})),read_only:ye()}).describe(i.of({direction:"two-columns"})),Re=p({type:m("trino"),host:x(),port:C(8080),database:w(),schema:Wt().optional(),username:k(),password:$(),async_support:v().default(!1).describe(i.of({label:"Async Support"}))}).describe(i.of({direction:"two-columns"})),Ie=p({type:m("iceberg"),name:d().describe(i.of({label:"Catalog Name"})),catalog:oe("type",[p({type:m("REST"),warehouse:G(),uri:d().optional().describe(i.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:ce()}),p({type:m("SQL"),warehouse:G(),uri:d().optional().describe(i.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),p({type:m("Hive"),warehouse:G(),uri:le()}),p({type:m("Glue"),warehouse:G(),uri:le()}),p({type:m("DynamoDB"),"dynamodb.profile-name":d().optional().describe(i.of({label:"Profile Name"})),"dynamodb.region":d().optional().describe(i.of({label:"Region"})),"dynamodb.access-key-id":d().optional().describe(i.of({label:"Access Key ID"})),"dynamodb.secret-access-key":d().optional().describe(i.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":d().optional().describe(i.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(i.of({special:"tabs"}))}),Te=p({type:m("datafusion"),sessionContext:v().optional().describe(i.of({label:"Use Session Context"}))}),De=p({type:m("pyspark"),host:x().optional(),port:C().optional()}),qe=p({type:m("redshift"),host:x(),port:C(5439),connectionType:oe("type",[p({type:m("IAM credentials"),region:d().describe(i.of({label:"Region"})),aws_access_key_id:d().nonempty().describe(i.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:d().nonempty().describe(i.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:d().optional().describe(i.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),p({type:m("DB credentials"),user:k(),password:$()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:w()}).describe(i.of({direction:"two-columns"})),Le=p({type:m("databricks"),access_token:ce("Access Token",!0),server_hostname:x("Server Hostname"),http_path:le("HTTP Path",!0),catalog:d().optional().describe(i.of({label:"Catalog"})),schema:d().optional().describe(i.of({label:"Schema"}))}).describe(i.of({direction:"two-columns"})),Pe=p({type:m("supabase"),host:x(),port:C(5432).optional(),database:w(),username:k(),password:$(),disable_client_pooling:v().default(!1).describe(i.of({label:"Disable Client-Side Pooling"}))}).describe(i.of({direction:"two-columns"})),Ht=oe("type",[Se,_e,we,xe,$e,ke,Ce,Ae,je,ve,Re,Ie,Te,De,qe,Le,Pe]);var de="env:";function tn(t){return t}function V(t){return typeof t=="string"?t.startsWith(de):!1}function he(t){return`${de}${t}`}function Mt(t){return t.replace(de,"")}const Ne={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var y=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},Qt=t=>`_${t}`,Gt=class{constructor(){ne(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=Qt(t),V(e)){let o=Mt(e),n=s?`os.environ.get("${o}", "${s}")`:`os.environ.get("${o}")`;return this.secrets[t]=n,t}if(s!=null){let o=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=o,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?U(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return U(e);let o=this.print(t,e,s);return o.startsWith('"')&&o.endsWith('"')?o.slice(1,-1):`{${o}}`}printPassword(t,e,s,o){let n=s?this.printInFString.bind(this):this.print.bind(this);return V(t)?n(o||"password",t):n(o||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
|
|
2
2
|
`)}},Vt=class extends y{generateImports(){return[]}generateConnectionCode(){let t=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",e=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0);return h(`
|
|
3
3
|
DATABASE_URL = f"postgresql://${this.secrets.printInFString("username",this.connection.username)}:${e}@${this.secrets.printInFString("host",this.connection.host)}:${this.secrets.printInFString("port",this.connection.port)}/${this.secrets.printInFString("database",this.connection.database)}"
|
|
4
4
|
engine = ${this.orm}.create_engine(DATABASE_URL${t})
|
|
@@ -108,4 +108,4 @@ ${z({host:t,port:e,database:s,...o&&{user:o},...n&&{password:n}},a=>` $
|
|
|
108
108
|
`)}},hs=class{constructor(){ne(this,"secrets",new Gt)}createGenerator(t,e){switch(t.type){case"postgres":return new Vt(t,e,this.secrets);case"mysql":return new zt(t,e,this.secrets);case"sqlite":return new Jt(t,e,this.secrets);case"snowflake":return new Yt(t,e,this.secrets);case"bigquery":return new Xt(t,e,this.secrets);case"duckdb":return new Zt(t,e,this.secrets);case"motherduck":return new es(t,e,this.secrets);case"clickhouse_connect":return new ts(t,e,this.secrets);case"timeplus":return new ss(t,e,this.secrets);case"chdb":return new ns(t,e,this.secrets);case"trino":return new os(t,e,this.secrets);case"iceberg":return new rs(t,e,this.secrets);case"datafusion":return new is(t,e,this.secrets);case"pyspark":return new as(t,e,this.secrets);case"redshift":return new cs(t,e,this.secrets);case"databricks":return new ls(t,e,this.secrets);case"supabase":return new ds(t,e,this.secrets);default:re(t)}}};function ps(t,e){if(!(e in Ne))throw Error(`Unsupported library: ${e}`);Ht.parse(t);let s=new hs,o=s.createGenerator(t,e),n=o.generateConnectionCode(),a=s.secrets,c=[...new Set([...a.imports,...o.imports])].sort();c.push("");let l=a.formatSecrets();return l&&c.push(l),c.push(n.trim()),c.join(`
|
|
109
109
|
`)}function U(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function z(t,e){return Object.entries(t).filter(([,s])=>s!=null&&s!=="").map(([s,o])=>e(typeof o=="boolean"?`${s}=${U(o)}`:`${s}=${o}`)).join(`,
|
|
110
110
|
`)}function ms(t,e){return Object.entries(t).filter(([,s])=>s!=null&&s!=="").map(([s,o])=>{let n=`"${s}"`;return e(typeof o=="boolean"?`${n}: ${U(o)}`:`${n}: ${o}`)}).join(`,
|
|
111
|
-
`)}var us=be(),K=me(We(),1),r=me(Xe(),1),Fe=(0,K.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Ye.NOOP});const bs=()=>(0,K.use)(Fe),fs=t=>{let e=(0,us.c)(14),{children:s}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let{data:n,isPending:a,error:c,refetch:l}=It(ws,o),b;e[1]===(n==null?void 0:n.secretKeys)?b=e[2]:(b=(n==null?void 0:n.secretKeys)||[],e[1]=n==null?void 0:n.secretKeys,e[2]=b);let u;e[3]===(n==null?void 0:n.providerNames)?u=e[4]:(u=(n==null?void 0:n.providerNames)||[],e[3]=n==null?void 0:n.providerNames,e[4]=u);let f;e[5]!==c||e[6]!==a||e[7]!==l||e[8]!==b||e[9]!==u?(f={secretKeys:b,providerNames:u,loading:a,error:c,refreshSecrets:l},e[5]=c,e[6]=a,e[7]=l,e[8]=b,e[9]=u,e[10]=f):f=e[10];let S;return e[11]!==s||e[12]!==f?(S=(0,r.jsx)(Fe,{value:f,children:s}),e[11]=s,e[12]=f,e[13]=S):S=e[13],S},gs={isMatch:t=>{if(t instanceof ue||t instanceof Ge){let{optionRegex:e}=i.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:o,providerNames:n,refreshSecrets:a}=bs(),{openModal:c,closeModal:l}=vt(),{label:b,description:u,optionRegex:f=""}=i.parse(t.description||""),[S,A]=Kt(o,g=>new RegExp(f,"i").test(g));return(0,r.jsx)(ut,{control:e.control,name:s,render:({field:g})=>(0,r.jsxs)(gt,{children:[(0,r.jsx)(wt,{children:b}),(0,r.jsx)(yt,{children:u}),(0,r.jsx)(mt,{children:(0,r.jsxs)("div",{className:"flex gap-2",children:[t instanceof ue?(0,r.jsx)(pt,{...g,value:g.value,onChange:g.onChange,className:fe("flex-1")}):(0,r.jsx)(ht,{...g,value:g.value,onChange:g.onChange,className:"flex-1"}),(0,r.jsxs)(lt,{children:[(0,r.jsx)(at,{asChild:!0,children:(0,r.jsx)(ie,{variant:"outline",size:"icon",className:fe(V(g.value)&&"bg-accent"),children:(0,r.jsx)(dt,{className:"h-3 w-3"})})}),(0,r.jsxs)(ct,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,r.jsxs)(ae,{onSelect:()=>{c((0,r.jsx)(Nt,{providerNames:n,onSuccess:_=>{a(),g.onChange(he(_)),l()},onClose:l}))},children:[(0,r.jsx)(rt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),S.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ge,{}),(0,r.jsx)(it,{children:"Recommended"})]}),S.map(_=>(0,r.jsx)(ae,{onSelect:()=>g.onChange(he(_)),children:_},_)),A.length>0&&(0,r.jsx)(ge,{}),A.map(_=>(0,r.jsx)(ae,{onSelect:()=>g.onChange(he(_)),children:_},_))]})]})]})}),(0,r.jsx)(bt,{})]})})}};function ys(t){return t.provider!=="env"}function Ss(t){return t.name}function _s(t){return t.keys}async function ws(){let t=await Lt.request({}),e=Pt(t.secrets).filter(ys).map(Ss);return{secretKeys:t.secrets.flatMap(_s).sort(),providerNames:e}}var W=be(),Ee=[{name:"PostgreSQL",schema:Se,color:"#336791",logo:"postgres",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"MySQL",schema:_e,color:"#00758F",logo:"mysql",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"SQLite",schema:we,color:"#003B57",logo:"sqlite",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DuckDB",schema:xe,color:"#FFD700",logo:"duckdb",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"MotherDuck",schema:$e,color:"#ff9538",logo:"motherduck",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"Snowflake",schema:ke,color:"#29B5E8",logo:"snowflake",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse",schema:Ae,color:"#2C2C1D",logo:"clickhouse",connectionLibraries:{libraries:["clickhouse_connect"],preferred:"clickhouse_connect"}},{name:"Timeplus",schema:je,color:"#B83280",logo:"timeplus",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"BigQuery",schema:Ce,color:"#4285F4",logo:"bigquery",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse Embedded",schema:ve,color:"#f2b611",logo:"clickhouse",connectionLibraries:{libraries:["chdb"],preferred:"chdb"}},{name:"Trino",schema:Re,color:"#d466b6",logo:"trino",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DataFusion",schema:Te,color:"#202A37",logo:"datafusion",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"PySpark",schema:De,color:"#1C5162",logo:"pyspark",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"Redshift",schema:qe,color:"#522BAE",logo:"redshift",connectionLibraries:{libraries:["redshift"],preferred:"redshift"}},{name:"Databricks",schema:Le,color:"#c41e0c",logo:"databricks",connectionLibraries:{libraries:["sqlalchemy","sqlmodel","ibis"],preferred:"sqlalchemy"}},{name:"Supabase",schema:Pe,color:"#238F5F",logo:"supabase",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}}],Be=[{name:"Iceberg",schema:Ie,color:"#000000",logo:"iceberg",connectionLibraries:{libraries:["pyiceberg"],preferred:"pyiceberg"}}],xs=t=>{let e=(0,W.c)(14),{onSelect:s}=t,o;e[0]===s?o=e[1]:(o=S=>{let{name:A,schema:g,color:_,logo:R}=S;return(0,r.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:{backgroundColor:_},onClick:()=>s(g),children:[(0,r.jsx)(Me,{name:R,className:"w-8 h-8 text-white brightness-0 invert dark:invert"}),(0,r.jsx)("span",{className:"text-white font-medium text-lg",children:A})]},A)},e[0]=s,e[1]=o);let n=o,a;e[2]===n?a=e[3]:(a=Ee.map(n),e[2]=n,e[3]=a);let c;e[4]===a?c=e[5]:(c=(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:a}),e[4]=a,e[5]=c);let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=(0,r.jsxs)("h4",{className:"font-semibold text-muted-foreground text-lg flex items-center gap-4",children:["Data Catalogs",(0,r.jsx)("hr",{className:"flex-1"})]}),e[6]=l):l=e[6];let b;e[7]===n?b=e[8]:(b=Be.map(n),e[7]=n,e[8]=b);let u;e[9]===b?u=e[10]:(u=(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:b}),e[9]=b,e[10]=u);let f;return e[11]!==c||e[12]!==u?(f=(0,r.jsxs)(r.Fragment,{children:[c,l,u]}),e[11]=c,e[12]=u,e[13]=f):f=e[13],f},$s=[gs],ks=t=>{var pe;let e=(0,W.c)(49),{schema:s,onSubmit:o,onBack:n}=t,a;e[0]===s?a=e[1]:(a=Dt(s),e[0]=s,e[1]=a);let c=s,l;e[2]===c?l=e[3]:(l=St(c),e[2]=c,e[3]=l);let b;e[4]!==a||e[5]!==l?(b={defaultValues:a,resolver:l,reValidateMode:"onChange"},e[4]=a,e[5]=l,e[6]=b):b=e[6];let u=ft(b),f=(pe=[...Ee,...Be].find(j=>j.schema===s))==null?void 0:pe.connectionLibraries,[S,A]=(0,K.useState)((f==null?void 0:f.preferred)??"sqlalchemy"),{createNewCell:g}=He(),_=Tt(),R;e[7]!==g||e[8]!==_?(R=j=>{g({code:j,before:!1,cellId:_??"__end__",skipIfCodeExists:!0})},e[7]=g,e[8]=_,e[9]=R):R=e[9];let J=R,H;e[10]!==J||e[11]!==o||e[12]!==S?(H=j=>{J(ps(j,S)),o()},e[10]=J,e[11]=o,e[12]=S,e[13]=H):H=e[13];let Y=H,I;e[14]!==u||e[15]!==Y?(I=u.handleSubmit(Y),e[14]=u,e[15]=Y,e[16]=I):I=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=(0,r.jsx)(_t,{}),e[17]=M):M=e[17];let T;e[18]!==u||e[19]!==s?(T=(0,r.jsx)(fs,{children:(0,r.jsx)(qt,{schema:s,form:u,renderers:$s,children:M})}),e[18]=u,e[19]=s,e[20]=T):T=e[20];let D;e[21]===n?D=e[22]:(D=(0,r.jsx)(ie,{type:"button",variant:"outline",onClick:n,children:"Back"}),e[21]=n,e[22]=D);let X=!u.formState.isValid,q;e[23]===X?q=e[24]:(q=(0,r.jsx)(ie,{type:"submit",disabled:X,children:"Add"}),e[23]=X,e[24]=q);let L;e[25]!==D||e[26]!==q?(L=(0,r.jsxs)("div",{className:"flex gap-2",children:[D,q]}),e[25]=D,e[26]=q,e[27]=L):L=e[27];let Z=ot,P;e[28]===Symbol.for("react.memo_cache_sentinel")?(P=j=>A(j),e[28]=P):P=e[28];let N;e[29]===Symbol.for("react.memo_cache_sentinel")?(N=(0,r.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[(0,r.jsx)(nt,{children:(0,r.jsx)(Ze,{placeholder:"Select a library"})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Preferred connection library"})]}),e[29]=N):N=e[29];let ee=tt,te=st,se=f==null?void 0:f.libraries.map(js),F;e[30]!==te||e[31]!==se?(F=(0,r.jsx)(te,{children:se}),e[30]=te,e[31]=se,e[32]=F):F=e[32];let E;e[33]!==ee||e[34]!==F?(E=(0,r.jsx)(ee,{children:F}),e[33]=ee,e[34]=F,e[35]=E):E=e[35];let B;e[36]!==Z||e[37]!==S||e[38]!==P||e[39]!==N||e[40]!==E?(B=(0,r.jsx)("div",{children:(0,r.jsxs)(Z,{value:S,onValueChange:P,children:[N,E]})}),e[36]=Z,e[37]=S,e[38]=P,e[39]=N,e[40]=E,e[41]=B):B=e[41];let O;e[42]!==L||e[43]!==B?(O=(0,r.jsxs)("div",{className:"flex gap-2 justify-between",children:[L,B]}),e[42]=L,e[43]=B,e[44]=O):O=e[44];let Q;return e[45]!==T||e[46]!==O||e[47]!==I?(Q=(0,r.jsxs)("form",{onSubmit:I,className:"space-y-4",children:[T,O]}),e[45]=T,e[46]=O,e[47]=I,e[48]=Q):Q=e[48],Q},Cs=t=>{let e=(0,W.c)(5),{onSubmit:s}=t,[o,n]=(0,K.useState)(null);if(!o){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,r.jsx)(xs,{onSelect:n}),e[0]=l):l=e[0],l}let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=()=>n(null),e[1]=a):a=e[1];let c;return e[2]!==s||e[3]!==o?(c=(0,r.jsx)(ks,{schema:o,onSubmit:s,onBack:a}),e[2]=s,e[3]=o,e[4]=c):c=e[4],c};const As=t=>{let e=(0,W.c)(6),{children:s}=t,[o,n]=(0,K.useState)(!1),a;e[0]===s?a=e[1]:(a=(0,r.jsx)(kt,{asChild:!0,children:s}),e[0]=s,e[1]=a);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=(0,r.jsx)(Oe,{onClose:()=>n(!1)}),e[2]=c):c=e[2];let l;return e[3]!==o||e[4]!==a?(l=(0,r.jsxs)(jt,{open:o,onOpenChange:n,children:[a,c]}),e[3]=o,e[4]=a,e[5]=l):l=e[5],l},Oe=t=>{let e=(0,W.c)(4),{onClose:s}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,r.jsx)($t,{children:"Add Connection"}),e[0]=o):o=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,r.jsxs)(xt,{className:"mb-4",children:[o,(0,r.jsxs)(At,{children:["Connect to your database or data catalog to query data directly from your notebook. Learn more about how to connect to your database in our"," ",(0,r.jsx)(Rt,{href:"https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database",children:"docs."})]})]}),e[1]=n):n=e[1];let a;return e[2]===s?a=e[3]:(a=(0,r.jsxs)(Ct,{className:"max-h-[75vh] overflow-y-auto",children:[n,(0,r.jsx)(Cs,{onSubmit:()=>s()})]}),e[2]=s,e[3]=a),a};function js(t){return(0,r.jsx)(et,{value:t,children:Ne[t]},t)}export{Oe as n,As as t};
|
|
111
|
+
`)}var us=be(),K=me(We(),1),r=me(Xe(),1),Fe=(0,K.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Ye.NOOP});const bs=()=>(0,K.use)(Fe),fs=t=>{let e=(0,us.c)(14),{children:s}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let{data:n,isPending:a,error:c,refetch:l}=It(ws,o),b;e[1]===(n==null?void 0:n.secretKeys)?b=e[2]:(b=(n==null?void 0:n.secretKeys)||[],e[1]=n==null?void 0:n.secretKeys,e[2]=b);let u;e[3]===(n==null?void 0:n.providerNames)?u=e[4]:(u=(n==null?void 0:n.providerNames)||[],e[3]=n==null?void 0:n.providerNames,e[4]=u);let f;e[5]!==c||e[6]!==a||e[7]!==l||e[8]!==b||e[9]!==u?(f={secretKeys:b,providerNames:u,loading:a,error:c,refreshSecrets:l},e[5]=c,e[6]=a,e[7]=l,e[8]=b,e[9]=u,e[10]=f):f=e[10];let S;return e[11]!==s||e[12]!==f?(S=(0,r.jsx)(Fe,{value:f,children:s}),e[11]=s,e[12]=f,e[13]=S):S=e[13],S},gs={isMatch:t=>{if(t instanceof ue||t instanceof Ge){let{optionRegex:e}=i.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:o,providerNames:n,refreshSecrets:a}=bs(),{openModal:c,closeModal:l}=vt(),{label:b,description:u,optionRegex:f=""}=i.parse(t.description||""),[S,A]=Kt(o,g=>new RegExp(f,"i").test(g));return(0,r.jsx)(ut,{control:e.control,name:s,render:({field:g})=>(0,r.jsxs)(gt,{children:[(0,r.jsx)(wt,{children:b}),(0,r.jsx)(yt,{children:u}),(0,r.jsx)(mt,{children:(0,r.jsxs)("div",{className:"flex gap-2",children:[t instanceof ue?(0,r.jsx)(pt,{...g,value:g.value,onChange:g.onChange,className:fe("flex-1")}):(0,r.jsx)(ht,{...g,value:g.value,onChange:g.onChange,className:"flex-1"}),(0,r.jsxs)(lt,{children:[(0,r.jsx)(at,{asChild:!0,children:(0,r.jsx)(ie,{variant:"outline",size:"icon",className:fe(V(g.value)&&"bg-accent"),children:(0,r.jsx)(dt,{className:"h-3 w-3"})})}),(0,r.jsxs)(ct,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,r.jsxs)(ae,{onSelect:()=>{c((0,r.jsx)(Nt,{providerNames:n,onSuccess:_=>{a(),g.onChange(he(_)),l()},onClose:l}))},children:[(0,r.jsx)(rt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),S.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ge,{}),(0,r.jsx)(it,{children:"Recommended"})]}),S.map(_=>(0,r.jsx)(ae,{onSelect:()=>g.onChange(he(_)),children:_},_)),A.length>0&&(0,r.jsx)(ge,{}),A.map(_=>(0,r.jsx)(ae,{onSelect:()=>g.onChange(he(_)),children:_},_))]})]})]})}),(0,r.jsx)(bt,{})]})})}};function ys(t){return t.provider!=="env"}function Ss(t){return t.name}function _s(t){return t.keys}async function ws(){let t=await Lt.request({}),e=Pt(t.secrets).filter(ys).map(Ss);return{secretKeys:t.secrets.flatMap(_s).sort(),providerNames:e}}var W=be(),Ee=[{name:"PostgreSQL",schema:Se,color:"#336791",logo:"postgres",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"MySQL",schema:_e,color:"#00758F",logo:"mysql",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"SQLite",schema:we,color:"#003B57",logo:"sqlite",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DuckDB",schema:xe,color:"#FFD700",logo:"duckdb",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"MotherDuck",schema:$e,color:"#ff9538",logo:"motherduck",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"Snowflake",schema:ke,color:"#29B5E8",logo:"snowflake",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse",schema:Ae,color:"#2C2C1D",logo:"clickhouse",connectionLibraries:{libraries:["clickhouse_connect"],preferred:"clickhouse_connect"}},{name:"Timeplus",schema:je,color:"#B83280",logo:"timeplus",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"BigQuery",schema:Ce,color:"#4285F4",logo:"bigquery",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse Embedded",schema:ve,color:"#f2b611",logo:"clickhouse",connectionLibraries:{libraries:["chdb"],preferred:"chdb"}},{name:"Trino",schema:Re,color:"#d466b6",logo:"trino",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DataFusion",schema:Te,color:"#202A37",logo:"datafusion",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"PySpark",schema:De,color:"#1C5162",logo:"pyspark",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"Redshift",schema:qe,color:"#522BAE",logo:"redshift",connectionLibraries:{libraries:["redshift"],preferred:"redshift"}},{name:"Databricks",schema:Le,color:"#c41e0c",logo:"databricks",connectionLibraries:{libraries:["sqlalchemy","sqlmodel","ibis"],preferred:"sqlalchemy"}},{name:"Supabase",schema:Pe,color:"#238F5F",logo:"supabase",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}}],Be=[{name:"Iceberg",schema:Ie,color:"#000000",logo:"iceberg",connectionLibraries:{libraries:["pyiceberg"],preferred:"pyiceberg"}}],xs=t=>{let e=(0,W.c)(14),{onSelect:s}=t,o;e[0]===s?o=e[1]:(o=S=>{let{name:A,schema:g,color:_,logo:R}=S;return(0,r.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:{backgroundColor:_},onClick:()=>s(g),children:[(0,r.jsx)(He,{name:R,className:"w-8 h-8 text-white brightness-0 invert dark:invert"}),(0,r.jsx)("span",{className:"text-white font-medium text-lg",children:A})]},A)},e[0]=s,e[1]=o);let n=o,a;e[2]===n?a=e[3]:(a=Ee.map(n),e[2]=n,e[3]=a);let c;e[4]===a?c=e[5]:(c=(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:a}),e[4]=a,e[5]=c);let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=(0,r.jsxs)("h4",{className:"font-semibold text-muted-foreground text-lg flex items-center gap-4",children:["Data Catalogs",(0,r.jsx)("hr",{className:"flex-1"})]}),e[6]=l):l=e[6];let b;e[7]===n?b=e[8]:(b=Be.map(n),e[7]=n,e[8]=b);let u;e[9]===b?u=e[10]:(u=(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:b}),e[9]=b,e[10]=u);let f;return e[11]!==c||e[12]!==u?(f=(0,r.jsxs)(r.Fragment,{children:[c,l,u]}),e[11]=c,e[12]=u,e[13]=f):f=e[13],f},$s=[gs],ks=t=>{var pe;let e=(0,W.c)(49),{schema:s,onSubmit:o,onBack:n}=t,a;e[0]===s?a=e[1]:(a=Dt(s),e[0]=s,e[1]=a);let c=s,l;e[2]===c?l=e[3]:(l=St(c),e[2]=c,e[3]=l);let b;e[4]!==a||e[5]!==l?(b={defaultValues:a,resolver:l,reValidateMode:"onChange"},e[4]=a,e[5]=l,e[6]=b):b=e[6];let u=ft(b),f=(pe=[...Ee,...Be].find(j=>j.schema===s))==null?void 0:pe.connectionLibraries,[S,A]=(0,K.useState)((f==null?void 0:f.preferred)??"sqlalchemy"),{createNewCell:g}=Me(),_=Tt(),R;e[7]!==g||e[8]!==_?(R=j=>{g({code:j,before:!1,cellId:_??"__end__",skipIfCodeExists:!0})},e[7]=g,e[8]=_,e[9]=R):R=e[9];let J=R,H;e[10]!==J||e[11]!==o||e[12]!==S?(H=j=>{J(ps(j,S)),o()},e[10]=J,e[11]=o,e[12]=S,e[13]=H):H=e[13];let Y=H,I;e[14]!==u||e[15]!==Y?(I=u.handleSubmit(Y),e[14]=u,e[15]=Y,e[16]=I):I=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=(0,r.jsx)(_t,{}),e[17]=M):M=e[17];let T;e[18]!==u||e[19]!==s?(T=(0,r.jsx)(fs,{children:(0,r.jsx)(qt,{schema:s,form:u,renderers:$s,children:M})}),e[18]=u,e[19]=s,e[20]=T):T=e[20];let D;e[21]===n?D=e[22]:(D=(0,r.jsx)(ie,{type:"button",variant:"outline",onClick:n,children:"Back"}),e[21]=n,e[22]=D);let X=!u.formState.isValid,q;e[23]===X?q=e[24]:(q=(0,r.jsx)(ie,{type:"submit",disabled:X,children:"Add"}),e[23]=X,e[24]=q);let L;e[25]!==D||e[26]!==q?(L=(0,r.jsxs)("div",{className:"flex gap-2",children:[D,q]}),e[25]=D,e[26]=q,e[27]=L):L=e[27];let Z=ot,P;e[28]===Symbol.for("react.memo_cache_sentinel")?(P=j=>A(j),e[28]=P):P=e[28];let N;e[29]===Symbol.for("react.memo_cache_sentinel")?(N=(0,r.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[(0,r.jsx)(nt,{children:(0,r.jsx)(Ze,{placeholder:"Select a library"})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Preferred connection library"})]}),e[29]=N):N=e[29];let ee=tt,te=st,se=f==null?void 0:f.libraries.map(js),F;e[30]!==te||e[31]!==se?(F=(0,r.jsx)(te,{children:se}),e[30]=te,e[31]=se,e[32]=F):F=e[32];let E;e[33]!==ee||e[34]!==F?(E=(0,r.jsx)(ee,{children:F}),e[33]=ee,e[34]=F,e[35]=E):E=e[35];let B;e[36]!==Z||e[37]!==S||e[38]!==P||e[39]!==N||e[40]!==E?(B=(0,r.jsx)("div",{children:(0,r.jsxs)(Z,{value:S,onValueChange:P,children:[N,E]})}),e[36]=Z,e[37]=S,e[38]=P,e[39]=N,e[40]=E,e[41]=B):B=e[41];let O;e[42]!==L||e[43]!==B?(O=(0,r.jsxs)("div",{className:"flex gap-2 justify-between",children:[L,B]}),e[42]=L,e[43]=B,e[44]=O):O=e[44];let Q;return e[45]!==T||e[46]!==O||e[47]!==I?(Q=(0,r.jsxs)("form",{onSubmit:I,className:"space-y-4",children:[T,O]}),e[45]=T,e[46]=O,e[47]=I,e[48]=Q):Q=e[48],Q},Cs=t=>{let e=(0,W.c)(5),{onSubmit:s}=t,[o,n]=(0,K.useState)(null);if(!o){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,r.jsx)(xs,{onSelect:n}),e[0]=l):l=e[0],l}let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=()=>n(null),e[1]=a):a=e[1];let c;return e[2]!==s||e[3]!==o?(c=(0,r.jsx)(ks,{schema:o,onSubmit:s,onBack:a}),e[2]=s,e[3]=o,e[4]=c):c=e[4],c};const As=t=>{let e=(0,W.c)(6),{children:s}=t,[o,n]=(0,K.useState)(!1),a;e[0]===s?a=e[1]:(a=(0,r.jsx)(kt,{asChild:!0,children:s}),e[0]=s,e[1]=a);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=(0,r.jsx)(Oe,{onClose:()=>n(!1)}),e[2]=c):c=e[2];let l;return e[3]!==o||e[4]!==a?(l=(0,r.jsxs)(jt,{open:o,onOpenChange:n,children:[a,c]}),e[3]=o,e[4]=a,e[5]=l):l=e[5],l},Oe=t=>{let e=(0,W.c)(4),{onClose:s}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,r.jsx)($t,{children:"Add Connection"}),e[0]=o):o=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,r.jsxs)(xt,{className:"mb-4",children:[o,(0,r.jsxs)(At,{children:["Connect to your database or data catalog to query data directly from your notebook. Learn more about how to connect to your database in our"," ",(0,r.jsx)(Rt,{href:"https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database",children:"docs."})]})]}),e[1]=n):n=e[1];let a;return e[2]===s?a=e[3]:(a=(0,r.jsxs)(Ct,{className:"max-h-[75vh] overflow-y-auto",children:[n,(0,r.jsx)(Cs,{onSubmit:()=>s()})]}),e[2]=s,e[3]=a),a};function js(t){return(0,r.jsx)(et,{value:t,children:Ne[t]},t)}export{Oe as n,As as t};
|