@marimo-team/frontend 0.23.2-dev11 → 0.23.2-dev13

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 (70) hide show
  1. package/dist/assets/{CellStatus-Bwtcvgko.js → CellStatus-CvVketBj.js} +1 -1
  2. package/dist/assets/{JsonOutput-ZBMYDZ3q.js → JsonOutput-DSDJDUaa.js} +1 -1
  3. package/dist/assets/{LazyAnyLanguageCodeMirror-CsrwfW0n.js → LazyAnyLanguageCodeMirror-fm2VqpnZ.js} +2 -2
  4. package/dist/assets/{MarimoErrorOutput-DLREr23s.js → MarimoErrorOutput-B6xkavKl.js} +1 -1
  5. package/dist/assets/{RenderHTML-5FjN3OZH.js → RenderHTML-Ds_EjQCe.js} +1 -1
  6. package/dist/assets/{add-cell-with-ai-DbPkyXyg.js → add-cell-with-ai-DHOdJYCW.js} +1 -1
  7. package/dist/assets/{add-connection-dialog-sNnLlFNN.js → add-connection-dialog-QrjKitAG.js} +1 -1
  8. package/dist/assets/{agent-panel-DMb4Q9pS.js → agent-panel-Dickktil.js} +1 -1
  9. package/dist/assets/{ai-model-dropdown-CZB8Xt_D.js → ai-model-dropdown-w8S2jfIS.js} +4 -4
  10. package/dist/assets/{any-language-editor-DkEDDsUJ.js → any-language-editor-ZhKJljlb.js} +1 -1
  11. package/dist/assets/{app-config-button-b2p8_NdZ.js → app-config-button-BckAiCUn.js} +1 -1
  12. package/dist/assets/{cell-editor-BhmiBBOV.js → cell-editor-B3eWG04j.js} +8 -8
  13. package/dist/assets/{cell-link-DMyOfytV.js → cell-link-CA-zSpGe.js} +1 -1
  14. package/dist/assets/{cells-CAft_y9h.js → cells-CvCKjUwL.js} +9 -9
  15. package/dist/assets/{chat-display-CnlcyHaA.js → chat-display-DXwFwqdO.js} +1 -1
  16. package/dist/assets/{chat-panel-DujR1b5z.js → chat-panel-DkIDMOu6.js} +1 -1
  17. package/dist/assets/{chat-ui-D-qk0TXi.js → chat-ui-CzVvVdHB.js} +1 -1
  18. package/dist/assets/{column-preview-D2B6qQUU.js → column-preview-CV6DJwQH.js} +1 -1
  19. package/dist/assets/{command-palette-eS5sJOYR.js → command-palette-BAWNAZMp.js} +1 -1
  20. package/dist/assets/{common-BK4i6reD.js → common-CoA1AJdr.js} +1 -1
  21. package/dist/assets/{components-Dta3XEEY.js → components-BhjaTG8G.js} +1 -1
  22. package/dist/assets/{components-CviIANwr.js → components-D21ZOc5-.js} +1 -1
  23. package/dist/assets/{datasource-C1kSlT4s.js → datasource-CGDFE2Dl.js} +1 -1
  24. package/dist/assets/{dependency-graph-panel-CMZnqwyn.js → dependency-graph-panel-DN6lUM5M.js} +1 -1
  25. package/dist/assets/{dist-DZJfxwLb.js → dist-CeWYEVw7.js} +2 -2
  26. package/dist/assets/{documentation-panel-D9WN55Gq.js → documentation-panel-BMEYjNmG.js} +1 -1
  27. package/dist/assets/{download-COyB8G-Y.js → download-Cz9yagTM.js} +1 -1
  28. package/dist/assets/{edit-page-DlRqSgY9.js → edit-page-DL44Xhld.js} +3 -3
  29. package/dist/assets/{error-panel-5I4mWGfs.js → error-panel-DcmkhCxZ.js} +1 -1
  30. package/dist/assets/{esm-BqofWdD5.js → esm-xpEhG7KX.js} +1 -1
  31. package/dist/assets/{file-explorer-panel-B86r63YC.js → file-explorer-panel-Cm0rqLaG.js} +1 -1
  32. package/dist/assets/{file-icons-CRsc39Ny.js → file-icons-CyM54ufD.js} +1 -1
  33. package/dist/assets/{floating-outline-Cj9Gdjkf.js → floating-outline-BYxKYVYd.js} +1 -1
  34. package/dist/assets/{focus-BtOH5aLt.js → focus-DfVKn9R8.js} +1 -1
  35. package/dist/assets/{form-Dd-gRdD5.js → form-D8rkP8Ig.js} +1 -1
  36. package/dist/assets/{home-page-B320ImBG.js → home-page-DEeiEOHu.js} +1 -1
  37. package/dist/assets/{hooks-B5RY2sms.js → hooks-D2tqOhv8.js} +1 -1
  38. package/dist/assets/{html-to-image-WCAzCguU.js → html-to-image-D4jc7m52.js} +1 -1
  39. package/dist/assets/{index-BjVgEJVi.js → index-DR9Po2ic.js} +4 -4
  40. package/dist/assets/{kiosk-mode-CJ7p0kAg.js → kiosk-mode-gTTXVMNB.js} +1 -1
  41. package/dist/assets/{layout-CnhRBcnG.js → layout-UpIwnVzJ.js} +1 -1
  42. package/dist/assets/{logs-panel-DG3RlQaY.js → logs-panel-CUw148Tx.js} +1 -1
  43. package/dist/assets/{markdown-renderer-BDdzHOwK.js → markdown-renderer-C88PtReb.js} +1 -1
  44. package/dist/assets/{name-cell-input-68gHDuvg.js → name-cell-input-CGI--sKC.js} +1 -1
  45. package/dist/assets/{outline-panel-Dr0105mz.js → outline-panel-DduwH0R5.js} +1 -1
  46. package/dist/assets/{packages-panel-CZHZDUXZ.js → packages-panel-B5Y9C0yo.js} +1 -1
  47. package/dist/assets/{panels-DkMIu1eO.js → panels-DVbiAjhB.js} +1 -1
  48. package/dist/assets/{process-output-CGSREMph.js → process-output-DHZBktnU.js} +1 -1
  49. package/dist/assets/{readonly-python-code-3lQBDicq.js → readonly-python-code-Dq9SF5-p.js} +1 -1
  50. package/dist/assets/{run-page-DX60GJ1i.js → run-page-IeagkCfu.js} +1 -1
  51. package/dist/assets/{scratchpad-panel-DxI-sH1n.js → scratchpad-panel-ByYUuUE7.js} +1 -1
  52. package/dist/assets/{session-panel-DxZNtbiE.js → session-panel-C86D9rsy.js} +1 -1
  53. package/dist/assets/{snippets-panel-CFXjJW29.js → snippets-panel-ubvMnyzj.js} +1 -1
  54. package/dist/assets/{state-BFn0AerH.js → state-BvTo39vs.js} +1 -1
  55. package/dist/assets/{state-CDUQVvOe.js → state-CwzLXxsb.js} +1 -1
  56. package/dist/assets/{textarea-CWy4stSy.js → textarea-BDH7sBL4.js} +1 -1
  57. package/dist/assets/{tracing-CIygWG5q.js → tracing-COHme3AD.js} +1 -1
  58. package/dist/assets/{tracing-panel-Dk7FE-7H.js → tracing-panel-D9XhFJ9Z.js} +2 -2
  59. package/dist/assets/{useAddCell-BZ5oFC7U.js → useAddCell-0FR_uwoE.js} +1 -1
  60. package/dist/assets/{useCellActionButton-Dd3hgOb6.js → useCellActionButton-B7pS3y8i.js} +1 -1
  61. package/dist/assets/{useDeleteCell-BHcPGuXL.js → useDeleteCell-BoljMURw.js} +1 -1
  62. package/dist/assets/{useDependencyPanelTab-B94SJnJl.js → useDependencyPanelTab-CxZaWEsQ.js} +1 -1
  63. package/dist/assets/{useNotebookActions-PmHNCN16.js → useNotebookActions-BhIJMijf.js} +1 -1
  64. package/dist/assets/{useRunCells-BJn5ZEb6.js → useRunCells-CAi-cJkW.js} +1 -1
  65. package/dist/assets/{useSplitCell-Bfb8riCm.js → useSplitCell-D88B-tBq.js} +1 -1
  66. package/dist/index.html +25 -25
  67. package/package.json +1 -1
  68. package/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap +4 -14
  69. package/src/core/codemirror/cells/extensions.ts +0 -4
  70. package/src/core/codemirror/keymaps/keymaps.ts +69 -2
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./esm-vpVfqVb3.js","./chunk-LvLJmgfZ.js","./dist-Hgde9xRP.js","./dist-BPkOpnKv.js","./dist-BNTOYRCs.js","./dist-VwkX7yeV.js","./dist-DlC_MlJ3.js","./dist-DDiNOVwA.js","./dist-C0ZJnmgG.js","./dist-CxquLoAZ.js","./dist-BZIkwcpM.js","./dist-ByWFdhfz.js","./dist-fPjTlo0F.js","./dist-4lB-oR9j.js","./dist-Dnlw22ji.js","./dist-DjS0QmS_.js","./dist-CHgkfE72.js","./dist-CJDjz8TY.js","./dist-CWLNI6B7.js","./dist-D281cBMB.js","./dist-Dz1-lL07.js","./dist-BYHplnRv.js","./dist-BaQhtL0H.js","./dist-CaQ_ONVt.js","./dist-DW-_Bd4t.js","./dist-BrR2nUId.js","./dist-IBCCX0qd.js","./dist-BvlMLwcr.js","./dist-D797J-u_.js","./dist-04hxiWlB.js","./dist-eH2iPs-V.js","./dist-CgYlATe-.js","./dist-BrK3C3Mc.js","./dist-B1XdVflW.js","./dist-BQuOw7vA.js","./dist-Gx6Yy96j.js","./dist-B6i4q8vX.js","./dist-bOlBcn5A.js","./dist-CQvRfEJt.js","./dist-Yk16cgLk.js","./dist-D_Lhmjyi.js","./dist-umvL589W.js","./apl-CuOurP-c.js","./apl-CArdF_Ee.js","./asciiarmor-C4q0KAuh.js","./asciiarmor-rf6n_8YZ.js","./asn1-gmsDz0li.js","./asn1-Bl4vlAxN.js","./brainfuck-RlYwG6Xx.js","./brainfuck-CWRjg_-2.js","./cobol--NmnvDWE.js","./cobol-B24ofC4q.js","./clike-0Uxq7Mmj.js","./clike-B4xEkWXN.js","./clojure-DaWCBM5I.js","./clojure-04C6o-hL.js","./css-vLkD8PfS.js","./css-C_vknI7E.js","./cmake-Nobmxv0n.js","./cmake-Dh64a3j4.js","./coffeescript-Cv1Wf46X.js","./coffeescript-B0i0O-b-.js","./commonlisp-8PbUodZQ.js","./commonlisp-NXg-Bye5.js","./cypher-Aazxis5r.js","./cypher-DwQoZmH9.js","./python-D-LGD-zO.js","./python-BvK-LeGt.js","./crystal-DOOJCjhq.js","./crystal-BOjNTZjx.js","./d-B-5Jnu40.js","./d-xedQGhmO.js","./diff-8GFZiZ2V.js","./diff-ChFnp8JW.js","./dockerfile-CmMwYXtW.js","./simple-mode-DxeVZov3.js","./dtd-DbhDFQ4b.js","./dtd-KbDPyUs4.js","./dylan-4K5wZgOx.js","./dylan-0KH4Nowk.js","./ecl-BCQ-LzuG.js","./ecl-B5iM_b7s.js","./eiffel-DjgNAio4.js","./eiffel-sVM1STl5.js","./elm-BJzUTgDF.js","./elm-BlNENVB6.js","./erlang-BMwCh1Tz.js","./erlang-C0uOSFok.js","./factor-DuQK79vi.js","./factor-B-0VZGQP.js","./forth-CN0H2hBb.js","./forth-Dkvgp5v0.js","./fortran-D-JaE1fl.js","./fortran-DWGt9NN5.js","./mllike-bIsNpdn1.js","./mllike-WTbu2PGL.js","./gas-B-bID6UX.js","./gas-ucVnXY28.js","./gherkin-JGxOpXhU.js","./gherkin-BRjIORXo.js","./groovy-BHPB9Hfx.js","./groovy-BwyAyRPC.js","./haskell-By6RbCCv.js","./haskell-Cs-Andhs.js","./haxe-HQiVsOCF.js","./haxe-BW46cyaq.js","./idl-B2iocbwq.js","./idl-BGiQ18ct.js","./javascript-CTjlnOSz.js","./javascript-I9_Q-6Fg.js","./julia-BiUkdI9P.js","./julia-Wfay9brY.js","./livescript-uNIpKRlq.js","./livescript-J6EnSQWw.js","./lua-CMIwWFMm.js","./lua-BO_knq_Q.js","./mirc-DA5aApOX.js","./mirc-82uLLidC.js","./mathematica-eDJrChdG.js","./mathematica-DU8ikXHk.js","./modelica-0mx6heI0.js","./modelica-w4uKZrXu.js","./mumps-5_kXgafg.js","./mumps-Bicgf-gh.js","./mbox-zqvBlhy3.js","./mbox-Dzzw6MxI.js","./nsis-DOhuqhNG.js","./nsis-DGDbP9K4.js","./ntriples-BWf6tqTo.js","./ntriples-CyotCBD4.js","./octave-DmFvn7Va.js","./octave-BP7UuRZ-.js","./oz-TIwA1cRs.js","./oz-C9dsRBsA.js","./pascal-BFfHjByI.js","./pascal-Do-HizJs.js","./perl-iyEBGoKl.js","./perl-DkWjygEp.js","./pig-Du8JEd9u.js","./pig-C5cO5Lzu.js","./powershell-rJPOSwVp.js","./powershell-B7iMkhi7.js","./properties-B7p1o35g.js","./properties-BojS2wNP.js","./protobuf-DSVPm4uR.js","./protobuf-C3jQLUT4.js","./pug-BBnJinJ-.js","./pug-5wW7Sn9S.js","./puppet-CvB_7oA0.js","./puppet-BIu7yw7Q.js","./q-s96Dgstm.js","./q-DxTFD_3l.js","./r-DCKN0Q_M.js","./r-D9kMb9Pl.js","./rpm-DKF6hj80.js","./rpm-DMBmptJ_.js","./ruby-DrHWYpO-.js","./ruby-Bi66LQBu.js","./sas-Bf--oEyw.js","./sas-DDMCLlZz.js","./scheme-BZSq5_CL.js","./scheme-MngEI34z.js","./shell-C5LsobAY.js","./shell-BSVgrHzY.js","./sieve-B6cTRfjv.js","./sieve-DvUWNrPv.js","./smalltalk-B-ZeF8oP.js","./smalltalk-CeZ66qpG.js","./sparql-hKgXdTt3.js","./sparql-oFx_t7AO.js","./stylus-MJ5VouuS.js","./stylus-KE-9LQSK.js","./swift-jqL65uqK.js","./swift-A-ZhZWU8.js","./stex-Dn4qnyVB.js","./stex-jWatZkll.js","./verilog-DuexQCyX.js","./verilog-SCT9zECa.js","./tcl-D9FDKTky.js","./tcl-CREXWwrr.js","./textile-Ne1MkNjB.js","./textile-Cj8L4qVJ.js","./toml-Ba1TjbvG.js","./toml-BwSlV2Pt.js","./troff-ClRZFpM8.js","./troff-DWonWT6V.js","./ttcn-JOxk9-wl.js","./ttcn--CHQduBW.js","./ttcn-cfg-D-oWP0t7.js","./ttcn-cfg-Cei3Mnk3.js","./turtle-CfJStbTs.js","./turtle-BaGuNPTf.js","./webidl-DZaOA0mR.js","./webidl-B7LbwCfy.js","./vb-DtMAcbIy.js","./vb-DQgwufRi.js","./vbscript-CUB17r-X.js","./vbscript-B66XhQhu.js","./velocity-Dwo66olV.js","./velocity-D7CxwqhZ.js","./vhdl-Mgyyw75F.js","./vhdl-Bz6d75os.js","./xquery-DpQixCSm.js","./xquery-BOMK2ySj.js","./yacas-B1gHpHXz.js","./yacas-Yk74VuuD.js","./z80-IF9HkI5m.js","./z80-BQKQ7DhX.js","./mscgen-BKLWiiDn.js","./mscgen-Bf7m7BDT.js","./dist-ZzjYvfSN.js","./dist-Dl90TzK0.js","./dist-CsTHFGvB.js","./node-sql-parser-UQ9Ur_LP.js"])))=>i.map(i=>d[i]);
2
- var c6=Object.defineProperty;var u6=(pa,_r,ri)=>_r in pa?c6(pa,_r,{enumerable:!0,configurable:!0,writable:!0,value:ri}):pa[_r]=ri;var ve=(pa,_r,ri)=>u6(pa,typeof _r!="symbol"?_r+"":_r,ri);import{a as d6,n as dw,o as f6,r as p6,s as Pu,t as rt}from"./chunk-LvLJmgfZ.js";import{c as fw,i as ze,l as pw,p as Te,r as h6,s as m6,u as Sn}from"./useEvent-D91BmmQi.js";import{t as Nu}from"./react-Bj1aDYRI.js";import{t as hw}from"./react-dom-CSu739Rf.js";import{B as g6,N as y6,P as mw,R as gw,T as yw,k as v6,w as b6}from"./zod-H_cgTO0M.js";import{t as er}from"./compiler-runtime-B3qBwwSJ.js";import{t as Mh}from"./debounce-BbSyBDA8.js";import{_ as be,d as Rr,f as vw,o as Mu,p as w6}from"./useEventListener-DGjKht0c.js";import{t as rn}from"./invariant-CkiqGLcK.js";import{f as bw,t as ww}from"./utils-8btzWeZg.js";import{S as Dh,r as _6,y as x6}from"./config-DoZCLcOb.js";import{n as k6,t as Pr}from"./cn-DYvqRARy.js";import{t as C6}from"./jsx-runtime-Blw4afVn.js";import{C as sa,S as _w,_ as xw,b as tr,f as S6,h as Du,m as E6,u as T6,v as kw,w as I6,y as L6}from"./fullscreen-k58KVlT-.js";import{l as Cw,o as O6}from"./dist-sZgjGm4S.js";import{d as A6}from"./menu-items-Dtw5N98_.js";import{a as R6,c as P6,i as jh,m as N6,n as M6,o as Sw,r as D6,s as j6,t as z6}from"./select-BwwUWhww.js";import{i as q6,t as zh}from"./tooltip-DmqhBBs6.js";import{t as Ew}from"./button-COIw2x9i.js";import{A as F6,At as qh,Bt as $t,C as B6,D as V6,Et as Tw,Ft as Iw,Gt as H6,H as Lw,Ht as xl,I as Ow,J as ju,Jt as la,Kt as Aw,Ot as as,S as $6,St as Ja,T as Rw,U as W6,Ut as Pw,Vt as U6,W as K6,Wt as zu,Xt as Wi,Yt as is,Zt as os,_t as Q6,at as Et,b as Nw,ct as Ui,f as Mw,it as G6,jt as J6,k as X6,l as ne,mt as Y6,nt as Dw,ot as Z6,p as e8,rt as ca,u as jw,ut as t8,xt as Fh,z as zw,zt as qu}from"./dist-VwkX7yeV.js";import{A as n8,E as r8,S as a8,T as i8,_ as o8,b as s8,d as qw,f as l8,h as c8,m as u8,n as d8,o as Bh,p as f8,s as p8,t as h8,u as m8,v as g8,w as y8,x as v8}from"./dist-DZJfxwLb.js";import{a as kl,i as Fw,m as Vh,n as b8,r as Bw}from"./arrays-DAC2orgH.js";import{n as nr}from"./once-hq2TLzOp.js";import{t as w8}from"./capabilities-BmGdj50E.js";import{t as _8}from"./cjs-D5tzp-Y6.js";import{t as Cl}from"./createReducer-CYlwteGD.js";import{d as Vw,l as Hw,n as x8,o as $w,p as k8,r as Fu}from"./dist-BNTOYRCs.js";import{t as Ww}from"./main-BNL5rxQw.js";import{n as Uw,t as C8}from"./useNonce-CbdaHKzX.js";import{i as ss,r as S8,t as E8}from"./strings-pfr2N700.js";import{t as br}from"./requests-9-v2bhoi.js";import{a as T8,c as I8,d as L8,f as Kw,i as O8,l as A8,n as R8,o as Hh,r as P8,s as $h,t as N8,u as M8}from"./dist-BPkOpnKv.js";import{t as ut}from"./createLucideIcon-w-Qo9n0R.js";import{a as Wh,i as D8,o as j8,r as z8,t as q8}from"./useLifecycle-N3bfh_O1.js";import{t as F8}from"./check-B-sKate2.js";import{t as B8}from"./x-Bv2rCglF.js";import{t as V8,u as H8}from"./toDate-BGIVWsZ9.js";import{t as Uh}from"./database-zap-BxfYZ6ML.js";import{n as $8,t as Sl}from"./DeferredRequestRegistry-BLWK1eKa.js";import{t as Fn}from"./badge-CwbVR_sO.js";import{t as re}from"./preload-helper-D2MJg03u.js";import{a as Qw,s as W8}from"./dist-BvlMLwcr.js";import{a as U8,i as Kh,n as K8,r as Gw,t as Q8}from"./dist-CgYlATe-.js";import{n as G8}from"./stex-jWatZkll.js";import{t as El}from"./use-toast-BDYuj3zG.js";import{n as Jw}from"./paths-BzSgteR-.js";import{n as J8}from"./useTheme-DCDmxPD0.js";import{t as Qh}from"./purify.es-BFDc-_i_.js";let Gh,Jh,Xa,Xh,Xw,Yh,Zh,Yw,Zw,e_,t_,n_,r_,a_,Ya,em,i_,Bn,o_,Vn,s_,l_,tm,c_,ls,Tl,Bu,Vu,u_,Hu,Za,Ki,nm,d_,$u,f_,rm,p_,Wu,h_,m_,g_,Uu,y_,ot,am,im,v_,om,Ku,sm,b_,Qi,w_,rr,Il,ua,Ll,__,lm,Qu,x_,k_,C_,S_,E_,T_,I_,L_,Gu,O_,A_,cm,R_,P_,N_,da,M_,um,dm,Ol,fm,ar,Ju,pm,Hn,D_,hm,Xu,Gi,j_,z_,En,q_,F_,Yu,B_,Al,mm,V_,gm,Zu,ym,H_,vm,$_,ed,bm,W_,U_,Rl,td,wm,nd,Pl,Nr,_m,Nl,cs,rd,K_,Ml,Q_,xm,km,ad,Dl,G_,Cm,Sm,Ye,J_,id,X_,Ji,Y_,Z_,fa,Em,ex,tx,nx,rx,Tm,Im,ax,Lm,Xi,ix,od,ox,Om,Am,Rm,sx,lx,sd,Pm,Nm,ld,mn,cx,Mm,ux,cd,ei,dx,Dm,fx,px,hx,jm,jl,ud,mx,gx,dd,yx,zm,vx,fd,zl,pd,qm,bx,ql,hd,Fm,md,gd,Bm,Vm,Hm,$m,wx,_x,xx,Yi,Wm,kx,us,Um,Km,Cx,Qm,ti,yd,Sx,Ex,Gm,Jm,Xm,Tx,Ix,Ym,Lx,vd,Ox,Ax,Zm,Rx,e0,bd,t0,ds,Px,fs,Nx,Mx,n0,Dx,r0,a0,jx,zx,qx,Fx,Bx,Vx,Hx,i0,wd,$x,Wx,_d,xd,o0,wr,Ux,ni,s0,kd,X8=(async()=>{var ur,Af,pi;let pa,_r,ri;pa=rt((e=>{function n(ie,ee){var W=ie.length;ie.push(ee);e:for(;0<W;){var Ie=W-1>>>1,He=ie[Ie];if(0<s(He,ee))ie[Ie]=ee,ie[W]=He,W=Ie;else break e}}function a(ie){return ie.length===0?null:ie[0]}function o(ie){if(ie.length===0)return null;var ee=ie[0],W=ie.pop();if(W!==ee){ie[0]=W;e:for(var Ie=0,He=ie.length,et=He>>>1;Ie<et;){var Fe=2*(Ie+1)-1,Ne=ie[Fe],Le=Fe+1,Me=ie[Le];if(0>s(Ne,W))Le<He&&0>s(Me,Ne)?(ie[Ie]=Me,ie[Le]=W,Ie=Le):(ie[Ie]=Ne,ie[Fe]=W,Ie=Fe);else if(Le<He&&0>s(Me,W))ie[Ie]=Me,ie[Le]=W,Ie=Le;else break e}}return ee}function s(ie,ee){var W=ie.sortIndex-ee.sortIndex;return W===0?ie.id-ee.id:W}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var f=Date,d=f.now();e.unstable_now=function(){return f.now()-d}}var m=[],b=[],_=1,x=null,S=3,E=!1,L=!1,P=!1,q=!1,V=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function J(ie){for(var ee=a(b);ee!==null;){if(ee.callback===null)o(b);else if(ee.startTime<=ie)o(b),ee.sortIndex=ee.expirationTime,n(m,ee);else break;ee=a(b)}}function le(ie){if(P=!1,J(ie),!L)if(a(m)!==null)L=!0,A||(A=!0,ye());else{var ee=a(b);ee!==null&&ue(le,ee.startTime-ie)}}var A=!1,j=-1,$=5,oe=-1;function de(){return q?!0:!(e.unstable_now()-oe<$)}function he(){if(q=!1,A){var ie=e.unstable_now();oe=ie;var ee=!0;try{e:{L=!1,P&&(P=!1,B(j),j=-1),E=!0;var W=S;try{t:{for(J(ie),x=a(m);x!==null&&!(x.expirationTime>ie&&de());){var Ie=x.callback;if(typeof Ie=="function"){x.callback=null,S=x.priorityLevel;var He=Ie(x.expirationTime<=ie);if(ie=e.unstable_now(),typeof He=="function"){x.callback=He,J(ie),ee=!0;break t}x===a(m)&&o(m),J(ie)}else o(m);x=a(m)}if(x!==null)ee=!0;else{var et=a(b);et!==null&&ue(le,et.startTime-ie),ee=!1}}break e}finally{x=null,S=W,E=!1}ee=void 0}}finally{ee?ye():A=!1}}}var ye;if(typeof M=="function")ye=function(){M(he)};else if(typeof MessageChannel<"u"){var ke=new MessageChannel,we=ke.port2;ke.port1.onmessage=he,ye=function(){we.postMessage(null)}}else ye=function(){V(he,0)};function ue(ie,ee){j=V(function(){ie(e.unstable_now())},ee)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(ie){ie.callback=null},e.unstable_forceFrameRate=function(ie){0>ie||125<ie?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<ie?Math.floor(1e3/ie):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(ie){switch(S){case 1:case 2:case 3:var ee=3;break;default:ee=S}var W=S;S=ee;try{return ie()}finally{S=W}},e.unstable_requestPaint=function(){q=!0},e.unstable_runWithPriority=function(ie,ee){switch(ie){case 1:case 2:case 3:case 4:case 5:break;default:ie=3}var W=S;S=ie;try{return ee()}finally{S=W}},e.unstable_scheduleCallback=function(ie,ee,W){var Ie=e.unstable_now();switch(typeof W=="object"&&W?(W=W.delay,W=typeof W=="number"&&0<W?Ie+W:Ie):W=Ie,ie){case 1:var He=-1;break;case 2:He=250;break;case 5:He=1073741823;break;case 4:He=1e4;break;default:He=5e3}return He=W+He,ie={id:_++,callback:ee,priorityLevel:ie,startTime:W,expirationTime:He,sortIndex:-1},W>Ie?(ie.sortIndex=W,n(b,ie),a(m)===null&&ie===a(b)&&(P?(B(j),j=-1):P=!0,ue(le,W-Ie))):(ie.sortIndex=He,n(m,ie),L||E||(L=!0,A||(A=!0,ye()))),ie},e.unstable_shouldYield=de,e.unstable_wrapCallback=function(ie){var ee=S;return function(){var W=S;S=ee;try{return ie.apply(this,arguments)}finally{S=W}}}})),_r=rt(((e,n)=>{n.exports=pa()})),ri=rt((e=>{var n=_r(),a=Nu(),o=hw();function s(t){var r="https://react.dev/errors/"+t;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function f(t){var r=t,i=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,r.flags&4098&&(i=r.return),t=r.return;while(t)}return r.tag===3?i:null}function d(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function m(t){if(t.tag===31){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function b(t){if(f(t)!==t)throw Error(s(188))}function _(t){var r=t.alternate;if(!r){if(r=f(t),r===null)throw Error(s(188));return r===t?t:null}for(var i=t,l=r;;){var p=i.return;if(p===null)break;var g=p.alternate;if(g===null){if(l=p.return,l!==null){i=l;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===i)return b(p),t;if(g===l)return b(p),r;g=g.sibling}throw Error(s(188))}if(i.return!==l.return)i=p,l=g;else{for(var C=!1,I=p.child;I;){if(I===i){C=!0,i=p,l=g;break}if(I===l){C=!0,l=p,i=g;break}I=I.sibling}if(!C){for(I=g.child;I;){if(I===i){C=!0,i=g,l=p;break}if(I===l){C=!0,l=g,i=p;break}I=I.sibling}if(!C)throw Error(s(189))}}if(i.alternate!==l)throw Error(s(190))}if(i.tag!==3)throw Error(s(188));return i.stateNode.current===i?t:r}function x(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t;for(t=t.child;t!==null;){if(r=x(t),r!==null)return r;t=t.sibling}return null}var S=Object.assign,E=Symbol.for("react.element"),L=Symbol.for("react.transitional.element"),P=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),J=Symbol.for("react.context"),le=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),oe=Symbol.for("react.lazy"),de=Symbol.for("react.activity"),he=Symbol.for("react.memo_cache_sentinel"),ye=Symbol.iterator;function ke(t){return typeof t!="object"||!t?null:(t=ye&&t[ye]||t["@@iterator"],typeof t=="function"?t:null)}var we=Symbol.for("react.client.reference");function ue(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===we?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case q:return"Fragment";case B:return"Profiler";case V:return"StrictMode";case A:return"Suspense";case j:return"SuspenseList";case de:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case P:return"Portal";case J:return t.displayName||"Context";case M:return(t._context.displayName||"Context")+".Consumer";case le:var r=t.render;return t=t.displayName,t||(t=(t=r.displayName||r.name||"",t===""?"ForwardRef":"ForwardRef("+t+")")),t;case $:return r=t.displayName||null,r===null?ue(t.type)||"Memo":r;case oe:r=t._payload,t=t._init;try{return ue(t(r))}catch{}}return null}var ie=Array.isArray,ee=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ie={pending:!1,data:null,method:null,action:null},He=[],et=-1;function Fe(t){return{current:t}}function Ne(t){0>et||(t.current=He[et],He[et]=null,et--)}function Le(t,r){et++,He[et]=t.current,t.current=r}var Me=Fe(null),Tt=Fe(null),Pt=Fe(null),wa=Fe(null);function yo(t,r){switch(Le(Pt,r),Le(Tt,t),Le(Me,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?j2(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=j2(r),t=z2(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Ne(Me),Le(Me,t)}function On(){Ne(Me),Ne(Tt),Ne(Pt)}function jr(t){t.memoizedState!==null&&Le(wa,t);var r=Me.current,i=z2(r,t.type);r!==i&&(Le(Tt,t),Le(Me,i))}function hi(t){Tt.current===t&&(Ne(Me),Ne(Tt)),wa.current===t&&(Ne(wa),vl._currentValue=Ie)}var vo,Es;function mt(t){if(vo===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);vo=r&&r[1]||"",Es=-1<i.stack.indexOf(`
2
+ var c6=Object.defineProperty;var u6=(pa,_r,ri)=>_r in pa?c6(pa,_r,{enumerable:!0,configurable:!0,writable:!0,value:ri}):pa[_r]=ri;var ve=(pa,_r,ri)=>u6(pa,typeof _r!="symbol"?_r+"":_r,ri);import{a as d6,n as dw,o as f6,r as p6,s as Pu,t as rt}from"./chunk-LvLJmgfZ.js";import{c as fw,i as ze,l as pw,p as Te,r as h6,s as m6,u as Sn}from"./useEvent-D91BmmQi.js";import{t as Nu}from"./react-Bj1aDYRI.js";import{t as hw}from"./react-dom-CSu739Rf.js";import{B as g6,N as y6,P as mw,R as gw,T as yw,k as v6,w as b6}from"./zod-H_cgTO0M.js";import{t as er}from"./compiler-runtime-B3qBwwSJ.js";import{t as Mh}from"./debounce-BbSyBDA8.js";import{_ as be,d as Rr,f as vw,o as Mu,p as w6}from"./useEventListener-DGjKht0c.js";import{t as rn}from"./invariant-CkiqGLcK.js";import{f as bw,t as ww}from"./utils-8btzWeZg.js";import{S as Dh,r as _6,y as x6}from"./config-DoZCLcOb.js";import{n as k6,t as Pr}from"./cn-DYvqRARy.js";import{t as C6}from"./jsx-runtime-Blw4afVn.js";import{C as sa,S as _w,_ as xw,b as tr,f as S6,h as Du,m as E6,u as T6,v as kw,w as I6,y as L6}from"./fullscreen-k58KVlT-.js";import{l as Cw,o as O6}from"./dist-sZgjGm4S.js";import{d as A6}from"./menu-items-Dtw5N98_.js";import{a as R6,c as P6,i as jh,m as N6,n as M6,o as Sw,r as D6,s as j6,t as z6}from"./select-BwwUWhww.js";import{i as q6,t as zh}from"./tooltip-DmqhBBs6.js";import{t as Ew}from"./button-COIw2x9i.js";import{A as F6,At as qh,Bt as $t,C as B6,D as V6,Et as Tw,Ft as Iw,Gt as H6,H as Lw,Ht as xl,I as Ow,J as ju,Jt as la,Kt as Aw,Ot as as,S as $6,St as Ja,T as Rw,U as W6,Ut as Pw,Vt as U6,W as K6,Wt as zu,Xt as Wi,Yt as is,Zt as os,_t as Q6,at as Et,b as Nw,ct as Ui,f as Mw,it as G6,jt as J6,k as X6,l as ne,mt as Y6,nt as Dw,ot as Z6,p as e8,rt as ca,u as jw,ut as t8,xt as Fh,z as zw,zt as qu}from"./dist-VwkX7yeV.js";import{C as n8,D as r8,L as a8,O as i8,T as o8,b as s8,d as qw,f as l8,g as c8,h as u8,k as d8,n as f8,o as Bh,p as p8,s as h8,t as m8,u as g8,w as y8,x as v8}from"./dist-CeWYEVw7.js";import{a as kl,i as Fw,m as Vh,n as b8,r as Bw}from"./arrays-DAC2orgH.js";import{n as nr}from"./once-hq2TLzOp.js";import{t as w8}from"./capabilities-BmGdj50E.js";import{t as _8}from"./cjs-D5tzp-Y6.js";import{t as Cl}from"./createReducer-CYlwteGD.js";import{d as Vw,l as Hw,n as x8,o as $w,p as k8,r as Fu}from"./dist-BNTOYRCs.js";import{t as Ww}from"./main-BNL5rxQw.js";import{n as Uw,t as C8}from"./useNonce-CbdaHKzX.js";import{i as ss,r as S8,t as E8}from"./strings-pfr2N700.js";import{t as br}from"./requests-9-v2bhoi.js";import{a as T8,c as I8,d as L8,f as Kw,i as O8,l as A8,n as R8,o as Hh,r as P8,s as $h,t as N8,u as M8}from"./dist-BPkOpnKv.js";import{t as ut}from"./createLucideIcon-w-Qo9n0R.js";import{a as Wh,i as D8,o as j8,r as z8,t as q8}from"./useLifecycle-N3bfh_O1.js";import{t as F8}from"./check-B-sKate2.js";import{t as B8}from"./x-Bv2rCglF.js";import{t as V8,u as H8}from"./toDate-BGIVWsZ9.js";import{t as Uh}from"./database-zap-BxfYZ6ML.js";import{n as $8,t as Sl}from"./DeferredRequestRegistry-BLWK1eKa.js";import{t as Fn}from"./badge-CwbVR_sO.js";import{t as re}from"./preload-helper-D2MJg03u.js";import{a as Qw,s as W8}from"./dist-BvlMLwcr.js";import{a as U8,i as Kh,n as K8,r as Gw,t as Q8}from"./dist-CgYlATe-.js";import{n as G8}from"./stex-jWatZkll.js";import{t as El}from"./use-toast-BDYuj3zG.js";import{n as Jw}from"./paths-BzSgteR-.js";import{n as J8}from"./useTheme-DCDmxPD0.js";import{t as Qh}from"./purify.es-BFDc-_i_.js";let Gh,Jh,Xa,Xh,Xw,Yh,Zh,Yw,Zw,e_,t_,n_,r_,a_,Ya,em,i_,Bn,o_,Vn,s_,l_,tm,c_,ls,Tl,Bu,Vu,u_,Hu,Za,Ki,nm,d_,$u,f_,rm,p_,Wu,h_,m_,g_,Uu,y_,ot,am,im,v_,om,Ku,sm,b_,Qi,w_,rr,Il,ua,Ll,__,lm,Qu,x_,k_,C_,S_,E_,T_,I_,L_,Gu,O_,A_,cm,R_,P_,N_,da,M_,um,dm,Ol,fm,ar,Ju,pm,Hn,D_,hm,Xu,Gi,j_,z_,En,q_,F_,Yu,B_,Al,mm,V_,gm,Zu,ym,H_,vm,$_,ed,bm,W_,U_,Rl,td,wm,nd,Pl,Nr,_m,Nl,cs,rd,K_,Ml,Q_,xm,km,ad,Dl,G_,Cm,Sm,Ye,J_,id,X_,Ji,Y_,Z_,fa,Em,ex,tx,nx,rx,Tm,Im,ax,Lm,Xi,ix,od,ox,Om,Am,Rm,sx,lx,sd,Pm,Nm,ld,mn,cx,Mm,ux,cd,ei,dx,Dm,fx,px,hx,jm,jl,ud,mx,gx,dd,yx,zm,vx,fd,zl,pd,qm,bx,ql,hd,Fm,md,gd,Bm,Vm,Hm,$m,wx,_x,xx,Yi,Wm,kx,us,Um,Km,Cx,Qm,ti,yd,Sx,Ex,Gm,Jm,Xm,Tx,Ix,Ym,Lx,vd,Ox,Ax,Zm,Rx,e0,bd,t0,ds,Px,fs,Nx,Mx,n0,Dx,r0,a0,jx,zx,qx,Fx,Bx,Vx,Hx,i0,wd,$x,Wx,_d,xd,o0,wr,Ux,ni,s0,kd,X8=(async()=>{var ur,Af,pi;let pa,_r,ri;pa=rt((e=>{function n(ie,ee){var W=ie.length;ie.push(ee);e:for(;0<W;){var Ie=W-1>>>1,He=ie[Ie];if(0<s(He,ee))ie[Ie]=ee,ie[W]=He,W=Ie;else break e}}function a(ie){return ie.length===0?null:ie[0]}function o(ie){if(ie.length===0)return null;var ee=ie[0],W=ie.pop();if(W!==ee){ie[0]=W;e:for(var Ie=0,He=ie.length,et=He>>>1;Ie<et;){var Fe=2*(Ie+1)-1,Ne=ie[Fe],Le=Fe+1,Me=ie[Le];if(0>s(Ne,W))Le<He&&0>s(Me,Ne)?(ie[Ie]=Me,ie[Le]=W,Ie=Le):(ie[Ie]=Ne,ie[Fe]=W,Ie=Fe);else if(Le<He&&0>s(Me,W))ie[Ie]=Me,ie[Le]=W,Ie=Le;else break e}}return ee}function s(ie,ee){var W=ie.sortIndex-ee.sortIndex;return W===0?ie.id-ee.id:W}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var f=Date,d=f.now();e.unstable_now=function(){return f.now()-d}}var m=[],b=[],_=1,x=null,S=3,E=!1,L=!1,P=!1,q=!1,V=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function J(ie){for(var ee=a(b);ee!==null;){if(ee.callback===null)o(b);else if(ee.startTime<=ie)o(b),ee.sortIndex=ee.expirationTime,n(m,ee);else break;ee=a(b)}}function le(ie){if(P=!1,J(ie),!L)if(a(m)!==null)L=!0,A||(A=!0,ye());else{var ee=a(b);ee!==null&&ue(le,ee.startTime-ie)}}var A=!1,j=-1,$=5,oe=-1;function de(){return q?!0:!(e.unstable_now()-oe<$)}function he(){if(q=!1,A){var ie=e.unstable_now();oe=ie;var ee=!0;try{e:{L=!1,P&&(P=!1,B(j),j=-1),E=!0;var W=S;try{t:{for(J(ie),x=a(m);x!==null&&!(x.expirationTime>ie&&de());){var Ie=x.callback;if(typeof Ie=="function"){x.callback=null,S=x.priorityLevel;var He=Ie(x.expirationTime<=ie);if(ie=e.unstable_now(),typeof He=="function"){x.callback=He,J(ie),ee=!0;break t}x===a(m)&&o(m),J(ie)}else o(m);x=a(m)}if(x!==null)ee=!0;else{var et=a(b);et!==null&&ue(le,et.startTime-ie),ee=!1}}break e}finally{x=null,S=W,E=!1}ee=void 0}}finally{ee?ye():A=!1}}}var ye;if(typeof M=="function")ye=function(){M(he)};else if(typeof MessageChannel<"u"){var ke=new MessageChannel,we=ke.port2;ke.port1.onmessage=he,ye=function(){we.postMessage(null)}}else ye=function(){V(he,0)};function ue(ie,ee){j=V(function(){ie(e.unstable_now())},ee)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(ie){ie.callback=null},e.unstable_forceFrameRate=function(ie){0>ie||125<ie?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<ie?Math.floor(1e3/ie):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(ie){switch(S){case 1:case 2:case 3:var ee=3;break;default:ee=S}var W=S;S=ee;try{return ie()}finally{S=W}},e.unstable_requestPaint=function(){q=!0},e.unstable_runWithPriority=function(ie,ee){switch(ie){case 1:case 2:case 3:case 4:case 5:break;default:ie=3}var W=S;S=ie;try{return ee()}finally{S=W}},e.unstable_scheduleCallback=function(ie,ee,W){var Ie=e.unstable_now();switch(typeof W=="object"&&W?(W=W.delay,W=typeof W=="number"&&0<W?Ie+W:Ie):W=Ie,ie){case 1:var He=-1;break;case 2:He=250;break;case 5:He=1073741823;break;case 4:He=1e4;break;default:He=5e3}return He=W+He,ie={id:_++,callback:ee,priorityLevel:ie,startTime:W,expirationTime:He,sortIndex:-1},W>Ie?(ie.sortIndex=W,n(b,ie),a(m)===null&&ie===a(b)&&(P?(B(j),j=-1):P=!0,ue(le,W-Ie))):(ie.sortIndex=He,n(m,ie),L||E||(L=!0,A||(A=!0,ye()))),ie},e.unstable_shouldYield=de,e.unstable_wrapCallback=function(ie){var ee=S;return function(){var W=S;S=ee;try{return ie.apply(this,arguments)}finally{S=W}}}})),_r=rt(((e,n)=>{n.exports=pa()})),ri=rt((e=>{var n=_r(),a=Nu(),o=hw();function s(t){var r="https://react.dev/errors/"+t;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function f(t){var r=t,i=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,r.flags&4098&&(i=r.return),t=r.return;while(t)}return r.tag===3?i:null}function d(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function m(t){if(t.tag===31){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function b(t){if(f(t)!==t)throw Error(s(188))}function _(t){var r=t.alternate;if(!r){if(r=f(t),r===null)throw Error(s(188));return r===t?t:null}for(var i=t,l=r;;){var p=i.return;if(p===null)break;var g=p.alternate;if(g===null){if(l=p.return,l!==null){i=l;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===i)return b(p),t;if(g===l)return b(p),r;g=g.sibling}throw Error(s(188))}if(i.return!==l.return)i=p,l=g;else{for(var C=!1,I=p.child;I;){if(I===i){C=!0,i=p,l=g;break}if(I===l){C=!0,l=p,i=g;break}I=I.sibling}if(!C){for(I=g.child;I;){if(I===i){C=!0,i=g,l=p;break}if(I===l){C=!0,l=g,i=p;break}I=I.sibling}if(!C)throw Error(s(189))}}if(i.alternate!==l)throw Error(s(190))}if(i.tag!==3)throw Error(s(188));return i.stateNode.current===i?t:r}function x(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t;for(t=t.child;t!==null;){if(r=x(t),r!==null)return r;t=t.sibling}return null}var S=Object.assign,E=Symbol.for("react.element"),L=Symbol.for("react.transitional.element"),P=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),J=Symbol.for("react.context"),le=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),oe=Symbol.for("react.lazy"),de=Symbol.for("react.activity"),he=Symbol.for("react.memo_cache_sentinel"),ye=Symbol.iterator;function ke(t){return typeof t!="object"||!t?null:(t=ye&&t[ye]||t["@@iterator"],typeof t=="function"?t:null)}var we=Symbol.for("react.client.reference");function ue(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===we?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case q:return"Fragment";case B:return"Profiler";case V:return"StrictMode";case A:return"Suspense";case j:return"SuspenseList";case de:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case P:return"Portal";case J:return t.displayName||"Context";case M:return(t._context.displayName||"Context")+".Consumer";case le:var r=t.render;return t=t.displayName,t||(t=(t=r.displayName||r.name||"",t===""?"ForwardRef":"ForwardRef("+t+")")),t;case $:return r=t.displayName||null,r===null?ue(t.type)||"Memo":r;case oe:r=t._payload,t=t._init;try{return ue(t(r))}catch{}}return null}var ie=Array.isArray,ee=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ie={pending:!1,data:null,method:null,action:null},He=[],et=-1;function Fe(t){return{current:t}}function Ne(t){0>et||(t.current=He[et],He[et]=null,et--)}function Le(t,r){et++,He[et]=t.current,t.current=r}var Me=Fe(null),Tt=Fe(null),Pt=Fe(null),wa=Fe(null);function yo(t,r){switch(Le(Pt,r),Le(Tt,t),Le(Me,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?j2(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=j2(r),t=z2(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Ne(Me),Le(Me,t)}function On(){Ne(Me),Ne(Tt),Ne(Pt)}function jr(t){t.memoizedState!==null&&Le(wa,t);var r=Me.current,i=z2(r,t.type);r!==i&&(Le(Tt,t),Le(Me,i))}function hi(t){Tt.current===t&&(Ne(Me),Ne(Tt)),wa.current===t&&(Ne(wa),vl._currentValue=Ie)}var vo,Es;function mt(t){if(vo===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);vo=r&&r[1]||"",Es=-1<i.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+vo+t+Es}var Ts=!1;function yn(t,r){if(!t||Ts)return"";Ts=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(r){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(ae){var Z=ae}Reflect.construct(t,[],fe)}else{try{fe.call()}catch(ae){Z=ae}t.call(fe.prototype)}}else{try{throw Error()}catch(ae){Z=ae}(fe=t())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(ae){if(ae&&Z&&typeof ae.stack=="string")return[ae.stack,Z.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=l.DetermineComponentFrameRoot(),C=g[0],I=g[1];if(C&&I){var F=C.split(`
5
5
  `),X=I.split(`
@@ -26,7 +26,7 @@ ${o.join(`
26
26
  z-index: 100;
27
27
  max-width: 300px;
28
28
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
29
- `,a.textContent=n;let o=e.coordsAtPos(e.state.selection.main.head);o&&(a.style.left=`${o.left}px`,a.style.top=`${o.bottom+5}px`),document.body.appendChild(a),setTimeout(()=>{a.style.opacity="0",a.style.transition="opacity 0.2s",setTimeout(()=>a.remove(),200)},3e3)}function Wl(e){if(e==null)return!0;if(Array.isArray(e))return e.length===0||e.every(Wl);if(typeof e=="string")return Pg(e);let n=e.value;return typeof n=="string"?Pg(n):!1}function Pg(e){return e==null?!0:typeof e=="string"?e.trim()===""||/^[\s\n`]*$/.test(e):!1}function Jk(e,n){let a=[];return n.iterChanges((o,s,c,f,d)=>{let m=d.toString();if(o===0&&s===e.length){a.push({text:m});return}let b=ya(e,o),_=ya(e,s);a.push({range:{start:b,end:_},text:m})}),a.sort((o,s)=>{if(!o.range)return 1;if(!s.range)return-1;let c=o.range.start.line??-1,f=s.range.start.line??-1;if(c!==f)return f-c;let d=o.range.start.character??-1;return(s.range.start.character??-1)-d}),a}var Xk=Ww(),Yk=Object.fromEntries(Object.entries(Xk.CompletionItemKind).map(([e,n])=>[n,e])),Ng;(function(e){e.PlainText=1,e.Snippet=2})(Ng||(Ng={}));function Zk(e){return e.replaceAll(/\\\\/g,"").replaceAll(/(\$(\d+))/g,(n,a,o)=>"${"+o+"}")}function eC(e,n){let{detail:a,labelDetails:o,label:s,kind:c,textEdit:f,insertText:d,documentation:m,additionalTextEdits:b,insertTextFormat:_}=e,x={label:s,detail:(o==null?void 0:o.detail)||a,apply(S,E,L,P){if(f&&Qk(f)?S.dispatch(Vw(S.state,f.newText,or(S.state.doc,f.range.start),or(S.state.doc,f.range.end))):d&&_===Ng.Snippet&&n.useSnippetOnCompletion?k8(Zk(d))(S,null,L,P):S.dispatch(Vw(S.state,d||s,L,P)),!b)return;let q=b.sort(({range:{end:V}},{range:{end:B}})=>or(S.state.doc,V)<or(S.state.doc,B)?1:or(S.state.doc,V)>or(S.state.doc,B)?-1:0);for(let V of q)S.dispatch(S.state.update({changes:{from:or(S.state.doc,V.range.start),to:Ut(S.state.doc,V.range.end),insert:V.newText}}))},type:c&&Yk[c].toLowerCase()};return n.hasResolveProvider&&n.resolveItem?x.info=async()=>{var S;try{let E=await((S=n.resolveItem)==null?void 0:S.call(n,e)),L=document.createElement("div");L.classList.add("documentation");let P=(E==null?void 0:E.documentation)||m;return!P||Wl(P)?null:(n.allowHTMLContent?L.innerHTML=sr(P,n.markdownRenderer):L.textContent=sr(P,n.markdownRenderer),L)}catch(E){if(console.error("Failed to resolve completion item:",E),Wl(m))return null;if(m){let L=document.createElement("div");return L.classList.add("documentation"),n.allowHTMLContent?L.innerHTML=sr(m,n.markdownRenderer):L.textContent=sr(m,n.markdownRenderer),L}return null}}:m&&(x.info=()=>{let S=document.createElement("div");return S.classList.add("documentation"),n.allowHTMLContent?S.innerHTML=sr(m,n.markdownRenderer):S.textContent=sr(m,n.markdownRenderer),S}),x}function tC(e,n,a){let o=[n?nC(n):rC,a==="python"?aC:void 0].filter(Boolean),s=e;if(n){let c=n.toLowerCase();/^\w+$/.test(c)&&(s=s.filter(({label:f,filterText:d})=>(d??f).toLowerCase().startsWith(c)))}for(let c of o)s.sort(c);return s}function nC(e){return(n,a)=>{let o=n.sortText??n.label,s=a.sortText??a.label;switch(!0){case(o.startsWith(e)&&!s.startsWith(e)):return-1;case(!o.startsWith(e)&&s.startsWith(e)):return 1}return o.localeCompare(s)}}function rC(e,n){let a=e.sortText??e.label,o=n.sortText??n.label;return a.localeCompare(o)}function aC(e,n){let a=e.label.endsWith("="),o=n.label.endsWith("=");return a&&!o?-1:!a&&o?1:0}function Mg(e){let n=new Proxy({},{get(){throw Error(e)}});return function(a){return a.at(-1)??n}}const Dg=xl.define({combine:Mg("No document URI provided. Either pass a one into the extension or use documentUri.of().")}),iC=xl.define({combine:Mg("No language ID provided. Either pass a one into the extension or use languageId.of().")});let Jd,jg;Jd=Ol(),jg=1e4,cs=class{constructor({rootUri:e,workspaceFolders:n,transport:a,initializationOptions:o,capabilities:s,timeout:c=jg,getWorkspaceConfiguration:f}){ve(this,"ready");ve(this,"capabilities");ve(this,"initializePromise");ve(this,"rootUri");ve(this,"workspaceFolders");ve(this,"timeout");ve(this,"transport");ve(this,"requestManager");ve(this,"client");ve(this,"initializationOptions");ve(this,"clientCapabilities");ve(this,"notificationListeners",new Set);this.rootUri=e,this.workspaceFolders=n,this.transport=a,this.initializationOptions=o,this.clientCapabilities=s,this.timeout=c,this.ready=!1,this.capabilities=null,this.requestManager=new Jd.RequestManager([this.transport]),this.client=new Jd.Client(this.requestManager),this.client.onNotification(m=>{this.processNotification(m)});let d=this.transport;d!=null&&d.connection&&d.connection.addEventListener("message",m=>{let b=JSON.parse(m.data);b.method==="workspace/configuration"&&f?d.connection.send(JSON.stringify({jsonrpc:"2.0",id:b.id,result:f(b.params)})):b.method&&b.id&&d.connection.send(JSON.stringify({jsonrpc:"2.0",id:b.id,result:null}))}),this.initializePromise=this.initialize()}getInitializationOptions(){let e={textDocument:{hover:{dynamicRegistration:!0,contentFormat:["markdown","plaintext"]},moniker:{},synchronization:{dynamicRegistration:!0,willSave:!1,didSave:!1,willSaveWaitUntil:!1},codeAction:{dynamicRegistration:!0,codeActionLiteralSupport:{codeActionKind:{valueSet:["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},resolveSupport:{properties:["edit"]}},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!0,commitCharactersSupport:!0,documentationFormat:["markdown","plaintext"],deprecatedSupport:!1,preselectSupport:!1},contextSupport:!1},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["markdown","plaintext"]}},declaration:{dynamicRegistration:!0,linkSupport:!0},definition:{dynamicRegistration:!0,linkSupport:!0},typeDefinition:{dynamicRegistration:!0,linkSupport:!0},implementation:{dynamicRegistration:!0,linkSupport:!0},rename:{dynamicRegistration:!0,prepareSupport:!0}},workspace:{didChangeConfiguration:{dynamicRegistration:!0}}};return{capabilities:this.clientCapabilities?typeof this.clientCapabilities=="function"?this.clientCapabilities(e):this.clientCapabilities:e,initializationOptions:this.initializationOptions,processId:null,rootUri:this.rootUri,workspaceFolders:this.workspaceFolders}}async initialize(){let{capabilities:e}=await this.request("initialize",this.getInitializationOptions(),this.timeout*3);this.capabilities=e,this.notify("initialized",{}),this.ready=!0}close(){this.client.close()}textDocumentDidOpen(e){return this.notify("textDocument/didOpen",e)}textDocumentDidChange(e){return this.notify("textDocument/didChange",e)}async textDocumentHover(e){return await this.request("textDocument/hover",e,this.timeout)}async textDocumentCompletion(e){return await this.request("textDocument/completion",e,this.timeout)}async completionItemResolve(e){return await this.request("completionItem/resolve",e,this.timeout)}async textDocumentDefinition(e){return await this.request("textDocument/definition",e,this.timeout)}async textDocumentCodeAction(e){return await this.request("textDocument/codeAction",e,this.timeout)}async textDocumentRename(e){return await this.request("textDocument/rename",e,this.timeout)}async textDocumentPrepareRename(e){return await this.request("textDocument/prepareRename",e,this.timeout)}async textDocumentSignatureHelp(e){return await this.request("textDocument/signatureHelp",e,this.timeout)}onNotification(e){return this.notificationListeners.add(e),()=>this.notificationListeners.delete(e)}request(e,n,a){return this.client.request({method:e,params:n},a)}notify(e,n){return this.client.notify({method:e,params:n})}processNotification(e){this.notificationListeners.forEach(n=>n(e))}},Ol();var va=Ww(),zg=console.log;function oC(){return String(Date.now()+Math.random())}let Xd;Pl=la.define(),Rl=is.define({create:()=>null,update(e,n){for(let a of n.effects)if(a.is(Pl))return a.value;if(e&&n.docChanged){let a=n.changes.mapPos(e.pos),o=e.end==null?void 0:n.changes.mapPos(e.end);return{...e,pos:a,end:o}}return e},provide:e=>J6.from(e)}),Xd=Iw.define();var sC=20,lC=class{constructor(e){ve(this,"documentVersion");ve(this,"pluginId");ve(this,"client");ve(this,"documentUri");ve(this,"languageId");ve(this,"view");ve(this,"allowHTMLContent");ve(this,"useSnippetOnCompletion");ve(this,"sendIncrementalChanges");ve(this,"featureOptions");ve(this,"onGoToDefinition");ve(this,"markdownRenderer");ve(this,"disposeListener");ve(this,"lastSeenDiagnosticsVersion",0);let{client:n,documentUri:a,languageId:o,view:s,featureOptions:c,sendIncrementalChanges:f=!0,allowHTMLContent:d=!1,useSnippetOnCompletion:m=!1,onGoToDefinition:b,markdownRenderer:_=Rg}=e;this.documentVersion=0,this.pluginId=oC(),this.client=n,this.documentUri=a,this.languageId=o,this.view=s,this.allowHTMLContent=d,this.useSnippetOnCompletion=m,this.sendIncrementalChanges=f,this.featureOptions=c,this.onGoToDefinition=b,this.markdownRenderer=_,this.disposeListener=n.onNotification(this.processNotification.bind(this)),this.initialize({documentText:this.view.state.doc.toString()})}update({state:e,docChanged:n,startState:{doc:a},changes:o}){n&&(this.sendIncrementalChanges?this.sendChanges(Jk(a,o)):this.sendChanges([{text:e.doc.toString()}]))}destroy(){var e;(e=this.disposeListener)==null||e.call(this)}async initialize({documentText:e}){this.client.initializePromise&&await this.client.initializePromise,await this.client.textDocumentDidOpen({textDocument:{uri:this.documentUri,languageId:this.languageId,text:e,version:this.documentVersion}})}async sendChanges(e){if(this.client.ready)try{await this.client.textDocumentDidChange({textDocument:{uri:this.documentUri,version:++this.documentVersion},contentChanges:e})}catch(n){console.error(n)}}requestDiagnostics(e){this.sendChanges([{text:e.state.doc.toString()}])}async requestHoverTooltip(e,{line:n,character:a}){var b;if(!this.featureOptions.hoverEnabled||!(this.client.ready&&((b=this.client.capabilities)!=null&&b.hoverProvider)))return null;let o=await this.client.textDocumentHover({textDocument:{uri:this.documentUri},position:{line:n,character:a}});if(!o)return null;let{contents:s,range:c}=o,f=Ut(e.state.doc,{line:n,character:a}),d;if(c&&(f=Ut(e.state.doc,c.start),d=Ut(e.state.doc,c.end)),f==null||Wl(s))return null;let m=document.createElement("div");return m.classList.add("documentation","cm-lsp-hover-tooltip"),this.allowHTMLContent?m.innerHTML=sr(s,this.markdownRenderer):m.textContent=sr(s,this.markdownRenderer),{pos:f,end:d,create:_=>({dom:m}),above:!0}}async requestCompletion(e,{line:n,character:a},{triggerKind:o,triggerCharacter:s}){var S;if(!this.featureOptions.completionEnabled||!(this.client.ready&&((S=this.client.capabilities)!=null&&S.completionProvider)))return null;let c=await this.client.textDocumentCompletion({textDocument:{uri:this.documentUri},position:{line:n,character:a},context:{triggerKind:o,triggerCharacter:s}});if(!c)return null;let f="items"in c?c.items:c,d=Kk(f),m=d?e.matchBefore(d)??e.matchBefore(/[a-zA-Z0-9_]+/):e.matchBefore(/[a-zA-Z0-9_]+/),{pos:b}=e,_=tC(f,m==null?void 0:m.text,this.languageId);m&&(b=m.from);let x=_.map(E=>{var L,P;return eC(E,{allowHTMLContent:this.allowHTMLContent,useSnippetOnCompletion:this.useSnippetOnCompletion,hasResolveProvider:((P=(L=this.client.capabilities)==null?void 0:L.completionProvider)==null?void 0:P.resolveProvider)??!1,resolveItem:this.client.completionItemResolve.bind(this.client)})});return{from:b,options:x,filter:!1}}async requestDefinition(e,{line:n,character:a}){var _;if(!this.featureOptions.definitionEnabled||!(this.client.ready&&((_=this.client.capabilities)!=null&&_.definitionProvider)))return;let o=await this.client.textDocumentDefinition({textDocument:{uri:this.documentUri},position:{line:n,character:a}});if(!o)return;let s=Array.isArray(o)?o:[o];if(s.length===0)return;let c=s[0];if(!c)return;let f="uri"in c?c.uri:c.targetUri,d="range"in c?c.range:c.targetRange,m=f!==this.documentUri,b={uri:f,range:d,isExternalDocument:m};return m||e.dispatch(e.state.update({selection:{anchor:or(e.state.doc,d.start),head:Ut(e.state.doc,d.end)}})),this.onGoToDefinition&&this.onGoToDefinition(b),b}processNotification(e){try{e.method==="textDocument/publishDiagnostics"&&this.processDiagnostics(e.params)}catch(n){zg(n)}}async processDiagnostics(e){if(e.uri!==this.documentUri)return;if(e.version!=null&&e.version>this.lastSeenDiagnosticsVersion&&(this.lastSeenDiagnosticsVersion=e.version,this.clearDiagnostics()),!this.featureOptions.diagnosticsEnabled){this.clearDiagnostics();return}let n={[va.DiagnosticSeverity.Error]:"error",[va.DiagnosticSeverity.Warning]:"warning",[va.DiagnosticSeverity.Information]:"info",[va.DiagnosticSeverity.Hint]:"info"},a=e.diagnostics.map(async({range:s,message:c,severity:f,code:d,source:m})=>{var _;let b=(_=await this.requestCodeActions(s,[d]))==null?void 0:_.map(x=>{var S;return{name:"command"in x&&typeof x.command=="object"&&((S=x.command)==null?void 0:S.title)||x.title,apply:async()=>{var E;if("edit"in x&&((E=x.edit)!=null&&E.changes)){let L=x.edit.changes[this.documentUri];if(!L)return;for(let P of L)this.view.dispatch(this.view.state.update({changes:{from:or(this.view.state.doc,P.range.start),to:Ut(this.view.state.doc,P.range.end),insert:P.newText}}))}"command"in x&&x.command&&zg("Executing command:",x.command)}}});return{from:or(this.view.state.doc,s.start),to:or(this.view.state.doc,s.end),severity:n[f??va.DiagnosticSeverity.Error],message:c,renderMessage:()=>{let x=document.createElement("div");return x.innerHTML=this.markdownRenderer(c),x},source:m||this.languageId,markClass:this.pluginId,actions:b}}),o=await Promise.all(a);this.addDiagnostics(o)}addDiagnostics(e){if(e.length===0)return;let n=this.view.state,a=[];p8(n,c=>(a.push(c),!0));let o=new Set(e.map(c=>c.source).filter(Boolean)),s=e.filter(c=>!o.has(c.source));this.view.dispatch(qw(n,[...s,...e]))}clearDiagnostics(){this.view.dispatch(qw(this.view.state,[]))}async requestCodeActions(e,n){var a;return!this.featureOptions.codeActionsEnabled||!(this.client.ready&&((a=this.client.capabilities)!=null&&a.codeActionProvider))?null:await this.client.textDocumentCodeAction({textDocument:{uri:this.documentUri},range:e,context:{diagnostics:[{range:e,code:n[0],source:this.languageId,message:""}]}})}async requestRename(e,{line:n,character:a}){var o;if(this.featureOptions.renameEnabled){if(!this.client.ready){In(e,"Language server not ready");return}if(!((o=this.client.capabilities)!=null&&o.renameProvider)){In(e,"Rename not supported by language server");return}try{let s=await this.client.textDocumentPrepareRename({textDocument:{uri:this.documentUri},position:{line:n,character:a}}).catch(()=>this.prepareRenameFallback(e,{line:n,character:a}));if(!s||"defaultBehavior"in s){In(e,"Cannot rename this symbol");return}let c=document.createElement("div");c.className="cm-rename-popup",c.style.cssText="position: absolute; padding: 4px; background: white; border: 1px solid #ddd; box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 99;";let f=document.createElement("input");f.type="text",f.style.cssText="width: 200px; padding: 4px; border: 1px solid #ddd;";let d="range"in s?s.range:s,m=Ut(e.state.doc,d.start);if(m==null)return;let b=Ut(e.state.doc,d.end);f.value=e.state.doc.sliceString(m,b),c.appendChild(f);let _=e.coordsAtPos(m);if(!_)return;c.style.left=`${_.left}px`,c.style.top=`${_.bottom+5}px`;let x=async()=>{let E=f.value.trim();if(!E){In(e,"New name cannot be empty"),c.remove();return}if(E===f.defaultValue){c.remove();return}try{let L=await this.client.textDocumentRename({textDocument:{uri:this.documentUri},position:{line:n,character:a},newName:E});await this.applyRenameEdit(e,L)}catch(L){In(e,`Rename failed: ${L instanceof Error?L.message:"Unknown error"}`)}finally{c.remove()}};f.addEventListener("keydown",E=>{E.key==="Enter"?x():E.key==="Escape"&&c.remove(),E.stopPropagation()});let S=E=>{c.contains(E.target)||(c.remove(),document.removeEventListener("mousedown",S))};document.addEventListener("mousedown",S),document.body.appendChild(c),f.focus(),f.select()}catch(s){In(e,`Rename failed: ${s instanceof Error?s.message:"Unknown error"}`)}}}async requestSignatureHelp(e,{line:n,character:a},o=void 0){var s,c,f;if(!(this.featureOptions.signatureHelpEnabled&&this.client.ready&&((s=this.client.capabilities)!=null&&s.signatureHelpProvider)))return null;try{let d=await this.client.textDocumentSignatureHelp({textDocument:{uri:this.documentUri},position:{line:n,character:a},context:{isRetrigger:!1,triggerKind:1,triggerCharacter:o}});if(!(d!=null&&d.signatures)||d.signatures.length===0)return null;let m=this.createTooltipContainer(),b=d.activeSignature??0,_=d.signatures[b]||d.signatures[0];if(!_)return null;let x=d.activeParameter??_.activeParameter??0,S=this.createSignatureElement(_,x);m.appendChild(S),_.documentation&&m.appendChild(this.createDocumentationElement(_.documentation));let E=(c=_.parameters)==null?void 0:c[x];E!=null&&E.documentation&&m.appendChild(this.createParameterDocElement(E.documentation));let L=Ut(e.state.doc,{line:n,character:a});return L==null?null:{pos:L,end:L,create:P=>({dom:m}),above:((f=this.featureOptions.signatureHelpOptions)==null?void 0:f.position)==="above"}}catch(d){return console.error("Signature help error:",d),null}}async showSignatureHelpTooltip(e,n,a){let o=await this.requestSignatureHelp(e,ya(e.state.doc,n),a);e.dispatch({effects:Pl.of(o)})}createTooltipContainer(){let e=document.createElement("div");return e.classList.add("cm-signature-help"),e.style.cssText="padding: 6px; max-width: 400px;",e}createSignatureElement(e,n){let a=document.createElement("div");if(a.classList.add("cm-signature"),a.style.cssText="font-family: monospace; margin-bottom: 4px;",!e.label||typeof e.label!="string")return a.textContent="Signature information unavailable",a;let o=e.label,s=e.parameters||[];if(s.length===0||!s[n])return a.textContent=o,a;let c=s[n].label;return typeof c=="string"?this.allowHTMLContent?a.innerHTML=o.replace(c,`<strong class="cm-signature-active-param">${c}</strong>`):a.textContent=o.replace(c,`\xAB${c}\xBB`):Array.isArray(c)&&c.length===2?this.applyRangeHighlighting(a,o,c[0],c[1]):a.textContent=o,a}applyRangeHighlighting(e,n,a,o){e.textContent="";let s=n.substring(0,a),c=n.substring(a,o),f=n.substring(o);e.appendChild(document.createTextNode(s));let d=document.createElement("span");d.classList.add("cm-signature-active-param"),d.style.cssText="font-weight: bold; text-decoration: underline;",d.textContent=c,e.appendChild(d),e.appendChild(document.createTextNode(f))}createDocumentationElement(e){let n=document.createElement("div");n.classList.add("cm-signature-docs"),n.style.cssText="margin-top: 4px; color: #666;";let a=sr(e,this.markdownRenderer);return this.allowHTMLContent?n.innerHTML=a:n.textContent=a,n}createParameterDocElement(e){let n=document.createElement("div");n.classList.add("cm-parameter-docs"),n.style.cssText="margin-top: 4px; font-style: italic; border-top: 1px solid #eee; padding-top: 4px;";let a=sr(e,this.markdownRenderer);return this.allowHTMLContent?n.innerHTML=a:n.textContent=a,n}prepareRenameFallback(e,{line:n,character:a}){let o=e.state.doc.line(n+1).text,s=/\w+/g,c,f=a,d=a;for(;(c=s.exec(o))!==null;){let m=c.index,b=c.index+c[0].length;if(a>=m&&a<=b){f=m,d=b;break}}return f===a&&d===a?null:{range:{start:{line:n,character:f},end:{line:n,character:d}},placeholder:o.slice(f,d)}}async applyRenameEdit(e,n){if(!n)return In(e,"No edit returned from language server"),!1;let a=n.changes??{},o=n.documentChanges??[];if(Object.keys(a).length===0&&o.length===0)return In(e,"No changes to apply"),!1;if(o.length>0)for(let s of o){if("textDocument"in s){if(s.textDocument.uri!==this.documentUri){In(e,"Multi-file rename not supported yet");continue}let c=s.edits.sort((f,d)=>{let m=Ut(e.state.doc,f.range.start);return(Ut(e.state.doc,d.range.start)??0)-(m??0)}).map(f=>({from:Ut(e.state.doc,f.range.start)??0,to:Ut(e.state.doc,f.range.end)??0,insert:f.newText}));return e.dispatch(e.state.update({changes:c})),!0}return In(e,"File creation, deletion, or renaming operations not supported yet"),!1}else if(Object.keys(a).length>0)for(let[s,c]of Object.entries(a)){if(s!==this.documentUri){In(e,"Multi-file rename not supported yet");continue}let f=c.sort((d,m)=>{let b=Ut(e.state.doc,d.range.start);return(Ut(e.state.doc,m.range.start)??0)-(b??0)}).map(d=>({from:Ut(e.state.doc,d.range.start)??0,to:Ut(e.state.doc,d.range.end)??0,insert:d.newText}));e.dispatch(e.state.update({changes:f}))}return!1}};om=function(e){var f;let n=null,a={rename:"F2",goToDefinition:"F12",signatureHelp:"Mod-Shift-Space",...e.keyboardShortcuts},o=e.client,s={diagnosticsEnabled:!0,hoverEnabled:!0,completionEnabled:!0,definitionEnabled:!0,renameEnabled:!0,codeActionsEnabled:!0,signatureHelpEnabled:!0,signatureActivateOnTyping:!1,signatureHelpOptions:{position:"below"},...e},c=[Ui.define(d=>(n=new lC({client:o,documentUri:e.documentUri??d.state.facet(Dg),languageId:e.languageId??d.state.facet(iC),view:d,featureOptions:s,sendIncrementalChanges:e.sendIncrementalChanges,allowHTMLContent:e.allowHTMLContent,useSnippetOnCompletion:e.useSnippetOnCompletion,onGoToDefinition:e.onGoToDefinition,markdownRenderer:e.markdownRenderer}),n))];if(c.push(Ja.of([{key:a.signatureHelp,run:d=>{if(!(n&&s.signatureHelpEnabled))return!1;let m=d.state.selection.main.head;return n.showSignatureHelpTooltip(d,m),!0}},{key:a.rename,run:d=>{if(!(n&&s.renameEnabled))return!1;let m=d.state.selection.main.head;return n.requestRename(d,ya(d.state.doc,m)),!0}},{key:a.goToDefinition,run:d=>{if(!(n&&s.definitionEnabled))return!1;let m=d.state.selection.main.head;return n.requestDefinition(d,ya(d.state.doc,m)).catch(b=>In(d,`Go to definition failed: ${b instanceof Error?b.message:"Unknown error"}`)),!0}}])),s.hoverEnabled&&c.push(Fh((d,m)=>n==null?null:n.requestHoverTooltip(d,ya(d.state.doc,m)),e.hoverConfig)),s.signatureHelpEnabled){c.push(Rl);let d=m=>m.state.field(Rl)?(m.dispatch({effects:Pl.of(null)}),!0):!1;c.push(Et.domEventHandlers({mousedown:(m,b)=>(d(b),!1)})),c.push(Ja.of([{key:")",run:m=>(d(m),!1)},{key:"Escape",run:m=>d(m)}])),c.push(Et.updateListener.of(m=>{if(!(n&&s.signatureActivateOnTyping)||!m.state.field(Rl)||!(m.selectionSet||m.docChanged))return;let b=m.state.selection.main.head;fC(m.state.doc,b)||d(m.view)})),c.push(Et.updateListener.of(async m=>{var E;if(!(n&&m.docChanged)||m.transactions.some(L=>L.annotation(Xd))||!((E=n.client.capabilities)!=null&&E.signatureHelpProvider)||!s.signatureActivateOnTyping)return;let b=n.client.capabilities.signatureHelpProvider.triggerCharacters||["(",","],_=m.changes,x=-1,S;_.iterChanges((L,P,q,V,B)=>{if(x>=0)return;let M=uC(B.toString(),q,b);M&&(x=M.triggerPos,S=M.triggerCharacter)}),x>=0&&n.showSignatureHelpTooltip(m.view,x,S)}))}return s.completionEnabled&&c.push(Fu({...e.completionConfig,override:[async d=>{var x,S;if(n==null)return null;let{state:m,pos:b}=d,_=cC(d,((S=(x=n.client.capabilities)==null?void 0:x.completionProvider)==null?void 0:S.triggerCharacters)??[],e.completionMatchBefore);return _==null?null:await n.requestCompletion(d,ya(m.doc,b),_)},...((f=e.completionConfig)==null?void 0:f.override)||[]]})),c.push(Et.domEventHandlers({click:(d,m)=>{if(s.definitionEnabled&&a.goToDefinition==="ctrlcmd"&&(d.ctrlKey||d.metaKey)){let b=m.posAtCoords({x:d.clientX,y:d.clientY});b&&n&&(n.requestDefinition(m,ya(m.state.doc,b)).catch(_=>In(m,`Go to definition failed: ${_ instanceof Error?_.message:"Unknown error"}`)),d.preventDefault())}}})),c};function cC(e,n,a){let{state:o,pos:s,explicit:c}=e,f=o.doc.lineAt(s),d=va.CompletionTriggerKind.Invoked,m,b=f.text[s-f.from-1]||"",_=n==null?void 0:n.includes(b);return!c&&_&&(d=va.CompletionTriggerKind.TriggerCharacter,m=b),d===va.CompletionTriggerKind.Invoked&&!e.matchBefore(a||/(\w+|\w+\.|\/|,)$/)?null:{triggerKind:d,triggerCharacter:m}}function uC(e,n,a){if(!e)return null;for(let o of a){let s=e.indexOf(o);if(s!==-1)return{triggerPos:n+s+1,triggerCharacter:o}}return null}function dC(e){let n=0;for(let a of e)a==="("?n++:a===")"&&n--;return n}function fC(e,n,a=sC){let o=e.lineAt(n),s=Math.max(1,o.number-a),c=e.line(s).from;return dC(e.sliceString(c,n))>0}yd=function(e,n,a={}){let{preserveCursor:o=!0,effects:s,userEvent:c}=a,f=e.state.doc;if(f.toString()!==n)if(o&&e.hasFocus){let d=e.state.selection.main.head,m=f.lineAt(d),b=m.number,_=d-m.from,x=e.state.update({changes:{from:0,to:f.length,insert:n}}).state.doc,S;if(b<=x.lines){let E=x.line(b),L=E.length;S=E.from+Math.min(_,L)}else S=x.line(x.lines).to;e.dispatch({changes:{from:0,to:f.length,insert:n},annotations:Xd.of(!0),selection:{anchor:S},effects:s,userEvent:c})}else e.dispatch({changes:{from:0,to:f.length,insert:n},effects:s,userEvent:c})},Qi=function(){return xl.define({combine:e=>e.find(n=>n!==void 0)})};const qg=Qi(),Fg=Qi(),Yd=Qi(),Ul=Qi(),Bg=Qi();f_=function({cellId:e,completionConfig:n,hotkeys:a,placeholderType:o,lspConfig:s,diagnosticsConfig:c}){return[Ul.of(e),qg.of(n),Fg.of(a),Yd.of(o),Bg.of({...s,diagnostics:c})]},ed=new qu;function pC(e){return Object.values(e.cellRuntime).some(n=>n.status==="running")}function hC(e){return Object.values(e.cellRuntime).filter(n=>n.status==="running"||n.status==="queued").length}function mC(e){return mm(e).length>0}h_=function(e){return e.cellIds.inOrderIds.map(n=>e.cellData[n])};function gC({cellHandles:e}){let n={};for(let[a,o]of Rr.entries(e))o.current&&(n[a]=o.current.editorView);return n}pm=function(e){let{cellIds:n,cellData:a}=e,o=[];for(let s of n.inOrderIds)a[s].config.disabled&&o.push(s);return o},s0=function(e){let{cellIds:n,cellData:a}=e,o=[];for(let s of n.inOrderIds)a[s].config.disabled||o.push(s);return o};function yC(e){return e.history.length>0}n_=function(e,n){let a=e.cellIds.findWithId(n).getDescendants(n);return{stale:a.some(o=>{var s,c;return((s=e.cellRuntime[o])==null?void 0:s.staleInputs)||((c=e.cellData[o])==null?void 0:c.edited)}),errored:a.some(o=>{var s;return(s=e.cellRuntime[o])==null?void 0:s.errored}),runningOrQueued:a.some(o=>{var s,c;return((s=e.cellRuntime[o])==null?void 0:s.status)==="running"||((c=e.cellRuntime[o])==null?void 0:c.status)==="queued"})}},mm=function(e){let{cellIds:n,cellData:a,cellRuntime:o}=e;return n.inOrderIds.filter(s=>ym({executionTime:o[s].runElapsedTimeMs??a[s].lastExecutionTime,status:o[s].status,errored:o[s].errored,interrupted:o[s].interrupted,stopped:o[s].stopped})||a[s].edited||o[s].interrupted||o[s].staleInputs&&!(o[s].status==="disabled-transitively"||a[s].config.disabled))},ym=function({executionTime:e,status:n,errored:a,interrupted:o,stopped:s}){return e===null&&n!=="queued"&&n!=="running"&&!(a||o||s)},ot=xl.define({combine:e=>e[0]}),ua=xl.define({combine:e=>e[0]});var vC={...Hh,caseInsensitiveIdentifiers:!0,identifierQuotes:"`"};const Vg=$h.define(vC),Hg=$h.define({charSetCasts:!0,doubleQuotedStrings:!1,unquotedBitLiterals:!0,hashComments:!1,spaceAfterDashes:!1,specialVar:"@?",identifierQuotes:'"',caseInsensitiveIdentifiers:!0,keywords:"percentile_cont row_number rank dense_rank rank_dense percent_rank cume_dist ntile lag lead first_value last_value nth_value !__postfix !~~ !~~* % & && * ** + - ->> / // <-> << <=> <@ >> @ @> Calendar JSON TimeZone ^ ^@ abort abs absolute access access_mode acos acosh action add add_parquet_key admin after age aggregate alias all all_profiling_output allow_community_extensions allow_extensions_metadata_mismatch allow_persistent_secrets allow_unredacted_secrets allow_unsigned_extensions allowed_directories allowed_paths also alter always analyse analyze and anti any any_value apply approx_count_distinct approx_quantile approx_top_k arbitrary arg_max arg_max_null arg_min arg_min_null argmax argmin array array_agg array_aggr array_aggregate array_append array_apply array_cat array_concat array_contains array_cosine_distance array_cosine_similarity array_cross_product array_distance array_distinct array_dot_product array_extract array_filter array_grade_up array_has array_has_all array_has_any array_indexof array_inner_product array_intersect array_length array_negative_dot_product array_negative_inner_product array_pop_back array_pop_front array_position array_prepend array_push_back array_push_front array_reduce array_resize array_reverse array_reverse_sort array_select array_slice array_sort array_to_json array_to_string array_to_string_comma_default array_transform array_unique array_value array_where array_zip arrow_large_buffer_size arrow_lossless_conversion arrow_output_list_view arrow_output_version arrow_scan arrow_scan_dumb as asc ascii asin asinh asof asof_loop_join_threshold assertion assignment asymmetric at atan atan2 atanh attach attribute authorization autoinstall_extension_repository autoinstall_known_extensions autoload_known_extensions avg backward bar base64 before begin between bigint bin binary binary_as_string bit bit_and bit_count bit_length bit_or bit_position bit_xor bitstring bitstring_agg blob bool bool_and bool_or boolean both bpchar by bytea cache call called can_cast_implicitly cardinality cascade cascaded case cast cast_to_type catalog catalog_error_max_schemas cbrt ceil ceiling centuries century chain char char_length character character_length characteristics check checkpoint checkpoint_threshold chr class close cluster coalesce col_description collate collation collations column columns combine comment comments commit committed compression concat concat_ws concurrently configuration conflict connection constant_or_null constraint constraints contains content continue conversion copy copy_database corr cos cosh cost cot count count_if count_star countif covar_pop covar_samp create create_sort_key cross csv cube current current_catalog current_connection_id current_database current_date current_localtime current_localtimestamp current_query current_query_id current_role current_schema current_schemas current_setting current_transaction_id current_user currval cursor custom_extension_repository custom_profiling_settings custom_user_agent cycle damerau_levenshtein data database database_list database_size date date_add date_diff date_part date_sub date_trunc datediff datepart datesub datetime datetrunc day dayname dayofmonth dayofweek dayofyear days deallocate debug_asof_iejoin debug_checkpoint_abort debug_force_external debug_force_no_cross_product debug_skip_checkpoint_on_commit debug_verify_vector debug_window_mode dec decade decades decimal declare decode default default_block_size default_collation default_null_order default_order default_secret_storage defaults deferrable deferred definer degrees delete delimiter delimiters depends desc describe detach dictionary disable disable_checkpoint_on_shutdown disable_logging disable_object_cache disable_optimizer disable_parquet_prefetching disable_print_progress_bar disable_profile disable_profiling disable_progress_bar disable_timestamptz_casts disable_verification disable_verify_external disable_verify_fetch_row disable_verify_parallelism disable_verify_serializer disabled_compression_methods disabled_filesystems disabled_log_types disabled_optimizers discard distinct divide do document domain double drop duckdb_api duckdb_columns duckdb_constraints duckdb_databases duckdb_dependencies duckdb_extensions duckdb_external_file_cache duckdb_functions duckdb_indexes duckdb_keywords duckdb_log_contexts duckdb_logs duckdb_logs_parsed duckdb_memory duckdb_optimizers duckdb_prepared_statements duckdb_schemas duckdb_secret_types duckdb_secrets duckdb_sequences duckdb_settings duckdb_table_sample duckdb_tables duckdb_temporary_files duckdb_types duckdb_variables duckdb_views dynamic_or_filter_threshold each editdist3 element_at else enable enable_checkpoint_on_shutdown enable_external_access enable_external_file_cache enable_fsst_vectors enable_geoparquet_conversion enable_http_logging enable_http_metadata_cache enable_logging enable_macro_dependencies enable_object_cache enable_optimizer enable_print_progress_bar enable_profile enable_profiling enable_progress_bar enable_progress_bar_print enable_verification enable_view_dependencies enabled_log_types encode encoding encrypted end ends_with entropy enum enum_code enum_first enum_last enum_range enum_range_boundary epoch epoch_ms epoch_ns epoch_us equi_width_bins era error errors_as_json escape even event except exclude excluding exclusive execute exists exp explain explain_output export export_state extension extension_directory extension_versions extensions external external_threads extract factorial false family favg fdiv fetch file_search_path filter finalize first flatten float float4 float8 floor fmod following for force force_bitpacking_mode force_checkpoint force_compression foreign format formatReadableDecimalSize formatReadableSize format_bytes format_pg_type format_type forward freeze from from_base64 from_binary from_hex from_json from_json_strict fsum full function functions gamma gcd gen_random_uuid generate_series generate_subscripts generated geomean geometric_mean get_bit get_block_size get_current_time get_current_timestamp getvariable glob global grade_up grant granted greatest greatest_common_divisor group group_concat grouping grouping_id groups guid hamming handler having header hex histogram histogram_exact histogram_values hold home_directory hour hours http_logging_output http_proxy http_proxy_password http_proxy_username hugeint identity ieee_floating_point_ops if ignore ilike ilike_escape immediate immediate_transaction_mode immutable implicit import import_database in in_search_path include including increment index index_scan_max_count index_scan_percentage indexes inet_client_addr inet_client_port inet_server_addr inet_server_port inherit inherits initially inline inner inout input insensitive insert install instead instr int int1 int128 int16 int2 int32 int4 int64 int8 integer integer_division integral intersect interval into invoker is is_histogram_other_bin isfinite isinf isnan isnull isodow isolation isoyear jaccard jaro_similarity jaro_winkler_similarity join json json_array json_array_length json_contains json_deserialize_sql json_each json_execute_serialized_sql json_exists json_extract json_extract_path json_extract_path_text json_extract_string json_group_array json_group_object json_group_structure json_keys json_merge_patch json_object json_pretty json_quote json_serialize_plan json_serialize_sql json_structure json_transform json_transform_strict json_tree json_type json_valid json_value julian kahan_sum key kurtosis kurtosis_pop label lambda lambda_syntax language large last last_day late_materialization_max_rows lateral lcase lcm leading leakproof least least_common_multiple left left_grapheme len length length_grapheme level levenshtein lgamma like like_escape limit list list_aggr list_aggregate list_any_value list_append list_apply list_approx_count_distinct list_avg list_bit_and list_bit_or list_bit_xor list_bool_and list_bool_or list_cat list_concat list_contains list_cosine_distance list_cosine_similarity list_count list_distance list_distinct list_dot_product list_element list_entropy list_extract list_filter list_first list_grade_up list_has list_has_all list_has_any list_histogram list_indexof list_inner_product list_intersect list_kurtosis list_kurtosis_pop list_last list_mad list_max list_median list_min list_mode list_negative_dot_product list_negative_inner_product list_pack list_position list_prepend list_product list_reduce list_resize list_reverse list_reverse_sort list_select list_sem list_skewness list_slice list_sort list_stddev_pop list_stddev_samp list_string_agg list_sum list_transform list_unique list_value list_var_pop list_var_samp list_where list_zip listagg listen ln load local location lock lock_configuration locked log log10 log2 log_query_path logged logging_level logging_mode logging_storage logical long lower lpad ltrim macro mad make_date make_time make_timestamp make_timestamp_ns make_timestamptz map map_concat map_contains map_contains_entry map_contains_value map_entries map_extract map_extract_value map_from_entries map_keys map_to_pg_oid map_values mapping match materialized max max_by max_expression_depth max_memory max_temp_directory_size max_vacuum_tasks maxvalue md5 md5_number md5_number_lower md5_number_upper mean median memory_limit merge_join_threshold metadata_info method microsecond microseconds millennia millennium millisecond milliseconds min min_by minute minutes minvalue mismatches mod mode month monthname months move multiply name names nanosecond national natural nchar nested_loop_join_threshold new next nextafter nextval nfc_normalize no none normalized_interval not not_ilike_escape not_like_escape nothing notify notnull now nowait null null_order nullif nulls numeric nvarchar obj_description object octet_length of off offset oid oids old old_implicit_casting on only operator option options or ord order order_by_non_integer_literal ordered_aggregate_threshold ordinality others out outer over overlaps overlay overriding owned owner pandas_analyze_sample pandas_scan parallel parquet_bloom_probe parquet_file_metadata parquet_kv_metadata parquet_metadata parquet_metadata_cache parquet_scan parquet_schema parse_dirname parse_dirpath parse_duckdb_log_message parse_filename parse_path parser partial partition partitioned partitioned_write_flush_threshold partitioned_write_max_open_files passing password percent perfect_ht_threshold persistent pi pivot pivot_filter_threshold pivot_limit pivot_longer pivot_wider placing plans platform policy position positional pow power pragma pragma_collations pragma_database_size pragma_metadata_info pragma_platform pragma_show pragma_storage_info pragma_table_info pragma_user_agent pragma_version preceding precision prefer_range_joins prefetch_all_parquet_files prefix prepare prepared preserve preserve_identifier_case preserve_insertion_order primary printf prior privileges procedural procedure produce_arrow_string_view product profile_output profiling_mode profiling_output program progress_bar_time publication python_enable_replacements python_map_function python_scan_all_frames qualify quantile quantile_cont quantile_disc quarter quarters query query_table quote radians random range read read_blob read_csv read_csv_auto read_json read_json_auto read_json_objects read_json_objects_auto read_ndjson read_ndjson_auto read_ndjson_objects read_parquet read_text real reassign recheck recursive reduce ref references referencing refresh regexp_escape regexp_extract regexp_extract_all regexp_full_match regexp_matches regexp_replace regexp_split_to_array regexp_split_to_table regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release remap_struct rename repeat repeat_row repeatable replace replica reservoir_quantile reset respect restart restrict returning returns reverse revoke right right_grapheme role rollback rollup round round_even roundbankers row row_to_json rows rpad rtrim rule sample savepoint scalar_subquery_error_on_multiple_rows scheduler_process_partial schema schemas scope scroll search search_path second seconds secret secret_directory security select sem semi seq_scan sequence sequences serializable server session session_user set set_bit setof sets setseed sha1 sha256 share shobj_description short show show_databases show_tables show_tables_expanded sign signbit signed similar simple sin sinh skewness skip smallint snapshot sniff_csv some sorted split split_part sql sqrt stable standalone start starts_with statement statistics stats stddev stddev_pop stddev_samp stdin stdout storage storage_compatibility_version storage_info stored str_split str_split_regex streaming_buffer_size strftime strict string string_agg string_split string_split_regex string_to_array strip strip_accents strlen strpos strptime struct struct_concat struct_extract struct_extract_at struct_insert struct_pack subscription substr substring substring_grapheme subtract suffix sum sum_no_overflow sumkahan summarize summary symmetric sysid system table table_info tables tablesample tablespace tan tanh temp temp_directory template temporary test_all_types test_vector_types text then threads ties time time_bucket timestamp timestamp_ms timestamp_ns timestamp_s timestamp_us timestamptz timetz timetz_byte_comparable timezone timezone_hour timezone_minute tinyint to to_base to_base64 to_binary to_centuries to_days to_decades to_hex to_hours to_json to_microseconds to_millennia to_milliseconds to_minutes to_months to_quarters to_seconds to_timestamp to_weeks to_years today trailing transaction transaction_timestamp transform translate treat trigger trim true trunc truncate truncate_duckdb_logs trusted try_cast try_strptime txid_current type typeof types ubigint ucase uhugeint uint128 uint16 uint32 uint64 uint8 uinteger unbin unbounded uncommitted unencrypted unhex unicode union union_extract union_tag union_value unique unknown unlisten unlogged unnest unpack unpivot unpivot_list until update upper url_decode url_encode use user user_agent username using usmallint utinyint uuid uuid_extract_timestamp uuid_extract_version uuidv4 uuidv7 vacuum valid validate validator value values var_pop var_samp varbinary varchar variable variadic variance varint varying vector_type verbose verify_external verify_fetch_row verify_parallelism verify_serializer version view views virtual volatile wal_autocheckpoint wavg week weekday weekofyear weeks weighted_avg when where which_secret whitespace window with within without work worker_threads wrapper write write_log xml xmlattributes xmlconcat xmlelement xmlexists xmlforest xmlnamespaces xmlparse xmlpi xmlroot xmlserialize xmltable xor year years yearweek yes zone zstd_min_string_length | || ~ ~~ ~~* ~~~",types:"JSON bigint binary bit bitstring blob bool boolean bpchar bytea char date datetime dec decimal double enum float float4 float8 guid hugeint int int1 int128 int16 int2 int32 int4 int64 int8 integer integral interval list logical long map null numeric nvarchar oid real row short signed smallint string struct text time timestamp timestamp_ms timestamp_ns timestamp_s timestamp_us timestamptz timetz tinyint ubigint uhugeint uint128 uint16 uint32 uint64 uint8 uinteger union usmallint utinyint uuid varbinary varchar varint"});var bC=new Set("postgresql.postgres.couchbase.db2.db2i.tidb.mysql.sqlite.mssql.sqlserver.duckdb.mariadb.cassandra.noql.spark.awsathena.athena.bigquery.hive.redshift.snowflake.flink.mongodb.trino.oracle.oracledb.singlestoredb.timescaledb.databricks.datafusion.microsoft sql server".split("."));function Kl(e){return bC.has(e)}function $g(e){let n=e.dialect;if(!Kl(n))return be.debug("Unknown dialect",{dialect:n}),hs;switch(n){case"postgresql":case"postgres":return Hh;case"mysql":return O8;case"sqlite":return I8;case"mssql":case"sqlserver":case"microsoft sql server":return R8;case"duckdb":return Hg;case"mariadb":return P8;case"cassandra":return N8;case"oracledb":case"oracle":return T8;case"bigquery":return Vg;case"timescaledb":return Hh;case"awsathena":case"athena":case"db2i":case"db2":case"hive":case"redshift":case"snowflake":case"flink":case"mongodb":case"noql":case"couchbase":case"trino":case"tidb":case"singlestoredb":case"spark":case"databricks":case"datafusion":return be.debug("Unsupported dialect",{dialect:n}),hs;default:return ss(n),hs}}var wC={...A8,caseInsensitiveIdentifiers:!0,identifierQuotes:"'"};let hs;hs=$h.define(wC),da="__marimo_duckdb",Ki=new Set([da]),T_="memory",jl=function(e){return e===""};var ms={formatTableName:e=>e,formatSelectClause:(e,n)=>`SELECT ${e} FROM ${n} LIMIT 100`};function _C(e){if(e=e.toLowerCase(),!Kl(e))return ms;switch(e){case"bigquery":{let n=Vg.spec.identifierQuotes;return{formatTableName:a=>`${n}${a}${n}`,formatSelectClause:ms.formatSelectClause}}case"mssql":case"sqlserver":case"microsoft sql server":return{formatTableName:ms.formatTableName,formatSelectClause:(n,a)=>`SELECT TOP 100 ${n} FROM ${a}`};case"timescaledb":case"postgres":case"postgresql":case"duckdb":return{formatTableName:n=>n.split(".").map(a=>`"${a}"`).join("."),formatSelectClause:(n,a)=>`SELECT ${n==="*"?"*":`"${n}"`} FROM ${a} LIMIT 100`};case"db2":case"db2i":case"mysql":case"sqlite":case"mariadb":case"cassandra":case"noql":case"awsathena":case"athena":case"hive":case"redshift":case"snowflake":case"flink":case"mongodb":case"oracle":case"oracledb":case"couchbase":case"tidb":case"spark":case"trino":case"singlestoredb":case"databricks":case"datafusion":return ms;default:return ss(e),ms}}x_=function({table:e,columnName:n,sqlTableContext:a}){if(a){let{engine:o,schema:s,defaultSchema:c,defaultDatabase:f,database:d,dialect:m}=a,b=e.name;jl(s)?b=d===f?b:`${d}.${b}`:(s!==c&&(b=`${s}.${b}`),d!==f&&(b=`${d}.${b}`));let _=_C(m),x=_.formatTableName(b),S=_.formatSelectClause(n,x);return o==="__marimo_duckdb"?`_df = mo.sql(f"""
29
+ `,a.textContent=n;let o=e.coordsAtPos(e.state.selection.main.head);o&&(a.style.left=`${o.left}px`,a.style.top=`${o.bottom+5}px`),document.body.appendChild(a),setTimeout(()=>{a.style.opacity="0",a.style.transition="opacity 0.2s",setTimeout(()=>a.remove(),200)},3e3)}function Wl(e){if(e==null)return!0;if(Array.isArray(e))return e.length===0||e.every(Wl);if(typeof e=="string")return Pg(e);let n=e.value;return typeof n=="string"?Pg(n):!1}function Pg(e){return e==null?!0:typeof e=="string"?e.trim()===""||/^[\s\n`]*$/.test(e):!1}function Jk(e,n){let a=[];return n.iterChanges((o,s,c,f,d)=>{let m=d.toString();if(o===0&&s===e.length){a.push({text:m});return}let b=ya(e,o),_=ya(e,s);a.push({range:{start:b,end:_},text:m})}),a.sort((o,s)=>{if(!o.range)return 1;if(!s.range)return-1;let c=o.range.start.line??-1,f=s.range.start.line??-1;if(c!==f)return f-c;let d=o.range.start.character??-1;return(s.range.start.character??-1)-d}),a}var Xk=Ww(),Yk=Object.fromEntries(Object.entries(Xk.CompletionItemKind).map(([e,n])=>[n,e])),Ng;(function(e){e.PlainText=1,e.Snippet=2})(Ng||(Ng={}));function Zk(e){return e.replaceAll(/\\\\/g,"").replaceAll(/(\$(\d+))/g,(n,a,o)=>"${"+o+"}")}function eC(e,n){let{detail:a,labelDetails:o,label:s,kind:c,textEdit:f,insertText:d,documentation:m,additionalTextEdits:b,insertTextFormat:_}=e,x={label:s,detail:(o==null?void 0:o.detail)||a,apply(S,E,L,P){if(f&&Qk(f)?S.dispatch(Vw(S.state,f.newText,or(S.state.doc,f.range.start),or(S.state.doc,f.range.end))):d&&_===Ng.Snippet&&n.useSnippetOnCompletion?k8(Zk(d))(S,null,L,P):S.dispatch(Vw(S.state,d||s,L,P)),!b)return;let q=b.sort(({range:{end:V}},{range:{end:B}})=>or(S.state.doc,V)<or(S.state.doc,B)?1:or(S.state.doc,V)>or(S.state.doc,B)?-1:0);for(let V of q)S.dispatch(S.state.update({changes:{from:or(S.state.doc,V.range.start),to:Ut(S.state.doc,V.range.end),insert:V.newText}}))},type:c&&Yk[c].toLowerCase()};return n.hasResolveProvider&&n.resolveItem?x.info=async()=>{var S;try{let E=await((S=n.resolveItem)==null?void 0:S.call(n,e)),L=document.createElement("div");L.classList.add("documentation");let P=(E==null?void 0:E.documentation)||m;return!P||Wl(P)?null:(n.allowHTMLContent?L.innerHTML=sr(P,n.markdownRenderer):L.textContent=sr(P,n.markdownRenderer),L)}catch(E){if(console.error("Failed to resolve completion item:",E),Wl(m))return null;if(m){let L=document.createElement("div");return L.classList.add("documentation"),n.allowHTMLContent?L.innerHTML=sr(m,n.markdownRenderer):L.textContent=sr(m,n.markdownRenderer),L}return null}}:m&&(x.info=()=>{let S=document.createElement("div");return S.classList.add("documentation"),n.allowHTMLContent?S.innerHTML=sr(m,n.markdownRenderer):S.textContent=sr(m,n.markdownRenderer),S}),x}function tC(e,n,a){let o=[n?nC(n):rC,a==="python"?aC:void 0].filter(Boolean),s=e;if(n){let c=n.toLowerCase();/^\w+$/.test(c)&&(s=s.filter(({label:f,filterText:d})=>(d??f).toLowerCase().startsWith(c)))}for(let c of o)s.sort(c);return s}function nC(e){return(n,a)=>{let o=n.sortText??n.label,s=a.sortText??a.label;switch(!0){case(o.startsWith(e)&&!s.startsWith(e)):return-1;case(!o.startsWith(e)&&s.startsWith(e)):return 1}return o.localeCompare(s)}}function rC(e,n){let a=e.sortText??e.label,o=n.sortText??n.label;return a.localeCompare(o)}function aC(e,n){let a=e.label.endsWith("="),o=n.label.endsWith("=");return a&&!o?-1:!a&&o?1:0}function Mg(e){let n=new Proxy({},{get(){throw Error(e)}});return function(a){return a.at(-1)??n}}const Dg=xl.define({combine:Mg("No document URI provided. Either pass a one into the extension or use documentUri.of().")}),iC=xl.define({combine:Mg("No language ID provided. Either pass a one into the extension or use languageId.of().")});let Jd,jg;Jd=Ol(),jg=1e4,cs=class{constructor({rootUri:e,workspaceFolders:n,transport:a,initializationOptions:o,capabilities:s,timeout:c=jg,getWorkspaceConfiguration:f}){ve(this,"ready");ve(this,"capabilities");ve(this,"initializePromise");ve(this,"rootUri");ve(this,"workspaceFolders");ve(this,"timeout");ve(this,"transport");ve(this,"requestManager");ve(this,"client");ve(this,"initializationOptions");ve(this,"clientCapabilities");ve(this,"notificationListeners",new Set);this.rootUri=e,this.workspaceFolders=n,this.transport=a,this.initializationOptions=o,this.clientCapabilities=s,this.timeout=c,this.ready=!1,this.capabilities=null,this.requestManager=new Jd.RequestManager([this.transport]),this.client=new Jd.Client(this.requestManager),this.client.onNotification(m=>{this.processNotification(m)});let d=this.transport;d!=null&&d.connection&&d.connection.addEventListener("message",m=>{let b=JSON.parse(m.data);b.method==="workspace/configuration"&&f?d.connection.send(JSON.stringify({jsonrpc:"2.0",id:b.id,result:f(b.params)})):b.method&&b.id&&d.connection.send(JSON.stringify({jsonrpc:"2.0",id:b.id,result:null}))}),this.initializePromise=this.initialize()}getInitializationOptions(){let e={textDocument:{hover:{dynamicRegistration:!0,contentFormat:["markdown","plaintext"]},moniker:{},synchronization:{dynamicRegistration:!0,willSave:!1,didSave:!1,willSaveWaitUntil:!1},codeAction:{dynamicRegistration:!0,codeActionLiteralSupport:{codeActionKind:{valueSet:["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},resolveSupport:{properties:["edit"]}},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!0,commitCharactersSupport:!0,documentationFormat:["markdown","plaintext"],deprecatedSupport:!1,preselectSupport:!1},contextSupport:!1},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["markdown","plaintext"]}},declaration:{dynamicRegistration:!0,linkSupport:!0},definition:{dynamicRegistration:!0,linkSupport:!0},typeDefinition:{dynamicRegistration:!0,linkSupport:!0},implementation:{dynamicRegistration:!0,linkSupport:!0},rename:{dynamicRegistration:!0,prepareSupport:!0}},workspace:{didChangeConfiguration:{dynamicRegistration:!0}}};return{capabilities:this.clientCapabilities?typeof this.clientCapabilities=="function"?this.clientCapabilities(e):this.clientCapabilities:e,initializationOptions:this.initializationOptions,processId:null,rootUri:this.rootUri,workspaceFolders:this.workspaceFolders}}async initialize(){let{capabilities:e}=await this.request("initialize",this.getInitializationOptions(),this.timeout*3);this.capabilities=e,this.notify("initialized",{}),this.ready=!0}close(){this.client.close()}textDocumentDidOpen(e){return this.notify("textDocument/didOpen",e)}textDocumentDidChange(e){return this.notify("textDocument/didChange",e)}async textDocumentHover(e){return await this.request("textDocument/hover",e,this.timeout)}async textDocumentCompletion(e){return await this.request("textDocument/completion",e,this.timeout)}async completionItemResolve(e){return await this.request("completionItem/resolve",e,this.timeout)}async textDocumentDefinition(e){return await this.request("textDocument/definition",e,this.timeout)}async textDocumentCodeAction(e){return await this.request("textDocument/codeAction",e,this.timeout)}async textDocumentRename(e){return await this.request("textDocument/rename",e,this.timeout)}async textDocumentPrepareRename(e){return await this.request("textDocument/prepareRename",e,this.timeout)}async textDocumentSignatureHelp(e){return await this.request("textDocument/signatureHelp",e,this.timeout)}onNotification(e){return this.notificationListeners.add(e),()=>this.notificationListeners.delete(e)}request(e,n,a){return this.client.request({method:e,params:n},a)}notify(e,n){return this.client.notify({method:e,params:n})}processNotification(e){this.notificationListeners.forEach(n=>n(e))}},Ol();var va=Ww(),zg=console.log;function oC(){return String(Date.now()+Math.random())}let Xd;Pl=la.define(),Rl=is.define({create:()=>null,update(e,n){for(let a of n.effects)if(a.is(Pl))return a.value;if(e&&n.docChanged){let a=n.changes.mapPos(e.pos),o=e.end==null?void 0:n.changes.mapPos(e.end);return{...e,pos:a,end:o}}return e},provide:e=>J6.from(e)}),Xd=Iw.define();var sC=20,lC=class{constructor(e){ve(this,"documentVersion");ve(this,"pluginId");ve(this,"client");ve(this,"documentUri");ve(this,"languageId");ve(this,"view");ve(this,"allowHTMLContent");ve(this,"useSnippetOnCompletion");ve(this,"sendIncrementalChanges");ve(this,"featureOptions");ve(this,"onGoToDefinition");ve(this,"markdownRenderer");ve(this,"disposeListener");ve(this,"lastSeenDiagnosticsVersion",0);let{client:n,documentUri:a,languageId:o,view:s,featureOptions:c,sendIncrementalChanges:f=!0,allowHTMLContent:d=!1,useSnippetOnCompletion:m=!1,onGoToDefinition:b,markdownRenderer:_=Rg}=e;this.documentVersion=0,this.pluginId=oC(),this.client=n,this.documentUri=a,this.languageId=o,this.view=s,this.allowHTMLContent=d,this.useSnippetOnCompletion=m,this.sendIncrementalChanges=f,this.featureOptions=c,this.onGoToDefinition=b,this.markdownRenderer=_,this.disposeListener=n.onNotification(this.processNotification.bind(this)),this.initialize({documentText:this.view.state.doc.toString()})}update({state:e,docChanged:n,startState:{doc:a},changes:o}){n&&(this.sendIncrementalChanges?this.sendChanges(Jk(a,o)):this.sendChanges([{text:e.doc.toString()}]))}destroy(){var e;(e=this.disposeListener)==null||e.call(this)}async initialize({documentText:e}){this.client.initializePromise&&await this.client.initializePromise,await this.client.textDocumentDidOpen({textDocument:{uri:this.documentUri,languageId:this.languageId,text:e,version:this.documentVersion}})}async sendChanges(e){if(this.client.ready)try{await this.client.textDocumentDidChange({textDocument:{uri:this.documentUri,version:++this.documentVersion},contentChanges:e})}catch(n){console.error(n)}}requestDiagnostics(e){this.sendChanges([{text:e.state.doc.toString()}])}async requestHoverTooltip(e,{line:n,character:a}){var b;if(!this.featureOptions.hoverEnabled||!(this.client.ready&&((b=this.client.capabilities)!=null&&b.hoverProvider)))return null;let o=await this.client.textDocumentHover({textDocument:{uri:this.documentUri},position:{line:n,character:a}});if(!o)return null;let{contents:s,range:c}=o,f=Ut(e.state.doc,{line:n,character:a}),d;if(c&&(f=Ut(e.state.doc,c.start),d=Ut(e.state.doc,c.end)),f==null||Wl(s))return null;let m=document.createElement("div");return m.classList.add("documentation","cm-lsp-hover-tooltip"),this.allowHTMLContent?m.innerHTML=sr(s,this.markdownRenderer):m.textContent=sr(s,this.markdownRenderer),{pos:f,end:d,create:_=>({dom:m}),above:!0}}async requestCompletion(e,{line:n,character:a},{triggerKind:o,triggerCharacter:s}){var S;if(!this.featureOptions.completionEnabled||!(this.client.ready&&((S=this.client.capabilities)!=null&&S.completionProvider)))return null;let c=await this.client.textDocumentCompletion({textDocument:{uri:this.documentUri},position:{line:n,character:a},context:{triggerKind:o,triggerCharacter:s}});if(!c)return null;let f="items"in c?c.items:c,d=Kk(f),m=d?e.matchBefore(d)??e.matchBefore(/[a-zA-Z0-9_]+/):e.matchBefore(/[a-zA-Z0-9_]+/),{pos:b}=e,_=tC(f,m==null?void 0:m.text,this.languageId);m&&(b=m.from);let x=_.map(E=>{var L,P;return eC(E,{allowHTMLContent:this.allowHTMLContent,useSnippetOnCompletion:this.useSnippetOnCompletion,hasResolveProvider:((P=(L=this.client.capabilities)==null?void 0:L.completionProvider)==null?void 0:P.resolveProvider)??!1,resolveItem:this.client.completionItemResolve.bind(this.client)})});return{from:b,options:x,filter:!1}}async requestDefinition(e,{line:n,character:a}){var _;if(!this.featureOptions.definitionEnabled||!(this.client.ready&&((_=this.client.capabilities)!=null&&_.definitionProvider)))return;let o=await this.client.textDocumentDefinition({textDocument:{uri:this.documentUri},position:{line:n,character:a}});if(!o)return;let s=Array.isArray(o)?o:[o];if(s.length===0)return;let c=s[0];if(!c)return;let f="uri"in c?c.uri:c.targetUri,d="range"in c?c.range:c.targetRange,m=f!==this.documentUri,b={uri:f,range:d,isExternalDocument:m};return m||e.dispatch(e.state.update({selection:{anchor:or(e.state.doc,d.start),head:Ut(e.state.doc,d.end)}})),this.onGoToDefinition&&this.onGoToDefinition(b),b}processNotification(e){try{e.method==="textDocument/publishDiagnostics"&&this.processDiagnostics(e.params)}catch(n){zg(n)}}async processDiagnostics(e){if(e.uri!==this.documentUri)return;if(e.version!=null&&e.version>this.lastSeenDiagnosticsVersion&&(this.lastSeenDiagnosticsVersion=e.version,this.clearDiagnostics()),!this.featureOptions.diagnosticsEnabled){this.clearDiagnostics();return}let n={[va.DiagnosticSeverity.Error]:"error",[va.DiagnosticSeverity.Warning]:"warning",[va.DiagnosticSeverity.Information]:"info",[va.DiagnosticSeverity.Hint]:"info"},a=e.diagnostics.map(async({range:s,message:c,severity:f,code:d,source:m})=>{var _;let b=(_=await this.requestCodeActions(s,[d]))==null?void 0:_.map(x=>{var S;return{name:"command"in x&&typeof x.command=="object"&&((S=x.command)==null?void 0:S.title)||x.title,apply:async()=>{var E;if("edit"in x&&((E=x.edit)!=null&&E.changes)){let L=x.edit.changes[this.documentUri];if(!L)return;for(let P of L)this.view.dispatch(this.view.state.update({changes:{from:or(this.view.state.doc,P.range.start),to:Ut(this.view.state.doc,P.range.end),insert:P.newText}}))}"command"in x&&x.command&&zg("Executing command:",x.command)}}});return{from:or(this.view.state.doc,s.start),to:or(this.view.state.doc,s.end),severity:n[f??va.DiagnosticSeverity.Error],message:c,renderMessage:()=>{let x=document.createElement("div");return x.innerHTML=this.markdownRenderer(c),x},source:m||this.languageId,markClass:this.pluginId,actions:b}}),o=await Promise.all(a);this.addDiagnostics(o)}addDiagnostics(e){if(e.length===0)return;let n=this.view.state,a=[];h8(n,c=>(a.push(c),!0));let o=new Set(e.map(c=>c.source).filter(Boolean)),s=e.filter(c=>!o.has(c.source));this.view.dispatch(qw(n,[...s,...e]))}clearDiagnostics(){this.view.dispatch(qw(this.view.state,[]))}async requestCodeActions(e,n){var a;return!this.featureOptions.codeActionsEnabled||!(this.client.ready&&((a=this.client.capabilities)!=null&&a.codeActionProvider))?null:await this.client.textDocumentCodeAction({textDocument:{uri:this.documentUri},range:e,context:{diagnostics:[{range:e,code:n[0],source:this.languageId,message:""}]}})}async requestRename(e,{line:n,character:a}){var o;if(this.featureOptions.renameEnabled){if(!this.client.ready){In(e,"Language server not ready");return}if(!((o=this.client.capabilities)!=null&&o.renameProvider)){In(e,"Rename not supported by language server");return}try{let s=await this.client.textDocumentPrepareRename({textDocument:{uri:this.documentUri},position:{line:n,character:a}}).catch(()=>this.prepareRenameFallback(e,{line:n,character:a}));if(!s||"defaultBehavior"in s){In(e,"Cannot rename this symbol");return}let c=document.createElement("div");c.className="cm-rename-popup",c.style.cssText="position: absolute; padding: 4px; background: white; border: 1px solid #ddd; box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 99;";let f=document.createElement("input");f.type="text",f.style.cssText="width: 200px; padding: 4px; border: 1px solid #ddd;";let d="range"in s?s.range:s,m=Ut(e.state.doc,d.start);if(m==null)return;let b=Ut(e.state.doc,d.end);f.value=e.state.doc.sliceString(m,b),c.appendChild(f);let _=e.coordsAtPos(m);if(!_)return;c.style.left=`${_.left}px`,c.style.top=`${_.bottom+5}px`;let x=async()=>{let E=f.value.trim();if(!E){In(e,"New name cannot be empty"),c.remove();return}if(E===f.defaultValue){c.remove();return}try{let L=await this.client.textDocumentRename({textDocument:{uri:this.documentUri},position:{line:n,character:a},newName:E});await this.applyRenameEdit(e,L)}catch(L){In(e,`Rename failed: ${L instanceof Error?L.message:"Unknown error"}`)}finally{c.remove()}};f.addEventListener("keydown",E=>{E.key==="Enter"?x():E.key==="Escape"&&c.remove(),E.stopPropagation()});let S=E=>{c.contains(E.target)||(c.remove(),document.removeEventListener("mousedown",S))};document.addEventListener("mousedown",S),document.body.appendChild(c),f.focus(),f.select()}catch(s){In(e,`Rename failed: ${s instanceof Error?s.message:"Unknown error"}`)}}}async requestSignatureHelp(e,{line:n,character:a},o=void 0){var s,c,f;if(!(this.featureOptions.signatureHelpEnabled&&this.client.ready&&((s=this.client.capabilities)!=null&&s.signatureHelpProvider)))return null;try{let d=await this.client.textDocumentSignatureHelp({textDocument:{uri:this.documentUri},position:{line:n,character:a},context:{isRetrigger:!1,triggerKind:1,triggerCharacter:o}});if(!(d!=null&&d.signatures)||d.signatures.length===0)return null;let m=this.createTooltipContainer(),b=d.activeSignature??0,_=d.signatures[b]||d.signatures[0];if(!_)return null;let x=d.activeParameter??_.activeParameter??0,S=this.createSignatureElement(_,x);m.appendChild(S),_.documentation&&m.appendChild(this.createDocumentationElement(_.documentation));let E=(c=_.parameters)==null?void 0:c[x];E!=null&&E.documentation&&m.appendChild(this.createParameterDocElement(E.documentation));let L=Ut(e.state.doc,{line:n,character:a});return L==null?null:{pos:L,end:L,create:P=>({dom:m}),above:((f=this.featureOptions.signatureHelpOptions)==null?void 0:f.position)==="above"}}catch(d){return console.error("Signature help error:",d),null}}async showSignatureHelpTooltip(e,n,a){let o=await this.requestSignatureHelp(e,ya(e.state.doc,n),a);e.dispatch({effects:Pl.of(o)})}createTooltipContainer(){let e=document.createElement("div");return e.classList.add("cm-signature-help"),e.style.cssText="padding: 6px; max-width: 400px;",e}createSignatureElement(e,n){let a=document.createElement("div");if(a.classList.add("cm-signature"),a.style.cssText="font-family: monospace; margin-bottom: 4px;",!e.label||typeof e.label!="string")return a.textContent="Signature information unavailable",a;let o=e.label,s=e.parameters||[];if(s.length===0||!s[n])return a.textContent=o,a;let c=s[n].label;return typeof c=="string"?this.allowHTMLContent?a.innerHTML=o.replace(c,`<strong class="cm-signature-active-param">${c}</strong>`):a.textContent=o.replace(c,`\xAB${c}\xBB`):Array.isArray(c)&&c.length===2?this.applyRangeHighlighting(a,o,c[0],c[1]):a.textContent=o,a}applyRangeHighlighting(e,n,a,o){e.textContent="";let s=n.substring(0,a),c=n.substring(a,o),f=n.substring(o);e.appendChild(document.createTextNode(s));let d=document.createElement("span");d.classList.add("cm-signature-active-param"),d.style.cssText="font-weight: bold; text-decoration: underline;",d.textContent=c,e.appendChild(d),e.appendChild(document.createTextNode(f))}createDocumentationElement(e){let n=document.createElement("div");n.classList.add("cm-signature-docs"),n.style.cssText="margin-top: 4px; color: #666;";let a=sr(e,this.markdownRenderer);return this.allowHTMLContent?n.innerHTML=a:n.textContent=a,n}createParameterDocElement(e){let n=document.createElement("div");n.classList.add("cm-parameter-docs"),n.style.cssText="margin-top: 4px; font-style: italic; border-top: 1px solid #eee; padding-top: 4px;";let a=sr(e,this.markdownRenderer);return this.allowHTMLContent?n.innerHTML=a:n.textContent=a,n}prepareRenameFallback(e,{line:n,character:a}){let o=e.state.doc.line(n+1).text,s=/\w+/g,c,f=a,d=a;for(;(c=s.exec(o))!==null;){let m=c.index,b=c.index+c[0].length;if(a>=m&&a<=b){f=m,d=b;break}}return f===a&&d===a?null:{range:{start:{line:n,character:f},end:{line:n,character:d}},placeholder:o.slice(f,d)}}async applyRenameEdit(e,n){if(!n)return In(e,"No edit returned from language server"),!1;let a=n.changes??{},o=n.documentChanges??[];if(Object.keys(a).length===0&&o.length===0)return In(e,"No changes to apply"),!1;if(o.length>0)for(let s of o){if("textDocument"in s){if(s.textDocument.uri!==this.documentUri){In(e,"Multi-file rename not supported yet");continue}let c=s.edits.sort((f,d)=>{let m=Ut(e.state.doc,f.range.start);return(Ut(e.state.doc,d.range.start)??0)-(m??0)}).map(f=>({from:Ut(e.state.doc,f.range.start)??0,to:Ut(e.state.doc,f.range.end)??0,insert:f.newText}));return e.dispatch(e.state.update({changes:c})),!0}return In(e,"File creation, deletion, or renaming operations not supported yet"),!1}else if(Object.keys(a).length>0)for(let[s,c]of Object.entries(a)){if(s!==this.documentUri){In(e,"Multi-file rename not supported yet");continue}let f=c.sort((d,m)=>{let b=Ut(e.state.doc,d.range.start);return(Ut(e.state.doc,m.range.start)??0)-(b??0)}).map(d=>({from:Ut(e.state.doc,d.range.start)??0,to:Ut(e.state.doc,d.range.end)??0,insert:d.newText}));e.dispatch(e.state.update({changes:f}))}return!1}};om=function(e){var f;let n=null,a={rename:"F2",goToDefinition:"F12",signatureHelp:"Mod-Shift-Space",...e.keyboardShortcuts},o=e.client,s={diagnosticsEnabled:!0,hoverEnabled:!0,completionEnabled:!0,definitionEnabled:!0,renameEnabled:!0,codeActionsEnabled:!0,signatureHelpEnabled:!0,signatureActivateOnTyping:!1,signatureHelpOptions:{position:"below"},...e},c=[Ui.define(d=>(n=new lC({client:o,documentUri:e.documentUri??d.state.facet(Dg),languageId:e.languageId??d.state.facet(iC),view:d,featureOptions:s,sendIncrementalChanges:e.sendIncrementalChanges,allowHTMLContent:e.allowHTMLContent,useSnippetOnCompletion:e.useSnippetOnCompletion,onGoToDefinition:e.onGoToDefinition,markdownRenderer:e.markdownRenderer}),n))];if(c.push(Ja.of([{key:a.signatureHelp,run:d=>{if(!(n&&s.signatureHelpEnabled))return!1;let m=d.state.selection.main.head;return n.showSignatureHelpTooltip(d,m),!0}},{key:a.rename,run:d=>{if(!(n&&s.renameEnabled))return!1;let m=d.state.selection.main.head;return n.requestRename(d,ya(d.state.doc,m)),!0}},{key:a.goToDefinition,run:d=>{if(!(n&&s.definitionEnabled))return!1;let m=d.state.selection.main.head;return n.requestDefinition(d,ya(d.state.doc,m)).catch(b=>In(d,`Go to definition failed: ${b instanceof Error?b.message:"Unknown error"}`)),!0}}])),s.hoverEnabled&&c.push(Fh((d,m)=>n==null?null:n.requestHoverTooltip(d,ya(d.state.doc,m)),e.hoverConfig)),s.signatureHelpEnabled){c.push(Rl);let d=m=>m.state.field(Rl)?(m.dispatch({effects:Pl.of(null)}),!0):!1;c.push(Et.domEventHandlers({mousedown:(m,b)=>(d(b),!1)})),c.push(Ja.of([{key:")",run:m=>(d(m),!1)},{key:"Escape",run:m=>d(m)}])),c.push(Et.updateListener.of(m=>{if(!(n&&s.signatureActivateOnTyping)||!m.state.field(Rl)||!(m.selectionSet||m.docChanged))return;let b=m.state.selection.main.head;fC(m.state.doc,b)||d(m.view)})),c.push(Et.updateListener.of(async m=>{var E;if(!(n&&m.docChanged)||m.transactions.some(L=>L.annotation(Xd))||!((E=n.client.capabilities)!=null&&E.signatureHelpProvider)||!s.signatureActivateOnTyping)return;let b=n.client.capabilities.signatureHelpProvider.triggerCharacters||["(",","],_=m.changes,x=-1,S;_.iterChanges((L,P,q,V,B)=>{if(x>=0)return;let M=uC(B.toString(),q,b);M&&(x=M.triggerPos,S=M.triggerCharacter)}),x>=0&&n.showSignatureHelpTooltip(m.view,x,S)}))}return s.completionEnabled&&c.push(Fu({...e.completionConfig,override:[async d=>{var x,S;if(n==null)return null;let{state:m,pos:b}=d,_=cC(d,((S=(x=n.client.capabilities)==null?void 0:x.completionProvider)==null?void 0:S.triggerCharacters)??[],e.completionMatchBefore);return _==null?null:await n.requestCompletion(d,ya(m.doc,b),_)},...((f=e.completionConfig)==null?void 0:f.override)||[]]})),c.push(Et.domEventHandlers({click:(d,m)=>{if(s.definitionEnabled&&a.goToDefinition==="ctrlcmd"&&(d.ctrlKey||d.metaKey)){let b=m.posAtCoords({x:d.clientX,y:d.clientY});b&&n&&(n.requestDefinition(m,ya(m.state.doc,b)).catch(_=>In(m,`Go to definition failed: ${_ instanceof Error?_.message:"Unknown error"}`)),d.preventDefault())}}})),c};function cC(e,n,a){let{state:o,pos:s,explicit:c}=e,f=o.doc.lineAt(s),d=va.CompletionTriggerKind.Invoked,m,b=f.text[s-f.from-1]||"",_=n==null?void 0:n.includes(b);return!c&&_&&(d=va.CompletionTriggerKind.TriggerCharacter,m=b),d===va.CompletionTriggerKind.Invoked&&!e.matchBefore(a||/(\w+|\w+\.|\/|,)$/)?null:{triggerKind:d,triggerCharacter:m}}function uC(e,n,a){if(!e)return null;for(let o of a){let s=e.indexOf(o);if(s!==-1)return{triggerPos:n+s+1,triggerCharacter:o}}return null}function dC(e){let n=0;for(let a of e)a==="("?n++:a===")"&&n--;return n}function fC(e,n,a=sC){let o=e.lineAt(n),s=Math.max(1,o.number-a),c=e.line(s).from;return dC(e.sliceString(c,n))>0}yd=function(e,n,a={}){let{preserveCursor:o=!0,effects:s,userEvent:c}=a,f=e.state.doc;if(f.toString()!==n)if(o&&e.hasFocus){let d=e.state.selection.main.head,m=f.lineAt(d),b=m.number,_=d-m.from,x=e.state.update({changes:{from:0,to:f.length,insert:n}}).state.doc,S;if(b<=x.lines){let E=x.line(b),L=E.length;S=E.from+Math.min(_,L)}else S=x.line(x.lines).to;e.dispatch({changes:{from:0,to:f.length,insert:n},annotations:Xd.of(!0),selection:{anchor:S},effects:s,userEvent:c})}else e.dispatch({changes:{from:0,to:f.length,insert:n},effects:s,userEvent:c})},Qi=function(){return xl.define({combine:e=>e.find(n=>n!==void 0)})};const qg=Qi(),Fg=Qi(),Yd=Qi(),Ul=Qi(),Bg=Qi();f_=function({cellId:e,completionConfig:n,hotkeys:a,placeholderType:o,lspConfig:s,diagnosticsConfig:c}){return[Ul.of(e),qg.of(n),Fg.of(a),Yd.of(o),Bg.of({...s,diagnostics:c})]},ed=new qu;function pC(e){return Object.values(e.cellRuntime).some(n=>n.status==="running")}function hC(e){return Object.values(e.cellRuntime).filter(n=>n.status==="running"||n.status==="queued").length}function mC(e){return mm(e).length>0}h_=function(e){return e.cellIds.inOrderIds.map(n=>e.cellData[n])};function gC({cellHandles:e}){let n={};for(let[a,o]of Rr.entries(e))o.current&&(n[a]=o.current.editorView);return n}pm=function(e){let{cellIds:n,cellData:a}=e,o=[];for(let s of n.inOrderIds)a[s].config.disabled&&o.push(s);return o},s0=function(e){let{cellIds:n,cellData:a}=e,o=[];for(let s of n.inOrderIds)a[s].config.disabled||o.push(s);return o};function yC(e){return e.history.length>0}n_=function(e,n){let a=e.cellIds.findWithId(n).getDescendants(n);return{stale:a.some(o=>{var s,c;return((s=e.cellRuntime[o])==null?void 0:s.staleInputs)||((c=e.cellData[o])==null?void 0:c.edited)}),errored:a.some(o=>{var s;return(s=e.cellRuntime[o])==null?void 0:s.errored}),runningOrQueued:a.some(o=>{var s,c;return((s=e.cellRuntime[o])==null?void 0:s.status)==="running"||((c=e.cellRuntime[o])==null?void 0:c.status)==="queued"})}},mm=function(e){let{cellIds:n,cellData:a,cellRuntime:o}=e;return n.inOrderIds.filter(s=>ym({executionTime:o[s].runElapsedTimeMs??a[s].lastExecutionTime,status:o[s].status,errored:o[s].errored,interrupted:o[s].interrupted,stopped:o[s].stopped})||a[s].edited||o[s].interrupted||o[s].staleInputs&&!(o[s].status==="disabled-transitively"||a[s].config.disabled))},ym=function({executionTime:e,status:n,errored:a,interrupted:o,stopped:s}){return e===null&&n!=="queued"&&n!=="running"&&!(a||o||s)},ot=xl.define({combine:e=>e[0]}),ua=xl.define({combine:e=>e[0]});var vC={...Hh,caseInsensitiveIdentifiers:!0,identifierQuotes:"`"};const Vg=$h.define(vC),Hg=$h.define({charSetCasts:!0,doubleQuotedStrings:!1,unquotedBitLiterals:!0,hashComments:!1,spaceAfterDashes:!1,specialVar:"@?",identifierQuotes:'"',caseInsensitiveIdentifiers:!0,keywords:"percentile_cont row_number rank dense_rank rank_dense percent_rank cume_dist ntile lag lead first_value last_value nth_value !__postfix !~~ !~~* % & && * ** + - ->> / // <-> << <=> <@ >> @ @> Calendar JSON TimeZone ^ ^@ abort abs absolute access access_mode acos acosh action add add_parquet_key admin after age aggregate alias all all_profiling_output allow_community_extensions allow_extensions_metadata_mismatch allow_persistent_secrets allow_unredacted_secrets allow_unsigned_extensions allowed_directories allowed_paths also alter always analyse analyze and anti any any_value apply approx_count_distinct approx_quantile approx_top_k arbitrary arg_max arg_max_null arg_min arg_min_null argmax argmin array array_agg array_aggr array_aggregate array_append array_apply array_cat array_concat array_contains array_cosine_distance array_cosine_similarity array_cross_product array_distance array_distinct array_dot_product array_extract array_filter array_grade_up array_has array_has_all array_has_any array_indexof array_inner_product array_intersect array_length array_negative_dot_product array_negative_inner_product array_pop_back array_pop_front array_position array_prepend array_push_back array_push_front array_reduce array_resize array_reverse array_reverse_sort array_select array_slice array_sort array_to_json array_to_string array_to_string_comma_default array_transform array_unique array_value array_where array_zip arrow_large_buffer_size arrow_lossless_conversion arrow_output_list_view arrow_output_version arrow_scan arrow_scan_dumb as asc ascii asin asinh asof asof_loop_join_threshold assertion assignment asymmetric at atan atan2 atanh attach attribute authorization autoinstall_extension_repository autoinstall_known_extensions autoload_known_extensions avg backward bar base64 before begin between bigint bin binary binary_as_string bit bit_and bit_count bit_length bit_or bit_position bit_xor bitstring bitstring_agg blob bool bool_and bool_or boolean both bpchar by bytea cache call called can_cast_implicitly cardinality cascade cascaded case cast cast_to_type catalog catalog_error_max_schemas cbrt ceil ceiling centuries century chain char char_length character character_length characteristics check checkpoint checkpoint_threshold chr class close cluster coalesce col_description collate collation collations column columns combine comment comments commit committed compression concat concat_ws concurrently configuration conflict connection constant_or_null constraint constraints contains content continue conversion copy copy_database corr cos cosh cost cot count count_if count_star countif covar_pop covar_samp create create_sort_key cross csv cube current current_catalog current_connection_id current_database current_date current_localtime current_localtimestamp current_query current_query_id current_role current_schema current_schemas current_setting current_transaction_id current_user currval cursor custom_extension_repository custom_profiling_settings custom_user_agent cycle damerau_levenshtein data database database_list database_size date date_add date_diff date_part date_sub date_trunc datediff datepart datesub datetime datetrunc day dayname dayofmonth dayofweek dayofyear days deallocate debug_asof_iejoin debug_checkpoint_abort debug_force_external debug_force_no_cross_product debug_skip_checkpoint_on_commit debug_verify_vector debug_window_mode dec decade decades decimal declare decode default default_block_size default_collation default_null_order default_order default_secret_storage defaults deferrable deferred definer degrees delete delimiter delimiters depends desc describe detach dictionary disable disable_checkpoint_on_shutdown disable_logging disable_object_cache disable_optimizer disable_parquet_prefetching disable_print_progress_bar disable_profile disable_profiling disable_progress_bar disable_timestamptz_casts disable_verification disable_verify_external disable_verify_fetch_row disable_verify_parallelism disable_verify_serializer disabled_compression_methods disabled_filesystems disabled_log_types disabled_optimizers discard distinct divide do document domain double drop duckdb_api duckdb_columns duckdb_constraints duckdb_databases duckdb_dependencies duckdb_extensions duckdb_external_file_cache duckdb_functions duckdb_indexes duckdb_keywords duckdb_log_contexts duckdb_logs duckdb_logs_parsed duckdb_memory duckdb_optimizers duckdb_prepared_statements duckdb_schemas duckdb_secret_types duckdb_secrets duckdb_sequences duckdb_settings duckdb_table_sample duckdb_tables duckdb_temporary_files duckdb_types duckdb_variables duckdb_views dynamic_or_filter_threshold each editdist3 element_at else enable enable_checkpoint_on_shutdown enable_external_access enable_external_file_cache enable_fsst_vectors enable_geoparquet_conversion enable_http_logging enable_http_metadata_cache enable_logging enable_macro_dependencies enable_object_cache enable_optimizer enable_print_progress_bar enable_profile enable_profiling enable_progress_bar enable_progress_bar_print enable_verification enable_view_dependencies enabled_log_types encode encoding encrypted end ends_with entropy enum enum_code enum_first enum_last enum_range enum_range_boundary epoch epoch_ms epoch_ns epoch_us equi_width_bins era error errors_as_json escape even event except exclude excluding exclusive execute exists exp explain explain_output export export_state extension extension_directory extension_versions extensions external external_threads extract factorial false family favg fdiv fetch file_search_path filter finalize first flatten float float4 float8 floor fmod following for force force_bitpacking_mode force_checkpoint force_compression foreign format formatReadableDecimalSize formatReadableSize format_bytes format_pg_type format_type forward freeze from from_base64 from_binary from_hex from_json from_json_strict fsum full function functions gamma gcd gen_random_uuid generate_series generate_subscripts generated geomean geometric_mean get_bit get_block_size get_current_time get_current_timestamp getvariable glob global grade_up grant granted greatest greatest_common_divisor group group_concat grouping grouping_id groups guid hamming handler having header hex histogram histogram_exact histogram_values hold home_directory hour hours http_logging_output http_proxy http_proxy_password http_proxy_username hugeint identity ieee_floating_point_ops if ignore ilike ilike_escape immediate immediate_transaction_mode immutable implicit import import_database in in_search_path include including increment index index_scan_max_count index_scan_percentage indexes inet_client_addr inet_client_port inet_server_addr inet_server_port inherit inherits initially inline inner inout input insensitive insert install instead instr int int1 int128 int16 int2 int32 int4 int64 int8 integer integer_division integral intersect interval into invoker is is_histogram_other_bin isfinite isinf isnan isnull isodow isolation isoyear jaccard jaro_similarity jaro_winkler_similarity join json json_array json_array_length json_contains json_deserialize_sql json_each json_execute_serialized_sql json_exists json_extract json_extract_path json_extract_path_text json_extract_string json_group_array json_group_object json_group_structure json_keys json_merge_patch json_object json_pretty json_quote json_serialize_plan json_serialize_sql json_structure json_transform json_transform_strict json_tree json_type json_valid json_value julian kahan_sum key kurtosis kurtosis_pop label lambda lambda_syntax language large last last_day late_materialization_max_rows lateral lcase lcm leading leakproof least least_common_multiple left left_grapheme len length length_grapheme level levenshtein lgamma like like_escape limit list list_aggr list_aggregate list_any_value list_append list_apply list_approx_count_distinct list_avg list_bit_and list_bit_or list_bit_xor list_bool_and list_bool_or list_cat list_concat list_contains list_cosine_distance list_cosine_similarity list_count list_distance list_distinct list_dot_product list_element list_entropy list_extract list_filter list_first list_grade_up list_has list_has_all list_has_any list_histogram list_indexof list_inner_product list_intersect list_kurtosis list_kurtosis_pop list_last list_mad list_max list_median list_min list_mode list_negative_dot_product list_negative_inner_product list_pack list_position list_prepend list_product list_reduce list_resize list_reverse list_reverse_sort list_select list_sem list_skewness list_slice list_sort list_stddev_pop list_stddev_samp list_string_agg list_sum list_transform list_unique list_value list_var_pop list_var_samp list_where list_zip listagg listen ln load local location lock lock_configuration locked log log10 log2 log_query_path logged logging_level logging_mode logging_storage logical long lower lpad ltrim macro mad make_date make_time make_timestamp make_timestamp_ns make_timestamptz map map_concat map_contains map_contains_entry map_contains_value map_entries map_extract map_extract_value map_from_entries map_keys map_to_pg_oid map_values mapping match materialized max max_by max_expression_depth max_memory max_temp_directory_size max_vacuum_tasks maxvalue md5 md5_number md5_number_lower md5_number_upper mean median memory_limit merge_join_threshold metadata_info method microsecond microseconds millennia millennium millisecond milliseconds min min_by minute minutes minvalue mismatches mod mode month monthname months move multiply name names nanosecond national natural nchar nested_loop_join_threshold new next nextafter nextval nfc_normalize no none normalized_interval not not_ilike_escape not_like_escape nothing notify notnull now nowait null null_order nullif nulls numeric nvarchar obj_description object octet_length of off offset oid oids old old_implicit_casting on only operator option options or ord order order_by_non_integer_literal ordered_aggregate_threshold ordinality others out outer over overlaps overlay overriding owned owner pandas_analyze_sample pandas_scan parallel parquet_bloom_probe parquet_file_metadata parquet_kv_metadata parquet_metadata parquet_metadata_cache parquet_scan parquet_schema parse_dirname parse_dirpath parse_duckdb_log_message parse_filename parse_path parser partial partition partitioned partitioned_write_flush_threshold partitioned_write_max_open_files passing password percent perfect_ht_threshold persistent pi pivot pivot_filter_threshold pivot_limit pivot_longer pivot_wider placing plans platform policy position positional pow power pragma pragma_collations pragma_database_size pragma_metadata_info pragma_platform pragma_show pragma_storage_info pragma_table_info pragma_user_agent pragma_version preceding precision prefer_range_joins prefetch_all_parquet_files prefix prepare prepared preserve preserve_identifier_case preserve_insertion_order primary printf prior privileges procedural procedure produce_arrow_string_view product profile_output profiling_mode profiling_output program progress_bar_time publication python_enable_replacements python_map_function python_scan_all_frames qualify quantile quantile_cont quantile_disc quarter quarters query query_table quote radians random range read read_blob read_csv read_csv_auto read_json read_json_auto read_json_objects read_json_objects_auto read_ndjson read_ndjson_auto read_ndjson_objects read_parquet read_text real reassign recheck recursive reduce ref references referencing refresh regexp_escape regexp_extract regexp_extract_all regexp_full_match regexp_matches regexp_replace regexp_split_to_array regexp_split_to_table regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex relative release remap_struct rename repeat repeat_row repeatable replace replica reservoir_quantile reset respect restart restrict returning returns reverse revoke right right_grapheme role rollback rollup round round_even roundbankers row row_to_json rows rpad rtrim rule sample savepoint scalar_subquery_error_on_multiple_rows scheduler_process_partial schema schemas scope scroll search search_path second seconds secret secret_directory security select sem semi seq_scan sequence sequences serializable server session session_user set set_bit setof sets setseed sha1 sha256 share shobj_description short show show_databases show_tables show_tables_expanded sign signbit signed similar simple sin sinh skewness skip smallint snapshot sniff_csv some sorted split split_part sql sqrt stable standalone start starts_with statement statistics stats stddev stddev_pop stddev_samp stdin stdout storage storage_compatibility_version storage_info stored str_split str_split_regex streaming_buffer_size strftime strict string string_agg string_split string_split_regex string_to_array strip strip_accents strlen strpos strptime struct struct_concat struct_extract struct_extract_at struct_insert struct_pack subscription substr substring substring_grapheme subtract suffix sum sum_no_overflow sumkahan summarize summary symmetric sysid system table table_info tables tablesample tablespace tan tanh temp temp_directory template temporary test_all_types test_vector_types text then threads ties time time_bucket timestamp timestamp_ms timestamp_ns timestamp_s timestamp_us timestamptz timetz timetz_byte_comparable timezone timezone_hour timezone_minute tinyint to to_base to_base64 to_binary to_centuries to_days to_decades to_hex to_hours to_json to_microseconds to_millennia to_milliseconds to_minutes to_months to_quarters to_seconds to_timestamp to_weeks to_years today trailing transaction transaction_timestamp transform translate treat trigger trim true trunc truncate truncate_duckdb_logs trusted try_cast try_strptime txid_current type typeof types ubigint ucase uhugeint uint128 uint16 uint32 uint64 uint8 uinteger unbin unbounded uncommitted unencrypted unhex unicode union union_extract union_tag union_value unique unknown unlisten unlogged unnest unpack unpivot unpivot_list until update upper url_decode url_encode use user user_agent username using usmallint utinyint uuid uuid_extract_timestamp uuid_extract_version uuidv4 uuidv7 vacuum valid validate validator value values var_pop var_samp varbinary varchar variable variadic variance varint varying vector_type verbose verify_external verify_fetch_row verify_parallelism verify_serializer version view views virtual volatile wal_autocheckpoint wavg week weekday weekofyear weeks weighted_avg when where which_secret whitespace window with within without work worker_threads wrapper write write_log xml xmlattributes xmlconcat xmlelement xmlexists xmlforest xmlnamespaces xmlparse xmlpi xmlroot xmlserialize xmltable xor year years yearweek yes zone zstd_min_string_length | || ~ ~~ ~~* ~~~",types:"JSON bigint binary bit bitstring blob bool boolean bpchar bytea char date datetime dec decimal double enum float float4 float8 guid hugeint int int1 int128 int16 int2 int32 int4 int64 int8 integer integral interval list logical long map null numeric nvarchar oid real row short signed smallint string struct text time timestamp timestamp_ms timestamp_ns timestamp_s timestamp_us timestamptz timetz tinyint ubigint uhugeint uint128 uint16 uint32 uint64 uint8 uinteger union usmallint utinyint uuid varbinary varchar varint"});var bC=new Set("postgresql.postgres.couchbase.db2.db2i.tidb.mysql.sqlite.mssql.sqlserver.duckdb.mariadb.cassandra.noql.spark.awsathena.athena.bigquery.hive.redshift.snowflake.flink.mongodb.trino.oracle.oracledb.singlestoredb.timescaledb.databricks.datafusion.microsoft sql server".split("."));function Kl(e){return bC.has(e)}function $g(e){let n=e.dialect;if(!Kl(n))return be.debug("Unknown dialect",{dialect:n}),hs;switch(n){case"postgresql":case"postgres":return Hh;case"mysql":return O8;case"sqlite":return I8;case"mssql":case"sqlserver":case"microsoft sql server":return R8;case"duckdb":return Hg;case"mariadb":return P8;case"cassandra":return N8;case"oracledb":case"oracle":return T8;case"bigquery":return Vg;case"timescaledb":return Hh;case"awsathena":case"athena":case"db2i":case"db2":case"hive":case"redshift":case"snowflake":case"flink":case"mongodb":case"noql":case"couchbase":case"trino":case"tidb":case"singlestoredb":case"spark":case"databricks":case"datafusion":return be.debug("Unsupported dialect",{dialect:n}),hs;default:return ss(n),hs}}var wC={...A8,caseInsensitiveIdentifiers:!0,identifierQuotes:"'"};let hs;hs=$h.define(wC),da="__marimo_duckdb",Ki=new Set([da]),T_="memory",jl=function(e){return e===""};var ms={formatTableName:e=>e,formatSelectClause:(e,n)=>`SELECT ${e} FROM ${n} LIMIT 100`};function _C(e){if(e=e.toLowerCase(),!Kl(e))return ms;switch(e){case"bigquery":{let n=Vg.spec.identifierQuotes;return{formatTableName:a=>`${n}${a}${n}`,formatSelectClause:ms.formatSelectClause}}case"mssql":case"sqlserver":case"microsoft sql server":return{formatTableName:ms.formatTableName,formatSelectClause:(n,a)=>`SELECT TOP 100 ${n} FROM ${a}`};case"timescaledb":case"postgres":case"postgresql":case"duckdb":return{formatTableName:n=>n.split(".").map(a=>`"${a}"`).join("."),formatSelectClause:(n,a)=>`SELECT ${n==="*"?"*":`"${n}"`} FROM ${a} LIMIT 100`};case"db2":case"db2i":case"mysql":case"sqlite":case"mariadb":case"cassandra":case"noql":case"awsathena":case"athena":case"hive":case"redshift":case"snowflake":case"flink":case"mongodb":case"oracle":case"oracledb":case"couchbase":case"tidb":case"spark":case"trino":case"singlestoredb":case"databricks":case"datafusion":return ms;default:return ss(e),ms}}x_=function({table:e,columnName:n,sqlTableContext:a}){if(a){let{engine:o,schema:s,defaultSchema:c,defaultDatabase:f,database:d,dialect:m}=a,b=e.name;jl(s)?b=d===f?b:`${d}.${b}`:(s!==c&&(b=`${s}.${b}`),d!==f&&(b=`${d}.${b}`));let _=_C(m),x=_.formatTableName(b),S=_.formatSelectClause(n,x);return o==="__marimo_duckdb"?`_df = mo.sql(f"""
30
30
  ${S}
31
31
  """)`:`_df = mo.sql(f"""
32
32
  ${S}
@@ -89,12 +89,12 @@ mark line col
89
89
  `),Q=k=="decimal"?/(-?)([\d]+)/:k=="hex"?/(-?)(?:0x)?([0-9a-f]+)/i:k=="octal"?/([0-7]+)/:null,ge=k=="decimal"?10:k=="hex"?16:k=="octal"?8:void 0,me=[],Re=[];if(k||T)for(var xe=0;xe<K.length;xe++){var Oe=T?K[xe].match(T):null;Oe&&Oe[0]!=""?me.push(Oe):Q&&Q.exec(K[xe])?me.push(K[xe]):Re.push(K[xe])}else Re=K;function Xe(De,Pe){if(y){var _t=De;De=Pe,Pe=_t}v&&(De=De.toLowerCase(),Pe=Pe.toLowerCase());var Mt=Q&&Q.exec(De),Vt=Q&&Q.exec(Pe);return!Mt||!Vt?De<Pe?-1:1:parseInt((Mt[1]+Mt[2]).toLowerCase(),ge)-parseInt((Vt[1]+Vt[2]).toLowerCase(),ge)}function Be(De,Pe){if(y){var _t=De;De=Pe,Pe=_t}return v&&(De[0]=De[0].toLowerCase(),Pe[0]=Pe[0].toLowerCase()),De[0]<Pe[0]?-1:1}if(me.sort(T?Be:Xe),T)for(var xe=0;xe<me.length;xe++)me[xe]=me[xe].input;else k||Re.sort(Xe);if(K=y?me.concat(Re):Re.concat(me),w){var dt=K,yt;K=[];for(var xe=0;xe<dt.length;xe++)dt[xe]!=yt&&K.push(dt[xe]),yt=dt[xe]}u.replaceRange(K.join(`
90
90
  `),te,Y)},vglobal:function(u,h){this.global(u,h)},normal:function(u,h){var y=!1,v=h.argString;if(v&&v[0]=="!"&&(v=v.slice(1),y=!0),v=v.trimStart(),!v){Je(u,"Argument is required.");return}var w=h.line;if(typeof w=="number")for(var k=isNaN(h.lineEnd)?w:h.lineEnd,T=w;T<=k;T++)u.setCursor(T,0),Pt(u,h.argString.trimStart(),{noremap:y}),u.state.vim.insertMode&&pn(u,!0);else Pt(u,h.argString.trimStart(),{noremap:y}),u.state.vim.insertMode&&pn(u,!0)},global:function(u,h){var y=h.argString;if(!y){Je(u,"Regular Expression missing from global");return}var v=h.commandName[0]==="v";y[0]==="!"&&h.commandName[0]==="g"&&(v=!0,y=y.slice(1));var w=h.line===void 0?u.firstLine():h.line,k=h.lineEnd||h.line||u.lastLine(),T=_c(y),O=y,R="";if(T&&T.length&&(O=T[0],R=T.slice(1,T.length).join("/")),O)try{Br(u,O,!0,!0)}catch{Je(u,"Invalid regex: "+O);return}for(var z=bn(u).getQuery(),D=[],te=w;te<=k;te++){var Y=u.getLine(te);z.test(Y)!==v&&D.push(R?u.getLineHandle(te):Y)}if(!R){Je(u,D.join(`
91
91
  `));return}var K=0,Q=function(){if(K<D.length){var ge=D[K++],me=u.getLineNumber(ge);if(me==null){Q();return}var Re=me+1+R;Kt.processCommand(u,Re,{callback:Q})}else u.releaseLineHandles&&u.releaseLineHandles()};Q()},substitute:function(u,h){if(!u.getSearchCursor)throw Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var y=h.argString,v=y?bi(y,y[0]):[],w="",k="",T,O,R,z=!1,D=!1;if(v&&v.length)w=v[0],ke("pcre")&&w!==""&&(w=new RegExp(w).source),k=v[1],k!==void 0&&(k=ke("pcre")?Ps(k.replace(/([^\\])&/g,"$1$$&")):xc(k),W.lastSubstituteReplacePart=k),T=v[2]?v[2].split(" "):[];else if(y&&y.length){Je(u,"Substitutions should be of the form :s/pattern/replace/");return}if(T&&(O=T[0],R=parseInt(T[1]),O&&(O.indexOf("c")!=-1&&(z=!0),O.indexOf("g")!=-1&&(D=!0),w=ke("pcre")?w+"/"+O:w.replace(/\//g,"\\/")+"/"+O)),w)try{Br(u,w,!0,!0)}catch{Je(u,"Invalid regex: "+w);return}if(k||(k=W.lastSubstituteReplacePart),k===void 0){Je(u,"No previous substitute regular expression");return}var te=bn(u).getQuery(),Y=h.line===void 0?u.getCursor().line:h.line,K=h.lineEnd||Y;Y==u.firstLine()&&K==u.lastLine()&&(K=1/0),R&&(Y=K,K=Y+R-1);var Q=Nt(u,new n(Y,0)),ge=u.getSearchCursor(te,Q);Ms(u,z,D,Y,K,ge,te,k,h.callback)},startinsert:function(u,h){Pt(u,h.argString=="!"?"A":"i",{})},redo:e.commands.redo,undo:e.commands.undo,write:function(u){e.commands.save?e.commands.save(u):u.save&&u.save()},nohlsearch:function(u){Hr(u)},yank:function(u){var h=Qe(u.getCursor()).line,y=u.getLine(h);W.registerController.pushText("0","yank",y,!0,!0)},delete:function(u,h){var y=h.selectionLine,v=isNaN(h.selectionLineEnd)?y:h.selectionLineEnd;Jt.delete(u,{linewise:!0},[{anchor:new n(y,0),head:new n(v+1,0)}])},join:function(u,h){var y=h.selectionLine,v=isNaN(h.selectionLineEnd)?y:h.selectionLineEnd;u.setCursor(new n(y,0)),zr.joinLines(u,{repeat:v-y},u.state.vim)},delmarks:function(u,h){if(!h.argString||!_a(h.argString)){Je(u,"Argument required");return}for(var y=u.state.vim,v=new e.StringStream(_a(h.argString));!v.eol();){v.eatSpace();var w=v.pos;if(!v.match(/[a-zA-Z]/,!1)){Je(u,"Invalid argument: "+h.argString.substring(w));return}var k=v.next();if(v.match("-",!0)){if(!v.match(/[a-zA-Z]/,!1)){Je(u,"Invalid argument: "+h.argString.substring(w));return}var T=k,O=v.next();if(T&&O&&M(T)==M(O)){var R=T.charCodeAt(0),z=O.charCodeAt(0);if(R>=z){Je(u,"Invalid argument: "+h.argString.substring(w));return}for(var D=0;D<=z-R;D++){var te=String.fromCharCode(R+D);delete y.marks[te]}}else{Je(u,"Invalid argument: "+T+"-");return}}else k&&delete y.marks[k]}}},Kt=new Eo;Fe.defineEx("version","ve",u=>{Je(u,"Codemirror-vim version: 6.3.0")});function Ms(u,h,y,v,w,k,T,O,R){u.state.vim.exMode=!0;var z=!1,D=0,te,Y,K;function Q(){u.operation(function(){for(;!z;)ge(),Re();xe()})}function ge(){var Xe="",Be=k.match||k.pos&&k.pos.match;Xe=Be?O.replace(/\$(\d{1,3}|[$&])/g,function(yt,De){if(De=="$")return"$";if(De=="&")return Be[0];for(var Pe=De;parseInt(Pe)>=Be.length&&Pe.length>0;)Pe=Pe.slice(0,Pe.length-1);return Pe?Be[Pe]+De.slice(Pe.length,De.length):yt}):u.getRange(k.from(),k.to()).replace(T,O);var dt=k.to().line;k.replace(Xe),Y=k.to().line,w+=Y-dt,K=Y<dt}function me(){var Xe=te&&Qe(k.to()),Be=k.findNext();return Be&&!Be[0]&&Xe&&gt(k.from(),Xe)&&(Be=k.findNext()),Be&&D++,Be}function Re(){for(;me()&&Sc(k.from(),v,w);)if(!(!y&&k.from().line==Y&&!K)){u.scrollIntoView(k.from(),30),u.setSelection(k.from(),k.to()),te=k.from(),z=!1;return}z=!0}function xe(Xe){if(Xe&&Xe(),u.focus(),te){u.setCursor(te);var Be=u.state.vim;Be.exMode=!1,Be.lastHPos=Be.lastHSPos=te.ch}R?R():z&&Je(u,(D?"Found "+D+" matches":"No matches found")+" for pattern: "+T+(ke("pcre")?" (set nopcre to use Vim regexps)":""))}function Oe(Xe,Be,dt){switch(e.e_stop(Xe),jr(Xe)){case"y":ge(),Re();break;case"n":Re();break;case"a":var yt=R;R=void 0,u.operation(Q),R=yt;break;case"l":ge();case"q":case"<Esc>":case"<C-c>":case"<C-[>":xe(dt);break}return z&&xe(dt),!0}if(Re(),z){Je(u,"No matches for "+T+(ke("pcre")?" (set nopcre to use vim regexps)":""));return}if(!h){Q(),R&&R();return}Ta(u,{prefix:sn("span","replace with ",sn("strong",O)," (y/n/a/q/l)"),onKeyDown:Oe})}function pn(u,h){var y=u.state.vim,v=W.macroModeState,w=W.registerController.getRegister("."),k=v.isPlaying,T=v.lastInsertModeChanges;k||(u.off("change",hr),y.insertEnd&&y.insertEnd.clear(),y.insertEnd=void 0,e.off(u.getInputField(),"keydown",zs)),!k&&y.insertModeRepeat&&y.insertModeRepeat>1&&(Si(u,y,y.insertModeRepeat-1,!0),y.lastEditInputState.repeatOverride=y.insertModeRepeat),delete y.insertModeRepeat,y.insertMode=!1,h||u.setCursor(u.getCursor().line,u.getCursor().ch-1),u.setOption("keyMap","vim"),u.setOption("disableInput",!0),u.toggleOverwrite(!1),w.setText(T.changes.join("")),e.signal(u,"vim-mode-change",{mode:"normal"}),v.isRecording&&js(v)}function Ir(u){o.unshift(u),u.keys&&Tc(u.keys)}function Tc(u){u.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(h){h&&(s[h]||(s[h]=0),s[h]++)})}function Ds(u){u.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(h){s[h]&&s[h]--})}function Ic(u,h,y,v,w){var k={keys:u,type:h};for(var T in k[h]=y,k[h+"Args"]=v,w)k[T]=w[T];Ir(k)}he("insertModeEscKeysTimeout",200,"number");function xi(u,h,y,v){var w=W.registerController.getRegister(v);if(v==":"){w.keyBuffer[0]&&Kt.processCommand(u,w.keyBuffer[0]),y.isPlaying=!1;return}var k=w.keyBuffer,T=0;y.isPlaying=!0,y.replaySearchQueries=w.searchQueries.slice(0);for(var O=0;O<k.length;O++)for(var R=k[O],z,D,te=/<(?:[CSMA]-)*\w+>|./gi;z=te.exec(R);)if(D=z[0],Fe.handleKey(u,D,"macro"),h.insertMode){var Y=w.insertModeChanges[T++].changes;W.macroModeState.lastInsertModeChanges.changes=Y,qs(u,Y,1),pn(u)}y.isPlaying=!1}function pr(u,h){if(!u.isPlaying){var y=u.latestRegister,v=W.registerController.getRegister(y);v&&v.pushText(h)}}function js(u){if(!u.isPlaying){var h=u.latestRegister,y=W.registerController.getRegister(h);y&&y.pushInsertModeChanges&&y.pushInsertModeChanges(u.lastInsertModeChanges)}}function ki(u,h){if(!u.isPlaying){var y=u.latestRegister,v=W.registerController.getRegister(y);v&&v.pushSearchQuery&&v.pushSearchQuery(h)}}function hr(u,h){var y=W.macroModeState,v=y.lastInsertModeChanges;if(!y.isPlaying)for(var w=u.state.vim;h;){if(v.expectCursorActivityForChange=!0,v.ignoreCount>1)v.ignoreCount--;else if(h.origin=="+input"||h.origin=="paste"||h.origin===void 0){var k=u.listSelections().length;k>1&&(v.ignoreCount=k);var T=h.text.join(`
92
- `);if(v.maybeReset&&(v.maybeReset=(v.changes=[],!1)),T)if(u.state.overwrite&&!/\n/.test(T))v.changes.push([T]);else{if(T.length>1){var O=w&&w.insertEnd&&w.insertEnd.find(),R=u.getCursor();if(O&&O.line==R.line){var z=O.ch-R.ch;z>0&&z<T.length&&(v.changes.push([T,z]),T="")}}T&&v.changes.push(T)}}h=h.next}}function To(u){var w;var h=u.state.vim;if(h.insertMode){var y=W.macroModeState;if(y.isPlaying)return;var v=y.lastInsertModeChanges;v.expectCursorActivityForChange?v.expectCursorActivityForChange=!1:(v.maybeReset=!0,h.insertEnd&&h.insertEnd.clear(),h.insertEnd=u.setBookmark(u.getCursor(),{insertLeft:!0}))}else(w=u.curOp)!=null&&w.isVimOp||Ci(u,h)}function Ci(u,h){var y=u.getCursor("anchor"),v=u.getCursor("head");if(h.visualMode&&!u.somethingSelected()?An(u,!1):!h.visualMode&&!h.insertMode&&u.somethingSelected()&&(h.visualMode=!0,h.visualLine=!1,e.signal(u,"vim-mode-change",{mode:"visual"})),h.visualMode){var w=wt(v,y)?0:-1,k=wt(v,y)?-1:0;v=kt(v,0,w),y=kt(y,0,k),h.sel={anchor:y,head:v},dn(u,h,"<",Xt(v,y)),dn(u,h,">",Sr(v,y))}else h.insertMode||(h.lastHPos=u.getCursor().ch)}function zs(u){var h=W.macroModeState.lastInsertModeChanges,y=e.keyName?e.keyName(u):u.key;y&&(y.indexOf("Delete")!=-1||y.indexOf("Backspace")!=-1)&&(h.maybeReset&&(h.maybeReset=(h.changes=[],!1)),h.changes.push(new He(y,u)))}function Si(u,h,y,v){var w=W.macroModeState;w.isPlaying=!0;var k=h.lastEditActionCommand,T=h.inputState;function O(){k?dr.processAction(u,h,k):dr.evalInput(u,h)}function R(D){if(w.lastInsertModeChanges.changes.length>0){D=h.lastEditActionCommand?D:1;var te=w.lastInsertModeChanges;qs(u,te.changes,D)}}if(h.inputState=h.lastEditInputState,k&&k.interlaceInsertRepeat)for(var z=0;z<y;z++)O(),R(1);else v||O(),R(y);h.inputState=T,h.insertMode&&!v&&pn(u),w.isPlaying=!1}function Ei(u,h){e.lookupKey(h,"vim-insert",function(y){return typeof y=="string"?e.commands[y](u):y(u),!0})}function qs(u,h,y){var v=u.getCursor("head"),w=W.macroModeState.lastInsertModeChanges.visualBlock;w&&(mc(u,v,w+1),y=u.listSelections().length,u.setCursor(v));for(var k=0;k<y;k++){w&&u.setCursor(kt(v,k,0));for(var T=0;T<h.length;T++){var O=h[T];if(O instanceof He)Ei(u,O.keyName);else if(typeof O=="string")u.replaceSelection(O);else{var R=u.getCursor(),z=kt(R,0,O[0].length-(O[1]||0));u.replaceRange(O[0],R,O[1]?R:z),u.setCursor(z)}}}w&&u.setCursor(kt(v,0,1))}function Qt(u){var h=new u.constructor;return Object.keys(u).forEach(function(y){if(y!="insertEnd"){var v=u[y];Array.isArray(v)?v=v.slice():v&&typeof v=="object"&&v.constructor!=Object&&(v=Qt(v)),h[y]=v}}),u.sel&&(h.sel={head:u.sel.head&&Qe(u.sel.head),anchor:u.sel.anchor&&Qe(u.sel.anchor)}),h}function $r(u,h,y){var k=ee(u),v=u,w=!1,k=Fe.maybeInitVimState_(v),T=k.visualBlock||k.wasInVisualBlock;if(v.state.closeVimNotification){var O=v.state.closeVimNotification;if(v.state.closeVimNotification=null,O(),h=="<CR>")return mt(v),!0}var R=v.isInMultiSelectMode();if(k.wasInVisualBlock&&!R?k.wasInVisualBlock=!1:R&&k.visualBlock&&(k.wasInVisualBlock=!0),h=="<Esc>"&&!k.insertMode&&!k.visualMode&&R&&k.status=="<Esc>")mt(v);else if(T||!R||v.inVirtualSelectionMode)w=Fe.handleKey(v,h,y);else{var z=Qt(k),D=k.inputState.changeQueueList||[];v.operation(function(){var Y;v.curOp&&(v.curOp.isVimOp=!0);var te=0;v.forEachSelection(function(){v.state.vim.inputState.changeQueue=D[te];var K=v.getCursor("head"),Q=v.getCursor("anchor"),ge=wt(K,Q)?0:-1,me=wt(K,Q)?-1:0;K=kt(K,0,ge),Q=kt(Q,0,me),v.state.vim.sel.head=K,v.state.vim.sel.anchor=Q,w=Fe.handleKey(v,h,y),v.virtualSelection&&(D[te]=v.state.vim.inputState.changeQueue,v.state.vim=Qt(z)),te++}),(Y=v.curOp)!=null&&Y.cursorActivity&&!w&&(v.curOp.cursorActivity=!1),v.state.vim=k,k.inputState.changeQueueList=D,k.inputState.changeQueue=null},!0)}return w&&!k.visualMode&&!k.insertMode&&k.visualMode!=v.somethingSelected()&&Ci(v,k),w}return Ie(),Fe}function Ln(e,n){var a=n.ch,o=n.line+1;o<1&&(o=1,a=0),o>e.lines&&(o=e.lines,a=Number.MAX_VALUE);var s=e.line(o);return Math.min(s.from+Math.max(0,a),s.to)}function lr(e,n){let a=e.lineAt(n);return{line:a.number-1,ch:n-a.from}}var Cr=class{constructor(e,n){this.line=e,this.ch=n}};function Ry(e,n,a){if(e.addEventListener)e.addEventListener(n,a,!1);else{var o=e._handlers||(e._handlers={});o[n]=(o[n]||[]).concat(a)}}function Py(e,n,a){if(e.removeEventListener)e.removeEventListener(n,a,!1);else{var o=e._handlers,s=o&&o[n];if(s){var c=s.indexOf(a);c>-1&&(o[n]=s.slice(0,c).concat(s.slice(c+1)))}}}function Ny(e,n,...a){var c;var o=(c=e._handlers)==null?void 0:c[n];if(o)for(var s=0;s<o.length;++s)o[s](...a)}function My(e,...n){if(e)for(var a=0;a<e.length;++a)e[a](...n)}var uf;try{uf=RegExp("[\\w\\p{Alphabetic}\\p{Number}_]","u")}catch{uf=/[\w]/}function bs(e,n){var a=e.cm6;if(!a.state.readOnly){var o="input.type.compose";if(e.curOp&&(e.curOp.lastChange||(o="input.type.compose.start")),n.annotations)try{n.annotations.some(function(s){s.value=="input"&&(s.value=o)})}catch(s){console.error(s)}else n.userEvent=o;return a.dispatch(n)}}function Dy(e,n){var o;e.curOp&&(e.curOp.$changeStart=void 0),(n?n8:r8)(e.cm6);let a=(o=e.curOp)==null?void 0:o.$changeStart;a!=null&&e.cm6.dispatch({selection:{anchor:a}})}var QS={Left:e=>as(e.cm6,{key:"Left"},"editor"),Right:e=>as(e.cm6,{key:"Right"},"editor"),Up:e=>as(e.cm6,{key:"Up"},"editor"),Down:e=>as(e.cm6,{key:"Down"},"editor"),Backspace:e=>as(e.cm6,{key:"Backspace"},"editor"),Delete:e=>as(e.cm6,{key:"Delete"},"editor")},Ve=class Qx{openDialog(n,a,o){return JS(this,n,a,o)}openNotification(n,a){return GS(this,n,a)}constructor(n){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=n,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(n,a){Ry(this,n,a)}off(n,a){Py(this,n,a)}signal(n,a,o){Ny(this,n,a,o)}indexFromPos(n){return Ln(this.cm6.state.doc,n)}posFromIndex(n){return lr(this.cm6.state.doc,n)}foldCode(n){let a=this.cm6,o=a.state.selection.ranges,s=this.cm6.state.doc,c=Ln(s,n),f=$t.create([$t.range(c,c)],0).ranges;a.state.selection.ranges=f,B6(a),a.state.selection.ranges=o}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(n,a){typeof n=="object"&&(a=n.ch,n=n.line);var o=Ln(this.cm6.state.doc,{line:n,ch:a||0});this.cm6.dispatch({selection:{anchor:o}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(n){var a=this.cm6.state.selection.main,o=n=="head"||!n?a.head:n=="anchor"?a.anchor:n=="start"?a.from:n=="end"?a.to:null;if(o==null)throw Error("Invalid cursor type");return this.posFromIndex(o)}listSelections(){var n=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(a=>({anchor:lr(n,a.anchor),head:lr(n,a.head)}))}setSelections(n,a){var o=this.cm6.state.doc,s=n.map(c=>{var f=Ln(o,c.head),d=Ln(o,c.anchor);return f==d?$t.cursor(f,1):$t.range(d,f)});this.cm6.dispatch({selection:$t.create(s,a)})}setSelection(n,a,o){this.setSelections([{anchor:n,head:a}],0),o&&o.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(n){var a=this.cm6.state.doc;return n<0||n>=a.lines?"":this.cm6.state.doc.line(n+1).text}getLineHandle(n){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:n,index:this.indexFromPos(new Cr(n,0))}}getLineNumber(n){var a=this.$lineHandleChanges;if(!a)return null;for(var o=n.index,s=0;s<a.length;s++)if(o=a[s].changes.mapPos(o,1,Pw.TrackAfter),o==null)return null;var c=this.posFromIndex(o);return c.ch==0?c.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(n,a){var o=this.cm6.state.doc;return this.cm6.state.sliceDoc(Ln(o,n),Ln(o,a))}replaceRange(n,a,o,s){o||(o=a);var c=this.cm6.state.doc,f=Ln(c,a),d=Ln(c,o);bs(this,{changes:{from:f,to:d,insert:n}})}replaceSelection(n){bs(this,this.cm6.state.replaceSelection(n))}replaceSelections(n){var a=this.cm6.state.selection.ranges.map((o,s)=>({from:o.from,to:o.to,insert:n[s]||""}));bs(this,{changes:a})}getSelection(){return this.getSelections().join(`
93
- `)}getSelections(){var n=this.cm6;return n.state.selection.ranges.map(a=>n.state.sliceDoc(a.from,a.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(n=>!n.empty)}getInputField(){return this.cm6.contentDOM}clipPos(n){var a=this.cm6.state.doc,o=n.ch,s=n.line+1;s<1&&(s=1,o=0),s>a.lines&&(s=a.lines,o=Number.MAX_VALUE);var c=a.line(s);return o=Math.min(Math.max(0,o),c.to-c.from),new Cr(s-1,o)}getValue(){return this.cm6.state.doc.toString()}setValue(n){var a=this.cm6;return a.dispatch({changes:{from:0,to:a.state.doc.length,insert:n},selection:$t.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(n,a){var o=this.cm6.state,s=Ln(o.doc,n),c=zw(o,s+1,-1);return c&&c.end||(c=zw(o,s,1),c&&c.end)?{to:lr(o.doc,c.end.from)}:{to:void 0}}scanForBracket(n,a,o,s){return ZS(this,n,a,o,s)}indentLine(n,a){a?this.indentMore():this.indentLess()}indentMore(){v8(this.cm6)}indentLess(){s8(this.cm6)}execCommand(n){if(n=="indentAuto")Qx.commands.indentAuto(this);else if(n=="goLineLeft")u8(this.cm6);else if(n=="goLineRight"){c8(this.cm6);let a=this.cm6.state,o=a.selection.main.head;o<a.doc.length&&a.sliceDoc(o,o+1)!==`
94
- `&&l8(this.cm6)}else console.log(n+" is not implemented")}setBookmark(n,a){var o=a!=null&&a.insertLeft?1:-1,s=this.indexFromPos(n);return new n3(this,s,o)}addOverlay({query:n}){let a=new d8({regexp:!0,search:n.source,caseSensitive:!/i/.test(n.flags)});if(a.valid){a.forVim=!0,this.cm6Query=a;let o=Bh.of(a);return this.cm6.dispatch({effects:o}),a}}removeOverlay(n){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let a=Bh.of(this.cm6Query);this.cm6.dispatch({effects:a})}getSearchCursor(n,a){var o=this,s=null,c=null,f=!1;a.ch??(a.ch=Number.MAX_VALUE);var d=Ln(o.cm6.state.doc,a),m=n.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(E,L){return L||"\\"+E});function b(E,L=0,P=E.length){return new h8(E,m,{ignoreCase:n.ignoreCase},L,P)}function _(E){var L=o.cm6.state.doc;if(E>L.length)return null;let P=b(L,E).next();return P.done?null:P.value}var x=1e4;function S(E,L){var P=o.cm6.state.doc;for(let q=1;;q++){let V=Math.max(E,L-q*x),B=b(P,V,L),M=null;for(;!B.next().done;)M=B.value;if(M&&(V==E||M.from>V+10))return M;if(V==E)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(E){var L=o.cm6.state.doc;return s=E?S(0,s?f?s.to-1:s.from:d):_(s?f?s.to+1:s.to:d),c=s&&{from:lr(L,s.from),to:lr(L,s.to),match:s.match},f=s?s.from==s.to:!1,s&&s.match},from:function(){return c==null?void 0:c.from},to:function(){return c==null?void 0:c.to},replace:function(E){s&&(bs(o,{changes:{from:s.from,to:s.to,insert:E}}),s.to=s.from+E.length,c&&(c.to=lr(o.cm6.state.doc,s.to)))},get match(){return c&&c.match}}}findPosV(n,a,o,s){let{cm6:c}=this,f=c.state.doc,d=o=="page"?c.dom.clientHeight:0,m=Ln(f,n),b=$t.cursor(m,1,void 0,s),_=Math.round(Math.abs(a));for(let S=0;S<_;S++)o=="page"?b=c.moveVertically(b,a>0,d):o=="line"&&(b=c.moveVertically(b,a>0));let x=lr(f,b.head);return(a<0&&b.head==0&&s!=0&&n.line==0&&n.ch!=0||a>0&&b.head==f.length&&x.ch!=s&&n.line==x.line)&&(x.hitSide=!0),x}charCoords(n,a){var o=this.cm6.contentDOM.getBoundingClientRect(),s=Ln(this.cm6.state.doc,n),c=this.cm6.coordsAtPos(s),f=-o.top;return{left:((c==null?void 0:c.left)||0)-o.left,top:((c==null?void 0:c.top)||0)+f,bottom:((c==null?void 0:c.bottom)||0)+f}}coordsChar(n,a){var o=this.cm6.contentDOM.getBoundingClientRect(),s=this.cm6.posAtCoords({x:n.left+o.left,y:n.top+o.top})||0;return lr(this.cm6.state.doc,s)}getScrollInfo(){var n=this.cm6.scrollDOM;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight,width:n.scrollWidth,clientHeight:n.clientHeight,clientWidth:n.clientWidth}}scrollTo(n,a){n!=null&&(this.cm6.scrollDOM.scrollLeft=n),a!=null&&(this.cm6.scrollDOM.scrollTop=a)}scrollIntoView(n,a){if(n){var o=this.indexFromPos(n);this.cm6.dispatch({effects:Et.scrollIntoView(o)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(n,a){this.cm6.dom.style.width=n+4+"px",this.cm6.dom.style.height=a+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(n){for(let o in this.$lineHandleChanges&&this.$lineHandleChanges.push(n),this.marks)this.marks[o].update(n.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(o=>o.map(n.changes)));var a=this.curOp=this.curOp||{};n.changes.iterChanges((o,s,c,f,d)=>{(a.$changeStart==null||a.$changeStart>c)&&(a.$changeStart=c),this.$lastChangeEndOffset=f;var m={text:d.toJSON()};a.lastChange?a.lastChange.next=a.lastChange=m:a.lastChange=a.change=m},!0),a.changeHandlers||(a.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var n=this.curOp=this.curOp||{};n.cursorActivityHandlers||(n.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(n,a){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var o=n()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return o}onBeforeEndOperation(){var n=this.curOp,a=!1;n&&(n.change&&My(n.changeHandlers,this,n.change),n&&n.cursorActivity&&(My(n.cursorActivityHandlers,this,null),n.isVimOp&&(a=!0)),this.curOp=null),a&&this.scrollIntoView()}moveH(n,a){if(a=="char"){var o=this.getCursor();this.setCursor(o.line,o.ch+n)}}setOption(n,a){switch(n){case"keyMap":this.state.keyMap=a;break;case"textwidth":this.state.textwidth=a;break}}getOption(n){switch(n){case"firstLineNumber":return 1;case"tabSize":return this.cm6.state.tabSize||4;case"readOnly":return this.cm6.state.readOnly;case"indentWithTabs":return this.cm6.state.facet(Ow)==" ";case"indentUnit":return this.cm6.state.facet(Ow).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(n){this.state.overwrite=n}getTokenTypeAt(n){var s,c,f;var a=this.indexFromPos(n),o=((f=(c=(s=Nw(this.cm6.state,a))==null?void 0:s.resolve(a))==null?void 0:c.type)==null?void 0:f.name)||"";return/comment/i.test(o)?"comment":/string/i.test(o)?"string":""}overWriteSelection(n){var a=this.cm6.state.doc,o=this.cm6.state.selection,s=o.ranges.map(c=>{if(c.empty){var f=c.to<a.length?a.sliceString(c.from,c.to+1):"";if(f&&!/\n/.test(f))return $t.range(c.from,c.to+1)}return c});this.cm6.dispatch({selection:$t.create(s,o.mainIndex)}),this.replaceSelection(n)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(n){var a=this.cm6.state.selection;this.virtualSelection=$t.create(a.ranges,a.mainIndex);for(var o=0;o<this.virtualSelection.ranges.length;o++){var s=this.virtualSelection.ranges[o];s&&(this.cm6.dispatch({selection:$t.create([s])}),n(),this.virtualSelection.ranges[o]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(n){return r3(this,n)}};Ve.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ve.Pos=Cr,Ve.StringStream=e8,Ve.commands={cursorCharLeft:function(e){f8(e.cm6)},redo:function(e){Dy(e,!1)},undo:function(e){Dy(e,!0)},newlineAndIndent:function(e){y8({state:e.cm6.state,dispatch:n=>bs(e,n)})},indentAuto:function(e){a8(e.cm6)},newlineAndIndentContinueComment:void 0,save:void 0},Ve.isWordChar=function(e){return uf.test(e)},Ve.keys=QS,Ve.addClass=function(e,n){},Ve.rmClass=function(e,n){},Ve.e_preventDefault=function(e){e.preventDefault()},Ve.e_stop=function(e){var n,a;(n=e==null?void 0:e.stopPropagation)==null||n.call(e),(a=e==null?void 0:e.preventDefault)==null||a.call(e)},Ve.lookupKey=function(e,n,a){var o=Ve.keys[e];!o&&/^Arrow/.test(e)&&(o=Ve.keys[e.slice(5)]),o&&a(o)},Ve.on=Ry,Ve.off=Py,Ve.signal=Ny,Ve.findMatchingTag=e3,Ve.findEnclosingTag=t3,Ve.keyName=void 0;function jy(e,n,a){var o=document.createElement("div");return o.appendChild(n),o}function zy(e,n){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=n}function GS(e,n,a){zy(e,d);var o=jy(e,n,a&&a.bottom),s=!1,c,f=a&&a.duration!==void 0?a.duration:5e3;function d(){s||(s=!0,clearTimeout(c),o.remove(),Fy(e,o))}return o.onclick=function(m){m.preventDefault(),d()},qy(e,o),f&&(c=setTimeout(d,f)),d}function qy(e,n){var a=e.state.dialog;e.state.dialog=n,n.style.flex="1",n&&a!==n&&(a&&a.contains(document.activeElement)&&e.focus(),a&&a.parentElement?a.parentElement.replaceChild(n,a):a&&a.remove(),Ve.signal(e,"dialog"))}function Fy(e,n){e.state.dialog==n&&(e.state.dialog=null,Ve.signal(e,"dialog"))}function JS(e,n,a,o){o||(o={}),zy(e,void 0);var s=jy(e,n,o.bottom),c=!1;qy(e,s);function f(m){if(typeof m=="string")d.value=m;else{if(c)return;c=!0,Fy(e,s),e.state.dialog||e.focus(),o.onClose&&o.onClose(s)}}var d=s.getElementsByTagName("input")[0];return d&&(o.value&&(d.value=o.value,o.selectValueOnOpen!==!1&&d.select()),o.onInput&&Ve.on(d,"input",function(m){o.onInput(m,d.value,f)}),o.onKeyUp&&Ve.on(d,"keyup",function(m){o.onKeyUp(m,d.value,f)}),Ve.on(d,"keydown",function(m){o&&o.onKeyDown&&o.onKeyDown(m,d.value,f)||(m.keyCode==13&&a&&a(d.value),(m.keyCode==27||o.closeOnEnter!==!1&&m.keyCode==13)&&(d.blur(),Ve.e_stop(m),f()))}),o.closeOnBlur!==!1&&Ve.on(d,"blur",function(){setTimeout(function(){document.activeElement!==d&&f()})}),d.focus()),f}var XS={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function YS(e){return e&&e.bracketRegex||/[(){}[\]]/}function ZS(e,n,a,o,s){for(var c=s&&s.maxScanLineLength||1e4,f=s&&s.maxScanLines||1e3,d=[],m=YS(s),b=a>0?Math.min(n.line+f,e.lastLine()+1):Math.max(e.firstLine()-1,n.line-f),_=n.line;_!=b;_+=a){var x=e.getLine(_);if(x){var S=a>0?0:x.length-1,E=a>0?x.length:-1;if(!(x.length>c))for(_==n.line&&(S=n.ch-(a<0?1:0));S!=E;S+=a){var L=x.charAt(S);if(m.test(L)){var P=XS[L];if(P&&P.charAt(1)==">"==a>0)d.push(L);else if(d.length)d.pop();else return{pos:new Cr(_,S),ch:L}}}}}return _-a==(a>0?e.lastLine():e.firstLine())?!1:null}function e3(e,n){return null}function t3(e,n){var c,f,d;var a=e.cm6.state,o=e.indexFromPos(n);o<a.doc.length&&a.sliceDoc(o,o+1)=="<"&&o++;for(var s=((c=Nw(a,o))==null?void 0:c.resolve(o))||null;s;){if(((f=s.firstChild)==null?void 0:f.type.name)=="OpenTag"&&((d=s.lastChild)==null?void 0:d.type.name)=="CloseTag")return{open:By(a.doc,s.firstChild),close:By(a.doc,s.lastChild)};s=s.parent}}function By(e,n){return{from:lr(e,n.from),to:lr(e,n.to)}}var n3=class{constructor(e,n,a){this.cm=e,this.id=e.$mid++,this.offset=n,this.assoc=a,e.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(e){this.offset!=null&&(this.offset=e.mapPos(this.offset,this.assoc,Pw.TrackDel))}};function r3(e,n){var L;for(var a=n.column||e.getOption("textwidth")||80,o=n.allowMerge!=0,s=Math.min(n.from,n.to),c=Math.max(n.from,n.to);s<=c;){var f=e.getLine(s);if(f.length>a){var d=E(f,a,5);if(d){var m=(L=/^\s*/.exec(f))==null?void 0:L[0];e.replaceRange(`
92
+ `);if(v.maybeReset&&(v.maybeReset=(v.changes=[],!1)),T)if(u.state.overwrite&&!/\n/.test(T))v.changes.push([T]);else{if(T.length>1){var O=w&&w.insertEnd&&w.insertEnd.find(),R=u.getCursor();if(O&&O.line==R.line){var z=O.ch-R.ch;z>0&&z<T.length&&(v.changes.push([T,z]),T="")}}T&&v.changes.push(T)}}h=h.next}}function To(u){var w;var h=u.state.vim;if(h.insertMode){var y=W.macroModeState;if(y.isPlaying)return;var v=y.lastInsertModeChanges;v.expectCursorActivityForChange?v.expectCursorActivityForChange=!1:(v.maybeReset=!0,h.insertEnd&&h.insertEnd.clear(),h.insertEnd=u.setBookmark(u.getCursor(),{insertLeft:!0}))}else(w=u.curOp)!=null&&w.isVimOp||Ci(u,h)}function Ci(u,h){var y=u.getCursor("anchor"),v=u.getCursor("head");if(h.visualMode&&!u.somethingSelected()?An(u,!1):!h.visualMode&&!h.insertMode&&u.somethingSelected()&&(h.visualMode=!0,h.visualLine=!1,e.signal(u,"vim-mode-change",{mode:"visual"})),h.visualMode){var w=wt(v,y)?0:-1,k=wt(v,y)?-1:0;v=kt(v,0,w),y=kt(y,0,k),h.sel={anchor:y,head:v},dn(u,h,"<",Xt(v,y)),dn(u,h,">",Sr(v,y))}else h.insertMode||(h.lastHPos=u.getCursor().ch)}function zs(u){var h=W.macroModeState.lastInsertModeChanges,y=e.keyName?e.keyName(u):u.key;y&&(y.indexOf("Delete")!=-1||y.indexOf("Backspace")!=-1)&&(h.maybeReset&&(h.maybeReset=(h.changes=[],!1)),h.changes.push(new He(y,u)))}function Si(u,h,y,v){var w=W.macroModeState;w.isPlaying=!0;var k=h.lastEditActionCommand,T=h.inputState;function O(){k?dr.processAction(u,h,k):dr.evalInput(u,h)}function R(D){if(w.lastInsertModeChanges.changes.length>0){D=h.lastEditActionCommand?D:1;var te=w.lastInsertModeChanges;qs(u,te.changes,D)}}if(h.inputState=h.lastEditInputState,k&&k.interlaceInsertRepeat)for(var z=0;z<y;z++)O(),R(1);else v||O(),R(y);h.inputState=T,h.insertMode&&!v&&pn(u),w.isPlaying=!1}function Ei(u,h){e.lookupKey(h,"vim-insert",function(y){return typeof y=="string"?e.commands[y](u):y(u),!0})}function qs(u,h,y){var v=u.getCursor("head"),w=W.macroModeState.lastInsertModeChanges.visualBlock;w&&(mc(u,v,w+1),y=u.listSelections().length,u.setCursor(v));for(var k=0;k<y;k++){w&&u.setCursor(kt(v,k,0));for(var T=0;T<h.length;T++){var O=h[T];if(O instanceof He)Ei(u,O.keyName);else if(typeof O=="string")u.replaceSelection(O);else{var R=u.getCursor(),z=kt(R,0,O[0].length-(O[1]||0));u.replaceRange(O[0],R,O[1]?R:z),u.setCursor(z)}}}w&&u.setCursor(kt(v,0,1))}function Qt(u){var h=new u.constructor;return Object.keys(u).forEach(function(y){if(y!="insertEnd"){var v=u[y];Array.isArray(v)?v=v.slice():v&&typeof v=="object"&&v.constructor!=Object&&(v=Qt(v)),h[y]=v}}),u.sel&&(h.sel={head:u.sel.head&&Qe(u.sel.head),anchor:u.sel.anchor&&Qe(u.sel.anchor)}),h}function $r(u,h,y){var k=ee(u),v=u,w=!1,k=Fe.maybeInitVimState_(v),T=k.visualBlock||k.wasInVisualBlock;if(v.state.closeVimNotification){var O=v.state.closeVimNotification;if(v.state.closeVimNotification=null,O(),h=="<CR>")return mt(v),!0}var R=v.isInMultiSelectMode();if(k.wasInVisualBlock&&!R?k.wasInVisualBlock=!1:R&&k.visualBlock&&(k.wasInVisualBlock=!0),h=="<Esc>"&&!k.insertMode&&!k.visualMode&&R&&k.status=="<Esc>")mt(v);else if(T||!R||v.inVirtualSelectionMode)w=Fe.handleKey(v,h,y);else{var z=Qt(k),D=k.inputState.changeQueueList||[];v.operation(function(){var Y;v.curOp&&(v.curOp.isVimOp=!0);var te=0;v.forEachSelection(function(){v.state.vim.inputState.changeQueue=D[te];var K=v.getCursor("head"),Q=v.getCursor("anchor"),ge=wt(K,Q)?0:-1,me=wt(K,Q)?-1:0;K=kt(K,0,ge),Q=kt(Q,0,me),v.state.vim.sel.head=K,v.state.vim.sel.anchor=Q,w=Fe.handleKey(v,h,y),v.virtualSelection&&(D[te]=v.state.vim.inputState.changeQueue,v.state.vim=Qt(z)),te++}),(Y=v.curOp)!=null&&Y.cursorActivity&&!w&&(v.curOp.cursorActivity=!1),v.state.vim=k,k.inputState.changeQueueList=D,k.inputState.changeQueue=null},!0)}return w&&!k.visualMode&&!k.insertMode&&k.visualMode!=v.somethingSelected()&&Ci(v,k),w}return Ie(),Fe}function Ln(e,n){var a=n.ch,o=n.line+1;o<1&&(o=1,a=0),o>e.lines&&(o=e.lines,a=Number.MAX_VALUE);var s=e.line(o);return Math.min(s.from+Math.max(0,a),s.to)}function lr(e,n){let a=e.lineAt(n);return{line:a.number-1,ch:n-a.from}}var Cr=class{constructor(e,n){this.line=e,this.ch=n}};function Ry(e,n,a){if(e.addEventListener)e.addEventListener(n,a,!1);else{var o=e._handlers||(e._handlers={});o[n]=(o[n]||[]).concat(a)}}function Py(e,n,a){if(e.removeEventListener)e.removeEventListener(n,a,!1);else{var o=e._handlers,s=o&&o[n];if(s){var c=s.indexOf(a);c>-1&&(o[n]=s.slice(0,c).concat(s.slice(c+1)))}}}function Ny(e,n,...a){var c;var o=(c=e._handlers)==null?void 0:c[n];if(o)for(var s=0;s<o.length;++s)o[s](...a)}function My(e,...n){if(e)for(var a=0;a<e.length;++a)e[a](...n)}var uf;try{uf=RegExp("[\\w\\p{Alphabetic}\\p{Number}_]","u")}catch{uf=/[\w]/}function bs(e,n){var a=e.cm6;if(!a.state.readOnly){var o="input.type.compose";if(e.curOp&&(e.curOp.lastChange||(o="input.type.compose.start")),n.annotations)try{n.annotations.some(function(s){s.value=="input"&&(s.value=o)})}catch(s){console.error(s)}else n.userEvent=o;return a.dispatch(n)}}function Dy(e,n){var o;e.curOp&&(e.curOp.$changeStart=void 0),(n?a8:d8)(e.cm6);let a=(o=e.curOp)==null?void 0:o.$changeStart;a!=null&&e.cm6.dispatch({selection:{anchor:a}})}var QS={Left:e=>as(e.cm6,{key:"Left"},"editor"),Right:e=>as(e.cm6,{key:"Right"},"editor"),Up:e=>as(e.cm6,{key:"Up"},"editor"),Down:e=>as(e.cm6,{key:"Down"},"editor"),Backspace:e=>as(e.cm6,{key:"Backspace"},"editor"),Delete:e=>as(e.cm6,{key:"Delete"},"editor")},Ve=class Qx{openDialog(n,a,o){return JS(this,n,a,o)}openNotification(n,a){return GS(this,n,a)}constructor(n){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=n,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(n,a){Ry(this,n,a)}off(n,a){Py(this,n,a)}signal(n,a,o){Ny(this,n,a,o)}indexFromPos(n){return Ln(this.cm6.state.doc,n)}posFromIndex(n){return lr(this.cm6.state.doc,n)}foldCode(n){let a=this.cm6,o=a.state.selection.ranges,s=this.cm6.state.doc,c=Ln(s,n),f=$t.create([$t.range(c,c)],0).ranges;a.state.selection.ranges=f,B6(a),a.state.selection.ranges=o}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(n,a){typeof n=="object"&&(a=n.ch,n=n.line);var o=Ln(this.cm6.state.doc,{line:n,ch:a||0});this.cm6.dispatch({selection:{anchor:o}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(n){var a=this.cm6.state.selection.main,o=n=="head"||!n?a.head:n=="anchor"?a.anchor:n=="start"?a.from:n=="end"?a.to:null;if(o==null)throw Error("Invalid cursor type");return this.posFromIndex(o)}listSelections(){var n=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(a=>({anchor:lr(n,a.anchor),head:lr(n,a.head)}))}setSelections(n,a){var o=this.cm6.state.doc,s=n.map(c=>{var f=Ln(o,c.head),d=Ln(o,c.anchor);return f==d?$t.cursor(f,1):$t.range(d,f)});this.cm6.dispatch({selection:$t.create(s,a)})}setSelection(n,a,o){this.setSelections([{anchor:n,head:a}],0),o&&o.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(n){var a=this.cm6.state.doc;return n<0||n>=a.lines?"":this.cm6.state.doc.line(n+1).text}getLineHandle(n){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:n,index:this.indexFromPos(new Cr(n,0))}}getLineNumber(n){var a=this.$lineHandleChanges;if(!a)return null;for(var o=n.index,s=0;s<a.length;s++)if(o=a[s].changes.mapPos(o,1,Pw.TrackAfter),o==null)return null;var c=this.posFromIndex(o);return c.ch==0?c.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(n,a){var o=this.cm6.state.doc;return this.cm6.state.sliceDoc(Ln(o,n),Ln(o,a))}replaceRange(n,a,o,s){o||(o=a);var c=this.cm6.state.doc,f=Ln(c,a),d=Ln(c,o);bs(this,{changes:{from:f,to:d,insert:n}})}replaceSelection(n){bs(this,this.cm6.state.replaceSelection(n))}replaceSelections(n){var a=this.cm6.state.selection.ranges.map((o,s)=>({from:o.from,to:o.to,insert:n[s]||""}));bs(this,{changes:a})}getSelection(){return this.getSelections().join(`
93
+ `)}getSelections(){var n=this.cm6;return n.state.selection.ranges.map(a=>n.state.sliceDoc(a.from,a.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(n=>!n.empty)}getInputField(){return this.cm6.contentDOM}clipPos(n){var a=this.cm6.state.doc,o=n.ch,s=n.line+1;s<1&&(s=1,o=0),s>a.lines&&(s=a.lines,o=Number.MAX_VALUE);var c=a.line(s);return o=Math.min(Math.max(0,o),c.to-c.from),new Cr(s-1,o)}getValue(){return this.cm6.state.doc.toString()}setValue(n){var a=this.cm6;return a.dispatch({changes:{from:0,to:a.state.doc.length,insert:n},selection:$t.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(n,a){var o=this.cm6.state,s=Ln(o.doc,n),c=zw(o,s+1,-1);return c&&c.end||(c=zw(o,s,1),c&&c.end)?{to:lr(o.doc,c.end.from)}:{to:void 0}}scanForBracket(n,a,o,s){return ZS(this,n,a,o,s)}indentLine(n,a){a?this.indentMore():this.indentLess()}indentMore(){y8(this.cm6)}indentLess(){n8(this.cm6)}execCommand(n){if(n=="indentAuto")Qx.commands.indentAuto(this);else if(n=="goLineLeft")u8(this.cm6);else if(n=="goLineRight"){c8(this.cm6);let a=this.cm6.state,o=a.selection.main.head;o<a.doc.length&&a.sliceDoc(o,o+1)!==`
94
+ `&&l8(this.cm6)}else console.log(n+" is not implemented")}setBookmark(n,a){var o=a!=null&&a.insertLeft?1:-1,s=this.indexFromPos(n);return new n3(this,s,o)}addOverlay({query:n}){let a=new f8({regexp:!0,search:n.source,caseSensitive:!/i/.test(n.flags)});if(a.valid){a.forVim=!0,this.cm6Query=a;let o=Bh.of(a);return this.cm6.dispatch({effects:o}),a}}removeOverlay(n){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let a=Bh.of(this.cm6Query);this.cm6.dispatch({effects:a})}getSearchCursor(n,a){var o=this,s=null,c=null,f=!1;a.ch??(a.ch=Number.MAX_VALUE);var d=Ln(o.cm6.state.doc,a),m=n.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(E,L){return L||"\\"+E});function b(E,L=0,P=E.length){return new m8(E,m,{ignoreCase:n.ignoreCase},L,P)}function _(E){var L=o.cm6.state.doc;if(E>L.length)return null;let P=b(L,E).next();return P.done?null:P.value}var x=1e4;function S(E,L){var P=o.cm6.state.doc;for(let q=1;;q++){let V=Math.max(E,L-q*x),B=b(P,V,L),M=null;for(;!B.next().done;)M=B.value;if(M&&(V==E||M.from>V+10))return M;if(V==E)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(E){var L=o.cm6.state.doc;return s=E?S(0,s?f?s.to-1:s.from:d):_(s?f?s.to+1:s.to:d),c=s&&{from:lr(L,s.from),to:lr(L,s.to),match:s.match},f=s?s.from==s.to:!1,s&&s.match},from:function(){return c==null?void 0:c.from},to:function(){return c==null?void 0:c.to},replace:function(E){s&&(bs(o,{changes:{from:s.from,to:s.to,insert:E}}),s.to=s.from+E.length,c&&(c.to=lr(o.cm6.state.doc,s.to)))},get match(){return c&&c.match}}}findPosV(n,a,o,s){let{cm6:c}=this,f=c.state.doc,d=o=="page"?c.dom.clientHeight:0,m=Ln(f,n),b=$t.cursor(m,1,void 0,s),_=Math.round(Math.abs(a));for(let S=0;S<_;S++)o=="page"?b=c.moveVertically(b,a>0,d):o=="line"&&(b=c.moveVertically(b,a>0));let x=lr(f,b.head);return(a<0&&b.head==0&&s!=0&&n.line==0&&n.ch!=0||a>0&&b.head==f.length&&x.ch!=s&&n.line==x.line)&&(x.hitSide=!0),x}charCoords(n,a){var o=this.cm6.contentDOM.getBoundingClientRect(),s=Ln(this.cm6.state.doc,n),c=this.cm6.coordsAtPos(s),f=-o.top;return{left:((c==null?void 0:c.left)||0)-o.left,top:((c==null?void 0:c.top)||0)+f,bottom:((c==null?void 0:c.bottom)||0)+f}}coordsChar(n,a){var o=this.cm6.contentDOM.getBoundingClientRect(),s=this.cm6.posAtCoords({x:n.left+o.left,y:n.top+o.top})||0;return lr(this.cm6.state.doc,s)}getScrollInfo(){var n=this.cm6.scrollDOM;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight,width:n.scrollWidth,clientHeight:n.clientHeight,clientWidth:n.clientWidth}}scrollTo(n,a){n!=null&&(this.cm6.scrollDOM.scrollLeft=n),a!=null&&(this.cm6.scrollDOM.scrollTop=a)}scrollIntoView(n,a){if(n){var o=this.indexFromPos(n);this.cm6.dispatch({effects:Et.scrollIntoView(o)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(n,a){this.cm6.dom.style.width=n+4+"px",this.cm6.dom.style.height=a+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(n){for(let o in this.$lineHandleChanges&&this.$lineHandleChanges.push(n),this.marks)this.marks[o].update(n.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(o=>o.map(n.changes)));var a=this.curOp=this.curOp||{};n.changes.iterChanges((o,s,c,f,d)=>{(a.$changeStart==null||a.$changeStart>c)&&(a.$changeStart=c),this.$lastChangeEndOffset=f;var m={text:d.toJSON()};a.lastChange?a.lastChange.next=a.lastChange=m:a.lastChange=a.change=m},!0),a.changeHandlers||(a.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var n=this.curOp=this.curOp||{};n.cursorActivityHandlers||(n.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(n,a){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var o=n()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return o}onBeforeEndOperation(){var n=this.curOp,a=!1;n&&(n.change&&My(n.changeHandlers,this,n.change),n&&n.cursorActivity&&(My(n.cursorActivityHandlers,this,null),n.isVimOp&&(a=!0)),this.curOp=null),a&&this.scrollIntoView()}moveH(n,a){if(a=="char"){var o=this.getCursor();this.setCursor(o.line,o.ch+n)}}setOption(n,a){switch(n){case"keyMap":this.state.keyMap=a;break;case"textwidth":this.state.textwidth=a;break}}getOption(n){switch(n){case"firstLineNumber":return 1;case"tabSize":return this.cm6.state.tabSize||4;case"readOnly":return this.cm6.state.readOnly;case"indentWithTabs":return this.cm6.state.facet(Ow)==" ";case"indentUnit":return this.cm6.state.facet(Ow).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(n){this.state.overwrite=n}getTokenTypeAt(n){var s,c,f;var a=this.indexFromPos(n),o=((f=(c=(s=Nw(this.cm6.state,a))==null?void 0:s.resolve(a))==null?void 0:c.type)==null?void 0:f.name)||"";return/comment/i.test(o)?"comment":/string/i.test(o)?"string":""}overWriteSelection(n){var a=this.cm6.state.doc,o=this.cm6.state.selection,s=o.ranges.map(c=>{if(c.empty){var f=c.to<a.length?a.sliceString(c.from,c.to+1):"";if(f&&!/\n/.test(f))return $t.range(c.from,c.to+1)}return c});this.cm6.dispatch({selection:$t.create(s,o.mainIndex)}),this.replaceSelection(n)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(n){var a=this.cm6.state.selection;this.virtualSelection=$t.create(a.ranges,a.mainIndex);for(var o=0;o<this.virtualSelection.ranges.length;o++){var s=this.virtualSelection.ranges[o];s&&(this.cm6.dispatch({selection:$t.create([s])}),n(),this.virtualSelection.ranges[o]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(n){return r3(this,n)}};Ve.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ve.Pos=Cr,Ve.StringStream=e8,Ve.commands={cursorCharLeft:function(e){p8(e.cm6)},redo:function(e){Dy(e,!1)},undo:function(e){Dy(e,!0)},newlineAndIndent:function(e){r8({state:e.cm6.state,dispatch:n=>bs(e,n)})},indentAuto:function(e){o8(e.cm6)},newlineAndIndentContinueComment:void 0,save:void 0},Ve.isWordChar=function(e){return uf.test(e)},Ve.keys=QS,Ve.addClass=function(e,n){},Ve.rmClass=function(e,n){},Ve.e_preventDefault=function(e){e.preventDefault()},Ve.e_stop=function(e){var n,a;(n=e==null?void 0:e.stopPropagation)==null||n.call(e),(a=e==null?void 0:e.preventDefault)==null||a.call(e)},Ve.lookupKey=function(e,n,a){var o=Ve.keys[e];!o&&/^Arrow/.test(e)&&(o=Ve.keys[e.slice(5)]),o&&a(o)},Ve.on=Ry,Ve.off=Py,Ve.signal=Ny,Ve.findMatchingTag=e3,Ve.findEnclosingTag=t3,Ve.keyName=void 0;function jy(e,n,a){var o=document.createElement("div");return o.appendChild(n),o}function zy(e,n){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=n}function GS(e,n,a){zy(e,d);var o=jy(e,n,a&&a.bottom),s=!1,c,f=a&&a.duration!==void 0?a.duration:5e3;function d(){s||(s=!0,clearTimeout(c),o.remove(),Fy(e,o))}return o.onclick=function(m){m.preventDefault(),d()},qy(e,o),f&&(c=setTimeout(d,f)),d}function qy(e,n){var a=e.state.dialog;e.state.dialog=n,n.style.flex="1",n&&a!==n&&(a&&a.contains(document.activeElement)&&e.focus(),a&&a.parentElement?a.parentElement.replaceChild(n,a):a&&a.remove(),Ve.signal(e,"dialog"))}function Fy(e,n){e.state.dialog==n&&(e.state.dialog=null,Ve.signal(e,"dialog"))}function JS(e,n,a,o){o||(o={}),zy(e,void 0);var s=jy(e,n,o.bottom),c=!1;qy(e,s);function f(m){if(typeof m=="string")d.value=m;else{if(c)return;c=!0,Fy(e,s),e.state.dialog||e.focus(),o.onClose&&o.onClose(s)}}var d=s.getElementsByTagName("input")[0];return d&&(o.value&&(d.value=o.value,o.selectValueOnOpen!==!1&&d.select()),o.onInput&&Ve.on(d,"input",function(m){o.onInput(m,d.value,f)}),o.onKeyUp&&Ve.on(d,"keyup",function(m){o.onKeyUp(m,d.value,f)}),Ve.on(d,"keydown",function(m){o&&o.onKeyDown&&o.onKeyDown(m,d.value,f)||(m.keyCode==13&&a&&a(d.value),(m.keyCode==27||o.closeOnEnter!==!1&&m.keyCode==13)&&(d.blur(),Ve.e_stop(m),f()))}),o.closeOnBlur!==!1&&Ve.on(d,"blur",function(){setTimeout(function(){document.activeElement!==d&&f()})}),d.focus()),f}var XS={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function YS(e){return e&&e.bracketRegex||/[(){}[\]]/}function ZS(e,n,a,o,s){for(var c=s&&s.maxScanLineLength||1e4,f=s&&s.maxScanLines||1e3,d=[],m=YS(s),b=a>0?Math.min(n.line+f,e.lastLine()+1):Math.max(e.firstLine()-1,n.line-f),_=n.line;_!=b;_+=a){var x=e.getLine(_);if(x){var S=a>0?0:x.length-1,E=a>0?x.length:-1;if(!(x.length>c))for(_==n.line&&(S=n.ch-(a<0?1:0));S!=E;S+=a){var L=x.charAt(S);if(m.test(L)){var P=XS[L];if(P&&P.charAt(1)==">"==a>0)d.push(L);else if(d.length)d.pop();else return{pos:new Cr(_,S),ch:L}}}}}return _-a==(a>0?e.lastLine():e.firstLine())?!1:null}function e3(e,n){return null}function t3(e,n){var c,f,d;var a=e.cm6.state,o=e.indexFromPos(n);o<a.doc.length&&a.sliceDoc(o,o+1)=="<"&&o++;for(var s=((c=Nw(a,o))==null?void 0:c.resolve(o))||null;s;){if(((f=s.firstChild)==null?void 0:f.type.name)=="OpenTag"&&((d=s.lastChild)==null?void 0:d.type.name)=="CloseTag")return{open:By(a.doc,s.firstChild),close:By(a.doc,s.lastChild)};s=s.parent}}function By(e,n){return{from:lr(e,n.from),to:lr(e,n.to)}}var n3=class{constructor(e,n,a){this.cm=e,this.id=e.$mid++,this.offset=n,this.assoc=a,e.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(e){this.offset!=null&&(this.offset=e.mapPos(this.offset,this.assoc,Pw.TrackDel))}};function r3(e,n){var L;for(var a=n.column||e.getOption("textwidth")||80,o=n.allowMerge!=0,s=Math.min(n.from,n.to),c=Math.max(n.from,n.to);s<=c;){var f=e.getLine(s);if(f.length>a){var d=E(f,a,5);if(d){var m=(L=/^\s*/.exec(f))==null?void 0:L[0];e.replaceRange(`
95
95
  `+m,new Cr(s,d.start),new Cr(s,d.end))}c++}else if(o&&/\S/.test(f)&&s!=c){var b=e.getLine(s+1);if(b&&/\S/.test(b)){var _=f.replace(/\s+$/,""),x=b.replace(/^\s+/,""),S=_+" "+x,d=E(S,a,5);d&&d.start>_.length||S.length<a?(e.replaceRange(" ",new Cr(s,_.length),new Cr(s+1,b.length-x.length)),s--,c--):_.length<f.length&&e.replaceRange("",new Cr(s,_.length),new Cr(s,f.length))}}s++}return s;function E(P,q,V){if(!(P.length<q)){var B=P.slice(0,q),M=P.slice(q),J=/^(?:(\s+)|(\S+)(\s+))/.exec(M),le=/(?:(\s+)|(\s+)(\S+))$/.exec(B),A=0,j=0;if(le&&!le[2]&&(A=q-le[1].length,j=q),J&&!J[2]&&(A||(A=q),j=q+J[1].length),A)return{start:A,end:j};if(le&&le[2]&&le.index>V)return{start:le.index,end:le.index+le[2].length};if(J&&J[2])return A=q+J[2].length,{start:A,end:A+J[3].length}}}}var df=Y6||(function(){let e={cursorBlinkRate:1200};return function(){return e}})(),a3=class{constructor(e,n,a,o,s,c,f,d,m,b){this.left=e,this.top=n,this.height=a,this.fontFamily=o,this.fontSize=s,this.fontWeight=c,this.color=f,this.className=d,this.letter=m,this.partial=b}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",e.style.height=this.height+"px",e.style.lineHeight=this.height+"px",e.style.fontFamily=this.fontFamily,e.style.fontSize=this.fontSize,e.style.fontWeight=this.fontWeight,e.style.color=this.partial?"transparent":this.color,e.className=this.className,e.textContent=this.letter}eq(e){return this.left==e.left&&this.top==e.top&&this.height==e.height&&this.fontFamily==e.fontFamily&&this.fontSize==e.fontSize&&this.fontWeight==e.fontWeight&&this.color==e.color&&this.className==e.className&&this.letter==e.letter}},i3=class{constructor(e,n){this.view=e,this.rangePieces=[],this.cursors=[],this.cm=n,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=e.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer cm-vimCursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),e.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let e=df(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=e+"ms"}update(e){(e.selectionSet||e.geometryChanged||e.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),o3(e)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:e}=this.view,n=[];for(let a of e.selection.ranges){let o=a==e.selection.main,s=c3(this.cm,this.view,a,o);s&&n.push(s)}return{cursors:n}}drawSel({cursors:e}){if(e.length!=this.cursors.length||e.some((n,a)=>!n.eq(this.cursors[a]))){let n=this.cursorLayer.children;if(n.length!==e.length){this.cursorLayer.textContent="";for(let a of e)this.cursorLayer.appendChild(a.draw())}else e.forEach((a,o)=>a.adjust(n[o]));this.cursors=e}}destroy(){this.cursorLayer.remove()}};function o3(e){return df(e.startState)!=df(e.state)}var s3=zu.highest(Et.theme({".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-fat-cursor":{position:"absolute",background:"#ff9696",border:"none",whiteSpace:"pre"},"&:not(.cm-focused) .cm-fat-cursor":{background:"none",outline:"solid 1px #ff9696",color:"transparent !important"}}));function l3(e){let n=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==G6.LTR?n.left:n.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft*e.scaleX,top:n.top-e.scrollDOM.scrollTop*e.scaleY}}function c3(e,n,a,o){var _,x,S;var s;let c=a.head,f=!1,d=1,m=e.state.vim;if(m&&(!m.insertMode||e.state.overwrite)){if(f=!0,m.visualBlock&&!o)return null;a.anchor<a.head&&(c<n.state.doc.length&&n.state.sliceDoc(c,c+1))!=`
96
96
  `&&c--,e.state.overwrite?d=.2:m.status&&(d=.5)}if(f){let E=c<n.state.doc.length&&n.state.sliceDoc(c,c+1);E&&/[\uDC00-\uDFFF]/.test(E)&&c>1&&(c--,E=n.state.sliceDoc(c,c+1));let L=n.coordsAtPos(c,1);if(!L)return null;let P=l3(n),q=n.domAtPos(c),V=q?q.node:n.contentDOM;for(V instanceof Text&&q.offset>=V.data.length&&((_=V.parentElement)==null?void 0:_.nextSibling)&&(V=(x=V.parentElement)==null?void 0:x.nextSibling,q={node:V,offset:0});q&&q.node instanceof HTMLElement;)V=q.node,q={node:q.node.childNodes[q.offset],offset:0};if(!(V instanceof HTMLElement)){if(!V.parentNode)return null;V=V.parentNode}let B=getComputedStyle(V),M=L.left,J=(S=(s=n).coordsForChar)==null?void 0:S.call(s,c);if(J&&(M=J.left),!E||E==`
97
- `||E=="\r")E="\xA0";else if(E==" "){E="\xA0";var b=n.coordsAtPos(c+1,-1);b&&(M=b.left-(b.left-L.left)/parseInt(B.tabSize))}else/[\uD800-\uDBFF]/.test(E)&&c<n.state.doc.length-1&&(E+=n.state.sliceDoc(c+1,c+2));let le=L.bottom-L.top;return new a3((M-P.left)/n.scaleX,(L.top-P.top+le*(1-d))/n.scaleY,le*d/n.scaleY,B.fontFamily,B.fontSize,B.fontWeight,B.color,o?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",E,d!=1)}else return null}let Vy,Hy,$y,Wy;Vy=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent),fa=KS(Ve),Hy=250,$y=Et.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:"none"},".cm-vim-panel":{padding:"0px 10px",fontFamily:"monospace",minHeight:"1.3em",display:"flex"},".cm-vim-panel input":{border:"none",outline:"none",backgroundColor:"inherit"},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"}}),Wy=Ui.fromClass(class{constructor(e){this.status="",this.query=null,this.decorations=ca.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=e;let n=this.cm=new Ve(e);fa.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new i3(e,n),this.updateClass(),this.cm.on("vim-command-done",()=>{n.state.vim&&(n.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",a=>{n.state.vim&&(n.state.vim.mode=a.mode,a.subMode&&(n.state.vim.mode+=" block"),n.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():e.dispatch({effects:Uy.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.spacer=document.createElement("span"),this.spacer.style.flex="1",this.statusButton=document.createElement("span"),this.statusButton.onclick=a=>{fa.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(e){var n;if((e.viewportChanged||e.docChanged)&&this.query&&this.highlight(this.query),e.docChanged&&this.cm.onChange(e),e.selectionSet&&this.cm.onSelectionChange(),e.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),e.transactions){for(let a of e.transactions)for(let o of a.effects)if(o.is(Bh))if(!((n=o.value)!=null&&n.forVim))this.highlight(null);else{let s=o.value.create();this.highlight(s)}}this.blockCursor.update(e)}updateClass(){let e=this.cm.state;!e.vim||e.vim.insertMode&&!e.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let e=this.cm.state.statusbar,n=this.cm.state.vim;if(!e||!n)return;let a=this.cm.state.dialog;if(a)a.parentElement!=e&&(e.textContent="",e.appendChild(a));else{e.textContent="";var o=(n.mode||"normal").toUpperCase();n.insertModeReturn&&(o+="(C-O)"),this.statusButton.textContent=`--${o}--`,e.appendChild(this.statusButton),e.appendChild(this.spacer)}this.dom.textContent=n.status,e.appendChild(this.dom)}destroy(){fa.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(e){if(this.query=e,!e)return this.decorations=ca.none;let{view:n}=this,a=new Aw;for(let o=0,s=n.visibleRanges,c=s.length;o<c;o++){let{from:f,to:d}=s[o];for(;o<c-1&&d>s[o+1].from-2*Hy;)d=s[++o].to;e.highlight(n.state,f,d,(m,b)=>{a.add(m,b,d3)})}return this.decorations=a.finish()}handleKey(e,n){let a=this.cm,o=a.state.vim;if(!o)return;let s=fa.vimKeyFromEvent(e,o);if(Ve.signal(this.cm,"inputEvent",{type:"handleKey",key:s}),!s)return;if(s=="<Esc>"&&!o.insertMode&&!o.visualMode&&this.query){let f=o.searchState_;f&&(a.removeOverlay(f.getOverlay()),f.setOverlay(null))}if(s==="<C-c>"&&!Ve.isMac&&a.somethingSelected())return this.waitForCopy=!0,!0;o.status=(o.status||"")+s;let c=fa.multiSelectHandleKey(a,s,"user");return o=fa.maybeInitVimState_(a),!c&&o.insertMode&&a.state.overwrite&&(e.key&&e.key.length==1&&!/\n/.test(e.key)?(c=!0,a.overWriteSelection(e.key)):e.key=="Backspace"&&(c=!0,Ve.commands.cursorCharLeft(a))),c&&(Ve.signal(this.cm,"vim-keypress",s),e.preventDefault(),e.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!c}},{eventHandlers:{copy:function(e,n){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var a=this.cm,o=a.state.vim;o&&(o.insertMode?a.setSelection(a.getCursor(),a.getCursor()):a.operation(()=>{a.curOp&&(a.curOp.isVimOp=!0),fa.handleKey(a,"<Esc>","user")}))}))},compositionstart:function(e,n){this.useNextTextInput=!0,Ve.signal(this.cm,"inputEvent",e)},compositionupdate:function(e,n){Ve.signal(this.cm,"inputEvent",e)},compositionend:function(e,n){Ve.signal(this.cm,"inputEvent",e)},keypress:function(e,n){Ve.signal(this.cm,"inputEvent",e),this.lastKeydown=="Dead"&&this.handleKey(e,n)},keydown:function(e,n){Ve.signal(this.cm,"inputEvent",e),this.lastKeydown=e.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(e,n))}},provide:()=>[Et.inputHandler.of((e,n,a,o)=>{var _,x;var s=zl(e);if(!s)return!1;var c=(_=s.state)==null?void 0:_.vim,f=s.state.vimPlugin;if(c&&!c.insertMode&&!((x=s.curOp)!=null&&x.isVimOp)){if(o==="\0\0")return!0;if(Ve.signal(s,"inputEvent",{type:"text",text:o,from:n,to:a}),o.length==1&&f.useNextTextInput){if(c.expectLiteralNext&&e.composing)return f.compositionText=o,!1;if(f.compositionText){var d=f.compositionText;f.compositionText="";var m=e.state.selection.main.head;if(d===e.state.sliceDoc(m-d.length,m)){var b=s.getCursor();s.replaceRange("",s.posFromIndex(m-d.length),b)}}return f.handleKey({key:o,preventDefault:()=>{},stopPropagation:()=>{}}),u3(e),!0}}return!1})],decorations:e=>e.decorations});function u3(e){var n=e.scrollDOM.parentElement;if(n){if(Vy){e.contentDOM.textContent="\0\0",e.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var a=e.scrollDOM.nextSibling,o=window.getSelection(),s=o&&{anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset};e.scrollDOM.remove(),n.insertBefore(e.scrollDOM,a);try{s&&o&&(o.setPosition(s.anchorNode,s.anchorOffset),s.focusNode&&o.extend(s.focusNode,s.focusOffset))}catch(c){console.error(c)}e.focus(),e.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}var d3=ca.mark({class:"cm-searchMatch"}),Uy=la.define(),f3=is.define({create:()=>!1,update(e,n){for(let a of n.effects)a.is(Uy)&&(e=a.value);return e},provide:e=>qh.from(e,n=>n?p3:null)});function p3(e){let n=document.createElement("div");n.className="cm-vim-panel";let a=e.cm;return a.state.dialog&&n.appendChild(a.state.dialog),{top:!1,dom:n}}function h3(e){let n=document.createElement("div");n.className="cm-vim-panel";let a=e.cm;return a.state.statusbar=n,a.state.vimPlugin.updateStatus(),{dom:n}}Px=function(e={}){return[$y,Wy,s3,e.status?qh.of(h3):f3]},zl=function(e){return e.cm||null},Jm=function(e){let n=e.state.selection.main;return n.from===0&&n.to===0},Vm=function(e,n=!1){let a=e.state.selection.main,o=e.state.doc.length;return n&&a.from===o-1&&a.to===o-1?!0:a.from===o&&a.to===o},xx=function(e){e&&e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length}})},dx=function(e){var n;return((n=zl(e))==null?void 0:n.state.vim)!=null},G_=function(e){var a;let n=(a=zl(e))==null?void 0:a.state.vim;return n?!n.mode&&!n.insertMode&&!n.visualMode?!0:n.mode==="normal":!1},Lx=function(e){e&&e.dispatch({selection:{anchor:0,head:e.state.doc.length}})};function Ky(e,n){if(!(n!=null&&n.length))return ca.none;let a=new Aw,o=e.facet(ua),s=n.filter(c=>c.kind==="cell"&&c.cellId===o).toSorted((c,f)=>c.lineNumber-f.lineNumber);for(let c of s)try{let f=e.doc.line(c.lineNumber),d=ca.line({class:"cm-error-line"});a.add(f.from,f.from,d)}catch(f){be.debug("Invalid line number in error decoration",{error:f})}return a.finish()}function Qy(e,n){if(!(n!=null&&n.length))return;let a=e.state.facet(ua),o=n.filter(f=>f.kind==="cell"&&f.cellId===a);if(o.length===0)return;let s=X6(e.state),c=[];for(let f of o)try{let d=e.state.doc.line(f.lineNumber);s.between(d.from,d.to,(m,b)=>{c.push(K6.of({from:m,to:b}))})}catch(d){be.debug("Invalid line numbers",{error:d})}c.length>0&&e.dispatch({effects:c})}var m3=class{constructor(e,n){let a=n.get();this.decorations=Ky(e.state,a),Qy(e,a),this.unsubscribe=n.sub(o=>{let s=this.decorations.size;this.decorations=Ky(e.state,o),Qy(e,o),s!==this.decorations.size&&e.dispatch({userEvent:"marimo.error-decoration-update"})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function g3(e){return Ui.define(n=>new m3(n,e),{decorations:n=>n.decorations})}function y3(e){return[g3(e),Et.theme({".cm-error-line":{backgroundColor:"color-mix(in srgb, var(--red-4) 40%, transparent)"},"&.cm-focused .cm-error-line.cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--red-6) 40%, transparent)"}})]}function v3({cellId:e,hotkeys:n}){let a=[];return a.push(...vw({key:n.getHotkey("cell.run").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).onRun(),!0)}),{key:n.getHotkey("cell.runAndNewBelow").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(ot);return s.onRun(),e==="__scratch__"||(o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!1})),!0}},...vw({key:n.getHotkey("cell.runAndNewAbove").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(ot);return s.onRun(),e==="__scratch__"||(o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!0})),!0}}),{key:n.getHotkey("cell.aiCompletion").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).aiCellCompletion()&&o.contentDOM.focus(),!0)}),e!=="__scratch__"&&a.push({key:n.getHotkey("cell.goToDefinition").key,preventDefault:!0,stopPropagation:!0,run:o=>(Um(o),!0)},{key:n.getHotkey("cell.delete").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.doc.length===0&&o.state.facet(ot).deleteCell(),!0)},{key:n.getHotkey("cell.moveUp").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveCell({cellId:e,before:!0}),!0)},{key:n.getHotkey("cell.moveDown").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveCell({cellId:e,before:!1}),!0)},{key:n.getHotkey("cell.moveLeft").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveCell({cellId:e,before:!0,direction:"left"}),!0)},{key:n.getHotkey("cell.moveRight").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveCell({cellId:e,before:!1,direction:"right"}),!0)},{key:"ArrowUp",preventDefault:!0,stopPropagation:!0,run:o=>Hw(o.state)?!1:Jm(o)?(o.state.facet(ot).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0):!1},{key:"ArrowDown",preventDefault:!0,stopPropagation:!0,run:o=>Hw(o.state)?!1:Vm(o)?(o.state.facet(ot).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0):!1},{key:n.getHotkey("cell.focusDown").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0)},{key:n.getHotkey("cell.focusUp").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0)},{key:n.getHotkey("cell.sendToBottom").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).sendToBottom({cellId:e}),!0)},{key:n.getHotkey("cell.sendToTop").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).sendToTop({cellId:e}),!0)},{key:n.getHotkey("cell.createAbove").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.contentDOM.blur(),o.state.facet(ot).createNewCell({cellId:e,before:!0}),!0)},{key:n.getHotkey("cell.createBelow").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.contentDOM.blur(),o.state.facet(ot).createNewCell({cellId:e,before:!1}),!0)},{key:n.getHotkey("cell.hideCode").key,preventDefault:!0,stopPropagation:!0,run:o=>{var c;let s=o.state.facet(ot).toggleHideCode();return $w(o),s?(o.contentDOM.blur(),(c=document.getElementById(En.create(e)))==null||c.focus()):o.contentDOM.focus(),!0}},{key:n.getHotkey("cell.splitCell").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(ot);return s.splitCell({cellId:e}),s.moveToNextCell&&requestAnimationFrame(()=>{o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!1})}),!0}}),[zu.high(Ja.of(a))]}function b3(e){return[Et.updateListener.of(n=>{if(n.docChanged){let a=n.transactions.some(f=>f.effects.some(d=>d.is(ys))),o=wr(n.view),s=n.view.state.facet(ot),c=n.view.state.facet(ua);s.updateCellCode({cellId:c,code:o,formattingChange:a})}}),vS(e)]}var w3=["input","delete","undo","redo"];function _3({docChanged:e,transactions:n,predicate:a=()=>!0,hasFocus:o=!1}){return!e||!a()||n.some(s=>s.effects.some(c=>c.is(ys)))?!1:n.some(s=>s.annotation(ni)===void 0?w3.some(c=>s.isUserEvent(c))||o:!1)}function x3({predicate:e}){return Et.updateListener.of(n=>{_3({docChanged:n.docChanged,transactions:n.transactions,predicate:e,hasFocus:n.view.hasFocus})&&n.view.state.facet(ot).onRun()})}Rx=function({cellId:e,hotkeys:n,cellActions:a}){return[ot.of(a),ua.of(e),v3({cellId:e,hotkeys:n}),b3(n),y3(mS(IT(e),ze))]};const Gy=async e=>{let n=e.state.doc.sliceString(0,e.pos),a=document.activeElement,o=null;if(a!==null){let f=En.findElement(a);f!==null&&(o=En.parse(f.id))}if(o===null)return be.error("Failed to find active cell."),null;let s=await sd.request({document:n,cellId:o});if(!s)return null;let c=lf.asHoverTooltip({position:e.pos,message:s,limitToType:"tooltip"});return c&&ze.set(id,{documentation:c.html??null}),c?null:lf.asCompletionResult(e.pos,s)};function k3(e){return n=>e.predicate(n.state)?e.completion(n):null}var C3=async e=>{let n=e.matchBefore(/:\w*$/);if(!e.explicit&&!n)return null;let a=await S3();return{from:(n==null?void 0:n.from)??e.pos,options:a,validFor:/^[\w:]*$/}},S3=nr(async()=>{let e=await fetch("https://unpkg.com/emojilib@3.0.11/dist/emoji-en-US.json").then(n=>{if(!n.ok)throw Error("Failed to fetch emoji list");return n.json()}).catch(()=>({}));return Object.entries(e).map(([n,a])=>({shortcode:a[0],label:a.map(o=>`:${o}`).join(" "),emoji:n,displayLabel:`${n} ${a[0].replaceAll("_"," ")}`,apply:n,type:"emoji"}))}),E3=async e=>{let n=e.matchBefore(/::[\w-:]*$/);if(!e.explicit&&!n)return null;let a=await T3();return{from:(n==null?void 0:n.from)??e.pos,options:a,validFor:/^[\w-:]*$/}},T3=nr(async()=>{let e=await fetch("https://unpkg.com/lucide-static@0.452.0/tags.json").then(a=>{if(!a.ok)throw Error("Failed to fetch Lucide icon list");return a.json()}).catch(()=>({})),n=a=>`https://cdn.jsdelivr.net/npm/lucide-static@0.452.0/icons/${a}.svg`;return Object.entries(e).map(([a,o])=>({label:`::${a}`,displayLabel:a,type:"lucide-icon",boost:10,apply:`::lucide:${a}::`,detail:o.join(", "),info:()=>{let s=document.createElement("img");return s.src=n(a),s.style.width="24px",s.style.height="24px",s}}))}),I3=e=>{let n=e.matchBefore(/\\\w*$/);return!e.explicit&&!n?null:{from:(n==null?void 0:n.from)??e.pos,options:L3(),validFor:/^[\w\\]*$/}},L3=nr(()=>[["alpha","\u03B1","Greek small letter alpha"],["beta","\u03B2","Greek small letter beta"],["gamma","\u03B3","Greek small letter gamma"],["delta","\u03B4","Greek small letter delta"],["epsilon","\u03B5","Greek small letter epsilon"],["zeta","\u03B6","Greek small letter zeta"],["eta","\u03B7","Greek small letter eta"],["theta","\u03B8","Greek small letter theta"],["iota","\u03B9","Greek small letter iota"],["kappa","\u03BA","Greek small letter kappa"],["lambda","\u03BB","Greek small letter lambda"],["mu","\u03BC","Greek small letter mu"],["nu","\u03BD","Greek small letter nu"],["xi","\u03BE","Greek small letter xi"],["omicron","\u03BF","Greek small letter omicron"],["pi","\u03C0","Greek small letter pi"],["rho","\u03C1","Greek small letter rho"],["sigma","\u03C3","Greek small letter sigma"],["tau","\u03C4","Greek small letter tau"],["upsilon","\u03C5","Greek small letter upsilon"],["phi","\u03C6","Greek small letter phi"],["chi","\u03C7","Greek small letter chi"],["psi","\u03C8","Greek small letter psi"],["omega","\u03C9","Greek small letter omega"],["Gamma","\u0393","Greek capital letter gamma"],["Delta","\u0394","Greek capital letter delta"],["Theta","\u0398","Greek capital letter theta"],["Lambda","\u039B","Greek capital letter lambda"],["Xi","\u039E","Greek capital letter xi"],["Pi","\u03A0","Greek capital letter pi"],["Sigma","\u03A3","Greek capital letter sigma"],["Phi","\u03A6","Greek capital letter phi"],["Psi","\u03A8","Greek capital letter psi"],["Omega","\u03A9","Greek capital letter omega"],["pm","\xB1","Plus-minus sign"],["mp","\u2213","Minus-plus sign"],["times","\xD7","Multiplication sign"],["div","\xF7","Division sign"],["cdot","\u22C5","Dot operator"],["ast","\u2217","Asterisk operator"],["star","\u22C6","Star operator"],["circ","\u2218","Ring operator"],["bullet","\u2022","Bullet"],["cap","\u2229","Intersection"],["cup","\u222A","Union"],["uplus","\u228E","Multiset union"],["sqcap","\u2293","Square cap"],["sqcup","\u2294","Square cup"],["vee","\u2228","Logical or"],["wedge","\u2227","Logical and"],["setminus","\u2216","Set minus"],["oplus","\u2295","Circled plus"],["ominus","\u2296","Circled minus"],["otimes","\u2297","Circled times"],["oslash","\u2298","Circled division slash"],["odot","\u2299","Circled dot operator"],["leq","\u2264","Less than or equal to"],["geq","\u2265","Greater than or equal to"],["equiv","\u2261","Identical to"],["prec","\u227A","Precedes"],["succ","\u227B","Succeeds"],["sim","\u223C","Tilde operator"],["perp","\u22A5","Up tack"],["mid","\u2223","Divides"],["parallel","\u2225","Parallel to"],["subset","\u2282","Subset of"],["supset","\u2283","Superset of"],["subseteq","\u2286","Subset of or equal to"],["supseteq","\u2287","Superset of or equal to"],["cong","\u2245","Approximately equal to"],["approx","\u2248","Almost equal to"],["neq","\u2260","Not equal to"],["ne","\u2260","Not equal to"],["propto","\u221D","Proportional to"],["leftarrow","\u2190","Leftward arrow"],["rightarrow","\u2192","Rightward arrow"],["Leftarrow","\u21D0","Leftward double arrow"],["Rightarrow","\u21D2","Rightward double arrow"],["leftrightarrow","\u2194","Left right arrow"],["Leftrightarrow","\u21D4","Left right double arrow"],["uparrow","\u2191","Upward arrow"],["downarrow","\u2193","Downward arrow"],["Uparrow","\u21D1","Upward double arrow"],["Downarrow","\u21D3","Downward double arrow"],["infty","\u221E","Infinity"],["nabla","\u2207","Nabla"],["partial","\u2202","Partial differential"],["forall","\u2200","For all"],["exists","\u2203","There exists"],["nexists","\u2204","There does not exist"],["emptyset","\u2205","Empty set"],["in","\u2208","Element of"],["notin","\u2209","Not an element of"],["sum","\u2211","N-ary summation"],["prod","\u220F","N-ary product"],["int","\u222B","Integral"],["oint","\u222E","Contour integral"],["sqrt","\u221A","Square root"],["hbar","\u210F","Planck constant over 2pi"],["ldots","\u2026","Horizontal ellipsis"],["cdots","\u22EF","Midline horizontal ellipsis"],["vdots","\u22EE","Vertical ellipsis"],["ddots","\u22F1","Down right diagonal ellipsis"]].map(([e,n,a])=>({label:`\\${e} ${a}`,displayLabel:e,type:"latex-symbol",boost:10,apply:`\\${e}`,info:()=>{let o=document.createElement("div");return o.textContent=`${n} ${a}`,o},detail:n})));const O3=[C3,E3,I3];var A3=100;function so(e){return!e.state.selection.main.empty}function ff({view:e,selection:n,markup:a}){let o=[],s=!0;for(let c=n.from;c<=n.to;c++)if(!e.state.doc.lineAt(c).text.startsWith(a)){s=!1;break}for(let c=n.from;c<=n.to;){let f=e.state.doc.lineAt(c),d=f.text.startsWith(a);s?o.push({from:f.from,to:f.from+a.length,insert:Wi.of([""])}):(d&&o.push({from:f.from,to:f.from+a.length,insert:Wi.of([""])}),o.push({from:f.from,insert:Wi.of([a])})),c=f.to+1}return o}function pf({view:e,range:n,markupAfter:a,markupBefore:o}){if(n.empty){let b=e.state.wordAt(n.head);b&&(n=b)}let s=e.state.sliceDoc(n.from-o.length,n.from)===o,c=e.state.sliceDoc(n.to,n.to+a.length)===a,f=[];f.push(s?{from:n.from-o.length,to:n.from,insert:Wi.of([""])}:{from:n.from,insert:Wi.of(o.split(`
97
+ `||E=="\r")E="\xA0";else if(E==" "){E="\xA0";var b=n.coordsAtPos(c+1,-1);b&&(M=b.left-(b.left-L.left)/parseInt(B.tabSize))}else/[\uD800-\uDBFF]/.test(E)&&c<n.state.doc.length-1&&(E+=n.state.sliceDoc(c+1,c+2));let le=L.bottom-L.top;return new a3((M-P.left)/n.scaleX,(L.top-P.top+le*(1-d))/n.scaleY,le*d/n.scaleY,B.fontFamily,B.fontSize,B.fontWeight,B.color,o?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",E,d!=1)}else return null}let Vy,Hy,$y,Wy;Vy=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent),fa=KS(Ve),Hy=250,$y=Et.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:"none"},".cm-vim-panel":{padding:"0px 10px",fontFamily:"monospace",minHeight:"1.3em",display:"flex"},".cm-vim-panel input":{border:"none",outline:"none",backgroundColor:"inherit"},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"}}),Wy=Ui.fromClass(class{constructor(e){this.status="",this.query=null,this.decorations=ca.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=e;let n=this.cm=new Ve(e);fa.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new i3(e,n),this.updateClass(),this.cm.on("vim-command-done",()=>{n.state.vim&&(n.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",a=>{n.state.vim&&(n.state.vim.mode=a.mode,a.subMode&&(n.state.vim.mode+=" block"),n.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():e.dispatch({effects:Uy.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.spacer=document.createElement("span"),this.spacer.style.flex="1",this.statusButton=document.createElement("span"),this.statusButton.onclick=a=>{fa.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(e){var n;if((e.viewportChanged||e.docChanged)&&this.query&&this.highlight(this.query),e.docChanged&&this.cm.onChange(e),e.selectionSet&&this.cm.onSelectionChange(),e.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),e.transactions){for(let a of e.transactions)for(let o of a.effects)if(o.is(Bh))if(!((n=o.value)!=null&&n.forVim))this.highlight(null);else{let s=o.value.create();this.highlight(s)}}this.blockCursor.update(e)}updateClass(){let e=this.cm.state;!e.vim||e.vim.insertMode&&!e.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let e=this.cm.state.statusbar,n=this.cm.state.vim;if(!e||!n)return;let a=this.cm.state.dialog;if(a)a.parentElement!=e&&(e.textContent="",e.appendChild(a));else{e.textContent="";var o=(n.mode||"normal").toUpperCase();n.insertModeReturn&&(o+="(C-O)"),this.statusButton.textContent=`--${o}--`,e.appendChild(this.statusButton),e.appendChild(this.spacer)}this.dom.textContent=n.status,e.appendChild(this.dom)}destroy(){fa.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(e){if(this.query=e,!e)return this.decorations=ca.none;let{view:n}=this,a=new Aw;for(let o=0,s=n.visibleRanges,c=s.length;o<c;o++){let{from:f,to:d}=s[o];for(;o<c-1&&d>s[o+1].from-2*Hy;)d=s[++o].to;e.highlight(n.state,f,d,(m,b)=>{a.add(m,b,d3)})}return this.decorations=a.finish()}handleKey(e,n){let a=this.cm,o=a.state.vim;if(!o)return;let s=fa.vimKeyFromEvent(e,o);if(Ve.signal(this.cm,"inputEvent",{type:"handleKey",key:s}),!s)return;if(s=="<Esc>"&&!o.insertMode&&!o.visualMode&&this.query){let f=o.searchState_;f&&(a.removeOverlay(f.getOverlay()),f.setOverlay(null))}if(s==="<C-c>"&&!Ve.isMac&&a.somethingSelected())return this.waitForCopy=!0,!0;o.status=(o.status||"")+s;let c=fa.multiSelectHandleKey(a,s,"user");return o=fa.maybeInitVimState_(a),!c&&o.insertMode&&a.state.overwrite&&(e.key&&e.key.length==1&&!/\n/.test(e.key)?(c=!0,a.overWriteSelection(e.key)):e.key=="Backspace"&&(c=!0,Ve.commands.cursorCharLeft(a))),c&&(Ve.signal(this.cm,"vim-keypress",s),e.preventDefault(),e.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!c}},{eventHandlers:{copy:function(e,n){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var a=this.cm,o=a.state.vim;o&&(o.insertMode?a.setSelection(a.getCursor(),a.getCursor()):a.operation(()=>{a.curOp&&(a.curOp.isVimOp=!0),fa.handleKey(a,"<Esc>","user")}))}))},compositionstart:function(e,n){this.useNextTextInput=!0,Ve.signal(this.cm,"inputEvent",e)},compositionupdate:function(e,n){Ve.signal(this.cm,"inputEvent",e)},compositionend:function(e,n){Ve.signal(this.cm,"inputEvent",e)},keypress:function(e,n){Ve.signal(this.cm,"inputEvent",e),this.lastKeydown=="Dead"&&this.handleKey(e,n)},keydown:function(e,n){Ve.signal(this.cm,"inputEvent",e),this.lastKeydown=e.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(e,n))}},provide:()=>[Et.inputHandler.of((e,n,a,o)=>{var _,x;var s=zl(e);if(!s)return!1;var c=(_=s.state)==null?void 0:_.vim,f=s.state.vimPlugin;if(c&&!c.insertMode&&!((x=s.curOp)!=null&&x.isVimOp)){if(o==="\0\0")return!0;if(Ve.signal(s,"inputEvent",{type:"text",text:o,from:n,to:a}),o.length==1&&f.useNextTextInput){if(c.expectLiteralNext&&e.composing)return f.compositionText=o,!1;if(f.compositionText){var d=f.compositionText;f.compositionText="";var m=e.state.selection.main.head;if(d===e.state.sliceDoc(m-d.length,m)){var b=s.getCursor();s.replaceRange("",s.posFromIndex(m-d.length),b)}}return f.handleKey({key:o,preventDefault:()=>{},stopPropagation:()=>{}}),u3(e),!0}}return!1})],decorations:e=>e.decorations});function u3(e){var n=e.scrollDOM.parentElement;if(n){if(Vy){e.contentDOM.textContent="\0\0",e.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var a=e.scrollDOM.nextSibling,o=window.getSelection(),s=o&&{anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset};e.scrollDOM.remove(),n.insertBefore(e.scrollDOM,a);try{s&&o&&(o.setPosition(s.anchorNode,s.anchorOffset),s.focusNode&&o.extend(s.focusNode,s.focusOffset))}catch(c){console.error(c)}e.focus(),e.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}var d3=ca.mark({class:"cm-searchMatch"}),Uy=la.define(),f3=is.define({create:()=>!1,update(e,n){for(let a of n.effects)a.is(Uy)&&(e=a.value);return e},provide:e=>qh.from(e,n=>n?p3:null)});function p3(e){let n=document.createElement("div");n.className="cm-vim-panel";let a=e.cm;return a.state.dialog&&n.appendChild(a.state.dialog),{top:!1,dom:n}}function h3(e){let n=document.createElement("div");n.className="cm-vim-panel";let a=e.cm;return a.state.statusbar=n,a.state.vimPlugin.updateStatus(),{dom:n}}Px=function(e={}){return[$y,Wy,s3,e.status?qh.of(h3):f3]},zl=function(e){return e.cm||null},Jm=function(e){let n=e.state.selection.main;return n.from===0&&n.to===0},Vm=function(e,n=!1){let a=e.state.selection.main,o=e.state.doc.length;return n&&a.from===o-1&&a.to===o-1?!0:a.from===o&&a.to===o},xx=function(e){e&&e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length}})},dx=function(e){var n;return((n=zl(e))==null?void 0:n.state.vim)!=null},G_=function(e){var a;let n=(a=zl(e))==null?void 0:a.state.vim;return n?!n.mode&&!n.insertMode&&!n.visualMode?!0:n.mode==="normal":!1},Lx=function(e){e&&e.dispatch({selection:{anchor:0,head:e.state.doc.length}})};function Ky(e,n){if(!(n!=null&&n.length))return ca.none;let a=new Aw,o=e.facet(ua),s=n.filter(c=>c.kind==="cell"&&c.cellId===o).toSorted((c,f)=>c.lineNumber-f.lineNumber);for(let c of s)try{let f=e.doc.line(c.lineNumber),d=ca.line({class:"cm-error-line"});a.add(f.from,f.from,d)}catch(f){be.debug("Invalid line number in error decoration",{error:f})}return a.finish()}function Qy(e,n){if(!(n!=null&&n.length))return;let a=e.state.facet(ua),o=n.filter(f=>f.kind==="cell"&&f.cellId===a);if(o.length===0)return;let s=X6(e.state),c=[];for(let f of o)try{let d=e.state.doc.line(f.lineNumber);s.between(d.from,d.to,(m,b)=>{c.push(K6.of({from:m,to:b}))})}catch(d){be.debug("Invalid line numbers",{error:d})}c.length>0&&e.dispatch({effects:c})}var m3=class{constructor(e,n){let a=n.get();this.decorations=Ky(e.state,a),Qy(e,a),this.unsubscribe=n.sub(o=>{let s=this.decorations.size;this.decorations=Ky(e.state,o),Qy(e,o),s!==this.decorations.size&&e.dispatch({userEvent:"marimo.error-decoration-update"})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function g3(e){return Ui.define(n=>new m3(n,e),{decorations:n=>n.decorations})}function y3(e){return[g3(e),Et.theme({".cm-error-line":{backgroundColor:"color-mix(in srgb, var(--red-4) 40%, transparent)"},"&.cm-focused .cm-error-line.cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--red-6) 40%, transparent)"}})]}function v3({cellId:e,hotkeys:n}){let a=[];return a.push(...vw({key:n.getHotkey("cell.run").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).onRun(),!0)}),{key:n.getHotkey("cell.runAndNewBelow").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(ot);return s.onRun(),e==="__scratch__"||(o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!1})),!0}},...vw({key:n.getHotkey("cell.runAndNewAbove").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(ot);return s.onRun(),e==="__scratch__"||(o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!0})),!0}}),{key:n.getHotkey("cell.aiCompletion").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).aiCellCompletion()&&o.contentDOM.focus(),!0)}),e!=="__scratch__"&&a.push({key:n.getHotkey("cell.goToDefinition").key,preventDefault:!0,stopPropagation:!0,run:o=>(Um(o),!0)},{key:n.getHotkey("cell.delete").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.doc.length===0&&o.state.facet(ot).deleteCell(),!0)},{key:n.getHotkey("cell.moveUp").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveCell({cellId:e,before:!0}),!0)},{key:n.getHotkey("cell.moveDown").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveCell({cellId:e,before:!1}),!0)},{key:n.getHotkey("cell.moveLeft").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveCell({cellId:e,before:!0,direction:"left"}),!0)},{key:n.getHotkey("cell.moveRight").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveCell({cellId:e,before:!1,direction:"right"}),!0)},{key:"ArrowUp",run:o=>Hw(o.state)?!1:Jm(o)?(o.state.facet(ot).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0):!1},{key:"ArrowDown",run:o=>Hw(o.state)?!1:Vm(o)?(o.state.facet(ot).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0):!1},{key:n.getHotkey("cell.focusDown").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0)},{key:n.getHotkey("cell.focusUp").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0)},{key:n.getHotkey("cell.sendToBottom").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).sendToBottom({cellId:e}),!0)},{key:n.getHotkey("cell.sendToTop").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(ot).sendToTop({cellId:e}),!0)},{key:n.getHotkey("cell.createAbove").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.contentDOM.blur(),o.state.facet(ot).createNewCell({cellId:e,before:!0}),!0)},{key:n.getHotkey("cell.createBelow").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.contentDOM.blur(),o.state.facet(ot).createNewCell({cellId:e,before:!1}),!0)},{key:n.getHotkey("cell.hideCode").key,preventDefault:!0,stopPropagation:!0,run:o=>{var c;let s=o.state.facet(ot).toggleHideCode();return $w(o),s?(o.contentDOM.blur(),(c=document.getElementById(En.create(e)))==null||c.focus()):o.contentDOM.focus(),!0}},{key:n.getHotkey("cell.splitCell").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(ot);return s.splitCell({cellId:e}),s.moveToNextCell&&requestAnimationFrame(()=>{o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!1})}),!0}}),[zu.high(Ja.of(a))]}function b3(e){return[Et.updateListener.of(n=>{if(n.docChanged){let a=n.transactions.some(f=>f.effects.some(d=>d.is(ys))),o=wr(n.view),s=n.view.state.facet(ot),c=n.view.state.facet(ua);s.updateCellCode({cellId:c,code:o,formattingChange:a})}}),vS(e)]}var w3=["input","delete","undo","redo"];function _3({docChanged:e,transactions:n,predicate:a=()=>!0,hasFocus:o=!1}){return!e||!a()||n.some(s=>s.effects.some(c=>c.is(ys)))?!1:n.some(s=>s.annotation(ni)===void 0?w3.some(c=>s.isUserEvent(c))||o:!1)}function x3({predicate:e}){return Et.updateListener.of(n=>{_3({docChanged:n.docChanged,transactions:n.transactions,predicate:e,hasFocus:n.view.hasFocus})&&n.view.state.facet(ot).onRun()})}Rx=function({cellId:e,hotkeys:n,cellActions:a}){return[ot.of(a),ua.of(e),v3({cellId:e,hotkeys:n}),b3(n),y3(mS(IT(e),ze))]};const Gy=async e=>{let n=e.state.doc.sliceString(0,e.pos),a=document.activeElement,o=null;if(a!==null){let f=En.findElement(a);f!==null&&(o=En.parse(f.id))}if(o===null)return be.error("Failed to find active cell."),null;let s=await sd.request({document:n,cellId:o});if(!s)return null;let c=lf.asHoverTooltip({position:e.pos,message:s,limitToType:"tooltip"});return c&&ze.set(id,{documentation:c.html??null}),c?null:lf.asCompletionResult(e.pos,s)};function k3(e){return n=>e.predicate(n.state)?e.completion(n):null}var C3=async e=>{let n=e.matchBefore(/:\w*$/);if(!e.explicit&&!n)return null;let a=await S3();return{from:(n==null?void 0:n.from)??e.pos,options:a,validFor:/^[\w:]*$/}},S3=nr(async()=>{let e=await fetch("https://unpkg.com/emojilib@3.0.11/dist/emoji-en-US.json").then(n=>{if(!n.ok)throw Error("Failed to fetch emoji list");return n.json()}).catch(()=>({}));return Object.entries(e).map(([n,a])=>({shortcode:a[0],label:a.map(o=>`:${o}`).join(" "),emoji:n,displayLabel:`${n} ${a[0].replaceAll("_"," ")}`,apply:n,type:"emoji"}))}),E3=async e=>{let n=e.matchBefore(/::[\w-:]*$/);if(!e.explicit&&!n)return null;let a=await T3();return{from:(n==null?void 0:n.from)??e.pos,options:a,validFor:/^[\w-:]*$/}},T3=nr(async()=>{let e=await fetch("https://unpkg.com/lucide-static@0.452.0/tags.json").then(a=>{if(!a.ok)throw Error("Failed to fetch Lucide icon list");return a.json()}).catch(()=>({})),n=a=>`https://cdn.jsdelivr.net/npm/lucide-static@0.452.0/icons/${a}.svg`;return Object.entries(e).map(([a,o])=>({label:`::${a}`,displayLabel:a,type:"lucide-icon",boost:10,apply:`::lucide:${a}::`,detail:o.join(", "),info:()=>{let s=document.createElement("img");return s.src=n(a),s.style.width="24px",s.style.height="24px",s}}))}),I3=e=>{let n=e.matchBefore(/\\\w*$/);return!e.explicit&&!n?null:{from:(n==null?void 0:n.from)??e.pos,options:L3(),validFor:/^[\w\\]*$/}},L3=nr(()=>[["alpha","\u03B1","Greek small letter alpha"],["beta","\u03B2","Greek small letter beta"],["gamma","\u03B3","Greek small letter gamma"],["delta","\u03B4","Greek small letter delta"],["epsilon","\u03B5","Greek small letter epsilon"],["zeta","\u03B6","Greek small letter zeta"],["eta","\u03B7","Greek small letter eta"],["theta","\u03B8","Greek small letter theta"],["iota","\u03B9","Greek small letter iota"],["kappa","\u03BA","Greek small letter kappa"],["lambda","\u03BB","Greek small letter lambda"],["mu","\u03BC","Greek small letter mu"],["nu","\u03BD","Greek small letter nu"],["xi","\u03BE","Greek small letter xi"],["omicron","\u03BF","Greek small letter omicron"],["pi","\u03C0","Greek small letter pi"],["rho","\u03C1","Greek small letter rho"],["sigma","\u03C3","Greek small letter sigma"],["tau","\u03C4","Greek small letter tau"],["upsilon","\u03C5","Greek small letter upsilon"],["phi","\u03C6","Greek small letter phi"],["chi","\u03C7","Greek small letter chi"],["psi","\u03C8","Greek small letter psi"],["omega","\u03C9","Greek small letter omega"],["Gamma","\u0393","Greek capital letter gamma"],["Delta","\u0394","Greek capital letter delta"],["Theta","\u0398","Greek capital letter theta"],["Lambda","\u039B","Greek capital letter lambda"],["Xi","\u039E","Greek capital letter xi"],["Pi","\u03A0","Greek capital letter pi"],["Sigma","\u03A3","Greek capital letter sigma"],["Phi","\u03A6","Greek capital letter phi"],["Psi","\u03A8","Greek capital letter psi"],["Omega","\u03A9","Greek capital letter omega"],["pm","\xB1","Plus-minus sign"],["mp","\u2213","Minus-plus sign"],["times","\xD7","Multiplication sign"],["div","\xF7","Division sign"],["cdot","\u22C5","Dot operator"],["ast","\u2217","Asterisk operator"],["star","\u22C6","Star operator"],["circ","\u2218","Ring operator"],["bullet","\u2022","Bullet"],["cap","\u2229","Intersection"],["cup","\u222A","Union"],["uplus","\u228E","Multiset union"],["sqcap","\u2293","Square cap"],["sqcup","\u2294","Square cup"],["vee","\u2228","Logical or"],["wedge","\u2227","Logical and"],["setminus","\u2216","Set minus"],["oplus","\u2295","Circled plus"],["ominus","\u2296","Circled minus"],["otimes","\u2297","Circled times"],["oslash","\u2298","Circled division slash"],["odot","\u2299","Circled dot operator"],["leq","\u2264","Less than or equal to"],["geq","\u2265","Greater than or equal to"],["equiv","\u2261","Identical to"],["prec","\u227A","Precedes"],["succ","\u227B","Succeeds"],["sim","\u223C","Tilde operator"],["perp","\u22A5","Up tack"],["mid","\u2223","Divides"],["parallel","\u2225","Parallel to"],["subset","\u2282","Subset of"],["supset","\u2283","Superset of"],["subseteq","\u2286","Subset of or equal to"],["supseteq","\u2287","Superset of or equal to"],["cong","\u2245","Approximately equal to"],["approx","\u2248","Almost equal to"],["neq","\u2260","Not equal to"],["ne","\u2260","Not equal to"],["propto","\u221D","Proportional to"],["leftarrow","\u2190","Leftward arrow"],["rightarrow","\u2192","Rightward arrow"],["Leftarrow","\u21D0","Leftward double arrow"],["Rightarrow","\u21D2","Rightward double arrow"],["leftrightarrow","\u2194","Left right arrow"],["Leftrightarrow","\u21D4","Left right double arrow"],["uparrow","\u2191","Upward arrow"],["downarrow","\u2193","Downward arrow"],["Uparrow","\u21D1","Upward double arrow"],["Downarrow","\u21D3","Downward double arrow"],["infty","\u221E","Infinity"],["nabla","\u2207","Nabla"],["partial","\u2202","Partial differential"],["forall","\u2200","For all"],["exists","\u2203","There exists"],["nexists","\u2204","There does not exist"],["emptyset","\u2205","Empty set"],["in","\u2208","Element of"],["notin","\u2209","Not an element of"],["sum","\u2211","N-ary summation"],["prod","\u220F","N-ary product"],["int","\u222B","Integral"],["oint","\u222E","Contour integral"],["sqrt","\u221A","Square root"],["hbar","\u210F","Planck constant over 2pi"],["ldots","\u2026","Horizontal ellipsis"],["cdots","\u22EF","Midline horizontal ellipsis"],["vdots","\u22EE","Vertical ellipsis"],["ddots","\u22F1","Down right diagonal ellipsis"]].map(([e,n,a])=>({label:`\\${e} ${a}`,displayLabel:e,type:"latex-symbol",boost:10,apply:`\\${e}`,info:()=>{let o=document.createElement("div");return o.textContent=`${n} ${a}`,o},detail:n})));const O3=[C3,E3,I3];var A3=100;function so(e){return!e.state.selection.main.empty}function ff({view:e,selection:n,markup:a}){let o=[],s=!0;for(let c=n.from;c<=n.to;c++)if(!e.state.doc.lineAt(c).text.startsWith(a)){s=!1;break}for(let c=n.from;c<=n.to;){let f=e.state.doc.lineAt(c),d=f.text.startsWith(a);s?o.push({from:f.from,to:f.from+a.length,insert:Wi.of([""])}):(d&&o.push({from:f.from,to:f.from+a.length,insert:Wi.of([""])}),o.push({from:f.from,insert:Wi.of([a])})),c=f.to+1}return o}function pf({view:e,range:n,markupAfter:a,markupBefore:o}){if(n.empty){let b=e.state.wordAt(n.head);b&&(n=b)}let s=e.state.sliceDoc(n.from-o.length,n.from)===o,c=e.state.sliceDoc(n.to,n.to+a.length)===a,f=[];f.push(s?{from:n.from-o.length,to:n.from,insert:Wi.of([""])}:{from:n.from,insert:Wi.of(o.split(`
98
98
  `))},c?{from:n.to,to:n.to+a.length,insert:Wi.of([""])}:{from:n.to,insert:Wi.of(a.split(`
99
99
  `))});let d=s?-o.length:o.length,m=c?-a.length:a.length;return{changes:f,range:$t.range(n.from+d,n.to+m)}}function R3(e){if(!so(e))return!1;let n=ff({view:e,selection:e.state.selection.main,markup:"> "});return n.length>0&&e.dispatch(e.state.update({changes:n,scrollIntoView:!0,userEvent:"input"})),e.focus(),!0}function P3(e){if(!so(e))return!1;let n=e.state.changeByRange(a=>{if(a.empty){let o=e.state.wordAt(a.head);o&&(a=o)}return pf({view:e,range:a,markupBefore:"**",markupAfter:"**"})});return e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:os.userEvent.of("input")})),e.focus(),!0}function Jy(e){if(!so(e))return!1;let n=e.state.changeByRange(a=>{if(a.empty){let s=e.state.wordAt(a.head);s&&(a=s)}let o=e.state.doc.lineAt(a.from).number!==e.state.doc.lineAt(a.to).number;return pf({view:e,range:a,markupBefore:o?"```\n":"`",markupAfter:o?"\n```":"`"})});return e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:os.userEvent.of("input")})),e.focus(),!0}function N3(e){let n=e.state.changeByRange(a=>{if(a.empty){let o=e.state.wordAt(a.head);o&&(a=o)}return pf({view:e,range:a,markupBefore:"_",markupAfter:"_"})});return e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:os.userEvent.of("input")})),e.focus(),!0}function Xy(e,n="http://"){if(!so(e))return!1;let a=e.state.changeByRange(s=>{let c=e.state.sliceDoc(s.from,s.to);return{changes:[{from:s.from,to:s.to,insert:`[${c}](${n})`}],range:s}});e.dispatch(e.state.update(a,{scrollIntoView:!0,annotations:os.userEvent.of("input")}));let{to:o}=a.selection.main;try{e.dispatch({selection:$t.create([$t.range(o+3,o+3+n.length),$t.cursor(o+3+n.length)])})}catch{}return e.focus(),!0}Xh=async function(e,n){var d;let a=new FileReader,o=await new Promise(m=>{a.onload=()=>m(a.result),a.readAsDataURL(n)}),s;try{if(o.startsWith("data:")){let m=o.split(",")[1],b=prompt("We can save your image as a file. Enter a filename.",n.name),_=n.type.split("/")[1];if(b===null){let x=Math.round(o.length/1024);if(x>A3){El({title:"Content too large",description:`The content size is ${x} KB, which is too large to paste directly into the document.`});return}}else{b.trim()===""?b=n.name:b.endsWith(`.${_}`)||(b=`${b}.${_}`);let x=ze.get(us),S=x?Jw.dirname(x):null,E=S?`${S}/public`:"public",L=await br().sendCreateFileOrFolder({path:E,type:"file",name:b,contents:m});L.success?(s=(d=L.info)==null?void 0:d.path,s&&S&&s.startsWith(S)&&(s=Jw.rest(s,S)),El({title:"Image uploaded successfully",description:`We've uploaded your image at ${s}`})):El({title:"Failed to upload image. Using raw base64 string."})}}}catch{El({title:"Failed to upload image. Using raw base64 string."})}let c=e.state.changeByRange(m=>{let b=e.state.sliceDoc(m.from,m.to);return b.trim()===""&&(b="alt"),{changes:[{from:m.from,to:m.to,insert:`![${b}](${s??o})`}],range:m}});e.dispatch(e.state.update(c,{scrollIntoView:!0,annotations:os.userEvent.of("input")}));let{to:f}=c.selection.main;try{e.dispatch({selection:$t.create([$t.range(f+4,f+4+o.length),$t.cursor(f+4+o.length)])})}catch{}return e.focus(),!0},Lm=async function(e,n){let a=await n.text(),o=e.state.changeByRange(s=>({changes:[{from:s.from,to:s.from,insert:a}],range:s}));return e.dispatch(e.state.update(o,{scrollIntoView:!0,annotations:os.userEvent.of("input")})),e.focus(),!0};function M3(e){if(!so(e))return!1;let{changes:n}=e.state.changeByRange(a=>({range:a,changes:ff({view:e,selection:a,markup:e.state.sliceDoc(a.from,a.to+2).startsWith("* ")?"* ":"- "})}));return n.length>0&&e.dispatch(e.state.update({changes:n,scrollIntoView:!0,userEvent:"input"})),e.focus(),!0}function D3(e){if(!so(e))return!1;let{changes:n}=e.state.changeByRange(a=>({range:a,changes:ff({view:e,selection:a,markup:"1. "})}));return n.length>0&&e.dispatch(e.state.update({changes:n,scrollIntoView:!0,userEvent:"input"})),e.focus(),!0}function j3(e){return[zu.highest(Ja.of([{key:e.getHotkey("markdown.bold").key,stopPropagation:!0,run:P3},{key:e.getHotkey("markdown.italic").key,stopPropagation:!0,run:N3},{key:e.getHotkey("markdown.link").key,stopPropagation:!0,run:n=>Xy(n)},{key:e.getHotkey("markdown.orderedList").key,run:D3},{key:e.getHotkey("markdown.unorderedList").key,run:M3},{key:e.getHotkey("markdown.blockquote").key,run:R3},{key:e.getHotkey("markdown.code").key,run:Jy},{key:"`",run:Jy}])),Et.domEventHandlers({paste:(n,a)=>{var s;if(a.state.selection.main.empty)return!1;let o=(s=n.clipboardData)==null?void 0:s.getData("text/plain");o!=null&&o.startsWith("http")&&(n.preventDefault(),Xy(a,o))}}),Et.domEventHandlers({paste:(n,a)=>{var s;let o=(s=n.clipboardData)==null?void 0:s.files[0];if(!o)return!1;if(o.type.startsWith("image/"))return n.preventDefault(),Xh(a,o),!0;if(o.type.startsWith("text/"))return n.preventDefault(),Lm(a,o),!0}})]}function z3(e,n,a=3,o=""){return Object.values(e).flatMap(s=>n.has(s.name)?[]:{label:`${o}${s.name}`,displayLabel:s.name,detail:s.dataType??"",boost:a,type:"variable",apply:`${o}${s.name}`,section:"Variable",info:()=>fm(s)})}fm=function(e){let n=document.createElement("div");n.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let a=document.createElement("div");a.classList.add("flex","items-center","gap-2");let o=document.createElement("span");if(o.classList.add("font-bold","text-base"),o.textContent=e.name,a.append(o),e.dataType){let s=document.createElement("span");s.classList.add("text-xs","px-1.5","py-0.5","rounded-full","bg-purple-100","text-purple-800","dark:bg-purple-900","dark:text-purple-200"),s.textContent=e.dataType,a.append(s)}if(n.append(a),e.value){let s=document.createElement("div");s.classList.add("flex","flex-col","gap-1");let c=document.createElement("div");c.classList.add("text-xs","text-muted-foreground"),c.textContent="Value:",s.append(c);let f=document.createElement("div");f.classList.add("text-xs","font-mono","bg-muted","p-2","rounded","overflow-auto","max-h-40"),f.textContent=e.value,s.append(f),n.append(s)}return n};var lo="Python",hf=123,Yy=125,mf=1,q3={mark:`${lo}Mark`,resolve:lo};function F3(e,n){return{defineNodes:[{name:lo,style:ju.emphasis},{name:`${lo}Mark`,style:ju.processingInstruction}],parseInline:[{name:lo,parse(a,o,s){return!n()||o!==hf&&o!==Yy||o===hf&&a.slice(s-1,s)==="{"?-1:a.addDelimiter(q3,s,s+mf,o===hf,o===Yy)}}],wrap:Dw(a=>{if(!n()||a.type.name!==lo)return null;let o=a.from+mf,s=a.to-mf;return o>=s||o<0||s<0?null:{parser:e,overlay:[{from:o,to:s}],extensions:[Gw().support]}})}}const B3=e=>{let n=e.state.doc.sliceString(0,e.pos),a=n.lastIndexOf("{");if(n.at(a-1)==="{"||a===-1||n.indexOf("}",a)>a)return null;let o=e.matchBefore(/\w*$/);if(!o)return null;let s=z3(ze.get(Za),new Set,99);return{from:o.from,options:s,validFor:/^\w*$/}};var Yl="InlineMathDollar",co="InlineMathBracket",Zl="BlockMathDollar",uo="BlockMathBracket",ci={[Yl]:1,[co]:3,[Zl]:2,[uo]:3},pt={DOLLAR:36,BACKSLASH:92,OPEN_PAREN:40,CLOSE_PAREN:41,OPEN_BRACKET:91,CLOSE_BRACKET:93},fo=Object.keys(ci).reduce((e,n)=>(e[n]={mark:`${n}Mark`,resolve:n},e),{});function V3(e){let n=[];return Object.keys(ci).forEach(a=>{n.push({name:a,style:ju.emphasis},{name:`${a}Mark`,style:ju.processingInstruction})}),{defineNodes:n,parseInline:[{name:Zl,parse(a,o,s){return o!==pt.DOLLAR||a.char(s+1)!==pt.DOLLAR?-1:a.addDelimiter(fo[Zl],s,s+ci[Zl],!0,!0)}},{name:Yl,parse(a,o,s){return o!==pt.DOLLAR||a.char(s+1)===pt.DOLLAR?-1:a.addDelimiter(fo[Yl],s,s+ci[Yl],!0,!0)}},{name:co,before:"Escape",parse(a,o,s){return o!==pt.BACKSLASH||a.char(s+1)!==pt.BACKSLASH||![pt.OPEN_PAREN,pt.CLOSE_PAREN].includes(a.char(s+2))?-1:a.addDelimiter(fo[co],s,s+ci[co],a.char(s+2)===pt.OPEN_PAREN,a.char(s+2)===pt.CLOSE_PAREN)}},{name:uo,before:"Escape",parse(a,o,s){return o!==pt.BACKSLASH||a.char(s+1)!==pt.BACKSLASH||![pt.OPEN_BRACKET,pt.CLOSE_BRACKET].includes(a.char(s+2))?-1:a.addDelimiter(fo[uo],s,s+ci[uo],a.char(s+2)===pt.OPEN_BRACKET,a.char(s+2)===pt.CLOSE_BRACKET)}},{name:co,before:"Escape",parse(a,o,s){return o!==pt.BACKSLASH||![pt.OPEN_PAREN,pt.CLOSE_PAREN].includes(a.char(s+1))?-1:a.addDelimiter(fo[co],s,s+2,a.char(s+1)===pt.OPEN_PAREN,a.char(s+1)===pt.CLOSE_PAREN)}},{name:uo,before:"Escape",parse(a,o,s){return o!==pt.BACKSLASH||![pt.OPEN_BRACKET,pt.CLOSE_BRACKET].includes(a.char(s+1))?-1:a.addDelimiter(fo[uo],s,s+2,a.char(s+1)===pt.OPEN_BRACKET,a.char(s+1)===pt.CLOSE_BRACKET)}}],wrap:Dw(a=>{let o=ci[a.type.name];if(o){let s=a.from+o,c=a.to-o;return s>=c||s<0||c<0?null:{parser:e,overlay:[{from:s,to:c}]}}return null})}}td=la.define(),rd=la.define(),Nr=is.define({create:()=>({}),update:(e,n)=>{for(let a of n.effects){if(a.is(td))return a.value;if(a.is(rd))return{...e,...a.value}}return e}}),Sx=!0,Ku=class{constructor(){ve(this,"parser",new Wu);ve(this,"type","markdown");ve(this,"defaultCode",this.parser.defaultCode);ve(this,"defaultMetadata",this.parser.defaultMetadata)}static fromMarkdown(e){return Wu.fromMarkdown(e)}transformIn(e){let n=this.parser.transformIn(e);return[n.code,n.offset,n.metadata]}transformOut(e,n){let a=this.parser.transformOut(e,n);return[a.code,a.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,n,a,o){let s=Qw().language.data,c,f=()=>{var m;if(!c)return!0;let d=c==null?void 0:c.state.field(Nr);return d===void 0?!1:((m=d.quotePrefix)==null?void 0:m.includes("f"))??!1};return[Ui.define(d=>(c=d,{})),Qw({base:W8,codeLanguages:$C,extensions:[V3(Mw.define(G8).parser),F3(Kh.parser,f)]}),j3(a),O3.map(d=>s.of({autocomplete:d})),Gw().language.data.of({autocomplete:k3({completion:Gy,predicate:f})}),Fu({defaultKeymap:!1,activateOnTyping:!0}),x3({predicate:()=>!f()})]}};function ec(){var e;return((e=ze.get(ql))==null?void 0:e.rootUri)??"file:///"}function tc(){var n;let e=(n=ze.get(ql))==null?void 0:n.rootUri;return e?[{uri:e,name:"marimo"}]:[]}function Zy(){var e;return((e=ze.get(ql))==null?void 0:e.documentUri)??"file:///__marimo_notebook__.py"}function H3(e){return Rr.filter(e,n=>n!==!1&&n!==null)}function e1(e){let n=e.map(H3);return Object.assign({},...n)}var $3=class{constructor(e){ve(this,"clients",[]);this.clients=e,this.documentUri=Zy()}onNotification(e){let n=[];for(let a of this.clients)n.push(a.onNotification(e));return()=>{for(let a of n)a();return!0}}get clientCapabilities(){return e1(this.clients.map(e=>{if(e.clientCapabilities)return typeof e.clientCapabilities=="function"?e.clientCapabilities({}):e.clientCapabilities}).filter(e=>e!=null))}get ready(){return this.clients.some(e=>e.ready)}set ready(e){this.clients.forEach(n=>{n.ready=e})}get capabilities(){return e1(this.clients.map(e=>e.capabilities).filter(e=>e!==null))}set capabilities(e){this.clients.forEach(n=>{n.capabilities=e})}get initializePromise(){return this.clients[0].initializePromise}set initializePromise(e){this.clients.forEach(n=>{n.initializePromise=e})}firstWithCapability(e){return this.clients.find(n=>{var a;return(a=n.capabilities)==null?void 0:a[e]})}clientsWithCapability(e){return this.clients.filter(n=>{var a;return(a=n.capabilities)==null?void 0:a[e]})}async initialize(){await Promise.all(this.clients.map(e=>e.initialize()))}async close(){await Promise.all(this.clients.map(e=>e.close()))}async textDocumentDidChange(e){return await Promise.all(this.clients.map(n=>n.textDocumentDidChange(e))),e}async completionItemResolve(e){let n=this.firstWithCapability("completionProvider");return n?n.completionItemResolve(e):e}async textDocumentCodeAction(e){let n=this.firstWithCapability("codeActionProvider");return n?n.textDocumentCodeAction(e):null}async textDocumentRename(e){let n=this.firstWithCapability("renameProvider");return n?n.textDocumentRename(e):null}async textDocumentPrepareRename(e){let n=this.firstWithCapability("renameProvider");return n?n.textDocumentPrepareRename(e):null}async textDocumentSignatureHelp(e){let n=this.firstWithCapability("signatureHelpProvider");return n?n.textDocumentSignatureHelp(e):null}async textDocumentCompletion(e){let n=this.clientsWithCapability("completionProvider");return W3(await Promise.allSettled(n.map(a=>a.textDocumentCompletion(e))))}async textDocumentDefinition(e){let n=this.firstWithCapability("definitionProvider");return n?n.textDocumentDefinition(e):null}async textDocumentDidOpen(e){return await Promise.all(this.clients.map(n=>n.textDocumentDidOpen(e))),e}async textDocumentHover(e){var n;for(let a of this.clients){if(!((n=a.capabilities)!=null&&n.hoverProvider))continue;let o=await a.textDocumentHover(e);if(o)return o}return{contents:[]}}};function W3(e){let n=[],a=!1;for(let o of e)if(o.status==="fulfilled"){let s=o.value;if(s==null)continue;Array.isArray(s)&&n.push(...s),"items"in s&&(n.push(...s.items),a||(a=s.isIncomplete))}return{items:n,isIncomplete:a}}w_=function(e){return[...U3(e),e].join(`
100
100
  `)};function U3(e){return t0().map(n=>{let a=wr(n);return a===e?null:a}).filter(Boolean).toSorted((n,a)=>n.startsWith("import")&&!a.startsWith("import")?-1:!n.startsWith("import")&&a.startsWith("import")?1:0)}var K3=Te(e=>{let n=e(Ye);return Rr.fromEntries(n.cellIds.inOrderIds.map(a=>{let o=n.cellHandles[a];return[a,o!=null&&o.current?wr(o.current.editorView):""]}))}),Q3=Te(e=>e(Ye).cellIds.inOrderIds),G3=Te(e=>X3(e(Q3),e(Za)));const J3=Te(e=>({cellIds:e(G3),codes:e(K3)}));function X3(e,n){var m,b;let a=new Map;e.forEach(_=>a.set(_,[]));let o=new Set(e),s=new Set(e);for(let{declaredBy:_,usedBy:x}of Object.values(n))for(let S of _){o.delete(S);for(let E of x)s.delete(E),E!==S&&((m=a.get(S))==null||m.push(E))}let c=new Map;e.forEach(_=>c.set(_,0)),a.forEach(_=>{_.forEach(x=>{c.set(x,(c.get(x)||0)+1)})});let f=[];c.forEach((_,x)=>{_===0&&f.push(x)});let d=[];for(;f.length>0;){let _=f.shift();if(!_)break;d.push(_),(b=a.get(_))==null||b.forEach(x=>{c.set(x,(c.get(x)||0)-1),c.get(x)===0&&f.push(x)})}return[...d.filter(_=>!o.has(_)),...o]}function Y3(e,n){let a=new Map,o=0;e.forEach(f=>{a.set(f,o),o+=n[f].split(`
@@ -109,7 +109,7 @@ mark line col
109
109
  `),isFenced:m}),o=[])};for(let m of n){let b=m.match(/^[\t ]*(`{3,}|~{3,})/);if(b){let _=b[1],x=_[0],S=_.length;if(!s){d(!1),s=!0,c=x,f=S,o.push(m);continue}if(x===c&&S>=f){o.push(m),d(!0),s=!1,c="",f=0;continue}}o.push(m)}return d(s),a}function sE(e){let n=[],a="",o=!1,s="",c=0;for(;c<e.length;){if(e[c]==="`"){let f=c;for(;f<e.length&&e[f]==="`";)f+=1;let d=e.slice(c,f);if(o&&d===s){a+=d,n.push({text:a,isInlineCode:!0}),a="",o=!1,s="",c=f;continue}if(!o){a&&(a=(n.push({text:a,isInlineCode:!1}),"")),o=!0,s=d,a+=d,c=f;continue}}a+=e[c],c+=1}return a&&n.push({text:a,isInlineCode:o}),n}function lE(e){let n=cE(e);return n=n.replaceAll(tE,(a,o)=>gf(o)),n=n.replaceAll(nE,(a,o)=>rc(o)),n=n.replaceAll(rE,(a,o)=>gf(o)),n=n.replaceAll(aE,(a,o)=>rc(o)),n}function po(e){var n;return((n=e.match(/^[\t ]*/))==null?void 0:n[0].replaceAll(" "," ").length)??0}function cE(e){var s;let n=e.split(`
110
110
  `);if(n.length===0)return e;let a=[],o=0;for(;o<n.length;){let c=n[o],f=c.match(/^[\t ]*\.\.\s+math::(.*)$/);if(!f){a.push(c),o+=1;continue}let d=((s=f[1])==null?void 0:s.trim())??"",m=po(c);o+=1;let b=[],_=d.includes("\\begin");if(d)b.push(d);else{for(;o<n.length;){let L=n[o];if(!L.trim()){o+=1;continue}if(!(po(L)>m&&L.trim().startsWith(":")))break;o+=1}if(o<n.length){let L=n[o];_=!!L.trim()&&po(L)<=m&&L.trimStart().startsWith("\\")}}if(_)for(;o<n.length&&n[o].trim();)b.push(n[o]),o+=1;else for(;o<n.length;){let L=n[o];if(!L.trim()){b.push(""),o+=1;continue}if(po(L)<=m)break;b.push(L),o+=1}let x=b.filter(L=>!!L.trim());if(x.length===0){a.push(c);continue}let S=Math.min(...x.map(L=>po(L))),E=b.map(L=>{if(!L)return"";let P=Math.min(S,po(L));return L.slice(P)}).join(`
111
111
  `).trim();a.push(gf(E))}return a.join(`
112
- `)}function rc(e){return`<marimo-tex class="arithmatex">||(${e.trim()}||)</marimo-tex>`}function gf(e){return`<marimo-tex class="arithmatex">||[${e.trim()}||]</marimo-tex>`}const cn={PREFIX:"file:///",of(e){return`${this.PREFIX}${e}`},is(e){return e.startsWith(this.PREFIX)},parse(e){return rn(this.is(e),`Invalid cell document URI: ${e}`),e.slice(this.PREFIX.length)}};function i1(e){return"notify"in e}function uE(e){return e.startsWith("_")&&!e.startsWith("__")}var dE=class{constructor(e){ve(this,"documentVersion",0);ve(this,"lastSnapshot",null);this.getNotebookCode=e}snapshot(){var a;let e=this.getLens(),n=((a=this.lastSnapshot)==null?void 0:a.mergedText)!==e.mergedText;return n?(this.documentVersion++,this.lastSnapshot=e,{lens:e,didChange:n,version:this.documentVersion}):{lens:e,didChange:n,version:this.documentVersion}}getLatestSnapshot(){if(!this.lastSnapshot)throw Error("No snapshots");return{lens:this.lastSnapshot,version:this.documentVersion}}getLens(){let{cellIds:e,codes:n}=this.getNotebookCode();return Y3(e,n)}},fE=()=>{let e=ld().cellHandles;return Rr.mapValues(e,n=>{var a;return(a=n.current)==null?void 0:a.editorViewOrNull})};function yf(e){let n=n1(e);return Array.isArray(n)?e:n}function vf(e){return{...e,documentation:yf(e.documentation)}}function pE(e){return e==null?null:Array.isArray(e)?e.map(n=>vf(n)):{...e,items:e.items.map(n=>vf(n))}}function hE(e){return{...e,signatures:e.signatures.map(n=>{var a;return{...n,documentation:yf(n.documentation),parameters:(a=n.parameters)==null?void 0:a.map(o=>({...o,documentation:yf(o.documentation)}))}})}}var ac=(ur=class{constructor(n,a,o=fE){ve(this,"completionItemCache",new Ql(10));ve(this,"latestDiagnosticsVersion",null);ve(this,"forwardedDiagnosticsVersion",0);this.documentUri=Zy(),this.getNotebookEditors=o,this.initialSettings=a,this.client=n,this.patchProcessNotification(),this.initializePromise.then(()=>{rn(i1(this.client),"notify is not a method on the client"),this.client.notify("workspace/didChangeConfiguration",{settings:a})}),this.snapshotter=new dE(this.getNotebookCode.bind(this))}static pruneSeenCellUris(n){for(let a of ur.SEEN_CELL_DOCUMENT_URIS){let o=cn.parse(a);n.has(o)||ur.SEEN_CELL_DOCUMENT_URIS.delete(a)}}onNotification(n){return this.client.onNotification(n)}get ready(){return this.client.ready}set ready(n){this.client.ready=n}get capabilities(){return this.client.capabilities}set capabilities(n){this.client.capabilities=n}get initializePromise(){return this.client.initializePromise}set initializePromise(n){this.client.initializePromise=n}get clientCapabilities(){return this.client.clientCapabilities}async initialize(){await this.client.initialize()}close(){this.client.close()}async resyncAllDocuments(){rn(i1(this.client),"notify is not a method on the client"),await this.client.initialize(),this.client.notify("workspace/didChangeConfiguration",{settings:this.initialSettings});let{lens:n,version:a}=this.snapshotter.snapshot();this.latestDiagnosticsVersion=null,this.forwardedDiagnosticsVersion=0,await this.client.textDocumentDidOpen({textDocument:{languageId:"python",text:n.mergedText,uri:this.documentUri,version:a}}),be.log("[lsp] Document re-synchronization complete")}getNotebookCode(){return ze.get(J3)}assertCellDocumentUri(n){rn(cn.is(n),"Execpted URI to be CellDocumentUri")}async textDocumentDidOpen(n){be.debug("[lsp] textDocumentDidOpen",n);let a=n.textDocument.uri;this.assertCellDocumentUri(a);let{lens:o,version:s}=this.snapshotter.snapshot();ur.SEEN_CELL_DOCUMENT_URIS.add(a);let c=await this.client.textDocumentDidOpen({textDocument:{languageId:n.textDocument.languageId,text:o.mergedText,uri:this.documentUri,version:s}});return c?{...c,textDocument:{...c.textDocument,text:o.mergedText}}:n}async sync(){let{lens:n,version:a,didChange:o}=this.snapshotter.snapshot(),s={textDocument:{uri:this.documentUri,version:a},contentChanges:[{text:n.mergedText}]};return o&&await this.client.textDocumentDidChange(s),{params:s,lens:n}}async textDocumentDidChange(n){if(be.debug("[lsp] textDocumentDidChange",n),n.contentChanges.length===1){let{params:a}=await this.sync();return a}return be.warn("[lsp] Unhandled textDocumentDidChange",n),this.client.textDocumentDidChange(n)}async textDocumentDefinition(n){let a=n.textDocument.uri;if(!cn.is(a))return be.warn("Invalid cell document URI",a),null;let{lens:o}=await this.sync(),s=cn.parse(a);return this.client.textDocumentDefinition({...n,textDocument:{uri:this.documentUri},position:o.transformPosition(n.position,s)})}async textDocumentSignatureHelp(n){let a=n.textDocument.uri;if(!cn.is(a))return be.warn("Invalid cell document URI",a),null;let{lens:o}=await this.sync(),s=cn.parse(a),c=await this.client.textDocumentSignatureHelp({...n,textDocument:{uri:this.documentUri},position:o.transformPosition(n.position,s)});return c?hE(c):null}textDocumentCodeAction(n){return Promise.resolve(null)}async textDocumentRename(n){var q;let a=n.textDocument.uri;if(!cn.is(a))return be.warn("Invalid cell document URI",a),null;let o=cn.parse(a),{lens:s}=await this.sync(),c=s.transformPosition(n.position,o),f=await this.client.textDocumentRename({...n,textDocument:{uri:this.documentUri},position:c});if(!f)return null;let d=(q=f.documentChanges)==null?void 0:q.flatMap(V=>"edits"in V?V.edits:[]);if(!d||d.length!==1)return be.warn("Expected exactly one edit",d),f;let m=d[0];if(!("newText"in m))return be.warn("Expected newText in edit",m),f;let b=s.getEditsForNewText(m.newText),_=new Map(b.map(V=>[V.cellId,V.text])),x=this.getNotebookEditors(),S=x[o],E=!1;if(S){let V=S.state.doc.line(n.position.line+1).from+n.position.character,{startToken:B,endToken:M}=cf(S.state.doc,V),J=S.state.doc.sliceString(B,M);E=uE(J),E&&be.debug("[lsp] Private variable rename detected, limiting to current cell",J)}let L=[],P=0;for(let[V,B]of Rr.entries(x)){if(E&&V!==o)continue;let M=_.get(V);if(M==null){be.warn("[lsp] No new code for cell during rename",V),L.push(V);continue}if(!B){be.warn("[lsp] No editor view for cell during rename",V),L.push(V);continue}wr(B)!==M&&(Ji(B,M),P++)}return L.length>0&&be.error(`[lsp] Rename partially failed: could not update ${L.length} cell(s)`,L),be.debug(`[lsp] Rename completed: updated ${P} cell(s)`),{...f,documentChanges:[{edits:[],textDocument:{uri:a,version:0}}]}}async completionItemResolve(n){let a=JSON.stringify(n),o=this.completionItemCache.get(a);if(o)return o;let s=this.client.completionItemResolve(n).then(c=>vf(c));return this.completionItemCache.set(a,s),s}async textDocumentPrepareRename(n){let a=n.textDocument.uri;if(!cn.is(a))return be.warn("Invalid cell document URI",a),null;let{lens:o}=await this.sync(),s=cn.parse(a);return this.client.textDocumentPrepareRename({...n,textDocument:{uri:this.documentUri},position:o.transformPosition(n.position,s)})}async textDocumentHover(n){be.debug("[lsp] textDocumentHover",n);let{lens:a}=await this.sync(),o=cn.parse(n.textDocument.uri),s=await this.client.textDocumentHover({...n,textDocument:{uri:this.documentUri},position:a.transformPosition(n.position,o)});return s?(typeof s.contents=="object"&&"kind"in s.contents&&(s.contents={kind:"markdown",value:s.contents.value}),s.contents=n1(s.contents)??s.contents,s.contents===""?null:(s.range&&(s.range=a.reverseRange(s.range,o)),s)):(be.debug("[lsp] no hover result"),s)}async textDocumentCompletion(n){let{lens:a}=this.snapshotter.getLatestSnapshot();if(!cn.is(n.textDocument.uri))return be.error("[lsp] Invalid cell document URI in completion request",n.textDocument.uri),null;let o=cn.parse(n.textDocument.uri);if(!o||o==="undefined")return be.error("[lsp] Invalid cellId 'undefined' in completion request",{cellId:o,uri:n.textDocument.uri,availableCellIds:a.cellIds}),null;a.cellIds.includes(o)||be.warn("[lsp] CellId in completion request not found in current lens",{cellId:o,uri:n.textDocument.uri,availableCellIds:a.cellIds});let s=a.transformPosition(n.position,o);return pE(await this.client.textDocumentCompletion({...n,textDocument:{uri:this.documentUri},position:s}))}patchProcessNotification(){rn("processNotification"in this.client,"processNotification is not a method on the client");let n=this.client.processNotification.bind(this.client),a=o=>{if(o.method==="textDocument/publishDiagnostics"){let s=o.params.version;if(s!=null){let S=this.latestDiagnosticsVersion;if(S!==null&&Number.isFinite(s)&&s<S){be.debug("[lsp] dropping stale diagnostics notification",o);return}this.latestDiagnosticsVersion=s}be.debug("[lsp] handling diagnostics",o);let c=this.snapshotter.getLatestSnapshot(),f=o.params.diagnostics,{lens:d}=c,m=++this.forwardedDiagnosticsVersion,b=new Map;for(let S of f)for(let E of d.cellIds)if(d.isInRange(S.range,E)){b.has(E)||b.set(E,[]);let L={...S,range:d.reverseRange(S.range,E)};b.get(E).push(L);break}let _=new Set(d.cellIds);ur.pruneSeenCellUris(_);let x=new Set(ur.SEEN_CELL_DOCUMENT_URIS);for(let[S,E]of b.entries()){be.debug("[lsp] diagnostics for cell",S,E);let L=cn.of(S);x.delete(L),n({...o,params:{...o.params,uri:L,version:m,diagnostics:E}})}if(x.size>0){be.debug("[lsp] clearing diagnostics",x);for(let S of x)n({method:"textDocument/publishDiagnostics",params:{uri:S,version:m,diagnostics:[]}})}return}return n(o)};this.client.processNotification=a}},ve(ur,"SEEN_CELL_DOCUMENT_URIS",new Set),ur),mE=Ol(),gE=Xa(),yE=class extends gE.Transport{constructor(n){super();ve(this,"isClosed",!1);ve(this,"hasConnectedBefore",!1);ve(this,"pendingSubscriptions",[]);this.options=n,this.delegate=void 0}createDelegate(){if(this.delegate)try{this.delegate.close()}catch(n){be.warn("Error closing old WebSocket delegate",n)}this.delegate=new mE.WebSocketTransport(this.options.getWsUrl());for(let{event:n,handler:a}of this.pendingSubscriptions)this.delegate.subscribe(n,a);return this.delegate}isDelegateClosedOrClosing(){if(!this.delegate)return!0;let n=this.delegate.connection;return n?n.readyState===WebSocket.CLOSING||n.readyState===WebSocket.CLOSED:!0}async connect(){if(this.isClosed)throw Error("Transport is closed");return this.connectionPromise||(this.connectionPromise=(async()=>{try{this.options.waitForConnection&&await this.options.waitForConnection();let n=this.delegate;(!n||this.isDelegateClosedOrClosing())&&(n=this.createDelegate()),await n.connect(),be.log("WebSocket transport connected successfully");let a=this.hasConnectedBefore;this.hasConnectedBefore=!0,a&&this.options.onReconnect&&(be.log("Calling onReconnect callback to re-synchronize state"),await this.options.onReconnect())}catch(n){throw be.error("WebSocket transport connection failed",n),this.delegate=void 0,n}finally{this.connectionPromise=void 0}})()),this.connectionPromise}close(){var n;this.isClosed=!0,(n=this.delegate)==null||n.close(),this.delegate=void 0,this.connectionPromise=void 0}subscribe(...n){super.subscribe(...n);let[a,o]=n;this.pendingSubscriptions.push({event:a,handler:o}),this.delegate&&this.delegate.subscribe(a,o)}unsubscribe(...n){let a=super.unsubscribe(...n),[o,s]=n;return this.pendingSubscriptions=this.pendingSubscriptions.filter(c=>!(c.event===o&&c.handler===s)),this.delegate&&this.delegate.unsubscribe(o,s),a}async sendData(n,a){var o;if(this.isDelegateClosedOrClosing()){be.warn("WebSocket is closed or closing, attempting to reconnect");try{await this.connect()}catch(s){throw be.error("Failed to reconnect WebSocket",s),s}}return(o=this.delegate)==null?void 0:o.sendData(n,a)}};function ic(e,n){let a=_6();return new yE({getWsUrl:()=>a.getLSPURL(e).toString(),waitForConnection:async()=>{await x6()},onReconnect:n})}la.define(),new qu;function vE(e){return e.facet(U6.readOnly)}function bE(e){return[Tw(e),Ja.of([{key:"ArrowRight",preventDefault:!0,run:n=>o1(n,e)},{key:"Tab",preventDefault:!0,run:n=>o1(n,e)}])]}function o1(e,n){if(vE(e.state))return!1;let a=e.state.doc.length;return a===0?(e.dispatch({changes:{from:0,to:a,insert:n},selection:{head:n.length,anchor:n.length}}),!0):!1}function wE(e){let{beforeText:n,linkText:a,afterText:o,onClick:s}=e;return[Tw(c=>{let f=document.createElement("span");f.append(document.createTextNode(n));let d=document.createElement("span");return d.textContent=a,d.classList.add("cm-clickable-placeholder"),d.onclick=m=>{m.stopPropagation(),s(c)},f.append(d),f.append(document.createTextNode(o)),f}),Et.theme({".cm-placeholder":{color:"var(--slate-8)"},".cm-clickable-placeholder":{cursor:"pointer !important",pointerEvents:"auto",color:"var(--slate-9)",textDecoration:"underline",textUnderlineOffset:"0.2em"},".cm-clickable-placeholder:hover":{color:"var(--sky-11)"}})]}var _E=nr(e=>{let n,a={transport:ic("pylsp",async()=>{await(n==null?void 0:n())}),rootUri:ec(),workspaceFolders:tc()},o=e==null?void 0:e.pylsp,s=["D100","D103"],c=["W292","E402","E302","E305"],f=["B018","I001"],d={pylsp:{plugins:{marimo_plugin:{enabled:!0},jedi:{auto_import_modules:["numpy"]},jedi_completion:{include_params:!0,resolve_at_most:50},flake8:{enabled:o==null?void 0:o.enable_flake8,extendIgnore:c},pydocstyle:{enabled:o==null?void 0:o.enable_pydocstyle,ignore:s},pylint:{enabled:o==null?void 0:o.enable_pylint},pyflakes:{enabled:o==null?void 0:o.enable_pyflakes},pylsp_mypy:{enabled:o==null?void 0:o.enable_mypy,live_mode:!0},ruff:{enabled:o==null?void 0:o.enable_ruff,extendIgnore:[...c,...s,...f]},signature:{formatter:o!=null&&o.enable_ruff?"ruff":"black",line_length:88}}}},m=new ac(new cs({...a}),d);return n=()=>m.resyncAllDocuments(),m}),xE=nr(e=>{let n,a=new ac(new cs({transport:ic("ty",async()=>{await(n==null?void 0:n())}),rootUri:ec(),workspaceFolders:tc(),getWorkspaceConfiguration:o=>[{disableLanguageServices:!0}]}),{});return n=()=>a.resyncAllDocuments(),a}),kE=nr(e=>{var o;let n,a=new ac(new cs({transport:ic("pyrefly",async()=>{await(n==null?void 0:n())}),rootUri:ec(),workspaceFolders:tc(),initializationOptions:{pyrefly:{displayTypeErrors:((o=e.diagnostics)==null?void 0:o.enabled)??!1?"force-on":"force-off"}}}),{});return n=()=>a.resyncAllDocuments(),a}),CE=nr(e=>{let n,a=new ac(new cs({transport:ic("basedpyright",async()=>{await(n==null?void 0:n())}),rootUri:ec(),workspaceFolders:tc()}),{});return n=()=>a.resyncAllDocuments(),a}),SE=class{constructor(){ve(this,"parser",new vy);ve(this,"type","python");ve(this,"defaultCode",this.parser.defaultCode);ve(this,"defaultMetadata",this.parser.defaultMetadata)}transformIn(e){let n=this.parser.transformIn(e);return[n.code,n.offset,n.metadata]}transformOut(e,n){let a=this.parser.transformOut(e,n);return[a.code,a.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,n,a,o,s){return[(()=>{var _,x,S,E,L;let c={defaultKeymap:!1,activateOnTyping:n.activate_on_typing,closeOnBlur:!1},f={hideOnChange:!0},d=[];(_=s==null?void 0:s.pylsp)!=null&&_.enabled&&vs("pylsp")&&d.push(_E(s)),(x=s==null?void 0:s.ty)!=null&&x.enabled&&vs("ty")&&d.push(xE(s)),(S=s==null?void 0:s.pyrefly)!=null&&S.enabled&&vs("pyrefly")&&d.push(kE(s)),(E=s==null?void 0:s.basedpyright)!=null&&E.enabled&&vs("basedpyright")&&d.push(CE(s));let m=n.signature_hint_on_typing,b=m?/(\w+|\w+\.|\/)$/:/(\w+|\w+\.|\(|\/|,)$/;if(d.length>0){let P=d.length===1?d[0]:new $3(d);return[om({client:P,languageId:"python",allowHTMLContent:!0,useSnippetOnCompletion:!0,hoverConfig:f,completionConfig:c,diagnosticsEnabled:((L=s.diagnostics)==null?void 0:L.enabled)??!1,sendIncrementalChanges:!1,signatureHelpEnabled:!0,signatureActivateOnTyping:m,signatureHelpOptions:{position:"above"},keyboardShortcuts:{signatureHelp:a.getHotkey("cell.signatureHelp").key,goToDefinition:a.getHotkey("cell.goToDefinition").key,rename:a.getHotkey("cell.renameSymbol").key},completionMatchBefore:b,onGoToDefinition:q=>{be.debug("onGoToDefinition",q),P.documentUri!==q.uri&&br().openFile({path:q.uri.replace("file://","")})}}),Dg.of(cn.of(e))]}return Fu({...c,override:[Gy]})})(),rm(),EE(o)]}};function EE(e){return e==="marimo-import"?zu.highest(bE("import marimo as mo")):e==="ai"?wE({beforeText:"Start coding or ",linkText:"generate",afterText:" with AI.",onClick:n=>{n.state.facet(ot).aiCellCompletion()}}):[]}var bf=Kh.configure({props:[V6.add({ParenthesizedExpression:Rw,ArgList:Rw})]});rm=function(){return new jw(bf,[bf.data.of({autocomplete:K8}),bf.data.of({autocomplete:Q8})])};const TE=e=>{let n;return async()=>(n||(n=e()),await n)};var oc=class{constructor(e={}){ve(this,"opts");ve(this,"parser",null);ve(this,"offsetRecord",{});ve(this,"getParser",TE(async()=>{if(this.parser)return this.parser;let e=await re(()=>import("./node-sql-parser-UQ9Ur_LP.js").then(async a=>(await a.__tla,a)).then(f6(1)),__vite__mapDeps([213,1]),import.meta.url),{Parser:n}=e.default||e;return this.parser=new n,this.parser}));this.opts=e}async parse(e,n){var s,c;this.offsetRecord={};let a=(c=(s=this.opts).getParserOptions)==null?void 0:c.call(s,n.state),o=await this.sanitizeSql(e,a);try{let f=await this.getParser();return(a==null?void 0:a.database)==="DuckDB"?this.parseWithDuckDBSupport(o,a):{success:!0,errors:[],ast:f.astify(o,a)}}catch(f){return{success:!1,errors:[this.extractErrorInfo(f,o)]}}}async sanitizeSql(e,n){if(n!=null&&n.ignoreBrackets){let{sql:a,offsetRecord:o}=OE(e);return this.offsetRecord=o,a}return e}async parseWithDuckDBSupport(e,n){let a=await this.getParser(),o=IE(e).trimStart().toLowerCase();if(o.startsWith("from")||o.includes("macro"))return{success:!0,errors:[]};let s=e;o.includes("create or replace table")&&(this.offsetRecord[e.indexOf("create or replace table")]=-11,s=e.replace(/create or replace table/i,"create table"));try{let c={...n,database:"PostgreSQL"};return{success:!0,errors:[],ast:a.astify(s,c)}}catch(c){return{success:!1,errors:[this.extractErrorInfo(c,e)]}}}extractErrorInfo(e,n){var f,d,m;let a=1,o=1,s=(e==null?void 0:e.message)||"SQL parsing error",c=e;if(c!=null&&c.location)a=((f=c.location.start)==null?void 0:f.line)||1,o=((d=c.location.start)==null?void 0:d.column)||1;else if(c!=null&&c.hash)a=c.hash.line||1,o=((m=c.hash.loc)==null?void 0:m.first_column)||1;else{let b=s.match(/line (\d+)/i),_=s.match(/column (\d+)/i);b!=null&&b[1]&&(a=parseInt(b[1],10)),_!=null&&_[1]&&(o=parseInt(_[1],10))}for(let[b,_]of Object.entries(this.offsetRecord))o>parseInt(b,10)&&(o-=_);return o>n.length&&(o=n.length),{message:this.cleanErrorMessage(s),line:Math.max(1,a),column:o,severity:"error"}}cleanErrorMessage(e){return e.replace(/^Error: /,"").replace(/Expected .* but .* found\./i,n=>n.replace(/but .* found/,"found unexpected token")).trim()}async validateSql(e,n){return(await this.parse(e,n)).errors}async extractTableReferences(e,n){var o,s;let a=n?(s=(o=this.opts).getParserOptions)==null?void 0:s.call(o,n.state):void 0;try{return(await this.getParser()).tableList(e,a).map(c=>{let f=c.split("::");return f[f.length-1]||c})}catch{return[]}}async extractColumnReferences(e,n){var o,s;let a=n!=null&&n.state?(s=(o=this.opts).getParserOptions)==null?void 0:s.call(o,n.state):void 0;try{return(await this.getParser()).columnList(e,a).map(c=>{let f=c.split("::");return f[f.length-1]||c})}catch{return[]}}};function IE(e,n=["/*","--"]){let a=[];if(n.includes("/*")&&a.push("/\\*[\\s\\S]*?\\*/"),n.includes("--")&&a.push("--[^\\n]*"),a.length===0)return e;let o=RegExp(`^\\s*(${a.join("|")})\\s*`,""),s=e,c="";for(;s!==c;)c=s,s=s.replace(o,"");return s}var LE=2;function OE(e){let n={};return{sql:e.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(\{[^}]*\})/g,(a,o,s,c,f)=>o||s?a:c?(n[f]=LE,`'${c}'`):a),offsetRecord:n}}var AE=750;function RE(e,n){let a=n.line(e.line).from+Math.max(0,e.column-1);return{from:a,to:a+1,severity:e.severity,message:e.message,source:"sql-parser"}}function PE(e={}){let n=e.parser||new oc;return m8(async a=>{let o=a.state.doc,s=o.toString();return s.trim()?(await n.validateSql(s,{state:a.state})).map(c=>RE(c,o)):[]},{delay:e.delay||AE})}function ui(e){return typeof e=="object"&&!Array.isArray(e)&&!("self"in e)}function Dr(e){return typeof e=="object"&&!Array.isArray(e)&&"self"in e&&"children"in e}function cr(e){return Array.isArray(e)}function un(e,n,a,o){let s=e.length;if(n==="string"||n==="completion"&&o&&cr(o))return"column";if(n==="namespace"&&a){if(cr(a))return"table";if(ui(a))return Object.values(a).some(c=>cr(c)||Dr(c)&&cr(c.children))?s<=1?"database":"schema":s===0?"database":"namespace"}if(n==="completion"&&a)return cr(a)?"table":(ui(a)&&Object.values(a).some(c=>cr(c)||Dr(c)&&cr(c.children)),s<=1?"database":"schema");switch(s){case 0:return"database";case 1:return"schema";default:return"namespace"}}function s1(e,n,a={}){let{maxDepth:o=10}=a;if(n===""&&Dr(e)){let c=un([],"completion",e.children);return{completion:e.self,path:[],type:"completion",semanticType:c,namespace:e.children}}let s=n.split(".").filter(c=>c.length>0);return s.length===0||s.length>o?null:wf(e,s,[],a)}function wf(e,n,a,o,s){if(n.length===0){if(Dr(e)){let m=un(a,"completion",e.children,s);return{completion:e.self,path:a,type:"completion",semanticType:m,namespace:e.children}}return{path:a,type:"namespace",semanticType:un(a,"namespace",e,s),namespace:e}}let[c,...f]=n,{caseSensitive:d=!1}=o;if(!c)return null;if(ui(e)){let m=d?Object.keys(e).find(b=>b===c):Object.keys(e).find(b=>b.toLowerCase()===c.toLowerCase());if(m){let b=e[m];if(b)return wf(b,f,[...a,m],o,e)}}else{if(Dr(e))return wf(e.children,n,a,o,e);if(cr(e)){for(let m of e)if(typeof m=="string"){if((d?m===c:m.toLowerCase()===c.toLowerCase())&&f.length===0){let b=un([...a,m],"string",void 0,e);return{value:m,path:[...a,m],type:"string",semanticType:b}}}else if((d?m.label===c:m.label.toLowerCase()===c.toLowerCase())&&f.length===0){let b=un([...a,m.label],"completion",void 0,e);return{completion:m,path:[...a,m.label],type:"completion",semanticType:b}}}}return null}function NE(e,n,a={}){let o=[];if(n.includes(".")){let s=n.lastIndexOf("."),c=n.substring(0,s),f=n.substring(s+1),d=s1(e,c,a);if(d!=null&&d.namespace)return _f(d.namespace,f,d.path,a)}else return _f(e,n,[],a);return o}function _f(e,n,a,o){let s=[],{caseSensitive:c=!1,allowPartialMatch:f=!0}=o;if(ui(e)){for(let[d,m]of Object.entries(e))if(f?c?d.startsWith(n):d.toLowerCase().startsWith(n.toLowerCase()):c?d===n:d.toLowerCase()===n.toLowerCase())if(Dr(m)){let b=un([...a,d],"completion",m.children,e);s.push({completion:m.self,path:[...a,d],type:"completion",semanticType:b,namespace:m.children})}else{let b=un([...a,d],"namespace",m,e);s.push({path:[...a,d],type:"namespace",semanticType:b,namespace:m})}}else if(Dr(e)){if(f?c?e.self.label.startsWith(n):e.self.label.toLowerCase().startsWith(n.toLowerCase()):c?e.self.label===n:e.self.label.toLowerCase()===n.toLowerCase()){let d=un([...a,e.self.label],"completion",e.children);s.push({completion:e.self,path:[...a,e.self.label],type:"completion",semanticType:d,namespace:e.children})}s.push(..._f(e.children,n,a,o))}else if(cr(e)){for(let d of e)if(typeof d=="string"){if(f?c?d.startsWith(n):d.toLowerCase().startsWith(n.toLowerCase()):c?d===n:d.toLowerCase()===n.toLowerCase()){let m=un([...a,d],"string",void 0,e);s.push({value:d,path:[...a,d],type:"string",semanticType:m})}}else if(f?c?d.label.startsWith(n):d.label.toLowerCase().startsWith(n.toLowerCase()):c?d.label===n:d.label.toLowerCase()===n.toLowerCase()){let m=un([...a,d.label],"completion",void 0,e);s.push({completion:d,path:[...a,d.label],type:"completion",semanticType:m})}}return s}function ME(e,n,a={}){let o=[],{maxDepth:s=10}=a;sc(e,[],o,s);let{caseSensitive:c=!1}=a;return o.filter(f=>f.path.some(d=>c?d===n:d.toLowerCase()===n.toLowerCase())).sort((f,d)=>{var _,x;let m=c?f.path[f.path.length-1]===n:((_=f.path[f.path.length-1])==null?void 0:_.toLowerCase())===n.toLowerCase(),b=c?d.path[d.path.length-1]===n:((x=d.path[d.path.length-1])==null?void 0:x.toLowerCase())===n.toLowerCase();return m&&!b?-1:!m&&b?1:f.path.length-d.path.length})}function sc(e,n,a,o){if(!(n.length>=o)){if(ui(e))for(let[s,c]of Object.entries(e)){let f=[...n,s];if(Dr(c)){let d=un(f,"completion",c.children,e);a.push({completion:c.self,path:f,type:"completion",semanticType:d,namespace:c.children}),sc(c.children,f,a,o)}else{let d=un(f,"namespace",c,e);a.push({path:f,type:"namespace",semanticType:d,namespace:c}),sc(c,f,a,o)}}else if(Dr(e)){let s=un(n,"completion",e.children);a.push({completion:e.self,path:n,type:"completion",semanticType:s,namespace:e.children}),sc(e.children,n,a,o)}else if(cr(e))for(let s of e)if(typeof s=="string"){let c=un([...n,s],"string",void 0,e);a.push({value:s,path:[...n,s],type:"string",semanticType:c})}else{let c=un([...n,s.label],"completion",void 0,e);a.push({completion:s,path:[...n,s.label],type:"completion",semanticType:c})}}}function l1(e,n,a={}){let{enableFuzzySearch:o=!1}=a,s=s1(e,n,a);if(s)return s;let c=NE(e,n,a);if(c.length>0)return c[0]||null;if(o){let f=ME(e,n,a);if(f.length>0)return f[0]||null}return null}function c1(e,n){if(n.size===0)return{};if(ui(e)){let a={};for(let[o,s]of Object.entries(e))if(Array.from(n).some(c=>c.toLowerCase()===o.toLowerCase()))a[o]=s;else if(ui(s)){let c=c1(s,n);Object.keys(c).length>0&&(a[o]=c)}return a}return e}function DE(e={}){let{schema:n={},keywords:a={},hoverTime:o=300,enableKeywords:s=!0,enableTables:c=!0,enableColumns:f=!0,enableFuzzySearch:d=!0,parser:m=new oc,tooltipRender:b,tooltipRenderers:_={}}=e,x=null;return Fh(async(S,E,L)=>{let{from:P,to:q,text:V}=S.state.doc.lineAt(E),B=E,M=E;x===null&&(x=typeof a=="function"?a(S):Promise.resolve(a));let J=await x;for(;B>P&&/[\w.]/.test(V[B-P-1]??"");)B--;for(;M<q&&/[\w.]/.test(V[M-P]??"");)M++;if(B===E&&L<0||M===E&&L>0)return null;let le=V.slice(B-P,M-P).toLowerCase();if(!le||le.length===0)return null;let A=typeof n=="function"?n(S):n,j=null;if(`${le}`,!j&&s&&J[le]&&(J[le],j={word:le,view:S,pos:E,tooltipType:"keyword",keywordData:{keyword:le,info:J[le]}}),!j&&(c||f)&&A){let $=S.state.doc.toString(),oe=await m.extractTableReferences($),de=new Set(oe.map(ke=>ke.toLowerCase())),he=c1(A,de),ye=l1(he,le,{enableFuzzySearch:d});!ye&&de.size===0&&(ye=l1(A,le,{enableFuzzySearch:d})),ye&&(Array.from(de),j={word:le,view:S,pos:E,tooltipType:"namespace",namespaceData:{item:ye,word:le,resolvedSchema:de.size>0?he:A}})}return j?{pos:B,end:M,above:!0,create($){if(b){let he=b(le,$,E);if(he)return{dom:he}}let oe=null;if(j.tooltipType==="keyword"&&j.keywordData)oe=_.keyword?_.keyword(j.keywordData):d1(j.keywordData);else if(j.tooltipType==="namespace"&&j.namespaceData){let he=j.namespaceData,{semanticType:ye}=he.item;oe=ye==="table"&&_.table?_.table(he):ye==="column"&&_.column?_.column(he):(ye==="database"||ye==="schema"||ye==="namespace")&&_.namespace?_.namespace(he):u1(he.item)}if(!oe)return{dom:document.createElement("div")};let de=document.createElement("div");return de.className="cm-sql-hover-tooltip",de.innerHTML=oe,{dom:de}}}:null},{hoverTime:o})}function u1(e){var s,c,f,d,m,b,_;let n=e.path.join("."),a=((s=e.completion)==null?void 0:s.label)||e.value||e.path[e.path.length-1]||"unknown",o=`<div class="sql-hover-${e.semanticType}">`;switch(o+=`<div class="sql-hover-header"><strong>${a}</strong> <span class="sql-hover-type">${e.semanticType}</span></div>`,e.semanticType){case"database":if(o+=`<div class="sql-hover-description">Database${(c=e.completion)!=null&&c.detail?`: ${e.completion.detail}`:""}</div>`,e.namespace){let x=lc(e.namespace);x>0&&(o+=`<div class="sql-hover-children">Contains ${x} schema${x===1?"":"s"}</div>`)}break;case"schema":if(o+=`<div class="sql-hover-description">Schema${(f=e.completion)!=null&&f.detail?`: ${e.completion.detail}`:""}</div>`,n&&(o+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${n}</code></div>`),e.namespace){let x=lc(e.namespace);x>0&&(o+=`<div class="sql-hover-children">Contains ${x} table${x===1?"":"s"}</div>`)}break;case"table":if(o+=`<div class="sql-hover-description">Table${(d=e.completion)!=null&&d.detail?`: ${e.completion.detail}`:""}</div>`,n){let x=e.path;x.length>1&&(o+=`<div class="sql-hover-path"><strong>Schema:</strong> <code>${x.slice(0,-1).join(".")}</code></div>`)}if(e.namespace&&cr(e.namespace)){let x=e.namespace;if(x.length>0){o+=`<div class="sql-hover-columns"><strong>Columns (${x.length}):</strong><br>`;let S=x.slice(0,8).map(E=>typeof E=="string"?E:E.label);o+=S.map(E=>`<code>${E}</code>`).join(", "),x.length>8&&(o+=`, <em>and ${x.length-8} more...</em>`),o+="</div>"}}break;case"column":if(o+=`<div class="sql-hover-description">Column${(m=e.completion)!=null&&m.detail?`: ${e.completion.detail}`:""}</div>`,n){let x=e.path;x.length>1&&(o+=`<div class="sql-hover-path"><strong>Table:</strong> <code>${x.slice(0,-1).join(".")}</code></div>`)}break;default:if(o+=`<div class="sql-hover-description">Namespace${(b=e.completion)!=null&&b.detail?`: ${e.completion.detail}`:""}</div>`,n&&(o+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${n}</code></div>`),e.namespace){let x=lc(e.namespace);x>0&&(o+=`<div class="sql-hover-children">Contains ${x} item${x===1?"":"s"}</div>`)}break}return(_=e.completion)!=null&&_.info&&typeof e.completion.info=="string"&&(o+=`<div class="sql-hover-info">${e.completion.info}</div>`),o+="</div>",o}function lc(e){return Array.isArray(e)?e.length:typeof e=="object"&&e?"self"in e&&"children"in e?1+lc(e.children):Object.keys(e).length:0}function d1(e){let{keyword:n,info:a}=e,o='<div class="sql-hover-keyword">';if(o+=`<div class="sql-hover-header"><strong>${n.toUpperCase()}</strong> <span class="sql-hover-type">keyword</span></div>`,o+=`<div class="sql-hover-description">${a.description}</div>`,a.syntax&&(o+=`<div class="sql-hover-syntax"><strong>Syntax:</strong> <code>${a.syntax}</code></div>`),a.example&&(o+=`<div class="sql-hover-example"><strong>Example:</strong><br><code>${a.example}</code></div>`),a.metadata&&typeof a.metadata=="object"&&Object.keys(a.metadata).length>0){o+='<div class="sql-hover-metadata">';for(let[s,c]of Object.entries(a.metadata))o+=`<span class="sql-hover-tag" title="${s}">${c}</span> `;o+="</div>"}return o+="</div>",o}function jE(e){let{tableName:n,columns:a,metadata:o}=e,s='<div class="sql-hover-table">';if(s+=`<div class="sql-hover-header"><strong>${n}</strong> <span class="sql-hover-type">table</span></div>`,s+=`<div class="sql-hover-description">Table with ${a.length} column${a.length===1?"":"s"}</div>`,a.length>0){s+='<div class="sql-hover-columns"><strong>Columns:</strong><br>';let c=a.slice(0,10);s+=c.map(f=>`<code>${f}</code>`).join(", "),a.length>10&&(s+=`, <em>and ${a.length-10} more...</em>`),s+="</div>"}if(o&&typeof o=="object"&&Object.keys(o).length>0){s+='<div class="sql-hover-metadata">';for(let[c,f]of Object.entries(o))s+=`<span class="sql-hover-tag" title="${c}">${f}</span> `;s+="</div>"}return s+="</div>",s}function zE(e){let{tableName:n,columnName:a,schema:o,metadata:s}=e,c='<div class="sql-hover-column">';c+=`<div class="sql-hover-header"><strong>${a}</strong> <span class="sql-hover-type">column</span></div>`,c+=`<div class="sql-hover-description">Column in table <code>${n}</code></div>`;let f=o[n];if(f&&f.length>1){let d=f.filter(m=>m!==a);if(d.length>0){c+=`<div class="sql-hover-related"><strong>Other columns in ${n}:</strong><br>`;let m=d.slice(0,8);c+=m.map(b=>`<code>${b}</code>`).join(", "),d.length>8&&(c+=`, <em>and ${d.length-8} more...</em>`),c+="</div>"}}if(s&&typeof s=="object"&&Object.keys(s).length>0){c+='<div class="sql-hover-metadata">';for(let[d,m]of Object.entries(s))c+=`<span class="sql-hover-tag" title="${d}">${m}</span> `;c+="</div>"}return c+="</div>",c}const qE={keyword:d1,table:jE,column:zE,namespace:u1},f1=(e="light")=>{let n=e==="dark"?{tooltipBg:"#1f2937",tooltipBorder:"#374151",tooltipText:"#f9fafb",tooltipTypeBg:"#374151",tooltipTypeText:"#9ca3af",tooltipChildren:"#9ca3af",codeBg:"#374151",codeText:"#f3f4f6",strong:"#ffffff",em:"#9ca3af",header:"#ffffff",info:"#d1d5db",related:"#d1d5db",path:"#d1d5db",example:"#d1d5db",columns:"#d1d5db",syntax:"#d1d5db"}:{tooltipBg:"#ffffff",tooltipBorder:"#e5e7eb",tooltipText:"#374151",tooltipTypeBg:"#f3f4f6",tooltipTypeText:"#6b7280",tooltipChildren:"#6b7280",codeBg:"#f9fafb",codeText:"#1f2937",strong:"#111827",em:"#6b7280",header:"#111827",info:"#374151",related:"#374151",path:"#374151",example:"#374151",columns:"#374151",syntax:"#374151"};return Et.theme({".cm-sql-hover-tooltip":{padding:"8px 12px",backgroundColor:n.tooltipBg,border:`1px solid ${n.tooltipBorder}`,borderRadius:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",fontSize:"13px",lineHeight:"1.4",maxWidth:"320px",fontFamily:"system-ui, -apple-system, sans-serif",color:n.tooltipText},".cm-sql-hover-tooltip .sql-hover-header":{marginBottom:"6px",display:"flex",alignItems:"center",gap:"6px",color:n.header},".cm-sql-hover-tooltip .sql-hover-type":{fontSize:"11px",padding:"2px 6px",backgroundColor:n.tooltipTypeBg,color:n.tooltipTypeText,borderRadius:"4px",fontWeight:"500"},".cm-sql-hover-tooltip .sql-hover-description":{color:n.info,marginBottom:"8px"},".cm-sql-hover-tooltip .sql-hover-syntax":{marginBottom:"8px",color:n.syntax},".cm-sql-hover-tooltip .sql-hover-example":{marginBottom:"4px",color:n.example},".cm-sql-hover-tooltip .sql-hover-columns":{marginBottom:"4px",color:n.columns},".cm-sql-hover-tooltip .sql-hover-related":{marginBottom:"4px",color:n.related},".cm-sql-hover-tooltip .sql-hover-path":{marginBottom:"4px",color:n.path},".cm-sql-hover-tooltip .sql-hover-info":{marginBottom:"4px",color:n.info},".cm-sql-hover-tooltip .sql-hover-children":{marginBottom:"4px",color:n.tooltipChildren,fontSize:"12px"},".cm-sql-hover-tooltip code":{backgroundColor:n.codeBg,padding:"1px 4px",borderRadius:"3px",fontSize:"12px",fontFamily:"ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace",color:n.codeText},".cm-sql-hover-tooltip strong":{fontWeight:"600",color:n.strong},".cm-sql-hover-tooltip em":{fontStyle:"italic",color:n.em}})};var FE=class{constructor(e){ve(this,"parser");ve(this,"cache",new Map);ve(this,"MAX_CACHE_SIZE",10);this.parser=e}async analyzeDocument(e){let n=e.doc.toString(),a=this.generateCacheKey(n),o=this.cache.get(a);if(o)return o;let s=await this.extractStatements(n,e);if(this.cache.set(a,s),this.cache.size>this.MAX_CACHE_SIZE){let c=this.cache.keys().next().value;c!==void 0&&this.cache.delete(c)}return s}async getStatementAtPosition(e,n){return(await this.analyzeDocument(e)).find(a=>n>=a.from&&n<=a.to)||null}async getStatementsInRange(e,n,a){return(await this.analyzeDocument(e)).filter(o=>o.from<=a&&o.to>=n)}async extractStatements(e,n){let a=[],o=this.splitByStatementSeparators(e),s=0;for(let c of o){let f=c.trim();if(f.length===0){s+=c.length;continue}let d=s+c.indexOf(f),m=d+f.length,b=n.doc.lineAt(d),_=n.doc.lineAt(m),x=this.stripComments(f);if(x.trim().length===0||x.trim()===";"){s+=c.length;continue}let S=await this.parser.parse(x,{state:n}),E=this.determineStatementType(x),L=x.endsWith(";")?x.slice(0,-1).trim():x.trim();a.push({from:d,to:m,lineFrom:b.number,lineTo:_.number,content:L,type:E,isValid:S.success}),s+=c.length}return a}splitByStatementSeparators(e){let n=[],a="",o=!1,s="",c=!1,f=!1,d=0;for(;d<e.length;){let m=e[d],b=e[d+1];if(!o&&!f&&m==="-"&&b==="-"){c=!0,a+=m+b,d+=2;continue}if(!o&&!c&&m==="/"&&b==="*"){f=!0,a+=m+b,d+=2;continue}if(f&&m==="*"&&b==="/"){f=!1,a+=m+b,d+=2;continue}if(c&&(m===`
112
+ `)}function rc(e){return`<marimo-tex class="arithmatex">||(${e.trim()}||)</marimo-tex>`}function gf(e){return`<marimo-tex class="arithmatex">||[${e.trim()}||]</marimo-tex>`}const cn={PREFIX:"file:///",of(e){return`${this.PREFIX}${e}`},is(e){return e.startsWith(this.PREFIX)},parse(e){return rn(this.is(e),`Invalid cell document URI: ${e}`),e.slice(this.PREFIX.length)}};function i1(e){return"notify"in e}function uE(e){return e.startsWith("_")&&!e.startsWith("__")}var dE=class{constructor(e){ve(this,"documentVersion",0);ve(this,"lastSnapshot",null);this.getNotebookCode=e}snapshot(){var a;let e=this.getLens(),n=((a=this.lastSnapshot)==null?void 0:a.mergedText)!==e.mergedText;return n?(this.documentVersion++,this.lastSnapshot=e,{lens:e,didChange:n,version:this.documentVersion}):{lens:e,didChange:n,version:this.documentVersion}}getLatestSnapshot(){if(!this.lastSnapshot)throw Error("No snapshots");return{lens:this.lastSnapshot,version:this.documentVersion}}getLens(){let{cellIds:e,codes:n}=this.getNotebookCode();return Y3(e,n)}},fE=()=>{let e=ld().cellHandles;return Rr.mapValues(e,n=>{var a;return(a=n.current)==null?void 0:a.editorViewOrNull})};function yf(e){let n=n1(e);return Array.isArray(n)?e:n}function vf(e){return{...e,documentation:yf(e.documentation)}}function pE(e){return e==null?null:Array.isArray(e)?e.map(n=>vf(n)):{...e,items:e.items.map(n=>vf(n))}}function hE(e){return{...e,signatures:e.signatures.map(n=>{var a;return{...n,documentation:yf(n.documentation),parameters:(a=n.parameters)==null?void 0:a.map(o=>({...o,documentation:yf(o.documentation)}))}})}}var ac=(ur=class{constructor(n,a,o=fE){ve(this,"completionItemCache",new Ql(10));ve(this,"latestDiagnosticsVersion",null);ve(this,"forwardedDiagnosticsVersion",0);this.documentUri=Zy(),this.getNotebookEditors=o,this.initialSettings=a,this.client=n,this.patchProcessNotification(),this.initializePromise.then(()=>{rn(i1(this.client),"notify is not a method on the client"),this.client.notify("workspace/didChangeConfiguration",{settings:a})}),this.snapshotter=new dE(this.getNotebookCode.bind(this))}static pruneSeenCellUris(n){for(let a of ur.SEEN_CELL_DOCUMENT_URIS){let o=cn.parse(a);n.has(o)||ur.SEEN_CELL_DOCUMENT_URIS.delete(a)}}onNotification(n){return this.client.onNotification(n)}get ready(){return this.client.ready}set ready(n){this.client.ready=n}get capabilities(){return this.client.capabilities}set capabilities(n){this.client.capabilities=n}get initializePromise(){return this.client.initializePromise}set initializePromise(n){this.client.initializePromise=n}get clientCapabilities(){return this.client.clientCapabilities}async initialize(){await this.client.initialize()}close(){this.client.close()}async resyncAllDocuments(){rn(i1(this.client),"notify is not a method on the client"),await this.client.initialize(),this.client.notify("workspace/didChangeConfiguration",{settings:this.initialSettings});let{lens:n,version:a}=this.snapshotter.snapshot();this.latestDiagnosticsVersion=null,this.forwardedDiagnosticsVersion=0,await this.client.textDocumentDidOpen({textDocument:{languageId:"python",text:n.mergedText,uri:this.documentUri,version:a}}),be.log("[lsp] Document re-synchronization complete")}getNotebookCode(){return ze.get(J3)}assertCellDocumentUri(n){rn(cn.is(n),"Execpted URI to be CellDocumentUri")}async textDocumentDidOpen(n){be.debug("[lsp] textDocumentDidOpen",n);let a=n.textDocument.uri;this.assertCellDocumentUri(a);let{lens:o,version:s}=this.snapshotter.snapshot();ur.SEEN_CELL_DOCUMENT_URIS.add(a);let c=await this.client.textDocumentDidOpen({textDocument:{languageId:n.textDocument.languageId,text:o.mergedText,uri:this.documentUri,version:s}});return c?{...c,textDocument:{...c.textDocument,text:o.mergedText}}:n}async sync(){let{lens:n,version:a,didChange:o}=this.snapshotter.snapshot(),s={textDocument:{uri:this.documentUri,version:a},contentChanges:[{text:n.mergedText}]};return o&&await this.client.textDocumentDidChange(s),{params:s,lens:n}}async textDocumentDidChange(n){if(be.debug("[lsp] textDocumentDidChange",n),n.contentChanges.length===1){let{params:a}=await this.sync();return a}return be.warn("[lsp] Unhandled textDocumentDidChange",n),this.client.textDocumentDidChange(n)}async textDocumentDefinition(n){let a=n.textDocument.uri;if(!cn.is(a))return be.warn("Invalid cell document URI",a),null;let{lens:o}=await this.sync(),s=cn.parse(a);return this.client.textDocumentDefinition({...n,textDocument:{uri:this.documentUri},position:o.transformPosition(n.position,s)})}async textDocumentSignatureHelp(n){let a=n.textDocument.uri;if(!cn.is(a))return be.warn("Invalid cell document URI",a),null;let{lens:o}=await this.sync(),s=cn.parse(a),c=await this.client.textDocumentSignatureHelp({...n,textDocument:{uri:this.documentUri},position:o.transformPosition(n.position,s)});return c?hE(c):null}textDocumentCodeAction(n){return Promise.resolve(null)}async textDocumentRename(n){var q;let a=n.textDocument.uri;if(!cn.is(a))return be.warn("Invalid cell document URI",a),null;let o=cn.parse(a),{lens:s}=await this.sync(),c=s.transformPosition(n.position,o),f=await this.client.textDocumentRename({...n,textDocument:{uri:this.documentUri},position:c});if(!f)return null;let d=(q=f.documentChanges)==null?void 0:q.flatMap(V=>"edits"in V?V.edits:[]);if(!d||d.length!==1)return be.warn("Expected exactly one edit",d),f;let m=d[0];if(!("newText"in m))return be.warn("Expected newText in edit",m),f;let b=s.getEditsForNewText(m.newText),_=new Map(b.map(V=>[V.cellId,V.text])),x=this.getNotebookEditors(),S=x[o],E=!1;if(S){let V=S.state.doc.line(n.position.line+1).from+n.position.character,{startToken:B,endToken:M}=cf(S.state.doc,V),J=S.state.doc.sliceString(B,M);E=uE(J),E&&be.debug("[lsp] Private variable rename detected, limiting to current cell",J)}let L=[],P=0;for(let[V,B]of Rr.entries(x)){if(E&&V!==o)continue;let M=_.get(V);if(M==null){be.warn("[lsp] No new code for cell during rename",V),L.push(V);continue}if(!B){be.warn("[lsp] No editor view for cell during rename",V),L.push(V);continue}wr(B)!==M&&(Ji(B,M),P++)}return L.length>0&&be.error(`[lsp] Rename partially failed: could not update ${L.length} cell(s)`,L),be.debug(`[lsp] Rename completed: updated ${P} cell(s)`),{...f,documentChanges:[{edits:[],textDocument:{uri:a,version:0}}]}}async completionItemResolve(n){let a=JSON.stringify(n),o=this.completionItemCache.get(a);if(o)return o;let s=this.client.completionItemResolve(n).then(c=>vf(c));return this.completionItemCache.set(a,s),s}async textDocumentPrepareRename(n){let a=n.textDocument.uri;if(!cn.is(a))return be.warn("Invalid cell document URI",a),null;let{lens:o}=await this.sync(),s=cn.parse(a);return this.client.textDocumentPrepareRename({...n,textDocument:{uri:this.documentUri},position:o.transformPosition(n.position,s)})}async textDocumentHover(n){be.debug("[lsp] textDocumentHover",n);let{lens:a}=await this.sync(),o=cn.parse(n.textDocument.uri),s=await this.client.textDocumentHover({...n,textDocument:{uri:this.documentUri},position:a.transformPosition(n.position,o)});return s?(typeof s.contents=="object"&&"kind"in s.contents&&(s.contents={kind:"markdown",value:s.contents.value}),s.contents=n1(s.contents)??s.contents,s.contents===""?null:(s.range&&(s.range=a.reverseRange(s.range,o)),s)):(be.debug("[lsp] no hover result"),s)}async textDocumentCompletion(n){let{lens:a}=this.snapshotter.getLatestSnapshot();if(!cn.is(n.textDocument.uri))return be.error("[lsp] Invalid cell document URI in completion request",n.textDocument.uri),null;let o=cn.parse(n.textDocument.uri);if(!o||o==="undefined")return be.error("[lsp] Invalid cellId 'undefined' in completion request",{cellId:o,uri:n.textDocument.uri,availableCellIds:a.cellIds}),null;a.cellIds.includes(o)||be.warn("[lsp] CellId in completion request not found in current lens",{cellId:o,uri:n.textDocument.uri,availableCellIds:a.cellIds});let s=a.transformPosition(n.position,o);return pE(await this.client.textDocumentCompletion({...n,textDocument:{uri:this.documentUri},position:s}))}patchProcessNotification(){rn("processNotification"in this.client,"processNotification is not a method on the client");let n=this.client.processNotification.bind(this.client),a=o=>{if(o.method==="textDocument/publishDiagnostics"){let s=o.params.version;if(s!=null){let S=this.latestDiagnosticsVersion;if(S!==null&&Number.isFinite(s)&&s<S){be.debug("[lsp] dropping stale diagnostics notification",o);return}this.latestDiagnosticsVersion=s}be.debug("[lsp] handling diagnostics",o);let c=this.snapshotter.getLatestSnapshot(),f=o.params.diagnostics,{lens:d}=c,m=++this.forwardedDiagnosticsVersion,b=new Map;for(let S of f)for(let E of d.cellIds)if(d.isInRange(S.range,E)){b.has(E)||b.set(E,[]);let L={...S,range:d.reverseRange(S.range,E)};b.get(E).push(L);break}let _=new Set(d.cellIds);ur.pruneSeenCellUris(_);let x=new Set(ur.SEEN_CELL_DOCUMENT_URIS);for(let[S,E]of b.entries()){be.debug("[lsp] diagnostics for cell",S,E);let L=cn.of(S);x.delete(L),n({...o,params:{...o.params,uri:L,version:m,diagnostics:E}})}if(x.size>0){be.debug("[lsp] clearing diagnostics",x);for(let S of x)n({method:"textDocument/publishDiagnostics",params:{uri:S,version:m,diagnostics:[]}})}return}return n(o)};this.client.processNotification=a}},ve(ur,"SEEN_CELL_DOCUMENT_URIS",new Set),ur),mE=Ol(),gE=Xa(),yE=class extends gE.Transport{constructor(n){super();ve(this,"isClosed",!1);ve(this,"hasConnectedBefore",!1);ve(this,"pendingSubscriptions",[]);this.options=n,this.delegate=void 0}createDelegate(){if(this.delegate)try{this.delegate.close()}catch(n){be.warn("Error closing old WebSocket delegate",n)}this.delegate=new mE.WebSocketTransport(this.options.getWsUrl());for(let{event:n,handler:a}of this.pendingSubscriptions)this.delegate.subscribe(n,a);return this.delegate}isDelegateClosedOrClosing(){if(!this.delegate)return!0;let n=this.delegate.connection;return n?n.readyState===WebSocket.CLOSING||n.readyState===WebSocket.CLOSED:!0}async connect(){if(this.isClosed)throw Error("Transport is closed");return this.connectionPromise||(this.connectionPromise=(async()=>{try{this.options.waitForConnection&&await this.options.waitForConnection();let n=this.delegate;(!n||this.isDelegateClosedOrClosing())&&(n=this.createDelegate()),await n.connect(),be.log("WebSocket transport connected successfully");let a=this.hasConnectedBefore;this.hasConnectedBefore=!0,a&&this.options.onReconnect&&(be.log("Calling onReconnect callback to re-synchronize state"),await this.options.onReconnect())}catch(n){throw be.error("WebSocket transport connection failed",n),this.delegate=void 0,n}finally{this.connectionPromise=void 0}})()),this.connectionPromise}close(){var n;this.isClosed=!0,(n=this.delegate)==null||n.close(),this.delegate=void 0,this.connectionPromise=void 0}subscribe(...n){super.subscribe(...n);let[a,o]=n;this.pendingSubscriptions.push({event:a,handler:o}),this.delegate&&this.delegate.subscribe(a,o)}unsubscribe(...n){let a=super.unsubscribe(...n),[o,s]=n;return this.pendingSubscriptions=this.pendingSubscriptions.filter(c=>!(c.event===o&&c.handler===s)),this.delegate&&this.delegate.unsubscribe(o,s),a}async sendData(n,a){var o;if(this.isDelegateClosedOrClosing()){be.warn("WebSocket is closed or closing, attempting to reconnect");try{await this.connect()}catch(s){throw be.error("Failed to reconnect WebSocket",s),s}}return(o=this.delegate)==null?void 0:o.sendData(n,a)}};function ic(e,n){let a=_6();return new yE({getWsUrl:()=>a.getLSPURL(e).toString(),waitForConnection:async()=>{await x6()},onReconnect:n})}la.define(),new qu;function vE(e){return e.facet(U6.readOnly)}function bE(e){return[Tw(e),Ja.of([{key:"ArrowRight",preventDefault:!0,run:n=>o1(n,e)},{key:"Tab",preventDefault:!0,run:n=>o1(n,e)}])]}function o1(e,n){if(vE(e.state))return!1;let a=e.state.doc.length;return a===0?(e.dispatch({changes:{from:0,to:a,insert:n},selection:{head:n.length,anchor:n.length}}),!0):!1}function wE(e){let{beforeText:n,linkText:a,afterText:o,onClick:s}=e;return[Tw(c=>{let f=document.createElement("span");f.append(document.createTextNode(n));let d=document.createElement("span");return d.textContent=a,d.classList.add("cm-clickable-placeholder"),d.onclick=m=>{m.stopPropagation(),s(c)},f.append(d),f.append(document.createTextNode(o)),f}),Et.theme({".cm-placeholder":{color:"var(--slate-8)"},".cm-clickable-placeholder":{cursor:"pointer !important",pointerEvents:"auto",color:"var(--slate-9)",textDecoration:"underline",textUnderlineOffset:"0.2em"},".cm-clickable-placeholder:hover":{color:"var(--sky-11)"}})]}var _E=nr(e=>{let n,a={transport:ic("pylsp",async()=>{await(n==null?void 0:n())}),rootUri:ec(),workspaceFolders:tc()},o=e==null?void 0:e.pylsp,s=["D100","D103"],c=["W292","E402","E302","E305"],f=["B018","I001"],d={pylsp:{plugins:{marimo_plugin:{enabled:!0},jedi:{auto_import_modules:["numpy"]},jedi_completion:{include_params:!0,resolve_at_most:50},flake8:{enabled:o==null?void 0:o.enable_flake8,extendIgnore:c},pydocstyle:{enabled:o==null?void 0:o.enable_pydocstyle,ignore:s},pylint:{enabled:o==null?void 0:o.enable_pylint},pyflakes:{enabled:o==null?void 0:o.enable_pyflakes},pylsp_mypy:{enabled:o==null?void 0:o.enable_mypy,live_mode:!0},ruff:{enabled:o==null?void 0:o.enable_ruff,extendIgnore:[...c,...s,...f]},signature:{formatter:o!=null&&o.enable_ruff?"ruff":"black",line_length:88}}}},m=new ac(new cs({...a}),d);return n=()=>m.resyncAllDocuments(),m}),xE=nr(e=>{let n,a=new ac(new cs({transport:ic("ty",async()=>{await(n==null?void 0:n())}),rootUri:ec(),workspaceFolders:tc(),getWorkspaceConfiguration:o=>[{disableLanguageServices:!0}]}),{});return n=()=>a.resyncAllDocuments(),a}),kE=nr(e=>{var o;let n,a=new ac(new cs({transport:ic("pyrefly",async()=>{await(n==null?void 0:n())}),rootUri:ec(),workspaceFolders:tc(),initializationOptions:{pyrefly:{displayTypeErrors:((o=e.diagnostics)==null?void 0:o.enabled)??!1?"force-on":"force-off"}}}),{});return n=()=>a.resyncAllDocuments(),a}),CE=nr(e=>{let n,a=new ac(new cs({transport:ic("basedpyright",async()=>{await(n==null?void 0:n())}),rootUri:ec(),workspaceFolders:tc()}),{});return n=()=>a.resyncAllDocuments(),a}),SE=class{constructor(){ve(this,"parser",new vy);ve(this,"type","python");ve(this,"defaultCode",this.parser.defaultCode);ve(this,"defaultMetadata",this.parser.defaultMetadata)}transformIn(e){let n=this.parser.transformIn(e);return[n.code,n.offset,n.metadata]}transformOut(e,n){let a=this.parser.transformOut(e,n);return[a.code,a.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,n,a,o,s){return[(()=>{var _,x,S,E,L;let c={defaultKeymap:!1,activateOnTyping:n.activate_on_typing,closeOnBlur:!1},f={hideOnChange:!0},d=[];(_=s==null?void 0:s.pylsp)!=null&&_.enabled&&vs("pylsp")&&d.push(_E(s)),(x=s==null?void 0:s.ty)!=null&&x.enabled&&vs("ty")&&d.push(xE(s)),(S=s==null?void 0:s.pyrefly)!=null&&S.enabled&&vs("pyrefly")&&d.push(kE(s)),(E=s==null?void 0:s.basedpyright)!=null&&E.enabled&&vs("basedpyright")&&d.push(CE(s));let m=n.signature_hint_on_typing,b=m?/(\w+|\w+\.|\/)$/:/(\w+|\w+\.|\(|\/|,)$/;if(d.length>0){let P=d.length===1?d[0]:new $3(d);return[om({client:P,languageId:"python",allowHTMLContent:!0,useSnippetOnCompletion:!0,hoverConfig:f,completionConfig:c,diagnosticsEnabled:((L=s.diagnostics)==null?void 0:L.enabled)??!1,sendIncrementalChanges:!1,signatureHelpEnabled:!0,signatureActivateOnTyping:m,signatureHelpOptions:{position:"above"},keyboardShortcuts:{signatureHelp:a.getHotkey("cell.signatureHelp").key,goToDefinition:a.getHotkey("cell.goToDefinition").key,rename:a.getHotkey("cell.renameSymbol").key},completionMatchBefore:b,onGoToDefinition:q=>{be.debug("onGoToDefinition",q),P.documentUri!==q.uri&&br().openFile({path:q.uri.replace("file://","")})}}),Dg.of(cn.of(e))]}return Fu({...c,override:[Gy]})})(),rm(),EE(o)]}};function EE(e){return e==="marimo-import"?zu.highest(bE("import marimo as mo")):e==="ai"?wE({beforeText:"Start coding or ",linkText:"generate",afterText:" with AI.",onClick:n=>{n.state.facet(ot).aiCellCompletion()}}):[]}var bf=Kh.configure({props:[V6.add({ParenthesizedExpression:Rw,ArgList:Rw})]});rm=function(){return new jw(bf,[bf.data.of({autocomplete:K8}),bf.data.of({autocomplete:Q8})])};const TE=e=>{let n;return async()=>(n||(n=e()),await n)};var oc=class{constructor(e={}){ve(this,"opts");ve(this,"parser",null);ve(this,"offsetRecord",{});ve(this,"getParser",TE(async()=>{if(this.parser)return this.parser;let e=await re(()=>import("./node-sql-parser-UQ9Ur_LP.js").then(async a=>(await a.__tla,a)).then(f6(1)),__vite__mapDeps([213,1]),import.meta.url),{Parser:n}=e.default||e;return this.parser=new n,this.parser}));this.opts=e}async parse(e,n){var s,c;this.offsetRecord={};let a=(c=(s=this.opts).getParserOptions)==null?void 0:c.call(s,n.state),o=await this.sanitizeSql(e,a);try{let f=await this.getParser();return(a==null?void 0:a.database)==="DuckDB"?this.parseWithDuckDBSupport(o,a):{success:!0,errors:[],ast:f.astify(o,a)}}catch(f){return{success:!1,errors:[this.extractErrorInfo(f,o)]}}}async sanitizeSql(e,n){if(n!=null&&n.ignoreBrackets){let{sql:a,offsetRecord:o}=OE(e);return this.offsetRecord=o,a}return e}async parseWithDuckDBSupport(e,n){let a=await this.getParser(),o=IE(e).trimStart().toLowerCase();if(o.startsWith("from")||o.includes("macro"))return{success:!0,errors:[]};let s=e;o.includes("create or replace table")&&(this.offsetRecord[e.indexOf("create or replace table")]=-11,s=e.replace(/create or replace table/i,"create table"));try{let c={...n,database:"PostgreSQL"};return{success:!0,errors:[],ast:a.astify(s,c)}}catch(c){return{success:!1,errors:[this.extractErrorInfo(c,e)]}}}extractErrorInfo(e,n){var f,d,m;let a=1,o=1,s=(e==null?void 0:e.message)||"SQL parsing error",c=e;if(c!=null&&c.location)a=((f=c.location.start)==null?void 0:f.line)||1,o=((d=c.location.start)==null?void 0:d.column)||1;else if(c!=null&&c.hash)a=c.hash.line||1,o=((m=c.hash.loc)==null?void 0:m.first_column)||1;else{let b=s.match(/line (\d+)/i),_=s.match(/column (\d+)/i);b!=null&&b[1]&&(a=parseInt(b[1],10)),_!=null&&_[1]&&(o=parseInt(_[1],10))}for(let[b,_]of Object.entries(this.offsetRecord))o>parseInt(b,10)&&(o-=_);return o>n.length&&(o=n.length),{message:this.cleanErrorMessage(s),line:Math.max(1,a),column:o,severity:"error"}}cleanErrorMessage(e){return e.replace(/^Error: /,"").replace(/Expected .* but .* found\./i,n=>n.replace(/but .* found/,"found unexpected token")).trim()}async validateSql(e,n){return(await this.parse(e,n)).errors}async extractTableReferences(e,n){var o,s;let a=n?(s=(o=this.opts).getParserOptions)==null?void 0:s.call(o,n.state):void 0;try{return(await this.getParser()).tableList(e,a).map(c=>{let f=c.split("::");return f[f.length-1]||c})}catch{return[]}}async extractColumnReferences(e,n){var o,s;let a=n!=null&&n.state?(s=(o=this.opts).getParserOptions)==null?void 0:s.call(o,n.state):void 0;try{return(await this.getParser()).columnList(e,a).map(c=>{let f=c.split("::");return f[f.length-1]||c})}catch{return[]}}};function IE(e,n=["/*","--"]){let a=[];if(n.includes("/*")&&a.push("/\\*[\\s\\S]*?\\*/"),n.includes("--")&&a.push("--[^\\n]*"),a.length===0)return e;let o=RegExp(`^\\s*(${a.join("|")})\\s*`,""),s=e,c="";for(;s!==c;)c=s,s=s.replace(o,"");return s}var LE=2;function OE(e){let n={};return{sql:e.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(\{[^}]*\})/g,(a,o,s,c,f)=>o||s?a:c?(n[f]=LE,`'${c}'`):a),offsetRecord:n}}var AE=750;function RE(e,n){let a=n.line(e.line).from+Math.max(0,e.column-1);return{from:a,to:a+1,severity:e.severity,message:e.message,source:"sql-parser"}}function PE(e={}){let n=e.parser||new oc;return g8(async a=>{let o=a.state.doc,s=o.toString();return s.trim()?(await n.validateSql(s,{state:a.state})).map(c=>RE(c,o)):[]},{delay:e.delay||AE})}function ui(e){return typeof e=="object"&&!Array.isArray(e)&&!("self"in e)}function Dr(e){return typeof e=="object"&&!Array.isArray(e)&&"self"in e&&"children"in e}function cr(e){return Array.isArray(e)}function un(e,n,a,o){let s=e.length;if(n==="string"||n==="completion"&&o&&cr(o))return"column";if(n==="namespace"&&a){if(cr(a))return"table";if(ui(a))return Object.values(a).some(c=>cr(c)||Dr(c)&&cr(c.children))?s<=1?"database":"schema":s===0?"database":"namespace"}if(n==="completion"&&a)return cr(a)?"table":(ui(a)&&Object.values(a).some(c=>cr(c)||Dr(c)&&cr(c.children)),s<=1?"database":"schema");switch(s){case 0:return"database";case 1:return"schema";default:return"namespace"}}function s1(e,n,a={}){let{maxDepth:o=10}=a;if(n===""&&Dr(e)){let c=un([],"completion",e.children);return{completion:e.self,path:[],type:"completion",semanticType:c,namespace:e.children}}let s=n.split(".").filter(c=>c.length>0);return s.length===0||s.length>o?null:wf(e,s,[],a)}function wf(e,n,a,o,s){if(n.length===0){if(Dr(e)){let m=un(a,"completion",e.children,s);return{completion:e.self,path:a,type:"completion",semanticType:m,namespace:e.children}}return{path:a,type:"namespace",semanticType:un(a,"namespace",e,s),namespace:e}}let[c,...f]=n,{caseSensitive:d=!1}=o;if(!c)return null;if(ui(e)){let m=d?Object.keys(e).find(b=>b===c):Object.keys(e).find(b=>b.toLowerCase()===c.toLowerCase());if(m){let b=e[m];if(b)return wf(b,f,[...a,m],o,e)}}else{if(Dr(e))return wf(e.children,n,a,o,e);if(cr(e)){for(let m of e)if(typeof m=="string"){if((d?m===c:m.toLowerCase()===c.toLowerCase())&&f.length===0){let b=un([...a,m],"string",void 0,e);return{value:m,path:[...a,m],type:"string",semanticType:b}}}else if((d?m.label===c:m.label.toLowerCase()===c.toLowerCase())&&f.length===0){let b=un([...a,m.label],"completion",void 0,e);return{completion:m,path:[...a,m.label],type:"completion",semanticType:b}}}}return null}function NE(e,n,a={}){let o=[];if(n.includes(".")){let s=n.lastIndexOf("."),c=n.substring(0,s),f=n.substring(s+1),d=s1(e,c,a);if(d!=null&&d.namespace)return _f(d.namespace,f,d.path,a)}else return _f(e,n,[],a);return o}function _f(e,n,a,o){let s=[],{caseSensitive:c=!1,allowPartialMatch:f=!0}=o;if(ui(e)){for(let[d,m]of Object.entries(e))if(f?c?d.startsWith(n):d.toLowerCase().startsWith(n.toLowerCase()):c?d===n:d.toLowerCase()===n.toLowerCase())if(Dr(m)){let b=un([...a,d],"completion",m.children,e);s.push({completion:m.self,path:[...a,d],type:"completion",semanticType:b,namespace:m.children})}else{let b=un([...a,d],"namespace",m,e);s.push({path:[...a,d],type:"namespace",semanticType:b,namespace:m})}}else if(Dr(e)){if(f?c?e.self.label.startsWith(n):e.self.label.toLowerCase().startsWith(n.toLowerCase()):c?e.self.label===n:e.self.label.toLowerCase()===n.toLowerCase()){let d=un([...a,e.self.label],"completion",e.children);s.push({completion:e.self,path:[...a,e.self.label],type:"completion",semanticType:d,namespace:e.children})}s.push(..._f(e.children,n,a,o))}else if(cr(e)){for(let d of e)if(typeof d=="string"){if(f?c?d.startsWith(n):d.toLowerCase().startsWith(n.toLowerCase()):c?d===n:d.toLowerCase()===n.toLowerCase()){let m=un([...a,d],"string",void 0,e);s.push({value:d,path:[...a,d],type:"string",semanticType:m})}}else if(f?c?d.label.startsWith(n):d.label.toLowerCase().startsWith(n.toLowerCase()):c?d.label===n:d.label.toLowerCase()===n.toLowerCase()){let m=un([...a,d.label],"completion",void 0,e);s.push({completion:d,path:[...a,d.label],type:"completion",semanticType:m})}}return s}function ME(e,n,a={}){let o=[],{maxDepth:s=10}=a;sc(e,[],o,s);let{caseSensitive:c=!1}=a;return o.filter(f=>f.path.some(d=>c?d===n:d.toLowerCase()===n.toLowerCase())).sort((f,d)=>{var _,x;let m=c?f.path[f.path.length-1]===n:((_=f.path[f.path.length-1])==null?void 0:_.toLowerCase())===n.toLowerCase(),b=c?d.path[d.path.length-1]===n:((x=d.path[d.path.length-1])==null?void 0:x.toLowerCase())===n.toLowerCase();return m&&!b?-1:!m&&b?1:f.path.length-d.path.length})}function sc(e,n,a,o){if(!(n.length>=o)){if(ui(e))for(let[s,c]of Object.entries(e)){let f=[...n,s];if(Dr(c)){let d=un(f,"completion",c.children,e);a.push({completion:c.self,path:f,type:"completion",semanticType:d,namespace:c.children}),sc(c.children,f,a,o)}else{let d=un(f,"namespace",c,e);a.push({path:f,type:"namespace",semanticType:d,namespace:c}),sc(c,f,a,o)}}else if(Dr(e)){let s=un(n,"completion",e.children);a.push({completion:e.self,path:n,type:"completion",semanticType:s,namespace:e.children}),sc(e.children,n,a,o)}else if(cr(e))for(let s of e)if(typeof s=="string"){let c=un([...n,s],"string",void 0,e);a.push({value:s,path:[...n,s],type:"string",semanticType:c})}else{let c=un([...n,s.label],"completion",void 0,e);a.push({completion:s,path:[...n,s.label],type:"completion",semanticType:c})}}}function l1(e,n,a={}){let{enableFuzzySearch:o=!1}=a,s=s1(e,n,a);if(s)return s;let c=NE(e,n,a);if(c.length>0)return c[0]||null;if(o){let f=ME(e,n,a);if(f.length>0)return f[0]||null}return null}function c1(e,n){if(n.size===0)return{};if(ui(e)){let a={};for(let[o,s]of Object.entries(e))if(Array.from(n).some(c=>c.toLowerCase()===o.toLowerCase()))a[o]=s;else if(ui(s)){let c=c1(s,n);Object.keys(c).length>0&&(a[o]=c)}return a}return e}function DE(e={}){let{schema:n={},keywords:a={},hoverTime:o=300,enableKeywords:s=!0,enableTables:c=!0,enableColumns:f=!0,enableFuzzySearch:d=!0,parser:m=new oc,tooltipRender:b,tooltipRenderers:_={}}=e,x=null;return Fh(async(S,E,L)=>{let{from:P,to:q,text:V}=S.state.doc.lineAt(E),B=E,M=E;x===null&&(x=typeof a=="function"?a(S):Promise.resolve(a));let J=await x;for(;B>P&&/[\w.]/.test(V[B-P-1]??"");)B--;for(;M<q&&/[\w.]/.test(V[M-P]??"");)M++;if(B===E&&L<0||M===E&&L>0)return null;let le=V.slice(B-P,M-P).toLowerCase();if(!le||le.length===0)return null;let A=typeof n=="function"?n(S):n,j=null;if(`${le}`,!j&&s&&J[le]&&(J[le],j={word:le,view:S,pos:E,tooltipType:"keyword",keywordData:{keyword:le,info:J[le]}}),!j&&(c||f)&&A){let $=S.state.doc.toString(),oe=await m.extractTableReferences($),de=new Set(oe.map(ke=>ke.toLowerCase())),he=c1(A,de),ye=l1(he,le,{enableFuzzySearch:d});!ye&&de.size===0&&(ye=l1(A,le,{enableFuzzySearch:d})),ye&&(Array.from(de),j={word:le,view:S,pos:E,tooltipType:"namespace",namespaceData:{item:ye,word:le,resolvedSchema:de.size>0?he:A}})}return j?{pos:B,end:M,above:!0,create($){if(b){let he=b(le,$,E);if(he)return{dom:he}}let oe=null;if(j.tooltipType==="keyword"&&j.keywordData)oe=_.keyword?_.keyword(j.keywordData):d1(j.keywordData);else if(j.tooltipType==="namespace"&&j.namespaceData){let he=j.namespaceData,{semanticType:ye}=he.item;oe=ye==="table"&&_.table?_.table(he):ye==="column"&&_.column?_.column(he):(ye==="database"||ye==="schema"||ye==="namespace")&&_.namespace?_.namespace(he):u1(he.item)}if(!oe)return{dom:document.createElement("div")};let de=document.createElement("div");return de.className="cm-sql-hover-tooltip",de.innerHTML=oe,{dom:de}}}:null},{hoverTime:o})}function u1(e){var s,c,f,d,m,b,_;let n=e.path.join("."),a=((s=e.completion)==null?void 0:s.label)||e.value||e.path[e.path.length-1]||"unknown",o=`<div class="sql-hover-${e.semanticType}">`;switch(o+=`<div class="sql-hover-header"><strong>${a}</strong> <span class="sql-hover-type">${e.semanticType}</span></div>`,e.semanticType){case"database":if(o+=`<div class="sql-hover-description">Database${(c=e.completion)!=null&&c.detail?`: ${e.completion.detail}`:""}</div>`,e.namespace){let x=lc(e.namespace);x>0&&(o+=`<div class="sql-hover-children">Contains ${x} schema${x===1?"":"s"}</div>`)}break;case"schema":if(o+=`<div class="sql-hover-description">Schema${(f=e.completion)!=null&&f.detail?`: ${e.completion.detail}`:""}</div>`,n&&(o+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${n}</code></div>`),e.namespace){let x=lc(e.namespace);x>0&&(o+=`<div class="sql-hover-children">Contains ${x} table${x===1?"":"s"}</div>`)}break;case"table":if(o+=`<div class="sql-hover-description">Table${(d=e.completion)!=null&&d.detail?`: ${e.completion.detail}`:""}</div>`,n){let x=e.path;x.length>1&&(o+=`<div class="sql-hover-path"><strong>Schema:</strong> <code>${x.slice(0,-1).join(".")}</code></div>`)}if(e.namespace&&cr(e.namespace)){let x=e.namespace;if(x.length>0){o+=`<div class="sql-hover-columns"><strong>Columns (${x.length}):</strong><br>`;let S=x.slice(0,8).map(E=>typeof E=="string"?E:E.label);o+=S.map(E=>`<code>${E}</code>`).join(", "),x.length>8&&(o+=`, <em>and ${x.length-8} more...</em>`),o+="</div>"}}break;case"column":if(o+=`<div class="sql-hover-description">Column${(m=e.completion)!=null&&m.detail?`: ${e.completion.detail}`:""}</div>`,n){let x=e.path;x.length>1&&(o+=`<div class="sql-hover-path"><strong>Table:</strong> <code>${x.slice(0,-1).join(".")}</code></div>`)}break;default:if(o+=`<div class="sql-hover-description">Namespace${(b=e.completion)!=null&&b.detail?`: ${e.completion.detail}`:""}</div>`,n&&(o+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${n}</code></div>`),e.namespace){let x=lc(e.namespace);x>0&&(o+=`<div class="sql-hover-children">Contains ${x} item${x===1?"":"s"}</div>`)}break}return(_=e.completion)!=null&&_.info&&typeof e.completion.info=="string"&&(o+=`<div class="sql-hover-info">${e.completion.info}</div>`),o+="</div>",o}function lc(e){return Array.isArray(e)?e.length:typeof e=="object"&&e?"self"in e&&"children"in e?1+lc(e.children):Object.keys(e).length:0}function d1(e){let{keyword:n,info:a}=e,o='<div class="sql-hover-keyword">';if(o+=`<div class="sql-hover-header"><strong>${n.toUpperCase()}</strong> <span class="sql-hover-type">keyword</span></div>`,o+=`<div class="sql-hover-description">${a.description}</div>`,a.syntax&&(o+=`<div class="sql-hover-syntax"><strong>Syntax:</strong> <code>${a.syntax}</code></div>`),a.example&&(o+=`<div class="sql-hover-example"><strong>Example:</strong><br><code>${a.example}</code></div>`),a.metadata&&typeof a.metadata=="object"&&Object.keys(a.metadata).length>0){o+='<div class="sql-hover-metadata">';for(let[s,c]of Object.entries(a.metadata))o+=`<span class="sql-hover-tag" title="${s}">${c}</span> `;o+="</div>"}return o+="</div>",o}function jE(e){let{tableName:n,columns:a,metadata:o}=e,s='<div class="sql-hover-table">';if(s+=`<div class="sql-hover-header"><strong>${n}</strong> <span class="sql-hover-type">table</span></div>`,s+=`<div class="sql-hover-description">Table with ${a.length} column${a.length===1?"":"s"}</div>`,a.length>0){s+='<div class="sql-hover-columns"><strong>Columns:</strong><br>';let c=a.slice(0,10);s+=c.map(f=>`<code>${f}</code>`).join(", "),a.length>10&&(s+=`, <em>and ${a.length-10} more...</em>`),s+="</div>"}if(o&&typeof o=="object"&&Object.keys(o).length>0){s+='<div class="sql-hover-metadata">';for(let[c,f]of Object.entries(o))s+=`<span class="sql-hover-tag" title="${c}">${f}</span> `;s+="</div>"}return s+="</div>",s}function zE(e){let{tableName:n,columnName:a,schema:o,metadata:s}=e,c='<div class="sql-hover-column">';c+=`<div class="sql-hover-header"><strong>${a}</strong> <span class="sql-hover-type">column</span></div>`,c+=`<div class="sql-hover-description">Column in table <code>${n}</code></div>`;let f=o[n];if(f&&f.length>1){let d=f.filter(m=>m!==a);if(d.length>0){c+=`<div class="sql-hover-related"><strong>Other columns in ${n}:</strong><br>`;let m=d.slice(0,8);c+=m.map(b=>`<code>${b}</code>`).join(", "),d.length>8&&(c+=`, <em>and ${d.length-8} more...</em>`),c+="</div>"}}if(s&&typeof s=="object"&&Object.keys(s).length>0){c+='<div class="sql-hover-metadata">';for(let[d,m]of Object.entries(s))c+=`<span class="sql-hover-tag" title="${d}">${m}</span> `;c+="</div>"}return c+="</div>",c}const qE={keyword:d1,table:jE,column:zE,namespace:u1},f1=(e="light")=>{let n=e==="dark"?{tooltipBg:"#1f2937",tooltipBorder:"#374151",tooltipText:"#f9fafb",tooltipTypeBg:"#374151",tooltipTypeText:"#9ca3af",tooltipChildren:"#9ca3af",codeBg:"#374151",codeText:"#f3f4f6",strong:"#ffffff",em:"#9ca3af",header:"#ffffff",info:"#d1d5db",related:"#d1d5db",path:"#d1d5db",example:"#d1d5db",columns:"#d1d5db",syntax:"#d1d5db"}:{tooltipBg:"#ffffff",tooltipBorder:"#e5e7eb",tooltipText:"#374151",tooltipTypeBg:"#f3f4f6",tooltipTypeText:"#6b7280",tooltipChildren:"#6b7280",codeBg:"#f9fafb",codeText:"#1f2937",strong:"#111827",em:"#6b7280",header:"#111827",info:"#374151",related:"#374151",path:"#374151",example:"#374151",columns:"#374151",syntax:"#374151"};return Et.theme({".cm-sql-hover-tooltip":{padding:"8px 12px",backgroundColor:n.tooltipBg,border:`1px solid ${n.tooltipBorder}`,borderRadius:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",fontSize:"13px",lineHeight:"1.4",maxWidth:"320px",fontFamily:"system-ui, -apple-system, sans-serif",color:n.tooltipText},".cm-sql-hover-tooltip .sql-hover-header":{marginBottom:"6px",display:"flex",alignItems:"center",gap:"6px",color:n.header},".cm-sql-hover-tooltip .sql-hover-type":{fontSize:"11px",padding:"2px 6px",backgroundColor:n.tooltipTypeBg,color:n.tooltipTypeText,borderRadius:"4px",fontWeight:"500"},".cm-sql-hover-tooltip .sql-hover-description":{color:n.info,marginBottom:"8px"},".cm-sql-hover-tooltip .sql-hover-syntax":{marginBottom:"8px",color:n.syntax},".cm-sql-hover-tooltip .sql-hover-example":{marginBottom:"4px",color:n.example},".cm-sql-hover-tooltip .sql-hover-columns":{marginBottom:"4px",color:n.columns},".cm-sql-hover-tooltip .sql-hover-related":{marginBottom:"4px",color:n.related},".cm-sql-hover-tooltip .sql-hover-path":{marginBottom:"4px",color:n.path},".cm-sql-hover-tooltip .sql-hover-info":{marginBottom:"4px",color:n.info},".cm-sql-hover-tooltip .sql-hover-children":{marginBottom:"4px",color:n.tooltipChildren,fontSize:"12px"},".cm-sql-hover-tooltip code":{backgroundColor:n.codeBg,padding:"1px 4px",borderRadius:"3px",fontSize:"12px",fontFamily:"ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace",color:n.codeText},".cm-sql-hover-tooltip strong":{fontWeight:"600",color:n.strong},".cm-sql-hover-tooltip em":{fontStyle:"italic",color:n.em}})};var FE=class{constructor(e){ve(this,"parser");ve(this,"cache",new Map);ve(this,"MAX_CACHE_SIZE",10);this.parser=e}async analyzeDocument(e){let n=e.doc.toString(),a=this.generateCacheKey(n),o=this.cache.get(a);if(o)return o;let s=await this.extractStatements(n,e);if(this.cache.set(a,s),this.cache.size>this.MAX_CACHE_SIZE){let c=this.cache.keys().next().value;c!==void 0&&this.cache.delete(c)}return s}async getStatementAtPosition(e,n){return(await this.analyzeDocument(e)).find(a=>n>=a.from&&n<=a.to)||null}async getStatementsInRange(e,n,a){return(await this.analyzeDocument(e)).filter(o=>o.from<=a&&o.to>=n)}async extractStatements(e,n){let a=[],o=this.splitByStatementSeparators(e),s=0;for(let c of o){let f=c.trim();if(f.length===0){s+=c.length;continue}let d=s+c.indexOf(f),m=d+f.length,b=n.doc.lineAt(d),_=n.doc.lineAt(m),x=this.stripComments(f);if(x.trim().length===0||x.trim()===";"){s+=c.length;continue}let S=await this.parser.parse(x,{state:n}),E=this.determineStatementType(x),L=x.endsWith(";")?x.slice(0,-1).trim():x.trim();a.push({from:d,to:m,lineFrom:b.number,lineTo:_.number,content:L,type:E,isValid:S.success}),s+=c.length}return a}splitByStatementSeparators(e){let n=[],a="",o=!1,s="",c=!1,f=!1,d=0;for(;d<e.length;){let m=e[d],b=e[d+1];if(!o&&!f&&m==="-"&&b==="-"){c=!0,a+=m+b,d+=2;continue}if(!o&&!c&&m==="/"&&b==="*"){f=!0,a+=m+b,d+=2;continue}if(f&&m==="*"&&b==="/"){f=!1,a+=m+b,d+=2;continue}if(c&&(m===`
113
113
  `||m==="\r")){c=!1,a+=m,d++;continue}if(c||f){a+=m,d++;continue}if(!o&&(m==="'"||m==='"'||m==="`"))o=!0,s=m,a+=m;else if(o&&m===s){if(b===s){a+=m+b,d+=2;continue}o=!1,s="",a+=m}else!o&&m===";"?(a+=m,n.push(a),a=""):a+=m;d++}return a.trim()&&n.push(a),n}determineStatementType(e){let n=e.trim().toLowerCase();return n.startsWith("select")?"select":n.startsWith("insert")?"insert":n.startsWith("update")?"update":n.startsWith("delete")?"delete":n.startsWith("create")?"create":n.startsWith("drop")?"drop":n.startsWith("alter")?"alter":n.startsWith("use")?"use":"other"}stripComments(e){let n="",a=!1,o="",s=!1,c=!1,f=0;for(;f<e.length;){let d=e[f],m=e[f+1];if(!a&&!c&&d==="-"&&m==="-"){s=!0,f+=2;continue}if(!a&&!s&&d==="/"&&m==="*"){c=!0,f+=2;continue}if(c&&d==="*"&&m==="/"){c=!1,f+=2;continue}if(s&&(d===`
114
114
  `||d==="\r")){s=!1,n+=d,f++;continue}if(s||c){f++;continue}if(!a&&(d==="'"||d==='"'||d==="`"))a=!0,o=d,n+=d;else if(a&&d===o){if(m===o){n+=d+m,f+=2;continue}a=!1,o="",n+=d}else n+=d;f++}return n}generateCacheKey(e){let n=0;for(let a=0;a<e.length;a++){let o=e.charCodeAt(a);n=(n<<5)-n+o,n&=n}return n.toString()}clearCache(){this.cache.clear()}},p1=la.define(),h1=is.define({create(){return{currentStatement:null,allStatements:[],cursorPosition:0,isFocused:!0}},update(e,n){for(let a of n.effects)if(a.is(p1))return a.value;return e}}),BE=class extends Z6{constructor(n,a,o=!0,s=!0){super();ve(this,"config");ve(this,"isCurrent");ve(this,"isValid");ve(this,"isFocused");this.config=n,this.isCurrent=a,this.isValid=o,this.isFocused=s}toDOM(){let n=document.createElement("div");n.className="cm-sql-gutter-marker";let a=this.config.backgroundColor||"#3b82f6";!this.isValid&&this.config.showInvalid!==!1&&(a=this.config.errorBackgroundColor||"#ef4444");let o;return o=this.isFocused?this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString():this.config.unfocusedOpacity===void 0?this.config.hideWhenNotFocused?"0":this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString():this.config.unfocusedOpacity.toString(),n.style.cssText=`
115
115
  background: ${a};
@@ -118,7 +118,7 @@ mark line col
118
118
  opacity: ${o};
119
119
  transition: opacity 150ms ease-in-out;
120
120
  border-radius: 1px;
121
- `,n}eq(n){return this.isCurrent===n.isCurrent&&this.isValid===n.isValid&&this.isFocused===n.isFocused&&this.config===n.config}};function VE(e,n){var d;let a=H6.empty;if((d=n.whenHide)!=null&&d.call(n,e))return a;let o=e.state.field(h1,!1);if(!o)return a;let{currentStatement:s,allStatements:c,isFocused:f}=o;try{for(let m of c){let b=(s==null?void 0:s.from)===m.from&&(s==null?void 0:s.to)===m.to;if(!m.isValid&&n.showInvalid===!1)continue;let _=new BE(n,b,m.isValid,f);for(let x=m.lineFrom;x<=m.lineTo;x++)try{if(x<1||x>e.state.doc.lines)continue;let S=e.state.doc.line(x);a=a.update({add:[_.range(S.from)]})}catch(S){console.warn("SqlGutter: Invalid line number",x,S)}}}catch(m){console.warn("SqlGutter: Error creating markers",m)}return a}function HE(e){return Et.updateListener.of(async n=>{if(!n.docChanged&&!n.selectionSet&&!n.focusChanged)return;let{state:a}=n.view,{main:o}=a.selection,s=o.head,c=await e.analyzeDocument(a),f={currentStatement:await e.getStatementAtPosition(a,s),allStatements:c,cursorPosition:s,isFocused:n.view.hasFocus};n.view.dispatch({effects:p1.of(f)})})}function $E(e){let n=e.width||3;return Et.baseTheme({".cm-sql-gutter":{width:`${n}px`,minWidth:`${n}px`},".cm-sql-gutter .cm-gutterElement":{width:`${n}px`,padding:"0",margin:"0"},".cm-sql-gutter-marker":{width:"100%",height:"100%",display:"block"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px"}})}function WE(e){return Q6({class:`cm-sql-gutter ${e.className||""}`,markers:n=>VE(n,e)})}function UE(e={}){return[h1,HE(new FE(e.parser||new oc)),$E(e),WE(e)]}function KE(e={}){let n=[],{enableLinting:a=!0,enableGutterMarkers:o=!0,enableHover:s=!0,linterConfig:c,gutterConfig:f,hoverConfig:d}=e;return a&&n.push(PE(c)),o&&n.push(UE(f)),s&&(n.push(DE(d)),d!=null&&d.theme?n.push(d.theme):n.push(f1())),n}var QE=class Gx{static jsonStringifySortKeys(){return n=>typeof n!="object"||!n?String(n):JSON.stringify(n,Object.keys(n).toSorted(),2)}constructor(n,a={}){this.delegate=n,this.toKey=a.toKey??Gx.jsonStringifySortKeys(),this.cache=new Ql(a.maxSize??128)}request(n){let a=this.toKey(n),o=this.cache.get(a);if(o!==void 0)return o;let s=this.delegate.request(n);return this.cache.set(a,s),s.catch(c=>{throw this.cache.delete(a),c})}resolve(n,a){this.delegate.resolve(n,a)}reject(n,a){this.delegate.reject(n,a)}};m_=new Sl("sql-table-preview",async(e,n)=>{await br().previewSQLTable({requestId:e,...n})}),H_=new Sl("sql-schema-list-preview",async(e,n)=>{await br().previewSQLSchemaList({requestId:e,...n})}),V_=new Sl("sql-table-list-preview",async(e,n)=>{await br().previewSQLTableList({requestId:e,...n})}),bm=new QE(new Sl("validate-sql",async(e,n)=>{await br().validateSQL({requestId:e,...n})}),{maxSize:3});var GE=er();let di;di=Te(new Map),r_=e=>{let n=(0,GE.c)(3),a=Sn(di),o;return n[0]!==e||n[1]!==a?(o=a.get(e),n[0]=e,n[1]=a,n[2]=o):o=n[2],o};function xf(e){let n=ze.get(di),a=new Map(n);a.delete(e),ze.set(di,a)}function JE(){ze.set(di,new Map)}function XE({cellId:e,errorMessage:n,dialect:a}){let o=ze.get(di),s=new Map(o),c=a==="DuckDB"?YE(n):m1(n);s.set(e,c),ze.set(di,s)}function YE(e){let{errorType:n,errorMessage:a}=m1(e),o=a,s,c=a.indexOf("LINE ");return c!==-1&&(s=a.slice(Math.max(0,c)).trim(),o=a.slice(0,Math.max(0,c)).trim()),{errorType:n,errorMessage:o,codeblock:s}}function m1(e){return{errorType:e.split(":")[0].trim(),errorMessage:e.split(":").slice(1).join(":").trim()}}function g1(e){return e.field(Nr)}function ZE(){return e=>{let n=g1(e.state).engine,a=li.getCompletionSource(n);return a&&L8(a)(e)||null}}function e4(){return e=>{let n=g1(e.state).engine,a=li.getDialect(n);return e.matchBefore(/\.\w*/)?null:M8(a,!0,(o,s)=>({label:o,type:s,info:async()=>{let c=(await t4())[o.toLocaleLowerCase()];if(!c)return null;let f=document.createElement("div");return f.innerHTML=qE.keyword({keyword:o,info:c}),f}}))(e)}}var t4=nr(async()=>{let e=await re(()=>import("./common-keywords-CvypSGuw.js").then(async a=>(await a.__tla,a)),[],import.meta.url),n=await re(()=>import("./duckdb-keywords-C63auBrb.js").then(async a=>(await a.__tla,a)),[],import.meta.url);return{...e.default.keywords,...n.default.keywords}}),n4=er(),y1=Ml("marimo:notebook-sql-mode","default",Qu);function r4(){let e=(0,n4.c)(3),[n,a]=pw(y1),o;return e[0]!==a||e[1]!==n?(o={sqlMode:n,setSQLMode:a},e[0]=a,e[1]=n,e[2]=o):o=e[2],o}function v1(){return ze.get(y1)}var a4=Hg,i4="DuckDB",b1=new qu;function kf(){return ze.get(Gi).latestEngineSelected}let w1;kd=(Af=class{constructor(){ve(this,"parser",new Zu);ve(this,"type","sql");this.sqlModeEnabled=!0}get defaultMetadata(){return{...this.parser.defaultMetadata,engine:kf()||"__marimo_duckdb"}}get defaultCode(){let e=kf();return e&&e!=="__marimo_duckdb"?`_df = mo.sql(f"""SELECT * FROM """, engine=${e})`:this.parser.defaultCode}transformIn(e){this.parser.defaultMetadata.engine=kf()||"__marimo_duckdb";let n=this.parser.transformIn(e),a=n.metadata;return a.engine&&a.engine!=="__marimo_duckdb"&&Ug(a.engine),[n.code,n.offset,a]}transformOut(e,n){let a=this.parser.transformOut(e,n);return[a.code,a.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,n,a,o,s){var f;let c=[b1.of(Kw({dialect:a4})),Ja.of([{key:"Tab",run:d=>x8(d)||i8(d),preventDefault:!0}]),Fu({defaultKeymap:!1,activateOnTyping:!0,override:[ZE(),B3,e4()]})];if(((f=s==null?void 0:s.diagnostics)==null?void 0:f.sql_linter)??!1){let d=ze.get(J8),m=new w1({getParserOptions:b=>({database:x1(b)??i4})});c.push(KE({enableLinting:!0,linterConfig:{delay:250,parser:m},enableGutterMarkers:!0,gutterConfig:{backgroundColor:"#3b82f6",errorBackgroundColor:"#ef4444",hideWhenNotFocused:!0,parser:m},hoverConfig:{schema:l4,hoverTime:300,enableKeywords:!0,enableTables:!0,enableColumns:!0,parser:m,theme:f1(d)}}),Et.updateListener.of(b=>{b.focusChanged&&m.setFocusState(b.view.hasFocus)}))}return this.sqlModeEnabled&&c.push(u4()),c}},ve(Af,"fromQuery",e=>Zu.fromQuery(e)),Af),w1=class extends oc{constructor(){super(...arguments);ve(this,"validationTimeout",null);ve(this,"VALIDATION_DELAY_MS",300);ve(this,"isFocused",!1)}setFocusState(n){this.isFocused=n}async validateWithDelay(n,a,o){return this.validationTimeout&&window.clearTimeout(this.validationTimeout),new Promise(s=>{this.validationTimeout=window.setTimeout(async()=>{var c;if(!this.isFocused){s([]);return}try{let f=await C1(n,a,o,v1());if(f.error){be.error("Failed to validate SQL",{error:f.error}),s([]);return}s(((c=f.parse_result)==null?void 0:c.errors)??[])}catch(f){be.error("Failed to validate SQL",{error:f}),s([])}},this.VALIDATION_DELAY_MS)})}async validateSql(n,a){let o=ho(a.state);if(!this.isFocused)return[];if(!Ki.has(o.engine))return super.validateSql(n,a);let s=x1(a.state);return this.validateWithDelay(n,o.engine,s)}async parse(n,a){return ho(a.state).engine==="__marimo_duckdb"?{success:!0,errors:[]}:super.parse(n,a)}};function _1(e,n){e.dispatch({effects:b1.reconfigure(Kw({dialect:n}))})}function o4(e,n){_1(e,li.getDialect(n))}function s4(e){let n=ho(e.state).engine;_1(e,li.getDialect(n))}function ho(e){return e.field(Nr)}function l4(e){let n=ho(e.state).engine,a=li.getCompletionSource(n);return a!=null&&a.schema?a.schema:{}}function x1(e){let n=ho(e).engine;return k1(n)}function k1(e){var a;let n=(a=li.getInternalDialect(e))==null?void 0:a.toLowerCase();if(!n||!Kl(n))return null;switch(n){case"postgresql":case"postgres":return"PostgreSQL";case"db2":case"db2i":return"DB2";case"mysql":return"MySQL";case"sqlite":return"Sqlite";case"mssql":case"sqlserver":case"microsoft sql server":return"TransactSQL";case"duckdb":return"DuckDB";case"mariadb":return"MariaDB";case"cassandra":return"Noql";case"athena":case"awsathena":return"Athena";case"bigquery":return"BigQuery";case"hive":return"Hive";case"redshift":return"Redshift";case"snowflake":return"Snowflake";case"flink":return"FlinkSQL";case"mongodb":case"noql":return"Noql";case"oracle":case"oracledb":case"timescaledb":case"couchbase":case"trino":case"tidb":case"singlestoredb":case"spark":case"databricks":case"datafusion":return be.debug("Unsupported dialect",{dialect:n}),null;default:return ss(n),null}}var c4=300;function u4(){return Ui.define(e=>{let n,a=null,o=e.state.facet(ua);return{update(s){if(!s.docChanged)return;let c=v1();if(c==="default")return;let f=ho(s.state).engine;if(!Ki.has(f))return;let d=s.state.doc.toString();n&&window.clearTimeout(n),n=window.setTimeout(async()=>{if(a!==d){if(a=d,d===""){xf(o);return}try{let m=k1(f),b=(await C1(d,f,m,c)).validate_result;b!=null&&b.error_message?XE({cellId:o,errorMessage:b.error_message,dialect:m}):xf(o)}catch(m){be.error("Failed to validate SQL",{error:m})}}},c4)},destroy(){n&&window.clearTimeout(n),xf(o)}}})}async function C1(e,n,a,o){let s=await bm.request({onlyParse:o==="default",engine:n,dialect:a,query:e});if(s.error)throw Error(s.error);return s}var d4=nr(()=>new SE),f4=nr(()=>new Ku),p4=nr(()=>new kd);Hn={get python(){return d4()},get markdown(){return f4()},get sql(){return p4()}};function h4(){return Object.values(Hn)}let S1;S1=er(),Ll=_e.forwardRef((e,n)=>{let a=(0,S1.c)(10),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("flex items-center justify-center peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",o),a[3]=o,a[4]=c);let f;a[5]===Symbol.for("react.memo_cache_sentinel")?(f=(0,N.jsx)(g0,{className:Pr("flex items-center justify-center text-current max-h-[14px] overflow-hidden"),children:(0,N.jsx)(F8,{className:"h-4 w-4"})}),a[5]=f):f=a[5];let d;return a[6]!==s||a[7]!==n||a[8]!==c?(d=(0,N.jsx)(Td,{ref:n,className:c,...s,children:f}),a[6]=s,a[7]=n,a[8]=c,a[9]=d):d=a[9],d}),Ll.displayName=Td.displayName,k_="_";var m4=new Set("__*.marimo.app.False.None.True.__peg_parser__.and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield.None.setup".split("."));am=function(e,n=!0){return e=e.trim(),e?(/^\d/.test(e)&&(e=`_${e}`),e=e.replaceAll(/\W/g,"_"),n?e.toLowerCase():e):"_"},M_=function(e,n){let a=new Set(n),o=e,s=f=>!a.has(f)&&!m4.has(f);if(s(e))return e;let c=1;for(;!s(o);)o=`${e}_${c}`,c++;return o},I_=function(e,n){return nm(e)?`cell-${n}`:e},nm=function(e){return e?e==="_"||e==="__":!0};var g4=er();function y4(e){let n=(0,g4.c)(15),{minWidth:a,padding:o}=e,s=a===void 0?70:a,c=o===void 0?15:o,[f,d]=(0,_e.useState)(50),m=(0,_e.useRef)(null),b=(0,_e.useRef)(null),_;n[0]===c?_=n[1]:(_=A=>{if(b.current&&m.current){let j=b.current;j.style.fontSize=window.getComputedStyle(m.current).fontSize,j.style.fontFamily=window.getComputedStyle(m.current).fontFamily,j.textContent=A;let $=j.offsetWidth;d($+c)}},n[0]=c,n[1]=_);let x=_,S;n[2]===x?S=n[3]:(S=()=>{var A;x(((A=m.current)==null?void 0:A.value)??"")},n[2]=x,n[3]=S),q8(S);let E;n[4]===x?E=n[5]:(E=A=>{x(A.target.value)},n[4]=x,n[5]=E);let L=`${f}px`,P=`${s}px`,q;n[6]!==L||n[7]!==P?(q={width:L,minWidth:P},n[6]=L,n[7]=P,n[8]=q):q=n[8];let V;n[9]!==E||n[10]!==q?(V={ref:m,type:"text",onChange:E,style:q},n[9]=E,n[10]=q,n[11]=V):V=n[11];let B=V,M;n[12]===Symbol.for("react.memo_cache_sentinel")?(M={ref:b,style:{visibility:"hidden",position:"absolute",whiteSpace:"pre"}},n[12]=M):M=n[12];let J=M,le;return n[13]===B?le=n[14]:(le={inputProps:B,spanProps:J},n[13]=B,n[14]=le),le}var v4=er();function b4({currentQuotePrefix:e,checked:n,prefix:a}){let o=e;return n?e===""?o=a:e!=="rf"&&a!==e&&(o="rf"):e===a?o="":e==="rf"&&(o=a==="r"?"f":"r"),o}let E1;E1=()=>{let e=(0,v4.c)(2),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,N.jsxs)("section",{className:"flex flex-col gap-0.5",children:[(0,N.jsxs)("header",{className:"flex items-center gap-1",children:[(0,N.jsx)("code",{className:"text-xs px-1 py-0.5 bg-(--slate-2) rounded",children:"r"}),(0,N.jsx)("span",{className:"font-semibold",children:"Raw String"})]}),(0,N.jsx)("p",{className:"text-sm text-muted-foreground",children:"Write LaTeX without escaping special characters"}),(0,N.jsx)("pre",{className:"text-xs bg-(--slate-2) p-2 rounded",children:"\\alpha \\beta"})]}),e[0]=n):n=e[0];let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=(0,N.jsxs)("div",{className:"flex flex-col gap-3.5",children:[n,(0,N.jsxs)("section",{className:"flex flex-col gap-0.5",children:[(0,N.jsxs)("header",{className:"flex items-center gap-1",children:[(0,N.jsx)("code",{className:"text-xs px-1 py-0.5 bg-(--slate-2) rounded",children:"f"}),(0,N.jsx)("span",{className:"font-semibold",children:"Format String"})]}),(0,N.jsx)("p",{className:"text-sm text-muted-foreground",children:"Interpolate Python values"}),(0,N.jsxs)("pre",{className:"text-xs bg-(--slate-2) p-2 rounded",children:["Hello ","{name}","! \u{1F601}"]})]})]}),e[1]=a):a=e[1],a},cm="data-cell-id",Zw=function(e){return{[cm]:e}},zm="data-for-cell-id",ud=function(e){return{[zm]:e}};var w4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClickHouse%3c/title%3e%3cpath%20d='M21.333%2010H24v4h-2.667ZM16%201.335h2.667v21.33H16Zm-5.333%200h2.666v21.33h-2.666ZM0%2022.665V1.335h2.667v21.33zm5.333-21.33H8v21.33H5.333Z'/%3e%3c/svg%3e",_4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDatabricks%3c/title%3e%3cpath%20d='M.95%2014.184L12%2020.403l9.919-5.55v2.21L12%2022.662l-10.484-5.96-.565.308v.77L12%2024l11.05-6.218v-4.317l-.515-.309L12%2019.118l-9.867-5.653v-2.21L12%2016.805l11.05-6.218V6.32l-.515-.308L12%2011.974%202.647%206.681%2012%201.388l7.76%204.368.668-.411v-.566L12%200%20.95%206.27v.72L12%2013.207l9.919-5.55v2.26L12%2015.52%201.516%209.56l-.565.308Z'/%3e%3c/svg%3e",x4="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAGcElEQVR4nNxZa2wcVxU+99557M6+vLazj6xjO6+maWVTl0YpLU1DU9KARNqooQhFVYJUqUWgiocqIVRESPlRoEhIqYoqgSiCItqQPkAEKUWQtlGSJtAY00R5mTjZTfze94x3HvdedMdZnKgS6s7O2kk/a7R3xvY933fOd874yhhucCyYAIWA9IOH2r+35/HUnjU96sBC8fAERQLpj0+mXjdeXM6rzy/no88uK6zolHu97EX8p/f/IWHAv38i9bsH+kIPo/ozhAJBgpR9J419je437xb62Zc7n/tcf+gRsebADYQAxLW2N/ApL/vNq4AdA7Ht2/piT4q15fAp1wEYAGEALYA18TzT1TXQ09O75qPuKbWS8NW4Lan27/pM4gWrBIgFnaIDvKZIpPPKt+nlgpMTi0q5PKqoqvZR950XAREZaz/fmHmFOFijwGHkDDu5PKGs1SlQ5gAAQ+S9U9Y/xM+Wy+WxRvaeFwE770z+OBNQbmYWwPlp63BPh3q7XQaCxAi50gP7Tldf87J3ywVszEQ2bumOf5WZAAajeWoDJjYOMM5BCECEw9miefxwduaol/1b2sQdCon/8BOZX3ETYWYiODFhvrNUC6ylFgJqzl27DxV+xD3GaGkFnl6deS4G8mJqAmRrtaGkoqxiJnazPpt9gPNVa3DvqfKrXmO0rAJ3RSLrHojHd4jMMwvBSMn+d1pSVrv37oXdz50Hx79JOXgtQGsqIAEiT8V7djtVzEiQ4w+K+t9uCmn3uNmX5rL/l8ullw5c1g80E6slFXgkuuixJVKw3y5jxEzExnV7pB3k7rr3hZDBiZl3njk+9u1mY/legSgm0cfiXbtcTziYHJmovNEXC99PZzAV41KMzaLtXGBVmaQltWfCdPLNxPNdwFdii58KYykhXM2AO5MGvTSAgw9aLnUx8zlomCxTKdeHdP14s/F8tdAiIie2RpPfAPcPNYAjRumNOwLRLZwL2rPgHAGnCF6aHPuJ5869Cr5WYFs0/S0ZkTDns9SK1BltI/JicYcEcXAX8L5R+vOblanf+hHTNwFtWGr7QiT9BAPklnWoVt5/qxrZILQI7wvyjHPrjKkfeL0y9QID76Pzavhmoa3RzNdkLMcYEKCA4aJtncjIgVs4oFnbCCGASDtRVrw3Uz7sV1xfBKiAlc2RJV+vkz9vWYMZWesTa1ER5vYEgot27YPvjJ/dXGBOwY+44JeAdaHkQxpRU9QVQGDIrPz1FjV+f/3eFcaRFcdKosicsh8x6/ClBzaEu7YLoqJNDUonVKR0UCTuRT9w9wshpAzb+qmcY2b9iFlH0xVow0r81sCiz9azfdCY3rNWSzw8a5/ZZ2ItPv9UmfiFP7Tn0HQFPhlMbuKIyOKkhThjNc4rBCtRJl5jrvO5W4mSY+beMib/4A/tOTQtYCCY2kTdszmHE7X8/tWBTtf7s7S528IYELxcuviMycWZzF80baHVgdT6/00fu3oso7Tdwa5Ypt7Aw5Zx7M1K7pf+UL4WTVWgQwqnQ5LWLexTpfblEFaT7Jrsc3GMLDw7+a9tFDj1j/YcmqpAWkn06yhERaYP6ZdeHtC6tl6deYPx4q7xY5+/YFfP+kf5WniqQELp6J6hNaNdia8s4TCojkmrjOYVHGin7qsLQdYqvb976uijk455yX/ac/AkYNLKZx9Nb/kNQkAsLJNBW9+/Uk3eJzI/ZlUG36qcfv6MXf3nmtjtO/ZO/v27/tOeA/L6iyu0pfdu7/riATF93s0fffq+toGdM5zmJ+ziuRgJpWSEgy/mXlk/Zk2f8ZfytfDcxOeM828XHH04TAIJjOTgDAlIiPNEmgQTw9Xh146UBn/aavLgVUAmkLk5IkdXFh09l62NHloaWblZjFGMONjMrsTUjqV5qzjuP90Pw9MUmrKms/2x276U0pbcO2Hlh9qUzj6GMJiclk/q5/b+Ovfqg+P29LD/dD+MhnsgSMLhnlDvPQVrOrcmfufjF2cuvI0BqVlj5GDBKmQZsJbMe9+BAZP1yU3fF+tloVV3LzSfhtEbXrWhO7Ri3ULz8PwmzoRXfTqr/+ddf+k0Dk8CEGBMOWccmC8H82bgSUAmfNO6S/q5Bc8+eBUQDXWtz1VP36gCMC4xnfPrZFw2/I9uLZi6u2aXs7ZdGWkNpcbQcAU0LX2XYYxeF/YBLwIYs0twndjnY4H/BgAA//95CrBYRwImwgAAAABJRU5ErkJggg==",k4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDuckDB%3c/title%3e%3cpath%20d='M12%200C5.363%200%200%205.363%200%2012s5.363%2012%2012%2012%2012-5.363%2012-12S18.637%200%2012%200zM9.502%207.03a4.974%204.974%200%200%201%204.97%204.97%204.974%204.974%200%200%201-4.97%204.97A4.974%204.974%200%200%201%204.532%2012a4.974%204.974%200%200%201%204.97-4.97zm6.563%203.183h2.351c.98%200%201.787.782%201.787%201.762s-.807%201.789-1.787%201.789h-2.351v-3.551z'/%3e%3c/svg%3e",C4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eGoogle%20BigQuery%3c/title%3e%3cpath%20d='M5.676%2010.595h2.052v5.244a5.892%205.892%200%200%201-2.052-2.088v-3.156zm18.179%2010.836a.504.504%200%200%201%200%20.708l-1.716%201.716a.504.504%200%200%201-.708%200l-4.248-4.248a.206.206%200%200%201-.007-.007c-.02-.02-.028-.045-.043-.066a10.736%2010.736%200%200%201-6.334%202.065C4.835%2021.599%200%2016.764%200%2010.799S4.835%200%2010.8%200s10.799%204.835%2010.799%2010.8c0%202.369-.772%204.553-2.066%206.333.025.017.052.028.074.05l4.248%204.248zm-5.028-10.632a8.015%208.015%200%201%200-8.028%208.028h.024a8.016%208.016%200%200%200%208.004-8.028zm-4.86%204.98a6.002%206.002%200%200%200%202.04-2.184v-1.764h-2.04v3.948zm-4.5.948c.442.057.887.08%201.332.072.4.025.8.025%201.2%200V7.692H9.468v9.035z'/%3e%3c/svg%3e",S4=""+new URL("iceberg-COKYXo-A.png",import.meta.url).href,E4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMotherDuck%3c/title%3e%3cg%20transform='scale(0.85)%20translate(0,%202)'%3e%3cpath%20fill='%23ff9538'%20d='M1.71%2015.86s7.45%205.32%207.89%205.59c.44.27%201.08.33%201.64.11.56-.22.98-.71%201.11-1.21s1.85-9.49%201.85-9.49c.02-.12.07-.48-.13-.83-.27-.47-.86-.71-1.38-.57-.42.12-.64.44-.7.55-.09.17-.26.45-.57.7-.24.19-.47.3-.58.34-.96.38-2.02.06-2.61-.72-.38-.48-1.04-.67-1.64-.43-.6.24-.94.84-.89%201.45.11.98-.44%201.94-1.4%202.32-.51.21-1.06.21-1.54.05-.12-.03-.51-.12-.89.09-.48.26-.74.84-.61%201.37.09.39.38.62.48.69z'%20/%3e%3cpath%20fill='%23ff9538'%20d='M14.12%204.21s2.65%208.76%202.83%209.24c.19.48.66.92%201.23%201.09.58.16%201.21.03%201.62-.28.41-.31%207.25-6.39%207.25-6.39.09-.08.35-.34.4-.74.07-.53-.25-1.09-.75-1.29-.4-.16-.78-.04-.89%200-.18.08-.48.2-.88.2-.3.01-.55-.05-.67-.08-.99-.28-1.64-1.18-1.63-2.16-.01-.61-.42-1.17-1.04-1.35-.62-.18-1.26.09-1.59.6-.51.84-1.53%201.27-2.52.99-.53-.15-.96-.48-1.25-.91-.07-.09-.33-.4-.76-.48-.54-.09-1.1.22-1.32.71-.16.37-.08.72-.04.84z'%20/%3e%3c/g%3e%3c/svg%3e",T4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMySQL%3c/title%3e%3cpath%20d='M16.405%205.501c-.115%200-.193.014-.274.033v.013h.014c.054.104.146.18.214.273.054.107.1.214.154.32l.014-.015c.094-.066.14-.172.14-.333-.04-.047-.046-.094-.08-.14-.04-.067-.126-.1-.18-.153zM5.77%2018.695h-.927a50.854%2050.854%200%2000-.27-4.41h-.008l-1.41%204.41H2.45l-1.4-4.41h-.01a72.892%2072.892%200%2000-.195%204.41H0c.055-1.966.192-3.81.41-5.53h1.15l1.335%204.064h.008l1.347-4.064h1.095c.242%202.015.384%203.86.428%205.53zm4.017-4.08c-.378%202.045-.876%203.533-1.492%204.46-.482.716-1.01%201.073-1.583%201.073-.153%200-.34-.046-.566-.138v-.494c.11.017.24.026.386.026.268%200%20.483-.075.647-.222.197-.18.295-.382.295-.605%200-.155-.077-.47-.23-.944L6.23%2014.615h.91l.727%202.36c.164.536.233.91.205%201.123.4-1.064.678-2.227.835-3.483zm12.325%204.08h-2.63v-5.53h.885v4.85h1.745zm-3.32.135l-1.016-.5c.09-.076.177-.158.255-.25.433-.506.648-1.258.648-2.253%200-1.83-.718-2.746-2.155-2.746-.704%200-1.254.232-1.65.697-.43.508-.646%201.256-.646%202.245%200%20.972.19%201.686.574%202.14.35.41.877.615%201.583.615.264%200%20.506-.033.725-.098l1.325.772.36-.622zM15.5%2017.588c-.225-.36-.337-.94-.337-1.736%200-1.393.424-2.09%201.27-2.09.443%200%20.77.167.977.5.224.362.336.936.336%201.723%200%201.404-.424%202.108-1.27%202.108-.445%200-.77-.167-.978-.5zm-1.658-.425c0%20.47-.172.856-.516%201.156-.344.3-.803.45-1.384.45-.543%200-1.064-.172-1.573-.515l.237-.476c.438.22.833.328%201.19.328.332%200%20.593-.073.783-.22a.754.754%200%2000.3-.615c0-.33-.23-.61-.648-.845-.388-.213-1.163-.657-1.163-.657-.422-.307-.632-.636-.632-1.177%200-.45.157-.81.47-1.085.315-.278.72-.415%201.22-.415.512%200%20.98.136%201.4.41l-.213.476a2.726%202.726%200%2000-1.064-.23c-.283%200-.502.068-.654.206a.685.685%200%2000-.248.524c0%20.328.234.61.666.85.393.215%201.187.67%201.187.67.433.305.648.63.648%201.168zm9.382-5.852c-.535-.014-.95.04-1.297.188-.1.04-.26.04-.274.167.055.053.063.14.11.214.08.134.218.313.346.407.14.11.28.216.427.31.26.16.555.255.81.416.145.094.293.213.44.313.073.05.12.14.214.172v-.02c-.046-.06-.06-.147-.105-.214-.067-.067-.134-.127-.2-.193a3.223%203.223%200%2000-.695-.675c-.214-.146-.682-.35-.77-.595l-.013-.014c.146-.013.32-.066.46-.106.227-.06.435-.047.67-.106.106-.027.213-.06.32-.094v-.06c-.12-.12-.21-.283-.334-.395a8.867%208.867%200%2000-1.104-.823c-.21-.134-.476-.22-.697-.334-.08-.04-.214-.06-.26-.127-.12-.146-.19-.34-.275-.514a17.69%2017.69%200%2001-.547-1.163c-.12-.262-.193-.523-.34-.763-.69-1.137-1.437-1.826-2.586-2.5-.247-.14-.543-.2-.856-.274-.167-.008-.334-.02-.5-.027-.11-.047-.216-.174-.31-.235-.38-.24-1.364-.76-1.644-.072-.18.434.267.862.422%201.082.115.153.26.328.34.5.047.116.06.235.107.356.106.294.207.622.347.897.073.14.153.287.247.413.054.073.146.107.167.227-.094.136-.1.334-.154.5-.24.757-.146%201.693.194%202.25.107.166.362.534.703.393.3-.12.234-.5.32-.835.02-.08.007-.133.048-.187v.015c.094.188.188.367.274.555.206.328.566.668.867.895.16.12.287.328.487.402v-.02h-.015c-.043-.058-.1-.086-.154-.133a3.445%203.445%200%2001-.35-.4%208.76%208.76%200%2001-.747-1.218c-.11-.21-.202-.436-.29-.643-.04-.08-.04-.2-.107-.24-.1.146-.247.273-.32.453-.127.288-.14.642-.188%201.01-.027.007-.014%200-.027.014-.214-.052-.287-.274-.367-.46-.2-.475-.233-1.238-.06-1.785.047-.14.247-.582.167-.716-.042-.127-.174-.2-.247-.303a2.478%202.478%200%2001-.24-.427c-.16-.374-.24-.788-.414-1.162-.08-.173-.22-.354-.334-.513-.127-.18-.267-.307-.368-.52-.033-.073-.08-.194-.027-.274.014-.054.042-.075.094-.09.088-.072.335.022.422.062.247.1.455.194.662.334.094.066.195.193.315.226h.14c.214.047.455.014.655.073.355.114.675.28.962.46a5.953%205.953%200%20012.085%202.286c.08.154.115.295.188.455.14.33.313.663.455.982.14.315.275.636.476.897.1.14.502.213.682.286.133.06.34.115.46.188.23.14.454.3.67.454.11.076.443.243.463.378z'/%3e%3c/svg%3e",T1=""+new URL("postgresql-q8VEBKGg.svg",import.meta.url).href,I4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eAmazon%20Redshift%3c/title%3e%3cpath%20d='M16.639%209.932a.822.822%200%200%201-.822-.82.823.823%200%200%201%201.645%200c0%20.452-.37.82-.823.82m-2.086%204.994a.823.823%200%200%201-.822-.822.822.822%200%200%201%201.645%200%20.822.822%200%200%201-.823.822m-5.004-.833a.822.822%200%201%201%20.002-1.644.822.822%200%200%201-.002%201.644m-2.083%204.578a.823.823%200%200%201-.823-.82.823.823%200%200%201%201.645%200c0%20.452-.37.82-.822.82m9.173-11.236a1.68%201.68%200%200%200-1.68%201.676c0%20.566.285%201.066.718%201.37l-.782%201.982a1.674%201.674%200%200%200-1.923%201.104l-1.753-.398a1.675%201.675%200%200%200-3.348.103c0%20.432.169.823.438%201.12l-.764%201.79c-.028-.001-.053-.008-.08-.008a1.68%201.68%200%200%200-1.68%201.676%201.68%201.68%200%200%200%203.36%200c0-.593-.312-1.112-.778-1.41l.674-1.579c.161.052.33.088.508.088.661%200%201.228-.386%201.502-.94l1.856.42a1.68%201.68%200%200%200%203.327-.325c0-.5-.224-.943-.574-1.25l.822-2.083c.053.005.104.016.157.016a1.68%201.68%200%200%200%201.68-1.676%201.68%201.68%200%200%200-1.68-1.676M12%2023.145c-4.17%200-7.286-1.252-7.286-2.37V4.79C6.14%205.938%209.131%206.547%2012%206.547c2.869%200%205.86-.609%207.286-1.756v15.983c0%201.12-3.116%202.37-7.286%202.37M12%20.856c4.293%200%207.286%201.274%207.286%202.419%200%201.143-2.993%202.418-7.286%202.418-4.293%200-7.286-1.275-7.286-2.418C4.714%202.129%207.707.855%2012%20.855m8.143%202.419C20.143%201.147%2015.947%200%2012%200%208.052%200%203.857%201.147%203.857%203.274l.002.01h-.002v17.49C3.857%2022.87%208.052%2024%2012%2024c3.947%200%208.143-1.13%208.143-3.226V3.284h-.002l.002-.01'/%3e%3c/svg%3e",L4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSnowflake%3c/title%3e%3cpath%20d='M24%203.459c0%20.646-.418%201.18-1.141%201.18-.723%200-1.142-.534-1.142-1.18%200-.647.419-1.18%201.142-1.18.723%200%201.141.533%201.141%201.18zm-.228%200c0-.533-.38-.951-.913-.951s-.913.38-.913.95c0%20.533.38.952.913.952.57%200%20.913-.419.913-.951zm-1.37-.533h.495c.266%200%20.456.152.456.38%200%20.153-.076.229-.19.305l.19.266v.038h-.266l-.19-.266h-.229v.266h-.266zm.495.228h-.229v.267h.229c.114%200%20.152-.038.152-.114.038-.077-.038-.153-.152-.153zM7.602%2012.4c.038-.151.076-.304.076-.456%200-.114-.038-.228-.038-.342-.114-.343-.304-.647-.646-.838l-4.87-2.777c-.685-.38-1.56-.152-1.94.533-.381.685-.153%201.56.532%201.94l2.701%201.56-2.701%201.56c-.685.38-.913%201.256-.533%201.94.38.685%201.256.914%201.94.533l4.832-2.777c.343-.267.571-.533.647-.876zm1.332%202.626c-.266-.038-.57.038-.837.19l-4.832%202.777c-.685.38-.913%201.256-.532%201.94.38.686%201.255.914%201.94.533l2.701-1.56v3.12c0%20.8.647%201.408%201.446%201.408.799%200%201.407-.647%201.407-1.408v-5.592c0-.761-.57-1.37-1.293-1.408zm4.946-6.088c.266.038.57-.038.837-.19l4.832-2.777c.685-.38.913-1.256.532-1.94-.38-.686-1.255-.914-1.94-.533l-2.701%201.56V1.975c0-.799-.647-1.408-1.446-1.408-.799%200-1.446.609-1.446%201.408V7.53c0%20.76.609%201.37%201.332%201.407zM3.265%205.97l4.832%202.777c.266.152.533.19.837.19.723-.038%201.331-.684%201.331-1.407V1.975c0-.799-.646-1.408-1.407-1.408-.799%200-1.446.647-1.446%201.408v3.12l-2.701-1.56c-.685-.38-1.56-.152-1.94.533-.419.646-.19%201.521.494%201.902zm9.093%206.011a.412.412%200%2000-.114-.266l-.57-.571a.346.346%200%2000-.267-.114.412.412%200%2000-.266.114l-.571.57a.411.411%200%2000-.114.267c0%20.076.038.19.114.267l.57.57a.345.345%200%2000.267.114c.076%200%20.19-.038.266-.114l.571-.57a.412.412%200%2000.114-.267zm1.598.533L11.94%2014.53c-.039.038-.153.114-.229.114h-.608a.411.411%200%2001-.267-.114L8.82%2012.514a.408.408%200%2001-.076-.229v-.608c0-.076.038-.19.114-.267l2.016-2.016a.41.41%200%2001.267-.114h.608a.41.41%200%2001.267.114l2.016%202.016a.347.347%200%2001.114.267v.608c-.076.077-.114.19-.19.229zm5.593%205.44l-4.832-2.777c-.266-.152-.57-.19-.837-.152-.723.038-1.332.684-1.332%201.408v5.554c0%20.8.647%201.408%201.408%201.408.799%200%201.446-.647%201.446-1.408v-3.12l2.7%201.56c.686.38%201.561.152%201.941-.533.419-.646.19-1.521-.494-1.94zm2.549-7.533l-2.701%201.56%202.7%201.56c.686.38.914%201.256.533%201.94-.38.685-1.255.913-1.94.533l-4.832-2.778a1.644%201.644%200%2001-.647-.798c-.037-.153-.076-.305-.076-.457%200-.114.039-.228.039-.342.114-.343.342-.647.646-.837l4.832-2.778c.685-.38%201.56-.152%201.94.533.457.609.19%201.484-.494%201.864'/%3e%3c/svg%3e",O4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eApache%20Spark%3c/title%3e%3cpath%20d='M10.812%200c-.425.013-.845.215-1.196.605a3.593%203.593%200%2000-.493.722c-.355.667-.425%201.415-.556%202.143a551.9%20551.9%200%2000-.726%204.087c-.027.16-.096.227-.244.273C5.83%208.386%204.06%208.94%202.3%209.514c-.387.125-.773.289-1.114.506-1.042.665-1.196%201.753-.415%202.71.346.422.79.715%201.284.936%201.1.49%202.202.976%203.3%201.47.019.01.036.013.053.019h-.004l1.306.535c0%20.023.002.045%200%20.073-.2%202.03-.39%204.063-.58%206.095-.04.419-.012.831.134%201.23.317.87%201.065%201.148%201.881.701.372-.204.666-.497.937-.818%201.372-1.623%202.746-3.244%204.113-4.872.111-.133.205-.15.363-.098.349.117.697.231%201.045.347h.001c.02.012.045.02.073.03l.142.042c1.248.416%202.68.775%203.929%201.19.4.132.622.164%201.045.098.311-.048.592-.062.828-.236.602-.33.995-.957.988-1.682-.005-.427-.154-.813-.35-1.186-.82-1.556-1.637-3.113-2.461-4.666-.078-.148-.076-.243.037-.375%201.381-1.615%202.756-3.236%204.133-4.855.272-.32.513-.658.653-1.058.308-.878-.09-1.57-1-1.741a2.783%202.783%200%2000-1.235.069c-1.974.521-3.947%201.041-5.918%201.57-.175.047-.26.015-.355-.144a353.08%20353.08%200%2000-2.421-4.018%204.61%204.61%200%2000-.652-.849c-.371-.37-.802-.549-1.227-.536zm.172%203.703a.592.592%200%2001.189.211c.87%201.446%201.742%202.89%202.609%204.338.07.118.135.16.277.121%201.525-.41%203.052-.813%204.579-1.217.367-.098.735-.193%201.103-.289a.399.399%200%2001-.1.2c-1.259%201.48-2.516%202.962-3.779%204.438-.11.13-.12.22-.04.37.937%201.803%201.768%203.309%202.498%204.76l-3.696-1.019c-.538-.18-1.077-.358-1.615-.539-.163-.055-.25-.03-.36.1-1.248%201.488-2.504%202.97-3.759%204.454a.398.398%200%2001-.18.132c.035-.378.068-.757.104-1.136.149-1.572.297-3.144.451-4.716-.03-.318.117-.405-.322-.545-1.493-.593-3.346-1.321-4.816-1.905a.595.595%200%2001.24-.134c1.797-.57%203.595-1.14%205.394-1.705.127-.04.199-.092.211-.233.013-.148.05-.294.076-.441.241-1.363.483-2.726.726-4.088.068-.386.14-.771.21-1.157z'/%3e%3c/svg%3e",A4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSQLite%3c/title%3e%3cpath%20d='M21.678.521c-1.032-.92-2.28-.55-3.513.544a8.71%208.71%200%200%200-.547.535c-2.109%202.237-4.066%206.38-4.674%209.544.237.48.422%201.093.544%201.561a13.044%2013.044%200%200%201%20.164.703s-.019-.071-.096-.296l-.05-.146a1.689%201.689%200%200%200-.033-.08c-.138-.32-.518-.995-.686-1.289-.143.423-.27.818-.376%201.176.484.884.778%202.4.778%202.4s-.025-.099-.147-.442c-.107-.303-.644-1.244-.772-1.464-.217.804-.304%201.346-.226%201.478.152.256.296.698.422%201.186.286%201.1.485%202.44.485%202.44l.017.224a22.41%2022.41%200%200%200%20.056%202.748c.095%201.146.273%202.13.5%202.657l.155-.084c-.334-1.038-.47-2.399-.41-3.967.09-2.398.642-5.29%201.661-8.304%201.723-4.55%204.113-8.201%206.3-9.945-1.993%201.8-4.692%207.63-5.5%209.788-.904%202.416-1.545%204.684-1.931%206.857.666-2.037%202.821-2.912%202.821-2.912s1.057-1.304%202.292-3.166c-.74.169-1.955.458-2.362.629-.6.251-.762.337-.762.337s1.945-1.184%203.613-1.72C21.695%207.9%2024.195%202.767%2021.678.521m-18.573.543A1.842%201.842%200%200%200%201.27%202.9v16.608a1.84%201.84%200%200%200%201.835%201.834h9.418a22.953%2022.953%200%200%201-.052-2.707c-.006-.062-.011-.141-.016-.2a27.01%2027.01%200%200%200-.473-2.378c-.121-.47-.275-.898-.369-1.057-.116-.197-.098-.31-.097-.432%200-.12.015-.245.037-.386a9.98%209.98%200%200%201%20.234-1.045l.217-.028c-.017-.035-.014-.065-.031-.097l-.041-.381a32.8%2032.8%200%200%201%20.382-1.194l.2-.019c-.008-.016-.01-.038-.018-.053l-.043-.316c.63-3.28%202.587-7.443%204.8-9.791.066-.069.133-.128.198-.194Z'/%3e%3c/svg%3e",R4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSupabase%3c/title%3e%3cpath%20d='M11.9%201.036c-.015-.986-1.26-1.41-1.874-.637L.764%2012.05C-.33%2013.427.65%2015.455%202.409%2015.455h9.579l.113%207.51c.014.985%201.259%201.408%201.873.636l9.262-11.653c1.093-1.375.113-3.403-1.645-3.403h-9.642z'/%3e%3c/svg%3e",P4="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3c!--%20Generated%20by%20Pixelmator%20Pro%203.6.17%20--%3e%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Option2SymbolB'%3e%3cg%20id='Layer1-2'%3e%3cg%20id='Group'%20opacity='0.4'%3e%3cpath%20id='Path'%20fill='%23d53c97'%20stroke='none'%20d='M%2017.016802%2012.188573%20C%2017.016802%209.607646%2015.86018%207.293022%2014.039526%205.731081%20C%2013.942595%205.70038%2013.844628%205.671406%2013.745972%205.645189%20C%2013.131133%205.809095%2012.54265%206.059378%2011.998103%206.388559%20C%2013.964327%207.575191%2015.281006%209.730104%2015.281006%2012.188573%20C%2015.279476%2014.563734%2014.033739%2016.764488%2011.998103%2017.988243%20C%2012.542634%2018.317537%2013.131119%2018.567936%2013.745972%2018.731958%20C%2013.844628%2018.705742%2013.942595%2018.67642%2014.039526%2018.645721%20C%2015.86018%2017.084126%2017.016802%2014.769501%2017.016802%2012.188573%20Z'/%3e%3cpath%20id='path1'%20fill='%23d53c97'%20stroke='none'%20d='M%2013.897406%205.609659%20L%2013.894991%205.60759%20C%2013.844973%205.619663%2013.7953%205.631737%2013.745972%205.645189%20C%2013.79599%205.631737%2013.847043%205.622078%2013.897406%205.609659%20Z'/%3e%3cpath%20id='path2'%20fill='%23d53c97'%20stroke='none'%20d='M%201.735796%2012.188573%20C%201.735796%209.164728%203.728925%206.59622%206.470945%205.729357%20C%207.554634%204.797861%208.856011%204.155121%2010.254373%203.860756%20C%209.680216%203.740549%209.095179%203.679977%208.508574%203.68%20C%203.816888%203.68%20-0%207.496887%20-0%2012.188573%20C%20-0%2016.880259%203.816888%2020.697147%208.508574%2020.697147%20C%209.0952%2020.697229%209.680255%2020.636539%2010.254373%2020.516048%20C%208.855971%2020.221794%207.554568%2019.579041%206.470945%2018.647446%20C%203.728925%2017.780582%201.735796%2015.213453%201.735796%2012.188573%20Z'/%3e%3cpath%20id='path3'%20fill='%23d53c97'%20stroke='none'%20d='M%2013.745972%2018.731958%20C%2013.7953%2018.745068%2013.844973%2018.757484%2013.894991%2018.769558%20C%2013.894991%2018.769558%2013.896715%2018.769558%2013.897406%2018.767488%20C%2013.847043%2018.754379%2013.79599%2018.745411%2013.745972%2018.731958%20Z'/%3e%3c/g%3e%3cpath%20id='path4'%20fill='%23ff3b65'%20stroke='none'%20d='M%2020.508402%2012.188573%20C%2020.508402%209.606611%2019.351088%207.290262%2017.5294%205.729357%20C%2016.301817%205.342468%2014.989366%205.313629%2013.745972%205.646223%20C%2016.636665%206.418224%2018.772606%209.058484%2018.772606%2012.189609%20C%2018.772606%2015.320732%2016.636665%2017.960991%2013.745972%2018.731958%20C%2014.98947%2019.064316%2016.301983%2019.034998%2017.5294%2018.647446%20C%2019.419907%2017.034296%2020.508638%2014.673781%2020.508402%2012.188573%20Z'/%3e%3cpath%20id='path5'%20fill='%23ff3b65'%20stroke='none'%20d='M%209.962543%2018.647446%20C%207.220525%2017.780582%205.227395%2015.213453%205.227395%2012.188573%20C%205.227395%209.163693%207.220525%206.59622%209.962543%205.729357%20C%2011.046233%204.797861%2012.34761%204.155121%2013.745972%203.860756%20C%2013.171818%203.74053%2012.586779%203.679956%2012.000173%203.68%20C%207.308832%203.68%203.491599%207.496887%203.491599%2012.188573%20C%203.491599%2016.880259%207.308487%2020.697147%2012.000173%2020.697147%20C%2012.586799%2020.697247%2013.171857%2020.636557%2013.745972%2020.516048%20C%2012.34757%2020.221794%2011.046167%2019.579041%209.962543%2018.647446%20Z'/%3e%3cpath%20id='path6'%20fill='%23383838'%20stroke='none'%20d='M%2015.491772%203.68%20C%2010.800431%203.68%206.983198%207.496887%206.983198%2012.188573%20C%206.983198%2016.880259%2010.800086%2020.697147%2015.491772%2020.697147%20C%2020.183456%2020.697147%2024%2016.880259%2024%2012.188573%20C%2024%207.496887%2020.183456%203.68%2015.491772%203.68%20Z%20M%2022.264549%2012.188573%20C%2022.264549%2015.923018%2019.226215%2018.961351%2015.491772%2018.961351%20C%2011.757326%2018.961351%208.718994%2015.923018%208.718994%2012.188573%20C%208.718994%208.454128%2011.757326%205.415796%2015.491772%205.415796%20C%2019.226215%205.415796%2022.264549%208.454128%2022.264549%2012.188573%20Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",N4=""+new URL("trino-DFsJbQoT.svg",import.meta.url).href,M4=er(),D4={sqlite:A4,duckdb:k4,motherduck:E4,postgres:T1,postgresql:T1,mysql:T4,snowflake:L4,databricks:_4,clickhouse:w4,timeplus:P4,bigquery:C4,trino:N4,iceberg:S4,datafusion:x4,pyspark:O4,redshift:I4,supabase:R4};tm=e=>{let n=(0,M4.c)(11),{name:a,className:o}=e,s=D4[a.toLowerCase()];if(!s){let d;n[0]===o?d=n[1]:(d=Pr("mt-0.5",o),n[0]=o,n[1]=d);let m;return n[2]===d?m=n[3]:(m=(0,N.jsx)(fs,{className:d}),n[2]=d,n[3]=m),m}let c;n[4]!==o||n[5]!==s?(c=Pr("invert-[.5] dark:invert-[.7]",o,s.endsWith(".png")&&"brightness-100 dark:brightness-100 invert-0 dark:invert-0"),n[4]=o,n[5]=s,n[6]=c):c=n[6];let f;return n[7]!==a||n[8]!==c||n[9]!==s?(f=(0,N.jsx)("img",{src:s,alt:a,className:c}),n[7]=a,n[8]=c,n[9]=s,n[10]=f):f=n[10],f};var Cf=er();const j4=e=>{let n=(0,Cf.c)(34),{selectedEngine:a,onChange:o,cellId:s}=e,c=Sn(wd),f=[],d=[];for(let[we,ue]of c.entries())Ki.has(we)?f.push(ue):d.push(ue);let m=C8(),b=a&&!c.has(a),_;n[0]!==c||n[1]!==o||n[2]!==m?(_=we=>{if(we===I1){window.open(L1,"_blank");return}let ue=c.get(we);ue&&(m(),o(ue.name),Ug(ue.name))},n[0]=c,n[1]=o,n[2]=m,n[3]=_):_=n[3];let x=_,S=V4,E=z6,L;n[4]===s?L=n[5]:(L=ud(s),n[4]=s,n[5]=L);let P;n[6]===Symbol.for("react.memo_cache_sentinel")?(P=(0,N.jsx)(P6,{placeholder:"Select an engine"}),n[6]=P):P=n[6];let q;n[7]===L?q=n[8]:(q=(0,N.jsx)(q4,{...L,children:P}),n[7]=L,n[8]=q);let V=M6,B;n[9]===s?B=n[10]:(B=ud(s),n[9]=s,n[10]=B);let M=D6,J;n[11]===Symbol.for("react.memo_cache_sentinel")?(J=(0,N.jsx)(R6,{children:"Database connections"}),n[11]=J):J=n[11];let le;n[12]!==b||n[13]!==a?(le=b&&(0,N.jsx)(jh,{value:a,children:(0,N.jsxs)("div",{className:"flex items-center gap-1 opacity-50",children:[(0,N.jsx)(Fm,{className:"h-3 w-3"}),(0,N.jsx)("span",{className:"truncate",children:Xg(a)})]})},a),n[12]=b,n[13]=a,n[14]=le):le=n[14];let A=S(d),j=d.length>0&&(0,N.jsx)(Sw,{}),$=S(f),oe;n[15]===Symbol.for("react.memo_cache_sentinel")?(oe=(0,N.jsx)(Sw,{}),n[15]=oe):oe=n[15];let de;n[16]===Symbol.for("react.memo_cache_sentinel")?(de=(0,N.jsx)(jh,{className:"text-muted-foreground",value:I1,children:(0,N.jsxs)("a",{className:"flex items-center gap-1",href:L1,target:"_blank",rel:"noreferrer",children:[(0,N.jsx)(H8,{className:"h-3 w-3"}),(0,N.jsx)("span",{children:"How to add a database connection"})]})}),n[16]=de):de=n[16];let he;n[17]!==M||n[18]!==j||n[19]!==$||n[20]!==J||n[21]!==le||n[22]!==A?(he=(0,N.jsxs)(M,{children:[J,le,A,j,$,oe,de]}),n[17]=M,n[18]=j,n[19]=$,n[20]=J,n[21]=le,n[22]=A,n[23]=he):he=n[23];let ye;n[24]!==V||n[25]!==he||n[26]!==B?(ye=(0,N.jsx)(V,{...B,children:he}),n[24]=V,n[25]=he,n[26]=B,n[27]=ye):ye=n[27];let ke;return n[28]!==E||n[29]!==x||n[30]!==a||n[31]!==ye||n[32]!==q?(ke=(0,N.jsx)("div",{className:"flex flex-row gap-1 items-center",children:(0,N.jsxs)(E,{value:a,onValueChange:x,children:[q,ye]})}),n[28]=E,n[29]=x,n[30]=a,n[31]=ye,n[32]=q,n[33]=ke):ke=n[33],ke};var I1="__help__",L1="http://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database";const z4=()=>{let e=(0,Cf.c)(16),{sqlMode:n,setSQLMode:a}=r4(),o;e[0]!==a||e[1]!==n?(o=()=>{let E=n==="validate"?"default":"validate";E==="default"&&JE(),a(E)},e[0]=a,e[1]=n,e[2]=o):o=e[2];let s=o,c=H4,f=$4,d;e[3]===n?d=e[4]:(d=f(n),e[3]=n,e[4]=d);let m;e[5]===n?m=e[6]:(m=c(n),e[5]=n,e[6]=m);let b=n==="validate"?"Validate":"Default",_;e[7]===b?_=e[8]:(_=(0,N.jsx)("span",{className:"ml-1",children:b}),e[7]=b,e[8]=_);let x;e[9]!==s||e[10]!==m||e[11]!==_?(x=(0,N.jsxs)(Ew,{variant:"ghost",size:"sm",onClick:s,className:"h-5 px-1.5 text-xs border-border shadow-none hover:bg-accent",children:[m,_]}),e[9]=s,e[10]=m,e[11]=_,e[12]=x):x=e[12];let S;return e[13]!==d||e[14]!==x?(S=(0,N.jsx)("div",{className:"flex flex-row gap-1 items-center",children:(0,N.jsx)(zh,{delayDuration:300,content:d,children:x})}),e[13]=d,e[14]=x,e[15]=S):S=e[15],S};var q4=e=>{let n=(0,Cf.c)(6),a,o;n[0]===e?(a=n[1],o=n[2]):({children:a,...o}=e,n[0]=e,n[1]=a,n[2]=o);let s;return n[3]!==a||n[4]!==o?(s=(0,N.jsx)(j6,{className:"text-xs border-border shadow-none! ring-0! h-5 px-1.5 hover:bg-accent transition-colors",...o,children:a}),n[3]=a,n[4]=o,n[5]=s):s=n[5],s};function F4(e){return e.source!=="iceberg"}function B4(e){return(0,N.jsx)(jh,{value:e.name,children:(0,N.jsxs)("div",{className:"flex items-center gap-1",children:[(0,N.jsx)(tm,{className:"h-3 w-3",name:e.dialect}),(0,N.jsx)("span",{className:"truncate ml-0.5",children:Xg(e.display_name)})]})},e.name)}function V4(e){return e=e.filter(F4),e.map(B4)}function H4(e){return e==="validate"?(0,N.jsx)(ef,{className:"h-3 w-3"}):(0,N.jsx)(Uh,{className:"h-3 w-3"})}function $4(e){return e==="validate"?(0,N.jsxs)("div",{className:"text-xs",children:[(0,N.jsxs)("div",{className:"font-semibold mb-1 flex flex-row items-center gap-1",children:[(0,N.jsx)(ef,{className:"h-3 w-3"}),"Validate Mode"]}),(0,N.jsx)("p",{children:"Queries are validated as you write them"})]}):(0,N.jsxs)("div",{className:"text-xs",children:[(0,N.jsxs)("div",{className:"font-semibold mb-1 flex flex-row items-center gap-1",children:[(0,N.jsx)(Uh,{className:"h-3 w-3"}),"Default Mode"]}),(0,N.jsx)("p",{children:"Standard editing"})]})}var O1=er(),A1=()=>{let e=(0,O1.c)(1),n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,N.jsx)("div",{className:"h-4 border-r border-border"}),e[0]=n):n=e[0],n};const W4=e=>{let n=(0,O1.c)(102),{view:a}=e,o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o={minWidth:50},n[0]=o):o=n[0];let{spanProps:s,inputProps:c}=y4(o),f;n[1]===a.state?f=n[2]:(f=a.state.field(Bn),n[1]=a.state,n[2]=f);let d=f,m;n[3]===a.state?m=n[4]:(m=a.state.facet(ua),n[3]=a.state,n[4]=m);let b=m,_;n[5]===Symbol.for("react.memo_cache_sentinel")?(_=(0,N.jsx)("div",{}),n[5]=_):_=n[5];let x=_,S=!1,E;n[6]===a?E=n[7]:(E=V=>{a.dispatch({effects:rd.of(V),changes:{from:0,to:a.state.doc.length,insert:a.state.doc.toString()}})},n[6]=a,n[7]=E);let L=E;if(d instanceof kd){let V;n[8]===a.state?V=n[9]:(V=a.state.field(Nr),n[8]=a.state,n[9]=V);let B=V;S=!0;let M;n[10]===L?M=n[11]:(M=Tt=>{let Pt=am(Tt.currentTarget.value,!1);Tt.currentTarget.value=Pt,L({dataframeName:Pt})},n[10]=L,n[11]=M);let J=M,le;n[12]!==L||n[13]!==a?(le=Tt=>{L({engine:Tt}),o4(a,Tt)},n[12]=L,n[13]=a,n[14]=le):le=n[14];let A=le,j;n[15]===Symbol.for("react.memo_cache_sentinel")?(j=(0,N.jsx)("span",{className:"select-none",children:"Output variable: "}),n[15]=j):j=n[15];let $;n[16]===c?$=n[17]:($=Tt=>{var Pt;(Pt=c.onChange)==null||Pt.call(c,Tt)},n[16]=c,n[17]=$);let oe;n[18]===J?oe=n[19]:(oe=Tt=>{Tt.key==="Enter"&&Tt.shiftKey&&J(Tt)},n[18]=J,n[19]=oe);let de;n[20]!==c||n[21]!==B.dataframeName||n[22]!==J||n[23]!==$||n[24]!==oe?(de=(0,N.jsx)("input",{...c,defaultValue:B.dataframeName,onChange:$,onBlur:J,onKeyDown:oe,className:"min-w-14 w-auto border border-border rounded px-1 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"}),n[20]=c,n[21]=B.dataframeName,n[22]=J,n[23]=$,n[24]=oe,n[25]=de):de=n[25];let he;n[26]===s?he=n[27]:(he=(0,N.jsx)("span",{...s}),n[26]=s,n[27]=he);let ye;n[28]!==de||n[29]!==he?(ye=(0,N.jsxs)("label",{className:"flex gap-2 items-center",children:[j,de,he]}),n[28]=de,n[29]=he,n[30]=ye):ye=n[30];let ke;n[31]!==b||n[32]!==B.engine||n[33]!==A?(ke=(0,N.jsx)(j4,{selectedEngine:B.engine,onChange:A,cellId:b}),n[31]=b,n[32]=B.engine,n[33]=A,n[34]=ke):ke=n[34];let we;n[35]===B.engine?we=n[36]:(we=B.engine==="__marimo_duckdb"&&(0,N.jsx)(z4,{}),n[35]=B.engine,n[36]=we);let ue;n[37]!==B.engine||n[38]!==a?(ue=async()=>{await FC(a,B.engine)},n[37]=B.engine,n[38]=a,n[39]=ue):ue=n[39];let ie;n[40]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,N.jsx)(Xm,{className:"h-3 w-3"}),n[40]=ie):ie=n[40];let ee;n[41]===ue?ee=n[42]:(ee=(0,N.jsx)(zh,{content:"Format SQL",children:(0,N.jsx)(Ew,{variant:"text",size:"icon",onClick:ue,children:ie})}),n[41]=ue,n[42]=ee);let W;n[43]===Symbol.for("react.memo_cache_sentinel")?(W=(0,N.jsx)(A1,{}),n[43]=W):W=n[43];let Ie;n[44]===L?Ie=n[45]:(Ie=Tt=>{L({showOutput:!Tt.target.checked})},n[44]=L,n[45]=Ie);let He=!B.showOutput,et;n[46]!==Ie||n[47]!==He?(et=(0,N.jsx)("input",{type:"checkbox",onChange:Ie,checked:He}),n[46]=Ie,n[47]=He,n[48]=et):et=n[48];let Fe;n[49]===Symbol.for("react.memo_cache_sentinel")?(Fe=(0,N.jsx)("span",{className:"select-none",children:"Hide output"}),n[49]=Fe):Fe=n[49];let Ne;n[50]===et?Ne=n[51]:(Ne=(0,N.jsxs)("label",{className:"flex items-center gap-2",children:[et,Fe]}),n[50]=et,n[51]=Ne);let Le;n[52]!==we||n[53]!==ee||n[54]!==Ne?(Le=(0,N.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[we,ee,W,Ne]}),n[52]=we,n[53]=ee,n[54]=Ne,n[55]=Le):Le=n[55];let Me;n[56]!==ye||n[57]!==ke||n[58]!==Le?(Me=(0,N.jsxs)("div",{className:"flex flex-1 gap-2 items-center",children:[ye,ke,Le]}),n[56]=ye,n[57]=ke,n[58]=Le,n[59]=Me):Me=n[59],x=Me}if(d instanceof Ku){S=!0;let V,B,M,J,le,A,j,$,oe,de;if(n[60]!==L||n[61]!==a.state){let{quotePrefix:Ie}=a.state.field(Nr);B=Ie,B===void 0&&(B="r",L({quotePrefix:B})),de=(He,et)=>{typeof et=="boolean"&&L({quotePrefix:b4({currentQuotePrefix:B,checked:et,prefix:He})})},J="flex flex-row w-full justify-end gap-1.5 items-center",oe="flex items-center gap-1.5",n[72]===Symbol.for("react.memo_cache_sentinel")?(M=(0,N.jsx)("span",{children:"r"}),n[72]=M):M=n[72],V=Ll,A="Toggle raw string",j="w-3 h-3",$=B.includes("r"),le=He=>{de("r",He)},n[60]=L,n[61]=a.state,n[62]=V,n[63]=B,n[64]=M,n[65]=J,n[66]=le,n[67]=A,n[68]=j,n[69]=$,n[70]=oe,n[71]=de}else V=n[62],B=n[63],M=n[64],J=n[65],le=n[66],A=n[67],j=n[68],$=n[69],oe=n[70],de=n[71];let he;n[73]!==V||n[74]!==le||n[75]!==A||n[76]!==j||n[77]!==$?(he=(0,N.jsx)(V,{"aria-label":A,className:j,checked:$,onCheckedChange:le}),n[73]=V,n[74]=le,n[75]=A,n[76]=j,n[77]=$,n[78]=he):he=n[78];let ye;n[79]!==M||n[80]!==he||n[81]!==oe?(ye=(0,N.jsxs)("div",{className:oe,children:[M,he]}),n[79]=M,n[80]=he,n[81]=oe,n[82]=ye):ye=n[82];let ke;n[83]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,N.jsx)("span",{children:"f"}),n[83]=ke):ke=n[83];let we;n[84]===B?we=n[85]:(we=B.includes("f"),n[84]=B,n[85]=we);let ue;n[86]===de?ue=n[87]:(ue=Ie=>{de("f",Ie)},n[86]=de,n[87]=ue);let ie;n[88]!==we||n[89]!==ue?(ie=(0,N.jsxs)("div",{className:"flex items-center gap-1.5",children:[ke,(0,N.jsx)(Ll,{"aria-label":"Toggle f-string",className:"w-3 h-3",checked:we,onCheckedChange:ue})]}),n[88]=we,n[89]=ue,n[90]=ie):ie=n[90];let ee;n[91]===Symbol.for("react.memo_cache_sentinel")?(ee=(0,N.jsx)(zh,{content:(0,N.jsx)(E1,{}),children:(0,N.jsx)(vd,{className:"w-3 h-3"})}),n[91]=ee):ee=n[91];let W;n[92]!==J||n[93]!==ye||n[94]!==ie?(W=(0,N.jsxs)("div",{className:J,children:[ye,ie,ee]}),n[92]=J,n[93]=ye,n[94]=ie,n[95]=W):W=n[95],x=W}let P;n[96]===S?P=n[97]:(P=S&&(0,N.jsx)(A1,{}),n[96]=S,n[97]=P);let q;return n[98]!==x||n[99]!==d.type||n[100]!==P?(q=(0,N.jsx)(q6,{children:(0,N.jsxs)("div",{className:"flex justify-between items-center gap-4 pl-2 pt-2",children:[x,P,d.type]})}),n[98]=x,n[99]=d.type,n[100]=P,n[101]=q):q=n[101],q};var Sf=new qu;Yu=la.define(),Bn=is.define({create(){return Hn.python},update(e,n){for(let a of n.effects)if(a.is(Yu))return a.value;return e},provide:e=>qh.from(e,n=>n.type==="python"?null:a=>HC(a,W4))});function U4(){let e=h4(),n=(a,o)=>{let s=e[o%e.length];return s.isSupported(a)?s:n(a,o+1)};return[Ja.of([{key:"F4",preventDefault:!0,run:a=>{let o=a.state.field(Bn),s=e.findIndex(f=>f.type===o.type),c=n(a.state.doc.toString(),s+1);return o===c?!1:(R1({view:a,nextLanguage:c,opts:{keepCodeAsIs:!1}}),!0)}}])]}function R1({view:e,nextLanguage:n,opts:a}){let o=e.state.field(Bn),s=e.state.doc.toString(),c=e.state.facet(qg),f=e.state.facet(Fg),d=e.state.facet(Yd),m=e.state.facet(Ul),b=e.state.facet(Bg),_=e.state.field(Nr),x=e.state.selection.main.head,S;if(a.keepCodeAsIs)S=s,o.type!==n.type&&(_={...n.defaultMetadata});else{let[E,L]=o.transformOut(s,_),[P,q,V]=n.transformIn(E);x+=L,x-=q,x=Vh(x,0,P.length),S=P,_=V}e.dispatch({effects:[Yu.of(n),td.of(_),Sf.reconfigure(n.getExtension(m,c,f,d,b)),ed.reconfigure([]),ys.of(!0)],changes:a.keepCodeAsIs?void 0:{from:0,to:e.state.doc.length,insert:S},selection:a.keepCodeAsIs?void 0:$t.cursor(x)}),e.dispatch({effects:[ed.reconfigure([o8()])]}),n.type==="sql"&&s4(e)}$x=function(e){let{placeholderType:n,completionConfig:a,hotkeys:o,cellId:s,lspConfig:c}=e;return[U4(),Sf.of(Hn.python.getExtension(s,a,o,n,c)),Bn,Nr]},j_=function(e){return P1(wr({state:e}).trim())};function P1(e){return e?Hn.markdown.isSupported(e)?Hn.markdown:Hn.sql.isSupported(e)?Hn.sql:Hn.python:Hn.python}Vu=function(e,n){e.state.field(Bn).type!==n.language&&R1({view:e,nextLanguage:Hn[n.language],opts:{keepCodeAsIs:n.keepCodeAsIs??!1}})},Bx=function(e,{completionConfig:n,hotkeysProvider:a,lspConfig:o}){let s=e.state.field(Bn),c=e.state.facet(Yd),f=e.state.facet(Ul);return f===void 0&&be.error("Cell ID is undefined in reconfigureLanguageEffect"),c===void 0&&be.error("Placeholder type is undefined in reconfigureLanguageEffect"),n===void 0&&be.error("Completion config is undefined in reconfigureLanguageEffect"),Sf.reconfigure(s.getExtension(f,n,a,c,o))},wr=function(e,n,a){let o=e.state.field(Bn),s=e.state.field(Nr),c=e.state.doc.toString();return n===void 0?o.transformOut(c,s)[0]:o.transformOut(c.slice(n,a),s)[0]},Ji=function(e,n){let a=e.state.field(Bn),o=P1(n);o.type!==a.type&&Vu(e,{language:o.type,keepCodeAsIs:!0});let[s]=e.state.field(Bn).transformIn(n);return yd(e,s),s};function K4(e){let n=e.state.selection.main.head,a=e.state.doc.toString(),o=a.length>0&&a[n-1]===`
121
+ `,n}eq(n){return this.isCurrent===n.isCurrent&&this.isValid===n.isValid&&this.isFocused===n.isFocused&&this.config===n.config}};function VE(e,n){var d;let a=H6.empty;if((d=n.whenHide)!=null&&d.call(n,e))return a;let o=e.state.field(h1,!1);if(!o)return a;let{currentStatement:s,allStatements:c,isFocused:f}=o;try{for(let m of c){let b=(s==null?void 0:s.from)===m.from&&(s==null?void 0:s.to)===m.to;if(!m.isValid&&n.showInvalid===!1)continue;let _=new BE(n,b,m.isValid,f);for(let x=m.lineFrom;x<=m.lineTo;x++)try{if(x<1||x>e.state.doc.lines)continue;let S=e.state.doc.line(x);a=a.update({add:[_.range(S.from)]})}catch(S){console.warn("SqlGutter: Invalid line number",x,S)}}}catch(m){console.warn("SqlGutter: Error creating markers",m)}return a}function HE(e){return Et.updateListener.of(async n=>{if(!n.docChanged&&!n.selectionSet&&!n.focusChanged)return;let{state:a}=n.view,{main:o}=a.selection,s=o.head,c=await e.analyzeDocument(a),f={currentStatement:await e.getStatementAtPosition(a,s),allStatements:c,cursorPosition:s,isFocused:n.view.hasFocus};n.view.dispatch({effects:p1.of(f)})})}function $E(e){let n=e.width||3;return Et.baseTheme({".cm-sql-gutter":{width:`${n}px`,minWidth:`${n}px`},".cm-sql-gutter .cm-gutterElement":{width:`${n}px`,padding:"0",margin:"0"},".cm-sql-gutter-marker":{width:"100%",height:"100%",display:"block"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px"}})}function WE(e){return Q6({class:`cm-sql-gutter ${e.className||""}`,markers:n=>VE(n,e)})}function UE(e={}){return[h1,HE(new FE(e.parser||new oc)),$E(e),WE(e)]}function KE(e={}){let n=[],{enableLinting:a=!0,enableGutterMarkers:o=!0,enableHover:s=!0,linterConfig:c,gutterConfig:f,hoverConfig:d}=e;return a&&n.push(PE(c)),o&&n.push(UE(f)),s&&(n.push(DE(d)),d!=null&&d.theme?n.push(d.theme):n.push(f1())),n}var QE=class Gx{static jsonStringifySortKeys(){return n=>typeof n!="object"||!n?String(n):JSON.stringify(n,Object.keys(n).toSorted(),2)}constructor(n,a={}){this.delegate=n,this.toKey=a.toKey??Gx.jsonStringifySortKeys(),this.cache=new Ql(a.maxSize??128)}request(n){let a=this.toKey(n),o=this.cache.get(a);if(o!==void 0)return o;let s=this.delegate.request(n);return this.cache.set(a,s),s.catch(c=>{throw this.cache.delete(a),c})}resolve(n,a){this.delegate.resolve(n,a)}reject(n,a){this.delegate.reject(n,a)}};m_=new Sl("sql-table-preview",async(e,n)=>{await br().previewSQLTable({requestId:e,...n})}),H_=new Sl("sql-schema-list-preview",async(e,n)=>{await br().previewSQLSchemaList({requestId:e,...n})}),V_=new Sl("sql-table-list-preview",async(e,n)=>{await br().previewSQLTableList({requestId:e,...n})}),bm=new QE(new Sl("validate-sql",async(e,n)=>{await br().validateSQL({requestId:e,...n})}),{maxSize:3});var GE=er();let di;di=Te(new Map),r_=e=>{let n=(0,GE.c)(3),a=Sn(di),o;return n[0]!==e||n[1]!==a?(o=a.get(e),n[0]=e,n[1]=a,n[2]=o):o=n[2],o};function xf(e){let n=ze.get(di),a=new Map(n);a.delete(e),ze.set(di,a)}function JE(){ze.set(di,new Map)}function XE({cellId:e,errorMessage:n,dialect:a}){let o=ze.get(di),s=new Map(o),c=a==="DuckDB"?YE(n):m1(n);s.set(e,c),ze.set(di,s)}function YE(e){let{errorType:n,errorMessage:a}=m1(e),o=a,s,c=a.indexOf("LINE ");return c!==-1&&(s=a.slice(Math.max(0,c)).trim(),o=a.slice(0,Math.max(0,c)).trim()),{errorType:n,errorMessage:o,codeblock:s}}function m1(e){return{errorType:e.split(":")[0].trim(),errorMessage:e.split(":").slice(1).join(":").trim()}}function g1(e){return e.field(Nr)}function ZE(){return e=>{let n=g1(e.state).engine,a=li.getCompletionSource(n);return a&&L8(a)(e)||null}}function e4(){return e=>{let n=g1(e.state).engine,a=li.getDialect(n);return e.matchBefore(/\.\w*/)?null:M8(a,!0,(o,s)=>({label:o,type:s,info:async()=>{let c=(await t4())[o.toLocaleLowerCase()];if(!c)return null;let f=document.createElement("div");return f.innerHTML=qE.keyword({keyword:o,info:c}),f}}))(e)}}var t4=nr(async()=>{let e=await re(()=>import("./common-keywords-CvypSGuw.js").then(async a=>(await a.__tla,a)),[],import.meta.url),n=await re(()=>import("./duckdb-keywords-C63auBrb.js").then(async a=>(await a.__tla,a)),[],import.meta.url);return{...e.default.keywords,...n.default.keywords}}),n4=er(),y1=Ml("marimo:notebook-sql-mode","default",Qu);function r4(){let e=(0,n4.c)(3),[n,a]=pw(y1),o;return e[0]!==a||e[1]!==n?(o={sqlMode:n,setSQLMode:a},e[0]=a,e[1]=n,e[2]=o):o=e[2],o}function v1(){return ze.get(y1)}var a4=Hg,i4="DuckDB",b1=new qu;function kf(){return ze.get(Gi).latestEngineSelected}let w1;kd=(Af=class{constructor(){ve(this,"parser",new Zu);ve(this,"type","sql");this.sqlModeEnabled=!0}get defaultMetadata(){return{...this.parser.defaultMetadata,engine:kf()||"__marimo_duckdb"}}get defaultCode(){let e=kf();return e&&e!=="__marimo_duckdb"?`_df = mo.sql(f"""SELECT * FROM """, engine=${e})`:this.parser.defaultCode}transformIn(e){this.parser.defaultMetadata.engine=kf()||"__marimo_duckdb";let n=this.parser.transformIn(e),a=n.metadata;return a.engine&&a.engine!=="__marimo_duckdb"&&Ug(a.engine),[n.code,n.offset,a]}transformOut(e,n){let a=this.parser.transformOut(e,n);return[a.code,a.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,n,a,o,s){var f;let c=[b1.of(Kw({dialect:a4})),Ja.of([{key:"Tab",run:d=>x8(d)||i8(d),preventDefault:!0}]),Fu({defaultKeymap:!1,activateOnTyping:!0,override:[ZE(),B3,e4()]})];if(((f=s==null?void 0:s.diagnostics)==null?void 0:f.sql_linter)??!1){let d=ze.get(J8),m=new w1({getParserOptions:b=>({database:x1(b)??i4})});c.push(KE({enableLinting:!0,linterConfig:{delay:250,parser:m},enableGutterMarkers:!0,gutterConfig:{backgroundColor:"#3b82f6",errorBackgroundColor:"#ef4444",hideWhenNotFocused:!0,parser:m},hoverConfig:{schema:l4,hoverTime:300,enableKeywords:!0,enableTables:!0,enableColumns:!0,parser:m,theme:f1(d)}}),Et.updateListener.of(b=>{b.focusChanged&&m.setFocusState(b.view.hasFocus)}))}return this.sqlModeEnabled&&c.push(u4()),c}},ve(Af,"fromQuery",e=>Zu.fromQuery(e)),Af),w1=class extends oc{constructor(){super(...arguments);ve(this,"validationTimeout",null);ve(this,"VALIDATION_DELAY_MS",300);ve(this,"isFocused",!1)}setFocusState(n){this.isFocused=n}async validateWithDelay(n,a,o){return this.validationTimeout&&window.clearTimeout(this.validationTimeout),new Promise(s=>{this.validationTimeout=window.setTimeout(async()=>{var c;if(!this.isFocused){s([]);return}try{let f=await C1(n,a,o,v1());if(f.error){be.error("Failed to validate SQL",{error:f.error}),s([]);return}s(((c=f.parse_result)==null?void 0:c.errors)??[])}catch(f){be.error("Failed to validate SQL",{error:f}),s([])}},this.VALIDATION_DELAY_MS)})}async validateSql(n,a){let o=ho(a.state);if(!this.isFocused)return[];if(!Ki.has(o.engine))return super.validateSql(n,a);let s=x1(a.state);return this.validateWithDelay(n,o.engine,s)}async parse(n,a){return ho(a.state).engine==="__marimo_duckdb"?{success:!0,errors:[]}:super.parse(n,a)}};function _1(e,n){e.dispatch({effects:b1.reconfigure(Kw({dialect:n}))})}function o4(e,n){_1(e,li.getDialect(n))}function s4(e){let n=ho(e.state).engine;_1(e,li.getDialect(n))}function ho(e){return e.field(Nr)}function l4(e){let n=ho(e.state).engine,a=li.getCompletionSource(n);return a!=null&&a.schema?a.schema:{}}function x1(e){let n=ho(e).engine;return k1(n)}function k1(e){var a;let n=(a=li.getInternalDialect(e))==null?void 0:a.toLowerCase();if(!n||!Kl(n))return null;switch(n){case"postgresql":case"postgres":return"PostgreSQL";case"db2":case"db2i":return"DB2";case"mysql":return"MySQL";case"sqlite":return"Sqlite";case"mssql":case"sqlserver":case"microsoft sql server":return"TransactSQL";case"duckdb":return"DuckDB";case"mariadb":return"MariaDB";case"cassandra":return"Noql";case"athena":case"awsathena":return"Athena";case"bigquery":return"BigQuery";case"hive":return"Hive";case"redshift":return"Redshift";case"snowflake":return"Snowflake";case"flink":return"FlinkSQL";case"mongodb":case"noql":return"Noql";case"oracle":case"oracledb":case"timescaledb":case"couchbase":case"trino":case"tidb":case"singlestoredb":case"spark":case"databricks":case"datafusion":return be.debug("Unsupported dialect",{dialect:n}),null;default:return ss(n),null}}var c4=300;function u4(){return Ui.define(e=>{let n,a=null,o=e.state.facet(ua);return{update(s){if(!s.docChanged)return;let c=v1();if(c==="default")return;let f=ho(s.state).engine;if(!Ki.has(f))return;let d=s.state.doc.toString();n&&window.clearTimeout(n),n=window.setTimeout(async()=>{if(a!==d){if(a=d,d===""){xf(o);return}try{let m=k1(f),b=(await C1(d,f,m,c)).validate_result;b!=null&&b.error_message?XE({cellId:o,errorMessage:b.error_message,dialect:m}):xf(o)}catch(m){be.error("Failed to validate SQL",{error:m})}}},c4)},destroy(){n&&window.clearTimeout(n),xf(o)}}})}async function C1(e,n,a,o){let s=await bm.request({onlyParse:o==="default",engine:n,dialect:a,query:e});if(s.error)throw Error(s.error);return s}var d4=nr(()=>new SE),f4=nr(()=>new Ku),p4=nr(()=>new kd);Hn={get python(){return d4()},get markdown(){return f4()},get sql(){return p4()}};function h4(){return Object.values(Hn)}let S1;S1=er(),Ll=_e.forwardRef((e,n)=>{let a=(0,S1.c)(10),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("flex items-center justify-center peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",o),a[3]=o,a[4]=c);let f;a[5]===Symbol.for("react.memo_cache_sentinel")?(f=(0,N.jsx)(g0,{className:Pr("flex items-center justify-center text-current max-h-[14px] overflow-hidden"),children:(0,N.jsx)(F8,{className:"h-4 w-4"})}),a[5]=f):f=a[5];let d;return a[6]!==s||a[7]!==n||a[8]!==c?(d=(0,N.jsx)(Td,{ref:n,className:c,...s,children:f}),a[6]=s,a[7]=n,a[8]=c,a[9]=d):d=a[9],d}),Ll.displayName=Td.displayName,k_="_";var m4=new Set("__*.marimo.app.False.None.True.__peg_parser__.and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield.None.setup".split("."));am=function(e,n=!0){return e=e.trim(),e?(/^\d/.test(e)&&(e=`_${e}`),e=e.replaceAll(/\W/g,"_"),n?e.toLowerCase():e):"_"},M_=function(e,n){let a=new Set(n),o=e,s=f=>!a.has(f)&&!m4.has(f);if(s(e))return e;let c=1;for(;!s(o);)o=`${e}_${c}`,c++;return o},I_=function(e,n){return nm(e)?`cell-${n}`:e},nm=function(e){return e?e==="_"||e==="__":!0};var g4=er();function y4(e){let n=(0,g4.c)(15),{minWidth:a,padding:o}=e,s=a===void 0?70:a,c=o===void 0?15:o,[f,d]=(0,_e.useState)(50),m=(0,_e.useRef)(null),b=(0,_e.useRef)(null),_;n[0]===c?_=n[1]:(_=A=>{if(b.current&&m.current){let j=b.current;j.style.fontSize=window.getComputedStyle(m.current).fontSize,j.style.fontFamily=window.getComputedStyle(m.current).fontFamily,j.textContent=A;let $=j.offsetWidth;d($+c)}},n[0]=c,n[1]=_);let x=_,S;n[2]===x?S=n[3]:(S=()=>{var A;x(((A=m.current)==null?void 0:A.value)??"")},n[2]=x,n[3]=S),q8(S);let E;n[4]===x?E=n[5]:(E=A=>{x(A.target.value)},n[4]=x,n[5]=E);let L=`${f}px`,P=`${s}px`,q;n[6]!==L||n[7]!==P?(q={width:L,minWidth:P},n[6]=L,n[7]=P,n[8]=q):q=n[8];let V;n[9]!==E||n[10]!==q?(V={ref:m,type:"text",onChange:E,style:q},n[9]=E,n[10]=q,n[11]=V):V=n[11];let B=V,M;n[12]===Symbol.for("react.memo_cache_sentinel")?(M={ref:b,style:{visibility:"hidden",position:"absolute",whiteSpace:"pre"}},n[12]=M):M=n[12];let J=M,le;return n[13]===B?le=n[14]:(le={inputProps:B,spanProps:J},n[13]=B,n[14]=le),le}var v4=er();function b4({currentQuotePrefix:e,checked:n,prefix:a}){let o=e;return n?e===""?o=a:e!=="rf"&&a!==e&&(o="rf"):e===a?o="":e==="rf"&&(o=a==="r"?"f":"r"),o}let E1;E1=()=>{let e=(0,v4.c)(2),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,N.jsxs)("section",{className:"flex flex-col gap-0.5",children:[(0,N.jsxs)("header",{className:"flex items-center gap-1",children:[(0,N.jsx)("code",{className:"text-xs px-1 py-0.5 bg-(--slate-2) rounded",children:"r"}),(0,N.jsx)("span",{className:"font-semibold",children:"Raw String"})]}),(0,N.jsx)("p",{className:"text-sm text-muted-foreground",children:"Write LaTeX without escaping special characters"}),(0,N.jsx)("pre",{className:"text-xs bg-(--slate-2) p-2 rounded",children:"\\alpha \\beta"})]}),e[0]=n):n=e[0];let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=(0,N.jsxs)("div",{className:"flex flex-col gap-3.5",children:[n,(0,N.jsxs)("section",{className:"flex flex-col gap-0.5",children:[(0,N.jsxs)("header",{className:"flex items-center gap-1",children:[(0,N.jsx)("code",{className:"text-xs px-1 py-0.5 bg-(--slate-2) rounded",children:"f"}),(0,N.jsx)("span",{className:"font-semibold",children:"Format String"})]}),(0,N.jsx)("p",{className:"text-sm text-muted-foreground",children:"Interpolate Python values"}),(0,N.jsxs)("pre",{className:"text-xs bg-(--slate-2) p-2 rounded",children:["Hello ","{name}","! \u{1F601}"]})]})]}),e[1]=a):a=e[1],a},cm="data-cell-id",Zw=function(e){return{[cm]:e}},zm="data-for-cell-id",ud=function(e){return{[zm]:e}};var w4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClickHouse%3c/title%3e%3cpath%20d='M21.333%2010H24v4h-2.667ZM16%201.335h2.667v21.33H16Zm-5.333%200h2.666v21.33h-2.666ZM0%2022.665V1.335h2.667v21.33zm5.333-21.33H8v21.33H5.333Z'/%3e%3c/svg%3e",_4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDatabricks%3c/title%3e%3cpath%20d='M.95%2014.184L12%2020.403l9.919-5.55v2.21L12%2022.662l-10.484-5.96-.565.308v.77L12%2024l11.05-6.218v-4.317l-.515-.309L12%2019.118l-9.867-5.653v-2.21L12%2016.805l11.05-6.218V6.32l-.515-.308L12%2011.974%202.647%206.681%2012%201.388l7.76%204.368.668-.411v-.566L12%200%20.95%206.27v.72L12%2013.207l9.919-5.55v2.26L12%2015.52%201.516%209.56l-.565.308Z'/%3e%3c/svg%3e",x4="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAGcElEQVR4nNxZa2wcVxU+99557M6+vLazj6xjO6+maWVTl0YpLU1DU9KARNqooQhFVYJUqUWgiocqIVRESPlRoEhIqYoqgSiCItqQPkAEKUWQtlGSJtAY00R5mTjZTfze94x3HvdedMdZnKgS6s7O2kk/a7R3xvY933fOd874yhhucCyYAIWA9IOH2r+35/HUnjU96sBC8fAERQLpj0+mXjdeXM6rzy/no88uK6zolHu97EX8p/f/IWHAv38i9bsH+kIPo/ozhAJBgpR9J419je437xb62Zc7n/tcf+gRsebADYQAxLW2N/ApL/vNq4AdA7Ht2/piT4q15fAp1wEYAGEALYA18TzT1TXQ09O75qPuKbWS8NW4Lan27/pM4gWrBIgFnaIDvKZIpPPKt+nlgpMTi0q5PKqoqvZR950XAREZaz/fmHmFOFijwGHkDDu5PKGs1SlQ5gAAQ+S9U9Y/xM+Wy+WxRvaeFwE770z+OBNQbmYWwPlp63BPh3q7XQaCxAi50gP7Tldf87J3ywVszEQ2bumOf5WZAAajeWoDJjYOMM5BCECEw9miefxwduaol/1b2sQdCon/8BOZX3ETYWYiODFhvrNUC6ylFgJqzl27DxV+xD3GaGkFnl6deS4G8mJqAmRrtaGkoqxiJnazPpt9gPNVa3DvqfKrXmO0rAJ3RSLrHojHd4jMMwvBSMn+d1pSVrv37oXdz50Hx79JOXgtQGsqIAEiT8V7djtVzEiQ4w+K+t9uCmn3uNmX5rL/l8ullw5c1g80E6slFXgkuuixJVKw3y5jxEzExnV7pB3k7rr3hZDBiZl3njk+9u1mY/legSgm0cfiXbtcTziYHJmovNEXC99PZzAV41KMzaLtXGBVmaQltWfCdPLNxPNdwFdii58KYykhXM2AO5MGvTSAgw9aLnUx8zlomCxTKdeHdP14s/F8tdAiIie2RpPfAPcPNYAjRumNOwLRLZwL2rPgHAGnCF6aHPuJ5869Cr5WYFs0/S0ZkTDns9SK1BltI/JicYcEcXAX8L5R+vOblanf+hHTNwFtWGr7QiT9BAPklnWoVt5/qxrZILQI7wvyjHPrjKkfeL0y9QID76Pzavhmoa3RzNdkLMcYEKCA4aJtncjIgVs4oFnbCCGASDtRVrw3Uz7sV1xfBKiAlc2RJV+vkz9vWYMZWesTa1ER5vYEgot27YPvjJ/dXGBOwY+44JeAdaHkQxpRU9QVQGDIrPz1FjV+f/3eFcaRFcdKosicsh8x6/ClBzaEu7YLoqJNDUonVKR0UCTuRT9w9wshpAzb+qmcY2b9iFlH0xVow0r81sCiz9azfdCY3rNWSzw8a5/ZZ2ItPv9UmfiFP7Tn0HQFPhlMbuKIyOKkhThjNc4rBCtRJl5jrvO5W4mSY+beMib/4A/tOTQtYCCY2kTdszmHE7X8/tWBTtf7s7S528IYELxcuviMycWZzF80baHVgdT6/00fu3oso7Tdwa5Ypt7Aw5Zx7M1K7pf+UL4WTVWgQwqnQ5LWLexTpfblEFaT7Jrsc3GMLDw7+a9tFDj1j/YcmqpAWkn06yhERaYP6ZdeHtC6tl6deYPx4q7xY5+/YFfP+kf5WniqQELp6J6hNaNdia8s4TCojkmrjOYVHGin7qsLQdYqvb976uijk455yX/ac/AkYNLKZx9Nb/kNQkAsLJNBW9+/Uk3eJzI/ZlUG36qcfv6MXf3nmtjtO/ZO/v27/tOeA/L6iyu0pfdu7/riATF93s0fffq+toGdM5zmJ+ziuRgJpWSEgy/mXlk/Zk2f8ZfytfDcxOeM828XHH04TAIJjOTgDAlIiPNEmgQTw9Xh146UBn/aavLgVUAmkLk5IkdXFh09l62NHloaWblZjFGMONjMrsTUjqV5qzjuP90Pw9MUmrKms/2x276U0pbcO2Hlh9qUzj6GMJiclk/q5/b+Ovfqg+P29LD/dD+MhnsgSMLhnlDvPQVrOrcmfufjF2cuvI0BqVlj5GDBKmQZsJbMe9+BAZP1yU3fF+tloVV3LzSfhtEbXrWhO7Ri3ULz8PwmzoRXfTqr/+ddf+k0Dk8CEGBMOWccmC8H82bgSUAmfNO6S/q5Bc8+eBUQDXWtz1VP36gCMC4xnfPrZFw2/I9uLZi6u2aXs7ZdGWkNpcbQcAU0LX2XYYxeF/YBLwIYs0twndjnY4H/BgAA//95CrBYRwImwgAAAABJRU5ErkJggg==",k4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDuckDB%3c/title%3e%3cpath%20d='M12%200C5.363%200%200%205.363%200%2012s5.363%2012%2012%2012%2012-5.363%2012-12S18.637%200%2012%200zM9.502%207.03a4.974%204.974%200%200%201%204.97%204.97%204.974%204.974%200%200%201-4.97%204.97A4.974%204.974%200%200%201%204.532%2012a4.974%204.974%200%200%201%204.97-4.97zm6.563%203.183h2.351c.98%200%201.787.782%201.787%201.762s-.807%201.789-1.787%201.789h-2.351v-3.551z'/%3e%3c/svg%3e",C4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eGoogle%20BigQuery%3c/title%3e%3cpath%20d='M5.676%2010.595h2.052v5.244a5.892%205.892%200%200%201-2.052-2.088v-3.156zm18.179%2010.836a.504.504%200%200%201%200%20.708l-1.716%201.716a.504.504%200%200%201-.708%200l-4.248-4.248a.206.206%200%200%201-.007-.007c-.02-.02-.028-.045-.043-.066a10.736%2010.736%200%200%201-6.334%202.065C4.835%2021.599%200%2016.764%200%2010.799S4.835%200%2010.8%200s10.799%204.835%2010.799%2010.8c0%202.369-.772%204.553-2.066%206.333.025.017.052.028.074.05l4.248%204.248zm-5.028-10.632a8.015%208.015%200%201%200-8.028%208.028h.024a8.016%208.016%200%200%200%208.004-8.028zm-4.86%204.98a6.002%206.002%200%200%200%202.04-2.184v-1.764h-2.04v3.948zm-4.5.948c.442.057.887.08%201.332.072.4.025.8.025%201.2%200V7.692H9.468v9.035z'/%3e%3c/svg%3e",S4=""+new URL("iceberg-COKYXo-A.png",import.meta.url).href,E4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMotherDuck%3c/title%3e%3cg%20transform='scale(0.85)%20translate(0,%202)'%3e%3cpath%20fill='%23ff9538'%20d='M1.71%2015.86s7.45%205.32%207.89%205.59c.44.27%201.08.33%201.64.11.56-.22.98-.71%201.11-1.21s1.85-9.49%201.85-9.49c.02-.12.07-.48-.13-.83-.27-.47-.86-.71-1.38-.57-.42.12-.64.44-.7.55-.09.17-.26.45-.57.7-.24.19-.47.3-.58.34-.96.38-2.02.06-2.61-.72-.38-.48-1.04-.67-1.64-.43-.6.24-.94.84-.89%201.45.11.98-.44%201.94-1.4%202.32-.51.21-1.06.21-1.54.05-.12-.03-.51-.12-.89.09-.48.26-.74.84-.61%201.37.09.39.38.62.48.69z'%20/%3e%3cpath%20fill='%23ff9538'%20d='M14.12%204.21s2.65%208.76%202.83%209.24c.19.48.66.92%201.23%201.09.58.16%201.21.03%201.62-.28.41-.31%207.25-6.39%207.25-6.39.09-.08.35-.34.4-.74.07-.53-.25-1.09-.75-1.29-.4-.16-.78-.04-.89%200-.18.08-.48.2-.88.2-.3.01-.55-.05-.67-.08-.99-.28-1.64-1.18-1.63-2.16-.01-.61-.42-1.17-1.04-1.35-.62-.18-1.26.09-1.59.6-.51.84-1.53%201.27-2.52.99-.53-.15-.96-.48-1.25-.91-.07-.09-.33-.4-.76-.48-.54-.09-1.1.22-1.32.71-.16.37-.08.72-.04.84z'%20/%3e%3c/g%3e%3c/svg%3e",T4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMySQL%3c/title%3e%3cpath%20d='M16.405%205.501c-.115%200-.193.014-.274.033v.013h.014c.054.104.146.18.214.273.054.107.1.214.154.32l.014-.015c.094-.066.14-.172.14-.333-.04-.047-.046-.094-.08-.14-.04-.067-.126-.1-.18-.153zM5.77%2018.695h-.927a50.854%2050.854%200%2000-.27-4.41h-.008l-1.41%204.41H2.45l-1.4-4.41h-.01a72.892%2072.892%200%2000-.195%204.41H0c.055-1.966.192-3.81.41-5.53h1.15l1.335%204.064h.008l1.347-4.064h1.095c.242%202.015.384%203.86.428%205.53zm4.017-4.08c-.378%202.045-.876%203.533-1.492%204.46-.482.716-1.01%201.073-1.583%201.073-.153%200-.34-.046-.566-.138v-.494c.11.017.24.026.386.026.268%200%20.483-.075.647-.222.197-.18.295-.382.295-.605%200-.155-.077-.47-.23-.944L6.23%2014.615h.91l.727%202.36c.164.536.233.91.205%201.123.4-1.064.678-2.227.835-3.483zm12.325%204.08h-2.63v-5.53h.885v4.85h1.745zm-3.32.135l-1.016-.5c.09-.076.177-.158.255-.25.433-.506.648-1.258.648-2.253%200-1.83-.718-2.746-2.155-2.746-.704%200-1.254.232-1.65.697-.43.508-.646%201.256-.646%202.245%200%20.972.19%201.686.574%202.14.35.41.877.615%201.583.615.264%200%20.506-.033.725-.098l1.325.772.36-.622zM15.5%2017.588c-.225-.36-.337-.94-.337-1.736%200-1.393.424-2.09%201.27-2.09.443%200%20.77.167.977.5.224.362.336.936.336%201.723%200%201.404-.424%202.108-1.27%202.108-.445%200-.77-.167-.978-.5zm-1.658-.425c0%20.47-.172.856-.516%201.156-.344.3-.803.45-1.384.45-.543%200-1.064-.172-1.573-.515l.237-.476c.438.22.833.328%201.19.328.332%200%20.593-.073.783-.22a.754.754%200%2000.3-.615c0-.33-.23-.61-.648-.845-.388-.213-1.163-.657-1.163-.657-.422-.307-.632-.636-.632-1.177%200-.45.157-.81.47-1.085.315-.278.72-.415%201.22-.415.512%200%20.98.136%201.4.41l-.213.476a2.726%202.726%200%2000-1.064-.23c-.283%200-.502.068-.654.206a.685.685%200%2000-.248.524c0%20.328.234.61.666.85.393.215%201.187.67%201.187.67.433.305.648.63.648%201.168zm9.382-5.852c-.535-.014-.95.04-1.297.188-.1.04-.26.04-.274.167.055.053.063.14.11.214.08.134.218.313.346.407.14.11.28.216.427.31.26.16.555.255.81.416.145.094.293.213.44.313.073.05.12.14.214.172v-.02c-.046-.06-.06-.147-.105-.214-.067-.067-.134-.127-.2-.193a3.223%203.223%200%2000-.695-.675c-.214-.146-.682-.35-.77-.595l-.013-.014c.146-.013.32-.066.46-.106.227-.06.435-.047.67-.106.106-.027.213-.06.32-.094v-.06c-.12-.12-.21-.283-.334-.395a8.867%208.867%200%2000-1.104-.823c-.21-.134-.476-.22-.697-.334-.08-.04-.214-.06-.26-.127-.12-.146-.19-.34-.275-.514a17.69%2017.69%200%2001-.547-1.163c-.12-.262-.193-.523-.34-.763-.69-1.137-1.437-1.826-2.586-2.5-.247-.14-.543-.2-.856-.274-.167-.008-.334-.02-.5-.027-.11-.047-.216-.174-.31-.235-.38-.24-1.364-.76-1.644-.072-.18.434.267.862.422%201.082.115.153.26.328.34.5.047.116.06.235.107.356.106.294.207.622.347.897.073.14.153.287.247.413.054.073.146.107.167.227-.094.136-.1.334-.154.5-.24.757-.146%201.693.194%202.25.107.166.362.534.703.393.3-.12.234-.5.32-.835.02-.08.007-.133.048-.187v.015c.094.188.188.367.274.555.206.328.566.668.867.895.16.12.287.328.487.402v-.02h-.015c-.043-.058-.1-.086-.154-.133a3.445%203.445%200%2001-.35-.4%208.76%208.76%200%2001-.747-1.218c-.11-.21-.202-.436-.29-.643-.04-.08-.04-.2-.107-.24-.1.146-.247.273-.32.453-.127.288-.14.642-.188%201.01-.027.007-.014%200-.027.014-.214-.052-.287-.274-.367-.46-.2-.475-.233-1.238-.06-1.785.047-.14.247-.582.167-.716-.042-.127-.174-.2-.247-.303a2.478%202.478%200%2001-.24-.427c-.16-.374-.24-.788-.414-1.162-.08-.173-.22-.354-.334-.513-.127-.18-.267-.307-.368-.52-.033-.073-.08-.194-.027-.274.014-.054.042-.075.094-.09.088-.072.335.022.422.062.247.1.455.194.662.334.094.066.195.193.315.226h.14c.214.047.455.014.655.073.355.114.675.28.962.46a5.953%205.953%200%20012.085%202.286c.08.154.115.295.188.455.14.33.313.663.455.982.14.315.275.636.476.897.1.14.502.213.682.286.133.06.34.115.46.188.23.14.454.3.67.454.11.076.443.243.463.378z'/%3e%3c/svg%3e",T1=""+new URL("postgresql-q8VEBKGg.svg",import.meta.url).href,I4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eAmazon%20Redshift%3c/title%3e%3cpath%20d='M16.639%209.932a.822.822%200%200%201-.822-.82.823.823%200%200%201%201.645%200c0%20.452-.37.82-.823.82m-2.086%204.994a.823.823%200%200%201-.822-.822.822.822%200%200%201%201.645%200%20.822.822%200%200%201-.823.822m-5.004-.833a.822.822%200%201%201%20.002-1.644.822.822%200%200%201-.002%201.644m-2.083%204.578a.823.823%200%200%201-.823-.82.823.823%200%200%201%201.645%200c0%20.452-.37.82-.822.82m9.173-11.236a1.68%201.68%200%200%200-1.68%201.676c0%20.566.285%201.066.718%201.37l-.782%201.982a1.674%201.674%200%200%200-1.923%201.104l-1.753-.398a1.675%201.675%200%200%200-3.348.103c0%20.432.169.823.438%201.12l-.764%201.79c-.028-.001-.053-.008-.08-.008a1.68%201.68%200%200%200-1.68%201.676%201.68%201.68%200%200%200%203.36%200c0-.593-.312-1.112-.778-1.41l.674-1.579c.161.052.33.088.508.088.661%200%201.228-.386%201.502-.94l1.856.42a1.68%201.68%200%200%200%203.327-.325c0-.5-.224-.943-.574-1.25l.822-2.083c.053.005.104.016.157.016a1.68%201.68%200%200%200%201.68-1.676%201.68%201.68%200%200%200-1.68-1.676M12%2023.145c-4.17%200-7.286-1.252-7.286-2.37V4.79C6.14%205.938%209.131%206.547%2012%206.547c2.869%200%205.86-.609%207.286-1.756v15.983c0%201.12-3.116%202.37-7.286%202.37M12%20.856c4.293%200%207.286%201.274%207.286%202.419%200%201.143-2.993%202.418-7.286%202.418-4.293%200-7.286-1.275-7.286-2.418C4.714%202.129%207.707.855%2012%20.855m8.143%202.419C20.143%201.147%2015.947%200%2012%200%208.052%200%203.857%201.147%203.857%203.274l.002.01h-.002v17.49C3.857%2022.87%208.052%2024%2012%2024c3.947%200%208.143-1.13%208.143-3.226V3.284h-.002l.002-.01'/%3e%3c/svg%3e",L4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSnowflake%3c/title%3e%3cpath%20d='M24%203.459c0%20.646-.418%201.18-1.141%201.18-.723%200-1.142-.534-1.142-1.18%200-.647.419-1.18%201.142-1.18.723%200%201.141.533%201.141%201.18zm-.228%200c0-.533-.38-.951-.913-.951s-.913.38-.913.95c0%20.533.38.952.913.952.57%200%20.913-.419.913-.951zm-1.37-.533h.495c.266%200%20.456.152.456.38%200%20.153-.076.229-.19.305l.19.266v.038h-.266l-.19-.266h-.229v.266h-.266zm.495.228h-.229v.267h.229c.114%200%20.152-.038.152-.114.038-.077-.038-.153-.152-.153zM7.602%2012.4c.038-.151.076-.304.076-.456%200-.114-.038-.228-.038-.342-.114-.343-.304-.647-.646-.838l-4.87-2.777c-.685-.38-1.56-.152-1.94.533-.381.685-.153%201.56.532%201.94l2.701%201.56-2.701%201.56c-.685.38-.913%201.256-.533%201.94.38.685%201.256.914%201.94.533l4.832-2.777c.343-.267.571-.533.647-.876zm1.332%202.626c-.266-.038-.57.038-.837.19l-4.832%202.777c-.685.38-.913%201.256-.532%201.94.38.686%201.255.914%201.94.533l2.701-1.56v3.12c0%20.8.647%201.408%201.446%201.408.799%200%201.407-.647%201.407-1.408v-5.592c0-.761-.57-1.37-1.293-1.408zm4.946-6.088c.266.038.57-.038.837-.19l4.832-2.777c.685-.38.913-1.256.532-1.94-.38-.686-1.255-.914-1.94-.533l-2.701%201.56V1.975c0-.799-.647-1.408-1.446-1.408-.799%200-1.446.609-1.446%201.408V7.53c0%20.76.609%201.37%201.332%201.407zM3.265%205.97l4.832%202.777c.266.152.533.19.837.19.723-.038%201.331-.684%201.331-1.407V1.975c0-.799-.646-1.408-1.407-1.408-.799%200-1.446.647-1.446%201.408v3.12l-2.701-1.56c-.685-.38-1.56-.152-1.94.533-.419.646-.19%201.521.494%201.902zm9.093%206.011a.412.412%200%2000-.114-.266l-.57-.571a.346.346%200%2000-.267-.114.412.412%200%2000-.266.114l-.571.57a.411.411%200%2000-.114.267c0%20.076.038.19.114.267l.57.57a.345.345%200%2000.267.114c.076%200%20.19-.038.266-.114l.571-.57a.412.412%200%2000.114-.267zm1.598.533L11.94%2014.53c-.039.038-.153.114-.229.114h-.608a.411.411%200%2001-.267-.114L8.82%2012.514a.408.408%200%2001-.076-.229v-.608c0-.076.038-.19.114-.267l2.016-2.016a.41.41%200%2001.267-.114h.608a.41.41%200%2001.267.114l2.016%202.016a.347.347%200%2001.114.267v.608c-.076.077-.114.19-.19.229zm5.593%205.44l-4.832-2.777c-.266-.152-.57-.19-.837-.152-.723.038-1.332.684-1.332%201.408v5.554c0%20.8.647%201.408%201.408%201.408.799%200%201.446-.647%201.446-1.408v-3.12l2.7%201.56c.686.38%201.561.152%201.941-.533.419-.646.19-1.521-.494-1.94zm2.549-7.533l-2.701%201.56%202.7%201.56c.686.38.914%201.256.533%201.94-.38.685-1.255.913-1.94.533l-4.832-2.778a1.644%201.644%200%2001-.647-.798c-.037-.153-.076-.305-.076-.457%200-.114.039-.228.039-.342.114-.343.342-.647.646-.837l4.832-2.778c.685-.38%201.56-.152%201.94.533.457.609.19%201.484-.494%201.864'/%3e%3c/svg%3e",O4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eApache%20Spark%3c/title%3e%3cpath%20d='M10.812%200c-.425.013-.845.215-1.196.605a3.593%203.593%200%2000-.493.722c-.355.667-.425%201.415-.556%202.143a551.9%20551.9%200%2000-.726%204.087c-.027.16-.096.227-.244.273C5.83%208.386%204.06%208.94%202.3%209.514c-.387.125-.773.289-1.114.506-1.042.665-1.196%201.753-.415%202.71.346.422.79.715%201.284.936%201.1.49%202.202.976%203.3%201.47.019.01.036.013.053.019h-.004l1.306.535c0%20.023.002.045%200%20.073-.2%202.03-.39%204.063-.58%206.095-.04.419-.012.831.134%201.23.317.87%201.065%201.148%201.881.701.372-.204.666-.497.937-.818%201.372-1.623%202.746-3.244%204.113-4.872.111-.133.205-.15.363-.098.349.117.697.231%201.045.347h.001c.02.012.045.02.073.03l.142.042c1.248.416%202.68.775%203.929%201.19.4.132.622.164%201.045.098.311-.048.592-.062.828-.236.602-.33.995-.957.988-1.682-.005-.427-.154-.813-.35-1.186-.82-1.556-1.637-3.113-2.461-4.666-.078-.148-.076-.243.037-.375%201.381-1.615%202.756-3.236%204.133-4.855.272-.32.513-.658.653-1.058.308-.878-.09-1.57-1-1.741a2.783%202.783%200%2000-1.235.069c-1.974.521-3.947%201.041-5.918%201.57-.175.047-.26.015-.355-.144a353.08%20353.08%200%2000-2.421-4.018%204.61%204.61%200%2000-.652-.849c-.371-.37-.802-.549-1.227-.536zm.172%203.703a.592.592%200%2001.189.211c.87%201.446%201.742%202.89%202.609%204.338.07.118.135.16.277.121%201.525-.41%203.052-.813%204.579-1.217.367-.098.735-.193%201.103-.289a.399.399%200%2001-.1.2c-1.259%201.48-2.516%202.962-3.779%204.438-.11.13-.12.22-.04.37.937%201.803%201.768%203.309%202.498%204.76l-3.696-1.019c-.538-.18-1.077-.358-1.615-.539-.163-.055-.25-.03-.36.1-1.248%201.488-2.504%202.97-3.759%204.454a.398.398%200%2001-.18.132c.035-.378.068-.757.104-1.136.149-1.572.297-3.144.451-4.716-.03-.318.117-.405-.322-.545-1.493-.593-3.346-1.321-4.816-1.905a.595.595%200%2001.24-.134c1.797-.57%203.595-1.14%205.394-1.705.127-.04.199-.092.211-.233.013-.148.05-.294.076-.441.241-1.363.483-2.726.726-4.088.068-.386.14-.771.21-1.157z'/%3e%3c/svg%3e",A4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSQLite%3c/title%3e%3cpath%20d='M21.678.521c-1.032-.92-2.28-.55-3.513.544a8.71%208.71%200%200%200-.547.535c-2.109%202.237-4.066%206.38-4.674%209.544.237.48.422%201.093.544%201.561a13.044%2013.044%200%200%201%20.164.703s-.019-.071-.096-.296l-.05-.146a1.689%201.689%200%200%200-.033-.08c-.138-.32-.518-.995-.686-1.289-.143.423-.27.818-.376%201.176.484.884.778%202.4.778%202.4s-.025-.099-.147-.442c-.107-.303-.644-1.244-.772-1.464-.217.804-.304%201.346-.226%201.478.152.256.296.698.422%201.186.286%201.1.485%202.44.485%202.44l.017.224a22.41%2022.41%200%200%200%20.056%202.748c.095%201.146.273%202.13.5%202.657l.155-.084c-.334-1.038-.47-2.399-.41-3.967.09-2.398.642-5.29%201.661-8.304%201.723-4.55%204.113-8.201%206.3-9.945-1.993%201.8-4.692%207.63-5.5%209.788-.904%202.416-1.545%204.684-1.931%206.857.666-2.037%202.821-2.912%202.821-2.912s1.057-1.304%202.292-3.166c-.74.169-1.955.458-2.362.629-.6.251-.762.337-.762.337s1.945-1.184%203.613-1.72C21.695%207.9%2024.195%202.767%2021.678.521m-18.573.543A1.842%201.842%200%200%200%201.27%202.9v16.608a1.84%201.84%200%200%200%201.835%201.834h9.418a22.953%2022.953%200%200%201-.052-2.707c-.006-.062-.011-.141-.016-.2a27.01%2027.01%200%200%200-.473-2.378c-.121-.47-.275-.898-.369-1.057-.116-.197-.098-.31-.097-.432%200-.12.015-.245.037-.386a9.98%209.98%200%200%201%20.234-1.045l.217-.028c-.017-.035-.014-.065-.031-.097l-.041-.381a32.8%2032.8%200%200%201%20.382-1.194l.2-.019c-.008-.016-.01-.038-.018-.053l-.043-.316c.63-3.28%202.587-7.443%204.8-9.791.066-.069.133-.128.198-.194Z'/%3e%3c/svg%3e",R4="data:image/svg+xml,%3csvg%20role='img'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eSupabase%3c/title%3e%3cpath%20d='M11.9%201.036c-.015-.986-1.26-1.41-1.874-.637L.764%2012.05C-.33%2013.427.65%2015.455%202.409%2015.455h9.579l.113%207.51c.014.985%201.259%201.408%201.873.636l9.262-11.653c1.093-1.375.113-3.403-1.645-3.403h-9.642z'/%3e%3c/svg%3e",P4="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3c!--%20Generated%20by%20Pixelmator%20Pro%203.6.17%20--%3e%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Option2SymbolB'%3e%3cg%20id='Layer1-2'%3e%3cg%20id='Group'%20opacity='0.4'%3e%3cpath%20id='Path'%20fill='%23d53c97'%20stroke='none'%20d='M%2017.016802%2012.188573%20C%2017.016802%209.607646%2015.86018%207.293022%2014.039526%205.731081%20C%2013.942595%205.70038%2013.844628%205.671406%2013.745972%205.645189%20C%2013.131133%205.809095%2012.54265%206.059378%2011.998103%206.388559%20C%2013.964327%207.575191%2015.281006%209.730104%2015.281006%2012.188573%20C%2015.279476%2014.563734%2014.033739%2016.764488%2011.998103%2017.988243%20C%2012.542634%2018.317537%2013.131119%2018.567936%2013.745972%2018.731958%20C%2013.844628%2018.705742%2013.942595%2018.67642%2014.039526%2018.645721%20C%2015.86018%2017.084126%2017.016802%2014.769501%2017.016802%2012.188573%20Z'/%3e%3cpath%20id='path1'%20fill='%23d53c97'%20stroke='none'%20d='M%2013.897406%205.609659%20L%2013.894991%205.60759%20C%2013.844973%205.619663%2013.7953%205.631737%2013.745972%205.645189%20C%2013.79599%205.631737%2013.847043%205.622078%2013.897406%205.609659%20Z'/%3e%3cpath%20id='path2'%20fill='%23d53c97'%20stroke='none'%20d='M%201.735796%2012.188573%20C%201.735796%209.164728%203.728925%206.59622%206.470945%205.729357%20C%207.554634%204.797861%208.856011%204.155121%2010.254373%203.860756%20C%209.680216%203.740549%209.095179%203.679977%208.508574%203.68%20C%203.816888%203.68%20-0%207.496887%20-0%2012.188573%20C%20-0%2016.880259%203.816888%2020.697147%208.508574%2020.697147%20C%209.0952%2020.697229%209.680255%2020.636539%2010.254373%2020.516048%20C%208.855971%2020.221794%207.554568%2019.579041%206.470945%2018.647446%20C%203.728925%2017.780582%201.735796%2015.213453%201.735796%2012.188573%20Z'/%3e%3cpath%20id='path3'%20fill='%23d53c97'%20stroke='none'%20d='M%2013.745972%2018.731958%20C%2013.7953%2018.745068%2013.844973%2018.757484%2013.894991%2018.769558%20C%2013.894991%2018.769558%2013.896715%2018.769558%2013.897406%2018.767488%20C%2013.847043%2018.754379%2013.79599%2018.745411%2013.745972%2018.731958%20Z'/%3e%3c/g%3e%3cpath%20id='path4'%20fill='%23ff3b65'%20stroke='none'%20d='M%2020.508402%2012.188573%20C%2020.508402%209.606611%2019.351088%207.290262%2017.5294%205.729357%20C%2016.301817%205.342468%2014.989366%205.313629%2013.745972%205.646223%20C%2016.636665%206.418224%2018.772606%209.058484%2018.772606%2012.189609%20C%2018.772606%2015.320732%2016.636665%2017.960991%2013.745972%2018.731958%20C%2014.98947%2019.064316%2016.301983%2019.034998%2017.5294%2018.647446%20C%2019.419907%2017.034296%2020.508638%2014.673781%2020.508402%2012.188573%20Z'/%3e%3cpath%20id='path5'%20fill='%23ff3b65'%20stroke='none'%20d='M%209.962543%2018.647446%20C%207.220525%2017.780582%205.227395%2015.213453%205.227395%2012.188573%20C%205.227395%209.163693%207.220525%206.59622%209.962543%205.729357%20C%2011.046233%204.797861%2012.34761%204.155121%2013.745972%203.860756%20C%2013.171818%203.74053%2012.586779%203.679956%2012.000173%203.68%20C%207.308832%203.68%203.491599%207.496887%203.491599%2012.188573%20C%203.491599%2016.880259%207.308487%2020.697147%2012.000173%2020.697147%20C%2012.586799%2020.697247%2013.171857%2020.636557%2013.745972%2020.516048%20C%2012.34757%2020.221794%2011.046167%2019.579041%209.962543%2018.647446%20Z'/%3e%3cpath%20id='path6'%20fill='%23383838'%20stroke='none'%20d='M%2015.491772%203.68%20C%2010.800431%203.68%206.983198%207.496887%206.983198%2012.188573%20C%206.983198%2016.880259%2010.800086%2020.697147%2015.491772%2020.697147%20C%2020.183456%2020.697147%2024%2016.880259%2024%2012.188573%20C%2024%207.496887%2020.183456%203.68%2015.491772%203.68%20Z%20M%2022.264549%2012.188573%20C%2022.264549%2015.923018%2019.226215%2018.961351%2015.491772%2018.961351%20C%2011.757326%2018.961351%208.718994%2015.923018%208.718994%2012.188573%20C%208.718994%208.454128%2011.757326%205.415796%2015.491772%205.415796%20C%2019.226215%205.415796%2022.264549%208.454128%2022.264549%2012.188573%20Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",N4=""+new URL("trino-DFsJbQoT.svg",import.meta.url).href,M4=er(),D4={sqlite:A4,duckdb:k4,motherduck:E4,postgres:T1,postgresql:T1,mysql:T4,snowflake:L4,databricks:_4,clickhouse:w4,timeplus:P4,bigquery:C4,trino:N4,iceberg:S4,datafusion:x4,pyspark:O4,redshift:I4,supabase:R4};tm=e=>{let n=(0,M4.c)(11),{name:a,className:o}=e,s=D4[a.toLowerCase()];if(!s){let d;n[0]===o?d=n[1]:(d=Pr("mt-0.5",o),n[0]=o,n[1]=d);let m;return n[2]===d?m=n[3]:(m=(0,N.jsx)(fs,{className:d}),n[2]=d,n[3]=m),m}let c;n[4]!==o||n[5]!==s?(c=Pr("invert-[.5] dark:invert-[.7]",o,s.endsWith(".png")&&"brightness-100 dark:brightness-100 invert-0 dark:invert-0"),n[4]=o,n[5]=s,n[6]=c):c=n[6];let f;return n[7]!==a||n[8]!==c||n[9]!==s?(f=(0,N.jsx)("img",{src:s,alt:a,className:c}),n[7]=a,n[8]=c,n[9]=s,n[10]=f):f=n[10],f};var Cf=er();const j4=e=>{let n=(0,Cf.c)(34),{selectedEngine:a,onChange:o,cellId:s}=e,c=Sn(wd),f=[],d=[];for(let[we,ue]of c.entries())Ki.has(we)?f.push(ue):d.push(ue);let m=C8(),b=a&&!c.has(a),_;n[0]!==c||n[1]!==o||n[2]!==m?(_=we=>{if(we===I1){window.open(L1,"_blank");return}let ue=c.get(we);ue&&(m(),o(ue.name),Ug(ue.name))},n[0]=c,n[1]=o,n[2]=m,n[3]=_):_=n[3];let x=_,S=V4,E=z6,L;n[4]===s?L=n[5]:(L=ud(s),n[4]=s,n[5]=L);let P;n[6]===Symbol.for("react.memo_cache_sentinel")?(P=(0,N.jsx)(P6,{placeholder:"Select an engine"}),n[6]=P):P=n[6];let q;n[7]===L?q=n[8]:(q=(0,N.jsx)(q4,{...L,children:P}),n[7]=L,n[8]=q);let V=M6,B;n[9]===s?B=n[10]:(B=ud(s),n[9]=s,n[10]=B);let M=D6,J;n[11]===Symbol.for("react.memo_cache_sentinel")?(J=(0,N.jsx)(R6,{children:"Database connections"}),n[11]=J):J=n[11];let le;n[12]!==b||n[13]!==a?(le=b&&(0,N.jsx)(jh,{value:a,children:(0,N.jsxs)("div",{className:"flex items-center gap-1 opacity-50",children:[(0,N.jsx)(Fm,{className:"h-3 w-3"}),(0,N.jsx)("span",{className:"truncate",children:Xg(a)})]})},a),n[12]=b,n[13]=a,n[14]=le):le=n[14];let A=S(d),j=d.length>0&&(0,N.jsx)(Sw,{}),$=S(f),oe;n[15]===Symbol.for("react.memo_cache_sentinel")?(oe=(0,N.jsx)(Sw,{}),n[15]=oe):oe=n[15];let de;n[16]===Symbol.for("react.memo_cache_sentinel")?(de=(0,N.jsx)(jh,{className:"text-muted-foreground",value:I1,children:(0,N.jsxs)("a",{className:"flex items-center gap-1",href:L1,target:"_blank",rel:"noreferrer",children:[(0,N.jsx)(H8,{className:"h-3 w-3"}),(0,N.jsx)("span",{children:"How to add a database connection"})]})}),n[16]=de):de=n[16];let he;n[17]!==M||n[18]!==j||n[19]!==$||n[20]!==J||n[21]!==le||n[22]!==A?(he=(0,N.jsxs)(M,{children:[J,le,A,j,$,oe,de]}),n[17]=M,n[18]=j,n[19]=$,n[20]=J,n[21]=le,n[22]=A,n[23]=he):he=n[23];let ye;n[24]!==V||n[25]!==he||n[26]!==B?(ye=(0,N.jsx)(V,{...B,children:he}),n[24]=V,n[25]=he,n[26]=B,n[27]=ye):ye=n[27];let ke;return n[28]!==E||n[29]!==x||n[30]!==a||n[31]!==ye||n[32]!==q?(ke=(0,N.jsx)("div",{className:"flex flex-row gap-1 items-center",children:(0,N.jsxs)(E,{value:a,onValueChange:x,children:[q,ye]})}),n[28]=E,n[29]=x,n[30]=a,n[31]=ye,n[32]=q,n[33]=ke):ke=n[33],ke};var I1="__help__",L1="http://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database";const z4=()=>{let e=(0,Cf.c)(16),{sqlMode:n,setSQLMode:a}=r4(),o;e[0]!==a||e[1]!==n?(o=()=>{let E=n==="validate"?"default":"validate";E==="default"&&JE(),a(E)},e[0]=a,e[1]=n,e[2]=o):o=e[2];let s=o,c=H4,f=$4,d;e[3]===n?d=e[4]:(d=f(n),e[3]=n,e[4]=d);let m;e[5]===n?m=e[6]:(m=c(n),e[5]=n,e[6]=m);let b=n==="validate"?"Validate":"Default",_;e[7]===b?_=e[8]:(_=(0,N.jsx)("span",{className:"ml-1",children:b}),e[7]=b,e[8]=_);let x;e[9]!==s||e[10]!==m||e[11]!==_?(x=(0,N.jsxs)(Ew,{variant:"ghost",size:"sm",onClick:s,className:"h-5 px-1.5 text-xs border-border shadow-none hover:bg-accent",children:[m,_]}),e[9]=s,e[10]=m,e[11]=_,e[12]=x):x=e[12];let S;return e[13]!==d||e[14]!==x?(S=(0,N.jsx)("div",{className:"flex flex-row gap-1 items-center",children:(0,N.jsx)(zh,{delayDuration:300,content:d,children:x})}),e[13]=d,e[14]=x,e[15]=S):S=e[15],S};var q4=e=>{let n=(0,Cf.c)(6),a,o;n[0]===e?(a=n[1],o=n[2]):({children:a,...o}=e,n[0]=e,n[1]=a,n[2]=o);let s;return n[3]!==a||n[4]!==o?(s=(0,N.jsx)(j6,{className:"text-xs border-border shadow-none! ring-0! h-5 px-1.5 hover:bg-accent transition-colors",...o,children:a}),n[3]=a,n[4]=o,n[5]=s):s=n[5],s};function F4(e){return e.source!=="iceberg"}function B4(e){return(0,N.jsx)(jh,{value:e.name,children:(0,N.jsxs)("div",{className:"flex items-center gap-1",children:[(0,N.jsx)(tm,{className:"h-3 w-3",name:e.dialect}),(0,N.jsx)("span",{className:"truncate ml-0.5",children:Xg(e.display_name)})]})},e.name)}function V4(e){return e=e.filter(F4),e.map(B4)}function H4(e){return e==="validate"?(0,N.jsx)(ef,{className:"h-3 w-3"}):(0,N.jsx)(Uh,{className:"h-3 w-3"})}function $4(e){return e==="validate"?(0,N.jsxs)("div",{className:"text-xs",children:[(0,N.jsxs)("div",{className:"font-semibold mb-1 flex flex-row items-center gap-1",children:[(0,N.jsx)(ef,{className:"h-3 w-3"}),"Validate Mode"]}),(0,N.jsx)("p",{children:"Queries are validated as you write them"})]}):(0,N.jsxs)("div",{className:"text-xs",children:[(0,N.jsxs)("div",{className:"font-semibold mb-1 flex flex-row items-center gap-1",children:[(0,N.jsx)(Uh,{className:"h-3 w-3"}),"Default Mode"]}),(0,N.jsx)("p",{children:"Standard editing"})]})}var O1=er(),A1=()=>{let e=(0,O1.c)(1),n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,N.jsx)("div",{className:"h-4 border-r border-border"}),e[0]=n):n=e[0],n};const W4=e=>{let n=(0,O1.c)(102),{view:a}=e,o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o={minWidth:50},n[0]=o):o=n[0];let{spanProps:s,inputProps:c}=y4(o),f;n[1]===a.state?f=n[2]:(f=a.state.field(Bn),n[1]=a.state,n[2]=f);let d=f,m;n[3]===a.state?m=n[4]:(m=a.state.facet(ua),n[3]=a.state,n[4]=m);let b=m,_;n[5]===Symbol.for("react.memo_cache_sentinel")?(_=(0,N.jsx)("div",{}),n[5]=_):_=n[5];let x=_,S=!1,E;n[6]===a?E=n[7]:(E=V=>{a.dispatch({effects:rd.of(V),changes:{from:0,to:a.state.doc.length,insert:a.state.doc.toString()}})},n[6]=a,n[7]=E);let L=E;if(d instanceof kd){let V;n[8]===a.state?V=n[9]:(V=a.state.field(Nr),n[8]=a.state,n[9]=V);let B=V;S=!0;let M;n[10]===L?M=n[11]:(M=Tt=>{let Pt=am(Tt.currentTarget.value,!1);Tt.currentTarget.value=Pt,L({dataframeName:Pt})},n[10]=L,n[11]=M);let J=M,le;n[12]!==L||n[13]!==a?(le=Tt=>{L({engine:Tt}),o4(a,Tt)},n[12]=L,n[13]=a,n[14]=le):le=n[14];let A=le,j;n[15]===Symbol.for("react.memo_cache_sentinel")?(j=(0,N.jsx)("span",{className:"select-none",children:"Output variable: "}),n[15]=j):j=n[15];let $;n[16]===c?$=n[17]:($=Tt=>{var Pt;(Pt=c.onChange)==null||Pt.call(c,Tt)},n[16]=c,n[17]=$);let oe;n[18]===J?oe=n[19]:(oe=Tt=>{Tt.key==="Enter"&&Tt.shiftKey&&J(Tt)},n[18]=J,n[19]=oe);let de;n[20]!==c||n[21]!==B.dataframeName||n[22]!==J||n[23]!==$||n[24]!==oe?(de=(0,N.jsx)("input",{...c,defaultValue:B.dataframeName,onChange:$,onBlur:J,onKeyDown:oe,className:"min-w-14 w-auto border border-border rounded px-1 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"}),n[20]=c,n[21]=B.dataframeName,n[22]=J,n[23]=$,n[24]=oe,n[25]=de):de=n[25];let he;n[26]===s?he=n[27]:(he=(0,N.jsx)("span",{...s}),n[26]=s,n[27]=he);let ye;n[28]!==de||n[29]!==he?(ye=(0,N.jsxs)("label",{className:"flex gap-2 items-center",children:[j,de,he]}),n[28]=de,n[29]=he,n[30]=ye):ye=n[30];let ke;n[31]!==b||n[32]!==B.engine||n[33]!==A?(ke=(0,N.jsx)(j4,{selectedEngine:B.engine,onChange:A,cellId:b}),n[31]=b,n[32]=B.engine,n[33]=A,n[34]=ke):ke=n[34];let we;n[35]===B.engine?we=n[36]:(we=B.engine==="__marimo_duckdb"&&(0,N.jsx)(z4,{}),n[35]=B.engine,n[36]=we);let ue;n[37]!==B.engine||n[38]!==a?(ue=async()=>{await FC(a,B.engine)},n[37]=B.engine,n[38]=a,n[39]=ue):ue=n[39];let ie;n[40]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,N.jsx)(Xm,{className:"h-3 w-3"}),n[40]=ie):ie=n[40];let ee;n[41]===ue?ee=n[42]:(ee=(0,N.jsx)(zh,{content:"Format SQL",children:(0,N.jsx)(Ew,{variant:"text",size:"icon",onClick:ue,children:ie})}),n[41]=ue,n[42]=ee);let W;n[43]===Symbol.for("react.memo_cache_sentinel")?(W=(0,N.jsx)(A1,{}),n[43]=W):W=n[43];let Ie;n[44]===L?Ie=n[45]:(Ie=Tt=>{L({showOutput:!Tt.target.checked})},n[44]=L,n[45]=Ie);let He=!B.showOutput,et;n[46]!==Ie||n[47]!==He?(et=(0,N.jsx)("input",{type:"checkbox",onChange:Ie,checked:He}),n[46]=Ie,n[47]=He,n[48]=et):et=n[48];let Fe;n[49]===Symbol.for("react.memo_cache_sentinel")?(Fe=(0,N.jsx)("span",{className:"select-none",children:"Hide output"}),n[49]=Fe):Fe=n[49];let Ne;n[50]===et?Ne=n[51]:(Ne=(0,N.jsxs)("label",{className:"flex items-center gap-2",children:[et,Fe]}),n[50]=et,n[51]=Ne);let Le;n[52]!==we||n[53]!==ee||n[54]!==Ne?(Le=(0,N.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[we,ee,W,Ne]}),n[52]=we,n[53]=ee,n[54]=Ne,n[55]=Le):Le=n[55];let Me;n[56]!==ye||n[57]!==ke||n[58]!==Le?(Me=(0,N.jsxs)("div",{className:"flex flex-1 gap-2 items-center",children:[ye,ke,Le]}),n[56]=ye,n[57]=ke,n[58]=Le,n[59]=Me):Me=n[59],x=Me}if(d instanceof Ku){S=!0;let V,B,M,J,le,A,j,$,oe,de;if(n[60]!==L||n[61]!==a.state){let{quotePrefix:Ie}=a.state.field(Nr);B=Ie,B===void 0&&(B="r",L({quotePrefix:B})),de=(He,et)=>{typeof et=="boolean"&&L({quotePrefix:b4({currentQuotePrefix:B,checked:et,prefix:He})})},J="flex flex-row w-full justify-end gap-1.5 items-center",oe="flex items-center gap-1.5",n[72]===Symbol.for("react.memo_cache_sentinel")?(M=(0,N.jsx)("span",{children:"r"}),n[72]=M):M=n[72],V=Ll,A="Toggle raw string",j="w-3 h-3",$=B.includes("r"),le=He=>{de("r",He)},n[60]=L,n[61]=a.state,n[62]=V,n[63]=B,n[64]=M,n[65]=J,n[66]=le,n[67]=A,n[68]=j,n[69]=$,n[70]=oe,n[71]=de}else V=n[62],B=n[63],M=n[64],J=n[65],le=n[66],A=n[67],j=n[68],$=n[69],oe=n[70],de=n[71];let he;n[73]!==V||n[74]!==le||n[75]!==A||n[76]!==j||n[77]!==$?(he=(0,N.jsx)(V,{"aria-label":A,className:j,checked:$,onCheckedChange:le}),n[73]=V,n[74]=le,n[75]=A,n[76]=j,n[77]=$,n[78]=he):he=n[78];let ye;n[79]!==M||n[80]!==he||n[81]!==oe?(ye=(0,N.jsxs)("div",{className:oe,children:[M,he]}),n[79]=M,n[80]=he,n[81]=oe,n[82]=ye):ye=n[82];let ke;n[83]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,N.jsx)("span",{children:"f"}),n[83]=ke):ke=n[83];let we;n[84]===B?we=n[85]:(we=B.includes("f"),n[84]=B,n[85]=we);let ue;n[86]===de?ue=n[87]:(ue=Ie=>{de("f",Ie)},n[86]=de,n[87]=ue);let ie;n[88]!==we||n[89]!==ue?(ie=(0,N.jsxs)("div",{className:"flex items-center gap-1.5",children:[ke,(0,N.jsx)(Ll,{"aria-label":"Toggle f-string",className:"w-3 h-3",checked:we,onCheckedChange:ue})]}),n[88]=we,n[89]=ue,n[90]=ie):ie=n[90];let ee;n[91]===Symbol.for("react.memo_cache_sentinel")?(ee=(0,N.jsx)(zh,{content:(0,N.jsx)(E1,{}),children:(0,N.jsx)(vd,{className:"w-3 h-3"})}),n[91]=ee):ee=n[91];let W;n[92]!==J||n[93]!==ye||n[94]!==ie?(W=(0,N.jsxs)("div",{className:J,children:[ye,ie,ee]}),n[92]=J,n[93]=ye,n[94]=ie,n[95]=W):W=n[95],x=W}let P;n[96]===S?P=n[97]:(P=S&&(0,N.jsx)(A1,{}),n[96]=S,n[97]=P);let q;return n[98]!==x||n[99]!==d.type||n[100]!==P?(q=(0,N.jsx)(q6,{children:(0,N.jsxs)("div",{className:"flex justify-between items-center gap-4 pl-2 pt-2",children:[x,P,d.type]})}),n[98]=x,n[99]=d.type,n[100]=P,n[101]=q):q=n[101],q};var Sf=new qu;Yu=la.define(),Bn=is.define({create(){return Hn.python},update(e,n){for(let a of n.effects)if(a.is(Yu))return a.value;return e},provide:e=>qh.from(e,n=>n.type==="python"?null:a=>HC(a,W4))});function U4(){let e=h4(),n=(a,o)=>{let s=e[o%e.length];return s.isSupported(a)?s:n(a,o+1)};return[Ja.of([{key:"F4",preventDefault:!0,run:a=>{let o=a.state.field(Bn),s=e.findIndex(f=>f.type===o.type),c=n(a.state.doc.toString(),s+1);return o===c?!1:(R1({view:a,nextLanguage:c,opts:{keepCodeAsIs:!1}}),!0)}}])]}function R1({view:e,nextLanguage:n,opts:a}){let o=e.state.field(Bn),s=e.state.doc.toString(),c=e.state.facet(qg),f=e.state.facet(Fg),d=e.state.facet(Yd),m=e.state.facet(Ul),b=e.state.facet(Bg),_=e.state.field(Nr),x=e.state.selection.main.head,S;if(a.keepCodeAsIs)S=s,o.type!==n.type&&(_={...n.defaultMetadata});else{let[E,L]=o.transformOut(s,_),[P,q,V]=n.transformIn(E);x+=L,x-=q,x=Vh(x,0,P.length),S=P,_=V}e.dispatch({effects:[Yu.of(n),td.of(_),Sf.reconfigure(n.getExtension(m,c,f,d,b)),ed.reconfigure([]),ys.of(!0)],changes:a.keepCodeAsIs?void 0:{from:0,to:e.state.doc.length,insert:S},selection:a.keepCodeAsIs?void 0:$t.cursor(x)}),e.dispatch({effects:[ed.reconfigure([s8()])]}),n.type==="sql"&&s4(e)}$x=function(e){let{placeholderType:n,completionConfig:a,hotkeys:o,cellId:s,lspConfig:c}=e;return[U4(),Sf.of(Hn.python.getExtension(s,a,o,n,c)),Bn,Nr]},j_=function(e){return P1(wr({state:e}).trim())};function P1(e){return e?Hn.markdown.isSupported(e)?Hn.markdown:Hn.sql.isSupported(e)?Hn.sql:Hn.python:Hn.python}Vu=function(e,n){e.state.field(Bn).type!==n.language&&R1({view:e,nextLanguage:Hn[n.language],opts:{keepCodeAsIs:n.keepCodeAsIs??!1}})},Bx=function(e,{completionConfig:n,hotkeysProvider:a,lspConfig:o}){let s=e.state.field(Bn),c=e.state.facet(Yd),f=e.state.facet(Ul);return f===void 0&&be.error("Cell ID is undefined in reconfigureLanguageEffect"),c===void 0&&be.error("Placeholder type is undefined in reconfigureLanguageEffect"),n===void 0&&be.error("Completion config is undefined in reconfigureLanguageEffect"),Sf.reconfigure(s.getExtension(f,n,a,c,o))},wr=function(e,n,a){let o=e.state.field(Bn),s=e.state.field(Nr),c=e.state.doc.toString();return n===void 0?o.transformOut(c,s)[0]:o.transformOut(c.slice(n,a),s)[0]},Ji=function(e,n){let a=e.state.field(Bn),o=P1(n);o.type!==a.type&&Vu(e,{language:o.type,keepCodeAsIs:!0});let[s]=e.state.field(Bn).transformIn(n);return yd(e,s),s};function K4(e){let n=e.state.selection.main.head,a=e.state.doc.toString(),o=a.length>0&&a[n-1]===`
122
122
  `,s=a.length>0&&a[n]===`
123
123
  `,c=o?n-1:n,f=s?n+1:n;return{beforeCursorCode:wr(e,0,c),afterCursorCode:wr(e,f)}}if(typeof document<"u"){let e="data-temp-href-target";Qh.addHook("beforeSanitizeAttributes",n=>{n.tagName==="A"&&(n.hasAttribute("target")||n.setAttribute("target","_self"),n.hasAttribute("target")&&n.setAttribute(e,n.getAttribute("target")||""))}),Qh.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&n.hasAttribute(e)&&(n.setAttribute("target",n.getAttribute(e)||""),n.removeAttribute(e),n.getAttribute("target")==="_blank"&&n.setAttribute("rel","noopener noreferrer"))})}a0=function(e){let n={USE_PROFILES:{html:!0,svg:!0,mathMl:!0},ADD_TAGS:["use"],ADD_ATTR:["href","xlink:href"],FORCE_BODY:!0,CUSTOM_ELEMENT_HANDLING:{tagNameCheck:/^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,attributeNameCheck:/^[A-Za-z][\w-]*$/},SAFE_FOR_XML:!e.includes("marimo-mermaid")};return Qh.sanitize(e,n)};var Q4=["marimo-carousel","marimo-tabs","marimo-accordion","marimo-sidebar"],G4="h1, h2, h3, h4, h5, h6";function J4(e){if(typeof DOMParser>"u")return null;let n=[],a=new DOMParser().parseFromString(e,"text/html").querySelectorAll(G4);for(let o of Array.from(a)){let s=o.textContent;if(Q4.some(m=>o.closest(m))||!s)continue;let c=Number.parseInt(o.tagName[1],10),f=o.innerHTML,d={name:s,level:c,by:Nm(o)};f!==s&&(d.html=a0(f)),n.push(d)}return{items:n}}Nm=function(e){let n=e.id;if(n)return{id:n};let a=e.textContent;return{path:`//${e.tagName}[contains(., "${a}")]`}};function X4(e){return{items:e.filter(Boolean).flatMap(n=>n.items)}}km=function(e){if(e==null||e.mimetype!=="text/html"&&e.mimetype!=="text/markdown"||e.data==null)return null;try{return rn(typeof e.data=="string","expected string"),J4(e.data)}catch{return be.error("Failed to parse outline"),null}},ux=function(e){return e==null?!1:e.items.some(n=>n.level<=3)};function N1(e,n){let a=f=>f.items.length===0?7:Math.min(...f.items.map(d=>d.level)),o=n[e];if(o==null||o.items.length===0)return be.warn("Failed to find a starting outline"),null;let s=a(o),c=e+1;for(;c<n.length;){let f=n[c];if(f&&a(f)<=s)return[e,c-1];c++}return[e,n.length-1]}md=function(e){return e==="application/vnd.marimo+error"||e==="application/vnd.marimo+traceback"},Cx=Ml("marimo:rtc:username","",Qu),Rm=nr(()=>dd("rtc_v2"));let Ef,M1,Tf,_s;Im=class Cd{static fromMilliseconds(n){return n==null?null:new Cd(n)}static fromSeconds(n){return n==null?null:new Cd(n*1e3)}static now(){return new Cd(Date.now())}constructor(n){this.ms=n}toMilliseconds(){return this.ms}toSeconds(){return this.ms/1e3}},Ef=(pi=class{constructor(){ve(this,"lines",[""]);ve(this,"cursor",{row:0,col:0})}ensureLine(n){for(;this.lines.length<=n;)this.lines.push("")}moveCursor(n,a){let o=this.cursor.row;this.cursor.row=Math.max(0,this.cursor.row+n),this.cursor.col=Math.max(0,this.cursor.col+a),this.ensureLine(this.cursor.row),n<0&&this.cursor.row<o&&this.lines.splice(this.cursor.row+1)}setCursor(n,a){this.cursor.row=Math.max(0,n),this.cursor.col=Math.max(0,a),this.ensureLine(this.cursor.row)}writeChar(n){this.ensureLine(this.cursor.row);let a=this.lines[this.cursor.row].padEnd(this.cursor.col," ");this.lines[this.cursor.row]=a.slice(0,this.cursor.col)+n+a.slice(this.cursor.col+1),this.cursor.col++}writeString(n){if(n.length===0)return;this.ensureLine(this.cursor.row);let a=this.lines[this.cursor.row].padEnd(this.cursor.col," ");this.lines[this.cursor.row]=a.slice(0,this.cursor.col)+n+a.slice(this.cursor.col+n.length),this.cursor.col+=n.length}control(n){switch(n){case`
124
124
  `:this.cursor.row++,this.cursor.col=0,this.ensureLine(this.cursor.row);break;case"\r":this.cursor.col=0;break;case" ":this.writeChar(" ");break;case"\b":this.cursor.col=Math.max(0,this.cursor.col-1);break;case"\v":this.cursor.row++,this.ensureLine(this.cursor.row);break}}handleEscape(n){let a=pi.ESCAPE_REGEX.exec(n);if(!a){this.writeString(n);return}let o=a[1].split(";").map(s=>s===""?1:Number.parseInt(s,10));switch(a[2]){case"A":this.moveCursor(-o[0],0);break;case"B":this.moveCursor(o[0],0);break;case"C":this.moveCursor(0,o[0]);break;case"D":this.moveCursor(0,-o[0]);break;case"H":this.setCursor(o[0]-1||0,o[1]-1||0);break;case"J":o[0]===2&&(this.lines=[""],this.setCursor(0,0));break;case"K":switch(this.ensureLine(this.cursor.row),o[0]){case 0:this.lines[this.cursor.row]=this.lines[this.cursor.row].slice(0,this.cursor.col);break;case 1:{let s=this.lines[this.cursor.row].length;this.lines[this.cursor.row]=" ".repeat(this.cursor.col)+this.lines[this.cursor.row].slice(this.cursor.col,s);break}case 2:this.lines[this.cursor.row]="";break}break;default:this.writeString(n);break}}render(){return this.lines.join(`
@@ -226,4 +226,4 @@ mark line col
226
226
  )
227
227
  `]))));let c=this._buffer.match(this._osc_regex);if(c===null)return e.kind=ht.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;e.kind=ht.OSCURL,e.url=c[1],e.text=c[2];var s=c[0].length;return this._buffer=this._buffer.slice(s),e}else if(o=="(")return e.kind=ht.Unknown,this._buffer=this._buffer.slice(3),e}}ansi_to_html(e){this.append_buffer(e);for(var n=[];;){var a=this.get_next_packet();if(a.kind==ht.EOS||a.kind==ht.Incomplete)break;a.kind==ht.ESC||a.kind==ht.Unknown||(a.kind==ht.Text?n.push(this.transform_to_html(this.with_state(a))):a.kind==ht.SGR?this.process_ansi(a):a.kind==ht.OSCURL&&n.push(this.process_hyperlink(a)))}return n.join("")}with_state(e){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:e.text}}process_ansi(e){let n=e.text.split(";");for(;n.length>0;){let a=n.shift(),o=parseInt(a,10);if(isNaN(o)||o===0)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(o===1)this.bold=!0;else if(o===2)this.faint=!0;else if(o===3)this.italic=!0;else if(o===4)this.underline=!0;else if(o===21)this.bold=!1;else if(o===22)this.faint=!1,this.bold=!1;else if(o===23)this.italic=!1;else if(o===24)this.underline=!1;else if(o===39)this.fg=null;else if(o===49)this.bg=null;else if(o>=30&&o<38)this.fg=this.ansi_colors[0][o-30];else if(o>=40&&o<48)this.bg=this.ansi_colors[0][o-40];else if(o>=90&&o<98)this.fg=this.ansi_colors[1][o-90];else if(o>=100&&o<108)this.bg=this.ansi_colors[1][o-100];else if((o===38||o===48)&&n.length>0){let s=o===38,c=n.shift();if(c==="5"&&n.length>0){let f=parseInt(n.shift(),10);f>=0&&f<=255&&(s?this.fg=this.palette_256[f]:this.bg=this.palette_256[f])}if(c==="2"&&n.length>2){let f=parseInt(n.shift(),10),d=parseInt(n.shift(),10),m=parseInt(n.shift(),10);if(f>=0&&f<=255&&d>=0&&d<=255&&m>=0&&m<=255){let b={rgb:[f,d,m],class_name:"truecolor"};s?this.fg=b:this.bg=b}}}}}transform_to_html(e){let n=e.text;if(n.length===0||(n=this.escape_txt_for_html(n),!e.bold&&!e.italic&&!e.faint&&!e.underline&&e.fg===null&&e.bg===null))return n;let a=[],o=[],s=e.fg,c=e.bg;e.bold&&a.push(this._boldStyle),e.faint&&a.push(this._faintStyle),e.italic&&a.push(this._italicStyle),e.underline&&a.push(this._underlineStyle),this._use_classes?(s&&(s.class_name==="truecolor"?a.push(`color:rgb(${s.rgb.join(",")})`):o.push(`${s.class_name}-fg`)),c&&(c.class_name==="truecolor"?a.push(`background-color:rgb(${c.rgb.join(",")})`):o.push(`${c.class_name}-bg`))):(s&&a.push(`color:rgb(${s.rgb.join(",")})`),c&&a.push(`background-color:rgb(${c.rgb})`));let f="",d="";return o.length&&(f=` class="${o.join(" ")}"`),a.length&&(d=` style="${a.join(";")}"`),`<span${d}${f}>${n}</span>`}process_hyperlink(e){let n=e.url.split(":");return n.length<1||!this._url_allowlist[n[0]]?"":`<a href="${this.escape_txt_for_html(e.url)}">${this.escape_txt_for_html(e.text)}</a>`}};function F1(e,...n){let a=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(a)}function pT(e,...n){let a=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(a,"g")}var hT,mT,gT,yT=new $m;bd=function(e){try{let n=document.createElement("div");return n.innerHTML=e,(n.textContent||n.innerText||"").split(`
228
228
  `).map(a=>a.trimEnd()).join(`
229
- `)}catch(n){return be.error("Error parsing HTML content:",n),e}},ix=function(e){if(!e)return"";try{return bd(yT.ansi_to_html(e))}catch(n){return be.error("Error converting ANSI to plain text:",n),e}},Gh=Te(null);let fi;fi=er(),W_=wk,um=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:w-fit md:max-w-[420px]",o),a[3]=o,a[4]=c);let f;return a[5]!==s||a[6]!==n||a[7]!==c?(f=(0,N.jsx)(N0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=f):f=a[8],f}),um.displayName=N0.displayName;let B1;B1=k6("data-[swipe=move]:transition-none group relative pointer-events-auto flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-right-full",{variants:{variant:{default:"bg-background border",danger:"group destructive text-error border-destructive bg-(--red-1) shadow-md-solid shadow-error"}},defaultVariants:{variant:"default"}}),Qm=_e.forwardRef((e,n)=>{let a=(0,fi.c)(11),o,s,c;a[0]===e?(o=a[1],s=a[2],c=a[3]):({className:o,variant:c,...s}=e,a[0]=e,a[1]=o,a[2]=s,a[3]=c);let f=c||"default",d;a[4]!==o||a[5]!==f?(d=Pr(B1({variant:f}),"print:hidden",o),a[4]=o,a[5]=f,a[6]=d):d=a[6];let m;return a[7]!==s||a[8]!==n||a[9]!==d?(m=(0,N.jsx)(M0,{ref:n,className:d,...s}),a[7]=s,a[8]=n,a[9]=d,a[10]=m):m=a[10],m}),Qm.displayName=M0.displayName;var V1=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-destructive/30 hover:group-[.destructive]:border-destructive/30 hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive",o),a[3]=o,a[4]=c);let f;return a[5]!==s||a[6]!==n||a[7]!==c?(f=(0,N.jsx)(z0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=f):f=a[8],f});V1.displayName=z0.displayName,im=_e.forwardRef((e,n)=>{let a=(0,fi.c)(10),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-hidden focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-500 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600",o),a[3]=o,a[4]=c);let f;a[5]===Symbol.for("react.memo_cache_sentinel")?(f=(0,N.jsx)(B8,{className:"h-4 w-4"}),a[5]=f):f=a[5];let d;return a[6]!==s||a[7]!==n||a[8]!==c?(d=(0,N.jsx)(q0,{ref:n,className:c,"toast-close":"",...s,children:f}),a[6]=s,a[7]=n,a[8]=c,a[9]=d):d=a[9],d}),im.displayName=q0.displayName,_m=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("text-sm font-semibold",o),a[3]=o,a[4]=c);let f;return a[5]!==s||a[6]!==n||a[7]!==c?(f=(0,N.jsx)(D0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=f):f=a[8],f}),_m.displayName=D0.displayName,wm=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("text-sm opacity-90",o),a[3]=o,a[4]=c);let f;return a[5]!==s||a[6]!==n||a[7]!==c?(f=(0,N.jsx)(j0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=f):f=a[8],f}),wm.displayName=j0.displayName;var H1=!1;function vT(e){var o;let n=[],a=[e.console].filter(Boolean).flat();for(let s of a){let c=s.mimetype==="text/plain",f=s.mimetype==="text/html"||s.mimetype==="application/vnd.marimo+traceback";if(c||f){let d=s.channel==="stderr"||s.channel==="marimo-error";switch(s.channel){case"stdout":case"stderr":case"marimo-error":{let m=E8.asString(s.data),b=f?bd(m):m;n.push({timestamp:s.timestamp||Date.now(),level:d?"stderr":"stdout",message:b,cellId:e.cell_id});break}default:break}}}if(n.forEach($1.log),a.length===0&&md((o=e.output)==null?void 0:o.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(c=>{$1.log({level:"stderr",cellId:e.cell_id,timestamp:e.timestamp??0,message:JSON.stringify(c)})});let s=e.output.data.filter(c=>"type"in c&&c.type==="exception"||c.type==="internal");if(s.length>0&&!H1){H1=!0;let c=s.find(f=>f.traceback);El(c?{title:"An internal error occurred",description:c.msg||"Click 'View' to see traceback",variant:"danger",action:_e.createElement(V1,{altText:"View traceback",onClick:()=>{ze.set(Gh,{traceback:c.traceback,errorMessage:c.msg||"An internal error occurred"})}},"View")}:{title:"An internal error occurred",description:"See console for details.",variant:"danger"})}}return n}var $1={log:e=>{let n=e.level==="stdout"?"gray":e.level==="stderr"?"red":"orange",a=e.level.toUpperCase();console.log(`%c[${a}]`,`color:${n}; padding:2px 0; border-radius:2px; font-weight:bold`,`[${sm(e.timestamp)}]`,`(${e.cellId}) ${e.message}`)}};sm=function(e){try{return fT(e).toLocaleTimeString(void 0,{hour12:!0,hour:"numeric",minute:"numeric",second:"numeric"})}catch{return""}},B_=function(e,n){let a=od(n);a?a.focus():be.warn(`[CellFocusManager] focusCellEditor: element not found: ${n}`)},p_=function(e){let n=document.getElementById(En.create(e));n?Lf(n):be.warn(`[CellFocusManager] focusCell: element not found: ${e}`)},d_=function(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})},vm=function(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("marimo-cell")};function Lf(e){try{e.focus()}catch{be.warn("[CellFocusManager] element may not be focusable",e)}}gm=function(e,n){let{retries:a,delay:o,initialDelay:s=0}=n,c=0,f=()=>{if(c<a){try{if(e())return}catch(d){be.error(`Error executing function on attempt ${c+1}, retrying`,{error:d})}c++,setTimeout(f,o)}};s>0?setTimeout(f,s):f()};function ks({cellId:e,cell:n,isCodeHidden:a,codeFocus:o,variableName:s}){var f;if(!n)return;let c=document.getElementById(En.create(e));if(!c){be.warn("scrollCellIntoView: element not found");return}if(vm()){Lf(c);return}if(a)Lf(c);else{let d=(f=n.current)==null?void 0:f.editorView;if(!d){be.warn("scrollCellIntoView: editor not found",e);return}if(d.hasFocus||!document.hasFocus())return;if(gm(()=>(d.focus(),d.hasFocus),{retries:5,delay:20}),o==="top")d.dispatch({selection:{anchor:0,head:0}});else if(o==="bottom"){let m=d.state.doc.line(d.state.doc.lines);d.dispatch({selection:{anchor:m.from,head:m.from}})}else s&&hd(d,s)}c.scrollIntoView({behavior:"smooth",block:"nearest"})}Ux=function(e){let n=document.getElementById(En.create(e));if(!n){be.warn("scrollCellIntoView: element not found");return}n.classList.add("focus-outline"),setTimeout(()=>{n.classList.remove("focus-outline")},2e3),n.scrollIntoView({behavior:"smooth",block:"center"})};function bT(){let e=document.getElementById("App");e==null||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}function wT(){var e;(e=document.getElementById("App"))==null||e.scrollTo({top:0,behavior:"smooth"})}e_=function(e){let n=od(e);if(n!=null&&n.hasFocus){wy(n,{behavior:"instant"});return}let a=document.getElementById(En.create(e));a?a.scrollIntoView({behavior:"instant",block:"nearest"}):be.warn(`[CellFocusManager] scrollCellIntoView: element not found: ${e}`)},rr=function({id:e,name:n="_",code:a="",lastCodeRun:o=null,lastExecutionTime:s=null,edited:c=!1,config:f,serializedEditorState:d=null}){return{id:e,config:f||{hide_code:!1,disabled:!1,column:null},name:n,code:a,edited:c,lastCodeRun:o,lastExecutionTime:s,serializedEditorState:d}};function _T(e){return{hide_code:!1,disabled:!1,column:null,...e}}ar=function(e){return{outline:null,output:null,consoleOutputs:[],status:"idle",staleInputs:!1,interrupted:!1,errored:!1,stopped:!1,runElapsedTimeMs:null,runStartTimestamp:null,lastRunStartTimestamp:null,debuggerActive:!1,...e}};var dc=er();function W1(e){let n={column:0,hide_code:!1,disabled:!1};return{...e,cellData:{[ls]:rr({id:ls,config:n}),...e.cellData},cellRuntime:{[ls]:ar(),...e.cellRuntime},cellHandles:{[ls]:(0,_e.createRef)(),...e.cellHandles}}}function xT(){return W1({cellIds:Dl.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}let kT,U1,CT,K1;({reducer:kT,addMiddleware:U1,createActions:CT,useActions:K1,valueAtom:Ye}=Cl(xT,{createNewCell:(e,n)=>{var L;let{cellId:a,before:o,code:s,lastCodeRun:c=null,lastExecutionTime:f=null,autoFocus:d=!0,skipIfCodeExists:m=!1,hideCode:b=!1}=n,_,x;if(m){for(let P of e.cellIds.inOrderIds)if(((L=e.cellData[P])==null?void 0:L.code)===s)return e}if(a==="__end__"){let P=e.cellIds.atOrThrow(0);_=P.id,x=P.length}else if(typeof a=="string"){let P=e.cellIds.findWithId(a);_=P.id,x=P.topLevelIds.indexOf(a)}else if(a.type==="__end__"){let P=e.cellIds.get(a.columnId)||e.cellIds.atOrThrow(0);_=P.id,x=P.length}else throw Error("Invalid cellId");let S=n.newCellId||Ya.create(),E=o?x:x+1;return{...e,cellIds:e.cellIds.insertId(S,_,E),cellData:{...e.cellData,[S]:rr({id:S,code:s,lastCodeRun:c,config:_T({hide_code:b}),lastExecutionTime:f,edited:!!s&&s!==c})},cellRuntime:{...e.cellRuntime,[S]:ar()},cellHandles:{...e.cellHandles,[S]:(0,_e.createRef)()},scrollKey:d?S:null,untouchedNewCells:b&&!s?new Set([...e.untouchedNewCells,S]):e.untouchedNewCells}},moveCell:(e,n)=>{let{cellId:a,before:o,direction:s}=n;if(o!==void 0&&s!==void 0&&be.warn("Both before and direction specified for moveCell. Ignoring one."),s){let d=e.cellIds.findWithId(a),m=e.cellIds.indexOf(d),b=s==="left"?m-1:m+1,_=e.cellIds.at(b);return _?{...e,cellIds:e.cellIds.moveAcrossColumns(d.id,a,_.id,void 0),scrollKey:a}:e}let c=e.cellIds.findWithId(a),f=c.indexOfOrThrow(a);return o&&f===0?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,f,0),scrollKey:a}:!o&&f===c.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,f,c.length-1),scrollKey:a}:o?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,f,f-1),scrollKey:a}:{...e,cellIds:e.cellIds.moveWithinColumn(c.id,f,f+1),scrollKey:a}},moveCellToIndex:(e,n)=>{let{cellId:a,columnId:o,index:s}=n,c=e.cellIds.findWithId(a),f=c.indexOfOrThrow(a),d=e.cellIds.get(o);if(!d)return e;let m=Math.max(0,Math.min(s,d.length)),b=c.id===o&&f<m?m-1:m;if(c.id===o&&f===b)return e;let _=e.cellIds.deleteById(a),x=_.get(o);return x?{...e,cellIds:_.insertId(a,o,Math.max(0,Math.min(b,x.length))),scrollKey:null}:e},dropCellOverCell:(e,n)=>{let{cellId:a,overCellId:o}=n,s=e.cellIds.findWithId(a),c=e.cellIds.findWithId(o),f=s.indexOfOrThrow(a),d=c.indexOfOrThrow(o);return s.id===c.id?f===d?e:{...e,cellIds:e.cellIds.moveWithinColumn(s.id,f,d),scrollKey:null}:{...e,cellIds:e.cellIds.moveAcrossColumns(s.id,a,c.id,o),scrollKey:null}},dropCellOverColumn:(e,n)=>{let{cellId:a,columnId:o}=n,s=e.cellIds.findWithId(a);return{...e,cellIds:e.cellIds.moveAcrossColumns(s.id,a,o,void 0)}},dropOverNewColumn:(e,n)=>{let{cellId:a}=n;return{...e,cellIds:e.cellIds.moveToNewColumn(a)}},moveColumn:(e,n)=>n.column===n.overColumn?e:{...e,cellIds:e.cellIds.moveColumn(n.column,n.overColumn)},focusCell:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,where:s}=n,c=a.indexOfOrThrow(o),f;f=s==="before"?Vh(c-1,0,a.length-1):s==="after"?Vh(c+1,0,a.length-1):c;let d=a.atOrThrow(f);return ks({cellId:d,cell:e.cellHandles[d],isCodeHidden:Cs(e,d),codeFocus:s==="after"?"top":"bottom",variableName:void 0}),e},focusTopCell:e=>{let n=e.cellIds.getColumns().at(0);if(n===void 0||n.length===0)return e;let a=n.first();return ks({cellId:a,cell:e.cellHandles[a],isCodeHidden:Cs(e,a),codeFocus:void 0,variableName:void 0}),wT(),e},focusBottomCell:e=>{let n=e.cellIds.getColumns().at(-1);if(n===void 0||n.length===0)return e;let a=n.last();return ks({cellId:a,cell:e.cellHandles[a],isCodeHidden:Cs(e,a),codeFocus:void 0,variableName:void 0}),bT(),e},sendToTop:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,scroll:s=!0}=n,c=a.indexOfOrThrow(o);return c===0?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,0),scrollKey:s?o:null}},sendToBottom:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,scroll:s=!0}=n,c=a.indexOfOrThrow(o),f=a.length-1;return c===f?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,f),scrollKey:s?o:null}},addColumn:(e,n)=>{let a=Ya.create();return{...e,cellIds:e.cellIds.addColumn(n.columnId,[a]),cellData:{...e.cellData,[a]:rr({id:a})},cellRuntime:{...e.cellRuntime,[a]:ar()},cellHandles:{...e.cellHandles,[a]:(0,_e.createRef)()},scrollKey:a}},addColumnBreakpoint:(e,n)=>{let{cellId:a}=n;return e.cellIds.getColumns()[0].inOrderIds[0]===a?e:{...e,cellIds:e.cellIds.insertBreakpoint(a)}},deleteColumn:(e,n)=>{let{columnId:a}=n;return{...e,cellIds:e.cellIds.delete(a)}},mergeAllColumns:e=>({...e,cellIds:e.cellIds.mergeAllColumns()}),compactColumns:e=>({...e,cellIds:e.cellIds.compact()}),deleteCell:(e,n)=>{var b,_;let a=n.cellId;if(e.cellIds.hasOnlyOneId())return e;let o;try{o=e.cellIds.findWithId(a)}catch(x){return be.warn("Skipping delete for missing cellId",{cellId:a,error:x}),e}let s=o.indexOfOrThrow(a),c=s===0?1:s-1,f=null;o.length>1&&(f=o.atOrThrow(c));let d=(_=(b=e.cellHandles[a].current)==null?void 0:b.editorView)==null?void 0:_.state.toJSON({history:g8});d&&(d.doc=e.cellData[a].code),TT(a);let m=e.cellData[a];return{...e,cellIds:e.cellIds.deleteById(a),history:[...e.history,{name:m.name,serializedEditorState:d,column:o.id,index:s,isSetupCell:a===Vn,config:m.config}],scrollKey:f}},undoDeleteCell:e=>{if(e.history.length===0)return e;let{name:n,serializedEditorState:a={doc:""},column:o,index:s,isSetupCell:c,config:f}=e.history[e.history.length-1],d=c?Vn:Ya.create(),m=rr({id:d,name:n,code:a.doc,edited:a.doc.trim().length>0,serializedEditorState:a,config:f});return{...e,cellIds:e.cellIds.insertId(d,o,s),cellData:{...e.cellData,[d]:m},cellRuntime:{...e.cellRuntime,[d]:ar()},cellHandles:{...e.cellHandles,[d]:(0,_e.createRef)()},history:e.history.slice(0,-1),scrollKey:d}},clearSerializedEditorState:(e,n)=>{let{cellId:a}=n;return go({state:e,cellId:a,cellReducer:o=>({...o,serializedEditorState:null})})},updateCellCode:(e,n)=>{let{cellId:a,code:o,formattingChange:s}=n;return e.cellData[a]?go({state:e,cellId:a,cellReducer:c=>s?{...c,code:o,lastCodeRun:c.edited?c.lastCodeRun:o}:{...c,code:o,edited:o.trim()!==c.lastCodeRun}}):e},updateCellName:(e,n)=>{let{cellId:a,name:o}=n;return go({state:e,cellId:a,cellReducer:s=>({...s,name:o})})},updateCellConfig:(e,n)=>{let{cellId:a,config:o}=n;return go({state:e,cellId:a,cellReducer:s=>({...s,config:{...s.config,...o}})})},prepareForRun:(e,n)=>go({state:Ss({state:e,cellId:n.cellId,cellReducer:a=>rT(a)}),cellId:n.cellId,cellReducer:a=>({...a,edited:!1,lastCodeRun:a.code.trim()})}),handleCellMessage:(e,n)=>{let a=n.cell_id,o=Ss({state:e,cellId:a,cellReducer:s=>nT(s,n)});return n.status==="queued"&&(o=go({state:o,cellId:a,cellReducer:s=>({...s,lastCodeRun:s.code.trim(),edited:!1})})),{...o,cellLogs:[...o.cellLogs,...vT(n)]}},setCellIds:(e,n)=>{if(m6(e.cellIds.inOrderIds,n.cellIds))return e;let a={...e.cellData},o={...e.cellRuntime},s={...e.cellHandles};for(let c of n.cellIds)c in e.cellData||(a[c]=rr({id:c})),c in e.cellRuntime||(o[c]=ar()),c in e.cellHandles||(s[c]=(0,_e.createRef)());return{...e,cellIds:Dl.fromWithPreviousShape(n.cellIds,e.cellIds),cellData:a,cellRuntime:o,cellHandles:s}},setCellCodes:(e,n)=>{var s,c;rn(n.codes.length===n.ids.length,"Expected codes and ids to have the same length");let a={...e},o=({cell:f,code:d,cellId:m,name:b,config:_})=>{if(!f)return rr({id:m,code:d,name:b,config:_,lastCodeRun:n.codeIsStale?null:d,edited:n.codeIsStale&&d.trim().length>0});let x=n.codeIsStale?f.lastCodeRun:d,S=x?x.trim()!==d.trim():!!d;if(f.code.trim()===d.trim())return{...f,code:d,edited:S,lastCodeRun:x,...b!==void 0&&{name:b},..._!==void 0&&{config:_}};if(!Rm()){let E=a.cellHandles[m].current;E!=null&&E.editorViewOrNull&&Ji(E.editorViewOrNull,d)}return{...f,code:d,edited:S,lastCodeRun:x,...b!==void 0&&{name:b},..._!==void 0&&{config:_}}};for(let f=0;f<n.ids.length;f++){let d=n.ids[f],m=n.codes[f];if(d===void 0||m===void 0)continue;let b=(s=n.names)==null?void 0:s[f],_=(c=n.configs)==null?void 0:c[f];a={...a,cellData:{...a.cellData,[d]:o({cell:a.cellData[d],code:m,cellId:d,name:b,config:_})}}}return a},setStdinResponse:(e,n)=>{let{cellId:a,response:o,outputIndex:s}=n;return Ss({state:e,cellId:a,cellReducer:c=>{let f=[...c.consoleOutputs],d=f[s];return d==null||d.channel!=="stdin"?(be.warn("Expected stdin output"),c):(f[s]={channel:"stdin",mimetype:d.mimetype,data:d.data,timestamp:d.timestamp,response:o},{...c,interrupted:!1,consoleOutputs:f})}})},setCells:(e,n)=>{let a=Object.fromEntries(n.map(s=>[s.id,s])),o=Object.fromEntries(n.map(s=>[s.id,ar()]));return W1({...e,cellIds:Dl.fromIdsAndColumns(n.map(s=>[s.id,s.config.column])),cellData:a,cellRuntime:o,cellHandles:Object.fromEntries(n.map(s=>[s.id,(0,_e.createRef)()]))})},moveToNextCell:(e,n)=>{let{cellId:a,before:o,noCreate:s=!1}=n;if(a==="__scratch__")return e;let c=e.cellIds.findWithId(a),f=c.indexOfOrThrow(a),d=o?f-1:f+1,m=d===c.length,b=d===-1;if(m&&!s){let _=Ya.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,d),cellData:{...e.cellData,[_]:rr({id:_})},cellRuntime:{...e.cellRuntime,[_]:ar()},cellHandles:{...e.cellHandles,[_]:(0,_e.createRef)()},scrollKey:_}}if(b&&!s){let _=Ya.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,0),cellData:{...e.cellData,[_]:rr({id:_})},cellRuntime:{...e.cellRuntime,[_]:ar()},cellHandles:{...e.cellHandles,[_]:(0,_e.createRef)()},scrollKey:_}}if((m||b)&&s)return e;if(d>=0&&d<c.length){let _=c.atOrThrow(d);ks({cellId:_,cell:e.cellHandles[_],isCodeHidden:Cs(e,_),codeFocus:o?"bottom":"top",variableName:void 0})}return e},markTouched:(e,n)=>{let{cellId:a}=n;if(e.untouchedNewCells.has(a)){let o=new Set(e.untouchedNewCells);return o.delete(a),{...e,untouchedNewCells:o}}return e},markUntouched:(e,n)=>{let{cellId:a}=n;if(!e.untouchedNewCells.has(a)){let o=new Set(e.untouchedNewCells);return o.add(a),{...e,untouchedNewCells:o}}return e},scrollToTarget:e=>{let n=e.scrollKey;if(n===null)return e;let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=o===a.length-1?a.last():a.atOrThrow(o);return ks({cellId:s,cell:e.cellHandles[s],isCodeHidden:Cs(e,s),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(Dk(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),unfoldAll:e=>(jk(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),clearLogs:e=>({...e,cellLogs:[]}),collapseCell:(e,n)=>{let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o.topLevelIds.map(d=>e.cellRuntime[d].outline),c=N1(o.indexOfOrThrow(a),s);if(!c)return e;let f=o.atOrThrow(c[1]);return{...e,cellIds:e.cellIds.transformWithCellId(a,d=>d.collapse(a,f)),scrollKey:a}},expandCell:(e,n)=>{let{cellId:a}=n;return{...e,cellIds:e.cellIds.transformWithCellId(a,o=>o.expand(a)),scrollKey:a}},collapseAllCells:e=>({...e,cellIds:e.cellIds.transformAll(n=>{let a=n.topLevelIds.map(m=>e.cellRuntime[m].outline),o=[...n.nodes],s=[],c=[],f=o.length-1;for(;f>=0;){let m=N1(f,a);if(m){let b=f,_=m[1],x=s.find(L=>L.start<=_&&L.end===_);x&&(_=x.start),s.push({start:b,end:_});let S=n.atOrThrow(b),E=n.atOrThrow(_);c.push({id:S,until:E})}else c.push(null);f--}let d=c.toReversed();return n.collapseAll(d)})}),expandAllCells:e=>({...e,cellIds:e.cellIds.transformAll(n=>n.expandAll())}),showCellIfHidden:(e,n)=>{let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o,c=o.findAndExpandDeep(a);return c.equals(s)?e:{...e,cellIds:e.cellIds.transformWithCellId(a,()=>c)}},splitCell:(e,n)=>{var _;let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o.indexOfOrThrow(a),c=e.cellData[a],f=e.cellHandles[a].current;if((f==null?void 0:f.editorView)==null)return e;let{beforeCursorCode:d,afterCursorCode:m}=K4(f.editorView);Ji(f.editorView,d);let b=Ya.create();return{...e,cellIds:e.cellIds.insertId(b,o.id,s+1),cellData:{...e.cellData,[a]:{...c,code:d,edited:!!d&&d.trim()!==((_=c.lastCodeRun)==null?void 0:_.trim())},[b]:rr({id:b,code:m,edited:!!m})},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]},[b]:ar()},cellHandles:{...e.cellHandles,[b]:(0,_e.createRef)()},scrollKey:b}},undoSplitCell:(e,n)=>{var f;let{cellId:a,snapshot:o}=n,s=e.cellData[a],c=e.cellHandles[a].current;return(c==null?void 0:c.editorView)==null?e:(Ji(c.editorView,o),{...e,cellIds:e.cellIds.transformWithCellId(a,d=>{let m=d.indexOfOrThrow(a)+1;return d.deleteAtIndex(m)}),cellData:{...e.cellData,[a]:{...s,code:o,edited:!!o&&(o==null?void 0:o.trim())!==((f=s.lastCodeRun)==null?void 0:f.trim())}},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,n)=>{let{cellId:a}=n;return Ss({state:e,cellId:a,cellReducer:o=>({...o,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,n)=>{let{cellId:a}=n;return Ss({state:e,cellId:a,cellReducer:o=>({...o,consoleOutputs:o.consoleOutputs.filter(s=>s.channel==="stdin"&&s.response==null)})})},clearAllCellOutputs:e=>{let n={...e.cellRuntime};for(let a of e.cellIds.inOrderIds)n[a]={...n[a],output:null,consoleOutputs:[]};return{...e,cellRuntime:n}},addSetupCellIfDoesntExist:(e,n)=>{let{code:a}=n;return e.cellIds.setupCellExists()?{...e,scrollKey:Vn}:{...e,cellIds:e.cellIds.insertId(Vn,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Vn]:rr({id:Vn,name:Vn,code:a,edited:!!a})},cellRuntime:{...e.cellRuntime,[Vn]:ar()},cellHandles:{...e.cellHandles,[Vn]:(0,_e.createRef)()},scrollKey:Vn}}})),U1(dT);function Cs(e,n){return!!e.cellData[n].config.hide_code&&!e.untouchedNewCells.has(n)}function Ss({state:e,cellId:n,cellReducer:a}){return n in e.cellRuntime?{...e,cellRuntime:{...e.cellRuntime,[n]:a(e.cellRuntime[n])}}:(be.warn(`Cell ${n} not found in state`),e)}function go({state:e,cellId:n,cellReducer:a}){return n in e.cellData?{...e,cellData:{...e.cellData,[n]:a(e.cellData[n])}}:(be.warn(`Cell ${n} not found in state`),e)}tx=function(e){let n=e.cellData,a={column:null};return e.cellIds.getColumns().length>1?e.cellIds.getColumns().flatMap((o,s)=>o.inOrderIds.map((c,f)=>{let d={...a};return f===0&&(d.column=s),{...n[c].config,...d}})):e.cellIds.getColumns().flatMap(o=>o.inOrderIds.map(s=>({...n[s].config,...a})))},ad=Te(e=>e(Ye).cellIds),Mx=Te(e=>e(ad).hasOnlyOneId()),K_=Te(e=>pm(e(Ye)).length>0),Te(e=>s0(e(Ye)).length>0);let Q1;Ax=Te(e=>yC(e(Ye))),Wx=Te(e=>mC(e(Ye))),cd=Te(e=>{let{cellIds:n,cellRuntime:a,cellData:o}=e(Ye);return n.inOrderIds.map(s=>{var d;let c=a[s],{name:f}=o[s];if(md((d=c.output)==null?void 0:d.mimetype)){rn(Array.isArray(c.output.data),"Expected array data");let m=c.output.data.filter(b=>!b.type.includes("ancestor"));if(m.length>0)return{output:{...c.output,data:m},cellId:s,cellName:f}}return null}).filter(Boolean)}),D_=Te(e=>{let{cellIds:n,cellRuntime:a}=e(Ye);return X4(n.inOrderIds.map(o=>a[o].outline))}),Ex=Te(e=>e(cd).length),Q1=h6(Te(e=>{let{cellIds:n,cellData:a}=e(Ye);return Rr.fromEntries(n.inOrderIds.map(o=>{var s;return[o,(s=a[o])==null?void 0:s.name]}))}));var ST=Te(e=>e(Ye).scrollKey);u_=()=>Sn(Ye),px=()=>Sn(ad),C_=()=>Sn(Q1),mx=()=>Sn(cd),__=()=>Sn(Ye).cellLogs,g_=()=>Sn(ST),ld=()=>ze.get(Ye),bx=()=>ze.get(Ye).cellIds,kx=()=>{let{cellIds:e,cellData:n}=ze.get(Ye);return e.inOrderIds.map(a=>{var o;return(o=n[a])==null?void 0:o.name}).filter(Boolean)};var ET=Lk(Ck(Ye,e=>e.cellIds.inOrderIds.map(n=>e.cellData[n])));L_=()=>pw(ET),wx=Te(e=>e(Ye).cellRuntime),Vx=Te(e=>pC(e(Ye))),z_=Te(e=>{let{cellRuntime:n}=e(Ye);return Object.entries(n).every(([a,o])=>o.status!=="running"||a==="__scratch__")}),a_=Te(e=>hC(e(Ye))),jx=Te(e=>e(Ye).cellIds.colLength),sx=Te(e=>e(Ye).cellIds.idLength>0),Ix=Te(e=>e(Ye).cellIds.getColumnIds()),gd=Md(e=>Te(n=>n(Ye).cellData[e]));var Of=Md(e=>Te(n=>n(Ye).cellRuntime[e]));const G1=Md(e=>Te(n=>n(Ye).cellHandles[e]));function TT(e){gd.remove(e),Of.remove(e),G1.remove(e)}o_=e=>{let n=(0,dc.c)(2),a;return n[0]===e?a=n[1]:(a=gd(e),n[0]=e,n[1]=a),Sn(a)},R_=e=>{let n=(0,dc.c)(2),a;return n[0]===e?a=n[1]:(a=Of(e),n[0]=e,n[1]=a),Sn(a)},Xw=e=>{let n=(0,dc.c)(2),a;return n[0]===e?a=n[1]:(a=G1(e),n[0]=e,n[1]=a),Sn(a)},t0=()=>{let{cellIds:e,cellHandles:n}=ze.get(Ye);return e.inOrderIds.map(a=>{var o,s;return(s=(o=n[a])==null?void 0:o.current)==null?void 0:s.editorViewOrNull}).filter(Boolean)},od=e=>{var a;let{cellHandles:n}=ze.get(Ye);return(a=n[e].current)==null?void 0:a.editorView},vx=function(e){let{cellIds:n,cellData:a,cellRuntime:o}=e;return n.getColumns().flatMap(s=>s.topLevelIds.map(c=>({...a[c],...o[c]})))},Y_=function(e){return Te(n=>n(Ye).untouchedNewCells.has(e))};function IT(e){let n=Of(e);return Te(a=>{let o=a(n);if(!o||o.status==="queued"||o.status==="running")return;let s=[],c=o.consoleOutputs;if(c&&c.length>0){let d=c.find(m=>m.mimetype==="application/vnd.marimo+traceback");if(d){let m=d.data;s.push(...Zm(m))}}let f=o.output;if((f==null?void 0:f.mimetype)==="application/vnd.marimo+error"){let d=f.data;if(Array.isArray(d))for(let m of d)m.type==="syntax"&&m.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:m.lineno}),m.type==="import-star"&&m.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:m.lineno})}return s.length>0?s:void 0})}c_=function(e){let n=(0,dc.c)(2),a;return n[0]===e?a=n[1]:(a=e===void 0?{}:e,n[0]=e,n[1]=a),K1(a)}})();export{Gh as $,Jh as $n,Xa as $r,Xh as $t,Xw as A,Yh as Ai,Zh as An,Yw as Ar,Zw as At,e_ as B,t_ as Bn,n_ as Br,r_ as Bt,a_ as C,Ya as Ci,em as Cn,i_ as Cr,Bn as Ct,o_ as D,Vn as Di,s_ as Dn,l_ as Dr,tm as Dt,c_ as E,ls as Ei,Tl as En,Bu as Er,Vu as Et,u_ as F,Hu as Fi,Za as Fn,Ki as Fr,nm as Ft,d_ as G,$u as Gn,f_ as Gr,rm as Gt,p_ as H,Wu as Hn,h_ as Hr,m_ as Ht,g_ as I,Uu as Ii,y_ as In,ot as Ir,am as It,im as J,v_ as Jn,om as Jr,Ku as Jt,sm as K,b_ as Kn,Qi as Kr,w_ as Kt,rr as L,Il as Ln,ua as Lr,Ll as Lt,__ as M,lm as Mi,Qu as Mn,x_ as Mr,k_ as Mt,C_ as N,S_ as Ni,E_ as Nn,T_ as Nr,I_ as Nt,L_ as O,Gu as Oi,O_ as On,A_ as Or,cm as Ot,R_ as P,P_ as Pi,N_ as Pn,da as Pr,M_ as Pt,um as Q,dm as Qn,Ol as Qr,fm as Qt,ar as R,Ju as Rn,pm as Rr,Hn as Rt,D_ as S,hm as Si,Xu as Sn,Gi as Sr,j_ as St,z_ as T,En as Ti,q_ as Tn,F_ as Tr,Yu as Tt,B_ as U,Al as Un,mm as Ur,V_ as Ut,gm as V,Zu as Vn,ym as Vr,H_ as Vt,vm as W,$_ as Wn,ed as Wr,bm as Wt,W_ as X,U_ as Xn,Rl as Xr,td as Xt,wm as Y,nd as Yn,Pl as Yr,Nr as Yt,_m as Z,Nl as Zn,cs as Zr,rd as Zt,K_ as _,X8 as __tla,Ml as _i,Q_ as _n,xm as _r,km as _t,ad as a,Dl as ai,G_ as an,Cm as ar,Sm as at,Ye as b,J_ as bi,id as bn,X_ as br,Ji as bt,Y_ as c,Z_ as ci,fa as cn,Em as cr,ex as ct,tx as d,nx as di,rx as dn,Tm as dr,Im as dt,ax as ei,Lm as en,Xi as er,ix as et,od as f,ox as fi,Om as fn,Am as fr,Rm as ft,sx as g,lx as gi,sd as gn,Pm as gr,Nm as gt,ld as h,mn as hi,cx as hn,Mm as hr,ux as ht,cd as i,ei as ii,dx as in,Dm as ir,fx as it,px as j,hx as ji,jm as jn,jl as jr,ud as jt,mx as k,gx as ki,dd as kn,yx as kr,zm as kt,vx as l,fd as li,zl as ln,pd as lr,qm as lt,bx as m,ql as mi,hd as mn,Fm as mr,md as mt,gd as n,Bm as ni,Vm as nn,Hm as nr,$m as nt,wx as o,_x as oi,xx as on,Yi as or,Wm as ot,kx as p,us as pi,Um as pn,Km as pr,Cx as pt,Qm as q,ti as qn,yd as qr,Sx as qt,Ex as r,Gm as ri,Jm as rn,Xm as rr,Tx as rt,Ix as s,Ym as si,Lx as sn,vd as sr,Ox as st,Ax as t,Zm as ti,Rx as tn,e0 as tr,bd as tt,t0 as u,ds as ui,Px as un,fs as ur,Nx as ut,Mx as v,n0 as vi,Dx as vn,r0 as vr,a0 as vt,jx as w,zx as wi,qx as wn,Fx as wr,Bx as wt,Vx as x,Hx as xi,i0 as xn,wd as xr,$x as xt,Wx as y,_d as yi,xd as yn,o0 as yr,wr as yt,Ux as z,ni as zn,s0 as zr,kd as zt};
229
+ `)}catch(n){return be.error("Error parsing HTML content:",n),e}},ix=function(e){if(!e)return"";try{return bd(yT.ansi_to_html(e))}catch(n){return be.error("Error converting ANSI to plain text:",n),e}},Gh=Te(null);let fi;fi=er(),W_=wk,um=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:w-fit md:max-w-[420px]",o),a[3]=o,a[4]=c);let f;return a[5]!==s||a[6]!==n||a[7]!==c?(f=(0,N.jsx)(N0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=f):f=a[8],f}),um.displayName=N0.displayName;let B1;B1=k6("data-[swipe=move]:transition-none group relative pointer-events-auto flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-right-full",{variants:{variant:{default:"bg-background border",danger:"group destructive text-error border-destructive bg-(--red-1) shadow-md-solid shadow-error"}},defaultVariants:{variant:"default"}}),Qm=_e.forwardRef((e,n)=>{let a=(0,fi.c)(11),o,s,c;a[0]===e?(o=a[1],s=a[2],c=a[3]):({className:o,variant:c,...s}=e,a[0]=e,a[1]=o,a[2]=s,a[3]=c);let f=c||"default",d;a[4]!==o||a[5]!==f?(d=Pr(B1({variant:f}),"print:hidden",o),a[4]=o,a[5]=f,a[6]=d):d=a[6];let m;return a[7]!==s||a[8]!==n||a[9]!==d?(m=(0,N.jsx)(M0,{ref:n,className:d,...s}),a[7]=s,a[8]=n,a[9]=d,a[10]=m):m=a[10],m}),Qm.displayName=M0.displayName;var V1=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-destructive/30 hover:group-[.destructive]:border-destructive/30 hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive",o),a[3]=o,a[4]=c);let f;return a[5]!==s||a[6]!==n||a[7]!==c?(f=(0,N.jsx)(z0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=f):f=a[8],f});V1.displayName=z0.displayName,im=_e.forwardRef((e,n)=>{let a=(0,fi.c)(10),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-hidden focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-500 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600",o),a[3]=o,a[4]=c);let f;a[5]===Symbol.for("react.memo_cache_sentinel")?(f=(0,N.jsx)(B8,{className:"h-4 w-4"}),a[5]=f):f=a[5];let d;return a[6]!==s||a[7]!==n||a[8]!==c?(d=(0,N.jsx)(q0,{ref:n,className:c,"toast-close":"",...s,children:f}),a[6]=s,a[7]=n,a[8]=c,a[9]=d):d=a[9],d}),im.displayName=q0.displayName,_m=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("text-sm font-semibold",o),a[3]=o,a[4]=c);let f;return a[5]!==s||a[6]!==n||a[7]!==c?(f=(0,N.jsx)(D0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=f):f=a[8],f}),_m.displayName=D0.displayName,wm=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("text-sm opacity-90",o),a[3]=o,a[4]=c);let f;return a[5]!==s||a[6]!==n||a[7]!==c?(f=(0,N.jsx)(j0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=f):f=a[8],f}),wm.displayName=j0.displayName;var H1=!1;function vT(e){var o;let n=[],a=[e.console].filter(Boolean).flat();for(let s of a){let c=s.mimetype==="text/plain",f=s.mimetype==="text/html"||s.mimetype==="application/vnd.marimo+traceback";if(c||f){let d=s.channel==="stderr"||s.channel==="marimo-error";switch(s.channel){case"stdout":case"stderr":case"marimo-error":{let m=E8.asString(s.data),b=f?bd(m):m;n.push({timestamp:s.timestamp||Date.now(),level:d?"stderr":"stdout",message:b,cellId:e.cell_id});break}default:break}}}if(n.forEach($1.log),a.length===0&&md((o=e.output)==null?void 0:o.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(c=>{$1.log({level:"stderr",cellId:e.cell_id,timestamp:e.timestamp??0,message:JSON.stringify(c)})});let s=e.output.data.filter(c=>"type"in c&&c.type==="exception"||c.type==="internal");if(s.length>0&&!H1){H1=!0;let c=s.find(f=>f.traceback);El(c?{title:"An internal error occurred",description:c.msg||"Click 'View' to see traceback",variant:"danger",action:_e.createElement(V1,{altText:"View traceback",onClick:()=>{ze.set(Gh,{traceback:c.traceback,errorMessage:c.msg||"An internal error occurred"})}},"View")}:{title:"An internal error occurred",description:"See console for details.",variant:"danger"})}}return n}var $1={log:e=>{let n=e.level==="stdout"?"gray":e.level==="stderr"?"red":"orange",a=e.level.toUpperCase();console.log(`%c[${a}]`,`color:${n}; padding:2px 0; border-radius:2px; font-weight:bold`,`[${sm(e.timestamp)}]`,`(${e.cellId}) ${e.message}`)}};sm=function(e){try{return fT(e).toLocaleTimeString(void 0,{hour12:!0,hour:"numeric",minute:"numeric",second:"numeric"})}catch{return""}},B_=function(e,n){let a=od(n);a?a.focus():be.warn(`[CellFocusManager] focusCellEditor: element not found: ${n}`)},p_=function(e){let n=document.getElementById(En.create(e));n?Lf(n):be.warn(`[CellFocusManager] focusCell: element not found: ${e}`)},d_=function(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})},vm=function(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("marimo-cell")};function Lf(e){try{e.focus()}catch{be.warn("[CellFocusManager] element may not be focusable",e)}}gm=function(e,n){let{retries:a,delay:o,initialDelay:s=0}=n,c=0,f=()=>{if(c<a){try{if(e())return}catch(d){be.error(`Error executing function on attempt ${c+1}, retrying`,{error:d})}c++,setTimeout(f,o)}};s>0?setTimeout(f,s):f()};function ks({cellId:e,cell:n,isCodeHidden:a,codeFocus:o,variableName:s}){var f;if(!n)return;let c=document.getElementById(En.create(e));if(!c){be.warn("scrollCellIntoView: element not found");return}if(vm()){Lf(c);return}if(a)Lf(c);else{let d=(f=n.current)==null?void 0:f.editorView;if(!d){be.warn("scrollCellIntoView: editor not found",e);return}if(d.hasFocus||!document.hasFocus())return;if(gm(()=>(d.focus(),d.hasFocus),{retries:5,delay:20}),o==="top")d.dispatch({selection:{anchor:0,head:0}});else if(o==="bottom"){let m=d.state.doc.line(d.state.doc.lines);d.dispatch({selection:{anchor:m.from,head:m.from}})}else s&&hd(d,s)}c.scrollIntoView({behavior:"smooth",block:"nearest"})}Ux=function(e){let n=document.getElementById(En.create(e));if(!n){be.warn("scrollCellIntoView: element not found");return}n.classList.add("focus-outline"),setTimeout(()=>{n.classList.remove("focus-outline")},2e3),n.scrollIntoView({behavior:"smooth",block:"center"})};function bT(){let e=document.getElementById("App");e==null||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}function wT(){var e;(e=document.getElementById("App"))==null||e.scrollTo({top:0,behavior:"smooth"})}e_=function(e){let n=od(e);if(n!=null&&n.hasFocus){wy(n,{behavior:"instant"});return}let a=document.getElementById(En.create(e));a?a.scrollIntoView({behavior:"instant",block:"nearest"}):be.warn(`[CellFocusManager] scrollCellIntoView: element not found: ${e}`)},rr=function({id:e,name:n="_",code:a="",lastCodeRun:o=null,lastExecutionTime:s=null,edited:c=!1,config:f,serializedEditorState:d=null}){return{id:e,config:f||{hide_code:!1,disabled:!1,column:null},name:n,code:a,edited:c,lastCodeRun:o,lastExecutionTime:s,serializedEditorState:d}};function _T(e){return{hide_code:!1,disabled:!1,column:null,...e}}ar=function(e){return{outline:null,output:null,consoleOutputs:[],status:"idle",staleInputs:!1,interrupted:!1,errored:!1,stopped:!1,runElapsedTimeMs:null,runStartTimestamp:null,lastRunStartTimestamp:null,debuggerActive:!1,...e}};var dc=er();function W1(e){let n={column:0,hide_code:!1,disabled:!1};return{...e,cellData:{[ls]:rr({id:ls,config:n}),...e.cellData},cellRuntime:{[ls]:ar(),...e.cellRuntime},cellHandles:{[ls]:(0,_e.createRef)(),...e.cellHandles}}}function xT(){return W1({cellIds:Dl.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}let kT,U1,CT,K1;({reducer:kT,addMiddleware:U1,createActions:CT,useActions:K1,valueAtom:Ye}=Cl(xT,{createNewCell:(e,n)=>{var L;let{cellId:a,before:o,code:s,lastCodeRun:c=null,lastExecutionTime:f=null,autoFocus:d=!0,skipIfCodeExists:m=!1,hideCode:b=!1}=n,_,x;if(m){for(let P of e.cellIds.inOrderIds)if(((L=e.cellData[P])==null?void 0:L.code)===s)return e}if(a==="__end__"){let P=e.cellIds.atOrThrow(0);_=P.id,x=P.length}else if(typeof a=="string"){let P=e.cellIds.findWithId(a);_=P.id,x=P.topLevelIds.indexOf(a)}else if(a.type==="__end__"){let P=e.cellIds.get(a.columnId)||e.cellIds.atOrThrow(0);_=P.id,x=P.length}else throw Error("Invalid cellId");let S=n.newCellId||Ya.create(),E=o?x:x+1;return{...e,cellIds:e.cellIds.insertId(S,_,E),cellData:{...e.cellData,[S]:rr({id:S,code:s,lastCodeRun:c,config:_T({hide_code:b}),lastExecutionTime:f,edited:!!s&&s!==c})},cellRuntime:{...e.cellRuntime,[S]:ar()},cellHandles:{...e.cellHandles,[S]:(0,_e.createRef)()},scrollKey:d?S:null,untouchedNewCells:b&&!s?new Set([...e.untouchedNewCells,S]):e.untouchedNewCells}},moveCell:(e,n)=>{let{cellId:a,before:o,direction:s}=n;if(o!==void 0&&s!==void 0&&be.warn("Both before and direction specified for moveCell. Ignoring one."),s){let d=e.cellIds.findWithId(a),m=e.cellIds.indexOf(d),b=s==="left"?m-1:m+1,_=e.cellIds.at(b);return _?{...e,cellIds:e.cellIds.moveAcrossColumns(d.id,a,_.id,void 0),scrollKey:a}:e}let c=e.cellIds.findWithId(a),f=c.indexOfOrThrow(a);return o&&f===0?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,f,0),scrollKey:a}:!o&&f===c.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,f,c.length-1),scrollKey:a}:o?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,f,f-1),scrollKey:a}:{...e,cellIds:e.cellIds.moveWithinColumn(c.id,f,f+1),scrollKey:a}},moveCellToIndex:(e,n)=>{let{cellId:a,columnId:o,index:s}=n,c=e.cellIds.findWithId(a),f=c.indexOfOrThrow(a),d=e.cellIds.get(o);if(!d)return e;let m=Math.max(0,Math.min(s,d.length)),b=c.id===o&&f<m?m-1:m;if(c.id===o&&f===b)return e;let _=e.cellIds.deleteById(a),x=_.get(o);return x?{...e,cellIds:_.insertId(a,o,Math.max(0,Math.min(b,x.length))),scrollKey:null}:e},dropCellOverCell:(e,n)=>{let{cellId:a,overCellId:o}=n,s=e.cellIds.findWithId(a),c=e.cellIds.findWithId(o),f=s.indexOfOrThrow(a),d=c.indexOfOrThrow(o);return s.id===c.id?f===d?e:{...e,cellIds:e.cellIds.moveWithinColumn(s.id,f,d),scrollKey:null}:{...e,cellIds:e.cellIds.moveAcrossColumns(s.id,a,c.id,o),scrollKey:null}},dropCellOverColumn:(e,n)=>{let{cellId:a,columnId:o}=n,s=e.cellIds.findWithId(a);return{...e,cellIds:e.cellIds.moveAcrossColumns(s.id,a,o,void 0)}},dropOverNewColumn:(e,n)=>{let{cellId:a}=n;return{...e,cellIds:e.cellIds.moveToNewColumn(a)}},moveColumn:(e,n)=>n.column===n.overColumn?e:{...e,cellIds:e.cellIds.moveColumn(n.column,n.overColumn)},focusCell:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,where:s}=n,c=a.indexOfOrThrow(o),f;f=s==="before"?Vh(c-1,0,a.length-1):s==="after"?Vh(c+1,0,a.length-1):c;let d=a.atOrThrow(f);return ks({cellId:d,cell:e.cellHandles[d],isCodeHidden:Cs(e,d),codeFocus:s==="after"?"top":"bottom",variableName:void 0}),e},focusTopCell:e=>{let n=e.cellIds.getColumns().at(0);if(n===void 0||n.length===0)return e;let a=n.first();return ks({cellId:a,cell:e.cellHandles[a],isCodeHidden:Cs(e,a),codeFocus:void 0,variableName:void 0}),wT(),e},focusBottomCell:e=>{let n=e.cellIds.getColumns().at(-1);if(n===void 0||n.length===0)return e;let a=n.last();return ks({cellId:a,cell:e.cellHandles[a],isCodeHidden:Cs(e,a),codeFocus:void 0,variableName:void 0}),bT(),e},sendToTop:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,scroll:s=!0}=n,c=a.indexOfOrThrow(o);return c===0?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,0),scrollKey:s?o:null}},sendToBottom:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,scroll:s=!0}=n,c=a.indexOfOrThrow(o),f=a.length-1;return c===f?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,f),scrollKey:s?o:null}},addColumn:(e,n)=>{let a=Ya.create();return{...e,cellIds:e.cellIds.addColumn(n.columnId,[a]),cellData:{...e.cellData,[a]:rr({id:a})},cellRuntime:{...e.cellRuntime,[a]:ar()},cellHandles:{...e.cellHandles,[a]:(0,_e.createRef)()},scrollKey:a}},addColumnBreakpoint:(e,n)=>{let{cellId:a}=n;return e.cellIds.getColumns()[0].inOrderIds[0]===a?e:{...e,cellIds:e.cellIds.insertBreakpoint(a)}},deleteColumn:(e,n)=>{let{columnId:a}=n;return{...e,cellIds:e.cellIds.delete(a)}},mergeAllColumns:e=>({...e,cellIds:e.cellIds.mergeAllColumns()}),compactColumns:e=>({...e,cellIds:e.cellIds.compact()}),deleteCell:(e,n)=>{var b,_;let a=n.cellId;if(e.cellIds.hasOnlyOneId())return e;let o;try{o=e.cellIds.findWithId(a)}catch(x){return be.warn("Skipping delete for missing cellId",{cellId:a,error:x}),e}let s=o.indexOfOrThrow(a),c=s===0?1:s-1,f=null;o.length>1&&(f=o.atOrThrow(c));let d=(_=(b=e.cellHandles[a].current)==null?void 0:b.editorView)==null?void 0:_.state.toJSON({history:v8});d&&(d.doc=e.cellData[a].code),TT(a);let m=e.cellData[a];return{...e,cellIds:e.cellIds.deleteById(a),history:[...e.history,{name:m.name,serializedEditorState:d,column:o.id,index:s,isSetupCell:a===Vn,config:m.config}],scrollKey:f}},undoDeleteCell:e=>{if(e.history.length===0)return e;let{name:n,serializedEditorState:a={doc:""},column:o,index:s,isSetupCell:c,config:f}=e.history[e.history.length-1],d=c?Vn:Ya.create(),m=rr({id:d,name:n,code:a.doc,edited:a.doc.trim().length>0,serializedEditorState:a,config:f});return{...e,cellIds:e.cellIds.insertId(d,o,s),cellData:{...e.cellData,[d]:m},cellRuntime:{...e.cellRuntime,[d]:ar()},cellHandles:{...e.cellHandles,[d]:(0,_e.createRef)()},history:e.history.slice(0,-1),scrollKey:d}},clearSerializedEditorState:(e,n)=>{let{cellId:a}=n;return go({state:e,cellId:a,cellReducer:o=>({...o,serializedEditorState:null})})},updateCellCode:(e,n)=>{let{cellId:a,code:o,formattingChange:s}=n;return e.cellData[a]?go({state:e,cellId:a,cellReducer:c=>s?{...c,code:o,lastCodeRun:c.edited?c.lastCodeRun:o}:{...c,code:o,edited:o.trim()!==c.lastCodeRun}}):e},updateCellName:(e,n)=>{let{cellId:a,name:o}=n;return go({state:e,cellId:a,cellReducer:s=>({...s,name:o})})},updateCellConfig:(e,n)=>{let{cellId:a,config:o}=n;return go({state:e,cellId:a,cellReducer:s=>({...s,config:{...s.config,...o}})})},prepareForRun:(e,n)=>go({state:Ss({state:e,cellId:n.cellId,cellReducer:a=>rT(a)}),cellId:n.cellId,cellReducer:a=>({...a,edited:!1,lastCodeRun:a.code.trim()})}),handleCellMessage:(e,n)=>{let a=n.cell_id,o=Ss({state:e,cellId:a,cellReducer:s=>nT(s,n)});return n.status==="queued"&&(o=go({state:o,cellId:a,cellReducer:s=>({...s,lastCodeRun:s.code.trim(),edited:!1})})),{...o,cellLogs:[...o.cellLogs,...vT(n)]}},setCellIds:(e,n)=>{if(m6(e.cellIds.inOrderIds,n.cellIds))return e;let a={...e.cellData},o={...e.cellRuntime},s={...e.cellHandles};for(let c of n.cellIds)c in e.cellData||(a[c]=rr({id:c})),c in e.cellRuntime||(o[c]=ar()),c in e.cellHandles||(s[c]=(0,_e.createRef)());return{...e,cellIds:Dl.fromWithPreviousShape(n.cellIds,e.cellIds),cellData:a,cellRuntime:o,cellHandles:s}},setCellCodes:(e,n)=>{var s,c;rn(n.codes.length===n.ids.length,"Expected codes and ids to have the same length");let a={...e},o=({cell:f,code:d,cellId:m,name:b,config:_})=>{if(!f)return rr({id:m,code:d,name:b,config:_,lastCodeRun:n.codeIsStale?null:d,edited:n.codeIsStale&&d.trim().length>0});let x=n.codeIsStale?f.lastCodeRun:d,S=x?x.trim()!==d.trim():!!d;if(f.code.trim()===d.trim())return{...f,code:d,edited:S,lastCodeRun:x,...b!==void 0&&{name:b},..._!==void 0&&{config:_}};if(!Rm()){let E=a.cellHandles[m].current;E!=null&&E.editorViewOrNull&&Ji(E.editorViewOrNull,d)}return{...f,code:d,edited:S,lastCodeRun:x,...b!==void 0&&{name:b},..._!==void 0&&{config:_}}};for(let f=0;f<n.ids.length;f++){let d=n.ids[f],m=n.codes[f];if(d===void 0||m===void 0)continue;let b=(s=n.names)==null?void 0:s[f],_=(c=n.configs)==null?void 0:c[f];a={...a,cellData:{...a.cellData,[d]:o({cell:a.cellData[d],code:m,cellId:d,name:b,config:_})}}}return a},setStdinResponse:(e,n)=>{let{cellId:a,response:o,outputIndex:s}=n;return Ss({state:e,cellId:a,cellReducer:c=>{let f=[...c.consoleOutputs],d=f[s];return d==null||d.channel!=="stdin"?(be.warn("Expected stdin output"),c):(f[s]={channel:"stdin",mimetype:d.mimetype,data:d.data,timestamp:d.timestamp,response:o},{...c,interrupted:!1,consoleOutputs:f})}})},setCells:(e,n)=>{let a=Object.fromEntries(n.map(s=>[s.id,s])),o=Object.fromEntries(n.map(s=>[s.id,ar()]));return W1({...e,cellIds:Dl.fromIdsAndColumns(n.map(s=>[s.id,s.config.column])),cellData:a,cellRuntime:o,cellHandles:Object.fromEntries(n.map(s=>[s.id,(0,_e.createRef)()]))})},moveToNextCell:(e,n)=>{let{cellId:a,before:o,noCreate:s=!1}=n;if(a==="__scratch__")return e;let c=e.cellIds.findWithId(a),f=c.indexOfOrThrow(a),d=o?f-1:f+1,m=d===c.length,b=d===-1;if(m&&!s){let _=Ya.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,d),cellData:{...e.cellData,[_]:rr({id:_})},cellRuntime:{...e.cellRuntime,[_]:ar()},cellHandles:{...e.cellHandles,[_]:(0,_e.createRef)()},scrollKey:_}}if(b&&!s){let _=Ya.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,0),cellData:{...e.cellData,[_]:rr({id:_})},cellRuntime:{...e.cellRuntime,[_]:ar()},cellHandles:{...e.cellHandles,[_]:(0,_e.createRef)()},scrollKey:_}}if((m||b)&&s)return e;if(d>=0&&d<c.length){let _=c.atOrThrow(d);ks({cellId:_,cell:e.cellHandles[_],isCodeHidden:Cs(e,_),codeFocus:o?"bottom":"top",variableName:void 0})}return e},markTouched:(e,n)=>{let{cellId:a}=n;if(e.untouchedNewCells.has(a)){let o=new Set(e.untouchedNewCells);return o.delete(a),{...e,untouchedNewCells:o}}return e},markUntouched:(e,n)=>{let{cellId:a}=n;if(!e.untouchedNewCells.has(a)){let o=new Set(e.untouchedNewCells);return o.add(a),{...e,untouchedNewCells:o}}return e},scrollToTarget:e=>{let n=e.scrollKey;if(n===null)return e;let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=o===a.length-1?a.last():a.atOrThrow(o);return ks({cellId:s,cell:e.cellHandles[s],isCodeHidden:Cs(e,s),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(Dk(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),unfoldAll:e=>(jk(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),clearLogs:e=>({...e,cellLogs:[]}),collapseCell:(e,n)=>{let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o.topLevelIds.map(d=>e.cellRuntime[d].outline),c=N1(o.indexOfOrThrow(a),s);if(!c)return e;let f=o.atOrThrow(c[1]);return{...e,cellIds:e.cellIds.transformWithCellId(a,d=>d.collapse(a,f)),scrollKey:a}},expandCell:(e,n)=>{let{cellId:a}=n;return{...e,cellIds:e.cellIds.transformWithCellId(a,o=>o.expand(a)),scrollKey:a}},collapseAllCells:e=>({...e,cellIds:e.cellIds.transformAll(n=>{let a=n.topLevelIds.map(m=>e.cellRuntime[m].outline),o=[...n.nodes],s=[],c=[],f=o.length-1;for(;f>=0;){let m=N1(f,a);if(m){let b=f,_=m[1],x=s.find(L=>L.start<=_&&L.end===_);x&&(_=x.start),s.push({start:b,end:_});let S=n.atOrThrow(b),E=n.atOrThrow(_);c.push({id:S,until:E})}else c.push(null);f--}let d=c.toReversed();return n.collapseAll(d)})}),expandAllCells:e=>({...e,cellIds:e.cellIds.transformAll(n=>n.expandAll())}),showCellIfHidden:(e,n)=>{let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o,c=o.findAndExpandDeep(a);return c.equals(s)?e:{...e,cellIds:e.cellIds.transformWithCellId(a,()=>c)}},splitCell:(e,n)=>{var _;let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o.indexOfOrThrow(a),c=e.cellData[a],f=e.cellHandles[a].current;if((f==null?void 0:f.editorView)==null)return e;let{beforeCursorCode:d,afterCursorCode:m}=K4(f.editorView);Ji(f.editorView,d);let b=Ya.create();return{...e,cellIds:e.cellIds.insertId(b,o.id,s+1),cellData:{...e.cellData,[a]:{...c,code:d,edited:!!d&&d.trim()!==((_=c.lastCodeRun)==null?void 0:_.trim())},[b]:rr({id:b,code:m,edited:!!m})},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]},[b]:ar()},cellHandles:{...e.cellHandles,[b]:(0,_e.createRef)()},scrollKey:b}},undoSplitCell:(e,n)=>{var f;let{cellId:a,snapshot:o}=n,s=e.cellData[a],c=e.cellHandles[a].current;return(c==null?void 0:c.editorView)==null?e:(Ji(c.editorView,o),{...e,cellIds:e.cellIds.transformWithCellId(a,d=>{let m=d.indexOfOrThrow(a)+1;return d.deleteAtIndex(m)}),cellData:{...e.cellData,[a]:{...s,code:o,edited:!!o&&(o==null?void 0:o.trim())!==((f=s.lastCodeRun)==null?void 0:f.trim())}},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,n)=>{let{cellId:a}=n;return Ss({state:e,cellId:a,cellReducer:o=>({...o,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,n)=>{let{cellId:a}=n;return Ss({state:e,cellId:a,cellReducer:o=>({...o,consoleOutputs:o.consoleOutputs.filter(s=>s.channel==="stdin"&&s.response==null)})})},clearAllCellOutputs:e=>{let n={...e.cellRuntime};for(let a of e.cellIds.inOrderIds)n[a]={...n[a],output:null,consoleOutputs:[]};return{...e,cellRuntime:n}},addSetupCellIfDoesntExist:(e,n)=>{let{code:a}=n;return e.cellIds.setupCellExists()?{...e,scrollKey:Vn}:{...e,cellIds:e.cellIds.insertId(Vn,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Vn]:rr({id:Vn,name:Vn,code:a,edited:!!a})},cellRuntime:{...e.cellRuntime,[Vn]:ar()},cellHandles:{...e.cellHandles,[Vn]:(0,_e.createRef)()},scrollKey:Vn}}})),U1(dT);function Cs(e,n){return!!e.cellData[n].config.hide_code&&!e.untouchedNewCells.has(n)}function Ss({state:e,cellId:n,cellReducer:a}){return n in e.cellRuntime?{...e,cellRuntime:{...e.cellRuntime,[n]:a(e.cellRuntime[n])}}:(be.warn(`Cell ${n} not found in state`),e)}function go({state:e,cellId:n,cellReducer:a}){return n in e.cellData?{...e,cellData:{...e.cellData,[n]:a(e.cellData[n])}}:(be.warn(`Cell ${n} not found in state`),e)}tx=function(e){let n=e.cellData,a={column:null};return e.cellIds.getColumns().length>1?e.cellIds.getColumns().flatMap((o,s)=>o.inOrderIds.map((c,f)=>{let d={...a};return f===0&&(d.column=s),{...n[c].config,...d}})):e.cellIds.getColumns().flatMap(o=>o.inOrderIds.map(s=>({...n[s].config,...a})))},ad=Te(e=>e(Ye).cellIds),Mx=Te(e=>e(ad).hasOnlyOneId()),K_=Te(e=>pm(e(Ye)).length>0),Te(e=>s0(e(Ye)).length>0);let Q1;Ax=Te(e=>yC(e(Ye))),Wx=Te(e=>mC(e(Ye))),cd=Te(e=>{let{cellIds:n,cellRuntime:a,cellData:o}=e(Ye);return n.inOrderIds.map(s=>{var d;let c=a[s],{name:f}=o[s];if(md((d=c.output)==null?void 0:d.mimetype)){rn(Array.isArray(c.output.data),"Expected array data");let m=c.output.data.filter(b=>!b.type.includes("ancestor"));if(m.length>0)return{output:{...c.output,data:m},cellId:s,cellName:f}}return null}).filter(Boolean)}),D_=Te(e=>{let{cellIds:n,cellRuntime:a}=e(Ye);return X4(n.inOrderIds.map(o=>a[o].outline))}),Ex=Te(e=>e(cd).length),Q1=h6(Te(e=>{let{cellIds:n,cellData:a}=e(Ye);return Rr.fromEntries(n.inOrderIds.map(o=>{var s;return[o,(s=a[o])==null?void 0:s.name]}))}));var ST=Te(e=>e(Ye).scrollKey);u_=()=>Sn(Ye),px=()=>Sn(ad),C_=()=>Sn(Q1),mx=()=>Sn(cd),__=()=>Sn(Ye).cellLogs,g_=()=>Sn(ST),ld=()=>ze.get(Ye),bx=()=>ze.get(Ye).cellIds,kx=()=>{let{cellIds:e,cellData:n}=ze.get(Ye);return e.inOrderIds.map(a=>{var o;return(o=n[a])==null?void 0:o.name}).filter(Boolean)};var ET=Lk(Ck(Ye,e=>e.cellIds.inOrderIds.map(n=>e.cellData[n])));L_=()=>pw(ET),wx=Te(e=>e(Ye).cellRuntime),Vx=Te(e=>pC(e(Ye))),z_=Te(e=>{let{cellRuntime:n}=e(Ye);return Object.entries(n).every(([a,o])=>o.status!=="running"||a==="__scratch__")}),a_=Te(e=>hC(e(Ye))),jx=Te(e=>e(Ye).cellIds.colLength),sx=Te(e=>e(Ye).cellIds.idLength>0),Ix=Te(e=>e(Ye).cellIds.getColumnIds()),gd=Md(e=>Te(n=>n(Ye).cellData[e]));var Of=Md(e=>Te(n=>n(Ye).cellRuntime[e]));const G1=Md(e=>Te(n=>n(Ye).cellHandles[e]));function TT(e){gd.remove(e),Of.remove(e),G1.remove(e)}o_=e=>{let n=(0,dc.c)(2),a;return n[0]===e?a=n[1]:(a=gd(e),n[0]=e,n[1]=a),Sn(a)},R_=e=>{let n=(0,dc.c)(2),a;return n[0]===e?a=n[1]:(a=Of(e),n[0]=e,n[1]=a),Sn(a)},Xw=e=>{let n=(0,dc.c)(2),a;return n[0]===e?a=n[1]:(a=G1(e),n[0]=e,n[1]=a),Sn(a)},t0=()=>{let{cellIds:e,cellHandles:n}=ze.get(Ye);return e.inOrderIds.map(a=>{var o,s;return(s=(o=n[a])==null?void 0:o.current)==null?void 0:s.editorViewOrNull}).filter(Boolean)},od=e=>{var a;let{cellHandles:n}=ze.get(Ye);return(a=n[e].current)==null?void 0:a.editorView},vx=function(e){let{cellIds:n,cellData:a,cellRuntime:o}=e;return n.getColumns().flatMap(s=>s.topLevelIds.map(c=>({...a[c],...o[c]})))},Y_=function(e){return Te(n=>n(Ye).untouchedNewCells.has(e))};function IT(e){let n=Of(e);return Te(a=>{let o=a(n);if(!o||o.status==="queued"||o.status==="running")return;let s=[],c=o.consoleOutputs;if(c&&c.length>0){let d=c.find(m=>m.mimetype==="application/vnd.marimo+traceback");if(d){let m=d.data;s.push(...Zm(m))}}let f=o.output;if((f==null?void 0:f.mimetype)==="application/vnd.marimo+error"){let d=f.data;if(Array.isArray(d))for(let m of d)m.type==="syntax"&&m.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:m.lineno}),m.type==="import-star"&&m.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:m.lineno})}return s.length>0?s:void 0})}c_=function(e){let n=(0,dc.c)(2),a;return n[0]===e?a=n[1]:(a=e===void 0?{}:e,n[0]=e,n[1]=a),K1(a)}})();export{Gh as $,Jh as $n,Xa as $r,Xh as $t,Xw as A,Yh as Ai,Zh as An,Yw as Ar,Zw as At,e_ as B,t_ as Bn,n_ as Br,r_ as Bt,a_ as C,Ya as Ci,em as Cn,i_ as Cr,Bn as Ct,o_ as D,Vn as Di,s_ as Dn,l_ as Dr,tm as Dt,c_ as E,ls as Ei,Tl as En,Bu as Er,Vu as Et,u_ as F,Hu as Fi,Za as Fn,Ki as Fr,nm as Ft,d_ as G,$u as Gn,f_ as Gr,rm as Gt,p_ as H,Wu as Hn,h_ as Hr,m_ as Ht,g_ as I,Uu as Ii,y_ as In,ot as Ir,am as It,im as J,v_ as Jn,om as Jr,Ku as Jt,sm as K,b_ as Kn,Qi as Kr,w_ as Kt,rr as L,Il as Ln,ua as Lr,Ll as Lt,__ as M,lm as Mi,Qu as Mn,x_ as Mr,k_ as Mt,C_ as N,S_ as Ni,E_ as Nn,T_ as Nr,I_ as Nt,L_ as O,Gu as Oi,O_ as On,A_ as Or,cm as Ot,R_ as P,P_ as Pi,N_ as Pn,da as Pr,M_ as Pt,um as Q,dm as Qn,Ol as Qr,fm as Qt,ar as R,Ju as Rn,pm as Rr,Hn as Rt,D_ as S,hm as Si,Xu as Sn,Gi as Sr,j_ as St,z_ as T,En as Ti,q_ as Tn,F_ as Tr,Yu as Tt,B_ as U,Al as Un,mm as Ur,V_ as Ut,gm as V,Zu as Vn,ym as Vr,H_ as Vt,vm as W,$_ as Wn,ed as Wr,bm as Wt,W_ as X,U_ as Xn,Rl as Xr,td as Xt,wm as Y,nd as Yn,Pl as Yr,Nr as Yt,_m as Z,Nl as Zn,cs as Zr,rd as Zt,K_ as _,X8 as __tla,Ml as _i,Q_ as _n,xm as _r,km as _t,ad as a,Dl as ai,G_ as an,Cm as ar,Sm as at,Ye as b,J_ as bi,id as bn,X_ as br,Ji as bt,Y_ as c,Z_ as ci,fa as cn,Em as cr,ex as ct,tx as d,nx as di,rx as dn,Tm as dr,Im as dt,ax as ei,Lm as en,Xi as er,ix as et,od as f,ox as fi,Om as fn,Am as fr,Rm as ft,sx as g,lx as gi,sd as gn,Pm as gr,Nm as gt,ld as h,mn as hi,cx as hn,Mm as hr,ux as ht,cd as i,ei as ii,dx as in,Dm as ir,fx as it,px as j,hx as ji,jm as jn,jl as jr,ud as jt,mx as k,gx as ki,dd as kn,yx as kr,zm as kt,vx as l,fd as li,zl as ln,pd as lr,qm as lt,bx as m,ql as mi,hd as mn,Fm as mr,md as mt,gd as n,Bm as ni,Vm as nn,Hm as nr,$m as nt,wx as o,_x as oi,xx as on,Yi as or,Wm as ot,kx as p,us as pi,Um as pn,Km as pr,Cx as pt,Qm as q,ti as qn,yd as qr,Sx as qt,Ex as r,Gm as ri,Jm as rn,Xm as rr,Tx as rt,Ix as s,Ym as si,Lx as sn,vd as sr,Ox as st,Ax as t,Zm as ti,Rx as tn,e0 as tr,bd as tt,t0 as u,ds as ui,Px as un,fs as ur,Nx as ut,Mx as v,n0 as vi,Dx as vn,r0 as vr,a0 as vt,jx as w,zx as wi,qx as wn,Fx as wr,Bx as wt,Vx as x,Hx as xi,i0 as xn,wd as xr,$x as xt,Wx as y,_d as yi,xd as yn,o0 as yr,wr as yt,Ux as z,ni as zn,s0 as zr,kd as zt};