/* eslint-disable */ /*! * Doka 4.7.2 * Copyright 2019 PQINA Inc - All Rights Reserved * Please visit https://pqina.nl/doka/ for further information */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Doka=e():t.Doka=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/dist",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var r=function(t,e){return e.parentNode.insertBefore(t,e)},i=function(t,e){return e.parentNode.insertBefore(t,e.nextSibling)};function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var a=function(t){return"object"===o(t)&&null!==t};function c(t){for(var e=1;e2&&void 0!==arguments[2]?arguments[2]:null;if(null===n)return t.getAttribute(e)||t.hasAttribute(e);t.setAttribute(e,n)};function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var d=["svg","path"],p=function(t){return d.includes(t)},m=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};"object"===h(e)&&(n=e,e=null);var r=p(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t);return e&&(p(t)?f(r,"class",e):r.className=e),l(n,function(t,e){f(r,t,e)}),r},g=function(t,e){return function(t,n){return void 0!==n?e.splice(n,0,t):e.push(t),t}},y=function(t,e){return function(n){return e.splice(e.indexOf(n),1),n.element.parentNode&&t.removeChild(n.element),n}};function v(t){for(var e=1;et.bottom&&(t.bottom=e.bottom),e.right>t.right&&(t.right=e.right)},b=function(t){t.width=t.right-t.left,t.height=t.bottom-t.top},O=function(t){return"number"==typeof t},T=function(t){return t<.5?2*t*t:(4-2*t)*t-1};function R(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x(t){return(x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var I={spring:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.stiffness,n=void 0===e?.5:e,r=t.damping,i=void 0===r?.75:r,o=t.mass,a=void 0===o?10:o,c=t.delay,u=void 0===c?0:c,l=null,f=null,h=0,d=!1,p=null,m=s({interpolate:function(t){if(null===p&&(p=t),!(t-u3&&void 0!==arguments[3]?arguments[3]:.001;return Math.abs(t-e)0&&void 0!==arguments[0]?arguments[0]:{},r=n.duration,i=void 0===r?500:r,o=n.easing,a=void 0===o?T:o,c=n.delay,u=void 0===c?0:c,l=null,f=!0,h=!1,d=null,p=s({interpolate:function(n){f||null===d||(null===l&&(l=n),n-l=0?a(h?1-e:e):0)*d)):(t=1,e=h?0:1,p.onupdate(e*d),p.oncomplete(e*d),f=!0)))},target:{get:function(){return h?0:d},set:function(t){if(null===d)return d=t,p.onupdate(t),void p.oncomplete(t);t3&&void 0!==arguments[3]&&arguments[3];(e=Array.isArray(e)?e:[e]).forEach(function(e){t.forEach(function(t){var i=t,o=function(){return n[t]},a=function(e){return n[t]=e};"object"===C(t)&&(i=t.key,o=t.getter||o,a=t.setter||a),e[i]&&!r||(e[i]={get:o,set:a})})})};function S(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var P=function(t){return null!=t};function L(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.layoutCalculated||(t.paddingTop=parseInt(n.paddingTop,10)||0,t.marginTop=parseInt(n.marginTop,10)||0,t.marginRight=parseInt(n.marginRight,10)||0,t.marginBottom=parseInt(n.marginBottom,10)||0,t.marginLeft=parseInt(n.marginLeft,10)||0,e.layoutCalculated=!0),t.left=e.offsetLeft||0,t.top=e.offsetTop||0,t.width=e.offsetWidth||0,t.height=e.offsetHeight||0,t.right=t.left+t.width,t.bottom=t.top+t.height,t.scrollTop=e.scrollTop,t.hidden=null===e.offsetParent&&"fixed"!==n.position,t};function j(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{},e=t.tag,n=void 0===e?"div":e,r=t.name,i=void 0===r?null:r,o=t.attributes,a=void 0===o?{}:o,c=t.read,u=void 0===c?function(){}:c,l=t.write,f=void 0===l?function(){}:l,h=t.create,d=void 0===h?function(){}:h,p=t.destroy,v=void 0===p?function(){}:p,E=t.filterFrameActionsForChild,_=void 0===E?function(t,e){return e}:E,b=t.didCreateView,O=void 0===b?function(){}:b,T=t.didWriteView,R=void 0===T?function(){}:T,x=t.ignoreRect,I=void 0!==x&&x,A=t.ignoreRectUpdate,C=void 0!==A&&A,M=t.mixins,S=void 0===M?[]:M;return function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=m(n,i?"doka--".concat(i):null,a),c=window.getComputedStyle(o,null),l=k(),h=null,p=!1,E=[],b=[],T={},x={},A=[f],M=[u],P=[v],L=function(){return o},G=function(){return[].concat(E)},D=function(){return h||(h=w(l,E,[0,0],[1,1]))},V=function(){return o.layoutCalculated=!1},U={element:{get:L},style:{get:function(){return c}},childViews:{get:G}},z=j({},U,{rect:{get:D},ref:{get:function(){return T}},is:function(t){return i===t},appendChild:(e=o,function(t,n){void 0!==n&&e.children[n]?e.insertBefore(t,e.children[n]):e.appendChild(t)}),createChildView:function(t){return function(e,n){return e(t,n)}}(t),linkView:function(t){return E.push(t),t},unlinkView:function(t){E.splice(E.indexOf(t),1)},appendChildView:g(0,E),removeChildView:y(o,E),registerWriter:function(t){return A.push(t)},registerReader:function(t){return M.push(t)},registerDestroyer:function(t){return P.push(t)},invalidateLayout:V,dispatch:t.dispatch,query:t.query}),B={element:{get:L},childViews:{get:G},rect:{get:D},resting:{get:function(){return p}},isRectIgnored:function(){return I},invalidateLayout:V,_read:function(){h=null,E.forEach(function(t){return t._read()}),!(C&&l.width&&l.height)&&k(l,o,c);var t={root:F,props:r,rect:l};M.forEach(function(e){return e(t)})},_write:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=0===e.length;return A.forEach(function(i){!1===i({props:r,root:F,actions:e,timestamp:t})&&(n=!1)}),b.forEach(function(e){!1===e.write(t)&&(n=!1)}),E.filter(function(t){return!!t.element.parentNode}).forEach(function(r){r._write(t,_(r,e))||(n=!1)}),E.forEach(function(r,i){r.element.parentNode||(F.appendChild(r.element,i),r._read(),r._write(t,_(r,e)),n=!1)}),p=n,R({props:r,root:F,actions:e,timestamp:t}),n},_destroy:function(){b.forEach(function(t){return t.destroy()}),P.forEach(function(t){t({root:F})}),E.forEach(function(t){return t._destroy()})}},Y=j({},U,{rect:{get:function(){return l}}});Object.keys(S).sort(function(t,e){return"styles"===t?1:"styles"===e?-1:0}).forEach(function(t){var e=N[t]({mixinConfig:S[t],viewProps:r,viewState:x,viewInternalAPI:z,viewExternalAPI:B,view:s(Y)});e&&b.push(e)});var F=s(z);d({root:F,props:r});var q=(o.children||[]).length;return E.forEach(function(t,e){F.appendChild(t.element,q+e)}),O(F),s(B)}},Y=function(t,e){return function(n){var r=n.root,i=n.props,o=n.actions,a=void 0===o?[]:o,c=n.timestamp;a.filter(function(e){return t[e.type]}).forEach(function(e){return t[e.type]({root:r,props:i,action:e.data,timestamp:c})}),e&&e({root:r,props:i,actions:a,timestamp:c})}},F=function(t){return Array.isArray(t)},q=function(t){return null==t},W=function(t){return t.trim()},X=function(t){return""+t},Z=function(t){return"boolean"==typeof t},H=function(t){return"string"==typeof t},K=function(t){return O(t)?t:H(t)?X(t).replace(/[a-z]+/gi,""):0},Q=function(t){return parseInt(K(t),10)},J=function(t){return O(t)&&isFinite(t)&&Math.floor(t)===t},$=function(t){if(J(t))return t;var e=X(t).trim();return/MB$/i.test(e)?(e=e.replace(/MB$i/,"").trim(),1e3*Q(e)*1e3):/KB/i.test(e)?(e=e.replace(/KB$i/,"").trim(),1e3*Q(e)):Q(e)};function tt(t){return(tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var et=function(t){return F(t)?"array":function(t){return null===t}(t)?"null":J(t)?"int":/^[0-9]+ ?(?:GB|MB|KB)$/gi.test(t)?"bytes":tt(t)},nt={array:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return q(t)?[]:F(t)?t:X(t).split(e).map(W).filter(function(t){return t.length})},boolean:function(t){return Z(t)?t:"true"===t},int:function(t){return"bytes"===et(t)?$(t):Q(t)},float:function(t){return parseFloat(K(t))},bytes:$,string:function(t){return function(t){return"function"==typeof t}(t)?t:X(t)},object:function(t){try{return JSON.parse(t.replace(/{\s*'/g,'{"').replace(/'\s*}/g,'"}').replace(/'\s*:/g,'":').replace(/:\s*'/g,':"').replace(/,\s*'/g,',"').replace(/'\s*,/g,'",'))}catch(e){return t}},file:function(t){return t},function:function(t){return function(t){for(var e=self,n=t.split("."),r=null;r=n.shift();)if(!(e=e[r]))return null;return e}(t)}},rt=function(t,e,n){if(t===e)return t;var r,i=et(t);if(i!==n){var o=(r=t,nt[n](r));if(i=et(o),null===o)throw'Trying to assign value with incorrect type to "'.concat(option,'", allowed type: "').concat(n,'"');t=o}return t},it=function(t){var e={};return l(t,function(n){var r,i,o,a=H(t[n])?t[n]:n,c=t[a];a===n?e[n]=(r=c[0],i=c[1],o=r,{enumerable:!0,get:function(){return o},set:function(t){o=rt(t,r,i)}}):e[n]=e[a]}),s(e)},ot=function(t){t.file=null,t.activeView=null,t.rootRect={x:0,y:0,left:0,top:0,width:0,height:0},t.stage=null,t.stageOffset=null,t.image=null,t.zoomTimeoutId=null,t.instantUpdate=!1,t.filePromise=null,t.fileLoader=null,t.instructions={size:null,crop:null,filter:null,color:null},t.filter=null,t.filterName=null,t.filterValue=null,t.colorValues={},t.colorMatrices={},t.size={width:!1,height:!1,aspectRatioLocked:!0,aspectRatioPrevious:!1},t.crop={rectangle:null,transforms:null,rotation:null,flip:null,aspectRatio:null,isRotating:!1,isDirty:!1,draft:{rectangle:null,transforms:null}}},at=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return t.split(/(?=[A-Z])/).map(function(t){return t.toLowerCase()}).join(e)},ct=function(t,e){t!==e&&console.warn("'".concat(t,"' is deprecated, please use '").concat(e,"' instead."))},ut=function(t){return function(e,n,r){var i={};return l(t,function(t){var n=at(t,"_").toUpperCase();i["SET_".concat(n)]=function(i){var o;try{o=r.options[t],r.options[t]=i.value}catch(t){}e("DID_SET_".concat(n),{value:r.options[t],prevValue:o})}}),i}},lt=function(t){return function(e){var n={};return l(t,function(t){n["GET_".concat(at(t,"_").toUpperCase())]=function(n){return e.options[t]}}),n}},st=function(){return Math.random().toString(36).substr(2,9)},ft=function(){var t=[],e=function(e,n){var r,i;r=t,i=t.findIndex(function(t){return t.event===e&&(t.cb===n||!n)}),r.splice(i,1)};return{fire:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Math.min(n,Math.max(e,t))},bt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;return parseFloat(t.toFixed(e))},Ot=function(t,e){return{x:bt(t.x,e),y:bt(t.y,e)}},Tt=function(t,e){return At(t.x-e.x,t.y-e.y)},Rt=function(t,e){return Math.sqrt(function(t,e){return function(t,e){return t.x*e.x+t.y*e.y}(Tt(t,e),Tt(t,e))}(t,e))},xt=function(t,e){return At(_t(t.x,e.x,e.x+e.width),_t(t.y,e.y,e.y+e.height))},It=function(t,e,n){var r=Math.cos(e),i=Math.sin(e),o=At(t.x-n.x,t.y-n.y);return At(n.x+r*o.x-i*o.y,n.y+i*o.x+r*o.y)},At=function(){return{x:arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,y:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0}},Ct=function(t,e,n){return Ut(e*(t.x-n.x)+n.x,e*(t.y-n.y)+n.y,e*t.width,e*t.height)},Mt=function(t,e){return Ut(t.x+e.x,t.y+e.y,t.width,t.height)},St={translate:Mt,rotate:function(t,e,n){var r=function(t,e,n){return 0===e?{tl:t.tl,tr:t.tr,br:t.br,bl:t.bl}:{tl:It(t.tl,e,n),tr:It(t.tr,e,n),br:It(t.br,e,n),bl:It(t.bl,e,n)}}(Vt(t),e,n),i=r.tl,o=r.tr,a=r.br,c=r.bl,u=Math.min(i.x,o.x,a.x,c.x),l=Math.min(i.y,o.y,a.y,c.y),s=Math.max(i.x,o.x,a.x,c.x),f=Math.max(i.y,o.y,a.y,c.y);return Ut(u,l,s-u,f-l)},scale:Ct},Pt=function(t){return Ut(t.x,t.y,t.width,t.height)},Lt=function(t){return{top:t.y,right:t.x+t.width,bottom:t.y+t.height,left:t.x}},Gt=function(t){var e=t.top,n=t.right,r=t.bottom,i=t.left;return{x:i,y:e,width:n-i,height:r-e}},Dt=function(t){return At(t.x+.5*t.width,t.y+.5*t.height)},Vt=function(t){return{tl:{x:t.x,y:t.y},tr:{x:t.x+t.width,y:t.y},br:{x:t.x+t.width,y:t.y+t.height},bl:{x:t.x,y:t.y+t.height}}},Ut=function(t,e,n,r){return{x:t,y:e,width:n,height:r}},Nt=function(t){if(q(t))return t;if(/:/.test(t)){var e=t.split(":"),n=e[0];return e[1]/n}return parseFloat(t)},kt=function(t,e){var n=t.width,r=n*e;return r>t.height&&(n=(r=t.height)/e),{x:.5*(t.width-n),y:.5*(t.height-r),width:n,height:r}},jt=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=t.height/t.width,i=e,o=1,a=r;a>i&&(o=(a=i)/r);var c=Math.max(1/o,i/a),u=t.width/(n*c*o);return{width:u,height:u*e}},zt=function(t,e){return{x:t,y:e}},Bt=function(t,e){return zt(t.x-e.x,t.y-e.y)},Yt=function(t,e){return Math.sqrt(function(t,e){return function(t,e){return t.x*e.x+t.y*e.y}(Bt(t,e),Bt(t,e))}(t,e))},Ft=function(t,e){var n=t,r=e,i=1.5707963267948966-e,o=Math.sin(1.5707963267948966),a=Math.sin(r),c=Math.sin(i),u=Math.cos(i),l=n/o;return zt(u*(l*a),u*(l*c))},qt=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{x:.5,y:.5},i=r.x>.5?1-r.x:r.x,o=r.y>.5?1-r.y:r.y,a=2*i*t.width,c=2*o*t.height,u=function(t,e){var n=t.width,r=t.height,i=Ft(n,e),o=Ft(r,e),a=zt(t.x+Math.abs(i.x),t.y-Math.abs(i.y)),c=zt(t.x+t.width+Math.abs(o.y),t.y+Math.abs(o.x)),u=zt(t.x-Math.abs(o.y),t.y+t.height-Math.abs(o.x));return{width:Yt(a,c),height:Yt(a,u)}}(e,n);return Math.max(u.width/a,u.height/c)},Wt=function(t,e){var n=e.origin,r=e.translation;return function(t,e,n){return e.reduce(function(t,e){return(0,St[e[0]])(t,e[1],n)},t)}(t,[["scale",e.scale],["translate",r]],n)},Xt=function(t,e){var n=t,r=e,i=1.5707963267948966-e,o=Math.sin(1.5707963267948966),a=Math.sin(r),c=Math.sin(i),u=Math.cos(i),l=n/o;return At(u*(l*a),u*(l*c))},Zt=function(t,e){var n=t.width,r=t.height,i=e%(Math.PI/2),o=Xt(n,i),a=Xt(r,i),c=Vt(t);return{tl:At(c.tl.x+Math.abs(o.x),c.tl.y-Math.abs(o.y)),tr:At(c.tr.x+Math.abs(a.y),c.tr.y+Math.abs(a.x)),br:At(c.br.x-Math.abs(o.x),c.br.y+Math.abs(o.y)),bl:At(c.bl.x-Math.abs(a.y),c.bl.y-Math.abs(a.x))}},Ht=function(t,e,n){var r=n.origin,i=n.translation,o=Wt(t,n),a={x:r.x+i.x,y:r.y+i.y},c=2*Math.PI+n.rotation%(2*Math.PI),u=Zt(e,c),l=It(u.tl,-c,a),s=It(u.tr,-c,a),f=It(u.br,-c,a),h={x:Math.min(l.x,s.x,f.x),y:Math.min(l.y,s.y,f.y),width:Math.max(l.x,s.x,f.x)-Math.min(l.x,s.x,f.x),height:Math.max(l.y,s.y,f.y)-Math.min(l.y,s.y,f.y)},d=Ut(h.x,h.y,h.width,h.height),p=Dt(d),m=e.height/e.width,g={x:(p.x-o.x)/o.width,y:(p.y-o.y)/o.height},y=g.y>.5?1-g.y:g.y,v=2*(g.x>.5?1-g.x:g.x)*o.width,E=2*y*o.height;return{center:g,zoom:Math.min(v/d.width,E/d.height),rotation:n.rotation,aspectRatio:m}};function Kt(t){for(var e=1;e4&&void 0!==arguments[4]?arguments[4]:"width",o=t.width,a=t.height;if(!o&&!a)return{width:o,height:a};if(o=o&&_t(o,e.width,n.width),a=a&&_t(a,e.height,n.height),!r)return{width:o,height:a};if(a)if(o)"width"===i?a=o/r:"height"===i?o=a*r:(a*rn.width?a=(o=n.width)/r:o/r>n.height&&(o=(a=n.height)*r));else{a=_t(a*r,e.width,n.width)/r}else o=_t(o/r,e.height,n.height)*r;return{width:o,height:a}};function ee(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},n=e.zoom,r=e.rotation,i=e.center,o=e.aspectRatio,a=jt(t,o,n),c={x:.5*a.width,y:.5*a.height},u={x:0,y:0,width:a.width,height:a.height,center:c},l=n*qt(t,kt(u,o),r,i);return{widthFloat:a.width/l,heightFloat:a.height/l,width:Math.round(a.width/l),height:Math.round(a.height/l)}},de=function(t,e){var n,r,i=Dt(e),o=Dt(t);return r=i,!(bt((n=o).x)===bt(r.x)&&bt(n.y)===bt(r.y))},pe=function(t){if(!t.stage||!t.image)return null;var e=t.crop.draft.rectangle||{free:t.crop.rectangle,limited:t.crop.rectangle},n=t.crop.draft.transforms||t.crop.transforms,r=n.origin,i=n.translation,o=n.scale,a=n.interaction,c=t.crop.rotation,u=t.crop.flip,s=!(!t.crop.draft.rectangle&&!t.crop.draft.transforms),f=s||t.instantUpdate,h=de(e.limited,t.stage),d=t.crop.isDirty||s,p=t.crop.isRotating,m={width:t.image.naturalWidth,height:t.image.naturalHeight},g=oe(t.colorMatrices),y={crop:he(m,$t(t.image,{rectangle:e.limited,transforms:{origin:r,translation:i,scale:o,rotation:c.main+c.sub},flip:u})),image:fe(t,e.limited)},v={x:0,y:0},E=0,w=0;if(f&&a){if(a.translation){var _=a.translation.x-i.x,b=a.translation.y-i.y;v.x=100*Math.sign(_)*Math.log10(1+Math.abs(_)/100),v.y=100*Math.sign(b)*Math.log10(1+Math.abs(b)/100)}if(a.scale){var O=a.scale-o;E=.25*Math.sign(O)*Math.log10(1+Math.abs(O)/.25)}if(a.rotation){var T=a.rotation-(c.main+c.sub);w=.05*Math.sign(T)*Math.log10(1+Math.abs(T)/.05)}}var R={},x=e.free,I=Lt(x),A=Lt(e.limited);return l(I,function(t){var e=I[t]-A[t];R[t]=A[t]+5*Math.sign(e)*Math.log10(1+Math.abs(e)/5)}),{canRecenter:h,canReset:d,isDraft:f,isRotating:p,cropRect:{x:R.left,y:R.top,width:R.right-R.left,height:R.bottom-R.top},origin:r,translation:i,translationBand:v,scale:o,scaleBand:E,rotation:c,rotationBand:w,flip:u,interaction:a,cropStatus:y,colorMatrix:g}},me=function(t,e){if(1165519206!==t.getUint32(e+=2,!1))return-1;var n=18761===t.getUint16(e+=6,!1);e+=t.getUint32(e+4,n);var r=t.getUint16(e,n);e+=2;for(var i=0;it.height&&(n=(r=t.height)/e);var i=.5*(t.width-n),o=.5*(t.height-r);return Ut(i,o,n,r)},we=function(t,e,n,r){var i=r.x>.5?1-r.x:r.x,o=r.y>.5?1-r.y:r.y,a=2*i*t.width,c=2*o*t.height,u=function(t,e){var n=t.width,r=t.height,i=Xt(n,e),o=Xt(r,e),a=Vt(t),c=At(a.tl.x+Math.abs(i.x),a.tl.y-Math.abs(i.y)),u=At(a.tr.x+Math.abs(o.y),a.tr.y+Math.abs(o.x)),l=At(a.bl.x-Math.abs(o.y),a.bl.y-Math.abs(o.x));return{width:Rt(c,u),height:Rt(c,l)}}(e,n);return Math.max(u.width/a,u.height/c)},_e=function(t,e,n){var r=t.center,i=t.zoom,o=t.aspectRatio,a=Dt(e),c={x:a.x-n.width*r.x,y:a.y-n.height*r.y},u=2*Math.PI+t.rotation%(2*Math.PI),l=we(n,Ee(e,o||n.height/n.width),u,r);return{origin:{x:r.x*n.width,y:r.y*n.height},translation:c,scale:i*l,rotation:t.rotation}};function be(t){for(var e=1;e=a.left&&o.top>=a.top&&o.bottom<=a.bottom&&o.right<=a.right))if("moving"===r){C.y>w.y?C.y=w.y:C.y+C.heightw.x?C.x=w.x:C.x+C.widthw.y?C.y=w.y:C.y+C.heightw.x?C.x=w.x:C.x+C.widthw.y?C.y=w.y:C.y+C.heightw.x?C.x=w.x:C.x+C.widthw.y?C.y=w.y:C.y+C.heightw.x?C.x=w.x:C.x+C.widthw.y){var k=C.y-w.y;C.y=w.y,C.height+=2*k,N=!0}if(C.y+C.heightw.x){var z=C.x-w.x;C.x=w.x,C.width+=2*z,N=!0}if(C.x+C.widthm.right||p.bottom>m.bottom||p.left=y.bottom){var O=y.bottom-y.top,T=y.right-y.left,R=Math.max(1,d.height/O),x=O*R,I=T*R-T;y.bottom=p.bottom,y.top=p.bottom-x,y.left-=.5*I,y.right+=.5*I}if(p.left<=y.left){var A=y.bottom-y.top,C=y.right-y.left,M=Math.max(1,d.width/C),S=C*M,P=A*M-A;y.right=p.left+S,y.left=p.left,y.top-=.5*P,y.bottom+=.5*P}if(p.right>=y.right){var L=y.bottom-y.top,G=y.right-y.left,D=Math.max(1,d.width/G),V=G*D,U=L*D-L;y.right=p.right,y.left=p.right-V,y.top-=.5*U,y.bottom+=.5*U}g=Ut(y.left,y.top,y.right-y.left,y.bottom-y.top)}var N=Vt(g),k=Dt(g),j=It(N.tl,o,c),z=It(N.br,o,c),B=j.x+.5*(z.x-j.x),Y=j.y+.5*(z.y-j.y),F=Mt(g,{x:B-k.x,y:Y-k.y}),q=Mt(d,{x:B-k.x,y:Y-k.y}),W=Dt(q),X={x:F.x,y:F.y},Z=F.width,H=F.height,K=(W.x-X.x)/Z,Q=(W.y-X.y)/H,J=Z/t.width,$={x:K*t.width,y:Q*t.height},tt=1-J,et=$.x*tt,nt=$.y*tt,rt={x:X.x+Z*K,y:X.y+H*Q},it=It(X,o,{x:X.x+.5*Z,y:X.y+.5*H}),ot=It(X,o,rt),at=it.x-ot.x,ct=it.y-ot.y;return{origin:$,translation:{x:X.x-et+at,y:X.y-nt+ct},scale:J,rotation:n.rotation}},Pe={nw:function(t){return{x:t.x,y:t.y}},ne:function(t){return{x:t.x+t.width,y:t.y}},se:function(t){return{x:t.x+t.width,y:t.y+t.height}},sw:function(t){return{x:t.x,y:t.y+t.height}}},Le=function(t,e){return Pe[t](e)},Ge=Math.PI/2,De=Math.PI/4,Ve=function(t){var e=bt(De),n=bt(Ge),r=t/n,i=Math.floor(r)*n,o=t-i;return o>e&&(o-=n,i+=n),{main:i,sub:o}},Ue=function(t){return new Promise(function(e,n){var r=new Image;r.src=URL.createObjectURL(t),r.onerror=function(t){clearInterval(i),n(t)};var i=setInterval(function(){r.naturalWidth&&r.naturalHeight&&(clearInterval(i),URL.revokeObjectURL(r.src),e({width:r.naturalWidth,height:r.naturalHeight}))},1)})},Ne=function(t,e){var n={width:t.width,height:t.height};if(t.width>e.width||t.height>e.height){var r=t.height/t.width,i=e.width/t.width,o=e.height/t.height;i=5&&e<=8;a?(r.width=o,r.height=i):(r.width=i,r.height=o);var c=r.getContext("2d");if(e&&c.transform.apply(c,function(t,e,n){return-1===n&&(n=1),ke[n](t,e)}(i,o,e)),je(n)){var u=[1,0,0,1,0,0];(!a&&n.horizontal||a&n.vertical)&&(u[0]=-1,u[4]=i),(!a&&n.vertical||a&&n.horizontal)&&(u[3]=-1,u[5]=o),c.transform.apply(c,u)}return c.drawImage(t,0,0,i,o),r};"undefined"!=typeof window&&void 0!==window.document&&(HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,n){var r=this.toDataURL(e,n).split(",")[1];setTimeout(function(){for(var n=atob(r),i=n.length,o=new Uint8Array(i),a=0;a1&&!1===u)return o(t,f);l=t.width*p,s=t.height*p}for(var m=t.width,g=t.height,y=Math.round(l),v=Math.round(s),E=t.data,w=new Uint8ClampedArray(y*v*4),_=m/y,b=g/v,O=Math.ceil(.5*_),T=Math.ceil(.5*b),R=0;R=-1&&B<=1&&(A=2*B*B*B-3*B*B+1)>0){var Y=E[(z=4*(j+V*m))+3];G+=A*Y,M+=A,Y<255&&(A=A*Y/250),S+=A*E[z],P+=A*E[z+1],L+=A*E[z+2],C+=A}}w[I]=S/C,w[I+1]=P/C,w[I+2]=L/C,w[I+3]=G/M,f&&n(I,w,f)}return{data:w,width:y,height:v}},filter:o},e=function(e,n){var r=e.transforms,i=null;if(r.forEach(function(t){"filter"===t.type&&(i=t)}),i){var o=null;r.forEach(function(t){"resize"===t.type&&(o=t)}),o&&(o.data.matrix=i.data,r=r.filter(function(t){return"filter"!==t.type}))}n(function(e,n){return e.forEach(function(e){n=t[e.type](n,e.data)}),n}(r,e.imageData))};function n(t,e,n){for(var r=0,i=0,o=0,a=e[t]/255,c=e[t+1]/255,u=e[t+2]/255,l=e[t+3]/255;r<4;r++)o=255*(a*n[i=5*r]+c*n[i+1]+u*n[i+2]+l*n[i+3]+n[i+4]),e[t+r]=Math.max(0,Math.min(o,255))}self.onmessage=function(t){e(t.data.message,function(e){self.postMessage({id:t.data.id,message:e},[e.data.buffer])})};var r=self.JSON.stringify([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]);function i(t){return self.JSON.stringify(t||[])===r}function o(t,e){if(!e||i(e))return t;for(var n=t.data,r=n.length,o=e[0],a=e[1],c=e[2],u=e[3],l=e[4],s=e[5],f=e[6],h=e[7],d=e[8],p=e[9],m=e[10],g=e[11],y=e[12],v=e[13],E=e[14],w=e[15],_=e[16],b=e[17],O=e[18],T=e[19],R=0,x=0,I=0,A=0,C=0;R=65504&&n<=65519||65534===n)&&(o||(o=Ye(e,i)),!(i+r>e.byteLength));)i+=r;return t.slice(0,i)}(r.result)||null)},r.readAsArrayBuffer(t.slice(0,262144))})},qe=function(t,e){var n=window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(n){var r=new n;return r.append(t),r.getBlob(e)}return new Blob([t],{type:e})},We=function(t){var e=new Blob(["(",t.toString(),")()"],{type:"application/javascript"}),n=URL.createObjectURL(e),r=new Worker(n);return{transfer:function(t,e){},post:function(t,e,n){var i=Math.random().toString(36).substr(2,9);r.onmessage=function(t){t.data.id===i&&e(t.data.message)},r.postMessage({id:i,message:t},n)},terminate:function(){r.terminate(),URL.revokeObjectURL(n)}}},Xe=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(function(r,i){if(!t||!function(t){return/^image/.test(t.type)}(t))return i();var o=n.stripImageHead,a=n.beforeCreateBlob,c=n.afterCreateBlob,u=n.canvasMemoryLimit,l=e.crop,s=e.size,f=e.filter,h=e.output,d=e.image.orientation?Math.max(1,Math.min(8,e.image.orientation)):null,p=h.quality,m=null===p?null:p/100,g=h.type,y=[];"number"!=typeof s.width&&"number"!=typeof s.height||y.push({type:"resize",data:s}),f&&20===f.length&&y.push({type:"filter",data:f});var v=function(t){var e=c?c(t):t;Promise.resolve(e).then(r)},E=function(t,e){return function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new Promise(function(r){var i=document.createElement("canvas");i.width=t.width,i.height=t.height,i.getContext("2d").putImageData(t,0,0);var o=n?n(i):i;Promise.resolve(o).then(function(t){t.toBlob(r,e.type,e.quality)})})}(t,e,a).then(function(t){if(o)return v(t);Fe(t).then(function(e){null!==e&&(t=new Blob([e,t.slice(20)],{type:t.type})),v(t)})}).catch(i)};if(/svg/.test(t.type)&&null===g)return function(t,e){return new Promise(function(n){var r=new FileReader;r.onloadend=function(){var t=r.result,i=document.createElement("div");i.style.cssText="position:absolute;pointer-events:none;width:0;height:0;visibility:hidden;",i.innerHTML=t;var o=i.querySelector("svg");document.body.appendChild(i);var a=o.getBBox();i.parentNode.removeChild(i);var c=i.querySelector("title"),u=o.getAttribute("viewBox")||"",l=o.getAttribute("width")||"",s=o.getAttribute("height")||"",f=parseFloat(l)||null,h=parseFloat(s)||null,d=(l.match(/[a-z]+/)||[])[0]||"",p=(s.match(/[a-z]+/)||[])[0]||"",m=u.split(" ").map(parseFloat),g=m.length?{x:m[0],y:m[1],width:m[2],height:m[3]}:a,y=null!=f?f:g.width,v=null!=h?h:g.height;o.style.overflow="visible",o.setAttribute("width",y),o.setAttribute("height",v);var E=e.aspectRatio||v/y,w=y,_=w*E,b=qt({width:y,height:v},kt({width:w,height:_},E),e.rotation,e.center),O=e.zoom*b,T=e.rotation*(180/Math.PI),R={x:.5*w,y:.5*_},x={x:R.x-y*e.center.x,y:R.y-v*e.center.y},I=["rotate(".concat(T," ").concat(R.x," ").concat(R.y,")"),"translate(".concat(R.x," ").concat(R.y,")"),"scale(".concat(O,")"),"translate(".concat(-R.x," ").concat(-R.y,")"),"translate(".concat(x.x," ").concat(x.y,")")],A=["scale(".concat(e.flip.horizontal?-1:1," ").concat(e.flip.vertical?-1:1,")"),"translate(".concat(e.flip.horizontal?-y:0," ").concat(e.flip.vertical?-v:0,")")],C='\n\n\x3c!-- Generator: PQINA - https://pqina.nl/ --\x3e\n').concat(c?c.textContent:"",'\nCropped with FilePond.\n\n\n').concat(o.outerHTML,"\n\n\n");n(C)},r.readAsText(t)})}(t,l).then(function(t){r(qe(t,"image/svg+xml"))});var w=URL.createObjectURL(t);(function(t){return new Promise(function(e,n){var r=new Image;r.onload=function(){e(r)},r.onerror=function(t){n(t)},r.src=t})})(w).then(function(e){URL.revokeObjectURL(w);var n=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).canvasMemoryLimit,i=n.zoom||1,o=ze(t,e,n.flip),a={width:o.width,height:o.height},c=n.aspectRatio||a.height/a.width,u=jt(a,c,i);if(r){var l=u.width*u.height;if(l>r){var s=Math.sqrt(r)/Math.sqrt(l);a.width=Math.floor(a.width*s),a.height=Math.floor(a.height*s),u=jt(a,c,i)}}var f=document.createElement("canvas"),h={x:.5*u.width,y:.5*u.height},d={x:0,y:0,width:u.width,height:u.height,center:h},p=i*qt(a,kt(d,c),n.rotation,n.center);f.width=Math.round(u.width/p),f.height=Math.round(u.height/p),h.x/=p,h.y/=p;var m=h.x-a.width*(n.center?n.center.x:.5),g=h.y-a.height*(n.center?n.center.y:.5),y=f.getContext("2d");return y.translate(h.x,h.y),y.rotate(n.rotation||0),y.drawImage(o,m-h.x,g-h.y,a.width,a.height),y.getImageData(0,0,f.width,f.height)}(e,d,l,{canvasMemoryLimit:u}),r={quality:m,type:g||t.type};if(!y.length)return E(n,r);var i=We(Be);i.post({transforms:y,imageData:n},function(t){E(function(t){var e;try{e=new ImageData(t.width,t.height)}catch(n){e=document.createElement("canvas").getContext("2d").createImageData(t.width,t.height)}return e.data.set(t.data),e}(t),r),i.terminate()},[n.data.buffer])})})},Ze=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return(e+t).slice(-e.length)},He=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return"".concat(t.getFullYear(),"-").concat(Ze(t.getMonth()+1,"00"),"-").concat(Ze(t.getDate(),"00"),"_").concat(Ze(t.getHours(),"00"),"-").concat(Ze(t.getMinutes(),"00"),"-").concat(Ze(t.getSeconds(),"00"))},Ke=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=t("GET_CROP_ASPECT_RATIO"),o={center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},zoom:1,rotation:0,aspectRatio:null};n?Object.assign(o,n):e.options.crop?Object.assign(o,e.options.crop):o.aspectRatio=i;var a=r.width,c=r.height;if(a&&c)o.aspectRatio=c/a;else if(e.instructions.size){var u=e.instructions.size,l=u.width,s=u.height;o.aspectRatio=s/l}return o},Qe=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},Je={jpeg:"jpg","svg+xml":"svg"},$e=function(t){return Array.isArray(t)&&20===t.length};function tn(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:0;return[.213+.787*t,.715-.715*t,.072-.072*t,0,0,.213-.213*t,.715+.285*t,.072-.072*t,0,0,.213-.213*t,.715-.715*t,.072+.928*t,0,0,0,0,0,1,0]}},an=Math.PI/2,cn=function(t){var e={upscale:t("GET_OUTPUT_UPSCALE"),mode:t("GET_OUTPUT_FIT"),width:t("GET_OUTPUT_WIDTH"),height:t("GET_OUTPUT_HEIGHT")},n=t("GET_SIZE_INPUT");if(t("ALLOW_MANUAL_RESIZE")&&(n.width||n.height)){var r=n.width,i=n.height,o=t("GET_CROP_RECTANGLE_ASPECT_RATIO");r&&!i?i=r/o:i&&!r&&(r=i*o),e.width=r,e.height=i,e.upscale=!0,e.mode="force"}return e},un=function(t,e,n){return new Promise(function(r,i){var o={data:null,file:null},a=Jt(e.image,e.crop),c=cn(n),u={crop:a,image:{orientation:e.file.orientation},size:c,output:{type:n("GET_OUTPUT_TYPE"),quality:n("GET_OUTPUT_QUALITY")},filter:e.colorMatrices.filter?{id:e.filterName,value:e.filterValue,matrix:e.colorMatrices.filter}:null,color:Object.keys(e.colorValues).length?Object.keys(e.colorValues).reduce(function(t,n){return t[n]={value:e.colorValues[n],matrix:e.colorMatrices[n].map(function(t){return bt(t,5)})},t},{}):null,colorMatrix:n("GET_COLOR_MATRIX")};if(t.data&&(o.data=u),t.file){var l={beforeCreateBlob:n("GET_BEFORE_CREATE_BLOB"),afterCreateBlob:n("GET_AFTER_CREATE_BLOB"),stripImageHead:n("GET_OUTPUT_STRIP_IMAGE_HEAD"),canvasMemoryLimit:n("GET_OUTPUT_CANVAS_MEMORY_LIMIT")},s=e.file.data,f=nn({},u,{filter:u.colorMatrix});Xe(s,f,l).then(function(t){var e;o.file=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i="string"==typeof n?t.slice(0,t.size,n):t.slice(0,t.size,t.type);return i.lastModifiedDate=new Date,H(e)||(e=He()),e&&null===r&&e.split(".").pop()?i.name=e:(r=r||function(t){if("string"!=typeof t)return"";var e=t.split("/").pop();return/svg/.test(e)?"svg":/zip|compressed/.test(e)?"zip":/plain/.test(e)?"txt":/msword/.test(e)?"doc":/[a-z]+/.test(e)?"jpeg"===e?"jpg":e:""}(i.type),i.name=e+(r?"."+r:"")),i}(t,function(t,e){var n=function(t){return t.substr(0,t.lastIndexOf("."))||t}(t),r=e.split("/")[1],i=Je[r]||r;return"".concat(n,".").concat(i)}(s.name,(e=t.type,/jpeg|png|svg\+xml/.test(e)?e:"image/jpeg"))),r(o)}).catch(i)}else r(o)})},ln=function(t){t.crop.draft.rotateMinScale=null},sn=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];!function(t){t.crop.draft.rotateMinScale||(t.crop.draft.rotateMinScale=t.crop.transforms.scale)}(t);var i=nn({},t.crop.transforms,{scale:t.crop.draft.rotateMinScale});t.crop.draft.transforms=wn(t.image,t.crop.rectangle,i,e.main+e.sub,n,t.crop.draft.transforms?t.crop.draft.transforms.rotation:t.crop.rotation.main+t.crop.rotation.sub,r),t.crop.rotation=Ve(t.crop.draft.transforms.rotation)},fn=function(t,e,n){if(null!==t.stage){gn(t),t.size.width=!!t.instructions.size&&t.instructions.size.width,t.size.height=!!t.instructions.size&&t.instructions.size.height,t.size.aspectRatioLocked=!0,t.size.aspectRatioPrevious=!1,t.crop.rectangle=Ee(t.stage,t.instructions.crop.aspectRatio||t.image.aspectRatio),t.crop.draft.rectangle=null,t.crop.transforms=_e(t.instructions.crop,t.stage,t.image),t.crop.draft.transforms=null,t.crop.rotation=Ve(t.instructions.crop.rotation),t.crop.flip=nn({},t.instructions.crop.flip);var r=e("GET_CROP_ASPECT_RATIO_OPTIONS")||[],i=r.map(function(t){return t.value}).find(function(e){return e===t.instructions.crop.aspectRatio}),o=r.find(function(t){return null===t.value});i?t.crop.aspectRatio=i:o&&r.length?t.crop.aspectRatio=null:t.crop.aspectRatio=e("GET_CROP_ASPECT_RATIO"),t.crop.isDirty=!1,Object.keys(t.instructions.color).forEach(function(e){return n("COLOR_SET_VALUE",{key:e,value:t.instructions.color[e]})}),n("FILTER_SET_VALUE",{value:t.instructions.filter}),ln(t)}},hn=function(t,e){if(t.stage){gn(t);var n=t.crop.rectangle,r=n.height/n.width,i=t.crop.aspectRatio;if(null!==i&&bt(r,3)!==i){var o=e("GET_MIN_CROP_SIZE");o.width=bt(o.width),o.height=bt(o.height);var a=Math.min(n.width,n.height);Math.min(a*i,a/i)bt(u,5)?(a&&(o+=2*a),nn({},Te(n),{rotation:o,interaction:{rotation:c.rotation}})):(c.scale=Math.min(u,c.scale),c.interaction={rotation:c.rotation},c)},_n=function(t,e,n,r,i){var o=Math.max(1e-10,r),a=Ie(t,e,nn({},Te(n),{scale:o}),"resizing"),c=En(e,i);return a.scale=Math.min(c,a.scale),a.interaction={scale:o},a},bn=function(t){return!1===t.file},On=function(t,e,n){return nn({AWAIT_IMAGE:function(){n.file||(n.noImageTimeout=setTimeout(function(){t("AWAITING_IMAGE")},250))},REQUEST_REMOVE_IMAGE:function(){t("UNLOAD_IMAGE"),n.file=!1,n.noImageTimeout=setTimeout(function(){t("AWAITING_IMAGE")},500)},DID_UNLOAD_IMAGE:function(){t("ABORT_IMAGE")},REQUEST_ABORT_IMAGE:function(e){t("UNLOAD_IMAGE"),n.file=!1,n.queuedFile=e},DID_SET_SRC:function(e){e.value!==e.prevValue&&(clearTimeout(n.noImageTimeout),t("REQUEST_LOAD_IMAGE",{source:e.value}))},ABORT_IMAGE:function(){if(n.file=null,n.queuedFile){var e=n.queuedFile;n.queuedFile=null,t("REQUEST_LOAD_IMAGE",e)}},REQUEST_LOAD_IMAGE:function(e){var r,i=e.source,o=e.success,a=void 0===o?function(){}:o,c=e.failure,u=void 0===c?function(t){}:c,l=e.options,s=e.resolveOnConfirm,f=void 0!==s&&s;if(clearTimeout(n.noImageTimeout),!i)return u();null===n.file?(ot(n),n.file={uid:st()},t("DID_REQUEST_LOAD_IMAGE"),(r=i,new Promise(function(t,e){if(H(r))fetch(r).then(function(t){if(t.ok)return t.blob();e(t)}).then(function(e){return t(e)});else if(r instanceof Blob)t(r);else{if("IMG"===r.nodeName){var n=function(e){var n=document.createElement("canvas");n.width=e.naturalWidth,n.height=e.naturalHeight,n.getContext("2d").drawImage(e,0,0),n.toBlob(t)};return r.complete?void n(r):void(r.onload=function(){return n(r)})}"CANVAS"!==r.nodeName?e(r):r.toBlob(t)}})).then(function(e){if(bn(n))return t("ABORT_IMAGE");e.name||(e.name=He()),n.file.orientation=-1,n.file.data=e,t("LOAD_IMAGE",{success:a,failure:u,options:l,resolveOnConfirm:f},!0),t("KICK")}).catch(function(e){if(bn(n))return t("ABORT_IMAGE");t("DID_LOAD_IMAGE_ERROR",{error:{status:"IMAGE_LOAD_ERROR",data:e}}),u(e)})):t("REQUEST_ABORT_IMAGE",{source:i,success:a,failure:u,options:l,resolveOnConfirm:f})},LOAD_IMAGE:function(r){var i=r.success,o=r.failure,a=r.options,c=void 0===a?{}:a,u=r.resolveOnConfirm;if(bn(n))return t("ABORT_IMAGE");var l=n.file.data;Promise.all([Ue(l),ge(l)]).then(function(r){if(bn(n))return t("ABORT_IMAGE");var a=r[0],l=r[1];n.file.orientation=l;var s=a.width,f=a.height;l>=5&&l<=8?(a.width=f,a.height=s):(a.width=s,a.height=f);var h=e("GET_MIN_IMAGE_SIZE");if(a.width0?r.y:Math.min(r.y,Math.max(e.y,f)),v=t.y>0?Math.max(r.y,Math.min(e.y,h)):r.y,a){var E=(v-y)/a;m=r.x-.5*E,g=r.x+.5*E}}else if(m=t.x>0?r.x:Math.min(r.x,Math.max(e.x,l)),g=t.x>0?Math.max(r.x,Math.min(e.x,s)):r.x,a){var w=(g-m)*a;y=r.y-.5*w,v=r.y+.5*w}var _,b,O,T,R=c.width,x=c.height;if(n===ve?(_=r.x-.5*R,b=r.x+.5*R,t.y<0?(O=r.y-x,T=r.y):t.y>0&&(O=r.y,T=r.y+x)):(O=r.y-.5*x,T=r.y+.5*x,t.x<0?(_=r.x-R,b=r.x):t.x>0&&(_=r.x,b=r.x+R)),a)if(n===ve){var I=Math.min((v-y)/a,d),A=I*a;ms&&(m=(g=s)-I),r.x=m+.5*I,t.y<0?y=r.y-A:t.y>0&&(v=r.y+A)}else{var C=Math.min((g-m)*a,p),M=C/a;yh&&(y=(v=h)-C),r.y=y+.5*C,t.x<0?m=r.x-M:t.x>0&&(g=r.x+M)}var S=Gt({top:y,right:g,bottom:v,left:m}),P=function(){var e=R*a;n===ye?(y=r.y-.5*e,v=r.y+.5*e):t.y<0?(v=r.y,y=v-e):t.y>0&&(y=r.y,v=y+e)},L=function(){var e=x/a;n===ve?(m=r.x-.5*e,g=r.x+.5*e):t.x<0?(g=r.x,m=g-e):t.x>0&&(m=r.x,g=m+e)};g_&&(m=_,g=_+R,a&&P()),y>O&&(y=O,v=O+x,a&&L()),vG&&(t.x<0?m=r.x-G:g=r.x+G),v-y>D&&(t.y<0?y=r.y-D:v=r.y+D),g-m==0&&(t.x>0?g=r.x+2:m=r.x-2),v-y==0&&(t.y>0?v=r.y+2:y=r.y-2),Math.round(m)s||Math.round(y)h){var V=h-f,U=s-l;if(ms){g=s;var k=Math.min(g-m,U);m=g-k}if(yh){v=h;var z=Math.min(v-y,V);y=v-z}S=Gt({top:y,right:g,bottom:v,left:m})}return{free:S,limited:Gt({top:y,right:g,bottom:v,left:m})}}(m,f,u,s,Lt(n.crop.rectangle),Lt(c),n.crop.aspectRatio,h,d),n.crop.draft.transforms=Se(a,n.crop.draft.rectangle.limited,n.crop.transforms)},CROP_RECT_CORNER_DRAG:function(t){var r=t.offset,i=t.origin,o=t.anchor,a=n.image,c=n.stage,u=Le(i,n.crop.rectangle),l=Le(o,n.crop.rectangle),s={x:u.x+r.x,y:u.y+r.y},f=e("GET_MIN_CROP_SIZE"),h=e("GET_MAX_CROP_SIZE");f.width=bt(f.width),f.height=bt(f.height);var d=En(n.crop.rectangle,e("GET_MIN_PREVIEW_IMAGE_SIZE"))/(n.crop.draft.transforms.scale||n.crop.transforms.scale);h.width=bt(h.width*d),h.height=bt(h.height*d);var p={x:Math.sign(u.x-l.x),y:Math.sign(u.y-l.y)};n.crop.draft.rectangle=function(t,e,n,r,i,o,a){var c=Lt(r),u=c.left,l=c.right,s=c.top,f=c.bottom,h=xt({x:e.x,y:e.y},r),d=t.x>0?n.x:Math.min(h.x,n.x),p=t.x>0?Math.max(n.x,h.x):n.x,m=t.y>0?n.y:Math.min(h.y,n.y),g=t.y>0?Math.max(n.y,h.y):n.y;if(i){var y=h.x-n.x;t.x>0?p=Math.max(n.x,n.x+t.x*y):d=Math.min(n.x,n.x-t.x*y),t.y>0?g=Math.max(n.y,n.y+t.x*y*i):m=Math.min(n.y,n.y-t.x*y*i)}var v=Gt({top:m,right:p,bottom:g,left:d});Gt({top:m,right:p,bottom:g,left:d});if(o.width&&o.height){var E=o.width,w=o.height;i&&(1===i?w=E=Math.max(E,w):Ew?w=E*i:E=w/i),p-d0?p=n.x+E:d=n.x-E),g-m0?g=n.y+w:m=n.y-w);var _=a.width,b=a.height;i&&(i<1?_=b/i:b=_*i),p-d>_&&(t.x<0?d=n.x-_:p=n.x+_),g-m>b&&(t.y<0?m=n.y-b:g=n.y+b)}if(p-d==0&&(t.x>0?p=n.x+2:d=n.x-2),g-m==0&&(t.y>0?g=n.y+2:m=n.y-2),Math.round(d)l||Math.round(m)f){var O=f-s,T=l-u;if(d0&&(g=n.y+R*i),t.y<0&&(m=n.y-R*i))}if(p>l){p=l;var x=Math.min(p-d,T);d=p-x,i&&(t.y>0&&(g=n.y+x*i),t.y<0&&(m=n.y-x*i))}if(m0&&(p=n.x+I/i),t.x<0&&(d=n.x-I/i))}if(g>f){g=f;var A=Math.min(g-m,O);m=g-A,i&&(t.x>0&&(p=n.x+A/i),t.x<0&&(d=n.x-A/i))}v=Gt({top:m,right:p,bottom:g,left:d})}return{free:v,limited:Gt({top:m,right:p,bottom:g,left:d})}}(p,s,l,c,n.crop.aspectRatio,f,h),n.crop.draft.transforms=Se(a,n.crop.draft.rectangle.limited,n.crop.transforms)},CROP_IMAGE_DRAG_GRAB:function(){return vn(n)||gn(n)},CROP_IMAGE_DRAG_RELEASE:function(){dn(n),ln(n),pn(n,e,t)},CROP_IMAGE_RESIZE_RELEASE:function(){dn(n),ln(n),pn(n,e,t)},CROP_IMAGE_ROTATE_RELEASE:function(){dn(n),pn(n,e,t)},CROP_IMAGE_DRAG:function(t){var e,r,i,o,a,c,u=t.value;gn(n),n.crop.draft.transforms=(e=n.image,r=n.crop.rectangle,i=n.crop.transforms,o=u,a={x:i.translation.x+o.x,y:i.translation.y+o.y},(c=Ie(e,r,nn({},Te(i),{translation:a}),"moving")).interaction={translation:a},c)},CROP_IMAGE_RESIZE:function(t){var r=t.value;gn(n);var i=n.crop.transforms;n.crop.draft.transforms=_n(n.image,n.crop.rectangle,i,i.scale+i.scale*r,e("GET_MIN_PREVIEW_IMAGE_SIZE"))},CROP_IMAGE_RESIZE_MULTIPLY:function(t){var r=t.value;gn(n);var i=n.crop.transforms;n.crop.draft.transforms=_n(n.image,n.crop.rectangle,i,i.scale*r,e("GET_MIN_PREVIEW_IMAGE_SIZE"))},CROP_IMAGE_RESIZE_AMOUNT:function(t){var r=t.value;gn(n);var i=n.crop.transforms;n.crop.draft.transforms=_n(n.image,n.crop.rectangle,i,(n.crop.draft.transforms?n.crop.draft.transforms.scale:i.scale)+r,e("GET_MIN_PREVIEW_IMAGE_SIZE"))},CROP_IMAGE_ROTATE:function(t){var r=t.value;gn(n),n.crop.isRotating=!0,sn(n,{main:n.crop.rotation.main,sub:r},e("GET_MIN_PREVIEW_IMAGE_SIZE"))},CROP_IMAGE_ROTATE_ADJUST:function(t){var r=t.value;gn(n),sn(n,{main:n.crop.rotation.main,sub:Math.min(Math.PI/4,Math.max(-Math.PI/4,n.crop.rotation.sub+r))},e("GET_MIN_PREVIEW_IMAGE_SIZE")),dn(n)},CROP_IMAGE_ROTATE_CENTER:function(){gn(n),sn(n,{main:n.crop.rotation.main,sub:0},e("GET_MIN_PREVIEW_IMAGE_SIZE")),dn(n)},CROP_IMAGE_ROTATE_LEFT:function(){mn(n,e,t),sn(n,{main:n.crop.rotation.main-an,sub:n.crop.rotation.sub},e("GET_MIN_PREVIEW_IMAGE_SIZE"),-an),dn(n)},CROP_IMAGE_ROTATE_RIGHT:function(){mn(n,e,t),sn(n,{main:n.crop.rotation.main+an,sub:n.crop.rotation.sub},e("GET_MIN_PREVIEW_IMAGE_SIZE"),an),dn(n)},CROP_IMAGE_FLIP_HORIZONTAL:function(){mn(n,e,t),0===bt(n.crop.rotation.main%Math.PI/2,5)?n.crop.flip.horizontal=!n.crop.flip.horizontal:n.crop.flip.vertical=!n.crop.flip.vertical,n.crop.isDirty=!0},CROP_IMAGE_FLIP_VERTICAL:function(){mn(n,e,t),0===bt(n.crop.rotation.main%Math.PI/2,5)?n.crop.flip.vertical=!n.crop.flip.vertical:n.crop.flip.horizontal=!n.crop.flip.horizontal,n.crop.isDirty=!0},DID_RECEIVE_IMAGE_DATA:function(t){var e=t.previewData,r=t.thumbData;n.file.preview=e,n.file.thumb=r},COLOR_SET_COLOR_VALUE:function(e){var r=e.key,i=e.value;n.crop.isDirty=!0,t("COLOR_SET_VALUE",{key:r,value:i})},COLOR_SET_VALUE:function(e){var r=e.key,i=e.value;n.colorValues[r]=i,t("SET_COLOR_MATRIX",{key:r,matrix:on[r](i)})}},Object.keys(on).reduce(function(r,i){var o=i.toUpperCase(),a=Qe(i);return r["SET_COLOR_".concat(o)]=function(r){var c=r.value;if(c!==r.prevValue){var u=en(e("GET_COLOR_".concat(o,"_RANGE")),2),l=u[0],s=u[1],f=_t(c,l,s);n.options["color".concat(a)]=f,n.instructions.color||(n.instructions.color={}),n.instructions.color[i]=f,t("COLOR_SET_VALUE",{key:i,value:f})}},r},{}),{SET_COLOR_MATRIX:function(e){var r=e.key,i=e.matrix;i?n.colorMatrices[r]=tn(i):delete n.colorMatrices[r],t("DID_SET_COLOR_MATRIX",{key:r,matrix:i})},FILTER_SET_FILTER:function(e){var r=e.value;n.crop.isDirty=!0,t("FILTER_SET_VALUE",{value:r})},FILTER_SET_VALUE:function(r){var i=r.value,o=$e(i)?i:null;if(H(i)){var a=e("GET_FILTERS");l(a,function(t,e){t===i&&(o=e.matrix())})}n.filter=i,n.filterName=H(i)?i:null,t("SET_COLOR_MATRIX",{key:"filter",matrix:o})},DID_SET_FILTER:function(e){var n=e.value;n!==e.prevValue&&(t("FILTER_SET_VALUE",{value:n}),t("SET_DATA",{filter:n}))},DID_SET_SIZE:function(e){var n=e.value;n!==e.prevValue&&t("SET_DATA",{size:n})},DID_SET_CROP:function(e){var n=e.value;n!==e.prevValue&&t("SET_DATA",{crop:n})},SET_DATA:function(r){if(r.size&&e("ALLOW_MANUAL_RESIZE")){var i=nn({width:null,height:null},r.size),o=te(i,e("GET_SIZE_MIN"),e("GET_SIZE_MAX"),null);n.instructions.size=nn({},o),t("RESIZE_SET_OUTPUT_SIZE",o)}r.filter&&(n.instructions.filter=r.filter),n.instructions.color=Object.keys(on).reduce(function(t,e){return t[e]=void 0===r.color||void 0===r.color[e]?n.options["color".concat(Qe(e))]:r.color[e],t},{}),r.crop&&(n.instructions.crop=Ke(e,n,r.crop,n.size),t("EDIT_RESET"))},DID_SET_INITIAL_STATE:function(t){var r=t.value||{},i=r.crop,o=r.filter,a=r.color,c=r.size,u=nn({width:null,height:null},void 0===c?{}:c),l=te(u,e("GET_SIZE_MIN"),e("GET_SIZE_MAX"),null);n.instructions.size=nn({},l),n.instructions.crop=Ke(e,n,i),n.instructions.filter=o||null,n.instructions.color=Object.keys(on).reduce(function(t,e){return t[e]=void 0===a||void 0===a[e]?n.options["color".concat(Qe(e))]:a[e],t},{}),n.crop.isDirty=!0},GET_DATA:function(r){var i=r.success,o=r.failure,a=r.file,c=r.data;if(n.file&&n.stage){var u={file:Z(a)?a:e("GET_OUTPUT_FILE"),data:Z(c)?c:e("GET_OUTPUT_DATA"),success:i,failure:o};t(u.file?"REQUEST_PREPARE_OUTPUT":"PREPARE_OUTPUT",u)}},REQUEST_PREPARE_OUTPUT:function(e){var n=e.file,r=e.data,i=e.success,o=e.failure;t("PREPARE_OUTPUT",{file:n,data:r,success:i,failure:o},!0),t("DID_REQUEST_PREPARE_OUTPUT")},PREPARE_OUTPUT:function(r){var i=r.file,o=r.data,a=r.success,c=void 0===a?function(){}:a,u=r.failure,l=void 0===u?function(){}:u;if(bn(n))return t("ABORT_IMAGE");un({file:i,data:o},n,e).then(function(e){if(t("DID_PREPARE_OUTPUT"),bn(n))return t("ABORT_IMAGE");c(e)}).catch(function(e){if(bn(n))return t("ABORT_IMAGE");l(e)})},EDIT_RESET:function(){gn(n),fn(n,e,t)},EDIT_CONFIRM:function(){if(n.file&&n.stage){gn(n),t("CROP_ZOOM");var r={file:e("GET_OUTPUT_FILE"),data:e("GET_OUTPUT_DATA"),success:function(e){n.filePromise.resolveOnConfirm&&n.filePromise.success(e),t("DID_CONFIRM",{output:e})}};t(r.file?"REQUEST_PREPARE_OUTPUT":"PREPARE_OUTPUT",r)}},EDIT_CANCEL:function(){n.filePromise&&n.filePromise.success(null),t("DID_CANCEL")},EDIT_CLOSE:function(){gn(n)},EDIT_DESTROY:function(){ot(n)},SET_OPTIONS:function(e){var n=e.options;l(n,function(e,n){t("SET_".concat(at(e,"_").toUpperCase()),{value:n})})}})},Tn=function(t,e){return B({ignoreRect:!0,name:t,mixins:e,create:function(t){var e=t.root,n=t.props;n.className&&e.element.classList.add(n.className),n.controls.map(function(t){var n=e.createChildView(t.view,t);t.didCreateView&&t.didCreateView(n),e.appendChildView(n)})}})},Rn=B({ignoreRect:!0,ignoreRectUpdate:!0,name:"button",mixins:{styles:["opacity"],animations:{opacity:{type:"tween",duration:250}},apis:["id"],listeners:!0},tag:"button",create:function(t){var e=t.root,n=t.props;e.element.innerHTML="".concat(n.icon||"","").concat(n.label,""),e.element.setAttribute("type",n.type||"button"),n.name&&n.name.split(" ").forEach(function(t){e.element.className+=" doka--button-".concat(t)}),e.ref.handleClick=function(t){"string"==typeof n.action?e.dispatch(n.action):n.action()},e.element.addEventListener("click",e.ref.handleClick),n.create&&n.create({root:e,props:n})},destroy:function(t){var e=t.root;e.element.removeEventListener("click",e.ref.handleClick)}}),xn=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:24;return'")},In=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return B({ignoreRect:!0,tag:t,create:function(t){t.root.element.textContent=e}})},An=function(t){t.element.dataset.viewStatus="idle",Cn(t)},Cn=function(t){t.ref.busyIndicators.forEach(function(t){t.translateY=-10,t.opacity=0,t.markedForRemoval=!0})},Mn=function(t,e,n){t.element.dataset.viewStatus="busy";var r=Sn(t,e,n);Cn(t),t.ref.busyIndicators.push(r),r.markedForRemoval=!1,r.translateY=0,r.opacity=1},Sn=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.appendChildView(t.createChildView(Tn("status-bubble",{styles:["opacity","translateY"],apis:["markedForRemoval"],animations:{opacity:{type:"tween",duration:500},translateY:{type:"spring",mass:20}}}),{translateY:20,opacity:0,controls:n?[{view:Rn,label:"Close",name:"icon-only status-bubble-close",icon:xn(''),action:n},{view:In("p",e)}]:[{view:In("p",e)}]}))},Pn=B({name:"edit-status",ignoreRect:!0,create:function(t){var e=t.root;e.ref.busyIndicators=[],e.element.setAttribute("tabindex",-1)},write:Y({AWAITING_IMAGE:function(t){var e=t.root;e.rect.element.hidden||Mn(e,e.query("GET_LABEL_STATUS_AWAITING_IMAGE"))},DID_PRESENT_IMAGE:function(t){var e=t.root;An(e)},DID_LOAD_IMAGE_ERROR:function(t){var e=t.root,n=/fullscreen/.test(e.query("GET_STYLE_LAYOUT_MODE"));Mn(e,e.query("GET_LABEL_STATUS_LOAD_IMAGE_ERROR"),n?function(){e.dispatch("EDIT_CANCEL")}:null)},DID_REQUEST_LOAD_IMAGE:function(t){var e=t.root;Mn(e,e.query("GET_LABEL_STATUS_LOADING_IMAGE"))},DID_REQUEST_PREPARE_OUTPUT:function(t){var e=t.root;Mn(e,e.query("GET_LABEL_STATUS_PROCESSING_IMAGE"))},DID_PREPARE_OUTPUT:function(t){var e=t.root;An(e)}}),didWriteView:function(t){var e=t.root;e.ref.busyIndicators=e.ref.busyIndicators.filter(function(t){return!t.markedForRemoval||0!==t.opacity||(e.removeChildView(t),!1)})}}),Ln={down:"pointerdown",move:"pointermove",up:"pointerup"},Gn=function(){var t=[],e=function(e){return t.findIndex(function(t){return t.pointerId===e.pointerId})};return{update:function(n){var r=e(n);r<0||(t[r]=n)},multiple:function(){return t.length>1},count:function(){return t.length},active:function(){return t.concat()},push:function(n){(function(t){return e(t)>=0})(n)||t.push(n)},pop:function(n){var r=e(n);r<0||t.splice(r,1)}}},Dn=function(t,e,n,r){return t.addEventListener(Ln[e],n,r)},Vn=function(t,e,n){return t.removeEventListener(Ln[e],n)},Un=function(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{stopPropagation:!0,cancelOnMultiple:!1},o={x:0,y:0},a={enabled:!0,origin:null,cancel:!1,cancelled:!1,pointers:Gn()},c=function(t){return{x:t.pageX-o.x,y:t.pageY-o.y}},u=function(t,e){return e&&e.apply(null,[t,c(t)])},l=function(n){var r=0===a.pointers.count();r&&(a.active=!1,a.cancel=!1,a.cancelled=!1),a.pointers.push(n),Dn(document.documentElement,"up",f),r?(t===n.target||t.contains(n.target))&&n.isPrimary&&(n.preventDefault(),i.stopPropagation&&(n.stopPropagation(),n.stopImmediatePropagation()),a.active=!0,o.x=n.pageX,o.y=n.pageY,Dn(document.documentElement,"move",s),e(n)):i.cancelOnMultiple&&(a.cancel=!0)},s=function(t){t.isPrimary&&(a.cancelled||(t.preventDefault(),u(t,n),a.cancel&&(a.cancelled=!0,u(t,r))))},f=function t(e){a.pointers.pop(e),0===a.pointers.count()&&(Vn(document.documentElement,"move",s),Vn(document.documentElement,"up",t)),a.active&&(a.cancelled||(e.preventDefault(),i.stopPropagation&&e.stopPropagation(),u(e,n),u(e,r)))};return Dn(document.documentElement,"down",l),{enable:function(){a.enabled||Dn(document.documentElement,"down",l),a.enabled=!0},disable:function(){a.enabled&&Vn(document.documentElement,"down",l),a.enabled=!1},destroy:function(){Vn(document.documentElement,"up",f),Vn(document.documentElement,"move",s),Vn(document.documentElement,"down",l)}}},Nn={1:function(){return[1,0,0,1,0,0]},2:function(t){return[-1,0,0,1,t,0]},3:function(t,e){return[-1,0,0,-1,t,e]},4:function(t,e){return[1,0,0,-1,0,e]},5:function(){return[0,1,1,0,0,0]},6:function(t,e){return[0,1,-1,0,e,0]},7:function(t,e){return[0,-1,-1,0,e,t]},8:function(t){return[0,-1,1,0,0,t]}},kn=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4?arguments[4]:void 0;e=Math.round(e),n=Math.round(n);var o=i||document.createElement("canvas"),a=o.getContext("2d");return r>=5&&r<=8?(o.width=n,o.height=e):(o.width=e,o.height=n),a.save(),function(t,e,n,r){-1!==r&&t.transform.apply(t,Nn[r](e,n))}(a,e,n,r),a.drawImage(t,0,0,e,n),a.restore(),o},jn=function(){self.onmessage=function(t){createImageBitmap(t.data.message.file).then(function(e){self.postMessage({id:t.data.id,message:e},[e])})}},zn=function(t){var e=new Blob(["(",t.toString(),")()"],{type:"application/javascript"}),n=URL.createObjectURL(e),r=new Worker(n),i=[];return{transfer:function(t,e){},post:function(t,e,n){var o=st();i[o]=e,r.onmessage=function(t){var e=i[t.data.id];e&&(e(t.data.message),delete i[t.data.id])},r.postMessage({id:o,message:t},n)},terminate:function(){r.terminate(),URL.revokeObjectURL(n)}}},Bn=function(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every(function(t,n){return t===e[n]})},Yn=function(t){var e;try{e=new ImageData(t.width,t.height)}catch(n){e=document.createElement("canvas").getContext("2d").createImageData(t.width,t.height)}return e.data.set(new Uint8ClampedArray(t.data)),e};function Fn(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e.9})&&(i.opacity=null,i.opacity=0),void i.setColorMatrix(r)}var o=e.createChildView(Hn,{imageData:e.query("GET_PREVIEW_IMAGE_DATA"),colorMatrix:r});o.element.dataset.key="b",o.zIndex=0,o.opacity=null,o.opacity=0,n.push(e.appendChildView(o))}},DID_APPLY_COLOR_MATRIX:function(t){var e=t.root,n=t.action,r=e.ref.bitmaps,i=r.find(function(t){return t.hasColorMatrix(n.matrix)});i&&(r.forEach(function(t){return t.zIndex=0}),i.opacity=1,i.zIndex=1)}}),create:function(t){var e=t.root;e.ref.currentMatrix=null,e.rotateZ=1e-5;var n="preview"!==e.query("GET_STYLE_LAYOUT_MODE");e.scaleX=n?1.15:1,e.scaleY=n?1.15:1,e.rotateX=n?1:null,e.rotateY=n?1:null;var r=e.query("GET_FILE"),i=URL.createObjectURL(r.data);!function(){var t=function(t){var n=Ne(t,{width:e.query("GET_MAX_IMAGE_PREVIEW_WIDTH"),height:e.query("GET_MAX_IMAGE_PREVIEW_HEIGHT")}),i=kn(t,n.width,n.height,r.orientation),o=i.height/i.width,a=96*Math.max(1,.75*window.devicePixelRatio),c=kn(i,o>1?a:a/o,o>1?a*o:a),u=i.getContext("2d").getImageData(0,0,i.width,i.height),l=c.getContext("2d").getImageData(0,0,c.width,c.height);e.ref.bitmaps=[e.appendChildView(e.createChildView(Hn,{imageData:u,colorMatrix:e.query("GET_COLOR_MATRIX"),onready:function(){e.dispatch("DID_RECEIVE_IMAGE_DATA",{previewData:u,thumbData:l}),e.dispatch("DID_PRESENT_IMAGE")}}))],e.ref.bitmaps[0].element.dataset.key="a"},n=function(){var e;(e=i,new Promise(function(t,n){var r=new Image;r.onload=function(){t(r)},r.onerror=function(t){n(t)},r.src=e})).then(t)};if(function(t){return"createImageBitmap"in window&&function(t){return/^image/.test(t.type)&&!/svg/.test(t.type)}(t)}(r.data)){var o=zn(jn);o.post({file:r.data},function(e){o.terminate(),e?t(e):n()})}else n()}()}}),Jn={type:"spring",stiffness:.4,damping:.65,mass:7},$n=B({name:"image-container",ignoreRect:!0,ignoreRectUpdate:!0,mixins:{apis:["flipHorizontal","flipVertical","scale","colorMatrix"],styles:["originX","originY","translateX","translateY","scaleX","scaleY","rotateZ","opacity"],animations:{opacity:{type:"tween",delay:150,duration:750},scaleX:Jn,scaleY:Jn,translateX:Jn,translateY:Jn,originX:Jn,originY:Jn,rotateZ:{type:"spring",stiffness:.25,damping:.25,mass:2.5}}},create:function(t){var e=t.root;e.ref.image=e.appendChildView(e.createChildView(Qn,{rotateX:0,rotateY:0,perspective:2e3})),e.ref.dragger=Un(e.element,function(){e.dispatch("CROP_IMAGE_DRAG_GRAB")},function(t,n){e.dispatch("CROP_IMAGE_DRAG",{value:n})},function(){e.dispatch("CROP_IMAGE_DRAG_RELEASE")},{cancelOnMultiple:!0})},destroy:function(t){t.root.ref.dragger.destroy()},write:Y({SHOW_VIEW:function(t){var e=t.root;"crop"===t.action.id?(e.element.setAttribute("tabindex",0),e.ref.dragger.enable()):(e.element.removeAttribute("tabindex"),e.ref.dragger.disable())}},function(t){var e=t.root,n=t.props,r=e.ref.image,i=n.colorMatrix;r.rotateX=n.flipVertical?Math.PI:0,r.rotateY=n.flipHorizontal?Math.PI:0,r.colorMatrix=i})}),tr=pt()&&1===window.devicePixelRatio?function(t){return Math.round(t)}:function(t){return t},er=function(t,e,n,r,i,o){t||(e.translateX=null,e.translateY=null,e.scaleX=null,e.scaleY=null);var a=tr(n),c=tr(r),u=tr(n+i)-a,l=tr(r+o)-c;e.translateX=a,e.translateY=c,e.scaleX=.01*u,e.scaleY=.01*l},nr=["top","right","bottom","left"],rr=B({ignoreRect:!0,name:"image-overlay",mixins:{styles:["opacity"],animations:{opacity:"spring"},apis:["rectangle","container","animate"]},create:function(t){var e=t.root;nr.forEach(function(t){e.ref[t]=e.appendChildView(e.createChildView(function(t){return B({ignoreRect:!0,ignoreRectUpdate:!0,name:"image-overlay-panel-".concat(t),mixins:{styles:["translateX","translateY","scaleX","scaleY"],animations:{translateX:Jn,translateY:Jn,scaleX:Jn,scaleY:Jn}}})}(t)))})},write:function(t){var e=t.root,n=t.props,r=e.ref,i=r.top,o=r.right,a=r.bottom,c=r.left,u=n.rectangle,l=n.container,s=n.animate;if(u){var f=e.rect.element,h=l,d=u.x,p=u.y,m=h.top,g=h.left,y=p+m,v=h.width,E=d+g,w=d+u.width,_=p+u.height,b=h.height-(_+m),O=g+f.width-(d+u.width);er(s,i,-g-2,-m-2,v+4,y+2),er(s,c,-g-2,p-2,E+2,u.height+4),er(s,o,w,p-2,O+2,u.height+4),er(s,a,-g-2,_,v+4,b+2)}}}),ir=["top","right","bottom","left"],or=B({name:"image-outline",ignoreRect:!0,mixins:{styles:["opacity"],animations:{opacity:{type:"spring"}},apis:["animate","rectangle","edgeWidth"]},create:function(t){var e=t.root;ir.forEach(function(t){e.ref[t]=e.appendChildView(e.createChildView(function(t){return B({ignoreRect:!0,ignoreRectUpdate:!0,name:"image-outline-edge-".concat(t),mixins:{styles:["translateX","translateY","scaleX","scaleY"],animations:{translateX:Jn,translateY:Jn,scaleX:Jn,scaleY:Jn}}})}(t)))})},write:function(t){var e=t.root,n=t.props,r=e.ref,i=r.top,o=r.right,a=r.bottom,c=r.left,u=n.animate,l=n.rectangle,s=n.edgeWidth;if(l){var f=l.x,h=l.y,d=l.width,p=l.height,m=2*s;er(u,i,f-s+1,h-s+1,d+m-2,s),er(u,c,f-s+1,h-s+1,s,p+m-2),er(u,o,f+d-1,h-s+1,s,p+m-2),er(u,a,f-s+1,h+p-1,d+m-2,s)}}});function ar(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var cr=B({name:"image",ignoreRect:!0,mixins:{styles:["opacity"],animations:{opacity:{type:"tween",duration:250}},apis:["offsetTop"]},create:function(t){var e=t.root;e.ref.hasTroubleAnimatingTransformOrigin="safari"in window,e.ref.image=e.appendChildView(e.createChildView($n,{flip:{horizontal:!1,vertical:!1},translateX:null,translateY:null,rotateZ:null,scaleX:null,scaleY:null,opacity:0})),e.ref.overlay=e.appendChildView(e.createChildView(rr,{opacity:0})),e.ref.outline=e.appendChildView(e.createChildView(or,{opacity:0}))},write:Y({DID_PRESENT_IMAGE:function(t){t.root.ref.image.opacity=1}},function(t){var e=t.root,n=t.props,r=t.actions,i=t.timestamp,o=e.ref,a=o.image,c=o.outline,u=o.overlay,l=o.hasTroubleAnimatingTransformOrigin,s=e.query("GET_CROP",n.id,i);if(s){var f=s.isDraft,h=s.cropRect,d=s.cropStatus,p=s.origin,m=s.translation,g=s.translationBand,y=s.scale,v=s.scaleBand,E=s.rotation,w=s.rotationBand,_=s.flip,b=s.colorMatrix,O=e.query("GET_ROOT"),T=e.query("GET_STAGE"),R=T.x,x=T.y;if(f&&(a.originX=null,a.originY=null,a.translateX=null,a.translateY=null,a.scaleX=null,a.scaleY=null,a.rotateZ=null),a.colorMatrix=b,a.perspective=100,l)!!r.find(function(t){return"CROP_IMAGE_DRAG_RELEASE"===t.type})&&y>1&&(a.originX=null,a.originY=null,a.translateX=null,a.translateY=null);var I=e.query("IS_ACTIVE_VIEW","crop"),A=I?.75:.9,C=1,M=function(t){for(var e=1;e