@marimo-team/frontend 0.25.3-dev95 → 0.25.3-dev96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CellStatus-CplYFNTy.js → CellStatus-Dc8AR1al.js} +1 -1
- package/dist/assets/{ErrorBoundary-CdGuz4a_.js → ErrorBoundary-DBQW23V4.js} +2 -2
- package/dist/assets/{JsonOutput-Csbov8Fx.js → JsonOutput-nLzWQ-0V.js} +1 -1
- package/dist/assets/{MarimoErrorOutput-czclLlOn.js → MarimoErrorOutput-DAFgeK_G.js} +1 -1
- package/dist/assets/{RenderHTML-CNDedpS4.js → RenderHTML-DwolbpuI.js} +1 -1
- package/dist/assets/{RunButton-CRfdOxVd.js → RunButton-BN3_mnoU.js} +1 -1
- package/dist/assets/{add-cell-with-ai-BAIX7r0P.js → add-cell-with-ai-CRbG5cTT.js} +2 -2
- package/dist/assets/{add-connection-dialog-DrDuM-tI.js → add-connection-dialog-CzCmVM_b.js} +1 -1
- package/dist/assets/{agent-panel-CoXq_rlA.js → agent-panel-zpTxANfi.js} +1 -1
- package/dist/assets/{ai-model-dropdown-COvWn46z.js → ai-model-dropdown-DL56ImUU.js} +2 -2
- package/dist/assets/{app-config-button-CtxoYG4F.js → app-config-button-BRBtaFi_.js} +1 -1
- package/dist/assets/{blob-DCjrjZKW.js → blob-CuL-H1JC.js} +1 -1
- package/dist/assets/{cache-panel-CbWZcBu0.js → cache-panel-BV-c7ed0.js} +1 -1
- package/dist/assets/{cell-editor-BnL0Sorl.js → cell-editor-C6QIY1Q-.js} +2 -2
- package/dist/assets/{cell-link-BFbgKiRH.js → cell-link-C9tkvy6x.js} +1 -1
- package/dist/assets/{cells-yOs72eZm.js → cells-B23_t5uX.js} +1 -1
- package/dist/assets/{chat-display-DwRM41t_.js → chat-display-DSezZ1qo.js} +1 -1
- package/dist/assets/{chat-panel-DeTEdjxF.js → chat-panel-CocbwA2Q.js} +2 -2
- package/dist/assets/{chat-ui-D6XucD07.js → chat-ui-DXvDBccG.js} +2 -2
- package/dist/assets/column-preview-BUQ_YMaE.js +1 -0
- package/dist/assets/{command-palette-CA6yfNLb.js → command-palette-HbIlNTLD.js} +1 -1
- package/dist/assets/{common-B-ZYnO1x.js → common-XXWicvmo.js} +1 -1
- package/dist/assets/{components-vu2jLG08.js → components-D1a5GeNf.js} +1 -1
- package/dist/assets/{datasource-BakEOWsf.js → datasource-Qo_t5PqI.js} +1 -1
- package/dist/assets/{dependency-graph-panel-DCGB3_id.js → dependency-graph-panel-DHrm4LUL.js} +2 -2
- package/dist/assets/{documentation-panel-CpGZ2Dfn.js → documentation-panel-BoNI3vXT.js} +1 -1
- package/dist/assets/{download-CV1k4XQ4.js → download-Cm3InGht.js} +1 -1
- package/dist/assets/{edit-page-By7n2M84.js → edit-page-BVkC2MyU.js} +6 -6
- package/dist/assets/{error-entries-JgrZYMbe.js → error-entries-DEkB-8EY.js} +1 -1
- package/dist/assets/{error-panel-DS7HWph-.js → error-panel-D7GInT--.js} +1 -1
- package/dist/assets/feedback-button-Cz9BdS49.js +1 -0
- package/dist/assets/{feedback-button-eYsTCK-g.js → feedback-button-sC38i-D1.js} +1 -1
- package/dist/assets/{file-explorer-panel-BTLwwwD4.js → file-explorer-panel-2XFMubVM.js} +1 -1
- package/dist/assets/{file-name-input-BaR4h2Ud.js → file-name-input-DPs3KKM-.js} +1 -1
- package/dist/assets/{floating-outline-Drd73Quo.js → floating-outline-C7MSAu6q.js} +1 -1
- package/dist/assets/{gallery-page-DXUD11Rm.js → gallery-page-B3fJlerH.js} +1 -1
- package/dist/assets/{glide-data-editor-DqBBoQBl.js → glide-data-editor-DrhzXms_.js} +1 -1
- package/dist/assets/{home-page-pgFFsmga.js → home-page-CajAhF9Q.js} +1 -1
- package/dist/assets/{hooks-D25kP4Sr.js → hooks-DteA-neM.js} +1 -1
- package/dist/assets/{index-DNG4qQ-E.js → index-YQHSwyF3.js} +6 -6
- package/dist/assets/{layout-DLHIGZTK.js → layout-DEFRD3k3.js} +3 -3
- package/dist/assets/{logs-panel-D5AAD2s9.js → logs-panel-BpM3pLdf.js} +1 -1
- package/dist/assets/{markdown-renderer--CwVm4kJ.js → markdown-renderer-C5aIPuRT.js} +1 -1
- package/dist/assets/{name-cell-input-BFKZaNI5.js → name-cell-input-Dd8oSXnd.js} +1 -1
- package/dist/assets/{outline-panel-qcwRnl0R.js → outline-panel-kFr3Fo2d.js} +1 -1
- package/dist/assets/{packages-panel-DnSryNcz.js → packages-panel-Ce_wBuIJ.js} +1 -1
- package/dist/assets/{panel-accordion-state-BwJpDMVt.js → panel-accordion-state-BO2rN4A5.js} +1 -1
- package/dist/assets/{panels-Aqzwb3UR.js → panels-Cy18qaTN.js} +1 -1
- package/dist/assets/{process-output-DuUfHYSr.js → process-output-CDhnnF3f.js} +1 -1
- package/dist/assets/{readonly-code-display-BY-9I_Yk.js → readonly-code-display-ChOK6mhE.js} +1 -1
- package/dist/assets/{readonly-python-code-DSyr-yE2.js → readonly-python-code-CVwB1OHZ.js} +1 -1
- package/dist/assets/{reveal-component-C_Lb7Mom.js → reveal-component-DE-4w0ik.js} +1 -1
- package/dist/assets/{run-page-ZTw-kCU-.js → run-page-C6qwGqj6.js} +1 -1
- package/dist/assets/{runtime-details-state-B7gpnuXx.js → runtime-details-state-BRSVs8um.js} +1 -1
- package/dist/assets/{scratchpad-panel-D2IHkKoG.js → scratchpad-panel--SxH2dnk.js} +1 -1
- package/dist/assets/session-panel-B0CkZ3wl.js +1 -0
- package/dist/assets/{snippets-panel-BNadUJLU.js → snippets-panel-CN-U1niV.js} +1 -1
- package/dist/assets/{state-BaYudep3.js → state-BRL89qqy.js} +1 -1
- package/dist/assets/{state-_1LTGJQM.js → state-BoRCcWOg.js} +1 -1
- package/dist/assets/{tracing-DbTgS4u9.js → tracing-CqxmObxN.js} +1 -1
- package/dist/assets/{tracing-panel-CjlrpXPy.js → tracing-panel-Bn8xJSPi.js} +2 -2
- package/dist/assets/{tree-actions-C_KYlaSv.js → tree-actions-DoPCJTpj.js} +1 -1
- package/dist/assets/{useAddCell-C0J8quGE.js → useAddCell-DKb7o70l.js} +1 -1
- package/dist/assets/{useCellActionButton-CbkOj6BE.js → useCellActionButton-CSNFulkR.js} +1 -1
- package/dist/assets/{useDeleteCell-DHkF5wgS.js → useDeleteCell-BPQ6Xcbj.js} +1 -1
- package/dist/assets/{useDependencyPanelTab--yXJW6X5.js → useDependencyPanelTab-4SMlwjEg.js} +1 -1
- package/dist/assets/{useNotebookActions-dJQalORg.js → useNotebookActions-B4kq9-P4.js} +1 -1
- package/dist/assets/{useRunCells-C_IwVJR_.js → useRunCells-BV6nl_Ok.js} +1 -1
- package/dist/assets/{useSplitCell-Ci4MEUj8.js → useSplitCell-Ca364Rrx.js} +1 -1
- package/dist/index.html +20 -20
- package/package.json +1 -1
- package/src/components/app-config/ai-config.tsx +1 -0
- package/src/components/chat/chat-components.tsx +2 -0
- package/src/components/chat/chat-panel.tsx +6 -1
- package/src/components/data-table/__tests__/column-explorer.test.tsx +27 -1
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +1 -1
- package/src/components/datasources/__tests__/column-actions.test.tsx +97 -0
- package/src/components/datasources/__tests__/column-preview.test.tsx +63 -2
- package/src/components/datasources/column-preview.tsx +8 -2
- package/src/components/datasources/datasources.tsx +12 -14
- package/src/components/debugger/debugger-code.tsx +5 -0
- package/src/components/dependency-graph/panels.tsx +2 -1
- package/src/components/editor/ai/ai-completion-editor.tsx +1 -0
- package/src/components/editor/alerts/startup-logs-alert.tsx +1 -0
- package/src/components/editor/cell/DeleteButton.tsx +1 -0
- package/src/components/editor/chrome/panels/cache-panel.tsx +1 -0
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +58 -1
- package/src/components/editor/chrome/wrapper/pending-ai-cells.tsx +12 -2
- package/src/components/editor/notebook-banner.tsx +1 -0
- package/src/components/editor/package-alert.tsx +2 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/toggle.tsx +7 -1
- package/src/components/mcp/mcp-status-indicator.tsx +1 -1
- package/src/components/slides/slide-form.tsx +1 -0
- package/src/core/codemirror/language/panel/panel.tsx +1 -0
- package/src/plugins/impl/RefreshPlugin.tsx +1 -0
- package/src/plugins/impl/chat/chat-ui.tsx +1 -0
- package/src/stories/button.stories.tsx +1 -0
- package/dist/assets/column-preview-DXM8SqGY.js +0 -1
- package/dist/assets/feedback-button-Dgs_HOOC.js +0 -1
- package/dist/assets/session-panel-cOSO3WCX.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t}from"./useEvent-BDjgaBtz.js";import{t as n}from"./react-DVplv7_D.js";import{$t as r,Bn as i,En as a,On as o,Xt as s,Yt as c,Zt as l,cn as u,dn as d,en as f,nn as p,tn as m,un as h}from"./cells-yOs72eZm.js";import{t as g}from"./compiler-runtime-BrajqUja.js";import{D as _,O as v,S as y}from"./config-DpY86_Yq.js";import{M as b}from"./config-CD1IuZFJ.js";import{t as x}from"./jsx-runtime-B74pBk57.js";import{o as S}from"./alert-dialog-C-sWmKva.js";import{l as C}from"./select-3CVGlYrC.js";import{c as w}from"./switch-DYjBfpNJ.js";import{t as T}from"./tooltip-CkGm8X7m.js";import{t as E}from"./button-D8gVKwe-.js";import{t as D}from"./createLucideIcon-DfJ2oMlA.js";import{d as O,f as k,i as A,k as j,n as M,u as N}from"./ai-model-dropdown-COvWn46z.js";import{r as P}from"./useNumberFormatter-D7O_26UI.js";import{b as F,p as I}from"./write-secret-modal-BEx-EUlh.js";import{Jt as L,Yt as R,nn as ee,r as z,tn as B}from"./input-DmHMEZGh.js";import{t as V}from"./settings-BpdQZRgT.js";import{t as te}from"./use-toast-Wu434mLr.js";import{s as H}from"./arrays-0R2reF2y.js";import{r as U}from"./requests-BIFR-h4M.js";import{r as ne}from"./useDebounce-DwTQ_1Pu.js";import{t as W}from"./kbd-pdKBv96t.js";import{t as G}from"./Inputs-BsQm29hD.js";var K=D(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),q=g(),J=x(),Y=e=>{let t=(0,q.c)(15),{description:n,disabled:r,tooltip:i}=e,a=r!==void 0&&r,o=i===void 0?`Shutdown`:i,{openConfirm:s,closeModal:c}=F(),{sendShutdown:l}=U(),u;t[0]===l?u=t[1]:(u=()=>{l(),setTimeout(X,200)},t[0]=l,t[1]=u);let d=u;if(b())return null;let f=a?`disabled`:`red`,p;t[2]!==c||t[3]!==n||t[4]!==d||t[5]!==s?(p=e=>{e.stopPropagation(),s({title:`Shutdown`,description:n,variant:`destructive`,confirmAction:(0,J.jsx)(S,{onClick:()=>{d(),c()},"aria-label":`Confirm Shutdown`,children:`Shutdown`})})},t[2]=c,t[3]=n,t[4]=d,t[5]=s,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,J.jsx)(P,{strokeWidth:1}),t[7]=m):m=t[7];let h;t[8]!==a||t[9]!==f||t[10]!==p?(h=(0,J.jsx)(G,{"aria-label":`Shutdown`,"data-testid":`shutdown-button`,shape:`circle`,size:`small`,color:f,className:`h-[27px] w-[27px]`,disabled:a,onClick:p,children:m}),t[8]=a,t[9]=f,t[10]=p,t[11]=h):h=t[11];let g;return t[12]!==h||t[13]!==o?(g=(0,J.jsx)(T,{content:o,children:h}),t[12]=h,t[13]=o,t[14]=g):g=t[14],g};function X(){window.close()}var Z=e(n(),1),re=100,ie=()=>{let e=(0,q.c)(37),[t,n]=y(),{saveAppConfig:u}=U(),d=(0,Z.useId)(),h=(0,Z.useId)(),g;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=a(_),e[0]=g):g=e[0];let v;e[1]===t?v=e[2]:(v={resolver:g,defaultValues:t},e[1]=t,e[2]=v);let b=o(v),x;e[3]!==u||e[4]!==n?(x=async e=>{await u({config:e}).then(()=>{n(e)}).catch(()=>{n(e)})},e[3]=u,e[4]=n,e[5]=x):x=e[5];let S=x,C;e[6]===S?C=e[7]:(C=e=>{S(e)},e[6]=S,e[7]=C);let w=ne(C,re),T;e[8]===t.width?T=e[9]:(T=[t.width],e[8]=t.width,e[9]=T),(0,Z.useEffect)(ae,T);let E;e[10]!==w||e[11]!==b?(E=b.handleSubmit(w),e[10]=w,e[11]=b,e[12]=E):E=e[12];let D;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,J.jsxs)(`div`,{children:[(0,J.jsx)(k,{children:`Notebook Settings`}),(0,J.jsx)(O,{children:`Configure how your notebook or application looks and behaves.`})]}),e[13]=D):D=e[13];let A;e[14]===b.control?A=e[15]:(A=(0,J.jsxs)(Q,{title:`Display`,children:[(0,J.jsx)(r,{control:b.control,name:`width`,render:se}),(0,J.jsx)(r,{control:b.control,name:`app_title`,render:$})]}),e[14]=b.control,e[15]=A);let j;e[16]===b.control?j=e[17]:(j=(0,J.jsxs)(Q,{title:`Custom Files`,children:[(0,J.jsx)(r,{control:b.control,name:`css_file`,render:ce}),(0,J.jsx)(r,{control:b.control,name:`html_head_file`,render:le})]}),e[16]=b.control,e[17]=j);let M;e[18]===b.control?M=e[19]:(M=(0,J.jsx)(Q,{title:`Data`,children:(0,J.jsx)(r,{control:b.control,name:`sql_output`,render:de})}),e[18]=b.control,e[19]=M);let N;e[20]!==d||e[21]!==h?(N=e=>{let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(s,{children:(0,J.jsxs)(`div`,{className:`flex gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(i,{id:d,"data-testid":`html-checkbox`,checked:t.value.includes(`html`),onCheckedChange:()=>{t.onChange(H(t.value,`html`))}}),(0,J.jsx)(m,{htmlFor:d,children:`HTML`})]}),(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(i,{id:h,"data-testid":`ipynb-checkbox`,checked:t.value.includes(`ipynb`),onCheckedChange:()=>{t.onChange(H(t.value,`ipynb`))}}),(0,J.jsx)(m,{htmlFor:h,children:`IPYNB`})]})]})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(l,{children:[`When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named`,` `,(0,J.jsx)(W,{className:`inline`,children:`__marimo__`}),` next to your notebook file.`]})]})},e[20]=d,e[21]=h,e[22]=N):N=e[22];let P;e[23]!==b.control||e[24]!==N?(P=(0,J.jsx)(Q,{title:`Exporting outputs`,children:(0,J.jsx)(r,{control:b.control,name:`auto_download`,render:N})}),e[23]=b.control,e[24]=N,e[25]=P):P=e[25];let F;e[26]!==P||e[27]!==A||e[28]!==j||e[29]!==M?(F=(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-8 gap-y-4`,children:[A,j,M,P]}),e[26]=P,e[27]=A,e[28]=j,e[29]=M,e[30]=F):F=e[30];let I;e[31]!==F||e[32]!==E?(I=(0,J.jsxs)(`form`,{onChange:E,className:`flex flex-col gap-6`,children:[D,F]}),e[31]=F,e[32]=E,e[33]=I):I=e[33];let L;return e[34]!==b||e[35]!==I?(L=(0,J.jsx)(c,{...b,children:I}),e[34]=b,e[35]=I,e[36]=L):L=e[36],L},Q=e=>{let t=(0,q.c)(5),{title:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,J.jsx)(`h3`,{className:`text-base font-semibold mb-1`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a};function ae(){window.dispatchEvent(new Event(`resize`))}function oe(e){return(0,J.jsx)(`option`,{value:e,children:e},e)}function se(e){let{field:t}=e;return(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{children:`Width`}),(0,J.jsx)(s,{children:(0,J.jsx)(C,{"data-testid":`app-width-select`,onChange:e=>t.onChange(e.target.value),value:t.value,disabled:t.disabled,className:`inline-flex mr-2`,children:j().map(oe)})}),(0,J.jsx)(p,{})]})}function $(e){let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{children:`App title`}),(0,J.jsx)(s,{children:(0,J.jsx)(z,{...t,value:t.value??``,onChange:e=>{t.onChange(e.target.value),v.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsx)(l,{children:`The application title is put in the title tag in the HTML code and typically displayed in the title bar of the browser window.`})]})}function ce(e){let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{className:`shrink-0`,children:`Custom CSS`}),(0,J.jsx)(s,{children:(0,J.jsx)(z,{...t,value:t.value??``,placeholder:`custom.css`,onChange:e=>{t.onChange(e.target.value),v.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsx)(l,{children:`A filepath to a custom css file to be injected into the notebook.`})]})}function le(e){let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{className:`shrink-0`,children:`HTML Head`}),(0,J.jsx)(s,{children:(0,J.jsx)(z,{...t,value:t.value??``,placeholder:`head.html`,onChange:e=>{t.onChange(e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(l,{children:[`A filepath to an HTML file to be injected into the`,` `,(0,J.jsx)(W,{className:`inline`,children:`<head/>`}),` section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts.`]})]})}function ue(e){return(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value)}function de(e){let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{children:`SQL Output Type`}),(0,J.jsx)(s,{children:(0,J.jsx)(C,{"data-testid":`sql-output-select`,onChange:e=>{t.onChange(e.target.value),te({title:`Kernel Restart Required`,description:`This change requires a kernel restart to take effect.`})},value:t.value,disabled:t.disabled,className:`inline-flex mr-2`,children:N.map(ue)})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(l,{children:[`The Python type returned by a SQL cell. For best performance with large datasets, we recommend using`,` `,(0,J.jsx)(W,{className:`inline`,children:`native`}),`. See the`,` `,(0,J.jsx)(I,{href:`https://docs.marimo.io/guides/working_with_data/sql`,children:`SQL guide`}),` `,`for more information.`]})]})}var fe=e=>{let n=(0,q.c)(32),{showAppConfig:r,disabled:i,tooltip:a}=e,o=r===void 0||r,s=i!==void 0&&i,c=a===void 0?`Settings`:a,[l,f]=t(M),p=s?`disabled`:`hint-green`,m;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,J.jsx)(V,{strokeWidth:1.8}),n[0]=m):m=n[0];let g;n[1]===c?g=n[2]:(g=(0,J.jsx)(T,{content:c,children:m}),n[1]=c,n[2]=g);let _;n[3]!==s||n[4]!==p||n[5]!==g?(_=(0,J.jsx)(G,{"aria-label":`Config`,"data-testid":`app-config-button`,shape:`circle`,size:`small`,className:`h-[27px] w-[27px]`,disabled:s,color:p,children:g}),n[3]=s,n[4]=p,n[5]=g,n[6]=_):_=n[6];let v=_,y;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,J.jsxs)(R,{className:`w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0`,children:[(0,J.jsx)(w,{children:(0,J.jsx)(B,{children:`User settings`})}),(0,J.jsx)(A,{})]}),n[7]=y):y=n[7];let b=y;if(!o){let e;n[8]===v?e=n[9]:(e=(0,J.jsx)(ee,{children:v}),n[8]=v,n[9]=e);let t;return n[10]!==f||n[11]!==l||n[12]!==e?(t=(0,J.jsxs)(L,{open:l,onOpenChange:f,children:[e,b]}),n[10]=f,n[11]=l,n[12]=e,n[13]=t):t=n[13],t}let x;n[14]===v?x=n[15]:(x=(0,J.jsx)(d,{asChild:!0,children:v}),n[14]=v,n[15]=x);let S,C;n[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,J.jsx)(ie,{}),C=(0,J.jsx)(`div`,{className:`h-px bg-border my-2`}),n[16]=S,n[17]=C):(S=n[16],C=n[17]);let D;n[18]===f?D=n[19]:(D=()=>f(!0),n[18]=f,n[19]=D);let O;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,J.jsx)(V,{strokeWidth:1.8,className:`w-4 h-4 mr-2`}),n[20]=O):O=n[20];let k;n[21]===D?k=n[22]:(k=(0,J.jsxs)(h,{className:`w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]`,align:`end`,side:`bottom`,onFocusOutside:pe,children:[S,C,(0,J.jsxs)(E,{onClick:D,variant:`link`,className:`px-0`,children:[O,`User settings`]})]}),n[21]=D,n[22]=k);let j;n[23]!==k||n[24]!==x?(j=(0,J.jsxs)(u,{children:[x,k]}),n[23]=k,n[24]=x,n[25]=j):j=n[25];let N;n[26]!==f||n[27]!==l?(N=(0,J.jsx)(L,{open:l,onOpenChange:f,children:b}),n[26]=f,n[27]=l,n[28]=N):N=n[28];let P;return n[29]!==j||n[30]!==N?(P=(0,J.jsxs)(J.Fragment,{children:[j,N]}),n[29]=j,n[30]=N,n[31]=P):P=n[31],P};function pe(e){return e.preventDefault()}export{Y as n,K as r,fe as t};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t}from"./useEvent-BDjgaBtz.js";import{t as n}from"./react-DVplv7_D.js";import{$t as r,Bn as i,En as a,On as o,Xt as s,Yt as c,Zt as l,cn as u,dn as d,en as f,nn as p,tn as m,un as h}from"./cells-B23_t5uX.js";import{t as g}from"./compiler-runtime-BrajqUja.js";import{D as _,O as v,S as y}from"./config-DpY86_Yq.js";import{M as b}from"./config-CD1IuZFJ.js";import{t as x}from"./jsx-runtime-B74pBk57.js";import{o as S}from"./alert-dialog-C-sWmKva.js";import{l as C}from"./select-3CVGlYrC.js";import{c as w}from"./switch-DYjBfpNJ.js";import{t as T}from"./tooltip-CkGm8X7m.js";import{t as E}from"./button-D8gVKwe-.js";import{t as D}from"./createLucideIcon-DfJ2oMlA.js";import{d as O,f as k,i as A,k as j,n as M,u as N}from"./ai-model-dropdown-DL56ImUU.js";import{r as P}from"./useNumberFormatter-D7O_26UI.js";import{b as F,p as I}from"./write-secret-modal-BEx-EUlh.js";import{Jt as L,Yt as R,nn as ee,r as z,tn as B}from"./input-DmHMEZGh.js";import{t as V}from"./settings-BpdQZRgT.js";import{t as te}from"./use-toast-Wu434mLr.js";import{s as H}from"./arrays-0R2reF2y.js";import{r as U}from"./requests-BIFR-h4M.js";import{r as ne}from"./useDebounce-DwTQ_1Pu.js";import{t as W}from"./kbd-pdKBv96t.js";import{t as G}from"./Inputs-BsQm29hD.js";var K=D(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),q=g(),J=x(),Y=e=>{let t=(0,q.c)(15),{description:n,disabled:r,tooltip:i}=e,a=r!==void 0&&r,o=i===void 0?`Shutdown`:i,{openConfirm:s,closeModal:c}=F(),{sendShutdown:l}=U(),u;t[0]===l?u=t[1]:(u=()=>{l(),setTimeout(X,200)},t[0]=l,t[1]=u);let d=u;if(b())return null;let f=a?`disabled`:`red`,p;t[2]!==c||t[3]!==n||t[4]!==d||t[5]!==s?(p=e=>{e.stopPropagation(),s({title:`Shutdown`,description:n,variant:`destructive`,confirmAction:(0,J.jsx)(S,{onClick:()=>{d(),c()},"aria-label":`Confirm Shutdown`,children:`Shutdown`})})},t[2]=c,t[3]=n,t[4]=d,t[5]=s,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,J.jsx)(P,{strokeWidth:1}),t[7]=m):m=t[7];let h;t[8]!==a||t[9]!==f||t[10]!==p?(h=(0,J.jsx)(G,{"aria-label":`Shutdown`,"data-testid":`shutdown-button`,shape:`circle`,size:`small`,color:f,className:`h-[27px] w-[27px]`,disabled:a,onClick:p,children:m}),t[8]=a,t[9]=f,t[10]=p,t[11]=h):h=t[11];let g;return t[12]!==h||t[13]!==o?(g=(0,J.jsx)(T,{content:o,children:h}),t[12]=h,t[13]=o,t[14]=g):g=t[14],g};function X(){window.close()}var Z=e(n(),1),re=100,ie=()=>{let e=(0,q.c)(37),[t,n]=y(),{saveAppConfig:u}=U(),d=(0,Z.useId)(),h=(0,Z.useId)(),g;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=a(_),e[0]=g):g=e[0];let v;e[1]===t?v=e[2]:(v={resolver:g,defaultValues:t},e[1]=t,e[2]=v);let b=o(v),x;e[3]!==u||e[4]!==n?(x=async e=>{await u({config:e}).then(()=>{n(e)}).catch(()=>{n(e)})},e[3]=u,e[4]=n,e[5]=x):x=e[5];let S=x,C;e[6]===S?C=e[7]:(C=e=>{S(e)},e[6]=S,e[7]=C);let w=ne(C,re),T;e[8]===t.width?T=e[9]:(T=[t.width],e[8]=t.width,e[9]=T),(0,Z.useEffect)(ae,T);let E;e[10]!==w||e[11]!==b?(E=b.handleSubmit(w),e[10]=w,e[11]=b,e[12]=E):E=e[12];let D;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,J.jsxs)(`div`,{children:[(0,J.jsx)(k,{children:`Notebook Settings`}),(0,J.jsx)(O,{children:`Configure how your notebook or application looks and behaves.`})]}),e[13]=D):D=e[13];let A;e[14]===b.control?A=e[15]:(A=(0,J.jsxs)(Q,{title:`Display`,children:[(0,J.jsx)(r,{control:b.control,name:`width`,render:se}),(0,J.jsx)(r,{control:b.control,name:`app_title`,render:$})]}),e[14]=b.control,e[15]=A);let j;e[16]===b.control?j=e[17]:(j=(0,J.jsxs)(Q,{title:`Custom Files`,children:[(0,J.jsx)(r,{control:b.control,name:`css_file`,render:ce}),(0,J.jsx)(r,{control:b.control,name:`html_head_file`,render:le})]}),e[16]=b.control,e[17]=j);let M;e[18]===b.control?M=e[19]:(M=(0,J.jsx)(Q,{title:`Data`,children:(0,J.jsx)(r,{control:b.control,name:`sql_output`,render:de})}),e[18]=b.control,e[19]=M);let N;e[20]!==d||e[21]!==h?(N=e=>{let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(s,{children:(0,J.jsxs)(`div`,{className:`flex gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(i,{id:d,"data-testid":`html-checkbox`,checked:t.value.includes(`html`),onCheckedChange:()=>{t.onChange(H(t.value,`html`))}}),(0,J.jsx)(m,{htmlFor:d,children:`HTML`})]}),(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(i,{id:h,"data-testid":`ipynb-checkbox`,checked:t.value.includes(`ipynb`),onCheckedChange:()=>{t.onChange(H(t.value,`ipynb`))}}),(0,J.jsx)(m,{htmlFor:h,children:`IPYNB`})]})]})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(l,{children:[`When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named`,` `,(0,J.jsx)(W,{className:`inline`,children:`__marimo__`}),` next to your notebook file.`]})]})},e[20]=d,e[21]=h,e[22]=N):N=e[22];let P;e[23]!==b.control||e[24]!==N?(P=(0,J.jsx)(Q,{title:`Exporting outputs`,children:(0,J.jsx)(r,{control:b.control,name:`auto_download`,render:N})}),e[23]=b.control,e[24]=N,e[25]=P):P=e[25];let F;e[26]!==P||e[27]!==A||e[28]!==j||e[29]!==M?(F=(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-8 gap-y-4`,children:[A,j,M,P]}),e[26]=P,e[27]=A,e[28]=j,e[29]=M,e[30]=F):F=e[30];let I;e[31]!==F||e[32]!==E?(I=(0,J.jsxs)(`form`,{onChange:E,className:`flex flex-col gap-6`,children:[D,F]}),e[31]=F,e[32]=E,e[33]=I):I=e[33];let L;return e[34]!==b||e[35]!==I?(L=(0,J.jsx)(c,{...b,children:I}),e[34]=b,e[35]=I,e[36]=L):L=e[36],L},Q=e=>{let t=(0,q.c)(5),{title:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,J.jsx)(`h3`,{className:`text-base font-semibold mb-1`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a};function ae(){window.dispatchEvent(new Event(`resize`))}function oe(e){return(0,J.jsx)(`option`,{value:e,children:e},e)}function se(e){let{field:t}=e;return(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{children:`Width`}),(0,J.jsx)(s,{children:(0,J.jsx)(C,{"data-testid":`app-width-select`,onChange:e=>t.onChange(e.target.value),value:t.value,disabled:t.disabled,className:`inline-flex mr-2`,children:j().map(oe)})}),(0,J.jsx)(p,{})]})}function $(e){let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{children:`App title`}),(0,J.jsx)(s,{children:(0,J.jsx)(z,{...t,value:t.value??``,onChange:e=>{t.onChange(e.target.value),v.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsx)(l,{children:`The application title is put in the title tag in the HTML code and typically displayed in the title bar of the browser window.`})]})}function ce(e){let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{className:`shrink-0`,children:`Custom CSS`}),(0,J.jsx)(s,{children:(0,J.jsx)(z,{...t,value:t.value??``,placeholder:`custom.css`,onChange:e=>{t.onChange(e.target.value),v.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsx)(l,{children:`A filepath to a custom css file to be injected into the notebook.`})]})}function le(e){let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{className:`shrink-0`,children:`HTML Head`}),(0,J.jsx)(s,{children:(0,J.jsx)(z,{...t,value:t.value??``,placeholder:`head.html`,onChange:e=>{t.onChange(e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(l,{children:[`A filepath to an HTML file to be injected into the`,` `,(0,J.jsx)(W,{className:`inline`,children:`<head/>`}),` section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts.`]})]})}function ue(e){return(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value)}function de(e){let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(f,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(m,{children:`SQL Output Type`}),(0,J.jsx)(s,{children:(0,J.jsx)(C,{"data-testid":`sql-output-select`,onChange:e=>{t.onChange(e.target.value),te({title:`Kernel Restart Required`,description:`This change requires a kernel restart to take effect.`})},value:t.value,disabled:t.disabled,className:`inline-flex mr-2`,children:N.map(ue)})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(l,{children:[`The Python type returned by a SQL cell. For best performance with large datasets, we recommend using`,` `,(0,J.jsx)(W,{className:`inline`,children:`native`}),`. See the`,` `,(0,J.jsx)(I,{href:`https://docs.marimo.io/guides/working_with_data/sql`,children:`SQL guide`}),` `,`for more information.`]})]})}var fe=e=>{let n=(0,q.c)(32),{showAppConfig:r,disabled:i,tooltip:a}=e,o=r===void 0||r,s=i!==void 0&&i,c=a===void 0?`Settings`:a,[l,f]=t(M),p=s?`disabled`:`hint-green`,m;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,J.jsx)(V,{strokeWidth:1.8}),n[0]=m):m=n[0];let g;n[1]===c?g=n[2]:(g=(0,J.jsx)(T,{content:c,children:m}),n[1]=c,n[2]=g);let _;n[3]!==s||n[4]!==p||n[5]!==g?(_=(0,J.jsx)(G,{"aria-label":`Config`,"data-testid":`app-config-button`,shape:`circle`,size:`small`,className:`h-[27px] w-[27px]`,disabled:s,color:p,children:g}),n[3]=s,n[4]=p,n[5]=g,n[6]=_):_=n[6];let v=_,y;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,J.jsxs)(R,{className:`w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0`,children:[(0,J.jsx)(w,{children:(0,J.jsx)(B,{children:`User settings`})}),(0,J.jsx)(A,{})]}),n[7]=y):y=n[7];let b=y;if(!o){let e;n[8]===v?e=n[9]:(e=(0,J.jsx)(ee,{children:v}),n[8]=v,n[9]=e);let t;return n[10]!==f||n[11]!==l||n[12]!==e?(t=(0,J.jsxs)(L,{open:l,onOpenChange:f,children:[e,b]}),n[10]=f,n[11]=l,n[12]=e,n[13]=t):t=n[13],t}let x;n[14]===v?x=n[15]:(x=(0,J.jsx)(d,{asChild:!0,children:v}),n[14]=v,n[15]=x);let S,C;n[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,J.jsx)(ie,{}),C=(0,J.jsx)(`div`,{className:`h-px bg-border my-2`}),n[16]=S,n[17]=C):(S=n[16],C=n[17]);let D;n[18]===f?D=n[19]:(D=()=>f(!0),n[18]=f,n[19]=D);let O;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,J.jsx)(V,{strokeWidth:1.8,className:`w-4 h-4 mr-2`}),n[20]=O):O=n[20];let k;n[21]===D?k=n[22]:(k=(0,J.jsxs)(h,{className:`w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]`,align:`end`,side:`bottom`,onFocusOutside:pe,children:[S,C,(0,J.jsxs)(E,{onClick:D,variant:`link`,className:`px-0`,children:[O,`User settings`]})]}),n[21]=D,n[22]=k);let j;n[23]!==k||n[24]!==x?(j=(0,J.jsxs)(u,{children:[x,k]}),n[23]=k,n[24]=x,n[25]=j):j=n[25];let N;n[26]!==f||n[27]!==l?(N=(0,J.jsx)(L,{open:l,onOpenChange:f,children:b}),n[26]=f,n[27]=l,n[28]=N):N=n[28];let P;return n[29]!==j||n[30]!==N?(P=(0,J.jsxs)(J.Fragment,{children:[j,N]}),n[29]=j,n[30]=N,n[31]=P):P=n[31],P};function pe(e){return e.preventDefault()}export{Y as n,K as r,fe as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./markdown-renderer
|
|
1
|
+
import{a as e}from"./markdown-renderer-C5aIPuRT.js";function t(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>{n(Error(`Failed to read blob: ${e.type}`))},r.readAsDataURL(e)})}function n(e){let[t,n]=e.split(`,`,2),r=/^data:(.+);base64$/.exec(t)?.[1],i=atob(n),a=i.length,o=new Uint8Array(a);for(let e=0;e<a;e++)o[e]=i.charCodeAt(e);return new Blob([o],{type:r})}function r({contents:t,mimeType:r,isBase64:i}){return i?n(e(t,r)):new Blob([t],{type:r})}export{r as n,t as r,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t}from"./useEvent-BDjgaBtz.js";import{t as n}from"./react-DVplv7_D.js";import{t as r}from"./compiler-runtime-BrajqUja.js";import{t as i}from"./cn-ldLVeaqm.js";import{t as a}from"./jsx-runtime-B74pBk57.js";import{a as o,c as s,i as c,l,n as u,o as d,r as f,s as p,t as m,u as h}from"./alert-dialog-C-sWmKva.js";import{t as g}from"./button-D8gVKwe-.js";import{t as _}from"./database-zap-B_PMVg8T.js";import{t as v}from"./spinner-DyNE-o8o.js";import{t as y}from"./refresh-cw-Qw1f8Jhy.js";import{t as b}from"./trash-2-DcgaW8fn.js";import{t as x}from"./use-toast-Wu434mLr.js";import{r as S}from"./requests-BIFR-h4M.js";import{t as C}from"./I18nProvider-Cg2I_s1_.js";import{i as w}from"./numbers-CsZVw3Dc.js";import{n as T}from"./useAsyncData-qvoPYHtx.js";import{t as E}from"./empty-state-BaCKb7o3.js";import{t as D}from"./requests-DuLJN9Tf.js";import{n as O,t as k}from"./formatting-uom1es4b.js";var A=r(),j=e(n(),1),M=a(),N=e=>{let t=(0,A.c)(27),{children:n,title:r,description:i,onConfirm:a,confirmText:g,cancelText:_,destructive:v}=e,y=g===void 0?`Continue`:g,b=_===void 0?`Cancel`:_,x=v!==void 0&&v,[S,C]=j.useState(!1),w;t[0]===a?w=t[1]:(w=()=>{a(),C(!1)},t[0]=a,t[1]=w);let T=w,E=x?d:u,D;t[2]===n?D=t[3]:(D=(0,M.jsx)(h,{asChild:!0,children:n}),t[2]=n,t[3]=D);let O;t[4]===r?O=t[5]:(O=(0,M.jsx)(l,{children:r}),t[4]=r,t[5]=O);let k;t[6]===i?k=t[7]:(k=(0,M.jsx)(o,{children:i}),t[6]=i,t[7]=k);let N;t[8]!==O||t[9]!==k?(N=(0,M.jsxs)(s,{children:[O,k]}),t[8]=O,t[9]=k,t[10]=N):N=t[10];let P;t[11]===b?P=t[12]:(P=(0,M.jsx)(f,{children:b}),t[11]=b,t[12]=P);let F;t[13]!==E||t[14]!==y||t[15]!==T?(F=(0,M.jsx)(E,{onClick:T,children:y}),t[13]=E,t[14]=y,t[15]=T,t[16]=F):F=t[16];let I;t[17]!==F||t[18]!==P?(I=(0,M.jsxs)(p,{children:[P,F]}),t[17]=F,t[18]=P,t[19]=I):I=t[19];let L;t[20]!==I||t[21]!==N?(L=(0,M.jsxs)(c,{children:[N,I]}),t[20]=I,t[21]=N,t[22]=L):L=t[22];let R;return t[23]!==S||t[24]!==L||t[25]!==D?(R=(0,M.jsxs)(m,{open:S,onOpenChange:C,children:[D,L]}),t[23]=S,t[24]=L,t[25]=D,t[26]=R):R=t[26],R},P=()=>{let{clearCache:e,getCacheInfo:n}=S(),r=t(D),[a,o]=(0,j.useState)(!1),{locale:s}=C(),{isPending:c,isFetching:l,refetch:u}=T(async()=>{await n(),await new Promise(e=>setTimeout(e,500))},[]),d=async()=>{try{o(!0),await e(),x({title:`Cache purged`,description:`All cached data has been cleared`}),u()}catch(e){x({title:`Error`,description:e instanceof Error?e.message:`Failed to purge cache`,variant:`danger`})}finally{o(!1)}};if(c&&!r)return(0,M.jsx)(v,{size:`medium`,centered:!0});let f=(0,M.jsxs)(g,{variant:`outline`,size:`sm`,onClick:u,disabled:l,children:[l?(0,M.jsx)(v,{size:`small`,className:`w-4 h-4 mr-2`}):(0,M.jsx)(y,{className:`w-4 h-4 mr-2`}),`Refresh`]});if(!r)return(0,M.jsx)(E,{title:`No cache data`,description:`Cache information is not available.`,icon:(0,M.jsx)(_,{}),action:f});let p=r.hits,m=r.misses,h=r.time,A=r.disk_total,P=r.disk_to_free,I=p+m,L=I>0?p/I*100:0;return I===0?(0,M.jsx)(E,{title:`No cache activity`,description:`The cache has not been used yet. Cached functions will appear here once they are executed.`,icon:(0,M.jsx)(_,{}),action:f}):(0,M.jsx)(`div`,{className:`flex flex-col h-full overflow-auto`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 h-full`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,M.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:u,disabled:l,children:(0,M.jsx)(y,{className:i(`h-4 w-4 text-muted-foreground hover:text-foreground`,l&&`animate-[spin_0.5s]`)})})}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Statistics`}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,M.jsx)(F,{label:`Time saved`,value:O(h,s),description:`Total execution time saved`}),(0,M.jsx)(F,{label:`Hit rate`,value:I>0?`${w(L,s)}%`:`—`,description:`${w(p,s)} hits / ${w(I,s)} total`}),(0,M.jsx)(F,{label:`Cache hits`,value:w(p,s),description:`Successful cache retrievals`}),(0,M.jsx)(F,{label:`Cache misses`,value:w(m,s),description:`Cache not found`})]})]}),A>0&&(0,M.jsxs)(`div`,{className:`space-y-3 pt-2 border-t`,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Storage`}),(0,M.jsx)(`div`,{className:`grid grid-cols-1 gap-3`,children:(0,M.jsx)(F,{label:`Disk usage`,value:k(A,s),description:P>0?`${k(P,s)} can be freed`:`Cache storage on disk`})})]}),(0,M.jsx)(`div`,{className:`my-auto`}),(0,M.jsx)(`div`,{className:`pt-2 border-t`,children:(0,M.jsx)(N,{title:`Purge cache?`,description:`This will permanently delete all cached data. This action cannot be undone.`,confirmText:`Purge`,destructive:!0,onConfirm:d,children:(0,M.jsxs)(g,{variant:`outlineDestructive`,size:`xs`,disabled:a,className:`w-full`,children:[a?(0,M.jsx)(v,{size:`small`,className:`w-3 h-3 mr-2`}):(0,M.jsx)(b,{className:`w-3 h-3 mr-2`}),`Purge Cache`]})})})]})})},F=e=>{let t=(0,A.c)(10),{label:n,value:r,description:i}=e,a;t[0]===n?a=t[1]:(a=(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,M.jsx)(`span`,{className:`text-lg font-semibold`,children:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i&&(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 rounded-lg border bg-card`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c};export{P as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t}from"./useEvent-BDjgaBtz.js";import{t as n}from"./react-DVplv7_D.js";import{t as r}from"./compiler-runtime-BrajqUja.js";import{t as i}from"./cn-ldLVeaqm.js";import{t as a}from"./jsx-runtime-B74pBk57.js";import{a as o,c as s,i as c,l,n as u,o as d,r as f,s as p,t as m,u as h}from"./alert-dialog-C-sWmKva.js";import{t as g}from"./button-D8gVKwe-.js";import{t as _}from"./database-zap-B_PMVg8T.js";import{t as v}from"./spinner-DyNE-o8o.js";import{t as y}from"./refresh-cw-Qw1f8Jhy.js";import{t as b}from"./trash-2-DcgaW8fn.js";import{t as x}from"./use-toast-Wu434mLr.js";import{r as S}from"./requests-BIFR-h4M.js";import{t as C}from"./I18nProvider-Cg2I_s1_.js";import{i as w}from"./numbers-CsZVw3Dc.js";import{n as T}from"./useAsyncData-qvoPYHtx.js";import{t as E}from"./empty-state-BaCKb7o3.js";import{t as D}from"./requests-DuLJN9Tf.js";import{n as O,t as k}from"./formatting-uom1es4b.js";var A=r(),j=e(n(),1),M=a(),N=e=>{let t=(0,A.c)(27),{children:n,title:r,description:i,onConfirm:a,confirmText:g,cancelText:_,destructive:v}=e,y=g===void 0?`Continue`:g,b=_===void 0?`Cancel`:_,x=v!==void 0&&v,[S,C]=j.useState(!1),w;t[0]===a?w=t[1]:(w=()=>{a(),C(!1)},t[0]=a,t[1]=w);let T=w,E=x?d:u,D;t[2]===n?D=t[3]:(D=(0,M.jsx)(h,{asChild:!0,children:n}),t[2]=n,t[3]=D);let O;t[4]===r?O=t[5]:(O=(0,M.jsx)(l,{children:r}),t[4]=r,t[5]=O);let k;t[6]===i?k=t[7]:(k=(0,M.jsx)(o,{children:i}),t[6]=i,t[7]=k);let N;t[8]!==O||t[9]!==k?(N=(0,M.jsxs)(s,{children:[O,k]}),t[8]=O,t[9]=k,t[10]=N):N=t[10];let P;t[11]===b?P=t[12]:(P=(0,M.jsx)(f,{children:b}),t[11]=b,t[12]=P);let F;t[13]!==E||t[14]!==y||t[15]!==T?(F=(0,M.jsx)(E,{onClick:T,children:y}),t[13]=E,t[14]=y,t[15]=T,t[16]=F):F=t[16];let I;t[17]!==F||t[18]!==P?(I=(0,M.jsxs)(p,{children:[P,F]}),t[17]=F,t[18]=P,t[19]=I):I=t[19];let L;t[20]!==I||t[21]!==N?(L=(0,M.jsxs)(c,{children:[N,I]}),t[20]=I,t[21]=N,t[22]=L):L=t[22];let R;return t[23]!==S||t[24]!==L||t[25]!==D?(R=(0,M.jsxs)(m,{open:S,onOpenChange:C,children:[D,L]}),t[23]=S,t[24]=L,t[25]=D,t[26]=R):R=t[26],R},P=()=>{let{clearCache:e,getCacheInfo:n}=S(),r=t(D),[a,o]=(0,j.useState)(!1),{locale:s}=C(),{isPending:c,isFetching:l,refetch:u}=T(async()=>{await n(),await new Promise(e=>setTimeout(e,500))},[]),d=async()=>{try{o(!0),await e(),x({title:`Cache purged`,description:`All cached data has been cleared`}),u()}catch(e){x({title:`Error`,description:e instanceof Error?e.message:`Failed to purge cache`,variant:`danger`})}finally{o(!1)}};if(c&&!r)return(0,M.jsx)(v,{size:`medium`,centered:!0});let f=(0,M.jsxs)(g,{variant:`outline`,size:`sm`,onClick:u,disabled:l,children:[l?(0,M.jsx)(v,{size:`small`,className:`w-4 h-4 mr-2`}):(0,M.jsx)(y,{className:`w-4 h-4 mr-2`}),`Refresh`]});if(!r)return(0,M.jsx)(E,{title:`No cache data`,description:`Cache information is not available.`,icon:(0,M.jsx)(_,{}),action:f});let p=r.hits,m=r.misses,h=r.time,A=r.disk_total,P=r.disk_to_free,I=p+m,L=I>0?p/I*100:0;return I===0?(0,M.jsx)(E,{title:`No cache activity`,description:`The cache has not been used yet. Cached functions will appear here once they are executed.`,icon:(0,M.jsx)(_,{}),action:f}):(0,M.jsx)(`div`,{className:`flex flex-col h-full overflow-auto`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 h-full`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,M.jsx)(g,{"aria-label":`Refresh cache`,variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:u,disabled:l,children:(0,M.jsx)(y,{className:i(`h-4 w-4 text-muted-foreground hover:text-foreground`,l&&`animate-[spin_0.5s]`)})})}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Statistics`}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,M.jsx)(F,{label:`Time saved`,value:O(h,s),description:`Total execution time saved`}),(0,M.jsx)(F,{label:`Hit rate`,value:I>0?`${w(L,s)}%`:`—`,description:`${w(p,s)} hits / ${w(I,s)} total`}),(0,M.jsx)(F,{label:`Cache hits`,value:w(p,s),description:`Successful cache retrievals`}),(0,M.jsx)(F,{label:`Cache misses`,value:w(m,s),description:`Cache not found`})]})]}),A>0&&(0,M.jsxs)(`div`,{className:`space-y-3 pt-2 border-t`,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Storage`}),(0,M.jsx)(`div`,{className:`grid grid-cols-1 gap-3`,children:(0,M.jsx)(F,{label:`Disk usage`,value:k(A,s),description:P>0?`${k(P,s)} can be freed`:`Cache storage on disk`})})]}),(0,M.jsx)(`div`,{className:`my-auto`}),(0,M.jsx)(`div`,{className:`pt-2 border-t`,children:(0,M.jsx)(N,{title:`Purge cache?`,description:`This will permanently delete all cached data. This action cannot be undone.`,confirmText:`Purge`,destructive:!0,onConfirm:d,children:(0,M.jsxs)(g,{variant:`outlineDestructive`,size:`xs`,disabled:a,className:`w-full`,children:[a?(0,M.jsx)(v,{size:`small`,className:`w-3 h-3 mr-2`}):(0,M.jsx)(b,{className:`w-3 h-3 mr-2`}),`Purge Cache`]})})})]})})},F=e=>{let t=(0,A.c)(10),{label:n,value:r,description:i}=e,a;t[0]===n?a=t[1]:(a=(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,M.jsx)(`span`,{className:`text-lg font-semibold`,children:r}),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=i&&(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i}),t[4]=i,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,M.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 rounded-lg border bg-card`,children:[a,o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c};export{P as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./loro_wasm_bg-C2Fqi8D-.js","./loro_wasm_bg-Ctp2cNI9.js","./rolldown-runtime-B0Z9INg1.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t,d as n,f as r,l as i,o as a,r as o,s,t as c,u as l}from"./useEvent-BDjgaBtz.js";import{t as u}from"./react-DVplv7_D.js";import{$i as d,Bn as f,Br as p,Bt as m,Ca as h,Ci as g,Co as _,Cr as v,D as y,Dr as b,Fr as x,H as S,I as C,Ir as w,K as T,Lr as E,Lt as D,Ni as O,Nn as ee,Nr as k,Pr as te,Qi as ne,Ri as re,Rr as A,Si as j,U as ie,Ur as M,V as N,Vn as P,W as ae,Wr as oe,Yn as se,Zn as ce,_i as le,_n as ue,_t as de,ai as fe,ar as pe,at as me,b as he,ba as ge,bi as _e,bt as ve,ca as ye,ci as be,cn as xe,cr as Se,d as Ce,dt as we,fi as Te,fn as Ee,fo as De,ft as Oe,ga as ke,gn as Ae,gt as je,h as Me,ha as Ne,ht as Pe,i as Fe,it as Ie,jo as Le,jr as Re,li as ze,lr as Be,mn as Ve,mt as He,ni as Ue,nr as We,or as Ge,ot as Ke,pi as qe,pt as Je,qa as Ye,ri as Xe,rr as Ze,sa as Qe,si as $e,sr as et,ti as tt,tr as nt,tt as rt,u as it,ui as at,un as ot,vn as st,vr as ct,vt as lt,wa as ut,wi as dt,xa as ft,xi as pt,xo as mt,yi as ht,za as gt,zr as F}from"./cells-
|
|
2
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t,d as n,f as r,l as i,o as a,r as o,s,t as c,u as l}from"./useEvent-BDjgaBtz.js";import{t as u}from"./react-DVplv7_D.js";import{$i as d,Bn as f,Br as p,Bt as m,Ca as h,Ci as g,Co as _,Cr as v,D as y,Dr as b,Fr as x,H as S,I as C,Ir as w,K as T,Lr as E,Lt as D,Ni as O,Nn as ee,Nr as k,Pr as te,Qi as ne,Ri as re,Rr as A,Si as j,U as ie,Ur as M,V as N,Vn as P,W as ae,Wr as oe,Yn as se,Zn as ce,_i as le,_n as ue,_t as de,ai as fe,ar as pe,at as me,b as he,ba as ge,bi as _e,bt as ve,ca as ye,ci as be,cn as xe,cr as Se,d as Ce,dt as we,fi as Te,fn as Ee,fo as De,ft as Oe,ga as ke,gn as Ae,gt as je,h as Me,ha as Ne,ht as Pe,i as Fe,it as Ie,jo as Le,jr as Re,li as ze,lr as Be,mn as Ve,mt as He,ni as Ue,nr as We,or as Ge,ot as Ke,pi as qe,pt as Je,qa as Ye,ri as Xe,rr as Ze,sa as Qe,si as $e,sr as et,ti as tt,tr as nt,tt as rt,u as it,ui as at,un as ot,vn as st,vr as ct,vt as lt,wa as ut,wi as dt,xa as ft,xi as pt,xo as mt,yi as ht,za as gt,zr as F}from"./cells-B23_t5uX.js";import{t as _t}from"./react-dom-_LrxgvjW.js";import{C as vt,I as yt,M as bt,N as xt,O as St,R as Ct,S as wt,b as Tt}from"./schemas-ChRqMOTL.js";import{t as Et}from"./compiler-runtime-BrajqUja.js";import{t as Dt}from"./debounce-aFmHgJZY.js";import{E as Ot,_ as kt,c as At,g as jt,h as Mt,s as Nt}from"./config-DpY86_Yq.js";import{_ as Pt,c as Ft,g as It,m as Lt,t as Rt}from"./useEventListener-CjDeLqFC.js";import{t as zt}from"./invariant-Ci2dTZ72.js";import{s as Bt}from"./config-DMz7oN0r.js";import{d as Vt,m as Ht,t as Ut}from"./session-CMLIzZKw.js";import{D as Wt,M as Gt,S as Kt,T as qt,_ as Jt,o as Yt,p as Xt,r as Zt}from"./config-CD1IuZFJ.js";import{c as Qt}from"./state-C5WAeuTu.js";import{t as $t}from"./ErrorBoundary-DBQW23V4.js";import{t as en}from"./cn-ldLVeaqm.js";import{t as tn}from"./jsx-runtime-B74pBk57.js";import{X as nn,Z as rn}from"./JsonOutput-nLzWQ-0V.js";import{d as an}from"./select-3CVGlYrC.js";import{n as on}from"./download-Cm3InGht.js";import{t as sn}from"./switch-DYjBfpNJ.js";import{t as cn}from"./tooltip-CkGm8X7m.js";import{r as ln,t as un}from"./button-D8gVKwe-.js";import{t as dn}from"./createLucideIcon-DfJ2oMlA.js";import{i as fn,n as pn}from"./paths-bkIFVj8h.js";import{r as mn}from"./layout-DEFRD3k3.js";import{A as hn,C as gn,D as _n,_ as vn,j as yn,t as bn,v as xn,y as Sn}from"./ai-model-dropdown-DL56ImUU.js";import{r as Cn}from"./useNumberFormatter-D7O_26UI.js";import{t as wn}from"./circle-check-BCurAHEb.js";import{B as Tn,F as En,G as Dn,I as On,L as kn,M as An,R as jn,T as Mn,V as Nn,W as Pn,c as Fn,f as In,i as Ln,n as Rn,o as zn,r as Bn,s as Vn,w as Hn,z as Un}from"./add-cell-with-ai-CRbG5cTT.js";import{t as Wn}from"./database-zap-B_PMVg8T.js";import{r as Gn,t as Kn}from"./file-icons-CdJgUy-I.js";import{t as qn}from"./components-DCo7mAWO.js";import{b as Jn}from"./write-secret-modal-BEx-EUlh.js";import{n as Yn}from"./spinner-DyNE-o8o.js";import{n as Xn,o as Zn,r as Qn}from"./readonly-python-code-CVwB1OHZ.js";import{n as $n,t as er}from"./useDeleteCell-BPQ6Xcbj.js";import{t as tr}from"./save-Dgoim6QF.js";import{G as nr,I as rr,Ut as ir,Xt as ar,Yt as or,Zt as sr,tn as cr}from"./input-DmHMEZGh.js";import{n as lr}from"./copy-KlhazlhB.js";import{t as ur}from"./use-toast-Wu434mLr.js";import{t as dr}from"./preload-helper-uBIymjUX.js";import{$t as fr,Ct as pr,Dt as mr,E as hr,Et as gr,Ft as _r,Gt as vr,H as yr,I as br,It as xr,Jt as Sr,Kt as Cr,Ot as wr,P as Tr,Qt as I,St as Er,Ut as Dr,V as Or,Vt as kr,Wt as Ar,Xt as jr,_ as Mr,at as L,dt as Nr,gt as Pr,ht as Fr,in as Ir,jt as Lr,lt as Rr,m as zr,ot as Br,st as R,tn as Vr,ut as Hr,w as Ur,wt as Wr,zt as Gr}from"./dist-Cny7_yZb.js";import{C as Kr,E as qr,I as Jr,O as Yr,S as Xr,a as Zr,c as Qr,n as $r,r as ei,w as ti}from"./dist-DBMV4gqt.js";import{o as ni}from"./arrays-0R2reF2y.js";import{n as ri}from"./once-6KNTRW0u.js";import{t as ii}from"./createReducer-CaI_Oa0v.js";import{a as ai,c as oi,f as si,h as ci,i as li,l as ui,n as di,o as fi,t as pi}from"./dist-qhAY4L2r.js";import{r as mi}from"./strings-C25fhMR_.js";import{r as hi,t as gi}from"./requests-BIFR-h4M.js";import{t as _i}from"./badge-crT3E0Rm.js";import{a as vi}from"./dist-DusFODSa.js";import{r as yi}from"./useTheme-BAA27lh7.js";import{t as bi}from"./I18nProvider-Cg2I_s1_.js";import{i as xi}from"./numbers-CsZVw3Dc.js";import{n as Si}from"./useAsyncData-qvoPYHtx.js";import{a as Ci}from"./useRunCells-BV6nl_Ok.js";import{l as wi}from"./useInstallPackage-wcDq9hYT.js";import{a as Ti}from"./errors-CNsgAw6m.js";import{t as z}from"./extends-CvVTau-c.js";import{t as Ei}from"./objectWithoutPropertiesLoose-Do6ywDBO.js";import{t as Di}from"./kbd-pdKBv96t.js";import{a as Oi,n as ki}from"./state-BoRCcWOg.js";import{a as Ai,o as ji}from"./cell-link-C9tkvy6x.js";import{a as Mi}from"./renderShortcut-rUwGqKgC.js";import{n as Ni,t as Pi}from"./icons-CiZ_8zS-.js";import{n as Fi}from"./esm-CI_o7NhW.js";import{t as Ii}from"./dist-AelfNxj6.js";import{t as Li}from"./skeleton-Cqh4O9g1.js";import{t as Ri}from"./requests-DuLJN9Tf.js";import{n as zi}from"./formatting-uom1es4b.js";import{t as Bi}from"./useSplitCell-Ca364Rrx.js";import{n as Vi,r as Hi,t as Ui}from"./panel-accordion-state-BO2rN4A5.js";import{Bo as Wi,Fo as Gi,Ho as Ki,Io as qi,Lo as Ji,No as Yi,Po as Xi,Ro as Zi,Uo as Qi,Vo as $i,ut as ea,zo as ta}from"./loro_wasm_bg-Ctp2cNI9.js";import{t as na}from"./Inputs-BsQm29hD.js";import{n as ra}from"./hooks-DteA-neM.js";var ia=dn(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),aa={showInput:`Mod-l`,acceptEdit:`Mod-y`,rejectEdit:`Mod-u`},oa=300,sa=Cr.define({combine:e=>Ir(e,{onError:console.error,inputDebounceTime:oa,keymaps:aa},{onError:(e,t)=>e&&t,inputDebounceTime:(e,t)=>e&&t,keymaps:(e,t)=>e&&t})}),ca=I.define(),la=fr.define({create(){return{show:!1,lineFrom:0,lineTo:0}},update(e,t){for(let e of t.effects)if(e.is(ca))return e.value;return e}}),ua=I.define(),da=I.define(),fa=fr.define({create(){return{shouldFocus:!1,inputValue:``}},update(e,t){let n=e;for(let e of t.effects)e.is(ua)&&(n={...n,inputValue:e.value}),e.is(da)&&(n={...n,shouldFocus:e.value});return n}}),pa=I.define(),ma=fr.define({create(){return null},update(e,t){for(let e of t.effects)if(e.is(pa))return e.value;return e}}),ha=I.define(),ga=fr.define({create(){return!1},update(e,t){for(let e of t.effects)if(e.is(ha))return e.value;return e}}),_a=1,va=e=>{let{state:t}=e,n=t.selection.main;if(n.empty)return!1;let r=t.doc,i=r.lineAt(n.from),a=r.lineAt(n.to);if(t.sliceDoc(i.from,a.to).trim().length<_a)return!1;let o=Math.max(1,Math.min(i.number,r.lines)),s=Math.max(1,Math.min(a.number,r.lines));return e.dispatch({effects:[ca.of({show:!0,lineFrom:o,lineTo:s}),da.of(!0),ua.of(``)],selection:Ar.cursor(i.from)}),!0},ya=e=>e.state.field(ma)?(e.dispatch({effects:[pa.of(null),ca.of({show:!1,lineFrom:0,lineTo:0}),da.of(!1),ua.of(``),ha.of(!1)]}),!0):!1,ba=e=>{let t=e.state.field(ma);return t?(e.dispatch({changes:{from:t.from,to:t.to,insert:t.oldCode},effects:[pa.of(null),ca.of({show:!1,lineFrom:0,lineTo:0}),da.of(!1),ua.of(``),ha.of(!1)]}),!0):!1},xa=fr.define({create(){return{suggestion:null}},update(e,t){let n=t.effects.find(e=>e.is(Sa));if(!t.docChanged&&!n&&!t.selection)return e;if(n&&t.state.doc===n.value.doc&&t.state.selection.main.head===n.value.pos)return{suggestion:n.value.text};if(e.suggestion&&t.docChanged&&t.startState.selection.ranges.length===1&&t.startState.selection.main.empty&&t.state.selection.ranges.length===1&&t.state.selection.main.empty){let n=t.startState.selection.main.head,r=``,i=0,a=!0;if(t.changes.iterChanges((e,t,o,s,c)=>{i++,a&&=e===n&&t===n,r=c.toString()}),a&&i===1&&r&&e.suggestion.startsWith(r)&&t.state.selection.main.head===n+r.length)return{suggestion:e.suggestion.slice(r.length)||null}}return{suggestion:null}}}),Sa=I.define();function Ca(e,t){let n=e.state.selection.main.head,r=[],i=L.widget({widget:new wa(t),side:1});return r.push(i.range(n)),L.set(r)}var wa=class extends Nr{suggestion;constructor(e){super(),this.suggestion=e}toDOM(){let e=document.createElement(`span`);return e.style.opacity=`0.4`,e.className=`cm-inline-suggestion`,e.textContent=this.suggestion,e.setAttribute(`role`,`suggestion`),e.setAttribute(`aria-label`,`Suggestion: ${this.suggestion}`),e}get lineBreaks(){return this.suggestion.split(`
|
|
3
3
|
`).length-1}},Ta=class{cache=new Map;timeout;constructor(e){this.timeout=e}get(e){let t=this.cache.get(e);return t?Date.now()-t.timestamp>this.timeout?(this.cache.delete(e),null):t.result:null}set(e,t){if(t){for(let[e,t]of this.cache)Date.now()-t.timestamp>this.timeout&&this.cache.delete(e);if(this.cache.delete(e),this.cache.set(e,{result:t,timestamp:Date.now()}),this.cache.size>20){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}}}},Ea=(e,t)=>Hr.fromClass(class{abortController=null;timer=null;cache;constructor(){this.cache=new Ta(t.cacheTimeout??1e3)}cancel(){this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.abortController?.abort(),this.abortController=null}update(n){let r=n.transactions.some(e=>e.effects.some(e=>e.is(Sa)&&e.value.text===null));if(!n.docChanged&&!n.selectionSet&&!r&&!(n.focusChanged&&!n.view.hasFocus)||(this.cancel(),!n.docChanged||n.state.field(xa).suggestion||!n.state.selection.main.empty||n.state.selection.ranges.length!==1||t.events?.beforeSuggestionFetch?.(n.view)===!1))return;let i=new AbortController;this.abortController=i;let a=n.state.doc,o=n.state.selection.main.head,s=JSON.stringify([a.toString(),o]),c=this.cache.get(s),l=async()=>{if(!i.signal.aborted)try{let r=c??await e(n.state,i.signal,n.view);if(i.signal.aborted||n.view.state.doc!==a||n.view.state.selection.main.head!==o||t.events?.shouldShowSuggestion?.(n.view,r)===!1)return;this.cache.set(s,r),n.view.dispatch({effects:Sa.of({text:r,doc:a,pos:o})})}catch(e){!i.signal.aborted&&e instanceof Error&&e.name!==`AbortError`&&console.error(`Suggestion fetch error:`,e)}};this.timer=setTimeout(l,c?0:t.delay??500)}destroy(){this.cancel()}}),Da=Hr.fromClass(class{decorations;constructor(){this.decorations=L.none}update(e){let t=e.state.field(xa)?.suggestion;if(!t){this.decorations=L.none;return}this.decorations=Ca(e.view,t)}},{decorations:e=>e.decorations});function Oa(e,t,n,r){return{...e.changeByRange(i=>{if(i===e.selection.main)return{changes:{from:n,to:r,insert:t},range:Ar.cursor(n+t.length)};let a=r-n;return!i.empty||a&&e.sliceDoc(i.from-a,i.from)!==e.sliceDoc(n,r)?{range:i}:{changes:{from:i.from-a,to:i.from,insert:t},range:Ar.cursor(i.from-a+t.length)}}),userEvent:`input.complete`}}var ka=e=>{let t=e.state.field(xa)?.suggestion;if(!t)return!1;let n=e.state.facet(Ma);return e.dispatch({...Oa(e.state,t,e.state.selection.main.head,e.state.selection.main.head)}),n.events?.onSuggestionAccepted?.(e,t),!0},Aa=e=>{let t=e.state.field(xa)?.suggestion;if(!t)return!1;let n=e.state.facet(Ma);return e.dispatch({effects:Sa.of({text:null,doc:e.state.doc,pos:e.state.selection.main.head})}),n.events?.onSuggestionRejected?.(e,t),!0},ja=gr.of([{key:`Tab`,run:ka},{key:`Escape`,run:Aa}]),Ma=Cr.define({combine:e=>e.at(-1)});function Na(e){let{includeKeymap:t=!0}=e;return[xa,Ma.of(e),Ea(e.fetchFn,e),Da,t?ja:[]]}var Pa=R.baseTheme({".cm-ai-input-container":{display:`flex`,flexDirection:`column`,gap:`4px`,width:`min(calc(100% + 7px), 500px)`,padding:`5px 5px`,margin:`0 -6px`,backgroundColor:`light-dark(rgb(241, 243, 245), rgb(40, 40, 40))`},".cm-ai-input":{display:`block`,width:`100%`,padding:`3px 8px`,border:`2px solid rgb(51, 154, 240)`,borderRadius:`5px`,fontSize:`12px`},".cm-ai-help-info-button":{fontSize:`10px`,paddingLeft:`10px`,height:`18px`,color:`light-dark(rgb(109, 117, 125), rgb(170, 170, 170))`,display:`block`,marginRight:`auto`},".cm-ai-help-info-button:hover":{color:`light-dark(rgb(89, 97, 105), rgb(190, 190, 190))`},".cm-ai-generate-button":{background:`#0E639C`,border:`none`,padding:`2px 6px`,color:`#ffffff`,cursor:`pointer`,font:`inherit`,borderRadius:`4px`,"&:hover":{backgroundColor:`#1177bb`}},".cm-line.cm-ai-selection, .cm-line.cm-ai-selection.cm-active-line":{backgroundColor:`light-dark(color-mix(in srgb, rgb(223, 227, 232) 50%, transparent), color-mix(in srgb, rgb(50, 50, 50) 50%, transparent)) !important`},".cm-line:has(.cm-new-code-line)":{backgroundColor:`light-dark(color-mix(in srgb, rgb(183, 235, 143) 50%, transparent), color-mix(in srgb, rgb(40, 100, 40) 50%, transparent)) !important`},".cm-old-code-container":{backgroundColor:`light-dark(rgb(255, 205, 205), rgb(100, 40, 40))`,position:`relative`,display:`flex`,paddingTop:`0`,width:`100%`,alignItems:`center`},".cm-code-button":{position:`absolute`,right:`5px`,top:`50%`,transform:`translateY(-50%)`,background:`none`,border:`none`,cursor:`pointer`,fontSize:`16px`},".cm-floating-buttons":{fontFamily:`sans-serif`,position:`absolute`,top:`-20px`,left:`5px`,display:`flex`},".cm-floating-button":{fontFamily:`sans-serif`,padding:`2px 5px`,fontSize:`10px`,cursor:`pointer`,fontWeight:`700`},".cm-floating-accept":{backgroundColor:`light-dark(rgb(55, 125, 34), rgb(40, 80, 25))`,borderTopLeftRadius:`5px`,borderBottomLeftRadius:`5px`,color:`white`,filter:`brightness(90%)`,"&:hover":{filter:`brightness(100%)`}},".cm-floating-reject":{backgroundColor:`light-dark(rgb(220, 53, 69), rgb(180, 40, 50))`,color:`white`,borderTopRightRadius:`5px`,borderBottomRightRadius:`5px`,filter:`brightness(90%)`,"&:hover":{filter:`brightness(100%)`}},".hotkey":{display:`inline-block`,padding:`0 4px`,borderRadius:`3px`,backgroundColor:`rgba(255, 255, 255, 0.1)`,fontSize:`90%`},".cm-ai-loading-indicator":{fontStyle:`italic`,fontSize:`10px`,paddingLeft:`12px`,color:`light-dark(rgb(109, 117, 125), rgb(170, 170, 170))`,opacity:`0`,transition:`opacity 0.3s ease-in-out`,"&::after":{content:`""`,display:`inline-block`,animation:`ellipsis-pulse 1.5s steps(4, end) infinite`},"&:not(:empty)":{opacity:`1`}},".cm-ai-input:disabled":{opacity:`0.5`},"@keyframes ellipsis-pulse":{"0%":{content:`'.'`},"25%":{content:`'..'`},"50%":{content:`'...'`},"75%":{content:`''`}},".cm-ai-loading-container":{display:`flex`,alignItems:`center`,padding:`0 8px`},".cm-ai-cancel-button":{padding:`2px 8px`,fontSize:`10px`,borderRadius:`4px`,color:`light-dark(rgb(109, 117, 125), rgb(170, 170, 170))`,cursor:`pointer`,"&:hover":{background:`light-dark(rgb(223, 227, 232), rgb(50, 50, 50))`}},".hidden":{display:`none`}}),Fa={mac:`⌘`,windows:`Ctrl`,default:`Ctrl`};function Ia(){return navigator.platform.startsWith(`Mac`)?Fa.mac:navigator.platform.startsWith(`Win`)?Fa.windows:Fa.default}function La(e){return e.replace(`Mod`,Ia()).replace(`-`,` `).toUpperCase()}function B(e,t){let n=document.createElement(e);return n.className=t,n}function Ra(e){let t=e.state.facet(sa),n={...aa,...t.keymaps},r=e.state.facet(za),i=B(`div`,`cm-ai-tooltip`).appendChild(B(`div`,`cm-ai-tooltip-button`)),a=i.appendChild(document.createElement(`span`));a.textContent=`${r.label} `;let o=a.appendChild(document.createElement(`span`));return o.className=`hotkey`,o.textContent=La(n.showInput),i.querySelector(`span`)?.addEventListener(`mousedown`,e=>{e.stopPropagation(),e.button===0&&e.preventDefault()}),i.querySelector(`span`)?.addEventListener(`click`,t=>{t.preventDefault(),va(e)}),i}var za=Cr.define({combine(e){return Ir(e,{render:Ra,hideOnBlur:!1,label:`Edit with AI`})}}),Ba=Hr.fromClass(class{view;suppress;dom;mousedown=()=>{this.suppress=!0};mouseup=()=>{this.suppress=!1,this.display(this.view)};scroll=()=>{this.display(this.view)};windowScroll=()=>{this.display(this.view)};constructor(e){this.view=e;let t=e.state.facet(za);this.suppress=!1,document.addEventListener(`mousedown`,this.mousedown),document.addEventListener(`mouseup`,this.mouseup),e.scrollDOM.addEventListener(`scroll`,this.scroll),window.addEventListener(`scroll`,this.windowScroll,!0);let n=t.render(e);e.dom.appendChild(n),this.dom=n}update(e){this.display(e.view)}docViewUpdate(e){this.display(e)}display(e){if(e.state.field(la).show){this.dom.style.display=`none`;return}if(e.state.facet(za).hideOnBlur&&!e.hasFocus){this.dom.style.display=`none`,this.dom.setAttribute(`aria-hidden`,`true`);return}e.requestMeasure({read:this.#e})}#e=e=>{let t=e.state.selection.ranges.find(e=>!e.empty);if(t&&!this.suppress){let n=e.coordsAtPos(t.from),r=e.coordsAtPos(t.to);if(!n||!r)return;let i=e.dom.getBoundingClientRect(),a=e.dom.parentElement?.getBoundingClientRect(),o=e=>e.top>=i.top&&e.top<=i.bottom&&e.left>=i.left&&e.left<=i.right,s=e=>!a||e.top>=a.top&&e.top<=a.bottom&&e.left>=a.left&&e.left<=a.right,c=o(n)||o(r),l=s(n)||s(r);if(!c||!l){this.dom.style.display=`none`,this.dom.setAttribute(`aria-hidden`,`true`);return}this.dom.style.display=`flex`,this.dom.setAttribute(`aria-hidden`,`false`);let u=this.dom.getBoundingClientRect(),d=o(n)?n:r,f=i.right-u.width,p=Math.min(d.left,f),m=d.top-u.height,h=a?a.y:-1/0;m<h&&(m=r.bottom),this.dom.style.left=`${p}px`,this.dom.style.top=`${m}px`,requestAnimationFrame(()=>{this.dom&&this.dom.setAttribute(`aria-hidden`,`false`)})}else this.dom.style.display=`none`,this.dom.setAttribute(`aria-hidden`,`true`)};destroy(){document.removeEventListener(`mousedown`,this.mousedown),document.removeEventListener(`mouseup`,this.mouseup),this.view.scrollDOM.removeEventListener(`scroll`,this.scroll),window.removeEventListener(`scroll`,this.windowScroll,!0),this.dom.remove()}}),Va=R.baseTheme({".cm-ai-tooltip-button":{userSelect:`none`,fontFamily:`system-ui, -apple-system, sans-serif`,position:`fixed`,display:`flex`,boxSizing:`border-box`,padding:`2px 6px`,borderRadius:`4px`,fontSize:`12px`,backgroundColor:`#0E639C`,color:`#ffffff`,border:`1px solid transparent`,boxShadow:`0 2px 4px rgba(0,0,0,0.1)`,zIndex:`999`,transition:`opacity 0.5s`,"&[aria-hidden='true']":{opacity:`0`},"&[aria-hidden='false']":{opacity:`1`},"& > span":{pointerEvents:`auto`,cursor:`pointer`,display:`inline-block`,padding:`2px`},"&:hover":{backgroundColor:`#1177bb`}}});function Ha(){return[Ba,Va]}var Ua=class extends Nr{oldCode;constructor(e){super(),this.oldCode=e}toDOM(e){let t=B(`div`,`cm-old-code-container`);t.setAttribute(`role`,`region`),t.setAttribute(`aria-label`,`Previous code version`);let n=B(`div`,`cm-old-code cm-line`);n.textContent=this.oldCode;let r=B(`div`,`cm-floating-buttons`),i=e.state.facet(sa),a={...aa,...i.keymaps},o=B(`button`,`cm-floating-button cm-floating-accept`);o.innerHTML=`<span class="hotkey">${La(a.acceptEdit)}</span> Accept`,o.setAttribute(`aria-label`,`Accept changes`),o.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),e.focus(),ya(e)});let s=B(`button`,`cm-floating-button cm-floating-reject`);return s.innerHTML=`<span class="hotkey">${La(a.rejectEdit)}</span> Reject`,s.setAttribute(`aria-label`,`Reject changes`),s.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),e.focus(),ba(e)}),r.append(o,s),t.append(n,r),t}updateDOM(e,t){return!0}},Wa=class extends Nr{complete;abortController=null;dom=null;input=null;loadingContainer=null;helpInfo=null;inputContainer=null;form=null;view=null;constructor(e){super(),this.complete=e}toDOM(e){if(this.dom)return this.dom;this.view=e;let t=e.state.field(fa),n=e.state.field(ga),r=B(`div`,`cm-ai-input-container`);this.inputContainer=r,this.dom=r;let i=B(`form`,`cm-ai-input-form`);this.form=i,i.setAttribute(`role`,`search`),i.setAttribute(`aria-label`,`AI editing instructions`),i.addEventListener(`submit`,e=>e.preventDefault());let a=B(`input`,`cm-ai-input`);this.input=a,i.append(a),a.placeholder=`Editing instructions...`,a.setAttribute(`aria-label`,`AI editing instructions`),a.setAttribute(`autocomplete`,`off`),a.setAttribute(`spellcheck`,`true`),a.value=t.inputValue;let o=B(`div`,`cm-ai-loading-container`);this.loadingContainer=o;let s=B(`div`,`cm-ai-loading-indicator`);s.setAttribute(`role`,`status`),s.setAttribute(`aria-live`,`polite`),s.textContent=`Generating`;let c=B(`button`,`cm-ai-cancel-button`);c.textContent=`Cancel`,c.setAttribute(`aria-label`,`Cancel code generation`),c.addEventListener(`click`,this.onCancel),o.append(c,s);let l=B(`div`,`cm-ai-help-info`);this.helpInfo=l;let u=l.appendChild(document.createElement(`button`));u.className=`cm-ai-help-info-button`,u.textContent=`Esc to close`,u.addEventListener(`click`,this.onCancel);let d=B(`button`,`cm-ai-generate-button`);d.textContent=`⏎ Generate`,d.setAttribute(`aria-label`,`Generate code`),d.addEventListener(`click`,this.handleSubmit),this.toggleLoading(n),t.shouldFocus&&requestAnimationFrame(()=>{a.value=t.inputValue,a.focus(),e.dispatch({effects:da.of(!1)})}),f(a.value),a.addEventListener(`input`,m),a.addEventListener(`keydown`,this.onKeyDown);function f(e){l.replaceChildren(e?d:u)}let p=``;function m(){e.dispatch({effects:ua.of(a.value)});let t=a.value.trim();t!==p&&(p=t,f(t))}return r}toggleLoading(e){this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&this.inputContainer?.replaceChildren(this.form,e?this.loadingContainer:this.helpInfo)}onKeyDown=async e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),await this.handleSubmit()):e.key===`Escape`&&this.onCancel()};onCancel=()=>{this.cleanup();let e=this.view;e&&(e.dispatch({effects:[ca.of({show:!1,lineFrom:0,lineTo:0}),ha.of(!1)]}),e.focus())};handleSubmit=async e=>{let t=this.view;if(!t)return;let n=t.state.facet(sa);e?.stopPropagation();let r=t.state.field(la),{input:i}=this;if(!i)return;let a=i.value.trim();if(!r.show||!a)return;let o=t.state.doc.line(r.lineFrom),s=t.state.doc.line(r.lineTo),c=o.from,l=s.to,u=t.state.sliceDoc(c,l),d=t.state.sliceDoc(0,c),f=t.state.sliceDoc(l);this.abortController=new AbortController,t.dispatch({effects:ha.of(!0)}),this.toggleLoading(!0);try{let e=await this.complete({prompt:a,selection:u,codeBefore:d,codeAfter:f,editorView:t,signal:this.abortController.signal});if(!t.state.field(la).show)return;if(!e||typeof e!=`string`)throw Error(`Invalid completion result`);t.dispatch({changes:{from:c,to:l,insert:e},effects:[ca.of({show:!1,lineFrom:0,lineTo:0}),pa.of({from:c,to:c+e.length,oldCode:u,newCode:e}),ha.of(!1)]})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;n.onError?.(e)}finally{this.cleanup(),this.toggleLoading(!1),t.focus()}};updateDOM(e,t){return this.dom=e,this.input=e.querySelector(`.cm-ai-input`),!0}cleanup(){this.abortController?.abort(),this.abortController=null,this.dom?.remove(),this.input?.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}};function Ga(e){if(!e.prompt)throw Error(`prompt function is required`);let t={...aa,...e.keymaps};return[sa.of(e),la,fa,ma,ga,Ha(),Pa,gr.of([{key:t.showInput,run:va}]),Sr.highest([gr.of([{key:t.acceptEdit,run:ya},{key:t.rejectEdit,run:ba}])]),Ka,qa,Ja,Ya]}var Ka=R.updateListener.of(e=>{let t=e.state.field(la);if(!t.show||!e.docChanged)return;let{lineFrom:n,lineTo:r}=t,i=!1;e.changes.iterChanges((t,a,o,s)=>{let c=e.state.doc.lineAt(t).number;if(c<n){let t=e.state.doc.lineAt(s).number-e.state.doc.lineAt(o).number;n+=t,r+=t,i=!0}else if(c<=r){let t=e.state.doc.lineAt(s).number-e.state.doc.lineAt(o).number;r+=t,i=!0}}),i&&e.view.dispatch({effects:[ca.of({show:!0,lineFrom:n,lineTo:r})]})}),qa=R.decorations.of(e=>{let t=e.state.field(ma);return t?L.set([L.mark({class:`cm-new-code-line`}).range(t.from,t.to)]):L.none}),Ja=R.decorations.compute([la],e=>{let t=e.field(la),n=e.facet(sa),r=[];if(t.show){let i=t.lineFrom,a=t.lineTo;for(let t=i;t<=a;t++){let a=e.doc.line(t).from;r.push(L.line({class:`cm-ai-selection`}).range(a)),t===i&&r.push(L.widget({widget:new Wa(n.prompt),side:-1}).range(a))}}return L.set(r)}),Ya=fr.define({create(e){return L.none},update(e,t){let n=t.state.field(ma);return n?L.set([L.widget({widget:new Ua(n.oldCode),block:!0}).range(n.from)]):L.none},provide:e=>R.decorations.from(e)}),V=e(u(),1),H=Et(),Xa=()=>({entries:new Map}),{valueAtom:Za,useActions:Qa}=ii(Xa,{submit:(e,t)=>{let{cellIds:n,deleteCell:r,deleteManyCells:i,store:a}=t,o=a.get(he),s=a.get(tt),c=new Set(o.cellIds.inOrderIds.filter(e=>o.cellData[e].code.trim()===``)),l=new Map;for(let e of n){if(c.has(e)){l.set(e,{cellId:e,type:`simple`});continue}let t=o.cellRuntime[e],n=new Map;for(let t of Object.values(s)){let r=t.declaredBy.includes(e),i=t.usedBy.some(e=>!c.has(e));r&&i&&n.set(t.name,t.usedBy)}let r;t?.runElapsedTimeMs&&t.runElapsedTimeMs>2e3&&(r=t.runElapsedTimeMs),n.size===0&&r===void 0?l.set(e,{cellId:e,type:`simple`}):l.set(e,{cellId:e,type:`expensive`,executionDurationMs:r,defs:n})}let u=[...l.values()].every(e=>e.type===`simple`);return l.size>0&&u?(l.size===1?r({cellId:[...l.values()][0].cellId}):i({cellIds:[...l.values()].map(e=>e.cellId)}),Xa()):{...e,entries:l}},clear:()=>Xa()});function $a(){let e=(0,H.c)(10),t=n(),{submit:r,clear:a}=Qa(),{entries:o}=i(Za),s=er(),c=$n(),l;e[0]!==s||e[1]!==c||e[2]!==t||e[3]!==r?(l=e=>{r({cellIds:e,deleteCell:s,deleteManyCells:c,store:t})},e[0]=s,e[1]=c,e[2]=t,e[3]=r,e[4]=l):l=e[4];let u=o.size===0,d=o.size>1,f;return e[5]!==a||e[6]!==l||e[7]!==u||e[8]!==d?(f={submit:l,clear:a,idle:u,shouldConfirmDelete:d},e[5]=a,e[6]=l,e[7]=u,e[8]=d,e[9]=f):f=e[9],f}function eo(e){let t=(0,H.c)(16),n=i(Za),r=Qa(),a=$n(),o;t[0]!==e||t[1]!==n.entries?(o=n.entries.get(e),t[0]=e,t[1]=n.entries,t[2]=o):o=t[2];let s=o;if(!s){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={isPending:!1},t[3]=e):e=t[3],e}if(n.entries.size!==1){let e;return t[4]===s?e=t[5]:(e={isPending:!0,shouldConfirmDelete:!1,...s},t[4]=s,t[5]=e),e}let c;t[6]!==r||t[7]!==a||t[8]!==n.entries?(c=()=>{a({cellIds:[...n.entries.values()].map(to)}),r.clear()},t[6]=r,t[7]=a,t[8]=n.entries,t[9]=c):c=t[9];let l;t[10]===r?l=t[11]:(l=()=>r.clear(),t[10]=r,t[11]=l);let u;return t[12]!==s||t[13]!==c||t[14]!==l?(u={isPending:!0,...s,shouldConfirmDelete:!0,confirm:c,cancel:l},t[12]=s,t[13]=c,t[14]=l,t[15]=u):u=t[15],u}function to(e){return e.cellId}async function no(e){if(!e.ok)throw Error(await e.text());if(!e.body)throw Error(`Failed to get response body`);let t=null,n=!1;if(await Nn({stream:Dn({stream:e.body,schema:Pn}).pipeThrough(new TransformStream({transform(e){if(!e.success)throw e.error;let r=e.value;if(kn(r)&&r.type===En)t=On.parse(r.data).code;else if(r.type===`error`)throw Error(r.errorText);else r.type===`finish`&&(n=r.finishReason===`stop`)}})),onError:e=>{throw e}}),!n)throw Error(`AI completion ended before final validation`);if(t===null)throw Error(`AI completion returned no cell code`);return t}async function ro(e){let t=`
|
|
4
4
|
${e.codeBefore}
|
|
5
5
|
<rewrite_this>
|
|
@@ -36,7 +36,7 @@ const partysocket = new PartySocket({
|
|
|
36
36
|
WebSocket: WS
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
`),df=!0);let r=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:e,protocols:n}),this._ws=n?new r(e,n):new r(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new nf.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new nf.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(e,t),this._handleClose(new nf.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=uf.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),rf(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>{this._ws?.send(e)}),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(lf(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(lf(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(lf(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._options.shouldReconnectOnClose&&!this._options.shouldReconnectOnClose(e)&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(lf(e))};_removeListeners(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError),this._ws.addEventListener(`error`,ff))}_addListeners(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},mf=R.baseTheme({".loro-cursor":{position:`absolute`,width:`2px`,display:`inline-block`,height:`1.2em`},".loro-cursor::before":{position:`absolute`,top:`1.3em`,left:`0`,content:`var(--rtc-name)`,padding:`2px 6px`,fontSize:`12px`,borderRadius:`3px`,whiteSpace:`nowrap`,userSelect:`none`,backgroundColor:`inherit`,opacity:`0.7`},".loro-selection":{opacity:`0.5`}});Gr.define();var hf=I.define(),gf=fr.define({create(){return{remoteCursors:new Map,isCheckout:!1}},update(e,t){for(let n of t.effects)if(n.is(hf))switch(n.value.type){case`update`:{let{peer:t,user:r,cursor:i}=n.value;e.remoteCursors.set(t,{uid:t,cursor:i,user:r});break}case`delete`:e.remoteCursors.delete(n.value.peer);break;case`checkout`:e.isCheckout=n.value.checkout}return e}}),_f=e=>{let t=e.transactions.flatMap(e=>e.effects).filter(e=>e.is(hf));return e.docChanged||e.viewportChanged||t.length>0},vf=()=>mr({above:!0,class:`loro-cursor-layer`,update:_f,markers:e=>{let{remoteCursors:t,isCheckout:n}=e.state.field(gf);return n?[]:[...t.values()].flatMap(t=>{let n=Ar.cursor(t.cursor.anchor);return bf.createCursor(e,n,t.user?.name||`unknown`,t.user?.colorClassName||``)})}}),yf=()=>mr({above:!1,class:`loro-selection-layer`,update:_f,markers:e=>{let{remoteCursors:t,isCheckout:n}=e.state.field(gf);return n?[]:[...t.entries()].filter(([,e])=>e.cursor.head!==void 0&&e.cursor.anchor!==e.cursor.head).flatMap(([,t])=>{let n=Ar.range(t.cursor.anchor,t.cursor.head);return Rr.forRange(e,`loro-selection ${t.user?.colorClassName||``}`,n)})}}),bf=class e{left;top;height;name;colorClassName;constructor(e,t,n,r,i){this.left=e,this.top=t,this.height=n,this.name=r,this.colorClassName=i}draw(){let e=document.createElement(`div`);return this.adjust(e),e}update(e){return this.adjust(e),!0}adjust(e){e.style.left=`${this.left}px`,e.style.top=`${this.top}px`,e.style.height=`${this.height}px`,e.className=`loro-cursor ${this.colorClassName}`,e.style.setProperty(`--rtc-name`,`"${this.name}"`)}eq(e){return this.left===e.left&&this.top===e.top&&this.height===e.height&&this.name===e.name}static createCursor(t,n,r,i){let a=e.calculateAbsoluteCursorPosition(n,t);if(!a)return[];let o=t.scrollDOM.getBoundingClientRect(),s=(t.textDirection===Br.LTR?o.left:o.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,c=o.top-t.scrollDOM.scrollTop;return[new e(a.left-s,a.top-c,a.bottom-a.top,r,i)]}static calculateAbsoluteCursorPosition(e,t){let n=Math.max(0,Math.min(t.state.doc.length,e.anchor));return t.coordsAtPos(n,e.assoc||1)}},xf=(e,t,n,r)=>{let i=[],{updated:a,added:o}=n;for(let n of[...a,...o]){let a=Sf(e,t,n,r);a&&i.push(a)}return i},Sf=(e,t,n,r)=>{let i=t.getAllStates()[n];if(!i||n===e.peerIdStr||i.scopeId!==r)return;if(i.type===`delete`)return hf.of({type:`delete`,peer:i.uid,scopeId:i.scopeId});let a=Xi.decode(i.cursor.anchor),o=e.getCursorPos(a)?.offset??0,s=o;if(i.cursor.head){let t=Xi.decode(i.cursor.head);s=e.getCursorPos(t)?.offset??0}return hf.of({type:`update`,peer:i.uid,scopeId:i.scopeId,cursor:{anchor:o,head:s},user:i.user})},Cf=class{sub;view;doc;user;awareness;getTextFromDoc;scopeId;getUserId;constructor(e,t,n,r,i,a,o){this.view=e,this.doc=t,this.user=n,this.awareness=r,this.getTextFromDoc=i,this.scopeId=a,this.getUserId=o,this.sub=this.doc.subscribe(e=>{if(e.by===`local`){let e=[];for(let t of this.awareness.peers()){let n=Sf(this.doc,this.awareness,t,this.scopeId);n&&e.push(n)}this.view.dispatch({effects:e})}else e.by===`checkout`&&this.view.dispatch({effects:[hf.of({type:`checkout`,checkout:this.doc.isDetached()})]})})}update(e){if(!e.selectionSet&&!e.focusChanged&&!e.docChanged)return;let t=e.state.selection.main;if(this.view.hasFocus&&!this.doc.isDetached()){let e=Tf({doc:this.doc,getTextFromDoc:this.getTextFromDoc,anchor:t.anchor,head:t.head});this.awareness.setLocalState({type:`update`,uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId,cursor:e,user:this.user})}else this.awareness.setLocalState({type:`delete`,uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}destroy(){this.sub?.(),this.awareness.setLocalState({type:`delete`,uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}},wf=class{_awarenessListener;view;doc;awareness;scopeId;constructor(e,t,n,r){this.view=e,this.doc=t,this.awareness=n,this.scopeId=r;let i=async(e,t)=>{t!==`local`&&this.view.dispatch({effects:xf(this.doc,this.awareness,e,this.scopeId)})};this._awarenessListener=i,this.awareness.addListener(i)}destroy(){this._awarenessListener&&this.awareness.removeListener(this._awarenessListener)}},Tf=({doc:e,getTextFromDoc:t,anchor:n,head:r})=>{n===r&&(r=void 0);let i=t(e).getCursor(n)?.encode();if(!i)throw Error(`cursor head not found`);let a;return r!==void 0&&(a=t(e).getCursor(r)?.encode()),{anchor:i,head:a}},Ef=[`bg-(--amber-6)`,`bg-(--blue-6)`,`bg-(--crimson-6)`,`bg-(--cyan-6)`,`bg-(--grass-6)`,`bg-(--gray-6)`,`bg-(--green-6)`,`bg-(--lime-6)`,`bg-(--orange-6)`,`bg-(--purple-6)`,`bg-(--red-6)`,`bg-(--sage-6)`,`bg-(--sky-6)`,`bg-(--slate-6)`],Df=e=>{if(typeof e==`string`){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t=Math.trunc(t);return Ef[Math.abs(t)%Ef.length]}return Ef[e%Ef.length]},Q=It.get(`rtc`),Of=Q.get(`awareness`).disabled(),kf=`awareness:`;function Af(e,t){let n=new TextEncoder().encode(e);return new Uint8Array([...n,...t])}function jf(e,t){return new TextDecoder().decode(e.slice(0,t.length))===t}function Mf(e,t){return e.slice(t.length)}var Nf=r(void 0),$=new qi,Pf=new Xd($.peerIdStr),Ff=ri(()=>{Q.debug(`creating websocket`);let e=new pf(Zt().getWsSyncURL(Ut()).toString(),void 0,{maxRetries:10,debug:!1,startClosed:!0,connectionTimeout:1e4});return Promise.resolve().then(async()=>{await Kt(),Vt()===`edit`&&e.reconnect()}),e.addEventListener(`message`,async e=>{let t=await e.data.arrayBuffer(),n=new Uint8Array(t);if(jf(n,kf)){let e=Mf(n,kf);Pf.apply(e),Of.debug(`applied awareness update`);return}$.import(n),Q.debug(`imported doc change. new doc:`,$.toJSON()),o.get(Nf)!==$&&o.set(Nf,$)}),e.addEventListener(`open`,()=>{Q.debug(`websocket open`)}),e.addEventListener(`close`,e=>{Q.warn(`websocket close`,e),o.get(Nf)===$&&o.set(Nf,void 0)}),e});me()&&Ff(),$.subscribeLocalUpdates(e=>{Q.debug(`local update, sending to server`),Ff().send(new Uint8Array(e))}),Pf.addListener((e,t)=>{let n=[...e.added,...e.removed,...e.updated];t===`local`&&(Of.debug(`awareness changes`,n),Ff().send(Af(kf,Pf.encode(n))))});function If(e,t,n=``){if(Gt())return{extension:[],code:n};let r=$.getByPath(`codes/${e}`)!==void 0,i=$.getMap(`codes`).getOrCreateContainer(e,new Zi);return r||(Q.log(`initializing code for new cell`,n),i.insert(0,n)),{code:n.toString(),extension:[Lf(e),Rf(e),zf($,Pf,{get name(){return o.get(Ke)||`Anonymous`},get colorClassName(){return Df(this.name)}},()=>i,e),be($,[`codes`,e],()=>i)]}}function Lf(e){let t=(e,t)=>{let n=e.state.field(Pe).type,r=t.toString();r&&r!==n&&(Q.debug(`[incoming] setting language type: ${n} -> ${r}`),lt(e,{language:r,keepCodeAsIs:!0}))},n=(e,t)=>{let n=e.state.field(nt),r=t.toJSON();a(n,r)||e.dispatch({effects:[Ze.of(r)],annotations:[$e.of(!0)]})};return Hr.define(r=>{let i;return Promise.resolve().then(()=>{let a=$.getByPath(`languages/${e}`);if(!a){Q.error(`no language container found for cell`,e);return}zt(a instanceof Zi,`language type is not a LoroText`);let o=$.getByPath(`language_metadata/${e}`);if(!o){Q.error(`no language metadata container found for cell`,e);return}zt(o instanceof Ji,`language metadata is not a LoroMap`),t(r,a),n(r,o),i=$.subscribe(e=>{if(e.origin===`local`)return;let i=e.events.some(e=>e.target===a.id),s=e.events.some(e=>e.target===o.id);i&&t(r,a),s&&n(r,o)})}),{destroy(){i()}}})}function Rf(e){let t=$.getMap(`languages`).getOrCreateContainer(e,new Zi),n=$.getMap(`language_metadata`).getOrCreateContainer(e,new Ji);return R.updateListener.of(e=>{let r=t.toString()!==``;if(!e.docChanged&&r)return;if(!r){let r=He(e.state).type;lt(e.view,{language:r}),Q.debug(`no initial language, setting default to`,r),t.delete(0,t.length),t.insert(0,r),Q.debug(`no initial language metadata, setting default to`,e.state.field(nt));let i=e.state.field(nt);for(let e of Object.keys(i))n.set(e,i[e]);$.commit();return}let i=!1;for(let r of e.transactions)if(!r.annotation($e)){for(let e of r.effects)if(e.is(de)&&t.toString()!==e.value.type&&(Q.debug(`[outgoing] language change: ${t} -> ${e.value.type}`),t.delete(0,t.length),t.insert(0,e.value.type),i=!0),e.is(Ze)||e.is(We)){let t=e.value;e.is(We)?(Q.debug(`[outgoing] setting language metadata: `,t),n.clear()):Q.debug(`[outgoing] updating language metadata: `,t);for(let e of Object.keys(t))n.set(e,t[e]);i=!0}}i&&$.commit()})}function zf(e,t,n,r,i,a){let o=`loro:cell:${i}`;return[gf,vf(),yf(),Hr.define(i=>new Cf(i,e,n,t,r,o,a)),Hr.define(n=>new wf(n,e,t,o)),mf]}var Bf=De,Vf=e=>{let t=(0,H.c)(41),{resetOnBlur:n,placeholderText:r,initialValue:i,flexibleWidth:a,onNameChange:o,className:s}=e,c=n!==void 0&&n,l=i===void 0?null:i,u=a!==void 0&&a,{sendListFiles:d}=hi(),[f,p]=(0,V.useState)(l),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=[],t[0]=m):m=t[0];let[h,g]=(0,V.useState)(m),[_,v]=(0,V.useState)(!1),y=(0,V.useRef)(null),b=(0,V.useRef)(!1),x,S;t[1]===l?(x=t[2],S=t[3]):(x=()=>{p(l)},S=[l],t[1]=l,t[2]=x,t[3]=S),(0,V.useEffect)(x,S);let C;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{v(!0)},t[4]=C):C=t[4];let w=C,T;t[5]!==l||t[6]!==c?(T=e=>{e.relatedTarget?.closest(`.filename-input`)||(v(!1),c&&p(l))},t[5]=l,t[6]=c,t[7]=T):T=t[7];let E=T,D;t[8]===f?D=t[9]:(D=pn.dirname(f||``),t[8]=f,t[9]=D);let O=D,ee=pn.basename(f||``),k=h.filter(e=>pn.basename(e.path).startsWith(ee)),te;t[10]!==O||t[11]!==_||t[12]!==d?(te=async()=>{if(!_){g([]);return}let e=await d({path:O});g(e.files)},t[10]=O,t[11]=_,t[12]=d,t[13]=te):te=t[13];let ne;t[14]!==O||t[15]!==_?(ne=[O,_],t[14]=O,t[15]=_,t[16]=ne):ne=t[16];let{isPending:re}=Si(te,ne),A=Hf(f,h,l),j=(A||k.length>0)&&(0,U.jsxs)(st,{className:`font-mono`,children:[!re&&(0,U.jsx)(Ve,{children:`No files`}),A&&(0,U.jsxs)(ue,{variant:`success`,className:`py-2 px-3`,onSelect:()=>{A&&(b.current=!0,o(A),y.current?.blur())},children:[(0,U.jsx)(ia,{className:`w-4 h-4 mr-2`}),` `,(0,U.jsxs)(`span`,{className:`text-sm`,children:[l?`Rename to: `:`Save as: `,(0,U.jsx)(`span`,{className:`font-medium text-sm`,children:pn.basename(A)})]})]},`_rename_`),k.map(e=>{let t=e.isDirectory?`directory`:Gn(e.path),n=Kn[t];return(0,U.jsxs)(ue,{variant:e.isDirectory?`default`:`muted`,className:`py-2 px-3`,onSelect:()=>{e.isDirectory?p(`${e.path}/`):p(e.path)},children:[(0,U.jsx)(n,{className:`w-4 h-4 mr-2`}),` `,pn.basename(e.path)]},e.path)})]}),ie=Math.max(20,f?.length||r?.length||0)*10,M=_?f||``:l||``,N;t[17]!==u||t[18]!==ie?(N=u?{maxWidth:ie}:void 0,t[17]=u,t[18]=ie,t[19]=N):N=t[19];let P;t[20]===s?P=t[21]:(P=en(s,`w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60`),t[20]=s,t[21]=P);let ae;t[22]!==r||t[23]!==M||t[24]!==N||t[25]!==P?(ae=(0,U.jsx)(Bf,{children:(0,U.jsx)(Ae,{"data-testid":`dir-completion-input`,tabIndex:-1,rootClassName:`border-none justify-center px-1`,spellCheck:`false`,value:M,onKeyDown:Uf,icon:null,ref:y,onValueChange:p,placeholder:r,autoComplete:`off`,style:N,className:P})}),t[22]=r,t[23]=M,t[24]=N,t[25]=P,t[26]=ae):ae=t[26];let oe=j&&`group-focus-within:block`,se;t[27]===oe?se=t[28]:(se=en(`p-0 w-full min-w-80 max-w-80vw hidden`,oe),t[27]=oe,t[28]=se);let ce;t[29]!==j||t[30]!==se?(ce=(0,U.jsx)(ot,{side:`bottom`,className:se,portal:!1,children:j}),t[29]=j,t[30]=se,t[31]=ce):ce=t[31];let le;t[32]!==ae||t[33]!==ce?(le=(0,U.jsxs)(st,{children:[ae,ce]}),t[32]=ae,t[33]=ce,t[34]=le):le=t[34];let de;t[35]!==E||t[36]!==le?(de=(0,U.jsx)(Ee,{onFocus:w,onBlur:E,shouldFilter:!1,id:`filename-input`,className:`bg-transparent group filename-input`,children:le}),t[35]=E,t[36]=le,t[37]=de):de=t[37];let fe;return t[38]!==_||t[39]!==de?(fe=(0,U.jsx)($t,{children:(0,U.jsx)(xe,{open:_,modal:!1,children:de})}),t[38]=_,t[39]=de,t[40]=fe):fe=t[40],fe};function Hf(e,t,n){if(e&&!e.endsWith(`/`)&&((fe(`markdown`)?new Set([`py`,`md`,`markdown`,`qmd`]):new Set([`py`])).has(pn.extension(e))||(e=e.endsWith(`.`)?`${e}py`:e.endsWith(`.p`)?`${e}y`:`${e}.py`),!t.some(t=>t.path===e||pn.basename(t.path)===e)&&!(n&&(n===e||pn.basename(n)===e))))return e}function Uf(e){e.key===`Escape`&&e.currentTarget.blur()}var Wf=e=>{let t=(0,H.c)(33),n=()=>{on(new Blob([r()],{type:`text/plain`}),`${e.proposedName}.json`)},r=c(qf),i;t[0]!==n||t[1]!==e?(i=t=>{t.preventDefault(),n(),e.closeModal()},t[0]=n,t[1]=e,t[2]=i):i=t[2];let a;t[3]===e?a=t[4]:(a=t=>{t.key===`Escape`&&e.closeModal()},t[3]=e,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,U.jsx)(cr,{className:`text-accent-foreground mb-6`,children:`Download unsaved changes?`}),t[5]=o):o=t[5];let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s={wordBreak:`break-word`},t[6]=s):s=t[6];let l,u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,U.jsx)(`p`,{children:`This app has unsaved changes. To recover:`}),u={paddingBottom:`10px`},t[7]=l,t[8]=u):(l=t[7],u=t[8]);let d;t[9]===e.proposedName?d=t[10]:(d=(0,U.jsxs)(`li`,{style:u,children:[`Click the "Download" button. This will download a file called\xA0`,(0,U.jsxs)(`code`,{children:[e.proposedName,`.json`]}),`. This file contains your code.`]}),t[9]=e.proposedName,t[10]=d);let f;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(f={paddingBottom:`10px`},t[11]=f):f=t[11];let p;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(p={display:`block`,padding:`10px`},t[12]=p):p=t[12];let m;t[13]===e.proposedName?m=t[14]:(m=(0,U.jsxs)(`code`,{style:p,children:[`marimo recover `,e.proposedName,`.json `,`>`,` `,e.proposedName,`.py`]}),t[13]=e.proposedName,t[14]=m);let h;t[15]===e.proposedName?h=t[16]:(h=(0,U.jsxs)(`code`,{children:[e.proposedName,`.py`]}),t[15]=e.proposedName,t[16]=h);let g;t[17]!==h||t[18]!==m?(g=(0,U.jsxs)(`li`,{style:f,children:[`In your terminal, type`,m,`to overwrite `,h,` with the recovered changes.`]}),t[17]=h,t[18]=m,t[19]=g):g=t[19];let _;t[20]!==g||t[21]!==d?(_=(0,U.jsx)(ar,{className:`markdown wrap-break-word`,style:s,children:(0,U.jsxs)(`div`,{className:`prose dark:prose-invert`,children:[l,(0,U.jsxs)(`ol`,{children:[d,g]})]})}),t[20]=g,t[21]=d,t[22]=_):_=t[22];let v;t[23]===e.closeModal?v=t[24]:(v=(0,U.jsx)(un,{"aria-label":`Cancel`,variant:`secondary`,"data-testid":`cancel-recovery-button`,onClick:e.closeModal,children:`Cancel`}),t[23]=e.closeModal,t[24]=v);let y;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,U.jsx)(un,{"data-testid":`download-recovery-button`,"aria-label":`Download`,variant:`default`,type:`submit`,children:`Download`}),t[25]=y):y=t[25];let b;t[26]===v?b=t[27]:(b=(0,U.jsxs)(sr,{children:[v,y]}),t[26]=v,t[27]=b);let x;return t[28]!==i||t[29]!==a||t[30]!==_||t[31]!==b?(x=(0,U.jsx)(or,{className:`w-fit`,children:(0,U.jsxs)(`form`,{onSubmit:i,onKeyDown:a,children:[o,_,b]})}),t[28]=i,t[29]=a,t[30]=_,t[31]=b,t[32]=x):x=t[32],x},Gf=e=>{let t=(0,H.c)(12),{filename:n,needsSave:r}=e,{openModal:i,closeModal:a}=Jn(),o;t[0]===n?o=t[1]:(o=n===null?`app`:pn.basename(n).split(`.`)[0],t[0]=n,t[1]=o);let s=o,c;t[2]!==a||t[3]!==r||t[4]!==i||t[5]!==s?(c=()=>{r&&i((0,U.jsx)(Wf,{proposedName:s,closeModal:a}))},t[2]=a,t[3]=r,t[4]=i,t[5]=s,t[6]=c):c=t[6];let l=c;_n(`global.save`,l);let u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=Mi(`global.save`),t[7]=u):u=t[7];let d=r?`yellow`:`gray`,f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,U.jsx)(tr,{strokeWidth:1.5,size:18}),t[8]=f):f=t[8];let p;return t[9]!==l||t[10]!==d?(p=(0,U.jsx)(cn,{content:u,children:(0,U.jsx)(na,{onClick:l,id:`save-button`,"aria-label":`Save`,className:`rectangle`,color:d,children:f})}),t[9]=l,t[10]=d,t[11]=p):p=t[11],p};function Kf(e){return{id:e.id,name:e.name,code:e.code,code_hash:null,config:{column:0,...e.config}}}function qf(){let e=Me(),t=ye(e),n={version:`1`,metadata:{marimo_version:Qt()},cells:t.map(Kf)};return JSON.stringify(n,null,2)}var Jf=r(void 0),Yf=r(e=>{let t=e(Jf);return Xf({state:e(he),layout:e(Zn),lastSavedNotebook:t})});function Xf({state:e,layout:t,lastSavedNotebook:n}){if(!n)return!1;let{cellIds:r,cellData:i}=e,o=r.inOrderIds.map(e=>i[e]),s=o.map(e=>e.code),c=o.map(e=>e.config),l=o.map(e=>e.name);return!ni(s,n.codes)||!ni(l,n.names)||!a(c,n.configs)||!a(t.selectedLayout,n.layout.selectedLayout)||!a(t.layoutData,n.layout.layoutData)}function Zf(e){let t=(0,H.c)(21),{codes:n,cellConfigs:r,config:i,connStatus:a,cellNames:o,needsSave:s,kioskMode:c,onSave:l}=e,u=(0,V.useRef)(null),d;t[0]===n?d=t[1]:(d=n.join(`:`),t[0]=n,t[1]=d);let f=d,p;t[2]===r?p=t[3]:(p=r.map(Qf).join(`:`),t[2]=r,t[3]=p);let m=p,h;t[4]===o?h=t[5]:(h=o.join(`:`),t[4]=o,t[5]=h);let g=h,_;t[6]!==i||t[7]!==a.state||t[8]!==c||t[9]!==s||t[10]!==l?(_=()=>{if(!c)return i.autosave===`after_delay`&&(u.current!==null&&clearTimeout(u.current),s&&a.state===qt.OPEN&&(u.current=setTimeout(l,i.autosave_delay))),()=>{u.current!==null&&clearTimeout(u.current)}},t[6]=i,t[7]=a.state,t[8]=c,t[9]=s,t[10]=l,t[11]=_):_=t[11];let v;t[12]!==m||t[13]!==g||t[14]!==f||t[15]!==i||t[16]!==a.state||t[17]!==c||t[18]!==s||t[19]!==l?(v=[f,m,g,i,a.state,l,c,s],t[12]=m,t[13]=g,t[14]=f,t[15]=i,t[16]=a.state,t[17]=c,t[18]=s,t[19]=l,t[20]=v):v=t[20],(0,V.useEffect)(_,v)}function Qf(e){return JSON.stringify(e)}var $f=Promise.resolve();function ep(e){let t=$f.then(e);return $f=t.then(()=>void 0,()=>void 0),t}var tp=e=>{let t=(0,H.c)(15),{kioskMode:n}=e,r=Ai(),a=i(Yf),o=i(Jt).state===qt.CLOSED,{saveOrNameNotebook:s,saveIfNotebookIsPersistent:c}=np(),l;t[0]!==n||t[1]!==c?(l={onSave:c,kioskMode:n},t[0]=n,t[1]=c,t[2]=l):l=t[2],sp(l),ra();let u;t[3]===a?u=t[4]:(u=e=>{if(a)return e.preventDefault(),e.returnValue=`You have unsaved changes. Are you sure you want to leave?`,e.returnValue},t[3]=a,t[4]=u),Rt(window,`beforeunload`,u);let d;t[5]===s?d=t[6]:(d=e=>{e.preventDefault(),e.stopPropagation(),s()},t[5]=s,t[6]=d);let f=d;if(_n(`global.save`,s),o){let e;return t[7]!==r||t[8]!==a?(e=(0,U.jsx)(Gf,{filename:r,needsSave:a}),t[7]=r,t[8]=a,t[9]=e):e=t[9],e}let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=Mi(`global.save`),t[10]=p):p=t[10];let m=a?`yellow`:`hint-green`,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,U.jsx)(tr,{strokeWidth:1.5,size:18}),t[11]=h):h=t[11];let g;return t[12]!==f||t[13]!==m?(g=(0,U.jsx)(cn,{content:p,children:(0,U.jsx)(na,{"data-testid":`save-button`,id:`save-button`,shape:`rectangle`,color:m,onClick:f,children:h})}),t[12]=f,t[13]=m,t[14]=g):g=t[14],g};function np(){let e=(0,H.c)(21),{sendSave:t}=hi(),{openModal:r,closeModal:i,openAlert:a}=Jn(),o=l(Jf),s=ji(),u=n(),d;e[0]!==a||e[1]!==t||e[2]!==o||e[3]!==u?(d=(e,n)=>ep(async()=>{let r=u.get(Jt),i=u.get(At);if(u.get(Ht))return;if(r.state!==qt.OPEN){a(`Failed to save notebook: not connected to a kernel.`);return}if(It.log(`saving to `,e),n&&i.format_on_save&&(It.log(`formatting notebook (onSave)`),await le()),ye(Me()).length===0)return;let s=await rt(async()=>{let n=Me(),r=ye(n),i=r.map(ap),a=r.map(ip),o=r.map(rp),s=Ce(n),c=u.get(Zn);return await t({cellIds:i,codes:a,names:o,filename:e,configs:s,layout:mn(),persist:!0}),{names:o,codes:a,configs:s,layout:c}});o(s)}),e[0]=a,e[1]=t,e[2]=o,e[3]=u,e[4]=d):d=e[4];let f=c(d),p;e[5]!==f||e[6]!==u?(p=e=>{let t=e!==void 0&&e,n=u.get(gt),r=u.get(Jt);op(n)&&r.state===qt.OPEN&&f(n,t)},e[5]=f,e[6]=u,e[7]=p):p=e[7];let m=c(p),h;e[8]!==f||e[9]!==s?(h=e=>{s(e).then(e=>{e!==null&&f(e,!0)})},e[8]=f,e[9]=s,e[10]=h):h=e[10];let g=h,_;e[11]!==i||e[12]!==g||e[13]!==r||e[14]!==m||e[15]!==u?(_=()=>{let e=u.get(gt),t=u.get(Jt);m(!0),!op(e)&&t.state!==qt.CLOSED&&r((0,U.jsx)(up,{onClose:i,onSave:g}))},e[11]=i,e[12]=g,e[13]=r,e[14]=m,e[15]=u,e[16]=_):_=e[16];let v=c(_),y;return e[17]!==m||e[18]!==f||e[19]!==v?(y={saveOrNameNotebook:v,saveIfNotebookIsPersistent:m,saveNotebook:f},e[17]=m,e[18]=f,e[19]=v,e[20]=y):y=e[20],y}function rp(e){return e.name}function ip(e){return e.code}function ap(e){return e.id}function op(e){return e!==null&&!e.startsWith(`/tmp/`)&&!e.startsWith(`/var/folders`)&&!e.includes(`AppData\\Local\\Temp`)}function sp(e){let n=(0,H.c)(14),r=i(At),a=C(),[o]=t(Jt),s=i(Yf),c,l;if(n[0]!==a){let e=ye(a);c=e.map(lp),l=e.map(cp),n[0]=a,n[1]=c,n[2]=l}else c=n[1],l=n[2];let u=l,d;n[3]===a?d=n[4]:(d=Ce(a),n[3]=a,n[4]=d);let f=d,p;n[5]!==r||n[6]!==u||n[7]!==c||n[8]!==f||n[9]!==o||n[10]!==s||n[11]!==e.kioskMode||n[12]!==e.onSave?(p={onSave:e.onSave,needsSave:s,codes:c,cellConfigs:f,cellNames:u,connStatus:o,config:r,kioskMode:e.kioskMode},n[5]=r,n[6]=u,n[7]=c,n[8]=f,n[9]=o,n[10]=s,n[11]=e.kioskMode,n[12]=e.onSave,n[13]=p):p=n[13],Zf(p)}function cp(e){return e.name}function lp(e){return e.code}var up=e=>{let t=(0,H.c)(17),{onClose:n,onSave:r}=e,[i,a]=(0,V.useState)(),o;t[0]!==n||t[1]!==r?(o=e=>{a(e),e.trim()&&(r(e),n())},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,U.jsx)(cr,{children:`Save notebook`}),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,U.jsx)(an,{className:`text-md pt-6 px-1`,children:`Save as`}),t[4]=l):l=t[4];let u;t[5]===s?u=t[6]:(u=(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[l,(0,U.jsx)(Vf,{onNameChange:s,placeholderText:`filename`,className:`missing-filename`})]}),t[5]=s,t[6]=u);let d;t[7]===n?d=t[8]:(d=(0,U.jsx)(un,{"data-testid":`cancel-save-dialog-button`,"aria-label":`Cancel`,variant:`secondary`,onClick:n,children:`Cancel`}),t[7]=n,t[8]=d);let f=!i,p;t[9]===f?p=t[10]:(p=(0,U.jsx)(un,{"data-testid":`submit-save-dialog-button`,"aria-label":`Save`,variant:`default`,disabled:f,type:`submit`,children:`Save`}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,U.jsxs)(sr,{children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==u||t[15]!==m?(h=(0,U.jsxs)(or,{children:[c,u,m]}),t[14]=u,t[15]=m,t[16]=h):h=t[16],h};function dp(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var fp={modified:{doc:``},original:{doc:``}},pp=(0,V.createContext)(fp);function mp(e,t){return z({},e,t,{modified:z({},e.modified,t.modified),original:z({},e.original,t.original)})}var hp=()=>(0,V.useContext)(pp),gp=e=>{var t=e.children,n=e.theme,r=(0,V.useReducer)(mp,z({},fp,{theme:n})),i=r[0],a=r[1];return(0,V.useEffect)(()=>a({theme:n}),[n]),(0,U.jsx)(pp.Provider,{value:z({},i,{dispatch:a}),children:t})},_p=[`extensions`,`value`,`selection`,`onChange`],vp=e=>{var t=e.extensions,n=t===void 0?[]:t,r=e.value,i=e.selection,a=e.onChange,o=Ei(e,_p),s=hp(),c=s.theme,l=s.dispatch,u=Fi(z({},o,{theme:c}));return(0,V.useEffect)(()=>l({original:{doc:r,selection:i,extensions:[...u,...n]},originalExtension:{onChange:a,option:o,extension:[n]}}),[e]),null};vp.displayName=`CodeMirrorMerge.Original`;var yp=[`extensions`,`value`,`selection`,`onChange`],bp=e=>{var t=e.extensions,n=t===void 0?[]:t,r=e.value,i=e.selection,a=e.onChange,o=Ei(e,yp),s=hp(),c=s.theme,l=s.dispatch,u=Fi(z({},o,{theme:c}));return(0,V.useEffect)(()=>{l({modified:{doc:r,selection:i,extensions:[...u,...n]},modifiedExtension:{onChange:a,option:o,extension:[n]}})},[e]),null};bp.displayName=`CodeMirrorMerge.Modified`;var xp=[`className`,`children`,`orientation`,`revertControls`,`highlightChanges`,`gutter`,`collapseUnchanged`,`destroyRerender`,`renderRevertControl`,`diffConfig`,`root`],Sp=[`modified`,`modifiedExtension`,`original`,`originalExtension`,`theme`,`dispatch`],Cp=V.forwardRef((e,t)=>{var n=e.className,r=e.children,i=e.orientation,a=e.revertControls,o=e.highlightChanges,s=e.gutter,c=e.collapseUnchanged,l=e.destroyRerender,u=l===void 0||l,d=e.renderRevertControl,f=e.diffConfig,p=e.root,m=Ei(e,xp),h=hp(),g=h.modified,_=h.modifiedExtension,v=h.original,y=h.originalExtension,b=h.theme,x=h.dispatch,S=Ei(h,Sp),C=(0,V.useRef)(null),w=(0,V.useRef)(),T={orientation:i,revertControls:a,highlightChanges:o,gutter:s,collapseUnchanged:c,renderRevertControl:d,diffConfig:f,root:p};(0,V.useImperativeHandle)(t,()=>({container:C.current,view:w.current,modified:g,original:v,config:z({a:v,b:g,parent:C.current},T)}),[C,w,g,v,T]);var E=R.updateListener.of(e=>{if(e.docChanged&&typeof y?.onChange==`function`){var t=e.state.doc.toString();y?.onChange(t,e)}}),D=R.updateListener.of(e=>{if(e.docChanged&&typeof _?.onChange==`function`){var t=e.state.doc.toString();_?.onChange(t,e)}});return(0,V.useEffect)(()=>{!w.current&&C.current&&y&&_&&(w.current=new Ii(z({a:z({},v,{extensions:[...y?.extension||[],...Fi(z({},y?.option,{theme:b})),E]}),b:z({},g,{extensions:[..._?.extension||[],...Fi(z({},_?.option,{theme:b})),D]}),parent:C.current},T)),x({view:w.current}))},[w,C,y,_]),(0,V.useEffect)(()=>{if(v&&v.doc&&w.current){var e=w.current?.a.state.doc.toString();if(e!==v.doc){var t;(t=w.current)==null||t.a.dispatch({changes:{from:0,to:e.length,insert:v.doc||``}})}}if(g&&g.doc&&w.current){var n=w.current?.b.state.doc.toString();if(n!==g.doc){var r;(r=w.current)==null||r.b.dispatch({changes:{from:0,to:n.length,insert:g.doc||``}})}}if(u&&w.current){var i=w.current.a.state.selection.ranges[0].from,a=w.current.b.state.selection.ranges[0].from;w.current.destroy(),w.current=new Ii(z({a:z({},v,{extensions:[...y?.extension||[],...Fi(z({},y?.option,{theme:b}))]}),b:z({},g,{extensions:[..._?.extension||[],...Fi(z({},_?.option,{theme:b}))]}),parent:C.current},T)),i&&(w.current.a.focus(),w.current.a.dispatch({selection:{anchor:i,head:i}})),a&&(w.current.b.focus(),w.current.b.dispatch({selection:{anchor:a,head:a}}))}},[w,b,C.current,v,g,y,_,u]),(0,V.useEffect)(()=>()=>w.current&&w.current.destroy(),[]),(0,V.useEffect)(()=>{if(w.current){var e={};S.orientation!==i&&(e.orientation=i),S.revertControls!==a&&(e.revertControls=a),S.highlightChanges!==o&&(e.highlightChanges=o),S.gutter!==s&&(e.gutter=s),S.collapseUnchanged!==c&&(e.collapseUnchanged=c),S.renderRevertControl!==d&&(e.collapseUnchanged=c),Object.keys(e).length&&x&&w.current&&(w.current.reconfigure(z({},e)),x(z({},e)))}},[x,w,i,a,o,s,c,d]),(0,U.jsx)(`div`,z({ref:C,className:`cm-merge-theme`+(n?` `+n:``)},m,{children:r}))});Cp.displayName=`CodeMirrorMerge.Internal`;var wp=[`theme`],Tp=V.forwardRef((e,t)=>{var n=e.theme,r=Ei(e,wp);return(0,U.jsx)(gp,{theme:n,children:(0,U.jsx)(Cp,z({},r,{ref:t}))})});Tp.Original=vp,Tp.Modified=bp,Tp.displayName=`CodeMirrorMerge`;var Ep=Tp.Original,Dp=Tp.Modified,Op=[se(),R.lineWrapping],kp=({cellId:e,aiCompletionCell:n,className:r,onChange:i,currentLanguageAdapter:a,currentCode:o,declineChange:s,acceptChange:c,runCell:l,outputArea:u,children:d})=>{let[p,m]=(0,V.useState)(!1),[h,g]=t(Oi),_=(0,V.useId)(),v=Yt(),{initialPrompt:y,triggerImmediately:x,cellId:C}=n??{},w=C===e,T=An(e),E;T?.type===`update_cell`&&(E=T.previousCode);let[D,O]=(0,V.useState)(``),[ee,k]=(0,V.useState)(y??``),te=V.useMemo(()=>new Tn({api:v.getAiURL(`completion`).toString(),headers:()=>v.headers(),prepareSendMessagesRequest:({body:e,id:t})=>({body:{...e,id:t}})}),[v]),{sendMessage:ne,stop:re,status:A}=Un({throttle:100,transport:te,onData:e=>{if(e.type===En){let t=On.parse(e.data);O(t.code.trimEnd())}},onError:e=>{O(``),ur({title:`Completion failed`,description:Ti(e)})},onFinish:({isAbort:e,isDisconnect:t,isError:n,finishReason:r})=>{(e||t||n||r!==`stop`)&&O(``)}}),j=A===`submitted`||A===`streaming`,ie=(0,V.useCallback)(()=>{O(``),re()},[re]),M=(0,V.useCallback)(async e=>{await re(),O(``);let t={...Mn({input:e}),prompt:e,includeOtherCode:h?ce(o):``,code:o,language:a??`python`};await ne({text:e},{body:t})},[o,a,h,ne,re]),N=(0,V.useCallback)(()=>{M(ee)},[M,ee]),P=V.useRef(null),ae=(0,V.useCallback)(()=>{x&&!j&&y&&M(y)},[x]);(0,V.useEffect)(()=>{w&&(S(()=>{let e=P.current;return e?.view?(e.view.focus(),ae(),!0):!1},{retries:3,delay:100,initialDelay:100}),b(P.current?.view))},[w,ae]),(0,V.useEffect)(()=>{w&&k(y||``)},[w,y,k]);let{theme:oe}=yi(),se=()=>{c(D),O(``)},le=()=>{ie(),m(!0),P.current?.view?.focus()},ue=w&&x&&(D||j);u??=`below`;let de=w&&(!x||p),fe=(0,U.jsx)(`div`,{className:en(`w-full bg-(--cm-background) flex justify-center transition-all duration-300 ease-in-out overflow-hidden`,ue?`max-h-20 opacity-100 translate-y-0`:`max-h-0 opacity-0 -translate-y-2`),children:(0,U.jsx)(Ap,{status:j?`loading`:`generated`,onAccept:se,onReject:le,showInputPrompt:p,setShowInputPrompt:m,runCell:l,className:`mt-4 mb-3 w-lg`})}),pe=(e,t)=>(0,U.jsxs)(Tp,{className:`cm`,theme:oe,children:[(0,U.jsx)(Ep,{onChange:i,value:e,extensions:Op}),(0,U.jsx)(Dp,{value:t,editable:!1,readOnly:!0,extensions:Op})]}),me=()=>{if(D&&w)return pe(o,D);if(!D&&E)return pe(E,o)},he=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ln,{isLoading:j,onAccept:se,size:`xs`,multipleCompletions:!1,label:Bn.accept,acceptShortcut:`Mod-↵`,runCell:l}),(0,U.jsx)(zn,{onDecline:le,size:`xs`,multipleCompletions:!1,label:Bn.decline,declineShortcut:`Shift-Mod-Delete`})]});return(0,U.jsxs)(`div`,{"data-ai-input-open":de,className:en(`flex flex-col w-full rounded-[inherit]`,r),children:[(0,U.jsx)(`div`,{className:en(`flex items-center gap-2 px-3 transition-all rounded-[inherit] rounded-b-none duration-300`,de&&`max-h-[400px] border-b min-h-11 visible`,!de&&`max-h-0 min-h-0 invisible`),children:w&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ye,{className:`text-(--blue-10) shrink-0`,size:16}),(0,U.jsx)(Rn,{inputRef:P,className:`h-full my-0 py-2 flex items-center`,onClose:()=>{ie(),s()},value:ee,onChange:k,onSubmit:()=>{j||(P.current?.view&&jn(P.current.view),N())},onKeyDown:Vn({handleAcceptCompletion:se,handleDeclineCompletion:le,isLoading:j,hasCompletion:D.trim().length>0})}),(0,U.jsxs)(`div`,{className:`-mr-1.5 py-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-end gap-0.5`,children:[(0,U.jsx)(In,{isLoading:j,onStop:ie,onSendClick:N,isEmpty:!ee.trim(),showStopLabel:!0}),(0,U.jsx)(Fn,{handleAddContext:()=>Hn(P),isLoading:j}),(0,U.jsx)(bn,{triggerClassName:`h-7 text-xs`,iconSize:`small`,forRole:`edit`,displayIconOnly:!0,placeholder:`Edit model`})]}),D&&(0,U.jsx)(`div`,{className:`mt-1 flex items-center gap-1`,children:he})]}),(0,U.jsx)(`div`,{className:`h-full w-px bg-border mx-2`}),(0,U.jsx)(cn,{content:`Include code from other cells`,children:(0,U.jsxs)(`div`,{className:`flex flex-row items-start gap-1 overflow-hidden`,children:[(0,U.jsx)(f,{"data-testid":`include-other-cells-checkbox`,id:_,checked:h,onCheckedChange:e=>g(!!e)}),(0,U.jsx)(an,{htmlFor:_,className:`text-muted-foreground text-xs whitespace-nowrap ellipsis`,children:`All code`})]})}),(0,U.jsx)(un,{"data-testid":`decline-completion-button`,variant:`text`,size:`icon`,disabled:j,onClick:()=>{ie(),s()},children:(0,U.jsx)(Cn,{className:`text-(--red-10)`,size:16})})]})}),u===`above`&&fe,me(),(!D||!w)&&!E&&d,u===`below`&&fe]})},Ap=e=>{let t=(0,H.c)(27),{status:n,onAccept:r,onReject:i,className:a,showInputPrompt:o,setShowInputPrompt:s,runCell:c}=e,l=n===`loading`,u;t[0]===a?u=t[1]:(u=en(`flex flex-row items-center gap-6 rounded-md py-2 px-2.5 text-sm border border-border bg-(--gray-2) dark:bg-(--gray-3)`,a),t[0]=a,t[1]=u);let d;t[2]===l?d=t[3]:(d=l?(0,U.jsx)(Yn,{className:`animate-spin text-blue-600 mb-px`,size:15,strokeWidth:2,"aria-label":`Generating fix`}):(0,U.jsx)(wn,{className:`text-green-600 mb-px`,size:15,strokeWidth:2,"aria-label":`Fix generated`}),t[2]=l,t[3]=d);let f=l?`Generating fix...`:`Showing fix`,p;t[4]===f?p=t[5]:(p=(0,U.jsx)(`p`,{className:`transition-opacity duration-200 text-muted-foreground`,children:f}),t[4]=f,t[5]=p);let m;t[6]!==d||t[7]!==p?(m=(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-2`,children:[d,p]}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,U.jsx)(an,{htmlFor:`show-input-prompt`,className:`text-muted-foreground text-xs whitespace-nowrap ellipsis`,children:`Show prompt`}),t[9]=h):h=t[9];let g;t[10]!==s||t[11]!==o?(g=(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-1`,children:[h,(0,U.jsx)(sn,{checked:o,onCheckedChange:s,size:`xs`})]}),t[10]=s,t[11]=o,t[12]=g):g=t[12];let _;t[13]!==l||t[14]!==r||t[15]!==c?(_=(0,U.jsx)(Ln,{isLoading:l,onAccept:r,size:`xs`,label:Bn.accept,runCell:c}),t[13]=l,t[14]=r,t[15]=c,t[16]=_):_=t[16];let v;t[17]===i?v=t[18]:(v=(0,U.jsx)(zn,{onDecline:i,size:`xs`,label:Bn.decline}),t[17]=i,t[18]=v);let y;t[19]!==_||t[20]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-2 ml-auto`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;return t[22]!==u||t[23]!==y||t[24]!==m||t[25]!==g?(b=(0,U.jsxs)(`div`,{className:u,children:[m,g,y]}),t[22]=u,t[23]=y,t[24]=m,t[25]=g,t[26]=b):b=t[26],b},jp=`web application/x-marimo-cell`,Mp=xt({cells:wt(xt({code:yt(),name:yt().optional(),config:xt({column:Ct([bt(),Tt()]).optional(),disabled:vt().optional(),hide_code:vt().optional(),expand_output:vt().optional()}).optional()})),version:St(`1.0`)});function Np(e){return e.map(e=>e.code).join(`
|
|
39
|
+
`),df=!0);let r=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:e,protocols:n}),this._ws=n?new r(e,n):new r(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new nf.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new nf.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(e,t),this._handleClose(new nf.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=uf.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),rf(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>{this._ws?.send(e)}),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(lf(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(lf(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(lf(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._options.shouldReconnectOnClose&&!this._options.shouldReconnectOnClose(e)&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(lf(e))};_removeListeners(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError),this._ws.addEventListener(`error`,ff))}_addListeners(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},mf=R.baseTheme({".loro-cursor":{position:`absolute`,width:`2px`,display:`inline-block`,height:`1.2em`},".loro-cursor::before":{position:`absolute`,top:`1.3em`,left:`0`,content:`var(--rtc-name)`,padding:`2px 6px`,fontSize:`12px`,borderRadius:`3px`,whiteSpace:`nowrap`,userSelect:`none`,backgroundColor:`inherit`,opacity:`0.7`},".loro-selection":{opacity:`0.5`}});Gr.define();var hf=I.define(),gf=fr.define({create(){return{remoteCursors:new Map,isCheckout:!1}},update(e,t){for(let n of t.effects)if(n.is(hf))switch(n.value.type){case`update`:{let{peer:t,user:r,cursor:i}=n.value;e.remoteCursors.set(t,{uid:t,cursor:i,user:r});break}case`delete`:e.remoteCursors.delete(n.value.peer);break;case`checkout`:e.isCheckout=n.value.checkout}return e}}),_f=e=>{let t=e.transactions.flatMap(e=>e.effects).filter(e=>e.is(hf));return e.docChanged||e.viewportChanged||t.length>0},vf=()=>mr({above:!0,class:`loro-cursor-layer`,update:_f,markers:e=>{let{remoteCursors:t,isCheckout:n}=e.state.field(gf);return n?[]:[...t.values()].flatMap(t=>{let n=Ar.cursor(t.cursor.anchor);return bf.createCursor(e,n,t.user?.name||`unknown`,t.user?.colorClassName||``)})}}),yf=()=>mr({above:!1,class:`loro-selection-layer`,update:_f,markers:e=>{let{remoteCursors:t,isCheckout:n}=e.state.field(gf);return n?[]:[...t.entries()].filter(([,e])=>e.cursor.head!==void 0&&e.cursor.anchor!==e.cursor.head).flatMap(([,t])=>{let n=Ar.range(t.cursor.anchor,t.cursor.head);return Rr.forRange(e,`loro-selection ${t.user?.colorClassName||``}`,n)})}}),bf=class e{left;top;height;name;colorClassName;constructor(e,t,n,r,i){this.left=e,this.top=t,this.height=n,this.name=r,this.colorClassName=i}draw(){let e=document.createElement(`div`);return this.adjust(e),e}update(e){return this.adjust(e),!0}adjust(e){e.style.left=`${this.left}px`,e.style.top=`${this.top}px`,e.style.height=`${this.height}px`,e.className=`loro-cursor ${this.colorClassName}`,e.style.setProperty(`--rtc-name`,`"${this.name}"`)}eq(e){return this.left===e.left&&this.top===e.top&&this.height===e.height&&this.name===e.name}static createCursor(t,n,r,i){let a=e.calculateAbsoluteCursorPosition(n,t);if(!a)return[];let o=t.scrollDOM.getBoundingClientRect(),s=(t.textDirection===Br.LTR?o.left:o.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,c=o.top-t.scrollDOM.scrollTop;return[new e(a.left-s,a.top-c,a.bottom-a.top,r,i)]}static calculateAbsoluteCursorPosition(e,t){let n=Math.max(0,Math.min(t.state.doc.length,e.anchor));return t.coordsAtPos(n,e.assoc||1)}},xf=(e,t,n,r)=>{let i=[],{updated:a,added:o}=n;for(let n of[...a,...o]){let a=Sf(e,t,n,r);a&&i.push(a)}return i},Sf=(e,t,n,r)=>{let i=t.getAllStates()[n];if(!i||n===e.peerIdStr||i.scopeId!==r)return;if(i.type===`delete`)return hf.of({type:`delete`,peer:i.uid,scopeId:i.scopeId});let a=Xi.decode(i.cursor.anchor),o=e.getCursorPos(a)?.offset??0,s=o;if(i.cursor.head){let t=Xi.decode(i.cursor.head);s=e.getCursorPos(t)?.offset??0}return hf.of({type:`update`,peer:i.uid,scopeId:i.scopeId,cursor:{anchor:o,head:s},user:i.user})},Cf=class{sub;view;doc;user;awareness;getTextFromDoc;scopeId;getUserId;constructor(e,t,n,r,i,a,o){this.view=e,this.doc=t,this.user=n,this.awareness=r,this.getTextFromDoc=i,this.scopeId=a,this.getUserId=o,this.sub=this.doc.subscribe(e=>{if(e.by===`local`){let e=[];for(let t of this.awareness.peers()){let n=Sf(this.doc,this.awareness,t,this.scopeId);n&&e.push(n)}this.view.dispatch({effects:e})}else e.by===`checkout`&&this.view.dispatch({effects:[hf.of({type:`checkout`,checkout:this.doc.isDetached()})]})})}update(e){if(!e.selectionSet&&!e.focusChanged&&!e.docChanged)return;let t=e.state.selection.main;if(this.view.hasFocus&&!this.doc.isDetached()){let e=Tf({doc:this.doc,getTextFromDoc:this.getTextFromDoc,anchor:t.anchor,head:t.head});this.awareness.setLocalState({type:`update`,uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId,cursor:e,user:this.user})}else this.awareness.setLocalState({type:`delete`,uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}destroy(){this.sub?.(),this.awareness.setLocalState({type:`delete`,uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}},wf=class{_awarenessListener;view;doc;awareness;scopeId;constructor(e,t,n,r){this.view=e,this.doc=t,this.awareness=n,this.scopeId=r;let i=async(e,t)=>{t!==`local`&&this.view.dispatch({effects:xf(this.doc,this.awareness,e,this.scopeId)})};this._awarenessListener=i,this.awareness.addListener(i)}destroy(){this._awarenessListener&&this.awareness.removeListener(this._awarenessListener)}},Tf=({doc:e,getTextFromDoc:t,anchor:n,head:r})=>{n===r&&(r=void 0);let i=t(e).getCursor(n)?.encode();if(!i)throw Error(`cursor head not found`);let a;return r!==void 0&&(a=t(e).getCursor(r)?.encode()),{anchor:i,head:a}},Ef=[`bg-(--amber-6)`,`bg-(--blue-6)`,`bg-(--crimson-6)`,`bg-(--cyan-6)`,`bg-(--grass-6)`,`bg-(--gray-6)`,`bg-(--green-6)`,`bg-(--lime-6)`,`bg-(--orange-6)`,`bg-(--purple-6)`,`bg-(--red-6)`,`bg-(--sage-6)`,`bg-(--sky-6)`,`bg-(--slate-6)`],Df=e=>{if(typeof e==`string`){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t=Math.trunc(t);return Ef[Math.abs(t)%Ef.length]}return Ef[e%Ef.length]},Q=It.get(`rtc`),Of=Q.get(`awareness`).disabled(),kf=`awareness:`;function Af(e,t){let n=new TextEncoder().encode(e);return new Uint8Array([...n,...t])}function jf(e,t){return new TextDecoder().decode(e.slice(0,t.length))===t}function Mf(e,t){return e.slice(t.length)}var Nf=r(void 0),$=new qi,Pf=new Xd($.peerIdStr),Ff=ri(()=>{Q.debug(`creating websocket`);let e=new pf(Zt().getWsSyncURL(Ut()).toString(),void 0,{maxRetries:10,debug:!1,startClosed:!0,connectionTimeout:1e4});return Promise.resolve().then(async()=>{await Kt(),Vt()===`edit`&&e.reconnect()}),e.addEventListener(`message`,async e=>{let t=await e.data.arrayBuffer(),n=new Uint8Array(t);if(jf(n,kf)){let e=Mf(n,kf);Pf.apply(e),Of.debug(`applied awareness update`);return}$.import(n),Q.debug(`imported doc change. new doc:`,$.toJSON()),o.get(Nf)!==$&&o.set(Nf,$)}),e.addEventListener(`open`,()=>{Q.debug(`websocket open`)}),e.addEventListener(`close`,e=>{Q.warn(`websocket close`,e),o.get(Nf)===$&&o.set(Nf,void 0)}),e});me()&&Ff(),$.subscribeLocalUpdates(e=>{Q.debug(`local update, sending to server`),Ff().send(new Uint8Array(e))}),Pf.addListener((e,t)=>{let n=[...e.added,...e.removed,...e.updated];t===`local`&&(Of.debug(`awareness changes`,n),Ff().send(Af(kf,Pf.encode(n))))});function If(e,t,n=``){if(Gt())return{extension:[],code:n};let r=$.getByPath(`codes/${e}`)!==void 0,i=$.getMap(`codes`).getOrCreateContainer(e,new Zi);return r||(Q.log(`initializing code for new cell`,n),i.insert(0,n)),{code:n.toString(),extension:[Lf(e),Rf(e),zf($,Pf,{get name(){return o.get(Ke)||`Anonymous`},get colorClassName(){return Df(this.name)}},()=>i,e),be($,[`codes`,e],()=>i)]}}function Lf(e){let t=(e,t)=>{let n=e.state.field(Pe).type,r=t.toString();r&&r!==n&&(Q.debug(`[incoming] setting language type: ${n} -> ${r}`),lt(e,{language:r,keepCodeAsIs:!0}))},n=(e,t)=>{let n=e.state.field(nt),r=t.toJSON();a(n,r)||e.dispatch({effects:[Ze.of(r)],annotations:[$e.of(!0)]})};return Hr.define(r=>{let i;return Promise.resolve().then(()=>{let a=$.getByPath(`languages/${e}`);if(!a){Q.error(`no language container found for cell`,e);return}zt(a instanceof Zi,`language type is not a LoroText`);let o=$.getByPath(`language_metadata/${e}`);if(!o){Q.error(`no language metadata container found for cell`,e);return}zt(o instanceof Ji,`language metadata is not a LoroMap`),t(r,a),n(r,o),i=$.subscribe(e=>{if(e.origin===`local`)return;let i=e.events.some(e=>e.target===a.id),s=e.events.some(e=>e.target===o.id);i&&t(r,a),s&&n(r,o)})}),{destroy(){i()}}})}function Rf(e){let t=$.getMap(`languages`).getOrCreateContainer(e,new Zi),n=$.getMap(`language_metadata`).getOrCreateContainer(e,new Ji);return R.updateListener.of(e=>{let r=t.toString()!==``;if(!e.docChanged&&r)return;if(!r){let r=He(e.state).type;lt(e.view,{language:r}),Q.debug(`no initial language, setting default to`,r),t.delete(0,t.length),t.insert(0,r),Q.debug(`no initial language metadata, setting default to`,e.state.field(nt));let i=e.state.field(nt);for(let e of Object.keys(i))n.set(e,i[e]);$.commit();return}let i=!1;for(let r of e.transactions)if(!r.annotation($e)){for(let e of r.effects)if(e.is(de)&&t.toString()!==e.value.type&&(Q.debug(`[outgoing] language change: ${t} -> ${e.value.type}`),t.delete(0,t.length),t.insert(0,e.value.type),i=!0),e.is(Ze)||e.is(We)){let t=e.value;e.is(We)?(Q.debug(`[outgoing] setting language metadata: `,t),n.clear()):Q.debug(`[outgoing] updating language metadata: `,t);for(let e of Object.keys(t))n.set(e,t[e]);i=!0}}i&&$.commit()})}function zf(e,t,n,r,i,a){let o=`loro:cell:${i}`;return[gf,vf(),yf(),Hr.define(i=>new Cf(i,e,n,t,r,o,a)),Hr.define(n=>new wf(n,e,t,o)),mf]}var Bf=De,Vf=e=>{let t=(0,H.c)(41),{resetOnBlur:n,placeholderText:r,initialValue:i,flexibleWidth:a,onNameChange:o,className:s}=e,c=n!==void 0&&n,l=i===void 0?null:i,u=a!==void 0&&a,{sendListFiles:d}=hi(),[f,p]=(0,V.useState)(l),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=[],t[0]=m):m=t[0];let[h,g]=(0,V.useState)(m),[_,v]=(0,V.useState)(!1),y=(0,V.useRef)(null),b=(0,V.useRef)(!1),x,S;t[1]===l?(x=t[2],S=t[3]):(x=()=>{p(l)},S=[l],t[1]=l,t[2]=x,t[3]=S),(0,V.useEffect)(x,S);let C;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{v(!0)},t[4]=C):C=t[4];let w=C,T;t[5]!==l||t[6]!==c?(T=e=>{e.relatedTarget?.closest(`.filename-input`)||(v(!1),c&&p(l))},t[5]=l,t[6]=c,t[7]=T):T=t[7];let E=T,D;t[8]===f?D=t[9]:(D=pn.dirname(f||``),t[8]=f,t[9]=D);let O=D,ee=pn.basename(f||``),k=h.filter(e=>pn.basename(e.path).startsWith(ee)),te;t[10]!==O||t[11]!==_||t[12]!==d?(te=async()=>{if(!_){g([]);return}let e=await d({path:O});g(e.files)},t[10]=O,t[11]=_,t[12]=d,t[13]=te):te=t[13];let ne;t[14]!==O||t[15]!==_?(ne=[O,_],t[14]=O,t[15]=_,t[16]=ne):ne=t[16];let{isPending:re}=Si(te,ne),A=Hf(f,h,l),j=(A||k.length>0)&&(0,U.jsxs)(st,{className:`font-mono`,children:[!re&&(0,U.jsx)(Ve,{children:`No files`}),A&&(0,U.jsxs)(ue,{variant:`success`,className:`py-2 px-3`,onSelect:()=>{A&&(b.current=!0,o(A),y.current?.blur())},children:[(0,U.jsx)(ia,{className:`w-4 h-4 mr-2`}),` `,(0,U.jsxs)(`span`,{className:`text-sm`,children:[l?`Rename to: `:`Save as: `,(0,U.jsx)(`span`,{className:`font-medium text-sm`,children:pn.basename(A)})]})]},`_rename_`),k.map(e=>{let t=e.isDirectory?`directory`:Gn(e.path),n=Kn[t];return(0,U.jsxs)(ue,{variant:e.isDirectory?`default`:`muted`,className:`py-2 px-3`,onSelect:()=>{e.isDirectory?p(`${e.path}/`):p(e.path)},children:[(0,U.jsx)(n,{className:`w-4 h-4 mr-2`}),` `,pn.basename(e.path)]},e.path)})]}),ie=Math.max(20,f?.length||r?.length||0)*10,M=_?f||``:l||``,N;t[17]!==u||t[18]!==ie?(N=u?{maxWidth:ie}:void 0,t[17]=u,t[18]=ie,t[19]=N):N=t[19];let P;t[20]===s?P=t[21]:(P=en(s,`w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60`),t[20]=s,t[21]=P);let ae;t[22]!==r||t[23]!==M||t[24]!==N||t[25]!==P?(ae=(0,U.jsx)(Bf,{children:(0,U.jsx)(Ae,{"data-testid":`dir-completion-input`,tabIndex:-1,rootClassName:`border-none justify-center px-1`,spellCheck:`false`,value:M,onKeyDown:Uf,icon:null,ref:y,onValueChange:p,placeholder:r,autoComplete:`off`,style:N,className:P})}),t[22]=r,t[23]=M,t[24]=N,t[25]=P,t[26]=ae):ae=t[26];let oe=j&&`group-focus-within:block`,se;t[27]===oe?se=t[28]:(se=en(`p-0 w-full min-w-80 max-w-80vw hidden`,oe),t[27]=oe,t[28]=se);let ce;t[29]!==j||t[30]!==se?(ce=(0,U.jsx)(ot,{side:`bottom`,className:se,portal:!1,children:j}),t[29]=j,t[30]=se,t[31]=ce):ce=t[31];let le;t[32]!==ae||t[33]!==ce?(le=(0,U.jsxs)(st,{children:[ae,ce]}),t[32]=ae,t[33]=ce,t[34]=le):le=t[34];let de;t[35]!==E||t[36]!==le?(de=(0,U.jsx)(Ee,{onFocus:w,onBlur:E,shouldFilter:!1,id:`filename-input`,className:`bg-transparent group filename-input`,children:le}),t[35]=E,t[36]=le,t[37]=de):de=t[37];let fe;return t[38]!==_||t[39]!==de?(fe=(0,U.jsx)($t,{children:(0,U.jsx)(xe,{open:_,modal:!1,children:de})}),t[38]=_,t[39]=de,t[40]=fe):fe=t[40],fe};function Hf(e,t,n){if(e&&!e.endsWith(`/`)&&((fe(`markdown`)?new Set([`py`,`md`,`markdown`,`qmd`]):new Set([`py`])).has(pn.extension(e))||(e=e.endsWith(`.`)?`${e}py`:e.endsWith(`.p`)?`${e}y`:`${e}.py`),!t.some(t=>t.path===e||pn.basename(t.path)===e)&&!(n&&(n===e||pn.basename(n)===e))))return e}function Uf(e){e.key===`Escape`&&e.currentTarget.blur()}var Wf=e=>{let t=(0,H.c)(33),n=()=>{on(new Blob([r()],{type:`text/plain`}),`${e.proposedName}.json`)},r=c(qf),i;t[0]!==n||t[1]!==e?(i=t=>{t.preventDefault(),n(),e.closeModal()},t[0]=n,t[1]=e,t[2]=i):i=t[2];let a;t[3]===e?a=t[4]:(a=t=>{t.key===`Escape`&&e.closeModal()},t[3]=e,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,U.jsx)(cr,{className:`text-accent-foreground mb-6`,children:`Download unsaved changes?`}),t[5]=o):o=t[5];let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s={wordBreak:`break-word`},t[6]=s):s=t[6];let l,u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,U.jsx)(`p`,{children:`This app has unsaved changes. To recover:`}),u={paddingBottom:`10px`},t[7]=l,t[8]=u):(l=t[7],u=t[8]);let d;t[9]===e.proposedName?d=t[10]:(d=(0,U.jsxs)(`li`,{style:u,children:[`Click the "Download" button. This will download a file called\xA0`,(0,U.jsxs)(`code`,{children:[e.proposedName,`.json`]}),`. This file contains your code.`]}),t[9]=e.proposedName,t[10]=d);let f;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(f={paddingBottom:`10px`},t[11]=f):f=t[11];let p;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(p={display:`block`,padding:`10px`},t[12]=p):p=t[12];let m;t[13]===e.proposedName?m=t[14]:(m=(0,U.jsxs)(`code`,{style:p,children:[`marimo recover `,e.proposedName,`.json `,`>`,` `,e.proposedName,`.py`]}),t[13]=e.proposedName,t[14]=m);let h;t[15]===e.proposedName?h=t[16]:(h=(0,U.jsxs)(`code`,{children:[e.proposedName,`.py`]}),t[15]=e.proposedName,t[16]=h);let g;t[17]!==h||t[18]!==m?(g=(0,U.jsxs)(`li`,{style:f,children:[`In your terminal, type`,m,`to overwrite `,h,` with the recovered changes.`]}),t[17]=h,t[18]=m,t[19]=g):g=t[19];let _;t[20]!==g||t[21]!==d?(_=(0,U.jsx)(ar,{className:`markdown wrap-break-word`,style:s,children:(0,U.jsxs)(`div`,{className:`prose dark:prose-invert`,children:[l,(0,U.jsxs)(`ol`,{children:[d,g]})]})}),t[20]=g,t[21]=d,t[22]=_):_=t[22];let v;t[23]===e.closeModal?v=t[24]:(v=(0,U.jsx)(un,{"aria-label":`Cancel`,variant:`secondary`,"data-testid":`cancel-recovery-button`,onClick:e.closeModal,children:`Cancel`}),t[23]=e.closeModal,t[24]=v);let y;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,U.jsx)(un,{"data-testid":`download-recovery-button`,"aria-label":`Download`,variant:`default`,type:`submit`,children:`Download`}),t[25]=y):y=t[25];let b;t[26]===v?b=t[27]:(b=(0,U.jsxs)(sr,{children:[v,y]}),t[26]=v,t[27]=b);let x;return t[28]!==i||t[29]!==a||t[30]!==_||t[31]!==b?(x=(0,U.jsx)(or,{className:`w-fit`,children:(0,U.jsxs)(`form`,{onSubmit:i,onKeyDown:a,children:[o,_,b]})}),t[28]=i,t[29]=a,t[30]=_,t[31]=b,t[32]=x):x=t[32],x},Gf=e=>{let t=(0,H.c)(12),{filename:n,needsSave:r}=e,{openModal:i,closeModal:a}=Jn(),o;t[0]===n?o=t[1]:(o=n===null?`app`:pn.basename(n).split(`.`)[0],t[0]=n,t[1]=o);let s=o,c;t[2]!==a||t[3]!==r||t[4]!==i||t[5]!==s?(c=()=>{r&&i((0,U.jsx)(Wf,{proposedName:s,closeModal:a}))},t[2]=a,t[3]=r,t[4]=i,t[5]=s,t[6]=c):c=t[6];let l=c;_n(`global.save`,l);let u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=Mi(`global.save`),t[7]=u):u=t[7];let d=r?`yellow`:`gray`,f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,U.jsx)(tr,{strokeWidth:1.5,size:18}),t[8]=f):f=t[8];let p;return t[9]!==l||t[10]!==d?(p=(0,U.jsx)(cn,{content:u,children:(0,U.jsx)(na,{onClick:l,id:`save-button`,"aria-label":`Save`,className:`rectangle`,color:d,children:f})}),t[9]=l,t[10]=d,t[11]=p):p=t[11],p};function Kf(e){return{id:e.id,name:e.name,code:e.code,code_hash:null,config:{column:0,...e.config}}}function qf(){let e=Me(),t=ye(e),n={version:`1`,metadata:{marimo_version:Qt()},cells:t.map(Kf)};return JSON.stringify(n,null,2)}var Jf=r(void 0),Yf=r(e=>{let t=e(Jf);return Xf({state:e(he),layout:e(Zn),lastSavedNotebook:t})});function Xf({state:e,layout:t,lastSavedNotebook:n}){if(!n)return!1;let{cellIds:r,cellData:i}=e,o=r.inOrderIds.map(e=>i[e]),s=o.map(e=>e.code),c=o.map(e=>e.config),l=o.map(e=>e.name);return!ni(s,n.codes)||!ni(l,n.names)||!a(c,n.configs)||!a(t.selectedLayout,n.layout.selectedLayout)||!a(t.layoutData,n.layout.layoutData)}function Zf(e){let t=(0,H.c)(21),{codes:n,cellConfigs:r,config:i,connStatus:a,cellNames:o,needsSave:s,kioskMode:c,onSave:l}=e,u=(0,V.useRef)(null),d;t[0]===n?d=t[1]:(d=n.join(`:`),t[0]=n,t[1]=d);let f=d,p;t[2]===r?p=t[3]:(p=r.map(Qf).join(`:`),t[2]=r,t[3]=p);let m=p,h;t[4]===o?h=t[5]:(h=o.join(`:`),t[4]=o,t[5]=h);let g=h,_;t[6]!==i||t[7]!==a.state||t[8]!==c||t[9]!==s||t[10]!==l?(_=()=>{if(!c)return i.autosave===`after_delay`&&(u.current!==null&&clearTimeout(u.current),s&&a.state===qt.OPEN&&(u.current=setTimeout(l,i.autosave_delay))),()=>{u.current!==null&&clearTimeout(u.current)}},t[6]=i,t[7]=a.state,t[8]=c,t[9]=s,t[10]=l,t[11]=_):_=t[11];let v;t[12]!==m||t[13]!==g||t[14]!==f||t[15]!==i||t[16]!==a.state||t[17]!==c||t[18]!==s||t[19]!==l?(v=[f,m,g,i,a.state,l,c,s],t[12]=m,t[13]=g,t[14]=f,t[15]=i,t[16]=a.state,t[17]=c,t[18]=s,t[19]=l,t[20]=v):v=t[20],(0,V.useEffect)(_,v)}function Qf(e){return JSON.stringify(e)}var $f=Promise.resolve();function ep(e){let t=$f.then(e);return $f=t.then(()=>void 0,()=>void 0),t}var tp=e=>{let t=(0,H.c)(15),{kioskMode:n}=e,r=Ai(),a=i(Yf),o=i(Jt).state===qt.CLOSED,{saveOrNameNotebook:s,saveIfNotebookIsPersistent:c}=np(),l;t[0]!==n||t[1]!==c?(l={onSave:c,kioskMode:n},t[0]=n,t[1]=c,t[2]=l):l=t[2],sp(l),ra();let u;t[3]===a?u=t[4]:(u=e=>{if(a)return e.preventDefault(),e.returnValue=`You have unsaved changes. Are you sure you want to leave?`,e.returnValue},t[3]=a,t[4]=u),Rt(window,`beforeunload`,u);let d;t[5]===s?d=t[6]:(d=e=>{e.preventDefault(),e.stopPropagation(),s()},t[5]=s,t[6]=d);let f=d;if(_n(`global.save`,s),o){let e;return t[7]!==r||t[8]!==a?(e=(0,U.jsx)(Gf,{filename:r,needsSave:a}),t[7]=r,t[8]=a,t[9]=e):e=t[9],e}let p;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=Mi(`global.save`),t[10]=p):p=t[10];let m=a?`yellow`:`hint-green`,h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,U.jsx)(tr,{strokeWidth:1.5,size:18}),t[11]=h):h=t[11];let g;return t[12]!==f||t[13]!==m?(g=(0,U.jsx)(cn,{content:p,children:(0,U.jsx)(na,{"data-testid":`save-button`,id:`save-button`,shape:`rectangle`,color:m,onClick:f,children:h})}),t[12]=f,t[13]=m,t[14]=g):g=t[14],g};function np(){let e=(0,H.c)(21),{sendSave:t}=hi(),{openModal:r,closeModal:i,openAlert:a}=Jn(),o=l(Jf),s=ji(),u=n(),d;e[0]!==a||e[1]!==t||e[2]!==o||e[3]!==u?(d=(e,n)=>ep(async()=>{let r=u.get(Jt),i=u.get(At);if(u.get(Ht))return;if(r.state!==qt.OPEN){a(`Failed to save notebook: not connected to a kernel.`);return}if(It.log(`saving to `,e),n&&i.format_on_save&&(It.log(`formatting notebook (onSave)`),await le()),ye(Me()).length===0)return;let s=await rt(async()=>{let n=Me(),r=ye(n),i=r.map(ap),a=r.map(ip),o=r.map(rp),s=Ce(n),c=u.get(Zn);return await t({cellIds:i,codes:a,names:o,filename:e,configs:s,layout:mn(),persist:!0}),{names:o,codes:a,configs:s,layout:c}});o(s)}),e[0]=a,e[1]=t,e[2]=o,e[3]=u,e[4]=d):d=e[4];let f=c(d),p;e[5]!==f||e[6]!==u?(p=e=>{let t=e!==void 0&&e,n=u.get(gt),r=u.get(Jt);op(n)&&r.state===qt.OPEN&&f(n,t)},e[5]=f,e[6]=u,e[7]=p):p=e[7];let m=c(p),h;e[8]!==f||e[9]!==s?(h=e=>{s(e).then(e=>{e!==null&&f(e,!0)})},e[8]=f,e[9]=s,e[10]=h):h=e[10];let g=h,_;e[11]!==i||e[12]!==g||e[13]!==r||e[14]!==m||e[15]!==u?(_=()=>{let e=u.get(gt),t=u.get(Jt);m(!0),!op(e)&&t.state!==qt.CLOSED&&r((0,U.jsx)(up,{onClose:i,onSave:g}))},e[11]=i,e[12]=g,e[13]=r,e[14]=m,e[15]=u,e[16]=_):_=e[16];let v=c(_),y;return e[17]!==m||e[18]!==f||e[19]!==v?(y={saveOrNameNotebook:v,saveIfNotebookIsPersistent:m,saveNotebook:f},e[17]=m,e[18]=f,e[19]=v,e[20]=y):y=e[20],y}function rp(e){return e.name}function ip(e){return e.code}function ap(e){return e.id}function op(e){return e!==null&&!e.startsWith(`/tmp/`)&&!e.startsWith(`/var/folders`)&&!e.includes(`AppData\\Local\\Temp`)}function sp(e){let n=(0,H.c)(14),r=i(At),a=C(),[o]=t(Jt),s=i(Yf),c,l;if(n[0]!==a){let e=ye(a);c=e.map(lp),l=e.map(cp),n[0]=a,n[1]=c,n[2]=l}else c=n[1],l=n[2];let u=l,d;n[3]===a?d=n[4]:(d=Ce(a),n[3]=a,n[4]=d);let f=d,p;n[5]!==r||n[6]!==u||n[7]!==c||n[8]!==f||n[9]!==o||n[10]!==s||n[11]!==e.kioskMode||n[12]!==e.onSave?(p={onSave:e.onSave,needsSave:s,codes:c,cellConfigs:f,cellNames:u,connStatus:o,config:r,kioskMode:e.kioskMode},n[5]=r,n[6]=u,n[7]=c,n[8]=f,n[9]=o,n[10]=s,n[11]=e.kioskMode,n[12]=e.onSave,n[13]=p):p=n[13],Zf(p)}function cp(e){return e.name}function lp(e){return e.code}var up=e=>{let t=(0,H.c)(17),{onClose:n,onSave:r}=e,[i,a]=(0,V.useState)(),o;t[0]!==n||t[1]!==r?(o=e=>{a(e),e.trim()&&(r(e),n())},t[0]=n,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,U.jsx)(cr,{children:`Save notebook`}),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,U.jsx)(an,{className:`text-md pt-6 px-1`,children:`Save as`}),t[4]=l):l=t[4];let u;t[5]===s?u=t[6]:(u=(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[l,(0,U.jsx)(Vf,{onNameChange:s,placeholderText:`filename`,className:`missing-filename`})]}),t[5]=s,t[6]=u);let d;t[7]===n?d=t[8]:(d=(0,U.jsx)(un,{"data-testid":`cancel-save-dialog-button`,"aria-label":`Cancel`,variant:`secondary`,onClick:n,children:`Cancel`}),t[7]=n,t[8]=d);let f=!i,p;t[9]===f?p=t[10]:(p=(0,U.jsx)(un,{"data-testid":`submit-save-dialog-button`,"aria-label":`Save`,variant:`default`,disabled:f,type:`submit`,children:`Save`}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,U.jsxs)(sr,{children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==u||t[15]!==m?(h=(0,U.jsxs)(or,{children:[c,u,m]}),t[14]=u,t[15]=m,t[16]=h):h=t[16],h};function dp(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var fp={modified:{doc:``},original:{doc:``}},pp=(0,V.createContext)(fp);function mp(e,t){return z({},e,t,{modified:z({},e.modified,t.modified),original:z({},e.original,t.original)})}var hp=()=>(0,V.useContext)(pp),gp=e=>{var t=e.children,n=e.theme,r=(0,V.useReducer)(mp,z({},fp,{theme:n})),i=r[0],a=r[1];return(0,V.useEffect)(()=>a({theme:n}),[n]),(0,U.jsx)(pp.Provider,{value:z({},i,{dispatch:a}),children:t})},_p=[`extensions`,`value`,`selection`,`onChange`],vp=e=>{var t=e.extensions,n=t===void 0?[]:t,r=e.value,i=e.selection,a=e.onChange,o=Ei(e,_p),s=hp(),c=s.theme,l=s.dispatch,u=Fi(z({},o,{theme:c}));return(0,V.useEffect)(()=>l({original:{doc:r,selection:i,extensions:[...u,...n]},originalExtension:{onChange:a,option:o,extension:[n]}}),[e]),null};vp.displayName=`CodeMirrorMerge.Original`;var yp=[`extensions`,`value`,`selection`,`onChange`],bp=e=>{var t=e.extensions,n=t===void 0?[]:t,r=e.value,i=e.selection,a=e.onChange,o=Ei(e,yp),s=hp(),c=s.theme,l=s.dispatch,u=Fi(z({},o,{theme:c}));return(0,V.useEffect)(()=>{l({modified:{doc:r,selection:i,extensions:[...u,...n]},modifiedExtension:{onChange:a,option:o,extension:[n]}})},[e]),null};bp.displayName=`CodeMirrorMerge.Modified`;var xp=[`className`,`children`,`orientation`,`revertControls`,`highlightChanges`,`gutter`,`collapseUnchanged`,`destroyRerender`,`renderRevertControl`,`diffConfig`,`root`],Sp=[`modified`,`modifiedExtension`,`original`,`originalExtension`,`theme`,`dispatch`],Cp=V.forwardRef((e,t)=>{var n=e.className,r=e.children,i=e.orientation,a=e.revertControls,o=e.highlightChanges,s=e.gutter,c=e.collapseUnchanged,l=e.destroyRerender,u=l===void 0||l,d=e.renderRevertControl,f=e.diffConfig,p=e.root,m=Ei(e,xp),h=hp(),g=h.modified,_=h.modifiedExtension,v=h.original,y=h.originalExtension,b=h.theme,x=h.dispatch,S=Ei(h,Sp),C=(0,V.useRef)(null),w=(0,V.useRef)(),T={orientation:i,revertControls:a,highlightChanges:o,gutter:s,collapseUnchanged:c,renderRevertControl:d,diffConfig:f,root:p};(0,V.useImperativeHandle)(t,()=>({container:C.current,view:w.current,modified:g,original:v,config:z({a:v,b:g,parent:C.current},T)}),[C,w,g,v,T]);var E=R.updateListener.of(e=>{if(e.docChanged&&typeof y?.onChange==`function`){var t=e.state.doc.toString();y?.onChange(t,e)}}),D=R.updateListener.of(e=>{if(e.docChanged&&typeof _?.onChange==`function`){var t=e.state.doc.toString();_?.onChange(t,e)}});return(0,V.useEffect)(()=>{!w.current&&C.current&&y&&_&&(w.current=new Ii(z({a:z({},v,{extensions:[...y?.extension||[],...Fi(z({},y?.option,{theme:b})),E]}),b:z({},g,{extensions:[..._?.extension||[],...Fi(z({},_?.option,{theme:b})),D]}),parent:C.current},T)),x({view:w.current}))},[w,C,y,_]),(0,V.useEffect)(()=>{if(v&&v.doc&&w.current){var e=w.current?.a.state.doc.toString();if(e!==v.doc){var t;(t=w.current)==null||t.a.dispatch({changes:{from:0,to:e.length,insert:v.doc||``}})}}if(g&&g.doc&&w.current){var n=w.current?.b.state.doc.toString();if(n!==g.doc){var r;(r=w.current)==null||r.b.dispatch({changes:{from:0,to:n.length,insert:g.doc||``}})}}if(u&&w.current){var i=w.current.a.state.selection.ranges[0].from,a=w.current.b.state.selection.ranges[0].from;w.current.destroy(),w.current=new Ii(z({a:z({},v,{extensions:[...y?.extension||[],...Fi(z({},y?.option,{theme:b}))]}),b:z({},g,{extensions:[..._?.extension||[],...Fi(z({},_?.option,{theme:b}))]}),parent:C.current},T)),i&&(w.current.a.focus(),w.current.a.dispatch({selection:{anchor:i,head:i}})),a&&(w.current.b.focus(),w.current.b.dispatch({selection:{anchor:a,head:a}}))}},[w,b,C.current,v,g,y,_,u]),(0,V.useEffect)(()=>()=>w.current&&w.current.destroy(),[]),(0,V.useEffect)(()=>{if(w.current){var e={};S.orientation!==i&&(e.orientation=i),S.revertControls!==a&&(e.revertControls=a),S.highlightChanges!==o&&(e.highlightChanges=o),S.gutter!==s&&(e.gutter=s),S.collapseUnchanged!==c&&(e.collapseUnchanged=c),S.renderRevertControl!==d&&(e.collapseUnchanged=c),Object.keys(e).length&&x&&w.current&&(w.current.reconfigure(z({},e)),x(z({},e)))}},[x,w,i,a,o,s,c,d]),(0,U.jsx)(`div`,z({ref:C,className:`cm-merge-theme`+(n?` `+n:``)},m,{children:r}))});Cp.displayName=`CodeMirrorMerge.Internal`;var wp=[`theme`],Tp=V.forwardRef((e,t)=>{var n=e.theme,r=Ei(e,wp);return(0,U.jsx)(gp,{theme:n,children:(0,U.jsx)(Cp,z({},r,{ref:t}))})});Tp.Original=vp,Tp.Modified=bp,Tp.displayName=`CodeMirrorMerge`;var Ep=Tp.Original,Dp=Tp.Modified,Op=[se(),R.lineWrapping],kp=({cellId:e,aiCompletionCell:n,className:r,onChange:i,currentLanguageAdapter:a,currentCode:o,declineChange:s,acceptChange:c,runCell:l,outputArea:u,children:d})=>{let[p,m]=(0,V.useState)(!1),[h,g]=t(Oi),_=(0,V.useId)(),v=Yt(),{initialPrompt:y,triggerImmediately:x,cellId:C}=n??{},w=C===e,T=An(e),E;T?.type===`update_cell`&&(E=T.previousCode);let[D,O]=(0,V.useState)(``),[ee,k]=(0,V.useState)(y??``),te=V.useMemo(()=>new Tn({api:v.getAiURL(`completion`).toString(),headers:()=>v.headers(),prepareSendMessagesRequest:({body:e,id:t})=>({body:{...e,id:t}})}),[v]),{sendMessage:ne,stop:re,status:A}=Un({throttle:100,transport:te,onData:e=>{if(e.type===En){let t=On.parse(e.data);O(t.code.trimEnd())}},onError:e=>{O(``),ur({title:`Completion failed`,description:Ti(e)})},onFinish:({isAbort:e,isDisconnect:t,isError:n,finishReason:r})=>{(e||t||n||r!==`stop`)&&O(``)}}),j=A===`submitted`||A===`streaming`,ie=(0,V.useCallback)(()=>{O(``),re()},[re]),M=(0,V.useCallback)(async e=>{await re(),O(``);let t={...Mn({input:e}),prompt:e,includeOtherCode:h?ce(o):``,code:o,language:a??`python`};await ne({text:e},{body:t})},[o,a,h,ne,re]),N=(0,V.useCallback)(()=>{M(ee)},[M,ee]),P=V.useRef(null),ae=(0,V.useCallback)(()=>{x&&!j&&y&&M(y)},[x]);(0,V.useEffect)(()=>{w&&(S(()=>{let e=P.current;return e?.view?(e.view.focus(),ae(),!0):!1},{retries:3,delay:100,initialDelay:100}),b(P.current?.view))},[w,ae]),(0,V.useEffect)(()=>{w&&k(y||``)},[w,y,k]);let{theme:oe}=yi(),se=()=>{c(D),O(``)},le=()=>{ie(),m(!0),P.current?.view?.focus()},ue=w&&x&&(D||j);u??=`below`;let de=w&&(!x||p),fe=(0,U.jsx)(`div`,{className:en(`w-full bg-(--cm-background) flex justify-center transition-all duration-300 ease-in-out overflow-hidden`,ue?`max-h-20 opacity-100 translate-y-0`:`max-h-0 opacity-0 -translate-y-2`),children:(0,U.jsx)(Ap,{status:j?`loading`:`generated`,onAccept:se,onReject:le,showInputPrompt:p,setShowInputPrompt:m,runCell:l,className:`mt-4 mb-3 w-lg`})}),pe=(e,t)=>(0,U.jsxs)(Tp,{className:`cm`,theme:oe,children:[(0,U.jsx)(Ep,{onChange:i,value:e,extensions:Op}),(0,U.jsx)(Dp,{value:t,editable:!1,readOnly:!0,extensions:Op})]}),me=()=>{if(D&&w)return pe(o,D);if(!D&&E)return pe(E,o)},he=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ln,{isLoading:j,onAccept:se,size:`xs`,multipleCompletions:!1,label:Bn.accept,acceptShortcut:`Mod-↵`,runCell:l}),(0,U.jsx)(zn,{onDecline:le,size:`xs`,multipleCompletions:!1,label:Bn.decline,declineShortcut:`Shift-Mod-Delete`})]});return(0,U.jsxs)(`div`,{"data-ai-input-open":de,className:en(`flex flex-col w-full rounded-[inherit]`,r),children:[(0,U.jsx)(`div`,{className:en(`flex items-center gap-2 px-3 transition-all rounded-[inherit] rounded-b-none duration-300`,de&&`max-h-[400px] border-b min-h-11 visible`,!de&&`max-h-0 min-h-0 invisible`),children:w&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ye,{className:`text-(--blue-10) shrink-0`,size:16}),(0,U.jsx)(Rn,{inputRef:P,className:`h-full my-0 py-2 flex items-center`,onClose:()=>{ie(),s()},value:ee,onChange:k,onSubmit:()=>{j||(P.current?.view&&jn(P.current.view),N())},onKeyDown:Vn({handleAcceptCompletion:se,handleDeclineCompletion:le,isLoading:j,hasCompletion:D.trim().length>0})}),(0,U.jsxs)(`div`,{className:`-mr-1.5 py-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-end gap-0.5`,children:[(0,U.jsx)(In,{isLoading:j,onStop:ie,onSendClick:N,isEmpty:!ee.trim(),showStopLabel:!0}),(0,U.jsx)(Fn,{handleAddContext:()=>Hn(P),isLoading:j}),(0,U.jsx)(bn,{triggerClassName:`h-7 text-xs`,iconSize:`small`,forRole:`edit`,displayIconOnly:!0,placeholder:`Edit model`})]}),D&&(0,U.jsx)(`div`,{className:`mt-1 flex items-center gap-1`,children:he})]}),(0,U.jsx)(`div`,{className:`h-full w-px bg-border mx-2`}),(0,U.jsx)(cn,{content:`Include code from other cells`,children:(0,U.jsxs)(`div`,{className:`flex flex-row items-start gap-1 overflow-hidden`,children:[(0,U.jsx)(f,{"data-testid":`include-other-cells-checkbox`,id:_,checked:h,onCheckedChange:e=>g(!!e)}),(0,U.jsx)(an,{htmlFor:_,className:`text-muted-foreground text-xs whitespace-nowrap ellipsis`,children:`All code`})]})}),(0,U.jsx)(un,{"aria-label":`Discard AI completion`,"data-testid":`decline-completion-button`,variant:`text`,size:`icon`,disabled:j,onClick:()=>{ie(),s()},children:(0,U.jsx)(Cn,{className:`text-(--red-10)`,size:16})})]})}),u===`above`&&fe,me(),(!D||!w)&&!E&&d,u===`below`&&fe]})},Ap=e=>{let t=(0,H.c)(27),{status:n,onAccept:r,onReject:i,className:a,showInputPrompt:o,setShowInputPrompt:s,runCell:c}=e,l=n===`loading`,u;t[0]===a?u=t[1]:(u=en(`flex flex-row items-center gap-6 rounded-md py-2 px-2.5 text-sm border border-border bg-(--gray-2) dark:bg-(--gray-3)`,a),t[0]=a,t[1]=u);let d;t[2]===l?d=t[3]:(d=l?(0,U.jsx)(Yn,{className:`animate-spin text-blue-600 mb-px`,size:15,strokeWidth:2,"aria-label":`Generating fix`}):(0,U.jsx)(wn,{className:`text-green-600 mb-px`,size:15,strokeWidth:2,"aria-label":`Fix generated`}),t[2]=l,t[3]=d);let f=l?`Generating fix...`:`Showing fix`,p;t[4]===f?p=t[5]:(p=(0,U.jsx)(`p`,{className:`transition-opacity duration-200 text-muted-foreground`,children:f}),t[4]=f,t[5]=p);let m;t[6]!==d||t[7]!==p?(m=(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-2`,children:[d,p]}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,U.jsx)(an,{htmlFor:`show-input-prompt`,className:`text-muted-foreground text-xs whitespace-nowrap ellipsis`,children:`Show prompt`}),t[9]=h):h=t[9];let g;t[10]!==s||t[11]!==o?(g=(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-1`,children:[h,(0,U.jsx)(sn,{checked:o,onCheckedChange:s,size:`xs`})]}),t[10]=s,t[11]=o,t[12]=g):g=t[12];let _;t[13]!==l||t[14]!==r||t[15]!==c?(_=(0,U.jsx)(Ln,{isLoading:l,onAccept:r,size:`xs`,label:Bn.accept,runCell:c}),t[13]=l,t[14]=r,t[15]=c,t[16]=_):_=t[16];let v;t[17]===i?v=t[18]:(v=(0,U.jsx)(zn,{onDecline:i,size:`xs`,label:Bn.decline}),t[17]=i,t[18]=v);let y;t[19]!==_||t[20]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-row items-center gap-2 ml-auto`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;return t[22]!==u||t[23]!==y||t[24]!==m||t[25]!==g?(b=(0,U.jsxs)(`div`,{className:u,children:[m,g,y]}),t[22]=u,t[23]=y,t[24]=m,t[25]=g,t[26]=b):b=t[26],b},jp=`web application/x-marimo-cell`,Mp=xt({cells:wt(xt({code:yt(),name:yt().optional(),config:xt({column:Ct([bt(),Tt()]).optional(),disabled:vt().optional(),hide_code:vt().optional(),expand_output:vt().optional()}).optional()})),version:St(`1.0`)});function Np(e){return e.map(e=>e.code).join(`
|
|
40
40
|
|
|
41
41
|
`)}async function Pp(e){let t={cells:e.map(e=>({code:e.code,name:e.name,config:e.config})),version:`1.0`},n=new Bp().add(jp,t).add(`text/plain`,Np(e)).build();await navigator.clipboard.write([n])}function Fp(){let e=(0,H.c)(13),t=y(),n=Te(),r=qe(),i;e[0]===n?i=e[1]:(i=async e=>{let t=Me(),r=e.map(e=>t.cellData[e]).filter(Boolean);if(r.length!==0)try{await Pp(r),n.clear(),Ip(r.length)}catch(e){let t=e;It.error(`Failed to copy cells to clipboard`,t);try{await lr(Np(r)),n.clear(),Ip(r.length)}catch{Lp()}}},e[0]=n,e[1]=i);let a=c(i),o;e[2]===n?o=e[3]:(o=async e=>{let t=Me(),r=e.filter(e=>t.cellData[e]),i=r.map(e=>t.cellData[e]);if(i.length!==0)try{await Pp(i),n.markForCut({cellIds:r})}catch(e){let t=e;It.error(`Failed to cut cells to clipboard`,t);try{await lr(Np(i)),n.markForCut({cellIds:r})}catch{Lp()}}},e[2]=n,e[3]=o);let s=c(o),l;e[4]!==t||e[5]!==n||e[6]!==r.cellIds?(l=async(e,i)=>{let{before:a}=i??{},o=a!==void 0&&a;if(r.cellIds.size>0){let i=[...r.cellIds],a=Me(),s=i.map(e=>{let t=a.cellIds.findWithId(e);return{columnId:t.id,index:t.indexOfOrThrow(e)}});t.moveCellsRelativeTo({cellIds:i,targetCellId:e,position:o?`before`:`after`,previousPlacements:s}),n.clear();return}try{let n=await navigator.clipboard.read();for(let r of n)if(r.types.includes(jp)){let n=await(await r.getType(jp)).text();try{let r=Mp.parse(JSON.parse(n));if(r.cells.length===0)break;let i=e,a=r.cells.toReversed();for(let e of a)t.createNewCell({cellId:i,before:o,code:e.code,name:e.name,config:e.config,hideCode:e.config?.hide_code,autoFocus:!0});return}catch(e){let t=e;It.warn(`Failed to parse clipboard cell data`,t)}}let r=await navigator.clipboard.readText();r.trim()?t.createNewCell({cellId:e,before:o,code:r,autoFocus:!0}):Rp()}catch(e){let t=e;It.error(`Failed to paste from clipboard`,t),zp()}},e[4]=t,e[5]=n,e[6]=r.cellIds,e[7]=l):l=e[7];let u=c(l),d;return e[8]!==a||e[9]!==s||e[10]!==u||e[11]!==n.clear?(d={copyCells:a,cutCells:s,pasteAtCell:u,clearPendingCut:n.clear},e[8]=a,e[9]=s,e[10]=u,e[11]=n.clear,e[12]=d):d=e[12],d}var Ip=e=>{let t=e===1?`Cell`:`${e} cells`;ur({title:`${t} copied`,description:`${t} ${e===1?`has`:`have`} been copied to clipboard.`})},Lp=()=>{ur({title:`Copy failed`,description:`Failed to copy cells to clipboard.`,variant:`danger`})},Rp=()=>{ur({title:`Nothing to paste`,description:`No cell or text found in clipboard.`,variant:`danger`})},zp=()=>{ur({title:`Paste failed`,description:`Failed to read from clipboard`,variant:`danger`})},Bp=class{items={};add(e,t){return ClipboardItem.supports(e)?typeof t==`string`?(this.items[e]=new Blob([t],{type:e}),this):(this.items[e]=new Blob([JSON.stringify(t)],{type:e}),this):(It.warn(`ClipboardItem does not support ${e}`),this)}build(){return new ClipboardItem(this.items)}};function Vp(){return{selectionStart:null,selectionEnd:null,selected:new Set}}var{reducer:Hp,createActions:Up,valueAtom:Wp,useActions:Gp}=ii(Vp,{select:(e,t)=>({selectionStart:t.cellId,selectionEnd:t.cellId,selected:new Set([t.cellId])}),extend:(e,t)=>{if(!e.selectionStart)return{selectionStart:t.cellId,selectionEnd:t.cellId,selected:new Set([t.cellId])};let{cellId:n,allCellIds:r}=t;try{let t=r.findWithId(e.selectionStart),i=t.indexOfOrThrow(e.selectionStart),a=t.indexOfOrThrow(n),[o,s]=i<a?[i,a]:[a,i],c=t.slice(o,s+1);return{selectionStart:e.selectionStart,selectionEnd:n,selected:new Set(c)}}catch{return{selectionStart:n,selectionEnd:n,selected:new Set([n])}}},clear:e=>e.selected.size===0?e:Vp()}),Kp=()=>i(Wp);function qp(e){let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=r(t=>t(Wp).selected.has(e)),t[0]=e,t[1]=n),i(n)}function Jp(){return Gp()}function Yp(e){return e.get(Wp).selected}var{valueAtom:Xp,useActions:Zp}=ii(()=>new Set,{add:(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},remove:(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),T(()=>{let e=document.activeElement;if(!e)return;let t=mt.findElementThroughShadowDOMs(e);t&&N(mt.parse(t.id))}),n}}),Qp=e=>r(t=>t(Xp).has(e));function $p(e){let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=Qp(e),t[0]=e,t[1]=n),i(n)}var em=new WeakMap,tm=500;function nm(e){if(e.ctrlKey||e.metaKey||e.altKey)return``;let t=e.key.toLowerCase();return e.shiftKey?`shift+${t}`:t}function rm(e,t){let n=nm(e),r=e.target;if(!n||!r)return!1;let i=em.get(r),a=n;i?.timeout&&clearTimeout(i.timeout),i&&(a=`${i.sequence} ${n}`);let o=t[a];if(o)return em.delete(r),o();if(!i){let e=t[n];if(e)return e()}if(Object.keys(t).some(e=>e.startsWith(`${a} `))){let e=window.setTimeout(()=>{em.delete(r)},tm);return em.set(r,{sequence:a,timeout:e}),!0}return em.delete(r),!1}function im(e){return{handle:t=>e(t),bulkHandle:t=>{let n=!0;try{for(let r of t)n&&=e(r);return n}catch{return!1}}}}function am(e){return{handle:t=>e([t]),bulkHandle:t=>e(t)}}function om(e,t){let n=(0,H.c)(12),r=D(),i=y(),a=Zp(),o;n[0]!==e||n[1]!==r?(o=()=>{r.focusCell({cellId:e})},n[0]=e,n[1]=r,n[2]=o):o=n[2];let s;n[3]!==i||n[4]!==e||n[5]!==t||n[6]!==r||n[7]!==a?(s=n=>{sm(n.relatedTarget)||sm(n.target)||cm(n.relatedTarget)!==e&&cm(n.relatedTarget?.closest(`[data-for-cell-id]`))!==e&&(a.remove(e),i.markTouched({cellId:e}),r.blurCell(),t.current&&pm(t.current))},n[3]=i,n[4]=e,n[5]=t,n[6]=r,n[7]=a,n[8]=s):s=n[8];let c;n[9]!==o||n[10]!==s?(c={onFocusWithin:o,onBlurWithin:s},n[9]=o,n[10]=s,n[11]=c):c=n[11];let{focusWithinProps:l}=rr(c);return l}function sm(e){return e?e instanceof HTMLElement&&e.closest(`.cm-vim-panel`)!==null:!1}function cm(e){return e&&e.getAttribute(ee)||null}function lm(e,t){let r=(0,H.c)(34),{canMoveX:a,editorView:o,cellActionDropdownRef:s}=t,{saveOrNameNotebook:c}=np(),{saveCellConfig:u}=hi(),d=l(ki),f=y(),p=n(),h=Zp(),g=Ci(),_=i(kt),{copyCells:v,pasteAtCell:b,cutCells:x}=Fp(),S=Jp(),C=qp(e),w=$a(),T=$n(),E=i(Ot),D;r[0]===E?D=r[1]:(D=jt(E),r[0]=E,r[1]=D);let O=D,ee;r[2]!==w||r[3]!==S?(ee={clear:()=>{w.clear(),S.clear()},extend:e=>{w.clear(),S.extend(e)},select:e=>{w.clear(),S.select(e)}},r[2]=w,r[3]=S,r[4]=ee):ee=r[4];let k=ee,te=i(Mt),ne;r[5]===te?ne=r[6]:(ne=(e,t)=>Lt(te.getHotkey(e).key)(t.nativeEvent||t),r[5]=te,r[6]=ne);let re=ne,A=om(e,o),j;r[7]!==f||r[8]!==O||r[9]!==a||r[10]!==s||r[11]!==e||r[12]!==v||r[13]!==x||r[14]!==T||r[15]!==o||r[16]!==C||r[17]!==re||r[18]!==_||r[19]!==b||r[20]!==w||r[21]!==g||r[22]!==u||r[23]!==c||r[24]!==k||r[25]!==d||r[26]!==p||r[27]!==h||r[28]!==E?(j={onKeyDown:t=>{if(ln.fromInput(t)){t.continuePropagation();return}let n={"Mod+ArrowUp":()=>(f.focusTopCell(),k.clear(),!0),"Mod+ArrowDown":()=>(f.focusBottomCell(),k.clear(),!0),ArrowUp:()=>(f.focusCell({cellId:e,where:`before`}),k.clear(),!0),ArrowDown:()=>(f.focusCell({cellId:e,where:`after`}),k.clear(),!0),ArrowLeft:()=>{if(a){let t=p.get(he),n=t.cellIds.findWithId(e),r=t.cellIds.indexOf(n),i=t.cellIds.at(r-1);if(i&&i.length>0){let t=fm(e,i);return f.focusCell({cellId:t,where:`exact`}),k.clear(),!0}}return!1},ArrowRight:()=>{if(a){let t=p.get(he),n=t.cellIds.findWithId(e),r=t.cellIds.indexOf(n),i=t.cellIds.at(r+1);if(i&&i.length>0){let t=fm(e,i);return f.focusCell({cellId:t,where:`exact`}),k.clear(),!0}}return!1},"Shift+ArrowUp":()=>{let t=p.get(Fe);k.extend({cellId:e,allCellIds:t});let n=t.findWithId(e).before(e);return n&&k.extend({cellId:n,allCellIds:t}),f.focusCell({cellId:e,where:`before`}),!0},"Shift+ArrowDown":()=>{let t=p.get(Fe);k.extend({cellId:e,allCellIds:t});let n=t.findWithId(e).after(e);return n&&k.extend({cellId:n,allCellIds:t}),f.focusCell({cellId:e,where:`after`}),!0},Escape:()=>p.get(at).size>0?(p.set(ze),!0):C?(k.clear(),!0):!1,Enter:()=>(h.add(e),ae(p,e),k.clear(),!0),s:()=>(c(),!0)};for(let[e,r]of Object.entries(n))if(Lt(e)(t)&&r()){t.preventDefault();return}let r={"cell.run":am(e=>(g(e),!0)),"cell.runAndNewBelow":am(e=>{g(e);let t=e[e.length-1];return f.moveToNextCell({cellId:t,before:!1}),!0}),"cell.runAndNewAbove":am(e=>{g(e);let t=e[0];return f.moveToNextCell({cellId:t,before:!0}),!0}),"cell.createAbove":e=>(f.createNewCell({cellId:e,before:!0}),!0),"cell.createBelow":e=>(f.createNewCell({cellId:e,before:!1}),!0),"cell.moveUp":am(e=>{let t=e[0];return p.get(he).cellIds.findWithId(t).first()!==t&&(e.forEach(e=>{f.moveCell({cellId:e,before:!0})}),!0)}),"cell.moveDown":am(e=>{let t=e[e.length-1];return p.get(he).cellIds.findWithId(t).last()!==t&&(e.toReversed().forEach(e=>{f.moveCell({cellId:e,before:!1})}),!0)}),"cell.moveLeft":im(e=>a?(f.moveCell({cellId:e,direction:`left`}),!0):!1),"cell.moveRight":im(e=>a?(f.moveCell({cellId:e,direction:`right`}),!0):!1),"cell.hideCode":am(e=>{let t=!e.map(e=>p.get(he).cellData[e]?.config||null).every(um);u({configs:Object.fromEntries(e.map(e=>[e,{hide_code:t}]))});for(let n of e)f.updateCellConfig({cellId:n,config:{hide_code:t}});if(e.length===1){let n=e[0];f.focusCell({cellId:n,where:`after`}),t?(o.current?.contentDOM.blur(),ie(n)):ae(p,n)}return!0}),"cell.focusDown":e=>(f.focusCell({cellId:e,where:`after`}),!0),"cell.focusUp":e=>(f.focusCell({cellId:e,where:`before`}),!0),"cell.sendToBottom":am(e=>(e.forEach(e=>{f.sendToBottom({cellId:e})}),!0)),"cell.sendToTop":am(e=>(e.toReversed().forEach(e=>{f.sendToTop({cellId:e})}),!0)),"cell.aiCompletion":e=>{if(!O)return!1;let t=!1;return d(n=>n?.cellId===e?(t=!0,null):{cellId:e}),t&&o.current?.focus(),!0},"cell.cellActions":()=>(s.current?.toggle(),!0),"command.copyCell":am(e=>(v(e),!0)),"command.cutCell":am(e=>(x(e),!0)),"command.pasteCell":e=>(b(e),!0),"command.createCellBefore":e=>!ln.hasModifier(t)&&(f.createNewCell({cellId:e,before:!0,autoFocus:!0}),!0),"command.createCellAfter":e=>!ln.hasModifier(t)&&(f.createNewCell({cellId:e,before:!1,autoFocus:!0}),!0),"command.createSqlCellAfter":e=>!ln.hasModifier(t)&&(m({autoInstantiate:!0,createNewCell:f.createNewCell,fromCellId:e,before:!0}),f.createNewCell({cellId:e,before:!1,autoFocus:!0,code:P.sql.defaultCode}),!0),"cell.delete":()=>{if(!E.keymap.destructive_delete)return!1;let t=i.size>=2?[...i]:[e],n=p.get(he);return t.some(e=>{let{status:t}=n.cellRuntime[e];return t===`running`||t===`queued`})?!1:w.idle?(w.submit(t),!0):(T({cellIds:t}),w.clear(),!0)}},i=Yp(p);if(_===`vim`&&rm(t.nativeEvent||t,{j:n.ArrowDown,k:n.ArrowUp,h:n.ArrowLeft,l:n.ArrowRight,i:n.Enter,"shift+j":n[`Shift+ArrowDown`],"shift+k":n[`Shift+ArrowUp`],"g g":n[`Mod+ArrowUp`],"shift+g":n[`Mod+ArrowDown`],"d d":()=>r[`cell.delete`](),"y y":()=>(v(i.size>=2?[...i]:[e]),!0),p:()=>(b(e,{before:!1}),!0),"shift+p":()=>(b(e,{before:!0}),!0),o:()=>(f.createNewCell({cellId:e,before:!1,autoFocus:!0}),!0),"shift+o":()=>(f.createNewCell({cellId:e,before:!0,autoFocus:!0}),!0),u:()=>(f.undoDeleteCell(),!0)})){t.preventDefault();return}for(let[n,a]of Object.entries(r))if(re(n,t)){if(typeof a==`function`){if(a(e)){t.preventDefault();return}}else if(i.size>=2?a.bulkHandle([...i]):a.handle(e)){t.preventDefault();return}return}t.continuePropagation()}},r[7]=f,r[8]=O,r[9]=a,r[10]=s,r[11]=e,r[12]=v,r[13]=x,r[14]=T,r[15]=o,r[16]=C,r[17]=re,r[18]=_,r[19]=b,r[20]=w,r[21]=g,r[22]=u,r[23]=c,r[24]=k,r[25]=d,r[26]=p,r[27]=h,r[28]=E,r[29]=j):j=r[29];let{keyboardProps:M}=nr(j),N;return r[30]!==A||r[31]!==C||r[32]!==M?(N=ir(A,M,{"data-selected":C,className:`data-[selected=true]:ring-1 data-[selected=true]:ring-(--blue-8) data-[selected=true]:ring-offset-1`}),r[30]=A,r[31]=C,r[32]=M,r[33]=N):N=r[33],N}function um(e){return e?.hide_code}function dm(e,t){let n=(0,H.c)(12),r=Zp(),a=i(kt),o=i(Mt),s;if(n[0]!==o){let e=o.getHotkey(`command.vimEnterCommandMode`);s=Lt(e.key),n[0]=o,n[1]=s}else s=n[1];let c=s,l;n[2]!==e||n[3]!==r?(l=()=>{r.remove(e),ie(e),T(()=>{N(e)})},n[2]=e,n[3]=r,n[4]=l):l=n[4];let u=l,d;n[5]!==t||n[6]!==u?(d=()=>{if(!t.current){u();return}let e=t.current,n=e.state;if(Jr(e))return;let r=!!n.field(ft,!1)||!!n.field(Se,!1),i=ui(n)!==null;r&&pm(e),i&&fi(e),!(r||i)&&u()},n[5]=t,n[6]=u,n[7]=d):d=n[7];let f=d,p;n[8]!==f||n[9]!==a||n[10]!==c?(p={onKeyDown:e=>{a===`vim`?c(e)&&f():e.key===`Escape`&&f(),e.continuePropagation()}},n[8]=f,n[9]=a,n[10]=c,n[11]=p):p=n[11];let{keyboardProps:m}=nr(p);return m}function fm(e,t){let n=document.getElementById(mt.create(e));if(!n)return t.first();let r=n.getBoundingClientRect();for(let e of t.topLevelIds){let t=document.getElementById(mt.create(e));if(t){let n=t.getBoundingClientRect();if(r.top<=n.bottom&&r.bottom>=n.top)return e}}return t.last()}function pm(e){e.state.field(ft,!1)&&e.dispatch({effects:ge.of(null)}),et(e)}var mm=50,hm=4,gm=60;function _m(e){return Math.min(gm,Math.max(hm,e))}var vm=e=>{let t=(0,H.c)(13),{code:n,className:r}=e,i,a,o,s;if(t[0]!==r||t[1]!==n){let e=n.split(`
|
|
42
42
|
`,mm);t[6]===r?i=t[7]:(i=en(`cm`,`mo-code-placeholder`,r),t[6]=r,t[7]=i),a=`cell-editor-placeholder`,o=!0,s=e.map(ym),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s}else i=t[2],a=t[3],o=t[4],s=t[5];let c;return t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,U.jsx)(`div`,{className:i,"data-testid":a,"aria-hidden":o,children:s}),t[8]=i,t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c};function ym(e,t){let n=e.trimEnd().length;return(0,U.jsx)(`div`,{className:`mo-code-placeholder-line`,children:n>0&&(0,U.jsx)(Li,{className:`mo-code-placeholder-bar`,style:{width:`${_m(n)}ch`}})},t)}var bm=e=>{let t=(0,H.c)(25),{editorViewRef:n,code:r,currentLanguageAdapter:i,onAfterToggle:a,className:o}=e,s=o===void 0?`absolute right-3 top-2 z-20 flex hover-action gap-1`:o,c;t[0]===r?c=t[1]:(c=P.markdown.isSupported(r)||r.trim()===``,t[0]=r,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=P.sql.isSupported(r)||r.trim()===``,t[2]=r,t[3]=u);let d=u&&i===`python`,f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,U.jsx)(fn,{color:`var(--sky-11)`,strokeWidth:2.5,className:`w-4 h-4`}),t[4]=f):f=t[4];let p;t[5]!==i||t[6]!==n||t[7]!==a||t[8]!==d?(p=(0,U.jsx)(xm,{editorViewRef:n,currentLanguageAdapter:i,canSwitchToLanguage:d,icon:f,toType:`sql`,displayName:`SQL`,onAfterToggle:a}),t[5]=i,t[6]=n,t[7]=a,t[8]=d,t[9]=p):p=t[9];let m=l&&i===`python`,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,U.jsx)(Pi,{fill:`var(--sky-11)`,color:`black`,className:`w-4 h-4`}),t[10]=h):h=t[10];let g;t[11]!==i||t[12]!==n||t[13]!==a||t[14]!==m?(g=(0,U.jsx)(xm,{editorViewRef:n,currentLanguageAdapter:i,canSwitchToLanguage:m,icon:h,toType:`markdown`,displayName:`Markdown`,onAfterToggle:a}),t[11]=i,t[12]=n,t[13]=a,t[14]=m,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,U.jsx)(Ni,{fill:`var(--sky-11)`,color:`black`,className:`w-4 h-4`}),t[16]=_):_=t[16];let v;t[17]!==i||t[18]!==n?(v=(0,U.jsx)(xm,{editorViewRef:n,currentLanguageAdapter:i,canSwitchToLanguage:!0,icon:_,toType:`python`,displayName:`Python`,onAfterToggle:Pt.NOOP}),t[17]=i,t[18]=n,t[19]=v):v=t[19];let y;return t[20]!==s||t[21]!==v||t[22]!==p||t[23]!==g?(y=(0,U.jsxs)(`div`,{className:s,children:[p,g,v]}),t[20]=s,t[21]=v,t[22]=p,t[23]=g,t[24]=y):y=t[24],y},xm=e=>{let t=(0,H.c)(10),{editorViewRef:n,currentLanguageAdapter:r,canSwitchToLanguage:i,icon:a,toType:o,displayName:s,onAfterToggle:c}=e,l;t[0]!==n||t[1]!==c||t[2]!==o?(l=()=>{let e=n.current;e&&(lt(e,{language:o}),c())},t[0]=n,t[1]=c,t[2]=o,t[3]=l):l=t[3];let u=l;if(!i||r===o)return null;let d=`View as ${s}`,f;t[4]!==u||t[5]!==a?(f=(0,U.jsx)(un,{"data-testid":`language-toggle-button`,variant:`text`,size:`xs`,className:`opacity-80 px-1`,onClick:u,children:a}),t[4]=u,t[5]=a,t[6]=f):f=t[6];let p;return t[7]!==d||t[8]!==f?(p=(0,U.jsx)(cn,{content:d,children:f}),t[7]=d,t[8]=f,t[9]=p):p=t[9],p};function Sm(e,t,n){return n?{code:n.code,extensions:[...t,n.extension]}:{code:e,extensions:t}}var Cm=({theme:e,showPlaceholder:n,id:r,config:a,code:o,status:s,serializedEditorState:l,setEditorView:u,runCell:d,userConfig:f,editorViewRef:p,editorViewParentRef:h,hidden:g,hasOutput:v,showHiddenCode:b,languageAdapter:x,setLanguageAdapter:S,showLanguageToggles:C=!0,inlineAiTooltip:w,outputArea:T,tooltipParentSelector:E})=>{let[D,O]=t(ki),ee=er(),{saveOrNameNotebook:k}=np(),te=$a(),{saveCellConfig:ne}=hi(),re=s===`running`||s===`queued`,A=y(),j=Bi(),ie=x===`markdown`,M=c(()=>re?!1:te.idle&&f.keymap.destructive_delete?(te.submit([r]),!0):(ee({cellId:r}),!0)),N=c(()=>!re&&(d(),p.current&&pm(p.current),!0)),P=c(()=>{let e=!a.hide_code;return ne({configs:{[r]:{hide_code:e}}}),A.updateCellConfig({cellId:r,config:{hide_code:e}}),e}),ae=i(Nt),oe=i(yn),se=c(()=>{m({autoInstantiate:ae,createNewCell:A.createNewCell}),a.hide_code||(ne({configs:{[r]:{hide_code:!0}}}),A.updateCellConfig({cellId:r,config:{hide_code:!0}}),A.markUntouched({cellId:r}))}),ce=c(()=>{m({autoInstantiate:ae,createNewCell:A.createNewCell})}),le=jt(f),ue=(0,V.useMemo)(()=>{let t=Vd({cellId:r,showPlaceholder:n,enableAI:le,cellActions:{...A,afterToggleMarkdown:se,afterToggleSQL:ce,onRun:N,deleteCell:M,saveNotebook:k,createManyBelow:e=>{for(let t of e.toReversed())A.createNewCell({code:t,before:!1,cellId:r,skipIfCodeExists:!0})},addOrAppendSetupCell:e=>{let t=Me();if(!t.cellIds.setupCellExists()){A.addSetupCellIfDoesntExist({code:e});return}let n=Qe(t)[_],r=n?we(n):t.cellData[_].code,i=r.trim()?`${r.trimEnd()}\n\n${e}`:e;n&&Oe(n,i),A.updateCellCode({cellId:_,code:i,formattingChange:!1})},splitCell:j,toggleHideCode:P,aiCellCompletion:()=>{if(!le)return!1;let e=!1;return O(t=>t?.cellId===r?(e=!0,null):{cellId:r}),e}},completionConfig:f.completion,acceptCompletionOnEnter:oe,keymapConfig:f.keymap,lspConfig:f.language_servers,theme:e,hotkeys:new Ft(f.keymap.overrides??{}),diagnosticsConfig:f.diagnostics,displayConfig:f.display,inlineAiTooltip:w??f.ai?.inline_tooltip??!1,tooltipParentSelector:E});return t.push(Hr.define(e=>(S(e.state.field(Pe).type),{update(e){S(e.state.field(Pe).type)}})),R.updateListener.of(e=>{e.selectionSet&&e.state.selection.ranges.some(e=>e.from!==e.to)&&b({focus:!1})}),R.domEventHandlers({focus:()=>{b({focus:!1})}})),t},[r,oe,f.keymap,f.completion,f.language_servers,f.display,f.diagnostics,f.ai?.inline_tooltip,w,E,le,e,n,A,j,P,M,N,O,se,ce,S,b,k]),de=me()&&Ie(r),fe=e=>{if(!de)return Sm(o,ue,void 0);let t=If(r,e=>{A.updateCellCode({cellId:r,code:e,formattingChange:!0})},e);return Sm(o,ue,t)},pe=c(()=>{let e=fe(o),t=new R({state:vr.create({doc:e.code,extensions:e.extensions})});u(t),de||lt(t,{language:He(t.state).type})}),he=c(()=>{zt(p.current!==null,`Editor view is not initialized`);let e=fe();p.current.dispatch({effects:[I.reconfigure.of([e.extensions]),je(p.current,{completionConfig:f.completion,hotkeysProvider:new Ft(f.keymap.overrides??{}),lspConfig:{...f.language_servers,diagnostics:f.diagnostics}})]})}),ge=c(()=>{zt(l,`Editor view is not initialized`);let e=fe(o),t=new R({state:vr.fromJSON(l,{doc:e.code,extensions:e.extensions},{history:Kr})});de||lt(t,{language:He(t.state).type}),u(t),A.clearSerializedEditorState({cellId:r})}),[_e,ve]=(0,V.useState)(l!==null);(0,V.useEffect)(()=>{if(p.current!==null){ve(!0);return}if(ve(!1),l!==null){ge(),ve(!0);return}return ut.request(r,()=>{p.current===null&&(pe(),ve(!0))}),()=>ut.cancel(r)},[r,p,ge,pe,l]),(0,V.useEffect)(()=>{p.current!==null&&he()},[he,ue,p]),(0,V.useEffect)(()=>()=>{p.current?.destroy(),p.current=null},[p]);let[ye,be]=rn({rootMargin:`300px 0px`,threshold:0});(0,V.useEffect)(()=>{_e||(be?.isIntersecting?ut.prioritize(r):ut.deprioritize(r))},[_e,be?.isIntersecting,r]);let xe=dm(r,p),Se=``;return ie&&g&&v?Se=`h-0 overflow-hidden`:g&&(Se=`opacity-20 h-8 [&>div.cm-editor]:h-full [&>div.cm-editor]:overflow-hidden [&_.cm-panels]:hidden`),(0,U.jsx)(kp,{cellId:r,aiCompletionCell:D,currentCode:p.current?.state.doc.toString()??o,currentLanguageAdapter:x,declineChange:c(()=>{O(null),p.current?.focus()}),onChange:c(e=>{p.current?.dispatch({changes:{from:0,to:p.current.state.doc.length,insert:e}})}),acceptChange:c(e=>{p.current?.dispatch({changes:{from:0,to:p.current.state.doc.length,insert:e}}),p.current?.focus(),O(null)}),runCell:N,outputArea:T,children:(0,U.jsxs)(`div`,{className:`relative w-full`,ref:ye,...xe,children:[_e?(0,U.jsx)(wm,{className:Se,editorView:p.current,ref:h,hidden:g,showHiddenCode:b}):(0,U.jsx)(vm,{code:o,className:Se}),!g&&C&&(0,U.jsx)(`div`,{className:`absolute top-1 right-5`,children:(0,U.jsx)(bm,{code:o,editorViewRef:p,currentLanguageAdapter:x,onAfterToggle:se})})]})})},wm=V.forwardRef((e,t)=>{let n=(0,H.c)(14),{className:r,editorView:i,hidden:a,showHiddenCode:o}=e,s=(0,V.useRef)(null),c,l;n[0]===i?(c=n[1],l=n[2]):(c=()=>{i!==null&&s.current!==null&&s.current.children.length===0&&s.current.append(i.dom)},l=[i,s],n[0]=i,n[1]=c,n[2]=l),(0,V.useEffect)(c,l);let u;n[3]===r?u=n[4]:(u=en(`cm mathjax_ignore`,r),n[3]=r,n[4]=u);let d;n[5]!==a||n[6]!==o?(d=e=>{a&&o&&(e.stopPropagation(),o({focus:!0}))},n[5]=a,n[6]=o,n[7]=d):d=n[7];let f;n[8]===t?f=n[9]:(f=e=>{t?dp(t,s)(e):dp(s)(e)},n[8]=t,n[9]=f);let p;return n[10]!==u||n[11]!==d||n[12]!==f?(p=(0,U.jsx)(`div`,{className:u,onDoubleClick:d,ref:f,"data-testid":`cell-editor`}),n[10]=u,n[11]=d,n[12]=f,n[13]=p):p=n[13],p});wm.displayName=`CellCodeMirrorEditor`;function Tm(e){let n=n=>{let r=(0,H.c)(5),a=i(Jt),[o,s]=t(Nf);if(me()&&Ie(n.id)&&(Xt(a.state)||o===void 0)){let e;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.jsx)(`span`,{children:`Waiting for real-time collaboration connection...`}),r[0]=e):e=r[0];let t;return r[1]===s?t=r[2]:(t=(0,U.jsx)(`div`,{className:`flex h-full w-full items-baseline p-4`,children:(0,U.jsxs)(nn,{milliseconds:1e3,fallback:null,children:[e,(0,U.jsx)(un,{variant:`link`,onClick:()=>{s(`disabled`)},children:`Turn off real-time collaboration`})]})}),r[1]=s,r[2]=t),t}let c;return r[3]===n?c=r[4]:(c=(0,U.jsx)(e,{...n}),r[3]=n,r[4]=c),c};return n.displayName=`WithWaitUntilConnected(${e.displayName})`,n}var Em=me()?Tm((0,V.memo)(Cm)):(0,V.memo)(Cm);export{fd as _,Zp as a,$a as b,dp as c,Jf as d,Vf as f,dd as g,hd as h,$p as i,tp as l,gd as m,bm as n,Jp as o,Nf as p,lm as r,Kp as s,Em as t,np as u,ud as v,eo as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,l as t,t as n,u as r}from"./useEvent-BDjgaBtz.js";import{D as i,In as a,M as o,P as s,gr as c,xo as l,za as u}from"./cells-
|
|
1
|
+
import{c as e,l as t,t as n,u as r}from"./useEvent-BDjgaBtz.js";import{D as i,In as a,M as o,P as s,gr as c,xo as l,za as u}from"./cells-B23_t5uX.js";import{t as d}from"./compiler-runtime-BrajqUja.js";import{p as f}from"./config-DpY86_Yq.js";import{g as p}from"./useEventListener-CjDeLqFC.js";import{i as m}from"./utils-B4K466FK.js";import{c as h}from"./session-CMLIzZKw.js";import{T as g,_}from"./config-CD1IuZFJ.js";import{t as v}from"./cn-ldLVeaqm.js";import{t as y}from"./jsx-runtime-B74pBk57.js";import{n as b}from"./paths-bkIFVj8h.js";import{b as x}from"./write-secret-modal-BEx-EUlh.js";import{r as S}from"./requests-BIFR-h4M.js";var C=d();function w(){return t(u)}function T(){let t=(0,C.c)(5),[i]=e(_),a=r(u),{openAlert:o}=x(),{sendRename:s}=S(),c;return t[0]!==i.state||t[1]!==o||t[2]!==s||t[3]!==a?(c=async e=>{let t=f();return i.state===g.OPEN?(h(t=>{e===null?t.delete(m.filePath):t.set(m.filePath,e)}),s({filename:e}).then(()=>(a(e),document.title=t.app_title||b.basename(e)||`Untitled Notebook`,e)).catch(e=>(o(e.message),null))):(o(`Failed to save notebook: not connected to a kernel.`),null)},t[0]=i.state,t[1]=o,t[2]=s,t[3]=a,t[4]=c):c=t[4],n(c)}var E=y(),D=e=>{let t=(0,C.c)(12),{className:n,cellId:r,variant:c,onClick:l,formatCellName:u,skipScroll:d}=e,f=s()[r]??``,p=o().inOrderIds.indexOf(r),{showCellIfHidden:m}=i(),h=u??j,g;t[0]===n?g=t[1]:(g=v(`inline-block cursor-pointer text-link hover:underline`,n),t[0]=n,t[1]=g);let _;t[2]!==r||t[3]!==l||t[4]!==m||t[5]!==d||t[6]!==c?(_=e=>{if(r===`__scratch__`)return!1;m({cellId:r}),e.stopPropagation(),e.preventDefault(),requestAnimationFrame(()=>{A(r,c,d)&&l?.()})},t[2]=r,t[3]=l,t[4]=m,t[5]=d,t[6]=c,t[7]=_):_=t[7];let y=h(a(f,p)),b;return t[8]!==g||t[9]!==_||t[10]!==y?(b=(0,E.jsx)(`div`,{className:g,role:`link`,tabIndex:-1,onClick:_,children:y}),t[8]=g,t[9]=_,t[10]=y,t[11]=b):b=t[11],b},O=e=>{let t=(0,C.c)(2),n;return t[0]===e?n=t[1]:(n=(0,E.jsx)(D,{...e,variant:`destructive`}),t[0]=e,t[1]=n),n},k=e=>{let t=(0,C.c)(10),{cellId:n,lineNumber:r}=e,i=w(),a;t[0]!==n||t[1]!==r?(a=()=>c(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]!==n||t[4]!==i?(o=e=>n===`__scratch__`?`scratch`:`marimo://${i||`untitled`}#cell=${e}`,t[3]=n,t[4]=i,t[5]=o):o=t[5];let s;return t[6]!==n||t[7]!==a||t[8]!==o?(s=(0,E.jsx)(D,{cellId:n,onClick:a,skipScroll:!0,variant:`destructive`,className:`traceback-cell-link`,formatCellName:o}),t[6]=n,t[7]=a,t[8]=o,t[9]=s):s=t[9],s};function A(e,t,n){let r=l.create(e),i=document.getElementById(r),a=i?.classList.contains(`has-error`);return i===null?(p.error(`Cell ${r} not found on page.`),!1):(n||i.scrollIntoView({behavior:`smooth`,block:`center`}),(t===`destructive`||a&&t===void 0)&&(i.classList.add(`error-outline`),setTimeout(()=>{i.classList.remove(`error-outline`)},2e3)),(t===`focus`||!a&&t===void 0)&&(i.classList.add(`focus-outline`),setTimeout(()=>{i.classList.remove(`focus-outline`)},2e3)),!0)}function j(e){return e}export{w as a,A as i,O as n,T as o,k as r,D as t};
|