import{n as c}from"./jotai-DDOP7CKM.js";import{Rr as d,Zn as i,x as f}from"./cells-B6jS0AIj.js";import{t as s}from"./requests-D3Z6okhb.js";function m({moduleName:t,variableName:l,onAddImport:r,appStore:a=c}){if(l in a.get(i))return!1;let{cellData:o,cellIds:e}=a.get(f),n=RegExp(`import[ 	]+${t}[ 	]+as[ 	]+${l}`,"g");for(let u of e.inOrderIds)if(n.test(o[u].code))return!1;return r(`import ${t} as ${l}`),!0}function I({autoInstantiate:t,createNewCell:l,fromCellId:r,before:a}){let o=s(),e=null;return m({moduleName:"marimo",variableName:"mo",onAddImport:n=>{e=d.create(),l({cellId:r??"__end__",before:a??!1,code:n,lastCodeRun:t?n:void 0,newCellId:e,skipIfCodeExists:!0,autoFocus:!1}),t&&o.sendRun({cellIds:[e],codes:[n]})}})?e:null}function p({autoInstantiate:t,createNewCell:l,fromCellId:r}){let a=s(),o=null;return m({moduleName:"altair",variableName:"alt",onAddImport:e=>{o=d.create(),l({cellId:r??"__end__",before:!1,code:e,lastCodeRun:t?e:void 0,newCellId:o,skipIfCodeExists:!0,autoFocus:!1}),t&&a.sendRun({cellIds:[o],codes:[e]})}})?o:null}export{I as n,p as t};
