@marimo-team/frontend 0.24.1-dev42 → 0.24.1-dev43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/assets/{CellStatus-CfNQG_fZ.js → CellStatus-B6CWKORY.js} +1 -1
  2. package/dist/assets/ConnectedDataExplorerComponent-DZnvpjue.js +1 -0
  3. package/dist/assets/JsonOutput-BI2qFHVr.js +50 -0
  4. package/dist/assets/MarimoErrorOutput-BXh29HCp.js +6 -0
  5. package/dist/assets/RenderHTML-COTZYPO7.js +1 -0
  6. package/dist/assets/RunButton-DTUzITFm.js +1 -0
  7. package/dist/assets/VisuallyHidden-DurJ_JBW.js +1 -0
  8. package/dist/assets/{add-cell-with-ai-CGBEoX6T.js → add-cell-with-ai-B0RdHenk.js} +19 -19
  9. package/dist/assets/add-connection-dialog-CcnJ2LkX.js +166 -0
  10. package/dist/assets/agent-panel-PB0I1dIC.js +286 -0
  11. package/dist/assets/ai-model-dropdown-DjQy2bo-.js +3 -0
  12. package/dist/assets/app-config-button-COFLeJCU.js +1 -0
  13. package/dist/assets/{blob-ChElOQvm.js → blob-BBiZd3vX.js} +1 -1
  14. package/dist/assets/{cache-panel-CLfGxru6.js → cache-panel-MAXVmKkG.js} +1 -1
  15. package/dist/assets/cell-editor-5wcJHF0s.js +24 -0
  16. package/dist/assets/cell-link-BbAJokoX.js +1 -0
  17. package/dist/assets/cells-B1S_6FG3.js +227 -0
  18. package/dist/assets/chat-display-ClG9MRI_.js +1 -0
  19. package/dist/assets/chat-panel-BRoqCSCR.js +4 -0
  20. package/dist/assets/chat-ui-CNvkb287.js +4 -0
  21. package/dist/assets/circle--ysFeW9z.js +1 -0
  22. package/dist/assets/column-preview-D6cIOnWQ.js +1 -0
  23. package/dist/assets/command-palette-DtZy0Am-.js +1 -0
  24. package/dist/assets/common-BGLbVHCS.js +1 -0
  25. package/dist/assets/components-BAvTsivu.js +1 -0
  26. package/dist/assets/config-DcB2swfZ.js +1 -0
  27. package/dist/assets/context-Do8M9TDF.js +1 -0
  28. package/dist/assets/{datasource-C0_eJO-0.js → datasource-BrSYgi6C.js} +2 -2
  29. package/dist/assets/dependency-graph-panel-C13q-nga.js +5 -0
  30. package/dist/assets/{documentation-panel-CxjnCPq6.js → documentation-panel-CtQqNEQw.js} +1 -1
  31. package/dist/assets/{download-CxzOE8FX.js → download-CIdXYNHv.js} +1 -1
  32. package/dist/assets/dropdown-menu-CqNabM1f.js +1 -0
  33. package/dist/assets/edit-page-jAyDC21z.js +9 -0
  34. package/dist/assets/{error-entries-DCRQWi_N.js → error-entries-DEjvzkum.js} +1 -1
  35. package/dist/assets/{error-panel-Bx5cPw6N.js → error-panel-BvrDwUv8.js} +1 -1
  36. package/dist/assets/file-explorer-panel-DYujxxK-.js +1 -0
  37. package/dist/assets/{file-icons-DxXY84Jn.js → file-icons-Bo1Ewf1W.js} +1 -1
  38. package/dist/assets/file-name-input-BDGq0-ac.js +3 -0
  39. package/dist/assets/{floating-outline-gjfcwmyU.js → floating-outline-CNsG18LK.js} +1 -1
  40. package/dist/assets/{gallery-page-BI3aTl8u.js → gallery-page-4dZlIWMe.js} +1 -1
  41. package/dist/assets/{glide-data-editor-CrWGp7DP.js → glide-data-editor-BQNVc0zc.js} +2 -2
  42. package/dist/assets/home-page-CFAldshJ.js +4 -0
  43. package/dist/assets/html-to-image-DMn_7CCA.js +2 -0
  44. package/dist/assets/index-0VrRpta0.css +2 -0
  45. package/dist/assets/index-BBPHmHdW.js +29 -0
  46. package/dist/assets/input-DeyycFtq.js +7 -0
  47. package/dist/assets/{layout-BQjGHHu-.js → layout-Ddsz1eHh.js} +5 -5
  48. package/dist/assets/{logs-panel-D1RUMXL1.js → logs-panel-BSD1GETR.js} +1 -1
  49. package/dist/assets/markdown-renderer-DIXiKP4m.js +2 -0
  50. package/dist/assets/{mermaid-DtNubw9S.js → mermaid-CwvTqKGz.js} +2 -2
  51. package/dist/assets/{name-cell-input-DSKoNRk3.js → name-cell-input-zqypwqoZ.js} +1 -1
  52. package/dist/assets/{outline-panel-UIygpaO3.js → outline-panel-C5GAyqII.js} +1 -1
  53. package/dist/assets/packages-panel-CYLyGihe.js +1 -0
  54. package/dist/assets/{pair-with-agent-modal-Pl5cv7Gv.js → pair-with-agent-modal-CBIL9_6g.js} +2 -2
  55. package/dist/assets/panel-accordion-state-DmV3OgfX.js +1 -0
  56. package/dist/assets/panels-D53vWR00.js +4 -0
  57. package/dist/assets/{process-output-BWDSbk5d.js → process-output-DNhz9LLW.js} +1 -1
  58. package/dist/assets/{readonly-code-display-Bbnq-khe.js → readonly-code-display-CKT-gv1m.js} +1 -1
  59. package/dist/assets/readonly-python-code-De0vvuWh.js +1 -0
  60. package/dist/assets/{renderShortcut-Dj3NbkoC.js → renderShortcut-D9XYVNe3.js} +1 -1
  61. package/dist/assets/{reveal-component-Bgmfon3f.js → reveal-component-C0L5MU2W.js} +4 -4
  62. package/dist/assets/run-page-DXZapRtY.js +1 -0
  63. package/dist/assets/scratchpad-panel-ja6doGoa.js +1 -0
  64. package/dist/assets/secrets-panel-B7Rcwc2I.js +1 -0
  65. package/dist/assets/select-BUEX2Vfl.js +1 -0
  66. package/dist/assets/session-panel-ftyqfsYy.js +1 -0
  67. package/dist/assets/{skeleton-DGs-LrlZ.js → skeleton-CxFczTPo.js} +1 -1
  68. package/dist/assets/snippets-panel-BZ254lxN.js +1 -0
  69. package/dist/assets/{state-WVnIPIsw.js → state-MlBpc9qi.js} +3 -3
  70. package/dist/assets/{state-N_csMEH1.js → state-llVv0lIh.js} +1 -1
  71. package/dist/assets/switch-CBR-ykv3.js +1 -0
  72. package/dist/assets/tabs-c6mpccpH.js +1 -0
  73. package/dist/assets/{terminal-aLrVlOf6.js → terminal-OC_FnEas.js} +3 -3
  74. package/dist/assets/tracing-C0FGWieO.js +1 -0
  75. package/dist/assets/tracing-panel-LeIOi1Tv.js +2 -0
  76. package/dist/assets/{tree-actions-Ctf5W0DR.js → tree-actions-CrWpuExP.js} +1 -1
  77. package/dist/assets/useAddCell-DIdbaU70.js +1 -0
  78. package/dist/assets/useCellActionButton-DXyUqFdJ.js +1 -0
  79. package/dist/assets/{useDateFormatter-CfPcCT-J.js → useDateFormatter-BiqAQ-zI.js} +1 -1
  80. package/dist/assets/{useDeleteCell-6wcjnAMK.js → useDeleteCell-CSCMg7Up.js} +1 -1
  81. package/dist/assets/useDependencyPanelTab-Bt7aBDpS.js +1 -0
  82. package/dist/assets/useNotebookActions-ClT4GmnB.js +10 -0
  83. package/dist/assets/useNumberFormatter-DHJ9s6Vk.js +1 -0
  84. package/dist/assets/useRunCells-DHnbXALT.js +1 -0
  85. package/dist/assets/{useSplitCell-oIRu7Qlj.js → useSplitCell-CxlsGCB_.js} +1 -1
  86. package/dist/assets/{vega-component-D4OKyVdb.js → vega-component-CzgE5HEs.js} +1 -1
  87. package/dist/assets/write-secret-modal-BG_B6y1P.js +2 -0
  88. package/dist/index.html +57 -71
  89. package/package.json +1 -1
  90. package/src/components/datasources/datasources.tsx +16 -17
  91. package/src/components/editor/actions/useNotebookActions.tsx +50 -0
  92. package/src/components/editor/chrome/panels/components.tsx +1 -1
  93. package/src/components/editor/connections/__tests__/add-connection-button.test.tsx +129 -0
  94. package/src/components/editor/connections/add-connection-button.tsx +132 -0
  95. package/src/components/editor/connections/components.tsx +11 -0
  96. package/src/components/editor/connections/quick-add-data-sources.tsx +11 -11
  97. package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +109 -1
  98. package/src/components/storage/storage-inspector.tsx +15 -17
  99. package/src/core/codemirror/language/panel/sql.test.tsx +69 -0
  100. package/src/core/codemirror/language/panel/sql.tsx +81 -4
  101. package/dist/assets/ConnectedDataExplorerComponent-88Ojqyhx.js +0 -1
  102. package/dist/assets/DeferredRequestRegistry-C-SpvRCH.js +0 -1
  103. package/dist/assets/ImperativeModal-68zj0lxy.js +0 -1
  104. package/dist/assets/JsonOutput-pCdkYz4X.js +0 -50
  105. package/dist/assets/MarimoErrorOutput-b7bFhjgD.js +0 -6
  106. package/dist/assets/RSPContexts-D2JcYZo2.js +0 -1
  107. package/dist/assets/RenderHTML-BUuDW4yZ.js +0 -1
  108. package/dist/assets/RunButton-4MKgVYXU.js +0 -1
  109. package/dist/assets/SSRProvider-C_WMmqnS.js +0 -1
  110. package/dist/assets/add-connection-dialog-BcLKuMHt.js +0 -166
  111. package/dist/assets/agent-panel-BVyaNGyG.js +0 -286
  112. package/dist/assets/ai-model-dropdown-C_IoSmhR.js +0 -3
  113. package/dist/assets/app-config-button-BvpunAmJ.js +0 -1
  114. package/dist/assets/cell-editor-pKuytlrm.js +0 -24
  115. package/dist/assets/cell-link-D9d1y67_.js +0 -1
  116. package/dist/assets/cells-BdoPd1mK.js +0 -226
  117. package/dist/assets/chat-display-CbsB82vm.js +0 -1
  118. package/dist/assets/chat-panel-DCPKH1gP.js +0 -4
  119. package/dist/assets/chat-ui-BwLG6iSS.js +0 -4
  120. package/dist/assets/circle-plus-cm-FRu9O.js +0 -1
  121. package/dist/assets/column-preview-fku2dKeP.js +0 -1
  122. package/dist/assets/command-Cvmdzx0n.js +0 -1
  123. package/dist/assets/command-palette-BJFR8wKv.js +0 -1
  124. package/dist/assets/common-CQ9OqrFS.js +0 -1
  125. package/dist/assets/components-CaOG3LOY.js +0 -1
  126. package/dist/assets/config-xlrIxOZJ.js +0 -1
  127. package/dist/assets/context-Bf2wPdef.js +0 -1
  128. package/dist/assets/data-source-discovery-BsrDlL04.js +0 -1
  129. package/dist/assets/dependency-graph-panel-CxZJ5e7D.js +0 -5
  130. package/dist/assets/dialog-EjSc4yoH.js +0 -1
  131. package/dist/assets/dropdown-menu-BpI5klSq.js +0 -1
  132. package/dist/assets/edit-page-DwKN7vIP.js +0 -9
  133. package/dist/assets/field-YoG_gQAY.js +0 -1
  134. package/dist/assets/file-explorer-panel-CRrPqu3s.js +0 -1
  135. package/dist/assets/file-name-input-uFNWUWCc.js +0 -3
  136. package/dist/assets/focus-DgNLvj0o.js +0 -1
  137. package/dist/assets/form-CD2uATFu.js +0 -2
  138. package/dist/assets/form-GIq5QCAI.js +0 -1
  139. package/dist/assets/home-page-CYg3rQCB.js +0 -4
  140. package/dist/assets/html-to-image-Bt7Ld74W.js +0 -2
  141. package/dist/assets/index-CrsPwq0f.js +0 -29
  142. package/dist/assets/index-H2TMW127.css +0 -2
  143. package/dist/assets/input-BuOxQ3Wy.js +0 -1
  144. package/dist/assets/label-B67m1YH7.js +0 -1
  145. package/dist/assets/links-C7oaxPJK.js +0 -1
  146. package/dist/assets/markdown-renderer-C8IbrNw3.js +0 -2
  147. package/dist/assets/packages-panel-CIwyYf45.js +0 -1
  148. package/dist/assets/panel-accordion-state-DAAi8MPY.js +0 -1
  149. package/dist/assets/panels-DcguQKjE.js +0 -4
  150. package/dist/assets/popover-CgOo22ko.js +0 -1
  151. package/dist/assets/radio-group-DZoEgN7k.js +0 -1
  152. package/dist/assets/readonly-python-code-CyfabMFb.js +0 -1
  153. package/dist/assets/refresh-ccw-DrVG5f2L.js +0 -1
  154. package/dist/assets/request-registry-mNu7sXOU.js +0 -1
  155. package/dist/assets/run-page-Buh6gERG.js +0 -1
  156. package/dist/assets/scratchpad-panel-soCf5igY.js +0 -1
  157. package/dist/assets/secrets-panel-CCb8F6PC.js +0 -1
  158. package/dist/assets/select-DwqnFsyg.js +0 -1
  159. package/dist/assets/session-panel-BO4lOJc-.js +0 -1
  160. package/dist/assets/snippets-panel-CulFiQ0V.js +0 -1
  161. package/dist/assets/sparkles-30wHhAF5.js +0 -1
  162. package/dist/assets/state-B-K0k6lb.js +0 -1
  163. package/dist/assets/switch-VzdUoXkf.js +0 -1
  164. package/dist/assets/textarea-mD3C73jw.js +0 -1
  165. package/dist/assets/tracing-B_Qlv38-.js +0 -1
  166. package/dist/assets/tracing-panel--KVMPYqh.js +0 -2
  167. package/dist/assets/useCellActionButton-BDVM-sW-.js +0 -1
  168. package/dist/assets/useDependencyPanelTab-D4TnSeLa.js +0 -1
  169. package/dist/assets/useNotebookActions-gEpi1TfO.js +0 -10
  170. package/dist/assets/useNumberFormatter-BmUQe2Pf.js +0 -1
  171. package/dist/assets/usePress-CwOqeEX3.js +0 -7
  172. package/dist/assets/useRunCells-DP6cAHq0.js +0 -1
  173. package/dist/assets/write-secret-modal-dplU5PG8.js +0 -2
  174. package/dist/assets/x-BgkoSHM-.js +0 -1
@@ -1,6 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t,d as n,f as r,l as i,r as a,t as o,u as s}from"./useEvent-xfs0Sn4r.js";import{t as c}from"./react-CBDbhulC.js";import{E as l,Pr as u,Rn as d,Ui as f,Wi as p,Wn as m,Zn as h,ia as g,it as _,kr as v,xa as y,y as b}from"./cells-BdoPd1mK.js";import{t as x}from"./compiler-runtime-CYIjoINj.js";import{g as S,p as C}from"./useEventListener-D27Dii_l.js";import{t as w}from"./invariant-Ci2dTZ72.js";import{a as T,i as E,x as D}from"./utils-R_pHe-RB.js";import{t as ee}from"./cn-ldLVeaqm.js";import{t as O}from"./jsx-runtime-B74pBk57.js";import{a as k,i as A,o as j,r as te,t as ne}from"./config-xlrIxOZJ.js";import{a as M,p as N,r as P,t as re}from"./dropdown-menu-BpI5klSq.js";import{t as F}from"./tooltip-D7dq6bnc.js";import{r as ie,t as I}from"./button-BMBznEru.js";import{n as ae}from"./strings-CpYReX2Q.js";import{t as oe}from"./createLucideIcon-B7HeEoG2.js";import{t as se}from"./check-BoA6XBpj.js";import{r as ce}from"./x-BgkoSHM-.js";import{t as le}from"./chevron-right-CKA5zVsM.js";import{t as ue}from"./hat-glasses-C8LSY3HT.js";import{t as de}from"./package-DPlscLzt.js";import{t as fe}from"./sparkles-30wHhAF5.js";import{l as pe,r as me}from"./datasource-C0_eJO-0.js";import{a as he}from"./dist-DzAWvPVK.js";import{t as ge}from"./uuid-k9DpjH68.js";import{t as _e}from"./use-toast-DpWHUGuF.js";import{t as ve}from"./RenderHTML-BUuDW4yZ.js";import{t as L}from"./kbd-Cwh96ZBE.js";import{t as R}from"./links-C7oaxPJK.js";import{r as ye,t as be}from"./alert-dmKwNsrp.js";import{o as xe,t as Se}from"./useInstallPackage-Bq7SlWgN.js";import{n as Ce,o as we}from"./state-N_csMEH1.js";import{n as z}from"./cell-link-D9d1y67_.js";var B=oe(`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`}]]),Te=oe(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),V=e(c(),1),H=x(),Ee=String.raw`_cell_([^\W_][\w-]*?)(_\w*)`,De=String.raw`(?<!_)${Ee}`;RegExp(`^${Ee}$`);var Oe=new RegExp(De),U=new RegExp(De,`g`);function ke(e){let t=[];U.lastIndex=0;let n=0,r=U.exec(e);for(;r!==null;)r.index>n&&t.push(e.slice(n,r.index)),t.push({cellId:r[1],name:r[2]}),n=r.index+r[0].length,r=U.exec(e);return n<e.length&&t.push(e.slice(n)),t}function Ae(e){return Oe.test(e)}function je(e){let t=null,n=e.cursor();do n.name===`ExpressionStatement`&&(t=n.node);while(n.next());return t}function Me(e){let t=e.split(`
2
- `),n=` `,r=je(he.parse(e));if(!r)return[`def _():`,...W(t,n),`${n}return`,``,``,`_()`].join(`
3
- `);let i=e.slice(0,r.from).trim(),a=e.slice(r.from).trim(),o=i.split(`
4
- `),s=a.split(`
5
- `);return[`def _():`,...W(o,n),`${n}return ${s[0]}`,...W(s.slice(1),n),``,``,`_()`].join(`
6
- `)}function W(e,t){if(e.length===1&&e[0]===``)return[];let n=[];for(let r of e)r===``?n.push(``):n.push(t+r);return n}function Ne(e,t){if(e.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 e=>{w(e.editor,`Editor is null`);let t=Me(e.editor.state.doc.toString());e.editor.dispatch({changes:{from:0,to:e.editor.state.doc.length,insert:t}})}}];if(e.type===`exception`&&e.exception_type===`NameError`){let t=e.msg.match(/name '(.+)' is not defined/)?.[1];if(!t||!(t in G))return[];let n=Pe(t);return[{title:`Fix: Add '${n}'`,description:`Add a new cell for the missing import`,fixType:`manual`,onFix:async e=>{e.addCodeBelow(n)}}]}return e.type===`sql-error`&&t.aiEnabled?[{title:`Fix with AI`,description:`Fix the SQL statement`,fixType:`ai`,onFix:async t=>{let n=me(t.cellId,a),r=`Fix the SQL statement: ${e.msg}.`;n&&(r+=`\nDatabase schema: ${n}`),t.aiFix?.setAiCompletionCell({cellId:t.cellId,initialPrompt:r,triggerImmediately:t.aiFix.triggerFix})}}]:[]}function Pe(e){let t=G[e];return t===e?`import ${t}`:`import ${t} as ${e}`}var G={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`},K=g(`marimo:acp:sessions:v1`,{sessions:[],activeTabId:null},m),Fe=r(e=>{let t=e(K);return t.activeTabId&&t.sessions.find(e=>e.tabId===t.activeTabId)||null},(e,t,n)=>{t(K,e=>({...e,activeTabId:n}))});function Ie(){return`tab_${ge()}`}function Le(e,t=20){return e.length<=t?e:`${e.slice(0,t-3)}...`}function Re(e,t){let n=Ke(t.agentId),r=Date.now(),i=t.firstMessage?Le(t.firstMessage.trim()):`New ${t.agentId} session`,a=Ie();if(n===`single`){let n=e.sessions.filter(e=>e.agentId===t.agentId),a=e.sessions.filter(e=>e.agentId!==t.agentId);if(n.length>0){let o=n[0],s={agentId:t.agentId,title:i,createdAt:r,lastUsedAt:r,tabId:o.tabId,externalAgentSessionId:null,selectedModel:t.model??o.selectedModel??null};return{...e,sessions:[...a.slice(0,0),s],activeTabId:s.tabId}}}return{...e,sessions:[...e.sessions.slice(0,0),{agentId:t.agentId,tabId:a,title:i,createdAt:r,lastUsedAt:r,externalAgentSessionId:null,selectedModel:t.model??null}],activeTabId:a}}function ze(e,t){let n=e.sessions.filter(e=>e.tabId!==t);return{sessions:n,activeTabId:e.activeTabId===t?n.length>0?n[n.length-1].tabId:null:e.activeTabId}}function Be(e,t){let n=e.activeTabId;return n?{...e,sessions:e.sessions.map(e=>e.tabId===n?{...e,title:Le(t)}:e)}:e}function Ve(e,t){return{...e,sessions:e.sessions.map(e=>e.tabId===t?{...e,lastUsedAt:Date.now()}:e)}}function He(e,t){let n=e.activeTabId;return n?{...e,sessions:e.sessions.map(e=>e.tabId===n?{...e,externalAgentSessionId:t,lastUsedAt:Date.now()}:e)}:e}function Ue(){return[`claude`,`gemini`,`codex`,`opencode`,`cursor`]}function We(e){return ae(e)}function Ge(e){let t=q[e].port,n=window.location.hostname;return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${n}:${t}/message`}var q={claude:{port:3017,command:`npx @zed-industries/claude-code-acp`,sessionSupport:`single`},gemini:{port:3019,command:`npx @google/gemini-cli --experimental-acp`,sessionSupport:`single`},codex:{port:3021,command:`npx @zed-industries/codex-acp`,sessionSupport:`single`},opencode:{port:3023,command:`npx opencode-ai acp`,sessionSupport:`single`},cursor:{port:3025,command:`agent acp`,sessionSupport:`single`}};function Ke(e){return q[e].sessionSupport}function qe(e){let t=q[e].port,n=q[e].command;return`npx stdio-to-ws "${C()?`cmd /c ${n}`:n}" --port ${t}`}var Je=g(`marimo:chrome:ai-panel-tab`,`chat`,m);function Ye(){let e=(0,H.c)(3),[n,r]=t(Je),i;return e[0]!==n||e[1]!==r?(i={aiPanelTab:n,setAiPanelTab:r},e[0]=n,e[1]=r,e[2]=i):i=e[2],i}var Xe=`code_mode`;function Ze(e,t){return e||(h(`external_agents`)?t:`chat`)}function Qe(){let e=(0,H.c)(6),{openApplication:t}=d(),{setAiPanelTab:r}=Ye(),{saveModeChange:i}=ne(),a=s(we),c=n(),l;return e[0]!==t||e[1]!==i||e[2]!==r||e[3]!==a||e[4]!==c?(l=async e=>{let n=Ze(e.panel,c.get(Je)),o=c.get(T),s=h(`external_agents`)&&c.get(K).sessions.length>0;if(!(n===`agents`?s:o)){_e({title:n===`agents`?`No agent session`:`AI not configured`,description:n===`agents`?`Start an agent session or switch to the chat panel.`:`Configure an AI provider and chat model to fix with AI.`,variant:`danger`});return}e.panel&&r(e.panel),n===`chat`&&await i(Xe).catch($e),a({prompt:e.prompt,submit:e.submit??!1}),t(`ai`)},e[0]=t,e[1]=i,e[2]=r,e[3]=a,e[4]=c,e[5]=l):l=e[5],o(l)}function $e(){return S.error(`Failed to save mode change`)}var et=g(`marimo:ai-autofix-mode`,`autofix`,m);function tt(){let e=(0,H.c)(3),[n,r]=t(et),i;return e[0]!==n||e[1]!==r?(i={fixMode:n,setFixMode:r},e[0]=n,e[1]=r,e[2]=i):i=e[2],i}var J=O();function nt(e,t){if(e!=null)return`@error://${e}\n\nPlease fix this error.`;let n=t?.trim();return n?`My code gives the following error. Please fix it:\n\n${n}`:`Please fix this error.`}var Y=e=>{let t=(0,H.c)(25),{errors:r,cellId:a,className:o}=e,c=n(),{createNewCell:u}=l(),d=i(E),f;if(t[0]!==d||t[1]!==r){let e;t[3]===d?e=t[4]:(e=e=>Ne(e,{aiEnabled:d}),t[3]=d,t[4]=e),f=r.flatMap(e),t[0]=d,t[1]=r,t[2]=f}else f=t[2];let p=f,m=s(Ce),h=Qe();if(p.length===0)return null;let g=p[0],_;t[5]!==a||t[6]!==u||t[7]!==g||t[8]!==m||t[9]!==c?(_=e=>{let t=c.get(b).cellHandles[a].current?.editorView;g.onFix({addCodeBelow:e=>{u({cellId:a,autoFocus:!1,before:!1,code:e})},editor:t,cellId:a,aiFix:{setAiCompletionCell:m,triggerFix:e}}),t?.focus()},t[5]=a,t[6]=u,t[7]=g,t[8]=m,t[9]=c,t[10]=_):_=t[10];let v=_,y;t[11]!==a||t[12]!==h?(y=()=>{h({prompt:nt(a)})},t[11]=a,t[12]=h,t[13]=y):y=t[13];let x=y,S;t[14]===o?S=t[15]:(S=ee(`my-2`,o),t[14]=o,t[15]=S);let C;t[16]!==g.description||t[17]!==g.fixType||t[18]!==g.title||t[19]!==v||t[20]!==x?(C=g.fixType===`ai`?(0,J.jsx)(at,{tooltip:g.description,openPrompt:()=>v(!1),applyAutofix:()=>v(!0),openChat:x}):(0,J.jsx)(F,{content:g.description,align:`start`,children:(0,J.jsxs)(I,{size:`xs`,variant:`outline`,className:`font-normal`,onClick:()=>v(!1),children:[(0,J.jsx)(pe,{className:`h-3 w-3 mr-2`}),g.title]})}),t[16]=g.description,t[17]=g.fixType,t[18]=g.title,t[19]=v,t[20]=x,t[21]=C):C=t[21];let w;return t[22]!==S||t[23]!==C?(w=(0,J.jsx)(`div`,{className:S,children:C}),t[22]=S,t[23]=C,t[24]=w):w=t[24],w},rt={autofix:{Icon:pe,title:`Inline AI Fix`,description:`Apply AI fixes inline in the cell`},chat:{Icon:ue,title:`Fix with AI assistant`,description:`Open the AI sidebar to fix`},prompt:{Icon:fe,title:`Suggest a prompt`,description:`Edit the prompt before applying`}},it=[`autofix`,`prompt`,`chat`],at=e=>{let t=(0,H.c)(18),{tooltip:n,openPrompt:r,applyAutofix:i,openChat:a}=e,{fixMode:o,setFixMode:s}=tt(),c=r;o===`chat`?c=a:o===`autofix`&&(c=i);let{Icon:l,title:u}=rt[o],d;t[0]===l?d=t[1]:(d=(0,J.jsx)(l,{className:`h-3 w-3 mr-2 mb-0.5`}),t[0]=l,t[1]=d);let f;t[2]!==c||t[3]!==d||t[4]!==u?(f=(0,J.jsxs)(I,{size:`xs`,variant:`outline`,className:`font-normal rounded-r-none border-r-0`,onClick:c,children:[d,u]}),t[2]=c,t[3]=d,t[4]=u,t[5]=f):f=t[5];let p;t[6]!==f||t[7]!==n?(p=(0,J.jsx)(F,{content:n,align:`start`,children:f}),t[6]=f,t[7]=n,t[8]=p):p=t[8];let m;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,J.jsx)(N,{asChild:!0,children:(0,J.jsx)(I,{size:`xs`,variant:`outline`,className:`rounded-l-none px-2`,"aria-label":`Fix options`,children:(0,J.jsx)(ce,{className:`h-3 w-3`})})}),t[9]=m):m=t[9];let h;t[10]!==o||t[11]!==s?(h=it.map(e=>(0,J.jsx)(M,{className:`flex items-center gap-2`,onClick:()=>s(e),children:(0,J.jsx)(ot,{mode:e,selected:e===o})},e)),t[10]=o,t[11]=s,t[12]=h):h=t[12];let g;t[13]===h?g=t[14]:(g=(0,J.jsxs)(re,{children:[m,(0,J.jsx)(P,{align:`end`,className:`w-56`,children:h})]}),t[13]=h,t[14]=g);let _;return t[15]!==p||t[16]!==g?(_=(0,J.jsxs)(`div`,{className:`flex`,children:[p,g]}),t[15]=p,t[16]=g,t[17]=_):_=t[17],_},ot=e=>{let t=(0,H.c)(15),{mode:n,selected:r}=e,{Icon:i,title:a,description:o}=rt[n],s;t[0]===i?s=t[1]:(s=(0,J.jsx)(i,{className:`h-4 w-4 shrink-0`}),t[0]=i,t[1]=s);let c;t[2]===a?c=t[3]:(c=(0,J.jsx)(`span`,{className:`font-medium`,children:a}),t[2]=a,t[3]=c);let l;t[4]===o?l=t[5]:(l=(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o}),t[4]=o,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===r?d=t[10]:(d=r&&(0,J.jsx)(se,{className:`h-4 w-4 ml-auto shrink-0`}),t[9]=r,t[10]=d);let f;return t[11]!==s||t[12]!==u||t[13]!==d?(f=(0,J.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[s,u,d]}),t[11]=s,t[12]=u,t[13]=d,t[14]=f):f=t[14],f},st=e=>{let t=(0,H.c)(12),{local:n}=e,r;t[0]===n.name?r=t[1]:(r=(0,J.jsx)(`span`,{className:`font-code`,children:n.name}),t[0]=n.name,t[1]=r);let i;t[2]===n.cellId?i=t[3]:(i=(0,J.jsx)(z,{cellId:n.cellId}),t[2]=n.cellId,t[3]=i);let a;t[4]!==r||t[5]!==i?(a=(0,J.jsxs)(`div`,{className:`max-w-xs`,children:[`Local variable `,r,` in cell`,` `,i,`.`]}),t[4]=r,t[5]=i,t[6]=a):a=t[6];let o=a,s;t[7]===n.name?s=t[8]:(s=(0,J.jsx)(`span`,{className:`font-code cursor-help`,children:n.name}),t[7]=n.name,t[8]=s);let c;return t[9]!==s||t[10]!==o?(c=(0,J.jsx)(F,{content:o,children:s}),t[9]=s,t[10]=o,t[11]=c):c=t[11],c},ct=e=>{let t=(0,H.c)(4),{segments:n}=e,r;t[0]===n?r=t[1]:(r=n.map(lt),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(J.Fragment,{children:r}),t[2]=r,t[3]=i),i};function lt(e,t){return typeof e==`string`?(0,J.jsx)(`span`,{children:e},t):(0,J.jsx)(st,{local:e},t)}var ut=new _,X=e=>{let t=RegExp(`\x1B\\[[0-9;]*m`,`g`);return e.replaceAll(t,``)},dt=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function ft(e){dt.lastIndex=0;let t=dt.exec(e);if(!t)return null;let n=t.index+t[0].length,r=e.slice(n).split(/\s+/),i=``,a=0;for(let e of r){let t=e.trim();if(!t)continue;if(t.startsWith(`-`)){a+=t.length+1;continue}let n=t.match(/^[\w,.[\]-]+/);if(n){i=n[0];break}break}if(!i)return null;let o=n+a+i.length;return{package:i,endIndex:o}}function Z(e,t=``){if(!e)return null;if(!/https?:\/\//.test(e))return e;let n=y(e);return n.length===1&&n[0].type===`text`?e:(0,J.jsx)(J.Fragment,{children:n.map((e,n)=>{let r=t?`${t}-${n}`:n;if(e.type===`url`){let t=X(e.url);return(0,J.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,onClick:ie.stopPropagation(),className:`text-link hover:underline`,children:t},r)}if(e.type===`image`){let t=X(e.url);return(0,J.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,onClick:ie.stopPropagation(),className:`text-link hover:underline`,children:t},r)}return(0,J.jsx)(V.Fragment,{children:e.value},r)})})}var pt=e=>{let t=(0,H.c)(6),{packages:n,children:r}=e,{handleInstallPackages:i}=Se(),a;t[0]!==i||t[1]!==n?(a=e=>{i(n),e.preventDefault()},t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==r||t[4]!==a?(o=(0,J.jsx)(`button`,{onClick:a,className:`text-link hover:underline`,type:`button`,children:r}),t[3]=r,t[4]=a,t[5]=o):o=t[5],o},mt=e=>{if(!(e instanceof p.Text))return;let t=X(e.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(t))return;let n=[],r=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=r.exec(t))!==null;){let e=i.index,r=ft(t.slice(e));r&&n.push({match:i,result:r})}if(n.length===0)return;let a=[],o=0;if(n.forEach((e,n)=>{let{match:r,result:i}=e,s=r.index,c=s+i.endIndex;if(o<s){let e=t.slice(o,s);a.push((0,J.jsx)(V.Fragment,{children:Z(e,`before-${n}`)},`before-${n}`))}let l=t.slice(s,c);a.push((0,J.jsx)(pt,{packages:[i.package],children:l},`install-${n}`)),o=c}),o<t.length){let e=t.slice(o);a.push((0,J.jsx)(V.Fragment,{children:Z(e,`after`)},`after`))}return(0,J.jsx)(J.Fragment,{children:a})},ht=e=>{if(!(e instanceof p.Text))return;let t=e.data;if(!/https?:\/\//.test(t))return;let n=Z(t);if(typeof n!=`string`)return(0,J.jsx)(J.Fragment,{children:n})},gt=(...e)=>t=>{for(let n of e){let e=n(t);if(e!==void 0)return e}},_t=(e,t)=>{let n=ut.ansi_to_html(e),r=f(n,{replace:e=>t(e)});return(0,J.jsx)(`span`,{children:r})},vt=e=>{let t=(0,H.c)(4),{text:n}=e,r;t[0]===n?r=t[1]:(r=_t(n,gt(mt,ht)),t[0]=n,t[1]=r);let i=r,a;return t[2]===i?a=t[3]:(a=(0,J.jsx)(J.Fragment,{children:i}),t[2]=i,t[3]=a),a},Q=e=>{let t=(0,H.c)(16),{traceback:n}=e,[r,i]=(0,V.useState)(!0),a;t[0]===r?a=t[1]:(a=()=>i(!r),t[0]=r,t[1]=a);let o=r?`Collapse traceback`:`Expand traceback`,s;t[2]===r?s=t[3]:(s=r?(0,J.jsx)(ce,{className:`h-3 w-3`}):(0,J.jsx)(le,{className:`h-3 w-3`}),t[2]=r,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,J.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wider`,children:`Traceback`}),t[4]=c):c=t[4];let l;t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s?(l=(0,J.jsxs)(`button`,{type:`button`,onClick:a,"aria-expanded":r,"aria-label":o,className:`flex items-center gap-1 text-muted-foreground/70 hover:text-muted-foreground transition-colors`,children:[s,c]}),t[5]=r,t[6]=a,t[7]=o,t[8]=s,t[9]=l):l=t[9];let u;t[10]!==r||t[11]!==n?(u=r&&(0,J.jsx)(`div`,{className:`font-code text-sm mt-1 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text`,children:ve({html:n})}),t[10]=r,t[11]=n,t[12]=u):u=t[12];let d;return t[13]!==l||t[14]!==u?(d=(0,J.jsxs)(`div`,{className:`mt-2`,children:[l,u]}),t[13]=l,t[14]=u,t[15]=d):d=t[15],d},$=e=>{let t=(0,H.c)(10),n=e.title??`Tip`,r;t[0]===n?r=t[1]:(r=(0,J.jsx)(j,{className:`pt-2 pb-0 font-normal`,children:n}),t[0]=n,t[1]=r);let i;t[2]===e.children?i=t[3]:(i=(0,J.jsx)(A,{className:`mr-24 text-[0.84375rem]`,wrapperClassName:`pt-0 pb-2`,children:e.children}),t[2]=e.children,t[3]=i);let a;t[4]!==r||t[5]!==i?(a=(0,J.jsxs)(k,{value:`item-1`,className:`text-muted-foreground`,children:[r,i]}),t[4]=r,t[5]=i,t[6]=a):a=t[6];let o;return t[7]!==e.className||t[8]!==a?(o=(0,J.jsx)(te,{type:`single`,collapsible:!0,className:e.className,children:a}),t[7]=e.className,t[8]=a,t[9]=o):o=t[9],o},yt=e=>{let t=(0,H.c)(38),{errors:n,cellId:r,className:a}=e,o=d(),s=i(D).display.cell_output===`above`,c=`This cell wasn't run because it has errors`,l=`destructive`,f=`text-error`,p=null;if(n.some(bt))c=`Interrupted`;else if(n.some(xt))c=`An internal error occurred`;else if(n.some(St))c=`Ancestor prevented from running`,l=`default`,f=`text-secondary-foreground`;else if(n.some(Ct))c=`Ancestor stopped`,l=`default`,f=`text-secondary-foreground`;else if(n.some(wt))c=`SQL error`;else if(n.some(Tt))c=null,p=`Cell not run`;else{let e;t[0]===n?e=t[1]:(e=n.find(Et),t[0]=n,t[1]=e);let r=e;r&&`exception_type`in r&&(c=r.exception_type)}let m,h,g,_,y,b;if(t[2]!==l||t[3]!==r||t[4]!==o||t[5]!==a||t[6]!==n||t[7]!==s||t[8]!==p||t[9]!==f||t[10]!==c){let e=n.filter(Dt),i=n.filter(Ot),d=n.filter(kt),x=n.filter(At),S=n.filter(jt),C=n.filter(Mt),w=n.filter(Nt),T=n.filter(Pt),E=n.filter(Ft),D=n.filter(It),O=n.filter(Lt),k=n.filter(Rt),A=n.filter(zt),j;t[17]===o?j=t[18]:(j=()=>{o.openApplication(`scratchpad`)},t[17]=o,t[18]=j);let te=j,ne=()=>{let t=[];if(O.length>0||k.length>0){let e=O.some(Bt),n=!e&&O.some(Vt);t.push((0,J.jsxs)(`div`,{children:[O.map(Ht),k.map(Ut),e&&(0,J.jsxs)(I,{size:`xs`,variant:`outline`,className:`mt-2 font-normal`,onClick:()=>xe(o),children:[(0,J.jsx)(de,{className:`h-3.5 w-3.5 mr-1.5 mb-0.5`}),(0,J.jsx)(`span`,{children:`Open package manager`})]}),n&&(0,J.jsxs)(I,{size:`xs`,variant:`outline`,className:`mt-2 font-normal`,onClick:()=>o.openApplication(`terminal`),children:[(0,J.jsx)(Te,{className:`h-3.5 w-3.5 mr-1.5`}),(0,J.jsx)(`span`,{children:`Open terminal`})]}),r&&(0,J.jsx)(Y,{errors:[...O,...k],cellId:r})]},`syntax-unknown`))}if(e.length>0&&t.push((0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-muted-foreground font-medium`,children:`The setup cell cannot be run because it has references.`}),(0,J.jsx)(`ul`,{className:`list-disc`,children:e.flatMap(Wt)}),r&&(0,J.jsx)(Y,{errors:e,cellId:r}),(0,J.jsxs)($,{title:`Why can't the setup cell have references?`,className:`mb-2`,children:[(0,J.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,J.jsx)(`p`,{className:`py-2`,children:`Try simplifying the setup cell to only contain only necessary variables.`}),(0,J.jsxs)(`p`,{className:`py-2`,children:[(0,J.jsxs)(R,{href:`https://links.marimo.app/errors-setup`,children:[`Learn more at our docs`,` `,(0,J.jsx)(B,{size:`0.75rem`,className:`inline`})]}),`.`]})]})]},`setup-refs`)),i.length>0&&t.push((0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-muted-foreground font-medium`,children:`This cell is in a cycle.`}),(0,J.jsx)(`ul`,{className:`list-disc`,children:i.flatMap(Gt)}),r&&(0,J.jsx)(Y,{errors:i,cellId:r}),(0,J.jsxs)($,{title:`What are cycles and how do I resolve them?`,className:`mb-2`,children:[(0,J.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,J.jsx)(`p`,{className:`py-2`,children:`Try merging these cells into a single cell to eliminate the cycle.`}),(0,J.jsxs)(`p`,{className:`py-2`,children:[(0,J.jsxs)(R,{href:`https://links.marimo.app/errors-cycles`,children:[`Learn more at our docs`,` `,(0,J.jsx)(B,{size:`0.75rem`,className:`inline`})]}),`.`]})]})]},`cycle`)),d.length>0){let e=d[0].name;t.push((0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-muted-foreground font-medium`,children:`This cell redefines variables from other cells.`}),d.map(qt),r&&(0,J.jsx)(Y,{errors:d,cellId:r}),(0,J.jsxs)($,{title:`Why can't I redefine variables?`,children:[(0,J.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,J.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,J.jsxs)(L,{className:`inline`,children:[`_`,e]}),`). to make them private to this cell.`]}),(0,J.jsxs)(`p`,{className:`py-2`,children:[(0,J.jsxs)(R,{href:`https://links.marimo.app/errors-multiple-definitions`,children:[`Learn more at our docs`,` `,(0,J.jsx)(B,{size:`0.75rem`,className:`inline`})]}),`.`]})]}),(0,J.jsx)($,{title:`Need a scratchpad?`,children:(0,J.jsxs)(`div`,{className:`flex flex-row gap-2 items-center`,children:[(0,J.jsxs)(I,{size:`xs`,variant:`link`,className:`my-2 font-normal mx-0 px-0`,onClick:te,children:[(0,J.jsx)(v,{className:`h-3`}),(0,J.jsx)(`span`,{children:`Try the scratchpad`})]}),(0,J.jsx)(`span`,{children:`to experiment without restrictions on variable names.`})]})})]},`multiple-defs`))}return x.length>0&&t.push((0,J.jsxs)(`div`,{children:[x.map(Jt),r&&(0,J.jsx)(Y,{errors:x,cellId:r}),(0,J.jsxs)($,{title:"Why can't I use `import *`?",children:[(0,J.jsx)(`p`,{className:`pb-2`,children:`Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution.`}),(0,J.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,J.jsx)(`p`,{className:`py-2`,children:`Star imports would also silently add names to globals, which would be incompatible with reactive execution.`}),(0,J.jsxs)(`p`,{className:`py-2`,children:[(0,J.jsxs)(R,{href:`https://links.marimo.app/errors-import-star`,children:[`Learn more at our docs`,` `,(0,J.jsx)(B,{size:`0.75rem`,className:`inline`})]}),`.`]})]})]},`import-star`)),S.length>0&&t.push((0,J.jsxs)(`div`,{children:[S.map(Yt),r&&(0,J.jsx)(Y,{errors:S,cellId:r})]},`interruption`)),C.length>0&&t.push((0,J.jsxs)(`ul`,{children:[C.map((e,t)=>{if(e.exception_type===`NameError`&&e.msg.startsWith(`name 'mo'`))return(0,J.jsx)(`li`,{className:`my-2`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`name 'mo' is not defined.`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground mt-2`,children:[`The marimo module (imported as`,` `,(0,J.jsx)(L,{className:`inline`,children:`mo`}),`) is required for Markdown, SQL, and UI elements.`]})]})},`exception-${t}`);if(e.exception_type===`NameError`&&e.msg.startsWith(`name '_`)){let n=ke(e.msg);return(0,J.jsx)(`li`,{className:`my-2`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:(0,J.jsx)(ct,{segments:n})}),(0,J.jsxs)(`p`,{className:`text-muted-foreground mt-2`,children:[`Variables prefixed with an underscore are local to a cell`,` `,`(`,(0,J.jsxs)(R,{href:`https://links.marimo.app/local-variables`,children:[`docs`,` `,(0,J.jsx)(B,{size:`0.75rem`,className:`inline`})]}),`).`]}),s&&(0,J.jsx)(`div`,{className:`text-muted-foreground mt-2`,children:`See the console area for a traceback.`})]})},`exception-${t}`)}return(0,J.jsx)(`li`,{className:`my-2`,children:e.raising_cell==null?(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:Z(e.msg,`exception-${t}`)}),`traceback`in e&&e.traceback?(0,J.jsx)(Q,{traceback:e.traceback}):s&&(0,J.jsx)(`div`,{className:`text-muted-foreground mt-2`,children:`See the console area for a traceback.`})]}):(0,J.jsxs)(`div`,{children:[Z(e.msg,`exception-${t}`),(0,J.jsx)(z,{cellId:e.raising_cell}),`traceback`in e&&e.traceback&&(0,J.jsx)(Q,{traceback:e.traceback})]})},`exception-${t}`)}),C.some(Xt)&&(0,J.jsx)($,{children:`Fix the error in the mentioned cells, or handle the exceptions with try/except blocks.`}),r&&(0,J.jsx)(Y,{errors:C,cellId:r})]},`exception`)),w.length>0&&t.push((0,J.jsxs)(`ul`,{children:[w.map(Zt),r&&(0,J.jsx)(Y,{errors:w,cellId:r}),(0,J.jsx)($,{children:w.some(Qt)?`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`)),T.length>0&&t.push((0,J.jsxs)(`div`,{children:[T.map($t),r&&(0,J.jsx)(Y,{errors:T,cellId:r})]},`internal`)),E.length>0&&t.push((0,J.jsxs)(`div`,{children:[E.map(en),r&&(0,J.jsx)(Y,{errors:E,cellId:r})]},`ancestor-prevented`)),D.length>0&&t.push((0,J.jsxs)(`div`,{children:[D.map(tn),r&&(0,J.jsx)(Y,{errors:D,cellId:r})]},`ancestor-stopped`)),A.length>0&&t.push((0,J.jsxs)(`div`,{children:[A.map(nn),r&&(0,J.jsx)(Y,{errors:A,cellId:r,className:`mt-2.5`})]},`sql-errors`)),t},M;t[19]===p?M=t[20]:(M=p&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 font-code text-[0.6875rem] uppercase tracking-wider text-muted-foreground/70`,children:[p,(0,J.jsx)(F,{content:`marimo didn't run this cell because it detected an error.`,delayDuration:200,children:(0,J.jsx)(u,{className:`size-3 cursor-help`})})]}),t[19]=p,t[20]=M);let N;t[21]!==f||t[22]!==c?(N=c&&(0,J.jsx)(ye,{className:`font-code font-medium ${f}`,children:c}),t[21]=f,t[22]=c,t[23]=N):N=t[23];let P;t[24]!==M||t[25]!==N?(P=(0,J.jsxs)(`div`,{className:`space-y-0.5`,children:[M,N]}),t[24]=M,t[25]=N,t[26]=P):P=t[26];let re=P;m=be,_=l,t[27]===a?y=t[28]:(y=ee(`border-none font-code text-sm text-[0.84375rem] p-0 text-muted-foreground normal has-[svg]:pl-0 space-y-2`,a),t[27]=a,t[28]=y),b=re,h=`flex flex-col gap-4`,g=ne(),t[2]=l,t[3]=r,t[4]=o,t[5]=a,t[6]=n,t[7]=s,t[8]=p,t[9]=f,t[10]=c,t[11]=m,t[12]=h,t[13]=g,t[14]=_,t[15]=y,t[16]=b}else m=t[11],h=t[12],g=t[13],_=t[14],y=t[15],b=t[16];let x;t[29]!==h||t[30]!==g?(x=(0,J.jsx)(`div`,{className:h,children:g}),t[29]=h,t[30]=g,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==y||t[35]!==b||t[36]!==x?(S=(0,J.jsxs)(m,{variant:_,className:y,children:[b,x]}),t[32]=m,t[33]=_,t[34]=y,t[35]=b,t[36]=x,t[37]=S):S=t[37],S};function bt(e){return e.type===`interruption`}function xt(e){return e.type===`internal`}function St(e){return e.type===`ancestor-prevented`}function Ct(e){return e.type===`ancestor-stopped`}function wt(e){return e.type===`sql-error`}function Tt(e){return e.type===`multiple-defs`||e.type===`cycle`||e.type===`setup-refs`||e.type===`import-star`}function Et(e){return e.type===`exception`}function Dt(e){return e.type===`setup-refs`}function Ot(e){return e.type===`cycle`}function kt(e){return e.type===`multiple-defs`}function At(e){return e.type===`import-star`}function jt(e){return e.type===`interruption`}function Mt(e){return e.type===`exception`}function Nt(e){return e.type===`strict-exception`}function Pt(e){return e.type===`internal`}function Ft(e){return e.type===`ancestor-prevented`}function It(e){return e.type===`ancestor-stopped`}function Lt(e){return e.type===`syntax`}function Rt(e){return e.type===`unknown`}function zt(e){return e.type===`sql-error`}function Bt(e){return e.msg.includes(`!pip`)}function Vt(e){return e.msg.includes(`use os.subprocess`)}function Ht(e,t){return(0,J.jsx)(`pre`,{children:Z(e.msg,`syntax-${t}`)},`syntax-${t}`)}function Ut(e,t){return(0,J.jsx)(`pre`,{children:Z(e.msg,`unknown-${t}`)},`unknown-${t}`)}function Wt(e,t){return e.edges_with_vars.map((e,n)=>(0,J.jsxs)(`li`,{className:`my-0.5 ml-8 text-muted-foreground/40`,children:[(0,J.jsx)(z,{cellId:e[0]}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`: `,` `,e[1].length===1?e[1][0]:e[1].join(`, `)]})]},`setup-refs-${t}-${n}`))}function Gt(e,t){return e.edges_with_vars.map((e,n)=>(0,J.jsxs)(`li`,{className:`my-0.5 ml-8 text-muted-foreground/40`,children:[(0,J.jsx)(z,{cellId:e[0]}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[` -> `,e[1].length===1?e[1][0]:e[1].join(`, `),` -> `]}),(0,J.jsx)(z,{cellId:e[2]})]},`cycle-${t}-${n}`))}function Kt(e,t){return(0,J.jsx)(`li`,{className:`my-0.5 ml-8 text-muted-foreground/40`,children:(0,J.jsx)(z,{cellId:e})},`cell-${t}`)}function qt(e,t){return(0,J.jsxs)(V.Fragment,{children:[(0,J.jsx)(`p`,{className:`text-muted-foreground mt-2`,children:`'${e.name}' was also defined by:`}),(0,J.jsx)(`ul`,{className:`list-disc`,children:e.cells.map(Kt)})]},`multiple-defs-${t}`)}function Jt(e,t){return(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e.msg},`import-star-${t}`)}function Yt(e,t){return(0,J.jsx)(`p`,{children:`This cell was interrupted and needs to be re-run.`},`interruption-${t}`)}function Xt(e){return e.raising_cell!=null}function Zt(e,t){return(0,J.jsx)(`li`,{className:`my-2`,children:e.blamed_cell==null?(0,J.jsx)(`p`,{children:e.msg}):(0,J.jsxs)(`div`,{children:[e.msg,(0,J.jsx)(z,{cellId:e.blamed_cell})]})},`strict-exception-${t}`)}function Qt(e){return e.blamed_cell!=null}function $t(e,t){return(0,J.jsx)(`p`,{children:e.msg},`internal-${t}`)}function en(e,t){return(0,J.jsxs)(`div`,{children:[e.msg,e.blamed_cell==null?(0,J.jsxs)(`span`,{children:[`(`,(0,J.jsx)(z,{cellId:e.raising_cell}),`)`]}):(0,J.jsxs)(`span`,{children:[`(`,(0,J.jsx)(z,{cellId:e.raising_cell}),`\xA0blames\xA0`,(0,J.jsx)(z,{cellId:e.blamed_cell}),`)`]})]},`ancestor-prevented-${t}`)}function tn(e,t){return(0,J.jsxs)(`div`,{children:[e.msg,(0,J.jsx)(z,{cellId:e.raising_cell})]},`ancestor-stopped-${t}`)}function nn(e,t){return(0,J.jsx)(`div`,{className:`space-y-2 mt-2`,children:(0,J.jsx)(`p`,{className:`text-muted-foreground whitespace-pre-wrap`,children:e.msg})},`sql-error-${t}`)}export{Te as S,He as _,nt as a,Ae as b,Re as c,We as d,Ke as f,Fe as g,ze as h,at as i,K as l,Ue as m,vt as n,Qe as o,Ge as p,ct as r,Ye as s,yt as t,qe as u,Ve as v,ke as x,Be as y};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./react-CBDbhulC.js";import{$ as n,Y as r,et as i}from"./input-BuOxQ3Wy.js";import{D as a,F as o,I as s,L as c,N as l,P as u,T as d,V as f,c as p,j as m,k as ee,l as h,p as g,w as _,x as v}from"./usePress-CwOqeEX3.js";import{t as y}from"./context-Bf2wPdef.js";var te=class{get currentNode(){return this._currentNode}set currentNode(e){if(!m(this.root,e))throw Error(`Cannot set currentNode to a node that is not contained by the root node.`);let t=[],n=e,r=e;for(this._currentNode=e;n&&n!==this.root;)if(n.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let e=n,i=this._doc.createTreeWalker(e,this.whatToShow,{acceptNode:this._acceptNode});t.push(i),i.currentNode=r,this._currentSetFor.add(i),n=r=e.host}else n=n.parentNode;let i=this._doc.createTreeWalker(this.root,this.whatToShow,{acceptNode:this._acceptNode});t.push(i),i.currentNode=r,this._currentSetFor.add(i),this._walkerStack=t}get doc(){return this._doc}firstChild(){let e=this.currentNode,t=this.nextNode();return m(e,t)?(t&&(this.currentNode=t),t):(this.currentNode=e,null)}lastChild(){let e=this._walkerStack[0].lastChild();return e&&(this.currentNode=e),e}nextNode(){let e=this._walkerStack[0].nextNode();if(e){if(e.shadowRoot){let t;if(typeof this.filter==`function`?t=this.filter(e):this.filter?.acceptNode&&(t=this.filter.acceptNode(e)),t===NodeFilter.FILTER_ACCEPT)return this.currentNode=e,e;let n=this.nextNode();return n&&(this.currentNode=n),n}return e&&(this.currentNode=e),e}if(this._walkerStack.length>1){this._walkerStack.shift();let e=this.nextNode();return e&&(this.currentNode=e),e}return null}previousNode(){let e=this._walkerStack[0];if(e.currentNode===e.root){if(this._currentSetFor.has(e)){if(this._currentSetFor.delete(e),this._walkerStack.length>1){this._walkerStack.shift();let e=this.previousNode();return e&&(this.currentNode=e),e}return null}return null}let t=e.previousNode();if(t){if(t.shadowRoot){let e;if(typeof this.filter==`function`?e=this.filter(t):this.filter?.acceptNode&&(e=this.filter.acceptNode(t)),e===NodeFilter.FILTER_ACCEPT)return t&&(this.currentNode=t),t;let n=this.lastChild();return n&&(this.currentNode=n),n}return t&&(this.currentNode=t),t}if(this._walkerStack.length>1){this._walkerStack.shift();let e=this.previousNode();return e&&(this.currentNode=e),e}return null}nextSibling(){return null}previousSibling(){return null}parentNode(){return null}constructor(e,t,n,r){this._walkerStack=[],this._currentSetFor=new Set,this._acceptNode=e=>{if(e.nodeType===Node.ELEMENT_NODE){let t=e.shadowRoot;if(t){let e=this._doc.createTreeWalker(t,this.whatToShow,{acceptNode:this._acceptNode});return this._walkerStack.unshift(e),NodeFilter.FILTER_ACCEPT}if(typeof this.filter==`function`)return this.filter(e);if(this.filter?.acceptNode)return this.filter.acceptNode(e);if(this.filter===null)return NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP},this._doc=e,this.root=t,this.filter=r??null,this.whatToShow=n??NodeFilter.SHOW_ALL,this._currentNode=t,this._walkerStack.unshift(e.createTreeWalker(t,n,this._acceptNode));let i=t.shadowRoot;if(i){let e=this._doc.createTreeWalker(i,this.whatToShow,{acceptNode:this._acceptNode});this._walkerStack.unshift(e)}}};function b(e,t,n,r){return o()?new te(e,t,n,r):e.createTreeWalker(t,n,r)}var x=e(t(),1);function ne(e,t){let n=(0,x.useRef)(!0),r=(0,x.useRef)(null),i=g(e);(0,x.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]),(0,x.useEffect)(()=>{let e=r.current;n.current?n.current=!1:(!e||t.some((t,n)=>!Object.is(t,e[n])))&&i(),r.current=t},t)}function S(e,t){if(!e)return!1;let n=window.getComputedStyle(e),r=document.scrollingElement||document.documentElement,i=/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY);return e===r&&n.overflow!==`hidden`&&(i=!0),i&&t&&(i=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),i}function C(e,t){let n=e;for(S(n,t)&&(n=n.parentElement);n&&!S(n,t);)n=n.parentElement;return n||document.scrollingElement||document.documentElement}function w(e,t){let n=[],r=document.scrollingElement||document.documentElement;do S(e,t)&&n.push(e),e=e.parentElement;while(e&&e!==r);return n}function T(e){return _()?e.metaKey:e.ctrlKey}var E=new Set([`checkbox`,`radio`,`range`,`color`,`file`,`image`,`button`,`submit`,`reset`]);function D(e){return e instanceof HTMLInputElement&&!E.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var O=0,k=new Map;function A(e){let[t,n]=(0,x.useState)();return f(()=>{if(!e)return;let t=k.get(e);if(t)n(t.element.id);else{let r=`react-aria-description-${O++}`;n(r);let i=document.createElement(`div`);i.id=r,i.style.display=`none`,i.textContent=e,document.body.appendChild(i),t={refCount:0,element:i},k.set(e,t)}return t.refCount++,()=>{t&&--t.refCount===0&&(t.element.remove(),k.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}function j(e,t,n={}){let{block:r=`nearest`,inline:i=`nearest`}=n;if(e===t)return;let o=e.scrollTop,s=e.scrollLeft,c=t.getBoundingClientRect(),l=e.getBoundingClientRect(),u=window.getComputedStyle(t),d=window.getComputedStyle(e),f=document.scrollingElement||document.documentElement,p=e===f?0:l.top,m=e===f?e.clientHeight:l.bottom,ee=e===f?0:l.left,h=e===f?e.clientWidth:l.right,g=parseInt(u.scrollMarginTop,10)||0,_=parseInt(u.scrollMarginBottom,10)||0,v=parseInt(u.scrollMarginLeft,10)||0,y=parseInt(u.scrollMarginRight,10)||0,te=parseInt(d.scrollPaddingTop,10)||0,b=parseInt(d.scrollPaddingBottom,10)||0,x=parseInt(d.scrollPaddingLeft,10)||0,ne=parseInt(d.scrollPaddingRight,10)||0,S=parseInt(d.borderTopWidth,10)||0,C=parseInt(d.borderBottomWidth,10)||0,w=parseInt(d.borderLeftWidth,10)||0,T=parseInt(d.borderRightWidth,10)||0,E=c.top-g,D=c.bottom+_,O=c.left-v,k=c.right+y,A=e===f?0:w+T,j=e===f?0:S+C,M=e.offsetWidth-e.clientWidth-A,N=e.offsetHeight-e.clientHeight-j,P=p+S+te,F=m-C-b-N,I=ee+w+x,L=h-T-ne;d.direction===`rtl`&&!a()?I+=M:L-=M;let R=E<P||D>F,z=O<I||k>L;if(R&&r===`start`)o+=E-P;else if(R&&r===`center`)o+=(E+D)/2-(P+F)/2;else if(R&&r===`end`)o+=D-F;else if(R&&r===`nearest`){let e=E-P,t=D-F;o+=Math.abs(e)<=Math.abs(t)?e:t}if(z&&i===`start`)s+=O-I;else if(z&&i===`center`)s+=(O+k)/2-(I+L)/2;else if(z&&i===`end`)s+=k-L;else if(z&&i===`nearest`){let e=O-I,t=k-L;s+=Math.abs(e)<=Math.abs(t)?e:t}e.scrollTo({left:s,top:o})}function M(e,t={}){let{containingElement:n}=t;if(e&&e.isConnected){let t=document.scrollingElement||document.documentElement;if(window.getComputedStyle(t).overflow!==`hidden`&&!v()){var r;let{left:t,top:o}=e.getBoundingClientRect();e==null||(r=e.scrollIntoView)==null||r.call(e,{block:`nearest`});let{left:s,top:c}=e.getBoundingClientRect();if(Math.abs(t-s)>1||Math.abs(o-c)>1){var i,a;n==null||(i=n.scrollIntoView)==null||i.call(n,{block:`center`,inline:`center`}),(a=e.scrollIntoView)==null||a.call(e,{block:`nearest`})}}else{let{left:t,top:r}=e.getBoundingClientRect(),i=w(e,!0);for(let t of i)j(t,e);let{left:a,top:o}=e.getBoundingClientRect();if(Math.abs(t-a)>1||Math.abs(r-o)>1){i=n?w(n,!0):[];for(let e of i)j(e,n,{block:`center`,inline:`center`})}}}}var N=new Map;function P(e){let{locale:t}=y(),n=t+(e?Object.entries(e).sort((e,t)=>e[0]<t[0]?-1:1).join():``);if(N.has(n))return N.get(n);let r=new Intl.Collator(t,e);return N.set(n,r),r}var F=x.createContext(null),I=`react-aria-focus-scope-restore`,L=null;function R(e){let{children:t,contain:n,restoreFocus:r,autoFocus:i}=e,a=(0,x.useRef)(null),o=(0,x.useRef)(null),c=(0,x.useRef)([]),{parentNode:u}=(0,x.useContext)(F)||{},d=(0,x.useMemo)(()=>new Z({scopeRef:c}),[c]);f(()=>{let e=u||Q.root;if(Q.getTreeNode(e.scopeRef)&&L&&!G(L,e.scopeRef)){let t=Q.getTreeNode(L);t&&(e=t)}e.addChild(d),Q.addNode(d)},[d,u]),f(()=>{let e=Q.getTreeNode(c);e&&(e.contain=!!n)},[n]),f(()=>{let e=a.current?.nextSibling,t=[],n=e=>e.stopPropagation();for(;e&&e!==o.current;)t.push(e),e.addEventListener(I,n),e=e.nextSibling;return c.current=t,()=>{for(let e of t)e.removeEventListener(I,n)}},[t]),ce(c,r,n),ae(c,n),ue(c,r,n),se(c,i),(0,x.useEffect)(()=>{let e=l(s(c.current?c.current[0]:void 0)),t=null;if(U(e,c.current)){for(let n of Q.traverse())n.scopeRef&&U(e,n.scopeRef.current)&&(t=n);t===Q.getTreeNode(c)&&(L=t.scopeRef)}},[c]),f(()=>()=>{let e=Q.getTreeNode(c)?.parent?.scopeRef??null;(c===L||G(c,L))&&(!e||Q.getTreeNode(e))&&(L=e),Q.removeTreeNode(c)},[c]);let p=(0,x.useMemo)(()=>z(c),[]),m=(0,x.useMemo)(()=>({focusManager:p,parentNode:d}),[d,p]);return x.createElement(F.Provider,{value:m},x.createElement(`span`,{"data-focus-scope-start":!0,hidden:!0,ref:a}),t,x.createElement(`span`,{"data-focus-scope-end":!0,hidden:!0,ref:o}))}function z(e){return{focusNext(t={}){let n=e.current,{from:r,tabbable:i,wrap:a,accept:o}=t,c=r||l(s(n[0]??void 0)),u=n[0].previousElementSibling,d=Y(B(n),{tabbable:i,accept:o},n);d.currentNode=U(c,n)?c:u;let f=d.nextNode();return!f&&a&&(d.currentNode=u,f=d.nextNode()),f&&K(f,!0),f},focusPrevious(t={}){let n=e.current,{from:r,tabbable:i,wrap:a,accept:o}=t,c=r||l(s(n[0]??void 0)),u=n[n.length-1].nextElementSibling,d=Y(B(n),{tabbable:i,accept:o},n);d.currentNode=U(c,n)?c:u;let f=d.previousNode();return!f&&a&&(d.currentNode=u,f=d.previousNode()),f&&K(f,!0),f},focusFirst(t={}){let n=e.current,{tabbable:r,accept:i}=t,a=Y(B(n),{tabbable:r,accept:i},n);a.currentNode=n[0].previousElementSibling;let o=a.nextNode();return o&&K(o,!0),o},focusLast(t={}){let n=e.current,{tabbable:r,accept:i}=t,a=Y(B(n),{tabbable:r,accept:i},n);a.currentNode=n[n.length-1].nextElementSibling;let o=a.previousNode();return o&&K(o,!0),o}}}function B(e){return e[0].parentElement}function V(e){let t=Q.getTreeNode(L);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function re(e){if(!e.form)return Array.from(s(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)).filter(e=>!e.form);let t=e.form.elements.namedItem(e.name),n=c(e);return t instanceof n.RadioNodeList?Array.from(t).filter(e=>e instanceof n.HTMLInputElement):t instanceof n.HTMLInputElement?[t]:[]}function ie(e){if(e.checked)return!0;let t=re(e);return t.length>0&&!t.some(e=>e.checked)}function ae(e,t){let n=(0,x.useRef)(void 0),r=(0,x.useRef)(void 0);f(()=>{let a=e.current;if(!t){r.current&&=(cancelAnimationFrame(r.current),void 0);return}let o=s(a?a[0]:void 0),c=t=>{if(t.key!==`Tab`||t.altKey||t.ctrlKey||t.metaKey||!V(e)||t.isComposing)return;let n=l(o),r=e.current;if(!r||!U(n,r))return;let i=Y(B(r),{tabbable:!0},r);if(!n)return;i.currentNode=n;let a=t.shiftKey?i.previousNode():i.nextNode();a||=(i.currentNode=t.shiftKey?r[r.length-1].nextElementSibling:r[0].previousElementSibling,t.shiftKey?i.previousNode():i.nextNode()),t.preventDefault(),a&&K(a,!0)},f=t=>{(!L||G(L,e))&&U(u(t),e.current)?(L=e,n.current=u(t)):V(e)&&!W(u(t),e)?n.current?n.current.focus():L&&L.current&&J(L.current):V(e)&&(n.current=u(t))},p=t=>{r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{let r=i(),a=(r===`virtual`||r===null)&&d()&&v(),s=l(o);if(!a&&s&&V(e)&&!W(s,e)){L=e;let r=u(t);if(r&&r.isConnected){var c;n.current=r,(c=n.current)==null||c.focus()}else L.current&&J(L.current)}})};return o.addEventListener(`keydown`,c,!1),o.addEventListener(`focusin`,f,!1),a?.forEach(e=>e.addEventListener(`focusin`,f,!1)),a?.forEach(e=>e.addEventListener(`focusout`,p,!1)),()=>{o.removeEventListener(`keydown`,c,!1),o.removeEventListener(`focusin`,f,!1),a?.forEach(e=>e.removeEventListener(`focusin`,f,!1)),a?.forEach(e=>e.removeEventListener(`focusout`,p,!1))}},[e,t]),f(()=>()=>{r.current&&cancelAnimationFrame(r.current)},[r])}function H(e){return W(e)}function U(e,t){return!e||!t?!1:t.some(t=>m(t,e))}function W(e,t=null){if(e instanceof Element&&e.closest(`[data-react-aria-top-layer]`))return!0;for(let{scopeRef:n}of Q.traverse(Q.getTreeNode(t)))if(n&&U(e,n.current))return!0;return!1}function oe(e){return W(e,L)}function G(e,t){let n=Q.getTreeNode(t)?.parent;for(;n;){if(n.scopeRef===e)return!0;n=n.parent}return!1}function K(e,t=!1){if(e!=null&&!t)try{n(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function q(e,t=!0){let n=e[0].previousElementSibling,r=B(e),i=Y(r,{tabbable:t},e);i.currentNode=n;let a=i.nextNode();return t&&!a&&(r=B(e),i=Y(r,{tabbable:!1},e),i.currentNode=n,a=i.nextNode()),a}function J(e,t=!0){K(q(e,t))}function se(e,t){let n=x.useRef(t);(0,x.useEffect)(()=>{if(n.current){L=e;let t=s(e.current?e.current[0]:void 0);!U(l(t),L.current)&&e.current&&J(e.current)}n.current=!1},[e])}function ce(e,t,n){f(()=>{if(t||n)return;let r=e.current,i=s(r?r[0]:void 0),a=t=>{let n=u(t);U(n,e.current)?L=e:H(n)||(L=null)};return i.addEventListener(`focusin`,a,!1),r?.forEach(e=>e.addEventListener(`focusin`,a,!1)),()=>{i.removeEventListener(`focusin`,a,!1),r?.forEach(e=>e.removeEventListener(`focusin`,a,!1))}},[e,t,n])}function le(e){let t=Q.getTreeNode(L);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return t?.scopeRef===e}function ue(e,t,n){let r=(0,x.useRef)(typeof document<`u`?l(s(e.current?e.current[0]:void 0)):null);f(()=>{let r=e.current,i=s(r?r[0]:void 0);if(!t||n)return;let a=()=>{(!L||G(L,e))&&U(l(i),e.current)&&(L=e)};return i.addEventListener(`focusin`,a,!1),r?.forEach(e=>e.addEventListener(`focusin`,a,!1)),()=>{i.removeEventListener(`focusin`,a,!1),r?.forEach(e=>e.removeEventListener(`focusin`,a,!1))}},[e,n]),f(()=>{let r=s(e.current?e.current[0]:void 0);if(!t)return;let i=t=>{if(t.key!==`Tab`||t.altKey||t.ctrlKey||t.metaKey||!V(e)||t.isComposing)return;let n=r.activeElement;if(!W(n,e)||!le(e))return;let i=Q.getTreeNode(e);if(!i)return;let a=i.nodeToRestore,o=Y(r.body,{tabbable:!0});o.currentNode=n;let s=t.shiftKey?o.previousNode():o.nextNode();if((!a||!a.isConnected||a===r.body)&&(a=void 0,i.nodeToRestore=void 0),(!s||!W(s,e))&&a){o.currentNode=a;do s=t.shiftKey?o.previousNode():o.nextNode();while(W(s,e));t.preventDefault(),t.stopPropagation(),s?K(s,!0):H(a)?K(a,!0):n.blur()}};return n||r.addEventListener(`keydown`,i,!0),()=>{n||r.removeEventListener(`keydown`,i,!0)}},[e,t,n]),f(()=>{let n=s(e.current?e.current[0]:void 0);if(!t)return;let i=Q.getTreeNode(e);if(i)return i.nodeToRestore=r.current??void 0,()=>{let r=Q.getTreeNode(e);if(!r)return;let i=r.nodeToRestore,a=l(n);if(t&&i&&(a&&W(a,e)||a===n.body&&le(e))){let t=Q.clone();requestAnimationFrame(()=>{if(n.activeElement===n.body){let n=t.getTreeNode(e);for(;n;){if(n.nodeToRestore&&n.nodeToRestore.isConnected){de(n.nodeToRestore);return}n=n.parent}for(n=t.getTreeNode(e);n;){if(n.scopeRef&&n.scopeRef.current&&Q.getTreeNode(n.scopeRef)){de(q(n.scopeRef.current,!0));return}n=n.parent}}})}}},[e,t])}function de(e){e.dispatchEvent(new CustomEvent(I,{bubbles:!0,cancelable:!0}))&&K(e)}function Y(e,t,n){let r=t?.tabbable?h:p,i=e?.nodeType===Node.ELEMENT_NODE?e:null,a=s(i),o=b(a,e||a,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return m(t?.from,e)||t?.tabbable&&e.tagName===`INPUT`&&e.getAttribute(`type`)===`radio`&&(!ie(e)||o.currentNode.tagName===`INPUT`&&o.currentNode.type===`radio`&&o.currentNode.name===e.name)?NodeFilter.FILTER_REJECT:r(e)&&(!n||U(e,n))&&(!t?.accept||t.accept(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t?.from&&(o.currentNode=t.from),o}function fe(e,t={}){return{focusNext(n={}){let r=e.current;if(!r)return null;let{from:i,tabbable:a=t.tabbable,wrap:o=t.wrap,accept:c=t.accept}=n,u=i||l(s(r)),d=Y(r,{tabbable:a,accept:c});m(r,u)&&(d.currentNode=u);let f=d.nextNode();return!f&&o&&(d.currentNode=r,f=d.nextNode()),f&&K(f,!0),f},focusPrevious(n=t){let r=e.current;if(!r)return null;let{from:i,tabbable:a=t.tabbable,wrap:o=t.wrap,accept:c=t.accept}=n,u=i||l(s(r)),d=Y(r,{tabbable:a,accept:c});if(m(r,u))d.currentNode=u;else{let e=X(d);return e&&K(e,!0),e??null}let f=d.previousNode();if(!f&&o){d.currentNode=r;let e=X(d);if(!e)return null;f=e}return f&&K(f,!0),f??null},focusFirst(n=t){let r=e.current;if(!r)return null;let{tabbable:i=t.tabbable,accept:a=t.accept}=n,o=Y(r,{tabbable:i,accept:a}).nextNode();return o&&K(o,!0),o},focusLast(n=t){let r=e.current;if(!r)return null;let{tabbable:i=t.tabbable,accept:a=t.accept}=n,o=X(Y(r,{tabbable:i,accept:a}));return o&&K(o,!0),o??null}}}function X(e){let t,n;do n=e.lastChild(),n&&(t=n);while(n);return t}var pe=class e{get size(){return this.fastMap.size}getTreeNode(e){return this.fastMap.get(e)}addTreeNode(e,t,n){let r=this.fastMap.get(t??null);if(!r)return;let i=new Z({scopeRef:e});r.addChild(i),i.parent=r,this.fastMap.set(e,i),n&&(i.nodeToRestore=n)}addNode(e){this.fastMap.set(e.scopeRef,e)}removeTreeNode(e){if(e===null)return;let t=this.fastMap.get(e);if(!t)return;let n=t.parent;for(let e of this.traverse())e!==t&&t.nodeToRestore&&e.nodeToRestore&&t.scopeRef&&t.scopeRef.current&&U(e.nodeToRestore,t.scopeRef.current)&&(e.nodeToRestore=t.nodeToRestore);let r=t.children;n&&(n.removeChild(t),r.size>0&&r.forEach(e=>n&&n.addChild(e))),this.fastMap.delete(t.scopeRef)}*traverse(e=this.root){if(e.scopeRef!=null&&(yield e),e.children.size>0)for(let t of e.children)yield*this.traverse(t)}clone(){let t=new e;for(let e of this.traverse())t.addTreeNode(e.scopeRef,e.parent?.scopeRef??null,e.nodeToRestore);return t}constructor(){this.fastMap=new Map,this.root=new Z({scopeRef:null}),this.fastMap.set(null,this.root)}},Z=class{addChild(e){this.children.add(e),e.parent=this}removeChild(e){this.children.delete(e),e.parent=void 0}constructor(e){this.children=new Set,this.contain=!1,this.scopeRef=e.scopeRef}},Q=new pe,$={border:0,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`};function me(e={}){let{style:t,isFocusable:n}=e,[i,a]=(0,x.useState)(!1),{focusWithinProps:o}=r({isDisabled:!n,onFocusWithinChange:e=>a(e)}),s=(0,x.useMemo)(()=>i?t:t?{...$,...t}:$,[i]);return{visuallyHiddenProps:{...o,style:s}}}function he(e){let{children:t,elementType:n=`div`,isFocusable:r,style:i,...a}=e,{visuallyHiddenProps:o}=me(e);return x.createElement(n,ee(a,o),t)}var ge=(0,x.createContext)(null);(0,x.createContext)(null),(0,x.createContext)(null),(0,x.createContext)(null),(0,x.createContext)(null);var _e=(0,x.createContext)({}),ve=(0,x.createContext)(null);(0,x.createContext)(null);export{S as _,me as a,Y as c,j as d,M as f,C as g,D as h,he as i,fe as l,T as m,ve as n,oe as o,A as p,_e as r,R as s,ge as t,P as u,ne as v,b as y};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{f as t,l as n,r}from"./useEvent-xfs0Sn4r.js";import{t as i}from"./react-CBDbhulC.js";import{Nn as a,Ui as o,Wi as s,mt as c,p as l,wn as u}from"./cells-BdoPd1mK.js";import{t as d}from"./compiler-runtime-CYIjoINj.js";import{g as f}from"./useEventListener-D27Dii_l.js";import{c as p}from"./utils-R_pHe-RB.js";import{E as m}from"./config-CUBl5qBg.js";import{t as h}from"./jsx-runtime-B74pBk57.js";import{t as g}from"./tooltip-D7dq6bnc.js";import{t as _}from"./copy-icon-LPQzn7_f.js";import{t as v}from"./usePress-CwOqeEX3.js";import{n as y}from"./useDebounce-Dulm61-t.js";import{t as b}from"./useRunCells-DP6cAHq0.js";var x=d(),S=e(i(),1),C=h(),w=e=>{let t=(0,x.c)(16),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({href:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(0,S.useRef)(null),o;t[4]===r?o=t[5]:(o=()=>{let e=new URL(globalThis.location.href);e.hash=r,globalThis.history.pushState({},``,e.toString()),globalThis.dispatchEvent(new HashChangeEvent(`hashchange`));let t=r.slice(1),n=document.getElementById(t);n&&n.scrollIntoView({behavior:`smooth`,block:`start`})},t[4]=r,t[5]=o);let s=o,c;t[6]===s?c=t[7]:(c={onPress:()=>{s()}},t[6]=s,t[7]=c);let{pressProps:l}=v(c),u;t[8]===s?u=t[9]:(u=e=>{e.preventDefault(),s()},t[8]=s,t[9]=u);let d=u,f;return t[10]!==n||t[11]!==d||t[12]!==r||t[13]!==l||t[14]!==i?(f=(0,C.jsx)(`a`,{ref:a,href:r,...l,onClick:d,...i,children:n}),t[10]=n,t[11]=d,t[12]=r,t[13]=l,t[14]=i,t[15]=f):f=t[15],f};async function T(e){let t=l().inOrderIds.at(0);if(t)try{let n=await u.request({document:e,cellId:t});if(!n||n.options.length===0)return;let i=e.split(`.`).pop()??e,o=n.options[0],s=n.options.find(e=>e.name===i)??o;s?.completion_info&&r.set(a,{documentation:s.completion_info})}catch(t){f.debug(`Doc lookup failed for "${e}"`,t)}}var E=e=>{let t=(0,x.c)(8),{qualifiedName:n,children:r}=e,i;t[0]===n?i=t[1]:(i=()=>{T(n)},t[0]=n,t[1]=i);let a=y(i,100),o;t[2]===a?o=t[3]:(o=()=>a.cancel(),t[2]=a,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,C.jsx)(`span`,{onMouseEnter:a,onMouseLeave:o,children:r}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s};function D(e){if(typeof e!=`object`||!e)return!1;let t=e;return!(t.trusted!==!0||t.notebookCode!==void 0&&typeof t.notebookCode!=`string`)}function O(){let e=window?.__MARIMO_EXPORT_CONTEXT__;return D(e)?e:void 0}function k(){return O()?.trusted===!0}function A(){if(r.get(b)||k()||r.get(p))return!0;try{if(m()===`read`)return!0}catch{}return!1}var j=t(e=>{let t=e(b),n=e(p);if(t||n||k())return!1;let r=!0;try{r=m()===`read`}catch{return!0}return!r});function M(){return n(j)}var N=e=>{if(e instanceof s.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return S.createElement(S.Fragment)},P=(e,t)=>{if(t instanceof s.Element&&t.name===`body`){if((0,S.isValidElement)(e)&&`props`in e){let t=e.props.children;return(0,C.jsx)(C.Fragment,{children:t})}return}},F=(e,t)=>{if(t instanceof s.Element&&t.name===`html`){if((0,S.isValidElement)(e)&&`props`in e){let t=e.props.children;return(0,C.jsx)(C.Fragment,{children:t})}return}},I=e=>{if(e instanceof s.Element&&e.attribs&&e.name===`iframe`){let t=document.createElement(`iframe`);return Object.entries(e.attribs).forEach(([e,n])=>{e.startsWith(`"`)&&e.endsWith(`"`)&&(e=e.slice(1,-1)),t.setAttribute(e,n)}),(0,C.jsx)(`div`,{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},L=e=>{if(e instanceof s.Element&&e.name===`script`){let t=e.attribs.src;if(!t)return;if(!A())return f.warn(`[RenderHTML] refusing <script src> in untrusted context: ${t}`),(0,C.jsx)(C.Fragment,{});if(![...document.querySelectorAll(`script[src]`)].some(e=>e.getAttribute(`src`)===t)){let e=document.createElement(`script`);e.src=t,document.head.append(e)}return(0,C.jsx)(C.Fragment,{})}},R=(e,t)=>{if(t instanceof s.Element&&t.name===`a`){let n=t.attribs.href;if(n?.startsWith(`#`)&&!n.startsWith(`#code/`)){let r=null;return(0,S.isValidElement)(e)&&`props`in e&&(r=e.props.children),(0,C.jsx)(w,{href:n,...t.attribs,children:r})}}},z=(e,t,n)=>{if(t instanceof s.Element&&t.name===`div`&&t.attribs?.class?.includes(`codehilite`))return(0,C.jsx)(W,{children:e},n)},B=(e,t,n)=>{if(!(t instanceof s.Element)||t.name!==`img`)return;let r=t.attribs?.src;if(!(!r||!(0,S.isValidElement)(e))&&!/^data:/i.test(r))return(0,S.cloneElement)(e,{key:`${r}-${n}`})},V=(e,t,n)=>{if(!(t instanceof s.Element)||t.name!==`input`||t.attribs?.type!==`checkbox`||!(0,S.isValidElement)(e))return;let r=`checked`in t.attribs;return(0,S.cloneElement)(e,{key:`checkbox-${n}-${r}`})},H=(e,t)=>{if(t instanceof s.Element&&t.attribs?.[`data-marimo-doc`]){let n=t.attribs[`data-marimo-doc`];return(0,C.jsx)(E,{qualifiedName:n,children:e})}},U=(e,t)=>{if(t instanceof s.Element&&t.attribs?.[`data-tooltip`]){if((t.name?.toLowerCase()??``).startsWith(`marimo-`))return;let n=t.attribs[`data-tooltip`];return(0,C.jsx)(g,{content:n,children:e})}},W=e=>{let t=(0,x.c)(3),{children:n}=e,r=(0,S.useRef)(null),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,C.jsx)(`div`,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,C.jsx)(_,{tooltip:!1,className:`p-1`,value:()=>{let e=r.current?.firstChild;return e&&e.textContent||``}})}),t[0]=i):i=t[0];let a;return t[1]===n?a=t[2]:(a=(0,C.jsxs)(`div`,{className:`relative group codehilite-wrapper`,ref:r,children:[n,i]}),t[1]=n,t[2]=a),a},G=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:n=!0})=>(0,C.jsx)(K,{html:e,alwaysSanitizeHtml:n,additionalReplacements:t}),K=e=>{let t=(0,x.c)(7),{html:n,additionalReplacements:r,alwaysSanitizeHtml:i}=e,a;t[0]===r?a=t[1]:(a=r===void 0?[]:r,t[0]=r,t[1]=a);let o=a,s=M(),l;bb0:{if(i||s){let e;t[2]===n?e=t[3]:(e=c(n),t[2]=n,t[3]=e),l=e;break bb0}l=n}let u=l,d;return t[4]!==o||t[5]!==u?(d=q({html:u,additionalReplacements:o}),t[4]=o,t[5]=u,t[6]=d):d=t[6],d};function q({html:e,additionalReplacements:t=[]}){let n=[N,I,L,...t],r=[z,R,H,U,P,F],i=[B,V];return o(e,{replace:(e,t)=>{for(let r of n){let n=r(e,t);if(n)return n}return e},transform:(e,t,n)=>{let a=e;for(let e of r){let r=e(a,t,n);if(r){a=r;break}}for(let e of i){let r=e(a,t,n);r&&(a=r)}return a}})}export{k as n,G as t};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./react-CBDbhulC.js";import{t as n}from"./compiler-runtime-CYIjoINj.js";import{_ as r}from"./useEventListener-D27Dii_l.js";import{h as i,u as a}from"./config-CUBl5qBg.js";import{n as o,t as s}from"./cn-ldLVeaqm.js";import{t as c}from"./jsx-runtime-B74pBk57.js";import{t as l}from"./tooltip-D7dq6bnc.js";import{r as u}from"./button-BMBznEru.js";import{r as d}from"./requests-C6_IaFh7.js";import{t as f}from"./createLucideIcon-B7HeEoG2.js";import{i as p}from"./useDeleteCell-6wcjnAMK.js";import{C as m,O as h,ut as g,w as _}from"./input-BuOxQ3Wy.js";import{t as v}from"./square-B58Ib8Ir.js";import{N as y,P as b,V as x,j as S,k as C}from"./usePress-CwOqeEX3.js";import{l as w}from"./RSPContexts-D2JcYZo2.js";import{t as T}from"./context-Bf2wPdef.js";import{a as E}from"./renderShortcut-Dj3NbkoC.js";var D=f(`hard-drive-download`,[[`path`,{d:`M12 2v8`,key:`1q4o3n`}],[`path`,{d:`m16 6-4 4-4-4`,key:`6wukr`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M10 18h.01`,key:`h775k`}]]),O=e(t(),1);function k(e,t){let{"aria-label":n,"aria-labelledby":r,orientation:i=`horizontal`}=e,[a,o]=(0,O.useState)(!1);x(()=>{o(!!(t.current&&t.current.parentElement?.closest(`[role="toolbar"]`)))});let{direction:s}=T(),c=s===`rtl`&&i===`horizontal`,l=w(t),u=e=>{if(S(e.currentTarget,b(e))){if(i===`horizontal`&&e.key===`ArrowRight`||i===`vertical`&&e.key===`ArrowDown`)c?l.focusPrevious():l.focusNext();else if(i===`horizontal`&&e.key===`ArrowLeft`||i===`vertical`&&e.key===`ArrowUp`)c?l.focusNext():l.focusPrevious();else if(e.key===`Tab`){e.stopPropagation(),d.current=y(),e.shiftKey?l.focusFirst():l.focusLast();return}else return;e.stopPropagation(),e.preventDefault()}},d=(0,O.useRef)(null),f=e=>{!S(e.currentTarget,e.relatedTarget)&&!d.current&&(d.current=b(e))},p=e=>{if(d.current&&!S(e.currentTarget,e.relatedTarget)&&S(t.current,b(e))){var n;(n=d.current)==null||n.focus(),d.current=null}};return{toolbarProps:{...g(e,{labelable:!0}),role:a?`group`:`toolbar`,"aria-orientation":i,"aria-label":n,"aria-labelledby":n==null?r:void 0,onKeyDownCapture:a?void 0:u,onFocusCapture:a?void 0:p,onBlurCapture:a?void 0:f}}}var A=(0,O.createContext)({}),j=(0,O.forwardRef)(function(e,t){[e,t]=m(e,t,A);let{toolbarProps:n}=k(e,t),r=_({...e,values:{orientation:e.orientation||`horizontal`},defaultClassName:`react-aria-Toolbar`}),i=g(e,{global:!0});return delete i.id,O.createElement(h.div,{...C(i,r,n),ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||`horizontal`},r.children)}),M=c(),N=n(),P=200;function F(e){let t=(0,N.c)(3),[n,r]=(0,O.useState)(!1),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e)return;r(!1);let t=setTimeout(()=>{r(!0)},P);return()=>clearTimeout(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,O.useEffect)(i,a),e&&n}var I=o(`rounded-full shadow-xs-solid border p-[5px] transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background`,{variants:{variant:{default:`hover:bg-accent hover:text-accent-foreground`,stale:`bg-(--yellow-3) hover:bg-(--yellow-4) text-(--yellow-11)`,green:`hover:bg-(--grass-2) hover:text-(--grass-11) hover:border-[var(--grass-7)],`,disabled:`opacity-50 cursor-not-allowed`,danger:`hover:bg-(--red-3) hover:text-(--red-11)`}},defaultVariants:{variant:`default`}}),L=e=>{let t=(0,N.c)(18),n,r,i,a,o,c,d;if(t[0]!==e){let{children:l,tooltip:f,disabled:p,variant:m,...h}=e;n=l,d=f;let g=p!==void 0&&p;r=g,i=h,a=e=>{g||h.onClick?.(e)},o=u.preventFocus,c=s(I({variant:m}),h.className),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=d}else n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],d=t[7];let f;t[8]!==n||t[9]!==r||t[10]!==i||t[11]!==a||t[12]!==o||t[13]!==c?(f=(0,M.jsx)(`button`,{disabled:r,...i,onClick:a,onMouseDown:o,className:c,children:n}),t[8]=n,t[9]=r,t[10]=i,t[11]=a,t[12]=o,t[13]=c,t[14]=f):f=t[14];let p=f;if(d){let e;return t[15]!==p||t[16]!==d?(e=(0,M.jsx)(l,{content:d,side:`top`,delayDuration:200,usePortal:!1,children:p}),t[15]=p,t[16]=d,t[17]=e):e=t[17],e}return p},R=e=>{let t=(0,N.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=s(`flex items-center gap-1 bg-background m-[2px] rounded-full`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,M.jsx)(j,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},z=e=>{let t=(0,N.c)(9),{connectionState:n,status:a}=e,{sendInterrupt:o}=d(),s=F(a===`running`),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=E(`global.interrupt`),t[0]=c):c=t[0];let l;t[1]!==n||t[2]!==s?(l=i(n)||!s,t[1]=n,t[2]=s,t[3]=l):l=t[3];let u=s?o:r.NOOP,f=s?`stale`:`disabled`,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,M.jsx)(v,{strokeWidth:1.5}),t[4]=p):p=t[4];let m;return t[5]!==l||t[6]!==u||t[7]!==f?(m=(0,M.jsx)(L,{tooltip:c,disabled:l,onClick:u,variant:f,"data-testid":`run-button`,children:p}),t[5]=l,t[6]=u,t[7]=f,t[8]=m):m=t[8],m};function B({connectionState:e,needsRun:t,loading:n,inactive:r}){return i(e)?`disabled`:t&&!n?`stale`:n||r?`disabled`:`green`}var V=e=>{let t=(0,N.c)(27),{onClick:n,connectionState:r,needsRun:o,status:s,config:c,edited:l}=e,u=s===`disabled-transitively`,d=s===`running`||s===`queued`,f,m;t[0]!==u||t[1]!==c.disabled||t[2]!==r||t[3]!==l||t[4]!==d||t[5]!==o?(f=i(r)||d||!c.disabled&&u&&!l,m=B({connectionState:r,needsRun:o,loading:d,inactive:f}),t[0]=u,t[1]=c.disabled,t[2]=r,t[3]=l,t[4]=d,t[5]=o,t[6]=f,t[7]=m):(f=t[6],m=t[7]);let h=m;if(c.disabled){let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsx)(D,{}),t[8]=e):e=t[8];let r;return t[9]!==f||t[10]!==n||t[11]!==h?(r=(0,M.jsx)(L,{tooltip:`Add code to notebook`,disabled:f,onClick:n,variant:h,"data-testid":`run-button`,children:e}),t[9]=f,t[10]=n,t[11]=h,t[12]=r):r=t[12],r}if(!c.disabled&&u&&!l){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsx)(p,{strokeWidth:1.2}),t[13]=e):e=t[13];let r;return t[14]!==f||t[15]!==n||t[16]!==h?(r=(0,M.jsx)(L,{disabled:f,tooltip:`This cell can't be run because it has a disabled ancestor`,onClick:n,variant:h,"data-testid":`run-button`,children:e}),t[14]=f,t[15]=n,t[16]=h,t[17]=r):r=t[17],r}let g;if(i(r)){let e;t[18]===r?e=t[19]:(e=a(r),t[18]=r,t[19]=e),g=e}else if(s===`queued`)g=`This cell is already queued to run`;else if(s===`running`)g=`This cell is already running.`;else{let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=E(`cell.run`),t[20]=e):e=t[20],g=e}let _;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,M.jsx)(p,{strokeWidth:1.2}),t[21]=_):_=t[21];let v;return t[22]!==f||t[23]!==n||t[24]!==g||t[25]!==h?(v=(0,M.jsx)(L,{tooltip:g,disabled:f,onClick:n,variant:h,"data-testid":`run-button`,children:_}),t[22]=f,t[23]=n,t[24]=g,t[25]=h,t[26]=v):v=t[26],v};export{F as a,L as i,z as n,R as r,V as t};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./react-CBDbhulC.js";var n=e(t(),1),r={prefix:String(Math.round(Math.random()*1e10)),current:0},i=n.createContext(r),a=n.createContext(!1);typeof window<`u`&&window.document&&window.document.createElement;var o=new WeakMap;function s(e=!1){let t=(0,n.useContext)(i),r=(0,n.useRef)(null);if(r.current===null&&!e){let e=n.default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentOwner?.current;if(e){let n=o.get(e);n==null?o.set(e,{id:t.current,state:e.memoizedState}):e.memoizedState!==n.state&&(t.current=n.id,o.delete(e))}r.current=++t.current}return r.current}function c(e){let t=(0,n.useContext)(i),r=s(!!e),a=`react-aria${t.prefix}`;return e||`${a}-${r}`}function l(e){let t=n.useId(),[i]=(0,n.useState)(m()),a=i?`react-aria`:`react-aria${r.prefix}`;return e||`${a}-${t}`}var u=typeof n.useId==`function`?l:c;function d(){return!1}function f(){return!0}function p(e){return()=>{}}function m(){return typeof n.useSyncExternalStore==`function`?n.useSyncExternalStore(p,d,f):(0,n.useContext)(a)}export{u as n,m as t};
@@ -1,166 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t}from"./useEvent-xfs0Sn4r.js";import{t as n}from"./react-CBDbhulC.js";import{Ct as r,E as i,Pr as a,Yr as o,cr as s}from"./cells-BdoPd1mK.js";import{Cn as c,In as l,Q as u,kt as d,ln as f,zt as p}from"./schemas-aTUejmFi.js";import{c as m,o as h,p as g,t as _}from"./form-CD2uATFu.js";import{t as v}from"./compiler-runtime-CYIjoINj.js";import{_ as y}from"./useEventListener-D27Dii_l.js";import{c as b}from"./utils-R_pHe-RB.js";import{t as x}from"./cn-ldLVeaqm.js";import{t as S}from"./jsx-runtime-B74pBk57.js";import{a as C,c as w,i as T,o as E,r as ee,s as te,t as ne}from"./popover-CgOo22ko.js";import{c as re,i as ie,n as ae,r as oe,s as se,t as ce}from"./select-DwqnFsyg.js";import{i as le,t as ue}from"./tooltip-D7dq6bnc.js";import{t as de}from"./button-BMBznEru.js";import{r as D}from"./strings-CpYReX2Q.js";import{r as fe,t as pe}from"./x-BgkoSHM-.js";import{t as me}from"./circle-plus-cm-FRu9O.js";import{t as he}from"./components-DwH_Yb1N.js";import{n as O}from"./DeferredRequestRegistry-C-SpvRCH.js";import{t as ge}from"./plus-C4J9gIE1.js";import{t as _e}from"./sparkles-30wHhAF5.js";import{a as ve,c as ye,i as be,n as xe,o as Se,p as Ce,r as we,s as k,u as Te}from"./form-GIq5QCAI.js";import{a as Ee,c as De,l as Oe,n as ke,r as Ae,t as je}from"./dialog-EjSc4yoH.js";import{n as Me}from"./ImperativeModal-68zj0lxy.js";import{t as A}from"./links-C7oaxPJK.js";import{t as Ne}from"./useIframeCapabilities-DEpTCh1Q.js";import{r as Pe}from"./html-to-image-Bt7Ld74W.js";import{o as Fe}from"./focus-DgNLvj0o.js";import{n as Ie}from"./useAsyncData-Buhk-UgR.js";import{a as Le,c as Re,i as j,o as M,s as ze,t as Be}from"./command-Cvmdzx0n.js";import{t as Ve}from"./request-registry-mNu7sXOU.js";import{a as N,c as P,d as He,f as Ue,i as We,l as Ge,n as Ke,o as qe,r as F,s as I,t as Je,u as Ye}from"./write-secret-modal-dplU5PG8.js";import{a as Xe,i as Ze,n as Qe,t as $e}from"./data-source-discovery-BsrDlL04.js";import{t as et}from"./state-B-K0k6lb.js";var L=v(),R=e(n(),1),z=S();function tt(e,t){if(!t)return{recommended:[],other:[...e]};let n;try{n=new RegExp(t,`i`)}catch{return{recommended:[],other:[...e]}}let r=[],i=[];for(let t of e)n.test(t)?r.push(t):i.push(t);return{recommended:r,other:i}}var nt=({value:e,onChange:t,placeholder:n,secretsOnly:r=!1,recommendedKeys:i,otherKeys:a,onCreateSecret:o,className:s,searchPlaceholder:c,formatCustomValueLabel:l=e=>`Use "${e}"`,createSecretLabel:u=`Create a new secret`,allowCustomValue:d,allowCreateSecret:f})=>{let[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(``),_=h.trim(),v=!r&&_.length>0&&_!==e&&(d?.(_)??!0),y=f?.(_)??!0,b=e?I(e)?qe(e):e:null,S=e=>{t(P(e)),m(!1),g(``)},C=e=>{t(e),m(!1),g(``)};return(0,z.jsxs)(`div`,{className:x(`flex w-full min-w-48 mb-1 items-center gap-1`,s),children:[(0,z.jsxs)(ne,{modal:!0,open:p,onOpenChange:e=>{m(e),e||g(``)},children:[(0,z.jsx)(T,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,className:x(`flex h-6 min-w-0 flex-1 shadow-xs-solid items-center justify-between`,`rounded-sm border border-input bg-background px-1.5 text-sm font-code ring-offset-background placeholder:text-muted-foreground`,`hover:shadow-sm-solid focus:outline-hidden focus:ring-1 focus:ring-ring focus:border-primary focus:shadow-md-solid`,I(e)&&`bg-accent`),"aria-expanded":p,children:[(0,z.jsx)(`span`,{className:`truncate flex-1 min-w-0 text-left flex items-center gap-1.5`,children:b?(0,z.jsxs)(z.Fragment,{children:[I(e)&&(0,z.jsx)(O,{className:`h-3 w-3 shrink-0 opacity-70`}),(0,z.jsx)(`span`,{className:`truncate`,children:b})]}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:n})}),(0,z.jsx)(fe,{className:`ml-1 h-4 w-4 opacity-50 shrink-0`})]})}),(0,z.jsx)(ee,{className:`w-(--radix-popover-trigger-width) p-0`,align:`start`,children:(0,z.jsxs)(Be,{children:[(0,z.jsx)(Le,{placeholder:c??(r?`Search secrets...`:`Type a value or search secrets...`),rootClassName:`px-1 h-8`,autoFocus:!0,value:h,onValueChange:g}),(0,z.jsxs)(ze,{className:`max-h-60 overscroll-contain`,children:[v&&(0,z.jsx)(j,{children:(0,z.jsx)(M,{value:`use custom value ${_}`,onSelect:()=>C(_),children:l(_)})}),y&&(0,z.jsx)(j,{className:`mt-0`,children:(0,z.jsxs)(M,{value:`create new secret ${_}`,onSelect:()=>{let e=_||void 0;m(!1),g(``),o(e)},children:[(0,z.jsx)(me,{className:`mr-2 h-3.5 w-3.5`}),u]})}),i.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Re,{className:`mt-0`}),(0,z.jsx)(j,{heading:`Recommended`,children:i.map(e=>(0,z.jsxs)(M,{value:e,onSelect:()=>S(e),children:[(0,z.jsx)(O,{className:`mr-2 h-3 w-3 opacity-70`}),e]},e))})]}),a.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Re,{className:`mt-0`}),(0,z.jsx)(j,{heading:i.length>0?`Other`:void 0,children:a.map(e=>(0,z.jsxs)(M,{value:e,onSelect:()=>S(e),children:[(0,z.jsx)(O,{className:`mr-2 h-3 w-3 opacity-70`}),e]},e))})]})]})]})})]}),e&&(0,z.jsx)(`button`,{type:`button`,"aria-label":`Clear`,className:x(`flex h-6 w-6 shrink-0 items-center justify-center rounded-sm`,`text-muted-foreground hover:bg-muted hover:text-foreground`,`focus:outline-hidden focus:ring-1 focus:ring-ring`),onClick:()=>{t(``),g(``),m(!1)},children:(0,z.jsx)(pe,{className:`h-3.5 w-3.5`})})]})},rt=(0,R.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:y.NOOP}),it=()=>(0,R.use)(rt),at=e=>{let t=(0,L.c)(14),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let{data:i,isPending:a,error:o,refetch:s}=Ie(dt,r);i?.secretKeys,i?.providerNames;let c;t[1]===i?.secretKeys?c=t[2]:(c=i?.secretKeys||[],t[1]=i?.secretKeys,t[2]=c);let l;t[3]===i?.providerNames?l=t[4]:(l=i?.providerNames||[],t[3]=i?.providerNames,t[4]=l);let u;t[5]!==o||t[6]!==a||t[7]!==s||t[8]!==c||t[9]!==l?(u={secretKeys:c,providerNames:l,loading:a,error:o,refreshSecrets:s},t[5]=o,t[6]=a,t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10];let d=u,f;return t[11]!==n||t[12]!==d?(f=(0,z.jsx)(rt,{value:d,children:n}),t[11]=n,t[12]=d,t[13]=f):f=t[13],f},ot={isMatch:e=>{if(e instanceof u){let{optionRegex:t}=m.parse(e.description||``);return!!t}return!1},Component:({schema:e,form:t,path:n})=>{let{secretKeys:r,providerNames:i,refreshSecrets:a}=it(),{openModal:o,closeModal:s}=Me(),{label:c,description:l,placeholder:u,optionRegex:d=``,inputType:f}=m.parse(e.description||``),p=f===`password`,{recommended:h,other:g}=tt(r,d);return(0,z.jsx)(ve,{control:t.control,name:n,render:({field:e})=>(0,z.jsxs)(Se,{children:[(0,z.jsx)(k,{children:c}),(0,z.jsx)(we,{children:l}),(0,z.jsx)(xe,{children:(0,z.jsx)(nt,{value:e.value?String(e.value):``,onChange:e.onChange,placeholder:u,secretsOnly:p,recommendedKeys:h,otherKeys:g,onCreateSecret:t=>{o((0,z.jsx)(Je,{providerNames:i,initialValue:t,onSuccess:t=>{a(),e.onChange(P(t)),s()},onClose:s}))}})}),(0,z.jsx)(ye,{})]})})}},st={isMatch:e=>{if(e instanceof u){let{special:t}=m.parse(e.description||``);return t===`secret_textarea`}return!1},Component:({schema:e,form:t,path:n})=>{let{secretKeys:r,providerNames:i,refreshSecrets:o}=it(),{openModal:s,closeModal:c}=Me(),{label:l,description:u,placeholder:d}=m.parse(e.description||``);return(0,z.jsx)(ve,{control:t.control,name:n,render:({field:e})=>{let t=e.value?String(e.value):``,n=Ye(t)?Ue(t):t;return(0,z.jsxs)(Se,{children:[(0,z.jsxs)(k,{className:`flex items-center gap-1`,children:[l,(0,z.jsx)(ue,{content:`Enter a path to a file on disk, or create a secret to paste JSON directly.`,delayDuration:300,children:(0,z.jsx)(`button`,{type:`button`,className:`inline-flex`,"aria-label":`Credential input help`,children:(0,z.jsx)(a,{className:`h-3.5 w-3.5`})})})]}),(0,z.jsx)(we,{children:u}),(0,z.jsx)(xe,{children:(0,z.jsx)(nt,{value:n,onChange:t=>{e.onChange(!t||I(t)||Ye(t)?t:He(t))},placeholder:d,searchPlaceholder:`Type a file path or paste JSON`,formatCustomValueLabel:e=>`Use "${e}" as a file path`,createSecretLabel:`Paste JSON credentials`,allowCustomValue:e=>!We(e),allowCreateSecret:e=>!e||We(e),recommendedKeys:[],otherKeys:r,onCreateSecret:t=>{s((0,z.jsx)(Je,{providerNames:i,initialValue:t,multiline:!0,onSuccess:t=>{o(),e.onChange(P(t)),c()},onClose:c}))}})}),(0,z.jsx)(ye,{})]})}})}};function ct(e){return e.provider!==`env`}function lt(e){return e.name}function ut(e){return e.keys}async function dt(){let e=await Ve.request({}),t=Ke(e.secrets).filter(ct).map(lt);return{secretKeys:e.secrets.flatMap(ut).toSorted(),providerNames:t}}var ft=[ot,st],B=e=>{let t=(0,L.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,z.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-4`,children:n}),t[0]=n,t[1]=r),r},V=e=>{let t=(0,L.c)(9),{name:n,color:r,icon:i,onSelect:a}=e,o;t[0]===r?o=t[1]:(o={backgroundColor:r},t[0]=r,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,z.jsx)(`span`,{className:`text-white font-medium text-lg`,children:n}),t[2]=n,t[3]=s);let c;return t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==s?(c=(0,z.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:o,onClick:a,children:[i,s]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8],c},pt=e=>{let t=(0,L.c)(25),{onBack:n,isValid:r,libraries:i,preferredLibrary:a,onLibraryChange:o,displayNames:s,libraryLabel:c}=e,l=c===void 0?`Preferred library`:c,u;t[0]===n?u=t[1]:(u=(0,z.jsx)(de,{type:`button`,variant:`outline`,onClick:n,children:`Back`}),t[0]=n,t[1]=u);let d=!r,f;t[2]===d?f=t[3]:(f=(0,z.jsx)(de,{type:`submit`,disabled:d,children:`Add`}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,z.jsx)(se,{children:(0,z.jsx)(re,{placeholder:`Select a library`})}),t[7]=m):m=t[7];let h;t[8]===l?h=t[9]:(h=(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 items-end`,children:[m,(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l})]}),t[8]=l,t[9]=h);let g;if(t[10]!==s||t[11]!==i){let e;t[13]===s?e=t[14]:(e=e=>(0,z.jsx)(ie,{value:e,children:s[e]??e},e),t[13]=s,t[14]=e),g=i.map(e),t[10]=s,t[11]=i,t[12]=g}else g=t[12];let _;t[15]===g?_=t[16]:(_=(0,z.jsx)(ae,{children:(0,z.jsx)(oe,{children:g})}),t[15]=g,t[16]=_);let v;t[17]!==o||t[18]!==a||t[19]!==h||t[20]!==_?(v=(0,z.jsx)(`div`,{children:(0,z.jsxs)(ce,{value:a,onValueChange:o,children:[h,_]})}),t[17]=o,t[18]=a,t[19]=h,t[20]=_,t[21]=v):v=t[21];let y;return t[22]!==v||t[23]!==p?(y=(0,z.jsxs)(`div`,{className:`flex gap-2 justify-between`,children:[p,v]}),t[22]=v,t[23]=p,t[24]=y):y=t[24],y};function mt(){let e=(0,L.c)(4),{createNewCell:n}=i(),r=Fe(),a=t(b),o;return e[0]!==a||e[1]!==n||e[2]!==r?(o=e=>{/\bmo\./.test(e)&&Pe({autoInstantiate:a,createNewCell:n,fromCellId:r}),n({code:e,before:!1,cellId:r??`__end__`,skipIfCodeExists:!0})},e[0]=a,e[1]=n,e[2]=r,e[3]=o):o=e[3],o}var ht=e=>{let t=(0,L.c)(30),{schema:n,libraries:r,preferredLibrary:i,displayNames:a,libraryLabel:o,generateCode:s,onSubmit:c,onBack:l}=e,u;t[0]===n?u=t[1]:(u=h(n),t[0]=n,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=Te(n),t[2]=n,t[3]=f);let p;t[4]!==d||t[5]!==f?(p={defaultValues:d,resolver:f,reValidateMode:`onChange`},t[4]=d,t[5]=f,t[6]=p):p=t[6];let m=Ce(p),[g,v]=R.useState(i),y=mt(),b;t[7]!==s||t[8]!==y||t[9]!==c||t[10]!==g?(b=e=>{y(s(e,g)),c()},t[7]=s,t[8]=y,t[9]=c,t[10]=g,t[11]=b):b=t[11];let x=b,S;t[12]!==m||t[13]!==x?(S=m.handleSubmit(x),t[12]=m,t[13]=x,t[14]=S):S=t[14];let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,z.jsx)(be,{}),t[15]=C):C=t[15];let w;t[16]!==m||t[17]!==n?(w=(0,z.jsx)(at,{children:(0,z.jsx)(_,{schema:n,form:m,renderers:ft,children:C})}),t[16]=m,t[17]=n,t[18]=w):w=t[18];let T;t[19]!==a||t[20]!==m.formState.isValid||t[21]!==r||t[22]!==o||t[23]!==l||t[24]!==g?(T=(0,z.jsx)(pt,{onBack:l,isValid:m.formState.isValid,libraries:r,preferredLibrary:g,onLibraryChange:v,displayNames:a,libraryLabel:o}),t[19]=a,t[20]=m.formState.isValid,t[21]=r,t[22]=o,t[23]=l,t[24]=g,t[25]=T):T=t[25];let E;return t[26]!==S||t[27]!==w||t[28]!==T?(E=(0,z.jsxs)(`form`,{onSubmit:S,className:`space-y-4`,children:[w,T]}),t[26]=S,t[27]=w,t[28]=T,t[29]=E):E=t[29],E};function H(){return l().optional().describe(m.of({label:`Password`,inputType:`password`,optionRegex:`(password|passwd|pgpassword|db.?pass(word)?)`}))}function U(e,t){let n=l();return n=t?n.nonempty():n.optional(),n=n.describe(m.of({label:e||`Token`,inputType:`password`,optionRegex:`(token|api.?key|access.?token|auth.?token|(^|_)pat(_|$))`})),n}function W(){return l().optional().describe(m.of({label:`Warehouse Name`,optionRegex:`(warehouse|snowflake.?warehouse)`}))}function G(e,t){let n=l();return n=t?n.nonempty():n.optional(),n.describe(m.of({label:e||`URI`,optionRegex:`(uri|url|connection.?string|database.?url|jdbc)`}))}function K(e){return l().nonempty().describe(m.of({label:e||`Host`,optionRegex:`^(?!.*(kubernetes|gpg)).*(host(name)?|pghost|db.?host|database.?host|mysql.?host|postgres.?host|server.?host)`}))}function q(){return l().describe(m.of({label:`Database`,optionRegex:`(database|db.?name|pgdatabase|^DB$|^DATABASE$)`}))}function gt(){return l().describe(m.of({label:`Schema`,optionRegex:`(^SCHEMA$|db.?schema|postgres.?schema|pg.?schema|_SCHEMA$)`}))}function J(){return l().nonempty().describe(m.of({label:`Username`,optionRegex:`(username|pguser|db.?user|^USER$|_USER$)`}))}function Y(e){let t=g().describe(m.of({label:`Port`,inputType:`number`,placeholder:e?.toString()})).transform(Number).refine(e=>e>=0&&e<=65535,{message:`Port must be between 0 and 65535`});return e===void 0?t:t.default(e)}function _t(){return d().default(!1).describe(m.of({label:`Read Only`}))}var vt=c({type:f(`postgres`),host:K(),port:Y(5432).optional(),database:q(),username:J(),password:H(),ssl:d().default(!1).describe(m.of({label:`Use SSL`}))}).describe(m.of({direction:`two-columns`})),yt=c({type:f(`mysql`),host:K(),port:Y(3306),database:q(),username:J(),password:H(),ssl:d().default(!1).describe(m.of({label:`Use SSL`}))}).describe(m.of({direction:`two-columns`})),bt=c({type:f(`sqlite`),database:q().describe(m.of({label:`Database Path`}))}).describe(m.of({direction:`two-columns`})),xt=c({type:f(`duckdb`),database:q().describe(m.of({label:`Database Path`})),read_only:_t()}).describe(m.of({direction:`two-columns`})),St=c({type:f(`motherduck`),database:q().default(`my_db`).describe(m.of({label:`Database Name`})),token:U()}).describe(m.of({direction:`two-columns`})),Ct=c({type:f(`snowflake`),account:l().nonempty().describe(m.of({label:`Account`,optionRegex:`(snowflake.?account|^SNOWFLAKE_ACCOUNT$|account.?id)`})),warehouse:l().optional().describe(m.of({label:`Warehouse`,optionRegex:`(snowflake.?warehouse|warehouse)`})),database:q(),schema:l().optional().describe(m.of({label:`Schema`,optionRegex:`(snowflake.?schema|^SCHEMA$|_SCHEMA$)`})),role:l().optional().describe(m.of({label:`Role`})),authType:p(`type`,[c({type:f(`Password`),username:J(),password:H(),enable_mfa:d().default(!1).describe(m.of({label:`Enable MFA (Duo Push)`}))}),c({type:f(`SSO (Browser)`),username:J()}),c({type:f(`Key Pair`),username:J(),private_key_path:l().nonempty().describe(m.of({label:`Private Key Path`,placeholder:`/path/to/rsa_key.p8`})),private_key_passphrase:l().optional().describe(m.of({label:`Private Key Passphrase`,inputType:`password`,optionRegex:`(passphrase|private.?key.?passphrase|key.?passphrase)`}))}),c({type:f(`OAuth / PAT`),token:U(`Token`,!0)})]).default({type:`Password`,username:`username`,enable_mfa:!1}).describe(m.of({special:`tabs`}))}).describe(m.of({direction:`two-columns`})),wt=c({type:f(`bigquery`),project:l().nonempty().describe(m.of({label:`Project ID`,optionRegex:`(bigquery.?project|gcp.?project|google.?cloud.?project|project.?id)`})),dataset:l().nonempty().describe(m.of({label:`Dataset`,optionRegex:`(bigquery.?dataset|dataset)`})),credentials_json:l().describe(m.of({label:`Credentials JSON`,special:`secret_textarea`}))}).describe(m.of({direction:`two-columns`})),Tt=c({type:f(`clickhouse_connect`),host:K(),port:Y(8123).optional(),username:J(),password:H(),secure:d().default(!1).describe(m.of({label:`Use HTTPs`})),proxy_path:l().optional().describe(m.of({label:`Proxy Path`,placeholder:`/clickhouse`}))}).describe(m.of({direction:`two-columns`})),Et=c({type:f(`timeplus`),host:K().default(`localhost`),port:Y(8123).optional(),username:J().default(`default`),password:H().default(``)}).describe(m.of({direction:`two-columns`})),Dt=c({type:f(`chdb`),database:q().describe(m.of({label:`Database Path`})),read_only:_t()}).describe(m.of({direction:`two-columns`})),Ot=c({type:f(`trino`),host:K(),port:Y(8080),database:q(),schema:gt().optional(),username:J(),password:H(),async_support:d().default(!1).describe(m.of({label:`Async Support`}))}).describe(m.of({direction:`two-columns`})),kt=c({type:f(`iceberg`),name:l().describe(m.of({label:`Catalog Name`})),catalog:p(`type`,[c({type:f(`REST`),warehouse:W(),uri:l().optional().describe(m.of({label:`URI`,placeholder:`https://`,optionRegex:`(uri|url|connection.?string|database.?url|jdbc)`})),token:U()}),c({type:f(`SQL`),warehouse:W(),uri:l().optional().describe(m.of({label:`URI`,placeholder:`jdbc:iceberg://host:port/database`,optionRegex:`(uri|url|connection.?string|database.?url|jdbc)`}))}),c({type:f(`Hive`),warehouse:W(),uri:G()}),c({type:f(`Glue`),warehouse:W(),uri:G()}),c({type:f(`DynamoDB`),"dynamodb.profile-name":l().optional().describe(m.of({label:`Profile Name`})),"dynamodb.region":l().optional().describe(m.of({label:`Region`})),"dynamodb.access-key-id":l().optional().describe(m.of({label:`Access Key ID`,inputType:`password`,optionRegex:`(access.?key.?id|aws.?access.?key)`})),"dynamodb.secret-access-key":l().optional().describe(m.of({label:`Secret Access Key`,inputType:`password`,optionRegex:`(secret.?access.?key|aws.?secret)`})),"dynamodb.session-token":l().optional().describe(m.of({label:`Session Token`,inputType:`password`,optionRegex:`(session.?token|aws.?session)`}))})]).default({type:`REST`,token:void 0}).describe(m.of({special:`tabs`}))}),At=c({type:f(`datafusion`),sessionContext:d().optional().describe(m.of({label:`Use Session Context`}))}),jt=c({type:f(`pyspark`),host:K().optional(),port:Y().optional()}),Mt=c({type:f(`redshift`),host:K(),port:Y(5439),connectionType:p(`type`,[c({type:f(`IAM credentials`),region:l().describe(m.of({label:`Region`})),aws_access_key_id:l().nonempty().describe(m.of({label:`AWS Access Key ID`,inputType:`password`,optionRegex:`(access.?key.?id|aws.?access.?key)`})),aws_secret_access_key:l().nonempty().describe(m.of({label:`AWS Secret Access Key`,inputType:`password`,optionRegex:`(secret.?access.?key|aws.?secret)`})),aws_session_token:l().optional().describe(m.of({label:`AWS Session Token`,inputType:`password`,optionRegex:`(session.?token|aws.?session)`}))}),c({type:f(`DB credentials`),user:J(),password:H()})]).default({type:`IAM credentials`,aws_access_key_id:``,aws_secret_access_key:``,region:``}),database:q()}).describe(m.of({direction:`two-columns`})),Nt=c({type:f(`databricks`),access_token:U(`Access Token`,!0),server_hostname:K(`Server Hostname`),http_path:G(`HTTP Path`,!0),catalog:l().optional().describe(m.of({label:`Catalog`})),schema:l().optional().describe(m.of({label:`Schema`}))}).describe(m.of({direction:`two-columns`})),Pt=c({type:f(`supabase`),host:K(),port:Y(5432).optional(),database:q(),username:J(),password:H(),disable_client_pooling:d().default(!1).describe(m.of({label:`Disable Client-Side Pooling`}))}).describe(m.of({direction:`two-columns`})),Ft=p(`type`,[vt,yt,bt,xt,St,Ct,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt]),It={sqlmodel:`SQLModel`,sqlalchemy:`SQLAlchemy`,duckdb:`DuckDB`,clickhouse_connect:`ClickHouse Connect`,chdb:`chDB`,pyiceberg:`PyIceberg`,ibis:`Ibis`,motherduck:`MotherDuck`,redshift:`Redshift`,databricks:`Databricks`},X=class{connection;orm;secrets;constructor(e,t,n){this.connection=e,this.orm=t,this.secrets=n}get imports(){let e=new Set(this.generateImports());switch(this.orm){case`sqlalchemy`:e.add(`import sqlalchemy`);break;case`sqlmodel`:e.add(`import sqlmodel`);break;case`duckdb`:e.add(`import duckdb`);break;case`ibis`:e.add(`import ibis`)}return e}},Lt=e=>`_${e}`,Rt=class{secrets={};get imports(){return Object.keys(this.secrets).length===0?new Set:new Set([`import os`])}print(e,t,n){if(e=Lt(e),I(t)){let r=Ge(t),i=n?`os.environ.get("${r}", "${n}")`:`os.environ.get("${r}")`;return this.secrets[e]=i,e}if(n!=null){let r=`os.environ.get("${t}", "${n}")`;return this.secrets[e]=r,e}return typeof t==`number`||typeof t==`number`?`${t}`:typeof t==`boolean`?Z(t):t?`"${t}"`:``}printInFString(e,t,n){if(t===void 0)return``;if(typeof t==`number`)return`${t}`;if(typeof t==`boolean`)return Z(t);let r=this.print(e,t,n);return r.startsWith(`"`)&&r.endsWith(`"`)?r.slice(1,-1):`{${r}}`}printPassword(e,t,n,r){let i=n?this.printInFString.bind(this):this.print.bind(this);return I(e)?i(r||`password`,e):i(r||`password`,t,e)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?``:Object.entries(this.secrets).map(([e,t])=>`${e} = ${t}`).join(`
2
- `)}},zt=class extends X{generateImports(){return[]}generateConnectionCode(){let e=this.connection.ssl?`, connect_args={'sslmode': 'require'}`:``,t=this.secrets.printPassword(this.connection.password,`POSTGRES_PASSWORD`,!0),n=this.secrets.printInFString(`username`,this.connection.username),r=this.secrets.printInFString(`host`,this.connection.host),i=this.secrets.printInFString(`port`,this.connection.port),a=this.secrets.printInFString(`database`,this.connection.database);return s(`
3
- DATABASE_URL = f"postgresql://${n}:${t}@${r}:${i}/${a}"
4
- engine = ${this.orm}.create_engine(DATABASE_URL${e})
5
- `)}},Bt=class extends X{generateImports(){return[]}generateConnectionCode(){let e=this.connection.ssl?`, connect_args={'ssl': {'ssl-mode': 'preferred'}}`:``,t=this.secrets.printPassword(this.connection.password,`MYSQL_PASSWORD`,!0),n=this.secrets.printInFString(`database`,this.connection.database),r=this.secrets.printInFString(`username`,this.connection.username),i=this.secrets.printInFString(`host`,this.connection.host),a=this.secrets.printInFString(`port`,this.connection.port);return s(`
6
- DATABASE_URL = f"mysql+pymysql://${r}:${t}@${i}:${a}/${n}"
7
- engine = ${this.orm}.create_engine(DATABASE_URL${e})
8
- `)}},Vt=class extends X{generateImports(){return[]}generateConnectionCode(){let e=this.connection.database?this.secrets.printInFString(`database`,this.connection.database):``,t=e.startsWith(`{`)&&e.endsWith(`}`)?`DATABASE_URL = f"sqlite:///${e}"`:`DATABASE_URL = "sqlite:///${e}"`;return s(`
9
- ${t}
10
- engine = ${this.orm}.create_engine(DATABASE_URL)
11
- `)}},Ht=class extends X{generateImports(){return[`from snowflake.sqlalchemy import URL`]}generateConnectionCode(){let{authType:e,account:t,database:n,warehouse:r,schema:i,role:a}=this.connection,o={account:this.secrets.print(`account`,t),database:this.secrets.print(`database`,n),warehouse:r?this.secrets.print(`warehouse`,r):void 0,schema:i?this.secrets.print(`schema`,i):void 0,role:a?this.secrets.print(`role`,a):void 0};switch(e.type){case`Password`:{let t=this.secrets.printPassword(e.password,`SNOWFLAKE_PASSWORD`,!1),n={...o,user:this.secrets.print(`user`,e.username),password:t};return e.enable_mfa?s(`
12
- engine = ${this.orm}.create_engine(
13
- URL(
14
- ${Q(n,e=>` ${e}`)},
15
- ),
16
- connect_args={"authenticator": "username_password_mfa"},
17
- )
18
- `):s(`
19
- engine = ${this.orm}.create_engine(
20
- URL(
21
- ${Q(n,e=>` ${e}`)},
22
- )
23
- )
24
- `)}case`SSO (Browser)`:{let t={...o,user:this.secrets.print(`user`,e.username),authenticator:`"externalbrowser"`};return s(`
25
- engine = ${this.orm}.create_engine(
26
- URL(
27
- ${Q(t,e=>` ${e}`)},
28
- )
29
- )
30
- `)}case`Key Pair`:{let t={...o,user:this.secrets.print(`user`,e.username)},n=this.secrets.print(`private_key_path`,e.private_key_path),r=e.private_key_passphrase?this.secrets.printPassword(e.private_key_passphrase,`SNOWFLAKE_PRIVATE_KEY_PASSPHRASE`,!1):void 0,i=[` "authenticator": "SNOWFLAKE_JWT"`,` "private_key_file": ${n}`];return r&&i.push(` "private_key_file_pwd": ${r}`),s(`
31
- engine = ${this.orm}.create_engine(
32
- URL(
33
- ${Q(t,e=>` ${e}`)},
34
- ),
35
- connect_args={
36
- ${i.join(`,
37
- `)},
38
- },
39
- )
40
- `)}case`OAuth / PAT`:{let t=this.secrets.printPassword(e.token,`SNOWFLAKE_TOKEN`,!1),n={...o,authenticator:`"oauth"`,token:t};return s(`
41
- engine = ${this.orm}.create_engine(
42
- URL(
43
- ${Q(n,e=>` ${e}`)},
44
- )
45
- )
46
- `)}default:D(e)}}},Ut=class extends X{get credential(){return N(this.connection.credentials_json,e=>this.secrets.print(`credentials_json`,e))}generateImports(){return this.credential.kind===`path`?[]:[`import json`]}generateConnectionCode(){let e=this.secrets.printInFString(`project`,this.connection.project),t=this.secrets.printInFString(`dataset`,this.connection.dataset),n=this.credential;return n.kind===`path`?s(`
47
- engine = ${this.orm}.create_engine(f"bigquery://${e}/${t}", credentials_path="${F(n.path)}")
48
- `):s(`
49
- credentials = ${n.expr}
50
- engine = ${this.orm}.create_engine(f"bigquery://${e}/${t}", credentials_info=credentials)
51
- `)}},Wt=class extends X{generateImports(){return[]}generateConnectionCode(){let e=this.secrets.printInFString(`database`,this.connection.database||`:memory:`);return s(`
52
- DATABASE_URL = "${e}"
53
- engine = ${this.orm}.connect(DATABASE_URL, read_only=${Z(this.connection.read_only)})
54
- `)}},Gt=class extends X{generateImports(){return[]}generateConnectionCode(){let e=this.secrets.printInFString(`database`,this.connection.database);if(!this.connection.token)return s(`
55
- conn = duckdb.connect("md:${e}")
56
- `);let t=this.secrets.printPassword(this.connection.token,`MOTHERDUCK_TOKEN`,!1);return s(`
57
- conn = duckdb.connect("md:${e}", config={"motherduck_token": ${t}})
58
- `)}},Kt=class extends X{generateImports(){return[`import clickhouse_connect`]}generateConnectionCode(){let e=this.secrets.printPassword(this.connection.password,`CLICKHOUSE_PASSWORD`,!1),t={host:this.secrets.print(`host`,this.connection.host),user:this.secrets.print(`user`,this.connection.username),secure:this.secrets.print(`secure`,this.connection.secure),port:this.connection.port?this.secrets.print(`port`,this.connection.port):void 0,password:this.connection.password?e:void 0,proxy_path:this.connection.proxy_path?this.secrets.print(`proxy_path`,this.connection.proxy_path):void 0};return s(`
59
- engine = ${this.orm}.get_client(
60
- ${Q(t,e=>` ${e}`)},
61
- )
62
- `)}},qt=class extends X{generateImports(){return[]}generateConnectionCode(){let e=this.secrets.printPassword(this.connection.password,`TIMEPLUS_PASSWORD`,!0),t=this.secrets.printInFString(`username`,this.connection.username),n=this.secrets.printInFString(`host`,this.connection.host),r=this.secrets.printInFString(`port`,this.connection.port);return s(`
63
- DATABASE_URL = f"timeplus://${t}:${e}@${n}:${r}"
64
- engine = ${this.orm}.create_engine(DATABASE_URL)
65
- `)}},Jt=class extends X{generateImports(){return[`import chdb`]}generateConnectionCode(){let e=this.secrets.print(`database`,this.connection.database)||`""`;return s(`
66
- engine = ${this.orm}.connect(${e}, read_only=${Z(this.connection.read_only)})
67
- `)}},Yt=class extends X{generateImports(){return this.connection.async_support?[`import aiotrino`]:[`import trino.sqlalchemy`]}generateConnectionCode(){let e=this.connection.async_support?`aiotrino`:`trino`,t=this.connection.schema?`/${this.connection.schema}`:``,n=this.secrets.printInFString(`username`,this.connection.username),r=this.secrets.printInFString(`host`,this.connection.host),i=this.secrets.printInFString(`port`,this.connection.port),a=this.secrets.printInFString(`database`,this.connection.database),o=this.secrets.printPassword(this.connection.password,`TRINO_PASSWORD`,!0);return s(`
68
- engine = ${this.orm}.create_engine(f"${e}://${n}:${o}@${r}:${i}/${a}${t}")
69
- `)}},Xt=class extends X{getCatalogOptions(){return Object.fromEntries(Object.entries(this.connection.catalog).filter(([e,t])=>t!=null&&t!==``&&e!==`type`))}generateImports(){if(Object.keys(this.getCatalogOptions()).length===0)return[`from pyiceberg.catalog import load_catalog`];switch(this.connection.catalog.type){case`REST`:return[`from pyiceberg.catalog.rest import RestCatalog`];case`SQL`:return[`from pyiceberg.catalog.sql import SqlCatalog`];case`Hive`:return[`from pyiceberg.catalog.hive import HiveCatalog`];case`Glue`:return[`from pyiceberg.catalog.glue import GlueCatalog`];case`DynamoDB`:return[`from pyiceberg.catalog.dynamodb import DynamoDBCatalog`];default:D(this.connection.catalog)}}generateConnectionCode(){let e=`"${this.connection.name}"`,t=this.getCatalogOptions();if(Object.keys(t).length===0)return`catalog = load_catalog(${e})`;for(let[e,n]of Object.entries(t))I(n)?t[e]=this.secrets.print(e,n):typeof n==`string`&&(t[e]=`"${n}"`);let n=an(t,e=>` ${e}`);switch(this.connection.catalog.type){case`REST`:return s(`
70
- catalog = RestCatalog(
71
- ${e},
72
- **{\n${n}
73
- },
74
- )
75
- `);case`SQL`:return s(`
76
- catalog = SqlCatalog(
77
- ${e},
78
- **{\n${n}
79
- },
80
- )
81
- `);case`Hive`:return s(`
82
- catalog = HiveCatalog(
83
- ${e},
84
- **{\n${n}
85
- },
86
- )
87
- `);case`Glue`:return s(`
88
- catalog = GlueCatalog(
89
- ${e},
90
- **{\n${n}
91
- },
92
- )
93
- `);case`DynamoDB`:return s(`
94
- catalog = DynamoDBCatalog(
95
- ${e},
96
- **{\n${n}
97
- },
98
- )
99
- `);default:D(this.connection.catalog)}}},Zt=class extends X{generateImports(){return[`from datafusion import SessionContext`]}generateConnectionCode(){return this.connection.sessionContext?s(`
100
- ctx = SessionContext()
101
- # Sample table
102
- _ = ctx.from_pydict({"a": [1, 2, 3]}, "my_table")
103
-
104
- con = ibis.datafusion.connect(ctx)
105
- `):s(`
106
- con = ibis.datafusion.connect()
107
- `)}},Qt=class extends X{generateImports(){return[`from pyspark.sql import SparkSession`]}generateConnectionCode(){if(this.connection.host||this.connection.port){let e=this.secrets.printInFString(`host`,this.connection.host),t=this.secrets.printInFString(`port`,this.connection.port);return s(`
108
- session = SparkSession.builder.remote(f"sc://${e}:${t}").getOrCreate()
109
- con = ibis.pyspark.connect(session)
110
- `)}return s(`
111
- con = ibis.pyspark.connect()
112
- `)}},$t=class extends X{generateImports(){return[`import redshift_connector`]}generateConnectionCode(){let e=this.secrets.print(`host`,this.connection.host),t=this.secrets.print(`port`,this.connection.port),n=this.secrets.print(`database`,this.connection.database);if(this.connection.connectionType.type===`IAM credentials`){let r=this.secrets.print(`aws_access_key_id`,this.connection.connectionType.aws_access_key_id),i=this.secrets.print(`aws_secret_access_key`,this.connection.connectionType.aws_secret_access_key),a=this.connection.connectionType.aws_session_token?this.secrets.print(`aws_session_token`,this.connection.connectionType.aws_session_token):void 0,o={iam:!0,host:e,port:t,region:`"${this.connection.connectionType.region}"`,database:n,access_key_id:r,secret_access_key:i,...a&&{session_token:a}};return s(`
113
- con = redshift_connector.connect(
114
- ${Q(o,e=>` ${e}`)},
115
- )
116
- `)}let r=this.connection.connectionType.user?this.secrets.print(`user`,this.connection.connectionType.user):void 0,i=this.connection.connectionType.password?this.secrets.printPassword(this.connection.connectionType.password,`REDSHIFT_PASSWORD`,!1):void 0,a={host:e,port:t,database:n,...r&&{user:r},...i&&{password:i}};return s(`
117
- con = redshift_connector.connect(
118
- ${Q(a,e=>` ${e}`)},
119
- )
120
- `)}},en=class extends X{generateImports(){return[]}generateConnectionCode(){let e=this.orm!==`ibis`,t=this.secrets.printPassword(this.connection.access_token,`DATABRICKS_ACCESS_TOKEN`,e,`access_token`),n=this.secrets.printPassword(this.connection.server_hostname,`DATABRICKS_SERVER_HOSTNAME`,e,`server_hostname`),r=this.secrets.printPassword(this.connection.http_path,`DATABRICKS_HTTP_PATH`,e,`http_path`),i=this.connection.catalog?this.secrets.printInFString(`catalog`,this.connection.catalog):void 0,a=this.connection.schema?this.secrets.printInFString(`schema`,this.connection.schema):void 0,o=`databricks://token:${t}@${n}?http_path=${r}`;if(i&&(o+=`&catalog=${i}`),a&&(o+=`&schema=${a}`),this.orm===`ibis`){let e=i?`\n catalog=${i},`:``,o=a?`\n schema=${a},`:``;return s(`
121
- engine = ibis.databricks.connect(
122
- server_hostname=${n},
123
- http_path=${r},${e}${o}
124
- access_token=${t}
125
- )
126
- `)}return s(`
127
- DATABASE_URL = f"${o}"
128
- engine = ${this.orm}.create_engine(DATABASE_URL)
129
- `)}},tn=class extends X{generateImports(){return this.connection.disable_client_pooling?[`from sqlalchemy.pool import NullPool`]:[]}generateConnectionCode(){let e=this.secrets.printPassword(this.connection.password,`SUPABASE_PASSWORD`,!0),t=this.secrets.printInFString(`username`,this.connection.username),n=this.secrets.printInFString(`host`,this.connection.host),r=this.secrets.printInFString(`port`,this.connection.port),i=this.secrets.printInFString(`database`,this.connection.database),a=this.connection.disable_client_pooling?`, poolclass=NullPool`:``;return s(`
130
- DATABASE_URL = f"postgresql+psycopg2://${t}:${e}@${n}:${r}/${i}?sslmode=require"
131
- engine = ${this.orm}.create_engine(DATABASE_URL${a})
132
- `)}},nn=class{secrets=new Rt;createGenerator(e,t){switch(e.type){case`postgres`:return new zt(e,t,this.secrets);case`mysql`:return new Bt(e,t,this.secrets);case`sqlite`:return new Vt(e,t,this.secrets);case`snowflake`:return new Ht(e,t,this.secrets);case`bigquery`:return new Ut(e,t,this.secrets);case`duckdb`:return new Wt(e,t,this.secrets);case`motherduck`:return new Gt(e,t,this.secrets);case`clickhouse_connect`:return new Kt(e,t,this.secrets);case`timeplus`:return new qt(e,t,this.secrets);case`chdb`:return new Jt(e,t,this.secrets);case`trino`:return new Yt(e,t,this.secrets);case`iceberg`:return new Xt(e,t,this.secrets);case`datafusion`:return new Zt(e,t,this.secrets);case`pyspark`:return new Qt(e,t,this.secrets);case`redshift`:return new $t(e,t,this.secrets);case`databricks`:return new en(e,t,this.secrets);case`supabase`:return new tn(e,t,this.secrets);default:D(e)}}};function rn(e,t){if(!(t in It))throw Error(`Unsupported library: ${t}`);Ft.parse(e);let n=new nn,r=n.createGenerator(e,t),i=r.generateConnectionCode(),a=n.secrets,o=[...new Set([...a.imports,...r.imports])].toSorted();o.push(``);let s=a.formatSecrets();return s&&o.push(s),o.push(i.trim()),o.join(`
133
- `)}function Z(e){return e.toString().charAt(0).toUpperCase()+e.toString().slice(1)}function Q(e,t){return Object.entries(e).filter(([,e])=>e!=null&&e!==``).map(([e,n])=>t(typeof n==`boolean`?`${e}=${Z(n)}`:`${e}=${n}`)).join(`,
134
- `)}function an(e,t){return Object.entries(e).filter(([,e])=>e!=null&&e!==``).map(([e,n])=>{let r=`"${e}"`;return t(typeof n==`boolean`?`${r}: ${Z(n)}`:`${r}: ${n}`)}).join(`,
135
- `)}var on=[{name:`PostgreSQL`,schema:vt,color:`#336791`,logo:`postgres`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`],preferred:`sqlalchemy`}},{name:`MySQL`,schema:yt,color:`#00758F`,logo:`mysql`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`],preferred:`sqlalchemy`}},{name:`SQLite`,schema:bt,color:`#003B57`,logo:`sqlite`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`],preferred:`sqlalchemy`}},{name:`DuckDB`,schema:xt,color:`#FFD700`,logo:`duckdb`,connectionLibraries:{libraries:[`duckdb`],preferred:`duckdb`}},{name:`MotherDuck`,schema:St,color:`#ff9538`,logo:`motherduck`,connectionLibraries:{libraries:[`duckdb`],preferred:`duckdb`}},{name:`Snowflake`,schema:Ct,color:`#29B5E8`,logo:`snowflake`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`],preferred:`sqlalchemy`}},{name:`ClickHouse`,schema:Tt,color:`#2C2C1D`,logo:`clickhouse`,connectionLibraries:{libraries:[`clickhouse_connect`],preferred:`clickhouse_connect`}},{name:`Timeplus`,schema:Et,color:`#B83280`,logo:`timeplus`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`],preferred:`sqlalchemy`}},{name:`BigQuery`,schema:wt,color:`#4285F4`,logo:`bigquery`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`],preferred:`sqlalchemy`}},{name:`ClickHouse Embedded`,schema:Dt,color:`#f2b611`,logo:`clickhouse`,connectionLibraries:{libraries:[`chdb`],preferred:`chdb`}},{name:`Trino`,schema:Ot,color:`#d466b6`,logo:`trino`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`],preferred:`sqlalchemy`}},{name:`DataFusion`,schema:At,color:`#202A37`,logo:`datafusion`,connectionLibraries:{libraries:[`ibis`],preferred:`ibis`}},{name:`PySpark`,schema:jt,color:`#1C5162`,logo:`pyspark`,connectionLibraries:{libraries:[`ibis`],preferred:`ibis`}},{name:`Redshift`,schema:Mt,color:`#522BAE`,logo:`redshift`,connectionLibraries:{libraries:[`redshift`],preferred:`redshift`}},{name:`Databricks`,schema:Nt,color:`#c41e0c`,logo:`databricks`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`,`ibis`],preferred:`sqlalchemy`}},{name:`Supabase`,schema:Pt,color:`#238F5F`,logo:`supabase`,connectionLibraries:{libraries:[`sqlalchemy`,`sqlmodel`],preferred:`sqlalchemy`}}],sn=[{name:`Iceberg`,schema:kt,color:`#000000`,logo:`iceberg`,connectionLibraries:{libraries:[`pyiceberg`],preferred:`pyiceberg`}}],cn=[...on,...sn],ln=e=>{let t=(0,L.c)(12),{onSelect:n}=e,i;t[0]===n?i=t[1]:(i=on.map(e=>{let{name:t,schema:i,color:a,logo:o}=e;return(0,z.jsx)(V,{name:t,color:a,icon:(0,z.jsx)(r,{name:o,className:`w-8 h-8 text-white brightness-0 invert dark:invert`}),onSelect:()=>n(i)},t)}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a=(0,z.jsx)(B,{children:i}),t[2]=i,t[3]=a);let o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsxs)(`h4`,{className:`font-semibold text-muted-foreground text-lg flex items-center gap-4 my-2`,children:[`Data Catalogs`,(0,z.jsx)(`hr`,{className:`flex-1`})]}),t[4]=o):o=t[4];let s;t[5]===n?s=t[6]:(s=sn.map(e=>{let{name:t,schema:i,color:a,logo:o}=e;return(0,z.jsx)(V,{name:t,color:a,icon:(0,z.jsx)(r,{name:o,className:`w-8 h-8 text-white brightness-0 invert dark:invert`}),onSelect:()=>n(i)},t)}),t[5]=n,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,z.jsx)(B,{children:s}),t[7]=s,t[8]=c);let l;return t[9]!==a||t[10]!==c?(l=(0,z.jsxs)(z.Fragment,{children:[a,o,c]}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l},un=e=>{let t=(0,L.c)(13),{onSubmit:n,header:r}=e,[i,a]=(0,R.useState)(null);if(!i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`div`,{children:(0,z.jsx)(ln,{onSelect:a})}),t[0]=e):e=t[0];let n;return t[1]===r?n=t[2]:(n=(0,z.jsxs)(z.Fragment,{children:[r,e]}),t[1]=r,t[2]=n),n}let o;t[3]===i?o=t[4]:(o=cn.find(e=>e.schema===i),t[3]=i,t[4]=o);let s=o?.connectionLibraries,c;t[5]===s?.libraries?c=t[6]:(c=s?.libraries??[],t[5]=s?.libraries,t[6]=c);let l=s?.preferred??`sqlalchemy`,u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>a(null),t[7]=u):u=t[7];let d;return t[8]!==n||t[9]!==i||t[10]!==c||t[11]!==l?(d=(0,z.jsx)(ht,{schema:i,libraries:c,preferredLibrary:l,displayNames:It,libraryLabel:`Preferred connection library`,generateCode:dn,onSubmit:n,onBack:u}),t[8]=n,t[9]=i,t[10]=c,t[11]=l,t[12]=d):d=t[12],d};function dn(e,t){return rn(e,t)}function fn(){let e=(0,L.c)(2),n=t($e),r;return e[0]===n?r=e[1]:(r=[n],e[0]=n,e[1]=r),Ie(Qe,r)}function pn(e){let n=(0,L.c)(6),{data:r}=fn(),i=t(o),a=t(et),s;bb0:{if(!r){let e;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[0]=e):e=n[0],s=e;break bb0}let t;if(n[1]!==i||n[2]!==r||n[3]!==e||n[4]!==a){let o={dialects:[...i.values()].map(gn),storageProtocols:a.map(hn),storageBackendTypes:a.map(mn)};t=r.filter(t=>Xe(t,e)&&!Ze(t,o)),n[1]=i,n[2]=r,n[3]=e,n[4]=a,n[5]=t}else t=n[5];s=t}return s}function mn(e){return e.backendType.toLowerCase()}function hn(e){return e.protocol.toLowerCase()}function gn(e){return e.dialect.toLowerCase()}var _n=e=>{let t=(0,L.c)(13),{className:n,sources:r,onAdd:i}=e;if(r.length===0)return null;let a;t[0]===n?a=t[1]:(a=x(`rounded-full bg-[linear-gradient(135deg,var(--blue-2),var(--purple-3))] px-3 py-2`,n),t[0]=n,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsxs)(`div`,{className:`mr-1 flex items-center gap-1.5`,children:[(0,z.jsx)(_e,{className:`h-3.5 w-3.5 text-(--blue-9)`}),(0,z.jsx)(`h3`,{id:`quick-add-data-sources-title`,className:`text-sm`,children:`Quick add`})]}),t[2]=o):o=t[2];let s;if(t[3]!==i||t[4]!==r){let e;t[6]===i?e=t[7]:(e=e=>(0,z.jsx)(ue,{side:`bottom`,content:(0,z.jsx)(vn,{source:e}),children:(0,z.jsxs)(`button`,{type:`button`,"aria-label":`Add ${e.displayName} connection`,className:`inline-flex items-center gap-1 rounded-full border border-border/60 bg-background px-2.5 py-1 text-xs font-medium text-foreground/90 transition-colors hover:border-(--blue-7) focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2`,onClick:()=>i(e),children:[(0,z.jsx)(ge,{className:`h-3 w-3 text-muted-foreground`}),e.displayName]})},e.id),t[6]=i,t[7]=e),s=r.map(e),t[3]=i,t[4]=r,t[5]=s}else s=t[5];let c;t[8]===s?c=t[9]:(c=(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o,(0,z.jsx)(le,{delayDuration:200,children:s})]}),t[8]=s,t[9]=c);let l;return t[10]!==a||t[11]!==c?(l=(0,z.jsx)(`section`,{"aria-labelledby":`quick-add-data-sources-title`,className:a,children:c}),t[10]=a,t[11]=c,t[12]=l):l=t[12],l},vn=e=>{let t=(0,L.c)(17),{source:n}=e,r;t[0]===n.displayName?r=t[1]:(r=(0,z.jsx)(`div`,{className:`font-medium`,children:n.displayName}),t[0]=n.displayName,t[1]=r);let i;t[2]===n.origins?i=t[3]:(i=n.origins.map(bn).join(` and `),t[2]=n.origins,t[3]=i);let a;t[4]===i?a=t[5]:(a=(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Detected from`,` `,i]}),t[4]=i,t[5]=a);let o;t[6]!==r||t[7]!==a?(o=(0,z.jsxs)(`div`,{children:[r,a]}),t[6]=r,t[7]=a,t[8]=o):o=t[8];let s;t[9]===n.configuration?s=t[10]:(s=n.configuration.map(xn),t[9]=n.configuration,t[10]=s);let c;t[11]===s?c=t[12]:(c=(0,z.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:s}),t[11]=s,t[12]=c);let l;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Click to add a configured cell.`}),t[13]=l):l=t[13];let u;return t[14]!==o||t[15]!==c?(u=(0,z.jsxs)(`div`,{className:`min-w-64 space-y-2 py-1`,children:[o,c,l]}),t[14]=o,t[15]=c,t[16]=u):u=t[16],u},yn=e=>{let t=(0,L.c)(7),{onSubmit:n,className:r,group:i}=e,a=mt(),o=pn(i),s;t[0]!==a||t[1]!==n?(s=e=>{a(e.code),n?.()},t[0]=a,t[1]=n,t[2]=s):s=t[2];let c;return t[3]!==r||t[4]!==o||t[5]!==s?(c=(0,z.jsx)(_n,{className:r,sources:o,onAdd:s}),t[3]=r,t[4]=o,t[5]=s,t[6]=c):c=t[6],c};function bn(e){return e.label}function xn(e){return(0,z.jsxs)(`div`,{className:`contents`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:e.field}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:e.value.kind===`environment-variable`?`os.environ["${e.value.name}"]`:e.value.value})})]},e.value.kind===`environment-variable`?e.value.name:`${e.field}:${e.value.value}`)}var $=()=>p(`type`,[c({type:f(`Access keys`),access_key_id:l().optional().describe(m.of({label:`Access Key ID`,description:`Leave empty to use the default credential chain`,inputType:`password`,optionRegex:`(access.?key.?id|object.?storage.?key|aws.?access.?key)`})),secret_access_key:l().optional().describe(m.of({label:`Secret Access Key`,inputType:`password`,optionRegex:`(secret.?access.?key|object.?storage.?secret|aws.?secret)`}))}),c({type:f(`Container credentials`),container_credentials_full_uri:l().nonempty().describe(m.of({label:`Credentials URI`,description:`Endpoint that vends credentials to the container`,placeholder:`http://169.254.170.23/v1/credentials`,optionRegex:`container.?credentials`})),container_authorization_token_file:l().nonempty().describe(m.of({label:`Authorization Token File`,description:`File holding the token sent to the credentials URI`,placeholder:`/var/run/secrets/token`,optionRegex:`(container.?authorization.?token.?file|container.?auth.?token)`}))})]).default({type:`Access keys`}).describe(m.of({label:`Credentials`,special:`tabs`})),Sn=c({type:f(`s3`),bucket:l().nonempty().describe(m.of({label:`Bucket`,placeholder:`my-bucket`,optionRegex:`(bucket|s3.?bucket)`})),region:l().optional().describe(m.of({label:`Region`,placeholder:`us-east-1`,optionRegex:`(region|aws.?region)`})),endpoint_url:l().optional().describe(m.of({label:`Endpoint URL`,description:`Ignored if the AWS_ENDPOINT_URL_S3 environment variable is set`,placeholder:`https://s3.amazonaws.com`,optionRegex:`(endpoint|s3.?url|s3.?endpoint)`})),allow_http:d().default(!1).describe(m.of({label:`Allow HTTP`,description:`Required for plain-http (non-TLS) endpoints`})),auth:$()}).describe(m.of({direction:`two-columns`})),Cn=c({type:f(`gcs`),bucket:l().nonempty().describe(m.of({label:`Bucket`,placeholder:`my-bucket`,optionRegex:`(bucket|gcs.?bucket|google.?bucket)`})),service_account_key:l().optional().describe(m.of({label:`Service Account Key (JSON)`,special:`secret_textarea`}))}).describe(m.of({direction:`two-columns`})),wn=c({type:f(`azure`),container:l().nonempty().describe(m.of({label:`Container`,placeholder:`my-container`})),account_name:l().nonempty().describe(m.of({label:`Account Name`,placeholder:`storageaccount`,optionRegex:`(azure.?account|account.?name|storage.?account)`})),account_key:l().optional().describe(m.of({label:`Account Key`,inputType:`password`,optionRegex:`(azure.?key|account.?key|storage.?key)`}))}).describe(m.of({direction:`two-columns`})),Tn=c({type:f(`coreweave`),bucket:l().nonempty().describe(m.of({label:`Bucket`,placeholder:`bucket-name`})),region:l().nonempty().describe(m.of({label:`Region`,placeholder:`US-EAST-04A`})),auth:$()}).describe(m.of({direction:`two-columns`})),En=c({type:f(`gdrive`),credentials_json:l().optional().describe(m.of({label:`Service Account JSON`,description:`Leave empty to use browser-based authentication`,special:`secret_textarea`}))}).describe(m.of({direction:`two-columns`})),Dn=c({type:f(`huggingface`),token:l().optional().describe(m.of({label:`Access Token`,description:`Leave empty to use the HF_TOKEN environment variable or cached login`,inputType:`password`,optionRegex:`(hf.?token|hugging.?face.?token|hub.?token)`}))}).describe(m.of({direction:`two-columns`}));function On(e){return e!=null&&e!==``}var kn=c({type:f(`github`),org:l().nonempty().describe(m.of({label:`Organization or user`})),repo:l().nonempty().describe(m.of({label:`Repository`})),sha:l().optional().describe(m.of({label:`Branch, tag, or commit`,placeholder:`main`,description:`Leave empty to use the default branch`})),username:l().optional().describe(m.of({label:`Username`,description:`Set this together with access token`,optionRegex:`(github.?username|github.?user)`})),token:l().optional().describe(m.of({label:`Access Token`,description:`Set this together with username. Required for private repos and to avoid GitHub's rate limits.`,inputType:`password`,optionRegex:`(github.?token|gh.?token|github.?pat)`}))}).refine(e=>On(e.username)===On(e.token),{message:`Username and access token are required together`,path:[`token`]}).describe(m.of({direction:`two-columns`})),An=p(`type`,[Sn,Cn,wn,Tn,En,Dn,kn]),jn={obstore:`obstore`,fsspec:`fsspec`,huggingface_hub:`huggingface_hub`},Mn=class{secrets={};get imports(){return Object.keys(this.secrets).length===0?new Set:new Set([`import os`])}print(e,t){if(t===void 0||t===``)return``;let n=`_${e}`;if(I(t)){let e=Ge(t);return this.secrets[n]=`os.environ.get("${e}")`,n}return`"${F(t)}"`}formatSecrets(){return Object.keys(this.secrets).length===0?``:Object.entries(this.secrets).map(([e,t])=>`${e} = ${t}`).join(`
136
- `)}};function Nn(e,t){if(e?.type===`Container credentials`)return[` container_credentials_full_uri=${t.print(`container_credentials_full_uri`,e.container_credentials_full_uri)},`,` container_authorization_token_file=${t.print(`container_authorization_token_file`,e.container_authorization_token_file)},`];let n=[];return e?.access_key_id&&n.push(` access_key_id=${t.print(`access_key_id`,e.access_key_id)},`),e?.secret_access_key&&n.push(` secret_access_key=${t.print(`secret_access_key`,e.secret_access_key)},`),n}function Pn(e,t){let n=t.print(`bucket`,e.bucket),r=new Set([`from obstore.store import S3Store`]),i=[];e.region&&i.push(` region=${t.print(`region`,e.region)},`),i.push(...Nn(e.auth,t)),e.endpoint_url&&i.push(` endpoint_url=${t.print(`endpoint_url`,e.endpoint_url)},`),e.allow_http&&i.push(` allow_http=True,`);let a=i.length>0?`\n${i.join(`
137
- `)}\n`:``;return{imports:r,code:s(`
138
- store = S3Store(${n},${a})
139
- `)}}function Fn(e,t){let n=t.print(`bucket`,e.bucket),r=new Set([`from obstore.store import GCSStore`]);if(!e.service_account_key)return{imports:r,code:s(`
140
- store = GCSStore(${n})
141
- `)};let i=N(e.service_account_key,e=>t.print(`service_account_key`,e));return i.kind===`path`?{imports:r,code:s(`
142
- store = GCSStore(${n},
143
- service_account_path="${F(i.path)}",
144
- )
145
- `)}:(r.add(`import json`),{imports:r,code:s(`
146
- _credentials = ${i.expr}
147
- store = GCSStore(${n},
148
- service_account_key=_credentials,
149
- )
150
- `)})}function In(e,t){let n=t.print(`container`,e.container),r=t.print(`account_name`,e.account_name),i=new Set([`from obstore.store import AzureStore`]),a=[`account_name=${r},`];return e.account_key&&a.push(`account_key=${t.print(`account_key`,e.account_key)},`),{imports:i,code:`store = AzureStore(${n},\n${a.map(e=>` ${e}`).join(`
151
- `)}\n)`}}function Ln(e,t){let n=t.print(`bucket`,e.bucket),r=new Set([`from obstore.store import S3Store`]),i=[` region=${t.print(`region`,e.region)},`];i.push(...Nn(e.auth,t)),i.push(` endpoint="https://${e.bucket}.cwobject.com",`,` virtual_hosted_style_request=True,`);let a=`\n${i.join(`
152
- `)}\n`;return{imports:r,code:s(`
153
- store = S3Store(${n},${a})
154
- `)}}function Rn(e,t){let{secrets:n,isEmbedded:r=!1}=t,i=new Set([`from gdrive_fsspec import GoogleDriveFileSystem`]);if(e.credentials_json){let t=N(e.credentials_json,e=>n.print(`credentials_json`,e));return t.kind===`path`?{imports:i,code:s(`
155
- fs = GoogleDriveFileSystem(creds="${F(t.path)}", token="service_account", use_listings_cache=False, skip_instance_cache=True)
156
- `)}:(i.add(`import json`),{imports:i,code:s(`
157
- _creds = ${t.expr}
158
- fs = GoogleDriveFileSystem(creds=_creds, token="service_account", use_listings_cache=False, skip_instance_cache=True)
159
- `)})}return{imports:i,code:s(r?`
160
- fs = GoogleDriveFileSystem(use_listings_cache=False, skip_instance_cache=True, auth_kwargs={"use_local_webserver": False})
161
- mo.output.clear_console()
162
- `:`
163
- fs = GoogleDriveFileSystem(use_listings_cache=False, skip_instance_cache=True)
164
- `)}}function zn(e,t){let n=new Set([`from huggingface_hub import HfApi`]);return e.token?{imports:n,code:`hf = HfApi(token=${t.print(`token`,e.token)})`}:{imports:n,code:`hf = HfApi()`}}function Bn(e,t){let n=new Set([`from fsspec.implementations.github import GithubFileSystem`]),r=[`org=${t.print(`org`,e.org)},`,`repo=${t.print(`repo`,e.repo)},`];return e.sha&&r.push(`sha=${t.print(`sha`,e.sha)},`),e.username&&e.token&&r.push(`username=${t.print(`username`,e.username)},`,`token=${t.print(`token`,e.token)},`),{imports:n,code:`fs = GithubFileSystem(\n${r.map(e=>` ${e}`).join(`
165
- `)}\n)`}}function Vn(e,t){An.parse(e);let n=new Mn,r;switch(e.type){case`s3`:r=Pn(e,n);break;case`gcs`:r=Fn(e,n);break;case`azure`:r=In(e,n);break;case`coreweave`:r=Ln(e,n);break;case`gdrive`:r=Rn(e,{secrets:n,isEmbedded:t.isEmbedded});break;case`huggingface`:r=zn(e,n);break;case`github`:r=Bn(e,n);break;default:D(e)}let i=[...new Set([...n.imports,...r.imports])].toSorted();i.push(``);let a=n.formatSecrets();return a&&i.push(a),i.push(r.code.trim()),i.join(`
166
- `)}var Hn=`#232F3E`,Un=[{name:`Amazon S3`,schema:Sn,protocol:`s3`,storageLibraries:{libraries:[`obstore`],preferred:`obstore`}},{name:`Google Cloud Storage`,schema:Cn,protocol:`gcs`,storageLibraries:{libraries:[`obstore`],preferred:`obstore`}},{name:`Azure Blob Storage`,schema:wn,protocol:`azure`,storageLibraries:{libraries:[`obstore`],preferred:`obstore`}},{name:`CoreWeave`,schema:Tn,protocol:`coreweave`,storageLibraries:{libraries:[`obstore`],preferred:`obstore`}},{name:`Google Drive`,schema:En,protocol:`gdrive`,storageLibraries:{libraries:[`fsspec`],preferred:`fsspec`}},{name:`Hugging Face Hub`,schema:Dn,protocol:`hf`,storageLibraries:{libraries:[`huggingface_hub`],preferred:`huggingface_hub`}},{name:`GitHub`,schema:kn,protocol:`github`,storageLibraries:{libraries:[`fsspec`],preferred:`fsspec`}}],Wn=e=>{let t=(0,L.c)(4),{onSelect:n}=e,r;t[0]===n?r=t[1]:(r=Un.map(e=>{let{name:t,schema:r,protocol:i}=e;return(0,z.jsx)(V,{name:t,color:Hn,icon:(0,z.jsx)(he,{protocol:i,forceDark:!0,className:`w-7.5 h-7.5 text-white`}),onSelect:()=>n(r)},t)}),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,z.jsx)(B,{children:r}),t[2]=r,t[3]=i),i},Gn=e=>{let t=(0,L.c)(16),{onSubmit:n,header:r}=e,{isEmbedded:i}=Ne(),[a,o]=(0,R.useState)(null);if(!a){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(`div`,{children:(0,z.jsx)(Wn,{onSelect:o})}),t[0]=e):e=t[0];let n;return t[1]===r?n=t[2]:(n=(0,z.jsxs)(z.Fragment,{children:[r,e]}),t[1]=r,t[2]=n),n}let s;t[3]===a?s=t[4]:(s=Un.find(e=>e.schema===a),t[3]=a,t[4]=s);let c=s?.storageLibraries,l;t[5]===c?.libraries?l=t[6]:(l=c?.libraries??[],t[5]=c?.libraries,t[6]=l);let u=c?.preferred??`obstore`,d;t[7]===i?d=t[8]:(d=(e,t)=>Vn(e,{library:t,isEmbedded:i}),t[7]=i,t[8]=d);let f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>o(null),t[9]=f):f=t[9];let p;return t[10]!==n||t[11]!==a||t[12]!==l||t[13]!==u||t[14]!==d?(p=(0,z.jsx)(ht,{schema:a,libraries:l,preferredLibrary:u,displayNames:jn,libraryLabel:`Preferred storage library`,generateCode:d,onSubmit:n,onBack:f}),t[10]=n,t[11]=a,t[12]=l,t[13]=u,t[14]=d,t[15]=p):p=t[15],p},Kn=e=>{let t=(0,L.c)(9),{children:n,defaultTab:r}=e,i=r===void 0?`databases`:r,[a,o]=(0,R.useState)(!1),s;t[0]===n?s=t[1]:(s=(0,z.jsx)(Oe,{asChild:!0,children:n}),t[0]=n,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>o(!1),t[2]=c):c=t[2];let l;t[3]===i?l=t[4]:(l=(0,z.jsx)(qn,{defaultTab:i,onClose:c}),t[3]=i,t[4]=l);let u;return t[5]!==a||t[6]!==s||t[7]!==l?(u=(0,z.jsxs)(je,{open:a,onOpenChange:o,children:[s,l]}),t[5]=a,t[6]=s,t[7]=l,t[8]=u):u=t[8],u},qn=e=>{let t=(0,L.c)(24),{defaultTab:n,onClose:r}=e,[i,a]=(0,R.useState)(n===void 0?`databases`:n),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsxs)(te,{className:`w-full mb-4`,children:[(0,z.jsx)(w,{value:`databases`,className:`flex-1`,children:`Databases & Catalogs`}),(0,z.jsx)(w,{value:`storage`,className:`flex-1`,children:`Remote Storages`})]}),t[0]=o):o=t[0];let s=o,c;t[1]===i?c=t[2]:(c=i===`databases`?(0,z.jsxs)(z.Fragment,{children:[`Don't see your database or connection method? A`,` `,(0,z.jsx)(A,{href:`https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database`,children:`code snippet`}),` `,`is all you need.`]}):(0,z.jsxs)(z.Fragment,{children:[`Don't see your storage or connection method? A`,` `,(0,z.jsx)(A,{href:`https://docs.marimo.io/guides/working_with_data/remote_storage/#creating-a-storage-connection`,children:`code snippet`}),` `,`is all you need.`]}),t[1]=i,t[2]=c);let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(De,{children:`Add Connection`}),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,z.jsx)(A,{href:`https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database`,children:`database, data catalog`}),t[4]=d):d=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(A,{href:`https://docs.marimo.io/guides/working_with_data/remote_storage/`,children:`remote storage`}),t[5]=f):f=t[5];let p;t[6]===l?p=t[7]:(p=(0,z.jsxs)(Ee,{children:[u,(0,z.jsxs)(Ae,{children:[`Connect to a`,` `,d,` `,`or`,` `,f,` `,`directly from your notebook.`,(0,z.jsx)(`span`,{className:`block`,children:l})]})]}),t[6]=l,t[7]=p);let m=i===`storage`?`storage`:`database`,h;t[8]!==r||t[9]!==m?(h=(0,z.jsx)(yn,{onSubmit:r,className:`-mt-2`,group:m}),t[8]=r,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>a(e),t[11]=g):g=t[11];let _;t[12]===r?_=t[13]:(_=(0,z.jsx)(E,{value:`databases`,className:`mt-0 focus-visible:ring-0 focus-visible:ring-offset-0`,children:(0,z.jsx)(un,{onSubmit:r,header:s})}),t[12]=r,t[13]=_);let v;t[14]===r?v=t[15]:(v=(0,z.jsx)(E,{value:`storage`,className:`mt-0 focus-visible:ring-0 focus-visible:ring-offset-0`,children:(0,z.jsx)(Gn,{onSubmit:r,header:s})}),t[14]=r,t[15]=v);let y;t[16]!==i||t[17]!==_||t[18]!==v?(y=(0,z.jsxs)(C,{value:i,onValueChange:g,children:[_,v]}),t[16]=i,t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;return t[20]!==y||t[21]!==p||t[22]!==h?(b=(0,z.jsxs)(ke,{className:`max-h-[75vh] overflow-y-auto`,children:[p,h,y]}),t[20]=y,t[21]=p,t[22]=h,t[23]=b):b=t[23],b};export{qn as n,pn as r,Kn as t};