!function(y){angular.module("ui.bootstrap.contextMenu",[]).service("CustomService",function(){"use strict";return{initialize:function(n){console.log("got here",n)}}}).directive("contextMenu",["$parse","$q","CustomService","$sce",function(n,d,f,e){var p=[],g=function(n){for(;p.length&&(!n||p.length>n);)p.pop().remove()},h=function(n,e,t,o,a,i,r,l,c,u){"use strict";var s=angular.isArray(o[1])||o[1]&&angular.isFunction(o[1].then)?o[1]:angular.isArray(o[2])||o[2]&&angular.isFunction(o[2].then)?o[2]:angular.isArray(o[3])||o[3]&&angular.isFunction(o[3].then)?o[3]:null,f="New Item";"function"==typeof o[0]||"string"==typeof o[0]||void 0!==o.text?f=function(n,e,t,o,a,i,r,l){var c=l("<a>");c.css("padding-right","8px"),c.attr({tabindex:"-1",href:"#"}),"string"==typeof e[0]?t=e[0]:"function"==typeof e[0]?t=e[0].call(n,n,o,a):void 0!==e.text&&(t=e.text);var u=d.when(t);return i.push(u),u.then(function(n){r&&(c.css("cursor","default"),c.append(l('<strong style="font-family:monospace;font-weight:bold;float:right;">&gt;</strong>'))),c.append(n)}),c}(n,o,f,e,t,r,s,c):"function"==typeof o.html?f=o.html(n):void 0!==o.html&&(f=o.html),i.append(f);m(n,void 0!==o.enabled?o.enabled.call(n,n,e,t,f):"function"!=typeof o[2]||o[2].call(n,n,e,t,f),o,a,i,s,t,f,e,c,u)},m=function(t,n,e,o,a,i,r,l,c,u,s){if(n){var f=function(n){g(s+1);var e={pageX:c.pageX+o[0].offsetWidth-1,pageY:o[0].offsetTop+a[0].offsetTop-3,view:c.view||window,event:n};d.when(i).then(function(n){v(t,e,n,r,s+1)})};a.on("click",function(n){1==n.which&&(n.preventDefault(),t.$apply(function(){i?f(n):(u(c.currentTarget).removeClass("context"),g(),angular.isFunction(e[1])?e[1].call(t,t,c,r,l,a):e.click.call(t,t,c,r,l,a))}))}),a.on("mouseover",function(n){t.$apply(function(){i?f(n):g(s+1)})})}else a.on("click",function(n){n.preventDefault()}),a.addClass("disabled")},v=function(t,o,n,a,i,e){i||(i=0),y(o.currentTarget).addClass("context");var r=y("<ul>");r.addClass("dropdown-menu"),r.attr({role:"menu"}),r.css({display:"block",position:"absolute",left:o.pageX+"px",top:o.pageY+"px","z-index":1e4});var l=[];angular.forEach(n,function(n){var e=y("<li>");null===n?e.addClass("divider"):"object"==typeof n[0]?f.initialize(e,n):h(t,o,a,n,r,e,l,0,y,i),r.append(e)});Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight);function c(n){s(n)}function u(n){for(var e=y(n.target),t=!0;e.length;){if(e.hasClass("dropdown-menu")){t=!1;break}e=e.parent()}t&&s(n)}function s(n){y(document.body).off("mousedown",u),y(document).off("scroll",c),y(o.originalTarget).removeClass("context"),g()}y(document).find("body").append(r),function(c,u,s,n){"use strict";d.all(n).then(function(){var n=s.pageY,e=angular.element(c[0]).prop("offsetHeight"),t=window.scrollY+s.view.innerHeight;if(e<n&&t-n<e+20)n=s.pageY-e,u&&0<u&&(n+=s.event.currentTarget.offsetHeight);else if(t<=e)angular.element(c[0]).css({height:t-5,"overflow-y":"scroll"}),n=0;else if(t-n<e){var o=5;n<o&&(o=n),n=t-e-o}var a=s.pageX,i=angular.element(c[0]).prop("offsetWidth"),r=s.view.innerWidth;if(i<a&&r-a-5<i)a=r-i-5;else if(r-a<i){var l=5;a<l+5&&(l=a+5),a=r-i-l-5}c.css({display:"block",position:"absolute",left:a+"px",top:n+"px"})})}(r,i,o,l),0===i&&(y(document.body).on("mousedown",u),y(document).on("scroll",c)),t.$on("$destroy",function(){g()}),p.push(r)};return function(a,n,i){var e="contextmenu";i.contextMenuOn&&"string"==typeof i.contextMenuOn&&(e=i.contextMenuOn),n.on(e,function(o){if(i.allowEventPropagation||(o.stopPropagation(),o.preventDefault()),("ontouchstart"in window||navigator.maxTouchPoints)&&"true"===n.attr("draggable"))return!1;a.$apply(function(){var n=a.$eval(i.contextMenu),e=i.contextMenuClass,t=a.$eval(i.model);if(!(n instanceof Array))throw'"'+i.contextMenu+'" not an array';0!==n.length&&v(a,o,n,t,void 0,e)})})}}])}(window.angular.element);