const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-CJIOLS6O.js","./micromark-factory-space-BygYYKhs.js","./chunk-LvLJmgfZ.js","./katex-BE4UDS50.js"])))=>i.map(i=>d[i]);
import{s as v}from"./chunk-LvLJmgfZ.js";import{u as G}from"./useEvent-D91BmmQi.js";import{t as J}from"./react-Bj1aDYRI.js";import{D as K,Ht as Q,Zt as Y,__tla as Z}from"./cells-BsaJrRWi.js";import{t as N}from"./compiler-runtime-B3qBwwSJ.js";import{c as X}from"./utils-CvI-39U6.js";import{t as tt}from"./jsx-runtime-BqBOg78p.js";import{t as A}from"./button-BbCh-29a.js";import{at as et}from"./dist-BrR4M-k3.js";import{t as rt}from"./createLucideIcon-D5guW7EU.js";import{n as at,t as nt,__tla as ot}from"./LazyAnyLanguageCodeMirror-BEvXb3VX.js";import{t as st}from"./preload-helper-BPPi7vOr.js";import{r as lt}from"./useTheme-CI2eq4XN.js";import{n as it}from"./copy-LK56fFow.js";import{o as ct,__tla as ut}from"./chunk-5FQGJX7Z-D9iBG0F7.js";import{r as mt}from"./html-to-image-BWL3Ct4n.js";import{o as dt}from"./focus-q38vUCl-.js";import{n as ft}from"./useAsyncData-bgszE9F0.js";let S,E,U,I,j,T,$,B,C,D,k,L,pt=Promise.all([(()=>{try{return Z}catch{}})(),(()=>{try{return ot}catch{}})(),(()=>{try{return ut}catch{}})()]).then(async()=>{let y,d,x,b;I=rt("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),y=N(),d=v(J(),1),x={},b={},U=function(e){let t=(0,y.c)(6),[r,a]=(0,d.useState)(x[e]??!1),n,o;t[0]!==e||t[1]!==r?(n=()=>{x[e]=r},o=[e,r],t[0]=e,t[1]=r,t[2]=n,t[3]=o):(n=t[2],o=t[3]),(0,d.useEffect)(n,o);let s;return t[4]===r?s=t[5]:(s=[r,a],t[4]=r,t[5]=s),s},L=function(e){let t=(0,y.c)(6),[r,a]=(0,d.useState)(b[e]??!1),n,o;t[0]!==e||t[1]!==r?(n=()=>{b[e]=r},o=[e,r],t[0]=e,t[1]=r,t[2]=n,t[3]=o):(n=t[2],o=t[3]),(0,d.useEffect)(n,o);let s;return t[4]===r?s=t[5]:(s=[r,a],t[4]=r,t[5]=s),s},T=function(e){return e==null||e.data==null||e.data===""},$=function(e,t){return`data:${t};base64,${e}`},D=function(e){return e.startsWith("data:")&&e.includes(";base64,")},B=function(e){return e.split(",")[1]};function q(e){let t=globalThis.atob(e),r=t.length,a=new Uint8Array(r);for(let n=0;n<r;n++)a[n]=t.charCodeAt(n);return a}j=Uint8Array.fromBase64??q,C=function(e){let t=j(e);return new DataView(t.buffer)};function z(e){let t="",r=e.length;for(let a=0;a<r;a++)t+=String.fromCharCode(e[a]);return globalThis.btoa(t)}const M="toBase64"in Uint8Array.prototype?e=>e.toBase64():z;S=function(e){return M(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},E=function(e){return(e.buffers??[]).map(C)};var g=N(),l=v(tt(),1),O=[et.lineWrapping];function P(e,t){return e?e==="python"?{language:e,code:t}:e==="sql"?{language:"python",code:Q.fromQuery(t)}:e==="markdown"?{language:"python",code:Y.fromMarkdown(t)}:e==="shell"||e==="bash"?{language:"python",code:`import subprocess
subprocess.run("${t}")`}:{language:"python",code:`_${e} = """
${t}
"""`}:{language:"python",code:t}}var R=e=>{let t=(0,g.c)(9),{code:r,language:a}=e,{createNewCell:n}=K(),o=dt(),s=G(X),i;t[0]!==s||t[1]!==r||t[2]!==n||t[3]!==a||t[4]!==o?(i=()=>{let f=P(a,r);a==="sql"&&mt({autoInstantiate:s,createNewCell:n,fromCellId:o}),n({code:f.code,before:!1,cellId:o??"__end__"})},t[0]=s,t[1]=r,t[2]=n,t[3]=a,t[4]=o,t[5]=i):i=t[5];let c=i,m;t[6]===Symbol.for("react.memo_cache_sentinel")?(m=(0,l.jsx)(at,{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)(A,{size:"xs",variant:"outline",onClick:c,children:["Add to Notebook",m]}),t[7]=c,t[8]=u),u},V=e=>{let t=(0,g.c)(17),{code:r,language:a}=e,{theme:n}=lt(),[o,s]=(0,d.useState)(r);o!==r&&s(r);let i;t[0]===o?i=t[1]:(i=async()=>{await it(o)},t[0]=o,t[1]=i);let c=i,m=n==="dark"?"dark":"light",u;t[2]!==a||t[3]!==m||t[4]!==o?(u=(0,l.jsx)(d.Suspense,{children:(0,l.jsx)(nt,{theme:m,language:a,hideUnsupportedLanguageErrors:!0,className:"cm border rounded overflow-hidden",extensions:O,value:o,onChange:s})}),t[2]=a,t[3]=m,t[4]=o,t[5]=u):u=t[5];let f;t[6]===c?f=t[7]:(f=(0,l.jsx)(W,{size:"xs",variant:"outline",onClick:c,children:"Copy"}),t[6]=c,t[7]=f);let p;t[8]!==a||t[9]!==o?(p=(0,l.jsx)(R,{code:o,language:a}),t[8]=a,t[9]=o,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],_},W=e=>{let t=(0,g.c)(9),r,a;t[0]===e?(r=t[1],a=t[2]):({onClick:r,...a}=e,t[0]=e,t[1]=r,t[2]=a);let[n,o]=(0,d.useState)(!1),s;t[3]===r?s=t[4]:(s=m=>{r==null||r(m),o(!0),setTimeout(()=>o(!1),1e3)},t[3]=r,t[4]=s);let i=n?"Copied":"Copy",c;return t[5]!==a||t[6]!==s||t[7]!==i?(c=(0,l.jsx)(A,{...a,onClick:s,children:i}),t[5]=a,t[6]=s,t[7]=i,t[8]=c):c=t[8],c},H={code:({children:e,className:t})=>{let r=t==null?void 0:t.replace("language-","");if(r&&typeof e=="string"){let a=e.trim();return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-xs text-muted-foreground pl-1",children:r}),(0,l.jsx)(V,{code:a,language:r})]})}return(0,l.jsx)("code",{className:t,children:e})}},w,F=()=>{let{data:e}=ft(async()=>w||(w={math:(await st(()=>import("./dist-CJIOLS6O.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3]),import.meta.url)).math},w),[]);return e};k=(0,d.memo)(e=>{let t=(0,g.c)(3),{content:r}=e,a=F(),n;return t[0]!==r||t[1]!==a?(n=(0,l.jsx)(ct,{components:H,plugins:a,className:"mo-markdown-renderer",children:r}),t[0]=r,t[1]=a,t[2]=n):n=t[2],n}),k.displayName="MarkdownRenderer"});export{pt as __tla,S as a,E as c,U as d,I as f,j as i,T as l,$ as n,B as o,C as r,D as s,k as t,L as u};
