+ ${b}
+ ${l&&"pkg"===s.name?i.html`<${go} value=${null==o||null===(r=o.terminal_outputs)||void 0===r?void 0:r.nbpkg_sync} />`:l&&"backend_launch"===s.name?i.html`<${go} value=${a} />`:void 0}
+ `},ko=e=>/^\d+$/.test(e),Eo=(e,t)=>{const n=_o.indexOf(e.name),o=_o.indexOf(t.name);if(-1===n&&-1===o)return null!=e.started_at||null!=t.started_at?(e.started_at??1/0)-(t.started_at??1/0):ko(e.name)&&ko(t.name)?parseInt(e.name)-parseInt(t.name):e.name.localeCompare(t.name);{let e=e=>-1===e?1/0:e;return e(n)-e(o)}},$o=e=>null!=e.finished_at,xo=e=>null!=e.started_at,So=e=>xo(e)&&!$o(e),No=e=>Object.values(e.subtasks).reduce(((e,t)=>e+No(t)),$o(e)?1:0),Co=e=>Object.values(e.subtasks).reduce(((e,t)=>e+Co(t)),1),Ao=(e,t,n,o={})=>({name:e,subtasks:o,timing:"local",started_at:i.useMemo((()=>t||n?Date.now()/1e3:null),[t||n]),finished_at:i.useMemo((()=>n?Date.now()/1e3:null),[n])}),Mo=(e,t)=>{const n=i.useRef(t);i.useEffect((()=>{let o=e(n.current);return n.current=t,o}),t)};i=r("cNaMA");de=r("4zMEb");var Oo=r("41Mhf");const To={wait_for_user:0,requesting:.4,created:.6,responded:.7,notebook_running:.9,ready:1},Ro=e=>e.endsWith("/")?e:e+"/",Do=e=>fetch(`https://stats.plutojl.org/count?p=/${e}&s=${screen.width},${screen.height},${devicePixelRatio}#skip_sw`,{cache:"no-cache"}).catch((()=>{})),Lo=async({setStatePromise:e,connect:t,launch_params:n})=>{try{Do("binder-start"),await e(le((e=>{e.backend_launch_phase=To.requesting,e.disable_ui=!1,e.notebook.status_tree=null})));const{binder_session_url:o,binder_session_token:a}=await((e,{on_log:t})=>new Promise(((n,o)=>{console.log("Starting binder connection to",e);try{let a=new EventSource(e);a.onerror=t=>{console.error("Binder error: Lost connection to "+e,t),a.close(),o(t)};let r=null,i="",s=e=>{console.log("Binder: ",e,` at ${(new Date).toLocaleTimeString()}`),i=`${i}${e}\n`,t(i)};a.onmessage=t=>{let i=JSON.parse(t.data);switch(i.phase&&i.phase!==r&&(r=i.phase.toLowerCase(),s(`\n\n⏱️ Binder subphase: ${r}\n`)),i.message&&s(i.message.replace("] ","]\n")),i.phase){case"failed":console.error("Binder error: Failed to build",e,i),a.close(),o(new Error(i));break;case"ready":a.close(),n({binder_session_url:Ro(i.url)+"pluto/",binder_session_token:i.token})}}}catch(e){console.error(e),o("Failed to open event source the mybinder.org. This probably means that the URL is invalid.")}})))(n.binder_url.replace("mybinder.org/v2/","mybinder.org/build/"),{on_log:t=>e(le((e=>{e.backend_launch_logs=t})))}),r=e=>Oo.with_query_params(e,{token:a});console.log("Binder URL:",r(o)),window.shutdown_binder=()=>{fetch(r(new URL("../api/shutdown",o)),{method:"POST"})},await e(le((e=>{e.backend_launch_phase=To.created,e.binder_session_url=o,e.binder_session_token=a}))),await fetch(r(o)),await e(le((e=>{e.backend_launch_phase=To.responded})));let i=async()=>{const e=r(Oo.with_query_params(new URL("notebookupload",o),{name:new URLSearchParams(window.location.search).get("name"),execution_allowed:"true"}));return console.log("downloading locally and uploading ",e,n.notebookfile),fetch(e,{method:"POST",body:await(await fetch(new Request(n.notebookfile,{integrity:n.notebookfile_integrity}))).arrayBuffer()})},s=async(e,t)=>{const n=Oo.with_query_params(new URL("open",o),{[e]:t});return console.log(`open ${e}:`,n),fetch(r(n),{method:"POST"})},l=(e,t)=>()=>s(e,t),c=n.notebookfile.startsWith("data:")?[i]:[l("path",n.notebookfile),l("url",new URL(n.notebookfile,window.location.href).href),i],d=new Response;for(let e of c)if(d=await e(),d.ok)break;if(!d.ok){let e=await d.blob();return void(window.location.href=URL.createObjectURL(e))}const u=await d.text(),p=r(Oo.with_query_params(new URL("edit",o),{id:u}));console.info("notebook_id:",u),await e(le((e=>{e.notebook.notebook_id=u,e.backend_launch_phase=To.notebook_running,e.refresh_target=p}))),console.log("Connecting WebSocket");const m=t(r(new URL("channels",de.ws_address_from_base(o))));await de.timeout_promise(m,2e4).catch((e=>{console.error("Failed to establish connection within 20 seconds. Navigating to the edit URL directly.",e),window.parent.location.href=p}))}catch(e){console.error("Failed to initialize binder!",e),alert("Something went wrong! 😮\n\nWe failed to initialize the binder connection. Please try again with a different browser, or come back later.")}};var Io=r("hrGZZ");const Po=e=>window.dispatchEvent(new CustomEvent("open_bottom_right_panel",{detail:e}));let jo=({desired_doc_query:e,on_update_doc_query:t,notebook:n,connected:o,backend_launch_phase:a,backend_launch_logs:r,sanitize_html:s=!0})=>{let l=i.useRef();const c=i.useRef(!1),[d,u]=i.useState(null),p=null==d;Io.useEventListener(window,"open_bottom_right_panel",(e=>{console.log(e.detail),c.current=!1,u(e.detail),"none"===window.getComputedStyle(l.current).display&&alert("This browser window is too small to show docs.\n\nMake the window bigger, or try zooming out.")}),[u]);const m=Uo(n,a),[g,h]=i.useMemo((()=>null==m?[0,0]:[Co(m)-1,No(m)-($o(m)?1:0)]),[m]),f=h{let t=i.useContext(ye);const[n,o]=i.useState(0);return i.useEffect((()=>{if(e){let e=async()=>{let e=()=>t.send("current_time").then((e=>e.message.time)),n=()=>Date.now()/1e3;for(let t=0;t<16;t++)await e();let a=await n(),r=await e(),i=await e(),s=(a+await n())/2-(r+i)/2;isNaN(s)||o(s)};e();let n=setInterval(e,6e4);return()=>clearInterval(n)}}),[e]),n})({connected:o});return i.html`
+
+ `};const Bo=(e,t)=>{const[n,o]=i.useState(!1);return i.useEffect((()=>{if(e){let e=setTimeout((()=>{o(!0)}),t);return()=>clearTimeout(e)}o(!1)}),[e]),n},Uo=(e,t)=>{var n;const o=Fo(t);return null==t?e.status_tree:{name:"notebook",started_at:0,finished_at:null,subtasks:{...null===(n=e.status_tree)||void 0===n?void 0:n.subtasks,backend_launch:o}}},Fo=e=>{let t=e??-1;const n=Object.fromEntries(["requesting","created","responded","notebook_running"].map((e=>{let n=To[e],o=`backend_${e}`;return[o,Ao(o,t>=n,t>n)]})));return Ao("backend_launch",null!=e&&e>To.wait_for_user,e===To.ready,n)};let{autocompletion:zo,completionKeymap:qo,completionStatus:Ho,acceptCompletion:Wo}=St.autocomplete;const Go=(e,t)=>e.state.field(Ko).active.find((e=>e.source==t));let Ko=zo()[0];const Zo=St.StateEffect.define(),Vo=St.StateField.define({create:()=>!1,update(e,t){var n,o;for(let e of t.effects)if(e.is(Zo))return!0;return(null==(null===(n=t.startState.field(Ko,!1))||void 0===n?void 0:n.open)||null!=(null===(o=t.state.field(Ko,!1))||void 0===o?void 0:o.open))&&((null==t.startState.field(Ko,!1).open||t.startState.field(Ko,!1)===t.state.field(Ko,!1))&&e)}});const Qo=[{key:"Tab",run:e=>{if(Wo(e))return!0;if(e.state.readOnly)return!1;let t=e.state.selection.main,n=e.state.sliceDoc(t.from-1,t.from);return!!t.empty&&(!/^(\t| |\n|\=|\)|)$/.test(n)&&(e.dispatch({effects:Zo.of(10)}),St.autocomplete.startCompletion(e)))}},{key:"?",run:e=>{var t;return!!((null===(t=e.state.field(Ko,!1))||void 0===t?void 0:t.open)??!1)&&(Po("docs"),!0)}},{key:".",run:e=>(Wo(e),!1)}];let Xo=e=>St.EditorView.updateListener.of((t=>{let n=t.state.field(Ko,!1),o=null==n?void 0:n.open;if(null==o)return;let a=o.options[o.selected],r=a.completion.apply??a.completion.label;if("string"!=typeof r)return;const i=Go(t.view,a.source);if(!(null==i?void 0:i.from))return;const s=i.from,l=Math.min(i.to,t.state.doc.length);let c=t.state.update({changes:{from:s,to:l,insert:r}}),d=zn(c.state);null!=d&&e(d)}));let Yo=e=>async t=>{let n=t.state.sliceDoc(0,t.pos),o=await e({text:n});if(!o)return null;let{start:a,stop:r,results:i}=o,s=!function(e){const t=St.syntaxTree(e.state).resolve(e.pos);return null!=t&&("TripleString"===t.name||"String"===t.name)}(t);return{from:a,to:r,filter:!1,options:i.map((([e,t,n,o,a,r])=>({label:e,apply:r&&s?r:e,detail:r??void 0})))}},Jo=e=>/^[@a-zA-Z_][a-zA-Z0-9!_]*\"?$/.test(e)?null:":"===e?`:(${e})`:`:${e}`;const ea=function*(e,t,n){let o=0;for(let[a,{valid_from:r}]of e.entries())!t.has(a)&&r{const t=Yo(e),n=(e=>async t=>{let n=t.state.sliceDoc(0,t.pos),o=(e=>e.matchBefore(/\.\:[^\s"'`()\[\].]*/))(t);o&&(n=n.slice(0,o.from+1)+n.slice(o.from+2));let a=await e({text:n});if(!a)return null;let{start:r,stop:i,results:s}=a;o&&(i+=1);const l=t.state.field(Pn).definitions,c=new Set;let d="."===n.slice(0,r).slice(-1);return{from:r,to:i,options:[...s.map((([e,t,n,o,a],r)=>{let i=d?Jo(e)??e:e;return l.has(e)&&c.add(e),{label:e,apply:i,type:ve.cl({c_notexported:!n,[`c_${t}`]:null!=t,[`completion_${a}`]:null!=a,c_from_notebook:o})??void 0,boost:50-r/s.length}})),...s.filter((([e])=>d&&null!=Jo(e))).map((([e,t,n],o)=>{let a=Jo(e)??"";return{label:a,apply:a,type:(n?"":"c_notexported ")+(null==t?"":"c_"+t),boost:-99-o/s.length,is_not_exported:!n}})),...Array.from(ea(l,c,t.pos))]}})(e);return e=>{let o=(e=>e.matchBefore(/\\[^\s"'.`]*/))(e)||(e=>e.matchBefore(/~\//))(e);return null===o?n(e):t(e)}},na=async e=>{const t=await St.autocomplete.completeAnyWord(e);return null===t?null:{from:t.from,options:t.options.map((({label:e},t)=>({label:e,apply:e,type:void 0,boost:0-t})))}};let oa=({request_autocomplete:e,on_update_doc_query:t})=>{let n=null,o=null;return[Vo,zo({activateOnTyping:!1,override:[ta((async t=>{if(ce.default.isEqual(t,n)){let e=await o;if(null!=e)return e}return n=t,o=e(t),await o})),na],defaultKeymap:!1,maxRenderedOptions:512,optionClass:e=>e.type??""}),St.EditorView.updateListener.of((e=>{let t=e.state.field(Ko,!1),n=e.state.field(Vo,!1);null!=(null==t?void 0:t.open)&&n&&"active"===Ho(e.state)&&1===t.open.options.length&&((e,t)=>{let n=t.completion.apply||t.completion.label,o=Go(e,t.source);(null==o?void 0:o.from)&&("string"==typeof n?e.dispatch({changes:{from:o.from,to:o.to,insert:n},selection:{anchor:o.from+n.length},userEvent:"input.complete"}):n(e,t.completion,o.from,o.to))})(e.view,t.open.options[0])})),St.EditorView.updateListener.of((e=>{for(let n of e.transactions){var t;let o=n.annotation(St.autocomplete.pickedCompletion);o&&"string"==typeof o.apply&&o.apply.endsWith("/")&&(null===(t=o.type)||void 0===t?void 0:t.match(/(^| )completion_path( |$)/))&&St.autocomplete.startCompletion(e.view)}})),Xo(t),St.keymap.of(Qo),St.keymap.of(qo)]};ce=r("9Ta4i"),St=r("hiQgq"),io=r("1gqBQ"),ce=r("9Ta4i"),i=r("cNaMA");const aa=e=>null==e?[null]:Object.entries(e).flat(),ra=({nbpkg:e,package_name:t,available_versions:n,is_disable_pkg:o})=>{let a="error",r="error",s=i.html`error`,l=!1;const c=(null==e?void 0:e.installed_versions[t])??null,d=(null==e?void 0:e.waiting_for_permission)??!1,u=!d&&(((null==e?void 0:e.busy_packages)??[]).includes(t)||!((null==e?void 0:e.instantiated)??1));if(o){const e=t;a="disable_pkg",r=`${e} disables Pluto's built-in package manager.`,s=i.html`${e} disables Pluto's built-in package manager.`}else null!=c||ce.default.isEqual(n,["stdlib"])?null==c||"stdlib"===c?(a="installed",r=`${t} is part of Julia's pre-installed 'standard library'.`,s=i.html`${t} is part of Julia's pre-installed standard library.`):d?(a="will_be_installed",r=`${t} (v${ce.default.last(n)}) will be installed when you run this notebook.`,s=i.html`${t}v${ce.default.last(n)}
+ will be installed when you run this notebook.`):u?(a="busy",r=`${t} (v${c}) is installing...`,s=i.html`${t}v${c}
+ is installing...`):(a="installed",r=`${t} (v${c}) is installed in the notebook.`,s=i.html`${t}v${c}
+ is installed in the notebook.`,m=n,l=!("stdlib"===(p=c)||!ce.default.isArray(m))&&ce.default.last(m)!==p):null!=n&&ce.default.isArray(n)&&(0===n.length?(a="not_found",r=`The package "${t}" could not be found in the registry. Did you make a typo?`,s=i.html`The package "${t}" could not be found in the registry.
+ Did you make a typo?`):(a="will_be_installed",r=`${t} (v${ce.default.last(n)}) will be installed in the notebook when you run this cell.`,s=i.html`${t}v${ce.default.last(n)}
+ will be installed in the notebook when you run this cell.`));var p,m;return{status:a,hint:s,hint_raw:r,available_versions:n,chosen_version:c,busy:u,offer_update:l}},ia=({package_name:e,pluto_actions:t,notebook_id:n,nbpkg:o})=>{const[a,r]=i.useState(null);i.useEffect((()=>{(t.get_avaible_versions({package_name:e,notebook_id:n})??Promise.resolve([])).then((e=>{r(e)}))}),[e]);const{status:s,hint_raw:l}=ra({nbpkg:o,package_name:e,is_disable_pkg:!1,available_versions:a});return i.html`
+
+
+
+ `},sa=({package_name:e})=>{const{hint_raw:t}=ra({nbpkg:null,package_name:e,is_disable_pkg:!0,available_versions:null});return i.html`
+
+
+
+ `};i=r("cNaMA"),i=r("cNaMA"),St=r("hiQgq");class la extends St.WidgetType{constructor(e){super(),this.element=e}eq(e){return!1}toDOM(){let e=document.createElement("span");return i.render(this.element,e),e}updateDOM(e){return i.render(this.element,e),!0}}const ca=["Pkg.activate","Pkg.API.activate","Pkg.develop","Pkg.API.develop","Pkg.add","Pkg.API.add","quickactivate","@quickactivate"];function da(e,{pluto_actions:t,notebook_id:n,nbpkg:o}){let a=new Set,r=e.visibleRanges.flatMap((({from:r,to:s})=>{let l=function({doc:e,tree:t,from:n,to:o}){let a=0,r=[];return function({tree:e,enter:t,leave:n,from:o=0,to:a=e.length}){let r=e.cursor();for(;;){let e=!1;if(r.from<=a&&r.to>=o&&(r.type.isAnonymous||!1!==t(r))){if(r.firstChild())continue;r.type.isAnonymous||(e=!0)}for(;e&&n&&n(r),e=r.type.isAnonymous,!r.nextSibling();){if(!r.parent())return;e=!0}}}({tree:t,from:n,to:o,enter:t=>{if("QuoteExpression"!==t.name&&"QuoteStatement"!==t.name||a++,"InterpolationExpression"===t.name&&a--,0!==a)return;if("CallExpression"===t.name||"MacroExpression"===t.name){let n=t.node.firstChild,o=e.sliceString(n.from,n.to);return void(ca.includes(o)&&r.push({type:"package_disabler",name:o,from:t.to,to:t.to}))}let n=hn((e=>on`import A, ${e}`)),o=e=>{let t=null;return(t=n(rn`${un.as("package")}.${un.any}`).match(e))?o(t.package):(t=n(rn`.${un.maybe(un.any)}`).match(e))?null:(t=n(rn`${un.Identifier}`).match(e))?e:void console.warn("Unknown nested import specifier: "+e.toString())},i=null;if((i=sn(rn`import ${un.as("specifier")}: ${un.many()}`).match(t))??(i=sn(rn`import ${un.as("specifier")}, ${un.many("specifiers")}`).match(t))??(i=sn(rn`using ${un.as("specifier")}: ${un.many()}`).match(t))??(i=sn(rn`using ${un.as("specifier")}, ${un.many("specifiers")}`).match(t))){let{specifier:a,specifiers:s=[]}=i;a&&(s=[{node:a},...s]);for(let{node:t}of s){t=mn(t);let a=null;if(a=n(rn`${un.as("package")} as ${un.maybe(un.any)}`).match(t)){let t=o(a.package);t&&r.push({type:"package",name:e.sliceString(t.from,t.to),from:t.to,to:t.to})}else if(a=n(rn`${un.as("package")}.${un.any}`).match(t)){let t=o(a.package);t&&r.push({type:"package",name:e.sliceString(t.from,t.to),from:t.to,to:t.to})}else if(a=n(rn`.${un.as("scoped")}`).match(t));else if(a=n(rn`${un.as("package")}`).match(t)){let t=o(a.package);t&&r.push({type:"package",name:e.sliceString(t.from,t.to),from:t.to,to:t.to})}else console.warn("Unknown import specifier: "+t.toString())}if(i=null,i=sn(rn`using ${un.as("specifier")}, ${un.many("specifiers")}`).match(t)){let{specifier:t}=i;t&&("\n"!==e.sliceString(t.to,t.to+1)&&""!==e.sliceString(t.to,t.to+1)||r.push({type:"implicit_using",name:e.sliceString(t.from,t.to),from:t.to,to:t.to}))}return!1}if("ImportStatement"===t.name)throw new Error("What")},leave:e=>{"QuoteExpression"!==e.name&&"QuoteStatement"!==e.name||a--,"InterpolationExpression"===e.name&&a++}}),r}({doc:e.state.doc,tree:St.syntaxTree(e.state),from:r,to:s});return l.map((e=>{if("package"===e.type){let{name:r}=e;if("Base"!==r&&"Core"!==r&&!a.has(r)){return a.add(r),St.Decoration.widget({widget:new la(i.html`
+ <${ia}
+ key=${r}
+ package_name=${r}
+ pluto_actions=${t}
+ notebook_id=${n}
+ nbpkg=${o}
+ />
+ `),side:1}).range(e.to)}}else{if("package_disabler"===e.type){return St.Decoration.widget({widget:new la(i.html` <${sa} package_name=${e.name} /> `),side:1}).range(e.to)}if("implicit_using"===e.type&&"HypertextLiteral"===e.name){return St.Decoration.widget({widget:new la(i.html`
+
+ : @htl, @htl_str
+
+ `),side:1}).range(e.to)}}}))})).filter((e=>null!=e));return St.Decoration.set(r,!0)}const ua=St.Facet.define({combine:e=>e[0],compare:ce.default.isEqual}),pa=({pluto_actions:e,notebook_id_ref:t})=>St.ViewPlugin.fromClass(class{update_decos(n){const o=da(n,{pluto_actions:e,notebook_id:t.current,nbpkg:n.state.facet(ua)});this.decorations=o}constructor(e){this.update_decos(e)}update(e){(e.docChanged||e.viewportChanged||e.state.facet(ua)!==e.startState.facet(ua))&&this.update_decos(e.view)}},{decorations:e=>e.decorations});ce=r("9Ta4i"),St=r("hiQgq"),i=r("cNaMA");const ma=St.StateEffect.define({}),ga=St.StateField.define({create:()=>({defaultCharacterWidth:null,measuredSpaceWidth:null,measuredTabWidth:null}),update(e,t){for(let e of t.effects)if(e.is(ma))return e.value;return e}});let ha=St.EditorView.updateListener.of((e=>{let t=e.view.defaultCharacterWidth,{defaultCharacterWidth:n,measuredSpaceWidth:o}=e.view.state.field(ga,!1);if(n!==t){let n,o;e.view.dispatch({effects:[ma.of({defaultCharacterWidth:t,measuredSpaceWidth:n,measuredTabWidth:o})]})}})),fa=St.StateField.define({create:()=>St.Decoration.none,update(e,t){let n=t.startState.field(ga,!1),o=n.measuredSpaceWidth??n.defaultCharacterWidth,{measuredSpaceWidth:a,defaultCharacterWidth:r}=t.state.field(ga,!1),s=a??r;if(null==s)return St.Decoration.none;if(!t.docChanged&&e!==St.Decoration.none&&o===s)return e;let l=[];for(let e of ce.default.range(0,t.state.doc.lines)){let n=t.state.doc.line(e+1);if(0===n.length)continue;let o=0;for(let e of n.text){if("\t"!==e)break;o++}const a=Math.min(o,12),r=4*a*s,c=St.Decoration.line({attributes:{style:`--indented: ${r}px;`,class:"awesome-wrapping-plugin-the-line"}});if(l.push(c.range(n.from,n.from)),0!==a&&l.push(St.Decoration.mark({class:"awesome-wrapping-plugin-the-tabs"}).range(n.from,n.from+a)),o>a)for(let e of ce.default.range(a,o))l.push(St.Decoration.replace({widget:new la(i.html`⇥ `),block:!1}).range(n.from+e,n.from+e+1))}return St.Decoration.set(l)},provide:e=>St.EditorView.decorations.from(e)}),_a=St.Decoration.mark({class:"indentation-so-dont-break"}),ba=(St.StateField.define({create:()=>St.Decoration.none,update(e,t){let n=[];for(const e of t.newDoc)for(const t of e.matchAll(/[^ \t]+([ \t]|$)+/g))null!=t.index&&0!==t.index&&n.push(_a.range(0+t.index,0+t.index+t[0].length));return St.Decoration.set(n,!0)},provide:e=>St.EditorView.decorations.from(e)}),[ga,ha,fa]);let va=(St=r("hiQgq")).autocomplete.autocompletion()[0],ya=St.EditorView.domEventHandlers({keydown:(e,t)=>{var n;let o=t.state.selection.main;if(!o.empty)return!1;if(!e.repeat)return!1;if("Backspace"===e.key&&0===t.state.doc.length)return!0;if("Delete"===e.key&&0===t.state.doc.length)return!0;let a=(null===(n=t.state.field(va,!1))||void 0===n?void 0:n.open)??!1;return"ArrowUp"!==e.key||a?"ArrowDown"!==e.key||a?"ArrowLeft"===e.key&&e.repeat?!!t.moveByChar(o,!1).eq(o):"ArrowRight"===e.key?!!t.moveByChar(o,!0).eq(o):void 0:!!t.moveVertically(t.state.selection.main,!0).eq(o):!!t.moveVertically(t.state.selection.main,!1).eq(o)}}),wa=({focus_on_neighbor:e})=>(({focus_on_neighbor:e})=>St.keymap.of([{key:"PageUp",run:()=>(e({cell_delta:-1,line:0,character:0}),!0)},{key:"PageDown",run:()=>(e({cell_delta:1,line:0,character:0}),!0)},{key:"ArrowLeft",run:t=>{let n=t.state.selection.main;return!!n.empty&&!!t.moveByChar(n,!1).eq(n)&&(e({cell_delta:-1,line:1/0,character:1/0}),!0)}},{key:"ArrowUp",run:t=>{let n=t.state.selection.main;return!!n.empty&&!!t.moveVertically(n,!1).eq(n)&&(e({cell_delta:-1,line:1/0,character:1/0}),!0)}},{key:"ArrowRight",run:t=>{let n=t.state.selection.main;return!!n.empty&&!!t.moveByChar(n,!0).eq(n)&&(e({cell_delta:1,line:0,character:0}),!0)}},{key:"ArrowDown",run:t=>{let n=t.state.selection.main;return!!n.empty&&!!t.moveVertically(n,!0).eq(n)&&(e({cell_delta:1,line:0,character:0}),!0)}}]))({focus_on_neighbor:e});St=r("hiQgq");let ka=({pluto_actions:e,cell_id:t})=>St.EditorView.domEventHandlers({paste:(n,o)=>{if(!o.hasFocus)return console.log("CodeMirror, why are you registring this paste? You aren't focused!"),!0;n.stopPropagation();const a=n.clipboardData.getData("text/plain"),r=_e(a);return null!=r&&(0===o.state.selection.main.from&&o.state.selection.main.to===o.state.doc.length?(e.add_deserialized_cells(a,t,r),e.confirm_delete_multiple("This Should Never Be Visible",[t]),!0):(o.state.selection.main.to===o.state.doc.length||0===o.state.selection.main.from)&&(e.add_deserialized_cells(a,t,r),!0))}});St=r("hiQgq"),St=r("hiQgq"),St=r("hiQgq");function Ea(e){var t,n,o;let a=e.parent.firstChild,r=e.parent.lastChild;if(!("end"===r.name))return null;let i=null===(t=e.parent.getChild("CatchClause"))||void 0===t?void 0:t.firstChild,s=null===(n=e.parent.getChild("TryElseClause"))||void 0===n?void 0:n.firstChild,l=null===(o=e.parent.getChild("FinallyClause"))||void 0===o?void 0:o.firstChild;return[{from:a.from,to:a.to},i&&{from:i.from,to:i.to},s&&{from:s.from,to:s.to},l&&{from:l.from,to:l.to},{from:r.from,to:r.to}].filter((e=>null!=e))}const $a=(St=r("hiQgq")).EditorView.baseTheme({".cm-matchingBracket":{backgroundColor:"#328c8252"},".cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),xa=St.Facet.define({combine:e=>St.combineConfig(e,{afterCursor:!0,brackets:"()[]{}",maxScanDistance:1e4})}),Sa=St.Decoration.mark({class:"cm-matchingBracket"}),Na=(St.Decoration.mark({class:"cm-nonmatchingBracket"}),[St.StateField.define({create:()=>St.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],o=t.state.facet(xa);for(let e of t.state.selection.ranges){if(!e.empty)continue;let a=Aa(t.state,e.head,-1,o)||e.head>0&&Aa(t.state,e.head-1,1,o)||o.afterCursor&&(Aa(t.state,e.head,1,o)||e.headSt.EditorView.decorations.from(e)}),$a]);function Ca(e={}){return[xa.of(e),Na]}function Aa(e,t,n,o={}){let a=o.maxScanDistance||1e4,r=o.brackets||"()[]{}",i=St.syntaxTree(e),s=i.resolveInner(t,n),l=function(e){var t,n;if("end"===e.name&&(e="IfStatement"===e.parent.name?null===(t=e.parent)||void 0===t||null===(n=t.firstChild)||void 0===n?void 0:n.firstChild:e.parent.firstChild),null==e)return[];if("mutable"===e.name||"struct"===e.name){"struct"===e.name&&(e=e.parent.firstChild);let t=e.parent.getChild("struct"),n=e.parent.lastChild;return"end"===n.name&&t?[{from:e.from,to:t.to},{from:n.from,to:n.to}]:null}if("struct"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("quote"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("begin"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("do"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("for"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("let"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("macro"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("function"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("while"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("type"===e.name&&(e=e.parent.firstChild),"abstract"===e.name||"primitive"===e.name){let t=e.parent.lastChild,n="end"===t.name,o=e.parent.getChild("type");return n&&o?[{from:e.from,to:o.to},{from:t.from,to:t.to}]:null}if("if"===e.name||"else"===e.name||"elseif"===e.name){"if"===e.name&&(e=e.parent);let t=!1;"else"===e.name&&(e=e.parent,t=!0),"elseif"===e.name&&(e=e.parent.parent);let n=e.parent.firstChild,o=e.parent.lastChild;if("end"!==o.name)return null;if(t&&"try"===n.name)return Ea(e);let a=[];a.push({from:n.from,to:n.to});for(let t of e.parent.getChildren("ElseifClause")){let e=t.firstChild;a.push({from:e.from,to:e.to})}for(let t of e.parent.getChildren("ElseClause")){let e=t.firstChild;a.push({from:e.from,to:e.to})}return a.push({from:o.from,to:o.to}),a}if("try"===e.name||"catch"===e.name||"finally"===e.name||"else"===e.name)return"catch"===e.name&&(e=e.parent),"finally"===e.name&&(e=e.parent),"else"===e.name&&(e=e.parent),"end"===e.parent.lastChild.name?Ea(e):null;if("module"===e.name||"baremodule"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}return null}(s);return l||function(e,t,n,o,a,r,i){let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=i.indexOf(s);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},d=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!d.next().done&&e<=r;){let r=d.value;n<0&&(e+=r.length);let s=t+e*n;for(let e=n>0?0:r.length-1,t=n>0?r.length:-1;e!=t;e+=n){let t=i.indexOf(r[e]);if(!(t<0||o.resolve(s+e,1).type!=a))if(t%2==0==n>0)u++;else{if(1==u)return t>>1==l>>1?[c,{from:s+e,to:s+e+1}]:null;u--}}n>0&&(e+=r.length)}return d.done?[c]:null}(e,t,n,i,s.type,a,r)}ve=r("aN0pg");const Ma=(St=r("hiQgq")).Decoration.line({attributes:{class:"cm-highlighted-line"}}),Oa=St.Decoration.mark({attributes:{class:"cm-highlighted-range"}});const Ta=St.Facet.define({combine:e=>e[0],compare:(e,t)=>e===t}),Ra=St.Facet.define({combine:e=>e[0],compare:(e,t)=>e===t}),Da=()=>St.ViewPlugin.fromClass(class{updateDecos(e){this.decorations=function(e){let t=e.state.facet(Ta);if(null==t||null==t||t<0||t>e.state.doc.lines)return St.Decoration.set([]);let n=e.state.doc.line(t);return St.Decoration.set([Ma.range(n.from,n.from)])}(e)}constructor(e){this.decorations=St.Decoration.set([]),this.updateDecos(e)}update(e){(e.docChanged||e.state.facet(Ta)!==e.startState.facet(Ta))&&this.updateDecos(e.view)}},{decorations:e=>e.decorations}),La=()=>St.ViewPlugin.fromClass(class{updateDecos(e){this.decorations=function(e){let t=e.state.facet(Ra);if(null==t)return St.Decoration.set([]);let{from:n,to:o}=t;return n<0||n==o?St.Decoration.set([]):St.Decoration.set([Oa.range(n,o)])}(e)}constructor(e){this.decorations=St.Decoration.set([]),this.updateDecos(e)}update(e){(e.docChanged||e.state.facet(Ra)!==e.startState.facet(Ra))&&this.updateDecos(e.view)}},{decorations:e=>e.decorations});St=r("hiQgq");function Ia(e,t){return({state:n,dispatch:o})=>{if(n.readOnly)return!1;let a=e(t,n.selection.ranges,n);return!!a&&(o(n.update(a)),!0)}}const Pa=Ia(za,0),ja=(Ia(za,1),Ia(za,2),Ia(Fa,0)),Ba=(Ia(Fa,1),Ia(Fa,2),[{key:"Mod-/",run:e=>{let t=Ua(e.state);return t.line?Pa(e):!!t.block&&ja(e)}},{key:"Alt-A",run:ja}]);function Ua(e,t=e.selection.main.head){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}function Fa(e,t,n){let o=t.map((e=>Ua(n,e.from).block));if(!o.every((e=>e)))return null;let a=t.map(((e,t)=>function(e,{open:t,close:n},o,a){let r,i,s=e.sliceDoc(o-50,o),l=e.sliceDoc(a,a+50),c=/\s*$/.exec(s)[0].length,d=/^\s*/.exec(l)[0].length,u=s.length-c;if(s.slice(u-t.length,u)==t&&l.slice(d,d+n.length)==n)return{open:{pos:o-c,margin:c&&1},close:{pos:a+d,margin:d&&1}};a-o<=100?r=i=e.sliceDoc(o,a):(r=e.sliceDoc(o,o+50),i=e.sliceDoc(a-50,a));let p=/^\s*/.exec(r)[0].length,m=/\s*$/.exec(i)[0].length,g=i.length-m-n.length;return r.slice(p,p+t.length)==t&&i.slice(g,g+n.length)==n?{open:{pos:o+p+t.length,margin:/\s/.test(r.charAt(p+t.length))?1:0},close:{pos:a-m-n.length,margin:/\s/.test(i.charAt(g-1))?1:0}}:null}(n,o[t],e.from,e.to)));if(2!=e&&!a.every((e=>e))){let e=0;return n.changeByRange((t=>{let{open:n,close:r}=o[e++];if(a[e])return{range:t};let i=n.length+1;return{changes:[{from:t.from,insert:n+" "},{from:t.to,insert:" "+r}],range:St.EditorSelection.range(t.anchor+i,t.head+i)}}))}if(1!=e&&a.some((e=>e))){let e=[];for(let t,n=0;na&&(e==r||r>s.from)){a=s.from;let e=i??Ua(n,t).line;if(!e)continue;let r=/^\s*/.exec(s.text)[0].length,c=r==s.length,d=s.text.slice(r,r+e.length)==e?r:-1;re.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:n,indent:a,empty:r,single:i}of o)!i&&r||e.push({from:t.from+a,insert:n+" "});let t=n.changes(e);return{changes:t,selection:n.selection.map(t,1)}}if(1!=e&&o.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:a}of o)if(n>=0){let o=t.from+n,r=o+a.length;" "==t.text[r-t.from]&&r++,e.push({from:o,to:r})}return{changes:e}}return null}St=r("hiQgq");let qa={key:"Mod-d",run:({state:e,dispatch:t})=>{if(e.selection.main.empty){var n,o;let a=["Identifier","FieldName"],r=St.syntaxTree(e).cursorAt(e.selection.main.from,-1),i=St.syntaxTree(e).cursorAt(e.selection.main.from,1);for(let e of a){let n=r.name===e?r:i.name===e?i:null;if(n)return t({selection:{anchor:n.from,head:n.to}}),!0}let s=e.doc.lineAt(e.selection.main.from),l=e.selection.main.from-s.from,c=s.text.slice(0,l),d=s.text.slice(l),u=(null===(n=c.match(/(\w+)$/))||void 0===n?void 0:n[0])??"",p=(null===(o=d.match(/^(\w+)/))||void 0===o?void 0:o[0])??"";t({selection:{anchor:e.selection.main.from-u.length,head:e.selection.main.from+p.length}})}else St.selectNextOccurrence({state:e,dispatch:t});return!1},shift:({state:e,dispatch:t})=>{if(1===e.selection.ranges.length)return!1;let n=e.selection.ranges.at(e.selection.mainIndex-1),o=e.selection.ranges.filter((e=>e!==n)),a=o.indexOf(e.selection.main),r=(i=o,s=e.selection.mainIndex-1,i.slice(s,s+1)[0]);var i,s;return t({selection:St.EditorSelection.create(o,a),effects:null==r?[]:St.EditorView.scrollIntoView(r.from)}),!0},preventDefault:!0};de=r("4zMEb");var Ha=r("aTIpG");Io=r("hrGZZ"),St=r("hiQgq");const Wa="true"===window.localStorage.getItem("ENABLE_CM_MIXED_PARSER"),Ga="true"===window.localStorage.getItem("ENABLE_CM_SPELLCHECK");Wa&&console.log("YOU ENABLED THE CODEMIRROR MIXED LANGUAGE PARSER\nThanks! Awesome!\nPlease let us know if you find any bugs...\nIf enough people do this, we can make it the default parser.\n"),window.PLUTO_TOGGLE_CM_MIXED_PARSER=(e=!Wa)=>{window.localStorage.setItem("ENABLE_CM_MIXED_PARSER",String(e)),window.location.reload()},window.PLUTO_TOGGLE_CM_SPELLCHECK=(e=!Ga)=>{window.localStorage.setItem("ENABLE_CM_SPELLCHECK",String(e)),window.location.reload()};const Ka=St.HighlightStyle.define([{tag:St.tags.propertyName,color:"var(--cm-property-color)"},{tag:St.tags.unit,color:"var(--cm-tag-color)"},{tag:St.tags.literal,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.macroName,color:"var(--cm-macro-color)",fontWeight:700},{tag:St.tags.special(St.tags.brace),color:"var(--cm-macro-color)",fontWeight:700},{tag:St.tags.standard(St.tags.variableName),color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.bool,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"},{tag:St.tags.atom,color:"var(--cm-atom-color)"},{tag:St.tags.number,color:"var(--cm-number-color)"},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.string,color:"var(--cm-string-color)"},{tag:St.tags.variableName,color:"var(--cm-var-color)",fontWeight:700},{tag:St.tags.typeName,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.typeOperator,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.bracket,color:"var(--cm-bracket-color)"},{tag:St.tags.brace,color:"var(--cm-bracket-color)"},{tag:St.tags.tagName,color:"var(--cm-tag-color)"},{tag:St.tags.link,color:"var(--cm-link-color)"},{tag:St.tags.invalid,color:"var(--cm-error-color)",background:"var(--cm-error-bg-color)"}],{all:{color:"var(--cm-editor-text-color)"},scope:St.julia_andrey().language}),Za=St.HighlightStyle.define([{tag:St.tags.propertyName,color:"var(--cm-property-color)"},{tag:St.tags.unit,color:"var(--cm-tag-color)"},{tag:St.tags.literal,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.macroName,color:"var(--cm-macro-color)",fontWeight:700},{tag:St.tags.standard(St.tags.variableName),color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.bool,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.atom,color:"var(--cm-atom-color)"},{tag:St.tags.number,color:"var(--cm-number-color)"},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.string,color:"var(--cm-string-color)"},{tag:St.tags.variableName,color:"var(--cm-var-color)",fontWeight:700},{tag:St.tags.typeName,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.typeOperator,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.bracket,color:"var(--cm-bracket-color)"},{tag:St.tags.brace,color:"var(--cm-bracket-color)"},{tag:St.tags.tagName,color:"var(--cm-tag-color)"},{tag:St.tags.link,color:"var(--cm-link-color)"},{tag:St.tags.invalid,color:"var(--cm-error-color)",background:"var(--cm-error-bg-color)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic",filter:"none"}],{scope:St.javascriptLanguage,all:{color:"var(--cm-editor-text-color)",filter:"contrast(0.5)"}}),Va=St.HighlightStyle.define([{tag:St.tags.propertyName,color:"var(--cm-property-color)"},{tag:St.tags.unit,color:"var(--cm-tag-color)"},{tag:St.tags.literal,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.macroName,color:"var(--cm-macro-color)",fontWeight:700},{tag:St.tags.standard(St.tags.variableName),color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.bool,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"},{tag:St.tags.atom,color:"var(--cm-atom-color)"},{tag:St.tags.number,color:"var(--cm-number-color)"},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.string,color:"var(--cm-string-color)"},{tag:St.tags.variableName,color:"var(--cm-var-color)",fontWeight:700},{tag:St.tags.typeName,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.typeOperator,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.bracket,color:"var(--cm-bracket-color)"},{tag:St.tags.brace,color:"var(--cm-bracket-color)"},{tag:St.tags.tagName,color:"var(--cm-tag-color)"},{tag:St.tags.link,color:"var(--cm-link-color)"},{tag:St.tags.invalid,color:"var(--cm-error-color)",background:"var(--cm-error-bg-color)"}],{scope:St.pythonLanguage,all:{color:"var(--cm-editor-text-color)",filter:"contrast(0.5)"}}),Qa=St.HighlightStyle.define([{tag:St.tags.propertyName,color:"var(--cm-css-accent-color)",fontWeight:700},{tag:St.tags.variableName,color:"var(--cm-css-accent-color)",fontWeight:700},{tag:St.tags.definitionOperator,color:"var(--cm-css-color)"},{tag:St.tags.keyword,color:"var(--cm-css-color)"},{tag:St.tags.modifier,color:"var(--cm-css-accent-color)"},{tag:St.tags.punctuation,opacity:.5},{tag:St.tags.literal,color:"var(--cm-css-color)"},{tag:St.tags.tagName,color:"var(--cm-css-color)",fontWeight:700},{tag:St.tags.className,color:"var(--cm-css-why-doesnt-codemirror-highlight-all-the-text-aaa)"},{tag:St.tags.constant(St.tags.className),color:"var(--cm-css-why-doesnt-codemirror-highlight-all-the-text-aaa)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"}],{scope:St.cssLanguage,all:{color:"var(--cm-css-color)"}}),Xa=St.HighlightStyle.define([{tag:St.tags.tagName,color:"var(--cm-html-accent-color)",fontWeight:600},{tag:St.tags.attributeName,color:"var(--cm-html-accent-color)",fontWeight:600},{tag:St.tags.attributeValue,color:"var(--cm-html-accent-color)"},{tag:St.tags.angleBracket,color:"var(--cm-html-accent-color)",fontWeight:600,opacity:.7},{tag:St.tags.content,color:"var(--cm-html-color)",fontWeight:400},{tag:St.tags.documentMeta,color:"var(--cm-html-accent-color)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"}],{scope:St.htmlLanguage,all:{color:"var(--cm-html-color)"}}),Ya=St.HighlightStyle.define([{tag:St.tags.content,color:"var(--cm-md-color)"},{tag:St.tags.quote,color:"var(--cm-md-color)"},{tag:St.tags.link,textDecoration:"underline"},{tag:St.tags.url,color:"var(--cm-md-color)",textDecoration:"none"},{tag:St.tags.emphasis,fontStyle:"italic"},{tag:St.tags.strong,fontWeight:"bolder"},{tag:St.tags.heading,color:"var(--cm-md-color)",fontWeight:700},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"},{tag:St.tags.processingInstruction,color:"var(--cm-md-accent-color) !important",opacity:"0.5"},{tag:St.tags.monospace,color:"var(--cm-md-accent-color)"}],{scope:St.markdownLanguage,all:{color:"var(--cm-md-color)"}}),Ja=e=>e.state.doc.toString(),er=(e,t)=>e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t}}),tr=(e,t,n,o)=>e.dispatch({changes:{from:n,to:o,insert:t}});let nr=(e,t)=>{let n=i.useRef(new St.Compartment),o=i.useRef(n.current.of(t));return i.useLayoutEffect((()=>{var o,a;null===(o=e.current)||void 0===o||null===(a=o.dispatch)||void 0===a||a.call(o,{effects:n.current.reconfigure(t)})}),[t]),o.current},or=(e,{line:t,ch:n})=>{let o=e.line(ce.default.clamp(t+1,1,e.lines)),a=ce.default.clamp(n,0,o.length);return o.from+a};const ar=({local_code:e,remote_code:t,disable_input:n,focus_after_creation:o,cm_forced_focus:a,set_cm_forced_focus:r,show_input:s,on_submit:l,on_delete:c,on_add_after:d,on_change:u,on_update_doc_query:p,on_focus_neighbor:m,on_line_heights:g,nbpkg:h,cell_id:f,notebook_id:_,any_logs:b,show_logs:v,set_show_logs:y,set_cell_disabled:w,cm_highlighted_line:k,cm_highlighted_range:E,metadata:$,global_definition_locations:x,cm_diagnostics:S})=>{let N=i.useContext(ye);const{disabled:C,skip_as_script:A}=$;let[M,O]=i.useState(null);if(M){const e=M;throw O(null),e}const T=i.useRef(_);T.current=_;const R=i.useRef(null),D=i.useRef(null),L=i.useRef(null);let I=nr(R,ua.of(h)),P=nr(R,Wn.of(x)),j=nr(R,Ta.of(k)),B=nr(R,Ra.of(E)),U=nr(R,St.EditorState.readOnly.of(n)),F=nr(R,i.useMemo((()=>St.EditorView.updateListener.of((e=>{e.docChanged&&u(e.state.doc.toString())}))),[u]));return i.useLayoutEffect((()=>{if(null==D.current)return;const t=e=>((async e=>{await e()})((async()=>{await d();e.state.doc.toString()!==L.current&&l()})),!0);let n=St.autocomplete.completionKeymap.find((e=>"Enter"===e.key));const a=()=>{const e=R.current,t=Ja(e),n=t.trim(),o=t.length-t.trimStart().length;if(console.table({value:t,trimmed:n,offset:o}),n.startsWith('md"')&&n.endsWith('"')){let t,a;if(n.startsWith('md"""')&&n.endsWith('"""')?(t=5,a=n.length-3):(t=3,a=n.length-1),t>=a||""==n.substring(t,a).trim())er(e,"");else{for(;/\s/.test(n[t]);)++t;for(;/\s/.test(n[a-1]);)--a;tr(e,"",a+o,e.state.doc.length),tr(e,"",0,t+o)}}else{let t='md"""\n',n='\n"""',o=e.state.selection.main;e.dispatch({changes:[{from:0,to:0,insert:t},{from:e.state.doc.length,to:e.state.doc.length,insert:n}],selection:0===o.from?{anchor:o.from+t.length,head:o.to+t.length}:void 0})}return!0},i=e=>!e.state.facet(St.EditorState.readOnly)&&(0===e.state.doc.length&&(m(f,1),c(),!0)),s=e=>!e.state.facet(St.EditorState.readOnly)&&(0===e.state.doc.length&&(m(f,-1,1/0,1/0),c(),!0)),u=(e,t)=>{if(e.state.facet(St.EditorState.readOnly))return!1;const n=e.state.selection.main,o=0===n.anchor&&n.head===e.state.doc.length;return console.log({all_is_selected:o}),o||1===e.state.doc.lines?(N.move_remote_cells([f],N.get_notebook().cell_order.indexOf(f)+(-1===t?-1:2)),requestIdleCallback((()=>{e.dispatch({selection:{anchor:0,head:e.state.doc.length},scrollIntoView:!0}),e.focus()})),!0):1===t?St.moveLineDown(e):St.moveLineUp(e)},h=[{key:"Shift-Enter",run:()=>(l(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:t},{key:"Ctrl-Enter",run:t},{key:"Tab",run:e=>{var t;if(e.state.readOnly)return!1;if(null==n||null===(t=n.run)||void 0===t?void 0:t.call(n,e))return!0;let o=e.state.selection.main;return o.empty?(e.dispatch({changes:{from:o.from,to:o.to,insert:"\t"},selection:St.EditorSelection.cursor(o.from+1)}),!0):St.indentMore(e)},shift:St.indentLess},{key:"Ctrl-m",mac:"Cmd-m",run:a},{key:"Ctrl-m",run:a},{key:"Ctrl-M",run:a},{key:"Delete",run:i},{key:"Ctrl-Delete",run:i},{key:"Backspace",run:s},{key:"Ctrl-Backspace",run:s},{key:"Alt-ArrowUp",run:e=>u(e,-1)},{key:"Alt-ArrowDown",run:e=>u(e,1)},qa];let _=!1;const b=St.EditorView.updateListener.of((e=>{if(e.view.hasFocus&&(e.docChanged||e.selectionSet)){let t=e.state;try{let e=zn(t,_);null!=e&&p(e)}finally{}}})),v=window.matchMedia("(prefers-color-scheme: dark)").matches,y=R.current=new St.EditorView({state:St.EditorState.create({doc:e,extensions:[St.EditorView.theme({},{dark:v}),I,j,B,P,U,Da(),La(),ya,pa({pluto_actions:N,notebook_id_ref:T}),Pn,St.syntaxHighlighting(Ka),St.syntaxHighlighting(Xa),St.syntaxHighlighting(Ya),St.syntaxHighlighting(Za),St.syntaxHighlighting(Va),St.syntaxHighlighting(Qa),St.lineNumbers(),St.highlightSpecialChars(),St.history(),St.drawSelection(),St.EditorState.allowMultipleSelections.of(!0),St.EditorView.clickAddsSelectionRange.of((e=>e.altKey&&!e.shiftKey)),St.indentOnInput(),St.EditorState.languageData.of(((e,t,n)=>[{closeBrackets:{brackets:["(","[","{"]}}])),St.closeBrackets(),St.rectangularSelection({eventFilter:e=>e.altKey&&e.shiftKey&&0==e.button}),St.highlightSelectionMatches(),Ca(),b,Ha.tab_help_plugin,St.EditorView.domEventHandlers({blur:(e,t)=>{document.activeElement===t.contentDOM||(setTimeout((()=>{t.dispatch({selection:{anchor:t.state.selection.main.head},scrollIntoView:!1}),t.contentDOM.blur()}),0),r(null))}}),ka({pluto_actions:N,cell_id:f}),St.EditorView.updateListener.of((e=>{e.docChanged&&e.state.doc.length>0&&"?"===e.state.sliceDoc(0,1)&&Po("docs")})),St.EditorState.tabSize.of(4),St.indentUnit.of("\t"),...Wa?[to(),St.markdown({defaultCodeLanguage:to()}),St.html(),St.javascript(),St.python(),Qn]:[St.julia_andrey()],Gn,oa({request_autocomplete:async({text:e})=>{let t=await de.timeout_promise(N.send("complete",{query:e},{notebook_id:T.current}),5e3).catch(console.warn);if(!t)return null;let{message:n}=t;return{start:xt.utf8index_to_ut16index(e,n.start),stop:xt.utf8index_to_ut16index(e,n.stop),results:n.results}},on_update_doc_query:p}),St.keymap.of(h),St.keymap.of(Ba),wa({focus_on_neighbor:({cell_delta:e,line:t,character:n})=>m(f,e,t,n)}),St.keymap.of([...St.closeBracketsKeymap,...St.defaultKeymap,...St.historyKeymap,...St.foldKeymap]),St.placeholder("Enter cell code..."),St.EditorView.contentAttributes.of({spellcheck:String(Ga)}),St.EditorView.lineWrapping,ba,St.EditorView.updateListener.of((e=>{e.docChanged&&e.view.dispatch(St.setDiagnostics(e.state,[]))})),F,St.EditorView.exceptionSink.of((e=>{O(e),console.error("EditorView exception!",e)}))]}),parent:D.current});y.dom.CodeMirror={getValue:()=>Ja(y),setValue:e=>er(y,e)},o&&setTimeout((()=>{let e=R.current;null!=e&&(e.dom.scrollIntoView({behavior:"smooth",block:"nearest"}),e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length},effects:[Ha.LastFocusWasForcedEffect.of(!0)]}),e.focus())}));const w=D.current.querySelector("div.cm-content");if(w){const e=new ResizeObserver((()=>{const e=w.children,t=ce.default.map(e,(e=>e.offsetTop)),n=[...t.slice(1).map(((e,n)=>e-t[n])),15];g(n)}));return e.observe(w),()=>{e.unobserve(w)}}}),[]),i.useEffect((()=>{if(null==R.current)return;const e=R.current,t=S;e.dispatch(St.setDiagnostics(e.state,t))}),[S]),i.useEffect((()=>{if(null==R.current)return;const e=Ja(R.current)??"";null==L.current&&""===t&&""!==e||(L.current=t,e!==t&&er(R.current,t))}),[t]),i.useEffect((()=>{const e=R.current;if(null!=e)if(null==a)e.dispatch({selection:{anchor:e.state.selection.main.head,head:e.state.selection.main.head}});else{let n={anchor:or(e.state.doc,a[0]),head:or(e.state.doc,a[1])};if(null===(t=a[2])||void 0===t?void 0:t.definition_of){var t;let o=e.state.field(Pn),r=null==o?void 0:o.definitions.get(null===(t=a[2])||void 0===t?void 0:t.definition_of);r&&(n={anchor:r.from,head:r.to})}e.dom.scrollIntoView({behavior:"smooth",block:"nearest"}),e.focus(),e.dispatch({scrollIntoView:!0,selection:n,effects:[St.EditorView.scrollIntoView(St.EditorSelection.range(n.anchor,n.head),{yMargin:80}),Ha.LastFocusWasForcedEffect.of(!0)]})}}),[a]),i.html`
+
+ <${rr}
+ on_delete=${c}
+ cell_id=${f}
+ run_cell=${l}
+ skip_as_script=${A}
+ running_disabled=${C}
+ any_logs=${b}
+ show_logs=${v}
+ set_show_logs=${y}
+ set_cell_disabled=${w}
+ />
+
+ `},rr=({on_delete:e,cell_id:t,run_cell:n,skip_as_script:o,running_disabled:a,any_logs:r,show_logs:s,set_show_logs:l,set_cell_disabled:c})=>{const d=i.useRef(null);let u=i.useContext(ye);const[p,m]=i.useState(!1),g=i.useRef(null),h=i.useRef(null),f=e=>{e&&(h.current=document.activeElement),m(e)};i.useLayoutEffect((()=>{var e,t,n;p?null===(t=null===(e=g.current)||void 0===e?void 0:e.querySelector("li"))||void 0===t||t.focus():h.current instanceof HTMLElement&&(null===(n=h.current)||void 0===n||n.focus())}),[p]);return Io.useEventListener(window,"keydown",(e=>{"Escape"===e.key&&f(!1)})),i.html` `},ir=({frame:e,cell_id:t})=>{const n=e.file.indexOf("#==#");if(-1!=n){const o=e.file.substr(n+4,36),a=i.html`{window.dispatchEvent(new CustomEvent("cell_focus",{detail:{cell_id:o,line:e.line-1}})),t.preventDefault()}}
+ >
+ ${o==t?"Local":"Other"}: ${e.line}
+ `;return i.html`${a}`}return i.html`${e.file}:${e.line}`},sr=({frame:e})=>{const t=e.call.indexOf("(");return-1!=t?i.html`${e.call.substr(0,t)}${e.call.substr(t)}`:i.html`${e.call}`},lr=e=>e.flatMap(((t,n)=>n===e.length-1?[t]:n===e.length-2?[t," and "]:[t,", "])),cr=({cell_id:e,diagnostics:t})=>(i.useEffect((()=>(window.dispatchEvent(new CustomEvent("cell_diagnostics",{detail:{cell_id:e,diagnostics:t}})),()=>window.dispatchEvent(new CustomEvent("cell_diagnostics",{detail:{cell_id:e,diagnostics:[]}})))),[t]),i.html`
+
+
`}},{pattern:/LoadError: cannot assign a value to variable workspace#\d+\..+ from module workspace#\d+/,display:()=>i.html`
Tried to reevaluate an include call, this is not supported. You might need to restart this notebook from the main menu.
+
+ For a workaround, use the alternative version of include described here:
+ GH issue 115
+
+
In the future, include will be deprecated, and this will be the default.
`},{pattern:/MethodError: no method matching .*\nClosest candidates are:/,display:e=>e.split("\n").map((e=>i.html`
${e}
`))},{pattern:/Cyclic references among (.*)\./,display:e=>e.split("\n").map((e=>{const t=e.match(/Cyclic references among (.*)\./);if(t){let e=t[1].split(/, | and /).map((e=>i.html`${e}`));return i.html`