@marimo-team/frontend 0.23.10-dev3 → 0.23.10-dev5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/assets/{CellStatus-D_RReCKN.js → CellStatus-CYdgIFLB.js} +1 -1
  2. package/dist/assets/{JsonOutput-40Fp2jEG.js → JsonOutput-fyYubT1B.js} +1 -1
  3. package/dist/assets/{MarimoErrorOutput-HYZo17DD.js → MarimoErrorOutput-DYkyRvbE.js} +1 -1
  4. package/dist/assets/{RenderHTML-B_YU1hMw.js → RenderHTML-CGw415hl.js} +1 -1
  5. package/dist/assets/{add-cell-with-ai-QmkSVxE_.js → add-cell-with-ai-0svqc926.js} +1 -1
  6. package/dist/assets/{add-connection-dialog-C_d6NoB6.js → add-connection-dialog-CjYufci_.js} +1 -1
  7. package/dist/assets/{agent-panel-Dq-14MP2.js → agent-panel-BBoTLbrd.js} +1 -1
  8. package/dist/assets/{ai-model-dropdown-BZsz2gBj.js → ai-model-dropdown-CW_Zz-J1.js} +1 -1
  9. package/dist/assets/{app-config-button-DrjQAYDI.js → app-config-button-CoN5u2Ul.js} +1 -1
  10. package/dist/assets/{cell-editor-BnxVODbx.js → cell-editor-DojmelXc.js} +1 -1
  11. package/dist/assets/{cell-link-Gwsf-bMV.js → cell-link-xJoNOwtA.js} +1 -1
  12. package/dist/assets/{cells-BRMYB7Wo.js → cells-BFTdVtl5.js} +2 -2
  13. package/dist/assets/{chat-display-DG6DhHcQ.js → chat-display-g-2nC0vU.js} +1 -1
  14. package/dist/assets/{chat-panel-BvrrOl8J.js → chat-panel-Cn7x98vj.js} +1 -1
  15. package/dist/assets/{chat-ui-g5FqhPv-.js → chat-ui-CnZAV2rN.js} +1 -1
  16. package/dist/assets/{column-preview-Bd7jDAiw.js → column-preview-COP8lRZk.js} +1 -1
  17. package/dist/assets/{command-palette-NK5d8oXe.js → command-palette-BA7lhXiO.js} +1 -1
  18. package/dist/assets/{common-uMN7vCPi.js → common-BrAxXgQC.js} +1 -1
  19. package/dist/assets/{components-C6xgQdpy.js → components-CG3Cj6Hm.js} +1 -1
  20. package/dist/assets/{components-C_z0Dsug.js → components-zJe4_t36.js} +1 -1
  21. package/dist/assets/{datasource-CHSjxFZg.js → datasource-BEIQWqLs.js} +1 -1
  22. package/dist/assets/{dependency-graph-panel-BmJ-hPrs.js → dependency-graph-panel-CTF_du1u.js} +1 -1
  23. package/dist/assets/{documentation-panel-6ZJIjjrY.js → documentation-panel-B1BuNN6c.js} +1 -1
  24. package/dist/assets/{download-cs3tezQD.js → download-DwObWxor.js} +1 -1
  25. package/dist/assets/{edit-page-DBwRiakc.js → edit-page-DGDyeOQj.js} +6 -6
  26. package/dist/assets/{error-panel-BAL4mIVv.js → error-panel-BlGh1rbR.js} +1 -1
  27. package/dist/assets/{file-explorer-panel-B6UWw04X.js → file-explorer-panel-PX5ccow0.js} +1 -1
  28. package/dist/assets/{file-icons-CNegz5Wt.js → file-icons-BqkEAg4n.js} +1 -1
  29. package/dist/assets/{floating-outline-C_E8vH7G.js → floating-outline-DQaphys-.js} +1 -1
  30. package/dist/assets/{focus-B2t0WTxH.js → focus-Ch00G7oo.js} +1 -1
  31. package/dist/assets/{form-BnFjtYoC.js → form-mMtSITO5.js} +1 -1
  32. package/dist/assets/{home-page-5euYDrSb.js → home-page-CxDyzbWl.js} +1 -1
  33. package/dist/assets/{hooks-DTSuaBec.js → hooks-L_sAIP6F.js} +1 -1
  34. package/dist/assets/{html-to-image-GGmvROsd.js → html-to-image-DWnBdIxw.js} +1 -1
  35. package/dist/assets/{index-DIc0rD1S.js → index-v6_0iwpH.js} +3 -3
  36. package/dist/assets/{kiosk-mode-Di1lkQq9.js → kiosk-mode-CR4aMKFR.js} +1 -1
  37. package/dist/assets/{layout-Bco8l-YP.js → layout-CWSuYt_k.js} +3 -3
  38. package/dist/assets/{logs-panel-CaW-dsNY.js → logs-panel-DHNBqQ8N.js} +1 -1
  39. package/dist/assets/{markdown-renderer-CHlWY8PG.js → markdown-renderer-DMWX12-G.js} +1 -1
  40. package/dist/assets/{name-cell-input-DUOo0eNf.js → name-cell-input-pKRmiljn.js} +1 -1
  41. package/dist/assets/{outline-panel-BOHhothv.js → outline-panel-CXAxQcpY.js} +1 -1
  42. package/dist/assets/{packages-panel-4nEohRPp.js → packages-panel-BRcB12VO.js} +1 -1
  43. package/dist/assets/{panels-BAdoiY2Y.js → panels-Cv7CSW_P.js} +1 -1
  44. package/dist/assets/{process-output-ClRYUndH.js → process-output-EPCivWmT.js} +1 -1
  45. package/dist/assets/{radio-group-DcUXH-59.js → radio-group-Cc9ma3vN.js} +1 -1
  46. package/dist/assets/{readonly-python-code-D6Ca_8n6.js → readonly-python-code-CT0pldK0.js} +1 -1
  47. package/dist/assets/{reveal-component-ComuCTva.js → reveal-component-kUnpLz_A.js} +1 -1
  48. package/dist/assets/{run-page-iIqjPtCe.js → run-page-BxAIWn9o.js} +1 -1
  49. package/dist/assets/{scratchpad-panel-rClgbzFO.js → scratchpad-panel-X-aqmMyS.js} +1 -1
  50. package/dist/assets/{session-panel-DSNfdRG3.js → session-panel-nN6IIBbv.js} +1 -1
  51. package/dist/assets/{snippets-panel-CUFYazvB.js → snippets-panel-D8UsweT7.js} +1 -1
  52. package/dist/assets/{state-BZoBW9cM.js → state-0417Fmr2.js} +1 -1
  53. package/dist/assets/{state-CRuZ8deV.js → state-BXPk8FBd.js} +1 -1
  54. package/dist/assets/{textarea-0Z0sU8Go.js → textarea-DoNsOWV-.js} +1 -1
  55. package/dist/assets/{tracing-Drwmt2bI.js → tracing-CWyDDU1B.js} +1 -1
  56. package/dist/assets/{tracing-panel-Bk-q3YTu.js → tracing-panel-AxeMvTw4.js} +2 -2
  57. package/dist/assets/{useCellActionButton-DARfBbL-.js → useCellActionButton-CQpJErdb.js} +1 -1
  58. package/dist/assets/{useDeleteCell-l5BAp1WU.js → useDeleteCell-Cy9toFWY.js} +1 -1
  59. package/dist/assets/{useDependencyPanelTab-CP0s5K4d.js → useDependencyPanelTab-DIKqX7lF.js} +1 -1
  60. package/dist/assets/{useNotebookActions-DFkPMDea.js → useNotebookActions-aNrwsrEq.js} +1 -1
  61. package/dist/assets/{useRunCells-2n74L4TT.js → useRunCells-D8uIzoGA.js} +1 -1
  62. package/dist/assets/{useSplitCell-CLVd_9hM.js → useSplitCell-BL2KIR3W.js} +1 -1
  63. package/dist/index.html +22 -22
  64. package/package.json +1 -1
  65. package/src/components/editor/cell/cell-context-menu.tsx +15 -2
  66. package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -28
  67. package/src/core/cells/__tests__/cell.test.ts +29 -2
  68. package/src/core/cells/cell.ts +5 -1
  69. package/src/core/codemirror/go-to-definition/commands.ts +4 -3
@@ -1 +1 @@
1
- import{s as z}from"./chunk-LvLJmgfZ.js";import{l as X}from"./useEvent-D91BmmQi.js";import{t as Z}from"./react-Bj1aDYRI.js";import{Bt as I}from"./cells-BRMYB7Wo.js";import{t as H}from"./compiler-runtime-B3qBwwSJ.js";import{S as $,c as ee,i as te,l as se,n as le,u as ae}from"./ai-model-dropdown-BZsz2gBj.js";import{E as B,T as oe,b as ne}from"./utils-CvI-39U6.js";import{T as re}from"./config-ClMcu_sV.js";import{t as ie}from"./jsx-runtime-BqBOg78p.js";import{o as ce}from"./alert-dialog-BqFLkbUc.js";import{i as de,r as he,t as me}from"./popover-Bz_0Vkyf.js";import{l as Q}from"./select-DZcFyKFQ.js";import{t as R}from"./tooltip-DTV9tlSr.js";import{t as xe}from"./button-BbCh-29a.js";import{s as U}from"./arrays-DYDL-3-i.js";import{r as Y}from"./requests-DIwGYs0l.js";import{t as pe}from"./createLucideIcon-D5guW7EU.js";import{t as fe}from"./x-C-6liIBr.js";import{r as D}from"./input-C3Hrdlqq.js";import{t as K}from"./settings-DfFe0dWD.js";import{a as M,c as A,d as L,g as ue,i as je,l as E,o as P,p as ve,u as S}from"./textarea-0Z0sU8Go.js";import{t as ge}from"./use-toast-IPAtJGea.js";import{i as be}from"./RSPContexts-CdN1NyAt.js";import{n as we}from"./useDebounce-7xZwVnnu.js";import{c as ye,l as Ne,n as Ce,t as V}from"./dialog-DzC_QCtT.js";import{n as ke}from"./ImperativeModal-B3Th7k4R.js";import{t as O}from"./kbd-CTUAEnEx.js";import{t as _e}from"./links-D1JoyKTt.js";import{t as G}from"./Inputs-C6ftxLAJ.js";var Se=pe("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"}]]),Te=H(),s=z(ie(),1);const Me=t=>{let e=(0,Te.c)(15),{description:a,disabled:f,tooltip:r}=t,i=f===void 0?!1:f,u=r===void 0?"Shutdown":r,{openConfirm:b,closeModal:l}=ke(),{sendShutdown:o}=Y(),w;e[0]===o?w=e[1]:(w=()=>{o(),setTimeout(Ae,200)},e[0]=o,e[1]=w);let j=w;if(re())return null;let m=i?"disabled":"red",c;e[2]!==l||e[3]!==a||e[4]!==j||e[5]!==b?(c=h=>{h.stopPropagation(),b({title:"Shutdown",description:a,variant:"destructive",confirmAction:(0,s.jsx)(ce,{onClick:()=>{j(),l()},"aria-label":"Confirm Shutdown",children:"Shutdown"})})},e[2]=l,e[3]=a,e[4]=j,e[5]=b,e[6]=c):c=e[6];let n;e[7]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsx)(fe,{strokeWidth:1}),e[7]=n):n=e[7];let d;e[8]!==i||e[9]!==m||e[10]!==c?(d=(0,s.jsx)(G,{"aria-label":"Shutdown","data-testid":"shutdown-button",shape:"circle",size:"small",color:m,className:"h-[27px] w-[27px]",disabled:i,onClick:c,children:n}),e[8]=i,e[9]=m,e[10]=c,e[11]=d):d=e[11];let x;return e[12]!==d||e[13]!==u?(x=(0,s.jsx)(R,{content:u,children:d}),e[12]=d,e[13]=u,e[14]=x):x=e[14],x};function Ae(){window.close()}var J=H(),W=z(Z(),1),Le=100;const Ee=()=>{let t=(0,J.c)(37),[e,a]=ne(),{saveAppConfig:f}=Y(),r=(0,W.useId)(),i=(0,W.useId)(),u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=ve(oe),t[0]=u):u=t[0];let b;t[1]===e?b=t[2]:(b={resolver:u,defaultValues:e},t[1]=e,t[2]=b);let l=ue(b),o;t[3]!==f||t[4]!==a?(o=async p=>{await f({config:p}).then(()=>{a(p)}).catch(()=>{a(p)})},t[3]=f,t[4]=a,t[5]=o):o=t[5];let w=o,j;t[6]===w?j=t[7]:(j=p=>{w(p)},t[6]=w,t[7]=j);let m=we(j,Le),c;t[8]===e.width?c=t[9]:(c=[e.width],t[8]=e.width,t[9]=c),(0,W.useEffect)(Pe,c);let n;t[10]!==m||t[11]!==l?(n=l.handleSubmit(m),t[10]=m,t[11]=l,t[12]=n):n=t[12];let d;t[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)("div",{children:[(0,s.jsx)(ae,{children:"Notebook Settings"}),(0,s.jsx)(se,{children:"Configure how your notebook or application looks and behaves."})]}),t[13]=d):d=t[13];let x;t[14]===l.control?x=t[15]:(x=(0,s.jsxs)(F,{title:"Display",children:[(0,s.jsx)(A,{control:l.control,name:"width",render:Fe}),(0,s.jsx)(A,{control:l.control,name:"app_title",render:He})]}),t[14]=l.control,t[15]=x);let h;t[16]===l.control?h=t[17]:(h=(0,s.jsxs)(F,{title:"Custom Files",children:[(0,s.jsx)(A,{control:l.control,name:"css_file",render:De}),(0,s.jsx)(A,{control:l.control,name:"html_head_file",render:Oe})]}),t[16]=l.control,t[17]=h);let y;t[18]===l.control?y=t[19]:(y=(0,s.jsx)(F,{title:"Data",children:(0,s.jsx)(A,{control:l.control,name:"sql_output",render:ze})}),t[18]=l.control,t[19]=y);let N;t[20]!==r||t[21]!==i?(N=p=>{let{field:_}=p;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-col gap-2",children:[(0,s.jsx)(M,{children:(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(I,{id:r,"data-testid":"html-checkbox",checked:_.value.includes("html"),onCheckedChange:()=>{_.onChange(U(_.value,"html"))}}),(0,s.jsx)(S,{htmlFor:r,children:"HTML"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(I,{id:i,"data-testid":"ipynb-checkbox",checked:_.value.includes("ipynb"),onCheckedChange:()=>{_.onChange(U(_.value,"ipynb"))}}),(0,s.jsx)(S,{htmlFor:i,children:"IPYNB"})]})]})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named"," ",(0,s.jsx)(O,{className:"inline",children:"__marimo__"})," next to your notebook file."]})]})},t[20]=r,t[21]=i,t[22]=N):N=t[22];let v;t[23]!==l.control||t[24]!==N?(v=(0,s.jsx)(F,{title:"Exporting outputs",children:(0,s.jsx)(A,{control:l.control,name:"auto_download",render:N})}),t[23]=l.control,t[24]=N,t[25]=v):v=t[25];let C;t[26]!==v||t[27]!==x||t[28]!==h||t[29]!==y?(C=(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[x,h,y,v]}),t[26]=v,t[27]=x,t[28]=h,t[29]=y,t[30]=C):C=t[30];let g;t[31]!==C||t[32]!==n?(g=(0,s.jsxs)("form",{onChange:n,className:"flex flex-col gap-6",children:[d,C]}),t[31]=C,t[32]=n,t[33]=g):g=t[33];let k;return t[34]!==l||t[35]!==g?(k=(0,s.jsx)(je,{...l,children:g}),t[34]=l,t[35]=g,t[36]=k):k=t[36],k};var F=t=>{let e=(0,J.c)(5),{title:a,children:f}=t,r;e[0]===a?r=e[1]:(r=(0,s.jsx)("h3",{className:"text-base font-semibold mb-1",children:a}),e[0]=a,e[1]=r);let i;return e[2]!==f||e[3]!==r?(i=(0,s.jsxs)("div",{className:"flex flex-col gap-y-2",children:[r,f]}),e[2]=f,e[3]=r,e[4]=i):i=e[4],i};function Pe(){window.dispatchEvent(new Event("resize"))}function qe(t){return(0,s.jsx)("option",{value:t,children:t},t)}function Fe(t){let{field:e}=t;return(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"Width"}),(0,s.jsx)(M,{children:(0,s.jsx)(Q,{"data-testid":"app-width-select",onChange:a=>e.onChange(a.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:$().map(qe)})}),(0,s.jsx)(L,{})]})}function He(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"App title"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",onChange:a=>{e.onChange(a.target.value),B.safeParse(a.target.value).success&&(document.title=a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsx)(P,{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 De(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{className:"shrink-0",children:"Custom CSS"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",placeholder:"custom.css",onChange:a=>{e.onChange(a.target.value),B.safeParse(a.target.value).success&&(document.title=a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsx)(P,{children:"A filepath to a custom css file to be injected into the notebook."})]})}function Oe(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{className:"shrink-0",children:"HTML Head"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",placeholder:"head.html",onChange:a=>{e.onChange(a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["A filepath to an HTML file to be injected into the"," ",(0,s.jsx)(O,{className:"inline",children:"<head/>"})," section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts."]})]})}function We(t){return(0,s.jsx)("option",{value:t.value,children:t.label},t.value)}function ze(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"SQL Output Type"}),(0,s.jsx)(M,{children:(0,s.jsx)(Q,{"data-testid":"sql-output-select",onChange:a=>{e.onChange(a.target.value),ge({title:"Kernel Restart Required",description:"This change requires a kernel restart to take effect."})},value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:ee.map(We)})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["The Python type returned by a SQL cell. For best performance with large datasets, we recommend using"," ",(0,s.jsx)(O,{className:"inline",children:"native"}),". See the"," ",(0,s.jsx)(_e,{href:"https://docs.marimo.io/guides/working_with_data/sql",children:"SQL guide"})," ","for more information."]})]})}var Ie=H();const Be=t=>{let e=(0,Ie.c)(32),{showAppConfig:a,disabled:f,tooltip:r}=t,i=a===void 0?!0:a,u=f===void 0?!1:f,b=r===void 0?"Settings":r,[l,o]=X(le),w=u?"disabled":"hint-green",j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsx)(K,{strokeWidth:1.8}),e[0]=j):j=e[0];let m;e[1]===b?m=e[2]:(m=(0,s.jsx)(R,{content:b,children:j}),e[1]=b,e[2]=m);let c;e[3]!==u||e[4]!==w||e[5]!==m?(c=(0,s.jsx)(G,{"aria-label":"Config","data-testid":"app-config-button",shape:"circle",size:"small",className:"h-[27px] w-[27px]",disabled:u,color:w,children:m}),e[3]=u,e[4]=w,e[5]=m,e[6]=c):c=e[6];let n=c,d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)(Ce,{className:"w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0",children:[(0,s.jsx)(be,{children:(0,s.jsx)(ye,{children:"User settings"})}),(0,s.jsx)(te,{})]}),e[7]=d):d=e[7];let x=d;if(!i){let T;e[8]===n?T=e[9]:(T=(0,s.jsx)(Ne,{children:n}),e[8]=n,e[9]=T);let q;return e[10]!==o||e[11]!==l||e[12]!==T?(q=(0,s.jsxs)(V,{open:l,onOpenChange:o,children:[T,x]}),e[10]=o,e[11]=l,e[12]=T,e[13]=q):q=e[13],q}let h;e[14]===n?h=e[15]:(h=(0,s.jsx)(de,{asChild:!0,children:n}),e[14]=n,e[15]=h);let y,N;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Ee,{}),N=(0,s.jsx)("div",{className:"h-px bg-border my-2"}),e[16]=y,e[17]=N):(y=e[16],N=e[17]);let v;e[18]===o?v=e[19]:(v=()=>o(!0),e[18]=o,e[19]=v);let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=(0,s.jsx)(K,{strokeWidth:1.8,className:"w-4 h-4 mr-2"}),e[20]=C):C=e[20];let g;e[21]===v?g=e[22]:(g=(0,s.jsxs)(he,{className:"w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]",align:"end",side:"bottom",onFocusOutside:Qe,children:[y,N,(0,s.jsxs)(xe,{onClick:v,variant:"link",className:"px-0",children:[C,"User settings"]})]}),e[21]=v,e[22]=g);let k;e[23]!==g||e[24]!==h?(k=(0,s.jsxs)(me,{children:[h,g]}),e[23]=g,e[24]=h,e[25]=k):k=e[25];let p;e[26]!==o||e[27]!==l?(p=(0,s.jsx)(V,{open:l,onOpenChange:o,children:x}),e[26]=o,e[27]=l,e[28]=p):p=e[28];let _;return e[29]!==k||e[30]!==p?(_=(0,s.jsxs)(s.Fragment,{children:[k,p]}),e[29]=k,e[30]=p,e[31]=_):_=e[31],_};function Qe(t){return t.preventDefault()}export{Me as n,Se as r,Be as t};
1
+ import{s as z}from"./chunk-LvLJmgfZ.js";import{l as X}from"./useEvent-D91BmmQi.js";import{t as Z}from"./react-Bj1aDYRI.js";import{Bt as I}from"./cells-BFTdVtl5.js";import{t as H}from"./compiler-runtime-B3qBwwSJ.js";import{S as $,c as ee,i as te,l as se,n as le,u as ae}from"./ai-model-dropdown-CW_Zz-J1.js";import{E as B,T as oe,b as ne}from"./utils-CvI-39U6.js";import{T as re}from"./config-ClMcu_sV.js";import{t as ie}from"./jsx-runtime-BqBOg78p.js";import{o as ce}from"./alert-dialog-BqFLkbUc.js";import{i as de,r as he,t as me}from"./popover-Bz_0Vkyf.js";import{l as Q}from"./select-DZcFyKFQ.js";import{t as R}from"./tooltip-DTV9tlSr.js";import{t as xe}from"./button-BbCh-29a.js";import{s as U}from"./arrays-DYDL-3-i.js";import{r as Y}from"./requests-DIwGYs0l.js";import{t as pe}from"./createLucideIcon-D5guW7EU.js";import{t as fe}from"./x-C-6liIBr.js";import{r as D}from"./input-C3Hrdlqq.js";import{t as K}from"./settings-DfFe0dWD.js";import{a as M,c as A,d as L,g as ue,i as je,l as E,o as P,p as ve,u as S}from"./textarea-DoNsOWV-.js";import{t as ge}from"./use-toast-IPAtJGea.js";import{i as be}from"./RSPContexts-CdN1NyAt.js";import{n as we}from"./useDebounce-7xZwVnnu.js";import{c as ye,l as Ne,n as Ce,t as V}from"./dialog-DzC_QCtT.js";import{n as ke}from"./ImperativeModal-B3Th7k4R.js";import{t as O}from"./kbd-CTUAEnEx.js";import{t as _e}from"./links-D1JoyKTt.js";import{t as G}from"./Inputs-C6ftxLAJ.js";var Se=pe("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"}]]),Te=H(),s=z(ie(),1);const Me=t=>{let e=(0,Te.c)(15),{description:a,disabled:f,tooltip:r}=t,i=f===void 0?!1:f,u=r===void 0?"Shutdown":r,{openConfirm:b,closeModal:l}=ke(),{sendShutdown:o}=Y(),w;e[0]===o?w=e[1]:(w=()=>{o(),setTimeout(Ae,200)},e[0]=o,e[1]=w);let j=w;if(re())return null;let m=i?"disabled":"red",c;e[2]!==l||e[3]!==a||e[4]!==j||e[5]!==b?(c=h=>{h.stopPropagation(),b({title:"Shutdown",description:a,variant:"destructive",confirmAction:(0,s.jsx)(ce,{onClick:()=>{j(),l()},"aria-label":"Confirm Shutdown",children:"Shutdown"})})},e[2]=l,e[3]=a,e[4]=j,e[5]=b,e[6]=c):c=e[6];let n;e[7]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsx)(fe,{strokeWidth:1}),e[7]=n):n=e[7];let d;e[8]!==i||e[9]!==m||e[10]!==c?(d=(0,s.jsx)(G,{"aria-label":"Shutdown","data-testid":"shutdown-button",shape:"circle",size:"small",color:m,className:"h-[27px] w-[27px]",disabled:i,onClick:c,children:n}),e[8]=i,e[9]=m,e[10]=c,e[11]=d):d=e[11];let x;return e[12]!==d||e[13]!==u?(x=(0,s.jsx)(R,{content:u,children:d}),e[12]=d,e[13]=u,e[14]=x):x=e[14],x};function Ae(){window.close()}var J=H(),W=z(Z(),1),Le=100;const Ee=()=>{let t=(0,J.c)(37),[e,a]=ne(),{saveAppConfig:f}=Y(),r=(0,W.useId)(),i=(0,W.useId)(),u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=ve(oe),t[0]=u):u=t[0];let b;t[1]===e?b=t[2]:(b={resolver:u,defaultValues:e},t[1]=e,t[2]=b);let l=ue(b),o;t[3]!==f||t[4]!==a?(o=async p=>{await f({config:p}).then(()=>{a(p)}).catch(()=>{a(p)})},t[3]=f,t[4]=a,t[5]=o):o=t[5];let w=o,j;t[6]===w?j=t[7]:(j=p=>{w(p)},t[6]=w,t[7]=j);let m=we(j,Le),c;t[8]===e.width?c=t[9]:(c=[e.width],t[8]=e.width,t[9]=c),(0,W.useEffect)(Pe,c);let n;t[10]!==m||t[11]!==l?(n=l.handleSubmit(m),t[10]=m,t[11]=l,t[12]=n):n=t[12];let d;t[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)("div",{children:[(0,s.jsx)(ae,{children:"Notebook Settings"}),(0,s.jsx)(se,{children:"Configure how your notebook or application looks and behaves."})]}),t[13]=d):d=t[13];let x;t[14]===l.control?x=t[15]:(x=(0,s.jsxs)(F,{title:"Display",children:[(0,s.jsx)(A,{control:l.control,name:"width",render:Fe}),(0,s.jsx)(A,{control:l.control,name:"app_title",render:He})]}),t[14]=l.control,t[15]=x);let h;t[16]===l.control?h=t[17]:(h=(0,s.jsxs)(F,{title:"Custom Files",children:[(0,s.jsx)(A,{control:l.control,name:"css_file",render:De}),(0,s.jsx)(A,{control:l.control,name:"html_head_file",render:Oe})]}),t[16]=l.control,t[17]=h);let y;t[18]===l.control?y=t[19]:(y=(0,s.jsx)(F,{title:"Data",children:(0,s.jsx)(A,{control:l.control,name:"sql_output",render:ze})}),t[18]=l.control,t[19]=y);let N;t[20]!==r||t[21]!==i?(N=p=>{let{field:_}=p;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-col gap-2",children:[(0,s.jsx)(M,{children:(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(I,{id:r,"data-testid":"html-checkbox",checked:_.value.includes("html"),onCheckedChange:()=>{_.onChange(U(_.value,"html"))}}),(0,s.jsx)(S,{htmlFor:r,children:"HTML"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(I,{id:i,"data-testid":"ipynb-checkbox",checked:_.value.includes("ipynb"),onCheckedChange:()=>{_.onChange(U(_.value,"ipynb"))}}),(0,s.jsx)(S,{htmlFor:i,children:"IPYNB"})]})]})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named"," ",(0,s.jsx)(O,{className:"inline",children:"__marimo__"})," next to your notebook file."]})]})},t[20]=r,t[21]=i,t[22]=N):N=t[22];let v;t[23]!==l.control||t[24]!==N?(v=(0,s.jsx)(F,{title:"Exporting outputs",children:(0,s.jsx)(A,{control:l.control,name:"auto_download",render:N})}),t[23]=l.control,t[24]=N,t[25]=v):v=t[25];let C;t[26]!==v||t[27]!==x||t[28]!==h||t[29]!==y?(C=(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[x,h,y,v]}),t[26]=v,t[27]=x,t[28]=h,t[29]=y,t[30]=C):C=t[30];let g;t[31]!==C||t[32]!==n?(g=(0,s.jsxs)("form",{onChange:n,className:"flex flex-col gap-6",children:[d,C]}),t[31]=C,t[32]=n,t[33]=g):g=t[33];let k;return t[34]!==l||t[35]!==g?(k=(0,s.jsx)(je,{...l,children:g}),t[34]=l,t[35]=g,t[36]=k):k=t[36],k};var F=t=>{let e=(0,J.c)(5),{title:a,children:f}=t,r;e[0]===a?r=e[1]:(r=(0,s.jsx)("h3",{className:"text-base font-semibold mb-1",children:a}),e[0]=a,e[1]=r);let i;return e[2]!==f||e[3]!==r?(i=(0,s.jsxs)("div",{className:"flex flex-col gap-y-2",children:[r,f]}),e[2]=f,e[3]=r,e[4]=i):i=e[4],i};function Pe(){window.dispatchEvent(new Event("resize"))}function qe(t){return(0,s.jsx)("option",{value:t,children:t},t)}function Fe(t){let{field:e}=t;return(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"Width"}),(0,s.jsx)(M,{children:(0,s.jsx)(Q,{"data-testid":"app-width-select",onChange:a=>e.onChange(a.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:$().map(qe)})}),(0,s.jsx)(L,{})]})}function He(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"App title"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",onChange:a=>{e.onChange(a.target.value),B.safeParse(a.target.value).success&&(document.title=a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsx)(P,{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 De(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{className:"shrink-0",children:"Custom CSS"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",placeholder:"custom.css",onChange:a=>{e.onChange(a.target.value),B.safeParse(a.target.value).success&&(document.title=a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsx)(P,{children:"A filepath to a custom css file to be injected into the notebook."})]})}function Oe(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{className:"shrink-0",children:"HTML Head"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",placeholder:"head.html",onChange:a=>{e.onChange(a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["A filepath to an HTML file to be injected into the"," ",(0,s.jsx)(O,{className:"inline",children:"<head/>"})," section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts."]})]})}function We(t){return(0,s.jsx)("option",{value:t.value,children:t.label},t.value)}function ze(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"SQL Output Type"}),(0,s.jsx)(M,{children:(0,s.jsx)(Q,{"data-testid":"sql-output-select",onChange:a=>{e.onChange(a.target.value),ge({title:"Kernel Restart Required",description:"This change requires a kernel restart to take effect."})},value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:ee.map(We)})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["The Python type returned by a SQL cell. For best performance with large datasets, we recommend using"," ",(0,s.jsx)(O,{className:"inline",children:"native"}),". See the"," ",(0,s.jsx)(_e,{href:"https://docs.marimo.io/guides/working_with_data/sql",children:"SQL guide"})," ","for more information."]})]})}var Ie=H();const Be=t=>{let e=(0,Ie.c)(32),{showAppConfig:a,disabled:f,tooltip:r}=t,i=a===void 0?!0:a,u=f===void 0?!1:f,b=r===void 0?"Settings":r,[l,o]=X(le),w=u?"disabled":"hint-green",j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsx)(K,{strokeWidth:1.8}),e[0]=j):j=e[0];let m;e[1]===b?m=e[2]:(m=(0,s.jsx)(R,{content:b,children:j}),e[1]=b,e[2]=m);let c;e[3]!==u||e[4]!==w||e[5]!==m?(c=(0,s.jsx)(G,{"aria-label":"Config","data-testid":"app-config-button",shape:"circle",size:"small",className:"h-[27px] w-[27px]",disabled:u,color:w,children:m}),e[3]=u,e[4]=w,e[5]=m,e[6]=c):c=e[6];let n=c,d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)(Ce,{className:"w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0",children:[(0,s.jsx)(be,{children:(0,s.jsx)(ye,{children:"User settings"})}),(0,s.jsx)(te,{})]}),e[7]=d):d=e[7];let x=d;if(!i){let T;e[8]===n?T=e[9]:(T=(0,s.jsx)(Ne,{children:n}),e[8]=n,e[9]=T);let q;return e[10]!==o||e[11]!==l||e[12]!==T?(q=(0,s.jsxs)(V,{open:l,onOpenChange:o,children:[T,x]}),e[10]=o,e[11]=l,e[12]=T,e[13]=q):q=e[13],q}let h;e[14]===n?h=e[15]:(h=(0,s.jsx)(de,{asChild:!0,children:n}),e[14]=n,e[15]=h);let y,N;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Ee,{}),N=(0,s.jsx)("div",{className:"h-px bg-border my-2"}),e[16]=y,e[17]=N):(y=e[16],N=e[17]);let v;e[18]===o?v=e[19]:(v=()=>o(!0),e[18]=o,e[19]=v);let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=(0,s.jsx)(K,{strokeWidth:1.8,className:"w-4 h-4 mr-2"}),e[20]=C):C=e[20];let g;e[21]===v?g=e[22]:(g=(0,s.jsxs)(he,{className:"w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]",align:"end",side:"bottom",onFocusOutside:Qe,children:[y,N,(0,s.jsxs)(xe,{onClick:v,variant:"link",className:"px-0",children:[C,"User settings"]})]}),e[21]=v,e[22]=g);let k;e[23]!==g||e[24]!==h?(k=(0,s.jsxs)(me,{children:[h,g]}),e[23]=g,e[24]=h,e[25]=k):k=e[25];let p;e[26]!==o||e[27]!==l?(p=(0,s.jsx)(V,{open:l,onOpenChange:o,children:x}),e[26]=o,e[27]=l,e[28]=p):p=e[28];let _;return e[29]!==k||e[30]!==p?(_=(0,s.jsxs)(s.Fragment,{children:[k,p]}),e[29]=k,e[30]=p,e[31]=_):_=e[31],_};function Qe(t){return t.preventDefault()}export{Me as n,Se as r,Be as t};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./loro_wasm_bg-CtNTubKN.js","./loro_wasm_bg-CXnd80ne.js","./chunk-LvLJmgfZ.js"])))=>i.map(i=>d[i]);
2
- var fd=Object.defineProperty;var Ba=Q=>{throw TypeError(Q)};var md=(Q,H,ye)=>H in Q?fd(Q,H,{enumerable:!0,configurable:!0,writable:!0,value:ye}):Q[H]=ye;var p=(Q,H,ye)=>md(Q,typeof H!="symbol"?H+"":H,ye),pd=(Q,H,ye)=>H.has(Q)||Ba("Cannot "+ye);var Pa=(Q,H,ye)=>(pd(Q,H,"read from private field"),ye?ye.call(Q):H.get(Q)),ja=(Q,H,ye)=>H.has(Q)?Ba("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(Q):H.set(Q,ye);import{s as Ma}from"./chunk-LvLJmgfZ.js";import{d as Ra,f as wr,i as Y,l as kn,n as ae,p as Ut,s as Cn,u as ie}from"./useEvent-D91BmmQi.js";import{t as gd}from"./react-Bj1aDYRI.js";import{$r as vr,$t as Ga,Bn as hd,Bt as bd,Ct as yd,D as Sn,Di as wd,Dt as vd,Et as xn,Gn as Ed,Gr as Nd,H as kd,Hn as Ja,I as Cd,Ii as In,Jn as Sd,Jt as xd,K as Wa,Mn as Id,Mt as Ad,Ot as Td,Qn as Fd,Qt as Er,Rn as Ld,Sn as Od,Tn as Nr,U as Va,Un as _d,V as $a,Vt as Ha,W as qa,Wn as Dd,Yt as kr,a as za,at as Ud,b as rt,bn as Bd,d as Ka,en as Ya,h as Bt,hn as Pd,ht as jd,in as Md,kt as Pt,mt as Cr,ni as Rd,nn as Gd,oi as Jd,qn as Wd,rn as Vd,si as Xa,sn as An,st as $d,ti as Hd,u as Qa,un as qd,vn as zd,wi as Za,wt as Sr,xn as Kd,yr as Yd,zn as Xd,__tla as Qd}from"./cells-BRMYB7Wo.js";import{B as Zd,N as ef,P as xr,R as ei,S as tf,T as ti,k as nf,w as rf}from"./zod-H_cgTO0M.js";import{t as We}from"./compiler-runtime-B3qBwwSJ.js";import{C as of,f as af,m as sf,p as lf,t as cf,v as uf,w as df}from"./ai-model-dropdown-BZsz2gBj.js";import{_ as Ve,c as ni,h as Ir,t as ff,v as mf}from"./useEventListener-DvoEXWke.js";import{t as jt}from"./invariant-BUdrueMv.js";import{_ as ri,c as pf,g as oi,h as ai,l as ii,w as Ar}from"./utils-CvI-39U6.js";import{S as si,T as gf,m as hf,o as bf,r as li,v as yt,w as Mt}from"./config-ClMcu_sV.js";import{n as yf,t as wf}from"./switch-BiU_sAcn.js";import{n as vf}from"./globals-7JnRMGd4.js";import{t as Ef}from"./ErrorBoundary-DyYDV0HI.js";import{t as ct}from"./cn-DCUzRj2J.js";import{t as Nf}from"./jsx-runtime-BqBOg78p.js";import{l as kf,r as Cf,t as Sf}from"./popover-Bz_0Vkyf.js";import{B as xf,__tla as If}from"./JsonOutput-40Fp2jEG.js";import{t as Tr}from"./label-xHqFtfdz.js";import{r as Af}from"./download-cs3tezQD.js";import{t as Tn}from"./tooltip-DTV9tlSr.js";import{r as Fr,t as ut}from"./button-BbCh-29a.js";import{Bt as wt,Ct as ci,Dt as Tf,E as Ff,Ft as Lr,H as ui,Ht as Rt,I as Lf,J as l,Jt as he,Kt as Of,Lt as Fn,Mt as _f,P as Df,St as $e,V as di,Vt as Or,Wt as dt,Yt as Ye,Zt as Gt,_ as Uf,a as Bf,at as R,bt as Pf,ct as Ze,en as Ln,ft as jf,it as Mf,lt as On,m as Rf,pt as Gf,rt as $,st as Jf,vt as Wf,w as Vf,wt as $f,yt as Hf,zt as qf}from"./dist-BrR4M-k3.js";import{E as zf,P as Kf,S as Yf,a as Xf,b as Qf,c as Zf,n as _r,r as em,w as tm,x as nm}from"./dist-CHcznzB-.js";import{o as fi}from"./arrays-DYDL-3-i.js";import{n as rm}from"./once-DRroIaBz.js";import{t as Dr}from"./createReducer-CI9qeK_X.js";import{a as om,c as am,f as _n,h as im,i as sm,l as Jt,n as mi,o as lm,t as cm}from"./dist-HlsDto3K.js";import{t as um}from"./main-B0OX4z33.js";import{r as Dn,t as dm}from"./requests-DIwGYs0l.js";import{t as fm}from"./createLucideIcon-D5guW7EU.js";import{r as pi,t as mm,__tla as pm}from"./layout-Bco8l-YP.js";import{t as gm}from"./x-C-6liIBr.js";import{t as hm}from"./circle-check-C17zXg7L.js";import{D as gi,E as bm,S as ym,a as hi,d as wm,j as vm,k as Em,n as Nm,o as km,r as bi,s as Cm}from"./add-cell-with-ai-QmkSVxE_.js";import{r as Sm,t as xm}from"./file-icons-CNegz5Wt.js";import{n as Im}from"./spinner-Bhir8k53.js";import{t as yi}from"./save-Clg5dMoP.js";import{Y as Am,Z as wi}from"./input-C3Hrdlqq.js";import{t as Tm}from"./sparkles-lWUAsPhp.js";import{t as Fm}from"./preload-helper-BPPi7vOr.js";import{t as vt}from"./use-toast-IPAtJGea.js";import{n as et}from"./paths-D5zczhUD.js";import{t as Lm}from"./session-0B5NBztP.js";import{r as Om}from"./useTheme-CI2eq4XN.js";import{n as vi}from"./copy-LK56fFow.js";import{k as _m}from"./usePress-DQ_tAz5W.js";import{a as Dm}from"./useRunCells-2n74L4TT.js";import{c as Ei,i as Ni,n as ki,r as Um}from"./dialog-DzC_QCtT.js";import{t as Ci}from"./useHotkey-TKvjHf1m.js";import{n as Si}from"./ImperativeModal-B3Th7k4R.js";import{r as Bm}from"./errors-vr57w7Ul.js";import{t as z}from"./extends-BiFDv3jB.js";import{t as Wt}from"./objectWithoutPropertiesLoose-DfWeGRFv.js";import{t as Pm}from"./kbd-CTUAEnEx.js";import{a as Ur}from"./useInstallPackage-DUF4IRRI.js";import{i as jm,n as xi}from"./state-BZoBW9cM.js";import{a as Mm,o as Rm}from"./cell-link-Gwsf-bMV.js";import{r as Ii}from"./html-to-image-GGmvROsd.js";import{a as Gm}from"./focus-B2t0WTxH.js";import{n as Jm}from"./useAsyncData-bgszE9F0.js";import{a as Wm,o as Ai,r as Vm,s as Ti,t as $m}from"./command-KARR7KMq.js";import{a as Fi}from"./renderShortcut-CcFk3m01.js";import{n as Hm,t as qm}from"./icons-Ol38nIbL.js";import{n as Et}from"./esm-CqWdmSnV.js";import{t as Li}from"./dist-4ni0fia5.js";import{n as Br,t as Oi}from"./useDeleteCell-l5BAp1WU.js";import{t as zm}from"./useSplitCell-CLVd_9hM.js";import{co as Km,do as Pr,fo as Ym,ft as Xm,go as Nt,ho as _i,lo as jr,mo as Di,oo as Qm,po as Zm,so as Ui,uo as Bi,__tla as ep}from"./loro_wasm_bg-CXnd80ne.js";import{t as tp}from"./ws-BnE9sl8z.js";import{t as Pi}from"./Inputs-C6ftxLAJ.js";import{n as np}from"./hooks-DTSuaBec.js";let Un,Mr,ji,Rr,ft,Gr,ve,Vt,$t,Mi,Ri,Gi,Ji,Wi,Bn,Vi,Pn,$i,jn,rp=Promise.all([(()=>{try{return Qd}catch{}})(),(()=>{try{return If}catch{}})(),(()=>{try{return pm}catch{}})(),(()=>{try{return ep}catch{}})()]).then(async()=>{var Nn,Ua,Ne,ke,Ce,Se,xe,Ie,Ae,Te,Fe,Le,Oe,_e,De,Ue,Be,Pe,je,Me,Re;var Q=fm("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"}]]);const H={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"};var ye=300;const Ct=Rt.define({combine:e=>Ln(e,{onError:console.error,inputDebounceTime:ye,keymaps:H},{onError:(t,n)=>t&&n,inputDebounceTime:(t,n)=>t&&n,keymaps:(t,n)=>t&&n})}),ot=he.define(),at=Ye.define({create(){return{show:!1,lineFrom:0,lineTo:0}},update(e,t){for(let n of t.effects)if(n.is(ot))return n.value;return e}}),St=he.define(),xt=he.define(),Wr=Ye.define({create(){return{shouldFocus:!1,inputValue:""}},update(e,t){let n=e;for(let r of t.effects)r.is(St)&&(n={...n,inputValue:r.value}),r.is(xt)&&(n={...n,shouldFocus:r.value});return n}}),Ht=he.define(),It=Ye.define({create(){return null},update(e,t){for(let n of t.effects)if(n.is(Ht))return n.value;return e}}),mt=he.define(),Vr=Ye.define({create(){return!1},update(e,t){for(let n of t.effects)if(n.is(mt))return n.value;return e}});var Hi=1;const $r=e=>{let{state:t}=e,n=t.selection.main;if(n.empty)return!1;let r=t.doc,o=r.lineAt(n.from),a=r.lineAt(n.to);if(t.sliceDoc(o.from,a.to).trim().length<Hi)return!1;let i=Math.max(1,Math.min(o.number,r.lines)),s=Math.max(1,Math.min(a.number,r.lines));return e.dispatch({effects:[ot.of({show:!0,lineFrom:i,lineTo:s}),xt.of(!0),St.of("")],selection:wt.cursor(o.from)}),!0},Hr=e=>e.state.field(It)?(e.dispatch({effects:[Ht.of(null),ot.of({show:!1,lineFrom:0,lineTo:0}),xt.of(!1),St.of(""),mt.of(!1)]}),!0):!1,qr=e=>{let t=e.state.field(It);return t?(e.dispatch({changes:{from:t.from,to:t.to,insert:t.oldCode},effects:[Ht.of(null),ot.of({show:!1,lineFrom:0,lineTo:0}),xt.of(!1),St.of(""),mt.of(!1)]}),!0):!1};var Mn={mac:"\u2318",windows:"\u229E Win",default:"Ctrl"};function qi(){return navigator.platform.startsWith("Mac")?Mn.mac:navigator.platform.startsWith("Win")?Mn.windows:Mn.default}function Rn(e){return e.replace("Mod",qi()).replace("-"," ").toUpperCase()}function pe(e,t){let n=document.createElement(e);return n.className=t,n}function zi(e,t,n=void 0){let r=()=>{};return(...o)=>(r(),new Promise((a,i)=>{let s=setTimeout(()=>a(e(...o)),t);r=()=>{clearTimeout(s),n!==void 0&&i(n)}}))}var qt=Ye.define({create(){return{suggestion:null}},update(e,t){let n=t.effects.find(r=>r.is(zt));return!t.docChanged&&!n&&!t.selection?e:n&&t.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),zt=he.define();function Ki(e,t){let n=e.state.selection.main.head,r=[],o=$.widget({widget:new Yi(t),side:1});return r.push(o.range(n)),$.set(r)}var Yi=class extends On{constructor(t){super();p(this,"suggestion");this.suggestion=t}toDOM(){let t=document.createElement("span");return t.style.opacity="0.4",t.className="cm-inline-suggestion",t.textContent=this.suggestion,t.setAttribute("role","suggestion"),t.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),t}get lineBreaks(){return this.suggestion.split(`
2
+ var fd=Object.defineProperty;var Ba=Q=>{throw TypeError(Q)};var md=(Q,H,ye)=>H in Q?fd(Q,H,{enumerable:!0,configurable:!0,writable:!0,value:ye}):Q[H]=ye;var p=(Q,H,ye)=>md(Q,typeof H!="symbol"?H+"":H,ye),pd=(Q,H,ye)=>H.has(Q)||Ba("Cannot "+ye);var Pa=(Q,H,ye)=>(pd(Q,H,"read from private field"),ye?ye.call(Q):H.get(Q)),ja=(Q,H,ye)=>H.has(Q)?Ba("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(Q):H.set(Q,ye);import{s as Ma}from"./chunk-LvLJmgfZ.js";import{d as Ra,f as wr,i as Y,l as kn,n as ae,p as Ut,s as Cn,u as ie}from"./useEvent-D91BmmQi.js";import{t as gd}from"./react-Bj1aDYRI.js";import{$r as vr,$t as Ga,Bn as hd,Bt as bd,Ct as yd,D as Sn,Di as wd,Dt as vd,Et as xn,Gn as Ed,Gr as Nd,H as kd,Hn as Ja,I as Cd,Ii as In,Jn as Sd,Jt as xd,K as Wa,Mn as Id,Mt as Ad,Ot as Td,Qn as Fd,Qt as Er,Rn as Ld,Sn as Od,Tn as Nr,U as Va,Un as _d,V as $a,Vt as Ha,W as qa,Wn as Dd,Yt as kr,a as za,at as Ud,b as rt,bn as Bd,d as Ka,en as Ya,h as Bt,hn as Pd,ht as jd,in as Md,kt as Pt,mt as Cr,ni as Rd,nn as Gd,oi as Jd,qn as Wd,rn as Vd,si as Xa,sn as An,st as $d,ti as Hd,u as Qa,un as qd,vn as zd,wi as Za,wt as Sr,xn as Kd,yr as Yd,zn as Xd,__tla as Qd}from"./cells-BFTdVtl5.js";import{B as Zd,N as ef,P as xr,R as ei,S as tf,T as ti,k as nf,w as rf}from"./zod-H_cgTO0M.js";import{t as We}from"./compiler-runtime-B3qBwwSJ.js";import{C as of,f as af,m as sf,p as lf,t as cf,v as uf,w as df}from"./ai-model-dropdown-CW_Zz-J1.js";import{_ as Ve,c as ni,h as Ir,t as ff,v as mf}from"./useEventListener-DvoEXWke.js";import{t as jt}from"./invariant-BUdrueMv.js";import{_ as ri,c as pf,g as oi,h as ai,l as ii,w as Ar}from"./utils-CvI-39U6.js";import{S as si,T as gf,m as hf,o as bf,r as li,v as yt,w as Mt}from"./config-ClMcu_sV.js";import{n as yf,t as wf}from"./switch-BiU_sAcn.js";import{n as vf}from"./globals-7JnRMGd4.js";import{t as Ef}from"./ErrorBoundary-DyYDV0HI.js";import{t as ct}from"./cn-DCUzRj2J.js";import{t as Nf}from"./jsx-runtime-BqBOg78p.js";import{l as kf,r as Cf,t as Sf}from"./popover-Bz_0Vkyf.js";import{B as xf,__tla as If}from"./JsonOutput-fyYubT1B.js";import{t as Tr}from"./label-xHqFtfdz.js";import{r as Af}from"./download-DwObWxor.js";import{t as Tn}from"./tooltip-DTV9tlSr.js";import{r as Fr,t as ut}from"./button-BbCh-29a.js";import{Bt as wt,Ct as ci,Dt as Tf,E as Ff,Ft as Lr,H as ui,Ht as Rt,I as Lf,J as l,Jt as he,Kt as Of,Lt as Fn,Mt as _f,P as Df,St as $e,V as di,Vt as Or,Wt as dt,Yt as Ye,Zt as Gt,_ as Uf,a as Bf,at as R,bt as Pf,ct as Ze,en as Ln,ft as jf,it as Mf,lt as On,m as Rf,pt as Gf,rt as $,st as Jf,vt as Wf,w as Vf,wt as $f,yt as Hf,zt as qf}from"./dist-BrR4M-k3.js";import{E as zf,P as Kf,S as Yf,a as Xf,b as Qf,c as Zf,n as _r,r as em,w as tm,x as nm}from"./dist-CHcznzB-.js";import{o as fi}from"./arrays-DYDL-3-i.js";import{n as rm}from"./once-DRroIaBz.js";import{t as Dr}from"./createReducer-CI9qeK_X.js";import{a as om,c as am,f as _n,h as im,i as sm,l as Jt,n as mi,o as lm,t as cm}from"./dist-HlsDto3K.js";import{t as um}from"./main-B0OX4z33.js";import{r as Dn,t as dm}from"./requests-DIwGYs0l.js";import{t as fm}from"./createLucideIcon-D5guW7EU.js";import{r as pi,t as mm,__tla as pm}from"./layout-CWSuYt_k.js";import{t as gm}from"./x-C-6liIBr.js";import{t as hm}from"./circle-check-C17zXg7L.js";import{D as gi,E as bm,S as ym,a as hi,d as wm,j as vm,k as Em,n as Nm,o as km,r as bi,s as Cm}from"./add-cell-with-ai-0svqc926.js";import{r as Sm,t as xm}from"./file-icons-BqkEAg4n.js";import{n as Im}from"./spinner-Bhir8k53.js";import{t as yi}from"./save-Clg5dMoP.js";import{Y as Am,Z as wi}from"./input-C3Hrdlqq.js";import{t as Tm}from"./sparkles-lWUAsPhp.js";import{t as Fm}from"./preload-helper-BPPi7vOr.js";import{t as vt}from"./use-toast-IPAtJGea.js";import{n as et}from"./paths-D5zczhUD.js";import{t as Lm}from"./session-0B5NBztP.js";import{r as Om}from"./useTheme-CI2eq4XN.js";import{n as vi}from"./copy-LK56fFow.js";import{k as _m}from"./usePress-DQ_tAz5W.js";import{a as Dm}from"./useRunCells-D8uIzoGA.js";import{c as Ei,i as Ni,n as ki,r as Um}from"./dialog-DzC_QCtT.js";import{t as Ci}from"./useHotkey-TKvjHf1m.js";import{n as Si}from"./ImperativeModal-B3Th7k4R.js";import{r as Bm}from"./errors-vr57w7Ul.js";import{t as z}from"./extends-BiFDv3jB.js";import{t as Wt}from"./objectWithoutPropertiesLoose-DfWeGRFv.js";import{t as Pm}from"./kbd-CTUAEnEx.js";import{a as Ur}from"./useInstallPackage-DUF4IRRI.js";import{i as jm,n as xi}from"./state-0417Fmr2.js";import{a as Mm,o as Rm}from"./cell-link-xJoNOwtA.js";import{r as Ii}from"./html-to-image-DWnBdIxw.js";import{a as Gm}from"./focus-Ch00G7oo.js";import{n as Jm}from"./useAsyncData-bgszE9F0.js";import{a as Wm,o as Ai,r as Vm,s as Ti,t as $m}from"./command-KARR7KMq.js";import{a as Fi}from"./renderShortcut-CcFk3m01.js";import{n as Hm,t as qm}from"./icons-Ol38nIbL.js";import{n as Et}from"./esm-CqWdmSnV.js";import{t as Li}from"./dist-4ni0fia5.js";import{n as Br,t as Oi}from"./useDeleteCell-Cy9toFWY.js";import{t as zm}from"./useSplitCell-BL2KIR3W.js";import{co as Km,do as Pr,fo as Ym,ft as Xm,go as Nt,ho as _i,lo as jr,mo as Di,oo as Qm,po as Zm,so as Ui,uo as Bi,__tla as ep}from"./loro_wasm_bg-CXnd80ne.js";import{t as tp}from"./ws-BnE9sl8z.js";import{t as Pi}from"./Inputs-C6ftxLAJ.js";import{n as np}from"./hooks-L_sAIP6F.js";let Un,Mr,ji,Rr,ft,Gr,ve,Vt,$t,Mi,Ri,Gi,Ji,Wi,Bn,Vi,Pn,$i,jn,rp=Promise.all([(()=>{try{return Qd}catch{}})(),(()=>{try{return If}catch{}})(),(()=>{try{return pm}catch{}})(),(()=>{try{return ep}catch{}})()]).then(async()=>{var Nn,Ua,Ne,ke,Ce,Se,xe,Ie,Ae,Te,Fe,Le,Oe,_e,De,Ue,Be,Pe,je,Me,Re;var Q=fm("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"}]]);const H={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"};var ye=300;const Ct=Rt.define({combine:e=>Ln(e,{onError:console.error,inputDebounceTime:ye,keymaps:H},{onError:(t,n)=>t&&n,inputDebounceTime:(t,n)=>t&&n,keymaps:(t,n)=>t&&n})}),ot=he.define(),at=Ye.define({create(){return{show:!1,lineFrom:0,lineTo:0}},update(e,t){for(let n of t.effects)if(n.is(ot))return n.value;return e}}),St=he.define(),xt=he.define(),Wr=Ye.define({create(){return{shouldFocus:!1,inputValue:""}},update(e,t){let n=e;for(let r of t.effects)r.is(St)&&(n={...n,inputValue:r.value}),r.is(xt)&&(n={...n,shouldFocus:r.value});return n}}),Ht=he.define(),It=Ye.define({create(){return null},update(e,t){for(let n of t.effects)if(n.is(Ht))return n.value;return e}}),mt=he.define(),Vr=Ye.define({create(){return!1},update(e,t){for(let n of t.effects)if(n.is(mt))return n.value;return e}});var Hi=1;const $r=e=>{let{state:t}=e,n=t.selection.main;if(n.empty)return!1;let r=t.doc,o=r.lineAt(n.from),a=r.lineAt(n.to);if(t.sliceDoc(o.from,a.to).trim().length<Hi)return!1;let i=Math.max(1,Math.min(o.number,r.lines)),s=Math.max(1,Math.min(a.number,r.lines));return e.dispatch({effects:[ot.of({show:!0,lineFrom:i,lineTo:s}),xt.of(!0),St.of("")],selection:wt.cursor(o.from)}),!0},Hr=e=>e.state.field(It)?(e.dispatch({effects:[Ht.of(null),ot.of({show:!1,lineFrom:0,lineTo:0}),xt.of(!1),St.of(""),mt.of(!1)]}),!0):!1,qr=e=>{let t=e.state.field(It);return t?(e.dispatch({changes:{from:t.from,to:t.to,insert:t.oldCode},effects:[Ht.of(null),ot.of({show:!1,lineFrom:0,lineTo:0}),xt.of(!1),St.of(""),mt.of(!1)]}),!0):!1};var Mn={mac:"\u2318",windows:"\u229E Win",default:"Ctrl"};function qi(){return navigator.platform.startsWith("Mac")?Mn.mac:navigator.platform.startsWith("Win")?Mn.windows:Mn.default}function Rn(e){return e.replace("Mod",qi()).replace("-"," ").toUpperCase()}function pe(e,t){let n=document.createElement(e);return n.className=t,n}function zi(e,t,n=void 0){let r=()=>{};return(...o)=>(r(),new Promise((a,i)=>{let s=setTimeout(()=>a(e(...o)),t);r=()=>{clearTimeout(s),n!==void 0&&i(n)}}))}var qt=Ye.define({create(){return{suggestion:null}},update(e,t){let n=t.effects.find(r=>r.is(zt));return!t.docChanged&&!n&&!t.selection?e:n&&t.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),zt=he.define();function Ki(e,t){let n=e.state.selection.main.head,r=[],o=$.widget({widget:new Yi(t),side:1});return r.push(o.range(n)),$.set(r)}var Yi=class extends On{constructor(t){super();p(this,"suggestion");this.suggestion=t}toDOM(){let t=document.createElement("span");return t.style.opacity="0.4",t.className="cm-inline-suggestion",t.textContent=this.suggestion,t.setAttribute("role","suggestion"),t.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),t}get lineBreaks(){return this.suggestion.split(`
3
3
  `).length-1}},Xi=class{constructor(e){p(this,"cache",new Map);p(this,"timeout");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()})}},Qi=(e,t)=>Ze.fromClass(class{constructor(){p(this,"abortController",null);p(this,"cache");this.cache=new Xi(t.cacheTimeout??1e3)}async update(n){var i,s,u,c,d;if(!n.docChanged||((s=(i=t.events)==null?void 0:i.beforeSuggestionFetch)==null?void 0:s.call(i,n.view))===!1)return;(u=this.abortController)==null||u.abort(),this.abortController=new AbortController;let r=n.state.doc,o=r.toString(),a=this.cache.get(o);if(a){n.view.dispatch({effects:zt.of({text:a,doc:r})});return}try{let f=await e(n.state,this.abortController.signal,n.view);if(this.abortController.signal.aborted||((d=(c=t.events)==null?void 0:c.shouldShowSuggestion)==null?void 0:d.call(c,n.view,f))===!1)return;this.cache.set(o,f),n.view.dispatch({effects:zt.of({text:f,doc:r})})}catch(f){f instanceof Error&&f.name!=="AbortError"&&console.error("Suggestion fetch error:",f)}}destroy(){var n;(n=this.abortController)==null||n.abort()}}),Zi=Ze.fromClass(class{constructor(){p(this,"decorations");this.decorations=$.none}update(e){var n;let t=(n=e.state.field(qt))==null?void 0:n.suggestion;if(!t){this.decorations=$.none;return}this.decorations=Ki(e.view,t)}},{decorations:e=>e.decorations});function es(e,t,n,r){return{...e.changeByRange(o=>{if(o===e.selection.main)return{changes:{from:n,to:r,insert:t},range:wt.cursor(n+t.length)};let a=r-n;return!o.empty||a&&e.sliceDoc(o.from-a,o.from)!==e.sliceDoc(n,r)?{range:o}:{changes:{from:o.from-a,to:o.from,insert:t},range:wt.cursor(o.from-a+t.length)}}),userEvent:"input.complete"}}var ts=e=>{var r,o,a;let t=(r=e.state.field(qt))==null?void 0:r.suggestion;if(!t)return!1;let n=e.state.facet(Gn);return e.dispatch({...es(e.state,t,e.state.selection.main.head,e.state.selection.main.head)}),(a=(o=n.events)==null?void 0:o.onSuggestionAccepted)==null||a.call(o,e,t),!0},zr=e=>{var r,o,a;let t=(r=e.state.field(qt))==null?void 0:r.suggestion;if(!t)return!1;let n=e.state.facet(Gn);return e.dispatch({effects:zt.of({text:null,doc:e.state.doc})}),(a=(o=n.events)==null?void 0:o.onSuggestionRejected)==null||a.call(o,e,t),!0},ns=$e.of([{key:"Tab",run:ts},{key:"Escape",run:zr}]),Gn=Rt.define({combine:e=>e.at(-1)});function Kr(e){let{delay:t=500,includeKeymap:n=!0}=e,r=zi(e.fetchFn,t);return[qt,Gn.of(e),Qi(r,e),Zi,n?ns:[]]}const rs=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 os(e){var s,u;let t=e.state.facet(Ct),n={...H,...t.keymaps},r=e.state.facet(Kt),o=pe("div","cm-ai-tooltip").appendChild(pe("div","cm-ai-tooltip-button")),a=o.appendChild(document.createElement("span"));a.textContent=`${r.label} `;let i=a.appendChild(document.createElement("span"));return i.className="hotkey",i.textContent=Rn(n.showInput),(s=o.querySelector("span"))==null||s.addEventListener("mousedown",c=>{c.stopPropagation(),c.button===0&&c.preventDefault()}),(u=o.querySelector("span"))==null||u.addEventListener("click",c=>{c.preventDefault(),$r(e)}),o}const Kt=Rt.define({combine(e){return Ln(e,{render:os,hideOnBlur:!1,label:"Edit with AI"})}}),as=Ze.fromClass((Ua=class{constructor(e){p(this,"view");p(this,"suppress");p(this,"dom");p(this,"mousedown",()=>{this.suppress=!0});p(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});p(this,"scroll",()=>{this.display(this.view)});p(this,"windowScroll",()=>{this.display(this.view)});ja(this,Nn,e=>{var n;let t=e.state.selection.ranges.find(r=>!r.empty);if(t&&!this.suppress){let r=e.coordsAtPos(t.from),o=e.coordsAtPos(t.to);if(!r||!o)return;let a=e.dom.getBoundingClientRect(),i=(n=e.dom.parentElement)==null?void 0:n.getBoundingClientRect(),s=v=>v.top>=a.top&&v.top<=a.bottom&&v.left>=a.left&&v.left<=a.right,u=v=>!i||v.top>=i.top&&v.top<=i.bottom&&v.left>=i.left&&v.left<=i.right,c=s(r)||s(o),d=u(r)||u(o);if(!c||!d){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}this.dom.style.display="flex",this.dom.setAttribute("aria-hidden","false");let f=this.dom.getBoundingClientRect(),g=s(r)?r:o,m=a.right-f.width,h=Math.min(g.left,m),w=g.top-f.height,y=i?i.y:-1/0;w<y&&(w=o.bottom),this.dom.style.left=`${h}px`,this.dom.style.top=`${w}px`,requestAnimationFrame(()=>{this.dom&&this.dom.setAttribute("aria-hidden","false")})}else this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true")});this.view=e;let t=e.state.facet(Kt);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(at).show){this.dom.style.display="none";return}if(e.state.facet(Kt).hideOnBlur&&!e.hasFocus){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}e.requestMeasure({read:Pa(this,Nn)})}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()}},Nn=new WeakMap,Ua));var is=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 ss(){return[as,is]}var ls=class extends On{constructor(t){super();p(this,"oldCode");this.oldCode=t}toDOM(t){let n=pe("div","cm-old-code-container");n.setAttribute("role","region"),n.setAttribute("aria-label","Previous code version");let r=pe("div","cm-old-code cm-line");r.textContent=this.oldCode;let o=pe("div","cm-floating-buttons"),a=t.state.facet(Ct),i={...H,...a.keymaps},s=pe("button","cm-floating-button cm-floating-accept");s.innerHTML=`<span class="hotkey">${Rn(i.acceptEdit)}</span> Accept`,s.setAttribute("aria-label","Accept changes"),s.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),t.focus(),Hr(t)});let u=pe("button","cm-floating-button cm-floating-reject");return u.innerHTML=`<span class="hotkey">${Rn(i.rejectEdit)}</span> Reject`,u.setAttribute("aria-label","Reject changes"),u.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),t.focus(),qr(t)}),o.append(s,u),n.append(r,o),n}updateDOM(t,n){return!0}},cs=class extends On{constructor(t){super();p(this,"complete");p(this,"abortController",null);p(this,"dom",null);p(this,"input",null);p(this,"loadingContainer",null);p(this,"helpInfo",null);p(this,"inputContainer",null);p(this,"form",null);p(this,"view",null);p(this,"onKeyDown",async t=>{t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),await this.handleSubmit()):t.key==="Escape"&&this.onCancel()});p(this,"onCancel",()=>{this.cleanup();let t=this.view;t&&(t.dispatch({effects:[ot.of({show:!1,lineFrom:0,lineTo:0}),mt.of(!1)]}),t.focus())});p(this,"handleSubmit",async t=>{var h;let n=this.view;if(!n)return;let r=n.state.facet(Ct);t==null||t.stopPropagation();let o=n.state.field(at),{input:a}=this;if(!a)return;let i=a.value.trim();if(!o.show||!i)return;let s=n.state.doc.line(o.lineFrom),u=n.state.doc.line(o.lineTo),c=s.from,d=u.to,f=n.state.sliceDoc(c,d),g=n.state.sliceDoc(0,c),m=n.state.sliceDoc(d);this.abortController=new AbortController,n.dispatch({effects:mt.of(!0)}),this.toggleLoading(!0);try{let w=await this.complete({prompt:i,selection:f,codeBefore:g,codeAfter:m,editorView:n,signal:this.abortController.signal});if(!n.state.field(at).show)return;if(!w||typeof w!="string")throw Error("Invalid completion result");n.dispatch({changes:{from:c,to:d,insert:w},effects:[ot.of({show:!1,lineFrom:0,lineTo:0}),Ht.of({from:c,to:c+w.length,oldCode:f,newCode:w}),mt.of(!1)]})}catch(w){if(w instanceof DOMException&&w.name==="AbortError")return;(h=r.onError)==null||h.call(r,w)}finally{this.cleanup(),this.toggleLoading(!1),n.focus()}});this.complete=t}toDOM(t){if(this.dom)return this.dom;this.view=t;let n=t.state.field(Wr),r=t.state.field(Vr),o=pe("div","cm-ai-input-container");this.inputContainer=o,this.dom=o;let a=pe("form","cm-ai-input-form");this.form=a,a.setAttribute("role","search"),a.setAttribute("aria-label","AI editing instructions"),a.addEventListener("submit",y=>y.preventDefault());let i=pe("input","cm-ai-input");this.input=i,a.append(i),i.placeholder="Editing instructions...",i.setAttribute("aria-label","AI editing instructions"),i.setAttribute("autocomplete","off"),i.setAttribute("spellcheck","true"),i.value=n.inputValue;let s=pe("div","cm-ai-loading-container");this.loadingContainer=s;let u=pe("div","cm-ai-loading-indicator");u.setAttribute("role","status"),u.setAttribute("aria-live","polite"),u.textContent="Generating";let c=pe("button","cm-ai-cancel-button");c.textContent="Cancel",c.setAttribute("aria-label","Cancel code generation"),c.addEventListener("click",this.onCancel),s.append(c,u);let d=pe("div","cm-ai-help-info");this.helpInfo=d;let f=d.appendChild(document.createElement("button"));f.className="cm-ai-help-info-button",f.textContent="Esc to close",f.addEventListener("click",this.onCancel);let g=pe("button","cm-ai-generate-button");g.textContent="\u23CE Generate",g.setAttribute("aria-label","Generate code"),g.addEventListener("click",this.handleSubmit),this.toggleLoading(r),n.shouldFocus&&requestAnimationFrame(()=>{i.value=n.inputValue,i.focus(),t.dispatch({effects:xt.of(!1)})}),m(i.value),i.addEventListener("input",w),i.addEventListener("keydown",this.onKeyDown);function m(y){d.replaceChildren(y?g:f)}let h="";function w(){t.dispatch({effects:St.of(i.value)});let y=i.value.trim();y!==h&&(h=y,m(y))}return o}toggleLoading(t){var n;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&((n=this.inputContainer)==null||n.replaceChildren(this.form,t?this.loadingContainer:this.helpInfo))}updateDOM(t,n){return this.dom=t,this.input=t.querySelector(".cm-ai-input"),!0}cleanup(){var t,n,r;(t=this.abortController)==null||t.abort(),this.abortController=null,(n=this.dom)==null||n.remove(),(r=this.input)==null||r.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}};function us(e){if(!e.prompt)throw Error("prompt function is required");let t={...H,...e.keymaps};return[Ct.of(e),at,Wr,It,Vr,ss(),rs,$e.of([{key:t.showInput,run:$r}]),dt.highest([$e.of([{key:t.acceptEdit,run:Hr},{key:t.rejectEdit,run:qr}])]),ds,fs,ms,ps]}const ds=R.updateListener.of(e=>{let t=e.state.field(at);if(!t.show||!e.docChanged)return;let{lineFrom:n,lineTo:r}=t,o=!1;e.changes.iterChanges((a,i,s,u)=>{let c=e.state.doc.lineAt(a).number;if(c<n){let d=e.state.doc.lineAt(u).number-e.state.doc.lineAt(s).number;n+=d,r+=d,o=!0}else if(c<=r){let d=e.state.doc.lineAt(u).number-e.state.doc.lineAt(s).number;r+=d,o=!0}}),o&&e.view.dispatch({effects:[ot.of({show:!0,lineFrom:n,lineTo:r})]})}),fs=R.decorations.of(e=>{let t=e.state.field(It);return t?$.set([$.mark({class:"cm-new-code-line"}).range(t.from,t.to)]):$.none}),ms=R.decorations.compute([at],e=>{let t=e.field(at),n=e.facet(Ct),r=[];if(t.show){let o=t.lineFrom,a=t.lineTo;for(let i=o;i<=a;i++){let s=e.doc.line(i).from;r.push($.line({class:"cm-ai-selection"}).range(s)),i===o&&r.push($.widget({widget:new cs(n.prompt),side:-1}).range(s))}}return $.set(r)}),ps=Ye.define({create(e){return $.none},update(e,t){let n=t.state.field(It);return n?$.set([$.widget({widget:new ls(n.oldCode),block:!0}).range(n.from)]):$.none},provide:e=>R.decorations.from(e)});var gs=We(),F=Ma(gd(),1),Jn=()=>({entries:new Map}),{valueAtom:Yr,useActions:Xr}=Dr(Jn,{submit:(e,t)=>{let{cellIds:n,deleteCell:r,deleteManyCells:o,store:a}=t,i=a.get(rt),s=a.get(Ld),u=new Set(i.cellIds.inOrderIds.filter(f=>i.cellData[f].code.trim()==="")),c=new Map;for(let f of n){if(u.has(f)){c.set(f,{cellId:f,type:"simple"});continue}let g=i.cellRuntime[f],m=new Map;for(let w of Object.values(s)){let y=w.declaredBy.includes(f),v=w.usedBy.some(C=>!u.has(C));y&&v&&m.set(w.name,w.usedBy)}let h;g!=null&&g.runElapsedTimeMs&&g.runElapsedTimeMs>2e3&&(h=g.runElapsedTimeMs),m.size===0&&h===void 0?c.set(f,{cellId:f,type:"simple"}):c.set(f,{cellId:f,type:"expensive",executionDurationMs:h,defs:m})}let d=[...c.values()].every(f=>f.type==="simple");return c.size>0&&d?(c.size===1?r({cellId:[...c.values()][0].cellId}):o({cellIds:[...c.values()].map(f=>f.cellId)}),Jn()):{...e,entries:c}},clear:()=>Jn()});jn=function(){let e=wr(),{submit:t,clear:n}=Xr(),{entries:r}=ie(Yr),o=Oi(),a=Br();return(0,F.useMemo)(()=>({submit:i=>{t({cellIds:i,deleteCell:o,deleteManyCells:a,store:e})},clear:n,get idle(){return r.size===0},get shouldConfirmDelete(){return r.size>1}}),[e,t,n,r,o,a])},$i=function(e){let t=(0,gs.c)(16),n=ie(Yr),r=Xr(),o=Br(),a;t[0]!==e||t[1]!==n.entries?(a=n.entries.get(e),t[0]=e,t[1]=n.entries,t[2]=a):a=t[2];let i=a;if(!i){let d;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d={isPending:!1},t[3]=d):d=t[3],d}if(n.entries.size!==1){let d;return t[4]===i?d=t[5]:(d={isPending:!0,shouldConfirmDelete:!1,...i},t[4]=i,t[5]=d),d}let s;t[6]!==r||t[7]!==o||t[8]!==n.entries?(s=()=>{o({cellIds:[...n.entries.values()].map(hs)}),r.clear()},t[6]=r,t[7]=o,t[8]=n.entries,t[9]=s):s=t[9];let u;t[10]===r?u=t[11]:(u=()=>r.clear(),t[10]=r,t[11]=u);let c;return t[12]!==i||t[13]!==s||t[14]!==u?(c={isPending:!0,...i,shouldConfirmDelete:!0,confirm:s,cancel:u},t[12]=i,t[13]=s,t[14]=u,t[15]=c):c=t[15],c};function hs(e){return e.cellId}async function bs(e){var s,u;let t=`
4
4
  ${e.codeBefore}
5
5
  <rewrite_this>
@@ -1 +1 @@
1
- import{s as L}from"./chunk-LvLJmgfZ.js";import{d as P,l as w,n as j,u as O}from"./useEvent-D91BmmQi.js";import{D as y,Ii as A,It as D,M as E,P as S,mn as T,wi as _}from"./cells-BRMYB7Wo.js";import{t as b}from"./compiler-runtime-B3qBwwSJ.js";import{_ as $}from"./useEventListener-DvoEXWke.js";import{p as F}from"./utils-CvI-39U6.js";import{r as I}from"./constants-DMpttj8Q.js";import{v as M,w as q}from"./config-ClMcu_sV.js";import{t as B}from"./cn-DCUzRj2J.js";import{t as H}from"./jsx-runtime-BqBOg78p.js";import{r as R}from"./requests-DIwGYs0l.js";import{n as U}from"./paths-D5zczhUD.js";import{s as V}from"./session-0B5NBztP.js";import{n as z}from"./ImperativeModal-B3Th7k4R.js";var G=b();function N(){return O(_)}function J(){let r=(0,G.c)(5),[t]=w(M),e=P(_),{openAlert:s}=z(),{sendRename:o}=R(),a;return r[0]!==t.state||r[1]!==s||r[2]!==o||r[3]!==e?(a=async l=>{let n=F();return t.state===q.OPEN?(V(i=>{l===null?i.delete(I.filePath):i.set(I.filePath,l)}),o({filename:l}).then(()=>(e(l),document.title=n.app_title||U.basename(l)||"Untitled Notebook",l)).catch(i=>(s(i.message),null))):(s("Failed to save notebook: not connected to a kernel."),null)},r[0]=t.state,r[1]=s,r[2]=o,r[3]=e,r[4]=a):a=r[4],j(a)}var p=b(),v=L(H(),1);const h=r=>{let t=(0,p.c)(12),{className:e,cellId:s,variant:o,onClick:a,formatCellName:l,skipScroll:n}=r,i=S()[s]??"",C=E().inOrderIds.indexOf(s),{showCellIfHidden:d}=y(),g=l??W,c;t[0]===e?c=t[1]:(c=B("inline-block cursor-pointer text-link hover:underline",e),t[0]=e,t[1]=c);let m;t[2]!==s||t[3]!==a||t[4]!==d||t[5]!==n||t[6]!==o?(m=k=>{if(s==="__scratch__")return!1;d({cellId:s}),k.stopPropagation(),k.preventDefault(),requestAnimationFrame(()=>{x(s,o,n)&&(a==null||a())})},t[2]=s,t[3]=a,t[4]=d,t[5]=n,t[6]=o,t[7]=m):m=t[7];let f=g(D(i,C)),u;return t[8]!==c||t[9]!==m||t[10]!==f?(u=(0,v.jsx)("div",{className:c,role:"link",tabIndex:-1,onClick:m,children:f}),t[8]=c,t[9]=m,t[10]=f,t[11]=u):u=t[11],u},K=r=>{let t=(0,p.c)(2),e;return t[0]===r?e=t[1]:(e=(0,v.jsx)(h,{...r,variant:"destructive"}),t[0]=r,t[1]=e),e},Q=r=>{let t=(0,p.c)(10),{cellId:e,lineNumber:s}=r,o=N(),a;t[0]!==e||t[1]!==s?(a=()=>T(e,s),t[0]=e,t[1]=s,t[2]=a):a=t[2];let l;t[3]!==e||t[4]!==o?(l=i=>e==="__scratch__"?"scratch":`marimo://${o||"untitled"}#cell=${i}`,t[3]=e,t[4]=o,t[5]=l):l=t[5];let n;return t[6]!==e||t[7]!==a||t[8]!==l?(n=(0,v.jsx)(h,{cellId:e,onClick:a,skipScroll:!0,variant:"destructive",className:"traceback-cell-link",formatCellName:l}),t[6]=e,t[7]=a,t[8]=l,t[9]=n):n=t[9],n};function x(r,t,e){let s=A.create(r),o=document.getElementById(s),a=o==null?void 0:o.classList.contains("has-error");return o===null?($.error(`Cell ${s} not found on page.`),!1):(e||o.scrollIntoView({behavior:"smooth",block:"center"}),(t==="destructive"||a&&t===void 0)&&(o.classList.add("error-outline"),setTimeout(()=>{o.classList.remove("error-outline")},2e3)),(t==="focus"||!a&&t===void 0)&&(o.classList.add("focus-outline"),setTimeout(()=>{o.classList.remove("focus-outline")},2e3)),!0)}function W(r){return r}export{N as a,x as i,K as n,J as o,Q as r,h as t};
1
+ import{s as L}from"./chunk-LvLJmgfZ.js";import{d as P,l as w,n as j,u as O}from"./useEvent-D91BmmQi.js";import{D as y,Ii as A,It as D,M as E,P as S,mn as T,wi as _}from"./cells-BFTdVtl5.js";import{t as b}from"./compiler-runtime-B3qBwwSJ.js";import{_ as $}from"./useEventListener-DvoEXWke.js";import{p as F}from"./utils-CvI-39U6.js";import{r as I}from"./constants-DMpttj8Q.js";import{v as M,w as q}from"./config-ClMcu_sV.js";import{t as B}from"./cn-DCUzRj2J.js";import{t as H}from"./jsx-runtime-BqBOg78p.js";import{r as R}from"./requests-DIwGYs0l.js";import{n as U}from"./paths-D5zczhUD.js";import{s as V}from"./session-0B5NBztP.js";import{n as z}from"./ImperativeModal-B3Th7k4R.js";var G=b();function N(){return O(_)}function J(){let r=(0,G.c)(5),[t]=w(M),e=P(_),{openAlert:s}=z(),{sendRename:o}=R(),a;return r[0]!==t.state||r[1]!==s||r[2]!==o||r[3]!==e?(a=async l=>{let n=F();return t.state===q.OPEN?(V(i=>{l===null?i.delete(I.filePath):i.set(I.filePath,l)}),o({filename:l}).then(()=>(e(l),document.title=n.app_title||U.basename(l)||"Untitled Notebook",l)).catch(i=>(s(i.message),null))):(s("Failed to save notebook: not connected to a kernel."),null)},r[0]=t.state,r[1]=s,r[2]=o,r[3]=e,r[4]=a):a=r[4],j(a)}var p=b(),v=L(H(),1);const h=r=>{let t=(0,p.c)(12),{className:e,cellId:s,variant:o,onClick:a,formatCellName:l,skipScroll:n}=r,i=S()[s]??"",C=E().inOrderIds.indexOf(s),{showCellIfHidden:d}=y(),g=l??W,c;t[0]===e?c=t[1]:(c=B("inline-block cursor-pointer text-link hover:underline",e),t[0]=e,t[1]=c);let m;t[2]!==s||t[3]!==a||t[4]!==d||t[5]!==n||t[6]!==o?(m=k=>{if(s==="__scratch__")return!1;d({cellId:s}),k.stopPropagation(),k.preventDefault(),requestAnimationFrame(()=>{x(s,o,n)&&(a==null||a())})},t[2]=s,t[3]=a,t[4]=d,t[5]=n,t[6]=o,t[7]=m):m=t[7];let f=g(D(i,C)),u;return t[8]!==c||t[9]!==m||t[10]!==f?(u=(0,v.jsx)("div",{className:c,role:"link",tabIndex:-1,onClick:m,children:f}),t[8]=c,t[9]=m,t[10]=f,t[11]=u):u=t[11],u},K=r=>{let t=(0,p.c)(2),e;return t[0]===r?e=t[1]:(e=(0,v.jsx)(h,{...r,variant:"destructive"}),t[0]=r,t[1]=e),e},Q=r=>{let t=(0,p.c)(10),{cellId:e,lineNumber:s}=r,o=N(),a;t[0]!==e||t[1]!==s?(a=()=>T(e,s),t[0]=e,t[1]=s,t[2]=a):a=t[2];let l;t[3]!==e||t[4]!==o?(l=i=>e==="__scratch__"?"scratch":`marimo://${o||"untitled"}#cell=${i}`,t[3]=e,t[4]=o,t[5]=l):l=t[5];let n;return t[6]!==e||t[7]!==a||t[8]!==l?(n=(0,v.jsx)(h,{cellId:e,onClick:a,skipScroll:!0,variant:"destructive",className:"traceback-cell-link",formatCellName:l}),t[6]=e,t[7]=a,t[8]=l,t[9]=n):n=t[9],n};function x(r,t,e){let s=A.create(r),o=document.getElementById(s),a=o==null?void 0:o.classList.contains("has-error");return o===null?($.error(`Cell ${s} not found on page.`),!1):(e||o.scrollIntoView({behavior:"smooth",block:"center"}),(t==="destructive"||a&&t===void 0)&&(o.classList.add("error-outline"),setTimeout(()=>{o.classList.remove("error-outline")},2e3)),(t==="focus"||!a&&t===void 0)&&(o.classList.add("focus-outline"),setTimeout(()=>{o.classList.remove("focus-outline")},2e3)),!0)}function W(r){return r}export{N as a,x as i,K as n,J as o,Q as r,h as t};
@@ -54,7 +54,7 @@ ${a.sqlString}
54
54
  `),a=[];for(let o of n)if(o!=null&&o.startsWith("#"))a.push(o);else break;return a}};function OS(e){do{if(e.name==="AssignStatement")return e.node;if(e.name!=="Comment")return null}while(e.next());return null}function Oy(e){try{let n=bS(e).cursor();n.name==="Script"&&n.next();let a=OS(n);if(!a||e.slice(a.to).trim().length>0)return null;let o=null,s=null,c,d,f=0,m=a.cursor();if(m.firstChild(),m.name==="VariableName"&&(o=e.slice(m.from,m.to)),!o)return null;let b=!1,w=null;for(;m.nextSibling();)if(m.name==="AssignOp")b=!0;else if(b&&!w){w=m.node;break}if(!w||w.name==="ConditionalExpression"||w.name==="BinaryExpression"||w.name==="UnaryExpression")return null;let x=w.cursor(),S=null;if(x.name==="CallExpression")S=x.node;else{x.firstChild();do if(x.name==="CallExpression"){S=x.node;break}while(x.nextSibling())}if(S){let E=S.cursor(),I=!1;if(E.firstChild(),E.name==="MemberExpression"&&(I=e.slice(E.from,E.to)==="mo.sql"),I){for(;E.next();)if(E.name==="ArgList"){let{args:P,kwargs:q}=_S(E.node.cursor(),e);P.length===1&&(s=CS(P[0],e),f=P[0].from+SS(e.slice(P[0].from,P[0].to)));for(let{key:B,value:V}of q)switch(B){case"engine":c=V;break;case"output":d=V==="True";break}if(s==="")return{dfName:o,sqlString:"",engine:c,output:d,startPosition:f};break}}}return!o||!s?null:{dfName:o,sqlString:vS(s),engine:c,output:d,startPosition:f}}catch(n){return console.warn("Failed to parse SQL statement",n),null}}function AS(e){return e.split(`
55
55
  `).map(n=>n!=null&&n.trim()?` ${n}`:n).join(`
56
56
  `)}var RS=Fn(),uf=()=>({cellIds:new Set}),{valueAtom:df,useActions:PS}=us(uf,{markForCut:(e,n)=>({cellIds:new Set(n.cellIds)}),clear:()=>uf()});Xu=Ee(e=>e(df).cellIds),Em=Ee(null,(e,n)=>{n(df,uf())}),Kx=function(){return PS()},D_=function(e){let n=(0,RS.c)(3),a=rn(Xu),o;return n[0]!==e||n[1]!==a?(o=a.has(e),n[0]=e,n[1]=a,n[2]=o):o=n[2],o},P_=function(){return rn(df)},ax=(e,n,a)=>Qi.define(o=>new MS(o,e,n,a)),Ya=Hw.define();var MS=class{constructor(e,n,a,o){ve(this,"isInitDispatch",!1);ve(this,"onRemoteUpdate",e=>{if(e.by!=="local"){if(e.by==="checkout"){this.view.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:this.getTextFromDoc(this.doc).toString()}],annotations:[Ya.of(this)]});return}if(e.by==="import"){let n=[],a=0;for(let{diff:o,path:s}of e.events){if(s.join("/")!==this.docPath.join("/")||o.type!=="text")continue;let c=o.diff;for(let d of c)d.insert?n.push({from:a,to:a,insert:d.insert}):d.delete?(n.push({from:a,to:a+d.delete}),a+=d.delete):d.retain!=null&&(a+=d.retain);n.length>0&&this.view.dispatch({changes:n,annotations:[Ya.of(this)]})}}}});this.view=e,this.doc=n,this.docPath=a,this.getTextFromDoc=o,this.sub=n.subscribe(this.onRemoteUpdate),Promise.resolve().then(()=>{this.isInitDispatch=!0;let s=this.view.state.doc.toString(),c=this.getTextFromDoc(this.doc);s!==c.toString()&&e.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:c.toString()}],annotations:[Ya.of(this)]})})}update(e){if(this.isInitDispatch){this.isInitDispatch=!1;return}if(!e.docChanged||e.transactions.length>0&&(e.transactions[0].annotation(Ya)===this||e.transactions[0].annotation(Ya)==="undo"))return;let n=0;e.changes.iterChanges((a,o,s,c,d)=>{let f=d.sliceString(0,d.length,`
57
- `);a!==o&&this.getTextFromDoc(this.doc).delete(a+n,o-a),f.length>0&&this.getTextFromDoc(this.doc).insert(a+n,f),n+=f.length-(o-a)}),this.doc.commit()}destroy(){var e;(e=this.sub)==null||e.call(this),this.sub=void 0}};function NS(e,n){return{get:()=>n.get(e),sub:a=>n.sub(e,()=>a(n.get(e)))}}function DS(e,{offset:n,body:a=window,behavior:o="smooth"}){let s=(n==null?void 0:n.top)??0,c=(n==null?void 0:n.bottom)??0,d=e.getBoundingClientRect();if(d.top<s){a.scrollBy({top:d.top-s,behavior:o});return}if(d.bottom>window.innerHeight-c){a.scrollBy({top:d.bottom-window.innerHeight+c,behavior:o});return}}Ll=function(e){return e?e.state.field(Vn).type:"python"};function jS(e,n){return!e||Ll(e)===n?!1:e.state.doc.toString().trim()===""?!0:$n[n].isSupported(wr(e))}od=function(e,n,a={}){return!a.force&&!jS(e,n)?!1:(bd(e,{language:n}),n)};function zS(e){return Xa.of([{key:e.getHotkey("cell.format").key,preventDefault:!0,run:n=>(Hu({[n.state.facet(ua)]:n}),!0)},{key:e.getHotkey("cell.viewAsMarkdown").key,preventDefault:!0,run:n=>{let a=od(n,Ll(n)==="markdown"?"python":"markdown",{force:!0});return a==="markdown"&&n.state.facet(st).afterToggleMarkdown(),a!==!1}},{key:e.getHotkey("cell.viewAsSQL").key,preventDefault:!0,run:n=>{let a=od(n,Ll(n)==="sql"?"python":"sql",{force:!0});return a==="sql"&&n.state.facet(st).afterToggleSQL(),a!==!1}}])}ck=function(){return Et.updateListener.of(e=>{if(e.view.hasFocus&&e.heightChanged&&e.docChanged){if(e.transactions.some(n=>n.effects.some(a=>a.is(xs))))return;Ay(e.view,{behavior:"smooth"})}})};function Ay(e,n){let a=e.dom.getElementsByClassName("cm-activeLine cm-line");if(a.length===1){let o=a[0],s=document.getElementById("App");an(s,"App not found"),DS(o,{offset:{top:30,bottom:150},body:s,behavior:n.behavior})}}function qS(){return{}}let FS,BS,Ry;({reducer:FS,createActions:BS,valueAtom:ei,useActions:Ry}=us(qS,{setVariables:(e,n)=>{let a={...e},o={};for(let s of n)o[s.name]={...a[s.name],...s};return o},addVariables:(e,n)=>{let a={...e};for(let o of n)a[o.name]={...a[o.name],...o};return a},setMetadata:(e,n)=>{let a={...e};for(let{name:o,value:s,dataType:c}of n)a[o]&&(a[o]={...a[o],value:s,dataType:c});return a}})),O_=()=>rn(ei),q_=function(){return Ry()},vm=function(e){let n=e.storage||gs;return{getItem(a,o){try{let s=n.getItem(a);if(!s)return o;let c=JSON.parse(s);return e.fromSerializable(c)}catch(s){return be.warn(`Error getting ${a} from storage`,s),o}},setItem:(a,o)=>{n.setItem(a,JSON.stringify(e.toSerializable(o)))},removeItem:a=>{n.removeItem(a)}}},Qu=eg(()=>gs),gm=function(e,n){if(typeof window>"u")return;let a=`__marimo__${n}`;window[a]&&be.warn(`Overwriting existing debug object ${a}`),window[a]=e};var VS={markdown:!0,wasm_layouts:!1,rtc_v2:!1,cache_panel:!1,external_agents:!1};ed=function(e){var n,a;return((a=(n=Mw())==null?void 0:n.experimental)==null?void 0:a[e])??VS[e]};function HS(e,n){br().saveUserConfig({config:{experimental:{[e]:n}}})}gm(HS,"setFeatureFlag"),zl=[{type:"files",Icon:iy,label:"Files",tooltip:"View files",defaultSection:"sidebar",additionalKeywords:["explorer","browser","directory"]},{type:"variables",Icon:Ym,label:"Variables",tooltip:"Explore variables and data sources",defaultSection:"sidebar",additionalKeywords:["state","scope","inspector"]},{type:"packages",Icon:km,label:"Packages",tooltip:"Manage packages",defaultSection:"sidebar",additionalKeywords:["dependencies","pip","install"]},{type:"ai",Icon:cm,label:"AI",tooltip:"Chat & Agents",defaultSection:"sidebar",additionalKeywords:["chat","copilot","assistant"]},{type:"outline",Icon:u0,label:"Outline",tooltip:"View outline",defaultSection:"sidebar",additionalKeywords:["toc","structure","headings"]},{type:"documentation",Icon:o0,label:"Docs",tooltip:"View live docs",defaultSection:"sidebar",additionalKeywords:["reference","api"]},{type:"dependencies",Icon:e0,label:"Dependencies",tooltip:"Explore dependencies",defaultSection:"sidebar",additionalKeywords:["graph","imports"]},{type:"errors",Icon:xm,label:"Errors",tooltip:"View errors",defaultSection:"developer-panel",additionalKeywords:["exceptions","problems","diagnostics"]},{type:"scratchpad",Icon:Bm,label:"Scratchpad",tooltip:"Scratchpad",defaultSection:"developer-panel",additionalKeywords:["scratch","draft","playground"]},{type:"tracing",Icon:ym,label:"Tracing",tooltip:"View tracing",defaultSection:"developer-panel",additionalKeywords:["profiling","performance"]},{type:"secrets",Icon:oy,label:"Secrets",tooltip:"Manage secrets",defaultSection:"developer-panel",hidden:ju(),additionalKeywords:["env","environment","keys","credentials"]},{type:"logs",Icon:Am,label:"Logs",tooltip:"View logs",defaultSection:"developer-panel",additionalKeywords:["console","stdout"]},{type:"terminal",Icon:Um,label:"Terminal",tooltip:"Terminal",hidden:ju(),defaultSection:"developer-panel",requiredCapability:"terminal",additionalKeywords:["shell","console","bash","command"]},{type:"snippets",Icon:sy,label:"Snippets",tooltip:"Snippets",defaultSection:"developer-panel",additionalKeywords:["templates","examples"]},{type:"cache",Icon:tm,label:"Cache",tooltip:"View cache",defaultSection:"developer-panel",hidden:!ed("cache_panel"),additionalKeywords:["memory","memoize"]}],f_=new Map(zl.map(e=>[e.type,e])),Mx=function({panel:e,capabilities:n,aiEnabled:a}){return!!(e.hidden||e.type==="ai"&&!a||e.requiredCapability&&!n[e.requiredCapability])};var $S=Fn(),ff={sidebar:zl.filter(e=>!e.hidden&&e.defaultSection==="sidebar").map(e=>e.type),developerPanel:zl.filter(e=>!e.hidden&&e.defaultSection==="developer-panel").map(e=>e.type)};function WS(e){let n=new Set([...e.sidebar,...e.developerPanel]);return{sidebar:[...e.sidebar,...ff.sidebar.filter(a=>!n.has(a))],developerPanel:[...e.developerPanel,...ff.developerPanel.filter(a=>!n.has(a))]}}lm=Rl("marimo:panel-layout",ff,vm({toSerializable:e=>e,fromSerializable:e=>WS(e)}),{getOnInit:!0});function Py(e){let n=Pe.get(lm);return n.sidebar.includes(e)?"sidebar":n.developerPanel.includes(e)?"developer-panel":null}var My="marimo:sidebar",Ny=new dd(Ow({selectedPanel:Aw().optional().transform(e=>e),isSidebarOpen:Rw(),isDeveloperPanelOpen:Rw().optional().default(!1),selectedDeveloperPanelTab:Aw().optional().default("errors").transform(e=>e)}),US);function US(){return{selectedPanel:"variables",isSidebarOpen:!1,isDeveloperPanelOpen:!1,selectedDeveloperPanelTab:"errors"}}let KS,QS,Dy;({reducer:KS,createActions:QS,valueAtom:ad,useActions:Dy}=us(()=>Ny.get(My),{openApplication:(e,n)=>{let a=Py(n);return a==="sidebar"?{...e,selectedPanel:n,isSidebarOpen:!0}:a==="developer-panel"?{...e,selectedDeveloperPanelTab:n,isDeveloperPanelOpen:!0}:e},toggleApplication:(e,n)=>{let a=Py(n);return a==="sidebar"?{...e,selectedPanel:n,isSidebarOpen:e.isSidebarOpen?e.selectedPanel!==n:!0}:a==="developer-panel"?{...e,selectedDeveloperPanelTab:n,isDeveloperPanelOpen:e.isDeveloperPanelOpen?e.selectedDeveloperPanelTab!==n:!0}:e},toggleSidebarPanel:e=>({...e,isSidebarOpen:!e.isSidebarOpen}),setIsSidebarOpen:(e,n)=>({...e,isSidebarOpen:n}),toggleDeveloperPanel:e=>({...e,isDeveloperPanelOpen:!e.isDeveloperPanelOpen}),setIsDeveloperPanelOpen:(e,n)=>({...e,isDeveloperPanelOpen:n})},[(e,n)=>Ny.set(My,n)])),G_=()=>{let e=(0,$S.c)(2),n=rn(ad);if(n.isSidebarOpen)return n;let a;return e[0]===n?a=e[1]:(a={...n,selectedPanel:void 0},e[0]=n,e[1]=a),a},w_=function(){return Dy()},h0=Ee({terminal:!1,pylsp:!1,basedpyright:!1,ty:!1,pyrefly:!1});function wa(e){var n;return((n=Pe.get(h0))==null?void 0:n[e])??!1}Ku=Ee({documentation:null});var jy=new Set(["FunctionDefinition","LambdaExpression","ArrayComprehensionExpression","SetComprehension","DictionaryComprehensionExpression","ComprehensionExpression","ClassDefinition"]);function GS(e){let n=Kh(e.state);if(!n||ZS(n))return[];let a=new Set(Object.keys(e.variables).filter(E=>{let I=e.variables[E];return I.dataType!=="module"&&!I.declaredBy.includes("setup")&&!I.declaredBy.includes(e.cellId)}));if(a.size===0)return[];let o=[],s=new Map,c=new Map,d=new Map;function f(E,I){var J,le,A,j,$,oe,de,he,ye,ke,we;let P=E.cursor(),q=P.name,B=P.from,V=jy.has(q),N=I;switch(V&&(N=[...I,B],s.set(B,new Set),c.set(B,q)),q){case"FunctionDefinition":{let ue=E.cursor();ue.firstChild();do if(ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=I[I.length-1]??-1;s.has(W)||s.set(W,new Set),(J=s.get(W))==null||J.add(ee);break}while(ue.nextSibling());let ie=E.cursor();ie.firstChild();do if(ie.name==="ParamList"){let ee=ie.node.cursor();ee.firstChild();do if(ee.name==="VariableName"){let W=e.state.doc.sliceString(ee.from,ee.to);(le=s.get(B))==null||le.add(W)}while(ee.nextSibling())}while(ie.nextSibling());break}case"LambdaExpression":{let ue=E.cursor();ue.firstChild();do if(ue.name==="ParamList"){let ie=ue.node.cursor();ie.firstChild();do if(ie.name==="VariableName"){let ee=e.state.doc.sliceString(ie.from,ie.to);(A=s.get(B))==null||A.add(ee)}while(ie.nextSibling())}while(ue.nextSibling());break}case"ArrayComprehensionExpression":case"DictionaryComprehensionExpression":case"SetComprehension":case"ComprehensionExpression":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="for")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to);(j=s.get(B))==null||j.add(ee)}else if(ie&&ue.name==="TupleExpression"){let ee=ue.node.cursor();ee.firstChild();do if(ee.name==="VariableName"){let W=e.state.doc.sliceString(ee.from,ee.to);($=s.get(B))==null||$.add(W)}while(ee.nextSibling())}else ie&&ue.name==="in"&&(ie=!1);while(ue.nextSibling());break}case"ClassDefinition":{let ue=E.cursor();ue.firstChild();do if(ue.name==="VariableName"){let ie=e.state.doc.sliceString(ue.from,ue.to),ee=I[I.length-1]??-1;s.has(ee)||s.set(ee,new Set),(oe=s.get(ee))==null||oe.add(ie);break}while(ue.nextSibling());d.set(B,[]);break}case"AssignStatement":{let ue=E.cursor(),ie=[];ue.firstChild();do ue.name==="AssignOp"&&ie.push(ue.from);while(ue.nextSibling());let ee=ie[ie.length-1],W=E.cursor();W.firstChild();let Ie=N[N.length-1]??-1;do W.from<ee&&pf(W,{currentScope:Ie,state:e.state,allDeclarations:s,scopeTypes:c,classLevelDeclarations:d,assignmentPosition:P.to});while(W.nextSibling());break}case"ForStatement":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="for")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=N[N.length-1]??-1;s.has(W)||s.set(W,new Set),(de=s.get(W))==null||de.add(ee)}else ie&&ue.name==="in"&&(ie=!1);while(ue.nextSibling());break}case"ImportStatement":{let ue=E.cursor();ue.firstChild();do if(ue.name==="VariableName"){let ie=e.state.doc.sliceString(ue.from,ue.to),ee=N[N.length-1]??-1;s.has(ee)||s.set(ee,new Set),(he=s.get(ee))==null||he.add(ie)}while(ue.nextSibling());break}case"ImportFromStatement":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="import")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=N[N.length-1]??-1;s.has(W)||s.set(W,new Set),(ye=s.get(W))==null||ye.add(ee)}while(ue.nextSibling());break}case"TryStatement":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="as")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=N[N.length-1]??-1;s.has(W)||s.set(W,new Set),(ke=s.get(W))==null||ke.add(ee),ie=!1}while(ue.nextSibling());break}case"WithStatement":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="as")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=N[N.length-1]??-1;s.has(W)||s.set(W,new Set),(we=s.get(W))==null||we.add(ee),ie=!1}while(ue.nextSibling());break}}S(P,ue=>{f(ue,N)})}function m(E,I,P){let q=d.get(I);return q?q.some(([B,V])=>B===E&&V<P):!1}function b(E,I,P){var q,B;for(let V of I)if(c.get(V)==="ClassDefinition"){if(m(E,V,P))return!0}else if((q=s.get(V))!=null&&q.has(E))return!0;return((B=s.get(-1))==null?void 0:B.has(E))??!1}function w(E,I){let P=E.cursor(),q=P.name,B=P.from,V=jy.has(q),N=I;if(V&&(N=[...I,B]),q==="VariableName"){let J=e.state.doc.sliceString(P.from,P.to);x(J,P)&&(b(J,N,P.from)||o.push({from:P.from,to:P.to,variableName:J}))}S(P,J=>{w(J,N)})}function x(E,I){return a.has(E)&&!YS(I)&&!JS(I)&&!XS(I)}function S(E,I){if(E.firstChild())do I(E.node);while(E.nextSibling())}return f(n,[]),w(n,[]),o}function JS(e){let n=e.node.cursor();if(n.moveTo(e.from),n.parent()&&n.name==="CallExpression"&&n.firstChild())do if(n.name==="ArgList"&&n.firstChild()){do if(n.from===e.from&&n.to===e.to)return n.nextSibling()&&n.name==="AssignOp";while(n.nextSibling());break}while(n.nextSibling());return!1}function XS(e){let n=e.node.cursor();if(n.parent()&&n.name==="AssignStatement"){let a=n.node.cursor();a.firstChild();let o=-1;do if(a.name==="AssignOp"){o=a.from;break}while(a.nextSibling());return o!==-1&&e.from<o}return!1}function YS(e){let n=e.node.cursor();return!!(n.prevSibling()&&n.name===".")}function ZS(e){let n=e.cursor();do if(n.name==="\u26A0"||n.type.isError)return!0;while(n.next());return!1}function pf(e,n){var a;switch(e.name){case"VariableName":{let o=n.state.doc.sliceString(e.from,e.to);if(n.currentScope!==-1&&n.scopeTypes.get(n.currentScope)==="ClassDefinition"){let s=n.classLevelDeclarations.get(n.currentScope);s&&s.push([o,n.assignmentPosition])}else n.allDeclarations.has(n.currentScope)||n.allDeclarations.set(n.currentScope,new Set),(a=n.allDeclarations.get(n.currentScope))==null||a.add(o);break}case"TupleExpression":{let o=e.node.cursor();o.firstChild();do pf(o,n);while(o.nextSibling());break}case"ArrayExpression":{let o=e.node.cursor();o.firstChild();do pf(o,n);while(o.nextSibling());break}}}var e3=ca.mark({class:"mo-cm-reactive-reference"});bx=ca.mark({class:"mo-cm-reactive-reference-hover"});var zy=la.define(),t3=class{constructor(e,n){ve(this,"highlightDebounceMs",300);this.view=e,this.cellId=n,this.scheduleHighlighting=Hh(()=>{this.runHighlighting()},this.highlightDebounceMs),this.variablesUnsubscribe=Pe.sub(ei,()=>{this.scheduleHighlighting()}),this.scheduleHighlighting()}update(e){(e.docChanged||e.focusChanged)&&this.scheduleHighlighting()}destroy(){this.scheduleHighlighting.cancel(),this.variablesUnsubscribe()}runHighlighting(){let e=GS({state:this.view.state,cellId:this.cellId,variables:Pe.get(ei)});e.length>0&&be.debug(`Found ${e.length} reactive variables in cell ${this.cellId}`),queueMicrotask(()=>{this.view.dispatch({effects:zy.of(e)})})}};rd=ls.define({create(){return{decorations:ca.none,ranges:[]}},update(e,n){let a={decorations:e.decorations.map(n.changes),ranges:e.ranges};for(let o of n.effects)o.is(zy)&&(a={decorations:ca.set(o.value.map(s=>e3.range(s.from,s.to))),ranges:o.value});return a},provide:e=>Et.decorations.from(e,n=>n.decorations)});function n3(e){return[rd,Qi.define(n=>new t3(n,e))]}ok=function(e,n){return n?n3(e):[]};function qy(e,n=!1){if(!e)return null;let a=document.createElement("span");if(a.classList.add("mo-cm-tooltip"),a.classList.add("docs-documentation"),n&&a.classList.add("cm-tooltip-section"),a.style.display="flex",a.style.flexDirection="column",a.style.gap=".8rem",a.innerHTML=e,n){let o=document.createElement("div");o.classList.add("text-xs","text-muted-foreground","font-medium","pt-1","-mt-2","border-t","border-border");let s=document.createElement("kbd");s.className="ml-1 rounded-md bg-muted/40 px-2 text-[0.75rem] font-prose center border border-foreground/20 text-muted-foreground inline whitespace-nowrap",s.textContent=G6()?"\u2318":"Ctrl",o.append(document.createTextNode("Jump to defining cell ")),o.append(s),o.append(document.createTextNode(" + Click")),a.append(o)}return a}Ed=new Tl("autocomplete-result",async(e,n)=>{let{sendCodeCompletionRequest:a}=br();await a({id:e,...n})});var r3={param:3,property:2};const hf={asCompletionResult(e,n){return{from:e-n.prefix_length,options:n.options.map(a=>({label:a.name,type:a.type,boost:r3[a.type]??1,info:()=>qy(a.completion_info)})),validFor:/^\w*$/}},asHoverTooltip({position:e,message:n,limitToType:a,excludeTypes:o,exactName:s,showGoToDefinitionHint:c=!1}){let d=a3(n.options,s);if(!d)return;let f=e-n.prefix_length,m=qy(d.completion_info,c);if(m&&!(a&&d.type!==a)&&!(o!=null&&o.includes(d.type)))return{pos:f,html:d.completion_info,end:f+d.name.length,above:!0,create:()=>({dom:m,resize:!1})}}};function a3(e,n){if(e.length!==0){if(e.length===1)return e[0];if(n)return e.find(a=>a.name===n)}}nk=function(e){var n,a,o,s;return[(n=e==null?void 0:e.pylsp)!=null&&n.enabled&&wa("pylsp")||(a=e==null?void 0:e.ty)!=null&&a.enabled&&wa("ty")||(o=e==null?void 0:e.pyrefly)!=null&&o.enabled&&wa("pyrefly")||(s=e==null?void 0:e.basedpyright)!=null&&s.enabled&&wa("basedpyright")?[]:Qh(async(c,d)=>{let f=await Fy({view:c,pos:d,excludeTypes:["tooltip"]});return f===null||f==="cancelled"?null:f},{hideOnChange:!0}),s3]};async function Fy({view:e,pos:n,excludeTypes:a}){var w;let o=En.findElement(e.dom);if(!o)return be.error("Failed to find active cell."),null;let s=En.parse(o.id),{startToken:c,endToken:d}=mf(e.state.doc,n),f=((w=e.state.field(rd,!1))==null?void 0:w.ranges.some(x=>n>=x.from&&n<=x.to))??!1,m=await Ed.request({document:e.state.doc.slice(0,d).toString(),cellId:s});if(!m)return"cancelled";let b=e.state.doc.slice(c,d).toString();return hf.asHoverTooltip({position:d,message:m,exactName:b,excludeTypes:a,showGoToDefinitionHint:f})??null}function mf(e,n){let a=n,o=a>0?e.sliceString(a-1,a):"",s=a<e.length?e.sliceString(a,a+1):"";o==="("&&s===")"&&--a;let c=a,d=a;for(;c>0;){let f=e.sliceString(c-1,c);if(!/\w/.test(f))break;c--}for(;d<e.length;){let f=e.sliceString(d,d+1);if(!/\w/.test(f))break;d++}return{startToken:c,endToken:d}}function i3(e){let{head:n}=e.selection.main,a=e.doc.sliceString(n-1,n);return/\w/.test(a)}var o3=Hh(async(e,n)=>{if(Pe.get(ad).selectedPanel!=="documentation")return;let a=await Fy({view:e,pos:n});a!=="cancelled"&&Pe.set(Ku,{documentation:(a==null?void 0:a.html)??null})},300),s3=Et.updateListener.of(e=>{if(e.selectionSet&&i3(e.state)){let n=e.state.selection.main.head;o3(e.view,n)}}),By=new Set(["FunctionDefinition","LambdaExpression","ArrayComprehensionExpression","SetComprehensionExpression","DictionaryComprehensionExpression","ComprehensionExpression","ClassDefinition"]),l3=new Set(["ClassDefinition"]);function Vy(e,n){e.focus(),requestAnimationFrame(()=>{e.dispatch({selection:{anchor:n,head:n},effects:Et.scrollIntoView(n,{y:"center"})})})}function c3(e,n){let a=Kh(e),o=null;return a.iterate({enter:s=>{if(o!==null)return!1;if(s.name==="VariableName"&&e.doc.sliceString(s.from,s.to)===n)return o=s.from,!1;if(s.name==="Comment"||s.name==="String")return!1}}),o}function u3(e,n){let a=[],o=e.resolveInner(n,0);for(;o;)By.has(o.name)&&(a.some(s=>s.type==="FunctionDefinition"||s.type==="LambdaExpression")&&o.name==="ClassDefinition"||a.push({id:o.from,type:o.name})),o=o.parent;return a.push({id:-1,type:"global"}),a}function co(e,n,a){e.push({scopeId:n,from:a})}function d3(e,n){if(e.firstChild())do n(e.node);while(e.nextSibling())}function gf(e,n,a,o,s){switch(e.name){case"VariableName":n.doc.sliceString(e.from,e.to)===a&&co(s,o,e.from);break;case"TupleExpression":case"ArrayExpression":{let c=e.node.cursor();c.firstChild();do gf(c,n,a,o,s);while(c.nextSibling());break}default:break}}function Hy(e,n,a,o,s){let c=e.cursor();c.firstChild();do{if(c.name!=="ParamList")continue;let d=c.node.cursor();d.firstChild();do d.name==="VariableName"&&n.doc.sliceString(d.from,d.to)===a&&co(s,o,d.from);while(d.nextSibling())}while(c.nextSibling())}function f3(e,n,a,o,s){let c=e.cursor();c.firstChild();let d=!1;do if(c.name==="for")d=!0;else{if(d&&c.name==="in")break;d&&gf(c,n,a,o,s)}while(c.nextSibling())}function $y(e,n,a,o,s){let c=e.cursor(),d=c.name,f=c.from,m=By.has(d)?[...o,f]:o,b=m[m.length-1]??-1;switch(d){case"FunctionDefinition":case"ClassDefinition":{let w=e.cursor();w.firstChild();do if(w.name==="VariableName"&&n.doc.sliceString(w.from,w.to)===a){co(s,o[o.length-1]??-1,w.from);break}while(w.nextSibling());d==="FunctionDefinition"&&Hy(e,n,a,f,s);break}case"LambdaExpression":Hy(e,n,a,f,s);break;case"ArrayComprehensionExpression":case"DictionaryComprehensionExpression":case"SetComprehensionExpression":case"ComprehensionExpression":case"ForStatement":f3(e,n,a,b,s);break;case"AssignStatement":{let w=[],x=e.cursor();x.firstChild();do x.name==="AssignOp"&&w.push(x.from);while(x.nextSibling());let S=w[w.length-1];if(S===void 0)break;let E=e.cursor();E.firstChild();do E.from<S&&gf(E,n,a,b,s);while(E.nextSibling());break}case"ImportStatement":{let w=e.cursor();w.firstChild();do w.name==="VariableName"&&n.doc.sliceString(w.from,w.to)===a&&co(s,b,w.from);while(w.nextSibling());break}case"ImportFromStatement":{let w=e.cursor();w.firstChild();let x=!1;do w.name==="import"?x=!0:x&&w.name==="VariableName"&&n.doc.sliceString(w.from,w.to)===a&&co(s,b,w.from);while(w.nextSibling());break}case"TryStatement":case"WithStatement":{let w=e.cursor();w.firstChild();let x=!1;do w.name==="as"?x=!0:x&&w.name==="VariableName"&&n.doc.sliceString(w.from,w.to)===a&&(co(s,b,w.from),x=!1);while(w.nextSibling());break}default:break}d3(c,w=>{$y(w,n,a,m,s)})}function p3(e,n,a){let o=Kh(e),s=[];$y(o,e,n,[],s);let c=Math.max(0,Math.min(a,e.doc.length));for(let d of u3(o,c)){let f=s.filter(m=>m.scopeId===d.id).filter(m=>l3.has(d.type)?m.from<=c:!0).toSorted((m,b)=>m.from-b.from)[0];if(f)return f.from}return null}Nl=function(e,n,a,o=!0){let{state:s}=e,c=null;return a!==void 0&&(c=p3(s,n,a)),c===null&&o&&(c=c3(s,n)),c===null?!1:(Vy(e,c),!0)};function h3(e,n){return Vy(e,e.state.doc.line(n).from),!0}function m3(e){let{from:n,to:a}=e.selection.main;if(n===a){let{startToken:o,endToken:s}=mf(e.doc,n);return{position:o,word:e.doc.sliceString(o,s)}}return{position:n,word:e.doc.sliceString(n,a)}}function g3(e,n){if(!n)return null;let a=e[n];return!a||a.declaredBy.length===0?null:a.declaredBy[0]}function y3(e){return e.startsWith("_")}Vm=function(e){let{state:n}=e,{position:a,word:o}=m3(n);return o?(r_(e),e.dispatch({effects:OI}),Hm(e,o,a)):!1},Hm=function(e,n,a){if(a!==void 0&&Nl(e,n,a,!1))return!0;let o=v3(e,n);return o?Nl(o,n):!1},Bx=function(e,n){let a=Wy(e);return a?h3(a,n):!1};function v3(e,n){if(y3(n))return e;let a=g3(Pe.get(ei),n);return a?Wy(a):null}function Wy(e){var n;return((n=Pe.get(Xe).cellHandles[e].current)==null?void 0:n.editorView)??null}function b3(e){var n=e.Pos;function a(u,h,y){if(h.line===y.line&&h.ch>=y.ch-1){var v=u.getLine(h.line).charCodeAt(h.ch);55296<=v&&v<=55551&&(y.ch+=1)}return{start:h,end:y}}var o=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],s=Object.create(null),c=o.length,d=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],f=_o("");function m(u){u.setOption("disableInput",!0),u.setOption("showCursorWhenSelecting",!1),e.signal(u,"vim-mode-change",{mode:"normal"}),u.on("cursorActivity",Oo),ee(u),e.on(u.getInputField(),"paste",w(u))}function b(u){u.setOption("disableInput",!1),u.off("cursorActivity",Oo),e.off(u.getInputField(),"paste",w(u)),u.state.vim=null,Oa&&clearTimeout(Oa)}function w(u){var h=u.state.vim;return h.onPasteFn||(h.onPasteFn=function(){h.insertMode||(u.setCursor(kt(u.getCursor(),0,1)),zr.enterInsertMode(u,{},h))}),h.onPasteFn}var x=/[\d]/,S=[e.isWordChar,function(u){return u&&!e.isWordChar(u)&&!/\s/.test(u)}],E=[function(u){return/\S/.test(u)}],I=["<",">"],P=["-",'"',".",":","_","/","+"],q=/^\w$/,B=/^[A-Z]$/;try{B=RegExp("^[\\p{Lu}]$","u")}catch{}function V(u,h){return h>=u.firstLine()&&h<=u.lastLine()}function N(u){return/^[a-z]$/.test(u)}function J(u){return"()[]{}".indexOf(u)!=-1}function le(u){return x.test(u)}function A(u){return B.test(u)}function j(u){return/^\s*$/.test(u)}function $(u){return".?!".indexOf(u)!=-1}function oe(u,h){for(var y=0;y<h.length;y++)if(h[y]==u)return!0;return!1}var de={};function he(u,h,y,v,_){if(h===void 0&&!_)throw Error("defaultValue is required unless callback is provided");if(y||(y="string"),de[u]={type:y,defaultValue:h,callback:_},v)for(var k=0;k<v.length;k++)de[v[k]]=de[u];h&&ye(u,h)}function ye(u,h,y,v){var _=de[u];v||(v={});var k=v.scope;if(!_)return Error("Unknown option: "+u);if(_.type=="boolean"){if(h&&h!==!0)return Error("Invalid argument: "+u+"="+h);h!==!1&&(h=!0)}_.callback?(k!=="local"&&_.callback(h,void 0),k!=="global"&&y&&_.callback(h,y)):(k!=="local"&&(_.value=_.type=="boolean"?!!h:h),k!=="global"&&y&&(y.state.vim.options[u]={value:h}))}function ke(u,h,y){var v=de[u];y||(y={});var _=y.scope;if(!v)return Error("Unknown option: "+u);if(v.callback){let k=h&&v.callback(void 0,h);return _!=="global"&&k!==void 0?k:_==="local"?void 0:v.callback()}else return(_!=="global"&&h&&h.state.vim.options[u]||_!=="local"&&v||{}).value}he("filetype",void 0,"string",["ft"],function(u,h){if(h!==void 0)if(u===void 0){let y=h.getOption("mode");return y=="null"?"":y}else{let y=u==""?"null":u;h.setOption("mode",y)}}),he("textwidth",80,"number",["tw"],function(u,h){if(h!==void 0){if(u===void 0)return h.getOption("textwidth");var y=Math.round(u);y>1&&h.setOption("textwidth",y)}});var we=function(){var u=100,h=-1,y=0,v=0,_=Array(u);function k(R,z,D){var te=_[h%u];function Y(Q){var ge=++h%u,me=_[ge];me&&me.clear(),_[ge]=R.setBookmark(Q)}if(te){var K=te.find();K&&!gt(K,z)&&Y(z)}else Y(z);Y(D),y=h,v=h-u+1,v<0&&(v=0)}function T(R,z){h+=z,h>y?h=y:h<v&&(h=v);var D=_[(u+h)%u];if(D&&!D.find()){var te=z>0?1:-1,Y,K=R.getCursor();do if(h+=te,D=_[(u+h)%u],D&&(Y=D.find())&&!gt(K,Y))break;while(h<y&&h>v)}return D}function O(R,z){var D=h,te=T(R,z);return h=D,te&&te.find()}return{cachedCursor:void 0,add:k,find:O,move:T}},ue=function(u){return u?{changes:u.changes,expectCursorActivityForChange:u.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class ie{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=ue()}exitMacroRecordMode(){var h=W.macroModeState;h.onRecordingDone&&h.onRecordingDone(),h.onRecordingDone=void 0,h.isRecording=!1}enterMacroRecordMode(h,y){var v=W.registerController.getRegister(y);if(v){if(v.clear(),this.latestRegister=y,h.openDialog){var _=cn("span",{class:"cm-vim-message"},"recording @"+y);this.onRecordingDone=h.openDialog(_,function(){},{bottom:!0})}this.isRecording=!0}}}function ee(u){return u.state.vim||(u.state.vim={inputState:new Ls,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new n(0,0),head:new n(0,0)},options:{},expectLiteralNext:!1,status:""}),u.state.vim}var W;function Ie(){for(var u in W={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:we(),macroModeState:new ie,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new pc({}),searchHistoryController:new xo,exCommandHistoryController:new xo},de){var h=de[u];h.value=h.defaultValue}}class He{constructor(h,y){this.keyName=h,this.key=y.key,this.ctrlKey=y.ctrlKey,this.altKey=y.altKey,this.metaKey=y.metaKey,this.shiftKey=y.shiftKey}}var et,Fe={enterVimMode:m,leaveVimMode:b,buildKeyMap:function(){},getRegisterController:function(){return W.registerController},resetVimGlobalState_:Ie,getVimGlobalState_:function(){return W},maybeInitVimState_:ee,suppressErrorLogging:!1,InsertModeKey:He,map:function(u,h,y){Kt.map(u,h,y)},unmap:function(u,h){return Kt.unmap(u,h)},noremap:function(u,h,y){Kt.map(u,h,y,!0)},mapclear:function(u){var h=o.length,y=c,v=o.slice(0,h-y);if(o=o.slice(h-y),u)for(var _=v.length-1;_>=0;_--){var k=v[_];if(u!==k.context)if(k.context)this._mapCommand(k);else{var T=["normal","insert","visual"];for(var O in T)if(T[O]!==u){var R=Object.assign({},k);R.context=T[O],this._mapCommand(R)}}}},langmap:gi,vimKeyFromEvent:jr,setOption:ye,getOption:ke,defineOption:he,defineEx:function(u,h,y){if(!h)h=u;else if(u.indexOf(h)!==0)throw Error('(Vim.defineEx) "'+h+'" is not a prefix of "'+u+'", command not registered');Kn[u]=y,Kt.commandMap_[h]={name:u,shortName:h,type:"api"}},handleKey:function(u,h,y){var v=this.findKey(u,h,y);if(typeof v=="function")return v()},multiSelectHandleKey:$r,findKey:function(u,h,y){var v=ee(u),_=u;function k(){var D=W.macroModeState;if(D.isRecording){if(h=="q")return D.exitMacroRecordMode(),mt(_),!0;y!="mapping"&&pr(D,h)}}function T(){if(h=="<Esc>"){if(v.visualMode)An(_);else if(v.insertMode)hn(_);else return;return mt(_),!0}}function O(){if(T())return!0;v.inputState.keyBuffer.push(h);var D=v.inputState.keyBuffer.join(""),te=h.length==1,Y=dr.matchCommand(D,o,v.inputState,"insert"),K=v.inputState.changeQueue;if(Y.type=="none")return mt(_),!1;if(Y.type=="partial"){if(Y.expectLiteralNext&&(v.expectLiteralNext=!0),et&&window.clearTimeout(et),et=te&&window.setTimeout(function(){v.insertMode&&v.inputState.keyBuffer.length&&mt(_)},ke("insertModeEscKeysTimeout")),te){var Q=_.listSelections();(!K||K.removed.length!=Q.length)&&(K=v.inputState.changeQueue=new Os),K.inserted+=h;for(var ge=0;ge<Q.length;ge++){var me=Xt(Q[ge].anchor,Q[ge].head),Re=Sr(Q[ge].anchor,Q[ge].head),xe=_.getRange(me,_.state.overwrite?kt(Re,0,1):Re);K.removed[ge]=(K.removed[ge]||"")+xe}}return!te}else Y.type=="full"&&(v.inputState.keyBuffer.length=0);if(v.expectLiteralNext=!1,et&&window.clearTimeout(et),Y.command&&K){for(var Q=_.listSelections(),ge=0;ge<Q.length;ge++){var Oe=Q[ge].head;_.replaceRange(K.removed[ge]||"",kt(Oe,0,-K.inserted.length),Oe,"+input")}W.macroModeState.lastInsertModeChanges.changes.pop()}return Y.command||mt(_),Y.command}function R(){if(k()||T())return!0;v.inputState.keyBuffer.push(h);var D=v.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(D))return!0;var te=/^(\d*)(.*)$/.exec(D);if(!te)return mt(_),!1;var Y=v.visualMode?"visual":"normal",K=te[2]||te[1];v.inputState.operatorShortcut&&v.inputState.operatorShortcut.slice(-1)==K&&(K=v.inputState.operatorShortcut);var Q=dr.matchCommand(K,o,v.inputState,Y);return Q.type=="none"?(mt(_),!1):Q.type=="partial"?(Q.expectLiteralNext&&(v.expectLiteralNext=!0),!0):Q.type=="clear"?(mt(_),!0):(v.expectLiteralNext=!1,v.inputState.keyBuffer.length=0,te=/^(\d*)(.*)$/.exec(D),te&&te[1]&&te[1]!="0"&&v.inputState.pushRepeatDigit(te[1]),Q.command)}var z=v.insertMode?O():R();if(z===!1)return!v.insertMode&&(h.length===1||e.isMac&&/<A-.>/.test(h))?function(){return!0}:void 0;if(z===!0)return function(){return!0};if(z)return function(){return _.operation(function(){_.curOp.isVimOp=!0;try{if(typeof z!="object")return;z.type=="keyToKey"?Pt(_,z.toKeys,z):dr.processCommand(_,v,z)}catch(D){throw _.state.vim=void 0,ee(_),Fe.suppressErrorLogging||console.log(D),D}return!0})}},handleEx:function(u,h){Kt.processCommand(u,h)},defineMotion:Bf,defineAction:mc,defineOperator:Vf,mapCommand:Lc,_mapCommand:Ir,defineRegister:Ff,exitVisualMode:An,exitInsertMode:hn},Ne=[],Le=!1,De;function Tt(u){if(!De)throw Error("No prompt to send key to");if(u[0]=="<"){var h=u.toLowerCase().slice(1,-1);if(h=h.split("-").pop()||"",h=="lt")u="<";else if(h=="space")u=" ";else if(h=="cr")u=`
57
+ `);a!==o&&this.getTextFromDoc(this.doc).delete(a+n,o-a),f.length>0&&this.getTextFromDoc(this.doc).insert(a+n,f),n+=f.length-(o-a)}),this.doc.commit()}destroy(){var e;(e=this.sub)==null||e.call(this),this.sub=void 0}};function NS(e,n){return{get:()=>n.get(e),sub:a=>n.sub(e,()=>a(n.get(e)))}}function DS(e,{offset:n,body:a=window,behavior:o="smooth"}){let s=(n==null?void 0:n.top)??0,c=(n==null?void 0:n.bottom)??0,d=e.getBoundingClientRect();if(d.top<s){a.scrollBy({top:d.top-s,behavior:o});return}if(d.bottom>window.innerHeight-c){a.scrollBy({top:d.bottom-window.innerHeight+c,behavior:o});return}}Ll=function(e){return e?e.state.field(Vn).type:"python"};function jS(e,n){return!e||Ll(e)===n?!1:e.state.doc.toString().trim()===""?!0:$n[n].isSupported(wr(e))}od=function(e,n,a={}){return!a.force&&!jS(e,n)?!1:(bd(e,{language:n}),n)};function zS(e){return Xa.of([{key:e.getHotkey("cell.format").key,preventDefault:!0,run:n=>(Hu({[n.state.facet(ua)]:n}),!0)},{key:e.getHotkey("cell.viewAsMarkdown").key,preventDefault:!0,run:n=>{let a=od(n,Ll(n)==="markdown"?"python":"markdown",{force:!0});return a==="markdown"&&n.state.facet(st).afterToggleMarkdown(),a!==!1}},{key:e.getHotkey("cell.viewAsSQL").key,preventDefault:!0,run:n=>{let a=od(n,Ll(n)==="sql"?"python":"sql",{force:!0});return a==="sql"&&n.state.facet(st).afterToggleSQL(),a!==!1}}])}ck=function(){return Et.updateListener.of(e=>{if(e.view.hasFocus&&e.heightChanged&&e.docChanged){if(e.transactions.some(n=>n.effects.some(a=>a.is(xs))))return;Ay(e.view,{behavior:"smooth"})}})};function Ay(e,n){let a=e.dom.getElementsByClassName("cm-activeLine cm-line");if(a.length===1){let o=a[0],s=document.getElementById("App");an(s,"App not found"),DS(o,{offset:{top:30,bottom:150},body:s,behavior:n.behavior})}}function qS(){return{}}let FS,BS,Ry;({reducer:FS,createActions:BS,valueAtom:ei,useActions:Ry}=us(qS,{setVariables:(e,n)=>{let a={...e},o={};for(let s of n)o[s.name]={...a[s.name],...s};return o},addVariables:(e,n)=>{let a={...e};for(let o of n)a[o.name]={...a[o.name],...o};return a},setMetadata:(e,n)=>{let a={...e};for(let{name:o,value:s,dataType:c}of n)a[o]&&(a[o]={...a[o],value:s,dataType:c});return a}})),O_=()=>rn(ei),q_=function(){return Ry()},vm=function(e){let n=e.storage||gs;return{getItem(a,o){try{let s=n.getItem(a);if(!s)return o;let c=JSON.parse(s);return e.fromSerializable(c)}catch(s){return be.warn(`Error getting ${a} from storage`,s),o}},setItem:(a,o)=>{n.setItem(a,JSON.stringify(e.toSerializable(o)))},removeItem:a=>{n.removeItem(a)}}},Qu=eg(()=>gs),gm=function(e,n){if(typeof window>"u")return;let a=`__marimo__${n}`;window[a]&&be.warn(`Overwriting existing debug object ${a}`),window[a]=e};var VS={markdown:!0,wasm_layouts:!1,rtc_v2:!1,cache_panel:!1,external_agents:!1};ed=function(e){var n,a;return((a=(n=Mw())==null?void 0:n.experimental)==null?void 0:a[e])??VS[e]};function HS(e,n){br().saveUserConfig({config:{experimental:{[e]:n}}})}gm(HS,"setFeatureFlag"),zl=[{type:"files",Icon:iy,label:"Files",tooltip:"View files",defaultSection:"sidebar",additionalKeywords:["explorer","browser","directory"]},{type:"variables",Icon:Ym,label:"Variables",tooltip:"Explore variables and data sources",defaultSection:"sidebar",additionalKeywords:["state","scope","inspector"]},{type:"packages",Icon:km,label:"Packages",tooltip:"Manage packages",defaultSection:"sidebar",additionalKeywords:["dependencies","pip","install"]},{type:"ai",Icon:cm,label:"AI",tooltip:"Chat & Agents",defaultSection:"sidebar",additionalKeywords:["chat","copilot","assistant"]},{type:"outline",Icon:u0,label:"Outline",tooltip:"View outline",defaultSection:"sidebar",additionalKeywords:["toc","structure","headings"]},{type:"documentation",Icon:o0,label:"Docs",tooltip:"View live docs",defaultSection:"sidebar",additionalKeywords:["reference","api"]},{type:"dependencies",Icon:e0,label:"Dependencies",tooltip:"Explore dependencies",defaultSection:"sidebar",additionalKeywords:["graph","imports"]},{type:"errors",Icon:xm,label:"Errors",tooltip:"View errors",defaultSection:"developer-panel",additionalKeywords:["exceptions","problems","diagnostics"]},{type:"scratchpad",Icon:Bm,label:"Scratchpad",tooltip:"Scratchpad",defaultSection:"developer-panel",additionalKeywords:["scratch","draft","playground"]},{type:"tracing",Icon:ym,label:"Tracing",tooltip:"View tracing",defaultSection:"developer-panel",additionalKeywords:["profiling","performance"]},{type:"secrets",Icon:oy,label:"Secrets",tooltip:"Manage secrets",defaultSection:"developer-panel",hidden:ju(),additionalKeywords:["env","environment","keys","credentials"]},{type:"logs",Icon:Am,label:"Logs",tooltip:"View logs",defaultSection:"developer-panel",additionalKeywords:["console","stdout"]},{type:"terminal",Icon:Um,label:"Terminal",tooltip:"Terminal",hidden:ju(),defaultSection:"developer-panel",requiredCapability:"terminal",additionalKeywords:["shell","console","bash","command"]},{type:"snippets",Icon:sy,label:"Snippets",tooltip:"Snippets",defaultSection:"developer-panel",additionalKeywords:["templates","examples"]},{type:"cache",Icon:tm,label:"Cache",tooltip:"View cache",defaultSection:"developer-panel",hidden:!ed("cache_panel"),additionalKeywords:["memory","memoize"]}],f_=new Map(zl.map(e=>[e.type,e])),Mx=function({panel:e,capabilities:n,aiEnabled:a}){return!!(e.hidden||e.type==="ai"&&!a||e.requiredCapability&&!n[e.requiredCapability])};var $S=Fn(),ff={sidebar:zl.filter(e=>!e.hidden&&e.defaultSection==="sidebar").map(e=>e.type),developerPanel:zl.filter(e=>!e.hidden&&e.defaultSection==="developer-panel").map(e=>e.type)};function WS(e){let n=new Set([...e.sidebar,...e.developerPanel]);return{sidebar:[...e.sidebar,...ff.sidebar.filter(a=>!n.has(a))],developerPanel:[...e.developerPanel,...ff.developerPanel.filter(a=>!n.has(a))]}}lm=Rl("marimo:panel-layout",ff,vm({toSerializable:e=>e,fromSerializable:e=>WS(e)}),{getOnInit:!0});function Py(e){let n=Pe.get(lm);return n.sidebar.includes(e)?"sidebar":n.developerPanel.includes(e)?"developer-panel":null}var My="marimo:sidebar",Ny=new dd(Ow({selectedPanel:Aw().optional().transform(e=>e),isSidebarOpen:Rw(),isDeveloperPanelOpen:Rw().optional().default(!1),selectedDeveloperPanelTab:Aw().optional().default("errors").transform(e=>e)}),US);function US(){return{selectedPanel:"variables",isSidebarOpen:!1,isDeveloperPanelOpen:!1,selectedDeveloperPanelTab:"errors"}}let KS,QS,Dy;({reducer:KS,createActions:QS,valueAtom:ad,useActions:Dy}=us(()=>Ny.get(My),{openApplication:(e,n)=>{let a=Py(n);return a==="sidebar"?{...e,selectedPanel:n,isSidebarOpen:!0}:a==="developer-panel"?{...e,selectedDeveloperPanelTab:n,isDeveloperPanelOpen:!0}:e},toggleApplication:(e,n)=>{let a=Py(n);return a==="sidebar"?{...e,selectedPanel:n,isSidebarOpen:e.isSidebarOpen?e.selectedPanel!==n:!0}:a==="developer-panel"?{...e,selectedDeveloperPanelTab:n,isDeveloperPanelOpen:e.isDeveloperPanelOpen?e.selectedDeveloperPanelTab!==n:!0}:e},toggleSidebarPanel:e=>({...e,isSidebarOpen:!e.isSidebarOpen}),setIsSidebarOpen:(e,n)=>({...e,isSidebarOpen:n}),toggleDeveloperPanel:e=>({...e,isDeveloperPanelOpen:!e.isDeveloperPanelOpen}),setIsDeveloperPanelOpen:(e,n)=>({...e,isDeveloperPanelOpen:n})},[(e,n)=>Ny.set(My,n)])),G_=()=>{let e=(0,$S.c)(2),n=rn(ad);if(n.isSidebarOpen)return n;let a;return e[0]===n?a=e[1]:(a={...n,selectedPanel:void 0},e[0]=n,e[1]=a),a},w_=function(){return Dy()},h0=Ee({terminal:!1,pylsp:!1,basedpyright:!1,ty:!1,pyrefly:!1});function wa(e){var n;return((n=Pe.get(h0))==null?void 0:n[e])??!1}Ku=Ee({documentation:null});var jy=new Set(["FunctionDefinition","LambdaExpression","ArrayComprehensionExpression","SetComprehension","DictionaryComprehensionExpression","ComprehensionExpression","ClassDefinition"]);function GS(e){let n=Kh(e.state);if(!n||ZS(n))return[];let a=new Set(Object.keys(e.variables).filter(E=>{let I=e.variables[E];return I.dataType!=="module"&&!I.declaredBy.includes("setup")&&!I.declaredBy.includes(e.cellId)}));if(a.size===0)return[];let o=[],s=new Map,c=new Map,d=new Map;function f(E,I){var J,le,A,j,$,oe,de,he,ye,ke,we;let P=E.cursor(),q=P.name,B=P.from,V=jy.has(q),N=I;switch(V&&(N=[...I,B],s.set(B,new Set),c.set(B,q)),q){case"FunctionDefinition":{let ue=E.cursor();ue.firstChild();do if(ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=I[I.length-1]??-1;s.has(W)||s.set(W,new Set),(J=s.get(W))==null||J.add(ee);break}while(ue.nextSibling());let ie=E.cursor();ie.firstChild();do if(ie.name==="ParamList"){let ee=ie.node.cursor();ee.firstChild();do if(ee.name==="VariableName"){let W=e.state.doc.sliceString(ee.from,ee.to);(le=s.get(B))==null||le.add(W)}while(ee.nextSibling())}while(ie.nextSibling());break}case"LambdaExpression":{let ue=E.cursor();ue.firstChild();do if(ue.name==="ParamList"){let ie=ue.node.cursor();ie.firstChild();do if(ie.name==="VariableName"){let ee=e.state.doc.sliceString(ie.from,ie.to);(A=s.get(B))==null||A.add(ee)}while(ie.nextSibling())}while(ue.nextSibling());break}case"ArrayComprehensionExpression":case"DictionaryComprehensionExpression":case"SetComprehension":case"ComprehensionExpression":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="for")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to);(j=s.get(B))==null||j.add(ee)}else if(ie&&ue.name==="TupleExpression"){let ee=ue.node.cursor();ee.firstChild();do if(ee.name==="VariableName"){let W=e.state.doc.sliceString(ee.from,ee.to);($=s.get(B))==null||$.add(W)}while(ee.nextSibling())}else ie&&ue.name==="in"&&(ie=!1);while(ue.nextSibling());break}case"ClassDefinition":{let ue=E.cursor();ue.firstChild();do if(ue.name==="VariableName"){let ie=e.state.doc.sliceString(ue.from,ue.to),ee=I[I.length-1]??-1;s.has(ee)||s.set(ee,new Set),(oe=s.get(ee))==null||oe.add(ie);break}while(ue.nextSibling());d.set(B,[]);break}case"AssignStatement":{let ue=E.cursor(),ie=[];ue.firstChild();do ue.name==="AssignOp"&&ie.push(ue.from);while(ue.nextSibling());let ee=ie[ie.length-1],W=E.cursor();W.firstChild();let Ie=N[N.length-1]??-1;do W.from<ee&&pf(W,{currentScope:Ie,state:e.state,allDeclarations:s,scopeTypes:c,classLevelDeclarations:d,assignmentPosition:P.to});while(W.nextSibling());break}case"ForStatement":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="for")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=N[N.length-1]??-1;s.has(W)||s.set(W,new Set),(de=s.get(W))==null||de.add(ee)}else ie&&ue.name==="in"&&(ie=!1);while(ue.nextSibling());break}case"ImportStatement":{let ue=E.cursor();ue.firstChild();do if(ue.name==="VariableName"){let ie=e.state.doc.sliceString(ue.from,ue.to),ee=N[N.length-1]??-1;s.has(ee)||s.set(ee,new Set),(he=s.get(ee))==null||he.add(ie)}while(ue.nextSibling());break}case"ImportFromStatement":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="import")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=N[N.length-1]??-1;s.has(W)||s.set(W,new Set),(ye=s.get(W))==null||ye.add(ee)}while(ue.nextSibling());break}case"TryStatement":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="as")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=N[N.length-1]??-1;s.has(W)||s.set(W,new Set),(ke=s.get(W))==null||ke.add(ee),ie=!1}while(ue.nextSibling());break}case"WithStatement":{let ue=E.cursor();ue.firstChild();let ie=!1;do if(ue.name==="as")ie=!0;else if(ie&&ue.name==="VariableName"){let ee=e.state.doc.sliceString(ue.from,ue.to),W=N[N.length-1]??-1;s.has(W)||s.set(W,new Set),(we=s.get(W))==null||we.add(ee),ie=!1}while(ue.nextSibling());break}}S(P,ue=>{f(ue,N)})}function m(E,I,P){let q=d.get(I);return q?q.some(([B,V])=>B===E&&V<P):!1}function b(E,I,P){var q,B;for(let V of I)if(c.get(V)==="ClassDefinition"){if(m(E,V,P))return!0}else if((q=s.get(V))!=null&&q.has(E))return!0;return((B=s.get(-1))==null?void 0:B.has(E))??!1}function w(E,I){let P=E.cursor(),q=P.name,B=P.from,V=jy.has(q),N=I;if(V&&(N=[...I,B]),q==="VariableName"){let J=e.state.doc.sliceString(P.from,P.to);x(J,P)&&(b(J,N,P.from)||o.push({from:P.from,to:P.to,variableName:J}))}S(P,J=>{w(J,N)})}function x(E,I){return a.has(E)&&!YS(I)&&!JS(I)&&!XS(I)}function S(E,I){if(E.firstChild())do I(E.node);while(E.nextSibling())}return f(n,[]),w(n,[]),o}function JS(e){let n=e.node.cursor();if(n.moveTo(e.from),n.parent()&&n.name==="CallExpression"&&n.firstChild())do if(n.name==="ArgList"&&n.firstChild()){do if(n.from===e.from&&n.to===e.to)return n.nextSibling()&&n.name==="AssignOp";while(n.nextSibling());break}while(n.nextSibling());return!1}function XS(e){let n=e.node.cursor();if(n.parent()&&n.name==="AssignStatement"){let a=n.node.cursor();a.firstChild();let o=-1;do if(a.name==="AssignOp"){o=a.from;break}while(a.nextSibling());return o!==-1&&e.from<o}return!1}function YS(e){let n=e.node.cursor();return!!(n.prevSibling()&&n.name===".")}function ZS(e){let n=e.cursor();do if(n.name==="\u26A0"||n.type.isError)return!0;while(n.next());return!1}function pf(e,n){var a;switch(e.name){case"VariableName":{let o=n.state.doc.sliceString(e.from,e.to);if(n.currentScope!==-1&&n.scopeTypes.get(n.currentScope)==="ClassDefinition"){let s=n.classLevelDeclarations.get(n.currentScope);s&&s.push([o,n.assignmentPosition])}else n.allDeclarations.has(n.currentScope)||n.allDeclarations.set(n.currentScope,new Set),(a=n.allDeclarations.get(n.currentScope))==null||a.add(o);break}case"TupleExpression":{let o=e.node.cursor();o.firstChild();do pf(o,n);while(o.nextSibling());break}case"ArrayExpression":{let o=e.node.cursor();o.firstChild();do pf(o,n);while(o.nextSibling());break}}}var e3=ca.mark({class:"mo-cm-reactive-reference"});bx=ca.mark({class:"mo-cm-reactive-reference-hover"});var zy=la.define(),t3=class{constructor(e,n){ve(this,"highlightDebounceMs",300);this.view=e,this.cellId=n,this.scheduleHighlighting=Hh(()=>{this.runHighlighting()},this.highlightDebounceMs),this.variablesUnsubscribe=Pe.sub(ei,()=>{this.scheduleHighlighting()}),this.scheduleHighlighting()}update(e){(e.docChanged||e.focusChanged)&&this.scheduleHighlighting()}destroy(){this.scheduleHighlighting.cancel(),this.variablesUnsubscribe()}runHighlighting(){let e=GS({state:this.view.state,cellId:this.cellId,variables:Pe.get(ei)});e.length>0&&be.debug(`Found ${e.length} reactive variables in cell ${this.cellId}`),queueMicrotask(()=>{this.view.dispatch({effects:zy.of(e)})})}};rd=ls.define({create(){return{decorations:ca.none,ranges:[]}},update(e,n){let a={decorations:e.decorations.map(n.changes),ranges:e.ranges};for(let o of n.effects)o.is(zy)&&(a={decorations:ca.set(o.value.map(s=>e3.range(s.from,s.to))),ranges:o.value});return a},provide:e=>Et.decorations.from(e,n=>n.decorations)});function n3(e){return[rd,Qi.define(n=>new t3(n,e))]}ok=function(e,n){return n?n3(e):[]};function qy(e,n=!1){if(!e)return null;let a=document.createElement("span");if(a.classList.add("mo-cm-tooltip"),a.classList.add("docs-documentation"),n&&a.classList.add("cm-tooltip-section"),a.style.display="flex",a.style.flexDirection="column",a.style.gap=".8rem",a.innerHTML=e,n){let o=document.createElement("div");o.classList.add("text-xs","text-muted-foreground","font-medium","pt-1","-mt-2","border-t","border-border");let s=document.createElement("kbd");s.className="ml-1 rounded-md bg-muted/40 px-2 text-[0.75rem] font-prose center border border-foreground/20 text-muted-foreground inline whitespace-nowrap",s.textContent=G6()?"\u2318":"Ctrl",o.append(document.createTextNode("Jump to defining cell ")),o.append(s),o.append(document.createTextNode(" + Click")),a.append(o)}return a}Ed=new Tl("autocomplete-result",async(e,n)=>{let{sendCodeCompletionRequest:a}=br();await a({id:e,...n})});var r3={param:3,property:2};const hf={asCompletionResult(e,n){return{from:e-n.prefix_length,options:n.options.map(a=>({label:a.name,type:a.type,boost:r3[a.type]??1,info:()=>qy(a.completion_info)})),validFor:/^\w*$/}},asHoverTooltip({position:e,message:n,limitToType:a,excludeTypes:o,exactName:s,showGoToDefinitionHint:c=!1}){let d=a3(n.options,s);if(!d)return;let f=e-n.prefix_length,m=qy(d.completion_info,c);if(m&&!(a&&d.type!==a)&&!(o!=null&&o.includes(d.type)))return{pos:f,html:d.completion_info,end:f+d.name.length,above:!0,create:()=>({dom:m,resize:!1})}}};function a3(e,n){if(e.length!==0){if(e.length===1)return e[0];if(n)return e.find(a=>a.name===n)}}nk=function(e){var n,a,o,s;return[(n=e==null?void 0:e.pylsp)!=null&&n.enabled&&wa("pylsp")||(a=e==null?void 0:e.ty)!=null&&a.enabled&&wa("ty")||(o=e==null?void 0:e.pyrefly)!=null&&o.enabled&&wa("pyrefly")||(s=e==null?void 0:e.basedpyright)!=null&&s.enabled&&wa("basedpyright")?[]:Qh(async(c,d)=>{let f=await Fy({view:c,pos:d,excludeTypes:["tooltip"]});return f===null||f==="cancelled"?null:f},{hideOnChange:!0}),s3]};async function Fy({view:e,pos:n,excludeTypes:a}){var w;let o=En.findElement(e.dom);if(!o)return be.error("Failed to find active cell."),null;let s=En.parse(o.id),{startToken:c,endToken:d}=mf(e.state.doc,n),f=((w=e.state.field(rd,!1))==null?void 0:w.ranges.some(x=>n>=x.from&&n<=x.to))??!1,m=await Ed.request({document:e.state.doc.slice(0,d).toString(),cellId:s});if(!m)return"cancelled";let b=e.state.doc.slice(c,d).toString();return hf.asHoverTooltip({position:d,message:m,exactName:b,excludeTypes:a,showGoToDefinitionHint:f})??null}function mf(e,n){let a=n,o=a>0?e.sliceString(a-1,a):"",s=a<e.length?e.sliceString(a,a+1):"";o==="("&&s===")"&&--a;let c=a,d=a;for(;c>0;){let f=e.sliceString(c-1,c);if(!/\w/.test(f))break;c--}for(;d<e.length;){let f=e.sliceString(d,d+1);if(!/\w/.test(f))break;d++}return{startToken:c,endToken:d}}function i3(e){let{head:n}=e.selection.main,a=e.doc.sliceString(n-1,n);return/\w/.test(a)}var o3=Hh(async(e,n)=>{if(Pe.get(ad).selectedPanel!=="documentation")return;let a=await Fy({view:e,pos:n});a!=="cancelled"&&Pe.set(Ku,{documentation:(a==null?void 0:a.html)??null})},300),s3=Et.updateListener.of(e=>{if(e.selectionSet&&i3(e.state)){let n=e.state.selection.main.head;o3(e.view,n)}}),By=new Set(["FunctionDefinition","LambdaExpression","ArrayComprehensionExpression","SetComprehensionExpression","DictionaryComprehensionExpression","ComprehensionExpression","ClassDefinition"]),l3=new Set(["ClassDefinition"]);function Vy(e,n){requestAnimationFrame(()=>{e.focus(),e.dispatch({selection:{anchor:n,head:n},effects:Et.scrollIntoView(n,{y:"center"})})})}function c3(e,n){let a=Kh(e),o=null;return a.iterate({enter:s=>{if(o!==null)return!1;if(s.name==="VariableName"&&e.doc.sliceString(s.from,s.to)===n)return o=s.from,!1;if(s.name==="Comment"||s.name==="String")return!1}}),o}function u3(e,n){let a=[],o=e.resolveInner(n,0);for(;o;)By.has(o.name)&&(a.some(s=>s.type==="FunctionDefinition"||s.type==="LambdaExpression")&&o.name==="ClassDefinition"||a.push({id:o.from,type:o.name})),o=o.parent;return a.push({id:-1,type:"global"}),a}function co(e,n,a){e.push({scopeId:n,from:a})}function d3(e,n){if(e.firstChild())do n(e.node);while(e.nextSibling())}function gf(e,n,a,o,s){switch(e.name){case"VariableName":n.doc.sliceString(e.from,e.to)===a&&co(s,o,e.from);break;case"TupleExpression":case"ArrayExpression":{let c=e.node.cursor();c.firstChild();do gf(c,n,a,o,s);while(c.nextSibling());break}default:break}}function Hy(e,n,a,o,s){let c=e.cursor();c.firstChild();do{if(c.name!=="ParamList")continue;let d=c.node.cursor();d.firstChild();do d.name==="VariableName"&&n.doc.sliceString(d.from,d.to)===a&&co(s,o,d.from);while(d.nextSibling())}while(c.nextSibling())}function f3(e,n,a,o,s){let c=e.cursor();c.firstChild();let d=!1;do if(c.name==="for")d=!0;else{if(d&&c.name==="in")break;d&&gf(c,n,a,o,s)}while(c.nextSibling())}function $y(e,n,a,o,s){let c=e.cursor(),d=c.name,f=c.from,m=By.has(d)?[...o,f]:o,b=m[m.length-1]??-1;switch(d){case"FunctionDefinition":case"ClassDefinition":{let w=e.cursor();w.firstChild();do if(w.name==="VariableName"&&n.doc.sliceString(w.from,w.to)===a){co(s,o[o.length-1]??-1,w.from);break}while(w.nextSibling());d==="FunctionDefinition"&&Hy(e,n,a,f,s);break}case"LambdaExpression":Hy(e,n,a,f,s);break;case"ArrayComprehensionExpression":case"DictionaryComprehensionExpression":case"SetComprehensionExpression":case"ComprehensionExpression":case"ForStatement":f3(e,n,a,b,s);break;case"AssignStatement":{let w=[],x=e.cursor();x.firstChild();do x.name==="AssignOp"&&w.push(x.from);while(x.nextSibling());let S=w[w.length-1];if(S===void 0)break;let E=e.cursor();E.firstChild();do E.from<S&&gf(E,n,a,b,s);while(E.nextSibling());break}case"ImportStatement":{let w=e.cursor();w.firstChild();do w.name==="VariableName"&&n.doc.sliceString(w.from,w.to)===a&&co(s,b,w.from);while(w.nextSibling());break}case"ImportFromStatement":{let w=e.cursor();w.firstChild();let x=!1;do w.name==="import"?x=!0:x&&w.name==="VariableName"&&n.doc.sliceString(w.from,w.to)===a&&co(s,b,w.from);while(w.nextSibling());break}case"TryStatement":case"WithStatement":{let w=e.cursor();w.firstChild();let x=!1;do w.name==="as"?x=!0:x&&w.name==="VariableName"&&n.doc.sliceString(w.from,w.to)===a&&(co(s,b,w.from),x=!1);while(w.nextSibling());break}default:break}d3(c,w=>{$y(w,n,a,m,s)})}function p3(e,n,a){let o=Kh(e),s=[];$y(o,e,n,[],s);let c=Math.max(0,Math.min(a,e.doc.length));for(let d of u3(o,c)){let f=s.filter(m=>m.scopeId===d.id).filter(m=>l3.has(d.type)?m.from<=c:!0).toSorted((m,b)=>m.from-b.from)[0];if(f)return f.from}return null}Nl=function(e,n,a,o=!0){let{state:s}=e,c=null;return a!==void 0&&(c=p3(s,n,a)),c===null&&o&&(c=c3(s,n)),c===null?!1:(Vy(e,c),!0)};function h3(e,n){return Vy(e,e.state.doc.line(n).from),!0}function m3(e){let{from:n,to:a}=e.selection.main;if(n===a){let{startToken:o,endToken:s}=mf(e.doc,n);return{position:o,word:e.doc.sliceString(o,s)}}return{position:n,word:e.doc.sliceString(n,a)}}function g3(e,n){if(!n)return null;let a=e[n];return!a||a.declaredBy.length===0?null:a.declaredBy[0]}function y3(e){return e.startsWith("_")}Vm=function(e){let{state:n}=e,{position:a,word:o}=m3(n);return o?(r_(e),e.dispatch({effects:OI}),Hm(e,o,a)):!1},Hm=function(e,n,a){if(a!==void 0&&Nl(e,n,a,!1))return!0;let o=v3(e,n);return o?Nl(o,n):!1},Bx=function(e,n){let a=Wy(e);return a?h3(a,n):!1};function v3(e,n){if(y3(n))return e;let a=g3(Pe.get(ei),n);return a?Wy(a):null}function Wy(e){var n;return((n=Pe.get(Xe).cellHandles[e].current)==null?void 0:n.editorView)??null}function b3(e){var n=e.Pos;function a(u,h,y){if(h.line===y.line&&h.ch>=y.ch-1){var v=u.getLine(h.line).charCodeAt(h.ch);55296<=v&&v<=55551&&(y.ch+=1)}return{start:h,end:y}}var o=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],s=Object.create(null),c=o.length,d=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],f=_o("");function m(u){u.setOption("disableInput",!0),u.setOption("showCursorWhenSelecting",!1),e.signal(u,"vim-mode-change",{mode:"normal"}),u.on("cursorActivity",Oo),ee(u),e.on(u.getInputField(),"paste",w(u))}function b(u){u.setOption("disableInput",!1),u.off("cursorActivity",Oo),e.off(u.getInputField(),"paste",w(u)),u.state.vim=null,Oa&&clearTimeout(Oa)}function w(u){var h=u.state.vim;return h.onPasteFn||(h.onPasteFn=function(){h.insertMode||(u.setCursor(kt(u.getCursor(),0,1)),zr.enterInsertMode(u,{},h))}),h.onPasteFn}var x=/[\d]/,S=[e.isWordChar,function(u){return u&&!e.isWordChar(u)&&!/\s/.test(u)}],E=[function(u){return/\S/.test(u)}],I=["<",">"],P=["-",'"',".",":","_","/","+"],q=/^\w$/,B=/^[A-Z]$/;try{B=RegExp("^[\\p{Lu}]$","u")}catch{}function V(u,h){return h>=u.firstLine()&&h<=u.lastLine()}function N(u){return/^[a-z]$/.test(u)}function J(u){return"()[]{}".indexOf(u)!=-1}function le(u){return x.test(u)}function A(u){return B.test(u)}function j(u){return/^\s*$/.test(u)}function $(u){return".?!".indexOf(u)!=-1}function oe(u,h){for(var y=0;y<h.length;y++)if(h[y]==u)return!0;return!1}var de={};function he(u,h,y,v,_){if(h===void 0&&!_)throw Error("defaultValue is required unless callback is provided");if(y||(y="string"),de[u]={type:y,defaultValue:h,callback:_},v)for(var k=0;k<v.length;k++)de[v[k]]=de[u];h&&ye(u,h)}function ye(u,h,y,v){var _=de[u];v||(v={});var k=v.scope;if(!_)return Error("Unknown option: "+u);if(_.type=="boolean"){if(h&&h!==!0)return Error("Invalid argument: "+u+"="+h);h!==!1&&(h=!0)}_.callback?(k!=="local"&&_.callback(h,void 0),k!=="global"&&y&&_.callback(h,y)):(k!=="local"&&(_.value=_.type=="boolean"?!!h:h),k!=="global"&&y&&(y.state.vim.options[u]={value:h}))}function ke(u,h,y){var v=de[u];y||(y={});var _=y.scope;if(!v)return Error("Unknown option: "+u);if(v.callback){let k=h&&v.callback(void 0,h);return _!=="global"&&k!==void 0?k:_==="local"?void 0:v.callback()}else return(_!=="global"&&h&&h.state.vim.options[u]||_!=="local"&&v||{}).value}he("filetype",void 0,"string",["ft"],function(u,h){if(h!==void 0)if(u===void 0){let y=h.getOption("mode");return y=="null"?"":y}else{let y=u==""?"null":u;h.setOption("mode",y)}}),he("textwidth",80,"number",["tw"],function(u,h){if(h!==void 0){if(u===void 0)return h.getOption("textwidth");var y=Math.round(u);y>1&&h.setOption("textwidth",y)}});var we=function(){var u=100,h=-1,y=0,v=0,_=Array(u);function k(R,z,D){var te=_[h%u];function Y(Q){var ge=++h%u,me=_[ge];me&&me.clear(),_[ge]=R.setBookmark(Q)}if(te){var K=te.find();K&&!gt(K,z)&&Y(z)}else Y(z);Y(D),y=h,v=h-u+1,v<0&&(v=0)}function T(R,z){h+=z,h>y?h=y:h<v&&(h=v);var D=_[(u+h)%u];if(D&&!D.find()){var te=z>0?1:-1,Y,K=R.getCursor();do if(h+=te,D=_[(u+h)%u],D&&(Y=D.find())&&!gt(K,Y))break;while(h<y&&h>v)}return D}function O(R,z){var D=h,te=T(R,z);return h=D,te&&te.find()}return{cachedCursor:void 0,add:k,find:O,move:T}},ue=function(u){return u?{changes:u.changes,expectCursorActivityForChange:u.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class ie{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=ue()}exitMacroRecordMode(){var h=W.macroModeState;h.onRecordingDone&&h.onRecordingDone(),h.onRecordingDone=void 0,h.isRecording=!1}enterMacroRecordMode(h,y){var v=W.registerController.getRegister(y);if(v){if(v.clear(),this.latestRegister=y,h.openDialog){var _=cn("span",{class:"cm-vim-message"},"recording @"+y);this.onRecordingDone=h.openDialog(_,function(){},{bottom:!0})}this.isRecording=!0}}}function ee(u){return u.state.vim||(u.state.vim={inputState:new Ls,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new n(0,0),head:new n(0,0)},options:{},expectLiteralNext:!1,status:""}),u.state.vim}var W;function Ie(){for(var u in W={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:we(),macroModeState:new ie,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new pc({}),searchHistoryController:new xo,exCommandHistoryController:new xo},de){var h=de[u];h.value=h.defaultValue}}class He{constructor(h,y){this.keyName=h,this.key=y.key,this.ctrlKey=y.ctrlKey,this.altKey=y.altKey,this.metaKey=y.metaKey,this.shiftKey=y.shiftKey}}var et,Fe={enterVimMode:m,leaveVimMode:b,buildKeyMap:function(){},getRegisterController:function(){return W.registerController},resetVimGlobalState_:Ie,getVimGlobalState_:function(){return W},maybeInitVimState_:ee,suppressErrorLogging:!1,InsertModeKey:He,map:function(u,h,y){Kt.map(u,h,y)},unmap:function(u,h){return Kt.unmap(u,h)},noremap:function(u,h,y){Kt.map(u,h,y,!0)},mapclear:function(u){var h=o.length,y=c,v=o.slice(0,h-y);if(o=o.slice(h-y),u)for(var _=v.length-1;_>=0;_--){var k=v[_];if(u!==k.context)if(k.context)this._mapCommand(k);else{var T=["normal","insert","visual"];for(var O in T)if(T[O]!==u){var R=Object.assign({},k);R.context=T[O],this._mapCommand(R)}}}},langmap:gi,vimKeyFromEvent:jr,setOption:ye,getOption:ke,defineOption:he,defineEx:function(u,h,y){if(!h)h=u;else if(u.indexOf(h)!==0)throw Error('(Vim.defineEx) "'+h+'" is not a prefix of "'+u+'", command not registered');Kn[u]=y,Kt.commandMap_[h]={name:u,shortName:h,type:"api"}},handleKey:function(u,h,y){var v=this.findKey(u,h,y);if(typeof v=="function")return v()},multiSelectHandleKey:$r,findKey:function(u,h,y){var v=ee(u),_=u;function k(){var D=W.macroModeState;if(D.isRecording){if(h=="q")return D.exitMacroRecordMode(),mt(_),!0;y!="mapping"&&pr(D,h)}}function T(){if(h=="<Esc>"){if(v.visualMode)An(_);else if(v.insertMode)hn(_);else return;return mt(_),!0}}function O(){if(T())return!0;v.inputState.keyBuffer.push(h);var D=v.inputState.keyBuffer.join(""),te=h.length==1,Y=dr.matchCommand(D,o,v.inputState,"insert"),K=v.inputState.changeQueue;if(Y.type=="none")return mt(_),!1;if(Y.type=="partial"){if(Y.expectLiteralNext&&(v.expectLiteralNext=!0),et&&window.clearTimeout(et),et=te&&window.setTimeout(function(){v.insertMode&&v.inputState.keyBuffer.length&&mt(_)},ke("insertModeEscKeysTimeout")),te){var Q=_.listSelections();(!K||K.removed.length!=Q.length)&&(K=v.inputState.changeQueue=new Os),K.inserted+=h;for(var ge=0;ge<Q.length;ge++){var me=Xt(Q[ge].anchor,Q[ge].head),Re=Sr(Q[ge].anchor,Q[ge].head),xe=_.getRange(me,_.state.overwrite?kt(Re,0,1):Re);K.removed[ge]=(K.removed[ge]||"")+xe}}return!te}else Y.type=="full"&&(v.inputState.keyBuffer.length=0);if(v.expectLiteralNext=!1,et&&window.clearTimeout(et),Y.command&&K){for(var Q=_.listSelections(),ge=0;ge<Q.length;ge++){var Oe=Q[ge].head;_.replaceRange(K.removed[ge]||"",kt(Oe,0,-K.inserted.length),Oe,"+input")}W.macroModeState.lastInsertModeChanges.changes.pop()}return Y.command||mt(_),Y.command}function R(){if(k()||T())return!0;v.inputState.keyBuffer.push(h);var D=v.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(D))return!0;var te=/^(\d*)(.*)$/.exec(D);if(!te)return mt(_),!1;var Y=v.visualMode?"visual":"normal",K=te[2]||te[1];v.inputState.operatorShortcut&&v.inputState.operatorShortcut.slice(-1)==K&&(K=v.inputState.operatorShortcut);var Q=dr.matchCommand(K,o,v.inputState,Y);return Q.type=="none"?(mt(_),!1):Q.type=="partial"?(Q.expectLiteralNext&&(v.expectLiteralNext=!0),!0):Q.type=="clear"?(mt(_),!0):(v.expectLiteralNext=!1,v.inputState.keyBuffer.length=0,te=/^(\d*)(.*)$/.exec(D),te&&te[1]&&te[1]!="0"&&v.inputState.pushRepeatDigit(te[1]),Q.command)}var z=v.insertMode?O():R();if(z===!1)return!v.insertMode&&(h.length===1||e.isMac&&/<A-.>/.test(h))?function(){return!0}:void 0;if(z===!0)return function(){return!0};if(z)return function(){return _.operation(function(){_.curOp.isVimOp=!0;try{if(typeof z!="object")return;z.type=="keyToKey"?Pt(_,z.toKeys,z):dr.processCommand(_,v,z)}catch(D){throw _.state.vim=void 0,ee(_),Fe.suppressErrorLogging||console.log(D),D}return!0})}},handleEx:function(u,h){Kt.processCommand(u,h)},defineMotion:Bf,defineAction:mc,defineOperator:Vf,mapCommand:Lc,_mapCommand:Ir,defineRegister:Ff,exitVisualMode:An,exitInsertMode:hn},Ne=[],Le=!1,De;function Tt(u){if(!De)throw Error("No prompt to send key to");if(u[0]=="<"){var h=u.toLowerCase().slice(1,-1);if(h=h.split("-").pop()||"",h=="lt")u="<";else if(h=="space")u=" ";else if(h=="cr")u=`
58
58
  `;else if(On[h]){var y=De.value||"",v={key:On[h],target:{value:y,selectionEnd:y.length,selectionStart:y.length}};De.onKeyDown&&De.onKeyDown(v,De.value,k),De&&De.onKeyUp&&De.onKeyUp(v,De.value,k);return}}if(u==`
59
59
  `){var _=De;De=null,_.onClose&&_.onClose(_.value)}else De.value=(De.value||"")+u;function k(T){De&&(typeof T=="string"?De.value=T:De=null)}}function Pt(u,h,y){var v=Le;if(y){if(Ne.indexOf(y)!=-1)return;Ne.push(y),Le=y.noremap!=0}try{for(var _=ee(u),k=/<(?:[CSMA]-)*\w+>|./gi,T;T=k.exec(h);){var O=T[0],R=_.insertMode;if(De){Tt(O);continue}if(!Fe.handleKey(u,O,"mapping")&&R&&_.insertMode){if(O[0]=="<"){var z=O.toLowerCase().slice(1,-1);if(z=z.split("-").pop()||"",z=="lt")O="<";else if(z=="space")O=" ";else if(z=="cr")O=`
60
60
  `;else if(On.hasOwnProperty(z)){O=On[z],Ii(u,O);continue}else O=O[0],k.lastIndex=T.index+1}u.replaceSelection(O)}}}finally{if(Ne.pop(),Le=Ne.length?v:!1,!Ne.length&&De){var D=De;De=null,Ia(u,D)}}}var _a={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},wo={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},On={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(_a)).forEach(function(u){On[(_a[u]||"").toLowerCase()]=On[u.toLowerCase()]=u});function jr(u,h){var k;var y=u.key;if(!wo[y]){y.length>1&&y[0]=="n"&&(y=y.replace("Numpad","")),y=_a[y]||y;var v="";if(u.ctrlKey&&(v+="C-"),u.altKey&&(v+="A-"),u.metaKey&&(v+="M-"),e.isMac&&v=="A-"&&y.length==1&&(v=v.slice(2)),(v||y.length>1)&&u.shiftKey&&(v+="S-"),h&&!h.expectLiteralNext&&y.length==1){if(f.keymap&&y in f.keymap)(f.remapCtrl!=0||!v)&&(y=f.keymap[y]);else if(y.charCodeAt(0)>128&&!s[y]){var _=((k=u.code)==null?void 0:k.slice(-1))||"";u.shiftKey||(_=_.toLowerCase()),_&&(y=_,!v&&u.altKey&&(v="A-"))}}return v+=y,v.length>1&&(v="<"+v+">"),v}}function gi(u,h){f.string!==u&&(f=_o(u)),f.remapCtrl=h}function _o(u){let h={};if(!u)return{keymap:h,string:""};function y(v){return v.split(/\\?(.)/).filter(Boolean)}return u.split(/((?:[^\\,]|\\.)+),/).map(v=>{if(!v)return;let _=v.split(/((?:[^\\;]|\\.)+);/);if(_.length==3){let k=y(_[1]),T=y(_[2]);if(k.length!==T.length)return;for(let O=0;O<k.length;++O)h[k[O]]=T[O]}else if(_.length==1){let k=y(v);if(k.length%2!=0)return;for(let T=0;T<k.length;T+=2)h[k[T]]=k[T+1]}}),{keymap:h,string:u}}he("langmap",void 0,"string",["lmap"],function(u,h){if(u===void 0)return f.string;gi(u)});class Ls{constructor(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=void 0,this.changeQueue=null}pushRepeatDigit(h){this.operator?this.motionRepeat=this.motionRepeat.concat(h):this.prefixRepeat=this.prefixRepeat.concat(h)}getRepeat(){var h=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(h=1,this.prefixRepeat.length>0&&(h*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(h*=parseInt(this.motionRepeat.join(""),10))),h}}function mt(u,h){u.state.vim.inputState=new Ls,u.state.vim.expectLiteralNext=!1,e.signal(u,"vim-command-done",h)}function Os(){this.removed=[],this.inserted=""}class vn{constructor(h,y,v){this.clear(),this.keyBuffer=[h||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!y,this.blockwise=!!v}setText(h,y,v){this.keyBuffer=[h||""],this.linewise=!!y,this.blockwise=!!v}pushText(h,y){y&&(this.linewise||this.keyBuffer.push(`
@@ -125,7 +125,7 @@ mark line col
125
125
  `).length):a++}if(a<n)return e;let s=o+1,c={channel:"stderr",mimetype:"text/html",data:`<pre>Streaming output truncated to last ${n} lines.
126
126
  </pre>`,timestamp:-1},d=e[s];if(d==null)return[c,...e.slice(s+1)];if(d.mimetype==="text/plain"){an(typeof d.data=="string","expected string");let f=d.data.split(`
127
127
  `),m=n-(a-f.length);return[c,{...d,data:f.slice(-m).join(`
128
- `)},...e.slice(s+1)]}return[c,...e.slice(s+1)]}function IT(e,n){let a={...e};switch(n.status){case"queued":a.interrupted=!1,a.errored=!1,a.runElapsedTimeMs=null,a.debuggerActive=!1;break;case"running":a.interrupted=!1,e.stopped&&(a.output=null),a.status==="queued"&&(a.consoleOutputs=[]),a.stopped=!1,a.runStartTimestamp=n.timestamp,a.lastRunStartTimestamp=n.timestamp;break;case"idle":e.runStartTimestamp&&(a.runElapsedTimeMs=t0.fromSeconds((n.timestamp??0)-e.runStartTimestamp).toMilliseconds(),a.runStartTimestamp=null,a.staleInputs=!1),!e.lastRunStartTimestamp&&n.timestamp&&(a.lastRunStartTimestamp=n.timestamp),a.debuggerActive=!1;break;case null:break;case"disabled-transitively":break;case void 0:break;default:ds(n.status)}a.output=n.output??a.output,a.staleInputs=n.stale_inputs??a.staleInputs,a.status=n.status??a.status,a.serialization=n.serialization;let o=!1;n.output!=null&&n.output.mimetype==="application/vnd.marimo+error"&&((a.status==="queued"||a.status==="running")&&(a.status="idle"),an(Array.isArray(n.output.data),"Expected error output data to be an array"),n.output.data.some(f=>f.type==="interruption")?(a.interrupted=!0,o=!0):n.output.data.some(f=>f.type.includes("ancestor"))?a.stopped=!0:a.errored=!0);let s=e.consoleOutputs;o&&(a.debuggerActive=!1,s=s.map(f=>f.channel==="stdin"?{...f,response:f.response??""}:f));let c=n.console;c!=null&&(s=CT(Array.isArray(c)?c:[...s,c])),a.consoleOutputs=s,a.outline=y0(a.output);let d=[n.console].flat().filter(Boolean).filter(f=>f.channel==="pdb");return d.length>0&&d.some(f=>f.data==="start")&&(a.debuggerActive=!0),a}function LT(e){let n={...e};return e.status!=="disabled-transitively"&&(n.status="queued"),n.interrupted=!1,n.errored=!1,n.runElapsedTimeMs=null,n.debuggerActive=!1,n}jm=function(e){return e==="running"||e==="queued"},Ex=function(e,n){let{status:a,output:o,runStartTimestamp:s,interrupted:c,staleInputs:d}=e;if(c)return!1;if(n)return!0;let f=jm(a),m=a==="running"&&o!==null&&s!==null&&(o.timestamp??0)>s;return f&&!m?!0:d},vx=function(){let e=Pe.get(xd);return Ju(e,"internal-error: initial mode not found"),an(e!=="present","internal-error: initial mode cannot be 'present'"),e},xx=function(e){return e==="read"||e==="home"||e==="gallery"?e:e==="edit"?"present":"edit"},d0=Ee({mode:Nw()?"read":"not-set",cellAnchor:null}),xd=Ee(void 0),s0=Ee(!1),qx=function(){let{mode:e}=rn(d0);return e!=="read"};function pi(e,n){if(!e){be.warn("getCell: cellId is undefined");return}let a=n.cellData[e];if(!a){be.warn(`getCell: cell ${e} not found in state`);return}return a}function X1(e,n){let a=n.cellIds.inOrderIds,o=a.indexOf(e);if(o>0)return{after:a[o-1]};if(o===0&&a.length>1)return{before:a[1]}}function Y1(e){let n=new Map,a=e.cellIds.getColumns();for(let[o,s]of a.entries())for(let c of s.inOrderIds)n.set(c,o);return n}function vo(e,n){let a=new Set(e.cellIds.inOrderIds),o=[];for(let s of n.cellIds.inOrderIds)if(!a.has(s)){let c=pi(s,n);c&&o.push({type:"create-cell",cellId:c.id,code:c.code,name:c.name,config:c.config,...X1(c.id,n)})}return o}function OT(e,n){let a=new Set(n.cellIds.inOrderIds),o=[];for(let s of e.cellIds.inOrderIds)a.has(s)||o.push({type:"delete-cell",cellId:s});return o}function dc(e,n){let a=Y1(e),o=Y1(n),s=[];for(let[c,d]of o)if(a.get(c)!==d){let f=pi(c,n);s.push({type:"set-config",cellId:c,column:d,disabled:(f==null?void 0:f.config.disabled)??!1,hideCode:(f==null?void 0:f.config.hide_code)??!1})}return s.push({type:"reorder-cells",cellIds:n.cellIds.inOrderIds}),s}function AT(e,n,a){switch(a.type){case"createNewCell":return vo(e,n);case"deleteCell":return[{type:"delete-cell",cellId:a.payload.cellId}];case"moveCell":case"sendToTop":case"sendToBottom":{let{cellId:o}=a.payload;return[{type:"move-cell",cellId:o,...X1(o,n)}]}case"dropCellOverCell":case"dropCellOverColumn":case"moveCellToIndex":case"moveCellsRelativeTo":return dc(e,n);case"updateCellCode":{let o=pi(a.payload.cellId,n);return o?[{type:"set-code",cellId:o.id,code:o.code}]:[]}case"updateCellName":{let o=pi(a.payload.cellId,n);return o?[{type:"set-name",cellId:o.id,name:o.name}]:[]}case"updateCellConfig":{let{cellId:o}=a.payload,s=pi(o,n);return s?[{type:"set-config",cellId:o,column:s.config.column??null,disabled:s.config.disabled??!1,hideCode:s.config.hide_code??!1}]:[]}case"dropOverNewColumn":case"moveColumn":case"addColumnBreakpoint":case"deleteColumn":case"mergeAllColumns":case"compactColumns":return dc(e,n);case"addColumn":return[...vo(e,n),...dc(e,n)];case"undoDeleteCell":{let o=vo(e,n),s=dc(e,n);return o.length===0?s:s.length>1?[...o,...s]:o}case"splitCell":{let{cellId:o}=a.payload,s=pi(o,n);return s?[{type:"set-code",cellId:o,code:s.code},...vo(e,n)]:[]}case"undoSplitCell":{let{cellId:o}=a.payload,s=pi(o,n);return s?[{type:"set-code",cellId:o,code:s.code},...OT(e,n)]:[]}case"moveToNextCell":return vo(e,n);case"addSetupCellIfDoesntExist":return vo(e,n);case"focusCell":case"focusTopCell":case"focusBottomCell":case"scrollToTarget":case"showCellIfHidden":case"markTouched":case"markUntouched":return[];case"prepareForRun":case"handleCellMessage":case"setCellIds":case"rebuildCellColumns":case"setCellCodes":case"setCells":case"setStdinResponse":case"clearSerializedEditorState":case"clearCellOutput":case"clearCellConsoleOutput":case"clearAllCellOutputs":case"clearLogs":return[];case"foldAll":case"unfoldAll":case"collapseCell":case"expandCell":case"collapseAllCells":case"expandAllCells":return[];default:e8(a)}}function RT(e){let n=new Set,a=new Set;for(let o of e)o.type==="create-cell"?n.add(o.cellId):o.type==="delete-cell"&&a.add(o.cellId);return n.intersection(a)}function PT(e,n){var o,s,c;let a=[];for(let d of e)switch(d.type){case"create-cell":{let f="__end__",m=!1;d.after?(f=d.after,m=!1):d.before&&(f=d.before,m=!0),a.push({type:"createNewCell",payload:{cellId:f,before:m,code:d.code,newCellId:d.cellId,autoFocus:!1,hideCode:((o=d.config)==null?void 0:o.hide_code)??!1}}),d.name&&a.push({type:"updateCellName",payload:{cellId:d.cellId,name:d.name}}),(((s=d.config)==null?void 0:s.disabled)!=null||((c=d.config)==null?void 0:c.column)!=null)&&a.push({type:"updateCellConfig",payload:{cellId:d.cellId,config:{...d.config.disabled!=null&&{disabled:d.config.disabled},...d.config.column!=null&&{column:d.config.column}}}});break}case"delete-cell":a.push({type:"deleteCell",payload:{cellId:d.cellId}});break;case"move-cell":{let f=[...n()],m=d.cellId,b=f.indexOf(m);if(b<0)break;if(f.splice(b,1),d.after){let w=f.indexOf(d.after);w>=0?f.splice(w+1,0,m):f.push(m)}else if(d.before){let w=f.indexOf(d.before);w>=0?f.splice(w,0,m):f.unshift(m)}else f.push(m);a.push({type:"setCellIds",payload:{cellIds:f}});break}case"reorder-cells":a.push({type:"setCellIds",payload:{cellIds:d.cellIds}});break;case"set-code":a.push({type:"setCellCodes",payload:{ids:[d.cellId],codes:[d.code],codeIsStale:!0}});break;case"set-name":a.push({type:"updateCellName",payload:{cellId:d.cellId,name:d.name}});break;case"set-config":a.push({type:"updateCellConfig",payload:{cellId:d.cellId,config:{column:d.column,disabled:d.disabled,hide_code:d.hideCode}}});break}return a}var Z1=new Set(["set-code","set-name","set-config"]),MT=new Set(["set-code","set-name","set-config","move-cell"]);function NT(e){let n=new Set;for(let s of e)s.type==="delete-cell"&&n.add(s.cellId);let a=e.filter(s=>!(MT.has(s.type)&&"cellId"in s&&n.has(s.cellId))),o=new Map;return a.forEach((s,c)=>{Z1.has(s.type)&&"cellId"in s&&o.set(`${s.type}:${s.cellId}`,c)}),a.filter((s,c)=>Z1.has(s.type)&&"cellId"in s?o.get(`${s.type}:${s.cellId}`)===c:!0)}var Nf=[],DT=Hh(()=>{let e=NT(Nf);Nf=[],e.length!==0&&br().sendDocumentTransaction({changes:e})},400);function jT(e){return"cellId"in e&&e.cellId==="__scratch__"}function zT(e){Pe.get(s0)||jT(e)||(Nf.push(e),DT())}function qT(e,n,a){for(let o of AT(e,n,a))zT(o)}Ax=function(e,n,a){var f;let o=RT(e),s=[...e.filter(m=>m.type!=="set-config"),...e.filter(m=>m.type==="set-config")],c=!1,d=null;for(let m of s)if(!(o.size>0&&"cellId"in m&&o.has(m.cellId))){m.type==="set-config"&&(c=!0),m.type==="create-cell"&&((f=m.config)==null?void 0:f.column)!=null&&(c=!0),m.type==="reorder-cells"&&(d=m.cellIds);for(let b of PT([m],a))n[b.type](b.payload)}c&&n.rebuildCellColumns({cellIds:d??a()})};function FT(e,n){return y8(e*1e3,n==null?void 0:n.in)}var Df=function(e,n){return Object.defineProperty?Object.defineProperty(e,"raw",{value:n}):e.raw=n,e},ht;(function(e){e[e.EOS=0]="EOS",e[e.Text=1]="Text",e[e.Incomplete=2]="Incomplete",e[e.ESC=3]="ESC",e[e.Unknown=4]="Unknown",e[e.SGR=5]="SGR",e[e.OSCURL=6]="OSCURL"})(ht||(ht={})),i0=class{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer="",this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle="font-weight:bold",this.faintStyle="opacity:0.7",this.italicStyle="font-style:italic",this.underlineStyle="text-decoration:underline"}set use_classes(e){this._use_classes=e}get use_classes(){return this._use_classes}set url_allowlist(e){this._url_allowlist=e}get url_allowlist(){return this._url_allowlist}set escape_html(e){this._escape_html=e}get escape_html(){return this._escape_html}set boldStyle(e){this._boldStyle=e}get boldStyle(){return this._boldStyle}set faintStyle(e){this._faintStyle=e}get faintStyle(){return this._faintStyle}set italicStyle(e){this._italicStyle=e}get italicStyle(){return this._italicStyle}set underlineStyle(e){this._underlineStyle=e}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(a=>{a.forEach(o=>{this.palette_256.push(o)})});let e=[0,95,135,175,215,255];for(let a=0;a<6;++a)for(let o=0;o<6;++o)for(let s=0;s<6;++s){let c={rgb:[e[a],e[o],e[s]],class_name:"truecolor"};this.palette_256.push(c)}let n=8;for(let a=0;a<24;++a,n+=10){let o={rgb:[n,n,n],class_name:"truecolor"};this.palette_256.push(o)}}escape_txt_for_html(e){return this._escape_html?e.replace(/[&<>"']/gm,n=>{if(n==="&")return"&amp;";if(n==="<")return"&lt;";if(n===">")return"&gt;";if(n==='"')return"&quot;";if(n==="'")return"&#x27;"}):e}append_buffer(e){this._buffer+=e}get_next_packet(){var e={kind:ht.EOS,text:"",url:""},n=this._buffer.length;if(n==0)return e;var a=this._buffer.indexOf("\x1B");if(a==-1)return e.kind=ht.Text,e.text=this._buffer,this._buffer="",e;if(a>0)return e.kind=ht.Text,e.text=this._buffer.slice(0,a),this._buffer=this._buffer.slice(a),e;if(a==0){if(n<3)return e.kind=ht.Incomplete,e;var o=this._buffer.charAt(1);if(o!="["&&o!="]"&&o!="(")return e.kind=ht.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;if(o=="["){this._csi_regex||(this._csi_regex=ev(VT||(VT=Df([`
128
+ `)},...e.slice(s+1)]}return[c,...e.slice(s+1)]}function IT(e,n){let a={...e};switch(n.status){case"queued":a.interrupted=!1,a.errored=!1,a.runElapsedTimeMs=null,a.debuggerActive=!1;break;case"running":a.interrupted=!1,e.stopped&&(a.output=null),a.status==="queued"&&(a.consoleOutputs=[]),a.stopped=!1,a.runStartTimestamp=n.timestamp,a.lastRunStartTimestamp=n.timestamp;break;case"idle":e.runStartTimestamp&&(a.runElapsedTimeMs=t0.fromSeconds((n.timestamp??0)-e.runStartTimestamp).toMilliseconds(),a.runStartTimestamp=null,a.staleInputs=!1),!e.lastRunStartTimestamp&&n.timestamp&&(a.lastRunStartTimestamp=n.timestamp),a.debuggerActive=!1;break;case null:break;case"disabled-transitively":break;case void 0:break;default:ds(n.status)}a.output=n.output??a.output,a.staleInputs=n.stale_inputs??a.staleInputs,a.status=n.status??a.status,n.serialization!==void 0&&(a.serialization=n.serialization);let o=!1;n.output!=null&&n.output.mimetype==="application/vnd.marimo+error"&&((a.status==="queued"||a.status==="running")&&(a.status="idle"),an(Array.isArray(n.output.data),"Expected error output data to be an array"),n.output.data.some(f=>f.type==="interruption")?(a.interrupted=!0,o=!0):n.output.data.some(f=>f.type.includes("ancestor"))?a.stopped=!0:a.errored=!0);let s=e.consoleOutputs;o&&(a.debuggerActive=!1,s=s.map(f=>f.channel==="stdin"?{...f,response:f.response??""}:f));let c=n.console;c!=null&&(s=CT(Array.isArray(c)?c:[...s,c])),a.consoleOutputs=s,a.outline=y0(a.output);let d=[n.console].flat().filter(Boolean).filter(f=>f.channel==="pdb");return d.length>0&&d.some(f=>f.data==="start")&&(a.debuggerActive=!0),a}function LT(e){let n={...e};return e.status!=="disabled-transitively"&&(n.status="queued"),n.interrupted=!1,n.errored=!1,n.runElapsedTimeMs=null,n.debuggerActive=!1,n}jm=function(e){return e==="running"||e==="queued"},Ex=function(e,n){let{status:a,output:o,runStartTimestamp:s,interrupted:c,staleInputs:d}=e;if(c)return!1;if(n)return!0;let f=jm(a),m=a==="running"&&o!==null&&s!==null&&(o.timestamp??0)>s;return f&&!m?!0:d},vx=function(){let e=Pe.get(xd);return Ju(e,"internal-error: initial mode not found"),an(e!=="present","internal-error: initial mode cannot be 'present'"),e},xx=function(e){return e==="read"||e==="home"||e==="gallery"?e:e==="edit"?"present":"edit"},d0=Ee({mode:Nw()?"read":"not-set",cellAnchor:null}),xd=Ee(void 0),s0=Ee(!1),qx=function(){let{mode:e}=rn(d0);return e!=="read"};function pi(e,n){if(!e){be.warn("getCell: cellId is undefined");return}let a=n.cellData[e];if(!a){be.warn(`getCell: cell ${e} not found in state`);return}return a}function X1(e,n){let a=n.cellIds.inOrderIds,o=a.indexOf(e);if(o>0)return{after:a[o-1]};if(o===0&&a.length>1)return{before:a[1]}}function Y1(e){let n=new Map,a=e.cellIds.getColumns();for(let[o,s]of a.entries())for(let c of s.inOrderIds)n.set(c,o);return n}function vo(e,n){let a=new Set(e.cellIds.inOrderIds),o=[];for(let s of n.cellIds.inOrderIds)if(!a.has(s)){let c=pi(s,n);c&&o.push({type:"create-cell",cellId:c.id,code:c.code,name:c.name,config:c.config,...X1(c.id,n)})}return o}function OT(e,n){let a=new Set(n.cellIds.inOrderIds),o=[];for(let s of e.cellIds.inOrderIds)a.has(s)||o.push({type:"delete-cell",cellId:s});return o}function dc(e,n){let a=Y1(e),o=Y1(n),s=[];for(let[c,d]of o)if(a.get(c)!==d){let f=pi(c,n);s.push({type:"set-config",cellId:c,column:d,disabled:(f==null?void 0:f.config.disabled)??!1,hideCode:(f==null?void 0:f.config.hide_code)??!1})}return s.push({type:"reorder-cells",cellIds:n.cellIds.inOrderIds}),s}function AT(e,n,a){switch(a.type){case"createNewCell":return vo(e,n);case"deleteCell":return[{type:"delete-cell",cellId:a.payload.cellId}];case"moveCell":case"sendToTop":case"sendToBottom":{let{cellId:o}=a.payload;return[{type:"move-cell",cellId:o,...X1(o,n)}]}case"dropCellOverCell":case"dropCellOverColumn":case"moveCellToIndex":case"moveCellsRelativeTo":return dc(e,n);case"updateCellCode":{let o=pi(a.payload.cellId,n);return o?[{type:"set-code",cellId:o.id,code:o.code}]:[]}case"updateCellName":{let o=pi(a.payload.cellId,n);return o?[{type:"set-name",cellId:o.id,name:o.name}]:[]}case"updateCellConfig":{let{cellId:o}=a.payload,s=pi(o,n);return s?[{type:"set-config",cellId:o,column:s.config.column??null,disabled:s.config.disabled??!1,hideCode:s.config.hide_code??!1}]:[]}case"dropOverNewColumn":case"moveColumn":case"addColumnBreakpoint":case"deleteColumn":case"mergeAllColumns":case"compactColumns":return dc(e,n);case"addColumn":return[...vo(e,n),...dc(e,n)];case"undoDeleteCell":{let o=vo(e,n),s=dc(e,n);return o.length===0?s:s.length>1?[...o,...s]:o}case"splitCell":{let{cellId:o}=a.payload,s=pi(o,n);return s?[{type:"set-code",cellId:o,code:s.code},...vo(e,n)]:[]}case"undoSplitCell":{let{cellId:o}=a.payload,s=pi(o,n);return s?[{type:"set-code",cellId:o,code:s.code},...OT(e,n)]:[]}case"moveToNextCell":return vo(e,n);case"addSetupCellIfDoesntExist":return vo(e,n);case"focusCell":case"focusTopCell":case"focusBottomCell":case"scrollToTarget":case"showCellIfHidden":case"markTouched":case"markUntouched":return[];case"prepareForRun":case"handleCellMessage":case"setCellIds":case"rebuildCellColumns":case"setCellCodes":case"setCells":case"setStdinResponse":case"clearSerializedEditorState":case"clearCellOutput":case"clearCellConsoleOutput":case"clearAllCellOutputs":case"clearLogs":return[];case"foldAll":case"unfoldAll":case"collapseCell":case"expandCell":case"collapseAllCells":case"expandAllCells":return[];default:e8(a)}}function RT(e){let n=new Set,a=new Set;for(let o of e)o.type==="create-cell"?n.add(o.cellId):o.type==="delete-cell"&&a.add(o.cellId);return n.intersection(a)}function PT(e,n){var o,s,c;let a=[];for(let d of e)switch(d.type){case"create-cell":{let f="__end__",m=!1;d.after?(f=d.after,m=!1):d.before&&(f=d.before,m=!0),a.push({type:"createNewCell",payload:{cellId:f,before:m,code:d.code,newCellId:d.cellId,autoFocus:!1,hideCode:((o=d.config)==null?void 0:o.hide_code)??!1}}),d.name&&a.push({type:"updateCellName",payload:{cellId:d.cellId,name:d.name}}),(((s=d.config)==null?void 0:s.disabled)!=null||((c=d.config)==null?void 0:c.column)!=null)&&a.push({type:"updateCellConfig",payload:{cellId:d.cellId,config:{...d.config.disabled!=null&&{disabled:d.config.disabled},...d.config.column!=null&&{column:d.config.column}}}});break}case"delete-cell":a.push({type:"deleteCell",payload:{cellId:d.cellId}});break;case"move-cell":{let f=[...n()],m=d.cellId,b=f.indexOf(m);if(b<0)break;if(f.splice(b,1),d.after){let w=f.indexOf(d.after);w>=0?f.splice(w+1,0,m):f.push(m)}else if(d.before){let w=f.indexOf(d.before);w>=0?f.splice(w,0,m):f.unshift(m)}else f.push(m);a.push({type:"setCellIds",payload:{cellIds:f}});break}case"reorder-cells":a.push({type:"setCellIds",payload:{cellIds:d.cellIds}});break;case"set-code":a.push({type:"setCellCodes",payload:{ids:[d.cellId],codes:[d.code],codeIsStale:!0}});break;case"set-name":a.push({type:"updateCellName",payload:{cellId:d.cellId,name:d.name}});break;case"set-config":a.push({type:"updateCellConfig",payload:{cellId:d.cellId,config:{column:d.column,disabled:d.disabled,hide_code:d.hideCode}}});break}return a}var Z1=new Set(["set-code","set-name","set-config"]),MT=new Set(["set-code","set-name","set-config","move-cell"]);function NT(e){let n=new Set;for(let s of e)s.type==="delete-cell"&&n.add(s.cellId);let a=e.filter(s=>!(MT.has(s.type)&&"cellId"in s&&n.has(s.cellId))),o=new Map;return a.forEach((s,c)=>{Z1.has(s.type)&&"cellId"in s&&o.set(`${s.type}:${s.cellId}`,c)}),a.filter((s,c)=>Z1.has(s.type)&&"cellId"in s?o.get(`${s.type}:${s.cellId}`)===c:!0)}var Nf=[],DT=Hh(()=>{let e=NT(Nf);Nf=[],e.length!==0&&br().sendDocumentTransaction({changes:e})},400);function jT(e){return"cellId"in e&&e.cellId==="__scratch__"}function zT(e){Pe.get(s0)||jT(e)||(Nf.push(e),DT())}function qT(e,n,a){for(let o of AT(e,n,a))zT(o)}Ax=function(e,n,a){var f;let o=RT(e),s=[...e.filter(m=>m.type!=="set-config"),...e.filter(m=>m.type==="set-config")],c=!1,d=null;for(let m of s)if(!(o.size>0&&"cellId"in m&&o.has(m.cellId))){m.type==="set-config"&&(c=!0),m.type==="create-cell"&&((f=m.config)==null?void 0:f.column)!=null&&(c=!0),m.type==="reorder-cells"&&(d=m.cellIds);for(let b of PT([m],a))n[b.type](b.payload)}c&&n.rebuildCellColumns({cellIds:d??a()})};function FT(e,n){return y8(e*1e3,n==null?void 0:n.in)}var Df=function(e,n){return Object.defineProperty?Object.defineProperty(e,"raw",{value:n}):e.raw=n,e},ht;(function(e){e[e.EOS=0]="EOS",e[e.Text=1]="Text",e[e.Incomplete=2]="Incomplete",e[e.ESC=3]="ESC",e[e.Unknown=4]="Unknown",e[e.SGR=5]="SGR",e[e.OSCURL=6]="OSCURL"})(ht||(ht={})),i0=class{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer="",this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle="font-weight:bold",this.faintStyle="opacity:0.7",this.italicStyle="font-style:italic",this.underlineStyle="text-decoration:underline"}set use_classes(e){this._use_classes=e}get use_classes(){return this._use_classes}set url_allowlist(e){this._url_allowlist=e}get url_allowlist(){return this._url_allowlist}set escape_html(e){this._escape_html=e}get escape_html(){return this._escape_html}set boldStyle(e){this._boldStyle=e}get boldStyle(){return this._boldStyle}set faintStyle(e){this._faintStyle=e}get faintStyle(){return this._faintStyle}set italicStyle(e){this._italicStyle=e}get italicStyle(){return this._italicStyle}set underlineStyle(e){this._underlineStyle=e}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(a=>{a.forEach(o=>{this.palette_256.push(o)})});let e=[0,95,135,175,215,255];for(let a=0;a<6;++a)for(let o=0;o<6;++o)for(let s=0;s<6;++s){let c={rgb:[e[a],e[o],e[s]],class_name:"truecolor"};this.palette_256.push(c)}let n=8;for(let a=0;a<24;++a,n+=10){let o={rgb:[n,n,n],class_name:"truecolor"};this.palette_256.push(o)}}escape_txt_for_html(e){return this._escape_html?e.replace(/[&<>"']/gm,n=>{if(n==="&")return"&amp;";if(n==="<")return"&lt;";if(n===">")return"&gt;";if(n==='"')return"&quot;";if(n==="'")return"&#x27;"}):e}append_buffer(e){this._buffer+=e}get_next_packet(){var e={kind:ht.EOS,text:"",url:""},n=this._buffer.length;if(n==0)return e;var a=this._buffer.indexOf("\x1B");if(a==-1)return e.kind=ht.Text,e.text=this._buffer,this._buffer="",e;if(a>0)return e.kind=ht.Text,e.text=this._buffer.slice(0,a),this._buffer=this._buffer.slice(a),e;if(a==0){if(n<3)return e.kind=ht.Incomplete,e;var o=this._buffer.charAt(1);if(o!="["&&o!="]"&&o!="(")return e.kind=ht.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;if(o=="["){this._csi_regex||(this._csi_regex=ev(VT||(VT=Df([`
129
129
  ^ # beginning of line
130
130
  #
131
131
  # First attempt