function useUniqueId(idProp) {
var instanceId = Object(external_wp_compose_["useInstanceId"])(InputBase);
var id = "input-base-control-".concat(instanceId);
function InputBase(_ref, ref) {
var __unstableInputWidth = _ref.__unstableInputWidth,
children = _ref.children,
className = _ref.className,
_ref$disabled = _ref.disabled,
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
_ref$hideLabelFromVis = _ref.hideLabelFromVision,
hideLabelFromVision = _ref$hideLabelFromVis === void 0 ? false : _ref$hideLabelFromVis,
labelPosition = _ref.labelPosition,
_ref$isFocused = _ref.isFocused,
isFocused = _ref$isFocused === void 0 ? false : _ref$isFocused,
size = _ref$size === void 0 ? 'default' : _ref$size,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["__unstableInputWidth", "children", "className", "disabled", "hideLabelFromVision", "labelPosition", "id", "isFocused", "label", "prefix", "size", "suffix"]);
var id = useUniqueId(idProp);
return Object(external_wp_element_["createElement"])(input_control_styles_Root, Object(esm_extends["a" /* default */])({}, props, {
labelPosition: labelPosition,
}), Object(external_wp_element_["createElement"])(LabelWrapper, null, Object(external_wp_element_["createElement"])(label_Label, {
className: "components-input-control__label",
hideLabelFromVision: hideLabelFromVision,
labelPosition: labelPosition,
}, label)), Object(external_wp_element_["createElement"])(Container, {
__unstableInputWidth: __unstableInputWidth,
className: "components-input-control__container",
labelPosition: labelPosition
}, prefix && Object(external_wp_element_["createElement"])(Prefix, {
className: "components-input-control__prefix"
}, prefix), children, suffix && Object(external_wp_element_["createElement"])(Suffix, {
className: "components-input-control__suffix"
}, suffix), Object(external_wp_element_["createElement"])(backdrop, {
/* harmony default export */ var input_base = (Object(external_wp_element_["forwardRef"])(InputBase));
// CONCATENATED MODULE: ./node_modules/react-use-gesture/dist/reactusegesture.esm.js
return v1.map(function (v, i) {
return v1.map(function (v, i) {
* @param movement the difference between current and initial vectors
function calculateDistance(movement) {
return Math.hypot.apply(Math, movement);
function calculateAllGeometry(movement, delta) {
var dl = calculateDistance(delta);
var alpha = dl === 0 ? 0 : 1 / dl;
var direction = delta.map(function (v) {
var distance = calculateDistance(movement);
* Calculates all kinematics
* @template T the expected vector type
* @param movement the difference between current and initial vectors
* @param delta the difference between current and previous vectors
* @param delta_t the time difference between current and previous timestamps
* @returns all kinematics
function calculateAllKinematics(movement, delta, dt) {
var dl = calculateDistance(delta);
var alpha = dl === 0 ? 0 : 1 / dl;
var beta = dt === 0 ? 0 : 1 / dt;
var velocity = beta * dl;
var velocities = delta.map(function (v) {
var direction = delta.map(function (v) {
var distance = calculateDistance(movement);
* Because IE doesn't support `Math.sign` function, so we use the polyfill version of the function.
* This polyfill function is suggested by Mozilla:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign#Polyfill
if (Math.sign) return Math.sign(x);
return Number(x > 0) - Number(x < 0) || +x;
function minMax(value, min, max) {
return Math.max(min, Math.min(value, max));
} // Based on @aholachek ;)
// https://twitter.com/chpwn/status/285540192096497664
// https://medium.com/@nathangitter/building-fluid-interfaces-ios-swift-9732bb934bf5
function rubberband2(distance, constant) {
// default constant from the article is 0.7
return Math.pow(distance, constant * 5);
function rubberband(distance, dimension, constant) {
if (dimension === 0 || Math.abs(dimension) === Infinity) return rubberband2(distance, constant);
return distance * dimension * constant / (dimension + constant * distance);
function rubberbandIfOutOfBounds(position, min, max, constant) {
if (constant === void 0) {
if (constant === 0) return minMax(position, min, max);
if (position < min) return -rubberband(min - position, max - min, constant) + min;
if (position > max) return +rubberband(position - max, max - min, constant) + max;
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
return _extends.apply(this, arguments);
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var sourceKeys = Object.keys(source);
for (i = 0; i < sourceKeys.length; i++) {
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
function _assertThisInitialized(self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
function _unsupportedIterableToArray(o, minLen) {
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (i >= o.length) return {
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
it = o[Symbol.iterator]();
* TODO Beware that only optimized cases are covered in tests =)
* TODO Need to cover general case as well
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
fns[_key] = arguments[_key];
if (fns.length === 0) return noop;
if (fns.length === 1) return fns[0];
for (var _iterator = _createForOfIteratorHelperLoose(fns), _step; !(_step = _iterator()).done;) {
result = fn.apply(this, arguments) || result;
* Expects a simple value or 2D vector (an array with 2 elements) and
* always returns 2D vector. If simple value is passed, returns a
* vector with this value as both coordinates.
function ensureVector(value, fallback) {
if (value === undefined) {
if (fallback === undefined) {
throw new Error('Must define fallback value if undefined is expected');
if (Array.isArray(value)) return value;
* Helper for defining a default value
function assignDefault(value, fallback) {
return Object.assign({}, fallback, value || {});
* Resolves getters (functions) by calling them
* If simple value is given it just passes through
if (typeof v === 'function') {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
return v.apply(void 0, args);
function resolveWith(config, resolvers) {
for (var _i = 0, _Object$entries = Object.entries(resolvers); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _Object$entries[_i],
key = _Object$entries$_i[0],
resolver = _Object$entries$_i[1];
switch (typeof resolver) {
result[key] = resolver.call(result, config[key], key, config);
result[key] = resolveWith(config[key], resolver);
if (resolver) result[key] = config[key];
* Whether the browser supports GestureEvent (ie Safari)
* @returns true if the browser supports gesture event
function supportsGestureEvents() {
// TODO [TS] possibly find GestureEvent definitions?
// @ts-ignore: no type definitions for webkit GestureEvents
return 'constructor' in GestureEvent;
function supportsTouchEvents() {
return typeof window !== 'undefined' && 'ontouchstart' in window;
function supportsPointerEvents() {
return typeof window !== 'undefined' && 'onpointerdown' in window;
function getEventTouches(event) {
if ('pointerId' in event) return null;
return event.type === 'touchend' ? event.changedTouches : event.targetTouches;
function getTouchIds(event) {
return Array.from(getEventTouches(event)).map(function (t) {
function getGenericEventData(event) {
var buttons = 'buttons' in event ? event.buttons : 0;
var shiftKey = event.shiftKey,
ctrlKey = event.ctrlKey; // TODO check if this might create some overrides?
var identity = function identity(xy) {
* Gets pointer event values.
* @returns pointer event values
function getPointerEventValues(event, transform) {
if (transform === void 0) {
var touchEvents = getEventTouches(event);
var _ref = touchEvents ? touchEvents[0] : event,
return transform([clientX, clientY]);
* Gets two touches event data
* @returns two touches event data
function getTwoTouchesEventValues(event, pointerIds, transform) {
if (transform === void 0) {
var _Array$from$filter = Array.from(event.touches).filter(function (t) {
return pointerIds.includes(t.identifier);
A = _Array$from$filter[0],
B = _Array$from$filter[1];
if (!A || !B) throw Error("The event doesn't have two pointers matching the pointerIds");
var dx = B.clientX - A.clientX;
var dy = B.clientY - A.clientY;
var cx = (B.clientX + A.clientX) / 2;
var cy = (B.clientY + A.clientY) / 2; // const e: any = 'nativeEvent' in event ? event.nativeEvent : event
var distance = Math.hypot(dx, dy); // FIXME rotation has inconsistant values so we're not using it atm
// const angle = (e.rotation as number) ?? -(Math.atan2(dx, dy) * 180) / Math.PI
var angle = -(Math.atan2(dx, dy) * 180) / Math.PI;
var values = transform([distance, angle]);
var origin = transform([cx, cy]);
* Gets scroll event values
* @returns scroll event values
function getScrollEventValues(event, transform) {
if (transform === void 0) {
// If the currentTarget is the window then we return the scrollX/Y position.
// If not (ie the currentTarget is a DOM element), then we return scrollLeft/Top
var _event$currentTarget = event.currentTarget,
scrollX = _event$currentTarget.scrollX,
scrollY = _event$currentTarget.scrollY,
scrollLeft = _event$currentTarget.scrollLeft,
scrollTop = _event$currentTarget.scrollTop;
return transform([scrollX || scrollLeft || 0, scrollY || scrollTop || 0]);
} // wheel delta defaults from https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js