"use strict";(self.webpackChunkdiploma=self.webpackChunkdiploma||[]).push([[568],{568:(t,e,o)=>{o.r(e),o.d(e,{ButtonExtension:()=>s,default:()=>l});var a=o(923),n=o(33);const i={activate:function(t){t.docRegistry.addWidgetExtension("Notebook",new s)},id:"toolbar-button",autoStart:!0};class s{createNew(t,e){let o;const i="http://158.160.25.120:8080";(async()=>{const t=await fetch(`${i}/api/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));if(null!=e){const t=await fetch(`${i}/api/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?location.href=document.location.href:location.href=await t.text()}}}))},tooltip:"Move state"});return t.toolbar.insertItem(10,"moveState",s),new a.DisposableDelegate((()=>{s.dispose()}))}}const l=i}}]);