import{r as t,f as o,h as e,e as s}from"./p-42c7aa22.js";import{i as n}from"./p-c5ef88a4.js";const i=":host,stencila-document-toolbar{--background:var(--color-neutral-100);display:block}:host([position=fixed]),stencila-document-toolbar[position=fixed]{left:0;max-width:none!important;position:fixed;top:0;width:100%;z-index:30}:host([position=fixed])+*,stencila-document-toolbar[position=fixed]+*{margin-top:3rem}:host .hidden-sm,stencila-document-toolbar .hidden-sm{display:none}@media (min-width:640px){:host .hidden-sm,stencila-document-toolbar .hidden-sm{display:inline}}:host .documentStatus,stencila-document-toolbar .documentStatus{color:#4a4a4a;color:var(--color-key,#4a4a4a);font-size:.875rem;line-height:1.25rem;line-height:1}:host .documentStatus.success,stencila-document-toolbar .documentStatus.success{color:#1b5430;color:var(--color-success-700,#1b5430)}:host .documentStatus.danger,stencila-document-toolbar .documentStatus.danger{color:#cf445e;color:var(--color-danger-500,#cf445e)}:host .documentStatus stencila-icon,stencila-document-toolbar .documentStatus stencila-icon{margin-right:.25rem}:host .documentStatus stencila-tooltip,stencila-document-toolbar .documentStatus stencila-tooltip{cursor:help}:host .documentStatus span,stencila-document-toolbar .documentStatus span{vertical-align:middle}";const a=":host,stencila-document-toolbar{--background:var(--color-neutral-100);display:block}:host([position=fixed]),stencila-document-toolbar[position=fixed]{left:0;max-width:none!important;position:fixed;top:0;width:100%;z-index:30}:host([position=fixed])+*,stencila-document-toolbar[position=fixed]+*{margin-top:3rem}:host .hidden-sm,stencila-document-toolbar .hidden-sm{display:none}@media (min-width:640px){:host .hidden-sm,stencila-document-toolbar .hidden-sm{display:inline}}:host .documentStatus,stencila-document-toolbar .documentStatus{color:#4a4a4a;color:var(--color-key,#4a4a4a);font-size:.875rem;line-height:1.25rem;line-height:1}:host .documentStatus.success,stencila-document-toolbar .documentStatus.success{color:#1b5430;color:var(--color-success-700,#1b5430)}:host .documentStatus.danger,stencila-document-toolbar .documentStatus.danger{color:#cf445e;color:var(--color-danger-500,#cf445e)}:host .documentStatus stencila-icon,stencila-document-toolbar .documentStatus stencila-icon{margin-right:.25rem}:host .documentStatus stencila-tooltip,stencila-document-toolbar .documentStatus stencila-tooltip{cursor:help}:host .documentStatus span,stencila-document-toolbar .documentStatus span{vertical-align:middle}";const l=class{constructor(e){t(this,e);this.codeExecuteEvent=o(this,"stencila-code-execute",7);this.kernelRestart=o(this,"stencila-kernel-restart",7);this.codeExecuteCancelEvent=o(this,"stencila-code-execute-cancel",7);var s,i;this.position="fixed";this.isExecutable=Object.keys((i=(s=window.stencilaWebClient)===null||s===void 0?void 0:s.executableLanguages)!==null&&i!==void 0?i:{}).length>0;this.shiftIsPressed=false;this.altIsPressed=false;this.onKeyPress=t=>{this.shiftIsPressed=t.shiftKey;this.altIsPressed=t.altKey};this.addKeyListeners=()=>{window.addEventListener("keydown",this.onKeyPress);window.addEventListener("keyup",this.onKeyPress)};this.removeKeyListeners=()=>{window.removeEventListener("keydown",this.onKeyPress);window.removeEventListener("keyup",this.onKeyPress);this.shiftIsPressed=false;this.altIsPressed=false};this.runDocument=t=>{if(n(this.executeStatus)){this.codeExecuteCancelEvent.emit({nodeId:null,scope:"All"})}else{if(this.altIsPressed){this.kernelRestart.emit()}else{this.codeExecuteEvent.emit({nodeId:null,ordering:t.shiftKey?"Appearance":"Topological"})}}}}onDiscoverExecutableLanguages({detail:t}){this.isExecutable=Object.keys(t.languages).length>0}render(){return e(s,{position:this.position},e("stencila-toolbar",null,e("span",{slot:"start"},e("stencila-button",{onKeyDown:this.onKeyPress,color:"stock",icon:this.altIsPressed?"restart":n(this.executeStatus)?"loader-2":"play",size:"small",onClick:this.runDocument,disabled:!this.isExecutable,dataEl:"Toolbar/Run Document",onMouseEnter:this.addKeyListeners,onMouseLeave:this.removeKeyListeners,tooltip:this.altIsPressed?undefined:this.shiftIsPressed?"Run sequentially":"Run topologically"},this.altIsPressed?"Restart kernel":n(this.executeStatus)?"Cancel":["Run",e("span",{class:"hidden-sm"}," Document")])),this.sourceUrl!==undefined&&e("span",{slot:"end"},e("stencila-button",{color:"stock",href:this.sourceUrl,target:"_blank",rel:"nofollow noopener",icon:"external-link",size:"small",dataEl:"Toolbar/Project Source"},"Source"))))}};l.style={default:i,material:a};export{l as stencila_document_toolbar};
//# sourceMappingURL=p-a7f62aa6.entry.js.map