"use strict";(self.webpackChunkdatabrix_hub_extension=self.webpackChunkdatabrix_hub_extension||[]).push([[509],{509:(e,t,o)=>{o.r(t),o.d(t,{default:()=>l});var n=o(974),i=o(607),a=o(605),r=o(74);async function s(){const e=window.location.href,t=window.location.origin,o=e.match(/\/hub\/user\/([^\/]+)\/lab/),n=t+`/jupyterhub/hub/api/users/${o?o[1]:null}/server`;console.log("HUB API URL: ",n);const i=r.PageConfig.getToken();if(!i)throw new Error("API token is not available from PageConfig.");let a;try{const e=await fetch(n,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`token ${i}`}});if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);a=await e.json(),console.log("Response Data:",a)}catch(e){console.error("Error fetching data:",e)}}const l=[{id:"databrix-hub-extension:connectionlost",description:"Provides a service to be notified when the connection to the hub server is lost.",requires:[n.JupyterFrontEnd.IPaths,a.ITranslator],optional:[n.JupyterLab.IInfo],activate:(e,t,o,n)=>{const a=o.load("jupyterlab");return async(e,t)=>{const o=await(0,i.showDialog)({title:a.__("Server unavailable or unreachable"),body:a.__("Your server is not running.\nYou have been inactive for a long time, or Jupyterhub has shut down your server.\nPlease Login again!"),buttons:[i.Dialog.okButton({label:a.__("Restart")})]});n&&(n.isConnected=!0),o.button.accept&&(window.location.href="")}},autoStart:!0,provides:n.IConnectionLost},{id:"idle-culler-warning",autoStart:!0,requires:[a.ITranslator],activate:(e,t)=>{const o=t.load("jupyterlab");let n,a;console.log("JupyterLab extension idle-culler-warning is activated!");const r=()=>{n&&(clearTimeout(n),clearTimeout(a)),n=window.setTimeout((async()=>{(await(0,i.showDialog)({title:o.__("Are you still online?"),body:o.__("Your session will be stopped if no activity is detected in the next minute."),buttons:[i.Dialog.okButton({label:o.__("YES")})]})).button.accept&&(clearTimeout(n),console.log("User is still online."))}),6e4),a=window.setTimeout(s,12e4)};window.addEventListener("mousemove",r),window.addEventListener("keydown",r),window.addEventListener("click",r),window.addEventListener("scroll",r)}}]}}]);