mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-15 18:57:12 +01:00
2 lines
28 KiB
JavaScript
2 lines
28 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{186:function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},308:function(e,t,n){(function(i){var o,r;"undefined"!=typeof self&&self,void 0===(r="function"==typeof(o=function(){"function"!=typeof Promise&&function(t){function n(e,t){return function(){e.apply(t,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],h(e,n(a,this),n(s,this))}function r(e){var t=this;return null===this._state?void this._deferreds.push(e):void p((function(){var n=t._state?e.onFulfilled:e.onRejected;if(null!==n){var i;try{i=n(t._value)}catch(t){return void e.reject(t)}e.resolve(i)}else(t._state?e.resolve:e.reject)(t._value)}))}function a(e){try{if(e===this)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if("function"==typeof t)return void h(n(t,e),n(a,this),n(s,this))}this._state=!0,this._value=e,l.call(this)}catch(e){s.call(this,e)}}function s(e){this._state=!1,this._value=e,l.call(this)}function l(){for(var e=0,t=this._deferreds.length;t>e;e++)r.call(this,this._deferreds[e]);this._deferreds=null}function c(e,t,n,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=i}function h(e,t,n){var i=!1;try{e((function(e){i||(i=!0,t(e))}),(function(e){i||(i=!0,n(e))}))}catch(e){if(i)return;i=!0,n(e)}}var u=setTimeout,p="function"==typeof i&&i||function(e){u(e,1)},d=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var n=this;return new o((function(i,o){r.call(n,new c(e,t,i,o))}))},o.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&d(arguments[0])?arguments[0]:arguments);return new o((function(t,n){function i(r,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,(function(e){i(r,e)}),n)}e[r]=a,0==--o&&t(e)}catch(e){n(e)}}if(0===e.length)return t([]);for(var o=e.length,r=0;r<e.length;r++)i(r,e[r])}))},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o((function(t){t(e)}))},o.reject=function(e){return new o((function(t,n){n(e)}))},o.race=function(e){return new o((function(t,n){for(var i=0,o=e.length;o>i;i++)e[i].then(t,n)}))},o._setImmediateFn=function(e){p=e},e.exports?e.exports=o:t.Promise||(t.Promise=o)}(this),"function"!=typeof window.CustomEvent&&function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}(),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(e,t,n){for(var i=atob(this.toDataURL(t,n).split(",")[1]),o=i.length,r=new Uint8Array(o),a=0;a<o;a++)r[a]=i.charCodeAt(a);e(new Blob([r],{type:t||"image/png"}))}});var t,n,o,r=["Webkit","Moz","ms"],a=document.createElement("div").style,s=[1,8,3,6],l=[2,7,4,5];function c(e){if(e in a)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=r.length;n--;)if((e=r[n]+t)in a)return e}function h(e,t){for(var n in e=e||{},t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},h(e[n],t[n])):e[n]=t[n];return e}function u(e){return h({},e)}function p(e){if("createEvent"in document){var t=document.createEvent("HTMLEvents");t.initEvent("change",!1,!0),e.dispatchEvent(t)}else e.fireEvent("onchange")}function d(e,t,n){if("string"==typeof t){var i=t;(t={})[i]=n}for(var o in t)e.style[o]=t[o]}function m(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function f(e,t){for(var n in t)e.setAttribute(n,t[n])}function v(e){return parseInt(e,10)}function g(e,t){var n=e.naturalWidth,i=e.naturalHeight,o=t||x(e);if(o&&o>=5){var r=n;n=i,i=r}return{width:n,height:i}}n=c("transform"),t=c("transformOrigin"),o=c("userSelect");var w={translate3d:{suffix:", 0px"},translate:{suffix:""}},y=function(e,t,n){this.x=parseFloat(e),this.y=parseFloat(t),this.scale=parseFloat(n)};y.parse=function(e){return e.style?y.parse(e.style[n]):e.indexOf("matrix")>-1||e.indexOf("none")>-1?y.fromMatrix(e):y.fromString(e)},y.fromMatrix=function(e){var t=e.substring(7).split(",");return t.length&&"none"!==e||(t=[1,0,0,1,0,0]),new y(v(t[4]),v(t[5]),parseFloat(t[0]))},y.fromString=function(e){var t=e.split(") "),n=t[0].substring(ae.globals.translate.length+1).split(","),i=t.length>1?t[1].substring(6):1,o=n.length>1?n[0]:0,r=n.length>1?n[1]:0;return new y(o,r,i)},y.prototype.toString=function(){var e=w[ae.globals.translate].suffix||"";return ae.globals.translate+"("+this.x+"px, "+this.y+"px"+e+") scale("+this.scale+")"};var b=function(e){if(!e||!e.style[t])return this.x=0,void(this.y=0);var n=e.style[t].split(" ");this.x=parseFloat(n[0]),this.y=parseFloat(n[1])};function x(e){return e.exifdata&&e.exifdata.Orientation?v(e.exifdata.Orientation):1}function C(e,t,n){var i=t.width,o=t.height,r=e.getContext("2d");switch(e.width=t.width,e.height=t.height,r.save(),n){case 2:r.translate(i,0),r.scale(-1,1);break;case 3:r.translate(i,o),r.rotate(180*Math.PI/180);break;case 4:r.translate(0,o),r.scale(1,-1);break;case 5:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.scale(1,-1);break;case 6:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.translate(0,-o);break;case 7:e.width=o,e.height=i,r.rotate(-90*Math.PI/180),r.translate(-i,o),r.scale(1,-1);break;case 8:e.width=o,e.height=i,r.translate(0,i),r.rotate(-90*Math.PI/180)}r.drawImage(t,0,0,i,o),r.restore()}function E(){var e,t,n,i,o,r,a=this.options.viewport.type?"cr-vp-"+this.options.viewport.type:null;this.options.useCanvas=this.options.enableOrientation||_.call(this),this.data={},this.elements={},e=this.elements.boundary=document.createElement("div"),n=this.elements.viewport=document.createElement("div"),t=this.elements.img=document.createElement("img"),i=this.elements.overlay=document.createElement("div"),this.options.useCanvas?(this.elements.canvas=document.createElement("canvas"),this.elements.preview=this.elements.canvas):this.elements.preview=t,m(e,"cr-boundary"),e.setAttribute("aria-dropeffect","none"),o=this.options.boundary.width,r=this.options.boundary.height,d(e,{width:o+(isNaN(o)?"":"px"),height:r+(isNaN(r)?"":"px")}),m(n,"cr-viewport"),a&&m(n,a),d(n,{width:this.options.viewport.width+"px",height:this.options.viewport.height+"px"}),n.setAttribute("tabindex",0),m(this.elements.preview,"cr-image"),f(this.elements.preview,{alt:"preview","aria-grabbed":"false"}),m(i,"cr-overlay"),this.element.appendChild(e),e.appendChild(this.elements.preview),e.appendChild(n),e.appendChild(i),m(this.element,"croppie-container"),this.options.customClass&&m(this.element,this.options.customClass),B.call(this),this.options.enableZoom&&I.call(this),this.options.enableResize&&T.call(this)}function _(){return this.options.enableExif&&window.EXIF}function T(){var e,t,n,i,r,a,s,l=this,c=document.createElement("div"),h=!1;function u(a){if((void 0===a.button||0===a.button)&&(a.preventDefault(),!h)){var s=l.elements.overlay.getBoundingClientRect();if(h=!0,t=a.pageX,n=a.pageY,e=-1!==a.currentTarget.className.indexOf("vertical")?"v":"h",i=s.width,r=s.height,a.touches){var c=a.touches[0];t=c.pageX,n=c.pageY}window.addEventListener("mousemove",p),window.addEventListener("touchmove",p),window.addEventListener("mouseup",f),window.addEventListener("touchend",f),document.body.style[o]="none"}}function p(o){var a=o.pageX,s=o.pageY;if(o.preventDefault(),o.touches){var h=o.touches[0];a=h.pageX,s=h.pageY}var u=a-t,p=s-n,m=l.options.viewport.height+p,f=l.options.viewport.width+u;"v"===e&&m>=50&&m<=r?(d(c,{height:m+"px"}),l.options.boundary.height+=p,d(l.elements.boundary,{height:l.options.boundary.height+"px"}),l.options.viewport.height+=p,d(l.elements.viewport,{height:l.options.viewport.height+"px"})):"h"===e&&f>=50&&f<=i&&(d(c,{width:f+"px"}),l.options.boundary.width+=u,d(l.elements.boundary,{width:l.options.boundary.width+"px"}),l.options.viewport.width+=u,d(l.elements.viewport,{width:l.options.viewport.width+"px"})),Z.call(l),S.call(l),k.call(l),Y.call(l),n=s,t=a}function f(){h=!1,window.removeEventListener("mousemove",p),window.removeEventListener("touchmove",p),window.removeEventListener("mouseup",f),window.removeEventListener("touchend",f),document.body.style[o]=""}m(c,"cr-resizer"),d(c,{width:this.options.viewport.width+"px",height:this.options.viewport.height+"px"}),this.options.resizeControls.height&&(m(a=document.createElement("div"),"cr-resizer-vertical"),c.appendChild(a)),this.options.resizeControls.width&&(m(s=document.createElement("div"),"cr-resizer-horisontal"),c.appendChild(s)),a&&(a.addEventListener("mousedown",u),a.addEventListener("touchstart",u)),s&&(s.addEventListener("mousedown",u),s.addEventListener("touchstart",u)),this.elements.boundary.appendChild(c)}function L(e){if(this.options.enableZoom){var t=this.elements.zoomer,n=Q(e,4);t.value=Math.max(parseFloat(t.min),Math.min(parseFloat(t.max),n)).toString()}}function I(){var e=this,t=e.elements.zoomerWrap=document.createElement("div"),n=e.elements.zoomer=document.createElement("input");function i(){M.call(e,{value:parseFloat(n.value),origin:new b(e.elements.preview),viewportRect:e.elements.viewport.getBoundingClientRect(),transform:y.parse(e.elements.preview)})}function o(t){var n,o;if("ctrl"===e.options.mouseWheelZoom&&!0!==t.ctrlKey)return 0;n=t.wheelDelta?t.wheelDelta/1200:t.deltaY?t.deltaY/1060:t.detail?t.detail/-60:0,o=e._currentZoom+n*e._currentZoom,t.preventDefault(),L.call(e,o),i.call(e)}m(t,"cr-slider-wrap"),m(n,"cr-slider"),n.type="range",n.step="0.0001",n.value="1",n.style.display=e.options.showZoomer?"":"none",n.setAttribute("aria-label","zoom"),e.element.appendChild(t),t.appendChild(n),e._currentZoom=1,e.elements.zoomer.addEventListener("input",i),e.elements.zoomer.addEventListener("change",i),e.options.mouseWheelZoom&&(e.elements.boundary.addEventListener("mousewheel",o),e.elements.boundary.addEventListener("DOMMouseScroll",o))}function M(e){var i=this,o=e?e.transform:y.parse(i.elements.preview),r=e?e.viewportRect:i.elements.viewport.getBoundingClientRect(),a=e?e.origin:new b(i.elements.preview);function s(){var e={};e[n]=o.toString(),e[t]=a.toString(),d(i.elements.preview,e)}if(i._currentZoom=e?e.value:i._currentZoom,o.scale=i._currentZoom,i.elements.zoomer.setAttribute("aria-valuenow",i._currentZoom),s(),i.options.enforceBoundary){var l=R.call(i,r),c=l.translate,h=l.origin;o.x>=c.maxX&&(a.x=h.minX,o.x=c.maxX),o.x<=c.minX&&(a.x=h.maxX,o.x=c.minX),o.y>=c.maxY&&(a.y=h.minY,o.y=c.maxY),o.y<=c.minY&&(a.y=h.maxY,o.y=c.minY)}s(),X.call(i),Y.call(i)}function R(e){var t=this._currentZoom,n=e.width,i=e.height,o=this.elements.boundary.clientWidth/2,r=this.elements.boundary.clientHeight/2,a=this.elements.preview.getBoundingClientRect(),s=a.width,l=a.height,c=n/2,h=i/2,u=-1*(c/t-o),p=-1*(h/t-r),d=1/t*c,m=1/t*h;return{translate:{maxX:u,minX:u-(s*(1/t)-n*(1/t)),maxY:p,minY:p-(l*(1/t)-i*(1/t))},origin:{maxX:s*(1/t)-d,minX:d,maxY:l*(1/t)-m,minY:m}}}function k(e){var i=this._currentZoom,o=this.elements.preview.getBoundingClientRect(),r=this.elements.viewport.getBoundingClientRect(),a=y.parse(this.elements.preview.style[n]),s=new b(this.elements.preview),l=r.top-o.top+r.height/2,c=r.left-o.left+r.width/2,h={},u={};if(e){var p=s.x,m=s.y,f=a.x,v=a.y;h.y=p,h.x=m,a.y=f,a.x=v}else h.y=l/i,h.x=c/i,u.y=(h.y-s.y)*(1-i),u.x=(h.x-s.x)*(1-i),a.x-=u.x,a.y-=u.y;var g={};g[t]=h.x+"px "+h.y+"px",g[n]=a.toString(),d(this.elements.preview,g)}function B(){var e,t,i,r,a,s=this,l=!1;function c(e,t){var n=s.elements.preview.getBoundingClientRect(),i=a.y+t,o=a.x+e;s.options.enforceBoundary?(r.top>n.top+t&&r.bottom<n.bottom+t&&(a.y=i),r.left>n.left+e&&r.right<n.right+e&&(a.x=o)):(a.y=i,a.x=o)}function h(e){s.elements.preview.setAttribute("aria-grabbed",e),s.elements.boundary.setAttribute("aria-dropeffect",e?"move":"none")}function u(n){if((void 0===n.button||0===n.button)&&(n.preventDefault(),!l)){if(l=!0,e=n.pageX,t=n.pageY,n.touches){var i=n.touches[0];e=i.pageX,t=i.pageY}h(l),a=y.parse(s.elements.preview),window.addEventListener("mousemove",m),window.addEventListener("touchmove",m),window.addEventListener("mouseup",f),window.addEventListener("touchend",f),document.body.style[o]="none",r=s.elements.viewport.getBoundingClientRect()}}function m(o){o.preventDefault();var r=o.pageX,l=o.pageY;if(o.touches){var h=o.touches[0];r=h.pageX,l=h.pageY}var u=r-e,m=l-t,f={};if("touchmove"===o.type&&o.touches.length>1){var v=o.touches[0],g=o.touches[1],w=Math.sqrt((v.pageX-g.pageX)*(v.pageX-g.pageX)+(v.pageY-g.pageY)*(v.pageY-g.pageY));i||(i=w/s._currentZoom);var y=w/i;return L.call(s,y),void p(s.elements.zoomer)}c(u,m),f[n]=a.toString(),d(s.elements.preview,f),Z.call(s),t=l,e=r}function f(){h(l=!1),window.removeEventListener("mousemove",m),window.removeEventListener("touchmove",m),window.removeEventListener("mouseup",f),window.removeEventListener("touchend",f),document.body.style[o]="",k.call(s),Y.call(s),i=0}s.elements.overlay.addEventListener("mousedown",u),s.elements.viewport.addEventListener("keydown",(function(e){var t;if(!e.shiftKey||38!==e.keyCode&&40!==e.keyCode){if(s.options.enableKeyMovement&&e.keyCode>=37&&e.keyCode<=40){e.preventDefault();var l=function(e){switch(e){case 37:return[1,0];case 38:return[0,1];case 39:return[-1,0];case 40:return[0,-1]}}(e.keyCode);a=y.parse(s.elements.preview),document.body.style[o]="none",r=s.elements.viewport.getBoundingClientRect(),function(e){var t=e[0],r=e[1],l={};c(t,r),l[n]=a.toString(),d(s.elements.preview,l),Z.call(s),document.body.style[o]="",k.call(s),Y.call(s),i=0}(l)}}else t=38===e.keyCode?parseFloat(s.elements.zoomer.value)+parseFloat(s.elements.zoomer.step):parseFloat(s.elements.zoomer.value)-parseFloat(s.elements.zoomer.step),s.setZoom(t)})),s.elements.overlay.addEventListener("touchstart",u)}function Z(){if(this.elements){var e=this.elements.boundary.getBoundingClientRect(),t=this.elements.preview.getBoundingClientRect();d(this.elements.overlay,{width:t.width+"px",height:t.height+"px",top:t.top-e.top+"px",left:t.left-e.left+"px"})}}b.prototype.toString=function(){return this.x+"px "+this.y+"px"};var F,z,O,A,X=(F=Z,z=500,function(){var e=this,t=arguments,n=function(){A=null,O||F.apply(e,t)},i=O&&!A;clearTimeout(A),A=setTimeout(n,z),i&&F.apply(e,t)});function Y(){var e,t=this.get();j.call(this)&&(this.options.update.call(this,t),this.$&&"undefined"==typeof Prototype?this.$(this.element).trigger("update.croppie",t):(window.CustomEvent?e=new CustomEvent("update",{detail:t}):(e=document.createEvent("CustomEvent")).initCustomEvent("update",!0,!0,t),this.element.dispatchEvent(e)))}function j(){return this.elements.preview.offsetHeight>0&&this.elements.preview.offsetWidth>0}function W(){var e,i={},o=this.elements.preview,r=new y(0,0,1),a=new b;j.call(this)&&!this.data.bound&&(this.data.bound=!0,i[n]=r.toString(),i[t]=a.toString(),i.opacity=1,d(o,i),e=this.elements.preview.getBoundingClientRect(),this._originalImageWidth=e.width,this._originalImageHeight=e.height,this.data.orientation=x(this.elements.img),this.options.enableZoom?S.call(this,!0):this._currentZoom=1,r.scale=this._currentZoom,i[n]=r.toString(),d(o,i),this.data.points.length?H.call(this,this.data.points):N.call(this),k.call(this),Z.call(this))}function S(e){var t,n,i,o,r=Math.max(this.options.minZoom,0)||0,a=this.options.maxZoom||1.5,s=this.elements.zoomer,l=parseFloat(s.value),c=this.elements.boundary.getBoundingClientRect(),h=g(this.elements.img,this.data.orientation),u=this.elements.viewport.getBoundingClientRect();this.options.enforceBoundary&&(i=u.width/h.width,o=u.height/h.height,r=Math.max(i,o)),r>=a&&(a=r+1),s.min=Q(r,4),s.max=Q(a,4),!e&&(l<s.min||l>s.max)?L.call(this,l<s.min?s.min:s.max):e&&(n=Math.max(c.width/h.width,c.height/h.height),t=null!==this.data.boundZoom?this.data.boundZoom:n,L.call(this,t)),p(s)}function H(e){if(4!==e.length)throw"Croppie - Invalid number of points supplied: "+e;var i=e[2]-e[0],o=this.elements.viewport.getBoundingClientRect(),r=this.elements.boundary.getBoundingClientRect(),a=o.left-r.left,s=o.top-r.top,l=o.width/i,c=e[1],h=e[0],u=-1*e[1]+s,p=-1*e[0]+a,m={};m[t]=h+"px "+c+"px",m[n]=new y(p,u,l).toString(),d(this.elements.preview,m),L.call(this,l),this._currentZoom=l}function N(){var e=this.elements.preview.getBoundingClientRect(),t=this.elements.viewport.getBoundingClientRect(),i=this.elements.boundary.getBoundingClientRect(),o=t.left-i.left,r=t.top-i.top,a=o-(e.width-t.width)/2,s=r-(e.height-t.height)/2,l=new y(a,s,this._currentZoom);d(this.elements.preview,n,l.toString())}function P(e){var t=this.elements.canvas,n=this.elements.img;t.getContext("2d").clearRect(0,0,t.width,t.height),t.width=n.width,t.height=n.height,C(t,n,this.options.enableOrientation&&e||x(n))}function D(e){var t=e.points,n=v(t[0]),i=v(t[1]),o=v(t[2])-n,r=v(t[3])-i,a=e.circle,s=document.createElement("canvas"),l=s.getContext("2d"),c=e.outputWidth||o,h=e.outputHeight||r;s.width=c,s.height=h,e.backgroundColor&&(l.fillStyle=e.backgroundColor,l.fillRect(0,0,c,h));var u=n,p=i,d=o,m=r,f=0,g=0,w=c,y=h;return n<0&&(u=0,f=Math.abs(n)/o*c),d+u>this._originalImageWidth&&(w=(d=this._originalImageWidth-u)/o*c),i<0&&(p=0,g=Math.abs(i)/r*h),m+p>this._originalImageHeight&&(y=(m=this._originalImageHeight-p)/r*h),l.drawImage(this.elements.preview,u,p,d,m,f,g,w,y),a&&(l.fillStyle="#fff",l.globalCompositeOperation="destination-in",l.beginPath(),l.arc(s.width/2,s.height/2,s.width/2,0,2*Math.PI,!0),l.closePath(),l.fill()),s}function q(e){var t=e.points,n=document.createElement("div"),i=document.createElement("img"),o=t[2]-t[0],r=t[3]-t[1];return m(n,"croppie-result"),n.appendChild(i),d(i,{left:-1*t[0]+"px",top:-1*t[1]+"px"}),i.src=e.url,d(n,{width:o+"px",height:r+"px"}),n}function $(e){return D.call(this,e).toDataURL(e.format,e.quality)}function K(e){var t=this;return new Promise((function(n){D.call(t,e).toBlob((function(e){n(e)}),e.format,e.quality)}))}function U(e){this.elements.img.parentNode&&(Array.prototype.forEach.call(this.elements.img.classList,(function(t){e.classList.add(t)})),this.elements.img.parentNode.replaceChild(e,this.elements.img),this.elements.preview=e),this.elements.img=e}function J(e,t){var n,i,o,r,a=this,s=[],l=null,c=_.call(a);if("string"==typeof e)n=e,e={};else if(Array.isArray(e))s=e.slice();else{if(void 0===e&&a.data.url)return W.call(a),Y.call(a),null;n=e.url,s=e.points||[],l=void 0===e.zoom?null:e.zoom}return a.data.bound=!1,a.data.url=n||a.data.url,a.data.boundZoom=l,(i=n,o=c,r=new Image,r.style.opacity="0",new Promise((function(e,t){function n(){r.style.opacity="1",setTimeout((function(){e(r)}),1)}r.removeAttribute("crossOrigin"),i.match(/^https?:\/\/|^\/\//)&&r.setAttribute("crossOrigin","anonymous"),r.onload=function(){o?EXIF.getData(r,(function(){n()})):n()},r.onerror=function(e){r.style.opacity=1,setTimeout((function(){t(e)}),1)},r.src=i}))).then((function(n){if(U.call(a,n),s.length)a.options.relative&&(s=[s[0]*n.naturalWidth/100,s[1]*n.naturalHeight/100,s[2]*n.naturalWidth/100,s[3]*n.naturalHeight/100]);else{var i,o,r=g(n),l=a.elements.viewport.getBoundingClientRect(),c=l.width/l.height;r.width/r.height>c?i=(o=r.height)*c:(i=r.width,o=r.height/c);var h=(r.width-i)/2,u=(r.height-o)/2,p=h+i,d=u+o;a.data.points=[h,u,p,d]}a.data.points=s.map((function(e){return parseFloat(e)})),a.options.useCanvas&&P.call(a,e.orientation),W.call(a),Y.call(a),t&&t()}))}function Q(e,t){return parseFloat(e).toFixed(t||0)}function G(){var e=this.elements.preview.getBoundingClientRect(),t=this.elements.viewport.getBoundingClientRect(),n=t.left-e.left,i=t.top-e.top,o=(t.width-this.elements.viewport.offsetWidth)/2,r=(t.height-this.elements.viewport.offsetHeight)/2,a=n+this.elements.viewport.offsetWidth+o,s=i+this.elements.viewport.offsetHeight+r,l=this._currentZoom;(l===1/0||isNaN(l))&&(l=1);var c=this.options.enforceBoundary?0:Number.NEGATIVE_INFINITY;return n=Math.max(c,n/l),i=Math.max(c,i/l),a=Math.max(c,a/l),s=Math.max(c,s/l),{points:[Q(n),Q(i),Q(a),Q(s)],zoom:l,orientation:this.data.orientation}}var V={type:"canvas",format:"png",quality:1},ee=["jpeg","webp","png"];function te(e){var t=this,n=G.call(t),i=h(u(V),u(e)),o="string"==typeof e?e:i.type||"base64",r=i.size||"viewport",a=i.format,s=i.quality,l=i.backgroundColor,c="boolean"==typeof i.circle?i.circle:"circle"===t.options.viewport.type,p=t.elements.viewport.getBoundingClientRect(),d=p.width/p.height;return"viewport"===r?(n.outputWidth=p.width,n.outputHeight=p.height):"object"==typeof r&&(r.width&&r.height?(n.outputWidth=r.width,n.outputHeight=r.height):r.width?(n.outputWidth=r.width,n.outputHeight=r.width/d):r.height&&(n.outputWidth=r.height*d,n.outputHeight=r.height)),ee.indexOf(a)>-1&&(n.format="image/"+a,n.quality=s),n.circle=c,n.url=t.data.url,n.backgroundColor=l,new Promise((function(e){switch(o.toLowerCase()){case"rawcanvas":e(D.call(t,n));break;case"canvas":case"base64":e($.call(t,n));break;case"blob":K.call(t,n).then(e);break;default:e(q.call(t,n))}}))}function ne(){W.call(this)}function ie(e){if(!this.options.useCanvas||!this.options.enableOrientation)throw"Croppie: Cannot rotate without enableOrientation && EXIF.js included";var t,n,i,o,r,a=this.elements.canvas;this.data.orientation=(t=this.data.orientation,n=e,i=s.indexOf(t)>-1?s:l,o=i.indexOf(t),r=n/90%i.length,i[(i.length+o+r%i.length)%i.length]),C(a,this.elements.img,this.data.orientation),k.call(this,!0),S.call(this)}function oe(){var e,t;this.element.removeChild(this.elements.boundary),e=this.element,t="croppie-container",e.classList?e.classList.remove(t):e.className=e.className.replace(t,""),this.options.enableZoom&&this.element.removeChild(this.elements.zoomerWrap),delete this.elements}if(window.jQuery){var re=window.jQuery;re.fn.croppie=function(e){var t=typeof e;if("string"===t){var n=Array.prototype.slice.call(arguments,1),i=re(this).data("croppie");return"get"===e?i.get():"result"===e?i.result.apply(i,n):"bind"===e?i.bind.apply(i,n):this.each((function(){var t=re(this).data("croppie");if(t){var i=t[e];if(!re.isFunction(i))throw"Croppie "+e+" method not found";i.apply(t,n),"destroy"===e&&re(this).removeData("croppie")}}))}return this.each((function(){var t=new ae(this,e);t.$=re,re(this).data("croppie",t)}))}}function ae(e,t){if(e.className.indexOf("croppie-container")>-1)throw new Error("Croppie: Can't initialize croppie more than once");if(this.element=e,this.options=h(u(ae.defaults),t),"img"===this.element.tagName.toLowerCase()){var n=this.element;m(n,"cr-original-image"),f(n,{"aria-hidden":"true",alt:""});var i=document.createElement("div");this.element.parentNode.appendChild(i),i.appendChild(n),this.element=i,this.options.url=this.options.url||n.src}if(E.call(this),this.options.url){var o={url:this.options.url,points:this.options.points};delete this.options.url,delete this.options.points,J.call(this,o)}}return ae.defaults={viewport:{width:100,height:100,type:"square"},boundary:{},orientationControls:{enabled:!0,leftClass:"",rightClass:""},resizeControls:{width:!0,height:!0},customClass:"",showZoomer:!0,enableZoom:!0,enableResize:!1,mouseWheelZoom:!0,enableExif:!1,enforceBoundary:!0,enableOrientation:!1,enableKeyMovement:!0,update:function(){}},ae.globals={translate:"translate3d"},h(ae.prototype,{bind:function(e,t){return J.call(this,e,t)},get:function(){var e=G.call(this),t=e.points;return this.options.relative&&(t[0]/=this.elements.img.naturalWidth/100,t[1]/=this.elements.img.naturalHeight/100,t[2]/=this.elements.img.naturalWidth/100,t[3]/=this.elements.img.naturalHeight/100),e},result:function(e){return te.call(this,e)},refresh:function(){return ne.call(this)},setZoom:function(e){L.call(this,e),p(this.elements.zoomer)},rotate:function(e){ie.call(this,e)},destroy:function(){return oe.call(this)}}),ae})?o.call(t,n,t,e):o)||(e.exports=r)}).call(this,n(309).setImmediate)},309:function(e,t,n){(function(e){var i=void 0!==e&&e||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function r(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new r(o.call(setTimeout,i,arguments),clearTimeout)},t.setInterval=function(){return new r(o.call(setInterval,i,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(i,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(310),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(186))},310:function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var i,o,r,a,s,l=1,c={},h=!1,u=e.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(e);p=p&&p.setTimeout?p:e,"[object process]"==={}.toString.call(e.process)?i=function(e){t.nextTick((function(){m(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){m(e.data)},i=function(e){r.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(o=u.documentElement,i=function(e){var t=u.createElement("script");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,o.removeChild(t),t=null},o.appendChild(t)}):i=function(e){setTimeout(m,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&m(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),i=function(t){e.postMessage(a+t,"*")}),p.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var o={callback:e,args:t};return c[l]=o,i(l),l++},p.clearImmediate=d}function d(e){delete c[e]}function m(e){if(h)setTimeout(m,0,e);else{var t=c[e];if(t){h=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(void 0,n)}}(t)}finally{d(e),h=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(186),n(311))},311:function(e,t){var n,i,o=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===r||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:r}catch(e){n=r}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var l,c=[],h=!1,u=-1;function p(){h&&l&&(h=!1,l.length?c=l.concat(c):u=-1,c.length&&d())}function d(){if(!h){var e=s(p);h=!0;for(var t=c.length;t;){for(l=c,c=[];++u<t;)l&&l[u].run();u=-1,t=c.length}l=null,h=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function f(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new m(e,t)),1!==c.length||h||s(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=f,o.addListener=f,o.once=f,o.off=f,o.removeListener=f,o.removeAllListeners=f,o.emit=f,o.prependListener=f,o.prependOnceListener=f,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},312:function(e,t,n){}}]);
|
|
//# sourceMappingURL=6.1712ed1ad0fe8fb0958d.js.map
|