/** * imagetools (Enhancement 1.1v) * The tinymce-plugins is used to import imagetools (Enhancement) * * https://github.com/Five-great/tinymce-plugins * * Copyright 2020, Five(Li Hailong) The Chengdu, China https://www.fivecc.cn/ * * Licensed under MIT */ (function(){var P=function(a){var b=a;return{get:function(){return b},set:function(c){b=c}}},ra=tinymce.util.Tools.resolve("tinymce.PluginManager"),H=tinymce.util.Tools.resolve("tinymce.util.Tools"),Q=function(){},v=function(a){return function(){return a}},w=v(!1),I=v(!0),B=function(){return J},J=function(){var a=function(d){return d.isNone()},b=function(d){return d()},c=function(d){return d};return{fold:function(d,e){return d()},is:w,isSome:w,isNone:I,getOr:c,getOrThunk:b,getOrDie:function(d){throw Error(d|| "error: getOrDie called on none.");},getOrNull:v(null),getOrUndefined:v(void 0),or:c,orThunk:b,map:B,each:Q,bind:B,exists:w,forall:I,filter:B,equals:a,equals_:a,toArray:function(){return[]},toString:v("none()")}}(),K=function(a){var b=v(a),c=function(){return e},d=function(f){return f(a)},e={fold:function(f,h){return h(a)},is:function(f){return a===f},isSome:I,isNone:w,getOr:b,getOrThunk:b,getOrDie:b,getOrNull:b,getOrUndefined:b,or:c,orThunk:c,map:function(f){return K(f(a))},each:function(f){f(a)}, bind:d,exists:d,forall:d,filter:function(f){return f(a)?e:J},toArray:function(){return[a]},toString:function(){return"some("+a+")"},equals:function(f){return f.is(a)},equals_:function(f,h){return f.fold(w,function(k){return h(a,k)})}};return e},q={some:K,none:B,from:function(a){return null===a||void 0===a?J:K(a)}},C=function(a){return null===a||void 0===a},sa=function(a){return function(b){return typeof b===a}}("function"),D=function(a,b){var c=document.createElement("canvas");c.width=a;c.height= b;return c},ta=function(a){var b=D(a.width,a.height);b.getContext("2d").drawImage(a,0,0);return b},va=function(){function a(g){var l=this;null===this._state?this._deferreds.push(g):k(function(){var m=l._state?g.onFulfilled:g.onRejected;if(null===m)(l._state?g.resolve:g.reject)(l._value);else{try{var n=m(l._value)}catch(u){g.reject(u);return}g.resolve(n)}})}function b(g){try{if(g===this)throw new TypeError("A promise cannot be resolved with itself.");if(g&&("object"===typeof g||"function"===typeof g)){var l= g.then;if("function"===typeof l){E(p(l,g),p(b,this),p(c,this));return}}this._state=!0;this._value=g;d.call(this)}catch(m){c.call(this,m)}}function c(g){this._state=!1;this._value=g;d.call(this)}function d(){for(var g=0,l=this._deferreds;ge?360+e:e;if(90===e||270===e){var r=f.width;f.width=f.height; f.height=r}if(90===e||180===e)k=f.width;if(270===e||180===e)p=f.height;h.translate(k,p);h.rotate(e*Math.PI/180);h.drawImage(c,0,0);return Z(f,d)})},Da=function(a,b){return a.toCanvas().then(function(c){var d=a.getType(),e=D(c.width,c.height),f=e.getContext("2d");"v"===b?(f.scale(1,-1),f.drawImage(c,0,-e.height)):(f.scale(-1,1),f.drawImage(c,-e.width,0));return Z(e,d)})},Ea=Object.keys,Fa=function(a,b){for(var c=Ea(a),d=0,e=c.length;da||300<=a},Pa=function(a,b){var c={"Content-Type":"application/json;charset=UTF-8","tiny-api-key":b};return aa(Oa(a,b),c).then(function(d){if(ca(d.status)){var e=d.status;d=d.blob;e="application/json"!==(null===d||void 0===d?void 0:d.type)||400!==e&&403!==e&&404!==e&&500!==e?ba(e):Na(d)}else e=t.resolve(d.blob);return e})},Qa=function(a,b){return aa(a,{},b).then(function(c){return ca(c.status)? ba(c.status):t.resolve(c.blob)})},da=function(a,b,c){void 0===c&&(c=!1);return b?Pa(a,b):Qa(a,c)},Ra=function(a){return Y(a)},y=function(a){if(null===a||void 0===a)throw Error("Node cannot be null or undefined");return{dom:a}},z={fromHtml:function(a,b){b=(b||document).createElement("div");b.innerHTML=a;if(!b.hasChildNodes()||1