JsUtils

JavaScript Utility functions

Ce script ne doit pas être installé directement. C'est une librairie destinée à être incluse dans d'autres scripts avec la méta-directive // @require https://update.greasyfork.org/scripts/19117/209854/JsUtils.js

(function(a){a.fn.extend({sortList:function(){return function(){if(0!==this.length){if(!this.is("ul, ol"))throw"Error: sortList can only be used on a ul or ol tag!";var d=arguments,e=!1;if("undefined"!==typeof d[0]){if("boolean"!==typeof d[0])throw"the first argument must be a boolean";e=d[0]}for(var c=[],b=0;b<this.length;b++){var g=a(this.get(b)),f=g.children("li").not(function(b,e){for(b=1;b<d.length;b++){var f=d[b];if(a.trim(a(this).text())===f)return c.push(a(this)),!0}return!1}).get();f.sort(function(c,
b){return a(c).text().toUpperCase().localeCompare(a(b).text().toUpperCase())});a.each(f,function(c,a){g.append(a)});!0===e&&a.each(c,function(c,b){a(this).parent().append(this)})}return this}}.apply(this,arguments)},offOn:function(a,e,c){c=c||!1;this.off(a).on(a,e);c&&this.trigger(a);return this},sortSelect:function(){for(var d=0;d<this.length;d++){var e=a(this[d]);if(!e.is("select"))throw"SortSelect can only be used on a select node";var c=[];a.each(e.children(),function(b,e){1==a(this).data("sortIgnore")&&
c.push(this)});var b=e.children("option").not(function(b){return 0<=a.inArray(this,c)?!0:!1});b.sort(function(c,b){return a(c).text().toUpperCase().localeCompare(a(b).text().toUpperCase())});for(var g=0;g<b.length;g++)e.append(b[g])}return this},center:function(){this.css("position","absolute");this.css("top",Math.max(0,(a(window).height()-a(this).outerHeight())/2+a(window).scrollTop())+"px");this.css("left",Math.max(0,(a(window).width()-a(this).outerWidth())/2+a(window).scrollLeft())+"px");return this},
sortTable:function(d,e){d="undefined"===typeof d?-1:d;e="undefined"===typeof e?!1:e;if(0!==this.length){if("number"!==typeof d)throw"col must be of type number. Got type"+typeof d+" instead";if(!this.is("table"))throw"Error: sortTable can only be used on a table!";var c=a(this).find("tbody").children("tr").get();e?c.sort(function(c,b){return parseInt(a(c).text())-parseInt(a(b).text())}):-1===d?c.sort(function(c,b){return a(c).text().toUpperCase().localeCompare(a(b).text().toUpperCase())}):c.sort(function(c,
b){var e=a(c).children("td").eq(d).text().toUpperCase(),f=a(b).children("td").eq(d).text().toUpperCase();return e.localeCompare(f)});for(var b=0;b<c.length;b++)a(this).find("tbody").append(c[b]);return this}},changetext:function(a){if(0!==this.length)return this.contents().filter(function(){return 3===this.nodeType})[0].nodeValue=a,this},enableButton:function(a){if(0!==this.length){if(!this.is("a, button"))throw"This function may only be used on a button or anchor tag";if("undefined"===typeof a||
null===a)throw"The argument passed to this function must be a boolean";!0===a?this.prop("disabled",!1).removeClass("disabled"):this.prop("disabled",!0).addClass("disabled");return this}}});(function(){(function(){var d=jQuery.fn.hide;a.fn.hide=function(){d.apply(this,arguments);this.is(":hidden")||this.addClass("hide");return this}})();(function(){var d=jQuery.fn.show;a.fn.show=function(a){"string"!==typeof arguments[0]?d.apply(this,arguments):d.apply(this);var c=this.prop("nodeName");c=document.createElement(c);
var b="getComputedStyle"in window;document.body.appendChild(c);b=(b?window.getComputedStyle(c,""):c.currentStyle).display;document.body.removeChild(c);c=b;void 0!==a&&(c=a);this.is(":hidden")&&(this.hasClass("hide")?this.removeClass("hide").css("display",c):this.hasClass("hidden")&&this.removeClass("hidden").css("display",c),this.is(":hidden")&&this.css("display",c+" !important"));return this}})()})();(function(){(function(){Object.defineProperty(jQuery.expr.filters,"offscreen",{value:function(d){d=
a(d);var e=a(window),c=e.scrollTop(),b=e.scrollLeft();var g=b+e.width();var e=c+e.height(),f=d.offset();f.right=f.left+d.outerWidth();f.bottom=f.top+d.outerHeight();return g<f.left||b>f.right||e<f.top||c>f.bottom}})})()})();(function(){(function(){var a=jQuery.fn.addClass;jQuery.fn.addClass=function(){var e=a.apply(this,arguments);jQuery(this).trigger("cssClassChanged");return e}})()})()})(jQuery);
var ObjectUtil=function(){var a=function(){if(null==arguments||0===arguments.length)return!1;for(var a=0;a<arguments.length;a++){var b=arguments[a];if(void 0===b||null===b)return!1}return!0},d=function(a){return a instanceof jQuery||"jquery"in Object(a)?!0:!1},e=function(){if(null==arguments||0===arguments.length)return!1;for(var a=0;a<arguments.length;a++){var b=arguments[a];if(void 0===b||null===b||0===b.length||"string"!==typeof b||0===$.trim(b).length)return!1}return!0};return{isjQuery:d,validString:function(){return e.apply(this,
arguments)},extendObj:function(a,b){if("function"!==typeof b)throw Error("sub must be a Constructor");if("function"!==typeof a)throw Error("base must be a Constructor");b.prototype=Object.create(a.prototype);return b.prototype.constructor=b},stringContains:function(a,b){return!!~a.indexOf(b)},getElementFromJqueryArray:function(a,b){if(!d(a))throw new TypeError("element must be an instance of Jquery");if("number"!==typeof b)throw new TypeError("element must be a number");return a.filter(function(a){return a===
b})},deepCompare:function(){function a(b,c){var e;if(isNaN(b)&&isNaN(c)&&"number"===typeof b&&"number"===typeof c||b===c)return!0;if("function"===typeof b&&"function"===typeof c||b instanceof Date&&c instanceof Date||b instanceof RegExp&&c instanceof RegExp||b instanceof String&&c instanceof String||b instanceof Number&&c instanceof Number)return b.toString()===c.toString();if(!(b instanceof Object&&c instanceof Object)||b.isPrototypeOf(c)||c.isPrototypeOf(b)||b.constructor!==c.constructor||b.prototype!==
c.prototype||-1<d.indexOf(b)||-1<h.indexOf(c))return!1;for(e in c)if(c.hasOwnProperty(e)!==b.hasOwnProperty(e)||typeof c[e]!==typeof b[e])return!1;for(e in b){if(c.hasOwnProperty(e)!==b.hasOwnProperty(e)||typeof c[e]!==typeof b[e])return!1;switch(typeof b[e]){case "object":case "function":d.push(b);h.push(c);if(!a(b[e],c[e]))return!1;d.pop();h.pop();break;default:if(b[e]!==c[e])return!1}}return!0}var b;if(1>arguments.length)return!0;var e=1;for(b=arguments.length;e<b;e++){var d=[];var h=[];if(!a(arguments[0],
arguments[e]))return!1}return!0},guid:function(){function a(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},isValidObject:function(a){return"undefined"!==typeof a&&null!==a&&"object"===typeof a&&0<Object.keys(a).length},clone:function(a,b){return b?$.extend(!0,{},a):$.extend(a,!0)},assertValid:function(){return a.apply(this,arguments)},makeAbstract:function(a,b){if(a.constructor===b)throw new TypeError("Cannot instantiate abstract class '"+
b.name+"' ");}}}(),LanguageFormatUtils=function(){return{isRtl:function(a){return RegExp("^[^\u0591-\u07ff\u200f\u202b\u202e\ufb1d-\ufdfd\ufe70-\ufefc]*?[\u0591-\u07ff\u200f\u202b\u202e\ufb1d-\ufdfd\ufe70-\ufefc]").test(a)}}}(),DomUtil=function(){return{injectCss:function(a){(new RegExp(/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/)).test(a)?$("<link>").prop({type:"text/css",rel:"stylesheet"}).attr("href",a).appendTo("head"):$("<style>").prop("type","text/css").html(a).appendTo("head")}}}(),
UrlUtils=function(){return{addParameter:function(a,d,e,c){if(0<a.indexOf("#")){var b=a.indexOf("#");var g=a.substring(a.indexOf("#"),a.length)}else g="",b=a.length;a=a.substring(0,b).split("?");b="";if(1<a.length)for(var f=a[1].split("&"),h=0;h<f.length;h++){var k=f[h].split("=");k[0]!=d&&(b=""==b?"?":b+"&",b+=k[0]+"="+(k[1]?k[1]:""))}""==b&&(b="?");c?b="?"+d+"="+e+(1<b.length?"&"+b.substring(1):""):(""!==b&&"?"!=b&&(b+="&"),b+=d+"="+(e?e:""));return a[0]+b+g},getParameter:function(a){var d=location.href;
a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");a=(new RegExp("[\\?&]"+a+"=([^&#]*)")).exec(d);return null==a?null:a[1]}}}(),XmlUtil=function(){return{encodeXml:function(a){if("string"===typeof a)return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},decodeXml:function(a){if("string"===typeof a)return a.replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}}}(),XssEncoder=function(a){return a}(XmlUtil||
{}),fileUtil=function(){var a=function(){return window.File&&window.FileReader&&window.FileList&&window.Blob?!0:!1},d=function(a){ObjectUtil.isjQuery(a)&&(a=a.val());a=a.substr(a.lastIndexOf(".")+1);if(""===a)throw"No file extension";return a.toLowerCase()},e=function(a,c){if(0==a)return"0 Byte";var b=Math.floor(Math.log(a)/Math.log(1024));return(a/Math.pow(1024,b)).toPrecision(c+1||3)+" "+"Bytes KB MB GB TB PB EB ZB YB".split(" ")[b]},c=function(){return{getImageInfoFromInput:function(b,c){function f(a,
b){var c=new FileReader;c.addEventListener("load",function(){var d=new Image;d.addEventListener("load",function(){var f={};Object.defineProperties(f,{fileName:{value:a.name},imageWidth:{value:d.width},imageHeight:{value:d.height},imageType:{value:a.type},fileSize:{value:e(a.size)},base64:{value:c.result}});Object.freeze(f);b.resolve(f,this)});d.src=g?window.URL.createObjectURL(a):c.result;g&&window.URL.revokeObjectURL(a)});c.readAsDataURL(a);return b.promise()}if(a()){if(ObjectUtil.isjQuery(b)){if(0===
b.length)throw"Input does not exist";b=b[0]}BrowserUtils.isChrome()&&(window.URL=window.webkitURL);var g=window.URL,k=b.files;if(!k)throw new TypeError("File upload not supported by your browser.");if(0<k.length)if(k=k[0],/\.(tif|jpg|cur|tiff|ico|bmp|gif|png|jpeg|wbmp|rle)$/i.test(k.name)){var q=$.Deferred();$.when(f(k,q)).done(function(a,b){c.call(b,a,b)})}else throw new ImageBoundException("Unsupported Image extension: '"+d(k.name)+"' file name: '"+k.name+"'");}}}}();return{getFileExt:d,getFileNameFromInput:function(b){if(ObjectUtil.isjQuery(b)){if(0===
b.length)throw"Input does not exist";b=b[0]}if(null===b)throw"Input does not exist";if("url"===b.getAttribute("type")||!a()){b=b.value;if("string"!==typeof b)throw"path does not contain a value, this maybe because you did not pass in an object that represents an input";return b.replace(/^C:\\fakepath\\/i,"").split("\\").pop().split("/").pop()}return b.files[0].name},supportsFileApi:a,ImageUtils:c,b64toBlob:function(a,c,e){c=c||"";e=e||512;var b=null;try{b=atob(a)}catch(t){var b={},d,f=0,g,n=0,l,m=
"",r=String.fromCharCode,p=a.length;for(d=0;64>d;d++)b["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d)]=d;for(g=0;g<p;g++)for(d=b[a.charAt(g)],f=(f<<6)+d,n+=6;8<=n;)((l=f>>>(n-=8)&255)||g<p-2)&&(m+=r(l));b=m}if(null===b)throw new TypeError("Unable to parse base 64");a=[];for(l=0;l<b.length;l+=e){f=b.slice(l,l+e);n=Array(f.length);for(m=0;m<f.length;m++)n[m]=f.charCodeAt(m);f=new Uint8Array(n);a.push(f)}return new Blob(a,{type:c})},fileToBase64:function(a,c){if(ObjectUtil.isjQuery(a)){if(0===
a.length)throw"Input does not exist";a=a[0]}var b=a.files;if(!b)throw new TypeError("File upload not supported by your browser.");var b=b[0],e=new FileReader;e.addEventListener("load",function(){c.call(e.result,e.result)});e.readAsDataURL(b)},getFileAsText:function(a,c){if(ObjectUtil.isjQuery(a)){if(0===a.length)throw"Input does not exist";a=a[0]}var b=a.files;if(!b)throw new TypeError("File upload not supported by your browser.");var b=b[0],e=new FileReader;e.addEventListener("load",function(a){c.call(e,
e.result)});e.readAsText(b)}}}(),AjaxUtils=function(){return{preformAjaxCall:function(a,d,e,c){c="undefined"===typeof c?!0:c;if("undefined"===typeof d)console.error("Type must be supplied");else return e="undefined"===typeof e?null:e,a={type:d,url:a,cache:!1,async:c,dataType:"json"},"POST"===d&&(null!==e&&(a.data=e),a.contentType="application/json"),9===IeUtils.getIeVersion()&&"undefined"!==typeof $.support&&($.support.cors=!0),$.ajax(a)},downloadViaJavaScript:function(a,d,e,c,b,g){c=void 0===c?null:
c;b=void 0===b?null:b;g||(g="POST");loading(!0);var f=new XMLHttpRequest;f.open(g,a,!0);f.responseType="blob";f.withCredentials=!0;"POST"==g&&f.setRequestHeader("Content-type","application/json");var h=!1;f.onreadystatechange=function(){var a=null;if(f.readyState===XMLHttpRequest.DONE){h&&(a=new HttpException(f));if(c)var d=c;else d=f.getResponseHeader("Content-Disposition"),ObjectUtil.validString(d)&&-1<d.indexOf("filename")?(d=d.split("filename").pop(),d=d.replace("=",""),d=d.trim(),d=d.replace(/"/g,
""),d=d.replace("*UTF-8''","")):d="untitled.txt";if(!b){var g=f.getResponseHeader("Content-Type");ObjectUtil.validString(g)}a=function(a,b,c,e){c?showErrorDialog(e.getError()):saveAs(a,b)}.bind(this,f.response,d,h,a);loading(!1);e.call(this,a)}else f.readyState===XMLHttpRequest.HEADERS_RECEIVED&&200!==f.status&&(f.responseType="text",h=!0)};"POST"===g?f.send(JSON.stringify(d)):f.send()}}}(),dragDrop=function(a,d){return{fileUtil:a,canSupportDragAndDrop:function(){return a.supportsFileApi()}}}(fileUtil||
{},window),ArrayUtils=function(){return{removeFromArray:function(a,d){console&&console.warn("The use of 'removeFromArray' is depricated, please use 'yourArray._remove_(item)' instead");for(var e=a.length;e--;)ObjectUtil.isjQuery(d)?$(a[e]).is(d)&&a.splice(e,1):a[e]===d&&a.splice(e,1)},arrayCopy:function(a,d){if(!Array.isArray(a))throw new TypeError("array to copy must be of type 'Array'");return $.extend("undefined"===typeof d?!1:d,[],a)},validArray:function(a){return Array.isArray(a)&&0<a.length},
arraySort:function(a){a.sort(function(a,e){return a.toUpperCase().localeCompare(e.toUpperCase())})},objectArrayIndex:function(a,d,e){e="undefined"===typeof e?!0:e;var c=a.indexOf(d);if(-1<c)return c;c=$.inArray(d,a);if(-1<c)return c;if(e)for(e=0,c=a.length;e<c;e++)if(ObjectUtil.deepCompare(a[e],d))return e;return-1}}}(),ColourUtils=function(){var a=Math.random();return{getRandomColour:function(){a+=.618033988749895;var d=a%=1,e=parseInt(6*d),c=6*d-e,d=.75*(1-.7),b=.75*(1-.7*c),c=.75*(1-.7*(1-c));
if(0==e){var g=.75;var f=c;var h=d}else 1==e?(g=b,f=.75,h=d):2==e?(g=d,f=.75,h=c):3==e?(g=d,f=b,h=.75):4==e?(g=c,f=d,h=.75):5==e&&(g=.75,f=d,h=b);return"rgb("+parseInt(256*g)+","+parseInt(256*f)+","+parseInt(256*h)+")"}}}(),BrowserUtils=function(){var a=function(){var a=function(){var a=window.navigator.userAgent,c=a.indexOf("Edge/");return 0<c?parseInt(a.substring(c+5,a.indexOf(".",c)),10):null};return{getVersion:a,isEdge:function(){return null!==a()}}}();return{detectMobile:function(){var a=!1,
e=navigator.userAgent||navigator.vendor||window.opera;if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,
4)))a=!0;return a},isChrome:function(){return null!==window.chrome&&"Google Inc."===window.navigator.vendor?!0:!1},isFireFox:function(){return-1<navigator.userAgent.toLowerCase().indexOf("firefox")?!0:!1},isWebkit:function(){return/webkit/.test(navigator.userAgent.toLowerCase())},isEdgeOrIe:function(){return a.isEdge()||IeUtils.isIe()},Edge:a}}(),IeUtils=function(){var a=function(){return-1!==navigator.appVersion.indexOf("MSIE 10")},d=function(){return!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)},
e=function(){return 0<window.navigator.userAgent.indexOf("MSIE ")|d()||a()?!0:!1};return{isIe:e,getIeVersion:function(){if(!e())return null;var c="unknown",b={"5.5":5.5,"5.6":6,"5.7":7,"5.8":8,9:9},g=(new Function("/*@cc_on return @_jscript_version; @*/"))();"undefined"!==typeof g?(c=b[g],"undefined"===typeof c&&(c=a()?10:d()?11:-1!=navigator.appVersion.indexOf("MSIE 9.")?9:"unknown")):a()?c=10:d()&&(c=11);return c}}}(),VersionUtil=function(){return{isHigherVersion:function(a,d){if("string"!==typeof a&&
"string"!==typeof d)throw"versions must be strings";for(var e=a.split("."),c=d.split("."),b=e.length>c.length?c.length:e.length,g=0;g<b;g++){var f=parseInt(e[g]),h=parseInt(c[g]);if(f>h)return!0;if(h>f)return!1}return e.length>=c.length}}}(),QueryString=function(){for(var a={},d=window.location.search.substring(1).split("&"),e=0;e<d.length;e++){var c=d[e].split("=");"undefined"===typeof a[c[0]]?a[c[0]]=c[1]:"string"===typeof a[c[0]]?a[c[0]]=[a[c[0]],c[1]]:a[c[0]].push(c[1])}return a}();
(function(){function a(a){var c=1;"-"==a[0]&&(c=-1,a=a.substr(1));return function(b,e){if("undefined"===typeof b[a]||"undefined"===typeof e[a])throw"There is no property with the value of "+a.toString()+" inside this object";return b[a].toUpperCase().localeCompare(e[a].toUpperCase())*c}}function d(){if(0==arguments.length)throw"Zero length arguments not allowed for Array.sortBy()";var e=arguments;return function(c,b){for(var d=0,f=0;0==d&&f<e.length;f++)d=a(e[f])(c,b);return d}}Object.defineProperty(Array.prototype,
"sortBy",{enumerable:!1,writable:!0,value:function(){return this.sort(d.apply(null,arguments))},configurable:!0})})();
(function(){Array.prototype._remove_||(Object.defineProperty(Array.prototype,"_remove_",{enumerable:!1,value:function(a){for(var d=0,e=this.length;d<e;d++){var c=this[d];ObjectUtil.isjQuery(a)?$(c).is(a)&&this.splice(d,1):(a===c||ObjectUtil.deepCompare(a,c))&&this.splice(d,1)}},configurable:!0}),Array.prototype.moveItem||(Object.defineProperty(Array.prototype,"moveItem",{value:function(a,d){for(;0>a;)a+=this.length;for(;0>d;)d+=this.length;if(d>=this.length)for(var e=d-this.length;e--+1;)this.push(void 0);
this.splice(d,0,this.splice(a,1)[0])},configurable:!0}),Object.defineProperty(Array.prototype,"addAll",{value:function(){(function(){for(var a=0;a<arguments.length;a++)for(var d=arguments[a],e=0,c=d.length;e<c;e++)this.push(d[e])}).apply(this,arguments)},configurable:!0}),Object.defineProperty(Array.prototype,"removeIdx",{value:function(a){this.splice(a,1)},configurable:!0})))})();
(function(){Object.defineProperty(Function.prototype,"getName",{value:function(){try{return/^function\s+([\w\$]+)\s*\(/.exec(this.toString())[1]}catch(a){return null}},configurable:!0})})();(function(){Object.defineProperty(Object,"deepFreeze",{value:function(a){function d(a){a=Object.freeze(a);for(var c in a){var b=a[c];ObjectUtil.isValidObject(b)&&d(b);Object.freeze(b)}return a}return a=d(a)}})})();
(function(){Object.defineProperty(String.prototype,"trunc",{value:function(a,d){var e=this.length>a,c=e?this.substr(0,a-1):this,c=d&&e?c.substr(0,c.lastIndexOf(" ")):c;return e?c+"&hellip;":c}})})();
var LinkedArray=function(){var a=function e(a){if("undefined"===typeof a)throw new TypeError("a type must be supplied");var b=[];Object.setPrototypeOf(b,e.prototype);Object.defineProperty(b,"_type",{value:a});return b};a.prototype=[];a.prototype.push=function(){for(var a=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),c=0;c<a.length;c++){var b=a[c];if(Array.isArray(this._type)){if(!Array.isArray(b))throw new TypeError("this array only accepts instance of arrays");}else if("object"===
typeof this._type||"function"===typeof this._type){if("undefined"===typeof b)break;if(!(b instanceof this._type)){a="This array only accepts instance of {supplied object}";if(""!==this._type.name)a="This array only accepts instance of "+this._type.name;else try{var g=this._type.getName(),a=null==g?"Please supply the correct value to this array":"This array only accepts instance of "+g}catch(f){}throw new TypeError(a);}}else{if("number"===typeof this._type&&"number"!==typeof b)throw new TypeError("this array only accepts "+
typeof this._type);if("boolean"===typeof this._type&&"boolean"!==typeof b)throw new TypeError("this array only accepts "+typeof this._type);if("string"===typeof this._type&&"string"!==typeof b)throw new TypeError("this array only accepts "+typeof this._type);}}a.forEach(function(a,b,c){Array.prototype.push.call(this,a)},this)};a.prototype.getType=function(){return"function"===typeof this._type?new this._type:"object"===typeof this._type?this._type:typeof this._type};return a}();
(function(){Object.defineProperties(String.prototype,{replaceAll:{value:function(a,d){return this.split(a).join(d)},configurable:!0}})})();
var ImageBoundException=function(a){function d(d){a.apply(this,arguments);this.name="ImageBoundException";this.message=d||"An error occured with this image";this.stack=Error().stack}d.prototype=Object.create(a.prototype);return d.prototype.constructor=d}(Error),HttpCodes=Object.freeze({100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",
301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",
417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",
511:"Network Authentication Required"}),HttpException=function(a){function d(c){a.call(this);this.status=c.status;this.name="HttpException";this.internalError=!1;0===this.status?(this.isInternalError=!0,this.internalError=c.statusText.split(":").shift(),this.message=c.statusText.split(":").slice(-1).join().trim()):this.message=c.statusText;this.stack=Error().stack;try{this.responseText=c.responseText}catch(b){this.responseText=void 0}c.responseJSON&&(this._responseJson=c.responseJSON)}d.prototype=
Object.create(a.prototype);d.prototype.constructor=d;d.prototype.getStatus=function(){return this.status};d.prototype.getHttpReason=function(){return this.isInternalError?e.call(this):HttpCodes[this.status]};d.prototype.getResponseText=function(){return this.responseText};d.prototype.getError=function(){return this.isInternalError?e.call(this):void 0!==this._responseJson?1===this._responseJson.Error.length?this._responseJson.Error[0]:this._responseJson.Error:void 0===this.responseText?this.message:
this.responseText};var e=function(){return this.isInternalError?"ERROR"===this.internalError.trim().toUpperCase()?"There was no cause for this error, this is likely to do with your browser not accepting the HTTP request for the resource, this can happen if you are trying to do a cross domain request":this.internalError:null};return d}(Error);