Comparing version 1.7.3 to 1.7.4
import { SelectoOptions } from "./types"; | ||
export declare const injector: import("css-styled").StyledInjector; | ||
export declare const CLASS_NAME: string; | ||
export declare const PROPERTIES: readonly ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio"]; | ||
export declare const OPTIONS: readonly ["dragContainer", "cspNonce", ...("boundContainer" | "selectableTargets" | "selectByClick" | "selectFromInside" | "continueSelect" | "toggleContinueSelect" | "keyContainer" | "hitRate" | "scrollOptions" | "checkInput" | "preventDefault" | "ratio")[]]; | ||
export declare const PROPERTIES: readonly ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementPoints"]; | ||
export declare const OPTIONS: readonly ["dragContainer", "cspNonce", ...("boundContainer" | "selectableTargets" | "selectByClick" | "selectFromInside" | "continueSelect" | "toggleContinueSelect" | "keyContainer" | "hitRate" | "scrollOptions" | "checkInput" | "preventDefault" | "ratio" | "getElementPoints")[]]; | ||
export declare const OPTION_TYPES: { | ||
@@ -7,0 +7,0 @@ [key in keyof SelectoOptions]: any; |
@@ -23,2 +23,3 @@ import { IObject } from "@daybrush/utils"; | ||
ratio: number; | ||
getElementPoints: GetElementPointsFunction; | ||
} | ||
@@ -40,2 +41,8 @@ export interface Hypertext { | ||
} | ||
export interface Point { | ||
pos1: number[]; | ||
pos2: number[]; | ||
pos3: number[]; | ||
pos4: number[]; | ||
} | ||
export interface OnSelect { | ||
@@ -97,1 +104,7 @@ selected: Array<HTMLElement | SVGElement>; | ||
}; | ||
export declare type GetElementPointsFunction = (el: HTMLElement | SVGElement) => { | ||
pos1: number[]; | ||
pos2: number[]; | ||
pos3: number[]; | ||
pos4: number[]; | ||
}; |
@@ -16,1 +16,7 @@ import { Hypertext, Rect } from "./types"; | ||
}): Rect; | ||
export declare function getDefaultElementPoints(el: HTMLElement): { | ||
pos1: number[]; | ||
pos2: number[]; | ||
pos3: number[]; | ||
pos4: number[]; | ||
}; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 1.7.3 | ||
version: 1.7.4 | ||
*/ | ||
@@ -198,3 +198,3 @@ 'use strict'; | ||
var maxHeight = distY < 0 ? startY - boundArea.top : boundArea.bottom - startY; | ||
_a = utils.caculateBoundSize([width, height], [0, 0], [maxWidth, maxHeight], !!ratio), width = _a[0], height = _a[1]; | ||
_a = utils.calculateBoundSize([width, height], [0, 0], [maxWidth, maxHeight], !!ratio), width = _a[0], height = _a[1]; | ||
distX = (distX >= 0 ? 1 : -1) * width; | ||
@@ -215,2 +215,15 @@ distY = (distY >= 0 ? 1 : -1) * height; | ||
} | ||
function getDefaultElementPoints(el) { | ||
var rect = el.getBoundingClientRect(); | ||
var left = rect.left, | ||
top = rect.top, | ||
width = rect.width, | ||
height = rect.height; | ||
return { | ||
pos1: [left, top], | ||
pos2: [left + width, top], | ||
pos3: [left, top + height], | ||
pos4: [left + width, top + height] | ||
}; | ||
} | ||
@@ -223,3 +236,3 @@ var injector = styled("\n:host {\n position: fixed;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
var CLASS_NAME = "selecto-selection " + injector.className; | ||
var PROPERTIES = ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio"]; | ||
var PROPERTIES = ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementPoints"]; | ||
/** | ||
@@ -247,3 +260,4 @@ * @memberof Selecto | ||
cspNonce: String, | ||
ratio: Number | ||
ratio: Number, | ||
getElementPoints: Function | ||
}; | ||
@@ -587,2 +601,3 @@ /** | ||
boundContainer: false, | ||
getElementPoints: getDefaultElementPoints, | ||
cspNonce: "", | ||
@@ -697,20 +712,9 @@ ratio: 0 | ||
var getElementPoints = this.getElementPoints; | ||
var selectableTargets = this.getSelectableTargets(); | ||
var selectableRects = selectableTargets.map(function (target) { | ||
var rect = target.getBoundingClientRect(); | ||
var left = rect.left, | ||
top = rect.top, | ||
width = rect.width, | ||
height = rect.height; | ||
return { | ||
left: left, | ||
top: top, | ||
right: left + width, | ||
bottom: top + height, | ||
width: width, | ||
height: height | ||
}; | ||
var selectablePoints = selectableTargets.map(function (target) { | ||
return getElementPoints(target); | ||
}); | ||
datas.selectableTargets = selectableTargets; | ||
datas.selectableRects = selectableRects; | ||
datas.selectablePoints = selectablePoints; | ||
}; | ||
@@ -798,3 +802,3 @@ /** | ||
__proto.hitTest = function (selectRect, clientX, clientY, targets, rects) { | ||
__proto.hitTest = function (selectRect, clientX, clientY, targets, points) { | ||
var _a = this.options, | ||
@@ -808,7 +812,20 @@ hitRate = _a.hitRate, | ||
return targets.filter(function (target, i) { | ||
var _a = rects[i], | ||
rectLeft = _a.left, | ||
rectTop = _a.top, | ||
rectRight = _a.right, | ||
rectBottom = _a.bottom; | ||
var _a = points[i], | ||
pos1 = _a.pos1, | ||
pos2 = _a.pos2, | ||
pos3 = _a.pos3, | ||
pos4 = _a.pos4; | ||
var _b = [0, 1].map(function (j) { | ||
return Math.min(pos1[j], pos2[j], pos3[j], pos4[j]); | ||
}), | ||
rectLeft = _b[0], | ||
rectTop = _b[1]; | ||
var _c = [0, 1].map(function (j) { | ||
return Math.max(pos1[j], pos2[j], pos3[j], pos4[j]); | ||
}), | ||
rectRight = _c[0], | ||
rectBottom = _c[1]; | ||
var isStart = rectLeft <= clientX && clientX <= rectRight && rectTop <= clientY && clientY <= rectBottom; | ||
@@ -857,7 +874,7 @@ var rectSize = (rectRight - rectLeft) * (rectBottom - rectTop); | ||
datas.startY -= offsetY; | ||
datas.selectableRects.forEach(function (rect) { | ||
rect.top -= offsetY; | ||
rect.bottom -= offsetY; | ||
rect.left -= offsetX; | ||
rect.right -= offsetX; | ||
datas.selectablePoints.forEach(function (rect) { | ||
[rect.pos1, rect.pos2, rect.pos3, rect.pos4].forEach(function (pos) { | ||
pos[0] -= offsetX; | ||
pos[1] -= offsetY; | ||
}); | ||
}); | ||
@@ -1071,3 +1088,3 @@ | ||
this.target.style.cssText += "display: block;" + "left:0px;top:0px;" + ("transform: translate(" + left + "px, " + top + "px);") + ("width:" + width + "px;height:" + height + "px;"); | ||
var passedTargets = this.hitTest(rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectableRects); | ||
var passedTargets = this.hitTest(rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectablePoints); | ||
var selectedTargets = this.passSelectedTargets(passedTargets); | ||
@@ -1074,0 +1091,0 @@ this.trigger("drag", __assign(__assign({}, e), { |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 1.7.3 | ||
version: 1.7.4 | ||
*/ | ||
@@ -13,3 +13,3 @@ import EventEmitter from '@scena/event-emitter'; | ||
import { Properties } from 'framework-utils'; | ||
import { hasClass, addClass, caculateBoundSize, removeEvent, addEvent, isObject, isArray, camelize, isString } from '@daybrush/utils'; | ||
import { hasClass, addClass, calculateBoundSize, removeEvent, addEvent, isObject, isArray, camelize, isString } from '@daybrush/utils'; | ||
import ChildrenDiffer, { diff } from '@egjs/children-differ'; | ||
@@ -197,3 +197,3 @@ import DragScroll from '@scena/dragscroll'; | ||
var maxHeight = distY < 0 ? startY - boundArea.top : boundArea.bottom - startY; | ||
_a = caculateBoundSize([width, height], [0, 0], [maxWidth, maxHeight], !!ratio), width = _a[0], height = _a[1]; | ||
_a = calculateBoundSize([width, height], [0, 0], [maxWidth, maxHeight], !!ratio), width = _a[0], height = _a[1]; | ||
distX = (distX >= 0 ? 1 : -1) * width; | ||
@@ -214,2 +214,15 @@ distY = (distY >= 0 ? 1 : -1) * height; | ||
} | ||
function getDefaultElementPoints(el) { | ||
var rect = el.getBoundingClientRect(); | ||
var left = rect.left, | ||
top = rect.top, | ||
width = rect.width, | ||
height = rect.height; | ||
return { | ||
pos1: [left, top], | ||
pos2: [left + width, top], | ||
pos3: [left, top + height], | ||
pos4: [left + width, top + height] | ||
}; | ||
} | ||
@@ -222,3 +235,3 @@ var injector = styled("\n:host {\n position: fixed;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n"); | ||
var CLASS_NAME = "selecto-selection " + injector.className; | ||
var PROPERTIES = ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio"]; | ||
var PROPERTIES = ["boundContainer", "selectableTargets", "selectByClick", "selectFromInside", "continueSelect", "toggleContinueSelect", "keyContainer", "hitRate", "scrollOptions", "checkInput", "preventDefault", "ratio", "getElementPoints"]; | ||
/** | ||
@@ -246,3 +259,4 @@ * @memberof Selecto | ||
cspNonce: String, | ||
ratio: Number | ||
ratio: Number, | ||
getElementPoints: Function | ||
}; | ||
@@ -586,2 +600,3 @@ /** | ||
boundContainer: false, | ||
getElementPoints: getDefaultElementPoints, | ||
cspNonce: "", | ||
@@ -696,20 +711,9 @@ ratio: 0 | ||
var getElementPoints = this.getElementPoints; | ||
var selectableTargets = this.getSelectableTargets(); | ||
var selectableRects = selectableTargets.map(function (target) { | ||
var rect = target.getBoundingClientRect(); | ||
var left = rect.left, | ||
top = rect.top, | ||
width = rect.width, | ||
height = rect.height; | ||
return { | ||
left: left, | ||
top: top, | ||
right: left + width, | ||
bottom: top + height, | ||
width: width, | ||
height: height | ||
}; | ||
var selectablePoints = selectableTargets.map(function (target) { | ||
return getElementPoints(target); | ||
}); | ||
datas.selectableTargets = selectableTargets; | ||
datas.selectableRects = selectableRects; | ||
datas.selectablePoints = selectablePoints; | ||
}; | ||
@@ -797,3 +801,3 @@ /** | ||
__proto.hitTest = function (selectRect, clientX, clientY, targets, rects) { | ||
__proto.hitTest = function (selectRect, clientX, clientY, targets, points) { | ||
var _a = this.options, | ||
@@ -807,7 +811,20 @@ hitRate = _a.hitRate, | ||
return targets.filter(function (target, i) { | ||
var _a = rects[i], | ||
rectLeft = _a.left, | ||
rectTop = _a.top, | ||
rectRight = _a.right, | ||
rectBottom = _a.bottom; | ||
var _a = points[i], | ||
pos1 = _a.pos1, | ||
pos2 = _a.pos2, | ||
pos3 = _a.pos3, | ||
pos4 = _a.pos4; | ||
var _b = [0, 1].map(function (j) { | ||
return Math.min(pos1[j], pos2[j], pos3[j], pos4[j]); | ||
}), | ||
rectLeft = _b[0], | ||
rectTop = _b[1]; | ||
var _c = [0, 1].map(function (j) { | ||
return Math.max(pos1[j], pos2[j], pos3[j], pos4[j]); | ||
}), | ||
rectRight = _c[0], | ||
rectBottom = _c[1]; | ||
var isStart = rectLeft <= clientX && clientX <= rectRight && rectTop <= clientY && clientY <= rectBottom; | ||
@@ -856,7 +873,7 @@ var rectSize = (rectRight - rectLeft) * (rectBottom - rectTop); | ||
datas.startY -= offsetY; | ||
datas.selectableRects.forEach(function (rect) { | ||
rect.top -= offsetY; | ||
rect.bottom -= offsetY; | ||
rect.left -= offsetX; | ||
rect.right -= offsetX; | ||
datas.selectablePoints.forEach(function (rect) { | ||
[rect.pos1, rect.pos2, rect.pos3, rect.pos4].forEach(function (pos) { | ||
pos[0] -= offsetX; | ||
pos[1] -= offsetY; | ||
}); | ||
}); | ||
@@ -1070,3 +1087,3 @@ | ||
this.target.style.cssText += "display: block;" + "left:0px;top:0px;" + ("transform: translate(" + left + "px, " + top + "px);") + ("width:" + width + "px;height:" + height + "px;"); | ||
var passedTargets = this.hitTest(rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectableRects); | ||
var passedTargets = this.hitTest(rect, datas.startX, datas.startY, datas.selectableTargets, datas.selectablePoints); | ||
var selectedTargets = this.passSelectedTargets(passedTargets); | ||
@@ -1073,0 +1090,0 @@ this.trigger("drag", __assign(__assign({}, e), { |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/selecto.git | ||
version: 1.7.3 | ||
version: 1.7.4 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Selecto=e()}(this,function(){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var E=function(){return(E=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};var S="string",l=['"',"'",'\\"',"\\'"];function u(t){return t&&"object"==typeof t}function h(t,e,n,r){for(var i=n;i<r;++i){var o=e[i].trim();if(o===t)return i;var a=i;if("("===o?a=h(")",e,i+1,r):-1<l.indexOf(o)&&(a=h(o,e,i+1,r)),-1===a)break;i=a}return-1}function s(t){return function(t,e){for(var n=new RegExp("(\\s*"+(e||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=t.split(n).filter(Boolean),i=r.length,o=[],a=[],s=0;s<i;++s){var c=r[s].trim(),u=s;if("("===c)u=h(")",r,s+1,i);else{if(")"===c)throw new Error("invalid format");if(-1<l.indexOf(c))u=h(c,r,s+1,i);else if(c===e){a.length&&(o.push(a.join("")),a=[]);continue}}-1===u&&(u=i-1),a.push(r.slice(s,u+1).join("")),s=u}return a.length&&o.push(a.join("")),o}(t,",")}function w(){return Date.now?Date.now():(new Date).getTime()}function f(t,n,r){return[[n[0],n[0]*t[1]/t[0]],[n[1]*t[0]/t[1],n[1]]].filter(function(t){return t.every(function(t,e){return r?t<=n[e]:t>=n[e]})})[0]||t}function v(t,o,a,e){if(!e)return t.map(function(t,e){return n=t,r=o[e],i=a[e],Math.max(r,Math.min(n,i));var n,r,i});var n=t[0],r=t[1],i=f(t,o,!1),s=i[0],c=i[1],u=f(t,a,!0),l=u[0],h=u[1];return n<s||r<c?(n=s,r=c):(l<n||h<r)&&(n=l,r=h),[n,r]}function b(t,e,n,r){t.addEventListener(e,n,r)}function C(t,e,n){t.removeEventListener(e,n)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};var t=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(u(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(u(t))for(var n in t)this.off(n);else if(e){var r=this._events[t];if(r){var i=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,i=0;i<r;++i)if(e(t[i],i,t))return i;return n}(r,function(t){return t.listener===e});-1<i&&r.splice(i,1)}}else this._events[t]=[];else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this;void 0===n&&(n={});var t=this._events[e];if(!e||!t)return!0;var i=!1;return n.eventType=e,n.stop=function(){i=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!i},e.trigger=function(t,e){return void 0===e&&(e={}),this.emit(t,e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(i({listener:e},n))},t}(),o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var D=function(){return(D=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t){return 180*(e=[t[0].clientX,t[0].clientY],n=[t[1].clientX,t[1].clientY],r=n[0]-e[0],i=n[1]-e[1],(0<=(o=Math.atan2(i,r))?o:o+2*Math.PI)/Math.PI);var e,n,r,i,o}function k(t){return t.touches?function(t){for(var e=Math.min(t.length,2),n=[],r=0;r<e;++r)n.push(g(t[r]));return n}(t.touches):[g(t)]}function a(t,e,n){var r=n.length,i=d(t,r),o=i.clientX,a=i.clientY,s=i.originalClientX,c=i.originalClientY,u=d(e,r),l=u.clientX,h=u.clientY,f=d(n,r);return{clientX:s,clientY:c,deltaX:o-l,deltaY:a-h,distX:o-f.clientX,distY:a-f.clientY}}function r(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function g(t){return{clientX:t.clientX,clientY:t.clientY}}function d(t,e){void 0===e&&(e=t.length);for(var n={clientX:0,clientY:0,originalClientX:0,originalClientY:0},r=0;r<e;++r){var i=t[r];n.originalClientX+="originalClientX"in i?i.originalClientX:i.clientX,n.originalClientY+="originalClientY"in i?i.originalClientY:i.clientY,n.clientX+=i.clientX,n.clientY+=i.clientY}return e?{clientX:n.clientX/e,clientY:n.clientY/e,originalClientX:n.originalClientX/e,originalClientY:n.originalClientY/e}:n}var O=function(){function t(t){this.prevClients=[],this.startClients=[],this.movement=0,this.length=0,this.startClients=t,this.prevClients=t,this.length=t.length}var e=t.prototype;return e.addClients=function(t){void 0===t&&(t=this.prevClients);var e=this.getPosition(t),n=e.deltaX,r=e.deltaY;return this.movement+=Math.sqrt(n*n+r*r),this.prevClients=t,e},e.getAngle=function(t){return void 0===t&&(t=this.prevClients),n(t)},e.getRotation=function(t){return void 0===t&&(t=this.prevClients),n(t)-n(this.startClients)},e.getPosition=function(t){return a(t||this.prevClients,this.prevClients,this.startClients)},e.getPositions=function(n){void 0===n&&(n=this.prevClients);var r=this.prevClients;return this.startClients.map(function(t,e){return a([n[e]],[r[e]],[t])})},e.getMovement=function(t){var e=this.movement;if(!t)return e;var n=d(t,this.length),r=d(this.prevClients,this.length),i=n.clientX-r.clientX,o=n.clientY-r.clientY;return Math.sqrt(i*i+o*o)+e},e.getDistance=function(t){return void 0===t&&(t=this.prevClients),r(t)},e.getScale=function(t){return void 0===t&&(t=this.prevClients),r(t)/r(this.startClients)},e.move=function(e,n){this.startClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=e,t.clientY-=n})},t}(),T=["textarea","input"],p=function(c){function t(){this.constructor=e}var e,n;function r(t,e){void 0===e&&(e={});var y=c.call(this)||this;y.options={},y.flag=!1,y.pinchFlag=!1,y.datas={},y.isDrag=!1,y.isPinch=!1,y.isMouse=!1,y.isTouch=!1,y.clientStores=[],y.targets=[],y.prevTime=0,y.isDouble=!1,y.onDragStart=function(t,e){if(void 0===e&&(e=!0),y.flag||!1!==t.cancelable){var n=y.options,r=n.container,i=n.pinchOutside,o=n.preventRightClick,a=n.preventDefault,s=n.checkInput,c=y.isTouch,u=!y.flag;if(u){var l=document.activeElement,h=t.target,f=h.tagName.toLowerCase(),g=-1<T.indexOf(f),d=h.isContentEditable;if(g||d){if(s||l===h)return!1;if(l&&d&&l.isContentEditable&&l.contains(h))return!1}else if((a||"touchstart"===t.type)&&l){var p=l.tagName;(l.isContentEditable||-1<T.indexOf(p))&&l.blur()}if(y.clientStores=[new O(k(t))],y.flag=!0,y.isDrag=!1,y.datas={},o&&(3===t.which||2===t.button))return y.initDrag(),!1;!1===y.emit("dragStart",D({datas:y.datas,inputEvent:t,isTrusted:e},y.getCurrentStore().getPosition()))&&y.initDrag(),y.isDouble=w()-y.prevTime<200,y.flag&&a&&t.preventDefault()}if(!y.flag)return!1;var v,m=0;if(u&&c&&i&&(m=setTimeout(function(){b(r,"touchstart",y.onDragStart,{passive:!1})})),!u&&c&&i&&C(r,"touchstart",y.onDragStart),y.flag&&((v=t).touches&&2<=v.touches.length)){if(clearTimeout(m),u&&t.touches.length!==t.changedTouches.length)return;y.pinchFlag||y.onPinchStart(t)}}},y.onDrag=function(t,e){if(y.flag){var n=k(t),r=y.moveClients(n,t,!1);(y.pinchFlag||r.deltaX||r.deltaY)&&y.emit("drag",D({},r,{isScroll:!!e,inputEvent:t})),y.pinchFlag&&y.onPinch(t,n),y.getCurrentStore().addClients(n)}},y.onDragEnd=function(t){if(y.flag){var e=y.options,n=e.pinchOutside,r=e.container;y.isTouch&&n&&C(r,"touchstart",y.onDragStart),y.flag=!1;var i=y.getCurrentStore().getPosition(),o=w(),a=!y.isDrag&&y.isDouble;y.prevTime=y.isDrag||a?0:o,y.emit("dragEnd",D({datas:y.datas,isDouble:a,isDrag:y.isDrag,inputEvent:t},i)),y.pinchFlag&&y.onPinchEnd(t),y.clientStores=[]}},y.onBlur=function(){y.onDragEnd()};var n=[].concat(t);y.options=D({checkInput:!1,container:1<n.length?window:n[0],preventRightClick:!0,preventDefault:!0,checkWindowBlur:!1,pinchThreshold:0,events:["touch","mouse"]},e);var r=y.options,i=r.container,o=r.events,a=r.checkWindowBlur;if(y.isTouch=-1<o.indexOf("touch"),y.isMouse=-1<o.indexOf("mouse"),y.targets=n,y.isMouse&&(n.forEach(function(t){b(t,"mousedown",y.onDragStart)}),b(i,"mousemove",y.onDrag),b(i,"mouseup",y.onDragEnd),b(i,"contextmenu",y.onDragEnd)),a&&b(window,"blur",y.onBlur),y.isTouch){var s={passive:!1};n.forEach(function(t){b(t,"touchstart",y.onDragStart,s)}),b(i,"touchmove",y.onDrag,s),b(i,"touchend",y.onDragEnd,s),b(i,"touchcancel",y.onDragEnd,s)}return y}o(e=r,n=c),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t);var i=r.prototype;return i.getMovement=function(t){return this.getCurrentStore().getMovement(t)+this.clientStores.slice(1).reduce(function(t,e){return t+e.movement},0)},i.isDragging=function(){return this.isDrag},i.isFlag=function(){return this.flag},i.isPinchFlag=function(){return this.pinchFlag},i.isPinching=function(){return this.isPinch},i.scrollBy=function(t,e,n,r){void 0===r&&(r=!0),this.flag&&(this.clientStores[0].move(t,e),r&&this.onDrag(n,!0))},i.move=function(t,e){var r=t[0],i=t[1],n=this.getCurrentStore().prevClients;return this.moveClients(n.map(function(t){var e=t.clientX,n=t.clientY;return{clientX:e+r,clientY:n+i,originalClientX:e,originalClientY:n}}),e,!0)},i.triggerDragStart=function(t){this.onDragStart(t,!1)},i.setEventDatas=function(t){var e=this.datas;for(var n in t)e[n]=t[n];return this},i.getEventDatas=function(){return this.datas},i.unset=function(){var e=this,t=this.targets,n=this.options.container;this.off(),C(window,"blur",this.onBlur),this.isMouse&&(t.forEach(function(t){C(t,"mousedown",e.onDragStart)}),C(n,"mousemove",this.onDrag),C(n,"mouseup",this.onDragEnd),C(n,"contextmenu",this.onDragEnd)),this.isTouch&&(t.forEach(function(t){C(t,"touchstart",e.onDragStart)}),C(n,"touchstart",this.onDragStart),C(n,"touchmove",this.onDrag),C(n,"touchend",this.onDragEnd),C(n,"touchcancel",this.onDragEnd))},i.onPinchStart=function(t){var e=this.options.pinchThreshold;if(!(this.isDrag&&this.getMovement()>e)){var n=new O(k(t));this.pinchFlag=!0,this.clientStores.splice(0,0,n),!1===this.emit("pinchStart",D({datas:this.datas,angle:n.getAngle(),touches:this.getCurrentStore().getPositions()},n.getPosition(),{inputEvent:t}))&&(this.pinchFlag=!1)}},i.onPinch=function(t,e){if(this.flag&&this.pinchFlag&&!(e.length<2)){var n=this.getCurrentStore();this.isPinch=!0,this.emit("pinch",D({datas:this.datas,movement:this.getMovement(e),angle:n.getAngle(e),rotation:n.getRotation(e),touches:n.getPositions(e),scale:n.getScale(e),distance:n.getDistance(e)},n.getPosition(e),{inputEvent:t}))}},i.onPinchEnd=function(t){if(this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.getCurrentStore();this.emit("pinchEnd",D({datas:this.datas,isPinch:e,touches:n.getPositions()},n.getPosition(),{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}},i.initDrag=function(){this.clientStores=[],this.pinchFlag=!1,this.flag=!1},i.getCurrentStore=function(){return this.clientStores[0]},i.moveClients=function(t,e,n){var r=this.getCurrentStore()[n?"addClients":"getPosition"](t);return this.isDrag=!0,D({datas:this.datas},r,{movement:this.getMovement(t),isDrag:this.isDrag,isPinch:this.isPinch,isScroll:!1,inputEvent:e})},r}(t);var y=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,r=this.values,i=n.indexOf(t),o=-1===i?n.length:i;n[o]=t,r[o]=e},t}(),_=function(){function t(){this.object={}}var e=t.prototype;return e.get=function(t){return this.object[t]},e.set=function(t,e){this.object[t]=e},t}(),P="function"==typeof Map,m=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var x=function(){function t(t,e,n,r,i,o,a,s){this.prevList=t,this.list=e,this.added=n,this.removed=r,this.changed=i,this.maintained=o,this.changedBeforeAdded=a,this.fixed=s}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t,n,s,c,e=(t=this.changedBeforeAdded,n=this.fixed,s=[],c=[],t.forEach(function(t){var e=t[0],n=t[1],r=new m;s[e]=r,c[n]=r}),s.forEach(function(t,e){t.connect(s[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],r=t[1];if(n===r)return[0,0];var i=s[n],o=c[r-1],a=i.getIndex();return i.disconnect(),o?i.connect(o,o.next):i.connect(void 0,s[0]),[a,i.getIndex()]})),u=this.changed,l=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],r=t[1],i=u[e],o=i[0],a=i[1];if(n!==r)return l.push([o,a]),!0}),this.cachePureChanged=l},t}();function Y(t,e,n){var r=P?Map:n?_:y,i=n||function(t){return t},o=[],a=[],s=[],c=t.map(i),u=e.map(i),l=new r,h=new r,f=[],g=[],d={},p=[],v=0,m=0;return c.forEach(function(t,e){l.set(t,e)}),u.forEach(function(t,e){h.set(t,e)}),c.forEach(function(t,e){var n=h.get(t);void 0===n?(++m,a.push(e)):d[n]=m}),u.forEach(function(t,e){var n=l.get(t);void 0===n?(o.push(e),++v):(s.push([n,e]),m=d[e]||0,f.push([n-m,e-v]),g.push(e===n),n!==e&&p.push([n,e]))}),a.reverse(),new x(t,e,o,a,p,s,f,g)}var X=function(t,e){return(X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var e,j="function"==typeof Map?void 0:(e=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++e)}),K=function(e){function t(){this.constructor=n}var n,r;function i(t){return void 0===t&&(t=[]),e.call(this,t,j)||this}return X(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t),i}(function(){function t(t,e){void 0===t&&(t=[]),this.findKeyCallback=e,this.list=[].slice.call(t)}return t.prototype.update=function(t){var e=[].slice.call(t),n=Y(this.list,e,this.findKeyCallback);return this.list=e,n},t}());function M(t,e){return Y(t,e,j)}var A=function(t,e){return(A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function R(t){var e=t.container;return[e.scrollLeft,e.scrollTop]}var B=function(e){function t(){this.constructor=n}var n,r;function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.startRect=null,t.startPos=[],t.prevTime=0,t.timer=0,t}A(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return o.dragStart=function(t,e){var n=e.container.getBoundingClientRect(),r=n.top,i=n.left,o=n.width,a=n.height;this.startPos=[t.clientX,t.clientY],this.startRect={top:r,left:i,width:o,height:a}},o.drag=function(t,e){var n=this,r=t.clientX,i=t.clientY,o=e.container,a=e.threshold,s=void 0===a?0:a,c=e.throttleTime,u=void 0===c?0:c,l=e.getScrollPosition,h=void 0===l?R:l,f=this.startRect,g=this.startPos,d=w(),p=Math.max(u+this.prevTime-d,0),v=[0,0];if(f.top>i-s?(g[1]>f.top||i<g[1])&&(v[1]=-1):f.top+f.height<i+s&&(g[1]<f.top+f.height||i>g[1])&&(v[1]=1),f.left>r-s?(g[0]>f.left||r<g[0])&&(v[0]=-1):f.left+f.width<r+s&&(g[0]<f.left+f.width||r>g[0])&&(v[0]=1),clearTimeout(this.timer),!v[0]&&!v[1])return!1;if(0<p)return this.timer=window.setTimeout(function(){n.drag(t,e)},p),!1;this.prevTime=d;var m=h({container:o,direction:v});this.trigger("scroll",{container:o,direction:v,inputEvent:t});var y=h({container:o,direction:v}),b=y[0]-m[0],C=y[1]-m[1];return!(!b&&!C)&&(this.trigger("move",{offsetX:v[0]?b:0,offsetY:v[1]?C:0,inputEvent:t}),u&&(this.timer=window.setTimeout(function(){n.drag(t,e)},u)),!0)},o.dragEnd=function(){clearTimeout(this.timer)},i}(t),F=function(t,e){return(F=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function N(t){return t&&"object"==typeof t}function I(t){return Array.isArray(t)}function L(t){return"string"==typeof t}function q(t,e,n,r){t.addEventListener(e,n,r)}function U(t,e,n){t.removeEventListener(e,n)}var W=function(){return(W=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};var z=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(N(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(N(t))for(var n in t)this.off(n);else if(e){var r=this._events[t];if(r){var i=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,i=0;i<r;++i)if(e(t[i],i,t))return i;return n}(r,function(t){return t.listener===e});-1<i&&r.splice(i,1)}}else this._events[t]=[];else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this;void 0===n&&(n={});var t=this._events[e];if(!e||!t)return!0;var i=!1;return n.eventType=e,n.stop=function(){i=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!i},e.trigger=function(t,e){return void 0===e&&(e={}),this.emit(t,e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(W({listener:e},n))},t}();var H,G,V=(function(t,e){function n(t){if(t&&"object"==typeof t){var e=t.which||t.keyCode||t.charCode;e&&(t=e)}if("number"==typeof t)return a[t];var n,r=String(t);return(n=i[r.toLowerCase()])?n:(n=o[r.toLowerCase()])||(1===r.length?r.charCodeAt(0):void 0)}n.isEventKey=function(t,e){if(t&&"object"==typeof t){var n=t.which||t.keyCode||t.charCode;if(null==n)return!1;if("string"==typeof e){var r;if(r=i[e.toLowerCase()])return r===n;if(r=o[e.toLowerCase()])return r===n}else if("number"==typeof e)return e===n;return!1}};var i=(e=t.exports=n).code=e.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=e.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91};for(r=97;r<123;r++)i[String.fromCharCode(r)]=r-32;for(var r=48;r<58;r++)i[r-48]=r;for(r=1;r<13;r++)i["f"+r]=r+111;for(r=0;r<10;r++)i["numpad "+r]=r+96;var a=e.names=e.title={};for(r in i)a[i[r]]=r;for(var s in o)i[s]=o[s]}(H={exports:{}},H.exports),H.exports),$=(V.code,V.codes,V.aliases,V.names),J=(V.title,{"+":"plus","left command":"meta","right command":"meta"}),Q={shift:1,ctrl:2,alt:3,meta:4};function Z(t){var e=$[t]||"";for(var n in J)e=e.replace(n,J[n]);return e.replace(/\s/g,"")}function tt(t,e){void 0===e&&(e=Z(t.keyCode));var n,r=[(n=t).shiftKey&&"shift",n.ctrlKey&&"ctrl",n.altKey&&"alt",n.metaKey&&"meta"].filter(Boolean);return-1===r.indexOf(e)&&r.push(e),r.filter(Boolean)}function et(t){var e=t.slice();return e.sort(function(t,e){return(Q[t]||5)-(Q[e]||5)}),e}var nt=function(n){function t(){this.constructor=e}var e,r;function i(t){void 0===t&&(t=window);var e=n.call(this)||this;return e.container=t,e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e.clear=function(){return e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e},e.keydownEvent=function(t){e.triggerEvent("keydown",t)},e.keyupEvent=function(t){e.triggerEvent("keyup",t)},e.blur=function(){e.clear(),e.trigger("blur")},q(t,"blur",e.blur),q(t,"keydown",e.keydownEvent),q(t,"keyup",e.keyupEvent),e}F(e=i,r=n),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return Object.defineProperty(i,"global",{get:function(){return G=G||new i},enumerable:!1,configurable:!0}),i.setGlobal=function(){return this.global},o.destroy=function(){var t=this.container;this.clear(),this.off(),U(t,"blur",this.blur),U(t,"keydown",this.keydownEvent),U(t,"keyup",this.keyupEvent)},o.keydown=function(t,e){return this.addEvent("keydown",t,e)},o.offKeydown=function(t,e){return this.removeEvent("keydown",t,e)},o.offKeyup=function(t,e){return this.removeEvent("keyup",t,e)},o.keyup=function(t,e){return this.addEvent("keyup",t,e)},o.addEvent=function(t,e,n){return I(e)?this.on(t+"."+et(e).join("."),n):L(e)?this.on(t+"."+e,n):this.on(t,e),this},o.removeEvent=function(t,e,n){return I(e)?this.off(t+"."+et(e).join("."),n):L(e)?this.off(t+"."+e,n):this.off(t,e),this},o.triggerEvent=function(t,e){this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey;var n=Z(e.keyCode),r={key:n,isToggle:"ctrl"===n||"shift"===n||"meta"===n||"alt"===n,inputEvent:e,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey};this.trigger(t,r),this.trigger(t+"."+n,r);var i=tt(e,n);1<i.length&&this.trigger(t+"."+i.join("."),r)},i}(z);function rt(t,e,n){var r=t.tag,i=t.children,o=t.attributes,a=t.className,s=t.style,c=e||document.createElement(r);for(var u in o)c.setAttribute(u,o[u]);var l=c.children;if(i.forEach(function(t,e){rt(t,l[e],c)}),a&&a.split(" ").forEach(function(t){var e,n,r,i;i=t,((r=c).classList?r.classList.contains(i):r.className.match(new RegExp("(\\s|^)"+i+"(\\s|$)")))||(n=t,(e=c).classList?e.classList.add(n):e.className+=" "+n)}),s){var h=c.style;for(var u in s)h[u]=s[u]}return!e&&n&&n.appendChild(c),c}function it(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=e||{},o=i.className,a=i.style;return{tag:t,className:void 0===o?"":o,style:void 0===a?{}:a,attributes:function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(i,["className","style"]),children:n}}function ot(t,e,n){t!==e&&n(t,e)}function at(t,e,n){var r,i=t.distX,o=void 0===i?0:i,a=t.distY,s=void 0===a?0:a,c=t.datas,u=c.startX,l=c.startY;if(0<e){var h=Math.sqrt((o*o+s*s)/(1+e*e));o=(0<=o?1:-1)*(e*h),s=(0<=s?1:-1)*h}var f=Math.abs(o),g=Math.abs(s);o=(0<=o?1:-1)*(f=(r=v([f,g],[0,0],[o<0?u-n.left:n.right-u,s<0?l-n.top:n.bottom-l],!!e))[0]),s=(0<=s?1:-1)*(g=r[1]);var d=u+Math.min(0,o),p=l+Math.min(0,s);return{left:d,top:p,right:d+f,bottom:p+g,width:f,height:g}}function st(t,e,n,r){var i,o,a=document.createElement("style");return a.setAttribute("type","text/css"),a.setAttribute("data-styled-id",t),n.nonce&&a.setAttribute("nonce",n.nonce),a.innerHTML=(i=t,o=e,n.original?o:o.replace(/([^};{\s}][^};{]*|^\s*){/gm,function(t,e){var n=e.trim();return(n?s(n):[""]).map(function(t){var e=t.trim();return 0===e.indexOf("@")?e:-1<e.indexOf(":global")?e.replace(/\:global/g,""):-1<e.indexOf(":host")?""+e.replace(/\:host/g,"."+i):e?"."+i+" "+e:"."+i}).join(", ")+" {"})),(r||document.head||document.body).appendChild(a),a}var ct,ut,lt,ht,ft=(lt="rCS"+function(t){for(var e=5381,n=t.length;n;)e=33*e^t.charCodeAt(--n);return e>>>0}(ct="\n:host {\n position: fixed;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n").toString(36),ht=0,{className:lt,inject:function(t,e){void 0===e&&(e={});var n,r=function(t){if(t&&t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),i=0===ht;return(r||i)&&(n=st(lt,ct,e,r)),i&&(ut=n),r||++ht,{destroy:function(){r?(t.removeChild(n),n=null):(0<ht&&--ht,0===ht&&ut&&(ut.parentNode.removeChild(ut),ut=null))}}}}),gt="selecto-selection "+ft.className,dt=["boundContainer","selectableTargets","selectByClick","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate","scrollOptions","checkInput","preventDefault","ratio"],pt=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(["dragContainer","cspNonce"],dt),vt={boundContainer:null,target:null,container:null,dragContainer:null,selectableTargets:Array,selectByClick:Boolean,selectFromInside:Boolean,continueSelect:Boolean,toggleContinueSelect:Array,keyContainer:null,hitRate:Number,scrollOptions:Object,checkInput:Boolean,preventDefault:Boolean,cspNonce:String,ratio:Number},mt=function(e){function t(){this.constructor=n}var n,r;function i(t){void 0===t&&(t={});var C=e.call(this)||this;return C.selectedTargets=[],C.differ=new K,C.dragScroll=new B,C.onDragStart=function(t,e){var n=t.datas,r=t.clientX,i=t.clientY,o=t.inputEvent,a=C.options,s=a.continueSelect,c=a.selectFromInside,u=a.selectByClick,l=a.boundContainer;C.findSelectableTargets(n),n.startSelectedTargets=C.selectedTargets;var h={left:-1/0,top:-1/0,right:1/0,bottom:1/0};if(l){var f=(typeof l===S?document.querySelector(l):!0===l?C.container:l).getBoundingClientRect();h={left:f.left,top:f.top,right:f.right,bottom:f.bottom}}n.boundArea=h,n.selectedTargets=[];var g={left:r,top:i,right:r,bottom:i,width:0,height:0},d=[];if(!c||u){for(var p=e||document.elementFromPoint(r,i);p&&!(-1<n.selectableTargets.indexOf(p));)p=p.parentElement;d=p?[p]:[]}var v=0<d.length,m=!c&&v;if(m&&!u)return t.stop(),!1;var y=o.type;if(!(!("mousedown"===y||"touchstart"===y)||C.trigger("dragStart",E({},t))))return t.stop(),!1;if(s?d=C.passSelectedTargets(d):C.selectedTargets=[],C.select(d,g,o,!0),n.startX=r,n.startY=i,n.selectedTargets=d,n.boundsArea=C.target.style.cssText+="left:0px;top:0px;transform: translate("+r+"px, "+i+"px)",m&&u)return C.onDragEnd(t),o.preventDefault(),t.stop(),!1;"touchstart"===y&&o.preventDefault();var b=C.options.scrollOptions;return b&&b.container&&C.dragScroll.dragStart(t,b),!0},C.onDrag=function(t){var e=C.options.scrollOptions;e&&e.container&&C.dragScroll.drag(t,e)||C.check(t)},C.onDragEnd=function(t){var e=t.datas,n=t.inputEvent,r=at(t,C.options.ratio,e.boundArea);C.dragScroll.dragEnd(),C.target.style.cssText+="display: none;",n&&"mousedown"!==n.type&&"touchstart"!==n.type&&C.trigger("dragEnd",E(E({isDouble:!1,isDrag:!1},t),{rect:r})),C.selectEnd(e.startSelectedTargets,e.selectedTargets,r,t),C.selectedTargets=e.selectedTargets},C.onKeyDown=function(t){C.sameCombiKey(t)&&(C.continueSelect=!0,C.trigger("keydown",{}))},C.onKeyUp=function(t){C.sameCombiKey(t,!0)&&(C.continueSelect=!1,C.trigger("keyup",{}))},C.onBlur=function(){C.toggleContinueSelect&&C.continueSelect&&(C.continueSelect=!1,C.trigger("keyup",{}))},C.onDocumentSelectStart=function(e){if(C.gesto.isFlag()){var t=C.dragContainer;t===window&&(t=document.documentElement);var n=t instanceof Element?[t]:[].slice.call(t),r=e.target;n.some(function(t){if(t===r||t.contains(r))return e.preventDefault(),!0})}},C.target=t.target,C.container=t.container,C.options=E({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectFromInside:!0,hitRate:100,continueSelect:!1,toggleContinueSelect:null,keyContainer:null,scrollOptions:void 0,checkInput:!1,preventDefault:!1,boundContainer:!1,cspNonce:"",ratio:0},t),C.initElement(),C.initDragScroll(),C.setKeyController(),C}c(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o,a,s=i.prototype;return s.setSelectedTargets=function(t){return this.selectedTargets=t,this.differ=new K(t),this},s.getSelectedTargets=function(){return this.selectedTargets},s.setKeyContainer=function(t){var e=this,n=this.options;ot(n.keyContainer,t,function(){n.keyContainer=t,e.setKeyController()})},s.setToggleContinueSelect=function(t){var e=this,n=this.options;ot(n.toggleContinueSelect,t,function(){n.toggleContinueSelect=t,e.setKeyEvent()})},s.setPreventDefault=function(t){this.gesto.options.preventDefault=t},s.setCheckInput=function(t){this.gesto.options.checkInput=t},s.triggerDragStart=function(t){return this.gesto.triggerDragStart(t),this},s.destroy=function(){this.off(),this.keycon&&this.keycon.destroy(),this.gesto.unset(),this.injectResult.destroy(),C(document,"selectstart",this.onDocumentSelectStart),this.keycon=null,this.gesto=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},s.findSelectableTargets=function(t){void 0===t&&(t=this.gesto.getEventDatas());var e=this.getSelectableTargets(),n=e.map(function(t){var e=t.getBoundingClientRect(),n=e.left,r=e.top,i=e.width,o=e.height;return{left:n,top:r,right:n+i,bottom:r+o,width:i,height:o}});t.selectableTargets=e,t.selectableRects=n},s.clickTarget=function(t,e){var n=function(t){if("touches"in t){var e=t.touches[0]||t.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),r={datas:{},clientX:n.clientX,clientY:n.clientY,inputEvent:t,stop:function(){return!1}};return this.onDragStart(r,e)&&this.onDragEnd(r),this},s.setKeyController=function(){var t=this.options,e=t.keyContainer,n=t.toggleContinueSelect;this.keycon&&(this.keycon.destroy(),this.keycon=null),n&&(this.keycon=new nt(e||window),this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on("blur",this.onBlur))},s.setKeyEvent=function(){this.options.toggleContinueSelect&&!this.keycon&&this.setKeyController()},s.initElement=function(){this.target=rt(it("div",{className:gt}),this.target,this.container);var t=this.target,e=this.options,n=e.dragContainer,r=e.checkInput,i=e.preventDefault;this.dragContainer="string"==typeof n?[].slice.call(document.querySelectorAll(n)):this.options.dragContainer||this.target.parentNode,this.gesto=new p(this.dragContainer,{checkWindowBlur:!0,container:window,checkInput:r,preventDefault:i}).on({dragStart:this.onDragStart,drag:this.onDrag,dragEnd:this.onDragEnd}),b(document,"selectstart",this.onDocumentSelectStart),this.injectResult=ft.inject(t,{nonce:this.options.cspNonce})},s.hitTest=function(t,d,p,e,v){var n=this.options,m=n.hitRate,y=n.selectByClick,b=t.left,C=t.top,E=t.right,S=t.bottom;return e.filter(function(t,e){var n=v[e],r=n.left,i=n.top,o=n.right,a=n.bottom,s=r<=d&&d<=o&&i<=p&&p<=a,c=(o-r)*(a-i),u=Math.max(r,b),l=Math.min(o,E),h=Math.max(i,C),f=Math.min(a,S);if(y&&s)return!0;if(l<u||f<h)return!1;var g=Math.round((l-u)*(f-h)/c*100);return m<=g})},s.initDragScroll=function(){var o=this;this.dragScroll.on("scroll",function(t){var e=t.container,n=t.direction;o.trigger("scroll",{container:e,direction:n})}).on("move",function(t){var e=t.offsetX,n=t.offsetY,r=t.inputEvent,i=r.datas;i.startX-=e,i.startY-=n,i.selectableRects.forEach(function(t){t.top-=n,t.bottom-=n,t.left-=e,t.right-=e}),o.gesto.scrollBy(e,n,r.inputEvent,!1),r.distX+=e,r.distY+=n,o.check(r)})},s.getSelectableTargets=function(){var e=[];return this.options.selectableTargets.forEach(function(t){u(t)?e.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){e.push(t)})}),e},s.passSelectedTargets=function(t){var e=M(this.selectedTargets,t),n=e.list,r=e.prevList,i=e.added,o=e.removed;return i.map(function(t){return n[t]}).concat(o.map(function(t){return r[t]}))},s.select=function(t,e,n,r){var i=this.differ.update(t),o=i.added,a=i.removed,s=i.prevList,c=i.list;r&&this.trigger("selectStart",{selected:t,added:o.map(function(t){return c[t]}),removed:a.map(function(t){return s[t]}),rect:e,inputEvent:n}),(o.length||a.length)&&this.trigger("select",{selected:t,added:o.map(function(t){return c[t]}),removed:a.map(function(t){return s[t]}),rect:e,inputEvent:n})},s.selectEnd=function(t,e,n,r){var i=r.inputEvent,o=r.isDouble,a=M(t,e),s=a.added,c=a.removed,u=a.prevList,l=a.list,h=M(this.selectedTargets,e),f=h.added,g=h.removed,d=h.prevList,p=h.list,v=i&&i.type,m="mousedown"===v||"touchstart"===v;this.trigger("selectEnd",{selected:e,added:s.map(function(t){return l[t]}),removed:c.map(function(t){return u[t]}),afterAdded:f.map(function(t){return p[t]}),afterRemoved:g.map(function(t){return d[t]}),isDragStart:m,isDouble:!!o,rect:n,inputEvent:i})},s.check=function(t){var e=t.datas,n=t.inputEvent,r=at(t,this.options.ratio,e.boundArea),i=r.top,o=r.left,a=r.width,s=r.height;this.target.style.cssText+="display: block;left:0px;top:0px;transform: translate("+o+"px, "+i+"px);width:"+a+"px;height:"+s+"px;";var c=this.hitTest(r,e.startX,e.startY,e.selectableTargets,e.selectableRects),u=this.passSelectedTargets(c);this.trigger("drag",E(E({},t),{rect:r})),this.select(u,r,n),e.selectedTargets=u},s.sameCombiKey=function(t,e){var n,r=[].concat(this.options.toggleContinueSelect),i=tt(t.inputEvent,t.key),o=(n=r[0],Array.isArray(n)?r:[r]);if(e){var a=t.key;return o.some(function(t){return t.some(function(t){return t===a})})}return o.some(function(t){return t.every(function(t){return-1<i.indexOf(t)})})},i=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;0<=s;s--)(i=t[s])&&(a=(o<3?i(a):3<o?i(e,n,a):i(e,n))||a);return 3<o&&a&&Object.defineProperty(e,n,a),a}([(o=dt,a=function(t,e){var n={enumerable:!0,configurable:!0,get:function(){return this.options[e]}},r=("set "+e).replace(/[\s-_]([a-z])/g,function(t,e){return e.toUpperCase()});t[r]?n.set=function(t){this[r](t)}:n.set=function(t){this.options[e]=t},Object.defineProperty(t,e,n)},function(t){var e=t.prototype;o.forEach(function(t){a(e,t)})})],i)}(t),yt={__proto__:null,default:mt,OPTIONS:pt,OPTION_TYPES:vt,PROPERTIES:dt,EVENTS:["dragStart","drag","dragEnd","selectStart","select","selectEnd","keydown","keyup","scroll"],METHODS:["clickTarget","setSelectedTargets","triggerDragStart"],CLASS_NAME:gt};for(var bt in yt)mt[bt]=yt[bt];return mt}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Selecto=e()}(this,function(){"use strict";var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var E=function(){return(E=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};var S="string",l=['"',"'",'\\"',"\\'"];function u(t){return t&&"object"==typeof t}function h(t,e,n,r){for(var i=n;i<r;++i){var o=e[i].trim();if(o===t)return i;var s=i;if("("===o?s=h(")",e,i+1,r):-1<l.indexOf(o)&&(s=h(o,e,i+1,r)),-1===s)break;i=s}return-1}function a(t){return function(t,e){for(var n=new RegExp("(\\s*"+(e||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=t.split(n).filter(Boolean),i=r.length,o=[],s=[],a=0;a<i;++a){var c=r[a].trim(),u=a;if("("===c)u=h(")",r,a+1,i);else{if(")"===c)throw new Error("invalid format");if(-1<l.indexOf(c))u=h(c,r,a+1,i);else if(c===e){s.length&&(o.push(s.join("")),s=[]);continue}}-1===u&&(u=i-1),s.push(r.slice(a,u+1).join("")),a=u}return s.length&&o.push(s.join("")),o}(t,",")}function w(){return Date.now?Date.now():(new Date).getTime()}function f(t,n,r){return[[n[0],n[0]*t[1]/t[0]],[n[1]*t[0]/t[1],n[1]]].filter(function(t){return t.every(function(t,e){return r?t<=n[e]:t>=n[e]})})[0]||t}function v(t,o,s,e){if(!e)return t.map(function(t,e){return n=t,r=o[e],i=s[e],Math.max(r,Math.min(n,i));var n,r,i});var n=t[0],r=t[1],i=f(t,o,!1),a=i[0],c=i[1],u=f(t,s,!0),l=u[0],h=u[1];return n<a||r<c?(n=a,r=c):(l<n||h<r)&&(n=l,r=h),[n,r]}function C(t,e,n,r){t.addEventListener(e,n,r)}function b(t,e,n){t.removeEventListener(e,n)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};var t=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(u(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(u(t))for(var n in t)this.off(n);else if(e){var r=this._events[t];if(r){var i=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,i=0;i<r;++i)if(e(t[i],i,t))return i;return n}(r,function(t){return t.listener===e});-1<i&&r.splice(i,1)}}else this._events[t]=[];else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this;void 0===n&&(n={});var t=this._events[e];if(!e||!t)return!0;var i=!1;return n.eventType=e,n.stop=function(){i=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!i},e.trigger=function(t,e){return void 0===e&&(e={}),this.emit(t,e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(i({listener:e},n))},t}(),o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var D=function(){return(D=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t){return 180*(e=[t[0].clientX,t[0].clientY],n=[t[1].clientX,t[1].clientY],r=n[0]-e[0],i=n[1]-e[1],(0<=(o=Math.atan2(i,r))?o:o+2*Math.PI)/Math.PI);var e,n,r,i,o}function k(t){return t.touches?function(t){for(var e=Math.min(t.length,2),n=[],r=0;r<e;++r)n.push(g(t[r]));return n}(t.touches):[g(t)]}function s(t,e,n){var r=n.length,i=d(t,r),o=i.clientX,s=i.clientY,a=i.originalClientX,c=i.originalClientY,u=d(e,r),l=u.clientX,h=u.clientY,f=d(n,r);return{clientX:a,clientY:c,deltaX:o-l,deltaY:s-h,distX:o-f.clientX,distY:s-f.clientY}}function r(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function g(t){return{clientX:t.clientX,clientY:t.clientY}}function d(t,e){void 0===e&&(e=t.length);for(var n={clientX:0,clientY:0,originalClientX:0,originalClientY:0},r=0;r<e;++r){var i=t[r];n.originalClientX+="originalClientX"in i?i.originalClientX:i.clientX,n.originalClientY+="originalClientY"in i?i.originalClientY:i.clientY,n.clientX+=i.clientX,n.clientY+=i.clientY}return e?{clientX:n.clientX/e,clientY:n.clientY/e,originalClientX:n.originalClientX/e,originalClientY:n.originalClientY/e}:n}var O=function(){function t(t){this.prevClients=[],this.startClients=[],this.movement=0,this.length=0,this.startClients=t,this.prevClients=t,this.length=t.length}var e=t.prototype;return e.addClients=function(t){void 0===t&&(t=this.prevClients);var e=this.getPosition(t),n=e.deltaX,r=e.deltaY;return this.movement+=Math.sqrt(n*n+r*r),this.prevClients=t,e},e.getAngle=function(t){return void 0===t&&(t=this.prevClients),n(t)},e.getRotation=function(t){return void 0===t&&(t=this.prevClients),n(t)-n(this.startClients)},e.getPosition=function(t){return s(t||this.prevClients,this.prevClients,this.startClients)},e.getPositions=function(n){void 0===n&&(n=this.prevClients);var r=this.prevClients;return this.startClients.map(function(t,e){return s([n[e]],[r[e]],[t])})},e.getMovement=function(t){var e=this.movement;if(!t)return e;var n=d(t,this.length),r=d(this.prevClients,this.length),i=n.clientX-r.clientX,o=n.clientY-r.clientY;return Math.sqrt(i*i+o*o)+e},e.getDistance=function(t){return void 0===t&&(t=this.prevClients),r(t)},e.getScale=function(t){return void 0===t&&(t=this.prevClients),r(t)/r(this.startClients)},e.move=function(e,n){this.startClients.forEach(function(t){t.clientX-=e,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=e,t.clientY-=n})},t}(),T=["textarea","input"],p=function(c){function t(){this.constructor=e}var e,n;function r(t,e){void 0===e&&(e={});var y=c.call(this)||this;y.options={},y.flag=!1,y.pinchFlag=!1,y.datas={},y.isDrag=!1,y.isPinch=!1,y.isMouse=!1,y.isTouch=!1,y.clientStores=[],y.targets=[],y.prevTime=0,y.isDouble=!1,y.onDragStart=function(t,e){if(void 0===e&&(e=!0),y.flag||!1!==t.cancelable){var n=y.options,r=n.container,i=n.pinchOutside,o=n.preventRightClick,s=n.preventDefault,a=n.checkInput,c=y.isTouch,u=!y.flag;if(u){var l=document.activeElement,h=t.target,f=h.tagName.toLowerCase(),g=-1<T.indexOf(f),d=h.isContentEditable;if(g||d){if(a||l===h)return!1;if(l&&d&&l.isContentEditable&&l.contains(h))return!1}else if((s||"touchstart"===t.type)&&l){var p=l.tagName;(l.isContentEditable||-1<T.indexOf(p))&&l.blur()}if(y.clientStores=[new O(k(t))],y.flag=!0,y.isDrag=!1,y.datas={},o&&(3===t.which||2===t.button))return y.initDrag(),!1;!1===y.emit("dragStart",D({datas:y.datas,inputEvent:t,isTrusted:e},y.getCurrentStore().getPosition()))&&y.initDrag(),y.isDouble=w()-y.prevTime<200,y.flag&&s&&t.preventDefault()}if(!y.flag)return!1;var v,m=0;if(u&&c&&i&&(m=setTimeout(function(){C(r,"touchstart",y.onDragStart,{passive:!1})})),!u&&c&&i&&b(r,"touchstart",y.onDragStart),y.flag&&((v=t).touches&&2<=v.touches.length)){if(clearTimeout(m),u&&t.touches.length!==t.changedTouches.length)return;y.pinchFlag||y.onPinchStart(t)}}},y.onDrag=function(t,e){if(y.flag){var n=k(t),r=y.moveClients(n,t,!1);(y.pinchFlag||r.deltaX||r.deltaY)&&y.emit("drag",D({},r,{isScroll:!!e,inputEvent:t})),y.pinchFlag&&y.onPinch(t,n),y.getCurrentStore().addClients(n)}},y.onDragEnd=function(t){if(y.flag){var e=y.options,n=e.pinchOutside,r=e.container;y.isTouch&&n&&b(r,"touchstart",y.onDragStart),y.flag=!1;var i=y.getCurrentStore().getPosition(),o=w(),s=!y.isDrag&&y.isDouble;y.prevTime=y.isDrag||s?0:o,y.emit("dragEnd",D({datas:y.datas,isDouble:s,isDrag:y.isDrag,inputEvent:t},i)),y.pinchFlag&&y.onPinchEnd(t),y.clientStores=[]}},y.onBlur=function(){y.onDragEnd()};var n=[].concat(t);y.options=D({checkInput:!1,container:1<n.length?window:n[0],preventRightClick:!0,preventDefault:!0,checkWindowBlur:!1,pinchThreshold:0,events:["touch","mouse"]},e);var r=y.options,i=r.container,o=r.events,s=r.checkWindowBlur;if(y.isTouch=-1<o.indexOf("touch"),y.isMouse=-1<o.indexOf("mouse"),y.targets=n,y.isMouse&&(n.forEach(function(t){C(t,"mousedown",y.onDragStart)}),C(i,"mousemove",y.onDrag),C(i,"mouseup",y.onDragEnd),C(i,"contextmenu",y.onDragEnd)),s&&C(window,"blur",y.onBlur),y.isTouch){var a={passive:!1};n.forEach(function(t){C(t,"touchstart",y.onDragStart,a)}),C(i,"touchmove",y.onDrag,a),C(i,"touchend",y.onDragEnd,a),C(i,"touchcancel",y.onDragEnd,a)}return y}o(e=r,n=c),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t);var i=r.prototype;return i.getMovement=function(t){return this.getCurrentStore().getMovement(t)+this.clientStores.slice(1).reduce(function(t,e){return t+e.movement},0)},i.isDragging=function(){return this.isDrag},i.isFlag=function(){return this.flag},i.isPinchFlag=function(){return this.pinchFlag},i.isPinching=function(){return this.isPinch},i.scrollBy=function(t,e,n,r){void 0===r&&(r=!0),this.flag&&(this.clientStores[0].move(t,e),r&&this.onDrag(n,!0))},i.move=function(t,e){var r=t[0],i=t[1],n=this.getCurrentStore().prevClients;return this.moveClients(n.map(function(t){var e=t.clientX,n=t.clientY;return{clientX:e+r,clientY:n+i,originalClientX:e,originalClientY:n}}),e,!0)},i.triggerDragStart=function(t){this.onDragStart(t,!1)},i.setEventDatas=function(t){var e=this.datas;for(var n in t)e[n]=t[n];return this},i.getEventDatas=function(){return this.datas},i.unset=function(){var e=this,t=this.targets,n=this.options.container;this.off(),b(window,"blur",this.onBlur),this.isMouse&&(t.forEach(function(t){b(t,"mousedown",e.onDragStart)}),b(n,"mousemove",this.onDrag),b(n,"mouseup",this.onDragEnd),b(n,"contextmenu",this.onDragEnd)),this.isTouch&&(t.forEach(function(t){b(t,"touchstart",e.onDragStart)}),b(n,"touchstart",this.onDragStart),b(n,"touchmove",this.onDrag),b(n,"touchend",this.onDragEnd),b(n,"touchcancel",this.onDragEnd))},i.onPinchStart=function(t){var e=this.options.pinchThreshold;if(!(this.isDrag&&this.getMovement()>e)){var n=new O(k(t));this.pinchFlag=!0,this.clientStores.splice(0,0,n),!1===this.emit("pinchStart",D({datas:this.datas,angle:n.getAngle(),touches:this.getCurrentStore().getPositions()},n.getPosition(),{inputEvent:t}))&&(this.pinchFlag=!1)}},i.onPinch=function(t,e){if(this.flag&&this.pinchFlag&&!(e.length<2)){var n=this.getCurrentStore();this.isPinch=!0,this.emit("pinch",D({datas:this.datas,movement:this.getMovement(e),angle:n.getAngle(e),rotation:n.getRotation(e),touches:n.getPositions(e),scale:n.getScale(e),distance:n.getDistance(e)},n.getPosition(e),{inputEvent:t}))}},i.onPinchEnd=function(t){if(this.pinchFlag){var e=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.getCurrentStore();this.emit("pinchEnd",D({datas:this.datas,isPinch:e,touches:n.getPositions()},n.getPosition(),{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}},i.initDrag=function(){this.clientStores=[],this.pinchFlag=!1,this.flag=!1},i.getCurrentStore=function(){return this.clientStores[0]},i.moveClients=function(t,e,n){var r=this.getCurrentStore()[n?"addClients":"getPosition"](t);return this.isDrag=!0,D({datas:this.datas},r,{movement:this.getMovement(t),isDrag:this.isDrag,isPinch:this.isPinch,isScroll:!1,inputEvent:e})},r}(t);var y=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,r=this.values,i=n.indexOf(t),o=-1===i?n.length:i;n[o]=t,r[o]=e},t}(),P=function(){function t(){this.object={}}var e=t.prototype;return e.get=function(t){return this.object[t]},e.set=function(t,e){this.object[t]=e},t}(),_="function"==typeof Map,m=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var x=function(){function t(t,e,n,r,i,o,s,a){this.prevList=t,this.list=e,this.added=n,this.removed=r,this.changed=i,this.maintained=o,this.changedBeforeAdded=s,this.fixed=a}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t,n,a,c,e=(t=this.changedBeforeAdded,n=this.fixed,a=[],c=[],t.forEach(function(t){var e=t[0],n=t[1],r=new m;a[e]=r,c[n]=r}),a.forEach(function(t,e){t.connect(a[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],r=t[1];if(n===r)return[0,0];var i=a[n],o=c[r-1],s=i.getIndex();return i.disconnect(),o?i.connect(o,o.next):i.connect(void 0,a[0]),[s,i.getIndex()]})),u=this.changed,l=[];this.cacheOrdered=e.filter(function(t,e){var n=t[0],r=t[1],i=u[e],o=i[0],s=i[1];if(n!==r)return l.push([o,s]),!0}),this.cachePureChanged=l},t}();function Y(t,e,n){var r=_?Map:n?P:y,i=n||function(t){return t},o=[],s=[],a=[],c=t.map(i),u=e.map(i),l=new r,h=new r,f=[],g=[],d={},p=[],v=0,m=0;return c.forEach(function(t,e){l.set(t,e)}),u.forEach(function(t,e){h.set(t,e)}),c.forEach(function(t,e){var n=h.get(t);void 0===n?(++m,s.push(e)):d[n]=m}),u.forEach(function(t,e){var n=l.get(t);void 0===n?(o.push(e),++v):(a.push([n,e]),m=d[e]||0,f.push([n-m,e-v]),g.push(e===n),n!==e&&p.push([n,e]))}),s.reverse(),new x(t,e,o,s,p,a,f,g)}var X=function(t,e){return(X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var e,j="function"==typeof Map?void 0:(e=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++e)}),K=function(e){function t(){this.constructor=n}var n,r;function i(t){return void 0===t&&(t=[]),e.call(this,t,j)||this}return X(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t),i}(function(){function t(t,e){void 0===t&&(t=[]),this.findKeyCallback=e,this.list=[].slice.call(t)}return t.prototype.update=function(t){var e=[].slice.call(t),n=Y(this.list,e,this.findKeyCallback);return this.list=e,n},t}());function M(t,e){return Y(t,e,j)}var A=function(t,e){return(A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function B(t){var e=t.container;return[e.scrollLeft,e.scrollTop]}var R=function(e){function t(){this.constructor=n}var n,r;function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.startRect=null,t.startPos=[],t.prevTime=0,t.timer=0,t}A(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return o.dragStart=function(t,e){var n=e.container.getBoundingClientRect(),r=n.top,i=n.left,o=n.width,s=n.height;this.startPos=[t.clientX,t.clientY],this.startRect={top:r,left:i,width:o,height:s}},o.drag=function(t,e){var n=this,r=t.clientX,i=t.clientY,o=e.container,s=e.threshold,a=void 0===s?0:s,c=e.throttleTime,u=void 0===c?0:c,l=e.getScrollPosition,h=void 0===l?B:l,f=this.startRect,g=this.startPos,d=w(),p=Math.max(u+this.prevTime-d,0),v=[0,0];if(f.top>i-a?(g[1]>f.top||i<g[1])&&(v[1]=-1):f.top+f.height<i+a&&(g[1]<f.top+f.height||i>g[1])&&(v[1]=1),f.left>r-a?(g[0]>f.left||r<g[0])&&(v[0]=-1):f.left+f.width<r+a&&(g[0]<f.left+f.width||r>g[0])&&(v[0]=1),clearTimeout(this.timer),!v[0]&&!v[1])return!1;if(0<p)return this.timer=window.setTimeout(function(){n.drag(t,e)},p),!1;this.prevTime=d;var m=h({container:o,direction:v});this.trigger("scroll",{container:o,direction:v,inputEvent:t});var y=h({container:o,direction:v}),C=y[0]-m[0],b=y[1]-m[1];return!(!C&&!b)&&(this.trigger("move",{offsetX:v[0]?C:0,offsetY:v[1]?b:0,inputEvent:t}),u&&(this.timer=window.setTimeout(function(){n.drag(t,e)},u)),!0)},o.dragEnd=function(){clearTimeout(this.timer)},i}(t),F=function(t,e){return(F=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function N(t){return t&&"object"==typeof t}function I(t){return Array.isArray(t)}function L(t){return"string"==typeof t}function q(t,e,n,r){t.addEventListener(e,n,r)}function U(t,e,n){t.removeEventListener(e,n)}var W=function(){return(W=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};var z=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(N(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(N(t))for(var n in t)this.off(n);else if(e){var r=this._events[t];if(r){var i=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,i=0;i<r;++i)if(e(t[i],i,t))return i;return n}(r,function(t){return t.listener===e});-1<i&&r.splice(i,1)}}else this._events[t]=[];else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this;void 0===n&&(n={});var t=this._events[e];if(!e||!t)return!0;var i=!1;return n.eventType=e,n.stop=function(){i=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!i},e.trigger=function(t,e){return void 0===e&&(e={}),this.emit(t,e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(W({listener:e},n))},t}();var H,G,V=(function(t,e){function n(t){if(t&&"object"==typeof t){var e=t.which||t.keyCode||t.charCode;e&&(t=e)}if("number"==typeof t)return s[t];var n,r=String(t);return(n=i[r.toLowerCase()])?n:(n=o[r.toLowerCase()])||(1===r.length?r.charCodeAt(0):void 0)}n.isEventKey=function(t,e){if(t&&"object"==typeof t){var n=t.which||t.keyCode||t.charCode;if(null==n)return!1;if("string"==typeof e){var r;if(r=i[e.toLowerCase()])return r===n;if(r=o[e.toLowerCase()])return r===n}else if("number"==typeof e)return e===n;return!1}};var i=(e=t.exports=n).code=e.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=e.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91};for(r=97;r<123;r++)i[String.fromCharCode(r)]=r-32;for(var r=48;r<58;r++)i[r-48]=r;for(r=1;r<13;r++)i["f"+r]=r+111;for(r=0;r<10;r++)i["numpad "+r]=r+96;var s=e.names=e.title={};for(r in i)s[i[r]]=r;for(var a in o)i[a]=o[a]}(H={exports:{}},H.exports),H.exports),$=(V.code,V.codes,V.aliases,V.names),J=(V.title,{"+":"plus","left command":"meta","right command":"meta"}),Q={shift:1,ctrl:2,alt:3,meta:4};function Z(t){var e=$[t]||"";for(var n in J)e=e.replace(n,J[n]);return e.replace(/\s/g,"")}function tt(t,e){void 0===e&&(e=Z(t.keyCode));var n,r=[(n=t).shiftKey&&"shift",n.ctrlKey&&"ctrl",n.altKey&&"alt",n.metaKey&&"meta"].filter(Boolean);return-1===r.indexOf(e)&&r.push(e),r.filter(Boolean)}function et(t){var e=t.slice();return e.sort(function(t,e){return(Q[t]||5)-(Q[e]||5)}),e}var nt=function(n){function t(){this.constructor=e}var e,r;function i(t){void 0===t&&(t=window);var e=n.call(this)||this;return e.container=t,e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e.clear=function(){return e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e},e.keydownEvent=function(t){e.triggerEvent("keydown",t)},e.keyupEvent=function(t){e.triggerEvent("keyup",t)},e.blur=function(){e.clear(),e.trigger("blur")},q(t,"blur",e.blur),q(t,"keydown",e.keydownEvent),q(t,"keyup",e.keyupEvent),e}F(e=i,r=n),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o=i.prototype;return Object.defineProperty(i,"global",{get:function(){return G=G||new i},enumerable:!1,configurable:!0}),i.setGlobal=function(){return this.global},o.destroy=function(){var t=this.container;this.clear(),this.off(),U(t,"blur",this.blur),U(t,"keydown",this.keydownEvent),U(t,"keyup",this.keyupEvent)},o.keydown=function(t,e){return this.addEvent("keydown",t,e)},o.offKeydown=function(t,e){return this.removeEvent("keydown",t,e)},o.offKeyup=function(t,e){return this.removeEvent("keyup",t,e)},o.keyup=function(t,e){return this.addEvent("keyup",t,e)},o.addEvent=function(t,e,n){return I(e)?this.on(t+"."+et(e).join("."),n):L(e)?this.on(t+"."+e,n):this.on(t,e),this},o.removeEvent=function(t,e,n){return I(e)?this.off(t+"."+et(e).join("."),n):L(e)?this.off(t+"."+e,n):this.off(t,e),this},o.triggerEvent=function(t,e){this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey;var n=Z(e.keyCode),r={key:n,isToggle:"ctrl"===n||"shift"===n||"meta"===n||"alt"===n,inputEvent:e,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey};this.trigger(t,r),this.trigger(t+"."+n,r);var i=tt(e,n);1<i.length&&this.trigger(t+"."+i.join("."),r)},i}(z);function rt(t,e,n){var r=t.tag,i=t.children,o=t.attributes,s=t.className,a=t.style,c=e||document.createElement(r);for(var u in o)c.setAttribute(u,o[u]);var l=c.children;if(i.forEach(function(t,e){rt(t,l[e],c)}),s&&s.split(" ").forEach(function(t){var e,n,r,i;i=t,((r=c).classList?r.classList.contains(i):r.className.match(new RegExp("(\\s|^)"+i+"(\\s|$)")))||(n=t,(e=c).classList?e.classList.add(n):e.className+=" "+n)}),a){var h=c.style;for(var u in a)h[u]=a[u]}return!e&&n&&n.appendChild(c),c}function it(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=e||{},o=i.className,s=i.style;return{tag:t,className:void 0===o?"":o,style:void 0===s?{}:s,attributes:function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(i,["className","style"]),children:n}}function ot(t,e,n){t!==e&&n(t,e)}function st(t,e,n){var r,i=t.distX,o=void 0===i?0:i,s=t.distY,a=void 0===s?0:s,c=t.datas,u=c.startX,l=c.startY;if(0<e){var h=Math.sqrt((o*o+a*a)/(1+e*e));o=(0<=o?1:-1)*(e*h),a=(0<=a?1:-1)*h}var f=Math.abs(o),g=Math.abs(a);o=(0<=o?1:-1)*(f=(r=v([f,g],[0,0],[o<0?u-n.left:n.right-u,a<0?l-n.top:n.bottom-l],!!e))[0]),a=(0<=a?1:-1)*(g=r[1]);var d=u+Math.min(0,o),p=l+Math.min(0,a);return{left:d,top:p,right:d+f,bottom:p+g,width:f,height:g}}function at(t){var e=t.getBoundingClientRect(),n=e.left,r=e.top,i=e.width,o=e.height;return{pos1:[n,r],pos2:[n+i,r],pos3:[n,r+o],pos4:[n+i,r+o]}}function ct(t,e,n,r){var i,o,s=document.createElement("style");return s.setAttribute("type","text/css"),s.setAttribute("data-styled-id",t),n.nonce&&s.setAttribute("nonce",n.nonce),s.innerHTML=(i=t,o=e,n.original?o:o.replace(/([^};{\s}][^};{]*|^\s*){/gm,function(t,e){var n=e.trim();return(n?a(n):[""]).map(function(t){var e=t.trim();return 0===e.indexOf("@")?e:-1<e.indexOf(":global")?e.replace(/\:global/g,""):-1<e.indexOf(":host")?""+e.replace(/\:host/g,"."+i):e?"."+i+" "+e:"."+i}).join(", ")+" {"})),(r||document.head||document.body).appendChild(s),s}var ut,lt,ht,ft,gt=(ht="rCS"+function(t){for(var e=5381,n=t.length;n;)e=33*e^t.charCodeAt(--n);return e>>>0}(ut="\n:host {\n position: fixed;\n display: none;\n border: 1px solid #4af;\n background: rgba(68, 170, 255, 0.5);\n z-index: 100;\n}\n").toString(36),ft=0,{className:ht,inject:function(t,e){void 0===e&&(e={});var n,r=function(t){if(t&&t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e}}(t),i=0===ft;return(r||i)&&(n=ct(ht,ut,e,r)),i&&(lt=n),r||++ft,{destroy:function(){r?(t.removeChild(n),n=null):(0<ft&&--ft,0===ft&<&&(lt.parentNode.removeChild(lt),lt=null))}}}}),dt="selecto-selection "+gt.className,pt=["boundContainer","selectableTargets","selectByClick","selectFromInside","continueSelect","toggleContinueSelect","keyContainer","hitRate","scrollOptions","checkInput","preventDefault","ratio","getElementPoints"],vt=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}(["dragContainer","cspNonce"],pt),mt={boundContainer:null,target:null,container:null,dragContainer:null,selectableTargets:Array,selectByClick:Boolean,selectFromInside:Boolean,continueSelect:Boolean,toggleContinueSelect:Array,keyContainer:null,hitRate:Number,scrollOptions:Object,checkInput:Boolean,preventDefault:Boolean,cspNonce:String,ratio:Number,getElementPoints:Function},yt=function(e){function t(){this.constructor=n}var n,r;function i(t){void 0===t&&(t={});var b=e.call(this)||this;return b.selectedTargets=[],b.differ=new K,b.dragScroll=new R,b.onDragStart=function(t,e){var n=t.datas,r=t.clientX,i=t.clientY,o=t.inputEvent,s=b.options,a=s.continueSelect,c=s.selectFromInside,u=s.selectByClick,l=s.boundContainer;b.findSelectableTargets(n),n.startSelectedTargets=b.selectedTargets;var h={left:-1/0,top:-1/0,right:1/0,bottom:1/0};if(l){var f=(typeof l===S?document.querySelector(l):!0===l?b.container:l).getBoundingClientRect();h={left:f.left,top:f.top,right:f.right,bottom:f.bottom}}n.boundArea=h,n.selectedTargets=[];var g={left:r,top:i,right:r,bottom:i,width:0,height:0},d=[];if(!c||u){for(var p=e||document.elementFromPoint(r,i);p&&!(-1<n.selectableTargets.indexOf(p));)p=p.parentElement;d=p?[p]:[]}var v=0<d.length,m=!c&&v;if(m&&!u)return t.stop(),!1;var y=o.type;if(!(!("mousedown"===y||"touchstart"===y)||b.trigger("dragStart",E({},t))))return t.stop(),!1;if(a?d=b.passSelectedTargets(d):b.selectedTargets=[],b.select(d,g,o,!0),n.startX=r,n.startY=i,n.selectedTargets=d,n.boundsArea=b.target.style.cssText+="left:0px;top:0px;transform: translate("+r+"px, "+i+"px)",m&&u)return b.onDragEnd(t),o.preventDefault(),t.stop(),!1;"touchstart"===y&&o.preventDefault();var C=b.options.scrollOptions;return C&&C.container&&b.dragScroll.dragStart(t,C),!0},b.onDrag=function(t){var e=b.options.scrollOptions;e&&e.container&&b.dragScroll.drag(t,e)||b.check(t)},b.onDragEnd=function(t){var e=t.datas,n=t.inputEvent,r=st(t,b.options.ratio,e.boundArea);b.dragScroll.dragEnd(),b.target.style.cssText+="display: none;",n&&"mousedown"!==n.type&&"touchstart"!==n.type&&b.trigger("dragEnd",E(E({isDouble:!1,isDrag:!1},t),{rect:r})),b.selectEnd(e.startSelectedTargets,e.selectedTargets,r,t),b.selectedTargets=e.selectedTargets},b.onKeyDown=function(t){b.sameCombiKey(t)&&(b.continueSelect=!0,b.trigger("keydown",{}))},b.onKeyUp=function(t){b.sameCombiKey(t,!0)&&(b.continueSelect=!1,b.trigger("keyup",{}))},b.onBlur=function(){b.toggleContinueSelect&&b.continueSelect&&(b.continueSelect=!1,b.trigger("keyup",{}))},b.onDocumentSelectStart=function(e){if(b.gesto.isFlag()){var t=b.dragContainer;t===window&&(t=document.documentElement);var n=t instanceof Element?[t]:[].slice.call(t),r=e.target;n.some(function(t){if(t===r||t.contains(r))return e.preventDefault(),!0})}},b.target=t.target,b.container=t.container,b.options=E({target:null,container:null,dragContainer:null,selectableTargets:[],selectByClick:!0,selectFromInside:!0,hitRate:100,continueSelect:!1,toggleContinueSelect:null,keyContainer:null,scrollOptions:void 0,checkInput:!1,preventDefault:!1,boundContainer:!1,getElementPoints:at,cspNonce:"",ratio:0},t),b.initElement(),b.initDragScroll(),b.setKeyController(),b}c(n=i,r=e),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t);var o,s,a=i.prototype;return a.setSelectedTargets=function(t){return this.selectedTargets=t,this.differ=new K(t),this},a.getSelectedTargets=function(){return this.selectedTargets},a.setKeyContainer=function(t){var e=this,n=this.options;ot(n.keyContainer,t,function(){n.keyContainer=t,e.setKeyController()})},a.setToggleContinueSelect=function(t){var e=this,n=this.options;ot(n.toggleContinueSelect,t,function(){n.toggleContinueSelect=t,e.setKeyEvent()})},a.setPreventDefault=function(t){this.gesto.options.preventDefault=t},a.setCheckInput=function(t){this.gesto.options.checkInput=t},a.triggerDragStart=function(t){return this.gesto.triggerDragStart(t),this},a.destroy=function(){this.off(),this.keycon&&this.keycon.destroy(),this.gesto.unset(),this.injectResult.destroy(),b(document,"selectstart",this.onDocumentSelectStart),this.keycon=null,this.gesto=null,this.injectResult=null,this.target=null,this.container=null,this.options=null},a.findSelectableTargets=function(t){void 0===t&&(t=this.gesto.getEventDatas());var e=this.getElementPoints,n=this.getSelectableTargets(),r=n.map(function(t){return e(t)});t.selectableTargets=n,t.selectablePoints=r},a.clickTarget=function(t,e){var n=function(t){if("touches"in t){var e=t.touches[0]||t.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}}return{clientX:t.clientX,clientY:t.clientY}}(t),r={datas:{},clientX:n.clientX,clientY:n.clientY,inputEvent:t,stop:function(){return!1}};return this.onDragStart(r,e)&&this.onDragEnd(r),this},a.setKeyController=function(){var t=this.options,e=t.keyContainer,n=t.toggleContinueSelect;this.keycon&&(this.keycon.destroy(),this.keycon=null),n&&(this.keycon=new nt(e||window),this.keycon.keydown(this.onKeyDown).keyup(this.onKeyUp).on("blur",this.onBlur))},a.setKeyEvent=function(){this.options.toggleContinueSelect&&!this.keycon&&this.setKeyController()},a.initElement=function(){this.target=rt(it("div",{className:dt}),this.target,this.container);var t=this.target,e=this.options,n=e.dragContainer,r=e.checkInput,i=e.preventDefault;this.dragContainer="string"==typeof n?[].slice.call(document.querySelectorAll(n)):this.options.dragContainer||this.target.parentNode,this.gesto=new p(this.dragContainer,{checkWindowBlur:!0,container:window,checkInput:r,preventDefault:i}).on({dragStart:this.onDragStart,drag:this.onDrag,dragEnd:this.onDragEnd}),C(document,"selectstart",this.onDocumentSelectStart),this.injectResult=gt.inject(t,{nonce:this.options.cspNonce})},a.hitTest=function(t,b,E,e,S){var n=this.options,w=n.hitRate,D=n.selectByClick,k=t.left,O=t.top,T=t.right,P=t.bottom;return e.filter(function(t,e){var n=S[e],r=n.pos1,i=n.pos2,o=n.pos3,s=n.pos4,a=[0,1].map(function(t){return Math.min(r[t],i[t],o[t],s[t])}),c=a[0],u=a[1],l=[0,1].map(function(t){return Math.max(r[t],i[t],o[t],s[t])}),h=l[0],f=l[1],g=c<=b&&b<=h&&u<=E&&E<=f,d=(h-c)*(f-u),p=Math.max(c,k),v=Math.min(h,T),m=Math.max(u,O),y=Math.min(f,P);if(D&&g)return!0;if(v<p||y<m)return!1;var C=Math.round((v-p)*(y-m)/d*100);return w<=C})},a.initDragScroll=function(){var o=this;this.dragScroll.on("scroll",function(t){var e=t.container,n=t.direction;o.trigger("scroll",{container:e,direction:n})}).on("move",function(t){var e=t.offsetX,n=t.offsetY,r=t.inputEvent,i=r.datas;i.startX-=e,i.startY-=n,i.selectablePoints.forEach(function(t){[t.pos1,t.pos2,t.pos3,t.pos4].forEach(function(t){t[0]-=e,t[1]-=n})}),o.gesto.scrollBy(e,n,r.inputEvent,!1),r.distX+=e,r.distY+=n,o.check(r)})},a.getSelectableTargets=function(){var e=[];return this.options.selectableTargets.forEach(function(t){u(t)?e.push(t):[].slice.call(document.querySelectorAll(t)).forEach(function(t){e.push(t)})}),e},a.passSelectedTargets=function(t){var e=M(this.selectedTargets,t),n=e.list,r=e.prevList,i=e.added,o=e.removed;return i.map(function(t){return n[t]}).concat(o.map(function(t){return r[t]}))},a.select=function(t,e,n,r){var i=this.differ.update(t),o=i.added,s=i.removed,a=i.prevList,c=i.list;r&&this.trigger("selectStart",{selected:t,added:o.map(function(t){return c[t]}),removed:s.map(function(t){return a[t]}),rect:e,inputEvent:n}),(o.length||s.length)&&this.trigger("select",{selected:t,added:o.map(function(t){return c[t]}),removed:s.map(function(t){return a[t]}),rect:e,inputEvent:n})},a.selectEnd=function(t,e,n,r){var i=r.inputEvent,o=r.isDouble,s=M(t,e),a=s.added,c=s.removed,u=s.prevList,l=s.list,h=M(this.selectedTargets,e),f=h.added,g=h.removed,d=h.prevList,p=h.list,v=i&&i.type,m="mousedown"===v||"touchstart"===v;this.trigger("selectEnd",{selected:e,added:a.map(function(t){return l[t]}),removed:c.map(function(t){return u[t]}),afterAdded:f.map(function(t){return p[t]}),afterRemoved:g.map(function(t){return d[t]}),isDragStart:m,isDouble:!!o,rect:n,inputEvent:i})},a.check=function(t){var e=t.datas,n=t.inputEvent,r=st(t,this.options.ratio,e.boundArea),i=r.top,o=r.left,s=r.width,a=r.height;this.target.style.cssText+="display: block;left:0px;top:0px;transform: translate("+o+"px, "+i+"px);width:"+s+"px;height:"+a+"px;";var c=this.hitTest(r,e.startX,e.startY,e.selectableTargets,e.selectablePoints),u=this.passSelectedTargets(c);this.trigger("drag",E(E({},t),{rect:r})),this.select(u,r,n),e.selectedTargets=u},a.sameCombiKey=function(t,e){var n,r=[].concat(this.options.toggleContinueSelect),i=tt(t.inputEvent,t.key),o=(n=r[0],Array.isArray(n)?r:[r]);if(e){var s=t.key;return o.some(function(t){return t.some(function(t){return t===s})})}return o.some(function(t){return t.every(function(t){return-1<i.indexOf(t)})})},i=function(t,e,n,r){var i,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;0<=a;a--)(i=t[a])&&(s=(o<3?i(s):3<o?i(e,n,s):i(e,n))||s);return 3<o&&s&&Object.defineProperty(e,n,s),s}([(o=pt,s=function(t,e){var n={enumerable:!0,configurable:!0,get:function(){return this.options[e]}},r=("set "+e).replace(/[\s-_]([a-z])/g,function(t,e){return e.toUpperCase()});t[r]?n.set=function(t){this[r](t)}:n.set=function(t){this.options[e]=t},Object.defineProperty(t,e,n)},function(t){var e=t.prototype;o.forEach(function(t){s(e,t)})})],i)}(t),Ct={__proto__:null,default:yt,OPTIONS:vt,OPTION_TYPES:mt,PROPERTIES:pt,EVENTS:["dragStart","drag","dragEnd","selectStart","select","selectEnd","keydown","keyup","scroll"],METHODS:["clickTarget","setSelectedTargets","triggerDragStart"],CLASS_NAME:dt};for(var bt in Ct)yt[bt]=Ct[bt];return yt}); | ||
//# sourceMappingURL=selecto.min.js.map |
{ | ||
"name": "selecto", | ||
"version": "1.7.3", | ||
"version": "1.7.4", | ||
"description": "Selecto.js is a component that allows you to select elements in the drag area using the mouse or touch.", | ||
@@ -14,2 +14,4 @@ "main": "./dist/selecto.cjs.js", | ||
"doc": "rm -rf ./doc && jsdoc -c jsdoc.json", | ||
"test": "jest --watchAll", | ||
"coverage": "jest --coverage && print-coveralls --sort=desc", | ||
"prerelease": "npm run build && npm run doc && npm run storybook && prerelease --dirs=dist,doc", | ||
@@ -45,3 +47,3 @@ "storybook": "cd storybook/ && npm run build && cd ../", | ||
"dependencies": { | ||
"@daybrush/utils": "^1.1.0", | ||
"@daybrush/utils": "^1.1.1", | ||
"@egjs/children-differ": "^1.0.1", | ||
@@ -63,5 +65,9 @@ "@scena/dragscroll": "^0.3.1", | ||
"@daybrush/release": "^0.2.4", | ||
"@types/jest": "^24.0.13", | ||
"daybrush-jsdoc-template": "^1.6.0", | ||
"jest": "^24.8.0", | ||
"print-coveralls": "^1.2.2", | ||
"print-sizes": "^0.1.0", | ||
"pvu": "^0.4.1", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.20.1", | ||
@@ -68,0 +74,0 @@ "typescript": "^3.7.4" |
@@ -32,2 +32,3 @@ import styled from "css-styled"; | ||
"ratio", | ||
"getElementPoints", | ||
] as const; | ||
@@ -61,2 +62,3 @@ /** | ||
ratio: Number, | ||
getElementPoints: Function, | ||
}; | ||
@@ -63,0 +65,0 @@ |
@@ -48,2 +48,3 @@ import { IObject } from "@daybrush/utils"; | ||
ratio: number; | ||
getElementPoints: GetElementPointsFunction; | ||
} | ||
@@ -58,3 +59,2 @@ | ||
} | ||
export interface Rect { | ||
@@ -69,2 +69,9 @@ top: number; | ||
export interface Point { | ||
pos1: number[]; | ||
pos2: number[]; | ||
pos3: number[]; | ||
pos4: number[]; | ||
} | ||
/** | ||
@@ -156,1 +163,7 @@ * @memberof Selecto | ||
export type SelectoMethods = { [P in typeof METHODS[number]]: Selecto[P] }; | ||
export type GetElementPointsFunction = (el: HTMLElement | SVGElement) => { | ||
pos1: number[], | ||
pos2: number[], | ||
pos3: number[], | ||
pos4: number[], | ||
}; |
import { Hypertext, Rect } from "./types"; | ||
import { IObject, addClass, hasClass, convertUnitSize, caculateBoundSize } from "@daybrush/utils"; | ||
import { IObject, addClass, hasClass, calculateBoundSize } from "@daybrush/utils"; | ||
@@ -101,3 +101,3 @@ export function getClient(e: MouseEvent | TouchEvent) { | ||
[width, height] = caculateBoundSize([width, height], [0, 0], [maxWidth, maxHeight], !!ratio); | ||
[width, height] = calculateBoundSize([width, height], [0, 0], [maxWidth, maxHeight], !!ratio); | ||
distX = (distX >= 0 ? 1 : -1) * width; | ||
@@ -120,1 +120,13 @@ distY = (distY >= 0 ? 1 : -1) * height; | ||
} | ||
export function getDefaultElementPoints(el: HTMLElement) { | ||
const rect = el.getBoundingClientRect(); | ||
const { left, top, width, height } = rect; | ||
return { | ||
pos1: [left, top], | ||
pos2: [left + width, top], | ||
pos3: [left, top + height], | ||
pos4: [left + width, top + height], | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
496382
32
7189
12
Updated@daybrush/utils@^1.1.1