PageSourceSearch

https://atletiq.com/panel/assets/angular_app/directives/ngImgCrop/ng-img-crop.js

js atletiq.com collected 2026-09-24 12:24:02 UTC 71,342 bytes, 3 lines download raw bytes

1/*! ngImgCropExtended v0.5.4 License: MIT */!function(){var e=angular.module("ngImgCrop",[]);e.factory("cropAreaCircle",["cropArea",function(e){var t=function(){e.apply(this,arguments),this._boxResizeBaseSize=30,this._boxResizeNormalRatio=.9,this._boxResizeHoverRatio=1.2,this._iconMoveNormalRatio=.9,this._iconMoveHoverRatio=1.2,this._boxResizeNormalSize=this._boxResizeBaseSize*this._boxResizeNormalRatio,this._boxResizeHoverSize=this._boxResizeBaseSize*this._boxResizeHoverRatio,this._posDragStartX=0,this._posDragStartY=0,this._posResizeStartX=0,this._posResizeStartY=0,this._posResizeStartSize=0,this._boxResizeIsHover=!1,this._areaIsHover=!1,this._boxResizeIsDragging=!1,this._areaIsDragging=!1};return t.prototype=new e,t.prototype.getType=function(){return"circle"},t.prototype._calcCirclePerimeterCoords=function(e){var t=this._size.w/2,i=e*(Math.PI/180),r=this.getCenterPoint().x+t*Math.cos(i),n=this.getCenterPoint().y+t*Math.sin(i);return[r,n]},t.prototype._calcResizeIconCenterCoords=function(){return this._calcCirclePerimeterCoords(-45)},t.prototype._isCoordWithinArea=function(e){return Math.sqrt((e[0]-this.getCenterPoint().x)*(e[0]-this.getCenterPoint().x)+(e[1]-this.getCenterPoint().y)*(e[1]-this.getCenterPoint().y))<this._size.w/2},t.prototype._isCoordWithinBoxResize=function(e){var t=this._calcResizeIconCenterCoords(),i=this._boxResizeHoverSize/2;return e[0]>t[0]-i&&e[0]<t[0]+i&&e[1]>t[1]-i&&e[1]<t[1]+i},t.prototype._drawArea=function(e,t,i){e.arc(t.x,t.y,i.w/2,0,2*Math.PI)},t.prototype.draw=function(){e.prototype.draw.apply(this,arguments);var t=this.getCenterPoint();this._cropCanvas.drawIconMove([t.x,t.y],this._areaIsHover?this._iconMoveHoverRatio:this._iconMoveNormalRatio),this._cropCanvas.drawIconResizeBoxNESW(this._calcResizeIconCenterCoords(),this._boxResizeBaseSize,this._boxResizeIsHover?this._boxResizeHoverRatio:this._boxResizeNormalRatio)},t.prototype.processMouseMove=function(e,t){var i="default",r=!1;if(this._boxResizeIsHover=!1,this._areaIsHover=!1,this._areaIsDragging)this.setCenterPointOnMove({x:e-this._posDragStartX,y:t-this._posDragStartY}),this._areaIsHover=!0,i="move",r=!0,this._events.trigger("area-move");else if(this._boxResizeIsDragging){i="nesw-resize";var n,o,a;o=e-this._posResizeStartX,a=this._posResizeStartY-t,n=o>a?this._posResizeStartSize.w+2*a:this._posResizeStartSize.w+2*o;var s=(this.getCenterPoint(),{}),h={};s.x=this.getCenterPoint().x-.5*n,h.x=this.getCenterPoint().x+.5*n,s.y=this.getCenterPoint().y-.5*n,h.y=this.getCenterPoint().y+.5*n,this.CircleOnMove(s,h),this._boxResizeIsHover=!0,r=!0,this._events.trigger("area-resize")}else this._isCoordWithinBoxResize([e,t])?(i="nesw-resize",this._areaIsHover=!1,this._boxResizeIsHover=!0,r=!0):this._isCoordWithinArea([e,t])&&(i="move",this._areaIsHover=!0,r=!0);return angular.element(this._ctx.canvas).css({cursor:i}),r},t.prototype.processMouseDown=function(e,t){if(this._isCoordWithinBoxResize([e,t]))this._areaIsDragging=!1,this._areaIsHover=!1,this._boxResizeIsDragging=!0,this._boxResizeIsHover=!0,this._posResizeStartX=e,this._posResizeStartY=t,this._posResizeStartSize=this._size,this._events.trigger("area-resize-start");else if(this._isCoordWithinArea([e,t])){this._areaIsDragging=!0,this._areaIsHover=!0,this._boxResizeIsDragging=!1,this._boxResizeIsHover=!1;var i=this.getCenterPoint();this._posDragStartX=e-i.x,this._posDragStartY=t-i.y,this._events.trigger("area-move-start")}},t.prototype.processMouseUp=function(){this._areaIsDragging&&(this._areaIsDragging=!1,this._events.trigger("area-move-end")),this._boxResizeIsDragging&&(this._boxResizeIsDragging=!1,this._events.trigger("area-resize-end")),this._areaIsHover=!1,this._boxResizeIsHover=!1,this._posDragStartX=0,this._posDragStartY=0},t}]),e.factory("cropAreaRectangle",["cropArea",function(e){var t=function(){e.apply(this,arguments),this._resizeCtrlBaseRadius=15,this._resizeCtrlNormalRatio=.75,this._resizeCtrlHoverRatio=1,this._iconMoveNormalRatio=.9,this._iconMoveHoverRatio=1.2,this._resizeCtrlNormalRadius=this._resizeCtrlBaseRadius*this._resizeCtrlNormalRatio,this._resizeCtrlHoverRadius=this._resizeCtrlBaseRadius*this._resizeCtrlHoverRatio,this._posDragStartX=0,this._posDragStartY=0,this._posResizeStartX=0,this._posResizeStartY=0,this._posResizeStartSize={w:0,h:0},this._resizeCtrlIsHover=-1,this._areaIsHover=!1,this._resizeCtrlIsDragging=-1,this._areaIsDragging=!1};return t.prototype=new e,t.prototype.getType=function(){return"rectangle"},t.prototype._calcRectangleCorners=function(){var e=this.getSize(),t=this.getSouthEastBound();return[[e.x,e.y],[t.x,e.y],[e.x,t.y],[t.x,t.y]]},t.prototype._calcRectangleDimensions=function(){var e=this.getSize(),t=this.getSouthEastBound();return{left:e.x,top:e.y,right:t.x,bottom:t.y}},t.prototype._isCoordWithinArea=function(e){var t=this._calcRectangleDimensions();return e[0]>=t.left&&e[0]<=t.right&&e[1]>=t.top&&e[1]<=t.bottom},t.prototype._isCoordWithinResizeCtrl=function(e){for(var t=this._calcRectangleCorners(),i=-1,r=0,n=t.length;n>r;r++){var o=t[r];if(e[0]>o[0]-this._resizeCtrlHoverRadius&&e[0]<o[0]+this._resizeCtrlHoverRadius&&e[1]>o[1]-this._resizeCtrlHoverRadius&&e[1]<o[1]+this._resizeCtrlHoverRadius){i=r;break}}return i},t.prototype._drawArea=function(e,t,i){e.rect(i.x,i.y,i.w,i.h)},t.prototype.draw=function(){e.prototype.draw.apply(this,arguments);var t=this.getCenterPoint();this._cropCanvas.drawIconMove([t.x,t.y],this._areaIsHover?this._iconMoveHoverRatio:this._iconMoveNormalRatio);for(var i=this._calcRectangleCorners(),r=0,n=i.length;n>r;r++){var o=i[r];this._cropCanvas.drawIconResizeCircle(o,this._resizeCtrlBaseRadius,this._resizeCtrlIsHover===r?this._resizeCtrlHoverRatio:this._resizeCtrlNormalRatio)}},t.prototype.processMouseMove=function(e,t){var i="default",r=!1;if(this._resizeCtrlIsHover=-1,this._areaIsHover=!1,this._areaIsDragging)this.setCenterPointOnMove({x:e-this._posDragStartX,y:t-this._posDragStartY}),this._areaIsHover=!0,i="move",r=!0,this._events.trigger("area-move");else if(this._resizeCtrlIsDragging>-1){var n=this.getSize(),o=this.getSouthEastBound(),a=e;switch(this._resizeCtrlIsDragging){case 0:this._aspect&&(a=o.x-(o.y-t)*this._aspect),this.setSizeByCorners({x:a,y:t},{x:o.x,y:o.y}),i="nwse-resize";break;case 1:this._aspect&&(a=n.x+(o.y-t)*this._aspect),this.setSizeByCorners({x:n.x,y:t},{x:a,y:o.y}),i="nesw-resize";break;case 2:this._aspect&&(a=o.x-(t-n.y)*this._aspect),this.setSizeByCorners({x:a,y:n.y},{x:o.x,y:t}),i="nesw-resize";break;case 3:this._aspect&&(a=n.x+(t-n.y)*this._aspect),this.setSizeByCorners({x:n.x,y:n.y},{x:a,y:t}),i="nwse-resize"}this._resizeCtrlIsHover=this._resizeCtrlIsDragging,r=!0,this._events.trigger("area-resize")}else{var s=this._isCoordWithinResizeCtrl([e,t]);if(s>-1){switch(s){case 0:i="nwse-resize";break;case 1:i="nesw-resize";break;case 2:i="nesw-resize";break;case 3:i="nwse-resize"}this._areaIsHover=!1,this._resizeCtrlIsHover=s,r=!0}else this._isCoordWithinArea([e,t])&&(i="move",this._areaIsHover=!0,r=!0)}return angular.element(this._ctx.canvas).css({cursor:i}),r},t.prototype.processMouseDown=function(e,t){var i=this._isCoordWithinResizeCtrl([e,t]);if(i>-1)this._areaIsDragging=!1,this._areaIsHover=!1,this._resizeCtrlIsDragging=i,this._resizeCtrlIsHover=i,this._posResizeStartX=e,this._posResizeStartY=t,this._posResizeStartSize=this._size,this._events.trigger("area-resize-start");else if(this._isCoordWithinArea([e,t])){this._areaIsDragging=!0,this._areaIsHover=!0,this._resizeCtrlIsDragging=-1,this._resizeCtrlIsHover=-1;var r=this.getCenterPoint();this._posDragStartX=e-r.x,this._posDragStartY=t-r.y,this._events.trigger("area-move-start")}},t.prototype.processMouseUp=function(){this._areaIsDragging&&(this._areaIsDragging=!1,this._events.trigger("area-move-end")),this._resizeCtrlIsDragging>-1&&(this._resizeCtrlIsDragging=-1,this._events.trigger("area-resize-end")),this._areaIsHover=!1,this._resizeCtrlIsHover=-1,this._posDragStartX=0,this._posDragStartY=0},t}]),e.factory("cropAreaSquare",["cropArea",function(e){var t=function(){e.apply(this,arguments),this._resizeCtrlBaseRadius=15,this._resizeCtrlNormalRatio=.75,this._resizeCtrlHoverRatio=1,this._iconMoveNormalRatio=.9,this._iconMoveHoverRatio=1.2,this._resizeCtrlNormalRadius=this._resizeCtrlBaseRadius*this._resizeCtrlNormalRatio,this._resizeCtrlHoverRadius=this._resizeCtrlBaseRadius*this._resizeCtrlHoverRatio,this._posDragStartX=0,this._posDragStartY=0,this._posResizeStartX=0,this._posResizeStartY=0,this._posResizeStartSize=0,this._resizeCtrlIsHover=-1,this._areaIsHover=!1,this._resizeCtrlIsDragging=-1,this._areaIsDragging=!1};return t.prototype=new e,t.prototype.getType=function(){return"square"},t.prototype._calcSquareCorners=function(){var e=this.getSize(),t=this.getSouthEastBound();return[[e.x,e.y],[t.x,e.y],[e.x,t.y],[t.x,t.y]]},t.prototype._calcSquareDimensions=function(){var e=this.getSize(),t=this.getSouthEastBound();return{left:e.x,top:e.y,right:t.x,bottom:t.y}},t.prototype._isCoordWithinArea=function(e){var t=this._calcSquareDimensions();return e[0]>=t.left&&e[0]<=t.right&&e[1]>=t.top&&e[1]<=t.bottom},t.prototype._isCoordWithinResizeCtrl=function(e){for(var t=this._calcSquareCorners(),i=-1,r=0,n=t.length;n>r;r++){var o=t[r];if(e[0]>o[0]-this._resizeCtrlHoverRadius&&e[0]<o[0]+this._resizeCtrlHoverRadius&&e[1]>o[1]-this._resizeCtrlHoverRadius&&e[1]<o[1]+this._resizeCtrlHoverRadius){i=r;break}}return i},t.prototype._drawArea=function(e,t,i){e.rect(i.x,i.y,i.w,i.h)},t.prototype.draw=function(){e.prototype.draw.apply(this,arguments);var t=this.getCenterPoint();this._cropCanvas.drawIconMove([t.x,t.y],this._areaIsHover?this._iconMoveHoverRatio:this._iconMoveNormalRatio);for(var i=this._calcSquareCorners(),r=0,n=i.length;n>r;r++){var o=i[r];this._cropCanvas.drawIconResizeCircle(o,this._resizeCtrlBaseRadius,this._resizeCtrlIsHover===r?this._resizeCtrlHoverRatio:this._resizeCtrlNormalRatio)}},t.prototype.processMouseMove=function(e,t){var i="default",r=!1;if(this._resizeCtrlIsHover=-1,this._areaIsHover=!1,this._areaIsDragging)this.setCenterPointOnMove({x:e-this._posDragStartX,y:t-this._posDragStartY}),this._areaIsHover=!0,i="move",r=!0,this._events.trigger("area-move");else if(this._resizeCtrlIsDragging>-1){var n,o;switch(this._resizeCtrlIsDragging){case 0:n=-1,o=-1,i="nwse-resize";break;case 1:n=1,o=-1,i="nesw-resize";break;case 2:n=-1,o=1,i="nesw-resize";break;case 3:n=1,o=1,i="nwse-resize"}var a,s=(e-this._posResizeStartX)*n,h=(t-this._posResizeStartY)*o;a=s>h?this._posResizeStartSize.w+h:this._posResizeStartSize.w+s;var c=Math.max(this._minSize.w,a),u={},l={},g={},f={},p=this.getSize(),d=this.getSouthEastBound();switch(this._resizeCtrlIsDragging){case 0:u.x=d.x-c,u.y=d.y-c,u.y>0&&this.setSizeByCorners(u,{x:d.x,y:d.y}),i="nwse-resize";break;case 1:s>=0&&h>=0?(f.x=p.x+c,f.y=d.y-c):(0>s||0>h)&&(f.x=p.x+c,f.y=d.y-c),f.y>0&&this.setSizeByCorners({x:p.x,y:f.y},{x:f.x,y:d.y}),i="nesw-resize";break;case 2:s>=0&&h>=0?(g.x=d.x-c,g.y=p.y+c):(0>=s||0>=h)&&(g.x=d.x-c,g.y=p.y+c),g.y<this._ctx.canvas.height&&this.setSizeByCorners({x:g.x,y:p.y},{x:d.x,y:g.y}),i="nesw-resize";break;case 3:l.x=p.x+c,l.y=p.y+c,l.y<this._ctx.canvas.height&&this.setSizeByCorners({x:p.x,y:p.y},l),i="nwse-resize"}this._resizeCtrlIsHover=this._resizeCtrlIsDragging,r=!0,this._events.trigger("area-resize")}else{var v=this._isCoordWithinResizeCtrl([e,t]);if(v>-1){switch(v){case 0:i="nwse-resize";break;case 1:i="nesw-resize";break;case 2:i="nesw-resize";break;case 3:i="nwse-resize"}this._areaIsHover=!1,this._resizeCtrlIsHover=v,r=!0}else this._isCoordWithinArea([e,t])&&(i="move",this._areaIsHover=!0,r=!0)}return angular.element(this._ctx.canvas).css({cursor:i}),r},t.prototype.processMouseDown=function(e,t){var i=this._isCoordWithinResizeCtrl([e,t]);if(i>-1)this._areaIsDragging=!1,this._areaIsHover=!1,this._resizeCtrlIsDragging=i,this._resizeCtrlIsHover=i,this._posResizeStartX=e,this._posResizeStartY=t,this._posResizeStartSize=this._size,this._events.trigger("area-resize-start");else if(this._isCoordWithinArea([e,t])){this._areaIsDragging=!0,this._areaIsHover=!0,this._resizeCtrlIsDragging=-1,this._resizeCtrlIsHover=-1;var r=this.getCenterPoint();this._posDragStartX=e-r.x,this._posDragStartY=t-r.y,this._events.trigger("area-move-start")}},t.prototype.processMouseUp=function(){this._areaIsDragging&&(this._areaIsDragging=!1,this._events.trigger("area-move-end")),this._resizeCtrlIsDragging>-1&&(this._resizeCtrlIsDragging=-1,this._events.trigger("area-resize-end")),this._areaIsHover=!1,this._resizeCtrlIsHover=-1,this._posDragStartX=0,this._posDragStartY=0},t}]),e.factory("cropArea",["cropCanvas",function(e){var t=function(t,i){this._ctx=t,this._events=i,this._minSize={x:0,y:0,w:80,h:80},this._initSize=void 0,this._initCoords=void 0,this._allowCropResizeOnCorners=!1,this._forceAspectRatio=!1,this._aspect=null,this._cropCanvas=new e(t),this._image=new Image,this._size={x:0,y:0,w:150,h:150}};return t.prototype.setAllowCropResizeOnCorners=function(e){this._allowCropResizeOnCorners=e},t.prototype.getImage=function(){return this._image},t.prototype.setImage=function(e){this._image=e},t.prototype.setForceAspectRatio=function(e){this._forceAspectRatio=e},t.prototype.setAspect=function(e){this._aspect=e},t.prototype.getAspect=function(){return this._aspect},t.prototype.getCanvasSize=function(){return{w:this._ctx.canvas.width,h:this._ctx.canvas.height}},t.prototype.getSize=function(){return this._size},t.prototype.setSize=function(e){e=this._processSize(e),this._size=this._preventBoundaryCollision(e)},t.prototype.setSizeOnMove=function(e){e=this._processSize(e),this._size=this._allowCropResizeOnCorners?this._preventBoundaryCollision(e):this._allowMouseOutsideCanvas(e)},t.prototype.CircleOnMove=function(e,t){var i={x:e.x,y:e.y,w:t.x-e.x,h:t.y-e.y},r=this._ctx.canvas.height,n=this._ctx.canvas.width;(i.w>n||i.h>r)&&(r>n?(i.w=n,i.h=n):(i.w=r,i.h=r)),i.x+i.w>n&&(i.x=n-i.w),i.y+i.h>r&&(i.y=r-i.h),i.x<0&&(i.x=0),i.y<0&&(i.y=0),this._minSize.w>i.w&&(i.w=this._minSize.w,i.x=this._size.x),this._minSize.h>i.h&&(i.h=this._minSize.h,i.y=this._size.y),this._size=i},t.prototype.setSizeByCorners=function(e,t){var i={x:e.x,y:e.y,w:t.x-e.x,h:t.y-e.y};this.setSize(i)},t.prototype.getSouthEastBound=function(){return this._southEastBound(this.getSize())},t.prototype.setMinSize=function(e){this._minSize=this._processSize(e),this.setSize(this._minSize)},t.prototype.getMinSize=function(){return this._minSize},t.prototype.getCenterPoint=function(){var e=this.getSize();return{x:e.x+e.w/2,y:e.y+e.h/2}},t.prototype.setCenterPoint=function(e){var t=this.getSize();this.setSize({x:e.x-t.w/2,y:e.y-t.h/2,w:t.w,h:t.h})},t.prototype.setCenterPointOnMove=function(e){var t=this.getSize();this.setSizeOnMove({x:e.x-t.w/2,y:e.y-t.h/2,w:t.w,h:t.h})},t.prototype.setInitSize=function(e){this._initSize=this._processSize(e),this.setSize(this._initSize)},t.prototype.getInitSize=function(){return this._initSize},t.prototype.setInitCoords=function(e){e.h=this.getSize().h,e.w=this.getSize().w,this._initCoords=this._processSize(e),this.setSize(this._initCoords)},t.prototype.getInitCoords=function(){return this._initCoords},t.prototype.getType=function(){return"circle"},t.prototype._allowMouseOutsideCanvas=function(e){var t=this._ctx.canvas.height,i=this._ctx.canvas.width,r={w:e.w,h:e.h};return r.x=e.x<0?0:e.x+e.w>
1i?i-e.w:e.x,r.y=e.y<0?0:e.y+e.h>t?t-e.h:e.y,r},t.prototype._preventBoundaryCollision=function(e){var t=this._ctx.canvas.height,i=this._ctx.canvas.width,r={x:e.x,y:e.y},n=this._southEastBound(e);r.x<0&&(r.x=0),r.y<0&&(r.y=0),n.x>i&&(n.x=i),n.y>t&&(n.y=t);var o=this._forceAspectRatio?e.w:n.x-r.x,a=this._forceAspectRatio?e.h:n.y-r.y;this._aspect&&(o=a*this._aspect,r.x+o>i&&(o=i-r.x,a=o/this._aspect,this._minSize.w>o&&(o=this._minSize.w),this._minSize.h>a&&(a=this._minSize.h),r.x=i-o),r.y+a>t&&(r.y=t-a)),this._forceAspectRatio&&(o=a,r.x+o>i&&(o=i-r.x,o<this._minSize.w&&(o=this._minSize.w),a=o));var s={x:r.x,y:r.y,w:o,h:a};return s.w<this._minSize.w&&!this._forceAspectRatio&&(s.w=this._minSize.w,n=this._southEastBound(s),n.x>i&&(n.x=i,r.x=Math.max(n.x-i,n.x-this._minSize.w),s={x:r.x,y:r.y,w:n.x-r.x,h:n.y-r.y})),s.h<this._minSize.h&&!this._forceAspectRatio&&(s.h=this._minSize.h,n=this._southEastBound(s),n.y>t&&(n.y=t,r.y=Math.max(n.y-t,n.y-this._minSize.h),s={x:r.x,y:r.y,w:n.x-r.x,h:n.y-r.y})),this._forceAspectRatio&&(n=this._southEastBound(s),n.y>t&&(s.y=t-s.h),n.x>i&&(s.x=i-s.w)),s},t.prototype._dontDragOutside=function(){var e=this._ctx.canvas.height,t=this._ctx.canvas.width;this._width>t&&(this._width=t),this._height>e&&(this._height=e),this._x<this._width/2&&(this._x=this._width/2),this._x>t-this._width/2&&(this._x=t-this._width/2),this._y<this._height/2&&(this._y=this._height/2),this._y>e-this._height/2&&(this._y=e-this._height/2)},t.prototype._drawArea=function(){},t.prototype._processSize=function(e){"number"==typeof e&&(e={w:e,h:e});var t=e.w;return this._aspect&&(t=e.h*this._aspect),{x:e.x||this.getSize().x,y:e.y||this.getSize().y,w:t||this._minSize.w,h:e.h||this._minSize.h}},t.prototype._southEastBound=function(e){return{x:e.x+e.w,y:e.y+e.h}},t.prototype.draw=function(){this._cropCanvas.drawCropArea(this._image,this.getCenterPoint(),this._size,this._drawArea)},t.prototype.processMouseMove=function(){},t.prototype.processMouseDown=function(){},t.prototype.processMouseUp=function(){},t}]),e.factory("cropCanvas",[function(){var e=[[-.5,-2],[-3,-4.5],[-.5,-7],[-7,-7],[-7,-.5],[-4.5,-3],[-2,-.5]],t=[[.5,-2],[3,-4.5],[.5,-7],[7,-7],[7,-.5],[4.5,-3],[2,-.5]],i=[[-.5,2],[-3,4.5],[-.5,7],[-7,7],[-7,.5],[-4.5,3],[-2,.5]],r=[[.5,2],[3,4.5],[.5,7],[7,7],[7,.5],[4.5,3],[2,.5]],n=[[-1.5,-2.5],[-1.5,-6],[-5,-6],[0,-11],[5,-6],[1.5,-6],[1.5,-2.5]],o=[[-2.5,-1.5],[-6,-1.5],[-6,-5],[-11,0],[-6,5],[-6,1.5],[-2.5,1.5]],a=[[-1.5,2.5],[-1.5,6],[-5,6],[0,11],[5,6],[1.5,6],[1.5,2.5]],s=[[2.5,-1.5],[6,-1.5],[6,-5],[11,0],[6,5],[6,1.5],[2.5,1.5]],h={areaOutline:"#fff",resizeBoxStroke:"#fff",resizeBoxFill:"#444",resizeBoxArrowFill:"#fff",resizeCircleStroke:"#fff",resizeCircleFill:"#444",moveIconFill:"#fff"};return function(c){var u=function(e,t,i){return[i*e[0]+t[0],i*e[1]+t[1]]},l=function(e,t,i,r){c.save(),c.fillStyle=t,c.beginPath();var n,o=u(e[0],i,r);c.moveTo(o[0],o[1]);for(var a in e)a>0&&(n=u(e[a],i,r),c.lineTo(n[0],n[1]));c.lineTo(o[0],o[1]),c.fill(),c.closePath(),c.restore()};this.drawIconMove=function(e,t){l(n,h.moveIconFill,e,t),l(o,h.moveIconFill,e,t),l(a,h.moveIconFill,e,t),l(s,h.moveIconFill,e,t)},this.drawIconResizeCircle=function(e,t,i){var r=t*i;c.save(),c.strokeStyle=h.resizeCircleStroke,c.lineWidth=2,c.fillStyle=h.resizeCircleFill,c.beginPath(),c.arc(e[0],e[1],r,0,2*Math.PI),c.fill(),c.stroke(),c.closePath(),c.restore()},this.drawIconResizeBoxBase=function(e,t,i){var r=t*i;c.save(),c.strokeStyle=h.resizeBoxStroke,c.lineWidth=2,c.fillStyle=h.resizeBoxFill,c.fillRect(e[0]-r/2,e[1]-r/2,r,r),c.strokeRect(e[0]-r/2,e[1]-r/2,r,r),c.restore()},this.drawIconResizeBoxNESW=function(e,r,n){this.drawIconResizeBoxBase(e,r,n),l(t,h.resizeBoxArrowFill,e,n),l(i,h.resizeBoxArrowFill,e,n)},this.drawIconResizeBoxNWSE=function(t,i,n){this.drawIconResizeBoxBase(t,i,n),l(e,h.resizeBoxArrowFill,t,n),l(r,h.resizeBoxArrowFill,t,n)},this.drawCropArea=function(e,t,i,r){var n=Math.abs(e.width/c.canvas.width),o=Math.abs(e.height/c.canvas.height),a=Math.abs(t.x-i.w/2),s=Math.abs(t.y-i.h/2);c.save(),c.strokeStyle=h.areaOutline,c.lineWidth=2,c.beginPath(),r(c,t,i),c.stroke(),c.clip(),i.w>0&&c.drawImage(e,a*n,s*o,Math.abs(i.w*n),Math.abs(i.h*o),a,s,Math.abs(i.w),Math.abs(i.h)),c.beginPath(),r(c,t,i),c.stroke(),c.clip(),c.restore(
1)}}}]),e.service("cropEXIF",[function(){function e(e){return!!e.exifdata}function t(e,t){t=t||e.match(/^data\:([^\;]+)\;base64,/im)[1]||"",e=e.replace(/^data\:([^\;]+)\;base64,/gim,"");for(var i=atob(e),r=i.length,n=new ArrayBuffer(r),o=new Uint8Array(n),a=0;r>a;a++)o[a]=i.charCodeAt(a);return n}function i(e,t){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="blob",i.onload=function(){(200==this.status||0===this.status)&&t(this.response)},i.send()}function r(e,r){function a(t){var i=n(t),a=o(t);e.exifdata=i||{},e.iptcdata=a||{},r&&r.call(e)}if(e.src)if(/^data\:/i.test(e.src)){var s=t(e.src);a(s)}else if(/^blob\:/i.test(e.src)){var h=new FileReader;h.onload=function(e){a(e.target.result)},i(e.src,function(e){h.readAsArrayBuffer(e)})}else{var c=new XMLHttpRequest;c.onload=function(){if(200!=this.status&&0!==this.status)throw"Could not load image";a(c.response),c=null},c.open("GET",e.src,!0),c.responseType="arraybuffer",c.send(null)}else if(window.FileReader&&(e instanceof window.Blob||e instanceof window.File)){var h=new FileReader;h.onload=function(e){l&&console.log("Got file of length "+e.target.result.byteLength),a(e.target.result)},h.readAsArrayBuffer(e)}}function n(e){var t=new DataView(e);if(l&&console.log("Got file of length "+e.byteLength),255!=t.getUint8(0)||216!=t.getUint8(1))return l&&console.log("Not a valid JPEG"),!1;for(var i,r=2,n=e.byteLength;n>r;){if(255!=t.getUint8(r))return l&&console.log("Not a valid marker at offset "+r+", found: "+t.getUint8(r)),!1;if(i=t.getUint8(r+1),l&&console.log(i),225==i)return l&&console.log("Found 0xFFE1 marker"),u(t,r+4,t.getUint16(r+2)-2);r+=2+t.getUint16(r+2)}}function o(e){var t=new DataView(e);if(l&&console.log("Got file of length "+e.byteLength),255!=t.getUint8(0)||216!=t.getUint8(1))return l&&console.log("Not a valid JPEG"),!1;for(var i=2,r=e.byteLength,n=function(e,t){return 56===e.getUint8(t)&&66===e.getUint8(t+1)&&73===e.getUint8(t+2)&&77===e.getUint8(t+3)&&4===e.getUint8(t+4)&&4===e.getUint8(t+5)};r>i;){if(n(t,i)){var o=t.getUint8(i+7);o%2!==0&&(o+=1),0===o&&(o=4);var s=i+8+o,h=t.getUint16(i+6+o);return a(e,s,h)}i++}}function a(e,t,i){for(var r,n,o,a,s,h=new DataView(e),u={},l=t;t+i>l;)28===h.getUint8(l)&&2===h.getUint8(l+1)&&(a=h.getUint8(l+2),a in v&&(o=h.getInt16(l+3),s=o+5,n=v[a],r=c(h,l+5,o),u.hasOwnProperty(n)?u[n]instanceof Array?u[n].push(r):u[n]=[u[n],r]:u[n]=r)),l++;return u}function s(e,t,i,r,n){var o,a,s,c=e.getUint16(i,!n),u={};for(s=0;c>s;s++)o=i+12*s+2,a=r[e.getUint16(o,!n)],!a&&l&&console.log("Unknown tag: "+e.getUint16(o,!n)),u[a]=h(e,o,t,i,n);return u}function h(e,t,i,r,n){var o,a,s,h,u,l,g=e.getUint16(t+2,!n),f=e.getUint32(t+4,!n),p=e.getUint32(t+8,!n)+i;switch(g){case 1:case 7:if(1==f)return e.getUint8(t+8,!n);for(o=f>4?p:t+8,a=[],h=0;f>h;h++)a[h]=e.getUint8(o+h);return a;case 2:return o=f>4?p:t+8,c(e,o,f-1);case 3:if(1==f)return e.getUint16(t+8,!n);for(o=f>2?p:t+8,a=[],h=0;f>h;h++)a[h]=e.getUint16(o+2*h,!n);return a;case 4:if(1==f)return e.getUint32(t+8,!n);for(a=[],h=0;f>h;h++)a[h]=e.getUint32(p+4*h,!n);return a;case 5:if(1==f)return u=e.getUint32(p,!n),l=e.getUint32(p+4,!n),s=new Number(u/l),s.numerator=u,s.denominator=l,s;for(a=[],h=0;f>h;h++)u=e.getUint32(p+8*h,!n),l=e.getUint32(p+4+8*h,!n),a[h]=new Number(u/l),a[h].numerator=u,a[h].denominator=l;return a;case 9:if(1==f)return e.getInt32(t+8,!n);for(a=[],h=0;f>h;h++)a[h]=e.getInt32(p+4*h,!n);return a;case 10:if(1==f)return e.getInt32(p,!n)/e.getInt32(p+4,!n);for(a=[],h=0;f>h;h++)a[h]=e.getInt32(p+8*h,!n)/e.getInt32(p+4+8*h,!n);return a}}function c(e,t,i){for(var r="",n=t;t+i>n;n++)r+=String.fromCharCode(e.getUint8(n));return r}function u(e,t){if("Exif"!=c(e,t,4))return l&&console.log("Not valid EXIF data! "+c(e,t,4)),!1;var i,r,n,o,a,h=t+6;if(18761==e.getUint16(h))i=!1;else{if(19789!=e.getUint16(h))return l&&console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"),!1;i=!0}if(42!=e.getUint16(h+2,!i))return l&&console.log("Not valid TIFF data! (no 0x002A)"),!1;var u=e.getUint32(h+4,!i);if(8>u)return l&&console.log("Not valid TIFF data! (First offset less than 8)",e.getUint32(h+4,!i)),!1;if(r=s(e,h,h+u,f,i),r.ExifIFDPointer){o=s(e,h,h+r.ExifIFDPointer,g,i);for(n in o){switch(n){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":o[n]=d[n][o[n]];break;case"ExifVersion":case"FlashpixVersion":o[n]=String.fromCharCode(o[n][0],o[n][1],o[n][2],o[n][3]);break;case"ComponentsConfiguration":o[n]=d.Components[o[n][0]]+d.Components[o[n][1]]+d.Components[o[n][2]]+d.Components[o[n][3]]}r[n]=o[n]}}if(r.GPSInfoIFDPointer){a=s(e,h,h+r.GPSInfoIFDPointer,p,i);for(n in a){switch(n){case"GPSVersionID":a[n]=a[n][0]+"."+a[n][1]+"."+a[n][2]+"."+a[n][3]}r[n]=a[n]}}return r}var l=!1,g=this.Tags={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",3738
10:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},f=this.TiffTags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},p=this.GPSTags={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},d=this.StringValues={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}},v={120:"caption",110:"credit",25:"keywords",55:"dateCreated",80:"byline",85:"bylineTitle",122:"captionWriter",105:"headline",116:"copyright",15:"category"};this.getData=function(t,i){return(t instanceof Image||t instanceof HTMLImageElement)&&!t.complete?!1:(e(t)?i&&i.call(t):r(t,i),!0)},this.getTag=function(t,i){return e(t)?t.exifdata[i]:void 0},this.getAllTags=function(t){if(!e(t))return{};var i,r=t.exifdata,n={};for(i in r)r.hasOwnProperty(i)&&(n[i]=r[i]);return n},this.pretty=function(t){if(!e(t))return"";var i,r=t.exifdata,n="";for(i in r)r.hasOwnProperty(i)&&(n+="object"==typeof r[i]?r[i]instanceof Number?i+" : "+r[i]+" ["+r[i].numerator+"/"+r[i].denominator+"]\r\n":i+" : ["+r[i].length+" values]\r\n":i+" : "+r[i]+"\r\n");return n},this.readFromBinaryFile=function(e){return n(e)}}]),e.factory("cropHost",["$document","$q","cropAreaCircle","cropAreaSquare","cropAreaRectangle","cropEXIF",function(e,t,i,r,n,o){var a=function(e){var t=e.getBoundingClientRect(),i=document.body,r=document.documentElement,n=window.pageYOffset||r.scrollTop||i.scrollTop,o=window.pageXOffset||r.scrollLeft||i.scrollLeft,a=r.clientTop||i.clientTop||0,s=r.clientLeft||i.clientLeft||0,h=t.top+n-a,c=t.left+o-s;
1return{top:Math.round(h),left:Math.round(c)}};return function(s,h,c){function u(){l.clearRect(0,0,l.canvas.width,l.canvas.height),null!==g&&(l.drawImage(g,0,0,l.canvas.width,l.canvas.height),l.save(),l.fillStyle="rgba(0, 0, 0, 0.65)",l.fillRect(0,0,l.canvas.width,l.canvas.height),l.restore(),f.draw())}var l=null,g=null,f=null,p=null,d=null,v=this,m=[100,100],w=[300,300],y=[],S={w:200,h:200},_=null,C="image/png",z=null,x=!1;this.setInitMax=function(e){p=e},this.setAllowCropResizeOnCorners=function(e){f.setAllowCropResizeOnCorners(e)};var I=function(){if(null!==g){f.setImage(g);var e=[g.width,g.height],t=g.width/g.height,i=e;i[0]>w[0]?(i[0]=w[0],i[1]=i[0]/t):i[0]<m[0]&&(i[0]=m[0],i[1]=i[0]/t),i[1]>w[1]?(i[1]=w[1],i[0]=i[1]*t):i[1]<m[1]&&(i[1]=m[1],i[0]=i[1]*t),s.prop("width",i[0]).prop("height",i[1]).css({"margin-left":-i[0]/2+"px","margin-top":-i[1]/2+"px"});var r=l.canvas.width,n=l.canvas.height,o=v.getAreaType();if("circle"===o||"square"===o)r>n?r=n:n=r;
2else if("rectangle"===o&&d){var a=f.getAspect();r/n>a?r=a*n:n=a*r}p?f.setSize({w:r,h:n}):void 0!==f.getInitSize()?f.setSize({w:Math.min(f.getInitSize().w,r/2),h:Math.min(f.getInitSize().h,n/2)}):f.setSize({w:Math.min(200,r/2),h:Math.min(200,n/2)}),f.getInitCoords()?f.setSize({w:f.getSize().w,h:f.getSize().h,x:f.getInitCoords().x,y:f.getInitCoords().y}):f.setCenterPoint({x:l.canvas.width/2,y:l.canvas.height/2})}else s.prop("width",0).prop("height",0).css({"margin-top":0});u()},b=function(e){return angular.isDefined(e.changedTouches)?e.changedTouches:e.originalEvent.changedTouches},R=function(e){if(null!==g){var t,i,r=a(l.canvas);"touchmove"===e.type?(t=b(e)[0].pageX,i=b(e)[0].pageY):(t=e.pageX,i=e.pageY),f.processMouseMove(t-r.left,i-r.top),u()}},D=function(e){if(e.preventDefault(),e.stopPropagation(),null!==g){var t,i,r=a(l.canvas);"touchstart"===e.type?(t=b(e)[0].pageX,i=b(e)[0].pageY):(t=e.pageX,i=e.pageY),f.processMouseDown(t-r.left,i-r.top),u()}},P=function(e){if(null!==g){var t,i,r=a(l.canvas);"touchend"===e.type?(t=b(e)[0].pageX,i=b(e)[0].pageY):(t=e.pageX,i=e.pageY),f.processMouseUp(t-r.left,i-r.top),u()}},M=function(e){var t,i,r=e,n=f.getCenterPoint(),o={dataURI:null,imageData:null};if(i=angular.element("<canvas></canvas>")[0],t=i.getContext("2d"),i.width=r.w,i.height=r.h,null!==g){var a=(n.x-f.getSize().w/2)*(g.width/l.canvas.width),s=(n.y-f.getSize().h/2)*(g.height/l.canvas.height),h=f.getSize().w*(g.width/l.canvas.width),c=f.getSize().h*(g.height/l.canvas.height);if(x)t.drawImage(g,a,s,h,c,0,0,r.w,r.h);else{var u,p,d=h/c;d>1?(p=r.w,u=p/d):(u=r.h,p=u*d),t.drawImage(g,a,s,h,c,0,0,Math.round(p),Math.round(u))}o.dataURI=null!==z?i.toDataURL(C,z):i.toDataURL(C)}return o};this.getResultImage=function(){if(0==y.length)return M(this.getResultImageSize());for(var e=[],t=0;t<y.length;t++)e.push({dataURI:M(y[t]).dataURI,w:y[t].w,h:y[t].h});return e},this.getResultImageDataBlob=function(){var e,i,r=f.getCenterPoint(),n=this.getResultImageSize(),o=t.defer();if(i=angular.element("<canvas></canvas>")[0],e=i.getContext("2d"),i.width=n.w,i.height=n.h,null!==g){var a=(r.x-f.getSize().w/2)*(g.width/l.canvas.width),s=(r.y-f.getSize().h/2)*(g.height/l.canvas.height),h=f.getSize().w*(g.width/l.canvas.width),c=f.getSize().h*(g.height/l.canvas.height);if(x)e.drawImage(g,a,s,h,c,0,0,n.w,n.h);else{var u,p,d=h/c;d>1?(p=n.w,u=p/d):(u=n.h,p=u*d),e.drawImage(g,a,s,h,c,0,0,Math.round(p),Math.round(u))}}return i.toBlob(function(e){o.resolve(e)},C),o.promise},this.getAreaCoords=function(){return f.getSize()},this.getArea=function(){return f},this.setNewImageSource=function(e){if(g=null,I(),c.trigger("image-updated"),e){var t=new Image;t.onload=function(){c.trigger("load-done"),o.getData(t,function(){var e=o.getTag(t,"Orientation");if([3,6,8].indexOf(e)>-1){var i=document.createElement("canvas"),r=i.getContext("2d"),n=t.width,a=t.height,s=0,h=0,u=0,l=0,f=0;switch(l=n,f=a,e){case 3:s=-t.width,h=-t.height,u=180;break;case 6:n=t.height,a=t.width,h=-t.height,l=a,f=n,u=90;break;case 8:n=t.height,a=t.width,s=-t.width,l=a,f=n,u=270}var p=1e3;if(n>p||a>p){var d=0;n>p?(d=p/n,n=p,a=d*a):a>p&&(d=p/a,a=p,n=d*n),h=d*h,s=d*s,l=d*l,f=d*f}i.width=n,i.height=a,r.rotate(u*Math.PI/180),r.drawImage(t,s,h,l,f),g=new Image,g.onload=function(){I(),c.trigger("image-updated")},g.src=i.toDataURL(C)}else g=t;I(),c.trigger("image-updated")})},t.onerror=function(){c.trigger("load-error")},c.trigger("load-start"),e instanceof window.Blob?t.src=URL.createObjectURL(e):("http"===e.substring(0,4).toLowerCase()&&(t.crossOrigin="anonymous"),t.src=e)}},this.setMaxDimensions=function(e,t){if(w=[e,t],null!==g){var i=l.canvas.width,r=l.canvas.height,n=[g.width,g.height],o=g.width/g.height,a=n;a[0]>w[0]?(a[0]=w[0],a[1]=a[0]/o):a[0]<m[0]&&(a[0]=m[0],a[1]=a[0]/o),a[1]>w[1]?(a[1]=w[1],a[0]=a[1]*o):a[1]<m[1]&&(a[1]=m[1],a[0]=a[1]*o),s.prop("width",a[0]).prop("height",a[1]).css({"margin-left":-a[0]/2+"px","margin-top":-a[1]/2+"px"});var h=l.canvas.width/i,c=l.canvas.height/r,p=Math.min(h,c);f.setSize({w:f.getSize().w*p,h:f.getSize().h*p});var d=f.getCenterPoint();f.setCenterPoint({x:d.x*h,y:d.y*c})}else s.prop("width",0).prop("height",0).css({"margin-top":0});u()},this.setAreaMinSize=function(e){angular.isUndefined(e)||(e="number"==typeof e||"string"==typeof e?{w:parseInt(parseInt(e),10),h:parseInt(parseInt(e),10)}:{w:parseInt(e.w,10),h:parseInt(e.h,10)},isNaN(e.w)||isNaN(e.h)||(f.setMinSize(e),u()))},this.setAreaMinRelativeSize=function(e){if(null!==g){var t=f.getCanvasSize();if(angular.isUndefined(e))return;"number"==typeof e||"string"==typeof e?(_={w:e,h:e}
2,e={w:t.w/(g.width/parseInt(parseInt(e),10)),h:t.h/(g.height/parseInt(parseInt(e),10))}):(_=e,e={w:t.w/(g.width/parseInt(parseInt(e.w),10)),h:t.h/(g.height/parseInt(parseInt(e.h),10))}),isNaN(e.w)||isNaN(e.h)||(f.setMinSize(e),u())}},this.setAreaInitSize=function(e){angular.isUndefined(e)||(e="number"==typeof e||"string"==typeof e?{w:parseInt(parseInt(e),10),h:parseInt(parseInt(e),10)}:{w:parseInt(e.w,10),h:parseInt(e.h,10)},isNaN(e.w)||isNaN(e.h)||(f.setInitSize(e),u()))},this.setAreaInitCoords=function(e){angular.isUndefined(e)||(e={x:parseInt(e.x,10),y:parseInt(e.y,10)},isNaN(e.x)||isNaN(e.y)||(f.setInitCoords(e),u()))},this.setMaxCanvasDimensions=function(e){if(!angular.isUndefined(e)){var t=[];t="number"==typeof e||"string"==typeof e?[parseInt(parseInt(e),10),parseInt(parseInt(e),10)]:[parseInt(e.h,10),parseInt(e.w,10)],!isNaN(t[0])&&t[0]>0&&t[0]>m[0]&&!isNaN(t[1])&&t[1]>0&&t[1]>m[1]&&(w=t)}},this.setMinCanvasDimensions=function(e){if(!angular.isUndefined(e)){var t=[];t="number"==typeof e||"string"==typeof e?[parseInt(parseInt(e),10),parseInt(parseInt(e),10)]:[parseInt(e.h,10),parseInt(e.w,10)],!isNaN(t[0])&&t[0]>=0&&!isNaN(t[1])&&t[1]>=0&&(m=t)}},this.getResultImageSize=function(){if("selection"==S)return f.getSize();if("max"==S){var e=1;g&&l&&l.canvas&&(e=g.width/l.canvas.width);var t={w:e*f.getSize().w,h:e*f.getSize().h};return _&&(t.w<_.w&&(t.w=_.w),t.h<_.h&&(t.h=_.h)),t}return S},this.setResultImageSize=function(e){if(angular.isArray(e))return y=e.slice(),e={w:parseInt(e[0].w,10),h:parseInt(e[0].h,10)},void 0;if(!angular.isUndefined(e)){if(angular.isString(e))return S=e,void 0;angular.isNumber(e)&&(e=parseInt(e,10),e={w:e,h:e}),e={w:parseInt(e.w,10),h:parseInt(e.h,10)},isNaN(e.w)||isNaN(e.h)||(S=e,u())}},this.setResultImageFormat=function(e){C=e},this.setResultImageQuality=function(e){e=parseFloat(e),!isNaN(e)&&e>=0&&1>=e&&(z=e)},this.getAreaType=function(){return f.getType()},this.setAreaType=function(e){var t=f.getCenterPoint(),o=f.getSize(),a=f.getMinSize(),s=t.x,h=t.y,p=i;"square"===e?p=r:"rectangle"===e&&(p=n),f=new p(l,c),f.setMinSize(a),f.setSize(o),"square"===e||"circle"===e?(x=!0,f.setForceAspectRatio(!0)):(x=!1,f.setForceAspectRatio(!1)),f.setCenterPoint({x:s,y:h}),null!==g&&f.setImage(g),u()},this.getDominantColor=function(e){var i=new Image,r=new ColorThief,n=null,o=t.defer();return i.src=e,i.onload=function(){n=r.getColor(i),o.resolve(n)},o.promise},this.getPalette=function(e){var i=new Image,r=new ColorThief,n=null,o=t.defer();return i.src=e,i.onload=function(){n=r.getPalette(i,colorPaletteLength),o.resolve(n)},o.promise},this.setPaletteColorLength=function(e){colorPaletteLength=e},this.setAspect=function(e){d=!0,f.setAspect(e);var t=f.getMinSize();t.w=t.h*e,f.setMinSize(t);var i=f.getSize();i.w=i.h*e,f.setSize(i)},l=s[0].getContext("2d"),f=new i(l,c),e.on("mousemove",R),s.on("mousedown",D),e.on("mouseup",P),e.on("touchmove",R),s.on("touchstart",D),e.on("touchend",P),this.destroy=function(){e.off("mousemove",R),s.off("mousedown",D),e.off("mouseup",R),e.off("touchmove",R),s.off("touchstart",D),e.off("touchend",R),s.remove()}}}]),e.factory("cropPubSub",[function(){return function(){var e={};this.on=function(t,i){return t.split(" ").forEach(function(t){e[t]||(e[t]=[]),e[t].push(i)}),this},this.trigger=function(t,i){return angular.forEach(e[t],function(e){e.call(null,i)}),this}}}]),e.directive("imgCrop",["$timeout","cropHost","cropPubSub",function(e,t,i){return{restrict:"E",scope:{image:"=",resultImage:"=",resultArrayImage:"=?",resultBlob:"=?",urlBlob:"=?",chargement:"=?",cropject:"=?",maxCanvasDimensions:"=?",minCanvasDimensions:"=?",changeOnFly:"=?",liveView:"=?",initMaxArea:"=?",areaCoords:"=?",areaType:"@",areaMinSize:"=?",areaInitSize:"=?",areaInitCoords:"=?",areaMinRelativeSize:"=?",resultImageSize:"=?",resultImageFormat:"=?",resultImageQuality:"=?",aspectRatio:"=?",allowCropResizeOnCorners:"=?",dominantColor:"=?",paletteColor:"=?",paletteColorLength:"=?",onChange:"&",onLoadBegin:"&",onLoadDone:"&",onLoadError:"&"},template:"<canvas></canvas>",controller:["$scope",function(e){e.events=new i}],link:function(i,r){i.liveView&&"boolean"==typeof i.liveView.block?i.liveView.render=function(e){s(i,
2!0,e)}:i.liveView={block:!1};var n,o=i.events,a=new t(r.find("canvas"),{},o),s=function(e,t,i){if(""!==e.image&&(!e.liveView.block||t)){var r=a.getResultImage();if(angular.isArray(r))o=r[0].dataURI,e.resultArrayImage=r,console.log(e.resultArrayImage);else var o=r.dataURI;var s=window.URL||window.webkitURL;n!==o&&(n=o,e.resultImage=o,e.liveView.callback&&e.liveView.callback(o),i&&i(o),a.getResultImageDataBlob().then(function(t){e.resultBlob=t,e.urlBlob=s.createObjectURL(t)}),e.resultImage&&(a.getDominantColor(e.resultImage).then(function(t){e.dominantColor=t}),a.getPalette(e.resultImage).then(function(t){e.paletteColor=t})),h(e),e.onChange({$dataURI:e.resultImage}))}},h=function(e){var t=a.getAreaCoords();e.areaCoords=t},c=function(e){var t=a.getAreaCoords(),i={x:a.getArea().getImage().width/a.getArea().getCanvasSize().w,y:a.getArea().getImage().height/a.getArea().getCanvasSize().h};e.cropject={areaCoords:t,cropWidth:t.w,cropHeight:t.h,cropTop:t.y,cropLeft:t.x,cropImageWidth:Math.round(t.w*i.x),cropImageHeight:Math.round(t.h*i.y),cropImageTop:Math.round(t.y*i.y),cropImageLeft:Math.round(t.x*i.x)}},u=function(t){return function(){e(function(){i.$apply(function(e){t(e)})})}};null==i.chargement&&(i.chargement="Chargement");var l=function(){r.append('<div class="loading"><span>'+i.chargement+"...</span></div>")};o.on("load-start",u(function(e){e.onLoadBegin({})})).on("load-done",u(function(e){angular.element(r.children()[r.children().length-1]).remove(),e.onLoadDone({})})).on("load-error",u(function(e){e.onLoadError({})})).on("area-move area-resize",u(function(e){e.changeOnFly&&s(e),c(e)})).on("area-move-end area-resize-end image-updated",u(function(e){s(e),c(e)})).on("image-updated",u(function(e){a.setAreaMinRelativeSize(e.areaMinRelativeSize)})),i.$watch("image",function(t){t&&l(),e(function(){a.setInitMax(i.initMaxArea),a.setNewImageSource(i.image)},100)}),i.$watch("areaType",function(){a.setAreaType(i.areaType),s(i)}),i.$watch("areaMinSize",function(){a.setAreaMinSize(i.areaMinSize),s(i)}),i.$watch("areaMinRelativeSize",function(){""!==i.image&&(a.setAreaMinRelativeSize(i.areaMinRelativeSize),s(i))}),i.$watch("areaInitSize",function(){a.setAreaInitSize(i.areaInitSize),s(i)}),i.$watch("areaInitCoords",function(){a.setAreaInitCoords(i.areaInitCoords),s(i)}),i.$watch("maxCanvasDimensions",function(){a.setMaxCanvasDimensions(i.maxCanvasDimensions)}),i.$watch("minCanvasDimensions",function(){a.setMinCanvasDimensions(i.minCanvasDimensions)}),i.$watch("resultImageFormat",function(){a.setResultImageFormat(i.resultImageFormat),s(i)}),i.$watch("resultImageQuality",function(){a.setResultImageQuality(i.resultImageQuality),s(i)}),i.$watch("resultImageSize",function(){a.setResultImageSize(i.resultImageSize),s(i)}),i.$watch("paletteColorLength",function(){a.setPaletteColorLength(i.paletteColorLength)}),i.$watch("aspectRatio",function(){"string"==typeof i.aspectRatio&&""!=i.aspectRatio&&(i.aspectRatio=parseInt(i.aspectRatio)),i.aspectRatio&&a.setAspect(i.aspectRatio)}),i.$watch("allowCropResizeOnCorners",function(){i.allowCropResizeOnCorners&&a.setAllowCropResizeOnCorners(i.allowCropResizeOnCorners)}),i.$watch(function(){return[r[0].clientWidth,r[0].clientHeight]},function(e){e[0]>0&&e[1]>0&&(a.setMaxDimensions(e[0],e[1]),s(i))},!0),i.$on("$destroy",function(){a.destroy()})}}}]),function(e){"use strict";var t,i=e.Uint8Array,r=e.HTMLCanvasElement,n=r&&r.prototype,o=/\s*;\s*base64\s*(?:;|$)/i,a="toDataURL",s=function(e){for(var r,n,o,a=e.length,s=new i(a/4*3|0),h=0,c=0,u=[0,0],l=0,g=0;a--;)n=e.charCodeAt(h++),r=t[n-43],255!==r&&r!==o&&(u[1]=u[0],u[0]=n,g=g<<6|r,l++,4===l&&(s[c++]=g>>>16,61!==u[1]&&(s[c++]=g>>>8),61!==u[0]&&(s[c++]=g),l=0));return s};i&&(t=new i([62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])),r&&!n.toBlob&&(n.toBlob=function(e,t){if(t||(t="image/png"),this.mozGetAsFile)return e(this.mozGetAsFile("canvas",t)),void 0;if(this.msToBlob&&/^\s*image\/png\s*(?:$|;)/i.test(t))return e(this.msToBlob()),void 0;
2var r,n=Array.prototype.slice.call(arguments,1),h=this[a].apply(this,n),c=h.indexOf(","),u=h.substring(c+1),l=o.test(h.substring(0,c));Blob.fake?(r=new Blob,r.encoding=l?"base64":"URI",r.data=u,r.size=u.length):i&&(r=l?new Blob([s(u)],{type:t}):new Blob([decodeURIComponent(u)],{type:t})),"undefined"!=typeof e&&e(r)},n.toBlobHD=n.toDataURLHD?function(){a="toDataURLHD";var e=this.toBlob();return a="toDataURL",e}:n.toBlob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this),function(){var e=function(e){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),document.body.appendChild(this.canvas),this.width=this.canvas.width=e.width,this.height=this.canvas.height=e.height,this.context.drawImage(e,0,0,this.width,this.height)};e.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},e.prototype.update=function(e){this.context.putImageData(e,0,0)},e.prototype.getPixelCount=function(){return this.width*this.height},e.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)},e.prototype.removeCanvas=function(){this.canvas.parentNode.removeChild(this.canvas)};var t=function(){};if(t.prototype.getColor=function(e,t){var i=this.getPalette(e,5,t),r=i[0];return r},t.prototype.getPalette=function(t,i,n){"undefined"==typeof i&&(i=10),("undefined"==typeof n||1>n)&&(n=10);for(var o,a,s,h,c,u=new e(t),l=u.getImageData(),g=l.data,f=u.getPixelCount(),p=[],d=0;f>d;d+=n)o=4*d,a=g[o+0],s=g[o+1],h=g[o+2],c=g[o+3],c>=125&&(a>250&&s>250&&h>250||p.push([a,s,h]));var v=r.quantize(p,i),m=v?v.palette():null;return u.removeCanvas(),m},!i)var i={map:function(e,t){var i={};return t?e.map(function(e,r){return i.index=r,t.call(i,e)}):e.slice()},naturalOrder:function(e,t){return t>e?-1:e>t?1:0},sum:function(e,t){var i={};return e.reduce(t?function(e,r,n){return i.index=n,e+t.call(i,r)}:function(e,t){return e+t},0)},max:function(e,t){return Math.max.apply(null,t?i.map(e,t):e)}};var r=function(){function e(e,t,i){return(e<<2*c)+(t<<c)+i}function t(e){function t(){i.sort(e),r=!0}var i=[],r=!1;return{push:function(e){i.push(e),r=!1},peek:function(e){return r||t(),void 0===e&&(e=i.length-1),i[e]},pop:function(){return r||t(),i.pop()},size:function(){return i.length},map:function(e){return i.map(e)},debug:function(){return r||t(),i}}}function r(e,t,i,r,n,o,a){var s=this;s.r1=e,s.r2=t,s.g1=i,s.g2=r,s.b1=n,s.b2=o,s.histo=a}function n(){this.vboxes=new t(function(e,t){return i.naturalOrder(e.vbox.count()*e.vbox.volume(),t.vbox.count()*t.vbox.volume())})}function o(t){var i,r,n,o,a=1<<3*c,s=new Array(a);return t.forEach(function(t){r=t[0]>>u,n=t[1]>>u,o=t[2]>>u,i=e(r,n,o),s[i]=(s[i]||0)+1}),s}function a(e,t){var i,n,o,a=1e6,s=0,h=1e6,c=0,l=1e6,g=0;return e.forEach(function(e){i=e[0]>>u,n=e[1]>>u,o=e[2]>>u,a>i?a=i:i>s&&(s=i),h>n?h=n:n>c&&(c=n),l>o?l=o:o>g&&(g=o)}),new r(a,s,h,c,l,g,t)}function s(t,r){function n(e){var t,i,n,o,a,s=e+"1",h=e+"2",u=0;for(c=r[s];c<=r[h];c++)if(d[c]>p/2){for(n=r.copy(),o=r.copy(),t=c-r[s],i=r[h]-c,a=i>=t?Math.min(r[h]-1,~~(c+i/2)):Math.max(r[s],~~(c-1-t/2));!d[a];)a++;for(u=v[a];!u&&d[a-1];)u=v[--a];return n[h]=a,o[s]=n[h]+1,[n,o]}}if(r.count()){var o=r.r2-r.r1+1,a=r.g2-r.g1+1,s=r.b2-r.b1+1,h=i.max([o,a,s]);if(1==r.count())return[r.copy()];var c,u,l,g,f,p=0,d=[],v=[];if(h==o)for(c=r.r1;c<=r.r2;c++){for(g=0,u=r.g1;u<=r.g2;u++)for(l=r.b1;l<=r.b2;l++)f=e(c,u,l),g+=t[f]||0;p+=g,d[c]=p}else if(h==a)for(c=r.g1;c<=r.g2;c++){for(g=0,u=r.r1;u<=r.r2;u++)for(l=r.b1;l<=r.b2;l++)f=e(u,c,l),g+=t[f]||0;p+=g,d[c]=p}else for(c=r.b1;c<=r.b2;c++){for(g=0,u=r.r1;u<=r.r2;u++)for(l=r.g1;l<=r.g2;l++)f=e(u,l,c),g+=t[f]||0;p+=g,d[c]=p}return d.forEach(function(e,t){v[t]=p-e}),h==o?n("r"):h==a?n("g"):n("b")}}function h(e,r){function h(e,t){for(var i,r=1,n=0;l>n;)if(i=e.pop(),i.count()){var o=s(c,i),a=o[0],h=o[1];if(!a)return;if(e.push(a),h&&(e.push(h),r++),r>=t)return;if(n++>l)return}else e.push(i),n++}if(!e.length||2>r||r>256)return!1;var c=o(e),u=0;c.forEach(function(){u++});var f=a(e,c),p=new t(function(e,t){return i.naturalOrder(e.count(),t.count())});p.push(f),h(p,g*r);for(var d=new t(function(e,t){return i.naturalOrder(e.count()*e.volume(),t.count()*t.volume())});p.size();)d.push(p.pop());h(d,r-d.size());for(var v=new n;d.size();)v.push(d.pop());return v}var c=5,u=8-c,l=1e3,g=.75;return r.prototype={volume:function(e){var t=this;return(!t._volume||e)&&(t._volume=(t.r2-t.r1+1)*(t.g2-t.g1+1)*(t.b2-t.b1+1)),t._volume},count:function(t){var i=this,r=i.histo;if(!i._count_set||t){var n,o,a,s=0;for(n=i.r1;n<=i.r2;n++)for(o=i.g1;o<=i.g2;o++)for(a=i.b1;a<=i.b2;a++)index=e(n,o,a),s+=r[index]||0;i._count=s,i._count_set=!0}return i._count},copy:function(){var e=this;return new r(e.r1,e.r2,e.g1,e.g2,e.b1,e.b2,e.histo)},avg:function(t){var i=this,r=i.histo;if(!i._avg||t){var n,o,a,s,h,u=0,l=1<<8-c,g=0,f=0,p=0;for(o=i.r1;o<=i.r2;o++)for(a=i.g1;a<=i.g2;a++)for(s=i.b1;s<=i.b2;s++)h=e(o,a,s),n=r[h]||0,u+=n,g+=n*(o+.5)*l,f+=n*(a+.5)*l,p+=n*(s+.5)*l;i._avg=u?[~~(g/u),~~(f/u),~~(p/u)]:[~~(l*(i.r1+i.r2+1)/2),~~(l*(i.g1+i.g2+1)/2),~~(l*(i.b1+i.b2+1)/2)]}return i._avg},contains:function(e){var t=this,i=e[0]>>u;return gval=e[1]>>u,bval=e[2]>>u,i>=t.r1&&i<=t.r2&&gval>=t.g1&&gval<=t.g2&&bval>=t.b1&&bval<=t.b2}},n.prototype={push:function(e){this.vboxes.push({vbox:e,color:e.avg()})},palette:function(){return this.vboxes.map(function(e){return e.color})},size:function(){return this.vboxes.size()},map:function(e){for(var t=this.vboxes,i=0;i<t.size();i++)if(t.peek(i).vbox.contains(e))return t.peek(i).color;return this.nearest(e)},nearest:function(e){for(var t,i,r,n=this.vboxes,o=0;o<n.size();o++)i=Math.sqrt(Math.pow(e[0]-n.peek(o).color[0],2)+Math.pow(e[1]-n.peek(o).color[1],2)+Math.pow(e[2]-n.peek(o).color[2],2)),(t>i||void 0===t)&&(t=i,r=n.peek(o).color);return r},forcebw:function(){var e=this.vboxes;e.sort(function(e,t){return i.naturalOrder(i.sum(e.color),i.sum(t.color))});var t=e[0].color;t[0]<5&&t[1]<5&&t[2]<5&&(e[0].color=[0,0,0]);var r=e.length-1,n=e[r].color;n[0]>251&&n[1]>251&&n[2]>251&&(e[r].color=[255,255,255])}},{quantize:h}}();"function"==typeof define&&define.amd?define([],function(){return t}):"object"==typeof exports?module.exports=t:this.ColorThief=t}.call(this)}(),function(){function e(e){return!!e.exifdata}function t(e,t){t=t||e.match(/^data\:([^\;]+)\;base64,/im)[1]||"",e=e.replace(/^data\:([^\;]+)\;base64,/gim,"");for(var i=atob(e),r=i.length,n=new ArrayBuffer(r),o=new Uint8Array(n),a=0;r>a;a++)o[a]=i.charCodeAt(a);return n}function i(e,t){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="blob",i.onload=function(){(200==this.status||0===this.status)&&t(this.response)},i.send()}function r(e,r){function n(t){var i=o(t),n=a(t);e.exifdata=i||{},e.iptcdata=n||{},r&&r.call(e)}if(e.src)if(/^data\:/i.test(e.src)){var s=t(e.src);n(s)}else if(/^blob\:/i.test(e.src)){var h=new FileReader;h.onload=function(e){n(e.target.result)},i(e.src,function(e){h.readAsArrayBuffer(e)})}else{var c=new XMLHttpRequest;c.onload=function(){if(200!=this.status&&0!==this.status)throw"Could not load image";n(c.response),c=null},c.open("GET",e.src,!0),c.responseType="arraybuffer",c.send(null)}else if(window.FileReader&&(e instanceof window.Blob||e instanceof window.File)){var h=new FileReader;h.onload=function(e){g&&console.log("Got file of length "+e.target.result.byteLength),n(e.target.result)},h.readAsArrayBuffer(e)}}function o(e){var t=new DataView(e);if(g&&console.log("Got file of length "+e.byteLength),255!=t.getUint8(0)||216!=t.getUint8(1))return g&&console.log("Not a valid JPEG"),!1;for(var i,r=2,n=e.byteLength;n>r;){if(255!=t.getUint8(r))return g&&console.log("Not a valid marker at offset "+r+", found: "+t.getUint8(r)),!1;if(i=t.getUint8(r+1),g&&console.log(i),225==i)return g&&console.log("Found 0xFFE1 marker"),l(t,r+4,t.getUint16(r+2)-2);r+=2+t.getUint16(r+2)}}function a(e){var t=new DataView(e);if(g&&console.log("Got file of length "+e.byteLength),255!=t.getUint8(0)||216!=t.getUint8(1))return g&&console.log("Not a valid JPEG"),!1;for(var i=2,r=e.byteLength,n=function(e,t){return 56===e.getUint8(t)&&66===e.getUint8(t+1)&&73===e.getUint8(t+2)&&77===e.getUint8(t+3)&&4===e.getUint8(t+4)&&4
2===e.getUint8(t+5)};r>i;){if(n(t,i)){var o=t.getUint8(i+7);o%2!==0&&(o+=1),0===o&&(o=4);var a=i+8+o,h=t.getUint16(i+6+o);return s(e,a,h)}i++}}function s(e,t,i){for(var r,n,o,a,s,h=new DataView(e),c={},l=t;t+i>l;)28===h.getUint8(l)&&2===h.getUint8(l+1)&&(a=h.getUint8(l+2),a in y&&(o=h.getInt16(l+3),s=o+5,n=y[a],r=u(h,l+5,o),c.hasOwnProperty(n)?c[n]instanceof Array?c[n].push(r):c[n]=[c[n],r]:c[n]=r)),l++;return c}function h(e,t,i,r,n){var o,a,s,h=e.getUint16(i,!n),u={};for(s=0;h>s;s++)o=i+12*s+2,a=r[e.getUint16(o,!n)],!a&&g&&console.log("Unknown tag: "+e.getUint16(o,!n)),u[a]=c(e,o,t,i,n);return u}function c(e,t,i,r,n){var o,a,s,h,c,l,g=e.getUint16(t+2,!n),f=e.getUint32(t+4,!n),p=e.getUint32(t+8,!n)+i;switch(g){case 1:case 7:if(1==f)return e.getUint8(t+8,!n);for(o=f>4?p:t+8,a=[],h=0;f>h;h++)a[h]=e.getUint8(o+h);return a;case 2:return o=f>4?p:t+8,u(e,o,f-1);case 3:if(1==f)return e.getUint16(t+8,!n);for(o=f>2?p:t+8,a=[],h=0;f>h;h++)a[h]=e.getUint16(o+2*h,!n);return a;case 4:if(1==f)return e.getUint32(t+8,!n);for(a=[],h=0;f>h;h++)a[h]=e.getUint32(p+4*h,!n);return a;case 5:if(1==f)return c=e.getUint32(p,!n),l=e.getUint32(p+4,!n),s=new Number(c/l),s.numerator=c,s.denominator=l,s;for(a=[],h=0;f>h;h++)c=e.getUint32(p+8*h,!n),l=e.getUint32(p+4+8*h,!n),a[h]=new Number(c/l),a[h].numerator=c,a[h].denominator=l;return a;case 9:if(1==f)return e.getInt32(t+8,!n);for(a=[],h=0;f>h;h++)a[h]=e.getInt32(p+4*h,!n);return a;case 10:if(1==f)return e.getInt32(p,!n)/e.getInt32(p+4,!n);for(a=[],h=0;f>h;h++)a[h]=e.getInt32(p+8*h,!n)/e.getInt32(p+4+8*h,!n);return a}}function u(e,t,i){var r="";for(n=t;t+i>n;n++)r+=String.fromCharCode(e.getUint8(n));return r}function l(e,t){if("Exif"!=u(e,t,4))return g&&console.log("Not valid EXIF data! "+u(e,t,4)),!1;var i,r,n,o,a,s=t+6;if(18761==e.getUint16(s))i=!1;else{if(19789!=e.getUint16(s))return g&&console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"),!1;i=!0}if(42!=e.getUint16(s+2,!i))return g&&console.log("Not valid TIFF data! (no 0x002A)"),!1;var c=e.getUint32(s+4,!i);if(8>c)return g&&console.log("Not valid TIFF data! (First offset less than 8)",e.getUint32(s+4,!i)),!1;if(r=h(e,s,s+c,v,i),r.ExifIFDPointer){o=h(e,s,s+r.ExifIFDPointer,d,i);for(n in o){switch(n){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":o[n]=w[n][o[n]];break;case"ExifVersion":case"FlashpixVersion":o[n]=String.fromCharCode(o[n][0],o[n][1],o[n][2],o[n][3]);break;case"ComponentsConfiguration":o[n]=w.Components[o[n][0]]+w.Components[o[n][1]]+w.Components[o[n][2]]+w.Components[o[n][3]]}r[n]=o[n]}}if(r.GPSInfoIFDPointer){a=h(e,s,s+r.GPSInfoIFDPointer,m,i);for(n in a){switch(n){case"GPSVersionID":a[n]=a[n][0]+"."+a[n][1]+"."+a[n][2]+"."+a[n][3]}r[n]=a[n]}}return r}var g=!1,f=this,p=function(e){return e instanceof p?e:this instanceof p?(this.EXIFwrapped=e,void 0):new p(e)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=p),exports.EXIF=p):f.EXIF=p;var d=p.Tags={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"E
2xposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},v=p.TiffTags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},m=p.GPSTags={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},w=p.StringValues={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}},y={120:"caption",110:"credit",25:"keywords",55:"dateCreated",80:"byline",85:"bylineTitle",122:"captionWriter",105:"headline",116:"copyright",15:"category"};p.getData=function(t,i){return(t instanceof Image||t instanceof HTMLImageElement)&&!t.complete?!1:(e(t)?i&&i.call(t):r(t,i),!0)},p.getTag=function(t,i){return e(t)?t.exifdata[i]:void 0},p.getAllTags=function(t){if(!e(t))return{};var i,r=t.exifdata,n={};for(i in r)r.hasOwnProperty(i)&&(n[i]=r[i]);return n},p.pretty=function(t){if(!e(t))return"";var i,r=t.exifdata,n="";for(i in r)r.hasOwnProperty(i)&&(n+="object"==typeof r[i]?r[i]instanceof Number?i+" : "+r[i]+" ["+r[i].numerator+"/"+r[i].denominator+"]\r\n":i+" : ["+r[i].length+" values]\r\n":i+" : "+r[i]+"\r\n");return n},p.readFromBinaryFile=function(e){return o(e)},"function"==typeof define&&define.amd&&define("exif-js",[],function(){return p})}
2.call(this),function(){function e(e){var t=e.naturalWidth,i=e.naturalHeight;if(t*i>1048576){var r=document.createElement("canvas");r.width=r.height=1;var n=r.getContext("2d");return n.drawImage(e,-t+1,0),0===n.getImageData(0,0,1,1).data[3]}return!1}function t(e,t,i){var r=document.createElement("canvas");r.width=1,r.height=i;var n=r.getContext("2d");n.drawImage(e,0,0);for(var o=n.getImageData(0,0,1,i).data,a=0,s=i,h=i;h>a;){var c=o[4*(h-1)+3];0===c?s=h:a=h,h=s+a>>1}var u=h/i;return 0===u?1:u}function i(e,t,i){var n=document.createElement("canvas");return r(e,n,t,i),n.toDataURL("image/jpeg",t.quality||.8)}function r(i,r,o,a){var s=i.naturalWidth,h=i.naturalHeight;if(s+h){var c=o.width,u=o.height,l=r.getContext("2d");l.save(),n(r,l,c,u,o.orientation);var g=e(i);g&&(s/=2,h/=2);var f=1024,p=document.createElement("canvas");p.width=p.height=f;for(var d=p.getContext("2d"),v=a?t(i,s,h):1,m=Math.ceil(f*c/s),w=Math.ceil(f*u/h/v),y=0,S=0;h>y;){for(var _=0,C=0;s>_;)d.clearRect(0,0,f,f),d.drawImage(i,-_,-y),l.drawImage(p,0,0,f,f,C,S,m,w),_+=f,C+=m;y+=f,S+=w}l.restore(),p=d=null}}function n(e,t,i,r,n){switch(n){case 5:case 6:case 7:case 8:e.width=r,e.height=i;break;default:e.width=i,e.height=r}switch(n){case 2:t.translate(i,0),t.scale(-1,1);break;case 3:t.translate(i,r),t.rotate(Math.PI);break;case 4:t.translate(0,r),t.scale(1,-1);break;case 5:t.rotate(.5*Math.PI),t.scale(1,-1);break;
3case 6:t.rotate(.5*Math.PI),t.translate(0,-r);break;case 7:t.rotate(.5*Math.PI),t.translate(i,-r),t.scale(-1,1);break;case 8:t.rotate(-.5*Math.PI),t.translate(-i,0)}}function o(e){if(window.Blob&&e instanceof Blob){if(!a)throw Error("No createObjectURL function found to create blob url");var t=new Image;t.src=a.createObjectURL(e),this.blob=e,e=t}if(!e.naturalWidth&&!e.naturalHeight){var i=this;e.onload=e.onerror=function(){var e=i.imageLoadListeners;if(e){i.imageLoadListeners=null;for(var t=0,r=e.length;r>t;t++)e[t]()}},this.imageLoadListeners=[]}this.srcImage=e}var a=window.URL&&window.URL.createObjectURL?window.URL:window.webkitURL&&window.webkitURL.createObjectURL?window.webkitURL:null;o.prototype.render=function(e,t,n){if(this.imageLoadListeners){var o=this;return this.imageLoadListeners.push(function(){o.render(e,t,n)}),void 0}t=t||{};var s=this.srcImage.naturalWidth,h=this.srcImage.naturalHeight,c=t.width,u=t.height,l=t.maxWidth,g=t.maxHeight,f=!this.blob||"image/jpeg"===this.blob.type;c&&!u?u=h*c/s<<0:u&&!c?c=s*u/h<<0:(c=s,u=h),l&&c>l&&(c=l,u=h*c/s<<0),g&&u>g&&(u=g,c=s*u/h<<0);var p={width:c,height:u};for(var d in t)p[d]=t[d];var v=e.tagName.toLowerCase();"img"===v?e.src=i(this.srcImage,p,f):"canvas"===v&&r(this.srcImage,e,p,f),"function"==typeof this.onrender&&this.onrender(e),n&&n(),this.blob&&(this.blob=null,a.revokeObjectURL(this.srcImage.src))},"function"==typeof define&&define.amd?define([],function(){return o}):"object"==typeof exports?module.exports=o:this.MegaPixImage=o}(),function(){var e=function(e){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),document.body.appendChild(this.canvas),this.width=this.canvas.width=e.width,this.height=this.canvas.height=e.height,this.context.drawImage(e,0,0,this.width,this.height)};e.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},e.prototype.update=function(e){this.context.putImageData(e,0,0)},e.prototype.getPixelCount=function(){return this.width*this.height},e.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)},e.prototype.removeCanvas=function(){this.canvas.parentNode.removeChild(this.canvas)};var t=function(){};if(t.prototype.getColor=function(e,t){var i=this.getPalette(e,5,t),r=i[0];return r},t.prototype.getPalette=function(t,i,n){"undefined"==typeof i&&(i=10),("undefined"==typeof n||1>n)&&(n=10);for(var o,a,s,h,c,u=new e(t),l=u.getImageData(),g=l.data,f=u.getPixelCount(),p=[],d=0;f>d;d+=n)o=4*d,a=g[o+0],s=g[o+1],h=g[o+2],c=g[o+3],c>=125&&(a>250&&s>250&&h>250||p.push([a,s,h]));var v=r.quantize(p,i),m=v?v.palette():null;return u.removeCanvas(),m},!i)var i={map:function(e,t){var i={};return t?e.map(function(e,r){return i.index=r,t.call(i,e)}):e.slice()},naturalOrder:function(e,t){return t>e?-1:e>t?1:0},sum:function(e,t){var i={};return e.reduce(t?function(e,r,n){return i.index=n,e+t.call(i,r)}:function(e,t){return e+t},0)},max:function(e,t){return Math.max.apply(null,t?i.map(e,t):e)}};var r=function(){function e(e,t,i){return(e<<2*c)+(t<<c)+i}function t(e){function t(){i.sort(e),r=!0}var i=[],r=!1;return{push:function(e){i.push(e),r=!1},peek:function(e){return r||t(),void 0===e&&(e=i.length-1),i[e]},pop:function(){return r||t(),i.pop()},size:function(){return i.length},map:function(e){return i.map(e)},debug:function(){return r||t(),i}}}function r(e,t,i,r,n,o,a){var s=this;s.r1=e,s.r2=t,s.g1=i,s.g2=r,s.b1=n,s.b2=o,s.histo=a}function n(){this.vboxes=new t(function(e,t){return i.naturalOrder(e.vbox.count()*e.vbox.volume(),t.vbox.count()*t.vbox.volume())})}function o(t){var i,r,n,o,a=1<<3*c,s=new Array(a);return t.forEach(function(t){r=t[0]>>u,n=t[1]>>u,o=t[2]>>u,i=e(r,n,o),s[i]=(s[i]||0)+1}),s}function a(e,t){var i,n,o,a=1e6,s=0,h=1e6,c=0,l=1e6,g=0;return e.forEach(function(e){i=e[0]>>u,n=e[1]>>u,o=e[2]>>u,a>i?a=i:i>s&&(s=i),h>n?h=n:n>c&&(c=n),l>o?l=o:o>g&&(g=o)}),new r(a,s,h,c,l,g,t)}function s(t,r){function n(e){var t,i,n,o,a,s=e+"1",h=e+"2",u=0;for(c=r[s];c<=r[h];c++)if(d[c]>p/2){for(n=r.copy(),o=r.copy(),t=c-r[s],i=r[h]-c,a=i>
3=t?Math.min(r[h]-1,~~(c+i/2)):Math.max(r[s],~~(c-1-t/2));!d[a];)a++;for(u=v[a];!u&&d[a-1];)u=v[--a];return n[h]=a,o[s]=n[h]+1,[n,o]}}if(r.count()){var o=r.r2-r.r1+1,a=r.g2-r.g1+1,s=r.b2-r.b1+1,h=i.max([o,a,s]);if(1==r.count())return[r.copy()];var c,u,l,g,f,p=0,d=[],v=[];if(h==o)for(c=r.r1;c<=r.r2;c++){for(g=0,u=r.g1;u<=r.g2;u++)for(l=r.b1;l<=r.b2;l++)f=e(c,u,l),g+=t[f]||0;p+=g,d[c]=p}else if(h==a)for(c=r.g1;c<=r.g2;c++){for(g=0,u=r.r1;u<=r.r2;u++)for(l=r.b1;l<=r.b2;l++)f=e(u,c,l),g+=t[f]||0;p+=g,d[c]=p}else for(c=r.b1;c<=r.b2;c++){for(g=0,u=r.r1;u<=r.r2;u++)for(l=r.g1;l<=r.g2;l++)f=e(u,l,c),g+=t[f]||0;p+=g,d[c]=p}return d.forEach(function(e,t){v[t]=p-e}),h==o?n("r"):h==a?n("g"):n("b")}}function h(e,r){function h(e,t){for(var i,r=1,n=0;l>n;)if(i=e.pop(),i.count()){var o=s(c,i),a=o[0],h=o[1];if(!a)return;if(e.push(a),h&&(e.push(h),r++),r>=t)return;if(n++>l)return}else e.push(i),n++}if(!e.length||2>r||r>256)return!1;var c=o(e),u=0;c.forEach(function(){u++});var f=a(e,c),p=new t(function(e,t){return i.naturalOrder(e.count(),t.count())});p.push(f),h(p,g*r);for(var d=new t(function(e,t){return i.naturalOrder(e.count()*e.volume(),t.count()*t.volume())});p.size();)d.push(p.pop());h(d,r-d.size());for(var v=new n;d.size();)v.push(d.pop());return v}var c=5,u=8-c,l=1e3,g=.75;return r.prototype={volume:function(e){var t=this;return(!t._volume||e)&&(t._volume=(t.r2-t.r1+1)*(t.g2-t.g1+1)*(t.b2-t.b1+1)),t._volume},count:function(t){var i=this,r=i.histo;if(!i._count_set||t){var n,o,a,s=0;for(n=i.r1;n<=i.r2;n++)for(o=i.g1;o<=i.g2;o++)for(a=i.b1;a<=i.b2;a++)index=e(n,o,a),s+=r[index]||0;i._count=s,i._count_set=!0}return i._count},copy:function(){var e=this;return new r(e.r1,e.r2,e.g1,e.g2,e.b1,e.b2,e.histo)},avg:function(t){var i=this,r=i.histo;if(!i._avg||t){var n,o,a,s,h,u=0,l=1<<8-c,g=0,f=0,p=0;for(o=i.r1;o<=i.r2;o++)for(a=i.g1;a<=i.g2;a++)for(s=i.b1;s<=i.b2;s++)h=e(o,a,s),n=r[h]||0,u+=n,g+=n*(o+.5)*l,f+=n*(a+.5)*l,p+=n*(s+.5)*l;i._avg=u?[~~(g/u),~~(f/u),~~(p/u)]:[~~(l*(i.r1+i.r2+1)/2),~~(l*(i.g1+i.g2+1)/2),~~(l*(i.b1+i.b2+1)/2)]}return i._avg},contains:function(e){var t=this,i=e[0]>>u;return gval=e[1]>>u,bval=e[2]>>u,i>=t.r1&&i<=t.r2&&gval>=t.g1&&gval<=t.g2&&bval>=t.b1&&bval<=t.b2}},n.prototype={push:function(e){this.vboxes.push({vbox:e,color:e.avg()})},palette:function(){return this.vboxes.map(function(e){return e.color})},size:function(){return this.vboxes.size()},map:function(e){for(var t=this.vboxes,i=0;i<t.size();i++)if(t.peek(i).vbox.contains(e))return t.peek(i).color;return this.nearest(e)},nearest:function(e){for(var t,i,r,n=this.vboxes,o=0;o<n.size();o++)i=Math.sqrt(Math.pow(e[0]-n.peek(o).color[0],2)+Math.pow(e[1]-n.peek(o).color[1],2)+Math.pow(e[2]-n.peek(o).color[2],2)),(t>i||void 0===t)&&(t=i,r=n.peek(o).color);return r},forcebw:function(){var e=this.vboxes;e.sort(function(e,t){return i.naturalOrder(i.sum(e.color),i.sum(t.color))});var t=e[0].color;t[0]<5&&t[1]<5&&t[2]<5&&(e[0].color=[0,0,0]);var r=e.length-1,n=e[r].color;n[0]>251&&n[1]>251&&n[2]>251&&(e[r].color=[255,255,255])}},{quantize:h}}();"function"==typeof define&&define.amd?define([],function(){return t}):"object"==typeof exports?module.exports=t:this.ColorThief=t}.call(this);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.