"use strict";(self.webpackChunkdiploma=self.webpackChunkdiploma||[]).push([[568],{568:(t,e,o)=>{o.r(e),o.d(e,{ButtonExtension:()=>i,default:()=>l});var a=o(923),n=o(33);const s={activate:function(t){t.docRegistry.addWidgetExtension("Notebook",new i)},id:"toolbar-button",autoStart:!0};class i{createNew(t,e){let o;(async()=>{const t=await fetch("http://localhost:8080/available_vm",{method:"GET",headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`Error! status: ${t.status}`);o=await t.json()})().catch((t=>{throw t})),console.log(o);const s=new n.ToolbarButton({className:"Move state",label:"Move state",onClick:async()=>{let t;return t=null!=o?o.data.map((t=>t.name)):["current vm"],n.InputDialog.getItem({title:"Switch to vm",items:t}).then((async t=>{if(t.button.accept&&null!=o){let e=o.data.find((e=>e.name===t.value));const a=t=>new Promise((e=>setTimeout(e,t)));if(null!=e){await a(1e4);const t=await fetch("http://localhost:8080/switch_vm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error("failed to switch vm");null==t.body?window.location.href=document.location.href:window.location.href=await t.text()}}}))},tooltip:"Move state"});return t.toolbar.insertItem(10,"moveState",s),new a.DisposableDelegate((()=>{s.dispose()}))}}const l=s}}]);