Socket
Socket
Sign inDemoInstall

mj-context-menu

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mj-context-menu - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

LICENSE

2

cjs/index.d.ts

@@ -14,5 +14,5 @@ import { ContextMenu as obj0 } from './context_menu.js';

export declare const Parser: typeof obj4;
export declare const version = "0.8.0";
export declare const version = "0.9.1";
export declare const SelectionBox: typeof obj5;
export declare const Variable: typeof obj6;
export declare const ParserFactory: typeof obj7;

@@ -17,3 +17,3 @@ "use strict";

exports.Parser = parse_js_1.Parser;
exports.version = '0.8.0';
exports.version = '0.9.1';
exports.SelectionBox = selection_box_js_1.SelectionBox;

@@ -20,0 +20,0 @@ exports.Variable = variable_js_1.Variable;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ContextMenu=e():t.ContextMenu=e()}(this,(()=>(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ContextMenu:()=>rt,CssStyles:()=>at,Info:()=>ht,Parser:()=>lt,ParserFactory:()=>mt,Popup:()=>ut,SelectionBox:()=>ct,Variable:()=>pt,version:()=>dt});var s,i={};t.r(i),t.d(i,{addInfoStyles:()=>B,addMenuStyles:()=>F}),function(t){t[t.RETURN=13]="RETURN",t[t.ESCAPE=27]="ESCAPE",t[t.SPACE=32]="SPACE",t[t.LEFT=37]="LEFT",t[t.UP=38]="UP",t[t.RIGHT=39]="RIGHT",t[t.DOWN=40]="DOWN"}(s||(s={}));const n="click",o="dblclick",r="mousedown",a="mouseup",h="mouseover",u="mouseout",l="selectstart";class d{constructor(){this.bubble=!1}bubbleKey(){this.bubble=!0}keydown(t){switch(t.keyCode){case s.ESCAPE:this.escape(t);break;case s.RIGHT:this.right(t);break;case s.LEFT:this.left(t);break;case s.UP:this.up(t);break;case s.DOWN:this.down(t);break;case s.RETURN:case s.SPACE:this.space(t);break;default:return}this.bubble?this.bubble=!1:this.stop(t)}escape(t){}space(t){}left(t){}right(t){}up(t){}down(t){}stop(t){t&&(t.stopPropagation(),t.preventDefault(),t.cancelBubble=!0)}mousedown(t){return this.stop(t)}mouseup(t){return this.stop(t)}mouseover(t){return this.stop(t)}mouseout(t){return this.stop(t)}click(t){return this.stop(t)}addEvents(t){t.addEventListener(r,this.mousedown.bind(this)),t.addEventListener(a,this.mouseup.bind(this)),t.addEventListener(h,this.mouseover.bind(this)),t.addEventListener(u,this.mouseout.bind(this)),t.addEventListener(n,this.click.bind(this)),t.addEventListener("keydown",this.keydown.bind(this)),t.addEventListener("dragstart",this.stop.bind(this)),t.addEventListener(l,this.stop.bind(this)),t.addEventListener("contextmenu",this.stop.bind(this)),t.addEventListener(o,this.stop.bind(this))}}class c extends d{addAttributes(t){for(const e in t)this.html.setAttribute(e,t[e])}get html(){return this._html||this.generateHtml(),this._html}set html(t){this._html=t,this.addEvents(t)}generateHtml(){const t=document.createElement("div");t.classList.add(this.className),t.setAttribute("role",this.role),this.html=t}focus(){const t=this.html;t.setAttribute("tabindex","0"),t.focus()}unfocus(){const t=this.html;t.hasAttribute("tabindex")&&t.setAttribute("tabindex","-1");try{t.blur()}catch(t){}t.blur()}}class p extends c{constructor(){super(...arguments),this.posted=!1}isPosted(){return this.posted}post(t,e){this.posted||(void 0!==t&&void 0!==e&&this.html.setAttribute("style","left: "+t+"px; top: "+e+"px;"),this.display(),this.posted=!0)}unpost(){if(!this.posted)return;const t=this.html;t.parentNode&&t.parentNode.removeChild(t),this.posted=!1}}const m="CtxtMenu";function b(t){return m+"_"+t}function f(t){return b(t)}function E(t){return b(t)}const g={ATTACHED:f("Attached"),CONTEXTMENU:f("ContextMenu"),MENU:f("Menu"),MENUARROW:f("MenuArrow"),MENUACTIVE:f("MenuActive"),MENUCHECK:f("MenuCheck"),MENUCLOSE:f("MenuClose"),MENUCOMBOBOX:f("MenuComboBox"),MENUDISABLED:f("MenuDisabled"),MENUFRAME:f("MenuFrame"),MENUITEM:f("MenuItem"),MENULABEL:f("MenuLabel"),MENURADIOCHECK:f("MenuRadioCheck"),MENUINPUTBOX:f("MenuInputBox"),MENURULE:f("MenuRule"),MENUSLIDER:f("MenuSlider"),MOUSEPOST:f("MousePost"),RTL:f("RTL"),INFO:f("Info"),INFOCLOSE:f("InfoClose"),INFOCONTENT:f("InfoContent"),INFOSIGNATURE:f("InfoSignature"),INFOTITLE:f("InfoTitle"),SLIDERVALUE:f("SliderValue"),SLIDERBAR:f("SliderBar"),SELECTION:f("Selection"),SELECTIONBOX:f("SelectionBox"),SELECTIONMENU:f("SelectionMenu"),SELECTIONDIVIDER:f("SelectionDivider"),SELECTIONITEM:f("SelectionItem")},x={COUNTER:E("Counter"),KEYDOWNFUNC:E("keydownFunc"),CONTEXTMENUFUNC:E("contextmenuFunc"),OLDTAB:E("Oldtabindex"),TOUCHFUNC:E("TouchFunc")};class v extends c{constructor(t,e){super(),this._menu=t,this._type=e,this.className=g.MENUITEM,this.role="menuitem",this.hidden=!1}get menu(){return this._menu}set menu(t){this._menu=t}get type(){return this._type}hide(){this.hidden=!0,this.menu.generateMenu()}show(){this.hidden=!1,this.menu.generateMenu()}isHidden(){return this.hidden}}function C(t){const e=t.menu;e.baseMenu?e.baseMenu.unpost():e.unpost()}function w(t){const e=t.menu;return(e.baseMenu?e.baseMenu:e).store.active}function M(t,e){console.error("ContextMenu Error: "+e)}function N(){return y++}let y=0;class L extends v{constructor(t,e,s,i){super(t,e),this._content=s,this.disabled=!1,this.callbacks=[],this._id=i||s}get content(){return this._content}set content(t){this._content=t,this.generateHtml(),this.menu&&this.menu.generateHtml()}get id(){return this._id}press(){this.disabled||(this.executeAction(),this.executeCallbacks_())}executeAction(){}registerCallback(t){-1===this.callbacks.indexOf(t)&&this.callbacks.push(t)}unregisterCallback(t){const e=this.callbacks.indexOf(t);-1!==e&&this.callbacks.splice(e,1)}mousedown(t){this.press(),this.stop(t)}mouseover(t){this.focus(),this.stop(t)}mouseout(t){this.deactivate(),this.stop(t)}generateHtml(){super.generateHtml();const t=this.html;t.setAttribute("aria-disabled","false"),t.textContent=this.content}activate(){this.disabled||this.html.classList.add(g.MENUACTIVE)}deactivate(){this.html.classList.remove(g.MENUACTIVE)}focus(){this.menu.focused=this,super.focus(),this.activate()}unfocus(){this.deactivate(),super.unfocus()}escape(t){C(this)}up(t){this.menu.up(t)}down(t){this.menu.down(t)}left(t){this.menu.left(t)}right(t){this.menu.right(t)}space(t){this.press()}disable(){this.disabled=!0;const t=this.html;t.classList.add(g.MENUDISABLED),t.setAttribute("aria-disabled","true")}enable(){this.disabled=!1;const t=this.html;t.classList.remove(g.MENUDISABLED),t.removeAttribute("aria-disabled")}executeCallbacks_(){for(const t of this.callbacks)try{t(this)}catch(t){M(0,"Callback for menu entry "+this.id+" failed.")}}}class O extends L{static fromJson(t,{content:e,menu:s,id:i},n){const o=new this(n,e,i),r=t.get("subMenu")(t,s,o);return o.submenu=r,o}constructor(t,e,s){super(t,"submenu",e,s),this._submenu=null}set submenu(t){this._submenu=t}get submenu(){return this._submenu}mouseover(t){this.focus(),this.stop(t)}mouseout(t){this.stop(t)}unfocus(){if(this.submenu.isPosted()){if(this.menu.focused!==this)return super.unfocus(),void this.menu.unpostSubmenus();this.html.setAttribute("tabindex","-1"),this.html.blur()}else super.unfocus()}focus(){super.focus(),this.submenu.isPosted()||this.disabled||this.submenu.post()}executeAction(){this.submenu.isPosted()?this.submenu.unpost():this.submenu.post()}generateHtml(){super.generateHtml();const t=this.html;this.span=document.createElement("span"),this.span.textContent="\u25ba",this.span.classList.add(g.MENUARROW),t.appendChild(this.span),t.setAttribute("aria-haspopup","true")}left(t){this.submenu.isPosted()?this.submenu.unpost():super.left(t)}right(t){this.submenu.isPosted()?this.submenu.down(t):this.submenu.post()}toJson(){return{type:""}}}class A extends p{constructor(){super(...arguments),this.className=g.CONTEXTMENU,this.role="menu",this._items=[],this._baseMenu=null}set baseMenu(t){this._baseMenu=t}get baseMenu(){return this._baseMenu}get items(){return this._items}set items(t){this._items=t}get pool(){return this.variablePool}get focused(){return this._focused}set focused(t){if(this._focused===t)return;this._focused||this.unfocus();const e=this._focused;this._focused=t,e&&e.unfocus()}up(t){const e=this.items.filter((t=>t instanceof L&&!t.isHidden()));if(0===e.length)return;if(!this.focused)return void e[e.length-1].focus();let s=e.indexOf(this.focused);-1!==s&&(s=s?--s:e.length-1,e[s].focus())}down(t){const e=this.items.filter((t=>t instanceof L&&!t.isHidden()));if(0===e.length)return;if(!this.focused)return void e[0].focus();let s=e.indexOf(this.focused);-1!==s&&(s++,s=s===e.length?0:s,e[s].focus())}generateHtml(){super.generateHtml(),this.generateMenu()}generateMenu(){const t=this.html;t.classList.add(g.MENU);for(const e of this.items){if(!e.isHidden()){t.appendChild(e.html);continue}const s=e.html;s.parentNode&&s.parentNode.removeChild(s)}}post(t,e){this.variablePool.update(),super.post(t,e)}unpostSubmenus(){const t=this.items.filter((t=>t instanceof O));for(const e of t)e.submenu.unpost(),e!==this.focused&&e.unfocus()}unpost(){super.unpost(),this.unpostSubmenus(),this.focused=null}find(t){for(const e of this.items)if("rule"!==e.type){if(e.id===t)return e;if("submenu"===e.type){const s=e.submenu.find(t);if(s)return s}}return null}}class S{constructor(t){this.menu=t,this.store=[],this._active=null,this.counter=0,this.attachedClass=g.ATTACHED+"_"+N(),this.taborder=!0,this.attrMap={}}set active(t){do{if(-1!==this.store.indexOf(t)){this._active=t;break}t=t.parentNode}while(t)}get active(){return this._active}next(){const t=this.store.length;if(0===t)return this.active=null,null;let e=this.store.indexOf(this.active);return e=-1===e?0:e<t-1?e+1:0,this.active=this.store[e],this.active}previous(){const t=this.store.length;if(0===t)return this.active=null,null;const e=t-1;let s=this.store.indexOf(this.active);return s=-1===s||0===s?e:s-1,this.active=this.store[s],this.active}clear(){this.remove(this.store)}insert(t){const e=t instanceof HTMLElement?[t]:t;for(const t of e)this.insertElement(t);this.sort()}remove(t){const e=t instanceof HTMLElement?[t]:t;for(const t of e)this.removeElement(t);this.sort()}inTaborder(t){this.taborder&&!t&&this.removeTaborder(),!this.taborder&&t&&this.insertTaborder(),this.taborder=t}insertTaborder(){this.taborder&&this.insertTaborder_()}removeTaborder(){this.taborder&&this.removeTaborder_()}insertElement(t){t.classList.contains(this.attachedClass)||(t.classList.add(this.attachedClass),this.taborder&&this.addTabindex(t),this.addEvents(t))}removeElement(t){t.classList.contains(this.attachedClass)&&(t.classList.remove(this.attachedClass),this.taborder&&this.removeTabindex(t),this.removeEvents(t))}sort(){const t=document.getElementsByClassName(this.attachedClass);this.store=[].slice.call(t)}insertTaborder_(){this.store.forEach((t=>t.setAttribute("tabindex","0")))}removeTaborder_(){this.store.forEach((t=>t.setAttribute("tabindex","-1")))}addTabindex(t){t.hasAttribute("tabindex")&&t.setAttribute(x.OLDTAB,t.getAttribute("tabindex")),t.setAttribute("tabindex","0")}removeTabindex(t){t.hasAttribute(x.OLDTAB)?(t.setAttribute("tabindex",t.getAttribute(x.OLDTAB)),t.removeAttribute(x.OLDTAB)):t.removeAttribute("tabindex")}addEvents(t){t.hasAttribute(x.COUNTER)||(this.addEvent(t,"contextmenu",this.menu.post.bind(this.menu)),this.addEvent(t,"keydown",this.keydown.bind(this)),t.setAttribute(x.COUNTER,this.counter.toString()),this.counter++)}addEvent(t,e,s){const i=x[e.toUpperCase()+"FUNC"];this.attrMap[i+this.counter]=s,t.addEventListener(e,s)}removeEvents(t){if(!t.hasAttribute(x.COUNTER))return;const e=t.getAttribute(x.COUNTER);this.removeEvent(t,"contextmenu",e),this.removeEvent(t,"keydown",e),t.removeAttribute(x.COUNTER)}removeEvent(t,e,s){const i=x[e.toUpperCase()+"FUNC"],n=this.attrMap[i+s];t.removeEventListener(e,n)}keydown(t){t.keyCode===s.SPACE&&(this.menu.post(t),t.preventDefault(),t.stopImmediatePropagation())}}class T{constructor(){this.pool={}}insert(t){this.pool[t.name]=t}lookup(t){return this.pool[t]}remove(t){delete this.pool[t]}update(){for(const t in this.pool)this.pool[t].update()}}class U extends A{static fromJson(t,{pool:e,items:s,id:i=""}){const n=new this(t);n.id=i;const o=t.get("variable");e.forEach((e=>o(t,e,n.pool)));const r=t.get("items")(t,s,n);return n.items=r,n}constructor(t){super(),this.factory=t,this.id="",this.moving=!1,this._store=new S(this),this.widgets=[],this.variablePool=new T}generateHtml(){this.isPosted()&&this.unpost(),super.generateHtml(),this._frame=document.createElement("div"),this._frame.classList.add(g.MENUFRAME);const t="left: 0px; top: 0px; z-index: 200; width: 100%; height: 100%; border: 0px; padding: 0px; margin: 0px;";this._frame.setAttribute("style","position: absolute; "+t);const e=document.createElement("div");e.setAttribute("style","position: fixed; "+t),this._frame.appendChild(e),e.addEventListener("mousedown",function(t){this.unpost(),this.unpostWidgets(),this.stop(t)}.bind(this))}display(){document.body.appendChild(this.frame),this.frame.appendChild(this.html),this.focus()}escape(t){this.unpost(),this.unpostWidgets()}unpost(){if(super.unpost(),this.widgets.length>0)return;this.frame.parentNode.removeChild(this.frame);const t=this.store;this.moving||t.insertTaborder(),t.active.focus()}left(t){this.move_(this.store.previous())}right(t){this.move_(this.store.next())}get frame(){return this._frame}get store(){return this._store}post(t,e){if(void 0!==e)return this.moving||this.store.removeTaborder(),void super.post(t,e);const s=t;let i,n,o;if(s instanceof Event?(i=s.target,this.stop(s)):i=s,s instanceof MouseEvent&&(n=s.pageX,o=s.pageY,n||o||!s.clientX||(n=s.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,o=s.clientY+document.body.scrollTop+document.documentElement.scrollTop)),!n&&!o&&i){const t=window.pageXOffset||document.documentElement.scrollLeft,e=window.pageYOffset||document.documentElement.scrollTop,s=i.getBoundingClientRect();n=(s.right+s.left)/2+t,o=(s.bottom+s.top)/2+e}this.store.active=i,this.anchor=this.store.active;const r=this.html;n+r.offsetWidth>document.body.offsetWidth-5&&(n=document.body.offsetWidth-r.offsetWidth-5),this.post(n,o)}registerWidget(t){this.widgets.push(t)}unregisterWidget(t){const e=this.widgets.indexOf(t);e>-1&&this.widgets.splice(e,1),0===this.widgets.length&&this.unpost()}unpostWidgets(){this.widgets.forEach((t=>t.unpost()))}toJson(){return{type:""}}move_(t){this.anchor&&t!==this.anchor&&(this.moving=!0,this.unpost(),this.post(t),this.moving=!1)}}function k(t){return"."+(g[t]||t)}const I={};I[k("INFOCLOSE")]="{ top:.2em; right:.2em;}",I[k("INFOCONTENT")]="{ overflow:auto; text-align:left; font-size:80%; padding:.4em .6em; border:1px inset; margin:1em 0px; max-height:20em; max-width:30em; background-color:#EEEEEE; white-space:normal;}",I[k("INFO")+k("MOUSEPOST")]="{outline:none;}",I[k("INFO")]='{ position:fixed; left:50%; width:auto; text-align:center; border:3px outset; padding:1em 2em; background-color:#DDDDDD; color:black; cursor:default; font-family:message-box; font-size:120%; font-style:normal; text-indent:0; text-transform:none; line-height:normal; letter-spacing:normal; word-spacing:normal; word-wrap:normal; white-space:nowrap; float:none; z-index:201; border-radius: 15px; /* Opera 10.5 and IE9 */ -webkit-border-radius:15px; /* Safari and Chrome */ -moz-border-radius:15px; /* Firefox */ -khtml-border-radius:15px; /* Konqueror */ box-shadow:0px 10px 20px #808080; /* Opera 10.5 and IE9 */ -webkit-box-shadow:0px 10px 20px #808080; /* Safari 3 & Chrome */ -moz-box-shadow:0px 10px 20px #808080; /* Forefox 3.5 */ -khtml-box-shadow:0px 10px 20px #808080; /* Konqueror */ filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color="gray", Positive="true"); /* IE */}';const _={};_[k("MENU")]="{ position:absolute; background-color:white; color:black; width:auto; padding:5px 0px; border:1px solid #CCCCCC; margin:0; cursor:default; font: menu; text-align:left; text-indent:0; text-transform:none; line-height:normal; letter-spacing:normal; word-spacing:normal; word-wrap:normal; white-space:nowrap; float:none; z-index:201; border-radius: 5px; /* Opera 10.5 and IE9 */ -webkit-border-radius: 5px; /* Safari and Chrome */ -moz-border-radius: 5px; /* Firefox */ -khtml-border-radius: 5px; /* Konqueror */ box-shadow:0px 10px 20px #808080; /* Opera 10.5 and IE9 */ -webkit-box-shadow:0px 10px 20px #808080; /* Safari 3 & Chrome */ -moz-box-shadow:0px 10px 20px #808080; /* Forefox 3.5 */ -khtml-box-shadow:0px 10px 20px #808080; /* Konqueror */}",_[k("MENUITEM")]="{ padding: 1px 2em; background:transparent;}",_[k("MENUARROW")]="{ position:absolute; right:.5em; padding-top:.25em; color:#666666; font-family: null; font-size: .75em}",_[k("MENUACTIVE")+" "+k("MENUARROW")]="{color:white}",_[k("MENUARROW")+k("RTL")]="{left:.5em; right:auto}",_[k("MENUCHECK")]="{ position:absolute; left:.7em; font-family: null}",_[k("MENUCHECK")+k("RTL")]="{ right:.7em; left:auto }",_[k("MENURADIOCHECK")]="{ position:absolute; left: .7em;}",_[k("MENURADIOCHECK")+k("RTL")]="{ right: .7em; left:auto}",_[k("MENUINPUTBOX")]="{ padding-left: 1em; right:.5em; color:#666666; font-family: null;}",_[k("MENUINPUTBOX")+k("RTL")]="{ left: .1em;}",_[k("MENUCOMBOBOX")]="{ left:.1em; padding-bottom:.5em;}",_[k("MENUSLIDER")]="{ left: .1em;}",_[k("SLIDERVALUE")]="{ position:absolute; right:.1em; padding-top:.25em; color:#333333; font-size: .75em}",_[k("SLIDERBAR")]="{ outline: none; background: #d3d3d3}",_[k("MENULABEL")]="{ padding: 1px 2em 3px 1.33em; font-style:italic}",_[k("MENURULE")]="{ border-top: 1px solid #DDDDDD; margin: 4px 3px;}",_[k("MENUDISABLED")]="{ color:GrayText}",_[k("MENUACTIVE")]="{ background-color: #606872; color: white;}",_[k("MENUDISABLED")+":focus"]="{ background-color: #E8E8E8}",_[k("MENULABEL")+":focus"]="{ background-color: #E8E8E8}",_[k("CONTEXTMENU")+":focus"]="{ outline:none}",_[k("CONTEXTMENU")+" "+k("MENUITEM")+":focus"]="{ outline:none}",_[k("SELECTIONMENU")]="{ position:relative; float:left; border-bottom: none; -webkit-box-shadow:none; -webkit-border-radius:0px; }",_[k("SELECTIONITEM")]="{ padding-right: 1em;}",_[k("SELECTION")]="{ right: 40%; width:50%; }",_[k("SELECTIONBOX")]="{ padding: 0em; max-height:20em; max-width: none; background-color:#FFFFFF;}",_[k("SELECTIONDIVIDER")]="{ clear: both; border-top: 2px solid #000000;}",_[k("MENU")+" "+k("MENUCLOSE")]="{ top:-10px; left:-10px}";const D={};D[k("MENUCLOSE")]='{ position:absolute; cursor:pointer; display:inline-block; border:2px solid #AAA; border-radius:18px; -webkit-border-radius: 18px; /* Safari and Chrome */ -moz-border-radius: 18px; /* Firefox */ -khtml-border-radius: 18px; /* Konqueror */ font-family: "Courier New", Courier; font-size:24px; color:#F0F0F0}',D[k("MENUCLOSE")+" span"]="{ display:block; background-color:#AAA; border:1.5px solid; border-radius:18px; -webkit-border-radius: 18px; /* Safari and Chrome */ -moz-border-radius: 18px; /* Firefox */ -khtml-border-radius: 18px; /* Konqueror */ line-height:0; padding:8px 0 6px /* may need to be browser-specific */}",D[k("MENUCLOSE")+":hover"]="{ color:white!important; border:2px solid #CCC!important}",D[k("MENUCLOSE")+":hover span"]="{ background-color:#CCC!important}",D[k("MENUCLOSE")+":hover:focus"]="{ outline:none}";let R=!1,H=!1,P=!1;function F(t){H||(W(_,t),H=!0,J(t))}function B(t){R||(W(I,t),R=!0,J(t))}function J(t){P||(W(D,t),P=!0)}function W(t,e){const s=e||document,i=s.createElement("style");i.type="text/css";let n="";for(const e in t)n+=e,n+=" ",n+=t[e],n+="\n";i.innerHTML=n,s.head.appendChild(i)}class V extends p{constructor(t){super(),this.element=t,this.className=g.MENUCLOSE,this.role="button"}generateHtml(){const t=document.createElement("span");t.classList.add(this.className),t.setAttribute("role",this.role),t.setAttribute("tabindex","0");const e=document.createElement("span");e.textContent="\xd7",t.appendChild(e),this.html=t}display(){}unpost(){super.unpost(),this.element.unpost()}keydown(t){this.bubbleKey(),super.keydown(t)}space(t){this.unpost(),this.stop(t)}mousedown(t){this.unpost(),this.stop(t)}}class z extends p{constructor(t,e,s){super(),this.title=t,this.signature=s,this.className=g.INFO,this.role="dialog",this.contentDiv=this.generateContent(),this.close=this.generateClose(),this.content=e||function(){return""}}attachMenu(t){this.menu=t}generateHtml(){super.generateHtml();const t=this.html;t.appendChild(this.generateTitle()),t.appendChild(this.contentDiv),t.appendChild(this.generateSignature()),t.appendChild(this.close.html),t.setAttribute("tabindex","0")}post(){super.post();const t=document.documentElement,e=this.html,s=window.innerHeight||t.clientHeight||t.scrollHeight||0,i=Math.floor(-e.offsetWidth/2),n=Math.floor((s-e.offsetHeight)/3);e.setAttribute("style","margin-left: "+i+"px; top: "+n+"px;"),window.event instanceof MouseEvent&&e.classList.add(g.MOUSEPOST),e.focus()}display(){this.menu.registerWidget(this),this.contentDiv.innerHTML=this.content();const t=this.menu.html;t.parentNode&&t.parentNode.removeChild(t),this.menu.frame.appendChild(this.html)}click(t){}keydown(t){this.bubbleKey(),super.keydown(t)}escape(t){this.unpost()}unpost(){super.unpost(),this.html.classList.remove(g.MOUSEPOST),this.menu.unregisterWidget(this)}generateClose(){const t=new V(this),e=t.html;return e.classList.add(g.INFOCLOSE),e.setAttribute("aria-label","Close Dialog Box"),t}generateTitle(){const t=document.createElement("span");return t.innerHTML=this.title,t.classList.add(g.INFOTITLE),t}generateContent(){const t=document.createElement("div");return t.classList.add(g.INFOCONTENT),t.setAttribute("tabindex","0"),t}generateSignature(){const t=document.createElement("span");return t.innerHTML=this.signature,t.classList.add(g.INFOSIGNATURE),t}toJson(){return{type:""}}}class K extends p{constructor(t,e){super(),this.title=t,this.window=null,this.localSettings={left:Math.round((screen.width-400)/2),top:Math.round((screen.height-300)/3)},this.windowList=[],this.mobileFlag=!1,this.active=null,this.content=e||function(){return""}}attachMenu(t){this.menu=t}post(){this.display()}display(){this.active=this.menu.store.active;const t=[];for(const e in K.popupSettings)t.push(e+"="+K.popupSettings[e]);for(const e in this.localSettings)t.push(e+"="+this.localSettings[e]);this.window=window.open("","_blank",t.join(",")),this.windowList.push(this.window);const e=this.window.document;this.mobileFlag?(e.open(),e.write('<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>'+this.title+'</title></head><body style="font-size:85%">'),e.write("<pre>"+this.generateContent()+"</pre>"),e.write('<hr><input type="button" value="Close" onclick="window.close()" />'),e.write("</body></html>"),e.close()):(e.open(),e.write("<html><head><title>"+this.title+'</title></head><body style="font-size:85%">'),e.write("<table><tr><td><pre>"+this.generateContent()+"</pre></td></tr></table>"),e.write("</body></html>"),e.close(),setTimeout(this.resize.bind(this),50))}unpost(){this.windowList.forEach((t=>t.close())),this.window=null}generateContent(){return this.content(this.active)}resize(){const t=this.window.document.body.firstChild;let e=this.window.outerHeight-this.window.innerHeight||30,s=this.window.outerWidth-this.window.innerWidth||30;s=Math.max(140,Math.min(Math.floor(.5*this.window.screen.width),t.offsetWidth+s+25)),e=Math.max(40,Math.min(Math.floor(.5*this.window.screen.height),t.offsetHeight+e+25)),this.window.resizeTo(s,e);const i=this.active.getBoundingClientRect();if(i){const t=Math.max(0,Math.min(i.right-Math.floor(s/2),this.window.screen.width-s-20)),n=Math.max(0,Math.min(i.bottom-Math.floor(e/2),this.window.screen.height-e-20));this.window.moveTo(t,n)}this.active=null}toJson(){return{type:""}}}K.popupSettings={status:"no",toolbar:"no",locationbar:"no",menubar:"no",directories:"no",personalbar:"no",resizable:"yes",scrollbars:"yes",width:400,height:300};class X extends L{static fromJson(t,{content:e,action:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"command",e,i),this.command=s}executeAction(){try{this.command(w(this))}catch(t){M(0,"Illegal command callback.")}C(this)}toJson(){return{type:""}}}class j{static fromJson(t,{name:e,getter:s,setter:i},n){const o=new this(e,s,i);n.insert(o)}constructor(t,e,s){this._name=t,this.getter=e,this.setter=s,this.items=[]}get name(){return this._name}getValue(t){try{return this.getter(t)}catch(t){return M(0,"Command of variable "+this.name+" failed."),null}}setValue(t,e){try{this.setter(t,e)}catch(t){M(0,"Command of variable "+this.name+" failed.")}this.update()}register(t){-1===this.items.indexOf(t)&&this.items.push(t)}unregister(t){const e=this.items.indexOf(t);-1!==e&&this.items.splice(e,1)}update(){this.items.forEach((t=>t.update()))}registerCallback(t){this.items.forEach((e=>e.registerCallback(t)))}unregisterCallback(t){this.items.forEach((e=>e.unregisterCallback(t)))}toJson(){return{type:"variable",name:this.name,getter:this.getter.toString(),setter:this.setter.toString()}}}class q extends L{generateHtml(){super.generateHtml();const t=this.html;this.span||this.generateSpan(),t.appendChild(this.span),this.update()}register(){this.variable.register(this)}unregister(){this.variable.unregister(this)}update(){this.updateAria(),this.span&&this.updateSpan()}}class G extends q{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"checkbox",e,i),this.role="menuitemcheckbox",this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(!this.variable.getValue()),C(this)}generateSpan(){this.span=document.createElement("span"),this.span.textContent="\u2713",this.span.classList.add(g.MENUCHECK)}updateAria(){this.html.setAttribute("aria-checked",this.variable.getValue()?"true":"false")}updateSpan(){this.span.style.display=this.variable.getValue()?"":"none"}toJson(){return{type:""}}}class Y extends q{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"combobox",e,i),this.role="combobox",this.inputEvent=!1,this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.input.value,w(this))}space(t){super.space(t),C(this)}focus(){super.focus(),this.input.focus()}unfocus(){super.unfocus(),this.updateSpan()}generateHtml(){super.generateHtml();this.html.classList.add(g.MENUCOMBOBOX)}generateSpan(){this.span=document.createElement("span"),this.span.classList.add(g.MENUINPUTBOX),this.input=document.createElement("input"),this.input.addEventListener("keydown",this.inputKey.bind(this)),this.input.setAttribute("size","10em"),this.input.setAttribute("type","text"),this.input.setAttribute("tabindex","-1"),this.span.appendChild(this.input)}inputKey(t){this.bubbleKey(),this.inputEvent=!0}keydown(t){if(this.inputEvent&&t.keyCode!==s.ESCAPE&&t.keyCode!==s.RETURN)return this.inputEvent=!1,void t.stopPropagation();super.keydown(t),t.stopPropagation()}updateAria(){}updateSpan(){let t;try{t=this.variable.getValue(w(this))}catch(e){t=""}this.input.value=t}toJson(){return{type:""}}}class Q extends L{static fromJson(t,{content:e,id:s},i){return new this(i,e,s)}constructor(t,e,s){super(t,"label",e,s)}generateHtml(){super.generateHtml();this.html.classList.add(g.MENULABEL)}toJson(){return{type:""}}}class Z extends q{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"radio",e,i),this.role="menuitemradio",this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.id),C(this)}generateSpan(){this.span=document.createElement("span"),this.span.textContent="\u2713",this.span.classList.add(g.MENURADIOCHECK)}updateAria(){this.html.setAttribute("aria-checked",this.variable.getValue()===this.id?"true":"false")}updateSpan(){this.span.style.display=this.variable.getValue()===this.id?"":"none"}toJson(){return{type:""}}}class $ extends v{static fromJson(t,e,s){return new this(s)}constructor(t){super(t,"rule"),this.className=g.MENUITEM,this.role="separator"}generateHtml(){super.generateHtml();const t=this.html;t.classList.add(g.MENURULE),t.setAttribute("aria-orientation","vertical")}addEvents(t){}toJson(){return{type:"rule"}}}class tt extends q{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"slider",e,i),this.role="slider",this.labelId="ctx_slideLabel"+N(),this.valueId="ctx_slideValue"+N(),this.inputEvent=!1,this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.input.value,w(this)),this.update()}space(t){super.space(t),C(this)}focus(){super.focus(),this.input.focus()}unfocus(){super.unfocus(),this.updateSpan()}generateHtml(){super.generateHtml();this.html.classList.add(g.MENUSLIDER),this.valueSpan=document.createElement("span"),this.valueSpan.setAttribute("id",this.valueId),this.valueSpan.classList.add(g.SLIDERVALUE),this.html.appendChild(this.valueSpan)}generateSpan(){this.span=document.createElement("span"),this.labelSpan=document.createElement("span"),this.labelSpan.setAttribute("id",this.labelId),this.labelSpan.appendChild(this.html.childNodes[0]),this.html.appendChild(this.labelSpan),this.input=document.createElement("input"),this.input.setAttribute("type","range"),this.input.setAttribute("min","0"),this.input.setAttribute("max","100"),this.input.setAttribute("aria-valuemin","0"),this.input.setAttribute("aria-valuemax","100"),this.input.setAttribute("aria-labelledby",this.labelId),this.input.addEventListener("keydown",this.inputKey.bind(this)),this.input.addEventListener("input",this.executeAction.bind(this)),this.input.classList.add(g.SLIDERBAR),this.span.appendChild(this.input)}inputKey(t){this.inputEvent=!0}mousedown(t){t.stopPropagation()}mouseup(t){event.stopPropagation()}keydown(t){const e=t.keyCode;return e===s.UP||e===s.DOWN?(t.preventDefault(),void super.keydown(t)):this.inputEvent&&e!==s.ESCAPE&&e!==s.RETURN?(this.inputEvent=!1,void t.stopPropagation()):(super.keydown(t),void t.stopPropagation())}updateAria(){const t=this.variable.getValue();t&&this.input&&(this.input.setAttribute("aria-valuenow",t),this.input.setAttribute("aria-valuetext",t+"%"))}updateSpan(){let t;try{t=this.variable.getValue(w(this)),this.valueSpan.innerHTML=t+"%"}catch(e){t=""}this.input.value=t}toJson(){return{type:""}}}class et extends A{static fromJson(t,{items:e},s){const i=new this(s),n=t.get("items")(t,e,i);return i.items=n,i}constructor(t){super(),this._anchor=t,this.variablePool=this.anchor.menu.pool,this.setBaseMenu()}get anchor(){return this._anchor}post(){if(!this.anchor.menu.isPosted())return;let t=this.anchor.html;const e=this.html,s=this.baseMenu.frame,i=t.offsetWidth;let n=i-2,o=0;for(;t&&t!==s;)n+=t.offsetLeft,o+=t.offsetTop,t=t.parentNode;n+e.offsetWidth>document.body.offsetWidth-5&&(n=Math.max(5,n-i-e.offsetWidth+6)),super.post(n,o)}display(){this.baseMenu.frame.appendChild(this.html)}setBaseMenu(){let t=this;do{t=t.anchor.menu}while(t instanceof et);this.baseMenu=t}left(t){this.focused=null,this.anchor.focus()}toJson(){return{type:""}}}class st extends A{static fromJson(t,{title:e,values:s,variable:i},n){const o=new this(n),r=t.get("label")(t,{content:e||"",id:e||"id"},o),a=t.get("rule")(t,{},o),h=s.map((e=>t.get("radio")(t,{content:e,variable:i,id:e},o))),u=[r,a].concat(h);return o.items=u,o}constructor(t){super(),this.anchor=t,this.className=g.SELECTIONMENU,this.variablePool=this.anchor.menu.pool,this.baseMenu=this.anchor.menu}generateHtml(){super.generateHtml(),this.items.forEach((t=>t.html.classList.add(g.SELECTIONITEM)))}display(){}right(t){this.anchor.right(t)}left(t){this.anchor.left(t)}}class it extends z{static fromJson(t,{title:e,signature:s,selections:i,order:n,grid:o},r){const a=new this(e,s,n,o);a.attachMenu(r);const h=i.map((e=>t.get("selectionMenu")(t,e,a)));return a.selections=h,a}constructor(t,e,s="none",i="vertical"){super(t,null,e),this.style=s,this.grid=i,this._selections=[],this.prefix="ctxt-selection",this._balanced=!0}attachMenu(t){this.menu=t}get selections(){return this._selections}set selections(t){this._selections=[],t.forEach((t=>this.addSelection(t)))}addSelection(t){t.anchor=this,this._selections.push(t)}rowDiv(t){const e=document.createElement("div");this.contentDiv.appendChild(e);const s=t.map((t=>(e.appendChild(t.html),t.html.id||(t.html.id=this.prefix+N()),t.html.getBoundingClientRect()))),i=s.map((t=>t.width)),n=i.reduce(((t,e)=>t+e),0),o=s.reduce(((t,e)=>Math.max(t,e.height)),0);return e.classList.add(g.SELECTIONDIVIDER),e.setAttribute("style","height: "+o+"px;"),[e,n,o,i]}display(){if(super.display(),this.order(),!this.selections.length)return;const t=[];let e=0,s=[];const i=this.getChunkSize(this.selections.length);for(let n=0;n<this.selections.length;n+=i){const o=this.selections.slice(n,n+i),[r,a,h,u]=this.rowDiv(o);t.push(r),e=Math.max(e,a),o.forEach((t=>t.html.style.height=h+"px")),s=this.combineColumn(s,u)}this._balanced&&(this.balanceColumn(t,s),e=s.reduce(((t,e)=>t+e),20)),t.forEach((t=>t.style.width=e+"px"))}getChunkSize(t){switch(this.grid){case"square":return Math.floor(Math.sqrt(t));case"horizontal":return Math.floor(t/it.chunkSize);default:return it.chunkSize}}balanceColumn(t,e){t.forEach((t=>{const s=Array.from(t.children);for(let t,i=0;t=s[i];i++)t.style.width=e[i]+"px"}))}combineColumn(t,e){let s=[],i=0;for(;t[i]||e[i];){if(!t[i]){s=s.concat(e.slice(i));break}if(!e[i]){s=s.concat(t.slice(i));break}s.push(Math.max(t[i],e[i])),i++}return s}left(t){this.move(t,(t=>(0===t?this.selections.length:t)-1))}right(t){this.move(t,(t=>t===this.selections.length-1?0:t+1))}generateHtml(){super.generateHtml(),this.html.classList.add(g.SELECTION)}generateContent(){const t=super.generateContent();return t.classList.add(g.SELECTIONBOX),t.removeAttribute("tabindex"),t}findSelection(t){const e=t.target;let s=null;if(e.id&&(s=this.selections.find((t=>t.html.id===e.id))),!s){const t=e.parentElement.id;s=this.selections.find((e=>e.html.id===t))}return s}move(t,e){const s=this.findSelection(t);s.focused&&s.focused.unfocus();const i=e(this.selections.indexOf(s));this.selections[i].focus()}order(){this.selections.sort(it.orderMethod.get(this.style))}toJson(){return{type:""}}}it.chunkSize=4,it.orderMethod=new Map([["alphabetical",(t,e)=>t.items[0].content.localeCompare(e.items[0].content)],["none",(t,e)=>1],["decreasing",(t,e)=>{const s=t.items.length,i=e.items.length;return s<i?1:i<s?-1:0}],["increasing",(t,e)=>{const s=t.items.length,i=e.items.length;return s<i?-1:i<s?1:0}]]);class nt{constructor(t){this._parser=new Map(t)}get(t){return this._parser.get(t)}add(t,e){this._parser.set(t,e)}}var ot=function(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(s[i[n]]=t[i[n]])}return s};const rt=U,at=i,ht=z,ut=K,lt=class{constructor(t=[]){this._initList=[["command",X.fromJson.bind(X)],["checkbox",G.fromJson.bind(G)],["combo",Y.fromJson.bind(Y)],["slider",tt.fromJson.bind(tt)],["label",Q.fromJson.bind(Q)],["radio",Z.fromJson.bind(Z)],["rule",$.fromJson.bind($)],["submenu",O.fromJson.bind(O)],["contextMenu",U.fromJson.bind(U)],["subMenu",et.fromJson.bind(et)],["variable",j.fromJson.bind(j)],["items",this.items.bind(this)],["selectionMenu",st.fromJson.bind(st)],["selectionBox",it.fromJson.bind(it)]],this._factory=new nt(this._initList),t.forEach((([t,e])=>this.factory.add(t,e)))}get factory(){return this._factory}items(t,e,s){const i=[];for(const t of e){const e=this.parse(t,s);e&&(s.items.push(e),t.disabled&&e.disable(),t.hidden&&i.push(e))}return i.forEach((t=>t.hide())),s.items}parse(t,...e){var{type:s}=t,i=ot(t,["type"]);const n=this.factory.get(s);return n?n(this.factory,i,...e):null}},dt="0.8.0",ct=it,pt=j,mt=nt;return e})()));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ContextMenu=e():t.ContextMenu=e()}(this,(()=>(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ContextMenu:()=>rt,CssStyles:()=>at,Info:()=>ht,Parser:()=>lt,ParserFactory:()=>mt,Popup:()=>ut,SelectionBox:()=>ct,Variable:()=>pt,version:()=>dt});var s,i={};t.r(i),t.d(i,{addInfoStyles:()=>B,addMenuStyles:()=>F}),function(t){t[t.RETURN=13]="RETURN",t[t.ESCAPE=27]="ESCAPE",t[t.SPACE=32]="SPACE",t[t.LEFT=37]="LEFT",t[t.UP=38]="UP",t[t.RIGHT=39]="RIGHT",t[t.DOWN=40]="DOWN"}(s||(s={}));const n="click",o="dblclick",r="mousedown",a="mouseup",h="mouseover",u="mouseout",l="selectstart";class d{constructor(){this.bubble=!1}bubbleKey(){this.bubble=!0}keydown(t){switch(t.keyCode){case s.ESCAPE:this.escape(t);break;case s.RIGHT:this.right(t);break;case s.LEFT:this.left(t);break;case s.UP:this.up(t);break;case s.DOWN:this.down(t);break;case s.RETURN:case s.SPACE:this.space(t);break;default:return}this.bubble?this.bubble=!1:this.stop(t)}escape(t){}space(t){}left(t){}right(t){}up(t){}down(t){}stop(t){t&&(t.stopPropagation(),t.preventDefault(),t.cancelBubble=!0)}mousedown(t){return this.stop(t)}mouseup(t){return this.stop(t)}mouseover(t){return this.stop(t)}mouseout(t){return this.stop(t)}click(t){return this.stop(t)}addEvents(t){t.addEventListener(r,this.mousedown.bind(this)),t.addEventListener(a,this.mouseup.bind(this)),t.addEventListener(h,this.mouseover.bind(this)),t.addEventListener(u,this.mouseout.bind(this)),t.addEventListener(n,this.click.bind(this)),t.addEventListener("keydown",this.keydown.bind(this)),t.addEventListener("dragstart",this.stop.bind(this)),t.addEventListener(l,this.stop.bind(this)),t.addEventListener("contextmenu",this.stop.bind(this)),t.addEventListener(o,this.stop.bind(this))}}class c extends d{addAttributes(t){for(const e in t)this.html.setAttribute(e,t[e])}get html(){return this._html||this.generateHtml(),this._html}set html(t){this._html=t,this.addEvents(t)}generateHtml(){const t=document.createElement("div");t.classList.add(this.className),t.setAttribute("role",this.role),this.html=t}focus(){const t=this.html;t.setAttribute("tabindex","0"),t.focus()}unfocus(){const t=this.html;t.hasAttribute("tabindex")&&t.setAttribute("tabindex","-1");try{t.blur()}catch(t){}t.blur()}}class p extends c{constructor(){super(...arguments),this.posted=!1}isPosted(){return this.posted}post(t,e){this.posted||(void 0!==t&&void 0!==e&&this.html.setAttribute("style","left: "+t+"px; top: "+e+"px;"),this.display(),this.posted=!0)}unpost(){if(!this.posted)return;const t=this.html;t.parentNode&&t.parentNode.removeChild(t),this.posted=!1}}const m="CtxtMenu";function b(t){return m+"_"+t}function f(t){return b(t)}function E(t){return b(t)}const g={ATTACHED:f("Attached"),CONTEXTMENU:f("ContextMenu"),MENU:f("Menu"),MENUARROW:f("MenuArrow"),MENUACTIVE:f("MenuActive"),MENUCHECK:f("MenuCheck"),MENUCLOSE:f("MenuClose"),MENUCOMBOBOX:f("MenuComboBox"),MENUDISABLED:f("MenuDisabled"),MENUFRAME:f("MenuFrame"),MENUITEM:f("MenuItem"),MENULABEL:f("MenuLabel"),MENURADIOCHECK:f("MenuRadioCheck"),MENUINPUTBOX:f("MenuInputBox"),MENURULE:f("MenuRule"),MENUSLIDER:f("MenuSlider"),MOUSEPOST:f("MousePost"),RTL:f("RTL"),INFO:f("Info"),INFOCLOSE:f("InfoClose"),INFOCONTENT:f("InfoContent"),INFOSIGNATURE:f("InfoSignature"),INFOTITLE:f("InfoTitle"),SLIDERVALUE:f("SliderValue"),SLIDERBAR:f("SliderBar"),SELECTION:f("Selection"),SELECTIONBOX:f("SelectionBox"),SELECTIONMENU:f("SelectionMenu"),SELECTIONDIVIDER:f("SelectionDivider"),SELECTIONITEM:f("SelectionItem")},x={COUNTER:E("Counter"),KEYDOWNFUNC:E("keydownFunc"),CONTEXTMENUFUNC:E("contextmenuFunc"),OLDTAB:E("Oldtabindex"),TOUCHFUNC:E("TouchFunc")};class v extends c{constructor(t,e){super(),this._menu=t,this._type=e,this.className=g.MENUITEM,this.role="menuitem",this.hidden=!1}get menu(){return this._menu}set menu(t){this._menu=t}get type(){return this._type}hide(){this.hidden=!0,this.menu.generateMenu()}show(){this.hidden=!1,this.menu.generateMenu()}isHidden(){return this.hidden}}function C(t){const e=t.menu;e.baseMenu?e.baseMenu.unpost():e.unpost()}function w(t){const e=t.menu;return(e.baseMenu?e.baseMenu:e).store.active}function M(t,e){console.error("ContextMenu Error: "+e)}function N(){return y++}let y=0;class L extends v{constructor(t,e,s,i){super(t,e),this._content=s,this.disabled=!1,this.callbacks=[],this._id=i||s}get content(){return this._content}set content(t){this._content=t,this.generateHtml(),this.menu&&this.menu.generateHtml()}get id(){return this._id}press(){this.disabled||(this.executeAction(),this.executeCallbacks_())}executeAction(){}registerCallback(t){-1===this.callbacks.indexOf(t)&&this.callbacks.push(t)}unregisterCallback(t){const e=this.callbacks.indexOf(t);-1!==e&&this.callbacks.splice(e,1)}mousedown(t){this.press(),this.stop(t)}mouseover(t){this.focus(),this.stop(t)}mouseout(t){this.deactivate(),this.stop(t)}generateHtml(){super.generateHtml();const t=this.html;t.setAttribute("aria-disabled","false"),t.textContent=this.content}activate(){this.disabled||this.html.classList.add(g.MENUACTIVE)}deactivate(){this.html.classList.remove(g.MENUACTIVE)}focus(){this.menu.focused=this,super.focus(),this.activate()}unfocus(){this.deactivate(),super.unfocus()}escape(t){C(this)}up(t){this.menu.up(t)}down(t){this.menu.down(t)}left(t){this.menu.left(t)}right(t){this.menu.right(t)}space(t){this.press()}disable(){this.disabled=!0;const t=this.html;t.classList.add(g.MENUDISABLED),t.setAttribute("aria-disabled","true")}enable(){this.disabled=!1;const t=this.html;t.classList.remove(g.MENUDISABLED),t.removeAttribute("aria-disabled")}executeCallbacks_(){for(const t of this.callbacks)try{t(this)}catch(t){M(0,"Callback for menu entry "+this.id+" failed.")}}}class O extends L{static fromJson(t,{content:e,menu:s,id:i},n){const o=new this(n,e,i),r=t.get("subMenu")(t,s,o);return o.submenu=r,o}constructor(t,e,s){super(t,"submenu",e,s),this._submenu=null}set submenu(t){this._submenu=t}get submenu(){return this._submenu}mouseover(t){this.focus(),this.stop(t)}mouseout(t){this.stop(t)}unfocus(){if(this.submenu.isPosted()){if(this.menu.focused!==this)return super.unfocus(),void this.menu.unpostSubmenus();this.html.setAttribute("tabindex","-1"),this.html.blur()}else super.unfocus()}focus(){super.focus(),this.submenu.isPosted()||this.disabled||this.submenu.post()}executeAction(){this.submenu.isPosted()?this.submenu.unpost():this.submenu.post()}generateHtml(){super.generateHtml();const t=this.html;this.span=document.createElement("span"),this.span.textContent="\u25ba",this.span.classList.add(g.MENUARROW),t.appendChild(this.span),t.setAttribute("aria-haspopup","true")}left(t){this.submenu.isPosted()?this.submenu.unpost():super.left(t)}right(t){this.submenu.isPosted()?this.submenu.down(t):this.submenu.post()}toJson(){return{type:""}}}class A extends p{constructor(){super(...arguments),this.className=g.CONTEXTMENU,this.role="menu",this._items=[],this._baseMenu=null}set baseMenu(t){this._baseMenu=t}get baseMenu(){return this._baseMenu}get items(){return this._items}set items(t){this._items=t}get pool(){return this.variablePool}get focused(){return this._focused}set focused(t){if(this._focused===t)return;this._focused||this.unfocus();const e=this._focused;this._focused=t,e&&e.unfocus()}up(t){const e=this.items.filter((t=>t instanceof L&&!t.isHidden()));if(0===e.length)return;if(!this.focused)return void e[e.length-1].focus();let s=e.indexOf(this.focused);-1!==s&&(s=s?--s:e.length-1,e[s].focus())}down(t){const e=this.items.filter((t=>t instanceof L&&!t.isHidden()));if(0===e.length)return;if(!this.focused)return void e[0].focus();let s=e.indexOf(this.focused);-1!==s&&(s++,s=s===e.length?0:s,e[s].focus())}generateHtml(){super.generateHtml(),this.generateMenu()}generateMenu(){const t=this.html;t.classList.add(g.MENU);for(const e of this.items){if(!e.isHidden()){t.appendChild(e.html);continue}const s=e.html;s.parentNode&&s.parentNode.removeChild(s)}}post(t,e){this.variablePool.update(),super.post(t,e)}unpostSubmenus(){const t=this.items.filter((t=>t instanceof O));for(const e of t)e.submenu.unpost(),e!==this.focused&&e.unfocus()}unpost(){super.unpost(),this.unpostSubmenus(),this.focused=null}find(t){for(const e of this.items)if("rule"!==e.type){if(e.id===t)return e;if("submenu"===e.type){const s=e.submenu.find(t);if(s)return s}}return null}}class S{constructor(t){this.menu=t,this.store=[],this._active=null,this.counter=0,this.attachedClass=g.ATTACHED+"_"+N(),this.taborder=!0,this.attrMap={}}set active(t){do{if(-1!==this.store.indexOf(t)){this._active=t;break}t=t.parentNode}while(t)}get active(){return this._active}next(){const t=this.store.length;if(0===t)return this.active=null,null;let e=this.store.indexOf(this.active);return e=-1===e?0:e<t-1?e+1:0,this.active=this.store[e],this.active}previous(){const t=this.store.length;if(0===t)return this.active=null,null;const e=t-1;let s=this.store.indexOf(this.active);return s=-1===s||0===s?e:s-1,this.active=this.store[s],this.active}clear(){this.remove(this.store)}insert(t){const e=t instanceof HTMLElement?[t]:t;for(const t of e)this.insertElement(t);this.sort()}remove(t){const e=t instanceof HTMLElement?[t]:t;for(const t of e)this.removeElement(t);this.sort()}inTaborder(t){this.taborder&&!t&&this.removeTaborder(),!this.taborder&&t&&this.insertTaborder(),this.taborder=t}insertTaborder(){this.taborder&&this.insertTaborder_()}removeTaborder(){this.taborder&&this.removeTaborder_()}insertElement(t){t.classList.contains(this.attachedClass)||(t.classList.add(this.attachedClass),this.taborder&&this.addTabindex(t),this.addEvents(t))}removeElement(t){t.classList.contains(this.attachedClass)&&(t.classList.remove(this.attachedClass),this.taborder&&this.removeTabindex(t),this.removeEvents(t))}sort(){const t=document.getElementsByClassName(this.attachedClass);this.store=[].slice.call(t)}insertTaborder_(){this.store.forEach((t=>t.setAttribute("tabindex","0")))}removeTaborder_(){this.store.forEach((t=>t.setAttribute("tabindex","-1")))}addTabindex(t){t.hasAttribute("tabindex")&&t.setAttribute(x.OLDTAB,t.getAttribute("tabindex")),t.setAttribute("tabindex","0")}removeTabindex(t){t.hasAttribute(x.OLDTAB)?(t.setAttribute("tabindex",t.getAttribute(x.OLDTAB)),t.removeAttribute(x.OLDTAB)):t.removeAttribute("tabindex")}addEvents(t){t.hasAttribute(x.COUNTER)||(this.addEvent(t,"contextmenu",this.menu.post.bind(this.menu)),this.addEvent(t,"keydown",this.keydown.bind(this)),t.setAttribute(x.COUNTER,this.counter.toString()),this.counter++)}addEvent(t,e,s){const i=x[e.toUpperCase()+"FUNC"];this.attrMap[i+this.counter]=s,t.addEventListener(e,s)}removeEvents(t){if(!t.hasAttribute(x.COUNTER))return;const e=t.getAttribute(x.COUNTER);this.removeEvent(t,"contextmenu",e),this.removeEvent(t,"keydown",e),t.removeAttribute(x.COUNTER)}removeEvent(t,e,s){const i=x[e.toUpperCase()+"FUNC"],n=this.attrMap[i+s];t.removeEventListener(e,n)}keydown(t){t.keyCode===s.SPACE&&(this.menu.post(t),t.preventDefault(),t.stopImmediatePropagation())}}class T{constructor(){this.pool={}}insert(t){this.pool[t.name]=t}lookup(t){return this.pool[t]}remove(t){delete this.pool[t]}update(){for(const t in this.pool)this.pool[t].update()}}class U extends A{static fromJson(t,{pool:e,items:s,id:i=""}){const n=new this(t);n.id=i;const o=t.get("variable");e.forEach((e=>o(t,e,n.pool)));const r=t.get("items")(t,s,n);return n.items=r,n}constructor(t){super(),this.factory=t,this.id="",this.moving=!1,this._store=new S(this),this.widgets=[],this.variablePool=new T}generateHtml(){this.isPosted()&&this.unpost(),super.generateHtml(),this._frame=document.createElement("div"),this._frame.classList.add(g.MENUFRAME);const t="left: 0px; top: 0px; z-index: 200; width: 100%; height: 100%; border: 0px; padding: 0px; margin: 0px;";this._frame.setAttribute("style","position: absolute; "+t);const e=document.createElement("div");e.setAttribute("style","position: fixed; "+t),this._frame.appendChild(e),e.addEventListener("mousedown",function(t){this.unpost(),this.unpostWidgets(),this.stop(t)}.bind(this))}display(){document.body.appendChild(this.frame),this.frame.appendChild(this.html),this.focus()}escape(t){this.unpost(),this.unpostWidgets()}unpost(){if(super.unpost(),this.widgets.length>0)return;this.frame.parentNode.removeChild(this.frame);const t=this.store;this.moving||t.insertTaborder(),t.active.focus()}left(t){this.move_(this.store.previous())}right(t){this.move_(this.store.next())}get frame(){return this._frame}get store(){return this._store}post(t,e){if(void 0!==e)return this.moving||this.store.removeTaborder(),void super.post(t,e);const s=t;let i,n,o;if(s instanceof Event?(i=s.target,this.stop(s)):i=s,s instanceof MouseEvent&&(n=s.pageX,o=s.pageY,n||o||!s.clientX||(n=s.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,o=s.clientY+document.body.scrollTop+document.documentElement.scrollTop)),!n&&!o&&i){const t=window.pageXOffset||document.documentElement.scrollLeft,e=window.pageYOffset||document.documentElement.scrollTop,s=i.getBoundingClientRect();n=(s.right+s.left)/2+t,o=(s.bottom+s.top)/2+e}this.store.active=i,this.anchor=this.store.active;const r=this.html;n+r.offsetWidth>document.body.offsetWidth-5&&(n=document.body.offsetWidth-r.offsetWidth-5),this.post(n,o)}registerWidget(t){this.widgets.push(t)}unregisterWidget(t){const e=this.widgets.indexOf(t);e>-1&&this.widgets.splice(e,1),0===this.widgets.length&&this.unpost()}unpostWidgets(){this.widgets.forEach((t=>t.unpost()))}toJson(){return{type:""}}move_(t){this.anchor&&t!==this.anchor&&(this.moving=!0,this.unpost(),this.post(t),this.moving=!1)}}function k(t){return"."+(g[t]||t)}const I={};I[k("INFOCLOSE")]="{ top:.2em; right:.2em;}",I[k("INFOCONTENT")]="{ overflow:auto; text-align:left; font-size:80%; padding:.4em .6em; border:1px inset; margin:1em 0px; max-height:20em; max-width:30em; background-color:#EEEEEE; white-space:normal;}",I[k("INFO")+k("MOUSEPOST")]="{outline:none;}",I[k("INFO")]='{ position:fixed; left:50%; width:auto; text-align:center; border:3px outset; padding:1em 2em; background-color:#DDDDDD; color:black; cursor:default; font-family:message-box; font-size:120%; font-style:normal; text-indent:0; text-transform:none; line-height:normal; letter-spacing:normal; word-spacing:normal; word-wrap:normal; white-space:nowrap; float:none; z-index:201; border-radius: 15px; /* Opera 10.5 and IE9 */ -webkit-border-radius:15px; /* Safari and Chrome */ -moz-border-radius:15px; /* Firefox */ -khtml-border-radius:15px; /* Konqueror */ box-shadow:0px 10px 20px #808080; /* Opera 10.5 and IE9 */ -webkit-box-shadow:0px 10px 20px #808080; /* Safari 3 & Chrome */ -moz-box-shadow:0px 10px 20px #808080; /* Forefox 3.5 */ -khtml-box-shadow:0px 10px 20px #808080; /* Konqueror */ filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color="gray", Positive="true"); /* IE */}';const _={};_[k("MENU")]="{ position:absolute; background-color:white; color:black; width:auto; padding:5px 0px; border:1px solid #CCCCCC; margin:0; cursor:default; font: menu; text-align:left; text-indent:0; text-transform:none; line-height:normal; letter-spacing:normal; word-spacing:normal; word-wrap:normal; white-space:nowrap; float:none; z-index:201; border-radius: 5px; /* Opera 10.5 and IE9 */ -webkit-border-radius: 5px; /* Safari and Chrome */ -moz-border-radius: 5px; /* Firefox */ -khtml-border-radius: 5px; /* Konqueror */ box-shadow:0px 10px 20px #808080; /* Opera 10.5 and IE9 */ -webkit-box-shadow:0px 10px 20px #808080; /* Safari 3 & Chrome */ -moz-box-shadow:0px 10px 20px #808080; /* Forefox 3.5 */ -khtml-box-shadow:0px 10px 20px #808080; /* Konqueror */}",_[k("MENUITEM")]="{ padding: 1px 2em; background:transparent;}",_[k("MENUARROW")]="{ position:absolute; right:.5em; padding-top:.25em; color:#666666; font-family: null; font-size: .75em}",_[k("MENUACTIVE")+" "+k("MENUARROW")]="{color:white}",_[k("MENUARROW")+k("RTL")]="{left:.5em; right:auto}",_[k("MENUCHECK")]="{ position:absolute; left:.7em; font-family: null}",_[k("MENUCHECK")+k("RTL")]="{ right:.7em; left:auto }",_[k("MENURADIOCHECK")]="{ position:absolute; left: .7em;}",_[k("MENURADIOCHECK")+k("RTL")]="{ right: .7em; left:auto}",_[k("MENUINPUTBOX")]="{ padding-left: 1em; right:.5em; color:#666666; font-family: null;}",_[k("MENUINPUTBOX")+k("RTL")]="{ left: .1em;}",_[k("MENUCOMBOBOX")]="{ left:.1em; padding-bottom:.5em;}",_[k("MENUSLIDER")]="{ left: .1em;}",_[k("SLIDERVALUE")]="{ position:absolute; right:.1em; padding-top:.25em; color:#333333; font-size: .75em}",_[k("SLIDERBAR")]="{ outline: none; background: #d3d3d3}",_[k("MENULABEL")]="{ padding: 1px 2em 3px 1.33em; font-style:italic}",_[k("MENURULE")]="{ border-top: 1px solid #DDDDDD; margin: 4px 3px;}",_[k("MENUDISABLED")]="{ color:GrayText}",_[k("MENUACTIVE")]="{ background-color: #606872; color: white;}",_[k("MENUDISABLED")+":focus"]="{ background-color: #E8E8E8}",_[k("MENULABEL")+":focus"]="{ background-color: #E8E8E8}",_[k("CONTEXTMENU")+":focus"]="{ outline:none}",_[k("CONTEXTMENU")+" "+k("MENUITEM")+":focus"]="{ outline:none}",_[k("SELECTIONMENU")]="{ position:relative; float:left; border-bottom: none; -webkit-box-shadow:none; -webkit-border-radius:0px; }",_[k("SELECTIONITEM")]="{ padding-right: 1em;}",_[k("SELECTION")]="{ right: 40%; width:50%; }",_[k("SELECTIONBOX")]="{ padding: 0em; max-height:20em; max-width: none; background-color:#FFFFFF;}",_[k("SELECTIONDIVIDER")]="{ clear: both; border-top: 2px solid #000000;}",_[k("MENU")+" "+k("MENUCLOSE")]="{ top:-10px; left:-10px}";const D={};D[k("MENUCLOSE")]='{ position:absolute; cursor:pointer; display:inline-block; border:2px solid #AAA; border-radius:18px; -webkit-border-radius: 18px; /* Safari and Chrome */ -moz-border-radius: 18px; /* Firefox */ -khtml-border-radius: 18px; /* Konqueror */ font-family: "Courier New", Courier; font-size:24px; color:#F0F0F0}',D[k("MENUCLOSE")+" span"]="{ display:block; background-color:#AAA; border:1.5px solid; border-radius:18px; -webkit-border-radius: 18px; /* Safari and Chrome */ -moz-border-radius: 18px; /* Firefox */ -khtml-border-radius: 18px; /* Konqueror */ line-height:0; padding:8px 0 6px /* may need to be browser-specific */}",D[k("MENUCLOSE")+":hover"]="{ color:white!important; border:2px solid #CCC!important}",D[k("MENUCLOSE")+":hover span"]="{ background-color:#CCC!important}",D[k("MENUCLOSE")+":hover:focus"]="{ outline:none}";let R=!1,H=!1,P=!1;function F(t){H||(W(_,t),H=!0,J(t))}function B(t){R||(W(I,t),R=!0,J(t))}function J(t){P||(W(D,t),P=!0)}function W(t,e){const s=e||document,i=s.createElement("style");i.type="text/css";let n="";for(const e in t)n+=e,n+=" ",n+=t[e],n+="\n";i.innerHTML=n,s.head.appendChild(i)}class V extends p{constructor(t){super(),this.element=t,this.className=g.MENUCLOSE,this.role="button"}generateHtml(){const t=document.createElement("span");t.classList.add(this.className),t.setAttribute("role",this.role),t.setAttribute("tabindex","0");const e=document.createElement("span");e.textContent="\xd7",t.appendChild(e),this.html=t}display(){}unpost(){super.unpost(),this.element.unpost()}keydown(t){this.bubbleKey(),super.keydown(t)}space(t){this.unpost(),this.stop(t)}mousedown(t){this.unpost(),this.stop(t)}}class z extends p{constructor(t,e,s){super(),this.title=t,this.signature=s,this.className=g.INFO,this.role="dialog",this.contentDiv=this.generateContent(),this.close=this.generateClose(),this.content=e||function(){return""}}attachMenu(t){this.menu=t}generateHtml(){super.generateHtml();const t=this.html;t.appendChild(this.generateTitle()),t.appendChild(this.contentDiv),t.appendChild(this.generateSignature()),t.appendChild(this.close.html),t.setAttribute("tabindex","0")}post(){super.post();const t=document.documentElement,e=this.html,s=window.innerHeight||t.clientHeight||t.scrollHeight||0,i=Math.floor(-e.offsetWidth/2),n=Math.floor((s-e.offsetHeight)/3);e.setAttribute("style","margin-left: "+i+"px; top: "+n+"px;"),window.event instanceof MouseEvent&&e.classList.add(g.MOUSEPOST),e.focus()}display(){this.menu.registerWidget(this),this.contentDiv.innerHTML=this.content();const t=this.menu.html;t.parentNode&&t.parentNode.removeChild(t),this.menu.frame.appendChild(this.html)}click(t){}keydown(t){this.bubbleKey(),super.keydown(t)}escape(t){this.unpost()}unpost(){super.unpost(),this.html.classList.remove(g.MOUSEPOST),this.menu.unregisterWidget(this)}generateClose(){const t=new V(this),e=t.html;return e.classList.add(g.INFOCLOSE),e.setAttribute("aria-label","Close Dialog Box"),t}generateTitle(){const t=document.createElement("span");return t.innerHTML=this.title,t.classList.add(g.INFOTITLE),t}generateContent(){const t=document.createElement("div");return t.classList.add(g.INFOCONTENT),t.setAttribute("tabindex","0"),t}generateSignature(){const t=document.createElement("span");return t.innerHTML=this.signature,t.classList.add(g.INFOSIGNATURE),t}toJson(){return{type:""}}}class K extends p{constructor(t,e){super(),this.title=t,this.window=null,this.localSettings={left:Math.round((screen.width-400)/2),top:Math.round((screen.height-300)/3)},this.windowList=[],this.mobileFlag=!1,this.active=null,this.content=e||function(){return""}}attachMenu(t){this.menu=t}post(){this.display()}display(){this.active=this.menu.store.active;const t=[];for(const e in K.popupSettings)t.push(e+"="+K.popupSettings[e]);for(const e in this.localSettings)t.push(e+"="+this.localSettings[e]);this.window=window.open("","_blank",t.join(",")),this.windowList.push(this.window);const e=this.window.document;this.mobileFlag?(e.open(),e.write('<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>'+this.title+'</title></head><body style="font-size:85%">'),e.write("<pre>"+this.generateContent()+"</pre>"),e.write('<hr><input type="button" value="Close" onclick="window.close()" />'),e.write("</body></html>"),e.close()):(e.open(),e.write("<html><head><title>"+this.title+'</title></head><body style="font-size:85%">'),e.write("<table><tr><td><pre>"+this.generateContent()+"</pre></td></tr></table>"),e.write("</body></html>"),e.close(),setTimeout(this.resize.bind(this),50))}unpost(){this.windowList.forEach((t=>t.close())),this.window=null}generateContent(){return this.content(this.active)}resize(){const t=this.window.document.body.firstChild;let e=this.window.outerHeight-this.window.innerHeight||30,s=this.window.outerWidth-this.window.innerWidth||30;s=Math.max(140,Math.min(Math.floor(.5*this.window.screen.width),t.offsetWidth+s+25)),e=Math.max(40,Math.min(Math.floor(.5*this.window.screen.height),t.offsetHeight+e+25)),this.window.resizeTo(s,e);const i=this.active.getBoundingClientRect();if(i){const t=Math.max(0,Math.min(i.right-Math.floor(s/2),this.window.screen.width-s-20)),n=Math.max(0,Math.min(i.bottom-Math.floor(e/2),this.window.screen.height-e-20));this.window.moveTo(t,n)}this.active=null}toJson(){return{type:""}}}K.popupSettings={status:"no",toolbar:"no",locationbar:"no",menubar:"no",directories:"no",personalbar:"no",resizable:"yes",scrollbars:"yes",width:400,height:300};class X extends L{static fromJson(t,{content:e,action:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"command",e,i),this.command=s}executeAction(){try{this.command(w(this))}catch(t){M(0,"Illegal command callback.")}C(this)}toJson(){return{type:""}}}class j{static fromJson(t,{name:e,getter:s,setter:i},n){const o=new this(e,s,i);n.insert(o)}constructor(t,e,s){this._name=t,this.getter=e,this.setter=s,this.items=[]}get name(){return this._name}getValue(t){try{return this.getter(t)}catch(t){return M(0,"Command of variable "+this.name+" failed."),null}}setValue(t,e){try{this.setter(t,e)}catch(t){M(0,"Command of variable "+this.name+" failed.")}this.update()}register(t){-1===this.items.indexOf(t)&&this.items.push(t)}unregister(t){const e=this.items.indexOf(t);-1!==e&&this.items.splice(e,1)}update(){this.items.forEach((t=>t.update()))}registerCallback(t){this.items.forEach((e=>e.registerCallback(t)))}unregisterCallback(t){this.items.forEach((e=>e.unregisterCallback(t)))}toJson(){return{type:"variable",name:this.name,getter:this.getter.toString(),setter:this.setter.toString()}}}class q extends L{generateHtml(){super.generateHtml();const t=this.html;this.span||this.generateSpan(),t.appendChild(this.span),this.update()}register(){this.variable.register(this)}unregister(){this.variable.unregister(this)}update(){this.updateAria(),this.span&&this.updateSpan()}}class G extends q{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"checkbox",e,i),this.role="menuitemcheckbox",this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(!this.variable.getValue()),C(this)}generateSpan(){this.span=document.createElement("span"),this.span.textContent="\u2713",this.span.classList.add(g.MENUCHECK)}updateAria(){this.html.setAttribute("aria-checked",this.variable.getValue()?"true":"false")}updateSpan(){this.span.style.display=this.variable.getValue()?"":"none"}toJson(){return{type:""}}}class Y extends q{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"combobox",e,i),this.role="combobox",this.inputEvent=!1,this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.input.value,w(this))}space(t){super.space(t),C(this)}focus(){super.focus(),this.input.focus()}unfocus(){super.unfocus(),this.updateSpan()}generateHtml(){super.generateHtml();this.html.classList.add(g.MENUCOMBOBOX)}generateSpan(){this.span=document.createElement("span"),this.span.classList.add(g.MENUINPUTBOX),this.input=document.createElement("input"),this.input.addEventListener("keydown",this.inputKey.bind(this)),this.input.setAttribute("size","10em"),this.input.setAttribute("type","text"),this.input.setAttribute("tabindex","-1"),this.span.appendChild(this.input)}inputKey(t){this.bubbleKey(),this.inputEvent=!0}keydown(t){if(this.inputEvent&&t.keyCode!==s.ESCAPE&&t.keyCode!==s.RETURN)return this.inputEvent=!1,void t.stopPropagation();super.keydown(t),t.stopPropagation()}updateAria(){}updateSpan(){let t;try{t=this.variable.getValue(w(this))}catch(e){t=""}this.input.value=t}toJson(){return{type:""}}}class Q extends L{static fromJson(t,{content:e,id:s},i){return new this(i,e,s)}constructor(t,e,s){super(t,"label",e,s)}generateHtml(){super.generateHtml();this.html.classList.add(g.MENULABEL)}toJson(){return{type:""}}}class Z extends q{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"radio",e,i),this.role="menuitemradio",this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.id),C(this)}generateSpan(){this.span=document.createElement("span"),this.span.textContent="\u2713",this.span.classList.add(g.MENURADIOCHECK)}updateAria(){this.html.setAttribute("aria-checked",this.variable.getValue()===this.id?"true":"false")}updateSpan(){this.span.style.display=this.variable.getValue()===this.id?"":"none"}toJson(){return{type:""}}}class $ extends v{static fromJson(t,e,s){return new this(s)}constructor(t){super(t,"rule"),this.className=g.MENUITEM,this.role="separator"}generateHtml(){super.generateHtml();const t=this.html;t.classList.add(g.MENURULE),t.setAttribute("aria-orientation","vertical")}addEvents(t){}toJson(){return{type:"rule"}}}class tt extends q{static fromJson(t,{content:e,variable:s,id:i},n){return new this(n,e,s,i)}constructor(t,e,s,i){super(t,"slider",e,i),this.role="slider",this.labelId="ctx_slideLabel"+N(),this.valueId="ctx_slideValue"+N(),this.inputEvent=!1,this.variable=t.pool.lookup(s),this.register()}executeAction(){this.variable.setValue(this.input.value,w(this)),this.update()}space(t){super.space(t),C(this)}focus(){super.focus(),this.input.focus()}unfocus(){super.unfocus(),this.updateSpan()}generateHtml(){super.generateHtml();this.html.classList.add(g.MENUSLIDER),this.valueSpan=document.createElement("span"),this.valueSpan.setAttribute("id",this.valueId),this.valueSpan.classList.add(g.SLIDERVALUE),this.html.appendChild(this.valueSpan)}generateSpan(){this.span=document.createElement("span"),this.labelSpan=document.createElement("span"),this.labelSpan.setAttribute("id",this.labelId),this.labelSpan.appendChild(this.html.childNodes[0]),this.html.appendChild(this.labelSpan),this.input=document.createElement("input"),this.input.setAttribute("type","range"),this.input.setAttribute("min","0"),this.input.setAttribute("max","100"),this.input.setAttribute("aria-valuemin","0"),this.input.setAttribute("aria-valuemax","100"),this.input.setAttribute("aria-labelledby",this.labelId),this.input.addEventListener("keydown",this.inputKey.bind(this)),this.input.addEventListener("input",this.executeAction.bind(this)),this.input.classList.add(g.SLIDERBAR),this.span.appendChild(this.input)}inputKey(t){this.inputEvent=!0}mousedown(t){t.stopPropagation()}mouseup(t){event.stopPropagation()}keydown(t){const e=t.keyCode;return e===s.UP||e===s.DOWN?(t.preventDefault(),void super.keydown(t)):this.inputEvent&&e!==s.ESCAPE&&e!==s.RETURN?(this.inputEvent=!1,void t.stopPropagation()):(super.keydown(t),void t.stopPropagation())}updateAria(){const t=this.variable.getValue();t&&this.input&&(this.input.setAttribute("aria-valuenow",t),this.input.setAttribute("aria-valuetext",t+"%"))}updateSpan(){let t;try{t=this.variable.getValue(w(this)),this.valueSpan.innerHTML=t+"%"}catch(e){t=""}this.input.value=t}toJson(){return{type:""}}}class et extends A{static fromJson(t,{items:e},s){const i=new this(s),n=t.get("items")(t,e,i);return i.items=n,i}constructor(t){super(),this._anchor=t,this.variablePool=this.anchor.menu.pool,this.setBaseMenu()}get anchor(){return this._anchor}post(){if(!this.anchor.menu.isPosted())return;let t=this.anchor.html;const e=this.html,s=this.baseMenu.frame,i=t.offsetWidth;let n=i-2,o=0;for(;t&&t!==s;)n+=t.offsetLeft,o+=t.offsetTop,t=t.parentNode;n+e.offsetWidth>document.body.offsetWidth-5&&(n=Math.max(5,n-i-e.offsetWidth+6)),super.post(n,o)}display(){this.baseMenu.frame.appendChild(this.html)}setBaseMenu(){let t=this;do{t=t.anchor.menu}while(t instanceof et);this.baseMenu=t}left(t){this.focused=null,this.anchor.focus()}toJson(){return{type:""}}}class st extends A{static fromJson(t,{title:e,values:s,variable:i},n){const o=new this(n),r=t.get("label")(t,{content:e||"",id:e||"id"},o),a=t.get("rule")(t,{},o),h=s.map((e=>t.get("radio")(t,{content:e,variable:i,id:e},o))),u=[r,a].concat(h);return o.items=u,o}constructor(t){super(),this.anchor=t,this.className=g.SELECTIONMENU,this.variablePool=this.anchor.menu.pool,this.baseMenu=this.anchor.menu}generateHtml(){super.generateHtml(),this.items.forEach((t=>t.html.classList.add(g.SELECTIONITEM)))}display(){}right(t){this.anchor.right(t)}left(t){this.anchor.left(t)}}class it extends z{static fromJson(t,{title:e,signature:s,selections:i,order:n,grid:o},r){const a=new this(e,s,n,o);a.attachMenu(r);const h=i.map((e=>t.get("selectionMenu")(t,e,a)));return a.selections=h,a}constructor(t,e,s="none",i="vertical"){super(t,null,e),this.style=s,this.grid=i,this._selections=[],this.prefix="ctxt-selection",this._balanced=!0}attachMenu(t){this.menu=t}get selections(){return this._selections}set selections(t){this._selections=[],t.forEach((t=>this.addSelection(t)))}addSelection(t){t.anchor=this,this._selections.push(t)}rowDiv(t){const e=document.createElement("div");this.contentDiv.appendChild(e);const s=t.map((t=>(e.appendChild(t.html),t.html.id||(t.html.id=this.prefix+N()),t.html.getBoundingClientRect()))),i=s.map((t=>t.width)),n=i.reduce(((t,e)=>t+e),0),o=s.reduce(((t,e)=>Math.max(t,e.height)),0);return e.classList.add(g.SELECTIONDIVIDER),e.setAttribute("style","height: "+o+"px;"),[e,n,o,i]}display(){if(super.display(),this.order(),!this.selections.length)return;const t=[];let e=0,s=[];const i=this.getChunkSize(this.selections.length);for(let n=0;n<this.selections.length;n+=i){const o=this.selections.slice(n,n+i),[r,a,h,u]=this.rowDiv(o);t.push(r),e=Math.max(e,a),o.forEach((t=>t.html.style.height=h+"px")),s=this.combineColumn(s,u)}this._balanced&&(this.balanceColumn(t,s),e=s.reduce(((t,e)=>t+e),20)),t.forEach((t=>t.style.width=e+"px"))}getChunkSize(t){switch(this.grid){case"square":return Math.floor(Math.sqrt(t));case"horizontal":return Math.floor(t/it.chunkSize);default:return it.chunkSize}}balanceColumn(t,e){t.forEach((t=>{const s=Array.from(t.children);for(let t,i=0;t=s[i];i++)t.style.width=e[i]+"px"}))}combineColumn(t,e){let s=[],i=0;for(;t[i]||e[i];){if(!t[i]){s=s.concat(e.slice(i));break}if(!e[i]){s=s.concat(t.slice(i));break}s.push(Math.max(t[i],e[i])),i++}return s}left(t){this.move(t,(t=>(0===t?this.selections.length:t)-1))}right(t){this.move(t,(t=>t===this.selections.length-1?0:t+1))}generateHtml(){super.generateHtml(),this.html.classList.add(g.SELECTION)}generateContent(){const t=super.generateContent();return t.classList.add(g.SELECTIONBOX),t.removeAttribute("tabindex"),t}findSelection(t){const e=t.target;let s=null;if(e.id&&(s=this.selections.find((t=>t.html.id===e.id))),!s){const t=e.parentElement.id;s=this.selections.find((e=>e.html.id===t))}return s}move(t,e){const s=this.findSelection(t);s.focused&&s.focused.unfocus();const i=e(this.selections.indexOf(s));this.selections[i].focus()}order(){this.selections.sort(it.orderMethod.get(this.style))}toJson(){return{type:""}}}it.chunkSize=4,it.orderMethod=new Map([["alphabetical",(t,e)=>t.items[0].content.localeCompare(e.items[0].content)],["none",(t,e)=>1],["decreasing",(t,e)=>{const s=t.items.length,i=e.items.length;return s<i?1:i<s?-1:0}],["increasing",(t,e)=>{const s=t.items.length,i=e.items.length;return s<i?-1:i<s?1:0}]]);class nt{constructor(t){this._parser=new Map(t)}get(t){return this._parser.get(t)}add(t,e){this._parser.set(t,e)}}var ot=function(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(s[i[n]]=t[i[n]])}return s};const rt=U,at=i,ht=z,ut=K,lt=class{constructor(t=[]){this._initList=[["command",X.fromJson.bind(X)],["checkbox",G.fromJson.bind(G)],["combo",Y.fromJson.bind(Y)],["slider",tt.fromJson.bind(tt)],["label",Q.fromJson.bind(Q)],["radio",Z.fromJson.bind(Z)],["rule",$.fromJson.bind($)],["submenu",O.fromJson.bind(O)],["contextMenu",U.fromJson.bind(U)],["subMenu",et.fromJson.bind(et)],["variable",j.fromJson.bind(j)],["items",this.items.bind(this)],["selectionMenu",st.fromJson.bind(st)],["selectionBox",it.fromJson.bind(it)]],this._factory=new nt(this._initList),t.forEach((([t,e])=>this.factory.add(t,e)))}get factory(){return this._factory}items(t,e,s){const i=[];for(const t of e){const e=this.parse(t,s);e&&(s.items.push(e),t.disabled&&e.disable(),t.hidden&&i.push(e))}return i.forEach((t=>t.hide())),s.items}parse(t,...e){var{type:s}=t,i=ot(t,["type"]);const n=this.factory.get(s);return n?n(this.factory,i,...e):null}},dt="0.9.1",ct=it,pt=j,mt=nt;return e})()));

@@ -14,5 +14,5 @@ import { ContextMenu as obj0 } from './context_menu.js';

export declare const Parser: typeof obj4;
export declare const version = "0.8.0";
export declare const version = "0.9.1";
export declare const SelectionBox: typeof obj5;
export declare const Variable: typeof obj6;
export declare const ParserFactory: typeof obj7;

@@ -14,3 +14,3 @@ import { ContextMenu as obj0 } from './context_menu.js';

export const Parser = obj4;
export const version = '0.8.0';
export const version = '0.9.1';
export const SelectionBox = obj5;

@@ -17,0 +17,0 @@ export const Variable = obj6;

{
"name": "mj-context-menu",
"version": "0.9.0",
"version": "0.9.1",
"description": "A generic context menu",

@@ -5,0 +5,0 @@ "main": "dist/ContextMenu.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc