@marimo-team/frontend 0.18.5-dev172 → 0.18.5-dev176

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 (77) hide show
  1. package/dist/assets/{CellStatus-ClrYbUob.js → CellStatus-CBYhhgmz.js} +1 -1
  2. package/dist/assets/{JsonOutput-CkeISXrs.js → JsonOutput-CZTTeJuI.js} +9 -9
  3. package/dist/assets/{MarimoErrorOutput-CO8cm8-0.js → MarimoErrorOutput-C_Zgofmd.js} +2 -2
  4. package/dist/assets/{RenderHTML-D6fh5YLC.js → RenderHTML-CQm5bp6v.js} +1 -1
  5. package/dist/assets/{add-cell-with-ai-B3V6Mgb9.js → add-cell-with-ai-CYDfp9kl.js} +12 -12
  6. package/dist/assets/{add-database-form-C-K88iSC.js → add-database-form-CAIOqeCP.js} +1 -1
  7. package/dist/assets/{agent-panel-BvLqBe3U.js → agent-panel-DA-Q5xZe.js} +6 -6
  8. package/dist/assets/{ai-model-dropdown-D1nEKS8b.js → ai-model-dropdown-DYQpnG3w.js} +1 -1
  9. package/dist/assets/{app-config-button-BD5l-v4I.js → app-config-button-BgBrtReY.js} +1 -1
  10. package/dist/assets/{cell-actions-CJiaF9Tu.js → cell-actions-Cfm2D7jK.js} +1 -1
  11. package/dist/assets/cell-link-gAvJ31U3.js +1 -0
  12. package/dist/assets/{cells-rr1jjvJk.js → cells-BEv4yuHU.js} +49 -49
  13. package/dist/assets/{chat-components-DXJsXOD8.js → chat-components-CtSjkjex.js} +1 -1
  14. package/dist/assets/{chat-display-C08N0rx5.js → chat-display-KOmOjcf7.js} +1 -1
  15. package/dist/assets/{chat-panel-CNL6ANh8.js → chat-panel-Cnzaj27Q.js} +2 -2
  16. package/dist/assets/client-B4TxOzev.js +4 -0
  17. package/dist/assets/{column-preview-BzvHnhPG.js → column-preview-BBUgbmud.js} +1 -1
  18. package/dist/assets/{command-xU8ykulh.js → command-Ba7-DaYn.js} +1 -1
  19. package/dist/assets/{command-palette-B_md1fzh.js → command-palette-YDHUhPo7.js} +1 -1
  20. package/dist/assets/{common-_RAkDTpe.js → common-DAfp8hHB.js} +1 -1
  21. package/dist/assets/{datasource-DHbNHnua.js → datasource-hC-skADj.js} +2 -2
  22. package/dist/assets/{dependency-graph-panel-BGp5UzmZ.js → dependency-graph-panel-StKdREPL.js} +3 -3
  23. package/dist/assets/{documentation-panel-CuPlvIjJ.js → documentation-panel-CTFNwL8m.js} +1 -1
  24. package/dist/assets/{download-DKRxBkYD.js → download-VDZsvjsd.js} +1 -1
  25. package/dist/assets/{edit-page-DAFshpgY.js → edit-page-BidQt2RA.js} +7 -7
  26. package/dist/assets/{error-panel-CoYFpNUd.js → error-panel-DdOpe33s.js} +1 -1
  27. package/dist/assets/{es-YVwBDiDw.js → es-BlGpQO9i.js} +1 -1
  28. package/dist/assets/{file-explorer-panel-BcpntT7Q.js → file-explorer-panel-CKyg9zrY.js} +1 -1
  29. package/dist/assets/{floating-outline-CHprSkP6.js → floating-outline-DPboW4_E.js} +1 -1
  30. package/dist/assets/{focus-D3ygI6Sy.js → focus-yB7yTfF-.js} +1 -1
  31. package/dist/assets/{form-B_zRT4QS.js → form-iKFmPQ40.js} +2 -2
  32. package/dist/assets/{globals-D46Vbo5D.js → globals-TVCm1yPw.js} +1 -1
  33. package/dist/assets/{home-page-DuPzZzUf.js → home-page-CONVcKNl.js} +2 -2
  34. package/dist/assets/{index-CQBtzy-J.js → index-B8BT3mFF.js} +8 -8
  35. package/dist/assets/{kiosk-mode-CTjr_Jn4.js → kiosk-mode-DcdtDydP.js} +1 -1
  36. package/dist/assets/{layout-CprHgyfx.js → layout-BlZ6buP7.js} +3 -3
  37. package/dist/assets/{logs-panel-CFM-1lMP.js → logs-panel-DijLPYP3.js} +1 -1
  38. package/dist/assets/{markdown-renderer-DecoaRsV.js → markdown-renderer-D0AQKFve.js} +1 -1
  39. package/dist/assets/{mode-BYulXE3t.js → mode-DwlGsYIa.js} +1 -1
  40. package/dist/assets/{name-cell-input-BGJDnv5Z.js → name-cell-input-6Dtlhxow.js} +1 -1
  41. package/dist/assets/{outline-panel-C-__7mIh.js → outline-panel-P4zU6fY0.js} +1 -1
  42. package/dist/assets/{packages-panel-B4bQCG8Y.js → packages-panel-v9jWz5EP.js} +1 -1
  43. package/dist/assets/{panel-context-Bee798AZ.js → panel-context-60G2HB3E.js} +7 -7
  44. package/dist/assets/{panels-CuLZ4Xjj.js → panels-lotEul91.js} +1 -1
  45. package/dist/assets/{process-output-2gz8Uri2.js → process-output-DYPOAdn4.js} +1 -1
  46. package/dist/assets/{readonly-python-code-ihKi3Mrq.js → readonly-python-code-DekTVJhb.js} +1 -1
  47. package/dist/assets/{run-page-Q1ifcEUY.js → run-page-tmxSwwZL.js} +1 -1
  48. package/dist/assets/scratchpad-panel-C6eFtFsQ.js +1 -0
  49. package/dist/assets/{session-panel-Bn5_JmbT.js → session-panel-kCJhrTva.js} +1 -1
  50. package/dist/assets/{snippets-panel-CVBBnX9H.js → snippets-panel-BNyKWUxX.js} +1 -1
  51. package/dist/assets/{state-BHFBtWym.js → state-BrkNVBuj.js} +1 -1
  52. package/dist/assets/{state-DNwec0Uj.js → state-DTKootMj.js} +1 -1
  53. package/dist/assets/{switch-iJj-D3dz.js → switch-1zrEJdOH.js} +1 -1
  54. package/dist/assets/{textarea-DmNrZcLR.js → textarea-CmispJBv.js} +1 -1
  55. package/dist/assets/tracing-BOiTysGY.js +1 -0
  56. package/dist/assets/{tracing-panel-DaDvGMEN.js → tracing-panel-Cu4PqbRd.js} +2 -2
  57. package/dist/assets/{types-4-l_7Ws2.js → types-Qx81Y6OC.js} +1 -1
  58. package/dist/assets/{useAddCell-BpMe5DB-.js → useAddCell-DAIZvt_N.js} +1 -1
  59. package/dist/assets/{useCellActionButton-Dh4wbVPA.js → useCellActionButton-CbsPOO0-.js} +1 -1
  60. package/dist/assets/{useDeleteCell-DBzN8QcP.js → useDeleteCell-Dpa7vzrC.js} +1 -1
  61. package/dist/assets/{useNotebookActions-DKyQBNlS.js → useNotebookActions-CwwguV4h.js} +1 -1
  62. package/dist/assets/useRunCells-dG-K1cYZ.js +1 -0
  63. package/dist/assets/{useSplitCell-CvKAuKQ_.js → useSplitCell-2xhwtwJD.js} +1 -1
  64. package/dist/assets/{utilities.esm-CT3NbLA9.js → utilities.esm-DcHHFDdt.js} +2 -2
  65. package/dist/index.html +31 -31
  66. package/package.json +1 -1
  67. package/src/components/editor/chrome/state.ts +3 -3
  68. package/src/components/editor/chrome/types.ts +22 -0
  69. package/src/components/editor/chrome/wrapper/app-chrome.tsx +7 -2
  70. package/src/components/editor/chrome/wrapper/sidebar.tsx +7 -2
  71. package/src/core/config/capabilities.ts +1 -1
  72. package/src/plugins/impl/code/any-language-editor.tsx +1 -1
  73. package/dist/assets/cell-link-Hwo1QbqQ.js +0 -1
  74. package/dist/assets/client-SMzMTiO_.js +0 -4
  75. package/dist/assets/scratchpad-panel-B75Qsjwz.js +0 -1
  76. package/dist/assets/tracing-D9h130fg.js +0 -1
  77. package/dist/assets/useRunCells-BGzo-QMk.js +0 -1
@@ -1,3 +1,3 @@
1
- var at=Object.defineProperty;var it=(t,e,n)=>e in t?at(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>it(t,typeof e!="symbol"?e+"":e,n);var j;import{s as ce}from"./chunk-LvLJmgfZ.js";import{i as Q,l as D,o as ot,p as P}from"./useEvent-DlWF5OMa.js";import{t as lt}from"./react-BGmjiNul.js";import{Rr as ut,Wr as ct,Xr as z,Yr as dt,v as ft,y as mt}from"./cells-rr1jjvJk.js";import{B as pt,C as de,D as ht,I as gt,N as yt,P as O,R as fe,k as W,w as me}from"./zod-Cg4WLWh2.js";import{t as pe}from"./compiler-runtime-DeeZ7FnK.js";import{t as bt}from"./get-CyLJYAfP.js";import{r as wt}from"./useLifecycle-CmDXEyIC.js";import{t as vt}from"./debounce-BbFlGgjv.js";import{t as xt}from"./_baseSet-6FYvpjrm.js";import{d as E,p as y}from"./hotkeys-uKX61F1_.js";import{t as Et}from"./invariant-C6yE60hi.js";import{x as _t}from"./utils-CJJIceVn.js";import{M as Ct}from"./config-cCkBQ_ER.js";import{a as kt}from"./switch-iJj-D3dz.js";import{n as he}from"./globals-D46Vbo5D.js";import{t as ge}from"./ErrorBoundary-Drf1manw.js";import{t as Rt}from"./jsx-runtime-DN_bIXfG.js";import{t as Ft}from"./button-DuYGqRtX.js";import{t as Nt}from"./cn-C1rgT0yh.js";import{Z as St}from"./JsonOutput-CkeISXrs.js";import{t as ye}from"./requests-C0HaHO6a.js";import{t as be}from"./createLucideIcon-CW2xpJ57.js";import{h as qt}from"./select-D0g5GnIs.js";import{c as Pt,i as Mt,l as jt,r as Tt,u as It}from"./markdown-renderer-DecoaRsV.js";import{t as At}from"./DeferredRequestRegistry-B3BENoUa.js";import{t as K}from"./Deferred-DzyBMRsy.js";import{t as Lt}from"./uuid-ClFZlR7U.js";import{t as Ut}from"./use-toast-Bzf3rpev.js";import{t as we}from"./tooltip-CvjcEpZC.js";import{t as ve}from"./mode-BYulXE3t.js";import{n as zt,r as Ot,t as Wt}from"./share-CXQVxivL.js";import{r as Dt,t as Ht}from"./react-resizable-panels.browser.esm-BqxQegSf.js";import{t as xe}from"./toggle-G1t0cQyf.js";function Bt(t,e,n){return t==null?t:xt(t,e,n)}var H=Bt,Vt=be("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),Xt=be("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function $t(t){return{all:t||(t=new Map),on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}var u=ce(lt(),1),Z=(0,u.createContext)(null),Yt=t=>{let{controller:e}=(0,u.useContext)(Z),n=u.useRef(Symbol("fill"));return(0,u.useEffect)(()=>(e.mount({name:t.name,ref:n.current,children:t.children}),()=>{e.unmount({name:t.name,ref:n.current})}),[]),(0,u.useEffect)(()=>{e.update({name:t.name,ref:n.current,children:t.children})}),null},Gt=Object.defineProperty,Qt=(t,e,n)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ee=(t,e,n)=>(Qt(t,typeof e=="symbol"?e:e+"",n),n),_e=console,Kt=class{constructor(t){Ee(this,"_bus"),Ee(this,"_db"),this._bus=t,this.handleFillMount=this.handleFillMount.bind(this),this.handleFillUpdated=this.handleFillUpdated.bind(this),this.handleFillUnmount=this.handleFillUnmount.bind(this),this._db={byName:new Map,byFill:new Map}}mount(){this._bus.on("fill-mount",this.handleFillMount),this._bus.on("fill-updated",this.handleFillUpdated),this._bus.on("fill-unmount",this.handleFillUnmount)}unmount(){this._bus.off("fill-mount",this.handleFillMount),this._bus.off("fill-updated",this.handleFillUpdated),this._bus.off("fill-unmount",this.handleFillUnmount)}handleFillMount({fill:t}){let e=u.Children.toArray(t.children),n=t.name,r={fill:t,children:e,name:n},s=this._db.byName.get(n);s?(s.components.push(r),s.listeners.forEach(i=>i([...s.components]))):this._db.byName.set(n,{listeners:[],components:[r]}),this._db.byFill.set(t.ref,r)}handleFillUpdated({fill:t}){let e=this._db.byFill.get(t.ref),n=u.Children.toArray(t.children);if(e){e.children=n;let r=this._db.byName.get(e.name);if(r)r.listeners.forEach(s=>s([...r.components]));else throw Error("registration was expected to be defined")}else{_e.error("[handleFillUpdated] component was expected to be defined");return}}handleFillUnmount({fill:t}){let e=this._db.byFill.get(t.ref);if(!e){_e.error("[handleFillUnmount] component was expected to be defined");return}let n=e.name,r=this._db.byName.get(n);if(!r)throw Error("registration was expected to be defined");r.components=r.components.filter(s=>s!==e),this._db.byFill.delete(t.ref),r.listeners.length===0&&r.components.length===0?this._db.byName.delete(n):r.listeners.forEach(s=>s([...r.components]))}onComponentsChange(t,e){let n=this._db.byName.get(t);n?(n.listeners.push(e),e(n.components)):(this._db.byName.set(t,{listeners:[e],components:[]}),e([]))}getFillsByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.fill):[]}getChildrenByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.children).reduce((n,r)=>n.concat(r),[]):[]}removeOnComponentsChange(t,e){let n=this._db.byName.get(t);if(!n)throw Error("expected registration to be defined");let r=n.listeners;r.splice(r.indexOf(e),1)}},Zt=Object.defineProperty,Jt=(t,e,n)=>e in t?Zt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,en=(t,e,n)=>(Jt(t,typeof e=="symbol"?e:e+"",n),n),Ce=class{constructor(){en(this,"bus",$t())}mount(t){this.bus.emit("fill-mount",{fill:t})}unmount(t){this.bus.emit("fill-unmount",{fill:t})}update(t){this.bus.emit("fill-updated",{fill:t})}};function tn(t){let e=t||new Ce;return{controller:e,manager:new Kt(e.bus)}}var nn=({controller:t,children:e})=>{let[n]=u.useState(()=>{let r=tn(t);return r.manager.mount(),r});return u.useEffect(()=>()=>{n.manager.unmount()},[]),u.createElement(Z.Provider,{value:n},e)};function J(t,e){let[n,r]=(0,u.useState)([]),{manager:s}=(0,u.useContext)(Z);return(0,u.useEffect)(()=>(s.onComponentsChange(t,r),()=>{s.removeOnComponentsChange(t,r)}),[t]),n.flatMap((i,d)=>{let{children:l}=i;return l.map((p,b)=>{if(typeof p=="number"||typeof p=="string")throw Error("Only element children will work here");return u.cloneElement(p,{key:d.toString()+b.toString(),...e})})})}var ke=t=>{let e=J(t.name,t.childProps);if(typeof t.children=="function"){let n=t.children(e);if(u.isValidElement(n)||n===null)return n;throw Error("Slot rendered with function must return a valid React Element.")}return e};const rn=new Ce,B={SIDEBAR:"sidebar",CONTEXT_AWARE_PANEL:"context-aware-panel"};var sn=class{constructor(){a(this,"subscriptions",new Map)}addSubscription(t,e){var n;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(n=this.subscriptions.get(t))==null||n.add(e)}removeSubscription(t,e){var n;(n=this.subscriptions.get(t))==null||n.delete(e)}notify(t,e){for(let n of this.subscriptions.get(t)??[])n(e)}},Re=class ue{constructor(e){a(this,"subscriptions",new sn);this.producer=e}static withProducerCallback(e){return new ue(e)}static empty(){return new ue}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,n){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,n){this.subscriptions.addSubscription(e,n),e==="open"&&n(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,n){this.subscriptions.removeSubscription(e,n)}},an=1e10,on=1e3;function V(t,e){let n=t.map(r=>`"${r}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${n}`)}function ln(t={}){let e={};function n(o){e=o}let r={};function s(o){var f;r.unregisterHandler&&r.unregisterHandler(),r=o,(f=r.registerHandler)==null||f.call(r,U)}let i;function d(o){if(typeof o=="function"){i=o;return}i=(f,g)=>{let c=o[f];if(c)return c(g);let h=o._;if(!h)throw Error(`The requested method has no handler: ${f}`);return h(f,g)}}let{maxRequestTime:l=on}=t;t.transport&&s(t.transport),t.requestHandler&&d(t.requestHandler),t._debugHooks&&n(t._debugHooks);let p=0;function b(){return p<=an?++p:p=0}let x=new Map,w=new Map;function _(o,...f){let g=f[0];return new Promise((c,h)=>{var I;if(!r.send)throw V(["send"],"make requests");let S=b(),M={type:"request",id:S,method:o,params:g};x.set(S,{resolve:c,reject:h}),l!==1/0&&w.set(S,setTimeout(()=>{w.delete(S),h(Error("RPC request timed out."))},l)),(I=e.onSend)==null||I.call(e,M),r.send(M)})}let F=new Proxy(_,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>_(f,c)}),C=F;function k(o,...f){var h;let g=f[0];if(!r.send)throw V(["send"],"send messages");let c={type:"message",id:o,payload:g};(h=e.onSend)==null||h.call(e,c),r.send(c)}let R=new Proxy(k,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>k(f,c)}),v=R,N=new Map,q=new Set;function T(o,f){var g;if(!r.registerHandler)throw V(["registerHandler"],"register message listeners");if(o==="*"){q.add(f);return}N.has(o)||N.set(o,new Set),(g=N.get(o))==null||g.add(f)}function L(o,f){var g,c;if(o==="*"){q.delete(f);return}(g=N.get(o))==null||g.delete(f),((c=N.get(o))==null?void 0:c.size)===0&&N.delete(o)}async function U(o){var f,g;if((f=e.onReceive)==null||f.call(e,o),!("type"in o))throw Error("Message does not contain a type.");if(o.type==="request"){if(!r.send||!i)throw V(["send","requestHandler"],"handle requests");let{id:c,method:h,params:S}=o,M;try{M={type:"response",id:c,success:!0,payload:await i(h,S)}}catch(I){if(!(I instanceof Error))throw I;M={type:"response",id:c,success:!1,error:I.message}}(g=e.onSend)==null||g.call(e,M),r.send(M);return}if(o.type==="response"){let c=w.get(o.id);c!=null&&clearTimeout(c);let{resolve:h,reject:S}=x.get(o.id)??{};o.success?h==null||h(o.payload):S==null||S(Error(o.error));return}if(o.type==="message"){for(let h of q)h(o.id,o.payload);let c=N.get(o.id);if(!c)return;for(let h of c)h(o.payload);return}throw Error(`Unexpected RPC message type: ${o.type}`)}return{setTransport:s,setRequestHandler:d,request:F,requestProxy:C,send:R,sendProxy:v,addMessageListener:T,removeMessageListener:L,proxy:{send:v,request:C},_setDebugHooks:n}}function un(t){return ln(t)}var Fe="[transport-id]";function cn(t,e){let{transportId:n}=e;return n==null?t:{[Fe]:n,data:t}}function dn(t,e){let{transportId:n,filter:r}=e,s=r==null?void 0:r();if(n!=null&&s!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(n){if(t[Fe]!==n)return[!0];i=t.data}return s===!1?[!0]:[!1,i]}function fn(t,e={}){let{transportId:n,filter:r,remotePort:s}=e,i=t,d=s??t,l;return{send(p){d.postMessage(cn(p,{transportId:n}))},registerHandler(p){l=b=>{let x=b.data,[w,_]=dn(x,{transportId:n,filter:()=>r==null?void 0:r(b)});w||p(_)},i.addEventListener("message",l)},unregisterHandler(){l&&i.removeEventListener("message",l)}}}function mn(t,e){return fn(t,e)}function Ne(t){return un({transport:mn(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{E.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{E.debug("[rpc] Worker -> Parent",e)}}})}const Se=P("Initializing..."),pn=P(t=>{let e=t(ft),n=Object.values(e.cellRuntime);return n.some(r=>!It(r.output))?!0:n.every(r=>r.status==="idle")});var qe=zt(),Pe="marimo:file",Me=new ut(null);const hn={saveFile(t){Me.set(Pe,t)},readFile(){return Me.get(Pe)}};var gn={saveFile(t){z.setCodeForHash((0,qe.compressToEncodedURIComponent)(t))},readFile(){let t=z.getCodeFromHash()||z.getCodeFromSearchParam();return t?(0,qe.decompressFromEncodedURIComponent)(t):null}};const yn={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var bn={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}},wn={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
1
+ var at=Object.defineProperty;var it=(t,e,n)=>e in t?at(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>it(t,typeof e!="symbol"?e+"":e,n);var j;import{s as ce}from"./chunk-LvLJmgfZ.js";import{i as Q,l as D,o as ot,p as P}from"./useEvent-DlWF5OMa.js";import{t as lt}from"./react-BGmjiNul.js";import{Gr as ut,Xr as ct,Zr as z,v as dt,y as ft,zr as mt}from"./cells-BEv4yuHU.js";import{B as pt,C as de,D as ht,I as gt,N as yt,P as O,R as fe,k as W,w as me}from"./zod-Cg4WLWh2.js";import{t as pe}from"./compiler-runtime-DeeZ7FnK.js";import{t as bt}from"./get-CyLJYAfP.js";import{r as wt}from"./useLifecycle-CmDXEyIC.js";import{t as vt}from"./debounce-BbFlGgjv.js";import{t as xt}from"./_baseSet-6FYvpjrm.js";import{d as E,p as y}from"./hotkeys-uKX61F1_.js";import{t as Et}from"./invariant-C6yE60hi.js";import{x as _t}from"./utils-CJJIceVn.js";import{M as Ct}from"./config-cCkBQ_ER.js";import{a as kt}from"./switch-1zrEJdOH.js";import{n as he}from"./globals-TVCm1yPw.js";import{t as ge}from"./ErrorBoundary-Drf1manw.js";import{t as Rt}from"./jsx-runtime-DN_bIXfG.js";import{t as Ft}from"./button-DuYGqRtX.js";import{t as Nt}from"./cn-C1rgT0yh.js";import{Z as St}from"./JsonOutput-CZTTeJuI.js";import{t as ye}from"./requests-C0HaHO6a.js";import{t as be}from"./createLucideIcon-CW2xpJ57.js";import{h as qt}from"./select-D0g5GnIs.js";import{c as Pt,i as Mt,l as jt,r as Tt,u as It}from"./markdown-renderer-D0AQKFve.js";import{t as At}from"./DeferredRequestRegistry-B3BENoUa.js";import{t as K}from"./Deferred-DzyBMRsy.js";import{t as Lt}from"./uuid-ClFZlR7U.js";import{t as Ut}from"./use-toast-Bzf3rpev.js";import{t as we}from"./tooltip-CvjcEpZC.js";import{t as ve}from"./mode-DwlGsYIa.js";import{n as zt,r as Ot,t as Wt}from"./share-CXQVxivL.js";import{r as Dt,t as Ht}from"./react-resizable-panels.browser.esm-BqxQegSf.js";import{t as xe}from"./toggle-G1t0cQyf.js";function Bt(t,e,n){return t==null?t:xt(t,e,n)}var H=Bt,Vt=be("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),Xt=be("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);function $t(t){return{all:t||(t=new Map),on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}var u=ce(lt(),1),Z=(0,u.createContext)(null),Yt=t=>{let{controller:e}=(0,u.useContext)(Z),n=u.useRef(Symbol("fill"));return(0,u.useEffect)(()=>(e.mount({name:t.name,ref:n.current,children:t.children}),()=>{e.unmount({name:t.name,ref:n.current})}),[]),(0,u.useEffect)(()=>{e.update({name:t.name,ref:n.current,children:t.children})}),null},Gt=Object.defineProperty,Qt=(t,e,n)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ee=(t,e,n)=>(Qt(t,typeof e=="symbol"?e:e+"",n),n),_e=console,Kt=class{constructor(t){Ee(this,"_bus"),Ee(this,"_db"),this._bus=t,this.handleFillMount=this.handleFillMount.bind(this),this.handleFillUpdated=this.handleFillUpdated.bind(this),this.handleFillUnmount=this.handleFillUnmount.bind(this),this._db={byName:new Map,byFill:new Map}}mount(){this._bus.on("fill-mount",this.handleFillMount),this._bus.on("fill-updated",this.handleFillUpdated),this._bus.on("fill-unmount",this.handleFillUnmount)}unmount(){this._bus.off("fill-mount",this.handleFillMount),this._bus.off("fill-updated",this.handleFillUpdated),this._bus.off("fill-unmount",this.handleFillUnmount)}handleFillMount({fill:t}){let e=u.Children.toArray(t.children),n=t.name,r={fill:t,children:e,name:n},s=this._db.byName.get(n);s?(s.components.push(r),s.listeners.forEach(i=>i([...s.components]))):this._db.byName.set(n,{listeners:[],components:[r]}),this._db.byFill.set(t.ref,r)}handleFillUpdated({fill:t}){let e=this._db.byFill.get(t.ref),n=u.Children.toArray(t.children);if(e){e.children=n;let r=this._db.byName.get(e.name);if(r)r.listeners.forEach(s=>s([...r.components]));else throw Error("registration was expected to be defined")}else{_e.error("[handleFillUpdated] component was expected to be defined");return}}handleFillUnmount({fill:t}){let e=this._db.byFill.get(t.ref);if(!e){_e.error("[handleFillUnmount] component was expected to be defined");return}let n=e.name,r=this._db.byName.get(n);if(!r)throw Error("registration was expected to be defined");r.components=r.components.filter(s=>s!==e),this._db.byFill.delete(t.ref),r.listeners.length===0&&r.components.length===0?this._db.byName.delete(n):r.listeners.forEach(s=>s([...r.components]))}onComponentsChange(t,e){let n=this._db.byName.get(t);n?(n.listeners.push(e),e(n.components)):(this._db.byName.set(t,{listeners:[e],components:[]}),e([]))}getFillsByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.fill):[]}getChildrenByName(t){let e=this._db.byName.get(t);return e?e.components.map(n=>n.children).reduce((n,r)=>n.concat(r),[]):[]}removeOnComponentsChange(t,e){let n=this._db.byName.get(t);if(!n)throw Error("expected registration to be defined");let r=n.listeners;r.splice(r.indexOf(e),1)}},Zt=Object.defineProperty,Jt=(t,e,n)=>e in t?Zt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,en=(t,e,n)=>(Jt(t,typeof e=="symbol"?e:e+"",n),n),Ce=class{constructor(){en(this,"bus",$t())}mount(t){this.bus.emit("fill-mount",{fill:t})}unmount(t){this.bus.emit("fill-unmount",{fill:t})}update(t){this.bus.emit("fill-updated",{fill:t})}};function tn(t){let e=t||new Ce;return{controller:e,manager:new Kt(e.bus)}}var nn=({controller:t,children:e})=>{let[n]=u.useState(()=>{let r=tn(t);return r.manager.mount(),r});return u.useEffect(()=>()=>{n.manager.unmount()},[]),u.createElement(Z.Provider,{value:n},e)};function J(t,e){let[n,r]=(0,u.useState)([]),{manager:s}=(0,u.useContext)(Z);return(0,u.useEffect)(()=>(s.onComponentsChange(t,r),()=>{s.removeOnComponentsChange(t,r)}),[t]),n.flatMap((i,d)=>{let{children:l}=i;return l.map((p,b)=>{if(typeof p=="number"||typeof p=="string")throw Error("Only element children will work here");return u.cloneElement(p,{key:d.toString()+b.toString(),...e})})})}var ke=t=>{let e=J(t.name,t.childProps);if(typeof t.children=="function"){let n=t.children(e);if(u.isValidElement(n)||n===null)return n;throw Error("Slot rendered with function must return a valid React Element.")}return e};const rn=new Ce,B={SIDEBAR:"sidebar",CONTEXT_AWARE_PANEL:"context-aware-panel"};var sn=class{constructor(){a(this,"subscriptions",new Map)}addSubscription(t,e){var n;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(n=this.subscriptions.get(t))==null||n.add(e)}removeSubscription(t,e){var n;(n=this.subscriptions.get(t))==null||n.delete(e)}notify(t,e){for(let n of this.subscriptions.get(t)??[])n(e)}},Re=class ue{constructor(e){a(this,"subscriptions",new sn);this.producer=e}static withProducerCallback(e){return new ue(e)}static empty(){return new ue}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,n){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,n){this.subscriptions.addSubscription(e,n),e==="open"&&n(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,n){this.subscriptions.removeSubscription(e,n)}},an=1e10,on=1e3;function V(t,e){let n=t.map(r=>`"${r}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${n}`)}function ln(t={}){let e={};function n(o){e=o}let r={};function s(o){var f;r.unregisterHandler&&r.unregisterHandler(),r=o,(f=r.registerHandler)==null||f.call(r,U)}let i;function d(o){if(typeof o=="function"){i=o;return}i=(f,g)=>{let c=o[f];if(c)return c(g);let h=o._;if(!h)throw Error(`The requested method has no handler: ${f}`);return h(f,g)}}let{maxRequestTime:l=on}=t;t.transport&&s(t.transport),t.requestHandler&&d(t.requestHandler),t._debugHooks&&n(t._debugHooks);let p=0;function b(){return p<=an?++p:p=0}let x=new Map,w=new Map;function _(o,...f){let g=f[0];return new Promise((c,h)=>{var I;if(!r.send)throw V(["send"],"make requests");let S=b(),M={type:"request",id:S,method:o,params:g};x.set(S,{resolve:c,reject:h}),l!==1/0&&w.set(S,setTimeout(()=>{w.delete(S),h(Error("RPC request timed out."))},l)),(I=e.onSend)==null||I.call(e,M),r.send(M)})}let F=new Proxy(_,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>_(f,c)}),C=F;function k(o,...f){var h;let g=f[0];if(!r.send)throw V(["send"],"send messages");let c={type:"message",id:o,payload:g};(h=e.onSend)==null||h.call(e,c),r.send(c)}let R=new Proxy(k,{get:(o,f,g)=>f in o?Reflect.get(o,f,g):c=>k(f,c)}),v=R,N=new Map,q=new Set;function T(o,f){var g;if(!r.registerHandler)throw V(["registerHandler"],"register message listeners");if(o==="*"){q.add(f);return}N.has(o)||N.set(o,new Set),(g=N.get(o))==null||g.add(f)}function L(o,f){var g,c;if(o==="*"){q.delete(f);return}(g=N.get(o))==null||g.delete(f),((c=N.get(o))==null?void 0:c.size)===0&&N.delete(o)}async function U(o){var f,g;if((f=e.onReceive)==null||f.call(e,o),!("type"in o))throw Error("Message does not contain a type.");if(o.type==="request"){if(!r.send||!i)throw V(["send","requestHandler"],"handle requests");let{id:c,method:h,params:S}=o,M;try{M={type:"response",id:c,success:!0,payload:await i(h,S)}}catch(I){if(!(I instanceof Error))throw I;M={type:"response",id:c,success:!1,error:I.message}}(g=e.onSend)==null||g.call(e,M),r.send(M);return}if(o.type==="response"){let c=w.get(o.id);c!=null&&clearTimeout(c);let{resolve:h,reject:S}=x.get(o.id)??{};o.success?h==null||h(o.payload):S==null||S(Error(o.error));return}if(o.type==="message"){for(let h of q)h(o.id,o.payload);let c=N.get(o.id);if(!c)return;for(let h of c)h(o.payload);return}throw Error(`Unexpected RPC message type: ${o.type}`)}return{setTransport:s,setRequestHandler:d,request:F,requestProxy:C,send:R,sendProxy:v,addMessageListener:T,removeMessageListener:L,proxy:{send:v,request:C},_setDebugHooks:n}}function un(t){return ln(t)}var Fe="[transport-id]";function cn(t,e){let{transportId:n}=e;return n==null?t:{[Fe]:n,data:t}}function dn(t,e){let{transportId:n,filter:r}=e,s=r==null?void 0:r();if(n!=null&&s!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(n){if(t[Fe]!==n)return[!0];i=t.data}return s===!1?[!0]:[!1,i]}function fn(t,e={}){let{transportId:n,filter:r,remotePort:s}=e,i=t,d=s??t,l;return{send(p){d.postMessage(cn(p,{transportId:n}))},registerHandler(p){l=b=>{let x=b.data,[w,_]=dn(x,{transportId:n,filter:()=>r==null?void 0:r(b)});w||p(_)},i.addEventListener("message",l)},unregisterHandler(){l&&i.removeEventListener("message",l)}}}function mn(t,e){return fn(t,e)}function Ne(t){return un({transport:mn(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{E.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{E.debug("[rpc] Worker -> Parent",e)}}})}const Se=P("Initializing..."),pn=P(t=>{let e=t(dt),n=Object.values(e.cellRuntime);return n.some(r=>!It(r.output))?!0:n.every(r=>r.status==="idle")});var qe=zt(),Pe="marimo:file",Me=new mt(null);const hn={saveFile(t){Me.set(Pe,t)},readFile(){return Me.get(Pe)}};var gn={saveFile(t){z.setCodeForHash((0,qe.compressToEncodedURIComponent)(t))},readFile(){let t=z.getCodeFromHash()||z.getCodeFromSearchParam();return t?(0,qe.decompressFromEncodedURIComponent)(t):null}};const yn={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var bn={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}},wn={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
2
2
  `)}},je=class{constructor(t){this.stores=t}insert(t,e){this.stores.splice(t,0,e)}saveFile(t){this.stores.forEach(e=>e.saveFile(t))}readFile(){for(let t of this.stores){let e=t.readFile();if(e)return e}return null}};const X=new je([yn,gn]),ee=new je([hn,bn,wn]);var Te=class rt{constructor(){a(this,"initialized",new K);a(this,"sendRename",async({filename:e})=>(e===null||(z.setFilename(e),await this.rpc.proxy.request.bridge({functionName:"rename_file",payload:e})),null));a(this,"sendSave",async e=>{if(!this.saveRpc)return E.warn("Save RPC not initialized"),null;await this.saveRpc.saveNotebook(e);let n=await this.readCode();return n.contents&&(X.saveFile(n.contents),ee.saveFile(n.contents)),this.rpc.proxy.request.saveNotebook(e).catch(r=>{E.error(r)}),null});a(this,"sendCopy",async()=>{y()});a(this,"sendStdin",async e=>(await this.rpc.proxy.request.bridge({functionName:"put_input",payload:e.text}),null));a(this,"sendPdb",async()=>{y()});a(this,"sendRun",async e=>(await this.rpc.proxy.request.loadPackages(e.codes.join(`
3
- `)),await this.putControlRequest({type:"execute-cells",...e}),null));a(this,"sendRunScratchpad",async e=>(await this.rpc.proxy.request.loadPackages(e.code),await this.putControlRequest({type:"execute-scratchpad",...e}),null));a(this,"sendInterrupt",async()=>(this.interruptBuffer!==void 0&&(this.interruptBuffer[0]=2),null));a(this,"sendShutdown",async()=>(window.close(),null));a(this,"sendFormat",async e=>await this.rpc.proxy.request.bridge({functionName:"format",payload:e}));a(this,"sendDeleteCell",async e=>(await this.putControlRequest({type:"delete-cell",...e}),null));a(this,"sendInstallMissingPackages",async e=>(this.putControlRequest({type:"install-packages",...e}),null));a(this,"sendCodeCompletionRequest",async e=>(Q.get(mt)||await this.rpc.proxy.request.bridge({functionName:"code_complete",payload:e}),null));a(this,"saveUserConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_user_config",payload:e}),kt.post("/kernel/save_user_config",e,{baseUrl:"/"}).catch(n=>(E.error(n),null))));a(this,"saveAppConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_app_config",payload:e}),null));a(this,"saveCellConfig",async e=>(await this.putControlRequest({type:"update-cell-config",...e}),null));a(this,"sendRestart",async()=>{let e=await this.readCode();return e.contents&&(X.saveFile(e.contents),ee.saveFile(e.contents)),Ot(),null});a(this,"readCode",async()=>this.saveRpc?{contents:await this.saveRpc.readNotebook()}:(E.warn("Save RPC not initialized"),{contents:""}));a(this,"readSnippets",async()=>await this.rpc.proxy.request.bridge({functionName:"read_snippets",payload:void 0}));a(this,"openFile",async({path:e})=>{let n=Wt({code:null,baseUrl:window.location.origin});return window.open(n,"_blank"),null});a(this,"sendListFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"list_files",payload:e}));a(this,"sendSearchFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"search_files",payload:e}));a(this,"sendComponentValues",async e=>(await this.putControlRequest({type:"update-ui-element",...e,token:Lt()}),null));a(this,"sendInstantiate",async e=>null);a(this,"sendFunctionRequest",async e=>(await this.putControlRequest({type:"invoke-function",...e}),null));a(this,"sendCreateFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"create_file_or_directory",payload:e}));a(this,"sendDeleteFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"delete_file_or_directory",payload:e}));a(this,"sendRenameFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"move_file_or_directory",payload:e}));a(this,"sendUpdateFile",async e=>await this.rpc.proxy.request.bridge({functionName:"update_file",payload:e}));a(this,"sendFileDetails",async e=>await this.rpc.proxy.request.bridge({functionName:"file_details",payload:e}));a(this,"exportAsHTML",async e=>await this.rpc.proxy.request.bridge({functionName:"export_html",payload:e}));a(this,"exportAsMarkdown",async e=>await this.rpc.proxy.request.bridge({functionName:"export_markdown",payload:e}));a(this,"previewDatasetColumn",async e=>(await this.putControlRequest({type:"preview-dataset-column",...e}),null));a(this,"previewSQLTable",async e=>(await this.putControlRequest({type:"preview-sql-table",...e}),null));a(this,"previewSQLTableList",async e=>(await this.putControlRequest({type:"list-sql-tables",...e}),null));a(this,"previewDataSourceConnection",async e=>(await this.putControlRequest({type:"list-data-source-connection",...e}),null));a(this,"validateSQL",async e=>(await this.putControlRequest({type:"validate-sql",...e}),null));a(this,"sendModelValue",async e=>(await this.putControlRequest({type:"update-widget-model",...e}),null));a(this,"syncCellIds",()=>Promise.resolve(null));a(this,"addPackage",async e=>this.rpc.proxy.request.addPackage(e));a(this,"removePackage",async e=>this.rpc.proxy.request.removePackage(e));a(this,"getPackageList",async()=>await this.rpc.proxy.request.listPackages());a(this,"getDependencyTree",async()=>({tree:{dependencies:[],name:"",tags:[],version:null}}));a(this,"listSecretKeys",async e=>(await this.putControlRequest({type:"list-secret-keys",...e}),null));a(this,"getUsageStats",y);a(this,"openTutorial",y);a(this,"getRecentFiles",y);a(this,"getWorkspaceFiles",y);a(this,"getRunningNotebooks",y);a(this,"shutdownSession",y);a(this,"autoExportAsHTML",y);a(this,"autoExportAsMarkdown",y);a(this,"autoExportAsIPYNB",y);a(this,"writeSecret",y);a(this,"invokeAiTool",y);a(this,"clearCache",y);a(this,"getCacheInfo",y);Ct()&&(this.rpc=Ne(new Worker(new URL(""+new URL("worker-CUL1lW-N.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})),this.rpc.addMessageListener("ready",()=>{this.startSession()}),this.rpc.addMessageListener("initialized",()=>{this.saveRpc=this.getSaveWorker(),this.setInterruptBuffer(),this.initialized.resolve()}),this.rpc.addMessageListener("initializingMessage",({message:e})=>{Q.set(Se,e)}),this.rpc.addMessageListener("initializedError",({error:e})=>{this.initialized.status==="resolved"&&(E.error(e),Ut({title:"Error initializing",description:e,variant:"danger"})),this.initialized.reject(Error(e))}),this.rpc.addMessageListener("kernelMessage",({message:e})=>{var n;(n=this.messageConsumer)==null||n.call(this,new MessageEvent("message",{data:e}))}))}static get INSTANCE(){let e="_marimo_private_PyodideBridge";return window[e]||(window[e]=new rt),window[e]}getSaveWorker(){return ve()==="read"?(E.debug("Skipping SaveWorker in read-mode"),{readFile:y,readNotebook:y,saveNotebook:y}):Ne(new Worker(new URL(""+new URL("save-worker-DtF6B3PS.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})).proxy.request}async startSession(){let e=await X.readFile(),n=await ee.readFile(),r=z.getFilename(),s=Q.get(_t),i={},d=new URLSearchParams(window.location.search);for(let l of d.keys()){let p=d.getAll(l);i[l]=p.length===1?p[0]:p}await this.rpc.proxy.request.startSession({queryParameters:i,code:e||n||"",filename:r,userConfig:{...s,runtime:{...s.runtime,auto_instantiate:ve()==="read"?!0:s.runtime.auto_instantiate}}})}setInterruptBuffer(){crossOriginIsolated?(this.interruptBuffer=new Uint8Array(new SharedArrayBuffer(1)),this.rpc.proxy.request.setInterruptBuffer(this.interruptBuffer)):E.warn("Not running in a secure context; interrupts are not available.")}attachMessageConsumer(e){this.messageConsumer=e,this.rpc.proxy.send.consumerReady({})}async putControlRequest(e){await this.rpc.proxy.request.bridge({functionName:"put_control_request",payload:e})}};function vn(){return Re.withProducerCallback(t=>{Te.INSTANCE.attachMessageConsumer(t)})}const Ie=P({isInstantiated:!1,error:null});function xn(){return ot(Ie,t=>t.isInstantiated)}function $(t){return()=>({TYPE:t,is(e){return e.type===t},create(e){return new CustomEvent(t,e)}})}const Ae=$("marimo-value-input")(),Le=$("marimo-value-update")(),Ue=$("marimo-value-ready")(),ze=$("marimo-incoming-message")();function En(t,e){return Ae.create({bubbles:!0,composed:!0,detail:{value:t,element:e}})}var Oe=class st{static get INSTANCE(){let e="_marimo_private_UIElementRegistry";return window[e]||(window[e]=new st),window[e]}constructor(){this.entries=new Map}has(e){return this.entries.has(e)}set(e,n){if(this.entries.has(e))throw Error(`UIElement ${e} already registered`);this.entries.set(e,{objectId:e,value:n,elements:new Set})}registerInstance(e,n){let r=this.entries.get(e);r===void 0?this.entries.set(e,{objectId:e,value:dt(n,this),elements:new Set([n])}):r.elements.add(n)}removeInstance(e,n){let r=this.entries.get(e);r!=null&&r.elements.has(n)&&r.elements.delete(n)}removeElementsByCell(e){[...this.entries.keys()].filter(n=>n.startsWith(`${e}-`)).forEach(n=>{this.entries.delete(n)})}lookupValue(e){let n=this.entries.get(e);return n===void 0?void 0:n.value}broadcastMessage(e,n,r){let s=this.entries.get(e);s===void 0?E.warn("UIElementRegistry missing entry",e):s.elements.forEach(i=>{i.dispatchEvent(ze.create({bubbles:!1,composed:!0,detail:{objectId:e,message:n,buffers:r}}))})}broadcastValueUpdate(e,n,r){let s=this.entries.get(n);s===void 0?E.warn("UIElementRegistry missing entry",n):(s.value=r,s.elements.forEach(i=>{i!==e&&i.dispatchEvent(Le.create({bubbles:!1,composed:!0,detail:{value:r,element:i}}))}),document.dispatchEvent(Ue.create({bubbles:!0,composed:!0,detail:{objectId:n}})))}};const _n=Oe.INSTANCE,Cn=new At("function-call-result",async(t,e)=>{await ye().sendFunctionRequest({functionCallId:t,...e})}),kn="68px";var Rn="288px";const Fn=t=>t?/^\d+$/.test(t)?`${t}px`:t:Rn,Nn=ct({isOpen:!0},(t,e)=>{if(!e)return t;switch(e.type){case"toggle":return{...t,isOpen:e.isOpen??t.isOpen};case"setWidth":return{...t,width:e.width};default:return t}});function Sn(t){return jt(Tt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)))}function te(t,e=[]){let n=[];if(t instanceof DataView)n.push(e);else if(Array.isArray(t))for(let[r,s]of t.entries())n.push(...te(s,[...e,r]));else if(typeof t=="object"&&t)for(let[r,s]of Object.entries(t))n.push(...te(s,[...e,r]));return n}function ne(t){let e=te(t);if(e.length===0)return{state:t,buffers:[],bufferPaths:[]};let n=structuredClone(t),r=[],s=[];for(let i of e){let d=bt(t,i);if(d instanceof DataView){let l=Sn(d);r.push(l),s.push(i),H(n,i,l)}}return{state:n,buffers:r,bufferPaths:s}}function qn(t){return typeof t=="object"&&!!t&&"state"in t&&"bufferPaths"in t&&"buffers"in t}function Y(t){let{state:e,bufferPaths:n,buffers:r}=t;if(!n||n.length===0)return e;r&&Et(r.length===n.length,"Buffers and buffer paths not the same length");let s=structuredClone(e);for(let[i,d]of n.entries()){let l=r==null?void 0:r[i];if(l==null){E.warn("[anywidget] Could not find buffer at path",d);continue}if(typeof l=="string"){let p=Mt(Pt(l));H(s,d,new DataView(p.buffer))}else H(s,d,l)}return s}const We=new class{constructor(t=1e4){a(this,"models",new Map);this.timeout=t}get(t){let e=this.models.get(t);return e||(e=new K,this.models.set(t,e),setTimeout(()=>{e.status==="pending"&&(e.reject(Error(`Model not found for key: ${t}`)),this.models.delete(t))},this.timeout)),e.promise}set(t,e){let n=this.models.get(t);n||(n=new K,this.models.set(t,n)),n.resolve(e)}delete(t){this.models.delete(t)}};var De=(j=class{constructor(e,n,r,s){a(this,"ANY_CHANGE_EVENT","change");a(this,"listeners",{});a(this,"widget_manager",{async get_model(e){let n=await j._modelManager.get(e);if(!n)throw Error(`Model not found with id: ${e}. This is likely because the model was not registered.`);return n}});a(this,"emitAnyChange",vt(()=>{var e;(e=this.listeners[this.ANY_CHANGE_EVENT])==null||e.forEach(n=>n())},0));this.data=e,this.onChange=n,this.sendToWidget=r,this.dirtyFields=new Map([...s].map(i=>[i,this.data[i]]))}off(e,n){var r;if(!e){this.listeners={};return}if(!n){this.listeners[e]=new Set;return}(r=this.listeners[e])==null||r.delete(n)}send(e,n,r){let{state:s,bufferPaths:i,buffers:d}=ne(e);this.sendToWidget({content:{state:s,bufferPaths:i},buffers:d}).then(n)}get(e){return this.data[e]}set(e,n){this.data={...this.data,[e]:n},this.dirtyFields.set(e,n),this.emit(`change:${e}`,n),this.emitAnyChange()}save_changes(){if(this.dirtyFields.size===0)return;let e=Object.fromEntries(this.dirtyFields.entries());this.dirtyFields.clear(),this.onChange(e)}updateAndEmitDiffs(e){e!=null&&Object.keys(e).forEach(n=>{let r=n;this.data[r]!==e[r]&&this.set(r,e[r])})}receiveCustomMessage(e,n=[]){var s;let r=He.safeParse(e);if(r.success){let i=r.data;switch(i.method){case"update":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"custom":(s=this.listeners["msg:custom"])==null||s.forEach(d=>d(i.content,n));break;case"open":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"echo_update":break;default:E.error("[anywidget] Unknown message method",i.method);break}}else E.error("Failed to parse message",r.error),E.error("Message",e)}on(e,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n)}emit(e,n){this.listeners[e]&&this.listeners[e].forEach(r=>r(n))}},a(j,"_modelManager",We),j),re=me(me(pt([fe(),yt()]))),se=gt(fe(),de()),He=ht("method",[O({method:W("open"),state:se,buffer_paths:re.optional()}),O({method:W("update"),state:se,buffer_paths:re.optional()}),O({method:W("custom"),content:de()}),O({method:W("echo_update"),buffer_paths:re,state:se}),O({method:W("close")})]);function Pn(t){return t==null?!1:He.safeParse(t).success}async function Mn({modelId:t,msg:e,buffers:n,modelManager:r}){if(e.method==="echo_update")return;if(e.method==="custom"){(await r.get(t)).receiveCustomMessage(e,n);return}if(e.method==="close"){r.delete(t);return}let{method:s,state:i,buffer_paths:d=[]}=e,l=Y({state:i,bufferPaths:d,buffers:n});if(s==="open"){let p=new De(l,b=>{let{state:x,buffers:w,bufferPaths:_}=ne(b);ye().sendModelValue({modelId:t,message:{state:x,bufferPaths:_},buffers:w})},y,new Set);r.set(t,p);return}if(s==="update"){(await r.get(t)).updateAndEmitDiffs(l);return}wt(s)}const Be=P(null),jn=P(null),Ve=P(!1),Tn=P(!1),Xe=P(!1);var In=pe();const $e=t=>{let e=(0,In.c)(8),{onResize:n,startingWidth:r,minWidth:s,maxWidth:i}=t,d=(0,u.useRef)(null),l=(0,u.useRef)(null),p=(0,u.useRef)(null),b,x;e[0]!==i||e[1]!==s||e[2]!==n?(b=()=>{let C=d.current,k=l.current,R=p.current;if(!C||!k&&!R)return;let v=Number.parseInt(window.getComputedStyle(C).width,10),N=0,q=!1,T=null,L=c=>{if(!C||!q||!T)return;let h=c.clientX-N;N=c.clientX,v=T==="left"?v-h:v+h,s&&(v=Math.max(s,v)),i&&(v=Math.min(i,v)),C.style.width=`${v}px`},U=()=>{q&&(n==null||n(v),q=!1,T=null),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)},o=(c,h)=>{c.preventDefault(),q=!0,T=h,N=c.clientX,document.addEventListener("mousemove",L),document.addEventListener("mouseup",U)},f=c=>o(c,"left"),g=c=>o(c,"right");return k&&k.addEventListener("mousedown",f),R&&R.addEventListener("mousedown",g),()=>{k&&k.removeEventListener("mousedown",f),R&&R.removeEventListener("mousedown",g),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)}},x=[s,i,n],e[0]=i,e[1]=s,e[2]=n,e[3]=b,e[4]=x):(b=e[3],x=e[4]),(0,u.useEffect)(b,x);let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w={left:l,right:p},e[5]=w):w=e[5];let _=r==="contentWidth"?"var(--content-width-medium)":`${r}px`,F;return e[6]===_?F=e[7]:(F={resizableDivRef:d,handleRefs:w,style:{width:_}},e[6]=_,e[7]=F),F};function Ye(t){t||window.dispatchEvent(new Event("resize"))}var Ge=pe(),m=ce(Rt(),1);const An=()=>{let t=(0,Ge.c)(16),[e,n]=D(Be),[r,s]=D(Ve),[i,d]=D(Tn),[l,p]=D(Xe),b;t[0]!==s||t[1]!==n?(b=()=>{n(null),s(!1)},t[0]=s,t[1]=n,t[2]=b):b=t[2];let x=b;if(J(B.CONTEXT_AWARE_PANEL).length===0||!e||!r)return null;let w;t[3]!==l||t[4]!==i||t[5]!==p||t[6]!==d?(w=()=>(0,m.jsxs)("div",{className:"flex flex-row items-center gap-3",children:[(0,m.jsx)(we,{content:i?"Unpin panel":"Pin panel",children:(0,m.jsx)(xe,{size:"xs",onPressedChange:()=>d(!i),pressed:i,"aria-label":i?"Unpin panel":"Pin panel",children:i?(0,m.jsx)(Xt,{className:"w-4 h-4"}):(0,m.jsx)(St,{className:"w-4 h-4"})})}),(0,m.jsx)(we,{content:l?(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Follow focused table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel updates as cells that output tables are focused. Click to fix to the current cell."})]}):(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Focus on current table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel is focused on the current table. Click to update based on which cell is focused."})]}),children:(0,m.jsx)(xe,{size:"xs",onPressedChange:()=>p(!l),pressed:l,"aria-label":l?"Follow focused cell":"Fixed",children:(0,m.jsx)(Vt,{className:Nt("w-4 h-4",l&&"text-primary")})})})]}),t[3]=l,t[4]=i,t[5]=p,t[6]=d,t[7]=w):w=t[7];let _=w,F;t[8]!==x||t[9]!==_?(F=()=>(0,m.jsxs)("div",{className:"mt-2 pb-7 mb-4 h-full overflow-auto",children:[(0,m.jsxs)("div",{className:"flex flex-row justify-between items-center mx-2",children:[_(),(0,m.jsx)(Ft,{variant:"linkDestructive",size:"icon",onClick:x,"aria-label":"Close selection panel",children:(0,m.jsx)(qt,{className:"w-4 h-4"})})]}),(0,m.jsx)(ge,{children:(0,m.jsx)(ke,{name:B.CONTEXT_AWARE_PANEL})})]}),t[8]=x,t[9]=_,t[10]=F):F=t[10];let C=F;if(!i){let v;return t[11]===C?v=t[12]:(v=(0,m.jsx)(Un,{children:C()}),t[11]=C,t[12]=v),v}let k;t[13]===Symbol.for("react.memo_cache_sentinel")?(k=(0,m.jsx)(Dt,{onDragging:Ye,className:"resize-handle border-border z-20 no-print border-l"}),t[13]=k):k=t[13];let R;return t[14]===C?R=t[15]:(R=(0,m.jsxs)(m.Fragment,{children:[k,(0,m.jsx)(Ht,{defaultSize:20,minSize:15,maxSize:80,children:C()})]}),t[14]=C,t[15]=R),R},Ln=t=>{let e=(0,Ge.c)(2),{children:n}=t,r;return e[0]===n?r=e[1]:(r=(0,m.jsx)(ge,{children:(0,m.jsx)(Yt,{name:B.CONTEXT_AWARE_PANEL,children:n})}),e[0]=n,e[1]=r),r};var Un=({children:t})=>{let{resizableDivRef:e,handleRefs:n,style:r}=$e({startingWidth:400,minWidth:300,maxWidth:1500});return(0,m.jsxs)("div",{className:"absolute z-40 right-0 h-full bg-background flex flex-row",children:[(0,m.jsx)("div",{ref:n.left,className:"w-1 h-full cursor-col-resize border-l"}),(0,m.jsx)("div",{ref:e,style:r,children:t})]})};function zn(){var t=[...arguments];return(0,u.useMemo)(()=>e=>{t.forEach(n=>n(e))},t)}var Qe=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0;function G(t){let e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function ae(t){return"nodeType"in t}function A(t){var e;return t?G(t)?t:ae(t)?((e=t.ownerDocument)==null?void 0:e.defaultView)??window:window:window}function Ke(t){let{Document:e}=A(t);return t instanceof e}function Ze(t){return G(t)?!1:t instanceof A(t).HTMLElement}function Je(t){return t instanceof A(t).SVGElement}function On(t){return t?G(t)?t.document:ae(t)?Ke(t)?t:Ze(t)||Je(t)?t.ownerDocument:document:document:document}var ie=Qe?u.useLayoutEffect:u.useEffect;function et(t){let e=(0,u.useRef)(t);return ie(()=>{e.current=t}),(0,u.useCallback)(function(){var n=[...arguments];return e.current==null?void 0:e.current(...n)},[])}function Wn(){let t=(0,u.useRef)(null);return[(0,u.useCallback)((e,n)=>{t.current=setInterval(e,n)},[]),(0,u.useCallback)(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[])]}function Dn(t,e){e===void 0&&(e=[t]);let n=(0,u.useRef)(t);return ie(()=>{n.current!==t&&(n.current=t)},e),n}function Hn(t,e){let n=(0,u.useRef)();return(0,u.useMemo)(()=>{let r=t(n.current);return n.current=r,r},[...e])}function Bn(t){let e=et(t),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(r=>{r!==n.current&&(e==null||e(r,n.current)),n.current=r},[])]}function Vn(t){let e=(0,u.useRef)();return(0,u.useEffect)(()=>{e.current=t},[t]),e.current}var oe={};function Xn(t,e){return(0,u.useMemo)(()=>{if(e)return e;let n=oe[t]==null?0:oe[t]+1;return oe[t]=n,t+"-"+n},[t,e])}function tt(t){return function(e){return[...arguments].slice(1).reduce((n,r)=>{let s=Object.entries(r);for(let[i,d]of s){let l=n[i];l!=null&&(n[i]=l+t*d)}return n},{...e})}}var $n=tt(1),Yn=tt(-1);function Gn(t){return"clientX"in t&&"clientY"in t}function Qn(t){if(!t)return!1;let{KeyboardEvent:e}=A(t.target);return e&&t instanceof e}function Kn(t){if(!t)return!1;let{TouchEvent:e}=A(t.target);return e&&t instanceof e}function Zn(t){if(Kn(t)){if(t.touches&&t.touches.length){let{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){let{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return Gn(t)?{x:t.clientX,y:t.clientY}:null}var le=Object.freeze({Translate:{toString(t){if(!t)return;let{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;let{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[le.Translate.toString(t),le.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),nt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Jn(t){return t.matches(nt)?t:t.querySelector(nt)}export{vn as $,jn as A,Fn as B,Xn as C,$e as D,Ye as E,Pn as F,ze as G,Cn as H,Y as I,Le as J,Ae as K,qn as L,We as M,De as N,Ve as O,Mn as P,Te as Q,ne as R,Vn as S,Ln as T,Oe as U,Nn as V,_n as W,Ie as X,En as Y,xn as Z,Wn as _,Zn as a,rn as at,Hn as b,Ke as c,J as ct,ae as d,X as et,Je as f,et as g,zn as h,Jn as i,B as it,Xe as j,Be as k,Ze as l,H as lt,Yn as m,$n as n,Se as nt,On as o,nn as ot,G as p,Ue as q,Qe as r,Re as rt,A as s,ke as st,le as t,pn as tt,Qn as u,ie as v,An as w,Bn as x,Dn as y,kn as z};
3
+ `)),await this.putControlRequest({type:"execute-cells",...e}),null));a(this,"sendRunScratchpad",async e=>(await this.rpc.proxy.request.loadPackages(e.code),await this.putControlRequest({type:"execute-scratchpad",...e}),null));a(this,"sendInterrupt",async()=>(this.interruptBuffer!==void 0&&(this.interruptBuffer[0]=2),null));a(this,"sendShutdown",async()=>(window.close(),null));a(this,"sendFormat",async e=>await this.rpc.proxy.request.bridge({functionName:"format",payload:e}));a(this,"sendDeleteCell",async e=>(await this.putControlRequest({type:"delete-cell",...e}),null));a(this,"sendInstallMissingPackages",async e=>(this.putControlRequest({type:"install-packages",...e}),null));a(this,"sendCodeCompletionRequest",async e=>(Q.get(ft)||await this.rpc.proxy.request.bridge({functionName:"code_complete",payload:e}),null));a(this,"saveUserConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_user_config",payload:e}),kt.post("/kernel/save_user_config",e,{baseUrl:"/"}).catch(n=>(E.error(n),null))));a(this,"saveAppConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_app_config",payload:e}),null));a(this,"saveCellConfig",async e=>(await this.putControlRequest({type:"update-cell-config",...e}),null));a(this,"sendRestart",async()=>{let e=await this.readCode();return e.contents&&(X.saveFile(e.contents),ee.saveFile(e.contents)),Ot(),null});a(this,"readCode",async()=>this.saveRpc?{contents:await this.saveRpc.readNotebook()}:(E.warn("Save RPC not initialized"),{contents:""}));a(this,"readSnippets",async()=>await this.rpc.proxy.request.bridge({functionName:"read_snippets",payload:void 0}));a(this,"openFile",async({path:e})=>{let n=Wt({code:null,baseUrl:window.location.origin});return window.open(n,"_blank"),null});a(this,"sendListFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"list_files",payload:e}));a(this,"sendSearchFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"search_files",payload:e}));a(this,"sendComponentValues",async e=>(await this.putControlRequest({type:"update-ui-element",...e,token:Lt()}),null));a(this,"sendInstantiate",async e=>null);a(this,"sendFunctionRequest",async e=>(await this.putControlRequest({type:"invoke-function",...e}),null));a(this,"sendCreateFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"create_file_or_directory",payload:e}));a(this,"sendDeleteFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"delete_file_or_directory",payload:e}));a(this,"sendRenameFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"move_file_or_directory",payload:e}));a(this,"sendUpdateFile",async e=>await this.rpc.proxy.request.bridge({functionName:"update_file",payload:e}));a(this,"sendFileDetails",async e=>await this.rpc.proxy.request.bridge({functionName:"file_details",payload:e}));a(this,"exportAsHTML",async e=>await this.rpc.proxy.request.bridge({functionName:"export_html",payload:e}));a(this,"exportAsMarkdown",async e=>await this.rpc.proxy.request.bridge({functionName:"export_markdown",payload:e}));a(this,"previewDatasetColumn",async e=>(await this.putControlRequest({type:"preview-dataset-column",...e}),null));a(this,"previewSQLTable",async e=>(await this.putControlRequest({type:"preview-sql-table",...e}),null));a(this,"previewSQLTableList",async e=>(await this.putControlRequest({type:"list-sql-tables",...e}),null));a(this,"previewDataSourceConnection",async e=>(await this.putControlRequest({type:"list-data-source-connection",...e}),null));a(this,"validateSQL",async e=>(await this.putControlRequest({type:"validate-sql",...e}),null));a(this,"sendModelValue",async e=>(await this.putControlRequest({type:"update-widget-model",...e}),null));a(this,"syncCellIds",()=>Promise.resolve(null));a(this,"addPackage",async e=>this.rpc.proxy.request.addPackage(e));a(this,"removePackage",async e=>this.rpc.proxy.request.removePackage(e));a(this,"getPackageList",async()=>await this.rpc.proxy.request.listPackages());a(this,"getDependencyTree",async()=>({tree:{dependencies:[],name:"",tags:[],version:null}}));a(this,"listSecretKeys",async e=>(await this.putControlRequest({type:"list-secret-keys",...e}),null));a(this,"getUsageStats",y);a(this,"openTutorial",y);a(this,"getRecentFiles",y);a(this,"getWorkspaceFiles",y);a(this,"getRunningNotebooks",y);a(this,"shutdownSession",y);a(this,"autoExportAsHTML",y);a(this,"autoExportAsMarkdown",y);a(this,"autoExportAsIPYNB",y);a(this,"writeSecret",y);a(this,"invokeAiTool",y);a(this,"clearCache",y);a(this,"getCacheInfo",y);Ct()&&(this.rpc=Ne(new Worker(new URL(""+new URL("worker-CUL1lW-N.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})),this.rpc.addMessageListener("ready",()=>{this.startSession()}),this.rpc.addMessageListener("initialized",()=>{this.saveRpc=this.getSaveWorker(),this.setInterruptBuffer(),this.initialized.resolve()}),this.rpc.addMessageListener("initializingMessage",({message:e})=>{Q.set(Se,e)}),this.rpc.addMessageListener("initializedError",({error:e})=>{this.initialized.status==="resolved"&&(E.error(e),Ut({title:"Error initializing",description:e,variant:"danger"})),this.initialized.reject(Error(e))}),this.rpc.addMessageListener("kernelMessage",({message:e})=>{var n;(n=this.messageConsumer)==null||n.call(this,new MessageEvent("message",{data:e}))}))}static get INSTANCE(){let e="_marimo_private_PyodideBridge";return window[e]||(window[e]=new rt),window[e]}getSaveWorker(){return ve()==="read"?(E.debug("Skipping SaveWorker in read-mode"),{readFile:y,readNotebook:y,saveNotebook:y}):Ne(new Worker(new URL(""+new URL("save-worker-DtF6B3PS.js",import.meta.url).href,""+import.meta.url),{type:"module",name:he()})).proxy.request}async startSession(){let e=await X.readFile(),n=await ee.readFile(),r=z.getFilename(),s=Q.get(_t),i={},d=new URLSearchParams(window.location.search);for(let l of d.keys()){let p=d.getAll(l);i[l]=p.length===1?p[0]:p}await this.rpc.proxy.request.startSession({queryParameters:i,code:e||n||"",filename:r,userConfig:{...s,runtime:{...s.runtime,auto_instantiate:ve()==="read"?!0:s.runtime.auto_instantiate}}})}setInterruptBuffer(){crossOriginIsolated?(this.interruptBuffer=new Uint8Array(new SharedArrayBuffer(1)),this.rpc.proxy.request.setInterruptBuffer(this.interruptBuffer)):E.warn("Not running in a secure context; interrupts are not available.")}attachMessageConsumer(e){this.messageConsumer=e,this.rpc.proxy.send.consumerReady({})}async putControlRequest(e){await this.rpc.proxy.request.bridge({functionName:"put_control_request",payload:e})}};function vn(){return Re.withProducerCallback(t=>{Te.INSTANCE.attachMessageConsumer(t)})}const Ie=P({isInstantiated:!1,error:null});function xn(){return ot(Ie,t=>t.isInstantiated)}function $(t){return()=>({TYPE:t,is(e){return e.type===t},create(e){return new CustomEvent(t,e)}})}const Ae=$("marimo-value-input")(),Le=$("marimo-value-update")(),Ue=$("marimo-value-ready")(),ze=$("marimo-incoming-message")();function En(t,e){return Ae.create({bubbles:!0,composed:!0,detail:{value:t,element:e}})}var Oe=class st{static get INSTANCE(){let e="_marimo_private_UIElementRegistry";return window[e]||(window[e]=new st),window[e]}constructor(){this.entries=new Map}has(e){return this.entries.has(e)}set(e,n){if(this.entries.has(e))throw Error(`UIElement ${e} already registered`);this.entries.set(e,{objectId:e,value:n,elements:new Set})}registerInstance(e,n){let r=this.entries.get(e);r===void 0?this.entries.set(e,{objectId:e,value:ct(n,this),elements:new Set([n])}):r.elements.add(n)}removeInstance(e,n){let r=this.entries.get(e);r!=null&&r.elements.has(n)&&r.elements.delete(n)}removeElementsByCell(e){[...this.entries.keys()].filter(n=>n.startsWith(`${e}-`)).forEach(n=>{this.entries.delete(n)})}lookupValue(e){let n=this.entries.get(e);return n===void 0?void 0:n.value}broadcastMessage(e,n,r){let s=this.entries.get(e);s===void 0?E.warn("UIElementRegistry missing entry",e):s.elements.forEach(i=>{i.dispatchEvent(ze.create({bubbles:!1,composed:!0,detail:{objectId:e,message:n,buffers:r}}))})}broadcastValueUpdate(e,n,r){let s=this.entries.get(n);s===void 0?E.warn("UIElementRegistry missing entry",n):(s.value=r,s.elements.forEach(i=>{i!==e&&i.dispatchEvent(Le.create({bubbles:!1,composed:!0,detail:{value:r,element:i}}))}),document.dispatchEvent(Ue.create({bubbles:!0,composed:!0,detail:{objectId:n}})))}};const _n=Oe.INSTANCE,Cn=new At("function-call-result",async(t,e)=>{await ye().sendFunctionRequest({functionCallId:t,...e})}),kn="68px";var Rn="288px";const Fn=t=>t?/^\d+$/.test(t)?`${t}px`:t:Rn,Nn=ut({isOpen:!0},(t,e)=>{if(!e)return t;switch(e.type){case"toggle":return{...t,isOpen:e.isOpen??t.isOpen};case"setWidth":return{...t,width:e.width};default:return t}});function Sn(t){return jt(Tt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)))}function te(t,e=[]){let n=[];if(t instanceof DataView)n.push(e);else if(Array.isArray(t))for(let[r,s]of t.entries())n.push(...te(s,[...e,r]));else if(typeof t=="object"&&t)for(let[r,s]of Object.entries(t))n.push(...te(s,[...e,r]));return n}function ne(t){let e=te(t);if(e.length===0)return{state:t,buffers:[],bufferPaths:[]};let n=structuredClone(t),r=[],s=[];for(let i of e){let d=bt(t,i);if(d instanceof DataView){let l=Sn(d);r.push(l),s.push(i),H(n,i,l)}}return{state:n,buffers:r,bufferPaths:s}}function qn(t){return typeof t=="object"&&!!t&&"state"in t&&"bufferPaths"in t&&"buffers"in t}function Y(t){let{state:e,bufferPaths:n,buffers:r}=t;if(!n||n.length===0)return e;r&&Et(r.length===n.length,"Buffers and buffer paths not the same length");let s=structuredClone(e);for(let[i,d]of n.entries()){let l=r==null?void 0:r[i];if(l==null){E.warn("[anywidget] Could not find buffer at path",d);continue}if(typeof l=="string"){let p=Mt(Pt(l));H(s,d,new DataView(p.buffer))}else H(s,d,l)}return s}const We=new class{constructor(t=1e4){a(this,"models",new Map);this.timeout=t}get(t){let e=this.models.get(t);return e||(e=new K,this.models.set(t,e),setTimeout(()=>{e.status==="pending"&&(e.reject(Error(`Model not found for key: ${t}`)),this.models.delete(t))},this.timeout)),e.promise}set(t,e){let n=this.models.get(t);n||(n=new K,this.models.set(t,n)),n.resolve(e)}delete(t){this.models.delete(t)}};var De=(j=class{constructor(e,n,r,s){a(this,"ANY_CHANGE_EVENT","change");a(this,"listeners",{});a(this,"widget_manager",{async get_model(e){let n=await j._modelManager.get(e);if(!n)throw Error(`Model not found with id: ${e}. This is likely because the model was not registered.`);return n}});a(this,"emitAnyChange",vt(()=>{var e;(e=this.listeners[this.ANY_CHANGE_EVENT])==null||e.forEach(n=>n())},0));this.data=e,this.onChange=n,this.sendToWidget=r,this.dirtyFields=new Map([...s].map(i=>[i,this.data[i]]))}off(e,n){var r;if(!e){this.listeners={};return}if(!n){this.listeners[e]=new Set;return}(r=this.listeners[e])==null||r.delete(n)}send(e,n,r){let{state:s,bufferPaths:i,buffers:d}=ne(e);this.sendToWidget({content:{state:s,bufferPaths:i},buffers:d}).then(n)}get(e){return this.data[e]}set(e,n){this.data={...this.data,[e]:n},this.dirtyFields.set(e,n),this.emit(`change:${e}`,n),this.emitAnyChange()}save_changes(){if(this.dirtyFields.size===0)return;let e=Object.fromEntries(this.dirtyFields.entries());this.dirtyFields.clear(),this.onChange(e)}updateAndEmitDiffs(e){e!=null&&Object.keys(e).forEach(n=>{let r=n;this.data[r]!==e[r]&&this.set(r,e[r])})}receiveCustomMessage(e,n=[]){var s;let r=He.safeParse(e);if(r.success){let i=r.data;switch(i.method){case"update":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"custom":(s=this.listeners["msg:custom"])==null||s.forEach(d=>d(i.content,n));break;case"open":this.updateAndEmitDiffs(Y({state:i.state,bufferPaths:i.buffer_paths??[],buffers:n}));break;case"echo_update":break;default:E.error("[anywidget] Unknown message method",i.method);break}}else E.error("Failed to parse message",r.error),E.error("Message",e)}on(e,n){this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n)}emit(e,n){this.listeners[e]&&this.listeners[e].forEach(r=>r(n))}},a(j,"_modelManager",We),j),re=me(me(pt([fe(),yt()]))),se=gt(fe(),de()),He=ht("method",[O({method:W("open"),state:se,buffer_paths:re.optional()}),O({method:W("update"),state:se,buffer_paths:re.optional()}),O({method:W("custom"),content:de()}),O({method:W("echo_update"),buffer_paths:re,state:se}),O({method:W("close")})]);function Pn(t){return t==null?!1:He.safeParse(t).success}async function Mn({modelId:t,msg:e,buffers:n,modelManager:r}){if(e.method==="echo_update")return;if(e.method==="custom"){(await r.get(t)).receiveCustomMessage(e,n);return}if(e.method==="close"){r.delete(t);return}let{method:s,state:i,buffer_paths:d=[]}=e,l=Y({state:i,bufferPaths:d,buffers:n});if(s==="open"){let p=new De(l,b=>{let{state:x,buffers:w,bufferPaths:_}=ne(b);ye().sendModelValue({modelId:t,message:{state:x,bufferPaths:_},buffers:w})},y,new Set);r.set(t,p);return}if(s==="update"){(await r.get(t)).updateAndEmitDiffs(l);return}wt(s)}const Be=P(null),jn=P(null),Ve=P(!1),Tn=P(!1),Xe=P(!1);var In=pe();const $e=t=>{let e=(0,In.c)(8),{onResize:n,startingWidth:r,minWidth:s,maxWidth:i}=t,d=(0,u.useRef)(null),l=(0,u.useRef)(null),p=(0,u.useRef)(null),b,x;e[0]!==i||e[1]!==s||e[2]!==n?(b=()=>{let C=d.current,k=l.current,R=p.current;if(!C||!k&&!R)return;let v=Number.parseInt(window.getComputedStyle(C).width,10),N=0,q=!1,T=null,L=c=>{if(!C||!q||!T)return;let h=c.clientX-N;N=c.clientX,v=T==="left"?v-h:v+h,s&&(v=Math.max(s,v)),i&&(v=Math.min(i,v)),C.style.width=`${v}px`},U=()=>{q&&(n==null||n(v),q=!1,T=null),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)},o=(c,h)=>{c.preventDefault(),q=!0,T=h,N=c.clientX,document.addEventListener("mousemove",L),document.addEventListener("mouseup",U)},f=c=>o(c,"left"),g=c=>o(c,"right");return k&&k.addEventListener("mousedown",f),R&&R.addEventListener("mousedown",g),()=>{k&&k.removeEventListener("mousedown",f),R&&R.removeEventListener("mousedown",g),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",U)}},x=[s,i,n],e[0]=i,e[1]=s,e[2]=n,e[3]=b,e[4]=x):(b=e[3],x=e[4]),(0,u.useEffect)(b,x);let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w={left:l,right:p},e[5]=w):w=e[5];let _=r==="contentWidth"?"var(--content-width-medium)":`${r}px`,F;return e[6]===_?F=e[7]:(F={resizableDivRef:d,handleRefs:w,style:{width:_}},e[6]=_,e[7]=F),F};function Ye(t){t||window.dispatchEvent(new Event("resize"))}var Ge=pe(),m=ce(Rt(),1);const An=()=>{let t=(0,Ge.c)(16),[e,n]=D(Be),[r,s]=D(Ve),[i,d]=D(Tn),[l,p]=D(Xe),b;t[0]!==s||t[1]!==n?(b=()=>{n(null),s(!1)},t[0]=s,t[1]=n,t[2]=b):b=t[2];let x=b;if(J(B.CONTEXT_AWARE_PANEL).length===0||!e||!r)return null;let w;t[3]!==l||t[4]!==i||t[5]!==p||t[6]!==d?(w=()=>(0,m.jsxs)("div",{className:"flex flex-row items-center gap-3",children:[(0,m.jsx)(we,{content:i?"Unpin panel":"Pin panel",children:(0,m.jsx)(xe,{size:"xs",onPressedChange:()=>d(!i),pressed:i,"aria-label":i?"Unpin panel":"Pin panel",children:i?(0,m.jsx)(Xt,{className:"w-4 h-4"}):(0,m.jsx)(St,{className:"w-4 h-4"})})}),(0,m.jsx)(we,{content:l?(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Follow focused table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel updates as cells that output tables are focused. Click to fix to the current cell."})]}):(0,m.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,m.jsx)("span",{children:"Focus on current table"}),(0,m.jsx)("span",{className:"text-xs text-muted-foreground w-64",children:"The panel is focused on the current table. Click to update based on which cell is focused."})]}),children:(0,m.jsx)(xe,{size:"xs",onPressedChange:()=>p(!l),pressed:l,"aria-label":l?"Follow focused cell":"Fixed",children:(0,m.jsx)(Vt,{className:Nt("w-4 h-4",l&&"text-primary")})})})]}),t[3]=l,t[4]=i,t[5]=p,t[6]=d,t[7]=w):w=t[7];let _=w,F;t[8]!==x||t[9]!==_?(F=()=>(0,m.jsxs)("div",{className:"mt-2 pb-7 mb-4 h-full overflow-auto",children:[(0,m.jsxs)("div",{className:"flex flex-row justify-between items-center mx-2",children:[_(),(0,m.jsx)(Ft,{variant:"linkDestructive",size:"icon",onClick:x,"aria-label":"Close selection panel",children:(0,m.jsx)(qt,{className:"w-4 h-4"})})]}),(0,m.jsx)(ge,{children:(0,m.jsx)(ke,{name:B.CONTEXT_AWARE_PANEL})})]}),t[8]=x,t[9]=_,t[10]=F):F=t[10];let C=F;if(!i){let v;return t[11]===C?v=t[12]:(v=(0,m.jsx)(Un,{children:C()}),t[11]=C,t[12]=v),v}let k;t[13]===Symbol.for("react.memo_cache_sentinel")?(k=(0,m.jsx)(Dt,{onDragging:Ye,className:"resize-handle border-border z-20 no-print border-l"}),t[13]=k):k=t[13];let R;return t[14]===C?R=t[15]:(R=(0,m.jsxs)(m.Fragment,{children:[k,(0,m.jsx)(Ht,{defaultSize:20,minSize:15,maxSize:80,children:C()})]}),t[14]=C,t[15]=R),R},Ln=t=>{let e=(0,Ge.c)(2),{children:n}=t,r;return e[0]===n?r=e[1]:(r=(0,m.jsx)(ge,{children:(0,m.jsx)(Yt,{name:B.CONTEXT_AWARE_PANEL,children:n})}),e[0]=n,e[1]=r),r};var Un=({children:t})=>{let{resizableDivRef:e,handleRefs:n,style:r}=$e({startingWidth:400,minWidth:300,maxWidth:1500});return(0,m.jsxs)("div",{className:"absolute z-40 right-0 h-full bg-background flex flex-row",children:[(0,m.jsx)("div",{ref:n.left,className:"w-1 h-full cursor-col-resize border-l"}),(0,m.jsx)("div",{ref:e,style:r,children:t})]})};function zn(){var t=[...arguments];return(0,u.useMemo)(()=>e=>{t.forEach(n=>n(e))},t)}var Qe=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0;function G(t){let e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function ae(t){return"nodeType"in t}function A(t){var e;return t?G(t)?t:ae(t)?((e=t.ownerDocument)==null?void 0:e.defaultView)??window:window:window}function Ke(t){let{Document:e}=A(t);return t instanceof e}function Ze(t){return G(t)?!1:t instanceof A(t).HTMLElement}function Je(t){return t instanceof A(t).SVGElement}function On(t){return t?G(t)?t.document:ae(t)?Ke(t)?t:Ze(t)||Je(t)?t.ownerDocument:document:document:document}var ie=Qe?u.useLayoutEffect:u.useEffect;function et(t){let e=(0,u.useRef)(t);return ie(()=>{e.current=t}),(0,u.useCallback)(function(){var n=[...arguments];return e.current==null?void 0:e.current(...n)},[])}function Wn(){let t=(0,u.useRef)(null);return[(0,u.useCallback)((e,n)=>{t.current=setInterval(e,n)},[]),(0,u.useCallback)(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[])]}function Dn(t,e){e===void 0&&(e=[t]);let n=(0,u.useRef)(t);return ie(()=>{n.current!==t&&(n.current=t)},e),n}function Hn(t,e){let n=(0,u.useRef)();return(0,u.useMemo)(()=>{let r=t(n.current);return n.current=r,r},[...e])}function Bn(t){let e=et(t),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(r=>{r!==n.current&&(e==null||e(r,n.current)),n.current=r},[])]}function Vn(t){let e=(0,u.useRef)();return(0,u.useEffect)(()=>{e.current=t},[t]),e.current}var oe={};function Xn(t,e){return(0,u.useMemo)(()=>{if(e)return e;let n=oe[t]==null?0:oe[t]+1;return oe[t]=n,t+"-"+n},[t,e])}function tt(t){return function(e){return[...arguments].slice(1).reduce((n,r)=>{let s=Object.entries(r);for(let[i,d]of s){let l=n[i];l!=null&&(n[i]=l+t*d)}return n},{...e})}}var $n=tt(1),Yn=tt(-1);function Gn(t){return"clientX"in t&&"clientY"in t}function Qn(t){if(!t)return!1;let{KeyboardEvent:e}=A(t.target);return e&&t instanceof e}function Kn(t){if(!t)return!1;let{TouchEvent:e}=A(t.target);return e&&t instanceof e}function Zn(t){if(Kn(t)){if(t.touches&&t.touches.length){let{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){let{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return Gn(t)?{x:t.clientX,y:t.clientY}:null}var le=Object.freeze({Translate:{toString(t){if(!t)return;let{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;let{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[le.Translate.toString(t),le.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),nt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Jn(t){return t.matches(nt)?t:t.querySelector(nt)}export{vn as $,jn as A,Fn as B,Xn as C,$e as D,Ye as E,Pn as F,ze as G,Cn as H,Y as I,Le as J,Ae as K,qn as L,We as M,De as N,Ve as O,Mn as P,Te as Q,ne as R,Vn as S,Ln as T,Oe as U,Nn as V,_n as W,Ie as X,En as Y,xn as Z,Wn as _,Zn as a,rn as at,Hn as b,Ke as c,J as ct,ae as d,X as et,Je as f,et as g,zn as h,Jn as i,B as it,Xe as j,Be as k,Ze as l,H as lt,Yn as m,$n as n,Se as nt,On as o,nn as ot,G as p,Ue as q,Qe as r,Re as rt,A as s,ke as st,le as t,pn as tt,Qn as u,ie as v,An as w,Bn as x,Dn as y,kn as z};
package/dist/index.html CHANGED
@@ -66,7 +66,7 @@
66
66
  <marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
67
67
  <!-- /TODO -->
68
68
  <title>{{ title }}</title>
69
- <script type="module" crossorigin src="./assets/index-CQBtzy-J.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-B8BT3mFF.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-BW0IMuFq.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/hotkeys-uKX61F1_.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/defaultLocale-BLUna9fQ.js">
@@ -136,7 +136,7 @@
136
136
  <link rel="modulepreload" crossorigin href="./assets/toInteger-CDcO32Gx.js">
137
137
  <link rel="modulepreload" crossorigin href="./assets/database-zap-CaVvnK_o.js">
138
138
  <link rel="modulepreload" crossorigin href="./assets/main-CwSdzVhm.js">
139
- <link rel="modulepreload" crossorigin href="./assets/cells-rr1jjvJk.js">
139
+ <link rel="modulepreload" crossorigin href="./assets/cells-BEv4yuHU.js">
140
140
  <link rel="modulepreload" crossorigin href="./assets/ErrorBoundary-Drf1manw.js">
141
141
  <link rel="modulepreload" crossorigin href="./assets/kbd-Czc5z_04.js">
142
142
  <link rel="modulepreload" crossorigin href="./assets/useInstallPackage-RldLPyJs.js">
@@ -150,33 +150,33 @@
150
150
  <link rel="modulepreload" crossorigin href="./assets/usePress-C2LPFxyv.js">
151
151
  <link rel="modulepreload" crossorigin href="./assets/input-CaEtLL8p.js">
152
152
  <link rel="modulepreload" crossorigin href="./assets/ImperativeModal-q6QlC2aZ.js">
153
- <link rel="modulepreload" crossorigin href="./assets/cell-link-Hwo1QbqQ.js">
153
+ <link rel="modulepreload" crossorigin href="./assets/cell-link-gAvJ31U3.js">
154
154
  <link rel="modulepreload" crossorigin href="./assets/multi-map-fjX9ImVF.js">
155
155
  <link rel="modulepreload" crossorigin href="./assets/alert-BEdExd6A.js">
156
156
  <link rel="modulepreload" crossorigin href="./assets/chevron-right-CqEd11Di.js">
157
157
  <link rel="modulepreload" crossorigin href="./assets/dropdown-menu-BP4_BZLr.js">
158
158
  <link rel="modulepreload" crossorigin href="./assets/links-DNmjkr65.js">
159
- <link rel="modulepreload" crossorigin href="./assets/datasource-DHbNHnua.js">
160
- <link rel="modulepreload" crossorigin href="./assets/state-BHFBtWym.js">
161
- <link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-CO8cm8-0.js">
159
+ <link rel="modulepreload" crossorigin href="./assets/datasource-hC-skADj.js">
160
+ <link rel="modulepreload" crossorigin href="./assets/state-BrkNVBuj.js">
161
+ <link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-C_Zgofmd.js">
162
162
  <link rel="modulepreload" crossorigin href="./assets/copy-DRhpWiOq.js">
163
163
  <link rel="modulepreload" crossorigin href="./assets/copy-gBVL4NN-.js">
164
164
  <link rel="modulepreload" crossorigin href="./assets/copy-icon-B69c-352.js">
165
165
  <link rel="modulepreload" crossorigin href="./assets/spinner-C1czjtp7.js">
166
- <link rel="modulepreload" crossorigin href="./assets/es-YVwBDiDw.js">
167
- <link rel="modulepreload" crossorigin href="./assets/focus-D3ygI6Sy.js">
166
+ <link rel="modulepreload" crossorigin href="./assets/es-BlGpQO9i.js">
167
+ <link rel="modulepreload" crossorigin href="./assets/focus-yB7yTfF-.js">
168
168
  <link rel="modulepreload" crossorigin href="./assets/LazyAnyLanguageCodeMirror-jpEDlD0M.js">
169
169
  <link rel="modulepreload" crossorigin href="./assets/katex-AwOI3EvM.js">
170
170
  <link rel="modulepreload" crossorigin href="./assets/marked.esm-CHnOtnr3.js">
171
171
  <link rel="modulepreload" crossorigin href="./assets/chunk-OGVTOU66-CjNLT2C3.js">
172
- <link rel="modulepreload" crossorigin href="./assets/markdown-renderer-DecoaRsV.js">
172
+ <link rel="modulepreload" crossorigin href="./assets/markdown-renderer-D0AQKFve.js">
173
173
  <link rel="modulepreload" crossorigin href="./assets/dist-DOFFh6Ii.js">
174
- <link rel="modulepreload" crossorigin href="./assets/command-xU8ykulh.js">
174
+ <link rel="modulepreload" crossorigin href="./assets/command-Ba7-DaYn.js">
175
175
  <link rel="modulepreload" crossorigin href="./assets/popover-DtnzNVk-.js">
176
- <link rel="modulepreload" crossorigin href="./assets/useRunCells-BGzo-QMk.js">
177
- <link rel="modulepreload" crossorigin href="./assets/mode-BYulXE3t.js">
176
+ <link rel="modulepreload" crossorigin href="./assets/useRunCells-dG-K1cYZ.js">
177
+ <link rel="modulepreload" crossorigin href="./assets/mode-DwlGsYIa.js">
178
178
  <link rel="modulepreload" crossorigin href="./assets/purify.es-N-2faAGj.js">
179
- <link rel="modulepreload" crossorigin href="./assets/RenderHTML-D6fh5YLC.js">
179
+ <link rel="modulepreload" crossorigin href="./assets/RenderHTML-CQm5bp6v.js">
180
180
  <link rel="modulepreload" crossorigin href="./assets/table--_20dwBZ.js">
181
181
  <link rel="modulepreload" crossorigin href="./assets/tabs-Ctk4D03n.js">
182
182
  <link rel="modulepreload" crossorigin href="./assets/useAsyncData-BJJJOr9W.js">
@@ -186,7 +186,7 @@
186
186
  <link rel="modulepreload" crossorigin href="./assets/en-US-DhMN8sxe.js">
187
187
  <link rel="modulepreload" crossorigin href="./assets/isValid-DhzaK-Y1.js">
188
188
  <link rel="modulepreload" crossorigin href="./assets/dates-CdsE1R40.js">
189
- <link rel="modulepreload" crossorigin href="./assets/download-DKRxBkYD.js">
189
+ <link rel="modulepreload" crossorigin href="./assets/download-VDZsvjsd.js">
190
190
  <link rel="modulepreload" crossorigin href="./assets/maps-s2pQkyf5.js">
191
191
  <link rel="modulepreload" crossorigin href="./assets/extends-B9D0JO9U.js">
192
192
  <link rel="modulepreload" crossorigin href="./assets/emotion-is-prop-valid.esm-lG8j6oqk.js">
@@ -194,47 +194,47 @@
194
194
  <link rel="modulepreload" crossorigin href="./assets/range-sshwVRcP.js">
195
195
  <link rel="modulepreload" crossorigin href="./assets/capitalize-DQeWKRGx.js">
196
196
  <link rel="modulepreload" crossorigin href="./assets/table-BLx7B_us.js">
197
- <link rel="modulepreload" crossorigin href="./assets/JsonOutput-CkeISXrs.js">
197
+ <link rel="modulepreload" crossorigin href="./assets/JsonOutput-CZTTeJuI.js">
198
198
  <link rel="modulepreload" crossorigin href="./assets/file-BnFXtaZZ.js">
199
199
  <link rel="modulepreload" crossorigin href="./assets/play-BJDBXApx.js">
200
- <link rel="modulepreload" crossorigin href="./assets/chat-components-DXJsXOD8.js">
200
+ <link rel="modulepreload" crossorigin href="./assets/chat-components-CtSjkjex.js">
201
201
  <link rel="modulepreload" crossorigin href="./assets/isEmpty-DIxUV1UR.js">
202
202
  <link rel="modulepreload" crossorigin href="./assets/circle-check-big-OIMTUpe6.js">
203
- <link rel="modulepreload" crossorigin href="./assets/chat-display-C08N0rx5.js">
204
- <link rel="modulepreload" crossorigin href="./assets/ai-model-dropdown-D1nEKS8b.js">
203
+ <link rel="modulepreload" crossorigin href="./assets/chat-display-KOmOjcf7.js">
204
+ <link rel="modulepreload" crossorigin href="./assets/ai-model-dropdown-DYQpnG3w.js">
205
205
  <link rel="modulepreload" crossorigin href="./assets/renderShortcut-D0Pei-OA.js">
206
- <link rel="modulepreload" crossorigin href="./assets/useDeleteCell-DBzN8QcP.js">
206
+ <link rel="modulepreload" crossorigin href="./assets/useDeleteCell-Dpa7vzrC.js">
207
207
  <link rel="modulepreload" crossorigin href="./assets/icons-D4lB4En9.js">
208
- <link rel="modulepreload" crossorigin href="./assets/process-output-2gz8Uri2.js">
208
+ <link rel="modulepreload" crossorigin href="./assets/process-output-DYPOAdn4.js">
209
209
  <link rel="modulepreload" crossorigin href="./assets/blob-Dg_vNTSs.js">
210
210
  <link rel="modulepreload" crossorigin href="./assets/objectWithoutPropertiesLoose-CboCOq4o.js">
211
211
  <link rel="modulepreload" crossorigin href="./assets/esm-B3JckBtM.js">
212
- <link rel="modulepreload" crossorigin href="./assets/add-cell-with-ai-B3V6Mgb9.js">
212
+ <link rel="modulepreload" crossorigin href="./assets/add-cell-with-ai-CYDfp9kl.js">
213
213
  <link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-D42sFB6d.js">
214
214
  <link rel="modulepreload" crossorigin href="./assets/square-function-DxXFdbn8.js">
215
215
  <link rel="modulepreload" crossorigin href="./assets/spec-qp_XZeSS.js">
216
- <link rel="modulepreload" crossorigin href="./assets/column-preview-BzvHnhPG.js">
217
- <link rel="modulepreload" crossorigin href="./assets/switch-iJj-D3dz.js">
216
+ <link rel="modulepreload" crossorigin href="./assets/column-preview-BBUgbmud.js">
217
+ <link rel="modulepreload" crossorigin href="./assets/switch-1zrEJdOH.js">
218
218
  <link rel="modulepreload" crossorigin href="./assets/toggle-G1t0cQyf.js">
219
- <link rel="modulepreload" crossorigin href="./assets/globals-D46Vbo5D.js">
219
+ <link rel="modulepreload" crossorigin href="./assets/globals-TVCm1yPw.js">
220
220
  <link rel="modulepreload" crossorigin href="./assets/share-CXQVxivL.js">
221
221
  <link rel="modulepreload" crossorigin href="./assets/memoize-DN0TMY36.js">
222
222
  <link rel="modulepreload" crossorigin href="./assets/get-CyLJYAfP.js">
223
223
  <link rel="modulepreload" crossorigin href="./assets/_baseSet-6FYvpjrm.js">
224
224
  <link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-BqxQegSf.js">
225
- <link rel="modulepreload" crossorigin href="./assets/utilities.esm-CT3NbLA9.js">
226
- <link rel="modulepreload" crossorigin href="./assets/floating-outline-CHprSkP6.js">
227
- <link rel="modulepreload" crossorigin href="./assets/useAddCell-BpMe5DB-.js">
225
+ <link rel="modulepreload" crossorigin href="./assets/utilities.esm-DcHHFDdt.js">
226
+ <link rel="modulepreload" crossorigin href="./assets/floating-outline-DPboW4_E.js">
227
+ <link rel="modulepreload" crossorigin href="./assets/useAddCell-DAIZvt_N.js">
228
228
  <link rel="modulepreload" crossorigin href="./assets/eye-off-D9zAYqG9.js">
229
229
  <link rel="modulepreload" crossorigin href="./assets/plus-CHesBJpY.js">
230
- <link rel="modulepreload" crossorigin href="./assets/readonly-python-code-ihKi3Mrq.js">
230
+ <link rel="modulepreload" crossorigin href="./assets/readonly-python-code-DekTVJhb.js">
231
231
  <link rel="modulepreload" crossorigin href="./assets/file-video-camera-CZUg-nFA.js">
232
- <link rel="modulepreload" crossorigin href="./assets/types-4-l_7Ws2.js">
232
+ <link rel="modulepreload" crossorigin href="./assets/types-Qx81Y6OC.js">
233
233
  <link rel="modulepreload" crossorigin href="./assets/label-qwandMoh.js">
234
- <link rel="modulepreload" crossorigin href="./assets/textarea-DmNrZcLR.js">
234
+ <link rel="modulepreload" crossorigin href="./assets/textarea-CmispJBv.js">
235
235
  <link rel="modulepreload" crossorigin href="./assets/refresh-ccw-DbW1_PHb.js">
236
236
  <link rel="modulepreload" crossorigin href="./assets/trash-2-C-lF7BNB.js">
237
- <link rel="modulepreload" crossorigin href="./assets/form-B_zRT4QS.js">
237
+ <link rel="modulepreload" crossorigin href="./assets/form-iKFmPQ40.js">
238
238
  <link rel="modulepreload" crossorigin href="./assets/field-DDKGFzpC.js">
239
239
  <link rel="modulepreload" crossorigin href="./assets/useBoolean-BDG41CyP.js">
240
240
  <link rel="modulepreload" crossorigin href="./assets/useDeepCompareMemoize-gzLRYatP.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.18.5-dev172",
3
+ "version": "0.18.5-dev176",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -7,7 +7,7 @@ import { createReducerAndAtoms } from "@/utils/createReducer";
7
7
  import { jotaiJsonStorage } from "@/utils/storage/jotai";
8
8
  import { ZodLocalStorage } from "@/utils/storage/typed";
9
9
  import type { PanelType } from "./types";
10
- import { PANELS } from "./types";
10
+ import { isPanelHidden, PANELS } from "./types";
11
11
 
12
12
  export interface ChromeState {
13
13
  selectedPanel: PanelType | undefined;
@@ -27,10 +27,10 @@ export interface PanelLayout {
27
27
 
28
28
  const DEFAULT_PANEL_LAYOUT: PanelLayout = {
29
29
  sidebar: PANELS.filter(
30
- (p) => !p.hidden && p.defaultSection === "sidebar",
30
+ (p) => !isPanelHidden(p) && p.defaultSection === "sidebar",
31
31
  ).map((p) => p.type),
32
32
  developerPanel: PANELS.filter(
33
- (p) => !p.hidden && p.defaultSection === "developer-panel",
33
+ (p) => !isPanelHidden(p) && p.defaultSection === "developer-panel",
34
34
  ).map((p) => p.type),
35
35
  };
36
36
 
@@ -18,7 +18,9 @@ import {
18
18
  VariableIcon,
19
19
  XCircleIcon,
20
20
  } from "lucide-react";
21
+ import { hasCapability } from "@/core/config/capabilities";
21
22
  import { getFeatureFlag } from "@/core/config/feature-flag";
23
+ import type { Capabilities } from "@/core/kernel/messages";
22
24
  import { isWasm } from "@/core/wasm/utils";
23
25
 
24
26
  /**
@@ -56,6 +58,8 @@ export interface PanelDescriptor {
56
58
  hidden?: boolean;
57
59
  /** Which section this panel belongs to by default */
58
60
  defaultSection: PanelSection;
61
+ /** Capability required for this panel to be visible. If the capability is false, the panel is hidden. */
62
+ requiredCapability?: keyof Capabilities;
59
63
  }
60
64
 
61
65
  /**
@@ -162,7 +166,9 @@ export const PANELS: PanelDescriptor[] = [
162
166
  Icon: TerminalSquareIcon,
163
167
  label: "Terminal",
164
168
  tooltip: "Terminal",
169
+ hidden: isWasm(),
165
170
  defaultSection: "developer-panel",
171
+ requiredCapability: "terminal",
166
172
  },
167
173
  {
168
174
  type: "cache",
@@ -177,3 +183,19 @@ export const PANELS: PanelDescriptor[] = [
177
183
  export const PANEL_MAP = new Map<PanelType, PanelDescriptor>(
178
184
  PANELS.map((p) => [p.type, p]),
179
185
  );
186
+
187
+ /**
188
+ * Check if a panel should be hidden based on its `hidden` property
189
+ * and `requiredCapability`.
190
+ */
191
+ export function isPanelHidden(panel: PanelDescriptor): boolean {
192
+ if (panel.hidden) {
193
+ return true;
194
+ }
195
+ if (panel.requiredCapability) {
196
+ if (!hasCapability(panel.requiredCapability)) {
197
+ return true;
198
+ }
199
+ }
200
+ return false;
201
+ }
@@ -28,7 +28,12 @@ import { ErrorBoundary } from "../../boundary/ErrorBoundary";
28
28
  import { ContextAwarePanel } from "../panels/context-aware-panel/context-aware-panel";
29
29
  import { PanelSectionProvider } from "../panels/panel-context";
30
30
  import { panelLayoutAtom, useChromeActions, useChromeState } from "../state";
31
- import { PANEL_MAP, PANELS, type PanelDescriptor } from "../types";
31
+ import {
32
+ isPanelHidden,
33
+ PANEL_MAP,
34
+ PANELS,
35
+ type PanelDescriptor,
36
+ } from "../types";
32
37
  import { BackendConnectionStatus } from "./footer-items/backend-status";
33
38
  import { Minimap } from "./minimap";
34
39
  import { PanelsWrapper } from "./panels";
@@ -125,7 +130,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
125
130
  const availableDevPanels = useMemo(() => {
126
131
  const sidebarIds = new Set(panelLayout.sidebar);
127
132
  return PANELS.filter((p) => {
128
- if (p.hidden) {
133
+ if (isPanelHidden(p)) {
129
134
  return false;
130
135
  }
131
136
  // Exclude panels that are in the sidebar
@@ -11,7 +11,12 @@ import { notebookQueuedOrRunningCountAtom } from "@/core/cells/cells";
11
11
  import { cn } from "@/utils/cn";
12
12
  import { FeedbackButton } from "../components/feedback-button";
13
13
  import { panelLayoutAtom, useChromeActions, useChromeState } from "../state";
14
- import { PANEL_MAP, PANELS, type PanelDescriptor } from "../types";
14
+ import {
15
+ isPanelHidden,
16
+ PANEL_MAP,
17
+ PANELS,
18
+ type PanelDescriptor,
19
+ } from "../types";
15
20
 
16
21
  export const Sidebar: React.FC = () => {
17
22
  const { selectedPanel, selectedDeveloperPanelTab } = useChromeState();
@@ -28,7 +33,7 @@ export const Sidebar: React.FC = () => {
28
33
  const availableSidebarPanels = useMemo(() => {
29
34
  const devPanelIds = new Set(panelLayout.developerPanel);
30
35
  return PANELS.filter((p) => {
31
- if (p.hidden) {
36
+ if (isPanelHidden(p)) {
32
37
  return false;
33
38
  }
34
39
  // Exclude panels that are in the developer panel
@@ -11,5 +11,5 @@ export const capabilitiesAtom = atom<Capabilities>({
11
11
  });
12
12
 
13
13
  export function hasCapability(key: keyof Capabilities): boolean {
14
- return store.get(capabilitiesAtom)[key] ?? false;
14
+ return store.get(capabilitiesAtom)?.[key] ?? false;
15
15
  }
@@ -15,7 +15,7 @@ import type { ResolvedTheme } from "@/theme/useTheme";
15
15
  import { Logger } from "@/utils/Logger";
16
16
  import { ErrorBanner } from "../common/error-banner";
17
17
 
18
- export const LANGUAGE_MAP: Record<string, string> = {
18
+ export const LANGUAGE_MAP: Record<string, LanguageName | undefined> = {
19
19
  python: "py",
20
20
  javascript: "js",
21
21
  typescript: "ts",
@@ -1 +0,0 @@
1
- import{s as P}from"./chunk-LvLJmgfZ.js";import{d as j,l as O,n as w,u as y}from"./useEvent-DlWF5OMa.js";import{$r as A,A as L,C as $,Gt as E,Hr as _,O as S,Pt as T,pt as D}from"./cells-rr1jjvJk.js";import{t as b}from"./compiler-runtime-DeeZ7FnK.js";import{d as F}from"./hotkeys-uKX61F1_.js";import{u as H}from"./utils-CJJIceVn.js";import{r as C}from"./constants-Bkp4R3bQ.js";import{j as q,p as B,w as G}from"./config-cCkBQ_ER.js";import{t as M}from"./jsx-runtime-DN_bIXfG.js";import{t as R}from"./cn-C1rgT0yh.js";import{r as U}from"./requests-C0HaHO6a.js";import{n as V}from"./ImperativeModal-q6QlC2aZ.js";var z=b();function I(){return y(_)}function J(){let r=(0,z.c)(5),[t]=O(G),e=j(_),{openAlert:a}=V(),{sendRename:o}=U(),s;return r[0]!==t.state||r[1]!==a||r[2]!==o||r[3]!==e?(s=async l=>{let n=H();return t.state===q.OPEN?(B(i=>{l===null?i.delete(C.filePath):i.set(C.filePath,l)}),o({filename:l}).then(()=>(e(l),document.title=n.app_title||T.basename(l)||"Untitled Notebook",l)).catch(i=>(a(i.message),null))):(a("Failed to save notebook: not connected to a kernel."),null)},r[0]=t.state,r[1]=a,r[2]=o,r[3]=e,r[4]=s):s=r[4],w(s)}var p=b(),v=P(M(),1);const k=r=>{let t=(0,p.c)(12),{className:e,cellId:a,variant:o,onClick:s,formatCellName:l,skipScroll:n}=r,i=L()[a]??"",x=S().inOrderIds.indexOf(a),{showCellIfHidden:d}=$(),g=l??W,c;t[0]===e?c=t[1]:(c=R("inline-block cursor-pointer text-link hover:underline",e),t[0]=e,t[1]=c);let m;t[2]!==a||t[3]!==s||t[4]!==d||t[5]!==n||t[6]!==o?(m=h=>{if(a==="__scratch__")return!1;d({cellId:a}),h.stopPropagation(),h.preventDefault(),requestAnimationFrame(()=>{N(a,o,n)&&(s==null||s())})},t[2]=a,t[3]=s,t[4]=d,t[5]=n,t[6]=o,t[7]=m):m=t[7];let f=g(D(i,x)),u;return t[8]!==c||t[9]!==m||t[10]!==f?(u=(0,v.jsx)("div",{className:c,role:"link",tabIndex:-1,onClick:m,children:f}),t[8]=c,t[9]=m,t[10]=f,t[11]=u):u=t[11],u},K=r=>{let t=(0,p.c)(2),e;return t[0]===r?e=t[1]:(e=(0,v.jsx)(k,{...r,variant:"destructive"}),t[0]=r,t[1]=e),e},Q=r=>{let t=(0,p.c)(10),{cellId:e,lineNumber:a}=r,o=I(),s;t[0]!==e||t[1]!==a?(s=()=>E(e,a),t[0]=e,t[1]=a,t[2]=s):s=t[2];let l;t[3]!==e||t[4]!==o?(l=i=>e==="__scratch__"?"scratch":`marimo://${o||"untitled"}#cell=${i}`,t[3]=e,t[4]=o,t[5]=l):l=t[5];let n;return t[6]!==e||t[7]!==s||t[8]!==l?(n=(0,v.jsx)(k,{cellId:e,onClick:s,skipScroll:!0,variant:"destructive",className:"traceback-cell-link",formatCellName:l}),t[6]=e,t[7]=s,t[8]=l,t[9]=n):n=t[9],n};function N(r,t,e){let a=A.create(r),o=document.getElementById(a);return o===null?(F.error(`Cell ${a} not found on page.`),!1):(e||o.scrollIntoView({behavior:"smooth",block:"center"}),t==="destructive"&&(o.classList.add("error-outline"),setTimeout(()=>{o.classList.remove("error-outline")},2e3)),t==="focus"&&(o.classList.add("focus-outline"),setTimeout(()=>{o.classList.remove("focus-outline")},2e3)),!0)}function W(r){return r}export{I as a,N as i,K as n,J as o,Q as r,k as t};
@@ -1,4 +0,0 @@
1
- var A=Object.defineProperty;var L=(n,e,t)=>e in n?A(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>L(n,typeof e!="symbol"?e+"":e,t);var g;import{i as p,o as W,p as b}from"./useEvent-DlWF5OMa.js";import{Br as P,Cr as R,Dr as B,Er as K,Gr as j,Ht as a,It as J,Lt as Q,Or as X,Tt as Y,Ut as w,V as Z,Wt as ee,dn as te,dr as v,fr as D,kr as ne,qt as ie,zt as S}from"./cells-rr1jjvJk.js";import{x as re}from"./_Uint8Array-BGESiCQL.js";import{i as se}from"./useLifecycle-CmDXEyIC.js";import{t as oe}from"./debounce-BbFlGgjv.js";import{d as o}from"./hotkeys-uKX61F1_.js";import{t as x}from"./invariant-C6yE60hi.js";import{d as ae,g as I}from"./utils-CJJIceVn.js";import{k as le,r as ce}from"./config-cCkBQ_ER.js";import{St as m,Ut as E,at as ue,ct as M}from"./dist-CAcX026F.js";import{O as T,g as de,k as F,w as me}from"./dist-CI6_zMIl.js";import{n as h}from"./once-CTiSlR1m.js";import{t as pe}from"./requests-C0HaHO6a.js";import{t as ge}from"./use-toast-Bzf3rpev.js";import{a as he}from"./error-banner-DU5Qb8a8.js";var fe="Expected a function";function we(n,e,t){var r=!0,s=!0;if(typeof n!="function")throw TypeError(fe);return re(t)&&(r="leading"in t?!!t.leading:r,s="trailing"in t?!!t.trailing:s),oe(n,e,{leading:r,maxWait:e,trailing:s})}var ve=we;function Ce(n){"scheduler"in window?window.scheduler.postTask(n,{priority:"background"}):"requestIdleCallback"in window?requestIdleCallback(n):setTimeout(n,0)}var C=null,ye=class{constructor(n){c(this,"abortController",new AbortController);this.view=n.view,this.view.dom.addEventListener("focus",()=>{C=new WeakRef(this.view)},{signal:this.abortController.signal,capture:!0}),this.update()}update(){let n=this.view.dom.querySelector(".cm-vimCursorLayer");if(n instanceof HTMLElement)if(Z())n.style.display="none";else{let e=(C==null?void 0:C.deref())===this.view;n.style.display=e?"":"none"}}destroy(){this.abortController.abort()}};const O={map:{args:["lhs","rhs"]},nmap:{mode:"normal",args:["lhs","rhs"]},vmap:{mode:"visual",args:["lhs","rhs"]},imap:{mode:"insert",args:["lhs","rhs"]},noremap:{args:["lhs","rhs"]},nnoremap:{mode:"normal",args:["lhs","rhs"]},vnoremap:{mode:"visual",args:["lhs","rhs"]},inoremap:{mode:"insert",args:["lhs","rhs"]},unmap:{args:["lhs"]},nunmap:{mode:"normal",args:["lhs"]},vunmap:{mode:"visual",args:["lhs"]},iunmap:{mode:"insert",args:["lhs"]},mapclear:{},nmapclear:{mode:"normal"},vmapclear:{mode:"visual"},imapclear:{mode:"insert"}};function be(n,e){let t=[];for(let r of n.split(`
2
- `)){if(r.startsWith('"')||r.trim()==="")continue;let s=xe(r,e);s&&t.push(s)}return t}function xe(n,e){let t=n.split(/\s+/),r=t[0],s=0;if(r in O){let i=O[r],u={};for(let f of i.args||[])if(s+=1,s<t.length)u[f]=t[s];else{e&&e(`Not enough arguments for "${r}" command: "${n}"`);return}let d={name:r};return"args"in i&&(d.args=u),"mode"in i&&(d.mode=i.mode),d}e&&e(`Unknown vimrc command: "${n}"`)}function Ie(){return ke(),De(),[m.of([{key:"j",run:n=>{if(J(n,!0)&&S(n)){let e=n.state.facet(v),t=n.state.facet(D);return e.moveToNextCell({cellId:t,before:!1,noCreate:!0}),!0}return!1}}]),m.of([{key:"k",run:n=>{if(Q(n)&&S(n)){let e=n.state.facet(v),t=n.state.facet(D);return e.moveToNextCell({cellId:t,before:!0,noCreate:!0}),!0}return!1}}]),m.of([{linux:"Ctrl-[",win:"Ctrl-[",run:n=>{let e=w(n);return e?$(e)?e.state.vim.insertMode?(a.exitInsertMode(e,!0),!0):!1:(o.warn("Expected CodeMirror instance to have Vim state"),!1):(o.warn("Expected CodeMirror instance to have CodeMirror instance state"),!1)}}]),M.define(n=>(requestAnimationFrame(()=>{H.INSTANCES.addInstance(n)}),{destroy(){H.INSTANCES.removeInstance(n)}})),M.define(n=>new ye({view:n})),ue.domEventHandlers({keydown(n,e){return n.ctrlKey&&n.key==="Escape"?(e.dom.dispatchEvent(new KeyboardEvent(n.type,n)),!0):!1}})]}var ke=h(()=>{a.defineAction("goToDefinition",n=>{let e=n.cm6;return ie(e)}),a.mapCommand("gd","action","goToDefinition",{},{context:"normal"}),a.defineEx("write","w",n=>{let e=n.cm6;e&&e.state.facet(v).saveNotebook()})}),De=h(async()=>{var e;let n=(e=p.get(I).keymap)==null?void 0:e.vimrc;if(n)try{o.log(`Loading vimrc from ${n}`);let t=(await pe().sendFileDetails({path:n})).contents;if(!t){o.error(`Failed to load vimrc from ${n}`);return}Se(be(t,o.warn))}catch(t){o.error("Failed to load vimrc:",t)}});function Se(n){function e(i){if(!i.args){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}if(!i.args.lhs||!i.args.rhs){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}i.mode?a.map(i.args.lhs,i.args.rhs,i.mode):a.map(i.args.lhs,i.args.rhs)}function t(i){if(!i.args){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}if(!i.args.lhs||!i.args.rhs){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}i.mode?a.noremap(i.args.lhs,i.args.rhs,i.mode):a.noremap(i.args.lhs,i.args.rhs)}function r(i){if(!i.args){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}if(!i.args.lhs){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}i.mode?a.unmap(i.args.lhs,i.mode):a.unmap(i.args.lhs)}function s(i){i.mode?a.mapclear(i.mode):a.mapclear()}for(let i of n)"map|nmap|vmap|imap".split("|").includes(i.name)?e(i):"noremap|nnoremap|vnoremap|inoremap".split("|").includes(i.name)?t(i):"unmap|nunmap|vunmap|iunmap".split("|").includes(i.name)?r(i):"mapclear|nmapclear|vmapclear|imapclear".split("|").includes(i.name)?s(i):o.warn(`Could not execute vimrc command "${i.name}: unknown command"`)}var H=(g=class{constructor(){c(this,"instances",new Set);c(this,"isBroadcasting",!1)}addInstance(e){this.instances.add(e);let t=w(e);if(!t){o.warn("Expected CodeMirror instance to have CodeMirror instance state");return}t.on("vim-mode-change",r=>{this.isBroadcasting||(x("mode"in r,'Expected event to have a "mode" property'),this.isBroadcasting=!0,Ce(()=>{this.broadcastModeChange(e,r.mode,r.subMode),this.isBroadcasting=!1}))})}removeInstance(e){this.instances.delete(e)}broadcastModeChange(e,t,r){x("exitInsertMode"in a,"Vim does not have an exitInsertMode method"),x("exitVisualMode"in a,"Vim does not have an exitVisualMode method");for(let s of this.instances)if(s!==e){let i=w(s);if(!i){o.warn("Expected CodeMirror instance to have CodeMirror instance state");continue}let u=i.setSelections.bind(i);if(i.setSelections=()=>[],!$(i)){o.warn("Expected CodeMirror instance to have Vim state");continue}let d=i.state.vim;switch(t){case"normal":d.insertMode&&a.exitInsertMode(i,!0),d.visualMode&&a.exitVisualMode(i,!0);break;case"insert":d.insertMode||a.handleKey(i,"i","");break;case"visual":break}i.setSelections=u}}},c(g,"INSTANCES",new g),g);function $(n){return n.state.vim!==void 0}const Ee=["default","vim"];function Me(n,e){switch(n.preset){case"default":return[m.of(V()),m.of(q(e))];case"vim":return[m.of(Fe()),m.of(q(e)),m.of([{key:"Enter",run:t=>{var r,s;return(s=(r=w(t))==null?void 0:r.state.vim)!=null&&s.insertMode?me(t):!1}}]),E.high(Oe("d",t=>t.state.doc.toString()==="",t=>t.state.doc.toString()===""?(t.state.facet(v).deleteCell(),!0):!1)),ee({status:!1}),E.high(Ie())];default:return se(n.preset),[]}}var Te=new Set([F,T]),V=h(()=>de.filter(n=>!Te.has(n.run))),q=n=>[{key:n.getHotkey("cell.toggleComment").key,run:F},{key:n.getHotkey("cell.toggleBlockComment").key,run:T}],Fe=h(()=>{let n=new Set(["Enter","Ctrl-v"]);return V().filter(e=>!n.has(e.key||e.mac||e.linux||e.win||""))});function Oe(n,e,t){let r="",s=0;return m.of([{any:(i,u)=>{let d=u.key,f=u.timeStamp;return d!==n||!e(i)?(r="",s=0,!1):r===n&&f-s<500&&t(i)?(r="",s=0,!0):(r=d,s=f,!1)}}])}var N="marimo:copilot:signedIn";const He=j(N,null,te,{getOnInit:!0}),$e=b(null),y=b(null),k=b({busy:!1,kind:null,message:null});function Ve(n){p.set(y,n)}function qe(n){p.get(y)===n&&p.set(y,null)}function Ne(){return P.getItem(N)==="true"}function _(){let n=Ne(),e=ae();return n&&e.completion.copilot==="github"}function _e(){return W(I,n=>n.completion.copilot==="github")}var Ge=B(),l=o.get("@github/copilot-language-server"),Ue=class extends K{constructor(e){super(e);c(this,"documentVersion",0);c(this,"hasOpenedDocument",!1);c(this,"copilotSettings",{});c(this,"getCompletionInternal",async(e,t)=>await this._request("textDocument/inlineCompletion",{...e,textDocument:{...e.textDocument,version:t}}));c(this,"throttledGetCompletionInternal",ve(this.getCompletionInternal,200));c(this,"handleNotification",e=>{if(!e.params)return;let t=e;if(t.method==="statusNotification"&&p.set(k,t.params),t.method==="didChangeStatus"&&p.set(k,t.params),t.method==="window/logMessage"){let{type:r,message:s}=t.params;switch(r){case 1:l.error("[GitHub Copilot]",s);break;case 2:l.warn("[GitHub Copilot]",s);break;case 3:l.debug("[GitHub Copilot]",s);break;default:l.log("[GitHub Copilot]",s);break}}});this.copilotSettings=e.copilotSettings??{},this.onNotification(this.handleNotification),this.attachInitializeListener()}attachInitializeListener(){this.initializePromise.then(()=>{this.sendConfiguration()})}async sendConfiguration(){let e=this.copilotSettings;!e||Object.keys(e).length===0||(await this.notify("workspace/didChangeConfiguration",{settings:e}),l.debug("#sendConfiguration: Configuration sent",e))}async _request(e,t){return await this.request(e,t)}async notify(e,t){return l.debug("#notify",e,t),super.notify(e,t)}getInitializationOptions(){let e={name:"marimo",version:"0.1.0"};return{...super.getInitializationOptions(),workspaceFolders:[],capabilities:{workspace:{workspaceFolders:!1}},initializationOptions:{editorInfo:e,editorPluginInfo:e}}}isDisabled(){return!_()}async textDocumentDidOpen(e){return this.isDisabled()?e:(this.hasOpenedDocument=!0,super.textDocumentDidOpen(e))}async textDocumentCompletion(e){return[]}async textDocumentDidChange(e){if(this.isDisabled())return e;this.hasOpenedDocument||await this.textDocumentDidOpen({textDocument:{uri:e.textDocument.uri,languageId:"python",version:e.textDocument.version,text:e.contentChanges[0].text}});let t=e.contentChanges;t.length!==1&&l.warn("#textDocumentDidChange: Multiple changes detected. This is not supported.",t);let r=t[0];"range"in r&&l.warn("#textDocumentDidChange: Copilot doesn't support range changes.",r);let s=Y(r.text);return super.textDocumentDidChange({...e,contentChanges:[{text:s}],textDocument:Ge.VersionedTextDocumentIdentifier.create(e.textDocument.uri,++this.documentVersion)})}textDocumentHover(e){return Promise.resolve({contents:[]})}signOut(){return this._request("signOut",{})}async signInInitiate(){l.log("#signInInitiate: Starting sign-in flow");try{let e=await this._request("signIn",{});return l.log("#signInInitiate: Sign-in flow started successfully"),e}catch(e){throw l.warn("#signInInitiate: Failed to start sign-in flow",e),e}}async signInConfirm(e){l.log("#signInConfirm: Confirming sign-in");try{let t=await this._request("signInConfirm",e);return l.log("#signInConfirm: Sign-in confirmed successfully"),t}catch(t){throw l.warn("#signInConfirm: Failed to confirm sign-in",t),t}}async signedIn(){try{let{status:e}=await this._request("checkStatus",{});return l.log("#checkStatus: Status check completed",{status:e}),e==="SignedIn"||e==="AlreadySignedIn"||e==="OK"}catch(e){throw l.warn("#signedIn: Failed to check sign-in status",e),e}}async getCompletion(e){if(this.isDisabled())return null;let t=this.documentVersion;if(e.textDocument.version=t,t===0)return null;Ve(t);let r=await this.throttledGetCompletionInternal(e,t);return qe(t),t===this.documentVersion?r??null:null}},ze=X(),Ae=ne(),Le=class extends Ae.Transport{constructor(e){super();c(this,"pendingSubscriptions",[]);this.delegate=void 0,this.pendingSubscriptions=[],this.options={retries:e.retries??3,retryDelayMs:e.retryDelayMs??1e3,maxTimeoutMs:e.maxTimeoutMs??5e3,getWsUrl:e.getWsUrl,waitForReady:e.waitForReady,showError:e.showError}}subscribe(...e){super.subscribe(...e);let[t,r]=e;this.pendingSubscriptions.push({event:t,handler:r}),this.delegate&&this.delegate.subscribe(t,r)}unsubscribe(...e){let t=super.unsubscribe(...e),[r,s]=e;if(this.delegate&&this.delegate.unsubscribe(r,s),s)if(r){let i=this.pendingSubscriptions.findIndex(u=>u.event===r&&u.handler===s);i>-1&&this.pendingSubscriptions.splice(i,1)}else this.pendingSubscriptions=this.pendingSubscriptions.filter(i=>i.handler!==s);else r?this.pendingSubscriptions=this.pendingSubscriptions.filter(i=>i.event!==r):this.pendingSubscriptions=[];return t}createDelegate(){let e=new ze.WebSocketTransport(this.options.getWsUrl());for(let{event:t,handler:r}of this.pendingSubscriptions)e.subscribe(t,r);return e}async tryConnect(){for(let e=1;e<=this.options.retries;e++)try{this.delegate||(this.delegate=this.createDelegate()),await this.delegate.connect(),o.log("Copilot#connect: Connected successfully");return}catch(t){if(o.warn(`Copilot#connect: Connection attempt ${e}/${this.options.retries} failed`,t),e===this.options.retries)throw this.delegate=void 0,this.options.showError("GitHub Copilot Connection Error",`Failed to connect to GitHub Copilot. Please check your settings and try again.
3
-
4
- `+he(t)),t;await new Promise(r=>setTimeout(r,this.options.retryDelayMs))}}async connect(){return await this.options.waitForReady(),this.tryConnect()}close(){var e;(e=this.delegate)==null||e.close(),this.delegate=void 0}async sendData(e,t){if(!this.delegate){o.log("Copilot#sendData: Delegate not initialized, reconnecting...");try{await this.options.waitForReady(),await this.tryConnect()}catch(r){throw o.error("Copilot#sendData: Failed to reconnect transport",r),Error("Unable to connect to GitHub Copilot. Please check your settings and try again.")}}if(!this.delegate)throw Error("Failed to initialize GitHub Copilot connection. Please try again.");return t=Math.min(t??this.options.maxTimeoutMs,this.options.maxTimeoutMs),this.delegate.sendData(e,t)}};const G="/__marimo_copilot__.py";var U=`file://${G}`;const We=h(()=>{let n=ce();return new Le({getWsUrl:()=>n.getLSPURL("copilot").toString(),waitForReady:async()=>{await _e(),await le()},showError:(e,t)=>{ge({variant:"danger",title:e,description:t})}})}),z=h(()=>{var e,t;let n=((t=(e=p.get(I).ai)==null?void 0:e.github)==null?void 0:t.copilot_settings)??{};return new Ue({rootUri:U,workspaceFolders:null,transport:We(),copilotSettings:n})});function Pe(){return R({documentUri:U,client:z(),languageId:"copilot",hoverEnabled:!1,completionEnabled:!1,definitionEnabled:!1,renameEnabled:!1,codeActionsEnabled:!1,signatureHelpEnabled:!1,diagnosticsEnabled:!1,sendIncrementalChanges:!1})}export{k as a,He as c,$e as i,Ee as l,Pe as n,y as o,z as r,_ as s,G as t,Me as u};
@@ -1 +0,0 @@
1
- import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as be,l as we,n as V,p as ae,u as Ne}from"./useEvent-DlWF5OMa.js";import{t as ye}from"./react-BGmjiNul.js";import{$r as ke,C as ze,Gr as Ce,M as Se,dn as Oe,ei as m,__tla as Ae}from"./cells-rr1jjvJk.js";import"./react-dom-C9fstfnp.js";import{t as se}from"./compiler-runtime-DeeZ7FnK.js";import"./tooltip-CrRUCOBw.js";import{f as ie}from"./hotkeys-uKX61F1_.js";import{v as Ie}from"./utils-CJJIceVn.js";import{t as Me}from"./constants-Bkp4R3bQ.js";import"./config-cCkBQ_ER.js";import{t as Le}from"./jsx-runtime-DN_bIXfG.js";import{t as z}from"./button-DuYGqRtX.js";import{t as le}from"./cn-C1rgT0yh.js";import"./dist-CAcX026F.js";import{n as Pe,__tla as Ee}from"./JsonOutput-CkeISXrs.js";import"./cjs-Bj40p_Np.js";import"./main-CwSdzVhm.js";import"./useNonce-EAuSVK-5.js";import{r as Re}from"./requests-C0HaHO6a.js";import{t as ne}from"./createLucideIcon-CW2xpJ57.js";import{d as De,__tla as He}from"./layout-CprHgyfx.js";import{n as Ve,t as qe,__tla as Ge}from"./LazyAnyLanguageCodeMirror-jpEDlD0M.js";import"./download-DKRxBkYD.js";import"./markdown-renderer-DecoaRsV.js";import{u as Te}from"./toDate-5JckKRQn.js";import{i as Ue,n as $e,r as Be,__tla as Fe}from"./panel-context-Bee798AZ.js";import{t as Je}from"./play-BJDBXApx.js";import{t as Ke}from"./spinner-C1czjtp7.js";import"./dist-HGZzCB0y.js";import"./dist-CVj-_Iiz.js";import"./dist-BVf1IY4_.js";import"./dist-Cq_4nPfh.js";import"./dist-RKnr9SNh.js";import{r as Qe}from"./useTheme-DfP1CWaW.js";import"./Combination-D1TsGrBC.js";import{t as C}from"./tooltip-CvjcEpZC.js";import"./dates-CdsE1R40.js";import"./popover-DtnzNVk-.js";import"./vega-loader.browser-C8wT63Va.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import"./purify.es-N-2faAGj.js";import{__tla as We}from"./chunk-OGVTOU66-CjNLT2C3.js";import"./katex-AwOI3EvM.js";import"./marked.esm-CHnOtnr3.js";import"./es-YVwBDiDw.js";import{o as Xe}from"./focus-D3ygI6Sy.js";import{a as Ye}from"./renderShortcut-D0Pei-OA.js";import"./esm-B3JckBtM.js";import{n as Ze,r as et,t as me}from"./react-resizable-panels.browser.esm-BqxQegSf.js";import"./name-cell-input-BGJDnv5Z.js";import"./Inputs-DmoeP8nh.js";import{__tla as tt}from"./loro_wasm_bg-CghhyG7y.js";import"./ws-itdlXHqs.js";import"./dist-BRZzJw_5.js";import"./dist-P7JHert4.js";import"./dist-CoiWxjLF.js";import"./dist-cVYW_wBR.js";import"./dist-BAmo7Mv9.js";import"./dist-3oAtECdQ.js";import"./dist-D6Pwf0VF.js";import"./dist-D9HMoxdZ.js";import"./dist-JtCdI6tY.js";import"./esm-CCqLcax5.js";import{t as rt}from"./kiosk-mode-CTjr_Jn4.js";let ce,ot=Promise.all([(()=>{try{return Ae}catch{}})(),(()=>{try{return Ee}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return Ge}catch{}})(),(()=>{try{return Fe}catch{}})(),(()=>{try{return We}catch{}})(),(()=>{try{return tt}catch{}})()]).then(async()=>{var de=ne("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),pe=ne("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),he=se(),q=oe(ye(),1),ue=15;const G=Ce("marimo:scratchpadHistory:v1",[],Oe),fe=ae(!1),xe=ae(null,(e,s,i)=>{if(i=i.trim(),!i)return;let n=e(G);s(G,[i,...n.filter(c=>c!==i)].slice(0,ue))});var t=oe(Le(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,he.c)(60),s=Se(),[i]=Ie(),{theme:n}=Qe(),c=(0,q.useRef)(null),T=Xe(),{createNewCell:U,updateCellCode:d}=ze(),{sendRunScratchpad:p}=Re(),S=$e(),$=Be(),l=s.cellRuntime[m],B=l==null?void 0:l.output,O=l==null?void 0:l.status,F=l==null?void 0:l.consoleOutputs,r=((re=s.cellData.__scratch__)==null?void 0:re.code)??"",J=be(xe),[a,h]=we(fe),u=Ne(G),A;e[0]!==J||e[1]!==r||e[2]!==p?(A=()=>{p({code:r}),J(r)},e[0]=J,e[1]=r,e[2]=p,e[3]=A):A=e[3];let f=V(A),I;e[4]!==r||e[5]!==U||e[6]!==T?(I=()=>{r.trim()&&U({code:r,before:!1,cellId:T??"__end__"})},e[4]=r,e[5]=U,e[6]=T,e[7]=I):I=e[7];let K=V(I),M;e[8]!==p||e[9]!==d?(M=()=>{d({cellId:m,code:"",formattingChange:!1}),p({code:""});let o=c.current;o&&o.dispatch({changes:{from:0,to:o.state.doc.length,insert:""}})},e[8]=p,e[9]=d,e[10]=M):M=e[10];let Q=V(M),L;e[11]!==h||e[12]!==d?(L=o=>{h(!1),d({cellId:m,code:o,formattingChange:!1});let k=c.current;k&&k.dispatch({changes:{from:0,to:k.state.doc.length,insert:o}})},e[11]=h,e[12]=d,e[13]=L):L=e[13];let W=V(L),[X,je]=(0,q.useState)(),P;e[14]!==W||e[15]!==u||e[16]!==a||e[17]!==n?(P=()=>a?(0,t.jsx)("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:(0,t.jsx)("div",{className:"overflow-auto flex flex-col gap-3",children:u.map((o,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>W(o),children:(0,t.jsx)(q.Suspense,{children:(0,t.jsx)(qe,{language:"python",theme:n,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:o.trim(),editable:!1,readOnly:!0})})},k))})}):null,e[14]=W,e[15]=u,e[16]=a,e[17]=n,e[18]=P):P=e[18];let Y=P,E;e[19]!==Q||e[20]!==K||e[21]!==f||e[22]!==u.length||e[23]!==a||e[24]!==h||e[25]!==O?(E=()=>(0,t.jsxs)("div",{className:"flex items-center shrink-0 border-b",children:[(0,t.jsx)(C,{content:Ye("cell.run"),children:(0,t.jsx)(z,{"data-testid":"scratchpad-run-button",onClick:f,disabled:a,variant:"text",size:"xs",children:(0,t.jsx)(Je,{color:"var(--grass-11)",size:16})})}),(0,t.jsx)(C,{content:"Clear code and outputs",children:(0,t.jsx)(z,{disabled:a,size:"xs",variant:"text",onClick:Q,children:(0,t.jsx)(de,{size:16})})}),(0,t.jsx)(rt,{children:(0,t.jsx)(C,{content:"Insert code",children:(0,t.jsx)(z,{disabled:a,size:"xs",variant:"text",onClick:K,children:(0,t.jsx)(Ve,{size:16})})})}),(O==="running"||O==="queued")&&(0,t.jsx)(Ke,{className:"inline",size:"small"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(C,{content:"Toggle history",children:(0,t.jsx)(z,{size:"xs",variant:"text",className:le(a&&"bg-(--sky-3) rounded-none"),onClick:()=>h(!a),disabled:u.length===0,children:(0,t.jsx)(pe,{size:16})})}),(0,t.jsx)(C,{content:(0,t.jsx)("span",{className:"block max-w-prose",children:"Use this scratchpad to experiment with code without restrictions on variable names. Variables defined here aren't saved to notebook memory, and the code is not saved in the notebook file."}),children:(0,t.jsx)(z,{size:"xs",variant:"text",children:(0,t.jsx)(Te,{size:16})})})]}),e[19]=Q,e[20]=K,e[21]=f,e[22]=u.length,e[23]=a,e[24]=h,e[25]=O,e[26]=E):E=e[26];let Z=E,ge=S==="vertical",R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=ke.create(m),e[27]=R):R=e[27];let x;e[28]===Z?x=e[29]:(x=Z(),e[28]=Z,e[29]=x);let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=o=>{c.current=o},e[30]=D):D=e[30];let _;e[31]!==r||e[32]!==f||e[33]!==X||e[34]!==n||e[35]!==i?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ue,{theme:n,showPlaceholder:!1,id:m,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:f,userConfig:i,editorViewRef:c,setEditorView:D,hidden:!1,showHiddenCode:ie.NOOP,languageAdapter:X,setLanguageAdapter:je})}),e[31]=r,e[32]=f,e[33]=X,e[34]=n,e[35]=i,e[36]=_):_=e[36];let v;e[37]===Y?v=e[38]:(v=Y(),e[37]=Y,e[38]=v);let j;e[39]!==v||e[40]!==x||e[41]!==_?(j=(0,t.jsx)(me,{defaultSize:40,minSize:20,maxSize:70,children:(0,t.jsxs)("div",{className:"h-full flex flex-col overflow-hidden relative",children:[x,_,v]})}),e[39]=v,e[40]=x,e[41]=_,e[42]=j):j=e[42];let ee=ge?"h-1":"w-1",g;e[43]===ee?g=e[44]:(g=le("bg-border hover:bg-primary/50 transition-colors",ee),e[43]=ee,e[44]=g);let b;e[45]===g?b=e[46]:(b=(0,t.jsx)(et,{className:g}),e[45]=g,e[46]=b);let w;e[47]===B?w=e[48]:(w=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Pe,{allowExpand:!1,output:B,className:Me.outputArea,cellId:m,stale:!1,loading:!1})}),e[47]=B,e[48]=w);let N;e[49]===F?N=e[50]:(N=(0,t.jsx)("div",{className:"overflow-auto shrink-0 max-h-[50%]",children:(0,t.jsx)(De,{consoleOutputs:F,className:"overflow-auto",stale:!1,cellName:"_",onSubmitDebugger:ie.NOOP,cellId:m,debuggerActive:!1})}),e[49]=F,e[50]=N);let y;e[51]!==w||e[52]!==N?(y=(0,t.jsx)(me,{defaultSize:60,minSize:20,children:(0,t.jsxs)("div",{className:"h-full flex flex-col divide-y overflow-hidden",children:[w,N]})}),e[51]=w,e[52]=N,e[53]=y):y=e[53];let H;return e[54]!==S||e[55]!==$||e[56]!==j||e[57]!==b||e[58]!==y?(H=(0,t.jsx)("div",{className:"flex flex-col h-full overflow-hidden",id:R,children:(0,t.jsxs)(Ze,{direction:S,className:"h-full",children:[j,b,y]},$)}),e[54]=S,e[55]=$,e[56]=j,e[57]=b,e[58]=y,e[59]=H):H=e[59],H};let te;te=se(),ce=()=>{let e=(0,te.c)(1),s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(ve,{}),e[0]=s):s=e[0],s}});export{ot as __tla,ce as default};
@@ -1 +0,0 @@
1
- import{s as L}from"./chunk-LvLJmgfZ.js";import{d as ee,p as te,u as q}from"./useEvent-DlWF5OMa.js";import{t as le}from"./react-BGmjiNul.js";import{Hn as re,Jn as se,O as ae,U}from"./cells-rr1jjvJk.js";import"./react-dom-C9fstfnp.js";import{t as ie}from"./compiler-runtime-DeeZ7FnK.js";import"./config-cCkBQ_ER.js";import{t as ne}from"./jsx-runtime-DN_bIXfG.js";import{t as oe}from"./cn-C1rgT0yh.js";import"./dist-CAcX026F.js";import"./cjs-Bj40p_Np.js";import"./main-CwSdzVhm.js";import"./useNonce-EAuSVK-5.js";import{t as de}from"./createLucideIcon-CW2xpJ57.js";import{n as ce,r as A}from"./CellStatus-ClrYbUob.js";import{_ as me}from"./select-D0g5GnIs.js";import{t as pe}from"./chevron-right-CqEd11Di.js";import{t as ue}from"./circle-check-Cr0N4h9T.js";import{t as he}from"./circle-play-r3MHdB-P.js";import"./dist-HGZzCB0y.js";import"./dist-CVj-_Iiz.js";import"./dist-BVf1IY4_.js";import"./dist-Cq_4nPfh.js";import"./dist-RKnr9SNh.js";import{r as fe}from"./useTheme-DfP1CWaW.js";import"./Combination-D1TsGrBC.js";import{t as J}from"./tooltip-CvjcEpZC.js";import"./vega-loader.browser-C8wT63Va.js";import{r as xe,t as ve}from"./react-vega-ENLQ2Qtg.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import{t as ge}from"./cell-link-Hwo1QbqQ.js";import{t as je}from"./bundle.esm-B0Sy2M4C.js";import{n as ye,r as Se,t as V}from"./react-resizable-panels.browser.esm-BqxQegSf.js";import{t as Ie}from"./empty-state-B0XJ9ZUi.js";import"./multi-icon-BOYRpNB_.js";import{t as be}from"./clear-button-BJflRZeI.js";import{n as Ne,t as Te}from"./runs-yuOchwkU.js";var we=de("circle-ellipsis",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]),H=ie(),z=L(le(),1);const Y="hoveredCellId",G="cellHover";var ke="cellNum",K="cell",D="startTimestamp",W="endTimestamp",X="status";function Re(t,e,l,i){let n="hoursminutessecondsmilliseconds";return{$schema:"https://vega.github.io/schema/vega-lite/v6.json",background:i==="dark"?"black":void 0,mark:{type:"bar",cornerRadius:2},params:[{name:Y,bind:{element:`#${e}`}},{name:G,select:{type:"point",on:"mouseover",fields:[K],clear:"mouseout"}}],height:{step:l==="sideBySide"?26:21},encoding:{y:{field:ke,scale:{paddingInner:.2},sort:{field:"sortPriority"},title:"cell",axis:l==="sideBySide"?null:void 0},x:{field:D,type:"temporal",axis:{orient:"top",title:null}},x2:{field:W,type:"temporal"},tooltip:[{field:D,type:"temporal",timeUnit:n,title:"Start"},{field:W,type:"temporal",timeUnit:n,title:"End"}],size:{value:{expr:`${Y} == toString(datum.${K}) ? 19.5 : 18`}},color:{field:X,scale:{domain:["success","error"],range:["#37BE5F","red"]},legend:null}},data:{values:t},transform:[{calculate:`datum.${X} === 'queued' ? 9999999999999 : datum.${D}`,as:"sortPriority"}],config:{view:{stroke:"transparent"}}}}function Z(t){try{let e=new Date(t*1e3);return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}.${String(e.getMilliseconds()).padStart(3,"0")}`}catch{return""}}var r=L(ne(),1),Q=te(new Map);const _e=()=>{let t=(0,H.c)(32),{runIds:e,runMap:l}=q(Te),i=q(Q),{clearRuns:n}=Ne(),{theme:o}=fe(),[a,w]=(0,z.useState)("above"),u;t[0]===a?u=t[1]:(u=()=>{w(a==="above"?"sideBySide":"above")},t[0]=a,t[1]=u);let c=u;if(e.length===0){let s;return t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(Ie,{title:"No traces",description:(0,r.jsx)("span",{children:"Cells that have ran will appear here."}),icon:(0,r.jsx)(se,{})}),t[2]=s):s=t[2],s}let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=(0,r.jsx)("label",{htmlFor:"chartPosition",className:"text-xs",children:"Inline chart"}),t[3]=m):m=t[3];let x=a==="sideBySide",p;t[4]!==x||t[5]!==c?(p=(0,r.jsxs)("div",{className:"flex flex-row gap-1 items-center",children:[m,(0,r.jsx)("input",{type:"checkbox",name:"chartPosition","data-testid":"chartPosition",onClick:c,defaultChecked:x,className:"h-3 cursor-pointer"})]}),t[4]=x,t[5]=c,t[6]=p):p=t[6];let d;t[7]===n?d=t[8]:(d=(0,r.jsx)(be,{dataTestId:"clear-traces-button",onClick:n}),t[7]=n,t[8]=d);let h;t[9]!==p||t[10]!==d?(h=(0,r.jsxs)("div",{className:"flex flex-row justify-start gap-3",children:[p,d]}),t[9]=p,t[10]=d,t[11]=h):h=t[11];let v;if(t[12]!==a||t[13]!==i||t[14]!==e||t[15]!==l||t[16]!==o){let s;t[18]!==a||t[19]!==i||t[20]!==l||t[21]!==o?(s=(N,T)=>{let b=l.get(N);return b?(0,r.jsx)(Me,{run:b,isExpanded:i.get(b.runId),isMostRecentRun:T===0,chartPosition:a,theme:o},b.runId):null},t[18]=a,t[19]=i,t[20]=l,t[21]=o,t[22]=s):s=t[22],v=e.map(s),t[12]=a,t[13]=i,t[14]=e,t[15]=l,t[16]=o,t[17]=v}else v=t[17];let g;t[23]===v?g=t[24]:(g=(0,r.jsx)("div",{className:"flex flex-col gap-3",children:v}),t[23]=v,t[24]=g);let j;t[25]!==h||t[26]!==g?(j=(0,r.jsx)(V,{defaultSize:50,minSize:30,maxSize:80,children:(0,r.jsxs)("div",{className:"py-1 px-2 overflow-y-scroll h-full",children:[h,g]})}),t[25]=h,t[26]=g,t[27]=j):j=t[27];let I;t[28]===Symbol.for("react.memo_cache_sentinel")?(I=(0,r.jsx)(Se,{className:"w-1 bg-border hover:bg-primary/50 transition-colors"}),t[28]=I):I=t[28];let f;t[29]===Symbol.for("react.memo_cache_sentinel")?(f=(0,r.jsx)(V,{defaultSize:50,children:(0,r.jsx)("div",{})}),t[29]=f):f=t[29];let y;return t[30]===j?y=t[31]:(y=(0,r.jsxs)(ye,{direction:"horizontal",className:"h-full",children:[j,I,f]}),t[30]=j,t[31]=y),y};var Me=({run:t,isMostRecentRun:e,chartPosition:l,isExpanded:i,theme:n})=>{let o=ee(Q);i??(i=e);let a=()=>{o(c=>{let m=new Map(c);return m.set(t.runId,!i),m})},w=(0,r.jsx)(i?me:pe,{height:16,className:"inline"}),u=(0,r.jsxs)("span",{className:"text-sm cursor-pointer",onClick:a,children:["Run - ",U(t.runStartTime),w]});return i?(0,r.jsx)($e,{run:t,chartPosition:l,theme:n,title:u},t.runId):(0,r.jsx)("div",{className:"flex flex-col",children:(0,r.jsx)("pre",{className:"font-mono font-semibold",children:u})},t.runId)},$e=t=>{let e=(0,H.c)(40),{run:l,chartPosition:i,theme:n,title:o}=t,[a,w]=(0,z.useState)(),u=(0,z.useRef)(null),{ref:c,width:m}=je(),x=m===void 0?300:m,p=ae(),d,h;if(e[0]!==p||e[1]!==i||e[2]!==l.cellRuns||e[3]!==l.runId||e[4]!==n){let k=[...l.cellRuns.values()].map(S=>{let R=S.elapsedTime??0;return{cell:S.cellId,cellNum:p.inOrderIds.indexOf(S.cellId),startTimestamp:Z(S.startTime),endTimestamp:Z(S.startTime+R),elapsedTime:A(R*1e3),status:S.status}});d=`hiddenInputElement-${l.runId}`,h=xe(Re(k,d,i,n)),e[0]=p,e[1]=i,e[2]=l.cellRuns,e[3]=l.runId,e[4]=n,e[5]=d,e[6]=h}else d=e[5],h=e[6];let v=h.spec,g=n==="dark"?"dark":void 0,j=x-50,I=i==="above"?120:100,f;e[7]!==g||e[8]!==j||e[9]!==I?(f={theme:g,width:j,height:I,actions:!1,mode:"vega",renderer:"canvas"},e[7]=g,e[8]=j,e[9]=I,e[10]=f):f=e[10];let y;e[11]!==f||e[12]!==v?(y={ref:u,spec:v,options:f},e[11]=f,e[12]=v,e[13]=y):y=e[13];let s=ve(y),N;e[14]===(s==null?void 0:s.view)?N=e[15]:(N=()=>{let k=[{signalName:G,handler:(S,R)=>{var F;let C=(F=R.cell)==null?void 0:F[0];w(C??null)}}];return k.forEach(S=>{let{signalName:R,handler:C}=S;s==null||s.view.addSignalListener(R,C)}),()=>{k.forEach(S=>{let{signalName:R,handler:C}=S;s==null||s.view.removeSignalListener(R,C)})}},e[14]=s==null?void 0:s.view,e[15]=N);let T;e[16]===s?T=e[17]:(T=[s],e[16]=s,e[17]=T),(0,z.useEffect)(N,T);let b;e[18]!==d||e[19]!==a||e[20]!==l?(b=(0,r.jsx)(ze,{run:l,hoveredCellId:a,hiddenInputElementId:d}),e[18]=d,e[19]=a,e[20]=l,e[21]=b):b=e[21];let _=b,O=i==="sideBySide"?"-mt-0.5 flex-1":"",E;e[22]===Symbol.for("react.memo_cache_sentinel")?(E=(0,r.jsx)(z.Suspense,{children:(0,r.jsx)("div",{ref:u})}),e[22]=E):E=e[22];let P;e[23]!==c||e[24]!==O?(P=(0,r.jsx)("div",{className:O,ref:c,children:E}),e[23]=c,e[24]=O,e[25]=P):P=e[25];let M=P;if(i==="above"){let k;e[26]!==M||e[27]!==o||e[28]!==_?(k=(0,r.jsxs)("pre",{className:"font-mono font-semibold",children:[o,M,_]}),e[26]=M,e[27]=o,e[28]=_,e[29]=k):k=e[29];let S;return e[30]!==l.runId||e[31]!==k?(S=(0,r.jsx)("div",{className:"flex flex-col",children:k},l.runId),e[30]=l.runId,e[31]=k,e[32]=S):S=e[32],S}let $;e[33]!==o||e[34]!==_?($=(0,r.jsxs)("pre",{className:"font-mono font-semibold",children:[o,_]}),e[33]=o,e[34]=_,e[35]=$):$=e[35];let B;return e[36]!==M||e[37]!==l.runId||e[38]!==$?(B=(0,r.jsxs)("div",{className:"flex flex-row",children:[$,M]},l.runId),e[36]=M,e[37]=l.runId,e[38]=$,e[39]=B):B=e[39],B},ze=t=>{let e=(0,H.c)(12),{run:l,hoveredCellId:i,hiddenInputElementId:n}=t,o=(0,z.useRef)(null),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=d=>{o.current&&(o.current.value=String(d),o.current.dispatchEvent(new Event("input",{bubbles:!0})))},e[0]=a):a=e[0];let w=a,u=i||"",c;e[1]!==n||e[2]!==u?(c=(0,r.jsx)("input",{type:"text",id:n,defaultValue:u,hidden:!0,ref:o}),e[1]=n,e[2]=u,e[3]=c):c=e[3];let m;e[4]===l.cellRuns?m=e[5]:(m=[...l.cellRuns.values()],e[4]=l.cellRuns,e[5]=m);let x;e[6]!==i||e[7]!==m?(x=m.map(d=>(0,r.jsx)(Ee,{cellRun:d,hovered:d.cellId===i,dispatchHoverEvent:w},d.cellId)),e[6]=i,e[7]=m,e[8]=x):x=e[8];let p;return e[9]!==c||e[10]!==x?(p=(0,r.jsxs)("div",{className:"text-xs mt-0.5 ml-3 flex flex-col gap-0.5",children:[c,x]}),e[9]=c,e[10]=x,e[11]=p):p=e[11],p},Ce={success:(0,r.jsx)(ue,{color:"green",size:14}),running:(0,r.jsx)(he,{color:"var(--blue-10)",size:14}),error:(0,r.jsx)(re,{color:"red",size:14}),queued:(0,r.jsx)(we,{color:"grey",size:14})},Ee=t=>{let e=(0,H.c)(39),{cellRun:l,hovered:i,dispatchHoverEvent:n}=t,o;e[0]===l.elapsedTime?o=e[1]:(o=l.elapsedTime?A(l.elapsedTime*1e3):"-",e[0]=l.elapsedTime,e[1]=o);let a=o,w;e[2]!==l.elapsedTime||e[3]!==a?(w=l.elapsedTime?(0,r.jsxs)("span",{children:["This cell took ",(0,r.jsx)(ce,{elapsedTime:a})," to run"]}):(0,r.jsx)("span",{children:"This cell has not been run"}),e[2]=l.elapsedTime,e[3]=a,e[4]=w):w=e[4];let u=w,c;e[5]!==l.cellId||e[6]!==n?(c=()=>{n(l.cellId)},e[5]=l.cellId,e[6]=n,e[7]=c):c=e[7];let m=c,x;e[8]===n?x=e[9]:(x=()=>{n(null)},e[8]=n,e[9]=x);let p=x,d=i&&"bg-(--gray-3) opacity-100",h;e[10]===d?h=e[11]:(h=oe("flex flex-row gap-2 py-1 px-1 opacity-70 hover:bg-(--gray-3) hover:opacity-100",d),e[10]=d,e[11]=h);let v;e[12]===l.startTime?v=e[13]:(v=U(l.startTime),e[12]=l.startTime,e[13]=v);let g;e[14]===v?g=e[15]:(g=(0,r.jsxs)("span",{className:"text-(--gray-10) dark:text-(--gray-11)",children:["[",v,"]"]}),e[14]=v,e[15]=g);let j;e[16]===l.cellId?j=e[17]:(j=(0,r.jsxs)("span",{className:"text-(--gray-10) w-16",children:["(",(0,r.jsx)(ge,{cellId:l.cellId}),")"]}),e[16]=l.cellId,e[17]=j);let I;e[18]===l.code?I=e[19]:(I=(0,r.jsx)("span",{className:"w-40 truncate -ml-1",children:l.code}),e[18]=l.code,e[19]=I);let f;e[20]===a?f=e[21]:(f=(0,r.jsx)("span",{className:"text-(--gray-10) dark:text-(--gray-11)",children:a}),e[20]=a,e[21]=f);let y;e[22]!==u||e[23]!==f?(y=(0,r.jsx)(J,{content:u,children:f}),e[22]=u,e[23]=f,e[24]=y):y=e[24];let s=Ce[l.status],N;e[25]!==l.status||e[26]!==s?(N=(0,r.jsx)(J,{content:l.status,children:s}),e[25]=l.status,e[26]=s,e[27]=N):N=e[27];let T;e[28]!==y||e[29]!==N?(T=(0,r.jsxs)("div",{className:"flex flex-row gap-1 w-16 justify-end -ml-2",children:[y,N]}),e[28]=y,e[29]=N,e[30]=T):T=e[30];let b;return e[31]!==m||e[32]!==p||e[33]!==I||e[34]!==T||e[35]!==h||e[36]!==g||e[37]!==j?(b=(0,r.jsxs)("div",{className:h,onMouseEnter:m,onMouseLeave:p,children:[g,j,I,T]}),e[31]=m,e[32]=p,e[33]=I,e[34]=T,e[35]=h,e[36]=g,e[37]=j,e[38]=b):b=e[38],b};export{_e as Tracing};
@@ -1 +0,0 @@
1
- import{d as I,n as i,p as k}from"./useEvent-DlWF5OMa.js";import{C as w,gn as y,mr as F,p as f,rt as b,vr as x}from"./cells-rr1jjvJk.js";import{t as C}from"./compiler-runtime-DeeZ7FnK.js";import{d as D}from"./hotkeys-uKX61F1_.js";import{o as H}from"./dist-DKNOF5xd.js";import{r as V}from"./requests-C0HaHO6a.js";var u=C();const g=k(!1);function _(){let r=(0,u.c)(2),n=p(),t;return r[0]===n?t=r[1]:(t=()=>n(x(f())),r[0]=n,r[1]=t),i(t)}function j(r){let n=(0,u.c)(3),t=p(),e;return n[0]!==r||n[1]!==t?(e=()=>{r!==void 0&&t([r])},n[0]=r,n[1]=t,n[2]=e):e=n[2],i(e)}function q(){let r=(0,u.c)(2),n=p(),t;return r[0]===n?t=r[1]:(t=()=>n(F(f())),r[0]=n,r[1]=t),i(t)}function p(){let r=(0,u.c)(4),{prepareForRun:n}=w(),{sendRun:t}=V(),e=I(g),o;return r[0]!==n||r[1]!==t||r[2]!==e?(o=async s=>{if(s.length===0)return;let c=f();return e(!0),v({cellIds:s,sendRun:t,prepareForRun:n,notebook:c})},r[0]=n,r[1]=t,r[2]=e,r[3]=o):o=r[3],i(o)}async function v({cellIds:r,sendRun:n,prepareForRun:t,notebook:e}){var m,R,h;if(r.length===0)return;let{cellHandles:o,cellData:s}=e,c=[];for(let a of r){let l=(R=(m=o[a])==null?void 0:m.current)==null?void 0:R.editorView,d;l?(y(l)!=="markdown"&&H(l),d=b(l)):d=((h=s[a])==null?void 0:h.code)||"",c.push(d),t({cellId:a})}await n({cellIds:r,codes:c}).catch(a=>{D.error(a)})}export{p as a,j as i,v as n,_ as o,q as r,g as t};