@marimo-team/frontend 0.22.1-dev33 → 0.22.1-dev34
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-CNt4LxkV.js → JsonOutput-D1i8P1dG.js} +1 -1
- package/dist/assets/{add-connection-dialog-Ca1Tc12W.js → add-connection-dialog-ogwy8tvS.js} +1 -1
- package/dist/assets/{agent-panel-BYAJ_EOf.js → agent-panel-BHLkHj7k.js} +1 -1
- package/dist/assets/{cell-editor-CSxVMYfU.js → cell-editor-_GDTh-4a.js} +2 -2
- package/dist/assets/{column-preview-B92BXVH1.js → column-preview-NDhbeu0E.js} +1 -1
- package/dist/assets/{command-palette-BHXQKZ5s.js → command-palette-uJxkhle4.js} +1 -1
- package/dist/assets/common-CRBlPqv5.js +1 -0
- package/dist/assets/{dependency-graph-panel-CABb99dr.js → dependency-graph-panel-BBmN-Vc7.js} +1 -1
- package/dist/assets/{edit-page-DtYaxOp-.js → edit-page-Cr_DnrkM.js} +4 -4
- package/dist/assets/{file-explorer-panel-DJgn_eST.js → file-explorer-panel-g9KppC7Y.js} +1 -1
- package/dist/assets/{form-BFjzbGu5.js → form-BVnQnVQ2.js} +1 -1
- package/dist/assets/{hooks-C2LN7xdC.js → hooks-zQJ9iU_R.js} +1 -1
- package/dist/assets/{index-BG82ditz.js → index-KI45dku7.js} +3 -3
- package/dist/assets/{layout-Cb75LpRE.js → layout-Cudicm29.js} +2 -2
- package/dist/assets/{panels-C-PHvQEf.js → panels-BCRqI88j.js} +1 -1
- package/dist/assets/{run-page-BZ-VoP12.js → run-page-C-ySBXLo.js} +1 -1
- package/dist/assets/{scratchpad-panel-CCcUfWUz.js → scratchpad-panel-C5Pogi1P.js} +1 -1
- package/dist/assets/{session-panel-DaLr35Wc.js → session-panel-DEsnZWks.js} +1 -1
- package/dist/assets/{snippets-panel-qn7otI-U.js → snippets-panel-DQgE3W8I.js} +1 -1
- package/dist/assets/{state-q7CKuEm6.js → state-CV8Wy3e4.js} +1 -1
- package/dist/assets/{useNotebookActions-DB5vGtvM.js → useNotebookActions-Bb4xxjuJ.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
- package/src/components/editor/cell/code/cell-editor.tsx +1 -1
- package/src/components/editor/chrome/panels/snippets-panel.tsx +1 -1
- package/src/components/editor/links/cell-link-list.tsx +1 -1
- package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +2 -3
- package/src/components/editor/navigation/navigation.ts +2 -2
- package/src/components/editor/output/console/ConsoleOutput.tsx +1 -1
- package/src/utils/mime-types.ts +1 -1
- package/dist/assets/common-B5GX57h6.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var jt=Object.defineProperty;var De=f=>{throw TypeError(f)};var Dt=(f,h,y)=>h in f?jt(f,h,{enumerable:!0,configurable:!0,writable:!0,value:y}):f[h]=y;var n=(f,h,y)=>Dt(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 Ht}from"./useEvent-D91BmmQi.js";import{Cn as Ot,Z as He,b as $t,ci as zt,ii as Vt,mi as Y,oi as Qt,pi as Yt,ti as Gt,x as Jt,__tla as Kt}from"./cells-ArUhhHls.js";import{t as Zt}from"./get-D7jeR2wg.js";import{t as Xt}from"./debounce-BbSyBDA8.js";import{t as er}from"./_baseSet-49dbm-yb.js";import{_ as p,y as g}from"./useEventListener-DGjKht0c.js";import{t as tr}from"./invariant-CkiqGLcK.js";import{S as rr}from"./utils-DKaC_ndw.js";import{S as sr,n as nr}from"./config-CmaJdl9U.js";import{n as ar}from"./switch-DqrqDBdD.js";import{n as Oe}from"./globals-DK8gKReW.js";import{at as ce,ot as $e,__tla as ir}from"./JsonOutput-
|
|
1
|
+
var jt=Object.defineProperty;var De=f=>{throw TypeError(f)};var Dt=(f,h,y)=>h in f?jt(f,h,{enumerable:!0,configurable:!0,writable:!0,value:y}):f[h]=y;var n=(f,h,y)=>Dt(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 Ht}from"./useEvent-D91BmmQi.js";import{Cn as Ot,Z as He,b as $t,ci as zt,ii as Vt,mi as Y,oi as Qt,pi as Yt,ti as Gt,x as Jt,__tla as Kt}from"./cells-ArUhhHls.js";import{t as Zt}from"./get-D7jeR2wg.js";import{t as Xt}from"./debounce-BbSyBDA8.js";import{t as er}from"./_baseSet-49dbm-yb.js";import{_ as p,y as g}from"./useEventListener-DGjKht0c.js";import{t as tr}from"./invariant-CkiqGLcK.js";import{S as rr}from"./utils-DKaC_ndw.js";import{S as sr,n as nr}from"./config-CmaJdl9U.js";import{n as ar}from"./switch-DqrqDBdD.js";import{n as Oe}from"./globals-DK8gKReW.js";import{at as ce,ot as $e,__tla as ir}from"./JsonOutput-D1i8P1dG.js";import{t as or}from"./createReducer-CYlwteGD.js";import{r as lr}from"./strings-pfr2N700.js";import{t as pe}from"./requests-9-v2bhoi.js";import{a as ze,l as ur,r as Ve,__tla as dr}from"./markdown-renderer-CyUc0f8D.js";import{t as cr}from"./DeferredRequestRegistry-KOgQgaJP.js";import{t as pr}from"./preload-helper-DItdS47A.js";import{t as Qe}from"./Deferred-DMWKlZOV.js";import{t as Ye}from"./uuid-DercMavo.js";import{t as fr}from"./use-toast-T0_cQDma.js";import{n as hr,r as mr,t as gr}from"./share-DkQqqFqC.js";import{t as yr}from"./blob-CpeNXBj-.js";import{i as wr,r as br,t as vr}from"./events-BRAWQiYK.js";let G,fe,he,Ge,Je,Ke,Ze,Xe,J,et,me,tt,rt,st,ge,nt,ne,at,it,ye,ot,lt,_r=Promise.all([(()=>{try{return Kt}catch{}})(),(()=>{try{return ir}catch{}})(),(()=>{try{return dr}catch{}})()]).then(async()=>{var U,ee,dt,Ie,M,T,E,Le,F,Ne,P,V,D,ae,Ae,Ue,te,I,L,H,R,B,N,ct,pt,ft,re;function f(t,e,r){return t==null?t:er(t,e,r)}G=f,lt=de(null);var{valueAtom:h,useActions:y}=or(()=>({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:[]})});Ge=()=>Ht(h),ot=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 mt(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,Wt)}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(),j={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,j),s.send(j)})}let se=new Proxy(O,{get:(l,c,w)=>c in l?Reflect.get(l,c,w):m=>O(c,m)}),Te=se;function Be(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 We=new Proxy(Be,{get:(l,c,w)=>c in l?Reflect.get(l,c,w):m=>Be(c,m)}),je=We,W=new Map,le=new Set;function Tt(l,c){var w;if(!s.registerHandler)throw K(["registerHandler"],"register message listeners");if(l==="*"){le.add(c);return}W.has(l)||W.set(l,new Set),(w=W.get(l))==null||w.add(c)}function Bt(l,c){var w,m;if(l==="*"){le.delete(c);return}(w=W.get(l))==null||w.delete(c),((m=W.get(l))==null?void 0:m.size)===0&&W.delete(l)}async function Wt(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,j;try{j={type:"response",id:m,success:!0,payload:await i(b,k)}}catch($){if(!($ instanceof Error))throw $;j={type:"response",id:m,success:!1,error:$.message}}(w=e.onSend)==null||w.call(e,j),s.send(j);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=W.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:We,sendProxy:je,addMessageListener:Tt,removeMessageListener:Bt,proxy:{send:je,request:Te},_setDebugHooks:r}}function gt(t){return mt(t)}var _e="[transport-id]";function yt(t,e){let{transportId:r}=e;return r==null?t:{[_e]:r,data:t}}function wt(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 bt(t,e={}){let{transportId:r,filter:s,remotePort:a}=e,i=t,u=a??t,d;return{send(v){u.postMessage(yt(v,{transportId:r}))},registerHandler(v){d=q=>{let x=q.data,[S,O]=wt(x,{transportId:r,filter:()=>s==null?void 0:s(q)});S||v(O)},i.addEventListener("message",d)},unregisterHandler(){d&&i.removeEventListener("message",d)}}}function vt(t,e){return bt(t,e)}function Ce(t){return gt({transport:vt(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..."),Xe=de(t=>{let e=t($t),r=Object.values(e.cellRuntime);return r.some(s=>!ur(s.output))?!0:r.every(s=>s.status==="idle")});var Re=hr(),qe="marimo:file",xe=new Gt(null);const _t={saveFile(t){xe.set(qe,t)},readFile(){return xe.get(qe)}};var Ct={saveFile(t){Y.setCodeForHash((0,Re.compressToEncodedURIComponent)(t))},readFile(){let t=Y.getCodeFromHash()||Y.getCodeFromSearchParam();return t?(0,Re.decompressFromEncodedURIComponent)(t):null}};const Rt={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var qt={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 xt={saveFile(t){},readFile(){return Q.get(Vt)??null}};var St={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
|
|
2
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([xt,Rt,Ct]),Z=new Se([_t,qt,St]),ge=class ut{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
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 +1 @@
|
|
|
1
|
-
import{s as we}from"./chunk-LvLJmgfZ.js";import{d as L,l as Ze,p as Xe,u as de}from"./useEvent-D91BmmQi.js";import{t as et}from"./react-Bj1aDYRI.js";import{$ as tt,E as ge,Sn as at,Vt as ot,_ as nt,_i as ce,_n as it,dr as st,et as lt,h as je,jr as rt,or as dt,rr as ct,t as ht,tr as pt,tt as ve,vn as mt,yn as ut}from"./cells-ArUhhHls.js";import{t as D}from"./compiler-runtime-B3qBwwSJ.js";import{n as ft,x as yt}from"./ai-model-dropdown-Dnf-CxbP.js";import{_ as T,d as Ce}from"./useEventListener-DGjKht0c.js";import{y as kt}from"./utils-DKaC_ndw.js";import{n as A,t as ze}from"./constants-tOPFFcLZ.js";import{S as he,h as bt,x as xt}from"./config-CmaJdl9U.js";import{t as wt}from"./jsx-runtime-Blw4afVn.js";import{o as gt}from"./alert-dialog-CXspBRlP.js";import{a as jt,c as vt,i as Ct,n as zt,r as Mt,s as Wt,t as St}from"./select--zcABebs.js";import{gt as _t}from"./JsonOutput-CNt4LxkV.js";import{c as Me,d as pe,n as Dt,o as At,r as me,t as Pt}from"./download-7EtMZf2Y.js";import{m as Nt}from"./form-BFjzbGu5.js";import{t as It}from"./tooltip-DmqhBBs6.js";import{r as Et,t as ue}from"./button-BKVLeSTX.js";import{i as Lt,t as We}from"./strings-pfr2N700.js";import{r as H}from"./requests-9-v2bhoi.js";import{t as h}from"./createLucideIcon-w-Qo9n0R.js";import{a as Se,f as Tt,i as _e,m as Ht,p as De,u as Ae}from"./layout-Cb75LpRE.js";import{t as Pe}from"./check-B-sKate2.js";import{n as qt}from"./maps-B4xARV9R.js";import{r as Rt}from"./useCellActionButton-BiYBXHfb.js";import{t as Bt}from"./copy-DFMsQ6MJ.js";import{t as Vt}from"./eye-off-DgRJ-xBZ.js";import{t as Ft}from"./file-plus-corner-BjSB-E2p.js";import{t as J}from"./file-DaJ4JeZH.js";import{t as Ot}from"./github-CP61uL34.js";import{n as Yt,r as Kt,t as $t}from"./youtube-zkHE2QB5.js";import{i as Ut,n as Ne}from"./add-connection-dialog-Ca1Tc12W.js";import{n as Gt,t as Jt}from"./square-BVY9SgWs.js";import{t as Qt}from"./image-CpSydGUq.js";import{t as Zt}from"./link-BCjh6ihR.js";import{r as Xt}from"./input-DjrybsRY.js";import{t as ea}from"./settings-D6Nc4lMz.js";import{y as ta}from"./textarea-DqzNK0s9.js";import{t as C}from"./use-toast-T0_cQDma.js";import{n as Ie,t as aa}from"./paths-Dfii2bN8.js";import{o as oa}from"./session-DDorezMU.js";import{a as na,c as ia,i as sa,n as la,r as ra}from"./dialog-CognbQV_.js";import{n as fe}from"./ImperativeModal-DSu22ncS.js";import{r as da,t as ca}from"./share-DkQqqFqC.js";import{n as Q}from"./copy-C8iWa1qI.js";import{r as ha}from"./useRunCells-DgBY-vh9.js";import{a as pa}from"./cell-link-D4UrIH9w.js";import{a as ma}from"./renderShortcut-Bjt8kSBs.js";import{t as ua}from"./icons-UbXYeuXE.js";import{t as fa}from"./links-wWTxfdQn.js";import{r as ya,t as Ee}from"./hooks-C2LN7xdC.js";import{t as Le}from"./types-z6Sk3JCV.js";var ka=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ba=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Te=h("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"}]]),He=h("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"}]]),qe=h("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"}]]),xa=h("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"}]]),wa=h("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"}]]),ga=h("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"}]]),Re=h("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"}]]),ja=h("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"}]]),va=h("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"}]]),Ca=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Be=h("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"}]]),za=h("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"}]]),Ma=h("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"}]]),Ve=h("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"}]]),Fe=D(),ye=we(et(),1),a=we(wt(),1),Z="https://static.marimo.app";const Wa=e=>{let t=(0,Fe.c)(25),{onClose:n}=e,[o,s]=(0,ye.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Z}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let N=await r({download:!1,includeCode:!0,files:Tt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Z}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:N,path:l})}).catch(()=>{z.dismiss(),C({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:A.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({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]=r,t[1]=n,t[2]=l,t[3]=d):d=t[3];let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ia,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(na,{children:[m,(0,a.jsxs)(ra,{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:Z,target:"_blank",children:Z}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Xt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(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)(Sa,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(ue,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(ue,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await Q(i)},children:"Create"}),t[16]=i,t[17]=b);let x;t[18]!==k||t[19]!==b?(x=(0,a.jsxs)(sa,{children:[k,b]}),t[18]=k,t[19]=b,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(la,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,x]})}),t[21]=d,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var Sa=e=>{let t=(0,Fe.c)(8),[n,o]=ye.useState(!1),s;t[0]===e.text?s=t[1]:(s=Et.stopPropagation(async m=>{m.preventDefault(),await Q(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Bt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ue,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(It,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},_a=D();function Da(){let e=document.getElementsByClassName(ze.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=ce.findElement(t);if(!o){T.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:ce.parse(o.id)}}}return T.warn("No visible output area found for scroll anchor"),null}function Aa(e){if(!e){T.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(ce.create(e.cellId));if(!t){T.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${ze.outputArea}`)){T.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Oe(){let e=(0,_a.c)(2),t=L(ve),n;return e[0]===t?n=e[1]:(n=()=>{let o=Da();t(s=>({mode:lt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Aa(o)})})},e[0]=t,e[1]=n),n}const Ye=Xe(!1);var Pa=D();const Na=()=>{let e=(0,Pa.c)(7),{selectedLayout:t}=Se(),{setLayoutView:n}=_e();if(he()&&!at("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Wt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(vt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(zt,{children:(0,a.jsxs)(Mt,{children:[(0,a.jsx)(jt,{children:"View as"}),Le.map(Ea)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(St,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Ia(e){return(0,a.jsx)(Ke(e),{className:"h-4 w-4"})}function Ke(e){switch(e){case"vertical":return ja;case"grid":return Kt;case"slides":return Be;default:return Lt(e),Jt}}function $e(e){return We.startCase(e)}function Ea(e){return(0,a.jsx)(Ct,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ia(e),(0,a.jsx)("span",{children:$e(e)})]})},e)}async function La(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ta=D();function Ha(e){let t=(0,Ta.c)(5),{openPrompt:n,closeModal:o}=fe(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=aa.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ie.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Ie.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),fa(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const qa=()=>{let{updateCellConfig:e}=ge(),{saveCellConfig:t}=H();return(0,ye.useCallback)(async()=>{let n=new ot,o=je(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Ce.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var Ra=D();function Ue(){let e=(0,Ra.c)(4),{openConfirm:t}=fe(),n=L(bt),{sendRestart:o}=H(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{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)(gt,{onClick:async()=>{n({state:xt.CLOSING}),await o(),da()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ba=D(),P=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Va(){var be,xe;let e=(0,Ba.c)(51),t=pa(),{openModal:n,closeModal:o}=fe(),{toggleApplication:s}=it(),{selectedPanel:r}=mt(),[l]=Ze(ve),i=de(tt),d=qa(),[m]=kt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:k}=ge(),b=Ue(),x=ha(),j=Ha(t),v=L(Ye),N=L(ft),z=L(yt),{exportAsIPYNB:ee,exportAsMarkdown:te,readCode:I,saveCellConfig:ae,updateCellOutputs:M}=H(),W=ya(),oe=de(nt),ne=de(ht),{selectedLayout:q}=Se(),{setLayoutView:ie}=_e(),R=Oe(),B=((be=m.sharing)==null?void 0:be.html)??!0,V=((xe=m.sharing)==null?void 0:xe.wasm)??!0,ke=!he(),se=q==="slides",Ge=so,Je=io,F;e[0]!==t||e[1]!==W||e[2]!==M?(F=async c=>{let{preset:p,title:E}=c;if(!t){X();return}await Me(E,async re=>{await Ee({takeScreenshots:()=>W({progress:re}),updateCellOutputs:M}),await La({filename:t,preset:p,downloadPDF:Dt})})},e[0]=t,e[1]=W,e[2]=M,e[3]=F):F=e[3];let S=F,O;e[4]===S?O=e[5]:(O=async()=>{if(ke){await S({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(no,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=S,e[5]=O);let Y=O,K;e[6]!==ee||e[7]!==t||e[8]!==W||e[9]!==M?(K=async()=>{if(!t){X();return}await Me("Downloading IPYNB...",async c=>{await Ee({takeScreenshots:()=>W({progress:c}),updateCellOutputs:M});let p=await ee({download:!1});me(new Blob([p],{type:"application/x-ipynb+json"}),pe.toIPYNB(document.title))})},e[6]=ee,e[7]=t,e[8]=W,e[9]=M,e[10]=K):K=e[10];let le=K,$;e[11]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),e[11]=$):$=e[11];let U;e[12]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(De,{size:14,strokeWidth:1.5}),e[12]=U):U=e[12];let _;e[13]===t?_=e[14]:(_=async()=>{if(!t){X();return}await Ae({filename:t,includeCode:!0})},e[13]=t,e[14]=_);let G;return e[15]!==f||e[16]!==ne||e[17]!==u||e[18]!==o||e[19]!==y||e[20]!==j||e[21]!==S||e[22]!==k||e[23]!==te||e[24]!==t||e[25]!==Y||e[26]!==le||e[27]!==oe||e[28]!==d||e[29]!==se||e[30]!==i||e[31]!==n||e[32]!==I||e[33]!==b||e[34]!==x||e[35]!==ae||e[36]!==q||e[37]!==r||e[38]!==v||e[39]!==z||e[40]!==ie||e[41]!==N||e[42]!==B||e[43]!==V||e[44]!==_||e[45]!==s||e[46]!==R||e[47]!==g||e[48]!==w||e[49]!==l.mode?(G=[{icon:$,label:"Download",handle:P,dropdown:[{icon:U,label:"Download as HTML",handle:_},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){X();return}await Ae({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(ua,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await te({download:!1});me(new Blob([c],{type:"text/plain"}),pe.toMarkdown(document.title))}},{icon:(0,a.jsx)(va,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:le},{icon:(0,a.jsx)(Ht,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await I();me(new Blob([c.contents],{type:"text/plain"}),pe.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Qt,{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: ",ma("global.hideCode",!1)]}),handle:oo},se?{divider:!0,icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:P,dropdown:[{icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:Y},{icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:Je(!0),hidden:!ke,handle:async()=>{await S({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:Y}]},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Share",handle:P,hidden:!B&&!V,dropdown:[{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!B,handle:async()=>{n((0,a.jsx)(Wa,{onClose:o}))}},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!V,handle:async()=>{await Q(ca({code:(await I()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:P,dropdown:ut.flatMap(c=>{let{type:p,Icon:E,hidden:re,additionalKeywords:Qe}=c;return re?[]:{label:We.startCase(p),rightElement:Ge(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:Qe}})},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Present as",handle:P,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(ta,{size:14,strokeWidth:1.5}):(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{R()}},...Le.map((c,p)=>{let E=Ke(c);return{divider:p===0,label:$e(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:q===c&&(0,a.jsx)(Pe,{size:14})}),handle:()=>{ie(c),l.mode==="edit"&&R()}}})]},{icon:(0,a.jsx)(wa,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||he(),handle:j},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await Q((await I()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!oe||i,handle:async()=>{let c=rt(je());await ae({configs:Ce.fromEntries(c.map(ao))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Ne,{onClose:o}))}},{icon:(0,a.jsx)(Ut,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Ne,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!ne||i,handle:()=>{g()}},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(xa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ba,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ka,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:k,redundant:!0},{divider:!0,icon:(0,a.jsx)(He,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(to)},{icon:(0,a.jsx)(ga,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(eo)},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>N(Xa),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Resources",handle:P,dropdown:[{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Za},{icon:(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Qa},{icon:(0,a.jsx)(Yt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ja},{icon:(0,a.jsx)($t,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ga},{icon:(0,a.jsx)(pt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ua}]},{divider:!0,icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:$a},{icon:(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ka}].filter(Ya).map(Fa),e[15]=f,e[16]=ne,e[17]=u,e[18]=o,e[19]=y,e[20]=j,e[21]=S,e[22]=k,e[23]=te,e[24]=t,e[25]=Y,e[26]=le,e[27]=oe,e[28]=d,e[29]=se,e[30]=i,e[31]=n,e[32]=I,e[33]=b,e[34]=x,e[35]=ae,e[36]=q,e[37]=r,e[38]=v,e[39]=z,e[40]=ie,e[41]=N,e[42]=B,e[43]=V,e[44]=_,e[45]=s,e[46]=R,e[47]=g,e[48]=w,e[49]=l.mode,e[50]=G):G=e[50],G}function Fa(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Oa)}:e}function Oa(e){return!e.hidden}function Ya(e){return!e.hidden}function Ka(){let e=oa();window.open(e,"_blank")}function $a(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ua(){window.open(A.releasesPage,"_blank")}function Ga(){window.open(A.youtube,"_blank")}function Ja(){window.open(A.discordLink,"_blank")}function Qa(){window.open(A.githubPage,"_blank")}function Za(){window.open(A.docsPage,"_blank")}function Xa(e){return!e}function eo(e){return!e}function to(e){return!e}function ao(e){return[e,{disabled:!1}]}async function oo(){let e=document.getElementById("App");e&&await At({element:e,filename:document.title,prepare:Pt})}function no(){return window.print()}function io(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 so(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Pe,{size:14})})}function X(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Oe as a,qe as c,Ye as i,He as l,Ue as n,Ve as o,Na as r,Re as s,Va as t,Te as u};
|
|
1
|
+
import{s as we}from"./chunk-LvLJmgfZ.js";import{d as L,l as Ze,p as Xe,u as de}from"./useEvent-D91BmmQi.js";import{t as et}from"./react-Bj1aDYRI.js";import{$ as tt,E as ge,Sn as at,Vt as ot,_ as nt,_i as ce,_n as it,dr as st,et as lt,h as je,jr as rt,or as dt,rr as ct,t as ht,tr as pt,tt as ve,vn as mt,yn as ut}from"./cells-ArUhhHls.js";import{t as D}from"./compiler-runtime-B3qBwwSJ.js";import{n as ft,x as yt}from"./ai-model-dropdown-Dnf-CxbP.js";import{_ as T,d as Ce}from"./useEventListener-DGjKht0c.js";import{y as kt}from"./utils-DKaC_ndw.js";import{n as A,t as ze}from"./constants-tOPFFcLZ.js";import{S as he,h as bt,x as xt}from"./config-CmaJdl9U.js";import{t as wt}from"./jsx-runtime-Blw4afVn.js";import{o as gt}from"./alert-dialog-CXspBRlP.js";import{a as jt,c as vt,i as Ct,n as zt,r as Mt,s as Wt,t as St}from"./select--zcABebs.js";import{gt as _t}from"./JsonOutput-D1i8P1dG.js";import{c as Me,d as pe,n as Dt,o as At,r as me,t as Pt}from"./download-7EtMZf2Y.js";import{m as Nt}from"./form-BVnQnVQ2.js";import{t as It}from"./tooltip-DmqhBBs6.js";import{r as Et,t as ue}from"./button-BKVLeSTX.js";import{i as Lt,t as We}from"./strings-pfr2N700.js";import{r as H}from"./requests-9-v2bhoi.js";import{t as h}from"./createLucideIcon-w-Qo9n0R.js";import{a as Se,f as Tt,i as _e,m as Ht,p as De,u as Ae}from"./layout-Cudicm29.js";import{t as Pe}from"./check-B-sKate2.js";import{n as qt}from"./maps-B4xARV9R.js";import{r as Rt}from"./useCellActionButton-BiYBXHfb.js";import{t as Bt}from"./copy-DFMsQ6MJ.js";import{t as Vt}from"./eye-off-DgRJ-xBZ.js";import{t as Ft}from"./file-plus-corner-BjSB-E2p.js";import{t as J}from"./file-DaJ4JeZH.js";import{t as Ot}from"./github-CP61uL34.js";import{n as Yt,r as Kt,t as $t}from"./youtube-zkHE2QB5.js";import{i as Ut,n as Ne}from"./add-connection-dialog-ogwy8tvS.js";import{n as Gt,t as Jt}from"./square-BVY9SgWs.js";import{t as Qt}from"./image-CpSydGUq.js";import{t as Zt}from"./link-BCjh6ihR.js";import{r as Xt}from"./input-DjrybsRY.js";import{t as ea}from"./settings-D6Nc4lMz.js";import{y as ta}from"./textarea-DqzNK0s9.js";import{t as C}from"./use-toast-T0_cQDma.js";import{n as Ie,t as aa}from"./paths-Dfii2bN8.js";import{o as oa}from"./session-DDorezMU.js";import{a as na,c as ia,i as sa,n as la,r as ra}from"./dialog-CognbQV_.js";import{n as fe}from"./ImperativeModal-DSu22ncS.js";import{r as da,t as ca}from"./share-DkQqqFqC.js";import{n as Q}from"./copy-C8iWa1qI.js";import{r as ha}from"./useRunCells-DgBY-vh9.js";import{a as pa}from"./cell-link-D4UrIH9w.js";import{a as ma}from"./renderShortcut-Bjt8kSBs.js";import{t as ua}from"./icons-UbXYeuXE.js";import{t as fa}from"./links-wWTxfdQn.js";import{r as ya,t as Ee}from"./hooks-zQJ9iU_R.js";import{t as Le}from"./types-z6Sk3JCV.js";var ka=h("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),ba=h("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Te=h("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"}]]),He=h("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"}]]),qe=h("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"}]]),xa=h("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"}]]),wa=h("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"}]]),ga=h("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"}]]),Re=h("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"}]]),ja=h("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"}]]),va=h("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"}]]),Ca=h("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Be=h("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"}]]),za=h("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"}]]),Ma=h("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"}]]),Ve=h("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"}]]),Fe=D(),ye=we(et(),1),a=we(wt(),1),Z="https://static.marimo.app";const Wa=e=>{let t=(0,Fe.c)(25),{onClose:n}=e,[o,s]=(0,ye.useState)(""),{exportAsHTML:r}=H(),l=`${o}-${Math.random().toString(36).slice(2,6)}`,i=`${Z}/static/${l}`,d;t[0]!==r||t[1]!==n||t[2]!==l?(d=async v=>{v.preventDefault(),n();let N=await r({download:!1,includeCode:!0,files:Tt.INSTANCE.filenames()}),z=C({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Z}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:N,path:l})}).catch(()=>{z.dismiss(),C({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:A.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),z.dismiss(),C({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]=r,t[1]=n,t[2]=l,t[3]=d):d=t[3];let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(ia,{children:"Share static notebook"}),t[4]=m):m=t[4];let w;t[5]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(na,{children:[m,(0,a.jsxs)(ra,{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:Z,target:"_blank",children:Z}),"."]})]}),t[5]=w):w=t[5];let g;t[6]===Symbol.for("react.memo_cache_sentinel")?(g=v=>{s(v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=g):g=t[6];let u;t[7]===o?u=t[8]:(u=(0,a.jsx)(Xt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:g,required:!0,autoComplete:"off"}),t[7]=o,t[8]=u);let f;t[9]===i?f=t[10]:(f=(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)(Sa,{text:i}),(0,a.jsx)("span",{className:"text-primary",children:i})]})]}),t[9]=i,t[10]=f);let y;t[11]!==u||t[12]!==f?(y=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,f]}),t[11]=u,t[12]=f,t[13]=y):y=t[13];let k;t[14]===n?k=t[15]:(k=(0,a.jsx)(ue,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=k);let b;t[16]===i?b=t[17]:(b=(0,a.jsx)(ue,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await Q(i)},children:"Create"}),t[16]=i,t[17]=b);let x;t[18]!==k||t[19]!==b?(x=(0,a.jsxs)(sa,{children:[k,b]}),t[18]=k,t[19]=b,t[20]=x):x=t[20];let j;return t[21]!==d||t[22]!==x||t[23]!==y?(j=(0,a.jsx)(la,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[w,y,x]})}),t[21]=d,t[22]=x,t[23]=y,t[24]=j):j=t[24],j};var Sa=e=>{let t=(0,Fe.c)(8),[n,o]=ye.useState(!1),s;t[0]===e.text?s=t[1]:(s=Et.stopPropagation(async m=>{m.preventDefault(),await Q(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let r=s,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(Bt,{size:14,strokeWidth:1.5}),t[2]=l):l=t[2];let i;t[3]===r?i=t[4]:(i=(0,a.jsx)(ue,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:l}),t[3]=r,t[4]=i);let d;return t[5]!==n||t[6]!==i?(d=(0,a.jsx)(It,{content:"Copied!",open:n,children:i}),t[5]=n,t[6]=i,t[7]=d):d=t[7],d},_a=D();function Da(){let e=document.getElementsByClassName(ze.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=ce.findElement(t);if(!o){T.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:ce.parse(o.id)}}}return T.warn("No visible output area found for scroll anchor"),null}function Aa(e){if(!e){T.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(ce.create(e.cellId));if(!t){T.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${ze.outputArea}`)){T.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function Oe(){let e=(0,_a.c)(2),t=L(ve),n;return e[0]===t?n=e[1]:(n=()=>{let o=Da();t(s=>({mode:lt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Aa(o)})})},e[0]=t,e[1]=n),n}const Ye=Xe(!1);var Pa=D();const Na=()=>{let e=(0,Pa.c)(7),{selectedLayout:t}=Se(),{setLayoutView:n}=_e();if(he()&&!at("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=i=>n(i),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Wt,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(vt,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(zt,{children:(0,a.jsxs)(Mt,{children:[(0,a.jsx)(jt,{children:"View as"}),Le.map(Ea)]})}),e[3]=r):r=e[3];let l;return e[4]!==t||e[5]!==o?(l=(0,a.jsxs)(St,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,r]}),e[4]=t,e[5]=o,e[6]=l):l=e[6],l};function Ia(e){return(0,a.jsx)(Ke(e),{className:"h-4 w-4"})}function Ke(e){switch(e){case"vertical":return ja;case"grid":return Kt;case"slides":return Be;default:return Lt(e),Jt}}function $e(e){return We.startCase(e)}function Ea(e){return(0,a.jsx)(Ct,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Ia(e),(0,a.jsx)("span",{children:$e(e)})]})},e)}async function La(e){let{filename:t,preset:n,downloadPDF:o}=e;await o({filename:t,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var Ta=D();function Ha(e){let t=(0,Ta.c)(5),{openPrompt:n,closeModal:o}=fe(),{sendCopy:s}=H(),r;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(r=()=>{if(!e)return null;let l=aa.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ie.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:i=>{let d=l.join(Ie.dirname(e),i);s({source:e,destination:d}).then(()=>{o(),C({title:"Notebook copied",description:"A copy of the notebook has been created."}),fa(d)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=r):r=t[4],r}const qa=()=>{let{updateCellConfig:e}=ge(),{saveCellConfig:t}=H();return(0,ye.useCallback)(async()=>{let n=new ot,o=je(),s=o.cellIds.inOrderIds,r={};for(let i of s){if(o.cellData[i]===void 0)continue;let{code:d,config:m}=o.cellData[i];m.hide_code||n.isSupported(d)&&(r[i]={hide_code:!0})}let l=Ce.entries(r);if(l.length!==0){await t({configs:r});for(let[i,d]of l)e({cellId:i,config:d})}},[e])};var Ra=D();function Ue(){let e=(0,Ra.c)(4),{openConfirm:t}=fe(),n=L(bt),{sendRestart:o}=H(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{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)(gt,{onClick:async()=>{n({state:xt.CLOSING}),await o(),da()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Ba=D(),P=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Va(){var be,xe;let e=(0,Ba.c)(51),t=pa(),{openModal:n,closeModal:o}=fe(),{toggleApplication:s}=it(),{selectedPanel:r}=mt(),[l]=Ze(ve),i=de(tt),d=qa(),[m]=kt(),{updateCellConfig:w,undoDeleteCell:g,clearAllCellOutputs:u,addSetupCellIfDoesntExist:f,collapseAllCells:y,expandAllCells:k}=ge(),b=Ue(),x=ha(),j=Ha(t),v=L(Ye),N=L(ft),z=L(yt),{exportAsIPYNB:ee,exportAsMarkdown:te,readCode:I,saveCellConfig:ae,updateCellOutputs:M}=H(),W=ya(),oe=de(nt),ne=de(ht),{selectedLayout:q}=Se(),{setLayoutView:ie}=_e(),R=Oe(),B=((be=m.sharing)==null?void 0:be.html)??!0,V=((xe=m.sharing)==null?void 0:xe.wasm)??!0,ke=!he(),se=q==="slides",Ge=so,Je=io,F;e[0]!==t||e[1]!==W||e[2]!==M?(F=async c=>{let{preset:p,title:E}=c;if(!t){X();return}await Me(E,async re=>{await Ee({takeScreenshots:()=>W({progress:re}),updateCellOutputs:M}),await La({filename:t,preset:p,downloadPDF:Dt})})},e[0]=t,e[1]=W,e[2]=M,e[3]=F):F=e[3];let S=F,O;e[4]===S?O=e[5]:(O=async()=>{if(ke){await S({preset:"document",title:"Downloading Document PDF..."});return}let c=new Event("export-beforeprint"),p=new Event("export-afterprint");window.dispatchEvent(c),setTimeout(no,0),setTimeout(()=>window.dispatchEvent(p),0)},e[4]=S,e[5]=O);let Y=O,K;e[6]!==ee||e[7]!==t||e[8]!==W||e[9]!==M?(K=async()=>{if(!t){X();return}await Me("Downloading IPYNB...",async c=>{await Ee({takeScreenshots:()=>W({progress:c}),updateCellOutputs:M});let p=await ee({download:!1});me(new Blob([p],{type:"application/x-ipynb+json"}),pe.toIPYNB(document.title))})},e[6]=ee,e[7]=t,e[8]=W,e[9]=M,e[10]=K):K=e[10];let le=K,$;e[11]===Symbol.for("react.memo_cache_sentinel")?($=(0,a.jsx)(_t,{size:14,strokeWidth:1.5}),e[11]=$):$=e[11];let U;e[12]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)(De,{size:14,strokeWidth:1.5}),e[12]=U):U=e[12];let _;e[13]===t?_=e[14]:(_=async()=>{if(!t){X();return}await Ae({filename:t,includeCode:!0})},e[13]=t,e[14]=_);let G;return e[15]!==f||e[16]!==ne||e[17]!==u||e[18]!==o||e[19]!==y||e[20]!==j||e[21]!==S||e[22]!==k||e[23]!==te||e[24]!==t||e[25]!==Y||e[26]!==le||e[27]!==oe||e[28]!==d||e[29]!==se||e[30]!==i||e[31]!==n||e[32]!==I||e[33]!==b||e[34]!==x||e[35]!==ae||e[36]!==q||e[37]!==r||e[38]!==v||e[39]!==z||e[40]!==ie||e[41]!==N||e[42]!==B||e[43]!==V||e[44]!==_||e[45]!==s||e[46]!==R||e[47]!==g||e[48]!==w||e[49]!==l.mode?(G=[{icon:$,label:"Download",handle:P,dropdown:[{icon:U,label:"Download as HTML",handle:_},{icon:(0,a.jsx)(De,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){X();return}await Ae({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(ua,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let c=await te({download:!1});me(new Blob([c],{type:"text/plain"}),pe.toMarkdown(document.title))}},{icon:(0,a.jsx)(va,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:le},{icon:(0,a.jsx)(Ht,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let c=await I();me(new Blob([c.contents],{type:"text/plain"}),pe.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Qt,{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: ",ma("global.hideCode",!1)]}),handle:oo},se?{divider:!0,icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:P,dropdown:[{icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:Y},{icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:Je(!0),hidden:!ke,handle:async()=>{await S({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(J,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:Y}]},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Share",handle:P,hidden:!B&&!V,dropdown:[{icon:(0,a.jsx)(Nt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!B,handle:async()=>{n((0,a.jsx)(Wa,{onClose:o}))}},{icon:(0,a.jsx)(Zt,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!V,handle:async()=>{await Q(ca({code:(await I()).contents})),C({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:P,dropdown:ut.flatMap(c=>{let{type:p,Icon:E,hidden:re,additionalKeywords:Qe}=c;return re?[]:{label:We.startCase(p),rightElement:Ge(r===p),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),handle:()=>s(p),additionalKeywords:Qe}})},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Present as",handle:P,dropdown:[{icon:l.mode==="present"?(0,a.jsx)(ta,{size:14,strokeWidth:1.5}):(0,a.jsx)(Re,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{R()}},...Le.map((c,p)=>{let E=Ke(c);return{divider:p===0,label:$e(c),icon:(0,a.jsx)(E,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:q===c&&(0,a.jsx)(Pe,{size:14})}),handle:()=>{ie(c),l.mode==="edit"&&R()}}})]},{icon:(0,a.jsx)(wa,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||he(),handle:j},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await Q((await I()).contents),C({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!oe||i,handle:async()=>{let c=rt(je());await ae({configs:Ce.fromEntries(c.map(ao))});for(let p of c)w({cellId:p,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(qe,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{f({})}},{icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Ne,{onClose:o}))}},{icon:(0,a.jsx)(Ut,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Ne,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!ne||i,handle:()=>{g()}},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:b,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(xa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{x()}},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{u()}},{icon:(0,a.jsx)(Vt,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(ba,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:y,redundant:!0},{icon:(0,a.jsx)(ka,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:k,redundant:!0},{divider:!0,icon:(0,a.jsx)(He,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(to)},{icon:(0,a.jsx)(ga,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>z(eo)},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>N(Xa),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(qt,{size:14,strokeWidth:1.5}),label:"Resources",handle:P,dropdown:[{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Za},{icon:(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Qa},{icon:(0,a.jsx)(Yt,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Ja},{icon:(0,a.jsx)($t,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Ga},{icon:(0,a.jsx)(pt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Ua}]},{divider:!0,icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:$a},{icon:(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:Ka}].filter(Ya).map(Fa),e[15]=f,e[16]=ne,e[17]=u,e[18]=o,e[19]=y,e[20]=j,e[21]=S,e[22]=k,e[23]=te,e[24]=t,e[25]=Y,e[26]=le,e[27]=oe,e[28]=d,e[29]=se,e[30]=i,e[31]=n,e[32]=I,e[33]=b,e[34]=x,e[35]=ae,e[36]=q,e[37]=r,e[38]=v,e[39]=z,e[40]=ie,e[41]=N,e[42]=B,e[43]=V,e[44]=_,e[45]=s,e[46]=R,e[47]=g,e[48]=w,e[49]=l.mode,e[50]=G):G=e[50],G}function Fa(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Oa)}:e}function Oa(e){return!e.hidden}function Ya(e){return!e.hidden}function Ka(){let e=oa();window.open(e,"_blank")}function $a(){let e=document.baseURI.split("?")[0];window.open(e,"_self")}function Ua(){window.open(A.releasesPage,"_blank")}function Ga(){window.open(A.youtube,"_blank")}function Ja(){window.open(A.discordLink,"_blank")}function Qa(){window.open(A.githubPage,"_blank")}function Za(){window.open(A.docsPage,"_blank")}function Xa(e){return!e}function eo(e){return!e}function to(e){return!e}function ao(e){return[e,{disabled:!1}]}async function oo(){let e=document.getElementById("App");e&&await At({element:e,filename:document.title,prepare:Pt})}function no(){return window.print()}function io(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 so(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Pe,{size:14})})}function X(){C({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{Oe as a,qe as c,Ye as i,He as l,Ue as n,Ve as o,Na as r,Re as s,Va as t,Te 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-KI45dku7.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-D1i8P1dG.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-CBbUxOvL.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-BfHGr__b.js">
|
|
202
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
202
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-NDhbeu0E.js">
|
|
203
203
|
<link rel="modulepreload" crossorigin href="./assets/icons-UbXYeuXE.js">
|
|
204
204
|
<link rel="modulepreload" crossorigin href="./assets/floating-outline-B6Qyid7Q.js">
|
|
205
205
|
<link rel="modulepreload" crossorigin href="./assets/useAddCell-cC7JUC0q.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-CV8Wy3e4.js">
|
|
224
224
|
<link rel="modulepreload" crossorigin href="./assets/label-C89F4v17.js">
|
|
225
225
|
<link rel="modulepreload" crossorigin href="./assets/textarea-DqzNK0s9.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-BVnQnVQ2.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
|
@@ -186,7 +186,7 @@ const CellEditorInternal = ({
|
|
|
186
186
|
deleteCell: handleDelete,
|
|
187
187
|
saveNotebook: saveOrNameNotebook,
|
|
188
188
|
createManyBelow: (cells) => {
|
|
189
|
-
for (const code of
|
|
189
|
+
for (const code of cells.toReversed()) {
|
|
190
190
|
cellActions.createNewCell({
|
|
191
191
|
code,
|
|
192
192
|
before: false,
|
|
@@ -125,7 +125,7 @@ const SnippetViewer: React.FC<{ snippet: Snippet; onClose: () => void }> = ({
|
|
|
125
125
|
|
|
126
126
|
const handleInsertSnippet = () => {
|
|
127
127
|
// Add below last focused cell in reverse order
|
|
128
|
-
for (const section of
|
|
128
|
+
for (const section of snippet.sections.toReversed()) {
|
|
129
129
|
if (section.code) {
|
|
130
130
|
createNewCell({
|
|
131
131
|
code: section.code,
|
|
@@ -24,7 +24,7 @@ export const CellLinkList: React.FC<Props> = ({
|
|
|
24
24
|
skipScroll,
|
|
25
25
|
}) => {
|
|
26
26
|
const cellIndex = useCellIds();
|
|
27
|
-
const sortedCellIds =
|
|
27
|
+
const sortedCellIds = cellIds.toSorted((a, b) => {
|
|
28
28
|
return cellIndex.inOrderIds.indexOf(a) - cellIndex.inOrderIds.indexOf(b);
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -167,8 +167,7 @@ export function useMultiCellActionButtons(cellIds: CellId[]) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// Move cells in the appropriate order to maintain relative positions
|
|
170
|
-
const sortedCells =
|
|
171
|
-
direction === "up" ? cellIds : [...cellIds].toReversed();
|
|
170
|
+
const sortedCells = direction === "up" ? cellIds : cellIds.toReversed();
|
|
172
171
|
sortedCells.forEach((cellId) => {
|
|
173
172
|
moveCell({ cellId, before: direction === "up" });
|
|
174
173
|
});
|
|
@@ -177,7 +176,7 @@ export function useMultiCellActionButtons(cellIds: CellId[]) {
|
|
|
177
176
|
|
|
178
177
|
const sendSelectedCellsToTop = useEvent((cellIds: CellId[]) => {
|
|
179
178
|
// Send in reverse order to maintain relative positions
|
|
180
|
-
|
|
179
|
+
cellIds.toReversed().forEach((cellId) => {
|
|
181
180
|
sendToTop({ cellId });
|
|
182
181
|
});
|
|
183
182
|
});
|
|
@@ -401,7 +401,7 @@ export function useCellNavigationProps(
|
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
// Move cells in the appropriate order to maintain relative positions
|
|
404
|
-
|
|
404
|
+
cellIds.toReversed().forEach((cellId) => {
|
|
405
405
|
actions.moveCell({ cellId, before: false });
|
|
406
406
|
});
|
|
407
407
|
return true;
|
|
@@ -480,7 +480,7 @@ export function useCellNavigationProps(
|
|
|
480
480
|
}),
|
|
481
481
|
"cell.sendToTop": addSingleHandler((cellIds) => {
|
|
482
482
|
// Send in reverse order to maintain relative positions
|
|
483
|
-
|
|
483
|
+
cellIds.toReversed().forEach((cellId) => {
|
|
484
484
|
actions.sendToTop({ cellId });
|
|
485
485
|
});
|
|
486
486
|
return true;
|
|
@@ -167,7 +167,7 @@ const ConsoleOutputInternal = (props: Props): React.ReactNode => {
|
|
|
167
167
|
return null;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
const reversedOutputs =
|
|
170
|
+
const reversedOutputs = consoleOutputs.toReversed();
|
|
171
171
|
const isPdb = reversedOutputs.some(
|
|
172
172
|
(output) =>
|
|
173
173
|
typeof output.data === "string" && output.data.includes("(Pdb)"),
|
package/src/utils/mime-types.ts
CHANGED
|
@@ -151,7 +151,7 @@ export function sortByPrecedence<T>(
|
|
|
151
151
|
): [MimeType, T][] {
|
|
152
152
|
const unknownPrecedence = precedence.size;
|
|
153
153
|
|
|
154
|
-
return
|
|
154
|
+
return entries.toSorted((a, b) => {
|
|
155
155
|
const indexA = precedence.get(a[0]) ?? unknownPrecedence;
|
|
156
156
|
const indexB = precedence.get(b[0]) ?? unknownPrecedence;
|
|
157
157
|
return indexA - indexB;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as v}from"./chunk-LvLJmgfZ.js";import{t as w}from"./react-Bj1aDYRI.js";import{j as k}from"./cells-ArUhhHls.js";import{t as g}from"./compiler-runtime-B3qBwwSJ.js";import{t as N}from"./jsx-runtime-Blw4afVn.js";import{i as y,r as C,t as _}from"./popover-AtoFZ7i4.js";import{t as b}from"./badge-CufG8W4J.js";import{t as S}from"./use-toast-T0_cQDma.js";import{n as I}from"./copy-C8iWa1qI.js";import{t as j}from"./cell-link-D4UrIH9w.js";var O=g(),i=v(N(),1);const B=p=>{let e=(0,O.c)(18),{maxCount:n,cellIds:r,onClick:t,skipScroll:o}=p,m=k(),l,a,c;if(e[0]!==r||e[1]!==m||e[2]!==n||e[3]!==t||e[4]!==o){c=Symbol.for("react.early_return_sentinel");e:{let f;e[8]===m?f=e[9]:(f=(s,x)=>m.inOrderIds.indexOf(s)-m.inOrderIds.indexOf(x),e[8]=m,e[9]=f);let u=[...r].toSorted(f);if(r.length===0){let s;e[10]===Symbol.for("react.memo_cache_sentinel")?(s=(0,i.jsx)("div",{className:"text-muted-foreground",children:"--"}),e[10]=s):s=e[10],c=s;break e}let h;e[11]!==r.length||e[12]!==t||e[13]!==o?(h=(s,x)=>(0,i.jsxs)("span",{className:"truncate",children:[(0,i.jsx)(j,{variant:"focus",cellId:s,skipScroll:o,className:"whitespace-nowrap",onClick:t?()=>t(s):void 0},s),x<r.length-1&&", "]},s),e[11]=r.length,e[12]=t,e[13]=o,e[14]=h):h=e[14],l=u.slice(0,n).map(h),a=r.length>n&&(0,i.jsxs)(_,{children:[(0,i.jsx)(y,{asChild:!0,children:(0,i.jsxs)("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",r.length-n," more"]})}),(0,i.jsx)(C,{className:"w-auto",children:(0,i.jsx)("div",{className:"flex flex-col gap-1 py-1",children:u.slice(n).map(s=>(0,i.jsx)(j,{variant:"focus",cellId:s,className:"whitespace-nowrap",onClick:t?()=>t(s):void 0},s))})})]})}e[0]=r,e[1]=m,e[2]=n,e[3]=t,e[4]=o,e[5]=l,e[6]=a,e[7]=c}else l=e[5],a=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let d;return e[15]!==l||e[16]!==a?(d=(0,i.jsxs)(i.Fragment,{children:[l,a]}),e[15]=l,e[16]=a,e[17]=d):d=e[17],d};var F=g();w();const q=p=>{let e=(0,F.c)(15),n,r,t,o;e[0]===p?(n=e[1],r=e[2],t=e[3],o=e[4]):({name:r,declaredBy:n,onClick:t,...o}=p,e[0]=p,e[1]=n,e[2]=r,e[3]=t,e[4]=o);let m=n.length>1?"destructive":"outline",l;e[5]!==r||e[6]!==t?(l=async d=>{if(t){t(d);return}await I(r),S({title:"Copied to clipboard"})},e[5]=r,e[6]=t,e[7]=l):l=e[7];let a;e[8]!==r||e[9]!==m||e[10]!==l?(a=(0,i.jsx)(b,{title:r,variant:m,className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:l,children:r}),e[8]=r,e[9]=m,e[10]=l,e[11]=a):a=e[11];let c;return e[12]!==o||e[13]!==a?(c=(0,i.jsx)("div",{className:"max-w-[130px]",...o,children:a}),e[12]=o,e[13]=a,e[14]=c):c=e[14],c};export{B as n,q as t};
|