@marimo-team/frontend 0.24.1-dev61 → 0.24.1-dev62
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-DeTZJKkI.js → CellStatus-ByrqmRbF.js} +1 -1
- package/dist/assets/{JsonOutput-CucHb-Xd.js → JsonOutput-DbjqR1zZ.js} +1 -1
- package/dist/assets/{MarimoErrorOutput-9BDdSrft.js → MarimoErrorOutput-CidvW8yi.js} +1 -1
- package/dist/assets/{RenderHTML-9AmE10az.js → RenderHTML-DyTQ_aJR.js} +1 -1
- package/dist/assets/{RunButton-B1OO4yPE.js → RunButton-Cv_ckYEH.js} +1 -1
- package/dist/assets/{add-cell-with-ai-B382kx-8.js → add-cell-with-ai-DKAX5Wkq.js} +1 -1
- package/dist/assets/{add-connection-dialog-CCgzVaXE.js → add-connection-dialog-k-xbLWdR.js} +1 -1
- package/dist/assets/{agent-panel-tC3KSuFA.js → agent-panel-BJEEx6sL.js} +1 -1
- package/dist/assets/{ai-model-dropdown-BwTphSMd.js → ai-model-dropdown-Cwwyj9FR.js} +1 -1
- package/dist/assets/{app-config-button-C3LicTtk.js → app-config-button-DOupOPfE.js} +1 -1
- package/dist/assets/{blob-EfjbJ__b.js → blob-D2x71aTK.js} +1 -1
- package/dist/assets/{cell-editor-CR6poe2J.js → cell-editor-CA-TDKsV.js} +1 -1
- package/dist/assets/{cell-link-q2lv7md_.js → cell-link-c74wFaiz.js} +1 -1
- package/dist/assets/{cells-v0dAmt79.js → cells-DNoi9Edm.js} +3 -3
- package/dist/assets/{chat-display-C-KzQ4Sl.js → chat-display-1WcDqz9D.js} +1 -1
- package/dist/assets/{chat-panel-BM8a5kkg.js → chat-panel-BwFn9Fqv.js} +1 -1
- package/dist/assets/{chat-ui-B10QUDuE.js → chat-ui-Dh1Yvmb2.js} +1 -1
- package/dist/assets/{column-preview-DahZx7i3.js → column-preview-BrO557-t.js} +1 -1
- package/dist/assets/{command-palette-DLDqpso1.js → command-palette-09UTreJu.js} +1 -1
- package/dist/assets/{common-C-hdr6As.js → common-CAMZMCwq.js} +1 -1
- package/dist/assets/{components-Cnt-rCdC.js → components-DJLtV_Mj.js} +1 -1
- package/dist/assets/{datasource-Bq9EwG3Q.js → datasource-DVv7qUFu.js} +1 -1
- package/dist/assets/{dependency-graph-panel-DLgUYv2G.js → dependency-graph-panel-IgEoFXFw.js} +1 -1
- package/dist/assets/{documentation-panel-BIqV8dCY.js → documentation-panel-CpJX3LTt.js} +1 -1
- package/dist/assets/{download-D-WORhyV.js → download-CCPBCjzu.js} +1 -1
- package/dist/assets/{edit-page-rjLWDywQ.js → edit-page-acN1qybv.js} +4 -4
- package/dist/assets/{error-entries-DOcZqCs5.js → error-entries-DOS37j7f.js} +1 -1
- package/dist/assets/{error-panel-xPtHRph4.js → error-panel-B3q6q2Gs.js} +1 -1
- package/dist/assets/{file-explorer-panel-YhKO1Kb8.js → file-explorer-panel-uum_XPfd.js} +1 -1
- package/dist/assets/{file-icons-BI3Xijjz.js → file-icons-CLGmPKoJ.js} +1 -1
- package/dist/assets/{file-name-input-B0v9VVzS.js → file-name-input-DC441YXk.js} +1 -1
- package/dist/assets/{floating-outline-fI7KiW7l.js → floating-outline-W5HJSoBY.js} +1 -1
- package/dist/assets/{home-page-BMzFHuuq.js → home-page-ChhDXfUJ.js} +1 -1
- package/dist/assets/{index-B2a_xizI.js → index-CTgrlfah.js} +3 -3
- package/dist/assets/{layout-Dqce0OL2.js → layout-D6bpFA5-.js} +3 -3
- package/dist/assets/{logs-panel-BlKmgk9O.js → logs-panel-DmbccYWJ.js} +1 -1
- package/dist/assets/{markdown-renderer-BHFj8yJ6.js → markdown-renderer-CB2UurmB.js} +1 -1
- package/dist/assets/{name-cell-input-9y9cdffD.js → name-cell-input-CX4R8mJV.js} +1 -1
- package/dist/assets/{outline-panel-BkyU6F0r.js → outline-panel-LEx0BFUs.js} +1 -1
- package/dist/assets/{packages-panel-DGuBWpad.js → packages-panel-C1GVBEEm.js} +1 -1
- package/dist/assets/{panel-accordion-state-C2vAFKpP.js → panel-accordion-state-HNISBQa4.js} +1 -1
- package/dist/assets/{panels-ZCSZ8vcg.js → panels-DHzJd4RF.js} +1 -1
- package/dist/assets/{process-output-DmEilKB6.js → process-output-DIhqtgs6.js} +1 -1
- package/dist/assets/{readonly-code-display-2N0THiJK.js → readonly-code-display-Cee30pk_.js} +1 -1
- package/dist/assets/{readonly-python-code-DyB_sdtx.js → readonly-python-code-m_9bVgtt.js} +1 -1
- package/dist/assets/{reveal-component-DmwU8_uO.js → reveal-component-UsIugcdk.js} +1 -1
- package/dist/assets/{run-page-C-fKIihG.js → run-page-BBlp0Qjt.js} +1 -1
- package/dist/assets/{scratchpad-panel-D_0HEFCV.js → scratchpad-panel-H9rBgtaS.js} +1 -1
- package/dist/assets/{session-panel-BAqFjL9-.js → session-panel-F_IDPTWG.js} +1 -1
- package/dist/assets/{skeleton-BUOlBrWg.js → skeleton-HSX1nQ-v.js} +1 -1
- package/dist/assets/{snippets-panel-C4dcsNOG.js → snippets-panel-DpCuVkpq.js} +1 -1
- package/dist/assets/{state-Du63Xg9M.js → state-CHqSZb7R.js} +1 -1
- package/dist/assets/{state-C8pDImyF.js → state-DGgHgBN9.js} +1 -1
- package/dist/assets/{tracing-DPTkPFxO.js → tracing-BEJAq4zg.js} +1 -1
- package/dist/assets/{tracing-panel-3SQN2w-o.js → tracing-panel-D8QL7Nar.js} +2 -2
- package/dist/assets/{tree-actions-Bn9POqng.js → tree-actions-CxkW_mv4.js} +1 -1
- package/dist/assets/{useAddCell-DtdPi8nq.js → useAddCell-CAX4gqgE.js} +1 -1
- package/dist/assets/{useCellActionButton-BS300A54.js → useCellActionButton-Cje0V_da.js} +1 -1
- package/dist/assets/{useDeleteCell-Ha8ut0yy.js → useDeleteCell-CL_90v2g.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-DsrUeu8t.js → useDependencyPanelTab-BEA9Hqzv.js} +1 -1
- package/dist/assets/{useNotebookActions-DdgIE9oe.js → useNotebookActions-Rn6aXLN2.js} +1 -1
- package/dist/assets/{useRunCells-CIALOcRX.js → useRunCells-DttzF-pt.js} +1 -1
- package/dist/assets/{useSplitCell-dEuZjk85.js → useSplitCell-BD2q-Clc.js} +1 -1
- package/dist/index.html +19 -19
- package/package.json +1 -1
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +66 -1
- package/src/core/codemirror/copilot/getCodes.ts +22 -25
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +25 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t}from"./useEvent-xfs0Sn4r.js";import{t as n}from"./react-CBDbhulC.js";import{$t as r,An as i,Mn as a,Wn as o,an as s,en as c,fn as l,hn as u,in as d,mn as f,on as p,rn as m,tn as h}from"./cells-v0dAmt79.js";import{t as g}from"./compiler-runtime-CYIjoINj.js";import{C as _,O as v,k as y}from"./utils-CUZQNAWJ.js";import{E as b,d as x,f as S,i as C,n as w,u as T}from"./ai-model-dropdown-BwTphSMd.js";import{N as E}from"./config-DaNyNpZL.js";import{t as D}from"./jsx-runtime-B74pBk57.js";import{o as O}from"./alert-dialog-DBoy-FMx.js";import{l as k}from"./select-BUEX2Vfl.js";import{t as A}from"./tooltip-D7dq6bnc.js";import{t as j}from"./button-BMBznEru.js";import{s as M}from"./arrays-BqUx5USx.js";import{r as N}from"./requests-C6_IaFh7.js";import{t as P}from"./createLucideIcon-B7HeEoG2.js";import{r as F}from"./useNumberFormatter-DHJ9s6Vk.js";import{M as I,T as L,b as R,j as z,p as ee,w as B}from"./write-secret-modal-BG_B6y1P.js";import{r as V}from"./input-DeyycFtq.js";import{t as H}from"./settings-C-cYas75.js";import{t as te}from"./use-toast-DpWHUGuF.js";import{t as U}from"./VisuallyHidden-DurJ_JBW.js";import{n as W}from"./useDebounce-Dulm61-t.js";import{t as G}from"./kbd-Cwh96ZBE.js";import{t as K}from"./Inputs-E85rt2lh.js";var ne=P(`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=D(),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}=R(),{sendShutdown:l}=N(),u;t[0]===l?u=t[1]:(u=()=>{l(),setTimeout(X,200)},t[0]=l,t[1]=u);let d=u;if(E())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)(O,{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)(F,{strokeWidth:1}),t[7]=m):m=t[7];let h;t[8]!==a||t[9]!==f||t[10]!==p?(h=(0,J.jsx)(K,{"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)(A,{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]=_(),{saveAppConfig:l}=N(),u=(0,Z.useId)(),f=(0,Z.useId)(),g;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(v),e[0]=g):g=e[0];let y;e[1]===t?y=e[2]:(y={resolver:g,defaultValues:t},e[1]=t,e[2]=y);let b=a(y),C;e[3]!==l||e[4]!==n?(C=async e=>{await l({config:e}).then(()=>{n(e)}).catch(()=>{n(e)})},e[3]=l,e[4]=n,e[5]=C):C=e[5];let w=C,T;e[6]===w?T=e[7]:(T=e=>{w(e)},e[6]=w,e[7]=T);let E=W(T,re),D;e[8]===t.width?D=e[9]:(D=[t.width],e[8]=t.width,e[9]=D),(0,Z.useEffect)(ae,D);let O;e[10]!==E||e[11]!==b?(O=b.handleSubmit(E),e[10]=E,e[11]=b,e[12]=O):O=e[12];let k;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,J.jsxs)(`div`,{children:[(0,J.jsx)(S,{children:`Notebook Settings`}),(0,J.jsx)(x,{children:`Configure how your notebook or application looks and behaves.`})]}),e[13]=k):k=e[13];let A;e[14]===b.control?A=e[15]:(A=(0,J.jsxs)(Q,{title:`Display`,children:[(0,J.jsx)(m,{control:b.control,name:`width`,render:se}),(0,J.jsx)(m,{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)(m,{control:b.control,name:`css_file`,render:ce}),(0,J.jsx)(m,{control:b.control,name:`html_head_file`,render:le})]}),e[16]=b.control,e[17]=j);let P;e[18]===b.control?P=e[19]:(P=(0,J.jsx)(Q,{title:`Data`,children:(0,J.jsx)(m,{control:b.control,name:`sql_output`,render:de})}),e[18]=b.control,e[19]=P);let F;e[20]!==u||e[21]!==f?(F=e=>{let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(d,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(c,{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)(o,{id:u,"data-testid":`html-checkbox`,checked:t.value.includes(`html`),onCheckedChange:()=>{t.onChange(M(t.value,`html`))}}),(0,J.jsx)(s,{htmlFor:u,children:`HTML`})]}),(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(o,{id:f,"data-testid":`ipynb-checkbox`,checked:t.value.includes(`ipynb`),onCheckedChange:()=>{t.onChange(M(t.value,`ipynb`))}}),(0,J.jsx)(s,{htmlFor:f,children:`IPYNB`})]})]})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(h,{children:[`When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named`,` `,(0,J.jsx)(G,{className:`inline`,children:`__marimo__`}),` next to your notebook file.`]})]})},e[20]=u,e[21]=f,e[22]=F):F=e[22];let I;e[23]!==b.control||e[24]!==F?(I=(0,J.jsx)(Q,{title:`Exporting outputs`,children:(0,J.jsx)(m,{control:b.control,name:`auto_download`,render:F})}),e[23]=b.control,e[24]=F,e[25]=I):I=e[25];let L;e[26]!==I||e[27]!==A||e[28]!==j||e[29]!==P?(L=(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-8 gap-y-4`,children:[A,j,P,I]}),e[26]=I,e[27]=A,e[28]=j,e[29]=P,e[30]=L):L=e[30];let R;e[31]!==L||e[32]!==O?(R=(0,J.jsxs)(`form`,{onChange:O,className:`flex flex-col gap-6`,children:[k,L]}),e[31]=L,e[32]=O,e[33]=R):R=e[33];let z;return e[34]!==b||e[35]!==R?(z=(0,J.jsx)(r,{...b,children:R}),e[34]=b,e[35]=R,e[36]=z):z=e[36],z},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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{children:`Width`}),(0,J.jsx)(c,{children:(0,J.jsx)(k,{"data-testid":`app-width-select`,onChange:e=>t.onChange(e.target.value),value:t.value,disabled:t.disabled,className:`inline-flex mr-2`,children:b().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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{children:`App title`}),(0,J.jsx)(c,{children:(0,J.jsx)(V,{...t,value:t.value??``,onChange:e=>{t.onChange(e.target.value),y.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsx)(h,{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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{className:`shrink-0`,children:`Custom CSS`}),(0,J.jsx)(c,{children:(0,J.jsx)(V,{...t,value:t.value??``,placeholder:`custom.css`,onChange:e=>{t.onChange(e.target.value),y.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsx)(h,{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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{className:`shrink-0`,children:`HTML Head`}),(0,J.jsx)(c,{children:(0,J.jsx)(V,{...t,value:t.value??``,placeholder:`head.html`,onChange:e=>{t.onChange(e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(h,{children:[`A filepath to an HTML file to be injected into the`,` `,(0,J.jsx)(G,{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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{children:`SQL Output Type`}),(0,J.jsx)(c,{children:(0,J.jsx)(k,{"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:T.map(ue)})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(h,{children:[`The Python type returned by a SQL cell. For best performance with large datasets, we recommend using`,` `,(0,J.jsx)(G,{className:`inline`,children:`native`}),`. See the`,` `,(0,J.jsx)(ee,{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,[d,p]=t(w),m=s?`disabled`:`hint-green`,h;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,J.jsx)(H,{strokeWidth:1.8}),n[0]=h):h=n[0];let g;n[1]===c?g=n[2]:(g=(0,J.jsx)(A,{content:c,children:h}),n[1]=c,n[2]=g);let _;n[3]!==s||n[4]!==m||n[5]!==g?(_=(0,J.jsx)(K,{"aria-label":`Config`,"data-testid":`app-config-button`,shape:`circle`,size:`small`,className:`h-[27px] w-[27px]`,disabled:s,color:m,children:g}),n[3]=s,n[4]=m,n[5]=g,n[6]=_):_=n[6];let v=_,y;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,J.jsxs)(L,{className:`w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0`,children:[(0,J.jsx)(U,{children:(0,J.jsx)(z,{children:`User settings`})}),(0,J.jsx)(C,{})]}),n[7]=y):y=n[7];let b=y;if(!o){let e;n[8]===v?e=n[9]:(e=(0,J.jsx)(I,{children:v}),n[8]=v,n[9]=e);let t;return n[10]!==p||n[11]!==d||n[12]!==e?(t=(0,J.jsxs)(B,{open:d,onOpenChange:p,children:[e,b]}),n[10]=p,n[11]=d,n[12]=e,n[13]=t):t=n[13],t}let x;n[14]===v?x=n[15]:(x=(0,J.jsx)(u,{asChild:!0,children:v}),n[14]=v,n[15]=x);let S,T;n[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,J.jsx)(ie,{}),T=(0,J.jsx)(`div`,{className:`h-px bg-border my-2`}),n[16]=S,n[17]=T):(S=n[16],T=n[17]);let E;n[18]===p?E=n[19]:(E=()=>p(!0),n[18]=p,n[19]=E);let D;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,J.jsx)(H,{strokeWidth:1.8,className:`w-4 h-4 mr-2`}),n[20]=D):D=n[20];let O;n[21]===E?O=n[22]:(O=(0,J.jsxs)(f,{className:`w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]`,align:`end`,side:`bottom`,onFocusOutside:pe,children:[S,T,(0,J.jsxs)(j,{onClick:E,variant:`link`,className:`px-0`,children:[D,`User settings`]})]}),n[21]=E,n[22]=O);let k;n[23]!==O||n[24]!==x?(k=(0,J.jsxs)(l,{children:[x,O]}),n[23]=O,n[24]=x,n[25]=k):k=n[25];let M;n[26]!==p||n[27]!==d?(M=(0,J.jsx)(B,{open:d,onOpenChange:p,children:b}),n[26]=p,n[27]=d,n[28]=M):M=n[28];let N;return n[29]!==k||n[30]!==M?(N=(0,J.jsxs)(J.Fragment,{children:[k,M]}),n[29]=k,n[30]=M,n[31]=N):N=n[31],N};function pe(e){return e.preventDefault()}export{Y as n,ne as r,fe as t};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t}from"./useEvent-xfs0Sn4r.js";import{t as n}from"./react-CBDbhulC.js";import{$t as r,An as i,Mn as a,Wn as o,an as s,en as c,fn as l,hn as u,in as d,mn as f,on as p,rn as m,tn as h}from"./cells-DNoi9Edm.js";import{t as g}from"./compiler-runtime-CYIjoINj.js";import{C as _,O as v,k as y}from"./utils-CUZQNAWJ.js";import{E as b,d as x,f as S,i as C,n as w,u as T}from"./ai-model-dropdown-Cwwyj9FR.js";import{N as E}from"./config-DaNyNpZL.js";import{t as D}from"./jsx-runtime-B74pBk57.js";import{o as O}from"./alert-dialog-DBoy-FMx.js";import{l as k}from"./select-BUEX2Vfl.js";import{t as A}from"./tooltip-D7dq6bnc.js";import{t as j}from"./button-BMBznEru.js";import{s as M}from"./arrays-BqUx5USx.js";import{r as N}from"./requests-C6_IaFh7.js";import{t as P}from"./createLucideIcon-B7HeEoG2.js";import{r as F}from"./useNumberFormatter-DHJ9s6Vk.js";import{M as I,T as L,b as R,j as z,p as ee,w as B}from"./write-secret-modal-BG_B6y1P.js";import{r as V}from"./input-DeyycFtq.js";import{t as H}from"./settings-C-cYas75.js";import{t as te}from"./use-toast-DpWHUGuF.js";import{t as U}from"./VisuallyHidden-DurJ_JBW.js";import{n as W}from"./useDebounce-Dulm61-t.js";import{t as G}from"./kbd-Cwh96ZBE.js";import{t as K}from"./Inputs-E85rt2lh.js";var ne=P(`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=D(),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}=R(),{sendShutdown:l}=N(),u;t[0]===l?u=t[1]:(u=()=>{l(),setTimeout(X,200)},t[0]=l,t[1]=u);let d=u;if(E())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)(O,{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)(F,{strokeWidth:1}),t[7]=m):m=t[7];let h;t[8]!==a||t[9]!==f||t[10]!==p?(h=(0,J.jsx)(K,{"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)(A,{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]=_(),{saveAppConfig:l}=N(),u=(0,Z.useId)(),f=(0,Z.useId)(),g;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(v),e[0]=g):g=e[0];let y;e[1]===t?y=e[2]:(y={resolver:g,defaultValues:t},e[1]=t,e[2]=y);let b=a(y),C;e[3]!==l||e[4]!==n?(C=async e=>{await l({config:e}).then(()=>{n(e)}).catch(()=>{n(e)})},e[3]=l,e[4]=n,e[5]=C):C=e[5];let w=C,T;e[6]===w?T=e[7]:(T=e=>{w(e)},e[6]=w,e[7]=T);let E=W(T,re),D;e[8]===t.width?D=e[9]:(D=[t.width],e[8]=t.width,e[9]=D),(0,Z.useEffect)(ae,D);let O;e[10]!==E||e[11]!==b?(O=b.handleSubmit(E),e[10]=E,e[11]=b,e[12]=O):O=e[12];let k;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,J.jsxs)(`div`,{children:[(0,J.jsx)(S,{children:`Notebook Settings`}),(0,J.jsx)(x,{children:`Configure how your notebook or application looks and behaves.`})]}),e[13]=k):k=e[13];let A;e[14]===b.control?A=e[15]:(A=(0,J.jsxs)(Q,{title:`Display`,children:[(0,J.jsx)(m,{control:b.control,name:`width`,render:se}),(0,J.jsx)(m,{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)(m,{control:b.control,name:`css_file`,render:ce}),(0,J.jsx)(m,{control:b.control,name:`html_head_file`,render:le})]}),e[16]=b.control,e[17]=j);let P;e[18]===b.control?P=e[19]:(P=(0,J.jsx)(Q,{title:`Data`,children:(0,J.jsx)(m,{control:b.control,name:`sql_output`,render:de})}),e[18]=b.control,e[19]=P);let F;e[20]!==u||e[21]!==f?(F=e=>{let{field:t}=e;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-y-1`,children:[(0,J.jsxs)(d,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(c,{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)(o,{id:u,"data-testid":`html-checkbox`,checked:t.value.includes(`html`),onCheckedChange:()=>{t.onChange(M(t.value,`html`))}}),(0,J.jsx)(s,{htmlFor:u,children:`HTML`})]}),(0,J.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,J.jsx)(o,{id:f,"data-testid":`ipynb-checkbox`,checked:t.value.includes(`ipynb`),onCheckedChange:()=>{t.onChange(M(t.value,`ipynb`))}}),(0,J.jsx)(s,{htmlFor:f,children:`IPYNB`})]})]})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(h,{children:[`When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named`,` `,(0,J.jsx)(G,{className:`inline`,children:`__marimo__`}),` next to your notebook file.`]})]})},e[20]=u,e[21]=f,e[22]=F):F=e[22];let I;e[23]!==b.control||e[24]!==F?(I=(0,J.jsx)(Q,{title:`Exporting outputs`,children:(0,J.jsx)(m,{control:b.control,name:`auto_download`,render:F})}),e[23]=b.control,e[24]=F,e[25]=I):I=e[25];let L;e[26]!==I||e[27]!==A||e[28]!==j||e[29]!==P?(L=(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-8 gap-y-4`,children:[A,j,P,I]}),e[26]=I,e[27]=A,e[28]=j,e[29]=P,e[30]=L):L=e[30];let R;e[31]!==L||e[32]!==O?(R=(0,J.jsxs)(`form`,{onChange:O,className:`flex flex-col gap-6`,children:[k,L]}),e[31]=L,e[32]=O,e[33]=R):R=e[33];let z;return e[34]!==b||e[35]!==R?(z=(0,J.jsx)(r,{...b,children:R}),e[34]=b,e[35]=R,e[36]=z):z=e[36],z},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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{children:`Width`}),(0,J.jsx)(c,{children:(0,J.jsx)(k,{"data-testid":`app-width-select`,onChange:e=>t.onChange(e.target.value),value:t.value,disabled:t.disabled,className:`inline-flex mr-2`,children:b().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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{children:`App title`}),(0,J.jsx)(c,{children:(0,J.jsx)(V,{...t,value:t.value??``,onChange:e=>{t.onChange(e.target.value),y.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsx)(h,{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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{className:`shrink-0`,children:`Custom CSS`}),(0,J.jsx)(c,{children:(0,J.jsx)(V,{...t,value:t.value??``,placeholder:`custom.css`,onChange:e=>{t.onChange(e.target.value),y.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsx)(h,{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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{className:`shrink-0`,children:`HTML Head`}),(0,J.jsx)(c,{children:(0,J.jsx)(V,{...t,value:t.value??``,placeholder:`head.html`,onChange:e=>{t.onChange(e.target.value)}})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(h,{children:[`A filepath to an HTML file to be injected into the`,` `,(0,J.jsx)(G,{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)(d,{className:`flex flex-row items-center space-x-1 space-y-0`,children:[(0,J.jsx)(s,{children:`SQL Output Type`}),(0,J.jsx)(c,{children:(0,J.jsx)(k,{"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:T.map(ue)})}),(0,J.jsx)(p,{})]}),(0,J.jsxs)(h,{children:[`The Python type returned by a SQL cell. For best performance with large datasets, we recommend using`,` `,(0,J.jsx)(G,{className:`inline`,children:`native`}),`. See the`,` `,(0,J.jsx)(ee,{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,[d,p]=t(w),m=s?`disabled`:`hint-green`,h;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,J.jsx)(H,{strokeWidth:1.8}),n[0]=h):h=n[0];let g;n[1]===c?g=n[2]:(g=(0,J.jsx)(A,{content:c,children:h}),n[1]=c,n[2]=g);let _;n[3]!==s||n[4]!==m||n[5]!==g?(_=(0,J.jsx)(K,{"aria-label":`Config`,"data-testid":`app-config-button`,shape:`circle`,size:`small`,className:`h-[27px] w-[27px]`,disabled:s,color:m,children:g}),n[3]=s,n[4]=m,n[5]=g,n[6]=_):_=n[6];let v=_,y;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,J.jsxs)(L,{className:`w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0`,children:[(0,J.jsx)(U,{children:(0,J.jsx)(z,{children:`User settings`})}),(0,J.jsx)(C,{})]}),n[7]=y):y=n[7];let b=y;if(!o){let e;n[8]===v?e=n[9]:(e=(0,J.jsx)(I,{children:v}),n[8]=v,n[9]=e);let t;return n[10]!==p||n[11]!==d||n[12]!==e?(t=(0,J.jsxs)(B,{open:d,onOpenChange:p,children:[e,b]}),n[10]=p,n[11]=d,n[12]=e,n[13]=t):t=n[13],t}let x;n[14]===v?x=n[15]:(x=(0,J.jsx)(u,{asChild:!0,children:v}),n[14]=v,n[15]=x);let S,T;n[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,J.jsx)(ie,{}),T=(0,J.jsx)(`div`,{className:`h-px bg-border my-2`}),n[16]=S,n[17]=T):(S=n[16],T=n[17]);let E;n[18]===p?E=n[19]:(E=()=>p(!0),n[18]=p,n[19]=E);let D;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,J.jsx)(H,{strokeWidth:1.8,className:`w-4 h-4 mr-2`}),n[20]=D):D=n[20];let O;n[21]===E?O=n[22]:(O=(0,J.jsxs)(f,{className:`w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]`,align:`end`,side:`bottom`,onFocusOutside:pe,children:[S,T,(0,J.jsxs)(j,{onClick:E,variant:`link`,className:`px-0`,children:[D,`User settings`]})]}),n[21]=E,n[22]=O);let k;n[23]!==O||n[24]!==x?(k=(0,J.jsxs)(l,{children:[x,O]}),n[23]=O,n[24]=x,n[25]=k):k=n[25];let M;n[26]!==p||n[27]!==d?(M=(0,J.jsx)(B,{open:d,onOpenChange:p,children:b}),n[26]=p,n[27]=d,n[28]=M):M=n[28];let N;return n[29]!==k||n[30]!==M?(N=(0,J.jsxs)(J.Fragment,{children:[k,M]}),n[29]=k,n[30]=M,n[31]=N):N=n[31],N};function pe(e){return e.preventDefault()}export{Y as n,ne as r,fe as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./markdown-renderer-
|
|
1
|
+
import{a as e}from"./markdown-renderer-CB2UurmB.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,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./loro_wasm_bg-BzjWitFM.js","./loro_wasm_bg-BRA1AbB3.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-xfs0Sn4r.js";import{t as u}from"./react-CBDbhulC.js";import{$a as d,$n as f,Aa as p,B as m,Ba as h,Bi as g,Br as _,Ci as v,Di as y,Dr as b,E as x,Ei as S,F as C,Fr as w,Gn as T,H as E,Hr as D,Ja as O,Jr as k,K as ee,Ko as te,Ln as A,Lr as ne,No as j,Oi as re,Qa as ie,Qi as ae,Rr as M,Sn as oe,So as se,Sr as N,St as ce,Ti as le,U as P,Ur as F,V as ue,Vr as de,Vt as fe,W as pe,Wn as me,Wr as he,Wt as ge,_i as _e,_t as ve,ai as ye,ar as be,bn as xe,bt as Se,ct as Ce,da as we,di as Te,dr as Ee,fi as De,fn as Oe,fr as ke,ga as Ae,gi as je,gn as Me,go as Ne,gt as Pe,ht as Fe,i as Ie,ja as Le,jo as Re,jr as ze,l as Be,li as Ve,lr as He,lt as Ue,m as We,mi as Ge,mn as Ke,oi as qe,or as Je,pi as Ye,pr as Xe,qa as Ze,qr as Qe,si as $e,sr as et,to as tt,tr as nt,u as rt,ur as it,ut as at,vn as ot,vt as st,wi as ct,wt as lt,xi as ut,xn as dt,xt as ft,y as pt,yo as mt,yt as ht,za as gt,zr as _t}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-xfs0Sn4r.js";import{t as u}from"./react-CBDbhulC.js";import{$a as d,$n as f,Aa as p,B as m,Ba as h,Bi as g,Br as _,Ci as v,Di as y,Dr as b,E as x,Ei as S,F as C,Fr as w,Gn as T,H as E,Hr as D,Ja as O,Jr as k,K as ee,Ko as te,Ln as A,Lr as ne,No as j,Oi as re,Qa as ie,Qi as ae,Rr as M,Sn as oe,So as se,Sr as N,St as ce,Ti as le,U as P,Ur as F,V as ue,Vr as de,Vt as fe,W as pe,Wn as me,Wr as he,Wt as ge,_i as _e,_t as ve,ai as ye,ar as be,bn as xe,bt as Se,ct as Ce,da as we,di as Te,dr as Ee,fi as De,fn as Oe,fr as ke,ga as Ae,gi as je,gn as Me,go as Ne,gt as Pe,ht as Fe,i as Ie,ja as Le,jo as Re,jr as ze,l as Be,li as Ve,lr as He,lt as Ue,m as We,mi as Ge,mn as Ke,oi as qe,or as Je,pi as Ye,pr as Xe,qa as Ze,qr as Qe,si as $e,sr as et,to as tt,tr as nt,u as rt,ur as it,ut as at,vn as ot,vt as st,wi as ct,wt as lt,xi as ut,xn as dt,xt as ft,y as pt,yo as mt,yt as ht,za as gt,zr as _t}from"./cells-DNoi9Edm.js";import{t as vt}from"./react-dom-BQrReHnR.js";import{Cn as yt,In as bt,Jn as xt,Sn as St,Tt as Ct,kt as wt,ln as Tt,xt as Et}from"./schemas-aTUejmFi.js";import{t as Dt}from"./compiler-runtime-CYIjoINj.js";import{t as Ot}from"./debounce-aFmHgJZY.js";import{D as kt,_ as At,c as jt,g as Mt,l as Nt,v as Pt}from"./utils-CUZQNAWJ.js";import{D as Ft,O as It,b as Lt,g as Rt,h as zt,m as Bt,t as Vt,w as Ht}from"./ai-model-dropdown-Cwwyj9FR.js";import{_ as Ut,c as Wt,g as Gt,m as Kt,t as qt}from"./useEventListener-D27Dii_l.js";import{t as Jt}from"./invariant-Ci2dTZ72.js";import{E as Yt,N as Xt,O as Zt,S as Qt,T as $t,m as en,o as tn,r as nn,v as rn}from"./config-DaNyNpZL.js";import{n as an,t as on}from"./switch-27TbonxF.js";import{c as sn,n as cn,r as ln}from"./readonly-python-code-m_9bVgtt.js";import{t as un}from"./ErrorBoundary-TUuUdxHz.js";import{t as dn}from"./cn-ldLVeaqm.js";import{t as fn}from"./jsx-runtime-B74pBk57.js";import{d as pn}from"./select-BUEX2Vfl.js";import{J as mn,Y as hn}from"./JsonOutput-DbjqR1zZ.js";import{n as gn}from"./download-CCPBCjzu.js";import{t as _n}from"./tooltip-D7dq6bnc.js";import{r as vn,t as yn}from"./button-BMBznEru.js";import{At as bn,Bt as xn,Ct as Sn,Dt as Cn,E as wn,Et as Tn,Ft as En,Gt as Dn,H as On,Ht as kn,I as An,P as jn,Pt as Mn,Qt as Nn,Rt as Pn,St as Fn,Tt as In,Ut as Ln,V as Rn,Wt as zn,Yt as Bn,Zt as I,_ as Vn,at as L,dt as Hn,en as Un,gt as Wn,ht as Gn,lt as Kn,m as qn,ot as Jn,qt as Yn,rn as Xn,st as R,ut as Zn,w as Qn,xt as $n}from"./dist-PIe1xcZo.js";import{C as er,E as tr,I as nr,O as rr,S as ir,a as ar,c as or,n as sr,r as cr,w as lr}from"./dist-CbQrIaPV.js";import{o as ur}from"./arrays-BqUx5USx.js";import{n as dr}from"./once-Haz_uxEL.js";import{t as fr}from"./createReducer-Bq-nQJiK.js";import{a as pr,c as mr,f as hr,h as gr,i as _r,l as vr,n as yr,o as br,t as xr}from"./dist-Dz_04liz.js";import{r as Sr}from"./strings-CpYReX2Q.js";import{r as Cr,t as wr}from"./requests-C6_IaFh7.js";import{t as Tr}from"./createLucideIcon-B7HeEoG2.js";import{r as Er,t as Dr}from"./layout-D6bpFA5-.js";import{r as Or}from"./useNumberFormatter-DHJ9s6Vk.js";import{t as kr}from"./circle-check-CUWv70QX.js";import{B as Ar,F as jr,G as Mr,I as Nr,L as Pr,M as Fr,R as Ir,T as Lr,V as Rr,W as zr,c as Br,f as Vr,i as Hr,n as Ur,o as Wr,r as Gr,s as Kr,w as qr,z as Jr}from"./add-cell-with-ai-DKAX5Wkq.js";import{t as Yr}from"./database-zap-CloO6gbw.js";import{r as Xr,t as Zr}from"./file-icons-CLGmPKoJ.js";import{t as Qr}from"./components-ib4asSo7.js";import{D as $r,E as ei,T as ti,b as ni,j as ri}from"./write-secret-modal-BG_B6y1P.js";import{n as ii}from"./spinner-Ck-Hgfvj.js";import{n as ai,t as oi}from"./useDeleteCell-CL_90v2g.js";import{t as si}from"./save-BybsbOKz.js";import{I as ci,Mt as li,P as ui}from"./input-DeyycFtq.js";import{t as di}from"./badge-D_-uqy2N.js";import{t as fi}from"./preload-helper-HclGiUj8.js";import{a as pi}from"./dist-DzAWvPVK.js";import{t as mi}from"./use-toast-DpWHUGuF.js";import{n as hi}from"./paths-zcL04qUW.js";import{t as gi}from"./session-CEdta5_Q.js";import{r as _i}from"./useTheme-D3zvxdF3.js";import{t as vi}from"./context-Do8M9TDF.js";import{i as yi}from"./numbers-DKurV_vq.js";import{n as bi}from"./useAsyncData-Buhk-UgR.js";import{n as xi}from"./copy-Cg05mM3C.js";import{a as Si}from"./useRunCells-DttzF-pt.js";import{a as Ci}from"./errors-DzO-nXy-.js";import{t as z}from"./extends-CvVTau-c.js";import{i as wi,n as Ti}from"./esm-Dw0vvSg2.js";import{t as Ei}from"./kbd-Cwh96ZBE.js";import{a as Di}from"./useInstallPackage-Bq7SlWgN.js";import{a as Oi,n as ki}from"./state-CHqSZb7R.js";import{a as Ai,o as ji}from"./cell-link-c74wFaiz.js";import{a as Mi}from"./renderShortcut-CS4ccH3x.js";import{n as Ni,t as Pi}from"./icons-CjLa9BiH.js";import{t as Fi}from"./dist-8lhGoJ54.js";import{t as Ii}from"./requests-S_7PqcSt.js";import{n as Li}from"./formatting-BJlT1s_3.js";import{t as Ri}from"./useSplitCell-BD2q-Clc.js";import{n as zi,r as Bi,t as Vi}from"./panel-accordion-state-HNISBQa4.js";import{co as Hi,do as Ui,fo as Wi,ft as Gi,go as Ki,ho as qi,lo as Ji,mo as Yi,oo as Xi,po as Zi,so as Qi,uo as $i}from"./loro_wasm_bg-BRA1AbB3.js";import{t as ea}from"./ws-DLVysDhS.js";import{t as ta}from"./Inputs-E85rt2lh.js";import{r as na,t as ra}from"./skeleton-HSX1nQ-v.js";var ia=Tr(`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=Dn.define({combine:e=>Xn(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=Nn.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=Nn.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=Nn.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=Nn.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:Ln.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={mac:`⌘`,windows:`⊞ Win`,default:`Ctrl`};function Sa(){return navigator.platform.startsWith(`Mac`)?xa.mac:navigator.platform.startsWith(`Win`)?xa.windows:xa.default}function Ca(e){return e.replace(`Mod`,Sa()).replace(`-`,` `).toUpperCase()}function B(e,t){let n=document.createElement(e);return n.className=t,n}function wa(e,t,n=void 0){let r=()=>{};return(...i)=>(r(),new Promise((a,o)=>{let s=setTimeout(()=>a(e(...i)),t);r=()=>{clearTimeout(s),n!==void 0&&o(n)}}))}var Ta=Nn.define({create(){return{suggestion:null}},update(e,t){let n=t.effects.find(e=>e.is(Ea));return!t.docChanged&&!n&&!t.selection?e:n&&t.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),Ea=I.define();function Da(e,t){let n=e.state.selection.main.head,r=[],i=L.widget({widget:new Oa(t),side:1});return r.push(i.range(n)),L.set(r)}var Oa=class extends Hn{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}},ka=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){this.cache.set(e,{result:t,timestamp:Date.now()})}},Aa=(e,t)=>Zn.fromClass(class{abortController=null;cache;constructor(){this.cache=new ka(t.cacheTimeout??1e3)}async update(n){if(!n.docChanged||t.events?.beforeSuggestionFetch?.(n.view)===!1)return;this.abortController?.abort(),this.abortController=new AbortController;let r=n.state.doc,i=r.toString(),a=this.cache.get(i);if(a){n.view.dispatch({effects:Ea.of({text:a,doc:r})});return}try{let a=await e(n.state,this.abortController.signal,n.view);if(this.abortController.signal.aborted||t.events?.shouldShowSuggestion?.(n.view,a)===!1)return;this.cache.set(i,a),n.view.dispatch({effects:Ea.of({text:a,doc:r})})}catch(e){e instanceof Error&&e.name!==`AbortError`&&console.error(`Suggestion fetch error:`,e)}}destroy(){this.abortController?.abort()}}),ja=Zn.fromClass(class{decorations;constructor(){this.decorations=L.none}update(e){let t=e.state.field(Ta)?.suggestion;if(!t){this.decorations=L.none;return}this.decorations=Da(e.view,t)}},{decorations:e=>e.decorations});function Ma(e,t,n,r){return{...e.changeByRange(i=>{if(i===e.selection.main)return{changes:{from:n,to:r,insert:t},range:Ln.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:Ln.cursor(i.from-a+t.length)}}),userEvent:`input.complete`}}var Na=e=>{let t=e.state.field(Ta)?.suggestion;if(!t)return!1;let n=e.state.facet(Ia);return e.dispatch({...Ma(e.state,t,e.state.selection.main.head,e.state.selection.main.head)}),n.events?.onSuggestionAccepted?.(e,t),!0},Pa=e=>{let t=e.state.field(Ta)?.suggestion;if(!t)return!1;let n=e.state.facet(Ia);return e.dispatch({effects:Ea.of({text:null,doc:e.state.doc})}),n.events?.onSuggestionRejected?.(e,t),!0},Fa=In.of([{key:`Tab`,run:Na},{key:`Escape`,run:Pa}]),Ia=Dn.define({combine:e=>e.at(-1)});function La(e){let{delay:t=500,includeKeymap:n=!0}=e,r=wa(e.fetchFn,t);return[Ta,Ia.of(e),Aa(r,e),ja,n?Fa:[]]}var Ra=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`}});function za(e){let t=e.state.facet(sa),n={...aa,...t.keymaps},r=e.state.facet(Ba),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=Ca(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 Ba=Dn.define({combine(e){return Xn(e,{render:za,hideOnBlur:!1,label:`Edit with AI`})}}),Va=Zn.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(Ba);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(Ba).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()}}),Ha=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 Ua(){return[Va,Ha]}var Wa=class extends Hn{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">${Ca(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">${Ca(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}},Ga=class extends Hn{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 Ka(e){if(!e.prompt)throw Error(`prompt function is required`);let t={...aa,...e.keymaps};return[sa.of(e),la,fa,ma,ga,Ua(),Ra,In.of([{key:t.showInput,run:va}]),Yn.highest([In.of([{key:t.acceptEdit,run:ya},{key:t.rejectEdit,run:ba}])]),qa,Ja,Ya,Xa]}var qa=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})]})}),Ja=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}),Ya=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 Ga(n.prompt),side:-1}).range(a))}}return L.set(r)}),Xa=Nn.define({create(e){return L.none},update(e,t){let n=t.state.field(ma);return n?L.set([L.widget({widget:new Wa(n.oldCode),block:!0}).range(n.from)]):L.none},provide:e=>R.decorations.from(e)}),V=Dt(),H=e(u(),1),Za=()=>({entries:new Map}),{valueAtom:Qa,useActions:$a}=fr(Za,{submit:(e,t)=>{let{cellIds:n,deleteCell:r,deleteManyCells:i,store:a}=t,o=a.get(pt),s=a.get(ye),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)}),Za()):{...e,entries:l}},clear:()=>Za()});function eo(){let e=n(),{submit:t,clear:r}=$a(),{entries:a}=i(Qa),o=oi(),s=ai();return(0,H.useMemo)(()=>({submit:n=>{t({cellIds:n,deleteCell:o,deleteManyCells:s,store:e})},clear:r,get idle(){return a.size===0},get shouldConfirmDelete(){return a.size>1}}),[e,t,r,a,o,s])}function to(e){let t=(0,V.c)(16),n=i(Qa),r=$a(),a=ai(),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(no)}),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 no(e){return e.cellId}async function ro(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 Rr({stream:Mr({stream:e.body,schema:zr}).pipeThrough(new TransformStream({transform(e){if(!e.success)throw e.error;let r=e.value;if(Pr(r)&&r.type===jr)t=Nr.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 io(e){let t=`
|
|
4
4
|
${e.codeBefore}
|
|
5
5
|
<rewrite_this>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,l as t,t as n,u as r}from"./useEvent-xfs0Sn4r.js";import{Bn as i,E as a,N as o,br as s,go as c,j as l,jo as u}from"./cells-
|
|
1
|
+
import{c as e,l as t,t as n,u as r}from"./useEvent-xfs0Sn4r.js";import{Bn as i,E as a,N as o,br as s,go as c,j as l,jo as u}from"./cells-DNoi9Edm.js";import{t as d}from"./compiler-runtime-CYIjoINj.js";import{m as f}from"./utils-CUZQNAWJ.js";import{g as p}from"./useEventListener-D27Dii_l.js";import{r as m}from"./constants-BDbGiS7O.js";import{T as h,v as g}from"./config-DaNyNpZL.js";import{t as _}from"./cn-ldLVeaqm.js";import{t as v}from"./jsx-runtime-B74pBk57.js";import{r as y}from"./requests-C6_IaFh7.js";import{b}from"./write-secret-modal-BG_B6y1P.js";import{n as x}from"./paths-zcL04qUW.js";import{s as S}from"./session-CEdta5_Q.js";var C=d();function w(){return t(c)}function T(){let t=(0,C.c)(5),[i]=e(g),a=r(c),{openAlert:o}=b(),{sendRename:s}=y(),l;return t[0]!==i.state||t[1]!==o||t[2]!==s||t[3]!==a?(l=async e=>{let t=f();return i.state===h.OPEN?(S(t=>{e===null?t.delete(m.filePath):t.set(m.filePath,e)}),s({filename:e}).then(()=>(a(e),document.title=t.app_title||x.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]=l):l=t[4],n(l)}var E=v(),D=e=>{let t=(0,C.c)(12),{className:n,cellId:r,variant:s,onClick:c,formatCellName:u,skipScroll:d}=e,f=o()[r]??``,p=l().inOrderIds.indexOf(r),{showCellIfHidden:m}=a(),h=u??j,g;t[0]===n?g=t[1]:(g=_(`inline-block cursor-pointer text-link hover:underline`,n),t[0]=n,t[1]=g);let v;t[2]!==r||t[3]!==c||t[4]!==m||t[5]!==d||t[6]!==s?(v=e=>{if(r===`__scratch__`)return!1;m({cellId:r}),e.stopPropagation(),e.preventDefault(),requestAnimationFrame(()=>{A(r,s,d)&&c?.()})},t[2]=r,t[3]=c,t[4]=m,t[5]=d,t[6]=s,t[7]=v):v=t[7];let y=h(i(f,p)),b;return t[8]!==g||t[9]!==v||t[10]!==y?(b=(0,E.jsx)(`div`,{className:g,role:`link`,tabIndex:-1,onClick:v,children:y}),t[8]=g,t[9]=v,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=()=>s(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 c;return t[6]!==n||t[7]!==a||t[8]!==o?(c=(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]=c):c=t[9],c};function A(e,t,n){let r=u.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};
|
|
@@ -91,8 +91,8 @@ mark line col
|
|
|
91
91
|
`||e==`\r`)e=`\xA0`;else if(e==` `){e=`\xA0`;var l=t.coordsAtPos(a+1,-1);l&&(f=l.left-(l.left-n.left)/parseInt(d.tabSize))}else/[\uD800-\uDBFF]/.test(e)&&a<t.state.doc.length-1&&(e+=t.state.sliceDoc(a+1,a+2));let m=n.bottom-n.top;return new CO((f-o.left)/t.scaleX,(n.top-o.top+m*(1-s))/t.scaleY,m*s/t.scaleY,d.fontFamily,d.fontSize,d.fontWeight,d.color,r?`cm-fat-cursor cm-cursor-primary`:`cm-fat-cursor cm-cursor-secondary`,e,s!=1)}return null}var kO=typeof navigator<`u`&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent),AO=YD(sO),jO=pu.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:`none`},".cm-vim-panel":{padding:`0px 10px`,fontFamily:`monospace`,minHeight:`1.3em`,display:`flex`},".cm-vim-panel input":{border:`none`,outline:`none`,backgroundColor:`inherit`},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`}}),MO=hu.fromClass(class{constructor(e){this.status=``,this.query=null,this.decorations=Zl.none,this.waitForCopy=!1,this.lastKeydown=``,this.useNextTextInput=!1,this.compositionText=``,this.view=e;let t=this.cm=new sO(e);AO.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new wO(e,t),this.updateClass(),this.cm.on(`vim-command-done`,()=>{t.state.vim&&(t.state.vim.status=``),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on(`vim-mode-change`,e=>{t.state.vim&&(t.state.vim.mode=e.mode,e.subMode&&(t.state.vim.mode+=` block`),t.state.vim.status=``,this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on(`dialog`,()=>{this.cm.state.statusbar?this.updateStatus():e.dispatch({effects:FO.of(!!this.cm.state.dialog)})}),this.dom=document.createElement(`span`),this.spacer=document.createElement(`span`),this.spacer.style.flex=`1`,this.statusButton=document.createElement(`span`),this.statusButton.onclick=e=>{AO.handleKey(this.cm,`<Esc>`,`user`),this.cm.focus()},this.statusButton.style.cssText=`cursor: pointer`}update(e){if((e.viewportChanged||e.docChanged)&&this.query&&this.highlight(this.query),e.docChanged&&this.cm.onChange(e),e.selectionSet&&this.cm.onSelectionChange(),e.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),e.transactions){for(let t of e.transactions)for(let e of t.effects)if(e.is(ju)){if(!e.value?.forVim)this.highlight(null);else{let t=e.value.create();this.highlight(t)}}}this.blockCursor.update(e)}updateClass(){let e=this.cm.state;!e.vim||e.vim.insertMode&&!e.overwrite?this.view.scrollDOM.classList.remove(`cm-vimMode`):this.view.scrollDOM.classList.add(`cm-vimMode`)}updateStatus(){let e=this.cm.state.statusbar,t=this.cm.state.vim;if(!e||!t)return;let n=this.cm.state.dialog;if(n)n.parentElement!=e&&(e.textContent=``,e.appendChild(n));else{e.textContent=``;var r=(t.mode||`normal`).toUpperCase();t.insertModeReturn&&(r+=`(C-O)`),this.statusButton.textContent=`--${r}--`,e.appendChild(this.statusButton),e.appendChild(this.spacer)}this.dom.textContent=t.status,e.appendChild(this.dom)}destroy(){AO.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(e){if(this.query=e,!e)return this.decorations=Zl.none;let{view:t}=this,n=new Jl;for(let r=0,i=t.visibleRanges,a=i.length;r<a;r++){let{from:o,to:s}=i[r];for(;r<a-1&&s>i[r+1].from-500;)s=i[++r].to;e.highlight(t.state,o,s,(e,t)=>{n.add(e,t,PO)})}return this.decorations=n.finish()}handleKey(e,t){let n=this.cm,r=n.state.vim;if(!r)return;let i=AO.vimKeyFromEvent(e,r);if(sO.signal(this.cm,`inputEvent`,{type:`handleKey`,key:i}),!i)return;if(i==`<Esc>`&&!r.insertMode&&!r.visualMode&&this.query){let e=r.searchState_;e&&(n.removeOverlay(e.getOverlay()),e.setOverlay(null))}if(i===`<C-c>`&&!sO.isMac&&n.somethingSelected())return this.waitForCopy=!0,!0;r.status=(r.status||``)+i;let a=AO.multiSelectHandleKey(n,i,`user`);return r=AO.maybeInitVimState_(n),!a&&r.insertMode&&n.state.overwrite&&(e.key&&e.key.length==1&&!/\n/.test(e.key)?(a=!0,n.overWriteSelection(e.key)):e.key==`Backspace`&&(a=!0,sO.commands.cursorCharLeft(n))),a&&(sO.signal(this.cm,`vim-keypress`,i),e.preventDefault(),e.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!a}},{eventHandlers:{copy:function(e,t){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var e=this.cm,t=e.state.vim;t&&(t.insertMode?e.setSelection(e.getCursor(),e.getCursor()):e.operation(()=>{e.curOp&&(e.curOp.isVimOp=!0),AO.handleKey(e,`<Esc>`,`user`)}))}))},compositionstart:function(e,t){this.useNextTextInput=!0,sO.signal(this.cm,`inputEvent`,e)},compositionupdate:function(e,t){sO.signal(this.cm,`inputEvent`,e)},compositionend:function(e,t){sO.signal(this.cm,`inputEvent`,e)},keypress:function(e,t){sO.signal(this.cm,`inputEvent`,e),this.lastKeydown==`Dead`&&this.handleKey(e,t)},keydown:function(e,t){sO.signal(this.cm,`inputEvent`,e),this.lastKeydown=e.key,this.lastKeydown==`Unidentified`||this.lastKeydown==`Process`||this.lastKeydown==`Dead`?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(e,t))}},provide:()=>[pu.inputHandler.of((e,t,n,r)=>{var i=BO(e);if(!i)return!1;var a=i.state?.vim,o=i.state.vimPlugin;if(a&&!a.insertMode&&!i.curOp?.isVimOp){if(r===`\0\0`)return!0;if(sO.signal(i,`inputEvent`,{type:`text`,text:r,from:t,to:n}),r.length==1&&o.useNextTextInput){if(a.expectLiteralNext&&e.composing)return o.compositionText=r,!1;if(o.compositionText){var s=o.compositionText;o.compositionText=``;var c=e.state.selection.main.head;if(s===e.state.sliceDoc(c-s.length,c)){var l=i.getCursor();i.replaceRange(``,i.posFromIndex(c-s.length),l)}}return o.handleKey({key:r,preventDefault:()=>{},stopPropagation:()=>{}}),NO(e),!0}}return!1})],decorations:e=>e.decorations});function NO(e){var t=e.scrollDOM.parentElement;if(t){if(kO){e.contentDOM.textContent=`\0\0`,e.contentDOM.dispatchEvent(new CustomEvent(`compositionend`));return}var n=e.scrollDOM.nextSibling,r=window.getSelection(),i=r&&{anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset};e.scrollDOM.remove(),t.insertBefore(e.scrollDOM,n);try{i&&r&&(r.setPosition(i.anchorNode,i.anchorOffset),i.focusNode&&r.extend(i.focusNode,i.focusOffset))}catch(e){console.error(e)}e.focus(),e.contentDOM.dispatchEvent(new CustomEvent(`compositionend`))}}var PO=Zl.mark({class:`cm-searchMatch`}),FO=Yl.define(),IO=Bl.define({create:()=>!1,update(e,t){for(let n of t.effects)n.is(FO)&&(e=n.value);return e},provide:e=>Rl.from(e,e=>e?LO:null)});function LO(e){let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=e.cm;return n.state.dialog&&t.appendChild(n.state.dialog),{top:!1,dom:t}}function RO(e){let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=e.cm;return n.state.statusbar=t,n.state.vimPlugin.updateStatus(),{dom:t}}function zO(e={}){return[jO,MO,EO,e.status?Rl.of(RO):IO]}function BO(e){return e.cm||null}function VO(e){let t=e.state.selection.main;return t.from===0&&t.to===0}function HO(e,t=!1){let n=e.state.selection.main,r=e.state.doc.length;return t&&n.from===r-1&&n.to===r-1?!0:n.from===r&&n.to===r}function UO(e){e&&e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length}})}function WO(e){requestAnimationFrame(()=>{let t=e.current?.view;t&&(t.focus(),UO(t))})}function GO(e){let t=e.dom.closest(`.marimo-cell`);t&&requestAnimationFrame(()=>{t.scrollIntoView({behavior:`instant`,block:`nearest`,inline:`nearest`})})}function KO(e){return BO(e)?.state.vim!=null}function qO(e){let t=BO(e)?.state.vim;return t?!t.mode&&!t.insertMode&&!t.visualMode||t.mode===`normal`:!1}function JO(e){e&&e.dispatch({selection:{anchor:0,head:e.state.doc.length}})}var YO=new Set([Q.ClassDefinition]);function XO(e,t){requestAnimationFrame(()=>{e.focus(),e.dispatch({selection:{anchor:t,head:t},effects:pu.scrollIntoView(t,{y:`center`})})}),GO(e)}function ZO(e,t){let n=Ml(e),r=null;return n.iterate({enter:n=>{if(r!==null)return!1;if(n.name===Q.VariableName&&e.doc.sliceString(n.from,n.to)===t)return r=n.from,!1;if(n.name===Q.Comment||n.name===Q.String)return!1}}),r}function QO(e,t){let n=[],r=e.resolveInner(t,0);for(;r;)CD.has(r.name)&&(n.some(e=>e.type===Q.FunctionDefinition||e.type===Q.LambdaExpression)&&r.name===Q.ClassDefinition||n.push({id:r.from,type:r.name})),r=r.parent;return n.push({id:-1,type:`global`}),n}function $O(e,t,n){e.push({scopeId:t,from:n})}function ek(e,t){if(e.firstChild())do t(e.node);while(e.nextSibling())}function tk(e,t){let{state:n,variableName:r,scopeId:i,declarations:a}=t;switch(e.name){case Q.VariableName:n.doc.sliceString(e.from,e.to)===r&&$O(a,i,e.from);break;case Q.TupleExpression:case Q.ArrayExpression:{let n=e.node.cursor();n.firstChild();do tk(n,t);while(n.nextSibling());break}}}function nk(e,t){let{state:n,variableName:r,scopeId:i,declarations:a}=t,o=e.cursor();o.firstChild();do{if(o.name!==Q.ParamList)continue;let e=o.node.cursor();e.firstChild();do e.name===Q.VariableName&&n.doc.sliceString(e.from,e.to)===r&&$O(a,i,e.from);while(e.nextSibling())}while(o.nextSibling())}function rk(e,t){let n=e.cursor();n.firstChild();let r=!1;do if(n.name===SD.For)r=!0;else if(r&&n.name===SD.In)break;else r&&tk(n,t);while(n.nextSibling())}function ik(e,t){let{state:n,variableName:r,scopeStack:i,declarations:a}=t,o=e.cursor(),s=o.name,c=o.from,l=CD.has(s)?[...i,c]:i,u=l[l.length-1]??-1;switch(s){case Q.FunctionDefinition:case Q.ClassDefinition:{let t=e.cursor();t.firstChild();do if(t.name===Q.VariableName&&n.doc.sliceString(t.from,t.to)===r){$O(a,i[i.length-1]??-1,t.from);break}while(t.nextSibling());s===Q.FunctionDefinition&&nk(e,{state:n,variableName:r,scopeId:c,declarations:a});break}case Q.LambdaExpression:nk(e,{state:n,variableName:r,scopeId:c,declarations:a});break;case Q.ArrayComprehensionExpression:case Q.DictionaryComprehensionExpression:case Q.SetComprehensionExpression:case Q.ComprehensionExpression:case Q.ForStatement:rk(e,{state:n,variableName:r,scopeId:u,declarations:a});break;case Q.AssignStatement:{let t=[],i=e.cursor();i.firstChild();do i.name===Q.AssignOp&&t.push(i.from);while(i.nextSibling());let o=t[t.length-1];if(o===void 0)break;let s=e.cursor();s.firstChild();do s.from<o&&tk(s,{state:n,variableName:r,scopeId:u,declarations:a});while(s.nextSibling());break}case Q.ImportStatement:{let t=e.cursor();t.firstChild();let i=!1,o=null,s=()=>{o?.matches&&$O(a,u,o.from),o=null};do{if(t.name===SD.Import){i=!0;continue}if(i){if(t.name===SD.As){o=null;continue}t.name===Q.VariableName?(s(),o={from:t.from,matches:n.doc.sliceString(t.from,t.to)===r}):t.name===`,`&&s()}}while(t.nextSibling());s();break}case Q.TryStatement:case Q.WithStatement:{let t=e.cursor();t.firstChild();let i=!1;do t.name===SD.As?i=!0:i&&t.name===Q.VariableName&&n.doc.sliceString(t.from,t.to)===r&&($O(a,u,t.from),i=!1);while(t.nextSibling());break}}ek(o,e=>{ik(e,{state:n,variableName:r,scopeStack:l,declarations:a})})}function ak(e,t,n){let r=Ml(e),i=[];ik(r,{state:e,variableName:t,scopeStack:[],declarations:i});let a=Math.max(0,Math.min(n,e.doc.length));for(let e of QO(r,a)){let t=i.filter(t=>t.scopeId===e.id).filter(t=>!YO.has(e.type)||t.from<=a).toSorted((e,t)=>e.from-t.from)[0];if(t)return t.from}return null}function ok(e,t,n){let{state:r}=e,i=n===void 0?ZO(r,t):ak(r,t,n);return i!==null&&(XO(e,i),!0)}function sk(e,t){return XO(e,e.state.doc.line(t).from),!0}function ck(e,t){let n=u.get(ac);return(n===`mac`?e.mac??e.key:n===`windows`?e.win??e.key:e.linux??e.key)===t}function lk(e){let{from:t,to:n}=e.selection.main;if(t===n){let{startToken:n,endToken:r}=GD(e.doc,t);return{position:n,word:e.doc.sliceString(n,r)}}return{position:t,word:e.doc.sliceString(t,n)}}function uk(e,t){if(!t)return null;let n=e[t];return!n||n.declaredBy.length===0?null:n.declaredBy[0]}function dk(e){return e.startsWith(`_`)}function fk(e){let{state:t}=e,{position:n,word:r}=lk(t);return r?(Xu(e),e.dispatch({effects:uu}),hk(e,r,n)):!1}function pk(e,t=u.get(nc).getHotkey(`cell.goToDefinition`).key){for(let n of e.state.facet(H).flat())if(ck(n,t)&&n.run?.(e))return!0;return!1}function mk(e){return fk(e)?!0:pk(e)}function hk(e,t,n){if(n!==void 0&&ok(e,t,n))return!0;let r=_k(e,t);return r?ok(r,t):!1}function gk(e,t){let n=vk(e);return n?sk(n,t):!1}function _k(e,t){if(dk(t))return e;let n=uk(u.get(XE),t);return n?vk(n):null}function vk(e){return u.get(YU).cellHandles[e].current?.editorView??null}var yk=o(null);function bk(e){let t=u.get(yk);if(e===null){u.set(yk,null);return}(t?.cellId!==e.cellId||t.line!==e.line)&&u.set(yk,{...e,startedAtMs:Date.now()})}var xk=o(new Map),Sk=new Set;function Ck(e){return o(t=>{let n=t(yk);return n?.cellId===e?n.line:null})}function wk(e){return o(t=>{let n=t(yk);return n?.cellId===e?{line:n.line,startedAtMs:n.startedAtMs}:null})}function Tk(e){return o(t=>t(xk).get(e)??Sk)}function Ek(e){let t={};for(let[n,r]of e)r.size>0&&(t[n]=[...r].toSorted((e,t)=>e-t));id().sendSetBreakpoints({breakpoints:t}).catch(e=>{B.debug(`Failed to sync breakpoints to kernel`,{error:e})})}function Dk(e){let t=u.get(xk);if(!t.has(e))return;let n=new Map(t);n.delete(e),u.set(xk,n),Ek(n)}function Ok(){let e=u.get(xk);e.size>0&&Ek(e)}function kk(e,t){let n=u.get(xk),r=new Map(n),i=new Set(r.get(e)??[]);i.has(t)?i.delete(t):i.add(t),i.size>0?r.set(e,i):r.delete(e),u.set(xk,r),Ek(r)}function Ak(e,t){if(t==null||t<1||t>e.doc.lines)return Zl.none;let n=new Jl;try{let r=e.doc.line(t);n.add(r.from,r.from,Zl.line({class:`cm-debugger-current-line`}))}catch(e){B.debug(`Invalid debugger line`,{error:e})}return n.finish()}var jk=class{unsubscribe;decorations;constructor(e,t){this.decorations=Ak(e.state,t.get()),this.unsubscribe=t.sub(t=>{this.decorations=Ak(e.state,t),e.dispatch({userEvent:`marimo.debugger-line-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function Mk(e){return[hu.define(t=>new jk(t,e),{decorations:e=>e.decorations}),pu.theme({".cm-debugger-current-line":{backgroundColor:`color-mix(in srgb, var(--amber-4) 50%, transparent)`}})]}var Nk=new class extends eu{toDOM(){let e=document.createElement(`div`);return e.className=`cm-breakpoint-marker`,e}},Pk=Yl.define(),Fk=Bl.define({create:()=>new Set,update(e,t){for(let e of t.effects)if(e.is(Pk))return e.value;return e}});function Ik(e){let t=e.field(Fk);if(t.size===0)return Fl.empty;let n=new Jl;for(let r of[...t].toSorted((e,t)=>e-t))if(r>=1&&r<=e.doc.lines){let t=e.doc.line(r);n.add(t.from,t.from,Nk)}return n.finish()}var Lk=class{unsubscribe;constructor(e,t){let n=t=>{e.dispatch({effects:Pk.of(t)})};t.get().size>0&&queueMicrotask(()=>n(t.get())),this.unsubscribe=t.sub(n)}destroy(){this.unsubscribe()}};function Rk(e,t){return[Fk,hu.define(e=>new Lk(e,t)),$l({class:`cm-breakpoint-gutter`,markers:e=>Ik(e.state),initialSpacer:()=>Nk,domEventHandlers:{mousedown:(t,n)=>{let r=t.state.doc.lineAt(n.from).number;return kk(e,r),!0}}}),pu.theme({".cm-breakpoint-gutter":{width:`14px`,cursor:`pointer`},".cm-breakpoint-marker":{width:`8px`,height:`8px`,borderRadius:`50%`,backgroundColor:`var(--red-9)`,margin:`4px auto`}})]}var zk=class e{ms;static fromMilliseconds(t){return t==null?null:new e(t)}static fromSeconds(t){return t==null?null:new e(t*1e3)}static now(){return new e(Date.now())}constructor(e){this.ms=e}toMilliseconds(){return this.ms}toSeconds(){return this.ms/1e3}};function Bk(e){if(e===null)return``;let t=e,n=t/1e3;return n>=60?`${Math.floor(n/60)}m${Math.floor(n%60)}s`:n>=1?`${n.toFixed(2).toString()}s`:`${t.toFixed(0).toString()}ms`}var Vk=500,Hk=250,Uk=class e extends tu{static intervals=new WeakMap;startedAtMs;constructor(e){super(),this.startedAtMs=e}eq(e){return e.startedAtMs===this.startedAtMs}toDOM(){let t=document.createElement(`span`);t.className=`cm-line-timer`,t.setAttribute(`aria-hidden`,`true`);let n=()=>{let e=Date.now()-this.startedAtMs;t.textContent=e>=Vk?Bk(e):``};return n(),e.intervals.set(t,window.setInterval(n,Hk)),t}destroy(t){let n=e.intervals.get(t);n!==void 0&&(window.clearInterval(n),e.intervals.delete(t))}ignoreEvent(){return!0}};function Wk(e,t){if(t===null||t.line<1||t.line>e.doc.lines)return Zl.none;let n=new Jl;try{let r=e.doc.line(t.line);n.add(r.from,r.from,Zl.line({class:`cm-timing-current-line`})),n.add(r.to,r.to,Zl.widget({widget:new Uk(t.startedAtMs),side:1}))}catch(e){B.debug(`Invalid timing line`,{error:e})}return n.finish()}var Gk=class{unsubscribe;decorations;constructor(e,t){this.decorations=Wk(e.state,t.get()),this.unsubscribe=t.sub(t=>{this.decorations=Wk(e.state,t),e.dispatch({userEvent:`marimo.timing-line-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function Kk(e){return[hu.define(t=>new Gk(t,e),{decorations:e=>e.decorations}),pu.theme({".cm-timing-current-line":{backgroundColor:`color-mix(in srgb, var(--grass-4) 50%, transparent)`},".cm-line-timer":{color:`var(--grass-11)`,fontSize:`0.85em`,marginLeft:`1.5ch`,pointerEvents:`none`}})]}function qk(e,t){if(!t?.length)return Zl.none;let n=new Jl,r=e.facet(gC),i=t.filter(e=>e.kind===`cell`&&e.cellId===r).toSorted((e,t)=>e.lineNumber-t.lineNumber);for(let t of i)try{let r=e.doc.line(t.lineNumber),i=Zl.line({class:`cm-error-line`});n.add(r.from,r.from,i)}catch(e){B.debug(`Invalid line number in error decoration`,{error:e})}return n.finish()}function Jk(e,t){if(!t?.length)return;let n=e.state.facet(gC),r=t.filter(e=>e.kind===`cell`&&e.cellId===n);if(r.length===0)return;let i=ou(e.state),a=[];for(let t of r)try{let n=e.state.doc.line(t.lineNumber);i.between(n.from,n.to,(e,t)=>{a.push(Gl.of({from:e,to:t}))})}catch(e){B.debug(`Invalid line numbers`,{error:e})}a.length>0&&e.dispatch({effects:a})}var Yk=class{unsubscribe;decorations;constructor(e,t){let n=t.get();this.decorations=qk(e.state,n),Jk(e,n),this.unsubscribe=t.sub(t=>{let n=this.decorations.size;this.decorations=qk(e.state,t),Jk(e,t),n!==this.decorations.size&&e.dispatch({userEvent:`marimo.error-decoration-update`})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function Xk(e){return hu.define(t=>new Yk(t,e),{decorations:e=>e.decorations})}function Zk(e){return[Xk(e),pu.theme({".cm-error-line":{backgroundColor:`color-mix(in srgb, var(--red-4) 40%, transparent)`},"&.cm-focused .cm-error-line.cm-activeLine":{backgroundColor:`color-mix(in srgb, var(--red-5) 40%, transparent)`}})]}function Qk({cellId:e,hotkeys:t}){let n=[];return n.push(...cc({key:t.getHotkey(`cell.run`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.facet(hC).onRun(),!0)}),{key:t.getHotkey(`cell.runAndNewBelow`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(hC);return n.onRun(),e===`__scratch__`||(t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!1}),!0)}},...cc({key:t.getHotkey(`cell.runAndNewAbove`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(hC);return n.onRun(),e===`__scratch__`||(t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!0}),!0)}}),{key:t.getHotkey(`cell.aiCompletion`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.facet(hC).aiCellCompletion()&&e.contentDOM.focus(),!0)}),e!==`__scratch__`&&n.push({key:t.getHotkey(`cell.goToDefinition`).key,run:e=>fk(e)},{key:t.getHotkey(`cell.delete`).key,preventDefault:!0,stopPropagation:!0,run:e=>(e.state.doc.length===0&&e.state.facet(hC).deleteCell(),!0)},{key:t.getHotkey(`cell.moveUp`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(hC).moveCell({cellId:e,before:!0}),!0)},{key:t.getHotkey(`cell.moveDown`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(hC).moveCell({cellId:e,before:!1}),!0)},{key:t.getHotkey(`cell.moveLeft`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(hC).moveCell({cellId:e,before:!0,direction:`left`}),!0)},{key:t.getHotkey(`cell.moveRight`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(hC).moveCell({cellId:e,before:!1,direction:`right`}),!0)},{key:`ArrowUp`,run:t=>Ju(t.state)?!1:VO(t)?(t.state.facet(hC).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0):!1},{key:`ArrowDown`,run:t=>Ju(t.state)?!1:HO(t)?(t.state.facet(hC).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0):!1},{key:t.getHotkey(`cell.focusDown`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(hC).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0)},{key:t.getHotkey(`cell.focusUp`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(hC).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0)},{key:t.getHotkey(`cell.sendToBottom`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(hC).sendToBottom({cellId:e}),!0)},{key:t.getHotkey(`cell.sendToTop`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.state.facet(hC).sendToTop({cellId:e}),!0)},{key:t.getHotkey(`cell.createAbove`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.contentDOM.blur(),t.state.facet(hC).createNewCell({cellId:e,before:!0}),!0)},{key:t.getHotkey(`cell.createBelow`).key,preventDefault:!0,stopPropagation:!0,run:t=>(t.contentDOM.blur(),t.state.facet(hC).createNewCell({cellId:e,before:!1}),!0)},{key:t.getHotkey(`cell.hideCode`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(hC).toggleHideCode();return Xu(t),n?(t.contentDOM.blur(),document.getElementById(Xm.create(e))?.focus()):t.contentDOM.focus(),!0}},{key:t.getHotkey(`cell.splitCell`).key,preventDefault:!0,stopPropagation:!0,run:t=>{let n=t.state.facet(hC);return n.splitCell({cellId:e}),n.moveToNextCell&&requestAnimationFrame(()=>{t.contentDOM.blur(),n.moveToNextCell({cellId:e,before:!1})}),!0}}),[fu.high(H.of(n))]}function $k(e){return[pu.updateListener.of(e=>{if(e.docChanged){let t=e.transactions.some(e=>e.effects.some(e=>e.is(kT))),n=rH(e.view),r=e.view.state.facet(hC),i=e.view.state.facet(gC);r.updateCellCode({cellId:i,code:n,formattingChange:t}),u.get(DE).has(i)&&u.set(OE)}}),WE(e)]}var eA=[`input`,`delete`,`undo`,`redo`];function tA({docChanged:e,transactions:t,predicate:n=()=>!0,hasFocus:r=!1}){return!e||!n()||t.some(e=>e.effects.some(e=>e.is(kT)))?!1:t.some(e=>e.annotation(NE)===void 0?eA.some(t=>e.isUserEvent(t))||r:!1)}function nA({predicate:e}){return pu.updateListener.of(t=>{tA({docChanged:t.docChanged,transactions:t.transactions,predicate:e,hasFocus:t.view.hasFocus})&&t.view.state.facet(hC).onRun()})}function rA({cellId:e,hotkeys:t,cellActions:n}){let r=LE(`debugger`),i=LE(`line_timing`);return[hC.of(n),gC.of(e),Qk({cellId:e,hotkeys:t}),$k(t),Zk(zE(VW(e),u)),r?Rk(e,zE(Tk(e),u)):[],i?Kk(zE(wk(e),u)):r?Mk(zE(Ck(e),u)):[]]}var iA=Yl.define(),aA=20;function oA(e){let{state:t,anchor:n,head:r}=e;if(r<n)return!1;let i=t.doc.lineAt(r).number,a=t.doc.lineAt(n).number,o=Math.max(a,i-aA+1),s=Math.max(n,t.doc.line(o).from),c=s>n,l=+!!c,u=t.doc.iterRange(s,r);for(;;){let{value:e,done:t}=u.next();if(t)break;for(let t of e)if(t===`(`)l++;else if(t===`)`&&(l--,c?l<=0:l<0))return!1}return!0}function sA(e){return{...e,create:t=>{let{dom:n,...r}=e.create(t),i=document.createElement(`div`);return i.classList.add(`mo-cm-tooltip`),i.append(n),{...r,dom:i}}}}var cA=Bl.define({create:()=>null,update(e,t){for(let e of t.effects)if(e.is(iA))return e.value;if(!e||t.selection&&!t.docChanged)return null;if(t.docChanged){let n=t.changes.mapPos(e.pos);return oA({state:t.state,anchor:n,head:t.state.selection.main.head})?{...e,pos:n}:null}return e},provide:e=>zl.from(e)});function lA(e){return e.state.field(cA,!1)?(e.dispatch({effects:iA.of(null)}),!0):!1}var uA=async e=>{let t=e.state.doc.sliceString(0,e.pos),n=document.activeElement,r=null;if(n!==null){let e=Xm.findElement(n);e!==null&&(r=Xm.parse(e.id))}if(r===null)return B.error(`Failed to find active cell.`),null;let i=await zD.request({document:t,cellId:r});if(!i)return e.view?.dispatch({effects:iA.of(null)}),null;let a=VD.asHoverTooltip({position:e.pos,message:i,limitToType:`tooltip`});return a&&u.set(xD,{documentation:a.html??null}),e.view?.dispatch({effects:iA.of(a?sA(a):null)}),a?null:VD.asCompletionResult(e.pos,i)};function dA(e){return t=>e.predicate(t.state)?e.completion(t):null}var fA=async e=>{let t=e.matchBefore(/:\w*$/);if(!e.explicit&&!t)return null;let n=await pA();return{from:t?.from??e.pos,options:n,validFor:/^[\w:]*$/}},pA=Uu(async()=>{let e=await fetch(`https://unpkg.com/emojilib@3.0.11/dist/emoji-en-US.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch emoji list`);return e.json()}).catch(()=>({}));return Object.entries(e).map(([e,t])=>({shortcode:t[0],label:t.map(e=>`:${e}`).join(` `),emoji:e,displayLabel:`${e} ${t[0].replaceAll(`_`,` `)}`,apply:e,type:`emoji`}))}),mA=async e=>{let t=e.matchBefore(/::[\w-:]*$/);if(!e.explicit&&!t)return null;let n=await hA();return{from:t?.from??e.pos,options:n,validFor:/^[\w-:]*$/}},hA=Uu(async()=>{let e=await fetch(`https://unpkg.com/lucide-static@0.452.0/tags.json`).then(e=>{if(!e.ok)throw Error(`Failed to fetch Lucide icon list`);return e.json()}).catch(()=>({})),t=e=>`https://cdn.jsdelivr.net/npm/lucide-static@0.452.0/icons/${e}.svg`;return Object.entries(e).map(([e,n])=>({label:`::${e}`,displayLabel:e,type:`lucide-icon`,boost:10,apply:`::lucide:${e}::`,detail:n.join(`, `),info:()=>{let n=document.createElement(`img`);return n.src=t(e),n.style.width=`24px`,n.style.height=`24px`,n}}))}),gA=e=>{let t=e.matchBefore(/\\\w*$/);return!e.explicit&&!t?null:{from:t?.from??e.pos,options:_A(),validFor:/^[\w\\]*$/}},_A=Uu(()=>[[`alpha`,`α`,`Greek small letter alpha`],[`beta`,`β`,`Greek small letter beta`],[`gamma`,`γ`,`Greek small letter gamma`],[`delta`,`δ`,`Greek small letter delta`],[`epsilon`,`ε`,`Greek small letter epsilon`],[`zeta`,`ζ`,`Greek small letter zeta`],[`eta`,`η`,`Greek small letter eta`],[`theta`,`θ`,`Greek small letter theta`],[`iota`,`ι`,`Greek small letter iota`],[`kappa`,`κ`,`Greek small letter kappa`],[`lambda`,`λ`,`Greek small letter lambda`],[`mu`,`μ`,`Greek small letter mu`],[`nu`,`ν`,`Greek small letter nu`],[`xi`,`ξ`,`Greek small letter xi`],[`omicron`,`ο`,`Greek small letter omicron`],[`pi`,`π`,`Greek small letter pi`],[`rho`,`ρ`,`Greek small letter rho`],[`sigma`,`σ`,`Greek small letter sigma`],[`tau`,`τ`,`Greek small letter tau`],[`upsilon`,`υ`,`Greek small letter upsilon`],[`phi`,`φ`,`Greek small letter phi`],[`chi`,`χ`,`Greek small letter chi`],[`psi`,`ψ`,`Greek small letter psi`],[`omega`,`ω`,`Greek small letter omega`],[`Gamma`,`Γ`,`Greek capital letter gamma`],[`Delta`,`Δ`,`Greek capital letter delta`],[`Theta`,`Θ`,`Greek capital letter theta`],[`Lambda`,`Λ`,`Greek capital letter lambda`],[`Xi`,`Ξ`,`Greek capital letter xi`],[`Pi`,`Π`,`Greek capital letter pi`],[`Sigma`,`Σ`,`Greek capital letter sigma`],[`Phi`,`Φ`,`Greek capital letter phi`],[`Psi`,`Ψ`,`Greek capital letter psi`],[`Omega`,`Ω`,`Greek capital letter omega`],[`pm`,`±`,`Plus-minus sign`],[`mp`,`∓`,`Minus-plus sign`],[`times`,`×`,`Multiplication sign`],[`div`,`÷`,`Division sign`],[`cdot`,`⋅`,`Dot operator`],[`ast`,`∗`,`Asterisk operator`],[`star`,`⋆`,`Star operator`],[`circ`,`∘`,`Ring operator`],[`bullet`,`•`,`Bullet`],[`cap`,`∩`,`Intersection`],[`cup`,`∪`,`Union`],[`uplus`,`⊎`,`Multiset union`],[`sqcap`,`⊓`,`Square cap`],[`sqcup`,`⊔`,`Square cup`],[`vee`,`∨`,`Logical or`],[`wedge`,`∧`,`Logical and`],[`setminus`,`∖`,`Set minus`],[`oplus`,`⊕`,`Circled plus`],[`ominus`,`⊖`,`Circled minus`],[`otimes`,`⊗`,`Circled times`],[`oslash`,`⊘`,`Circled division slash`],[`odot`,`⊙`,`Circled dot operator`],[`leq`,`≤`,`Less than or equal to`],[`geq`,`≥`,`Greater than or equal to`],[`equiv`,`≡`,`Identical to`],[`prec`,`≺`,`Precedes`],[`succ`,`≻`,`Succeeds`],[`sim`,`∼`,`Tilde operator`],[`perp`,`⊥`,`Up tack`],[`mid`,`∣`,`Divides`],[`parallel`,`∥`,`Parallel to`],[`subset`,`⊂`,`Subset of`],[`supset`,`⊃`,`Superset of`],[`subseteq`,`⊆`,`Subset of or equal to`],[`supseteq`,`⊇`,`Superset of or equal to`],[`cong`,`≅`,`Approximately equal to`],[`approx`,`≈`,`Almost equal to`],[`neq`,`≠`,`Not equal to`],[`ne`,`≠`,`Not equal to`],[`propto`,`∝`,`Proportional to`],[`leftarrow`,`←`,`Leftward arrow`],[`rightarrow`,`→`,`Rightward arrow`],[`Leftarrow`,`⇐`,`Leftward double arrow`],[`Rightarrow`,`⇒`,`Rightward double arrow`],[`leftrightarrow`,`↔`,`Left right arrow`],[`Leftrightarrow`,`⇔`,`Left right double arrow`],[`uparrow`,`↑`,`Upward arrow`],[`downarrow`,`↓`,`Downward arrow`],[`Uparrow`,`⇑`,`Upward double arrow`],[`Downarrow`,`⇓`,`Downward double arrow`],[`infty`,`∞`,`Infinity`],[`nabla`,`∇`,`Nabla`],[`partial`,`∂`,`Partial differential`],[`forall`,`∀`,`For all`],[`exists`,`∃`,`There exists`],[`nexists`,`∄`,`There does not exist`],[`emptyset`,`∅`,`Empty set`],[`in`,`∈`,`Element of`],[`notin`,`∉`,`Not an element of`],[`sum`,`∑`,`N-ary summation`],[`prod`,`∏`,`N-ary product`],[`int`,`∫`,`Integral`],[`oint`,`∮`,`Contour integral`],[`sqrt`,`√`,`Square root`],[`hbar`,`ℏ`,`Planck constant over 2pi`],[`ldots`,`…`,`Horizontal ellipsis`],[`cdots`,`⋯`,`Midline horizontal ellipsis`],[`vdots`,`⋮`,`Vertical ellipsis`],[`ddots`,`⋱`,`Down right diagonal ellipsis`]].map(([e,t,n])=>({label:`\\${e} ${n}`,displayLabel:e,type:`latex-symbol`,boost:10,apply:`\\${e}`,info:()=>{let e=document.createElement(`div`);return e.textContent=`${t} ${n}`,e},detail:t}))),vA=[fA,mA,gA],yA=100;function bA(e){return!e.state.selection.main.empty}function xA({view:e,selection:t,markup:n}){let r=[],i=!0;for(let r=t.from;r<=t.to;r++)if(!e.state.doc.lineAt(r).text.startsWith(n)){i=!1;break}for(let a=t.from;a<=t.to;){let t=e.state.doc.lineAt(a),o=t.text.startsWith(n);i?r.push({from:t.from,to:t.from+n.length,insert:Dl.of([``])}):(o&&r.push({from:t.from,to:t.from+n.length,insert:Dl.of([``])}),r.push({from:t.from,insert:Dl.of([n])})),a=t.to+1}return r}function SA({view:e,range:t,markupAfter:n,markupBefore:r}){if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}let i=e.state.sliceDoc(t.from-r.length,t.from)===r,a=e.state.sliceDoc(t.to,t.to+n.length)===n,o=[];o.push(i?{from:t.from-r.length,to:t.from,insert:Dl.of([``])}:{from:t.from,insert:Dl.of(r.split(`
|
|
92
92
|
`))},a?{from:t.to,to:t.to+n.length,insert:Dl.of([``])}:{from:t.to,insert:Dl.of(n.split(`
|
|
93
93
|
`))});let s=i?-r.length:r.length,c=a?-n.length:n.length;return{changes:o,range:U.range(t.from+s,t.to+c)}}function CA(e){if(!bA(e))return!1;let t=xA({view:e,selection:e.state.selection.main,markup:`> `});return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function wA(e){if(!bA(e))return!1;let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}return SA({view:e,range:t,markupBefore:`**`,markupAfter:`**`})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:nu.userEvent.of(`input`)})),e.focus(),!0}function TA(e){if(!bA(e))return!1;let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}let n=e.state.doc.lineAt(t.from).number!==e.state.doc.lineAt(t.to).number;return SA({view:e,range:t,markupBefore:n?"```\n":"`",markupAfter:n?"\n```":"`"})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:nu.userEvent.of(`input`)})),e.focus(),!0}function EA(e){let t=e.state.changeByRange(t=>{if(t.empty){let n=e.state.wordAt(t.head);n&&(t=n)}return SA({view:e,range:t,markupBefore:`_`,markupAfter:`_`})});return e.dispatch(e.state.update(t,{scrollIntoView:!0,annotations:nu.userEvent.of(`input`)})),e.focus(),!0}function DA(e,t=`http://`){if(!bA(e))return!1;let n=e.state.changeByRange(n=>{let r=e.state.sliceDoc(n.from,n.to);return{changes:[{from:n.from,to:n.to,insert:`[${r}](${t})`}],range:n}});e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:nu.userEvent.of(`input`)}));let{to:r}=n.selection.main;try{e.dispatch({selection:U.create([U.range(r+3,r+3+t.length),U.cursor(r+3+t.length)])})}catch{}return e.focus(),!0}async function OA(e,t){let n=new FileReader,r=await new Promise(e=>{n.onload=()=>e(n.result),n.readAsDataURL(t)}),i;try{if(r.startsWith(`data:`)){let e=prompt(`We can save your image as a file. Enter a filename.`,t.name),n=t.type.split(`/`)[1];if(e===null){let e=Math.round(r.length/1024);if(e>yA){of({title:`Content too large`,description:`The content size is ${e} KB, which is too large to paste directly into the document.`});return}}else{e.trim()===``?e=t.name:e.endsWith(`.${n}`)||(e=`${e}.${n}`);let r=u.get(K_),a=r?sf.dirname(r):null,o=a?`${a}/public`:`public`,s=await id().sendCreateFileOrFolder({path:o,type:`file`,name:e,file:t});s.success?(i=s.info?.path,i&&a&&i.startsWith(a)&&(i=sf.rest(i,a).replaceAll(`\\`,`/`)),of({title:`Image uploaded successfully`,description:`We've uploaded your image at ${i}`})):of({title:`Failed to upload image. Using raw base64 string.`})}}}catch{of({title:`Failed to upload image. Using raw base64 string.`})}let a=e.state.changeByRange(t=>{let n=e.state.sliceDoc(t.from,t.to);return n.trim()===``&&(n=`alt`),{changes:[{from:t.from,to:t.to,insert:``}],range:t}});e.dispatch(e.state.update(a,{scrollIntoView:!0,annotations:nu.userEvent.of(`input`)}));let{to:o}=a.selection.main;try{e.dispatch({selection:U.create([U.range(o+4,o+4+r.length),U.cursor(o+4+r.length)])})}catch{}return e.focus(),!0}async function kA(e,t){let n=await t.text(),r=e.state.changeByRange(e=>({changes:[{from:e.from,to:e.from,insert:n}],range:e}));return e.dispatch(e.state.update(r,{scrollIntoView:!0,annotations:nu.userEvent.of(`input`)})),e.focus(),!0}function AA(e){if(!bA(e))return!1;let{changes:t}=e.state.changeByRange(t=>({range:t,changes:xA({view:e,selection:t,markup:e.state.sliceDoc(t.from,t.to+2).startsWith(`* `)?`* `:`- `})}));return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function jA(e){if(!bA(e))return!1;let{changes:t}=e.state.changeByRange(t=>({range:t,changes:xA({view:e,selection:t,markup:`1. `})}));return t.length>0&&e.dispatch(e.state.update({changes:t,scrollIntoView:!0,userEvent:`input`})),e.focus(),!0}function MA(e){return[fu.highest(H.of([{key:e.getHotkey(`markdown.bold`).key,stopPropagation:!0,run:wA},{key:e.getHotkey(`markdown.italic`).key,stopPropagation:!0,run:EA},{key:e.getHotkey(`markdown.link`).key,stopPropagation:!0,run:e=>DA(e)},{key:e.getHotkey(`markdown.orderedList`).key,run:jA},{key:e.getHotkey(`markdown.unorderedList`).key,run:AA},{key:e.getHotkey(`markdown.blockquote`).key,run:CA},{key:e.getHotkey(`markdown.code`).key,run:TA},{key:"`",run:TA}])),pu.domEventHandlers({paste:(e,t)=>{if(t.state.selection.main.empty)return!1;let n=e.clipboardData?.getData(`text/plain`);n?.startsWith(`http`)&&(e.preventDefault(),DA(t,n))}}),pu.domEventHandlers({paste:(e,t)=>{let n=e.clipboardData?.files[0];if(!n)return!1;if(n.type.startsWith(`image/`))return e.preventDefault(),OA(t,n),!0;if(n.type.startsWith(`text/`))return e.preventDefault(),kA(t,n),!0}})]}function NA(e,t,n=3,r=``){return Object.values(e).flatMap(e=>t.has(e.name)?[]:{label:`${r}${e.name}`,displayLabel:e.name,detail:e.dataType??``,boost:n,type:`variable`,apply:`${r}${e.name}`,section:`Variable`,info:()=>PA(e)})}function PA(e){let t=document.createElement(`div`);t.classList.add(`mo-cm-tooltip`,`docs-documentation`,`min-w-[200px]`,`flex`,`flex-col`,`gap-1`,`p-2`);let n=document.createElement(`div`);n.classList.add(`flex`,`items-center`,`gap-2`);let r=document.createElement(`span`);if(r.classList.add(`font-bold`,`text-base`),r.textContent=e.name,n.append(r),e.dataType){let t=document.createElement(`span`);t.classList.add(`text-xs`,`px-1.5`,`py-0.5`,`rounded-full`,`bg-purple-100`,`text-purple-800`,`dark:bg-purple-900`,`dark:text-purple-200`),t.textContent=e.dataType,n.append(t)}if(t.append(n),e.value){let n=document.createElement(`div`);n.classList.add(`flex`,`flex-col`,`gap-1`);let r=document.createElement(`div`);r.classList.add(`text-xs`,`text-muted-foreground`),r.textContent=`Value:`,n.append(r);let i=document.createElement(`div`);i.classList.add(`text-xs`,`font-mono`,`bg-muted`,`p-2`,`rounded`,`overflow-auto`,`max-h-40`),i.textContent=e.value,n.append(i),t.append(n)}return t}var FA=`Python`,IA=123,LA=125,RA=1,zA={mark:`${FA}Mark`,resolve:FA};function BA(e,t){return{defineNodes:[{name:FA,style:ql.emphasis},{name:`${FA}Mark`,style:ql.processingInstruction}],parseInline:[{name:FA,parse(e,n,r){return!t()||n!==IA&&n!==LA||n===IA&&e.slice(r-1,r)===`{`?-1:e.addDelimiter(zA,r,r+RA,n===IA,n===LA)}}],wrap:iu(n=>{if(!t()||n.type.name!==FA)return null;let r=n.from+RA,i=n.to-RA;return r>=i||r<0||i<0?null:{parser:e,overlay:[{from:r,to:i}],extensions:[nf().support]}})}}var VA=e=>{let t=e.state.doc.sliceString(0,e.pos),n=t.lastIndexOf(`{`);if(t.at(n-1)===`{`||n===-1||t.indexOf(`}`,n)>n)return null;let r=e.matchBefore(/\w*$/);if(!r)return null;let i=NA(u.get(XE),new Set,99);return{from:r.from,options:i,validFor:/^\w*$/}},HA=`InlineMathDollar`,UA=`InlineMathBracket`,WA=`BlockMathDollar`,GA=`BlockMathBracket`,KA={[HA]:1,[UA]:3,[WA]:2,[GA]:3},qA={DOLLAR:36,BACKSLASH:92,OPEN_PAREN:40,CLOSE_PAREN:41,OPEN_BRACKET:91,CLOSE_BRACKET:93},JA=Object.keys(KA).reduce((e,t)=>(e[t]={mark:`${t}Mark`,resolve:t},e),{});function YA(e){let t=[];return Object.keys(KA).forEach(e=>{t.push({name:e,style:ql.emphasis},{name:`${e}Mark`,style:ql.processingInstruction})}),{defineNodes:t,parseInline:[{name:WA,parse(e,t,n){return t!==qA.DOLLAR||e.char(n+1)!==qA.DOLLAR?-1:e.addDelimiter(JA[WA],n,n+KA[WA],!0,!0)}},{name:HA,parse(e,t,n){return t!==qA.DOLLAR||e.char(n+1)===qA.DOLLAR?-1:e.addDelimiter(JA[HA],n,n+KA[HA],!0,!0)}},{name:UA,before:`Escape`,parse(e,t,n){return t!==qA.BACKSLASH||e.char(n+1)!==qA.BACKSLASH||![qA.OPEN_PAREN,qA.CLOSE_PAREN].includes(e.char(n+2))?-1:e.addDelimiter(JA[UA],n,n+KA[UA],e.char(n+2)===qA.OPEN_PAREN,e.char(n+2)===qA.CLOSE_PAREN)}},{name:GA,before:`Escape`,parse(e,t,n){return t!==qA.BACKSLASH||e.char(n+1)!==qA.BACKSLASH||![qA.OPEN_BRACKET,qA.CLOSE_BRACKET].includes(e.char(n+2))?-1:e.addDelimiter(JA[GA],n,n+KA[GA],e.char(n+2)===qA.OPEN_BRACKET,e.char(n+2)===qA.CLOSE_BRACKET)}},{name:UA,before:`Escape`,parse(e,t,n){return t!==qA.BACKSLASH||![qA.OPEN_PAREN,qA.CLOSE_PAREN].includes(e.char(n+1))?-1:e.addDelimiter(JA[UA],n,n+2,e.char(n+1)===qA.OPEN_PAREN,e.char(n+1)===qA.CLOSE_PAREN)}},{name:GA,before:`Escape`,parse(e,t,n){return t!==qA.BACKSLASH||![qA.OPEN_BRACKET,qA.CLOSE_BRACKET].includes(e.char(n+1))?-1:e.addDelimiter(JA[GA],n,n+2,e.char(n+1)===qA.OPEN_BRACKET,e.char(n+1)===qA.CLOSE_BRACKET)}}],wrap:iu(t=>{let n=KA[t.type.name];if(n){let r=t.from+n,i=t.to-n;return r>=i||r<0||i<0?null:{parser:e,overlay:[{from:r,to:i}]}}return null})}}var XA=Yl.define(),ZA=Yl.define(),QA=Bl.define({create:()=>({}),update:(e,t)=>{for(let n of t.effects){if(n.is(XA))return n.value;if(n.is(ZA))return{...e,...n.value}}return e}}),$A=class{parser=new _E;type=`markdown`;defaultCode=this.parser.defaultCode;defaultMetadata=this.parser.defaultMetadata;static fromMarkdown(e){return _E.fromMarkdown(e)}transformIn(e){let t=this.parser.transformIn(e);return[t.code,t.offset,t.metadata]}transformOut(e,t){let n=this.parser.transformOut(e,t);return[n.code,n.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,t,n,r){let i=Zd().language.data,a,o=()=>{if(!a)return!0;let e=a?.state.field(QA);return e===void 0?!1:e.quotePrefix?.includes(`f`)??!1};return[hu.define(e=>(a=e,{})),Zd({base:Qd,codeLanguages:IT,extensions:[YA(ru.define(af).parser),BA(ef.parser,o)]}),MA(n),vA.map(e=>i.of({autocomplete:e})),nf().language.data.of({autocomplete:dA({completion:uA,predicate:o})}),Qu({defaultKeymap:!1,activateOnTyping:!0}),nA({predicate:()=>!o()})]}},ej={PREFIX:`file:///`,of(e){return`${this.PREFIX}${e}`},is(e){return e.startsWith(this.PREFIX)},parse(e){return mc(this.is(e),`Invalid cell document URI: ${e}`),e.slice(this.PREFIX.length)}};function tj(e){return`notify`in e&&typeof e.notify==`function`}function nj(e){return`processNotification`in e&&typeof e.processNotification==`function`}function rj(e){return ej.is(e)?u.get(tW).inOrderIds.includes(ej.parse(e)):!1}function ij(){return u.get(J_)?.rootUri??`file:///`}function aj(){let e=u.get(J_)?.rootUri;return e?[{uri:e,name:`marimo`}]:[]}function oj(){return u.get(J_)?.documentUri??`file:///__marimo_notebook__.py`}function sj(e){return pc.filter(e,e=>e!==!1&&e!==null)}function cj(e){let t=e.map(sj);return Object.assign({},...t)}var lj=class{clients=[];documentUri;constructor(e){this.clients=e,this.documentUri=oj()}onNotification(e){let t=[];for(let n of this.clients)t.push(n.onNotification(e));return()=>{for(let e of t)e();return!0}}get clientCapabilities(){return cj(this.clients.map(e=>{if(e.clientCapabilities)return typeof e.clientCapabilities==`function`?e.clientCapabilities({}):e.clientCapabilities}).filter(e=>e!=null))}get ready(){return this.clients.some(e=>e.ready)}set ready(e){this.clients.forEach(t=>{t.ready=e})}get capabilities(){return cj(this.clients.map(e=>e.capabilities).filter(e=>e!==null))}set capabilities(e){this.clients.forEach(t=>{t.capabilities=e})}get initializePromise(){return this.clients[0].initializePromise}set initializePromise(e){this.clients.forEach(t=>{t.initializePromise=e})}firstWithMethod(e){return this.clients.find(t=>t.hasCapability(e))}clientsWithMethod(e){return this.clients.filter(t=>t.hasCapability(e))}hasCapability(e){return this.clients.some(t=>t.hasCapability(e))}async initialize(){await Promise.all(this.clients.map(e=>e.initialize()))}async close(){await Promise.all(this.clients.map(e=>e.close()))}async textDocumentDidChange(e){await Promise.all(this.clients.map(t=>t.textDocumentDidChange(e)))}async completionItemResolve(e){let t=this.firstWithMethod(`textDocument/completion`);return t?t.completionItemResolve(e):e}async textDocumentCodeAction(e){let t=this.firstWithMethod(`textDocument/codeAction`);return t?t.textDocumentCodeAction(e):null}async codeActionResolve(e){let t=this.firstWithMethod(`textDocument/codeAction`);return t?t.codeActionResolve(e):e}async textDocumentRename(e){let t=this.firstWithMethod(`textDocument/rename`);return t?t.textDocumentRename(e):null}async textDocumentPrepareRename(e){let t=this.firstWithMethod(`textDocument/prepareRename`);return t?t.textDocumentPrepareRename(e):null}async textDocumentSignatureHelp(e){let t=this.firstWithMethod(`textDocument/signatureHelp`);return t?t.textDocumentSignatureHelp(e):null}async textDocumentCompletion(e){let t=this.clientsWithMethod(`textDocument/completion`);return uj(await Promise.allSettled(t.map(t=>t.textDocumentCompletion(e))))}async textDocumentDefinition(e){let t=this.firstWithMethod(`textDocument/definition`);return t?t.textDocumentDefinition(e):null}async textDocumentDidOpen(e){return(await Promise.all(this.clients.map(t=>t.textDocumentDidOpen(e)))).some(e=>e!==!1)}async textDocumentDidClose(e){await Promise.all(this.clients.map(t=>t.textDocumentDidClose(e)))}async textDocumentWillSave(e){await Promise.all(this.clients.map(t=>t.textDocumentWillSave(e)))}async textDocumentWillSaveWaitUntil(e){let t=await Promise.allSettled(this.clients.map(t=>t.textDocumentWillSaveWaitUntil(e)));for(let e of t)if(e.status===`fulfilled`&&e.value?.length)return e.value;return null}async textDocumentDidSave(e){await Promise.all(this.clients.map(t=>t.textDocumentDidSave(e)))}async textDocumentHover(e){for(let t of this.clients){if(!t.hasCapability(`textDocument/hover`))continue;let n=await t.textDocumentHover(e);if(n)return n}return{contents:[]}}};function uj(e){let t=[],n=!1;for(let r of e)if(r.status===`fulfilled`){let e=r.value;if(e==null)continue;Array.isArray(e)&&t.push(...e),`items`in e&&(t.push(...e.items),n||=e.isIncomplete)}return{items:t,isIncomplete:n}}function dj(e){let t=$d.parse(e),n=``;return du(e,t,Il,(e,t)=>{let r=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);n+=t?`<span class="${t}">${r}</span>`:r},()=>{n+=`
|
|
94
|
-
`}),n}function fj(){let e=new $u.Renderer,t=e.code.bind(e);return e.code=e=>{let{text:n,lang:r}=e;return n.trim()?r===`python`||r===`py`?`<pre><code class="language-python">${dj(n)}</code></pre>\n`:t(e):``},t=>$u(t,{async:!1,gfm:!0,breaks:!0,renderer:e})}function pj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mj(e,t){return typeof e[t]==`function`}
|
|
95
|
-
`)}function
|
|
94
|
+
`}),n}function fj(){let e=new $u.Renderer,t=e.code.bind(e);return e.code=e=>{let{text:n,lang:r}=e;return n.trim()?r===`python`||r===`py`?`<pre><code class="language-python">${dj(n)}</code></pre>\n`:t(e):``},t=>$u(t,{async:!1,gfm:!0,breaks:!0,renderer:e})}function pj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mj(e,t){return typeof e[t]==`function`}var hj=o(e=>{let t=e(YU);return pc.fromEntries(t.cellIds.inOrderIds.map(e=>{let n=t.cellHandles[e]?.current?.editorViewOrNull;return[e,n?rH(n):t.cellData[e]?.code??``]}))});function gj(e){return[..._j(e),e].join(`
|
|
95
|
+
`)}function _j(e){return Object.values(u.get(hj)).filter(t=>t!==``&&t!==e).toSorted((e,t)=>e.startsWith(`import`)&&!t.startsWith(`import`)?-1:!e.startsWith(`import`)&&t.startsWith(`import`)?1:0)}var vj=o(e=>e(YU).cellIds.inOrderIds),yj=o(e=>xj(e(vj),e(XE))),bj=o(e=>({cellIds:e(yj),codes:e(hj)}));function xj(e,t){let n=new Map;e.forEach(e=>n.set(e,[]));let r=new Set(e),i=new Set(e);for(let{declaredBy:e,usedBy:a}of Object.values(t))for(let t of e){r.delete(t);for(let e of a)i.delete(e),e!==t&&n.get(t)?.push(e)}let a=new Map;e.forEach(e=>a.set(e,0)),n.forEach(e=>{e.forEach(e=>{a.set(e,(a.get(e)||0)+1)})});let o=[];a.forEach((e,t)=>{e===0&&o.push(t)});let s=[];for(;o.length>0;){let e=o.shift();if(!e)break;s.push(e),n.get(e)?.forEach(e=>{a.set(e,(a.get(e)||0)-1),a.get(e)===0&&o.push(e)})}return[...s.filter(e=>!r.has(e)),...r]}function Sj(e,t){let n=new Map,r=0;e.forEach(e=>{n.set(e,r),r+=t[e].split(`
|
|
96
96
|
`).length});function i(e){return n.has(e)||B.warn(`[lsp] no cell line offsets for`,e),n.get(e)??0}let a=e.map(e=>t[e]).join(`
|
|
97
97
|
`);return{cellIds:e,mergedText:a,transformRange:(e,t)=>Cj(e,i(t)),reverseRange:(e,t)=>Cj(e,-i(t)),isInRange:(e,r)=>{let i=t[r].split(`
|
|
98
98
|
`).length,a=n.get(r)||0,o=e.start.line-a,s=e.end.line-a,c=o>=0&&o<i,l=s>=0&&s<i;return c&&!l&&B.warn(`[lsp] Cross-cell diagnostic detected: range starts in cell but ends outside`,{cellId:r,range:e,cellLines:i,offset:a}),c&&l},getEditsForNewText:e=>{let r=e.split(`
|
|
@@ -224,4 +224,4 @@ mark line col
|
|
|
224
224
|
)
|
|
225
225
|
`]));let n=this._buffer.match(this._osc_regex);if(n===null)return e.kind=$H.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;e.kind=$H.OSCURL,e.url=n[1],e.text=n[2];var i=n[0].length;return this._buffer=this._buffer.slice(i),e}if(r==`(`)return e.kind=$H.Unknown,this._buffer=this._buffer.slice(3),e}}ansi_to_html(e){this.append_buffer(e);for(var t=[];;){var n=this.get_next_packet();if(n.kind==$H.EOS||n.kind==$H.Incomplete)break;n.kind!=$H.ESC&&n.kind!=$H.Unknown&&(n.kind==$H.Text?t.push(this.transform_to_html(this.with_state(n))):n.kind==$H.SGR?this.process_ansi(n):n.kind==$H.OSCURL&&t.push(this.process_hyperlink(n)))}return t.join(``)}with_state(e){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:e.text}}process_ansi(e){let t=e.text.split(`;`);for(;t.length>0;){let e=t.shift(),n=parseInt(e,10);if(isNaN(n)||n===0)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(n===1)this.bold=!0;else if(n===2)this.faint=!0;else if(n===3)this.italic=!0;else if(n===4)this.underline=!0;else if(n===21)this.bold=!1;else if(n===22)this.faint=!1,this.bold=!1;else if(n===23)this.italic=!1;else if(n===24)this.underline=!1;else if(n===39)this.fg=null;else if(n===49)this.bg=null;else if(n>=30&&n<38)this.fg=this.ansi_colors[0][n-30];else if(n>=40&&n<48)this.bg=this.ansi_colors[0][n-40];else if(n>=90&&n<98)this.fg=this.ansi_colors[1][n-90];else if(n>=100&&n<108)this.bg=this.ansi_colors[1][n-100];else if((n===38||n===48)&&t.length>0){let e=n===38,r=t.shift();if(r===`5`&&t.length>0){let n=parseInt(t.shift(),10);n>=0&&n<=255&&(e?this.fg=this.palette_256[n]:this.bg=this.palette_256[n])}if(r===`2`&&t.length>2){let n=parseInt(t.shift(),10),r=parseInt(t.shift(),10),i=parseInt(t.shift(),10);if(n>=0&&n<=255&&r>=0&&r<=255&&i>=0&&i<=255){let t={rgb:[n,r,i],class_name:`truecolor`};e?this.fg=t:this.bg=t}}}}}transform_to_html(e){let t=e.text;if(t.length===0||(t=this.escape_txt_for_html(t),!e.bold&&!e.italic&&!e.faint&&!e.underline&&e.fg===null&&e.bg===null))return t;let n=[],r=[],i=e.fg,a=e.bg;e.bold&&n.push(this._boldStyle),e.faint&&n.push(this._faintStyle),e.italic&&n.push(this._italicStyle),e.underline&&n.push(this._underlineStyle),this._use_classes?(i&&(i.class_name===`truecolor`?n.push(`color:rgb(${i.rgb.join(`,`)})`):r.push(`${i.class_name}-fg`)),a&&(a.class_name===`truecolor`?n.push(`background-color:rgb(${a.rgb.join(`,`)})`):r.push(`${a.class_name}-bg`))):(i&&n.push(`color:rgb(${i.rgb.join(`,`)})`),a&&n.push(`background-color:rgb(${a.rgb})`));let o=``,s=``;return r.length&&(o=` class="${r.join(` `)}"`),n.length&&(s=` style="${n.join(`;`)}"`),`<span${s}${o}>${t}</span>`}process_hyperlink(e){let t=e.url.split(`:`);return t.length<1||!this._url_allowlist[t[0]]?``:`<a href="${this.escape_txt_for_html(e.url)}">${this.escape_txt_for_html(e.text)}</a>`}};function tU(e,...t){let n=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,``);return new RegExp(n)}function nU(e,...t){let n=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,``);return new RegExp(n,`g`)}var rU,iU,aU,oU=new eU;function sU(e){try{let t=document.createElement(`div`);return t.innerHTML=e,(t.textContent||t.innerText||``).split(`
|
|
226
226
|
`).map(e=>e.trimEnd()).join(`
|
|
227
|
-
`)}catch(t){return B.error(`Error parsing HTML content:`,t),e}}function cU(e){if(!e)return``;try{return sU(oU.ansi_to_html(e))}catch(t){return B.error(`Error converting ANSI to plain text:`,t),e}}var lU=o(null),uU=h_,dU=q.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:w-fit md:max-w-[420px]`,`print:hidden`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,J.jsx)(g_,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});dU.displayName=g_.displayName;var fU={default:`bg-background border`,danger:`group destructive text-error border-destructive bg-(--red-1) shadow-md-solid shadow-error`},pU=Sc(`data-[swipe=move]:transition-none group relative pointer-events-auto flex w-full items-start justify-between gap-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-right-full`,{variants:{variant:fU},defaultVariants:{variant:`default`}});function mU(e){return typeof e==`string`&&e in fU}var hU=q.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=mU(a)?a:`default`,s;n[4]!==r||n[5]!==o?(s=V(pU({variant:o}),`print:hidden`,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==t||n[9]!==s?(c=(0,J.jsx)(__,{ref:t,className:s,...i}),n[7]=i,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});hU.displayName=__.displayName;var gU=q.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-destructive/30 hover:group-[.destructive]:border-destructive/30 hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,J.jsx)(b_,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});gU.displayName=b_.displayName;var _U=q.forwardRef((e,t)=>{let n=(0,X.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-hidden focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-500 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,J.jsx)(Td,{className:`h-4 w-4`}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,J.jsx)(x_,{ref:t,className:a,"toast-close":``,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});_U.displayName=x_.displayName;var vU=q.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`text-sm font-semibold`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,J.jsx)(v_,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});vU.displayName=v_.displayName;var yU=q.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,onPointerDown:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===r?o=n[5]:(o=V(`max-h-48 overflow-auto text-sm opacity-90 whitespace-pre-wrap wrap-break-word select-text cursor-text`,r),n[4]=r,n[5]=o);let s;n[6]===i?s=n[7]:(s=e=>{e.stopPropagation(),i?.(e)},n[6]=i,n[7]=s);let c;return n[8]!==a||n[9]!==t||n[10]!==o||n[11]!==s?(c=(0,J.jsx)(y_,{ref:t,className:o,onPointerDown:s,...a}),n[8]=a,n[9]=t,n[10]=o,n[11]=s,n[12]=c):c=n[12],c});yU.displayName=y_.displayName;function bU(e){return e.type===`cell`?e.cellId:`lsp:${e.name}`}var xU=!1;function SU(e){let t=[],n=[e.console].filter(Boolean).flat();for(let r of n){let n=r.mimetype===`text/plain`,i=r.mimetype===`text/html`||r.mimetype===`application/vnd.marimo+traceback`;if(n||i){let n=r.channel===`stderr`||r.channel===`marimo-error`;switch(r.channel){case`stdout`:case`stderr`:case`marimo-error`:{let a=rd.asString(r.data),o=i?sU(a):a;t.push({timestamp:r.timestamp||Date.now(),level:n?`stderr`:`stdout`,message:o,source:{type:`cell`,cellId:e.cell_id}});break}}}}if(t.forEach(CU.log),n.length===0&&QS(e.output?.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(t=>{CU.log({level:`stderr`,source:{type:`cell`,cellId:e.cell_id},timestamp:e.timestamp??0,message:JSON.stringify(t)})});let t=e.output.data.filter(e=>`type`in e&&e.type===`exception`||e.type===`internal`),n=u.get(gc)===`read`;if(t.length>0&&!xU&&n){xU=!0;let e=t.find(e=>e.traceback);of(e?{title:`An internal error occurred`,description:e.msg||`Click 'View' to see traceback`,variant:`danger`,action:q.createElement(gU,{altText:`View traceback`,onClick:()=>{u.set(lU,{traceback:e.traceback,errorMessage:e.msg||`An internal error occurred`})}},`View`)}:{title:`An internal error occurred`,description:`See console for details.`,variant:`danger`})}}return t}var CU={log:e=>{let t=e.level===`stdout`?`gray`:e.level===`stderr`?`red`:`orange`,n=e.level.toUpperCase();console.log(`%c[${n}]`,`color:${t}; padding:2px 0; border-radius:2px; font-weight:bold`,`[${wU(e.timestamp)}]`,`(${bU(e.source)}) ${e.message}`)}};function wU(e){try{return ZH(e).toLocaleTimeString(void 0,{hour12:!0,hour:`numeric`,minute:`numeric`,second:`numeric`})}catch{return``}}function TU(e,t){let n=RW(t);n?n.focus():B.warn(`[CellFocusManager] focusCellEditor: element not found: ${t}`)}function EU(e){let t=document.getElementById(Xm.create(e));t?kU(t):B.warn(`[CellFocusManager] focusCell: element not found: ${e}`)}function DU(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}function OU(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains(`marimo-cell`)}function kU(e){try{e.focus()}catch{B.warn(`[CellFocusManager] element may not be focusable`,e)}}function AU(e,t){let{retries:n,delay:r,initialDelay:i=0}=t,a=0,o=()=>{if(a<n){try{if(e())return}catch(e){B.error(`Error executing function on attempt ${a+1}, retrying`,{error:e})}a++,setTimeout(o,r)}};i>0?setTimeout(o,i):o()}function jU(){let e=globalThis.scheduler;if(typeof e?.postTask==`function`)return t=>{e.postTask(t,{priority:`user-visible`}).catch(e=>{setTimeout(()=>{throw e})})};if(typeof MessageChannel==`function`){let e=[],t=new MessageChannel;return t.port1.onmessage=()=>{e.shift()?.()},n=>{e.push(n),t.port2.postMessage(null)}}return e=>{setTimeout(e,0)}}var MU=jU();function NU(e=MU){let t=new Map,n=new Set,r=!1;function i(){r||t.size===0||(r=!0,e(o))}function a(){for(let e of n){if(t.has(e))return e;n.delete(e)}return t.keys().next().value}function o(){r=!1;try{let e=a();if(e!==void 0){let r=t.get(e);t.delete(e),n.delete(e),r?.()}}finally{i()}}return{request(e,n){t.set(e,n),i()},promote(e){let r=t.get(e);r&&(t.delete(e),n.delete(e),r())},prioritize(e){t.has(e)&&n.add(e)},deprioritize(e){n.delete(e)},cancel(e){t.delete(e),n.delete(e)}}}var PU=NU();function FU({cellId:e,cell:t,isCodeHidden:n,codeFocus:r,variableName:i}){if(!t)return;let a=document.getElementById(Xm.create(e));if(!a){B.warn(`scrollCellIntoView: element not found`);return}if(OU()){kU(a);return}if(n)kU(a);else{PU.promote(e);let n=t.current?.editorView;if(!n){B.warn(`scrollCellIntoView: editor not found`,e);return}if(n.hasFocus||!document.hasFocus())return;if(AU(()=>(n.focus(),n.hasFocus),{retries:5,delay:20}),r===`top`)n.dispatch({selection:{anchor:0,head:0}});else if(r===`bottom`){let e=n.state.doc.line(n.state.doc.lines);n.dispatch({selection:{anchor:e.from,head:e.from}})}else i&&ok(n,i)}a.scrollIntoView({behavior:`smooth`,block:`nearest`})}function IU(e){let t=document.getElementById(Xm.create(e));if(!t){B.warn(`scrollCellIntoView: element not found`);return}t.classList.add(`focus-outline`),setTimeout(()=>{t.classList.remove(`focus-outline`)},2e3),t.scrollIntoView({behavior:`smooth`,block:`center`})}function LU(){let e=document.getElementById(`App`);e?.scrollTo({top:e.scrollHeight,behavior:`smooth`})}function RU(){document.getElementById(`App`)?.scrollTo({top:0,behavior:`smooth`})}function zU(e){let t=RW(e);if(t?.hasFocus){KE(t,{behavior:`instant`});return}let n=document.getElementById(Xm.create(e));n?n.scrollIntoView({behavior:`instant`,block:`nearest`}):B.warn(`[CellFocusManager] scrollCellIntoView: element not found: ${e}`)}function BU({id:e,name:t=`_`,code:n=``,lastCodeRun:r=null,lastExecutionTime:i=null,edited:a=!1,config:o,serializedEditorState:s=null}){return{id:e,config:o||{hide_code:!1,disabled:!1,column:null},name:t,code:n,edited:a,lastCodeRun:r,lastExecutionTime:i,serializedEditorState:s}}function VU(e){return{hide_code:!1,disabled:!1,column:null,...e}}function HU(e){return{outline:null,output:null,consoleOutputs:[],status:`idle`,staleInputs:!1,interrupted:!1,errored:!1,stopped:!1,runElapsedTimeMs:null,runStartTimestamp:null,lastRunStartTimestamp:null,debuggerActive:!1,...e}}function UU(e){let t={column:0,hide_code:!1,disabled:!1};return{...e,cellData:{[qm]:BU({id:qm,config:t}),...e.cellData},cellRuntime:{[qm]:HU(),...e.cellRuntime},cellHandles:{[qm]:(0,q.createRef)(),...e.cellHandles}}}function WU(){return UU({cellIds:dv.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}var{reducer:GU,addMiddleware:KU,createActions:qU,useActions:JU,valueAtom:YU}=Ku(WU,{createNewCell:(e,t)=>{let{cellId:n,before:r,code:i,name:a,config:o,lastCodeRun:s=null,lastExecutionTime:c=null,autoFocus:l=!0,skipIfCodeExists:u=!1,hideCode:d=void 0}=t,f,p;if(u){for(let t of e.cellIds.inOrderIds)if(e.cellData[t]?.code===i)return e}if(n===`__end__`){let t=e.cellIds.atOrThrow(0);f=t.id,p=t.length}else if(typeof n==`string`){let t=e.cellIds.findWithId(n);f=t.id,p=t.topLevelIds.indexOf(n)}else if(n.type===`__end__`){let t=e.cellIds.get(n.columnId)||e.cellIds.atOrThrow(0);f=t.id,p=t.length}else throw Error(`Invalid cellId`);let m=t.newCellId||Ym.create(),h=r?p:p+1;return{...e,cellIds:e.cellIds.insertId(m,f,h),cellData:{...e.cellData,[m]:BU({id:m,code:i,name:a,lastCodeRun:s,config:VU({...o,...d!=null&&{hide_code:d}}),lastExecutionTime:c,edited:!!i&&i!==s})},cellRuntime:{...e.cellRuntime,[m]:HU()},cellHandles:{...e.cellHandles,[m]:(0,q.createRef)()},scrollKey:l?m:null,untouchedNewCells:d&&l?new Set([...e.untouchedNewCells,m]):e.untouchedNewCells}},moveCell:(e,t)=>{let{cellId:n,before:r,direction:i}=t;if(r!==void 0&&i!==void 0&&B.warn(`Both before and direction specified for moveCell. Ignoring one.`),i){let t=e.cellIds.findWithId(n),r=e.cellIds.indexOf(t),a=i===`left`?r-1:r+1,o=e.cellIds.at(a);return o?{...e,cellIds:e.cellIds.moveAcrossColumns(t.id,n,o.id,void 0),scrollKey:n}:e}let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n);return r&&o===0?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,0),scrollKey:n}:!r&&o===a.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,a.length-1),scrollKey:n}:r?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,o-1),scrollKey:n}:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,o+1),scrollKey:n}},moveCellToIndex:(e,t)=>{let{cellId:n,columnId:r,index:i}=t,a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=e.cellIds.get(r);if(!s)return e;let c=Math.max(0,Math.min(i,s.length)),l=a.id===r&&o<c?c-1:c;if(a.id===r&&o===l)return e;let u=e.cellIds.deleteById(n),d=u.get(r);return d?{...e,cellIds:u.insertId(n,r,Math.max(0,Math.min(l,d.length))),scrollKey:null}:e},dropCellOverCell:(e,t)=>{let{cellId:n,overCellId:r}=t,i=e.cellIds.findWithId(n),a=e.cellIds.findWithId(r),o=i.indexOfOrThrow(n),s=a.indexOfOrThrow(r);return i.id===a.id?o===s?e:{...e,cellIds:e.cellIds.moveWithinColumn(i.id,o,s),scrollKey:null}:{...e,cellIds:e.cellIds.moveAcrossColumns(i.id,n,a.id,r),scrollKey:null}},moveCellsRelativeTo:(e,t)=>{let{cellIds:n,targetCellId:r,position:i,previousPlacements:a}=t;if(n.length===0)return e;let o=e.cellIds.moveCellsRelativeTo(n,r,i),s=a&&a.length===n.length?[...e.history,{type:`move`,cellIds:n,placements:a}]:e.history;return{...e,cellIds:o,history:s,scrollKey:null}},dropCellOverColumn:(e,t)=>{let{cellId:n,columnId:r}=t,i=e.cellIds.findWithId(n);return{...e,cellIds:e.cellIds.moveAcrossColumns(i.id,n,r,void 0)}},dropOverNewColumn:(e,t)=>{let{cellId:n}=t;return{...e,cellIds:e.cellIds.moveToNewColumn(n)}},moveColumn:(e,t)=>t.column===t.overColumn?e:{...e,cellIds:e.cellIds.moveColumn(t.column,t.overColumn)},focusCell:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,where:i}=t,a=n.indexOfOrThrow(r),o;o=i===`before`?Vu(a-1,0,n.length-1):i===`after`?Vu(a+1,0,n.length-1):a;let s=n.atOrThrow(o);return FU({cellId:s,cell:e.cellHandles[s],isCodeHidden:XU(e,s),codeFocus:i===`after`?`top`:`bottom`,variableName:void 0}),e},focusTopCell:e=>{let t=e.cellIds.getColumns().at(0);if(t===void 0||t.length===0)return e;let n=t.first();return FU({cellId:n,cell:e.cellHandles[n],isCodeHidden:XU(e,n),codeFocus:void 0,variableName:void 0}),RU(),e},focusBottomCell:e=>{let t=e.cellIds.getColumns().at(-1);if(t===void 0||t.length===0)return e;let n=t.last();return FU({cellId:n,cell:e.cellHandles[n],isCodeHidden:XU(e,n),codeFocus:void 0,variableName:void 0}),LU(),e},sendToTop:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,scroll:i=!0}=t,a=n.indexOfOrThrow(r);return a===0?e:{...e,cellIds:e.cellIds.moveWithinColumn(n.id,a,0),scrollKey:i?r:null}},sendToBottom:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,scroll:i=!0}=t,a=n.indexOfOrThrow(r),o=n.length-1;return a===o?e:{...e,cellIds:e.cellIds.moveWithinColumn(n.id,a,o),scrollKey:i?r:null}},addColumn:(e,t)=>{let n=Ym.create();return{...e,cellIds:e.cellIds.addColumn(t.columnId,[n]),cellData:{...e.cellData,[n]:BU({id:n})},cellRuntime:{...e.cellRuntime,[n]:HU()},cellHandles:{...e.cellHandles,[n]:(0,q.createRef)()},scrollKey:n}},addColumnBreakpoint:(e,t)=>{let{cellId:n}=t;return e.cellIds.getColumns()[0].inOrderIds[0]===n?e:{...e,cellIds:e.cellIds.insertBreakpoint(n)}},deleteColumn:(e,t)=>{let{columnId:n}=t;return{...e,cellIds:e.cellIds.delete(n)}},mergeAllColumns:e=>({...e,cellIds:e.cellIds.mergeAllColumns()}),compactColumns:e=>({...e,cellIds:e.cellIds.compact()}),deleteCell:(e,t)=>{let n=t.cellId;if(e.cellIds.hasOnlyOneId())return e;let r;try{r=e.cellIds.findWithId(n)}catch(t){return B.warn(`Skipping delete for missing cellId`,{cellId:n,error:t}),e}let i=r.indexOfOrThrow(n),a=i===0?1:i-1,o=null;r.length>1&&(o=r.atOrThrow(a));let s=(e.cellHandles[n].current?.editorView)?.state.toJSON({history:yu});s&&(s.doc=e.cellData[n].code),NW(n);let c=e.cellData[n];return{...e,cellIds:e.cellIds.deleteById(n),history:[...e.history,{type:`delete`,name:c.name,serializedEditorState:s,column:r.id,index:i,isSetupCell:n===Jm,config:c.config}],scrollKey:o}},undoDeleteCell:e=>{if(e.history.length===0)return e;let t=e.history[e.history.length-1];if(t.type===`move`){let{cellIds:n,placements:r}=t;if(n.length===0||r.length!==n.length||n.some(t=>!e.cellData[t]))return{...e,history:e.history.slice(0,-1)};let i=n.map((e,t)=>({id:e,columnId:r[t].columnId,index:r[t].index}));return{...e,cellIds:e.cellIds.placeCells(i),history:e.history.slice(0,-1),scrollKey:n[0]??null}}let{name:n,serializedEditorState:r={doc:``},column:i,index:a,isSetupCell:o,config:s}=t,c=o?Jm:Ym.create(),l=BU({id:c,name:n,code:r.doc,edited:r.doc.trim().length>0,serializedEditorState:r,config:s});return{...e,cellIds:e.cellIds.insertId(c,i,a),cellData:{...e.cellData,[c]:l},cellRuntime:{...e.cellRuntime,[c]:HU()},cellHandles:{...e.cellHandles,[c]:(0,q.createRef)()},history:e.history.slice(0,-1),scrollKey:c}},clearSerializedEditorState:(e,t)=>{let{cellId:n}=t;return QU({state:e,cellId:n,cellReducer:e=>({...e,serializedEditorState:null})})},updateCellCode:(e,t)=>{let{cellId:n,code:r,formattingChange:i}=t;return e.cellData[n]?QU({state:e,cellId:n,cellReducer:e=>i?{...e,code:r,lastCodeRun:e.edited?e.lastCodeRun:r}:{...e,code:r,edited:r.trim()!==e.lastCodeRun}}):e},updateCellName:(e,t)=>{let{cellId:n,name:r}=t;return QU({state:e,cellId:n,cellReducer:e=>({...e,name:r})})},updateCellConfig:(e,t)=>{let{cellId:n,config:r}=t;return QU({state:e,cellId:n,cellReducer:e=>({...e,config:VU({...e.config,...r})})})},prepareForRun:(e,t)=>QU({state:ZU({state:e,cellId:t.cellId,cellReducer:e=>AH(e)}),cellId:t.cellId,cellReducer:e=>({...e,edited:!1,lastCodeRun:e.code.trim()})}),handleCellMessage:(e,t)=>{let n=t.cell_id,r=ZU({state:e,cellId:n,cellReducer:e=>kH(e,t)});return t.status===`queued`&&(r=QU({state:r,cellId:n,cellReducer:e=>({...e,lastCodeRun:e.code.trim(),edited:!1})})),{...r,cellLogs:[...r.cellLogs,...SU(t)]}},addLogs:(e,t)=>({...e,cellLogs:[...e.cellLogs,...t.logs]}),setCellIds:(e,t)=>{if(l(e.cellIds.inOrderIds,t.cellIds))return e;let n={...e.cellData},r={...e.cellRuntime},i={...e.cellHandles};for(let a of t.cellIds)a in e.cellData||(n[a]=BU({id:a})),a in e.cellRuntime||(r[a]=HU()),a in e.cellHandles||(i[a]=(0,q.createRef)());return{...e,cellIds:dv.fromWithPreviousShape(t.cellIds,e.cellIds),cellData:n,cellRuntime:r,cellHandles:i}},rebuildCellColumns:(e,t)=>{let n=dv.fromIdsAndColumns(t.cellIds.map(t=>[t,e.cellData[t]?.config.column??null]));return{...e,cellIds:n}},setCellCodes:(e,t)=>{mc(t.codes.length===t.ids.length,`Expected codes and ids to have the same length`);let n={...e},r=({cell:e,code:r,cellId:i,name:a,config:o})=>{if(!e)return BU({id:i,code:r,name:a,config:o,lastCodeRun:t.codeIsStale?null:r,edited:t.codeIsStale&&r.trim().length>0});let s=t.codeIsStale?e.lastCodeRun:r,c=s?s.trim()!==r.trim():!!r;if(e.code.trim()===r.trim())return{...e,code:r,edited:c,lastCodeRun:s,...a!==void 0&&{name:a},...o!==void 0&&{config:o}};if(!_H()||!vH(i)){let e=n.cellHandles[i].current;e?.editorViewOrNull&&iH(e.editorViewOrNull,r)}return{...e,code:r,edited:c,lastCodeRun:s,...a!==void 0&&{name:a},...o!==void 0&&{config:o}}};for(let e=0;e<t.ids.length;e++){let i=t.ids[e],a=t.codes[e];if(i===void 0||a===void 0)continue;let o=t.names?.[e],s=t.configs?.[e];n={...n,cellData:{...n.cellData,[i]:r({cell:n.cellData[i],code:a,cellId:i,name:o,config:s})}}}return n},setStdinResponse:(e,t)=>{let{cellId:n,response:r,outputIndex:i}=t;return ZU({state:e,cellId:n,cellReducer:e=>{let t=[...e.consoleOutputs],n=t[i];return n==null||n.channel!==`stdin`?(B.warn(`Expected stdin output`),e):(t[i]={channel:`stdin`,mimetype:n.mimetype,data:n.data,timestamp:n.timestamp,response:r},{...e,interrupted:!1,consoleOutputs:t})}})},setCells:(e,t)=>{let n=Object.fromEntries(t.map(e=>[e.id,e])),r=_c(),i=t=>{if(!r)return HU();let n=e.cellRuntime[t];return n&&(n.output!=null||n.consoleOutputs.length>0)?n:HU()},a=Object.fromEntries(t.map(e=>[e.id,i(e.id)]));return UU({...e,cellIds:dv.fromIdsAndColumns(t.map(e=>[e.id,e.config.column])),cellData:n,cellRuntime:a,cellHandles:Object.fromEntries(t.map(e=>[e.id,(0,q.createRef)()]))})},moveToNextCell:(e,t)=>{let{cellId:n,before:r,noCreate:i=!1}=t;if(n===`__scratch__`)return e;let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=r?o-1:o+1,c=s===a.length,l=s===-1;if(c&&!i){let t=Ym.create();return{...e,cellIds:e.cellIds.insertId(t,a.id,s),cellData:{...e.cellData,[t]:BU({id:t})},cellRuntime:{...e.cellRuntime,[t]:HU()},cellHandles:{...e.cellHandles,[t]:(0,q.createRef)()},scrollKey:t}}if(l&&!i){let t=Ym.create();return{...e,cellIds:e.cellIds.insertId(t,a.id,0),cellData:{...e.cellData,[t]:BU({id:t})},cellRuntime:{...e.cellRuntime,[t]:HU()},cellHandles:{...e.cellHandles,[t]:(0,q.createRef)()},scrollKey:t}}if((c||l)&&i)return e;if(s>=0&&s<a.length){let t=a.atOrThrow(s);FU({cellId:t,cell:e.cellHandles[t],isCodeHidden:XU(e,t),codeFocus:r?`bottom`:`top`,variableName:void 0})}return e},markTouched:(e,t)=>{let{cellId:n}=t;if(e.untouchedNewCells.has(n)){let t=new Set(e.untouchedNewCells);return t.delete(n),{...e,untouchedNewCells:t}}return e},markUntouched:(e,t)=>{let{cellId:n}=t;if(!e.untouchedNewCells.has(n)){let t=new Set(e.untouchedNewCells);return t.add(n),{...e,untouchedNewCells:t}}return e},scrollToTarget:e=>{let t=e.scrollKey;if(t===null)return e;let n=e.cellIds.findWithId(t),r=n.indexOfOrThrow(t),i=r===n.length-1?n.last():n.atOrThrow(r);return FU({cellId:i,cell:e.cellHandles[i],isCodeHidden:XU(e,i),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(jv(Object.values(e.cellHandles).map(e=>e.current?.editorView)),e),unfoldAll:e=>(Mv(Object.values(e.cellHandles).map(e=>e.current?.editorView)),e),clearLogs:e=>({...e,cellLogs:[]}),collapseCell:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r.topLevelIds.map(t=>e.cellRuntime[t].outline),a=hH(r.indexOfOrThrow(n),i);if(!a)return e;let o=r.atOrThrow(a[1]);return{...e,cellIds:e.cellIds.transformWithCellId(n,e=>e.collapse(n,o)),scrollKey:n}},expandCell:(e,t)=>{let{cellId:n}=t;return{...e,cellIds:e.cellIds.transformWithCellId(n,e=>e.expand(n)),scrollKey:n}},collapseAllCells:e=>({...e,cellIds:e.cellIds.transformAll(t=>{let n=t.topLevelIds.map(t=>e.cellRuntime[t].outline),r=[...t.nodes],i=[],a=[],o=r.length-1;for(;o>=0;){let e=hH(o,n);if(e){let n=o,r=e[1],s=i.find(e=>e.start<=r&&e.end===r);s&&(r=s.start),i.push({start:n,end:r});let c=t.atOrThrow(n),l=t.atOrThrow(r);a.push({id:c,until:l})}else a.push(null);o--}let s=a.toReversed();return t.collapseAll(s)})}),expandAllCells:e=>({...e,cellIds:e.cellIds.transformAll(e=>e.expandAll())}),showCellIfHidden:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r,a=r.findAndExpandDeep(n);return a.equals(i)?e:{...e,cellIds:e.cellIds.transformWithCellId(n,()=>a)}},splitCell:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r.indexOfOrThrow(n),a=e.cellData[n],o=e.cellHandles[n].current;if(o?.editorView==null)return e;let{beforeCursorCode:s,afterCursorCode:c}=aH(o.editorView);iH(o.editorView,s);let l=Ym.create();return{...e,cellIds:e.cellIds.insertId(l,r.id,i+1),cellData:{...e.cellData,[n]:{...a,code:s,edited:!!s&&s.trim()!==a.lastCodeRun?.trim()},[l]:BU({id:l,code:c,edited:!!c})},cellRuntime:{...e.cellRuntime,[n]:{...e.cellRuntime[n],output:null,consoleOutputs:[]},[l]:HU()},cellHandles:{...e.cellHandles,[l]:(0,q.createRef)()},scrollKey:l}},undoSplitCell:(e,t)=>{let{cellId:n,snapshot:r}=t,i=e.cellData[n],a=e.cellHandles[n].current;return a?.editorView==null?e:(iH(a.editorView,r),{...e,cellIds:e.cellIds.transformWithCellId(n,e=>{let t=e.indexOfOrThrow(n)+1;return e.deleteAtIndex(t)}),cellData:{...e.cellData,[n]:{...i,code:r,edited:!!r&&r?.trim()!==i.lastCodeRun?.trim()}},cellRuntime:{...e.cellRuntime,[n]:{...e.cellRuntime[n],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,t)=>{let{cellId:n}=t;return ZU({state:e,cellId:n,cellReducer:e=>({...e,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,t)=>{let{cellId:n}=t;return ZU({state:e,cellId:n,cellReducer:e=>({...e,consoleOutputs:e.consoleOutputs.filter(e=>e.channel===`stdin`&&e.response==null)})})},clearAllCellOutputs:e=>{let t={...e.cellRuntime};for(let n of e.cellIds.inOrderIds)t[n]={...t[n],output:null,consoleOutputs:[]};return{...e,cellRuntime:t}},addSetupCellIfDoesntExist:(e,t)=>{let{code:n}=t;return e.cellIds.setupCellExists()?{...e,scrollKey:Jm}:{...e,cellIds:e.cellIds.insertId(Jm,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Jm]:BU({id:Jm,name:Jm,code:n,edited:!!n})},cellRuntime:{...e.cellRuntime,[Jm]:HU()},cellHandles:{...e.cellHandles,[Jm]:(0,q.createRef)()},scrollKey:Jm}}});KU(YH);function XU(e,t){return!!e.cellData[t].config.hide_code&&!e.untouchedNewCells.has(t)}function ZU({state:e,cellId:t,cellReducer:n}){return t in e.cellRuntime?{...e,cellRuntime:{...e.cellRuntime,[t]:n(e.cellRuntime[t])}}:(B.warn(`Cell ${t} not found in state`),e)}function QU({state:e,cellId:t,cellReducer:n}){return t in e.cellData?{...e,cellData:{...e.cellData,[t]:n(e.cellData[t])}}:(B.warn(`Cell ${t} not found in state`),e)}function $U(e){let t=e.cellData,n={column:null};return e.cellIds.getColumns().length>1?e.cellIds.getColumns().flatMap((e,r)=>e.inOrderIds.map((e,i)=>{let a={...n};return i===0&&(a.column=r),{...t[e].config,...a}})):e.cellIds.getColumns().flatMap(e=>e.inOrderIds.map(e=>({...t[e].config,...n})))}var eW=qU(e=>{u.set(YU,t=>GU(t,e))}).addLogs,tW=o(e=>e(YU).cellIds),nW=o(e=>e(tW).hasOnlyOneId()),rW=o(e=>iC(e(YU)).length>0);o(e=>aC(e(YU)).length>0);var iW=o(e=>oC(e(YU))),aW=o(e=>sC(e(YU))),oW=o(e=>tC(e(YU))),sW=o(e=>{let{cellIds:t,cellRuntime:n,cellData:r}=e(YU);return t.inOrderIds.map(e=>{let t=n[e],{name:i}=r[e];if(QS(t.output?.mimetype)){mc(Array.isArray(t.output.data),`Expected array data`);let n=t.output.data.filter(e=>!e.type.includes(`ancestor`));if(n.length>0)return{output:{...t.output,data:n},cellId:e,cellName:i}}return null}).filter(Boolean)}),cW=o(e=>{let{cellIds:t,cellRuntime:n}=e(YU);return fH(t.inOrderIds.map(e=>n[e].outline))}),lW=o(e=>e(sW).length),uW=c(o(e=>{let{cellIds:t,cellData:n}=e(YU);return pc.fromEntries(t.inOrderIds.map(e=>[e,n[e]?.name]))})),dW=o(e=>e(YU).scrollKey),fW=()=>s(YU),pW=()=>s(tW),mW=()=>s(uW),hW=()=>s(sW),gW=()=>s(YU).cellLogs,_W=()=>s(dW),vW=()=>u.get(YU),yW=()=>u.get(YU).cellIds,bW=()=>{let{cellIds:e,cellData:t}=u.get(YU);return e.inOrderIds.map(e=>t[e]?.name).filter(Boolean)},xW=R_(j_(YU,e=>e.cellIds.inOrderIds.map(t=>e.cellData[t]))),SW=()=>a(xW),CW=o(e=>e(YU).cellRuntime),wW=o(e=>$S(e(YU))),TW=o(e=>{let{cellRuntime:t}=e(YU);return Object.entries(t).every(([e,t])=>t.status!==`running`||e===`__scratch__`)}),EW=o(e=>eC(e(YU))),DW=o(e=>e(YU).cellIds.colLength),OW=o(e=>e(YU).cellIds.idLength>0),kW=o(e=>e(YU).cellIds.getColumnIds()),AW=D_(e=>o(t=>t(YU).cellData[e])),jW=D_(e=>o(t=>t(YU).cellRuntime[e])),MW=D_(e=>o(t=>t(YU).cellHandles[e]));function NW(e){AW.remove(e),jW.remove(e),MW.remove(e)}var PW=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=AW(e),t[0]=e,t[1]=n),s(n)},FW=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=jW(e),t[0]=e,t[1]=n),s(n)},IW=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=MW(e),t[0]=e,t[1]=n),s(n)},LW=()=>{let{cellIds:e,cellHandles:t}=u.get(YU);return e.inOrderIds.map(e=>t[e]?.current?.editorViewOrNull).filter(Boolean)},RW=e=>{let{cellHandles:t}=u.get(YU);return t[e].current?.editorView};function zW(e){let{cellIds:t,cellData:n,cellRuntime:r}=e;return t.getColumns().flatMap(e=>e.topLevelIds.map(e=>({...n[e],...r[e]})))}function BW(e){return o(t=>t(YU).untouchedNewCells.has(e))}function VW(e){let t=jW(e);return o(n=>{let r=n(t);if(!r||r.status===`queued`||r.status===`running`)return;let i=[],a=r.consoleOutputs;if(a&&a.length>0){let e=a.find(e=>e.mimetype===`application/vnd.marimo+traceback`);if(e){let t=e.data;i.push(...kv(t))}}let o=r.output;if(o?.mimetype===`application/vnd.marimo+error`){let t=o.data;if(Array.isArray(t))for(let n of t)n.type===`syntax`&&n.lineno!=null&&i.push({kind:`cell`,cellId:e,lineNumber:n.lineno}),n.type===`import-star`&&n.lineno!=null&&i.push({kind:`cell`,cellId:e,lineNumber:n.lineno})}return i.length>0?i:void 0})}function HW(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n),JU(n)}export{vU as $,kS as $a,bw as $i,yM as $n,rD as $r,Gz as $t,IW as A,DC as Aa,Yw as Ai,uR as An,$m as Ao,GO as Ar,fV as At,zU as B,nC as Ba,Iw as Bi,QF as Bn,Im as Bo,kD as Br,FB as Bt,DW as C,RC as Ca,$w as Ci,Oz as Cn,Qh as Co,ok as Cr,DV as Ct,PW as D,LC as Da,vT as Di,rz as Dn,rh as Do,KO as Dr,wV as Dt,HW as E,PC as Ea,_T as Ei,xz as En,nh as Eo,VO as Er,SV as Et,fW as F,iC as Fa,Hw as Fi,_I as Fn,Zm as Fo,UD as Fr,QB as Ft,OU as G,XS as Ga,Aw as Gi,KF as Gn,mm as Go,xD as Gr,gB as Gt,AU as H,mC as Ha,Nw as Hi,$F as Hn,km as Ho,SD as Hr,IB as Ht,_W as I,aC as Ia,Vw as Ii,rI as In,Um as Io,zD as Ir,nV as It,bU as J,JS as Ja,Dw as Ji,nF as Jn,vD as Jr,fB as Jt,DU as K,ZS as Ka,kw as Ki,TF as Kn,mf as Ko,yD as Kr,_B as Kt,BU as L,cC as La,Bw as Li,aI as Ln,Wm as Lo,MD as Lr,NB as Lt,gW as M,gC as Ma,qw as Mi,tR as Mn,qm as Mo,AO as Mr,uV as Mt,mW as N,dC as Na,Kw as Ni,zI as Nn,Jm as No,BO as Nr,rV as Nt,SW as O,OC as Oa,uT as Oi,dR as On,eh as Oo,qO as Or,TV as Ot,FW as P,fC as Pa,Uw as Pi,XI as Pn,Qm as Po,zO as Pr,$B as Pt,uU as Q,OS as Qa,xw as Qi,oF as Qn,nD as Qr,oB as Qt,HU as R,uC as Ra,zw as Ri,iI as Rn,Rm as Ro,LD as Rr,RB as Rt,EW as S,jC as Sa,AT as Si,Tz as Sn,Jh as So,mk as Sr,tH as St,aW as T,NC as Ta,aT as Ti,bz as Tn,th as To,HO as Tr,bV as Tt,EU as U,lC as Ua,Mw as Ui,XF as Un,Em as Uo,Q as Ur,kB as Ut,PU as V,pC as Va,Pw as Vi,ZF as Vn,jm as Vo,wD as Vr,PB as Vt,TU as W,QS as Wa,jw as Wi,JF as Wn,Tm as Wo,CD as Wr,OB as Wt,_U as X,VS as Xa,Cw as Xi,rF as Xn,_D as Xr,lB as Xt,hU as Y,HS as Ya,Tw as Yi,iF as Yn,sD as Yr,pB as Yt,yU as Z,IS as Za,Sw as Zi,aF as Zn,gD as Zr,aB as Zt,nW as _,KC as _a,jE as _i,Cz as _n,J_ as _o,Ok as _r,QV as _t,CW as a,fw as aa,XE as ai,Qz as an,Tv as ao,QA as ar,XH as at,wW as b,MC as ba,JT as bi,wz as bn,H_ as bo,gk as br,nH as bt,zW as c,lw as ca,UE as ci,Bz as cn,sv as co,PA as cr,vH as ct,RW as d,rw as da,NE as di,zz as dn,$_ as do,lA as dr,mH as dt,vw as ea,iD as ei,$z as en,gS as eo,iM as er,dU as et,bW as f,tw as fa,ME as fi,jz as fn,ev as fo,cA as fr,dH as ft,rW as g,GC as ga,kE as gi,Sz as gn,K_ as go,Dk as gr,iH as gt,OW as h,qC as ha,AE as hi,Mz as hn,q_ as ho,Bk as hr,rH as ht,tW as i,pw as ia,$E as ii,Zz as in,Ov as io,$A as ir,eU as it,pW as j,hC as ja,Gw as ji,ML as jn,Xm as jo,JO as jr,dV as jt,hW as k,EC as ka,Jw as ki,fR as kn,Ym as ko,UO as kr,pV as kt,LW as l,ow as la,LE as li,Vz as ln,av as lo,OA as lr,_H as lt,vW as m,nw as ma,DE as mi,Iz as mn,Y_ as mo,zk as mr,oH as mt,AW as n,gw as na,tD as ni,Kz as nn,Dv as no,mj as nr,cU as nt,kW as o,dw as oa,GE as oi,tB as on,wv as oo,XA as or,jH as ot,yW as p,sw as pa,OE as pi,Pz as pn,Q_ as po,rA as pr,pH as pt,wU as q,YS as qa,Ow as qi,cF as qn,mD as qr,dB as qt,lW as r,hw as ra,QE as ri,Jz as rn,kv as ro,pj as rr,sU as rt,BW as s,uw as sa,VE as si,nB as sn,dv as so,ZA as sr,MH as st,iW as t,_w as ta,eD as ti,eB as tn,ex as to,hj as tr,lU as tt,$U as u,iw as ua,FE as ui,Rz as un,tv as uo,kA as ur,gH as ut,oW as v,WC as va,bE as vi,Ez as vn,U_ as vo,bk as vr,$V as vt,TW as w,kC as wa,oT as wi,Az as wn,ih as wo,WO as wr,xV as wt,cW as x,AC as xa,jT as xi,kz as xn,j_ as xo,fk as xr,JV as xt,YU as y,JC as ya,_E as yi,Dz as yn,E_ as yo,kk as yr,YV as yt,IU as z,rC as za,Rw as zi,oI as zn,zm as zo,FD as zr,LB as zt};
|
|
227
|
+
`)}catch(t){return B.error(`Error parsing HTML content:`,t),e}}function cU(e){if(!e)return``;try{return sU(oU.ansi_to_html(e))}catch(t){return B.error(`Error converting ANSI to plain text:`,t),e}}var lU=o(null),uU=h_,dU=q.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:w-fit md:max-w-[420px]`,`print:hidden`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,J.jsx)(g_,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});dU.displayName=g_.displayName;var fU={default:`bg-background border`,danger:`group destructive text-error border-destructive bg-(--red-1) shadow-md-solid shadow-error`},pU=Sc(`data-[swipe=move]:transition-none group relative pointer-events-auto flex w-full items-start justify-between gap-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-right-full`,{variants:{variant:fU},defaultVariants:{variant:`default`}});function mU(e){return typeof e==`string`&&e in fU}var hU=q.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=mU(a)?a:`default`,s;n[4]!==r||n[5]!==o?(s=V(pU({variant:o}),`print:hidden`,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==i||n[8]!==t||n[9]!==s?(c=(0,J.jsx)(__,{ref:t,className:s,...i}),n[7]=i,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});hU.displayName=__.displayName;var gU=q.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-destructive/30 hover:group-[.destructive]:border-destructive/30 hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,J.jsx)(b_,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});gU.displayName=b_.displayName;var _U=q.forwardRef((e,t)=>{let n=(0,X.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-hidden focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-500 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,J.jsx)(Td,{className:`h-4 w-4`}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,J.jsx)(x_,{ref:t,className:a,"toast-close":``,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});_U.displayName=x_.displayName;var vU=q.forwardRef((e,t)=>{let n=(0,X.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=V(`text-sm font-semibold`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,J.jsx)(v_,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});vU.displayName=v_.displayName;var yU=q.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,onPointerDown:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===r?o=n[5]:(o=V(`max-h-48 overflow-auto text-sm opacity-90 whitespace-pre-wrap wrap-break-word select-text cursor-text`,r),n[4]=r,n[5]=o);let s;n[6]===i?s=n[7]:(s=e=>{e.stopPropagation(),i?.(e)},n[6]=i,n[7]=s);let c;return n[8]!==a||n[9]!==t||n[10]!==o||n[11]!==s?(c=(0,J.jsx)(y_,{ref:t,className:o,onPointerDown:s,...a}),n[8]=a,n[9]=t,n[10]=o,n[11]=s,n[12]=c):c=n[12],c});yU.displayName=y_.displayName;function bU(e){return e.type===`cell`?e.cellId:`lsp:${e.name}`}var xU=!1;function SU(e){let t=[],n=[e.console].filter(Boolean).flat();for(let r of n){let n=r.mimetype===`text/plain`,i=r.mimetype===`text/html`||r.mimetype===`application/vnd.marimo+traceback`;if(n||i){let n=r.channel===`stderr`||r.channel===`marimo-error`;switch(r.channel){case`stdout`:case`stderr`:case`marimo-error`:{let a=rd.asString(r.data),o=i?sU(a):a;t.push({timestamp:r.timestamp||Date.now(),level:n?`stderr`:`stdout`,message:o,source:{type:`cell`,cellId:e.cell_id}});break}}}}if(t.forEach(CU.log),n.length===0&&QS(e.output?.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(t=>{CU.log({level:`stderr`,source:{type:`cell`,cellId:e.cell_id},timestamp:e.timestamp??0,message:JSON.stringify(t)})});let t=e.output.data.filter(e=>`type`in e&&e.type===`exception`||e.type===`internal`),n=u.get(gc)===`read`;if(t.length>0&&!xU&&n){xU=!0;let e=t.find(e=>e.traceback);of(e?{title:`An internal error occurred`,description:e.msg||`Click 'View' to see traceback`,variant:`danger`,action:q.createElement(gU,{altText:`View traceback`,onClick:()=>{u.set(lU,{traceback:e.traceback,errorMessage:e.msg||`An internal error occurred`})}},`View`)}:{title:`An internal error occurred`,description:`See console for details.`,variant:`danger`})}}return t}var CU={log:e=>{let t=e.level===`stdout`?`gray`:e.level===`stderr`?`red`:`orange`,n=e.level.toUpperCase();console.log(`%c[${n}]`,`color:${t}; padding:2px 0; border-radius:2px; font-weight:bold`,`[${wU(e.timestamp)}]`,`(${bU(e.source)}) ${e.message}`)}};function wU(e){try{return ZH(e).toLocaleTimeString(void 0,{hour12:!0,hour:`numeric`,minute:`numeric`,second:`numeric`})}catch{return``}}function TU(e,t){let n=RW(t);n?n.focus():B.warn(`[CellFocusManager] focusCellEditor: element not found: ${t}`)}function EU(e){let t=document.getElementById(Xm.create(e));t?kU(t):B.warn(`[CellFocusManager] focusCell: element not found: ${e}`)}function DU(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}function OU(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains(`marimo-cell`)}function kU(e){try{e.focus()}catch{B.warn(`[CellFocusManager] element may not be focusable`,e)}}function AU(e,t){let{retries:n,delay:r,initialDelay:i=0}=t,a=0,o=()=>{if(a<n){try{if(e())return}catch(e){B.error(`Error executing function on attempt ${a+1}, retrying`,{error:e})}a++,setTimeout(o,r)}};i>0?setTimeout(o,i):o()}function jU(){let e=globalThis.scheduler;if(typeof e?.postTask==`function`)return t=>{e.postTask(t,{priority:`user-visible`}).catch(e=>{setTimeout(()=>{throw e})})};if(typeof MessageChannel==`function`){let e=[],t=new MessageChannel;return t.port1.onmessage=()=>{e.shift()?.()},n=>{e.push(n),t.port2.postMessage(null)}}return e=>{setTimeout(e,0)}}var MU=jU();function NU(e=MU){let t=new Map,n=new Set,r=!1;function i(){r||t.size===0||(r=!0,e(o))}function a(){for(let e of n){if(t.has(e))return e;n.delete(e)}return t.keys().next().value}function o(){r=!1;try{let e=a();if(e!==void 0){let r=t.get(e);t.delete(e),n.delete(e),r?.()}}finally{i()}}return{request(e,n){t.set(e,n),i()},promote(e){let r=t.get(e);r&&(t.delete(e),n.delete(e),r())},prioritize(e){t.has(e)&&n.add(e)},deprioritize(e){n.delete(e)},cancel(e){t.delete(e),n.delete(e)}}}var PU=NU();function FU({cellId:e,cell:t,isCodeHidden:n,codeFocus:r,variableName:i}){if(!t)return;let a=document.getElementById(Xm.create(e));if(!a){B.warn(`scrollCellIntoView: element not found`);return}if(OU()){kU(a);return}if(n)kU(a);else{PU.promote(e);let n=t.current?.editorView;if(!n){B.warn(`scrollCellIntoView: editor not found`,e);return}if(n.hasFocus||!document.hasFocus())return;if(AU(()=>(n.focus(),n.hasFocus),{retries:5,delay:20}),r===`top`)n.dispatch({selection:{anchor:0,head:0}});else if(r===`bottom`){let e=n.state.doc.line(n.state.doc.lines);n.dispatch({selection:{anchor:e.from,head:e.from}})}else i&&ok(n,i)}a.scrollIntoView({behavior:`smooth`,block:`nearest`})}function IU(e){let t=document.getElementById(Xm.create(e));if(!t){B.warn(`scrollCellIntoView: element not found`);return}t.classList.add(`focus-outline`),setTimeout(()=>{t.classList.remove(`focus-outline`)},2e3),t.scrollIntoView({behavior:`smooth`,block:`center`})}function LU(){let e=document.getElementById(`App`);e?.scrollTo({top:e.scrollHeight,behavior:`smooth`})}function RU(){document.getElementById(`App`)?.scrollTo({top:0,behavior:`smooth`})}function zU(e){let t=RW(e);if(t?.hasFocus){KE(t,{behavior:`instant`});return}let n=document.getElementById(Xm.create(e));n?n.scrollIntoView({behavior:`instant`,block:`nearest`}):B.warn(`[CellFocusManager] scrollCellIntoView: element not found: ${e}`)}function BU({id:e,name:t=`_`,code:n=``,lastCodeRun:r=null,lastExecutionTime:i=null,edited:a=!1,config:o,serializedEditorState:s=null}){return{id:e,config:o||{hide_code:!1,disabled:!1,column:null},name:t,code:n,edited:a,lastCodeRun:r,lastExecutionTime:i,serializedEditorState:s}}function VU(e){return{hide_code:!1,disabled:!1,column:null,...e}}function HU(e){return{outline:null,output:null,consoleOutputs:[],status:`idle`,staleInputs:!1,interrupted:!1,errored:!1,stopped:!1,runElapsedTimeMs:null,runStartTimestamp:null,lastRunStartTimestamp:null,debuggerActive:!1,...e}}function UU(e){let t={column:0,hide_code:!1,disabled:!1};return{...e,cellData:{[qm]:BU({id:qm,config:t}),...e.cellData},cellRuntime:{[qm]:HU(),...e.cellRuntime},cellHandles:{[qm]:(0,q.createRef)(),...e.cellHandles}}}function WU(){return UU({cellIds:dv.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}var{reducer:GU,addMiddleware:KU,createActions:qU,useActions:JU,valueAtom:YU}=Ku(WU,{createNewCell:(e,t)=>{let{cellId:n,before:r,code:i,name:a,config:o,lastCodeRun:s=null,lastExecutionTime:c=null,autoFocus:l=!0,skipIfCodeExists:u=!1,hideCode:d=void 0}=t,f,p;if(u){for(let t of e.cellIds.inOrderIds)if(e.cellData[t]?.code===i)return e}if(n===`__end__`){let t=e.cellIds.atOrThrow(0);f=t.id,p=t.length}else if(typeof n==`string`){let t=e.cellIds.findWithId(n);f=t.id,p=t.topLevelIds.indexOf(n)}else if(n.type===`__end__`){let t=e.cellIds.get(n.columnId)||e.cellIds.atOrThrow(0);f=t.id,p=t.length}else throw Error(`Invalid cellId`);let m=t.newCellId||Ym.create(),h=r?p:p+1;return{...e,cellIds:e.cellIds.insertId(m,f,h),cellData:{...e.cellData,[m]:BU({id:m,code:i,name:a,lastCodeRun:s,config:VU({...o,...d!=null&&{hide_code:d}}),lastExecutionTime:c,edited:!!i&&i!==s})},cellRuntime:{...e.cellRuntime,[m]:HU()},cellHandles:{...e.cellHandles,[m]:(0,q.createRef)()},scrollKey:l?m:null,untouchedNewCells:d&&l?new Set([...e.untouchedNewCells,m]):e.untouchedNewCells}},moveCell:(e,t)=>{let{cellId:n,before:r,direction:i}=t;if(r!==void 0&&i!==void 0&&B.warn(`Both before and direction specified for moveCell. Ignoring one.`),i){let t=e.cellIds.findWithId(n),r=e.cellIds.indexOf(t),a=i===`left`?r-1:r+1,o=e.cellIds.at(a);return o?{...e,cellIds:e.cellIds.moveAcrossColumns(t.id,n,o.id,void 0),scrollKey:n}:e}let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n);return r&&o===0?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,0),scrollKey:n}:!r&&o===a.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,a.length-1),scrollKey:n}:r?{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,o-1),scrollKey:n}:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,o,o+1),scrollKey:n}},moveCellToIndex:(e,t)=>{let{cellId:n,columnId:r,index:i}=t,a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=e.cellIds.get(r);if(!s)return e;let c=Math.max(0,Math.min(i,s.length)),l=a.id===r&&o<c?c-1:c;if(a.id===r&&o===l)return e;let u=e.cellIds.deleteById(n),d=u.get(r);return d?{...e,cellIds:u.insertId(n,r,Math.max(0,Math.min(l,d.length))),scrollKey:null}:e},dropCellOverCell:(e,t)=>{let{cellId:n,overCellId:r}=t,i=e.cellIds.findWithId(n),a=e.cellIds.findWithId(r),o=i.indexOfOrThrow(n),s=a.indexOfOrThrow(r);return i.id===a.id?o===s?e:{...e,cellIds:e.cellIds.moveWithinColumn(i.id,o,s),scrollKey:null}:{...e,cellIds:e.cellIds.moveAcrossColumns(i.id,n,a.id,r),scrollKey:null}},moveCellsRelativeTo:(e,t)=>{let{cellIds:n,targetCellId:r,position:i,previousPlacements:a}=t;if(n.length===0)return e;let o=e.cellIds.moveCellsRelativeTo(n,r,i),s=a&&a.length===n.length?[...e.history,{type:`move`,cellIds:n,placements:a}]:e.history;return{...e,cellIds:o,history:s,scrollKey:null}},dropCellOverColumn:(e,t)=>{let{cellId:n,columnId:r}=t,i=e.cellIds.findWithId(n);return{...e,cellIds:e.cellIds.moveAcrossColumns(i.id,n,r,void 0)}},dropOverNewColumn:(e,t)=>{let{cellId:n}=t;return{...e,cellIds:e.cellIds.moveToNewColumn(n)}},moveColumn:(e,t)=>t.column===t.overColumn?e:{...e,cellIds:e.cellIds.moveColumn(t.column,t.overColumn)},focusCell:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,where:i}=t,a=n.indexOfOrThrow(r),o;o=i===`before`?Vu(a-1,0,n.length-1):i===`after`?Vu(a+1,0,n.length-1):a;let s=n.atOrThrow(o);return FU({cellId:s,cell:e.cellHandles[s],isCodeHidden:XU(e,s),codeFocus:i===`after`?`top`:`bottom`,variableName:void 0}),e},focusTopCell:e=>{let t=e.cellIds.getColumns().at(0);if(t===void 0||t.length===0)return e;let n=t.first();return FU({cellId:n,cell:e.cellHandles[n],isCodeHidden:XU(e,n),codeFocus:void 0,variableName:void 0}),RU(),e},focusBottomCell:e=>{let t=e.cellIds.getColumns().at(-1);if(t===void 0||t.length===0)return e;let n=t.last();return FU({cellId:n,cell:e.cellHandles[n],isCodeHidden:XU(e,n),codeFocus:void 0,variableName:void 0}),LU(),e},sendToTop:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,scroll:i=!0}=t,a=n.indexOfOrThrow(r);return a===0?e:{...e,cellIds:e.cellIds.moveWithinColumn(n.id,a,0),scrollKey:i?r:null}},sendToBottom:(e,t)=>{let n=e.cellIds.findWithId(t.cellId);if(n.length===0)return e;let{cellId:r,scroll:i=!0}=t,a=n.indexOfOrThrow(r),o=n.length-1;return a===o?e:{...e,cellIds:e.cellIds.moveWithinColumn(n.id,a,o),scrollKey:i?r:null}},addColumn:(e,t)=>{let n=Ym.create();return{...e,cellIds:e.cellIds.addColumn(t.columnId,[n]),cellData:{...e.cellData,[n]:BU({id:n})},cellRuntime:{...e.cellRuntime,[n]:HU()},cellHandles:{...e.cellHandles,[n]:(0,q.createRef)()},scrollKey:n}},addColumnBreakpoint:(e,t)=>{let{cellId:n}=t;return e.cellIds.getColumns()[0].inOrderIds[0]===n?e:{...e,cellIds:e.cellIds.insertBreakpoint(n)}},deleteColumn:(e,t)=>{let{columnId:n}=t;return{...e,cellIds:e.cellIds.delete(n)}},mergeAllColumns:e=>({...e,cellIds:e.cellIds.mergeAllColumns()}),compactColumns:e=>({...e,cellIds:e.cellIds.compact()}),deleteCell:(e,t)=>{let n=t.cellId;if(e.cellIds.hasOnlyOneId())return e;let r;try{r=e.cellIds.findWithId(n)}catch(t){return B.warn(`Skipping delete for missing cellId`,{cellId:n,error:t}),e}let i=r.indexOfOrThrow(n),a=i===0?1:i-1,o=null;r.length>1&&(o=r.atOrThrow(a));let s=(e.cellHandles[n].current?.editorView)?.state.toJSON({history:yu});s&&(s.doc=e.cellData[n].code),NW(n);let c=e.cellData[n];return{...e,cellIds:e.cellIds.deleteById(n),history:[...e.history,{type:`delete`,name:c.name,serializedEditorState:s,column:r.id,index:i,isSetupCell:n===Jm,config:c.config}],scrollKey:o}},undoDeleteCell:e=>{if(e.history.length===0)return e;let t=e.history[e.history.length-1];if(t.type===`move`){let{cellIds:n,placements:r}=t;if(n.length===0||r.length!==n.length||n.some(t=>!e.cellData[t]))return{...e,history:e.history.slice(0,-1)};let i=n.map((e,t)=>({id:e,columnId:r[t].columnId,index:r[t].index}));return{...e,cellIds:e.cellIds.placeCells(i),history:e.history.slice(0,-1),scrollKey:n[0]??null}}let{name:n,serializedEditorState:r={doc:``},column:i,index:a,isSetupCell:o,config:s}=t,c=o?Jm:Ym.create(),l=BU({id:c,name:n,code:r.doc,edited:r.doc.trim().length>0,serializedEditorState:r,config:s});return{...e,cellIds:e.cellIds.insertId(c,i,a),cellData:{...e.cellData,[c]:l},cellRuntime:{...e.cellRuntime,[c]:HU()},cellHandles:{...e.cellHandles,[c]:(0,q.createRef)()},history:e.history.slice(0,-1),scrollKey:c}},clearSerializedEditorState:(e,t)=>{let{cellId:n}=t;return QU({state:e,cellId:n,cellReducer:e=>({...e,serializedEditorState:null})})},updateCellCode:(e,t)=>{let{cellId:n,code:r,formattingChange:i}=t;return e.cellData[n]?QU({state:e,cellId:n,cellReducer:e=>i?{...e,code:r,lastCodeRun:e.edited?e.lastCodeRun:r}:{...e,code:r,edited:r.trim()!==e.lastCodeRun}}):e},updateCellName:(e,t)=>{let{cellId:n,name:r}=t;return QU({state:e,cellId:n,cellReducer:e=>({...e,name:r})})},updateCellConfig:(e,t)=>{let{cellId:n,config:r}=t;return QU({state:e,cellId:n,cellReducer:e=>({...e,config:VU({...e.config,...r})})})},prepareForRun:(e,t)=>QU({state:ZU({state:e,cellId:t.cellId,cellReducer:e=>AH(e)}),cellId:t.cellId,cellReducer:e=>({...e,edited:!1,lastCodeRun:e.code.trim()})}),handleCellMessage:(e,t)=>{let n=t.cell_id,r=ZU({state:e,cellId:n,cellReducer:e=>kH(e,t)});return t.status===`queued`&&(r=QU({state:r,cellId:n,cellReducer:e=>({...e,lastCodeRun:e.code.trim(),edited:!1})})),{...r,cellLogs:[...r.cellLogs,...SU(t)]}},addLogs:(e,t)=>({...e,cellLogs:[...e.cellLogs,...t.logs]}),setCellIds:(e,t)=>{if(l(e.cellIds.inOrderIds,t.cellIds))return e;let n={...e.cellData},r={...e.cellRuntime},i={...e.cellHandles};for(let a of t.cellIds)a in e.cellData||(n[a]=BU({id:a})),a in e.cellRuntime||(r[a]=HU()),a in e.cellHandles||(i[a]=(0,q.createRef)());return{...e,cellIds:dv.fromWithPreviousShape(t.cellIds,e.cellIds),cellData:n,cellRuntime:r,cellHandles:i}},rebuildCellColumns:(e,t)=>{let n=dv.fromIdsAndColumns(t.cellIds.map(t=>[t,e.cellData[t]?.config.column??null]));return{...e,cellIds:n}},setCellCodes:(e,t)=>{mc(t.codes.length===t.ids.length,`Expected codes and ids to have the same length`);let n={...e},r=({cell:e,code:r,cellId:i,name:a,config:o})=>{if(!e)return BU({id:i,code:r,name:a,config:o,lastCodeRun:t.codeIsStale?null:r,edited:t.codeIsStale&&r.trim().length>0});let s=t.codeIsStale?e.lastCodeRun:r,c=s?s.trim()!==r.trim():!!r;if(e.code.trim()===r.trim())return{...e,code:r,edited:c,lastCodeRun:s,...a!==void 0&&{name:a},...o!==void 0&&{config:o}};if(!_H()||!vH(i)){let e=n.cellHandles[i].current;e?.editorViewOrNull&&iH(e.editorViewOrNull,r)}return{...e,code:r,edited:c,lastCodeRun:s,...a!==void 0&&{name:a},...o!==void 0&&{config:o}}};for(let e=0;e<t.ids.length;e++){let i=t.ids[e],a=t.codes[e];if(i===void 0||a===void 0)continue;let o=t.names?.[e],s=t.configs?.[e];n={...n,cellData:{...n.cellData,[i]:r({cell:n.cellData[i],code:a,cellId:i,name:o,config:s})}}}return n},setStdinResponse:(e,t)=>{let{cellId:n,response:r,outputIndex:i}=t;return ZU({state:e,cellId:n,cellReducer:e=>{let t=[...e.consoleOutputs],n=t[i];return n==null||n.channel!==`stdin`?(B.warn(`Expected stdin output`),e):(t[i]={channel:`stdin`,mimetype:n.mimetype,data:n.data,timestamp:n.timestamp,response:r},{...e,interrupted:!1,consoleOutputs:t})}})},setCells:(e,t)=>{let n=Object.fromEntries(t.map(e=>[e.id,e])),r=_c(),i=t=>{if(!r)return HU();let n=e.cellRuntime[t];return n&&(n.output!=null||n.consoleOutputs.length>0)?n:HU()},a=Object.fromEntries(t.map(e=>[e.id,i(e.id)]));return UU({...e,cellIds:dv.fromIdsAndColumns(t.map(e=>[e.id,e.config.column])),cellData:n,cellRuntime:a,cellHandles:Object.fromEntries(t.map(e=>[e.id,(0,q.createRef)()]))})},moveToNextCell:(e,t)=>{let{cellId:n,before:r,noCreate:i=!1}=t;if(n===`__scratch__`)return e;let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=r?o-1:o+1,c=s===a.length,l=s===-1;if(c&&!i){let t=Ym.create();return{...e,cellIds:e.cellIds.insertId(t,a.id,s),cellData:{...e.cellData,[t]:BU({id:t})},cellRuntime:{...e.cellRuntime,[t]:HU()},cellHandles:{...e.cellHandles,[t]:(0,q.createRef)()},scrollKey:t}}if(l&&!i){let t=Ym.create();return{...e,cellIds:e.cellIds.insertId(t,a.id,0),cellData:{...e.cellData,[t]:BU({id:t})},cellRuntime:{...e.cellRuntime,[t]:HU()},cellHandles:{...e.cellHandles,[t]:(0,q.createRef)()},scrollKey:t}}if((c||l)&&i)return e;if(s>=0&&s<a.length){let t=a.atOrThrow(s);FU({cellId:t,cell:e.cellHandles[t],isCodeHidden:XU(e,t),codeFocus:r?`bottom`:`top`,variableName:void 0})}return e},markTouched:(e,t)=>{let{cellId:n}=t;if(e.untouchedNewCells.has(n)){let t=new Set(e.untouchedNewCells);return t.delete(n),{...e,untouchedNewCells:t}}return e},markUntouched:(e,t)=>{let{cellId:n}=t;if(!e.untouchedNewCells.has(n)){let t=new Set(e.untouchedNewCells);return t.add(n),{...e,untouchedNewCells:t}}return e},scrollToTarget:e=>{let t=e.scrollKey;if(t===null)return e;let n=e.cellIds.findWithId(t),r=n.indexOfOrThrow(t),i=r===n.length-1?n.last():n.atOrThrow(r);return FU({cellId:i,cell:e.cellHandles[i],isCodeHidden:XU(e,i),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(jv(Object.values(e.cellHandles).map(e=>e.current?.editorView)),e),unfoldAll:e=>(Mv(Object.values(e.cellHandles).map(e=>e.current?.editorView)),e),clearLogs:e=>({...e,cellLogs:[]}),collapseCell:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r.topLevelIds.map(t=>e.cellRuntime[t].outline),a=hH(r.indexOfOrThrow(n),i);if(!a)return e;let o=r.atOrThrow(a[1]);return{...e,cellIds:e.cellIds.transformWithCellId(n,e=>e.collapse(n,o)),scrollKey:n}},expandCell:(e,t)=>{let{cellId:n}=t;return{...e,cellIds:e.cellIds.transformWithCellId(n,e=>e.expand(n)),scrollKey:n}},collapseAllCells:e=>({...e,cellIds:e.cellIds.transformAll(t=>{let n=t.topLevelIds.map(t=>e.cellRuntime[t].outline),r=[...t.nodes],i=[],a=[],o=r.length-1;for(;o>=0;){let e=hH(o,n);if(e){let n=o,r=e[1],s=i.find(e=>e.start<=r&&e.end===r);s&&(r=s.start),i.push({start:n,end:r});let c=t.atOrThrow(n),l=t.atOrThrow(r);a.push({id:c,until:l})}else a.push(null);o--}let s=a.toReversed();return t.collapseAll(s)})}),expandAllCells:e=>({...e,cellIds:e.cellIds.transformAll(e=>e.expandAll())}),showCellIfHidden:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r,a=r.findAndExpandDeep(n);return a.equals(i)?e:{...e,cellIds:e.cellIds.transformWithCellId(n,()=>a)}},splitCell:(e,t)=>{let{cellId:n}=t,r=e.cellIds.findWithId(n),i=r.indexOfOrThrow(n),a=e.cellData[n],o=e.cellHandles[n].current;if(o?.editorView==null)return e;let{beforeCursorCode:s,afterCursorCode:c}=aH(o.editorView);iH(o.editorView,s);let l=Ym.create();return{...e,cellIds:e.cellIds.insertId(l,r.id,i+1),cellData:{...e.cellData,[n]:{...a,code:s,edited:!!s&&s.trim()!==a.lastCodeRun?.trim()},[l]:BU({id:l,code:c,edited:!!c})},cellRuntime:{...e.cellRuntime,[n]:{...e.cellRuntime[n],output:null,consoleOutputs:[]},[l]:HU()},cellHandles:{...e.cellHandles,[l]:(0,q.createRef)()},scrollKey:l}},undoSplitCell:(e,t)=>{let{cellId:n,snapshot:r}=t,i=e.cellData[n],a=e.cellHandles[n].current;return a?.editorView==null?e:(iH(a.editorView,r),{...e,cellIds:e.cellIds.transformWithCellId(n,e=>{let t=e.indexOfOrThrow(n)+1;return e.deleteAtIndex(t)}),cellData:{...e.cellData,[n]:{...i,code:r,edited:!!r&&r?.trim()!==i.lastCodeRun?.trim()}},cellRuntime:{...e.cellRuntime,[n]:{...e.cellRuntime[n],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,t)=>{let{cellId:n}=t;return ZU({state:e,cellId:n,cellReducer:e=>({...e,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,t)=>{let{cellId:n}=t;return ZU({state:e,cellId:n,cellReducer:e=>({...e,consoleOutputs:e.consoleOutputs.filter(e=>e.channel===`stdin`&&e.response==null)})})},clearAllCellOutputs:e=>{let t={...e.cellRuntime};for(let n of e.cellIds.inOrderIds)t[n]={...t[n],output:null,consoleOutputs:[]};return{...e,cellRuntime:t}},addSetupCellIfDoesntExist:(e,t)=>{let{code:n}=t;return e.cellIds.setupCellExists()?{...e,scrollKey:Jm}:{...e,cellIds:e.cellIds.insertId(Jm,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Jm]:BU({id:Jm,name:Jm,code:n,edited:!!n})},cellRuntime:{...e.cellRuntime,[Jm]:HU()},cellHandles:{...e.cellHandles,[Jm]:(0,q.createRef)()},scrollKey:Jm}}});KU(YH);function XU(e,t){return!!e.cellData[t].config.hide_code&&!e.untouchedNewCells.has(t)}function ZU({state:e,cellId:t,cellReducer:n}){return t in e.cellRuntime?{...e,cellRuntime:{...e.cellRuntime,[t]:n(e.cellRuntime[t])}}:(B.warn(`Cell ${t} not found in state`),e)}function QU({state:e,cellId:t,cellReducer:n}){return t in e.cellData?{...e,cellData:{...e.cellData,[t]:n(e.cellData[t])}}:(B.warn(`Cell ${t} not found in state`),e)}function $U(e){let t=e.cellData,n={column:null};return e.cellIds.getColumns().length>1?e.cellIds.getColumns().flatMap((e,r)=>e.inOrderIds.map((e,i)=>{let a={...n};return i===0&&(a.column=r),{...t[e].config,...a}})):e.cellIds.getColumns().flatMap(e=>e.inOrderIds.map(e=>({...t[e].config,...n})))}var eW=qU(e=>{u.set(YU,t=>GU(t,e))}).addLogs,tW=o(e=>e(YU).cellIds),nW=o(e=>e(tW).hasOnlyOneId()),rW=o(e=>iC(e(YU)).length>0);o(e=>aC(e(YU)).length>0);var iW=o(e=>oC(e(YU))),aW=o(e=>sC(e(YU))),oW=o(e=>tC(e(YU))),sW=o(e=>{let{cellIds:t,cellRuntime:n,cellData:r}=e(YU);return t.inOrderIds.map(e=>{let t=n[e],{name:i}=r[e];if(QS(t.output?.mimetype)){mc(Array.isArray(t.output.data),`Expected array data`);let n=t.output.data.filter(e=>!e.type.includes(`ancestor`));if(n.length>0)return{output:{...t.output,data:n},cellId:e,cellName:i}}return null}).filter(Boolean)}),cW=o(e=>{let{cellIds:t,cellRuntime:n}=e(YU);return fH(t.inOrderIds.map(e=>n[e].outline))}),lW=o(e=>e(sW).length),uW=c(o(e=>{let{cellIds:t,cellData:n}=e(YU);return pc.fromEntries(t.inOrderIds.map(e=>[e,n[e]?.name]))})),dW=o(e=>e(YU).scrollKey),fW=()=>s(YU),pW=()=>s(tW),mW=()=>s(uW),hW=()=>s(sW),gW=()=>s(YU).cellLogs,_W=()=>s(dW),vW=()=>u.get(YU),yW=()=>u.get(YU).cellIds,bW=()=>{let{cellIds:e,cellData:t}=u.get(YU);return e.inOrderIds.map(e=>t[e]?.name).filter(Boolean)},xW=R_(j_(YU,e=>e.cellIds.inOrderIds.map(t=>e.cellData[t]))),SW=()=>a(xW),CW=o(e=>e(YU).cellRuntime),wW=o(e=>$S(e(YU))),TW=o(e=>{let{cellRuntime:t}=e(YU);return Object.entries(t).every(([e,t])=>t.status!==`running`||e===`__scratch__`)}),EW=o(e=>eC(e(YU))),DW=o(e=>e(YU).cellIds.colLength),OW=o(e=>e(YU).cellIds.idLength>0),kW=o(e=>e(YU).cellIds.getColumnIds()),AW=D_(e=>o(t=>t(YU).cellData[e])),jW=D_(e=>o(t=>t(YU).cellRuntime[e])),MW=D_(e=>o(t=>t(YU).cellHandles[e]));function NW(e){AW.remove(e),jW.remove(e),MW.remove(e)}var PW=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=AW(e),t[0]=e,t[1]=n),s(n)},FW=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=jW(e),t[0]=e,t[1]=n),s(n)},IW=e=>{let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=MW(e),t[0]=e,t[1]=n),s(n)},LW=()=>{let{cellIds:e,cellHandles:t}=u.get(YU);return e.inOrderIds.map(e=>t[e]?.current?.editorViewOrNull).filter(Boolean)},RW=e=>{let{cellHandles:t}=u.get(YU);return t[e].current?.editorView};function zW(e){let{cellIds:t,cellData:n,cellRuntime:r}=e;return t.getColumns().flatMap(e=>e.topLevelIds.map(e=>({...n[e],...r[e]})))}function BW(e){return o(t=>t(YU).untouchedNewCells.has(e))}function VW(e){let t=jW(e);return o(n=>{let r=n(t);if(!r||r.status===`queued`||r.status===`running`)return;let i=[],a=r.consoleOutputs;if(a&&a.length>0){let e=a.find(e=>e.mimetype===`application/vnd.marimo+traceback`);if(e){let t=e.data;i.push(...kv(t))}}let o=r.output;if(o?.mimetype===`application/vnd.marimo+error`){let t=o.data;if(Array.isArray(t))for(let n of t)n.type===`syntax`&&n.lineno!=null&&i.push({kind:`cell`,cellId:e,lineNumber:n.lineno}),n.type===`import-star`&&n.lineno!=null&&i.push({kind:`cell`,cellId:e,lineNumber:n.lineno})}return i.length>0?i:void 0})}function HW(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n),JU(n)}export{vU as $,kS as $a,bw as $i,yM as $n,rD as $r,Gz as $t,IW as A,DC as Aa,Yw as Ai,uR as An,$m as Ao,GO as Ar,fV as At,zU as B,nC as Ba,Iw as Bi,QF as Bn,Im as Bo,kD as Br,FB as Bt,DW as C,RC as Ca,$w as Ci,Oz as Cn,Qh as Co,ok as Cr,DV as Ct,PW as D,LC as Da,vT as Di,rz as Dn,rh as Do,KO as Dr,wV as Dt,HW as E,PC as Ea,_T as Ei,xz as En,nh as Eo,VO as Er,SV as Et,fW as F,iC as Fa,Hw as Fi,_I as Fn,Zm as Fo,UD as Fr,QB as Ft,OU as G,XS as Ga,Aw as Gi,KF as Gn,mm as Go,xD as Gr,gB as Gt,AU as H,mC as Ha,Nw as Hi,$F as Hn,km as Ho,SD as Hr,IB as Ht,_W as I,aC as Ia,Vw as Ii,rI as In,Um as Io,zD as Ir,nV as It,bU as J,JS as Ja,Dw as Ji,nF as Jn,vD as Jr,fB as Jt,DU as K,ZS as Ka,kw as Ki,TF as Kn,mf as Ko,yD as Kr,_B as Kt,BU as L,cC as La,Bw as Li,aI as Ln,Wm as Lo,MD as Lr,NB as Lt,gW as M,gC as Ma,qw as Mi,tR as Mn,qm as Mo,AO as Mr,uV as Mt,mW as N,dC as Na,Kw as Ni,zI as Nn,Jm as No,BO as Nr,rV as Nt,SW as O,OC as Oa,uT as Oi,dR as On,eh as Oo,qO as Or,TV as Ot,FW as P,fC as Pa,Uw as Pi,XI as Pn,Qm as Po,zO as Pr,$B as Pt,uU as Q,OS as Qa,xw as Qi,oF as Qn,nD as Qr,oB as Qt,HU as R,uC as Ra,zw as Ri,iI as Rn,Rm as Ro,LD as Rr,RB as Rt,EW as S,jC as Sa,AT as Si,Tz as Sn,Jh as So,mk as Sr,tH as St,aW as T,NC as Ta,aT as Ti,bz as Tn,th as To,HO as Tr,bV as Tt,EU as U,lC as Ua,Mw as Ui,XF as Un,Em as Uo,Q as Ur,kB as Ut,PU as V,pC as Va,Pw as Vi,ZF as Vn,jm as Vo,wD as Vr,PB as Vt,TU as W,QS as Wa,jw as Wi,JF as Wn,Tm as Wo,CD as Wr,OB as Wt,_U as X,VS as Xa,Cw as Xi,rF as Xn,_D as Xr,lB as Xt,hU as Y,HS as Ya,Tw as Yi,iF as Yn,sD as Yr,pB as Yt,yU as Z,IS as Za,Sw as Zi,aF as Zn,gD as Zr,aB as Zt,nW as _,KC as _a,jE as _i,Cz as _n,J_ as _o,Ok as _r,QV as _t,CW as a,fw as aa,XE as ai,Qz as an,Tv as ao,QA as ar,XH as at,wW as b,MC as ba,JT as bi,wz as bn,H_ as bo,gk as br,nH as bt,zW as c,lw as ca,UE as ci,Bz as cn,sv as co,PA as cr,vH as ct,RW as d,rw as da,NE as di,zz as dn,$_ as do,lA as dr,mH as dt,vw as ea,iD as ei,$z as en,gS as eo,iM as er,dU as et,bW as f,tw as fa,ME as fi,jz as fn,ev as fo,cA as fr,dH as ft,rW as g,GC as ga,kE as gi,Sz as gn,K_ as go,Dk as gr,iH as gt,OW as h,qC as ha,AE as hi,Mz as hn,q_ as ho,Bk as hr,rH as ht,tW as i,pw as ia,$E as ii,Zz as in,Ov as io,$A as ir,eU as it,pW as j,hC as ja,Gw as ji,ML as jn,Xm as jo,JO as jr,dV as jt,hW as k,EC as ka,Jw as ki,fR as kn,Ym as ko,UO as kr,pV as kt,LW as l,ow as la,LE as li,Vz as ln,av as lo,OA as lr,_H as lt,vW as m,nw as ma,DE as mi,Iz as mn,Y_ as mo,zk as mr,oH as mt,AW as n,gw as na,tD as ni,Kz as nn,Dv as no,mj as nr,cU as nt,kW as o,dw as oa,GE as oi,tB as on,wv as oo,XA as or,jH as ot,yW as p,sw as pa,OE as pi,Pz as pn,Q_ as po,rA as pr,pH as pt,wU as q,YS as qa,Ow as qi,cF as qn,mD as qr,dB as qt,lW as r,hw as ra,QE as ri,Jz as rn,kv as ro,pj as rr,sU as rt,BW as s,uw as sa,VE as si,nB as sn,dv as so,ZA as sr,MH as st,iW as t,_w as ta,eD as ti,eB as tn,ex as to,gj as tr,lU as tt,$U as u,iw as ua,FE as ui,Rz as un,tv as uo,kA as ur,gH as ut,oW as v,WC as va,bE as vi,Ez as vn,U_ as vo,bk as vr,$V as vt,TW as w,kC as wa,oT as wi,Az as wn,ih as wo,WO as wr,xV as wt,cW as x,AC as xa,jT as xi,kz as xn,j_ as xo,fk as xr,JV as xt,YU as y,JC as ya,_E as yi,Dz as yn,E_ as yo,kk as yr,YV as yt,IU as z,rC as za,Rw as zi,oI as zn,zm as zo,FD as zr,LB as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./react-CBDbhulC.js";import{Xi as n,Yi as r,ta as i}from"./cells-v0dAmt79.js";import{In as a,kt as o,un as s,wt as c}from"./schemas-aTUejmFi.js";import{t as l}from"./compiler-runtime-CYIjoINj.js";import{t as u}from"./isEmpty-BJso7_X0.js";import{et as d}from"./ai-model-dropdown-BwTphSMd.js";import{g as f}from"./useEventListener-D27Dii_l.js";import{t as p}from"./cn-ldLVeaqm.js";import{t as m}from"./jsx-runtime-B74pBk57.js";import{a as h,i as g,o as _,r as v}from"./config-Cl3eMWxb.js";import{t as y}from"./button-BMBznEru.js";import{i as b}from"./strings-CpYReX2Q.js";import{t as x}from"./createLucideIcon-B7HeEoG2.js";import{t as S}from"./ban-CwXfMsC1.js";import{t as C}from"./bot-message-square-CGhPjWFf.js";import{a as w}from"./useNumberFormatter-DHJ9s6Vk.js";import{t as T}from"./markdown-renderer-BHFj8yJ6.js";import{p as E,u as D}from"./add-cell-with-ai-B382kx-8.js";import{t as O}from"./external-link-Bp3BxyRA.js";import{n as k}from"./spinner-Ck-Hgfvj.js";import{l as A}from"./datasource-Bq9EwG3Q.js";import{t as j}from"./RenderHTML-9AmE10az.js";var M=x(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),N=x(`shield-question-mark`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),P=`user_cancelled`;function F(e){if(e.type===`abort`)return e.reason}function I(e){return e.isAbort?e.streamReason||`user_cancelled`:null}function L(e){switch(e){case P:return`Generation stopped`;case`timeout`:return`Generation stopped: timed out`;default:return`Generation stopped: ${e}`}}var R=l(),z=e(t(),1),B=m(),V=e=>{let t=(0,R.c)(13),{reasoning:n,index:r,isStreaming:i}=e,a=r===void 0?0:r,o=i!==void 0&&i,[s,c]=z.useState(``);if(!n&&!o)return null;let l=o?`reasoning`:s,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,B.jsx)(C,{className:`h-3 w-3`}),t[0]=u):u=t[0];let d=o?`Thinking`:`View reasoning`,f=n.length>0&&` (${n.length} chars)`,p;t[1]!==d||t[2]!==f?(p=(0,B.jsx)(_,{className:`text-xs text-muted-foreground hover:bg-muted/50 px-2 py-1 h-auto rounded-sm [&[data-state=open]>svg]:rotate-180`,children:(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[u,d,f]})}),t[1]=d,t[2]=f,t[3]=p):p=t[3];let m;t[4]===n?m=t[5]:(m=(0,B.jsx)(g,{className:`pb-2 px-2`,children:(0,B.jsx)(`div`,{className:`bg-muted/30 border border-muted/50 rounded-md p-3 italic text-muted-foreground/90 relative`,children:(0,B.jsx)(`div`,{className:`pr-6`,children:(0,B.jsx)(T,{content:n})})})}),t[4]=n,t[5]=m);let y;t[6]!==p||t[7]!==m?(y=(0,B.jsxs)(h,{value:`reasoning`,className:`border-0`,children:[p,m]}),t[6]=p,t[7]=m,t[8]=y):y=t[8];let b;return t[9]!==a||t[10]!==l||t[11]!==y?(b=(0,B.jsx)(v,{type:`single`,collapsible:!0,className:`w-full mb-2`,value:l,onValueChange:c,children:y},a),t[9]=a,t[10]=l,t[11]=y,t[12]=b):b=t[12],b};function H(e){return e.replace(`tool-`,``)}var U=e=>{let t=(0,R.c)(9),{input:n,label:r}=e,i=r===void 0?`Tool Request`:r;if(n==null)return null;let a;t[0]===i?a=t[1]:(a=(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground`,children:i}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=JSON.stringify(n,null,2),t[2]=n,t[3]=o);let s;t[4]===o?s=t[5]:(s=(0,B.jsx)(`pre`,{className:`bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64`,children:o}),t[4]=o,t[5]=s);let c;return t[6]!==a||t[7]!==s?(c=(0,B.jsxs)(`div`,{className:`space-y-2`,children:[a,s]}),t[6]=a,t[7]=s,t[8]=c):c=t[8],c},W=e=>{let t=(0,R.c)(27),{toolName:n,input:r,approval:i,onApprove:a,className:o}=e,s;t[0]===o?s=t[1]:(s=p(`rounded-md border border-(--amber-6) bg-(--amber-2) p-3 space-y-3`,o),t[0]=o,t[1]=s);let c;t[2]===n?c=t[3]:(c=H(n),t[2]=n,t[3]=c);let l=`Approval required for ${c}`,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,B.jsx)(N,{className:`h-4 w-4 text-(--amber-11) mt-0.5 shrink-0`}),t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,B.jsx)(`span`,{className:`font-semibold`,children:`Approval required:`}),t[5]=d):d=t[5];let f;t[6]===n?f=t[7]:(f=H(n),t[6]=n,t[7]=f);let m;t[8]===f?m=t[9]:(m=(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[u,(0,B.jsxs)(`div`,{className:`text-xs text-(--amber-11) leading-relaxed`,children:[d,` `,(0,B.jsx)(`code`,{className:`font-mono`,children:f})]})]}),t[8]=f,t[9]=m);let h;t[10]===r?h=t[11]:(h=(0,B.jsx)(U,{input:r}),t[10]=r,t[11]=h);let g;t[12]!==i.id||t[13]!==a?(g=(0,B.jsx)(y,{size:`xs`,variant:`outline`,onClick:()=>a({id:i.id,approved:!1}),children:`Deny`}),t[12]=i.id,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==i.id||t[16]!==a?(_=(0,B.jsx)(y,{size:`xs`,onClick:()=>a({id:i.id,approved:!0}),children:`Approve`}),t[15]=i.id,t[16]=a,t[17]=_):_=t[17];let v;t[18]!==_||t[19]!==g?(v=(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[g,_]}),t[18]=_,t[19]=g,t[20]=v):v=t[20];let b;return t[21]!==s||t[22]!==v||t[23]!==l||t[24]!==m||t[25]!==h?(b=(0,B.jsxs)(`div`,{className:s,role:`alertdialog`,"aria-label":l,children:[m,h,v]}),t[21]=s,t[22]=v,t[23]=l,t[24]=m,t[25]=h,t[26]=b):b=t[26],b},G=e=>{let t=(0,R.c)(28),{toolName:n,input:r,errorText:a,isLive:o,className:s}=e,[c,l]=z.useState(o),u=z.useRef(o),d,f;t[0]===o?(d=t[1],f=t[2]):(d=()=>{u.current&&!o&&l(!1),u.current=o},f=[o],t[0]=o,t[1]=d,t[2]=f),z.useEffect(d,f);let m;t[3]===s?m=t[4]:(m=p(`rounded-md border border-(--red-6) bg-(--red-2)`,s),t[3]=s,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l(K),t[5]=h):h=t[5];let g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,B.jsx)(i,{className:`h-3.5 w-3.5 shrink-0`}),t[6]=g):g=t[6];let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,B.jsx)(`span`,{className:`font-semibold`,children:`Failed:`}),t[7]=_):_=t[7];let v;t[8]===n?v=t[9]:(v=H(n),t[8]=n,t[9]=v);let y;t[10]===v?y=t[11]:(y=(0,B.jsxs)(`span`,{className:`flex-1 text-left`,children:[_,` `,(0,B.jsx)(`code`,{className:`font-mono`,children:v})]}),t[10]=v,t[11]=y);let b=c&&`rotate-180`,x;t[12]===b?x=t[13]:(x=p(`h-3.5 w-3.5 shrink-0 transition-transform`,b),t[12]=b,t[13]=x);let S;t[14]===x?S=t[15]:(S=(0,B.jsx)(w,{className:x}),t[14]=x,t[15]=S);let C;t[16]!==c||t[17]!==S||t[18]!==y?(C=(0,B.jsxs)(`button`,{type:`button`,onClick:h,className:`w-full flex items-center gap-2 px-3 py-2 text-xs text-(--red-11) hover:bg-(--red-3) rounded-md transition-colors`,"aria-expanded":c,children:[g,y,S]}),t[16]=c,t[17]=S,t[18]=y,t[19]=C):C=t[19];let T;t[20]!==a||t[21]!==r||t[22]!==c?(T=c&&(0,B.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t border-(--red-6)/40 pt-3`,children:[(0,B.jsx)(U,{input:r}),a&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-(--red-11) mb-1`,children:`Error`}),(0,B.jsx)(`pre`,{className:`bg-(--red-2) border border-(--red-6) rounded p-2 text-xs text-(--red-11) leading-relaxed overflow-auto scrollbar-thin max-h-64 whitespace-pre-wrap`,children:a})]})]}),t[20]=a,t[21]=r,t[22]=c,t[23]=T):T=t[23];let E;return t[24]!==C||t[25]!==T||t[26]!==m?(E=(0,B.jsxs)(`div`,{className:m,children:[C,T]}),t[24]=C,t[25]=T,t[26]=m,t[27]=E):E=t[27],E};function K(e){return!e}function q(e){return e==null||typeof e==`object`&&u(e)}var J=s({status:a().default(`success`),auth_required:o().default(!1),action_url:c(),next_steps:c(),meta:c(),message:a().nullish()}),Y=e=>{let t=(0,R.c)(12),{data:n}=e,i;if(t[0]!==n){let{status:e,auth_required:a,action_url:o,meta:s,next_steps:c,message:l,...u}=n,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground`,children:`Tool Result`}),t[2]=d):d=t[2];let f;t[3]===e?f=t[4]:(f=(0,B.jsx)(`span`,{className:`text-xs px-2 py-0.5 bg-(--grass-2) text-(--grass-11) rounded-full font-medium capitalize`,children:e}),t[3]=e,t[4]=f);let p;t[5]===a?p=t[6]:(p=a&&(0,B.jsx)(`span`,{className:`text-xs px-2 py-0.5 bg-(--amber-2) text-(--amber-11) rounded-full`,children:`Auth Required`}),t[5]=a,t[6]=p);let m;t[7]!==f||t[8]!==p?(m=(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[d,(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f,p]})]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===l?h=t[11]:(h=l&&(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(r,{className:`h-3 w-3 text-(--blue-11) mt-0.5 shrink-0`}),(0,B.jsx)(`div`,{className:`text-xs text-foreground`,children:l})]}),t[10]=l,t[11]=h),i=(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,h,u&&(0,B.jsx)(`div`,{className:`space-y-3`,children:Object.entries(u).map(Z)})]}),t[0]=n,t[1]=i}else i=t[1];return i},X=e=>{let t=(0,R.c)(8),{result:n}=e,r;t[0]===n?r=t[1]:(r=J.safeParse(n),t[0]=n,t[1]=r);let i=r;if(i.success){let e;return t[2]===i.data?e=t[3]:(e=(0,B.jsx)(Y,{data:i.data}),t[2]=i.data,t[3]=e),e}let a;t[4]===n?a=t[5]:(a=typeof n==`string`?n:JSON.stringify(n,null,2),t[4]=n,t[5]=a);let o;return t[6]===a?o=t[7]:(o=(0,B.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1 max-h-64 overflow-y-auto scrollbar-thin`,children:a}),t[6]=a,t[7]=o),o};function Z(e){let[t,n]=e;return q(n)?null:(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}),(0,B.jsx)(`pre`,{className:`bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64`,children:JSON.stringify(n,null,2)})]},t)}var ee={"input-streaming":`Generating`,"input-available":`Running`,"approval-responded":`Awaiting result`,"output-available":`Done`,"output-denied":`Denied`},te=new Set([`input-streaming`,`input-available`,`approval-responded`]),ne=e=>{let t=(0,R.c)(5),{state:n,interrupted:r}=e;if(r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(M,{className:`h-3 w-3 text-muted-foreground`}),t[0]=e):e=t[0],e}switch(n){case`input-streaming`:case`input-available`:case`approval-responded`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(k,{className:`h-3 w-3 animate-spin`}),t[1]=e):e=t[1],e}case`output-available`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(d,{className:`h-3 w-3 text-(--grass-11)`}),t[2]=e):e=t[2],e}case`output-denied`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(S,{className:`h-3 w-3 text-muted-foreground`}),t[3]=e):e=t[3],e}default:{b(n);let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(A,{className:`h-3 w-3`}),t[4]=e):e=t[4],e}}};function re(e){switch(e){case`output-available`:return`text-(--grass-11)/80`;case`output-denied`:return`text-muted-foreground`;case`input-streaming`:case`input-available`:case`approval-responded`:return``;default:return b(e),``}}var Q=e=>{let t=(0,R.c)(34),{toolName:n,state:r,input:i,result:a,approval:o,index:s,className:c,isActive:l}=e,u=s===void 0?0:s,d=l===void 0||l,f;t[0]!==d||t[1]!==r?(f=!d&&te.has(r),t[0]=d,t[1]=r,t[2]=f):f=t[2];let m=f,y=`tool-${u}`,b;t[3]===c?b=t[4]:(b=p(`w-full`,c),t[3]=c,t[4]=b);let x;t[5]!==m||t[6]!==r?(x=p(`h-6 text-xs border-border shadow-none! ring-0! bg-muted/60 hover:bg-muted py-0 px-2 gap-1 rounded-sm [&[data-state=open]>svg]:rotate-180 hover:no-underline`,m?`text-muted-foreground`:re(r)),t[5]=m,t[6]=r,t[7]=x):x=t[7];let S;t[8]!==m||t[9]!==r?(S=(0,B.jsx)(ne,{state:r,interrupted:m}),t[8]=m,t[9]=r,t[10]=S):S=t[10];let C=m?`Interrupted`:ee[r],w;t[11]===n?w=t[12]:(w=H(n),t[11]=n,t[12]=w);let T;t[13]===w?T=t[14]:(T=(0,B.jsx)(`code`,{className:`font-mono text-xs`,children:w}),t[13]=w,t[14]=T);let E;t[15]!==T||t[16]!==S||t[17]!==C?(E=(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[S,C,`:`,T]}),t[15]=T,t[16]=S,t[17]=C,t[18]=E):E=t[18];let D;t[19]!==E||t[20]!==x?(D=(0,B.jsx)(_,{className:x,children:E}),t[19]=E,t[20]=x,t[21]=D):D=t[21];let O;t[22]!==o||t[23]!==i||t[24]!==a||t[25]!==r?(O=(0,B.jsx)(g,{className:`py-2 px-2`,children:(0,B.jsx)(ie,{state:r,input:i,result:a,approval:o})}),t[22]=o,t[23]=i,t[24]=a,t[25]=r,t[26]=O):O=t[26];let k;t[27]!==D||t[28]!==O?(k=(0,B.jsxs)(h,{value:`tool-call`,className:`border-0`,children:[D,O]}),t[27]=D,t[28]=O,t[29]=k):k=t[29];let A;return t[30]!==k||t[31]!==y||t[32]!==b?(A=(0,B.jsx)(v,{type:`single`,collapsible:!0,className:b,children:k},y),t[30]=k,t[31]=y,t[32]=b,t[33]=A):A=t[33],A},ie=e=>{let t=(0,R.c)(16),{state:n,input:r,result:i,approval:a}=e;switch(n){case`input-streaming`:case`input-available`:case`approval-responded`:{let e;return t[0]===r?e=t[1]:(e=(0,B.jsx)(U,{input:r}),t[0]=r,t[1]=e),e}case`output-available`:{let e;t[2]===r?e=t[3]:(e=(0,B.jsx)(U,{input:r}),t[2]=r,t[3]=e);let n;t[4]===i?n=t[5]:(n=i!=null&&(0,B.jsx)(X,{result:i}),t[4]=i,t[5]=n);let a;return t[6]!==e||t[7]!==n?(a=(0,B.jsxs)(`div`,{className:`space-y-3`,children:[e,n]}),t[6]=e,t[7]=n,t[8]=a):a=t[8],a}case`output-denied`:{let e;t[9]===r?e=t[10]:(e=(0,B.jsx)(U,{input:r}),t[9]=r,t[10]=e);let n=a?.reason?`: ${a.reason}`:`.`,i;t[11]===n?i=t[12]:(i=(0,B.jsxs)(`div`,{className:`bg-muted/40 border border-border rounded-md p-3 text-xs text-muted-foreground leading-relaxed`,children:[`Tool execution was denied`,n]}),t[11]=n,t[12]=i);let o;return t[13]!==e||t[14]!==i?(o=(0,B.jsxs)(`div`,{className:`space-y-3`,children:[e,i]}),t[13]=e,t[14]=i,t[15]=o):o=t[15],o}default:return b(n),null}},$=e=>{let t=(0,R.c)(27),{toolName:n,state:r,result:i,errorText:a,input:o,approval:s,onApprove:c,index:l,className:u,isLive:d,isActive:f}=e,p=d===void 0||d,m=f===void 0||f;switch(r){case`approval-requested`:{if(s!=null&&c!=null){let e;return t[0]!==s||t[1]!==u||t[2]!==o||t[3]!==c||t[4]!==n?(e=(0,B.jsx)(W,{toolName:n,input:o,approval:s,onApprove:c,className:u}),t[0]=s,t[1]=u,t[2]=o,t[3]=c,t[4]=n,t[5]=e):e=t[5],e}let e;return t[6]!==u||t[7]!==l||t[8]!==o||t[9]!==m||t[10]!==n?(e=(0,B.jsx)(Q,{toolName:n,state:`input-available`,input:o,index:l,className:u,isActive:m}),t[6]=u,t[7]=l,t[8]=o,t[9]=m,t[10]=n,t[11]=e):e=t[11],e}case`output-error`:{let e;return t[12]!==u||t[13]!==a||t[14]!==o||t[15]!==p||t[16]!==n?(e=(0,B.jsx)(G,{toolName:n,input:o,errorText:a,isLive:p,className:u}),t[12]=u,t[13]=a,t[14]=o,t[15]=p,t[16]=n,t[17]=e):e=t[17],e}case`input-streaming`:case`input-available`:case`approval-responded`:case`output-available`:case`output-denied`:{let e;return t[18]!==s||t[19]!==u||t[20]!==l||t[21]!==o||t[22]!==m||t[23]!==i||t[24]!==r||t[25]!==n?(e=(0,B.jsx)(Q,{toolName:n,state:r,input:o,result:i,approval:s,index:l,className:u,isActive:m}),t[18]=s,t[19]=u,t[20]=l,t[21]=o,t[22]=m,t[23]=i,t[24]=r,t[25]=n,t[26]=e):e=t[26],e}default:return b(r),null}},ae=({message:e,isStreamingReasoning:t,isLast:r,isActive:i,addToolApprovalResponse:a})=>{return(0,B.jsx)(B.Fragment,{children:e.parts.map((e,t)=>o(e,t))});function o(o,s){if(oe(o))return(0,B.jsx)($,{index:s,toolName:o.type,result:o.output,errorText:o.state===`output-error`?o.errorText:void 0,className:`my-2`,state:o.state,input:o.input,approval:o.approval,onApprove:a,isLive:r,isActive:i},s);if(se(o))return f.debug(`Found data part`,o),null;switch(o.type){case`text`:return o.text.includes(`<marimo-`)?(0,B.jsx)(z.Fragment,{children:j({html:o.text})},s):(0,B.jsx)(T,{content:o.text},s);case`reasoning`:return(0,B.jsx)(V,{reasoning:o.text,index:s,isStreaming:t&&r&&s===(e.parts.length||0)-1},s);case`file`:return(0,B.jsx)(D,{attachment:o},s);case`reasoning-file`:return(0,B.jsx)(D,{attachment:{type:`file`,mediaType:o.mediaType,url:o.url}},s);case`dynamic-tool`:return(0,B.jsx)($,{toolName:o.toolName,result:o.output,errorText:o.state===`output-error`?o.errorText:void 0,state:o.state,input:o.input,approval:o.approval,onApprove:a,isLive:r,isActive:i},s);case`source-document`:return(0,B.jsx)(E,{icon:(0,B.jsx)(n,{className:`h-3 w-3 shrink-0`}),title:o.title,subtitle:o.filename},s);case`source-url`:return(0,B.jsx)(E,{icon:(0,B.jsx)(O,{className:`h-3 w-3 shrink-0`}),title:o.title??o.url,subtitle:o.title?o.url:void 0,href:o.url},s);case`custom`:return(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:o.kind},s);case`step-start`:return null;default:return b(o),null}}};function oe(e){return e.type.startsWith(`tool-`)}function se(e){return e.type.startsWith(`data-`)}export{I as i,L as n,F as r,ae as t};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{t}from"./react-CBDbhulC.js";import{Xi as n,Yi as r,ta as i}from"./cells-DNoi9Edm.js";import{In as a,kt as o,un as s,wt as c}from"./schemas-aTUejmFi.js";import{t as l}from"./compiler-runtime-CYIjoINj.js";import{t as u}from"./isEmpty-BJso7_X0.js";import{et as d}from"./ai-model-dropdown-Cwwyj9FR.js";import{g as f}from"./useEventListener-D27Dii_l.js";import{t as p}from"./cn-ldLVeaqm.js";import{t as m}from"./jsx-runtime-B74pBk57.js";import{a as h,i as g,o as _,r as v}from"./config-Cl3eMWxb.js";import{t as y}from"./button-BMBznEru.js";import{i as b}from"./strings-CpYReX2Q.js";import{t as x}from"./createLucideIcon-B7HeEoG2.js";import{t as S}from"./ban-CwXfMsC1.js";import{t as C}from"./bot-message-square-CGhPjWFf.js";import{a as w}from"./useNumberFormatter-DHJ9s6Vk.js";import{t as T}from"./markdown-renderer-CB2UurmB.js";import{p as E,u as D}from"./add-cell-with-ai-DKAX5Wkq.js";import{t as O}from"./external-link-Bp3BxyRA.js";import{n as k}from"./spinner-Ck-Hgfvj.js";import{l as A}from"./datasource-DVv7qUFu.js";import{t as j}from"./RenderHTML-DyTQ_aJR.js";var M=x(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),N=x(`shield-question-mark`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),P=`user_cancelled`;function F(e){if(e.type===`abort`)return e.reason}function I(e){return e.isAbort?e.streamReason||`user_cancelled`:null}function L(e){switch(e){case P:return`Generation stopped`;case`timeout`:return`Generation stopped: timed out`;default:return`Generation stopped: ${e}`}}var R=l(),z=e(t(),1),B=m(),V=e=>{let t=(0,R.c)(13),{reasoning:n,index:r,isStreaming:i}=e,a=r===void 0?0:r,o=i!==void 0&&i,[s,c]=z.useState(``);if(!n&&!o)return null;let l=o?`reasoning`:s,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,B.jsx)(C,{className:`h-3 w-3`}),t[0]=u):u=t[0];let d=o?`Thinking`:`View reasoning`,f=n.length>0&&` (${n.length} chars)`,p;t[1]!==d||t[2]!==f?(p=(0,B.jsx)(_,{className:`text-xs text-muted-foreground hover:bg-muted/50 px-2 py-1 h-auto rounded-sm [&[data-state=open]>svg]:rotate-180`,children:(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[u,d,f]})}),t[1]=d,t[2]=f,t[3]=p):p=t[3];let m;t[4]===n?m=t[5]:(m=(0,B.jsx)(g,{className:`pb-2 px-2`,children:(0,B.jsx)(`div`,{className:`bg-muted/30 border border-muted/50 rounded-md p-3 italic text-muted-foreground/90 relative`,children:(0,B.jsx)(`div`,{className:`pr-6`,children:(0,B.jsx)(T,{content:n})})})}),t[4]=n,t[5]=m);let y;t[6]!==p||t[7]!==m?(y=(0,B.jsxs)(h,{value:`reasoning`,className:`border-0`,children:[p,m]}),t[6]=p,t[7]=m,t[8]=y):y=t[8];let b;return t[9]!==a||t[10]!==l||t[11]!==y?(b=(0,B.jsx)(v,{type:`single`,collapsible:!0,className:`w-full mb-2`,value:l,onValueChange:c,children:y},a),t[9]=a,t[10]=l,t[11]=y,t[12]=b):b=t[12],b};function H(e){return e.replace(`tool-`,``)}var U=e=>{let t=(0,R.c)(9),{input:n,label:r}=e,i=r===void 0?`Tool Request`:r;if(n==null)return null;let a;t[0]===i?a=t[1]:(a=(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground`,children:i}),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=JSON.stringify(n,null,2),t[2]=n,t[3]=o);let s;t[4]===o?s=t[5]:(s=(0,B.jsx)(`pre`,{className:`bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64`,children:o}),t[4]=o,t[5]=s);let c;return t[6]!==a||t[7]!==s?(c=(0,B.jsxs)(`div`,{className:`space-y-2`,children:[a,s]}),t[6]=a,t[7]=s,t[8]=c):c=t[8],c},W=e=>{let t=(0,R.c)(27),{toolName:n,input:r,approval:i,onApprove:a,className:o}=e,s;t[0]===o?s=t[1]:(s=p(`rounded-md border border-(--amber-6) bg-(--amber-2) p-3 space-y-3`,o),t[0]=o,t[1]=s);let c;t[2]===n?c=t[3]:(c=H(n),t[2]=n,t[3]=c);let l=`Approval required for ${c}`,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,B.jsx)(N,{className:`h-4 w-4 text-(--amber-11) mt-0.5 shrink-0`}),t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,B.jsx)(`span`,{className:`font-semibold`,children:`Approval required:`}),t[5]=d):d=t[5];let f;t[6]===n?f=t[7]:(f=H(n),t[6]=n,t[7]=f);let m;t[8]===f?m=t[9]:(m=(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[u,(0,B.jsxs)(`div`,{className:`text-xs text-(--amber-11) leading-relaxed`,children:[d,` `,(0,B.jsx)(`code`,{className:`font-mono`,children:f})]})]}),t[8]=f,t[9]=m);let h;t[10]===r?h=t[11]:(h=(0,B.jsx)(U,{input:r}),t[10]=r,t[11]=h);let g;t[12]!==i.id||t[13]!==a?(g=(0,B.jsx)(y,{size:`xs`,variant:`outline`,onClick:()=>a({id:i.id,approved:!1}),children:`Deny`}),t[12]=i.id,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==i.id||t[16]!==a?(_=(0,B.jsx)(y,{size:`xs`,onClick:()=>a({id:i.id,approved:!0}),children:`Approve`}),t[15]=i.id,t[16]=a,t[17]=_):_=t[17];let v;t[18]!==_||t[19]!==g?(v=(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[g,_]}),t[18]=_,t[19]=g,t[20]=v):v=t[20];let b;return t[21]!==s||t[22]!==v||t[23]!==l||t[24]!==m||t[25]!==h?(b=(0,B.jsxs)(`div`,{className:s,role:`alertdialog`,"aria-label":l,children:[m,h,v]}),t[21]=s,t[22]=v,t[23]=l,t[24]=m,t[25]=h,t[26]=b):b=t[26],b},G=e=>{let t=(0,R.c)(28),{toolName:n,input:r,errorText:a,isLive:o,className:s}=e,[c,l]=z.useState(o),u=z.useRef(o),d,f;t[0]===o?(d=t[1],f=t[2]):(d=()=>{u.current&&!o&&l(!1),u.current=o},f=[o],t[0]=o,t[1]=d,t[2]=f),z.useEffect(d,f);let m;t[3]===s?m=t[4]:(m=p(`rounded-md border border-(--red-6) bg-(--red-2)`,s),t[3]=s,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l(K),t[5]=h):h=t[5];let g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,B.jsx)(i,{className:`h-3.5 w-3.5 shrink-0`}),t[6]=g):g=t[6];let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,B.jsx)(`span`,{className:`font-semibold`,children:`Failed:`}),t[7]=_):_=t[7];let v;t[8]===n?v=t[9]:(v=H(n),t[8]=n,t[9]=v);let y;t[10]===v?y=t[11]:(y=(0,B.jsxs)(`span`,{className:`flex-1 text-left`,children:[_,` `,(0,B.jsx)(`code`,{className:`font-mono`,children:v})]}),t[10]=v,t[11]=y);let b=c&&`rotate-180`,x;t[12]===b?x=t[13]:(x=p(`h-3.5 w-3.5 shrink-0 transition-transform`,b),t[12]=b,t[13]=x);let S;t[14]===x?S=t[15]:(S=(0,B.jsx)(w,{className:x}),t[14]=x,t[15]=S);let C;t[16]!==c||t[17]!==S||t[18]!==y?(C=(0,B.jsxs)(`button`,{type:`button`,onClick:h,className:`w-full flex items-center gap-2 px-3 py-2 text-xs text-(--red-11) hover:bg-(--red-3) rounded-md transition-colors`,"aria-expanded":c,children:[g,y,S]}),t[16]=c,t[17]=S,t[18]=y,t[19]=C):C=t[19];let T;t[20]!==a||t[21]!==r||t[22]!==c?(T=c&&(0,B.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t border-(--red-6)/40 pt-3`,children:[(0,B.jsx)(U,{input:r}),a&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-(--red-11) mb-1`,children:`Error`}),(0,B.jsx)(`pre`,{className:`bg-(--red-2) border border-(--red-6) rounded p-2 text-xs text-(--red-11) leading-relaxed overflow-auto scrollbar-thin max-h-64 whitespace-pre-wrap`,children:a})]})]}),t[20]=a,t[21]=r,t[22]=c,t[23]=T):T=t[23];let E;return t[24]!==C||t[25]!==T||t[26]!==m?(E=(0,B.jsxs)(`div`,{className:m,children:[C,T]}),t[24]=C,t[25]=T,t[26]=m,t[27]=E):E=t[27],E};function K(e){return!e}function q(e){return e==null||typeof e==`object`&&u(e)}var J=s({status:a().default(`success`),auth_required:o().default(!1),action_url:c(),next_steps:c(),meta:c(),message:a().nullish()}),Y=e=>{let t=(0,R.c)(12),{data:n}=e,i;if(t[0]!==n){let{status:e,auth_required:a,action_url:o,meta:s,next_steps:c,message:l,...u}=n,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,B.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground`,children:`Tool Result`}),t[2]=d):d=t[2];let f;t[3]===e?f=t[4]:(f=(0,B.jsx)(`span`,{className:`text-xs px-2 py-0.5 bg-(--grass-2) text-(--grass-11) rounded-full font-medium capitalize`,children:e}),t[3]=e,t[4]=f);let p;t[5]===a?p=t[6]:(p=a&&(0,B.jsx)(`span`,{className:`text-xs px-2 py-0.5 bg-(--amber-2) text-(--amber-11) rounded-full`,children:`Auth Required`}),t[5]=a,t[6]=p);let m;t[7]!==f||t[8]!==p?(m=(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[d,(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f,p]})]}),t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===l?h=t[11]:(h=l&&(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(r,{className:`h-3 w-3 text-(--blue-11) mt-0.5 shrink-0`}),(0,B.jsx)(`div`,{className:`text-xs text-foreground`,children:l})]}),t[10]=l,t[11]=h),i=(0,B.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[m,h,u&&(0,B.jsx)(`div`,{className:`space-y-3`,children:Object.entries(u).map(Z)})]}),t[0]=n,t[1]=i}else i=t[1];return i},X=e=>{let t=(0,R.c)(8),{result:n}=e,r;t[0]===n?r=t[1]:(r=J.safeParse(n),t[0]=n,t[1]=r);let i=r;if(i.success){let e;return t[2]===i.data?e=t[3]:(e=(0,B.jsx)(Y,{data:i.data}),t[2]=i.data,t[3]=e),e}let a;t[4]===n?a=t[5]:(a=typeof n==`string`?n:JSON.stringify(n,null,2),t[4]=n,t[5]=a);let o;return t[6]===a?o=t[7]:(o=(0,B.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1 max-h-64 overflow-y-auto scrollbar-thin`,children:a}),t[6]=a,t[7]=o),o};function Z(e){let[t,n]=e;return q(n)?null:(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}),(0,B.jsx)(`pre`,{className:`bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64`,children:JSON.stringify(n,null,2)})]},t)}var ee={"input-streaming":`Generating`,"input-available":`Running`,"approval-responded":`Awaiting result`,"output-available":`Done`,"output-denied":`Denied`},te=new Set([`input-streaming`,`input-available`,`approval-responded`]),ne=e=>{let t=(0,R.c)(5),{state:n,interrupted:r}=e;if(r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(M,{className:`h-3 w-3 text-muted-foreground`}),t[0]=e):e=t[0],e}switch(n){case`input-streaming`:case`input-available`:case`approval-responded`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(k,{className:`h-3 w-3 animate-spin`}),t[1]=e):e=t[1],e}case`output-available`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(d,{className:`h-3 w-3 text-(--grass-11)`}),t[2]=e):e=t[2],e}case`output-denied`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(S,{className:`h-3 w-3 text-muted-foreground`}),t[3]=e):e=t[3],e}default:{b(n);let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,B.jsx)(A,{className:`h-3 w-3`}),t[4]=e):e=t[4],e}}};function re(e){switch(e){case`output-available`:return`text-(--grass-11)/80`;case`output-denied`:return`text-muted-foreground`;case`input-streaming`:case`input-available`:case`approval-responded`:return``;default:return b(e),``}}var Q=e=>{let t=(0,R.c)(34),{toolName:n,state:r,input:i,result:a,approval:o,index:s,className:c,isActive:l}=e,u=s===void 0?0:s,d=l===void 0||l,f;t[0]!==d||t[1]!==r?(f=!d&&te.has(r),t[0]=d,t[1]=r,t[2]=f):f=t[2];let m=f,y=`tool-${u}`,b;t[3]===c?b=t[4]:(b=p(`w-full`,c),t[3]=c,t[4]=b);let x;t[5]!==m||t[6]!==r?(x=p(`h-6 text-xs border-border shadow-none! ring-0! bg-muted/60 hover:bg-muted py-0 px-2 gap-1 rounded-sm [&[data-state=open]>svg]:rotate-180 hover:no-underline`,m?`text-muted-foreground`:re(r)),t[5]=m,t[6]=r,t[7]=x):x=t[7];let S;t[8]!==m||t[9]!==r?(S=(0,B.jsx)(ne,{state:r,interrupted:m}),t[8]=m,t[9]=r,t[10]=S):S=t[10];let C=m?`Interrupted`:ee[r],w;t[11]===n?w=t[12]:(w=H(n),t[11]=n,t[12]=w);let T;t[13]===w?T=t[14]:(T=(0,B.jsx)(`code`,{className:`font-mono text-xs`,children:w}),t[13]=w,t[14]=T);let E;t[15]!==T||t[16]!==S||t[17]!==C?(E=(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[S,C,`:`,T]}),t[15]=T,t[16]=S,t[17]=C,t[18]=E):E=t[18];let D;t[19]!==E||t[20]!==x?(D=(0,B.jsx)(_,{className:x,children:E}),t[19]=E,t[20]=x,t[21]=D):D=t[21];let O;t[22]!==o||t[23]!==i||t[24]!==a||t[25]!==r?(O=(0,B.jsx)(g,{className:`py-2 px-2`,children:(0,B.jsx)(ie,{state:r,input:i,result:a,approval:o})}),t[22]=o,t[23]=i,t[24]=a,t[25]=r,t[26]=O):O=t[26];let k;t[27]!==D||t[28]!==O?(k=(0,B.jsxs)(h,{value:`tool-call`,className:`border-0`,children:[D,O]}),t[27]=D,t[28]=O,t[29]=k):k=t[29];let A;return t[30]!==k||t[31]!==y||t[32]!==b?(A=(0,B.jsx)(v,{type:`single`,collapsible:!0,className:b,children:k},y),t[30]=k,t[31]=y,t[32]=b,t[33]=A):A=t[33],A},ie=e=>{let t=(0,R.c)(16),{state:n,input:r,result:i,approval:a}=e;switch(n){case`input-streaming`:case`input-available`:case`approval-responded`:{let e;return t[0]===r?e=t[1]:(e=(0,B.jsx)(U,{input:r}),t[0]=r,t[1]=e),e}case`output-available`:{let e;t[2]===r?e=t[3]:(e=(0,B.jsx)(U,{input:r}),t[2]=r,t[3]=e);let n;t[4]===i?n=t[5]:(n=i!=null&&(0,B.jsx)(X,{result:i}),t[4]=i,t[5]=n);let a;return t[6]!==e||t[7]!==n?(a=(0,B.jsxs)(`div`,{className:`space-y-3`,children:[e,n]}),t[6]=e,t[7]=n,t[8]=a):a=t[8],a}case`output-denied`:{let e;t[9]===r?e=t[10]:(e=(0,B.jsx)(U,{input:r}),t[9]=r,t[10]=e);let n=a?.reason?`: ${a.reason}`:`.`,i;t[11]===n?i=t[12]:(i=(0,B.jsxs)(`div`,{className:`bg-muted/40 border border-border rounded-md p-3 text-xs text-muted-foreground leading-relaxed`,children:[`Tool execution was denied`,n]}),t[11]=n,t[12]=i);let o;return t[13]!==e||t[14]!==i?(o=(0,B.jsxs)(`div`,{className:`space-y-3`,children:[e,i]}),t[13]=e,t[14]=i,t[15]=o):o=t[15],o}default:return b(n),null}},$=e=>{let t=(0,R.c)(27),{toolName:n,state:r,result:i,errorText:a,input:o,approval:s,onApprove:c,index:l,className:u,isLive:d,isActive:f}=e,p=d===void 0||d,m=f===void 0||f;switch(r){case`approval-requested`:{if(s!=null&&c!=null){let e;return t[0]!==s||t[1]!==u||t[2]!==o||t[3]!==c||t[4]!==n?(e=(0,B.jsx)(W,{toolName:n,input:o,approval:s,onApprove:c,className:u}),t[0]=s,t[1]=u,t[2]=o,t[3]=c,t[4]=n,t[5]=e):e=t[5],e}let e;return t[6]!==u||t[7]!==l||t[8]!==o||t[9]!==m||t[10]!==n?(e=(0,B.jsx)(Q,{toolName:n,state:`input-available`,input:o,index:l,className:u,isActive:m}),t[6]=u,t[7]=l,t[8]=o,t[9]=m,t[10]=n,t[11]=e):e=t[11],e}case`output-error`:{let e;return t[12]!==u||t[13]!==a||t[14]!==o||t[15]!==p||t[16]!==n?(e=(0,B.jsx)(G,{toolName:n,input:o,errorText:a,isLive:p,className:u}),t[12]=u,t[13]=a,t[14]=o,t[15]=p,t[16]=n,t[17]=e):e=t[17],e}case`input-streaming`:case`input-available`:case`approval-responded`:case`output-available`:case`output-denied`:{let e;return t[18]!==s||t[19]!==u||t[20]!==l||t[21]!==o||t[22]!==m||t[23]!==i||t[24]!==r||t[25]!==n?(e=(0,B.jsx)(Q,{toolName:n,state:r,input:o,result:i,approval:s,index:l,className:u,isActive:m}),t[18]=s,t[19]=u,t[20]=l,t[21]=o,t[22]=m,t[23]=i,t[24]=r,t[25]=n,t[26]=e):e=t[26],e}default:return b(r),null}},ae=({message:e,isStreamingReasoning:t,isLast:r,isActive:i,addToolApprovalResponse:a})=>{return(0,B.jsx)(B.Fragment,{children:e.parts.map((e,t)=>o(e,t))});function o(o,s){if(oe(o))return(0,B.jsx)($,{index:s,toolName:o.type,result:o.output,errorText:o.state===`output-error`?o.errorText:void 0,className:`my-2`,state:o.state,input:o.input,approval:o.approval,onApprove:a,isLive:r,isActive:i},s);if(se(o))return f.debug(`Found data part`,o),null;switch(o.type){case`text`:return o.text.includes(`<marimo-`)?(0,B.jsx)(z.Fragment,{children:j({html:o.text})},s):(0,B.jsx)(T,{content:o.text},s);case`reasoning`:return(0,B.jsx)(V,{reasoning:o.text,index:s,isStreaming:t&&r&&s===(e.parts.length||0)-1},s);case`file`:return(0,B.jsx)(D,{attachment:o},s);case`reasoning-file`:return(0,B.jsx)(D,{attachment:{type:`file`,mediaType:o.mediaType,url:o.url}},s);case`dynamic-tool`:return(0,B.jsx)($,{toolName:o.toolName,result:o.output,errorText:o.state===`output-error`?o.errorText:void 0,state:o.state,input:o.input,approval:o.approval,onApprove:a,isLive:r,isActive:i},s);case`source-document`:return(0,B.jsx)(E,{icon:(0,B.jsx)(n,{className:`h-3 w-3 shrink-0`}),title:o.title,subtitle:o.filename},s);case`source-url`:return(0,B.jsx)(E,{icon:(0,B.jsx)(O,{className:`h-3 w-3 shrink-0`}),title:o.title??o.url,subtitle:o.title?o.url:void 0,href:o.url},s);case`custom`:return(0,B.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:o.kind},s);case`step-start`:return null;default:return b(o),null}}};function oe(e){return e.type.startsWith(`tool-`)}function se(e){return e.type.startsWith(`data-`)}export{I as i,L as n,F as r,ae as t};
|