@marimo-team/frontend 0.22.1-dev40 → 0.22.1-dev43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{JsonOutput-IpD2GLtO.js → JsonOutput-Ctdzcd2D.js} +1 -1
- package/dist/assets/{add-connection-dialog-C42PDYI7.js → add-connection-dialog-CEquGDgf.js} +1 -1
- package/dist/assets/{agent-panel-CH-jHjEl.js → agent-panel-BxXEWtsJ.js} +1 -1
- package/dist/assets/{cell-editor-Dd6UaL1A.js → cell-editor-B8HsInsi.js} +1 -1
- package/dist/assets/{column-preview-ZSErTRFA.js → column-preview-BlmqVfbV.js} +1 -1
- package/dist/assets/{command-palette-CjF_cblG.js → command-palette-GcPDhv4l.js} +1 -1
- package/dist/assets/{edit-page-CMd8_Psc.js → edit-page-DETVkEv4.js} +3 -3
- package/dist/assets/{file-explorer-panel-Dr_ZNDk3.js → file-explorer-panel-Bg6RAr5R.js} +1 -1
- package/dist/assets/{form-3ZUGKch9.js → form-DkNMeOSQ.js} +1 -1
- package/dist/assets/{hooks-CHE17GG1.js → hooks-wt7ylZro.js} +1 -1
- package/dist/assets/{index-Bt8G6SSE.js → index-D0MoPi4a.js} +3 -3
- package/dist/assets/{layout-B-lTkLKA.js → layout-CsKQkdEh.js} +1 -1
- package/dist/assets/{panels-uc8QhzpO.js → panels-D87Ptke4.js} +1 -1
- package/dist/assets/{run-page-DKCqiq_f.js → run-page-D7ezkhN_.js} +1 -1
- package/dist/assets/{scratchpad-panel-ChHLgDv_.js → scratchpad-panel-BELUYBUe.js} +1 -1
- package/dist/assets/{session-panel-CPKKt31q.js → session-panel-BfReO77m.js} +1 -1
- package/dist/assets/{state-C93JW11U.js → state-BpEWsL00.js} +3 -3
- package/dist/assets/{useNotebookActions-DuHUqtII.js → useNotebookActions-B6uSj23Z.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
- package/src/components/data-table/renderers.tsx +18 -12
- package/src/core/dom/uiregistry.ts +42 -8
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}},Se=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}};let Z;J=new Se([
|
|
3
|
-
`)),await this.putControlRequest({type:"execute-cells",...e}),null));n(this,"sendRunScratchpad",async e=>(await this.rpc.proxy.request.loadPackages(e.code),await this.putControlRequest({type:"execute-scratchpad",...e}),null));n(this,"sendInterrupt",async()=>(this.interruptBuffer!==void 0&&(this.interruptBuffer[0]=2),null));n(this,"sendShutdown",async()=>(window.close(),null));n(this,"sendFormat",async e=>await this.rpc.proxy.request.bridge({functionName:"format",payload:e}));n(this,"sendDeleteCell",async e=>(await this.putControlRequest({type:"delete-cell",...e}),null));n(this,"sendInstallMissingPackages",async e=>(this.putControlRequest({type:"install-packages",...e}),null));n(this,"sendCodeCompletionRequest",async e=>(Q.get(Jt)||await this.rpc.proxy.request.bridge({functionName:"code_complete",payload:e}),null));n(this,"saveUserConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_user_config",payload:e}),ar.post("/kernel/save_user_config",e,{baseUrl:"/"}).catch(r=>(p.error(r),null))));n(this,"saveAppConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_app_config",payload:e}),null));n(this,"saveCellConfig",async e=>(await this.putControlRequest({type:"update-cell-config",...e}),null));n(this,"sendRestart",async()=>{let e=await this.readCode();return e.contents&&(J.saveFile(e.contents),Z.saveFile(e.contents)),mr(),null});n(this,"readCode",async()=>this.saveRpc?{contents:await this.saveRpc.readNotebook()}:(p.warn("Save RPC not initialized"),{contents:""}));n(this,"readSnippets",async()=>await this.rpc.proxy.request.bridge({functionName:"read_snippets",payload:void 0}));n(this,"openFile",async({path:e})=>{let r=gr({code:null,baseUrl:window.location.origin});return window.open(r,"_blank"),null});n(this,"sendListFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"list_files",payload:e}));n(this,"sendSearchFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"search_files",payload:e}));n(this,"sendComponentValues",async e=>(await this.putControlRequest({type:"update-ui-element",...e,token:Ye()}),null));n(this,"sendInstantiate",async e=>null);n(this,"sendFunctionRequest",async e=>(await this.putControlRequest({type:"invoke-function",...e}),null));n(this,"sendCreateFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"create_file_or_directory",payload:e}));n(this,"sendDeleteFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"delete_file_or_directory",payload:e}));n(this,"sendRenameFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"move_file_or_directory",payload:e}));n(this,"sendUpdateFile",async e=>await this.rpc.proxy.request.bridge({functionName:"update_file",payload:e}));n(this,"sendFileDetails",async e=>await this.rpc.proxy.request.bridge({functionName:"file_details",payload:e}));n(this,"exportAsHTML",async e=>await this.rpc.proxy.request.bridge({functionName:"export_html",payload:e}));n(this,"exportAsMarkdown",async e=>await this.rpc.proxy.request.bridge({functionName:"export_markdown",payload:e}));n(this,"previewDatasetColumn",async e=>(await this.putControlRequest({type:"preview-dataset-column",...e}),null));n(this,"previewSQLTable",async e=>(await this.putControlRequest({type:"preview-sql-table",...e}),null));n(this,"previewSQLTableList",async e=>(await this.putControlRequest({type:"list-sql-tables",...e}),null));n(this,"previewSQLSchemaList",async e=>(await this.putControlRequest({type:"list-sql-schemas",...e}),null));n(this,"previewDataSourceConnection",async e=>(await this.putControlRequest({type:"list-data-source-connection",...e}),null));n(this,"validateSQL",async e=>(await this.putControlRequest({type:"validate-sql",...e}),null));n(this,"sendModelValue",async e=>(await this.putControlRequest({type:"model",...e}),null));n(this,"sendDocumentTransaction",()=>Promise.resolve(null));n(this,"addPackage",async e=>this.rpc.proxy.request.addPackage(e));n(this,"removePackage",async e=>this.rpc.proxy.request.removePackage(e));n(this,"getPackageList",async()=>await this.rpc.proxy.request.listPackages());n(this,"getDependencyTree",async()=>({tree:{dependencies:[],name:"",tags:[],version:null}}));n(this,"listSecretKeys",async e=>(await this.putControlRequest({type:"list-secret-keys",...e}),null));n(this,"getUsageStats",g);n(this,"openTutorial",g);n(this,"getRecentFiles",g);n(this,"getWorkspaceFiles",g);n(this,"getRunningNotebooks",g);n(this,"shutdownSession",g);n(this,"exportAsIPYNB",g);n(this,"exportAsPDF",g);n(this,"autoExportAsHTML",g);n(this,"autoExportAsMarkdown",g);n(this,"autoExportAsIPYNB",g);n(this,"updateCellOutputs",g);n(this,"writeSecret",g);n(this,"invokeAiTool",g);n(this,"clearCache",g);n(this,"getCacheInfo",g);n(this,"listStorageEntries",g);n(this,"downloadStorage",g);sr()&&(this.rpc=Ce(new Worker(new URL(""+new URL("worker-BPV9SmHz.js",import.meta.url).href,""+import.meta.url),{type:"module",name:Oe()})),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(fe,e)}),this.rpc.addMessageListener("initializedError",({error:e})=>{this.initialized.status==="resolved"&&(p.error(e),fr({title:"Error initializing",description:e,variant:"danger"})),this.initialized.reject(Error(e))}),this.rpc.addMessageListener("kernelMessage",({message:e})=>{var r;(r=this.messageConsumer)==null||r.call(this,new MessageEvent("message",{data:e}))}))}static get INSTANCE(){let e="_marimo_private_PyodideBridge";return window[e]||(window[e]=new ut),window[e]}getSaveWorker(){return He()==="read"?(p.debug("Skipping SaveWorker in read-mode"),{readFile:g,readNotebook:g,saveNotebook:g}):Ce(new Worker(new URL(""+new URL("save-worker-CtJsIYIM.js",import.meta.url).href,""+import.meta.url),{type:"module",name:Oe()})).proxy.request}async startSession(){let e=await J.readFile(),r=await Z.readFile(),s=Q.get(Qt)??Y.getFilename(),a=Q.get(rr),i={},u=new URLSearchParams(window.location.search);for(let d of u.keys()){let v=u.getAll(d);i[d]=v.length===1?v[0]:v}await this.rpc.proxy.request.startSession({queryParameters:i,code:e||r||"",filename:s,userConfig:{...a,runtime:{...a.runtime,auto_instantiate:He()==="read"?!0:a.runtime.auto_instantiate}}})}setInterruptBuffer(){crossOriginIsolated?(this.interruptBuffer=new Uint8Array(new SharedArrayBuffer(1)),this.rpc.proxy.request.setInterruptBuffer(this.interruptBuffer)):p.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})}},tt=function(){return ye.withProducerCallback(t=>{ge.INSTANCE.attachMessageConsumer(t)})},Ke=function(t=ce()){let e=window.fetch;return window.fetch=async(r,s)=>{let a=r instanceof Request?r.url:r.toString();if(a.startsWith("data:"))return e(r,s);try{let i=X(a,t);if(i){let u=await(await e(i)).arrayBuffer();return new Response(u,{headers:{"Content-Type":Et(a)}})}return e(r,s)}catch(i){return p.error("Error parsing URL",i),e(r,s)}},()=>{window.fetch=e}};function Et(t){return t.endsWith(".csv")?"text/csv":t.endsWith(".json")?"application/json":t.endsWith(".txt")?"text/plain":"application/octet-stream"}Ze=function(t,e=ce()){let r=t.http.bind(t),s=t.load.bind(t);return t.http=async a=>{let i=X(a,e);if(i)return await window.fetch(i).then(u=>u.text());try{return await r(a)}catch(u){if(a.startsWith("data:"))return await window.fetch(a).then(d=>d.text());throw u}},t.load=async a=>{let i=X(a,e);if(i)return await window.fetch(i).then(u=>u.text());try{return await s(a)}catch(u){if(a.startsWith("data:"))return await window.fetch(a).then(d=>d.text());throw u}},()=>{t.http=r,t.load=s}};function Ee(t){return t.startsWith(".")?t.slice(1):t}function kt(t,e=ce()){let r=X(t,e);if(!r)return t;let s=yr(r);return URL.createObjectURL(s)}function X(t,e){let r=document.baseURI;r.startsWith("blob:")&&(r=r.replace("blob:",""));let s=new URL(t,r).pathname,a=ke(t),i=ke(s);return e[t]||e[Ee(t)]||e[s]||e[Ee(s)]||a&&e[a]||i&&e[i]}function ke(t){let e=t.indexOf("/@file/");return e===-1?null:t.slice(e)}function ie(t,e=[]){let r=[];if(t instanceof DataView)r.push(e);else if(Array.isArray(t))for(let[s,a]of t.entries())r.push(...ie(a,[...e,s]));else if(typeof t=="object"&&t)for(let[s,a]of Object.entries(t))r.push(...ie(a,[...e,s]));return r}function Mt(t){let e=ie(t);if(e.length===0)return{state:t,buffers:[],bufferPaths:[]};let r=structuredClone(t),s=[],a=[];for(let i of e){let u=Zt(t,i);if(u instanceof DataView){let d=ze(u);s.push(d),a.push(i),G(r,i,d)}}return{state:r,buffers:s,bufferPaths:a}}function Me(t){let{state:e,bufferPaths:r,buffers:s}=t;if(!r||r.length===0)return e;s&&tr(s.length===r.length,"Buffers and buffer paths not the same length");let a=e;for(let[i,u]of r.entries()){let d=s==null?void 0:s[i];if(d==null){p.warn("[anywidget] Could not find buffer at path",u);continue}typeof d=="string"?G(a,u,Ve(d)):G(a,u,d)}return a}const Pe={invoke:async()=>{let t="anywidget.invoke not supported in marimo. Please file an issue at https://github.com/marimo-team/marimo/issues";throw p.warn(t),Error(t)}};function Pt(t){if(typeof AbortSignal.any=="function")return AbortSignal.any(t);let e=new AbortController;for(let r of t){if(r.aborted)return e.abort(r.reason),e.signal;r.addEventListener("abort",()=>e.abort(r.reason),{once:!0})}return e.signal}var Ft=(Ie=class{constructor(){_(this,ee);_(this,U,new Map)}getModule(t,e){let r=o(this,U).get(e);if(r)return r;let s=A(this,ee,dt).call(this,t).catch(a=>{throw o(this,U).delete(e),a});return o(this,U).set(e,s),s}invalidate(t){p.debug(`[WidgetDefRegistry] Invalidating module cache for hash=${t}`),o(this,U).delete(t)}},U=new WeakMap,ee=new WeakSet,dt=async function(t){let e=nr(t).toString();return $e()&&(e=kt(e)),pr(()=>import(e).then(async r=>(await r.__tla,r)),[],import.meta.url)},Ie),It=(Le=class{constructor(){_(this,M);_(this,T);_(this,E)}async bind(t,e){var i,u;if(o(this,E)&&o(this,T)===t)return o(this,E);o(this,E)&&o(this,T)!==t&&(p.debug("[WidgetBinding] Hot-reload detected, aborting previous binding"),(i=o(this,M))==null||i.abort(),C(this,M,void 0),C(this,E,void 0)),C(this,T,t),C(this,M,new AbortController);let r=o(this,M).signal,s=typeof t=="function"?await t():t,a=await((u=s.initialize)==null?void 0:u.call(s,{model:e,experimental:Pe}));return a&&r.addEventListener("abort",a),C(this,E,async(d,v)=>{var x;let q=await((x=s.render)==null?void 0:x.call(s,{model:e,el:d,experimental:Pe}));q&&Pt([v,r]).addEventListener("abort",()=>{let S=v.aborted?"view unmount":"binding destroyed";p.debug(`[WidgetBinding] Render cleanup triggered (reason: ${S})`),q()})}),o(this,E)}destroy(){var t;p.debug("[WidgetBinding] Destroying binding, aborting initialize lifecycle"),(t=o(this,M))==null||t.abort(),C(this,M,void 0),C(this,T,void 0),C(this,E,void 0)}},M=new WeakMap,T=new WeakMap,E=new WeakMap,Le),Lt=(Ne=class{constructor(){_(this,F,new Map)}getOrCreate(t){let e=o(this,F).get(t);return e||(e=new It,o(this,F).set(t,e)),e}destroy(t){let e=o(this,F).get(t);e&&(p.debug(`[BindingManager] Destroying binding for model=${t}`),e.destroy(),o(this,F).delete(t))}has(t){return o(this,F).has(t)}},F=new WeakMap,Ne);it=new Ft,me=new Lt;var Nt=(Ae=class{constructor(t=1e4){_(this,D);_(this,P,new Map);_(this,V);C(this,V,t)}get(t){let e=A(this,D,ae).call(this,t);return e.deferred.status==="pending"&&setTimeout(()=>{e.deferred.status==="pending"&&(e.deferred.reject(Error(`Model not found for key: ${t}`)),o(this,P).delete(t))},o(this,V)),e.deferred.promise}create(t,e){let r=A(this,D,ae).call(this,t);r.deferred.resolve(e(r.controller.signal))}set(t,e){A(this,D,ae).call(this,t).deferred.resolve(e)}getSync(t){let e=o(this,P).get(t);if(e&&e.deferred.status==="resolved")return e.deferred.value}delete(t){var e;p.debug(`[ModelManager] Deleting model=${t}, aborting lifecycle signal`),(e=o(this,P).get(t))==null||e.controller.abort(),o(this,P).delete(t)}},P=new WeakMap,V=new WeakMap,D=new WeakSet,ae=function(t){let e=o(this,P).get(t);return e||(e={deferred:new Qe,controller:new AbortController},o(this,P).set(t,e)),e},Ae),Fe=Symbol("marimo");function oe(t){return t[Fe]}ne=new Nt;var At=(Ue=Fe,B=class{constructor(e,r,s){_(this,N);_(this,te,"change");_(this,I);_(this,L);_(this,H);_(this,R,{});n(this,Ue,{updateAndEmitDiffs:e=>A(this,N,pt).call(this,e),emitCustomMessage:(e,r)=>A(this,N,ft).call(this,e,r)});n(this,"widget_manager",{async get_model(e){let r=await B._modelManager.get(e);if(!r)throw Error(`Model not found with id: ${e}. This is likely because the model was not registered.`);return r}});_(this,re,Xt(()=>{let e=o(this,R)[o(this,te)];if(e)for(let r of e)try{r()}catch(s){p.error("Error emitting event",s)}},0));C(this,L,e),C(this,H,r),C(this,I,new Map),s&&s.addEventListener("abort",()=>{p.debug("[Model] Signal aborted, clearing all listeners"),C(this,R,{})})}off(e,r){var s;if(!e){C(this,R,{});return}if(!r){o(this,R)[e]=new Set;return}(s=o(this,R)[e])==null||s.delete(r)}send(e,r,s){let a=(s??[]).map(i=>i instanceof ArrayBuffer?new DataView(i):new DataView(i.buffer,i.byteOffset,i.byteLength));return o(this,H).sendCustomMessage(e,a).then(()=>r==null?void 0:r())}get(e){return o(this,L)[e]}set(e,r){C(this,L,{...o(this,L),[e]:r}),o(this,I).set(e,r),A(this,N,ct).call(this,`change:${e}`,r),o(this,re).call(this)}save_changes(){if(o(this,I).size===0)return;let e=Object.fromEntries(o(this,I).entries());o(this,I).clear(),o(this,H).sendUpdate(e)}on(e,r){o(this,R)[e]||(o(this,R)[e]=new Set),o(this,R)[e].add(r)}},te=new WeakMap,I=new WeakMap,L=new WeakMap,H=new WeakMap,R=new WeakMap,N=new WeakSet,ct=function(e,r){if(!o(this,R)[e])return;let s=o(this,R)[e];for(let a of s)try{a(r)}catch(i){p.error("Error emitting event",i)}},pt=function(e){e!=null&&Object.keys(e).forEach(r=>{let s=r;o(this,L)[s]!==e[s]&&this.set(s,e[s])})},ft=function(e,r=[]){let s=o(this,R)["msg:custom"];if(s)for(let a of s)try{a(e.content,r)}catch(i){p.error("Error emitting event",i)}},re=new WeakMap,n(B,"_modelManager",ne),B);Je=async function(t,e){let r=e.model_id,s=e.message,a=("buffers"in s?s.buffers:[]).map(Ve);switch(s.method){case"open":{let{state:i,buffer_paths:u=[]}=s,d=Me({state:i,bufferPaths:u,buffers:a}),v=t.getSync(r);if(v){oe(v).updateAndEmitDiffs(d);return}t.create(r,q=>new At(d,$e()?{sendUpdate:async()=>{},sendCustomMessage:async()=>{}}:{async sendUpdate(x){if(q.aborted){p.debug(`[Model] sendUpdate suppressed for model=${r} (signal aborted)`);return}let{state:S,buffers:O,bufferPaths:se}=Mt(x);await pe().sendModelValue({modelId:r,message:{method:"update",state:S,bufferPaths:se},buffers:O})},async sendCustomMessage(x,S){if(q.aborted){p.debug(`[Model] sendCustomMessage suppressed for model=${r} (signal aborted)`);return}await pe().sendModelValue({modelId:r,message:{method:"custom",content:x},buffers:S.map(ze)})}},q));return}case"custom":oe(await t.get(r)).emitCustomMessage({method:"custom",content:s.content},a);return;case"close":me.destroy(r),t.delete(r);return;case"update":{let{state:i,buffer_paths:u=[]}=s,d=Me({state:i,bufferPaths:u,buffers:a});oe(await t.get(r)).updateAndEmitDiffs(d);return}default:lr(s)}},Ot(ne,"MODEL_MANAGER"),he=class ht{static get INSTANCE(){let e="_marimo_private_UIElementRegistry";return window[e]||(window[e]=new ht),window[e]}constructor(){this.entries=new Map}has(e){return this.entries.has(e)}set(e,r){this.entries.has(e)&&p.debug("UIElementRegistry overwriting entry for objectId.",e),this.entries.set(e,{objectId:e,value:r,elements:new Set})}registerInstance(e,r){let s=this.entries.get(e);s===void 0?this.entries.set(e,{objectId:e,value:Yt(r,this),elements:new Set([r])}):s.elements.add(r)}removeInstance(e,r){let s=this.entries.get(e);s!=null&&s.elements.has(r)&&s.elements.delete(r)}removeElementsByCell(e){[...this.entries.keys()].filter(r=>r.startsWith(`${e}-`)).forEach(r=>{this.entries.delete(r)})}lookupValue(e){let r=this.entries.get(e);return r===void 0?void 0:r.value}broadcastMessage(e,r,s){let a=this.entries.get(e);a===void 0?p.warn("UIElementRegistry missing entry",e):a.elements.forEach(i=>{i.dispatchEvent(vr.create({bubbles:!1,composed:!0,detail:{objectId:e,message:r,buffers:s}}))})}broadcastValueUpdate(e,r,s){let a=this.entries.get(r);a===void 0?p.warn("UIElementRegistry missing entry",r):(a.value=s,a.elements.forEach(i=>{i!==e&&i.dispatchEvent(wr.create({bubbles:!1,composed:!0,detail:{value:s,element:i}}))}),document.dispatchEvent(br.create({bubbles:!0,composed:!0,detail:{objectId:r}})))}},st=he.INSTANCE,et=new cr("function-call-result",async(t,e)=>{await pe().sendFunctionRequest({functionCallId:t,...e})}),at="68px";var Ut="288px";rt=t=>t?/^\d+$/.test(t)?`${t}px`:t:Ut,nt=zt({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}})});export{G as S,fe as _,_r as __tla,he as a,Ge as b,Je as c,Ke as d,Ze as f,Xe as g,J as h,et as i,me as l,tt as m,rt as n,st as o,ge as p,nt as r,ne as s,at as t,it as u,ye as v,ot as x,lt as y};
|
|
1
|
+
var Ht=Object.defineProperty;var De=f=>{throw TypeError(f)};var Ot=(f,h,y)=>h in f?Ht(f,h,{enumerable:!0,configurable:!0,writable:!0,value:y}):f[h]=y;var n=(f,h,y)=>Ot(f,typeof h!="symbol"?h+"":h,y),ue=(f,h,y)=>h.has(f)||De("Cannot "+y);var o=(f,h,y)=>(ue(f,h,"read from private field"),y?y.call(f):h.get(f)),_=(f,h,y)=>h.has(f)?De("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(f):h.set(f,y),C=(f,h,y,z)=>(ue(f,h,"write to private field"),z?z.call(f,y):h.set(f,y),y),A=(f,h,y)=>(ue(f,h,"access private method"),y);import{i as Q,p as de,u as $t}from"./useEvent-D91BmmQi.js";import{Cn as zt,Z as He,b as Vt,ci as Qt,ii as Yt,mi as Y,oi as Gt,pi as Jt,ti as Kt,x as Zt,__tla as Xt}from"./cells-CcsG9Aum.js";import{t as er}from"./get-D7jeR2wg.js";import{t as tr}from"./debounce-BbSyBDA8.js";import{t as rr}from"./_baseSet-49dbm-yb.js";import{_ as p,y as g}from"./useEventListener-DGjKht0c.js";import{t as sr}from"./invariant-CkiqGLcK.js";import{S as nr}from"./utils-DKaC_ndw.js";import{S as ar,n as ir}from"./config-CmaJdl9U.js";import{n as or}from"./switch-DqrqDBdD.js";import{n as Oe}from"./globals-DK8gKReW.js";import{at as ce,ot as $e,__tla as lr}from"./JsonOutput-Ctdzcd2D.js";import{t as ur}from"./createReducer-CYlwteGD.js";import{r as dr}from"./strings-pfr2N700.js";import{t as pe}from"./requests-9-v2bhoi.js";import{a as ze,l as cr,r as Ve,__tla as pr}from"./markdown-renderer-B91NzmVT.js";import{t as fr}from"./DeferredRequestRegistry-KOgQgaJP.js";import{t as hr}from"./preload-helper-DItdS47A.js";import{t as Qe}from"./Deferred-DMWKlZOV.js";import{t as Ye}from"./uuid-DercMavo.js";import{t as mr}from"./use-toast-T0_cQDma.js";import{n as gr,r as yr,t as wr}from"./share-DkQqqFqC.js";import{t as br}from"./blob-CpeNXBj-.js";import{i as Ge,r as vr,t as _r}from"./events-BRAWQiYK.js";let G,fe,he,Je,Ke,Ze,Xe,et,J,tt,me,rt,st,nt,ge,at,ne,it,ot,ye,lt,ut,Cr=Promise.all([(()=>{try{return Xt}catch{}})(),(()=>{try{return lr}catch{}})(),(()=>{try{return pr}catch{}})()]).then(async()=>{var U,ee,ct,Ie,M,T,E,Le,F,Ne,P,V,D,ae,Ae,Ue,te,I,L,H,R,j,N,pt,ft,ht,re;function f(t,e,r){return t==null?t:rr(t,e,r)}G=f,ut=de(null);var{valueAtom:h,useActions:y}=ur(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:Ye()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(r=>r.id!==e)}),clearBanners:t=>({...t,banners:[]})});Je=()=>$t(h),lt=function(){return y()};let z,be,ve;z=class{constructor(){n(this,"subscriptions",new Map)}addSubscription(t,e){var r;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(r=this.subscriptions.get(t))==null||r.add(e)}removeSubscription(t,e){var r;(r=this.subscriptions.get(t))==null||r.delete(e)}notify(t,e){for(let r of this.subscriptions.get(t)??[])r(e)}},ye=class we{constructor(e){n(this,"subscriptions",new z);this.producer=e}static withProducerCallback(e){return new we(e)}static empty(){return new we}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,r){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,r){this.subscriptions.addSubscription(e,r),e==="open"&&r(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,r){this.subscriptions.removeSubscription(e,r)}},be=1e10,ve=1e3;function K(t,e){let r=t.map(s=>`"${s}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${r}`)}function gt(t={}){let e={};function r(l){e=l}let s={};function a(l){var c;s.unregisterHandler&&s.unregisterHandler(),s=l,(c=s.registerHandler)==null||c.call(s,Dt)}let i;function u(l){if(typeof l=="function"){i=l;return}i=(c,w)=>{let m=l[c];if(m)return m(w);let b=l._;if(!b)throw Error(`The requested method has no handler: ${c}`);return b(c,w)}}let{maxRequestTime:d=ve}=t;t.transport&&a(t.transport),t.requestHandler&&u(t.requestHandler),t._debugHooks&&r(t._debugHooks);let v=0;function q(){return v<=be?++v:v=0}let x=new Map,S=new Map;function O(l,...c){let w=c[0];return new Promise((m,b)=>{var $;if(!s.send)throw K(["send"],"make requests");let k=q(),W={type:"request",id:k,method:l,params:w};x.set(k,{resolve:m,reject:b}),d!==1/0&&S.set(k,setTimeout(()=>{S.delete(k),b(Error("RPC request timed out."))},d)),($=e.onSend)==null||$.call(e,W),s.send(W)})}let se=new Proxy(O,{get:(l,c,w)=>c in l?Reflect.get(l,c,w):m=>O(c,m)}),Te=se;function je(l,...c){var b;let w=c[0];if(!s.send)throw K(["send"],"send messages");let m={type:"message",id:l,payload:w};(b=e.onSend)==null||b.call(e,m),s.send(m)}let Be=new Proxy(je,{get:(l,c,w)=>c in l?Reflect.get(l,c,w):m=>je(c,m)}),We=Be,B=new Map,le=new Set;function Bt(l,c){var w;if(!s.registerHandler)throw K(["registerHandler"],"register message listeners");if(l==="*"){le.add(c);return}B.has(l)||B.set(l,new Set),(w=B.get(l))==null||w.add(c)}function Wt(l,c){var w,m;if(l==="*"){le.delete(c);return}(w=B.get(l))==null||w.delete(c),((m=B.get(l))==null?void 0:m.size)===0&&B.delete(l)}async function Dt(l){var c,w;if((c=e.onReceive)==null||c.call(e,l),!("type"in l))throw Error("Message does not contain a type.");if(l.type==="request"){if(!s.send||!i)throw K(["send","requestHandler"],"handle requests");let{id:m,method:b,params:k}=l,W;try{W={type:"response",id:m,success:!0,payload:await i(b,k)}}catch($){if(!($ instanceof Error))throw $;W={type:"response",id:m,success:!1,error:$.message}}(w=e.onSend)==null||w.call(e,W),s.send(W);return}if(l.type==="response"){let m=S.get(l.id);m!=null&&clearTimeout(m);let{resolve:b,reject:k}=x.get(l.id)??{};l.success?b==null||b(l.payload):k==null||k(Error(l.error));return}if(l.type==="message"){for(let b of le)b(l.id,l.payload);let m=B.get(l.id);if(!m)return;for(let b of m)b(l.payload);return}throw Error(`Unexpected RPC message type: ${l.type}`)}return{setTransport:a,setRequestHandler:u,request:se,requestProxy:Te,send:Be,sendProxy:We,addMessageListener:Bt,removeMessageListener:Wt,proxy:{send:We,request:Te},_setDebugHooks:r}}function yt(t){return gt(t)}var _e="[transport-id]";function wt(t,e){let{transportId:r}=e;return r==null?t:{[_e]:r,data:t}}function bt(t,e){let{transportId:r,filter:s}=e,a=s==null?void 0:s();if(r!=null&&a!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(r){if(t[_e]!==r)return[!0];i=t.data}return a===!1?[!0]:[!1,i]}function vt(t,e={}){let{transportId:r,filter:s,remotePort:a}=e,i=t,u=a??t,d;return{send(v){u.postMessage(wt(v,{transportId:r}))},registerHandler(v){d=q=>{let x=q.data,[S,O]=bt(x,{transportId:r,filter:()=>s==null?void 0:s(q)});S||v(O)},i.addEventListener("message",d)},unregisterHandler(){d&&i.removeEventListener("message",d)}}}function _t(t,e){return vt(t,e)}function Ce(t){return yt({transport:_t(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{p.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{p.debug("[rpc] Worker -> Parent",e)}}})}fe=de("Initializing..."),et=de(t=>{let e=t(Vt),r=Object.values(e.cellRuntime);return r.some(s=>!cr(s.output))?!0:r.every(s=>s.status==="idle")});var Re=gr(),qe="marimo:file",xe=new Kt(null);const Ct={saveFile(t){xe.set(qe,t)},readFile(){return xe.get(qe)}};var Rt={saveFile(t){Y.setCodeForHash((0,Re.compressToEncodedURIComponent)(t))},readFile(){let t=Y.getCodeFromHash()||Y.getCodeFromSearchParam();return t?(0,Re.decompressFromEncodedURIComponent)(t):null}};const qt={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var xt={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)}};const St={saveFile(t){},readFile(){return Q.get(Yt)??null}};var Et={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
|
|
2
|
+
`)}},Se=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}};let Z;J=new Se([St,qt,Rt]),Z=new Se([Ct,xt,Et]),ge=class dt{constructor(){n(this,"initialized",new Qe);n(this,"sendRename",async({filename:e})=>(e===null||(Y.setFilename(e),await this.rpc.proxy.request.bridge({functionName:"rename_file",payload:e})),null));n(this,"sendSave",async e=>{if(!this.saveRpc)return p.warn("Save RPC not initialized"),null;await this.saveRpc.saveNotebook(e);let r=await this.readCode();return r.contents&&(J.saveFile(r.contents),Z.saveFile(r.contents)),this.rpc.proxy.request.saveNotebook(e).catch(s=>{p.error(s)}),null});n(this,"sendCopy",async()=>{g()});n(this,"sendStdin",async e=>(await this.rpc.proxy.request.bridge({functionName:"put_input",payload:e.text}),null));n(this,"sendPdb",async()=>{g()});n(this,"sendRun",async e=>(await this.rpc.proxy.request.loadPackages(e.codes.join(`
|
|
3
|
+
`)),await this.putControlRequest({type:"execute-cells",...e}),null));n(this,"sendRunScratchpad",async e=>(await this.rpc.proxy.request.loadPackages(e.code),await this.putControlRequest({type:"execute-scratchpad",...e}),null));n(this,"sendInterrupt",async()=>(this.interruptBuffer!==void 0&&(this.interruptBuffer[0]=2),null));n(this,"sendShutdown",async()=>(window.close(),null));n(this,"sendFormat",async e=>await this.rpc.proxy.request.bridge({functionName:"format",payload:e}));n(this,"sendDeleteCell",async e=>(await this.putControlRequest({type:"delete-cell",...e}),null));n(this,"sendInstallMissingPackages",async e=>(this.putControlRequest({type:"install-packages",...e}),null));n(this,"sendCodeCompletionRequest",async e=>(Q.get(Zt)||await this.rpc.proxy.request.bridge({functionName:"code_complete",payload:e}),null));n(this,"saveUserConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_user_config",payload:e}),or.post("/kernel/save_user_config",e,{baseUrl:"/"}).catch(r=>(p.error(r),null))));n(this,"saveAppConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_app_config",payload:e}),null));n(this,"saveCellConfig",async e=>(await this.putControlRequest({type:"update-cell-config",...e}),null));n(this,"sendRestart",async()=>{let e=await this.readCode();return e.contents&&(J.saveFile(e.contents),Z.saveFile(e.contents)),yr(),null});n(this,"readCode",async()=>this.saveRpc?{contents:await this.saveRpc.readNotebook()}:(p.warn("Save RPC not initialized"),{contents:""}));n(this,"readSnippets",async()=>await this.rpc.proxy.request.bridge({functionName:"read_snippets",payload:void 0}));n(this,"openFile",async({path:e})=>{let r=wr({code:null,baseUrl:window.location.origin});return window.open(r,"_blank"),null});n(this,"sendListFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"list_files",payload:e}));n(this,"sendSearchFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"search_files",payload:e}));n(this,"sendComponentValues",async e=>(await this.putControlRequest({type:"update-ui-element",...e,token:Ye()}),null));n(this,"sendInstantiate",async e=>null);n(this,"sendFunctionRequest",async e=>(await this.putControlRequest({type:"invoke-function",...e}),null));n(this,"sendCreateFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"create_file_or_directory",payload:e}));n(this,"sendDeleteFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"delete_file_or_directory",payload:e}));n(this,"sendRenameFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"move_file_or_directory",payload:e}));n(this,"sendUpdateFile",async e=>await this.rpc.proxy.request.bridge({functionName:"update_file",payload:e}));n(this,"sendFileDetails",async e=>await this.rpc.proxy.request.bridge({functionName:"file_details",payload:e}));n(this,"exportAsHTML",async e=>await this.rpc.proxy.request.bridge({functionName:"export_html",payload:e}));n(this,"exportAsMarkdown",async e=>await this.rpc.proxy.request.bridge({functionName:"export_markdown",payload:e}));n(this,"previewDatasetColumn",async e=>(await this.putControlRequest({type:"preview-dataset-column",...e}),null));n(this,"previewSQLTable",async e=>(await this.putControlRequest({type:"preview-sql-table",...e}),null));n(this,"previewSQLTableList",async e=>(await this.putControlRequest({type:"list-sql-tables",...e}),null));n(this,"previewSQLSchemaList",async e=>(await this.putControlRequest({type:"list-sql-schemas",...e}),null));n(this,"previewDataSourceConnection",async e=>(await this.putControlRequest({type:"list-data-source-connection",...e}),null));n(this,"validateSQL",async e=>(await this.putControlRequest({type:"validate-sql",...e}),null));n(this,"sendModelValue",async e=>(await this.putControlRequest({type:"model",...e}),null));n(this,"sendDocumentTransaction",()=>Promise.resolve(null));n(this,"addPackage",async e=>this.rpc.proxy.request.addPackage(e));n(this,"removePackage",async e=>this.rpc.proxy.request.removePackage(e));n(this,"getPackageList",async()=>await this.rpc.proxy.request.listPackages());n(this,"getDependencyTree",async()=>({tree:{dependencies:[],name:"",tags:[],version:null}}));n(this,"listSecretKeys",async e=>(await this.putControlRequest({type:"list-secret-keys",...e}),null));n(this,"getUsageStats",g);n(this,"openTutorial",g);n(this,"getRecentFiles",g);n(this,"getWorkspaceFiles",g);n(this,"getRunningNotebooks",g);n(this,"shutdownSession",g);n(this,"exportAsIPYNB",g);n(this,"exportAsPDF",g);n(this,"autoExportAsHTML",g);n(this,"autoExportAsMarkdown",g);n(this,"autoExportAsIPYNB",g);n(this,"updateCellOutputs",g);n(this,"writeSecret",g);n(this,"invokeAiTool",g);n(this,"clearCache",g);n(this,"getCacheInfo",g);n(this,"listStorageEntries",g);n(this,"downloadStorage",g);ar()&&(this.rpc=Ce(new Worker(new URL(""+new URL("worker-BPV9SmHz.js",import.meta.url).href,""+import.meta.url),{type:"module",name:Oe()})),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(fe,e)}),this.rpc.addMessageListener("initializedError",({error:e})=>{this.initialized.status==="resolved"&&(p.error(e),mr({title:"Error initializing",description:e,variant:"danger"})),this.initialized.reject(Error(e))}),this.rpc.addMessageListener("kernelMessage",({message:e})=>{var r;(r=this.messageConsumer)==null||r.call(this,new MessageEvent("message",{data:e}))}))}static get INSTANCE(){let e="_marimo_private_PyodideBridge";return window[e]||(window[e]=new dt),window[e]}getSaveWorker(){return He()==="read"?(p.debug("Skipping SaveWorker in read-mode"),{readFile:g,readNotebook:g,saveNotebook:g}):Ce(new Worker(new URL(""+new URL("save-worker-CtJsIYIM.js",import.meta.url).href,""+import.meta.url),{type:"module",name:Oe()})).proxy.request}async startSession(){let e=await J.readFile(),r=await Z.readFile(),s=Q.get(Gt)??Y.getFilename(),a=Q.get(nr),i={},u=new URLSearchParams(window.location.search);for(let d of u.keys()){let v=u.getAll(d);i[d]=v.length===1?v[0]:v}await this.rpc.proxy.request.startSession({queryParameters:i,code:e||r||"",filename:s,userConfig:{...a,runtime:{...a.runtime,auto_instantiate:He()==="read"?!0:a.runtime.auto_instantiate}}})}setInterruptBuffer(){crossOriginIsolated?(this.interruptBuffer=new Uint8Array(new SharedArrayBuffer(1)),this.rpc.proxy.request.setInterruptBuffer(this.interruptBuffer)):p.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})}},rt=function(){return ye.withProducerCallback(t=>{ge.INSTANCE.attachMessageConsumer(t)})},Ze=function(t=ce()){let e=window.fetch;return window.fetch=async(r,s)=>{let a=r instanceof Request?r.url:r.toString();if(a.startsWith("data:"))return e(r,s);try{let i=X(a,t);if(i){let u=await(await e(i)).arrayBuffer();return new Response(u,{headers:{"Content-Type":kt(a)}})}return e(r,s)}catch(i){return p.error("Error parsing URL",i),e(r,s)}},()=>{window.fetch=e}};function kt(t){return t.endsWith(".csv")?"text/csv":t.endsWith(".json")?"application/json":t.endsWith(".txt")?"text/plain":"application/octet-stream"}Xe=function(t,e=ce()){let r=t.http.bind(t),s=t.load.bind(t);return t.http=async a=>{let i=X(a,e);if(i)return await window.fetch(i).then(u=>u.text());try{return await r(a)}catch(u){if(a.startsWith("data:"))return await window.fetch(a).then(d=>d.text());throw u}},t.load=async a=>{let i=X(a,e);if(i)return await window.fetch(i).then(u=>u.text());try{return await s(a)}catch(u){if(a.startsWith("data:"))return await window.fetch(a).then(d=>d.text());throw u}},()=>{t.http=r,t.load=s}};function Ee(t){return t.startsWith(".")?t.slice(1):t}function Mt(t,e=ce()){let r=X(t,e);if(!r)return t;let s=br(r);return URL.createObjectURL(s)}function X(t,e){let r=document.baseURI;r.startsWith("blob:")&&(r=r.replace("blob:",""));let s=new URL(t,r).pathname,a=ke(t),i=ke(s);return e[t]||e[Ee(t)]||e[s]||e[Ee(s)]||a&&e[a]||i&&e[i]}function ke(t){let e=t.indexOf("/@file/");return e===-1?null:t.slice(e)}function ie(t,e=[]){let r=[];if(t instanceof DataView)r.push(e);else if(Array.isArray(t))for(let[s,a]of t.entries())r.push(...ie(a,[...e,s]));else if(typeof t=="object"&&t)for(let[s,a]of Object.entries(t))r.push(...ie(a,[...e,s]));return r}function Pt(t){let e=ie(t);if(e.length===0)return{state:t,buffers:[],bufferPaths:[]};let r=structuredClone(t),s=[],a=[];for(let i of e){let u=er(t,i);if(u instanceof DataView){let d=ze(u);s.push(d),a.push(i),G(r,i,d)}}return{state:r,buffers:s,bufferPaths:a}}function Me(t){let{state:e,bufferPaths:r,buffers:s}=t;if(!r||r.length===0)return e;s&&sr(s.length===r.length,"Buffers and buffer paths not the same length");let a=e;for(let[i,u]of r.entries()){let d=s==null?void 0:s[i];if(d==null){p.warn("[anywidget] Could not find buffer at path",u);continue}typeof d=="string"?G(a,u,Ve(d)):G(a,u,d)}return a}const Pe={invoke:async()=>{let t="anywidget.invoke not supported in marimo. Please file an issue at https://github.com/marimo-team/marimo/issues";throw p.warn(t),Error(t)}};function Ft(t){if(typeof AbortSignal.any=="function")return AbortSignal.any(t);let e=new AbortController;for(let r of t){if(r.aborted)return e.abort(r.reason),e.signal;r.addEventListener("abort",()=>e.abort(r.reason),{once:!0})}return e.signal}var It=(Ie=class{constructor(){_(this,ee);_(this,U,new Map)}getModule(t,e){let r=o(this,U).get(e);if(r)return r;let s=A(this,ee,ct).call(this,t).catch(a=>{throw o(this,U).delete(e),a});return o(this,U).set(e,s),s}invalidate(t){p.debug(`[WidgetDefRegistry] Invalidating module cache for hash=${t}`),o(this,U).delete(t)}},U=new WeakMap,ee=new WeakSet,ct=async function(t){let e=ir(t).toString();return $e()&&(e=Mt(e)),hr(()=>import(e).then(async r=>(await r.__tla,r)),[],import.meta.url)},Ie),Lt=(Le=class{constructor(){_(this,M);_(this,T);_(this,E)}async bind(t,e){var i,u;if(o(this,E)&&o(this,T)===t)return o(this,E);o(this,E)&&o(this,T)!==t&&(p.debug("[WidgetBinding] Hot-reload detected, aborting previous binding"),(i=o(this,M))==null||i.abort(),C(this,M,void 0),C(this,E,void 0)),C(this,T,t),C(this,M,new AbortController);let r=o(this,M).signal,s=typeof t=="function"?await t():t,a=await((u=s.initialize)==null?void 0:u.call(s,{model:e,experimental:Pe}));return a&&r.addEventListener("abort",a),C(this,E,async(d,v)=>{var x;let q=await((x=s.render)==null?void 0:x.call(s,{model:e,el:d,experimental:Pe}));q&&Ft([v,r]).addEventListener("abort",()=>{let S=v.aborted?"view unmount":"binding destroyed";p.debug(`[WidgetBinding] Render cleanup triggered (reason: ${S})`),q()})}),o(this,E)}destroy(){var t;p.debug("[WidgetBinding] Destroying binding, aborting initialize lifecycle"),(t=o(this,M))==null||t.abort(),C(this,M,void 0),C(this,T,void 0),C(this,E,void 0)}},M=new WeakMap,T=new WeakMap,E=new WeakMap,Le),Nt=(Ne=class{constructor(){_(this,F,new Map)}getOrCreate(t){let e=o(this,F).get(t);return e||(e=new Lt,o(this,F).set(t,e)),e}destroy(t){let e=o(this,F).get(t);e&&(p.debug(`[BindingManager] Destroying binding for model=${t}`),e.destroy(),o(this,F).delete(t))}has(t){return o(this,F).has(t)}},F=new WeakMap,Ne);ot=new It,me=new Nt;var At=(Ae=class{constructor(t=1e4){_(this,D);_(this,P,new Map);_(this,V);C(this,V,t)}get(t){let e=A(this,D,ae).call(this,t);return e.deferred.status==="pending"&&setTimeout(()=>{e.deferred.status==="pending"&&(e.deferred.reject(Error(`Model not found for key: ${t}`)),o(this,P).delete(t))},o(this,V)),e.deferred.promise}create(t,e){let r=A(this,D,ae).call(this,t);r.deferred.resolve(e(r.controller.signal))}set(t,e){A(this,D,ae).call(this,t).deferred.resolve(e)}getSync(t){let e=o(this,P).get(t);if(e&&e.deferred.status==="resolved")return e.deferred.value}delete(t){var e;p.debug(`[ModelManager] Deleting model=${t}, aborting lifecycle signal`),(e=o(this,P).get(t))==null||e.controller.abort(),o(this,P).delete(t)}},P=new WeakMap,V=new WeakMap,D=new WeakSet,ae=function(t){let e=o(this,P).get(t);return e||(e={deferred:new Qe,controller:new AbortController},o(this,P).set(t,e)),e},Ae),Fe=Symbol("marimo");function oe(t){return t[Fe]}ne=new At;var Ut=(Ue=Fe,j=class{constructor(e,r,s){_(this,N);_(this,te,"change");_(this,I);_(this,L);_(this,H);_(this,R,{});n(this,Ue,{updateAndEmitDiffs:e=>A(this,N,ft).call(this,e),emitCustomMessage:(e,r)=>A(this,N,ht).call(this,e,r)});n(this,"widget_manager",{async get_model(e){let r=await j._modelManager.get(e);if(!r)throw Error(`Model not found with id: ${e}. This is likely because the model was not registered.`);return r}});_(this,re,tr(()=>{let e=o(this,R)[o(this,te)];if(e)for(let r of e)try{r()}catch(s){p.error("Error emitting event",s)}},0));C(this,L,e),C(this,H,r),C(this,I,new Map),s&&s.addEventListener("abort",()=>{p.debug("[Model] Signal aborted, clearing all listeners"),C(this,R,{})})}off(e,r){var s;if(!e){C(this,R,{});return}if(!r){o(this,R)[e]=new Set;return}(s=o(this,R)[e])==null||s.delete(r)}send(e,r,s){let a=(s??[]).map(i=>i instanceof ArrayBuffer?new DataView(i):new DataView(i.buffer,i.byteOffset,i.byteLength));return o(this,H).sendCustomMessage(e,a).then(()=>r==null?void 0:r())}get(e){return o(this,L)[e]}set(e,r){C(this,L,{...o(this,L),[e]:r}),o(this,I).set(e,r),A(this,N,pt).call(this,`change:${e}`,r),o(this,re).call(this)}save_changes(){if(o(this,I).size===0)return;let e=Object.fromEntries(o(this,I).entries());o(this,I).clear(),o(this,H).sendUpdate(e)}on(e,r){o(this,R)[e]||(o(this,R)[e]=new Set),o(this,R)[e].add(r)}},te=new WeakMap,I=new WeakMap,L=new WeakMap,H=new WeakMap,R=new WeakMap,N=new WeakSet,pt=function(e,r){if(!o(this,R)[e])return;let s=o(this,R)[e];for(let a of s)try{a(r)}catch(i){p.error("Error emitting event",i)}},ft=function(e){e!=null&&Object.keys(e).forEach(r=>{let s=r;o(this,L)[s]!==e[s]&&this.set(s,e[s])})},ht=function(e,r=[]){let s=o(this,R)["msg:custom"];if(s)for(let a of s)try{a(e.content,r)}catch(i){p.error("Error emitting event",i)}},re=new WeakMap,n(j,"_modelManager",ne),j);Ke=async function(t,e){let r=e.model_id,s=e.message,a=("buffers"in s?s.buffers:[]).map(Ve);switch(s.method){case"open":{let{state:i,buffer_paths:u=[]}=s,d=Me({state:i,bufferPaths:u,buffers:a}),v=t.getSync(r);if(v){oe(v).updateAndEmitDiffs(d);return}t.create(r,q=>new Ut(d,$e()?{sendUpdate:async()=>{},sendCustomMessage:async()=>{}}:{async sendUpdate(x){if(q.aborted){p.debug(`[Model] sendUpdate suppressed for model=${r} (signal aborted)`);return}let{state:S,buffers:O,bufferPaths:se}=Pt(x);await pe().sendModelValue({modelId:r,message:{method:"update",state:S,bufferPaths:se},buffers:O})},async sendCustomMessage(x,S){if(q.aborted){p.debug(`[Model] sendCustomMessage suppressed for model=${r} (signal aborted)`);return}await pe().sendModelValue({modelId:r,message:{method:"custom",content:x},buffers:S.map(ze)})}},q));return}case"custom":oe(await t.get(r)).emitCustomMessage({method:"custom",content:s.content},a);return;case"close":me.destroy(r),t.delete(r);return;case"update":{let{state:i,buffer_paths:u=[]}=s,d=Me({state:i,bufferPaths:u,buffers:a});oe(await t.get(r)).updateAndEmitDiffs(d);return}default:dr(s)}},zt(ne,"MODEL_MANAGER");function Tt(t){return typeof t!="object"||!t?!1:"type"in t&&t.type==="marimo-ui-value-update"}he=class mt{static get INSTANCE(){let e="_marimo_private_UIElementRegistry";return window[e]||(window[e]=new mt),window[e]}constructor(){this.entries=new Map}has(e){return this.entries.has(e)}set(e,r){this.entries.has(e)&&p.debug("UIElementRegistry overwriting entry for objectId.",e),this.entries.set(e,{objectId:e,value:r,elements:new Set})}registerInstance(e,r){let s=this.entries.get(e);s===void 0?this.entries.set(e,{objectId:e,value:Jt(r,this),elements:new Set([r])}):s.elements.add(r)}removeInstance(e,r){let s=this.entries.get(e);s!=null&&s.elements.has(r)&&s.elements.delete(r)}removeElementsByCell(e){[...this.entries.keys()].filter(r=>r.startsWith(`${e}-`)).forEach(r=>{this.entries.delete(r)})}lookupValue(e){let r=this.entries.get(e);return r===void 0?void 0:r.value}broadcastMessage(e,r,s){let a=this.entries.get(e);if(a===void 0){p.warn("UIElementRegistry missing entry",e);return}if(Tt(r)){a.value=r.value,a.elements.forEach(i=>{i.dispatchEvent(Ge.create({bubbles:!1,composed:!0,detail:{value:r.value,element:i}}))});return}a.elements.forEach(i=>{i.dispatchEvent(_r.create({bubbles:!1,composed:!0,detail:{objectId:e,message:r,buffers:s}}))})}broadcastValueUpdate(e,r,s){let a=this.entries.get(r);a===void 0?p.warn("UIElementRegistry missing entry",r):(a.value=s,a.elements.forEach(i=>{i!==e&&i.dispatchEvent(Ge.create({bubbles:!1,composed:!0,detail:{value:s,element:i}}))}),document.dispatchEvent(vr.create({bubbles:!0,composed:!0,detail:{objectId:r}})))}},nt=he.INSTANCE,tt=new fr("function-call-result",async(t,e)=>{await pe().sendFunctionRequest({functionCallId:t,...e})}),it="68px";var jt="288px";st=t=>t?/^\d+$/.test(t)?`${t}px`:t:jt,at=Qt({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}})});export{G as S,fe as _,Cr as __tla,he as a,Je as b,Ke as c,Ze as d,Xe as f,et as g,J as h,tt as i,me as l,rt as m,st as n,nt as o,ge as p,at as r,ne as s,it as t,ot as u,ye as v,lt as x,ut as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as Ce}from"./chunk-LvLJmgfZ.js";import{d as E,l as ct,p as ht,u as Z}from"./useEvent-D91BmmQi.js";import{t as mt}from"./react-Bj1aDYRI.js";import{$ as pt,E as ze,Sn as ut,Vt as ft,_ as xt,_i as pe,_n as yt,dr as kt,et as bt,h as Me,jr as wt,or as jt,rr as gt,t as vt,tr as Ct,tt as We,vn as zt,yn as Mt}from"./cells-CcsG9Aum.js";import{t as z}from"./compiler-runtime-B3qBwwSJ.js";import{n as Wt,x as _t}from"./ai-model-dropdown-D14GiszF.js";import{_ as L,d as _e}from"./useEventListener-DGjKht0c.js";import{y as Nt}from"./utils-DKaC_ndw.js";import{n as P,t as Ne}from"./constants-tOPFFcLZ.js";import{S as ue,h as St,i as Dt,x as Pt}from"./config-CmaJdl9U.js";import{t as At}from"./jsx-runtime-Blw4afVn.js";import{o as It}from"./alert-dialog-CXspBRlP.js";import{a as Tt,c as fe,o as xe,s as Et}from"./popover-AtoFZ7i4.js";import{a as Lt,c as Ht,i as Rt,n as qt,r as $t,s as Bt,t as Vt}from"./select--zcABebs.js";import{gt as Ot}from"./JsonOutput-IpD2GLtO.js";import{c as Se,d as ye,n as Ft,o as Ut,r as ke,t as Yt}from"./download-BFQaUFKI.js";import{m as Kt}from"./form-3ZUGKch9.js";import{t as De}from"./tooltip-DmqhBBs6.js";import{r as Pe,t as H}from"./button-BKVLeSTX.js";import{i as Gt,t as Ae}from"./strings-pfr2N700.js";import{r as R}from"./requests-9-v2bhoi.js";import{t as b}from"./createLucideIcon-w-Qo9n0R.js";import{a as Ie,f as Jt,i as Te,m as Xt,p as Ee,u as Le}from"./layout-B-lTkLKA.js";import{t as be}from"./check-B-sKate2.js";import{n as Qt}from"./maps-B4xARV9R.js";import{r as Zt}from"./useCellActionButton-4HWj1rt3.js";import{t as He}from"./copy-DFMsQ6MJ.js";import{t as ea}from"./eye-off-DgRJ-xBZ.js";import{t as ta}from"./file-plus-corner-BjSB-E2p.js";import{t as ee}from"./file-DaJ4JeZH.js";import{t as aa}from"./github-CP61uL34.js";import{n as oa,r as na,t as sa}from"./youtube-zkHE2QB5.js";import{i as la,n as Re}from"./add-connection-dialog-C42PDYI7.js";import{n as ia,t as ra}from"./square-BVY9SgWs.js";import{t as da}from"./image-CpSydGUq.js";import{t as ca}from"./link-BCjh6ihR.js";import{r as ha}from"./input-DjrybsRY.js";import{t as ma}from"./settings-D6Nc4lMz.js";import{t as pa}from"./sparkles-DczT6OBt.js";import{y as ua}from"./textarea-DJEKmYtw.js";import{t as M}from"./use-toast-T0_cQDma.js";import{n as qe,t as fa}from"./paths-Dfii2bN8.js";import{o as xa}from"./session-DDorezMU.js";import{a as $e,c as Be,i as Ve,n as Oe,r as Fe}from"./dialog-CognbQV_.js";import{n as we}from"./ImperativeModal-DSu22ncS.js";import{r as ya,t as ka}from"./share-DkQqqFqC.js";import{n as q}from"./copy-C8iWa1qI.js";import{r as ba}from"./useRunCells-Du76UV1R.js";import{a as wa}from"./cell-link-Cimoe3Fv.js";import{a as ja}from"./renderShortcut-Bjt8kSBs.js";import{t as ga}from"./icons-UbXYeuXE.js";import{t as va}from"./links-wWTxfdQn.js";import{r as Ca,t as Ue}from"./hooks-CHE17GG1.js";import{t as Ye}from"./types-z6Sk3JCV.js";var za=b("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Ma=b("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ke=b("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ge=b("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Je=b("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Wa=b("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),_a=b("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Na=b("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Xe=b("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Sa=b("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),Da=b("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Pa=b("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Qe=b("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),Aa=b("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Ia=b("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Ze=b("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),et=z(),$=Ce(mt(),1),a=Ce(At(),1);function Ta(e){let t=new URL(e.url);return e.authToken&&t.searchParams.set("auth",e.authToken),t.toString()}function Ea(e,t){let n=`uvx marimo@latest pair prompt --url '${t}'`;switch(e){case"claude":return`claude "$(${n} --claude)"`;case"codex":return`codex "$(${n} --codex)"`;case"opencode":return`opencode "$(${n} --opencode)"`}}var La="npx skills add marimo-team/marimo-pair";const Ha=e=>{let t=(0,et.c)(25),{onClose:n}=e,[o,d]=(0,$.useState)("claude"),i=Z(Dt),l;t[0]!==o||t[1]!==i?(l=Ea(o,Ta(i)),t[0]=o,t[1]=i,t[2]=l):l=t[2];let s=l,r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Be,{children:"Pair with an agent"}),t[3]=r):r=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsxs)($e,{children:[r,(0,a.jsxs)(Fe,{children:["Use an AI coding agent to pair-program on this notebook."," ",(0,a.jsx)("a",{href:"https://links.marimo.app/marimo-pair",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"Learn more"}),"."]})]}),t[4]=c):c=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"1. Install the skill"}),(0,a.jsx)(te,{command:La})]}),t[5]=h):h=t[5];let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("span",{className:"text-sm font-medium",children:"2. Run in your terminal"}),t[6]=p):p=t[6];let u;t[7]===Symbol.for("react.memo_cache_sentinel")?(u=C=>d(C),t[7]=u):u=t[7];let w;t[8]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Et,{className:"w-full",children:[(0,a.jsx)(fe,{value:"claude",className:"flex-1",children:"Claude"}),(0,a.jsx)(fe,{value:"codex",className:"flex-1",children:"Codex"}),(0,a.jsx)(fe,{value:"opencode",className:"flex-1",children:"OpenCode"})]}),t[8]=w):w=t[8];let f;t[9]===s?f=t[10]:(f=(0,a.jsx)(xe,{value:"claude",className:"mt-3",children:(0,a.jsx)(te,{command:s})}),t[9]=s,t[10]=f);let x;t[11]===s?x=t[12]:(x=(0,a.jsx)(xe,{value:"codex",className:"mt-3",children:(0,a.jsx)(te,{command:s})}),t[11]=s,t[12]=x);let y;t[13]===s?y=t[14]:(y=(0,a.jsx)(xe,{value:"opencode",className:"mt-3",children:(0,a.jsx)(te,{command:s})}),t[13]=s,t[14]=y);let k;t[15]!==o||t[16]!==y||t[17]!==f||t[18]!==x?(k=(0,a.jsxs)("div",{className:"flex flex-col gap-4 py-2",children:[h,(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[p,(0,a.jsxs)(Tt,{value:o,onValueChange:u,children:[w,f,x,y]})]})]}),t[15]=o,t[16]=y,t[17]=f,t[18]=x,t[19]=k):k=t[19];let j;t[20]===n?j=t[21]:(j=(0,a.jsx)(Ve,{children:(0,a.jsx)(H,{variant:"secondary",onClick:n,children:"Close"})}),t[20]=n,t[21]=j);let v;return t[22]!==k||t[23]!==j?(v=(0,a.jsxs)(Oe,{className:"sm:max-w-lg",children:[c,k,j]}),t[22]=k,t[23]=j,t[24]=v):v=t[24],v};var te=e=>{let t=(0,et.c)(15),{command:n}=e,[o,d]=(0,$.useState)(!1),i;t[0]===n?i=t[1]:(i=Pe.stopPropagation(async u=>{u.preventDefault(),await q(n),d(!0),setTimeout(()=>d(!1),2e3)}),t[0]=n,t[1]=i);let l=i,s;t[2]===n?s=t[3]:(s=(0,a.jsx)("code",{className:"flex-1 select-all break-words",children:n}),t[2]=n,t[3]=s);let r;t[4]===o?r=t[5]:(r=o?(0,a.jsx)(be,{size:14,strokeWidth:1.5}):(0,a.jsx)(He,{size:14,strokeWidth:1.5}),t[4]=o,t[5]=r);let c;t[6]!==l||t[7]!==r?(c=(0,a.jsx)(H,{onClick:l,size:"xs",variant:"ghost",children:r}),t[6]=l,t[7]=r,t[8]=c):c=t[8];let h;t[9]!==o||t[10]!==c?(h=(0,a.jsx)(De,{content:"Copied!",open:o,children:c}),t[9]=o,t[10]=c,t[11]=h):h=t[11];let p;return t[12]!==s||t[13]!==h?(p=(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted px-3 py-2 font-mono text-xs",children:[s,h]}),t[12]=s,t[13]=h,t[14]=p):p=t[14],p},tt=z(),ae="https://static.marimo.app";const Ra=e=>{let t=(0,tt.c)(25),{onClose:n}=e,[o,d]=(0,$.useState)(""),{exportAsHTML:i}=R(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,s=`${ae}/static/${l}`,r;t[0]!==i||t[1]!==n||t[2]!==l?(r=async v=>{v.preventDefault(),n();let C=await i({download:!1,includeCode:!0,files:Jt.INSTANCE.filenames()}),W=M({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${ae}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:C,path:l})}).catch(()=>{W.dismiss(),M({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:P.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),W.dismiss(),M({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=i,t[1]=n,t[2]=l,t[3]=r):r=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Be,{children:"Share static notebook"}),t[4]=c):c=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsxs)($e,{children:[c,(0,a.jsxs)(Fe,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:ae,target:"_blank",children:ae}),"."]})]}),t[5]=h):h=t[5];let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=v=>{d(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=p):p=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(ha,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:p,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let w;t[9]===s?w=t[10]:(w=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(qa,{text:s}),(0,a.jsx)("span",{className:"text-primary",children:s})]})]}),t[9]=s,t[10]=w);let f;t[11]!==u||t[12]!==w?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,w]}),t[11]=u,t[12]=w,t[13]=f):f=t[13];let x;t[14]===n?x=t[15]:(x=(0,a.jsx)(H,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=x);let y;t[16]===s?y=t[17]:(y=(0,a.jsx)(H,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await q(s)},children:"Create"}),t[16]=s,t[17]=y);let k;t[18]!==x||t[19]!==y?(k=(0,a.jsxs)(Ve,{children:[x,y]}),t[18]=x,t[19]=y,t[20]=k):k=t[20];let j;return t[21]!==r||t[22]!==k||t[23]!==f?(j=(0,a.jsx)(Oe,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:r,children:[h,f,k]})}),t[21]=r,t[22]=k,t[23]=f,t[24]=j):j=t[24],j};var qa=e=>{let t=(0,tt.c)(8),[n,o]=$.useState(!1),d;t[0]===e.text?d=t[1]:(d=Pe.stopPropagation(async c=>{c.preventDefault(),await q(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=d);let i=d,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(He,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let s;t[3]===i?s=t[4]:(s=(0,a.jsx)(H,{"data-testid":"copy-static-notebook-url-button",onClick:i,size:"xs",variant:"secondary",children:l}),t[3]=i,t[4]=s);let r;return t[5]!==n||t[6]!==s?(r=(0,a.jsx)(De,{content:"Copied!",open:n,children:s}),t[5]=n,t[6]=s,t[7]=r):r=t[7],r},$a=z();function Ba(){let e=document.getElementsByClassName(Ne.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=pe.findElement(t);if(!o){L.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:pe.parse(o.id)}}}return L.warn("No visible output area found for scroll anchor"),null}function Va(e){if(!e){L.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(pe.create(e.cellId));if(!t){L.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${Ne.outputArea}`)){L.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function at(){let e=(0,$a.c)(2),t=E(We),n;return e[0]===t?n=e[1]:(n=()=>{let o=Ba();t(d=>({mode:bt(d.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Va(o)})})},e[0]=t,e[1]=n),n}const ot=ht(!1);var Oa=z();const Fa=()=>{let e=(0,Oa.c)(7),{selectedLayout:t}=Ie(),{setLayoutView:n}=Te();if(ue()&&!ut("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=s=>n(s),e[0]=n,e[1]=o);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(Bt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Ht,{placeholder:"Select a view"})}),e[2]=d):d=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(qt,{children:(0,a.jsxs)($t,{children:[(0,a.jsx)(Lt,{children:"View as"}),Ye.map(Ya)]})}),e[3]=i):i=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Vt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[d,i]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Ua(e){return(0,a.jsx)(nt(e),{className:"h-4 w-4"})}function nt(e){switch(e){case"vertical":return Sa;case"grid":return na;case"slides":return Qe;default:return Gt(e),ra}}function st(e){return Ae.startCase(e)}function Ya(e){return(0,a.jsx)(Rt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ua(e),(0,a.jsx)("span",{children:st(e)})]})},e)}async function Ka(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ga=z();function Ja(e){let t=(0,Ga.c)(5),{openPrompt:n,closeModal:o}=we(),{sendCopy:d}=R(),i;return t[0]!==o||t[1]!==n||t[2]!==d||t[3]!==e?(i=()=>{if(!e)return null;let l=fa.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${qe.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:s=>{let r=l.join(qe.dirname(e),s);d({source:e,destination:r}).then(()=>{o(),M({title:"Notebook copied",description:"A copy of the notebook has been created."}),va(r)})}})},t[0]=o,t[1]=n,t[2]=d,t[3]=e,t[4]=i):i=t[4],i}const Xa=()=>{let{updateCellConfig:e}=ze(),{saveCellConfig:t}=R();return(0,$.useCallback)(async()=>{let n=new ft,o=Me(),d=o.cellIds.inOrderIds,i={};for(let s of d){if(o.cellData[s]===void 0)continue;let{code:r,config:c}=o.cellData[s];c.hide_code||n.isSupported(r)&&(i[s]={hide_code:!0})}let l=_e.entries(i);if(l.length!==0){await t({configs:i});for(let[s,r]of l)e({cellId:s,config:r})}},[e])};var Qa=z();function lt(){let e=(0,Qa.c)(4),{openConfirm:t}=we(),n=E(St),{sendRestart:o}=R(),d;return e[0]!==t||e[1]!==o||e[2]!==n?(d=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(It,{onClick:async()=>{n({state:Pt.CLOSING}),await o(),ya()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=d):d=e[3],d}var Za=z(),A=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function eo(){var ge,ve;let e=(0,Za.c)(51),t=wa(),{openModal:n,closeModal:o}=we(),{toggleApplication:d}=yt(),{selectedPanel:i}=zt(),[l]=ct(We),s=Z(pt),r=Xa(),[c]=Nt(),{updateCellConfig:h,undoDeleteCell:p,clearAllCellOutputs:u,addSetupCellIfDoesntExist:w,collapseAllCells:f,expandAllCells:x}=ze(),y=lt(),k=ba(),j=Ja(t),v=E(ot),C=E(Wt),W=E(_t),{exportAsIPYNB:ne,exportAsMarkdown:se,readCode:I,saveCellConfig:le,updateCellOutputs:_}=R(),N=Ca(),ie=Z(xt),re=Z(vt),{selectedLayout:B}=Ie(),{setLayoutView:de}=Te(),V=at(),O=((ge=c.sharing)==null?void 0:ge.html)??!0,F=((ve=c.sharing)==null?void 0:ve.wasm)??!0,je=!ue(),ce=B==="slides",it=bo,rt=ko,U;e[0]!==t||e[1]!==N||e[2]!==_?(U=async m=>{let{preset:g,title:T}=m;if(!t){oe();return}await Se(T,async me=>{await Ue({takeScreenshots:()=>N({progress:me}),updateCellOutputs:_}),await Ka({filename:t,preset:g,downloadPDF:Ft})})},e[0]=t,e[1]=N,e[2]=_,e[3]=U):U=e[3];let S=U,Y;e[4]===S?Y=e[5]:(Y=async()=>{if(je){await S({preset:"document",title:"Downloading Document PDF..."});return}let m=new Event("export-beforeprint"),g=new Event("export-afterprint");window.dispatchEvent(m),setTimeout(yo,0),setTimeout(()=>window.dispatchEvent(g),0)},e[4]=S,e[5]=Y);let K=Y,G;e[6]!==ne||e[7]!==t||e[8]!==N||e[9]!==_?(G=async()=>{if(!t){oe();return}await Se("Downloading IPYNB...",async m=>{await Ue({takeScreenshots:()=>N({progress:m}),updateCellOutputs:_});let g=await ne({download:!1});ke(new Blob([g],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},e[6]=ne,e[7]=t,e[8]=N,e[9]=_,e[10]=G):G=e[10];let he=G,J;e[11]===Symbol.for("react.memo_cache_sentinel")?(J=(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),e[11]=J):J=e[11];let X;e[12]===Symbol.for("react.memo_cache_sentinel")?(X=(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),e[12]=X):X=e[12];let D;e[13]===t?D=e[14]:(D=async()=>{if(!t){oe();return}await Le({filename:t,includeCode:!0})},e[13]=t,e[14]=D);let Q;return e[15]!==w||e[16]!==re||e[17]!==u||e[18]!==o||e[19]!==f||e[20]!==j||e[21]!==S||e[22]!==x||e[23]!==se||e[24]!==t||e[25]!==K||e[26]!==he||e[27]!==ie||e[28]!==r||e[29]!==ce||e[30]!==s||e[31]!==n||e[32]!==I||e[33]!==y||e[34]!==k||e[35]!==le||e[36]!==B||e[37]!==i||e[38]!==v||e[39]!==W||e[40]!==de||e[41]!==C||e[42]!==O||e[43]!==F||e[44]!==D||e[45]!==d||e[46]!==V||e[47]!==p||e[48]!==h||e[49]!==l.mode?(Q=[{icon:J,label:"Download",handle:A,dropdown:[{icon:X,label:"Download as HTML",handle:D},{icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){oe();return}await Le({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(ga,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let m=await se({download:!1});ke(new Blob([m],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Da,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:he},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let m=await I();ke(new Blob([m.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",ja("global.hideCode",!1)]}),handle:xo},ce?{divider:!0,icon:(0,a.jsx)(ee,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:A,dropdown:[{icon:(0,a.jsx)(ee,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:K},{icon:(0,a.jsx)(ee,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:rt(!0),hidden:!je,handle:async()=>{await S({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(ee,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:K}]},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",handle:async()=>{n((0,a.jsx)(Ha,{onClose:o}))}},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Share",handle:A,hidden:!O&&!F,dropdown:[{icon:(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!O,handle:async()=>{n((0,a.jsx)(Ra,{onClose:o}))}},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!F,handle:async()=>{await q(ka({code:(await I()).contents})),M({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:A,dropdown:Mt.flatMap(m=>{let{type:g,Icon:T,hidden:me,additionalKeywords:dt}=m;return me?[]:{label:Ae.startCase(g),rightElement:it(i===g),icon:(0,a.jsx)(T,{size:14,strokeWidth:1.5}),handle:()=>d(g),additionalKeywords:dt}})},{icon:(0,a.jsx)(Qe,{size:14,strokeWidth:1.5}),label:"Present as",handle:A,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(ua,{size:14,strokeWidth:1.5}):(0,a.jsx)(Xe,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{V()}},...Ye.map((m,g)=>{let T=nt(m);return{divider:g===0,label:st(m),icon:(0,a.jsx)(T,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:B===m&&(0,a.jsx)(be,{size:14})}),handle:()=>{de(m),l.mode==="edit"&&V()}}})]},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ue(),handle:j},{icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await q((await I()).contents),M({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!ie||s,handle:async()=>{let m=wt(Me());await le({configs:_e.fromEntries(m.map(fo))});for(let g of m)h({cellId:g,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Je,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{w({})}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Re,{onClose:o}))}},{icon:(0,a.jsx)(la,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Re,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ze,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!re||s,handle:()=>{p()}},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:y,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:r,redundant:!0},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(uo)},{icon:(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>W(po)},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>C(mo),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Resources",handle:A,dropdown:[{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:ho},{icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"GitHub",handle:co},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:ro},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"YouTube",handle:io},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Changelog",handle:lo}]},{divider:!0,icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:so},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:no}].filter(oo).map(to),e[15]=w,e[16]=re,e[17]=u,e[18]=o,e[19]=f,e[20]=j,e[21]=S,e[22]=x,e[23]=se,e[24]=t,e[25]=K,e[26]=he,e[27]=ie,e[28]=r,e[29]=ce,e[30]=s,e[31]=n,e[32]=I,e[33]=y,e[34]=k,e[35]=le,e[36]=B,e[37]=i,e[38]=v,e[39]=W,e[40]=de,e[41]=C,e[42]=O,e[43]=F,e[44]=D,e[45]=d,e[46]=V,e[47]=p,e[48]=h,e[49]=l.mode,e[50]=Q):Q=e[50],Q}function to(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(ao)}:e}function ao(e){return!e.hidden}function oo(e){return!e.hidden}function no(){let e=xa();window.open(e,"_blank")}function so(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function lo(){window.open(P.releasesPage,"_blank")}function io(){window.open(P.youtube,"_blank")}function ro(){window.open(P.discordLink,"_blank")}function co(){window.open(P.githubPage,"_blank")}function ho(){window.open(P.docsPage,"_blank")}function mo(e){return!e}function po(e){return!e}function uo(e){return!e}function fo(e){return[e,{disabled:!1}]}async function xo(){let e=document.getElementById("App");e&&await Ut({element:e,filename:document.title,prepare:Yt})}function yo(){return window.print()}function ko(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function bo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(be,{size:14})})}function oe(){M({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{at as a,Je as c,ot as i,Ge as l,lt as n,Ze as o,Fa as r,Xe as s,eo as t,Ke as u};
|
|
1
|
+
import{s as Ce}from"./chunk-LvLJmgfZ.js";import{d as E,l as ct,p as ht,u as Z}from"./useEvent-D91BmmQi.js";import{t as mt}from"./react-Bj1aDYRI.js";import{$ as pt,E as ze,Sn as ut,Vt as ft,_ as xt,_i as pe,_n as yt,dr as kt,et as bt,h as Me,jr as wt,or as jt,rr as gt,t as vt,tr as Ct,tt as We,vn as zt,yn as Mt}from"./cells-CcsG9Aum.js";import{t as z}from"./compiler-runtime-B3qBwwSJ.js";import{n as Wt,x as _t}from"./ai-model-dropdown-D14GiszF.js";import{_ as L,d as _e}from"./useEventListener-DGjKht0c.js";import{y as Nt}from"./utils-DKaC_ndw.js";import{n as P,t as Ne}from"./constants-tOPFFcLZ.js";import{S as ue,h as St,i as Dt,x as Pt}from"./config-CmaJdl9U.js";import{t as At}from"./jsx-runtime-Blw4afVn.js";import{o as It}from"./alert-dialog-CXspBRlP.js";import{a as Tt,c as fe,o as xe,s as Et}from"./popover-AtoFZ7i4.js";import{a as Lt,c as Ht,i as Rt,n as qt,r as $t,s as Bt,t as Vt}from"./select--zcABebs.js";import{gt as Ot}from"./JsonOutput-Ctdzcd2D.js";import{c as Se,d as ye,n as Ft,o as Ut,r as ke,t as Yt}from"./download-BFQaUFKI.js";import{m as Kt}from"./form-DkNMeOSQ.js";import{t as De}from"./tooltip-DmqhBBs6.js";import{r as Pe,t as H}from"./button-BKVLeSTX.js";import{i as Gt,t as Ae}from"./strings-pfr2N700.js";import{r as R}from"./requests-9-v2bhoi.js";import{t as b}from"./createLucideIcon-w-Qo9n0R.js";import{a as Ie,f as Jt,i as Te,m as Xt,p as Ee,u as Le}from"./layout-CsKQkdEh.js";import{t as be}from"./check-B-sKate2.js";import{n as Qt}from"./maps-B4xARV9R.js";import{r as Zt}from"./useCellActionButton-4HWj1rt3.js";import{t as He}from"./copy-DFMsQ6MJ.js";import{t as ea}from"./eye-off-DgRJ-xBZ.js";import{t as ta}from"./file-plus-corner-BjSB-E2p.js";import{t as ee}from"./file-DaJ4JeZH.js";import{t as aa}from"./github-CP61uL34.js";import{n as oa,r as na,t as sa}from"./youtube-zkHE2QB5.js";import{i as la,n as Re}from"./add-connection-dialog-CEquGDgf.js";import{n as ia,t as ra}from"./square-BVY9SgWs.js";import{t as da}from"./image-CpSydGUq.js";import{t as ca}from"./link-BCjh6ihR.js";import{r as ha}from"./input-DjrybsRY.js";import{t as ma}from"./settings-D6Nc4lMz.js";import{t as pa}from"./sparkles-DczT6OBt.js";import{y as ua}from"./textarea-DJEKmYtw.js";import{t as M}from"./use-toast-T0_cQDma.js";import{n as qe,t as fa}from"./paths-Dfii2bN8.js";import{o as xa}from"./session-DDorezMU.js";import{a as $e,c as Be,i as Ve,n as Oe,r as Fe}from"./dialog-CognbQV_.js";import{n as we}from"./ImperativeModal-DSu22ncS.js";import{r as ya,t as ka}from"./share-DkQqqFqC.js";import{n as q}from"./copy-C8iWa1qI.js";import{r as ba}from"./useRunCells-Du76UV1R.js";import{a as wa}from"./cell-link-Cimoe3Fv.js";import{a as ja}from"./renderShortcut-Bjt8kSBs.js";import{t as ga}from"./icons-UbXYeuXE.js";import{t as va}from"./links-wWTxfdQn.js";import{r as Ca,t as Ue}from"./hooks-wt7ylZro.js";import{t as Ye}from"./types-z6Sk3JCV.js";var za=b("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Ma=b("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ke=b("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ge=b("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Je=b("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Wa=b("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),_a=b("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Na=b("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Xe=b("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Sa=b("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),Da=b("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),Pa=b("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Qe=b("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),Aa=b("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Ia=b("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Ze=b("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),et=z(),$=Ce(mt(),1),a=Ce(At(),1);function Ta(e){let t=new URL(e.url);return e.authToken&&t.searchParams.set("auth",e.authToken),t.toString()}function Ea(e,t){let n=`uvx marimo@latest pair prompt --url '${t}'`;switch(e){case"claude":return`claude "$(${n} --claude)"`;case"codex":return`codex "$(${n} --codex)"`;case"opencode":return`opencode "$(${n} --opencode)"`}}var La="npx skills add marimo-team/marimo-pair";const Ha=e=>{let t=(0,et.c)(25),{onClose:n}=e,[o,d]=(0,$.useState)("claude"),i=Z(Dt),l;t[0]!==o||t[1]!==i?(l=Ea(o,Ta(i)),t[0]=o,t[1]=i,t[2]=l):l=t[2];let s=l,r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Be,{children:"Pair with an agent"}),t[3]=r):r=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsxs)($e,{children:[r,(0,a.jsxs)(Fe,{children:["Use an AI coding agent to pair-program on this notebook."," ",(0,a.jsx)("a",{href:"https://links.marimo.app/marimo-pair",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"Learn more"}),"."]})]}),t[4]=c):c=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"1. Install the skill"}),(0,a.jsx)(te,{command:La})]}),t[5]=h):h=t[5];let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("span",{className:"text-sm font-medium",children:"2. Run in your terminal"}),t[6]=p):p=t[6];let u;t[7]===Symbol.for("react.memo_cache_sentinel")?(u=C=>d(C),t[7]=u):u=t[7];let w;t[8]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Et,{className:"w-full",children:[(0,a.jsx)(fe,{value:"claude",className:"flex-1",children:"Claude"}),(0,a.jsx)(fe,{value:"codex",className:"flex-1",children:"Codex"}),(0,a.jsx)(fe,{value:"opencode",className:"flex-1",children:"OpenCode"})]}),t[8]=w):w=t[8];let f;t[9]===s?f=t[10]:(f=(0,a.jsx)(xe,{value:"claude",className:"mt-3",children:(0,a.jsx)(te,{command:s})}),t[9]=s,t[10]=f);let x;t[11]===s?x=t[12]:(x=(0,a.jsx)(xe,{value:"codex",className:"mt-3",children:(0,a.jsx)(te,{command:s})}),t[11]=s,t[12]=x);let y;t[13]===s?y=t[14]:(y=(0,a.jsx)(xe,{value:"opencode",className:"mt-3",children:(0,a.jsx)(te,{command:s})}),t[13]=s,t[14]=y);let k;t[15]!==o||t[16]!==y||t[17]!==f||t[18]!==x?(k=(0,a.jsxs)("div",{className:"flex flex-col gap-4 py-2",children:[h,(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[p,(0,a.jsxs)(Tt,{value:o,onValueChange:u,children:[w,f,x,y]})]})]}),t[15]=o,t[16]=y,t[17]=f,t[18]=x,t[19]=k):k=t[19];let j;t[20]===n?j=t[21]:(j=(0,a.jsx)(Ve,{children:(0,a.jsx)(H,{variant:"secondary",onClick:n,children:"Close"})}),t[20]=n,t[21]=j);let v;return t[22]!==k||t[23]!==j?(v=(0,a.jsxs)(Oe,{className:"sm:max-w-lg",children:[c,k,j]}),t[22]=k,t[23]=j,t[24]=v):v=t[24],v};var te=e=>{let t=(0,et.c)(15),{command:n}=e,[o,d]=(0,$.useState)(!1),i;t[0]===n?i=t[1]:(i=Pe.stopPropagation(async u=>{u.preventDefault(),await q(n),d(!0),setTimeout(()=>d(!1),2e3)}),t[0]=n,t[1]=i);let l=i,s;t[2]===n?s=t[3]:(s=(0,a.jsx)("code",{className:"flex-1 select-all break-words",children:n}),t[2]=n,t[3]=s);let r;t[4]===o?r=t[5]:(r=o?(0,a.jsx)(be,{size:14,strokeWidth:1.5}):(0,a.jsx)(He,{size:14,strokeWidth:1.5}),t[4]=o,t[5]=r);let c;t[6]!==l||t[7]!==r?(c=(0,a.jsx)(H,{onClick:l,size:"xs",variant:"ghost",children:r}),t[6]=l,t[7]=r,t[8]=c):c=t[8];let h;t[9]!==o||t[10]!==c?(h=(0,a.jsx)(De,{content:"Copied!",open:o,children:c}),t[9]=o,t[10]=c,t[11]=h):h=t[11];let p;return t[12]!==s||t[13]!==h?(p=(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted px-3 py-2 font-mono text-xs",children:[s,h]}),t[12]=s,t[13]=h,t[14]=p):p=t[14],p},tt=z(),ae="https://static.marimo.app";const Ra=e=>{let t=(0,tt.c)(25),{onClose:n}=e,[o,d]=(0,$.useState)(""),{exportAsHTML:i}=R(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,s=`${ae}/static/${l}`,r;t[0]!==i||t[1]!==n||t[2]!==l?(r=async v=>{v.preventDefault(),n();let C=await i({download:!1,includeCode:!0,files:Jt.INSTANCE.filenames()}),W=M({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${ae}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:C,path:l})}).catch(()=>{W.dismiss(),M({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:P.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),W.dismiss(),M({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=i,t[1]=n,t[2]=l,t[3]=r):r=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Be,{children:"Share static notebook"}),t[4]=c):c=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsxs)($e,{children:[c,(0,a.jsxs)(Fe,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:ae,target:"_blank",children:ae}),"."]})]}),t[5]=h):h=t[5];let p;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=v=>{d(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=p):p=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(ha,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:p,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let w;t[9]===s?w=t[10]:(w=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(qa,{text:s}),(0,a.jsx)("span",{className:"text-primary",children:s})]})]}),t[9]=s,t[10]=w);let f;t[11]!==u||t[12]!==w?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,w]}),t[11]=u,t[12]=w,t[13]=f):f=t[13];let x;t[14]===n?x=t[15]:(x=(0,a.jsx)(H,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=x);let y;t[16]===s?y=t[17]:(y=(0,a.jsx)(H,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await q(s)},children:"Create"}),t[16]=s,t[17]=y);let k;t[18]!==x||t[19]!==y?(k=(0,a.jsxs)(Ve,{children:[x,y]}),t[18]=x,t[19]=y,t[20]=k):k=t[20];let j;return t[21]!==r||t[22]!==k||t[23]!==f?(j=(0,a.jsx)(Oe,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:r,children:[h,f,k]})}),t[21]=r,t[22]=k,t[23]=f,t[24]=j):j=t[24],j};var qa=e=>{let t=(0,tt.c)(8),[n,o]=$.useState(!1),d;t[0]===e.text?d=t[1]:(d=Pe.stopPropagation(async c=>{c.preventDefault(),await q(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=d);let i=d,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(He,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let s;t[3]===i?s=t[4]:(s=(0,a.jsx)(H,{"data-testid":"copy-static-notebook-url-button",onClick:i,size:"xs",variant:"secondary",children:l}),t[3]=i,t[4]=s);let r;return t[5]!==n||t[6]!==s?(r=(0,a.jsx)(De,{content:"Copied!",open:n,children:s}),t[5]=n,t[6]=s,t[7]=r):r=t[7],r},$a=z();function Ba(){let e=document.getElementsByClassName(Ne.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=pe.findElement(t);if(!o){L.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:pe.parse(o.id)}}}return L.warn("No visible output area found for scroll anchor"),null}function Va(e){if(!e){L.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(pe.create(e.cellId));if(!t){L.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${Ne.outputArea}`)){L.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function at(){let e=(0,$a.c)(2),t=E(We),n;return e[0]===t?n=e[1]:(n=()=>{let o=Ba();t(d=>({mode:bt(d.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Va(o)})})},e[0]=t,e[1]=n),n}const ot=ht(!1);var Oa=z();const Fa=()=>{let e=(0,Oa.c)(7),{selectedLayout:t}=Ie(),{setLayoutView:n}=Te();if(ue()&&!ut("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=s=>n(s),e[0]=n,e[1]=o);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(Bt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Ht,{placeholder:"Select a view"})}),e[2]=d):d=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(qt,{children:(0,a.jsxs)($t,{children:[(0,a.jsx)(Lt,{children:"View as"}),Ye.map(Ya)]})}),e[3]=i):i=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(Vt,{"data-testid":"layout-select",value:t,onValueChange:o,children:[d,i]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Ua(e){return(0,a.jsx)(nt(e),{className:"h-4 w-4"})}function nt(e){switch(e){case"vertical":return Sa;case"grid":return na;case"slides":return Qe;default:return Gt(e),ra}}function st(e){return Ae.startCase(e)}function Ya(e){return(0,a.jsx)(Rt,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ua(e),(0,a.jsx)("span",{children:st(e)})]})},e)}async function Ka(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ga=z();function Ja(e){let t=(0,Ga.c)(5),{openPrompt:n,closeModal:o}=we(),{sendCopy:d}=R(),i;return t[0]!==o||t[1]!==n||t[2]!==d||t[3]!==e?(i=()=>{if(!e)return null;let l=fa.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${qe.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:s=>{let r=l.join(qe.dirname(e),s);d({source:e,destination:r}).then(()=>{o(),M({title:"Notebook copied",description:"A copy of the notebook has been created."}),va(r)})}})},t[0]=o,t[1]=n,t[2]=d,t[3]=e,t[4]=i):i=t[4],i}const Xa=()=>{let{updateCellConfig:e}=ze(),{saveCellConfig:t}=R();return(0,$.useCallback)(async()=>{let n=new ft,o=Me(),d=o.cellIds.inOrderIds,i={};for(let s of d){if(o.cellData[s]===void 0)continue;let{code:r,config:c}=o.cellData[s];c.hide_code||n.isSupported(r)&&(i[s]={hide_code:!0})}let l=_e.entries(i);if(l.length!==0){await t({configs:i});for(let[s,r]of l)e({cellId:s,config:r})}},[e])};var Qa=z();function lt(){let e=(0,Qa.c)(4),{openConfirm:t}=we(),n=E(St),{sendRestart:o}=R(),d;return e[0]!==t||e[1]!==o||e[2]!==n?(d=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(It,{onClick:async()=>{n({state:Pt.CLOSING}),await o(),ya()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=d):d=e[3],d}var Za=z(),A=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function eo(){var ge,ve;let e=(0,Za.c)(51),t=wa(),{openModal:n,closeModal:o}=we(),{toggleApplication:d}=yt(),{selectedPanel:i}=zt(),[l]=ct(We),s=Z(pt),r=Xa(),[c]=Nt(),{updateCellConfig:h,undoDeleteCell:p,clearAllCellOutputs:u,addSetupCellIfDoesntExist:w,collapseAllCells:f,expandAllCells:x}=ze(),y=lt(),k=ba(),j=Ja(t),v=E(ot),C=E(Wt),W=E(_t),{exportAsIPYNB:ne,exportAsMarkdown:se,readCode:I,saveCellConfig:le,updateCellOutputs:_}=R(),N=Ca(),ie=Z(xt),re=Z(vt),{selectedLayout:B}=Ie(),{setLayoutView:de}=Te(),V=at(),O=((ge=c.sharing)==null?void 0:ge.html)??!0,F=((ve=c.sharing)==null?void 0:ve.wasm)??!0,je=!ue(),ce=B==="slides",it=bo,rt=ko,U;e[0]!==t||e[1]!==N||e[2]!==_?(U=async m=>{let{preset:g,title:T}=m;if(!t){oe();return}await Se(T,async me=>{await Ue({takeScreenshots:()=>N({progress:me}),updateCellOutputs:_}),await Ka({filename:t,preset:g,downloadPDF:Ft})})},e[0]=t,e[1]=N,e[2]=_,e[3]=U):U=e[3];let S=U,Y;e[4]===S?Y=e[5]:(Y=async()=>{if(je){await S({preset:"document",title:"Downloading Document PDF..."});return}let m=new Event("export-beforeprint"),g=new Event("export-afterprint");window.dispatchEvent(m),setTimeout(yo,0),setTimeout(()=>window.dispatchEvent(g),0)},e[4]=S,e[5]=Y);let K=Y,G;e[6]!==ne||e[7]!==t||e[8]!==N||e[9]!==_?(G=async()=>{if(!t){oe();return}await Se("Downloading IPYNB...",async m=>{await Ue({takeScreenshots:()=>N({progress:m}),updateCellOutputs:_});let g=await ne({download:!1});ke(new Blob([g],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},e[6]=ne,e[7]=t,e[8]=N,e[9]=_,e[10]=G):G=e[10];let he=G,J;e[11]===Symbol.for("react.memo_cache_sentinel")?(J=(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),e[11]=J):J=e[11];let X;e[12]===Symbol.for("react.memo_cache_sentinel")?(X=(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),e[12]=X):X=e[12];let D;e[13]===t?D=e[14]:(D=async()=>{if(!t){oe();return}await Le({filename:t,includeCode:!0})},e[13]=t,e[14]=D);let Q;return e[15]!==w||e[16]!==re||e[17]!==u||e[18]!==o||e[19]!==f||e[20]!==j||e[21]!==S||e[22]!==x||e[23]!==se||e[24]!==t||e[25]!==K||e[26]!==he||e[27]!==ie||e[28]!==r||e[29]!==ce||e[30]!==s||e[31]!==n||e[32]!==I||e[33]!==y||e[34]!==k||e[35]!==le||e[36]!==B||e[37]!==i||e[38]!==v||e[39]!==W||e[40]!==de||e[41]!==C||e[42]!==O||e[43]!==F||e[44]!==D||e[45]!==d||e[46]!==V||e[47]!==p||e[48]!==h||e[49]!==l.mode?(Q=[{icon:J,label:"Download",handle:A,dropdown:[{icon:X,label:"Download as HTML",handle:D},{icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){oe();return}await Le({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(ga,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let m=await se({download:!1});ke(new Blob([m],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Da,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:he},{icon:(0,a.jsx)(Xt,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let m=await I();ke(new Blob([m.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:l.mode!=="present",tooltip:l.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",ja("global.hideCode",!1)]}),handle:xo},ce?{divider:!0,icon:(0,a.jsx)(ee,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:A,dropdown:[{icon:(0,a.jsx)(ee,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:K},{icon:(0,a.jsx)(ee,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:rt(!0),hidden:!je,handle:async()=>{await S({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(ee,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:K}]},{icon:(0,a.jsx)(pa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",handle:async()=>{n((0,a.jsx)(Ha,{onClose:o}))}},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Share",handle:A,hidden:!O&&!F,dropdown:[{icon:(0,a.jsx)(Kt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!O,handle:async()=>{n((0,a.jsx)(Ra,{onClose:o}))}},{icon:(0,a.jsx)(ca,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!F,handle:async()=>{await q(ka({code:(await I()).contents})),M({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:A,dropdown:Mt.flatMap(m=>{let{type:g,Icon:T,hidden:me,additionalKeywords:dt}=m;return me?[]:{label:Ae.startCase(g),rightElement:it(i===g),icon:(0,a.jsx)(T,{size:14,strokeWidth:1.5}),handle:()=>d(g),additionalKeywords:dt}})},{icon:(0,a.jsx)(Qe,{size:14,strokeWidth:1.5}),label:"Present as",handle:A,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(ua,{size:14,strokeWidth:1.5}):(0,a.jsx)(Xe,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{V()}},...Ye.map((m,g)=>{let T=nt(m);return{divider:g===0,label:st(m),icon:(0,a.jsx)(T,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:B===m&&(0,a.jsx)(be,{size:14})}),handle:()=>{de(m),l.mode==="edit"&&V()}}})]},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ue(),handle:j},{icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await q((await I()).contents),M({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!ie||s,handle:async()=>{let m=wt(Me());await le({configs:_e.fromEntries(m.map(fo))});for(let g of m)h({cellId:g,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Je,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{w({})}},{icon:(0,a.jsx)(gt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Re,{onClose:o}))}},{icon:(0,a.jsx)(la,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Re,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ze,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!re||s,handle:()=>{p()}},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:y,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:r,redundant:!0},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f,redundant:!0},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x,redundant:!0},{divider:!0,icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(uo)},{icon:(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>W(po)},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>C(mo),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(Qt,{size:14,strokeWidth:1.5}),label:"Resources",handle:A,dropdown:[{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:ho},{icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"GitHub",handle:co},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:ro},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"YouTube",handle:io},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Changelog",handle:lo}]},{divider:!0,icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:so},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:no}].filter(oo).map(to),e[15]=w,e[16]=re,e[17]=u,e[18]=o,e[19]=f,e[20]=j,e[21]=S,e[22]=x,e[23]=se,e[24]=t,e[25]=K,e[26]=he,e[27]=ie,e[28]=r,e[29]=ce,e[30]=s,e[31]=n,e[32]=I,e[33]=y,e[34]=k,e[35]=le,e[36]=B,e[37]=i,e[38]=v,e[39]=W,e[40]=de,e[41]=C,e[42]=O,e[43]=F,e[44]=D,e[45]=d,e[46]=V,e[47]=p,e[48]=h,e[49]=l.mode,e[50]=Q):Q=e[50],Q}function to(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(ao)}:e}function ao(e){return!e.hidden}function oo(e){return!e.hidden}function no(){let e=xa();window.open(e,"_blank")}function so(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function lo(){window.open(P.releasesPage,"_blank")}function io(){window.open(P.youtube,"_blank")}function ro(){window.open(P.discordLink,"_blank")}function co(){window.open(P.githubPage,"_blank")}function ho(){window.open(P.docsPage,"_blank")}function mo(e){return!e}function po(e){return!e}function uo(e){return!e}function fo(e){return[e,{disabled:!1}]}async function xo(){let e=document.getElementById("App");e&&await Ut({element:e,filename:document.title,prepare:Yt})}function yo(){return window.print()}function ko(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function bo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(be,{size:14})})}function oe(){M({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{at as a,Je as c,ot as i,Ge as l,lt as n,Ze as o,Fa as r,Xe as s,eo as t,Ke as u};
|
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-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-D0MoPi4a.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-DItdS47A.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
|
|
@@ -192,14 +192,14 @@
|
|
|
192
192
|
<link rel="modulepreload" crossorigin href="./assets/table-qC3alE1r.js">
|
|
193
193
|
<link rel="modulepreload" crossorigin href="./assets/message-circle-ehj_MdGz.js">
|
|
194
194
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-D0qmuH5W.js">
|
|
195
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-
|
|
195
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-Ctdzcd2D.js">
|
|
196
196
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-CsXoiEZx.js">
|
|
197
197
|
<link rel="modulepreload" crossorigin href="./assets/square-function-DIHpmVFo.js">
|
|
198
198
|
<link rel="modulepreload" crossorigin href="./assets/spec-CFx2bitO.js">
|
|
199
199
|
<link rel="modulepreload" crossorigin href="./assets/ellipsis-vertical-DEH0lwkn.js">
|
|
200
200
|
<link rel="modulepreload" crossorigin href="./assets/refresh-cw-CoFbRtMK.js">
|
|
201
201
|
<link rel="modulepreload" crossorigin href="./assets/components-DpxyscxU.js">
|
|
202
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
202
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-BlmqVfbV.js">
|
|
203
203
|
<link rel="modulepreload" crossorigin href="./assets/icons-UbXYeuXE.js">
|
|
204
204
|
<link rel="modulepreload" crossorigin href="./assets/floating-outline-Cfa1ESSb.js">
|
|
205
205
|
<link rel="modulepreload" crossorigin href="./assets/useAddCell-mJ1PkF-E.js">
|
|
@@ -220,12 +220,12 @@
|
|
|
220
220
|
<link rel="modulepreload" crossorigin href="./assets/memoize-BwAF2XN5.js">
|
|
221
221
|
<link rel="modulepreload" crossorigin href="./assets/get-D7jeR2wg.js">
|
|
222
222
|
<link rel="modulepreload" crossorigin href="./assets/_baseSet-49dbm-yb.js">
|
|
223
|
-
<link rel="modulepreload" crossorigin href="./assets/state-
|
|
223
|
+
<link rel="modulepreload" crossorigin href="./assets/state-BpEWsL00.js">
|
|
224
224
|
<link rel="modulepreload" crossorigin href="./assets/label-C89F4v17.js">
|
|
225
225
|
<link rel="modulepreload" crossorigin href="./assets/textarea-DJEKmYtw.js">
|
|
226
226
|
<link rel="modulepreload" crossorigin href="./assets/refresh-ccw-DxvV30QW.js">
|
|
227
227
|
<link rel="modulepreload" crossorigin href="./assets/trash-2-CwDX6_Ac.js">
|
|
228
|
-
<link rel="modulepreload" crossorigin href="./assets/form-
|
|
228
|
+
<link rel="modulepreload" crossorigin href="./assets/form-DkNMeOSQ.js">
|
|
229
229
|
<link rel="modulepreload" crossorigin href="./assets/renderShortcut-Bjt8kSBs.js">
|
|
230
230
|
<link rel="modulepreload" crossorigin href="./assets/field-C6i22m8B.js">
|
|
231
231
|
<link rel="modulepreload" crossorigin href="./assets/VisuallyHidden-DVY6OceZ.js">
|
package/package.json
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
type HeaderGroup,
|
|
10
10
|
type Row,
|
|
11
11
|
type Table,
|
|
12
|
-
type Table as TanStackTable,
|
|
13
12
|
} from "@tanstack/react-table";
|
|
14
13
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
15
14
|
import { type JSX, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -52,7 +51,7 @@ export function renderTableHeader<TData>(
|
|
|
52
51
|
)}
|
|
53
52
|
style={style}
|
|
54
53
|
ref={(thead) => {
|
|
55
|
-
columnSizingHandler(
|
|
54
|
+
columnSizingHandler({ table, column: header.column, thead });
|
|
56
55
|
}}
|
|
57
56
|
>
|
|
58
57
|
{header.isPlaceholder
|
|
@@ -323,23 +322,30 @@ function getPinningStyles<TData>(
|
|
|
323
322
|
|
|
324
323
|
// Update column sizes in table state for column pinning offsets
|
|
325
324
|
// https://github.com/TanStack/table/discussions/3947#discussioncomment-9564867
|
|
326
|
-
function columnSizingHandler<TData>(
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
325
|
+
function columnSizingHandler<TData>({
|
|
326
|
+
table,
|
|
327
|
+
column,
|
|
328
|
+
thead,
|
|
329
|
+
}: {
|
|
330
|
+
table: Table<TData>;
|
|
331
|
+
column: Column<TData>;
|
|
332
|
+
thead: HTMLTableCellElement | null;
|
|
333
|
+
}): void {
|
|
331
334
|
if (!thead) {
|
|
332
335
|
return;
|
|
333
336
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
337
|
+
// Round to avoid infinite re-render loops: the browser's table layout
|
|
338
|
+
// algorithm may render a <th> at a slightly different width than the
|
|
339
|
+
// CSS `width` we set via column.getSize(), so a strict float === float
|
|
340
|
+
// comparison never stabilizes. Rounding to integers ensures convergence
|
|
341
|
+
// after at most one cycle.
|
|
342
|
+
const measuredWidth = Math.round(thead.getBoundingClientRect().width);
|
|
343
|
+
if (table.getState().columnSizing[column.id] === measuredWidth) {
|
|
338
344
|
return;
|
|
339
345
|
}
|
|
340
346
|
|
|
341
347
|
table.setColumnSizing((prevSizes) => ({
|
|
342
348
|
...prevSizes,
|
|
343
|
-
[column.id]:
|
|
349
|
+
[column.id]: measuredWidth,
|
|
344
350
|
}));
|
|
345
351
|
}
|
|
@@ -10,6 +10,23 @@ import {
|
|
|
10
10
|
} from "./events";
|
|
11
11
|
import { parseInitialValue } from "./htmlUtils";
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Kernel-initiated UI value update, sent via the existing
|
|
15
|
+
* `send-ui-element-message` channel when `set_ui_value` (code_mode)
|
|
16
|
+
* changes a widget's value so the frontend can reflect the new state.
|
|
17
|
+
*/
|
|
18
|
+
interface UIValueUpdateMessage {
|
|
19
|
+
type: "marimo-ui-value-update";
|
|
20
|
+
value: ValueType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isUIValueUpdateMessage(msg: unknown): msg is UIValueUpdateMessage {
|
|
24
|
+
if (typeof msg !== "object" || msg === null) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return "type" in msg && msg.type === "marimo-ui-value-update";
|
|
28
|
+
}
|
|
29
|
+
|
|
13
30
|
interface UIElementEntry {
|
|
14
31
|
objectId: string;
|
|
15
32
|
value: ValueType;
|
|
@@ -141,21 +158,38 @@ export class UIElementRegistry {
|
|
|
141
158
|
const entry = this.entries.get(objectId);
|
|
142
159
|
if (entry === undefined) {
|
|
143
160
|
Logger.warn("UIElementRegistry missing entry", objectId);
|
|
144
|
-
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Kernel-initiated value update — push into DOM elements without
|
|
165
|
+
// dispatching MarimoValueReadyEvent to avoid a round-trip.
|
|
166
|
+
if (isUIValueUpdateMessage(message)) {
|
|
167
|
+
entry.value = message.value;
|
|
145
168
|
entry.elements.forEach((element) => {
|
|
146
169
|
element.dispatchEvent(
|
|
147
|
-
|
|
148
|
-
bubbles: false,
|
|
170
|
+
MarimoValueUpdateEvent.create({
|
|
171
|
+
bubbles: false,
|
|
149
172
|
composed: true,
|
|
150
|
-
detail: {
|
|
151
|
-
objectId: objectId,
|
|
152
|
-
message: message,
|
|
153
|
-
buffers: buffers,
|
|
154
|
-
},
|
|
173
|
+
detail: { value: message.value, element: element },
|
|
155
174
|
}),
|
|
156
175
|
);
|
|
157
176
|
});
|
|
177
|
+
return;
|
|
158
178
|
}
|
|
179
|
+
|
|
180
|
+
entry.elements.forEach((element) => {
|
|
181
|
+
element.dispatchEvent(
|
|
182
|
+
MarimoIncomingMessageEvent.create({
|
|
183
|
+
bubbles: false, // only the intended target gets the message
|
|
184
|
+
composed: true,
|
|
185
|
+
detail: {
|
|
186
|
+
objectId: objectId,
|
|
187
|
+
message: message,
|
|
188
|
+
buffers: buffers,
|
|
189
|
+
},
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
192
|
+
});
|
|
159
193
|
}
|
|
160
194
|
|
|
161
195
|
/**
|