!function(e){function t(t){for(var r,u,c=t[0],i=t[1],a=t[2],l=0,f=[];l<c.length;l++)u=c[l],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&f.push(o[u][0]),o[u]=0;for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);for(d&&d(t);f.length;)f.shift()();return s.push.apply(s,a||[]),n()}function n(){for(var e,t=0;t<s.length;t++){for(var n=s[t],r=!0,c=1;c<n.length;c++){var i=n[c];0!==o[i]&&(r=!1)}r&&(s.splice(t--,1),e=u(u.s=n[0]))}return e}var r={},o={19:0},s=[];function u(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,u),n.l=!0,n.exports}u.m=e,u.c=r,u.d=function(e,t,n){u.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,t){if(1&t&&(e=u(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(u.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)u.d(n,r,function(t){return e[t]}.bind(null,r));return n},u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,"a",t),t},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.p="/dist/";var c=window.webpackJsonp=window.webpackJsonp||[],i=c.push.bind(c);c.push=t,c=c.slice();for(var a=0;a<c.length;a++)t(c[a]);var d=i;s.push([119,0]),n()}({119:function(e,t,n){"use strict";n(185);const r=n(0),o=n(8),s=n(7),u=n(4),c=n(2),i=n(28),a=n(3),{codeFrameColumns:d}=n(120),l=n(1),f=n(9),p=n(136),m=n(137),y=n(138),h=n(139),{runSelected:x}=n(140),b=u.css,C=s();CloudCmd.UserMenu=e.exports;const{Key:g}=CloudCmd;e.exports.init=async()=>{await Promise.all([b(CloudCmd.prefix+"/dist/user-menu.css"),CloudCmd.View()])},e.exports.show=async function(){l.show.load("top");const{dirPath:e}=w,t=await fetch(`${CloudCmd.prefix}/api/v1/user-menu?dir=${e}`),n=await t.text(),[r,o]=i(p,n);if(l.hide(),r)return f.alert(P({error:r,source:n}));C(n);const{names:s,keys:u,items:a,settings:d}=h(o);if(d.run)return x(d.select,a,I);const m=c("button",{className:"cloudcmd-user-menu-button",innerText:"User Menu",notAppend:!0}),y=c("select",{className:"cloudcmd-user-menu",innerHTML:v(s),notAppend:!0,size:10});m.addEventListener("click",M(o,y)),y.addEventListener("dblclick",k(o)),y.addEventListener("keydown",j({keys:u,userMenu:o}));CloudCmd.View.show([m,y],{autoSize:!0,afterShow:()=>y.focus()})},e.exports.hide=O;const{CurrentInfo:w}=DOM;function v(e){const t=[];for(const n of e)t.push(`<option>${n}</option>`);return t.join("")}function O(){CloudCmd.View.hide()}const k=r(async(e,t)=>{const{value:n}=t.target;await I(e[n])}),M=o(async(e,{value:t})=>{await I(e[t])}),j=r(async({keys:e,userMenu:t},n)=>{const{keyCode:r,target:o}=n,s=n.key.toUpperCase();let u;if(n.preventDefault(),n.stopPropagation(),r===g.ESC)return O();if(r===g.ENTER)u=t[o.value];else{if(!e[s])return m(o,n);u=e[s]}await I(u)}),I=async e=>{O();const[t]=await a(e,{DOM:DOM,CloudCmd:CloudCmd,tryToCatch:a});if(!t)return;const n=C();return f.alert(P({error:t,source:n}))};function P({error:e,source:t}){const{code:n}=e;if(!n||"frame"===n)return e.message;const[r,o]=y(e);return`<pre>${d(t,{start:{line:r,column:o}},{message:e.message,highlightCode:!1})}</pre>`}},136:function(e,t,n){"use strict";e.exports=e=>{const t={};return Function("module",e)(t),t.exports}},137:function(e,t,n){"use strict";const r=n(7),{J:o,K:s,UP:u,DOWN:c}=n(36),i=r(1);e.exports=(e,{key:t,keyCode:n})=>{if(/^\d+$/.test(t)&&i(Number(t)),n===c||n===o){const t=i();return i(1),function(e,t){const{length:n}=e;e.selectedIndex===n-1?e.selectedIndex=0:e.selectedIndex+=t;e.selectedIndex<0&&(e.selectedIndex=n-1)}(e,t)}if(n===u||n===s){const t=i();return i(1),function(e,t){const{length:n}=e;e.selectedIndex?e.selectedIndex-=t:e.selectedIndex=n-1;e.selectedIndex<0&&(e.selectedIndex=0)}(e,t)}}},138:function(e,t,n){"use strict";const r=e=>"number"==typeof e;e.exports=e=>{const{lineNumber:t,columnNumber:n}=e;if(r(t)&&r(n))return[t,n];const o=e.stack.indexOf(">"),s=e.stack.slice(o+1),u=s.indexOf(")"),c=s.slice(1,u),[i,a]=c.split(":");return[Number(i),Number(a)]}},139:function(e,t,n){"use strict";const{entries:r,assign:o}=Object;e.exports=e=>{const t=[],n={},s={},u={};for(const[c,i]of r(e)){if("__settings"===c){o(u,e[c]);continue}if(c.startsWith("_"))continue;t.push(c);const[r,a]=c.split(" - ");n[r]=i,s[a]=i}return{names:t,keys:n,items:s,settings:u}}},140:function(e,t,n){"use strict";e.exports.runSelected=async(e,t,n)=>{for(const r of e)await n(t[r])}},185:function(e,t){}});
//# sourceMappingURL=user-menu.js.map