const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-By4rFZwg.js","./micromark-factory-space-Dx_STMJD.js","./chunk-LvLJmgfZ.js","./katex-Di-siZEY.js"])))=>i.map(i=>d[i]);
import{s as A}from"./chunk-LvLJmgfZ.js";import{u as X}from"./useEvent-D91BmmQi.js";import{t as Y}from"./react-Bj1aDYRI.js";import{E as Z,Ft as tt,Jt as et,__tla as at}from"./cells-CJLUCcQg.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{c as rt}from"./utils-BWBBpCkT.js";import{t as nt}from"./jsx-runtime-Blw4afVn.js";import{t as E}from"./button-DDGiD1NW.js";import{st}from"./dist-12S8I4CH.js";import{t as ot}from"./createLucideIcon-w-Qo9n0R.js";import{n as lt,t as it,__tla as ct}from"./LazyAnyLanguageCodeMirror-A-Ant1Ad.js";import{t as ut}from"./preload-helper-TXkS1QI3.js";import{r as mt}from"./useTheme-Bxv9B31g.js";import{n as dt}from"./copy-Bxb1_Gtw.js";import{a as ft,c as pt,l as x,s as ht,__tla as gt}from"./chunk-5FQGJX7Z-CYQpNADu.js";import{r as _t}from"./html-to-image-CN9yTa5s.js";import{o as yt}from"./focus-B6HBbAwF.js";import{n as xt}from"./useAsyncData-Bg5iAViP.js";let U,$,I,T,z,B,L,b,O,w,j,P,bt=Promise.all([(()=>{try{return at}catch{}})(),(()=>{try{return ct}catch{}})(),(()=>{try{return gt}catch{}})()]).then(async()=>{var N;T=ot("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),U=function(e,t){return`data:${t};base64,${e}`},P=function(e){return e.startsWith("data:")&&e.includes(";base64,")},B=function(e){return e.split(",")[1]};function q(e){let t=globalThis.atob(e),a=t.length,r=new Uint8Array(a);for(let n=0;n<a;n++)r[n]=t.charCodeAt(n);return r}w=Uint8Array.fromBase64??q,b=function(e){let t=w(e);return new DataView(t.buffer)};function D(e){let t="",a=e.length;for(let r=0;r<a;r++)t+=String.fromCharCode(e[r]);return globalThis.btoa(t)}const M="toBase64"in Uint8Array.prototype?e=>e.toBase64():D;$=function(e){return M(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},I=function(e){return(e.buffers??[]).map(b)};var v=S(),d=A(Y(),1),C={},k={};z=function(e){let t=(0,v.c)(6),[a,r]=(0,d.useState)(C[e]??!1),n,s;t[0]!==e||t[1]!==a?(n=()=>{C[e]=a},s=[e,a],t[0]=e,t[1]=a,t[2]=n,t[3]=s):(n=t[2],s=t[3]),(0,d.useEffect)(n,s);let o;return t[4]===a?o=t[5]:(o=[a,r],t[4]=a,t[5]=o),o},O=function(e){let t=(0,v.c)(6),[a,r]=(0,d.useState)(k[e]??!1),n,s;t[0]!==e||t[1]!==a?(n=()=>{k[e]=a},s=[e,a],t[0]=e,t[1]=a,t[2]=n,t[3]=s):(n=t[2],s=t[3]),(0,d.useEffect)(n,s);let o;return t[4]===a?o=t[5]:(o=[a,r],t[4]=a,t[5]=o),o},L=function(e){return e==null||e.data==null||e.data===""};var g=S(),l=A(nt(),1),R=[st.lineWrapping];function V(e,t){return e?e==="python"?{language:e,code:t}:e==="sql"?{language:"python",code:tt.fromQuery(t)}:e==="markdown"?{language:"python",code:et.fromMarkdown(t)}:e==="shell"||e==="bash"?{language:"python",code:`import subprocess
subprocess.run("${t}")`}:{language:"python",code:`_${e} = """
${t}
"""`}:{language:"python",code:t}}var W=e=>{let t=(0,g.c)(9),{code:a,language:r}=e,{createNewCell:n}=Z(),s=yt(),o=X(rt),i;t[0]!==o||t[1]!==a||t[2]!==n||t[3]!==r||t[4]!==s?(i=()=>{let f=V(r,a);r==="sql"&&_t({autoInstantiate:o,createNewCell:n,fromCellId:s}),n({code:f.code,before:!1,cellId:s??"__end__"})},t[0]=o,t[1]=a,t[2]=n,t[3]=r,t[4]=s,t[5]=i):i=t[5];let c=i,m;t[6]===Symbol.for("react.memo_cache_sentinel")?(m=(0,l.jsx)(lt,{className:"ml-2 h-4 w-4"}),t[6]=m):m=t[6];let u;return t[7]===c?u=t[8]:(u=(0,l.jsxs)(E,{size:"xs",variant:"outline",onClick:c,children:["Add to Notebook",m]}),t[7]=c,t[8]=u),u},F=e=>{let t=(0,g.c)(17),{code:a,language:r}=e,{theme:n}=mt(),[s,o]=(0,d.useState)(a);s!==a&&o(a);let i;t[0]===s?i=t[1]:(i=async()=>{await dt(s)},t[0]=s,t[1]=i);let c=i,m=n==="dark"?"dark":"light",u;t[2]!==r||t[3]!==m||t[4]!==s?(u=(0,l.jsx)(d.Suspense,{children:(0,l.jsx)(it,{theme:m,language:r,hideUnsupportedLanguageErrors:!0,className:"cm border rounded overflow-hidden",extensions:R,value:s,onChange:o})}),t[2]=r,t[3]=m,t[4]=s,t[5]=u):u=t[5];let f;t[6]===c?f=t[7]:(f=(0,l.jsx)(J,{size:"xs",variant:"outline",onClick:c,children:"Copy"}),t[6]=c,t[7]=f);let p;t[8]!==r||t[9]!==s?(p=(0,l.jsx)(W,{code:s,language:r}),t[8]=r,t[9]=s,t[10]=p):p=t[10];let h;t[11]!==f||t[12]!==p?(h=(0,l.jsxs)("div",{className:"flex justify-end mt-2 space-x-2",children:[f,p]}),t[11]=f,t[12]=p,t[13]=h):h=t[13];let _;return t[14]!==u||t[15]!==h?(_=(0,l.jsxs)("div",{className:"relative",children:[u,h]}),t[14]=u,t[15]=h,t[16]=_):_=t[16],_},J=e=>{let t=(0,g.c)(9),a,r;t[0]===e?(a=t[1],r=t[2]):({onClick:a,...r}=e,t[0]=e,t[1]=a,t[2]=r);let[n,s]=(0,d.useState)(!1),o;t[3]===a?o=t[4]:(o=m=>{a==null||a(m),s(!0),setTimeout(()=>s(!1),1e3)},t[3]=a,t[4]=o);let i=n?"Copied":"Copy",c;return t[5]!==r||t[6]!==o||t[7]!==i?(c=(0,l.jsx)(E,{...r,onClick:o,children:i}),t[5]=r,t[6]=o,t[7]=i,t[8]=c):c=t[8],c},Q={...x,attributes:{...x.attributes,"*":[...((N=x.attributes)==null?void 0:N["*"])??[],"className"]}},G=Object.values({...ft,sanitize:[pt,Q]}),H={code:({children:e,className:t})=>{let a=t==null?void 0:t.replace("language-","");if(a&&typeof e=="string"){let r=e.trim();return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-xs text-muted-foreground pl-1",children:a}),(0,l.jsx)(F,{code:r,language:a})]})}return(0,l.jsx)("code",{className:t,children:e})}},y,K=()=>{let{data:e}=xt(async()=>y||(y={math:(await ut(()=>import("./dist-By4rFZwg.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3]),import.meta.url)).math},y),[]);return e};j=(0,d.memo)(e=>{let t=(0,g.c)(3),{content:a}=e,r=K(),n;return t[0]!==a||t[1]!==r?(n=(0,l.jsx)(ht,{components:H,plugins:r,rehypePlugins:G,className:"mo-markdown-renderer",children:a}),t[0]=a,t[1]=r,t[2]=n):n=t[2],n}),j.displayName="MarkdownRenderer"});export{bt as __tla,U as a,$ as c,I as d,T as f,z as i,B as l,L as n,b as o,O as r,w as s,j as t,P as u};
