import{s as g}from"./chunk-DZLz74EQ.js";import{d as k,l as v}from"./jotai-DDOP7CKM.js";import{$n as w,E as y,dr as F,h as p,nt as x,sr as D}from"./cells-B6jS0AIj.js";import{n as E}from"./jsx-runtime-DvsdsEjx.js";import{u as H}from"./hotkeys-Lbk6RHir.js";import{r as V}from"./requests-D3Z6okhb.js";import{o as _}from"./dist-C13bkrcz.js";import{n as i}from"./useEvent-d8iQXgui.js";var u=g(E(),1);const I=k(!1);function $(){let r=(0,u.c)(2),t=f(),n;return r[0]===t?n=r[1]:(n=()=>t(F(p())),r[0]=t,r[1]=n),i(n)}function j(r){let t=(0,u.c)(3),n=f(),o;return t[0]!==r||t[1]!==n?(o=()=>{r!==void 0&&n([r])},t[0]=r,t[1]=n,t[2]=o):o=t[2],i(o)}function q(){let r=(0,u.c)(2),t=f(),n;return r[0]===t?n=r[1]:(n=()=>t(D(p())),r[0]=t,r[1]=n),i(n)}function f(){let r=(0,u.c)(4),{prepareForRun:t}=y(),{sendRun:n}=V(),o=v(I),e;return r[0]!==t||r[1]!==n||r[2]!==o?(e=async s=>{if(s.length===0)return;let c=p();return o(!0),b({cellIds:s,sendRun:n,prepareForRun:t,notebook:c})},r[0]=t,r[1]=n,r[2]=o,r[3]=e):e=r[3],i(e)}async function b({cellIds:r,sendRun:t,prepareForRun:n,notebook:o}){var d,h,R;if(r.length===0)return;let{cellHandles:e,cellData:s}=o,c=[];for(let a of r){let l=(h=(d=e[a])==null?void 0:d.current)==null?void 0:h.editorView,m;l?(w(l)!=="markdown"&&_(l),m=x(l)):m=((R=s[a])==null?void 0:R.code)||"",c.push(m),n({cellId:a})}await t({cellIds:r,codes:c}).catch(a=>{H.error(a)})}export{f as a,j as i,b as n,$ as o,q as r,I as t};
