PageSourceSearch

https://static.openfoodfacts.org/js/dist/cropper.esm.js

js openfoodfacts.org collected 2026-09-24 08:23:56 UTC 49,941 bytes, 3 lines download raw bytes

vendor: 7,636 bytes, lines 1-2
1/*! Cropper.js v2.2.0 | (c) 2015-present Chen Fengyuan | MIT */
2const IS_BROWSER="undefined"!=typeof window&&void 0!==window.document,WINDOW=IS_BROWSER?window:{},IS_TOUCH_DEVICE=!!IS_BROWSER&&"ontouchstart"in WINDOW.document.documentElement,HAS_POINTER_EVENT=!!IS_BROWSER&&"PointerEvent"in WINDOW,NAMESPACE="cropper",CROPPER_CANVAS="cropper-canvas",CROPPER_CROSSHAIR="cropper-crosshair",CROPPER_GIRD="cropper-grid",CROPPER_HANDLE="cropper-handle",CROPPER_IMAGE="cropper-image",CROPPER_SELECTION="cropper-selection",CROPPER_SHADE="cropper-shade",CROPPER_VIEWER="cropper-viewer",ACTION_SELECT="select",ACTION_MOVE="move",ACTION_SCALE="scale",ACTION_ROTATE="rotate",ACTION_TRANSFORM="transform",ACTION_NONE="none",ACTION_RESIZE_NORTH="n-resize",ACTION_RESIZE_EAST="e-resize",ACTION_RESIZE_SOUTH="s-resize",ACTION_RESIZE_WEST="w-resize",ACTION_RESIZE_NORTHEAST="ne-resize",ACTION_RESIZE_NORTHWEST="nw-resize",ACTION_RESIZE_SOUTHEAST="se-resize",ACTION_RESIZE_SOUTHWEST="sw-resize",ATTRIBUTE_ACTION="action",EVENT_TOUCH_END=IS_TOUCH_DEVICE?"touchend touchcancel":"mouseup",EVENT_TOUCH_MOVE=IS_TOUCH_DEVICE?"touchmove":"mousemove",EVENT_TOUCH_START=IS_TOUCH_DEVICE?"touchstart":"mousedown",EVENT_POINTER_DOWN=HAS_POINTER_EVENT?"pointerdown":EVENT_TOUCH_START,EVENT_POINTER_MOVE=HAS_POINTER_EVENT?"pointermove":EVENT_TOUCH_MOVE,EVENT_POINTER_UP=HAS_POINTER_EVENT?"pointerup pointercancel":EVENT_TOUCH_END,EVENT_ERROR="error",EVENT_KEYDOWN="keydown",EVENT_LOAD="load",EVENT_RESIZE="resize",EVENT_WHEEL="wheel",EVENT_ACTION="action",EVENT_ACTION_END="actionend",EVENT_ACTION_MOVE="actionmove",EVENT_ACTION_START="actionstart",EVENT_CHANGE="change",EVENT_TRANSFORM="transform",OBJECT_FIT_CONTAIN="contain",OBJECT_FIT_COVER="cover",OBJECT_FIT_FILL="fill",OBJECT_FIT_NONE="none",OBJECT_FIT_SCALE_DOWN="scale-down";function isString(t){return"string"==typeof t}const isNaN=Number.isNaN||WINDOW.isNaN;function isNumber(t){return"number"==typeof t&&!isNaN(t)}function isPositiveNumber(t){return isNumber(t)&&t>0&&t<1/0}function isUndefined(t){return void 0===t}function isObject(t){return"object"==typeof t&&null!==t}const{hasOwnProperty:hasOwnProperty}=Object.prototype;function isPlainObject(t){if(!isObject(t))return!1;try{const{constructor:e}=t,{prototype:i}=e;return e&&i&&hasOwnProperty.call(i,"isPrototypeOf")}catch(t){return!1}}function isFunction(t){return"function"==typeof t}function isElement(t){return"object"==typeof t&&null!==t&&1===t.nodeType}const REGEXP_CAMEL_CASE=/([a-z\d])([A-Z])/g;function toKebabCase(t){return String(t).replace(REGEXP_CAMEL_CASE,"$1-$2").toLowerCase()}const REGEXP_KEBAB_CASE=/-[A-z\d]/g;function toCamelCase(t){return t.replace(REGEXP_KEBAB_CASE,t=>t.slice(1).toUpperCase())}const REGEXP_SPACES=/\s\s*/;function off(t,e,i,s){e.trim().split(REGEXP_SPACES).forEach(e=>{t.removeEventListener(e,i,s)})}function on(t,e,i,s){e.trim().split(REGEXP_SPACES).forEach(e=>{t.addEventListener(e,i,s)})}function once(t,e,i,s){on(t,e,i,Object.assign(Object.assign({},s),{once:!0}))}const defaultEventOptions={bubbles:!0,cancelable:!0,composed:!0};function emit(t,e,i,s){return t.dispatchEvent(new CustomEvent(e,Object.assign(Object.assign(Object.assign({},defaultEventOptions),{detail:i}),s)))}function getComposedPathTarget(t){if("function"==typeof t.composedPath){return t.composedPath().find(isElement)||t.target}return t.target}const resolvedPromise=Promise.resolve();function nextTick(t,e){return e?resolvedPromise.then(t?e.bind(t):e):resolvedPromise}function getRootDocument(t){const e=t.getRootNode();switch(e.nodeType){case 1:return e.ownerDocument;case 9:case 11:return e}return null}function getOffset(t){const{documentElement:e}=t.ownerDocument,i=t.getBoundingClientRect();return{left:i.left+(WINDOW.pageXOffset-e.clientLeft),top:i.top+(WINDOW.pageYOffset-e.clientTop)}}const REGEXP_ANGLE_UNIT=/deg|g?rad|turn$/i;function toAngleInRadian(t){const e=parseFloat(t)||0;if(0!==e){const[i="rad"]=String(t).match(REGEXP_ANGLE_UNIT)||[];switch(i.toLowerCase()){case"deg":return e/360*(2*Math.PI);case"grad":return e/400*(2*Math.PI);case"turn":return e*(2*Math.PI)}}return e}const SIZE_ADJUSTMENT_TYPE_CONTAIN="contain",SIZE_ADJUSTMENT_TYPE_COVER="cover";function getAdjustedSizes(t,e="contain"){const{aspectRatio:i}=t;let{width:s,height:n}=t;const o=isPositiveNumber(s),a=isPositiveNumber(n);if(o&&a){const t=n*i;"contain"===e&&t>s||"cover"===e&&t<s?n=s/i:s=n*i}else o?n=s/i:a&&(s=n*i);return{width:s,height:n}}function multiplyMatrices(t,...e){if(0===e.length)return t;const[i,s,n,o,a,r]=t,[h,c,l,d,u,p]=e[0];return multiplyMatrices(t=[i*h+n*c,s*h+o*c,i*l+n*d,s*l+o*d,i*u+n*p+a,s*u+o*p+r],...e.slice(1))}var style$8=":host([hidden]){display:none!important}";const REGEXP_SUFFIX=/left|top|width|height/i,DEFAULT_SHADOW_ROOT_MODE="open",shadowRoots=new WeakMap,styleSheets=new WeakMap,tagNames=new Map,supportsAdoptedStyleSheets=Boolean(WINDOW.document&&Array.isArray(WINDOW.document.adoptedStyleSheets)&&WINDOW.CSSStyleSheet&&"replaceSync"in WINDOW.CSSStyleSheet.prototype);class CropperElement extends HTMLElement{get $sharedStyle(){return`${this.themeColor?`:host{--theme-color: ${this.themeColor};}`:""}${style$8}`}constructor(){var t,e;super(),this.shadowRootMode="open",this.slottable=!0;const i=null===(e=null===(t=Object.getPrototypeOf(this))||void 0===t?void 0:t.constructor)||void 0===e?void 0:e.$name;i&&tagNames.set(i,this.tagName.toLowerCase())}static get observedAttributes(){return["shadow-root-mode","slottable","theme-color"]}attributeChangedCallback(t,e,i){if(Object.is(i,e))return;const s=toCamelCase(t);let n=i;switch(typeof this[s]){case"boolean":n=null!==i&&"false"!==i;break;case"number":n=Number(i)}switch(this[s]=n,t){case"theme-color":{const t=styleSheets.get(this),e=this.$sharedStyle;t&&e&&(supportsAdoptedStyleSheets?t.replaceSync(e):t.textContent=e);break}}}$propertyChangedCallback(t,e,i){if(!Object.is(i,e))switch(t=toKebabCase(t),typeof i){case"boolean":!0===i?this.hasAttribute(t)||this.setAttribute(t,""):this.removeAttribute(t);break;case"number":i=isNaN(i)?"":String(i);default:i?this.getAttribute(t)!==i&&this.setAttribute(t,i):this.removeAttribute(t)}}connectedCallback(){Object.getPrototypeOf(this).constructor.observedAttributes.forEach(t=>{const e=toCamelCase(t);let i=this[e];isUndefined(i)||this.$propertyChangedCallback(e,void 0,i),Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>i,set(t){const s=i;i=t,this.$propertyChangedCallback(e,s,t)}})});const t=this.shadowRoot||this.attachShadow({mode:this.shadowRootMode||"open"});if(shadowRoots.set(this,t),styleSheets.set(this,this.$addStyles(this.$sharedStyle)),this.$style&&this.$addStyles(this.$style),this.$template){const e=document.createElement("template");e.innerHTML=this.$template,t.appendChild(e.content)}if(this.slottable){const e=document.createElement("slot");t.appendChild(e)}}disconnectedCallback(){styleSheets.has(this)&&styleSheets.delete(this),shadowRoots.has(this)&&shadowRoots.delete(this)}$getTagNameOf(t){var e;return null!==(e=tagNames.get(t))&&void 0!==e?e:t}$setStyles(t){return Object.keys(t).forEach(e=>{let i=t[e];isNumber(i)&&(i=0!==i&&REGEXP_SUFFIX.test(e)?`${i}px`:String(i)),this.style[e]=i}),this}$getShadowRoot(){return this.shadowRoot||shadowRoots.get(this)}$addStyles(t){let e;const i=this.$getShadowRoot();return supportsAdoptedStyleSheets?(e=new CSSStyleSheet,e.replaceSync(t),i.adoptedStyleSheets=i.adoptedStyleSheets.concat(e)):(e=document.createElement("style"),e.textContent=t,i.appendChild(e)),e}$emit(t,e,i){return emit(this,t,e,i)}$nextTick(t){return nextTick(this,t)}static $define(t,e){isObject(t)&&(e=t,t=""),t||(t=this.$name||this.name),t=toKebabCase(t),IS_BROW
2SER&&WINDOW.customElements&&!WINDOW.customElements.get(t)&&customElements.define(t,this,e)}}CropperElement.$version="2.2.0";var style$7=':host{display:block;min-height:100px;min-width:200px;overflow:hidden;position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([background]){background-color:#fff;background-image:repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc),repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc);background-image:repeating-conic-gradient(#ccc 0 25%,#fff 0 50%);background-position:0 0,.5rem .5rem;background-size:1rem 1rem}:host([disabled]){pointer-events:none}:host([disabled]):after{bottom:0;content:"";cursor:not-allowed;display:block;left:0;pointer-events:none;position:absolute;right:0;top:0}';class CropperCanvas extends CropperElement{constructor(){super(...arguments),this.$onPointerDown=null,this.$onPointerMove=null,this.$onPointerUp=null,this.$onWheel=null,this.$wheeling=!1,this.$pointers=new Map,this.$style=style$7,this.$action="none",this.background=!1,this.disabled=!1,this.scaleStep=.1,this.themeColor="#39f"}static get observedAttributes(){return super.observedAttributes.concat(["background","disabled","scale-step"])}connectedCallback(){super.connectedCallback(),this.disabled||this.$bind()}disconnectedCallback(){this.$unbind(),super.disconnectedCallback()}$propertyChangedCallback(t,e,i){if(!Object.is(i,e)&&(super.$propertyChangedCallback(t,e,i),"disabled"===t))i?this.$unbind():this.$bind()}$bind(){this.$onPointerDown||(this.$onPointerDown=this.$handlePointerDown.bind(this),on(this,EVENT_POINTER_DOWN,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),on(this.ownerDocument,EVENT_POINTER_MOVE,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),on(this.ownerDocument,EVENT_POINTER_UP,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),on(this,"wheel",this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(off(this,EVENT_POINTER_DOWN,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(off(this.ownerDocument,EVENT_POINTER_MOVE,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(off(this.ownerDocument,EVENT_POINTER_UP,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(off(this,"wheel",this.$onWheel,{capture:!0}),this.$onWheel=null),this.$pointers.clear(),this.style.willChange="",this.$action="none"}$addPointers(t){const{$pointers:e}=this;if(t.changedTouches)Array.from(t.changedTouches).forEach(({identifier:t,pageX:i,pageY:s})=>{e.set(t,{startX:i,startY:s,endX:i,endY:s})});else{const{pointerId:i=0,pageX:s,pageY:n}=t;e.set(i,{startX:s,startY:n,endX:s,endY:n})}}$removePointers(t){const{$pointers:e}=this;if(t.changedTouches)Array.from(t.changedTouches).forEach(({identifier:t})=>{e.delete(t)});else{const{pointerId:i=0}=t;e.delete(i)}0===e.size&&(this.style.willChange="",this.$action="none")}$handlePointerDown(t){const{buttons:e,button:i,type:s}=t;if(this.disabled||("pointerdown"===s&&"mouse"===t.pointerType||"mousedown"===s)&&(isNumber(e)&&1!==e||isNumber(i)&&0!==i||t.ctrlKey))return;this.$addPointers(t);const{$pointers:n}=this;let o="none";n.size>1?o="transform":isElement(t.target)&&(o=t.target.action||t.target.getAttribute("action")||"none"),!1!==this.$emit("actionstart",{action:o,relatedEvent:t})?(t.preventDefault(),this.$action=o,this.style.willChange="transform"):this.$removePointers(t)}$handlePointerMove(t){const{$action:e,$pointers:i}=this;if(this.disabled||"none"===e||0===i.size)return;if(!1===this.$emit("actionmove",{action:e,relatedEvent:t}))return;if(t.preventDefault(),t.changedTouches)Array.from(t.changedTouches).forEach(({identifier:t,pageX:e,pageY:s})=>{const n=i.get(t);n&&Object.assign(n,{endX:e,endY:s})});else{const{pointerId:e=0,pageX:s,pageY:n}=t,o=i.get(e);o&&Object.assign(o,{endX:s,endY:n})}const s={action:e,relatedEvent:t};if("transform"===e){const e=new Map(i);let n=0,o=0,a=0,r=0,h=t.pageX,c=t.pageY;
2i.forEach((t,i)=>{e.delete(i),e.forEach(e=>{let i=e.startX-t.startX,s=e.startY-t.startY,l=e.endX-t.endX,d=e.endY-t.endY,u=0,p=0,E=0,m=0;if(0===i?s<0?E=2*Math.PI:s>0&&(E=Math.PI):i>0?E=Math.PI/2+Math.atan(s/i):i<0&&(E=1.5*Math.PI+Math.atan(s/i)),0===l?d<0?m=2*Math.PI:d>0&&(m=Math.PI):l>0?m=Math.PI/2+Math.atan(d/l):l<0&&(m=1.5*Math.PI+Math.atan(d/l)),m>0||E>0){const i=m-E,s=Math.abs(i);s>n&&(n=s,a=i,h=(t.startX+e.startX)/2,c=(t.startY+e.startY)/2)}if(i=Math.abs(i),s=Math.abs(s),l=Math.abs(l),d=Math.abs(d),i>0&&s>0?u=Math.sqrt(i*i+s*s):i>0?u=i:s>0&&(u=s),l>0&&d>0?p=Math.sqrt(l*l+d*d):l>0?p=l:d>0&&(p=d),u>0&&p>0){const i=(p-u)/u,s=Math.abs(i);s>o&&(o=s,r=i,h=(t.startX+e.startX)/2,c=(t.startY+e.startY)/2)}})});const l=n>0,d=o>0;l&&d?(s.rotate=a,s.scale=r,s.centerX=h,s.centerY=c):l?(s.action="rotate",s.rotate=a,s.centerX=h,s.centerY=c):d?(s.action="scale",s.scale=r,s.centerX=h,s.centerY=c):s.action="none"}else{const[t]=Array.from(i.values());Object.assign(s,t)}i.forEach(t=>{t.startX=t.endX,t.startY=t.endY}),"none"!==s.action&&this.$emit("action",s)}$handlePointerUp(t){const{$action:e}=this;this.disabled?this.$removePointers(t):"none"!==e&&!1!==this.$emit("actionend",{action:e,relatedEvent:t})?(t.preventDefault(),this.$removePointers(t)):this.$removePointers(t)}$handleWheel(t){if(this.disabled)return;if(t.preventDefault(),this.$wheeling)return;this.$wheeling=!0,setTimeout(()=>{this.$wheeling=!1},50);const e=(t.deltaY>0?-1:1)*this.scaleStep;this.$emit("action",{action:"scale",scale:e,relatedEvent:t})}$setAction(t){return isString(t)&&(this.$action=t),this}$toCanvas(t){return new Promise((e,i)=>{if(!this.isConnected)return void i(new Error("The current element is not connected to the DOM."));const s=document.createElement("canvas");let n=this.offsetWidth,o=this.offsetHeight,a=1;isPlainObject(t)&&(isPositiveNumber(t.width)||isPositiveNumber(t.height))&&(({width:n,height:o}=getAdjustedSizes({aspectRatio:n/o,width:t.width,height:t.height})),a=n/this.offsetWidth),s.width=n,s.height=o;const r=this.querySelector(this.$getTagNameOf(CROPPER_IMAGE));r?r.$ready().then(i=>{const h=s.getContext("2d");if(h){const[e,c,l,d,u,p]=r.$getTransform();let E=u,m=p,$=i.naturalWidth,g=i.naturalHeight;1!==a&&(E*=a,m*=a,$*=a,g*=a);const C=$/2,b=g/2;h.fillStyle="transparent",h.fillRect(0,0,n,o),isPlainObject(t)&&isFunction(t.beforeDraw)&&t.beforeDraw.call(this,h,s),h.save(),h.translate(C,b),h.transform(e,c,l,d,E,m),h.translate(-C,-b),h.drawImage(i,0,0,$,g),h.restore(
vendor: 5,013 bytes, line 2
2)}e(s)}).catch(i):e(s)})}}CropperCanvas.$name=CROPPER_CANVAS,CropperCanvas.$version="2.2.0";var style$6=":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}";const canvasCache$3=new WeakMap,NATIVE_ATTRIBUTES=["alt","crossorigin","decoding","elementtiming","fetchpriority","loading","referrerpolicy","sizes","src","srcset"];class CropperImage extends CropperElement{constructor(){super(...arguments),this.$isReady=!1,this.$matrix=[1,0,0,1,0,0],this.$onLoad=null,this.$onCanvasAction=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$actionStartTarget=null,this.$style=style$6,this.$image=new Image,this.initialCenterSize="",this.initialFit=OBJECT_FIT_CONTAIN,this.maxFit="",this.minFit="",this.rotatable=!1,this.scalable=!1,this.skewable=!1,this.slottable=!1,this.translatable=!1,this.alt="",this.crossorigin="",this.decoding="",this.elementtiming="",this.fetchpriority="",this.loading="",this.referrerpolicy="",this.sizes="",this.src="",this.srcset=""}set $canvas(t){canvasCache$3.set(this,t)}get $canvas(){return canvasCache$3.get(this)}static get observedAttributes(){return super.observedAttributes.concat(NATIVE_ATTRIBUTES,["initial-center-size","initial-fit","max-fit","min-fit","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(t,e,i){Object.is(i,e)||(super.attributeChangedCallback(t,e,i),NATIVE_ATTRIBUTES.includes(t)&&(null===i?this.$image.removeAttribute(t):this.$image.setAttribute(t,i)))}$propertyChangedCallback(t,e,i){if(!Object.is(i,e))switch(super.$propertyChangedCallback(t,e,i),t){case"initialCenterSize":case"initialFit":this.$nextTick(()=>{this.$isReady&&this.$canvas&&this.$center(i)});break;case"maxFit":case"minFit":this.$nextTick(()=>{this.$isReady&&this.$canvas&&(this.$resetTransform(),this.$center(this.initialCenterSize||this.initialFit))});break;case"src":this.$isReady=!1}}connectedCallback(){super.connectedCallback();const{$image:t}=this,e=this.closest(this.$getTagNameOf(CROPPER_CANVAS));e&&(this.$canvas=e,this.$setStyles({display:"block",position:"absolute"}),this.$onCanvasActionStart=t=>{var e,i;t.defaultPrevented||(this.$actionStartTarget=null===(i=null===(e=t.detail)||void 0===e?void 0:e.relatedEvent)||void 0===i?void 0:i.target)},this.$onCanvasActionEnd=()=>{this.$actionStartTarget=null},this.$onCanvasAction=this.$handleAction.bind(this),on(e,"actionstart",this.$onCanvasActionStart),on(e,"actionend",this.$onCanvasActionEnd),on(e,"action",this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),on(t,"load",this.$onLoad),this.$getShadowRoot().appendChild(t)}disconnectedCallback(){const{$image:t,$canvas:e}=this;e&&(this.$onCanvasActionStart&&(off(e,"actionstart",this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(off(e,"actionend",this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(off(e,"action",this.$onCanvasAction),this.$onCanvasAction=null)),t&&this.$onLoad&&(off(t,"load",this.$onLoad),this.$onLoad=null),this.$getShadowRoot().removeChild(t),super.disconnectedCallback()}$handleLoad(){const{$image:t}=this;this.$setStyles({width:t.naturalWidth,height:t.naturalHeight}),this.$canvas&&this.$center(this.initialCenterSize||this.initialFit),this.$isReady=!0}$handleAction(t){if(t.defaultPrevented||this.hidden||!(this.rotatable||this.scalable||this.translatable))return;const{$canvas:e}=this,{detail:i}=t;if(i){const{relatedEvent:t}=i;let{action:s}=i;switch("transform"!==s||this.rotatable&&this.scalable||(s=this.rotatable?"rotate":this.scalable?"scale":"none"),s){case"move":if(this.translatable){let s=null;t&&(s=t.target.closest(this.$getTagNameOf(CROPPER_SELECTION))),s||(s=e.querySelector(this.$getTagNameOf(CROPPER_SELECTION))),s&&s.multiple&&!s.active&&(s=e.querySelector(`${this.$getTagNameOf(CROPPER_SELECTION)}[active]`)),s&&!s.hidden&&s.movable&&!s.dynamic&&this.$actionStartTarget&&s.contains(this.$actionStartTarget)||this.$move(i.endX-i.startX,i.endY-i.startY)}break;case"rotate":if(this.rotatable)if(t){const{x:e,y:s}=this.getBoundingClientRect();this.$rotate(i.rotate,t.clientX-e,t.clientY-s)}else this.$rotate(i.rotate);break;case"scale":if(this.scalable)if(t){const e=t.target.closest(this.$getTagNameOf(CROPPER_SELECTION));if(!e||!e.zoomable||e.zoomable&&e.dynamic){const{x:e,y:s}=this.getBoundingClientRect();this.$zoom(i.scale,t.clientX-e,t.clientY-s)}}else this.$zoom(i.scale);break;case"transform":if(this.rotatable&&this.scalable){const{rotate:e}=i;let{scale:s}=i;s<0?s=1/(1-s):s+=1;const n=Math.cos(e),o=Math.sin(e),[a,r,h,c]=[n*s,o*s,-o*s,n*s];if(t){const e=this.getBoundingClientRect(),i=t.clientX-e.x,s=t.clientY-e.y,[n,o,l,d]=this.$matrix,u=i-e.width/2,p=s-e.height/2,E=(u*d-l*p)/(n*d-l*o),m=(p*n-o*u)/(n*d-l*o);this.$transform(a,r,h,c,E*(1-a)+m*h,m*(1-c)+E*r)}else this.$transform(a,r,h,c,0,0)}}}}$ready(t){const{$image:e}=this,i=new Promise((t,i)=>{const s=new Error("Failed to load the image source");
2if(e.complete)e.naturalWidth>0&&e.naturalHeight>0?t(e):i(s);else{const n=()=>{off(e,"error",o),setTimeout(()=>{t(e)})},o=()=>{off(e,"load",n),i(s)};once(e,"load",n),once(e,"error",o)}});return isFunction(t)&&i.then(e=>(t(e),e)),i}$center(t){const{parentElement:e}=this;if(!e)return this;const i=e.getBoundingClientRect(),s=i.width,n=i.height,{x:o,y:a,width:r,height:h}=this.getBoundingClientRect(),c=o+r/2,l=a+h/2,d=i.x+s/2,u=i.y+n/2,{translatable:p}=this;p||this.$isReady||(this.translatable=!0,this.$nextTick(()=>{this.translatable=p})),this.$move(d-c,u-l);const{maxFit:E,minFit:m}=this;if(t||E||m){const{naturalWidth:e,naturalHeight:i}=this.$image;switch(t){case OBJECT_FIT_COVER:[OBJECT_FIT_FILL,OBJECT_FIT_CONTAIN,OBJECT_FIT_SCALE_DOWN].includes(E)||"none"===E&&(e<s||i<n)?t=E:"none"===m&&e>s&&i>n&&(t=m);break;case OBJECT_FIT_FILL:[OBJECT_FIT_CONTAIN,OBJECT_FIT_SCALE_DOWN].includes(E)||"none"===E&&(e<s||i<n)?t=E:(m===OBJECT_FIT_COVER||"none"===m&&e>s&&i>n)&&(t=m);break;case OBJECT_FIT_CONTAIN:E===OBJECT_FIT_SCALE_DOWN||"none"===E&&e<s&&i<n?t=E:([OBJECT_FIT_COVER,OBJECT_FIT_FILL].includes(m)||"none"===m&&(e>s||i>n))&&(t=m);break;case OBJECT_FIT_SCALE_DOWN:"none"===E&&e<s&&i<n?t=E:([OBJECT_FIT_COVER,OBJECT_FIT_FILL,OBJECT_FIT_CONTAIN].includes(m)||"none"===m&&e>s&&i>n)&&(t=m);break;default:[OBJECT_FIT_COVER,OBJECT_FIT_FILL,OBJECT_FIT_CONTAIN,OBJECT_FIT_SCALE_DOWN].includes(E)&&(e>s||i>n)?t=E:[OBJECT_FIT_COVER,OBJECT_FIT_FILL,OBJECT_FIT_CONTAIN,OBJECT_FIT_SCALE_DOWN].includes(m)&&e<s&&i<n&&(t=m)}const o=s/r,a=n/h,{scalable:c}=this;switch(c||this.$isReady||(this.scalable=!0,this.$nextTick(()=>{this.scalable=c})),t){case OBJECT_FIT_COVER:this.$scale(Math.max(o,a));break;case OBJECT_FIT_CONTAIN:this.$scale(Math.min(o,a));break;case OBJECT_FIT_FILL:this.$scale(o,a);break;case OBJECT_FIT_SCALE_DOWN:this.$scale(Math.min(o,a,1));break;case"none":this.$scale(1)}}return this}$move(t,e=t){if(this.translatable&&isNumber(t)&&isNumber(e)){const[i,s,n,o]=this.$matrix,a=(t*o-n*e)/(i*o-n*s),r=(e*i-s*t)/(i*o-n*s);this.$translate(a,r)}return this}$moveTo(t,e=t){if(this.translatable&&isNumber(t)&&isNumber(e)){const[i,s,n,o]=this.$matrix,a=(t*o-n*e)/(i*o-n*s),r=(e*i-s*t)/(i*o-n*s);this.$setTransform(i,s,n,o,a,r)}return this}$rotate(t,e,i){if(this.rotatable){const s=toAngleInRadian(t),n=Math.cos(s),o=Math.sin(s),[a,r,h,c]=[n,o,-o,n];if(isNumber(e)&&isNumber(i)){const[t,s,n,o]=this.$matrix,{width:l,height:d}=this.getBoundingClientRect(),u=e-l/2,p=i-d/2,E=(u*o-n*p)/(t*o-n*s),m=(p*t-s*u)/(t*o-n*s);this.$transform(a,r,h,c,E*(1-a)-m*h,m*(1-c)-E*r)}else this.$transform(a,r,h,c,0,0)}return this}$zoom(t,e,i){if(!this.scalable||0===t)return this;if(t<0?t=1/(1-t):t+=1,isNumber(e)&&isNumber(i)){const[s,n,o,a]=this.$matrix,{width:r,height:h}=this.getBoundingClientRect(),c=e-r/2,l=i-h/2,d=(c*a-o*l)/(s*a-o*n),u=(l*s-n*c)/(s*a-o*n);this.$transform(t,0,0,t,d*(1-t),u*(1-t))}else this.$scale(t);return this}$scale(t,e=t){return this.scalable&&this.$transform(t,0,0,e,0,0),this}$skew(t,e=0){if(this.skewable){const i=toAngleInRadian(t),s=toAngleInRadian(e);this.$transform(1,Math.tan(s),Math.tan(i),1,0,0)}return this}$translate(t,e=t){return this.translatable&&isNumber(t)&&isNumber(e)&&this.$transform(1,0,0,1,t,e),this}$transform(t,e,i,s,n,o){return isNumber(t)&&isNumber(e)&&isNumber(i)&&isNumber(s)&&isNumber(n)&&isNumber(o)?this.$setTransform(multiplyMatrices(this.$matrix,[t,e,i,s,n,o])):this}$setTransform(t,e,i,s,n,o){if((this.rotatable||this.scalable||this.skewable||this.translatable)&&(Array.isArray(t)&&([t,e,i,s,n,o]=t),isNumber(t)&&isNumber(e)&&isNumber(i)&&isNumber(s)&&isNumber(n)&&isNumber(o))){const a=[...this.$matrix],r=[t,e,i,s,n,o];if(this.$isReady&&this.$canvas){const{$canvas:t}=this,e=t.getBoundingClientRect();this.style.transform=`matrix(${r.join(", ")})`;const i=this.$image.getBoundingClientRect();this.style.transform=`matrix(${a.join(", ")})`;let{maxFit:s,minFit:n}=this;if(s||n){if(i.top>e.bottom||i.right<e.left||i.bottom<e.top||i.left>e.right)return this;const{naturalWidth:t,naturalHeight:o}=this.$image;switch(s===OBJECT_FIT_SCALE_DOWN&&(s=t>=e.width||o>=e.height?OBJECT_FIT_CONTAIN:"none"),s){case OBJECT_FIT_COVER:if(i.width>e.width&&i.height>e.height)return this;break;
vendor: 4,542 bytes, line 2
2case OBJECT_FIT_FILL:case OBJECT_FIT_CONTAIN:if(i.width>e.width||i.height>e.height)return this;break;case"none":if(i.width>t||i.height>o)return this}switch(n===OBJECT_FIT_SCALE_DOWN&&(n=t>=e.width||o>=e.height?OBJECT_FIT_CONTAIN:"none"),n){case OBJECT_FIT_COVER:case OBJECT_FIT_FILL:if(i.width<e.width||i.height<e.height)return this;break;case OBJECT_FIT_CONTAIN:if(i.width<e.width&&i.height<e.height)return this;break;case"none":if(i.width<t||i.height<o)return this}}if(!1===this.$emit("change",{x:i.x-e.x,y:i.y-e.y,width:i.width,height:i.height}))return this}if(!1===this.$emit("transform",{matrix:r,oldMatrix:a}))return this;this.$matrix=r,this.style.transform=`matrix(${r.join(", ")})`}return this}$getTransform(){return this.$matrix.slice()}$resetTransform(){return this.$setTransform([1,0,0,1,0,0])}}CropperImage.$name=CROPPER_IMAGE,CropperImage.$version="2.2.0";var style$5=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}";const canvasCache$2=new WeakMap;class CropperShade extends CropperElement{constructor(){super(...arguments),this.$onWindowResize=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$onSelectionChange=null,this.$style=style$5,this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(t){canvasCache$2.set(this,t)}get $canvas(){return canvasCache$2.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const t=this.closest(this.$getTagNameOf(CROPPER_CANVAS));if(t){this.$canvas=t,this.style.position="absolute";const e=t.querySelector(this.$getTagNameOf(CROPPER_SELECTION));e&&(this.$onWindowResize=this.$render.bind(this),this.$onCanvasActionStart=t=>{e.hidden&&"select"===t.detail.action&&(this.hidden=!1)},this.$onCanvasActionEnd=t=>{e.hidden&&"select"===t.detail.action&&(this.hidden=!0)},this.$onSelectionChange=t=>{var i,s;if((null===(s=null===(i=t.target)||void 0===i?void 0:i.constructor)||void 0===s?void 0:s.$name)!==CROPPER_SELECTION)return;const{x:n,y:o,width:a,height:r}=t.defaultPrevented?e:t.detail;this.$change(n,o,a,r),(e.hidden||0===n&&0===o&&0===a&&0===r)&&(this.hidden=!0)},on(window,"resize",this.$onWindowResize),on(t,"actionstart",this.$onCanvasActionStart),on(t,"actionend",this.$onCanvasActionEnd),on(t,"change",this.$onSelectionChange))}this.$render()}disconnectedCallback(){const{$canvas:t}=this;t&&(this.$onWindowResize&&(off(window,"resize",this.$onWindowResize),this.$onWindowResize=null),this.$onCanvasActionStart&&(off(t,"actionstart",this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(off(t,"actionend",this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onSelectionChange&&(off(t,"change",this.$onSelectionChange),this.$onSelectionChange=null)),super.disconnectedCallback()}$change(t,e,i=this.width,s=this.height){return isNumber(t)&&isNumber(e)&&isNumber(i)&&isNumber(s)&&(t!==this.x||e!==this.y||i!==this.width||s!==this.height)?(this.hidden&&(this.hidden=!1),this.x=t,this.y=e,this.width=i,this.height=s,this.$render()):this}$reset(){return this.$change(0,0,0,0)}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height,outlineWidth:WINDOW.innerWidth*WINDOW.devicePixelRatio})}}CropperShade.$name=CROPPER_SHADE,CropperShade.$version="2.2.0";var style$4=':host{background-color:var(--theme-color);display:block}:host([action=move]),:host([action=select]){height:100%;left:0;position:absolute;top:0;width:100%}:host([action=move]){cursor:move}:host([action=select]){cursor:crosshair}:host([action$=-resize]){background-color:transparent;height:15px;position:absolute;width:15px}:host([action$=-resize]):after{background-color:var(--theme-color);content:"";display:block;height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:5px}:host([action=n-resize]),:host([action=s-resize]){cursor:ns-resize;left:50%;transform:translateX(-50%);width:100%}:host([action=n-resize]){top:-8px}:host([action=s-resize]){bottom:-8px}:host([action=e-resize]),:host([action=w-resize]){cursor:ew-resize;height:100%;top:50%;transform:translateY(-50%)}:host([action=e-resize]){right:-8px}:host([action=w-resize]){left:-8px}:host([action=ne-resize]){cursor:nesw-resize;right:-8px;top:-8px}:host([action=nw-resize]){cursor:nwse-resize;left:-8px;top:-8px}:host([action=se-resize]){bottom:-8px;
2cursor:nwse-resize;right:-8px}:host([action=se-resize]):after{height:15px;width:15px}@media (pointer:coarse){:host([action=se-resize]):after{height:10px;width:10px}}@media (pointer:fine){:host([action=se-resize]):after{height:5px;width:5px}}:host([action=sw-resize]){bottom:-8px;cursor:nesw-resize;left:-8px}:host([plain]){background-color:transparent}';class CropperHandle extends CropperElement{constructor(){super(...arguments),this.$onCanvasCropEnd=null,this.$onCanvasCropStart=null,this.$style=style$4,this.action="none",this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}CropperHandle.$name=CROPPER_HANDLE,CropperHandle.$version="2.2.0";var style$3=':host{display:block;left:0;position:relative;right:0}:host([outlined]){outline:1px solid var(--theme-color)}:host([multiple]){outline:1px dashed hsla(0,0%,100%,.5)}:host([multiple]):after{bottom:0;content:"";cursor:pointer;display:block;left:0;position:absolute;right:0;top:0}:host([multiple][active]){outline-color:var(--theme-color);z-index:1}:host([multiple])>*{visibility:hidden}:host([multiple][active])>*{visibility:visible}:host([multiple][active]):after{display:none}';const canvasCache$1=new WeakMap;class CropperSelection extends CropperElement{constructor(){super(...arguments),this.$onCanvasAction=null,this.$onCanvasActionStart=null,this.$onCanvasActionEnd=null,this.$onDocumentKeyDown=null,this.$action="",this.$actionStartTarget=null,this.$changing=!1,this.$style=style$3,this.$initialSelection={x:0,y:0,width:0,height:0},this.x=0,this.y=0,this.width=0,this.height=0,this.aspectRatio=NaN,this.initialAspectRatio=NaN,this.initialCoverage=NaN,this.active=!1,this.linked=!1,this.dynamic=!1,this.movable=!1,this.resizable=!1,this.zoomable=!1,this.multiple=!1,this.keyboard=!1,this.outlined=!1,this.precise=!1}set $canvas(t){canvasCache$1.set(this,t)}get $canvas(){return canvasCache$1.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["active","aspect-ratio","dynamic","height","initial-aspect-ratio","initial-coverage","keyboard","linked","movable","multiple","outlined","precise","resizable","width","x","y","zoomable"])}$propertyChangedCallback(t,e,i){if(!Object.is(i,e))switch(super.$propertyChangedCallback(t,e,i),t){case"x":case"y":case"width":case"height":this.$changing||this.$nextTick(()=>{this.$change(this.x,this.y,this.width,this.height,this.aspectRatio,!0)});break;case"aspectRatio":case"initialAspectRatio":this.$nextTick(()=>{this.$initSelection()});break;case"initialCoverage":this.$nextTick(()=>{isPositiveNumber(i)&&i<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(i?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),on(this.ownerDocument,"keydown",this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(off(this.ownerDocument,"keydown",this.$onDocumentKeyDown),this.$onDocumentKeyDown=null))});break;case"multiple":this.$nextTick(()=>{if(this.$canvas){const t=this.$getSelections();i?(t.forEach(t=>{t.active=!1}),this.active=!0,this.$emit("change",{x:this.x,y:this.y,width:this.width,height:this.height})):(this.active=!1,t.slice(1).forEach(t=>{this.$removeSelection(t)}))}});break;case"precise":this.$nextTick(()=>{this.$change(this.x,this.y)});break;case"linked":i&&(this.dynamic=!0)}}connectedCallback(){super.connectedCallback();const t=this.closest(this.$getTagNameOf(CROPPER_CANVAS));t?(this.$canvas=t,this.$setStyles({position:"absolute",transform:`translate(${this.x}px, ${this.y}px)`}),this.hidden||this.$render(),this.$initSelection(!0),this.$onCanvasActionStart=this.$handleActionStart.bind(this),this.$onCanvasActionEnd=this.$handleActionEnd.bind(this),this.$onCanvasAction=this.$handleAction.bind(this),on(t,"actionstart",this.$onCanvasActionStart),on(t,"actionend",this.$onCanvasActionEnd),on(t,"action",this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:t}=this;t&&(this.$onCanvasActionStart&&(off(t,"actionstart",this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(off(t,"actionend",this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(off(t,"action",this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let t=[];return this.parentElement&&(t=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(CROPPER_SELECTION)))),t}$initSelection(t=!1,e=!1){const{initialCoverage:i,parentElement:s}=this;if(isPositiveNumber(i)&&s){const n=this.aspectRatio||this.initialAspectRatio;let o=(e?0:this.width)||s.offsetWidth*i,a=(e?0:this.height)||s.offsetHeight*i;isPositiveNumber(n)&&({width:o,height:a}=getAdjustedSizes({aspectRatio:n,width:o,height:a})),this.$change(this.x,this.y,o,a),t&&this.$center(),this.$initialSelection={x:this.x,y:this.y,width:this.width,height:this.height}}}$createSelection(){const t=this.cloneNode(!0);return this.hasAttribute("id")&&t.removeAttribute("id"),t.initialCoverage=NaN,this.active=!1,this.parentElement&&this.parentElement.insertBefore(t,this.nextSibling),t}$removeSelection(t=this){if(this.parentElement){const e=this.$getSelections();if(e.length>1){const i=e.indexOf(t),s=e[i+1]||e[i-1];s&&(t.active=!1,this.parentElement.removeChild(t),s.active=!0,s.$emit("change",{x:s.x,y:s.y,width:s.width,height:s.height}))}else this.$clear()}}$handleActionStart(t){var e,i;if(t.defaultPrevented)return;const s=null===(i=null===(e=t.detail)||void 0===e?void 0:e.relatedEvent)||void 0===i?void 0:i.target;this.$action="",this.$actionStartTarget=s,!this.hidden&&this.multiple&&!this.active&&s===this&&this.parentElement&&(this.$getSelections().forEac
vendor: 15,846 bytes, line 2
2h(t=>{t.active=!1}),this.active=!0,this.$emit("change",{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(t){const{currentTarget:e,detail:i}=t;if(t.defaultPrevented||!e||!i)return;const{relatedEvent:s}=i;let{action:n}=i;const o=s?getComposedPathTarget(s):null;if(!n&&this.multiple&&(n=this.$action||(null==o?void 0:o.action),this.$action=n),!n||this.hidden&&"select"!==n||this.multiple&&!this.active&&"scale"!==n)return;const{width:a,height:r}=this;let h=i.endX-i.startX,c=i.endY-i.startY,{aspectRatio:l}=this;switch(!isPositiveNumber(l)&&s.shiftKey&&(l=isPositiveNumber(a)&&isPositiveNumber(r)?a/r:1),n){case"select":if(0!==h||0!==c){0===h?h=c:0===c&&(c=h);const{$canvas:t}=this,s=getOffset(e);(this.multiple&&!this.hidden?this.$createSelection():this).$change(i.startX-s.left,i.startY-s.top,Math.abs(h),Math.abs(c),l),h<0?c<0?n="nw-resize":c>0&&(n="sw-resize"):h>0&&(c<0?n="ne-resize":c>0&&(n="se-resize")),t&&(t.$action=n)}break;case"move":this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(h,c);break;case"scale":case"transform":if(s&&this.zoomable&&(this.dynamic||this.contains(s.target))){const t=getOffset(e);this.$zoom(i.scale,s.pageX-t.left,s.pageY-t.top)}break;default:this.$resize(n,h,c,l)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(t){if(t.defaultPrevented||this.hidden||!this.keyboard||this.multiple&&!this.active)return;const{activeElement:e}=document;if(!e||!["INPUT","TEXTAREA"].includes(e.tagName)&&!["true","plaintext-only"].includes(e.contentEditable))switch(t.key){case"Backspace":t.metaKey&&(t.preventDefault(),this.$removeSelection());break;case"Delete":t.preventDefault(),this.$removeSelection();break;case"ArrowLeft":t.preventDefault(),this.$move(-1,0);break;case"ArrowRight":t.preventDefault(),this.$move(1,0);break;case"ArrowUp":t.preventDefault(),this.$move(0,-1);break;case"ArrowDown":t.preventDefault(),this.$move(0,1);break;case"+":t.preventDefault(),this.$zoom(.1);break;case"-":t.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:t}=this;if(!t)return this;const e=(t.offsetWidth-this.width)/2,i=(t.offsetHeight-this.height)/2;return this.$change(e,i)}$move(t,e=t){return this.$moveTo(this.x+t,this.y+e)}$moveTo(t,e=t){return this.movable?this.$change(t,e):this}$resize(t,e=0,i=0,s=this.aspectRatio){if(!this.resizable)return this;const n=isPositiveNumber(s),{$canvas:o}=this;let{x:a,y:r,width:h,height:c}=this;switch(t){case"n-resize":r+=i,c-=i,c<0&&(t="s-resize",c=-c,r-=c),n&&(a+=(e=i*s)/2,h-=e,h<0&&(h=-h,a-=h));break;case"e-resize":h+=e,h<0&&(t="w-resize",h=-h,a-=h),n&&(r-=(i=e/s)/2,c+=i,c<0&&(c=-c,r-=c));break;case"s-resize":c+=i,c<0&&(t="n-resize",c=-c,r-=c),n&&(a-=(e=i*s)/2,h+=e,h<0&&(h=-h,a-=h));break;case"w-resize":a+=e,h-=e,h<0&&(t="e-resize",h=-h,a-=h),n&&(r+=(i=e/s)/2,c-=i,c<0&&(c=-c,r-=c));break;case"ne-resize":n&&(i=-e/s),r+=i,c-=i,h+=e,h<0&&c<0?(t="sw-resize",h=-h,c=-c,a-=h,r-=c):h<0?(t="nw-resize",h=-h,a-=h):c<0&&(t="se-resize",c=-c,r-=c);break;case"nw-resize":n&&(i=e/s),a+=e,r+=i,h-=e,c-=i,h<0&&c<0?(t="se-resize",h=-h,c=-c,a-=h,r-=c):h<0?(t="ne-resize",h=-h,a-=h):c<0&&(t="sw-resize",c=-c,r-=c);break;case"se-resize":n&&(i=e/s),h+=e,c+=i,h<0&&c<0?(t="nw-resize",h=-h,c=-c,a-=h,r-=c):h<0?(t="sw-resize",h=-h,a-=h):c<0&&(t="ne-resize",c=-c,r-=c);break;case"sw-resize":n&&(i=-e/s),a+=e,h-=e,c+=i,h<0&&c<0?(t="ne-resize",h=-h,c=-c,a-=h,r-=c):h<0?(t="se-resize",h=-h,a-=h):c<0&&(t="nw-resize",c=-c,r-=c)}return o&&o.$setAction(t),this.$change(a,r,h,c)}$zoom(t,e,i){if(!this.zoomable||0===t)return this;t<0?t=1/(1-t):t+=1;const{width:s,height:n}=this,o=s*t,a=n*t;let r=this.x,h=this.y;return isNumber(e)&&isNumber(i)?(r-=(o-s)*((e-this.x)/s),h-=(a-n)*((i-this.y)/n)):(r-=(o-s)/2,h-=(a-n)/2),this.$change(r,h,o,a)}$change(t,e,i=this.width,s=this.height,n=this.aspectRatio,o=!1){return this.$changing||!isNumber(t)||!isNumber(e)||!isNumber(i)||!isNumber(s)||i<0||s<0?this:(isPositiveNumber(n)&&({width:i,height:s}=getAdjustedSizes({aspectRatio:n,width:i,height:s},"cover")),this.precise||(t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s)),t===this.x&&e===this.y&&i===this.width&&s===this.height&&Object.is(n,this.aspectRatio)&&!o?this:(this.hidden&&(this.hidden=!1),!1===this.$emit("change",{x:t,y:e,width:i,height:s})?this:(this.$changing=!0,this.x=t,this.y=e,this.width=i,this.height=s,this.$changing=!1,this.$render())))}$reset(){const{x:t,y:e,width:i,height:s}=this.$initialSelection;return this.$change(t,e,i,s)}$clear(){return this.$change(0,0,0,0,NaN,!0),this.hidden=!0,this}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height})}$toCanvas(t){return new Promise((e,i)=>{if(!this.isConnected)return void i(new Error("The current element is not connected to the DOM."));const s=document.createElement("canvas");let{width:n,height:o}=this,a=1;if(isPlainObject(t)&&(isPositiveNumber(t.width)||isPositiveNumber(t.height))&&(({width:n,height:o}=getAdjustedSizes({aspectRatio:n/o,width:t.width,height:t.height})),a=n/this.width),s.width=n,s.height=o,!this.$canvas)return void e(s);const r=this.$canvas.querySelector(this.$getTagNameOf(CROPPER_IMAGE));r?r.$ready().then(i=>{const h=s.getContext("2d");if(h){const[e,c,l,d,u,p]=r.$getTransform(),E=-this.x,m=-this.y,$=(E*d-l*m)/(e*d-l*c),g=(m*e-c*E)/(e*d-l*c);let C=e*$+l*g+u,b=c*$+d*g+p,T=i.naturalWidth,f=i.naturalHeight;1!==a&&(C*=a,b*=a,T*=a,f*=a);const v=T/2,O=f/2;h.fillStyle="transparent",h.fillRect(0,0,n,o),isPlainObject(t)&&isFunction(t.beforeDraw)&&t.beforeDraw.call(this,h,s),h.save(),h.translate(v,O),h.transform(e,c,l,d,C,b),h.translate(-v,-O),h.drawImage(i,0,0,T,f),h.restore()}e(s)}).catch(i):e(s)})}}CropperSelection.$name=CROPPER_SELECTION,CropperSelection.$version="2.2.0";var style$2=":host{display:flex;flex-direction:column;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([bordered]){border:1px dashed var(--theme-color)}:host([covered]){bottom:0;left:0;position:absolute;right:0;top:0}:host>span{display:flex;flex:1}:host>span+span{border-top:1px dashed var(--theme-color)}:host>span>span{flex:1}:host>span>span+span{border-left:1px dashed var(--theme-color)}";class CropperGrid extends CropperElement{constructor(){super(...arguments),this.$style=style$2,this.bordered=!1,this.columns=3,this.covered=!1,this.rows=3,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["bordered","columns","covered","rows"])}$propertyChangedCallback(t,e,i){Object.is(i,e)||(super.$propertyChangedCallback(t,e,i),"rows"!==t&&"columns"!==t||this.$nextTick(()=>{this.$render()}))}connectedCallback(){super.connectedCallback(),this.$render()}$render(){const t=this.$getShadowRoot(),e=document.createDocumentFragment();for(let t=0;t<this.rows;t+=1){const t=document.createElement("span");t.setAttribute("data-cropper-grid-row",""),t.setAttribute("role","row");for(let e=0;e<this.columns;e+=1){const e=document.createElement("span");e.setAttribute("role","gridcell"),t.appendChild(e)}e.appendChild(t)}t&&(t.querySelectorAll("[data-cropper-grid-row]").forEach(t=>t.remove()),t.appendChild(e))}}CropperGrid.$name=CROPPER_GIRD,CropperGrid.$version="2.2.0";var style$1=':host{display:inline-block;height:1em;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1em}:host:after,:host:before{background-color:var(--theme-color);content:"";display:block;position:absolute}:host:before{height:1px;left:0;top:50%;transform:translateY(-50%);width:100%}:host:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:1px}:host([centered]){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}';class CropperCrosshair extends CropperElement{constructor(){super(...arguments),this.$style=style$1,this.centered=!1,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["centered"])}}CropperCrosshair.$name=CROPPER_CROSSHAIR,CropperCrosshair.$version="2.2.0";var style=":host{display:block;height:100%;overflow:hidden;position:relative;width:100%}";const canvasCache=new WeakMap,imageCache=new WeakMap,selectionCache=new WeakMap,sourceImageCache=new WeakMap,RESIZE_BOTH="both",RESIZE_HORIZONTAL="horizontal",RESIZE_VERTICAL="vertical",RESIZE_NONE="none";class CropperViewer extends CropperElement{constructor(){super(...arguments),this.$onSelectionChange=null,this.$onSourceImageLoad=null,this.$onSourceImageTransform=null,this.$scale=1,this.$style=style,this.resize="vertical",this.selection="",this.slottable=!1}set $image(t){imageCache.set(this,t)}get $image(){return imageCache.get(this)}set $sourceImage(t){sourceImageCache.set(this,t)}get $sourceImage(){return sourceImageCache.get(this)}set $canvas(t){canvasCache.set(this,t)}get $canvas(){return canvasCache.get(this)}set $selection(t){selectionCache.set(this,t)}get $selection(){return selectionCache.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){var t,e;super.connectedCallback();let i=null;if(i=this.selection?null!==(e=null===(t=getRootDocument(this))||void 0===t?void 0:t.querySelector(this.selection))&&void 0!==e?e:null:this.closest(this.$getTagNameOf(CROPPER_SELECTION)),isElement(i)){this.$selection=i,this.$onSelectionChange=this.$handleSelectionChange.bind(this),on(i,"change",this.$onSelectionChange);const t=i.closest(this.$getTagNameOf(CROPPER_CANVAS));if(t){this.$canvas=t;const e=t.querySelector(this.$getTagNameOf(CROPPER_IMAGE));e&&(this.$sourceImage=e,this.$image=e.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),on(e.$image,"load",this.$onSourceImageLoad),on(e,"transform",this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$image:t,$selection:e,$sourceImage:i}=this;e&&this.$onSelectionChange&&(off(e,"change",this.$onSelectionChange),this.$onSelectionChange=null),i&&this.$onSourceImageLoad&&(off(i.$image,"load",this.$onSourceImageLoad),this.$onSourceImageLoad=null),i&&this.$onSourceImageTransform&&(off(i,"transform",this.$onSourceImageTransform),this.$onSourceImageTransform=null);const s=this.$getShadowRoot();t&&(null==s?void 0:s.contains(t))&&s.removeChild(t),super.disconnectedCallback()}$handleSelectionChange(t){this.$render(t.defaultPrevented?this.$selection:t.detail)}$handleSourceImageLoad(){const{$image:t,$sourceImage:e}=this,i=t.getAttribute("src"),s=e.getAttribute("src");s&&s!==i&&(t.setAttribute("src",s),t.$ready(()=>{this.$render()}))}$handleSourceImageTransform(t){this.$render(void 0,t.detail.matrix)}$render(t,e){const{$canvas:i,$selection:s}=this;t||s.hidden||(t=s),(!t||0===t.x&&0===t.y&&0===t.width&&0===t.height)&&(t={x:0,y:0,width:i.offsetWidth,height:i.offsetHeight});const{x:n,y:o,width:a,height:r}=t,h={},{clientWidth:c,clientHeight:l}=this;let d=c,u=l,p=NaN;switch(this.resize){case"both":p=1,d=a,u=r,h.width=a,h.height=r;break;case"horizontal":p=r>0?l/r:0,d=a*p,h.width=d;break;case"vertical":p=a>0?c/a:0,u=r*p,h.height=u;break;default:c>0?p=a>0?c/a:0:l>0&&(p=r>0?l/r:0)}this.$scale=p,this.$setStyles(h),this.$sourceImage&&setTimeout(()=>{this.$transformImageByOffset(null!=e?e:this.$sourceImage.$getTransform(),-n,-o)})}$transformImageByOffset(t,e,i){const{$image:s,$scale:n,$sourceImage:o}=this;if(o&&s&&n>=0){const[a,r,h,c,l,d]=t,u=(e*c-h*i)/(a*c-h*r),p=(i*a-r*e)/(a*c-h*r),E=a*u+h*p+l,m=r*u+c*p+d;o.$ready(t=>{this.$setStyles.call(s,{width:t.naturalWidth*n,height:t.naturalHeight*n})}),s.$setTransform(a,r,h,c,E*n,m*n)}}}CropperViewer.$name=CROPPER_VIEWER,CropperViewer.$version="2.2.0";var DEFAULT_TEMPLATE='<cropper-canvas background><cropper-image rotatable scalable skewable translatable></cropper-image><cropper-shade hidden></cropper-shade><cropper-handle action="select" plain></cropper-handle><cropper-selection initial-coverage="0.5" movable resizable><cropper-grid role="grid" bordered covered></cropper-grid><cropper-crosshair centered></cropper-crosshair><cropper-handle action="move" theme-color="rgba(255, 255, 255, 0.35)"></cropper-handle><cropper-handle action="n-resize"></cropper-handle><cropper-handle action="e-resize"></cropper-handle><cropper-handle action="s-resize"></cropper-handle><cropper-handle action="w-resize"></cropper-handle><cropper-handle action="ne-resize"></cropper-handle><cropper-handle action="nw-resize"></cropper-handle><cropper-handle action="se-resize"></cropper-handle><cropper-handle action="sw-resize"></cropper-handle></cropper-selection></cropper-canvas>';const REGEXP_ALLOWED_ELEMENTS=/^(img|canvas)$/,REGEXP_BLOCKED_TAGS=/<(\/?(?:script|style)[^>]*)>/gi,DEFAULT_OPTIONS={template:DEFAULT_TEMPLATE};CropperCanvas.$define(),CropperCrosshair.$define(),CropperGrid.$define(),CropperHandle.$define(),CropperImage.$define(),CropperSelection.$define(),CropperShade.$define(),CropperViewer.$define();class Cropper{constructor(t,e){var i;if(this.options=DEFAULT_OPTIONS,isString(t)&&(t=document.querySelector(t)),!isElement(t)||!REGEXP_ALLOWED_ELEMENTS.test(t.localName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,e=Object.assign(Object.assign({},DEFAULT_OPTIONS),e),this.options=e;let{container:s}=e;if(s&&(isString(s)&&(s=null===(i=getRootDocument(t))||void 0===i?void 0:i.querySelector(s)),!isElement(s)))throw new Error("The `container` option must be an element or a valid selector.");isElement(s)||(s=t.parentElement?t.parentElement:t.ownerDocument.body),this.container=s;const n=t.localName;let o="";"img"===n?({src:o}=t):"canvas"===n&&window.HTMLCanvasElement&&(o=t.toDataURL());const{template:a}=e;if(a&&isString(a)){const e=document.createElement("template"),i=document.createDocumentFragment();e.innerHTML=a.replace(REGEXP_BLOCKED_TAGS,"&lt;$1&gt;"),i.appendChild(e.content),Array.from(i.querySelectorAll(CROPPER_IMAGE)).forEach(e=>{e.setAttribute("src",o),e.setAttribute("alt",t.alt||"The image to crop"),"img"===n&&["crossorigin","decoding","elementtiming","fetchpriority","loading","referrerpolicy","sizes","srcset"].forEach(i=>{t.hasAttribute(i)&&e.setAttribute(i,t.getAttribute(i)||"")})}),t.parentElement?(t.style.display="none",s.insertBefore(i,t.nextSibling)):s.appendChild(i)}}getCropperCanvas(){return this.container.querySelector(CROPPER_CANVAS)}getCropperImage(){return this.container.querySelector(CROPPER_IMAGE)}getCropperSelection(){return this.container.querySelector(CROPPER_SELECTION)}getCropperSelections(){return this.container.querySelectorAll(CROPPER_SELECTION)}destroy(){var t;const e=this.getCropperCanvas();e&&(null===(t=e.parentElement)||void 0===t||t.removeChild(e)),this.element&&(this.element.style.display="")}}Cropper.version="2.2.0";export{ACTION_MOVE,ACTION_NONE,ACTION_RESIZE_EAST,ACTION_RESIZE_NORTH,ACTION_RESIZE_NORTHEAST,ACTION_RESIZE_NORTHWEST,ACTION_RESIZE_SOUTH,ACTION_RESIZE_SOUTHEAST,ACTION_RESIZE_SOUTHWEST,ACTION_RESIZE_WEST,ACTION_ROTATE,ACTION_SCALE,ACTION_SELECT,ACTION_TRANSFORM,ATTRIBUTE_ACTION,CROPPER_CANVAS,CROPPER_CROSSHAIR,CROPPER_GIRD,CROPPER_HANDLE,CROPPER_IMAGE,CROPPER_SELECTION,CROPPER_SHADE,CROPPER_VIEWER,CropperCanvas,CropperCrosshair,CropperElement,CropperGrid,CropperHandle,CropperImage,CropperSelection,CropperShade,CropperViewer,DEFAULT_TEMPLATE,EVENT_ACTION,EVENT_ACTION_END,EVENT_ACTION_MOVE,EVENT_ACTION_START,EVENT_CHANGE,EVENT_ERROR,EVENT_KEYDOWN,EVENT_LOAD,EVENT_POINTER_DOWN,EVENT_POINTER_MOVE,EVENT_POINTER_UP,EVENT_RESIZE,EVENT_TOUCH_END,EVENT_TOUCH_MOVE,EVENT_TOUCH_START,EVENT_TRANSFORM,EVENT_WHEEL,HAS_POINTER_EVENT,IS_BROWSER,IS_TOUCH_DEVICE,NAMESPACE,OBJECT_FIT_CONTAIN,OBJ
2ECT_FIT_COVER,OBJECT_FIT_FILL,OBJECT_FIT_NONE,OBJECT_FIT_SCALE_DOWN,WINDOW,Cropper as default,emit,getAdjustedSizes,getComposedPathTarget,getOffset,getRootDocument,isElement,isFunction,isNaN,isNumber,isObject,isPlainObject,isPositiveNumber,isString,isUndefined,multiplyMatrices,nextTick,off,on,once,toAngleInRadian,toCamelCase,toKebabCase};
3//# sourceMappingURL=cropper.esm.js.map

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.