UNPKG

@cogic/annotorious

Version:

A JavaScript image annotation library

2 lines 78.6 kB
/*! For license information please see annotorious-selector-pack.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Annotorious=t():(e.Annotorious=e.Annotorious||{},e.Annotorious.SelectorPack=t())}(self,(function(){return(()=>{var e={94:e=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}e.exports=function e(n,r){if(n===r)return!0;if(n&&r&&"object"==t(n)&&"object"==t(r)){if(n.constructor!==r.constructor)return!1;var o,i,a;if(Array.isArray(n)){if((o=n.length)!=r.length)return!1;for(i=o;0!=i--;)if(!e(n[i],r[i]))return!1;return!0}if(n.constructor===RegExp)return n.source===r.source&&n.flags===r.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===r.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===r.toString();if((o=(a=Object.keys(n)).length)!==Object.keys(r).length)return!1;for(i=o;0!=i--;)if(!Object.prototype.hasOwnProperty.call(r,a[i]))return!1;for(i=o;0!=i--;){var u=a[i];if(!e(n[u],r[u]))return!1}return!0}return n!=n&&r!=r}},773:e=>{function t(){}t.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function o(){r.off(e,o),t.apply(n,arguments)}return o._=t,this.on(e,o,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,o=n.length;r<o;r++)n[r].fn.apply(n[r].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),r=n[e],o=[];if(r&&t)for(var i=0,a=r.length;i<a;i++)r[i].fn!==t&&r[i].fn._!==t&&o.push(r[i]);return o.length?n[e]=o:delete n[e],this}},e.exports=t,e.exports.TinyEmitter=t}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};return(()=>{"use strict";n.d(r,{default:()=>Rn});var e,t=n(773),o=n.n(t),i="http://www.w3.org/2000/svg",a=function(e,t){var n=function(e){var t=e.getAttribute("class");return t?new Set(t.split(" ")):new Set}(e);n.add(t),e.setAttribute("class",Array.from(n).join(" "))},u=new Uint8Array(16);function c(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(u)}const l=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&l.test(e)};for(var f=[],p=0;p<256;++p)f.push((p+256).toString(16).substr(1));const d=function(e,t,n){var r=(e=e||{}).random||(e.rng||c)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[e[t+0]]+f[e[t+1]]+f[e[t+2]]+f[e[t+3]]+"-"+f[e[t+4]]+f[e[t+5]]+"-"+f[e[t+6]]+f[e[t+7]]+"-"+f[e[t+8]]+f[e[t+9]]+"-"+f[e[t+10]]+f[e[t+11]]+f[e[t+12]]+f[e[t+13]]+f[e[t+14]]+f[e[t+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n}(r)};var y=n(94),b=n.n(y);function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){m(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=function(){function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),m(this,"clone",(function(t,n){return new e(g(g({},r.underlying),t),g(g({},r.opts),n))})),m(this,"selector",(function(e){var t=r.underlying.target;if(t.selector)return(Array.isArray(t.selector)?t.selector:[t.selector]).find((function(t){return t.type===e}))})),this.underlying=t,this.opts=n}var t,n;return t=e,(n=[{key:"isEqual",value:function(e){return"Annotation"===(null==e?void 0:e.type)&&(this.underlying===e.underlying||!(!this.underlying.id||!e.underlying.id)&&b()(this.underlying,e.underlying))}},{key:"readOnly",get:function(){var e;return null===(e=this.opts)||void 0===e?void 0:e.readOnly}},{key:"id",get:function(){return this.underlying.id}},{key:"type",get:function(){return this.underlying.type}},{key:"motivation",get:function(){return this.underlying.motivation}},{key:"body",get:function(){return this.underlying.body}},{key:"target",get:function(){return this.underlying.target}},{key:"bodies",get:function(){return Array.isArray(this.underlying.body)?this.underlying.body:[this.underlying.body]},set:function(e){this.underlying.body=e}},{key:"targets",get:function(){return Array.isArray(this.underlying.target)?this.underlying.target:[this.underlying.target]}},{key:"quote",get:function(){return this.selector("TextQuoteSelector").exact}},{key:"start",get:function(){return this.selector("TextPositionSelector").start}},{key:"end",get:function(){return this.selector("TextPositionSelector").end}}])&&v(t.prototype,n),e}();function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){E(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function E(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}m(w,"create",(function(e){var t={"@context":"http://www.w3.org/ns/anno.jsonld",type:"Annotation",id:"#".concat(d()),body:[]};return new w(g(g({},t),e))}));var A=function(){function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),E(this,"clone",(function(t){var n=new e;return n.underlying=JSON.parse(JSON.stringify(r.underlying)),t&&(n.underlying=O(O({},n.underlying),t)),n})),E(this,"selector",(function(e){var t=r.underlying.target;if(t.selector)return(Array.isArray(t.selector)?t.selector:[t.selector]).find((function(t){return t.type===e}))})),E(this,"toAnnotation",(function(){var e=Object.assign({},r.underlying,{"@context":"http://www.w3.org/ns/anno.jsonld",type:"Annotation",id:"#".concat(d())});return new w(e)})),this.underlying={type:"Selection",body:n||[],target:t}}var t,n;return t=e,(n=[{key:"type",get:function(){return this.underlying.type}},{key:"body",get:function(){return this.underlying.body}},{key:"target",get:function(){return this.underlying.target}},{key:"targets",get:function(){return Array.isArray(this.underlying.target)?this.underlying.target:[this.underlying.target]}},{key:"isEqual",value:function(e){return!!e&&b()(this.underlying,e.underlying)}},{key:"bodies",get:function(){return Array.isArray(this.underlying.body)?this.underlying.body:[this.underlying.body]}},{key:"quote",get:function(){return this.selector("TextQuoteSelector").exact}},{key:"isSelection",get:function(){return!0}}])&&j(t.prototype,n),e}();function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function k(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),e}function M(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&R(e,t)}function R(e,t){return R=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},R(e,t)}function _(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=D(e);if(t){var o=D(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return T(this,n)}}function T(e,t){if(t&&("object"===P(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return G(e)}function G(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function D(e){return D=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},D(e)}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var H="An implementation is missing",L="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,B=function(e){M(n,e);var t=_(n);function n(e,r,o){var a;x(this,n),N(G(a=t.call(this)),"enableResponsive",(function(){window.ResizeObserver&&(a.resizeObserver=new ResizeObserver((function(){var e=a.svg.getBoundingClientRect(),t=a.svg.viewBox.baseVal,n=t.width,r=t.height;a.scale=Math.max(n/e.width,r/e.height),a.onScaleChanged&&a.onScaleChanged(a.scale)})),a.resizeObserver.observe(a.svg.parentNode))})),N(G(a),"getSVGPoint",(function(e){var t=a.svg.createSVGPoint();if(L){var n=a.svg.getBoundingClientRect(),r=e.clientX-n.x,o=e.clientY-n.y,i=a.svg.getBoundingClientRect(),u=i.left,c=i.top;return t.x=r+u,t.y=o+c,t.matrixTransform(a.g.getScreenCTM().inverse())}return t.x=e.offsetX,t.y=e.offsetY,t.matrixTransform(a.g.getCTM().inverse())})),N(G(a),"drawHandle",(function(e,t){var n=document.createElementNS(i,"g");n.setAttribute("class","a9s-handle");var r=document.createElementNS(i,"g"),o=function(n){var r=document.createElementNS(i,"circle");return r.setAttribute("cx",e),r.setAttribute("cy",t),r.setAttribute("r",n),r},u=a.config.handleRadius||6,c=o(u);c.setAttribute("class","a9s-handle-inner");var l=o(u+1);return l.setAttribute("class","a9s-handle-outer"),r.appendChild(l),r.appendChild(c),n.appendChild(r),n})),N(G(a),"setHandleXY",(function(e,t,n){var r=e.querySelector(".a9s-handle-inner");r.setAttribute("cx",t),r.setAttribute("cy",n);var o=e.querySelector(".a9s-handle-outer");o.setAttribute("cx",t),o.setAttribute("cy",n)})),N(G(a),"getHandleXY",(function(e){var t=e.querySelector(".a9s-handle-outer");return{x:parseFloat(t.getAttribute("cx")),y:parseFloat(t.getAttribute("cy"))}})),N(G(a),"scaleHandle",(function(e){var t=e.querySelector(".a9s-handle-inner"),n=e.querySelector(".a9s-handle-outer"),r=a.scale*(a.config.handleRadius||6);t.setAttribute("r",r),n.setAttribute("r",r)})),a.svg=e.closest("svg"),a.g=e,a.config=r,a.env=o,a.scale=1;var u=o.image;return(u instanceof Element||u instanceof HTMLDocument)&&a.enableResponsive(),a}return k(n,[{key:"destroy",value:function(){this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeObserver=null}}]),n}(o()),U=function(e){M(n,e);var t=_(n);function n(e,r,o){var i;return x(this,n),N(G(i=t.call(this,e,r,o)),"attachListeners",(function(e){var t=e.mouseMove,n=e.mouseUp,r=e.dblClick;t&&(i.mouseMove=function(e){var n=i.getSVGPoint(e),r=n.x,o=n.y;i.started||(i.emit("startSelection",{x:r,y:o}),i.started=!0),t(r,o,e)},i.svg.addEventListener("mousemove",i.mouseMove)),n&&(i.mouseUp=function(e){if(0===e.button){var t=i.getSVGPoint(e),r=t.x,o=t.y;n(r,o,e)}},document.addEventListener("mouseup",i.mouseUp)),r&&(i.dblClick=function(e){var t=i.getSVGPoint(e),n=t.x,o=t.y;r(n,o,e)},document.addEventListener("dblclick",i.dblClick))})),N(G(i),"detachListeners",(function(){i.mouseMove&&i.svg.removeEventListener("mousemove",i.mouseMove),i.mouseUp&&document.removeEventListener("mouseup",i.mouseUp),i.dblClick&&document.removeEventListener("dblclick",i.dblClick)})),N(G(i),"start",(function(e,t){var n=i.getSVGPoint(e),r=n.x,o=n.y;i.startDrawing(r,o,t,e)})),N(G(i),"startDrawing",(function(e){throw new Error(H)})),N(G(i),"createEditableShape",(function(e){throw new Error(H)})),i.started=!1,i}return k(n,[{key:"isDrawing",get:function(){throw new Error(H)}}]),n}(B);function X(e){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},X(e)}function Y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function q(e,t){return q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},q(e,t)}function F(e,t){if(t&&("object"===X(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return z(e)}function z(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function V(e){return V=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},V(e)}U.supports=function(e){throw new Error(H)};var I="An implementation is missing",W=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&q(e,t)}(a,e);var t,n,r,o,i=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=V(r);if(o){var n=V(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return F(this,e)});function a(e,t,n,r){var o,u,c,l;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),l=function(e){throw new Error(I)},(c="updateState")in(u=z(o=i.call(this,t,n,r)))?Object.defineProperty(u,c,{value:l,enumerable:!0,configurable:!0,writable:!0}):u[c]=l,o.annotation=e,o}return t=a,(n=[{key:"element",get:function(){throw new Error(I)}}])&&Y(t.prototype,n),a}(B);function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var $=function(e,t){var n=e.selector("FragmentSelector");if(null!=n&&n.conformsTo.startsWith("http://www.w3.org/TR/media-frags")){var r=n.value,o=r.includes(":")?r.substring(r.indexOf("=")+1,r.indexOf(":")):"pixel",i=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Z(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((r.includes(":")?r.substring(r.indexOf(":")+1):r.substring(r.indexOf("=")+1)).split(",").map(parseFloat),4),a=i[0],u=i[1],c=i[2],l=i[3];return"percent"===o.toLowerCase()&&(a=a*t.naturalWidth/100,u=u*t.naturalHeight/100,c=c*t.naturalWidth/100,l=l*t.naturalHeight/100),{x:a,y:u,w:c,h:l}}};function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function J(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?K(Object(n),!0).forEach((function(t){Q(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ee=function(e,t,n,r){return J(J({},function(e,t,n,r,o,i){return"percent"===(null==i?void 0:i.toLowerCase())?function(e,t,n,r,o){var i=e/o.naturalWidth*100,a=t/o.naturalHeight*100,u=0/o.naturalWidth*100,c=0/o.naturalHeight*100;return{source:o.src,selector:{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:"xywh=percent:".concat(i,",").concat(a,",").concat(u,",").concat(c)}}}(e,t,0,0,o):function(e,t,n,r,o){return{source:null==o?void 0:o.src,selector:{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:"xywh=pixel:".concat(e,",").concat(t,",").concat(0,",").concat(0)}}}(e,t,0,0,o)}(e,t,0,0,n,r)),{},{renderedVia:{name:"point"}})};function te(e){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},te(e)}function ne(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function re(e,t,n){return re="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=ue(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},re(e,t,n||e)}function oe(e,t){return oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},oe(e,t)}function ie(e,t){if(t&&("object"===te(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return ae(e)}function ae(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ue(e){return ue=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ue(e)}function ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(u,e);var t,n,r,o,a=(r=u,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=ue(r);if(o){var n=ue(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return ie(this,e)});function u(e,t,n,r){var o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),ce(ae(o=a.call(this,e,t,n,r)),"onScaleChanged",(function(){return o.scaleHandle(o.point)})),ce(ae(o),"onGrab",(function(){o.isGrabbed=!0})),ce(ae(o),"onMouseMove",(function(e){if(0===e.button&&o.isGrabbed){var t=o.getSVGPoint(e),n=t.x,r=t.y;o.setHandleXY(o.point,n,r);var i=ee(n,r,o.env.image,o.config.fragmentUnit);o.emit("update",i)}})),ce(ae(o),"onMouseUp",(function(){o.isGrabbed=!1})),ce(ae(o),"updateState",(function(e){var t=$(e,o.env.image),n=t.x,r=t.y;o.setHandleXY(o.point,n,r)})),o.svg.addEventListener("mousemove",o.onMouseMove),o.svg.addEventListener("mouseup",o.onMouseUp);var c=$(e,r.image),l=c.x,s=c.y;return o.container=document.createElementNS(i,"g"),o.elementGroup=document.createElementNS(i,"g"),o.elementGroup.setAttribute("class","a9s-annotation editable selected"),o.point=o.drawHandle(l,s),o.point.addEventListener("mousedown",o.onGrab),o.elementGroup.appendChild(o.point),o.container.appendChild(o.elementGroup),t.appendChild(o.container),o.isGrabbed=!1,o}return t=u,(n=[{key:"element",get:function(){return this.elementGroup}},{key:"destroy",value:function(){this.svg.removeEventListener("mousemove",this.onMouseMove),this.svg.removeEventListener("mouseup",this.onMouseUp),this.container.parentNode.removeChild(this.container),re(ue(u.prototype),"destroy",this).call(this)}}])&&ne(t.prototype,n),u}(W);function se(e){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},se(e)}function fe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function pe(e,t){return pe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},pe(e,t)}function de(e,t){if(t&&("object"===se(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return ye(e)}function ye(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function be(e){return be=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},be(e)}function he(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ge=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&pe(e,t)}(a,e);var t,n,r,o,i=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=be(r);if(o){var n=be(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return de(this,e)});function a(e,t,n){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),he(ye(r=i.call(this,e,t,n)),"startDrawing",(function(e,t,n,o){var i,a=null===(i=o.target.closest(".a9s-annotation"))||void 0===i?void 0:i.annotation;if(a&&function(e){var t;return"point"===(null===(t=e.target.renderedVia)||void 0===t?void 0:t.name)}(a))r.emit("cancel");else{var u=r.drawHandle(e,t);r.scaleHandle(u),r.g.appendChild(u),u.annotation=new A(ee(e,t,r.env.image,r.config.fragmentUnit)),r.emit("complete",u)}})),he(ye(r),"stop",(function(){})),he(ye(r),"createEditableShape",(function(e){return new le(e,r.g,r.config,r.env)})),r}return t=a,(n=[{key:"isDrawing",get:function(){return!1}}])&&fe(t.prototype,n),a}(U);ge.identifier="point",ge.supports=function(e){return!1};var ve=function(e){var t=function(e){Array.from(e.attributes).forEach((function(t){t.name.startsWith("on")&&e.removeAttribute(t.name)}))},n=e.getElementsByTagName("script");return Array.from(n).reverse().forEach((function(e){return e.parentNode.removeChild(e)})),t(e),Array.from(e.querySelectorAll("*")).forEach(t),e},me=function(e){var t,n,r=e.selector("SvgSelector");if(r){var o=new DOMParser,a=r.value,u=o.parseFromString(a,"image/svg+xml"),c=u.lookupPrefix(i),l=u.lookupNamespaceURI(null);return c||l?ve(u).firstChild:ve((t=u,n=(new XMLSerializer).serializeToString(t.documentElement).replace("<svg>",'<svg xmlns="'.concat(i,'">')),(new DOMParser).parseFromString(n,"image/svg+xml").documentElement)).firstChild}},we=function(e){var t=me(e),n=document.createElementNS(i,"g"),r=t.cloneNode(!0);r.setAttribute("class","a9s-inner");var o=t.cloneNode(!0);return o.setAttribute("class","a9s-outer"),n.appendChild(o),n.appendChild(r),n},Se=function(e,t){var n=e.querySelector(".a9s-inner").cloneNode(!0);n.removeAttribute("class"),n.removeAttribute("xmlns");var r=n.outerHTML||(new XMLSerializer).serializeToString(n);return r=r.replace(' xmlns="'.concat(i,'"'),""),{source:null==t?void 0:t.src,selector:{type:"SvgSelector",value:"<svg>".concat(r,"</svg>")}}},Oe=function(e,t,n,r){e.setAttribute("cx",t),e.setAttribute("cy",n),e.setAttribute("r",r)},je=function(e,t,n,r){var o=e.querySelector(".a9s-inner"),i=e.querySelector(".a9s-outer");Oe(o,t,n,r),Oe(i,t,n,r)},Ee=function(e){var t=e.querySelector(".a9s-outer");return{cx:parseFloat(t.getAttribute("cx")),cy:parseFloat(t.getAttribute("cy")),r:parseFloat(t.getAttribute("r"))}};function Ae(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Pe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var xe=function(){function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Pe(this,"redraw",(function(){var e=Ee(r.circle),t=e.cx,n=e.cy,o=e.r,i=t+o>r.w?r.w-o:t,a=n+o>r.h?r.h-o:n+o;r.mask.setAttribute("d","M0 0 h".concat(r.w," v").concat(r.h," h-").concat(r.w," z M").concat(i," ").concat(a," a ").concat(o," ").concat(o," 0 1 1 1 0"))})),Pe(this,"destroy",(function(){return r.mask.parentNode.removeChild(r.mask)})),this.w=t.naturalWidth,this.h=t.naturalHeight,this.circle=n;var o=Ee(this.circle),a=o.cx,u=o.cy,c=o.r,l=a+c>this.w?this.w-c:a,s=u+c>this.h?this.h-c:u+c;this.mask=document.createElementNS(i,"path"),this.mask.setAttribute("fill-rule","evenodd"),this.mask.setAttribute("class","a9s-selection-mask"),this.mask.setAttribute("d","M0 0 h".concat(this.w," v").concat(this.h," h-").concat(this.w," z M").concat(l," ").concat(s," a ").concat(c," ").concat(c," 0 1 1 1 0"))}var t,n;return t=e,(n=[{key:"element",get:function(){return this.mask}}])&&Ae(t.prototype,n),e}();function Ce(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ke(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Me=function(){function e(t,n,r,o){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ke(this,"dragTo",(function(e,t){var n=a.env.image,r=n.naturalWidth,o=n.naturalHeight;a.group.style.display=null;var i=e-a.anchor[0],u=t-a.anchor[1],c=Math.max(1,Math.pow(Math.pow(i,2)+Math.pow(u,2),.5)/2),l=a.anchor[0]+i/2,s=a.anchor[1]+u/2;l-c<0||l+c>r||s-c<0||s+c>o||(je(a.circle,l,s,c),a.mask.redraw())})),ke(this,"getBoundingClientRect",(function(){return a.circle.getBoundingClientRect()})),ke(this,"toSelection",(function(){return new A(Se(a.group,a.env.image))})),ke(this,"destroy",(function(){a.group.parentNode.removeChild(a.group),a.mask=null,a.circle=null,a.group=null})),this.anchor=[t,n],this.env=o,this.group=document.createElementNS(i,"g"),this.circle=function(e,t,n){var r=document.createElementNS(i,"g"),o=document.createElementNS(i,"circle"),a=document.createElementNS(i,"circle");return a.setAttribute("class","a9s-inner"),Oe(a,e,t,2),o.setAttribute("class","a9s-outer"),Oe(o,e,t,2),r.appendChild(o),r.appendChild(a),r}(t,n),this.circle.setAttribute("class","a9s-selection"),this.mask=new xe(o.image,this.circle),this.group.style.pointerEvents="none",this.group.style.display="none",this.group.appendChild(this.mask.element),this.group.appendChild(this.circle),r.appendChild(this.group)}var t,n;return t=e,(n=[{key:"element",get:function(){return this.circle}}])&&Ce(t.prototype,n),e}(),Re=/firefox/i.test(navigator.userAgent),_e=function(e,t,n,r,o){e.setAttribute("width",r),e.setAttribute("height",o),Re?(e.setAttribute("x",0),e.setAttribute("y",0),e.setAttribute("transform","translate(".concat(t,", ").concat(n,")"))):(e.setAttribute("x",t),e.setAttribute("y",n))},Te=function(e,t){var n=t.getBBox(),r=n.x,o=n.y,a=n.width,u=n.height,c=document.createElementNS(i,"svg");c.setAttribute("class","a9s-formatter-el"),_e(c,r,o,a,u);var l=document.createElementNS(i,"g");l.appendChild(e),c.appendChild(l),t.append(c)},Ge=function(e,t,n){if(!n)return e;var r=n(t);if(!r)return e;if("string"==typeof r||r instanceof String)a(e,r);else if(r.nodeType===Node.ELEMENT_NODE)Te(r,e);else{var o=r.className,i=r.style,u=r.element;if(o&&a(e,o),i){var c=e.querySelector(".a9s-outer"),l=e.querySelector(".a9s-inner");c&&l?(c.setAttribute("style","display:none"),l.setAttribute("style",i)):e.setAttribute("style",i)}for(var s in u&&Te(u,e),r)r.hasOwnProperty(s)&&s.startsWith("data-")&&e.setAttribute(s,r[s])}},De=function(e,t,n,r,o){var i=e.querySelector(".a9s-formatter-el");i&&_e(i,t,n,r,o)};function Ne(e){return Ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ne(e)}function He(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Le(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Le(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Le(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Be(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ue(e,t,n){return Ue="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Fe(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},Ue(e,t,n||e)}function Xe(e,t){return Xe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Xe(e,t)}function Ye(e,t){if(t&&("object"===Ne(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return qe(e)}function qe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Fe(e){return Fe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Fe(e)}function ze(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ve=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Xe(e,t)}(u,e);var t,n,r,o,a=(r=u,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Fe(r);if(o){var n=Fe(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return Ye(this,e)});function u(e,t,n,r){var o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),ze(qe(o=a.call(this,e,t,n,r)),"setSize",(function(e,t,n){je(o.circle,e,t,n),o.mask.redraw(),De(o.elementGroup,e,t,n,n);var r=He(o.handles,4),i=r[0],a=r[1],u=r[2],c=r[3];o.setHandleXY(i,e,t-n),o.setHandleXY(a,e+n,t),o.setHandleXY(u,e,t+n),o.setHandleXY(c,e-n,t)})),ze(qe(o),"stretchCorners",(function(e,t,n){var r,i=o.getHandleXY(t),a=n.x,u=n.y,c=0,l=0;0==e||2==e?(a=i.x,l=u-i.y,r=Math.abs(l)/2):(u=i.y,c=a-i.x,r=Math.abs(c)/2);var s=c>0?i.x:a,f=l>0?i.y:u,p=s+Math.abs(c)/2,d=f+Math.abs(l)/2;if(je(o.circle,p,d,r),o.mask.redraw(),De(o.elementGroup,p,d,r,r),0==e||2==e){var y=0,b=2;(0==e&&l>0||2==e&&l<0)&&(y=2,b=0),o.setHandleXY(o.handles[y],p,d-r),o.setHandleXY(o.handles[b],p,d+r),o.setHandleXY(o.handles[1],p+r,d),o.setHandleXY(o.handles[3],p-r,d)}else{var h=3,g=1;(1==e&&c>0||3==e&&c<0)&&(h=1,g=3),o.setHandleXY(o.handles[h],p+r,d),o.setHandleXY(o.handles[g],p-r,d),o.setHandleXY(o.handles[0],p,d-r),o.setHandleXY(o.handles[2],p,d+r)}})),ze(qe(o),"onGrab",(function(e){return function(t){o.grabbedElem=e;var n=o.getSVGPoint(t),r=Ee(o.circle),i=r.cx,a=r.cy;o.grabbedAt={x:n.x-i,y:n.y-a}}})),ze(qe(o),"onMouseMove",(function(e){var t=function(e,t){return e<0?0:e>t?t:e};if(o.grabbedElem){var n=o.getSVGPoint(e);if(o.grabbedElem===o.circle){var r=Ee(o.circle).r,i=o.env.image,a=i.naturalWidth,u=i.naturalHeight,c=Math.max(t(n.x-o.grabbedAt.x,a-r),r),l=Math.max(t(n.y-o.grabbedAt.y,u-r),r);o.setSize(c,l,r),o.emit("update",Se(o.circle,o.env.image))}else{var s=o.handles.indexOf(o.grabbedElem),f=s<2?o.handles[s+2]:o.handles[s-2];o.stretchCorners(s,f,n),o.emit("update",Se(o.circle,o.env.image))}}})),ze(qe(o),"onMouseUp",(function(){o.grabbedElem=null,o.grabbedAt=null})),ze(qe(o),"onScaleChanged",(function(e){return o.handles.map(o.scaleHandle)})),ze(qe(o),"updateState",(function(e){var t=me(e),n=parseFloat(t.getAttribute("cx")),r=parseFloat(t.getAttribute("cy")),i=parseFloat(t.getAttribute("r"));o.setSize(n,r,i)})),o.svg.addEventListener("mousemove",o.onMouseMove),o.svg.addEventListener("mouseup",o.onMouseUp),o.containerGroup=document.createElementNS(i,"g"),o.circle=we(e),o.circle.querySelector(".a9s-inner").addEventListener("mousedown",o.onGrab(o.circle)),o.mask=new xe(r.image,o.circle),o.containerGroup.appendChild(o.mask.element),o.elementGroup=document.createElementNS(i,"g"),o.elementGroup.setAttribute("class","a9s-annotation editable selected"),o.elementGroup.appendChild(o.circle);var c=Ee(o.circle),l=c.cx,s=c.cy,f=c.r;return o.handles=[[l,s-f],[l+f,s],[l,s+f],[l-f,s]].map((function(e){var t=He(e,2),n=t[0],r=t[1],i=o.drawHandle(n,r);return i.addEventListener("mousedown",o.onGrab(i)),o.elementGroup.appendChild(i),i})),o.containerGroup.appendChild(o.elementGroup),t.appendChild(o.containerGroup),Ge(o.circle,e,n.formatter),o.grabbedElem=null,o.grabbedAt=null,o}return t=u,(n=[{key:"element",get:function(){return this.elementGroup}},{key:"destroy",value:function(){this.containerGroup.parentNode.removeChild(this.containerGroup),Ue(Fe(u.prototype),"destroy",this).call(this)}}])&&Be(t.prototype,n),u}(W);function Ie(e){return Ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ie(e)}function We(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ze(e,t){return Ze=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ze(e,t)}function $e(e,t){if(t&&("object"===Ie(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Ke(e)}function Ke(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Je(e){return Je=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Je(e)}function Qe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var et=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ze(e,t)}(a,e);var t,n,r,o,i=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=Je(r);if(o){var n=Je(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return $e(this,e)});function a(e,t,n){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),Qe(Ke(r=i.call(this,e,t,n)),"startDrawing",(function(e,t){r.attachListeners({mouseMove:r.onMouseMove,mouseUp:r.onMouseUp}),r.rubberband=new Me(e,t,r.g,r.env)})),Qe(Ke(r),"stop",(function(){r.rubberband&&(r.rubberband.destroy(),r.rubberband=null)})),Qe(Ke(r),"onMouseMove",(function(e,t){return r.rubberband.dragTo(e,t)})),Qe(Ke(r),"onMouseUp",(function(){r.detachListeners(),r.started=!1;var e=r.rubberband.getBoundingClientRect(),t=e.width,n=e.height,o=r.config.minSelectionWidth||4,i=r.config.minSelectionHeight||4;if(t>=o&&n>=i){var a=r.rubberband.element;a.annotation=r.rubberband.toSelection(),r.emit("complete",a)}else r.emit("cancel");r.stop()})),Qe(Ke(r),"createEditableShape",(function(e){return new Ve(e,r.g,r.config,r.env)})),r.rubberband=null,r}return t=a,(n=[{key:"isDrawing",get:function(){return null!=this.rubberband}}])&&We(t.prototype,n),a}(U);et.identifier="circle",et.supports=function(e){var t,n=e.selector("SvgSelector");if(n)return null===(t=n.value)||void 0===t?void 0:t.match(/^<svg.*<circle/g)};var tt=function(e,t,n,r,o){e.setAttribute("cx",t),e.setAttribute("cy",n),e.setAttribute("rx",r),e.setAttribute("ry",o)},nt=function(e,t,n,r,o){var i=e.querySelector(".a9s-inner"),a=e.querySelector(".a9s-outer");tt(i,t,n,r,o),tt(a,t,n,r,o)},rt=function(e){var t=e.querySelector(".a9s-outer");return{cx:parseFloat(t.getAttribute("cx")),cy:parseFloat(t.getAttribute("cy")),rx:parseFloat(t.getAttribute("rx")),ry:parseFloat(t.getAttribute("ry"))}};function ot(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function it(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var at=function(){function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),it(this,"redraw",(function(){var e=rt(r.ellipse),t=e.cx,n=e.cy,o=e.rx,i=e.ry,a=n+i;r.mask.setAttribute("d","M0 0 h".concat(r.w," v").concat(r.h," h-").concat(r.w," z M").concat(t," ").concat(a," a ").concat(o," ").concat(i," 0 1 1 1 0"))})),it(this,"destroy",(function(){return r.mask.parentNode.removeChild(r.mask)})),this.w=t.naturalWidth,this.h=t.naturalHeight,this.ellipse=n;var o=rt(this.ellipse),a=o.cx,u=o.cy,c=o.rx,l=o.ry,s=u+l;this.mask=document.createElementNS(i,"path"),this.mask.setAttribute("fill-rule","evenodd"),this.mask.setAttribute("class","a9s-selection-mask"),this.mask.setAttribute("d","M0 0 h".concat(this.w," v").concat(this.h," h-").concat(this.w," z M").concat(a," ").concat(s," a ").concat(c," ").concat(l," 0 1 1 1 0"))}var t,n;return t=e,(n=[{key:"element",get:function(){return this.mask}}])&&ot(t.prototype,n),e}();function ut(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ct(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var lt=function(){function e(t,n,r,o){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ct(this,"dragTo",(function(e,t){a.group.style.display=null;var n=e-a.anchor[0],r=t-a.anchor[1],o=n>0?a.anchor[0]+n/2:e+n/2,i=r>0?a.anchor[1]+r/2:t+r/2,u=Math.abs(n/2),c=Math.abs(r/2);nt(a.ellipse,o,i,u,c),a.mask.redraw()})),ct(this,"getBoundingClientRect",(function(){return a.ellipse.getBoundingClientRect()})),ct(this,"toSelection",(function(){return new A(Se(a.group,a.env.image))})),ct(this,"destroy",(function(){a.group.parentNode.removeChild(a.group),a.mask=null,a.ellipse=null,a.group=null})),this.anchor=[t,n],this.env=o,this.group=document.createElementNS(i,"g"),this.ellipse=function(e,t,n,r){var o=document.createElementNS(i,"g"),a=document.createElementNS(i,"ellipse"),u=document.createElementNS(i,"ellipse");return a.setAttribute("class","a9s-inner"),tt(a,e,t,2,r),u.setAttribute("class","a9s-outer"),tt(u,e,t,2,r),o.appendChild(u),o.appendChild(a),o}(t,n),this.ellipse.setAttribute("class","a9s-selection"),this.mask=new at(o.image,this.ellipse),this.group.style.pointerEvents="none",this.group.style.display="none",this.group.appendChild(this.mask.element),this.group.appendChild(this.ellipse),r.appendChild(this.group)}var t,n;return t=e,(n=[{key:"element",get:function(){return this.ellipse}}])&&ut(t.prototype,n),e}();function st(e){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},st(e)}function ft(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return pt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pt(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function dt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function yt(e,t,n){return yt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=vt(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}},yt(e,t,n||e)}function bt(e,t){return bt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},bt(e,t)}function ht(e,t){if(t&&("object"===st(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return gt(e)}function gt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vt(e){return vt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},vt(e)}function mt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&bt(e,t)}(u,e);var t,n,r,o,a=(r=u,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=vt(r);if(o){var n=vt(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return ht(this,e)});function u(e,t,n,r){var o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),mt(gt(o=a.call(this,e,t,n,r)),"setSize",(function(e,t,n,r){nt(o.ellipse,e,t,n,r),o.mask.redraw(),De(o.elementGroup,e,t,n,r);var i=ft(o.handles,4),a=i[0],u=i[1],c=i[2],l=i[3];o.setHandleXY(a,e,t-r),o.setHandleXY(u,e+n,t),o.setHandleXY(c,e,t+r),o.setHandleXY(l,e-n,t)})),mt(gt(o),"stretchCorners",(function(e,t,n,r){var i=o.getHandleXY(t),a=o.getHandleXY(n),u=r.x,c=r.y,l=0,s=0;0==e||2==e?u=i.x:c=i.y;var f=u-i.x,p=c-i.y,d=f>0?i.x:u,y=p>0?i.y:c,b=Math.abs(f),h=Math.abs(p),g=d+b/2,v=y+h/2;if(l=b/2,s=h/2,0==e||2==e?l=Math.abs(i.x-a.x):s=Math.abs(i.y-a.y),nt(o.ellipse,g,v,l,s),o.mask.redraw(),De(o.elementGroup,g,v,l,s),0==e||2==e){var m=0,w=2;(0==e&&p>0||2==e&&p<0)&&(m=2,w=0),o.setHandleXY(o.handles[m],g,v-s),o.setHandleXY(o.handles[w],g,v+s),o.setHandleXY(o.handles[1],g+l,v),o.setHandleXY(o.handles[3],g-l,v)}else{var S=3,O=1;(1==e&&f>0||3==e&&f<0)&&(S=1,O=3),o.setHandleXY(o.handles[S],g+l,v),o.setHandleXY(o.handles[O],g-l,v),o.setHandleXY(o.handles[0],g,v-s),o.setHandleXY(o.handles[2],g,v+s)}})),mt(gt(o),"onGrab",(function(e){return function(t){o.grabbedElem=e;var n=o.getSVGPoint(t),r=rt(o.ellipse),i=r.cx,a=r.cy;o.grabbedAt={x:n.x-i,y:n.y-a}}})),mt(gt(o),"onMouseMove",(function(e){var t=function(e,t){return e<0?0:e>t?t:e};if(o.grabbedElem){var n=o.getSVGPoint(e);if(o.grabbedElem===o.ellipse){var r=rt(o.ellipse),i=r.rx,a=r.ry,u=o.env.image,c=u.naturalWidth,l=u.naturalHeight,s=t(n.x-o.grabbedAt.x,c-i),f=t(n.y-o.grabbedAt.y,l-a);o.setSize(s,f,i,a),o.emit("update",Se(o.ellipse,o.env.image))}else{var p=o.handles.indexOf(o.grabbedElem),d=p<2?o.handles[p+2]:o.handles[p-2],y=o.handles[(p+3)%4];o.stretchCorners(p,d,y,n),o.emit("update",Se(o.ellipse,o.env.image))}}})),mt(gt(o),"onMouseUp",(function(){o.grabbedElem=null,o.grabbedAt=null})),mt(gt(o),"onScaleChanged",(function(e){return o.handles.map(o.scaleHandle)})),mt(gt(o),"updateState",(function(e){var t=me(e),n=parseFloat(t.getAttribute("cx")),r=parseFloat(t.getAttribute("cy")),i=parseFloat(t.getAttribute("rx")),a=parseFloat(t.getAttribute("ry"));o.setSize(n,r,i,a)})),o.svg.addEventListener("mousemove",o.onMouseMove),o.svg.addEventListener("mouseup",o.onMouseUp),o.containerGroup=document.createElementNS(i,"g"),o.ellipse=we(e),o.ellipse.querySelector(".a9s-inner").addEventListener("mousedown",o.onGrab(o.ellipse)),o.mask=new at(r.image,o.ellipse),o.containerGroup.appendChild(o.mask.element),o.elementGroup=document.createElementNS(i,"g"),o.elementGroup.setAttribute("class","a9s-annotation editable selected"),o.elementGroup.appendChild(o.ellipse);var c=rt(o.ellipse),l=c.cx,s=c.cy,f=c.rx,p=c.ry;return o.handles=[[l,s-p],[l+f,s],[l,s+p],[l-f,s]].map((function(e){var t=ft(e,2),n=t[0],r=t[1],i=o.drawHandle(n,r);return i.addEventListener("mousedown",o.onGrab(i)),o.elementGroup.appendChild(i),i})),o.containerGroup.appendChild(o.elementGroup),t.appendChild(o.containerGroup),Ge(o.ellipse,e,n.formatter),o.grabbedElem=null,o.grabbedAt=null,o}return t=u,(n=[{key:"element",get:function(){return this.elementGroup}},{key:"destroy",value:function(){this.containerGroup.parentNode.removeChild(this.containerGroup),yt(vt(u.prototype),"destroy",this).call(this)}}])&&dt(t.prototype,n),u}(W);function St(e){return St="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},St(e)}function Ot(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function jt(e,t){return jt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},jt(e,t)}function Et(e,t){if(t&&("object"===St(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return At(e)}function At(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Pt(e){return Pt=Object