iobroker.vis-2
Version:
Next generation graphical user interface for ioBroker.
47,521 lines • 1.54 MB
JavaScript
import { j as jsxRuntimeExports, __tla as __tla_0 } from "./jsx-runtime-DgDbgMDY.js";
import { m as __mf_10, g as __mf_17, _ as __mf_24, n as __mf_28, h as __mf_32, i as __mf_20, k as __mf_29, e as __mf_15, f as __mf_9, o as __mf_21, c as __mf_31, b as __mf_30, p as __mf_14, q as __mf_26, a as React, r as __mf_2, j as __mf_1, s as __mf_35, t as __mf_13, __tla as __tla_1 } from "./iobroker_vis__loadShare__react__loadShare__.js-Bo2lxMHB.js";
import { _ as __mf_2$1, g as __mf_70, b as __mf_15$1, q as __mf_0, a as __mf_110, d as __mf_4, r as __mf_85$2, __tla as __tla_2 } from "./iobroker_vis__loadShare___mf_0_iobroker_mf_1_adapter_mf_2_react_mf_2_v5__loadShare__.js-CyaIGDzt.js";
import { d as dist, __tla as __tla_3 } from "./index-Cs8MllMO.js";
import { V as VisRxWidget, N as NOTHING_SELECTED, w as VisBaseWidget, x as getUsedObjectIDsInWidget, y as addClass$1, z as calculateOverflow, d as deepClone, A as isVarFinite, B as replaceGroupAttr, s as store, C as selectView, a as recalculateFields, E as parseDimension, F as hasWidgetAccess, __tla as __tla_4 } from "./visRxWidget-CsJe4ZeY.js";
import { h as __mf_27, v as __mf_14$1, _ as __mf_32$1, a as __mf_36, i as __mf_121, B as __mf_58, b as __mf_34, x as __mf_42, U as __mf_86, D as __mf_43, V as __mf_85, W as __mf_48, I as __mf_61, d as __mf_16, c as __mf_33, X as __mf_79, g as __mf_53, f as __mf_72, o as __mf_69, A as __mf_70$1, G as __mf_120, H as __mf_109, E as __mf_37, L as __mf_63, Y as __mf_64, M as __mf_66, z as __mf_67, r as __mf_126, N as __mf_71, Z as __mf_118, $ as __mf_113, n as __mf_25, a0 as __mf_111, a1 as __mf_116, a2 as __mf_39, a3 as __mf_112, K as __mf_60, e as __mf_89, a4 as __mf_18, a5 as __mf_122, j as __mf_83, l as __mf_81, m as __mf_7, C as __mf_108, k as __mf_40, p as __mf_92, a6 as __mf_46, a7 as __mf_98, __tla as __tla_5 } from "./iobroker_vis__loadShare___mf_0_mui_mf_1_material__loadShare__.js-y8HJH6Vp.js";
import { ao as __mf_3771, b as __mf_1776, S as __mf_7882, n as __mf_2326, _ as __mf_1671, an as __mf_4885, ap as __mf_2256, aq as __mf_1711, d as __mf_2781, c as __mf_1766, p as __mf_85$1, j as __mf_2876, __tla as __tla_6 } from "./iobroker_vis__loadShare___mf_0_mui_mf_1_icons_mf_2_material__loadShare__.js-L78p1KXL.js";
import { E as EditIcon, F as FileIcon, __tla as __tla_7 } from "./InsertDriveFile-B8DoT0SQ.js";
import { _ as __mf_6, a as __mf_133, b as __mf_131, __tla as __tla_8 } from "./iobroker_vis__loadShare___mf_0_mui_mf_1_system__loadShare__.js-Dt1au33l.js";
import { h as ThemeProvider, u as useThemeProps, i as forceReflow, j as Transition, k as useSlotProps, T as Typography, I as IconButton, l as useControlled, n as useEventCallback, o as useForkRef, M as MenuItem, p as MenuList, q as ButtonBase, r as InputAdornment, s as useFormControl, v as visuallyHidden$1, w as InputLabel, F as FormHelperText, x as FormControl, y as TextField, z as useTheme, A as Fade, C as TransitionGroup, D as useMediaQuery, G as Grow, E as FocusTrap, H as ownerDocument, P as Paper, J as Popper, B as Button, K as DialogActions, L as List, N as ListItem, O as Chip, Q as resolveComponentProps, R as Dialog, S as dialogClasses, U as DialogContent, __tla as __tla_9 } from "./Dialog-DElqR5zv.js";
import { _ as _objectWithoutPropertiesLoose$3, a as _extends$1, b as _inheritsLoose } from "./assertThisInitialized-DFQXnDE3.js";
import { t as toPropertyKey, h as hoistNonReactStatics } from "./hoist-non-react-statics.cjs-1ABLww7O.js";
import { P as PropTypes, __tla as __tla_10 } from "./iobroker_vis__loadShare__prop_mf_2_types__loadShare__.js-OoAqYupB.js";
import { _ as __mf_9$1, R as ReactDOM, __tla as __tla_11 } from "./iobroker_vis__loadShare__react_mf_2_dom__loadShare__.js-1rEIXFyN.js";
import { c as clsx, a as capitalize, __tla as __tla_12 } from "./clsx-XqGtd7JN.js";
import { g as generateUtilityClass, a as generateUtilityClasses, c as composeClasses, __tla as __tla_13 } from "./createStyled-BvULSPVR.js";
import { c as createSvgIcon, a as styled, __tla as __tla_14 } from "./createSvgIcon-DDwAmV8Q.js";
import { u as useRtl, a as useEnhancedEffect, b as useId, __tla as __tla_15 } from "./useMediaQuery-D88JRmB1.js";
let ConnectedDroppable, DragDropContext, FaFolderOpen, GenIcon, HTML5Backend, MaterialIconSelector, PublicDraggable, UploadFile, VisWidgetsCatalog, useCollector, useDrag, commonStyles, FaFolder, useDrop, DndProvider, getWidgetTypes, VisView, invariant$2, registerWidgetsLoadIndicator, createTheme, parseAttributes, reactIsExports, useDragDropManager, v4;
let __tla = Promise.all([
(() => {
try {
return __tla_0;
} catch {
}
})(),
(() => {
try {
return __tla_1;
} catch {
}
})(),
(() => {
try {
return __tla_2;
} catch {
}
})(),
(() => {
try {
return __tla_3;
} catch {
}
})(),
(() => {
try {
return __tla_4;
} catch {
}
})(),
(() => {
try {
return __tla_5;
} catch {
}
})(),
(() => {
try {
return __tla_6;
} catch {
}
})(),
(() => {
try {
return __tla_7;
} catch {
}
})(),
(() => {
try {
return __tla_8;
} catch {
}
})(),
(() => {
try {
return __tla_9;
} catch {
}
})(),
(() => {
try {
return __tla_10;
} catch {
}
})(),
(() => {
try {
return __tla_11;
} catch {
}
})(),
(() => {
try {
return __tla_12;
} catch {
}
})(),
(() => {
try {
return __tla_13;
} catch {
}
})(),
(() => {
try {
return __tla_14;
} catch {
}
})(),
(() => {
try {
return __tla_15;
} catch {
}
})()
]).then(async () => {
function getDefaultExportFromCjs(x2) {
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
}
const refType = PropTypes.oneOfType([
PropTypes.func,
PropTypes.object
]);
const DndContext = __mf_10({
dragDropManager: void 0
});
function _defineProperty$8(e2, r2, t) {
return (r2 = toPropertyKey(r2)) in e2 ? Object.defineProperty(e2, r2, {
value: t,
enumerable: true,
configurable: true,
writable: true
}) : e2[r2] = t, e2;
}
function ownKeys$3(e2, r2) {
var t = Object.keys(e2);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e2);
r2 && (o = o.filter(function(r3) {
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread2(e2) {
for (var r2 = 1; r2 < arguments.length; r2++) {
var t = null != arguments[r2] ? arguments[r2] : {};
r2 % 2 ? ownKeys$3(Object(t), true).forEach(function(r3) {
_defineProperty$8(e2, r3, t[r3]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function(r3) {
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t, r3));
});
}
return e2;
}
function formatProdErrorMessage$1(code) {
return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or use the non-minified dev environment for full errors. ";
}
var $$observable$1 = (function() {
return typeof Symbol === "function" && Symbol.observable || "@@observable";
})();
var randomString$1 = function randomString2() {
return Math.random().toString(36).substring(7).split("").join(".");
};
var ActionTypes$1 = {
INIT: "@@redux/INIT" + randomString$1(),
REPLACE: "@@redux/REPLACE" + randomString$1()
};
function isPlainObject$1(obj) {
if (typeof obj !== "object" || obj === null) return false;
var proto = obj;
while (Object.getPrototypeOf(proto) !== null) {
proto = Object.getPrototypeOf(proto);
}
return Object.getPrototypeOf(obj) === proto;
}
function createStore$2(reducer2, preloadedState, enhancer) {
var _ref2;
if (typeof preloadedState === "function" && typeof enhancer === "function" || typeof enhancer === "function" && typeof arguments[3] === "function") {
throw new Error(formatProdErrorMessage$1(0));
}
if (typeof preloadedState === "function" && typeof enhancer === "undefined") {
enhancer = preloadedState;
preloadedState = void 0;
}
if (typeof enhancer !== "undefined") {
if (typeof enhancer !== "function") {
throw new Error(formatProdErrorMessage$1(1));
}
return enhancer(createStore$2)(reducer2, preloadedState);
}
if (typeof reducer2 !== "function") {
throw new Error(formatProdErrorMessage$1(2));
}
var currentReducer = reducer2;
var currentState = preloadedState;
var currentListeners = [];
var nextListeners = currentListeners;
var isDispatching = false;
function ensureCanMutateNextListeners() {
if (nextListeners === currentListeners) {
nextListeners = currentListeners.slice();
}
}
function getState() {
if (isDispatching) {
throw new Error(formatProdErrorMessage$1(3));
}
return currentState;
}
function subscribe(listener) {
if (typeof listener !== "function") {
throw new Error(formatProdErrorMessage$1(4));
}
if (isDispatching) {
throw new Error(formatProdErrorMessage$1(5));
}
var isSubscribed = true;
ensureCanMutateNextListeners();
nextListeners.push(listener);
return function unsubscribe() {
if (!isSubscribed) {
return;
}
if (isDispatching) {
throw new Error(formatProdErrorMessage$1(6));
}
isSubscribed = false;
ensureCanMutateNextListeners();
var index = nextListeners.indexOf(listener);
nextListeners.splice(index, 1);
currentListeners = null;
};
}
function dispatch(action) {
if (!isPlainObject$1(action)) {
throw new Error(formatProdErrorMessage$1(7));
}
if (typeof action.type === "undefined") {
throw new Error(formatProdErrorMessage$1(8));
}
if (isDispatching) {
throw new Error(formatProdErrorMessage$1(9));
}
try {
isDispatching = true;
currentState = currentReducer(currentState, action);
} finally {
isDispatching = false;
}
var listeners = currentListeners = nextListeners;
for (var i = 0; i < listeners.length; i++) {
var listener = listeners[i];
listener();
}
return action;
}
function replaceReducer(nextReducer) {
if (typeof nextReducer !== "function") {
throw new Error(formatProdErrorMessage$1(10));
}
currentReducer = nextReducer;
dispatch({
type: ActionTypes$1.REPLACE
});
}
function observable() {
var _ref;
var outerSubscribe = subscribe;
return _ref = {
subscribe: function subscribe2(observer) {
if (typeof observer !== "object" || observer === null) {
throw new Error(formatProdErrorMessage$1(11));
}
function observeState() {
if (observer.next) {
observer.next(getState());
}
}
observeState();
var unsubscribe = outerSubscribe(observeState);
return {
unsubscribe
};
}
}, _ref[$$observable$1] = function() {
return this;
}, _ref;
}
dispatch({
type: ActionTypes$1.INIT
});
return _ref2 = {
dispatch,
subscribe,
getState,
replaceReducer
}, _ref2[$$observable$1] = observable, _ref2;
}
invariant$2 = function(condition, format, ...args) {
if (isProduction()) {
if (format === void 0) {
throw new Error("invariant requires an error message argument");
}
}
if (!condition) {
let error;
if (format === void 0) {
error = new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");
} else {
let argIndex = 0;
error = new Error(format.replace(/%s/g, function() {
return args[argIndex++];
}));
error.name = "Invariant Violation";
}
error.framesToPop = 1;
throw error;
}
};
function isProduction() {
return typeof process !== "undefined" && true;
}
function get(obj, path, defaultValue) {
return path.split(".").reduce((a, c2) => a && a[c2] ? a[c2] : defaultValue || null, obj);
}
function without$1(items, item) {
return items.filter((i) => i !== item);
}
function isObject$1(input) {
return typeof input === "object";
}
function xor(itemsA, itemsB) {
const map = /* @__PURE__ */ new Map();
const insertItem = (item) => {
map.set(item, map.has(item) ? map.get(item) + 1 : 1);
};
itemsA.forEach(insertItem);
itemsB.forEach(insertItem);
const result = [];
map.forEach((count2, key) => {
if (count2 === 1) {
result.push(key);
}
});
return result;
}
function intersection(itemsA, itemsB) {
return itemsA.filter((t) => itemsB.indexOf(t) > -1);
}
const INIT_COORDS = "dnd-core/INIT_COORDS";
const BEGIN_DRAG = "dnd-core/BEGIN_DRAG";
const PUBLISH_DRAG_SOURCE = "dnd-core/PUBLISH_DRAG_SOURCE";
const HOVER = "dnd-core/HOVER";
const DROP = "dnd-core/DROP";
const END_DRAG = "dnd-core/END_DRAG";
function setClientOffset(clientOffset, sourceClientOffset) {
return {
type: INIT_COORDS,
payload: {
sourceClientOffset: sourceClientOffset || null,
clientOffset: clientOffset || null
}
};
}
const ResetCoordinatesAction = {
type: INIT_COORDS,
payload: {
clientOffset: null,
sourceClientOffset: null
}
};
function createBeginDrag(manager) {
return function beginDrag(sourceIds = [], options = {
publishSource: true
}) {
const { publishSource = true, clientOffset, getSourceClientOffset: getSourceClientOffset2 } = options;
const monitor = manager.getMonitor();
const registry = manager.getRegistry();
manager.dispatch(setClientOffset(clientOffset));
verifyInvariants$1(sourceIds, monitor, registry);
const sourceId = getDraggableSource(sourceIds, monitor);
if (sourceId == null) {
manager.dispatch(ResetCoordinatesAction);
return;
}
let sourceClientOffset = null;
if (clientOffset) {
if (!getSourceClientOffset2) {
throw new Error("getSourceClientOffset must be defined");
}
verifyGetSourceClientOffsetIsFunction(getSourceClientOffset2);
sourceClientOffset = getSourceClientOffset2(sourceId);
}
manager.dispatch(setClientOffset(clientOffset, sourceClientOffset));
const source = registry.getSource(sourceId);
const item = source.beginDrag(monitor, sourceId);
if (item == null) {
return void 0;
}
verifyItemIsObject(item);
registry.pinSource(sourceId);
const itemType = registry.getSourceType(sourceId);
return {
type: BEGIN_DRAG,
payload: {
itemType,
item,
sourceId,
clientOffset: clientOffset || null,
sourceClientOffset: sourceClientOffset || null,
isSourcePublic: !!publishSource
}
};
};
}
function verifyInvariants$1(sourceIds, monitor, registry) {
invariant$2(!monitor.isDragging(), "Cannot call beginDrag while dragging.");
sourceIds.forEach(function(sourceId) {
invariant$2(registry.getSource(sourceId), "Expected sourceIds to be registered.");
});
}
function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset2) {
invariant$2(typeof getSourceClientOffset2 === "function", "When clientOffset is provided, getSourceClientOffset must be a function.");
}
function verifyItemIsObject(item) {
invariant$2(isObject$1(item), "Item must be an object.");
}
function getDraggableSource(sourceIds, monitor) {
let sourceId = null;
for (let i = sourceIds.length - 1; i >= 0; i--) {
if (monitor.canDragSource(sourceIds[i])) {
sourceId = sourceIds[i];
break;
}
}
return sourceId;
}
function _defineProperty$7(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread$7(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys2 = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys2.forEach(function(key) {
_defineProperty$7(target, key, source[key]);
});
}
return target;
}
function createDrop(manager) {
return function drop2(options = {}) {
const monitor = manager.getMonitor();
const registry = manager.getRegistry();
verifyInvariants(monitor);
const targetIds = getDroppableTargets(monitor);
targetIds.forEach((targetId, index) => {
const dropResult = determineDropResult(targetId, index, registry, monitor);
const action = {
type: DROP,
payload: {
dropResult: _objectSpread$7({}, options, dropResult)
}
};
manager.dispatch(action);
});
};
}
function verifyInvariants(monitor) {
invariant$2(monitor.isDragging(), "Cannot call drop while not dragging.");
invariant$2(!monitor.didDrop(), "Cannot call drop twice during one drag operation.");
}
function determineDropResult(targetId, index, registry, monitor) {
const target = registry.getTarget(targetId);
let dropResult = target ? target.drop(monitor, targetId) : void 0;
verifyDropResultType(dropResult);
if (typeof dropResult === "undefined") {
dropResult = index === 0 ? {} : monitor.getDropResult();
}
return dropResult;
}
function verifyDropResultType(dropResult) {
invariant$2(typeof dropResult === "undefined" || isObject$1(dropResult), "Drop result must either be an object or undefined.");
}
function getDroppableTargets(monitor) {
const targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);
targetIds.reverse();
return targetIds;
}
function createEndDrag(manager) {
return function endDrag() {
const monitor = manager.getMonitor();
const registry = manager.getRegistry();
verifyIsDragging(monitor);
const sourceId = monitor.getSourceId();
if (sourceId != null) {
const source = registry.getSource(sourceId, true);
source.endDrag(monitor, sourceId);
registry.unpinSource();
}
return {
type: END_DRAG
};
};
}
function verifyIsDragging(monitor) {
invariant$2(monitor.isDragging(), "Cannot call endDrag while not dragging.");
}
function matchesType(targetType, draggedItemType) {
if (draggedItemType === null) {
return targetType === null;
}
return Array.isArray(targetType) ? targetType.some((t) => t === draggedItemType) : targetType === draggedItemType;
}
function createHover(manager) {
return function hover(targetIdsArg, { clientOffset } = {}) {
verifyTargetIdsIsArray(targetIdsArg);
const targetIds = targetIdsArg.slice(0);
const monitor = manager.getMonitor();
const registry = manager.getRegistry();
const draggedItemType = monitor.getItemType();
removeNonMatchingTargetIds(targetIds, registry, draggedItemType);
checkInvariants(targetIds, monitor, registry);
hoverAllTargets(targetIds, monitor, registry);
return {
type: HOVER,
payload: {
targetIds,
clientOffset: clientOffset || null
}
};
};
}
function verifyTargetIdsIsArray(targetIdsArg) {
invariant$2(Array.isArray(targetIdsArg), "Expected targetIds to be an array.");
}
function checkInvariants(targetIds, monitor, registry) {
invariant$2(monitor.isDragging(), "Cannot call hover while not dragging.");
invariant$2(!monitor.didDrop(), "Cannot call hover after drop.");
for (let i = 0; i < targetIds.length; i++) {
const targetId = targetIds[i];
invariant$2(targetIds.lastIndexOf(targetId) === i, "Expected targetIds to be unique in the passed array.");
const target = registry.getTarget(targetId);
invariant$2(target, "Expected targetIds to be registered.");
}
}
function removeNonMatchingTargetIds(targetIds, registry, draggedItemType) {
for (let i = targetIds.length - 1; i >= 0; i--) {
const targetId = targetIds[i];
const targetType = registry.getTargetType(targetId);
if (!matchesType(targetType, draggedItemType)) {
targetIds.splice(i, 1);
}
}
}
function hoverAllTargets(targetIds, monitor, registry) {
targetIds.forEach(function(targetId) {
const target = registry.getTarget(targetId);
target.hover(monitor, targetId);
});
}
function createPublishDragSource(manager) {
return function publishDragSource() {
const monitor = manager.getMonitor();
if (monitor.isDragging()) {
return {
type: PUBLISH_DRAG_SOURCE
};
}
return;
};
}
function createDragDropActions(manager) {
return {
beginDrag: createBeginDrag(manager),
publishDragSource: createPublishDragSource(manager),
hover: createHover(manager),
drop: createDrop(manager),
endDrag: createEndDrag(manager)
};
}
class DragDropManagerImpl {
receiveBackend(backend) {
this.backend = backend;
}
getMonitor() {
return this.monitor;
}
getBackend() {
return this.backend;
}
getRegistry() {
return this.monitor.registry;
}
getActions() {
const manager = this;
const { dispatch } = this.store;
function bindActionCreator2(actionCreator) {
return (...args) => {
const action = actionCreator.apply(manager, args);
if (typeof action !== "undefined") {
dispatch(action);
}
};
}
const actions = createDragDropActions(this);
return Object.keys(actions).reduce((boundActions, key) => {
const action = actions[key];
boundActions[key] = bindActionCreator2(action);
return boundActions;
}, {});
}
dispatch(action) {
this.store.dispatch(action);
}
constructor(store2, monitor) {
this.isSetUp = false;
this.handleRefCountChange = () => {
const shouldSetUp = this.store.getState().refCount > 0;
if (this.backend) {
if (shouldSetUp && !this.isSetUp) {
this.backend.setup();
this.isSetUp = true;
} else if (!shouldSetUp && this.isSetUp) {
this.backend.teardown();
this.isSetUp = false;
}
}
};
this.store = store2;
this.monitor = monitor;
store2.subscribe(this.handleRefCountChange);
}
}
function add$1(a, b2) {
return {
x: a.x + b2.x,
y: a.y + b2.y
};
}
function subtract$1(a, b2) {
return {
x: a.x - b2.x,
y: a.y - b2.y
};
}
function getSourceClientOffset(state) {
const { clientOffset, initialClientOffset, initialSourceClientOffset } = state;
if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) {
return null;
}
return subtract$1(add$1(clientOffset, initialSourceClientOffset), initialClientOffset);
}
function getDifferenceFromInitialOffset(state) {
const { clientOffset, initialClientOffset } = state;
if (!clientOffset || !initialClientOffset) {
return null;
}
return subtract$1(clientOffset, initialClientOffset);
}
const NONE = [];
const ALL = [];
NONE.__IS_NONE__ = true;
ALL.__IS_ALL__ = true;
function areDirty(dirtyIds, handlerIds) {
if (dirtyIds === NONE) {
return false;
}
if (dirtyIds === ALL || typeof handlerIds === "undefined") {
return true;
}
const commonIds = intersection(handlerIds, dirtyIds);
return commonIds.length > 0;
}
class DragDropMonitorImpl {
subscribeToStateChange(listener, options = {}) {
const { handlerIds } = options;
invariant$2(typeof listener === "function", "listener must be a function.");
invariant$2(typeof handlerIds === "undefined" || Array.isArray(handlerIds), "handlerIds, when specified, must be an array of strings.");
let prevStateId = this.store.getState().stateId;
const handleChange = () => {
const state = this.store.getState();
const currentStateId = state.stateId;
try {
const canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !areDirty(state.dirtyHandlerIds, handlerIds);
if (!canSkipListener) {
listener();
}
} finally {
prevStateId = currentStateId;
}
};
return this.store.subscribe(handleChange);
}
subscribeToOffsetChange(listener) {
invariant$2(typeof listener === "function", "listener must be a function.");
let previousState = this.store.getState().dragOffset;
const handleChange = () => {
const nextState = this.store.getState().dragOffset;
if (nextState === previousState) {
return;
}
previousState = nextState;
listener();
};
return this.store.subscribe(handleChange);
}
canDragSource(sourceId) {
if (!sourceId) {
return false;
}
const source = this.registry.getSource(sourceId);
invariant$2(source, `Expected to find a valid source. sourceId=${sourceId}`);
if (this.isDragging()) {
return false;
}
return source.canDrag(this, sourceId);
}
canDropOnTarget(targetId) {
if (!targetId) {
return false;
}
const target = this.registry.getTarget(targetId);
invariant$2(target, `Expected to find a valid target. targetId=${targetId}`);
if (!this.isDragging() || this.didDrop()) {
return false;
}
const targetType = this.registry.getTargetType(targetId);
const draggedItemType = this.getItemType();
return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId);
}
isDragging() {
return Boolean(this.getItemType());
}
isDraggingSource(sourceId) {
if (!sourceId) {
return false;
}
const source = this.registry.getSource(sourceId, true);
invariant$2(source, `Expected to find a valid source. sourceId=${sourceId}`);
if (!this.isDragging() || !this.isSourcePublic()) {
return false;
}
const sourceType = this.registry.getSourceType(sourceId);
const draggedItemType = this.getItemType();
if (sourceType !== draggedItemType) {
return false;
}
return source.isDragging(this, sourceId);
}
isOverTarget(targetId, options = {
shallow: false
}) {
if (!targetId) {
return false;
}
const { shallow } = options;
if (!this.isDragging()) {
return false;
}
const targetType = this.registry.getTargetType(targetId);
const draggedItemType = this.getItemType();
if (draggedItemType && !matchesType(targetType, draggedItemType)) {
return false;
}
const targetIds = this.getTargetIds();
if (!targetIds.length) {
return false;
}
const index = targetIds.indexOf(targetId);
if (shallow) {
return index === targetIds.length - 1;
} else {
return index > -1;
}
}
getItemType() {
return this.store.getState().dragOperation.itemType;
}
getItem() {
return this.store.getState().dragOperation.item;
}
getSourceId() {
return this.store.getState().dragOperation.sourceId;
}
getTargetIds() {
return this.store.getState().dragOperation.targetIds;
}
getDropResult() {
return this.store.getState().dragOperation.dropResult;
}
didDrop() {
return this.store.getState().dragOperation.didDrop;
}
isSourcePublic() {
return Boolean(this.store.getState().dragOperation.isSourcePublic);
}
getInitialClientOffset() {
return this.store.getState().dragOffset.initialClientOffset;
}
getInitialSourceClientOffset() {
return this.store.getState().dragOffset.initialSourceClientOffset;
}
getClientOffset() {
return this.store.getState().dragOffset.clientOffset;
}
getSourceClientOffset() {
return getSourceClientOffset(this.store.getState().dragOffset);
}
getDifferenceFromInitialOffset() {
return getDifferenceFromInitialOffset(this.store.getState().dragOffset);
}
constructor(store2, registry) {
this.store = store2;
this.registry = registry;
}
}
const scope = typeof global !== "undefined" ? global : self;
const BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
function makeRequestCallFromTimer(callback) {
return function requestCall() {
const timeoutHandle = setTimeout(handleTimer, 0);
const intervalHandle = setInterval(handleTimer, 50);
function handleTimer() {
clearTimeout(timeoutHandle);
clearInterval(intervalHandle);
callback();
}
};
}
function makeRequestCallFromMutationObserver(callback) {
let toggle = 1;
const observer = new BrowserMutationObserver(callback);
const node = document.createTextNode("");
observer.observe(node, {
characterData: true
});
return function requestCall() {
toggle = -toggle;
node.data = toggle;
};
}
const makeRequestCall = typeof BrowserMutationObserver === "function" ? makeRequestCallFromMutationObserver : makeRequestCallFromTimer;
class AsapQueue {
enqueueTask(task) {
const { queue: q2, requestFlush } = this;
if (!q2.length) {
requestFlush();
this.flushing = true;
}
q2[q2.length] = task;
}
constructor() {
this.queue = [];
this.pendingErrors = [];
this.flushing = false;
this.index = 0;
this.capacity = 1024;
this.flush = () => {
const { queue: q2 } = this;
while (this.index < q2.length) {
const currentIndex = this.index;
this.index++;
q2[currentIndex].call();
if (this.index > this.capacity) {
for (let scan = 0, newLength = q2.length - this.index; scan < newLength; scan++) {
q2[scan] = q2[scan + this.index];
}
q2.length -= this.index;
this.index = 0;
}
}
q2.length = 0;
this.index = 0;
this.flushing = false;
};
this.registerPendingError = (err) => {
this.pendingErrors.push(err);
this.requestErrorThrow();
};
this.requestFlush = makeRequestCall(this.flush);
this.requestErrorThrow = makeRequestCallFromTimer(() => {
if (this.pendingErrors.length) {
throw this.pendingErrors.shift();
}
});
}
}
class RawTask {
call() {
try {
this.task && this.task();
} catch (error) {
this.onError(error);
} finally {
this.task = null;
this.release(this);
}
}
constructor(onError, release) {
this.onError = onError;
this.release = release;
this.task = null;
}
}
class TaskFactory {
create(task) {
const tasks = this.freeTasks;
const t1 = tasks.length ? tasks.pop() : new RawTask(this.onError, (t) => tasks[tasks.length] = t);
t1.task = task;
return t1;
}
constructor(onError) {
this.onError = onError;
this.freeTasks = [];
}
}
const asapQueue = new AsapQueue();
const taskFactory = new TaskFactory(asapQueue.registerPendingError);
function asap(task) {
asapQueue.enqueueTask(taskFactory.create(task));
}
const ADD_SOURCE = "dnd-core/ADD_SOURCE";
const ADD_TARGET = "dnd-core/ADD_TARGET";
const REMOVE_SOURCE = "dnd-core/REMOVE_SOURCE";
const REMOVE_TARGET = "dnd-core/REMOVE_TARGET";
function addSource(sourceId) {
return {
type: ADD_SOURCE,
payload: {
sourceId
}
};
}
function addTarget(targetId) {
return {
type: ADD_TARGET,
payload: {
targetId
}
};
}
function removeSource(sourceId) {
return {
type: REMOVE_SOURCE,
payload: {
sourceId
}
};
}
function removeTarget(targetId) {
return {
type: REMOVE_TARGET,
payload: {
targetId
}
};
}
function validateSourceContract(source) {
invariant$2(typeof source.canDrag === "function", "Expected canDrag to be a function.");
invariant$2(typeof source.beginDrag === "function", "Expected beginDrag to be a function.");
invariant$2(typeof source.endDrag === "function", "Expected endDrag to be a function.");
}
function validateTargetContract(target) {
invariant$2(typeof target.canDrop === "function", "Expected canDrop to be a function.");
invariant$2(typeof target.hover === "function", "Expected hover to be a function.");
invariant$2(typeof target.drop === "function", "Expected beginDrag to be a function.");
}
function validateType(type, allowArray) {
if (allowArray && Array.isArray(type)) {
type.forEach((t) => validateType(t, false));
return;
}
invariant$2(typeof type === "string" || typeof type === "symbol", allowArray ? "Type can only be a string, a symbol, or an array of either." : "Type can only be a string or a symbol.");
}
var HandlerRole;
(function(HandlerRole2) {
HandlerRole2["SOURCE"] = "SOURCE";
HandlerRole2["TARGET"] = "TARGET";
})(HandlerRole || (HandlerRole = {}));
let nextUniqueId = 0;
function getNextUniqueId() {
return nextUniqueId++;
}
function getNextHandlerId(role) {
const id = getNextUniqueId().toString();
switch (role) {
case HandlerRole.SOURCE:
return `S${id}`;
case HandlerRole.TARGET:
return `T${id}`;
default:
throw new Error(`Unknown Handler Role: ${role}`);
}
}
function parseRoleFromHandlerId(handlerId) {
switch (handlerId[0]) {
case "S":
return HandlerRole.SOURCE;
case "T":
return HandlerRole.TARGET;
default:
throw new Error(`Cannot parse handler ID: ${handlerId}`);
}
}
function mapContainsValue(map, searchValue) {
const entries = map.entries();
let isDone = false;
do {
const { done, value: [, value] } = entries.next();
if (value === searchValue) {
return true;
}
isDone = !!done;
} while (!isDone);
return false;
}
class HandlerRegistryImpl {
addSource(type, source) {
validateType(type);
validateSourceContract(source);
const sourceId = this.addHandler(HandlerRole.SOURCE, type, source);
this.store.dispatch(addSource(sourceId));
return sourceId;
}
addTarget(type, target) {
validateType(type, true);
validateTargetContract(target);
const targetId = this.addHandler(HandlerRole.TARGET, type, target);
this.store.dispatch(addTarget(targetId));
return targetId;
}
containsHandler(handler) {
return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler);
}
getSource(sourceId, includePinned = false) {
invariant$2(this.isSourceId(sourceId), "Expected a valid source ID.");
const isPinned = includePinned && sourceId === this.pinnedSourceId;
const source = isPinned ? this.pinnedSource : this.dragSources.get(sourceId);
return source;
}
getTarget(targetId) {
invariant$2(this.isTargetId(targetId), "Expected a valid target ID.");
return this.dropTargets.get(targetId);
}
getSourceType(sourceId) {
invariant$2(this.isSourceId(sourceId), "Expected a valid source ID.");
return this.types.get(sourceId);
}
getTargetType(targetId) {
invariant$2(this.isTargetId(targetId), "Expected a valid target ID.");
return this.types.get(targetId);
}
isSourceId(handlerId) {
const role = parseRoleFromHandlerId(handlerId);
return role === HandlerRole.SOURCE;
}
isTargetId(handlerId) {
const role = parseRoleFromHandlerId(handlerId);
return role === HandlerRole.TARGET;
}
removeSource(sourceId) {
invariant$2(this.getSource(sourceId), "Expected an existing source.");
this.store.dispatch(removeSource(sourceId));
asap(() => {
this.dragSources.delete(sourceId);
this.types.delete(sourceId);
});
}
removeTarget(targetId) {
invariant$2(this.getTarget(targetId), "Expected an existing target.");
this.store.dispatch(removeTarget(targetId));
this.dropTargets.delete(targetId);
this.types.delete(targetId);
}
pinSource(sourceId) {
const source = this.getSource(sourceId);
invariant$2(source, "Expected an existing source.");
this.pinnedSourceId = sourceId;
this.pinnedSource = source;
}
unpinSource() {
invariant$2(this.pinnedSource, "No source is pinned at the time.");
this.pinnedSourceId = null;
this.pinnedSource = null;
}
addHandler(role, type, handler) {
const id = getNextHandlerId(role);
this.types.set(id, type);
if (role === HandlerRole.SOURCE) {
this.dragSources.set(id, handler);
} else if (role === HandlerRole.TARGET) {
this.dropTargets.set(id, handler);
}
return id;
}
constructor(store2) {
this.types = /* @__PURE__ */ new Map();
this.dragSources = /* @__PURE__ */ new Map();
this.dropTargets = /* @__PURE__ */ new Map();
this.pinnedSourceId = null;
this.pinnedSource = null;
this.store = store2;
}
}
const strictEquality = (a, b2) => a === b2;
function areCoordsEqual(offsetA, offsetB) {
if (!offsetA && !offsetB) {
return true;
} else if (!offsetA || !offsetB) {
return false;
} else {
return offsetA.x === offsetB.x && offsetA.y === offsetB.y;
}
}
function areArraysEqual(a, b2, isEqual2 = strictEquality) {
if (a.length !== b2.length) {
return false;
}
for (let i = 0; i < a.length; ++i) {
if (!isEqual2(a[i], b2[i])) {
return false;
}
}
return true;
}
function reduce$5(_state = NONE, action) {
switch (action.type) {
case HOVER:
break;
case ADD_SOURCE:
case ADD_TARGET:
case REMOVE_TARGET:
case REMOVE_SOURCE:
return NONE;
case BEGIN_DRAG:
case PUBLISH_DRAG_SOURCE:
case END_DRAG:
case DROP:
default:
return ALL;
}
const { targetIds = [], prevTargetIds = [] } = action.payload;
const result = xor(targetIds, prevTargetIds);
const didChange = result.length > 0 || !areArraysEqual(targetIds, prevTargetIds);
if (!didChange) {
return NONE;
}
const prevInnermostTargetId = prevTargetIds[prevTargetIds.length - 1];
const innermostTargetId = targetIds[targetIds.length - 1];
if (prevInnermostTargetId !== innermostTargetId) {
if (prevInnermostTargetId) {
result.push(prevInnermostTargetId);
}
if (innermostTargetId) {
result.push(innermostTargetId);
}
}
return result;
}
function _defineProperty$6(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread$6(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys2 = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys2.forEach(function(key) {
_defineProperty$6(target, key, source[key]);
});
}
return target;
}
const initialState$2 = {
initialSourceClientOffset: null,
initialClientOffset: null,
clientOffset: null
};
function reduce$4(state = initialState$2, action) {
const { payload } = action;
switch (action.type) {
case INIT_COORDS:
case BEGIN_DRAG:
return {
initialSourceClientOffset: payload.sourceClientOffset,
initialClientOffset: payload.clientOffset,
clientOffset: payload.clientOffset
};
case HOVER:
if (areCoordsEqual(state.clientOffset, payload.clientOffset)) {
return state;
}
return _objectSpread$6({}, state, {
clientOffset: payload.clientOffset
});
case END_DRAG:
case DROP:
return initialState$2;
default:
return state;
}
}
function _defineProperty$5(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread$5(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys2 = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys2.forEach(function(key) {
_defineProperty$5(target, key, source[key]);
});
}
return target;
}
const initialState$1 = {
itemType: null,
item: null,
sourceId: null,
targetIds: [],
dropResult: null,
didDrop: false,
isSourcePublic: null
};
function reduce$3(state = initialState$1, action) {
const { payload } = action;
switch (action.type) {
case BEGIN_DRAG:
return _objectSpread$5({}, state, {
itemType: payload.itemType,
item: payload.item,
sourceId: payload.sourceId,
isSourcePublic: payload.isSourcePublic,
dropResult: null,
didDrop: false
});
case PUBLISH_DRAG_SOURCE:
return _objectSpread$5({}, state, {
isSourcePublic: true
});
case HOVER:
return _objectSpread$5({}, state, {
targetIds: payload.targetIds
});
case REMOVE_TARGET:
if (state.targetIds.indexOf(payload.targetId) === -1) {
return state;
}
return _objectSpread$5({}, state, {
targetIds: without$1(state.targetIds, payload.targetId)
});
case DROP:
return _objectSpread$5({}, state, {
dropResult: payload.dropResult,
didDrop: true,
targetIds: []
});
case END_DRAG:
return _objectSpread$5({}, state, {
itemType: null,
item: null,
sourceId: null,
dropResult: null,
didDrop: false,
isSourcePublic: null,
targetIds: []
});
default:
return state;
}
}
function reduce$2(state = 0, action) {
switch (action.type) {
case ADD_SOURCE:
case ADD_TARGET:
return state + 1;
case REMOVE_SOURCE:
case REMOVE_TARGET:
return state - 1;
default:
return state;
}
}
function reduce$1(state = 0) {
return state + 1;
}
function _defineProperty$4(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread$4(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys2 = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys2.forEach(function(key) {
_defineProperty$4(target, key, source[key]);
});
}
return target;
}
function reduce(state = {}, action) {
return {
dirtyHandlerIds: reduce$5(state.dirtyHandlerIds, {
type: action.type,
payload: _objectSpread$4({}, action.payload, {
prevTargetIds: get(state, "dragOperation.targetIds", [])
})
}),
dragOffset: reduce$4(state.dragOffset, action),
refCount: reduce$2(state.refCount, action),
dragOperation: reduce$3(state.dragOperation, action),
stateId: reduce$1(state.stateId)
};
}
function createDragDropManager(backendFactory, globalContext = void 0, backendOptions = {}, debugMode = false) {
const store2 = makeStoreInstance(debugMode);
const monitor = new DragDropMonitorImpl(store2, new HandlerRegistryImpl(store2));
const manager = new DragDropManagerImpl(store2, monitor);
const backend = backendFactory(manager, globalContext, backendOptions);
manager.receiveBackend(backend);
return manager;
}
function makeStoreInstance(debugMode) {
const reduxDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__;
return createStore$2(reduce, debugMode && reduxDevTools && reduxDevTools({
name: "dnd-core",
instanceId: "dnd-core"
}));
}
function _objectWithoutProperties$2(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose$2(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _objectWithoutPropertiesLoose$2(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
let refCount = 0;
const INSTANCE_SYM = /* @__PURE__ */ Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");
DndProvider = __mf_17(function DndProvider2(_param) {
var { children } = _param, props = _objectWithoutProperties$2(_param, [
"children"
]);
const [manager, isGlobalInstance] = getDndContextValue(props);
__mf_24(() => {
if (isGlobalInstance) {
const context = getGlobalContext();
++refCount;
return () => {
if (--refCount === 0) {
context[INSTANCE_SYM] = null;
}
};
}
return;
}, []);
return jsxRuntimeExports.jsx(DndContext.Provider, {
value: manager,
children
});
});
function getDndContextValue(props) {
if ("manager" in props) {
const manager2 = {
dragDropManager: props.manager
};
return [
manager2,
false
];
}
const manager = createSingletonDndContext(props.backend, props.context, props.options, props.debugMode);
const isGlobalInstance = !props.context;
return [
manager,
isGlobalInstance
];
}
function createSingletonDndContext(backend, context = getGlobalContext(), options, debugMode) {
const ctx = context;
if (!ctx[INSTANCE_SYM]) {
ctx[INSTANCE_SYM] = {
dragDropManager: createDragDropManager(backend, context, options, debugMode)
};
}
return ctx[INSTANCE_SYM];
}
function getGlobalContext() {
return typeof global !== "undefined" ? global : window;
}
var fastDeepEqual = function equal2(a, b2) {
if (a === b2) return true;
if (a && b2 && typeof a == "object" && typeof b2 == "object") {
if (a.constructor !== b2.constructor) return false;
var length, i, keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b2.length) return false;
for (i = length; i-- !== 0; ) if (!equal2(a[i], b2[i])) return false;
return true;
}
if (a.constructor === RegExp) return a.source === b2.source && a.flags === b2.flags;
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b2.valueOf();
if (a.toString !== Object.prototype.toString) return a.toString() === b2.toString();
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b2).length) return false;
for (i = length; i-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(b2, keys[i])) return false;
for (i = length; i-- !== 0; ) {
var key = keys[i];
if (!equal2(a[key], b2[key])) return false;
}
return true;
}
return a !== a && b2 !== b2;
};
const equal = getDefaultExportFromCjs(fastDeepEqual);
const useIsomorphicLayoutEffect$2 = typeof window !== "undefined" ? __mf_28 : __mf_24;
useCollector = function(monitor, collect, onUpdate) {
const [collected, setCollected] = __mf_32(() => collect(monitor));
const updateCollected = __mf_20(() => {
const nextValue = collect(monitor);
if (!equal(collected, nextValue)) {
setCollected(nextValue);
if (onUpdate) {
onUpdate();
}
}
}, [
collected,
monitor,
onUpdate
]);
useIsomorphicLayoutEffect$2(updateCollected);
return [
collected,
updateCollected
];
};
function useMonitorOutput(monitor, collect, onCollect) {
const [collected, updateCollected] = useCollector(monitor, collect, onCollect);
useIsomorphicLayoutEffect$2(function subscribeToMonitorStateChange() {
const handlerId = monitor.getHandlerId();
if (handlerId == null) {
return;
}
return monitor.subscribeToStateChange(updateCollected, {
handlerIds: [
handlerId
]
});
}, [
monitor,
updateCollected
]);
return collected;
}
function useCollectedProps(collector, monitor, connector) {
return useMonitorOutput(monitor, collector || (() => ({})), () => connector.reconnect());
}
function useOptionalFactory(arg, deps) {
const memoDeps = [
...deps || []
];
if (deps == null && typeof arg !== "function") {
memoDeps.push(arg);
}
return __mf_29(() => {
return typeof arg === "function" ? arg() : arg;
}, memoDeps);
}
function useConnectDragSource(connector) {
return __mf_29(() => connector.hooks.dragSource(), [
connector
]);
}
function useConnectDragPreview(connector) {
return __mf_29(() => connector.hooks.dragPreview(), [
connector
]);
}
let isCallingCanDrag = false;
let isCallingIsDragging = false;
class DragSourceMonitorImpl {
receiveHandlerId(sourceId) {
this.sourceId = sourceId;
}
getHandlerId() {
return this.sourceId;
}
canDrag() {
invariant$2(!isCallingCanDrag, "You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");
try {
isCallingCanDrag = true;
return this.internalMonitor.canDragSource(this.sourceId);
} finally {
isCallingCanDrag = false;
}
}
isDragging() {
if (!this.sourceId) {
return false;
}
invariant$2(!isCallingIsDragging, "You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");
try {
isCallingIsDragging = true;
return this.internalMonitor.isDraggingSource(this.sourceId);
} finally {
isCallingIsDragging = false;
}
}
subscribeToStateChange(listener, options) {
return this.internalMonitor.subscribeToStateChange(listener, options);
}
isDraggingSource(sourceId) {
return this.internalMonitor.isDraggingSource(sourceId);
}
isOverTarget(targetId, options) {
return this.internalMonitor.isOverTarget(targetId, options);
}
getTargetIds() {
return this.internalMonitor.getTargetIds();
}
isSourcePublic() {
return this.internalMonitor.isSourcePublic();
}
getSourceId() {
return this.internalMonitor.getSourceId();
}
subscribeToOffsetChange(listener) {
return this.internalMonitor.subscribeToOffsetChange(listener);
}
canDragSource(sourceId) {
return this.internalMonitor.canDragSource(sourceId);
}
canDropOnTarget(targetId) {
return this.internalMonitor.canDropOnTarget(targetId);
}
getItemType() {
return this.internalMonitor.getItemType();
}
getItem() {
return this.internalMonitor.getItem();
}
getDropResult() {
return this.internalMonitor.getDropResult();
}
didDrop() {
return this.internalMonitor.didDrop();
}
getInitialClientOffset() {
return this.internalMonitor.getInitialClientOffset();
}
getInitialSourceClientOffset() {
return this.internalMonitor.getInitialSourceClientOffset();
}
getSourceClientOffset() {
return this.internalMonitor.getSourceClientOffset();
}
getClientOffset() {
return this.internalMonitor.getClientOffset();
}
getDifferenceFromInitialOffset() {
return this.internalMonitor.getDifferenceFromInitialOffset();
}
constructor(manager) {
this.sourceId = null;
this.internalMonitor = manager.getMonitor();
}
}
let isCallingCanDrop = false;
class DropTargetMonitorImpl {
receiveHandlerId(targetId) {
this.targetId = targetId;
}
getHandlerId() {
return this.targetId;
}
subscribeToStateChange(listener, options) {
return this.internalMonitor.subscribeToStateChange(listener, options);
}
canDrop() {
if (!this.targetId) {
return false;
}
invariant$2(!isCallingCanDrop, "You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");
try {
isCallingCanDrop = true;
return this.internalMonitor.canDropOnTarget(this.targetId);
} finally {
isCallingCanDrop = false;
}
}
isOver(options) {
if (!this.targetId) {
return false;
}
return this.internalMonitor.isOverTarget(this.targetId, options);
}
getItemType() {
return this.internalMonitor.getItemType();
}
getItem() {
return this.internalMonitor.getItem();
}
getDropResult() {
return this.internalMonitor.getDropResult();
}
didDrop() {
return this.internalMonitor.didDrop();
}
getInitialClientOffset() {
return this.internalMonitor.getInitialClientOffset();
}
getInitialSourceClientOffset() {
return this.internalMonitor.getInitialSourceClientOffset();
}
getSourceClientOffset() {
return this.internalMonitor.getSourceClientOffset();
}
getClientOffset() {
return this.internalMonitor.getClientOffset();
}
getDifferenceFromInitialOffset() {
return this.internalMonitor.getDifferenceFromInitialOffset();
}
constructor(manager) {
this.targetId = null;
this.internalMonitor = manager.getMonitor();
}
}
function registerTarget(type, target, manager) {
const registry = manager.getRegistry();
const targetId = registry.addTarget(type, target);
return [
targetId,
() => registry.removeTarget(targetId)
];
}
function registerSource(type, source, manager) {
const registry = manager.getRegistry();
const sourceId = registry.addSource(type, source);
return [
sourceId,
() => registry.removeSource(sourceId)
];
}
function shallowEqual$1(objA, objB, compare, compareContext) {
let compareResult = void 0;
if (compareResult !== void 0) {
return !!compareResult;
}
if (objA === objB) {
return true;
}
if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
return false;
}
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
for (let idx = 0; idx < keysA.length; idx++) {
const key = keysA[idx];
if (!bHasOwnProperty(key)) {
return false;
}
const valueA = objA[key];
const valueB = objB[key];
compareResult = void 0;
if (compareResult === false || compareResult === void 0 && valueA !== valueB) {
return false;
}
}
return true;
}
function isRef(obj) {
return obj !== null && typeof obj === "object" && Object.prototype.hasOwnProperty.call(obj, "current");
}
function throwIfCompositeComponentElement(element) {
if (typeof element.type === "string") {
return;
}
const displayName = element.type.displayName || element.type.name || "the component";
throw new Error(`Only native element nodes can now be passed to React DnD connectors.You can either wrap ${displayName} into a <div>, or turn it into a drag source or a drop target itself.`);
}
function wrapHookToRecognizeElement(hook) {
return (elementOrNode = null, options = null) => {
if (!__mf_15(elementOrNode)) {
const node = elementOrNode;
hook(node, options);
return node;
}
const element = elementOrNode;
throwIfCompositeComponentElement(element);
const ref = options ? (node) => hook(node, options) : hook;
return cloneWithRef(element, ref);
};
}
function wrapConnectorHooks(hooks) {
const wrappedHooks = {};
Object.keys(hooks).forEach((key) => {
const hook = hooks[key];
if (key.endsWith("Ref")) {
wrappedHooks[key] = hooks[key];
} else {
const wrappedHook = wrapHookToRecognizeElement(hook);
wrappedHooks[key] = () => wrappedHook;
}
});
return wrappedHooks;
}
function setRef(ref, node) {
if (typeof ref === "function") {
ref(node);
} else {
ref.current = node;
}
}
function cloneWithRef(element, newRef) {
const previousRef = element.ref;
invariant$2(typeof previousRef !== "string", "Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs");
if (!previousRef) {
return __mf_9(element, {
ref: newRef
});
} else {
return __mf_9(element, {
ref: (node) => {
setRef(previousRef, node);
setRef(newRef, node);
}
});
}
}
class SourceConnector {
receiveHandlerId(newHandlerId) {
if (this.handlerId === newHandlerId) {
return;
}
this.handlerId = newHandlerId;
this.reconnect();
}
get connectTarget() {
return this.dragSource;
}
get dragSourceOptions() {
return this.dragSourceOptionsInternal;
}
set dragSourceOptions(options) {
this.dragSourceOptionsInternal = options;
}
get dragPreviewOptions() {
return this.dragPreviewOptionsInternal;
}
set dragPreviewOptions(options) {
this.dragPreviewOptionsInternal = options;
}
reconnect() {
const didChange = this.reconnectDragSource();
this.reconnectDragPreview(didChange);
}
reconnectDragSource() {
const dragSource = this.dragSource;
const didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
if (didChange) {
this.disconnectDragSource();
}
if (!this.handlerId) {
return didChange;
}
if (!dragSource) {
this.lastConnectedDragSource = dragSource;
return didChange;
}
if (didChange) {
this.lastConnectedHandlerId = this.handlerId;
this.lastConnectedDragSource = dragSource;
this.lastConnectedDragSourceOptions = this.dragSourceOptions;
this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
}
return didChange;
}
reconnectDragPreview(forceDidChange = false) {
const dragPreview = this.dragPreview;
const didChange = forceDidChange || this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
if (didChange) {
this.disconnectDragPreview();
}
if (!this.handlerId) {
return;
}
if (!dragPreview) {
this.lastConnectedDragPreview = dragPreview;
return;
}
if (didChange) {
this.lastConnectedHandlerId = this.handlerId;
this.lastConnectedDragPreview = dragPreview;
this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
}
}
didHandlerIdChange() {
return this.lastConnectedHandlerId !== this.handlerId;
}
didConnectedDragSourceChange() {
return this.lastConnectedDragSource !== this.dragSource;
}
didConnectedDragPreviewChange() {
return this.lastConnectedDragPreview !== this.dragPreview;
}
didDragSourceOptionsChange() {
return !shallowEqual$1(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
}
didDragPreviewOptionsChange() {
return !shallowEqual$1(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
}
disconnectDragSource() {
if (this.dragSourceUnsubscribe) {
this.dragSourceUnsubscribe();
this.dragSourceUnsubscribe = void 0;
}
}
disconnectDragPreview() {
if (this.dragPreviewUnsubscribe) {
this.dragPreviewUnsubscribe();
this.dragPreviewUnsubscribe = void 0;
this.dragPreviewNode = null;
this.dragPreviewRef = null;
}
}
get dragSource() {
return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
}
get dragPreview() {
return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
}
clearDragSource() {
this.dragSourceNode = null;
this.dragSourceRef = null;
}
clearDragPreview() {
this.dragPreviewNode = null;
this.dragPreviewRef = null;
}
constructor(backend) {
this.hooks = wrapConnectorHooks({
dragSource: (node, options) => {
this.clearDragSource();
this.dragSourceOptions = options || null;
if (isRef(node)) {
this.dragSourceRef = node;
} else {
this.dragSourceNode = node;
}
this.reconnectDragSource();
},
dragPreview: (node, options) => {
this.clearDragPreview();
this.dragPreviewOptions = options || null;
if (isRef(node)) {
this.dragPreviewRef = node;
} else {
this.dragPreviewNode = node;
}
this.reconnectDragPreview();
}
});
this.handlerId = null;
this.dragSourceRef = null;
this.dragSourceOptionsInternal = null;
this.dragPreviewRef = null;
this.dragPreviewOptionsInternal = null;
this.lastConnectedHandlerId = null;
this.lastConnectedDragSource = null;
this.lastConnectedDragSourceOptions = null;
this.lastConnectedDragPreview = null;
this.lastConnectedDragPreviewOptions = null;
this.backend = backend;
}
}
class TargetConnector {
get connectTarget() {
return this.dropTarget;
}
reconnect() {
const didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange();
if (didChange) {
this.disconnectDropTarget();
}
const dropTarget = this.dropTarget;
if (!this.handlerId) {
return;
}
if (!dropTarget) {
this.lastConnectedDropTarget = dropTarget;
return;
}
if (didChange) {
this.lastConnectedHandlerId = this.handlerId;
this.lastConnectedDropTarget = dropTarget;
this.lastConnectedDropTargetOptions = this.dropTargetOptions;
this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, dropTarget, this.dropTargetOptions);
}
}
receiveHandlerId(newHandlerId) {
if (newHandlerId === this.handlerId) {
return;
}
this.handlerId = newHandlerId;
this.reconnect();
}
get dropTargetOptions() {
return this.dropTargetOptionsInternal;
}
set dropTargetOptions(options) {
this.dropTargetOptionsInternal = options;
}
didHandlerIdChange() {
return this.lastConnectedHandlerId !== this.handlerId;
}
didDropTargetChange() {
return this.lastConnectedDropTarget !== this.dropTarget;
}
didOptionsChange() {
return !shallowEqual$1(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
}
disconnectDropTarget() {
if (this.unsubscribeDropTarget) {
this.unsubscribeDropTarget();
this.unsubscribeDropTarget = void 0;
}
}
get dropTarget() {
return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
}
clearDropTarget() {
this.dropTargetRef = null;
this.dropTargetNode = null;
}
constructor(backend) {
this.hooks = wrapConnectorHooks({
dropTarget: (node, options) => {
this.clearDropTarget();
this.dropTargetOptions = options;
if (isRef(node)) {
this.dropTargetRef = node;
} else {
this.dropTargetNode = node;
}
this.reconnect();
}
});
this.handlerId = null;
this.dropTargetRef = null;
this.dropTargetOptionsInternal = null;
this.lastConnectedHandlerId = null;
this.lastConnectedDropTarget = null;
this.lastConnectedDropTargetOptions = null;
this.backend = backend;
}
}
useDragDropManager = function() {
const { dragDropManager } = __mf_21(DndContext);
invariant$2(dragDropManager != null, "Expected drag drop context");
return dragDropManager;
};
function useDragSourceConnector(dragSourceOptions, dragPreviewOptions) {
const manager = useDragDropManager();
const connector = __mf_29(() => new SourceConnector(manager.getBackend()), [
manager
]);
useIsomorphicLayoutEffect$2(() => {
connector.dragSourceOptions = dragSourceOptions || null;
connector.reconnect();
return () => connector.disconnectDragSource();
}, [
connector,
dragSourceOptions
]);
useIsomorphicLayoutEffect$2(() => {
connector.dragPreviewOptions = dragPreviewOptions || null;
connector.reconnect();
return () => connector.disconnectDragPreview();
}, [
connector,
dragPreviewOptions
]);
return connector;
}
function useDragSourceMonitor() {
const manager = useDragDropManager();
return __mf_29(() => new DragSourceMonitorImpl(manager), [
manager
]);
}
class DragSourceImpl {
beginDrag() {
const spec = this.spec;
const monitor = this.monitor;
let result = null;
if (typeof spec.item === "object") {
result = spec.item;
} else if (typeof spec.item === "function") {
result = spec.item(monitor);
} else {
result = {};
}
return result !== null && result !== void 0 ? result : null;
}
canDrag() {
const spec = this.spec;
const monitor = this.monitor;
if (typeof spec.canDrag === "boolean") {
return spec.canDrag;
} else if (typeof spec.canDrag === "function") {
return spec.canDrag(monitor);
} else {
return true;
}
}
isDragging(globalMonitor, target) {
const spec = this.spec;
const monitor = this.monitor;
const { isDragging } = spec;
return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId();
}
endDrag() {
const spec = this.spec;
const monitor = this.monitor;
const connector = this.connector;
const { end: end2 } = spec;
if (end2) {
end2(monitor.getItem(), monitor);
}
connector.reconnect();
}
constructor(spec, monitor, connector) {
this.spec = spec;
this.monitor = monitor;
this.connector = connector;
}
}
function useDragSource(spec, monitor, connector) {
const handler = __mf_29(() => new DragSourceImpl(spec, monitor, connector), [
monitor,
connector
]);
__mf_24(() => {
handler.spec = spec;
}, [
spec
]);
return handler;
}
function useDragType(spec) {
return __mf_29(() => {
const result = spec.type;
invariant$2(result != null, "spec.type must be defined");
return result;
}, [
spec
]);
}
function useRegisteredDragSource(spec, monitor, connector) {
const manager = useDragDropManager();
const handler = useDragSource(spec, monitor, connector);
const itemType = useDragType(spec);
useIsomorphicLayoutEffect$2(function registerDragSource() {
if (itemType != null) {
const [handlerId, unregister] = registerSource(itemType, handler, manager);
monitor.receiveHandlerId(handlerId);
connector.receiveHandlerId(handlerId);
return unregister;
}
return;
}, [
manager,
monitor,
connector,
handler,
itemType
]);
}
useDrag = function(specArg, deps) {
const spec = useOptionalFactory(specArg, deps);
invariant$2(!spec.begin, `useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)`);
const monitor = useDragSourceMonitor();
const connector = useDragSourceConnector(spec.options, spec.previewOptions);
useRegisteredDragSource(spec, monitor, connector);
return [
useCollectedProps(spec.collect, monitor, connector),
useConnectDragSource(connector),
useConnectDragPreview(connector)
];
};
function useConnectDropTarget(connector) {
return __mf_29(() => connector.hooks.dropTarget(), [
connector
]);
}
function useDropTargetConnector(options) {
const manager = useDragDropManager();
const connector = __mf_29(() => new TargetConnector(manager.getBackend()), [
manager
]);
useIsomorphicLayoutEffect$2(() => {
connector.dropTargetOptions = options || null;
connector.reconnect();
return () => connector.disconnectDropTarget();
}, [
options
]);
return connector;
}
function useDropTargetMonitor() {
const manager = useDragDropManager();
return __mf_29(() => new DropTargetMonitorImpl(manager), [
manager
]);
}
function useAccept(spec) {
const { accept } = spec;
return __mf_29(() => {
invariant$2(spec.accept != null, "accept must be defined");
return Array.isArray(accept) ? accept : [
accept
];
}, [
accept
]);
}
class DropTargetImpl {
canDrop() {
const spec = this.spec;
const monitor = this.monitor;
return spec.canDrop ? spec.canDrop(monitor.getItem(), monitor) : true;
}
hover() {
const spec = this.spec;
const monitor = this.monitor;
if (spec.hover) {
spec.hover(monitor.getItem(), monitor);
}
}
drop() {
const spec = this.spec;
const monitor = this.monitor;
if (spec.drop) {
return spec.drop(monitor.getItem(), monitor);
}
return;
}
constructor(spec, monitor) {
this.spec = spec;
this.monitor = monitor;
}
}
function useDropTarget(spec, monitor) {
const dropTarget = __mf_29(() => new DropTargetImpl(spec, monitor), [
monitor
]);
__mf_24(() => {
dropTarget.spec = spec;
}, [
spec
]);
return dropTarget;
}
function useRegisteredDropTarget(spec, monitor, connector) {
const manager = useDragDropManager();
const dropTarget = useDropTarget(spec, monitor);
const accept = useAccept(spec);
useIsomorphicLayoutEffect$2(function registerDropTarget() {
const [handlerId, unregister] = registerTarget(accept, dropTarget, manager);
monitor.receiveHandlerId(handlerId);
connector.receiveHandlerId(handlerId);
return unregister;
}, [
manager,
monitor,
dropTarget,
connector,
accept.map((a) => a.toString()).join("|")
]);
}
useDrop = function(specArg, deps) {
const spec = useOptionalFactory(specArg, deps);
const monitor = useDropTargetMonitor();
const connector = useDropTargetConnector(spec.options);
useRegisteredDropTarget(spec, monitor, connector);
return [
useCollectedProps(spec.collect, monitor, connector),
useConnectDropTarget(connector)
];
};
function memoize(fn) {
let result = null;
const memoized = () => {
if (result == null) {
result = fn();
}
return result;
};
return memoized;
}
function without(items, item) {
return items.filter((i) => i !== item);
}
function union(itemsA, itemsB) {
const set = /* @__PURE__ */ new Set();
const insertItem = (item) => set.add(item);
itemsA.forEach(insertItem);
itemsB.forEach(insertItem);
const result = [];
set.forEach((key) => result.push(key));
return result;
}
class EnterLeaveCounter {
enter(enteringNode) {
const previousLength = this.entered.length;
const isNodeEntered = (node) => this.isNodeInDocument(node) && (!node.contains || node.contains(enteringNode));
this.entered = union(this.entered.filter(isNodeEntered), [
enteringNode
]);
return previousLength === 0 && this.entered.length > 0;
}
leave(leavingNode) {
const previousLength = this.entered.length;
this.entered = without(this.entered.filter(this.isNodeInDocument), leavingNode);
return previousLength > 0 && this.entered.length === 0;
}
reset() {
this.entered = [];
}
constructor(isNodeInDocument) {
this.entered = [];
this.isNodeInDocument = isNodeInDocument;
}
}
class NativeDragSource {
initializeExposedProperties() {
Object.keys(this.config.exposeProperties).forEach((property) => {
Object.defineProperty(this.item, property, {
configurable: true,
enumerable: true,
get() {
console.warn(`Browser doesn't allow reading "${property}" until the drop event.`);
return null;
}
});
});
}
loadDataTransfer(dataTransfer) {
if (dataTransfer) {
const newProperties = {};
Object.keys(this.config.exposeProperties).forEach((property) => {
const propertyFn = this.config.exposeProperties[property];
if (propertyFn != null) {
newProperties[property] = {
value: propertyFn(dataTransfer, this.config.matchesTypes),
configurable: true,
enumerable: true
};
}
});
Object.defineProperties(this.item, newProperties);
}
}
canDrag() {
return true;
}
beginDrag() {
return this.item;
}
isDragging(monitor, handle) {
return handle === monitor.getSourceId();
}
endDrag() {
}
constructor(config2) {
this.config = config2;
this.item = {};
this.initializeExposedProperties();
}
}
const FILE = "__NATIVE_FILE__";
const URL = "__NATIVE_URL__";
const TEXT = "__NATIVE_TEXT__";
const HTML = "__NATIVE_HTML__";
const NativeTypes = Object.freeze(Object.defineProperty({
__proto__: null,
FILE,
HTML,
TEXT,
URL
}, Symbol.toStringTag, {
value: "Module"
}));
function getDataFromDataTransfer(dataTransfer, typesToTry, defaultValue) {
const result = typesToTry.reduce((resultSoFar, typeToTry) => resultSoFar || dataTransfer.getData(typeToTry), "");
return result != null ? result : defaultValue;
}
const nativeTypesConfig = {
[FILE]: {
exposeProperties: {
files: (dataTransfer) => Array.prototype.slice.call(dataTransfer.files),
items: (dataTransfer) => dataTransfer.items,
dataTransfer: (dataTransfer) => dataTransfer
},
matchesTypes: [
"Files"
]
},
[HTML]: {
exposeProperties: {
html: (dataTransfer, matchesTypes) => getDataFromDataTransfer(dataTransfer, matchesTypes, ""),
dataTransfer: (dataTransfer) => dataTransfer
},
matchesTypes: [
"Html",
"text/html"
]
},
[URL]: {
exposeProperties: {
urls: (dataTransfer, matchesTypes) => getDataFromDataTransfer(dataTransfer, matchesTypes, "").split("\n"),
dataTransfer: (dataTransfer) => dataTransfer
},
matchesTypes: [
"Url",
"text/uri-list"
]
},
[TEXT]: {
exposeProperties: {
text: (dataTransfer, matchesTypes) => getDataFromDataTransfer(dataTransfer, matchesTypes, ""),
dataTransfer: (dataTransfer) => dataTransfer
},
matchesTypes: [
"Text",
"text/plain"
]
}
};
function createNativeDragSource(type, dataTransfer) {
const config2 = nativeTypesConfig[type];
if (!config2) {
throw new Error(`native type ${type} has no configuration`);
}
const result = new NativeDragSource(config2);
result.loadDataTransfer(dataTransfer);
return result;
}
function matchNativeItemType(dataTransfer) {
if (!dataTransfer) {
return null;
}
const dataTransferTypes = Array.prototype.slice.call(dataTransfer.types || []);
return Object.keys(nativeTypesConfig).filter((nativeItemType) => {
const typeConfig = nativeTypesConfig[nativeItemType];
if (!(typeConfig === null || typeConfig === void 0 ? void 0 : typeConfig.matchesTypes)) {
return false;
}
return typeConfig.matchesTypes.some((t) => dataTransferTypes.indexOf(t) > -1);
})[0] || null;
}
const isFirefox = memoize(() => /firefox/i.test(navigator.userAgent));
const isSafari = memoize(() => Boolean(window.safari));
class MonotonicInterpolant {
interpolate(x2) {
const { xs, ys, c1s, c2s, c3s } = this;
let i = xs.length - 1;
if (x2 === xs[i]) {
return ys[i];
}
let low = 0;
let high = c3s.length - 1;
let mid;
while (low <= high) {
mid = Math.floor(0.5 * (low + high));
const xHere = xs[mid];
if (xHere < x2) {
low = mid + 1;
} else if (xHere > x2) {
high = mid - 1;
} else {
return ys[mid];
}
}
i = Math.max(0, high);
const diff = x2 - xs[i];
const diffSq = diff * diff;
return ys[i] + c1s[i] * diff + c2s[i] * diffSq + c3s[i] * diff * diffSq;
}
constructor(xs, ys) {
const { length } = xs;
const indexes = [];
for (let i = 0; i < length; i++) {
indexes.push(i);
}
indexes.sort((a, b2) => xs[a] < xs[b2] ? -1 : 1);
const dxs = [];
const ms = [];
let dx;
let dy;
for (let i1 = 0; i1 < length - 1; i1++) {
dx = xs[i1 + 1] - xs[i1];
dy = ys[i1 + 1] - ys[i1];
dxs.push(dx);
ms.push(dy / dx);
}
const c1s = [
ms[0]
];
for (let i2 = 0; i2 < dxs.length - 1; i2++) {
const m22 = ms[i2];
const mNext = ms[i2 + 1];
if (m22 * mNext <= 0) {
c1s.push(0);
} else {
dx = dxs[i2];
const dxNext = dxs[i2 + 1];
const common = dx + dxNext;
c1s.push(3 * common / ((common + dxNext) / m22 + (common + dx) / mNext));
}
}
c1s.push(ms[ms.length - 1]);
const c2s = [];
const c3s = [];
let m2;
for (let i3 = 0; i3 < c1s.length - 1; i3++) {
m2 = ms[i3];
const c1 = c1s[i3];
const invDx = 1 / dxs[i3];
const common = c1 + c1s[i3 + 1] - m2 - m2;
c2s.push((m2 - c1 - common) * invDx);
c3s.push(common * invDx * invDx);
}
this.xs = xs;
this.ys = ys;
this.c1s = c1s;
this.c2s = c2s;
this.c3s = c3s;
}
}
const ELEMENT_NODE = 1;
function getNodeClientOffset(node) {
const el = node.nodeType === ELEMENT_NODE ? node : node.parentElement;
if (!el) {
return null;
}
const { top, left } = el.getBoundingClientRect();
return {
x: left,
y: top
};
}
function getEventClientOffset(e2) {
return {
x: e2.clientX,
y: e2.clientY
};
}
function isImageNode(node) {
var ref;
return node.nodeName === "IMG" && (isFirefox() || !((ref = document.documentElement) === null || ref === void 0 ? void 0 : ref.contains(node)));
}
function getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight) {
let dragPreviewWidth = isImage ? dragPreview.width : sourceWidth;
let dragPreviewHeight = isImage ? dragPreview.height : sourceHeight;
if (isSafari() && isImage) {
dragPreviewHeight /= window.devicePixelRatio;
dragPreviewWidth /= window.devicePixelRatio;
}
return {
dragPreviewWidth,
dragPreviewHeight
};
}
function getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint) {
const isImage = isImageNode(dragPreview);
const dragPreviewNode = isImage ? sourceNode : dragPreview;
const dragPreviewNodeOffsetFromClient = getNodeClientOffset(dragPreviewNode);
const offsetFromDragPreview = {
x: clientOffset.x - dragPreviewNodeOffsetFromClient.x,
y: clientOffset.y - dragPreviewNodeOffsetFromClient.y
};
const { offsetWidth: sourceWidth, offsetHeight: sourceHeight } = sourceNode;
const { anchorX, anchorY } = anchorPoint;
const { dragPreviewWidth, dragPreviewHeight } = getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight);
const calculateYOffset = () => {
const interpolantY = new MonotonicInterpolant([
0,
0.5,
1
], [
offsetFromDragPreview.y,
offsetFromDragPreview.y / sourceHeight * dragPreviewHeight,
offsetFromDragPreview.y + dragPreviewHeight - sourceHeight
]);
let y2 = interpolantY.interpolate(anchorY);
if (isSafari() && isImage) {
y2 += (window.devicePixelRatio - 1) * dragPreviewHeight;
}
return y2;
};
const calculateXOffset = () => {
const interpolantX = new MonotonicInterpolant([
0,
0.5,
1
], [
offsetFromDragPreview.x,
offsetFromDragPreview.x / sourceWidth * dragPreviewWidth,
offsetFromDragPreview.x + dragPreviewWidth - sourceWidth
]);
return interpolantX.interpolate(anchorX);
};
const { offsetX, offsetY } = offsetPoint;
const isManualOffsetX = offsetX === 0 || offsetX;
const isManualOffsetY = offsetY === 0 || offsetY;
return {
x: isManualOffsetX ? offsetX : calculateXOffset(),
y: isManualOffsetY ? offsetY : calculateYOffset()
};
}
class OptionsReader {
get window() {
if (this.globalContext) {
return this.globalContext;
} else if (typeof window !== "undefined") {
return window;
}
return void 0;
}
get document() {
var ref;
if ((ref = this.globalContext) === null || ref === void 0 ? void 0 : ref.document) {
return this.globalContext.document;
} else if (this.window) {
return this.window.document;
} else {
return void 0;
}
}
get rootElement() {
var ref;
return ((ref = this.optionsArgs) === null || ref === void 0 ? void 0 : ref.rootElement) || this.window;
}
constructor(globalContext, options) {
this.ownerDocument = null;
this.globalContext = globalContext;
this.optionsArgs = options;
}
}
function _defineProperty$3(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread$3(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys2 = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys2.forEach(function(key) {
_defineProperty$3(target, key, source[key]);
});
}
return target;
}
class HTML5BackendImpl {
profile() {
var ref, ref1;
return {
sourcePreviewNodes: this.sourcePreviewNodes.size,
sourcePreviewNodeOptions: this.sourcePreviewNodeOptions.size,
sourceNodeOptions: this.sourceNodeOptions.size,
sourceNodes: this.sourceNodes.size,
dragStartSourceIds: ((ref = this.dragStartSourceIds) === null || ref === void 0 ? void 0 : ref.length) || 0,
dropTargetIds: this.dropTargetIds.length,
dragEnterTargetIds: this.dragEnterTargetIds.length,
dragOverTargetIds: ((ref1 = this.dragOverTargetIds) === null || ref1 === void 0 ? void 0 : ref1.length) || 0
};
}
get window() {
return this.options.window;
}
get document() {
return this.options.document;
}
get rootElement() {
return this.options.rootElement;
}
setup() {
const root = this.rootElement;
if (root === void 0) {
return;
}
if (root.__isReactDndBackendSetUp) {
throw new Error("Cannot have two HTML5 backends at the same time.");
}
root.__isReactDndBackendSetUp = true;
this.addEventListeners(root);
}
teardown() {
const root = this.rootElement;
if (root === void 0) {
return;
}
root.__isReactDndBackendSetUp = false;
this.removeEventListeners(this.rootElement);
this.clearCurrentDragSourceNode();
if (this.asyncEndDragFrameId) {
var ref;
(ref = this.window) === null || ref === void 0 ? void 0 : ref.cancelAnimationFrame(this.asyncEndDragFrameId);
}
}
connectDragPreview(sourceId, node, options) {
this.sourcePreviewNodeOptions.set(sourceId, options);
this.sourcePreviewNodes.set(sourceId, node);
return () => {
this.sourcePreviewNodes.delete(sourceId);
this.sourcePreviewNodeOptions.delete(sourceId);
};
}
connectDragSource(sourceId, node, options) {
this.sourceNodes.set(sourceId, node);
this.sourceNodeOptions.set(sourceId, options);
const handleDragStart = (e2) => this.handleDragStart(e2, sourceId);
const handleSelectStart = (e2) => this.handleSelectStart(e2);
node.setAttribute("draggable", "true");
node.addEventListener("dragstart", handleDragStart);
node.addEventListener("selectstart", handleSelectStart);
return () => {
this.sourceNodes.delete(sourceId);
this.sourceNodeOptions.delete(sourceId);
node.removeEventListener("dragstart", handleDragStart);
node.removeEventListener("selectstart", handleSelectStart);
node.setAttribute("draggable", "false");
};
}
connectDropTarget(targetId, node) {
const handleDragEnter = (e2) => this.handleDragEnter(e2, targetId);
const handleDragOver = (e2) => this.handleDragOver(e2, targetId);
const handleDrop = (e2) => this.handleDrop(e2, targetId);
node.addEventListener("dragenter", handleDragEnter);
node.addEventListener("dragover", handleDragOver);
node.addEventListener("drop", handleDrop);
return () => {
node.removeEventListener("dragenter", handleDragEnter);
node.removeEventListener("dragover", handleDragOver);
node.removeEventListener("drop", handleDrop);
};
}
addEventListeners(target) {
if (!target.addEventListener) {
return;
}
target.addEventListener("dragstart", this.handleTopDragStart);
target.addEventListener("dragstart", this.handleTopDragStartCapture, true);
target.addEventListener("dragend", this.handleTopDragEndCapture, true);
target.addEventListener("dragenter", this.handleTopDragEnter);
target.addEventListener("dragenter", this.handleTopDragEnterCapture, true);
target.addEventListener("dragleave", this.handleTopDragLeaveCapture, true);
target.addEventListener("dragover", this.handleTopDragOver);
target.addEventListener("dragover", this.handleTopDragOverCapture, true);
target.addEventListener("drop", this.handleTopDrop);
target.addEventListener("drop", this.handleTopDropCapture, true);
}
removeEventListeners(target) {
if (!target.removeEventListener) {
return;
}
target.removeEventListener("dragstart", this.handleTopDragStart);
target.removeEventListener("dragstart", this.handleTopDragStartCapture, true);
target.removeEventListener("dragend", this.handleTopDragEndCapture, true);
target.removeEventListener("dragenter", this.handleTopDragEnter);
target.removeEventListener("dragenter", this.handleTopDragEnterCapture, true);
target.removeEventListener("dragleave", this.handleTopDragLeaveCapture, true);
target.removeEventListener("dragover", this.handleTopDragOver);
target.removeEventListener("dragover", this.handleTopDragOverCapture, true);
target.removeEventListener("drop", this.handleTopDrop);
target.removeEventListener("drop", this.handleTopDropCapture, true);
}
getCurrentSourceNodeOptions() {
const sourceId = this.monitor.getSourceId();
const sourceNodeOptions = this.sourceNodeOptions.get(sourceId);
return _objectSpread$3({
dropEffect: this.altKeyPressed ? "copy" : "move"
}, sourceNodeOptions || {});
}
getCurrentDropEffect() {
if (this.isDraggingNativeItem()) {
return "copy";
}
return this.getCurrentSourceNodeOptions().dropEffect;
}
getCurrentSourcePreviewNodeOptions() {
const sourceId = this.monitor.getSourceId();
const sourcePreviewNodeOptions = this.sourcePreviewNodeOptions.get(sourceId);
return _objectSpread$3({
anchorX: 0.5,
anchorY: 0.5,
captureDraggingState: false
}, sourcePreviewNodeOptions || {});
}
isDraggingNativeItem() {
const itemType = this.monitor.getItemType();
return Object.keys(NativeTypes).some((key) => NativeTypes[key] === itemType);
}
beginDragNativeItem(type, dataTransfer) {
this.clearCurrentDragSourceNode();
this.currentNativeSource = createNativeDragSource(type, dataTransfer);
this.currentNativeHandle = this.registry.addSource(type, this.currentNativeSource);
this.actions.beginDrag([
this.currentNativeHandle
]);
}
setCurrentDragSourceNode(node) {
this.clearCurrentDragSourceNode();
this.currentDragSourceNode = node;
const MOUSE_MOVE_TIMEOUT = 1e3;
this.mouseMoveTimeoutTimer = setTimeout(() => {
var ref;
return (ref = this.rootElement) === null || ref === void 0 ? void 0 : ref.addEventListener("mousemove", this.endDragIfSourceWasRemovedFromDOM, true);
}, MOUSE_MOVE_TIMEOUT);
}
clearCurrentDragSourceNode() {
if (this.currentDragSourceNode) {
this.currentDragSourceNode = null;
if (this.rootElement) {
var ref;
(ref = this.window) === null || ref === void 0 ? void 0 : ref.clearTimeout(this.mouseMoveTimeoutTimer || void 0);
this.rootElement.removeEventListener("mousemove", this.endDragIfSourceWasRemovedFromDOM, true);
}
this.mouseMoveTimeoutTimer = null;
return true;
}
return false;
}
handleDragStart(e2, sourceId) {
if (e2.defaultPrevented) {
return;
}
if (!this.dragStartSourceIds) {
this.dragStartSourceIds = [];
}
this.dragStartSourceIds.unshift(sourceId);
}
handleDragEnter(_e, targetId) {
this.dragEnterTargetIds.unshift(targetId);
}
handleDragOver(_e, targetId) {
if (this.dragOverTargetIds === null) {
this.dragOverTargetIds = [];
}
this.dragOverTargetIds.unshift(targetId);
}
handleDrop(_e, targetId) {
this.dropTargetIds.unshift(targetId);
}
constructor(manager, globalContext, options) {
this.sourcePreviewNodes = /* @__PURE__ */ new Map();
this.sourcePreviewNodeOptions = /* @__PURE__ */ new Map();
this.sourceNodes = /* @__PURE__ */ new Map();
this.sourceNodeOptions = /* @__PURE__ */ new Map();
this.dragStartSourceIds = null;
this.dropTargetIds = [];
this.dragEnterTargetIds = [];
this.currentNativeSource = null;
this.currentNativeHandle = null;
this.currentDragSourceNode = null;
this.altKeyPressed = false;
this.mouseMoveTimeoutTimer = null;
this.asyncEndDragFrameId = null;
this.dragOverTargetIds = null;
this.lastClientOffset = null;
this.hoverRafId = null;
this.getSourceClientOffset = (sourceId) => {
const source = this.sourceNodes.get(sourceId);
return source && getNodeClientOffset(source) || null;
};
this.endDragNativeItem = () => {
if (!this.isDraggingNativeItem()) {
return;
}
this.actions.endDrag();
if (this.currentNativeHandle) {
this.registry.removeSource(this.currentNativeHandle);
}
this.currentNativeHandle = null;
this.currentNativeSource = null;
};
this.isNodeInDocument = (node) => {
return Boolean(node && this.document && this.document.body && this.document.body.contains(node));
};
this.endDragIfSourceWasRemovedFromDOM = () => {
const node = this.currentDragSourceNode;
if (node == null || this.isNodeInDocument(node)) {
return;
}
if (this.clearCurrentDragSourceNode() && this.monitor.isDragging()) {
this.actions.endDrag();
}
this.cancelHover();
};
this.scheduleHover = (dragOverTargetIds) => {
if (this.hoverRafId === null && typeof requestAnimationFrame !== "undefined") {
this.hoverRafId = requestAnimationFrame(() => {
if (this.monitor.isDragging()) {
this.actions.hover(dragOverTargetIds || [], {
clientOffset: this.lastClientOffset
});
}
this.hoverRafId = null;
});
}
};
this.cancelHover = () => {
if (this.hoverRafId !== null && typeof cancelAnimationFrame !== "undefined") {
cancelAnimationFrame(this.hoverRafId);
this.hoverRafId = null;
}
};
this.handleTopDragStartCapture = () => {
this.clearCurrentDragSourceNode();
this.dragStartSourceIds = [];
};
this.handleTopDragStart = (e2) => {
if (e2.defaultPrevented) {
return;
}
const { dragStartSourceIds } = this;
this.dragStartSourceIds = null;
const clientOffset = getEventClientOffset(e2);
if (this.monitor.isDragging()) {
this.actions.endDrag();
this.cancelHover();
}
this.actions.beginDrag(dragStartSourceIds || [], {
publishSource: false,
getSourceClientOffset: this.getSourceClientOffset,
clientOffset
});
const { dataTransfer } = e2;
const nativeType = matchNativeItemType(dataTransfer);
if (this.monitor.isDragging()) {
if (dataTransfer && typeof dataTransfer.setDragImage === "function") {
const sourceId = this.monitor.getSourceId();
const sourceNode = this.sourceNodes.get(sourceId);
const dragPreview = this.sourcePreviewNodes.get(sourceId) || sourceNode;
if (dragPreview) {
const { anchorX, anchorY, offsetX, offsetY } = this.getCurrentSourcePreviewNodeOptions();
const anchorPoint = {
anchorX,
anchorY
};
const offsetPoint = {
offsetX,
offsetY
};
const dragPreviewOffset = getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint);
dataTransfer.setDragImage(dragPreview, dragPreviewOffset.x, dragPreviewOffset.y);
}
}
try {
dataTransfer === null || dataTransfer === void 0 ? void 0 : dataTransfer.setData("application/json", {});
} catch (err) {
}
this.setCurrentDragSourceNode(e2.target);
const { captureDraggingState } = this.getCurrentSourcePreviewNodeOptions();
if (!captureDraggingState) {
setTimeout(() => this.actions.publishDragSource(), 0);
} else {
this.actions.publishDragSource();
}
} else if (nativeType) {
this.beginDragNativeItem(nativeType);
} else if (dataTransfer && !dataTransfer.types && (e2.target && !e2.target.hasAttribute || !e2.target.hasAttribute("draggable"))) {
return;
} else {
e2.preventDefault();
}
};
this.handleTopDragEndCapture = () => {
if (this.clearCurrentDragSourceNode() && this.monitor.isDragging()) {
this.actions.endDrag();
}
this.cancelHover();
};
this.handleTopDragEnterCapture = (e2) => {
this.dragEnterTargetIds = [];
if (this.isDraggingNativeItem()) {
var ref;
(ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e2.dataTransfer);
}
const isFirstEnter = this.enterLeaveCounter.enter(e2.target);
if (!isFirstEnter || this.monitor.isDragging()) {
return;
}
const { dataTransfer } = e2;
const nativeType = matchNativeItemType(dataTransfer);
if (nativeType) {
this.beginDragNativeItem(nativeType, dataTransfer);
}
};
this.handleTopDragEnter = (e2) => {
const { dragEnterTargetIds } = this;
this.dragEnterTargetIds = [];
if (!this.monitor.isDragging()) {
return;
}
this.altKeyPressed = e2.altKey;
if (dragEnterTargetIds.length > 0) {
this.actions.hover(dragEnterTargetIds, {
clientOffset: getEventClientOffset(e2)
});
}
const canDrop = dragEnterTargetIds.some((targetId) => this.monitor.canDropOnTarget(targetId));
if (canDrop) {
e2.preventDefault();
if (e2.dataTransfer) {
e2.dataTransfer.dropEffect = this.getCurrentDropEffect();
}
}
};
this.handleTopDragOverCapture = (e2) => {
this.dragOverTargetIds = [];
if (this.isDraggingNativeItem()) {
var ref;
(ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e2.dataTransfer);
}
};
this.handleTopDragOver = (e2) => {
const { dragOverTargetIds } = this;
this.dragOverTargetIds = [];
if (!this.monitor.isDragging()) {
e2.preventDefault();
if (e2.dataTransfer) {
e2.dataTransfer.dropEffect = "none";
}
return;
}
this.altKeyPressed = e2.altKey;
this.lastClientOffset = getEventClientOffset(e2);
this.scheduleHover(dragOverTargetIds);
const canDrop = (dragOverTargetIds || []).some((targetId) => this.monitor.canDropOnTarget(targetId));
if (canDrop) {
e2.preventDefault();
if (e2.dataTransfer) {
e2.dataTransfer.dropEffect = this.getCurrentDropEffect();
}
} else if (this.isDraggingNativeItem()) {
e2.preventDefault();
} else {
e2.preventDefault();
if (e2.dataTransfer) {
e2.dataTransfer.dropEffect = "none";
}
}
};
this.handleTopDragLeaveCapture = (e2) => {
if (this.isDraggingNativeItem()) {
e2.preventDefault();
}
const isLastLeave = this.enterLeaveCounter.leave(e2.target);
if (!isLastLeave) {
return;
}
if (this.isDraggingNativeItem()) {
setTimeout(() => this.endDragNativeItem(), 0);
}
this.cancelHover();
};
this.handleTopDropCapture = (e2) => {
this.dropTargetIds = [];
if (this.isDraggingNativeItem()) {
var ref;
e2.preventDefault();
(ref = this.currentNativeSource) === null || ref === void 0 ? void 0 : ref.loadDataTransfer(e2.dataTransfer);
} else if (matchNativeItemType(e2.dataTransfer)) {
e2.preventDefault();
}
this.enterLeaveCounter.reset();
};
this.handleTopDrop = (e2) => {
const { dropTargetIds } = this;
this.dropTargetIds = [];
this.actions.hover(dropTargetIds, {
clientOffset: getEventClientOffset(e2)
});
this.actions.drop({
dropEffect: this.getCurrentDropEffect()
});
if (this.isDraggingNativeItem()) {
this.endDragNativeItem();
} else if (this.monitor.isDragging()) {
this.actions.endDrag();
}
this.cancelHover();
};
this.handleSelectStart = (e2) => {
const target = e2.target;
if (typeof target.dragDrop !== "function") {
return;
}
if (target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable) {
return;
}
e2.preventDefault();
target.dragDrop();
};
this.options = new OptionsReader(globalContext, options);
this.actions = manager.getActions();
this.monitor = manager.getMonitor();
this.registry = manager.getRegistry();
this.enterLeaveCounter = new EnterLeaveCounter(this.isNodeInDocument);
}
}
HTML5Backend = function createBackend(manager, context, options) {
return new HTML5BackendImpl(manager, context, options);
};
var reactIs = {
exports: {}
};
var reactIs_production_min = {};
var b = 60103, c = 60106, d = 60107, e = 60108, f = 60114, g = 60109, h = 60110, k = 60112, l = 60113, m = 60120, n = 60115, p = 60116, q = 60121, r = 60122, u = 60117, v = 60129, w = 60131;
if ("function" === typeof Symbol && Symbol.for) {
var x = Symbol.for;
b = x("react.element");
c = x("react.portal");
d = x("react.fragment");
e = x("react.strict_mode");
f = x("react.profiler");
g = x("react.provider");
h = x("react.context");
k = x("react.forward_ref");
l = x("react.suspense");
m = x("react.suspense_list");
n = x("react.memo");
p = x("react.lazy");
q = x("react.block");
r = x("react.server.block");
u = x("react.fundamental");
v = x("react.debug_trace_mode");
w = x("react.legacy_hidden");
}
function y(a) {
if ("object" === typeof a && null !== a) {
var t = a.$$typeof;
switch (t) {
case b:
switch (a = a.type, a) {
case d:
case f:
case e:
case l:
case m:
return a;
default:
switch (a = a && a.$$typeof, a) {
case h:
case k:
case p:
case n:
case g:
return a;
default:
return t;
}
}
case c:
return t;
}
}
}
var z = g, A = b, B = k, C = d, D = p, E = n, F = c, G = f, H = e, I = l;
reactIs_production_min.ContextConsumer = h;
reactIs_production_min.ContextProvider = z;
reactIs_production_min.Element = A;
reactIs_production_min.ForwardRef = B;
reactIs_production_min.Fragment = C;
reactIs_production_min.Lazy = D;
reactIs_production_min.Memo = E;
reactIs_production_min.Portal = F;
reactIs_production_min.Profiler = G;
reactIs_production_min.StrictMode = H;
reactIs_production_min.Suspense = I;
reactIs_production_min.isAsyncMode = function() {
return false;
};
reactIs_production_min.isConcurrentMode = function() {
return false;
};
reactIs_production_min.isContextConsumer = function(a) {
return y(a) === h;
};
reactIs_production_min.isContextProvider = function(a) {
return y(a) === g;
};
reactIs_production_min.isElement = function(a) {
return "object" === typeof a && null !== a && a.$$typeof === b;
};
reactIs_production_min.isForwardRef = function(a) {
return y(a) === k;
};
reactIs_production_min.isFragment = function(a) {
return y(a) === d;
};
reactIs_production_min.isLazy = function(a) {
return y(a) === p;
};
reactIs_production_min.isMemo = function(a) {
return y(a) === n;
};
reactIs_production_min.isPortal = function(a) {
return y(a) === c;
};
reactIs_production_min.isProfiler = function(a) {
return y(a) === f;
};
reactIs_production_min.isStrictMode = function(a) {
return y(a) === e;
};
reactIs_production_min.isSuspense = function(a) {
return y(a) === l;
};
reactIs_production_min.isValidElementType = function(a) {
return "string" === typeof a || "function" === typeof a || a === d || a === f || a === v || a === e || a === l || a === m || a === w || "object" === typeof a && null !== a && (a.$$typeof === p || a.$$typeof === n || a.$$typeof === g || a.$$typeof === h || a.$$typeof === k || a.$$typeof === u || a.$$typeof === q || a[0] === r) ? true : false;
};
reactIs_production_min.typeOf = y;
{
reactIs.exports = reactIs_production_min;
}
reactIsExports = reactIs.exports;
commonStyles = {
backgroundClass: {
display: "flex",
alignItems: "center"
},
backgroundClassSquare: {
width: 40,
height: 40,
display: "inline-block",
marginRight: 4
},
selected: (theme) => ({
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText
}),
clearPadding: {
p: 0,
mt: 0,
mb: 0,
ml: 0,
mr: 0,
minHeight: "initial"
},
fieldContent: {
fontSize: "80%",
"& svg": {
fontSize: "1rem"
}
},
fieldContentColor: {
"& label": {
display: "none"
},
"& input": {
fontSize: "80%"
}
},
fieldContentSlider: {
display: "inline",
width: "calc(100% - 50px)",
marginRight: 8
},
fieldContentSliderInput: {
display: "inline",
width: 50
},
menuItem: {
cursor: "pointer"
},
listFolder: {
backgroundColor: "inherit",
lineHeight: "36px"
},
iconFolder: {
verticalAlign: "middle",
marginRight: 6,
marginTop: -3,
fontSize: 20,
color: "#00dc00"
},
iconPreview: {}
};
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e2) {
reject(e2);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e2) {
reject(e2);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
var e2 = new Error(message);
return e2.name = "SuppressedError", e2.error = error, e2.suppressed = suppressed, e2;
};
const COMMON_MIME_TYPES = /* @__PURE__ */ new Map([
[
"1km",
"application/vnd.1000minds.decision-model+xml"
],
[
"3dml",
"text/vnd.in3d.3dml"
],
[
"3ds",
"image/x-3ds"
],
[
"3g2",
"video/3gpp2"
],
[
"3gp",
"video/3gp"
],
[
"3gpp",
"video/3gpp"
],
[
"3mf",
"model/3mf"
],
[
"7z",
"application/x-7z-compressed"
],
[
"7zip",
"application/x-7z-compressed"
],
[
"123",
"application/vnd.lotus-1-2-3"
],
[
"aab",
"application/x-authorware-bin"
],
[
"aac",
"audio/x-acc"
],
[
"aam",
"application/x-authorware-map"
],
[
"aas",
"application/x-authorware-seg"
],
[
"abw",
"application/x-abiword"
],
[
"ac",
"application/vnd.nokia.n-gage.ac+xml"
],
[
"ac3",
"audio/ac3"
],
[
"acc",
"application/vnd.americandynamics.acc"
],
[
"ace",
"application/x-ace-compressed"
],
[
"acu",
"application/vnd.acucobol"
],
[
"acutc",
"application/vnd.acucorp"
],
[
"adp",
"audio/adpcm"
],
[
"aep",
"application/vnd.audiograph"
],
[
"afm",
"application/x-font-type1"
],
[
"afp",
"application/vnd.ibm.modcap"
],
[
"ahead",
"application/vnd.ahead.space"
],
[
"ai",
"application/pdf"
],
[
"aif",
"audio/x-aiff"
],
[
"aifc",
"audio/x-aiff"
],
[
"aiff",
"audio/x-aiff"
],
[
"air",
"application/vnd.adobe.air-application-installer-package+zip"
],
[
"ait",
"application/vnd.dvb.ait"
],
[
"ami",
"application/vnd.amiga.ami"
],
[
"amr",
"audio/amr"
],
[
"apk",
"application/vnd.android.package-archive"
],
[
"apng",
"image/apng"
],
[
"appcache",
"text/cache-manifest"
],
[
"application",
"application/x-ms-application"
],
[
"apr",
"application/vnd.lotus-approach"
],
[
"arc",
"application/x-freearc"
],
[
"arj",
"application/x-arj"
],
[
"asc",
"application/pgp-signature"
],
[
"asf",
"video/x-ms-asf"
],
[
"asm",
"text/x-asm"
],
[
"aso",
"application/vnd.accpac.simply.aso"
],
[
"asx",
"video/x-ms-asf"
],
[
"atc",
"application/vnd.acucorp"
],
[
"atom",
"application/atom+xml"
],
[
"atomcat",
"application/atomcat+xml"
],
[
"atomdeleted",
"application/atomdeleted+xml"
],
[
"atomsvc",
"application/atomsvc+xml"
],
[
"atx",
"application/vnd.antix.game-component"
],
[
"au",
"audio/x-au"
],
[
"avi",
"video/x-msvideo"
],
[
"avif",
"image/avif"
],
[
"aw",
"application/applixware"
],
[
"azf",
"application/vnd.airzip.filesecure.azf"
],
[
"azs",
"application/vnd.airzip.filesecure.azs"
],
[
"azv",
"image/vnd.airzip.accelerator.azv"
],
[
"azw",
"application/vnd.amazon.ebook"
],
[
"b16",
"image/vnd.pco.b16"
],
[
"bat",
"application/x-msdownload"
],
[
"bcpio",
"application/x-bcpio"
],
[
"bdf",
"application/x-font-bdf"
],
[
"bdm",
"application/vnd.syncml.dm+wbxml"
],
[
"bdoc",
"application/x-bdoc"
],
[
"bed",
"application/vnd.realvnc.bed"
],
[
"bh2",
"application/vnd.fujitsu.oasysprs"
],
[
"bin",
"application/octet-stream"
],
[
"blb",
"application/x-blorb"
],
[
"blorb",
"application/x-blorb"
],
[
"bmi",
"application/vnd.bmi"
],
[
"bmml",
"application/vnd.balsamiq.bmml+xml"
],
[
"bmp",
"image/bmp"
],
[
"book",
"application/vnd.framemaker"
],
[
"box",
"application/vnd.previewsystems.box"
],
[
"boz",
"application/x-bzip2"
],
[
"bpk",
"application/octet-stream"
],
[
"bpmn",
"application/octet-stream"
],
[
"bsp",
"model/vnd.valve.source.compiled-map"
],
[
"btif",
"image/prs.btif"
],
[
"buffer",
"application/octet-stream"
],
[
"bz",
"application/x-bzip"
],
[
"bz2",
"application/x-bzip2"
],
[
"c",
"text/x-c"
],
[
"c4d",
"application/vnd.clonk.c4group"
],
[
"c4f",
"application/vnd.clonk.c4group"
],
[
"c4g",
"application/vnd.clonk.c4group"
],
[
"c4p",
"application/vnd.clonk.c4group"
],
[
"c4u",
"application/vnd.clonk.c4group"
],
[
"c11amc",
"application/vnd.cluetrust.cartomobile-config"
],
[
"c11amz",
"application/vnd.cluetrust.cartomobile-config-pkg"
],
[
"cab",
"application/vnd.ms-cab-compressed"
],
[
"caf",
"audio/x-caf"
],
[
"cap",
"application/vnd.tcpdump.pcap"
],
[
"car",
"application/vnd.curl.car"
],
[
"cat",
"application/vnd.ms-pki.seccat"
],
[
"cb7",
"application/x-cbr"
],
[
"cba",
"application/x-cbr"
],
[
"cbr",
"application/x-cbr"
],
[
"cbt",
"application/x-cbr"
],
[
"cbz",
"application/x-cbr"
],
[
"cc",
"text/x-c"
],
[
"cco",
"application/x-cocoa"
],
[
"cct",
"application/x-director"
],
[
"ccxml",
"application/ccxml+xml"
],
[
"cdbcmsg",
"application/vnd.contact.cmsg"
],
[
"cda",
"application/x-cdf"
],
[
"cdf",
"application/x-netcdf"
],
[
"cdfx",
"application/cdfx+xml"
],
[
"cdkey",
"application/vnd.mediastation.cdkey"
],
[
"cdmia",
"application/cdmi-capability"
],
[
"cdmic",
"application/cdmi-container"
],
[
"cdmid",
"application/cdmi-domain"
],
[
"cdmio",
"application/cdmi-object"
],
[
"cdmiq",
"application/cdmi-queue"
],
[
"cdr",
"application/cdr"
],
[
"cdx",
"chemical/x-cdx"
],
[
"cdxml",
"application/vnd.chemdraw+xml"
],
[
"cdy",
"application/vnd.cinderella"
],
[
"cer",
"application/pkix-cert"
],
[
"cfs",
"application/x-cfs-compressed"
],
[
"cgm",
"image/cgm"
],
[
"chat",
"application/x-chat"
],
[
"chm",
"application/vnd.ms-htmlhelp"
],
[
"chrt",
"application/vnd.kde.kchart"
],
[
"cif",
"chemical/x-cif"
],
[
"cii",
"application/vnd.anser-web-certificate-issue-initiation"
],
[
"cil",
"application/vnd.ms-artgalry"
],
[
"cjs",
"application/node"
],
[
"cla",
"application/vnd.claymore"
],
[
"class",
"application/octet-stream"
],
[
"clkk",
"application/vnd.crick.clicker.keyboard"
],
[
"clkp",
"application/vnd.crick.clicker.palette"
],
[
"clkt",
"application/vnd.crick.clicker.template"
],
[
"clkw",
"application/vnd.crick.clicker.wordbank"
],
[
"clkx",
"application/vnd.crick.clicker"
],
[
"clp",
"application/x-msclip"
],
[
"cmc",
"application/vnd.cosmocaller"
],
[
"cmdf",
"chemical/x-cmdf"
],
[
"cml",
"chemical/x-cml"
],
[
"cmp",
"application/vnd.yellowriver-custom-menu"
],
[
"cmx",
"image/x-cmx"
],
[
"cod",
"application/vnd.rim.cod"
],
[
"coffee",
"text/coffeescript"
],
[
"com",
"application/x-msdownload"
],
[
"conf",
"text/plain"
],
[
"cpio",
"application/x-cpio"
],
[
"cpp",
"text/x-c"
],
[
"cpt",
"application/mac-compactpro"
],
[
"crd",
"application/x-mscardfile"
],
[
"crl",
"application/pkix-crl"
],
[
"crt",
"application/x-x509-ca-cert"
],
[
"crx",
"application/x-chrome-extension"
],
[
"cryptonote",
"application/vnd.rig.cryptonote"
],
[
"csh",
"application/x-csh"
],
[
"csl",
"application/vnd.citationstyles.style+xml"
],
[
"csml",
"chemical/x-csml"
],
[
"csp",
"application/vnd.commonspace"
],
[
"csr",
"application/octet-stream"
],
[
"css",
"text/css"
],
[
"cst",
"application/x-director"
],
[
"csv",
"text/csv"
],
[
"cu",
"application/cu-seeme"
],
[
"curl",
"text/vnd.curl"
],
[
"cww",
"application/prs.cww"
],
[
"cxt",
"application/x-director"
],
[
"cxx",
"text/x-c"
],
[
"dae",
"model/vnd.collada+xml"
],
[
"daf",
"application/vnd.mobius.daf"
],
[
"dart",
"application/vnd.dart"
],
[
"dataless",
"application/vnd.fdsn.seed"
],
[
"davmount",
"application/davmount+xml"
],
[
"dbf",
"application/vnd.dbf"
],
[
"dbk",
"application/docbook+xml"
],
[
"dcr",
"application/x-director"
],
[
"dcurl",
"text/vnd.curl.dcurl"
],
[
"dd2",
"application/vnd.oma.dd2+xml"
],
[
"ddd",
"application/vnd.fujixerox.ddd"
],
[
"ddf",
"application/vnd.syncml.dmddf+xml"
],
[
"dds",
"image/vnd.ms-dds"
],
[
"deb",
"application/x-debian-package"
],
[
"def",
"text/plain"
],
[
"deploy",
"application/octet-stream"
],
[
"der",
"application/x-x509-ca-cert"
],
[
"dfac",
"application/vnd.dreamfactory"
],
[
"dgc",
"application/x-dgc-compressed"
],
[
"dic",
"text/x-c"
],
[
"dir",
"application/x-director"
],
[
"dis",
"application/vnd.mobius.dis"
],
[
"disposition-notification",
"message/disposition-notification"
],
[
"dist",
"application/octet-stream"
],
[
"distz",
"application/octet-stream"
],
[
"djv",
"image/vnd.djvu"
],
[
"djvu",
"image/vnd.djvu"
],
[
"dll",
"application/octet-stream"
],
[
"dmg",
"application/x-apple-diskimage"
],
[
"dmn",
"application/octet-stream"
],
[
"dmp",
"application/vnd.tcpdump.pcap"
],
[
"dms",
"application/octet-stream"
],
[
"dna",
"application/vnd.dna"
],
[
"doc",
"application/msword"
],
[
"docm",
"application/vnd.ms-word.template.macroEnabled.12"
],
[
"docx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
],
[
"dot",
"application/msword"
],
[
"dotm",
"application/vnd.ms-word.template.macroEnabled.12"
],
[
"dotx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.template"
],
[
"dp",
"application/vnd.osgi.dp"
],
[
"dpg",
"application/vnd.dpgraph"
],
[
"dra",
"audio/vnd.dra"
],
[
"drle",
"image/dicom-rle"
],
[
"dsc",
"text/prs.lines.tag"
],
[
"dssc",
"application/dssc+der"
],
[
"dtb",
"application/x-dtbook+xml"
],
[
"dtd",
"application/xml-dtd"
],
[
"dts",
"audio/vnd.dts"
],
[
"dtshd",
"audio/vnd.dts.hd"
],
[
"dump",
"application/octet-stream"
],
[
"dvb",
"video/vnd.dvb.file"
],
[
"dvi",
"application/x-dvi"
],
[
"dwd",
"application/atsc-dwd+xml"
],
[
"dwf",
"model/vnd.dwf"
],
[
"dwg",
"image/vnd.dwg"
],
[
"dxf",
"image/vnd.dxf"
],
[
"dxp",
"application/vnd.spotfire.dxp"
],
[
"dxr",
"application/x-director"
],
[
"ear",
"application/java-archive"
],
[
"ecelp4800",
"audio/vnd.nuera.ecelp4800"
],
[
"ecelp7470",
"audio/vnd.nuera.ecelp7470"
],
[
"ecelp9600",
"audio/vnd.nuera.ecelp9600"
],
[
"ecma",
"application/ecmascript"
],
[
"edm",
"application/vnd.novadigm.edm"
],
[
"edx",
"application/vnd.novadigm.edx"
],
[
"efif",
"application/vnd.picsel"
],
[
"ei6",
"application/vnd.pg.osasli"
],
[
"elc",
"application/octet-stream"
],
[
"emf",
"image/emf"
],
[
"eml",
"message/rfc822"
],
[
"emma",
"application/emma+xml"
],
[
"emotionml",
"application/emotionml+xml"
],
[
"emz",
"application/x-msmetafile"
],
[
"eol",
"audio/vnd.digital-winds"
],
[
"eot",
"application/vnd.ms-fontobject"
],
[
"eps",
"application/postscript"
],
[
"epub",
"application/epub+zip"
],
[
"es",
"application/ecmascript"
],
[
"es3",
"application/vnd.eszigno3+xml"
],
[
"esa",
"application/vnd.osgi.subsystem"
],
[
"esf",
"application/vnd.epson.esf"
],
[
"et3",
"application/vnd.eszigno3+xml"
],
[
"etx",
"text/x-setext"
],
[
"eva",
"application/x-eva"
],
[
"evy",
"application/x-envoy"
],
[
"exe",
"application/octet-stream"
],
[
"exi",
"application/exi"
],
[
"exp",
"application/express"
],
[
"exr",
"image/aces"
],
[
"ext",
"application/vnd.novadigm.ext"
],
[
"ez",
"application/andrew-inset"
],
[
"ez2",
"application/vnd.ezpix-album"
],
[
"ez3",
"application/vnd.ezpix-package"
],
[
"f",
"text/x-fortran"
],
[
"f4v",
"video/mp4"
],
[
"f77",
"text/x-fortran"
],
[
"f90",
"text/x-fortran"
],
[
"fbs",
"image/vnd.fastbidsheet"
],
[
"fcdt",
"application/vnd.adobe.formscentral.fcdt"
],
[
"fcs",
"application/vnd.isac.fcs"
],
[
"fdf",
"application/vnd.fdf"
],
[
"fdt",
"application/fdt+xml"
],
[
"fe_launch",
"application/vnd.denovo.fcselayout-link"
],
[
"fg5",
"application/vnd.fujitsu.oasysgp"
],
[
"fgd",
"application/x-director"
],
[
"fh",
"image/x-freehand"
],
[
"fh4",
"image/x-freehand"
],
[
"fh5",
"image/x-freehand"
],
[
"fh7",
"image/x-freehand"
],
[
"fhc",
"image/x-freehand"
],
[
"fig",
"application/x-xfig"
],
[
"fits",
"image/fits"
],
[
"flac",
"audio/x-flac"
],
[
"fli",
"video/x-fli"
],
[
"flo",
"application/vnd.micrografx.flo"
],
[
"flv",
"video/x-flv"
],
[
"flw",
"application/vnd.kde.kivio"
],
[
"flx",
"text/vnd.fmi.flexstor"
],
[
"fly",
"text/vnd.fly"
],
[
"fm",
"application/vnd.framemaker"
],
[
"fnc",
"application/vnd.frogans.fnc"
],
[
"fo",
"application/vnd.software602.filler.form+xml"
],
[
"for",
"text/x-fortran"
],
[
"fpx",
"image/vnd.fpx"
],
[
"frame",
"application/vnd.framemaker"
],
[
"fsc",
"application/vnd.fsc.weblaunch"
],
[
"fst",
"image/vnd.fst"
],
[
"ftc",
"application/vnd.fluxtime.clip"
],
[
"fti",
"application/vnd.anser-web-funds-transfer-initiation"
],
[
"fvt",
"video/vnd.fvt"
],
[
"fxp",
"application/vnd.adobe.fxp"
],
[
"fxpl",
"application/vnd.adobe.fxp"
],
[
"fzs",
"application/vnd.fuzzysheet"
],
[
"g2w",
"application/vnd.geoplan"
],
[
"g3",
"image/g3fax"
],
[
"g3w",
"application/vnd.geospace"
],
[
"gac",
"application/vnd.groove-account"
],
[
"gam",
"application/x-tads"
],
[
"gbr",
"application/rpki-ghostbusters"
],
[
"gca",
"application/x-gca-compressed"
],
[
"gdl",
"model/vnd.gdl"
],
[
"gdoc",
"application/vnd.google-apps.document"
],
[
"geo",
"application/vnd.dynageo"
],
[
"geojson",
"application/geo+json"
],
[
"gex",
"application/vnd.geometry-explorer"
],
[
"ggb",
"application/vnd.geogebra.file"
],
[
"ggt",
"application/vnd.geogebra.tool"
],
[
"ghf",
"application/vnd.groove-help"
],
[
"gif",
"image/gif"
],
[
"gim",
"application/vnd.groove-identity-message"
],
[
"glb",
"model/gltf-binary"
],
[
"gltf",
"model/gltf+json"
],
[
"gml",
"application/gml+xml"
],
[
"gmx",
"application/vnd.gmx"
],
[
"gnumeric",
"application/x-gnumeric"
],
[
"gpg",
"application/gpg-keys"
],
[
"gph",
"application/vnd.flographit"
],
[
"gpx",
"application/gpx+xml"
],
[
"gqf",
"application/vnd.grafeq"
],
[
"gqs",
"application/vnd.grafeq"
],
[
"gram",
"application/srgs"
],
[
"gramps",
"application/x-gramps-xml"
],
[
"gre",
"application/vnd.geometry-explorer"
],
[
"grv",
"application/vnd.groove-injector"
],
[
"grxml",
"application/srgs+xml"
],
[
"gsf",
"application/x-font-ghostscript"
],
[
"gsheet",
"application/vnd.google-apps.spreadsheet"
],
[
"gslides",
"application/vnd.google-apps.presentation"
],
[
"gtar",
"application/x-gtar"
],
[
"gtm",
"application/vnd.groove-tool-message"
],
[
"gtw",
"model/vnd.gtw"
],
[
"gv",
"text/vnd.graphviz"
],
[
"gxf",
"application/gxf"
],
[
"gxt",
"application/vnd.geonext"
],
[
"gz",
"application/gzip"
],
[
"gzip",
"application/gzip"
],
[
"h",
"text/x-c"
],
[
"h261",
"video/h261"
],
[
"h263",
"video/h263"
],
[
"h264",
"video/h264"
],
[
"hal",
"application/vnd.hal+xml"
],
[
"hbci",
"application/vnd.hbci"
],
[
"hbs",
"text/x-handlebars-template"
],
[
"hdd",
"application/x-virtualbox-hdd"
],
[
"hdf",
"application/x-hdf"
],
[
"heic",
"image/heic"
],
[
"heics",
"image/heic-sequence"
],
[
"heif",
"image/heif"
],
[
"heifs",
"image/heif-sequence"
],
[
"hej2",
"image/hej2k"
],
[
"held",
"application/atsc-held+xml"
],
[
"hh",
"text/x-c"
],
[
"hjson",
"application/hjson"
],
[
"hlp",
"application/winhlp"
],
[
"hpgl",
"application/vnd.hp-hpgl"
],
[
"hpid",
"application/vnd.hp-hpid"
],
[
"hps",
"application/vnd.hp-hps"
],
[
"hqx",
"application/mac-binhex40"
],
[
"hsj2",
"image/hsj2"
],
[
"htc",
"text/x-component"
],
[
"htke",
"application/vnd.kenameaapp"
],
[
"htm",
"text/html"
],
[
"html",
"text/html"
],
[
"hvd",
"application/vnd.yamaha.hv-dic"
],
[
"hvp",
"application/vnd.yamaha.hv-voice"
],
[
"hvs",
"application/vnd.yamaha.hv-script"
],
[
"i2g",
"application/vnd.intergeo"
],
[
"icc",
"application/vnd.iccprofile"
],
[
"ice",
"x-conference/x-cooltalk"
],
[
"icm",
"application/vnd.iccprofile"
],
[
"ico",
"image/x-icon"
],
[
"ics",
"text/calendar"
],
[
"ief",
"image/ief"
],
[
"ifb",
"text/calendar"
],
[
"ifm",
"application/vnd.shana.informed.formdata"
],
[
"iges",
"model/iges"
],
[
"igl",
"application/vnd.igloader"
],
[
"igm",
"application/vnd.insors.igm"
],
[
"igs",
"model/iges"
],
[
"igx",
"application/vnd.micrografx.igx"
],
[
"iif",
"application/vnd.shana.informed.interchange"
],
[
"img",
"application/octet-stream"
],
[
"imp",
"application/vnd.accpac.simply.imp"
],
[
"ims",
"application/vnd.ms-ims"
],
[
"in",
"text/plain"
],
[
"ini",
"text/plain"
],
[
"ink",
"application/inkml+xml"
],
[
"inkml",
"application/inkml+xml"
],
[
"install",
"application/x-install-instructions"
],
[
"iota",
"application/vnd.astraea-software.iota"
],
[
"ipfix",
"application/ipfix"
],
[
"ipk",
"application/vnd.shana.informed.package"
],
[
"irm",
"application/vnd.ibm.rights-management"
],
[
"irp",
"application/vnd.irepository.package+xml"
],
[
"iso",
"application/x-iso9660-image"
],
[
"itp",
"application/vnd.shana.informed.formtemplate"
],
[
"its",
"application/its+xml"
],
[
"ivp",
"application/vnd.immervision-ivp"
],
[
"ivu",
"application/vnd.immervision-ivu"
],
[
"jad",
"text/vnd.sun.j2me.app-descriptor"
],
[
"jade",
"text/jade"
],
[
"jam",
"application/vnd.jam"
],
[
"jar",
"application/java-archive"
],
[
"jardiff",
"application/x-java-archive-diff"
],
[
"java",
"text/x-java-source"
],
[
"jhc",
"image/jphc"
],
[
"jisp",
"application/vnd.jisp"
],
[
"jls",
"image/jls"
],
[
"jlt",
"application/vnd.hp-jlyt"
],
[
"jng",
"image/x-jng"
],
[
"jnlp",
"application/x-java-jnlp-file"
],
[
"joda",
"application/vnd.joost.joda-archive"
],
[
"jp2",
"image/jp2"
],
[
"jpe",
"image/jpeg"
],
[
"jpeg",
"image/jpeg"
],
[
"jpf",
"image/jpx"
],
[
"jpg",
"image/jpeg"
],
[
"jpg2",
"image/jp2"
],
[
"jpgm",
"video/jpm"
],
[
"jpgv",
"video/jpeg"
],
[
"jph",
"image/jph"
],
[
"jpm",
"video/jpm"
],
[
"jpx",
"image/jpx"
],
[
"js",
"application/javascript"
],
[
"json",
"application/json"
],
[
"json5",
"application/json5"
],
[
"jsonld",
"application/ld+json"
],
[
"jsonl",
"application/jsonl"
],
[
"jsonml",
"application/jsonml+json"
],
[
"jsx",
"text/jsx"
],
[
"jxr",
"image/jxr"
],
[
"jxra",
"image/jxra"
],
[
"jxrs",
"image/jxrs"
],
[
"jxs",
"image/jxs"
],
[
"jxsc",
"image/jxsc"
],
[
"jxsi",
"image/jxsi"
],
[
"jxss",
"image/jxss"
],
[
"kar",
"audio/midi"
],
[
"karbon",
"application/vnd.kde.karbon"
],
[
"kdb",
"application/octet-stream"
],
[
"kdbx",
"application/x-keepass2"
],
[
"key",
"application/x-iwork-keynote-sffkey"
],
[
"kfo",
"application/vnd.kde.kformula"
],
[
"kia",
"application/vnd.kidspiration"
],
[
"kml",
"application/vnd.google-earth.kml+xml"
],
[
"kmz",
"application/vnd.google-earth.kmz"
],
[
"kne",
"application/vnd.kinar"
],
[
"knp",
"application/vnd.kinar"
],
[
"kon",
"application/vnd.kde.kontour"
],
[
"kpr",
"application/vnd.kde.kpresenter"
],
[
"kpt",
"application/vnd.kde.kpresenter"
],
[
"kpxx",
"application/vnd.ds-keypoint"
],
[
"ksp",
"application/vnd.kde.kspread"
],
[
"ktr",
"application/vnd.kahootz"
],
[
"ktx",
"image/ktx"
],
[
"ktx2",
"image/ktx2"
],
[
"ktz",
"application/vnd.kahootz"
],
[
"kwd",
"application/vnd.kde.kword"
],
[
"kwt",
"application/vnd.kde.kword"
],
[
"lasxml",
"application/vnd.las.las+xml"
],
[
"latex",
"application/x-latex"
],
[
"lbd",
"application/vnd.llamagraphics.life-balance.desktop"
],
[
"lbe",
"application/vnd.llamagraphics.life-balance.exchange+xml"
],
[
"les",
"application/vnd.hhe.lesson-player"
],
[
"less",
"text/less"
],
[
"lgr",
"application/lgr+xml"
],
[
"lha",
"application/octet-stream"
],
[
"link66",
"application/vnd.route66.link66+xml"
],
[
"list",
"text/plain"
],
[
"list3820",
"application/vnd.ibm.modcap"
],
[
"listafp",
"application/vnd.ibm.modcap"
],
[
"litcoffee",
"text/coffeescript"
],
[
"lnk",
"application/x-ms-shortcut"
],
[
"log",
"text/plain"
],
[
"lostxml",
"application/lost+xml"
],
[
"lrf",
"application/octet-stream"
],
[
"lrm",
"application/vnd.ms-lrm"
],
[
"ltf",
"application/vnd.frogans.ltf"
],
[
"lua",
"text/x-lua"
],
[
"luac",
"application/x-lua-bytecode"
],
[
"lvp",
"audio/vnd.lucent.voice"
],
[
"lwp",
"application/vnd.lotus-wordpro"
],
[
"lzh",
"application/octet-stream"
],
[
"m1v",
"video/mpeg"
],
[
"m2a",
"audio/mpeg"
],
[
"m2v",
"video/mpeg"
],
[
"m3a",
"audio/mpeg"
],
[
"m3u",
"text/plain"
],
[
"m3u8",
"application/vnd.apple.mpegurl"
],
[
"m4a",
"audio/x-m4a"
],
[
"m4p",
"application/mp4"
],
[
"m4s",
"video/iso.segment"
],
[
"m4u",
"application/vnd.mpegurl"
],
[
"m4v",
"video/x-m4v"
],
[
"m13",
"application/x-msmediaview"
],
[
"m14",
"application/x-msmediaview"
],
[
"m21",
"application/mp21"
],
[
"ma",
"application/mathematica"
],
[
"mads",
"application/mads+xml"
],
[
"maei",
"application/mmt-aei+xml"
],
[
"mag",
"application/vnd.ecowin.chart"
],
[
"maker",
"application/vnd.framemaker"
],
[
"man",
"text/troff"
],
[
"manifest",
"text/cache-manifest"
],
[
"map",
"application/json"
],
[
"mar",
"application/octet-stream"
],
[
"markdown",
"text/markdown"
],
[
"mathml",
"application/mathml+xml"
],
[
"mb",
"application/mathematica"
],
[
"mbk",
"application/vnd.mobius.mbk"
],
[
"mbox",
"application/mbox"
],
[
"mc1",
"application/vnd.medcalcdata"
],
[
"mcd",
"application/vnd.mcd"
],
[
"mcurl",
"text/vnd.curl.mcurl"
],
[
"md",
"text/markdown"
],
[
"mdb",
"application/x-msaccess"
],
[
"mdi",
"image/vnd.ms-modi"
],
[
"mdx",
"text/mdx"
],
[
"me",
"text/troff"
],
[
"mesh",
"model/mesh"
],
[
"meta4",
"application/metalink4+xml"
],
[
"metalink",
"application/metalink+xml"
],
[
"mets",
"application/mets+xml"
],
[
"mfm",
"application/vnd.mfmp"
],
[
"mft",
"application/rpki-manifest"
],
[
"mgp",
"application/vnd.osgeo.mapguide.package"
],
[
"mgz",
"application/vnd.proteus.magazine"
],
[
"mid",
"audio/midi"
],
[
"midi",
"audio/midi"
],
[
"mie",
"application/x-mie"
],
[
"mif",
"application/vnd.mif"
],
[
"mime",
"message/rfc822"
],
[
"mj2",
"video/mj2"
],
[
"mjp2",
"video/mj2"
],
[
"mjs",
"application/javascript"
],
[
"mk3d",
"video/x-matroska"
],
[
"mka",
"audio/x-matroska"
],
[
"mkd",
"text/x-markdown"
],
[
"mks",
"video/x-matroska"
],
[
"mkv",
"video/x-matroska"
],
[
"mlp",
"application/vnd.dolby.mlp"
],
[
"mmd",
"application/vnd.chipnuts.karaoke-mmd"
],
[
"mmf",
"application/vnd.smaf"
],
[
"mml",
"text/mathml"
],
[
"mmr",
"image/vnd.fujixerox.edmics-mmr"
],
[
"mng",
"video/x-mng"
],
[
"mny",
"application/x-msmoney"
],
[
"mobi",
"application/x-mobipocket-ebook"
],
[
"mods",
"application/mods+xml"
],
[
"mov",
"video/quicktime"
],
[
"movie",
"video/x-sgi-movie"
],
[
"mp2",
"audio/mpeg"
],
[
"mp2a",
"audio/mpeg"
],
[
"mp3",
"audio/mpeg"
],
[
"mp4",
"video/mp4"
],
[
"mp4a",
"audio/mp4"
],
[
"mp4s",
"application/mp4"
],
[
"mp4v",
"video/mp4"
],
[
"mp21",
"application/mp21"
],
[
"mpc",
"application/vnd.mophun.certificate"
],
[
"mpd",
"application/dash+xml"
],
[
"mpe",
"video/mpeg"
],
[
"mpeg",
"video/mpeg"
],
[
"mpg",
"video/mpeg"
],
[
"mpg4",
"video/mp4"
],
[
"mpga",
"audio/mpeg"
],
[
"mpkg",
"application/vnd.apple.installer+xml"
],
[
"mpm",
"application/vnd.blueice.multipass"
],
[
"mpn",
"application/vnd.mophun.application"
],
[
"mpp",
"application/vnd.ms-project"
],
[
"mpt",
"application/vnd.ms-project"
],
[
"mpy",
"application/vnd.ibm.minipay"
],
[
"mqy",
"application/vnd.mobius.mqy"
],
[
"mrc",
"application/marc"
],
[
"mrcx",
"application/marcxml+xml"
],
[
"ms",
"text/troff"
],
[
"mscml",
"application/mediaservercontrol+xml"
],
[
"mseed",
"application/vnd.fdsn.mseed"
],
[
"mseq",
"application/vnd.mseq"
],
[
"msf",
"application/vnd.epson.msf"
],
[
"msg",
"application/vnd.ms-outlook"
],
[
"msh",
"model/mesh"
],
[
"msi",
"application/x-msdownload"
],
[
"msl",
"application/vnd.mobius.msl"
],
[
"msm",
"application/octet-stream"
],
[
"msp",
"application/octet-stream"
],
[
"msty",
"application/vnd.muvee.style"
],
[
"mtl",
"model/mtl"
],
[
"mts",
"model/vnd.mts"
],
[
"mus",
"application/vnd.musician"
],
[
"musd",
"application/mmt-usd+xml"
],
[
"musicxml",
"application/vnd.recordare.musicxml+xml"
],
[
"mvb",
"application/x-msmediaview"
],
[
"mvt",
"application/vnd.mapbox-vector-tile"
],
[
"mwf",
"application/vnd.mfer"
],
[
"mxf",
"application/mxf"
],
[
"mxl",
"application/vnd.recordare.musicxml"
],
[
"mxmf",
"audio/mobile-xmf"
],
[
"mxml",
"application/xv+xml"
],
[
"mxs",
"application/vnd.triscape.mxs"
],
[
"mxu",
"video/vnd.mpegurl"
],
[
"n-gage",
"application/vnd.nokia.n-gage.symbian.install"
],
[
"n3",
"text/n3"
],
[
"nb",
"application/mathematica"
],
[
"nbp",
"application/vnd.wolfram.player"
],
[
"nc",
"application/x-netcdf"
],
[
"ncx",
"application/x-dtbncx+xml"
],
[
"nfo",
"text/x-nfo"
],
[
"ngdat",
"application/vnd.nokia.n-gage.data"
],
[
"nitf",
"application/vnd.nitf"
],
[
"nlu",
"application/vnd.neurolanguage.nlu"
],
[
"nml",
"application/vnd.enliven"
],
[
"nnd",
"application/vnd.noblenet-directory"
],
[
"nns",
"application/vnd.noblenet-sealer"
],
[
"nnw",
"application/vnd.noblenet-web"
],
[
"npx",
"image/vnd.net-fpx"
],
[
"nq",
"application/n-quads"
],
[
"nsc",
"application/x-conference"
],
[
"nsf",
"application/vnd.lotus-notes"
],
[
"nt",
"application/n-triples"
],
[
"ntf",
"application/vnd.nitf"
],
[
"numbers",
"application/x-iwork-numbers-sffnumbers"
],
[
"nzb",
"application/x-nzb"
],
[
"oa2",
"application/vnd.fujitsu.oasys2"
],
[
"oa3",
"application/vnd.fujitsu.oasys3"
],
[
"oas",
"application/vnd.fujitsu.oasys"
],
[
"obd",
"application/x-msbinder"
],
[
"obgx",
"application/vnd.openblox.game+xml"
],
[
"obj",
"model/obj"
],
[
"oda",
"application/oda"
],
[
"odb",
"application/vnd.oasis.opendocument.database"
],
[
"odc",
"application/vnd.oasis.opendocument.chart"
],
[
"odf",
"application/vnd.oasis.opendocument.formula"
],
[
"odft",
"application/vnd.oasis.opendocument.formula-template"
],
[
"odg",
"application/vnd.oasis.opendocument.graphics"
],
[
"odi",
"application/vnd.oasis.opendocument.image"
],
[
"odm",
"application/vnd.oasis.opendocument.text-master"
],
[
"odp",
"application/vnd.oasis.opendocument.presentation"
],
[
"ods",
"application/vnd.oasis.opendocument.spreadsheet"
],
[
"odt",
"application/vnd.oasis.opendocument.text"
],
[
"oga",
"audio/ogg"
],
[
"ogex",
"model/vnd.opengex"
],
[
"ogg",
"audio/ogg"
],
[
"ogv",
"video/ogg"
],
[
"ogx",
"application/ogg"
],
[
"omdoc",
"application/omdoc+xml"
],
[
"onepkg",
"application/onenote"
],
[
"onetmp",
"application/onenote"
],
[
"onetoc",
"application/onenote"
],
[
"onetoc2",
"application/onenote"
],
[
"opf",
"application/oebps-package+xml"
],
[
"opml",
"text/x-opml"
],
[
"oprc",
"application/vnd.palm"
],
[
"opus",
"audio/ogg"
],
[
"org",
"text/x-org"
],
[
"osf",
"application/vnd.yamaha.openscoreformat"
],
[
"osfpvg",
"application/vnd.yamaha.openscoreformat.osfpvg+xml"
],
[
"osm",
"application/vnd.openstreetmap.data+xml"
],
[
"otc",
"application/vnd.oasis.opendocument.chart-template"
],
[
"otf",
"font/otf"
],
[
"otg",
"application/vnd.oasis.opendocument.graphics-template"
],
[
"oth",
"application/vnd.oasis.opendocument.text-web"
],
[
"oti",
"application/vnd.oasis.opendocument.image-template"
],
[
"otp",
"application/vnd.oasis.opendocument.presentation-template"
],
[
"ots",
"application/vnd.oasis.opendocument.spreadsheet-template"
],
[
"ott",
"application/vnd.oasis.opendocument.text-template"
],
[
"ova",
"application/x-virtualbox-ova"
],
[
"ovf",
"application/x-virtualbox-ovf"
],
[
"owl",
"application/rdf+xml"
],
[
"oxps",
"application/oxps"
],
[
"oxt",
"application/vnd.openofficeorg.extension"
],
[
"p",
"text/x-pascal"
],
[
"p7a",
"application/x-pkcs7-signature"
],
[
"p7b",
"application/x-pkcs7-certificates"
],
[
"p7c",
"application/pkcs7-mime"
],
[
"p7m",
"application/pkcs7-mime"
],
[
"p7r",
"application/x-pkcs7-certreqresp"
],
[
"p7s",
"application/pkcs7-signature"
],
[
"p8",
"application/pkcs8"
],
[
"p10",
"application/x-pkcs10"
],
[
"p12",
"application/x-pkcs12"
],
[
"pac",
"application/x-ns-proxy-autoconfig"
],
[
"pages",
"application/x-iwork-pages-sffpages"
],
[
"pas",
"text/x-pascal"
],
[
"paw",
"application/vnd.pawaafile"
],
[
"pbd",
"application/vnd.powerbuilder6"
],
[
"pbm",
"image/x-portable-bitmap"
],
[
"pcap",
"application/vnd.tcpdump.pcap"
],
[
"pcf",
"application/x-font-pcf"
],
[
"pcl",
"application/vnd.hp-pcl"
],
[
"pclxl",
"application/vnd.hp-pclxl"
],
[
"pct",
"image/x-pict"
],
[
"pcurl",
"application/vnd.curl.pcurl"
],
[
"pcx",
"image/x-pcx"
],
[
"pdb",
"application/x-pilot"
],
[
"pde",
"text/x-processing"
],
[
"pdf",
"application/pdf"
],
[
"pem",
"application/x-x509-user-cert"
],
[
"pfa",
"application/x-font-type1"
],
[
"pfb",
"application/x-font-type1"
],
[
"pfm",
"application/x-font-type1"
],
[
"pfr",
"application/font-tdpfr"
],
[
"pfx",
"application/x-pkcs12"
],
[
"pgm",
"image/x-portable-graymap"
],
[
"pgn",
"application/x-chess-pgn"
],
[
"pgp",
"application/pgp"
],
[
"php",
"application/x-httpd-php"
],
[
"php3",
"application/x-httpd-php"
],
[
"php4",
"application/x-httpd-php"
],
[
"phps",
"application/x-httpd-php-source"
],
[
"phtml",
"application/x-httpd-php"
],
[
"pic",
"image/x-pict"
],
[
"pkg",
"application/octet-stream"
],
[
"pki",
"application/pkixcmp"
],
[
"pkipath",
"application/pkix-pkipath"
],
[
"pkpass",
"application/vnd.apple.pkpass"
],
[
"pl",
"application/x-perl"
],
[
"plb",
"application/vnd.3gpp.pic-bw-large"
],
[
"plc",
"application/vnd.mobius.plc"
],
[
"plf",
"application/vnd.pocketlearn"
],
[
"pls",
"application/pls+xml"
],
[
"pm",
"application/x-perl"
],
[
"pml",
"application/vnd.ctc-posml"
],
[
"png",
"image/png"
],
[
"pnm",
"image/x-portable-anymap"
],
[
"portpkg",
"application/vnd.macports.portpkg"
],
[
"pot",
"application/vnd.ms-powerpoint"
],
[
"potm",
"application/vnd.ms-powerpoint.presentation.macroEnabled.12"
],
[
"potx",
"application/vnd.openxmlformats-officedocument.presentationml.template"
],
[
"ppa",
"application/vnd.ms-powerpoint"
],
[
"ppam",
"application/vnd.ms-powerpoint.addin.macroEnabled.12"
],
[
"ppd",
"application/vnd.cups-ppd"
],
[
"ppm",
"image/x-portable-pixmap"
],
[
"pps",
"application/vnd.ms-powerpoint"
],
[
"ppsm",
"application/vnd.ms-powerpoint.slideshow.macroEnabled.12"
],
[
"ppsx",
"application/vnd.openxmlformats-officedocument.presentationml.slideshow"
],
[
"ppt",
"application/powerpoint"
],
[
"pptm",
"application/vnd.ms-powerpoint.presentation.macroEnabled.12"
],
[
"pptx",
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
],
[
"pqa",
"application/vnd.palm"
],
[
"prc",
"application/x-pilot"
],
[
"pre",
"application/vnd.lotus-freelance"
],
[
"prf",
"application/pics-rules"
],
[
"provx",
"application/provenance+xml"
],
[
"ps",
"application/postscript"
],
[
"psb",
"application/vnd.3gpp.pic-bw-small"
],
[
"psd",
"application/x-photoshop"
],
[
"psf",
"application/x-font-linux-psf"
],
[
"pskcxml",
"application/pskc+xml"
],
[
"pti",
"image/prs.pti"
],
[
"ptid",
"application/vnd.pvi.ptid1"
],
[
"pub",
"application/x-mspublisher"
],
[
"pvb",
"application/vnd.3gpp.pic-bw-var"
],
[
"pwn",
"application/vnd.3m.post-it-notes"
],
[
"pya",
"audio/vnd.ms-playready.media.pya"
],
[
"pyv",
"video/vnd.ms-playready.media.pyv"
],
[
"qam",
"application/vnd.epson.quickanime"
],
[
"qbo",
"application/vnd.intu.qbo"
],
[
"qfx",
"application/vnd.intu.qfx"
],
[
"qps",
"application/vnd.publishare-delta-tree"
],
[
"qt",
"video/quicktime"
],
[
"qwd",
"application/vnd.quark.quarkxpress"
],
[
"qwt",
"application/vnd.quark.quarkxpress"
],
[
"qxb",
"application/vnd.quark.quarkxpress"
],
[
"qxd",
"application/vnd.quark.quarkxpress"
],
[
"qxl",
"application/vnd.quark.quarkxpress"
],
[
"qxt",
"application/vnd.quark.quarkxpress"
],
[
"ra",
"audio/x-realaudio"
],
[
"ram",
"audio/x-pn-realaudio"
],
[
"raml",
"application/raml+yaml"
],
[
"rapd",
"application/route-apd+xml"
],
[
"rar",
"application/x-rar"
],
[
"ras",
"image/x-cmu-raster"
],
[
"rcprofile",
"application/vnd.ipunplugged.rcprofile"
],
[
"rdf",
"application/rdf+xml"
],
[
"rdz",
"application/vnd.data-vision.rdz"
],
[
"relo",
"application/p2p-overlay+xml"
],
[
"rep",
"application/vnd.businessobjects"
],
[
"res",
"application/x-dtbresource+xml"
],
[
"rgb",
"image/x-rgb"
],
[
"rif",
"application/reginfo+xml"
],
[
"rip",
"audio/vnd.rip"
],
[
"ris",
"application/x-research-info-systems"
],
[
"rl",
"application/resource-lists+xml"
],
[
"rlc",
"image/vnd.fujixerox.edmics-rlc"
],
[
"rld",
"application/resource-lists-diff+xml"
],
[
"rm",
"audio/x-pn-realaudio"
],
[
"rmi",
"audio/midi"
],
[
"rmp",
"audio/x-pn-realaudio-plugin"
],
[
"rms",
"application/vnd.jcp.javame.midlet-rms"
],
[
"rmvb",
"application/vnd.rn-realmedia-vbr"
],
[
"rnc",
"application/relax-ng-compact-syntax"
],
[
"rng",
"application/xml"
],
[
"roa",
"application/rpki-roa"
],
[
"roff",
"text/troff"
],
[
"rp9",
"application/vnd.cloanto.rp9"
],
[
"rpm",
"audio/x-pn-realaudio-plugin"
],
[
"rpss",
"application/vnd.nokia.radio-presets"
],
[
"rpst",
"application/vnd.nokia.radio-preset"
],
[
"rq",
"application/sparql-query"
],
[
"rs",
"application/rls-services+xml"
],
[
"rsa",
"application/x-pkcs7"
],
[
"rsat",
"application/atsc-rsat+xml"
],
[
"rsd",
"application/rsd+xml"
],
[
"rsheet",
"application/urc-ressheet+xml"
],
[
"rss",
"application/rss+xml"
],
[
"rtf",
"text/rtf"
],
[
"rtx",
"text/richtext"
],
[
"run",
"application/x-makeself"
],
[
"rusd",
"application/route-usd+xml"
],
[
"rv",
"video/vnd.rn-realvideo"
],
[
"s",
"text/x-asm"
],
[
"s3m",
"audio/s3m"
],
[
"saf",
"application/vnd.yamaha.smaf-audio"
],
[
"sass",
"text/x-sass"
],
[
"sbml",
"application/sbml+xml"
],
[
"sc",
"application/vnd.ibm.secure-container"
],
[
"scd",
"application/x-msschedule"
],
[
"scm",
"application/vnd.lotus-screencam"
],
[
"scq",
"application/scvp-cv-request"
],
[
"scs",
"application/scvp-cv-response"
],
[
"scss",
"text/x-scss"
],
[
"scurl",
"text/vnd.curl.scurl"
],
[
"sda",
"application/vnd.stardivision.draw"
],
[
"sdc",
"application/vnd.stardivision.calc"
],
[
"sdd",
"application/vnd.stardivision.impress"
],
[
"sdkd",
"application/vnd.solent.sdkm+xml"
],
[
"sdkm",
"application/vnd.solent.sdkm+xml"
],
[
"sdp",
"application/sdp"
],
[
"sdw",
"application/vnd.stardivision.writer"
],
[
"sea",
"application/octet-stream"
],
[
"see",
"application/vnd.seemail"
],
[
"seed",
"application/vnd.fdsn.seed"
],
[
"sema",
"application/vnd.sema"
],
[
"semd",
"application/vnd.semd"
],
[
"semf",
"application/vnd.semf"
],
[
"senmlx",
"application/senml+xml"
],
[
"sensmlx",
"application/sensml+xml"
],
[
"ser",
"application/java-serialized-object"
],
[
"setpay",
"application/set-payment-initiation"
],
[
"setreg",
"application/set-registration-initiation"
],
[
"sfd-hdstx",
"application/vnd.hydrostatix.sof-data"
],
[
"sfs",
"application/vnd.spotfire.sfs"
],
[
"sfv",
"text/x-sfv"
],
[
"sgi",
"image/sgi"
],
[
"sgl",
"application/vnd.stardivision.writer-global"
],
[
"sgm",
"text/sgml"
],
[
"sgml",
"text/sgml"
],
[
"sh",
"application/x-sh"
],
[
"shar",
"application/x-shar"
],
[
"shex",
"text/shex"
],
[
"shf",
"application/shf+xml"
],
[
"shtml",
"text/html"
],
[
"sid",
"image/x-mrsid-image"
],
[
"sieve",
"application/sieve"
],
[
"sig",
"application/pgp-signature"
],
[
"sil",
"audio/silk"
],
[
"silo",
"model/mesh"
],
[
"sis",
"application/vnd.symbian.install"
],
[
"sisx",
"application/vnd.symbian.install"
],
[
"sit",
"application/x-stuffit"
],
[
"sitx",
"application/x-stuffitx"
],
[
"siv",
"application/sieve"
],
[
"skd",
"application/vnd.koan"
],
[
"skm",
"application/vnd.koan"
],
[
"skp",
"application/vnd.koan"
],
[
"skt",
"application/vnd.koan"
],
[
"sldm",
"application/vnd.ms-powerpoint.slide.macroenabled.12"
],
[
"sldx",
"application/vnd.openxmlformats-officedocument.presentationml.slide"
],
[
"slim",
"text/slim"
],
[
"slm",
"text/slim"
],
[
"sls",
"application/route-s-tsid+xml"
],
[
"slt",
"application/vnd.epson.salt"
],
[
"sm",
"application/vnd.stepmania.stepchart"
],
[
"smf",
"application/vnd.stardivision.math"
],
[
"smi",
"application/smil"
],
[
"smil",
"application/smil"
],
[
"smv",
"video/x-smv"
],
[
"smzip",
"application/vnd.stepmania.package"
],
[
"snd",
"audio/basic"
],
[
"snf",
"application/x-font-snf"
],
[
"so",
"application/octet-stream"
],
[
"spc",
"application/x-pkcs7-certificates"
],
[
"spdx",
"text/spdx"
],
[
"spf",
"application/vnd.yamaha.smaf-phrase"
],
[
"spl",
"application/x-futuresplash"
],
[
"spot",
"text/vnd.in3d.spot"
],
[
"spp",
"application/scvp-vp-response"
],
[
"spq",
"application/scvp-vp-request"
],
[
"spx",
"audio/ogg"
],
[
"sql",
"application/x-sql"
],
[
"src",
"application/x-wais-source"
],
[
"srt",
"application/x-subrip"
],
[
"sru",
"application/sru+xml"
],
[
"srx",
"application/sparql-results+xml"
],
[
"ssdl",
"application/ssdl+xml"
],
[
"sse",
"application/vnd.kodak-descriptor"
],
[
"ssf",
"application/vnd.epson.ssf"
],
[
"ssml",
"application/ssml+xml"
],
[
"sst",
"application/octet-stream"
],
[
"st",
"application/vnd.sailingtracker.track"
],
[
"stc",
"application/vnd.sun.xml.calc.template"
],
[
"std",
"application/vnd.sun.xml.draw.template"
],
[
"stf",
"application/vnd.wt.stf"
],
[
"sti",
"application/vnd.sun.xml.impress.template"
],
[
"stk",
"application/hyperstudio"
],
[
"stl",
"model/stl"
],
[
"stpx",
"model/step+xml"
],
[
"stpxz",
"model/step-xml+zip"
],
[
"stpz",
"model/step+zip"
],
[
"str",
"application/vnd.pg.format"
],
[
"stw",
"application/vnd.sun.xml.writer.template"
],
[
"styl",
"text/stylus"
],
[
"stylus",
"text/stylus"
],
[
"sub",
"text/vnd.dvb.subtitle"
],
[
"sus",
"application/vnd.sus-calendar"
],
[
"susp",
"application/vnd.sus-calendar"
],
[
"sv4cpio",
"application/x-sv4cpio"
],
[
"sv4crc",
"application/x-sv4crc"
],
[
"svc",
"application/vnd.dvb.service"
],
[
"svd",
"application/vnd.svd"
],
[
"svg",
"image/svg+xml"
],
[
"svgz",
"image/svg+xml"
],
[
"swa",
"application/x-director"
],
[
"swf",
"application/x-shockwave-flash"
],
[
"swi",
"application/vnd.aristanetworks.swi"
],
[
"swidtag",
"application/swid+xml"
],
[
"sxc",
"application/vnd.sun.xml.calc"
],
[
"sxd",
"application/vnd.sun.xml.draw"
],
[
"sxg",
"application/vnd.sun.xml.writer.global"
],
[
"sxi",
"application/vnd.sun.xml.impress"
],
[
"sxm",
"application/vnd.sun.xml.math"
],
[
"sxw",
"application/vnd.sun.xml.writer"
],
[
"t",
"text/troff"
],
[
"t3",
"application/x-t3vm-image"
],
[
"t38",
"image/t38"
],
[
"taglet",
"application/vnd.mynfc"
],
[
"tao",
"application/vnd.tao.intent-module-archive"
],
[
"tap",
"image/vnd.tencent.tap"
],
[
"tar",
"application/x-tar"
],
[
"tcap",
"application/vnd.3gpp2.tcap"
],
[
"tcl",
"application/x-tcl"
],
[
"td",
"application/urc-targetdesc+xml"
],
[
"teacher",
"application/vnd.smart.teacher"
],
[
"tei",
"application/tei+xml"
],
[
"teicorpus",
"application/tei+xml"
],
[
"tex",
"application/x-tex"
],
[
"texi",
"application/x-texinfo"
],
[
"texinfo",
"application/x-texinfo"
],
[
"text",
"text/plain"
],
[
"tfi",
"application/thraud+xml"
],
[
"tfm",
"application/x-tex-tfm"
],
[
"tfx",
"image/tiff-fx"
],
[
"tga",
"image/x-tga"
],
[
"tgz",
"application/x-tar"
],
[
"thmx",
"application/vnd.ms-officetheme"
],
[
"tif",
"image/tiff"
],
[
"tiff",
"image/tiff"
],
[
"tk",
"application/x-tcl"
],
[
"tmo",
"application/vnd.tmobile-livetv"
],
[
"toml",
"application/toml"
],
[
"torrent",
"application/x-bittorrent"
],
[
"tpl",
"application/vnd.groove-tool-template"
],
[
"tpt",
"application/vnd.trid.tpt"
],
[
"tr",
"text/troff"
],
[
"tra",
"application/vnd.trueapp"
],
[
"trig",
"application/trig"
],
[
"trm",
"application/x-msterminal"
],
[
"ts",
"video/mp2t"
],
[
"tsd",
"application/timestamped-data"
],
[
"tsv",
"text/tab-separated-values"
],
[
"ttc",
"font/collection"
],
[
"ttf",
"font/ttf"
],
[
"ttl",
"text/turtle"
],
[
"ttml",
"application/ttml+xml"
],
[
"twd",
"application/vnd.simtech-mindmapper"
],
[
"twds",
"application/vnd.simtech-mindmapper"
],
[
"txd",
"application/vnd.genomatix.tuxedo"
],
[
"txf",
"application/vnd.mobius.txf"
],
[
"txt",
"text/plain"
],
[
"u8dsn",
"message/global-delivery-status"
],
[
"u8hdr",
"message/global-headers"
],
[
"u8mdn",
"message/global-disposition-notification"
],
[
"u8msg",
"message/global"
],
[
"u32",
"application/x-authorware-bin"
],
[
"ubj",
"application/ubjson"
],
[
"udeb",
"application/x-debian-package"
],
[
"ufd",
"application/vnd.ufdl"
],
[
"ufdl",
"application/vnd.ufdl"
],
[
"ulx",
"application/x-glulx"
],
[
"umj",
"application/vnd.umajin"
],
[
"unityweb",
"application/vnd.unity"
],
[
"uoml",
"application/vnd.uoml+xml"
],
[
"uri",
"text/uri-list"
],
[
"uris",
"text/uri-list"
],
[
"urls",
"text/uri-list"
],
[
"usdz",
"model/vnd.usdz+zip"
],
[
"ustar",
"application/x-ustar"
],
[
"utz",
"application/vnd.uiq.theme"
],
[
"uu",
"text/x-uuencode"
],
[
"uva",
"audio/vnd.dece.audio"
],
[
"uvd",
"application/vnd.dece.data"
],
[
"uvf",
"application/vnd.dece.data"
],
[
"uvg",
"image/vnd.dece.graphic"
],
[
"uvh",
"video/vnd.dece.hd"
],
[
"uvi",
"image/vnd.dece.graphic"
],
[
"uvm",
"video/vnd.dece.mobile"
],
[
"uvp",
"video/vnd.dece.pd"
],
[
"uvs",
"video/vnd.dece.sd"
],
[
"uvt",
"application/vnd.dece.ttml+xml"
],
[
"uvu",
"video/vnd.uvvu.mp4"
],
[
"uvv",
"video/vnd.dece.video"
],
[
"uvva",
"audio/vnd.dece.audio"
],
[
"uvvd",
"application/vnd.dece.data"
],
[
"uvvf",
"application/vnd.dece.data"
],
[
"uvvg",
"image/vnd.dece.graphic"
],
[
"uvvh",
"video/vnd.dece.hd"
],
[
"uvvi",
"image/vnd.dece.graphic"
],
[
"uvvm",
"video/vnd.dece.mobile"
],
[
"uvvp",
"video/vnd.dece.pd"
],
[
"uvvs",
"video/vnd.dece.sd"
],
[
"uvvt",
"application/vnd.dece.ttml+xml"
],
[
"uvvu",
"video/vnd.uvvu.mp4"
],
[
"uvvv",
"video/vnd.dece.video"
],
[
"uvvx",
"application/vnd.dece.unspecified"
],
[
"uvvz",
"application/vnd.dece.zip"
],
[
"uvx",
"application/vnd.dece.unspecified"
],
[
"uvz",
"application/vnd.dece.zip"
],
[
"vbox",
"application/x-virtualbox-vbox"
],
[
"vbox-extpack",
"application/x-virtualbox-vbox-extpack"
],
[
"vcard",
"text/vcard"
],
[
"vcd",
"application/x-cdlink"
],
[
"vcf",
"text/x-vcard"
],
[
"vcg",
"application/vnd.groove-vcard"
],
[
"vcs",
"text/x-vcalendar"
],
[
"vcx",
"application/vnd.vcx"
],
[
"vdi",
"application/x-virtualbox-vdi"
],
[
"vds",
"model/vnd.sap.vds"
],
[
"vhd",
"application/x-virtualbox-vhd"
],
[
"vis",
"application/vnd.visionary"
],
[
"viv",
"video/vnd.vivo"
],
[
"vlc",
"application/videolan"
],
[
"vmdk",
"application/x-virtualbox-vmdk"
],
[
"vob",
"video/x-ms-vob"
],
[
"vor",
"application/vnd.stardivision.writer"
],
[
"vox",
"application/x-authorware-bin"
],
[
"vrml",
"model/vrml"
],
[
"vsd",
"application/vnd.visio"
],
[
"vsf",
"application/vnd.vsf"
],
[
"vss",
"application/vnd.visio"
],
[
"vst",
"application/vnd.visio"
],
[
"vsw",
"application/vnd.visio"
],
[
"vtf",
"image/vnd.valve.source.texture"
],
[
"vtt",
"text/vtt"
],
[
"vtu",
"model/vnd.vtu"
],
[
"vxml",
"application/voicexml+xml"
],
[
"w3d",
"application/x-director"
],
[
"wad",
"application/x-doom"
],
[
"wadl",
"application/vnd.sun.wadl+xml"
],
[
"war",
"application/java-archive"
],
[
"wasm",
"application/wasm"
],
[
"wav",
"audio/x-wav"
],
[
"wax",
"audio/x-ms-wax"
],
[
"wbmp",
"image/vnd.wap.wbmp"
],
[
"wbs",
"application/vnd.criticaltools.wbs+xml"
],
[
"wbxml",
"application/wbxml"
],
[
"wcm",
"application/vnd.ms-works"
],
[
"wdb",
"application/vnd.ms-works"
],
[
"wdp",
"image/vnd.ms-photo"
],
[
"weba",
"audio/webm"
],
[
"webapp",
"application/x-web-app-manifest+json"
],
[
"webm",
"video/webm"
],
[
"webmanifest",
"application/manifest+json"
],
[
"webp",
"image/webp"
],
[
"wg",
"application/vnd.pmi.widget"
],
[
"wgt",
"application/widget"
],
[
"wks",
"application/vnd.ms-works"
],
[
"wm",
"video/x-ms-wm"
],
[
"wma",
"audio/x-ms-wma"
],
[
"wmd",
"application/x-ms-wmd"
],
[
"wmf",
"image/wmf"
],
[
"wml",
"text/vnd.wap.wml"
],
[
"wmlc",
"application/wmlc"
],
[
"wmls",
"text/vnd.wap.wmlscript"
],
[
"wmlsc",
"application/vnd.wap.wmlscriptc"
],
[
"wmv",
"video/x-ms-wmv"
],
[
"wmx",
"video/x-ms-wmx"
],
[
"wmz",
"application/x-msmetafile"
],
[
"woff",
"font/woff"
],
[
"woff2",
"font/woff2"
],
[
"word",
"application/msword"
],
[
"wpd",
"application/vnd.wordperfect"
],
[
"wpl",
"application/vnd.ms-wpl"
],
[
"wps",
"application/vnd.ms-works"
],
[
"wqd",
"application/vnd.wqd"
],
[
"wri",
"application/x-mswrite"
],
[
"wrl",
"model/vrml"
],
[
"wsc",
"message/vnd.wfa.wsc"
],
[
"wsdl",
"application/wsdl+xml"
],
[
"wspolicy",
"application/wspolicy+xml"
],
[
"wtb",
"application/vnd.webturbo"
],
[
"wvx",
"video/x-ms-wvx"
],
[
"x3d",
"model/x3d+xml"
],
[
"x3db",
"model/x3d+fastinfoset"
],
[
"x3dbz",
"model/x3d+binary"
],
[
"x3dv",
"model/x3d-vrml"
],
[
"x3dvz",
"model/x3d+vrml"
],
[
"x3dz",
"model/x3d+xml"
],
[
"x32",
"application/x-authorware-bin"
],
[
"x_b",
"model/vnd.parasolid.transmit.binary"
],
[
"x_t",
"model/vnd.parasolid.transmit.text"
],
[
"xaml",
"application/xaml+xml"
],
[
"xap",
"application/x-silverlight-app"
],
[
"xar",
"application/vnd.xara"
],
[
"xav",
"application/xcap-att+xml"
],
[
"xbap",
"application/x-ms-xbap"
],
[
"xbd",
"application/vnd.fujixerox.docuworks.binder"
],
[
"xbm",
"image/x-xbitmap"
],
[
"xca",
"application/xcap-caps+xml"
],
[
"xcs",
"application/calendar+xml"
],
[
"xdf",
"application/xcap-diff+xml"
],
[
"xdm",
"application/vnd.syncml.dm+xml"
],
[
"xdp",
"application/vnd.adobe.xdp+xml"
],
[
"xdssc",
"application/dssc+xml"
],
[
"xdw",
"application/vnd.fujixerox.docuworks"
],
[
"xel",
"application/xcap-el+xml"
],
[
"xenc",
"application/xenc+xml"
],
[
"xer",
"application/patch-ops-error+xml"
],
[
"xfdf",
"application/vnd.adobe.xfdf"
],
[
"xfdl",
"application/vnd.xfdl"
],
[
"xht",
"application/xhtml+xml"
],
[
"xhtml",
"application/xhtml+xml"
],
[
"xhvml",
"application/xv+xml"
],
[
"xif",
"image/vnd.xiff"
],
[
"xl",
"application/excel"
],
[
"xla",
"application/vnd.ms-excel"
],
[
"xlam",
"application/vnd.ms-excel.addin.macroEnabled.12"
],
[
"xlc",
"application/vnd.ms-excel"
],
[
"xlf",
"application/xliff+xml"
],
[
"xlm",
"application/vnd.ms-excel"
],
[
"xls",
"application/vnd.ms-excel"
],
[
"xlsb",
"application/vnd.ms-excel.sheet.binary.macroEnabled.12"
],
[
"xlsm",
"application/vnd.ms-excel.sheet.macroEnabled.12"
],
[
"xlsx",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
],
[
"xlt",
"application/vnd.ms-excel"
],
[
"xltm",
"application/vnd.ms-excel.template.macroEnabled.12"
],
[
"xltx",
"application/vnd.openxmlformats-officedocument.spreadsheetml.template"
],
[
"xlw",
"application/vnd.ms-excel"
],
[
"xm",
"audio/xm"
],
[
"xml",
"application/xml"
],
[
"xns",
"application/xcap-ns+xml"
],
[
"xo",
"application/vnd.olpc-sugar"
],
[
"xop",
"application/xop+xml"
],
[
"xpi",
"application/x-xpinstall"
],
[
"xpl",
"application/xproc+xml"
],
[
"xpm",
"image/x-xpixmap"
],
[
"xpr",
"application/vnd.is-xpr"
],
[
"xps",
"application/vnd.ms-xpsdocument"
],
[
"xpw",
"application/vnd.intercon.formnet"
],
[
"xpx",
"application/vnd.intercon.formnet"
],
[
"xsd",
"application/xml"
],
[
"xsl",
"application/xml"
],
[
"xslt",
"application/xslt+xml"
],
[
"xsm",
"application/vnd.syncml+xml"
],
[
"xspf",
"application/xspf+xml"
],
[
"xul",
"application/vnd.mozilla.xul+xml"
],
[
"xvm",
"application/xv+xml"
],
[
"xvml",
"application/xv+xml"
],
[
"xwd",
"image/x-xwindowdump"
],
[
"xyz",
"chemical/x-xyz"
],
[
"xz",
"application/x-xz"
],
[
"yaml",
"text/yaml"
],
[
"yang",
"application/yang"
],
[
"yin",
"application/yin+xml"
],
[
"yml",
"text/yaml"
],
[
"ymp",
"text/x-suse-ymp"
],
[
"z",
"application/x-compress"
],
[
"z1",
"application/x-zmachine"
],
[
"z2",
"application/x-zmachine"
],
[
"z3",
"application/x-zmachine"
],
[
"z4",
"application/x-zmachine"
],
[
"z5",
"application/x-zmachine"
],
[
"z6",
"application/x-zmachine"
],
[
"z7",
"application/x-zmachine"
],
[
"z8",
"application/x-zmachine"
],
[
"zaz",
"application/vnd.zzazz.deck+xml"
],
[
"zip",
"application/zip"
],
[
"zir",
"application/vnd.zul"
],
[
"zirz",
"application/vnd.zul"
],
[
"zmm",
"application/vnd.handheld-entertainment+xml"
],
[
"zsh",
"text/x-scriptzsh"
]
]);
function toFileWithPath(file, path, h2) {
const f2 = withMimeType(file);
const { webkitRelativePath } = file;
const p2 = typeof path === "string" ? path : typeof webkitRelativePath === "string" && webkitRelativePath.length > 0 ? webkitRelativePath : `./${file.name}`;
if (typeof f2.path !== "string") {
setObjProp(f2, "path", p2);
}
setObjProp(f2, "relativePath", p2);
return f2;
}
function withMimeType(file) {
const { name } = file;
const hasExtension = name && name.lastIndexOf(".") !== -1;
if (hasExtension && !file.type) {
const ext = name.split(".").pop().toLowerCase();
const type = COMMON_MIME_TYPES.get(ext);
if (type) {
Object.defineProperty(file, "type", {
value: type,
writable: false,
configurable: false,
enumerable: true
});
}
}
return file;
}
function setObjProp(f2, key, value) {
Object.defineProperty(f2, key, {
value,
writable: false,
configurable: false,
enumerable: true
});
}
const FILES_TO_IGNORE = [
".DS_Store",
"Thumbs.db"
];
function fromEvent(evt) {
return __awaiter(this, void 0, void 0, function* () {
if (isObject(evt) && isDataTransfer(evt.dataTransfer)) {
return getDataTransferFiles(evt.dataTransfer, evt.type);
} else if (isChangeEvt(evt)) {
return getInputFiles(evt);
} else if (Array.isArray(evt) && evt.every((item) => "getFile" in item && typeof item.getFile === "function")) {
return getFsHandleFiles(evt);
}
return [];
});
}
function isDataTransfer(value) {
return isObject(value);
}
function isChangeEvt(value) {
return isObject(value) && isObject(value.target);
}
function isObject(v2) {
return typeof v2 === "object" && v2 !== null;
}
function getInputFiles(evt) {
return fromList(evt.target.files).map((file) => toFileWithPath(file));
}
function getFsHandleFiles(handles) {
return __awaiter(this, void 0, void 0, function* () {
const files = yield Promise.all(handles.map((h2) => h2.getFile()));
return files.map((file) => toFileWithPath(file));
});
}
function getDataTransferFiles(dt, type) {
return __awaiter(this, void 0, void 0, function* () {
if (dt.items) {
const items = fromList(dt.items).filter((item) => item.kind === "file");
if (type !== "drop") {
return items;
}
const files = yield Promise.all(items.map(toFilePromises));
return noIgnoredFiles(flatten(files));
}
return noIgnoredFiles(fromList(dt.files).map((file) => toFileWithPath(file)));
});
}
function noIgnoredFiles(files) {
return files.filter((file) => FILES_TO_IGNORE.indexOf(file.name) === -1);
}
function fromList(items) {
if (items === null) {
return [];
}
const files = [];
for (let i = 0; i < items.length; i++) {
const file = items[i];
files.push(file);
}
return files;
}
function toFilePromises(item) {
if (typeof item.webkitGetAsEntry !== "function") {
return fromDataTransferItem(item);
}
const entry = item.webkitGetAsEntry();
if (entry && entry.isDirectory) {
return fromDirEntry(entry);
}
return fromDataTransferItem(item, entry);
}
function flatten(items) {
return items.reduce((acc, files) => [
...acc,
...Array.isArray(files) ? flatten(files) : [
files
]
], []);
}
function fromDataTransferItem(item, entry) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
if (globalThis.isSecureContext && typeof item.getAsFileSystemHandle === "function") {
const h2 = yield item.getAsFileSystemHandle();
if (h2 === null) {
throw new Error(`${item} is not a File`);
}
if (h2 !== void 0) {
const file2 = yield h2.getFile();
file2.handle = h2;
return toFileWithPath(file2);
}
}
const file = item.getAsFile();
if (!file) {
throw new Error(`${item} is not a File`);
}
const fwp = toFileWithPath(file, (_a = entry === null || entry === void 0 ? void 0 : entry.fullPath) !== null && _a !== void 0 ? _a : void 0);
return fwp;
});
}
function fromEntry(entry) {
return __awaiter(this, void 0, void 0, function* () {
return entry.isDirectory ? fromDirEntry(entry) : fromFileEntry(entry);
});
}
function fromDirEntry(entry) {
const reader = entry.createReader();
return new Promise((resolve, reject) => {
const entries = [];
function readEntries() {
reader.readEntries((batch2) => __awaiter(this, void 0, void 0, function* () {
if (!batch2.length) {
try {
const files = yield Promise.all(entries);
resolve(files);
} catch (err) {
reject(err);
}
} else {
const items = Promise.all(batch2.map(fromEntry));
entries.push(items);
readEntries();
}
}), (err) => {
reject(err);
});
}
readEntries();
});
}
function fromFileEntry(entry) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
entry.file((file) => {
const fwp = toFileWithPath(file, entry.fullPath);
resolve(fwp);
}, (err) => {
reject(err);
});
});
});
}
var _default = function(file, acceptedFiles) {
if (file && acceptedFiles) {
var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(",");
if (acceptedFilesArray.length === 0) {
return true;
}
var fileName = file.name || "";
var mimeType = (file.type || "").toLowerCase();
var baseMimeType = mimeType.replace(/\/.*$/, "");
return acceptedFilesArray.some(function(type) {
var validType = type.trim().toLowerCase();
if (validType.charAt(0) === ".") {
return fileName.toLowerCase().endsWith(validType);
} else if (validType.endsWith("/*")) {
return baseMimeType === validType.replace(/\/.*$/, "");
}
return mimeType === validType;
});
}
return true;
};
function _toConsumableArray$1(arr) {
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
}
function _nonIterableSpread$1() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _iterableToArray$1(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _arrayWithoutHoles$1(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
}
function ownKeys$2(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread$2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys$2(Object(source), true).forEach(function(key) {
_defineProperty$2(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty$2(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _slicedToArray$1(arr, i) {
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
}
function _nonIterableRest$1() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray$1(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
var n2 = Object.prototype.toString.call(o).slice(8, -1);
if (n2 === "Object" && o.constructor) n2 = o.constructor.name;
if (n2 === "Map" || n2 === "Set") return Array.from(o);
if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$1(o, minLen);
}
function _arrayLikeToArray$1(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];
}
return arr2;
}
function _iterableToArrayLimit$1(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _arrayWithHoles$1(arr) {
if (Array.isArray(arr)) return arr;
}
var accepts = typeof _default === "function" ? _default : _default.default;
var FILE_INVALID_TYPE = "file-invalid-type";
var FILE_TOO_LARGE = "file-too-large";
var FILE_TOO_SMALL = "file-too-small";
var TOO_MANY_FILES = "too-many-files";
var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr2() {
var accept = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
var acceptArr = accept.split(",");
var msg = acceptArr.length > 1 ? "one of ".concat(acceptArr.join(", ")) : acceptArr[0];
return {
code: FILE_INVALID_TYPE,
message: "File type must be ".concat(msg)
};
};
var getTooLargeRejectionErr = function getTooLargeRejectionErr2(maxSize) {
return {
code: FILE_TOO_LARGE,
message: "File is larger than ".concat(maxSize, " ").concat(maxSize === 1 ? "byte" : "bytes")
};
};
var getTooSmallRejectionErr = function getTooSmallRejectionErr2(minSize) {
return {
code: FILE_TOO_SMALL,
message: "File is smaller than ".concat(minSize, " ").concat(minSize === 1 ? "byte" : "bytes")
};
};
var TOO_MANY_FILES_REJECTION = {
code: TOO_MANY_FILES,
message: "Too many files"
};
function isDataTransferItemWithEmptyType(file) {
return file.type === "" && typeof file.getAsFile === "function";
}
function fileAccepted(file, accept) {
var isAcceptable = file.type === "application/x-moz-file" || accepts(file, accept) || isDataTransferItemWithEmptyType(file);
return [
isAcceptable,
isAcceptable ? null : getInvalidTypeRejectionErr(accept)
];
}
function fileMatchSize(file, minSize, maxSize) {
if (isDefined(file.size)) {
if (isDefined(minSize) && isDefined(maxSize)) {
if (file.size > maxSize) return [
false,
getTooLargeRejectionErr(maxSize)
];
if (file.size < minSize) return [
false,
getTooSmallRejectionErr(minSize)
];
} else if (isDefined(minSize) && file.size < minSize) return [
false,
getTooSmallRejectionErr(minSize)
];
else if (isDefined(maxSize) && file.size > maxSize) return [
false,
getTooLargeRejectionErr(maxSize)
];
}
return [
true,
null
];
}
function isDefined(value) {
return value !== void 0 && value !== null;
}
function allFilesAccepted(_ref) {
var files = _ref.files, accept = _ref.accept, minSize = _ref.minSize, maxSize = _ref.maxSize, multiple = _ref.multiple, maxFiles = _ref.maxFiles, validator = _ref.validator;
if (!multiple && files.length > 1 || multiple && maxFiles >= 1 && files.length > maxFiles) {
return false;
}
return files.every(function(file) {
var _fileAccepted = fileAccepted(file, accept), _fileAccepted2 = _slicedToArray$1(_fileAccepted, 1), accepted = _fileAccepted2[0];
var _fileMatchSize = fileMatchSize(file, minSize, maxSize), _fileMatchSize2 = _slicedToArray$1(_fileMatchSize, 1), sizeMatch = _fileMatchSize2[0];
var customErrors = validator ? validator(file) : null;
return accepted && sizeMatch && !customErrors;
});
}
function isPropagationStopped(event) {
if (typeof event.isPropagationStopped === "function") {
return event.isPropagationStopped();
} else if (typeof event.cancelBubble !== "undefined") {
return event.cancelBubble;
}
return false;
}
function isEvtWithFiles(event) {
if (!event.dataTransfer) {
return !!event.target && !!event.target.files;
}
return Array.prototype.some.call(event.dataTransfer.types, function(type) {
return type === "Files" || type === "application/x-moz-file";
});
}
function onDocumentDragOver(event) {
event.preventDefault();
}
function isIe(userAgent) {
return userAgent.indexOf("MSIE") !== -1 || userAgent.indexOf("Trident/") !== -1;
}
function isEdge(userAgent) {
return userAgent.indexOf("Edge/") !== -1;
}
function isIeOrEdge() {
var userAgent = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.navigator.userAgent;
return isIe(userAgent) || isEdge(userAgent);
}
function composeEventHandlers() {
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
fns[_key] = arguments[_key];
}
return function(event) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
return fns.some(function(fn) {
if (!isPropagationStopped(event) && fn) {
fn.apply(void 0, [
event
].concat(args));
}
return isPropagationStopped(event);
});
};
}
function canUseFileSystemAccessAPI() {
return "showOpenFilePicker" in window;
}
function pickerOptionsFromAccept(accept) {
if (isDefined(accept)) {
var acceptForPicker = Object.entries(accept).filter(function(_ref2) {
var _ref3 = _slicedToArray$1(_ref2, 2), mimeType = _ref3[0], ext = _ref3[1];
var ok = true;
if (!isMIMEType(mimeType)) {
console.warn('Skipped "'.concat(mimeType, '" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.'));
ok = false;
}
if (!Array.isArray(ext) || !ext.every(isExt)) {
console.warn('Skipped "'.concat(mimeType, '" because an invalid file extension was provided.'));
ok = false;
}
return ok;
}).reduce(function(agg, _ref4) {
var _ref5 = _slicedToArray$1(_ref4, 2), mimeType = _ref5[0], ext = _ref5[1];
return _objectSpread$2(_objectSpread$2({}, agg), {}, _defineProperty$2({}, mimeType, ext));
}, {});
return [
{
description: "Files",
accept: acceptForPicker
}
];
}
return accept;
}
function acceptPropAsAcceptAttr(accept) {
if (isDefined(accept)) {
return Object.entries(accept).reduce(function(a, _ref6) {
var _ref7 = _slicedToArray$1(_ref6, 2), mimeType = _ref7[0], ext = _ref7[1];
return [].concat(_toConsumableArray$1(a), [
mimeType
], _toConsumableArray$1(ext));
}, []).filter(function(v2) {
return isMIMEType(v2) || isExt(v2);
}).join(",");
}
return void 0;
}
function isAbort(v2) {
return v2 instanceof DOMException && (v2.name === "AbortError" || v2.code === v2.ABORT_ERR);
}
function isSecurityError(v2) {
return v2 instanceof DOMException && (v2.name === "SecurityError" || v2.code === v2.SECURITY_ERR);
}
function isMIMEType(v2) {
return v2 === "audio/*" || v2 === "video/*" || v2 === "image/*" || v2 === "text/*" || v2 === "application/*" || /\w+\/[-+.\w]+/g.test(v2);
}
function isExt(v2) {
return /^.*\.[\w]+$/.test(v2);
}
var _excluded$K = [
"children"
], _excluded2$8 = [
"open"
], _excluded3$3 = [
"refKey",
"role",
"onKeyDown",
"onFocus",
"onBlur",
"onClick",
"onDragEnter",
"onDragOver",
"onDragLeave",
"onDrop"
], _excluded4 = [
"refKey",
"onChange",
"onClick"
];
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n2 = Object.prototype.toString.call(o).slice(8, -1);
if (n2 === "Object" && o.constructor) n2 = o.constructor.name;
if (n2 === "Map" || n2 === "Set") return Array.from(o);
if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) 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];
}
return arr2;
}
function _iterableToArrayLimit(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function ownKeys$1(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread$1(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys$1(Object(source), true).forEach(function(key) {
_defineProperty$1(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty$1(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectWithoutProperties$1(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose$1(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _objectWithoutPropertiesLoose$1(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
var Dropzone = __mf_14(function(_ref, ref) {
var children = _ref.children, params = _objectWithoutProperties$1(_ref, _excluded$K);
var _useDropzone = useDropzone(params), open = _useDropzone.open, props = _objectWithoutProperties$1(_useDropzone, _excluded2$8);
__mf_26(ref, function() {
return {
open
};
}, [
open
]);
return React.createElement(__mf_2, null, children(_objectSpread$1(_objectSpread$1({}, props), {}, {
open
})));
});
Dropzone.displayName = "Dropzone";
var defaultProps$1 = {
disabled: false,
getFilesFromEvent: fromEvent,
maxSize: Infinity,
minSize: 0,
multiple: true,
maxFiles: 0,
preventDropOnDocument: true,
noClick: false,
noKeyboard: false,
noDrag: false,
noDragEventsBubbling: false,
validator: null,
useFsAccessApi: false,
autoFocus: false
};
Dropzone.defaultProps = defaultProps$1;
Dropzone.propTypes = {
children: PropTypes.func,
accept: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),
multiple: PropTypes.bool,
preventDropOnDocument: PropTypes.bool,
noClick: PropTypes.bool,
noKeyboard: PropTypes.bool,
noDrag: PropTypes.bool,
noDragEventsBubbling: PropTypes.bool,
minSize: PropTypes.number,
maxSize: PropTypes.number,
maxFiles: PropTypes.number,
disabled: PropTypes.bool,
getFilesFromEvent: PropTypes.func,
onFileDialogCancel: PropTypes.func,
onFileDialogOpen: PropTypes.func,
useFsAccessApi: PropTypes.bool,
autoFocus: PropTypes.bool,
onDragEnter: PropTypes.func,
onDragLeave: PropTypes.func,
onDragOver: PropTypes.func,
onDrop: PropTypes.func,
onDropAccepted: PropTypes.func,
onDropRejected: PropTypes.func,
onError: PropTypes.func,
validator: PropTypes.func
};
var initialState = {
isFocused: false,
isFileDialogActive: false,
isDragActive: false,
isDragAccept: false,
isDragReject: false,
isDragGlobal: false,
acceptedFiles: [],
fileRejections: []
};
function useDropzone() {
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
var _defaultProps$props = _objectSpread$1(_objectSpread$1({}, defaultProps$1), props), accept = _defaultProps$props.accept, disabled = _defaultProps$props.disabled, getFilesFromEvent = _defaultProps$props.getFilesFromEvent, maxSize = _defaultProps$props.maxSize, minSize = _defaultProps$props.minSize, multiple = _defaultProps$props.multiple, maxFiles = _defaultProps$props.maxFiles, onDragEnter = _defaultProps$props.onDragEnter, onDragLeave = _defaultProps$props.onDragLeave, onDragOver = _defaultProps$props.onDragOver, onDrop = _defaultProps$props.onDrop, onDropAccepted = _defaultProps$props.onDropAccepted, onDropRejected = _defaultProps$props.onDropRejected, onFileDialogCancel = _defaultProps$props.onFileDialogCancel, onFileDialogOpen = _defaultProps$props.onFileDialogOpen, useFsAccessApi = _defaultProps$props.useFsAccessApi, autoFocus = _defaultProps$props.autoFocus, preventDropOnDocument = _defaultProps$props.preventDropOnDocument, noClick = _defaultProps$props.noClick, noKeyboard = _defaultProps$props.noKeyboard, noDrag = _defaultProps$props.noDrag, noDragEventsBubbling = _defaultProps$props.noDragEventsBubbling, onError = _defaultProps$props.onError, validator = _defaultProps$props.validator;
var acceptAttr = __mf_29(function() {
return acceptPropAsAcceptAttr(accept);
}, [
accept
]);
var pickerTypes = __mf_29(function() {
return pickerOptionsFromAccept(accept);
}, [
accept
]);
var onFileDialogOpenCb = __mf_29(function() {
return typeof onFileDialogOpen === "function" ? onFileDialogOpen : noop$3;
}, [
onFileDialogOpen
]);
var onFileDialogCancelCb = __mf_29(function() {
return typeof onFileDialogCancel === "function" ? onFileDialogCancel : noop$3;
}, [
onFileDialogCancel
]);
var rootRef = __mf_31(null);
var inputRef = __mf_31(null);
var _useReducer = __mf_30(reducer$1, initialState), _useReducer2 = _slicedToArray(_useReducer, 2), state = _useReducer2[0], dispatch = _useReducer2[1];
var isFocused = state.isFocused, isFileDialogActive = state.isFileDialogActive;
var fsAccessApiWorksRef = __mf_31(typeof window !== "undefined" && window.isSecureContext && useFsAccessApi && canUseFileSystemAccessAPI());
var onWindowFocus = function onWindowFocus2() {
if (!fsAccessApiWorksRef.current && isFileDialogActive) {
setTimeout(function() {
if (inputRef.current) {
var files = inputRef.current.files;
if (!files.length) {
dispatch({
type: "closeDialog"
});
onFileDialogCancelCb();
}
}
}, 300);
}
};
__mf_24(function() {
window.addEventListener("focus", onWindowFocus, false);
return function() {
window.removeEventListener("focus", onWindowFocus, false);
};
}, [
inputRef,
isFileDialogActive,
onFileDialogCancelCb,
fsAccessApiWorksRef
]);
var dragTargetsRef = __mf_31([]);
var globalDragTargetsRef = __mf_31([]);
var onDocumentDrop = function onDocumentDrop2(event) {
if (rootRef.current && rootRef.current.contains(event.target)) {
return;
}
event.preventDefault();
dragTargetsRef.current = [];
};
__mf_24(function() {
if (preventDropOnDocument) {
document.addEventListener("dragover", onDocumentDragOver, false);
document.addEventListener("drop", onDocumentDrop, false);
}
return function() {
if (preventDropOnDocument) {
document.removeEventListener("dragover", onDocumentDragOver);
document.removeEventListener("drop", onDocumentDrop);
}
};
}, [
rootRef,
preventDropOnDocument
]);
__mf_24(function() {
var onDocumentDragEnter = function onDocumentDragEnter2(event) {
globalDragTargetsRef.current = [].concat(_toConsumableArray(globalDragTargetsRef.current), [
event.target
]);
if (isEvtWithFiles(event)) {
dispatch({
isDragGlobal: true,
type: "setDragGlobal"
});
}
};
var onDocumentDragLeave = function onDocumentDragLeave2(event) {
globalDragTargetsRef.current = globalDragTargetsRef.current.filter(function(el) {
return el !== event.target && el !== null;
});
if (globalDragTargetsRef.current.length > 0) {
return;
}
dispatch({
isDragGlobal: false,
type: "setDragGlobal"
});
};
var onDocumentDragEnd = function onDocumentDragEnd2() {
globalDragTargetsRef.current = [];
dispatch({
isDragGlobal: false,
type: "setDragGlobal"
});
};
var onDocumentDropGlobal = function onDocumentDropGlobal2() {
globalDragTargetsRef.current = [];
dispatch({
isDragGlobal: false,
type: "setDragGlobal"
});
};
document.addEventListener("dragenter", onDocumentDragEnter, false);
document.addEventListener("dragleave", onDocumentDragLeave, false);
document.addEventListener("dragend", onDocumentDragEnd, false);
document.addEventListener("drop", onDocumentDropGlobal, false);
return function() {
document.removeEventListener("dragenter", onDocumentDragEnter);
document.removeEventListener("dragleave", onDocumentDragLeave);
document.removeEventListener("dragend", onDocumentDragEnd);
document.removeEventListener("drop", onDocumentDropGlobal);
};
}, [
rootRef
]);
__mf_24(function() {
if (!disabled && autoFocus && rootRef.current) {
rootRef.current.focus();
}
return function() {
};
}, [
rootRef,
autoFocus,
disabled
]);
var onErrCb = __mf_20(function(e2) {
if (onError) {
onError(e2);
} else {
console.error(e2);
}
}, [
onError
]);
var onDragEnterCb = __mf_20(function(event) {
event.preventDefault();
event.persist();
stopPropagation(event);
dragTargetsRef.current = [].concat(_toConsumableArray(dragTargetsRef.current), [
event.target
]);
if (isEvtWithFiles(event)) {
Promise.resolve(getFilesFromEvent(event)).then(function(files) {
if (isPropagationStopped(event) && !noDragEventsBubbling) {
return;
}
var fileCount = files.length;
var isDragAccept = fileCount > 0 && allFilesAccepted({
files,
accept: acceptAttr,
minSize,
maxSize,
multiple,
maxFiles,
validator
});
var isDragReject = fileCount > 0 && !isDragAccept;
dispatch({
isDragAccept,
isDragReject,
isDragActive: true,
type: "setDraggedFiles"
});
if (onDragEnter) {
onDragEnter(event);
}
}).catch(function(e2) {
return onErrCb(e2);
});
}
}, [
getFilesFromEvent,
onDragEnter,
onErrCb,
noDragEventsBubbling,
acceptAttr,
minSize,
maxSize,
multiple,
maxFiles,
validator
]);
var onDragOverCb = __mf_20(function(event) {
event.preventDefault();
event.persist();
stopPropagation(event);
var hasFiles = isEvtWithFiles(event);
if (hasFiles && event.dataTransfer) {
try {
event.dataTransfer.dropEffect = "copy";
} catch (_unused) {
}
}
if (hasFiles && onDragOver) {
onDragOver(event);
}
return false;
}, [
onDragOver,
noDragEventsBubbling
]);
var onDragLeaveCb = __mf_20(function(event) {
event.preventDefault();
event.persist();
stopPropagation(event);
var targets = dragTargetsRef.current.filter(function(target) {
return rootRef.current && rootRef.current.contains(target);
});
var targetIdx = targets.indexOf(event.target);
if (targetIdx !== -1) {
targets.splice(targetIdx, 1);
}
dragTargetsRef.current = targets;
if (targets.length > 0) {
return;
}
dispatch({
type: "setDraggedFiles",
isDragActive: false,
isDragAccept: false,
isDragReject: false
});
if (isEvtWithFiles(event) && onDragLeave) {
onDragLeave(event);
}
}, [
rootRef,
onDragLeave,
noDragEventsBubbling
]);
var setFiles = __mf_20(function(files, event) {
var acceptedFiles = [];
var fileRejections = [];
files.forEach(function(file) {
var _fileAccepted = fileAccepted(file, acceptAttr), _fileAccepted2 = _slicedToArray(_fileAccepted, 2), accepted = _fileAccepted2[0], acceptError = _fileAccepted2[1];
var _fileMatchSize = fileMatchSize(file, minSize, maxSize), _fileMatchSize2 = _slicedToArray(_fileMatchSize, 2), sizeMatch = _fileMatchSize2[0], sizeError = _fileMatchSize2[1];
var customErrors = validator ? validator(file) : null;
if (accepted && sizeMatch && !customErrors) {
acceptedFiles.push(file);
} else {
var errors = [
acceptError,
sizeError
];
if (customErrors) {
errors = errors.concat(customErrors);
}
fileRejections.push({
file,
errors: errors.filter(function(e2) {
return e2;
})
});
}
});
if (!multiple && acceptedFiles.length > 1 || multiple && maxFiles >= 1 && acceptedFiles.length > maxFiles) {
acceptedFiles.forEach(function(file) {
fileRejections.push({
file,
errors: [
TOO_MANY_FILES_REJECTION
]
});
});
acceptedFiles.splice(0);
}
dispatch({
acceptedFiles,
fileRejections,
isDragReject: fileRejections.length > 0,
type: "setFiles"
});
if (onDrop) {
onDrop(acceptedFiles, fileRejections, event);
}
if (fileRejections.length > 0 && onDropRejected) {
onDropRejected(fileRejections, event);
}
if (acceptedFiles.length > 0 && onDropAccepted) {
onDropAccepted(acceptedFiles, event);
}
}, [
dispatch,
multiple,
acceptAttr,
minSize,
maxSize,
maxFiles,
onDrop,
onDropAccepted,
onDropRejected,
validator
]);
var onDropCb = __mf_20(function(event) {
event.preventDefault();
event.persist();
stopPropagation(event);
dragTargetsRef.current = [];
if (isEvtWithFiles(event)) {
Promise.resolve(getFilesFromEvent(event)).then(function(files) {
if (isPropagationStopped(event) && !noDragEventsBubbling) {
return;
}
setFiles(files, event);
}).catch(function(e2) {
return onErrCb(e2);
});
}
dispatch({
type: "reset"
});
}, [
getFilesFromEvent,
setFiles,
onErrCb,
noDragEventsBubbling
]);
var openFileDialog = __mf_20(function() {
if (fsAccessApiWorksRef.current) {
dispatch({
type: "openDialog"
});
onFileDialogOpenCb();
var opts = {
multiple,
types: pickerTypes
};
window.showOpenFilePicker(opts).then(function(handles) {
return getFilesFromEvent(handles);
}).then(function(files) {
setFiles(files, null);
dispatch({
type: "closeDialog"
});
}).catch(function(e2) {
if (isAbort(e2)) {
onFileDialogCancelCb(e2);
dispatch({
type: "closeDialog"
});
} else if (isSecurityError(e2)) {
fsAccessApiWorksRef.current = false;
if (inputRef.current) {
inputRef.current.value = null;
inputRef.current.click();
} else {
onErrCb(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."));
}
} else {
onErrCb(e2);
}
});
return;
}
if (inputRef.current) {
dispatch({
type: "openDialog"
});
onFileDialogOpenCb();
inputRef.current.value = null;
inputRef.current.click();
}
}, [
dispatch,
onFileDialogOpenCb,
onFileDialogCancelCb,
useFsAccessApi,
setFiles,
onErrCb,
pickerTypes,
multiple
]);
var onKeyDownCb = __mf_20(function(event) {
if (!rootRef.current || !rootRef.current.isEqualNode(event.target)) {
return;
}
if (event.key === " " || event.key === "Enter" || event.keyCode === 32 || event.keyCode === 13) {
event.preventDefault();
openFileDialog();
}
}, [
rootRef,
openFileDialog
]);
var onFocusCb = __mf_20(function() {
dispatch({
type: "focus"
});
}, []);
var onBlurCb = __mf_20(function() {
dispatch({
type: "blur"
});
}, []);
var onClickCb = __mf_20(function() {
if (noClick) {
return;
}
if (isIeOrEdge()) {
setTimeout(openFileDialog, 0);
} else {
openFileDialog();
}
}, [
noClick,
openFileDialog
]);
var composeHandler = function composeHandler2(fn) {
return disabled ? null : fn;
};
var composeKeyboardHandler = function composeKeyboardHandler2(fn) {
return noKeyboard ? null : composeHandler(fn);
};
var composeDragHandler = function composeDragHandler2(fn) {
return noDrag ? null : composeHandler(fn);
};
var stopPropagation = function stopPropagation2(event) {
if (noDragEventsBubbling) {
event.stopPropagation();
}
};
var getRootProps = __mf_29(function() {
return function() {
var _ref2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref2$refKey = _ref2.refKey, refKey = _ref2$refKey === void 0 ? "ref" : _ref2$refKey, role = _ref2.role, onKeyDown = _ref2.onKeyDown, onFocus = _ref2.onFocus, onBlur = _ref2.onBlur, onClick = _ref2.onClick, onDragEnter2 = _ref2.onDragEnter, onDragOver2 = _ref2.onDragOver, onDragLeave2 = _ref2.onDragLeave, onDrop2 = _ref2.onDrop, rest = _objectWithoutProperties$1(_ref2, _excluded3$3);
return _objectSpread$1(_objectSpread$1(_defineProperty$1({
onKeyDown: composeKeyboardHandler(composeEventHandlers(onKeyDown, onKeyDownCb)),
onFocus: composeKeyboardHandler(composeEventHandlers(onFocus, onFocusCb)),
onBlur: composeKeyboardHandler(composeEventHandlers(onBlur, onBlurCb)),
onClick: composeHandler(composeEventHandlers(onClick, onClickCb)),
onDragEnter: composeDragHandler(composeEventHandlers(onDragEnter2, onDragEnterCb)),
onDragOver: composeDragHandler(composeEventHandlers(onDragOver2, onDragOverCb)),
onDragLeave: composeDragHandler(composeEventHandlers(onDragLeave2, onDragLeaveCb)),
onDrop: composeDragHandler(composeEventHandlers(onDrop2, onDropCb)),
role: typeof role === "string" && role !== "" ? role : "presentation"
}, refKey, rootRef), !disabled && !noKeyboard ? {
tabIndex: 0
} : {}), rest);
};
}, [
rootRef,
onKeyDownCb,
onFocusCb,
onBlurCb,
onClickCb,
onDragEnterCb,
onDragOverCb,
onDragLeaveCb,
onDropCb,
noKeyboard,
noDrag,
disabled
]);
var onInputElementClick = __mf_20(function(event) {
event.stopPropagation();
}, []);
var getInputProps = __mf_29(function() {
return function() {
var _ref3 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref3$refKey = _ref3.refKey, refKey = _ref3$refKey === void 0 ? "ref" : _ref3$refKey, onChange = _ref3.onChange, onClick = _ref3.onClick, rest = _objectWithoutProperties$1(_ref3, _excluded4);
var inputProps = _defineProperty$1({
accept: acceptAttr,
multiple,
type: "file",
style: {
border: 0,
clip: "rect(0, 0, 0, 0)",
clipPath: "inset(50%)",
height: "1px",
margin: "0 -1px -1px 0",
overflow: "hidden",
padding: 0,
position: "absolute",
width: "1px",
whiteSpace: "nowrap"
},
onChange: composeHandler(composeEventHandlers(onChange, onDropCb)),
onClick: composeHandler(composeEventHandlers(onClick, onInputElementClick)),
tabIndex: -1
}, refKey, inputRef);
return _objectSpread$1(_objectSpread$1({}, inputProps), rest);
};
}, [
inputRef,
accept,
multiple,
onDropCb,
disabled
]);
return _objectSpread$1(_objectSpread$1({}, state), {}, {
isFocused: isFocused && !disabled,
getRootProps,
getInputProps,
rootRef,
inputRef,
open: composeHandler(openFileDialog)
});
}
function reducer$1(state, action) {
switch (action.type) {
case "focus":
return _objectSpread$1(_objectSpread$1({}, state), {}, {
isFocused: true
});
case "blur":
return _objectSpread$1(_objectSpread$1({}, state), {}, {
isFocused: false
});
case "openDialog":
return _objectSpread$1(_objectSpread$1({}, initialState), {}, {
isFileDialogActive: true
});
case "closeDialog":
return _objectSpread$1(_objectSpread$1({}, state), {}, {
isFileDialogActive: false
});
case "setDraggedFiles":
return _objectSpread$1(_objectSpread$1({}, state), {}, {
isDragActive: action.isDragActive,
isDragAccept: action.isDragAccept,
isDragReject: action.isDragReject
});
case "setFiles":
return _objectSpread$1(_objectSpread$1({}, state), {}, {
acceptedFiles: action.acceptedFiles,
fileRejections: action.fileRejections,
isDragReject: action.isDragReject
});
case "setDragGlobal":
return _objectSpread$1(_objectSpread$1({}, state), {}, {
isDragGlobal: action.isDragGlobal
});
case "reset":
return _objectSpread$1({}, initialState);
default:
return state;
}
}
function noop$3() {
}
const IMAGE_TYPES = [
".png",
".jpg",
".svg",
".gif",
".apng",
".avif",
".webp",
".jpeg",
".bmp",
".ico",
".tiff",
".tif"
];
UploadFile = (props) => {
const [fileName, setFileName] = __mf_32("");
const [fileData, setFileData] = __mf_32(null);
const [working, setWorking] = __mf_32(false);
const [error, setError] = __mf_32("");
const onDrop = __mf_20((acceptedFiles, fileRejections) => {
if (acceptedFiles == null ? void 0 : acceptedFiles.length) {
setWorking(true);
if (error) {
setError("");
}
const reader = new FileReader();
setFileName(acceptedFiles[0].name);
reader.onload = (evt) => {
setWorking(false);
setFileData(evt.target.result);
props.onUpload(acceptedFiles[0].name, evt.target.result);
};
reader.readAsDataURL(acceptedFiles[0]);
}
if (fileRejections == null ? void 0 : fileRejections.length) {
fileRejections[0].errors.forEach((err) => {
if (err.code === "file-too-large") {
setError(__mf_2$1.t("File too large"));
} else if (err.code === "file-invalid-type") {
setError(__mf_2$1.t("Invalid file type"));
} else {
setError(`Error: ${err.message}`);
}
setTimeout(() => {
if (error) {
setError("");
}
}, 3e3);
});
}
}, [
error
]);
const { getRootProps, getInputProps, isDragActive } = useDropzone({
onDrop,
maxFiles: 1,
maxSize: props.maxSize || void 0,
accept: props.accept
});
return jsxRuntimeExports.jsxs("div", {
...getRootProps(),
style: {
display: "flex",
alignItems: "center",
justifyContent: "center",
width: "100%",
height: 200,
borderRadius: 4,
boxSizing: "border-box",
borderStyle: "dashed",
borderWidth: 1,
borderColor: isDragActive ? props.themeType === "dark" ? "lightgreen" : "green" : "inherit"
},
children: [
error ? jsxRuntimeExports.jsx("div", {
style: {
color: "#a90000"
},
children: error
}) : null,
props.disabled || working ? null : jsxRuntimeExports.jsx("input", {
...getInputProps()
}),
working ? jsxRuntimeExports.jsx(__mf_27, {}) : jsxRuntimeExports.jsx("p", {
style: {
textAlign: "center",
color: isDragActive ? props.themeType === "dark" ? "lightgreen" : "green" : "inherit"
},
children: fileName ? jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
children: [
jsxRuntimeExports.jsx("div", {
children: fileName
}),
fileName.endsWith(".zip") ? jsxRuntimeExports.jsx(__mf_3771, {}) : null,
IMAGE_TYPES.find((ext) => fileName.toLowerCase().endsWith(ext)) ? jsxRuntimeExports.jsx("img", {
src: fileData,
alt: "uploaded",
style: {
maxWidth: 100,
maxHeight: 100
}
}) : null,
fileData ? jsxRuntimeExports.jsxs("div", {
style: {
fontSize: 10,
opacity: 0.5
},
children: [
"(",
__mf_70.formatBytes(fileData.length),
")"
]
}) : null
]
}) : props.instruction || `${__mf_2$1.t("Drop the files here ...")} ${props.maxSize ? __mf_2$1.t("(Maximal file size is %s)", __mf_70.formatBytes(props.maxSize)) : ""}`
})
]
});
};
const MAX_ICONS = 250;
const styles$4 = {
dialog: {
height: "100%"
},
iconName: {
fontSize: 10,
width: 50,
overflow: "hidden",
textOverflow: "ellipsis"
},
iconDiv: (theme) => ({
margin: 0,
textAlign: "center",
cursor: "pointer",
padding: 2,
borderRadius: 2,
"&:hover": {
backgroundColor: theme.palette.secondary.main
}
}),
icon: (theme) => ({
width: 48,
height: 48,
color: theme.palette.text.primary
}),
iconSelected: (theme) => ({
backgroundColor: theme.palette.primary.main,
"&:hover": {
backgroundColor: theme.palette.primary.light
}
}),
typeName: {
whiteSpace: "nowrap"
}
};
const ICON_TYPES = [
"baseline",
"outline",
"round",
"sharp",
"twotone",
"knx-uf",
"upload"
];
function getText$1(text, lang) {
if (typeof text === "string") {
return text;
}
return text[lang] || text.en;
}
MaterialIconSelector = class extends __mf_1 {
list = {};
visibilityTimer = null;
index = null;
filterTimer = null;
constructor(props) {
super(props);
const iconType = this.props.iconType || window.localStorage.getItem("vis.icon.type") || ICON_TYPES[0];
this.state = {
listLoaded: false,
selectedIcon: "",
filter: this.props.filter || window.localStorage.getItem("vis.icon.filter") || "",
iconType,
iconTypeLoaded: {},
filtered: [],
loading: iconType !== "upload",
page: 1,
maxPages: 0,
additionalSetsInfo: {},
anyIconSetLogo: !!Object.keys(this.props.additionalSets || {}).find((iconSet) => this.props.additionalSets[iconSet].icon)
};
}
setStateAsync(state) {
return new Promise((resolve) => {
this.setState(state, () => resolve());
});
}
async loadIconSet(type) {
var _a;
if (!this.list[type]) {
await this.setStateAsync({
loading: true
});
this.list[type] = true;
if (type === "customIcons") {
try {
this.list[type] = await fetch(this.props.customIcons).then((res) => res.json());
} catch (e2) {
this.list[type] = {};
console.error(`Cannot load custom icons from ${this.props.customIcons}: ${e2}`);
}
} else if ((_a = this.props.additionalSets) == null ? void 0 : _a[type]) {
this.list[type] = await fetch(this.props.additionalSets[type].url).then((res) => res.json()).then((data) => {
const list = {};
Object.keys(data).forEach((iconName) => {
list[iconName] = data[iconName].src;
});
const additionalSetsInfo = {
...this.state.additionalSetsInfo
};
additionalSetsInfo[type] = {};
const lang = __mf_2$1.getLanguage();
Object.keys(data).forEach((iconName) => {
additionalSetsInfo[type][iconName] = {
name: getText$1(data[iconName].name, lang),
keywords: data[iconName].words
};
});
this.setState({
additionalSetsInfo
});
return list;
}).catch(async (e2) => {
console.error(`Cannot load icons set "${type}" from ${this.props.additionalSets[type].url}: ${e2}`);
type = "baseline";
return await fetch(`./material-icons/${type}.json`).then((res) => res.json());
});
} else if (ICON_TYPES.includes(type)) {
this.list[type] = await fetch(`./material-icons/${type}.json`).then((res) => res.json());
} else {
type = "baseline";
this.list[type] = await fetch(`./material-icons/${type}.json`).then((res) => res.json());
}
if (typeof this.list[type] !== "boolean") {
const typedList = this.list[type];
const icons = Object.keys(typedList);
for (let i = 0; i < icons.length; i++) {
const icon = icons[i];
typedList[icon] = `data:image/svg+xml;base64,${typedList[icon]}`;
}
}
this.setState({
iconType: type,
iconTypeLoaded: {
...this.state.iconTypeLoaded,
[type]: true
},
filtered: [],
loading: false
}, () => this.applyFilter(true));
}
return type;
}
loadList() {
if (!this.state.listLoaded) {
void fetch("./material-icons/index.json").then((res) => res.json()).then(async (index) => {
this.index = index;
const iconType = await this.loadIconSet(this.state.iconType);
this.setState({
listLoaded: true,
iconType
}, () => this.applyFilter(true));
});
}
}
componentWillUnmount() {
if (this.filterTimer) {
clearTimeout(this.filterTimer);
this.filterTimer = null;
}
if (this.visibilityTimer) {
clearTimeout(this.visibilityTimer);
this.visibilityTimer = null;
}
}
applyFilter(filter) {
let timeout = 200;
if (filter === true) {
timeout = 0;
filter = void 0;
}
if (this.filterTimer) {
clearTimeout(this.filterTimer);
}
this.filterTimer = setTimeout(() => {
var _a, _b;
this.filterTimer = null;
let filtered;
filter = filter === void 0 ? this.state.filter : filter;
if (filter) {
filter = filter.toLowerCase();
if ((_a = this.props.additionalSets) == null ? void 0 : _a[this.state.iconType]) {
filtered = Object.keys(this.list[this.state.iconType]).filter((icon) => {
var _a2, _b2, _c, _d;
const info = (_b2 = (_a2 = this.state.additionalSetsInfo) == null ? void 0 : _a2[this.state.iconType]) == null ? void 0 : _b2[icon];
return icon.includes(filter) || ((_c = info == null ? void 0 : info.name) == null ? void 0 : _c.toLowerCase().includes(filter)) || ((_d = info == null ? void 0 : info.keywords) == null ? void 0 : _d.find((tag) => tag.toLowerCase().includes(filter)));
});
} else if (this.state.iconType === "knx-uf") {
filtered = Object.keys(this.list["knx-uf"]).filter((icon) => icon.includes(filter));
} else if (this.state.iconType === "customIcons") {
filtered = Object.keys(this.list.customIcons).filter((icon) => icon.includes(filter));
} else {
filtered = this.index.filter((icon) => {
var _a2, _b2;
return !((_a2 = icon.unsupported_families) == null ? void 0 : _a2.includes(this.state.iconType)) && (icon.name.includes(filter) || ((_b2 = icon.tags) == null ? void 0 : _b2.find((tag) => tag.includes(filter))));
}).map((icon) => icon.name);
}
} else if ((_b = this.props.additionalSets) == null ? void 0 : _b[this.state.iconType]) {
filtered = Object.keys(this.list[this.state.iconType]);
} else if (this.state.iconType === "knx-uf") {
filtered = Object.keys(this.list["knx-uf"]);
} else if (this.state.iconType === "customIcons") {
filtered = Object.keys(this.list.customIcons);
} else {
filtered = this.index.filter((icon) => !icon.unsupported_families || !icon.unsupported_families.includes(this.state.iconType)).map((icon) => icon.name);
}
this.setState({
filtered,
page: 1,
maxPages: Math.ceil(filtered.length / MAX_ICONS)
});
}, timeout);
}
componentDidMount() {
this.loadList();
this.visibilityTimer = setTimeout(() => {
this.visibilityTimer = null;
const el = window.document.getElementById(`vis-material-icon-type-${this.state.iconType}`);
el == null ? void 0 : el.scrollIntoView({
block: "nearest"
});
}, 200);
}
onSelect() {
if (this.state.selectedIcon && this.state.selectedIcon.startsWith("data:")) {
this.props.onClose(this.state.selectedIcon);
} else {
const typedList = this.list[this.state.iconType];
if (typedList && typedList !== true) {
this.props.onClose(typedList[this.state.selectedIcon]);
}
}
}
renderIcons() {
var _a, _b, _c;
const iconStyle = this.props.customColor && this.state.iconType === "customIcons" ? {
color: this.props.customColor
} : {};
const icons = [];
const typedIconList = this.list[this.state.iconType];
if (typeof typedIconList === "boolean") {
return null;
}
const additionalInfo = (_a = this.state.additionalSetsInfo) == null ? void 0 : _a[this.state.iconType];
for (let i = (this.state.page - 1) * MAX_ICONS; i < this.state.page * MAX_ICONS && i < this.state.filtered.length; i++) {
const icon = this.state.filtered[i];
const title = ((_b = additionalInfo == null ? void 0 : additionalInfo[icon]) == null ? void 0 : _b.name) || icon.replace(/_/g, " ");
const keywords = ((_c = additionalInfo == null ? void 0 : additionalInfo[icon]) == null ? void 0 : _c.keywords) ? ` (${additionalInfo[icon].keywords.join(", ")})` : "";
icons.push(jsxRuntimeExports.jsxs(__mf_14$1, {
component: "div",
sx: __mf_70.getStyle(this.props.theme, styles$4.iconDiv, this.state.selectedIcon === icon && styles$4.iconSelected),
title: title + keywords,
onClick: () => this.setState({
selectedIcon: icon
}),
onDoubleClick: () => this.setState({
selectedIcon: icon
}, () => this.onSelect()),
children: [
jsxRuntimeExports.jsx(__mf_15$1, {
src: typedIconList[icon],
style: __mf_70.getStyle(this.props.theme, styles$4.icon, iconStyle)
}),
jsxRuntimeExports.jsx("div", {
style: styles$4.iconName,
children: title
})
]
}, icon));
}
return icons;
}
render() {
return jsxRuntimeExports.jsxs(__mf_32$1, {
open: true,
maxWidth: "lg",
fullWidth: true,
sx: {
"& .MuiDialog-paper": styles$4.dialog
},
children: [
jsxRuntimeExports.jsxs(__mf_36, {
children: [
jsxRuntimeExports.jsxs("span", {
style: {
marginRight: 20
},
children: [
this.state.iconType === "knx-uf" ? "KNX UF" : this.state.iconType !== "upload" ? "Material" : "",
"\xA0Icon Selector"
]
}),
this.state.iconType !== "upload" ? jsxRuntimeExports.jsx(__mf_121, {
value: this.state.filter,
slotProps: {
input: {
startAdornment: jsxRuntimeExports.jsx(__mf_58, {
position: "start",
children: jsxRuntimeExports.jsx(__mf_7882, {})
}),
endAdornment: this.state.filter ? jsxRuntimeExports.jsx(__mf_58, {
position: "start",
children: jsxRuntimeExports.jsx(__mf_1776, {
style: {
cursor: "pointer"
},
onClick: () => {
window.localStorage.removeItem("vis.icon.filter");
this.setState({
filter: ""
}, () => this.applyFilter(true));
}
})
}) : null
}
},
variant: "standard",
onChange: (e2) => {
window.localStorage.setItem("vis.icon.filter", e2.target.value);
this.setState({
filter: e2.target.value
}, () => this.applyFilter());
},
helperText: __mf_2$1.t("material_icons_result", this.state.filtered.length)
}) : null
]
}),
jsxRuntimeExports.jsxs(__mf_34, {
style: {
overflowY: "hidden",
height: "100%"
},
children: [
!this.props.iconType ? jsxRuntimeExports.jsx("div", {
style: {
width: 160 + (this.state.anyIconSetLogo ? 32 : 0),
display: "inline-block",
verticalAlign: "top",
height: "100%",
overflowY: "auto"
},
children: jsxRuntimeExports.jsx(__mf_42, {
children: jsxRuntimeExports.jsxs(__mf_86, {
value: this.state.iconType || "baseline",
onChange: (e2) => this.setState({
iconType: e2.target.value
}),
children: [
ICON_TYPES.map((type) => jsxRuntimeExports.jsx(__mf_43, {
id: `vis-material-icon-type-${type}`,
onClick: async () => {
window.localStorage.setItem("vis.icon.type", type);
const newState = {
iconType: type
};
if (type !== "upload") {
const iconType = await this.loadIconSet(type);
if (typeof this.list[type] !== "boolean" && this.state.selectedIcon && !this.list[type][this.state.selectedIcon]) {
newState.selectedIcon = "";
}
newState.iconType = iconType;
} else {
newState.selectedIcon = "";
newState.maxPages = 0;
}
this.setState(newState, () => this.applyFilter(true));
},
value: type,
control: jsxRuntimeExports.jsx(__mf_85, {}),
label: __mf_2$1.t(`material_icons_${type}`),
sx: {
".& MuiRadioGroup-label": styles$4.typeName
}
}, type)),
this.props.additionalSets ? Object.keys(this.props.additionalSets).map((type) => jsxRuntimeExports.jsx(__mf_43, {
id: `vis-material-icon-type-${type}`,
onClick: async () => {
window.localStorage.setItem("vis.icon.type", type);
const newState = {
iconType: type
};
const iconType = await this.loadIconSet(type);
if (typeof this.list[type] !== "boolean" && this.state.selectedIcon && !this.list[type][this.state.selectedIcon]) {
newState.selectedIcon = "";
}
newState.iconType = iconType;
this.setState(newState, () => this.applyFilter(true));
},
value: type,
control: jsxRuntimeExports.jsx(__mf_85, {}),
label: jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
alignItems: "center"
},
children: [
this.props.additionalSets[type].icon ? jsxRuntimeExports.jsx(__mf_15$1, {
src: this.props.additionalSets[type].icon,
style: {
width: 24,
height: 24,
marginRight: 4
}
}) : null,
getText$1(this.props.additionalSets[type].name || type, __mf_2$1.getLanguage())
]
}),
sx: {
"& .MuiFormControlLabel-label": styles$4.typeName
}
}, type)) : null,
this.props.customIcons ? jsxRuntimeExports.jsx(__mf_43, {
id: `vis-material-icon-type-customIcons`,
onClick: async () => {
window.localStorage.setItem("vis.icon.type", "customIcons");
const iconType = await this.loadIconSet("customIcons");
const newState = {
iconType
};
if (typeof this.list.customIcons !== "boolean" && this.state.selectedIcon && !this.list.customIcons[this.state.selectedIcon]) {
newState.selectedIcon = "";
}
this.setState(newState);
},
value: "customIcons",
control: jsxRuntimeExports.jsx(__mf_85, {}),
label: __mf_2$1.t("custom_icons"),
sx: {
"& .MuiFormControlLabel-label": styles$4.typeName
}
}, "customIcons") : null
]
})
})
}) : null,
jsxRuntimeExports.jsxs("div", {
style: {
width: `calc(100% - ${160 + 20 + (this.state.anyIconSetLogo ? 32 : 0)}px)`,
display: "inline-block",
height: "100%",
overflowY: "auto",
paddingLeft: 20
},
children: [
this.state.iconType === "knx-uf" ? jsxRuntimeExports.jsxs("div", {
style: {
paddingBottom: 20
},
children: [
`${__mf_2$1.t("Source")}:`,
"\xA0",
jsxRuntimeExports.jsx("a", {
style: {
textDecoration: "none"
},
href: "https://github.com/OpenAutomationProject/knx-uf-iconset",
target: "_blank",
rel: "noreferrer",
children: "https://github.com/OpenAutomationProject/knx-uf-iconset"
})
]
}) : null,
this.state.iconType !== "upload" && !this.state.loading && this.list[this.state.iconType] && this.list[this.state.iconType] !== true ? jsxRuntimeExports.jsx("div", {
style: {
width: "100%"
},
children: jsxRuntimeExports.jsx(__mf_48, {
container: true,
spacing: 2,
style: {
width: "100%",
paddingTop: 20
},
children: this.renderIcons()
})
}) : this.state.iconType !== "upload" ? jsxRuntimeExports.jsx(__mf_61, {}) : null,
this.state.iconType === "upload" ? jsxRuntimeExports.jsxs("div", {
children: [
jsxRuntimeExports.jsxs("div", {
style: {
width: "100%",
textAlign: "center",
marginBottom: 10,
marginTop: 10
},
children: [
__mf_2$1.t("icon_upload_hint"),
jsxRuntimeExports.jsx("br", {}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "outlined",
onClick: () => window.open("https://github.com/ioBroker/ioBroker.vis-2#svg-and-currentcolor", "_blank"),
children: __mf_2$1.t("Read about currentColor in SVG")
})
]
}),
jsxRuntimeExports.jsx(UploadFile, {
themeType: this.props.themeType,
onUpload: (_name, data) => this.setState({
selectedIcon: data.toString()
}),
maxSize: 15e3,
accept: {
"image/png": [
".png"
],
"image/jpeg": [
".jpg"
],
"image/svg+xml": [
".svg"
],
"image/gif": [
".gif"
],
"image/apng": [
".apng"
],
"image/avif": [
".avif"
],
"image/webp": [
".webp"
]
}
})
]
}) : null
]
})
]
}),
jsxRuntimeExports.jsxs(__mf_33, {
children: [
this.state.maxPages > 1 && !this.state.loading ? jsxRuntimeExports.jsx("div", {
style: {
marginLeft: 160 + (this.state.anyIconSetLogo ? 32 : 0)
},
children: jsxRuntimeExports.jsx(__mf_79, {
count: this.state.maxPages,
color: "primary",
page: this.state.page,
onChange: (event, page) => this.setState({
page
})
})
}) : null,
this.state.maxPages > 1 ? jsxRuntimeExports.jsx("div", {
style: {
flexGrow: 1
}
}) : null,
this.props.value ? jsxRuntimeExports.jsx(__mf_16, {
variant: "outlined",
color: "grey",
onClick: () => this.props.onClose(""),
startIcon: jsxRuntimeExports.jsx(__mf_2326, {}),
children: __mf_2$1.t("Delete")
}) : null,
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "primary",
onClick: () => this.onSelect(),
disabled: !this.state.selectedIcon,
startIcon: jsxRuntimeExports.jsx(__mf_1671, {}),
children: __mf_2$1.t("Select")
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "grey",
onClick: () => this.props.onClose(null),
startIcon: jsxRuntimeExports.jsx(__mf_1776, {}),
children: __mf_2$1.t("Cancel")
})
]
})
]
});
}
};
window.VisMaterialIconSelector = MaterialIconSelector;
function formatProdErrorMessage(code) {
return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or use the non-minified dev environment for full errors. ";
}
var $$observable = (function() {
return typeof Symbol === "function" && Symbol.observable || "@@observable";
})();
var randomString = function randomString2() {
return Math.random().toString(36).substring(7).split("").join(".");
};
var ActionTypes = {
INIT: "@@redux/INIT" + randomString(),
REPLACE: "@@redux/REPLACE" + randomString()
};
function isPlainObject(obj) {
if (typeof obj !== "object" || obj === null) return false;
var proto = obj;
while (Object.getPrototypeOf(proto) !== null) {
proto = Object.getPrototypeOf(proto);
}
return Object.getPrototypeOf(obj) === proto;
}
function createStore$1(reducer2, preloadedState, enhancer) {
var _ref2;
if (typeof preloadedState === "function" && typeof enhancer === "function" || typeof enhancer === "function" && typeof arguments[3] === "function") {
throw new Error(formatProdErrorMessage(0));
}
if (typeof preloadedState === "function" && typeof enhancer === "undefined") {
enhancer = preloadedState;
preloadedState = void 0;
}
if (typeof enhancer !== "undefined") {
if (typeof enhancer !== "function") {
throw new Error(formatProdErrorMessage(1));
}
return enhancer(createStore$1)(reducer2, preloadedState);
}
if (typeof reducer2 !== "function") {
throw new Error(formatProdErrorMessage(2));
}
var currentReducer = reducer2;
var currentState = preloadedState;
var currentListeners = [];
var nextListeners = currentListeners;
var isDispatching = false;
function ensureCanMutateNextListeners() {
if (nextListeners === currentListeners) {
nextListeners = currentListeners.slice();
}
}
function getState() {
if (isDispatching) {
throw new Error(formatProdErrorMessage(3));
}
return currentState;
}
function subscribe(listener) {
if (typeof listener !== "function") {
throw new Error(formatProdErrorMessage(4));
}
if (isDispatching) {
throw new Error(formatProdErrorMessage(5));
}
var isSubscribed = true;
ensureCanMutateNextListeners();
nextListeners.push(listener);
return function unsubscribe() {
if (!isSubscribed) {
return;
}
if (isDispatching) {
throw new Error(formatProdErrorMessage(6));
}
isSubscribed = false;
ensureCanMutateNextListeners();
var index = nextListeners.indexOf(listener);
nextListeners.splice(index, 1);
currentListeners = null;
};
}
function dispatch(action) {
if (!isPlainObject(action)) {
throw new Error(formatProdErrorMessage(7));
}
if (typeof action.type === "undefined") {
throw new Error(formatProdErrorMessage(8));
}
if (isDispatching) {
throw new Error(formatProdErrorMessage(9));
}
try {
isDispatching = true;
currentState = currentReducer(currentState, action);
} finally {
isDispatching = false;
}
var listeners = currentListeners = nextListeners;
for (var i = 0; i < listeners.length; i++) {
var listener = listeners[i];
listener();
}
return action;
}
function replaceReducer(nextReducer) {
if (typeof nextReducer !== "function") {
throw new Error(formatProdErrorMessage(10));
}
currentReducer = nextReducer;
dispatch({
type: ActionTypes.REPLACE
});
}
function observable() {
var _ref;
var outerSubscribe = subscribe;
return _ref = {
subscribe: function subscribe2(observer) {
if (typeof observer !== "object" || observer === null) {
throw new Error(formatProdErrorMessage(11));
}
function observeState() {
if (observer.next) {
observer.next(getState());
}
}
observeState();
var unsubscribe = outerSubscribe(observeState);
return {
unsubscribe
};
}
}, _ref[$$observable] = function() {
return this;
}, _ref;
}
dispatch({
type: ActionTypes.INIT
});
return _ref2 = {
dispatch,
subscribe,
getState,
replaceReducer
}, _ref2[$$observable] = observable, _ref2;
}
function bindActionCreator(actionCreator, dispatch) {
return function() {
return dispatch(actionCreator.apply(this, arguments));
};
}
function bindActionCreators$1(actionCreators, dispatch) {
if (typeof actionCreators === "function") {
return bindActionCreator(actionCreators, dispatch);
}
if (typeof actionCreators !== "object" || actionCreators === null) {
throw new Error(formatProdErrorMessage(16));
}
var boundActionCreators = {};
for (var key in actionCreators) {
var actionCreator = actionCreators[key];
if (typeof actionCreator === "function") {
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
}
}
return boundActionCreators;
}
function compose() {
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
if (funcs.length === 0) {
return function(arg) {
return arg;
};
}
if (funcs.length === 1) {
return funcs[0];
}
return funcs.reduce(function(a, b2) {
return function() {
return a(b2.apply(void 0, arguments));
};
});
}
function applyMiddleware() {
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
middlewares[_key] = arguments[_key];
}
return function(createStore2) {
return function() {
var store2 = createStore2.apply(void 0, arguments);
var _dispatch = function dispatch() {
throw new Error(formatProdErrorMessage(15));
};
var middlewareAPI = {
getState: store2.getState,
dispatch: function dispatch() {
return _dispatch.apply(void 0, arguments);
}
};
var chain = middlewares.map(function(middleware) {
return middleware(middlewareAPI);
});
_dispatch = compose.apply(void 0, chain)(store2.dispatch);
return _objectSpread2(_objectSpread2({}, store2), {}, {
dispatch: _dispatch
});
};
};
}
var ReactReduxContext = React.createContext(null);
function defaultNoopBatch(callback) {
callback();
}
var batch = defaultNoopBatch;
var setBatch = function setBatch2(newBatch) {
return batch = newBatch;
};
var getBatch = function getBatch2() {
return batch;
};
function createListenerCollection() {
var batch2 = getBatch();
var first = null;
var last = null;
return {
clear: function clear() {
first = null;
last = null;
},
notify: function notify() {
batch2(function() {
var listener = first;
while (listener) {
listener.callback();
listener = listener.next;
}
});
},
get: function get2() {
var listeners = [];
var listener = first;
while (listener) {
listeners.push(listener);
listener = listener.next;
}
return listeners;
},
subscribe: function subscribe(callback) {
var isSubscribed = true;
var listener = last = {
callback,
next: null,
prev: last
};
if (listener.prev) {
listener.prev.next = listener;
} else {
first = listener;
}
return function unsubscribe() {
if (!isSubscribed || first === null) return;
isSubscribed = false;
if (listener.next) {
listener.next.prev = listener.prev;
} else {
last = listener.prev;
}
if (listener.prev) {
listener.prev.next = listener.next;
} else {
first = listener.next;
}
};
}
};
}
var nullListeners = {
notify: function notify() {
},
get: function get2() {
return [];
}
};
function createSubscription(store2, parentSub) {
var unsubscribe;
var listeners = nullListeners;
function addNestedSub(listener) {
trySubscribe();
return listeners.subscribe(listener);
}
function notifyNestedSubs() {
listeners.notify();
}
function handleChangeWrapper() {
if (subscription.onStateChange) {
subscription.onStateChange();
}
}
function isSubscribed() {
return Boolean(unsubscribe);
}
function trySubscribe() {
if (!unsubscribe) {
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store2.subscribe(handleChangeWrapper);
listeners = createListenerCollection();
}
}
function tryUnsubscribe() {
if (unsubscribe) {
unsubscribe();
unsubscribe = void 0;
listeners.clear();
listeners = nullListeners;
}
}
var subscription = {
addNestedSub,
notifyNestedSubs,
handleChangeWrapper,
isSubscribed,
trySubscribe,
tryUnsubscribe,
getListeners: function getListeners() {
return listeners;
}
};
return subscription;
}
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined" ? __mf_28 : __mf_24;
function Provider(_ref) {
var store2 = _ref.store, context = _ref.context, children = _ref.children;
var contextValue = __mf_29(function() {
var subscription = createSubscription(store2);
return {
store: store2,
subscription
};
}, [
store2
]);
var previousState = __mf_29(function() {
return store2.getState();
}, [
store2
]);
useIsomorphicLayoutEffect$1(function() {
var subscription = contextValue.subscription;
subscription.onStateChange = subscription.notifyNestedSubs;
subscription.trySubscribe();
if (previousState !== store2.getState()) {
subscription.notifyNestedSubs();
}
return function() {
subscription.tryUnsubscribe();
subscription.onStateChange = null;
};
}, [
contextValue,
previousState
]);
var Context = context || ReactReduxContext;
return React.createElement(Context.Provider, {
value: contextValue
}, children);
}
var _excluded$J = [
"getDisplayName",
"methodName",
"renderCountProp",
"shouldHandleStateChanges",
"storeKey",
"withRef",
"forwardRef",
"context"
], _excluded2$7 = [
"reactReduxForwardedRef"
];
var EMPTY_ARRAY = [];
var NO_SUBSCRIPTION_ARRAY = [
null,
null
];
function storeStateUpdatesReducer(state, action) {
var updateCount = state[1];
return [
action.payload,
updateCount + 1
];
}
function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
useIsomorphicLayoutEffect$1(function() {
return effectFunc.apply(void 0, effectArgs);
}, dependencies);
}
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, actualChildProps, childPropsFromStoreUpdate, notifyNestedSubs) {
lastWrapperProps.current = wrapperProps;
lastChildProps.current = actualChildProps;
renderIsScheduled.current = false;
if (childPropsFromStoreUpdate.current) {
childPropsFromStoreUpdate.current = null;
notifyNestedSubs();
}
}
function subscribeUpdates(shouldHandleStateChanges, store2, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, childPropsFromStoreUpdate, notifyNestedSubs, forceComponentUpdateDispatch) {
if (!shouldHandleStateChanges) return;
var didUnsubscribe = false;
var lastThrownError = null;
var checkForUpdates = function checkForUpdates2() {
if (didUnsubscribe) {
return;
}
var latestStoreState = store2.getState();
var newChildProps, error;
try {
newChildProps = childPropsSelector(latestStoreState, lastWrapperProps.current);
} catch (e2) {
error = e2;
lastThrownError = e2;
}
if (!error) {
lastThrownError = null;
}
if (newChildProps === lastChildProps.current) {
if (!renderIsScheduled.current) {
notifyNestedSubs();
}
} else {
lastChildProps.current = newChildProps;
childPropsFromStoreUpdate.current = newChildProps;
renderIsScheduled.current = true;
forceComponentUpdateDispatch({
type: "STORE_UPDATED",
payload: {
error
}
});
}
};
subscription.onStateChange = checkForUpdates;
subscription.trySubscribe();
checkForUpdates();
var unsubscribeWrapper = function unsubscribeWrapper2() {
didUnsubscribe = true;
subscription.tryUnsubscribe();
subscription.onStateChange = null;
if (lastThrownError) {
throw lastThrownError;
}
};
return unsubscribeWrapper;
}
var initStateUpdates = function initStateUpdates2() {
return [
null,
0
];
};
function connectAdvanced(selectorFactory, _ref) {
if (_ref === void 0) {
_ref = {};
}
var _ref2 = _ref, _ref2$getDisplayName = _ref2.getDisplayName, getDisplayName = _ref2$getDisplayName === void 0 ? function(name) {
return "ConnectAdvanced(" + name + ")";
} : _ref2$getDisplayName, _ref2$methodName = _ref2.methodName, methodName = _ref2$methodName === void 0 ? "connectAdvanced" : _ref2$methodName, _ref2$renderCountProp = _ref2.renderCountProp, renderCountProp = _ref2$renderCountProp === void 0 ? void 0 : _ref2$renderCountProp, _ref2$shouldHandleSta = _ref2.shouldHandleStateChanges, shouldHandleStateChanges = _ref2$shouldHandleSta === void 0 ? true : _ref2$shouldHandleSta, _ref2$storeKey = _ref2.storeKey, storeKey = _ref2$storeKey === void 0 ? "store" : _ref2$storeKey;
_ref2.withRef;
var _ref2$forwardRef = _ref2.forwardRef, forwardRef = _ref2$forwardRef === void 0 ? false : _ref2$forwardRef, _ref2$context = _ref2.context, context = _ref2$context === void 0 ? ReactReduxContext : _ref2$context, connectOptions = _objectWithoutPropertiesLoose$3(_ref2, _excluded$J);
var Context = context;
return function wrapWithConnect(WrappedComponent) {
var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
var displayName = getDisplayName(wrappedComponentName);
var selectorFactoryOptions = _extends$1({}, connectOptions, {
getDisplayName,
methodName,
renderCountProp,
shouldHandleStateChanges,
storeKey,
displayName,
wrappedComponentName,
WrappedComponent
});
var pure = connectOptions.pure;
function createChildSelector(store2) {
return selectorFactory(store2.dispatch, selectorFactoryOptions);
}
var usePureOnlyMemo = pure ? __mf_29 : function(callback) {
return callback();
};
function ConnectFunction(props) {
var _useMemo = __mf_29(function() {
var reactReduxForwardedRef2 = props.reactReduxForwardedRef, wrapperProps2 = _objectWithoutPropertiesLoose$3(props, _excluded2$7);
return [
props.context,
reactReduxForwardedRef2,
wrapperProps2
];
}, [
props
]), propsContext = _useMemo[0], reactReduxForwardedRef = _useMemo[1], wrapperProps = _useMemo[2];
var ContextToUse = __mf_29(function() {
return propsContext && propsContext.Consumer && reactIsExports.isContextConsumer(React.createElement(propsContext.Consumer, null)) ? propsContext : Context;
}, [
propsContext,
Context
]);
var contextValue = __mf_21(ContextToUse);
var didStoreComeFromProps = Boolean(props.store) && Boolean(props.store.getState) && Boolean(props.store.dispatch);
Boolean(contextValue) && Boolean(contextValue.store);
var store2 = didStoreComeFromProps ? props.store : contextValue.store;
var childPropsSelector = __mf_29(function() {
return createChildSelector(store2);
}, [
store2
]);
var _useMemo2 = __mf_29(function() {
if (!shouldHandleStateChanges) return NO_SUBSCRIPTION_ARRAY;
var subscription2 = createSubscription(store2, didStoreComeFromProps ? null : contextValue.subscription);
var notifyNestedSubs2 = subscription2.notifyNestedSubs.bind(subscription2);
return [
subscription2,
notifyNestedSubs2
];
}, [
store2,
didStoreComeFromProps,
contextValue
]), subscription = _useMemo2[0], notifyNestedSubs = _useMemo2[1];
var overriddenContextValue = __mf_29(function() {
if (didStoreComeFromProps) {
return contextValue;
}
return _extends$1({}, contextValue, {
subscription
});
}, [
didStoreComeFromProps,
contextValue,
subscription
]);
var _useReducer = __mf_30(storeStateUpdatesReducer, EMPTY_ARRAY, initStateUpdates), _useReducer$ = _useReducer[0], previousStateUpdateResult = _useReducer$[0], forceComponentUpdateDispatch = _useReducer[1];
if (previousStateUpdateResult && previousStateUpdateResult.error) {
throw previousStateUpdateResult.error;
}
var lastChildProps = __mf_31();
var lastWrapperProps = __mf_31(wrapperProps);
var childPropsFromStoreUpdate = __mf_31();
var renderIsScheduled = __mf_31(false);
var actualChildProps = usePureOnlyMemo(function() {
if (childPropsFromStoreUpdate.current && wrapperProps === lastWrapperProps.current) {
return childPropsFromStoreUpdate.current;
}
return childPropsSelector(store2.getState(), wrapperProps);
}, [
store2,
previousStateUpdateResult,
wrapperProps
]);
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [
lastWrapperProps,
lastChildProps,
renderIsScheduled,
wrapperProps,
actualChildProps,
childPropsFromStoreUpdate,
notifyNestedSubs
]);
useIsomorphicLayoutEffectWithArgs(subscribeUpdates, [
shouldHandleStateChanges,
store2,
subscription,
childPropsSelector,
lastWrapperProps,
lastChildProps,
renderIsScheduled,
childPropsFromStoreUpdate,
notifyNestedSubs,
forceComponentUpdateDispatch
], [
store2,
subscription,
childPropsSelector
]);
var renderedWrappedComponent = __mf_29(function() {
return React.createElement(WrappedComponent, _extends$1({}, actualChildProps, {
ref: reactReduxForwardedRef
}));
}, [
reactReduxForwardedRef,
WrappedComponent,
actualChildProps
]);
var renderedChild = __mf_29(function() {
if (shouldHandleStateChanges) {
return React.createElement(ContextToUse.Provider, {
value: overriddenContextValue
}, renderedWrappedComponent);
}
return renderedWrappedComponent;
}, [
ContextToUse,
renderedWrappedComponent,
overriddenContextValue
]);
return renderedChild;
}
var Connect = pure ? React.memo(ConnectFunction) : ConnectFunction;
Connect.WrappedComponent = WrappedComponent;
Connect.displayName = ConnectFunction.displayName = displayName;
if (forwardRef) {
var forwarded = React.forwardRef(function forwardConnectRef(props, ref) {
return React.createElement(Connect, _extends$1({}, props, {
reactReduxForwardedRef: ref
}));
});
forwarded.displayName = displayName;
forwarded.WrappedComponent = WrappedComponent;
return hoistNonReactStatics(forwarded, WrappedComponent);
}
return hoistNonReactStatics(Connect, WrappedComponent);
};
}
function is(x2, y2) {
if (x2 === y2) {
return x2 !== 0 || y2 !== 0 || 1 / x2 === 1 / y2;
} else {
return x2 !== x2 && y2 !== y2;
}
}
function shallowEqual(objA, objB) {
if (is(objA, objB)) return true;
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return false;
for (var i = 0; i < keysA.length; i++) {
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
function bindActionCreators(actionCreators, dispatch) {
var boundActionCreators = {};
var _loop = function _loop2(key2) {
var actionCreator = actionCreators[key2];
if (typeof actionCreator === "function") {
boundActionCreators[key2] = function() {
return dispatch(actionCreator.apply(void 0, arguments));
};
}
};
for (var key in actionCreators) {
_loop(key);
}
return boundActionCreators;
}
function wrapMapToPropsConstant(getConstant) {
return function initConstantSelector(dispatch, options) {
var constant = getConstant(dispatch, options);
function constantSelector() {
return constant;
}
constantSelector.dependsOnOwnProps = false;
return constantSelector;
};
}
function getDependsOnOwnProps(mapToProps) {
return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== void 0 ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
}
function wrapMapToPropsFunc(mapToProps, methodName) {
return function initProxySelector(dispatch, _ref) {
_ref.displayName;
var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);
};
proxy.dependsOnOwnProps = true;
proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
proxy.mapToProps = mapToProps;
proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
var props = proxy(stateOrDispatch, ownProps);
if (typeof props === "function") {
proxy.mapToProps = props;
proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
props = proxy(stateOrDispatch, ownProps);
}
return props;
};
return proxy;
};
}
function whenMapDispatchToPropsIsFunction(mapDispatchToProps2) {
return typeof mapDispatchToProps2 === "function" ? wrapMapToPropsFunc(mapDispatchToProps2) : void 0;
}
function whenMapDispatchToPropsIsMissing(mapDispatchToProps2) {
return !mapDispatchToProps2 ? wrapMapToPropsConstant(function(dispatch) {
return {
dispatch
};
}) : void 0;
}
function whenMapDispatchToPropsIsObject(mapDispatchToProps2) {
return mapDispatchToProps2 && typeof mapDispatchToProps2 === "object" ? wrapMapToPropsConstant(function(dispatch) {
return bindActionCreators(mapDispatchToProps2, dispatch);
}) : void 0;
}
const defaultMapDispatchToPropsFactories = [
whenMapDispatchToPropsIsFunction,
whenMapDispatchToPropsIsMissing,
whenMapDispatchToPropsIsObject
];
function whenMapStateToPropsIsFunction(mapStateToProps) {
return typeof mapStateToProps === "function" ? wrapMapToPropsFunc(mapStateToProps) : void 0;
}
function whenMapStateToPropsIsMissing(mapStateToProps) {
return !mapStateToProps ? wrapMapToPropsConstant(function() {
return {};
}) : void 0;
}
const defaultMapStateToPropsFactories = [
whenMapStateToPropsIsFunction,
whenMapStateToPropsIsMissing
];
function defaultMergeProps(stateProps, dispatchProps, ownProps) {
return _extends$1({}, ownProps, stateProps, dispatchProps);
}
function wrapMergePropsFunc(mergeProps) {
return function initMergePropsProxy(dispatch, _ref) {
_ref.displayName;
var pure = _ref.pure, areMergedPropsEqual = _ref.areMergedPropsEqual;
var hasRunOnce = false;
var mergedProps;
return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
if (hasRunOnce) {
if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps;
} else {
hasRunOnce = true;
mergedProps = nextMergedProps;
}
return mergedProps;
};
};
}
function whenMergePropsIsFunction(mergeProps) {
return typeof mergeProps === "function" ? wrapMergePropsFunc(mergeProps) : void 0;
}
function whenMergePropsIsOmitted(mergeProps) {
return !mergeProps ? function() {
return defaultMergeProps;
} : void 0;
}
const defaultMergePropsFactories = [
whenMergePropsIsFunction,
whenMergePropsIsOmitted
];
var _excluded$I = [
"initMapStateToProps",
"initMapDispatchToProps",
"initMergeProps"
];
function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps2, mergeProps, dispatch) {
return function impureFinalPropsSelector(state, ownProps) {
return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps2(dispatch, ownProps), ownProps);
};
}
function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps2, mergeProps, dispatch, _ref) {
var areStatesEqual = _ref.areStatesEqual, areOwnPropsEqual = _ref.areOwnPropsEqual, areStatePropsEqual = _ref.areStatePropsEqual;
var hasRunAtLeastOnce = false;
var state;
var ownProps;
var stateProps;
var dispatchProps;
var mergedProps;
function handleFirstCall(firstState, firstOwnProps) {
state = firstState;
ownProps = firstOwnProps;
stateProps = mapStateToProps(state, ownProps);
dispatchProps = mapDispatchToProps2(dispatch, ownProps);
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
hasRunAtLeastOnce = true;
return mergedProps;
}
function handleNewPropsAndNewState() {
stateProps = mapStateToProps(state, ownProps);
if (mapDispatchToProps2.dependsOnOwnProps) dispatchProps = mapDispatchToProps2(dispatch, ownProps);
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
return mergedProps;
}
function handleNewProps() {
if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps);
if (mapDispatchToProps2.dependsOnOwnProps) dispatchProps = mapDispatchToProps2(dispatch, ownProps);
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
return mergedProps;
}
function handleNewState() {
var nextStateProps = mapStateToProps(state, ownProps);
var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
stateProps = nextStateProps;
if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
return mergedProps;
}
function handleSubsequentCalls(nextState, nextOwnProps) {
var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
var stateChanged = !areStatesEqual(nextState, state, nextOwnProps, ownProps);
state = nextState;
ownProps = nextOwnProps;
if (propsChanged && stateChanged) return handleNewPropsAndNewState();
if (propsChanged) return handleNewProps();
if (stateChanged) return handleNewState();
return mergedProps;
}
return function pureFinalPropsSelector(nextState, nextOwnProps) {
return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
};
}
function finalPropsSelectorFactory(dispatch, _ref2) {
var initMapStateToProps = _ref2.initMapStateToProps, initMapDispatchToProps = _ref2.initMapDispatchToProps, initMergeProps = _ref2.initMergeProps, options = _objectWithoutPropertiesLoose$3(_ref2, _excluded$I);
var mapStateToProps = initMapStateToProps(dispatch, options);
var mapDispatchToProps2 = initMapDispatchToProps(dispatch, options);
var mergeProps = initMergeProps(dispatch, options);
var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory;
return selectorFactory(mapStateToProps, mapDispatchToProps2, mergeProps, dispatch, options);
}
var _excluded$H = [
"pure",
"areStatesEqual",
"areOwnPropsEqual",
"areStatePropsEqual",
"areMergedPropsEqual"
];
function match(arg, factories, name) {
for (var i = factories.length - 1; i >= 0; i--) {
var result = factories[i](arg);
if (result) return result;
}
return function(dispatch, options) {
throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + ".");
};
}
function strictEqual(a, b2) {
return a === b2;
}
function createConnect(_temp) {
var _ref = _temp === void 0 ? {} : _temp, _ref$connectHOC = _ref.connectHOC, connectHOC = _ref$connectHOC === void 0 ? connectAdvanced : _ref$connectHOC, _ref$mapStateToPropsF = _ref.mapStateToPropsFactories, mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? defaultMapStateToPropsFactories : _ref$mapStateToPropsF, _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories, mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? defaultMapDispatchToPropsFactories : _ref$mapDispatchToPro, _ref$mergePropsFactor = _ref.mergePropsFactories, mergePropsFactories = _ref$mergePropsFactor === void 0 ? defaultMergePropsFactories : _ref$mergePropsFactor, _ref$selectorFactory = _ref.selectorFactory, selectorFactory = _ref$selectorFactory === void 0 ? finalPropsSelectorFactory : _ref$selectorFactory;
return function connect2(mapStateToProps, mapDispatchToProps2, mergeProps, _ref2) {
if (_ref2 === void 0) {
_ref2 = {};
}
var _ref3 = _ref2, _ref3$pure = _ref3.pure, pure = _ref3$pure === void 0 ? true : _ref3$pure, _ref3$areStatesEqual = _ref3.areStatesEqual, areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual, _ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual, areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? shallowEqual : _ref3$areOwnPropsEqua, _ref3$areStatePropsEq = _ref3.areStatePropsEqual, areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? shallowEqual : _ref3$areStatePropsEq, _ref3$areMergedPropsE = _ref3.areMergedPropsEqual, areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? shallowEqual : _ref3$areMergedPropsE, extraOptions = _objectWithoutPropertiesLoose$3(_ref3, _excluded$H);
var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, "mapStateToProps");
var initMapDispatchToProps = match(mapDispatchToProps2, mapDispatchToPropsFactories, "mapDispatchToProps");
var initMergeProps = match(mergeProps, mergePropsFactories, "mergeProps");
return connectHOC(selectorFactory, _extends$1({
methodName: "connect",
getDisplayName: function getDisplayName(name) {
return "Connect(" + name + ")";
},
shouldHandleStateChanges: Boolean(mapStateToProps),
initMapStateToProps,
initMapDispatchToProps,
initMergeProps,
pure,
areStatesEqual,
areOwnPropsEqual,
areStatePropsEqual,
areMergedPropsEqual
}, extraOptions));
};
}
const connect = createConnect();
setBatch(__mf_9$1);
function areInputsEqual$1(newInputs, lastInputs) {
if (newInputs.length !== lastInputs.length) {
return false;
}
for (var i = 0; i < newInputs.length; i++) {
if (newInputs[i] !== lastInputs[i]) {
return false;
}
}
return true;
}
function useMemoOne(getResult, inputs) {
var initial = __mf_32(function() {
return {
inputs,
result: getResult()
};
})[0];
var isFirstRun = __mf_31(true);
var committed = __mf_31(initial);
var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual$1(inputs, committed.current.inputs));
var cache = useCache ? committed.current : {
inputs,
result: getResult()
};
__mf_24(function() {
isFirstRun.current = false;
committed.current = cache;
}, [
cache
]);
return cache.result;
}
function useCallbackOne(callback, inputs) {
return useMemoOne(function() {
return callback;
}, inputs);
}
var useMemo = useMemoOne;
var useCallback = useCallbackOne;
var prefix$2 = "Invariant failed";
function invariant$1(condition, message) {
{
throw new Error(prefix$2);
}
}
var getRect = function getRect2(_ref) {
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
var width = right - left;
var height = bottom - top;
var rect = {
top,
right,
bottom,
left,
width,
height,
x: left,
y: top,
center: {
x: (right + left) / 2,
y: (bottom + top) / 2
}
};
return rect;
};
var expand = function expand2(target, expandBy) {
return {
top: target.top - expandBy.top,
left: target.left - expandBy.left,
bottom: target.bottom + expandBy.bottom,
right: target.right + expandBy.right
};
};
var shrink = function shrink2(target, shrinkBy) {
return {
top: target.top + shrinkBy.top,
left: target.left + shrinkBy.left,
bottom: target.bottom - shrinkBy.bottom,
right: target.right - shrinkBy.right
};
};
var shift = function shift2(target, shiftBy) {
return {
top: target.top + shiftBy.y,
left: target.left + shiftBy.x,
bottom: target.bottom + shiftBy.y,
right: target.right + shiftBy.x
};
};
var noSpacing$1 = {
top: 0,
right: 0,
bottom: 0,
left: 0
};
var createBox = function createBox2(_ref2) {
var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing$1 : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing$1 : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing$1 : _ref2$padding;
var marginBox = getRect(expand(borderBox, margin));
var paddingBox = getRect(shrink(borderBox, border));
var contentBox = getRect(shrink(paddingBox, padding));
return {
marginBox,
borderBox: getRect(borderBox),
paddingBox,
contentBox,
margin,
border,
padding
};
};
var parse = function parse2(raw) {
var value = raw.slice(0, -2);
var suffix = raw.slice(-2);
if (suffix !== "px") {
return 0;
}
var result = Number(value);
!!isNaN(result) ? invariant$1() : void 0;
return result;
};
var getWindowScroll$1 = function getWindowScroll2() {
return {
x: window.pageXOffset,
y: window.pageYOffset
};
};
var offset = function offset2(original, change) {
var borderBox = original.borderBox, border = original.border, margin = original.margin, padding = original.padding;
var shifted = shift(borderBox, change);
return createBox({
borderBox: shifted,
border,
margin,
padding
});
};
var withScroll = function withScroll2(original, scroll2) {
if (scroll2 === void 0) {
scroll2 = getWindowScroll$1();
}
return offset(original, scroll2);
};
var calculateBox = function calculateBox2(borderBox, styles2) {
var margin = {
top: parse(styles2.marginTop),
right: parse(styles2.marginRight),
bottom: parse(styles2.marginBottom),
left: parse(styles2.marginLeft)
};
var padding = {
top: parse(styles2.paddingTop),
right: parse(styles2.paddingRight),
bottom: parse(styles2.paddingBottom),
left: parse(styles2.paddingLeft)
};
var border = {
top: parse(styles2.borderTopWidth),
right: parse(styles2.borderRightWidth),
bottom: parse(styles2.borderBottomWidth),
left: parse(styles2.borderLeftWidth)
};
return createBox({
borderBox,
margin,
padding,
border
});
};
var getBox = function getBox2(el) {
var borderBox = el.getBoundingClientRect();
var styles2 = window.getComputedStyle(el);
return calculateBox(borderBox, styles2);
};
var safeIsNaN = Number.isNaN || function ponyfill(value) {
return typeof value === "number" && value !== value;
};
function isEqual$2(first, second) {
if (first === second) {
return true;
}
if (safeIsNaN(first) && safeIsNaN(second)) {
return true;
}
return false;
}
function areInputsEqual(newInputs, lastInputs) {
if (newInputs.length !== lastInputs.length) {
return false;
}
for (var i = 0; i < newInputs.length; i++) {
if (!isEqual$2(newInputs[i], lastInputs[i])) {
return false;
}
}
return true;
}
function memoizeOne(resultFn, isEqual2) {
if (isEqual2 === void 0) {
isEqual2 = areInputsEqual;
}
var lastThis;
var lastArgs = [];
var lastResult;
var calledOnce = false;
function memoized() {
var newArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
newArgs[_i] = arguments[_i];
}
if (calledOnce && lastThis === this && isEqual2(newArgs, lastArgs)) {
return lastResult;
}
lastResult = resultFn.apply(this, newArgs);
calledOnce = true;
lastThis = this;
lastArgs = newArgs;
return lastResult;
}
return memoized;
}
var rafSchd = function rafSchd2(fn) {
var lastArgs = [];
var frameId = null;
var wrapperFn = function wrapperFn2() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
lastArgs = args;
if (frameId) {
return;
}
frameId = requestAnimationFrame(function() {
frameId = null;
fn.apply(void 0, lastArgs);
});
};
wrapperFn.cancel = function() {
if (!frameId) {
return;
}
cancelAnimationFrame(frameId);
frameId = null;
};
return wrapperFn;
};
function log(type, message) {
{
return;
}
}
log.bind(null, "warn");
log.bind(null, "error");
function noop$1() {
}
function getOptions(shared2, fromBinding) {
return _extends$1({}, shared2, {}, fromBinding);
}
function bindEvents(el, bindings, sharedOptions) {
var unbindings = bindings.map(function(binding) {
var options = getOptions(sharedOptions, binding.options);
el.addEventListener(binding.eventName, binding.fn, options);
return function unbind() {
el.removeEventListener(binding.eventName, binding.fn, options);
};
});
return function unbindAll() {
unbindings.forEach(function(unbind) {
unbind();
});
};
}
var prefix = "Invariant failed";
function RbdInvariant(message) {
this.message = message;
}
RbdInvariant.prototype.toString = function toString() {
return this.message;
};
function invariant(condition, message) {
{
throw new RbdInvariant(prefix);
}
}
var ErrorBoundary = (function(_React$Component) {
_inheritsLoose(ErrorBoundary2, _React$Component);
function ErrorBoundary2() {
var _this;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _React$Component.call.apply(_React$Component, [
this
].concat(args)) || this;
_this.callbacks = null;
_this.unbind = noop$1;
_this.onWindowError = function(event) {
var callbacks = _this.getCallbacks();
if (callbacks.isDragging()) {
callbacks.tryAbort();
}
var err = event.error;
if (err instanceof RbdInvariant) {
event.preventDefault();
}
};
_this.getCallbacks = function() {
if (!_this.callbacks) {
throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");
}
return _this.callbacks;
};
_this.setCallbacks = function(callbacks) {
_this.callbacks = callbacks;
};
return _this;
}
var _proto = ErrorBoundary2.prototype;
_proto.componentDidMount = function componentDidMount() {
this.unbind = bindEvents(window, [
{
eventName: "error",
fn: this.onWindowError
}
]);
};
_proto.componentDidCatch = function componentDidCatch(err) {
if (err instanceof RbdInvariant) {
this.setState({});
return;
}
throw err;
};
_proto.componentWillUnmount = function componentWillUnmount() {
this.unbind();
};
_proto.render = function render() {
return this.props.children(this.setCallbacks);
};
return ErrorBoundary2;
})(React.Component);
var dragHandleUsageInstructions = "\n Press space bar to start a drag.\n When dragging you can use the arrow keys to move the item around and escape to cancel.\n Some screen readers may require you to be in focus mode or to use your pass through key\n";
var position = function position2(index) {
return index + 1;
};
var onDragStart = function onDragStart2(start3) {
return "\n You have lifted an item in position " + position(start3.source.index) + "\n";
};
var withLocation = function withLocation2(source, destination) {
var isInHomeList = source.droppableId === destination.droppableId;
var startPosition = position(source.index);
var endPosition = position(destination.index);
if (isInHomeList) {
return "\n You have moved the item from position " + startPosition + "\n to position " + endPosition + "\n ";
}
return "\n You have moved the item from position " + startPosition + "\n in list " + source.droppableId + "\n to list " + destination.droppableId + "\n in position " + endPosition + "\n ";
};
var withCombine = function withCombine2(id, source, combine2) {
var inHomeList = source.droppableId === combine2.droppableId;
if (inHomeList) {
return "\n The item " + id + "\n has been combined with " + combine2.draggableId;
}
return "\n The item " + id + "\n in list " + source.droppableId + "\n has been combined with " + combine2.draggableId + "\n in list " + combine2.droppableId + "\n ";
};
var onDragUpdate = function onDragUpdate2(update2) {
var location = update2.destination;
if (location) {
return withLocation(update2.source, location);
}
var combine2 = update2.combine;
if (combine2) {
return withCombine(update2.draggableId, update2.source, combine2);
}
return "You are over an area that cannot be dropped on";
};
var returnedToStart = function returnedToStart2(source) {
return "\n The item has returned to its starting position\n of " + position(source.index) + "\n";
};
var onDragEnd = function onDragEnd2(result) {
if (result.reason === "CANCEL") {
return "\n Movement cancelled.\n " + returnedToStart(result.source) + "\n ";
}
var location = result.destination;
var combine2 = result.combine;
if (location) {
return "\n You have dropped the item.\n " + withLocation(result.source, location) + "\n ";
}
if (combine2) {
return "\n You have dropped the item.\n " + withCombine(result.draggableId, result.source, combine2) + "\n ";
}
return "\n The item has been dropped while not over a drop area.\n " + returnedToStart(result.source) + "\n ";
};
var preset = {
dragHandleUsageInstructions,
onDragStart,
onDragUpdate,
onDragEnd
};
var origin = {
x: 0,
y: 0
};
var add = function add2(point1, point2) {
return {
x: point1.x + point2.x,
y: point1.y + point2.y
};
};
var subtract = function subtract2(point1, point2) {
return {
x: point1.x - point2.x,
y: point1.y - point2.y
};
};
var isEqual = function isEqual2(point1, point2) {
return point1.x === point2.x && point1.y === point2.y;
};
var negate = function negate2(point) {
return {
x: point.x !== 0 ? -point.x : 0,
y: point.y !== 0 ? -point.y : 0
};
};
var patch = function patch2(line, value, otherValue) {
var _ref;
if (otherValue === void 0) {
otherValue = 0;
}
return _ref = {}, _ref[line] = value, _ref[line === "x" ? "y" : "x"] = otherValue, _ref;
};
var distance = function distance2(point1, point2) {
return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
};
var closest = function closest2(target, points) {
return Math.min.apply(Math, points.map(function(point) {
return distance(target, point);
}));
};
var apply = function apply2(fn) {
return function(point) {
return {
x: fn(point.x),
y: fn(point.y)
};
};
};
var executeClip = (function(frame, subject) {
var result = getRect({
top: Math.max(subject.top, frame.top),
right: Math.min(subject.right, frame.right),
bottom: Math.min(subject.bottom, frame.bottom),
left: Math.max(subject.left, frame.left)
});
if (result.width <= 0 || result.height <= 0) {
return null;
}
return result;
});
var offsetByPosition = function offsetByPosition2(spacing, point) {
return {
top: spacing.top + point.y,
left: spacing.left + point.x,
bottom: spacing.bottom + point.y,
right: spacing.right + point.x
};
};
var getCorners = function getCorners2(spacing) {
return [
{
x: spacing.left,
y: spacing.top
},
{
x: spacing.right,
y: spacing.top
},
{
x: spacing.left,
y: spacing.bottom
},
{
x: spacing.right,
y: spacing.bottom
}
];
};
var noSpacing = {
top: 0,
right: 0,
bottom: 0,
left: 0
};
var scroll = function scroll2(target, frame) {
if (!frame) {
return target;
}
return offsetByPosition(target, frame.scroll.diff.displacement);
};
var increase = function increase2(target, axis, withPlaceholder) {
if (withPlaceholder && withPlaceholder.increasedBy) {
var _extends2;
return _extends$1({}, target, (_extends2 = {}, _extends2[axis.end] = target[axis.end] + withPlaceholder.increasedBy[axis.line], _extends2));
}
return target;
};
var clip = function clip2(target, frame) {
if (frame && frame.shouldClipSubject) {
return executeClip(frame.pageMarginBox, target);
}
return getRect(target);
};
var getSubject = (function(_ref) {
var page = _ref.page, withPlaceholder = _ref.withPlaceholder, axis = _ref.axis, frame = _ref.frame;
var scrolled = scroll(page.marginBox, frame);
var increased = increase(scrolled, axis, withPlaceholder);
var clipped = clip(increased, frame);
return {
page,
withPlaceholder,
active: clipped
};
});
var scrollDroppable = (function(droppable2, newScroll) {
!droppable2.frame ? invariant() : void 0;
var scrollable = droppable2.frame;
var scrollDiff = subtract(newScroll, scrollable.scroll.initial);
var scrollDisplacement = negate(scrollDiff);
var frame = _extends$1({}, scrollable, {
scroll: {
initial: scrollable.scroll.initial,
current: newScroll,
diff: {
value: scrollDiff,
displacement: scrollDisplacement
},
max: scrollable.scroll.max
}
});
var subject = getSubject({
page: droppable2.subject.page,
withPlaceholder: droppable2.subject.withPlaceholder,
axis: droppable2.axis,
frame
});
var result = _extends$1({}, droppable2, {
frame,
subject
});
return result;
});
function values(map) {
if (Object.values) {
return Object.values(map);
}
return Object.keys(map).map(function(key) {
return map[key];
});
}
function findIndex(list, predicate) {
if (list.findIndex) {
return list.findIndex(predicate);
}
for (var i = 0; i < list.length; i++) {
if (predicate(list[i])) {
return i;
}
}
return -1;
}
function find(list, predicate) {
if (list.find) {
return list.find(predicate);
}
var index = findIndex(list, predicate);
if (index !== -1) {
return list[index];
}
return void 0;
}
function toArray(list) {
return Array.prototype.slice.call(list);
}
var toDroppableMap = memoizeOne(function(droppables) {
return droppables.reduce(function(previous, current) {
previous[current.descriptor.id] = current;
return previous;
}, {});
});
var toDraggableMap = memoizeOne(function(draggables) {
return draggables.reduce(function(previous, current) {
previous[current.descriptor.id] = current;
return previous;
}, {});
});
var toDroppableList = memoizeOne(function(droppables) {
return values(droppables);
});
var toDraggableList = memoizeOne(function(draggables) {
return values(draggables);
});
var getDraggablesInsideDroppable = memoizeOne(function(droppableId, draggables) {
var result = toDraggableList(draggables).filter(function(draggable2) {
return droppableId === draggable2.descriptor.droppableId;
}).sort(function(a, b2) {
return a.descriptor.index - b2.descriptor.index;
});
return result;
});
function tryGetDestination(impact) {
if (impact.at && impact.at.type === "REORDER") {
return impact.at.destination;
}
return null;
}
function tryGetCombine(impact) {
if (impact.at && impact.at.type === "COMBINE") {
return impact.at.combine;
}
return null;
}
var removeDraggableFromList = memoizeOne(function(remove, list) {
return list.filter(function(item) {
return item.descriptor.id !== remove.descriptor.id;
});
});
var moveToNextCombine = (function(_ref) {
var isMovingForward = _ref.isMovingForward, draggable2 = _ref.draggable, destination = _ref.destination, insideDestination = _ref.insideDestination, previousImpact = _ref.previousImpact;
if (!destination.isCombineEnabled) {
return null;
}
var location = tryGetDestination(previousImpact);
if (!location) {
return null;
}
function getImpact(target) {
var at = {
type: "COMBINE",
combine: {
draggableId: target,
droppableId: destination.descriptor.id
}
};
return _extends$1({}, previousImpact, {
at
});
}
var all = previousImpact.displaced.all;
var closestId = all.length ? all[0] : null;
if (isMovingForward) {
return closestId ? getImpact(closestId) : null;
}
var withoutDraggable = removeDraggableFromList(draggable2, insideDestination);
if (!closestId) {
if (!withoutDraggable.length) {
return null;
}
var last = withoutDraggable[withoutDraggable.length - 1];
return getImpact(last.descriptor.id);
}
var indexOfClosest = findIndex(withoutDraggable, function(d2) {
return d2.descriptor.id === closestId;
});
!(indexOfClosest !== -1) ? invariant() : void 0;
var proposedIndex = indexOfClosest - 1;
if (proposedIndex < 0) {
return null;
}
var before = withoutDraggable[proposedIndex];
return getImpact(before.descriptor.id);
});
var isHomeOf = (function(draggable2, destination) {
return draggable2.descriptor.droppableId === destination.descriptor.id;
});
var noDisplacedBy = {
point: origin,
value: 0
};
var emptyGroups = {
invisible: {},
visible: {},
all: []
};
var noImpact = {
displaced: emptyGroups,
displacedBy: noDisplacedBy,
at: null
};
var isWithin = (function(lowerBound, upperBound) {
return function(value) {
return lowerBound <= value && value <= upperBound;
};
});
var isPartiallyVisibleThroughFrame = (function(frame) {
var isWithinVertical = isWithin(frame.top, frame.bottom);
var isWithinHorizontal = isWithin(frame.left, frame.right);
return function(subject) {
var isContained = isWithinVertical(subject.top) && isWithinVertical(subject.bottom) && isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
if (isContained) {
return true;
}
var isPartiallyVisibleVertically = isWithinVertical(subject.top) || isWithinVertical(subject.bottom);
var isPartiallyVisibleHorizontally = isWithinHorizontal(subject.left) || isWithinHorizontal(subject.right);
var isPartiallyContained = isPartiallyVisibleVertically && isPartiallyVisibleHorizontally;
if (isPartiallyContained) {
return true;
}
var isBiggerVertically = subject.top < frame.top && subject.bottom > frame.bottom;
var isBiggerHorizontally = subject.left < frame.left && subject.right > frame.right;
var isTargetBiggerThanFrame = isBiggerVertically && isBiggerHorizontally;
if (isTargetBiggerThanFrame) {
return true;
}
var isTargetBiggerOnOneAxis = isBiggerVertically && isPartiallyVisibleHorizontally || isBiggerHorizontally && isPartiallyVisibleVertically;
return isTargetBiggerOnOneAxis;
};
});
var isTotallyVisibleThroughFrame = (function(frame) {
var isWithinVertical = isWithin(frame.top, frame.bottom);
var isWithinHorizontal = isWithin(frame.left, frame.right);
return function(subject) {
var isContained = isWithinVertical(subject.top) && isWithinVertical(subject.bottom) && isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
return isContained;
};
});
var vertical = {
direction: "vertical",
line: "y",
crossAxisLine: "x",
start: "top",
end: "bottom",
size: "height",
crossAxisStart: "left",
crossAxisEnd: "right",
crossAxisSize: "width"
};
var horizontal = {
direction: "horizontal",
line: "x",
crossAxisLine: "y",
start: "left",
end: "right",
size: "width",
crossAxisStart: "top",
crossAxisEnd: "bottom",
crossAxisSize: "height"
};
var isTotallyVisibleThroughFrameOnAxis = (function(axis) {
return function(frame) {
var isWithinVertical = isWithin(frame.top, frame.bottom);
var isWithinHorizontal = isWithin(frame.left, frame.right);
return function(subject) {
if (axis === vertical) {
return isWithinVertical(subject.top) && isWithinVertical(subject.bottom);
}
return isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
};
};
});
var getDroppableDisplaced = function getDroppableDisplaced2(target, destination) {
var displacement = destination.frame ? destination.frame.scroll.diff.displacement : origin;
return offsetByPosition(target, displacement);
};
var isVisibleInDroppable = function isVisibleInDroppable2(target, destination, isVisibleThroughFrameFn) {
if (!destination.subject.active) {
return false;
}
return isVisibleThroughFrameFn(destination.subject.active)(target);
};
var isVisibleInViewport = function isVisibleInViewport2(target, viewport, isVisibleThroughFrameFn) {
return isVisibleThroughFrameFn(viewport)(target);
};
var isVisible = function isVisible2(_ref) {
var toBeDisplaced = _ref.target, destination = _ref.destination, viewport = _ref.viewport, withDroppableDisplacement2 = _ref.withDroppableDisplacement, isVisibleThroughFrameFn = _ref.isVisibleThroughFrameFn;
var displacedTarget = withDroppableDisplacement2 ? getDroppableDisplaced(toBeDisplaced, destination) : toBeDisplaced;
return isVisibleInDroppable(displacedTarget, destination, isVisibleThroughFrameFn) && isVisibleInViewport(displacedTarget, viewport, isVisibleThroughFrameFn);
};
var isPartiallyVisible = function isPartiallyVisible2(args) {
return isVisible(_extends$1({}, args, {
isVisibleThroughFrameFn: isPartiallyVisibleThroughFrame
}));
};
var isTotallyVisible = function isTotallyVisible2(args) {
return isVisible(_extends$1({}, args, {
isVisibleThroughFrameFn: isTotallyVisibleThroughFrame
}));
};
var isTotallyVisibleOnAxis = function isTotallyVisibleOnAxis2(args) {
return isVisible(_extends$1({}, args, {
isVisibleThroughFrameFn: isTotallyVisibleThroughFrameOnAxis(args.destination.axis)
}));
};
var getShouldAnimate = function getShouldAnimate2(id, last, forceShouldAnimate) {
if (typeof forceShouldAnimate === "boolean") {
return forceShouldAnimate;
}
if (!last) {
return true;
}
var invisible = last.invisible, visible = last.visible;
if (invisible[id]) {
return false;
}
var previous = visible[id];
return previous ? previous.shouldAnimate : true;
};
function getTarget(draggable2, displacedBy) {
var marginBox = draggable2.page.marginBox;
var expandBy = {
top: displacedBy.point.y,
right: 0,
bottom: 0,
left: displacedBy.point.x
};
return getRect(expand(marginBox, expandBy));
}
function getDisplacementGroups(_ref) {
var afterDragging = _ref.afterDragging, destination = _ref.destination, displacedBy = _ref.displacedBy, viewport = _ref.viewport, forceShouldAnimate = _ref.forceShouldAnimate, last = _ref.last;
return afterDragging.reduce(function process2(groups, draggable2) {
var target = getTarget(draggable2, displacedBy);
var id = draggable2.descriptor.id;
groups.all.push(id);
var isVisible3 = isPartiallyVisible({
target,
destination,
viewport,
withDroppableDisplacement: true
});
if (!isVisible3) {
groups.invisible[draggable2.descriptor.id] = true;
return groups;
}
var shouldAnimate = getShouldAnimate(id, last, forceShouldAnimate);
var displacement = {
draggableId: id,
shouldAnimate
};
groups.visible[id] = displacement;
return groups;
}, {
all: [],
visible: {},
invisible: {}
});
}
function getIndexOfLastItem(draggables, options) {
if (!draggables.length) {
return 0;
}
var indexOfLastItem = draggables[draggables.length - 1].descriptor.index;
return options.inHomeList ? indexOfLastItem : indexOfLastItem + 1;
}
function goAtEnd(_ref) {
var insideDestination = _ref.insideDestination, inHomeList = _ref.inHomeList, displacedBy = _ref.displacedBy, destination = _ref.destination;
var newIndex = getIndexOfLastItem(insideDestination, {
inHomeList
});
return {
displaced: emptyGroups,
displacedBy,
at: {
type: "REORDER",
destination: {
droppableId: destination.descriptor.id,
index: newIndex
}
}
};
}
function calculateReorderImpact(_ref2) {
var draggable2 = _ref2.draggable, insideDestination = _ref2.insideDestination, destination = _ref2.destination, viewport = _ref2.viewport, displacedBy = _ref2.displacedBy, last = _ref2.last, index = _ref2.index, forceShouldAnimate = _ref2.forceShouldAnimate;
var inHomeList = isHomeOf(draggable2, destination);
if (index == null) {
return goAtEnd({
insideDestination,
inHomeList,
displacedBy,
destination
});
}
var match2 = find(insideDestination, function(item) {
return item.descriptor.index === index;
});
if (!match2) {
return goAtEnd({
insideDestination,
inHomeList,
displacedBy,
destination
});
}
var withoutDragging = removeDraggableFromList(draggable2, insideDestination);
var sliceFrom = insideDestination.indexOf(match2);
var impacted = withoutDragging.slice(sliceFrom);
var displaced = getDisplacementGroups({
afterDragging: impacted,
destination,
displacedBy,
last,
viewport: viewport.frame,
forceShouldAnimate
});
return {
displaced,
displacedBy,
at: {
type: "REORDER",
destination: {
droppableId: destination.descriptor.id,
index
}
}
};
}
function didStartAfterCritical(draggableId, afterCritical) {
return Boolean(afterCritical.effected[draggableId]);
}
var fromCombine = (function(_ref) {
var isMovingForward = _ref.isMovingForward, destination = _ref.destination, draggables = _ref.draggables, combine2 = _ref.combine, afterCritical = _ref.afterCritical;
if (!destination.isCombineEnabled) {
return null;
}
var combineId = combine2.draggableId;
var combineWith = draggables[combineId];
var combineWithIndex = combineWith.descriptor.index;
var didCombineWithStartAfterCritical = didStartAfterCritical(combineId, afterCritical);
if (didCombineWithStartAfterCritical) {
if (isMovingForward) {
return combineWithIndex;
}
return combineWithIndex - 1;
}
if (isMovingForward) {
return combineWithIndex + 1;
}
return combineWithIndex;
});
var fromReorder = (function(_ref) {
var isMovingForward = _ref.isMovingForward, isInHomeList = _ref.isInHomeList, insideDestination = _ref.insideDestination, location = _ref.location;
if (!insideDestination.length) {
return null;
}
var currentIndex = location.index;
var proposedIndex = isMovingForward ? currentIndex + 1 : currentIndex - 1;
var firstIndex = insideDestination[0].descriptor.index;
var lastIndex = insideDestination[insideDestination.length - 1].descriptor.index;
var upperBound = isInHomeList ? lastIndex : lastIndex + 1;
if (proposedIndex < firstIndex) {
return null;
}
if (proposedIndex > upperBound) {
return null;
}
return proposedIndex;
});
var moveToNextIndex = (function(_ref) {
var isMovingForward = _ref.isMovingForward, isInHomeList = _ref.isInHomeList, draggable2 = _ref.draggable, draggables = _ref.draggables, destination = _ref.destination, insideDestination = _ref.insideDestination, previousImpact = _ref.previousImpact, viewport = _ref.viewport, afterCritical = _ref.afterCritical;
var wasAt = previousImpact.at;
!wasAt ? invariant() : void 0;
if (wasAt.type === "REORDER") {
var _newIndex = fromReorder({
isMovingForward,
isInHomeList,
location: wasAt.destination,
insideDestination
});
if (_newIndex == null) {
return null;
}
return calculateReorderImpact({
draggable: draggable2,
insideDestination,
destination,
viewport,
last: previousImpact.displaced,
displacedBy: previousImpact.displacedBy,
index: _newIndex
});
}
var newIndex = fromCombine({
isMovingForward,
destination,
displaced: previousImpact.displaced,
draggables,
combine: wasAt.combine,
afterCritical
});
if (newIndex == null) {
return null;
}
return calculateReorderImpact({
draggable: draggable2,
insideDestination,
destination,
viewport,
last: previousImpact.displaced,
displacedBy: previousImpact.displacedBy,
index: newIndex
});
});
var getCombinedItemDisplacement = (function(_ref) {
var displaced = _ref.displaced, afterCritical = _ref.afterCritical, combineWith = _ref.combineWith, displacedBy = _ref.displacedBy;
var isDisplaced = Boolean(displaced.visible[combineWith] || displaced.invisible[combineWith]);
if (didStartAfterCritical(combineWith, afterCritical)) {
return isDisplaced ? origin : negate(displacedBy.point);
}
return isDisplaced ? displacedBy.point : origin;
});
var whenCombining = (function(_ref) {
var afterCritical = _ref.afterCritical, impact = _ref.impact, draggables = _ref.draggables;
var combine2 = tryGetCombine(impact);
!combine2 ? invariant() : void 0;
var combineWith = combine2.draggableId;
var center = draggables[combineWith].page.borderBox.center;
var displaceBy = getCombinedItemDisplacement({
displaced: impact.displaced,
afterCritical,
combineWith,
displacedBy: impact.displacedBy
});
return add(center, displaceBy);
});
var distanceFromStartToBorderBoxCenter = function distanceFromStartToBorderBoxCenter2(axis, box) {
return box.margin[axis.start] + box.borderBox[axis.size] / 2;
};
var distanceFromEndToBorderBoxCenter = function distanceFromEndToBorderBoxCenter2(axis, box) {
return box.margin[axis.end] + box.borderBox[axis.size] / 2;
};
var getCrossAxisBorderBoxCenter = function getCrossAxisBorderBoxCenter2(axis, target, isMoving) {
return target[axis.crossAxisStart] + isMoving.margin[axis.crossAxisStart] + isMoving.borderBox[axis.crossAxisSize] / 2;
};
var goAfter = function goAfter2(_ref) {
var axis = _ref.axis, moveRelativeTo = _ref.moveRelativeTo, isMoving = _ref.isMoving;
return patch(axis.line, moveRelativeTo.marginBox[axis.end] + distanceFromStartToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving));
};
var goBefore = function goBefore2(_ref2) {
var axis = _ref2.axis, moveRelativeTo = _ref2.moveRelativeTo, isMoving = _ref2.isMoving;
return patch(axis.line, moveRelativeTo.marginBox[axis.start] - distanceFromEndToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveRelativeTo.marginBox, isMoving));
};
var goIntoStart = function goIntoStart2(_ref3) {
var axis = _ref3.axis, moveInto = _ref3.moveInto, isMoving = _ref3.isMoving;
return patch(axis.line, moveInto.contentBox[axis.start] + distanceFromStartToBorderBoxCenter(axis, isMoving), getCrossAxisBorderBoxCenter(axis, moveInto.contentBox, isMoving));
};
var whenReordering = (function(_ref) {
var impact = _ref.impact, draggable2 = _ref.draggable, draggables = _ref.draggables, droppable2 = _ref.droppable, afterCritical = _ref.afterCritical;
var insideDestination = getDraggablesInsideDroppable(droppable2.descriptor.id, draggables);
var draggablePage = draggable2.page;
var axis = droppable2.axis;
if (!insideDestination.length) {
return goIntoStart({
axis,
moveInto: droppable2.page,
isMoving: draggablePage
});
}
var displaced = impact.displaced, displacedBy = impact.displacedBy;
var closestAfter = displaced.all[0];
if (closestAfter) {
var closest3 = draggables[closestAfter];
if (didStartAfterCritical(closestAfter, afterCritical)) {
return goBefore({
axis,
moveRelativeTo: closest3.page,
isMoving: draggablePage
});
}
var withDisplacement = offset(closest3.page, displacedBy.point);
return goBefore({
axis,
moveRelativeTo: withDisplacement,
isMoving: draggablePage
});
}
var last = insideDestination[insideDestination.length - 1];
if (last.descriptor.id === draggable2.descriptor.id) {
return draggablePage.borderBox.center;
}
if (didStartAfterCritical(last.descriptor.id, afterCritical)) {
var page = offset(last.page, negate(afterCritical.displacedBy.point));
return goAfter({
axis,
moveRelativeTo: page,
isMoving: draggablePage
});
}
return goAfter({
axis,
moveRelativeTo: last.page,
isMoving: draggablePage
});
});
var withDroppableDisplacement = (function(droppable2, point) {
var frame = droppable2.frame;
if (!frame) {
return point;
}
return add(point, frame.scroll.diff.displacement);
});
var getResultWithoutDroppableDisplacement = function getResultWithoutDroppableDisplacement2(_ref) {
var impact = _ref.impact, draggable2 = _ref.draggable, droppable2 = _ref.droppable, draggables = _ref.draggables, afterCritical = _ref.afterCritical;
var original = draggable2.page.borderBox.center;
var at = impact.at;
if (!droppable2) {
return original;
}
if (!at) {
return original;
}
if (at.type === "REORDER") {
return whenReordering({
impact,
draggable: draggable2,
draggables,
droppable: droppable2,
afterCritical
});
}
return whenCombining({
impact,
draggables,
afterCritical
});
};
var getPageBorderBoxCenterFromImpact = (function(args) {
var withoutDisplacement = getResultWithoutDroppableDisplacement(args);
var droppable2 = args.droppable;
var withDisplacement = droppable2 ? withDroppableDisplacement(droppable2, withoutDisplacement) : withoutDisplacement;
return withDisplacement;
});
var scrollViewport = (function(viewport, newScroll) {
var diff = subtract(newScroll, viewport.scroll.initial);
var displacement = negate(diff);
var frame = getRect({
top: newScroll.y,
bottom: newScroll.y + viewport.frame.height,
left: newScroll.x,
right: newScroll.x + viewport.frame.width
});
var updated = {
frame,
scroll: {
initial: viewport.scroll.initial,
max: viewport.scroll.max,
current: newScroll,
diff: {
value: diff,
displacement
}
}
};
return updated;
});
function getDraggables(ids, draggables) {
return ids.map(function(id) {
return draggables[id];
});
}
function tryGetVisible(id, groups) {
for (var i = 0; i < groups.length; i++) {
var displacement = groups[i].visible[id];
if (displacement) {
return displacement;
}
}
return null;
}
var speculativelyIncrease = (function(_ref) {
var impact = _ref.impact, viewport = _ref.viewport, destination = _ref.destination, draggables = _ref.draggables, maxScrollChange = _ref.maxScrollChange;
var scrolledViewport = scrollViewport(viewport, add(viewport.scroll.current, maxScrollChange));
var scrolledDroppable = destination.frame ? scrollDroppable(destination, add(destination.frame.scroll.current, maxScrollChange)) : destination;
var last = impact.displaced;
var withViewportScroll = getDisplacementGroups({
afterDragging: getDraggables(last.all, draggables),
destination,
displacedBy: impact.displacedBy,
viewport: scrolledViewport.frame,
last,
forceShouldAnimate: false
});
var withDroppableScroll2 = getDisplacementGroups({
afterDragging: getDraggables(last.all, draggables),
destination: scrolledDroppable,
displacedBy: impact.displacedBy,
viewport: viewport.frame,
last,
forceShouldAnimate: false
});
var invisible = {};
var visible = {};
var groups = [
last,
withViewportScroll,
withDroppableScroll2
];
last.all.forEach(function(id) {
var displacement = tryGetVisible(id, groups);
if (displacement) {
visible[id] = displacement;
return;
}
invisible[id] = true;
});
var newImpact = _extends$1({}, impact, {
displaced: {
all: last.all,
invisible,
visible
}
});
return newImpact;
});
var withViewportDisplacement = (function(viewport, point) {
return add(viewport.scroll.diff.displacement, point);
});
var getClientFromPageBorderBoxCenter = (function(_ref) {
var pageBorderBoxCenter = _ref.pageBorderBoxCenter, draggable2 = _ref.draggable, viewport = _ref.viewport;
var withoutPageScrollChange = withViewportDisplacement(viewport, pageBorderBoxCenter);
var offset2 = subtract(withoutPageScrollChange, draggable2.page.borderBox.center);
return add(draggable2.client.borderBox.center, offset2);
});
var isTotallyVisibleInNewLocation = (function(_ref) {
var draggable2 = _ref.draggable, destination = _ref.destination, newPageBorderBoxCenter = _ref.newPageBorderBoxCenter, viewport = _ref.viewport, withDroppableDisplacement2 = _ref.withDroppableDisplacement, _ref$onlyOnMainAxis = _ref.onlyOnMainAxis, onlyOnMainAxis = _ref$onlyOnMainAxis === void 0 ? false : _ref$onlyOnMainAxis;
var changeNeeded = subtract(newPageBorderBoxCenter, draggable2.page.borderBox.center);
var shifted = offsetByPosition(draggable2.page.borderBox, changeNeeded);
var args = {
target: shifted,
destination,
withDroppableDisplacement: withDroppableDisplacement2,
viewport
};
return onlyOnMainAxis ? isTotallyVisibleOnAxis(args) : isTotallyVisible(args);
});
var moveToNextPlace = (function(_ref) {
var isMovingForward = _ref.isMovingForward, draggable2 = _ref.draggable, destination = _ref.destination, draggables = _ref.draggables, previousImpact = _ref.previousImpact, viewport = _ref.viewport, previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter, previousClientSelection = _ref.previousClientSelection, afterCritical = _ref.afterCritical;
if (!destination.isEnabled) {
return null;
}
var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
var isInHomeList = isHomeOf(draggable2, destination);
var impact = moveToNextCombine({
isMovingForward,
draggable: draggable2,
destination,
insideDestination,
previousImpact
}) || moveToNextIndex({
isMovingForward,
isInHomeList,
draggable: draggable2,
draggables,
destination,
insideDestination,
previousImpact,
viewport,
afterCritical
});
if (!impact) {
return null;
}
var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
impact,
draggable: draggable2,
droppable: destination,
draggables,
afterCritical
});
var isVisibleInNewLocation = isTotallyVisibleInNewLocation({
draggable: draggable2,
destination,
newPageBorderBoxCenter: pageBorderBoxCenter,
viewport: viewport.frame,
withDroppableDisplacement: false,
onlyOnMainAxis: true
});
if (isVisibleInNewLocation) {
var clientSelection = getClientFromPageBorderBoxCenter({
pageBorderBoxCenter,
draggable: draggable2,
viewport
});
return {
clientSelection,
impact,
scrollJumpRequest: null
};
}
var distance3 = subtract(pageBorderBoxCenter, previousPageBorderBoxCenter);
var cautious = speculativelyIncrease({
impact,
viewport,
destination,
draggables,
maxScrollChange: distance3
});
return {
clientSelection: previousClientSelection,
impact: cautious,
scrollJumpRequest: distance3
};
});
var getKnownActive = function getKnownActive2(droppable2) {
var rect = droppable2.subject.active;
!rect ? invariant() : void 0;
return rect;
};
var getBestCrossAxisDroppable = (function(_ref) {
var isMovingForward = _ref.isMovingForward, pageBorderBoxCenter = _ref.pageBorderBoxCenter, source = _ref.source, droppables = _ref.droppables, viewport = _ref.viewport;
var active = source.subject.active;
if (!active) {
return null;
}
var axis = source.axis;
var isBetweenSourceClipped = isWithin(active[axis.start], active[axis.end]);
var candidates = toDroppableList(droppables).filter(function(droppable2) {
return droppable2 !== source;
}).filter(function(droppable2) {
return droppable2.isEnabled;
}).filter(function(droppable2) {
return Boolean(droppable2.subject.active);
}).filter(function(droppable2) {
return isPartiallyVisibleThroughFrame(viewport.frame)(getKnownActive(droppable2));
}).filter(function(droppable2) {
var activeOfTarget = getKnownActive(droppable2);
if (isMovingForward) {
return active[axis.crossAxisEnd] < activeOfTarget[axis.crossAxisEnd];
}
return activeOfTarget[axis.crossAxisStart] < active[axis.crossAxisStart];
}).filter(function(droppable2) {
var activeOfTarget = getKnownActive(droppable2);
var isBetweenDestinationClipped = isWithin(activeOfTarget[axis.start], activeOfTarget[axis.end]);
return isBetweenSourceClipped(activeOfTarget[axis.start]) || isBetweenSourceClipped(activeOfTarget[axis.end]) || isBetweenDestinationClipped(active[axis.start]) || isBetweenDestinationClipped(active[axis.end]);
}).sort(function(a, b2) {
var first = getKnownActive(a)[axis.crossAxisStart];
var second = getKnownActive(b2)[axis.crossAxisStart];
if (isMovingForward) {
return first - second;
}
return second - first;
}).filter(function(droppable2, index, array) {
return getKnownActive(droppable2)[axis.crossAxisStart] === getKnownActive(array[0])[axis.crossAxisStart];
});
if (!candidates.length) {
return null;
}
if (candidates.length === 1) {
return candidates[0];
}
var contains = candidates.filter(function(droppable2) {
var isWithinDroppable = isWithin(getKnownActive(droppable2)[axis.start], getKnownActive(droppable2)[axis.end]);
return isWithinDroppable(pageBorderBoxCenter[axis.line]);
});
if (contains.length === 1) {
return contains[0];
}
if (contains.length > 1) {
return contains.sort(function(a, b2) {
return getKnownActive(a)[axis.start] - getKnownActive(b2)[axis.start];
})[0];
}
return candidates.sort(function(a, b2) {
var first = closest(pageBorderBoxCenter, getCorners(getKnownActive(a)));
var second = closest(pageBorderBoxCenter, getCorners(getKnownActive(b2)));
if (first !== second) {
return first - second;
}
return getKnownActive(a)[axis.start] - getKnownActive(b2)[axis.start];
})[0];
});
var getCurrentPageBorderBoxCenter = function getCurrentPageBorderBoxCenter2(draggable2, afterCritical) {
var original = draggable2.page.borderBox.center;
return didStartAfterCritical(draggable2.descriptor.id, afterCritical) ? subtract(original, afterCritical.displacedBy.point) : original;
};
var getCurrentPageBorderBox = function getCurrentPageBorderBox2(draggable2, afterCritical) {
var original = draggable2.page.borderBox;
return didStartAfterCritical(draggable2.descriptor.id, afterCritical) ? offsetByPosition(original, negate(afterCritical.displacedBy.point)) : original;
};
var getClosestDraggable = (function(_ref) {
var pageBorderBoxCenter = _ref.pageBorderBoxCenter, viewport = _ref.viewport, destination = _ref.destination, insideDestination = _ref.insideDestination, afterCritical = _ref.afterCritical;
var sorted = insideDestination.filter(function(draggable2) {
return isTotallyVisible({
target: getCurrentPageBorderBox(draggable2, afterCritical),
destination,
viewport: viewport.frame,
withDroppableDisplacement: true
});
}).sort(function(a, b2) {
var distanceToA = distance(pageBorderBoxCenter, withDroppableDisplacement(destination, getCurrentPageBorderBoxCenter(a, afterCritical)));
var distanceToB = distance(pageBorderBoxCenter, withDroppableDisplacement(destination, getCurrentPageBorderBoxCenter(b2, afterCritical)));
if (distanceToA < distanceToB) {
return -1;
}
if (distanceToB < distanceToA) {
return 1;
}
return a.descriptor.index - b2.descriptor.index;
});
return sorted[0] || null;
});
var getDisplacedBy = memoizeOne(function getDisplacedBy2(axis, displaceBy) {
var displacement = displaceBy[axis.line];
return {
value: displacement,
point: patch(axis.line, displacement)
};
});
var getRequiredGrowthForPlaceholder = function getRequiredGrowthForPlaceholder2(droppable2, placeholderSize, draggables) {
var axis = droppable2.axis;
if (droppable2.descriptor.mode === "virtual") {
return patch(axis.line, placeholderSize[axis.line]);
}
var availableSpace = droppable2.subject.page.contentBox[axis.size];
var insideDroppable = getDraggablesInsideDroppable(droppable2.descriptor.id, draggables);
var spaceUsed = insideDroppable.reduce(function(sum, dimension) {
return sum + dimension.client.marginBox[axis.size];
}, 0);
var requiredSpace = spaceUsed + placeholderSize[axis.line];
var needsToGrowBy = requiredSpace - availableSpace;
if (needsToGrowBy <= 0) {
return null;
}
return patch(axis.line, needsToGrowBy);
};
var withMaxScroll = function withMaxScroll2(frame, max) {
return _extends$1({}, frame, {
scroll: _extends$1({}, frame.scroll, {
max
})
});
};
var addPlaceholder = function addPlaceholder2(droppable2, draggable2, draggables) {
var frame = droppable2.frame;
!!isHomeOf(draggable2, droppable2) ? invariant() : void 0;
!!droppable2.subject.withPlaceholder ? invariant() : void 0;
var placeholderSize = getDisplacedBy(droppable2.axis, draggable2.displaceBy).point;
var requiredGrowth = getRequiredGrowthForPlaceholder(droppable2, placeholderSize, draggables);
var added = {
placeholderSize,
increasedBy: requiredGrowth,
oldFrameMaxScroll: droppable2.frame ? droppable2.frame.scroll.max : null
};
if (!frame) {
var _subject = getSubject({
page: droppable2.subject.page,
withPlaceholder: added,
axis: droppable2.axis,
frame: droppable2.frame
});
return _extends$1({}, droppable2, {
subject: _subject
});
}
var maxScroll = requiredGrowth ? add(frame.scroll.max, requiredGrowth) : frame.scroll.max;
var newFrame = withMaxScroll(frame, maxScroll);
var subject = getSubject({
page: droppable2.subject.page,
withPlaceholder: added,
axis: droppable2.axis,
frame: newFrame
});
return _extends$1({}, droppable2, {
subject,
frame: newFrame
});
};
var removePlaceholder = function removePlaceholder2(droppable2) {
var added = droppable2.subject.withPlaceholder;
!added ? invariant() : void 0;
var frame = droppable2.frame;
if (!frame) {
var _subject2 = getSubject({
page: droppable2.subject.page,
axis: droppable2.axis,
frame: null,
withPlaceholder: null
});
return _extends$1({}, droppable2, {
subject: _subject2
});
}
var oldMaxScroll = added.oldFrameMaxScroll;
!oldMaxScroll ? invariant() : void 0;
var newFrame = withMaxScroll(frame, oldMaxScroll);
var subject = getSubject({
page: droppable2.subject.page,
axis: droppable2.axis,
frame: newFrame,
withPlaceholder: null
});
return _extends$1({}, droppable2, {
subject,
frame: newFrame
});
};
var moveToNewDroppable = (function(_ref) {
var previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter, moveRelativeTo = _ref.moveRelativeTo, insideDestination = _ref.insideDestination, draggable2 = _ref.draggable, draggables = _ref.draggables, destination = _ref.destination, viewport = _ref.viewport, afterCritical = _ref.afterCritical;
if (!moveRelativeTo) {
if (insideDestination.length) {
return null;
}
var proposed = {
displaced: emptyGroups,
displacedBy: noDisplacedBy,
at: {
type: "REORDER",
destination: {
droppableId: destination.descriptor.id,
index: 0
}
}
};
var proposedPageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
impact: proposed,
draggable: draggable2,
droppable: destination,
draggables,
afterCritical
});
var withPlaceholder = isHomeOf(draggable2, destination) ? destination : addPlaceholder(destination, draggable2, draggables);
var isVisibleInNewLocation = isTotallyVisibleInNewLocation({
draggable: draggable2,
destination: withPlaceholder,
newPageBorderBoxCenter: proposedPageBorderBoxCenter,
viewport: viewport.frame,
withDroppableDisplacement: false,
onlyOnMainAxis: true
});
return isVisibleInNewLocation ? proposed : null;
}
var isGoingBeforeTarget = Boolean(previousPageBorderBoxCenter[destination.axis.line] <= moveRelativeTo.page.borderBox.center[destination.axis.line]);
var proposedIndex = (function() {
var relativeTo = moveRelativeTo.descriptor.index;
if (moveRelativeTo.descriptor.id === draggable2.descriptor.id) {
return relativeTo;
}
if (isGoingBeforeTarget) {
return relativeTo;
}
return relativeTo + 1;
})();
var displacedBy = getDisplacedBy(destination.axis, draggable2.displaceBy);
return calculateReorderImpact({
draggable: draggable2,
insideDestination,
destination,
viewport,
displacedBy,
last: emptyGroups,
index: proposedIndex
});
});
var moveCrossAxis = (function(_ref) {
var isMovingForward = _ref.isMovingForward, previousPageBorderBoxCenter = _ref.previousPageBorderBoxCenter, draggable2 = _ref.draggable, isOver = _ref.isOver, draggables = _ref.draggables, droppables = _ref.droppables, viewport = _ref.viewport, afterCritical = _ref.afterCritical;
var destination = getBestCrossAxisDroppable({
isMovingForward,
pageBorderBoxCenter: previousPageBorderBoxCenter,
source: isOver,
droppables,
viewport
});
if (!destination) {
return null;
}
var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
var moveRelativeTo = getClosestDraggable({
pageBorderBoxCenter: previousPageBorderBoxCenter,
viewport,
destination,
insideDestination,
afterCritical
});
var impact = moveToNewDroppable({
previousPageBorderBoxCenter,
destination,
draggable: draggable2,
draggables,
moveRelativeTo,
insideDestination,
viewport,
afterCritical
});
if (!impact) {
return null;
}
var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
impact,
draggable: draggable2,
droppable: destination,
draggables,
afterCritical
});
var clientSelection = getClientFromPageBorderBoxCenter({
pageBorderBoxCenter,
draggable: draggable2,
viewport
});
return {
clientSelection,
impact,
scrollJumpRequest: null
};
});
var whatIsDraggedOver = (function(impact) {
var at = impact.at;
if (!at) {
return null;
}
if (at.type === "REORDER") {
return at.destination.droppableId;
}
return at.combine.droppableId;
});
var getDroppableOver = function getDroppableOver2(impact, droppables) {
var id = whatIsDraggedOver(impact);
return id ? droppables[id] : null;
};
var moveInDirection = (function(_ref) {
var state = _ref.state, type = _ref.type;
var isActuallyOver = getDroppableOver(state.impact, state.dimensions.droppables);
var isMainAxisMovementAllowed = Boolean(isActuallyOver);
var home2 = state.dimensions.droppables[state.critical.droppable.id];
var isOver = isActuallyOver || home2;
var direction = isOver.axis.direction;
var isMovingOnMainAxis = direction === "vertical" && (type === "MOVE_UP" || type === "MOVE_DOWN") || direction === "horizontal" && (type === "MOVE_LEFT" || type === "MOVE_RIGHT");
if (isMovingOnMainAxis && !isMainAxisMovementAllowed) {
return null;
}
var isMovingForward = type === "MOVE_DOWN" || type === "MOVE_RIGHT";
var draggable2 = state.dimensions.draggables[state.critical.draggable.id];
var previousPageBorderBoxCenter = state.current.page.borderBoxCenter;
var _state$dimensions = state.dimensions, draggables = _state$dimensions.draggables, droppables = _state$dimensions.droppables;
return isMovingOnMainAxis ? moveToNextPlace({
isMovingForward,
previousPageBorderBoxCenter,
draggable: draggable2,
destination: isOver,
draggables,
viewport: state.viewport,
previousClientSelection: state.current.client.selection,
previousImpact: state.impact,
afterCritical: state.afterCritical
}) : moveCrossAxis({
isMovingForward,
previousPageBorderBoxCenter,
draggable: draggable2,
isOver,
draggables,
droppables,
viewport: state.viewport,
afterCritical: state.afterCritical
});
});
function isMovementAllowed(state) {
return state.phase === "DRAGGING" || state.phase === "COLLECTING";
}
function isPositionInFrame(frame) {
var isWithinVertical = isWithin(frame.top, frame.bottom);
var isWithinHorizontal = isWithin(frame.left, frame.right);
return function run(point) {
return isWithinVertical(point.y) && isWithinHorizontal(point.x);
};
}
function getHasOverlap(first, second) {
return first.left < second.right && first.right > second.left && first.top < second.bottom && first.bottom > second.top;
}
function getFurthestAway(_ref) {
var pageBorderBox = _ref.pageBorderBox, draggable2 = _ref.draggable, candidates = _ref.candidates;
var startCenter = draggable2.page.borderBox.center;
var sorted = candidates.map(function(candidate) {
var axis = candidate.axis;
var target = patch(candidate.axis.line, pageBorderBox.center[axis.line], candidate.page.borderBox.center[axis.crossAxisLine]);
return {
id: candidate.descriptor.id,
distance: distance(startCenter, target)
};
}).sort(function(a, b2) {
return b2.distance - a.distance;
});
return sorted[0] ? sorted[0].id : null;
}
function getDroppableOver$1(_ref2) {
var pageBorderBox = _ref2.pageBorderBox, draggable2 = _ref2.draggable, droppables = _ref2.droppables;
var candidates = toDroppableList(droppables).filter(function(item) {
if (!item.isEnabled) {
return false;
}
var active = item.subject.active;
if (!active) {
return false;
}
if (!getHasOverlap(pageBorderBox, active)) {
return false;
}
if (isPositionInFrame(active)(pageBorderBox.center)) {
return true;
}
var axis = item.axis;
var childCenter = active.center[axis.crossAxisLine];
var crossAxisStart = pageBorderBox[axis.crossAxisStart];
var crossAxisEnd = pageBorderBox[axis.crossAxisEnd];
var isContained = isWithin(active[axis.crossAxisStart], active[axis.crossAxisEnd]);
var isStartContained = isContained(crossAxisStart);
var isEndContained = isContained(crossAxisEnd);
if (!isStartContained && !isEndContained) {
return true;
}
if (isStartContained) {
return crossAxisStart < childCenter;
}
return crossAxisEnd > childCenter;
});
if (!candidates.length) {
return null;
}
if (candidates.length === 1) {
return candidates[0].descriptor.id;
}
return getFurthestAway({
pageBorderBox,
draggable: draggable2,
candidates
});
}
var offsetRectByPosition = function offsetRectByPosition2(rect, point) {
return getRect(offsetByPosition(rect, point));
};
var withDroppableScroll = (function(droppable2, area) {
var frame = droppable2.frame;
if (!frame) {
return area;
}
return offsetRectByPosition(area, frame.scroll.diff.value);
});
function getIsDisplaced(_ref) {
var displaced = _ref.displaced, id = _ref.id;
return Boolean(displaced.visible[id] || displaced.invisible[id]);
}
function atIndex(_ref) {
var draggable2 = _ref.draggable, closest3 = _ref.closest, inHomeList = _ref.inHomeList;
if (!closest3) {
return null;
}
if (!inHomeList) {
return closest3.descriptor.index;
}
if (closest3.descriptor.index > draggable2.descriptor.index) {
return closest3.descriptor.index - 1;
}
return closest3.descriptor.index;
}
var getReorderImpact = (function(_ref2) {
var targetRect = _ref2.pageBorderBoxWithDroppableScroll, draggable2 = _ref2.draggable, destination = _ref2.destination, insideDestination = _ref2.insideDestination, last = _ref2.last, viewport = _ref2.viewport, afterCritical = _ref2.afterCritical;
var axis = destination.axis;
var displacedBy = getDisplacedBy(destination.axis, draggable2.displaceBy);
var displacement = displacedBy.value;
var targetStart = targetRect[axis.start];
var targetEnd = targetRect[axis.end];
var withoutDragging = removeDraggableFromList(draggable2, insideDestination);
var closest3 = find(withoutDragging, function(child) {
var id = child.descriptor.id;
var childCenter = child.page.borderBox.center[axis.line];
var didStartAfterCritical$1 = didStartAfterCritical(id, afterCritical);
var isDisplaced = getIsDisplaced({
displaced: last,
id
});
if (didStartAfterCritical$1) {
if (isDisplaced) {
return targetEnd <= childCenter;
}
return targetStart < childCenter - displacement;
}
if (isDisplaced) {
return targetEnd <= childCenter + displacement;
}
return targetStart < childCenter;
});
var newIndex = atIndex({
draggable: draggable2,
closest: closest3,
inHomeList: isHomeOf(draggable2, destination)
});
return calculateReorderImpact({
draggable: draggable2,
insideDestination,
destination,
viewport,
last,
displacedBy,
index: newIndex
});
});
var combineThresholdDivisor = 4;
var getCombineImpact = (function(_ref) {
var draggable2 = _ref.draggable, targetRect = _ref.pageBorderBoxWithDroppableScroll, previousImpact = _ref.previousImpact, destination = _ref.destination, insideDestination = _ref.insideDestination, afterCritical = _ref.afterCritical;
if (!destination.isCombineEnabled) {
return null;
}
var axis = destination.axis;
var displacedBy = getDisplacedBy(destination.axis, draggable2.displaceBy);
var displacement = displacedBy.value;
var targetStart = targetRect[axis.start];
var targetEnd = targetRect[axis.end];
var withoutDragging = removeDraggableFromList(draggable2, insideDestination);
var combineWith = find(withoutDragging, function(child) {
var id = child.descriptor.id;
var childRect = child.page.borderBox;
var childSize = childRect[axis.size];
var threshold = childSize / combineThresholdDivisor;
var didStartAfterCritical$1 = didStartAfterCritical(id, afterCritical);
var isDisplaced = getIsDisplaced({
displaced: previousImpact.displaced,
id
});
if (didStartAfterCritical$1) {
if (isDisplaced) {
return targetEnd > childRect[axis.start] + threshold && targetEnd < childRect[axis.end] - threshold;
}
return targetStart > childRect[axis.start] - displacement + threshold && targetStart < childRect[axis.end] - displacement - threshold;
}
if (isDisplaced) {
return targetEnd > childRect[axis.start] + displacement + threshold && targetEnd < childRect[axis.end] + displacement - threshold;
}
return targetStart > childRect[axis.start] + threshold && targetStart < childRect[axis.end] - threshold;
});
if (!combineWith) {
return null;
}
var impact = {
displacedBy,
displaced: previousImpact.displaced,
at: {
type: "COMBINE",
combine: {
draggableId: combineWith.descriptor.id,
droppableId: destination.descriptor.id
}
}
};
return impact;
});
var getDragImpact = (function(_ref) {
var pageOffset = _ref.pageOffset, draggable2 = _ref.draggable, draggables = _ref.draggables, droppables = _ref.droppables, previousImpact = _ref.previousImpact, viewport = _ref.viewport, afterCritical = _ref.afterCritical;
var pageBorderBox = offsetRectByPosition(draggable2.page.borderBox, pageOffset);
var destinationId = getDroppableOver$1({
pageBorderBox,
draggable: draggable2,
droppables
});
if (!destinationId) {
return noImpact;
}
var destination = droppables[destinationId];
var insideDestination = getDraggablesInsideDroppable(destination.descriptor.id, draggables);
var pageBorderBoxWithDroppableScroll = withDroppableScroll(destination, pageBorderBox);
return getCombineImpact({
pageBorderBoxWithDroppableScroll,
draggable: draggable2,
previousImpact,
destination,
insideDestination,
afterCritical
}) || getReorderImpact({
pageBorderBoxWithDroppableScroll,
draggable: draggable2,
destination,
insideDestination,
last: previousImpact.displaced,
viewport,
afterCritical
});
});
var patchDroppableMap = (function(droppables, updated) {
var _extends2;
return _extends$1({}, droppables, (_extends2 = {}, _extends2[updated.descriptor.id] = updated, _extends2));
});
var clearUnusedPlaceholder = function clearUnusedPlaceholder2(_ref) {
var previousImpact = _ref.previousImpact, impact = _ref.impact, droppables = _ref.droppables;
var last = whatIsDraggedOver(previousImpact);
var now = whatIsDraggedOver(impact);
if (!last) {
return droppables;
}
if (last === now) {
return droppables;
}
var lastDroppable = droppables[last];
if (!lastDroppable.subject.withPlaceholder) {
return droppables;
}
var updated = removePlaceholder(lastDroppable);
return patchDroppableMap(droppables, updated);
};
var recomputePlaceholders = (function(_ref2) {
var draggable2 = _ref2.draggable, draggables = _ref2.draggables, droppables = _ref2.droppables, previousImpact = _ref2.previousImpact, impact = _ref2.impact;
var cleaned = clearUnusedPlaceholder({
previousImpact,
impact,
droppables
});
var isOver = whatIsDraggedOver(impact);
if (!isOver) {
return cleaned;
}
var droppable2 = droppables[isOver];
if (isHomeOf(draggable2, droppable2)) {
return cleaned;
}
if (droppable2.subject.withPlaceholder) {
return cleaned;
}
var patched = addPlaceholder(droppable2, draggable2, draggables);
return patchDroppableMap(cleaned, patched);
});
var update = (function(_ref) {
var state = _ref.state, forcedClientSelection = _ref.clientSelection, forcedDimensions = _ref.dimensions, forcedViewport = _ref.viewport, forcedImpact = _ref.impact, scrollJumpRequest = _ref.scrollJumpRequest;
var viewport = forcedViewport || state.viewport;
var dimensions = forcedDimensions || state.dimensions;
var clientSelection = forcedClientSelection || state.current.client.selection;
var offset2 = subtract(clientSelection, state.initial.client.selection);
var client = {
offset: offset2,
selection: clientSelection,
borderBoxCenter: add(state.initial.client.borderBoxCenter, offset2)
};
var page = {
selection: add(client.selection, viewport.scroll.current),
borderBoxCenter: add(client.borderBoxCenter, viewport.scroll.current),
offset: add(client.offset, viewport.scroll.diff.value)
};
var current = {
client,
page
};
if (state.phase === "COLLECTING") {
return _extends$1({
phase: "COLLECTING"
}, state, {
dimensions,
viewport,
current
});
}
var draggable2 = dimensions.draggables[state.critical.draggable.id];
var newImpact = forcedImpact || getDragImpact({
pageOffset: page.offset,
draggable: draggable2,
draggables: dimensions.draggables,
droppables: dimensions.droppables,
previousImpact: state.impact,
viewport,
afterCritical: state.afterCritical
});
var withUpdatedPlaceholders = recomputePlaceholders({
draggable: draggable2,
impact: newImpact,
previousImpact: state.impact,
draggables: dimensions.draggables,
droppables: dimensions.droppables
});
var result = _extends$1({}, state, {
current,
dimensions: {
draggables: dimensions.draggables,
droppables: withUpdatedPlaceholders
},
impact: newImpact,
viewport,
scrollJumpRequest: scrollJumpRequest || null,
forceShouldAnimate: scrollJumpRequest ? false : null
});
return result;
});
function getDraggables$1(ids, draggables) {
return ids.map(function(id) {
return draggables[id];
});
}
var recompute = (function(_ref) {
var impact = _ref.impact, viewport = _ref.viewport, draggables = _ref.draggables, destination = _ref.destination, forceShouldAnimate = _ref.forceShouldAnimate;
var last = impact.displaced;
var afterDragging = getDraggables$1(last.all, draggables);
var displaced = getDisplacementGroups({
afterDragging,
destination,
displacedBy: impact.displacedBy,
viewport: viewport.frame,
forceShouldAnimate,
last
});
return _extends$1({}, impact, {
displaced
});
});
var getClientBorderBoxCenter = (function(_ref) {
var impact = _ref.impact, draggable2 = _ref.draggable, droppable2 = _ref.droppable, draggables = _ref.draggables, viewport = _ref.viewport, afterCritical = _ref.afterCritical;
var pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
impact,
draggable: draggable2,
draggables,
droppable: droppable2,
afterCritical
});
return getClientFromPageBorderBoxCenter({
pageBorderBoxCenter,
draggable: draggable2,
viewport
});
});
var refreshSnap = (function(_ref) {
var state = _ref.state, forcedDimensions = _ref.dimensions, forcedViewport = _ref.viewport;
!(state.movementMode === "SNAP") ? invariant() : void 0;
var needsVisibilityCheck = state.impact;
var viewport = forcedViewport || state.viewport;
var dimensions = forcedDimensions || state.dimensions;
var draggables = dimensions.draggables, droppables = dimensions.droppables;
var draggable2 = draggables[state.critical.draggable.id];
var isOver = whatIsDraggedOver(needsVisibilityCheck);
!isOver ? invariant() : void 0;
var destination = droppables[isOver];
var impact = recompute({
impact: needsVisibilityCheck,
viewport,
destination,
draggables
});
var clientSelection = getClientBorderBoxCenter({
impact,
draggable: draggable2,
droppable: destination,
draggables,
viewport,
afterCritical: state.afterCritical
});
return update({
impact,
clientSelection,
state,
dimensions,
viewport
});
});
var getHomeLocation = (function(descriptor) {
return {
index: descriptor.index,
droppableId: descriptor.droppableId
};
});
var getLiftEffect = (function(_ref) {
var draggable2 = _ref.draggable, home2 = _ref.home, draggables = _ref.draggables, viewport = _ref.viewport;
var displacedBy = getDisplacedBy(home2.axis, draggable2.displaceBy);
var insideHome = getDraggablesInsideDroppable(home2.descriptor.id, draggables);
var rawIndex = insideHome.indexOf(draggable2);
!(rawIndex !== -1) ? invariant() : void 0;
var afterDragging = insideHome.slice(rawIndex + 1);
var effected = afterDragging.reduce(function(previous, item) {
previous[item.descriptor.id] = true;
return previous;
}, {});
var afterCritical = {
inVirtualList: home2.descriptor.mode === "virtual",
displacedBy,
effected
};
var displaced = getDisplacementGroups({
afterDragging,
destination: home2,
displacedBy,
last: null,
viewport: viewport.frame,
forceShouldAnimate: false
});
var impact = {
displaced,
displacedBy,
at: {
type: "REORDER",
destination: getHomeLocation(draggable2.descriptor)
}
};
return {
impact,
afterCritical
};
});
var patchDimensionMap = (function(dimensions, updated) {
return {
draggables: dimensions.draggables,
droppables: patchDroppableMap(dimensions.droppables, updated)
};
});
var offsetDraggable = (function(_ref) {
var draggable2 = _ref.draggable, offset$1 = _ref.offset, initialWindowScroll = _ref.initialWindowScroll;
var client = offset(draggable2.client, offset$1);
var page = withScroll(client, initialWindowScroll);
var moved = _extends$1({}, draggable2, {
placeholder: _extends$1({}, draggable2.placeholder, {
client
}),
client,
page
});
return moved;
});
var getFrame = (function(droppable2) {
var frame = droppable2.frame;
!frame ? invariant() : void 0;
return frame;
});
var adjustAdditionsForScrollChanges = (function(_ref) {
var additions = _ref.additions, updatedDroppables = _ref.updatedDroppables, viewport = _ref.viewport;
var windowScrollChange = viewport.scroll.diff.value;
return additions.map(function(draggable2) {
var droppableId = draggable2.descriptor.droppableId;
var modified = updatedDroppables[droppableId];
var frame = getFrame(modified);
var droppableScrollChange = frame.scroll.diff.value;
var totalChange = add(windowScrollChange, droppableScrollChange);
var moved = offsetDraggable({
draggable: draggable2,
offset: totalChange,
initialWindowScroll: viewport.scroll.initial
});
return moved;
});
});
var publishWhileDraggingInVirtual = (function(_ref) {
var state = _ref.state, published = _ref.published;
var withScrollChange = published.modified.map(function(update2) {
var existing = state.dimensions.droppables[update2.droppableId];
var scrolled = scrollDroppable(existing, update2.scroll);
return scrolled;
});
var droppables = _extends$1({}, state.dimensions.droppables, {}, toDroppableMap(withScrollChange));
var updatedAdditions = toDraggableMap(adjustAdditionsForScrollChanges({
additions: published.additions,
updatedDroppables: droppables,
viewport: state.viewport
}));
var draggables = _extends$1({}, state.dimensions.draggables, {}, updatedAdditions);
published.removals.forEach(function(id) {
delete draggables[id];
});
var dimensions = {
droppables,
draggables
};
var wasOverId = whatIsDraggedOver(state.impact);
var wasOver = wasOverId ? dimensions.droppables[wasOverId] : null;
var draggable2 = dimensions.draggables[state.critical.draggable.id];
var home2 = dimensions.droppables[state.critical.droppable.id];
var _getLiftEffect = getLiftEffect({
draggable: draggable2,
home: home2,
draggables,
viewport: state.viewport
}), onLiftImpact = _getLiftEffect.impact, afterCritical = _getLiftEffect.afterCritical;
var previousImpact = wasOver && wasOver.isCombineEnabled ? state.impact : onLiftImpact;
var impact = getDragImpact({
pageOffset: state.current.page.offset,
draggable: dimensions.draggables[state.critical.draggable.id],
draggables: dimensions.draggables,
droppables: dimensions.droppables,
previousImpact,
viewport: state.viewport,
afterCritical
});
var draggingState = _extends$1({
phase: "DRAGGING"
}, state, {
phase: "DRAGGING",
impact,
onLiftImpact,
dimensions,
afterCritical,
forceShouldAnimate: false
});
if (state.phase === "COLLECTING") {
return draggingState;
}
var dropPending3 = _extends$1({
phase: "DROP_PENDING"
}, draggingState, {
phase: "DROP_PENDING",
reason: state.reason,
isWaiting: false
});
return dropPending3;
});
var isSnapping = function isSnapping2(state) {
return state.movementMode === "SNAP";
};
var postDroppableChange = function postDroppableChange2(state, updated, isEnabledChanging) {
var dimensions = patchDimensionMap(state.dimensions, updated);
if (!isSnapping(state) || isEnabledChanging) {
return update({
state,
dimensions
});
}
return refreshSnap({
state,
dimensions
});
};
function removeScrollJumpRequest(state) {
if (state.isDragging && state.movementMode === "SNAP") {
return _extends$1({
phase: "DRAGGING"
}, state, {
scrollJumpRequest: null
});
}
return state;
}
var idle = {
phase: "IDLE",
completed: null,
shouldFlush: false
};
var reducer = (function(state, action) {
if (state === void 0) {
state = idle;
}
if (action.type === "FLUSH") {
return _extends$1({}, idle, {
shouldFlush: true
});
}
if (action.type === "INITIAL_PUBLISH") {
!(state.phase === "IDLE") ? invariant() : void 0;
var _action$payload = action.payload, critical = _action$payload.critical, clientSelection = _action$payload.clientSelection, viewport = _action$payload.viewport, dimensions = _action$payload.dimensions, movementMode = _action$payload.movementMode;
var draggable2 = dimensions.draggables[critical.draggable.id];
var home2 = dimensions.droppables[critical.droppable.id];
var client = {
selection: clientSelection,
borderBoxCenter: draggable2.client.borderBox.center,
offset: origin
};
var initial = {
client,
page: {
selection: add(client.selection, viewport.scroll.initial),
borderBoxCenter: add(client.selection, viewport.scroll.initial),
offset: add(client.selection, viewport.scroll.diff.value)
}
};
var isWindowScrollAllowed = toDroppableList(dimensions.droppables).every(function(item) {
return !item.isFixedOnPage;
});
var _getLiftEffect = getLiftEffect({
draggable: draggable2,
home: home2,
draggables: dimensions.draggables,
viewport
}), impact = _getLiftEffect.impact, afterCritical = _getLiftEffect.afterCritical;
var result = {
phase: "DRAGGING",
isDragging: true,
critical,
movementMode,
dimensions,
initial,
current: initial,
isWindowScrollAllowed,
impact,
afterCritical,
onLiftImpact: impact,
viewport,
scrollJumpRequest: null,
forceShouldAnimate: null
};
return result;
}
if (action.type === "COLLECTION_STARTING") {
if (state.phase === "COLLECTING" || state.phase === "DROP_PENDING") {
return state;
}
!(state.phase === "DRAGGING") ? invariant() : void 0;
var _result = _extends$1({
phase: "COLLECTING"
}, state, {
phase: "COLLECTING"
});
return _result;
}
if (action.type === "PUBLISH_WHILE_DRAGGING") {
!(state.phase === "COLLECTING" || state.phase === "DROP_PENDING") ? invariant() : void 0;
return publishWhileDraggingInVirtual({
state,
published: action.payload
});
}
if (action.type === "MOVE") {
if (state.phase === "DROP_PENDING") {
return state;
}
!isMovementAllowed(state) ? invariant() : void 0;
var _clientSelection = action.payload.client;
if (isEqual(_clientSelection, state.current.client.selection)) {
return state;
}
return update({
state,
clientSelection: _clientSelection,
impact: isSnapping(state) ? state.impact : null
});
}
if (action.type === "UPDATE_DROPPABLE_SCROLL") {
if (state.phase === "DROP_PENDING") {
return removeScrollJumpRequest(state);
}
if (state.phase === "COLLECTING") {
return removeScrollJumpRequest(state);
}
!isMovementAllowed(state) ? invariant() : void 0;
var _action$payload2 = action.payload, id = _action$payload2.id, newScroll = _action$payload2.newScroll;
var target = state.dimensions.droppables[id];
if (!target) {
return state;
}
var scrolled = scrollDroppable(target, newScroll);
return postDroppableChange(state, scrolled, false);
}
if (action.type === "UPDATE_DROPPABLE_IS_ENABLED") {
if (state.phase === "DROP_PENDING") {
return state;
}
!isMovementAllowed(state) ? invariant() : void 0;
var _action$payload3 = action.payload, _id = _action$payload3.id, isEnabled = _action$payload3.isEnabled;
var _target = state.dimensions.droppables[_id];
!_target ? invariant() : void 0;
!(_target.isEnabled !== isEnabled) ? invariant() : void 0;
var updated = _extends$1({}, _target, {
isEnabled
});
return postDroppableChange(state, updated, true);
}
if (action.type === "UPDATE_DROPPABLE_IS_COMBINE_ENABLED") {
if (state.phase === "DROP_PENDING") {
return state;
}
!isMovementAllowed(state) ? invariant() : void 0;
var _action$payload4 = action.payload, _id2 = _action$payload4.id, isCombineEnabled = _action$payload4.isCombineEnabled;
var _target2 = state.dimensions.droppables[_id2];
!_target2 ? invariant() : void 0;
!(_target2.isCombineEnabled !== isCombineEnabled) ? invariant() : void 0;
var _updated = _extends$1({}, _target2, {
isCombineEnabled
});
return postDroppableChange(state, _updated, true);
}
if (action.type === "MOVE_BY_WINDOW_SCROLL") {
if (state.phase === "DROP_PENDING" || state.phase === "DROP_ANIMATING") {
return state;
}
!isMovementAllowed(state) ? invariant() : void 0;
!state.isWindowScrollAllowed ? invariant() : void 0;
var _newScroll = action.payload.newScroll;
if (isEqual(state.viewport.scroll.current, _newScroll)) {
return removeScrollJumpRequest(state);
}
var _viewport = scrollViewport(state.viewport, _newScroll);
if (isSnapping(state)) {
return refreshSnap({
state,
viewport: _viewport
});
}
return update({
state,
viewport: _viewport
});
}
if (action.type === "UPDATE_VIEWPORT_MAX_SCROLL") {
if (!isMovementAllowed(state)) {
return state;
}
var maxScroll = action.payload.maxScroll;
if (isEqual(maxScroll, state.viewport.scroll.max)) {
return state;
}
var withMaxScroll3 = _extends$1({}, state.viewport, {
scroll: _extends$1({}, state.viewport.scroll, {
max: maxScroll
})
});
return _extends$1({
phase: "DRAGGING"
}, state, {
viewport: withMaxScroll3
});
}
if (action.type === "MOVE_UP" || action.type === "MOVE_DOWN" || action.type === "MOVE_LEFT" || action.type === "MOVE_RIGHT") {
if (state.phase === "COLLECTING" || state.phase === "DROP_PENDING") {
return state;
}
!(state.phase === "DRAGGING") ? invariant() : void 0;
var _result2 = moveInDirection({
state,
type: action.type
});
if (!_result2) {
return state;
}
return update({
state,
impact: _result2.impact,
clientSelection: _result2.clientSelection,
scrollJumpRequest: _result2.scrollJumpRequest
});
}
if (action.type === "DROP_PENDING") {
var reason = action.payload.reason;
!(state.phase === "COLLECTING") ? invariant() : void 0;
var newState = _extends$1({
phase: "DROP_PENDING"
}, state, {
phase: "DROP_PENDING",
isWaiting: true,
reason
});
return newState;
}
if (action.type === "DROP_ANIMATE") {
var _action$payload5 = action.payload, completed = _action$payload5.completed, dropDuration = _action$payload5.dropDuration, newHomeClientOffset = _action$payload5.newHomeClientOffset;
!(state.phase === "DRAGGING" || state.phase === "DROP_PENDING") ? invariant() : void 0;
var _result3 = {
phase: "DROP_ANIMATING",
completed,
dropDuration,
newHomeClientOffset,
dimensions: state.dimensions
};
return _result3;
}
if (action.type === "DROP_COMPLETE") {
var _completed = action.payload.completed;
return {
phase: "IDLE",
completed: _completed,
shouldFlush: false
};
}
return state;
});
var beforeInitialCapture = function beforeInitialCapture2(args) {
return {
type: "BEFORE_INITIAL_CAPTURE",
payload: args
};
};
var lift = function lift2(args) {
return {
type: "LIFT",
payload: args
};
};
var initialPublish = function initialPublish2(args) {
return {
type: "INITIAL_PUBLISH",
payload: args
};
};
var publishWhileDragging = function publishWhileDragging2(args) {
return {
type: "PUBLISH_WHILE_DRAGGING",
payload: args
};
};
var collectionStarting = function collectionStarting2() {
return {
type: "COLLECTION_STARTING",
payload: null
};
};
var updateDroppableScroll = function updateDroppableScroll2(args) {
return {
type: "UPDATE_DROPPABLE_SCROLL",
payload: args
};
};
var updateDroppableIsEnabled = function updateDroppableIsEnabled2(args) {
return {
type: "UPDATE_DROPPABLE_IS_ENABLED",
payload: args
};
};
var updateDroppableIsCombineEnabled = function updateDroppableIsCombineEnabled2(args) {
return {
type: "UPDATE_DROPPABLE_IS_COMBINE_ENABLED",
payload: args
};
};
var move = function move2(args) {
return {
type: "MOVE",
payload: args
};
};
var moveByWindowScroll = function moveByWindowScroll2(args) {
return {
type: "MOVE_BY_WINDOW_SCROLL",
payload: args
};
};
var updateViewportMaxScroll = function updateViewportMaxScroll2(args) {
return {
type: "UPDATE_VIEWPORT_MAX_SCROLL",
payload: args
};
};
var moveUp = function moveUp2() {
return {
type: "MOVE_UP",
payload: null
};
};
var moveDown = function moveDown2() {
return {
type: "MOVE_DOWN",
payload: null
};
};
var moveRight = function moveRight2() {
return {
type: "MOVE_RIGHT",
payload: null
};
};
var moveLeft = function moveLeft2() {
return {
type: "MOVE_LEFT",
payload: null
};
};
var flush = function flush2() {
return {
type: "FLUSH",
payload: null
};
};
var animateDrop = function animateDrop2(args) {
return {
type: "DROP_ANIMATE",
payload: args
};
};
var completeDrop = function completeDrop2(args) {
return {
type: "DROP_COMPLETE",
payload: args
};
};
var drop = function drop2(args) {
return {
type: "DROP",
payload: args
};
};
var dropPending = function dropPending2(args) {
return {
type: "DROP_PENDING",
payload: args
};
};
var dropAnimationFinished = function dropAnimationFinished2() {
return {
type: "DROP_ANIMATION_FINISHED",
payload: null
};
};
var lift$1 = (function(marshal) {
return function(_ref) {
var getState = _ref.getState, dispatch = _ref.dispatch;
return function(next) {
return function(action) {
if (action.type !== "LIFT") {
next(action);
return;
}
var _action$payload = action.payload, id = _action$payload.id, clientSelection = _action$payload.clientSelection, movementMode = _action$payload.movementMode;
var initial = getState();
if (initial.phase === "DROP_ANIMATING") {
dispatch(completeDrop({
completed: initial.completed
}));
}
!(getState().phase === "IDLE") ? invariant() : void 0;
dispatch(flush());
dispatch(beforeInitialCapture({
draggableId: id,
movementMode
}));
var scrollOptions = {
shouldPublishImmediately: movementMode === "SNAP"
};
var request = {
draggableId: id,
scrollOptions
};
var _marshal$startPublish = marshal.startPublishing(request), critical = _marshal$startPublish.critical, dimensions = _marshal$startPublish.dimensions, viewport = _marshal$startPublish.viewport;
dispatch(initialPublish({
critical,
dimensions,
clientSelection,
movementMode,
viewport
}));
};
};
};
});
var style = (function(marshal) {
return function() {
return function(next) {
return function(action) {
if (action.type === "INITIAL_PUBLISH") {
marshal.dragging();
}
if (action.type === "DROP_ANIMATE") {
marshal.dropping(action.payload.completed.result.reason);
}
if (action.type === "FLUSH" || action.type === "DROP_COMPLETE") {
marshal.resting();
}
next(action);
};
};
};
});
var curves = {
outOfTheWay: "cubic-bezier(0.2, 0, 0, 1)",
drop: "cubic-bezier(.2,1,.1,1)"
};
var combine = {
opacity: {
drop: 0,
combining: 0.7
},
scale: {
drop: 0.75
}
};
var timings = {
outOfTheWay: 0.2,
minDropTime: 0.33,
maxDropTime: 0.55
};
var outOfTheWayTiming = timings.outOfTheWay + "s " + curves.outOfTheWay;
var transitions = {
fluid: "opacity " + outOfTheWayTiming,
snap: "transform " + outOfTheWayTiming + ", opacity " + outOfTheWayTiming,
drop: function drop3(duration) {
var timing = duration + "s " + curves.drop;
return "transform " + timing + ", opacity " + timing;
},
outOfTheWay: "transform " + outOfTheWayTiming,
placeholder: "height " + outOfTheWayTiming + ", width " + outOfTheWayTiming + ", margin " + outOfTheWayTiming
};
var moveTo = function moveTo2(offset2) {
return isEqual(offset2, origin) ? null : "translate(" + offset2.x + "px, " + offset2.y + "px)";
};
var transforms = {
moveTo,
drop: function drop4(offset2, isCombining) {
var translate = moveTo(offset2);
if (!translate) {
return null;
}
if (!isCombining) {
return translate;
}
return translate + " scale(" + combine.scale.drop + ")";
}
};
var minDropTime = timings.minDropTime, maxDropTime = timings.maxDropTime;
var dropTimeRange = maxDropTime - minDropTime;
var maxDropTimeAtDistance = 1500;
var cancelDropModifier = 0.6;
var getDropDuration = (function(_ref) {
var current = _ref.current, destination = _ref.destination, reason = _ref.reason;
var distance$1 = distance(current, destination);
if (distance$1 <= 0) {
return minDropTime;
}
if (distance$1 >= maxDropTimeAtDistance) {
return maxDropTime;
}
var percentage = distance$1 / maxDropTimeAtDistance;
var duration = minDropTime + dropTimeRange * percentage;
var withDuration = reason === "CANCEL" ? duration * cancelDropModifier : duration;
return Number(withDuration.toFixed(2));
});
var getNewHomeClientOffset = (function(_ref) {
var impact = _ref.impact, draggable2 = _ref.draggable, dimensions = _ref.dimensions, viewport = _ref.viewport, afterCritical = _ref.afterCritical;
var draggables = dimensions.draggables, droppables = dimensions.droppables;
var droppableId = whatIsDraggedOver(impact);
var destination = droppableId ? droppables[droppableId] : null;
var home2 = droppables[draggable2.descriptor.droppableId];
var newClientCenter = getClientBorderBoxCenter({
impact,
draggable: draggable2,
draggables,
afterCritical,
droppable: destination || home2,
viewport
});
var offset2 = subtract(newClientCenter, draggable2.client.borderBox.center);
return offset2;
});
var getDropImpact = (function(_ref) {
var draggables = _ref.draggables, reason = _ref.reason, lastImpact = _ref.lastImpact, home2 = _ref.home, viewport = _ref.viewport, onLiftImpact = _ref.onLiftImpact;
if (!lastImpact.at || reason !== "DROP") {
var recomputedHomeImpact = recompute({
draggables,
impact: onLiftImpact,
destination: home2,
viewport,
forceShouldAnimate: true
});
return {
impact: recomputedHomeImpact,
didDropInsideDroppable: false
};
}
if (lastImpact.at.type === "REORDER") {
return {
impact: lastImpact,
didDropInsideDroppable: true
};
}
var withoutMovement = _extends$1({}, lastImpact, {
displaced: emptyGroups
});
return {
impact: withoutMovement,
didDropInsideDroppable: true
};
});
var drop$1 = (function(_ref) {
var getState = _ref.getState, dispatch = _ref.dispatch;
return function(next) {
return function(action) {
if (action.type !== "DROP") {
next(action);
return;
}
var state = getState();
var reason = action.payload.reason;
if (state.phase === "COLLECTING") {
dispatch(dropPending({
reason
}));
return;
}
if (state.phase === "IDLE") {
return;
}
var isWaitingForDrop = state.phase === "DROP_PENDING" && state.isWaiting;
!!isWaitingForDrop ? invariant() : void 0;
!(state.phase === "DRAGGING" || state.phase === "DROP_PENDING") ? invariant() : void 0;
var critical = state.critical;
var dimensions = state.dimensions;
var draggable2 = dimensions.draggables[state.critical.draggable.id];
var _getDropImpact = getDropImpact({
reason,
lastImpact: state.impact,
afterCritical: state.afterCritical,
onLiftImpact: state.onLiftImpact,
home: state.dimensions.droppables[state.critical.droppable.id],
viewport: state.viewport,
draggables: state.dimensions.draggables
}), impact = _getDropImpact.impact, didDropInsideDroppable = _getDropImpact.didDropInsideDroppable;
var destination = didDropInsideDroppable ? tryGetDestination(impact) : null;
var combine2 = didDropInsideDroppable ? tryGetCombine(impact) : null;
var source = {
index: critical.draggable.index,
droppableId: critical.droppable.id
};
var result = {
draggableId: draggable2.descriptor.id,
type: draggable2.descriptor.type,
source,
reason,
mode: state.movementMode,
destination,
combine: combine2
};
var newHomeClientOffset = getNewHomeClientOffset({
impact,
draggable: draggable2,
dimensions,
viewport: state.viewport,
afterCritical: state.afterCritical
});
var completed = {
critical: state.critical,
afterCritical: state.afterCritical,
result,
impact
};
var isAnimationRequired = !isEqual(state.current.client.offset, newHomeClientOffset) || Boolean(result.combine);
if (!isAnimationRequired) {
dispatch(completeDrop({
completed
}));
return;
}
var dropDuration = getDropDuration({
current: state.current.client.offset,
destination: newHomeClientOffset,
reason
});
var args = {
newHomeClientOffset,
dropDuration,
completed
};
dispatch(animateDrop(args));
};
};
});
var getWindowScroll = (function() {
return {
x: window.pageXOffset,
y: window.pageYOffset
};
});
function getWindowScrollBinding(update2) {
return {
eventName: "scroll",
options: {
passive: true,
capture: false
},
fn: function fn(event) {
if (event.target !== window && event.target !== window.document) {
return;
}
update2();
}
};
}
function getScrollListener(_ref) {
var onWindowScroll = _ref.onWindowScroll;
function updateScroll() {
onWindowScroll(getWindowScroll());
}
var scheduled = rafSchd(updateScroll);
var binding = getWindowScrollBinding(scheduled);
var unbind = noop$1;
function isActive() {
return unbind !== noop$1;
}
function start3() {
!!isActive() ? invariant() : void 0;
unbind = bindEvents(window, [
binding
]);
}
function stop() {
!isActive() ? invariant() : void 0;
scheduled.cancel();
unbind();
unbind = noop$1;
}
return {
start: start3,
stop,
isActive
};
}
var shouldEnd = function shouldEnd2(action) {
return action.type === "DROP_COMPLETE" || action.type === "DROP_ANIMATE" || action.type === "FLUSH";
};
var scrollListener = (function(store2) {
var listener = getScrollListener({
onWindowScroll: function onWindowScroll(newScroll) {
store2.dispatch(moveByWindowScroll({
newScroll
}));
}
});
return function(next) {
return function(action) {
if (!listener.isActive() && action.type === "INITIAL_PUBLISH") {
listener.start();
}
if (listener.isActive() && shouldEnd(action)) {
listener.stop();
}
next(action);
};
};
});
var getExpiringAnnounce = (function(announce) {
var wasCalled = false;
var isExpired = false;
var timeoutId = setTimeout(function() {
isExpired = true;
});
var result = function result2(message) {
if (wasCalled) {
return;
}
if (isExpired) {
return;
}
wasCalled = true;
announce(message);
clearTimeout(timeoutId);
};
result.wasCalled = function() {
return wasCalled;
};
return result;
});
var getAsyncMarshal = (function() {
var entries = [];
var execute3 = function execute4(timerId) {
var index = findIndex(entries, function(item) {
return item.timerId === timerId;
});
!(index !== -1) ? invariant() : void 0;
var _entries$splice = entries.splice(index, 1), entry = _entries$splice[0];
entry.callback();
};
var add3 = function add4(fn) {
var timerId = setTimeout(function() {
return execute3(timerId);
});
var entry = {
timerId,
callback: fn
};
entries.push(entry);
};
var flush3 = function flush4() {
if (!entries.length) {
return;
}
var shallow = [].concat(entries);
entries.length = 0;
shallow.forEach(function(entry) {
clearTimeout(entry.timerId);
entry.callback();
});
};
return {
add: add3,
flush: flush3
};
});
var areLocationsEqual = function areLocationsEqual2(first, second) {
if (first == null && second == null) {
return true;
}
if (first == null || second == null) {
return false;
}
return first.droppableId === second.droppableId && first.index === second.index;
};
var isCombineEqual = function isCombineEqual2(first, second) {
if (first == null && second == null) {
return true;
}
if (first == null || second == null) {
return false;
}
return first.draggableId === second.draggableId && first.droppableId === second.droppableId;
};
var isCriticalEqual = function isCriticalEqual2(first, second) {
if (first === second) {
return true;
}
var isDraggableEqual = first.draggable.id === second.draggable.id && first.draggable.droppableId === second.draggable.droppableId && first.draggable.type === second.draggable.type && first.draggable.index === second.draggable.index;
var isDroppableEqual = first.droppable.id === second.droppable.id && first.droppable.type === second.droppable.type;
return isDraggableEqual && isDroppableEqual;
};
var withTimings = function withTimings2(key, fn) {
fn();
};
var getDragStart = function getDragStart2(critical, mode) {
return {
draggableId: critical.draggable.id,
type: critical.droppable.type,
source: {
droppableId: critical.droppable.id,
index: critical.draggable.index
},
mode
};
};
var execute = function execute2(responder, data, announce, getDefaultMessage) {
if (!responder) {
announce(getDefaultMessage(data));
return;
}
var willExpire = getExpiringAnnounce(announce);
var provided = {
announce: willExpire
};
responder(data, provided);
if (!willExpire.wasCalled()) {
announce(getDefaultMessage(data));
}
};
var getPublisher = (function(getResponders, announce) {
var asyncMarshal = getAsyncMarshal();
var dragging = null;
var beforeCapture = function beforeCapture2(draggableId, mode) {
!!dragging ? invariant() : void 0;
withTimings("onBeforeCapture", function() {
var fn = getResponders().onBeforeCapture;
if (fn) {
var before = {
draggableId,
mode
};
fn(before);
}
});
};
var beforeStart = function beforeStart2(critical, mode) {
!!dragging ? invariant() : void 0;
withTimings("onBeforeDragStart", function() {
var fn = getResponders().onBeforeDragStart;
if (fn) {
fn(getDragStart(critical, mode));
}
});
};
var start3 = function start4(critical, mode) {
!!dragging ? invariant() : void 0;
var data = getDragStart(critical, mode);
dragging = {
mode,
lastCritical: critical,
lastLocation: data.source,
lastCombine: null
};
asyncMarshal.add(function() {
withTimings("onDragStart", function() {
return execute(getResponders().onDragStart, data, announce, preset.onDragStart);
});
});
};
var update2 = function update3(critical, impact) {
var location = tryGetDestination(impact);
var combine2 = tryGetCombine(impact);
!dragging ? invariant() : void 0;
var hasCriticalChanged = !isCriticalEqual(critical, dragging.lastCritical);
if (hasCriticalChanged) {
dragging.lastCritical = critical;
}
var hasLocationChanged = !areLocationsEqual(dragging.lastLocation, location);
if (hasLocationChanged) {
dragging.lastLocation = location;
}
var hasGroupingChanged = !isCombineEqual(dragging.lastCombine, combine2);
if (hasGroupingChanged) {
dragging.lastCombine = combine2;
}
if (!hasCriticalChanged && !hasLocationChanged && !hasGroupingChanged) {
return;
}
var data = _extends$1({}, getDragStart(critical, dragging.mode), {
combine: combine2,
destination: location
});
asyncMarshal.add(function() {
withTimings("onDragUpdate", function() {
return execute(getResponders().onDragUpdate, data, announce, preset.onDragUpdate);
});
});
};
var flush3 = function flush4() {
!dragging ? invariant() : void 0;
asyncMarshal.flush();
};
var drop5 = function drop6(result) {
!dragging ? invariant() : void 0;
dragging = null;
withTimings("onDragEnd", function() {
return execute(getResponders().onDragEnd, result, announce, preset.onDragEnd);
});
};
var abort = function abort2() {
if (!dragging) {
return;
}
var result = _extends$1({}, getDragStart(dragging.lastCritical, dragging.mode), {
combine: null,
destination: null,
reason: "CANCEL"
});
drop5(result);
};
return {
beforeCapture,
beforeStart,
start: start3,
update: update2,
flush: flush3,
drop: drop5,
abort
};
});
var responders = (function(getResponders, announce) {
var publisher = getPublisher(getResponders, announce);
return function(store2) {
return function(next) {
return function(action) {
if (action.type === "BEFORE_INITIAL_CAPTURE") {
publisher.beforeCapture(action.payload.draggableId, action.payload.movementMode);
return;
}
if (action.type === "INITIAL_PUBLISH") {
var critical = action.payload.critical;
publisher.beforeStart(critical, action.payload.movementMode);
next(action);
publisher.start(critical, action.payload.movementMode);
return;
}
if (action.type === "DROP_COMPLETE") {
var result = action.payload.completed.result;
publisher.flush();
next(action);
publisher.drop(result);
return;
}
next(action);
if (action.type === "FLUSH") {
publisher.abort();
return;
}
var state = store2.getState();
if (state.phase === "DRAGGING") {
publisher.update(state.critical, state.impact);
}
};
};
};
});
var dropAnimationFinish = (function(store2) {
return function(next) {
return function(action) {
if (action.type !== "DROP_ANIMATION_FINISHED") {
next(action);
return;
}
var state = store2.getState();
!(state.phase === "DROP_ANIMATING") ? invariant() : void 0;
store2.dispatch(completeDrop({
completed: state.completed
}));
};
};
});
var dropAnimationFlushOnScroll = (function(store2) {
var unbind = null;
var frameId = null;
function clear() {
if (frameId) {
cancelAnimationFrame(frameId);
frameId = null;
}
if (unbind) {
unbind();
unbind = null;
}
}
return function(next) {
return function(action) {
if (action.type === "FLUSH" || action.type === "DROP_COMPLETE" || action.type === "DROP_ANIMATION_FINISHED") {
clear();
}
next(action);
if (action.type !== "DROP_ANIMATE") {
return;
}
var binding = {
eventName: "scroll",
options: {
capture: true,
passive: false,
once: true
},
fn: function flushDropAnimation() {
var state = store2.getState();
if (state.phase === "DROP_ANIMATING") {
store2.dispatch(dropAnimationFinished());
}
}
};
frameId = requestAnimationFrame(function() {
frameId = null;
unbind = bindEvents(window, [
binding
]);
});
};
};
});
var dimensionMarshalStopper = (function(marshal) {
return function() {
return function(next) {
return function(action) {
if (action.type === "DROP_COMPLETE" || action.type === "FLUSH" || action.type === "DROP_ANIMATE") {
marshal.stopPublishing();
}
next(action);
};
};
};
});
var focus = (function(marshal) {
var isWatching = false;
return function() {
return function(next) {
return function(action) {
if (action.type === "INITIAL_PUBLISH") {
isWatching = true;
marshal.tryRecordFocus(action.payload.critical.draggable.id);
next(action);
marshal.tryRestoreFocusRecorded();
return;
}
next(action);
if (!isWatching) {
return;
}
if (action.type === "FLUSH") {
isWatching = false;
marshal.tryRestoreFocusRecorded();
return;
}
if (action.type === "DROP_COMPLETE") {
isWatching = false;
var result = action.payload.completed.result;
if (result.combine) {
marshal.tryShiftRecord(result.draggableId, result.combine.draggableId);
}
marshal.tryRestoreFocusRecorded();
}
};
};
};
});
var shouldStop = function shouldStop2(action) {
return action.type === "DROP_COMPLETE" || action.type === "DROP_ANIMATE" || action.type === "FLUSH";
};
var autoScroll = (function(autoScroller) {
return function(store2) {
return function(next) {
return function(action) {
if (shouldStop(action)) {
autoScroller.stop();
next(action);
return;
}
if (action.type === "INITIAL_PUBLISH") {
next(action);
var state = store2.getState();
!(state.phase === "DRAGGING") ? invariant() : void 0;
autoScroller.start(state);
return;
}
next(action);
autoScroller.scroll(store2.getState());
};
};
};
});
var pendingDrop = (function(store2) {
return function(next) {
return function(action) {
next(action);
if (action.type !== "PUBLISH_WHILE_DRAGGING") {
return;
}
var postActionState = store2.getState();
if (postActionState.phase !== "DROP_PENDING") {
return;
}
if (postActionState.isWaiting) {
return;
}
store2.dispatch(drop({
reason: postActionState.reason
}));
};
};
});
var composeEnhancers = compose;
var createStore = (function(_ref) {
var dimensionMarshal = _ref.dimensionMarshal, focusMarshal = _ref.focusMarshal, styleMarshal = _ref.styleMarshal, getResponders = _ref.getResponders, announce = _ref.announce, autoScroller = _ref.autoScroller;
return createStore$1(reducer, composeEnhancers(applyMiddleware(style(styleMarshal), dimensionMarshalStopper(dimensionMarshal), lift$1(dimensionMarshal), drop$1, dropAnimationFinish, dropAnimationFlushOnScroll, pendingDrop, autoScroll(autoScroller), scrollListener, focus(focusMarshal), responders(getResponders, announce))));
});
var clean$1 = function clean3() {
return {
additions: {},
removals: {},
modified: {}
};
};
function createPublisher(_ref) {
var registry = _ref.registry, callbacks = _ref.callbacks;
var staging = clean$1();
var frameId = null;
var collect = function collect2() {
if (frameId) {
return;
}
callbacks.collectionStarting();
frameId = requestAnimationFrame(function() {
frameId = null;
var _staging = staging, additions = _staging.additions, removals = _staging.removals, modified = _staging.modified;
var added = Object.keys(additions).map(function(id) {
return registry.draggable.getById(id).getDimension(origin);
}).sort(function(a, b2) {
return a.descriptor.index - b2.descriptor.index;
});
var updated = Object.keys(modified).map(function(id) {
var entry = registry.droppable.getById(id);
var scroll3 = entry.callbacks.getScrollWhileDragging();
return {
droppableId: id,
scroll: scroll3
};
});
var result = {
additions: added,
removals: Object.keys(removals),
modified: updated
};
staging = clean$1();
callbacks.publish(result);
});
};
var add3 = function add4(entry) {
var id = entry.descriptor.id;
staging.additions[id] = entry;
staging.modified[entry.descriptor.droppableId] = true;
if (staging.removals[id]) {
delete staging.removals[id];
}
collect();
};
var remove = function remove2(entry) {
var descriptor = entry.descriptor;
staging.removals[descriptor.id] = true;
staging.modified[descriptor.droppableId] = true;
if (staging.additions[descriptor.id]) {
delete staging.additions[descriptor.id];
}
collect();
};
var stop = function stop2() {
if (!frameId) {
return;
}
cancelAnimationFrame(frameId);
frameId = null;
staging = clean$1();
};
return {
add: add3,
remove,
stop
};
}
var getMaxScroll = (function(_ref) {
var scrollHeight = _ref.scrollHeight, scrollWidth = _ref.scrollWidth, height = _ref.height, width = _ref.width;
var maxScroll = subtract({
x: scrollWidth,
y: scrollHeight
}, {
x: width,
y: height
});
var adjustedMaxScroll = {
x: Math.max(0, maxScroll.x),
y: Math.max(0, maxScroll.y)
};
return adjustedMaxScroll;
});
var getDocumentElement = (function() {
var doc = document.documentElement;
!doc ? invariant() : void 0;
return doc;
});
var getMaxWindowScroll = (function() {
var doc = getDocumentElement();
var maxScroll = getMaxScroll({
scrollHeight: doc.scrollHeight,
scrollWidth: doc.scrollWidth,
width: doc.clientWidth,
height: doc.clientHeight
});
return maxScroll;
});
var getViewport = (function() {
var scroll3 = getWindowScroll();
var maxScroll = getMaxWindowScroll();
var top = scroll3.y;
var left = scroll3.x;
var doc = getDocumentElement();
var width = doc.clientWidth;
var height = doc.clientHeight;
var right = left + width;
var bottom = top + height;
var frame = getRect({
top,
left,
right,
bottom
});
var viewport = {
frame,
scroll: {
initial: scroll3,
current: scroll3,
max: maxScroll,
diff: {
value: origin,
displacement: origin
}
}
};
return viewport;
});
var getInitialPublish = (function(_ref) {
var critical = _ref.critical, scrollOptions = _ref.scrollOptions, registry = _ref.registry;
var viewport = getViewport();
var windowScroll = viewport.scroll.current;
var home2 = critical.droppable;
var droppables = registry.droppable.getAllByType(home2.type).map(function(entry) {
return entry.callbacks.getDimensionAndWatchScroll(windowScroll, scrollOptions);
});
var draggables = registry.draggable.getAllByType(critical.draggable.type).map(function(entry) {
return entry.getDimension(windowScroll);
});
var dimensions = {
draggables: toDraggableMap(draggables),
droppables: toDroppableMap(droppables)
};
var result = {
dimensions,
critical,
viewport
};
return result;
});
function shouldPublishUpdate(registry, dragging, entry) {
if (entry.descriptor.id === dragging.id) {
return false;
}
if (entry.descriptor.type !== dragging.type) {
return false;
}
var home2 = registry.droppable.getById(entry.descriptor.droppableId);
if (home2.descriptor.mode !== "virtual") {
return false;
}
return true;
}
var createDimensionMarshal = (function(registry, callbacks) {
var collection = null;
var publisher = createPublisher({
callbacks: {
publish: callbacks.publishWhileDragging,
collectionStarting: callbacks.collectionStarting
},
registry
});
var updateDroppableIsEnabled3 = function updateDroppableIsEnabled4(id, isEnabled) {
!registry.droppable.exists(id) ? invariant() : void 0;
if (!collection) {
return;
}
callbacks.updateDroppableIsEnabled({
id,
isEnabled
});
};
var updateDroppableIsCombineEnabled3 = function updateDroppableIsCombineEnabled4(id, isCombineEnabled) {
if (!collection) {
return;
}
!registry.droppable.exists(id) ? invariant() : void 0;
callbacks.updateDroppableIsCombineEnabled({
id,
isCombineEnabled
});
};
var updateDroppableScroll3 = function updateDroppableScroll4(id, newScroll) {
if (!collection) {
return;
}
!registry.droppable.exists(id) ? invariant() : void 0;
callbacks.updateDroppableScroll({
id,
newScroll
});
};
var scrollDroppable2 = function scrollDroppable3(id, change) {
if (!collection) {
return;
}
registry.droppable.getById(id).callbacks.scroll(change);
};
var stopPublishing = function stopPublishing2() {
if (!collection) {
return;
}
publisher.stop();
var home2 = collection.critical.droppable;
registry.droppable.getAllByType(home2.type).forEach(function(entry) {
return entry.callbacks.dragStopped();
});
collection.unsubscribe();
collection = null;
};
var subscriber = function subscriber2(event) {
!collection ? invariant() : void 0;
var dragging = collection.critical.draggable;
if (event.type === "ADDITION") {
if (shouldPublishUpdate(registry, dragging, event.value)) {
publisher.add(event.value);
}
}
if (event.type === "REMOVAL") {
if (shouldPublishUpdate(registry, dragging, event.value)) {
publisher.remove(event.value);
}
}
};
var startPublishing = function startPublishing2(request) {
!!collection ? invariant() : void 0;
var entry = registry.draggable.getById(request.draggableId);
var home2 = registry.droppable.getById(entry.descriptor.droppableId);
var critical = {
draggable: entry.descriptor,
droppable: home2.descriptor
};
var unsubscribe = registry.subscribe(subscriber);
collection = {
critical,
unsubscribe
};
return getInitialPublish({
critical,
registry,
scrollOptions: request.scrollOptions
});
};
var marshal = {
updateDroppableIsEnabled: updateDroppableIsEnabled3,
updateDroppableIsCombineEnabled: updateDroppableIsCombineEnabled3,
scrollDroppable: scrollDroppable2,
updateDroppableScroll: updateDroppableScroll3,
startPublishing,
stopPublishing
};
return marshal;
});
var canStartDrag = (function(state, id) {
if (state.phase === "IDLE") {
return true;
}
if (state.phase !== "DROP_ANIMATING") {
return false;
}
if (state.completed.result.draggableId === id) {
return false;
}
return state.completed.result.reason === "DROP";
});
var scrollWindow = (function(change) {
window.scrollBy(change.x, change.y);
});
var getScrollableDroppables = memoizeOne(function(droppables) {
return toDroppableList(droppables).filter(function(droppable2) {
if (!droppable2.isEnabled) {
return false;
}
if (!droppable2.frame) {
return false;
}
return true;
});
});
var getScrollableDroppableOver = function getScrollableDroppableOver2(target, droppables) {
var maybe = find(getScrollableDroppables(droppables), function(droppable2) {
!droppable2.frame ? invariant() : void 0;
return isPositionInFrame(droppable2.frame.pageMarginBox)(target);
});
return maybe;
};
var getBestScrollableDroppable = (function(_ref) {
var center = _ref.center, destination = _ref.destination, droppables = _ref.droppables;
if (destination) {
var _dimension = droppables[destination];
if (!_dimension.frame) {
return null;
}
return _dimension;
}
var dimension = getScrollableDroppableOver(center, droppables);
return dimension;
});
var config = {
startFromPercentage: 0.25,
maxScrollAtPercentage: 0.05,
maxPixelScroll: 28,
ease: function ease(percentage) {
return Math.pow(percentage, 2);
},
durationDampening: {
stopDampeningAt: 1200,
accelerateAt: 360
}
};
var getDistanceThresholds = (function(container, axis) {
var startScrollingFrom = container[axis.size] * config.startFromPercentage;
var maxScrollValueAt = container[axis.size] * config.maxScrollAtPercentage;
var thresholds = {
startScrollingFrom,
maxScrollValueAt
};
return thresholds;
});
var getPercentage = (function(_ref) {
var startOfRange = _ref.startOfRange, endOfRange = _ref.endOfRange, current = _ref.current;
var range = endOfRange - startOfRange;
if (range === 0) {
return 0;
}
var currentInRange = current - startOfRange;
var percentage = currentInRange / range;
return percentage;
});
var minScroll = 1;
var getValueFromDistance = (function(distanceToEdge, thresholds) {
if (distanceToEdge > thresholds.startScrollingFrom) {
return 0;
}
if (distanceToEdge <= thresholds.maxScrollValueAt) {
return config.maxPixelScroll;
}
if (distanceToEdge === thresholds.startScrollingFrom) {
return minScroll;
}
var percentageFromMaxScrollValueAt = getPercentage({
startOfRange: thresholds.maxScrollValueAt,
endOfRange: thresholds.startScrollingFrom,
current: distanceToEdge
});
var percentageFromStartScrollingFrom = 1 - percentageFromMaxScrollValueAt;
var scroll3 = config.maxPixelScroll * config.ease(percentageFromStartScrollingFrom);
return Math.ceil(scroll3);
});
var accelerateAt = config.durationDampening.accelerateAt;
var stopAt = config.durationDampening.stopDampeningAt;
var dampenValueByTime = (function(proposedScroll, dragStartTime) {
var startOfRange = dragStartTime;
var endOfRange = stopAt;
var now = Date.now();
var runTime = now - startOfRange;
if (runTime >= stopAt) {
return proposedScroll;
}
if (runTime < accelerateAt) {
return minScroll;
}
var betweenAccelerateAtAndStopAtPercentage = getPercentage({
startOfRange: accelerateAt,
endOfRange,
current: runTime
});
var scroll3 = proposedScroll * config.ease(betweenAccelerateAtAndStopAtPercentage);
return Math.ceil(scroll3);
});
var getValue = (function(_ref) {
var distanceToEdge = _ref.distanceToEdge, thresholds = _ref.thresholds, dragStartTime = _ref.dragStartTime, shouldUseTimeDampening = _ref.shouldUseTimeDampening;
var scroll3 = getValueFromDistance(distanceToEdge, thresholds);
if (scroll3 === 0) {
return 0;
}
if (!shouldUseTimeDampening) {
return scroll3;
}
return Math.max(dampenValueByTime(scroll3, dragStartTime), minScroll);
});
var getScrollOnAxis = (function(_ref) {
var container = _ref.container, distanceToEdges = _ref.distanceToEdges, dragStartTime = _ref.dragStartTime, axis = _ref.axis, shouldUseTimeDampening = _ref.shouldUseTimeDampening;
var thresholds = getDistanceThresholds(container, axis);
var isCloserToEnd = distanceToEdges[axis.end] < distanceToEdges[axis.start];
if (isCloserToEnd) {
return getValue({
distanceToEdge: distanceToEdges[axis.end],
thresholds,
dragStartTime,
shouldUseTimeDampening
});
}
return -1 * getValue({
distanceToEdge: distanceToEdges[axis.start],
thresholds,
dragStartTime,
shouldUseTimeDampening
});
});
var adjustForSizeLimits = (function(_ref) {
var container = _ref.container, subject = _ref.subject, proposedScroll = _ref.proposedScroll;
var isTooBigVertically = subject.height > container.height;
var isTooBigHorizontally = subject.width > container.width;
if (!isTooBigHorizontally && !isTooBigVertically) {
return proposedScroll;
}
if (isTooBigHorizontally && isTooBigVertically) {
return null;
}
return {
x: isTooBigHorizontally ? 0 : proposedScroll.x,
y: isTooBigVertically ? 0 : proposedScroll.y
};
});
var clean$2 = apply(function(value) {
return value === 0 ? 0 : value;
});
var getScroll = (function(_ref) {
var dragStartTime = _ref.dragStartTime, container = _ref.container, subject = _ref.subject, center = _ref.center, shouldUseTimeDampening = _ref.shouldUseTimeDampening;
var distanceToEdges = {
top: center.y - container.top,
right: container.right - center.x,
bottom: container.bottom - center.y,
left: center.x - container.left
};
var y2 = getScrollOnAxis({
container,
distanceToEdges,
dragStartTime,
axis: vertical,
shouldUseTimeDampening
});
var x2 = getScrollOnAxis({
container,
distanceToEdges,
dragStartTime,
axis: horizontal,
shouldUseTimeDampening
});
var required2 = clean$2({
x: x2,
y: y2
});
if (isEqual(required2, origin)) {
return null;
}
var limited = adjustForSizeLimits({
container,
subject,
proposedScroll: required2
});
if (!limited) {
return null;
}
return isEqual(limited, origin) ? null : limited;
});
var smallestSigned = apply(function(value) {
if (value === 0) {
return 0;
}
return value > 0 ? 1 : -1;
});
var getOverlap = /* @__PURE__ */ (function() {
var getRemainder = function getRemainder2(target, max) {
if (target < 0) {
return target;
}
if (target > max) {
return target - max;
}
return 0;
};
return function(_ref) {
var current = _ref.current, max = _ref.max, change = _ref.change;
var targetScroll = add(current, change);
var overlap = {
x: getRemainder(targetScroll.x, max.x),
y: getRemainder(targetScroll.y, max.y)
};
if (isEqual(overlap, origin)) {
return null;
}
return overlap;
};
})();
var canPartiallyScroll = function canPartiallyScroll2(_ref2) {
var rawMax = _ref2.max, current = _ref2.current, change = _ref2.change;
var max = {
x: Math.max(current.x, rawMax.x),
y: Math.max(current.y, rawMax.y)
};
var smallestChange = smallestSigned(change);
var overlap = getOverlap({
max,
current,
change: smallestChange
});
if (!overlap) {
return true;
}
if (smallestChange.x !== 0 && overlap.x === 0) {
return true;
}
if (smallestChange.y !== 0 && overlap.y === 0) {
return true;
}
return false;
};
var canScrollWindow = function canScrollWindow2(viewport, change) {
return canPartiallyScroll({
current: viewport.scroll.current,
max: viewport.scroll.max,
change
});
};
var getWindowOverlap = function getWindowOverlap2(viewport, change) {
if (!canScrollWindow(viewport, change)) {
return null;
}
var max = viewport.scroll.max;
var current = viewport.scroll.current;
return getOverlap({
current,
max,
change
});
};
var canScrollDroppable = function canScrollDroppable2(droppable2, change) {
var frame = droppable2.frame;
if (!frame) {
return false;
}
return canPartiallyScroll({
current: frame.scroll.current,
max: frame.scroll.max,
change
});
};
var getDroppableOverlap = function getDroppableOverlap2(droppable2, change) {
var frame = droppable2.frame;
if (!frame) {
return null;
}
if (!canScrollDroppable(droppable2, change)) {
return null;
}
return getOverlap({
current: frame.scroll.current,
max: frame.scroll.max,
change
});
};
var getWindowScrollChange = (function(_ref) {
var viewport = _ref.viewport, subject = _ref.subject, center = _ref.center, dragStartTime = _ref.dragStartTime, shouldUseTimeDampening = _ref.shouldUseTimeDampening;
var scroll3 = getScroll({
dragStartTime,
container: viewport.frame,
subject,
center,
shouldUseTimeDampening
});
return scroll3 && canScrollWindow(viewport, scroll3) ? scroll3 : null;
});
var getDroppableScrollChange = (function(_ref) {
var droppable2 = _ref.droppable, subject = _ref.subject, center = _ref.center, dragStartTime = _ref.dragStartTime, shouldUseTimeDampening = _ref.shouldUseTimeDampening;
var frame = droppable2.frame;
if (!frame) {
return null;
}
var scroll3 = getScroll({
dragStartTime,
container: frame.pageMarginBox,
subject,
center,
shouldUseTimeDampening
});
return scroll3 && canScrollDroppable(droppable2, scroll3) ? scroll3 : null;
});
var scroll$1 = (function(_ref) {
var state = _ref.state, dragStartTime = _ref.dragStartTime, shouldUseTimeDampening = _ref.shouldUseTimeDampening, scrollWindow2 = _ref.scrollWindow, scrollDroppable2 = _ref.scrollDroppable;
var center = state.current.page.borderBoxCenter;
var draggable2 = state.dimensions.draggables[state.critical.draggable.id];
var subject = draggable2.page.marginBox;
if (state.isWindowScrollAllowed) {
var viewport = state.viewport;
var _change = getWindowScrollChange({
dragStartTime,
viewport,
subject,
center,
shouldUseTimeDampening
});
if (_change) {
scrollWindow2(_change);
return;
}
}
var droppable2 = getBestScrollableDroppable({
center,
destination: whatIsDraggedOver(state.impact),
droppables: state.dimensions.droppables
});
if (!droppable2) {
return;
}
var change = getDroppableScrollChange({
dragStartTime,
droppable: droppable2,
subject,
center,
shouldUseTimeDampening
});
if (change) {
scrollDroppable2(droppable2.descriptor.id, change);
}
});
var createFluidScroller = (function(_ref) {
var scrollWindow2 = _ref.scrollWindow, scrollDroppable2 = _ref.scrollDroppable;
var scheduleWindowScroll = rafSchd(scrollWindow2);
var scheduleDroppableScroll = rafSchd(scrollDroppable2);
var dragging = null;
var tryScroll = function tryScroll2(state) {
!dragging ? invariant() : void 0;
var _dragging = dragging, shouldUseTimeDampening = _dragging.shouldUseTimeDampening, dragStartTime = _dragging.dragStartTime;
scroll$1({
state,
scrollWindow: scheduleWindowScroll,
scrollDroppable: scheduleDroppableScroll,
dragStartTime,
shouldUseTimeDampening
});
};
var start$1 = function start$12(state) {
!!dragging ? invariant() : void 0;
var dragStartTime = Date.now();
var wasScrollNeeded = false;
var fakeScrollCallback = function fakeScrollCallback2() {
wasScrollNeeded = true;
};
scroll$1({
state,
dragStartTime: 0,
shouldUseTimeDampening: false,
scrollWindow: fakeScrollCallback,
scrollDroppable: fakeScrollCallback
});
dragging = {
dragStartTime,
shouldUseTimeDampening: wasScrollNeeded
};
if (wasScrollNeeded) {
tryScroll(state);
}
};
var stop = function stop2() {
if (!dragging) {
return;
}
scheduleWindowScroll.cancel();
scheduleDroppableScroll.cancel();
dragging = null;
};
return {
start: start$1,
stop,
scroll: tryScroll
};
});
var createJumpScroller = (function(_ref) {
var move3 = _ref.move, scrollDroppable2 = _ref.scrollDroppable, scrollWindow2 = _ref.scrollWindow;
var moveByOffset = function moveByOffset2(state, offset2) {
var client = add(state.current.client.selection, offset2);
move3({
client
});
};
var scrollDroppableAsMuchAsItCan = function scrollDroppableAsMuchAsItCan2(droppable2, change) {
if (!canScrollDroppable(droppable2, change)) {
return change;
}
var overlap = getDroppableOverlap(droppable2, change);
if (!overlap) {
scrollDroppable2(droppable2.descriptor.id, change);
return null;
}
var whatTheDroppableCanScroll = subtract(change, overlap);
scrollDroppable2(droppable2.descriptor.id, whatTheDroppableCanScroll);
var remainder = subtract(change, whatTheDroppableCanScroll);
return remainder;
};
var scrollWindowAsMuchAsItCan = function scrollWindowAsMuchAsItCan2(isWindowScrollAllowed, viewport, change) {
if (!isWindowScrollAllowed) {
return change;
}
if (!canScrollWindow(viewport, change)) {
return change;
}
var overlap = getWindowOverlap(viewport, change);
if (!overlap) {
scrollWindow2(change);
return null;
}
var whatTheWindowCanScroll = subtract(change, overlap);
scrollWindow2(whatTheWindowCanScroll);
var remainder = subtract(change, whatTheWindowCanScroll);
return remainder;
};
var jumpScroller = function jumpScroller2(state) {
var request = state.scrollJumpRequest;
if (!request) {
return;
}
var destination = whatIsDraggedOver(state.impact);
!destination ? invariant() : void 0;
var droppableRemainder = scrollDroppableAsMuchAsItCan(state.dimensions.droppables[destination], request);
if (!droppableRemainder) {
return;
}
var viewport = state.viewport;
var windowRemainder = scrollWindowAsMuchAsItCan(state.isWindowScrollAllowed, viewport, droppableRemainder);
if (!windowRemainder) {
return;
}
moveByOffset(state, windowRemainder);
};
return jumpScroller;
});
var createAutoScroller = (function(_ref) {
var scrollDroppable2 = _ref.scrollDroppable, scrollWindow2 = _ref.scrollWindow, move3 = _ref.move;
var fluidScroller = createFluidScroller({
scrollWindow: scrollWindow2,
scrollDroppable: scrollDroppable2
});
var jumpScroll = createJumpScroller({
move: move3,
scrollWindow: scrollWindow2,
scrollDroppable: scrollDroppable2
});
var scroll3 = function scroll4(state) {
if (state.phase !== "DRAGGING") {
return;
}
if (state.movementMode === "FLUID") {
fluidScroller.scroll(state);
return;
}
if (!state.scrollJumpRequest) {
return;
}
jumpScroll(state);
};
var scroller = {
scroll: scroll3,
start: fluidScroller.start,
stop: fluidScroller.stop
};
return scroller;
});
var prefix$1 = "data-rbd";
var dragHandle = (function() {
var base = prefix$1 + "-drag-handle";
return {
base,
draggableId: base + "-draggable-id",
contextId: base + "-context-id"
};
})();
var draggable = (function() {
var base = prefix$1 + "-draggable";
return {
base,
contextId: base + "-context-id",
id: base + "-id"
};
})();
var droppable = (function() {
var base = prefix$1 + "-droppable";
return {
base,
contextId: base + "-context-id",
id: base + "-id"
};
})();
var scrollContainer = {
contextId: prefix$1 + "-scroll-container-context-id"
};
var makeGetSelector = function makeGetSelector2(context) {
return function(attribute) {
return "[" + attribute + '="' + context + '"]';
};
};
var getStyles = function getStyles2(rules, property) {
return rules.map(function(rule) {
var value = rule.styles[property];
if (!value) {
return "";
}
return rule.selector + " { " + value + " }";
}).join(" ");
};
var noPointerEvents = "pointer-events: none;";
var getStyles$1 = (function(contextId) {
var getSelector2 = makeGetSelector(contextId);
var dragHandle$1 = (function() {
var grabCursor = "\n cursor: -webkit-grab;\n cursor: grab;\n ";
return {
selector: getSelector2(dragHandle.contextId),
styles: {
always: "\n -webkit-touch-callout: none;\n -webkit-tap-highlight-color: rgba(0,0,0,0);\n touch-action: manipulation;\n ",
resting: grabCursor,
dragging: noPointerEvents,
dropAnimating: grabCursor
}
};
})();
var draggable$1 = (function() {
var transition = "\n transition: " + transitions.outOfTheWay + ";\n ";
return {
selector: getSelector2(draggable.contextId),
styles: {
dragging: transition,
dropAnimating: transition,
userCancel: transition
}
};
})();
var droppable$1 = {
selector: getSelector2(droppable.contextId),
styles: {
always: "overflow-anchor: none;"
}
};
var body = {
selector: "body",
styles: {
dragging: "\n cursor: grabbing;\n cursor: -webkit-grabbing;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n overflow-anchor: none;\n "
}
};
var rules = [
draggable$1,
dragHandle$1,
droppable$1,
body
];
return {
always: getStyles(rules, "always"),
resting: getStyles(rules, "resting"),
dragging: getStyles(rules, "dragging"),
dropAnimating: getStyles(rules, "dropAnimating"),
userCancel: getStyles(rules, "userCancel")
};
});
var useIsomorphicLayoutEffect = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined" ? __mf_28 : __mf_24;
var getHead = function getHead2() {
var head = document.querySelector("head");
!head ? invariant() : void 0;
return head;
};
var createStyleEl = function createStyleEl2(nonce) {
var el = document.createElement("style");
if (nonce) {
el.setAttribute("nonce", nonce);
}
el.type = "text/css";
return el;
};
function useStyleMarshal(contextId, nonce) {
var styles2 = useMemo(function() {
return getStyles$1(contextId);
}, [
contextId
]);
var alwaysRef = __mf_31(null);
var dynamicRef = __mf_31(null);
var setDynamicStyle = useCallback(memoizeOne(function(proposed) {
var el = dynamicRef.current;
!el ? invariant() : void 0;
el.textContent = proposed;
}), []);
var setAlwaysStyle = useCallback(function(proposed) {
var el = alwaysRef.current;
!el ? invariant() : void 0;
el.textContent = proposed;
}, []);
useIsomorphicLayoutEffect(function() {
!(!alwaysRef.current && !dynamicRef.current) ? invariant() : void 0;
var always = createStyleEl(nonce);
var dynamic = createStyleEl(nonce);
alwaysRef.current = always;
dynamicRef.current = dynamic;
always.setAttribute(prefix$1 + "-always", contextId);
dynamic.setAttribute(prefix$1 + "-dynamic", contextId);
getHead().appendChild(always);
getHead().appendChild(dynamic);
setAlwaysStyle(styles2.always);
setDynamicStyle(styles2.resting);
return function() {
var remove = function remove2(ref2) {
var current = ref2.current;
!current ? invariant() : void 0;
getHead().removeChild(current);
ref2.current = null;
};
remove(alwaysRef);
remove(dynamicRef);
};
}, [
nonce,
setAlwaysStyle,
setDynamicStyle,
styles2.always,
styles2.resting,
contextId
]);
var dragging = useCallback(function() {
return setDynamicStyle(styles2.dragging);
}, [
setDynamicStyle,
styles2.dragging
]);
var dropping = useCallback(function(reason) {
if (reason === "DROP") {
setDynamicStyle(styles2.dropAnimating);
return;
}
setDynamicStyle(styles2.userCancel);
}, [
setDynamicStyle,
styles2.dropAnimating,
styles2.userCancel
]);
var resting = useCallback(function() {
if (!dynamicRef.current) {
return;
}
setDynamicStyle(styles2.resting);
}, [
setDynamicStyle,
styles2.resting
]);
var marshal = useMemo(function() {
return {
dragging,
dropping,
resting
};
}, [
dragging,
dropping,
resting
]);
return marshal;
}
var getWindowFromEl = (function(el) {
return el && el.ownerDocument ? el.ownerDocument.defaultView : window;
});
function isHtmlElement(el) {
return el instanceof getWindowFromEl(el).HTMLElement;
}
function findDragHandle(contextId, draggableId) {
var selector = "[" + dragHandle.contextId + '="' + contextId + '"]';
var possible = toArray(document.querySelectorAll(selector));
if (!possible.length) {
return null;
}
var handle = find(possible, function(el) {
return el.getAttribute(dragHandle.draggableId) === draggableId;
});
if (!handle) {
return null;
}
if (!isHtmlElement(handle)) {
return null;
}
return handle;
}
function useFocusMarshal(contextId) {
var entriesRef = __mf_31({});
var recordRef = __mf_31(null);
var restoreFocusFrameRef = __mf_31(null);
var isMountedRef = __mf_31(false);
var register = useCallback(function register2(id, focus2) {
var entry = {
id,
focus: focus2
};
entriesRef.current[id] = entry;
return function unregister() {
var entries = entriesRef.current;
var current = entries[id];
if (current !== entry) {
delete entries[id];
}
};
}, []);
var tryGiveFocus = useCallback(function tryGiveFocus2(tryGiveFocusTo) {
var handle = findDragHandle(contextId, tryGiveFocusTo);
if (handle && handle !== document.activeElement) {
handle.focus();
}
}, [
contextId
]);
var tryShiftRecord = useCallback(function tryShiftRecord2(previous, redirectTo) {
if (recordRef.current === previous) {
recordRef.current = redirectTo;
}
}, []);
var tryRestoreFocusRecorded = useCallback(function tryRestoreFocusRecorded2() {
if (restoreFocusFrameRef.current) {
return;
}
if (!isMountedRef.current) {
return;
}
restoreFocusFrameRef.current = requestAnimationFrame(function() {
restoreFocusFrameRef.current = null;
var record = recordRef.current;
if (record) {
tryGiveFocus(record);
}
});
}, [
tryGiveFocus
]);
var tryRecordFocus = useCallback(function tryRecordFocus2(id) {
recordRef.current = null;
var focused = document.activeElement;
if (!focused) {
return;
}
if (focused.getAttribute(dragHandle.draggableId) !== id) {
return;
}
recordRef.current = id;
}, []);
useIsomorphicLayoutEffect(function() {
isMountedRef.current = true;
return function clearFrameOnUnmount() {
isMountedRef.current = false;
var frameId = restoreFocusFrameRef.current;
if (frameId) {
cancelAnimationFrame(frameId);
}
};
}, []);
var marshal = useMemo(function() {
return {
register,
tryRecordFocus,
tryRestoreFocusRecorded,
tryShiftRecord
};
}, [
register,
tryRecordFocus,
tryRestoreFocusRecorded,
tryShiftRecord
]);
return marshal;
}
function createRegistry() {
var entries = {
draggables: {},
droppables: {}
};
var subscribers = [];
function subscribe(cb) {
subscribers.push(cb);
return function unsubscribe() {
var index = subscribers.indexOf(cb);
if (index === -1) {
return;
}
subscribers.splice(index, 1);
};
}
function notify(event) {
if (subscribers.length) {
subscribers.forEach(function(cb) {
return cb(event);
});
}
}
function findDraggableById(id) {
return entries.draggables[id] || null;
}
function getDraggableById(id) {
var entry = findDraggableById(id);
!entry ? invariant() : void 0;
return entry;
}
var draggableAPI = {
register: function register(entry) {
entries.draggables[entry.descriptor.id] = entry;
notify({
type: "ADDITION",
value: entry
});
},
update: function update2(entry, last) {
var current = entries.draggables[last.descriptor.id];
if (!current) {
return;
}
if (current.uniqueId !== entry.uniqueId) {
return;
}
delete entries.draggables[last.descriptor.id];
entries.draggables[entry.descriptor.id] = entry;
},
unregister: function unregister(entry) {
var draggableId = entry.descriptor.id;
var current = findDraggableById(draggableId);
if (!current) {
return;
}
if (entry.uniqueId !== current.uniqueId) {
return;
}
delete entries.draggables[draggableId];
notify({
type: "REMOVAL",
value: entry
});
},
getById: getDraggableById,
findById: findDraggableById,
exists: function exists(id) {
return Boolean(findDraggableById(id));
},
getAllByType: function getAllByType(type) {
return values(entries.draggables).filter(function(entry) {
return entry.descriptor.type === type;
});
}
};
function findDroppableById(id) {
return entries.droppables[id] || null;
}
function getDroppableById(id) {
var entry = findDroppableById(id);
!entry ? invariant() : void 0;
return entry;
}
var droppableAPI = {
register: function register(entry) {
entries.droppables[entry.descriptor.id] = entry;
},
unregister: function unregister(entry) {
var current = findDroppableById(entry.descriptor.id);
if (!current) {
return;
}
if (entry.uniqueId !== current.uniqueId) {
return;
}
delete entries.droppables[entry.descriptor.id];
},
getById: getDroppableById,
findById: findDroppableById,
exists: function exists(id) {
return Boolean(findDroppableById(id));
},
getAllByType: function getAllByType(type) {
return values(entries.droppables).filter(function(entry) {
return entry.descriptor.type === type;
});
}
};
function clean4() {
entries.draggables = {};
entries.droppables = {};
subscribers.length = 0;
}
return {
draggable: draggableAPI,
droppable: droppableAPI,
subscribe,
clean: clean4
};
}
function useRegistry() {
var registry = useMemo(createRegistry, []);
__mf_24(function() {
return function unmount() {
requestAnimationFrame(registry.clean);
};
}, [
registry
]);
return registry;
}
var StoreContext = React.createContext(null);
var getBodyElement = (function() {
var body = document.body;
!body ? invariant() : void 0;
return body;
});
var visuallyHidden = {
position: "absolute",
width: "1px",
height: "1px",
margin: "-1px",
border: "0",
padding: "0",
overflow: "hidden",
clip: "rect(0 0 0 0)",
"clip-path": "inset(100%)"
};
var getId = function getId2(contextId) {
return "rbd-announcement-" + contextId;
};
function useAnnouncer(contextId) {
var id = useMemo(function() {
return getId(contextId);
}, [
contextId
]);
var ref2 = __mf_31(null);
__mf_24(function setup() {
var el = document.createElement("div");
ref2.current = el;
el.id = id;
el.setAttribute("aria-live", "assertive");
el.setAttribute("aria-atomic", "true");
_extends$1(el.style, visuallyHidden);
getBodyElement().appendChild(el);
return function cleanup() {
setTimeout(function remove() {
var body = getBodyElement();
if (body.contains(el)) {
body.removeChild(el);
}
if (el === ref2.current) {
ref2.current = null;
}
});
};
}, [
id
]);
var announce = useCallback(function(message) {
var el = ref2.current;
if (el) {
el.textContent = message;
return;
}
}, []);
return announce;
}
var count = 0;
var defaults = {
separator: "::"
};
function useUniqueId(prefix2, options) {
if (options === void 0) {
options = defaults;
}
return useMemo(function() {
return "" + prefix2 + options.separator + count++;
}, [
options.separator,
prefix2
]);
}
function getElementId(_ref) {
var contextId = _ref.contextId, uniqueId = _ref.uniqueId;
return "rbd-hidden-text-" + contextId + "-" + uniqueId;
}
function useHiddenTextElement(_ref2) {
var contextId = _ref2.contextId, text = _ref2.text;
var uniqueId = useUniqueId("hidden-text", {
separator: "-"
});
var id = useMemo(function() {
return getElementId({
contextId,
uniqueId
});
}, [
uniqueId,
contextId
]);
__mf_24(function mount() {
var el = document.createElement("div");
el.id = id;
el.textContent = text;
el.style.display = "none";
getBodyElement().appendChild(el);
return function unmount() {
var body = getBodyElement();
if (body.contains(el)) {
body.removeChild(el);
}
};
}, [
id,
text
]);
return id;
}
var AppContext = React.createContext(null);
function usePrevious(current) {
var ref2 = __mf_31(current);
__mf_24(function() {
ref2.current = current;
});
return ref2;
}
function create() {
var lock = null;
function isClaimed() {
return Boolean(lock);
}
function isActive(value) {
return value === lock;
}
function claim(abandon) {
!!lock ? invariant() : void 0;
var newLock = {
abandon
};
lock = newLock;
return newLock;
}
function release() {
!lock ? invariant() : void 0;
lock = null;
}
function tryAbandon() {
if (lock) {
lock.abandon();
release();
}
}
return {
isClaimed,
isActive,
claim,
release,
tryAbandon
};
}
var tab = 9;
var enter = 13;
var escape = 27;
var space = 32;
var pageUp = 33;
var pageDown = 34;
var end = 35;
var home = 36;
var arrowLeft = 37;
var arrowUp = 38;
var arrowRight = 39;
var arrowDown = 40;
var _preventedKeys;
var preventedKeys = (_preventedKeys = {}, _preventedKeys[enter] = true, _preventedKeys[tab] = true, _preventedKeys);
var preventStandardKeyEvents = (function(event) {
if (preventedKeys[event.keyCode]) {
event.preventDefault();
}
});
var supportedEventName = (function() {
var base = "visibilitychange";
if (typeof document === "undefined") {
return base;
}
var candidates = [
base,
"ms" + base,
"webkit" + base,
"moz" + base,
"o" + base
];
var supported = find(candidates, function(eventName) {
return "on" + eventName in document;
});
return supported || base;
})();
var primaryButton = 0;
var sloppyClickThreshold = 5;
function isSloppyClickThresholdExceeded(original, current) {
return Math.abs(current.x - original.x) >= sloppyClickThreshold || Math.abs(current.y - original.y) >= sloppyClickThreshold;
}
var idle$1 = {
type: "IDLE"
};
function getCaptureBindings(_ref) {
var cancel = _ref.cancel, completed = _ref.completed, getPhase = _ref.getPhase, setPhase = _ref.setPhase;
return [
{
eventName: "mousemove",
fn: function fn(event) {
var button = event.button, clientX = event.clientX, clientY = event.clientY;
if (button !== primaryButton) {
return;
}
var point = {
x: clientX,
y: clientY
};
var phase = getPhase();
if (phase.type === "DRAGGING") {
event.preventDefault();
phase.actions.move(point);
return;
}
!(phase.type === "PENDING") ? invariant() : void 0;
var pending = phase.point;
if (!isSloppyClickThresholdExceeded(pending, point)) {
return;
}
event.preventDefault();
var actions = phase.actions.fluidLift(point);
setPhase({
type: "DRAGGING",
actions
});
}
},
{
eventName: "mouseup",
fn: function fn(event) {
var phase = getPhase();
if (phase.type !== "DRAGGING") {
cancel();
return;
}
event.preventDefault();
phase.actions.drop({
shouldBlockNextClick: true
});
completed();
}
},
{
eventName: "mousedown",
fn: function fn(event) {
if (getPhase().type === "DRAGGING") {
event.preventDefault();
}
cancel();
}
},
{
eventName: "keydown",
fn: function fn(event) {
var phase = getPhase();
if (phase.type === "PENDING") {
cancel();
return;
}
if (event.keyCode === escape) {
event.preventDefault();
cancel();
return;
}
preventStandardKeyEvents(event);
}
},
{
eventName: "resize",
fn: cancel
},
{
eventName: "scroll",
options: {
passive: true,
capture: false
},
fn: function fn() {
if (getPhase().type === "PENDING") {
cancel();
}
}
},
{
eventName: "webkitmouseforcedown",
fn: function fn(event) {
var phase = getPhase();
!(phase.type !== "IDLE") ? invariant() : void 0;
if (phase.actions.shouldRespectForcePress()) {
cancel();
return;
}
event.preventDefault();
}
},
{
eventName: supportedEventName,
fn: cancel
}
];
}
function useMouseSensor(api) {
var phaseRef = __mf_31(idle$1);
var unbindEventsRef = __mf_31(noop$1);
var startCaptureBinding = useMemo(function() {
return {
eventName: "mousedown",
fn: function onMouseDown(event) {
if (event.defaultPrevented) {
return;
}
if (event.button !== primaryButton) {
return;
}
if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
return;
}
var draggableId = api.findClosestDraggableId(event);
if (!draggableId) {
return;
}
var actions = api.tryGetLock(draggableId, stop, {
sourceEvent: event
});
if (!actions) {
return;
}
event.preventDefault();
var point = {
x: event.clientX,
y: event.clientY
};
unbindEventsRef.current();
startPendingDrag(actions, point);
}
};
}, [
api
]);
var preventForcePressBinding = useMemo(function() {
return {
eventName: "webkitmouseforcewillbegin",
fn: function fn(event) {
if (event.defaultPrevented) {
return;
}
var id = api.findClosestDraggableId(event);
if (!id) {
return;
}
var options = api.findOptionsForDraggable(id);
if (!options) {
return;
}
if (options.shouldRespectForcePress) {
return;
}
if (!api.canGetLock(id)) {
return;
}
event.preventDefault();
}
};
}, [
api
]);
var listenForCapture = useCallback(function listenForCapture2() {
var options = {
passive: false,
capture: true
};
unbindEventsRef.current = bindEvents(window, [
preventForcePressBinding,
startCaptureBinding
], options);
}, [
preventForcePressBinding,
startCaptureBinding
]);
var stop = useCallback(function() {
var current = phaseRef.current;
if (current.type === "IDLE") {
return;
}
phaseRef.current = idle$1;
unbindEventsRef.current();
listenForCapture();
}, [
listenForCapture
]);
var cancel = useCallback(function() {
var phase = phaseRef.current;
stop();
if (phase.type === "DRAGGING") {
phase.actions.cancel({
shouldBlockNextClick: true
});
}
if (phase.type === "PENDING") {
phase.actions.abort();
}
}, [
stop
]);
var bindCapturingEvents = useCallback(function bindCapturingEvents2() {
var options = {
capture: true,
passive: false
};
var bindings = getCaptureBindings({
cancel,
completed: stop,
getPhase: function getPhase() {
return phaseRef.current;
},
setPhase: function setPhase(phase) {
phaseRef.current = phase;
}
});
unbindEventsRef.current = bindEvents(window, bindings, options);
}, [
cancel,
stop
]);
var startPendingDrag = useCallback(function startPendingDrag2(actions, point) {
!(phaseRef.current.type === "IDLE") ? invariant() : void 0;
phaseRef.current = {
type: "PENDING",
point,
actions
};
bindCapturingEvents();
}, [
bindCapturingEvents
]);
useIsomorphicLayoutEffect(function mount() {
listenForCapture();
return function unmount() {
unbindEventsRef.current();
};
}, [
listenForCapture
]);
}
var _scrollJumpKeys;
function noop$1$1() {
}
var scrollJumpKeys = (_scrollJumpKeys = {}, _scrollJumpKeys[pageDown] = true, _scrollJumpKeys[pageUp] = true, _scrollJumpKeys[home] = true, _scrollJumpKeys[end] = true, _scrollJumpKeys);
function getDraggingBindings(actions, stop) {
function cancel() {
stop();
actions.cancel();
}
function drop5() {
stop();
actions.drop();
}
return [
{
eventName: "keydown",
fn: function fn(event) {
if (event.keyCode === escape) {
event.preventDefault();
cancel();
return;
}
if (event.keyCode === space) {
event.preventDefault();
drop5();
return;
}
if (event.keyCode === arrowDown) {
event.preventDefault();
actions.moveDown();
return;
}
if (event.keyCode === arrowUp) {
event.preventDefault();
actions.moveUp();
return;
}
if (event.keyCode === arrowRight) {
event.preventDefault();
actions.moveRight();
return;
}
if (event.keyCode === arrowLeft) {
event.preventDefault();
actions.moveLeft();
return;
}
if (scrollJumpKeys[event.keyCode]) {
event.preventDefault();
return;
}
preventStandardKeyEvents(event);
}
},
{
eventName: "mousedown",
fn: cancel
},
{
eventName: "mouseup",
fn: cancel
},
{
eventName: "click",
fn: cancel
},
{
eventName: "touchstart",
fn: cancel
},
{
eventName: "resize",
fn: cancel
},
{
eventName: "wheel",
fn: cancel,
options: {
passive: true
}
},
{
eventName: supportedEventName,
fn: cancel
}
];
}
function useKeyboardSensor(api) {
var unbindEventsRef = __mf_31(noop$1$1);
var startCaptureBinding = useMemo(function() {
return {
eventName: "keydown",
fn: function onKeyDown(event) {
if (event.defaultPrevented) {
return;
}
if (event.keyCode !== space) {
return;
}
var draggableId = api.findClosestDraggableId(event);
if (!draggableId) {
return;
}
var preDrag = api.tryGetLock(draggableId, stop, {
sourceEvent: event
});
if (!preDrag) {
return;
}
event.preventDefault();
var isCapturing = true;
var actions = preDrag.snapLift();
unbindEventsRef.current();
function stop() {
!isCapturing ? invariant() : void 0;
isCapturing = false;
unbindEventsRef.current();
listenForCapture();
}
unbindEventsRef.current = bindEvents(window, getDraggingBindings(actions, stop), {
capture: true,
passive: false
});
}
};
}, [
api
]);
var listenForCapture = useCallback(function tryStartCapture() {
var options = {
passive: false,
capture: true
};
unbindEventsRef.current = bindEvents(window, [
startCaptureBinding
], options);
}, [
startCaptureBinding
]);
useIsomorphicLayoutEffect(function mount() {
listenForCapture();
return function unmount() {
unbindEventsRef.current();
};
}, [
listenForCapture
]);
}
var idle$2 = {
type: "IDLE"
};
var timeForLongPress = 120;
var forcePressThreshold = 0.15;
function getWindowBindings(_ref) {
var cancel = _ref.cancel, getPhase = _ref.getPhase;
return [
{
eventName: "orientationchange",
fn: cancel
},
{
eventName: "resize",
fn: cancel
},
{
eventName: "contextmenu",
fn: function fn(event) {
event.preventDefault();
}
},
{
eventName: "keydown",
fn: function fn(event) {
if (getPhase().type !== "DRAGGING") {
cancel();
return;
}
if (event.keyCode === escape) {
event.preventDefault();
}
cancel();
}
},
{
eventName: supportedEventName,
fn: cancel
}
];
}
function getHandleBindings(_ref2) {
var cancel = _ref2.cancel, completed = _ref2.completed, getPhase = _ref2.getPhase;
return [
{
eventName: "touchmove",
options: {
capture: false
},
fn: function fn(event) {
var phase = getPhase();
if (phase.type !== "DRAGGING") {
cancel();
return;
}
phase.hasMoved = true;
var _event$touches$ = event.touches[0], clientX = _event$touches$.clientX, clientY = _event$touches$.clientY;
var point = {
x: clientX,
y: clientY
};
event.preventDefault();
phase.actions.move(point);
}
},
{
eventName: "touchend",
fn: function fn(event) {
var phase = getPhase();
if (phase.type !== "DRAGGING") {
cancel();
return;
}
event.preventDefault();
phase.actions.drop({
shouldBlockNextClick: true
});
completed();
}
},
{
eventName: "touchcancel",
fn: function fn(event) {
if (getPhase().type !== "DRAGGING") {
cancel();
return;
}
event.preventDefault();
cancel();
}
},
{
eventName: "touchforcechange",
fn: function fn(event) {
var phase = getPhase();
!(phase.type !== "IDLE") ? invariant() : void 0;
var touch = event.touches[0];
if (!touch) {
return;
}
var isForcePress = touch.force >= forcePressThreshold;
if (!isForcePress) {
return;
}
var shouldRespect = phase.actions.shouldRespectForcePress();
if (phase.type === "PENDING") {
if (shouldRespect) {
cancel();
}
return;
}
if (shouldRespect) {
if (phase.hasMoved) {
event.preventDefault();
return;
}
cancel();
return;
}
event.preventDefault();
}
},
{
eventName: supportedEventName,
fn: cancel
}
];
}
function useTouchSensor(api) {
var phaseRef = __mf_31(idle$2);
var unbindEventsRef = __mf_31(noop$1);
var getPhase = useCallback(function getPhase2() {
return phaseRef.current;
}, []);
var setPhase = useCallback(function setPhase2(phase) {
phaseRef.current = phase;
}, []);
var startCaptureBinding = useMemo(function() {
return {
eventName: "touchstart",
fn: function onTouchStart(event) {
if (event.defaultPrevented) {
return;
}
var draggableId = api.findClosestDraggableId(event);
if (!draggableId) {
return;
}
var actions = api.tryGetLock(draggableId, stop, {
sourceEvent: event
});
if (!actions) {
return;
}
var touch = event.touches[0];
var clientX = touch.clientX, clientY = touch.clientY;
var point = {
x: clientX,
y: clientY
};
unbindEventsRef.current();
startPendingDrag(actions, point);
}
};
}, [
api
]);
var listenForCapture = useCallback(function listenForCapture2() {
var options = {
capture: true,
passive: false
};
unbindEventsRef.current = bindEvents(window, [
startCaptureBinding
], options);
}, [
startCaptureBinding
]);
var stop = useCallback(function() {
var current = phaseRef.current;
if (current.type === "IDLE") {
return;
}
if (current.type === "PENDING") {
clearTimeout(current.longPressTimerId);
}
setPhase(idle$2);
unbindEventsRef.current();
listenForCapture();
}, [
listenForCapture,
setPhase
]);
var cancel = useCallback(function() {
var phase = phaseRef.current;
stop();
if (phase.type === "DRAGGING") {
phase.actions.cancel({
shouldBlockNextClick: true
});
}
if (phase.type === "PENDING") {
phase.actions.abort();
}
}, [
stop
]);
var bindCapturingEvents = useCallback(function bindCapturingEvents2() {
var options = {
capture: true,
passive: false
};
var args = {
cancel,
completed: stop,
getPhase
};
var unbindTarget = bindEvents(window, getHandleBindings(args), options);
var unbindWindow = bindEvents(window, getWindowBindings(args), options);
unbindEventsRef.current = function unbindAll() {
unbindTarget();
unbindWindow();
};
}, [
cancel,
getPhase,
stop
]);
var startDragging = useCallback(function startDragging2() {
var phase = getPhase();
!(phase.type === "PENDING") ? invariant() : void 0;
var actions = phase.actions.fluidLift(phase.point);
setPhase({
type: "DRAGGING",
actions,
hasMoved: false
});
}, [
getPhase,
setPhase
]);
var startPendingDrag = useCallback(function startPendingDrag2(actions, point) {
!(getPhase().type === "IDLE") ? invariant() : void 0;
var longPressTimerId = setTimeout(startDragging, timeForLongPress);
setPhase({
type: "PENDING",
point,
actions,
longPressTimerId
});
bindCapturingEvents();
}, [
bindCapturingEvents,
getPhase,
setPhase,
startDragging
]);
useIsomorphicLayoutEffect(function mount() {
listenForCapture();
return function unmount() {
unbindEventsRef.current();
var phase = getPhase();
if (phase.type === "PENDING") {
clearTimeout(phase.longPressTimerId);
setPhase(idle$2);
}
};
}, [
getPhase,
listenForCapture,
setPhase
]);
useIsomorphicLayoutEffect(function webkitHack() {
var unbind = bindEvents(window, [
{
eventName: "touchmove",
fn: function fn() {
},
options: {
capture: false,
passive: false
}
}
]);
return unbind;
}, []);
}
var interactiveTagNames = {
input: true,
button: true,
textarea: true,
select: true,
option: true,
optgroup: true,
video: true,
audio: true
};
function isAnInteractiveElement(parent, current) {
if (current == null) {
return false;
}
var hasAnInteractiveTag = Boolean(interactiveTagNames[current.tagName.toLowerCase()]);
if (hasAnInteractiveTag) {
return true;
}
var attribute = current.getAttribute("contenteditable");
if (attribute === "true" || attribute === "") {
return true;
}
if (current === parent) {
return false;
}
return isAnInteractiveElement(parent, current.parentElement);
}
function isEventInInteractiveElement(draggable2, event) {
var target = event.target;
if (!isHtmlElement(target)) {
return false;
}
return isAnInteractiveElement(draggable2, target);
}
var getBorderBoxCenterPosition = (function(el) {
return getRect(el.getBoundingClientRect()).center;
});
function isElement(el) {
return el instanceof getWindowFromEl(el).Element;
}
var supportedMatchesName = (function() {
var base = "matches";
if (typeof document === "undefined") {
return base;
}
var candidates = [
base,
"msMatchesSelector",
"webkitMatchesSelector"
];
var value = find(candidates, function(name) {
return name in Element.prototype;
});
return value || base;
})();
function closestPonyfill(el, selector) {
if (el == null) {
return null;
}
if (el[supportedMatchesName](selector)) {
return el;
}
return closestPonyfill(el.parentElement, selector);
}
function closest$1(el, selector) {
if (el.closest) {
return el.closest(selector);
}
return closestPonyfill(el, selector);
}
function getSelector(contextId) {
return "[" + dragHandle.contextId + '="' + contextId + '"]';
}
function findClosestDragHandleFromEvent(contextId, event) {
var target = event.target;
if (!isElement(target)) {
return null;
}
var selector = getSelector(contextId);
var handle = closest$1(target, selector);
if (!handle) {
return null;
}
if (!isHtmlElement(handle)) {
return null;
}
return handle;
}
function tryGetClosestDraggableIdFromEvent(contextId, event) {
var handle = findClosestDragHandleFromEvent(contextId, event);
if (!handle) {
return null;
}
return handle.getAttribute(dragHandle.draggableId);
}
function findDraggable(contextId, draggableId) {
var selector = "[" + draggable.contextId + '="' + contextId + '"]';
var possible = toArray(document.querySelectorAll(selector));
var draggable$1 = find(possible, function(el) {
return el.getAttribute(draggable.id) === draggableId;
});
if (!draggable$1) {
return null;
}
if (!isHtmlElement(draggable$1)) {
return null;
}
return draggable$1;
}
function preventDefault(event) {
event.preventDefault();
}
function _isActive(_ref) {
var expected = _ref.expected, phase = _ref.phase, isLockActive = _ref.isLockActive;
_ref.shouldWarn;
if (!isLockActive()) {
return false;
}
if (expected !== phase) {
return false;
}
return true;
}
function canStart(_ref2) {
var lockAPI = _ref2.lockAPI, store2 = _ref2.store, registry = _ref2.registry, draggableId = _ref2.draggableId;
if (lockAPI.isClaimed()) {
return false;
}
var entry = registry.draggable.findById(draggableId);
if (!entry) {
return false;
}
if (!entry.options.isEnabled) {
return false;
}
if (!canStartDrag(store2.getState(), draggableId)) {
return false;
}
return true;
}
function tryStart(_ref3) {
var lockAPI = _ref3.lockAPI, contextId = _ref3.contextId, store2 = _ref3.store, registry = _ref3.registry, draggableId = _ref3.draggableId, forceSensorStop = _ref3.forceSensorStop, sourceEvent = _ref3.sourceEvent;
var shouldStart = canStart({
lockAPI,
store: store2,
registry,
draggableId
});
if (!shouldStart) {
return null;
}
var entry = registry.draggable.getById(draggableId);
var el = findDraggable(contextId, entry.descriptor.id);
if (!el) {
return null;
}
if (sourceEvent && !entry.options.canDragInteractiveElements && isEventInInteractiveElement(el, sourceEvent)) {
return null;
}
var lock = lockAPI.claim(forceSensorStop || noop$1);
var phase = "PRE_DRAG";
function getShouldRespectForcePress() {
return entry.options.shouldRespectForcePress;
}
function isLockActive() {
return lockAPI.isActive(lock);
}
function tryDispatch(expected, getAction) {
if (_isActive({
expected,
phase,
isLockActive,
shouldWarn: true
})) {
store2.dispatch(getAction());
}
}
var tryDispatchWhenDragging = tryDispatch.bind(null, "DRAGGING");
function lift$12(args) {
function completed() {
lockAPI.release();
phase = "COMPLETED";
}
if (phase !== "PRE_DRAG") {
completed();
!(phase === "PRE_DRAG") ? invariant() : void 0;
}
store2.dispatch(lift(args.liftActionArgs));
phase = "DRAGGING";
function finish3(reason, options) {
if (options === void 0) {
options = {
shouldBlockNextClick: false
};
}
args.cleanup();
if (options.shouldBlockNextClick) {
var unbind = bindEvents(window, [
{
eventName: "click",
fn: preventDefault,
options: {
once: true,
passive: false,
capture: true
}
}
]);
setTimeout(unbind);
}
completed();
store2.dispatch(drop({
reason
}));
}
return _extends$1({
isActive: function isActive() {
return _isActive({
expected: "DRAGGING",
phase,
isLockActive,
shouldWarn: false
});
},
shouldRespectForcePress: getShouldRespectForcePress,
drop: function drop5(options) {
return finish3("DROP", options);
},
cancel: function cancel(options) {
return finish3("CANCEL", options);
}
}, args.actions);
}
function fluidLift(clientSelection) {
var move$1 = rafSchd(function(client) {
tryDispatchWhenDragging(function() {
return move({
client
});
});
});
var api = lift$12({
liftActionArgs: {
id: draggableId,
clientSelection,
movementMode: "FLUID"
},
cleanup: function cleanup() {
return move$1.cancel();
},
actions: {
move: move$1
}
});
return _extends$1({}, api, {
move: move$1
});
}
function snapLift() {
var actions = {
moveUp: function moveUp$1() {
return tryDispatchWhenDragging(moveUp);
},
moveRight: function moveRight$1() {
return tryDispatchWhenDragging(moveRight);
},
moveDown: function moveDown$1() {
return tryDispatchWhenDragging(moveDown);
},
moveLeft: function moveLeft$1() {
return tryDispatchWhenDragging(moveLeft);
}
};
return lift$12({
liftActionArgs: {
id: draggableId,
clientSelection: getBorderBoxCenterPosition(el),
movementMode: "SNAP"
},
cleanup: noop$1,
actions
});
}
function abortPreDrag() {
var shouldRelease = _isActive({
expected: "PRE_DRAG",
phase,
isLockActive,
shouldWarn: true
});
if (shouldRelease) {
lockAPI.release();
}
}
var preDrag = {
isActive: function isActive() {
return _isActive({
expected: "PRE_DRAG",
phase,
isLockActive,
shouldWarn: false
});
},
shouldRespectForcePress: getShouldRespectForcePress,
fluidLift,
snapLift,
abort: abortPreDrag
};
return preDrag;
}
var defaultSensors = [
useMouseSensor,
useKeyboardSensor,
useTouchSensor
];
function useSensorMarshal(_ref4) {
var contextId = _ref4.contextId, store2 = _ref4.store, registry = _ref4.registry, customSensors = _ref4.customSensors, enableDefaultSensors = _ref4.enableDefaultSensors;
var useSensors = [].concat(enableDefaultSensors ? defaultSensors : [], customSensors || []);
var lockAPI = __mf_32(function() {
return create();
})[0];
var tryAbandonLock = useCallback(function tryAbandonLock2(previous, current) {
if (previous.isDragging && !current.isDragging) {
lockAPI.tryAbandon();
}
}, [
lockAPI
]);
useIsomorphicLayoutEffect(function listenToStore() {
var previous = store2.getState();
var unsubscribe = store2.subscribe(function() {
var current = store2.getState();
tryAbandonLock(previous, current);
previous = current;
});
return unsubscribe;
}, [
lockAPI,
store2,
tryAbandonLock
]);
useIsomorphicLayoutEffect(function() {
return lockAPI.tryAbandon;
}, [
lockAPI.tryAbandon
]);
var canGetLock = useCallback(function(draggableId) {
return canStart({
lockAPI,
registry,
store: store2,
draggableId
});
}, [
lockAPI,
registry,
store2
]);
var tryGetLock = useCallback(function(draggableId, forceStop, options) {
return tryStart({
lockAPI,
registry,
contextId,
store: store2,
draggableId,
forceSensorStop: forceStop,
sourceEvent: options && options.sourceEvent ? options.sourceEvent : null
});
}, [
contextId,
lockAPI,
registry,
store2
]);
var findClosestDraggableId = useCallback(function(event) {
return tryGetClosestDraggableIdFromEvent(contextId, event);
}, [
contextId
]);
var findOptionsForDraggable = useCallback(function(id) {
var entry = registry.draggable.findById(id);
return entry ? entry.options : null;
}, [
registry.draggable
]);
var tryReleaseLock = useCallback(function tryReleaseLock2() {
if (!lockAPI.isClaimed()) {
return;
}
lockAPI.tryAbandon();
if (store2.getState().phase !== "IDLE") {
store2.dispatch(flush());
}
}, [
lockAPI,
store2
]);
var isLockClaimed = useCallback(lockAPI.isClaimed, [
lockAPI
]);
var api = useMemo(function() {
return {
canGetLock,
tryGetLock,
findClosestDraggableId,
findOptionsForDraggable,
tryReleaseLock,
isLockClaimed
};
}, [
canGetLock,
tryGetLock,
findClosestDraggableId,
findOptionsForDraggable,
tryReleaseLock,
isLockClaimed
]);
for (var i = 0; i < useSensors.length; i++) {
useSensors[i](api);
}
}
var createResponders = function createResponders2(props) {
return {
onBeforeCapture: props.onBeforeCapture,
onBeforeDragStart: props.onBeforeDragStart,
onDragStart: props.onDragStart,
onDragEnd: props.onDragEnd,
onDragUpdate: props.onDragUpdate
};
};
function getStore(lazyRef) {
!lazyRef.current ? invariant() : void 0;
return lazyRef.current;
}
function App(props) {
var contextId = props.contextId, setCallbacks = props.setCallbacks, sensors = props.sensors, nonce = props.nonce, dragHandleUsageInstructions2 = props.dragHandleUsageInstructions;
var lazyStoreRef = __mf_31(null);
var lastPropsRef = usePrevious(props);
var getResponders = useCallback(function() {
return createResponders(lastPropsRef.current);
}, [
lastPropsRef
]);
var announce = useAnnouncer(contextId);
var dragHandleUsageInstructionsId = useHiddenTextElement({
contextId,
text: dragHandleUsageInstructions2
});
var styleMarshal = useStyleMarshal(contextId, nonce);
var lazyDispatch = useCallback(function(action) {
getStore(lazyStoreRef).dispatch(action);
}, []);
var marshalCallbacks = useMemo(function() {
return bindActionCreators$1({
publishWhileDragging,
updateDroppableScroll,
updateDroppableIsEnabled,
updateDroppableIsCombineEnabled,
collectionStarting
}, lazyDispatch);
}, [
lazyDispatch
]);
var registry = useRegistry();
var dimensionMarshal = useMemo(function() {
return createDimensionMarshal(registry, marshalCallbacks);
}, [
registry,
marshalCallbacks
]);
var autoScroller = useMemo(function() {
return createAutoScroller(_extends$1({
scrollWindow,
scrollDroppable: dimensionMarshal.scrollDroppable
}, bindActionCreators$1({
move
}, lazyDispatch)));
}, [
dimensionMarshal.scrollDroppable,
lazyDispatch
]);
var focusMarshal = useFocusMarshal(contextId);
var store2 = useMemo(function() {
return createStore({
announce,
autoScroller,
dimensionMarshal,
focusMarshal,
getResponders,
styleMarshal
});
}, [
announce,
autoScroller,
dimensionMarshal,
focusMarshal,
getResponders,
styleMarshal
]);
lazyStoreRef.current = store2;
var tryResetStore = useCallback(function() {
var current = getStore(lazyStoreRef);
var state = current.getState();
if (state.phase !== "IDLE") {
current.dispatch(flush());
}
}, []);
var isDragging = useCallback(function() {
var state = getStore(lazyStoreRef).getState();
return state.isDragging || state.phase === "DROP_ANIMATING";
}, []);
var appCallbacks = useMemo(function() {
return {
isDragging,
tryAbort: tryResetStore
};
}, [
isDragging,
tryResetStore
]);
setCallbacks(appCallbacks);
var getCanLift = useCallback(function(id) {
return canStartDrag(getStore(lazyStoreRef).getState(), id);
}, []);
var getIsMovementAllowed = useCallback(function() {
return isMovementAllowed(getStore(lazyStoreRef).getState());
}, []);
var appContext = useMemo(function() {
return {
marshal: dimensionMarshal,
focus: focusMarshal,
contextId,
canLift: getCanLift,
isMovementAllowed: getIsMovementAllowed,
dragHandleUsageInstructionsId,
registry
};
}, [
contextId,
dimensionMarshal,
dragHandleUsageInstructionsId,
focusMarshal,
getCanLift,
getIsMovementAllowed,
registry
]);
useSensorMarshal({
contextId,
store: store2,
registry,
customSensors: sensors,
enableDefaultSensors: props.enableDefaultSensors !== false
});
__mf_24(function() {
return tryResetStore;
}, [
tryResetStore
]);
return React.createElement(AppContext.Provider, {
value: appContext
}, React.createElement(Provider, {
context: StoreContext,
store: store2
}, props.children));
}
var count$1 = 0;
function useInstanceCount() {
return useMemo(function() {
return "" + count$1++;
}, []);
}
DragDropContext = function(props) {
var contextId = useInstanceCount();
var dragHandleUsageInstructions2 = props.dragHandleUsageInstructions || preset.dragHandleUsageInstructions;
return React.createElement(ErrorBoundary, null, function(setCallbacks) {
return React.createElement(App, {
nonce: props.nonce,
contextId,
setCallbacks,
dragHandleUsageInstructions: dragHandleUsageInstructions2,
enableDefaultSensors: props.enableDefaultSensors,
sensors: props.sensors,
onBeforeCapture: props.onBeforeCapture,
onBeforeDragStart: props.onBeforeDragStart,
onDragStart: props.onDragStart,
onDragUpdate: props.onDragUpdate,
onDragEnd: props.onDragEnd
}, props.children);
});
};
var isEqual$1 = function isEqual3(base) {
return function(value) {
return base === value;
};
};
var isScroll = isEqual$1("scroll");
var isAuto = isEqual$1("auto");
var isEither = function isEither2(overflow, fn) {
return fn(overflow.overflowX) || fn(overflow.overflowY);
};
var isElementScrollable = function isElementScrollable2(el) {
var style2 = window.getComputedStyle(el);
var overflow = {
overflowX: style2.overflowX,
overflowY: style2.overflowY
};
return isEither(overflow, isScroll) || isEither(overflow, isAuto);
};
var isBodyScrollable = function isBodyScrollable2() {
{
return false;
}
};
var getClosestScrollable = function getClosestScrollable2(el) {
if (el == null) {
return null;
}
if (el === document.body) {
return isBodyScrollable() ? el : null;
}
if (el === document.documentElement) {
return null;
}
if (!isElementScrollable(el)) {
return getClosestScrollable2(el.parentElement);
}
return el;
};
var getScroll$1 = (function(el) {
return {
x: el.scrollLeft,
y: el.scrollTop
};
});
var getIsFixed = function getIsFixed2(el) {
if (!el) {
return false;
}
var style2 = window.getComputedStyle(el);
if (style2.position === "fixed") {
return true;
}
return getIsFixed2(el.parentElement);
};
var getEnv = (function(start3) {
var closestScrollable = getClosestScrollable(start3);
var isFixedOnPage = getIsFixed(start3);
return {
closestScrollable,
isFixedOnPage
};
});
var getDroppableDimension = (function(_ref) {
var descriptor = _ref.descriptor, isEnabled = _ref.isEnabled, isCombineEnabled = _ref.isCombineEnabled, isFixedOnPage = _ref.isFixedOnPage, direction = _ref.direction, client = _ref.client, page = _ref.page, closest3 = _ref.closest;
var frame = (function() {
if (!closest3) {
return null;
}
var scrollSize = closest3.scrollSize, frameClient = closest3.client;
var maxScroll = getMaxScroll({
scrollHeight: scrollSize.scrollHeight,
scrollWidth: scrollSize.scrollWidth,
height: frameClient.paddingBox.height,
width: frameClient.paddingBox.width
});
return {
pageMarginBox: closest3.page.marginBox,
frameClient,
scrollSize,
shouldClipSubject: closest3.shouldClipSubject,
scroll: {
initial: closest3.scroll,
current: closest3.scroll,
max: maxScroll,
diff: {
value: origin,
displacement: origin
}
}
};
})();
var axis = direction === "vertical" ? vertical : horizontal;
var subject = getSubject({
page,
withPlaceholder: null,
axis,
frame
});
var dimension = {
descriptor,
isCombineEnabled,
isFixedOnPage,
axis,
isEnabled,
client,
page,
frame,
subject
};
return dimension;
});
var getClient = function getClient2(targetRef, closestScrollable) {
var base = getBox(targetRef);
if (!closestScrollable) {
return base;
}
if (targetRef !== closestScrollable) {
return base;
}
var top = base.paddingBox.top - closestScrollable.scrollTop;
var left = base.paddingBox.left - closestScrollable.scrollLeft;
var bottom = top + closestScrollable.scrollHeight;
var right = left + closestScrollable.scrollWidth;
var paddingBox = {
top,
right,
bottom,
left
};
var borderBox = expand(paddingBox, base.border);
var client = createBox({
borderBox,
margin: base.margin,
border: base.border,
padding: base.padding
});
return client;
};
var getDimension = (function(_ref) {
var ref2 = _ref.ref, descriptor = _ref.descriptor, env = _ref.env, windowScroll = _ref.windowScroll, direction = _ref.direction, isDropDisabled = _ref.isDropDisabled, isCombineEnabled = _ref.isCombineEnabled, shouldClipSubject = _ref.shouldClipSubject;
var closestScrollable = env.closestScrollable;
var client = getClient(ref2, closestScrollable);
var page = withScroll(client, windowScroll);
var closest3 = (function() {
if (!closestScrollable) {
return null;
}
var frameClient = getBox(closestScrollable);
var scrollSize = {
scrollHeight: closestScrollable.scrollHeight,
scrollWidth: closestScrollable.scrollWidth
};
return {
client: frameClient,
page: withScroll(frameClient, windowScroll),
scroll: getScroll$1(closestScrollable),
scrollSize,
shouldClipSubject
};
})();
var dimension = getDroppableDimension({
descriptor,
isEnabled: !isDropDisabled,
isCombineEnabled,
isFixedOnPage: env.isFixedOnPage,
direction,
client,
page,
closest: closest3
});
return dimension;
});
var immediate = {
passive: false
};
var delayed = {
passive: true
};
var getListenerOptions = (function(options) {
return options.shouldPublishImmediately ? immediate : delayed;
});
function useRequiredContext(Context) {
var result = __mf_21(Context);
!result ? invariant() : void 0;
return result;
}
var getClosestScrollableFromDrag = function getClosestScrollableFromDrag2(dragging) {
return dragging && dragging.env.closestScrollable || null;
};
function useDroppablePublisher(args) {
var whileDraggingRef = __mf_31(null);
var appContext = useRequiredContext(AppContext);
var uniqueId = useUniqueId("droppable");
var registry = appContext.registry, marshal = appContext.marshal;
var previousRef = usePrevious(args);
var descriptor = useMemo(function() {
return {
id: args.droppableId,
type: args.type,
mode: args.mode
};
}, [
args.droppableId,
args.mode,
args.type
]);
var publishedDescriptorRef = __mf_31(descriptor);
var memoizedUpdateScroll = useMemo(function() {
return memoizeOne(function(x2, y2) {
!whileDraggingRef.current ? invariant() : void 0;
var scroll4 = {
x: x2,
y: y2
};
marshal.updateDroppableScroll(descriptor.id, scroll4);
});
}, [
descriptor.id,
marshal
]);
var getClosestScroll = useCallback(function() {
var dragging = whileDraggingRef.current;
if (!dragging || !dragging.env.closestScrollable) {
return origin;
}
return getScroll$1(dragging.env.closestScrollable);
}, []);
var updateScroll = useCallback(function() {
var scroll4 = getClosestScroll();
memoizedUpdateScroll(scroll4.x, scroll4.y);
}, [
getClosestScroll,
memoizedUpdateScroll
]);
var scheduleScrollUpdate = useMemo(function() {
return rafSchd(updateScroll);
}, [
updateScroll
]);
var onClosestScroll = useCallback(function() {
var dragging = whileDraggingRef.current;
var closest3 = getClosestScrollableFromDrag(dragging);
!(dragging && closest3) ? invariant() : void 0;
var options = dragging.scrollOptions;
if (options.shouldPublishImmediately) {
updateScroll();
return;
}
scheduleScrollUpdate();
}, [
scheduleScrollUpdate,
updateScroll
]);
var getDimensionAndWatchScroll = useCallback(function(windowScroll, options) {
!!whileDraggingRef.current ? invariant() : void 0;
var previous = previousRef.current;
var ref2 = previous.getDroppableRef();
!ref2 ? invariant() : void 0;
var env = getEnv(ref2);
var dragging = {
ref: ref2,
descriptor,
env,
scrollOptions: options
};
whileDraggingRef.current = dragging;
var dimension = getDimension({
ref: ref2,
descriptor,
env,
windowScroll,
direction: previous.direction,
isDropDisabled: previous.isDropDisabled,
isCombineEnabled: previous.isCombineEnabled,
shouldClipSubject: !previous.ignoreContainerClipping
});
var scrollable = env.closestScrollable;
if (scrollable) {
scrollable.setAttribute(scrollContainer.contextId, appContext.contextId);
scrollable.addEventListener("scroll", onClosestScroll, getListenerOptions(dragging.scrollOptions));
}
return dimension;
}, [
appContext.contextId,
descriptor,
onClosestScroll,
previousRef
]);
var getScrollWhileDragging = useCallback(function() {
var dragging = whileDraggingRef.current;
var closest3 = getClosestScrollableFromDrag(dragging);
!(dragging && closest3) ? invariant() : void 0;
return getScroll$1(closest3);
}, []);
var dragStopped = useCallback(function() {
var dragging = whileDraggingRef.current;
!dragging ? invariant() : void 0;
var closest3 = getClosestScrollableFromDrag(dragging);
whileDraggingRef.current = null;
if (!closest3) {
return;
}
scheduleScrollUpdate.cancel();
closest3.removeAttribute(scrollContainer.contextId);
closest3.removeEventListener("scroll", onClosestScroll, getListenerOptions(dragging.scrollOptions));
}, [
onClosestScroll,
scheduleScrollUpdate
]);
var scroll3 = useCallback(function(change) {
var dragging = whileDraggingRef.current;
!dragging ? invariant() : void 0;
var closest3 = getClosestScrollableFromDrag(dragging);
!closest3 ? invariant() : void 0;
closest3.scrollTop += change.y;
closest3.scrollLeft += change.x;
}, []);
var callbacks = useMemo(function() {
return {
getDimensionAndWatchScroll,
getScrollWhileDragging,
dragStopped,
scroll: scroll3
};
}, [
dragStopped,
getDimensionAndWatchScroll,
getScrollWhileDragging,
scroll3
]);
var entry = useMemo(function() {
return {
uniqueId,
descriptor,
callbacks
};
}, [
callbacks,
descriptor,
uniqueId
]);
useIsomorphicLayoutEffect(function() {
publishedDescriptorRef.current = entry.descriptor;
registry.droppable.register(entry);
return function() {
if (whileDraggingRef.current) {
dragStopped();
}
registry.droppable.unregister(entry);
};
}, [
callbacks,
descriptor,
dragStopped,
entry,
marshal,
registry.droppable
]);
useIsomorphicLayoutEffect(function() {
if (!whileDraggingRef.current) {
return;
}
marshal.updateDroppableIsEnabled(publishedDescriptorRef.current.id, !args.isDropDisabled);
}, [
args.isDropDisabled,
marshal
]);
useIsomorphicLayoutEffect(function() {
if (!whileDraggingRef.current) {
return;
}
marshal.updateDroppableIsCombineEnabled(publishedDescriptorRef.current.id, args.isCombineEnabled);
}, [
args.isCombineEnabled,
marshal
]);
}
function noop$2() {
}
var empty = {
width: 0,
height: 0,
margin: noSpacing
};
var getSize = function getSize2(_ref) {
var isAnimatingOpenOnMount = _ref.isAnimatingOpenOnMount, placeholder2 = _ref.placeholder, animate = _ref.animate;
if (isAnimatingOpenOnMount) {
return empty;
}
if (animate === "close") {
return empty;
}
return {
height: placeholder2.client.borderBox.height,
width: placeholder2.client.borderBox.width,
margin: placeholder2.client.margin
};
};
var getStyle = function getStyle2(_ref2) {
var isAnimatingOpenOnMount = _ref2.isAnimatingOpenOnMount, placeholder2 = _ref2.placeholder, animate = _ref2.animate;
var size = getSize({
isAnimatingOpenOnMount,
placeholder: placeholder2,
animate
});
return {
display: placeholder2.display,
boxSizing: "border-box",
width: size.width,
height: size.height,
marginTop: size.margin.top,
marginRight: size.margin.right,
marginBottom: size.margin.bottom,
marginLeft: size.margin.left,
flexShrink: "0",
flexGrow: "0",
pointerEvents: "none",
transition: animate !== "none" ? transitions.placeholder : null
};
};
function Placeholder(props) {
var animateOpenTimerRef = __mf_31(null);
var tryClearAnimateOpenTimer = useCallback(function() {
if (!animateOpenTimerRef.current) {
return;
}
clearTimeout(animateOpenTimerRef.current);
animateOpenTimerRef.current = null;
}, []);
var animate = props.animate, onTransitionEnd = props.onTransitionEnd, onClose = props.onClose, contextId = props.contextId;
var _useState = __mf_32(props.animate === "open"), isAnimatingOpenOnMount = _useState[0], setIsAnimatingOpenOnMount = _useState[1];
__mf_24(function() {
if (!isAnimatingOpenOnMount) {
return noop$2;
}
if (animate !== "open") {
tryClearAnimateOpenTimer();
setIsAnimatingOpenOnMount(false);
return noop$2;
}
if (animateOpenTimerRef.current) {
return noop$2;
}
animateOpenTimerRef.current = setTimeout(function() {
animateOpenTimerRef.current = null;
setIsAnimatingOpenOnMount(false);
});
return tryClearAnimateOpenTimer;
}, [
animate,
isAnimatingOpenOnMount,
tryClearAnimateOpenTimer
]);
var onSizeChangeEnd = useCallback(function(event) {
if (event.propertyName !== "height") {
return;
}
onTransitionEnd();
if (animate === "close") {
onClose();
}
}, [
animate,
onClose,
onTransitionEnd
]);
var style2 = getStyle({
isAnimatingOpenOnMount,
animate: props.animate,
placeholder: props.placeholder
});
return React.createElement(props.placeholder.tagName, {
style: style2,
"data-rbd-placeholder-context-id": contextId,
onTransitionEnd: onSizeChangeEnd,
ref: props.innerRef
});
}
var Placeholder$1 = React.memo(Placeholder);
var DroppableContext = React.createContext(null);
var AnimateInOut = (function(_React$PureComponent) {
_inheritsLoose(AnimateInOut2, _React$PureComponent);
function AnimateInOut2() {
var _this;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _React$PureComponent.call.apply(_React$PureComponent, [
this
].concat(args)) || this;
_this.state = {
isVisible: Boolean(_this.props.on),
data: _this.props.on,
animate: _this.props.shouldAnimate && _this.props.on ? "open" : "none"
};
_this.onClose = function() {
if (_this.state.animate !== "close") {
return;
}
_this.setState({
isVisible: false
});
};
return _this;
}
AnimateInOut2.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
if (!props.shouldAnimate) {
return {
isVisible: Boolean(props.on),
data: props.on,
animate: "none"
};
}
if (props.on) {
return {
isVisible: true,
data: props.on,
animate: "open"
};
}
if (state.isVisible) {
return {
isVisible: true,
data: state.data,
animate: "close"
};
}
return {
isVisible: false,
animate: "close",
data: null
};
};
var _proto = AnimateInOut2.prototype;
_proto.render = function render() {
if (!this.state.isVisible) {
return null;
}
var provided = {
onClose: this.onClose,
data: this.state.data,
animate: this.state.animate
};
return this.props.children(provided);
};
return AnimateInOut2;
})(React.PureComponent);
var zIndexOptions = {
dragging: 5e3,
dropAnimating: 4500
};
var getDraggingTransition = function getDraggingTransition2(shouldAnimateDragMovement, dropping) {
if (dropping) {
return transitions.drop(dropping.duration);
}
if (shouldAnimateDragMovement) {
return transitions.snap;
}
return transitions.fluid;
};
var getDraggingOpacity = function getDraggingOpacity2(isCombining, isDropAnimating) {
if (!isCombining) {
return null;
}
return isDropAnimating ? combine.opacity.drop : combine.opacity.combining;
};
var getShouldDraggingAnimate = function getShouldDraggingAnimate2(dragging) {
if (dragging.forceShouldAnimate != null) {
return dragging.forceShouldAnimate;
}
return dragging.mode === "SNAP";
};
function getDraggingStyle(dragging) {
var dimension = dragging.dimension;
var box = dimension.client;
var offset2 = dragging.offset, combineWith = dragging.combineWith, dropping = dragging.dropping;
var isCombining = Boolean(combineWith);
var shouldAnimate = getShouldDraggingAnimate(dragging);
var isDropAnimating = Boolean(dropping);
var transform = isDropAnimating ? transforms.drop(offset2, isCombining) : transforms.moveTo(offset2);
var style2 = {
position: "fixed",
top: box.marginBox.top,
left: box.marginBox.left,
boxSizing: "border-box",
width: box.borderBox.width,
height: box.borderBox.height,
transition: getDraggingTransition(shouldAnimate, dropping),
transform,
opacity: getDraggingOpacity(isCombining, isDropAnimating),
zIndex: isDropAnimating ? zIndexOptions.dropAnimating : zIndexOptions.dragging,
pointerEvents: "none"
};
return style2;
}
function getSecondaryStyle(secondary) {
return {
transform: transforms.moveTo(secondary.offset),
transition: secondary.shouldAnimateDisplacement ? null : "none"
};
}
function getStyle$1(mapped) {
return mapped.type === "DRAGGING" ? getDraggingStyle(mapped) : getSecondaryStyle(mapped);
}
function getDimension$1(descriptor, el, windowScroll) {
if (windowScroll === void 0) {
windowScroll = origin;
}
var computedStyles = window.getComputedStyle(el);
var borderBox = el.getBoundingClientRect();
var client = calculateBox(borderBox, computedStyles);
var page = withScroll(client, windowScroll);
var placeholder2 = {
client,
tagName: el.tagName.toLowerCase(),
display: computedStyles.display
};
var displaceBy = {
x: client.marginBox.width,
y: client.marginBox.height
};
var dimension = {
descriptor,
placeholder: placeholder2,
displaceBy,
client,
page
};
return dimension;
}
function useDraggablePublisher(args) {
var uniqueId = useUniqueId("draggable");
var descriptor = args.descriptor, registry = args.registry, getDraggableRef = args.getDraggableRef, canDragInteractiveElements = args.canDragInteractiveElements, shouldRespectForcePress = args.shouldRespectForcePress, isEnabled = args.isEnabled;
var options = useMemo(function() {
return {
canDragInteractiveElements,
shouldRespectForcePress,
isEnabled
};
}, [
canDragInteractiveElements,
isEnabled,
shouldRespectForcePress
]);
var getDimension2 = useCallback(function(windowScroll) {
var el = getDraggableRef();
!el ? invariant() : void 0;
return getDimension$1(descriptor, el, windowScroll);
}, [
descriptor,
getDraggableRef
]);
var entry = useMemo(function() {
return {
uniqueId,
descriptor,
options,
getDimension: getDimension2
};
}, [
descriptor,
getDimension2,
options,
uniqueId
]);
var publishedRef = __mf_31(entry);
var isFirstPublishRef = __mf_31(true);
useIsomorphicLayoutEffect(function() {
registry.draggable.register(publishedRef.current);
return function() {
return registry.draggable.unregister(publishedRef.current);
};
}, [
registry.draggable
]);
useIsomorphicLayoutEffect(function() {
if (isFirstPublishRef.current) {
isFirstPublishRef.current = false;
return;
}
var last = publishedRef.current;
publishedRef.current = entry;
registry.draggable.update(entry, last);
}, [
entry,
registry.draggable
]);
}
function preventHtml5Dnd(event) {
event.preventDefault();
}
function Draggable(props) {
var ref2 = __mf_31(null);
var setRef2 = useCallback(function(el) {
ref2.current = el;
}, []);
var getRef = useCallback(function() {
return ref2.current;
}, []);
var _useRequiredContext = useRequiredContext(AppContext), contextId = _useRequiredContext.contextId, dragHandleUsageInstructionsId = _useRequiredContext.dragHandleUsageInstructionsId, registry = _useRequiredContext.registry;
var _useRequiredContext2 = useRequiredContext(DroppableContext), type = _useRequiredContext2.type, droppableId = _useRequiredContext2.droppableId;
var descriptor = useMemo(function() {
return {
id: props.draggableId,
index: props.index,
type,
droppableId
};
}, [
props.draggableId,
props.index,
type,
droppableId
]);
var children = props.children, draggableId = props.draggableId, isEnabled = props.isEnabled, shouldRespectForcePress = props.shouldRespectForcePress, canDragInteractiveElements = props.canDragInteractiveElements, isClone = props.isClone, mapped = props.mapped, dropAnimationFinishedAction = props.dropAnimationFinished;
if (!isClone) {
var forPublisher = useMemo(function() {
return {
descriptor,
registry,
getDraggableRef: getRef,
canDragInteractiveElements,
shouldRespectForcePress,
isEnabled
};
}, [
descriptor,
registry,
getRef,
canDragInteractiveElements,
shouldRespectForcePress,
isEnabled
]);
useDraggablePublisher(forPublisher);
}
var dragHandleProps = useMemo(function() {
return isEnabled ? {
tabIndex: 0,
role: "button",
"aria-describedby": dragHandleUsageInstructionsId,
"data-rbd-drag-handle-draggable-id": draggableId,
"data-rbd-drag-handle-context-id": contextId,
draggable: false,
onDragStart: preventHtml5Dnd
} : null;
}, [
contextId,
dragHandleUsageInstructionsId,
draggableId,
isEnabled
]);
var onMoveEnd = useCallback(function(event) {
if (mapped.type !== "DRAGGING") {
return;
}
if (!mapped.dropping) {
return;
}
if (event.propertyName !== "transform") {
return;
}
dropAnimationFinishedAction();
}, [
dropAnimationFinishedAction,
mapped
]);
var provided = useMemo(function() {
var style2 = getStyle$1(mapped);
var onTransitionEnd = mapped.type === "DRAGGING" && mapped.dropping ? onMoveEnd : null;
var result = {
innerRef: setRef2,
draggableProps: {
"data-rbd-draggable-context-id": contextId,
"data-rbd-draggable-id": draggableId,
style: style2,
onTransitionEnd
},
dragHandleProps
};
return result;
}, [
contextId,
dragHandleProps,
draggableId,
mapped,
onMoveEnd,
setRef2
]);
var rubric = useMemo(function() {
return {
draggableId: descriptor.id,
type: descriptor.type,
source: {
index: descriptor.index,
droppableId: descriptor.droppableId
}
};
}, [
descriptor.droppableId,
descriptor.id,
descriptor.index,
descriptor.type
]);
return children(provided, mapped.snapshot, rubric);
}
var isStrictEqual = (function(a, b2) {
return a === b2;
});
var whatIsDraggedOverFromResult = (function(result) {
var combine2 = result.combine, destination = result.destination;
if (destination) {
return destination.droppableId;
}
if (combine2) {
return combine2.droppableId;
}
return null;
});
var getCombineWithFromResult = function getCombineWithFromResult2(result) {
return result.combine ? result.combine.draggableId : null;
};
var getCombineWithFromImpact = function getCombineWithFromImpact2(impact) {
return impact.at && impact.at.type === "COMBINE" ? impact.at.combine.draggableId : null;
};
function getDraggableSelector() {
var memoizedOffset = memoizeOne(function(x2, y2) {
return {
x: x2,
y: y2
};
});
var getMemoizedSnapshot = memoizeOne(function(mode, isClone, draggingOver, combineWith, dropping) {
return {
isDragging: true,
isClone,
isDropAnimating: Boolean(dropping),
dropAnimation: dropping,
mode,
draggingOver,
combineWith,
combineTargetFor: null
};
});
var getMemoizedProps = memoizeOne(function(offset2, mode, dimension, isClone, draggingOver, combineWith, forceShouldAnimate) {
return {
mapped: {
type: "DRAGGING",
dropping: null,
draggingOver,
combineWith,
mode,
offset: offset2,
dimension,
forceShouldAnimate,
snapshot: getMemoizedSnapshot(mode, isClone, draggingOver, combineWith, null)
}
};
});
var selector = function selector2(state, ownProps) {
if (state.isDragging) {
if (state.critical.draggable.id !== ownProps.draggableId) {
return null;
}
var offset2 = state.current.client.offset;
var dimension = state.dimensions.draggables[ownProps.draggableId];
var draggingOver = whatIsDraggedOver(state.impact);
var combineWith = getCombineWithFromImpact(state.impact);
var forceShouldAnimate = state.forceShouldAnimate;
return getMemoizedProps(memoizedOffset(offset2.x, offset2.y), state.movementMode, dimension, ownProps.isClone, draggingOver, combineWith, forceShouldAnimate);
}
if (state.phase === "DROP_ANIMATING") {
var completed = state.completed;
if (completed.result.draggableId !== ownProps.draggableId) {
return null;
}
var isClone = ownProps.isClone;
var _dimension = state.dimensions.draggables[ownProps.draggableId];
var result = completed.result;
var mode = result.mode;
var _draggingOver = whatIsDraggedOverFromResult(result);
var _combineWith = getCombineWithFromResult(result);
var duration = state.dropDuration;
var dropping = {
duration,
curve: curves.drop,
moveTo: state.newHomeClientOffset,
opacity: _combineWith ? combine.opacity.drop : null,
scale: _combineWith ? combine.scale.drop : null
};
return {
mapped: {
type: "DRAGGING",
offset: state.newHomeClientOffset,
dimension: _dimension,
dropping,
draggingOver: _draggingOver,
combineWith: _combineWith,
mode,
forceShouldAnimate: null,
snapshot: getMemoizedSnapshot(mode, isClone, _draggingOver, _combineWith, dropping)
}
};
}
return null;
};
return selector;
}
function getSecondarySnapshot(combineTargetFor) {
return {
isDragging: false,
isDropAnimating: false,
isClone: false,
dropAnimation: null,
mode: null,
draggingOver: null,
combineTargetFor,
combineWith: null
};
}
var atRest = {
mapped: {
type: "SECONDARY",
offset: origin,
combineTargetFor: null,
shouldAnimateDisplacement: true,
snapshot: getSecondarySnapshot(null)
}
};
function getSecondarySelector() {
var memoizedOffset = memoizeOne(function(x2, y2) {
return {
x: x2,
y: y2
};
});
var getMemoizedSnapshot = memoizeOne(getSecondarySnapshot);
var getMemoizedProps = memoizeOne(function(offset2, combineTargetFor, shouldAnimateDisplacement) {
if (combineTargetFor === void 0) {
combineTargetFor = null;
}
return {
mapped: {
type: "SECONDARY",
offset: offset2,
combineTargetFor,
shouldAnimateDisplacement,
snapshot: getMemoizedSnapshot(combineTargetFor)
}
};
});
var getFallback = function getFallback2(combineTargetFor) {
return combineTargetFor ? getMemoizedProps(origin, combineTargetFor, true) : null;
};
var getProps = function getProps2(ownId, draggingId, impact, afterCritical) {
var visualDisplacement = impact.displaced.visible[ownId];
var isAfterCriticalInVirtualList = Boolean(afterCritical.inVirtualList && afterCritical.effected[ownId]);
var combine2 = tryGetCombine(impact);
var combineTargetFor = combine2 && combine2.draggableId === ownId ? draggingId : null;
if (!visualDisplacement) {
if (!isAfterCriticalInVirtualList) {
return getFallback(combineTargetFor);
}
if (impact.displaced.invisible[ownId]) {
return null;
}
var change = negate(afterCritical.displacedBy.point);
var _offset = memoizedOffset(change.x, change.y);
return getMemoizedProps(_offset, combineTargetFor, true);
}
if (isAfterCriticalInVirtualList) {
return getFallback(combineTargetFor);
}
var displaceBy = impact.displacedBy.point;
var offset2 = memoizedOffset(displaceBy.x, displaceBy.y);
return getMemoizedProps(offset2, combineTargetFor, visualDisplacement.shouldAnimate);
};
var selector = function selector2(state, ownProps) {
if (state.isDragging) {
if (state.critical.draggable.id === ownProps.draggableId) {
return null;
}
return getProps(ownProps.draggableId, state.critical.draggable.id, state.impact, state.afterCritical);
}
if (state.phase === "DROP_ANIMATING") {
var completed = state.completed;
if (completed.result.draggableId === ownProps.draggableId) {
return null;
}
return getProps(ownProps.draggableId, completed.result.draggableId, completed.impact, completed.afterCritical);
}
return null;
};
return selector;
}
var makeMapStateToProps = function makeMapStateToProps2() {
var draggingSelector = getDraggableSelector();
var secondarySelector = getSecondarySelector();
var selector = function selector2(state, ownProps) {
return draggingSelector(state, ownProps) || secondarySelector(state, ownProps) || atRest;
};
return selector;
};
var mapDispatchToProps = {
dropAnimationFinished
};
var ConnectedDraggable = connect(makeMapStateToProps, mapDispatchToProps, null, {
context: StoreContext,
pure: true,
areStatePropsEqual: isStrictEqual
})(Draggable);
function PrivateDraggable(props) {
var droppableContext = useRequiredContext(DroppableContext);
var isUsingCloneFor = droppableContext.isUsingCloneFor;
if (isUsingCloneFor === props.draggableId && !props.isClone) {
return null;
}
return React.createElement(ConnectedDraggable, props);
}
PublicDraggable = function(props) {
var isEnabled = typeof props.isDragDisabled === "boolean" ? !props.isDragDisabled : true;
var canDragInteractiveElements = Boolean(props.disableInteractiveElementBlocking);
var shouldRespectForcePress = Boolean(props.shouldRespectForcePress);
return React.createElement(PrivateDraggable, _extends$1({}, props, {
isClone: false,
isEnabled,
canDragInteractiveElements,
shouldRespectForcePress
}));
};
function Droppable(props) {
var appContext = __mf_21(AppContext);
!appContext ? invariant() : void 0;
var contextId = appContext.contextId, isMovementAllowed2 = appContext.isMovementAllowed;
var droppableRef = __mf_31(null);
var placeholderRef = __mf_31(null);
var children = props.children, droppableId = props.droppableId, type = props.type, mode = props.mode, direction = props.direction, ignoreContainerClipping = props.ignoreContainerClipping, isDropDisabled = props.isDropDisabled, isCombineEnabled = props.isCombineEnabled, snapshot = props.snapshot, useClone = props.useClone, updateViewportMaxScroll3 = props.updateViewportMaxScroll, getContainerForClone = props.getContainerForClone;
var getDroppableRef = useCallback(function() {
return droppableRef.current;
}, []);
var setDroppableRef = useCallback(function(value) {
droppableRef.current = value;
}, []);
useCallback(function() {
return placeholderRef.current;
}, []);
var setPlaceholderRef = useCallback(function(value) {
placeholderRef.current = value;
}, []);
var onPlaceholderTransitionEnd = useCallback(function() {
if (isMovementAllowed2()) {
updateViewportMaxScroll3({
maxScroll: getMaxWindowScroll()
});
}
}, [
isMovementAllowed2,
updateViewportMaxScroll3
]);
useDroppablePublisher({
droppableId,
type,
mode,
direction,
isDropDisabled,
isCombineEnabled,
ignoreContainerClipping,
getDroppableRef
});
var placeholder2 = React.createElement(AnimateInOut, {
on: props.placeholder,
shouldAnimate: props.shouldAnimatePlaceholder
}, function(_ref) {
var onClose = _ref.onClose, data = _ref.data, animate = _ref.animate;
return React.createElement(Placeholder$1, {
placeholder: data,
onClose,
innerRef: setPlaceholderRef,
animate,
contextId,
onTransitionEnd: onPlaceholderTransitionEnd
});
});
var provided = useMemo(function() {
return {
innerRef: setDroppableRef,
placeholder: placeholder2,
droppableProps: {
"data-rbd-droppable-id": droppableId,
"data-rbd-droppable-context-id": contextId
}
};
}, [
contextId,
droppableId,
placeholder2,
setDroppableRef
]);
var isUsingCloneFor = useClone ? useClone.dragging.draggableId : null;
var droppableContext = useMemo(function() {
return {
droppableId,
type,
isUsingCloneFor
};
}, [
droppableId,
isUsingCloneFor,
type
]);
function getClone() {
if (!useClone) {
return null;
}
var dragging = useClone.dragging, render = useClone.render;
var node = React.createElement(PrivateDraggable, {
draggableId: dragging.draggableId,
index: dragging.source.index,
isClone: true,
isEnabled: true,
shouldRespectForcePress: false,
canDragInteractiveElements: true
}, function(draggableProvided, draggableSnapshot) {
return render(draggableProvided, draggableSnapshot, dragging);
});
return ReactDOM.createPortal(node, getContainerForClone());
}
return React.createElement(DroppableContext.Provider, {
value: droppableContext
}, children(provided, snapshot), getClone());
}
var isMatchingType = function isMatchingType2(type, critical) {
return type === critical.droppable.type;
};
var getDraggable = function getDraggable2(critical, dimensions) {
return dimensions.draggables[critical.draggable.id];
};
var makeMapStateToProps$1 = function makeMapStateToProps3() {
var idleWithAnimation = {
placeholder: null,
shouldAnimatePlaceholder: true,
snapshot: {
isDraggingOver: false,
draggingOverWith: null,
draggingFromThisWith: null,
isUsingPlaceholder: false
},
useClone: null
};
var idleWithoutAnimation = _extends$1({}, idleWithAnimation, {
shouldAnimatePlaceholder: false
});
var getDraggableRubric = memoizeOne(function(descriptor) {
return {
draggableId: descriptor.id,
type: descriptor.type,
source: {
index: descriptor.index,
droppableId: descriptor.droppableId
}
};
});
var getMapProps = memoizeOne(function(id, isEnabled, isDraggingOverForConsumer, isDraggingOverForImpact, dragging, renderClone) {
var draggableId = dragging.descriptor.id;
var isHome = dragging.descriptor.droppableId === id;
if (isHome) {
var useClone = renderClone ? {
render: renderClone,
dragging: getDraggableRubric(dragging.descriptor)
} : null;
var _snapshot = {
isDraggingOver: isDraggingOverForConsumer,
draggingOverWith: isDraggingOverForConsumer ? draggableId : null,
draggingFromThisWith: draggableId,
isUsingPlaceholder: true
};
return {
placeholder: dragging.placeholder,
shouldAnimatePlaceholder: false,
snapshot: _snapshot,
useClone
};
}
if (!isEnabled) {
return idleWithoutAnimation;
}
if (!isDraggingOverForImpact) {
return idleWithAnimation;
}
var snapshot = {
isDraggingOver: isDraggingOverForConsumer,
draggingOverWith: draggableId,
draggingFromThisWith: null,
isUsingPlaceholder: true
};
return {
placeholder: dragging.placeholder,
shouldAnimatePlaceholder: true,
snapshot,
useClone: null
};
});
var selector = function selector2(state, ownProps) {
var id = ownProps.droppableId;
var type = ownProps.type;
var isEnabled = !ownProps.isDropDisabled;
var renderClone = ownProps.renderClone;
if (state.isDragging) {
var critical = state.critical;
if (!isMatchingType(type, critical)) {
return idleWithoutAnimation;
}
var dragging = getDraggable(critical, state.dimensions);
var isDraggingOver = whatIsDraggedOver(state.impact) === id;
return getMapProps(id, isEnabled, isDraggingOver, isDraggingOver, dragging, renderClone);
}
if (state.phase === "DROP_ANIMATING") {
var completed = state.completed;
if (!isMatchingType(type, completed.critical)) {
return idleWithoutAnimation;
}
var _dragging = getDraggable(completed.critical, state.dimensions);
return getMapProps(id, isEnabled, whatIsDraggedOverFromResult(completed.result) === id, whatIsDraggedOver(completed.impact) === id, _dragging, renderClone);
}
if (state.phase === "IDLE" && state.completed && !state.shouldFlush) {
var _completed = state.completed;
if (!isMatchingType(type, _completed.critical)) {
return idleWithoutAnimation;
}
var wasOver = whatIsDraggedOver(_completed.impact) === id;
var wasCombining = Boolean(_completed.impact.at && _completed.impact.at.type === "COMBINE");
var isHome = _completed.critical.droppable.id === id;
if (wasOver) {
return wasCombining ? idleWithAnimation : idleWithoutAnimation;
}
if (isHome) {
return idleWithAnimation;
}
return idleWithoutAnimation;
}
return idleWithoutAnimation;
};
return selector;
};
var mapDispatchToProps$1 = {
updateViewportMaxScroll
};
function getBody() {
!document.body ? invariant() : void 0;
return document.body;
}
var defaultProps = {
mode: "standard",
type: "DEFAULT",
direction: "vertical",
isDropDisabled: false,
isCombineEnabled: false,
ignoreContainerClipping: false,
renderClone: null,
getContainerForClone: getBody
};
ConnectedDroppable = connect(makeMapStateToProps$1, mapDispatchToProps$1, null, {
context: StoreContext,
pure: true,
areStatePropsEqual: isStrictEqual
})(Droppable);
ConnectedDroppable.defaultProps = defaultProps;
registerWidgetsLoadIndicator = function(cb) {
window.__widgetsLoadIndicator = cb;
};
dist.init({
name: "iobroker_vis",
remotes: []
});
function _loadComponentHelper(context) {
const promises = [];
for (let i = 0; i < context.visWidgetsCollection.components.length; i++) {
((index, _visWidgetsCollection) => {
context.countRef.max++;
const promise = dist.loadRemote(`${context.visWidgetsCollection.name}/${_visWidgetsCollection.components[index]}`).then((CustomComponent) => {
var _a;
if (CustomComponent) {
context.countRef.count++;
if (CustomComponent.default) {
CustomComponent.default.adapter = context.dynamicWidgetInstance._id.substring("system.adapter.".length).replace(/\.\d*$/, "");
CustomComponent.default.version = context.dynamicWidgetInstance.common.version;
CustomComponent.default.setIcon = context.dynamicWidgetInstance.common.icon;
CustomComponent.default.url = _visWidgetsCollection.url;
if (context.i18nPrefix) {
CustomComponent.default.i18nPrefix = context.i18nPrefix;
}
context.result.push(CustomComponent.default);
} else {
console.error(`Cannot load widget ${context.dynamicWidgetInstance._id}. No default found`);
}
(_a = window.__widgetsLoadIndicator) == null ? void 0 : _a.call(window, context.countRef.count, context.countRef.max);
}
}).catch((e2) => {
console.error(`Cannot load widget ${context.dynamicWidgetInstance._id}: ${e2.toString()}`);
console.error(`Cannot load widget ${context.dynamicWidgetInstance._id}: ${JSON.stringify(e2)}`);
});
promises.push(promise);
})(i, context.visWidgetsCollection);
}
return Promise.all(promises);
}
function getText(text) {
if (typeof text === "object") {
return text[__mf_2$1.getLanguage()] || text.en || "";
}
return (text || "").toString();
}
const cloudVersions = {
echarts: void 0,
eventlist: void 0,
fullcalendar: void 0,
openweathermap: void 0,
scenes: void 0,
scheduler: "module",
"vis-2-widgets-energy": void 0,
"vis-2-widgets-gauges": "module",
"vis-2-widgets-jaeger-design": "module",
"vis-2-widgets-material": void 0
};
function fixCloudBundlerType(adapterName, visWidgetsCollection) {
if (window.location.hostname.includes("iobroker.")) {
if (adapterName in cloudVersions) {
visWidgetsCollection.bundlerType = cloudVersions[adapterName];
}
}
}
function getRemoteWidgets(socket, onlyWidgetSets) {
let getObjectViewSystem = socket.getObjectViewSystem.bind(socket);
if (socket.getObjectViewSystemCached) {
getObjectViewSystem = socket.getObjectViewSystemCached.bind(socket);
}
return getObjectViewSystem("instance", "system.adapter.", "system.adapter.\u9999").then((objects) => {
var _a;
const result = [];
const additionalSets = {};
const countRef = {
count: 0,
max: 0
};
const instances = Object.values(objects);
const dynamicWidgetInstances = instances.filter((obj) => {
if (!obj.common.visWidgets && !obj.common.visIconSets) {
return false;
}
if (obj.common.visWidgets) {
const ignoreVersions = obj.common.visWidgets.ignoreInVersions || [];
return !ignoreVersions.includes(2) && (!onlyWidgetSets || onlyWidgetSets.includes(getText(obj.common.name)));
}
return !onlyWidgetSets;
});
const promises = [];
for (let i = 0; i < dynamicWidgetInstances.length; i++) {
const dynamicWidgetInstance = dynamicWidgetInstances[i];
for (const widgetSetName in dynamicWidgetInstance.common.visWidgets) {
if (widgetSetName === "i18n") {
const _widgetSetName = Object.keys(dynamicWidgetInstance.common.visWidgets).find((name) => name !== "i18n");
console.warn(`common.visWidgets.i18n is deprecated. Use common.visWidgets.${_widgetSetName}.i18n instead.`);
} else {
const visWidgetsCollection = dynamicWidgetInstance.common.visWidgets[widgetSetName];
if (Array.isArray(visWidgetsCollection.ignoreInVersions) && visWidgetsCollection.ignoreInVersions.includes(2)) {
continue;
}
if (!((_a = visWidgetsCollection.url) == null ? void 0 : _a.startsWith("http"))) {
visWidgetsCollection.url = `./vis-2/widgets/${visWidgetsCollection.url}`;
}
fixCloudBundlerType(dynamicWidgetInstance.common.name, visWidgetsCollection);
dist.registerRemotes([
{
name: visWidgetsCollection.name,
entry: visWidgetsCollection.url,
type: visWidgetsCollection.bundlerType || void 0
}
]);
if (visWidgetsCollection.components) {
((collection, instance) => {
try {
let i18nPrefix = "";
let i18nPromiseWait;
if (collection.url && collection.i18n === true) {
const pos = collection.url.lastIndexOf("/");
let i18nURL;
if (pos !== -1) {
i18nURL = collection.url.substring(0, pos);
} else {
i18nURL = collection.url;
}
const lang = __mf_2$1.getLanguage();
i18nPromiseWait = fetch(`${i18nURL}/i18n/${lang}.json`).then((data) => data.json()).then((json) => {
var _a2;
countRef.count++;
__mf_2$1.extendTranslations(json, lang);
(_a2 = window.__widgetsLoadIndicator) == null ? void 0 : _a2.call(window, countRef.count, promises.length);
}).catch((error) => {
if (lang !== "en") {
return fetch(`${i18nURL}/i18n/en.json`).then((data) => data.json()).then((json) => {
var _a2;
countRef.count++;
__mf_2$1.extendTranslations(json, lang);
(_a2 = window.__widgetsLoadIndicator) == null ? void 0 : _a2.call(window, countRef.count, promises.length);
}).catch((_error) => console.log(`Cannot load i18n "${i18nURL}/i18n/${lang}.json": ${_error}`));
}
console.log(`Cannot load i18n "${i18nURL}/i18n/${lang}.json": ${error}`);
return null;
});
promises.push(i18nPromiseWait);
} else if (collection.url && collection.i18n === "component") {
i18nPromiseWait = dist.loadRemote(`${collection.name}/translations`).then((translations) => {
var _a2;
countRef.count++;
if (translations.default.prefix === true) {
translations.default.prefix = `${instance.common.name}_`;
}
i18nPrefix = translations.default.prefix;
__mf_2$1.extendTranslations(translations.default);
(_a2 = window.__widgetsLoadIndicator) == null ? void 0 : _a2.call(window, countRef.count, promises.length);
}).catch((error) => console.log(`Cannot load i18n "${collection.name}": ${error}`));
} else if (collection.i18n && typeof collection.i18n === "object") {
try {
__mf_2$1.extendTranslations(collection.i18n);
} catch (error) {
console.error(`Cannot import i18n: ${error}`);
}
}
if (collection.components) {
if (i18nPromiseWait instanceof Promise) {
promises.push(i18nPromiseWait.then(() => _loadComponentHelper({
visWidgetsCollection: collection,
countRef,
dynamicWidgetInstance: instance,
i18nPrefix,
result
})));
} else {
promises.push(_loadComponentHelper({
visWidgetsCollection: collection,
countRef,
dynamicWidgetInstance: instance,
i18nPrefix,
result
}));
}
} else if (i18nPromiseWait instanceof Promise) {
promises.push(i18nPromiseWait);
}
} catch (e2) {
console.error(e2);
}
})(visWidgetsCollection, dynamicWidgetInstance);
}
}
}
if (!onlyWidgetSets) {
const visIconSets = dynamicWidgetInstance.common.visIconSets || {};
for (const iconSetName in visIconSets) {
const visIconSetCollection = visIconSets[iconSetName];
if (Array.isArray(visIconSetCollection.ignoreInVersions) && visIconSetCollection.ignoreInVersions.includes(2)) {
continue;
}
if (!visIconSetCollection.url) {
console.warn(`Icon set "${iconSetName}" of ${dynamicWidgetInstance._id} ignored: url missing`);
continue;
}
if (!visIconSetCollection.url.startsWith("http://") && !visIconSetCollection.url.startsWith("https://") && !visIconSetCollection.url.startsWith("file://")) {
visIconSetCollection.url = `widgets/${visIconSetCollection.url}`;
}
additionalSets[iconSetName] = {
name: visIconSetCollection.name,
url: visIconSetCollection.url,
icon: visIconSetCollection.icon
};
}
}
}
return Promise.all(promises).then(() => ({
widgetSets: result,
additionalSets
}));
}).catch((e2) => {
console.error("Cannot read instances", e2);
return void 0;
});
}
class BasicBar extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplValueFloatBar",
visSet: "basic",
visName: "Bar",
visPrev: "widgets/basic/img/Prev_ValueFloatBar.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "min",
type: "number",
default: 0
},
{
name: "max",
type: "number",
default: 100
},
{
name: "orientation",
type: "select",
default: "horizontal",
options: [
{
value: "horizontal",
label: "horizontal"
},
{
value: "vertical",
label: "vertical"
}
]
},
{
name: "color",
type: "color",
default: "blue"
},
{
name: "border",
type: "text"
},
{
name: "shadow",
type: "text"
},
{
name: "reverse",
type: "checkbox"
}
]
}
],
visDefaultStyle: {
width: 200,
height: 130
}
};
}
getWidgetInfo() {
return BasicBar.getWidgetInfo();
}
extractWidth(css, multiplier) {
const m2 = css.match(/([0-9]+)(px|em)?/);
if (m2) {
if (m2[1] && m2[2]) {
return parseInt(m2[1], 10) * (multiplier || 1) + m2[2];
}
return parseInt(m2[1], 10) * (multiplier || 1);
}
return void 0;
}
getCalc() {
const min = this.state.rxData.min || this.state.rxData.min === 0 ? Number(this.state.rxData.min) : 0;
const max = this.state.rxData.max || this.state.rxData.max === 0 ? Number(this.state.rxData.max) : 100;
let val = parseFloat(this.state.values[`${this.state.rxData.oid}.val`]) || 0;
val = (val - min) / (max - min);
return this.state.rxData.border ? `calc(${Math.round(val * 100)}% - ${this.extractWidth(this.state.rxData.border, 2)})` : `${Math.round(val * 100)}%`;
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
let style2;
if (this.state.rxData.orientation === "vertical") {
style2 = {
height: this.getCalc()
};
if (this.state.rxData.reverse) {
style2 = {
...style2,
left: 0,
position: "absolute",
bottom: "0"
};
}
if (this.state.rxData.border) {
style2 = {
...style2,
border: this.state.rxData.border,
width: `calc(100% - ${this.extractWidth(this.state.rxData.border, 2)}`
};
}
} else {
style2 = {
width: this.getCalc()
};
if (this.state.rxData.reverse) {
style2 = {
...style2,
float: "right"
};
}
if (this.state.rxData.border) {
style2 = {
...style2,
border: this.state.rxData.border,
height: `calc(100% - ${this.extractWidth(this.state.rxData.border, 2)}`
};
}
}
if (this.state.rxData.shadow) {
style2 = {
...style2,
boxShadow: this.state.rxData.shadow
};
}
if (this.state.rxData.color) {
style2 = {
...style2,
backgroundColor: this.state.rxData.color
};
}
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsx("div", {
"data-oid": this.state.rxData.oid,
className: "vis-widget-body",
style: style2
})
});
}
}
class BasicBulb extends VisRxWidget {
getWidgetInfo() {
return BasicBulb.getWidgetInfo();
}
static getWidgetInfo() {
return {
id: "tplBulbOnOffCtrl",
visSet: "basic",
visName: "Bulb on/off",
visPrev: "widgets/basic/img/Prev_BulbOnOffCtrl.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "min"
},
{
name: "max"
},
{
name: "icon_off",
type: "image",
default: "img/bulb_off.png"
},
{
name: "icon_on",
type: "image",
default: "img/bulb_on.png"
},
{
name: "readOnly",
type: "checkbox"
}
]
},
{
name: "ccontrol",
fields: [
{
name: "urlTrue"
},
{
name: "urlFalse"
},
{
name: "oidTrue",
type: "id"
},
{
name: "oidFalse",
type: "id"
},
{
name: "oidTrueValue"
},
{
name: "oidFalseValue"
}
]
}
]
};
}
toggle() {
if (this.state.rxData.oid === NOTHING_SELECTED || this.state.rxData.readOnly) {
return;
}
let val = this.state.values[`${this.state.rxData.oid}.val`];
const { oidTrue, urlTrue, oid, min, max, oidTrueValue, oidFalseValue } = this.state.rxData;
let { urlFalse, oidFalse } = this.state.rxData;
let finalMin = min ?? "";
let finalMax = max ?? "";
let oidTrueValueFinal = oidTrueValue ?? "";
let oidFalseValueFinal = oidFalseValue ?? "";
if (oidTrue || urlTrue) {
if (!oidFalse && oidTrue) {
oidFalse = oidTrue;
}
if (!urlFalse && urlTrue) {
urlFalse = urlTrue;
}
if (finalMax !== "") {
if (finalMax === "true") {
finalMax = true;
} else if (finalMax === "false") {
finalMax = false;
}
if (val === "true") {
val = true;
} else if (val === "false") {
val = false;
}
val = val === finalMax;
} else {
val = val === 1 || val === "1" || val === true || val === "true";
}
val = !val;
if (finalMin === "" || finalMin === "false" || finalMin === null) {
finalMin = false;
} else if (finalMax === "" || finalMax === "true" || finalMax === null) {
finalMax = true;
}
if (oidTrue && typeof oidTrue === "string") {
if (val) {
if (oidTrueValueFinal === "") {
oidTrueValueFinal = finalMax;
}
if (oidTrueValueFinal === "false") {
oidTrueValueFinal = false;
} else if (oidTrueValueFinal === "true") {
oidTrueValueFinal = true;
}
if (typeof oidTrueValueFinal === "string") {
const f2 = parseFloat(oidTrueValueFinal);
if (f2.toString() === oidTrueValueFinal) {
oidTrueValueFinal = f2;
}
}
this.props.context.setValue(oidTrue, oidTrueValueFinal);
} else if (typeof oidFalse === "string") {
if (oidFalseValueFinal === "") {
oidFalseValueFinal = finalMin;
} else if (oidFalseValueFinal === "false") {
oidFalseValueFinal = false;
} else if (oidFalseValueFinal === "true") {
oidFalseValueFinal = true;
}
if (typeof oidFalseValueFinal === "string") {
const f2 = parseFloat(oidFalseValueFinal);
if (f2.toString() === oidFalseValueFinal) {
oidFalseValueFinal = f2;
}
}
this.props.context.setValue(oidFalse, oidFalseValueFinal);
}
}
if (urlTrue) {
if (val) {
this.props.context.socket.getRawSocket().emit("httpGet", urlTrue);
} else {
this.props.context.socket.getRawSocket().emit("httpGet", urlFalse);
}
}
} else if (finalMin === "" && (val === null || val === "" || val === void 0 || val === false || val === "false") || finalMin !== "" && finalMin === val) {
typeof oid === "string" && this.props.context.setValue(oid, finalMax !== "" ? finalMax : true);
} else if (finalMax === "" && (val === true || val === "true") || finalMax !== "" && val === finalMax) {
typeof oid === "string" && this.props.context.setValue(oid, finalMin !== "" ? finalMin : false);
} else if (typeof oid === "string") {
val = parseFloat(val);
if (finalMin !== "" && finalMax !== "" && (typeof finalMax === "number" || typeof finalMax === "string") && (typeof finalMin === "number" || typeof finalMin === "string")) {
if (val >= (parseFloat(finalMax) - parseFloat(finalMin)) / 2) {
val = finalMin;
} else {
val = finalMax;
}
} else if (val >= 0.5) {
val = 0;
} else {
val = 1;
}
this.props.context.setValue(oid, val);
}
}
isFalse(val, min, max) {
if (min !== void 0 && min !== null && min !== "") {
if (val !== void 0 && typeof val !== "string") {
val = val.toString();
}
if (max !== void 0 && max !== null && max !== "") {
return val !== max;
}
return val === min;
}
if (val === void 0 || val === null || val === false || val === "false" || val === "FALSE" || val === "False" || val === "OFF" || val === "Off" || val === "off" || val === "") {
return true;
}
if (val === "0" || val === 0) {
return true;
}
const f2 = parseFloat(val);
if (f2.toString() !== "NaN") {
return !f2;
}
return false;
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
const val = this.state.values[`${this.state.rxData.oid}.val`];
const isOff = this.isFalse(val, this.state.rxData.min, this.state.rxData.max);
let src;
if (isOff) {
src = this.state.rxData.icon_off || "img/bulb_off.png";
} else {
src = this.state.rxData.icon_on || "img/bulb_on.png";
}
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
onClick: () => this.toggle(),
children: jsxRuntimeExports.jsx("img", {
src: src.toString(),
alt: "tplBulbOnOffCtrl",
width: "100%"
})
});
}
}
const PinSvg = (props) => jsxRuntimeExports.jsx("svg", {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 16 24",
style: props.style,
children: jsxRuntimeExports.jsx("path", {
fill: "currentColor",
d: "m7.97,0.026c-4.324,0 -7.82,3.72 -7.82,8.324c0,6.24 7.82,15.46 7.82,15.46s7.82,-9.21 7.82,-15.46c0,-4.6 -3.49,-8.32 -7.82,-8.32zm0,0"
})
});
class BasicRedNumber extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplRedNumber",
visSet: "basic",
visName: "Red Number",
visPrev: "widgets/basic/img/Prev_RedNumber.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "type",
type: "select",
options: [
{
value: "circle",
label: "basic_circle"
},
{
value: "pin",
label: "basic_pin"
}
]
},
{
name: "html_prepend",
type: "html"
},
{
name: "html_append_singular",
type: "html"
},
{
name: "html_append_plural",
type: "html"
},
{
name: "background",
type: "color"
},
{
name: "borderColor",
label: "basic_borderColor",
type: "color",
hidden: 'data.type === "pin"'
},
{
name: "borderRadius",
label: "basic_borderRadius",
type: "slider",
min: 0,
max: 100,
step: 1,
default: 16,
hidden: 'data.type === "pin"'
}
]
}
],
visDefaultStyle: {
width: 52,
height: 30
}
};
}
getWidgetInfo() {
return BasicRedNumber.getWidgetInfo();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
const val = this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected" ? parseFloat(this.state.values[`${this.state.rxData.oid}.val`]) : null;
if (!this.props.editMode && (!val || this.state.values[`${this.state.rxData.oid}.val`] === "false")) {
return null;
}
if (this.state.rxData.type === "pin") {
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
children: [
jsxRuntimeExports.jsx(PinSvg, {
style: {
width: "100%",
height: "100%",
position: "absolute",
top: 0,
left: 0,
zIndex: 0,
color: typeof this.state.rxData.background === "string" ? this.state.rxData.background || "red" : "red"
}
}),
jsxRuntimeExports.jsxs("div", {
style: {
position: "absolute",
top: "22%",
width: "96%",
textAlign: "center",
zIndex: 1
},
children: [
this.state.rxData.html_prepend ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_prepend
}
}) : null,
val === null ? "--" : val,
val === 1 ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append_singular
}
}) : jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append_plural
}
})
]
})
]
});
}
const style2 = {
padding: 3,
borderRadius: this.state.rxData.borderRadius !== void 0 && this.state.rxData.borderRadius !== null ? parseFloat(this.state.rxData.borderRadius) : 16,
borderColor: this.state.rxData.borderColor || "white",
borderWidth: 3,
borderStyle: "solid",
backgroundColor: this.state.rxData.background || "red",
minWidth: 21,
textAlign: "center",
color: props.style.color || "white",
fontSize: props.style.fontSize || 20,
fontFamily: props.style.fontFamily || "Helvetica",
display: "flex",
justifyContent: "center",
alignItems: "center",
boxSizing: "border-box"
};
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
style: style2,
children: [
this.state.rxData.html_prepend ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_prepend
}
}) : null,
val === null ? "--" : val,
val === 1 ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append_singular
}
}) : jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append_plural
}
})
]
});
}
}
class DangerousHtmlWithScript extends React.Component {
componentDidMount() {
const doc = new DOMParser().parseFromString(this.props.html, "text/html");
const scriptElements = doc.getElementsByTagName("script");
let i = 0;
const existingScripts = Array.from(document.querySelectorAll("script[type='text/javascript']"));
for (const scriptElement of Array.from(scriptElements)) {
const id = `${this.props.wid}-${i++}`;
const scriptExists = existingScripts.find((script2) => script2.id === id);
if (scriptExists) {
return;
}
const script = document.createElement("script");
script.id = id;
script.type = "text/javascript";
script.async = true;
script.innerHTML = scriptElement.innerHTML;
document.body.appendChild(script);
}
}
render() {
const { isDiv, html, ...otherProps } = this.props;
if (isDiv) {
return jsxRuntimeExports.jsx("div", {
dangerouslySetInnerHTML: {
__html: html
},
...otherProps
});
}
return jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: html
},
...otherProps
});
}
}
class BasicHtml extends VisRxWidget {
interval = null;
static getWidgetInfo() {
return {
id: "tplHtml",
visSet: "basic",
visName: "HTML",
visPrev: "widgets/basic/img/Prev_HTML.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "html",
type: "html"
},
{
name: "refreshInterval",
type: "slider",
min: 0,
max: 18e4,
step: 100
}
]
}
],
visDefaultStyle: {
width: 200,
height: 130
}
};
}
getWidgetInfo() {
return BasicHtml.getWidgetInfo();
}
componentWillUnmount() {
if (this.interval) {
clearInterval(this.interval);
this.interval = null;
}
super.componentWillUnmount();
}
componentDidMount() {
super.componentDidMount();
if (parseInt(this.state.rxData.refreshInterval, 10)) {
this.interval = setInterval(() => this.forceUpdate(), parseInt(this.state.rxData.refreshInterval, 10));
}
}
onRxDataChanged(prevRxData) {
super.onRxDataChanged(prevRxData);
if (this.interval) {
clearInterval(this.interval);
this.interval = null;
}
if (parseInt(this.state.rxData.refreshInterval, 10)) {
this.interval = setInterval(() => this.forceUpdate(), parseInt(this.state.rxData.refreshInterval, 10));
}
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
return jsxRuntimeExports.jsx(DangerousHtmlWithScript, {
className: "vis-widget-body",
html: (this.state.rxData.html || "").toString(),
isDiv: true,
wid: this.props.id
});
}
}
class BasicValueString extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplValueString",
visSet: "basic",
visName: "String",
visPrev: "widgets/basic/img/Prev_ValueString.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "html_prepend",
type: "html"
},
{
name: "html_append",
type: "html"
},
{
name: "test_html",
type: "html"
},
{
name: "icon",
type: "icon64"
},
{
name: "iconSize",
label: "icon_size_in_pixels",
type: "slider",
min: 5,
max: 200,
hidden: "!data.icon"
}
]
}
],
visWidgetLabel: "value_string",
visDefaultStyle: {
width: 100,
height: 30
}
};
}
getWidgetInfo() {
return BasicValueString.getWidgetInfo();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (props.style.width === void 0) {
props.style.width = 50;
}
if (props.style.height === void 0) {
props.style.height = 20;
}
const oid = this.state.rxData.oid && this.state.rxData.oid.includes('"') ? "" : this.state.rxData.oid || "";
let body;
if (this.props.editMode && this.state.rxData.test_html) {
body = this.state.rxData.test_html;
} else if (this.state.rxData.oid) {
if (this.state.rxData.oid.includes('"')) {
body = this.state.rxData.oid.substring(1, this.state.rxData.oid.length - 1);
} else if (oid) {
body = this.state.values[`${oid}.val`];
} else {
body = "";
}
} else {
body = "";
}
const style2 = this.state.rxData.icon ? {
display: "flex",
alignItems: "center"
} : {};
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsxs("div", {
"data-oid": oid,
style: style2,
children: [
this.state.rxData.icon ? jsxRuntimeExports.jsx(__mf_15$1, {
src: this.state.rxData.icon,
style: {
width: this.state.rxData.iconSize || 24,
height: this.state.rxData.iconSize || 24
}
}) : null,
jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_prepend ?? ""
}
}),
jsxRuntimeExports.jsx("span", {
children: body
}),
jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append ?? ""
}
})
]
})
});
}
}
class BasicValueInput extends VisRxWidget {
setTimer = null;
static getWidgetInfo() {
return {
id: "tplValueInput",
visSet: "basic",
visName: "Input val",
visWidgetLabel: "vis-2-widgets-basic-input_value",
visPrev: "widgets/basic/img/Prev_ValueInput.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "html_prepend",
type: "html"
},
{
name: "html_append",
type: "html"
},
{
name: "numeric",
type: "checkbox"
},
{
name: "min",
type: "number",
hidden: "!data.numeric"
},
{
name: "max",
type: "number",
hidden: "!data.numeric"
},
{
name: "autoSet",
type: "checkbox"
},
{
name: "autoSetDelay",
label: "vis-2-widgets-basic-autoSetDelay",
type: "number",
hidden: "!data.autoSet",
default: 1e3
},
{
name: "readOnly",
type: "checkbox"
},
{
name: "autoFocus",
type: "checkbox"
},
{
name: "noStyle",
type: "checkbox",
label: "vis-2-widgets-basic-noStyle"
},
{
name: "withEnter",
type: "checkbox",
hidden: "!!data.noStyle"
},
{
name: "variant",
type: "select",
hidden: "!!data.noStyle",
noTranslation: true,
options: [
{
value: "standard",
label: "standard"
},
{
value: "outlined",
label: "outlined"
},
{
value: "standard",
label: "standard"
}
],
default: "standard"
}
]
}
],
visDefaultStyle: {
width: 150,
height: 70
}
};
}
componentDidMount() {
super.componentDidMount();
const oid = this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected" && this.state.rxData.oid.includes('"') ? "" : this.state.rxData.oid || "";
let value;
if (this.state.rxData.oid) {
if (this.state.rxData.oid.includes('"')) {
value = this.state.rxData.oid.substring(1, this.state.rxData.oid.length - 1);
} else if (oid) {
value = this.state.values[`${oid}.val`] !== null && this.state.values[`${oid}.val`] !== void 0 ? this.state.values[`${oid}.val`].toString() : "";
} else {
value = "";
}
} else {
value = "";
}
this.setState({
value,
sentValue: true
});
}
onStateUpdated(id, state) {
if (id === this.state.rxData.oid && state && state.val !== null && state.val !== void 0) {
const valStr = state.val.toString();
if (this.state.value.toString() !== valStr) {
this.setState({
value: valStr
});
}
}
}
getWidgetInfo() {
return BasicValueInput.getWidgetInfo();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (props.style.width === void 0) {
props.style.width = 100;
}
if (props.style.height === void 0) {
props.style.height = 25;
}
const oid = this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected" && this.state.rxData.oid.includes('"') ? "" : this.state.rxData.oid || "";
let value;
if (this.state.rxData.oid) {
if (this.state.rxData.oid.includes('"')) {
value = this.state.rxData.oid.substring(1, this.state.rxData.oid.length - 1);
} else if (oid) {
value = this.state.value;
if (value === void 0 || value === null) {
value = "";
}
} else {
value = "";
}
} else {
value = "";
}
let content;
if (this.state.rxData.noStyle) {
content = jsxRuntimeExports.jsx("input", {
type: this.state.rxData.numeric ? "number" : "text",
style: {
flexGrow: 1,
height: "calc(100% - 6px)",
backgroundColor: this.props.context.themeType === "dark" ? "#333" : "#fff",
color: this.props.context.themeType === "dark" ? "#FFF" : "#000"
},
readOnly: this.state.rxData.readOnly || this.props.editMode,
autoFocus: this.state.rxData.autoFocus,
value,
onChange: (e2) => this.setState({
value: e2.target.value,
sentValue: false
}, () => {
if (this.state.rxData.autoSet) {
this.setTimer && clearTimeout(this.setTimer);
this.setTimer = setTimeout(() => {
this.setTimer = null;
this.setState({
sentValue: true
}, () => this.props.context.setValue(oid, this.state.value));
}, this.state.rxData.autoSetDelay || 1e3);
}
}),
onKeyDown: (e2) => {
if (e2.key === "Enter" && oid) {
this.setState({
sentValue: true
}, () => this.props.context.setValue(oid, this.state.value));
}
}
});
} else {
content = jsxRuntimeExports.jsx(__mf_121, {
type: this.state.rxData.numeric ? "number" : "text",
style: {
flexGrow: 1,
height: "100%"
},
sx: {
"& .MuiInputBase-root": {
height: "100%"
}
},
variant: this.state.rxData.variant,
slotProps: {
inputLabel: {
shrink: true
},
input: {
readOnly: this.state.rxData.readOnly || this.props.editMode,
endAdornment: !this.props.editMode && this.state.rxData.withEnter && oid && !this.state.sentValue ? jsxRuntimeExports.jsx(__mf_53, {
size: "small",
onClick: () => this.setState({
sentValue: true
}, () => this.props.context.setValue(oid, this.state.value)),
children: jsxRuntimeExports.jsx(__mf_4885, {})
}) : null
}
},
label: this.state.rxData.html_prepend,
helperText: this.state.rxData.html_append,
value,
onChange: (e2) => {
this.setState({
value: e2.target.value,
sentValue: false
}, () => {
if (this.state.rxData.autoSet && oid) {
this.setTimer && clearTimeout(this.setTimer);
this.setTimer = setTimeout(() => {
this.setTimer = null;
this.setState({
sentValue: true
}, () => this.props.context.setValue(oid, this.state.value));
}, this.state.rxData.autoSetDelay || 1e3);
}
});
},
onKeyDown: (e2) => {
if (e2.key === "Enter" && oid) {
this.setState({
sentValue: true
}, () => this.props.context.setValue(oid, this.state.value));
}
}
});
}
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
style: {
display: "flex",
alignItems: "center",
gap: 3
},
children: [
this.state.rxData.noStyle ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_prepend ?? ""
}
}) : null,
content,
this.state.rxData.noStyle ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append ?? ""
}
}) : null
]
});
}
}
var DefaultContext = {
color: void 0,
size: void 0,
className: void 0,
style: void 0,
attr: void 0
};
var IconContext = React.createContext && React.createContext(DefaultContext);
var _excluded$G = [
"attr",
"size",
"title"
];
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
}
return target;
}
function _extends() {
_extends = Object.assign ? Object.assign.bind() : 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 target;
};
return _extends.apply(this, arguments);
}
function ownKeys(e2, r2) {
var t = Object.keys(e2);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e2);
r2 && (o = o.filter(function(r3) {
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread(e2) {
for (var r2 = 1; r2 < arguments.length; r2++) {
var t = null != arguments[r2] ? arguments[r2] : {};
r2 % 2 ? ownKeys(Object(t), true).forEach(function(r3) {
_defineProperty(e2, r3, t[r3]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r3) {
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t, r3));
});
}
return e2;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _toPrimitive(t, r2) {
if ("object" != typeof t || !t) return t;
var e2 = t[Symbol.toPrimitive];
if (void 0 !== e2) {
var i = e2.call(t, r2);
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r2 ? String : Number)(t);
}
function Tree2Element(tree) {
return tree && tree.map((node, i) => React.createElement(node.tag, _objectSpread({
key: i
}, node.attr), Tree2Element(node.child)));
}
GenIcon = function(data) {
return (props) => React.createElement(IconBase, _extends({
attr: _objectSpread({}, data.attr)
}, props), Tree2Element(data.child));
};
function IconBase(props) {
var elem = (conf) => {
var { attr, size, title } = props, svgProps = _objectWithoutProperties(props, _excluded$G);
var computedSize = size || conf.size || "1em";
var className;
if (conf.className) className = conf.className;
if (props.className) className = (className ? className + " " : "") + props.className;
return React.createElement("svg", _extends({
stroke: "currentColor",
fill: "currentColor",
strokeWidth: "0"
}, conf.attr, attr, svgProps, {
className,
style: _objectSpread(_objectSpread({
color: props.color || conf.color
}, conf.style), props.style),
height: computedSize,
width: computedSize,
xmlns: "http://www.w3.org/2000/svg"
}), title && React.createElement("title", null, title), props.children);
};
return IconContext !== void 0 ? React.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
}
FaFolderOpen = function(props) {
return GenIcon({
"attr": {
"viewBox": "0 0 576 512"
},
"child": [
{
"tag": "path",
"attr": {
"d": "M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"
},
"child": []
}
]
})(props);
};
FaFolder = function(props) {
return GenIcon({
"attr": {
"viewBox": "0 0 512 512"
},
"child": [
{
"tag": "path",
"attr": {
"d": "M464 128H272l-64-64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48z"
},
"child": []
}
]
})(props);
};
class BasicViewInWidget extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplContainerView",
visSet: "basic",
visName: "View in widget",
visAttrs: [
{
name: "common",
fields: [
{
name: "contains_view",
label: "vis_2_widgets_basic_contains_view",
type: "views"
}
]
}
],
visPrev: "widgets/basic/img/Prev_ContainerView.png",
visWidgetLabel: "vis_2_widgets_basic_view_in_widget",
visSetLabel: "set_basic",
visDefaultStyle: {
width: 300,
height: 200
}
};
}
getWidgetInfo() {
return BasicViewInWidget.getWidgetInfo();
}
getViewOptions(project, options, parentId = null, level = 0) {
project.___settings.folders.filter((folder) => (folder.parentId || null) === parentId).forEach((folder) => {
options.push({
type: "folder",
folder,
level: level + 1
});
this.getViewOptions(project, options, folder.id, level + 1);
});
const keys = Object.keys(project).filter((view) => (project[view].parentId || null) === parentId && !view.startsWith("__"));
keys.forEach((view) => {
options.push({
type: "view",
view,
level: level + 1
});
});
return options;
}
renderViewSelector() {
const options = this.getViewOptions(this.props.context.views, [], null, 0).filter((option) => option.type === "folder" || option.view !== this.props.view);
return [
jsxRuntimeExports.jsx(__mf_53, {
style: this.props.context.editModeComponentStyle,
onMouseDown: (e2) => {
e2.stopPropagation();
e2.preventDefault();
this.props.onIgnoreMouseEvents(true);
this.setState({
showViewSelector: true
});
},
children: jsxRuntimeExports.jsx(EditIcon, {})
}, "button"),
this.state.showViewSelector ? jsxRuntimeExports.jsxs(__mf_32$1, {
open: true,
onClose: () => this.setState({
showViewSelector: false
}, () => this.props.onIgnoreMouseEvents(false)),
children: [
jsxRuntimeExports.jsx(__mf_36, {
children: __mf_2$1.t("vis_2_widgets_basic_contains_view")
}),
jsxRuntimeExports.jsx(__mf_34, {
children: options.map((option, key) => option.type === "view" ? jsxRuntimeExports.jsxs(__mf_72, {
value: option.view,
onClick: () => this.setState({
showViewSelector: false
}, () => {
this.props.onIgnoreMouseEvents(false);
this.props.context.onWidgetsChanged([
{
wid: this.props.id,
view: this.props.view,
data: {
contains_view: option.view
}
}
]);
}),
style: {
paddingLeft: option.level * 16,
lineHeight: "36px"
},
children: [
jsxRuntimeExports.jsx(FileIcon, {
style: {
verticalAlign: "middle",
marginRight: 4
}
}),
jsxRuntimeExports.jsx(__mf_69, {
primary: option.view,
style: {
verticalAlign: "middle"
}
})
]
}, key.toString()) : jsxRuntimeExports.jsxs(__mf_70$1, {
style: {
paddingLeft: option.level * 16,
lineHeight: "36px",
backgroundColor: "inherit"
},
children: [
jsxRuntimeExports.jsx(FaFolderOpen, {
style: {
verticalAlign: "middle",
marginRight: 6,
marginTop: -3,
fontSize: 20,
color: "#00dc00"
}
}),
jsxRuntimeExports.jsx("span", {
style: {
fontSize: "1rem"
},
children: option.folder.name
})
]
}, key))
})
]
}, "dialog") : null
];
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (props.style.width === void 0) {
props.style.width = 400;
}
if (props.style.height === void 0) {
props.style.height = 270;
}
const view = this.state.rxData.contains_view;
if (view === this.props.view) {
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
style: {
overflow: "hidden",
position: "absolute"
},
children: __mf_2$1.t("vis_2_widgets_basic_cannot_recursive")
});
}
if (!view) {
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
style: {
overflow: "hidden",
position: "absolute"
},
children: [
__mf_2$1.t("vis_2_widgets_basic_view_not_defined"),
this.props.editMode ? this.renderViewSelector() : null
]
});
}
const style2 = {
position: "absolute"
};
if (this.state.rxStyle["overflow-x"] && this.state.rxStyle["overflow-y"]) {
delete props.style.overflow;
if (this.state.rxStyle["overflow-y"] === this.state.rxStyle["overflow-x"]) {
style2.overflow = this.state.rxStyle["overflow-x"];
} else {
style2.overflowX = this.state.rxStyle["overflow-x"];
style2.overflowY = this.state.rxStyle["overflow-y"];
}
} else if (this.state.rxStyle["overflow-x"]) {
style2.overflowX = this.state.rxStyle["overflow-x"];
delete props.style.overflow;
} else if (this.state.rxStyle["overflow-y"]) {
style2.overflowY = this.state.rxStyle["overflow-y"];
delete props.style.overflow;
} else if (this.state.rxStyle.overflow) {
style2.overflow = this.state.rxStyle.overflow;
} else {
style2.overflow = "hidden";
}
delete props.style.overflow;
delete props.style.overflowX;
delete props.style.overflowY;
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
style: style2,
children: [
this.state.editMode ? jsxRuntimeExports.jsx("div", {
className: "vis-editmode-helper"
}) : null,
super.getWidgetView(view, void 0)
]
});
}
}
class BasicViewInWidget8 extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplStatefulContainerView8",
visSet: "basic",
visName: "View in widget 8",
visAttrs: "oid;count[1]/number;group.views;contains_view_(0-count)/views",
visPrev: "widgets/basic/img/Prev_StatefulContainerView8.png"
};
}
getWidgetInfo() {
return BasicViewInWidget8.getWidgetInfo();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (props.style.width === void 0) {
props.style.width = 400;
}
if (props.style.height === void 0) {
props.style.height = 270;
}
const viewArr = [];
let i = 1;
while (this.state.rxData[`contains_view_${i}`] !== void 0) {
viewArr.push(this.state.rxData[`contains_view_${i}`]);
i++;
}
const oid = this.state.rxData.oid;
let val = this.state.values[`${oid}.val`];
let view;
if (oid !== "nothing_selected" && val !== void 0) {
if (val === "true" || val === true) {
val = 1;
}
if (val === "false" || val === false) {
val = 0;
}
view = viewArr[val];
} else {
view = viewArr[0];
}
if (view === this.props.view) {
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
style: {
overflow: "hidden",
position: "absolute"
},
children: __mf_2$1.t("vis_2_widgets_basic_cannot_recursive")
});
}
const style2 = {
position: "absolute"
};
if (this.state.rxStyle["overflow-x"] && this.state.rxStyle["overflow-y"]) {
delete props.style.overflow;
if (this.state.rxStyle["overflow-y"] === this.state.rxStyle["overflow-x"]) {
style2.overflow = this.state.rxStyle["overflow-x"];
} else {
style2.overflowX = this.state.rxStyle["overflow-x"];
style2.overflowY = this.state.rxStyle["overflow-y"];
}
} else if (this.state.rxStyle["overflow-x"]) {
style2.overflowX = this.state.rxStyle["overflow-x"];
delete props.style.overflow;
} else if (this.state.rxStyle["overflow-y"]) {
style2.overflowY = this.state.rxStyle["overflow-y"];
delete props.style.overflow;
} else if (this.state.rxStyle.overflow) {
style2.overflow = this.state.rxStyle.overflow;
} else {
style2.overflow = "hidden";
}
delete props.style.overflow;
delete props.style.overflowX;
delete props.style.overflowY;
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
style: style2,
children: [
this.state.editMode ? jsxRuntimeExports.jsx("div", {
className: "vis-editmode-helper"
}) : null,
super.getWidgetView(view, void 0)
]
});
}
}
createTheme = function(themeName, overrides) {
const danger = "#dd5325";
const success = "#73b6a8";
const theme = __mf_0(themeName, overrides);
theme.palette.text.danger = {
color: danger
};
theme.palette.text.success = {
color: success
};
const classes = {
blockHeader: {
fontSize: 16,
textAlign: "left",
marginTop: "8px",
borderRadius: "2px",
paddingLeft: "8px"
},
viewTabs: {
minHeight: 0
},
viewTab: {
minWidth: 0,
minHeight: 0
},
lightedPanel: {
backgroundColor: themeName === "dark" || themeName === "blue" || themeName === "NW" ? "hsl(0deg 0% 20%)" : "hsl(0deg 0% 90%)"
},
toolbar: {
display: "flex",
alignItems: "center",
paddingTop: "10px",
paddingBottom: "10px"
},
viewManageBlock: {
display: "flex",
alignItems: "center"
},
viewManageButtonActions: {
textAlign: "right",
flex: 1
}
};
if (!theme.classes) {
theme.classes = classes;
} else {
Object.assign(theme.classes, classes);
}
return theme;
};
function analyzeDraggableResizable(el, result, widgetStyle) {
result = result || {};
result.resizable = true;
result.draggable = true;
if (el == null ? void 0 : el.dataset) {
const resizableOptionsStr = el.dataset.visResizable;
if (resizableOptionsStr) {
let resizableOptions = null;
try {
resizableOptions = JSON.parse(resizableOptionsStr);
} catch {
console.error(`Cannot parse resizable options by ${el.getAttribute("id")}: ${JSON.stringify(resizableOptions)}`);
}
if (resizableOptions) {
if (resizableOptions.disabled !== void 0) {
result.resizable = !resizableOptions.disabled;
}
if (resizableOptions.handles !== void 0) {
result.resizeHandles = resizableOptions.handles.split(",").map((h2) => h2.trim());
}
}
if (widgetStyle && !result.resizable && (!widgetStyle.width || !widgetStyle.height)) {
result.virtualHeight = el.clientHeight;
result.virtualWidth = el.clientWidth;
}
}
const draggableOptionsStr = el.dataset.visDraggable;
if (draggableOptionsStr) {
let draggableOptions = null;
try {
draggableOptions = JSON.parse(draggableOptionsStr);
} catch {
console.error(`Cannot parse draggable options by ${el.getAttribute("id")}: ${JSON.stringify(draggableOptions)}`);
}
if (draggableOptions) {
if (draggableOptions.disabled !== void 0) {
result.draggable = !draggableOptions.disabled;
}
}
}
result.hideHelper = el.dataset.visHideHelper === "true";
}
return result;
}
class VisCanWidget extends VisBaseWidget {
refViews = {};
isCanWidget = true;
bindings;
IDs;
bindingsTimer = null;
filterDisplay;
lastState;
oldEditMode;
oldData;
oldStyle;
updateOnStyle;
constructor(props) {
super(props);
Object.assign(this.state, {
mounted: false,
legacyViewContainers: [],
hideHelper: false,
resizable: true,
draggable: true
});
this.setupSubscriptions();
props.context.linkContext.registerChangeHandler(props.id, this.changeHandler);
props.context.buildLegacyStructures();
}
setupSubscriptions() {
this.bindings = {};
const linkContext = {
IDs: [],
bindings: this.bindings,
visibility: this.props.context.linkContext.visibility,
lastChanges: this.props.context.linkContext.lastChanges,
signals: this.props.context.linkContext.signals
};
getUsedObjectIDsInWidget(this.props.context.views, this.props.view, this.props.id, linkContext);
this.IDs = linkContext.IDs;
Object.keys(this.bindings).forEach((id) => {
this.props.context.linkContext.bindings[id] = this.props.context.linkContext.bindings[id] || [];
this.bindings[id].forEach((item) => this.props.context.linkContext.bindings[id].push(item));
});
Object.keys(linkContext).forEach((attr) => linkContext[attr] = null);
}
componentDidMount() {
super.componentDidMount();
this.props.context.linkContext.subscribe(this.IDs);
if (!this.widDiv) {
this.renderWidget(void 0, void 0, void 0, void 0, () => {
const newState = {
mounted: true
};
if (this.props.context.allWidgets[this.props.id]) {
analyzeDraggableResizable(this.widDiv, newState, this.props.context.allWidgets[this.props.id].style);
}
this.setState(newState);
});
}
}
componentWillUnmount() {
super.componentWillUnmount();
if (this.props.context.linkContext) {
if (this.props.context.linkContext && this.props.context.linkContext.unregisterChangeHandler) {
this.props.context.linkContext.unregisterChangeHandler(this.props.id, this.changeHandler);
}
}
this.bindings = {};
if (this.props.context.linkContext) {
if (this.props.context.linkContext.unsubscribe) {
this.props.context.linkContext.unsubscribe(this.IDs);
}
VisBaseWidget.removeFromArray(this.props.context.linkContext.visibility, this.IDs, this.props.view, this.props.id);
VisBaseWidget.removeFromArray(this.props.context.linkContext.lastChanges, this.IDs, this.props.view, this.props.id);
VisBaseWidget.removeFromArray(this.props.context.linkContext.signals, this.IDs, this.props.view, this.props.id);
VisBaseWidget.removeFromArray(this.props.context.linkContext.bindings, this.IDs, this.props.view, this.props.id);
}
this.destroy();
}
static applyStyle(el, style2, isSelected, editMode) {
if (typeof style2 === "string") {
const styleFromString = VisBaseWidget.parseStyle(style2);
Object.keys(styleFromString).forEach((attr) => {
if (!attr.startsWith("_")) {
let value = styleFromString[attr];
if (attr === "top" || attr === "left" || attr === "width" || attr === "height") {
if (value !== "0" && value !== 0 && value !== null && value !== "" && value.toString().match(/^[+-]?([0-9]*[.])?[0-9]+$/)) {
value = `${value}px`;
}
}
if (attr.includes("-")) {
console.log(`${attr} to ${value}`);
attr = attr.replace(/-([a-z])/g, (g2) => g2[1].toUpperCase());
}
if (value) {
el.style[attr] = value;
} else if (el.style[attr]) {
el.style[attr] = "";
}
}
});
} else if (style2) {
const styleObj = style2;
Object.keys(styleObj).forEach((attr) => {
let value = styleObj[attr];
if (attr && value !== void 0 && value !== null && !attr.startsWith("_")) {
if (attr === "top" || attr === "left" || attr === "width" || attr === "height") {
if (value !== "0" && value !== 0 && value !== null && value !== "" && value.toString().match(/^[+-]?([0-9]*[.])?[0-9]+$/)) {
value = `${value}px`;
}
}
if (attr.includes("-")) {
attr = attr.replace(/-([a-z])/g, (g2) => g2[1].toUpperCase());
}
if (value) {
el.style[attr] = value;
} else if (el.style[attr]) {
el.style[attr] = "";
}
}
});
if (editMode) {
if (isSelected) {
el.style.zIndex = (500 + (parseInt(styleObj["z-index"], 10) || 0)).toString();
}
const zIndex = parseInt(el.style.zIndex, 10) || 0;
const overlay = el.parentNode.querySelector(`#rx_${el.id}`);
if (overlay) {
overlay.style.zIndex = (zIndex + 1).toString();
}
el.style.userSelect = "none";
el.style.pointerEvents = "none";
}
if (el.style.position === "absolute") {
if (!el.style.top) {
el.style.top = "0px";
}
if (!el.style.left) {
el.style.left = "0px";
}
}
}
}
onCommand(command, options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
const result = super.onCommand(command, options);
if (result === false) {
if (command === "updatePosition") {
if (this.refService.current && this.widDiv) {
this.refService.current.style.width = `${this.widDiv.offsetWidth}px`;
this.refService.current.style.height = `${this.widDiv.offsetHeight}px`;
this.refService.current.style.left = `${this.widDiv.offsetLeft}px`;
this.refService.current.style.top = `${this.widDiv.offsetTop}px`;
}
} else if (command === "updateContainers") {
const containers = this.widDiv.querySelectorAll(".vis-view-container");
if (containers.length) {
const legacyViewContainers = [];
for (let v2 = 0; v2 < containers.length; v2++) {
const view = (containers[v2].dataset.visContains || "").trim();
if (view && view !== "undefined" && view !== "null") {
legacyViewContainers.push(view);
containers[v2].className = addClass$1(containers[v2].className, "vis-editmode-helper");
}
}
legacyViewContainers.sort();
if (JSON.stringify(legacyViewContainers) !== JSON.stringify(this.state.legacyViewContainers)) {
this.setState({
legacyViewContainers
});
}
}
} else if (command === "changeFilter") {
if (!this.widDiv) {
return null;
}
if (!((_a = options == null ? void 0 : options.filter) == null ? void 0 : _a.length)) {
if (this.filterDisplay !== void 0) {
this.widDiv.style.display = this.filterDisplay;
if ((_b = this.widDiv._customHandlers) == null ? void 0 : _b.onShow) {
this.widDiv._customHandlers.onShow(this.widDiv, this.props.id);
}
}
} else if (options.filter[0] === "$") {
if ((_d = (_c = this.props.context.allWidgets[this.props.id]) == null ? void 0 : _c.data) == null ? void 0 : _d.filterkey) {
if (this.widDiv.style.display !== "none") {
this.filterDisplay = this.widDiv.style.display;
this.widDiv.style.display = "none";
if ((_e = this.widDiv._customHandlers) == null ? void 0 : _e.onHide) {
this.widDiv._customHandlers.onHide(this.widDiv, this.props.id);
}
}
}
} else {
const wFilters = (_f = this.props.context.allWidgets[this.props.id]) == null ? void 0 : _f.data.filterkey;
if (wFilters) {
let found = false;
for (let w2 = 0; w2 < wFilters.length; w2++) {
if (options.filter.includes(wFilters[w2])) {
found = true;
break;
}
}
if (!found) {
if (this.widDiv.style.display !== "none") {
this.filterDisplay = this.widDiv.style.display;
this.widDiv.style.display = "none";
if ((_g = this.widDiv._customHandlers) == null ? void 0 : _g.onHide) {
(_h = this.widDiv._customHandlers) == null ? void 0 : _h.onHide(this.widDiv, this.props.id);
}
}
} else if (this.filterDisplay !== void 0 && this.widDiv.style.display === "none") {
this.widDiv.style.display = this.filterDisplay;
if ((_i = this.widDiv._customHandlers) == null ? void 0 : _i.onShow) {
(_j = this.widDiv._customHandlers) == null ? void 0 : _j.onShow(this.widDiv, this.props.id);
}
}
}
}
} else if (command === "collectFilters") {
return (_l = (_k = this.props.context.allWidgets[this.props.id]) == null ? void 0 : _k.data) == null ? void 0 : _l.filterkey;
}
}
return result;
}
destroy(update2) {
if (this.props.context.allWidgets[this.props.id]) {
delete this.props.context.allWidgets[this.props.id];
}
if (this.widDiv && (!update2 || !this.props.id.startsWith("g"))) {
const $wid = this.props.context.jQuery(this.widDiv);
const destroy = $wid.data("destroy");
if (typeof destroy === "function") {
destroy(this.props.id, $wid);
$wid.data("destroy", null);
}
this.widDiv.remove();
this.widDiv = null;
}
}
changeHandler = (type, item, stateId) => {
if (this.widDiv) {
if (type === "style") {
if (this.props.context.allWidgets[this.props.id]) {
VisCanWidget.applyStyle(this.widDiv, this.props.context.allWidgets[this.props.id].style, this.state.selected, this.state.editMode);
}
} else if (type === "signal") {
this.updateSignal(item);
} else if (type === "visibility") {
this.updateVisibility();
} else if (type === "lastChange") {
this.updateLastChange();
} else if (type === "binding") {
this.applyBinding(stateId);
}
}
};
updateSignal(item) {
if (this.widDiv) {
const signalDiv = this.widDiv.querySelector(`.vis-signal[data-index="${item.index}"]`);
if (signalDiv) {
if (this.isSignalVisible(item.index)) {
signalDiv.style.display = "";
} else {
signalDiv.style.display = "none";
}
}
}
}
updateLastChange() {
var _a;
if (this.widDiv) {
const widgetData = (_a = this.props.context.allWidgets[this.props.id]) == null ? void 0 : _a.data;
if (widgetData) {
const lcDiv = this.widDiv.querySelector(".vis-last-change");
if (lcDiv) {
lcDiv.innerHTML = window.vis.binds.basic.formatDate(this.props.context.canStates.attr(`${widgetData["lc-oid"]}.${widgetData["lc-type"] === "last-change" ? "lc" : "ts"}`), widgetData["lc-format"], widgetData["lc-is-interval"], widgetData["lc-is-moment"]);
} else {
console.warn(`[${this.props.id}] Last change not found!`);
}
}
}
}
updateVisibility() {
var _a;
if (this.widDiv && !this.state.editMode) {
const widgetData = (_a = this.props.context.allWidgets[this.props.id]) == null ? void 0 : _a.data;
if (widgetData) {
if (VisBaseWidget.isWidgetHidden(widgetData, this.props.context.canStates, this.props.id) || this.isWidgetFilteredOut(widgetData)) {
this.widDiv._storedDisplay = this.widDiv.style.display;
this.widDiv.style.display = "none";
if (this.widDiv && this.widDiv._customHandlers && this.widDiv._customHandlers.onHide) {
this.widDiv._customHandlers.onHide(this.widDiv, this.props.id);
}
} else {
this.widDiv.style.display = this.widDiv._storedDisplay || "";
this.widDiv._storedDisplay = "";
if (this.widDiv && this.widDiv._customHandlers && this.widDiv._customHandlers.onShow) {
this.widDiv._customHandlers.onShow(this.widDiv, this.props.id);
}
}
}
}
}
isSignalVisible(index, widgetData) {
widgetData = widgetData || this.props.context.allWidgets[this.props.id].data;
if (!widgetData) {
return false;
}
if (this.state.editMode) {
return !widgetData[`signals-hide-edit-${index}`];
}
const oid = widgetData[`signals-oid-${index}`];
if (oid) {
const val = this.props.context.canStates.attr(`${oid}.val`);
const condition = widgetData[`signals-cond-${index}`];
let value = widgetData[`signals-val-${index}`];
if (val === void 0 || val === null) {
return condition === "not exist";
}
if (!condition || value === void 0 || value === null) {
return condition === "not exist";
}
if (val === "null" && condition !== "exist" && condition !== "not exist") {
return false;
}
let valNotNull = val;
const t = typeof valNotNull;
if (t === "boolean" || val === "false" || val === "true") {
value = value === "true" || value === true || value === 1 || value === "1";
} else if (t === "number") {
value = parseFloat(value);
} else if (t === "object") {
valNotNull = JSON.stringify(valNotNull);
}
switch (condition) {
case "==":
value = value.toString();
valNotNull = valNotNull.toString();
if (valNotNull === "1") {
valNotNull = "true";
}
if (value === "1") {
value = "true";
}
if (valNotNull === "0") {
valNotNull = "false";
}
if (value === "0") {
value = "false";
}
return value === valNotNull;
case "!=":
value = value.toString();
valNotNull = valNotNull.toString();
if (valNotNull === "1") {
valNotNull = "true";
}
if (value === "1") {
value = "true";
}
if (valNotNull === "0") {
valNotNull = "false";
}
if (value === "0") {
value = "false";
}
return value !== valNotNull;
case ">=":
return valNotNull >= value;
case "<=":
return valNotNull <= value;
case ">":
return valNotNull > value;
case "<":
return valNotNull < value;
case "consist":
value = value.toString();
valNotNull = valNotNull.toString();
return valNotNull.toString().includes(value);
case "not consist":
value = value.toString();
valNotNull = valNotNull.toString();
return !valNotNull.toString().includes(value);
case "exist":
return value !== "null";
case "not exist":
return value === "null";
default:
console.log(`[${this.props.id}] Unknown signals condition: ${condition}`);
return false;
}
} else {
return false;
}
}
addSignalIcon(widgetData, index) {
var _a;
widgetData || (widgetData = (_a = this.props.context.allWidgets[this.props.id]) == null ? void 0 : _a.data);
if (!widgetData) {
return;
}
const divSignal = window.document.createElement("div");
divSignal.className = `vis-signal ${widgetData[`signals-blink-${index}`] ? "vis-signals-blink" : ""} ${widgetData[`signals-text-class-${index}`] || ""}`;
divSignal.dataset.index = index.toString();
divSignal.style.display = this.isSignalVisible(index) ? "" : "none";
divSignal.style.pointerEvents = "none";
divSignal.style.position = "absolute";
divSignal.style.zIndex = "10";
divSignal.style.top = `${widgetData[`signals-vert-${index}`] || 0}%`;
divSignal.style.left = `${widgetData[`signals-horz-${index}`] || 0}%`;
const divIcon = window.document.createElement("img");
divIcon.className = "vis-signal-icon";
let src = widgetData[`signals-icon-${index}`];
if (src) {
if (src.startsWith("/vis/")) {
src = src.substring(5);
} else if (src.startsWith("/vis-2/")) {
src = src.substring(5);
} else if (src.startsWith("/vis-2-beta/")) {
src = src.substring(12);
}
}
divIcon.src = src;
divIcon.style.width = `${widgetData[`signals-icon-size-${index}`] || 32}px`;
divIcon.style.height = "auto";
VisCanWidget.applyStyle(divIcon, widgetData[`signals-icon-style-${index}`]);
divSignal.appendChild(divIcon);
const text = widgetData[`signals-text-${index}`];
if (text) {
const divText = window.document.createElement("div");
const val = this.props.context.canStates.attr(`${widgetData[`signals-oid-${index}`]}.val`);
divText.className = "vis-signal-text";
VisCanWidget.applyStyle(divText, widgetData[`signals-text-style-${index}`]);
divText.innerHTML = text.replace("%s", (val ?? "").toString());
divSignal.appendChild(divText);
}
this.widDiv.appendChild(divSignal);
}
addLastChange(widgetData) {
const border = `${parseInt(widgetData["lc-border-radius"], 10) || 0}px`;
const css = {
background: "rgba(182,182,182,0.6)",
fontFamily: "Tahoma",
position: "absolute",
zIndex: 0,
borderRadius: widgetData["lc-position-horz"] === "left" ? `${border} 0 0 ${border}` : widgetData["lc-position-horz"] === "right" ? `0 ${border} ${border} 0` : border,
whiteSpace: "nowrap"
};
if (widgetData["lc-font-size"]) {
css.fontSize = widgetData["lc-font-size"];
}
if (widgetData["lc-font-style"]) {
css.fontStyle = widgetData["lc-font-style"];
}
if (widgetData["lc-font-family"]) {
css.fontFamily = widgetData["lc-font-family"];
}
if (widgetData["lc-bkg-color"]) {
css.background = widgetData["lc-bkg-color"];
}
if (widgetData["lc-color"]) {
css.color = widgetData["lc-color"];
}
if (widgetData["lc-border-width"]) {
css.borderWidth = parseInt(widgetData["lc-border-width"], 10) || 0;
}
if (widgetData["lc-border-style"]) {
css.borderStyle = widgetData["lc-border-style"];
}
if (widgetData["lc-border-color"]) {
css.borderColor = widgetData["lc-border-color"];
}
if (widgetData["lc-padding"]) {
css.padding = widgetData["lc-padding"];
} else {
css.paddingTop = 3;
css.paddingBottom = 3;
}
if (widgetData["lc-zindex"]) {
css.zIndex = widgetData["lc-zindex"];
}
if (widgetData["lc-position-vert"] === "top") {
css.top = `${parseInt(widgetData["lc-offset-vert"], 10)}px`;
} else if (widgetData["lc-position-vert"] === "bottom") {
css.bottom = `${parseInt(widgetData["lc-offset-vert"], 10)}px`;
} else if (widgetData["lc-position-vert"] === "middle") {
css.top = `calc(50% + ${parseInt(widgetData["lc-offset-vert"], 10) - 10}px)`;
}
const offset2 = parseFloat(widgetData["lc-offset-horz"]) || 0;
if (widgetData["lc-position-horz"] === "left") {
css.right = `calc(100% - ${offset2}px)`;
if (!widgetData["lc-padding"]) {
css.paddingRight = 10;
css.paddingLeft = 10;
}
} else if (widgetData["lc-position-horz"] === "right") {
css.left = `calc(100% + ${offset2}px)`;
if (!widgetData["lc-padding"]) {
css.paddingRight = 10;
css.paddingLeft = 10;
}
} else if (widgetData["lc-position-horz"] === "middle") {
css.left = `calc(50% + ${offset2}px)`;
}
const divLastChange = window.document.createElement("div");
divLastChange.className = "vis-last-change";
divLastChange.innerHTML = this.formatDate(this.props.context.canStates.attr(`${widgetData["lc-oid"]}.${widgetData["lc-type"] === "last-change" ? "lc" : "ts"}`), widgetData["lc-format"], widgetData["lc-is-interval"], widgetData["lc-is-moment"]);
Object.keys(css).forEach((attr) => divLastChange.style[attr] = css[attr]);
this.widDiv.prepend(divLastChange);
calculateOverflow(this.widDiv.style);
}
addChart(widgetData) {
this.widDiv.onclick = () => {
console.log(`[${this.props.id}] Show dialog with chart for ${widgetData["echart-oid"]}`);
};
}
applyBindings(doNotApplyStyles, widgetData, widgetStyle) {
Object.keys(this.bindings).forEach((id) => this.applyBinding(id, doNotApplyStyles, widgetData, widgetStyle));
}
applyBinding(stateId, doNotApplyStyles, widgetData, widgetStyle) {
const widgetContext = this.props.context.allWidgets[this.props.id];
if (!widgetContext && (!widgetData || !widgetStyle)) {
return;
}
const widget = this.props.context.views[this.props.view].widgets[this.props.id];
this.bindings[stateId].forEach((item) => {
widgetStyle = widgetStyle || widgetContext.style;
const value = this.props.context.formatUtils.formatBinding({
format: item.format,
view: item.view,
wid: this.props.id,
widget,
widgetData: widgetData || widgetContext.data,
moment: this.props.context.moment
});
if (item.type === "data") {
if (widgetData) {
widgetData[item.attr] = value;
} else if (widgetContext) {
widgetContext.data.attr(item.attr, value);
}
} else if (item.type === "style") {
if (widgetStyle) {
widgetStyle[item.attr] = value;
!doNotApplyStyles && VisCanWidget.applyStyle(this.widDiv, widgetStyle, this.state.selected, this.state.editMode);
} else if (widgetContext) {
widgetContext.style.attr(item.attr, value);
!doNotApplyStyles && VisCanWidget.applyStyle(this.widDiv, widgetContext.style, this.state.selected, this.state.editMode);
}
}
});
}
calcData(wid, widget, newWidgetStyle) {
let widgetData;
let widgetStyle;
let isRelative;
try {
widgetData = {
wid,
...widget.data || {}
};
widgetStyle = deepClone(newWidgetStyle || widget.style || {});
Object.keys(widgetData).forEach((attr) => {
if (attr && widgetData[attr] && typeof widgetData[attr] === "string" && (attr.startsWith("src") || attr.endsWith("src") || attr.includes("icon")) && widgetData[attr].startsWith("_PRJ_NAME")) {
widgetData[attr] = `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}${widgetData[attr].substring(9)}`;
}
});
if (widgetStyle["background-image"] && widgetStyle["background-image"].startsWith("_PRJ_NAME")) {
widgetStyle["background-image"] = `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}${widgetStyle["background-image"].substring(9)}`;
}
this.applyBindings(true, widgetData, widgetStyle);
if (widgetData.filterkey && typeof widgetData.filterkey === "string") {
widgetData.filterKeyParsed = widgetData.filterkey.split(",").map((f2) => f2.trim()).filter((f2) => f2);
}
isRelative = this.props.isRelative !== void 0 ? this.props.isRelative : widgetStyle && (widgetStyle.position === "relative" || widgetStyle.position === "static" || widgetStyle.position === "sticky");
if (isRelative) {
delete widgetStyle.top;
delete widgetStyle.left;
if (isVarFinite(this.props.context.views[this.props.view].settings.rowGap)) {
widgetStyle["margin-bottom"] = `${parseFloat(this.props.context.views[this.props.view].settings.rowGap)}px`;
}
}
if (this.state.multiViewWidget && this.state.editMode) {
if (widgetStyle.opacity === void 0 || widgetStyle.opacity === null || widgetStyle.opacity > 0.3) {
widgetStyle.opacity = 0.3;
}
}
} catch (e2) {
console.warn(`[${wid}] Cannot bind data of widget: ${e2}`);
return {
widgetData: null,
widgetStyle: null,
isRelative: false
};
}
return {
widgetData,
widgetStyle,
isRelative
};
}
renderWidget(update2, newWidgetData, newWidgetStyle, _count, cb) {
var _a;
_count = _count || 0;
const parentDivRef = this.props.refParent;
let parentDiv;
if (Object.prototype.hasOwnProperty.call(parentDivRef, "current")) {
parentDiv = parentDivRef.current;
} else {
console.log("IT does EXIST!!!. CHECK ME!");
parentDiv = parentDivRef;
}
if (!parentDiv) {
if (_count < 5) {
setTimeout(() => this.renderWidget(update2, newWidgetData, newWidgetStyle, _count + 1, cb), 50);
}
return;
}
const wid = this.props.id;
let widget = this.props.context.views[this.props.view].widgets[wid];
if (!widget || typeof widget !== "object") {
return;
}
if (widget == null ? void 0 : widget.groupid) {
const parentWidgetData = this.props.context.views[this.props.view].widgets[widget.groupid].data;
const names = Object.keys(parentWidgetData).map((attr) => attr.startsWith("attrType_") ? attr.substring(9) : null).filter((attr) => attr);
if (names.length && widget.data) {
let copied = false;
Object.keys(widget.data).forEach((attr) => {
if (typeof widget.data[attr] === "string" && names.find((a) => widget.data[attr].includes(a))) {
const result = replaceGroupAttr(widget.data[attr], parentWidgetData);
if (result.doesMatch) {
if (!copied) {
copied = true;
widget = JSON.parse(JSON.stringify(widget));
}
widget.data[attr] = result.newString || "";
}
}
});
}
}
if (!update2) {
const { isRelative: isRelative2, widgetData: widgetData2, widgetStyle: widgetStyle2 } = this.calcData(wid, widget, newWidgetStyle);
const newData2 = JSON.stringify(widgetData2);
const newStyle2 = JSON.stringify(widgetStyle2);
if (this.widDiv) {
if (this.oldEditMode === this.state.editMode) {
if (this.oldData === newData2 && !update2) {
if (this.oldStyle === newStyle2 || widgetData2._no_style) {
return;
}
if (!this.updateOnStyle) {
this.oldStyle = newStyle2;
if (this.props.context.allWidgets[wid] && this.props.context.allWidgets[wid].style) {
const mStyle = this.props.context.allWidgets[wid].style;
Object.keys(widgetStyle2).forEach((attr) => {
if (typeof widgetStyle2[attr] === "function") {
return;
}
if (mStyle[attr] !== widgetStyle2[attr]) {
mStyle.attr(attr, widgetStyle2[attr]);
}
});
}
VisCanWidget.applyStyle(this.widDiv, widgetStyle2, this.state.selected, this.state.editMode);
this.widDiv.style.position = isRelative2 ? widgetStyle2.position || "relative" : "absolute";
console.log("Rerender ignored as only style applied");
return;
}
}
}
}
}
this.destroy(update2);
const oldIDs = this.IDs;
VisBaseWidget.removeFromArray(this.props.context.linkContext.visibility, this.IDs, this.props.view, wid);
VisBaseWidget.removeFromArray(this.props.context.linkContext.lastChanges, this.IDs, this.props.view, wid);
VisBaseWidget.removeFromArray(this.props.context.linkContext.signals, this.IDs, this.props.view, wid);
VisBaseWidget.removeFromArray(this.props.context.linkContext.bindings, this.IDs, this.props.view, wid);
this.setupSubscriptions();
const unsubscribe = oldIDs.filter((id) => !this.IDs.includes(id));
if (unsubscribe.length) {
this.props.context.linkContext.unsubscribe(unsubscribe);
}
const subscribe = this.IDs.filter((id) => !oldIDs.includes(id));
if (subscribe.length) {
this.props.context.linkContext.subscribe(subscribe);
}
const { isRelative, widgetData, widgetStyle } = this.calcData(wid, widget, newWidgetStyle);
const newData = JSON.stringify(widgetData);
const newStyle = JSON.stringify(widgetStyle);
this.oldEditMode = this.state.editMode;
this.oldData = newData;
this.oldStyle = newStyle;
widgetData.wid = wid;
this.props.context.allWidgets[wid] = {
style: new this.props.context.can.Map(widgetStyle),
data: new this.props.context.can.Map(widgetData),
wid
};
let userGroups = widgetData["visibility-groups"];
if (!this.state.editMode && (userGroups == null ? void 0 : userGroups.length)) {
if (widgetData["visibility-groups-action"] === "hide") {
if (!this.isUserMemberOfGroup(this.props.context.user, userGroups)) {
return;
}
userGroups = null;
}
} else {
userGroups = null;
}
try {
if (this.props.tpl) {
if (!this.widDiv || !update2 || !((_a = widget == null ? void 0 : widget.data) == null ? void 0 : _a.members.length)) {
const options = {
data: this.props.context.allWidgets[wid].data,
viewDiv: this.props.view,
view: this.props.view,
style: this.props.context.allWidgets[wid].style
};
if (widgetData == null ? void 0 : widgetData.oid) {
options.val = this.props.context.canStates.attr(`${widgetData.oid}.val`);
}
const widgetFragment = this.props.context.can.view(this.props.tpl, options);
const scripts = Array.from(widgetFragment.querySelectorAll("script"));
for (let i = 0; i < scripts.length; i++) {
const script = scripts[i];
const newScript = document.createElement("script");
newScript.innerHTML = script.innerHTML;
script.parentNode.replaceChild(newScript, script);
}
if (isRelative) {
const pos = this.props.relativeWidgetOrder.indexOf(wid);
if (pos === 0) {
parentDiv.prepend(widgetFragment);
} else if (pos === this.props.relativeWidgetOrder.length - 1) {
parentDiv.appendChild(widgetFragment);
} else {
let div;
for (let i = pos + 1; i < this.props.relativeWidgetOrder.length; i++) {
div = parentDiv.querySelector(`#${this.props.relativeWidgetOrder[i]}`);
if (div) {
parentDiv.insertBefore(widgetFragment, div);
break;
}
}
if (!div) {
parentDiv.appendChild(widgetFragment);
}
}
} else {
parentDiv.appendChild(widgetFragment);
}
}
} else {
console.error(`[${wid}] Widget is invalid. Please delete it.`);
return;
}
this.widDiv = parentDiv.querySelector(`#${wid}`);
if (this.widDiv) {
if (this.props.context.allWidgets[wid].style && !widgetData._no_style) {
VisCanWidget.applyStyle(this.widDiv, this.props.context.allWidgets[wid].style, this.state.selected, this.state.editMode);
}
this.widDiv.style.position = isRelative ? this.props.context.allWidgets[wid].style.position || "relative" : "absolute";
this.widDiv.style.boxSizing = "border-box";
if (widgetData && widgetData.class) {
this.widDiv.className = addClass$1(this.widDiv.className, widgetData.class);
}
const tplEl = window.document.getElementById(this.props.tpl);
const visName = tplEl.dataset.visName || (wid[0] === "g" ? "group" : "noname");
const visSet = tplEl.dataset.visSet || "noset";
this.updateOnStyle = tplEl.dataset.visUpdateStyle === "true";
this.resizeLocked = tplEl.dataset.visResizeLocked === "true";
this.widDiv.className = addClass$1(this.widDiv.className, `vis-tpl-${visSet}-${visName.replace(/\s/g, "-")}`);
if (!this.state.editMode) {
this.updateVisibility();
} else if (this.props.context.allWidgets[this.props.id]) {
const newState = analyzeDraggableResizable(this.widDiv, null, this.props.context.allWidgets[this.props.id].style);
if (this.state.resizable !== newState.resizable || this.state.hideHelper !== newState.hideHelper || this.state.draggable !== newState.draggable) {
setTimeout(() => this.setState(newState), 50);
}
}
let s = 0;
while (widgetData[`signals-oid-${s}`]) {
this.addSignalIcon(widgetData, s);
s++;
}
if (widgetData["lc-oid"] && widgetData["lc-oid"] !== "nothing_selected") {
this.addLastChange(widgetData);
}
if (!this.state.editMode && widgetData["echart-oid"]) {
this.addChart(widgetData);
}
if (userGroups && widget.data["visibility-groups-action"] === "disabled" && !this.isUserMemberOfGroup(this.props.context.user, userGroups)) {
this.widDiv.className = addClass$1(this.widDiv.className, "vis-user-disabled");
}
if (this.refService.current) {
setTimeout(() => {
if (this.refService.current && this.widDiv) {
this.refService.current.style.width = `${this.widDiv.offsetWidth}px`;
this.refService.current.style.height = `${this.widDiv.offsetHeight}px`;
if (isRelative) {
this.refService.current.style.left = `${this.widDiv.offsetLeft}px`;
this.refService.current.style.top = `${this.widDiv.offsetTop}px`;
}
}
}, 50);
}
this.onCommand("updateContainers");
} else {
console.log("Div not yet rendered");
}
this.props.askView && this.props.askView("register", {
id: wid,
widDiv: this.widDiv || null,
refService: this.refService,
onMove: this.onMove,
onResize: this.onResize,
onTempSelect: this.onTempSelect,
onCommand: this.onCommandBound
});
} catch (e2) {
const lines = (e2.toString() + e2.stack.toString()).split("\n");
const error = `can't render ${this.props.tpl} ${wid} on "${this.props.view}": `;
this.props.context.socket.log(error, "error");
console.error(error);
for (let l2 = 0; l2 < lines.length; l2++) {
const line = `${l2} - ${lines[l2]}`;
this.props.context.socket.log(line, "error");
console.error(line);
}
}
cb && cb();
}
shouldComponentUpdate(_nextProps, nextState) {
const lastState = JSON.stringify(nextState);
if (!this.widDiv) {
this.lastState = lastState;
return true;
}
if (!this.lastState || lastState !== this.lastState) {
this.lastState = lastState;
return true;
}
return false;
}
renderWidgetBody(props) {
if (this.state.applyBindings && !this.bindingsTimer) {
this.bindingsTimer = setTimeout(() => {
this.bindingsTimer = null;
this.renderWidget(true);
}, 10);
}
if (this.widDiv && this.state.editMode && this.props.context.allWidgets[this.props.id]) {
const zIndexProp = this.props.context.allWidgets[this.props.id].style["z-index"];
const zIndex = parseInt(zIndexProp || 0, 10);
if (this.state.selected) {
this.widDiv.style.zIndex = (500 + (zIndex || 0)).toString();
} else if (zIndexProp !== void 0) {
this.widDiv.style.zIndex = parseInt(zIndexProp || 0, 10).toString();
}
if (this.state.selected) {
props.style.zIndex = 500 + (zIndex || 0) + 1;
} else {
props.style.zIndex = (zIndex || 0) + 1;
}
this.widDiv.style.userSelect = "none";
this.widDiv.style.pointerEvents = "none";
if (this.filterDisplay !== void 0) {
this.widDiv.style.display = this.filterDisplay;
delete this.filterDisplay;
}
}
props.style.position = "absolute";
const legacyViewContainers = this.state.legacyViewContainers.length ? this.state.legacyViewContainers.map((view) => {
const context = this.props.context;
const VisView2 = context.VisView;
this.refViews[view] = this.refViews[view] || React.createRef();
const otherRef = context.linkContext.getViewRef(view);
if (otherRef && otherRef !== this.refViews[view]) {
console.log("View is not rendered as used somewhere else!");
return null;
}
if (view && context.views[view]) {
return jsxRuntimeExports.jsx(VisView2, {
context,
activeView: view,
editMode: false,
view,
visInWidget: true,
theme: this.props.context.theme,
viewsActiveFilter: this.props.viewsActiveFilter
}, view);
}
return null;
}) : null;
if (!this.state.editMode) {
props.style.display = "none";
}
return legacyViewContainers;
}
}
const MENU_WIDTH_FULL = 200;
const MENU_WIDTH_NARROW = 56;
const TOOLBAR_SIZE = 48;
const styles$3 = {
root: {
width: "100%",
height: "100%",
display: "flex",
position: "relative"
},
rootHorizontal: {
width: "100%",
height: "100%",
display: "flex",
position: "relative",
flexDirection: "column"
},
toolBar: (theme) => ({
width: "100%",
height: TOOLBAR_SIZE,
overflow: "hidden",
lineHeight: `${TOOLBAR_SIZE}px`,
pl: "16px",
fontSize: 20,
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
transition: "padding-left 0.4s ease-in-out",
display: "flex",
alignItems: "center",
gap: 8
}),
toolbarIcon: {
height: 32,
width: "auto"
},
verticalMenu: (theme) => ({
width: "100%",
top: 0,
left: 0,
height: TOOLBAR_SIZE,
overflow: "hidden",
lineHeight: `${TOOLBAR_SIZE}px`,
backgroundColor: theme.palette.primary.main,
zIndex: 450
}),
toolBarWithClosedMenu: {
paddingLeft: `${16 + TOOLBAR_SIZE}px`
},
viewContentWithToolbar: {
position: "relative",
height: `calc(100% - ${TOOLBAR_SIZE}px)`,
width: "100%"
},
viewContentWithoutToolbar: {
position: "relative",
height: "100%",
width: "100%"
},
openMenuButton: {
position: "absolute",
top: 5,
width: TOOLBAR_SIZE,
height: TOOLBAR_SIZE,
zIndex: 999,
transition: "all 0.4s ease-in-out"
},
openMenuButtonFull: {},
openMenuButtonNarrow: {
left: 9
},
openMenuButtonHidden: {
left: 9,
opacity: 0.5
},
openMenuButtonIconHidden: {
transform: "rotate(180deg)",
transformOrigin: "center",
transition: "all 0.3s ease-in-out"
},
menu: {
transition: "width 0.4s ease-in-out, opacity 0.3s ease-in-out"
},
menuFull: {
height: "100%",
display: "inline-block",
overflow: "hidden",
opacity: 1
},
menuNarrow: {
width: MENU_WIDTH_NARROW,
height: "100%",
display: "inline-block",
overflow: "hidden",
opacity: 1
},
menuHidden: {
width: 0,
height: "100%",
display: "inline-block",
opacity: 0
},
afterMenu: {
transition: "width 0.4s ease-in-out"
},
afterMenuFull: {
height: "100%",
display: "inline-block"
},
afterMenuNarrow: {
width: `calc(100% - ${MENU_WIDTH_NARROW}px)`,
height: "100%",
display: "inline-block"
},
afterMenuHidden: {
width: "100%",
height: "100%",
display: "inline-block"
},
menuList: {
width: "100%",
height: "calc(100% - 49px)",
overflowY: "auto",
overflowX: "hidden"
},
menuItem: {
minHeight: TOOLBAR_SIZE
},
listItemIcon: {
width: 24,
height: 24
},
listItemIconText: {
paddingLeft: 8,
opacity: 1,
transition: "opacity 0.3s ease-in-out",
position: "absolute",
top: 12,
left: 16
},
listItemText: {
whiteSpace: "nowrap",
transition: "all 0.3s ease-in-out",
opacity: 1
},
listItemTextNarrow: {
opacity: 0
},
selectedMenu: (theme) => ({
backgroundColor: theme.palette.secondary.main,
color: theme.palette.secondary.contrastText
}),
menuToolbar: {
height: TOOLBAR_SIZE,
display: "flex",
lineHeight: `${TOOLBAR_SIZE}px`,
verticalAlign: "middle",
paddingLeft: 16,
fontSize: 20,
whiteSpace: "nowrap",
transition: "opacity 0.3s ease-in-out"
},
menuToolbarFull: {
opacity: 1
},
menuToolbarNarrow: {
opacity: 0
},
transparent: {
opacity: 0
}
};
class VisNavigation extends React.Component {
renderMenu(settings, menuFullWidth) {
const items = [];
Object.keys(this.props.context.views).forEach((view) => {
var _a;
if (view === "___settings") {
return;
}
const viewSettings = this.props.context.views[view].settings;
if (viewSettings.navigation) {
const item = {
text: settings.navigationOrientation === "horizontal" && viewSettings.navigationOnlyIcon ? null : viewSettings.navigationTitle || view,
color: viewSettings.navigationColor,
icon: viewSettings.navigationIcon || viewSettings.navigationImage,
noText: viewSettings.navigationOnlyIcon,
order: parseInt(viewSettings.navigationOrder || "0"),
view
};
items.push(item);
if ((_a = item.icon) == null ? void 0 : _a.startsWith("_PRJ_NAME/")) {
item.icon = `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}${item.icon.substring(9)}`;
}
}
});
items.sort((prevItem, nextItem) => prevItem.order === nextItem.order ? 0 : prevItem.order < nextItem.order ? -1 : 1);
if (settings.navigationOrientation === "horizontal") {
return jsxRuntimeExports.jsx(__mf_14$1, {
component: "div",
sx: styles$3.verticalMenu,
style: {
backgroundColor: settings.navigationBarColor || this.props.context.theme.palette.background.paper,
opacity: this.props.editMode ? 0.4 : 1,
position: this.props.context.runtime ? "fixed" : "relative"
},
children: jsxRuntimeExports.jsx(__mf_120, {
value: this.props.activeView,
children: items.map((item, index) => jsxRuntimeExports.jsx(__mf_109, {
iconPosition: "start",
style: {
minHeight: 48,
minWidth: item.noText ? 20 : void 0,
color: this.props.activeView === item.view ? settings.navigationSelectedColor : settings.navigationColor
},
icon: item.icon ? jsxRuntimeExports.jsx(__mf_15$1, {
src: item.icon,
style: {
...styles$3.listItemIcon,
color: this.props.activeView === item.view ? settings.navigationSelectedColor : settings.navigationColor
}
}) : void 0,
onClick: () => this.props.context.changeView(item.view),
value: item.view,
label: item.text
}, index))
})
});
}
const menuStyle = {
...styles$3.menu,
width: this.props.menuWidth === "full" ? menuFullWidth : void 0,
...this.props.menuWidth === "full" ? styles$3.menuFull : void 0,
...this.props.menuWidth === "narrow" ? styles$3.menuNarrow : void 0,
...this.props.menuWidth === "hidden" ? styles$3.menuHidden : void 0,
opacity: this.props.editMode ? 0.4 : 1,
backgroundColor: settings.navigationBackground || void 0
};
if (settings.navigationHideOnSelection) {
menuStyle.zIndex = 998;
menuStyle.position = this.props.context.runtime ? "fixed" : "absolute";
menuStyle.top = 0;
menuStyle.left = 0;
menuStyle.backgroundColor = settings.navigationBackground || this.props.context.theme.palette.background.paper;
}
const menuToolbarStyle = {
...styles$3.menuToolbar,
...this.props.menuWidth === "full" ? styles$3.menuToolbarFull : void 0,
...this.props.menuWidth === "narrow" ? styles$3.menuToolbarNarrow : void 0,
...this.props.menuWidth === "hidden" ? styles$3.menuToolbarNarrow : void 0,
color: settings.navigationHeaderTextColor || void 0
};
return jsxRuntimeExports.jsxs("div", {
style: menuStyle,
children: [
jsxRuntimeExports.jsx("div", {
style: menuToolbarStyle,
children: settings.navigationHeaderText || ""
}),
jsxRuntimeExports.jsx(__mf_37, {}),
jsxRuntimeExports.jsx("div", {
style: styles$3.menuList,
children: jsxRuntimeExports.jsx(__mf_63, {
children: items.map((item, index) => {
const menuItem = jsxRuntimeExports.jsx(__mf_64, {
disablePadding: true,
sx: __mf_70.getStyle(this.props.theme, styles$3.menuItem, this.props.activeView === item.view && styles$3.selectedMenu),
style: {
backgroundColor: this.props.activeView === item.view ? settings.navigationSelectedBackground : void 0
},
onClick: () => {
if (settings.navigationHideOnSelection) {
this.hideNavigationMenu();
}
this.props.context.changeView(item.view);
},
children: jsxRuntimeExports.jsxs(__mf_66, {
children: [
jsxRuntimeExports.jsx(__mf_67, {
children: item.icon ? jsxRuntimeExports.jsx(__mf_15$1, {
src: item.icon,
style: {
color: this.props.activeView === item.view ? settings.navigationSelectedColor : settings.navigationColor,
backgroundColor: "rgba(1,1,1,0)"
},
sx: __mf_70.getStyle(this.props.theme, styles$3.listItemIcon, this.props.activeView === item.view && styles$3.selectedMenu)
}) : jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
children: [
jsxRuntimeExports.jsx(__mf_2256, {
style: {
color: this.props.activeView === item.view ? settings.navigationSelectedColor : settings.navigationColor,
backgroundColor: "rgba(1,1,1,0)"
},
sx: __mf_70.getStyle(this.props.theme, this.props.menuWidth !== "full" && styles$3.transparent, this.props.activeView === item.view && styles$3.selectedMenu)
}),
item.text ? jsxRuntimeExports.jsx("span", {
style: {
...styles$3.listItemIconText,
...this.props.menuWidth === "full" ? styles$3.transparent : void 0,
color: this.props.activeView === item.view ? settings.navigationSelectedColor : settings.navigationColor
},
children: item.text[0].toUpperCase()
}) : null
]
})
}),
jsxRuntimeExports.jsx(__mf_69, {
primary: item.text,
style: {
color: this.props.activeView === item.view ? settings.navigationSelectedColor : settings.navigationColor
},
sx: {
"&.MuListItemText-primary": __mf_70.getStyle(this.props.theme, styles$3.listItemText, this.props.activeView === item.view && !settings.navigationSelectedColor && styles$3.selectedMenu, this.props.menuWidth === "narrow" && styles$3.listItemTextNarrow)
}
})
]
})
}, index);
return jsxRuntimeExports.jsx(__mf_126, {
title: this.props.menuWidth !== "full" ? item.text : "",
slotProps: {
popper: {
sx: {
pointerEvents: "none"
}
}
},
children: menuItem
}, index);
})
})
})
]
});
}
renderToolbar(settings) {
if (!settings.navigationBar) {
return null;
}
let style2;
if (settings.navigationBarColor) {
style2 = {
backgroundColor: settings.navigationBarColor,
color: __mf_70.getInvertedColor(settings.navigationBarColor, this.props.context.themeType, true)
};
} else {
style2 = {};
}
style2.opacity = this.props.editMode ? 0.4 : 1;
let icon = settings.navigationBarIcon || settings.navigationBarImage;
if (icon == null ? void 0 : icon.startsWith("_PRJ_NAME/")) {
icon = `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}${icon.substring(9)}`;
}
return jsxRuntimeExports.jsxs(__mf_14$1, {
component: "div",
sx: __mf_70.getStyle(this.props.theme, styles$3.toolBar, this.props.menuWidth === "hidden" && styles$3.toolBarWithClosedMenu),
style: style2,
children: [
icon ? jsxRuntimeExports.jsx(__mf_15$1, {
src: icon,
style: styles$3.toolbarIcon
}) : null,
settings.navigationBarText || this.props.activeView
]
});
}
hideNavigationMenu() {
window.localStorage.setItem("vis.navOpened", "hidden");
this.props.setMenuWidth("hidden");
}
renderOpenMenuButton(settings) {
let backgroundColor;
let color;
if (this.props.menuWidth === "hidden") {
if (settings.navigationButtonBackground) {
backgroundColor = this.props.context.themeType === "dark" ? "#FFFFFF40" : "#00000040";
} else {
backgroundColor = "transparent";
}
if (settings.navigationBar && !settings.navigationChevronColor) {
if (settings.navigationBarColor) {
color = __mf_70.getInvertedColor(settings.navigationBarColor, this.props.context.themeType, true);
} else {
color = this.props.context.themeType === "dark" ? "#FFF" : "#000";
}
} else {
color = settings.navigationChevronColor;
}
} else {
backgroundColor = "transparent";
}
return jsxRuntimeExports.jsx(__mf_53, {
onClick: () => {
if (settings.navigationHideOnSelection) {
if (this.props.menuWidth === "full") {
this.hideNavigationMenu();
} else {
window.localStorage.setItem("vis.navOpened", "full");
this.props.setMenuWidth("full");
}
} else if (this.props.menuWidth === "full") {
window.localStorage.setItem("vis.navOpened", "narrow");
this.props.setMenuWidth("narrow");
} else if (this.props.menuWidth === "narrow") {
if (!settings.navigationNoHide) {
this.hideNavigationMenu();
} else {
window.localStorage.setItem("vis.navOpened", "full");
this.props.setMenuWidth("full");
}
} else {
window.localStorage.setItem("vis.navOpened", "full");
this.props.setMenuWidth("full");
}
},
style: {
backgroundColor
},
children: jsxRuntimeExports.jsx(__mf_1711, {
style: {
...this.props.menuWidth === "hidden" || this.props.menuWidth === "narrow" && settings.navigationNoHide ? styles$3.openMenuButtonIconHidden : void 0,
color
}
})
});
}
render() {
if (!this.props.context.views || !this.props.context.views[this.props.view]) {
return null;
}
const settings = this.props.context.views[this.props.view].settings;
const menuFullWidth = parseInt(settings.navigationWidth, 10) || MENU_WIDTH_FULL;
if (settings.navigation && !this.props.visInWidget && settings.navigationOrientation === "horizontal" && this.props.view === this.props.activeView) {
return jsxRuntimeExports.jsxs("div", {
style: styles$3.rootHorizontal,
children: [
this.renderMenu(settings, menuFullWidth),
jsxRuntimeExports.jsx("div", {
style: {
...styles$3.viewContentWithToolbar,
marginTop: this.props.context.runtime ? TOOLBAR_SIZE : void 0
},
children: this.props.children
})
]
});
}
if (!settings.navigation && settings.navigationBar) {
return jsxRuntimeExports.jsxs("div", {
style: styles$3.afterMenuHidden,
children: [
this.renderToolbar(settings),
jsxRuntimeExports.jsx("div", {
style: styles$3.viewContentWithToolbar,
children: this.props.children
})
]
});
}
const menuWidth = settings.navigationHideOnSelection ? "hidden" : this.props.menuWidth;
const styleMenu = {
...styles$3.openMenuButton
};
if (this.props.menuWidth === "full") {
styleMenu.left = menuFullWidth - TOOLBAR_SIZE;
Object.assign(styleMenu, styles$3.openMenuButtonFull);
} else if (this.props.menuWidth === "narrow") {
Object.assign(styleMenu, styles$3.openMenuButtonNarrow);
} else {
Object.assign(styleMenu, styles$3.openMenuButtonHidden);
if (settings.navigationBar) {
styleMenu.opacity = 1;
}
}
const styleView = {
...styles$3.afterMenu
};
if (!settings.navigationHideMenu) {
if (menuWidth === "full") {
Object.assign(styleView, styles$3.afterMenuFull);
styleView.width = `calc(100% - ${menuFullWidth}px)`;
} else if (menuWidth === "narrow") {
Object.assign(styleView, styles$3.afterMenuNarrow);
} else {
Object.assign(styleView, styles$3.afterMenuHidden);
}
} else {
Object.assign(styleView, styles$3.afterMenuHidden);
}
return jsxRuntimeExports.jsxs("div", {
style: styles$3.root,
children: [
!settings.navigationHideMenu ? jsxRuntimeExports.jsx("div", {
style: styleMenu,
children: this.renderOpenMenuButton(settings)
}) : null,
!settings.navigationHideMenu ? this.renderMenu(settings, menuFullWidth) : null,
jsxRuntimeExports.jsxs("div", {
style: styleView,
children: [
this.renderToolbar(settings),
jsxRuntimeExports.jsx("div", {
style: settings.navigationBar ? styles$3.viewContentWithToolbar : styles$3.viewContentWithoutToolbar,
children: this.props.children
})
]
})
]
});
}
}
const MAX_COLUMNS = 8;
VisView = class extends React.Component {
static Z_INDEXES = {
VIEW_SELECT_RECTANGLE: 1201,
WIDGET_SERVICE_DIV: 1200
};
calculateRelativeWidgetPosition = null;
static themeCache = {};
promiseToCollect;
refView;
refRelativeView;
refRelativeColumnsView;
widgetsRefs;
selectDiv;
movement;
theme;
ignoreMouseEvents;
oldFilter;
registerDone = false;
lastClick = 0;
nextClickIsSteal = null;
loadingTheme = false;
moveTimer = null;
keysHandlerInstalled = false;
constructor(props) {
super(props);
this.promiseToCollect = VisWidgetsCatalog.collectRxInformation(props.context.socket, store.getState().visProject, props.context.changeProject);
this.state = {
mounted: false,
rulers: [],
loadedjQueryTheme: "",
themeCode: "",
width: 0,
menuWidth: window.localStorage.getItem("vis.menuWidth") || "full"
};
this.refView = React.createRef();
this.refRelativeView = React.createRef();
this.refRelativeColumnsView = new Array(MAX_COLUMNS);
for (let r2 = 0; r2 < MAX_COLUMNS; r2++) {
this.refRelativeColumnsView[r2] = React.createRef();
}
this.widgetsRefs = {};
this.selectDiv = null;
this.movement = null;
this.theme = {};
this.ignoreMouseEvents = false;
this.oldFilter = JSON.stringify(props.viewsActiveFilter && props.viewsActiveFilter[this.props.view] || []);
}
async componentDidMount() {
this.updateViewWidth();
await this.promiseToCollect;
this.props.context.linkContext.registerViewRef(this.props.view, this.refView, this.onCommand);
await this.loadJqueryTheme(this.getJQueryThemeName());
this.setState({
mounted: true
}, () => this.registerEditorHandlers());
}
componentWillUnmount() {
var _a;
this.props.context.linkContext.unregisterViewRef(this.props.view, this.refView);
if ((_a = this.refView.current) == null ? void 0 : _a._originalParent) {
this.refView.current._originalParent.appendChild(this.refView.current);
this.refView.current._originalParent = null;
}
if (this.selectDiv) {
this.selectDiv.remove();
this.selectDiv = null;
}
this.widgetsRefs = {};
this.registerEditorHandlers(true);
this.uninstallKeyHandlers();
}
onCommand = (command, options) => {
var _a;
if (command === "updateContainers") {
Object.keys(this.widgetsRefs).forEach((wid) => {
var _a2;
if ((_a2 = this.widgetsRefs[wid]) == null ? void 0 : _a2.onCommand) {
this.widgetsRefs[wid].onCommand("updateContainers");
}
});
return null;
}
if (command === "changeFilter") {
this.changeFilter(options);
return null;
}
if (command === "closeDialog" || command === "openDialog") {
if ((_a = this.widgetsRefs[options]) == null ? void 0 : _a.onCommand) {
this.widgetsRefs[options].onCommand(command);
}
return null;
}
if (command === "collectFilters") {
const widgets = store.getState().visProject[this.props.view].widgets;
const filterList = [];
Object.keys(widgets).forEach((wid) => {
var _a2, _b, _c, _d;
let filterValues;
if ((_a2 = this.widgetsRefs[wid]) == null ? void 0 : _a2.onCommand) {
filterValues = (_b = this.widgetsRefs[wid]) == null ? void 0 : _b.onCommand("collectFilters");
} else {
filterValues = (_d = (_c = widgets[wid]) == null ? void 0 : _c.data) == null ? void 0 : _d.filterkey;
}
if (filterValues) {
if (filterValues && typeof filterValues === "string") {
filterValues = filterValues.split(",").map((f2) => f2.trim()).filter((f2) => f2);
}
filterValues.forEach((f2) => !filterList.includes(f2) && filterList.push(f2));
}
});
return filterList;
}
return null;
};
changeFilter(options) {
options = {
filter: [],
...options
};
if (options.filter) {
this.props.viewsActiveFilter[this.props.view] = options.filter;
Object.keys(this.widgetsRefs).forEach((wid) => {
var _a;
if ((_a = this.widgetsRefs[wid]) == null ? void 0 : _a.onCommand) {
this.widgetsRefs[wid].onCommand("changeFilter");
}
});
if (window.vis.binds.bars && window.vis.binds.bars.filterChanged) {
try {
window.vis.binds.bars.filterChanged(this.props.view, options.filter.join(","));
} catch (error) {
console.error(`Cannot change filter: ${error}`);
}
}
}
return null;
}
askView = (command, props) => {
const widgetsRefs = this.widgetsRefs;
if (command === "register") {
if (props) {
const id = props.id;
widgetsRefs[id] = props;
}
} else if (command === "unregister") {
if (props && widgetsRefs[props.id] && widgetsRefs[props.id].uuid === props.uuid) {
delete widgetsRefs[props.id];
}
} else if (command === "update") {
if (props && widgetsRefs[props.id] && widgetsRefs[props.id].uuid === props.uuid) {
Object.assign(widgetsRefs[props.id], props);
}
} else if (command === "getRef") {
if (props) {
return widgetsRefs[props.id];
}
} else if (command === "getViewClass") {
return this;
}
return null;
};
onMouseWindowDown = (e2) => {
var _a;
if (!((_a = this.refView.current) == null ? void 0 : _a.contains(e2.target))) {
this.cancelStealMode(null);
}
};
onStealStyle = (attr, cb) => {
if (!attr) {
this.cancelStealMode(null);
return;
}
this.nextClickIsSteal = {
attr,
cb
};
Object.keys(this.widgetsRefs).forEach((wid) => {
var _a;
if ((_a = this.widgetsRefs[wid]) == null ? void 0 : _a.onCommand) {
this.widgetsRefs[wid].onCommand("startStealMode");
}
});
window.document.addEventListener("mousedown", this.onMouseWindowDown);
};
cancelStealMode(result) {
if (this.nextClickIsSteal) {
window.document.removeEventListener("mousedown", this.onMouseWindowDown);
this.nextClickIsSteal.cb(result);
Object.keys(this.widgetsRefs).forEach((wid) => {
var _a;
const onCommand = (_a = this.widgetsRefs[wid]) == null ? void 0 : _a.onCommand;
if (onCommand) {
onCommand("cancelStealMode");
}
});
this.nextClickIsSteal = null;
}
}
mouseDownLocal = this.props.context.runtime ? null : (e2) => {
var _a;
if (this.ignoreMouseEvents) {
return;
}
if (e2.button === 2) {
return;
}
if (this.nextClickIsSteal) {
this.cancelStealMode(null);
return;
}
this.props.context.setSelectedWidgets([]);
this.onMouseViewMove && window.document.addEventListener("mousemove", this.onMouseViewMove);
this.onMouseViewUp && window.document.addEventListener("mouseup", this.onMouseViewUp);
const rect = (_a = this.refView.current) == null ? void 0 : _a.getBoundingClientRect();
if (!rect) {
return;
}
this.movement = {
moved: false,
x: e2.clientX - rect.left,
y: e2.clientY - rect.top,
startX: e2.pageX,
startY: e2.pageY,
w: 0,
h: 0,
selectedWidgetsWithRectangle: [],
simpleMode: e2.shiftKey || e2.ctrlKey
};
};
doubleClickOnView = () => {
var _a;
if (this.props.editMode && ((_a = this.props.selectedWidgets) == null ? void 0 : _a.length) === 1 && store.getState().visProject[this.props.view].widgets[this.props.selectedWidgets[0]].tpl === "_tplGroup") {
this.props.context.setSelectedGroup(this.props.selectedWidgets[0]);
}
};
getWidgetsInRect(rect, simpleMode) {
const widgets = Object.keys(this.widgetsRefs).filter((id) => {
var _a;
if (!store.getState().visProject[this.props.view].widgets[id]) {
id !== "fakeId" && console.warn(`Orphaned widget ${id} found!`);
return null;
}
if (store.getState().visProject[this.props.view].widgets[id].groupid && !this.props.selectedGroup) {
return null;
}
const widDiv = this.widgetsRefs[id].widDiv || ((_a = this.widgetsRefs[id].refService) == null ? void 0 : _a.current);
if (widDiv) {
const wRect = widDiv.getBoundingClientRect();
if (simpleMode) {
if (wRect.top >= rect.top && wRect.top <= rect.bottom && wRect.left >= rect.left && wRect.left <= rect.right) {
return true;
}
if (wRect.bottom >= rect.top && wRect.bottom <= rect.bottom && wRect.right >= rect.left && wRect.right <= rect.right) {
return true;
}
if (wRect.top >= rect.top && wRect.top <= rect.bottom && wRect.right >= rect.left && wRect.right <= rect.right) {
return true;
}
if (wRect.bottom >= rect.top && wRect.bottom <= rect.bottom && wRect.left >= rect.left && wRect.left <= rect.right) {
return true;
}
} else if (wRect.top >= rect.top && wRect.top <= rect.bottom && wRect.left >= rect.left && wRect.left <= rect.right && wRect.bottom >= rect.top && wRect.bottom <= rect.bottom && wRect.right >= rect.left && wRect.right <= rect.right) {
return true;
}
}
return false;
});
widgets.sort();
return widgets;
}
onMouseViewMove = !this.props.context.runtime ? (e2) => {
if (this.ignoreMouseEvents || !this.movement) {
return;
}
if (!this.selectDiv && this.refView.current) {
this.selectDiv = window.document.createElement("div");
this.selectDiv.style.position = "absolute";
this.selectDiv.style.zIndex = VisView.Z_INDEXES.VIEW_SELECT_RECTANGLE.toString();
this.selectDiv.className = "vis-editmode-select-rect";
this.refView.current.appendChild(this.selectDiv);
}
this.movement.moved = true;
this.movement.w = e2.pageX - (this.movement.startX || 0);
this.movement.h = e2.pageY - (this.movement.startY || 0);
if (this.selectDiv) {
if (this.movement.w >= 0) {
this.selectDiv.style.left = `${this.movement.x}px`;
this.selectDiv.style.width = `${this.movement.w}px`;
} else {
this.selectDiv.style.left = `${this.movement.x + this.movement.w}px`;
this.selectDiv.style.width = `${-this.movement.w}px`;
}
if (this.movement.h >= 0) {
this.selectDiv.style.top = `${this.movement.y}px`;
this.selectDiv.style.height = `${this.movement.h}px`;
} else {
this.selectDiv.style.top = `${this.movement.y + this.movement.h}px`;
this.selectDiv.style.height = `${-this.movement.h}px`;
}
const widgets = this.getWidgetsInRect(this.selectDiv.getBoundingClientRect(), this.movement.simpleMode || false);
if (this.movement.selectedWidgetsWithRectangle && JSON.stringify(widgets) !== JSON.stringify(this.movement.selectedWidgetsWithRectangle)) {
widgets.forEach((id) => {
var _a, _b, _c;
if (!((_b = (_a = this.movement) == null ? void 0 : _a.selectedWidgetsWithRectangle) == null ? void 0 : _b.includes(id)) && this.widgetsRefs[id] && !store.getState().visProject[this.props.view].widgets[id].data.locked && this.props.selectedGroup !== id) {
if ((_c = this.widgetsRefs[id]) == null ? void 0 : _c.onTempSelect) {
this.widgetsRefs[id].onTempSelect(true);
}
}
});
this.movement.selectedWidgetsWithRectangle.forEach((id) => {
var _a;
if (!widgets.includes(id) && ((_a = this.widgetsRefs[id]) == null ? void 0 : _a.onTempSelect)) {
this.widgetsRefs[id].onTempSelect(false);
}
});
this.movement.selectedWidgetsWithRectangle = widgets.filter((widget) => !store.getState().visProject[this.props.view].widgets[widget].data.locked);
}
}
} : null;
onMouseViewUp = !this.props.context.runtime ? (e2) => {
var _a;
if (this.ignoreMouseEvents) {
return;
}
e2 && e2.stopPropagation();
this.onMouseViewMove && window.document.removeEventListener("mousemove", this.onMouseViewMove);
this.onMouseViewUp && window.document.removeEventListener("mouseup", this.onMouseViewUp);
if (this.selectDiv) {
this.selectDiv.remove();
this.selectDiv = null;
}
((_a = this.movement) == null ? void 0 : _a.selectedWidgetsWithRectangle) && this.props.context.setSelectedWidgets(this.movement.selectedWidgetsWithRectangle);
this.movement = null;
} : null;
mouseDownOnView = this.props.context.runtime ? null : (e2, wid, _isRelative, isResize, isDoubleClick) => {
var _a, _b;
if (this.ignoreMouseEvents) {
return;
}
if (this.nextClickIsSteal) {
if (this.widgetsRefs[wid]) {
const ref = this.widgetsRefs[wid].widDiv || ((_a = this.widgetsRefs[wid].refService) == null ? void 0 : _a.current);
this.cancelStealMode(ref ? ref.style[this.nextClickIsSteal.attr] : null);
} else {
this.cancelStealMode(null);
}
return;
}
if (this.props.context.disableInteraction || this.props.context.lockDragging || this.props.selectedWidgets.map((selectedWidget) => store.getState().visProject[this.props.view].widgets[selectedWidget]).find((widget) => widget.data.locked)) {
return;
}
if (this.lastClick && Date.now() - this.lastClick < 250 || isDoubleClick) {
this.lastClick = Date.now();
if (this.props.selectedWidgets.length === 1 && store.getState().visProject[this.props.view].widgets[this.props.selectedWidgets[0]].tpl === "_tplGroup") {
this.props.context.setSelectedGroup(this.props.selectedWidgets[0]);
}
return;
}
this.lastClick = Date.now();
if (this.props.selectedWidgets.includes(this.props.selectedGroup) && !isResize) {
return;
}
this.onMouseWidgetMove && ((_b = this.refView.current) == null ? void 0 : _b.addEventListener("mousemove", this.onMouseWidgetMove));
this.onMouseWidgetUp && window.document.addEventListener("mouseup", this.onMouseWidgetUp);
this.movement = {
moved: false,
startX: e2.pageX,
startY: e2.pageY,
isResize,
x: 0,
y: 0
};
const widgetsRefs = this.widgetsRefs;
this.props.selectedWidgets.forEach((selectedWidget) => {
var _a2, _b2, _c, _d;
const widgetRect = (_b2 = (_a2 = widgetsRefs[selectedWidget].refService) == null ? void 0 : _a2.current) == null ? void 0 : _b2.getBoundingClientRect();
if (this.movement && widgetRect && e2.pageX <= widgetRect.right && e2.pageX >= widgetRect.left && e2.pageY <= widgetRect.bottom && e2.pageY >= widgetRect.top) {
this.movement.startWidget = (_d = (_c = widgetsRefs[selectedWidget].refService) == null ? void 0 : _c.current) == null ? void 0 : _d.getBoundingClientRect();
}
});
this.props.selectedWidgets.forEach((_wid) => {
var _a2;
if ((_a2 = widgetsRefs[_wid]) == null ? void 0 : _a2.onMove) {
widgetsRefs[_wid].onMove();
}
});
Object.keys(widgetsRefs).forEach((_wid) => {
var _a2;
if ((_a2 = widgetsRefs[_wid]) == null ? void 0 : _a2.onCommand) {
widgetsRefs[_wid].onCommand("startMove");
}
});
};
onIgnoreMouseEvents = (ignore) => {
var _a;
if (this.props.editMode) {
this.ignoreMouseEvents = ignore;
this.props.context.onIgnoreMouseEvents(ignore);
if (ignore && this.movement) {
this.onMouseWidgetMove && ((_a = this.refView.current) == null ? void 0 : _a.removeEventListener("mousemove", this.onMouseWidgetMove));
this.onMouseWidgetUp && window.document.removeEventListener("mouseup", this.onMouseWidgetUp);
this.movement = null;
}
}
};
onMouseWidgetMove = !this.props.context.runtime ? (e2) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
if (!this.movement || !this.refView.current || this.props.selectedWidgets.includes(this.props.selectedGroup) && !this.movement.isResize) {
return;
}
const widgetsRefs = this.widgetsRefs;
this.movement.moved = true;
this.movement.x = e2.pageX - (this.movement.startX || 0);
this.movement.y = e2.pageY - (this.movement.startY || 0);
const viewRect = this.refView.current.getBoundingClientRect();
if (!this.movement.isResize && ((_a = store.getState().visProject[this.props.view].settings) == null ? void 0 : _a.snapType) === 2) {
const gridSize = parseInt(((_b = store.getState().visProject[this.props.view].settings) == null ? void 0 : _b.gridSize) || 0, 10) || 10;
this.movement.x -= Math.ceil(((((_c = this.movement.startWidget) == null ? void 0 : _c.left) || 0) - viewRect.left + this.movement.x) % gridSize);
this.movement.y -= Math.ceil(((((_d = this.movement.startWidget) == null ? void 0 : _d.top) || 0) - viewRect.top + this.movement.y) % gridSize);
}
if (!this.movement.isResize && ((_e = store.getState().visProject[this.props.view].settings) == null ? void 0 : _e.snapType) === 1) {
const left = (((_f = this.movement.startWidget) == null ? void 0 : _f.left) || 0) + this.movement.x;
const right = (((_g = this.movement.startWidget) == null ? void 0 : _g.right) || 0) + this.movement.x;
const top = (((_h = this.movement.startWidget) == null ? void 0 : _h.top) || 0) + this.movement.y;
const bottom = (((_i = this.movement.startWidget) == null ? void 0 : _i.bottom) || 0) + this.movement.y;
for (const wid in widgetsRefs) {
const widgetId = wid;
if (this.props.selectedWidgets.includes(widgetId)) {
continue;
}
const widgetRect = (_k = (_j = widgetsRefs[widgetId].refService) == null ? void 0 : _j.current) == null ? void 0 : _k.getBoundingClientRect();
if (widgetRect) {
if (Math.abs(widgetRect.top - bottom) <= 10 && left <= widgetRect.right && right >= widgetRect.left) {
this.movement.y += Math.round(widgetRect.top - bottom);
break;
}
if (Math.abs(widgetRect.bottom - top) <= 10 && left <= widgetRect.right && right >= widgetRect.left) {
this.movement.y += Math.round(widgetRect.bottom - top);
break;
}
if (Math.abs(widgetRect.left - right) <= 10 && top <= widgetRect.bottom && bottom >= widgetRect.top) {
this.movement.x += Math.round(widgetRect.left - right);
break;
}
if (Math.abs(widgetRect.right - left) <= 10 && top <= widgetRect.bottom && bottom >= widgetRect.top) {
this.movement.x += Math.round(widgetRect.right - left);
break;
}
}
}
}
this.showRulers();
this.props.selectedWidgets.forEach((wid) => {
var _a2;
const onMove = (_a2 = widgetsRefs[wid]) == null ? void 0 : _a2.onMove;
if (onMove && this.movement) {
onMove(this.movement.x, this.movement.y, false, this.calculateRelativeWidgetPosition);
}
const oWidget = store.getState().visProject[this.props.view].widgets[wid];
const attrs = Object.keys(oWidget.data);
attrs.forEach((attr) => {
var _a3;
if (attr.startsWith("widget") && oWidget.data[attr]) {
const onCommand = (_a3 = widgetsRefs[oWidget.data[attr]]) == null ? void 0 : _a3.onCommand;
if (onCommand) {
onCommand("updatePosition");
}
}
});
});
if (this.props.selectedWidgets.length === 1 && ((_m = (_l = widgetsRefs[this.props.selectedWidgets[0]]) == null ? void 0 : _l.refService) == null ? void 0 : _m.current)) {
let found = false;
for (const wid in widgetsRefs) {
const widgetId = wid;
if (this.props.selectedWidgets.includes(widgetId) || !widgetsRefs[widgetId] || !widgetsRefs[widgetId].canHaveWidgets || widgetsRefs[widgetId].doNotWantIncludeWidgets || !widgetsRefs[widgetId].onCommand || !((_n = widgetsRefs[widgetId].refService) == null ? void 0 : _n.current)) {
continue;
}
const baseRect = (_p = (_o = widgetsRefs[this.props.selectedWidgets[0]].refService) == null ? void 0 : _o.current) == null ? void 0 : _p.getBoundingClientRect();
const rect = (_r = (_q = widgetsRefs[widgetId].refService) == null ? void 0 : _q.current) == null ? void 0 : _r.getBoundingClientRect();
const onCommand = (_s = widgetsRefs[widgetId]) == null ? void 0 : _s.onCommand;
if (!found && baseRect && rect && baseRect.top >= rect.top && baseRect.left >= rect.left && baseRect.right <= rect.right && baseRect.bottom <= rect.bottom) {
found = true;
if (onCommand) {
onCommand("includePossible");
}
} else if (onCommand) {
onCommand("includePossibleNOT");
}
}
}
} : null;
showRulers = (hide) => {
var _a, _b, _c, _d, _e, _f;
const rulers = [];
if (hide) {
this.setState({
rulers
});
return;
}
const verticals = [];
const horizontals = [];
const viewRect = (_a = this.refView.current) == null ? void 0 : _a.getBoundingClientRect();
if (!viewRect) {
return;
}
for (const wid of Object.keys(this.widgetsRefs)) {
const widgetId = wid;
const { widgets } = selectView(store.getState(), this.props.view);
if (!this.props.selectedWidgets.includes(widgetId) && widgets[widgetId] && (this.props.selectedGroup && widgets[this.props.selectedGroup].data.members.includes(widgetId) || !this.props.selectedGroup) && (!widgets[widgetId].grouped || this.props.selectedGroup)) {
if (!((_b = this.widgetsRefs[widgetId].refService) == null ? void 0 : _b.current)) {
console.error(`CHECK WHY!!! ${widgetId} has no refService.current`);
} else {
const boundingRect = (_d = (_c = this.widgetsRefs[widgetId].refService) == null ? void 0 : _c.current) == null ? void 0 : _d.getBoundingClientRect();
if (boundingRect) {
horizontals.push(Math.round(boundingRect.top));
horizontals.push(Math.round(boundingRect.bottom));
verticals.push(Math.round(boundingRect.left));
verticals.push(Math.round(boundingRect.right));
}
}
}
}
const selectedHorizontals = [];
const selectedVerticals = [];
for (const wid of this.props.selectedWidgets) {
const { widgets } = selectView(store.getState(), this.props.view);
if (widgets[wid] && (!widgets[wid].grouped || this.props.selectedGroup)) {
const boundingRect = (_f = (_e = this.widgetsRefs[wid].refService) == null ? void 0 : _e.current) == null ? void 0 : _f.getBoundingClientRect();
if (boundingRect) {
selectedHorizontals.push(Math.round(boundingRect.top));
selectedHorizontals.push(Math.round(boundingRect.bottom));
selectedVerticals.push(Math.round(boundingRect.left));
selectedVerticals.push(Math.round(boundingRect.right));
}
}
}
horizontals.forEach((horizontal2) => selectedHorizontals.forEach((selectedHorizontal) => {
if (Math.abs(horizontal2 - selectedHorizontal) <= 0.3) {
rulers.push({
type: "horizontal",
value: horizontal2 - viewRect.top
});
}
}));
verticals.forEach((vertical2) => selectedVerticals.forEach((selectedVertical) => {
if (Math.abs(vertical2 - selectedVertical) <= 0.3) {
rulers.push({
type: "vertical",
value: vertical2 - viewRect.left
});
}
}));
this.setState({
rulers
});
};
onMouseWidgetUp = !this.props.context.runtime ? (e2) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
const widgetsRefs = this.widgetsRefs;
e2 && e2.stopPropagation();
this.onMouseWidgetMove && ((_a = this.refView.current) == null ? void 0 : _a.removeEventListener("mousemove", this.onMouseWidgetMove));
this.onMouseWidgetUp && window.document.removeEventListener("mouseup", this.onMouseWidgetUp);
if ((_b = this.movement) == null ? void 0 : _b.moved) {
this.props.selectedWidgets.forEach((wid) => {
var _a2;
const onMove = (_a2 = widgetsRefs[wid]) == null ? void 0 : _a2.onMove;
if (onMove && this.movement) {
onMove(this.movement.x, this.movement.y, true);
}
});
store.dispatch(recalculateFields(true));
}
Object.keys(widgetsRefs).forEach((_wid) => {
var _a2;
const onCommand = (_a2 = widgetsRefs[_wid]) == null ? void 0 : _a2.onCommand;
if (onCommand) {
onCommand("stopMove");
}
});
if (this.props.selectedWidgets.length === 1 && ((_d = (_c = widgetsRefs[this.props.selectedWidgets[0]]) == null ? void 0 : _c.refService) == null ? void 0 : _d.current)) {
for (const wid in widgetsRefs) {
const widgetId = wid;
if (this.props.selectedWidgets.includes(widgetId) || !widgetsRefs[widgetId] || !widgetsRefs[widgetId].canHaveWidgets || widgetsRefs[widgetId].doNotWantIncludeWidgets || !widgetsRefs[widgetId].onCommand || !((_e = widgetsRefs[widgetId].refService) == null ? void 0 : _e.current)) {
continue;
}
const baseRect = (_g = (_f = widgetsRefs[this.props.selectedWidgets[0]].refService) == null ? void 0 : _f.current) == null ? void 0 : _g.getBoundingClientRect();
const rect = (_i = (_h = widgetsRefs[widgetId].refService) == null ? void 0 : _h.current) == null ? void 0 : _i.getBoundingClientRect();
if (rect && baseRect && baseRect.top >= rect.top && baseRect.left >= rect.left && baseRect.right <= rect.right && baseRect.bottom <= rect.bottom) {
this.props.context.askAboutInclude(this.props.selectedWidgets[0], widgetId, (_wid, toWid) => {
var _a2;
const onCommand = (_a2 = widgetsRefs[toWid]) == null ? void 0 : _a2.onCommand;
if (onCommand) {
onCommand("include", _wid);
}
});
}
}
}
this.showRulers(true);
} : null;
editWidgetsRect(widget) {
var _a;
if (!this.refView.current) {
return null;
}
const viewLeft = this.refView.current.offsetLeft;
const viewTop = this.refView.current.offsetTop;
const ref = this.widgetsRefs[widget].widDiv || ((_a = this.widgetsRefs[widget].refService) == null ? void 0 : _a.current);
if (!ref) {
return null;
}
let top = ref.offsetTop - viewTop;
let left = ref.offsetLeft - viewLeft;
if (!left && !top) {
const style2 = store.getState().visProject[this.props.view].widgets[widget].style;
left = parseInt((style2 == null ? void 0 : style2.left) || "0", 10) + parseInt(ref.offsetLeft, 10);
top = parseInt((style2 == null ? void 0 : style2.top) || "0", 10) + parseInt(ref.offsetTop, 10);
left = left || 0;
top = top || 0;
}
return {
top,
left,
width: ref.clientWidth,
height: ref.clientHeight
};
}
pxToPercent = (oldStyle, newStyle) => {
if (!this.refView.current) {
return null;
}
const pRect = {
left: this.refView.current.clientLeft,
top: this.refView.current.clientTop,
height: this.refView.current.clientHeight,
width: this.refView.current.clientWidth
};
if (oldStyle.position === "relative") {
delete newStyle.top;
delete newStyle.left;
if (oldStyle.width === "100%") {
delete newStyle.width;
}
if (oldStyle.height === "100%") {
delete newStyle.height;
}
}
const resultStyle = {
...newStyle
};
if (newStyle.top && parseDimension(oldStyle.top).dimension === "%" && parseDimension(newStyle.top).dimension !== "%") {
resultStyle.top = parseDimension(newStyle.top).value * 100 / pRect.height;
resultStyle.top = `${Math.round(resultStyle.top * 100) / 100}%`;
}
if (newStyle.left && parseDimension(oldStyle.left).dimension === "%" && parseDimension(newStyle.left).dimension !== "%") {
resultStyle.left = parseDimension(newStyle.left).value * 100 / pRect.width;
resultStyle.left = `${Math.round(resultStyle.left * 100) / 100}%`;
}
if (newStyle.width && parseDimension(oldStyle.width).dimension === "%" && parseDimension(newStyle.width).dimension !== "%") {
resultStyle.width = parseDimension(newStyle.width).value / pRect.width * 100;
resultStyle.width = `${Math.round(resultStyle.width * 100) / 100}%`;
}
if (newStyle.height && parseDimension(oldStyle.height).dimension === "%" && parseDimension(newStyle.height).dimension !== "%") {
resultStyle.height = parseDimension(newStyle.height).value / pRect.height * 100;
resultStyle.height = `${Math.round(resultStyle.height * 100) / 100}%`;
}
return {
...oldStyle,
...resultStyle
};
};
onPxToPercent = (wids, attr, cb) => {
if (!this.refView.current) {
return [];
}
const pRect = {
height: this.refView.current.clientHeight,
width: this.refView.current.clientWidth
};
const results = wids.map((wid) => {
const wRect = this.editWidgetsRect(wid);
if (!wRect) {
return null;
}
let value;
if (attr === "top") {
value = wRect.top * 100 / pRect.height;
} else if (attr === "left") {
value = wRect.left * 100 / pRect.width;
} else if (attr === "width") {
value = wRect.width / pRect.width * 100;
} else {
value = wRect.height / pRect.height * 100;
}
return `${Math.round(value * 100) / 100}%`;
});
cb && cb(results);
return results;
};
onPercentToPx = (wids, attr, cb) => {
const results = wids.map((wid) => {
const wRect = this.editWidgetsRect(wid);
if (!wRect) {
return null;
}
return `${Math.round(wRect[attr])}px`;
});
cb && cb(results);
return results;
};
registerEditorHandlers(unregister) {
if (this.props.context.registerEditorCallback) {
if (!unregister && this.props.activeView === this.props.view) {
if (!this.registerDone) {
this.registerDone = true;
this.props.context.registerEditorCallback("onStealStyle", this.props.view, this.onStealStyle);
this.props.context.registerEditorCallback("onPxToPercent", this.props.view, this.onPxToPercent);
this.props.context.registerEditorCallback("pxToPercent", this.props.view, this.pxToPercent);
this.props.context.registerEditorCallback("onPercentToPx", this.props.view, this.onPercentToPx);
}
} else {
this.registerDone = false;
this.props.context.registerEditorCallback("onStealStyle", this.props.view);
this.props.context.registerEditorCallback("onPxToPercent", this.props.view);
this.props.context.registerEditorCallback("pxToPercent", this.props.view);
this.props.context.registerEditorCallback("onPercentToPx", this.props.view);
}
}
}
updateViewWidth() {
if (this.refRelativeView.current) {
if (this.refRelativeView.current.offsetWidth !== this.state.width) {
this.setState({
width: this.refRelativeView.current.offsetWidth
});
}
}
}
componentDidUpdate() {
this.registerEditorHandlers();
this.updateViewWidth();
if (!this.props.editMode) {
const newFilter = JSON.stringify(this.props.viewsActiveFilter && this.props.viewsActiveFilter[this.props.view] || []);
if (this.oldFilter !== newFilter) {
this.oldFilter = newFilter;
this.changeFilter({
filter: JSON.parse(newFilter)
});
}
}
}
static renderGitter(step, color) {
color = color || "#D0D0D0";
step = step || 10;
const bigWidth = step * 5;
const smallWidth = step;
const gitterPattern = btoa(`<svg width="${bigWidth}" height="${bigWidth}" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="grid" width="${bigWidth}" height="${bigWidth}" patternUnits="userSpaceOnUse">
<path d="M 0 ${smallWidth} L ${bigWidth} ${smallWidth} M ${smallWidth} 0 L ${smallWidth} ${bigWidth} M 0 ${2 * smallWidth} L ${bigWidth} ${2 * smallWidth} M ${2 * smallWidth} 0 L ${2 * smallWidth} ${bigWidth} M 0 ${3 * smallWidth} L ${bigWidth} ${3 * smallWidth} M ${3 * smallWidth} 0 L ${3 * smallWidth} ${bigWidth} M 0 ${4 * smallWidth} L ${bigWidth} ${4 * smallWidth} M ${4 * smallWidth} 0 L ${4 * smallWidth} ${bigWidth}" fill="none" stroke="${color}" opacity="0.2" stroke-width="1"/>
<path d="M ${bigWidth} 0 L 0 0 0 ${bigWidth}" fill="none" stroke="${color}" stroke-width="1"/>
</pattern>
</defs>
<rect width="100%" height="100%" fill="url(#grid)"/>
</svg>`);
const backgroundImage = `url(data:image/svg+xml;base64,${gitterPattern})`;
return jsxRuntimeExports.jsx("div", {
style: {
opacity: 0.2,
zIndex: -1,
userSelect: "none",
pointerEvents: "none",
width: "100%",
height: "100%",
backgroundImage,
backgroundPosition: "-1px -1px"
}
});
}
static getOneWidget(index, widget, options) {
var _a;
if (!VisWidgetsCatalog.rxWidgets) {
return null;
}
const WidgetEl = VisWidgetsCatalog.rxWidgets[widget.tpl] || (((_a = VisWidgetsCatalog.allWidgetsList) == null ? void 0 : _a.includes(widget.tpl)) ? VisCanWidget : VisBaseWidget);
return jsxRuntimeExports.jsx(WidgetEl, {
tpl: widget.tpl,
...options
}, `${index}_${options.id}`);
}
async loadJqueryTheme(jQueryTheme) {
if (VisView.themeCache[jQueryTheme] && this.props.view) {
let data = VisView.themeCache[jQueryTheme];
const _view = `visview_${this.props.view.replace(/\s/g, "_")}`;
data = data.replace(".ui-helper-hidden", `
#${_view} .ui-helper-hidden`);
data = data.replace(/(}.)/g, `}
#${_view} .`);
data = data.replace(/,\./g, `,#${_view} .`);
data = data.replace(/images/g, `../../lib/css/themes/jquery-ui/${jQueryTheme}/images`);
this.setState({
loadedjQueryTheme: jQueryTheme,
themeCode: data
});
} else {
try {
const resp = await fetch(`../../lib/css/themes/jquery-ui/${jQueryTheme}/jquery-ui.min.css`);
let data = await resp.text();
VisView.themeCache[jQueryTheme] = data;
const _view = `visview_${this.props.view.replace(/\s/g, "_")}`;
data = data.replace(".ui-helper-hidden", `
#${_view} .ui-helper-hidden`);
data = data.replace(/(}.)/g, `}
#${_view} .`);
data = data.replace(/,\./g, `,#${_view} .`);
data = data.replace(/images/g, `../../lib/css/themes/jquery-ui/${jQueryTheme}/images`);
this.setState({
loadedjQueryTheme: jQueryTheme,
themeCode: data
});
} catch (e2) {
console.warn(`Cannot load jQueryUI theme "${jQueryTheme}": ${e2.stack}`);
}
}
this.loadingTheme = false;
}
getJQueryThemeName() {
var _a;
const settings = this.props.view && ((_a = store.getState().visProject[this.props.view]) == null ? void 0 : _a.settings);
return (settings == null ? void 0 : settings.theme) || "redmond";
}
installKeyHandlers() {
if (!this.keysHandlerInstalled) {
this.keysHandlerInstalled = true;
window.addEventListener("keydown", this.onKeyDown, false);
}
}
uninstallKeyHandlers() {
if (this.keysHandlerInstalled) {
this.keysHandlerInstalled = false;
window.removeEventListener("keydown", this.onKeyDown, false);
}
}
moveWidgets = (leftShift, topShift) => {
if (!this.moveTimer) {
this.movement = {
x: 0,
y: 0
};
this.props.selectedWidgets.forEach((_wid) => {
var _a;
const onMove = (_a = this.widgetsRefs[_wid]) == null ? void 0 : _a.onMove;
if (onMove) {
onMove();
}
});
Object.keys(this.widgetsRefs).forEach((_wid) => {
var _a;
const onCommand = (_a = this.widgetsRefs[_wid]) == null ? void 0 : _a.onCommand;
if (onCommand) {
onCommand("startMove");
}
});
}
if (!this.movement) {
return;
}
this.movement.x += leftShift;
this.movement.y += topShift;
this.props.selectedWidgets.forEach((wid) => {
var _a;
const widgetsRefs = this.widgetsRefs;
const onMove = (_a = widgetsRefs[wid]) == null ? void 0 : _a.onMove;
if (onMove && this.movement) {
onMove(this.movement.x, this.movement.y, false, this.calculateRelativeWidgetPosition);
}
});
this.showRulers();
this.moveTimer && clearTimeout(this.moveTimer);
this.moveTimer = setTimeout(() => {
this.moveTimer = null;
this.showRulers(true);
store.dispatch(recalculateFields(true));
this.props.selectedWidgets.forEach((wid) => {
var _a;
const onMove = (_a = this.widgetsRefs[wid]) == null ? void 0 : _a.onMove;
if (onMove && this.movement) {
onMove(this.movement.x, this.movement.y, true, this.calculateRelativeWidgetPosition);
}
});
this.movement = null;
Object.keys(this.widgetsRefs).forEach((_wid) => {
var _a;
const onCommand = (_a = this.widgetsRefs[_wid]) == null ? void 0 : _a.onCommand;
if (onCommand) {
onCommand("stopMove");
}
});
}, 800);
};
resizeWidgets = (widthShift, heightShift) => {
if (!this.moveTimer) {
this.movement = {
x: 0,
y: 0,
isResize: true
};
Object.keys(this.widgetsRefs).forEach((_wid) => {
var _a;
const onCommand = (_a = this.widgetsRefs[_wid]) == null ? void 0 : _a.onCommand;
if (onCommand) {
onCommand("startResize");
}
});
this.props.selectedWidgets.forEach((_wid) => {
var _a;
const onMove = (_a = this.widgetsRefs[_wid]) == null ? void 0 : _a.onMove;
if (onMove) {
onMove();
}
});
}
if (!this.movement) {
return;
}
this.movement.x += widthShift;
this.movement.y += heightShift;
this.props.selectedWidgets.forEach((wid) => {
var _a;
const widgetsRefs = this.widgetsRefs;
const onMove = (_a = widgetsRefs[wid]) == null ? void 0 : _a.onMove;
if (onMove && this.movement) {
onMove(this.movement.x, this.movement.y, false, this.calculateRelativeWidgetPosition);
}
});
this.showRulers();
this.moveTimer && clearTimeout(this.moveTimer);
this.moveTimer = setTimeout(() => {
this.moveTimer = null;
this.showRulers(true);
this.props.selectedWidgets.forEach((wid) => {
var _a;
const onMove = (_a = this.widgetsRefs[wid]) == null ? void 0 : _a.onMove;
if (onMove && this.movement) {
onMove(this.movement.x, this.movement.y, true, this.calculateRelativeWidgetPosition);
}
});
Object.keys(this.widgetsRefs).forEach((_wid) => {
var _a;
const onCommand = (_a = this.widgetsRefs[_wid]) == null ? void 0 : _a.onCommand;
if (onCommand) {
onCommand("stopResize");
}
});
this.movement = null;
}, 800);
};
onKeyDown = (e2) => {
var _a;
if (!this.props.editMode) {
return;
}
if (((_a = document.activeElement) == null ? void 0 : _a.tagName) === "BODY") {
if (this.props.selectedWidgets.length) {
if (e2.key === "ArrowLeft") {
e2.preventDefault();
this[e2.shiftKey ? "resizeWidgets" : "moveWidgets"](e2.ctrlKey ? -10 : -1, 0);
}
if (e2.key === "ArrowRight") {
e2.preventDefault();
this[e2.shiftKey ? "resizeWidgets" : "moveWidgets"](e2.ctrlKey ? 10 : 1, 0);
}
if (e2.key === "ArrowUp") {
e2.preventDefault();
this[e2.shiftKey ? "resizeWidgets" : "moveWidgets"](0, e2.ctrlKey ? -10 : -1);
}
if (e2.key === "ArrowDown") {
e2.preventDefault();
this[e2.shiftKey ? "resizeWidgets" : "moveWidgets"](0, e2.ctrlKey ? 10 : 1);
}
}
}
};
renderScreenSize() {
var _a, _b;
const ww = parseInt(((_a = store.getState().visProject[this.props.view].settings) == null ? void 0 : _a.sizex) || 0, 10);
const hh = parseInt(((_b = store.getState().visProject[this.props.view].settings) == null ? void 0 : _b.sizey) || 0, 10);
if (!this.props.editMode || !this.props.view || !ww || !hh) {
return null;
}
return [
jsxRuntimeExports.jsx("div", {
style: {
top: 0,
left: 0,
width: `${ww}px`,
height: `${hh}px`,
position: "absolute",
borderTopWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 1,
borderBottomWidth: 1,
boxSizing: "content-box",
borderStyle: "dashed",
borderColor: "black",
zIndex: 1e3,
pointerEvents: "none",
userSelect: "none",
opacity: 0.7
}
}, "black"),
jsxRuntimeExports.jsx("div", {
style: {
top: 0,
left: 0,
width: `${ww + 1}px`,
height: `${hh + 1}px`,
position: "absolute",
borderTopWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 1,
borderBottomWidth: 1,
boxSizing: "content-box",
borderStyle: "dashed",
borderColor: "white",
zIndex: 1e3,
pointerEvents: "none",
userSelect: "none",
opacity: 0.7
}
}, "white")
];
}
getRelativeStyle(settings, groupId, limitScreenSize) {
var _a;
const relativeStyle = {};
if (groupId) {
const groupWidgetStyle = store.getState().visProject[this.props.view].widgets[groupId].style;
relativeStyle.width = (groupWidgetStyle == null ? void 0 : groupWidgetStyle.width) || "100%";
relativeStyle.height = (groupWidgetStyle == null ? void 0 : groupWidgetStyle.height) || "100%";
} else {
if (settings.sizex && !limitScreenSize) {
let ww = settings.sizex;
let hh = settings.sizey || 0;
if (isVarFinite(ww)) {
ww = parseFloat(ww);
}
if (isVarFinite(hh)) {
hh = parseFloat(hh);
}
if (typeof ww === "number" || ww.match(/\d$/)) {
ww = `${ww.toString()}px`;
}
if (typeof hh === "number" || hh.match(/\d$/)) {
hh = `${hh.toString()}px`;
}
relativeStyle.width = ww;
relativeStyle.height = hh;
} else {
relativeStyle.width = "100%";
relativeStyle.height = "100%";
}
relativeStyle.display = ((_a = settings.style) == null ? void 0 : _a.display) || "flex";
if (relativeStyle.display === "flex") {
relativeStyle.flexWrap = "wrap";
relativeStyle.columnGap = 8;
if (isVarFinite(settings.columnGap)) {
relativeStyle.columnGap = parseInt(settings.columnGap, 10);
}
}
}
relativeStyle.position = "absolute";
relativeStyle.top = 0;
relativeStyle.left = 0;
return relativeStyle;
}
getCountOfRelativeColumns(settings, relativeWidgetsCount) {
const width = this.state.width;
if (width) {
if (settings.columnWidth && isVarFinite(settings.columnWidth)) {
return Math.floor(this.state.width / settings.columnWidth) + 1;
}
let columns;
if (width < 600) {
columns = 1;
} else if (width < 900) {
columns = 2;
} else if (width < 1200) {
columns = 3;
} else if (width < 2064) {
columns = 4;
} else {
columns = Math.floor(width / 500) + 1;
}
if (columns > relativeWidgetsCount) {
columns = relativeWidgetsCount;
}
if (columns > MAX_COLUMNS) {
columns = MAX_COLUMNS;
}
return columns;
}
return 1;
}
renderNavigation(content) {
return jsxRuntimeExports.jsx(VisNavigation, {
context: this.props.context,
activeView: this.props.activeView,
view: this.props.view,
editMode: this.props.editMode,
menuWidth: this.state.menuWidth,
theme: this.props.context.theme,
setMenuWidth: (menuWidth) => {
window.localStorage.setItem("vis.menuWidth", menuWidth);
this.setState({
menuWidth
});
return new Promise((resolve) => {
setTimeout(() => {
this.updateViewWidth();
resolve(null);
}, 400);
});
},
children: content
});
}
render() {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
let rxAbsoluteWidgets = [];
let rxRelativeWidgets = [];
let rxGroupWidget;
const contextView = store.getState().visProject[this.props.view];
if (!this.props.view || !contextView) {
return null;
}
const settings = contextView.settings;
if (this.props.view === this.props.activeView && this.props.editMode && !this.keysHandlerInstalled) {
this.installKeyHandlers();
} else if ((this.props.view !== this.props.activeView || !this.props.editMode) && this.keysHandlerInstalled) {
this.uninstallKeyHandlers();
}
if (this.state.mounted && this.state.themeCode && this.refView.current) {
if (!((_a = this.props.viewsActiveFilter) == null ? void 0 : _a[this.props.view])) {
this.props.viewsActiveFilter[this.props.view] = (((_b = contextView.settings) == null ? void 0 : _b.filterkey) || "").split(",").map((f2) => f2.trim()).filter((f2) => f2);
}
const widgets = contextView.widgets;
let moveAllowed = true;
if (widgets) {
let relativeWidgetOrder = [];
if (this.props.selectedGroup) {
relativeWidgetOrder = [
...((_d = (_c = widgets[this.props.selectedGroup]) == null ? void 0 : _c.data) == null ? void 0 : _d.members) ?? []
];
} else if ((_e = contextView.settings) == null ? void 0 : _e.order) {
relativeWidgetOrder = [
...contextView.settings.order
];
}
if (this.props.selectedGroup) {
relativeWidgetOrder.sort((a, b2) => {
const widgetA = widgets[a];
const widgetB = widgets[b2];
const isRelativeA = widgetA.style && (widgetA.style.position === "relative" || widgetA.style.position === "static" || widgetA.style.position === "sticky");
const isRelativeB = widgetB.style && (widgetB.style.position === "relative" || widgetB.style.position === "static" || widgetB.style.position === "sticky");
if (isRelativeA && isRelativeB) {
return 0;
}
if (isRelativeA) {
return -1;
}
return 1;
});
}
const relativeWidgets = [];
const absoluteWidgets = [];
const unknownWidgets = [];
if (this.props.editMode && ((_f = this.props.selectedWidgets) == null ? void 0 : _f.length)) {
this.props.selectedWidgets.forEach((id) => {
const widget = contextView.widgets[id];
if (!widget || widget.groupid && !this.props.selectedGroup) {
return;
}
if (widget.style) {
if (widget.style.position === "relative") {
relativeWidgets.push(id);
} else if (!widget.style.position || widget.style.position === "absolute") {
absoluteWidgets.push(id);
} else {
unknownWidgets.push(id);
}
} else {
absoluteWidgets.push(id);
}
});
if (unknownWidgets.length) {
moveAllowed = false;
} else if (relativeWidgets.length && absoluteWidgets.length) {
moveAllowed = false;
}
}
const listRelativeWidgetsOrder = [];
const listAbsoluteWidgetsOrder = [];
const filterWidgets = contextView.filterWidgets;
const filterInvert = contextView.filterInvert;
Object.keys(widgets).forEach((id) => {
var _a2;
if (id === this.props.selectedGroup) {
return;
}
const widget = contextView.widgets[id];
if (!widget || widget.grouped && !this.props.selectedGroup) {
return;
}
if (!this.props.selectedGroup && widget.usedInWidget) {
return;
}
if (!hasWidgetAccess({
view: this.props.view,
editMode: this.props.editMode,
project: store.getState().visProject,
user: store.getState().activeUser,
wid: id
})) {
return;
}
if (this.props.selectedGroup && id !== this.props.selectedGroup && widget.groupid !== this.props.selectedGroup) {
return;
}
if (this.props.editMode && (filterWidgets == null ? void 0 : filterWidgets.length)) {
if ((_a2 = widget.data) == null ? void 0 : _a2.filterkey) {
let filterValues = widget.data.filterkey;
if (filterValues && typeof filterValues === "string") {
filterValues = filterValues.split(",").map((f2) => f2.trim()).filter((f2) => f2);
}
if (filterInvert) {
if (!filterWidgets.find((f2) => filterValues.includes(f2))) {
return;
}
} else if (filterWidgets.find((f2) => filterValues.includes(f2))) {
return;
}
} else if (filterInvert) {
return;
}
}
const isRelative = widget.style && (widget.style.position === "relative" || widget.style.position === "static" || widget.style.position === "sticky");
if (isRelative && id !== this.props.selectedGroup) {
if (!listRelativeWidgetsOrder.includes(id)) {
listRelativeWidgetsOrder.push(id);
}
} else {
const pos = listRelativeWidgetsOrder.indexOf(id);
pos !== -1 && listRelativeWidgetsOrder.splice(pos, 1);
if (!listAbsoluteWidgetsOrder.includes(id)) {
listAbsoluteWidgetsOrder.push(id);
}
}
});
if (!this.props.selectedGroup) {
for (let t = relativeWidgetOrder.length - 1; t >= 0; t--) {
if (!contextView.widgets[relativeWidgetOrder[t]]) {
relativeWidgetOrder.splice(t, 1);
}
}
}
listRelativeWidgetsOrder.sort((a, b2) => {
const posA = relativeWidgetOrder.indexOf(a);
const posB = relativeWidgetOrder.indexOf(b2);
if (posA === -1 && posB === -1) {
return 0;
}
if (posA === -1) {
return 1;
}
if (posB === -1) {
return -1;
}
return posA - posB;
});
const columns = this.props.selectedGroup || !settings ? 1 : this.getCountOfRelativeColumns(settings, listRelativeWidgetsOrder.length);
const wColumns = new Array(columns);
for (let w2 = 0; w2 < wColumns.length; w2++) {
wColumns[w2] = [];
}
const view = this.props.view;
rxAbsoluteWidgets = listAbsoluteWidgetsOrder.map((id, index) => {
var _a2;
return VisView.getOneWidget(index, contextView.widgets[id], {
context: this.props.context,
editMode: this.props.editMode,
id,
isRelative: false,
mouseDownOnView: this.mouseDownOnView,
moveAllowed,
ignoreMouseEvents: this.ignoreMouseEvents,
onIgnoreMouseEvents: this.onIgnoreMouseEvents,
refParent: this.props.selectedGroup ? this.refRelativeView : this.refView,
askView: this.askView,
relativeWidgetOrder,
selectedGroup: this.props.selectedGroup,
selectedWidgets: ((_a2 = this.movement) == null ? void 0 : _a2.selectedWidgetsWithRectangle) || this.props.selectedWidgets,
view,
viewsActiveFilter: this.props.viewsActiveFilter,
customSettings: this.props.customSettings
});
});
if (listRelativeWidgetsOrder.length) {
let columnIndex = 0;
listRelativeWidgetsOrder.forEach((id, index) => {
var _a2;
const widget = store.getState().visProject[view].widgets[id];
if (widget.style.newLine) {
columnIndex = 0;
}
const w2 = VisView.getOneWidget(index, widget, {
context: this.props.context,
editMode: this.props.editMode,
id,
isRelative: true,
mouseDownOnView: this.mouseDownOnView,
moveAllowed,
ignoreMouseEvents: this.ignoreMouseEvents,
onIgnoreMouseEvents: this.onIgnoreMouseEvents,
refParent: this.props.selectedGroup ? this.refRelativeView : this.refRelativeColumnsView[columnIndex],
askView: this.askView,
relativeWidgetOrder: this.props.selectedGroup ? relativeWidgetOrder : listRelativeWidgetsOrder,
selectedWidgets: ((_a2 = this.movement) == null ? void 0 : _a2.selectedWidgetsWithRectangle) || this.props.selectedWidgets,
selectedGroup: this.props.selectedGroup,
view,
customSettings: this.props.customSettings,
viewsActiveFilter: this.props.viewsActiveFilter
});
wColumns[columnIndex].push(w2);
columnIndex++;
if (columnIndex >= columns) {
columnIndex = 0;
}
});
if (this.props.selectedGroup) {
rxRelativeWidgets = wColumns[0];
} else {
const style22 = {};
if ((settings == null ? void 0 : settings.columnWidth) && isVarFinite(settings.columnWidth)) {
style22.maxWidth = parseFloat(settings.columnWidth);
}
rxRelativeWidgets = wColumns.map((column, i) => jsxRuntimeExports.jsx("div", {
ref: this.refRelativeColumnsView[i],
style: style22,
className: __mf_70.clsx("vis-view-column", this.props.editMode && "vis-view-column-edit"),
children: column
}, i));
}
} else {
rxRelativeWidgets = null;
}
if (this.props.selectedGroup) {
rxGroupWidget = VisView.getOneWidget(0, contextView.widgets[this.props.selectedGroup], {
context: this.props.context,
editMode: this.props.editMode,
id: this.props.selectedGroup,
isRelative: false,
mouseDownOnView: this.mouseDownOnView,
moveAllowed,
ignoreMouseEvents: this.ignoreMouseEvents,
onIgnoreMouseEvents: this.onIgnoreMouseEvents,
refParent: this.refView,
askView: this.askView,
relativeWidgetOrder,
selectedGroup: this.props.selectedGroup,
selectedWidgets: ((_g = this.movement) == null ? void 0 : _g.selectedWidgetsWithRectangle) || this.props.selectedWidgets,
view,
viewsActiveFilter: this.props.viewsActiveFilter,
customSettings: this.props.customSettings
});
}
}
}
let className = "vis-view";
const style2 = {
width: "100%",
height: "100%"
};
if (this.state.loadedjQueryTheme !== this.getJQueryThemeName() && this.props.view) {
if (!this.loadingTheme) {
this.loadingTheme = true;
setTimeout(() => this.loadJqueryTheme(this.getJQueryThemeName()), this.state.loadedjQueryTheme ? 50 : 0);
}
}
const backgroundStyle = {};
const backgroundClass = ((_h = settings == null ? void 0 : settings.style) == null ? void 0 : _h.background_class) || "";
(settings == null ? void 0 : settings.style) && Object.keys(settings.style).forEach((attr) => {
var _a2;
if (attr === "background_class") {
className = addClass$1(className, (_a2 = settings.style) == null ? void 0 : _a2.background_class);
} else {
const isBg = attr.startsWith("background");
if (!settings["bg-image"] || !isBg) {
const value = settings.style[attr];
attr = attr.replace(/(-\w)/g, (text) => text[1].toUpperCase());
style2[attr] = value;
if (isBg) {
backgroundStyle[attr] = value;
}
}
}
});
let theme = this.props.context.theme;
const customThemeType = (_i = this.props.customSettings) == null ? void 0 : _i.themeType;
if ((_k = (_j = this.props.customSettings) == null ? void 0 : _j.viewStyle) == null ? void 0 : _k.overrides) {
theme = createTheme(customThemeType || this.props.context.theme.palette.mode, this.props.customSettings.viewStyle.overrides);
} else if (customThemeType && customThemeType !== theme.palette.mode) {
if (!this.theme[customThemeType]) {
this.theme[customThemeType] = createTheme(customThemeType);
}
theme = this.theme[customThemeType];
}
if (!style2.backgroundColor && !style2.background) {
if ((_m = (_l = this.props.customSettings) == null ? void 0 : _l.viewStyle) == null ? void 0 : _m.backgroundColor) {
backgroundStyle.backgroundColor = this.props.customSettings.viewStyle.backgroundColor;
} else if (((_n = this.props.customSettings) == null ? void 0 : _n.themeType) === "dark") {
backgroundStyle.backgroundColor = "#000";
} else {
backgroundStyle.backgroundColor = theme.palette.mode === "dark" ? "#000" : "#fff";
}
}
if (!style2.color) {
if ((_p = (_o = this.props.customSettings) == null ? void 0 : _o.viewStyle) == null ? void 0 : _p.color) {
style2.color = this.props.customSettings.viewStyle.color;
} else {
style2.color = theme.palette.mode === "dark" ? "#fff" : "#000";
}
}
if (!style2.fontFamily && ((_r = (_q = this.props.customSettings) == null ? void 0 : _q.viewStyle) == null ? void 0 : _r.fontFamily)) {
style2.fontFamily = this.props.customSettings.viewStyle.fontFamily;
}
if (this.props.view !== this.props.activeView) {
style2.display = "none";
}
if (this.props.context.container) {
style2.overflow = "hidden";
}
let gridDiv = null;
if (((_s = store.getState().visProject[this.props.view].settings) == null ? void 0 : _s.snapType) === 2 && this.props.editMode) {
gridDiv = VisView.renderGitter((_t = contextView.settings) == null ? void 0 : _t.gridSize, (_u = contextView.settings) == null ? void 0 : _u.snapColor);
}
if (this.props.style) {
Object.assign(style2, this.props.style);
}
if (settings && settings["bg-image"]) {
backgroundStyle.backgroundImage = `url("../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}${settings["bg-image"].substring(9)}")`;
backgroundStyle.backgroundRepeat = "no-repeat";
backgroundStyle.backgroundPosition = "top left";
if (settings["bg-color"]) {
backgroundStyle.backgroundColor = settings["bg-color"];
}
if (settings["bg-position-x"]) {
backgroundStyle.backgroundPositionX = isVarFinite(settings["bg-position-x"]) ? `${settings["bg-position-x"]}px` : settings["bg-position-x"];
}
if (settings["bg-position-y"]) {
backgroundStyle.backgroundPositionY = isVarFinite(settings["bg-position-y"]) ? `${settings["bg-position-y"]}px` : settings["bg-position-y"];
}
if (settings["bg-width"] && settings["bg-height"]) {
const w2 = isVarFinite(settings["bg-width"]) ? `${settings["bg-width"]}px` : settings["bg-width"];
const h2 = isVarFinite(settings["bg-height"]) ? `${settings["bg-height"]}px` : settings["bg-height"];
backgroundStyle.backgroundSize = `${w2} ${h2}`;
} else if (settings["bg-width"]) {
backgroundStyle.backgroundSize = `${isVarFinite(settings["bg-width"]) ? `${settings["bg-width"]}px` : settings["bg-width"]} auto`;
} else if (settings["bg-height"]) {
const w2 = isVarFinite(settings["bg-height"]) ? `${settings["bg-height"]}px` : settings["bg-height"];
backgroundStyle.backgroundSize = `auto ${w2}`;
}
}
Object.assign(style2, backgroundStyle);
let renderedWidgets;
let limitScreenStyle = null;
if ((settings == null ? void 0 : settings.limitScreen) && (window.screen.width >= 800 && window.screen.height >= 800 || !settings.limitScreenDesktop)) {
let ignore = false;
if (settings.limitForInstances) {
const visInstance = window.localStorage.getItem("visInstance");
if (visInstance) {
const instances = settings.limitForInstances.split(",").map((i) => i.trim()).filter((i) => i);
if (instances.length && !instances.includes(visInstance)) {
ignore = true;
}
} else {
ignore = true;
}
}
if (!ignore) {
const ww = isVarFinite(settings.sizex) ? parseFloat(settings.sizex) : 0;
const hh = isVarFinite(settings.sizey) ? parseFloat(settings.sizey) : 0;
if (ww && hh) {
const borderWidth = parseFloat(settings.limitScreenBorderWidth) || 0;
const borderColor = settings.limitScreenBorderColor || "#333";
const borderStyle = settings.limitScreenBorderStyle || "dotted";
const bgColor = settings.limitScreenBackgroundColor || null;
limitScreenStyle = {
...backgroundStyle,
width: ww + borderWidth * 2,
height: hh + borderWidth * 2,
minWidth: ww + borderWidth * 2,
minHeight: hh + borderWidth * 2,
overflow: "auto",
position: "relative",
boxSizing: "border-box",
borderWidth,
borderColor,
borderStyle
};
style2.display = "flex";
style2.justifyContent = "center";
style2.alignItems = "center";
style2.backgroundColor = bgColor;
}
}
}
if (this.props.selectedGroup) {
renderedWidgets = rxGroupWidget;
} else if (settings) {
renderedWidgets = jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
children: [
rxRelativeWidgets ? jsxRuntimeExports.jsx("div", {
ref: this.refRelativeView,
style: this.getRelativeStyle(settings, this.props.selectedGroup, !!limitScreenStyle),
className: "vis-relative-view",
children: rxRelativeWidgets
}) : null,
rxAbsoluteWidgets
]
});
}
if (limitScreenStyle) {
renderedWidgets = jsxRuntimeExports.jsx("div", {
style: limitScreenStyle,
className: "vis-limit-screen",
children: renderedWidgets
});
}
let renderedView = jsxRuntimeExports.jsxs("div", {
className: `${className} visview_${this.props.view.replace(/\s/g, "_")}`,
ref: this.refView,
id: `visview_${this.props.view.replace(/\s/g, "_")}`,
onMouseDown: !this.props.context.runtime ? (e2) => this.props.editMode && this.mouseDownLocal && this.mouseDownLocal(e2) : void 0,
onDoubleClick: this.props.context.runtime ? () => this.props.editMode && this.doubleClickOnView && this.doubleClickOnView() : void 0,
style: style2,
children: [
jsxRuntimeExports.jsx("style", {
children: this.state.themeCode
}),
gridDiv,
limitScreenStyle ? null : this.renderScreenSize(),
this.state.rulers.map((ruler, key) => jsxRuntimeExports.jsx("div", {
style: {
pointerEvents: "none",
userSelect: "none",
position: "absolute",
width: ruler.type === "horizontal" ? "100%" : 10,
height: ruler.type === "horizontal" ? 10 : "100%",
borderStyle: "solid",
borderColor: "red",
borderWidth: 0,
borderLeftWidth: ruler.type === "horizontal" ? 0 : 1,
borderTopWidth: ruler.type === "horizontal" ? 1 : 0,
left: ruler.type === "horizontal" ? 0 : ruler.value,
top: ruler.type === "horizontal" ? ruler.value : 0,
zIndex: 1e3
}
}, key)),
renderedWidgets
]
});
if (settings && (settings.navigation || settings.navigationBar) && this.props.view === this.props.activeView) {
renderedView = this.renderNavigation(renderedView);
}
if (!this.props.visInWidget && this.props.activeView === this.props.view) {
const bgStyle = JSON.stringify(backgroundStyle);
if (!window._lastAppliedStyle || window._lastAppliedStyle !== bgStyle) {
window._lastAppliedStyle = bgStyle;
window.document.documentElement.removeAttribute("style");
Object.keys(backgroundStyle).forEach((attr) => window.document.documentElement.style[attr] = backgroundStyle[attr]);
}
window.document.documentElement.className = backgroundClass;
}
return jsxRuntimeExports.jsx(__mf_6, {
injectFirst: true,
children: jsxRuntimeExports.jsx(ThemeProvider, {
theme,
children: renderedView
})
});
}
};
class BasicGroup extends VisRxWidget {
static getWidgetInfo() {
return {
id: "_tplGroup",
visSet: "basic",
visName: "Group",
visPrev: "",
visAttrs: [
{
name: "common",
fields: []
}
]
};
}
componentDidMount() {
super.componentDidMount();
this.setState({
mounted: true
});
}
static _visAttrs(data, views, view) {
const listOfWidgets = data.members;
const attributes = [];
listOfWidgets.forEach((wid) => {
var _a;
const widgetData = (_a = views[view].widgets[wid]) == null ? void 0 : _a.data;
widgetData && Object.keys(widgetData).forEach((attr) => {
if (typeof widgetData[attr] === "string") {
let ms = widgetData[attr].match(/(groupAttr\d+)+?/g);
if (ms) {
ms.forEach((m2) => !attributes.includes(m2) && attributes.push(m2));
}
ms = widgetData[attr].match(/%([-_a-zA-Z\d]+)+?%/g);
if (ms) {
ms.forEach((m2) => {
const _attr = m2.substring(1, m2.length - 1);
!attributes.includes(_attr) && attributes.push(_attr);
});
}
}
});
});
const common = {
name: "common",
fields: [
{
name: "group_hint",
label: "group_hint",
type: "help",
text: "group_help"
}
]
};
const objects = {
name: "objects",
label: "group_fields",
fields: []
};
const groupFields = [
common,
objects
];
for (let i = 0; i < attributes.length; i++) {
const attrName = attributes[i];
const num = attrName.startsWith("groupAttr") ? parseInt(attrName.substring(9), 10) : 0;
common.fields.push({
name: attrName,
title: data[`attrName_${attrName}`] || data[`attrName${num}`] || attrName,
type: data[`attrType_${attrName}`] || data[`attrType${num}`] || ""
});
objects.fields.push({
name: `attrName_${attrName}`,
title: `${__mf_2$1.t("group_attrName")} [${attrName}]`,
type: "text"
});
objects.fields.push({
name: `attrType_${attrName}`,
title: `${__mf_2$1.t("group_attrType")} [${attrName}]`,
type: "select",
noTranslation: true,
options: [
"",
"text",
"checkbox",
"number",
"html",
"image",
"icon",
"icon64",
"id",
"color",
"views",
"widget",
"history",
"password",
"fontname",
"widget",
"groups",
"class",
"filters",
"json"
]
});
}
return groupFields;
}
getWidgetInfo() {
const info = BasicGroup.getWidgetInfo();
info.visAttrs = BasicGroup._visAttrs(this.props.context.views[this.props.view].widgets[this.props.id].data, this.props.context.views, this.props.view);
return info;
}
renderWidgetBody(props) {
var _a;
const context = this.props.context;
super.renderWidgetBody(props);
const widget = context.views[this.props.view].widgets[this.props.id];
if (this.props.id === this.props.selectedGroup) {
props.style.overflow = "visible";
}
const groupWidgets = [
...((_a = widget == null ? void 0 : widget.data) == null ? void 0 : _a.members) || []
];
let rxGroupWidgets = null;
if ((groupWidgets == null ? void 0 : groupWidgets.length) && this.state.mounted) {
groupWidgets.sort((a, b2) => {
const widgetA = context.views[this.props.view].widgets[a];
const widgetB = context.views[this.props.view].widgets[b2];
const isRelativeA = (widgetA == null ? void 0 : widgetA.style) && (widgetA.style.position === "relative" || widgetA.style.position === "static" || widgetA.style.position === "sticky");
const isRelativeB = (widgetB == null ? void 0 : widgetB.style) && (widgetB.style.position === "relative" || widgetB.style.position === "static" || widgetB.style.position === "sticky");
if (isRelativeA && isRelativeB) {
return 0;
}
if (isRelativeA) {
return -1;
}
return 1;
});
rxGroupWidgets = groupWidgets.map((id, index) => {
const _widget = context.views[this.props.view].widgets[id];
if (!_widget) {
return null;
}
const isRelative = _widget.style && (_widget.style.position === "relative" || _widget.style.position === "static" || _widget.style.position === "sticky");
return VisView.getOneWidget(index, _widget, {
selectedGroup: this.props.selectedGroup,
selectedWidgets: this.props.selectedWidgets,
context: this.props.context,
editMode: this.props.editMode,
moveAllowed: this.props.moveAllowed,
mouseDownOnView: this.props.mouseDownOnView,
index,
id,
view: this.props.view,
isRelative,
askView: this.props.askView,
refParent: props.refService,
relativeWidgetOrder: groupWidgets,
viewsActiveFilter: this.props.viewsActiveFilter,
customSettings: this.props.customSettings
});
});
}
return rxGroupWidgets;
}
}
class BasicSvgBool extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplValueBoolCtrlSvg",
visSet: "basic",
visName: "Bool SVG",
visWidgetLabel: "qui_Bool SVG",
visPrev: "widgets/basic/img/Prev_ValueBoolCtrlSvg.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "no_control",
type: "checkbox"
},
{
name: "svg_false",
type: "html",
default: "<polygon points='100,10 40,198 190,78 10,78 160,198' style='fill:lime; stroke:purple; stroke-width:5; fill-rule:nonzero' transform='scale(0.4)' />"
},
{
name: "svg_true",
type: "html",
default: "<polygon points='100,10 40,198 190,78 10,78 160,198' style='fill:yellow; stroke:red; stroke-width:5; fill-rule:nonzero' transform='scale(0.4)' />"
},
{
name: "svg_opacity",
type: "slider",
min: 0,
max: 1,
step: 0.05
}
]
}
],
visDefaultStyle: {
width: 85,
height: 85
}
};
}
getWidgetInfo() {
return BasicSvgBool.getWidgetInfo();
}
onSvgClick() {
const oid = this.state.rxData.oid;
let val = this.state.values[`${this.state.rxData.oid}.val`];
if (val === null || val === "" || val === void 0 || val === false || val === "false") {
this.props.context.setValue(oid, true);
} else if (val === true || val === "true") {
this.props.context.setValue(oid, false);
} else {
val = parseFloat(val);
if (val >= 0.5) {
val = 1;
} else {
val = 0;
}
this.props.context.setValue(oid, 1 - val);
}
}
renderSvg() {
let str = this.state.values[`${this.state.rxData.oid}.val`];
if (typeof str === "string") {
str = str.toLowerCase();
}
const val = parseFloat(str);
let opacity = this.state.rxData.svg_opacity;
if (this.props.editMode) {
if (opacity === void 0 || opacity === null || opacity === "") {
opacity = 1;
}
if (parseFloat(opacity) < 0.2) {
opacity = 0.2;
}
}
let svg;
if (val === 0 || str === "false" || str === "0" || str === "off" || str === false || str === null || str === void 0) {
svg = this.state.rxData.svg_false;
} else {
svg = this.state.rxData.svg_true;
}
return jsxRuntimeExports.jsx("svg", {
style: {
width: "100%",
height: "100%",
opacity
},
dangerouslySetInnerHTML: {
__html: svg
}
});
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
return jsxRuntimeExports.jsx("div", {
onClick: this.props.editMode ? null : () => this.onSvgClick(),
className: "vis-widget-body",
children: this.renderSvg()
});
}
}
class BasicSvgShape extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplShapes",
visSet: "basic",
visName: "SVG shape",
visPrev: "widgets/basic/img/Prev_SvgShape.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "svgType",
type: "select",
options: [
{
value: "line",
label: "basic_line"
},
{
value: "triangle",
label: "basic_triangle"
},
{
value: "square",
label: "basic_square"
},
{
value: "pentagone",
label: "basic_pentagone"
},
{
value: "hexagone",
label: "basic_hexagone"
},
{
value: "octagone",
label: "basic_octagone"
},
{
value: "circle",
label: "basic_circle"
},
{
value: "star",
label: "basic_star"
},
{
value: "arrow",
label: "basic_arrow"
},
{
value: "custom",
label: "basic_custom"
}
],
default: "circle"
},
{
name: "points",
type: "slider",
min: 3,
max: 20,
default: 3,
hidden: 'data.svgType !== "custom"'
},
{
name: "strokeColor",
type: "color",
default: "#009cb3"
},
{
name: "fill",
type: "color",
default: "#00b3ac"
},
{
name: "strokeWidth",
type: "slider",
min: 0,
max: 100,
default: 5
},
{
name: "rotate",
type: "slider",
min: 0,
max: 360,
default: 0
},
{
name: "scaleWidth",
type: "slider",
min: 0,
max: 1,
step: 0.05,
default: 1
},
{
name: "scaleHeight",
type: "slider",
min: 0,
max: 1,
step: 0.05,
default: 1
}
]
}
],
visDefaultStyle: {
width: 100,
height: 100
}
};
}
getWidgetInfo() {
return BasicSvgShape.getWidgetInfo();
}
static circlePoints(radius, num, step) {
step = step || 360 / num;
let text = "";
const radian = Math.PI / 180;
for (let i = 0; i < num; i++) {
const angle = radian * (i * step - 180);
const point = {
x: Math.sin(angle) * radius,
y: Math.cos(angle) * radius
};
text += `${point.x}, ${point.y} `;
}
return text;
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
let svg = null;
const rotate = Number(this.state.rxData.rotate) || 0;
const scaleWidth = Number(this.state.rxData.scaleWidth) || 1;
const scaleHeight = Number(this.state.rxData.scaleHeight) || 1;
const strokeWidth = Number(this.state.rxData.strokeWidth) || 0;
const transform = `rotate(${rotate}) scale(${scaleWidth}, ${scaleHeight})`;
if (this.state.rxData.svgType === "triangle") {
svg = jsxRuntimeExports.jsx("polygon", {
transform,
points: BasicSvgShape.circlePoints(50 - strokeWidth, 3)
});
} else if (this.state.rxData.svgType === "line") {
svg = jsxRuntimeExports.jsx("line", {
vectorEffect: "non-scaling-stroke",
transform: `rotate(${rotate})`,
x1: "-50",
y1: "0",
x2: "50",
y2: "0"
});
} else if (this.state.rxData.svgType === "circle") {
svg = jsxRuntimeExports.jsx("circle", {
transform,
cx: "0",
cy: "0",
r: 50 - strokeWidth / 2
});
} else if (this.state.rxData.svgType === "pentagone") {
svg = jsxRuntimeExports.jsx("polygon", {
transform,
points: BasicSvgShape.circlePoints(50 - strokeWidth, 5)
});
} else if (this.state.rxData.svgType === "square") {
svg = jsxRuntimeExports.jsx("polygon", {
transform,
points: BasicSvgShape.circlePoints(50 - strokeWidth, 4)
});
} else if (this.state.rxData.svgType === "hexagone") {
svg = jsxRuntimeExports.jsx("polygon", {
transform,
points: BasicSvgShape.circlePoints(50 - strokeWidth, 6)
});
} else if (this.state.rxData.svgType === "octagone") {
svg = jsxRuntimeExports.jsx("polygon", {
transform,
points: BasicSvgShape.circlePoints(50 - strokeWidth, 8)
});
} else if (this.state.rxData.svgType === "custom") {
svg = jsxRuntimeExports.jsx("polygon", {
transform,
points: BasicSvgShape.circlePoints(50 - strokeWidth, Number(this.state.rxData.points) || 3)
});
} else if (this.state.rxData.svgType === "star") {
svg = jsxRuntimeExports.jsx("polygon", {
transform,
points: BasicSvgShape.circlePoints(50 - strokeWidth, 5, 144)
});
} else if (this.state.rxData.svgType === "arrow") {
svg = jsxRuntimeExports.jsx("polygon", {
transform: `${transform} translate(0,10)`,
points: "0, -50 -43.3, 25 0,0 43.3, 25"
});
}
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsx("svg", {
xmlns: "http://www.w3.org/2000/svg",
version: "1.1",
viewBox: "-50 -50 100 100",
style: {
display: "block",
width: "100%",
height: "100%",
fill: this.state.rxData.fill,
stroke: this.state.rxData.strokeColor,
strokeWidth: this.state.rxData.strokeWidth
},
children: svg
})
});
}
}
class BasicScreenResolution extends VisRxWidget {
essentialData;
constructor(props) {
super(props);
this.state = {
...this.state,
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight
};
this.essentialData = JSON.stringify(this.buildEssentialProjectData());
}
buildEssentialProjectData() {
return Object.keys(this.props.context.views).sort().filter((f2) => f2 !== "___settings").map((viewId) => {
var _a, _b, _c, _d, _e, _f;
return {
id: viewId,
sizex: (_b = (_a = this.props.context.views[viewId]) == null ? void 0 : _a.settings) == null ? void 0 : _b.sizex,
sizey: (_d = (_c = this.props.context.views[viewId]) == null ? void 0 : _c.settings) == null ? void 0 : _d.sizey,
useAsDefault: (_f = (_e = this.props.context.views[viewId]) == null ? void 0 : _e.settings) == null ? void 0 : _f.useAsDefault
};
});
}
static getWidgetInfo() {
return {
id: "tplScreenResolution",
visSet: "basic",
visName: "Screen Resolution",
visPrev: "widgets/basic/img/Prev_ScreenResolution.png",
visAttrs: [],
visDefaultStyle: {
width: 170,
height: 75
}
};
}
componentDidMount() {
super.componentDidMount();
window.addEventListener("resize", this.onResize);
window.addEventListener("hashchange", this.onResize);
this.onResize();
}
componentWillUnmount() {
super.componentWillUnmount();
window.removeEventListener("resize", this.onResize);
window.removeEventListener("hashchange", this.onResize);
}
getWidgetInfo() {
return BasicScreenResolution.getWidgetInfo();
}
createScreenText() {
return jsxRuntimeExports.jsx("span", {
style: {
fontWeight: "bold",
cursor: "pointer"
},
onClick: () => {
if (!window.vis.instance) {
window.vis.generateInstance();
if (window.vis.instance) {
this.forceUpdate();
} else {
window.alert("Cannot generate!");
}
}
},
children: __mf_2$1.t("click to create")
});
}
onResize = () => {
var _a, _b, _c, _d;
let width;
let height;
let defaultView;
if (this.props.editMode) {
width = ((_b = (_a = this.props.context.views[this.props.context.activeView]) == null ? void 0 : _a.settings) == null ? void 0 : _b.sizex) || window.document.documentElement.clientWidth;
height = ((_d = (_c = this.props.context.views[this.props.context.activeView]) == null ? void 0 : _c.settings) == null ? void 0 : _d.sizey) || window.document.documentElement.clientHeight;
defaultView = window.vis.findNearestResolution(width, height);
} else {
width = document.documentElement.clientWidth || 0;
height = document.documentElement.clientHeight;
defaultView = window.vis.findNearestResolution();
}
this.setState({
width,
height,
defaultView
});
};
renderWidgetBody(props) {
super.renderWidgetBody(props);
const state = this.state;
const essentialData = JSON.stringify(this.buildEssentialProjectData());
if (essentialData !== this.essentialData) {
this.essentialData = essentialData;
setTimeout(() => this.onResize(), 100);
}
const style2 = {
border: "1px solid #888",
fontSize: 12,
opacity: 0.8,
width: "100%",
height: "100%",
boxSizing: "border-box",
padding: 10,
display: "flex",
flexDirection: "column",
overflow: "hidden",
justifyContent: "center"
};
const valueStyle = {
marginLeft: 8,
fontWeight: "bold"
};
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
style: style2,
children: [
jsxRuntimeExports.jsxs("div", {
children: [
__mf_2$1.t("Default view"),
":",
jsxRuntimeExports.jsx("span", {
style: valueStyle,
children: state.defaultView
})
]
}),
jsxRuntimeExports.jsxs("div", {
children: [
__mf_2$1.t("Width"),
":",
jsxRuntimeExports.jsxs("span", {
style: valueStyle,
children: [
state.width,
"px"
]
})
]
}),
jsxRuntimeExports.jsxs("div", {
children: [
__mf_2$1.t("Height"),
":",
jsxRuntimeExports.jsxs("span", {
style: valueStyle,
children: [
state.height,
"px"
]
})
]
}),
jsxRuntimeExports.jsxs("div", {
children: [
__mf_2$1.t("Instance"),
":",
jsxRuntimeExports.jsx("span", {
style: valueStyle,
children: window.vis.instance || this.createScreenText()
})
]
})
]
});
}
}
class BasicSpeechToText extends VisRxWidget {
recognition;
ignoreOnEnd = false;
componentDidMount() {
super.componentDidMount();
this.setState({
text: !window.webkitSpeechRecognition ? __mf_2$1.t("basic_speech2text_info_upgrade") : "",
image: this.state.rxData.imageInactive,
result: "",
resultColor: this.state.rxData.keyWordColor
});
if (!window.webkitSpeechRecognition) {
return;
}
if (this.state.rxData.speechMode === "continuous" && !this.state.editMode) {
this.startRecognition();
} else {
this.setState({
text: __mf_2$1.t("basic_speech2text_info_start")
});
}
}
getWidgetInfo() {
return BasicSpeechToText.getWidgetInfo();
}
static getWidgetInfo() {
return {
id: "tplSpeech2Text",
visSet: "basic",
visName: "Speech to Text",
visPrev: "widgets/basic/img/Prev_Speech2Text.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "speechMode",
type: "select",
default: "single",
options: [
{
value: "single",
label: "basic_speech2text_single"
},
{
value: "startstop",
label: "basic_speech2text_start_stop"
},
{
value: "continuous",
label: "basic_speech2text_continuous"
}
]
},
{
name: "language",
type: "select",
options: [
{
value: "",
label: ""
},
{
value: "en-US",
label: "basic_speech2text_en_us"
},
{
value: "de",
label: "de"
},
{
value: "ru-RU",
label: "basic_speech2text_ru_ru"
}
]
},
{
name: "keywords"
}
]
},
{
name: "image",
label: "Image",
fields: [
{
name: "noImage",
type: "checkbox",
label: "basic_speech2text_no_image"
},
{
name: "imageInactive",
default: "widgets/basic/img/micInactive.svg",
type: "image",
label: "basic_speech2text_image_inactive"
},
{
name: "imageActive",
default: "widgets/basic/img/micActive.svg",
type: "image",
label: "basic_speech2text_image_active"
},
{
name: "imageStarted",
default: "widgets/basic/img/micStarted.svg",
type: "image",
label: "basic_speech2text_started"
},
{
name: "imageDetected",
default: "widgets/basic/img/micDetected.svg",
type: "image",
label: "basic_speech2text_detected"
},
{
name: "imageSent",
default: "widgets/basic/img/micSent.svg",
type: "image",
label: "basic_speech2text_sent"
},
{
name: "imageHeightPx",
default: 70,
type: "slider",
min: 0,
max: 200,
step: 1,
label: "basic_speech2text_height"
},
{
name: "imageWidthPx",
default: 70,
type: "slider",
min: 0,
max: 200,
step: 1,
label: "basic_speech2text_width"
}
]
},
{
name: "text",
label: "Text",
fields: [
{
name: "noText",
type: "checkbox",
label: "basic_speech2text_no_text"
},
{
name: "noResults",
type: "checkbox",
label: "basic_speech2text_no_results"
},
{
name: "keyWordColor",
type: "color",
default: "#FFB051",
label: "basic_speech2text_key_word_color",
tooltip: "basic_speech2text_key_word_color_tooltip"
},
{
name: "textSentColor",
type: "color",
default: "#7E88D3",
label: "basic_speech2text_text_sent_color",
tooltip: "basic_speech2text_text_sent_color_tooltip"
}
]
}
],
visDefaultStyle: {
width: 500,
height: 77
}
};
}
findKeyWord(text) {
const words = this.state.rxData.keywords ? this.state.rxData.keywords.toLowerCase().split(/[\s,;]+/g) : null;
let found = false;
if (words) {
const wwords = text.toLowerCase().split(" ");
for (let w2 = 0; w2 < words.length; w2++) {
const pos = wwords.indexOf(words[w2]);
if (pos !== -1) {
let offset2 = 0;
for (let p2 = 0; p2 < pos; p2++) {
offset2 += wwords[p2].length + 1;
}
text = `${text.substring(0, offset2)}<b>${text.substring(offset2, offset2 + wwords[pos].length)}</b>${text.substring(offset2 + wwords[pos].length)}`;
found = true;
break;
}
}
} else {
return true;
}
return found ? text : false;
}
startRecognition() {
if (this.recognition) {
if (this.state.rxData.speechMode === "startstop") {
this.recognition.onend = null;
this.recognition.stop();
this.recognition = null;
this.setState({
text: __mf_2$1.t("basic_speech2text_info_start"),
image: this.state.rxData.imageInactive
});
}
return;
}
this.recognition = new window.webkitSpeechRecognition();
this.recognition.continuous = this.state.rxData.speechMode === "continuous" || this.state.rxData.speechMode === "startstop";
this.recognition.interimResults = true;
this.recognition.maxAlternatives = 1;
const startTimestamp = Date.now();
let finalTranscript = "";
let timer;
let lastText = "";
let originalColor;
this.recognition.onstart = () => {
this.setState({
text: __mf_2$1.t("basic_speech2text_info_speak_now"),
image: this.state.rxData.imageActive,
result: ""
});
};
this.recognition.onerror = (event) => {
this.setState({
result: "",
image: this.state.rxData.imageInactive
});
if (event.error === "no-speech") {
this.setState({
text: __mf_2$1.t("basic_speech2text_info_no_speech")
});
}
if (event.error === "audio-capture") {
this.setState({
text: __mf_2$1.t("basic_speech2text_info_no_microphone")
});
this.ignoreOnEnd = true;
}
if (event.error === "not-allowed") {
if (event.timeStamp - startTimestamp < 100) {
this.setState({
text: __mf_2$1.t("basic_speech2text_info_blocked")
});
} else {
this.setState({
text: __mf_2$1.t("basic_speech2text_info_denied")
});
}
this.ignoreOnEnd = true;
}
};
this.recognition.onend = () => {
this.recognition.stop();
this.recognition = null;
if (!this.ignoreOnEnd) {
setTimeout(() => {
this.setState({
image: this.state.rxData.imageInactive
});
if (this.state.rxData.speechMode === "continuous") {
this.setState({
result: "",
text: __mf_2$1.t("basic_speech2text_info_speak_now")
});
this.startRecognition();
} else {
this.setState({
result: "",
text: __mf_2$1.t("basic_speech2text_info_start")
});
}
}, 1e3);
}
};
this.recognition.onresult = (event) => {
let interimTranscript = "";
if (typeof event.results === "undefined") {
this.recognition.onend = null;
this.recognition.stop();
return;
}
for (let i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
finalTranscript += event.results[i][0].transcript;
} else {
interimTranscript += event.results[i][0].transcript;
}
}
if (this.state.image === this.state.rxData.imageActive) {
this.setState({
image: this.state.rxData.imageStarted
});
}
this.setState({
text: ""
});
let text = finalTranscript || interimTranscript;
const foundKeyword = this.findKeyWord(text);
if (!originalColor) {
originalColor = this.state.resultColor;
}
if (foundKeyword) {
text = typeof foundKeyword === "string" ? foundKeyword : text;
if (this.state.image === this.state.rxData.imageStarted) {
this.setState({
image: this.state.rxData.imageDetected
});
}
if (this.state.rxData.keyWordColor) {
this.setState({
resultColor: this.state.rxData.keyWordColor
});
}
}
this.setState({
text
});
if (finalTranscript) {
if (timer) {
clearTimeout(timer);
}
if (foundKeyword) {
this.setState({
image: this.state.rxData.imageSent
});
if (this.state.rxData.textSentColor) {
this.setState({
resultColor: this.state.rxData.textSentColor
});
}
this.props.context.setValue(this.state.rxData.oid, finalTranscript);
}
finalTranscript = "";
lastText = "";
setTimeout(() => {
this.setState({
image: this.state.rxData.imageActive,
text: __mf_2$1.t("basic_speech2text_info_speak_now"),
resultColor: originalColor,
result: ""
});
}, 1e3);
} else {
lastText = interimTranscript;
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
this.recognition.onend = null;
this.recognition.stop();
this.recognition = null;
const hasKeyword = !!this.findKeyWord(lastText);
if (hasKeyword) {
this.setState({
image: this.state.rxData.imageSent
});
if (this.state.rxData.textSentColor) {
this.setState({
resultColor: this.state.rxData.textSentColor
});
}
this.props.context.setValue(this.state.rxData.oid, finalTranscript);
}
finalTranscript = "";
lastText = "";
setTimeout(() => {
this.setState({
image: this.state.rxData.imageActive,
text: __mf_2$1.t("basic_speech2text_info_speak_now"),
resultColor: originalColor,
result: ""
});
this.startRecognition();
}, 1e3);
}, 3e3);
}
};
this.recognition.lang = this.state.rxData.language;
this.recognition.start();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsx("table", {
style: {
height: "100%",
width: "100%"
},
onClick: () => {
if (this.state.rxData.speechMode !== "continuous" && !this.state.editMode && window.webkitSpeechRecognition) {
this.startRecognition();
}
},
children: jsxRuntimeExports.jsx("tbody", {
children: jsxRuntimeExports.jsxs("tr", {
children: [
jsxRuntimeExports.jsx("td", {
style: {
display: this.state.rxData.noImage ? "none" : void 0
},
children: jsxRuntimeExports.jsx(__mf_15$1, {
alt: "mic",
style: {
height: `${this.state.rxData.imageHeightPx}px`,
width: `${this.state.rxData.imageWidthPx}px`
},
src: this.state.image
})
}),
jsxRuntimeExports.jsxs("td", {
className: "mic-text",
style: {
width: "100%"
},
children: [
jsxRuntimeExports.jsx("div", {
style: {
display: this.state.rxData.noText ? "none" : void 0
},
dangerouslySetInnerHTML: {
__html: this.state.text
}
}),
jsxRuntimeExports.jsx("div", {
style: {
display: this.state.rxData.noResults ? "none" : void 0,
color: this.state.resultColor
},
dangerouslySetInnerHTML: {
__html: this.state.result
}
})
]
})
]
})
})
})
});
}
}
class BasicIFrame extends VisRxWidget {
refreshInterval = null;
frameRef;
hashInstalled = false;
onWakeUpInstalled = false;
startedInterval = 0;
constructor(props) {
super(props);
this.frameRef = React.createRef();
}
static getWidgetInfo() {
return {
id: "tplIFrame",
visSet: "basic",
visName: "iFrame",
visPrev: "widgets/basic/img/Prev_iFrame.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "src",
type: "url"
},
{
name: "refreshInterval",
tooltip: "basic_refreshInterval_tooltip",
type: "slider",
min: 0,
max: 18e4,
step: 100,
default: 0
},
{
name: "noSandbox",
type: "checkbox"
},
{
name: "refreshOnWakeUp",
type: "checkbox"
},
{
name: "refreshOnViewChange",
type: "checkbox"
},
{
name: "refreshWithNoQuery",
type: "checkbox"
},
{
name: "scrollX",
type: "checkbox"
},
{
name: "scrollY",
type: "checkbox"
},
{
name: "seamless",
type: "checkbox",
default: true
}
]
}
],
visDefaultStyle: {
width: 600,
height: 320
}
};
}
componentDidMount() {
super.componentDidMount();
this.onPropertyUpdate();
}
componentWillUnmount() {
super.componentWillUnmount();
if (this.refreshInterval) {
clearInterval(this.refreshInterval);
this.refreshInterval = null;
}
if (this.hashInstalled) {
this.hashInstalled = false;
window.removeEventListener("hashchange", this.onHashChange);
}
}
getWidgetInfo() {
return BasicIFrame.getWidgetInfo();
}
onHashChange = () => {
if (this.props.context.activeView === this.props.view) {
this.refreshIFrame();
}
};
refreshIFrame() {
var _a, _b;
if (this.state.rxData.refreshWithNoQuery === true) {
(_b = (_a = this.frameRef.current) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.location.reload();
} else if (this.frameRef.current) {
this.frameRef.current.src = `${this.state.rxData.src}${this.state.rxData.src.includes("?") ? "&" : "?"}_refts=${Date.now()}`;
}
}
static isHidden(el) {
return el.offsetParent === null;
}
static getParents(el) {
const els = [];
let pel = el;
do {
pel = pel.parentNode;
els.unshift(el);
} while (pel);
return els;
}
onPropertyUpdate() {
const src = this.state.rxData.src || "";
const refreshInterval = Number(this.state.rxData.refreshInterval) || 0;
const refreshOnViewChange = this.state.rxData.refreshOnViewChange === true;
const refreshOnWakeUp = this.state.rxData.refreshOnWakeUp === true;
if (src) {
if (refreshOnViewChange) {
if (!this.hashInstalled) {
this.hashInstalled = true;
window.addEventListener("hashchange", this.onHashChange);
}
} else if (this.hashInstalled) {
this.hashInstalled = false;
window.removeEventListener("hashchange", this.onHashChange);
}
if (refreshInterval > 0) {
if (this.startedInterval !== refreshInterval) {
this.startedInterval = refreshInterval;
this.refreshInterval && clearInterval(this.refreshInterval);
this.refreshInterval = null;
}
this.refreshInterval = this.refreshInterval || setInterval(() => {
if (this.frameRef.current && !BasicIFrame.isHidden(this.frameRef.current)) {
const parents = BasicIFrame.getParents(this.frameRef.current).filter((el) => BasicIFrame.isHidden(el));
if (!parents.length || parents[0].tagName === "BODY" || parents[0].id === "materialdesign-vuetify-container") {
this.refreshIFrame();
}
}
}, refreshInterval);
} else if (this.refreshInterval) {
this.startedInterval = 0;
clearInterval(this.refreshInterval);
this.refreshInterval = null;
}
if (refreshOnWakeUp) {
if (!this.onWakeUpInstalled) {
this.onWakeUpInstalled = true;
window.vis.onWakeUp(this.onHashChange, this.props.id);
}
} else if (this.onWakeUpInstalled) {
this.onWakeUpInstalled = false;
window.vis.onWakeUp(null, this.props.id);
}
}
}
onRxDataChanged() {
this.onPropertyUpdate();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (this.props.editMode) {
props.overlayClassNames.push("vis-editmode-helper");
}
const style2 = {
position: "absolute",
boxSizing: "border-box",
padding: 0,
margin: 0,
border: 0,
width: "100%",
height: "100%",
overflowX: this.state.rxData.scrollX ? "scroll" : "hidden",
overflowY: this.state.rxData.scrollY ? "scroll" : "hidden"
};
const src = this.state.rxData.src || "";
return src ? jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsx("iframe", {
style: style2,
ref: this.frameRef,
title: this.props.id,
src: this.state.rxData.src,
sandbox: this.state.rxData.noSandbox ? "allow-modals allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts" : void 0,
seamless: this.state.rxData.seamless
})
}) : null;
}
}
class BasicIFrame8 extends VisRxWidget {
refreshInterval = null;
frameRef;
hashInstalled = false;
onWakeUpInstalled = false;
startedInterval = 0;
constructor(props) {
super(props);
this.frameRef = React.createRef();
}
static getWidgetInfo() {
return {
id: "tplStatefulIFrame8",
visSet: "basic",
visName: "iFrame 8",
visPrev: "widgets/basic/img/Prev_StatefulIFrame8.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "refreshInterval",
tooltip: "basic_refreshInterval_tooltip",
type: "slider",
min: 0,
max: 18e4,
step: 100,
default: 0
},
{
name: "refreshOnWakeUp",
type: "checkbox"
},
{
name: "refreshOnViewChange",
type: "checkbox"
},
{
name: "refreshWithNoQuery",
type: "checkbox"
},
{
name: "scrollX",
type: "checkbox"
},
{
name: "scrollY",
type: "checkbox"
},
{
name: "seamless",
type: "checkbox",
default: true
},
{
name: "count",
type: "slider",
min: 1,
max: 20,
default: 2
}
]
},
{
name: "frames",
label: "frames",
indexFrom: 0,
indexTo: "count",
fields: [
{
name: "src_",
type: "id"
},
{
name: "noSandbox",
type: "checkbox"
}
]
}
],
visDefaultStyle: {
width: 600,
height: 320
}
};
}
componentDidMount() {
super.componentDidMount();
this.onPropertyUpdate();
}
componentWillUnmount() {
super.componentWillUnmount();
this.refreshInterval && clearInterval(this.refreshInterval);
if (this.hashInstalled) {
this.hashInstalled = false;
window.removeEventListener("hashchange", this.onHashChange);
}
}
getWidgetInfo() {
return BasicIFrame8.getWidgetInfo();
}
getSrc() {
const value = this.state.values[`${this.state.rxData.oid}.val`];
if (value === void 0 || value === null) {
return this.state.rxData.src_1;
}
return this.state.rxData[`src_${value}`] || "";
}
getNoSandBox() {
const value = this.state.values[`${this.state.rxData.oid}.val`];
if (value === void 0 || value === null) {
return this.state.rxData.noSandbox1;
}
return this.state.rxData[`noSandbox${value}`] === true || this.state.rxData[`noSandbox${value}`] === "true";
}
onHashChange = () => {
if (this.props.context.activeView === this.props.view) {
this.refreshIFrame();
}
};
refreshIFrame() {
var _a, _b;
if (this.state.rxData.refreshWithNoQuery === true) {
(_b = (_a = this.frameRef.current) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.location.reload();
} else if (this.frameRef.current) {
const src = this.getSrc();
this.frameRef.current.src = `${src}${src.includes("?") ? "&" : "?"}_refts=${Date.now()}`;
}
}
static isHidden(el) {
return el.offsetParent === null;
}
static getParents(el) {
const els = [];
let pel = el;
do {
pel = pel.parentNode;
els.unshift(el);
} while (pel);
return els;
}
onPropertyUpdate() {
const src = this.getSrc();
const refreshInterval = Number(this.state.rxData.refreshInterval) || 0;
const refreshOnViewChange = this.state.rxData.refreshOnViewChange === true;
const refreshOnWakeUp = this.state.rxData.refreshOnWakeUp === true;
if (src) {
if (refreshOnViewChange) {
if (!this.hashInstalled) {
this.hashInstalled = true;
window.addEventListener("hashchange", this.onHashChange);
}
} else if (this.hashInstalled) {
this.hashInstalled = false;
window.removeEventListener("hashchange", this.onHashChange);
}
if (refreshInterval > 0) {
if (this.startedInterval !== refreshInterval) {
this.startedInterval = refreshInterval;
this.refreshInterval && clearInterval(this.refreshInterval);
this.refreshInterval = null;
}
this.refreshInterval = this.refreshInterval || setInterval(() => {
if (this.frameRef.current && !BasicIFrame8.isHidden(this.frameRef.current)) {
const parents = BasicIFrame8.getParents(this.frameRef.current).filter((el) => BasicIFrame8.isHidden(el));
if (!parents.length || parents[0].tagName === "BODY" || parents[0].id === "materialdesign-vuetify-container") {
this.refreshIFrame();
}
}
}, refreshInterval);
} else if (this.refreshInterval) {
this.startedInterval = 0;
clearInterval(this.refreshInterval);
this.refreshInterval = null;
}
if (refreshOnWakeUp) {
if (!this.onWakeUpInstalled) {
this.onWakeUpInstalled = true;
window.vis.onWakeUp(this.onHashChange, this.props.id);
}
} else if (this.onWakeUpInstalled) {
this.onWakeUpInstalled = false;
window.vis.onWakeUp(null, this.props.id);
}
}
}
onRxDataChanged() {
this.onPropertyUpdate();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (this.props.editMode) {
props.overlayClassNames.push("vis-editmode-helper");
}
const style2 = {
position: "absolute",
boxSizing: "border-box",
padding: 0,
margin: 0,
border: 0,
width: "100%",
height: "100%",
overflowX: this.state.rxData.scrollX ? "scroll" : "hidden",
overflowY: this.state.rxData.scrollY ? "scroll" : "hidden"
};
const src = this.getSrc();
const noSandbox = this.getNoSandBox();
return src ? jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsx("iframe", {
style: style2,
ref: this.frameRef,
title: this.props.id,
src,
sandbox: noSandbox ? "allow-modals allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts" : void 0,
seamless: this.state.rxData.seamless
})
}) : null;
}
}
class BasicImageGeneric extends VisRxWidget {
refreshInterval = null;
imageRef = React.createRef();
hashInstalled = false;
onWakeUpInstalled = false;
startedInterval = 0;
constructor(props) {
super(props);
}
componentDidMount() {
super.componentDidMount();
this.onPropertyUpdate();
}
componentWillUnmount() {
super.componentWillUnmount();
if (this.refreshInterval) {
clearInterval(this.refreshInterval);
}
if (this.hashInstalled) {
this.hashInstalled = false;
window.removeEventListener("hashchange", this.onHashChange);
}
}
onHashChange = () => {
if (this.props.context.activeView === this.props.view) {
this.refreshImage();
}
};
refreshImage() {
if (this.imageRef.current) {
const str = this.getImage();
if (this.state.rxData.refreshWithNoQuery === true) {
this.imageRef.current.src = str;
} else {
this.imageRef.current.src = `${str}${str.includes("?") ? "&" : "?"}_refts=${Date.now()}`;
}
}
}
static isHidden(el) {
return el.offsetParent === null;
}
static getParents(el) {
const els = [];
let pel = el;
do {
pel = pel.parentNode;
els.unshift(el);
} while (pel);
return els;
}
onPropertyUpdate() {
const src = this.getImage();
const refreshInterval = Number(this.state.rxData.refreshInterval) || 0;
const refreshOnViewChange = this.state.rxData.refreshOnViewChange === true;
const refreshOnWakeUp = this.state.rxData.refreshOnWakeUp === true;
if (src) {
if (refreshOnViewChange) {
if (!this.hashInstalled) {
this.hashInstalled = true;
window.addEventListener("hashchange", this.onHashChange);
}
} else if (this.hashInstalled) {
this.hashInstalled = false;
window.removeEventListener("hashchange", this.onHashChange);
}
if (refreshInterval > 0) {
if (this.startedInterval !== refreshInterval) {
this.startedInterval = refreshInterval;
if (this.refreshInterval) {
clearInterval(this.refreshInterval);
this.refreshInterval = null;
}
}
this.refreshInterval || (this.refreshInterval = setInterval(() => {
if (this.imageRef.current && !BasicImageGeneric.isHidden(this.imageRef.current)) {
const parents = BasicImageGeneric.getParents(this.imageRef.current).filter((el) => BasicImageGeneric.isHidden(el));
if (!parents.length || parents[0].tagName === "BODY" || parents[0].id === "materialdesign-vuetify-container") {
this.refreshImage();
}
}
}, refreshInterval));
} else if (this.refreshInterval) {
this.startedInterval = 0;
clearInterval(this.refreshInterval);
this.refreshInterval = null;
}
if (refreshOnWakeUp) {
if (!this.onWakeUpInstalled) {
this.onWakeUpInstalled = true;
window.vis.onWakeUp(this.onHashChange, this.props.id);
}
} else if (this.onWakeUpInstalled) {
this.onWakeUpInstalled = false;
window.vis.onWakeUp(null, this.props.id);
}
}
}
onRxDataChanged() {
this.onPropertyUpdate();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (this.props.editMode) {
props.overlayClassNames.push("vis-editmode-helper");
} else if (!this.state.rxData.allowUserInteractions) {
props.style.pointerEvents = "none";
props.style.userSelect = "none";
props.style.touchAction = "none";
}
const style2 = {
padding: 0,
margin: 0,
border: 0,
width: "100%",
height: "auto"
};
if (this.state.rxData.stretch) {
style2.height = "100%";
}
if (!this.state.rxData.allowUserInteractions) {
style2.touchAction = "none";
style2.userSelect = "none";
style2.pointerEvents = "none";
}
const src = this.getImage();
return src ? jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
style: {
overflow: "hidden",
pointerEvents: this.state.rxData.allowUserInteractions ? void 0 : "none",
touchAction: this.state.rxData.allowUserInteractions ? void 0 : "none",
userSelect: this.state.rxData.allowUserInteractions ? void 0 : "none"
},
children: jsxRuntimeExports.jsx(__mf_15$1, {
style: style2,
ref: this.imageRef,
src,
alt: this.props.id
})
}) : null;
}
}
class BasicImage extends BasicImageGeneric {
static getWidgetInfo() {
return {
id: "tplImage",
visSet: "basic",
visName: "Image",
visPrev: "widgets/basic/img/Prev_Image.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "src",
type: "image"
},
{
name: "stretch",
type: "checkbox"
},
{
name: "refreshInterval",
tooltip: "basic_refreshInterval_tooltip",
type: "slider",
min: 0,
max: 18e4,
step: 100,
default: 0
},
{
name: "refreshOnWakeUp",
type: "checkbox"
},
{
name: "refreshOnViewChange",
type: "checkbox"
},
{
name: "refreshWithNoQuery",
type: "checkbox"
},
{
name: "allowUserInteractions",
type: "checkbox"
}
]
}
],
visDefaultStyle: {
width: 200,
height: 130
}
};
}
getWidgetInfo() {
return BasicImage.getWidgetInfo();
}
getImage() {
return this.state.rxData.src || "";
}
}
class BasicHtmlNav extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplHtmlNav",
visSet: "basic",
visName: "HTML navigation",
visPrev: "widgets/basic/img/Prev_HTMLnavigation.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "html",
type: "html"
},
{
name: "nav_view",
type: "views"
},
{
name: "sub_view",
label: "basic_sub_view",
type: "text",
tooltip: "sub_view_tooltip",
hidden: "!data.nav_view"
}
]
}
],
visDefaultStyle: {
width: 200,
height: 130
}
};
}
getWidgetInfo() {
return BasicHtmlNav.getWidgetInfo();
}
onNavigate = () => {
if (this.state.rxData.nav_view) {
this.props.context.changeView((this.state.rxData.nav_view || "").toString(), this.state.rxData.sub_view ? this.state.rxData.sub_view.toString() : void 0);
}
};
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (props.style.width === void 0) {
props.style.width = 200;
}
if (props.style.height === void 0) {
props.style.height = 130;
}
return jsxRuntimeExports.jsx(DangerousHtmlWithScript, {
className: "vis-widget-body",
html: (this.state.rxData.html || "").toString(),
isDiv: true,
wid: this.props.id,
onClick: this.props.editMode ? null : this.onNavigate
});
}
}
const byteToHex = [];
for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 256).toString(16).slice(1));
}
function unsafeStringify(arr, offset2 = 0) {
return (byteToHex[arr[offset2 + 0]] + byteToHex[arr[offset2 + 1]] + byteToHex[arr[offset2 + 2]] + byteToHex[arr[offset2 + 3]] + "-" + byteToHex[arr[offset2 + 4]] + byteToHex[arr[offset2 + 5]] + "-" + byteToHex[arr[offset2 + 6]] + byteToHex[arr[offset2 + 7]] + "-" + byteToHex[arr[offset2 + 8]] + byteToHex[arr[offset2 + 9]] + "-" + byteToHex[arr[offset2 + 10]] + byteToHex[arr[offset2 + 11]] + byteToHex[arr[offset2 + 12]] + byteToHex[arr[offset2 + 13]] + byteToHex[arr[offset2 + 14]] + byteToHex[arr[offset2 + 15]]).toLowerCase();
}
let getRandomValues;
const rnds8 = new Uint8Array(16);
function rng() {
if (!getRandomValues) {
if (typeof crypto === "undefined" || !crypto.getRandomValues) {
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
}
getRandomValues = crypto.getRandomValues.bind(crypto);
}
return getRandomValues(rnds8);
}
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
const native = {
randomUUID
};
function _v4(options, buf, offset2) {
var _a;
options = options || {};
const rnds = options.random ?? ((_a = options.rng) == null ? void 0 : _a.call(options)) ?? rng();
if (rnds.length < 16) {
throw new Error("Random bytes length must be >= 16");
}
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
return unsafeStringify(rnds);
}
v4 = function(options, buf, offset2) {
if (native.randomUUID && true && !options) {
return native.randomUUID();
}
return _v4(options);
};
const styles$2 = {
handlerCell: {
alignItems: "center",
whiteSpace: "nowrap",
padding: "1px 4px",
verticalAlign: "middle"
},
grab: {
marginRight: 4,
marginTop: 12
},
index: {
display: "inline-block",
verticalAlign: "top",
marginTop: 15
},
cell: {
padding: "1px 4px",
verticalAlign: "bottom"
},
cellText: {
padding: "12px 4px 0px 4px"
},
cellImage: {
padding: "0px 4px",
verticalAlign: "bottom"
},
cellButton: {
padding: "0px 4px"
},
rowEven: (theme) => ({
backgroundColor: theme.palette.mode === "dark" ? "rgba(255, 255, 255, 0.04)" : "rgba(0, 0, 0, 0.04)"
})
};
class FiltersEditorDialog extends __mf_1 {
originalItems;
constructor(props) {
var _a;
super(props);
const items = (props.items || []).map((item) => ({
...item,
id: v4()
}));
this.state = {
filters: ((_a = window.vis) == null ? void 0 : _a.updateFilter()) || [],
items,
applyItems: JSON.stringify(props.items || []),
selectIcon: null,
selectImage: null,
anchorEl: null
};
this.originalItems = this.state.applyItems;
}
updateItems(items) {
const applyItems = JSON.parse(JSON.stringify(items));
applyItems.forEach((item) => delete item.id);
this.setState({
items,
applyItems: JSON.stringify(applyItems)
});
}
renderSelectIconDialog() {
if (this.state.selectIcon === null) {
return null;
}
return jsxRuntimeExports.jsx(MaterialIconSelector, {
themeType: this.props.context.theme.palette.mode,
theme: this.props.context.theme,
value: this.state.items[this.state.selectIcon],
additionalSets: this.props.context.additionalSets,
onClose: (icon) => {
if (icon !== null) {
const items = JSON.parse(JSON.stringify(this.state.items));
items[this.state.selectIcon].icon = icon;
this.updateItems(items);
}
this.setState({
selectIcon: null
});
}
});
}
renderFilterSelector() {
if (!this.state.anchorEl) {
return null;
}
const filters = this.state.filters.filter((filter) => !this.state.items.find((item) => item.value === filter));
return jsxRuntimeExports.jsxs(__mf_71, {
anchorEl: this.state.anchorEl,
open: true,
onClose: () => this.setState({
anchorEl: null
}),
children: [
filters == null ? void 0 : filters.map((filter) => jsxRuntimeExports.jsx(__mf_72, {
onClick: () => {
const items = JSON.parse(JSON.stringify(this.state.items));
items.push({
label: filter,
value: filter,
id: v4()
});
this.setState({
anchorEl: null
}, () => this.updateItems(items));
},
value: filter,
children: filter
}, filter)),
jsxRuntimeExports.jsx(__mf_72, {
sx: (theme) => ({
color: theme.palette.primary.main
}),
onClick: () => {
const items = JSON.parse(JSON.stringify(this.state.items));
items.push({
label: "",
value: "",
id: v4()
});
this.setState({
anchorEl: null
}, () => this.updateItems(items));
},
children: __mf_2$1.t("Custom")
}),
filters.length > 1 ? jsxRuntimeExports.jsx(__mf_72, {
sx: (theme) => ({
color: theme.palette.primary.main
}),
onClick: () => {
const items = JSON.parse(JSON.stringify(this.state.items));
filters.forEach((filter) => items.push({
label: filter,
value: filter,
id: v4()
}));
this.setState({
anchorEl: null
}, () => this.updateItems(items));
},
children: __mf_2$1.t("basic_all_filters")
}) : null
]
});
}
renderSelectImageDialog() {
if (this.state.selectImage === null) {
return null;
}
let _value = this.state.items[this.state.selectImage].image || "";
if (_value.startsWith("../")) {
_value = _value.substring(3);
} else if (_value.startsWith("_PRJ_NAME/")) {
_value = _value.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
return jsxRuntimeExports.jsx(__mf_110, {
theme: this.props.context.theme,
title: __mf_2$1.t("Select file"),
onClose: () => this.setState({
selectImage: null
}),
restrictToFolder: `${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}`,
allowNonRestricted: true,
allowUpload: true,
allowDownload: true,
allowCreateFolder: true,
allowDelete: true,
allowView: true,
showToolbar: true,
imagePrefix: "../",
selected: _value,
filterByType: "images",
onOk: (selectedOrArray) => {
let selected = selectedOrArray ? Array.isArray(selectedOrArray) ? selectedOrArray[0] : selectedOrArray : "";
const projectPrefix = `${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`;
if (selected == null ? void 0 : selected.startsWith(projectPrefix)) {
selected = `_PRJ_NAME/${selected.substring(projectPrefix.length)}`;
} else if (selected == null ? void 0 : selected.startsWith("/")) {
selected = `..${selected}`;
} else if (selected && !selected.startsWith(".")) {
selected = `../${selected}`;
}
const items = JSON.parse(JSON.stringify(this.state.items));
items[this.state.selectImage].image = selected;
this.updateItems(items);
this.setState({
selectImage: null
});
},
socket: this.props.context.socket
});
}
renderTableRow(item, index) {
let image = item.image;
if (image) {
if (image.startsWith("../")) {
image = image.substring(3);
} else if (image.startsWith("_PRJ_NAME/")) {
image = image.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
}
return jsxRuntimeExports.jsx(PublicDraggable, {
draggableId: item.id || "",
index,
children: (dragProvided) => jsxRuntimeExports.jsxs(__mf_118, {
sx: index % 2 ? styles$2.rowEven : void 0,
ref: dragProvided.innerRef,
...dragProvided.draggableProps,
children: [
jsxRuntimeExports.jsxs(__mf_113, {
style: styles$2.handlerCell,
...dragProvided.dragHandleProps,
children: [
jsxRuntimeExports.jsx(__mf_2781, {
style: styles$2.grab
}),
jsxRuntimeExports.jsxs("div", {
style: styles$2.index,
children: [
index + 1,
"."
]
})
]
}),
jsxRuntimeExports.jsx(__mf_113, {
style: styles$2.cellText,
children: jsxRuntimeExports.jsx(__mf_121, {
variant: "standard",
fullWidth: true,
value: item.value || "",
onChange: (e2) => {
const items = JSON.parse(JSON.stringify(this.state.items));
items[index].value = e2.target.value;
this.updateItems(items);
},
InputLabelProps: {
shrink: true
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
style: styles$2.cellText,
children: jsxRuntimeExports.jsx(__mf_121, {
variant: "standard",
fullWidth: true,
value: item.label || "",
onChange: (e2) => {
const items = JSON.parse(JSON.stringify(this.state.items));
items[index].label = e2.target.value;
this.updateItems(items);
},
InputLabelProps: {
shrink: true
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
style: styles$2.cellImage,
children: item.image ? null : jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
alignItems: "center"
},
children: [
jsxRuntimeExports.jsx(__mf_121, {
fullWidth: true,
size: "small",
variant: "standard",
value: item.icon,
onChange: (e2) => {
const items = JSON.parse(JSON.stringify(this.state.items));
items[index].icon = e2.target.value;
this.updateItems(items);
},
slotProps: {
input: {
endAdornment: item.icon ? jsxRuntimeExports.jsx(__mf_53, {
size: "small",
onClick: () => {
const items = JSON.parse(JSON.stringify(this.state.items));
items[index].icon = "";
this.updateItems(items);
},
children: jsxRuntimeExports.jsx(__mf_1766, {})
}) : null
}
}
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: item.icon ? "outlined" : void 0,
color: item.icon ? "grey" : void 0,
onClick: () => this.setState({
selectIcon: index
}),
children: item.icon ? jsxRuntimeExports.jsx(__mf_15$1, {
src: item.icon,
style: {
width: 36,
height: 36
}
}) : "..."
})
]
})
}),
jsxRuntimeExports.jsx(__mf_113, {
style: styles$2.cellImage,
children: item.icon ? null : jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
alignItems: "center"
},
children: [
jsxRuntimeExports.jsx(__mf_121, {
variant: "standard",
fullWidth: true,
slotProps: {
input: {
endAdornment: item.image ? jsxRuntimeExports.jsx(__mf_53, {
size: "small",
onClick: () => {
const items = JSON.parse(JSON.stringify(this.state.items));
items[index].image = "";
this.updateItems(items);
},
children: jsxRuntimeExports.jsx(__mf_1766, {})
}) : null
}
},
value: item.image,
onChange: (e2) => {
const items = JSON.parse(JSON.stringify(this.state.items));
items[index].image = e2.target.value;
this.updateItems(items);
}
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: image ? "outlined" : void 0,
color: image ? "grey" : void 0,
onClick: () => this.setState({
selectImage: index
}),
children: image ? jsxRuntimeExports.jsx(__mf_15$1, {
src: image,
style: {
width: 36,
height: 36
}
}) : "..."
})
]
})
}),
jsxRuntimeExports.jsx(__mf_113, {
style: styles$2.cell,
children: jsxRuntimeExports.jsx(__mf_4, {
style: {
width: "100%"
},
value: item.color,
onChange: (color) => {
const items = JSON.parse(JSON.stringify(this.state.items));
items[index].color = color;
this.updateItems(items);
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
style: styles$2.cell,
children: jsxRuntimeExports.jsx(__mf_4, {
style: {
width: "100%"
},
value: item.activeColor,
onChange: (color) => {
const items = JSON.parse(JSON.stringify(this.state.items));
items[index].activeColor = color;
this.updateItems(items);
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
style: styles$2.cellButton,
children: jsxRuntimeExports.jsx(__mf_25, {
checked: !!item.default,
onChange: (e2) => {
const items = JSON.parse(JSON.stringify(this.state.items));
if (!this.props.multiple && e2.target.checked) {
items.forEach((_item) => _item.default = false);
}
items[index].default = e2.target.checked;
this.updateItems(items);
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
style: styles$2.cellButton,
children: jsxRuntimeExports.jsx(__mf_53, {
size: "small",
onClick: () => {
const items = JSON.parse(JSON.stringify(this.state.items));
items.splice(index, 1);
this.updateItems(items);
},
children: jsxRuntimeExports.jsx(__mf_2326, {})
})
})
]
})
}, item.id);
}
renderTable() {
return jsxRuntimeExports.jsxs(__mf_111, {
stickyHeader: true,
size: "small",
children: [
jsxRuntimeExports.jsx(__mf_116, {
children: jsxRuntimeExports.jsxs(__mf_118, {
children: [
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: 40
},
children: jsxRuntimeExports.jsx(__mf_39, {
size: "small",
onClick: (event) => this.setState({
anchorEl: event.currentTarget
}),
children: jsxRuntimeExports.jsx(__mf_85$1, {})
})
}),
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: 70
},
children: __mf_2$1.t("Value")
}),
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: "calc(100% - 700px)"
},
children: __mf_2$1.t("Title")
}),
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: 150
},
children: __mf_2$1.t("Icon")
}),
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: 150
},
children: __mf_2$1.t("Image")
}),
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: 150
},
children: __mf_2$1.t("Text color")
}),
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: 150
},
children: __mf_2$1.t("jqui_active_color")
}),
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: 70
},
children: __mf_2$1.t("Default")
}),
jsxRuntimeExports.jsx(__mf_113, {
style: {
width: 40
}
})
]
})
}),
jsxRuntimeExports.jsx(DragDropContext, {
onDragEnd: (data) => {
if (!data.destination) {
return;
}
const items = JSON.parse(JSON.stringify(this.state.items));
const [removed] = items.splice(data.source.index, 1);
items.splice(data.destination.index, 0, removed);
this.updateItems(items);
},
children: jsxRuntimeExports.jsx(ConnectedDroppable, {
droppableId: "items",
type: "ROW",
children: (dropProvided) => jsxRuntimeExports.jsxs(__mf_112, {
ref: dropProvided.innerRef,
...dropProvided.droppableProps,
children: [
this.state.items.map((item, index) => this.renderTableRow(item, index)),
dropProvided.placeholder
]
})
})
})
]
});
}
render() {
return jsxRuntimeExports.jsxs(__mf_32$1, {
fullWidth: true,
maxWidth: "xl",
open: true,
onClose: () => this.props.onClose(),
children: [
jsxRuntimeExports.jsx(__mf_36, {
children: __mf_2$1.t("Edit")
}),
jsxRuntimeExports.jsxs(__mf_34, {
style: {
minHeight: "calc(90vh - 164px)"
},
children: [
this.renderSelectIconDialog(),
this.renderSelectImageDialog(),
this.renderFilterSelector(),
this.renderTable()
]
}),
jsxRuntimeExports.jsxs(__mf_33, {
children: [
jsxRuntimeExports.jsx(__mf_16, {
disabled: this.originalItems === this.state.applyItems,
variant: "contained",
onClick: () => this.props.onClose(JSON.parse(this.state.applyItems)),
color: "primary",
startIcon: jsxRuntimeExports.jsx(__mf_1671, {}),
children: __mf_2$1.t("Apply")
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "grey",
onClick: () => this.props.onClose(),
startIcon: jsxRuntimeExports.jsx(__mf_1776, {}),
children: __mf_2$1.t("Cancel")
})
]
})
]
});
}
}
function processFilter(filters) {
const len = filters.length;
for (let f2 = 0; f2 < len; f2++) {
const filter = filters[f2];
if (filter.includes(",")) {
const ff = filter.split(",").map((t) => t.trim()).filter((t) => t);
const first = ff.shift();
if (first) {
filters[f2] = first;
if (ff.length) {
filters.push(...ff);
}
}
} else if (filter.includes(";")) {
const ff = filter.split(";").map((t) => t.trim()).filter((t) => t);
const first = ff.shift();
if (first) {
filters[f2] = first;
if (ff.length) {
filters.push(...ff);
}
}
}
}
}
const ItemsEditor = (props) => {
const [open, setOpen] = __mf_32(false);
let items = props.data.items;
if (open && !items && props.data.filters) {
items = props.data.filters.split(";").map((item) => ({
label: item.trim(),
value: item.trim()
})).filter((item) => item.value);
}
if (open && typeof items === "string") {
try {
items = JSON.parse(items);
} catch {
items = [];
}
}
return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
children: [
jsxRuntimeExports.jsx(__mf_16, {
style: {
whiteSpace: "nowrap"
},
onClick: () => setOpen(true),
variant: "outlined",
startIcon: jsxRuntimeExports.jsx(__mf_2876, {}),
children: __mf_2$1.t("Edit")
}),
open ? jsxRuntimeExports.jsx(FiltersEditorDialog, {
context: props.context,
items: items || [],
multiple: props.data.multiple,
onClose: (newItems) => {
if (newItems) {
const data = JSON.parse(JSON.stringify(props.data));
data.items = JSON.stringify(newItems);
props.setData(data);
}
setOpen(false);
}
}) : null
]
});
};
class BasicFilterDropdown extends VisRxWidget {
editMode;
static getWidgetInfo() {
return {
id: "tplFilterDropdown",
visSet: "basic",
visName: "filter - dropdown",
visPrev: "widgets/basic/img/Prev_FilterDropdown.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "items",
label: "editor",
type: "custom",
noBinding: true,
component: (_field, data, onDataChange, props) => jsxRuntimeExports.jsx(ItemsEditor, {
data,
setData: onDataChange,
context: props.context
}),
default: "[]"
},
{
name: "type",
label: "Type",
type: "select",
options: [
{
value: "dropdown",
label: "basic_filter_type_dropdown"
},
{
value: "horizontal_buttons",
label: "basic_filter_type_horizontal_buttons"
},
{
value: "vertical_buttons",
label: "basic_filter_type_vertical_buttons"
}
],
default: "horizontal_buttons"
},
{
name: "widgetTitle",
label: "name",
hidden: 'data.type !== "dropdown"'
},
{
name: "autoFocus",
type: "checkbox",
hidden: 'data.type !== "dropdown"'
},
{
name: "multiple",
label: "basic_filter_multiple",
type: "checkbox"
},
{
name: "noAllOption",
label: "basic_no_all_option",
type: "checkbox"
},
{
name: "noFilterText",
label: "basic_no_filter_text",
type: "text",
hidden: "!!data.noAllOption"
},
{
name: "dropdownVariant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
{
value: "standard",
label: "standard"
},
{
value: "outlined",
label: "outlined"
},
{
value: "filled",
label: "filled"
}
],
default: "standard",
hidden: 'data.type !== "dropdown"'
},
{
name: "buttonsVariant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
{
value: "outlined",
label: "outlined"
},
{
value: "contained",
label: "contained"
},
{
value: "text",
label: "text"
}
],
default: "outlined",
hidden: 'data.type === "dropdown"'
},
{
name: "dropdownSmall",
label: "basic_small",
default: false,
type: "checkbox",
hidden: 'data.type !== "dropdown"'
}
]
}
],
visDefaultStyle: {
width: 200,
height: 50
}
};
}
getWidgetInfo() {
return BasicFilterDropdown.getWidgetInfo();
}
componentDidMount() {
super.componentDidMount();
if (!this.props.editMode) {
this.editMode = false;
const items = this.getItems();
if (items.find((item) => item.default && item.value)) {
const filter = [];
items.forEach((item) => item.default && filter.push(item.value));
processFilter(filter);
setTimeout(() => {
const view = this.props.askView("getViewClass");
view.onCommand("changeFilter", {
filter
});
}, 0);
}
} else {
this.editMode = true;
}
}
onCommand(command) {
if (command === "changeFilter") {
this.forceUpdate();
}
super.onCommand(command);
}
renderDropdown(items) {
const viewsActiveFilter = this.props.viewsActiveFilter[this.props.view] || [];
let value;
if (this.state.rxData.multiple) {
value = viewsActiveFilter;
} else {
value = viewsActiveFilter[0] || "";
}
return jsxRuntimeExports.jsxs(__mf_42, {
fullWidth: true,
variant: this.state.rxData.dropdownVariant || "standard",
children: [
this.state.rxData.widgetTitle ? jsxRuntimeExports.jsx(__mf_60, {
children: this.state.rxData.widgetTitle
}) : null,
jsxRuntimeExports.jsxs(__mf_89, {
fullWidth: true,
value: value || "_",
onChange: (e2) => {
let filter = e2.target.value === "_" ? [] : e2.target.value;
if (typeof filter === "string") {
filter = filter.split(",");
}
if (filter.includes("") || filter.includes("_")) {
filter = [];
}
processFilter(filter);
const view = this.props.askView("getViewClass");
view.onCommand("changeFilter", {
filter
});
},
renderValue: (val) => {
const option = items.find((item) => item.value === val);
if (option) {
return jsxRuntimeExports.jsx("span", {
style: {
color: option.color
},
children: option.label
});
}
if (val === "_" || !val) {
return this.state.rxData.noAllOption ? "" : __mf_2$1.t("basic_no_filter");
}
return val;
},
multiple: !!this.state.rxData.multiple,
autoFocus: !!this.state.rxData.autoFocus,
children: [
this.state.rxData.noAllOption ? null : jsxRuntimeExports.jsx(__mf_72, {
value: "_",
children: jsxRuntimeExports.jsx("em", {
children: this.state.rxData.noFilterText || __mf_2$1.t("basic_no_filter")
})
}),
items.map((option) => {
let image = option.icon;
if (!image && option.image) {
image = option.image;
if (image.startsWith("_PRJ_NAME/")) {
image = image.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
}
return jsxRuntimeExports.jsxs(__mf_72, {
value: option.value,
selected: viewsActiveFilter.includes(option.value),
style: {
color: viewsActiveFilter.includes(option.value) ? option.color : option.activeColor || option.color
},
children: [
image ? jsxRuntimeExports.jsx(__mf_15$1, {
src: image,
style: {
width: 24,
height: 24,
marginRight: 8
}
}) : null,
option.label
]
}, option.value);
})
]
})
]
});
}
renderButtons(items) {
const viewsActiveFilter = this.props.viewsActiveFilter[this.props.view] || [];
return jsxRuntimeExports.jsxs(__mf_18, {
variant: this.state.rxData.buttonsVariant || "contained",
orientation: this.state.rxData.type === "horizontal_buttons" ? "horizontal" : "vertical",
style: {
width: "100%",
height: "100%"
},
children: [
this.state.rxData.noAllOption ? null : jsxRuntimeExports.jsx(__mf_16, {
style: {
flexGrow: 1
},
onClick: () => {
const view = this.props.askView("getViewClass");
view.onCommand("changeFilter", {
filter: []
});
},
children: jsxRuntimeExports.jsx("em", {
children: this.state.rxData.noFilterText || __mf_2$1.t("basic_no_filter")
})
}),
items.map((option) => {
let image = option.icon;
if (!image && option.image) {
image = option.image;
if (image.startsWith("_PRJ_NAME/")) {
image = image.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
}
return jsxRuntimeExports.jsx(__mf_16, {
onClick: () => {
let filter;
if (this.state.rxData.multiple) {
filter = viewsActiveFilter.includes(option.value) ? viewsActiveFilter.filter((f2) => f2 !== option.value) : [
...viewsActiveFilter,
option.value
];
} else {
filter = [
option.value
];
}
const view = this.props.askView("getViewClass");
processFilter(filter);
view.onCommand("changeFilter", {
filter
});
},
color: viewsActiveFilter.includes(option.value) ? "primary" : void 0,
sx: (theme) => ({
backgroundColor: viewsActiveFilter.includes(option.value) ? this.state.rxData.buttonsVariant === "contained" ? theme.palette.secondary.main : theme.palette.primary.main : void 0,
color: viewsActiveFilter.includes(option.value) ? this.state.rxData.buttonsVariant === "contained" ? theme.palette.secondary.contrastText : theme.palette.primary.contrastText : void 0,
"&:hover": {
backgroundColor: viewsActiveFilter.includes(option.value) ? this.state.rxData.buttonsVariant === "contained" ? theme.palette.secondary.light : theme.palette.primary.light : void 0,
color: viewsActiveFilter.includes(option.value) ? this.state.rxData.buttonsVariant === "contained" ? theme.palette.secondary.contrastText : theme.palette.primary.contrastText : void 0
}
}),
startIcon: image ? jsxRuntimeExports.jsx(__mf_15$1, {
src: image,
alt: option.label,
style: {
height: 24
}
}) : null,
style: {
flexGrow: 1,
color: viewsActiveFilter.includes(option.value) ? option.activeColor || option.color : option.color
},
children: option.label
}, option.value);
})
]
});
}
getItems() {
let items = this.state.data.items;
if (!items && this.state.data.filters) {
items = this.state.data.filters.split(";").map((item) => ({
label: item.trim(),
value: item.trim()
})).filter((item) => item.value);
}
if (typeof items === "string") {
try {
items = JSON.parse(items);
} catch {
items = [];
}
}
items = items || [];
return items;
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (props.style.width === void 0) {
props.style.width = 200;
}
if (props.style.height === void 0) {
props.style.height = 50;
}
const items = this.getItems();
if (this.editMode !== void 0 && this.editMode !== this.props.editMode) {
this.editMode = this.props.editMode;
if (!this.editMode && items.find((item) => item.default && item.value)) {
const filter = [];
items.forEach((item) => item.default && filter.push(item.value));
processFilter(filter);
setTimeout(() => {
const view = this.props.askView("getViewClass");
view.onCommand("changeFilter", {
filter
});
}, 0);
}
}
const type = this.state.rxData.type || "dropdown";
if (type === "horizontal_buttons" || type === "vertical_buttons") {
return this.renderButtons(items);
}
return this.renderDropdown(items);
}
}
class BasicLink extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplLink",
visSet: "basic",
visName: "link",
visPrev: "widgets/basic/img/Prev_tplLink.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "html",
type: "html"
},
{
name: "href",
type: "url"
},
{
name: "target",
label: "target",
type: "auto",
options: [
"auto",
"_blank",
"_self",
"_parent",
"_top"
],
hidden: "!data.href"
}
]
}
],
visDefaultStyle: {
width: 200,
height: 130
}
};
}
getWidgetInfo() {
return BasicLink.getWidgetInfo();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (props.style.width === void 0) {
props.style.width = 200;
}
if (props.style.height === void 0) {
props.style.height = 130;
}
return jsxRuntimeExports.jsx("a", {
href: this.state.rxData.href,
target: this.state.rxData.target,
style: {
textDecoration: "none",
width: "100%",
height: "100%"
},
children: jsxRuntimeExports.jsx(DangerousHtmlWithScript, {
className: "vis-widget-body",
html: this.state.rxData.html,
isDiv: true,
wid: this.props.id
})
});
}
}
class BasicImage8 extends BasicImageGeneric {
static getWidgetInfo() {
return {
id: "tplStatefulImage8",
visSet: "basic",
visName: "Image 8",
visPrev: "widgets/basic/img/Prev_StatefulImage.png",
visDefaultStyle: {
width: 200,
height: 130
},
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "count",
type: "number",
default: 0,
onChange: (_field, data, changeData) => {
const { count: count2 } = data;
for (let i = 0; i < count2; i++) {
data[`g_images-${i}`] = true;
}
changeData(data);
store.dispatch(recalculateFields(true));
return Promise.resolve();
}
},
{
name: "stretch",
type: "checkbox"
},
{
name: "refreshInterval",
tooltip: "basic_refreshInterval_tooltip",
type: "slider",
min: 0,
max: 18e4,
step: 100,
default: 0
},
{
name: "refreshOnWakeUp",
type: "checkbox"
},
{
name: "refreshOnViewChange",
type: "checkbox"
},
{
name: "refreshWithNoQuery",
type: "checkbox"
},
{
name: "allowUserInteractions",
type: "checkbox"
}
]
},
{
name: "images",
label: "Image",
indexFrom: 0,
indexTo: "count",
fields: [
{
name: "src_",
type: "image"
}
]
}
]
};
}
getWidgetInfo() {
return BasicImage8.getWidgetInfo();
}
getImage() {
const images = [];
for (let i = 0; i <= this.state.rxData.count; i++) {
if (this.state.rxData[`src_${i}`]) {
images.push(this.state.rxData[`src_${i}`]);
}
}
if (this.state.rxData.oid !== "nothing_selected" && this.state.values[`${this.state.rxData.oid}.val`] !== void 0) {
let val = this.state.values[`${this.state.rxData.oid}.val`];
if (val === "true" || val === true) {
val = 1;
}
if (val === "false" || val === false) {
val = 0;
}
return images[val] || "";
}
return images[0] || "";
}
}
class BasicFrame extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplFrame",
visSet: "basic",
visName: "Border",
visPrev: "widgets/basic/img/Prev_tplFrame.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "title",
type: "text",
default: __mf_2$1.t("jqui_widgetTitle")
},
{
name: "title_back",
type: "color"
},
{
name: "title_top",
type: "slider",
min: -20,
max: 20,
default: -10
},
{
name: "title_left",
type: "slider",
min: -20,
max: 30,
default: 20
},
{
name: "header_height",
type: "slider",
min: 0,
max: 100
},
{
name: "header_color",
type: "color"
}
]
}
],
visDefaultStyle: {
width: 100,
height: 70,
"border-style": "solid",
"border-width": "1px",
"border-color": "#888",
"overflow-x": "visible",
"overflow-y": "visible"
}
};
}
getWidgetInfo() {
return BasicFrame.getWidgetInfo();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
let content = jsxRuntimeExports.jsx("div", {
style: {
position: "absolute",
top: this.state.rxData.title_top,
left: this.state.rxData.title_left,
backgroundColor: this.state.rxData.title_back || (this.state.rxData.header_height ? void 0 : this.props.context.themeType === "dark" ? "#000" : "#fff"),
padding: "0 5px"
},
children: this.state.rxData.title
});
if (this.state.rxData.header_height) {
content = jsxRuntimeExports.jsx("div", {
style: {
width: "100%",
height: this.state.rxData.header_height,
backgroundColor: this.state.rxData.header_color || (this.props.context.themeType === "dark" ? "#000" : "#fff")
},
children: content
});
}
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: content
});
}
}
class BasicNote extends VisRxWidget {
constructor(props) {
super(props);
Object.assign(this.state, {
dialog: false,
text: ""
});
}
static getWidgetInfo() {
return {
id: "tplNote",
visSet: "basic",
visName: "Note",
visPrev: "widgets/basic/img/Prev_Note.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "html_prepend",
type: "html"
},
{
name: "html_append",
type: "html"
},
{
name: "test_text",
type: "html"
},
{
name: "hide_corner",
label: "basic_node_hide_corner",
type: "checkbox"
}
]
}
],
visDefaultStyle: {
width: 100,
height: 70,
"border-radius": "5px",
"border-style": "solid",
"border-width": "1px",
"border-color": "#888",
"background-color": "rgba(255,255,105,0.8)"
}
};
}
getWidgetInfo() {
return BasicNote.getWidgetInfo();
}
renderDialog() {
if (!this.state.dialog) {
return null;
}
return jsxRuntimeExports.jsxs(__mf_32$1, {
open: true,
onClose: () => this.setState({
dialog: false
}),
fullWidth: true,
sx: {
"& .MuiDialog-paper": {}
},
children: [
jsxRuntimeExports.jsx(__mf_34, {
children: jsxRuntimeExports.jsx(__mf_122, {
style: {
width: "calc(100% - 6px)",
minHeight: 200,
backgroundColor: this.props.context.themeType === "dark" ? "black" : "white",
resize: "vertical",
color: this.props.context.themeType === "dark" ? "white" : "black"
},
value: this.state.text,
onChange: (e2) => this.setState({
text: e2.target.value
})
})
}),
jsxRuntimeExports.jsxs(__mf_33, {
children: [
this.state.text ? jsxRuntimeExports.jsx(__mf_53, {
onClick: (e2) => {
e2.stopPropagation();
this.setState({
text: ""
});
},
children: jsxRuntimeExports.jsx(__mf_2326, {})
}) : null,
jsxRuntimeExports.jsx("div", {
style: {
flex: 1
}
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "primary",
onClick: (e2) => {
e2.stopPropagation();
this.setState({
dialog: false
});
this.props.context.setValue(this.state.rxData.oid, this.state.text);
},
children: jsxRuntimeExports.jsx(__mf_1671, {})
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "grey",
onClick: (e2) => {
e2.stopPropagation();
this.setState({
dialog: false
});
},
children: jsxRuntimeExports.jsx(__mf_1776, {})
})
]
})
]
});
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
let corner = null;
if (!this.state.rxData.hide_corner) {
corner = jsxRuntimeExports.jsx("div", {
style: {
position: "absolute",
right: -10,
bottom: -10,
width: 20,
height: 20,
backgroundColor: this.state.rxStyle["border-color"],
transform: "rotate(45deg)"
}
});
}
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
onClick: () => !this.props.editMode && this.setState({
dialog: true,
text: this.state.values[`${this.state.rxData.oid}.val`]
}),
children: jsxRuntimeExports.jsxs("div", {
style: {
width: "100%",
height: "100%",
position: "relative",
overflow: this.state.rxData.hide_corner ? void 0 : "hidden"
},
children: [
jsxRuntimeExports.jsxs("div", {
style: {
padding: 10,
cursor: this.props.editMode ? "default" : "pointer",
width: "calc(100% - 20px)",
height: "calc(100% - 20px)"
},
children: [
!this.props.editMode ? this.renderDialog() : null,
this.state.rxData.html_prepend || "",
this.props.editMode && this.state.rxData.test_text ? this.state.rxData.test_text : this.state.values[`${this.state.rxData.oid}.val`] || "",
this.state.rxData.html_append || ""
]
}),
corner
]
})
});
}
}
class BasicLogout extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplHtmlLogout",
visSet: "basic",
visName: "HTML logout",
visPrev: "widgets/basic/img/Prev_HtmlLogout.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "html",
type: "html",
default: "Logout"
},
{
name: "redirect_url",
type: "url"
},
{
name: "in_app_close",
type: "checkbox"
},
{
name: "variant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
"contained",
"outlined",
"text"
],
default: "contained"
},
{
name: "icon",
label: "jqui_icon",
type: "icon64",
hidden: "!!data.image"
},
{
name: "image",
type: "image",
label: "jqui_image",
hidden: "!!data.icon"
}
]
}
],
visDefaultStyle: {
width: 70,
height: 30
}
};
}
getWidgetInfo() {
return BasicLogout.getWidgetInfo();
}
async onLogout() {
if (this.props.editMode) {
return;
}
if (this.state.rxData.in_app_close) {
if (typeof window.logout === "function") {
window.logout();
} else {
window.alert(__mf_2$1.t("This option works only in APP"));
}
} else {
if (!this.props.context.socket.isSecure) {
window.alert(__mf_2$1.t("This option works only for connection with authentication"));
return;
}
await this.props.context.socket.logout();
if (this.state.rxData.redirect_url) {
window.location.href = this.state.rxData.redirect_url;
} else {
window.location.reload();
}
}
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsx(__mf_16, {
style: {
width: "100%",
height: "100%",
minWidth: 30,
background: this.state.rxStyle.background || void 0,
backgroundColor: this.state.rxStyle["background-color"] || void 0,
color: this.state.rxStyle.color || void 0,
borderStyle: this.state.rxStyle["border-style"] || void 0,
borderWidth: this.state.rxStyle["border-width"] || void 0,
borderColor: this.state.rxStyle["border-color"] || void 0,
borderRadius: this.state.rxStyle["border-radius"] || void 0
},
variant: this.state.rxData.variant,
onClick: () => this.onLogout(),
startIcon: this.state.rxData.html && (this.state.rxData.icon || this.state.rxData.image) ? jsxRuntimeExports.jsx(__mf_15$1, {
src: this.state.rxData.icon || this.state.rxData.image
}) : void 0,
children: this.state.rxData.html ? jsxRuntimeExports.jsx("div", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html
}
}) : this.state.rxData.icon || this.state.rxData.image ? jsxRuntimeExports.jsx(__mf_15$1, {
src: this.state.rxData.icon || this.state.rxData.image
}) : jsxRuntimeExports.jsx(__mf_1776, {})
})
});
}
}
class JQuiButton extends VisRxWidget {
refButton;
refDialog;
hideTimeout;
setObjectType;
constructor(props) {
super(props);
this.state.width = 0;
this.state.height = 0;
this.state.dialogVisible = false;
this.state.showPassword = false;
this.state.password = "";
this.refButton = React.createRef();
this.refDialog = React.createRef();
}
static getWidgetInfo() {
return {
id: "tplJquiButtonLink",
visSet: "jqui",
visName: "Button Link",
visSetLabel: "jqui_set_label",
visWidgetLabel: "jqui_button_link",
visPrev: "widgets/jqui/img/Prev_ButtonLink.png",
visOrder: 1,
visAttrs: [
{
name: "common",
fields: [
{
name: "buttontext",
type: "text",
default: "URL",
hidden: (data) => !!data.html || !!(data.buttontext_view && data.nav_view) || !!data.externalDialog
},
{
name: "html",
type: "html",
default: "",
tooltip: "jqui_html_tooltip",
disabled: (data) => !!data.buttontext || !!data.icon || !!data.src || !!data.externalDialog
},
{
name: "Password",
type: "password",
label: "password",
tooltip: "jqui_password_tooltip",
disabled: (data) => !data.nav_view && !data.url && !data.href && !data.html_dialog && !data.contains_view
}
]
},
{
name: "view",
label: "jqui_view_group",
hidden: (data) => !!data.url || !!data.href || !!data.html_dialog || !!data.contains_view,
fields: [
{
name: "nav_view",
label: "jqui_nav_view",
type: "views"
},
{
name: "buttontext_view",
label: "jqui_buttontext_view",
type: "checkbox",
hidden: (data) => !data.nav_view
},
{
name: "sub_view",
label: "basic_sub_view",
type: "text",
tooltip: "sub_view_tooltip",
hidden: (data) => !data.nav_view
}
]
},
{
name: "URL",
label: "jqui_url_group",
hidden: (data) => !!data.html_dialog || !!data.contains_view || !!data.nav_view,
fields: [
{
name: "href",
label: "jqui_url_in_browser",
type: "url",
hidden: (data) => !!data.url,
tooltip: "jqui_href_tooltip"
},
{
name: "url",
label: "jqui_url_in_background",
type: "url",
hidden: (data) => !!data.href,
tooltip: "jqui_url_tooltip"
},
{
name: "target",
type: "auto",
options: [
"_blank",
"_self",
"_parent",
"_top"
],
hidden: (data) => !!data.url || !data.href
}
]
},
{
name: "style",
label: "Style",
hidden: (data) => !!data.externalDialog,
fields: [
{
name: "no_style",
type: "checkbox",
hidden: (data) => data.jquery_style
},
{
name: "jquery_style",
label: "jqui_jquery_style",
type: "checkbox",
hidden: (data) => data.no_style
},
{
name: "padding",
type: "slider",
min: 0,
max: 100,
default: 5
},
{
name: "variant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
"contained",
"outlined",
"standard"
],
default: "contained",
hidden: (data) => data.jquery_style || data.no_style
},
{
name: "color",
label: "jqui_button_color",
type: "select",
noTranslation: true,
options: [
"",
"primary",
"secondary"
],
default: "",
hidden: (data) => data.jquery_style || data.no_style
},
{
name: "html_prepend",
type: "html"
},
{
name: "html_append",
type: "html"
},
{
name: "visResizable",
label: "visResizable",
type: "checkbox",
default: false,
desiredSize: false
}
]
},
{
name: "icon",
hidden: (data) => !!data.externalDialog || data.jquery_style,
fields: [
{
name: "src",
label: "jqui_image",
type: "image",
hidden: (data) => data.icon
},
{
name: "icon",
label: "jqui_icon",
type: "icon64",
hidden: (data) => data.src
},
{
name: "invert_icon",
type: "checkbox",
hidden: (data) => !data.icon && !data.src
},
{
name: "imageHeight",
type: "slider",
min: 0,
max: 200,
default: 100,
hidden: (data) => !data.src
}
]
},
{
name: "dialog",
hidden: (data) => !!data.url || !!data.href || !!data.nav_view,
fields: [
{
name: "html_dialog",
type: "html",
hidden: (data) => !!data.contains_view
},
{
name: "contains_view",
type: "views",
hidden: (data) => !!data.html_dialog
},
{
name: "title",
type: "text",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "autoclose",
type: "slider",
min: 0,
max: 3e4,
step: 100,
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "modal",
type: "checkbox",
default: true,
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "dialog_width",
type: "text",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "dialog_height",
type: "text",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "dialog_class",
label: "CSS Class",
type: "text",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "persistent",
type: "checkbox",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "preload",
type: "checkbox",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "closeOnClick",
type: "checkbox",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "hideCloseButton",
label: "jqui_hide_close_button",
type: "checkbox",
hidden: (data) => !data.html_dialog && !data.contains_view && !!data.closeOnClick
},
{
name: "dialogBackgroundColor",
label: "Background color",
type: "color",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "dialogTitleColor",
type: "color",
label: "Text color",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "overflowX",
type: "select",
noTranslation: true,
options: [
"",
"auto",
"hidden",
"visible",
"scroll",
"initial",
"inherit"
],
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "overflowY",
type: "select",
noTranslation: true,
options: [
"",
"auto",
"hidden",
"visible",
"scroll",
"initial",
"inherit"
],
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "setId",
type: "id",
tooltip: "jqui_dialog_set_id_tooltip",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "setValue",
type: "text",
hidden: (data) => !data.setId || !data.html_dialog && !data.contains_view
},
{
name: "dialogName",
label: "jqui_dialog_name",
type: "text",
hidden: (data) => !data.html_dialog && !data.contains_view
},
{
name: "externalDialog",
label: "jqui_external_dialog",
tooltip: "jqui_external_dialog_tooltip",
type: "checkbox",
hidden: (data) => !data.html_dialog && !data.contains_view
}
]
}
]
};
}
static findField(widgetInfo, name) {
return VisRxWidget.findField(widgetInfo, name);
}
getWidgetInfo() {
return JQuiButton.getWidgetInfo();
}
componentDidMount() {
super.componentDidMount();
this.componentDidUpdate();
}
componentWillUnmount() {
this.hideTimeout && clearTimeout(this.hideTimeout);
this.hideTimeout = null;
super.componentWillUnmount();
}
componentDidUpdate() {
if (this.refButton.current) {
if (this.state.rxData.jquery_style && !this.refButton.current._jQueryDone) {
this.refButton.current._jQueryDone = true;
window.jQuery(this.refButton.current).button();
}
if (this.refButton.current.clientWidth !== this.state.width || this.refButton.current.clientHeight !== this.state.height) {
this.setState({
width: this.refButton.current.clientWidth,
height: this.refButton.current.clientHeight
});
}
}
if (this.refService.current && (this.state.rxData.html_dialog || this.state.rxData.contains_view) && !this.refService.current._showDialog) {
this.refService.current._showDialog = this.showDialog;
}
if (this.refService.current) {
const dialogName = this.refService.current.dataset.dialogName;
if ((dialogName || "") !== (this.state.rxData.dialogName || "")) {
if (!this.state.rxData.dialogName) {
delete this.refService.current.dataset.dialogName;
} else {
this.refService.current.dataset.dialogName = this.state.rxData.dialogName;
}
}
}
}
showDialog = (show) => {
this.setState({
dialogVisible: show
});
let timeout = this.state.rxData.autoclose;
if (timeout === true || timeout === "true") {
timeout = 1e4;
}
if (timeout === null || timeout === void 0 || timeout === "") {
return;
}
timeout = parseInt(timeout, 10);
if (timeout < 60) {
timeout *= 1e3;
}
timeout = timeout || 1e3;
if (timeout) {
if (show) {
this.hideTimeout = setTimeout(() => {
this.hideTimeout = null;
this.showDialog(false);
}, timeout);
} else if (this.hideTimeout) {
clearTimeout(this.hideTimeout);
this.hideTimeout = null;
}
}
};
onPasswordEnter() {
if (this.state.password === this.state.rxData.Password) {
this.setState({
showPassword: false
}, () => this.onClick(true));
} else {
window.alert(__mf_2$1.t("Wrong password"));
this.setState({
passwordError: true
}, () => {
setTimeout(() => this.setState({
passwordError: false
}), 3e3);
});
}
}
renderPasswordDialog() {
if (!this.state.showPassword) {
return null;
}
return jsxRuntimeExports.jsxs(__mf_32$1, {
open: true,
onClose: () => this.setState({
showPassword: false
}),
children: [
jsxRuntimeExports.jsx(__mf_36, {
children: __mf_2$1.t("Enter password")
}),
jsxRuntimeExports.jsx(__mf_34, {
children: jsxRuntimeExports.jsx(__mf_121, {
label: __mf_2$1.t("Password"),
error: this.state.passwordError,
helperText: this.state.passwordError ? __mf_2$1.t("Wrong password") : null,
type: "password",
autoFocus: true,
fullWidth: true,
variant: "standard",
value: this.state.password || "",
onChange: (e2) => this.setState({
password: e2.target.value
}),
onKeyUp: (e2) => e2.key === "Enter" && this.onPasswordEnter()
})
}),
jsxRuntimeExports.jsxs(__mf_33, {
children: [
jsxRuntimeExports.jsx(__mf_16, {
disabled: !this.state.password,
startIcon: jsxRuntimeExports.jsx(__mf_1671, {}),
onClick: (e2) => {
e2.stopPropagation();
e2.preventDefault();
this.onPasswordEnter();
},
color: "primary",
variant: "contained",
children: __mf_2$1.t("Enter")
}),
jsxRuntimeExports.jsx(__mf_16, {
startIcon: jsxRuntimeExports.jsx(__mf_1776, {}),
onClick: (e2) => {
e2.stopPropagation();
e2.preventDefault();
this.setState({
showPassword: false
});
},
color: "grey",
variant: "contained",
children: __mf_2$1.t("Cancel")
})
]
})
]
});
}
async setObjectWithState(oid, value) {
var _a;
if (this.setObjectType === void 0) {
try {
const obj = await this.props.context.socket.getObject(oid);
this.setObjectType = ((_a = obj == null ? void 0 : obj.common) == null ? void 0 : _a.type) || "string";
await this.setObjectWithState(oid, value);
} catch (error) {
console.warn(`Object ${oid} not found: ${error}`);
}
return;
}
if (this.setObjectType === "boolean") {
value = value === "true" || value === true || value === "1" || value === 1 || value === "on" || value === "ON";
} else if (this.setObjectType === "number") {
value = parseFloat(value);
} else if (value !== null && value !== void 0) {
value = value.toString();
}
this.props.context.setValue(oid, value);
}
onCommand(command) {
super.onCommand(command);
if (command === "openDialog") {
this.showDialog(true);
return true;
}
if (command === "closeDialog") {
this.showDialog(false);
return true;
}
return false;
}
onClick(passwordChecked) {
if (this.state.dialogVisible) {
return;
}
if (!passwordChecked && this.state.rxData.Password) {
if (this.props.editMode) {
window.alert(__mf_2$1.t("Ignored in edit mode"));
} else {
this.setState({
showPassword: true,
password: ""
});
}
return;
}
if (this.state.rxData.nav_view) {
this.props.context.changeView(this.state.rxData.nav_view);
} else if (!this.props.editMode && this.state.rxData.href) {
if (this.state.rxData.target || this.props.tpl === "tplJquiButtonLinkBlank" && this.state.rxData.target === void 0) {
window.open(this.state.rxData.href, this.state.rxData.target);
} else {
window.location.href = this.state.rxData.href;
}
} else if (this.state.rxData.url) {
this.props.context.socket.getRawSocket().emit("httpGet", this.state.rxData.url, (data) => console.log("httpGet", this.state.rxData.url, data));
}
if (this.state.rxData.html_dialog || this.state.rxData.contains_view) {
if (this.state.rxData.setId) {
this.setObjectWithState(this.state.rxData.setId, this.state.rxData.setValue).catch((error) => console.warn(`Cannot set state: ${error}`));
}
this.showDialog(true);
}
}
renderRxDialog(dialogStyle, content) {
console.log("test");
if (this.state.rxData.modal) {
console.log("in");
return jsxRuntimeExports.jsx(__mf_32$1, {
maxWidth: "xl",
id: `${this.props.id}_dialog`,
ref: this.refDialog,
open: this.state.dialogVisible,
onClick: () => {
if (this.state.rxData.closeOnClick) {
this.showDialog(false);
}
},
children: jsxRuntimeExports.jsxs("div", {
style: {
backgroundColor: this.state.rxData.dialogBackgroundColor
},
children: [
this.state.rxData.title ? jsxRuntimeExports.jsx(__mf_36, {
sx: {
color: this.state.rxData.dialogTitleColor
},
children: this.state.rxData.title
}) : null,
!this.state.rxData.hideCloseButton || !this.state.rxData.closeOnClick ? jsxRuntimeExports.jsx(__mf_53, {
sx: {
color: this.state.rxData.dialogTitleColor
},
style: {
position: "absolute",
top: 0,
right: 0,
zIndex: 800
},
onClick: () => this.showDialog(false),
children: jsxRuntimeExports.jsx(__mf_1776, {})
}) : null,
jsxRuntimeExports.jsx(__mf_34, {
children: content
})
]
})
});
}
if (!this.state.dialogVisible) {
dialogStyle.display = "none";
}
if (!dialogStyle.minWidth || dialogStyle.minWidth < 200) {
dialogStyle.minWidth = 200;
}
if (!dialogStyle.minHeight || dialogStyle.minHeight < 100) {
dialogStyle.minHeight = 100;
}
dialogStyle.backgroundColor = "blue";
const paperStyle = {
...dialogStyle
};
delete paperStyle.top;
delete paperStyle.left;
paperStyle.padding = this.state.rxData.title ? "0 24px 24px 24px" : "26px 24px 24px 24px";
return jsxRuntimeExports.jsx(__mf_83, {
open: this.state.dialogVisible,
id: `${this.props.id}_dialog`,
ref: this.refDialog,
anchorEl: this.refButton.current,
style: dialogStyle,
onClick: () => {
if (this.state.rxData.closeOnClick) {
this.showDialog(false);
}
},
children: jsxRuntimeExports.jsxs(__mf_81, {
style: {
...paperStyle,
background: "red !important"
},
children: [
this.state.rxData.title ? jsxRuntimeExports.jsx(__mf_36, {
style: {
padding: "16px 0 0 0"
},
children: jsxRuntimeExports.jsx("div", {
children: this.state.rxData.title
})
}) : null,
jsxRuntimeExports.jsx(__mf_53, {
style: {
position: "absolute",
top: 0,
right: 0,
zIndex: 800
},
onClick: () => this.showDialog(false),
children: jsxRuntimeExports.jsx(__mf_1776, {})
}),
jsxRuntimeExports.jsx(__mf_34, {
children: content
})
]
})
});
}
renderJQueryDialog(dialogStyle, content) {
return jsxRuntimeExports.jsx("div", {
id: `${this.props.id}_dialog`,
className: "vis-widget-dialog",
title: this.state.rxData.title,
style: dialogStyle,
ref: this.refDialog,
children: this.state.rxData.preload ? content : null
});
}
renderDialog() {
if (this.props.editMode || !this.state.dialogVisible && !this.state.rxData.persistent && !this.state.rxData.externalDialog || !this.state.rxData.html_dialog && !this.state.rxData.contains_view) {
return null;
}
const width = isVarFinite(this.state.rxData.dialog_width) ? parseFloat(this.state.rxData.dialog_width) : this.state.rxData.dialog_width;
const height = isVarFinite(this.state.rxData.dialog_height) ? parseFloat(this.state.rxData.dialog_height) : this.state.rxData.dialog_height;
const dialogStyle = {
minWidth: width || window.innerWidth - 50,
minHeight: height || window.innerHeight - 50,
overflowX: this.state.rxData.overflowX,
overflowY: this.state.rxData.overflowY
};
let content;
if (this.state.rxData.contains_view) {
content = jsxRuntimeExports.jsx("div", {
style: dialogStyle,
className: this.state.rxData.dialog_class,
children: super.getWidgetView(this.state.rxData.contains_view, void 0)
});
} else {
content = jsxRuntimeExports.jsx("div", {
style: dialogStyle,
className: this.state.rxData.dialog_class,
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_dialog
}
});
}
if (this.state.rxData.jquery_style) ;
return this.renderRxDialog(dialogStyle, content);
}
renderWidgetBody(props) {
var _a, _b;
super.renderWidgetBody(props);
const iconStyle = {
marginRight: 4,
filter: this.state.rxData.invert_icon ? "invert(1)" : void 0
};
if (!this.state.rxData.jquery_style && this.state.rxData.src) {
if (this.state.width > this.state.height) {
iconStyle.height = `${this.state.rxData.imageHeight || 100}%`;
iconStyle.width = "auto";
} else {
iconStyle.width = `${this.state.rxData.imageHeight || 100}%`;
iconStyle.height = "auto";
}
}
let iconSrc = !this.state.rxData.jquery_style && (this.state.rxData.src || this.state.rxData.icon);
if (iconSrc && iconSrc.startsWith("_PRJ_NAME/")) {
iconSrc = iconSrc.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
const icon = iconSrc ? jsxRuntimeExports.jsx(__mf_15$1, {
src: iconSrc,
style: iconStyle
}) : null;
const buttonStyle = {
textTransform: "none"
};
Object.keys(this.state.rxStyle).forEach((attr) => {
const value = this.state.rxStyle[attr];
if (value !== null && value !== void 0 && VisRxWidget.POSSIBLE_MUI_STYLES.includes(attr)) {
attr = attr.replace(/(-\w)/g, (text) => text[1].toUpperCase());
buttonStyle[attr] = value;
}
});
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}
let visResizable = this.state.data.visResizable;
if (visResizable === void 0 || visResizable === null) {
if (this.props.tpl === "tplJquiButtonNav" || this.props.tpl === "tplJquiNavPw" || this.props.tpl === "tplContainerDialog" || this.props.tpl === "tplContainerIconDialog" || this.props.tpl === "tplJquiDialog" || this.props.tpl === "tplJquiIconDialog" || this.props.tpl === "tplIconHttpGet" || this.props.tpl === "tplIconLink" || this.props.tpl === "tplJquiIconNav") {
visResizable = true;
}
}
if (visResizable) {
buttonStyle.width = "100%";
buttonStyle.height = "100%";
} else {
buttonStyle.padding = this.state.rxData.padding;
}
buttonStyle.minWidth = "unset";
let buttonText;
if (this.state.rxData.html) ;
else if (this.state.rxData.nav_view && this.state.rxData.buttontext_view) {
buttonText = ((_b = (_a = this.props.context.views[this.state.rxData.nav_view]) == null ? void 0 : _a.settings) == null ? void 0 : _b.navigationTitle) || this.state.rxData.nav_view;
} else if (this.state.rxData.buttontext === void 0) {
buttonText = this.state.rxData.text || "";
} else {
buttonText = this.state.rxData.buttontext;
}
let content;
if (this.state.rxData.externalDialog) {
content = this.props.editMode ? jsxRuntimeExports.jsxs("div", {
style: {
width: "100%",
height: "100%",
border: "2px dashed red",
backgroundColor: "grey",
color: "white",
boxSizing: "border-box"
},
children: [
jsxRuntimeExports.jsx(__mf_53, {
style: {
...this.props.context.editModeComponentStyle,
position: "absolute",
bottom: 0,
right: 0,
opacity: 0.4
},
onClick: (e2) => {
e2.stopPropagation();
e2.preventDefault();
const text = `setState('${this.props.context.adapterName}.${this.props.context.instance}.control.command', '${JSON.stringify({
command: "dialog",
instance: window.localStorage.getItem("visInstance"),
data: this.state.rxData.dialogName || this.props.id
})}')`;
window.alert(__mf_2$1.t("Copied %s", text));
__mf_70.copyToClipboard(text);
},
children: jsxRuntimeExports.jsx(__mf_85$2, {})
}),
jsxRuntimeExports.jsx("div", {
children: __mf_2$1.t("External dialog")
}),
jsxRuntimeExports.jsx("div", {
children: this.state.rxData.html_dialog ? "HTML" : `View: ${this.state.rxData.contains_view}`
}),
jsxRuntimeExports.jsx("div", {
children: `Name: ${this.state.rxData.dialogName ? `${this.state.rxData.dialogName} (${this.props.id})` : this.props.id}`
}),
jsxRuntimeExports.jsx("div", {
style: {
fontSize: 10
},
children: __mf_2$1.t("You can open dialog with following script:")
}),
jsxRuntimeExports.jsx("div", {
style: {
fontSize: 10
},
children: `setState('${this.props.context.adapterName}.${this.props.context.instance}.control.command', '${JSON.stringify({
command: "dialog",
instance: window.localStorage.getItem("visInstance"),
data: this.state.rxData.dialogName || this.props.id
})}')`
})
]
}) : null;
} else {
content = [
this.state.rxData.html_prepend ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_prepend
}
}, "prepend") : null,
this.state.rxData.html ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html
}
}, "content") : this.state.rxData.no_style || this.state.rxData.jquery_style ? jsxRuntimeExports.jsxs("button", {
className: this.state.rxData.nav_view && this.state.rxData.nav_view === window.location.hash.slice(1) ? "ui-state-active" : void 0,
ref: this.refButton,
type: "button",
style: buttonStyle,
onClick: () => this.onClick(),
children: [
icon,
buttonText
]
}, "content") : jsxRuntimeExports.jsxs(__mf_16, {
ref: this.refButton,
style: buttonStyle,
color: this.state.rxData.nav_view && this.state.rxData.nav_view === window.location.hash.slice(1) ? this.state.rxData.color === "primary" ? "secondary" : "primary" : this.state.rxData.color || "grey",
variant: this.state.rxData.variant === void 0 ? "contained" : this.state.rxData.variant,
onClick: () => this.onClick(),
children: [
icon,
buttonText
]
}, "content"),
this.state.rxData.html_append ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append
}
}, "append") : null
];
}
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
onClick: this.state.rxData.html ? () => this.onClick() : void 0,
children: [
content,
this.renderDialog(),
this.renderPasswordDialog()
]
});
}
}
class JQuiButtonBlank extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiButtonLinkBlank",
visSet: "jqui",
visName: "Button Link",
visWidgetLabel: "jqui_button_link_blank",
visPrev: "widgets/jqui/img/Prev_ButtonLinkBlank.png",
visOrder: 2,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const target = JQuiButton.findField(newWidgetInfo, "target");
target.default = "_blank";
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = false;
const text = JQuiButton.findField(newWidgetInfo, "buttontext");
text.default = "URL Browser";
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiButtonBlank.getWidgetInfo();
}
}
class JQuiIconLink extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplIconLink",
visSet: "jqui",
visName: "Button Link",
visWidgetLabel: "jqui_icon_link",
visPrev: "widgets/jqui/img/Prev_IconLink.png",
visOrder: 3,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const target = JQuiButton.findField(newWidgetInfo, "target");
target.default = "_blank";
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiIconLink.getWidgetInfo();
}
}
class JQuiWriteState extends VisRxWidget {
iterateInterval = null;
iterateTimeout = null;
constructor(props) {
super(props);
Object.assign(this.state, {
value: "",
valueType: null
});
}
static getWidgetInfo() {
return {
id: "tplIconState",
visSet: "jqui",
visName: "Icon State",
visWidgetLabel: "jqui_write_value",
visPrev: "widgets/jqui/img/Prev_WriteState.png",
visOrder: 26,
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id",
onChange: async (_field, data, changeData, socket) => {
var _a, _b, _c, _d, _e, _f;
if (data.oid && data.oid !== "nothing_selected") {
const obj = await socket.getObject(data.oid);
let changed = false;
if (((_a = obj == null ? void 0 : obj.common) == null ? void 0 : _a.min) !== void 0 && ((_b = obj == null ? void 0 : obj.common) == null ? void 0 : _b.min) !== null) {
if (data.min !== obj.common.min) {
data.min = obj.common.min;
changed = true;
}
}
if (((_c = obj == null ? void 0 : obj.common) == null ? void 0 : _c.max) !== void 0 && ((_d = obj == null ? void 0 : obj.common) == null ? void 0 : _d.max) !== null) {
if (data.max !== obj.common.max) {
data.max = obj.common.max;
changed = true;
}
if (data.step > 0) {
if (data.minmax !== obj.common.max) {
data.minmax = obj.common.max;
changed = true;
}
} else if (data.minmax !== obj.common.min) {
data.minmax = obj.common.min;
changed = true;
}
}
if (!data.step) {
if (((_e = obj == null ? void 0 : obj.common) == null ? void 0 : _e.step) !== void 0 && ((_f = obj == null ? void 0 : obj.common) == null ? void 0 : _f.step) !== null) {
if (data.step !== obj.common.step) {
data.step = obj.common.step;
changed = true;
}
}
}
changed && changeData(data);
}
}
},
{
name: "click_id",
type: "id",
noSubscribe: true
},
{
name: "type",
label: "jqui_type",
type: "select",
default: "value",
options: [
{
value: "value",
label: "jqui_from_value"
},
{
value: "oid",
label: "jqui_from_oid"
},
{
value: "toggle",
label: "jqui_toggle"
},
{
value: "change",
label: "jqui_increment_decrement"
}
]
},
{
name: "value_oid",
type: "id",
hidden: (data) => data.type !== "oid"
},
{
name: "value",
type: "text",
hidden: (data) => data.type !== "value"
},
{
name: "step",
type: "number",
hidden: (data) => data.type !== "change",
default: 1
},
{
name: "minmax",
label: "jqui_max",
type: "number",
hidden: (data) => data.type !== "change" || (parseFloat(data.step) || 0) < 0,
default: 1
},
{
name: "minmax",
label: "jqui_min",
type: "number",
hidden: (data) => data.type !== "change" || (parseFloat(data.step) || 0) >= 0,
default: 1
},
{
name: "repeat_delay",
type: "number",
label: "jqui_repeat_delay",
hidden: (data) => data.type !== "change",
default: 800
},
{
name: "repeat_interval",
type: "number",
label: "jqui_repeat_interval",
hidden: (data) => data.type !== "change",
default: 300
},
{
name: "min",
type: "number",
label: "jqui_min",
hidden: (data) => data.type !== "toggle",
default: 0
},
{
name: "max",
label: "jqui_max",
type: "number",
hidden: (data) => data.type !== "toggle",
default: 100
}
]
},
{
name: "style",
fields: [
{
name: "variant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
"contained",
"outlined",
"standard"
],
default: "contained"
},
{
name: "text",
type: "text",
default: __mf_2$1.t("jqui_Write state")
},
{
name: "src",
type: "image",
label: "jqui_image",
hidden: (data) => !!data.icon
},
{
name: "icon",
type: "icon64",
label: "jqui_icon",
hidden: (data) => !!data.src
},
{
name: "text_active",
label: "jqui_text_active",
type: "text"
},
{
name: "src_active",
type: "image",
label: "jqui_image_active",
hidden: (data) => !!data.icon_active
},
{
name: "icon_active",
type: "icon64",
label: "jqui_icon_active",
hidden: (data) => !!data.src_active
},
{
name: "invert_icon",
type: "checkbox",
hidden: (data) => !data.icon || !data.src
},
{
name: "invert_icon_active",
type: "checkbox",
hidden: (data) => !data.icon_active || !data.src_active
}
]
}
],
visDefaultStyle: {
width: 100,
height: 40
}
};
}
async componentDidMount() {
super.componentDidMount();
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
try {
const state = await this.props.context.socket.getState(this.state.rxData.oid);
this.onStateUpdated(this.state.rxData.oid, state);
} catch (e2) {
console.error(`Cannot get state ${this.state.rxData.oid}: ${e2}`);
}
}
}
static findField(widgetInfo, name) {
return VisRxWidget.findField(widgetInfo, name);
}
getWidgetInfo() {
return JQuiWriteState.getWidgetInfo();
}
onStateUpdated(id, state) {
if (id === this.state.rxData.oid && state) {
const value = state.val === null || state.val === void 0 ? "" : state.val;
if (this.state.value !== value.toString()) {
this.setState({
value: value.toString()
});
}
}
}
getControlOid() {
if (this.state.rxData.click_id && this.state.rxData.click_id !== "nothing_selected") {
return this.state.rxData.click_id;
}
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
return this.state.rxData.oid;
}
return "";
}
onClick() {
if (this.props.editMode) {
return;
}
let value;
switch (this.state.rxData.type) {
case "value":
value = this.state.rxData.value.toString();
break;
case "oid": {
value = this.state.values[`${this.state.rxData.value_oid}.val`];
if (value === void 0 || value === null) {
return;
}
break;
}
case "toggle":
value = parseFloat(this.state.values[`${this.state.rxData.oid}.val`]) || 0;
value = value.toString() === (this.state.rxData.max || 0).toString() ? this.state.rxData.min : this.state.rxData.max;
break;
case "change":
value = parseFloat(this.state.values[`${this.state.rxData.oid}.val`]) || 0;
value += parseFloat(this.state.rxData.step) || 0;
if (this.state.rxData.step > 0) {
if (value > parseFloat(this.state.rxData.minmax)) {
value = parseFloat(this.state.rxData.minmax);
}
} else if (value < parseFloat(this.state.rxData.minmax)) {
value = parseFloat(this.state.rxData.minmax);
}
break;
default:
return;
}
const oid = this.getControlOid();
if (oid) {
if (this.state.valueType === "number") {
this.props.context.setValue(oid, parseFloat(value));
} else {
this.props.context.setValue(oid, value);
}
}
this.setState({
value
});
}
renderIcon(isActive) {
let icon;
let invertIcon = null;
if (isActive) {
invertIcon = this.state.rxData.invert_icon_active;
icon = this.state.rxData.icon_active || this.state.rxData.src_active;
}
if (!icon) {
icon = this.state.rxData.icon || this.state.rxData.src;
invertIcon = this.state.rxData.invert_icon;
}
const color = this.state.rxStyle.color;
if (icon) {
if (icon.startsWith("_PRJ_NAME/")) {
icon = icon.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
return jsxRuntimeExports.jsx(__mf_15$1, {
style: {
color,
filter: invertIcon ? "invert(100%)" : void 0,
width: "100%",
height: "100%"
},
src: icon
}, "icon");
}
return null;
}
renderText() {
let text = this.state.rxData.text;
const color = this.state.rxStyle.color;
if (!text) {
if (this.state.rxData.type === "oid") {
text = this.state.values[`${this.state.rxData.value_oid}.val`];
} else if (this.state.rxData.type === "value") {
text = this.state.rxData.value;
} else if (this.state.rxData.type === "change") {
if (this.state.rxData.step > 0) {
text = `+${this.state.rxData.step}`;
} else {
text = this.state.rxData.step.toString();
}
}
}
return text ? jsxRuntimeExports.jsx("span", {
style: {
color
},
children: text
}) : null;
}
getIsActive() {
let actualValue = this.state.value;
if (actualValue === void 0 || actualValue === null) {
actualValue = "";
}
switch (this.state.rxData.type) {
case "value": {
let desiredValue = this.state.rxData.value;
if (desiredValue === void 0 || desiredValue === null) {
desiredValue = "";
}
return actualValue.toString() === desiredValue.toString();
}
case "oid": {
let oidValue = this.state.values[`${this.state.rxData.value_oid}.val`];
if (oidValue === void 0 || oidValue === null) {
oidValue = "";
}
return actualValue.toString() === oidValue.toString();
}
case "toggle":
return actualValue.toString() === (this.state.rxData.max || 0).toString();
default:
return false;
}
}
componentWillUnmount() {
super.componentWillUnmount();
this.iterateInterval && clearInterval(this.iterateInterval);
this.iterateInterval = null;
this.iterateTimeout && clearTimeout(this.iterateTimeout);
this.iterateTimeout = null;
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
const isActive = this.getIsActive();
const buttonStyle = {};
Object.keys(this.state.rxStyle).forEach((attr) => {
const value = this.state.rxStyle[attr];
if (value !== null && value !== void 0 && VisRxWidget.POSSIBLE_MUI_STYLES.includes(attr)) {
attr = attr.replace(/(-\w)/g, (text2) => text2[1].toUpperCase());
buttonStyle[attr] = value;
}
});
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}
const text = this.renderText();
buttonStyle.width = "100%";
buttonStyle.height = "100%";
buttonStyle.minWidth = "unset";
const buttonColor = isActive ? "primary" : "grey";
const content = jsxRuntimeExports.jsx(__mf_16, {
style: buttonStyle,
color: buttonColor,
startIcon: text ? this.renderIcon(isActive) : null,
onClick: () => this.onClick(),
onMouseDown: () => {
if (this.props.editMode) {
return;
}
const delay = parseInt(this.state.rxData.repeat_delay, 10);
if (delay) {
this.iterateTimeout && clearTimeout(this.iterateTimeout);
this.iterateTimeout = setTimeout(() => {
this.iterateTimeout = null;
this.iterateInterval && clearInterval(this.iterateInterval);
this.iterateInterval = setInterval(() => this.onClick(), parseInt(this.state.rxData.repeat_interval, 10) || 500);
this.onClick();
}, delay);
}
},
onMouseUp: () => {
if (this.props.editMode) {
return;
}
this.iterateInterval && clearInterval(this.iterateInterval);
this.iterateInterval = null;
this.iterateTimeout && clearTimeout(this.iterateTimeout);
this.iterateTimeout = null;
},
variant: this.state.rxData.variant || "contained",
children: text || this.renderIcon(isActive)
});
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: content
});
}
}
class JQuiIconInc extends JQuiWriteState {
static getWidgetInfo() {
const widgetInfo = JQuiWriteState.getWidgetInfo();
const newWidgetInfo = {
id: "tplIconInc",
visSet: "jqui",
visName: "Icon Increment",
visWidgetLabel: "jqui_icon_increment",
visPrev: "widgets/jqui/img/Prev_IconInc.png",
visOrder: 27,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_write_state_note"
});
const target = JQuiWriteState.findField(newWidgetInfo, "type");
target.default = "change";
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiIconInc.getWidgetInfo();
}
}
class JQuiIconHttpGet extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplIconHttpGet",
visSet: "jqui",
visName: "Icon HTTP GET",
visWidgetLabel: "jqui_icon_http_get",
visPrev: "widgets/jqui/img/Prev_IconHttpGet.png",
visOrder: 4,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const url = JQuiButton.findField(newWidgetInfo, "url");
url.default = "http://";
const text = JQuiButton.findField(newWidgetInfo, "buttontext");
text.default = "URL Backend";
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiIconHttpGet.getWidgetInfo();
}
}
class JQuiDialog extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiDialog",
visSet: "jqui",
visName: "HTML - Dialog",
visWidgetLabel: "jqui_html_dialog",
visPrev: "widgets/jqui/img/Prev_JquiDialog.png",
visOrder: 5,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
const html = JQuiButton.findField(newWidgetInfo, "html");
html.default = "<div>HTML</div>";
const buttonText = JQuiButton.findField(newWidgetInfo, "buttontext");
delete buttonText.default;
const htmlDialog = JQuiButton.findField(newWidgetInfo, "html_dialog");
htmlDialog.default = "<div>HTML Dialog</div>";
newWidgetInfo.visDefaultStyle = {
"border-width": "1px",
"border-style": "solid",
"border-color": "#000",
width: "200px",
height: "130px",
cursor: "pointer"
};
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiDialog.getWidgetInfo();
}
}
class JQuiIconDialog extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiIconDialog",
visSet: "jqui",
visName: "Icon - Dialog",
visWidgetLabel: "jqui_icon_dialog",
visPrev: "widgets/jqui/img/Prev_JquiIconDialog.png",
visOrder: 6,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
const buttonText = JQuiButton.findField(newWidgetInfo, "buttontext");
buttonText.default = "Icon Dialog";
const htmlDialog = JQuiButton.findField(newWidgetInfo, "html_dialog");
htmlDialog.default = "<div>HTML Dialog</div>";
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiIconDialog.getWidgetInfo();
}
}
class JQuiContainerDialog extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplContainerDialog",
visSet: "jqui",
visName: "container - HTML - view in jqui Dialog",
visWidgetLabel: "jqui_container_dialog",
visPrev: "widgets/jqui/img/Prev_ContainerDialog.png",
visOrder: 7,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
const buttonText = JQuiButton.findField(newWidgetInfo, "buttontext");
buttonText.default = "Container Dialog";
const htmlDialog = JQuiButton.findField(newWidgetInfo, "html_dialog");
htmlDialog.default = "<div>HTML Dialog</div>";
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiContainerDialog.getWidgetInfo();
}
}
class JQuiButtonNavigation extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiButtonNav",
visSet: "jqui",
visName: "Navigation Button",
visWidgetLabel: "jqui_navigation_button",
visPrev: "widgets/jqui/img/Prev_ButtonNav.png",
visOrder: 8,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_nav_blank_note"
});
const modal = JQuiButton.findField(newWidgetInfo, "modal");
delete modal.default;
const navView = JQuiButton.findField(newWidgetInfo, "nav_view");
navView.default = "";
const text = JQuiButton.findField(newWidgetInfo, "buttontext");
text.default = "View";
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiButtonNavigation.getWidgetInfo();
}
}
class JQuiIconNavigation extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiIconNav",
visSet: "jqui",
visName: "Navigation Icon",
visWidgetLabel: "jqui_navigation_icon",
visPrev: "widgets/jqui/img/Prev_IconNav.png",
visOrder: 9,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_nav_blank_note"
});
const buttonText = JQuiButton.findField(newWidgetInfo, "buttontext");
delete buttonText.default;
const modal = JQuiButton.findField(newWidgetInfo, "modal");
delete modal.default;
const navView = JQuiButton.findField(newWidgetInfo, "nav_view");
navView.default = "";
const icon = JQuiButton.findField(newWidgetInfo, "icon");
icon.default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik0yMSAzTDMgMTAuNTN2Ljk4bDYuODQgMi42NUwxMi40OCAyMWguOThMMjEgM3oiLz48L3N2Zz4=";
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiIconNavigation.getWidgetInfo();
}
}
class JQuiButtonPasswordNavigation extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiNavPw",
visSet: "jqui",
visName: "Navigation with password",
visWidgetLabel: "jqui_navigation_password",
visPrev: "widgets/jqui/img/Prev_ButtonNavPw.png",
visOrder: 10,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_nav_blank_note"
});
const modal = JQuiButton.findField(newWidgetInfo, "modal");
delete modal.default;
const text = JQuiButton.findField(newWidgetInfo, "buttontext");
text.default = "Password";
const navView = JQuiButton.findField(newWidgetInfo, "nav_view");
navView.default = "";
const password = JQuiButton.findField(newWidgetInfo, "Password");
password.default = "";
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiButtonPasswordNavigation.getWidgetInfo();
}
}
class JQuiDialogExternal extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplContainerDialogExternal",
visSet: "jqui",
visName: "External Dialog",
visWidgetLabel: "jqui_html_external_dialog",
visPrev: "widgets/jqui/img/Prev_JquiExternalDialog.png",
visOrder: 11,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const externalDialog = JQuiButton.findField(newWidgetInfo, "externalDialog");
externalDialog.default = true;
const htmlDialog = JQuiButton.findField(newWidgetInfo, "html_dialog");
htmlDialog.default = "<div>HTML Dialog</div>";
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiDialogExternal.getWidgetInfo();
}
}
class JQuiButtonDialogClose extends VisRxWidget {
constructor(props) {
super(props);
this.state.width = 0;
this.state.height = 0;
}
static getWidgetInfo() {
return {
id: "tplJquiButtonDialogClose",
visSet: "jqui",
visName: "Button dialog close",
visWidgetLabel: "jqui_button_dialog_close",
visPrev: "widgets/jqui/img/Prev_ButtonDialogClose.png",
visOrder: 13,
visAttrs: [
{
name: "common",
fields: [
{
label: "jqui_dialog_name",
tooltip: "jqui_dialog_name_tooltip",
type: "custom",
component: (field, data, onDataChange, options) => {
const names = [];
Object.keys(options.context.views).forEach((id) => {
const widgets = options.context.views[id].widgets;
widgets && Object.keys(widgets).forEach((widget) => {
var _a, _b, _c;
if (((_a = widgets[widget].data) == null ? void 0 : _a.html_dialog) || ((_b = widgets[widget].data) == null ? void 0 : _b.contains_view) || ((_c = widgets[widget].data) == null ? void 0 : _c.externalDialog)) {
if (widgets[widget].data.dialogName) {
names.push({
label: `${widgets[widget].data.dialogName} (${widget})`,
value: widgets[widget].data.dialogName
});
} else {
names.push({
label: widget,
value: widget
});
}
}
});
});
return jsxRuntimeExports.jsx(__mf_7, {
freeSolo: true,
options: names,
value: data.dlgName || "",
sx: {
width: "100%"
},
onInputChange: (e2, inputValue) => {
if (typeof inputValue === "object" && inputValue !== null) {
inputValue = inputValue.value;
}
onDataChange({
dlgName: inputValue
});
},
onChange: (e2, inputValue) => {
if (typeof inputValue === "object" && inputValue !== null) {
inputValue = inputValue.value;
}
onDataChange({
dlgName: inputValue
});
},
getOptionLabel: (option) => {
if (typeof option === "string") {
return option;
}
return option.label;
},
renderInput: (params) => jsxRuntimeExports.jsx(__mf_121, {
variant: "standard",
...params
})
});
}
},
{
name: "buttontext",
type: "text",
default: __mf_2$1.t("jqui_Close").replace("jqui_", ""),
hidden: (data) => !!data.html
},
{
name: "html",
type: "html",
default: "",
tooltip: "jqui_html_tooltip",
disabled: (data) => !!data.buttontext || !!data.icon || !!data.src
}
]
},
{
name: "style",
hidden: (data) => !!data.externalDialog,
fields: [
{
name: "no_style",
type: "checkbox",
hidden: (data) => data.jquery_style
},
{
name: "jquery_style",
label: "jqui_jquery_style",
type: "checkbox",
hidden: (data) => data.no_style
},
{
name: "padding",
type: "slider",
min: 0,
max: 100,
default: 5
},
{
name: "variant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
"contained",
"outlined",
"standard"
],
default: "contained",
hidden: (data) => data.jquery_style || data.no_style
},
{
name: "color",
label: "jqui_button_color",
type: "select",
noTranslation: true,
options: [
"",
"primary",
"secondary"
],
default: "",
hidden: (data) => data.jquery_style || data.no_style
},
{
name: "html_prepend",
type: "html"
},
{
name: "html_append",
type: "html"
},
{
name: "visResizable",
label: "visResizable",
type: "checkbox",
default: false,
desiredSize: false
}
]
},
{
name: "icon",
hidden: (data) => !!data.html,
fields: [
{
name: "src",
label: "jqui_image",
type: "image",
hidden: (data) => data.icon || data.jquery_style
},
{
name: "icon",
label: "jqui_icon",
type: "icon64",
default: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik0xOSA2LjQxTDE3LjU5IDVMMTIgMTAuNTlMNi40MSA1TDUgNi40MUwxMC41OSAxMkw1IDE3LjU5TDYuNDEgMTlMMTIgMTMuNDFMMTcuNTkgMTlMMTkgMTcuNTlMMTMuNDEgMTJ6Ii8+PC9zdmc+",
hidden: (data) => data.src || data.jquery_style
},
{
name: "invert_icon",
type: "checkbox",
hidden: (data) => (!data.icon || !data.image) && data.jquery_style
},
{
name: "imageHeight",
type: "slider",
min: 0,
max: 200,
default: 100,
hidden: (data) => !data.src || data.jquery_style
}
]
}
]
};
}
getWidgetInfo() {
return JQuiButtonDialogClose.getWidgetInfo();
}
onClick() {
var _a;
let dlgName = this.state.rxData.dlgName;
if (!dlgName) {
const views = Object.keys(this.props.context.views);
for (let i = 0; i < views.length; i++) {
const widgets = this.props.context.views[views[i]].widgets;
if (widgets) {
const wids = Object.keys(widgets);
for (let j = 0; j < wids.length; j++) {
if (((_a = widgets[wids[j]].data) == null ? void 0 : _a.contains_view) === this.props.view) {
dlgName = wids[j];
break;
}
}
}
if (dlgName) {
break;
}
}
}
if (dlgName) {
const el = window.document.getElementById(dlgName) || window.document.querySelector(`[data-dialog-name="${dlgName}"]`);
const viewName = Object.keys(this.props.context.views).find((view) => this.props.context.views[view].widgets[dlgName]);
this.props.context.onCommand("closeDialog", viewName, dlgName);
if (el == null ? void 0 : el._showDialog) {
el._showDialog(false);
} else {
window.jQuery(`#${dlgName}_dialog`).dialog("close");
}
} else {
window.alert("Dialog not found");
}
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
const iconStyle = {
filter: this.state.rxData.invert_icon ? "invert(1)" : void 0
};
if (!this.state.rxData.jquery_style && this.state.rxData.src) {
if (this.state.width > this.state.height) {
iconStyle.height = `${this.state.rxData.imageHeight || 100}%`;
iconStyle.width = "auto";
} else {
iconStyle.width = `${this.state.rxData.imageHeight || 100}%`;
iconStyle.height = "auto";
}
}
let iconSrc = !this.state.rxData.jquery_style && (this.state.rxData.src || this.state.rxData.icon);
if (iconSrc && iconSrc.startsWith("_PRJ_NAME/")) {
iconSrc = iconSrc.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
const icon = iconSrc ? jsxRuntimeExports.jsx(__mf_15$1, {
src: iconSrc,
style: iconStyle
}) : null;
const buttonStyle = {};
Object.keys(this.state.rxStyle).forEach((attr) => {
const value = this.state.rxStyle[attr];
if (value !== null && value !== void 0 && VisRxWidget.POSSIBLE_MUI_STYLES.includes(attr)) {
attr = attr.replace(/(-\w)/g, (text) => text[1].toUpperCase());
buttonStyle[attr] = value;
}
});
buttonStyle.minWidth = "unset";
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}
if (this.state.data.visResizable) {
buttonStyle.width = "100%";
buttonStyle.height = "100%";
} else {
buttonStyle.padding = this.state.rxData.padding;
}
let buttonText;
if (this.state.rxData.html) ;
else {
buttonText = this.state.rxData.buttontext;
}
const content = [
this.state.rxData.html_prepend ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_prepend
}
}, "prepend") : null,
this.state.rxData.html ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html
}
}, "content") : this.state.rxData.no_style || this.state.rxData.jquery_style ? jsxRuntimeExports.jsxs("button", {
type: "button",
style: buttonStyle,
onClick: () => this.onClick(),
children: [
icon,
buttonText
]
}, "content") : !buttonText ? jsxRuntimeExports.jsx(__mf_39, {
style: {
zIndex: this.props.editMode ? 0 : void 0
},
color: this.state.rxData.color || "grey",
onClick: () => this.onClick(),
size: "small",
children: icon
}, "content") : jsxRuntimeExports.jsx(__mf_16, {
style: buttonStyle,
color: this.state.rxData.color || "grey",
variant: this.state.rxData.variant === void 0 ? "contained" : this.state.rxData.variant,
onClick: () => this.onClick(),
startIcon: icon,
children: buttonText
}, "content"),
this.state.rxData.html_append ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append
}
}, "append") : null
];
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
onClick: this.state.rxData.html ? () => this.onClick() : void 0,
children: content
});
}
}
class JQuiContainerButtonDialog extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplContainerButtonDialog",
visSet: "jqui",
visName: "container - Button - view in jqui Dialog",
visWidgetLabel: "jqui_container_button_dialog",
visPrev: "widgets/jqui/img/Prev_ContainerButtonDialog.png",
visOrder: 11,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const buttonText = JQuiButton.findField(newWidgetInfo, "buttontext");
buttonText.default = "Container Dialog";
const containsView = JQuiButton.findField(newWidgetInfo, "contains_view");
containsView.default = "";
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiContainerButtonDialog.getWidgetInfo();
}
}
class JQuiContainerIconDialog extends JQuiButton {
static getWidgetInfo() {
const widgetInfo = JQuiButton.getWidgetInfo();
const newWidgetInfo = {
id: "tplContainerIconDialog",
visSet: "jqui",
visName: "container - Icon - view in jqui Dialog",
visWidgetLabel: "jqui_container_icon_dialog",
visPrev: "widgets/jqui/img/Prev_ContainerIconDialog.png",
visOrder: 12,
visAttrs: widgetInfo.visAttrs
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_link_blank_note"
});
const visResizable = JQuiButton.findField(newWidgetInfo, "visResizable");
visResizable.default = true;
const icon = JQuiButton.findField(newWidgetInfo, "icon");
icon.default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik0xOSAxOUg1VjVoN1YzSDVhMiAyIDAgMCAwLTIgMnYxNGEyIDIgMCAwIDAgMiAyaDE0YzEuMSAwIDItLjkgMi0ydi03aC0ydjd6TTE0IDN2MmgzLjU5bC05LjgzIDkuODNsMS40MSAxLjQxTDE5IDYuNDFWMTBoMlYzaC03eiIvPjwvc3ZnPg==";
const buttonText = JQuiButton.findField(newWidgetInfo, "buttontext");
delete buttonText.default;
const containsView = JQuiButton.findField(newWidgetInfo, "contains_view");
containsView.default = "";
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiContainerIconDialog.getWidgetInfo();
}
}
class JQuiInput extends VisRxWidget {
focused = false;
inputRef;
jQueryDone = false;
object = null;
constructor(props) {
super(props);
Object.assign(this.state, {
input: ""
});
this.inputRef = React.createRef();
}
static getWidgetInfo() {
return {
id: "tplJquiInput",
visSet: "jqui",
visName: "Input",
visWidgetLabel: "jqui_input",
visPrev: "widgets/jqui/img/Prev_Input.png",
visOrder: 13,
visAttrs: [
{
name: "common",
fields: [
{
name: "label",
type: "text",
default: __mf_2$1.t("jqui_input").replace("jqui_", "")
},
{
name: "oid",
type: "id",
onChange: async (_field, data, changeData, socket) => {
var _a, _b, _c;
if (data.oid && data.oid !== "nothing_selected") {
const obj = await socket.getObject(data.oid);
let changed = false;
if ((_a = obj == null ? void 0 : obj.common) == null ? void 0 : _a.unit) {
if (data.unit !== obj.common.unit) {
data.unit = obj.common.unit;
changed = true;
}
}
if (((_b = obj == null ? void 0 : obj.common) == null ? void 0 : _b.type) !== "number") {
if (!data.asString) {
data.asString = true;
changed = true;
}
} else if (((_c = obj == null ? void 0 : obj.common) == null ? void 0 : _c.type) === "number") {
if (data.asString) {
data.asString = false;
changed = true;
}
}
changed && changeData(data);
}
}
},
{
name: "asString",
type: "checkbox",
label: "jqui_as_string"
},
{
name: "autoFocus",
type: "checkbox"
},
{
name: "readOnly",
type: "checkbox",
label: "jqui_read_only"
},
{
name: "withEnter",
type: "checkbox",
label: "jqui_with_enter_button",
hidden: "!!data.readOnly"
},
{
name: "buttontext",
type: "text",
label: "jqui_button_text",
hidden: "!data.withEnter || !!data.readOnly"
},
{
name: "selectAllOnFocus",
type: "checkbox",
label: "jqui_select_all_on_focus",
tooltip: "jqui_select_all_on_focus_tooltip"
},
{
name: "unit",
type: "text",
label: "jqui_unit"
}
]
},
{
name: "style",
fields: [
{
name: "no_style",
type: "checkbox",
hidden: (data) => data.jquery_style
},
{
name: "jquery_style",
label: "jqui_jquery_style",
type: "checkbox",
hidden: (data) => data.no_style
},
{
name: "variant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
"filled",
"outlined",
"standard"
],
default: "standard",
hidden: (data) => data.jquery_style || data.no_style
},
{
name: "size",
type: "slider",
min: 4,
max: 100,
default: 10,
hidden: (data) => !data.no_style
}
]
}
]
};
}
getWidgetInfo() {
return JQuiInput.getWidgetInfo();
}
static findField(widgetInfo, name) {
return VisRxWidget.findField(widgetInfo, name);
}
async componentDidMount() {
super.componentDidMount();
try {
const input = await this.props.context.socket.getState(this.state.rxData.oid);
if (input && input.val !== void 0 && input.val !== null) {
input.val = input.val.toString();
this.setState({
input: input.val
});
}
} catch (error) {
console.error(`Cannot get state ${this.state.rxData.oid}: ${error}`);
}
if (this.inputRef.current && this.state.rxData.autoFocus && !this.props.editMode && (this.state.rxData.jquery_style || this.state.rxData.no_style)) {
setTimeout(() => this.inputRef.current.focus(), 100);
}
}
onStateUpdated(id, state) {
super.onStateUpdated(id, state);
if ((state == null ? void 0 : state.val) || (state == null ? void 0 : state.val) === 0) {
if (id === this.state.rxData.oid && !this.focused) {
if (state.val.toString() !== this.state.input.toString()) {
this.setState({
input: state.val
});
}
}
}
}
componentDidUpdate() {
if (this.inputRef.current) {
if (this.state.rxData.jquery_style && !this.jQueryDone) {
this.jQueryDone = true;
window.jQuery(this.inputRef.current).button().addClass("ui-state-default");
}
}
}
async setValue(value) {
var _a, _b, _c;
if (((_a = this.object) == null ? void 0 : _a._id) !== this.state.rxData.oid) {
this.object = await this.props.context.socket.getObject(this.state.rxData.oid);
if (!this.object) {
return;
}
}
if (((_c = (_b = this.object) == null ? void 0 : _b.common) == null ? void 0 : _c.type) === "number") {
let fValue = parseFloat(value.replace(",", "."));
if (Number.isNaN(value)) {
fValue = 0;
}
this.props.context.setValue(this.state.rxData.oid, fValue);
} else {
this.props.context.setValue(this.state.rxData.oid, value);
}
}
onChange(value) {
this.setState({
input: value
});
if (!this.state.rxData.withEnter) {
void this.setValue(value);
}
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
props.style.overflow = "visible";
let content;
const label = this.state.rxData.label;
if (!this.state.rxData.jquery_style && !this.state.rxData.no_style) {
content = jsxRuntimeExports.jsx(__mf_121, {
fullWidth: true,
value: this.state.input === null || this.state.input === void 0 ? "" : this.state.rxData.asString ? this.state.input.toString() : this.state.input,
type: this.state.rxData.asString ? "text" : "number",
onFocus: (e2) => {
this.focused = true;
if (this.state.rxData.selectAllOnFocus) {
e2.target.select();
}
},
onBlur: () => this.focused = false,
autoFocus: !this.props.editMode && this.state.rxData.autoFocus,
variant: this.state.rxData.variant === void 0 ? "standard" : this.state.rxData.variant,
slotProps: {
htmlInput: {
readOnly: this.state.rxData.readOnly
},
input: {
endAdornment: this.state.rxData.withEnter && !this.state.rxData.readOnly ? jsxRuntimeExports.jsx(__mf_58, {
position: "end",
children: this.state.rxData.buttontext ? jsxRuntimeExports.jsx(__mf_16, {
onClick: () => this.setValue(this.state.input),
variant: "contained",
style: {
marginBottom: 10,
minWidth: 40
},
children: this.state.rxData.buttontext
}) : jsxRuntimeExports.jsx(__mf_53, {
onClick: () => this.setValue(this.state.input),
edge: "end",
children: jsxRuntimeExports.jsx(__mf_4885, {})
})
}) : void 0,
startAdornment: this.state.rxData.unit ? jsxRuntimeExports.jsx(__mf_58, {
position: "start",
children: this.state.rxData.unit
}) : void 0
}
},
label,
onChange: (e2) => this.onChange(e2.target.value)
});
} else {
content = [
jsxRuntimeExports.jsx("div", {
style: {
marginRight: 8
},
children: label
}, "label"),
jsxRuntimeExports.jsx("input", {
style: {
flexGrow: 1
},
readOnly: this.state.rxData.readOnly,
value: this.state.input || "",
ref: this.inputRef,
size: this.state.rxData.size || 10,
onFocus: (e2) => {
this.focused = true;
if (this.state.rxData.selectAllOnFocus) {
e2.target.select();
}
},
onBlur: () => this.focused = false,
onChange: (e2) => this.onChange(e2.target.value)
}, "input"),
this.state.rxData.withEnter && !this.state.rxData.readOnly ? jsxRuntimeExports.jsx(__mf_53, {
style: {
marginRight: 5
},
onClick: () => this.setValue(this.state.input),
edge: "end",
children: jsxRuntimeExports.jsx(__mf_4885, {})
}, "button") : void 0
];
}
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
style: {
display: "flex",
alignItems: "center"
},
children: content
});
}
}
class JQuiInputSet extends JQuiInput {
static getWidgetInfo() {
const widgetInfo = JQuiInput.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiInputSet",
visSet: "jqui",
visName: "Input + Button",
visWidgetLabel: "jqui_input_with_button",
visPrev: "widgets/jqui/img/Prev_InputWithButton.png",
visOrder: 14,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 150,
height: 45
}
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_input_note"
});
const withEnter = JQuiInput.findField(newWidgetInfo, "withEnter");
if (withEnter) {
withEnter.default = true;
}
const buttonText = JQuiInput.findField(newWidgetInfo, "buttontext");
if (buttonText) {
buttonText.default = "OK";
}
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiInputSet.getWidgetInfo();
}
}
class JQuiBinaryState extends VisRxWidget {
textsLengthCache = {};
constructor(props) {
super(props);
Object.assign(this.state, {
isOn: false,
height: 0,
width: 0
});
}
static getWidgetInfo() {
return {
id: "tplJquiBool",
visSet: "jqui",
visName: "Html Bool",
visWidgetLabel: "jqui_binary_control",
visPrev: "widgets/jqui/img/Prev_BinaryControl.png",
visOrder: 14,
visAttrs: [
{
name: "common",
fields: [
{
name: "type",
label: "jqui_type",
type: "select",
noTranslation: true,
default: "button",
options: [
"button",
"round-button",
"html",
"radio",
"checkbox",
"image",
"switch"
]
},
{
name: "oid",
type: "id"
},
{
name: "readOnly",
type: "checkbox"
},
{
name: "pushMode",
type: "checkbox",
label: "jqui_push_mode",
tooltip: "jqui_push_mode_tooltip",
hidden: (data) => data.type !== "button" && data.type !== "round-button" && data.type !== "image"
},
{
name: "click_id",
type: "id",
noSubscribe: true,
hidden: (data) => !!data.readOnly
},
{
name: "invert",
label: "jqui_inverted",
type: "checkbox"
},
{
name: "test",
type: "select",
label: "jqui_test",
options: [
{
value: "",
label: "none"
},
{
value: true,
label: "jqui_true"
},
{
value: false,
label: "jqui_false"
}
]
}
]
},
{
name: "html",
label: "jqui_html",
hidden: (data) => data.type !== "html",
fields: [
{
name: "html_true",
type: "html",
label: "jqui_html_true"
},
{
name: "html_false",
type: "html",
label: "jqui_html_false"
}
]
},
{
name: "text",
label: "group_text",
fields: [
{
name: "text_false",
type: "text",
label: "text_false",
default: __mf_2$1.t("jqui_off").replace("jqui_", ""),
hidden: (data) => data.type === "image" || data.type === "html"
},
{
name: "text_true",
type: "text",
label: "text_true",
default: __mf_2$1.t("jqui_on").replace("jqui_", ""),
hidden: (data) => data.type === "image" || data.type === "html" || data.type === "round-button"
},
{
name: "color_false",
type: "color",
label: "color_false",
hidden: (data) => data.type === "image" || data.type === "html" || !data.text_false
},
{
name: "color_true",
type: "color",
label: "color_true",
hidden: (data) => data.type === "image" || data.type === "html" || !data.text_true
},
{
name: "alt_false",
type: "text",
label: "alt_false"
},
{
name: "alt_true",
type: "text",
label: "alt_true"
},
{
name: "equal_text_length",
type: "checkbox",
label: "jqui_equal_text_length",
tooltip: "jqui_equal_text_length_tooltip",
hidden: (data) => !data.text_true || !data.text_false
}
]
},
{
name: "style",
fields: [
{
name: "jquery_style",
label: "jqui_jquery_style",
type: "checkbox",
hidden: (data) => data.type !== "button"
},
{
name: "padding",
type: "slider",
min: 0,
max: 100,
default: 5
},
{
name: "variant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
"contained",
"outlined",
"standard"
],
default: "contained",
hidden: (data) => data.type !== "button" && data.type !== "radio"
},
{
name: "orientation",
label: "jqui_orientation",
type: "select",
noTranslation: true,
options: [
"horizontal",
"vertical"
],
default: "horizontal",
hidden: (data) => data.type !== "radio"
},
{
name: "notEqualLength",
label: "jqui_not_equal_length",
type: "checkbox",
hidden: (data) => data.type !== "radio" || data.orientation !== "horizontal"
},
{
name: "html_prepend",
type: "html"
},
{
name: "html_append",
type: "html"
}
]
},
{
name: "icon_false",
label: "group_icon_false",
fields: [
{
name: "src_false",
label: "jqui_image",
type: "image",
hidden: (data) => data.icon_false
},
{
name: "icon_false",
label: "jqui_icon",
type: "icon64",
hidden: (data) => data.src_false
},
{
name: "icon_color_false",
label: "jqui_color",
type: "color",
hidden: (data) => !data.icon_false
},
{
name: "invert_icon_false",
label: "jqui_invert_icon",
type: "checkbox",
hidden: (data) => !data.src_false && !data.icon_false
},
{
name: "imageHeight_false",
label: "jqui_image_height",
type: "slider",
min: 0,
max: 200,
hidden: (data) => !data.src_false && !data.icon_false
}
]
},
{
name: "icon_true",
label: "group_icon_true",
fields: [
{
name: "src_true",
label: "jqui_image",
type: "image",
hidden: (data) => data.icon_true
},
{
name: "icon_true",
label: "jqui_icon",
type: "icon64",
hidden: (data) => data.src_true
},
{
name: "icon_color_true",
label: "jqui_color",
type: "color",
hidden: (data) => !data.icon_true && !data.icon_false
},
{
name: "invert_icon_true",
label: "jqui_invert_icon",
type: "checkbox",
hidden: (data) => !data.src_true && !data.icon_true
},
{
name: "imageHeight_true",
label: "jqui_image_height",
type: "slider",
min: 0,
max: 200,
hidden: (data) => !data.src_true && !data.icon_true
}
]
}
]
};
}
async componentDidMount() {
super.componentDidMount();
if ((this.props.tpl === "tplIconStateBool" || this.props.tpl === "tplIconStatePushButton") && (this.state.data.false_text || this.state.data.true_text)) {
const data = JSON.parse(JSON.stringify(this.state.data));
data.text_false = data.false_text;
data.text_true = data.true_text;
data.src_false = data.false_src;
data.src_true = data.true_src;
data.alt_false = data.false_alt;
data.alt_true = data.true_alt;
data.invert_icon_false = data.invert_icon;
data.invert_icon_true = data.invert_icon;
if (this.props.tpl === "tplIconStatePushButton") {
data.pushMode = true;
}
data.false_text = null;
data.true_text = null;
if (this.props.context.onWidgetsChanged) {
setTimeout(() => this.props.context.onWidgetsChanged([
{
wid: this.props.id,
view: this.props.view,
data
}
]), 100);
}
}
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
try {
const state = await this.props.context.socket.getState(this.state.rxData.oid);
this.onStateUpdated(this.state.rxData.oid, state);
} catch (error) {
console.error(`Cannot get state ${this.state.rxData.oid}: ${error}`);
}
}
}
static findField(widgetInfo, name) {
return VisRxWidget.findField(widgetInfo, name);
}
getWidgetInfo() {
return JQuiBinaryState.getWidgetInfo();
}
onStateUpdated(id, state) {
if (id === this.state.rxData.oid && state) {
const isOn = state.val === true || state.val === "true" || state.val === 1 || state.val === "1" || state.val === "on" || state.val === "ON" || state.val === "On";
if (this.state.isOn !== isOn) {
this.setState({
isOn
});
}
}
}
getControlOid() {
if (this.state.rxData.click_id && this.state.rxData.click_id !== "nothing_selected") {
return this.state.rxData.click_id;
}
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
return this.state.rxData.oid;
}
return "";
}
onClick(isOn) {
if (this.state.rxData.readOnly || this.props.editMode) {
return;
}
if (isOn !== false && isOn !== true) {
isOn = !this.isOn();
}
const oid = this.getControlOid();
if (oid) {
this.props.context.setValue(oid, isOn);
}
this.setState({
isOn
});
}
onMyMouseDown() {
const oid = this.getControlOid();
if (oid) {
this.props.context.setValue(oid, !this.state.rxData.invert);
}
this.setState({
isOn: true
});
}
onMyMouseUp() {
const oid = this.getControlOid();
if (oid) {
this.props.context.setValue(oid, !!this.state.rxData.invert);
}
this.setState({
isOn: false
});
}
isOn() {
let value;
if (this.props.editMode && (this.state.rxData.test === true || this.state.rxData.test === false)) {
value = this.state.rxData.test;
} else {
value = this.state.isOn;
}
if (value === void 0 || value === null) {
value = false;
}
if (this.state.rxData.invert) {
value = !value;
}
return value;
}
renderIcon(isOn, doNotFallback) {
let icon;
let invert;
let height;
let color;
if (isOn) {
icon = this.state.rxData.src_true || this.state.rxData.icon_true;
if (icon) {
invert = this.state.rxData.invert_icon_true;
height = this.state.rxData.imageHeight_true;
}
color = this.state.rxData.icon_color_true;
}
if (!icon && (!isOn || !doNotFallback)) {
icon = this.state.rxData.src_false || this.state.rxData.icon_false;
if (icon) {
invert = this.state.rxData.invert_icon_false;
height = this.state.rxData.imageHeight_false;
color = color || this.state.rxData.icon_color_false;
}
}
const style2 = {};
if (invert) {
style2.filter = "invert(1)";
}
if (color) {
style2.color = color;
}
if (height) {
style2.height = height;
style2.width = "auto";
} else if (this.state.width && this.state.rxData.type === "image") {
if (this.state.width < this.state.height) {
style2.width = `calc(100% - ${(this.state.rxData.padding || 0) * 2}px)`;
style2.height = "auto";
style2.maxHeight = "100%";
} else {
style2.height = `calc(100% - ${(this.state.rxData.padding || 0) * 2}px)`;
style2.width = "auto";
style2.maxWidth = "100%";
}
} else if (this.state.rxData.type === "round-button") {
if (this.state.width < this.state.height) {
style2.width = `calc(70% - ${(this.state.rxData.padding || 0) * 2}px)`;
style2.height = "auto";
style2.maxHeight = "100%";
} else {
style2.height = `calc(70% - ${(this.state.rxData.padding || 0) * 2}px)`;
style2.width = "auto";
style2.maxWidth = "100%";
}
} else if (this.state.width < this.state.height) {
style2.width = `calc(100% - ${(this.state.rxData.padding || 0) * 2}px)`;
style2.height = "auto";
style2.maxHeight = "100%";
} else {
style2.height = `calc(100% - ${(this.state.rxData.padding || 0) * 2}px)`;
style2.width = "auto";
style2.maxWidth = "100%";
}
if (this.state.rxData.padding) {
style2.padding = this.state.rxData.padding;
}
if (icon) {
if (icon.startsWith("_PRJ_NAME/")) {
icon = icon.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
return jsxRuntimeExports.jsx(__mf_15$1, {
style: style2,
src: icon
}, "icon");
}
return null;
}
getTextWidth(text) {
if (!this.refService.current) {
return text * 14;
}
if (this.textsLengthCache[text]) {
return this.textsLengthCache[text];
}
const el = document.createElement("div");
el.style.position = "absolute";
el.style.visibility = "hidden";
el.style.height = "auto";
el.style.width = "auto";
el.innerHTML = text;
this.refService.current.appendChild(el);
const width = el.clientWidth;
this.refService.current.removeChild(el);
this.textsLengthCache[text] = width;
return width;
}
renderText(isOn) {
let text;
let color;
if (isOn) {
text = this.state.rxData.text_true !== void 0 ? this.state.rxData.text_true : this.state.rxData.on_text;
color = this.state.rxData.color_true;
}
text = text || (this.state.rxData.text_false !== void 0 ? this.state.rxData.text_false : this.state.rxData.off_text);
color = color || this.state.rxData.color_false;
if (this.state.rxData.equal_text_length && this.state.rxData.text_false && this.state.rxData.text_true) {
const falseLength = this.getTextWidth(this.state.rxData.text_false);
const trueLength = this.getTextWidth(this.state.rxData.text_true);
const length = Math.max(falseLength, trueLength);
return {
text: jsxRuntimeExports.jsx("div", {
style: {
width: length,
display: "inline-block",
color
},
children: text
}),
color
};
}
return {
text,
color
};
}
renderButton(isOn, style2) {
const icon = this.renderIcon(isOn);
const text = this.renderText(isOn);
style2.color = text.color || void 0;
return jsxRuntimeExports.jsxs(__mf_16, {
variant: this.state.rxData.variant === void 0 ? "contained" : this.state.rxData.variant,
color: isOn ? "primary" : "grey",
onMouseDown: this.state.rxData.pushMode && !this.state.rxData.readOnly && !this.props.editMode ? () => this.onMyMouseDown() : void 0,
onMouseUp: this.state.rxData.pushMode && !this.state.rxData.readOnly && !this.props.editMode ? () => this.onMyMouseUp() : void 0,
onClick: !this.state.rxData.pushMode && !this.state.rxData.readOnly && !this.props.editMode ? () => this.onClick() : void 0,
style: style2,
children: [
icon,
text.text
]
});
}
renderFab(isOn, style2) {
const icon = this.renderIcon(isOn);
const text = this.renderText(isOn);
style2.zIndex = this.props.editMode ? 0 : void 0;
return jsxRuntimeExports.jsx(__mf_39, {
style: style2,
color: isOn ? "primary" : "grey",
onMouseDown: this.state.rxData.pushMode && !this.state.rxData.readOnly && !this.props.editMode ? () => this.onMyMouseDown() : void 0,
onMouseUp: this.state.rxData.pushMode && !this.state.rxData.readOnly && !this.props.editMode ? () => this.onMyMouseUp() : void 0,
onClick: !this.state.rxData.pushMode && !this.state.rxData.readOnly && !this.props.editMode ? () => this.onClick() : void 0,
children: icon || text.text
});
}
renderHtml(isOn) {
let html;
if (isOn) {
html = this.state.rxData.html_true;
}
if (!html) {
html = this.state.rxData.html_false;
}
const icon = this.renderIcon(isOn);
return [
this.state.rxData.html_prepend ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_prepend
}
}, "prepend") : null,
icon,
html ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: html
}
}, "content") : null,
this.state.rxData.html_append ? jsxRuntimeExports.jsx("span", {
dangerouslySetInnerHTML: {
__html: this.state.rxData.html_append
}
}, "append") : null
];
}
renderSwitch(isOn, style2) {
const on = this.state.rxData.text_true !== void 0 ? this.state.rxData.text_true : this.state.rxData.on_text;
const textColorOn = this.state.rxData.color_true;
const off = this.state.rxData.text_false !== void 0 ? this.state.rxData.text_false : this.state.rxData.off_text;
const textColorOff = this.state.rxData.color_false;
const onIcon = this.renderIcon(true, true);
const offIcon = this.renderIcon(false);
if ((on || onIcon) && (off || offIcon)) {
style2.display = "flex";
style2.alignItems = "center";
return jsxRuntimeExports.jsxs("div", {
style: style2,
children: [
jsxRuntimeExports.jsx("div", {
style: {
marginTop: -2,
color: textColorOff
},
children: off
}),
jsxRuntimeExports.jsx("div", {
children: offIcon
}),
jsxRuntimeExports.jsx(__mf_108, {
checked: isOn,
onChange: () => this.onClick()
}),
jsxRuntimeExports.jsx("div", {
children: onIcon
}),
jsxRuntimeExports.jsx("div", {
style: {
marginTop: -2,
color: textColorOn
},
children: on
})
]
});
}
if (off || offIcon) {
let text;
if (offIcon && off) {
text = jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
alignItems: "center",
color: textColorOff
},
children: [
offIcon,
off
]
});
} else {
text = off || offIcon;
}
style2.marginLeft = 5;
return jsxRuntimeExports.jsx(__mf_43, {
style: style2,
control: jsxRuntimeExports.jsx(__mf_108, {
checked: isOn,
onChange: () => this.onClick()
}),
label: text
});
}
return jsxRuntimeExports.jsx("div", {
style: style2,
children: jsxRuntimeExports.jsx(__mf_108, {
checked: false,
onChange: () => this.onClick()
})
});
}
renderCheckbox(isOn, style2) {
let text = isOn ? this.state.rxData.text_true !== void 0 ? this.state.rxData.text_true : this.state.rxData.on_text : this.state.rxData.text_false !== void 0 ? this.state.rxData.text_false : this.state.rxData.off_text;
if (!text) {
text = this.state.rxData.text_false !== void 0 ? this.state.rxData.text_false : this.state.rxData.off_text;
}
const icon = isOn ? this.renderIcon(true) : this.renderIcon(false);
style2.marginLeft = 5;
if (text || icon) {
return jsxRuntimeExports.jsx(__mf_43, {
style: style2,
control: jsxRuntimeExports.jsx(__mf_25, {
checked: isOn,
onChange: () => this.onClick()
}),
label: jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
alignItems: "center"
},
children: [
icon,
text
]
})
});
}
return jsxRuntimeExports.jsx(__mf_25, {
style: style2,
checked: isOn,
onChange: () => this.onClick()
});
}
renderRadio(isOn, style2) {
const on = this.state.rxData.text_true !== void 0 ? this.state.rxData.text_true : this.state.rxData.on_text;
const off = this.state.rxData.text_false !== void 0 ? this.state.rxData.text_false : this.state.rxData.off_text;
const onIcon = this.renderIcon(true);
const offIcon = this.renderIcon(false);
let variant = this.state.rxData.variant === void 0 ? "contained" : this.state.rxData.variant;
if (variant === "standard") {
variant = "text";
}
const buttonStyle = this.state.rxData.orientation === "vertical" ? {
height: "50%"
} : this.state.rxData.notEqualLength ? void 0 : {
width: "50%"
};
return jsxRuntimeExports.jsxs(__mf_18, {
style: style2,
variant,
orientation: this.state.rxData.orientation || "horizontal",
children: [
jsxRuntimeExports.jsx(__mf_16, {
style: buttonStyle,
startIcon: offIcon,
color: isOn ? "grey" : "primary",
onClick: () => this.onClick(false),
children: off || __mf_2$1.t("off")
}),
jsxRuntimeExports.jsx(__mf_16, {
style: buttonStyle,
color: isOn ? "primary" : "grey",
startIcon: onIcon,
onClick: () => this.onClick(true),
children: on || __mf_2$1.t("on")
})
]
});
}
componentDidUpdate() {
if (!this.refService.current) {
return;
}
if (this.state.rxData.type === "image" || this.state.rxData.type === "html" || this.state.rxData.type === "button" && this.state.rxData.jquery_style) {
if (this.state.rxData.type === "button") {
const el = this.refService.current.getElementsByClassName("vis-widget-body");
if ((el == null ? void 0 : el.length) && !this.refService.current._jQueryDone) {
this.refService.current._jQueryDone = true;
window.jQuery(el[0]).button();
const textEl = el[0].getElementsByClassName("ui-button-text");
if (textEl == null ? void 0 : textEl.length) {
textEl[0].style.display = "flex";
textEl[0].style.alignItems = "center";
}
}
}
if (this.refService.current.clientWidth !== this.state.width || this.refService.current.clientHeight !== this.state.height) {
this.setState({
width: this.refService.current.clientWidth,
height: this.refService.current.clientHeight
});
}
}
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
const isOn = this.isOn();
const buttonStyle = {};
Object.keys(this.state.rxStyle).forEach((attr) => {
const value = this.state.rxStyle[attr];
if (value !== null && value !== void 0 && VisRxWidget.POSSIBLE_MUI_STYLES.includes(attr)) {
attr = attr.replace(/(-\w)/g, (text) => text[1].toUpperCase());
buttonStyle[attr] = value;
}
});
let type = this.state.rxData.type;
if (!type && this.props.tpl === "tplJquiRadio") {
type = "radio";
}
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}
buttonStyle.width = "100%";
buttonStyle.height = "100%";
buttonStyle.minWidth = "unset";
let content;
const bodyStyle = {
textAlign: "center"
};
if (type === "radio") {
content = this.renderRadio(isOn, buttonStyle);
} else if (type === "html" || type === "button" && this.state.rxData.jquery_style) {
bodyStyle.display = "flex";
bodyStyle.flexDirection = this.state.height > this.state.width ? "column" : "row";
bodyStyle.alignItems = "center";
bodyStyle.justifyContent = "center";
bodyStyle.cursor = !this.state.rxData.readOnly ? "pointer" : void 0;
content = this.renderHtml(isOn);
} else if (type === "switch") {
content = this.renderSwitch(isOn, buttonStyle);
} else if (type === "checkbox") {
content = this.renderCheckbox(isOn, buttonStyle);
} else if (type === "image") {
bodyStyle.cursor = !this.state.rxData.readOnly ? "pointer" : void 0;
content = this.renderIcon(isOn, !!buttonStyle);
} else if (type === "round-button") {
content = this.renderFab(isOn, buttonStyle);
} else if (!this.state.rxData.jquery_style) {
content = this.renderButton(isOn, buttonStyle);
}
const result = jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
style: bodyStyle,
onClick: type === "image" || type === "html" ? () => this.onClick() : void 0,
children: content
});
if (isOn && this.state.rxData.alt_true) {
return jsxRuntimeExports.jsx(__mf_126, {
title: this.state.rxData.alt_true,
slotProps: {
popper: {
sx: {
pointerEvents: "none"
}
}
},
children: result
});
}
if (!isOn && this.state.rxData.alt_false) {
return jsxRuntimeExports.jsx(__mf_126, {
title: this.state.rxData.alt_false,
slotProps: {
popper: {
sx: {
pointerEvents: "none"
}
}
},
children: result
});
}
return result;
}
}
class JQuiRadio extends JQuiBinaryState {
static getWidgetInfo() {
const widgetInfo = JQuiBinaryState.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiRadio",
visSet: "jqui",
visName: "Radiobuttons on/off",
visWidgetLabel: "jqui_radio_buttons_on_off",
visPrev: "widgets/jqui/img/Prev_RadioButtonsOnOff.png",
visOrder: 15,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 150,
height: 45
}
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_binary_control_note"
});
const type = JQuiBinaryState.findField(newWidgetInfo, "type");
if (type) {
type.default = "radio";
}
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiRadio.getWidgetInfo();
}
}
const BUTTONS = {
AUTO: "thermostat_auto",
MANUAL: "pan_tool",
VACATION: "houseboat",
PARTY: "celebration",
COOL: "ac_unit",
DRY: "dry",
ECO: "park",
FAN_ONLY: "air",
HEAT: "wb_sunny",
HEATING: "wb_sunny",
OFF: "power_settings_new"
};
class BulkEditor extends React.Component {
textRef;
constructor(props) {
super(props);
this.state = {
textDialogFocused: [],
states: null,
unit: "",
originalUnit: "",
usePercents: true,
min: 0,
max: 100,
steps: 4,
texts: [],
values: [],
colors: [],
activeColors: [],
icons: [],
images: [],
tooltips: [],
iconDialog: null,
imageDialog: null,
dialog: false,
dialogDelete: null
};
this.textRef = [];
}
static iconPromise;
static getIcon(icon) {
if (!(BulkEditor.iconPromise instanceof Promise)) {
BulkEditor.iconPromise = fetch("./material-icons/baseline.json").then((res) => res.json());
}
return BulkEditor.iconPromise.then((icons) => {
if (icons[icon]) {
return `data:image/svg+xml;base64,${icons[icon]}`;
}
return null;
}).catch((e2) => {
console.error(e2);
return null;
});
}
static async generateFields(data, socket) {
var _a, _b;
const oid = data.oid;
if (!oid || oid === "nothing_selected") {
return false;
}
if (data.count <= 1) {
let changed = false;
const obj = await socket.getObject(oid);
if ((_a = obj == null ? void 0 : obj.common) == null ? void 0 : _a.states) {
let states = obj.common.states;
if (Array.isArray(states)) {
states = {};
Object.keys(obj.common.states).forEach((key) => states[key] = key);
}
const keys = Object.keys(obj.common.states);
for (let i = 0; i < keys.length; i++) {
if (data[`text${i + 1}`] !== states[keys[i]]) {
data[`text${i + 1}`] = states[keys[i]];
changed = true;
}
if (data[`value${i + 1}`] !== keys[i]) {
data[`value${i + 1}`] = keys[i];
changed = true;
}
if (BUTTONS[states[keys[i]].toUpperCase()]) {
const icon = await BulkEditor.getIcon(BUTTONS[states[keys[i]].toUpperCase()]);
if (data[`icon${i + 1}`] !== icon) {
data[`icon${i + 1}`] = icon;
}
changed = true;
}
if (!data[`g_states-${i + 1}`]) {
data[`g_states-${i + 1}`] = true;
changed = true;
}
}
if (data.count !== keys.length) {
data.count = keys.length;
changed = true;
}
} else if (((_b = obj == null ? void 0 : obj.common) == null ? void 0 : _b.type) === "number") {
const unit = obj.common.unit || "";
const min = obj.common.min !== void 0 ? obj.common.min : 0;
const max = obj.common.max !== void 0 ? obj.common.max : 100;
const step = (max - min) / 4;
let count2 = 0;
for (let i = min; i < max; i += step) {
count2++;
const percent = Math.round((i - min) / (max - min) * 100);
if (data[`text${count2}`] !== percent.toString() + unit) {
data[`text${count2}`] = percent.toString() + unit;
changed = true;
}
if (data[`value${count2}`] !== i.toString()) {
data[`value${count2}`] = i.toString();
changed = true;
}
if (!data[`g_states-${count2}`]) {
data[`g_states-${count2}`] = true;
changed = true;
}
}
count2++;
if (data[`text${count2}`] !== 100 + unit) {
data[`text${count2}`] = 100 + unit;
changed = true;
}
if (data[`value${count2}`] !== max.toString()) {
data[`value${count2}`] = max.toString();
changed = true;
}
if (!data[`g_states-${count2}`]) {
data[`g_states-${count2}`] = true;
changed = true;
}
if (data.count !== count2) {
changed = true;
data.count = count2;
}
}
return changed ? data : false;
}
return false;
}
async calculateFirst(useStates) {
var _a, _b;
const newState = {
...this.state,
dialog: true
};
if (this.props.data.count < 1 || useStates !== void 0) {
const oid = this.props.data.oid;
if (oid && oid !== "nothing_selected") {
const obj = await this.props.socket.getObject(oid);
newState.texts = [];
newState.values = [];
if ((_a = obj == null ? void 0 : obj.common) == null ? void 0 : _a.states) {
newState.numbers = false;
let states = obj.common.states;
if (Array.isArray(states)) {
states = {};
Object.keys(obj.common.states).forEach((key) => states[key] = key);
}
newState.states = states;
const keys = Object.keys(states);
newState.texts = [];
newState.values = [];
for (let i = 0; i < keys.length; i++) {
newState.texts[i] = states[keys[i]];
newState.values[i] = keys[i];
if (BUTTONS[states[keys[i]].toUpperCase()]) {
newState.icons[i] = await BulkEditor.getIcon(BUTTONS[states[keys[i]].toUpperCase()]);
}
}
} else if (((_b = obj == null ? void 0 : obj.common) == null ? void 0 : _b.type) === "number") {
newState.numbers = true;
newState.unit = obj.common.unit || "";
newState.min = obj.common.min !== void 0 ? obj.common.min : 0;
newState.max = obj.common.max !== void 0 ? obj.common.max : 100;
newState.step = (newState.max - newState.min) / 4;
for (let i = newState.min; i < newState.max; i += newState.step) {
const value = Math.round((i - newState.min) / (newState.max - newState.min) * 100);
newState.texts.push(value + newState.unit);
newState.values.push(i);
}
newState.texts.push(100 + newState.unit);
newState.values.push(newState.max);
}
}
} else {
newState.texts = [];
newState.values = [];
newState.icons = [];
newState.images = [];
newState.colors = [];
newState.activeColors = [];
newState.tooltips = [];
for (let i = 0; i < this.props.data.count; i++) {
newState.texts[i] = this.props.data[`text${i + 1}`] || "";
newState.values[i] = this.props.data[`value${i + 1}`] || "";
newState.icons[i] = this.props.data[`icon${i + 1}`] || "";
newState.images[i] = this.props.data[`image${i + 1}`] || "";
newState.colors[i] = this.props.data[`color${i + 1}`] || "";
newState.activeColors[i] = this.props.data[`activeColor${i + 1}`] || "";
newState.tooltips[i] = this.props.data[`tooltip${i + 1}`] || "";
}
}
this.setState(newState);
}
renderDeleteDialog() {
if (this.state.dialogDelete === null) {
return null;
}
return jsxRuntimeExports.jsxs(__mf_32$1, {
open: true,
onClose: () => this.setState({
dialogDelete: null
}),
children: [
jsxRuntimeExports.jsx(__mf_34, {
children: __mf_2$1.t("jqui_Are you sure?")
}),
jsxRuntimeExports.jsxs(__mf_33, {
children: [
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "primary",
startIcon: jsxRuntimeExports.jsx(__mf_2326, {}),
onClick: () => {
const values2 = [
...this.state.values
];
const texts = [
...this.state.texts
];
const icons = [
...this.state.icons
];
const images = [
...this.state.images
];
const colors = [
...this.state.colors
];
const activeColors = [
...this.state.activeColors
];
const tooltips = [
...this.state.tooltips
];
if (typeof this.state.dialogDelete === "number") {
values2.splice(this.state.dialogDelete, 1);
texts.splice(this.state.dialogDelete, 1);
icons.splice(this.state.dialogDelete, 1);
images.splice(this.state.dialogDelete, 1);
colors.splice(this.state.dialogDelete, 1);
tooltips.splice(this.state.dialogDelete, 1);
activeColors.splice(this.state.dialogDelete, 1);
}
this.setState({
values: values2,
texts,
icons,
images,
colors,
activeColors,
tooltips,
dialogDelete: null
});
},
children: __mf_2$1.t("Delete")
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "grey",
startIcon: jsxRuntimeExports.jsx(__mf_1776, {}),
onClick: () => this.setState({
dialogDelete: null
}),
children: __mf_2$1.t("Cancel")
})
]
})
]
}, "deleteDialog");
}
renderMaterialDialog() {
if (this.state.iconDialog === null) {
return null;
}
return jsxRuntimeExports.jsx(MaterialIconSelector, {
theme: this.props.theme,
additionalSets: this.props.additionalSets,
themeType: this.props.themeType,
value: this.state.icons[this.state.iconDialog],
onClose: (icon) => {
this.setState({
iconDialog: null
});
if (icon !== null) {
const icons = [
...this.state.icons
];
if (typeof this.state.iconDialog === "number") {
icons[this.state.iconDialog] = icon;
}
this.setState({
icons,
iconDialog: null
});
}
}
}, "iconDialog");
}
renderImageDialog() {
if (this.state.imageDialog === null) {
return null;
}
let value = this.state.images[this.state.imageDialog];
if (value.startsWith("../")) {
value = value.substring(3);
} else if (value.startsWith("_PRJ_NAME/")) {
value = value.replace("_PRJ_NAME/", `../${this.props.adapterName}.${this.props.instance}/${this.props.projectName}/`);
}
const onChange = (selected, isClose) => {
const projectPrefix = `${this.props.adapterName}.${this.props.instance}/${this.props.projectName}/`;
if (selected == null ? void 0 : selected.startsWith(projectPrefix)) {
selected = `_PRJ_NAME/${selected.substring(projectPrefix.length)}`;
} else if (selected == null ? void 0 : selected.startsWith("/")) {
selected = `..${selected}`;
} else if (selected && !selected.startsWith(".")) {
selected = `../${selected}`;
}
const images = [
...this.state.images
];
if (typeof this.state.imageDialog === "number") {
images[this.state.imageDialog] = selected || "";
}
this.setState({
images
});
this.setState({
imageDialog: null
});
};
return jsxRuntimeExports.jsx(__mf_110, {
theme: this.props.theme,
title: __mf_2$1.t("jqui_Select file"),
onClose: () => this.setState({
imageDialog: null
}),
restrictToFolder: `${this.props.adapterName}.${this.props.instance}/${this.props.projectName}`,
allowNonRestricted: true,
allowUpload: true,
allowDownload: true,
allowCreateFolder: true,
allowDelete: true,
allowView: true,
showToolbar: true,
imagePrefix: "../",
selected: value,
filterByType: "images",
onOk: (selectedOrArray) => onChange(Array.isArray(selectedOrArray) ? selectedOrArray[0] : selectedOrArray),
socket: this.props.socket
}, "imageDialog");
}
onEnter() {
var _a, _b;
const values2 = [
...this.state.values
];
if ((_a = this.state.editDialog) == null ? void 0 : _a.add) {
const index = values2.length;
values2[index] = this.state.editDialog.value;
const texts = [
...this.state.texts
];
const icons = [
...this.state.icons
];
const images = [
...this.state.images
];
const colors = [
...this.state.colors
];
const activeColors = [
...this.state.activeColors
];
const tooltips = [
...this.state.tooltips
];
texts[index] = texts[index] || "";
icons[index] = icons[index] || "";
images[index] = images[index] || "";
colors[index] = colors[index] || "";
activeColors[index] = activeColors[index] || "";
tooltips[index] = tooltips[index] || "";
this.setState({
values: values2,
texts,
icons,
images,
colors,
activeColors,
tooltips,
editDialog: null
});
} else {
if (((_b = this.state.editDialog) == null ? void 0 : _b.index) !== void 0) {
values2[this.state.editDialog.index] = this.state.editDialog.value;
}
this.setState({
values: values2,
editDialog: null
});
}
}
renderEditDialog() {
if (!this.state.editDialog) {
return null;
}
const isUnique = !this.state.values.map((v2) => typeof v2 === "string" ? v2.trim() : v2).includes(this.state.editDialog.value);
return jsxRuntimeExports.jsxs(__mf_32$1, {
maxWidth: "sm",
open: true,
onClose: () => this.setState({
editDialog: null
}),
children: [
jsxRuntimeExports.jsx(__mf_36, {
children: this.state.editDialog.add ? __mf_2$1.t("jqui_Add new value") : __mf_2$1.t("Edit")
}),
jsxRuntimeExports.jsx(__mf_34, {
children: jsxRuntimeExports.jsx(__mf_121, {
onKeyDown: (e2) => {
var _a;
return e2.key === "Enter" && isUnique && ((_a = this.state.editDialog) == null ? void 0 : _a.value) && this.onEnter();
},
fullWidth: true,
autoFocus: true,
variant: "standard",
label: __mf_2$1.t("Value"),
value: this.state.editDialog.value,
onChange: (e2) => {
if (this.state.editDialog) {
this.setState((prevState) => ({
editDialog: {
value: e2.target.value,
add: prevState.editDialog.add,
index: prevState.editDialog.index
}
}));
}
}
})
}),
jsxRuntimeExports.jsxs(__mf_33, {
children: [
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "primary",
disabled: !isUnique || !this.state.editDialog.value,
startIcon: this.state.editDialog.add ? jsxRuntimeExports.jsx(__mf_85$1, {}) : jsxRuntimeExports.jsx(__mf_1671, {}),
onClick: () => this.onEnter(),
children: this.state.editDialog.add ? __mf_2$1.t("Add") : __mf_2$1.t("Apply")
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "grey",
startIcon: jsxRuntimeExports.jsx(__mf_1776, {}),
onClick: () => this.setState({
editDialog: null
}),
children: __mf_2$1.t("Cancel")
})
]
})
]
}, "editDialog");
}
renderLine(i) {
var _a;
let image = null;
this.textRef[i] = this.textRef[i] || React.createRef();
if (!this.state.icons[i]) {
const value = this.state.images[i];
const urlPopper = jsxRuntimeExports.jsx(__mf_83, {
open: !!(this.state.textDialogFocused[i] && (value == null ? void 0 : value.toString().startsWith(window.location.origin))),
anchorEl: (_a = this.textRef[i]) == null ? void 0 : _a.current,
placement: "bottom",
transition: true,
children: ({ TransitionProps }) => jsxRuntimeExports.jsx(__mf_40, {
...TransitionProps,
timeout: 350,
children: jsxRuntimeExports.jsxs(__mf_81, {
children: [
jsxRuntimeExports.jsxs(__mf_16, {
style: {
textTransform: "none"
},
onClick: () => {
const images = [
...this.state.images
];
images[i] = `.${images[i].toString().slice(window.location.origin.length)}`;
this.setState({
images
});
},
children: [
__mf_2$1.t("jqui_Replace to"),
` .${value.toString().slice(window.location.origin.length)}`
]
}),
jsxRuntimeExports.jsx(__mf_53, {
size: "small",
onClick: () => {
const textDialogFocused = [
...this.state.textDialogFocused
];
textDialogFocused[i] = false;
this.setState({
textDialogFocused
});
},
children: jsxRuntimeExports.jsx(__mf_1766, {
fontSize: "small"
})
})
]
})
})
}, "popper");
image = [
jsxRuntimeExports.jsx(__mf_121, {
variant: "standard",
fullWidth: true,
slotProps: {
input: {
sx: {
...commonStyles.clearPadding,
...commonStyles.fieldContent
},
endAdornment: jsxRuntimeExports.jsx(__mf_16, {
size: "small",
onClick: () => this.setState({
imageDialog: i
}),
children: "..."
})
}
},
ref: this.textRef[i],
value: this.state.images[i] || "",
onFocus: () => {
const textDialogFocused = [
...this.state.textDialogFocused
];
textDialogFocused[i] = true;
this.setState({
textDialogFocused
});
},
onBlur: () => {
const textDialogFocused = [
...this.state.textDialogFocused
];
textDialogFocused[i] = false;
this.setState({
textDialogFocused
});
},
onChange: (e2) => {
const images = [
...this.state.images
];
images[i] = e2.target.value;
this.setState({
images
});
}
}, "image"),
urlPopper
];
}
let button;
let iconSrc = this.state.images[i] || this.state.icons[i] || "";
if (iconSrc.startsWith("_PRJ_NAME/")) {
iconSrc = iconSrc.replace("_PRJ_NAME/", `../${this.props.adapterName}.${this.props.instance}/${this.props.projectName}/`);
}
if (this.props.data.type === "radio") {
const icon = jsxRuntimeExports.jsx(__mf_15$1, {
src: iconSrc,
style: {
width: 24,
height: 24
}
});
const text = jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
gap: 4
},
children: [
icon,
this.state.texts[i]
]
});
button = jsxRuntimeExports.jsx(__mf_43, {
control: jsxRuntimeExports.jsx(__mf_85, {
onClick: () => this.setState({
activeLine: i
}),
checked: this.state.activeLine === i
}),
labelPlacement: "end",
label: text
});
} else if (this.props.data.type === "select") {
const icon = jsxRuntimeExports.jsx(__mf_15$1, {
src: iconSrc,
style: {
width: 24,
height: 24
}
});
const text = jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
gap: 4
},
children: [
icon,
this.state.texts[i]
]
});
button = jsxRuntimeExports.jsx(__mf_72, {
onClick: () => this.setState({
activeLine: i
}),
selected: this.state.activeLine === i,
children: text
});
} else {
button = jsxRuntimeExports.jsx(__mf_16, {
style: {
color: this.state.activeLine === i ? this.state.activeColors[i] || this.state.colors[i] : this.state.colors[i] || void 0
},
color: this.state.activeLine === i ? "primary" : "grey",
variant: this.props.data.variant === void 0 ? "contained" : this.props.data.variant === "standard" ? "contained" : this.props.data.variant,
onClick: () => this.setState({
activeLine: i
}),
startIcon: jsxRuntimeExports.jsx(__mf_15$1, {
src: iconSrc,
style: {
width: 24,
height: 24
}
}),
children: this.state.texts[i]
});
}
return jsxRuntimeExports.jsxs(__mf_118, {
children: [
jsxRuntimeExports.jsxs(__mf_113, {
style: {
display: "flex",
alignItems: "center"
},
children: [
this.state.values[i],
jsxRuntimeExports.jsx(__mf_53, {
size: "small",
onClick: () => this.setState((prevState) => ({
editDialog: {
add: false,
index: i,
value: prevState.values[i]
}
})),
children: jsxRuntimeExports.jsx(__mf_2876, {})
})
]
}),
jsxRuntimeExports.jsx(__mf_113, {
children: jsxRuntimeExports.jsx(__mf_121, {
size: "small",
fullWidth: true,
variant: "standard",
value: this.state.texts[i] || "",
onChange: (e2) => {
const texts = [
...this.state.texts
];
texts[i] = e2.target.value;
this.setState({
texts
});
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
children: this.state.images[i] ? null : jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
width: "100%",
alignItems: "center"
},
children: [
jsxRuntimeExports.jsx(__mf_121, {
fullWidth: true,
size: "small",
variant: "standard",
value: this.state.icons[i] || "",
onChange: (e2) => {
const icons = [
...this.state.icons
];
icons[i] = e2.target.value;
this.setState({
icons
});
},
slotProps: {
input: {
endAdornment: this.state.icons[i] ? jsxRuntimeExports.jsx(__mf_53, {
size: "small",
onClick: () => {
const icons = [
...this.state.icons
];
icons[i] = "";
this.setState({
icons
});
},
children: jsxRuntimeExports.jsx(__mf_1766, {})
}) : null,
sx: {
...commonStyles.clearPadding,
...commonStyles.fieldContent
}
}
}
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: this.state.icons[i] ? "outlined" : void 0,
color: this.state.icons[i] ? "grey" : void 0,
onClick: () => this.setState({
iconDialog: i
}),
children: this.state.icons[i] ? jsxRuntimeExports.jsx(__mf_15$1, {
src: this.state.icons[i],
style: {
width: 36,
height: 36
}
}) : "..."
})
]
})
}),
jsxRuntimeExports.jsx(__mf_113, {
children: image
}),
jsxRuntimeExports.jsx(__mf_113, {
children: jsxRuntimeExports.jsx(__mf_4, {
value: this.state.colors[i],
onChange: (color) => {
const colors = [
...this.state.colors
];
colors[i] = color;
this.setState({
colors
});
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
children: jsxRuntimeExports.jsx(__mf_4, {
value: this.state.activeColors[i],
onChange: (color) => {
const activeColors = [
...this.state.activeColors
];
activeColors[i] = color;
this.setState({
activeColors
});
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
children: jsxRuntimeExports.jsx(__mf_121, {
size: "small",
fullWidth: true,
variant: "standard",
value: this.state.tooltips[i] || "",
onChange: (e2) => {
const tooltips = [
...this.state.tooltips
];
tooltips[i] = e2.target.value;
this.setState({
tooltips
});
}
})
}),
jsxRuntimeExports.jsx(__mf_113, {
children: jsxRuntimeExports.jsx(__mf_53, {
onClick: () => this.setState({
dialogDelete: i
}),
children: jsxRuntimeExports.jsx(__mf_2326, {})
})
}),
jsxRuntimeExports.jsx(__mf_113, {
children: button
})
]
}, `${this.state.values[i]}_${i}`);
}
renderMinMaxDialog() {
if (!this.state.minMaxDialog) {
return null;
}
const buttons = [];
const step = Math.round((this.state.max - this.state.min) / this.state.steps);
for (let i = this.state.min; i < this.state.max; i += step) {
let value = i;
if (this.state.usePercents) {
value = Math.round((i - this.state.min) / (this.state.max - this.state.min) * 100);
}
buttons.push(jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
disabled: true,
children: Math.round(value).toString() + this.state.unit
}, i));
}
buttons.push(jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
disabled: true,
children: (this.state.usePercents ? 100 : this.state.max).toString() + this.state.unit
}, 1e3));
return jsxRuntimeExports.jsxs(__mf_32$1, {
fullWidth: true,
maxWidth: "md",
open: true,
onClose: () => this.setState({
minMaxDialog: false
}),
children: [
jsxRuntimeExports.jsx(__mf_36, {
children: __mf_2$1.t("jqui_Number settings")
}),
jsxRuntimeExports.jsxs(__mf_34, {
children: [
this.state.min !== 0 || this.state.max !== 100 ? jsxRuntimeExports.jsx("div", {
style: {
width: "100%"
},
children: jsxRuntimeExports.jsx(__mf_43, {
control: jsxRuntimeExports.jsx(__mf_25, {
checked: this.state.usePercents,
onChange: (e2) => {
let unit = this.state.unit;
if (e2.target.checked) {
unit = unit || "%";
} else if (unit === "%") {
unit = this.state.originalUnit || "";
}
this.setState({
usePercents: e2.target.checked,
unit
});
}
}),
label: __mf_2$1.t("jqui_Percents")
})
}) : null,
jsxRuntimeExports.jsx(__mf_121, {
fullWidth: true,
type: "number",
variant: "standard",
label: __mf_2$1.t("jqui_Minimum value"),
value: this.state.min,
onChange: (e2) => this.setState({
min: Number(e2.target.value)
})
}),
jsxRuntimeExports.jsx(__mf_121, {
fullWidth: true,
type: "number",
variant: "standard",
label: __mf_2$1.t("jqui_Maximum value"),
value: this.state.max,
onChange: (e2) => this.setState({
max: Number(e2.target.value)
})
}),
jsxRuntimeExports.jsxs("div", {
style: {
width: "100%"
},
children: [
jsxRuntimeExports.jsx("div", {
style: {
width: "100%"
},
children: __mf_2$1.t("Steps")
}),
jsxRuntimeExports.jsx("div", {
style: {
width: "100%"
},
children: jsxRuntimeExports.jsx(__mf_92, {
value: this.state.steps,
step: 1,
valueLabelDisplay: "auto",
min: 2,
max: 20,
marks: [
{
value: 0,
label: "0"
},
{
value: 20,
label: "20"
}
],
onChange: (_e, value) => this.setState({
steps: value
})
})
})
]
}),
jsxRuntimeExports.jsx(__mf_121, {
fullWidth: true,
variant: "standard",
label: __mf_2$1.t("Unit"),
value: this.state.unit,
onChange: (e2) => this.setState({
unit: e2.target.value
})
}),
jsxRuntimeExports.jsx(__mf_18, {
style: {
marginTop: 20
},
variant: this.props.data.variant === void 0 ? "contained" : this.props.data.variant === "standard" ? "contained" : this.props.data.variant,
children: buttons
})
]
}),
jsxRuntimeExports.jsxs(__mf_33, {
children: [
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "primary",
startIcon: jsxRuntimeExports.jsx(__mf_1671, {}),
onClick: () => {
const newState = {
...this.state,
minMaxDialog: false,
values: [],
texts: [
...this.state.texts
],
icons: [
...this.state.icons
],
images: [
...this.state.images
],
colors: [
...this.state.colors
],
activeColors: [
...this.state.activeColors
],
tooltips: [
...this.state.tooltips
]
};
const _step = Math.round((this.state.max - this.state.min) / this.state.steps);
let index = 0;
for (let i = this.state.min; i < this.state.max; i += _step) {
if (this.state.usePercents) {
newState.texts[index] = Math.round((i - this.state.min) / (this.state.max - this.state.min) * 100) + this.state.unit;
} else {
newState.texts[index] = i + this.state.unit;
}
newState.values[index] = i.toString();
newState.icons[index] = newState.icons[index] || "";
newState.images[index] = newState.images[index] || "";
newState.colors[index] = newState.colors[index] || "";
newState.activeColors[index] = newState.activeColors[index] || "";
newState.tooltips[index] = newState.tooltips[index] || "";
index++;
}
newState.values[index] = this.state.max.toString();
newState.texts[index] = 100 + this.state.unit;
this.setState(newState);
},
children: __mf_2$1.t("Apply")
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "grey",
startIcon: jsxRuntimeExports.jsx(__mf_1776, {}),
onClick: () => this.setState({
minMaxDialog: false
}),
children: __mf_2$1.t("Cancel")
})
]
})
]
}, "minMaxDialog");
}
renderDialog() {
if (!this.state.dialog) {
return null;
}
return jsxRuntimeExports.jsxs(__mf_32$1, {
fullWidth: true,
maxWidth: "lg",
open: true,
onClose: () => this.setState({
dialog: false
}),
children: [
jsxRuntimeExports.jsx(__mf_36, {
children: __mf_2$1.t("jqui_Bulk edit")
}),
jsxRuntimeExports.jsxs(__mf_34, {
children: [
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
onClick: async () => {
var _a, _b, _c;
const oid = this.props.data.oid;
const newState = {
...this.state,
minMaxDialog: true,
usePercents: true,
min: this.state.min,
max: this.state.max || 100,
steps: 4,
unit: "%"
};
if (oid && oid !== "nothing_selected") {
const obj = await this.props.socket.getObject(oid);
newState.min = (_a = obj == null ? void 0 : obj.common) == null ? void 0 : _a.min;
if (newState.min === void 0 || newState.min === null) {
newState.min = 0;
}
newState.max = (_b = obj == null ? void 0 : obj.common) == null ? void 0 : _b.max;
if (newState.max === void 0 || newState.max === null) {
newState.max = 100;
}
newState.originalUnit = ((_c = obj == null ? void 0 : obj.common) == null ? void 0 : _c.unit) || "";
}
this.setState(newState);
},
children: __mf_2$1.t("jqui_Generate steps")
}),
this.state.states ? jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
onClick: () => this.calculateFirst(true),
children: __mf_2$1.t("jqui_Generate states")
}) : null,
jsxRuntimeExports.jsxs(__mf_111, {
children: [
jsxRuntimeExports.jsx(__mf_116, {
children: jsxRuntimeExports.jsxs(__mf_118, {
children: [
jsxRuntimeExports.jsx(__mf_113, {
children: __mf_2$1.t("Value")
}),
jsxRuntimeExports.jsx(__mf_113, {
children: __mf_2$1.t("Text")
}),
jsxRuntimeExports.jsx(__mf_113, {
children: __mf_2$1.t("Icon")
}),
jsxRuntimeExports.jsx(__mf_113, {
children: __mf_2$1.t("Image")
}),
jsxRuntimeExports.jsx(__mf_113, {
children: __mf_2$1.t("color")
}),
jsxRuntimeExports.jsx(__mf_113, {
children: __mf_2$1.t("jqui_active_color")
}),
jsxRuntimeExports.jsx(__mf_113, {
children: __mf_2$1.t("jqui_tooltip")
}),
jsxRuntimeExports.jsx(__mf_113, {
children: jsxRuntimeExports.jsx(__mf_39, {
size: "small",
style: {
marginRight: 8
},
onClick: () => this.setState({
editDialog: {
add: true,
value: ""
}
}),
children: jsxRuntimeExports.jsx(__mf_85$1, {})
})
}),
jsxRuntimeExports.jsx(__mf_113, {
children: __mf_2$1.t("jqui_Example")
})
]
})
}),
jsxRuntimeExports.jsx(__mf_112, {
children: this.state.values.map((_, i) => this.renderLine(i))
})
]
})
]
}),
jsxRuntimeExports.jsxs(__mf_33, {
children: [
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "primary",
startIcon: jsxRuntimeExports.jsx(__mf_1671, {}),
onClick: () => {
const data = {
...this.props.data
};
for (let i = 0; i < this.state.values.length; i++) {
data[`text${i + 1}`] = this.state.texts[i];
data[`value${i + 1}`] = this.state.values[i];
data[`icon${i + 1}`] = this.state.icons[i];
data[`image${i + 1}`] = this.state.images[i];
data[`color${i + 1}`] = this.state.colors[i];
data[`tooltip${i + 1}`] = this.state.tooltips[i];
data[`activeColor${i + 1}`] = this.state.activeColors[i];
data[`g_states-${i + 1}`] = true;
}
for (let i = this.state.values.length + 1; i < 30; i++) {
delete data[`text${i}`];
delete data[`value${i}`];
delete data[`icon${i}`];
delete data[`image${i}`];
delete data[`color${i}`];
delete data[`tooltip${i}`];
delete data[`activeColor${i}`];
delete data[`g_states-${i}`];
}
data.count = this.state.values.length;
this.props.onDataChange(data);
this.setState({
dialog: false
});
},
children: __mf_2$1.t("Apply")
}),
jsxRuntimeExports.jsx(__mf_16, {
variant: "contained",
color: "grey",
startIcon: jsxRuntimeExports.jsx(__mf_1776, {}),
onClick: () => this.setState({
dialog: false
}),
children: __mf_2$1.t("Cancel")
})
]
})
]
}, "dialog");
}
render() {
return [
jsxRuntimeExports.jsx(__mf_16, {
fullWidth: true,
variant: "outlined",
disabled: !this.props.data.oid,
onClick: () => this.calculateFirst(),
children: __mf_2$1.t("jqui_generate")
}, "button"),
this.renderMinMaxDialog(),
this.renderImageDialog(),
this.renderMaterialDialog(),
this.renderDeleteDialog(),
this.renderDialog(),
this.renderEditDialog()
];
}
}
class JQuiState extends VisRxWidget {
controlTimeout = null;
constructor(props) {
super(props);
Object.assign(this.state, {
value: "",
object: null
});
}
static getWidgetInfo() {
return {
id: "tplJquiButtonState",
visSet: "jqui",
visName: "States control",
visWidgetLabel: "jqui_states_control",
visPrev: "widgets/jqui/img/Prev_ButtonState.png",
visOrder: 14,
visAttrs: [
{
name: "common",
fields: [
{
name: "type",
label: "jqui_type",
type: "select",
noTranslation: true,
default: "button",
options: [
"button",
"select",
"radio",
"slider"
]
},
{
name: "oid",
type: "id",
onChange: async (_field, data, changeData, socket) => {
if (data.oid) {
if (await BulkEditor.generateFields(data, socket)) {
changeData(data);
}
}
}
},
{
name: "readOnly",
type: "checkbox"
},
{
name: "click_id",
type: "id",
noSubscribe: true,
hidden: (data) => !!data.readOnly
},
{
name: "count",
type: "slider",
min: 0,
default: 1,
max: 10,
hidden: (data) => !!data.percents
},
{
type: "custom",
component: (_field, data, onDataChange, props) => jsxRuntimeExports.jsx(BulkEditor, {
theme: props.context.theme,
data: data || {},
onDataChange,
socket: props.context.socket,
themeType: props.context.theme.palette.mode === "dark" ? "dark" : "light",
adapterName: props.context.adapterName,
instance: props.context.instance,
projectName: props.context.projectName,
additionalSets: props.context.additionalSets
})
},
{
name: "variant",
label: "jqui_variant",
type: "select",
noTranslation: true,
options: [
"contained",
"outlined",
"text",
"standard"
],
default: "contained",
hidden: (data) => data.type !== "button" && data.type !== "select"
},
{
name: "orientation",
label: "orientation",
type: "select",
options: [
"horizontal",
"vertical"
],
default: "horizontal",
hidden: (data) => data.type !== "button" && data.type !== "slider"
},
{
name: "widgetTitle",
label: "jqui_name",
type: "text"
},
{
name: "timeout",
label: "jqui_set_timeout",
type: "number",
hidden: (data) => data.type !== "slider"
},
{
name: "open",
label: "jqui_open",
type: "checkbox",
hidden: (data) => data.type !== "select"
}
]
},
{
name: "states",
label: "jqui_group_value",
indexFrom: 1,
indexTo: "count",
hidden: (data) => !!data.percents,
fields: [
{
name: "value",
type: "text",
label: "jqui_value",
default: "0"
},
{
name: "test",
type: "checkbox",
label: "jqui_test",
onChange: (field, data, changeData, _socket, index) => {
if (data[field.name]) {
let changed = false;
for (let i = 1; i <= data.count; i++) {
if (i !== index) {
if (data[`test${i}`]) {
changed = true;
data[`test${i}`] = false;
}
}
}
changed && changeData(data);
}
return Promise.resolve();
},
hidden: (data, index) => data.type === "slider" || data[`value${index}`] === "" || data[`value${index}`] === null || data[`value${index}`] === void 0
},
{
name: "onlyIcon",
type: "checkbox",
label: "jqui_only_icon"
},
{
name: "text",
default: __mf_2$1.t("Value"),
type: "text",
label: "jqui_text",
hidden: (data, index) => !!data[`onlyIcon${index}`] || data[`value${index}`] === "" || data[`value${index}`] === null || data[`value${index}`] === void 0
},
{
name: "color",
type: "color",
label: "color",
hidden: (data, index) => data.type === "slider" || data[`value${index}`] === "" || data[`value${index}`] === null || data[`value${index}`] === void 0
},
{
name: "activeColor",
type: "color",
label: "jqui_active_color",
hidden: (data, index) => data.type === "slider" || data[`value${index}`] === "" || data[`value${index}`] === null || data[`value${index}`] === void 0
},
{
name: "image",
label: "jqui_image",
type: "image",
hidden: (data, index) => data.type === "slider" || !!data.icon || data[`value${index}`] === "" || data[`value${index}`] === null || data[`value${index}`] === void 0
},
{
name: "icon",
label: "jqui_icon",
type: "icon64",
hidden: (data, index) => data.type === "slider" || !!data.image || data[`value${index}`] === "" || data[`value${index}`] === null || data[`value${index}`] === void 0
},
{
name: "tooltip",
label: "jqui_tooltip",
type: "text",
hidden: (data, index) => data.type === "slider" || data[`value${index}`] === "" || data[`value${index}`] === null || data[`value${index}`] === void 0
}
]
}
],
visDefaultStyle: {
width: 300,
height: 45
}
};
}
async componentDidMount() {
super.componentDidMount();
if (this.props.tpl === "tplJquiRadioSteps" && this.state.data && this.props.context.onWidgetsChanged && this.state.data.count === void 0) {
const data = deepClone(this.state.data);
data.count = 5;
const min = parseFloat(data.min || 0);
const max = parseFloat(data.max || 100);
data.value1 = min;
data.text1 = __mf_2$1.t("jqui_off");
data["g_states-1"] = true;
data.value5 = max;
data.text5 = "100%";
data["g_states-5"] = true;
data.value2 = (max - min) * 0.25 + min;
data.text2 = "25%";
data["g_states-2"] = true;
data.value3 = (max - min) * 0.5 + min;
data.text3 = "50%";
data["g_states-3"] = true;
data.value4 = (max - min) * 0.75 + min;
data.text4 = "75%";
data["g_states-4"] = true;
data.min = null;
data.max = null;
setTimeout(() => this.props.context.onWidgetsChanged([
{
wid: this.props.id,
view: this.props.view,
data
}
]), 100);
}
if ((this.props.tpl === "tplJquiRadioList" || this.props.tpl === "tplJquiSelectList") && this.state.data && this.state.data.values && this.state.data.texts && this.props.context.onWidgetsChanged) {
const values2 = this.state.data.values.split(";");
const texts = this.state.data.texts.split(";");
const data = deepClone(this.state.data);
data.values = null;
data.texts = null;
data.count = values2.length;
for (let i = 1; i <= values2.length; i++) {
data[`value${i}`] = values2[i - 1];
data[`text${i}`] = texts[i - 1];
data[`g_states-${i}`] = true;
}
data.type = this.props.tpl === "tplJquiRadioList" ? "radio" : "select";
if (this.props.context.onWidgetsChanged) {
setTimeout(() => this.props.context.onWidgetsChanged([
{
wid: this.props.id,
view: this.props.view,
data
}
]), 100);
}
}
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
try {
const state = await this.props.context.socket.getState(this.state.rxData.oid);
this.onStateUpdated(this.state.rxData.oid, state);
} catch (error) {
console.error(`Cannot get state ${this.state.rxData.oid}: ${error}`);
}
}
}
componentWillUnmount() {
super.componentWillUnmount();
if (this.controlTimeout) {
clearTimeout(this.controlTimeout);
this.controlTimeout = null;
}
}
static findField(widgetInfo, name) {
return VisRxWidget.findField(widgetInfo, name);
}
getWidgetInfo() {
return JQuiState.getWidgetInfo();
}
onStateUpdated(id, state) {
if (id === this.state.rxData.oid && state) {
const value = state.val === null || state.val === void 0 ? "" : state.val;
if (this.state.value !== value.toString()) {
this.setState({
value: value.toString()
});
}
}
}
getControlOid() {
if (this.state.rxData.click_id && this.state.rxData.click_id !== "nothing_selected") {
return this.state.rxData.click_id;
}
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
return this.state.rxData.oid;
}
return "";
}
onClick(indexOrValue, immediately) {
var _a;
if (this.state.rxData.readOnly || this.props.editMode) {
return;
}
if (this.state.rxData.type === "slider") {
if (this.controlTimeout) {
clearTimeout(this.controlTimeout);
}
this.controlTimeout = setTimeout(() => {
this.controlTimeout = null;
const oid = this.getControlOid();
if (oid) {
this.props.context.setValue(oid, parseFloat(indexOrValue));
}
}, immediately ? 0 : parseInt(this.state.rxData.timeout, 10) || 300);
this.setState({
value: indexOrValue
});
} else {
const oid = this.getControlOid();
if (oid) {
if (typeof this.state.object === "object" && ((_a = this.state.object) == null ? void 0 : _a.common.type) === "number") {
this.props.context.setValue(oid, parseFloat(this.state.rxData[`value${indexOrValue}`]));
} else {
this.props.context.setValue(oid, this.state.rxData[`value${indexOrValue}`]);
}
}
this.setState({
value: this.state.rxData[`value${indexOrValue}`]
});
}
}
getSelectedIndex(value) {
if (value === void 0) {
value = this.state.value;
}
if (this.props.editMode) {
for (let i = 1; i <= this.state.rxData.count; i++) {
if (this.state.rxData[`test${i}`]) {
return i;
}
}
}
for (let i = 1; i <= this.state.rxData.count; i++) {
if (this.state.rxData[`value${i}`] === value) {
return i;
}
}
return 0;
}
renderIcon(i, selectedIndex) {
let color;
const rxData = this.state.rxData;
let icon = rxData[`icon${i}`] || rxData[`image${i}`];
if (icon && rxData[`color${i}`]) {
color = rxData[`color${i}`];
if (i === selectedIndex && rxData[`activeColor${i}`]) {
color = rxData[`activeColor${i}`];
}
}
if (icon) {
if (icon.startsWith("_PRJ_NAME/")) {
icon = icon.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
const style2 = {
color
};
style2.width = "auto";
style2.height = 24;
return jsxRuntimeExports.jsx(__mf_15$1, {
style: style2,
src: icon
}, "icon");
}
return null;
}
renderText(i, selectedIndex) {
const rxData = this.state.rxData;
if (rxData[`onlyIcon${i}`]) {
return null;
}
let text = rxData[`text${i}`];
let color = rxData[`color${i}`];
if (i === selectedIndex && rxData[`activeColor${i}`]) {
color = rxData[`activeColor${i}`];
}
text = text || rxData[`value${i}`];
return jsxRuntimeExports.jsx("span", {
style: {
color
},
children: text
});
}
renderButton(i, selectedIndex, buttonStyle) {
const rxData = this.state.rxData;
const icon = this.renderIcon(i, selectedIndex);
const text = this.renderText(i, selectedIndex);
const button = jsxRuntimeExports.jsx(__mf_16, {
disabled: this.props.editMode,
style: {
...buttonStyle,
flexGrow: 1
},
startIcon: text ? icon : void 0,
color: selectedIndex === i ? "primary" : "grey",
onClick: () => this.onClick(i),
children: text || icon
}, i);
if (rxData[`tooltip${i}`]) {
return jsxRuntimeExports.jsx(__mf_126, {
title: rxData[`tooltip${i}`],
slotProps: {
popper: {
sx: {
pointerEvents: "none"
}
}
},
children: button
}, i);
}
return button;
}
renderRadio(i, selectedIndex, buttonStyle) {
const rxData = this.state.rxData;
const icon = this.renderIcon(i, selectedIndex);
let text = this.renderText(i, selectedIndex);
if (icon && text) {
text = jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
gap: 4
},
children: [
icon,
text
]
});
}
const button = jsxRuntimeExports.jsx(__mf_43, {
style: buttonStyle,
control: jsxRuntimeExports.jsx(__mf_85, {
disabled: this.props.editMode,
onClick: () => this.onClick(i),
checked: selectedIndex === i
}),
labelPlacement: "end",
label: text || icon
}, i);
if (rxData[`tooltip${i}`]) {
return jsxRuntimeExports.jsx(__mf_126, {
title: rxData[`tooltip${i}`],
slotProps: {
popper: {
sx: {
pointerEvents: "none"
}
}
},
children: button
}, i);
}
return button;
}
renderMenuItem(i, selectedIndex, buttonStyle) {
const rxData = this.state.rxData;
const icon = this.renderIcon(i, selectedIndex);
let text = this.renderText(i, selectedIndex);
if (icon && text) {
text = jsxRuntimeExports.jsxs("div", {
style: {
display: "flex",
gap: 4
},
children: [
icon,
text
]
});
}
return jsxRuntimeExports.jsx(__mf_72, {
title: rxData[`tooltip${i}`],
disabled: this.props.editMode,
selected: selectedIndex === i,
style: buttonStyle,
value: rxData[`value${i}`],
onClick: rxData.open ? () => this.onClick(i) : void 0,
children: text || icon
}, i);
}
renderWidgetBody(props) {
var _a;
super.renderWidgetBody(props);
const selectedIndex = this.getSelectedIndex();
const rxData = this.state.rxData;
if (((_a = this.state.object) == null ? void 0 : _a._id) !== this.state.rxData.oid && this.state.object !== false) {
Object.assign(this.state, {
object: false
});
setTimeout(async () => {
var _a2;
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
const obj = await this.props.context.socket.getObject(this.state.rxData.oid);
if ((_a2 = obj == null ? void 0 : obj.common) == null ? void 0 : _a2.type) {
this.setState({
object: {
_id: obj._id,
common: {
type: obj.common.type
},
type: "state",
native: {}
}
});
return;
}
}
this.setState({
object: {
_id: this.state.rxData.oid,
common: {
type: "string"
},
type: "state",
native: {}
}
});
}, 0);
}
const buttonStyle = {};
Object.keys(this.state.rxStyle).forEach((attr) => {
const value = rxData[attr];
if (value !== null && value !== void 0 && VisRxWidget.POSSIBLE_MUI_STYLES.includes(attr)) {
attr = attr.replace(/(-\w)/g, (text) => text[1].toUpperCase());
buttonStyle[attr] = value;
}
});
buttonStyle.minWidth = "unset";
if (buttonStyle.borderWidth) {
buttonStyle.borderWidth = VisBaseWidget.correctStylePxValue(buttonStyle.borderWidth);
}
if (buttonStyle.fontSize) {
buttonStyle.fontSize = VisBaseWidget.correctStylePxValue(buttonStyle.fontSize);
}
let content;
if ((!this.state.rxData.count || this.state.rxData.count === 1 && !rxData.text0 && !rxData.icon0 && !rxData.image0) && (!this.state.rxData.oid || this.state.rxData.oid === "nothing_selected")) {
content = jsxRuntimeExports.jsx(__mf_16, {
variant: "outlined",
style: {
width: "100%",
height: "100%"
},
children: __mf_2$1.t("Select object ID")
});
} else if (!this.state.rxData.count) {
content = jsxRuntimeExports.jsx(__mf_16, {
variant: "outlined",
style: {
width: "100%",
height: "100%"
},
children: __mf_2$1.t("Please define states")
});
} else if (this.state.rxData.type === "radio") {
const buttons = [];
for (let i = 1; i <= this.state.rxData.count; i++) {
buttons.push(this.renderRadio(i, selectedIndex, buttonStyle));
}
content = jsxRuntimeExports.jsx(__mf_86, {
style: {
width: "100%",
height: "100%"
},
children: buttons
});
} else if (this.state.rxData.type === "select") {
const buttons = [];
for (let i = 1; i <= this.state.rxData.count; i++) {
buttons.push(this.renderMenuItem(i, selectedIndex, buttonStyle));
}
let variant = "standard";
if (this.state.rxData.variant === "contained") {
variant = "filled";
} else if (this.state.rxData.variant === "outlined") {
variant = "outlined";
}
if (this.state.rxData.open) {
content = jsxRuntimeExports.jsx(__mf_63, {
style: {
width: "100%",
height: "100%"
},
children: buttons
});
} else {
content = jsxRuntimeExports.jsx(__mf_89, {
disabled: this.props.editMode,
style: {
width: "100%",
height: "100%"
},
value: this.state.value === void 0 ? "" : this.state.value,
onChange: (e2) => this.onClick(this.getSelectedIndex(e2.target.value)),
variant,
sx: {
"& .MuiSelect-select": variant === "filled" ? {
mb: "10px"
} : void 0
},
children: buttons
});
}
} else if (this.state.rxData.type === "slider") {
props.style.overflow = "visible";
const marks = [];
for (let i = 1; i <= this.state.rxData.count; i++) {
marks.push({
value: parseFloat(rxData[`value${i}`]) || 0,
label: rxData[`text${i}`] || 0
});
}
content = jsxRuntimeExports.jsx(__mf_92, {
disabled: this.props.editMode,
style: !this.state.rxData.orientation || this.state.rxData.orientation === "horizontal" ? {
marginLeft: 20,
marginRight: 20,
width: "calc(100% - 40px)"
} : {
marginTop: 10,
marginBottom: 10
},
value: parseFloat(this.state.value) || 0,
valueLabelDisplay: "auto",
min: marks[0].value,
max: marks[marks.length - 1].value,
orientation: this.state.rxData.orientation || "horizontal",
marks,
onChangeCommitted: (_e, value) => this.onClick(value, true),
onChange: (_e, value) => this.onClick(value)
});
} else {
const buttons = [];
for (let i = 1; i <= this.state.rxData.count; i++) {
buttons.push(this.renderButton(i, selectedIndex, buttonStyle));
}
content = jsxRuntimeExports.jsx(__mf_18, {
disabled: this.props.editMode,
style: {
width: "100%",
height: "100%"
},
orientation: this.state.rxData.orientation || "horizontal",
variant: this.state.rxData.variant === void 0 ? "contained" : this.state.rxData.variant === "standard" ? "text" : this.state.rxData.variant,
children: buttons
});
}
if (this.state.rxData.widgetTitle) {
content = jsxRuntimeExports.jsxs(__mf_42, {
fullWidth: true,
variant: this.state.rxData.variant === void 0 || this.state.rxData.variant === "text" ? "standard" : this.state.rxData.variant === "contained" ? "filled" : this.state.rxData.variant,
style: {
marginTop: this.state.rxData.type === "select" && this.state.rxData.variant === "outlined" ? 5 : void 0,
width: "100%",
height: this.state.rxData.type === "select" && this.state.rxData.variant === "outlined" ? "calc(100% - 5px)" : "100%"
},
children: [
this.state.rxData.type === "select" ? jsxRuntimeExports.jsx(__mf_60, {
children: this.state.rxData.widgetTitle
}) : jsxRuntimeExports.jsx(__mf_46, {
style: this.state.rxData.type === "slider" ? {
marginLeft: 10
} : void 0,
children: this.state.rxData.widgetTitle
}),
content
]
});
}
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: content
});
}
}
class JQuiRadioList extends JQuiState {
static getWidgetInfo() {
const widgetInfo = JQuiState.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiRadioList",
visSet: "jqui",
visName: "Radiobuttons ValueList",
visWidgetLabel: "jqui_radio_list",
visPrev: "widgets/jqui/img/Prev_RadioList.png",
visOrder: 15,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 250,
height: 45
}
};
const type = JQuiState.findField(newWidgetInfo, "type");
type.default = "radio";
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_state_note"
});
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiRadioList.getWidgetInfo();
}
}
class JQuiSelectList extends JQuiState {
static getWidgetInfo() {
const widgetInfo = JQuiState.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiSelectList",
visSet: "jqui",
visName: "Select ValueList",
visWidgetLabel: "jqui_select_list",
visPrev: "widgets/jqui/img/Prev_SelectList.png",
visOrder: 16,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 250,
height: 45
}
};
const type = JQuiState.findField(newWidgetInfo, "type");
type.default = "select";
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_state_note"
});
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiSelectList.getWidgetInfo();
}
}
class JQuiIconStatePushButton extends JQuiBinaryState {
static getWidgetInfo() {
const widgetInfo = JQuiBinaryState.getWidgetInfo();
const newWidgetInfo = {
id: "tplIconStatePushButton",
visSet: "jqui",
visName: "Binary Icon Push Button",
visWidgetLabel: "jqui_icon_state_push_button",
visPrev: "widgets/jqui/img/Prev_IconPushButton.png",
visOrder: 15,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 70,
height: 30
}
};
const pushMode = JQuiBinaryState.findField(newWidgetInfo, "pushMode");
if (pushMode) {
pushMode.default = true;
}
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_binary_control_note"
});
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiIconStatePushButton.getWidgetInfo();
}
}
class JQuiIconStateBool extends JQuiBinaryState {
static getWidgetInfo() {
const widgetInfo = JQuiBinaryState.getWidgetInfo();
const newWidgetInfo = {
id: "tplIconStateBool",
visSet: "jqui",
visName: "Binary Icon State",
visWidgetLabel: "jqui_icon_state_bool",
visPrev: "widgets/jqui/img/Prev_IconStateBool.png",
visOrder: 15,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 70,
height: 30
}
};
const iconFalse = JQuiBinaryState.findField(newWidgetInfo, "icon_false");
if (iconFalse) {
iconFalse.default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik05IDIxYzAgLjUuNCAxIDEgMWg0Yy42IDAgMS0uNSAxLTF2LTFIOXYxem0zLTE5QzguMSAyIDUgNS4xIDUgOWMwIDIuNCAxLjIgNC41IDMgNS43VjE3YzAgLjUuNCAxIDEgMWg2Yy42IDAgMS0uNSAxLTF2LTIuM2MxLjgtMS4zIDMtMy40IDMtNS43YzAtMy45LTMuMS03LTctN3oiLz48L3N2Zz4=";
}
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_binary_control_note"
});
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiIconStateBool.getWidgetInfo();
}
}
class JQuiRadioSteps extends JQuiState {
static getWidgetInfo() {
const widgetInfo = JQuiState.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiRadioSteps",
visSet: "jqui",
visName: "Radiobuttons 25%",
visWidgetLabel: "jqui_radio_steps",
visPrev: "widgets/jqui/img/Prev_RadioSteps.png",
visOrder: 25,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 350,
height: 35
}
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_state_note"
});
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiRadioSteps.getWidgetInfo();
}
}
class JQuiSlider extends VisRxWidget {
controlTimeout = null;
lastChanged = 0;
constructor(props) {
super(props);
Object.assign(this.state, {
value: "",
valueMax: null
});
}
static getWidgetInfo() {
return {
id: "tplJquiSlider",
visSet: "jqui",
visName: "Slider",
visWidgetLabel: "jqui_slider",
visPrev: "widgets/jqui/img/Prev_Slider.png",
visOrder: 24,
visAttrs: [
{
name: "common",
fields: [
{
name: "type",
label: "jqui_type",
type: "select",
options: [
{
value: "single",
label: "jqui_single"
},
{
value: "range",
label: "jqui_range"
}
]
},
{
name: "oid",
type: "id",
onChange: async (_field, data, changeData, socket) => {
var _a, _b, _c, _d, _e, _f, _g;
if (data.oid && data.oid !== "nothing_selected") {
const obj = await socket.getObject(data.oid);
let changed = false;
if (((_a = obj == null ? void 0 : obj.common) == null ? void 0 : _a.min) !== void 0 && ((_b = obj == null ? void 0 : obj.common) == null ? void 0 : _b.min) !== null) {
if (data.min !== obj.common.min) {
data.min = obj.common.min;
changed = true;
}
if (data.text !== obj.common.min.toString() + (obj.common.unit || "")) {
data.text = obj.common.min.toString() + (obj.common.unit || "");
changed = true;
}
}
if (((_c = obj == null ? void 0 : obj.common) == null ? void 0 : _c.max) !== void 0 && ((_d = obj == null ? void 0 : obj.common) == null ? void 0 : _d.max) !== null) {
if (data.max !== obj.common.max) {
data.max = obj.common.max;
changed = true;
}
if (data["text-2"] !== obj.common.max.toString() + (obj.common.unit || "")) {
data["text-2"] = obj.common.max.toString() + (obj.common.unit || "");
changed = true;
}
}
if ((_e = obj == null ? void 0 : obj.common) == null ? void 0 : _e.unit) {
if (data.unit !== obj.common.unit) {
data.unit = obj.common.unit;
changed = true;
}
}
if (!data.step) {
if (((_f = obj == null ? void 0 : obj.common) == null ? void 0 : _f.step) !== void 0 && ((_g = obj == null ? void 0 : obj.common) == null ? void 0 : _g.step) !== null) {
if (data.step !== obj.common.step) {
data.step = obj.common.step;
changed = true;
}
}
}
changed && changeData(data);
}
}
},
{
name: "click_id",
type: "id",
noSubscribe: true
},
{
name: "inverted",
type: "checkbox",
label: "jqui_inverted"
},
{
name: "min",
type: "number",
label: "jqui_min"
},
{
name: "max",
type: "number",
label: "jqui_max"
},
{
name: "min_distance",
type: "number",
hidden: (data) => data.type !== "range"
},
{
name: "shift_min_distance",
type: "checkbox",
hidden: (data) => data.type !== "range" || !data.min_distance
},
{
name: "step",
type: "number",
min: 0
},
{
name: "unit"
},
{
name: "timeout",
label: "jqui_set_timeout",
type: "number"
},
{
name: "oid-working",
label: "jqui_oid_working",
type: "id"
}
]
},
{
name: "second",
hidden: (data) => data.type !== "range",
fields: [
{
name: "inverted-2",
type: "checkbox",
label: "jqui_inverted"
},
{
name: "oid-2",
type: "id",
hidden: (data) => data.type !== "range"
},
{
name: "click_id-2",
type: "id",
noSubscribe: true,
hidden: (data) => !data["oid-2"] || data.type !== "range"
}
]
},
{
name: "style",
fields: [
{
name: "widgetTitle",
label: "jqui_name",
type: "text"
},
{
name: "orientation",
label: "orientation",
type: "select",
options: [
"horizontal",
"vertical"
],
default: "horizontal"
},
{
name: "text",
label: "jqui_text",
hidden: (data) => !!data.icon || !!data.image
},
{
name: "text-2",
label: "jqui_text_max",
hidden: (data) => !!data["icon-2"] || !!data["image-2"]
},
{
name: "image",
label: "jqui_image",
type: "image",
hidden: (data) => !!data.icon || !!data.text
},
{
name: "icon",
label: "jqui_icon",
type: "icon64",
hidden: (data) => !!data.image || !!data.text
},
{
name: "image-2",
label: "jqui_image_max",
type: "image",
hidden: (data) => !!data["icon-2"] || !!data["text-2"]
},
{
name: "icon-2",
label: "jqui_icon_max",
type: "icon64",
hidden: (data) => !!data["image-2"] || !!data["text-2"]
},
{
name: "valueLabelDisplay",
type: "select",
label: "jqui_value_label_display",
options: [
{
value: "auto",
label: "jqui_auto"
},
{
value: "on",
label: "jqui_on"
},
{
value: "off",
label: "jqui_off"
}
]
}
]
}
],
visDefaultStyle: {
width: 300,
height: 40
}
};
}
async componentDidMount() {
super.componentDidMount();
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
try {
const state = await this.props.context.socket.getState(this.state.rxData.oid);
this.onStateUpdated(this.state.rxData.oid, state);
} catch (error) {
console.error(`Cannot get state ${this.state.rxData.oid}: ${error}`);
}
}
if (this.state.rxData.type === "range" && this.state.rxData["oid-2"] && this.state.rxData["oid-2"] !== "nothing_selected") {
try {
const state = await this.props.context.socket.getState(this.state.rxData["oid-2"]);
this.onStateUpdated(this.state.rxData["oid-2"], state);
} catch (error) {
console.error(`Cannot get state ${this.state.rxData.oid}: ${error}`);
}
}
}
componentWillUnmount() {
super.componentWillUnmount();
if (this.controlTimeout) {
clearTimeout(this.controlTimeout);
this.controlTimeout = null;
}
}
static findField(widgetInfo, name) {
return VisRxWidget.findField(widgetInfo, name);
}
getWidgetInfo() {
return JQuiSlider.getWidgetInfo();
}
onStateUpdated(id, state) {
if (id === this.state.rxData.oid && state) {
let value = parseFloat(state.val === null || state.val === void 0 ? "0" : state.val) || 0;
if (this.state.rxData.inverted) {
value = parseFloat(this.state.rxData.max) - value + parseFloat(this.state.rxData.min);
}
if (this.state.value !== value.toString()) {
this.setState({
value: value.toString()
});
}
} else if (id === this.state.rxData["oid-2"] && state) {
let value = parseFloat(state.val === null || state.val === void 0 ? "0" : state.val) || 0;
if (this.state.rxData["inverted-2"]) {
value = parseFloat(this.state.rxData.max) - value + parseFloat(this.state.rxData.min);
}
if (this.state.valueMax !== value) {
this.setState({
valueMax: value
});
}
}
}
getControlOid(isMax) {
if (isMax) {
if (this.state.rxData["click_id-2"] && this.state.rxData["click_id-2"] !== "nothing_selected") {
return this.state.rxData["click_id-2"];
}
if (this.state.rxData["oid-2"] && this.state.rxData["oid-2"] !== "nothing_selected") {
return this.state.rxData["oid-2"];
}
} else {
if (this.state.rxData.click_id && this.state.rxData.click_id !== "nothing_selected") {
return this.state.rxData.click_id;
}
if (this.state.rxData.oid && this.state.rxData.oid !== "nothing_selected") {
return this.state.rxData.oid;
}
}
return "";
}
onChange(value, isMax, immediate2) {
if (this.props.editMode) {
return;
}
this.newState = this.newState || {};
const minDistance = isMax || this.state.rxData.type === "range" ? parseFloat(this.state.rxData.min_distance) || 0 : 0;
let valueMax;
let _value;
if (isMax) {
if (Array.isArray(value)) {
console.log(`Set ${value[0]} - ${value[1]}`);
_value = value[0];
valueMax = value[1];
if (minDistance) {
if (this.lastChanged === 2) {
if (this.state.rxData.shift_min_distance) {
valueMax = Math.max(valueMax, parseFloat(this.state.rxData.min) + minDistance);
if (valueMax - minDistance < _value) {
_value = valueMax - minDistance;
}
} else {
valueMax = Math.max(valueMax, parseFloat(this.state.value) + minDistance);
}
} else if (this.state.rxData.shift_min_distance) {
_value = Math.min(_value, parseFloat(this.state.rxData.max) - minDistance);
valueMax = this.state.valueMax;
if (valueMax - minDistance < _value) {
valueMax = _value + minDistance;
}
} else {
_value = Math.min(_value, this.state.valueMax - minDistance);
}
}
console.log(`Set ${_value} - ${valueMax}`);
} else {
this.lastChanged = 2;
valueMax = value;
if (minDistance) {
if (this.state.rxData.shift_min_distance) {
valueMax = Math.max(valueMax, parseFloat(this.state.rxData.min) + minDistance);
_value = parseFloat(this.state.value);
if (valueMax - minDistance < _value) {
_value = valueMax - minDistance;
}
} else {
valueMax = Math.max(value, parseFloat(this.state.value) + minDistance);
}
}
console.log(`Set (${_value || this.state.value}) - ${valueMax}`);
}
} else {
this.lastChanged = 1;
_value = value;
if (minDistance) {
if (this.state.rxData.shift_min_distance) {
_value = Math.min(_value, parseFloat(this.state.rxData.max) - minDistance);
valueMax = this.state.valueMax;
if (valueMax - minDistance < _value) {
valueMax = _value + minDistance;
}
} else {
_value = Math.min(_value, this.state.valueMax - minDistance);
}
}
console.log(`Set ${_value} - (${valueMax || this.state.valueMax})`);
}
this.newState.valueMax = valueMax;
this.newState.value = _value.toString();
if (this.controlTimeout) {
clearTimeout(this.controlTimeout);
}
this.controlTimeout = setTimeout(() => {
this.controlTimeout = null;
const newState = this.newState;
this.newState = null;
if (!newState) {
console.error("This can't be true!");
return;
}
if (newState.value !== void 0) {
const oid = this.getControlOid();
if (oid) {
let val = parseFloat(newState.value);
if (this.state.rxData.inverted) {
val = parseFloat(this.state.rxData.max) - val + parseFloat(this.state.rxData.min);
}
if (this.state.values[`${this.state.rxData.oid}.val`] !== val) {
this.props.context.setValue(oid, val);
}
}
}
if (newState.valueMax !== void 0) {
const oidMax = this.getControlOid(true);
if (oidMax) {
let val = newState.valueMax;
if (this.state.rxData["inverted-2"]) {
val = parseFloat(this.state.rxData.max) - val + parseFloat(this.state.rxData.min);
}
if (this.state.values[`${this.state.rxData["oid-2"]}.val`] !== val) {
this.props.context.setValue(oidMax, val);
}
}
}
}, immediate2 ? 0 : parseInt(this.state.rxData.timeout, 10) || 300);
this.setState(this.newState);
}
renderIcon(isMax) {
let icon;
if (isMax) {
icon = this.state.rxData["icon-2"] || this.state.rxData["image-2"];
} else {
icon = this.state.rxData.icon || this.state.rxData.image;
}
if (icon) {
if (icon && icon.startsWith("_PRJ_NAME/")) {
icon = icon.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
return jsxRuntimeExports.jsx(__mf_15$1, {
src: icon
});
}
return null;
}
renderText(isMax) {
return isMax ? this.state.rxData["text-2"] : this.state.rxData.text;
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
props.style.overflow = "visible";
const step = this.state.rxData.step === void 0 || this.state.rxData.step === null ? 0 : parseFloat(this.state.rxData.step);
let content;
if (this.state.rxData.type === "range") {
content = jsxRuntimeExports.jsx(__mf_92, {
valueLabelFormat: (value) => value + (this.state.rxData.unit || ""),
value: [
parseFloat(this.state.value) || 0,
this.state.valueMax || 0
],
valueLabelDisplay: this.state.rxData.valueLabelDisplay || "auto",
min: parseFloat(this.state.rxData.min === void 0 || this.state.rxData.min === null ? "0" : this.state.rxData.min),
max: parseFloat(this.state.rxData.max === void 0 || this.state.rxData.max === null ? "100" : this.state.rxData.max),
orientation: this.state.rxData.orientation || "horizontal",
disabled: !!this.state.values[`${this.state.rxData["oid-working"]}.val`],
step: step === 0 ? void 0 : step,
disableSwap: this.state.rxData.type === "range" ? true : void 0,
marks: step === 0 ? void 0 : true,
onChangeCommitted: (_e, value) => this.onChange(value, true, true),
onChange: (_e, value, activeThumb) => this.onChange(value[activeThumb], !!activeThumb)
}, "control");
} else {
content = jsxRuntimeExports.jsx(__mf_92, {
valueLabelFormat: (value) => value + (this.state.rxData.unit || ""),
value: parseFloat(this.state.value) || 0,
valueLabelDisplay: this.state.rxData.valueLabelDisplay || "auto",
min: parseFloat(this.state.rxData.min === void 0 || this.state.rxData.min === null ? "0" : this.state.rxData.min),
max: parseFloat(this.state.rxData.max === void 0 || this.state.rxData.max === null ? "100" : this.state.rxData.max),
disabled: !!this.state.values[`${this.state.rxData["oid-working"]}.val`],
orientation: this.state.rxData.orientation || "horizontal",
step: step === 0 ? void 0 : step,
marks: step === 0 ? void 0 : true,
onChangeCommitted: (_e, value) => this.onChange(value, false, true),
onChange: (_e, value) => this.onChange(value)
}, "control2");
}
if (this.state.rxData.text || this.state.rxData["text-2"] || this.state.rxData.icon || this.state.rxData["icon-2"] || this.state.rxData.image || this.state.rxData["image-2"]) {
content = jsxRuntimeExports.jsxs(__mf_98, {
spacing: 1,
style: {
width: "100%",
height: "100%"
},
direction: this.state.rxData.orientation === "vertical" ? "column" : "row",
sx: {
mb: 1
},
alignItems: "center",
children: [
this.renderText(this.state.rxData.orientation === "vertical"),
this.renderIcon(this.state.rxData.orientation === "vertical"),
content,
this.renderIcon(this.state.rxData.orientation !== "vertical"),
this.renderText(this.state.rxData.orientation !== "vertical")
]
}, "stack");
}
if (this.state.rxData.widgetTitle) {
content = jsxRuntimeExports.jsxs(__mf_42, {
fullWidth: true,
style: {
width: "100%",
height: "100%"
},
children: [
jsxRuntimeExports.jsx(__mf_46, {
style: {
marginLeft: 10
},
children: this.state.rxData.widgetTitle
}),
content
]
}, "form");
}
if (this.state.rxData["oid-working"] && this.state.values[`${this.state.rxData["oid-working"]}.val`]) {
content = [
content,
jsxRuntimeExports.jsx(__mf_61, {
style: {
position: "absolute",
bottom: 0,
left: 0,
right: 0
}
}, "progress")
];
}
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
style: {
position: "relative"
},
children: content
});
}
}
class JQuiSliderVertical extends JQuiSlider {
static getWidgetInfo() {
const widgetInfo = JQuiSlider.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiSliderVertical",
visSet: "jqui",
visName: "Vertical slider ",
visWidgetLabel: "jqui_slider_vertical",
visPrev: "widgets/jqui/img/Prev_SliderVertical.png",
visOrder: 25,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 40,
height: 300
}
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_slider_note"
});
const orientation = JQuiSlider.findField(newWidgetInfo, "orientation");
orientation.default = "vertical";
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiSliderVertical.getWidgetInfo();
}
}
var dayjs_min$1 = {
exports: {}
};
var dayjs_min = dayjs_min$1.exports;
(function(module, exports$1) {
!(function(t, e2) {
module.exports = e2();
})(dayjs_min, (function() {
var t = 1e3, e2 = 6e4, n2 = 36e5, r2 = "millisecond", i = "second", s = "minute", u2 = "hour", a = "day", o = "week", c2 = "month", f2 = "quarter", h2 = "year", d2 = "date", l2 = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y2 = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = {
name: "en",
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
ordinal: function(t2) {
var e3 = [
"th",
"st",
"nd",
"rd"
], n3 = t2 % 100;
return "[" + t2 + (e3[(n3 - 20) % 10] || e3[n3] || e3[0]) + "]";
}
}, m2 = function(t2, e3, n3) {
var r3 = String(t2);
return !r3 || r3.length >= e3 ? t2 : "" + Array(e3 + 1 - r3.length).join(n3) + t2;
}, v2 = {
s: m2,
z: function(t2) {
var e3 = -t2.utcOffset(), n3 = Math.abs(e3), r3 = Math.floor(n3 / 60), i2 = n3 % 60;
return (e3 <= 0 ? "+" : "-") + m2(r3, 2, "0") + ":" + m2(i2, 2, "0");
},
m: function t2(e3, n3) {
if (e3.date() < n3.date()) return -t2(n3, e3);
var r3 = 12 * (n3.year() - e3.year()) + (n3.month() - e3.month()), i2 = e3.clone().add(r3, c2), s2 = n3 - i2 < 0, u3 = e3.clone().add(r3 + (s2 ? -1 : 1), c2);
return +(-(r3 + (n3 - i2) / (s2 ? i2 - u3 : u3 - i2)) || 0);
},
a: function(t2) {
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
},
p: function(t2) {
return {
M: c2,
y: h2,
w: o,
d: a,
D: d2,
h: u2,
m: s,
s: i,
ms: r2,
Q: f2
}[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
},
u: function(t2) {
return void 0 === t2;
}
}, g2 = "en", D2 = {};
D2[g2] = M;
var p2 = "$isDayjsObject", S = function(t2) {
return t2 instanceof _ || !(!t2 || !t2[p2]);
}, w2 = function t2(e3, n3, r3) {
var i2;
if (!e3) return g2;
if ("string" == typeof e3) {
var s2 = e3.toLowerCase();
D2[s2] && (i2 = s2), n3 && (D2[s2] = n3, i2 = s2);
var u3 = e3.split("-");
if (!i2 && u3.length > 1) return t2(u3[0]);
} else {
var a2 = e3.name;
D2[a2] = e3, i2 = a2;
}
return !r3 && i2 && (g2 = i2), i2 || !r3 && g2;
}, O = function(t2, e3) {
if (S(t2)) return t2.clone();
var n3 = "object" == typeof e3 ? e3 : {};
return n3.date = t2, n3.args = arguments, new _(n3);
}, b2 = v2;
b2.l = w2, b2.i = S, b2.w = function(t2, e3) {
return O(t2, {
locale: e3.$L,
utc: e3.$u,
x: e3.$x,
$offset: e3.$offset
});
};
var _ = (function() {
function M2(t2) {
this.$L = w2(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p2] = true;
}
var m3 = M2.prototype;
return m3.parse = function(t2) {
this.$d = (function(t3) {
var e3 = t3.date, n3 = t3.utc;
if (null === e3) return /* @__PURE__ */ new Date(NaN);
if (b2.u(e3)) return /* @__PURE__ */ new Date();
if (e3 instanceof Date) return new Date(e3);
if ("string" == typeof e3 && !/Z$/i.test(e3)) {
var r3 = e3.match($);
if (r3) {
var i2 = r3[2] - 1 || 0, s2 = (r3[7] || "0").substring(0, 3);
return n3 ? new Date(Date.UTC(r3[1], i2, r3[3] || 1, r3[4] || 0, r3[5] || 0, r3[6] || 0, s2)) : new Date(r3[1], i2, r3[3] || 1, r3[4] || 0, r3[5] || 0, r3[6] || 0, s2);
}
}
return new Date(e3);
})(t2), this.init();
}, m3.init = function() {
var t2 = this.$d;
this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
}, m3.$utils = function() {
return b2;
}, m3.isValid = function() {
return !(this.$d.toString() === l2);
}, m3.isSame = function(t2, e3) {
var n3 = O(t2);
return this.startOf(e3) <= n3 && n3 <= this.endOf(e3);
}, m3.isAfter = function(t2, e3) {
return O(t2) < this.startOf(e3);
}, m3.isBefore = function(t2, e3) {
return this.endOf(e3) < O(t2);
}, m3.$g = function(t2, e3, n3) {
return b2.u(t2) ? this[e3] : this.set(n3, t2);
}, m3.unix = function() {
return Math.floor(this.valueOf() / 1e3);
}, m3.valueOf = function() {
return this.$d.getTime();
}, m3.startOf = function(t2, e3) {
var n3 = this, r3 = !!b2.u(e3) || e3, f3 = b2.p(t2), l3 = function(t3, e4) {
var i2 = b2.w(n3.$u ? Date.UTC(n3.$y, e4, t3) : new Date(n3.$y, e4, t3), n3);
return r3 ? i2 : i2.endOf(a);
}, $2 = function(t3, e4) {
return b2.w(n3.toDate()[t3].apply(n3.toDate("s"), (r3 ? [
0,
0,
0,
0
] : [
23,
59,
59,
999
]).slice(e4)), n3);
}, y3 = this.$W, M3 = this.$M, m4 = this.$D, v3 = "set" + (this.$u ? "UTC" : "");
switch (f3) {
case h2:
return r3 ? l3(1, 0) : l3(31, 11);
case c2:
return r3 ? l3(1, M3) : l3(0, M3 + 1);
case o:
var g3 = this.$locale().weekStart || 0, D3 = (y3 < g3 ? y3 + 7 : y3) - g3;
return l3(r3 ? m4 - D3 : m4 + (6 - D3), M3);
case a:
case d2:
return $2(v3 + "Hours", 0);
case u2:
return $2(v3 + "Minutes", 1);
case s:
return $2(v3 + "Seconds", 2);
case i:
return $2(v3 + "Milliseconds", 3);
default:
return this.clone();
}
}, m3.endOf = function(t2) {
return this.startOf(t2, false);
}, m3.$set = function(t2, e3) {
var n3, o2 = b2.p(t2), f3 = "set" + (this.$u ? "UTC" : ""), l3 = (n3 = {}, n3[a] = f3 + "Date", n3[d2] = f3 + "Date", n3[c2] = f3 + "Month", n3[h2] = f3 + "FullYear", n3[u2] = f3 + "Hours", n3[s] = f3 + "Minutes", n3[i] = f3 + "Seconds", n3[r2] = f3 + "Milliseconds", n3)[o2], $2 = o2 === a ? this.$D + (e3 - this.$W) : e3;
if (o2 === c2 || o2 === h2) {
var y3 = this.clone().set(d2, 1);
y3.$d[l3]($2), y3.init(), this.$d = y3.set(d2, Math.min(this.$D, y3.daysInMonth())).$d;
} else l3 && this.$d[l3]($2);
return this.init(), this;
}, m3.set = function(t2, e3) {
return this.clone().$set(t2, e3);
}, m3.get = function(t2) {
return this[b2.p(t2)]();
}, m3.add = function(r3, f3) {
var d3, l3 = this;
r3 = Number(r3);
var $2 = b2.p(f3), y3 = function(t2) {
var e3 = O(l3);
return b2.w(e3.date(e3.date() + Math.round(t2 * r3)), l3);
};
if ($2 === c2) return this.set(c2, this.$M + r3);
if ($2 === h2) return this.set(h2, this.$y + r3);
if ($2 === a) return y3(1);
if ($2 === o) return y3(7);
var M3 = (d3 = {}, d3[s] = e2, d3[u2] = n2, d3[i] = t, d3)[$2] || 1, m4 = this.$d.getTime() + r3 * M3;
return b2.w(m4, this);
}, m3.subtract = function(t2, e3) {
return this.add(-1 * t2, e3);
}, m3.format = function(t2) {
var e3 = this, n3 = this.$locale();
if (!this.isValid()) return n3.invalidDate || l2;
var r3 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b2.z(this), s2 = this.$H, u3 = this.$m, a2 = this.$M, o2 = n3.weekdays, c3 = n3.months, f3 = n3.meridiem, h3 = function(t3, n4, i3, s3) {
return t3 && (t3[n4] || t3(e3, r3)) || i3[n4].slice(0, s3);
}, d3 = function(t3) {
return b2.s(s2 % 12 || 12, t3, "0");
}, $2 = f3 || function(t3, e4, n4) {
var r4 = t3 < 12 ? "AM" : "PM";
return n4 ? r4.toLowerCase() : r4;
};
return r3.replace(y2, (function(t3, r4) {
return r4 || (function(t4) {
switch (t4) {
case "YY":
return String(e3.$y).slice(-2);
case "YYYY":
return b2.s(e3.$y, 4, "0");
case "M":
return a2 + 1;
case "MM":
return b2.s(a2 + 1, 2, "0");
case "MMM":
return h3(n3.monthsShort, a2, c3, 3);
case "MMMM":
return h3(c3, a2);
case "D":
return e3.$D;
case "DD":
return b2.s(e3.$D, 2, "0");
case "d":
return String(e3.$W);
case "dd":
return h3(n3.weekdaysMin, e3.$W, o2, 2);
case "ddd":
return h3(n3.weekdaysShort, e3.$W, o2, 3);
case "dddd":
return o2[e3.$W];
case "H":
return String(s2);
case "HH":
return b2.s(s2, 2, "0");
case "h":
return d3(1);
case "hh":
return d3(2);
case "a":
return $2(s2, u3, true);
case "A":
return $2(s2, u3, false);
case "m":
return String(u3);
case "mm":
return b2.s(u3, 2, "0");
case "s":
return String(e3.$s);
case "ss":
return b2.s(e3.$s, 2, "0");
case "SSS":
return b2.s(e3.$ms, 3, "0");
case "Z":
return i2;
}
return null;
})(t3) || i2.replace(":", "");
}));
}, m3.utcOffset = function() {
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
}, m3.diff = function(r3, d3, l3) {
var $2, y3 = this, M3 = b2.p(d3), m4 = O(r3), v3 = (m4.utcOffset() - this.utcOffset()) * e2, g3 = this - m4, D3 = function() {
return b2.m(y3, m4);
};
switch (M3) {
case h2:
$2 = D3() / 12;
break;
case c2:
$2 = D3();
break;
case f2:
$2 = D3() / 3;
break;
case o:
$2 = (g3 - v3) / 6048e5;
break;
case a:
$2 = (g3 - v3) / 864e5;
break;
case u2:
$2 = g3 / n2;
break;
case s:
$2 = g3 / e2;
break;
case i:
$2 = g3 / t;
break;
default:
$2 = g3;
}
return l3 ? $2 : b2.a($2);
}, m3.daysInMonth = function() {
return this.endOf(c2).$D;
}, m3.$locale = function() {
return D2[this.$L];
}, m3.locale = function(t2, e3) {
if (!t2) return this.$L;
var n3 = this.clone(), r3 = w2(t2, e3, true);
return r3 && (n3.$L = r3), n3;
}, m3.clone = function() {
return b2.w(this.$d, this);
}, m3.toDate = function() {
return new Date(this.valueOf());
}, m3.toJSON = function() {
return this.isValid() ? this.toISOString() : null;
}, m3.toISOString = function() {
return this.$d.toISOString();
}, m3.toString = function() {
return this.$d.toUTCString();
}, M2;
})(), k2 = _.prototype;
return O.prototype = k2, [
[
"$ms",
r2
],
[
"$s",
i
],
[
"$m",
s
],
[
"$H",
u2
],
[
"$W",
a
],
[
"$M",
c2
],
[
"$y",
h2
],
[
"$D",
d2
]
].forEach((function(t2) {
k2[t2[1]] = function(e3) {
return this.$g(e3, t2[0], t2[1]);
};
})), O.extend = function(t2, e3) {
return t2.$i || (t2(e3, _, O), t2.$i = true), O;
}, O.locale = w2, O.isDayjs = S, O.unix = function(t2) {
return O(1e3 * t2);
}, O.en = D2[g2], O.Ls = D2, O.p = {}, O;
}));
})(dayjs_min$1);
var dayjs_minExports = dayjs_min$1.exports;
const dayjs = getDefaultExportFromCjs(dayjs_minExports);
const _excluded$F = [
"localeText"
];
const MuiPickersAdapterContext = __mf_10(null);
const LocalizationProvider = function LocalizationProvider2(inProps) {
const { localeText: inLocaleText } = inProps, otherInProps = _objectWithoutPropertiesLoose$3(inProps, _excluded$F);
const { utils: parentUtils, localeText: parentLocaleText } = __mf_21(MuiPickersAdapterContext) ?? {
utils: void 0,
localeText: void 0
};
const props = useThemeProps({
props: otherInProps,
name: "MuiLocalizationProvider"
});
const { children, dateAdapter: DateAdapter, dateFormats, dateLibInstance, adapterLocale, localeText: themeLocaleText } = props;
const localeText = __mf_29(() => _extends$1({}, themeLocaleText, parentLocaleText, inLocaleText), [
themeLocaleText,
parentLocaleText,
inLocaleText
]);
const utils = __mf_29(() => {
if (!DateAdapter) {
if (parentUtils) {
return parentUtils;
}
return null;
}
const adapter = new DateAdapter({
locale: adapterLocale,
formats: dateFormats,
instance: dateLibInstance
});
if (!adapter.isMUIAdapter) {
throw new Error([
"MUI X: The date adapter should be imported from `@mui/x-date-pickers` or `@mui/x-date-pickers-pro`, not from `@date-io`",
"For example, `import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'` instead of `import AdapterDayjs from '@date-io/dayjs'`",
"More information on the installation documentation: https://mui.com/x/react-date-pickers/getting-started/#installation"
].join(`
`));
}
return adapter;
}, [
DateAdapter,
adapterLocale,
dateFormats,
dateLibInstance,
parentUtils
]);
const defaultDates = __mf_29(() => {
if (!utils) {
return null;
}
return {
minDate: utils.date("1900-01-01T00:00:00.000"),
maxDate: utils.date("2099-12-31T00:00:00.000")
};
}, [
utils
]);
const contextValue = __mf_29(() => {
return {
utils,
defaultDates,
localeText
};
}, [
defaultDates,
utils,
localeText
]);
return jsxRuntimeExports.jsx(MuiPickersAdapterContext.Provider, {
value: contextValue,
children
});
};
const getPickersLocalization = (pickersTranslations) => {
return {
components: {
MuiLocalizationProvider: {
defaultProps: {
localeText: _extends$1({}, pickersTranslations)
}
}
}
};
};
const buildGetOpenDialogAriaText = (params) => {
const { utils, formatKey, contextTranslation, propsTranslation } = params;
return (value) => {
const formattedValue = value !== null && utils.isValid(value) ? utils.format(value, formatKey) : null;
const translation = propsTranslation ?? contextTranslation;
return translation(value, utils, formattedValue);
};
};
const enUSPickers = {
previousMonth: "Previous month",
nextMonth: "Next month",
openPreviousView: "Open previous view",
openNextView: "Open next view",
calendarViewSwitchingButtonAriaLabel: (view) => view === "year" ? "year view is open, switch to calendar view" : "calendar view is open, switch to year view",
start: "Start",
end: "End",
startDate: "Start date",
startTime: "Start time",
endDate: "End date",
endTime: "End time",
cancelButtonLabel: "Cancel",
clearButtonLabel: "Clear",
okButtonLabel: "OK",
todayButtonLabel: "Today",
datePickerToolbarTitle: "Select date",
dateTimePickerToolbarTitle: "Select date & time",
timePickerToolbarTitle: "Select time",
dateRangePickerToolbarTitle: "Select date range",
clockLabelText: (view, time, utils, formattedTime) => `Select ${view}. ${!formattedTime && (time === null || !utils.isValid(time)) ? "No time selected" : `Selected time is ${formattedTime ?? utils.format(time, "fullTime")}`}`,
hoursClockNumberText: (hours) => `${hours} hours`,
minutesClockNumberText: (minutes) => `${minutes} minutes`,
secondsClockNumberText: (seconds) => `${seconds} seconds`,
selectViewText: (view) => `Select ${view}`,
calendarWeekNumberHeaderLabel: "Week number",
calendarWeekNumberHeaderText: "#",
calendarWeekNumberAriaLabelText: (weekNumber) => `Week ${weekNumber}`,
calendarWeekNumberText: (weekNumber) => `${weekNumber}`,
openDatePickerDialogue: (value, utils, formattedDate) => formattedDate || value !== null && utils.isValid(value) ? `Choose date, selected date is ${formattedDate ?? utils.format(value, "fullDate")}` : "Choose date",
openTimePickerDialogue: (value, utils, formattedTime) => formattedTime || value !== null && utils.isValid(value) ? `Choose time, selected time is ${formattedTime ?? utils.format(value, "fullTime")}` : "Choose time",
fieldClearLabel: "Clear",
timeTableLabel: "pick time",
dateTableLabel: "pick date",
fieldYearPlaceholder: (params) => "Y".repeat(params.digitAmount),
fieldMonthPlaceholder: (params) => params.contentType === "letter" ? "MMMM" : "MM",
fieldDayPlaceholder: () => "DD",
fieldWeekDayPlaceholder: (params) => params.contentType === "letter" ? "EEEE" : "EE",
fieldHoursPlaceholder: () => "hh",
fieldMinutesPlaceholder: () => "mm",
fieldSecondsPlaceholder: () => "ss",
fieldMeridiemPlaceholder: () => "aa",
year: "Year",
month: "Month",
day: "Day",
weekDay: "Week day",
hours: "Hours",
minutes: "Minutes",
seconds: "Seconds",
meridiem: "Meridiem",
empty: "Empty"
};
const DEFAULT_LOCALE = enUSPickers;
getPickersLocalization(enUSPickers);
const useLocalizationContext = () => {
const localization = __mf_21(MuiPickersAdapterContext);
if (localization === null) {
throw new Error([
"MUI X: Can not find the date and time pickers localization context.",
"It looks like you forgot to wrap your component in LocalizationProvider.",
"This can also happen if you are bundling multiple versions of the `@mui/x-date-pickers` package"
].join("\n"));
}
if (localization.utils === null) {
throw new Error([
"MUI X: Can not find the date and time pickers adapter from its localization context.",
"It looks like you forgot to pass a `dateAdapter` to your LocalizationProvider."
].join("\n"));
}
const localeText = __mf_29(() => _extends$1({}, DEFAULT_LOCALE, localization.localeText), [
localization.localeText
]);
return __mf_29(() => _extends$1({}, localization, {
localeText
}), [
localization,
localeText
]);
};
const useUtils = () => useLocalizationContext().utils;
const useDefaultDates = () => useLocalizationContext().defaultDates;
const useNow = (timezone) => {
const utils = useUtils();
const now = __mf_31(void 0);
if (now.current === void 0) {
now.current = utils.date(void 0, timezone);
}
return now.current;
};
const usePickersTranslations = () => useLocalizationContext().localeText;
function hasClass(element, className) {
if (element.classList) return !!className && element.classList.contains(className);
return (" " + (element.className.baseVal || element.className) + " ").indexOf(" " + className + " ") !== -1;
}
function addClass(element, className) {
if (element.classList) element.classList.add(className);
else if (!hasClass(element, className)) if (typeof element.className === "string") element.className = element.className + " " + className;
else element.setAttribute("class", (element.className && element.className.baseVal || "") + " " + className);
}
function replaceClassName(origClass, classToRemove) {
return origClass.replace(new RegExp("(^|\\s)" + classToRemove + "(?:\\s|$)", "g"), "$1").replace(/\s+/g, " ").replace(/^\s*|\s*$/g, "");
}
function removeClass$1(element, className) {
if (element.classList) {
element.classList.remove(className);
} else if (typeof element.className === "string") {
element.className = replaceClassName(element.className, className);
} else {
element.setAttribute("class", replaceClassName(element.className && element.className.baseVal || "", className));
}
}
var _addClass = function addClass$12(node, classes) {
return node && classes && classes.split(" ").forEach(function(c2) {
return addClass(node, c2);
});
};
var removeClass = function removeClass2(node, classes) {
return node && classes && classes.split(" ").forEach(function(c2) {
return removeClass$1(node, c2);
});
};
var CSSTransition = (function(_React$Component) {
_inheritsLoose(CSSTransition2, _React$Component);
function CSSTransition2() {
var _this;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _React$Component.call.apply(_React$Component, [
this
].concat(args)) || this;
_this.appliedClasses = {
appear: {},
enter: {},
exit: {}
};
_this.onEnter = function(maybeNode, maybeAppearing) {
var _this$resolveArgument = _this.resolveArguments(maybeNode, maybeAppearing), node = _this$resolveArgument[0], appearing = _this$resolveArgument[1];
_this.removeClasses(node, "exit");
_this.addClass(node, appearing ? "appear" : "enter", "base");
if (_this.props.onEnter) {
_this.props.onEnter(maybeNode, maybeAppearing);
}
};
_this.onEntering = function(maybeNode, maybeAppearing) {
var _this$resolveArgument2 = _this.resolveArguments(maybeNode, maybeAppearing), node = _this$resolveArgument2[0], appearing = _this$resolveArgument2[1];
var type = appearing ? "appear" : "enter";
_this.addClass(node, type, "active");
if (_this.props.onEntering) {
_this.props.onEntering(maybeNode, maybeAppearing);
}
};
_this.onEntered = function(maybeNode, maybeAppearing) {
var _this$resolveArgument3 = _this.resolveArguments(maybeNode, maybeAppearing), node = _this$resolveArgument3[0], appearing = _this$resolveArgument3[1];
var type = appearing ? "appear" : "enter";
_this.removeClasses(node, type);
_this.addClass(node, type, "done");
if (_this.props.onEntered) {
_this.props.onEntered(maybeNode, maybeAppearing);
}
};
_this.onExit = function(maybeNode) {
var _this$resolveArgument4 = _this.resolveArguments(maybeNode), node = _this$resolveArgument4[0];
_this.removeClasses(node, "appear");
_this.removeClasses(node, "enter");
_this.addClass(node, "exit", "base");
if (_this.props.onExit) {
_this.props.onExit(maybeNode);
}
};
_this.onExiting = function(maybeNode) {
var _this$resolveArgument5 = _this.resolveArguments(maybeNode), node = _this$resolveArgument5[0];
_this.addClass(node, "exit", "active");
if (_this.props.onExiting) {
_this.props.onExiting(maybeNode);
}
};
_this.onExited = function(maybeNode) {
var _this$resolveArgument6 = _this.resolveArguments(maybeNode), node = _this$resolveArgument6[0];
_this.removeClasses(node, "exit");
_this.addClass(node, "exit", "done");
if (_this.props.onExited) {
_this.props.onExited(maybeNode);
}
};
_this.resolveArguments = function(maybeNode, maybeAppearing) {
return _this.props.nodeRef ? [
_this.props.nodeRef.current,
maybeNode
] : [
maybeNode,
maybeAppearing
];
};
_this.getClassNames = function(type) {
var classNames = _this.props.classNames;
var isStringClassNames = typeof classNames === "string";
var prefix2 = isStringClassNames && classNames ? classNames + "-" : "";
var baseClassName = isStringClassNames ? "" + prefix2 + type : classNames[type];
var activeClassName = isStringClassNames ? baseClassName + "-active" : classNames[type + "Active"];
var doneClassName = isStringClassNames ? baseClassName + "-done" : classNames[type + "Done"];
return {
baseClassName,
activeClassName,
doneClassName
};
};
return _this;
}
var _proto = CSSTransition2.prototype;
_proto.addClass = function addClass2(node, type, phase) {
var className = this.getClassNames(type)[phase + "ClassName"];
var _this$getClassNames = this.getClassNames("enter"), doneClassName = _this$getClassNames.doneClassName;
if (type === "appear" && phase === "done" && doneClassName) {
className += " " + doneClassName;
}
if (phase === "active") {
if (node) forceReflow(node);
}
if (className) {
this.appliedClasses[type][phase] = className;
_addClass(node, className);
}
};
_proto.removeClasses = function removeClasses(node, type) {
var _this$appliedClasses$ = this.appliedClasses[type], baseClassName = _this$appliedClasses$.base, activeClassName = _this$appliedClasses$.active, doneClassName = _this$appliedClasses$.done;
this.appliedClasses[type] = {};
if (baseClassName) {
removeClass(node, baseClassName);
}
if (activeClassName) {
removeClass(node, activeClassName);
}
if (doneClassName) {
removeClass(node, doneClassName);
}
};
_proto.render = function render() {
var _this$props = this.props;
_this$props.classNames;
var props = _objectWithoutPropertiesLoose$3(_this$props, [
"classNames"
]);
return React.createElement(Transition, _extends$1({}, props, {
onEnter: this.onEnter,
onEntered: this.onEntered,
onEntering: this.onEntering,
onExit: this.onExit,
onExiting: this.onExiting,
onExited: this.onExited
}));
};
return CSSTransition2;
})(React.Component);
CSSTransition.defaultProps = {
classNames: ""
};
CSSTransition.propTypes = {};
const ArrowDropDownIcon = createSvgIcon(jsxRuntimeExports.jsx("path", {
d: "M7 10l5 5 5-5z"
}), "ArrowDropDown");
const ArrowLeftIcon = createSvgIcon(jsxRuntimeExports.jsx("path", {
d: "M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"
}), "ArrowLeft");
const ArrowRightIcon = createSvgIcon(jsxRuntimeExports.jsx("path", {
d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"
}), "ArrowRight");
const CalendarIcon = createSvgIcon(jsxRuntimeExports.jsx("path", {
d: "M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z"
}), "Calendar");
const ClockIcon = createSvgIcon(jsxRuntimeExports.jsxs(__mf_2, {
children: [
jsxRuntimeExports.jsx("path", {
d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
}),
jsxRuntimeExports.jsx("path", {
d: "M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"
})
]
}), "Clock");
createSvgIcon(jsxRuntimeExports.jsx("path", {
d: "M9 11H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V9h14v11z"
}), "DateRange");
createSvgIcon(jsxRuntimeExports.jsxs(__mf_2, {
children: [
jsxRuntimeExports.jsx("path", {
d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
}),
jsxRuntimeExports.jsx("path", {
d: "M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"
})
]
}), "Time");
const ClearIcon = createSvgIcon(jsxRuntimeExports.jsx("path", {
d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
}), "Clear");
function getPickersArrowSwitcherUtilityClass(slot) {
return generateUtilityClass("MuiPickersArrowSwitcher", slot);
}
generateUtilityClasses("MuiPickersArrowSwitcher", [
"root",
"spacer",
"button",
"previousIconButton",
"nextIconButton",
"leftArrowIcon",
"rightArrowIcon"
]);
const _excluded$E = [
"children",
"className",
"slots",
"slotProps",
"isNextDisabled",
"isNextHidden",
"onGoToNext",
"nextLabel",
"isPreviousDisabled",
"isPreviousHidden",
"onGoToPrevious",
"previousLabel",
"labelId"
], _excluded2$6 = [
"ownerState"
], _excluded3$2 = [
"ownerState"
];
const PickersArrowSwitcherRoot = styled("div", {
name: "MuiPickersArrowSwitcher",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
display: "flex"
});
const PickersArrowSwitcherSpacer = styled("div", {
name: "MuiPickersArrowSwitcher",
slot: "Spacer",
overridesResolver: (props, styles2) => styles2.spacer
})(({ theme }) => ({
width: theme.spacing(3)
}));
const PickersArrowSwitcherButton = styled(IconButton, {
name: "MuiPickersArrowSwitcher",
slot: "Button",
overridesResolver: (props, styles2) => styles2.button
})({
variants: [
{
props: {
hidden: true
},
style: {
visibility: "hidden"
}
}
]
});
const useUtilityClasses$v = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
spacer: [
"spacer"
],
button: [
"button"
],
previousIconButton: [
"previousIconButton"
],
nextIconButton: [
"nextIconButton"
],
leftArrowIcon: [
"leftArrowIcon"
],
rightArrowIcon: [
"rightArrowIcon"
]
};
return composeClasses(slots, getPickersArrowSwitcherUtilityClass, classes);
};
const PickersArrowSwitcher = __mf_14(function PickersArrowSwitcher2(inProps, ref) {
const isRtl = useRtl();
const props = useThemeProps({
props: inProps,
name: "MuiPickersArrowSwitcher"
});
const { children, className, slots, slotProps, isNextDisabled, isNextHidden, onGoToNext, nextLabel, isPreviousDisabled, isPreviousHidden, onGoToPrevious, previousLabel, labelId } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$E);
const ownerState = props;
const classes = useUtilityClasses$v(ownerState);
const nextProps = {
isDisabled: isNextDisabled,
isHidden: isNextHidden,
goTo: onGoToNext,
label: nextLabel
};
const previousProps = {
isDisabled: isPreviousDisabled,
isHidden: isPreviousHidden,
goTo: onGoToPrevious,
label: previousLabel
};
const PreviousIconButton = (slots == null ? void 0 : slots.previousIconButton) ?? PickersArrowSwitcherButton;
const previousIconButtonProps = useSlotProps({
elementType: PreviousIconButton,
externalSlotProps: slotProps == null ? void 0 : slotProps.previousIconButton,
additionalProps: {
size: "medium",
title: previousProps.label,
"aria-label": previousProps.label,
disabled: previousProps.isDisabled,
edge: "end",
onClick: previousProps.goTo
},
ownerState: _extends$1({}, ownerState, {
hidden: previousProps.isHidden
}),
className: clsx(classes.button, classes.previousIconButton)
});
const NextIconButton = (slots == null ? void 0 : slots.nextIconButton) ?? PickersArrowSwitcherButton;
const nextIconButtonProps = useSlotProps({
elementType: NextIconButton,
externalSlotProps: slotProps == null ? void 0 : slotProps.nextIconButton,
additionalProps: {
size: "medium",
title: nextProps.label,
"aria-label": nextProps.label,
disabled: nextProps.isDisabled,
edge: "start",
onClick: nextProps.goTo
},
ownerState: _extends$1({}, ownerState, {
hidden: nextProps.isHidden
}),
className: clsx(classes.button, classes.nextIconButton)
});
const LeftArrowIcon = (slots == null ? void 0 : slots.leftArrowIcon) ?? ArrowLeftIcon;
const _useSlotProps = useSlotProps({
elementType: LeftArrowIcon,
externalSlotProps: slotProps == null ? void 0 : slotProps.leftArrowIcon,
additionalProps: {
fontSize: "inherit"
},
ownerState,
className: classes.leftArrowIcon
}), leftArrowIconProps = _objectWithoutPropertiesLoose$3(_useSlotProps, _excluded2$6);
const RightArrowIcon = (slots == null ? void 0 : slots.rightArrowIcon) ?? ArrowRightIcon;
const _useSlotProps2 = useSlotProps({
elementType: RightArrowIcon,
externalSlotProps: slotProps == null ? void 0 : slotProps.rightArrowIcon,
additionalProps: {
fontSize: "inherit"
},
ownerState,
className: classes.rightArrowIcon
}), rightArrowIconProps = _objectWithoutPropertiesLoose$3(_useSlotProps2, _excluded3$2);
return jsxRuntimeExports.jsxs(PickersArrowSwitcherRoot, _extends$1({
ref,
className: clsx(classes.root, className),
ownerState
}, other, {
children: [
jsxRuntimeExports.jsx(PreviousIconButton, _extends$1({}, previousIconButtonProps, {
children: isRtl ? jsxRuntimeExports.jsx(RightArrowIcon, _extends$1({}, rightArrowIconProps)) : jsxRuntimeExports.jsx(LeftArrowIcon, _extends$1({}, leftArrowIconProps))
})),
children ? jsxRuntimeExports.jsx(Typography, {
variant: "subtitle1",
component: "span",
id: labelId,
children
}) : jsxRuntimeExports.jsx(PickersArrowSwitcherSpacer, {
className: classes.spacer,
ownerState
}),
jsxRuntimeExports.jsx(NextIconButton, _extends$1({}, nextIconButtonProps, {
children: isRtl ? jsxRuntimeExports.jsx(LeftArrowIcon, _extends$1({}, leftArrowIconProps)) : jsxRuntimeExports.jsx(RightArrowIcon, _extends$1({}, rightArrowIconProps))
}))
]
}));
});
const areViewsEqual = (views, expectedViews) => {
if (views.length !== expectedViews.length) {
return false;
}
return expectedViews.every((expectedView) => views.includes(expectedView));
};
const applyDefaultViewProps = ({ openTo, defaultOpenTo, views, defaultViews }) => {
const viewsWithDefault = views ?? defaultViews;
let openToWithDefault;
if (openTo != null) {
openToWithDefault = openTo;
} else if (viewsWithDefault.includes(defaultOpenTo)) {
openToWithDefault = defaultOpenTo;
} else if (viewsWithDefault.length > 0) {
openToWithDefault = viewsWithDefault[0];
} else {
throw new Error("MUI X: The `views` prop must contain at least one view.");
}
return {
views: viewsWithDefault,
openTo: openToWithDefault
};
};
const timeViews = [
"hours",
"minutes",
"seconds"
];
const isTimeView = (view) => timeViews.includes(view);
const isInternalTimeView = (view) => timeViews.includes(view) || view === "meridiem";
const getMeridiem = (date, utils) => {
if (!date) {
return null;
}
return utils.getHours(date) >= 12 ? "pm" : "am";
};
const convertValueToMeridiem = (value, meridiem, ampm) => {
if (ampm) {
const currentMeridiem = value >= 12 ? "pm" : "am";
if (currentMeridiem !== meridiem) {
return meridiem === "am" ? value - 12 : value + 12;
}
}
return value;
};
const convertToMeridiem = (time, meridiem, ampm, utils) => {
const newHoursAmount = convertValueToMeridiem(utils.getHours(time), meridiem, ampm);
return utils.setHours(time, newHoursAmount);
};
const getSecondsInDay = (date, utils) => {
return utils.getHours(date) * 3600 + utils.getMinutes(date) * 60 + utils.getSeconds(date);
};
const createIsAfterIgnoreDatePart = (disableIgnoringDatePartForTimeValidation, utils) => (dateLeft, dateRight) => {
if (disableIgnoringDatePartForTimeValidation) {
return utils.isAfter(dateLeft, dateRight);
}
return getSecondsInDay(dateLeft, utils) > getSecondsInDay(dateRight, utils);
};
const resolveTimeFormat = (utils, { format, views, ampm }) => {
if (format != null) {
return format;
}
const formats = utils.formats;
if (areViewsEqual(views, [
"hours"
])) {
return ampm ? `${formats.hours12h} ${formats.meridiem}` : formats.hours24h;
}
if (areViewsEqual(views, [
"minutes"
])) {
return formats.minutes;
}
if (areViewsEqual(views, [
"seconds"
])) {
return formats.seconds;
}
if (areViewsEqual(views, [
"minutes",
"seconds"
])) {
return `${formats.minutes}:${formats.seconds}`;
}
if (areViewsEqual(views, [
"hours",
"minutes",
"seconds"
])) {
return ampm ? `${formats.hours12h}:${formats.minutes}:${formats.seconds} ${formats.meridiem}` : `${formats.hours24h}:${formats.minutes}:${formats.seconds}`;
}
return ampm ? `${formats.hours12h}:${formats.minutes} ${formats.meridiem}` : `${formats.hours24h}:${formats.minutes}`;
};
function useViews({ onChange, onViewChange, openTo, view: inView, views, autoFocus, focusedView: inFocusedView, onFocusedViewChange }) {
const previousOpenTo = __mf_31(openTo);
const previousViews = __mf_31(views);
const defaultView = __mf_31(views.includes(openTo) ? openTo : views[0]);
const [view, setView] = useControlled({
name: "useViews",
state: "view",
controlled: inView,
default: defaultView.current
});
const defaultFocusedView = __mf_31(autoFocus ? view : null);
const [focusedView, setFocusedView] = useControlled({
name: "useViews",
state: "focusedView",
controlled: inFocusedView,
default: defaultFocusedView.current
});
__mf_24(() => {
if (previousOpenTo.current && previousOpenTo.current !== openTo || previousViews.current && previousViews.current.some((previousView2) => !views.includes(previousView2))) {
setView(views.includes(openTo) ? openTo : views[0]);
previousViews.current = views;
previousOpenTo.current = openTo;
}
}, [
openTo,
setView,
view,
views
]);
const viewIndex = views.indexOf(view);
const previousView = views[viewIndex - 1] ?? null;
const nextView = views[viewIndex + 1] ?? null;
const handleFocusedViewChange = useEventCallback((viewToFocus, hasFocus) => {
if (hasFocus) {
setFocusedView(viewToFocus);
} else {
setFocusedView((prevFocusedView) => viewToFocus === prevFocusedView ? null : prevFocusedView);
}
onFocusedViewChange == null ? void 0 : onFocusedViewChange(viewToFocus, hasFocus);
});
const handleChangeView = useEventCallback((newView) => {
handleFocusedViewChange(newView, true);
if (newView === view) {
return;
}
setView(newView);
if (onViewChange) {
onViewChange(newView);
}
});
const goToNextView = useEventCallback(() => {
if (nextView) {
handleChangeView(nextView);
}
});
const setValueAndGoToNextView = useEventCallback((value, currentViewSelectionState, selectedView) => {
const isSelectionFinishedOnCurrentView = currentViewSelectionState === "finish";
const hasMoreViews = selectedView ? views.indexOf(selectedView) < views.length - 1 : Boolean(nextView);
const globalSelectionState = isSelectionFinishedOnCurrentView && hasMoreViews ? "partial" : currentViewSelectionState;
onChange(value, globalSelectionState, selectedView);
if (selectedView && selectedView !== view) {
const nextViewAfterSelected = views[views.indexOf(selectedView) + 1];
if (nextViewAfterSelected) {
handleChangeView(nextViewAfterSelected);
}
} else if (isSelectionFinishedOnCurrentView) {
goToNextView();
}
});
return {
view,
setView: handleChangeView,
focusedView,
setFocusedView: handleFocusedViewChange,
nextView,
previousView,
defaultView: views.includes(openTo) ? openTo : views[0],
goToNextView,
setValueAndGoToNextView
};
}
function useNextMonthDisabled(month, { disableFuture, maxDate, timezone }) {
const utils = useUtils();
return __mf_29(() => {
const now = utils.date(void 0, timezone);
const lastEnabledMonth = utils.startOfMonth(disableFuture && utils.isBefore(now, maxDate) ? now : maxDate);
return !utils.isAfter(lastEnabledMonth, month);
}, [
disableFuture,
maxDate,
month,
utils,
timezone
]);
}
function usePreviousMonthDisabled(month, { disablePast, minDate, timezone }) {
const utils = useUtils();
return __mf_29(() => {
const now = utils.date(void 0, timezone);
const firstEnabledMonth = utils.startOfMonth(disablePast && utils.isAfter(now, minDate) ? now : minDate);
return !utils.isBefore(firstEnabledMonth, month);
}, [
disablePast,
minDate,
month,
utils,
timezone
]);
}
function useMeridiemMode(date, ampm, onChange, selectionState) {
const utils = useUtils();
const meridiemMode = getMeridiem(date, utils);
const handleMeridiemChange = __mf_20((mode) => {
const timeWithMeridiem = date == null ? null : convertToMeridiem(date, mode, Boolean(ampm), utils);
onChange(timeWithMeridiem, selectionState ?? "partial");
}, [
ampm,
date,
onChange,
selectionState,
utils
]);
return {
meridiemMode,
handleMeridiemChange
};
}
const DAY_SIZE = 36;
const DAY_MARGIN = 2;
const DIALOG_WIDTH = 320;
const MAX_CALENDAR_HEIGHT = 280;
const VIEW_HEIGHT = 336;
const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
const MULTI_SECTION_CLOCK_SECTION_WIDTH = 48;
const PickerViewRoot = styled("div")({
overflow: "hidden",
width: DIALOG_WIDTH,
maxHeight: VIEW_HEIGHT,
display: "flex",
flexDirection: "column",
margin: "0 auto"
});
function getTimeClockUtilityClass(slot) {
return generateUtilityClass("MuiTimeClock", slot);
}
generateUtilityClasses("MuiTimeClock", [
"root",
"arrowSwitcher"
]);
const CLOCK_WIDTH = 220;
const CLOCK_HOUR_WIDTH = 36;
const clockCenter = {
x: CLOCK_WIDTH / 2,
y: CLOCK_WIDTH / 2
};
const baseClockPoint = {
x: clockCenter.x,
y: 0
};
const cx = baseClockPoint.x - clockCenter.x;
const cy = baseClockPoint.y - clockCenter.y;
const rad2deg = (rad) => rad * (180 / Math.PI);
const getAngleValue = (step, offsetX, offsetY) => {
const x2 = offsetX - clockCenter.x;
const y2 = offsetY - clockCenter.y;
const atan = Math.atan2(cx, cy) - Math.atan2(x2, y2);
let deg = rad2deg(atan);
deg = Math.round(deg / step) * step;
deg %= 360;
const value = Math.floor(deg / step) || 0;
const delta = x2 ** 2 + y2 ** 2;
const distance2 = Math.sqrt(delta);
return {
value,
distance: distance2
};
};
const getMinutes = (offsetX, offsetY, step = 1) => {
const angleStep = step * 6;
let { value } = getAngleValue(angleStep, offsetX, offsetY);
value = value * step % 60;
return value;
};
const getHours = (offsetX, offsetY, ampm) => {
const { value, distance: distance2 } = getAngleValue(30, offsetX, offsetY);
let hour = value || 12;
if (!ampm) {
if (distance2 < CLOCK_WIDTH / 2 - CLOCK_HOUR_WIDTH) {
hour += 12;
hour %= 24;
}
} else {
hour %= 12;
}
return hour;
};
function getClockPointerUtilityClass(slot) {
return generateUtilityClass("MuiClockPointer", slot);
}
generateUtilityClasses("MuiClockPointer", [
"root",
"thumb"
]);
const _excluded$D = [
"className",
"hasSelected",
"isInner",
"type",
"viewValue"
];
const useUtilityClasses$u = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
thumb: [
"thumb"
]
};
return composeClasses(slots, getClockPointerUtilityClass, classes);
};
const ClockPointerRoot = styled("div", {
name: "MuiClockPointer",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})(({ theme }) => ({
width: 2,
backgroundColor: (theme.vars || theme).palette.primary.main,
position: "absolute",
left: "calc(50% - 1px)",
bottom: "50%",
transformOrigin: "center bottom 0px",
variants: [
{
props: {
shouldAnimate: true
},
style: {
transition: theme.transitions.create([
"transform",
"height"
])
}
}
]
}));
const ClockPointerThumb = styled("div", {
name: "MuiClockPointer",
slot: "Thumb",
overridesResolver: (_, styles2) => styles2.thumb
})(({ theme }) => ({
width: 4,
height: 4,
backgroundColor: (theme.vars || theme).palette.primary.contrastText,
borderRadius: "50%",
position: "absolute",
top: -21,
left: `calc(50% - ${CLOCK_HOUR_WIDTH / 2}px)`,
border: `${(CLOCK_HOUR_WIDTH - 4) / 2}px solid ${(theme.vars || theme).palette.primary.main}`,
boxSizing: "content-box",
variants: [
{
props: {
hasSelected: true
},
style: {
backgroundColor: (theme.vars || theme).palette.primary.main
}
}
]
}));
function ClockPointer(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiClockPointer"
});
const { className, isInner, type, viewValue } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$D);
const previousType = __mf_31(type);
__mf_24(() => {
previousType.current = type;
}, [
type
]);
const ownerState = _extends$1({}, props, {
shouldAnimate: previousType.current !== type
});
const classes = useUtilityClasses$u(ownerState);
const getAngleStyle = () => {
const max = type === "hours" ? 12 : 60;
let angle = 360 / max * viewValue;
if (type === "hours" && viewValue > 12) {
angle -= 360;
}
return {
height: Math.round((isInner ? 0.26 : 0.4) * CLOCK_WIDTH),
transform: `rotateZ(${angle}deg)`
};
};
return jsxRuntimeExports.jsx(ClockPointerRoot, _extends$1({
style: getAngleStyle(),
className: clsx(classes.root, className),
ownerState
}, other, {
children: jsxRuntimeExports.jsx(ClockPointerThumb, {
ownerState,
className: classes.thumb
})
}));
}
function getClockUtilityClass(slot) {
return generateUtilityClass("MuiClock", slot);
}
generateUtilityClasses("MuiClock", [
"root",
"clock",
"wrapper",
"squareMask",
"pin",
"amButton",
"pmButton",
"meridiemText",
"selected"
]);
const mergeDateAndTime = (utils, dateParam, timeParam) => {
let mergedDate = dateParam;
mergedDate = utils.setHours(mergedDate, utils.getHours(timeParam));
mergedDate = utils.setMinutes(mergedDate, utils.getMinutes(timeParam));
mergedDate = utils.setSeconds(mergedDate, utils.getSeconds(timeParam));
mergedDate = utils.setMilliseconds(mergedDate, utils.getMilliseconds(timeParam));
return mergedDate;
};
const findClosestEnabledDate = ({ date, disableFuture, disablePast, maxDate, minDate, isDateDisabled, utils, timezone }) => {
const today = mergeDateAndTime(utils, utils.date(void 0, timezone), date);
if (disablePast && utils.isBefore(minDate, today)) {
minDate = today;
}
if (disableFuture && utils.isAfter(maxDate, today)) {
maxDate = today;
}
let forward = date;
let backward = date;
if (utils.isBefore(date, minDate)) {
forward = minDate;
backward = null;
}
if (utils.isAfter(date, maxDate)) {
if (backward) {
backward = maxDate;
}
forward = null;
}
while (forward || backward) {
if (forward && utils.isAfter(forward, maxDate)) {
forward = null;
}
if (backward && utils.isBefore(backward, minDate)) {
backward = null;
}
if (forward) {
if (!isDateDisabled(forward)) {
return forward;
}
forward = utils.addDays(forward, 1);
}
if (backward) {
if (!isDateDisabled(backward)) {
return backward;
}
backward = utils.addDays(backward, -1);
}
}
return null;
};
const replaceInvalidDateByNull = (utils, value) => value == null || !utils.isValid(value) ? null : value;
const applyDefaultDate = (utils, value, defaultValue) => {
if (value == null || !utils.isValid(value)) {
return defaultValue;
}
return value;
};
const areDatesEqual = (utils, a, b2) => {
if (!utils.isValid(a) && a != null && !utils.isValid(b2) && b2 != null) {
return true;
}
return utils.isEqual(a, b2);
};
const getMonthsInYear = (utils, year) => {
const firstMonth = utils.startOfYear(year);
const months = [
firstMonth
];
while (months.length < 12) {
const prevMonth = months[months.length - 1];
months.push(utils.addMonths(prevMonth, 1));
}
return months;
};
const getTodayDate = (utils, timezone, valueType) => valueType === "date" ? utils.startOfDay(utils.date(void 0, timezone)) : utils.date(void 0, timezone);
const formatMeridiem = (utils, meridiem) => {
const date = utils.setHours(utils.date(), meridiem === "am" ? 2 : 14);
return utils.format(date, "meridiem");
};
const dateViews = [
"year",
"month",
"day"
];
const isDatePickerView = (view) => dateViews.includes(view);
const resolveDateFormat = (utils, { format, views }, isInToolbar) => {
if (format != null) {
return format;
}
const formats = utils.formats;
if (areViewsEqual(views, [
"year"
])) {
return formats.year;
}
if (areViewsEqual(views, [
"month"
])) {
return formats.month;
}
if (areViewsEqual(views, [
"day"
])) {
return formats.dayOfMonth;
}
if (areViewsEqual(views, [
"month",
"year"
])) {
return `${formats.month} ${formats.year}`;
}
if (areViewsEqual(views, [
"day",
"month"
])) {
return `${formats.month} ${formats.dayOfMonth}`;
}
if (isInToolbar) {
return /en/.test(utils.getCurrentLocaleCode()) ? formats.normalDateWithWeekday : formats.normalDate;
}
return formats.keyboardDate;
};
const getWeekdays = (utils, date) => {
const start = utils.startOfWeek(date);
return [
0,
1,
2,
3,
4,
5,
6
].map((diff) => utils.addDays(start, diff));
};
const useUtilityClasses$t = (ownerState) => {
const { classes, meridiemMode } = ownerState;
const slots = {
root: [
"root"
],
clock: [
"clock"
],
wrapper: [
"wrapper"
],
squareMask: [
"squareMask"
],
pin: [
"pin"
],
amButton: [
"amButton",
meridiemMode === "am" && "selected"
],
pmButton: [
"pmButton",
meridiemMode === "pm" && "selected"
],
meridiemText: [
"meridiemText"
]
};
return composeClasses(slots, getClockUtilityClass, classes);
};
const ClockRoot = styled("div", {
name: "MuiClock",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})(({ theme }) => ({
display: "flex",
justifyContent: "center",
alignItems: "center",
margin: theme.spacing(2)
}));
const ClockClock = styled("div", {
name: "MuiClock",
slot: "Clock",
overridesResolver: (_, styles2) => styles2.clock
})({
backgroundColor: "rgba(0,0,0,.07)",
borderRadius: "50%",
height: 220,
width: 220,
flexShrink: 0,
position: "relative",
pointerEvents: "none"
});
const ClockWrapper = styled("div", {
name: "MuiClock",
slot: "Wrapper",
overridesResolver: (_, styles2) => styles2.wrapper
})({
"&:focus": {
outline: "none"
}
});
const ClockSquareMask = styled("div", {
name: "MuiClock",
slot: "SquareMask",
overridesResolver: (_, styles2) => styles2.squareMask
})({
width: "100%",
height: "100%",
position: "absolute",
pointerEvents: "auto",
outline: 0,
touchAction: "none",
userSelect: "none",
variants: [
{
props: {
disabled: false
},
style: {
"@media (pointer: fine)": {
cursor: "pointer",
borderRadius: "50%"
},
"&:active": {
cursor: "move"
}
}
}
]
});
const ClockPin = styled("div", {
name: "MuiClock",
slot: "Pin",
overridesResolver: (_, styles2) => styles2.pin
})(({ theme }) => ({
width: 6,
height: 6,
borderRadius: "50%",
backgroundColor: (theme.vars || theme).palette.primary.main,
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)"
}));
const meridiemButtonCommonStyles = (theme, meridiemMode) => ({
zIndex: 1,
bottom: 8,
paddingLeft: 4,
paddingRight: 4,
width: CLOCK_HOUR_WIDTH,
variants: [
{
props: {
meridiemMode
},
style: {
backgroundColor: (theme.vars || theme).palette.primary.main,
color: (theme.vars || theme).palette.primary.contrastText,
"&:hover": {
backgroundColor: (theme.vars || theme).palette.primary.light
}
}
}
]
});
const ClockAmButton = styled(IconButton, {
name: "MuiClock",
slot: "AmButton",
overridesResolver: (_, styles2) => styles2.amButton
})(({ theme }) => _extends$1({}, meridiemButtonCommonStyles(theme, "am"), {
position: "absolute",
left: 8
}));
const ClockPmButton = styled(IconButton, {
name: "MuiClock",
slot: "PmButton",
overridesResolver: (_, styles2) => styles2.pmButton
})(({ theme }) => _extends$1({}, meridiemButtonCommonStyles(theme, "pm"), {
position: "absolute",
right: 8
}));
const ClockMeridiemText = styled(Typography, {
name: "MuiClock",
slot: "meridiemText",
overridesResolver: (_, styles2) => styles2.meridiemText
})({
overflow: "hidden",
whiteSpace: "nowrap",
textOverflow: "ellipsis"
});
function Clock(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiClock"
});
const { ampm, ampmInClock, autoFocus, children, value, handleMeridiemChange, isTimeDisabled, meridiemMode, minutesStep = 1, onChange, selectedId, type, viewValue, viewRange: [minViewValue, maxViewValue], disabled = false, readOnly, className } = props;
const ownerState = props;
const utils = useUtils();
const translations = usePickersTranslations();
const isMoving = __mf_31(false);
const classes = useUtilityClasses$t(ownerState);
const isSelectedTimeDisabled = isTimeDisabled(viewValue, type);
const isPointerInner = !ampm && type === "hours" && (viewValue < 1 || viewValue > 12);
const handleValueChange = (newValue, isFinish) => {
if (disabled || readOnly) {
return;
}
if (isTimeDisabled(newValue, type)) {
return;
}
onChange(newValue, isFinish);
};
const setTime = (event, isFinish) => {
let { offsetX, offsetY } = event;
if (offsetX === void 0) {
const rect = event.target.getBoundingClientRect();
offsetX = event.changedTouches[0].clientX - rect.left;
offsetY = event.changedTouches[0].clientY - rect.top;
}
const newSelectedValue = type === "seconds" || type === "minutes" ? getMinutes(offsetX, offsetY, minutesStep) : getHours(offsetX, offsetY, Boolean(ampm));
handleValueChange(newSelectedValue, isFinish);
};
const handleTouchSelection = (event) => {
isMoving.current = true;
setTime(event, "shallow");
};
const handleTouchEnd = (event) => {
if (isMoving.current) {
setTime(event, "finish");
isMoving.current = false;
}
event.preventDefault();
};
const handleMouseMove = (event) => {
if (event.buttons > 0) {
setTime(event.nativeEvent, "shallow");
}
};
const handleMouseUp = (event) => {
if (isMoving.current) {
isMoving.current = false;
}
setTime(event.nativeEvent, "finish");
};
const hasSelected = __mf_29(() => {
if (type === "hours") {
return true;
}
return viewValue % 5 === 0;
}, [
type,
viewValue
]);
const keyboardControlStep = type === "minutes" ? minutesStep : 1;
const listboxRef = __mf_31(null);
useEnhancedEffect(() => {
if (autoFocus) {
listboxRef.current.focus();
}
}, [
autoFocus
]);
const clampValue = (newValue) => Math.max(minViewValue, Math.min(maxViewValue, newValue));
const circleValue = (newValue) => (newValue + (maxViewValue + 1)) % (maxViewValue + 1);
const handleKeyDown = (event) => {
if (isMoving.current) {
return;
}
switch (event.key) {
case "Home":
handleValueChange(minViewValue, "partial");
event.preventDefault();
break;
case "End":
handleValueChange(maxViewValue, "partial");
event.preventDefault();
break;
case "ArrowUp":
handleValueChange(circleValue(viewValue + keyboardControlStep), "partial");
event.preventDefault();
break;
case "ArrowDown":
handleValueChange(circleValue(viewValue - keyboardControlStep), "partial");
event.preventDefault();
break;
case "PageUp":
handleValueChange(clampValue(viewValue + 5), "partial");
event.preventDefault();
break;
case "PageDown":
handleValueChange(clampValue(viewValue - 5), "partial");
event.preventDefault();
break;
case "Enter":
case " ":
handleValueChange(viewValue, "finish");
event.preventDefault();
break;
}
};
return jsxRuntimeExports.jsxs(ClockRoot, {
className: clsx(classes.root, className),
children: [
jsxRuntimeExports.jsxs(ClockClock, {
className: classes.clock,
children: [
jsxRuntimeExports.jsx(ClockSquareMask, {
onTouchMove: handleTouchSelection,
onTouchStart: handleTouchSelection,
onTouchEnd: handleTouchEnd,
onMouseUp: handleMouseUp,
onMouseMove: handleMouseMove,
ownerState: {
disabled
},
className: classes.squareMask
}),
!isSelectedTimeDisabled && jsxRuntimeExports.jsxs(__mf_2, {
children: [
jsxRuntimeExports.jsx(ClockPin, {
className: classes.pin
}),
value != null && jsxRuntimeExports.jsx(ClockPointer, {
type,
viewValue,
isInner: isPointerInner,
hasSelected
})
]
}),
jsxRuntimeExports.jsx(ClockWrapper, {
"aria-activedescendant": selectedId,
"aria-label": translations.clockLabelText(type, value, utils, value == null ? null : utils.format(value, "fullTime")),
ref: listboxRef,
role: "listbox",
onKeyDown: handleKeyDown,
tabIndex: 0,
className: classes.wrapper,
children
})
]
}),
ampm && ampmInClock && jsxRuntimeExports.jsxs(__mf_2, {
children: [
jsxRuntimeExports.jsx(ClockAmButton, {
onClick: readOnly ? void 0 : () => handleMeridiemChange("am"),
disabled: disabled || meridiemMode === null,
ownerState,
className: classes.amButton,
title: formatMeridiem(utils, "am"),
children: jsxRuntimeExports.jsx(ClockMeridiemText, {
variant: "caption",
className: classes.meridiemText,
children: formatMeridiem(utils, "am")
})
}),
jsxRuntimeExports.jsx(ClockPmButton, {
disabled: disabled || meridiemMode === null,
onClick: readOnly ? void 0 : () => handleMeridiemChange("pm"),
ownerState,
className: classes.pmButton,
title: formatMeridiem(utils, "pm"),
children: jsxRuntimeExports.jsx(ClockMeridiemText, {
variant: "caption",
className: classes.meridiemText,
children: formatMeridiem(utils, "pm")
})
})
]
})
]
});
}
function getClockNumberUtilityClass(slot) {
return generateUtilityClass("MuiClockNumber", slot);
}
const clockNumberClasses = generateUtilityClasses("MuiClockNumber", [
"root",
"selected",
"disabled"
]);
const _excluded$C = [
"className",
"disabled",
"index",
"inner",
"label",
"selected"
];
const useUtilityClasses$s = (ownerState) => {
const { classes, selected, disabled } = ownerState;
const slots = {
root: [
"root",
selected && "selected",
disabled && "disabled"
]
};
return composeClasses(slots, getClockNumberUtilityClass, classes);
};
const ClockNumberRoot = styled("span", {
name: "MuiClockNumber",
slot: "Root",
overridesResolver: (_, styles2) => [
styles2.root,
{
[`&.${clockNumberClasses.disabled}`]: styles2.disabled
},
{
[`&.${clockNumberClasses.selected}`]: styles2.selected
}
]
})(({ theme }) => ({
height: CLOCK_HOUR_WIDTH,
width: CLOCK_HOUR_WIDTH,
position: "absolute",
left: `calc((100% - ${CLOCK_HOUR_WIDTH}px) / 2)`,
display: "inline-flex",
justifyContent: "center",
alignItems: "center",
borderRadius: "50%",
color: (theme.vars || theme).palette.text.primary,
fontFamily: theme.typography.fontFamily,
"&:focused": {
backgroundColor: (theme.vars || theme).palette.background.paper
},
[`&.${clockNumberClasses.selected}`]: {
color: (theme.vars || theme).palette.primary.contrastText
},
[`&.${clockNumberClasses.disabled}`]: {
pointerEvents: "none",
color: (theme.vars || theme).palette.text.disabled
},
variants: [
{
props: {
inner: true
},
style: _extends$1({}, theme.typography.body2, {
color: (theme.vars || theme).palette.text.secondary
})
}
]
}));
function ClockNumber(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiClockNumber"
});
const { className, disabled, index, inner, label, selected } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$C);
const ownerState = props;
const classes = useUtilityClasses$s(ownerState);
const angle = index % 12 / 12 * Math.PI * 2 - Math.PI / 2;
const length = (CLOCK_WIDTH - CLOCK_HOUR_WIDTH - 2) / 2 * (inner ? 0.65 : 1);
const x2 = Math.round(Math.cos(angle) * length);
const y2 = Math.round(Math.sin(angle) * length);
return jsxRuntimeExports.jsx(ClockNumberRoot, _extends$1({
className: clsx(classes.root, className),
"aria-disabled": disabled ? true : void 0,
"aria-selected": selected ? true : void 0,
role: "option",
style: {
transform: `translate(${x2}px, ${y2 + (CLOCK_WIDTH - CLOCK_HOUR_WIDTH) / 2}px`
},
ownerState
}, other, {
children: label
}));
}
const getHourNumbers = ({ ampm, value, getClockNumberText, isDisabled, selectedId, utils }) => {
const currentHours = value ? utils.getHours(value) : null;
const hourNumbers = [];
const startHour = ampm ? 1 : 0;
const endHour = ampm ? 12 : 23;
const isSelected = (hour) => {
if (currentHours === null) {
return false;
}
if (ampm) {
if (hour === 12) {
return currentHours === 12 || currentHours === 0;
}
return currentHours === hour || currentHours - 12 === hour;
}
return currentHours === hour;
};
for (let hour = startHour; hour <= endHour; hour += 1) {
let label = hour.toString();
if (hour === 0) {
label = "00";
}
const inner = !ampm && (hour === 0 || hour > 12);
label = utils.formatNumber(label);
const selected = isSelected(hour);
hourNumbers.push(jsxRuntimeExports.jsx(ClockNumber, {
id: selected ? selectedId : void 0,
index: hour,
inner,
selected,
disabled: isDisabled(hour),
label,
"aria-label": getClockNumberText(label)
}, hour));
}
return hourNumbers;
};
const getMinutesNumbers = ({ utils, value, isDisabled, getClockNumberText, selectedId }) => {
const f2 = utils.formatNumber;
return [
[
5,
f2("05")
],
[
10,
f2("10")
],
[
15,
f2("15")
],
[
20,
f2("20")
],
[
25,
f2("25")
],
[
30,
f2("30")
],
[
35,
f2("35")
],
[
40,
f2("40")
],
[
45,
f2("45")
],
[
50,
f2("50")
],
[
55,
f2("55")
],
[
0,
f2("00")
]
].map(([numberValue, label], index) => {
const selected = numberValue === value;
return jsxRuntimeExports.jsx(ClockNumber, {
label,
id: selected ? selectedId : void 0,
index: index + 1,
inner: false,
disabled: isDisabled(numberValue),
selected,
"aria-label": getClockNumberText(label)
}, numberValue);
});
};
const useValueWithTimezone = ({ timezone: timezoneProp, value: valueProp, defaultValue, referenceDate, onChange, valueManager }) => {
const utils = useUtils();
const firstDefaultValue = __mf_31(defaultValue);
const inputValue = valueProp ?? firstDefaultValue.current ?? valueManager.emptyValue;
const inputTimezone = __mf_29(() => valueManager.getTimezone(utils, inputValue), [
utils,
valueManager,
inputValue
]);
const setInputTimezone = useEventCallback((newValue) => {
if (inputTimezone == null) {
return newValue;
}
return valueManager.setTimezone(utils, inputTimezone, newValue);
});
let timezoneToRender;
if (timezoneProp) {
timezoneToRender = timezoneProp;
} else if (inputTimezone) {
timezoneToRender = inputTimezone;
} else if (referenceDate) {
timezoneToRender = utils.getTimezone(referenceDate);
} else {
timezoneToRender = "default";
}
const valueWithTimezoneToRender = __mf_29(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [
valueManager,
utils,
timezoneToRender,
inputValue
]);
const handleValueChange = useEventCallback((newValue, ...otherParams) => {
const newValueWithInputTimezone = setInputTimezone(newValue);
onChange == null ? void 0 : onChange(newValueWithInputTimezone, ...otherParams);
});
return {
value: valueWithTimezoneToRender,
handleValueChange,
timezone: timezoneToRender
};
};
const useControlledValueWithTimezone = ({ name, timezone: timezoneProp, value: valueProp, defaultValue, referenceDate, onChange: onChangeProp, valueManager }) => {
const [valueWithInputTimezone, setValue] = useControlled({
name,
state: "value",
controlled: valueProp,
default: defaultValue ?? valueManager.emptyValue
});
const onChange = useEventCallback((newValue, ...otherParams) => {
setValue(newValue);
onChangeProp == null ? void 0 : onChangeProp(newValue, ...otherParams);
});
return useValueWithTimezone({
timezone: timezoneProp,
value: valueWithInputTimezone,
defaultValue: void 0,
referenceDate,
onChange,
valueManager
});
};
const SECTION_TYPE_GRANULARITY = {
year: 1,
month: 2,
day: 3,
hours: 4,
minutes: 5,
seconds: 6,
milliseconds: 7
};
const getSectionTypeGranularity = (sections) => Math.max(...sections.map((section) => SECTION_TYPE_GRANULARITY[section.type] ?? 1));
const roundDate = (utils, granularity, date) => {
if (granularity === SECTION_TYPE_GRANULARITY.year) {
return utils.startOfYear(date);
}
if (granularity === SECTION_TYPE_GRANULARITY.month) {
return utils.startOfMonth(date);
}
if (granularity === SECTION_TYPE_GRANULARITY.day) {
return utils.startOfDay(date);
}
let roundedDate = date;
if (granularity < SECTION_TYPE_GRANULARITY.minutes) {
roundedDate = utils.setMinutes(roundedDate, 0);
}
if (granularity < SECTION_TYPE_GRANULARITY.seconds) {
roundedDate = utils.setSeconds(roundedDate, 0);
}
if (granularity < SECTION_TYPE_GRANULARITY.milliseconds) {
roundedDate = utils.setMilliseconds(roundedDate, 0);
}
return roundedDate;
};
const getDefaultReferenceDate = ({ props, utils, granularity, timezone, getTodayDate: inGetTodayDate }) => {
let referenceDate = inGetTodayDate ? inGetTodayDate() : roundDate(utils, granularity, getTodayDate(utils, timezone));
if (props.minDate != null && utils.isAfterDay(props.minDate, referenceDate)) {
referenceDate = roundDate(utils, granularity, props.minDate);
}
if (props.maxDate != null && utils.isBeforeDay(props.maxDate, referenceDate)) {
referenceDate = roundDate(utils, granularity, props.maxDate);
}
const isAfter = createIsAfterIgnoreDatePart(props.disableIgnoringDatePartForTimeValidation ?? false, utils);
if (props.minTime != null && isAfter(props.minTime, referenceDate)) {
referenceDate = roundDate(utils, granularity, props.disableIgnoringDatePartForTimeValidation ? props.minTime : mergeDateAndTime(utils, referenceDate, props.minTime));
}
if (props.maxTime != null && isAfter(referenceDate, props.maxTime)) {
referenceDate = roundDate(utils, granularity, props.disableIgnoringDatePartForTimeValidation ? props.maxTime : mergeDateAndTime(utils, referenceDate, props.maxTime));
}
return referenceDate;
};
const getDateSectionConfigFromFormatToken = (utils, formatToken) => {
const config2 = utils.formatTokenMap[formatToken];
if (config2 == null) {
throw new Error([
`MUI X: The token "${formatToken}" is not supported by the Date and Time Pickers.`,
"Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported."
].join("\n"));
}
if (typeof config2 === "string") {
return {
type: config2,
contentType: config2 === "meridiem" ? "letter" : "digit",
maxLength: void 0
};
}
return {
type: config2.sectionType,
contentType: config2.contentType,
maxLength: config2.maxLength
};
};
const getDeltaFromKeyCode = (keyCode) => {
switch (keyCode) {
case "ArrowUp":
return 1;
case "ArrowDown":
return -1;
case "PageUp":
return 5;
case "PageDown":
return -5;
default:
return 0;
}
};
const getDaysInWeekStr = (utils, format) => {
const elements = [];
const now = utils.date(void 0, "default");
const startDate = utils.startOfWeek(now);
const endDate = utils.endOfWeek(now);
let current = startDate;
while (utils.isBefore(current, endDate)) {
elements.push(current);
current = utils.addDays(current, 1);
}
return elements.map((weekDay) => utils.formatByString(weekDay, format));
};
const getLetterEditingOptions = (utils, timezone, sectionType, format) => {
switch (sectionType) {
case "month": {
return getMonthsInYear(utils, utils.date(void 0, timezone)).map((month) => utils.formatByString(month, format));
}
case "weekDay": {
return getDaysInWeekStr(utils, format);
}
case "meridiem": {
const now = utils.date(void 0, timezone);
return [
utils.startOfDay(now),
utils.endOfDay(now)
].map((date) => utils.formatByString(date, format));
}
default: {
return [];
}
}
};
const FORMAT_SECONDS_NO_LEADING_ZEROS = "s";
const NON_LOCALIZED_DIGITS = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
];
const getLocalizedDigits = (utils) => {
const today = utils.date(void 0);
const formattedZero = utils.formatByString(utils.setSeconds(today, 0), FORMAT_SECONDS_NO_LEADING_ZEROS);
if (formattedZero === "0") {
return NON_LOCALIZED_DIGITS;
}
return Array.from({
length: 10
}).map((_, index) => utils.formatByString(utils.setSeconds(today, index), FORMAT_SECONDS_NO_LEADING_ZEROS));
};
const removeLocalizedDigits = (valueStr, localizedDigits) => {
if (localizedDigits[0] === "0") {
return valueStr;
}
const digits = [];
let currentFormattedDigit = "";
for (let i = 0; i < valueStr.length; i += 1) {
currentFormattedDigit += valueStr[i];
const matchingDigitIndex = localizedDigits.indexOf(currentFormattedDigit);
if (matchingDigitIndex > -1) {
digits.push(matchingDigitIndex.toString());
currentFormattedDigit = "";
}
}
return digits.join("");
};
const applyLocalizedDigits = (valueStr, localizedDigits) => {
if (localizedDigits[0] === "0") {
return valueStr;
}
return valueStr.split("").map((char) => localizedDigits[Number(char)]).join("");
};
const isStringNumber = (valueStr, localizedDigits) => {
const nonLocalizedValueStr = removeLocalizedDigits(valueStr, localizedDigits);
return nonLocalizedValueStr !== " " && !Number.isNaN(Number(nonLocalizedValueStr));
};
const cleanLeadingZeros = (valueStr, size) => {
let cleanValueStr = valueStr;
cleanValueStr = Number(cleanValueStr).toString();
while (cleanValueStr.length < size) {
cleanValueStr = `0${cleanValueStr}`;
}
return cleanValueStr;
};
const cleanDigitSectionValue = (utils, value, sectionBoundaries, localizedDigits, section) => {
if (section.type === "day" && section.contentType === "digit-with-letter") {
const date = utils.setDate(sectionBoundaries.longestMonth, value);
return utils.formatByString(date, section.format);
}
let valueStr = value.toString();
if (section.hasLeadingZerosInInput) {
valueStr = cleanLeadingZeros(valueStr, section.maxLength);
}
return applyLocalizedDigits(valueStr, localizedDigits);
};
const adjustSectionValue = (utils, timezone, section, keyCode, sectionsValueBoundaries, localizedDigits, activeDate, stepsAttributes) => {
const delta = getDeltaFromKeyCode(keyCode);
const isStart = keyCode === "Home";
const isEnd = keyCode === "End";
const shouldSetAbsolute = section.value === "" || isStart || isEnd;
const adjustDigitSection = () => {
const sectionBoundaries = sectionsValueBoundaries[section.type]({
currentDate: activeDate,
format: section.format,
contentType: section.contentType
});
const getCleanValue = (value) => cleanDigitSectionValue(utils, value, sectionBoundaries, localizedDigits, section);
const step = section.type === "minutes" && (stepsAttributes == null ? void 0 : stepsAttributes.minutesStep) ? stepsAttributes.minutesStep : 1;
let newSectionValueNumber;
if (shouldSetAbsolute) {
if (section.type === "year" && !isEnd && !isStart) {
return utils.formatByString(utils.date(void 0, timezone), section.format);
}
if (delta > 0 || isStart) {
newSectionValueNumber = sectionBoundaries.minimum;
} else {
newSectionValueNumber = sectionBoundaries.maximum;
}
} else {
const currentSectionValue = parseInt(removeLocalizedDigits(section.value, localizedDigits), 10);
newSectionValueNumber = currentSectionValue + delta * step;
}
if (newSectionValueNumber % step !== 0) {
if (delta < 0 || isStart) {
newSectionValueNumber += step - (step + newSectionValueNumber) % step;
}
if (delta > 0 || isEnd) {
newSectionValueNumber -= newSectionValueNumber % step;
}
}
if (newSectionValueNumber > sectionBoundaries.maximum) {
return getCleanValue(sectionBoundaries.minimum + (newSectionValueNumber - sectionBoundaries.maximum - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));
}
if (newSectionValueNumber < sectionBoundaries.minimum) {
return getCleanValue(sectionBoundaries.maximum - (sectionBoundaries.minimum - newSectionValueNumber - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));
}
return getCleanValue(newSectionValueNumber);
};
const adjustLetterSection = () => {
const options = getLetterEditingOptions(utils, timezone, section.type, section.format);
if (options.length === 0) {
return section.value;
}
if (shouldSetAbsolute) {
if (delta > 0 || isStart) {
return options[0];
}
return options[options.length - 1];
}
const currentOptionIndex = options.indexOf(section.value);
const newOptionIndex = (currentOptionIndex + delta) % options.length;
const clampedIndex = (newOptionIndex + options.length) % options.length;
return options[clampedIndex];
};
if (section.contentType === "digit" || section.contentType === "digit-with-letter") {
return adjustDigitSection();
}
return adjustLetterSection();
};
const getSectionVisibleValue = (section, target, localizedDigits) => {
let value = section.value || section.placeholder;
const hasLeadingZeros = target === "non-input" ? section.hasLeadingZerosInFormat : section.hasLeadingZerosInInput;
if (target === "non-input" && section.hasLeadingZerosInInput && !section.hasLeadingZerosInFormat) {
value = Number(removeLocalizedDigits(value, localizedDigits)).toString();
}
const shouldAddInvisibleSpace = [
"input-rtl",
"input-ltr"
].includes(target) && section.contentType === "digit" && !hasLeadingZeros && value.length === 1;
if (shouldAddInvisibleSpace) {
value = `${value}\u200E`;
}
if (target === "input-rtl") {
value = `\u2068${value}\u2069`;
}
return value;
};
const changeSectionValueFormat = (utils, valueStr, currentFormat, newFormat) => {
return utils.formatByString(utils.parse(valueStr, currentFormat), newFormat);
};
const isFourDigitYearFormat = (utils, format) => utils.formatByString(utils.date(void 0, "system"), format).length === 4;
const doesSectionFormatHaveLeadingZeros = (utils, contentType, sectionType, format) => {
if (contentType !== "digit") {
return false;
}
const now = utils.date(void 0, "default");
switch (sectionType) {
case "year": {
if (utils.lib === "dayjs" && format === "YY") {
return true;
}
return utils.formatByString(utils.setYear(now, 1), format).startsWith("0");
}
case "month": {
return utils.formatByString(utils.startOfYear(now), format).length > 1;
}
case "day": {
return utils.formatByString(utils.startOfMonth(now), format).length > 1;
}
case "weekDay": {
return utils.formatByString(utils.startOfWeek(now), format).length > 1;
}
case "hours": {
return utils.formatByString(utils.setHours(now, 1), format).length > 1;
}
case "minutes": {
return utils.formatByString(utils.setMinutes(now, 1), format).length > 1;
}
case "seconds": {
return utils.formatByString(utils.setSeconds(now, 1), format).length > 1;
}
default: {
throw new Error("Invalid section type");
}
}
};
const getDateFromDateSections = (utils, sections, localizedDigits) => {
const shouldSkipWeekDays = sections.some((section) => section.type === "day");
const sectionFormats = [];
const sectionValues = [];
for (let i = 0; i < sections.length; i += 1) {
const section = sections[i];
const shouldSkip = shouldSkipWeekDays && section.type === "weekDay";
if (!shouldSkip) {
sectionFormats.push(section.format);
sectionValues.push(getSectionVisibleValue(section, "non-input", localizedDigits));
}
}
const formatWithoutSeparator = sectionFormats.join(" ");
const dateWithoutSeparatorStr = sectionValues.join(" ");
return utils.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
};
const createDateStrForV7HiddenInputFromSections = (sections) => sections.map((section) => {
return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`;
}).join("");
const createDateStrForV6InputFromSections = (sections, localizedDigits, isRtl) => {
const formattedSections = sections.map((section) => {
const dateValue = getSectionVisibleValue(section, isRtl ? "input-rtl" : "input-ltr", localizedDigits);
return `${section.startSeparator}${dateValue}${section.endSeparator}`;
});
const dateStr = formattedSections.join("");
if (!isRtl) {
return dateStr;
}
return `\u2066${dateStr}\u2069`;
};
const getSectionsBoundaries = (utils, localizedDigits, timezone) => {
const today = utils.date(void 0, timezone);
const endOfYear = utils.endOfYear(today);
const endOfDay = utils.endOfDay(today);
const { maxDaysInMonth, longestMonth } = getMonthsInYear(utils, today).reduce((acc, month) => {
const daysInMonth = utils.getDaysInMonth(month);
if (daysInMonth > acc.maxDaysInMonth) {
return {
maxDaysInMonth: daysInMonth,
longestMonth: month
};
}
return acc;
}, {
maxDaysInMonth: 0,
longestMonth: null
});
return {
year: ({ format }) => ({
minimum: 0,
maximum: isFourDigitYearFormat(utils, format) ? 9999 : 99
}),
month: () => ({
minimum: 1,
maximum: utils.getMonth(endOfYear) + 1
}),
day: ({ currentDate }) => ({
minimum: 1,
maximum: currentDate != null && utils.isValid(currentDate) ? utils.getDaysInMonth(currentDate) : maxDaysInMonth,
longestMonth
}),
weekDay: ({ format, contentType }) => {
if (contentType === "digit") {
const daysInWeek = getDaysInWeekStr(utils, format).map(Number);
return {
minimum: Math.min(...daysInWeek),
maximum: Math.max(...daysInWeek)
};
}
return {
minimum: 1,
maximum: 7
};
},
hours: ({ format }) => {
const lastHourInDay = utils.getHours(endOfDay);
const hasMeridiem = removeLocalizedDigits(utils.formatByString(utils.endOfDay(today), format), localizedDigits) !== lastHourInDay.toString();
if (hasMeridiem) {
return {
minimum: 1,
maximum: Number(removeLocalizedDigits(utils.formatByString(utils.startOfDay(today), format), localizedDigits))
};
}
return {
minimum: 0,
maximum: lastHourInDay
};
},
minutes: () => ({
minimum: 0,
maximum: utils.getMinutes(endOfDay)
}),
seconds: () => ({
minimum: 0,
maximum: utils.getSeconds(endOfDay)
}),
meridiem: () => ({
minimum: 0,
maximum: 1
}),
empty: () => ({
minimum: 0,
maximum: 0
})
};
};
const transferDateSectionValue = (utils, section, dateToTransferFrom, dateToTransferTo) => {
switch (section.type) {
case "year": {
return utils.setYear(dateToTransferTo, utils.getYear(dateToTransferFrom));
}
case "month": {
return utils.setMonth(dateToTransferTo, utils.getMonth(dateToTransferFrom));
}
case "weekDay": {
const formattedDaysInWeek = getDaysInWeekStr(utils, section.format);
const dayInWeekStrOfActiveDate = utils.formatByString(dateToTransferFrom, section.format);
const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);
const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);
const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;
return utils.addDays(dateToTransferFrom, diff);
}
case "day": {
return utils.setDate(dateToTransferTo, utils.getDate(dateToTransferFrom));
}
case "meridiem": {
const isAM = utils.getHours(dateToTransferFrom) < 12;
const mergedDateHours = utils.getHours(dateToTransferTo);
if (isAM && mergedDateHours >= 12) {
return utils.addHours(dateToTransferTo, -12);
}
if (!isAM && mergedDateHours < 12) {
return utils.addHours(dateToTransferTo, 12);
}
return dateToTransferTo;
}
case "hours": {
return utils.setHours(dateToTransferTo, utils.getHours(dateToTransferFrom));
}
case "minutes": {
return utils.setMinutes(dateToTransferTo, utils.getMinutes(dateToTransferFrom));
}
case "seconds": {
return utils.setSeconds(dateToTransferTo, utils.getSeconds(dateToTransferFrom));
}
default: {
return dateToTransferTo;
}
}
};
const reliableSectionModificationOrder = {
year: 1,
month: 2,
day: 3,
weekDay: 4,
hours: 5,
minutes: 6,
seconds: 7,
meridiem: 8,
empty: 9
};
const mergeDateIntoReferenceDate = (utils, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) => [
...sections
].sort((a, b2) => reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b2.type]).reduce((mergedDate, section) => {
if (!shouldLimitToEditedSections || section.modified) {
return transferDateSectionValue(utils, section, dateToTransferFrom, mergedDate);
}
return mergedDate;
}, referenceDate);
const isAndroid = () => navigator.userAgent.toLowerCase().includes("android");
const getSectionOrder = (sections, shouldApplyRTL) => {
const neighbors = {};
if (!shouldApplyRTL) {
sections.forEach((_, index) => {
const leftIndex = index === 0 ? null : index - 1;
const rightIndex = index === sections.length - 1 ? null : index + 1;
neighbors[index] = {
leftIndex,
rightIndex
};
});
return {
neighbors,
startIndex: 0,
endIndex: sections.length - 1
};
}
const rtl2ltr = {};
const ltr2rtl = {};
let groupedSectionsStart = 0;
let groupedSectionsEnd = 0;
let RTLIndex = sections.length - 1;
while (RTLIndex >= 0) {
groupedSectionsEnd = sections.findIndex((section, index) => {
var _a;
return index >= groupedSectionsStart && ((_a = section.endSeparator) == null ? void 0 : _a.includes(" ")) && section.endSeparator !== " / ";
});
if (groupedSectionsEnd === -1) {
groupedSectionsEnd = sections.length - 1;
}
for (let i = groupedSectionsEnd; i >= groupedSectionsStart; i -= 1) {
ltr2rtl[i] = RTLIndex;
rtl2ltr[RTLIndex] = i;
RTLIndex -= 1;
}
groupedSectionsStart = groupedSectionsEnd + 1;
}
sections.forEach((_, index) => {
const rtlIndex = ltr2rtl[index];
const leftIndex = rtlIndex === 0 ? null : rtl2ltr[rtlIndex - 1];
const rightIndex = rtlIndex === sections.length - 1 ? null : rtl2ltr[rtlIndex + 1];
neighbors[index] = {
leftIndex,
rightIndex
};
});
return {
neighbors,
startIndex: rtl2ltr[0],
endIndex: rtl2ltr[sections.length - 1]
};
};
const parseSelectedSections = (selectedSections, sections) => {
if (selectedSections == null) {
return null;
}
if (selectedSections === "all") {
return "all";
}
if (typeof selectedSections === "string") {
const index = sections.findIndex((section) => section.type === selectedSections);
return index === -1 ? null : index;
}
return selectedSections;
};
const getSectionValueText = (section, utils) => {
if (!section.value) {
return void 0;
}
switch (section.type) {
case "month": {
if (section.contentType === "digit") {
return utils.format(utils.setMonth(utils.date(), Number(section.value) - 1), "month");
}
const parsedDate = utils.parse(section.value, section.format);
return parsedDate ? utils.format(parsedDate, "month") : void 0;
}
case "day":
return section.contentType === "digit" ? utils.format(utils.setDate(utils.startOfYear(utils.date()), Number(section.value)), "dayOfMonthFull") : section.value;
case "weekDay":
return void 0;
default:
return void 0;
}
};
const getSectionValueNow = (section, utils) => {
if (!section.value) {
return void 0;
}
switch (section.type) {
case "weekDay": {
if (section.contentType === "letter") {
return void 0;
}
return Number(section.value);
}
case "meridiem": {
const parsedDate = utils.parse(`01:00 ${section.value}`, `${utils.formats.hours12h}:${utils.formats.minutes} ${section.format}`);
if (parsedDate) {
return utils.getHours(parsedDate) >= 12 ? 1 : 0;
}
return void 0;
}
case "day":
return section.contentType === "digit-with-letter" ? parseInt(section.value, 10) : Number(section.value);
case "month": {
if (section.contentType === "digit") {
return Number(section.value);
}
const parsedDate = utils.parse(section.value, section.format);
return parsedDate ? utils.getMonth(parsedDate) + 1 : void 0;
}
default:
return section.contentType !== "letter" ? Number(section.value) : void 0;
}
};
const _excluded$B = [
"value",
"referenceDate"
];
const singleItemValueManager = {
emptyValue: null,
getTodayValue: getTodayDate,
getInitialReferenceValue: (_ref) => {
let { value, referenceDate } = _ref, params = _objectWithoutPropertiesLoose$3(_ref, _excluded$B);
if (value != null && params.utils.isValid(value)) {
return value;
}
if (referenceDate != null) {
return referenceDate;
}
return getDefaultReferenceDate(params);
},
cleanValue: replaceInvalidDateByNull,
areValuesEqual: areDatesEqual,
isSameError: (a, b2) => a === b2,
hasError: (error) => error != null,
defaultErrorState: null,
getTimezone: (utils, value) => value == null || !utils.isValid(value) ? null : utils.getTimezone(value),
setTimezone: (utils, timezone, value) => value == null ? null : utils.setTimezone(value, timezone)
};
const singleItemFieldValueManager = {
updateReferenceValue: (utils, value, prevReferenceValue) => value == null || !utils.isValid(value) ? prevReferenceValue : value,
getSectionsFromValue: (utils, date, prevSections, getSectionsFromDate) => {
const shouldReUsePrevDateSections = !utils.isValid(date) && !!prevSections;
if (shouldReUsePrevDateSections) {
return prevSections;
}
return getSectionsFromDate(date);
},
getV7HiddenInputValueFromSections: createDateStrForV7HiddenInputFromSections,
getV6InputValueFromSections: createDateStrForV6InputFromSections,
getActiveDateManager: (utils, state) => ({
date: state.value,
referenceDate: state.referenceValue,
getSections: (sections) => sections,
getNewValuesFromNewActiveDate: (newActiveDate) => ({
value: newActiveDate,
referenceValue: newActiveDate == null || !utils.isValid(newActiveDate) ? state.referenceValue : newActiveDate
})
}),
parseValueStr: (valueStr, referenceValue, parseDate) => parseDate(valueStr.trim(), referenceValue)
};
const useClockReferenceDate = ({ value, referenceDate: referenceDateProp, utils, props, timezone }) => {
const referenceDate = __mf_29(() => singleItemValueManager.getInitialReferenceValue({
value,
utils,
props,
referenceDate: referenceDateProp,
granularity: SECTION_TYPE_GRANULARITY.day,
timezone,
getTodayDate: () => getTodayDate(utils, timezone, "date")
}), []);
return value ?? referenceDate;
};
const _excluded$A = [
"ampm",
"ampmInClock",
"autoFocus",
"slots",
"slotProps",
"value",
"defaultValue",
"referenceDate",
"disableIgnoringDatePartForTimeValidation",
"maxTime",
"minTime",
"disableFuture",
"disablePast",
"minutesStep",
"shouldDisableTime",
"showViewSwitcher",
"onChange",
"view",
"views",
"openTo",
"onViewChange",
"focusedView",
"onFocusedViewChange",
"className",
"disabled",
"readOnly",
"timezone"
];
const useUtilityClasses$r = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
arrowSwitcher: [
"arrowSwitcher"
]
};
return composeClasses(slots, getTimeClockUtilityClass, classes);
};
const TimeClockRoot = styled(PickerViewRoot, {
name: "MuiTimeClock",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
display: "flex",
flexDirection: "column",
position: "relative"
});
const TimeClockArrowSwitcher = styled(PickersArrowSwitcher, {
name: "MuiTimeClock",
slot: "ArrowSwitcher",
overridesResolver: (props, styles2) => styles2.arrowSwitcher
})({
position: "absolute",
right: 12,
top: 15
});
const TIME_CLOCK_DEFAULT_VIEWS = [
"hours",
"minutes"
];
const TimeClock = __mf_14(function TimeClock2(inProps, ref) {
const utils = useUtils();
const props = useThemeProps({
props: inProps,
name: "MuiTimeClock"
});
const { ampm = utils.is12HourCycleInCurrentLocale(), ampmInClock = false, autoFocus, slots, slotProps, value: valueProp, defaultValue, referenceDate: referenceDateProp, disableIgnoringDatePartForTimeValidation = false, maxTime, minTime, disableFuture, disablePast, minutesStep = 1, shouldDisableTime, showViewSwitcher, onChange, view: inView, views = TIME_CLOCK_DEFAULT_VIEWS, openTo, onViewChange, focusedView, onFocusedViewChange, className, disabled, readOnly, timezone: timezoneProp } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$A);
const { value, handleValueChange, timezone } = useControlledValueWithTimezone({
name: "TimeClock",
timezone: timezoneProp,
value: valueProp,
defaultValue,
referenceDate: referenceDateProp,
onChange,
valueManager: singleItemValueManager
});
const valueOrReferenceDate = useClockReferenceDate({
value,
referenceDate: referenceDateProp,
utils,
props,
timezone
});
const translations = usePickersTranslations();
const now = useNow(timezone);
const { view, setView, previousView, nextView, setValueAndGoToNextView } = useViews({
view: inView,
views,
openTo,
onViewChange,
onChange: handleValueChange,
focusedView,
onFocusedViewChange
});
const { meridiemMode, handleMeridiemChange } = useMeridiemMode(valueOrReferenceDate, ampm, setValueAndGoToNextView);
const isTimeDisabled = __mf_20((rawValue, viewType) => {
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, utils);
const shouldCheckPastEnd = viewType === "hours" || viewType === "minutes" && views.includes("seconds");
const containsValidTime = ({ start, end: end2 }) => {
if (minTime && isAfter(minTime, end2)) {
return false;
}
if (maxTime && isAfter(start, maxTime)) {
return false;
}
if (disableFuture && isAfter(start, now)) {
return false;
}
if (disablePast && isAfter(now, shouldCheckPastEnd ? end2 : start)) {
return false;
}
return true;
};
const isValidValue = (timeValue, step = 1) => {
if (timeValue % step !== 0) {
return false;
}
if (shouldDisableTime) {
switch (viewType) {
case "hours":
return !shouldDisableTime(utils.setHours(valueOrReferenceDate, timeValue), "hours");
case "minutes":
return !shouldDisableTime(utils.setMinutes(valueOrReferenceDate, timeValue), "minutes");
case "seconds":
return !shouldDisableTime(utils.setSeconds(valueOrReferenceDate, timeValue), "seconds");
default:
return false;
}
}
return true;
};
switch (viewType) {
case "hours": {
const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
const dateWithNewHours = utils.setHours(valueOrReferenceDate, valueWithMeridiem);
if (utils.getHours(dateWithNewHours) !== valueWithMeridiem) {
return true;
}
const start = utils.setSeconds(utils.setMinutes(dateWithNewHours, 0), 0);
const end2 = utils.setSeconds(utils.setMinutes(dateWithNewHours, 59), 59);
return !containsValidTime({
start,
end: end2
}) || !isValidValue(valueWithMeridiem);
}
case "minutes": {
const dateWithNewMinutes = utils.setMinutes(valueOrReferenceDate, rawValue);
const start = utils.setSeconds(dateWithNewMinutes, 0);
const end2 = utils.setSeconds(dateWithNewMinutes, 59);
return !containsValidTime({
start,
end: end2
}) || !isValidValue(rawValue, minutesStep);
}
case "seconds": {
const dateWithNewSeconds = utils.setSeconds(valueOrReferenceDate, rawValue);
const start = dateWithNewSeconds;
const end2 = dateWithNewSeconds;
return !containsValidTime({
start,
end: end2
}) || !isValidValue(rawValue);
}
default:
throw new Error("not supported");
}
}, [
ampm,
valueOrReferenceDate,
disableIgnoringDatePartForTimeValidation,
maxTime,
meridiemMode,
minTime,
minutesStep,
shouldDisableTime,
utils,
disableFuture,
disablePast,
now,
views
]);
const selectedId = useId();
const viewProps = __mf_29(() => {
switch (view) {
case "hours": {
const handleHoursChange = (hourValue, isFinish) => {
const valueWithMeridiem = convertValueToMeridiem(hourValue, meridiemMode, ampm);
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, "hours");
};
const viewValue = utils.getHours(valueOrReferenceDate);
let viewRange;
if (ampm) {
if (viewValue > 12) {
viewRange = [
12,
23
];
} else {
viewRange = [
0,
11
];
}
} else {
viewRange = [
0,
23
];
}
return {
onChange: handleHoursChange,
viewValue,
children: getHourNumbers({
value,
utils,
ampm,
getClockNumberText: translations.hoursClockNumberText,
isDisabled: (hourValue) => disabled || isTimeDisabled(hourValue, "hours"),
selectedId
}),
viewRange
};
}
case "minutes": {
const minutesValue = utils.getMinutes(valueOrReferenceDate);
const handleMinutesChange = (minuteValue, isFinish) => {
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minuteValue), isFinish, "minutes");
};
return {
viewValue: minutesValue,
onChange: handleMinutesChange,
children: getMinutesNumbers({
utils,
value: minutesValue,
getClockNumberText: translations.minutesClockNumberText,
isDisabled: (minuteValue) => disabled || isTimeDisabled(minuteValue, "minutes"),
selectedId
}),
viewRange: [
0,
59
]
};
}
case "seconds": {
const secondsValue = utils.getSeconds(valueOrReferenceDate);
const handleSecondsChange = (secondValue, isFinish) => {
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, secondValue), isFinish, "seconds");
};
return {
viewValue: secondsValue,
onChange: handleSecondsChange,
children: getMinutesNumbers({
utils,
value: secondsValue,
getClockNumberText: translations.secondsClockNumberText,
isDisabled: (secondValue) => disabled || isTimeDisabled(secondValue, "seconds"),
selectedId
}),
viewRange: [
0,
59
]
};
}
default:
throw new Error("You must provide the type for ClockView");
}
}, [
view,
utils,
value,
ampm,
translations.hoursClockNumberText,
translations.minutesClockNumberText,
translations.secondsClockNumberText,
meridiemMode,
setValueAndGoToNextView,
valueOrReferenceDate,
isTimeDisabled,
selectedId,
disabled
]);
const ownerState = props;
const classes = useUtilityClasses$r(ownerState);
return jsxRuntimeExports.jsxs(TimeClockRoot, _extends$1({
ref,
className: clsx(classes.root, className),
ownerState
}, other, {
children: [
jsxRuntimeExports.jsx(Clock, _extends$1({
autoFocus: autoFocus ?? !!focusedView,
ampmInClock: ampmInClock && views.includes("hours"),
value,
type: view,
ampm,
minutesStep,
isTimeDisabled,
meridiemMode,
handleMeridiemChange,
selectedId,
disabled,
readOnly
}, viewProps)),
showViewSwitcher && jsxRuntimeExports.jsx(TimeClockArrowSwitcher, {
className: classes.arrowSwitcher,
slots,
slotProps,
onGoToPrevious: () => setView(previousView),
isPreviousDisabled: !previousView,
previousLabel: translations.openPreviousView,
onGoToNext: () => setView(nextView),
isNextDisabled: !nextView,
nextLabel: translations.openNextView,
ownerState
})
]
}));
});
function getDigitalClockUtilityClass(slot) {
return generateUtilityClass("MuiDigitalClock", slot);
}
generateUtilityClasses("MuiDigitalClock", [
"root",
"list",
"item"
]);
function arrayIncludes(array, itemOrItems) {
if (Array.isArray(itemOrItems)) {
return itemOrItems.every((item) => array.indexOf(item) !== -1);
}
return array.indexOf(itemOrItems) !== -1;
}
const onSpaceOrEnter = (innerFn, externalEvent) => (event) => {
if (event.key === "Enter" || event.key === " ") {
innerFn(event);
event.preventDefault();
event.stopPropagation();
}
};
const getActiveElement = (root = document) => {
const activeEl = root.activeElement;
if (!activeEl) {
return null;
}
if (activeEl.shadowRoot) {
return getActiveElement(activeEl.shadowRoot);
}
return activeEl;
};
const getFocusedListItemIndex = (listElement) => {
const children = Array.from(listElement.children);
return children.indexOf(getActiveElement(document));
};
const DEFAULT_DESKTOP_MODE_MEDIA_QUERY = "@media (pointer: fine)";
const _excluded$z = [
"ampm",
"timeStep",
"autoFocus",
"slots",
"slotProps",
"value",
"defaultValue",
"referenceDate",
"disableIgnoringDatePartForTimeValidation",
"maxTime",
"minTime",
"disableFuture",
"disablePast",
"minutesStep",
"shouldDisableTime",
"onChange",
"view",
"openTo",
"onViewChange",
"focusedView",
"onFocusedViewChange",
"className",
"disabled",
"readOnly",
"views",
"skipDisabled",
"timezone"
];
const useUtilityClasses$q = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
list: [
"list"
],
item: [
"item"
]
};
return composeClasses(slots, getDigitalClockUtilityClass, classes);
};
const DigitalClockRoot = styled(PickerViewRoot, {
name: "MuiDigitalClock",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
overflowY: "auto",
width: "100%",
"@media (prefers-reduced-motion: no-preference)": {
scrollBehavior: "auto"
},
maxHeight: DIGITAL_CLOCK_VIEW_HEIGHT,
variants: [
{
props: {
alreadyRendered: true
},
style: {
"@media (prefers-reduced-motion: no-preference)": {
scrollBehavior: "smooth"
}
}
}
]
});
const DigitalClockList = styled(MenuList, {
name: "MuiDigitalClock",
slot: "List",
overridesResolver: (props, styles2) => styles2.list
})({
padding: 0
});
const DigitalClockItem = styled(MenuItem, {
name: "MuiDigitalClock",
slot: "Item",
overridesResolver: (props, styles2) => styles2.item
})(({ theme }) => ({
padding: "8px 16px",
margin: "2px 4px",
"&:first-of-type": {
marginTop: 4
},
"&:hover": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : __mf_133(theme.palette.primary.main, theme.palette.action.hoverOpacity)
},
"&.Mui-selected": {
backgroundColor: (theme.vars || theme).palette.primary.main,
color: (theme.vars || theme).palette.primary.contrastText,
"&:focus-visible, &:hover": {
backgroundColor: (theme.vars || theme).palette.primary.dark
}
},
"&.Mui-focusVisible": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})` : __mf_133(theme.palette.primary.main, theme.palette.action.focusOpacity)
}
}));
const DigitalClock = __mf_14(function DigitalClock2(inProps, ref) {
const utils = useUtils();
const containerRef = __mf_31(null);
const handleRef = useForkRef(ref, containerRef);
const listRef = __mf_31(null);
const props = useThemeProps({
props: inProps,
name: "MuiDigitalClock"
});
const { ampm = utils.is12HourCycleInCurrentLocale(), timeStep = 30, autoFocus, slots, slotProps, value: valueProp, defaultValue, referenceDate: referenceDateProp, disableIgnoringDatePartForTimeValidation = false, maxTime, minTime, disableFuture, disablePast, minutesStep = 1, shouldDisableTime, onChange, view: inView, openTo, onViewChange, focusedView, onFocusedViewChange, className, disabled, readOnly, views = [
"hours"
], skipDisabled = false, timezone: timezoneProp } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$z);
const { value, handleValueChange: handleRawValueChange, timezone } = useControlledValueWithTimezone({
name: "DigitalClock",
timezone: timezoneProp,
value: valueProp,
defaultValue,
referenceDate: referenceDateProp,
onChange,
valueManager: singleItemValueManager
});
const translations = usePickersTranslations();
const now = useNow(timezone);
const ownerState = __mf_29(() => _extends$1({}, props, {
alreadyRendered: !!containerRef.current
}), [
props
]);
const classes = useUtilityClasses$q(ownerState);
const ClockItem = (slots == null ? void 0 : slots.digitalClockItem) ?? DigitalClockItem;
const clockItemProps = useSlotProps({
elementType: ClockItem,
externalSlotProps: slotProps == null ? void 0 : slotProps.digitalClockItem,
ownerState: {},
className: classes.item
});
const valueOrReferenceDate = useClockReferenceDate({
value,
referenceDate: referenceDateProp,
utils,
props,
timezone
});
const handleValueChange = useEventCallback((newValue) => handleRawValueChange(newValue, "finish", "hours"));
const { setValueAndGoToNextView } = useViews({
view: inView,
views,
openTo,
onViewChange,
onChange: handleValueChange,
focusedView,
onFocusedViewChange
});
const handleItemSelect = useEventCallback((newValue) => {
setValueAndGoToNextView(newValue, "finish");
});
__mf_24(() => {
if (containerRef.current === null) {
return;
}
const activeItem = containerRef.current.querySelector('[role="listbox"] [role="option"][tabindex="0"], [role="listbox"] [role="option"][aria-selected="true"]');
if (!activeItem) {
return;
}
const offsetTop = activeItem.offsetTop;
if (autoFocus || !!focusedView) {
activeItem.focus();
}
containerRef.current.scrollTop = offsetTop - 4;
});
const isTimeDisabled = __mf_20((valueToCheck) => {
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, utils);
const containsValidTime = () => {
if (minTime && isAfter(minTime, valueToCheck)) {
return false;
}
if (maxTime && isAfter(valueToCheck, maxTime)) {
return false;
}
if (disableFuture && isAfter(valueToCheck, now)) {
return false;
}
if (disablePast && isAfter(now, valueToCheck)) {
return false;
}
return true;
};
const isValidValue = () => {
if (utils.getMinutes(valueToCheck) % minutesStep !== 0) {
return false;
}
if (shouldDisableTime) {
return !shouldDisableTime(valueToCheck, "hours");
}
return true;
};
return !containsValidTime() || !isValidValue();
}, [
disableIgnoringDatePartForTimeValidation,
utils,
minTime,
maxTime,
disableFuture,
now,
disablePast,
minutesStep,
shouldDisableTime
]);
const timeOptions = __mf_29(() => {
const result = [];
const startOfDay = utils.startOfDay(valueOrReferenceDate);
let nextTimeStepOption = startOfDay;
while (utils.isSameDay(valueOrReferenceDate, nextTimeStepOption)) {
result.push(nextTimeStepOption);
nextTimeStepOption = utils.addMinutes(nextTimeStepOption, timeStep);
}
return result;
}, [
valueOrReferenceDate,
timeStep,
utils
]);
const focusedOptionIndex = timeOptions.findIndex((option) => utils.isEqual(option, valueOrReferenceDate));
const handleKeyDown = (event) => {
switch (event.key) {
case "PageUp": {
const newIndex = getFocusedListItemIndex(listRef.current) - 5;
const children = listRef.current.children;
const newFocusedIndex = Math.max(0, newIndex);
const childToFocus = children[newFocusedIndex];
if (childToFocus) {
childToFocus.focus();
}
event.preventDefault();
break;
}
case "PageDown": {
const newIndex = getFocusedListItemIndex(listRef.current) + 5;
const children = listRef.current.children;
const newFocusedIndex = Math.min(children.length - 1, newIndex);
const childToFocus = children[newFocusedIndex];
if (childToFocus) {
childToFocus.focus();
}
event.preventDefault();
break;
}
}
};
return jsxRuntimeExports.jsx(DigitalClockRoot, _extends$1({
ref: handleRef,
className: clsx(classes.root, className),
ownerState
}, other, {
children: jsxRuntimeExports.jsx(DigitalClockList, {
ref: listRef,
role: "listbox",
"aria-label": translations.timePickerToolbarTitle,
className: classes.list,
onKeyDown: handleKeyDown,
children: timeOptions.map((option, index) => {
if (skipDisabled && isTimeDisabled(option)) {
return null;
}
const isSelected = utils.isEqual(option, value);
const formattedValue = utils.format(option, ampm ? "fullTime12h" : "fullTime24h");
const tabIndex = focusedOptionIndex === index || focusedOptionIndex === -1 && index === 0 ? 0 : -1;
return jsxRuntimeExports.jsx(ClockItem, _extends$1({
onClick: () => !readOnly && handleItemSelect(option),
selected: isSelected,
disabled: disabled || isTimeDisabled(option),
disableRipple: readOnly,
role: "option",
"aria-disabled": readOnly,
"aria-selected": isSelected,
tabIndex
}, clockItemProps, {
children: formattedValue
}), `${option.valueOf()}-${formattedValue}`);
})
})
}));
});
function getMultiSectionDigitalClockUtilityClass(slot) {
return generateUtilityClass("MuiMultiSectionDigitalClock", slot);
}
generateUtilityClasses("MuiMultiSectionDigitalClock", [
"root"
]);
function getMultiSectionDigitalClockSectionUtilityClass(slot) {
return generateUtilityClass("MuiMultiSectionDigitalClockSection", slot);
}
generateUtilityClasses("MuiMultiSectionDigitalClockSection", [
"root",
"item"
]);
const _excluded$y = [
"autoFocus",
"onChange",
"className",
"disabled",
"readOnly",
"items",
"active",
"slots",
"slotProps",
"skipDisabled"
];
const useUtilityClasses$p = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
item: [
"item"
]
};
return composeClasses(slots, getMultiSectionDigitalClockSectionUtilityClass, classes);
};
const MultiSectionDigitalClockSectionRoot = styled(MenuList, {
name: "MuiMultiSectionDigitalClockSection",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})(({ theme }) => ({
maxHeight: DIGITAL_CLOCK_VIEW_HEIGHT,
width: 56,
padding: 0,
overflow: "hidden",
"@media (prefers-reduced-motion: no-preference)": {
scrollBehavior: "auto"
},
"@media (pointer: fine)": {
"&:hover": {
overflowY: "auto"
}
},
"@media (pointer: none), (pointer: coarse)": {
overflowY: "auto"
},
"&:not(:first-of-type)": {
borderLeft: `1px solid ${(theme.vars || theme).palette.divider}`
},
"&::after": {
display: "block",
content: '""',
height: "calc(100% - 40px - 6px)"
},
variants: [
{
props: {
alreadyRendered: true
},
style: {
"@media (prefers-reduced-motion: no-preference)": {
scrollBehavior: "smooth"
}
}
}
]
}));
const MultiSectionDigitalClockSectionItem = styled(MenuItem, {
name: "MuiMultiSectionDigitalClockSection",
slot: "Item",
overridesResolver: (_, styles2) => styles2.item
})(({ theme }) => ({
padding: 8,
margin: "2px 4px",
width: MULTI_SECTION_CLOCK_SECTION_WIDTH,
justifyContent: "center",
"&:first-of-type": {
marginTop: 4
},
"&:hover": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : __mf_133(theme.palette.primary.main, theme.palette.action.hoverOpacity)
},
"&.Mui-selected": {
backgroundColor: (theme.vars || theme).palette.primary.main,
color: (theme.vars || theme).palette.primary.contrastText,
"&:focus-visible, &:hover": {
backgroundColor: (theme.vars || theme).palette.primary.dark
}
},
"&.Mui-focusVisible": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})` : __mf_133(theme.palette.primary.main, theme.palette.action.focusOpacity)
}
}));
const MultiSectionDigitalClockSection = __mf_14(function MultiSectionDigitalClockSection2(inProps, ref) {
const containerRef = __mf_31(null);
const handleRef = useForkRef(ref, containerRef);
const previousActive = __mf_31(null);
const props = useThemeProps({
props: inProps,
name: "MuiMultiSectionDigitalClockSection"
});
const { autoFocus, onChange, className, disabled, readOnly, items, active, slots, slotProps, skipDisabled } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$y);
const ownerState = __mf_29(() => _extends$1({}, props, {
alreadyRendered: !!containerRef.current
}), [
props
]);
const classes = useUtilityClasses$p(ownerState);
const DigitalClockSectionItem = (slots == null ? void 0 : slots.digitalClockSectionItem) ?? MultiSectionDigitalClockSectionItem;
__mf_24(() => {
if (containerRef.current === null) {
return;
}
const activeItem = containerRef.current.querySelector('[role="option"][tabindex="0"], [role="option"][aria-selected="true"]');
if (active && autoFocus && activeItem) {
activeItem.focus();
}
if (!activeItem || previousActive.current === activeItem) {
return;
}
previousActive.current = activeItem;
const offsetTop = activeItem.offsetTop;
containerRef.current.scrollTop = offsetTop - 4;
});
const focusedOptionIndex = items.findIndex((item) => item.isFocused(item.value));
const handleKeyDown = (event) => {
switch (event.key) {
case "PageUp": {
const newIndex = getFocusedListItemIndex(containerRef.current) - 5;
const children = containerRef.current.children;
const newFocusedIndex = Math.max(0, newIndex);
const childToFocus = children[newFocusedIndex];
if (childToFocus) {
childToFocus.focus();
}
event.preventDefault();
break;
}
case "PageDown": {
const newIndex = getFocusedListItemIndex(containerRef.current) + 5;
const children = containerRef.current.children;
const newFocusedIndex = Math.min(children.length - 1, newIndex);
const childToFocus = children[newFocusedIndex];
if (childToFocus) {
childToFocus.focus();
}
event.preventDefault();
break;
}
}
};
return jsxRuntimeExports.jsx(MultiSectionDigitalClockSectionRoot, _extends$1({
ref: handleRef,
className: clsx(classes.root, className),
ownerState,
autoFocusItem: autoFocus && active,
role: "listbox",
onKeyDown: handleKeyDown
}, other, {
children: items.map((option, index) => {
var _a;
const isItemDisabled = (_a = option.isDisabled) == null ? void 0 : _a.call(option, option.value);
const isDisabled = disabled || isItemDisabled;
if (skipDisabled && isDisabled) {
return null;
}
const isSelected = option.isSelected(option.value);
const tabIndex = focusedOptionIndex === index || focusedOptionIndex === -1 && index === 0 ? 0 : -1;
return jsxRuntimeExports.jsx(DigitalClockSectionItem, _extends$1({
onClick: () => !readOnly && onChange(option.value),
selected: isSelected,
disabled: isDisabled,
disableRipple: readOnly,
role: "option",
"aria-disabled": readOnly || isDisabled || void 0,
"aria-label": option.ariaLabel,
"aria-selected": isSelected,
tabIndex,
className: classes.item
}, slotProps == null ? void 0 : slotProps.digitalClockSectionItem, {
children: option.label
}), option.label);
})
}));
});
const getHourSectionOptions = ({ now, value, utils, ampm, isDisabled, resolveAriaLabel, timeStep, valueOrReferenceDate }) => {
const currentHours = value ? utils.getHours(value) : null;
const result = [];
const isSelected = (hour, overriddenCurrentHours) => {
const resolvedCurrentHours = overriddenCurrentHours ?? currentHours;
if (resolvedCurrentHours === null) {
return false;
}
if (ampm) {
if (hour === 12) {
return resolvedCurrentHours === 12 || resolvedCurrentHours === 0;
}
return resolvedCurrentHours === hour || resolvedCurrentHours - 12 === hour;
}
return resolvedCurrentHours === hour;
};
const isFocused = (hour) => {
return isSelected(hour, utils.getHours(valueOrReferenceDate));
};
const endHour = ampm ? 11 : 23;
for (let hour = 0; hour <= endHour; hour += timeStep) {
let label = utils.format(utils.setHours(now, hour), ampm ? "hours12h" : "hours24h");
const ariaLabel = resolveAriaLabel(parseInt(label, 10).toString());
label = utils.formatNumber(label);
result.push({
value: hour,
label,
isSelected,
isDisabled,
isFocused,
ariaLabel
});
}
return result;
};
const getTimeSectionOptions = ({ value, utils, isDisabled, timeStep, resolveLabel, resolveAriaLabel, hasValue = true }) => {
const isSelected = (timeValue) => {
if (value === null) {
return false;
}
return hasValue && value === timeValue;
};
const isFocused = (timeValue) => {
return value === timeValue;
};
return [
...Array.from({
length: Math.ceil(60 / timeStep)
}, (_, index) => {
const timeValue = timeStep * index;
return {
value: timeValue,
label: utils.formatNumber(resolveLabel(timeValue)),
isDisabled,
isSelected,
isFocused,
ariaLabel: resolveAriaLabel(timeValue.toString())
};
})
];
};
const _excluded$x = [
"ampm",
"timeSteps",
"autoFocus",
"slots",
"slotProps",
"value",
"defaultValue",
"referenceDate",
"disableIgnoringDatePartForTimeValidation",
"maxTime",
"minTime",
"disableFuture",
"disablePast",
"minutesStep",
"shouldDisableTime",
"onChange",
"view",
"views",
"openTo",
"onViewChange",
"focusedView",
"onFocusedViewChange",
"className",
"disabled",
"readOnly",
"skipDisabled",
"timezone"
];
const useUtilityClasses$o = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
]
};
return composeClasses(slots, getMultiSectionDigitalClockUtilityClass, classes);
};
const MultiSectionDigitalClockRoot = styled(PickerViewRoot, {
name: "MuiMultiSectionDigitalClock",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})(({ theme }) => ({
display: "flex",
flexDirection: "row",
width: "100%",
borderBottom: `1px solid ${(theme.vars || theme).palette.divider}`
}));
const MultiSectionDigitalClock = __mf_14(function MultiSectionDigitalClock2(inProps, ref) {
const utils = useUtils();
const isRtl = useRtl();
const props = useThemeProps({
props: inProps,
name: "MuiMultiSectionDigitalClock"
});
const { ampm = utils.is12HourCycleInCurrentLocale(), timeSteps: inTimeSteps, autoFocus, slots, slotProps, value: valueProp, defaultValue, referenceDate: referenceDateProp, disableIgnoringDatePartForTimeValidation = false, maxTime, minTime, disableFuture, disablePast, minutesStep = 1, shouldDisableTime, onChange, view: inView, views: inViews = [
"hours",
"minutes"
], openTo, onViewChange, focusedView: inFocusedView, onFocusedViewChange, className, disabled, readOnly, skipDisabled = false, timezone: timezoneProp } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$x);
const { value, handleValueChange: handleRawValueChange, timezone } = useControlledValueWithTimezone({
name: "MultiSectionDigitalClock",
timezone: timezoneProp,
value: valueProp,
defaultValue,
referenceDate: referenceDateProp,
onChange,
valueManager: singleItemValueManager
});
const translations = usePickersTranslations();
const now = useNow(timezone);
const timeSteps = __mf_29(() => _extends$1({
hours: 1,
minutes: 5,
seconds: 5
}, inTimeSteps), [
inTimeSteps
]);
const valueOrReferenceDate = useClockReferenceDate({
value,
referenceDate: referenceDateProp,
utils,
props,
timezone
});
const handleValueChange = useEventCallback((newValue, selectionState, selectedView) => handleRawValueChange(newValue, selectionState, selectedView));
const views = __mf_29(() => {
if (!ampm || !inViews.includes("hours")) {
return inViews;
}
return inViews.includes("meridiem") ? inViews : [
...inViews,
"meridiem"
];
}, [
ampm,
inViews
]);
const { view, setValueAndGoToNextView, focusedView } = useViews({
view: inView,
views,
openTo,
onViewChange,
onChange: handleValueChange,
focusedView: inFocusedView,
onFocusedViewChange
});
const handleMeridiemValueChange = useEventCallback((newValue) => {
setValueAndGoToNextView(newValue, "finish", "meridiem");
});
const { meridiemMode, handleMeridiemChange } = useMeridiemMode(valueOrReferenceDate, ampm, handleMeridiemValueChange, "finish");
const isTimeDisabled = __mf_20((rawValue, viewType) => {
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, utils);
const shouldCheckPastEnd = viewType === "hours" || viewType === "minutes" && views.includes("seconds");
const containsValidTime = ({ start, end: end2 }) => {
if (minTime && isAfter(minTime, end2)) {
return false;
}
if (maxTime && isAfter(start, maxTime)) {
return false;
}
if (disableFuture && isAfter(start, now)) {
return false;
}
if (disablePast && isAfter(now, shouldCheckPastEnd ? end2 : start)) {
return false;
}
return true;
};
const isValidValue = (timeValue, step = 1) => {
if (timeValue % step !== 0) {
return false;
}
if (shouldDisableTime) {
switch (viewType) {
case "hours":
return !shouldDisableTime(utils.setHours(valueOrReferenceDate, timeValue), "hours");
case "minutes":
return !shouldDisableTime(utils.setMinutes(valueOrReferenceDate, timeValue), "minutes");
case "seconds":
return !shouldDisableTime(utils.setSeconds(valueOrReferenceDate, timeValue), "seconds");
default:
return false;
}
}
return true;
};
switch (viewType) {
case "hours": {
const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
const dateWithNewHours = utils.setHours(valueOrReferenceDate, valueWithMeridiem);
if (utils.getHours(dateWithNewHours) !== valueWithMeridiem) {
return true;
}
const start = utils.setSeconds(utils.setMinutes(dateWithNewHours, 0), 0);
const end2 = utils.setSeconds(utils.setMinutes(dateWithNewHours, 59), 59);
return !containsValidTime({
start,
end: end2
}) || !isValidValue(valueWithMeridiem);
}
case "minutes": {
const dateWithNewMinutes = utils.setMinutes(valueOrReferenceDate, rawValue);
const start = utils.setSeconds(dateWithNewMinutes, 0);
const end2 = utils.setSeconds(dateWithNewMinutes, 59);
return !containsValidTime({
start,
end: end2
}) || !isValidValue(rawValue, minutesStep);
}
case "seconds": {
const dateWithNewSeconds = utils.setSeconds(valueOrReferenceDate, rawValue);
const start = dateWithNewSeconds;
const end2 = dateWithNewSeconds;
return !containsValidTime({
start,
end: end2
}) || !isValidValue(rawValue);
}
default:
throw new Error("not supported");
}
}, [
ampm,
valueOrReferenceDate,
disableIgnoringDatePartForTimeValidation,
maxTime,
meridiemMode,
minTime,
minutesStep,
shouldDisableTime,
utils,
disableFuture,
disablePast,
now,
views
]);
const buildViewProps = __mf_20((viewToBuild) => {
switch (viewToBuild) {
case "hours": {
return {
onChange: (hours) => {
const valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), "finish", "hours");
},
items: getHourSectionOptions({
now,
value,
ampm,
utils,
isDisabled: (hours) => isTimeDisabled(hours, "hours"),
timeStep: timeSteps.hours,
resolveAriaLabel: translations.hoursClockNumberText,
valueOrReferenceDate
})
};
}
case "minutes": {
return {
onChange: (minutes) => {
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minutes), "finish", "minutes");
},
items: getTimeSectionOptions({
value: utils.getMinutes(valueOrReferenceDate),
utils,
isDisabled: (minutes) => isTimeDisabled(minutes, "minutes"),
resolveLabel: (minutes) => utils.format(utils.setMinutes(now, minutes), "minutes"),
timeStep: timeSteps.minutes,
hasValue: !!value,
resolveAriaLabel: translations.minutesClockNumberText
})
};
}
case "seconds": {
return {
onChange: (seconds) => {
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, seconds), "finish", "seconds");
},
items: getTimeSectionOptions({
value: utils.getSeconds(valueOrReferenceDate),
utils,
isDisabled: (seconds) => isTimeDisabled(seconds, "seconds"),
resolveLabel: (seconds) => utils.format(utils.setSeconds(now, seconds), "seconds"),
timeStep: timeSteps.seconds,
hasValue: !!value,
resolveAriaLabel: translations.secondsClockNumberText
})
};
}
case "meridiem": {
const amLabel = formatMeridiem(utils, "am");
const pmLabel = formatMeridiem(utils, "pm");
return {
onChange: handleMeridiemChange,
items: [
{
value: "am",
label: amLabel,
isSelected: () => !!value && meridiemMode === "am",
isFocused: () => !!valueOrReferenceDate && meridiemMode === "am",
ariaLabel: amLabel
},
{
value: "pm",
label: pmLabel,
isSelected: () => !!value && meridiemMode === "pm",
isFocused: () => !!valueOrReferenceDate && meridiemMode === "pm",
ariaLabel: pmLabel
}
]
};
}
default:
throw new Error(`Unknown view: ${viewToBuild} found.`);
}
}, [
now,
value,
ampm,
utils,
timeSteps.hours,
timeSteps.minutes,
timeSteps.seconds,
translations.hoursClockNumberText,
translations.minutesClockNumberText,
translations.secondsClockNumberText,
meridiemMode,
setValueAndGoToNextView,
valueOrReferenceDate,
isTimeDisabled,
handleMeridiemChange
]);
const viewsToRender = __mf_29(() => {
if (!isRtl) {
return views;
}
const digitViews = views.filter((v2) => v2 !== "meridiem");
digitViews.reverse();
if (views.includes("meridiem")) {
digitViews.push("meridiem");
}
return digitViews;
}, [
isRtl,
views
]);
const viewTimeOptions = __mf_29(() => {
return views.reduce((result, currentView) => {
return _extends$1({}, result, {
[currentView]: buildViewProps(currentView)
});
}, {});
}, [
views,
buildViewProps
]);
const ownerState = props;
const classes = useUtilityClasses$o(ownerState);
return jsxRuntimeExports.jsx(MultiSectionDigitalClockRoot, _extends$1({
ref,
className: clsx(classes.root, className),
ownerState,
role: "group"
}, other, {
children: viewsToRender.map((timeView) => jsxRuntimeExports.jsx(MultiSectionDigitalClockSection, {
items: viewTimeOptions[timeView].items,
onChange: viewTimeOptions[timeView].onChange,
active: view === timeView,
autoFocus: autoFocus || focusedView === timeView,
disabled,
readOnly,
slots,
slotProps,
skipDisabled,
"aria-label": translations.selectViewText(timeView)
}, timeView))
}));
});
function getPickersDayUtilityClass(slot) {
return generateUtilityClass("MuiPickersDay", slot);
}
const pickersDayClasses = generateUtilityClasses("MuiPickersDay", [
"root",
"dayWithMargin",
"dayOutsideMonth",
"hiddenDaySpacingFiller",
"today",
"selected",
"disabled"
]);
const _excluded$w = [
"autoFocus",
"className",
"day",
"disabled",
"disableHighlightToday",
"disableMargin",
"hidden",
"isAnimating",
"onClick",
"onDaySelect",
"onFocus",
"onBlur",
"onKeyDown",
"onMouseDown",
"onMouseEnter",
"outsideCurrentMonth",
"selected",
"showDaysOutsideCurrentMonth",
"children",
"today",
"isFirstVisibleCell",
"isLastVisibleCell"
];
const useUtilityClasses$n = (ownerState) => {
const { selected, disableMargin, disableHighlightToday, today, disabled, outsideCurrentMonth, showDaysOutsideCurrentMonth, classes } = ownerState;
const isHiddenDaySpacingFiller = outsideCurrentMonth && !showDaysOutsideCurrentMonth;
const slots = {
root: [
"root",
selected && !isHiddenDaySpacingFiller && "selected",
disabled && "disabled",
!disableMargin && "dayWithMargin",
!disableHighlightToday && today && "today",
outsideCurrentMonth && showDaysOutsideCurrentMonth && "dayOutsideMonth",
isHiddenDaySpacingFiller && "hiddenDaySpacingFiller"
],
hiddenDaySpacingFiller: [
"hiddenDaySpacingFiller"
]
};
return composeClasses(slots, getPickersDayUtilityClass, classes);
};
const styleArg = ({ theme }) => _extends$1({}, theme.typography.caption, {
width: DAY_SIZE,
height: DAY_SIZE,
borderRadius: "50%",
padding: 0,
backgroundColor: "transparent",
transition: theme.transitions.create("background-color", {
duration: theme.transitions.duration.short
}),
color: (theme.vars || theme).palette.text.primary,
"@media (pointer: fine)": {
"&:hover": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : __mf_133(theme.palette.primary.main, theme.palette.action.hoverOpacity)
}
},
"&:focus": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})` : __mf_133(theme.palette.primary.main, theme.palette.action.focusOpacity),
[`&.${pickersDayClasses.selected}`]: {
willChange: "background-color",
backgroundColor: (theme.vars || theme).palette.primary.dark
}
},
[`&.${pickersDayClasses.selected}`]: {
color: (theme.vars || theme).palette.primary.contrastText,
backgroundColor: (theme.vars || theme).palette.primary.main,
fontWeight: theme.typography.fontWeightMedium,
"&:hover": {
willChange: "background-color",
backgroundColor: (theme.vars || theme).palette.primary.dark
}
},
[`&.${pickersDayClasses.disabled}:not(.${pickersDayClasses.selected})`]: {
color: (theme.vars || theme).palette.text.disabled
},
[`&.${pickersDayClasses.disabled}&.${pickersDayClasses.selected}`]: {
opacity: 0.6
},
variants: [
{
props: {
disableMargin: false
},
style: {
margin: `0 ${DAY_MARGIN}px`
}
},
{
props: {
outsideCurrentMonth: true,
showDaysOutsideCurrentMonth: true
},
style: {
color: (theme.vars || theme).palette.text.secondary
}
},
{
props: {
disableHighlightToday: false,
today: true
},
style: {
[`&:not(.${pickersDayClasses.selected})`]: {
border: `1px solid ${(theme.vars || theme).palette.text.secondary}`
}
}
}
]
});
const overridesResolver = (props, styles2) => {
const { ownerState } = props;
return [
styles2.root,
!ownerState.disableMargin && styles2.dayWithMargin,
!ownerState.disableHighlightToday && ownerState.today && styles2.today,
!ownerState.outsideCurrentMonth && ownerState.showDaysOutsideCurrentMonth && styles2.dayOutsideMonth,
ownerState.outsideCurrentMonth && !ownerState.showDaysOutsideCurrentMonth && styles2.hiddenDaySpacingFiller
];
};
const PickersDayRoot = styled(ButtonBase, {
name: "MuiPickersDay",
slot: "Root",
overridesResolver
})(styleArg);
const PickersDayFiller = styled("div", {
name: "MuiPickersDay",
slot: "Root",
overridesResolver
})(({ theme }) => _extends$1({}, styleArg({
theme
}), {
opacity: 0,
pointerEvents: "none"
}));
const noop = () => {
};
const PickersDayRaw = __mf_14(function PickersDay2(inProps, forwardedRef) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersDay"
});
const { autoFocus = false, className, day, disabled = false, disableHighlightToday = false, disableMargin = false, isAnimating, onClick, onDaySelect, onFocus = noop, onBlur = noop, onKeyDown = noop, onMouseDown = noop, onMouseEnter = noop, outsideCurrentMonth, selected = false, showDaysOutsideCurrentMonth = false, children, today: isToday = false } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$w);
const ownerState = _extends$1({}, props, {
autoFocus,
disabled,
disableHighlightToday,
disableMargin,
selected,
showDaysOutsideCurrentMonth,
today: isToday
});
const classes = useUtilityClasses$n(ownerState);
const utils = useUtils();
const ref = __mf_31(null);
const handleRef = useForkRef(ref, forwardedRef);
useEnhancedEffect(() => {
if (autoFocus && !disabled && !isAnimating && !outsideCurrentMonth) {
ref.current.focus();
}
}, [
autoFocus,
disabled,
isAnimating,
outsideCurrentMonth
]);
const handleMouseDown = (event) => {
onMouseDown(event);
if (outsideCurrentMonth) {
event.preventDefault();
}
};
const handleClick = (event) => {
if (!disabled) {
onDaySelect(day);
}
if (outsideCurrentMonth) {
event.currentTarget.focus();
}
if (onClick) {
onClick(event);
}
};
if (outsideCurrentMonth && !showDaysOutsideCurrentMonth) {
return jsxRuntimeExports.jsx(PickersDayFiller, {
className: clsx(classes.root, classes.hiddenDaySpacingFiller, className),
ownerState,
role: other.role
});
}
return jsxRuntimeExports.jsx(PickersDayRoot, _extends$1({
className: clsx(classes.root, className),
ref: handleRef,
centerRipple: true,
disabled,
tabIndex: selected ? 0 : -1,
onKeyDown: (event) => onKeyDown(event, day),
onFocus: (event) => onFocus(event, day),
onBlur: (event) => onBlur(event, day),
onMouseEnter: (event) => onMouseEnter(event, day),
onClick: handleClick,
onMouseDown: handleMouseDown
}, other, {
ownerState,
children: !children ? utils.format(day, "dayOfMonth") : children
}));
});
const PickersDay = __mf_17(PickersDayRaw);
const validateDate = ({ props, value, timezone, adapter }) => {
if (value === null) {
return null;
}
const { shouldDisableDate, shouldDisableMonth, shouldDisableYear, disablePast, disableFuture } = props;
const now = adapter.utils.date(void 0, timezone);
const minDate = applyDefaultDate(adapter.utils, props.minDate, adapter.defaultDates.minDate);
const maxDate = applyDefaultDate(adapter.utils, props.maxDate, adapter.defaultDates.maxDate);
switch (true) {
case !adapter.utils.isValid(value):
return "invalidDate";
case Boolean(shouldDisableDate && shouldDisableDate(value)):
return "shouldDisableDate";
case Boolean(shouldDisableMonth && shouldDisableMonth(value)):
return "shouldDisableMonth";
case Boolean(shouldDisableYear && shouldDisableYear(value)):
return "shouldDisableYear";
case Boolean(disableFuture && adapter.utils.isAfterDay(value, now)):
return "disableFuture";
case Boolean(disablePast && adapter.utils.isBeforeDay(value, now)):
return "disablePast";
case Boolean(minDate && adapter.utils.isBeforeDay(value, minDate)):
return "minDate";
case Boolean(maxDate && adapter.utils.isAfterDay(value, maxDate)):
return "maxDate";
default:
return null;
}
};
validateDate.valueManager = singleItemValueManager;
const validateTime = ({ adapter, value, timezone, props }) => {
if (value === null) {
return null;
}
const { minTime, maxTime, minutesStep, shouldDisableTime, disableIgnoringDatePartForTimeValidation = false, disablePast, disableFuture } = props;
const now = adapter.utils.date(void 0, timezone);
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, adapter.utils);
switch (true) {
case !adapter.utils.isValid(value):
return "invalidDate";
case Boolean(minTime && isAfter(minTime, value)):
return "minTime";
case Boolean(maxTime && isAfter(value, maxTime)):
return "maxTime";
case Boolean(disableFuture && adapter.utils.isAfter(value, now)):
return "disableFuture";
case Boolean(disablePast && adapter.utils.isBefore(value, now)):
return "disablePast";
case Boolean(shouldDisableTime && shouldDisableTime(value, "hours")):
return "shouldDisableTime-hours";
case Boolean(shouldDisableTime && shouldDisableTime(value, "minutes")):
return "shouldDisableTime-minutes";
case Boolean(shouldDisableTime && shouldDisableTime(value, "seconds")):
return "shouldDisableTime-seconds";
case Boolean(minutesStep && adapter.utils.getMinutes(value) % minutesStep !== 0):
return "minutesStep";
default:
return null;
}
};
validateTime.valueManager = singleItemValueManager;
const DATE_VALIDATION_PROP_NAMES = [
"disablePast",
"disableFuture",
"minDate",
"maxDate",
"shouldDisableDate",
"shouldDisableMonth",
"shouldDisableYear"
];
const TIME_VALIDATION_PROP_NAMES = [
"disablePast",
"disableFuture",
"minTime",
"maxTime",
"shouldDisableTime",
"minutesStep",
"ampm",
"disableIgnoringDatePartForTimeValidation"
];
const DATE_TIME_VALIDATION_PROP_NAMES = [
"minDateTime",
"maxDateTime"
];
const VALIDATION_PROP_NAMES = [
...DATE_VALIDATION_PROP_NAMES,
...TIME_VALIDATION_PROP_NAMES,
...DATE_TIME_VALIDATION_PROP_NAMES
];
const extractValidationProps = (props) => VALIDATION_PROP_NAMES.reduce((extractedProps, propName) => {
if (props.hasOwnProperty(propName)) {
extractedProps[propName] = props[propName];
}
return extractedProps;
}, {});
function useValidation(options) {
const { props, validator, value, timezone, onError } = options;
const adapter = useLocalizationContext();
const previousValidationErrorRef = __mf_31(validator.valueManager.defaultErrorState);
const validationError = validator({
adapter,
value,
timezone,
props
});
const hasValidationError = validator.valueManager.hasError(validationError);
__mf_24(() => {
if (onError && !validator.valueManager.isSameError(validationError, previousValidationErrorRef.current)) {
onError(validationError, value);
}
previousValidationErrorRef.current = validationError;
}, [
validator,
onError,
validationError,
value
]);
const getValidationErrorForNewValue = useEventCallback((newValue) => {
return validator({
adapter,
value: newValue,
timezone,
props
});
});
return {
validationError,
hasValidationError,
getValidationErrorForNewValue
};
}
const expandFormat = ({ utils, format }) => {
let formatExpansionOverflow = 10;
let prevFormat = format;
let nextFormat = utils.expandFormat(format);
while (nextFormat !== prevFormat) {
prevFormat = nextFormat;
nextFormat = utils.expandFormat(prevFormat);
formatExpansionOverflow -= 1;
if (formatExpansionOverflow < 0) {
throw new Error("MUI X: The format expansion seems to be in an infinite loop. Please open an issue with the format passed to the picker component.");
}
}
return nextFormat;
};
const getEscapedPartsFromFormat = ({ utils, expandedFormat }) => {
const escapedParts = [];
const { start: startChar, end: endChar } = utils.escapedCharacters;
const regExp = new RegExp(`(\\${startChar}[^\\${endChar}]*\\${endChar})+`, "g");
let match2 = null;
while (match2 = regExp.exec(expandedFormat)) {
escapedParts.push({
start: match2.index,
end: regExp.lastIndex - 1
});
}
return escapedParts;
};
const getSectionPlaceholder = (utils, localeText, sectionConfig, sectionFormat) => {
switch (sectionConfig.type) {
case "year": {
return localeText.fieldYearPlaceholder({
digitAmount: utils.formatByString(utils.date(void 0, "default"), sectionFormat).length,
format: sectionFormat
});
}
case "month": {
return localeText.fieldMonthPlaceholder({
contentType: sectionConfig.contentType,
format: sectionFormat
});
}
case "day": {
return localeText.fieldDayPlaceholder({
format: sectionFormat
});
}
case "weekDay": {
return localeText.fieldWeekDayPlaceholder({
contentType: sectionConfig.contentType,
format: sectionFormat
});
}
case "hours": {
return localeText.fieldHoursPlaceholder({
format: sectionFormat
});
}
case "minutes": {
return localeText.fieldMinutesPlaceholder({
format: sectionFormat
});
}
case "seconds": {
return localeText.fieldSecondsPlaceholder({
format: sectionFormat
});
}
case "meridiem": {
return localeText.fieldMeridiemPlaceholder({
format: sectionFormat
});
}
default: {
return sectionFormat;
}
}
};
const createSection = ({ utils, date, shouldRespectLeadingZeros, localeText, localizedDigits, now, token, startSeparator }) => {
if (token === "") {
throw new Error("MUI X: Should not call `commitToken` with an empty token");
}
const sectionConfig = getDateSectionConfigFromFormatToken(utils, token);
const hasLeadingZerosInFormat = doesSectionFormatHaveLeadingZeros(utils, sectionConfig.contentType, sectionConfig.type, token);
const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === "digit";
const isValidDate = date != null && utils.isValid(date);
let sectionValue = isValidDate ? utils.formatByString(date, token) : "";
let maxLength = null;
if (hasLeadingZerosInInput) {
if (hasLeadingZerosInFormat) {
maxLength = sectionValue === "" ? utils.formatByString(now, token).length : sectionValue.length;
} else {
if (sectionConfig.maxLength == null) {
throw new Error(`MUI X: The token ${token} should have a 'maxDigitNumber' property on it's adapter`);
}
maxLength = sectionConfig.maxLength;
if (isValidDate) {
sectionValue = applyLocalizedDigits(cleanLeadingZeros(removeLocalizedDigits(sectionValue, localizedDigits), maxLength), localizedDigits);
}
}
}
return _extends$1({}, sectionConfig, {
format: token,
maxLength,
value: sectionValue,
placeholder: getSectionPlaceholder(utils, localeText, sectionConfig, token),
hasLeadingZerosInFormat,
hasLeadingZerosInInput,
startSeparator,
endSeparator: "",
modified: false
});
};
const buildSections = (params) => {
var _a;
const { utils, expandedFormat, escapedParts } = params;
const now = utils.date(void 0);
const sections = [];
let startSeparator = "";
const validTokens = Object.keys(utils.formatTokenMap).sort((a, b2) => b2.length - a.length);
const regExpFirstWordInFormat = /^([a-zA-Z]+)/;
const regExpWordOnlyComposedOfTokens = new RegExp(`^(${validTokens.join("|")})*$`);
const regExpFirstTokenInWord = new RegExp(`^(${validTokens.join("|")})`);
const getEscapedPartOfCurrentChar = (i2) => escapedParts.find((escapeIndex) => escapeIndex.start <= i2 && escapeIndex.end >= i2);
let i = 0;
while (i < expandedFormat.length) {
const escapedPartOfCurrentChar = getEscapedPartOfCurrentChar(i);
const isEscapedChar = escapedPartOfCurrentChar != null;
const firstWordInFormat = (_a = regExpFirstWordInFormat.exec(expandedFormat.slice(i))) == null ? void 0 : _a[1];
if (!isEscapedChar && firstWordInFormat != null && regExpWordOnlyComposedOfTokens.test(firstWordInFormat)) {
let word = firstWordInFormat;
while (word.length > 0) {
const firstWord = regExpFirstTokenInWord.exec(word)[1];
word = word.slice(firstWord.length);
sections.push(createSection(_extends$1({}, params, {
now,
token: firstWord,
startSeparator
})));
startSeparator = "";
}
i += firstWordInFormat.length;
} else {
const char = expandedFormat[i];
const isEscapeBoundary = isEscapedChar && (escapedPartOfCurrentChar == null ? void 0 : escapedPartOfCurrentChar.start) === i || (escapedPartOfCurrentChar == null ? void 0 : escapedPartOfCurrentChar.end) === i;
if (!isEscapeBoundary) {
if (sections.length === 0) {
startSeparator += char;
} else {
sections[sections.length - 1].endSeparator += char;
}
}
i += 1;
}
}
if (sections.length === 0 && startSeparator.length > 0) {
sections.push({
type: "empty",
contentType: "letter",
maxLength: null,
format: "",
value: "",
placeholder: "",
hasLeadingZerosInFormat: false,
hasLeadingZerosInInput: false,
startSeparator,
endSeparator: "",
modified: false
});
}
return sections;
};
const postProcessSections = ({ isRtl, formatDensity, sections }) => {
return sections.map((section) => {
const cleanSeparator = (separator) => {
let cleanedSeparator = separator;
if (isRtl && cleanedSeparator !== null && cleanedSeparator.includes(" ")) {
cleanedSeparator = `\u2069${cleanedSeparator}\u2066`;
}
if (formatDensity === "spacious" && [
"/",
".",
"-"
].includes(cleanedSeparator)) {
cleanedSeparator = ` ${cleanedSeparator} `;
}
return cleanedSeparator;
};
section.startSeparator = cleanSeparator(section.startSeparator);
section.endSeparator = cleanSeparator(section.endSeparator);
return section;
});
};
const buildSectionsFromFormat = (params) => {
let expandedFormat = expandFormat(params);
if (params.isRtl && params.enableAccessibleFieldDOMStructure) {
expandedFormat = expandedFormat.split(" ").reverse().join(" ");
}
const escapedParts = getEscapedPartsFromFormat(_extends$1({}, params, {
expandedFormat
}));
const sections = buildSections(_extends$1({}, params, {
expandedFormat,
escapedParts
}));
return postProcessSections(_extends$1({}, params, {
sections
}));
};
const useFieldState = (params) => {
const utils = useUtils();
const translations = usePickersTranslations();
const adapter = useLocalizationContext();
const isRtl = useRtl();
const { valueManager, fieldValueManager, valueType, validator, internalProps, internalProps: { value: valueProp, defaultValue, referenceDate: referenceDateProp, onChange, format, formatDensity = "dense", selectedSections: selectedSectionsProp, onSelectedSectionsChange, shouldRespectLeadingZeros = false, timezone: timezoneProp, enableAccessibleFieldDOMStructure = false } } = params;
const { timezone, value: valueFromTheOutside, handleValueChange } = useValueWithTimezone({
timezone: timezoneProp,
value: valueProp,
defaultValue,
referenceDate: referenceDateProp,
onChange,
valueManager
});
const localizedDigits = __mf_29(() => getLocalizedDigits(utils), [
utils
]);
const sectionsValueBoundaries = __mf_29(() => getSectionsBoundaries(utils, localizedDigits, timezone), [
utils,
localizedDigits,
timezone
]);
const getSectionsFromValue = __mf_20((value, fallbackSections = null) => fieldValueManager.getSectionsFromValue(utils, value, fallbackSections, (date) => buildSectionsFromFormat({
utils,
localeText: translations,
localizedDigits,
format,
date,
formatDensity,
shouldRespectLeadingZeros,
enableAccessibleFieldDOMStructure,
isRtl
})), [
fieldValueManager,
format,
translations,
localizedDigits,
isRtl,
shouldRespectLeadingZeros,
utils,
formatDensity,
enableAccessibleFieldDOMStructure
]);
const [state, setState] = __mf_32(() => {
const sections = getSectionsFromValue(valueFromTheOutside);
const stateWithoutReferenceDate = {
sections,
value: valueFromTheOutside,
referenceValue: valueManager.emptyValue,
tempValueStrAndroid: null
};
const granularity = getSectionTypeGranularity(sections);
const referenceValue = valueManager.getInitialReferenceValue({
referenceDate: referenceDateProp,
value: valueFromTheOutside,
utils,
props: internalProps,
granularity,
timezone
});
return _extends$1({}, stateWithoutReferenceDate, {
referenceValue
});
});
const [selectedSections, innerSetSelectedSections] = useControlled({
controlled: selectedSectionsProp,
default: null,
name: "useField",
state: "selectedSections"
});
const setSelectedSections = (newSelectedSections) => {
innerSetSelectedSections(newSelectedSections);
onSelectedSectionsChange == null ? void 0 : onSelectedSectionsChange(newSelectedSections);
};
const parsedSelectedSections = __mf_29(() => parseSelectedSections(selectedSections, state.sections), [
selectedSections,
state.sections
]);
const activeSectionIndex = parsedSelectedSections === "all" ? 0 : parsedSelectedSections;
const publishValue = ({ value, referenceValue, sections }) => {
setState((prevState) => _extends$1({}, prevState, {
sections,
value,
referenceValue,
tempValueStrAndroid: null
}));
if (valueManager.areValuesEqual(utils, state.value, value)) {
return;
}
const context = {
validationError: validator({
adapter,
value,
timezone,
props: internalProps
})
};
handleValueChange(value, context);
};
const setSectionValue = (sectionIndex, newSectionValue) => {
const newSections = [
...state.sections
];
newSections[sectionIndex] = _extends$1({}, newSections[sectionIndex], {
value: newSectionValue,
modified: true
});
return newSections;
};
const clearValue = () => {
publishValue({
value: valueManager.emptyValue,
referenceValue: state.referenceValue,
sections: getSectionsFromValue(valueManager.emptyValue)
});
};
const clearActiveSection = () => {
if (activeSectionIndex == null) {
return;
}
const activeSection = state.sections[activeSectionIndex];
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
const nonEmptySectionCountBefore = activeDateManager.getSections(state.sections).filter((section) => section.value !== "").length;
const hasNoOtherNonEmptySections = nonEmptySectionCountBefore === (activeSection.value === "" ? 0 : 1);
const newSections = setSectionValue(activeSectionIndex, "");
const newActiveDate = hasNoOtherNonEmptySections ? null : utils.getInvalidDate();
const newValues = activeDateManager.getNewValuesFromNewActiveDate(newActiveDate);
publishValue(_extends$1({}, newValues, {
sections: newSections
}));
};
const updateValueFromValueStr = (valueStr) => {
const parseDateStr = (dateStr, referenceDate) => {
const date = utils.parse(dateStr, format);
if (date == null || !utils.isValid(date)) {
return null;
}
const sections = buildSectionsFromFormat({
utils,
localeText: translations,
localizedDigits,
format,
date,
formatDensity,
shouldRespectLeadingZeros,
enableAccessibleFieldDOMStructure,
isRtl
});
return mergeDateIntoReferenceDate(utils, date, sections, referenceDate, false);
};
const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
const newReferenceValue = fieldValueManager.updateReferenceValue(utils, newValue, state.referenceValue);
publishValue({
value: newValue,
referenceValue: newReferenceValue,
sections: getSectionsFromValue(newValue, state.sections)
});
};
const updateSectionValue = ({ activeSection, newSectionValue, shouldGoToNextSection }) => {
if (shouldGoToNextSection && activeSectionIndex < state.sections.length - 1) {
setSelectedSections(activeSectionIndex + 1);
}
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
const newSections = setSectionValue(activeSectionIndex, newSectionValue);
const newActiveDateSections = activeDateManager.getSections(newSections);
const newActiveDate = getDateFromDateSections(utils, newActiveDateSections, localizedDigits);
let values2;
let shouldPublish;
if (newActiveDate != null && utils.isValid(newActiveDate)) {
const mergedDate = mergeDateIntoReferenceDate(utils, newActiveDate, newActiveDateSections, activeDateManager.referenceDate, true);
values2 = activeDateManager.getNewValuesFromNewActiveDate(mergedDate);
shouldPublish = true;
} else {
values2 = activeDateManager.getNewValuesFromNewActiveDate(newActiveDate);
shouldPublish = (newActiveDate != null && !utils.isValid(newActiveDate)) !== (activeDateManager.date != null && !utils.isValid(activeDateManager.date));
}
if (shouldPublish) {
return publishValue(_extends$1({}, values2, {
sections: newSections
}));
}
return setState((prevState) => _extends$1({}, prevState, values2, {
sections: newSections,
tempValueStrAndroid: null
}));
};
const setTempAndroidValueStr = (tempValueStrAndroid) => setState((prev) => _extends$1({}, prev, {
tempValueStrAndroid
}));
__mf_24(() => {
const sections = getSectionsFromValue(state.value);
setState((prevState) => _extends$1({}, prevState, {
sections
}));
}, [
format,
utils.locale,
isRtl
]);
__mf_24(() => {
let shouldUpdate;
if (!valueManager.areValuesEqual(utils, state.value, valueFromTheOutside)) {
shouldUpdate = true;
} else {
shouldUpdate = valueManager.getTimezone(utils, state.value) !== valueManager.getTimezone(utils, valueFromTheOutside);
}
if (shouldUpdate) {
setState((prevState) => _extends$1({}, prevState, {
value: valueFromTheOutside,
referenceValue: fieldValueManager.updateReferenceValue(utils, valueFromTheOutside, prevState.referenceValue),
sections: getSectionsFromValue(valueFromTheOutside)
}));
}
}, [
valueFromTheOutside
]);
return {
state,
activeSectionIndex,
parsedSelectedSections,
setSelectedSections,
clearValue,
clearActiveSection,
updateSectionValue,
updateValueFromValueStr,
setTempAndroidValueStr,
getSectionsFromValue,
sectionsValueBoundaries,
localizedDigits,
timezone
};
};
const QUERY_LIFE_DURATION_MS = 5e3;
const isQueryResponseWithoutValue = (response) => response.saveQuery != null;
const useFieldCharacterEditing = ({ sections, updateSectionValue, sectionsValueBoundaries, localizedDigits, setTempAndroidValueStr, timezone }) => {
const utils = useUtils();
const [query, setQuery] = __mf_32(null);
const resetQuery = useEventCallback(() => setQuery(null));
__mf_24(() => {
var _a;
if (query != null && ((_a = sections[query.sectionIndex]) == null ? void 0 : _a.type) !== query.sectionType) {
resetQuery();
}
}, [
sections,
query,
resetQuery
]);
__mf_24(() => {
if (query != null) {
const timeout = setTimeout(() => resetQuery(), QUERY_LIFE_DURATION_MS);
return () => {
clearTimeout(timeout);
};
}
return () => {
};
}, [
query,
resetQuery
]);
const applyQuery = ({ keyPressed, sectionIndex }, getFirstSectionValueMatchingWithQuery, isValidQueryValue) => {
const cleanKeyPressed = keyPressed.toLowerCase();
const activeSection = sections[sectionIndex];
if (query != null && (!isValidQueryValue || isValidQueryValue(query.value)) && query.sectionIndex === sectionIndex) {
const concatenatedQueryValue = `${query.value}${cleanKeyPressed}`;
const queryResponse2 = getFirstSectionValueMatchingWithQuery(concatenatedQueryValue, activeSection);
if (!isQueryResponseWithoutValue(queryResponse2)) {
setQuery({
sectionIndex,
value: concatenatedQueryValue,
sectionType: activeSection.type
});
return queryResponse2;
}
}
const queryResponse = getFirstSectionValueMatchingWithQuery(cleanKeyPressed, activeSection);
if (isQueryResponseWithoutValue(queryResponse) && !queryResponse.saveQuery) {
resetQuery();
return null;
}
setQuery({
sectionIndex,
value: cleanKeyPressed,
sectionType: activeSection.type
});
if (isQueryResponseWithoutValue(queryResponse)) {
return null;
}
return queryResponse;
};
const applyLetterEditing = (params) => {
const findMatchingOptions = (format, options, queryValue) => {
const matchingValues = options.filter((option) => option.toLowerCase().startsWith(queryValue));
if (matchingValues.length === 0) {
return {
saveQuery: false
};
}
return {
sectionValue: matchingValues[0],
shouldGoToNextSection: matchingValues.length === 1
};
};
const testQueryOnFormatAndFallbackFormat = (queryValue, activeSection, fallbackFormat, formatFallbackValue) => {
const getOptions2 = (format) => getLetterEditingOptions(utils, timezone, activeSection.type, format);
if (activeSection.contentType === "letter") {
return findMatchingOptions(activeSection.format, getOptions2(activeSection.format), queryValue);
}
if (fallbackFormat && formatFallbackValue != null && getDateSectionConfigFromFormatToken(utils, fallbackFormat).contentType === "letter") {
const fallbackOptions = getOptions2(fallbackFormat);
const response = findMatchingOptions(fallbackFormat, fallbackOptions, queryValue);
if (isQueryResponseWithoutValue(response)) {
return {
saveQuery: false
};
}
return _extends$1({}, response, {
sectionValue: formatFallbackValue(response.sectionValue, fallbackOptions)
});
}
return {
saveQuery: false
};
};
const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {
switch (activeSection.type) {
case "month": {
const formatFallbackValue = (fallbackValue) => changeSectionValueFormat(utils, fallbackValue, utils.formats.month, activeSection.format);
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, utils.formats.month, formatFallbackValue);
}
case "weekDay": {
const formatFallbackValue = (fallbackValue, fallbackOptions) => fallbackOptions.indexOf(fallbackValue).toString();
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, utils.formats.weekday, formatFallbackValue);
}
case "meridiem": {
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection);
}
default: {
return {
saveQuery: false
};
}
}
};
return applyQuery(params, getFirstSectionValueMatchingWithQuery);
};
const applyNumericEditing = (params) => {
const getNewSectionValue = (queryValue, section) => {
const cleanQueryValue = removeLocalizedDigits(queryValue, localizedDigits);
const queryValueNumber = Number(cleanQueryValue);
const sectionBoundaries = sectionsValueBoundaries[section.type]({
currentDate: null,
format: section.format,
contentType: section.contentType
});
if (queryValueNumber > sectionBoundaries.maximum) {
return {
saveQuery: false
};
}
if (queryValueNumber < sectionBoundaries.minimum) {
return {
saveQuery: true
};
}
const shouldGoToNextSection = queryValueNumber * 10 > sectionBoundaries.maximum || cleanQueryValue.length === sectionBoundaries.maximum.toString().length;
const newSectionValue = cleanDigitSectionValue(utils, queryValueNumber, sectionBoundaries, localizedDigits, section);
return {
sectionValue: newSectionValue,
shouldGoToNextSection
};
};
const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {
if (activeSection.contentType === "digit" || activeSection.contentType === "digit-with-letter") {
return getNewSectionValue(queryValue, activeSection);
}
if (activeSection.type === "month") {
doesSectionFormatHaveLeadingZeros(utils, "digit", "month", "MM");
const response = getNewSectionValue(queryValue, {
type: activeSection.type,
format: "MM",
hasLeadingZerosInInput: true,
contentType: "digit",
maxLength: 2
});
if (isQueryResponseWithoutValue(response)) {
return response;
}
const formattedValue = changeSectionValueFormat(utils, response.sectionValue, "MM", activeSection.format);
return _extends$1({}, response, {
sectionValue: formattedValue
});
}
if (activeSection.type === "weekDay") {
const response = getNewSectionValue(queryValue, activeSection);
if (isQueryResponseWithoutValue(response)) {
return response;
}
const formattedValue = getDaysInWeekStr(utils, activeSection.format)[Number(response.sectionValue) - 1];
return _extends$1({}, response, {
sectionValue: formattedValue
});
}
return {
saveQuery: false
};
};
return applyQuery(params, getFirstSectionValueMatchingWithQuery, (queryValue) => isStringNumber(queryValue, localizedDigits));
};
const applyCharacterEditing = useEventCallback((params) => {
const activeSection = sections[params.sectionIndex];
const isNumericEditing = isStringNumber(params.keyPressed, localizedDigits);
const response = isNumericEditing ? applyNumericEditing(_extends$1({}, params, {
keyPressed: applyLocalizedDigits(params.keyPressed, localizedDigits)
})) : applyLetterEditing(params);
if (response == null) {
setTempAndroidValueStr(null);
return;
}
updateSectionValue({
activeSection,
newSectionValue: response.sectionValue,
shouldGoToNextSection: response.shouldGoToNextSection
});
});
return {
applyCharacterEditing,
resetCharacterQuery: resetQuery
};
};
const useFieldV7TextField = (params) => {
const { internalProps: { disabled, readOnly = false }, forwardedProps: { sectionListRef: inSectionListRef, onBlur, onClick, onFocus, onInput, onPaste, focused: focusedProp, autoFocus = false }, fieldValueManager, applyCharacterEditing, resetCharacterQuery, setSelectedSections, parsedSelectedSections, state, clearActiveSection, clearValue, updateSectionValue, updateValueFromValueStr, sectionOrder, areAllSectionsEmpty, sectionsValueBoundaries } = params;
const sectionListRef = __mf_31(null);
const handleSectionListRef = useForkRef(inSectionListRef, sectionListRef);
const translations = usePickersTranslations();
const utils = useUtils();
const id = useId();
const [focused, setFocused] = __mf_32(false);
const interactions = __mf_29(() => ({
syncSelectionToDOM: () => {
if (!sectionListRef.current) {
return;
}
const selection = document.getSelection();
if (!selection) {
return;
}
if (parsedSelectedSections == null) {
if (selection.rangeCount > 0 && sectionListRef.current.getRoot().contains(selection.getRangeAt(0).startContainer)) {
selection.removeAllRanges();
}
if (focused) {
sectionListRef.current.getRoot().blur();
}
return;
}
if (!sectionListRef.current.getRoot().contains(getActiveElement(document))) {
return;
}
const range = new window.Range();
let target;
if (parsedSelectedSections === "all") {
target = sectionListRef.current.getRoot();
} else {
const section = state.sections[parsedSelectedSections];
if (section.type === "empty") {
target = sectionListRef.current.getSectionContainer(parsedSelectedSections);
} else {
target = sectionListRef.current.getSectionContent(parsedSelectedSections);
}
}
range.selectNodeContents(target);
target.focus();
selection.removeAllRanges();
selection.addRange(range);
},
getActiveSectionIndexFromDOM: () => {
const activeElement = getActiveElement(document);
if (!activeElement || !sectionListRef.current || !sectionListRef.current.getRoot().contains(activeElement)) {
return null;
}
return sectionListRef.current.getSectionIndexFromDOMElement(activeElement);
},
focusField: (newSelectedSections = 0) => {
if (!sectionListRef.current || interactions.getActiveSectionIndexFromDOM() != null) {
return;
}
const newParsedSelectedSections = parseSelectedSections(newSelectedSections, state.sections);
setFocused(true);
sectionListRef.current.getSectionContent(newParsedSelectedSections).focus();
},
setSelectedSections: (newSelectedSections) => {
if (!sectionListRef.current) {
return;
}
const newParsedSelectedSections = parseSelectedSections(newSelectedSections, state.sections);
const newActiveSectionIndex = newParsedSelectedSections === "all" ? 0 : newParsedSelectedSections;
setFocused(newActiveSectionIndex !== null);
setSelectedSections(newSelectedSections);
},
isFieldFocused: () => {
const activeElement = getActiveElement(document);
return !!sectionListRef.current && sectionListRef.current.getRoot().contains(activeElement);
}
}), [
parsedSelectedSections,
setSelectedSections,
state.sections,
focused
]);
const revertDOMSectionChange = useEventCallback((sectionIndex) => {
if (!sectionListRef.current) {
return;
}
const section = state.sections[sectionIndex];
sectionListRef.current.getSectionContent(sectionIndex).innerHTML = section.value || section.placeholder;
interactions.syncSelectionToDOM();
});
const handleContainerClick = useEventCallback((event, ...args) => {
if (event.isDefaultPrevented() || !sectionListRef.current) {
return;
}
setFocused(true);
onClick == null ? void 0 : onClick(event, ...args);
if (parsedSelectedSections === "all") {
setTimeout(() => {
const cursorPosition = document.getSelection().getRangeAt(0).startOffset;
if (cursorPosition === 0) {
setSelectedSections(sectionOrder.startIndex);
return;
}
let sectionIndex = 0;
let cursorOnStartOfSection = 0;
while (cursorOnStartOfSection < cursorPosition && sectionIndex < state.sections.length) {
const section = state.sections[sectionIndex];
sectionIndex += 1;
cursorOnStartOfSection += `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`.length;
}
setSelectedSections(sectionIndex - 1);
});
} else if (!focused) {
setFocused(true);
setSelectedSections(sectionOrder.startIndex);
} else {
const hasClickedOnASection = sectionListRef.current.getRoot().contains(event.target);
if (!hasClickedOnASection) {
setSelectedSections(sectionOrder.startIndex);
}
}
});
const handleContainerInput = useEventCallback((event) => {
onInput == null ? void 0 : onInput(event);
if (!sectionListRef.current || parsedSelectedSections !== "all") {
return;
}
const target = event.target;
const keyPressed = target.textContent ?? "";
sectionListRef.current.getRoot().innerHTML = state.sections.map((section) => `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`).join("");
interactions.syncSelectionToDOM();
if (keyPressed.length === 0 || keyPressed.charCodeAt(0) === 10) {
resetCharacterQuery();
clearValue();
setSelectedSections("all");
} else if (keyPressed.length > 1) {
updateValueFromValueStr(keyPressed);
} else {
if (parsedSelectedSections === "all") {
setSelectedSections(0);
}
applyCharacterEditing({
keyPressed,
sectionIndex: 0
});
}
});
const handleContainerPaste = useEventCallback((event) => {
onPaste == null ? void 0 : onPaste(event);
if (readOnly || parsedSelectedSections !== "all") {
event.preventDefault();
return;
}
const pastedValue = event.clipboardData.getData("text");
event.preventDefault();
resetCharacterQuery();
updateValueFromValueStr(pastedValue);
});
const handleContainerFocus = useEventCallback((...args) => {
onFocus == null ? void 0 : onFocus(...args);
if (focused || !sectionListRef.current) {
return;
}
setFocused(true);
const isFocusInsideASection = sectionListRef.current.getSectionIndexFromDOMElement(getActiveElement(document)) != null;
if (!isFocusInsideASection) {
setSelectedSections(sectionOrder.startIndex);
}
});
const handleContainerBlur = useEventCallback((...args) => {
onBlur == null ? void 0 : onBlur(...args);
setTimeout(() => {
if (!sectionListRef.current) {
return;
}
const activeElement = getActiveElement(document);
const shouldBlur = !sectionListRef.current.getRoot().contains(activeElement);
if (shouldBlur) {
setFocused(false);
setSelectedSections(null);
}
});
});
const getInputContainerClickHandler = useEventCallback((sectionIndex) => (event) => {
if (event.isDefaultPrevented()) {
return;
}
setSelectedSections(sectionIndex);
});
const handleInputContentMouseUp = useEventCallback((event) => {
event.preventDefault();
});
const getInputContentFocusHandler = useEventCallback((sectionIndex) => () => {
setSelectedSections(sectionIndex);
});
const handleInputContentPaste = useEventCallback((event) => {
event.preventDefault();
if (readOnly || disabled || typeof parsedSelectedSections !== "number") {
return;
}
const activeSection = state.sections[parsedSelectedSections];
const pastedValue = event.clipboardData.getData("text");
const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);
const digitsOnly = /^[0-9]+$/.test(pastedValue);
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
const isValidPastedValue = activeSection.contentType === "letter" && lettersOnly || activeSection.contentType === "digit" && digitsOnly || activeSection.contentType === "digit-with-letter" && digitsAndLetterOnly;
if (isValidPastedValue) {
resetCharacterQuery();
updateSectionValue({
activeSection,
newSectionValue: pastedValue,
shouldGoToNextSection: true
});
} else if (!lettersOnly && !digitsOnly) {
resetCharacterQuery();
updateValueFromValueStr(pastedValue);
}
});
const handleInputContentDragOver = useEventCallback((event) => {
event.preventDefault();
event.dataTransfer.dropEffect = "none";
});
const handleInputContentInput = useEventCallback((event) => {
if (!sectionListRef.current) {
return;
}
const target = event.target;
const keyPressed = target.textContent ?? "";
const sectionIndex = sectionListRef.current.getSectionIndexFromDOMElement(target);
const section = state.sections[sectionIndex];
if (readOnly || !sectionListRef.current) {
revertDOMSectionChange(sectionIndex);
return;
}
if (keyPressed.length === 0) {
if (section.value === "") {
revertDOMSectionChange(sectionIndex);
return;
}
const inputType = event.nativeEvent.inputType;
if (inputType === "insertParagraph" || inputType === "insertLineBreak") {
revertDOMSectionChange(sectionIndex);
return;
}
resetCharacterQuery();
clearActiveSection();
return;
}
applyCharacterEditing({
keyPressed,
sectionIndex
});
revertDOMSectionChange(sectionIndex);
});
useEnhancedEffect(() => {
if (!focused || !sectionListRef.current) {
return;
}
if (parsedSelectedSections === "all") {
sectionListRef.current.getRoot().focus();
} else if (typeof parsedSelectedSections === "number") {
const domElement = sectionListRef.current.getSectionContent(parsedSelectedSections);
if (domElement) {
domElement.focus();
}
}
}, [
parsedSelectedSections,
focused
]);
const sectionBoundaries = __mf_29(() => {
return state.sections.reduce((acc, next) => {
acc[next.type] = sectionsValueBoundaries[next.type]({
currentDate: null,
contentType: next.contentType,
format: next.format
});
return acc;
}, {});
}, [
sectionsValueBoundaries,
state.sections
]);
const isContainerEditable = parsedSelectedSections === "all";
const elements = __mf_29(() => {
return state.sections.map((section, index) => {
const isEditable = !isContainerEditable && !disabled && !readOnly;
return {
container: {
"data-sectionindex": index,
onClick: getInputContainerClickHandler(index)
},
content: {
tabIndex: isContainerEditable || index > 0 ? -1 : 0,
contentEditable: !isContainerEditable && !disabled && !readOnly,
role: "spinbutton",
id: `${id}-${section.type}`,
"aria-labelledby": `${id}-${section.type}`,
"aria-readonly": readOnly,
"aria-valuenow": getSectionValueNow(section, utils),
"aria-valuemin": sectionBoundaries[section.type].minimum,
"aria-valuemax": sectionBoundaries[section.type].maximum,
"aria-valuetext": section.value ? getSectionValueText(section, utils) : translations.empty,
"aria-label": translations[section.type],
"aria-disabled": disabled,
spellCheck: isEditable ? false : void 0,
autoCapitalize: isEditable ? "off" : void 0,
autoCorrect: isEditable ? "off" : void 0,
[parseInt(__mf_35, 10) >= 17 ? "enterKeyHint" : "enterkeyhint"]: isEditable ? "next" : void 0,
children: section.value || section.placeholder,
onInput: handleInputContentInput,
onPaste: handleInputContentPaste,
onFocus: getInputContentFocusHandler(index),
onDragOver: handleInputContentDragOver,
onMouseUp: handleInputContentMouseUp,
inputMode: section.contentType === "letter" ? "text" : "numeric"
},
before: {
children: section.startSeparator
},
after: {
children: section.endSeparator
}
};
});
}, [
state.sections,
getInputContentFocusHandler,
handleInputContentPaste,
handleInputContentDragOver,
handleInputContentInput,
getInputContainerClickHandler,
handleInputContentMouseUp,
disabled,
readOnly,
isContainerEditable,
translations,
utils,
sectionBoundaries,
id
]);
const handleValueStrChange = useEventCallback((event) => {
updateValueFromValueStr(event.target.value);
});
const valueStr = __mf_29(() => areAllSectionsEmpty ? "" : fieldValueManager.getV7HiddenInputValueFromSections(state.sections), [
areAllSectionsEmpty,
state.sections,
fieldValueManager
]);
__mf_24(() => {
if (sectionListRef.current == null) {
throw new Error([
"MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`",
"You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.",
"",
"If you want to keep using an `<input />` HTML element for the editing, please remove the `enableAccessibleFieldDOMStructure` prop from your picker or field component:",
"",
"<DatePicker slots={{ textField: MyCustomTextField }} />",
"",
"Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element"
].join("\n"));
}
if (autoFocus && sectionListRef.current) {
sectionListRef.current.getSectionContent(sectionOrder.startIndex).focus();
}
}, []);
return {
interactions,
returnedValue: {
autoFocus,
readOnly,
focused: focusedProp ?? focused,
sectionListRef: handleSectionListRef,
onBlur: handleContainerBlur,
onClick: handleContainerClick,
onFocus: handleContainerFocus,
onInput: handleContainerInput,
onPaste: handleContainerPaste,
enableAccessibleFieldDOMStructure: true,
elements,
tabIndex: parsedSelectedSections === 0 ? -1 : 0,
contentEditable: isContainerEditable,
value: valueStr,
onChange: handleValueStrChange,
areAllSectionsEmpty
}
};
};
const cleanString = (dirtyString) => dirtyString.replace(/[\u2066\u2067\u2068\u2069]/g, "");
const addPositionPropertiesToSections = (sections, localizedDigits, isRtl) => {
let position2 = 0;
let positionInInput = isRtl ? 1 : 0;
const newSections = [];
for (let i = 0; i < sections.length; i += 1) {
const section = sections[i];
const renderedValue = getSectionVisibleValue(section, isRtl ? "input-rtl" : "input-ltr", localizedDigits);
const sectionStr = `${section.startSeparator}${renderedValue}${section.endSeparator}`;
const sectionLength = cleanString(sectionStr).length;
const sectionLengthInInput = sectionStr.length;
const cleanedValue = cleanString(renderedValue);
const startInInput = positionInInput + (cleanedValue === "" ? 0 : renderedValue.indexOf(cleanedValue[0])) + section.startSeparator.length;
const endInInput = startInInput + cleanedValue.length;
newSections.push(_extends$1({}, section, {
start: position2,
end: position2 + sectionLength,
startInInput,
endInInput
}));
position2 += sectionLength;
positionInInput += sectionLengthInInput;
}
return newSections;
};
const useFieldV6TextField = (params) => {
const isRtl = useRtl();
const focusTimeoutRef = __mf_31(void 0);
const selectionSyncTimeoutRef = __mf_31(void 0);
const { forwardedProps: { onFocus, onClick, onPaste, onBlur, inputRef: inputRefProp, placeholder: inPlaceholder }, internalProps: { readOnly = false, disabled = false }, parsedSelectedSections, activeSectionIndex, state, fieldValueManager, valueManager, applyCharacterEditing, resetCharacterQuery, updateSectionValue, updateValueFromValueStr, clearActiveSection, clearValue, setTempAndroidValueStr, setSelectedSections, getSectionsFromValue, areAllSectionsEmpty, localizedDigits } = params;
const inputRef = __mf_31(null);
const handleRef = useForkRef(inputRefProp, inputRef);
const sections = __mf_29(() => addPositionPropertiesToSections(state.sections, localizedDigits, isRtl), [
state.sections,
localizedDigits,
isRtl
]);
const interactions = __mf_29(() => ({
syncSelectionToDOM: () => {
if (!inputRef.current) {
return;
}
if (parsedSelectedSections == null) {
if (inputRef.current.scrollLeft) {
inputRef.current.scrollLeft = 0;
}
return;
}
if (inputRef.current !== getActiveElement(document)) {
return;
}
const currentScrollTop = inputRef.current.scrollTop;
if (parsedSelectedSections === "all") {
inputRef.current.select();
} else {
const selectedSection = sections[parsedSelectedSections];
const selectionStart = selectedSection.type === "empty" ? selectedSection.startInInput - selectedSection.startSeparator.length : selectedSection.startInInput;
const selectionEnd = selectedSection.type === "empty" ? selectedSection.endInInput + selectedSection.endSeparator.length : selectedSection.endInInput;
if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {
if (inputRef.current === getActiveElement(document)) {
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
}
}
clearTimeout(selectionSyncTimeoutRef.current);
selectionSyncTimeoutRef.current = setTimeout(() => {
if (inputRef.current && inputRef.current === getActiveElement(document) && inputRef.current.selectionStart === inputRef.current.selectionEnd && (inputRef.current.selectionStart !== selectionStart || inputRef.current.selectionEnd !== selectionEnd)) {
interactions.syncSelectionToDOM();
}
});
}
inputRef.current.scrollTop = currentScrollTop;
},
getActiveSectionIndexFromDOM: () => {
const browserStartIndex = inputRef.current.selectionStart ?? 0;
const browserEndIndex = inputRef.current.selectionEnd ?? 0;
if (browserStartIndex === 0 && browserEndIndex === 0) {
return null;
}
const nextSectionIndex = browserStartIndex <= sections[0].startInInput ? 1 : sections.findIndex((section) => section.startInInput - section.startSeparator.length > browserStartIndex);
return nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;
},
focusField: (newSelectedSection = 0) => {
var _a;
if (getActiveElement(document) === inputRef.current) {
return;
}
(_a = inputRef.current) == null ? void 0 : _a.focus();
setSelectedSections(newSelectedSection);
},
setSelectedSections: (newSelectedSections) => setSelectedSections(newSelectedSections),
isFieldFocused: () => inputRef.current === getActiveElement(document)
}), [
inputRef,
parsedSelectedSections,
sections,
setSelectedSections
]);
const syncSelectionFromDOM = () => {
const browserStartIndex = inputRef.current.selectionStart ?? 0;
let nextSectionIndex;
if (browserStartIndex <= sections[0].startInInput) {
nextSectionIndex = 1;
} else if (browserStartIndex >= sections[sections.length - 1].endInInput) {
nextSectionIndex = 1;
} else {
nextSectionIndex = sections.findIndex((section) => section.startInInput - section.startSeparator.length > browserStartIndex);
}
const sectionIndex = nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;
setSelectedSections(sectionIndex);
};
const handleInputFocus = useEventCallback((...args) => {
onFocus == null ? void 0 : onFocus(...args);
const input = inputRef.current;
clearTimeout(focusTimeoutRef.current);
focusTimeoutRef.current = setTimeout(() => {
if (!input || input !== inputRef.current) {
return;
}
if (activeSectionIndex != null) {
return;
}
if (input.value.length && Number(input.selectionEnd) - Number(input.selectionStart) === input.value.length) {
setSelectedSections("all");
} else {
syncSelectionFromDOM();
}
});
});
const handleInputClick = useEventCallback((event, ...args) => {
if (event.isDefaultPrevented()) {
return;
}
onClick == null ? void 0 : onClick(event, ...args);
syncSelectionFromDOM();
});
const handleInputPaste = useEventCallback((event) => {
onPaste == null ? void 0 : onPaste(event);
event.preventDefault();
if (readOnly || disabled) {
return;
}
const pastedValue = event.clipboardData.getData("text");
if (typeof parsedSelectedSections === "number") {
const activeSection = state.sections[parsedSelectedSections];
const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);
const digitsOnly = /^[0-9]+$/.test(pastedValue);
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
const isValidPastedValue = activeSection.contentType === "letter" && lettersOnly || activeSection.contentType === "digit" && digitsOnly || activeSection.contentType === "digit-with-letter" && digitsAndLetterOnly;
if (isValidPastedValue) {
resetCharacterQuery();
updateSectionValue({
activeSection,
newSectionValue: pastedValue,
shouldGoToNextSection: true
});
return;
}
if (lettersOnly || digitsOnly) {
return;
}
}
resetCharacterQuery();
updateValueFromValueStr(pastedValue);
});
const handleContainerBlur = useEventCallback((...args) => {
onBlur == null ? void 0 : onBlur(...args);
setSelectedSections(null);
});
const handleInputChange = useEventCallback((event) => {
if (readOnly) {
return;
}
const targetValue = event.target.value;
if (targetValue === "") {
resetCharacterQuery();
clearValue();
return;
}
const eventData = event.nativeEvent.data;
const shouldUseEventData = eventData && eventData.length > 1;
const valueStr2 = shouldUseEventData ? eventData : targetValue;
const cleanValueStr = cleanString(valueStr2);
if (parsedSelectedSections === "all") {
setSelectedSections(activeSectionIndex);
}
if (activeSectionIndex == null || shouldUseEventData) {
updateValueFromValueStr(shouldUseEventData ? eventData : cleanValueStr);
return;
}
let keyPressed;
if (parsedSelectedSections === "all" && cleanValueStr.length === 1) {
keyPressed = cleanValueStr;
} else {
const prevValueStr = cleanString(fieldValueManager.getV6InputValueFromSections(sections, localizedDigits, isRtl));
let startOfDiffIndex = -1;
let endOfDiffIndex = -1;
for (let i = 0; i < prevValueStr.length; i += 1) {
if (startOfDiffIndex === -1 && prevValueStr[i] !== cleanValueStr[i]) {
startOfDiffIndex = i;
}
if (endOfDiffIndex === -1 && prevValueStr[prevValueStr.length - i - 1] !== cleanValueStr[cleanValueStr.length - i - 1]) {
endOfDiffIndex = i;
}
}
const activeSection = sections[activeSectionIndex];
const hasDiffOutsideOfActiveSection = startOfDiffIndex < activeSection.start || prevValueStr.length - endOfDiffIndex - 1 > activeSection.end;
if (hasDiffOutsideOfActiveSection) {
return;
}
const activeSectionEndRelativeToNewValue = cleanValueStr.length - prevValueStr.length + activeSection.end - cleanString(activeSection.endSeparator || "").length;
keyPressed = cleanValueStr.slice(activeSection.start + cleanString(activeSection.startSeparator || "").length, activeSectionEndRelativeToNewValue);
}
if (keyPressed.length === 0) {
if (isAndroid()) {
setTempAndroidValueStr(valueStr2);
}
resetCharacterQuery();
clearActiveSection();
return;
}
applyCharacterEditing({
keyPressed,
sectionIndex: activeSectionIndex
});
});
const placeholder = __mf_29(() => {
if (inPlaceholder !== void 0) {
return inPlaceholder;
}
return fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRtl);
}, [
inPlaceholder,
fieldValueManager,
getSectionsFromValue,
valueManager.emptyValue,
localizedDigits,
isRtl
]);
const valueStr = __mf_29(() => state.tempValueStrAndroid ?? fieldValueManager.getV6InputValueFromSections(state.sections, localizedDigits, isRtl), [
state.sections,
fieldValueManager,
state.tempValueStrAndroid,
localizedDigits,
isRtl
]);
__mf_24(() => {
if (inputRef.current && inputRef.current === getActiveElement(document)) {
setSelectedSections("all");
}
return () => {
clearTimeout(focusTimeoutRef.current);
clearTimeout(selectionSyncTimeoutRef.current);
};
}, []);
const inputMode = __mf_29(() => {
if (activeSectionIndex == null) {
return "text";
}
if (state.sections[activeSectionIndex].contentType === "letter") {
return "text";
}
return "numeric";
}, [
activeSectionIndex,
state.sections
]);
const inputHasFocus = inputRef.current && inputRef.current === getActiveElement(document);
const shouldShowPlaceholder = !inputHasFocus && areAllSectionsEmpty;
return {
interactions,
returnedValue: {
readOnly,
onBlur: handleContainerBlur,
onClick: handleInputClick,
onFocus: handleInputFocus,
onPaste: handleInputPaste,
inputRef: handleRef,
enableAccessibleFieldDOMStructure: false,
placeholder,
inputMode,
autoComplete: "off",
value: shouldShowPlaceholder ? "" : valueStr,
onChange: handleInputChange
}
};
};
const useField = (params) => {
const utils = useUtils();
const { internalProps, internalProps: { unstableFieldRef, minutesStep, enableAccessibleFieldDOMStructure = false, disabled = false, readOnly = false }, forwardedProps: { onKeyDown, error, clearable, onClear }, fieldValueManager, valueManager, validator } = params;
const isRtl = useRtl();
const stateResponse = useFieldState(params);
const { state, activeSectionIndex, parsedSelectedSections, setSelectedSections, clearValue, clearActiveSection, updateSectionValue, setTempAndroidValueStr, sectionsValueBoundaries, localizedDigits, timezone } = stateResponse;
const characterEditingResponse = useFieldCharacterEditing({
sections: state.sections,
updateSectionValue,
sectionsValueBoundaries,
localizedDigits,
setTempAndroidValueStr,
timezone
});
const { resetCharacterQuery } = characterEditingResponse;
const areAllSectionsEmpty = valueManager.areValuesEqual(utils, state.value, valueManager.emptyValue);
const useFieldTextField = enableAccessibleFieldDOMStructure ? useFieldV7TextField : useFieldV6TextField;
const sectionOrder = __mf_29(() => getSectionOrder(state.sections, isRtl && !enableAccessibleFieldDOMStructure), [
state.sections,
isRtl,
enableAccessibleFieldDOMStructure
]);
const { returnedValue, interactions } = useFieldTextField(_extends$1({}, params, stateResponse, characterEditingResponse, {
areAllSectionsEmpty,
sectionOrder
}));
const handleContainerKeyDown = useEventCallback((event) => {
onKeyDown == null ? void 0 : onKeyDown(event);
if (disabled) {
return;
}
switch (true) {
case ((event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === "A" && !event.shiftKey && !event.altKey): {
event.preventDefault();
setSelectedSections("all");
break;
}
case event.key === "ArrowRight": {
event.preventDefault();
if (parsedSelectedSections == null) {
setSelectedSections(sectionOrder.startIndex);
} else if (parsedSelectedSections === "all") {
setSelectedSections(sectionOrder.endIndex);
} else {
const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].rightIndex;
if (nextSectionIndex !== null) {
setSelectedSections(nextSectionIndex);
}
}
break;
}
case event.key === "ArrowLeft": {
event.preventDefault();
if (parsedSelectedSections == null) {
setSelectedSections(sectionOrder.endIndex);
} else if (parsedSelectedSections === "all") {
setSelectedSections(sectionOrder.startIndex);
} else {
const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].leftIndex;
if (nextSectionIndex !== null) {
setSelectedSections(nextSectionIndex);
}
}
break;
}
case event.key === "Delete": {
event.preventDefault();
if (readOnly) {
break;
}
if (parsedSelectedSections == null || parsedSelectedSections === "all") {
clearValue();
} else {
clearActiveSection();
}
resetCharacterQuery();
break;
}
case [
"ArrowUp",
"ArrowDown",
"Home",
"End",
"PageUp",
"PageDown"
].includes(event.key): {
event.preventDefault();
if (readOnly || activeSectionIndex == null) {
break;
}
if (parsedSelectedSections === "all") {
setSelectedSections(activeSectionIndex);
}
const activeSection = state.sections[activeSectionIndex];
const activeDateManager = fieldValueManager.getActiveDateManager(utils, state, activeSection);
const newSectionValue = adjustSectionValue(utils, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, activeDateManager.date, {
minutesStep
});
updateSectionValue({
activeSection,
newSectionValue,
shouldGoToNextSection: false
});
break;
}
}
});
useEnhancedEffect(() => {
interactions.syncSelectionToDOM();
});
const { hasValidationError } = useValidation({
props: internalProps,
validator,
timezone,
value: state.value,
onError: internalProps.onError
});
const inputError = __mf_29(() => {
if (error !== void 0) {
return error;
}
return hasValidationError;
}, [
hasValidationError,
error
]);
__mf_24(() => {
if (!inputError && activeSectionIndex == null) {
resetCharacterQuery();
}
}, [
state.referenceValue,
activeSectionIndex,
inputError
]);
__mf_24(() => {
if (state.tempValueStrAndroid != null && activeSectionIndex != null) {
resetCharacterQuery();
clearActiveSection();
}
}, [
state.sections
]);
__mf_26(unstableFieldRef, () => ({
getSections: () => state.sections,
getActiveSectionIndex: interactions.getActiveSectionIndexFromDOM,
setSelectedSections: interactions.setSelectedSections,
focusField: interactions.focusField,
isFieldFocused: interactions.isFieldFocused
}));
const handleClearValue = useEventCallback((event, ...args) => {
event.preventDefault();
onClear == null ? void 0 : onClear(event, ...args);
clearValue();
if (!interactions.isFieldFocused()) {
interactions.focusField(0);
} else {
setSelectedSections(sectionOrder.startIndex);
}
});
const commonForwardedProps = {
onKeyDown: handleContainerKeyDown,
onClear: handleClearValue,
error: inputError,
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled)
};
const commonAdditionalProps = {
disabled,
readOnly
};
return _extends$1({}, params.forwardedProps, commonForwardedProps, commonAdditionalProps, returnedValue);
};
const _excluded$v = [
"clearable",
"onClear",
"InputProps",
"sx",
"slots",
"slotProps"
], _excluded2$5 = [
"ownerState"
];
const useClearableField = (props) => {
const translations = usePickersTranslations();
const { clearable, onClear, InputProps, sx, slots, slotProps } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$v);
const IconButton$1 = (slots == null ? void 0 : slots.clearButton) ?? IconButton;
const _useSlotProps = useSlotProps({
elementType: IconButton$1,
externalSlotProps: slotProps == null ? void 0 : slotProps.clearButton,
ownerState: {},
className: "clearButton",
additionalProps: {
title: translations.fieldClearLabel
}
}), iconButtonProps = _objectWithoutPropertiesLoose$3(_useSlotProps, _excluded2$5);
const EndClearIcon = (slots == null ? void 0 : slots.clearIcon) ?? ClearIcon;
const endClearIconProps = useSlotProps({
elementType: EndClearIcon,
externalSlotProps: slotProps == null ? void 0 : slotProps.clearIcon,
ownerState: {}
});
return _extends$1({}, other, {
InputProps: _extends$1({}, InputProps, {
endAdornment: jsxRuntimeExports.jsxs(__mf_2, {
children: [
clearable && jsxRuntimeExports.jsx(InputAdornment, {
position: "end",
sx: {
marginRight: (InputProps == null ? void 0 : InputProps.endAdornment) ? -1 : -1.5
},
children: jsxRuntimeExports.jsx(IconButton$1, _extends$1({}, iconButtonProps, {
onClick: onClear,
children: jsxRuntimeExports.jsx(EndClearIcon, _extends$1({
fontSize: "small"
}, endClearIconProps))
}))
}),
InputProps == null ? void 0 : InputProps.endAdornment
]
})
}),
sx: [
{
"& .clearButton": {
opacity: 1
},
"@media (pointer: fine)": {
"& .clearButton": {
opacity: 0
},
"&:hover, &:focus-within": {
".clearButton": {
opacity: 1
}
}
}
},
...Array.isArray(sx) ? sx : [
sx
]
]
});
};
const SHARED_FIELD_INTERNAL_PROP_NAMES = [
"value",
"defaultValue",
"referenceDate",
"format",
"formatDensity",
"onChange",
"timezone",
"onError",
"shouldRespectLeadingZeros",
"selectedSections",
"onSelectedSectionsChange",
"unstableFieldRef",
"enableAccessibleFieldDOMStructure",
"disabled",
"readOnly",
"dateSeparator"
];
const useSplitFieldProps = (props, valueType) => {
return __mf_29(() => {
const forwardedProps = _extends$1({}, props);
const internalProps = {};
const extractProp = (propName) => {
if (forwardedProps.hasOwnProperty(propName)) {
internalProps[propName] = forwardedProps[propName];
delete forwardedProps[propName];
}
};
SHARED_FIELD_INTERNAL_PROP_NAMES.forEach(extractProp);
if (valueType === "date") {
DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
} else if (valueType === "time") {
TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
} else if (valueType === "date-time") {
DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
DATE_TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
}
return {
forwardedProps,
internalProps
};
}, [
props,
valueType
]);
};
const PickersContext = __mf_10(null);
function PickersProvider(props) {
const { contextValue, localeText, children } = props;
return jsxRuntimeExports.jsx(PickersContext.Provider, {
value: contextValue,
children: jsxRuntimeExports.jsx(LocalizationProvider, {
localeText,
children
})
});
}
const useDefaultizedDateField = (props) => {
const utils = useUtils();
const defaultDates = useDefaultDates();
return _extends$1({}, props, {
disablePast: props.disablePast ?? false,
disableFuture: props.disableFuture ?? false,
format: props.format ?? utils.formats.keyboardDate,
minDate: applyDefaultDate(utils, props.minDate, defaultDates.minDate),
maxDate: applyDefaultDate(utils, props.maxDate, defaultDates.maxDate)
});
};
const useDefaultizedTimeField = (props) => {
const utils = useUtils();
const ampm = props.ampm ?? utils.is12HourCycleInCurrentLocale();
const defaultFormat = ampm ? utils.formats.fullTime12h : utils.formats.fullTime24h;
return _extends$1({}, props, {
disablePast: props.disablePast ?? false,
disableFuture: props.disableFuture ?? false,
format: props.format ?? defaultFormat
});
};
const useDateField = (inProps) => {
const props = useDefaultizedDateField(inProps);
const { forwardedProps, internalProps } = useSplitFieldProps(props, "date");
return useField({
forwardedProps,
internalProps,
valueManager: singleItemValueManager,
fieldValueManager: singleItemFieldValueManager,
validator: validateDate,
valueType: "date"
});
};
function getPickersTextFieldUtilityClass(slot) {
return generateUtilityClass("MuiPickersTextField", slot);
}
generateUtilityClasses("MuiPickersTextField", [
"root",
"focused",
"disabled",
"error",
"required"
]);
function getPickersInputBaseUtilityClass(slot) {
return generateUtilityClass("MuiPickersInputBase", slot);
}
const pickersInputBaseClasses = generateUtilityClasses("MuiPickersInputBase", [
"root",
"focused",
"disabled",
"error",
"notchedOutline",
"sectionContent",
"sectionBefore",
"sectionAfter",
"adornedStart",
"adornedEnd",
"input"
]);
function getPickersSectionListUtilityClass(slot) {
return generateUtilityClass("MuiPickersSectionList", slot);
}
const pickersSectionListClasses = generateUtilityClasses("MuiPickersSectionList", [
"root",
"section",
"sectionContent"
]);
const _excluded$u = [
"slots",
"slotProps",
"elements",
"sectionListRef"
];
const PickersSectionListRoot = styled("div", {
name: "MuiPickersSectionList",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
direction: "ltr /*! @noflip */",
outline: "none"
});
const PickersSectionListSection = styled("span", {
name: "MuiPickersSectionList",
slot: "Section",
overridesResolver: (props, styles2) => styles2.section
})({});
const PickersSectionListSectionSeparator = styled("span", {
name: "MuiPickersSectionList",
slot: "SectionSeparator",
overridesResolver: (props, styles2) => styles2.sectionSeparator
})({
whiteSpace: "pre"
});
const PickersSectionListSectionContent = styled("span", {
name: "MuiPickersSectionList",
slot: "SectionContent",
overridesResolver: (props, styles2) => styles2.sectionContent
})({
outline: "none"
});
const useUtilityClasses$m = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
section: [
"section"
],
sectionContent: [
"sectionContent"
]
};
return composeClasses(slots, getPickersSectionListUtilityClass, classes);
};
function PickersSection(props) {
const { slots, slotProps, element, classes } = props;
const Section = (slots == null ? void 0 : slots.section) ?? PickersSectionListSection;
const sectionProps = useSlotProps({
elementType: Section,
externalSlotProps: slotProps == null ? void 0 : slotProps.section,
externalForwardedProps: element.container,
className: classes.section,
ownerState: {}
});
const SectionContent = (slots == null ? void 0 : slots.sectionContent) ?? PickersSectionListSectionContent;
const sectionContentProps = useSlotProps({
elementType: SectionContent,
externalSlotProps: slotProps == null ? void 0 : slotProps.sectionContent,
externalForwardedProps: element.content,
additionalProps: {
suppressContentEditableWarning: true
},
className: classes.sectionContent,
ownerState: {}
});
const SectionSeparator = (slots == null ? void 0 : slots.sectionSeparator) ?? PickersSectionListSectionSeparator;
const sectionSeparatorBeforeProps = useSlotProps({
elementType: SectionSeparator,
externalSlotProps: slotProps == null ? void 0 : slotProps.sectionSeparator,
externalForwardedProps: element.before,
ownerState: {
position: "before"
}
});
const sectionSeparatorAfterProps = useSlotProps({
elementType: SectionSeparator,
externalSlotProps: slotProps == null ? void 0 : slotProps.sectionSeparator,
externalForwardedProps: element.after,
ownerState: {
position: "after"
}
});
return jsxRuntimeExports.jsxs(Section, _extends$1({}, sectionProps, {
children: [
jsxRuntimeExports.jsx(SectionSeparator, _extends$1({}, sectionSeparatorBeforeProps)),
jsxRuntimeExports.jsx(SectionContent, _extends$1({}, sectionContentProps)),
jsxRuntimeExports.jsx(SectionSeparator, _extends$1({}, sectionSeparatorAfterProps))
]
}));
}
const PickersSectionList = __mf_14(function PickersSectionList2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersSectionList"
});
const { slots, slotProps, elements, sectionListRef } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$u);
const classes = useUtilityClasses$m(props);
const rootRef = __mf_31(null);
const handleRootRef = useForkRef(ref, rootRef);
const getRoot = (methodName) => {
if (!rootRef.current) {
throw new Error(`MUI X: Cannot call sectionListRef.${methodName} before the mount of the component.`);
}
return rootRef.current;
};
__mf_26(sectionListRef, () => ({
getRoot() {
return getRoot("getRoot");
},
getSectionContainer(index) {
const root = getRoot("getSectionContainer");
return root.querySelector(`.${pickersSectionListClasses.section}[data-sectionindex="${index}"]`);
},
getSectionContent(index) {
const root = getRoot("getSectionContent");
return root.querySelector(`.${pickersSectionListClasses.section}[data-sectionindex="${index}"] .${pickersSectionListClasses.sectionContent}`);
},
getSectionIndexFromDOMElement(element) {
const root = getRoot("getSectionIndexFromDOMElement");
if (element == null || !root.contains(element)) {
return null;
}
let sectionContainer = null;
if (element.classList.contains(pickersSectionListClasses.section)) {
sectionContainer = element;
} else if (element.classList.contains(pickersSectionListClasses.sectionContent)) {
sectionContainer = element.parentElement;
}
if (sectionContainer == null) {
return null;
}
return Number(sectionContainer.dataset.sectionindex);
}
}));
const Root = (slots == null ? void 0 : slots.root) ?? PickersSectionListRoot;
const rootProps = useSlotProps({
elementType: Root,
externalSlotProps: slotProps == null ? void 0 : slotProps.root,
externalForwardedProps: other,
additionalProps: {
ref: handleRootRef,
suppressContentEditableWarning: true
},
className: classes.root,
ownerState: {}
});
return jsxRuntimeExports.jsx(Root, _extends$1({}, rootProps, {
children: rootProps.contentEditable ? elements.map(({ content, before, after }) => `${before.children}${content.children}${after.children}`).join("") : jsxRuntimeExports.jsx(__mf_2, {
children: elements.map((element, elementIndex) => jsxRuntimeExports.jsx(PickersSection, {
slots,
slotProps,
element,
classes
}, elementIndex))
})
}));
});
const _excluded$t = [
"elements",
"areAllSectionsEmpty",
"defaultValue",
"label",
"value",
"onChange",
"id",
"autoFocus",
"endAdornment",
"startAdornment",
"renderSuffix",
"slots",
"slotProps",
"contentEditable",
"tabIndex",
"onInput",
"onPaste",
"onKeyDown",
"fullWidth",
"name",
"readOnly",
"inputProps",
"inputRef",
"sectionListRef"
];
const round = (value) => Math.round(value * 1e5) / 1e5;
const PickersInputBaseRoot = styled("div", {
name: "MuiPickersInputBase",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})(({ theme }) => _extends$1({}, theme.typography.body1, {
color: (theme.vars || theme).palette.text.primary,
cursor: "text",
padding: 0,
display: "flex",
justifyContent: "flex-start",
alignItems: "center",
position: "relative",
boxSizing: "border-box",
letterSpacing: `${round(0.15 / 16)}em`,
variants: [
{
props: {
fullWidth: true
},
style: {
width: "100%"
}
}
]
}));
const PickersInputBaseSectionsContainer = styled(PickersSectionListRoot, {
name: "MuiPickersInputBase",
slot: "SectionsContainer",
overridesResolver: (props, styles2) => styles2.sectionsContainer
})(({ theme }) => ({
padding: "4px 0 5px",
fontFamily: theme.typography.fontFamily,
fontSize: "inherit",
lineHeight: "1.4375em",
flexGrow: 1,
outline: "none",
display: "flex",
flexWrap: "nowrap",
overflow: "hidden",
letterSpacing: "inherit",
width: "182px",
variants: [
{
props: {
isRtl: true
},
style: {
textAlign: "right /*! @noflip */"
}
},
{
props: {
size: "small"
},
style: {
paddingTop: 1
}
},
{
props: {
adornedStart: false,
focused: false,
filled: false
},
style: {
color: "currentColor",
opacity: 0
}
},
{
props: ({ adornedStart, focused, filled, label }) => !adornedStart && !focused && !filled && label == null,
style: theme.vars ? {
opacity: theme.vars.opacity.inputPlaceholder
} : {
opacity: theme.palette.mode === "light" ? 0.42 : 0.5
}
}
]
}));
const PickersInputBaseSection = styled(PickersSectionListSection, {
name: "MuiPickersInputBase",
slot: "Section",
overridesResolver: (props, styles2) => styles2.section
})(({ theme }) => ({
fontFamily: theme.typography.fontFamily,
fontSize: "inherit",
letterSpacing: "inherit",
lineHeight: "1.4375em",
display: "inline-block",
whiteSpace: "nowrap"
}));
const PickersInputBaseSectionContent = styled(PickersSectionListSectionContent, {
name: "MuiPickersInputBase",
slot: "SectionContent",
overridesResolver: (props, styles2) => styles2.content
})(({ theme }) => ({
fontFamily: theme.typography.fontFamily,
lineHeight: "1.4375em",
letterSpacing: "inherit",
width: "fit-content",
outline: "none"
}));
const PickersInputBaseSectionSeparator = styled(PickersSectionListSectionSeparator, {
name: "MuiPickersInputBase",
slot: "Separator",
overridesResolver: (props, styles2) => styles2.separator
})(() => ({
whiteSpace: "pre",
letterSpacing: "inherit"
}));
const PickersInputBaseInput = styled("input", {
name: "MuiPickersInputBase",
slot: "Input",
overridesResolver: (props, styles2) => styles2.hiddenInput
})(_extends$1({}, visuallyHidden$1));
const useUtilityClasses$l = (ownerState) => {
const { focused, disabled, error, classes, fullWidth, readOnly, color, size, endAdornment, startAdornment } = ownerState;
const slots = {
root: [
"root",
focused && !disabled && "focused",
disabled && "disabled",
readOnly && "readOnly",
error && "error",
fullWidth && "fullWidth",
`color${capitalize(color)}`,
size === "small" && "inputSizeSmall",
Boolean(startAdornment) && "adornedStart",
Boolean(endAdornment) && "adornedEnd"
],
notchedOutline: [
"notchedOutline"
],
input: [
"input"
],
sectionsContainer: [
"sectionsContainer"
],
sectionContent: [
"sectionContent"
],
sectionBefore: [
"sectionBefore"
],
sectionAfter: [
"sectionAfter"
]
};
return composeClasses(slots, getPickersInputBaseUtilityClass, classes);
};
const PickersInputBase = __mf_14(function PickersInputBase2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersInputBase"
});
const { elements, areAllSectionsEmpty, value, onChange, id, endAdornment, startAdornment, renderSuffix, slots, slotProps, contentEditable, tabIndex, onInput, onPaste, onKeyDown, name, readOnly, inputProps, inputRef, sectionListRef } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$t);
const rootRef = __mf_31(null);
const handleRootRef = useForkRef(ref, rootRef);
const handleInputRef = useForkRef(inputProps == null ? void 0 : inputProps.ref, inputRef);
const isRtl = useRtl();
const muiFormControl = useFormControl();
if (!muiFormControl) {
throw new Error("MUI X: PickersInputBase should always be used inside a PickersTextField component");
}
const handleInputFocus = (event) => {
var _a;
if (muiFormControl.disabled) {
event.stopPropagation();
return;
}
(_a = muiFormControl.onFocus) == null ? void 0 : _a.call(muiFormControl, event);
};
__mf_24(() => {
if (muiFormControl) {
muiFormControl.setAdornedStart(Boolean(startAdornment));
}
}, [
muiFormControl,
startAdornment
]);
__mf_24(() => {
if (!muiFormControl) {
return;
}
if (areAllSectionsEmpty) {
muiFormControl.onEmpty();
} else {
muiFormControl.onFilled();
}
}, [
muiFormControl,
areAllSectionsEmpty
]);
const ownerState = _extends$1({}, props, muiFormControl, {
isRtl
});
const classes = useUtilityClasses$l(ownerState);
const InputRoot = (slots == null ? void 0 : slots.root) || PickersInputBaseRoot;
const inputRootProps = useSlotProps({
elementType: InputRoot,
externalSlotProps: slotProps == null ? void 0 : slotProps.root,
externalForwardedProps: other,
additionalProps: {
"aria-invalid": muiFormControl.error,
ref: handleRootRef
},
className: classes.root,
ownerState
});
const InputSectionsContainer = (slots == null ? void 0 : slots.input) || PickersInputBaseSectionsContainer;
return jsxRuntimeExports.jsxs(InputRoot, _extends$1({}, inputRootProps, {
children: [
startAdornment,
jsxRuntimeExports.jsx(PickersSectionList, {
sectionListRef,
elements,
contentEditable,
tabIndex,
className: classes.sectionsContainer,
onFocus: handleInputFocus,
onBlur: muiFormControl.onBlur,
onInput,
onPaste,
onKeyDown,
slots: {
root: InputSectionsContainer,
section: PickersInputBaseSection,
sectionContent: PickersInputBaseSectionContent,
sectionSeparator: PickersInputBaseSectionSeparator
},
slotProps: {
root: {
ownerState
},
sectionContent: {
className: pickersInputBaseClasses.sectionContent
},
sectionSeparator: ({ position: position2 }) => ({
className: position2 === "before" ? pickersInputBaseClasses.sectionBefore : pickersInputBaseClasses.sectionAfter
})
}
}),
endAdornment,
renderSuffix ? renderSuffix(_extends$1({}, muiFormControl)) : null,
jsxRuntimeExports.jsx(PickersInputBaseInput, _extends$1({
name,
className: classes.input,
value,
onChange,
id,
"aria-hidden": "true",
tabIndex: -1,
readOnly,
required: muiFormControl.required,
disabled: muiFormControl.disabled
}, inputProps, {
ref: handleInputRef
}))
]
}));
});
function getPickersOutlinedInputUtilityClass(slot) {
return generateUtilityClass("MuiPickersOutlinedInput", slot);
}
const pickersOutlinedInputClasses = _extends$1({}, pickersInputBaseClasses, generateUtilityClasses("MuiPickersOutlinedInput", [
"root",
"notchedOutline",
"input"
]));
const _excluded$s = [
"children",
"className",
"label",
"notched",
"shrink"
];
const OutlineRoot = styled("fieldset", {
name: "MuiPickersOutlinedInput",
slot: "NotchedOutline",
overridesResolver: (props, styles2) => styles2.notchedOutline
})(({ theme }) => {
const borderColor = theme.palette.mode === "light" ? "rgba(0, 0, 0, 0.23)" : "rgba(255, 255, 255, 0.23)";
return {
textAlign: "left",
position: "absolute",
bottom: 0,
right: 0,
top: -5,
left: 0,
margin: 0,
padding: "0 8px",
pointerEvents: "none",
borderRadius: "inherit",
borderStyle: "solid",
borderWidth: 1,
overflow: "hidden",
minWidth: "0%",
borderColor: theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.23)` : borderColor
};
});
const OutlineLabel = styled("span")(({ theme }) => ({
fontFamily: theme.typography.fontFamily,
fontSize: "inherit"
}));
const OutlineLegend = styled("legend")(({ theme }) => ({
float: "unset",
width: "auto",
overflow: "hidden",
variants: [
{
props: {
withLabel: false
},
style: {
padding: 0,
lineHeight: "11px",
transition: theme.transitions.create("width", {
duration: 150,
easing: theme.transitions.easing.easeOut
})
}
},
{
props: {
withLabel: true
},
style: {
display: "block",
padding: 0,
height: 11,
fontSize: "0.75em",
visibility: "hidden",
maxWidth: 0.01,
transition: theme.transitions.create("max-width", {
duration: 50,
easing: theme.transitions.easing.easeOut
}),
whiteSpace: "nowrap",
"& > span": {
paddingLeft: 5,
paddingRight: 5,
display: "inline-block",
opacity: 0,
visibility: "visible"
}
}
},
{
props: {
withLabel: true,
notched: true
},
style: {
maxWidth: "100%",
transition: theme.transitions.create("max-width", {
duration: 100,
easing: theme.transitions.easing.easeOut,
delay: 50
})
}
}
]
}));
function Outline(props) {
const { className, label } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$s);
const withLabel = label != null && label !== "";
const ownerState = _extends$1({}, props, {
withLabel
});
return jsxRuntimeExports.jsx(OutlineRoot, _extends$1({
"aria-hidden": true,
className
}, other, {
ownerState,
children: jsxRuntimeExports.jsx(OutlineLegend, {
ownerState,
children: withLabel ? jsxRuntimeExports.jsx(OutlineLabel, {
children: label
}) : jsxRuntimeExports.jsx(OutlineLabel, {
className: "notranslate",
children: "\u200B"
})
})
}));
}
const _excluded$r = [
"label",
"autoFocus",
"ownerState",
"notched"
];
const PickersOutlinedInputRoot = styled(PickersInputBaseRoot, {
name: "MuiPickersOutlinedInput",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})(({ theme }) => {
const borderColor = theme.palette.mode === "light" ? "rgba(0, 0, 0, 0.23)" : "rgba(255, 255, 255, 0.23)";
return {
padding: "0 14px",
borderRadius: (theme.vars || theme).shape.borderRadius,
[`&:hover .${pickersOutlinedInputClasses.notchedOutline}`]: {
borderColor: (theme.vars || theme).palette.text.primary
},
"@media (hover: none)": {
[`&:hover .${pickersOutlinedInputClasses.notchedOutline}`]: {
borderColor: theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.23)` : borderColor
}
},
[`&.${pickersOutlinedInputClasses.focused} .${pickersOutlinedInputClasses.notchedOutline}`]: {
borderStyle: "solid",
borderWidth: 2
},
[`&.${pickersOutlinedInputClasses.disabled}`]: {
[`& .${pickersOutlinedInputClasses.notchedOutline}`]: {
borderColor: (theme.vars || theme).palette.action.disabled
},
"*": {
color: (theme.vars || theme).palette.action.disabled
}
},
[`&.${pickersOutlinedInputClasses.error} .${pickersOutlinedInputClasses.notchedOutline}`]: {
borderColor: (theme.vars || theme).palette.error.main
},
variants: Object.keys((theme.vars ?? theme).palette).filter((key) => {
var _a;
return ((_a = (theme.vars ?? theme).palette[key]) == null ? void 0 : _a.main) ?? false;
}).map((color) => ({
props: {
color
},
style: {
[`&.${pickersOutlinedInputClasses.focused}:not(.${pickersOutlinedInputClasses.error}) .${pickersOutlinedInputClasses.notchedOutline}`]: {
borderColor: (theme.vars || theme).palette[color].main
}
}
}))
};
});
const PickersOutlinedInputSectionsContainer = styled(PickersInputBaseSectionsContainer, {
name: "MuiPickersOutlinedInput",
slot: "SectionsContainer",
overridesResolver: (props, styles2) => styles2.sectionsContainer
})({
padding: "16.5px 0",
variants: [
{
props: {
size: "small"
},
style: {
padding: "8.5px 0"
}
}
]
});
const useUtilityClasses$k = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
notchedOutline: [
"notchedOutline"
],
input: [
"input"
]
};
const composedClasses = composeClasses(slots, getPickersOutlinedInputUtilityClass, classes);
return _extends$1({}, classes, composedClasses);
};
const PickersOutlinedInput = __mf_14(function PickersOutlinedInput2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersOutlinedInput"
});
const { label, ownerState: ownerStateProp, notched } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$r);
const muiFormControl = useFormControl();
const ownerState = _extends$1({}, props, ownerStateProp, muiFormControl, {
color: (muiFormControl == null ? void 0 : muiFormControl.color) || "primary"
});
const classes = useUtilityClasses$k(ownerState);
return jsxRuntimeExports.jsx(PickersInputBase, _extends$1({
slots: {
root: PickersOutlinedInputRoot,
input: PickersOutlinedInputSectionsContainer
},
renderSuffix: (state) => jsxRuntimeExports.jsx(Outline, {
shrink: Boolean(notched || state.adornedStart || state.focused || state.filled),
notched: Boolean(notched || state.adornedStart || state.focused || state.filled),
className: classes.notchedOutline,
label: label != null && label !== "" && (muiFormControl == null ? void 0 : muiFormControl.required) ? jsxRuntimeExports.jsxs(__mf_2, {
children: [
label,
"\u2009",
"*"
]
}) : label,
ownerState
})
}, other, {
label,
classes,
ref
}));
});
PickersOutlinedInput.muiName = "Input";
function getPickersFilledInputUtilityClass(slot) {
return generateUtilityClass("MuiPickersFilledInput", slot);
}
const pickersFilledInputClasses = _extends$1({}, pickersInputBaseClasses, generateUtilityClasses("MuiPickersFilledInput", [
"root",
"underline",
"input"
]));
const _excluded$q = [
"label",
"autoFocus",
"disableUnderline",
"ownerState"
];
const PickersFilledInputRoot = styled(PickersInputBaseRoot, {
name: "MuiPickersFilledInput",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root,
shouldForwardProp: (prop) => __mf_131(prop) && prop !== "disableUnderline"
})(({ theme }) => {
const light = theme.palette.mode === "light";
const bottomLineColor = light ? "rgba(0, 0, 0, 0.42)" : "rgba(255, 255, 255, 0.7)";
const backgroundColor = light ? "rgba(0, 0, 0, 0.06)" : "rgba(255, 255, 255, 0.09)";
const hoverBackground = light ? "rgba(0, 0, 0, 0.09)" : "rgba(255, 255, 255, 0.13)";
const disabledBackground = light ? "rgba(0, 0, 0, 0.12)" : "rgba(255, 255, 255, 0.12)";
return {
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.bg : backgroundColor,
borderTopLeftRadius: (theme.vars || theme).shape.borderRadius,
borderTopRightRadius: (theme.vars || theme).shape.borderRadius,
transition: theme.transitions.create("background-color", {
duration: theme.transitions.duration.shorter,
easing: theme.transitions.easing.easeOut
}),
"&:hover": {
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.hoverBg : hoverBackground,
"@media (hover: none)": {
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.bg : backgroundColor
}
},
[`&.${pickersFilledInputClasses.focused}`]: {
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.bg : backgroundColor
},
[`&.${pickersFilledInputClasses.disabled}`]: {
backgroundColor: theme.vars ? theme.vars.palette.FilledInput.disabledBg : disabledBackground
},
variants: [
...Object.keys((theme.vars ?? theme).palette).filter((key) => (theme.vars ?? theme).palette[key].main).map((color) => {
var _a;
return {
props: {
color,
disableUnderline: false
},
style: {
"&::after": {
borderBottom: `2px solid ${(_a = (theme.vars || theme).palette[color]) == null ? void 0 : _a.main}`
}
}
};
}),
{
props: {
disableUnderline: false
},
style: {
"&::after": {
left: 0,
bottom: 0,
content: '""',
position: "absolute",
right: 0,
transform: "scaleX(0)",
transition: theme.transitions.create("transform", {
duration: theme.transitions.duration.shorter,
easing: theme.transitions.easing.easeOut
}),
pointerEvents: "none"
},
[`&.${pickersFilledInputClasses.focused}:after`]: {
transform: "scaleX(1) translateX(0)"
},
[`&.${pickersFilledInputClasses.error}`]: {
"&:before, &:after": {
borderBottomColor: (theme.vars || theme).palette.error.main
}
},
"&::before": {
borderBottom: `1px solid ${theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / ${theme.vars.opacity.inputUnderline})` : bottomLineColor}`,
left: 0,
bottom: 0,
content: '"\\00a0"',
position: "absolute",
right: 0,
transition: theme.transitions.create("border-bottom-color", {
duration: theme.transitions.duration.shorter
}),
pointerEvents: "none"
},
[`&:hover:not(.${pickersFilledInputClasses.disabled}, .${pickersFilledInputClasses.error}):before`]: {
borderBottom: `1px solid ${(theme.vars || theme).palette.text.primary}`
},
[`&.${pickersFilledInputClasses.disabled}:before`]: {
borderBottomStyle: "dotted"
}
}
},
{
props: ({ startAdornment }) => !!startAdornment,
style: {
paddingLeft: 12
}
},
{
props: ({ endAdornment }) => !!endAdornment,
style: {
paddingRight: 12
}
}
]
};
});
const PickersFilledSectionsContainer = styled(PickersInputBaseSectionsContainer, {
name: "MuiPickersFilledInput",
slot: "sectionsContainer",
overridesResolver: (props, styles2) => styles2.sectionsContainer
})({
paddingTop: 25,
paddingRight: 12,
paddingBottom: 8,
paddingLeft: 12,
variants: [
{
props: {
size: "small"
},
style: {
paddingTop: 21,
paddingBottom: 4
}
},
{
props: ({ startAdornment }) => !!startAdornment,
style: {
paddingLeft: 0
}
},
{
props: ({ endAdornment }) => !!endAdornment,
style: {
paddingRight: 0
}
},
{
props: {
hiddenLabel: true
},
style: {
paddingTop: 16,
paddingBottom: 17
}
},
{
props: {
hiddenLabel: true,
size: "small"
},
style: {
paddingTop: 8,
paddingBottom: 9
}
}
]
});
const useUtilityClasses$j = (ownerState) => {
const { classes, disableUnderline } = ownerState;
const slots = {
root: [
"root",
!disableUnderline && "underline"
],
input: [
"input"
]
};
const composedClasses = composeClasses(slots, getPickersFilledInputUtilityClass, classes);
return _extends$1({}, classes, composedClasses);
};
const PickersFilledInput = __mf_14(function PickersFilledInput2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersFilledInput"
});
const { label, disableUnderline = false, ownerState: ownerStateProp } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$q);
const muiFormControl = useFormControl();
const ownerState = _extends$1({}, props, ownerStateProp, muiFormControl, {
color: (muiFormControl == null ? void 0 : muiFormControl.color) || "primary"
});
const classes = useUtilityClasses$j(ownerState);
return jsxRuntimeExports.jsx(PickersInputBase, _extends$1({
slots: {
root: PickersFilledInputRoot,
input: PickersFilledSectionsContainer
},
slotProps: {
root: {
disableUnderline
}
}
}, other, {
label,
classes,
ref
}));
});
PickersFilledInput.muiName = "Input";
function getPickersInputUtilityClass(slot) {
return generateUtilityClass("MuiPickersFilledInput", slot);
}
const pickersInputClasses = _extends$1({}, pickersInputBaseClasses, generateUtilityClasses("MuiPickersInput", [
"root",
"input"
]));
const _excluded$p = [
"label",
"autoFocus",
"disableUnderline",
"ownerState"
];
const PickersInputRoot = styled(PickersInputBaseRoot, {
name: "MuiPickersInput",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})(({ theme }) => {
const light = theme.palette.mode === "light";
let bottomLineColor = light ? "rgba(0, 0, 0, 0.42)" : "rgba(255, 255, 255, 0.7)";
if (theme.vars) {
bottomLineColor = `rgba(${theme.vars.palette.common.onBackgroundChannel} / ${theme.vars.opacity.inputUnderline})`;
}
return {
"label + &": {
marginTop: 16
},
variants: [
...Object.keys((theme.vars ?? theme).palette).filter((key) => (theme.vars ?? theme).palette[key].main).map((color) => ({
props: {
color
},
style: {
"&::after": {
borderBottom: `2px solid ${(theme.vars || theme).palette[color].main}`
}
}
})),
{
props: {
disableUnderline: false
},
style: {
"&::after": {
background: "red",
left: 0,
bottom: 0,
content: '""',
position: "absolute",
right: 0,
transform: "scaleX(0)",
transition: theme.transitions.create("transform", {
duration: theme.transitions.duration.shorter,
easing: theme.transitions.easing.easeOut
}),
pointerEvents: "none"
},
[`&.${pickersInputClasses.focused}:after`]: {
transform: "scaleX(1) translateX(0)"
},
[`&.${pickersInputClasses.error}`]: {
"&:before, &:after": {
borderBottomColor: (theme.vars || theme).palette.error.main
}
},
"&::before": {
borderBottom: `1px solid ${bottomLineColor}`,
left: 0,
bottom: 0,
content: '"\\00a0"',
position: "absolute",
right: 0,
transition: theme.transitions.create("border-bottom-color", {
duration: theme.transitions.duration.shorter
}),
pointerEvents: "none"
},
[`&:hover:not(.${pickersInputClasses.disabled}, .${pickersInputClasses.error}):before`]: {
borderBottom: `2px solid ${(theme.vars || theme).palette.text.primary}`,
"@media (hover: none)": {
borderBottom: `1px solid ${bottomLineColor}`
}
},
[`&.${pickersInputClasses.disabled}:before`]: {
borderBottomStyle: "dotted"
}
}
}
]
};
});
const useUtilityClasses$i = (ownerState) => {
const { classes, disableUnderline } = ownerState;
const slots = {
root: [
"root",
!disableUnderline && "underline"
],
input: [
"input"
]
};
const composedClasses = composeClasses(slots, getPickersInputUtilityClass, classes);
return _extends$1({}, classes, composedClasses);
};
const PickersInput = __mf_14(function PickersInput2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersInput"
});
const { label, disableUnderline = false, ownerState: ownerStateProp } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$p);
const muiFormControl = useFormControl();
const ownerState = _extends$1({}, props, ownerStateProp, muiFormControl, {
disableUnderline,
color: (muiFormControl == null ? void 0 : muiFormControl.color) || "primary"
});
const classes = useUtilityClasses$i(ownerState);
return jsxRuntimeExports.jsx(PickersInputBase, _extends$1({
slots: {
root: PickersInputRoot
}
}, other, {
label,
classes,
ref
}));
});
PickersInput.muiName = "Input";
const _excluded$o = [
"onFocus",
"onBlur",
"className",
"color",
"disabled",
"error",
"variant",
"required",
"InputProps",
"inputProps",
"inputRef",
"sectionListRef",
"elements",
"areAllSectionsEmpty",
"onClick",
"onKeyDown",
"onKeyUp",
"onPaste",
"onInput",
"endAdornment",
"startAdornment",
"tabIndex",
"contentEditable",
"focused",
"value",
"onChange",
"fullWidth",
"id",
"name",
"helperText",
"FormHelperTextProps",
"label",
"InputLabelProps"
];
const VARIANT_COMPONENT = {
standard: PickersInput,
filled: PickersFilledInput,
outlined: PickersOutlinedInput
};
const PickersTextFieldRoot = styled(FormControl, {
name: "MuiPickersTextField",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
maxWidth: "100%"
});
const useUtilityClasses$h = (ownerState) => {
const { focused, disabled, classes, required } = ownerState;
const slots = {
root: [
"root",
focused && !disabled && "focused",
disabled && "disabled",
required && "required"
]
};
return composeClasses(slots, getPickersTextFieldUtilityClass, classes);
};
const PickersTextField = __mf_14(function PickersTextField2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersTextField"
});
const { onFocus, onBlur, className, color = "primary", disabled = false, error = false, variant = "outlined", required = false, InputProps, inputProps, inputRef, sectionListRef, elements, areAllSectionsEmpty, onClick, onKeyDown, onKeyUp, onPaste, onInput, endAdornment, startAdornment, tabIndex, contentEditable, focused, value, onChange, fullWidth, id: idProp, name, helperText, FormHelperTextProps, label, InputLabelProps } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$o);
const rootRef = __mf_31(null);
const handleRootRef = useForkRef(ref, rootRef);
const id = useId(idProp);
const helperTextId = helperText && id ? `${id}-helper-text` : void 0;
const inputLabelId = label && id ? `${id}-label` : void 0;
const ownerState = _extends$1({}, props, {
color,
disabled,
error,
focused,
required,
variant
});
const classes = useUtilityClasses$h(ownerState);
const PickersInputComponent = VARIANT_COMPONENT[variant];
return jsxRuntimeExports.jsxs(PickersTextFieldRoot, _extends$1({
className: clsx(classes.root, className),
ref: handleRootRef,
focused,
onFocus,
onBlur,
disabled,
variant,
error,
color,
fullWidth,
required,
ownerState
}, other, {
children: [
jsxRuntimeExports.jsx(InputLabel, _extends$1({
htmlFor: id,
id: inputLabelId
}, InputLabelProps, {
children: label
})),
jsxRuntimeExports.jsx(PickersInputComponent, _extends$1({
elements,
areAllSectionsEmpty,
onClick,
onKeyDown,
onKeyUp,
onInput,
onPaste,
endAdornment,
startAdornment,
tabIndex,
contentEditable,
value,
onChange,
id,
fullWidth,
inputProps,
inputRef,
sectionListRef,
label,
name,
role: "group",
"aria-labelledby": inputLabelId,
"aria-describedby": helperTextId,
"aria-live": helperTextId ? "polite" : void 0
}, InputProps)),
helperText && jsxRuntimeExports.jsx(FormHelperText, _extends$1({
id: helperTextId
}, FormHelperTextProps, {
children: helperText
}))
]
}));
});
const _excluded$n = [
"enableAccessibleFieldDOMStructure"
], _excluded2$4 = [
"InputProps",
"readOnly"
], _excluded3$1 = [
"onPaste",
"onKeyDown",
"inputMode",
"readOnly",
"InputProps",
"inputProps",
"inputRef"
];
const convertFieldResponseIntoMuiTextFieldProps = (_ref) => {
let { enableAccessibleFieldDOMStructure } = _ref, fieldResponse = _objectWithoutPropertiesLoose$3(_ref, _excluded$n);
if (enableAccessibleFieldDOMStructure) {
const { InputProps: InputProps2, readOnly: readOnly2 } = fieldResponse, other2 = _objectWithoutPropertiesLoose$3(fieldResponse, _excluded2$4);
return _extends$1({}, other2, {
InputProps: _extends$1({}, InputProps2 ?? {}, {
readOnly: readOnly2
})
});
}
const { onPaste, onKeyDown, inputMode, readOnly, InputProps, inputProps, inputRef } = fieldResponse, other = _objectWithoutPropertiesLoose$3(fieldResponse, _excluded3$1);
return _extends$1({}, other, {
InputProps: _extends$1({}, InputProps ?? {}, {
readOnly
}),
inputProps: _extends$1({}, inputProps ?? {}, {
inputMode,
onPaste,
onKeyDown,
ref: inputRef
})
});
};
const _excluded$m = [
"slots",
"slotProps",
"InputProps",
"inputProps"
];
const DateField = __mf_14(function DateField2(inProps, inRef) {
const themeProps = useThemeProps({
props: inProps,
name: "MuiDateField"
});
const { slots, slotProps, InputProps, inputProps } = themeProps, other = _objectWithoutPropertiesLoose$3(themeProps, _excluded$m);
const ownerState = themeProps;
const TextField$1 = (slots == null ? void 0 : slots.textField) ?? (inProps.enableAccessibleFieldDOMStructure ? PickersTextField : TextField);
const textFieldProps = useSlotProps({
elementType: TextField$1,
externalSlotProps: slotProps == null ? void 0 : slotProps.textField,
externalForwardedProps: other,
additionalProps: {
ref: inRef
},
ownerState
});
textFieldProps.inputProps = _extends$1({}, inputProps, textFieldProps.inputProps);
textFieldProps.InputProps = _extends$1({}, InputProps, textFieldProps.InputProps);
const fieldResponse = useDateField(textFieldProps);
const convertedFieldResponse = convertFieldResponseIntoMuiTextFieldProps(fieldResponse);
const processedFieldProps = useClearableField(_extends$1({}, convertedFieldResponse, {
slots,
slotProps
}));
return jsxRuntimeExports.jsx(TextField$1, _extends$1({}, processedFieldProps));
});
const useTimeField = (inProps) => {
const props = useDefaultizedTimeField(inProps);
const { forwardedProps, internalProps } = useSplitFieldProps(props, "time");
return useField({
forwardedProps,
internalProps,
valueManager: singleItemValueManager,
fieldValueManager: singleItemFieldValueManager,
validator: validateTime,
valueType: "time"
});
};
const _excluded$l = [
"slots",
"slotProps",
"InputProps",
"inputProps"
];
const TimeField = __mf_14(function TimeField2(inProps, inRef) {
const themeProps = useThemeProps({
props: inProps,
name: "MuiTimeField"
});
const { slots, slotProps, InputProps, inputProps } = themeProps, other = _objectWithoutPropertiesLoose$3(themeProps, _excluded$l);
const ownerState = themeProps;
const TextField$1 = (slots == null ? void 0 : slots.textField) ?? (inProps.enableAccessibleFieldDOMStructure ? PickersTextField : TextField);
const textFieldProps = useSlotProps({
elementType: TextField$1,
externalSlotProps: slotProps == null ? void 0 : slotProps.textField,
externalForwardedProps: other,
ownerState,
additionalProps: {
ref: inRef
}
});
textFieldProps.inputProps = _extends$1({}, inputProps, textFieldProps.inputProps);
textFieldProps.InputProps = _extends$1({}, InputProps, textFieldProps.InputProps);
const fieldResponse = useTimeField(textFieldProps);
const convertedFieldResponse = convertFieldResponseIntoMuiTextFieldProps(fieldResponse);
const processedFieldProps = useClearableField(_extends$1({}, convertedFieldResponse, {
slots,
slotProps
}));
return jsxRuntimeExports.jsx(TextField$1, _extends$1({}, processedFieldProps));
});
const useIsDateDisabled = ({ shouldDisableDate, shouldDisableMonth, shouldDisableYear, minDate, maxDate, disableFuture, disablePast, timezone }) => {
const adapter = useLocalizationContext();
return __mf_20((day) => validateDate({
adapter,
value: day,
timezone,
props: {
shouldDisableDate,
shouldDisableMonth,
shouldDisableYear,
minDate,
maxDate,
disableFuture,
disablePast
}
}) !== null, [
adapter,
shouldDisableDate,
shouldDisableMonth,
shouldDisableYear,
minDate,
maxDate,
disableFuture,
disablePast,
timezone
]);
};
const createCalendarStateReducer = (reduceAnimations, disableSwitchToMonthOnDayFocus, utils) => (state, action) => {
switch (action.type) {
case "changeMonth":
return _extends$1({}, state, {
slideDirection: action.direction,
currentMonth: action.newMonth,
isMonthSwitchingAnimating: !reduceAnimations
});
case "changeMonthTimezone": {
const newTimezone = action.newTimezone;
if (utils.getTimezone(state.currentMonth) === newTimezone) {
return state;
}
let newCurrentMonth = utils.setTimezone(state.currentMonth, newTimezone);
if (utils.getMonth(newCurrentMonth) !== utils.getMonth(state.currentMonth)) {
newCurrentMonth = utils.setMonth(newCurrentMonth, utils.getMonth(state.currentMonth));
}
return _extends$1({}, state, {
currentMonth: newCurrentMonth
});
}
case "finishMonthSwitchingAnimation":
return _extends$1({}, state, {
isMonthSwitchingAnimating: false
});
case "changeFocusedDay": {
if (state.focusedDay != null && action.focusedDay != null && utils.isSameDay(action.focusedDay, state.focusedDay)) {
return state;
}
const needMonthSwitch = action.focusedDay != null && !disableSwitchToMonthOnDayFocus && !utils.isSameMonth(state.currentMonth, action.focusedDay);
return _extends$1({}, state, {
focusedDay: action.focusedDay,
isMonthSwitchingAnimating: needMonthSwitch && !reduceAnimations && !action.withoutMonthSwitchingAnimation,
currentMonth: needMonthSwitch ? utils.startOfMonth(action.focusedDay) : state.currentMonth,
slideDirection: action.focusedDay != null && utils.isAfterDay(action.focusedDay, state.currentMonth) ? "left" : "right"
});
}
default:
throw new Error("missing support");
}
};
const useCalendarState = (params) => {
const { value, referenceDate: referenceDateProp, disableFuture, disablePast, disableSwitchToMonthOnDayFocus = false, maxDate, minDate, onMonthChange, reduceAnimations, shouldDisableDate, timezone } = params;
const utils = useUtils();
const reducerFn = __mf_31(createCalendarStateReducer(Boolean(reduceAnimations), disableSwitchToMonthOnDayFocus, utils)).current;
const referenceDate = __mf_29(() => {
return singleItemValueManager.getInitialReferenceValue({
value,
utils,
timezone,
props: params,
referenceDate: referenceDateProp,
granularity: SECTION_TYPE_GRANULARITY.day
});
}, [
referenceDateProp,
timezone
]);
const [calendarState, dispatch] = __mf_30(reducerFn, {
isMonthSwitchingAnimating: false,
focusedDay: referenceDate,
currentMonth: utils.startOfMonth(referenceDate),
slideDirection: "left"
});
__mf_24(() => {
dispatch({
type: "changeMonthTimezone",
newTimezone: utils.getTimezone(referenceDate)
});
}, [
referenceDate,
utils
]);
const handleChangeMonth = __mf_20((payload) => {
dispatch(_extends$1({
type: "changeMonth"
}, payload));
if (onMonthChange) {
onMonthChange(payload.newMonth);
}
}, [
onMonthChange
]);
const changeMonth = __mf_20((newDate) => {
const newDateRequested = newDate;
if (utils.isSameMonth(newDateRequested, calendarState.currentMonth)) {
return;
}
handleChangeMonth({
newMonth: utils.startOfMonth(newDateRequested),
direction: utils.isAfterDay(newDateRequested, calendarState.currentMonth) ? "left" : "right"
});
}, [
calendarState.currentMonth,
handleChangeMonth,
utils
]);
const isDateDisabled = useIsDateDisabled({
shouldDisableDate,
minDate,
maxDate,
disableFuture,
disablePast,
timezone
});
const onMonthSwitchingAnimationEnd = __mf_20(() => {
dispatch({
type: "finishMonthSwitchingAnimation"
});
}, []);
const changeFocusedDay = useEventCallback((newFocusedDate, withoutMonthSwitchingAnimation) => {
if (!isDateDisabled(newFocusedDate)) {
dispatch({
type: "changeFocusedDay",
focusedDay: newFocusedDate,
withoutMonthSwitchingAnimation
});
}
});
return {
referenceDate,
calendarState,
changeMonth,
changeFocusedDay,
isDateDisabled,
onMonthSwitchingAnimationEnd,
handleChangeMonth
};
};
const getPickersFadeTransitionGroupUtilityClass = (slot) => generateUtilityClass("MuiPickersFadeTransitionGroup", slot);
generateUtilityClasses("MuiPickersFadeTransitionGroup", [
"root"
]);
const useUtilityClasses$g = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
]
};
return composeClasses(slots, getPickersFadeTransitionGroupUtilityClass, classes);
};
const PickersFadeTransitionGroupRoot = styled(TransitionGroup, {
name: "MuiPickersFadeTransitionGroup",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})({
display: "block",
position: "relative"
});
function PickersFadeTransitionGroup(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersFadeTransitionGroup"
});
const { children, className, reduceAnimations, transKey } = props;
const classes = useUtilityClasses$g(props);
const theme = useTheme();
if (reduceAnimations) {
return children;
}
return jsxRuntimeExports.jsx(PickersFadeTransitionGroupRoot, {
className: clsx(classes.root, className),
children: jsxRuntimeExports.jsx(Fade, {
appear: false,
mountOnEnter: true,
unmountOnExit: true,
timeout: {
appear: theme.transitions.duration.enteringScreen,
enter: theme.transitions.duration.enteringScreen,
exit: 0
},
children
}, transKey)
});
}
const getPickersSlideTransitionUtilityClass = (slot) => generateUtilityClass("MuiPickersSlideTransition", slot);
const pickersSlideTransitionClasses = generateUtilityClasses("MuiPickersSlideTransition", [
"root",
"slideEnter-left",
"slideEnter-right",
"slideEnterActive",
"slideExit",
"slideExitActiveLeft-left",
"slideExitActiveLeft-right"
]);
const _excluded$k = [
"children",
"className",
"reduceAnimations",
"slideDirection",
"transKey",
"classes"
];
const useUtilityClasses$f = (ownerState) => {
const { classes, slideDirection } = ownerState;
const slots = {
root: [
"root"
],
exit: [
"slideExit"
],
enterActive: [
"slideEnterActive"
],
enter: [
`slideEnter-${slideDirection}`
],
exitActive: [
`slideExitActiveLeft-${slideDirection}`
]
};
return composeClasses(slots, getPickersSlideTransitionUtilityClass, classes);
};
const PickersSlideTransitionRoot = styled(TransitionGroup, {
name: "MuiPickersSlideTransition",
slot: "Root",
overridesResolver: (_, styles2) => [
styles2.root,
{
[`.${pickersSlideTransitionClasses["slideEnter-left"]}`]: styles2["slideEnter-left"]
},
{
[`.${pickersSlideTransitionClasses["slideEnter-right"]}`]: styles2["slideEnter-right"]
},
{
[`.${pickersSlideTransitionClasses.slideEnterActive}`]: styles2.slideEnterActive
},
{
[`.${pickersSlideTransitionClasses.slideExit}`]: styles2.slideExit
},
{
[`.${pickersSlideTransitionClasses["slideExitActiveLeft-left"]}`]: styles2["slideExitActiveLeft-left"]
},
{
[`.${pickersSlideTransitionClasses["slideExitActiveLeft-right"]}`]: styles2["slideExitActiveLeft-right"]
}
]
})(({ theme }) => {
const slideTransition = theme.transitions.create("transform", {
duration: theme.transitions.duration.complex,
easing: "cubic-bezier(0.35, 0.8, 0.4, 1)"
});
return {
display: "block",
position: "relative",
overflowX: "hidden",
"& > *": {
position: "absolute",
top: 0,
right: 0,
left: 0
},
[`& .${pickersSlideTransitionClasses["slideEnter-left"]}`]: {
willChange: "transform",
transform: "translate(100%)",
zIndex: 1
},
[`& .${pickersSlideTransitionClasses["slideEnter-right"]}`]: {
willChange: "transform",
transform: "translate(-100%)",
zIndex: 1
},
[`& .${pickersSlideTransitionClasses.slideEnterActive}`]: {
transform: "translate(0%)",
transition: slideTransition
},
[`& .${pickersSlideTransitionClasses.slideExit}`]: {
transform: "translate(0%)"
},
[`& .${pickersSlideTransitionClasses["slideExitActiveLeft-left"]}`]: {
willChange: "transform",
transform: "translate(-100%)",
transition: slideTransition,
zIndex: 0
},
[`& .${pickersSlideTransitionClasses["slideExitActiveLeft-right"]}`]: {
willChange: "transform",
transform: "translate(100%)",
transition: slideTransition,
zIndex: 0
}
};
});
function PickersSlideTransition(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersSlideTransition"
});
const { children, className, reduceAnimations, transKey } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$k);
const classes = useUtilityClasses$f(props);
const theme = useTheme();
if (reduceAnimations) {
return jsxRuntimeExports.jsx("div", {
className: clsx(classes.root, className),
children
});
}
const transitionClasses = {
exit: classes.exit,
enterActive: classes.enterActive,
enter: classes.enter,
exitActive: classes.exitActive
};
return jsxRuntimeExports.jsx(PickersSlideTransitionRoot, {
className: clsx(classes.root, className),
childFactory: (element) => __mf_9(element, {
classNames: transitionClasses
}),
role: "presentation",
children: jsxRuntimeExports.jsx(CSSTransition, _extends$1({
mountOnEnter: true,
unmountOnExit: true,
timeout: theme.transitions.duration.complex,
classNames: transitionClasses
}, other, {
children
}), transKey)
});
}
const getDayCalendarUtilityClass = (slot) => generateUtilityClass("MuiDayCalendar", slot);
generateUtilityClasses("MuiDayCalendar", [
"root",
"header",
"weekDayLabel",
"loadingContainer",
"slideTransition",
"monthContainer",
"weekContainer",
"weekNumberLabel",
"weekNumber"
]);
const _excluded$j = [
"parentProps",
"day",
"focusableDay",
"selectedDays",
"isDateDisabled",
"currentMonthNumber",
"isViewFocused"
], _excluded2$3 = [
"ownerState"
];
const useUtilityClasses$e = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
header: [
"header"
],
weekDayLabel: [
"weekDayLabel"
],
loadingContainer: [
"loadingContainer"
],
slideTransition: [
"slideTransition"
],
monthContainer: [
"monthContainer"
],
weekContainer: [
"weekContainer"
],
weekNumberLabel: [
"weekNumberLabel"
],
weekNumber: [
"weekNumber"
]
};
return composeClasses(slots, getDayCalendarUtilityClass, classes);
};
const weeksContainerHeight = (DAY_SIZE + DAY_MARGIN * 2) * 6;
const PickersCalendarDayRoot = styled("div", {
name: "MuiDayCalendar",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})({});
const PickersCalendarDayHeader = styled("div", {
name: "MuiDayCalendar",
slot: "Header",
overridesResolver: (_, styles2) => styles2.header
})({
display: "flex",
justifyContent: "center",
alignItems: "center"
});
const PickersCalendarWeekDayLabel = styled(Typography, {
name: "MuiDayCalendar",
slot: "WeekDayLabel",
overridesResolver: (_, styles2) => styles2.weekDayLabel
})(({ theme }) => ({
width: 36,
height: 40,
margin: "0 2px",
textAlign: "center",
display: "flex",
justifyContent: "center",
alignItems: "center",
color: (theme.vars || theme).palette.text.secondary
}));
const PickersCalendarWeekNumberLabel = styled(Typography, {
name: "MuiDayCalendar",
slot: "WeekNumberLabel",
overridesResolver: (_, styles2) => styles2.weekNumberLabel
})(({ theme }) => ({
width: 36,
height: 40,
margin: "0 2px",
textAlign: "center",
display: "flex",
justifyContent: "center",
alignItems: "center",
color: theme.palette.text.disabled
}));
const PickersCalendarWeekNumber = styled(Typography, {
name: "MuiDayCalendar",
slot: "WeekNumber",
overridesResolver: (_, styles2) => styles2.weekNumber
})(({ theme }) => _extends$1({}, theme.typography.caption, {
width: DAY_SIZE,
height: DAY_SIZE,
padding: 0,
margin: `0 ${DAY_MARGIN}px`,
color: theme.palette.text.disabled,
fontSize: "0.75rem",
alignItems: "center",
justifyContent: "center",
display: "inline-flex"
}));
const PickersCalendarLoadingContainer = styled("div", {
name: "MuiDayCalendar",
slot: "LoadingContainer",
overridesResolver: (_, styles2) => styles2.loadingContainer
})({
display: "flex",
justifyContent: "center",
alignItems: "center",
minHeight: weeksContainerHeight
});
const PickersCalendarSlideTransition = styled(PickersSlideTransition, {
name: "MuiDayCalendar",
slot: "SlideTransition",
overridesResolver: (_, styles2) => styles2.slideTransition
})({
minHeight: weeksContainerHeight
});
const PickersCalendarWeekContainer = styled("div", {
name: "MuiDayCalendar",
slot: "MonthContainer",
overridesResolver: (_, styles2) => styles2.monthContainer
})({
overflow: "hidden"
});
const PickersCalendarWeek = styled("div", {
name: "MuiDayCalendar",
slot: "WeekContainer",
overridesResolver: (_, styles2) => styles2.weekContainer
})({
margin: `${DAY_MARGIN}px 0`,
display: "flex",
justifyContent: "center"
});
function WrappedDay(_ref) {
let { parentProps, day, focusableDay, selectedDays, isDateDisabled, currentMonthNumber, isViewFocused } = _ref, other = _objectWithoutPropertiesLoose$3(_ref, _excluded$j);
const { disabled, disableHighlightToday, isMonthSwitchingAnimating, showDaysOutsideCurrentMonth, slots, slotProps, timezone } = parentProps;
const utils = useUtils();
const now = useNow(timezone);
const isFocusableDay = focusableDay !== null && utils.isSameDay(day, focusableDay);
const isSelected = selectedDays.some((selectedDay) => utils.isSameDay(selectedDay, day));
const isToday = utils.isSameDay(day, now);
const Day = (slots == null ? void 0 : slots.day) ?? PickersDay;
const _useSlotProps = useSlotProps({
elementType: Day,
externalSlotProps: slotProps == null ? void 0 : slotProps.day,
additionalProps: _extends$1({
disableHighlightToday,
showDaysOutsideCurrentMonth,
role: "gridcell",
isAnimating: isMonthSwitchingAnimating,
"data-timestamp": utils.toJsDate(day).valueOf()
}, other),
ownerState: _extends$1({}, parentProps, {
day,
selected: isSelected
})
}), dayProps = _objectWithoutPropertiesLoose$3(_useSlotProps, _excluded2$3);
const isDisabled = __mf_29(() => disabled || isDateDisabled(day), [
disabled,
isDateDisabled,
day
]);
const outsideCurrentMonth = __mf_29(() => utils.getMonth(day) !== currentMonthNumber, [
utils,
day,
currentMonthNumber
]);
const isFirstVisibleCell = __mf_29(() => {
const startOfMonth = utils.startOfMonth(utils.setMonth(day, currentMonthNumber));
if (!showDaysOutsideCurrentMonth) {
return utils.isSameDay(day, startOfMonth);
}
return utils.isSameDay(day, utils.startOfWeek(startOfMonth));
}, [
currentMonthNumber,
day,
showDaysOutsideCurrentMonth,
utils
]);
const isLastVisibleCell = __mf_29(() => {
const endOfMonth = utils.endOfMonth(utils.setMonth(day, currentMonthNumber));
if (!showDaysOutsideCurrentMonth) {
return utils.isSameDay(day, endOfMonth);
}
return utils.isSameDay(day, utils.endOfWeek(endOfMonth));
}, [
currentMonthNumber,
day,
showDaysOutsideCurrentMonth,
utils
]);
return jsxRuntimeExports.jsx(Day, _extends$1({}, dayProps, {
day,
disabled: isDisabled,
autoFocus: isViewFocused && isFocusableDay,
today: isToday,
outsideCurrentMonth,
isFirstVisibleCell,
isLastVisibleCell,
selected: isSelected,
tabIndex: isFocusableDay ? 0 : -1,
"aria-selected": isSelected,
"aria-current": isToday ? "date" : void 0
}));
}
function DayCalendar(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiDayCalendar"
});
const utils = useUtils();
const { onFocusedDayChange, className, currentMonth, selectedDays, focusedDay, loading, onSelectedDaysChange, onMonthSwitchingAnimationEnd, readOnly, reduceAnimations, renderLoading = () => jsxRuntimeExports.jsx("span", {
children: "..."
}), slideDirection, TransitionProps, disablePast, disableFuture, minDate, maxDate, shouldDisableDate, shouldDisableMonth, shouldDisableYear, dayOfWeekFormatter = (date) => utils.format(date, "weekdayShort").charAt(0).toUpperCase(), hasFocus, onFocusedViewChange, gridLabelId, displayWeekNumber, fixedWeekNumber, autoFocus, timezone } = props;
const now = useNow(timezone);
const classes = useUtilityClasses$e(props);
const isRtl = useRtl();
const isDateDisabled = useIsDateDisabled({
shouldDisableDate,
shouldDisableMonth,
shouldDisableYear,
minDate,
maxDate,
disablePast,
disableFuture,
timezone
});
const translations = usePickersTranslations();
const [internalHasFocus, setInternalHasFocus] = useControlled({
name: "DayCalendar",
state: "hasFocus",
controlled: hasFocus,
default: autoFocus ?? false
});
const [internalFocusedDay, setInternalFocusedDay] = __mf_32(() => focusedDay || now);
const handleDaySelect = useEventCallback((day) => {
if (readOnly) {
return;
}
onSelectedDaysChange(day);
});
const focusDay = (day) => {
if (!isDateDisabled(day)) {
onFocusedDayChange(day);
setInternalFocusedDay(day);
onFocusedViewChange == null ? void 0 : onFocusedViewChange(true);
setInternalHasFocus(true);
}
};
const handleKeyDown = useEventCallback((event, day) => {
switch (event.key) {
case "ArrowUp":
focusDay(utils.addDays(day, -7));
event.preventDefault();
break;
case "ArrowDown":
focusDay(utils.addDays(day, 7));
event.preventDefault();
break;
case "ArrowLeft": {
const newFocusedDayDefault = utils.addDays(day, isRtl ? 1 : -1);
const nextAvailableMonth = utils.addMonths(day, isRtl ? 1 : -1);
const closestDayToFocus = findClosestEnabledDate({
utils,
date: newFocusedDayDefault,
minDate: isRtl ? newFocusedDayDefault : utils.startOfMonth(nextAvailableMonth),
maxDate: isRtl ? utils.endOfMonth(nextAvailableMonth) : newFocusedDayDefault,
isDateDisabled,
timezone
});
focusDay(closestDayToFocus || newFocusedDayDefault);
event.preventDefault();
break;
}
case "ArrowRight": {
const newFocusedDayDefault = utils.addDays(day, isRtl ? -1 : 1);
const nextAvailableMonth = utils.addMonths(day, isRtl ? -1 : 1);
const closestDayToFocus = findClosestEnabledDate({
utils,
date: newFocusedDayDefault,
minDate: isRtl ? utils.startOfMonth(nextAvailableMonth) : newFocusedDayDefault,
maxDate: isRtl ? newFocusedDayDefault : utils.endOfMonth(nextAvailableMonth),
isDateDisabled,
timezone
});
focusDay(closestDayToFocus || newFocusedDayDefault);
event.preventDefault();
break;
}
case "Home":
focusDay(utils.startOfWeek(day));
event.preventDefault();
break;
case "End":
focusDay(utils.endOfWeek(day));
event.preventDefault();
break;
case "PageUp":
focusDay(utils.addMonths(day, 1));
event.preventDefault();
break;
case "PageDown":
focusDay(utils.addMonths(day, -1));
event.preventDefault();
break;
}
});
const handleFocus = useEventCallback((event, day) => focusDay(day));
const handleBlur = useEventCallback((event, day) => {
if (internalHasFocus && utils.isSameDay(internalFocusedDay, day)) {
onFocusedViewChange == null ? void 0 : onFocusedViewChange(false);
}
});
const currentMonthNumber = utils.getMonth(currentMonth);
const currentYearNumber = utils.getYear(currentMonth);
const validSelectedDays = __mf_29(() => selectedDays.filter((day) => !!day).map((day) => utils.startOfDay(day)), [
utils,
selectedDays
]);
const transitionKey = `${currentYearNumber}-${currentMonthNumber}`;
const slideNodeRef = __mf_29(() => __mf_13(), [
transitionKey
]);
const focusableDay = __mf_29(() => {
const startOfMonth = utils.startOfMonth(currentMonth);
const endOfMonth = utils.endOfMonth(currentMonth);
if (isDateDisabled(internalFocusedDay) || utils.isAfterDay(internalFocusedDay, endOfMonth) || utils.isBeforeDay(internalFocusedDay, startOfMonth)) {
return findClosestEnabledDate({
utils,
date: internalFocusedDay,
minDate: startOfMonth,
maxDate: endOfMonth,
disablePast,
disableFuture,
isDateDisabled,
timezone
});
}
return internalFocusedDay;
}, [
currentMonth,
disableFuture,
disablePast,
internalFocusedDay,
isDateDisabled,
utils,
timezone
]);
const weeksToDisplay = __mf_29(() => {
const toDisplay = utils.getWeekArray(currentMonth);
let nextMonth = utils.addMonths(currentMonth, 1);
while (fixedWeekNumber && toDisplay.length < fixedWeekNumber) {
const additionalWeeks = utils.getWeekArray(nextMonth);
const hasCommonWeek = utils.isSameDay(toDisplay[toDisplay.length - 1][0], additionalWeeks[0][0]);
additionalWeeks.slice(hasCommonWeek ? 1 : 0).forEach((week) => {
if (toDisplay.length < fixedWeekNumber) {
toDisplay.push(week);
}
});
nextMonth = utils.addMonths(nextMonth, 1);
}
return toDisplay;
}, [
currentMonth,
fixedWeekNumber,
utils
]);
return jsxRuntimeExports.jsxs(PickersCalendarDayRoot, {
role: "grid",
"aria-labelledby": gridLabelId,
className: classes.root,
children: [
jsxRuntimeExports.jsxs(PickersCalendarDayHeader, {
role: "row",
className: classes.header,
children: [
displayWeekNumber && jsxRuntimeExports.jsx(PickersCalendarWeekNumberLabel, {
variant: "caption",
role: "columnheader",
"aria-label": translations.calendarWeekNumberHeaderLabel,
className: classes.weekNumberLabel,
children: translations.calendarWeekNumberHeaderText
}),
getWeekdays(utils, now).map((weekday, i) => jsxRuntimeExports.jsx(PickersCalendarWeekDayLabel, {
variant: "caption",
role: "columnheader",
"aria-label": utils.format(weekday, "weekday"),
className: classes.weekDayLabel,
children: dayOfWeekFormatter(weekday)
}, i.toString()))
]
}),
loading ? jsxRuntimeExports.jsx(PickersCalendarLoadingContainer, {
className: classes.loadingContainer,
children: renderLoading()
}) : jsxRuntimeExports.jsx(PickersCalendarSlideTransition, _extends$1({
transKey: transitionKey,
onExited: onMonthSwitchingAnimationEnd,
reduceAnimations,
slideDirection,
className: clsx(className, classes.slideTransition)
}, TransitionProps, {
nodeRef: slideNodeRef,
children: jsxRuntimeExports.jsx(PickersCalendarWeekContainer, {
ref: slideNodeRef,
role: "rowgroup",
className: classes.monthContainer,
children: weeksToDisplay.map((week, index) => jsxRuntimeExports.jsxs(PickersCalendarWeek, {
role: "row",
className: classes.weekContainer,
"aria-rowindex": index + 1,
children: [
displayWeekNumber && jsxRuntimeExports.jsx(PickersCalendarWeekNumber, {
className: classes.weekNumber,
role: "rowheader",
"aria-label": translations.calendarWeekNumberAriaLabelText(utils.getWeekNumber(week[0])),
children: translations.calendarWeekNumberText(utils.getWeekNumber(week[0]))
}),
week.map((day, dayIndex) => jsxRuntimeExports.jsx(WrappedDay, {
parentProps: props,
day,
selectedDays: validSelectedDays,
focusableDay,
onKeyDown: handleKeyDown,
onFocus: handleFocus,
onBlur: handleBlur,
onDaySelect: handleDaySelect,
isDateDisabled,
currentMonthNumber,
isViewFocused: internalHasFocus,
"aria-colindex": dayIndex + 1
}, day.toString()))
]
}, `week-${week[0]}`))
})
}))
]
});
}
function getPickersMonthUtilityClass(slot) {
return generateUtilityClass("MuiPickersMonth", slot);
}
const pickersMonthClasses = generateUtilityClasses("MuiPickersMonth", [
"root",
"monthButton",
"disabled",
"selected"
]);
const _excluded$i = [
"autoFocus",
"className",
"children",
"disabled",
"selected",
"value",
"tabIndex",
"onClick",
"onKeyDown",
"onFocus",
"onBlur",
"aria-current",
"aria-label",
"monthsPerRow",
"slots",
"slotProps"
];
const useUtilityClasses$d = (ownerState) => {
const { disabled, selected, classes } = ownerState;
const slots = {
root: [
"root"
],
monthButton: [
"monthButton",
disabled && "disabled",
selected && "selected"
]
};
return composeClasses(slots, getPickersMonthUtilityClass, classes);
};
const PickersMonthRoot = styled("div", {
name: "MuiPickersMonth",
slot: "Root",
overridesResolver: (_, styles2) => [
styles2.root
]
})({
display: "flex",
alignItems: "center",
justifyContent: "center",
flexBasis: "33.3%",
variants: [
{
props: {
monthsPerRow: 4
},
style: {
flexBasis: "25%"
}
}
]
});
const MonthCalendarButton = styled("button", {
name: "MuiPickersMonth",
slot: "MonthButton",
overridesResolver: (_, styles2) => [
styles2.monthButton,
{
[`&.${pickersMonthClasses.disabled}`]: styles2.disabled
},
{
[`&.${pickersMonthClasses.selected}`]: styles2.selected
}
]
})(({ theme }) => _extends$1({
color: "unset",
backgroundColor: "transparent",
border: 0,
outline: 0
}, theme.typography.subtitle1, {
margin: "8px 0",
height: 36,
width: 72,
borderRadius: 18,
cursor: "pointer",
"&:focus": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.hoverOpacity})` : __mf_133(theme.palette.action.active, theme.palette.action.hoverOpacity)
},
"&:hover": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.hoverOpacity})` : __mf_133(theme.palette.action.active, theme.palette.action.hoverOpacity)
},
"&:disabled": {
cursor: "auto",
pointerEvents: "none"
},
[`&.${pickersMonthClasses.disabled}`]: {
color: (theme.vars || theme).palette.text.secondary
},
[`&.${pickersMonthClasses.selected}`]: {
color: (theme.vars || theme).palette.primary.contrastText,
backgroundColor: (theme.vars || theme).palette.primary.main,
"&:focus, &:hover": {
backgroundColor: (theme.vars || theme).palette.primary.dark
}
}
}));
const PickersMonth = __mf_17(function PickersMonth2(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersMonth"
});
const { autoFocus, className, children, disabled, selected, value, tabIndex, onClick, onKeyDown, onFocus, onBlur, "aria-current": ariaCurrent, "aria-label": ariaLabel, slots, slotProps } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$i);
const ref = __mf_31(null);
const classes = useUtilityClasses$d(props);
useEnhancedEffect(() => {
var _a;
if (autoFocus) {
(_a = ref.current) == null ? void 0 : _a.focus();
}
}, [
autoFocus
]);
const MonthButton = (slots == null ? void 0 : slots.monthButton) ?? MonthCalendarButton;
const monthButtonProps = useSlotProps({
elementType: MonthButton,
externalSlotProps: slotProps == null ? void 0 : slotProps.monthButton,
additionalProps: {
children,
disabled,
tabIndex,
ref,
type: "button",
role: "radio",
"aria-current": ariaCurrent,
"aria-checked": selected,
"aria-label": ariaLabel,
onClick: (event) => onClick(event, value),
onKeyDown: (event) => onKeyDown(event, value),
onFocus: (event) => onFocus(event, value),
onBlur: (event) => onBlur(event, value)
},
ownerState: props,
className: classes.monthButton
});
return jsxRuntimeExports.jsx(PickersMonthRoot, _extends$1({
className: clsx(classes.root, className),
ownerState: props
}, other, {
children: jsxRuntimeExports.jsx(MonthButton, _extends$1({}, monthButtonProps))
}));
});
function getMonthCalendarUtilityClass(slot) {
return generateUtilityClass("MuiMonthCalendar", slot);
}
generateUtilityClasses("MuiMonthCalendar", [
"root"
]);
const _excluded$h = [
"className",
"value",
"defaultValue",
"referenceDate",
"disabled",
"disableFuture",
"disablePast",
"maxDate",
"minDate",
"onChange",
"shouldDisableMonth",
"readOnly",
"disableHighlightToday",
"autoFocus",
"onMonthFocus",
"hasFocus",
"onFocusedViewChange",
"monthsPerRow",
"timezone",
"gridLabelId",
"slots",
"slotProps"
];
const useUtilityClasses$c = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
]
};
return composeClasses(slots, getMonthCalendarUtilityClass, classes);
};
function useMonthCalendarDefaultizedProps(props, name) {
const utils = useUtils();
const defaultDates = useDefaultDates();
const themeProps = useThemeProps({
props,
name
});
return _extends$1({
disableFuture: false,
disablePast: false
}, themeProps, {
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate)
});
}
const MonthCalendarRoot = styled("div", {
name: "MuiMonthCalendar",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
display: "flex",
flexWrap: "wrap",
alignContent: "stretch",
padding: "0 4px",
width: DIALOG_WIDTH,
boxSizing: "border-box"
});
const MonthCalendar = __mf_14(function MonthCalendar2(inProps, ref) {
const props = useMonthCalendarDefaultizedProps(inProps, "MuiMonthCalendar");
const { className, value: valueProp, defaultValue, referenceDate: referenceDateProp, disabled, disableFuture, disablePast, maxDate, minDate, onChange, shouldDisableMonth, readOnly, autoFocus = false, onMonthFocus, hasFocus, onFocusedViewChange, monthsPerRow = 3, timezone: timezoneProp, gridLabelId, slots, slotProps } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$h);
const { value, handleValueChange, timezone } = useControlledValueWithTimezone({
name: "MonthCalendar",
timezone: timezoneProp,
value: valueProp,
defaultValue,
referenceDate: referenceDateProp,
onChange,
valueManager: singleItemValueManager
});
const now = useNow(timezone);
const isRtl = useRtl();
const utils = useUtils();
const referenceDate = __mf_29(() => singleItemValueManager.getInitialReferenceValue({
value,
utils,
props,
timezone,
referenceDate: referenceDateProp,
granularity: SECTION_TYPE_GRANULARITY.month
}), []);
const ownerState = props;
const classes = useUtilityClasses$c(ownerState);
const todayMonth = __mf_29(() => utils.getMonth(now), [
utils,
now
]);
const selectedMonth = __mf_29(() => {
if (value != null) {
return utils.getMonth(value);
}
return null;
}, [
value,
utils
]);
const [focusedMonth, setFocusedMonth] = __mf_32(() => selectedMonth || utils.getMonth(referenceDate));
const [internalHasFocus, setInternalHasFocus] = useControlled({
name: "MonthCalendar",
state: "hasFocus",
controlled: hasFocus,
default: autoFocus ?? false
});
const changeHasFocus = useEventCallback((newHasFocus) => {
setInternalHasFocus(newHasFocus);
if (onFocusedViewChange) {
onFocusedViewChange(newHasFocus);
}
});
const isMonthDisabled = __mf_20((dateToValidate) => {
const firstEnabledMonth = utils.startOfMonth(disablePast && utils.isAfter(now, minDate) ? now : minDate);
const lastEnabledMonth = utils.startOfMonth(disableFuture && utils.isBefore(now, maxDate) ? now : maxDate);
const monthToValidate = utils.startOfMonth(dateToValidate);
if (utils.isBefore(monthToValidate, firstEnabledMonth)) {
return true;
}
if (utils.isAfter(monthToValidate, lastEnabledMonth)) {
return true;
}
if (!shouldDisableMonth) {
return false;
}
return shouldDisableMonth(monthToValidate);
}, [
disableFuture,
disablePast,
maxDate,
minDate,
now,
shouldDisableMonth,
utils
]);
const handleMonthSelection = useEventCallback((event, month) => {
if (readOnly) {
return;
}
const newDate = utils.setMonth(value ?? referenceDate, month);
handleValueChange(newDate);
});
const focusMonth = useEventCallback((month) => {
if (!isMonthDisabled(utils.setMonth(value ?? referenceDate, month))) {
setFocusedMonth(month);
changeHasFocus(true);
if (onMonthFocus) {
onMonthFocus(month);
}
}
});
__mf_24(() => {
setFocusedMonth((prevFocusedMonth) => selectedMonth !== null && prevFocusedMonth !== selectedMonth ? selectedMonth : prevFocusedMonth);
}, [
selectedMonth
]);
const handleKeyDown = useEventCallback((event, month) => {
const monthsInYear = 12;
const monthsInRow = 3;
switch (event.key) {
case "ArrowUp":
focusMonth((monthsInYear + month - monthsInRow) % monthsInYear);
event.preventDefault();
break;
case "ArrowDown":
focusMonth((monthsInYear + month + monthsInRow) % monthsInYear);
event.preventDefault();
break;
case "ArrowLeft":
focusMonth((monthsInYear + month + (isRtl ? 1 : -1)) % monthsInYear);
event.preventDefault();
break;
case "ArrowRight":
focusMonth((monthsInYear + month + (isRtl ? -1 : 1)) % monthsInYear);
event.preventDefault();
break;
}
});
const handleMonthFocus = useEventCallback((event, month) => {
focusMonth(month);
});
const handleMonthBlur = useEventCallback((event, month) => {
if (focusedMonth === month) {
changeHasFocus(false);
}
});
return jsxRuntimeExports.jsx(MonthCalendarRoot, _extends$1({
ref,
className: clsx(classes.root, className),
ownerState,
role: "radiogroup",
"aria-labelledby": gridLabelId
}, other, {
children: getMonthsInYear(utils, value ?? referenceDate).map((month) => {
const monthNumber = utils.getMonth(month);
const monthText = utils.format(month, "monthShort");
const monthLabel = utils.format(month, "month");
const isSelected = monthNumber === selectedMonth;
const isDisabled = disabled || isMonthDisabled(month);
return jsxRuntimeExports.jsx(PickersMonth, {
selected: isSelected,
value: monthNumber,
onClick: handleMonthSelection,
onKeyDown: handleKeyDown,
autoFocus: internalHasFocus && monthNumber === focusedMonth,
disabled: isDisabled,
tabIndex: monthNumber === focusedMonth && !isDisabled ? 0 : -1,
onFocus: handleMonthFocus,
onBlur: handleMonthBlur,
"aria-current": todayMonth === monthNumber ? "date" : void 0,
"aria-label": monthLabel,
monthsPerRow,
slots,
slotProps,
children: monthText
}, monthText);
})
}));
});
function getPickersYearUtilityClass(slot) {
return generateUtilityClass("MuiPickersYear", slot);
}
const pickersYearClasses = generateUtilityClasses("MuiPickersYear", [
"root",
"yearButton",
"selected",
"disabled"
]);
const _excluded$g = [
"autoFocus",
"className",
"children",
"disabled",
"selected",
"value",
"tabIndex",
"onClick",
"onKeyDown",
"onFocus",
"onBlur",
"aria-current",
"yearsPerRow",
"slots",
"slotProps"
];
const useUtilityClasses$b = (ownerState) => {
const { disabled, selected, classes } = ownerState;
const slots = {
root: [
"root"
],
yearButton: [
"yearButton",
disabled && "disabled",
selected && "selected"
]
};
return composeClasses(slots, getPickersYearUtilityClass, classes);
};
const PickersYearRoot = styled("div", {
name: "MuiPickersYear",
slot: "Root",
overridesResolver: (_, styles2) => [
styles2.root
]
})({
display: "flex",
alignItems: "center",
justifyContent: "center",
flexBasis: "33.3%",
variants: [
{
props: {
yearsPerRow: 4
},
style: {
flexBasis: "25%"
}
}
]
});
const YearCalendarButton = styled("button", {
name: "MuiPickersYear",
slot: "YearButton",
overridesResolver: (_, styles2) => [
styles2.yearButton,
{
[`&.${pickersYearClasses.disabled}`]: styles2.disabled
},
{
[`&.${pickersYearClasses.selected}`]: styles2.selected
}
]
})(({ theme }) => _extends$1({
color: "unset",
backgroundColor: "transparent",
border: 0,
outline: 0
}, theme.typography.subtitle1, {
margin: "6px 0",
height: 36,
width: 72,
borderRadius: 18,
cursor: "pointer",
"&:focus": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.focusOpacity})` : __mf_133(theme.palette.action.active, theme.palette.action.focusOpacity)
},
"&:hover": {
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.hoverOpacity})` : __mf_133(theme.palette.action.active, theme.palette.action.hoverOpacity)
},
"&:disabled": {
cursor: "auto",
pointerEvents: "none"
},
[`&.${pickersYearClasses.disabled}`]: {
color: (theme.vars || theme).palette.text.secondary
},
[`&.${pickersYearClasses.selected}`]: {
color: (theme.vars || theme).palette.primary.contrastText,
backgroundColor: (theme.vars || theme).palette.primary.main,
"&:focus, &:hover": {
backgroundColor: (theme.vars || theme).palette.primary.dark
}
}
}));
const PickersYear = __mf_17(function PickersYear2(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersYear"
});
const { autoFocus, className, children, disabled, selected, value, tabIndex, onClick, onKeyDown, onFocus, onBlur, "aria-current": ariaCurrent, slots, slotProps } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$g);
const ref = __mf_31(null);
const classes = useUtilityClasses$b(props);
useEnhancedEffect(() => {
var _a;
if (autoFocus) {
(_a = ref.current) == null ? void 0 : _a.focus();
}
}, [
autoFocus
]);
const YearButton = (slots == null ? void 0 : slots.yearButton) ?? YearCalendarButton;
const yearButtonProps = useSlotProps({
elementType: YearButton,
externalSlotProps: slotProps == null ? void 0 : slotProps.yearButton,
additionalProps: {
children,
disabled,
tabIndex,
ref,
type: "button",
role: "radio",
"aria-current": ariaCurrent,
"aria-checked": selected,
onClick: (event) => onClick(event, value),
onKeyDown: (event) => onKeyDown(event, value),
onFocus: (event) => onFocus(event, value),
onBlur: (event) => onBlur(event, value)
},
ownerState: props,
className: classes.yearButton
});
return jsxRuntimeExports.jsx(PickersYearRoot, _extends$1({
className: clsx(classes.root, className),
ownerState: props
}, other, {
children: jsxRuntimeExports.jsx(YearButton, _extends$1({}, yearButtonProps))
}));
});
function getYearCalendarUtilityClass(slot) {
return generateUtilityClass("MuiYearCalendar", slot);
}
generateUtilityClasses("MuiYearCalendar", [
"root"
]);
const _excluded$f = [
"autoFocus",
"className",
"value",
"defaultValue",
"referenceDate",
"disabled",
"disableFuture",
"disablePast",
"maxDate",
"minDate",
"onChange",
"readOnly",
"shouldDisableYear",
"disableHighlightToday",
"onYearFocus",
"hasFocus",
"onFocusedViewChange",
"yearsOrder",
"yearsPerRow",
"timezone",
"gridLabelId",
"slots",
"slotProps"
];
const useUtilityClasses$a = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
]
};
return composeClasses(slots, getYearCalendarUtilityClass, classes);
};
function useYearCalendarDefaultizedProps(props, name) {
const utils = useUtils();
const defaultDates = useDefaultDates();
const themeProps = useThemeProps({
props,
name
});
return _extends$1({
disablePast: false,
disableFuture: false
}, themeProps, {
yearsPerRow: themeProps.yearsPerRow ?? 3,
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate)
});
}
const YearCalendarRoot = styled("div", {
name: "MuiYearCalendar",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
display: "flex",
flexDirection: "row",
flexWrap: "wrap",
overflowY: "auto",
height: "100%",
padding: "0 4px",
width: DIALOG_WIDTH,
maxHeight: MAX_CALENDAR_HEIGHT,
boxSizing: "border-box",
position: "relative"
});
const YearCalendar = __mf_14(function YearCalendar2(inProps, ref) {
const props = useYearCalendarDefaultizedProps(inProps, "MuiYearCalendar");
const { autoFocus, className, value: valueProp, defaultValue, referenceDate: referenceDateProp, disabled, disableFuture, disablePast, maxDate, minDate, onChange, readOnly, shouldDisableYear, onYearFocus, hasFocus, onFocusedViewChange, yearsOrder = "asc", yearsPerRow, timezone: timezoneProp, gridLabelId, slots, slotProps } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$f);
const { value, handleValueChange, timezone } = useControlledValueWithTimezone({
name: "YearCalendar",
timezone: timezoneProp,
value: valueProp,
defaultValue,
referenceDate: referenceDateProp,
onChange,
valueManager: singleItemValueManager
});
const now = useNow(timezone);
const isRtl = useRtl();
const utils = useUtils();
const referenceDate = __mf_29(() => singleItemValueManager.getInitialReferenceValue({
value,
utils,
props,
timezone,
referenceDate: referenceDateProp,
granularity: SECTION_TYPE_GRANULARITY.year
}), []);
const ownerState = props;
const classes = useUtilityClasses$a(ownerState);
const todayYear = __mf_29(() => utils.getYear(now), [
utils,
now
]);
const selectedYear = __mf_29(() => {
if (value != null) {
return utils.getYear(value);
}
return null;
}, [
value,
utils
]);
const [focusedYear, setFocusedYear] = __mf_32(() => selectedYear || utils.getYear(referenceDate));
const [internalHasFocus, setInternalHasFocus] = useControlled({
name: "YearCalendar",
state: "hasFocus",
controlled: hasFocus,
default: autoFocus ?? false
});
const changeHasFocus = useEventCallback((newHasFocus) => {
setInternalHasFocus(newHasFocus);
if (onFocusedViewChange) {
onFocusedViewChange(newHasFocus);
}
});
const isYearDisabled = __mf_20((dateToValidate) => {
if (disablePast && utils.isBeforeYear(dateToValidate, now)) {
return true;
}
if (disableFuture && utils.isAfterYear(dateToValidate, now)) {
return true;
}
if (minDate && utils.isBeforeYear(dateToValidate, minDate)) {
return true;
}
if (maxDate && utils.isAfterYear(dateToValidate, maxDate)) {
return true;
}
if (!shouldDisableYear) {
return false;
}
const yearToValidate = utils.startOfYear(dateToValidate);
return shouldDisableYear(yearToValidate);
}, [
disableFuture,
disablePast,
maxDate,
minDate,
now,
shouldDisableYear,
utils
]);
const handleYearSelection = useEventCallback((event, year) => {
if (readOnly) {
return;
}
const newDate = utils.setYear(value ?? referenceDate, year);
handleValueChange(newDate);
});
const focusYear = useEventCallback((year) => {
if (!isYearDisabled(utils.setYear(value ?? referenceDate, year))) {
setFocusedYear(year);
changeHasFocus(true);
onYearFocus == null ? void 0 : onYearFocus(year);
}
});
__mf_24(() => {
setFocusedYear((prevFocusedYear) => selectedYear !== null && prevFocusedYear !== selectedYear ? selectedYear : prevFocusedYear);
}, [
selectedYear
]);
const verticalDirection = yearsOrder !== "desc" ? yearsPerRow * 1 : yearsPerRow * -1;
const horizontalDirection = isRtl && yearsOrder === "asc" || !isRtl && yearsOrder === "desc" ? -1 : 1;
const handleKeyDown = useEventCallback((event, year) => {
switch (event.key) {
case "ArrowUp":
focusYear(year - verticalDirection);
event.preventDefault();
break;
case "ArrowDown":
focusYear(year + verticalDirection);
event.preventDefault();
break;
case "ArrowLeft":
focusYear(year - horizontalDirection);
event.preventDefault();
break;
case "ArrowRight":
focusYear(year + horizontalDirection);
event.preventDefault();
break;
}
});
const handleYearFocus = useEventCallback((event, year) => {
focusYear(year);
});
const handleYearBlur = useEventCallback((event, year) => {
if (focusedYear === year) {
changeHasFocus(false);
}
});
const scrollerRef = __mf_31(null);
const handleRef = useForkRef(ref, scrollerRef);
__mf_24(() => {
if (autoFocus || scrollerRef.current === null) {
return;
}
const tabbableButton = scrollerRef.current.querySelector('[tabindex="0"]');
if (!tabbableButton) {
return;
}
const offsetHeight = tabbableButton.offsetHeight;
const offsetTop = tabbableButton.offsetTop;
const clientHeight = scrollerRef.current.clientHeight;
const scrollTop = scrollerRef.current.scrollTop;
const elementBottom = offsetTop + offsetHeight;
if (offsetHeight > clientHeight || offsetTop < scrollTop) {
return;
}
scrollerRef.current.scrollTop = elementBottom - clientHeight / 2 - offsetHeight / 2;
}, [
autoFocus
]);
const yearRange = utils.getYearRange([
minDate,
maxDate
]);
if (yearsOrder === "desc") {
yearRange.reverse();
}
return jsxRuntimeExports.jsx(YearCalendarRoot, _extends$1({
ref: handleRef,
className: clsx(classes.root, className),
ownerState,
role: "radiogroup",
"aria-labelledby": gridLabelId
}, other, {
children: yearRange.map((year) => {
const yearNumber = utils.getYear(year);
const isSelected = yearNumber === selectedYear;
const isDisabled = disabled || isYearDisabled(year);
return jsxRuntimeExports.jsx(PickersYear, {
selected: isSelected,
value: yearNumber,
onClick: handleYearSelection,
onKeyDown: handleKeyDown,
autoFocus: internalHasFocus && yearNumber === focusedYear,
disabled: isDisabled,
tabIndex: yearNumber === focusedYear && !isDisabled ? 0 : -1,
onFocus: handleYearFocus,
onBlur: handleYearBlur,
"aria-current": todayYear === yearNumber ? "date" : void 0,
yearsPerRow,
slots,
slotProps,
children: utils.format(year, "year")
}, utils.format(year, "year"));
})
}));
});
const getPickersCalendarHeaderUtilityClass = (slot) => generateUtilityClass("MuiPickersCalendarHeader", slot);
const pickersCalendarHeaderClasses = generateUtilityClasses("MuiPickersCalendarHeader", [
"root",
"labelContainer",
"label",
"switchViewButton",
"switchViewIcon"
]);
const _excluded$e = [
"slots",
"slotProps",
"currentMonth",
"disabled",
"disableFuture",
"disablePast",
"maxDate",
"minDate",
"onMonthChange",
"onViewChange",
"view",
"reduceAnimations",
"views",
"labelId",
"className",
"timezone",
"format"
], _excluded2$2 = [
"ownerState"
];
const useUtilityClasses$9 = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
labelContainer: [
"labelContainer"
],
label: [
"label"
],
switchViewButton: [
"switchViewButton"
],
switchViewIcon: [
"switchViewIcon"
]
};
return composeClasses(slots, getPickersCalendarHeaderUtilityClass, classes);
};
const PickersCalendarHeaderRoot = styled("div", {
name: "MuiPickersCalendarHeader",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})({
display: "flex",
alignItems: "center",
marginTop: 12,
marginBottom: 4,
paddingLeft: 24,
paddingRight: 12,
maxHeight: 40,
minHeight: 40
});
const PickersCalendarHeaderLabelContainer = styled("div", {
name: "MuiPickersCalendarHeader",
slot: "LabelContainer",
overridesResolver: (_, styles2) => styles2.labelContainer
})(({ theme }) => _extends$1({
display: "flex",
overflow: "hidden",
alignItems: "center",
cursor: "pointer",
marginRight: "auto"
}, theme.typography.body1, {
fontWeight: theme.typography.fontWeightMedium
}));
const PickersCalendarHeaderLabel = styled("div", {
name: "MuiPickersCalendarHeader",
slot: "Label",
overridesResolver: (_, styles2) => styles2.label
})({
marginRight: 6
});
const PickersCalendarHeaderSwitchViewButton = styled(IconButton, {
name: "MuiPickersCalendarHeader",
slot: "SwitchViewButton",
overridesResolver: (_, styles2) => styles2.switchViewButton
})({
marginRight: "auto",
variants: [
{
props: {
view: "year"
},
style: {
[`.${pickersCalendarHeaderClasses.switchViewIcon}`]: {
transform: "rotate(180deg)"
}
}
}
]
});
const PickersCalendarHeaderSwitchViewIcon = styled(ArrowDropDownIcon, {
name: "MuiPickersCalendarHeader",
slot: "SwitchViewIcon",
overridesResolver: (_, styles2) => styles2.switchViewIcon
})(({ theme }) => ({
willChange: "transform",
transition: theme.transitions.create("transform"),
transform: "rotate(0deg)"
}));
const PickersCalendarHeader = __mf_14(function PickersCalendarHeader2(inProps, ref) {
const translations = usePickersTranslations();
const utils = useUtils();
const props = useThemeProps({
props: inProps,
name: "MuiPickersCalendarHeader"
});
const { slots, slotProps, currentMonth: month, disabled, disableFuture, disablePast, maxDate, minDate, onMonthChange, onViewChange, view, reduceAnimations, views, labelId, className, timezone, format = `${utils.formats.month} ${utils.formats.year}` } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$e);
const ownerState = props;
const classes = useUtilityClasses$9(props);
const SwitchViewButton = (slots == null ? void 0 : slots.switchViewButton) ?? PickersCalendarHeaderSwitchViewButton;
const switchViewButtonProps = useSlotProps({
elementType: SwitchViewButton,
externalSlotProps: slotProps == null ? void 0 : slotProps.switchViewButton,
additionalProps: {
size: "small",
"aria-label": translations.calendarViewSwitchingButtonAriaLabel(view)
},
ownerState,
className: classes.switchViewButton
});
const SwitchViewIcon = (slots == null ? void 0 : slots.switchViewIcon) ?? PickersCalendarHeaderSwitchViewIcon;
const _useSlotProps = useSlotProps({
elementType: SwitchViewIcon,
externalSlotProps: slotProps == null ? void 0 : slotProps.switchViewIcon,
ownerState,
className: classes.switchViewIcon
}), switchViewIconProps = _objectWithoutPropertiesLoose$3(_useSlotProps, _excluded2$2);
const selectNextMonth = () => onMonthChange(utils.addMonths(month, 1), "left");
const selectPreviousMonth = () => onMonthChange(utils.addMonths(month, -1), "right");
const isNextMonthDisabled = useNextMonthDisabled(month, {
disableFuture,
maxDate,
timezone
});
const isPreviousMonthDisabled = usePreviousMonthDisabled(month, {
disablePast,
minDate,
timezone
});
const handleToggleView = () => {
if (views.length === 1 || !onViewChange || disabled) {
return;
}
if (views.length === 2) {
onViewChange(views.find((el) => el !== view) || views[0]);
} else {
const nextIndexToOpen = views.indexOf(view) !== 0 ? 0 : 1;
onViewChange(views[nextIndexToOpen]);
}
};
if (views.length === 1 && views[0] === "year") {
return null;
}
const label = utils.formatByString(month, format);
return jsxRuntimeExports.jsxs(PickersCalendarHeaderRoot, _extends$1({}, other, {
ownerState,
className: clsx(classes.root, className),
ref,
children: [
jsxRuntimeExports.jsxs(PickersCalendarHeaderLabelContainer, {
role: "presentation",
onClick: handleToggleView,
ownerState,
"aria-live": "polite",
className: classes.labelContainer,
children: [
jsxRuntimeExports.jsx(PickersFadeTransitionGroup, {
reduceAnimations,
transKey: label,
children: jsxRuntimeExports.jsx(PickersCalendarHeaderLabel, {
id: labelId,
ownerState,
className: classes.label,
children: label
})
}),
views.length > 1 && !disabled && jsxRuntimeExports.jsx(SwitchViewButton, _extends$1({}, switchViewButtonProps, {
children: jsxRuntimeExports.jsx(SwitchViewIcon, _extends$1({}, switchViewIconProps))
}))
]
}),
jsxRuntimeExports.jsx(Fade, {
in: view === "day",
appear: !reduceAnimations,
enter: !reduceAnimations,
children: jsxRuntimeExports.jsx(PickersArrowSwitcher, {
slots,
slotProps,
onGoToPrevious: selectPreviousMonth,
isPreviousDisabled: isPreviousMonthDisabled,
previousLabel: translations.previousMonth,
onGoToNext: selectNextMonth,
isNextDisabled: isNextMonthDisabled,
nextLabel: translations.nextMonth
})
})
]
}));
});
const PREFERS_REDUCED_MOTION = "@media (prefers-reduced-motion: reduce)";
const mobileVersionMatches = typeof navigator !== "undefined" && navigator.userAgent.match(/android\s(\d+)|OS\s(\d+)/i);
const androidVersion = mobileVersionMatches && mobileVersionMatches[1] ? parseInt(mobileVersionMatches[1], 10) : null;
const iOSVersion = mobileVersionMatches && mobileVersionMatches[2] ? parseInt(mobileVersionMatches[2], 10) : null;
const slowAnimationDevices = androidVersion && androidVersion < 10 || iOSVersion && iOSVersion < 13 || false;
const useDefaultReduceAnimations = () => {
const prefersReduced = useMediaQuery(PREFERS_REDUCED_MOTION, {
defaultMatches: false
});
return prefersReduced || slowAnimationDevices;
};
const getDateCalendarUtilityClass = (slot) => generateUtilityClass("MuiDateCalendar", slot);
generateUtilityClasses("MuiDateCalendar", [
"root",
"viewTransitionContainer"
]);
const _excluded$d = [
"autoFocus",
"onViewChange",
"value",
"defaultValue",
"referenceDate",
"disableFuture",
"disablePast",
"onChange",
"onYearChange",
"onMonthChange",
"reduceAnimations",
"shouldDisableDate",
"shouldDisableMonth",
"shouldDisableYear",
"view",
"views",
"openTo",
"className",
"disabled",
"readOnly",
"minDate",
"maxDate",
"disableHighlightToday",
"focusedView",
"onFocusedViewChange",
"showDaysOutsideCurrentMonth",
"fixedWeekNumber",
"dayOfWeekFormatter",
"slots",
"slotProps",
"loading",
"renderLoading",
"displayWeekNumber",
"yearsOrder",
"yearsPerRow",
"monthsPerRow",
"timezone"
];
const useUtilityClasses$8 = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
viewTransitionContainer: [
"viewTransitionContainer"
]
};
return composeClasses(slots, getDateCalendarUtilityClass, classes);
};
function useDateCalendarDefaultizedProps(props, name) {
const utils = useUtils();
const defaultDates = useDefaultDates();
const defaultReduceAnimations = useDefaultReduceAnimations();
const themeProps = useThemeProps({
props,
name
});
return _extends$1({}, themeProps, {
loading: themeProps.loading ?? false,
disablePast: themeProps.disablePast ?? false,
disableFuture: themeProps.disableFuture ?? false,
openTo: themeProps.openTo ?? "day",
views: themeProps.views ?? [
"year",
"day"
],
reduceAnimations: themeProps.reduceAnimations ?? defaultReduceAnimations,
renderLoading: themeProps.renderLoading ?? (() => jsxRuntimeExports.jsx("span", {
children: "..."
})),
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate)
});
}
const DateCalendarRoot = styled(PickerViewRoot, {
name: "MuiDateCalendar",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
display: "flex",
flexDirection: "column",
height: VIEW_HEIGHT
});
const DateCalendarViewTransitionContainer = styled(PickersFadeTransitionGroup, {
name: "MuiDateCalendar",
slot: "ViewTransitionContainer",
overridesResolver: (props, styles2) => styles2.viewTransitionContainer
})({});
const DateCalendar = __mf_14(function DateCalendar2(inProps, ref) {
const utils = useUtils();
const id = useId();
const props = useDateCalendarDefaultizedProps(inProps, "MuiDateCalendar");
const { autoFocus, onViewChange, value: valueProp, defaultValue, referenceDate: referenceDateProp, disableFuture, disablePast, onChange, onYearChange, onMonthChange, reduceAnimations, shouldDisableDate, shouldDisableMonth, shouldDisableYear, view: inView, views, openTo, className, disabled, readOnly, minDate, maxDate, disableHighlightToday, focusedView: inFocusedView, onFocusedViewChange, showDaysOutsideCurrentMonth, fixedWeekNumber, dayOfWeekFormatter, slots, slotProps, loading, renderLoading, displayWeekNumber, yearsOrder, yearsPerRow, monthsPerRow, timezone: timezoneProp } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$d);
const { value, handleValueChange, timezone } = useControlledValueWithTimezone({
name: "DateCalendar",
timezone: timezoneProp,
value: valueProp,
defaultValue,
referenceDate: referenceDateProp,
onChange,
valueManager: singleItemValueManager
});
const { view, setView, focusedView, setFocusedView, goToNextView, setValueAndGoToNextView } = useViews({
view: inView,
views,
openTo,
onChange: handleValueChange,
onViewChange,
autoFocus,
focusedView: inFocusedView,
onFocusedViewChange
});
const { referenceDate, calendarState, changeFocusedDay, changeMonth, handleChangeMonth, isDateDisabled, onMonthSwitchingAnimationEnd } = useCalendarState({
value,
referenceDate: referenceDateProp,
reduceAnimations,
onMonthChange,
minDate,
maxDate,
shouldDisableDate,
disablePast,
disableFuture,
timezone
});
const minDateWithDisabled = disabled && value || minDate;
const maxDateWithDisabled = disabled && value || maxDate;
const gridLabelId = `${id}-grid-label`;
const hasFocus = focusedView !== null;
const CalendarHeader = (slots == null ? void 0 : slots.calendarHeader) ?? PickersCalendarHeader;
const calendarHeaderProps = useSlotProps({
elementType: CalendarHeader,
externalSlotProps: slotProps == null ? void 0 : slotProps.calendarHeader,
additionalProps: {
views,
view,
currentMonth: calendarState.currentMonth,
onViewChange: setView,
onMonthChange: (newMonth, direction) => handleChangeMonth({
newMonth,
direction
}),
minDate: minDateWithDisabled,
maxDate: maxDateWithDisabled,
disabled,
disablePast,
disableFuture,
reduceAnimations,
timezone,
labelId: gridLabelId
},
ownerState: props
});
const handleDateMonthChange = useEventCallback((newDate) => {
const startOfMonth = utils.startOfMonth(newDate);
const endOfMonth = utils.endOfMonth(newDate);
const closestEnabledDate = isDateDisabled(newDate) ? findClosestEnabledDate({
utils,
date: newDate,
minDate: utils.isBefore(minDate, startOfMonth) ? startOfMonth : minDate,
maxDate: utils.isAfter(maxDate, endOfMonth) ? endOfMonth : maxDate,
disablePast,
disableFuture,
isDateDisabled,
timezone
}) : newDate;
if (closestEnabledDate) {
setValueAndGoToNextView(closestEnabledDate, "finish");
onMonthChange == null ? void 0 : onMonthChange(startOfMonth);
} else {
goToNextView();
changeMonth(startOfMonth);
}
changeFocusedDay(closestEnabledDate, true);
});
const handleDateYearChange = useEventCallback((newDate) => {
const startOfYear = utils.startOfYear(newDate);
const endOfYear = utils.endOfYear(newDate);
const closestEnabledDate = isDateDisabled(newDate) ? findClosestEnabledDate({
utils,
date: newDate,
minDate: utils.isBefore(minDate, startOfYear) ? startOfYear : minDate,
maxDate: utils.isAfter(maxDate, endOfYear) ? endOfYear : maxDate,
disablePast,
disableFuture,
isDateDisabled,
timezone
}) : newDate;
if (closestEnabledDate) {
setValueAndGoToNextView(closestEnabledDate, "finish");
onYearChange == null ? void 0 : onYearChange(closestEnabledDate);
} else {
goToNextView();
changeMonth(startOfYear);
}
changeFocusedDay(closestEnabledDate, true);
});
const handleSelectedDayChange = useEventCallback((day) => {
if (day) {
return handleValueChange(mergeDateAndTime(utils, day, value ?? referenceDate), "finish", view);
}
return handleValueChange(day, "finish", view);
});
__mf_24(() => {
if (value != null && utils.isValid(value)) {
changeMonth(value);
}
}, [
value
]);
const ownerState = props;
const classes = useUtilityClasses$8(ownerState);
const baseDateValidationProps = {
disablePast,
disableFuture,
maxDate,
minDate
};
const commonViewProps = {
disableHighlightToday,
readOnly,
disabled,
timezone,
gridLabelId,
slots,
slotProps
};
const prevOpenViewRef = __mf_31(view);
__mf_24(() => {
if (prevOpenViewRef.current === view) {
return;
}
if (focusedView === prevOpenViewRef.current) {
setFocusedView(view, true);
}
prevOpenViewRef.current = view;
}, [
focusedView,
setFocusedView,
view
]);
const selectedDays = __mf_29(() => [
value
], [
value
]);
return jsxRuntimeExports.jsxs(DateCalendarRoot, _extends$1({
ref,
className: clsx(classes.root, className),
ownerState
}, other, {
children: [
jsxRuntimeExports.jsx(CalendarHeader, _extends$1({}, calendarHeaderProps, {
slots,
slotProps
})),
jsxRuntimeExports.jsx(DateCalendarViewTransitionContainer, {
reduceAnimations,
className: classes.viewTransitionContainer,
transKey: view,
ownerState,
children: jsxRuntimeExports.jsxs("div", {
children: [
view === "year" && jsxRuntimeExports.jsx(YearCalendar, _extends$1({}, baseDateValidationProps, commonViewProps, {
value,
onChange: handleDateYearChange,
shouldDisableYear,
hasFocus,
onFocusedViewChange: (isViewFocused) => setFocusedView("year", isViewFocused),
yearsOrder,
yearsPerRow,
referenceDate
})),
view === "month" && jsxRuntimeExports.jsx(MonthCalendar, _extends$1({}, baseDateValidationProps, commonViewProps, {
hasFocus,
className,
value,
onChange: handleDateMonthChange,
shouldDisableMonth,
onFocusedViewChange: (isViewFocused) => setFocusedView("month", isViewFocused),
monthsPerRow,
referenceDate
})),
view === "day" && jsxRuntimeExports.jsx(DayCalendar, _extends$1({}, calendarState, baseDateValidationProps, commonViewProps, {
onMonthSwitchingAnimationEnd,
onFocusedDayChange: changeFocusedDay,
reduceAnimations,
selectedDays,
onSelectedDaysChange: handleSelectedDayChange,
shouldDisableDate,
shouldDisableMonth,
shouldDisableYear,
hasFocus,
onFocusedViewChange: (isViewFocused) => setFocusedView("day", isViewFocused),
showDaysOutsideCurrentMonth,
fixedWeekNumber,
dayOfWeekFormatter,
displayWeekNumber,
loading,
renderLoading
}))
]
})
})
]
}));
});
function getPickersToolbarUtilityClass(slot) {
return generateUtilityClass("MuiPickersToolbar", slot);
}
generateUtilityClasses("MuiPickersToolbar", [
"root",
"content"
]);
const _excluded$c = [
"children",
"className",
"toolbarTitle",
"hidden",
"titleId",
"isLandscape",
"classes",
"landscapeDirection"
];
const useUtilityClasses$7 = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
content: [
"content"
]
};
return composeClasses(slots, getPickersToolbarUtilityClass, classes);
};
const PickersToolbarRoot = styled("div", {
name: "MuiPickersToolbar",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})(({ theme }) => ({
display: "flex",
flexDirection: "column",
alignItems: "flex-start",
justifyContent: "space-between",
padding: theme.spacing(2, 3),
variants: [
{
props: {
isLandscape: true
},
style: {
height: "auto",
maxWidth: 160,
padding: 16,
justifyContent: "flex-start",
flexWrap: "wrap"
}
}
]
}));
const PickersToolbarContent = styled("div", {
name: "MuiPickersToolbar",
slot: "Content",
overridesResolver: (props, styles2) => styles2.content
})({
display: "flex",
flexWrap: "wrap",
width: "100%",
flex: 1,
justifyContent: "space-between",
alignItems: "center",
flexDirection: "row",
variants: [
{
props: {
isLandscape: true
},
style: {
justifyContent: "flex-start",
alignItems: "flex-start",
flexDirection: "column"
}
},
{
props: {
isLandscape: true,
landscapeDirection: "row"
},
style: {
flexDirection: "row"
}
}
]
});
const PickersToolbar = __mf_14(function PickersToolbar2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersToolbar"
});
const { children, className, toolbarTitle, hidden, titleId } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$c);
const ownerState = props;
const classes = useUtilityClasses$7(ownerState);
if (hidden) {
return null;
}
return jsxRuntimeExports.jsxs(PickersToolbarRoot, _extends$1({
ref,
className: clsx(classes.root, className),
ownerState
}, other, {
children: [
jsxRuntimeExports.jsx(Typography, {
color: "text.secondary",
variant: "overline",
id: titleId,
children: toolbarTitle
}),
jsxRuntimeExports.jsx(PickersToolbarContent, {
className: classes.content,
ownerState,
children
})
]
}));
});
function getDatePickerToolbarUtilityClass(slot) {
return generateUtilityClass("MuiDatePickerToolbar", slot);
}
generateUtilityClasses("MuiDatePickerToolbar", [
"root",
"title"
]);
const _excluded$b = [
"value",
"isLandscape",
"onChange",
"toolbarFormat",
"toolbarPlaceholder",
"views",
"className",
"onViewChange",
"view"
];
const useUtilityClasses$6 = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
title: [
"title"
]
};
return composeClasses(slots, getDatePickerToolbarUtilityClass, classes);
};
const DatePickerToolbarRoot = styled(PickersToolbar, {
name: "MuiDatePickerToolbar",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})({});
const DatePickerToolbarTitle = styled(Typography, {
name: "MuiDatePickerToolbar",
slot: "Title",
overridesResolver: (_, styles2) => styles2.title
})({
variants: [
{
props: {
isLandscape: true
},
style: {
margin: "auto 16px auto auto"
}
}
]
});
const DatePickerToolbar = __mf_14(function DatePickerToolbar2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiDatePickerToolbar"
});
const { value, isLandscape, toolbarFormat, toolbarPlaceholder = "\u2013\u2013", views, className } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$b);
const utils = useUtils();
const translations = usePickersTranslations();
const classes = useUtilityClasses$6(props);
const dateText = __mf_29(() => {
if (!value) {
return toolbarPlaceholder;
}
const formatFromViews = resolveDateFormat(utils, {
format: toolbarFormat,
views
}, true);
return utils.formatByString(value, formatFromViews);
}, [
value,
toolbarFormat,
toolbarPlaceholder,
utils,
views
]);
const ownerState = props;
return jsxRuntimeExports.jsx(DatePickerToolbarRoot, _extends$1({
ref,
toolbarTitle: translations.datePickerToolbarTitle,
isLandscape,
className: clsx(classes.root, className)
}, other, {
children: jsxRuntimeExports.jsx(DatePickerToolbarTitle, {
variant: "h4",
align: isLandscape ? "left" : "center",
ownerState,
className: classes.title,
children: dateText
})
}));
});
function useDatePickerDefaultizedProps(props, name) {
const utils = useUtils();
const defaultDates = useDefaultDates();
const themeProps = useThemeProps({
props,
name
});
const localeText = __mf_29(() => {
var _a;
if (((_a = themeProps.localeText) == null ? void 0 : _a.toolbarTitle) == null) {
return themeProps.localeText;
}
return _extends$1({}, themeProps.localeText, {
datePickerToolbarTitle: themeProps.localeText.toolbarTitle
});
}, [
themeProps.localeText
]);
return _extends$1({}, themeProps, {
localeText
}, applyDefaultViewProps({
views: themeProps.views,
openTo: themeProps.openTo,
defaultViews: [
"year",
"day"
],
defaultOpenTo: "day"
}), {
disableFuture: themeProps.disableFuture ?? false,
disablePast: themeProps.disablePast ?? false,
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate),
slots: _extends$1({
toolbar: DatePickerToolbar
}, themeProps.slots)
});
}
function getPickersPopperUtilityClass(slot) {
return generateUtilityClass("MuiPickersPopper", slot);
}
generateUtilityClasses("MuiPickersPopper", [
"root",
"paper"
]);
const _excluded$a = [
"PaperComponent",
"popperPlacement",
"ownerState",
"children",
"paperSlotProps",
"paperClasses",
"onPaperClick",
"onPaperTouchStart"
];
const useUtilityClasses$5 = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
],
paper: [
"paper"
]
};
return composeClasses(slots, getPickersPopperUtilityClass, classes);
};
const PickersPopperRoot = styled(Popper, {
name: "MuiPickersPopper",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})(({ theme }) => ({
zIndex: theme.zIndex.modal
}));
const PickersPopperPaper = styled(Paper, {
name: "MuiPickersPopper",
slot: "Paper",
overridesResolver: (_, styles2) => styles2.paper
})({
outline: 0,
transformOrigin: "top center",
variants: [
{
props: ({ placement }) => [
"top",
"top-start",
"top-end"
].includes(placement),
style: {
transformOrigin: "bottom center"
}
}
]
});
function clickedRootScrollbar(event, doc) {
return doc.documentElement.clientWidth < event.clientX || doc.documentElement.clientHeight < event.clientY;
}
function useClickAwayListener(active, onClickAway) {
const movedRef = __mf_31(false);
const syntheticEventRef = __mf_31(false);
const nodeRef = __mf_31(null);
const activatedRef = __mf_31(false);
__mf_24(() => {
if (!active) {
return void 0;
}
function armClickAwayListener() {
activatedRef.current = true;
}
document.addEventListener("mousedown", armClickAwayListener, true);
document.addEventListener("touchstart", armClickAwayListener, true);
return () => {
document.removeEventListener("mousedown", armClickAwayListener, true);
document.removeEventListener("touchstart", armClickAwayListener, true);
activatedRef.current = false;
};
}, [
active
]);
const handleClickAway = useEventCallback((event) => {
if (!activatedRef.current) {
return;
}
const insideReactTree = syntheticEventRef.current;
syntheticEventRef.current = false;
const doc = ownerDocument(nodeRef.current);
if (!nodeRef.current || "clientX" in event && clickedRootScrollbar(event, doc)) {
return;
}
if (movedRef.current) {
movedRef.current = false;
return;
}
let insideDOM;
if (event.composedPath) {
insideDOM = event.composedPath().indexOf(nodeRef.current) > -1;
} else {
insideDOM = !doc.documentElement.contains(event.target) || nodeRef.current.contains(event.target);
}
if (!insideDOM && !insideReactTree) {
onClickAway(event);
}
});
const handleSynthetic = () => {
syntheticEventRef.current = true;
};
__mf_24(() => {
if (active) {
const doc = ownerDocument(nodeRef.current);
const handleTouchMove = () => {
movedRef.current = true;
};
doc.addEventListener("touchstart", handleClickAway);
doc.addEventListener("touchmove", handleTouchMove);
return () => {
doc.removeEventListener("touchstart", handleClickAway);
doc.removeEventListener("touchmove", handleTouchMove);
};
}
return void 0;
}, [
active,
handleClickAway
]);
__mf_24(() => {
if (active) {
const doc = ownerDocument(nodeRef.current);
doc.addEventListener("click", handleClickAway);
return () => {
doc.removeEventListener("click", handleClickAway);
syntheticEventRef.current = false;
};
}
return void 0;
}, [
active,
handleClickAway
]);
return [
nodeRef,
handleSynthetic,
handleSynthetic
];
}
const PickersPopperPaperWrapper = __mf_14((props, ref) => {
const { PaperComponent, popperPlacement, ownerState: inOwnerState, children, paperSlotProps, paperClasses, onPaperClick, onPaperTouchStart } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$a);
const ownerState = _extends$1({}, inOwnerState, {
placement: popperPlacement
});
const paperProps = useSlotProps({
elementType: PaperComponent,
externalSlotProps: paperSlotProps,
additionalProps: {
tabIndex: -1,
elevation: 8,
ref
},
className: paperClasses,
ownerState
});
return jsxRuntimeExports.jsx(PaperComponent, _extends$1({}, other, paperProps, {
onClick: (event) => {
var _a;
onPaperClick(event);
(_a = paperProps.onClick) == null ? void 0 : _a.call(paperProps, event);
},
onTouchStart: (event) => {
var _a;
onPaperTouchStart(event);
(_a = paperProps.onTouchStart) == null ? void 0 : _a.call(paperProps, event);
},
ownerState,
children
}));
});
function PickersPopper(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersPopper"
});
const { anchorEl, children, containerRef = null, shouldRestoreFocus, onBlur, onDismiss, open, role, placement, slots, slotProps, reduceAnimations: inReduceAnimations } = props;
__mf_24(() => {
function handleKeyDown2(nativeEvent) {
if (open && nativeEvent.key === "Escape") {
onDismiss();
}
}
document.addEventListener("keydown", handleKeyDown2);
return () => {
document.removeEventListener("keydown", handleKeyDown2);
};
}, [
onDismiss,
open
]);
const lastFocusedElementRef = __mf_31(null);
__mf_24(() => {
if (role === "tooltip" || shouldRestoreFocus && !shouldRestoreFocus()) {
return;
}
if (open) {
lastFocusedElementRef.current = getActiveElement(document);
} else if (lastFocusedElementRef.current && lastFocusedElementRef.current instanceof HTMLElement) {
setTimeout(() => {
if (lastFocusedElementRef.current instanceof HTMLElement) {
lastFocusedElementRef.current.focus();
}
});
}
}, [
open,
role,
shouldRestoreFocus
]);
const [clickAwayRef, onPaperClick, onPaperTouchStart] = useClickAwayListener(open, onBlur ?? onDismiss);
const paperRef = __mf_31(null);
const handleRef = useForkRef(paperRef, containerRef);
const handlePaperRef = useForkRef(handleRef, clickAwayRef);
const ownerState = props;
const classes = useUtilityClasses$5(ownerState);
const defaultReduceAnimations = useDefaultReduceAnimations();
const reduceAnimations = inReduceAnimations ?? defaultReduceAnimations;
const handleKeyDown = (event) => {
if (event.key === "Escape") {
event.stopPropagation();
onDismiss();
}
};
const Transition2 = (slots == null ? void 0 : slots.desktopTransition) ?? reduceAnimations ? Fade : Grow;
const FocusTrap$1 = (slots == null ? void 0 : slots.desktopTrapFocus) ?? FocusTrap;
const Paper2 = (slots == null ? void 0 : slots.desktopPaper) ?? PickersPopperPaper;
const Popper2 = (slots == null ? void 0 : slots.popper) ?? PickersPopperRoot;
const popperProps = useSlotProps({
elementType: Popper2,
externalSlotProps: slotProps == null ? void 0 : slotProps.popper,
additionalProps: {
transition: true,
role,
open,
anchorEl,
placement,
onKeyDown: handleKeyDown
},
className: classes.root,
ownerState: props
});
return jsxRuntimeExports.jsx(Popper2, _extends$1({}, popperProps, {
children: ({ TransitionProps, placement: popperPlacement }) => jsxRuntimeExports.jsx(FocusTrap$1, _extends$1({
open,
disableAutoFocus: true,
disableRestoreFocus: true,
disableEnforceFocus: role === "tooltip",
isEnabled: () => true
}, slotProps == null ? void 0 : slotProps.desktopTrapFocus, {
children: jsxRuntimeExports.jsx(Transition2, _extends$1({}, TransitionProps, slotProps == null ? void 0 : slotProps.desktopTransition, {
children: jsxRuntimeExports.jsx(PickersPopperPaperWrapper, {
PaperComponent: Paper2,
ownerState,
popperPlacement,
ref: handlePaperRef,
onPaperClick,
onPaperTouchStart,
paperClasses: classes.paper,
paperSlotProps: slotProps == null ? void 0 : slotProps.desktopPaper,
children
})
}))
}))
}));
}
const useOpenState = ({ open, onOpen, onClose }) => {
const isControllingOpenProp = __mf_31(typeof open === "boolean").current;
const [openState, setIsOpenState] = __mf_32(false);
__mf_24(() => {
if (isControllingOpenProp) {
if (typeof open !== "boolean") {
throw new Error("You must not mix controlling and uncontrolled mode for `open` prop");
}
setIsOpenState(open);
}
}, [
isControllingOpenProp,
open
]);
const setIsOpen = __mf_20((newIsOpen) => {
if (!isControllingOpenProp) {
setIsOpenState(newIsOpen);
}
if (newIsOpen && onOpen) {
onOpen();
}
if (!newIsOpen && onClose) {
onClose();
}
}, [
isControllingOpenProp,
onOpen,
onClose
]);
return {
isOpen: openState,
setIsOpen
};
};
const shouldPublishValue = (params) => {
const { action, hasChanged, dateState, isControlled } = params;
const isCurrentValueTheDefaultValue = !isControlled && !dateState.hasBeenModifiedSinceMount;
if (action.name === "setValueFromField") {
return true;
}
if (action.name === "setValueFromAction") {
if (isCurrentValueTheDefaultValue && [
"accept",
"today",
"clear"
].includes(action.pickerAction)) {
return true;
}
return hasChanged(dateState.lastPublishedValue);
}
if (action.name === "setValueFromView" && action.selectionState !== "shallow") {
if (isCurrentValueTheDefaultValue) {
return true;
}
return hasChanged(dateState.lastPublishedValue);
}
if (action.name === "setValueFromShortcut") {
if (isCurrentValueTheDefaultValue) {
return true;
}
return hasChanged(dateState.lastPublishedValue);
}
return false;
};
const shouldCommitValue = (params) => {
const { action, hasChanged, dateState, isControlled, closeOnSelect } = params;
const isCurrentValueTheDefaultValue = !isControlled && !dateState.hasBeenModifiedSinceMount;
if (action.name === "setValueFromAction") {
if (isCurrentValueTheDefaultValue && [
"accept",
"today",
"clear"
].includes(action.pickerAction)) {
return true;
}
return hasChanged(dateState.lastCommittedValue);
}
if (action.name === "setValueFromView" && action.selectionState === "finish" && closeOnSelect) {
if (isCurrentValueTheDefaultValue) {
return true;
}
return hasChanged(dateState.lastCommittedValue);
}
if (action.name === "setValueFromShortcut") {
return action.changeImportance === "accept" && hasChanged(dateState.lastCommittedValue);
}
return false;
};
const shouldClosePicker = (params) => {
const { action, closeOnSelect } = params;
if (action.name === "setValueFromAction") {
return true;
}
if (action.name === "setValueFromView") {
return action.selectionState === "finish" && closeOnSelect;
}
if (action.name === "setValueFromShortcut") {
return action.changeImportance === "accept";
}
return false;
};
const usePickerValue = ({ props, valueManager, valueType, wrapperVariant, validator }) => {
const { onAccept, onChange, value: inValueWithoutRenderTimezone, defaultValue: inDefaultValue, closeOnSelect = wrapperVariant === "desktop", timezone: timezoneProp, referenceDate } = props;
const { current: defaultValue } = __mf_31(inDefaultValue);
const { current: isControlled } = __mf_31(inValueWithoutRenderTimezone !== void 0);
const [previousTimezoneProp, setPreviousTimezoneProp] = __mf_32(timezoneProp);
const utils = useUtils();
const adapter = useLocalizationContext();
const { isOpen, setIsOpen } = useOpenState(props);
const { timezone, value: inValueWithTimezoneToRender, handleValueChange } = useValueWithTimezone({
timezone: timezoneProp,
value: inValueWithoutRenderTimezone,
defaultValue,
referenceDate,
onChange,
valueManager
});
const [dateState, setDateState] = __mf_32(() => {
let initialValue;
if (inValueWithTimezoneToRender !== void 0) {
initialValue = inValueWithTimezoneToRender;
} else if (defaultValue !== void 0) {
initialValue = defaultValue;
} else {
initialValue = valueManager.emptyValue;
}
return {
draft: initialValue,
lastPublishedValue: initialValue,
lastCommittedValue: initialValue,
lastControlledValue: inValueWithoutRenderTimezone,
hasBeenModifiedSinceMount: false
};
});
const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
if (previousTimezoneProp !== timezoneProp) {
setPreviousTimezoneProp(timezoneProp);
if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
setDateState((prev) => _extends$1({}, prev, {
draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
}));
}
}
const { getValidationErrorForNewValue } = useValidation({
props,
validator,
timezone,
value: dateState.draft,
onError: props.onError
});
const updateDate = useEventCallback((action) => {
const updaterParams = {
action,
dateState,
hasChanged: (comparison) => !valueManager.areValuesEqual(utils, action.value, comparison),
isControlled,
closeOnSelect
};
const shouldPublish = shouldPublishValue(updaterParams);
const shouldCommit = shouldCommitValue(updaterParams);
const shouldClose = shouldClosePicker(updaterParams);
setDateState((prev) => _extends$1({}, prev, {
draft: action.value,
lastPublishedValue: shouldPublish ? action.value : prev.lastPublishedValue,
lastCommittedValue: shouldCommit ? action.value : prev.lastCommittedValue,
hasBeenModifiedSinceMount: true
}));
let cachedContext = null;
const getContext = () => {
if (!cachedContext) {
const validationError = action.name === "setValueFromField" ? action.context.validationError : getValidationErrorForNewValue(action.value);
cachedContext = {
validationError
};
if (action.name === "setValueFromShortcut") {
cachedContext.shortcut = action.shortcut;
}
}
return cachedContext;
};
if (shouldPublish) {
handleValueChange(action.value, getContext());
}
if (shouldCommit && onAccept) {
onAccept(action.value, getContext());
}
if (shouldClose) {
setIsOpen(false);
}
});
if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValueWithTimezoneToRender);
setDateState((prev) => _extends$1({}, prev, {
lastControlledValue: inValueWithoutRenderTimezone
}, isUpdateComingFromPicker ? {} : {
lastCommittedValue: inValueWithTimezoneToRender,
lastPublishedValue: inValueWithTimezoneToRender,
draft: inValueWithTimezoneToRender,
hasBeenModifiedSinceMount: true
}));
}
const handleClear = useEventCallback(() => {
updateDate({
value: valueManager.emptyValue,
name: "setValueFromAction",
pickerAction: "clear"
});
});
const handleAccept = useEventCallback(() => {
updateDate({
value: dateState.lastPublishedValue,
name: "setValueFromAction",
pickerAction: "accept"
});
});
const handleDismiss = useEventCallback(() => {
updateDate({
value: dateState.lastPublishedValue,
name: "setValueFromAction",
pickerAction: "dismiss"
});
});
const handleCancel = useEventCallback(() => {
updateDate({
value: dateState.lastCommittedValue,
name: "setValueFromAction",
pickerAction: "cancel"
});
});
const handleSetToday = useEventCallback(() => {
updateDate({
value: valueManager.getTodayValue(utils, timezone, valueType),
name: "setValueFromAction",
pickerAction: "today"
});
});
const handleOpen = useEventCallback((event) => {
event.preventDefault();
setIsOpen(true);
});
const handleClose = useEventCallback((event) => {
event == null ? void 0 : event.preventDefault();
setIsOpen(false);
});
const handleChange = useEventCallback((newValue, selectionState = "partial") => updateDate({
name: "setValueFromView",
value: newValue,
selectionState
}));
const handleSelectShortcut = useEventCallback((newValue, changeImportance, shortcut) => updateDate({
name: "setValueFromShortcut",
value: newValue,
changeImportance,
shortcut
}));
const handleChangeFromField = useEventCallback((newValue, context) => updateDate({
name: "setValueFromField",
value: newValue,
context
}));
const actions = {
onClear: handleClear,
onAccept: handleAccept,
onDismiss: handleDismiss,
onCancel: handleCancel,
onSetToday: handleSetToday,
onOpen: handleOpen,
onClose: handleClose
};
const fieldResponse = {
value: dateState.draft,
onChange: handleChangeFromField
};
const viewValue = __mf_29(() => valueManager.cleanValue(utils, dateState.draft), [
utils,
valueManager,
dateState.draft
]);
const viewResponse = {
value: viewValue,
onChange: handleChange,
onClose: handleClose,
open: isOpen
};
const isValid = (testedValue) => {
const error = validator({
adapter,
value: testedValue,
timezone,
props
});
return !valueManager.hasError(error);
};
const layoutResponse = _extends$1({}, actions, {
value: viewValue,
onChange: handleChange,
onSelectShortcut: handleSelectShortcut,
isValid
});
const contextValue = __mf_29(() => ({
onOpen: handleOpen,
onClose: handleClose,
open: isOpen
}), [
isOpen,
handleClose,
handleOpen
]);
return {
open: isOpen,
fieldProps: fieldResponse,
viewProps: viewResponse,
layoutProps: layoutResponse,
actions,
contextValue
};
};
const _excluded$9 = [
"className",
"sx"
];
const usePickerViews = ({ props, propsFromPickerValue, additionalViewProps, autoFocusView, rendererInterceptor, fieldRef }) => {
const { onChange, open, onClose } = propsFromPickerValue;
const { view: inView, views, openTo, onViewChange, viewRenderers, timezone } = props;
const propsToForwardToView = _objectWithoutPropertiesLoose$3(props, _excluded$9);
const { view, setView, defaultView, focusedView, setFocusedView, setValueAndGoToNextView } = useViews({
view: inView,
views,
openTo,
onChange,
onViewChange,
autoFocus: autoFocusView
});
const { hasUIView, viewModeLookup } = __mf_29(() => views.reduce((acc, viewForReduce) => {
let viewMode;
if (viewRenderers[viewForReduce] != null) {
viewMode = "UI";
} else {
viewMode = "field";
}
acc.viewModeLookup[viewForReduce] = viewMode;
if (viewMode === "UI") {
acc.hasUIView = true;
}
return acc;
}, {
hasUIView: false,
viewModeLookup: {}
}), [
viewRenderers,
views
]);
const timeViewsCount = __mf_29(() => views.reduce((acc, viewForReduce) => {
if (viewRenderers[viewForReduce] != null && isTimeView(viewForReduce)) {
return acc + 1;
}
return acc;
}, 0), [
viewRenderers,
views
]);
const currentViewMode = viewModeLookup[view];
const shouldRestoreFocus = useEventCallback(() => currentViewMode === "UI");
const [popperView, setPopperView] = __mf_32(currentViewMode === "UI" ? view : null);
if (popperView !== view && viewModeLookup[view] === "UI") {
setPopperView(view);
}
useEnhancedEffect(() => {
if (currentViewMode === "field" && open) {
onClose();
setTimeout(() => {
var _a, _b;
(_a = fieldRef == null ? void 0 : fieldRef.current) == null ? void 0 : _a.setSelectedSections(view);
(_b = fieldRef == null ? void 0 : fieldRef.current) == null ? void 0 : _b.focusField(view);
});
}
}, [
view
]);
useEnhancedEffect(() => {
if (!open) {
return;
}
let newView = view;
if (currentViewMode === "field" && popperView != null) {
newView = popperView;
}
if (newView !== defaultView && viewModeLookup[newView] === "UI" && viewModeLookup[defaultView] === "UI") {
newView = defaultView;
}
if (newView !== view) {
setView(newView);
}
setFocusedView(newView, true);
}, [
open
]);
const layoutProps = {
views,
view: popperView,
onViewChange: setView
};
return {
hasUIView,
shouldRestoreFocus,
layoutProps,
renderCurrentView: () => {
if (popperView == null) {
return null;
}
const renderer = viewRenderers[popperView];
if (renderer == null) {
return null;
}
const rendererProps = _extends$1({}, propsToForwardToView, additionalViewProps, propsFromPickerValue, {
views,
timezone,
onChange: setValueAndGoToNextView,
view: popperView,
onViewChange: setView,
focusedView,
onFocusedViewChange: setFocusedView,
showViewSwitcher: timeViewsCount > 1,
timeViewsCount
});
if (rendererInterceptor) {
return rendererInterceptor(viewRenderers, popperView, rendererProps);
}
return renderer(rendererProps);
}
};
};
function getOrientation() {
if (typeof window === "undefined") {
return "portrait";
}
if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
return Math.abs(window.screen.orientation.angle) === 90 ? "landscape" : "portrait";
}
if (window.orientation) {
return Math.abs(Number(window.orientation)) === 90 ? "landscape" : "portrait";
}
return "portrait";
}
const useIsLandscape = (views, customOrientation) => {
const [orientation, setOrientation] = __mf_32(getOrientation);
useEnhancedEffect(() => {
const eventHandler = () => {
setOrientation(getOrientation());
};
window.addEventListener("orientationchange", eventHandler);
return () => {
window.removeEventListener("orientationchange", eventHandler);
};
}, []);
if (arrayIncludes(views, [
"hours",
"minutes",
"seconds"
])) {
return false;
}
const orientationToUse = customOrientation || orientation;
return orientationToUse === "landscape";
};
const usePickerLayoutProps = ({ props, propsFromPickerValue, propsFromPickerViews, wrapperVariant }) => {
const { orientation } = props;
const isLandscape = useIsLandscape(propsFromPickerViews.views, orientation);
const isRtl = useRtl();
const layoutProps = _extends$1({}, propsFromPickerViews, propsFromPickerValue, {
isLandscape,
isRtl,
wrapperVariant,
disabled: props.disabled,
readOnly: props.readOnly
});
return {
layoutProps
};
};
function usePickerOwnerState(parameters) {
const { props, pickerValueResponse } = parameters;
return __mf_29(() => ({
value: pickerValueResponse.viewProps.value,
open: pickerValueResponse.open,
disabled: props.disabled ?? false,
readOnly: props.readOnly ?? false
}), [
pickerValueResponse.viewProps.value,
pickerValueResponse.open,
props.disabled,
props.readOnly
]);
}
const usePicker = ({ props, valueManager, valueType, wrapperVariant, additionalViewProps, validator, autoFocusView, rendererInterceptor, fieldRef }) => {
const pickerValueResponse = usePickerValue({
props,
valueManager,
valueType,
wrapperVariant,
validator
});
const pickerViewsResponse = usePickerViews({
props,
additionalViewProps,
autoFocusView,
fieldRef,
propsFromPickerValue: pickerValueResponse.viewProps,
rendererInterceptor
});
const pickerLayoutResponse = usePickerLayoutProps({
props,
wrapperVariant,
propsFromPickerValue: pickerValueResponse.layoutProps,
propsFromPickerViews: pickerViewsResponse.layoutProps
});
const pickerOwnerState = usePickerOwnerState({
props,
pickerValueResponse
});
return {
open: pickerValueResponse.open,
actions: pickerValueResponse.actions,
fieldProps: pickerValueResponse.fieldProps,
renderCurrentView: pickerViewsResponse.renderCurrentView,
hasUIView: pickerViewsResponse.hasUIView,
shouldRestoreFocus: pickerViewsResponse.shouldRestoreFocus,
layoutProps: pickerLayoutResponse.layoutProps,
contextValue: pickerValueResponse.contextValue,
ownerState: pickerOwnerState
};
};
function getPickersLayoutUtilityClass(slot) {
return generateUtilityClass("MuiPickersLayout", slot);
}
const pickersLayoutClasses = generateUtilityClasses("MuiPickersLayout", [
"root",
"landscape",
"contentWrapper",
"toolbar",
"actionBar",
"tabs",
"shortcuts"
]);
const _excluded$8 = [
"onAccept",
"onClear",
"onCancel",
"onSetToday",
"actions"
];
function PickersActionBar(props) {
const { onAccept, onClear, onCancel, onSetToday, actions } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$8);
const translations = usePickersTranslations();
if (actions == null || actions.length === 0) {
return null;
}
const buttons = actions == null ? void 0 : actions.map((actionType) => {
switch (actionType) {
case "clear":
return jsxRuntimeExports.jsx(Button, {
onClick: onClear,
children: translations.clearButtonLabel
}, actionType);
case "cancel":
return jsxRuntimeExports.jsx(Button, {
onClick: onCancel,
children: translations.cancelButtonLabel
}, actionType);
case "accept":
return jsxRuntimeExports.jsx(Button, {
onClick: onAccept,
children: translations.okButtonLabel
}, actionType);
case "today":
return jsxRuntimeExports.jsx(Button, {
onClick: onSetToday,
children: translations.todayButtonLabel
}, actionType);
default:
return null;
}
});
return jsxRuntimeExports.jsx(DialogActions, _extends$1({}, other, {
children: buttons
}));
}
const _excluded$7 = [
"items",
"changeImportance",
"isLandscape",
"onChange",
"isValid"
], _excluded2$1 = [
"getValue"
];
function PickersShortcuts(props) {
const { items, changeImportance = "accept", onChange, isValid } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$7);
if (items == null || items.length === 0) {
return null;
}
const resolvedItems = items.map((_ref) => {
let { getValue: getValue2 } = _ref, item = _objectWithoutPropertiesLoose$3(_ref, _excluded2$1);
const newValue = getValue2({
isValid
});
return _extends$1({}, item, {
label: item.label,
onClick: () => {
onChange(newValue, changeImportance, item);
},
disabled: !isValid(newValue)
});
});
return jsxRuntimeExports.jsx(List, _extends$1({
dense: true,
sx: [
{
maxHeight: VIEW_HEIGHT,
maxWidth: 200,
overflow: "auto"
},
...Array.isArray(other.sx) ? other.sx : [
other.sx
]
]
}, other, {
children: resolvedItems.map((item) => {
return jsxRuntimeExports.jsx(ListItem, {
children: jsxRuntimeExports.jsx(Chip, _extends$1({}, item))
}, item.id ?? item.label);
})
}));
}
function toolbarHasView(toolbarProps) {
return toolbarProps.view !== null;
}
const useUtilityClasses$4 = (ownerState) => {
const { classes, isLandscape } = ownerState;
const slots = {
root: [
"root",
isLandscape && "landscape"
],
contentWrapper: [
"contentWrapper"
],
toolbar: [
"toolbar"
],
actionBar: [
"actionBar"
],
tabs: [
"tabs"
],
landscape: [
"landscape"
],
shortcuts: [
"shortcuts"
]
};
return composeClasses(slots, getPickersLayoutUtilityClass, classes);
};
const usePickerLayout = (props) => {
const { wrapperVariant, onAccept, onClear, onCancel, onSetToday, view, views, onViewChange, value, onChange, onSelectShortcut, isValid, isLandscape, disabled, readOnly, children, slots, slotProps } = props;
const classes = useUtilityClasses$4(props);
const ActionBar = (slots == null ? void 0 : slots.actionBar) ?? PickersActionBar;
const actionBarProps = useSlotProps({
elementType: ActionBar,
externalSlotProps: slotProps == null ? void 0 : slotProps.actionBar,
additionalProps: {
onAccept,
onClear,
onCancel,
onSetToday,
actions: wrapperVariant === "desktop" ? [] : [
"cancel",
"accept"
]
},
className: classes.actionBar,
ownerState: _extends$1({}, props, {
wrapperVariant
})
});
const actionBar = jsxRuntimeExports.jsx(ActionBar, _extends$1({}, actionBarProps));
const Toolbar = slots == null ? void 0 : slots.toolbar;
const toolbarProps = useSlotProps({
elementType: Toolbar,
externalSlotProps: slotProps == null ? void 0 : slotProps.toolbar,
additionalProps: {
isLandscape,
onChange,
value,
view,
onViewChange,
views,
disabled,
readOnly
},
className: classes.toolbar,
ownerState: _extends$1({}, props, {
wrapperVariant
})
});
const toolbar = toolbarHasView(toolbarProps) && !!Toolbar ? jsxRuntimeExports.jsx(Toolbar, _extends$1({}, toolbarProps)) : null;
const content = children;
const Tabs = slots == null ? void 0 : slots.tabs;
const tabs = view && Tabs ? jsxRuntimeExports.jsx(Tabs, _extends$1({
view,
onViewChange,
className: classes.tabs
}, slotProps == null ? void 0 : slotProps.tabs)) : null;
const Shortcuts = (slots == null ? void 0 : slots.shortcuts) ?? PickersShortcuts;
const shortcutsProps = useSlotProps({
elementType: Shortcuts,
externalSlotProps: slotProps == null ? void 0 : slotProps.shortcuts,
additionalProps: {
isValid,
isLandscape,
onChange: onSelectShortcut
},
className: classes.shortcuts,
ownerState: {
isValid,
isLandscape,
onChange: onSelectShortcut,
wrapperVariant
}
});
const shortcuts = view && !!Shortcuts ? jsxRuntimeExports.jsx(Shortcuts, _extends$1({}, shortcutsProps)) : null;
return {
toolbar,
content,
tabs,
actionBar,
shortcuts
};
};
const useUtilityClasses$3 = (ownerState) => {
const { isLandscape, classes } = ownerState;
const slots = {
root: [
"root",
isLandscape && "landscape"
],
contentWrapper: [
"contentWrapper"
]
};
return composeClasses(slots, getPickersLayoutUtilityClass, classes);
};
const PickersLayoutRoot = styled("div", {
name: "MuiPickersLayout",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({
display: "grid",
gridAutoColumns: "max-content auto max-content",
gridAutoRows: "max-content auto max-content",
[`& .${pickersLayoutClasses.actionBar}`]: {
gridColumn: "1 / 4",
gridRow: 3
},
variants: [
{
props: {
isLandscape: true
},
style: {
[`& .${pickersLayoutClasses.toolbar}`]: {
gridColumn: 1,
gridRow: "2 / 3"
},
[`.${pickersLayoutClasses.shortcuts}`]: {
gridColumn: "2 / 4",
gridRow: 1
}
}
},
{
props: {
isLandscape: true,
isRtl: true
},
style: {
[`& .${pickersLayoutClasses.toolbar}`]: {
gridColumn: 3
}
}
},
{
props: {
isLandscape: false
},
style: {
[`& .${pickersLayoutClasses.toolbar}`]: {
gridColumn: "2 / 4",
gridRow: 1
},
[`& .${pickersLayoutClasses.shortcuts}`]: {
gridColumn: 1,
gridRow: "2 / 3"
}
}
},
{
props: {
isLandscape: false,
isRtl: true
},
style: {
[`& .${pickersLayoutClasses.shortcuts}`]: {
gridColumn: 3
}
}
}
]
});
const PickersLayoutContentWrapper = styled("div", {
name: "MuiPickersLayout",
slot: "ContentWrapper",
overridesResolver: (props, styles2) => styles2.contentWrapper
})({
gridColumn: 2,
gridRow: 2,
display: "flex",
flexDirection: "column"
});
const PickersLayout = __mf_14(function PickersLayout2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersLayout"
});
const { toolbar, content, tabs, actionBar, shortcuts } = usePickerLayout(props);
const { sx, className, isLandscape, wrapperVariant } = props;
const classes = useUtilityClasses$3(props);
return jsxRuntimeExports.jsxs(PickersLayoutRoot, {
ref,
sx,
className: clsx(classes.root, className),
ownerState: props,
children: [
isLandscape ? shortcuts : toolbar,
isLandscape ? toolbar : shortcuts,
jsxRuntimeExports.jsx(PickersLayoutContentWrapper, {
className: classes.contentWrapper,
children: wrapperVariant === "desktop" ? jsxRuntimeExports.jsxs(__mf_2, {
children: [
content,
tabs
]
}) : jsxRuntimeExports.jsxs(__mf_2, {
children: [
tabs,
content
]
})
}),
actionBar
]
});
});
const _excluded$6 = [
"props",
"getOpenDialogAriaText"
], _excluded2 = [
"ownerState"
], _excluded3 = [
"ownerState"
];
const useDesktopPicker = (_ref) => {
var _a;
let { props, getOpenDialogAriaText } = _ref, pickerParams = _objectWithoutPropertiesLoose$3(_ref, _excluded$6);
const { slots, slotProps: innerSlotProps, className, sx, format, formatDensity, enableAccessibleFieldDOMStructure, selectedSections, onSelectedSectionsChange, timezone, name, label, inputRef, readOnly, disabled, autoFocus, localeText, reduceAnimations } = props;
const containerRef = __mf_31(null);
const fieldRef = __mf_31(null);
const labelId = useId();
const isToolbarHidden = ((_a = innerSlotProps == null ? void 0 : innerSlotProps.toolbar) == null ? void 0 : _a.hidden) ?? false;
const { open, actions, hasUIView, layoutProps, renderCurrentView, shouldRestoreFocus, fieldProps: pickerFieldProps, contextValue, ownerState } = usePicker(_extends$1({}, pickerParams, {
props,
fieldRef,
autoFocusView: true,
additionalViewProps: {},
wrapperVariant: "desktop"
}));
const InputAdornment$1 = slots.inputAdornment ?? InputAdornment;
const _useSlotProps = useSlotProps({
elementType: InputAdornment$1,
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.inputAdornment,
additionalProps: {
position: "end"
},
ownerState: props
}), inputAdornmentProps = _objectWithoutPropertiesLoose$3(_useSlotProps, _excluded2);
const OpenPickerButton = slots.openPickerButton ?? IconButton;
const _useSlotProps2 = useSlotProps({
elementType: OpenPickerButton,
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.openPickerButton,
additionalProps: {
disabled: disabled || readOnly,
onClick: open ? actions.onClose : actions.onOpen,
"aria-label": getOpenDialogAriaText(pickerFieldProps.value),
edge: inputAdornmentProps.position
},
ownerState: props
}), openPickerButtonProps = _objectWithoutPropertiesLoose$3(_useSlotProps2, _excluded3);
const OpenPickerIcon = slots.openPickerIcon;
const openPickerIconProps = useSlotProps({
elementType: OpenPickerIcon,
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.openPickerIcon,
ownerState
});
const Field = slots.field;
const fieldProps = useSlotProps({
elementType: Field,
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.field,
additionalProps: _extends$1({}, pickerFieldProps, isToolbarHidden && {
id: labelId
}, {
readOnly,
disabled,
className,
sx,
format,
formatDensity,
enableAccessibleFieldDOMStructure,
selectedSections,
onSelectedSectionsChange,
timezone,
label,
name,
autoFocus: autoFocus && !props.open,
focused: open ? true : void 0
}, inputRef ? {
inputRef
} : {}),
ownerState: props
});
if (hasUIView) {
fieldProps.InputProps = _extends$1({}, fieldProps.InputProps, {
ref: containerRef
}, !props.disableOpenPicker && {
[`${inputAdornmentProps.position}Adornment`]: jsxRuntimeExports.jsx(InputAdornment$1, _extends$1({}, inputAdornmentProps, {
children: jsxRuntimeExports.jsx(OpenPickerButton, _extends$1({}, openPickerButtonProps, {
children: jsxRuntimeExports.jsx(OpenPickerIcon, _extends$1({}, openPickerIconProps))
}))
}))
});
}
const slotsForField = _extends$1({
textField: slots.textField,
clearIcon: slots.clearIcon,
clearButton: slots.clearButton
}, fieldProps.slots);
const Layout = slots.layout ?? PickersLayout;
let labelledById = labelId;
if (isToolbarHidden) {
if (label) {
labelledById = `${labelId}-label`;
} else {
labelledById = void 0;
}
}
const slotProps = _extends$1({}, innerSlotProps, {
toolbar: _extends$1({}, innerSlotProps == null ? void 0 : innerSlotProps.toolbar, {
titleId: labelId
}),
popper: _extends$1({
"aria-labelledby": labelledById
}, innerSlotProps == null ? void 0 : innerSlotProps.popper)
});
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
const renderPicker = () => jsxRuntimeExports.jsxs(PickersProvider, {
contextValue,
localeText,
children: [
jsxRuntimeExports.jsx(Field, _extends$1({}, fieldProps, {
slots: slotsForField,
slotProps,
unstableFieldRef: handleFieldRef
})),
jsxRuntimeExports.jsx(PickersPopper, _extends$1({
role: "dialog",
placement: "bottom-start",
anchorEl: containerRef.current
}, actions, {
open,
slots,
slotProps,
shouldRestoreFocus,
reduceAnimations,
children: jsxRuntimeExports.jsx(Layout, _extends$1({}, layoutProps, slotProps == null ? void 0 : slotProps.layout, {
slots,
slotProps,
children: renderCurrentView()
}))
}))
]
});
return {
renderPicker
};
};
const renderDateViewCalendar = ({ view, onViewChange, views, focusedView, onFocusedViewChange, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minDate, maxDate, shouldDisableDate, shouldDisableMonth, shouldDisableYear, reduceAnimations, onMonthChange, monthsPerRow, onYearChange, yearsOrder, yearsPerRow, slots, slotProps, loading, renderLoading, disableHighlightToday, readOnly, disabled, showDaysOutsideCurrentMonth, dayOfWeekFormatter, sx, autoFocus, fixedWeekNumber, displayWeekNumber, timezone }) => jsxRuntimeExports.jsx(DateCalendar, {
view,
onViewChange,
views: views.filter(isDatePickerView),
focusedView: focusedView && isDatePickerView(focusedView) ? focusedView : null,
onFocusedViewChange,
value,
defaultValue,
referenceDate,
onChange,
className,
classes,
disableFuture,
disablePast,
minDate,
maxDate,
shouldDisableDate,
shouldDisableMonth,
shouldDisableYear,
reduceAnimations,
onMonthChange,
monthsPerRow,
onYearChange,
yearsOrder,
yearsPerRow,
slots,
slotProps,
loading,
renderLoading,
disableHighlightToday,
readOnly,
disabled,
showDaysOutsideCurrentMonth,
dayOfWeekFormatter,
sx,
autoFocus,
fixedWeekNumber,
displayWeekNumber,
timezone
});
const DesktopDatePicker = __mf_14(function DesktopDatePicker2(inProps, ref) {
var _a, _b;
const translations = usePickersTranslations();
const utils = useUtils();
const defaultizedProps = useDatePickerDefaultizedProps(inProps, "MuiDesktopDatePicker");
const viewRenderers = _extends$1({
day: renderDateViewCalendar,
month: renderDateViewCalendar,
year: renderDateViewCalendar
}, defaultizedProps.viewRenderers);
const props = _extends$1({}, defaultizedProps, {
viewRenderers,
format: resolveDateFormat(utils, defaultizedProps, false),
yearsPerRow: defaultizedProps.yearsPerRow ?? 4,
slots: _extends$1({
openPickerIcon: CalendarIcon,
field: DateField
}, defaultizedProps.slots),
slotProps: _extends$1({}, defaultizedProps.slotProps, {
field: (ownerState) => {
var _a2;
return _extends$1({}, resolveComponentProps((_a2 = defaultizedProps.slotProps) == null ? void 0 : _a2.field, ownerState), extractValidationProps(defaultizedProps), {
ref
});
},
toolbar: _extends$1({
hidden: true
}, (_a = defaultizedProps.slotProps) == null ? void 0 : _a.toolbar)
})
});
const { renderPicker } = useDesktopPicker({
props,
valueManager: singleItemValueManager,
valueType: "date",
getOpenDialogAriaText: buildGetOpenDialogAriaText({
utils,
formatKey: "fullDate",
contextTranslation: translations.openDatePickerDialogue,
propsTranslation: (_b = props.localeText) == null ? void 0 : _b.openDatePickerDialogue
}),
validator: validateDate
});
return renderPicker();
});
DesktopDatePicker.propTypes = {
autoFocus: PropTypes.bool,
className: PropTypes.string,
closeOnSelect: PropTypes.bool,
dayOfWeekFormatter: PropTypes.func,
defaultValue: PropTypes.object,
disabled: PropTypes.bool,
disableFuture: PropTypes.bool,
disableHighlightToday: PropTypes.bool,
disableOpenPicker: PropTypes.bool,
disablePast: PropTypes.bool,
displayWeekNumber: PropTypes.bool,
enableAccessibleFieldDOMStructure: PropTypes.any,
fixedWeekNumber: PropTypes.number,
format: PropTypes.string,
formatDensity: PropTypes.oneOf([
"dense",
"spacious"
]),
inputRef: refType,
label: PropTypes.node,
loading: PropTypes.bool,
localeText: PropTypes.object,
maxDate: PropTypes.object,
minDate: PropTypes.object,
monthsPerRow: PropTypes.oneOf([
3,
4
]),
name: PropTypes.string,
onAccept: PropTypes.func,
onChange: PropTypes.func,
onClose: PropTypes.func,
onError: PropTypes.func,
onMonthChange: PropTypes.func,
onOpen: PropTypes.func,
onSelectedSectionsChange: PropTypes.func,
onViewChange: PropTypes.func,
onYearChange: PropTypes.func,
open: PropTypes.bool,
openTo: PropTypes.oneOf([
"day",
"month",
"year"
]),
orientation: PropTypes.oneOf([
"landscape",
"portrait"
]),
readOnly: PropTypes.bool,
reduceAnimations: PropTypes.bool,
referenceDate: PropTypes.object,
renderLoading: PropTypes.func,
selectedSections: PropTypes.oneOfType([
PropTypes.oneOf([
"all",
"day",
"empty",
"hours",
"meridiem",
"minutes",
"month",
"seconds",
"weekDay",
"year"
]),
PropTypes.number
]),
shouldDisableDate: PropTypes.func,
shouldDisableMonth: PropTypes.func,
shouldDisableYear: PropTypes.func,
showDaysOutsideCurrentMonth: PropTypes.bool,
slotProps: PropTypes.object,
slots: PropTypes.object,
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.func,
PropTypes.object,
PropTypes.bool
])),
PropTypes.func,
PropTypes.object
]),
timezone: PropTypes.string,
value: PropTypes.object,
view: PropTypes.oneOf([
"day",
"month",
"year"
]),
viewRenderers: PropTypes.shape({
day: PropTypes.func,
month: PropTypes.func,
year: PropTypes.func
}),
views: PropTypes.arrayOf(PropTypes.oneOf([
"day",
"month",
"year"
]).isRequired),
yearsOrder: PropTypes.oneOf([
"asc",
"desc"
]),
yearsPerRow: PropTypes.oneOf([
3,
4
])
};
const PickersModalDialogRoot = styled(Dialog)({
[`& .${dialogClasses.container}`]: {
outline: 0
},
[`& .${dialogClasses.paper}`]: {
outline: 0,
minWidth: DIALOG_WIDTH
}
});
const PickersModalDialogContent = styled(DialogContent)({
"&:first-of-type": {
padding: 0
}
});
function PickersModalDialog(props) {
const { children, onDismiss, open, slots, slotProps } = props;
const Dialog2 = (slots == null ? void 0 : slots.dialog) ?? PickersModalDialogRoot;
const Transition2 = (slots == null ? void 0 : slots.mobileTransition) ?? Fade;
return jsxRuntimeExports.jsx(Dialog2, _extends$1({
open,
onClose: onDismiss
}, slotProps == null ? void 0 : slotProps.dialog, {
TransitionComponent: Transition2,
TransitionProps: slotProps == null ? void 0 : slotProps.mobileTransition,
PaperComponent: slots == null ? void 0 : slots.mobilePaper,
PaperProps: slotProps == null ? void 0 : slotProps.mobilePaper,
children: jsxRuntimeExports.jsx(PickersModalDialogContent, {
children
})
}));
}
const _excluded$5 = [
"props",
"getOpenDialogAriaText"
];
const useMobilePicker = (_ref) => {
var _a;
let { props, getOpenDialogAriaText } = _ref, pickerParams = _objectWithoutPropertiesLoose$3(_ref, _excluded$5);
const { slots, slotProps: innerSlotProps, className, sx, format, formatDensity, enableAccessibleFieldDOMStructure, selectedSections, onSelectedSectionsChange, timezone, name, label, inputRef, readOnly, disabled, localeText } = props;
const fieldRef = __mf_31(null);
const labelId = useId();
const isToolbarHidden = ((_a = innerSlotProps == null ? void 0 : innerSlotProps.toolbar) == null ? void 0 : _a.hidden) ?? false;
const { open, actions, layoutProps, renderCurrentView, fieldProps: pickerFieldProps, contextValue } = usePicker(_extends$1({}, pickerParams, {
props,
fieldRef,
autoFocusView: true,
additionalViewProps: {},
wrapperVariant: "mobile"
}));
const Field = slots.field;
const fieldProps = useSlotProps({
elementType: Field,
externalSlotProps: innerSlotProps == null ? void 0 : innerSlotProps.field,
additionalProps: _extends$1({}, pickerFieldProps, isToolbarHidden && {
id: labelId
}, !(disabled || readOnly) && {
onClick: actions.onOpen,
onKeyDown: onSpaceOrEnter(actions.onOpen)
}, {
readOnly: readOnly ?? true,
disabled,
className,
sx,
format,
formatDensity,
enableAccessibleFieldDOMStructure,
selectedSections,
onSelectedSectionsChange,
timezone,
label,
name
}, inputRef ? {
inputRef
} : {}),
ownerState: props
});
fieldProps.inputProps = _extends$1({}, fieldProps.inputProps, {
"aria-label": getOpenDialogAriaText(pickerFieldProps.value)
});
const slotsForField = _extends$1({
textField: slots.textField
}, fieldProps.slots);
const Layout = slots.layout ?? PickersLayout;
let labelledById = labelId;
if (isToolbarHidden) {
if (label) {
labelledById = `${labelId}-label`;
} else {
labelledById = void 0;
}
}
const slotProps = _extends$1({}, innerSlotProps, {
toolbar: _extends$1({}, innerSlotProps == null ? void 0 : innerSlotProps.toolbar, {
titleId: labelId
}),
mobilePaper: _extends$1({
"aria-labelledby": labelledById
}, innerSlotProps == null ? void 0 : innerSlotProps.mobilePaper)
});
const handleFieldRef = useForkRef(fieldRef, fieldProps.unstableFieldRef);
const renderPicker = () => jsxRuntimeExports.jsxs(PickersProvider, {
contextValue,
localeText,
children: [
jsxRuntimeExports.jsx(Field, _extends$1({}, fieldProps, {
slots: slotsForField,
slotProps,
unstableFieldRef: handleFieldRef
})),
jsxRuntimeExports.jsx(PickersModalDialog, _extends$1({}, actions, {
open,
slots,
slotProps,
children: jsxRuntimeExports.jsx(Layout, _extends$1({}, layoutProps, slotProps == null ? void 0 : slotProps.layout, {
slots,
slotProps,
children: renderCurrentView()
}))
}))
]
});
return {
renderPicker
};
};
const MobileDatePicker = __mf_14(function MobileDatePicker2(inProps, ref) {
var _a, _b;
const translations = usePickersTranslations();
const utils = useUtils();
const defaultizedProps = useDatePickerDefaultizedProps(inProps, "MuiMobileDatePicker");
const viewRenderers = _extends$1({
day: renderDateViewCalendar,
month: renderDateViewCalendar,
year: renderDateViewCalendar
}, defaultizedProps.viewRenderers);
const props = _extends$1({}, defaultizedProps, {
viewRenderers,
format: resolveDateFormat(utils, defaultizedProps, false),
slots: _extends$1({
field: DateField
}, defaultizedProps.slots),
slotProps: _extends$1({}, defaultizedProps.slotProps, {
field: (ownerState) => {
var _a2;
return _extends$1({}, resolveComponentProps((_a2 = defaultizedProps.slotProps) == null ? void 0 : _a2.field, ownerState), extractValidationProps(defaultizedProps), {
ref
});
},
toolbar: _extends$1({
hidden: false
}, (_a = defaultizedProps.slotProps) == null ? void 0 : _a.toolbar)
})
});
const { renderPicker } = useMobilePicker({
props,
valueManager: singleItemValueManager,
valueType: "date",
getOpenDialogAriaText: buildGetOpenDialogAriaText({
utils,
formatKey: "fullDate",
contextTranslation: translations.openDatePickerDialogue,
propsTranslation: (_b = props.localeText) == null ? void 0 : _b.openDatePickerDialogue
}),
validator: validateDate
});
return renderPicker();
});
MobileDatePicker.propTypes = {
autoFocus: PropTypes.bool,
className: PropTypes.string,
closeOnSelect: PropTypes.bool,
dayOfWeekFormatter: PropTypes.func,
defaultValue: PropTypes.object,
disabled: PropTypes.bool,
disableFuture: PropTypes.bool,
disableHighlightToday: PropTypes.bool,
disableOpenPicker: PropTypes.bool,
disablePast: PropTypes.bool,
displayWeekNumber: PropTypes.bool,
enableAccessibleFieldDOMStructure: PropTypes.any,
fixedWeekNumber: PropTypes.number,
format: PropTypes.string,
formatDensity: PropTypes.oneOf([
"dense",
"spacious"
]),
inputRef: refType,
label: PropTypes.node,
loading: PropTypes.bool,
localeText: PropTypes.object,
maxDate: PropTypes.object,
minDate: PropTypes.object,
monthsPerRow: PropTypes.oneOf([
3,
4
]),
name: PropTypes.string,
onAccept: PropTypes.func,
onChange: PropTypes.func,
onClose: PropTypes.func,
onError: PropTypes.func,
onMonthChange: PropTypes.func,
onOpen: PropTypes.func,
onSelectedSectionsChange: PropTypes.func,
onViewChange: PropTypes.func,
onYearChange: PropTypes.func,
open: PropTypes.bool,
openTo: PropTypes.oneOf([
"day",
"month",
"year"
]),
orientation: PropTypes.oneOf([
"landscape",
"portrait"
]),
readOnly: PropTypes.bool,
reduceAnimations: PropTypes.bool,
referenceDate: PropTypes.object,
renderLoading: PropTypes.func,
selectedSections: PropTypes.oneOfType([
PropTypes.oneOf([
"all",
"day",
"empty",
"hours",
"meridiem",
"minutes",
"month",
"seconds",
"weekDay",
"year"
]),
PropTypes.number
]),
shouldDisableDate: PropTypes.func,
shouldDisableMonth: PropTypes.func,
shouldDisableYear: PropTypes.func,
showDaysOutsideCurrentMonth: PropTypes.bool,
slotProps: PropTypes.object,
slots: PropTypes.object,
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.func,
PropTypes.object,
PropTypes.bool
])),
PropTypes.func,
PropTypes.object
]),
timezone: PropTypes.string,
value: PropTypes.object,
view: PropTypes.oneOf([
"day",
"month",
"year"
]),
viewRenderers: PropTypes.shape({
day: PropTypes.func,
month: PropTypes.func,
year: PropTypes.func
}),
views: PropTypes.arrayOf(PropTypes.oneOf([
"day",
"month",
"year"
]).isRequired),
yearsOrder: PropTypes.oneOf([
"asc",
"desc"
]),
yearsPerRow: PropTypes.oneOf([
3,
4
])
};
const _excluded$4 = [
"desktopModeMediaQuery"
];
const DatePicker = __mf_14(function DatePicker2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiDatePicker"
});
const { desktopModeMediaQuery = DEFAULT_DESKTOP_MODE_MEDIA_QUERY } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$4);
const isDesktop = useMediaQuery(desktopModeMediaQuery, {
defaultMatches: true
});
if (isDesktop) {
return jsxRuntimeExports.jsx(DesktopDatePicker, _extends$1({
ref
}, other));
}
return jsxRuntimeExports.jsx(MobileDatePicker, _extends$1({
ref
}, other));
});
function getPickersToolbarTextUtilityClass(slot) {
return generateUtilityClass("MuiPickersToolbarText", slot);
}
const pickersToolbarTextClasses = generateUtilityClasses("MuiPickersToolbarText", [
"root",
"selected"
]);
const _excluded$3 = [
"className",
"selected",
"value"
];
const useUtilityClasses$2 = (ownerState) => {
const { classes, selected } = ownerState;
const slots = {
root: [
"root",
selected && "selected"
]
};
return composeClasses(slots, getPickersToolbarTextUtilityClass, classes);
};
const PickersToolbarTextRoot = styled(Typography, {
name: "MuiPickersToolbarText",
slot: "Root",
overridesResolver: (_, styles2) => [
styles2.root,
{
[`&.${pickersToolbarTextClasses.selected}`]: styles2.selected
}
]
})(({ theme }) => ({
transition: theme.transitions.create("color"),
color: (theme.vars || theme).palette.text.secondary,
[`&.${pickersToolbarTextClasses.selected}`]: {
color: (theme.vars || theme).palette.text.primary
}
}));
const PickersToolbarText = __mf_14(function PickersToolbarText2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersToolbarText"
});
const { className, value } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$3);
const classes = useUtilityClasses$2(props);
return jsxRuntimeExports.jsx(PickersToolbarTextRoot, _extends$1({
ref,
className: clsx(classes.root, className),
component: "span"
}, other, {
children: value
}));
});
const _excluded$2 = [
"align",
"className",
"selected",
"typographyClassName",
"value",
"variant",
"width"
];
const useUtilityClasses$1 = (ownerState) => {
const { classes } = ownerState;
const slots = {
root: [
"root"
]
};
return composeClasses(slots, getPickersToolbarUtilityClass, classes);
};
const PickersToolbarButtonRoot = styled(Button, {
name: "MuiPickersToolbarButton",
slot: "Root",
overridesResolver: (_, styles2) => styles2.root
})({
padding: 0,
minWidth: 16,
textTransform: "none"
});
const PickersToolbarButton = __mf_14(function PickersToolbarButton2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiPickersToolbarButton"
});
const { align, className, selected, typographyClassName, value, variant, width } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$2);
const classes = useUtilityClasses$1(props);
return jsxRuntimeExports.jsx(PickersToolbarButtonRoot, _extends$1({
variant: "text",
ref,
className: clsx(classes.root, className)
}, width ? {
sx: {
width
}
} : {}, other, {
children: jsxRuntimeExports.jsx(PickersToolbarText, {
align,
className: typographyClassName,
variant,
value,
selected
})
}));
});
function getTimePickerToolbarUtilityClass(slot) {
return generateUtilityClass("MuiTimePickerToolbar", slot);
}
const timePickerToolbarClasses = generateUtilityClasses("MuiTimePickerToolbar", [
"root",
"separator",
"hourMinuteLabel",
"hourMinuteLabelLandscape",
"hourMinuteLabelReverse",
"ampmSelection",
"ampmLandscape",
"ampmLabel"
]);
const _excluded$1 = [
"ampm",
"ampmInClock",
"value",
"isLandscape",
"onChange",
"view",
"onViewChange",
"views",
"disabled",
"readOnly",
"className"
];
const useUtilityClasses = (ownerState) => {
const { isLandscape, classes, isRtl } = ownerState;
const slots = {
root: [
"root"
],
separator: [
"separator"
],
hourMinuteLabel: [
"hourMinuteLabel",
isLandscape && "hourMinuteLabelLandscape",
isRtl && "hourMinuteLabelReverse"
],
ampmSelection: [
"ampmSelection",
isLandscape && "ampmLandscape"
],
ampmLabel: [
"ampmLabel"
]
};
return composeClasses(slots, getTimePickerToolbarUtilityClass, classes);
};
const TimePickerToolbarRoot = styled(PickersToolbar, {
name: "MuiTimePickerToolbar",
slot: "Root",
overridesResolver: (props, styles2) => styles2.root
})({});
const TimePickerToolbarSeparator = styled(PickersToolbarText, {
name: "MuiTimePickerToolbar",
slot: "Separator",
overridesResolver: (props, styles2) => styles2.separator
})({
outline: 0,
margin: "0 4px 0 2px",
cursor: "default"
});
const TimePickerToolbarHourMinuteLabel = styled("div", {
name: "MuiTimePickerToolbar",
slot: "HourMinuteLabel",
overridesResolver: (props, styles2) => [
{
[`&.${timePickerToolbarClasses.hourMinuteLabelLandscape}`]: styles2.hourMinuteLabelLandscape,
[`&.${timePickerToolbarClasses.hourMinuteLabelReverse}`]: styles2.hourMinuteLabelReverse
},
styles2.hourMinuteLabel
]
})({
display: "flex",
justifyContent: "flex-end",
alignItems: "flex-end",
variants: [
{
props: {
isRtl: true
},
style: {
flexDirection: "row-reverse"
}
},
{
props: {
isLandscape: true
},
style: {
marginTop: "auto"
}
}
]
});
const TimePickerToolbarAmPmSelection = styled("div", {
name: "MuiTimePickerToolbar",
slot: "AmPmSelection",
overridesResolver: (props, styles2) => [
{
[`.${timePickerToolbarClasses.ampmLabel}`]: styles2.ampmLabel
},
{
[`&.${timePickerToolbarClasses.ampmLandscape}`]: styles2.ampmLandscape
},
styles2.ampmSelection
]
})({
display: "flex",
flexDirection: "column",
marginRight: "auto",
marginLeft: 12,
[`& .${timePickerToolbarClasses.ampmLabel}`]: {
fontSize: 17
},
variants: [
{
props: {
isLandscape: true
},
style: {
margin: "4px 0 auto",
flexDirection: "row",
justifyContent: "space-around",
flexBasis: "100%"
}
}
]
});
function TimePickerToolbar(inProps) {
const props = useThemeProps({
props: inProps,
name: "MuiTimePickerToolbar"
});
const { ampm, ampmInClock, value, isLandscape, onChange, view, onViewChange, views, disabled, readOnly, className } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded$1);
const utils = useUtils();
const translations = usePickersTranslations();
const isRtl = useRtl();
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes("hours"));
const { meridiemMode, handleMeridiemChange } = useMeridiemMode(value, ampm, onChange);
const formatHours = (time) => ampm ? utils.format(time, "hours12h") : utils.format(time, "hours24h");
const ownerState = _extends$1({}, props, {
isRtl
});
const classes = useUtilityClasses(ownerState);
const separator = jsxRuntimeExports.jsx(TimePickerToolbarSeparator, {
tabIndex: -1,
value: ":",
variant: "h3",
selected: false,
className: classes.separator
});
return jsxRuntimeExports.jsxs(TimePickerToolbarRoot, _extends$1({
landscapeDirection: "row",
toolbarTitle: translations.timePickerToolbarTitle,
isLandscape,
ownerState,
className: clsx(classes.root, className)
}, other, {
children: [
jsxRuntimeExports.jsxs(TimePickerToolbarHourMinuteLabel, {
className: classes.hourMinuteLabel,
ownerState,
children: [
arrayIncludes(views, "hours") && jsxRuntimeExports.jsx(PickersToolbarButton, {
tabIndex: -1,
variant: "h3",
onClick: () => onViewChange("hours"),
selected: view === "hours",
value: value ? formatHours(value) : "--"
}),
arrayIncludes(views, [
"hours",
"minutes"
]) && separator,
arrayIncludes(views, "minutes") && jsxRuntimeExports.jsx(PickersToolbarButton, {
tabIndex: -1,
variant: "h3",
onClick: () => onViewChange("minutes"),
selected: view === "minutes",
value: value ? utils.format(value, "minutes") : "--"
}),
arrayIncludes(views, [
"minutes",
"seconds"
]) && separator,
arrayIncludes(views, "seconds") && jsxRuntimeExports.jsx(PickersToolbarButton, {
variant: "h3",
onClick: () => onViewChange("seconds"),
selected: view === "seconds",
value: value ? utils.format(value, "seconds") : "--"
})
]
}),
showAmPmControl && jsxRuntimeExports.jsxs(TimePickerToolbarAmPmSelection, {
className: classes.ampmSelection,
ownerState,
children: [
jsxRuntimeExports.jsx(PickersToolbarButton, {
disableRipple: true,
variant: "subtitle2",
selected: meridiemMode === "am",
typographyClassName: classes.ampmLabel,
value: formatMeridiem(utils, "am"),
onClick: readOnly ? void 0 : () => handleMeridiemChange("am"),
disabled
}),
jsxRuntimeExports.jsx(PickersToolbarButton, {
disableRipple: true,
variant: "subtitle2",
selected: meridiemMode === "pm",
typographyClassName: classes.ampmLabel,
value: formatMeridiem(utils, "pm"),
onClick: readOnly ? void 0 : () => handleMeridiemChange("pm"),
disabled
})
]
})
]
}));
}
function useTimePickerDefaultizedProps(props, name) {
var _a;
const utils = useUtils();
const themeProps = useThemeProps({
props,
name
});
const ampm = themeProps.ampm ?? utils.is12HourCycleInCurrentLocale();
const localeText = __mf_29(() => {
var _a2;
if (((_a2 = themeProps.localeText) == null ? void 0 : _a2.toolbarTitle) == null) {
return themeProps.localeText;
}
return _extends$1({}, themeProps.localeText, {
timePickerToolbarTitle: themeProps.localeText.toolbarTitle
});
}, [
themeProps.localeText
]);
return _extends$1({}, themeProps, {
ampm,
localeText
}, applyDefaultViewProps({
views: themeProps.views,
openTo: themeProps.openTo,
defaultViews: [
"hours",
"minutes"
],
defaultOpenTo: "hours"
}), {
disableFuture: themeProps.disableFuture ?? false,
disablePast: themeProps.disablePast ?? false,
slots: _extends$1({
toolbar: TimePickerToolbar
}, themeProps.slots),
slotProps: _extends$1({}, themeProps.slotProps, {
toolbar: _extends$1({
ampm,
ampmInClock: themeProps.ampmInClock
}, (_a = themeProps.slotProps) == null ? void 0 : _a.toolbar)
})
});
}
const renderTimeViewClock = ({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, minutesStep, ampm, ampmInClock, slots, slotProps, readOnly, disabled, sx, autoFocus, showViewSwitcher, disableIgnoringDatePartForTimeValidation, timezone }) => jsxRuntimeExports.jsx(TimeClock, {
view,
onViewChange,
focusedView: focusedView && isTimeView(focusedView) ? focusedView : null,
onFocusedViewChange,
views: views.filter(isTimeView),
value,
defaultValue,
referenceDate,
onChange,
className,
classes,
disableFuture,
disablePast,
minTime,
maxTime,
shouldDisableTime,
minutesStep,
ampm,
ampmInClock,
slots,
slotProps,
readOnly,
disabled,
sx,
autoFocus,
showViewSwitcher,
disableIgnoringDatePartForTimeValidation,
timezone
});
const renderDigitalClockTimeView = ({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, minutesStep, ampm, slots, slotProps, readOnly, disabled, sx, autoFocus, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timezone }) => jsxRuntimeExports.jsx(DigitalClock, {
view,
onViewChange,
focusedView,
onFocusedViewChange,
views: views.filter(isTimeView),
value,
defaultValue,
referenceDate,
onChange,
className,
classes,
disableFuture,
disablePast,
minTime,
maxTime,
shouldDisableTime,
minutesStep,
ampm,
slots,
slotProps,
readOnly,
disabled,
sx,
autoFocus,
disableIgnoringDatePartForTimeValidation,
timeStep: timeSteps == null ? void 0 : timeSteps.minutes,
skipDisabled,
timezone
});
const renderMultiSectionDigitalClockTimeView = ({ view, onViewChange, focusedView, onFocusedViewChange, views, value, defaultValue, referenceDate, onChange, className, classes, disableFuture, disablePast, minTime, maxTime, shouldDisableTime, minutesStep, ampm, slots, slotProps, readOnly, disabled, sx, autoFocus, disableIgnoringDatePartForTimeValidation, timeSteps, skipDisabled, timezone }) => jsxRuntimeExports.jsx(MultiSectionDigitalClock, {
view,
onViewChange,
focusedView,
onFocusedViewChange,
views: views.filter(isTimeView),
value,
defaultValue,
referenceDate,
onChange,
className,
classes,
disableFuture,
disablePast,
minTime,
maxTime,
shouldDisableTime,
minutesStep,
ampm,
slots,
slotProps,
readOnly,
disabled,
sx,
autoFocus,
disableIgnoringDatePartForTimeValidation,
timeSteps,
skipDisabled,
timezone
});
const resolveViews = (ampm, views, shouldUseSingleColumn) => {
if (shouldUseSingleColumn) {
return views.filter((view) => !isInternalTimeView(view) || view === "hours");
}
return ampm ? [
...views,
"meridiem"
] : views;
};
const resolveShouldRenderTimeInASingleColumn = (timeSteps, threshold) => 24 * 60 / ((timeSteps.hours ?? 1) * (timeSteps.minutes ?? 5)) <= threshold;
function resolveTimeViewsResponse({ thresholdToRenderTimeInASingleColumn: inThreshold, ampm, timeSteps: inTimeSteps, views }) {
const thresholdToRenderTimeInASingleColumn = inThreshold ?? 24;
const timeSteps = _extends$1({
hours: 1,
minutes: 5,
seconds: 5
}, inTimeSteps);
const shouldRenderTimeInASingleColumn = resolveShouldRenderTimeInASingleColumn(timeSteps, thresholdToRenderTimeInASingleColumn);
return {
thresholdToRenderTimeInASingleColumn,
timeSteps,
shouldRenderTimeInASingleColumn,
views: resolveViews(ampm, views, shouldRenderTimeInASingleColumn)
};
}
const DesktopTimePicker = __mf_14(function DesktopTimePicker2(inProps, ref) {
var _a, _b, _c, _d;
const translations = usePickersTranslations();
const utils = useUtils();
const defaultizedProps = useTimePickerDefaultizedProps(inProps, "MuiDesktopTimePicker");
const { shouldRenderTimeInASingleColumn, views: resolvedViews, timeSteps } = resolveTimeViewsResponse(defaultizedProps);
const renderTimeView = shouldRenderTimeInASingleColumn ? renderDigitalClockTimeView : renderMultiSectionDigitalClockTimeView;
const viewRenderers = _extends$1({
hours: renderTimeView,
minutes: renderTimeView,
seconds: renderTimeView,
meridiem: renderTimeView
}, defaultizedProps.viewRenderers);
const ampmInClock = defaultizedProps.ampmInClock ?? true;
const actionBarActions = shouldRenderTimeInASingleColumn ? [] : [
"accept"
];
const shouldHoursRendererContainMeridiemView = ((_a = viewRenderers.hours) == null ? void 0 : _a.name) === renderMultiSectionDigitalClockTimeView.name;
const views = !shouldHoursRendererContainMeridiemView ? resolvedViews.filter((view) => view !== "meridiem") : resolvedViews;
const props = _extends$1({}, defaultizedProps, {
ampmInClock,
timeSteps,
viewRenderers,
format: resolveTimeFormat(utils, defaultizedProps),
views: shouldRenderTimeInASingleColumn ? [
"hours"
] : views,
slots: _extends$1({
field: TimeField,
openPickerIcon: ClockIcon
}, defaultizedProps.slots),
slotProps: _extends$1({}, defaultizedProps.slotProps, {
field: (ownerState) => {
var _a2;
return _extends$1({}, resolveComponentProps((_a2 = defaultizedProps.slotProps) == null ? void 0 : _a2.field, ownerState), extractValidationProps(defaultizedProps), {
ref
});
},
toolbar: _extends$1({
hidden: true,
ampmInClock
}, (_b = defaultizedProps.slotProps) == null ? void 0 : _b.toolbar),
actionBar: _extends$1({
actions: actionBarActions
}, (_c = defaultizedProps.slotProps) == null ? void 0 : _c.actionBar)
})
});
const { renderPicker } = useDesktopPicker({
props,
valueManager: singleItemValueManager,
valueType: "time",
getOpenDialogAriaText: buildGetOpenDialogAriaText({
utils,
formatKey: "fullTime",
contextTranslation: translations.openTimePickerDialogue,
propsTranslation: (_d = props.localeText) == null ? void 0 : _d.openTimePickerDialogue
}),
validator: validateTime
});
return renderPicker();
});
DesktopTimePicker.propTypes = {
ampm: PropTypes.bool,
ampmInClock: PropTypes.bool,
autoFocus: PropTypes.bool,
className: PropTypes.string,
closeOnSelect: PropTypes.bool,
defaultValue: PropTypes.object,
disabled: PropTypes.bool,
disableFuture: PropTypes.bool,
disableIgnoringDatePartForTimeValidation: PropTypes.bool,
disableOpenPicker: PropTypes.bool,
disablePast: PropTypes.bool,
enableAccessibleFieldDOMStructure: PropTypes.any,
format: PropTypes.string,
formatDensity: PropTypes.oneOf([
"dense",
"spacious"
]),
inputRef: refType,
label: PropTypes.node,
localeText: PropTypes.object,
maxTime: PropTypes.object,
minTime: PropTypes.object,
minutesStep: PropTypes.number,
name: PropTypes.string,
onAccept: PropTypes.func,
onChange: PropTypes.func,
onClose: PropTypes.func,
onError: PropTypes.func,
onOpen: PropTypes.func,
onSelectedSectionsChange: PropTypes.func,
onViewChange: PropTypes.func,
open: PropTypes.bool,
openTo: PropTypes.oneOf([
"hours",
"meridiem",
"minutes",
"seconds"
]),
orientation: PropTypes.oneOf([
"landscape",
"portrait"
]),
readOnly: PropTypes.bool,
reduceAnimations: PropTypes.bool,
referenceDate: PropTypes.object,
selectedSections: PropTypes.oneOfType([
PropTypes.oneOf([
"all",
"day",
"empty",
"hours",
"meridiem",
"minutes",
"month",
"seconds",
"weekDay",
"year"
]),
PropTypes.number
]),
shouldDisableTime: PropTypes.func,
skipDisabled: PropTypes.bool,
slotProps: PropTypes.object,
slots: PropTypes.object,
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.func,
PropTypes.object,
PropTypes.bool
])),
PropTypes.func,
PropTypes.object
]),
thresholdToRenderTimeInASingleColumn: PropTypes.number,
timeSteps: PropTypes.shape({
hours: PropTypes.number,
minutes: PropTypes.number,
seconds: PropTypes.number
}),
timezone: PropTypes.string,
value: PropTypes.object,
view: PropTypes.oneOf([
"hours",
"meridiem",
"minutes",
"seconds"
]),
viewRenderers: PropTypes.shape({
hours: PropTypes.func,
meridiem: PropTypes.func,
minutes: PropTypes.func,
seconds: PropTypes.func
}),
views: PropTypes.arrayOf(PropTypes.oneOf([
"hours",
"minutes",
"seconds"
]).isRequired)
};
const MobileTimePicker = __mf_14(function MobileTimePicker2(inProps, ref) {
var _a, _b;
const translations = usePickersTranslations();
const utils = useUtils();
const defaultizedProps = useTimePickerDefaultizedProps(inProps, "MuiMobileTimePicker");
const viewRenderers = _extends$1({
hours: renderTimeViewClock,
minutes: renderTimeViewClock,
seconds: renderTimeViewClock
}, defaultizedProps.viewRenderers);
const ampmInClock = defaultizedProps.ampmInClock ?? false;
const props = _extends$1({}, defaultizedProps, {
ampmInClock,
viewRenderers,
format: resolveTimeFormat(utils, defaultizedProps),
slots: _extends$1({
field: TimeField
}, defaultizedProps.slots),
slotProps: _extends$1({}, defaultizedProps.slotProps, {
field: (ownerState) => {
var _a2;
return _extends$1({}, resolveComponentProps((_a2 = defaultizedProps.slotProps) == null ? void 0 : _a2.field, ownerState), extractValidationProps(defaultizedProps), {
ref
});
},
toolbar: _extends$1({
hidden: false,
ampmInClock
}, (_a = defaultizedProps.slotProps) == null ? void 0 : _a.toolbar)
})
});
const { renderPicker } = useMobilePicker({
props,
valueManager: singleItemValueManager,
valueType: "time",
getOpenDialogAriaText: buildGetOpenDialogAriaText({
utils,
formatKey: "fullTime",
contextTranslation: translations.openTimePickerDialogue,
propsTranslation: (_b = props.localeText) == null ? void 0 : _b.openTimePickerDialogue
}),
validator: validateTime
});
return renderPicker();
});
MobileTimePicker.propTypes = {
ampm: PropTypes.bool,
ampmInClock: PropTypes.bool,
autoFocus: PropTypes.bool,
className: PropTypes.string,
closeOnSelect: PropTypes.bool,
defaultValue: PropTypes.object,
disabled: PropTypes.bool,
disableFuture: PropTypes.bool,
disableIgnoringDatePartForTimeValidation: PropTypes.bool,
disableOpenPicker: PropTypes.bool,
disablePast: PropTypes.bool,
enableAccessibleFieldDOMStructure: PropTypes.any,
format: PropTypes.string,
formatDensity: PropTypes.oneOf([
"dense",
"spacious"
]),
inputRef: refType,
label: PropTypes.node,
localeText: PropTypes.object,
maxTime: PropTypes.object,
minTime: PropTypes.object,
minutesStep: PropTypes.number,
name: PropTypes.string,
onAccept: PropTypes.func,
onChange: PropTypes.func,
onClose: PropTypes.func,
onError: PropTypes.func,
onOpen: PropTypes.func,
onSelectedSectionsChange: PropTypes.func,
onViewChange: PropTypes.func,
open: PropTypes.bool,
openTo: PropTypes.oneOf([
"hours",
"minutes",
"seconds"
]),
orientation: PropTypes.oneOf([
"landscape",
"portrait"
]),
readOnly: PropTypes.bool,
reduceAnimations: PropTypes.bool,
referenceDate: PropTypes.object,
selectedSections: PropTypes.oneOfType([
PropTypes.oneOf([
"all",
"day",
"empty",
"hours",
"meridiem",
"minutes",
"month",
"seconds",
"weekDay",
"year"
]),
PropTypes.number
]),
shouldDisableTime: PropTypes.func,
slotProps: PropTypes.object,
slots: PropTypes.object,
sx: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.func,
PropTypes.object,
PropTypes.bool
])),
PropTypes.func,
PropTypes.object
]),
timezone: PropTypes.string,
value: PropTypes.object,
view: PropTypes.oneOf([
"hours",
"minutes",
"seconds"
]),
viewRenderers: PropTypes.shape({
hours: PropTypes.func,
minutes: PropTypes.func,
seconds: PropTypes.func
}),
views: PropTypes.arrayOf(PropTypes.oneOf([
"hours",
"minutes",
"seconds"
]).isRequired)
};
const _excluded = [
"desktopModeMediaQuery"
];
const TimePicker = __mf_14(function TimePicker2(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: "MuiTimePicker"
});
const { desktopModeMediaQuery = DEFAULT_DESKTOP_MODE_MEDIA_QUERY } = props, other = _objectWithoutPropertiesLoose$3(props, _excluded);
const isDesktop = useMediaQuery(desktopModeMediaQuery, {
defaultMatches: true
});
if (isDesktop) {
return jsxRuntimeExports.jsx(DesktopTimePicker, _extends$1({
ref
}, other));
}
return jsxRuntimeExports.jsx(MobileTimePicker, _extends$1({
ref
}, other));
});
var weekOfYear$1 = {
exports: {}
};
var weekOfYear = weekOfYear$1.exports;
(function(module, exports$1) {
!(function(e2, t) {
module.exports = t();
})(weekOfYear, (function() {
var e2 = "week", t = "year";
return function(i, n2, r2) {
var f2 = n2.prototype;
f2.week = function(i2) {
if (void 0 === i2 && (i2 = null), null !== i2) return this.add(7 * (i2 - this.week()), "day");
var n3 = this.$locale().yearStart || 1;
if (11 === this.month() && this.date() > 25) {
var f3 = r2(this).startOf(t).add(1, t).date(n3), s = r2(this).endOf(e2);
if (f3.isBefore(s)) return 1;
}
var a = r2(this).startOf(t).date(n3).startOf(e2).subtract(1, "millisecond"), o = this.diff(a, e2, true);
return o < 0 ? r2(this).startOf("week").week() : Math.ceil(o);
}, f2.weeks = function(e3) {
return void 0 === e3 && (e3 = null), this.week(e3);
};
};
}));
})(weekOfYear$1);
var weekOfYearExports = weekOfYear$1.exports;
const weekOfYearPlugin = getDefaultExportFromCjs(weekOfYearExports);
var customParseFormat$1 = {
exports: {}
};
var customParseFormat = customParseFormat$1.exports;
(function(module, exports$1) {
!(function(e2, t) {
module.exports = t();
})(customParseFormat, (function() {
var e2 = {
LTS: "h:mm:ss A",
LT: "h:mm A",
L: "MM/DD/YYYY",
LL: "MMMM D, YYYY",
LLL: "MMMM D, YYYY h:mm A",
LLLL: "dddd, MMMM D, YYYY h:mm A"
}, t = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, n2 = /\d/, r2 = /\d\d/, i = /\d\d?/, o = /\d*[^-_:/,()\s\d]+/, s = {}, a = function(e3) {
return (e3 = +e3) + (e3 > 68 ? 1900 : 2e3);
};
var f2 = function(e3) {
return function(t2) {
this[e3] = +t2;
};
}, h2 = [
/[+-]\d\d:?(\d\d)?|Z/,
function(e3) {
(this.zone || (this.zone = {})).offset = (function(e4) {
if (!e4) return 0;
if ("Z" === e4) return 0;
var t2 = e4.match(/([+-]|\d\d)/g), n3 = 60 * t2[1] + (+t2[2] || 0);
return 0 === n3 ? 0 : "+" === t2[0] ? -n3 : n3;
})(e3);
}
], u2 = function(e3) {
var t2 = s[e3];
return t2 && (t2.indexOf ? t2 : t2.s.concat(t2.f));
}, d2 = function(e3, t2) {
var n3, r3 = s.meridiem;
if (r3) {
for (var i2 = 1; i2 <= 24; i2 += 1) if (e3.indexOf(r3(i2, 0, t2)) > -1) {
n3 = i2 > 12;
break;
}
} else n3 = e3 === (t2 ? "pm" : "PM");
return n3;
}, c2 = {
A: [
o,
function(e3) {
this.afternoon = d2(e3, false);
}
],
a: [
o,
function(e3) {
this.afternoon = d2(e3, true);
}
],
Q: [
n2,
function(e3) {
this.month = 3 * (e3 - 1) + 1;
}
],
S: [
n2,
function(e3) {
this.milliseconds = 100 * +e3;
}
],
SS: [
r2,
function(e3) {
this.milliseconds = 10 * +e3;
}
],
SSS: [
/\d{3}/,
function(e3) {
this.milliseconds = +e3;
}
],
s: [
i,
f2("seconds")
],
ss: [
i,
f2("seconds")
],
m: [
i,
f2("minutes")
],
mm: [
i,
f2("minutes")
],
H: [
i,
f2("hours")
],
h: [
i,
f2("hours")
],
HH: [
i,
f2("hours")
],
hh: [
i,
f2("hours")
],
D: [
i,
f2("day")
],
DD: [
r2,
f2("day")
],
Do: [
o,
function(e3) {
var t2 = s.ordinal, n3 = e3.match(/\d+/);
if (this.day = n3[0], t2) for (var r3 = 1; r3 <= 31; r3 += 1) t2(r3).replace(/\[|\]/g, "") === e3 && (this.day = r3);
}
],
w: [
i,
f2("week")
],
ww: [
r2,
f2("week")
],
M: [
i,
f2("month")
],
MM: [
r2,
f2("month")
],
MMM: [
o,
function(e3) {
var t2 = u2("months"), n3 = (u2("monthsShort") || t2.map((function(e4) {
return e4.slice(0, 3);
}))).indexOf(e3) + 1;
if (n3 < 1) throw new Error();
this.month = n3 % 12 || n3;
}
],
MMMM: [
o,
function(e3) {
var t2 = u2("months").indexOf(e3) + 1;
if (t2 < 1) throw new Error();
this.month = t2 % 12 || t2;
}
],
Y: [
/[+-]?\d+/,
f2("year")
],
YY: [
r2,
function(e3) {
this.year = a(e3);
}
],
YYYY: [
/\d{4}/,
f2("year")
],
Z: h2,
ZZ: h2
};
function l2(n3) {
var r3, i2;
r3 = n3, i2 = s && s.formats;
for (var o2 = (n3 = r3.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(t2, n4, r4) {
var o3 = r4 && r4.toUpperCase();
return n4 || i2[r4] || e2[r4] || i2[o3].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(e3, t3, n5) {
return t3 || n5.slice(1);
}));
}))).match(t), a2 = o2.length, f3 = 0; f3 < a2; f3 += 1) {
var h3 = o2[f3], u3 = c2[h3], d3 = u3 && u3[0], l3 = u3 && u3[1];
o2[f3] = l3 ? {
regex: d3,
parser: l3
} : h3.replace(/^\[|\]$/g, "");
}
return function(e3) {
for (var t2 = {}, n4 = 0, r4 = 0; n4 < a2; n4 += 1) {
var i3 = o2[n4];
if ("string" == typeof i3) r4 += i3.length;
else {
var s2 = i3.regex, f4 = i3.parser, h4 = e3.slice(r4), u4 = s2.exec(h4)[0];
f4.call(t2, u4), e3 = e3.replace(u4, "");
}
}
return (function(e4) {
var t3 = e4.afternoon;
if (void 0 !== t3) {
var n5 = e4.hours;
t3 ? n5 < 12 && (e4.hours += 12) : 12 === n5 && (e4.hours = 0), delete e4.afternoon;
}
})(t2), t2;
};
}
return function(e3, t2, n3) {
n3.p.customParseFormat = true, e3 && e3.parseTwoDigitYear && (a = e3.parseTwoDigitYear);
var r3 = t2.prototype, i2 = r3.parse;
r3.parse = function(e4) {
var t3 = e4.date, r4 = e4.utc, o2 = e4.args;
this.$u = r4;
var a2 = o2[1];
if ("string" == typeof a2) {
var f3 = true === o2[2], h3 = true === o2[3], u3 = f3 || h3, d3 = o2[2];
h3 && (d3 = o2[2]), s = this.$locale(), !f3 && d3 && (s = n3.Ls[d3]), this.$d = (function(e5, t4, n4, r5) {
try {
if ([
"x",
"X"
].indexOf(t4) > -1) return new Date(("X" === t4 ? 1e3 : 1) * e5);
var i3 = l2(t4)(e5), o3 = i3.year, s2 = i3.month, a3 = i3.day, f4 = i3.hours, h4 = i3.minutes, u4 = i3.seconds, d4 = i3.milliseconds, c4 = i3.zone, m3 = i3.week, M2 = /* @__PURE__ */ new Date(), Y = a3 || (o3 || s2 ? 1 : M2.getDate()), p2 = o3 || M2.getFullYear(), v2 = 0;
o3 && !s2 || (v2 = s2 > 0 ? s2 - 1 : M2.getMonth());
var D2, w2 = f4 || 0, g2 = h4 || 0, y2 = u4 || 0, L = d4 || 0;
return c4 ? new Date(Date.UTC(p2, v2, Y, w2, g2, y2, L + 60 * c4.offset * 1e3)) : n4 ? new Date(Date.UTC(p2, v2, Y, w2, g2, y2, L)) : (D2 = new Date(p2, v2, Y, w2, g2, y2, L), m3 && (D2 = r5(D2).week(m3).toDate()), D2);
} catch (e6) {
return /* @__PURE__ */ new Date("");
}
})(t3, a2, r4, n3), this.init(), d3 && true !== d3 && (this.$L = this.locale(d3).$L), u3 && t3 != this.format(a2) && (this.$d = /* @__PURE__ */ new Date("")), s = {};
} else if (a2 instanceof Array) for (var c3 = a2.length, m2 = 1; m2 <= c3; m2 += 1) {
o2[1] = a2[m2 - 1];
var M = n3.apply(this, o2);
if (M.isValid()) {
this.$d = M.$d, this.$L = M.$L, this.init();
break;
}
m2 === c3 && (this.$d = /* @__PURE__ */ new Date(""));
}
else i2.call(this, e4);
};
};
}));
})(customParseFormat$1);
var customParseFormatExports = customParseFormat$1.exports;
const customParseFormatPlugin = getDefaultExportFromCjs(customParseFormatExports);
var localizedFormat$1 = {
exports: {}
};
var localizedFormat = localizedFormat$1.exports;
(function(module, exports$1) {
!(function(e2, t) {
module.exports = t();
})(localizedFormat, (function() {
var e2 = {
LTS: "h:mm:ss A",
LT: "h:mm A",
L: "MM/DD/YYYY",
LL: "MMMM D, YYYY",
LLL: "MMMM D, YYYY h:mm A",
LLLL: "dddd, MMMM D, YYYY h:mm A"
};
return function(t, o, n2) {
var r2 = o.prototype, i = r2.format;
n2.en.formats = e2, r2.format = function(t2) {
void 0 === t2 && (t2 = "YYYY-MM-DDTHH:mm:ssZ");
var o2 = this.$locale().formats, n3 = (function(t3, o3) {
return t3.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(t4, n4, r3) {
var i2 = r3 && r3.toUpperCase();
return n4 || o3[r3] || e2[r3] || o3[i2].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(e3, t5, o4) {
return t5 || o4.slice(1);
}));
}));
})(t2, void 0 === o2 ? {} : o2);
return i.call(this, n3);
};
};
}));
})(localizedFormat$1);
var localizedFormatExports = localizedFormat$1.exports;
const localizedFormatPlugin = getDefaultExportFromCjs(localizedFormatExports);
var isBetween$1 = {
exports: {}
};
var isBetween = isBetween$1.exports;
(function(module, exports$1) {
!(function(e2, i) {
module.exports = i();
})(isBetween, (function() {
return function(e2, i, t) {
i.prototype.isBetween = function(e3, i2, s, f2) {
var n2 = t(e3), o = t(i2), r2 = "(" === (f2 = f2 || "()")[0], u2 = ")" === f2[1];
return (r2 ? this.isAfter(n2, s) : !this.isBefore(n2, s)) && (u2 ? this.isBefore(o, s) : !this.isAfter(o, s)) || (r2 ? this.isBefore(n2, s) : !this.isAfter(n2, s)) && (u2 ? this.isAfter(o, s) : !this.isBefore(o, s));
};
};
}));
})(isBetween$1);
var isBetweenExports = isBetween$1.exports;
const isBetweenPlugin = getDefaultExportFromCjs(isBetweenExports);
var advancedFormat$1 = {
exports: {}
};
var advancedFormat = advancedFormat$1.exports;
(function(module, exports$1) {
!(function(e2, t) {
module.exports = t();
})(advancedFormat, (function() {
return function(e2, t) {
var r2 = t.prototype, n2 = r2.format;
r2.format = function(e3) {
var t2 = this, r3 = this.$locale();
if (!this.isValid()) return n2.bind(this)(e3);
var s = this.$utils(), a = (e3 || "YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g, (function(e4) {
switch (e4) {
case "Q":
return Math.ceil((t2.$M + 1) / 3);
case "Do":
return r3.ordinal(t2.$D);
case "gggg":
return t2.weekYear();
case "GGGG":
return t2.isoWeekYear();
case "wo":
return r3.ordinal(t2.week(), "W");
case "w":
case "ww":
return s.s(t2.week(), "w" === e4 ? 1 : 2, "0");
case "W":
case "WW":
return s.s(t2.isoWeek(), "W" === e4 ? 1 : 2, "0");
case "k":
case "kk":
return s.s(String(0 === t2.$H ? 24 : t2.$H), "k" === e4 ? 1 : 2, "0");
case "X":
return Math.floor(t2.$d.getTime() / 1e3);
case "x":
return t2.$d.getTime();
case "z":
return "[" + t2.offsetName() + "]";
case "zzz":
return "[" + t2.offsetName("long") + "]";
default:
return e4;
}
}));
return n2.bind(this)(a);
};
};
}));
})(advancedFormat$1);
var advancedFormatExports = advancedFormat$1.exports;
const advancedFormatPlugin = getDefaultExportFromCjs(advancedFormatExports);
dayjs.extend(localizedFormatPlugin);
dayjs.extend(weekOfYearPlugin);
dayjs.extend(isBetweenPlugin);
dayjs.extend(advancedFormatPlugin);
const formatTokenMap = {
YY: "year",
YYYY: {
sectionType: "year",
contentType: "digit",
maxLength: 4
},
M: {
sectionType: "month",
contentType: "digit",
maxLength: 2
},
MM: "month",
MMM: {
sectionType: "month",
contentType: "letter"
},
MMMM: {
sectionType: "month",
contentType: "letter"
},
D: {
sectionType: "day",
contentType: "digit",
maxLength: 2
},
DD: "day",
Do: {
sectionType: "day",
contentType: "digit-with-letter"
},
d: {
sectionType: "weekDay",
contentType: "digit",
maxLength: 2
},
dd: {
sectionType: "weekDay",
contentType: "letter"
},
ddd: {
sectionType: "weekDay",
contentType: "letter"
},
dddd: {
sectionType: "weekDay",
contentType: "letter"
},
A: "meridiem",
a: "meridiem",
H: {
sectionType: "hours",
contentType: "digit",
maxLength: 2
},
HH: "hours",
h: {
sectionType: "hours",
contentType: "digit",
maxLength: 2
},
hh: "hours",
m: {
sectionType: "minutes",
contentType: "digit",
maxLength: 2
},
mm: "minutes",
s: {
sectionType: "seconds",
contentType: "digit",
maxLength: 2
},
ss: "seconds"
};
const defaultFormats = {
year: "YYYY",
month: "MMMM",
monthShort: "MMM",
dayOfMonth: "D",
dayOfMonthFull: "Do",
weekday: "dddd",
weekdayShort: "dd",
hours24h: "HH",
hours12h: "hh",
meridiem: "A",
minutes: "mm",
seconds: "ss",
fullDate: "ll",
keyboardDate: "L",
shortDate: "MMM D",
normalDate: "D MMMM",
normalDateWithWeekday: "ddd, MMM D",
fullTime: "LT",
fullTime12h: "hh:mm A",
fullTime24h: "HH:mm",
keyboardDateTime: "L LT",
keyboardDateTime12h: "L hh:mm A",
keyboardDateTime24h: "L HH:mm"
};
const MISSING_UTC_PLUGIN = [
"Missing UTC plugin",
"To be able to use UTC or timezones, you have to enable the `utc` plugin",
"Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc"
].join("\n");
const MISSING_TIMEZONE_PLUGIN = [
"Missing timezone plugin",
"To be able to use timezones, you have to enable both the `utc` and the `timezone` plugin",
"Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-timezone"
].join("\n");
const withLocale = (dayjs2, locale) => !locale ? dayjs2 : (...args) => dayjs2(...args).locale(locale);
class AdapterDayjs {
constructor({ locale: _locale, formats } = {}) {
this.isMUIAdapter = true;
this.isTimezoneCompatible = true;
this.lib = "dayjs";
this.dayjs = void 0;
this.locale = void 0;
this.formats = void 0;
this.escapedCharacters = {
start: "[",
end: "]"
};
this.formatTokenMap = formatTokenMap;
this.setLocaleToValue = (value) => {
const expectedLocale = this.getCurrentLocaleCode();
if (expectedLocale === value.locale()) {
return value;
}
return value.locale(expectedLocale);
};
this.hasUTCPlugin = () => typeof dayjs.utc !== "undefined";
this.hasTimezonePlugin = () => typeof dayjs.tz !== "undefined";
this.isSame = (value, comparing, comparisonTemplate) => {
const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
return value.format(comparisonTemplate) === comparingInValueTimezone.format(comparisonTemplate);
};
this.cleanTimezone = (timezone) => {
switch (timezone) {
case "default": {
return void 0;
}
case "system": {
return dayjs.tz.guess();
}
default: {
return timezone;
}
}
};
this.createSystemDate = (value) => {
if (this.hasUTCPlugin() && this.hasTimezonePlugin()) {
const timezone = dayjs.tz.guess();
if (timezone !== "UTC") {
return dayjs.tz(value, timezone);
}
return dayjs(value);
}
return dayjs(value);
};
this.createUTCDate = (value) => {
if (!this.hasUTCPlugin()) {
throw new Error(MISSING_UTC_PLUGIN);
}
return dayjs.utc(value);
};
this.createTZDate = (value, timezone) => {
if (!this.hasUTCPlugin()) {
throw new Error(MISSING_UTC_PLUGIN);
}
if (!this.hasTimezonePlugin()) {
throw new Error(MISSING_TIMEZONE_PLUGIN);
}
const keepLocalTime = value !== void 0 && !value.endsWith("Z");
return dayjs(value).tz(this.cleanTimezone(timezone), keepLocalTime);
};
this.getLocaleFormats = () => {
const locales = dayjs.Ls;
const locale = this.locale || "en";
let localeObject = locales[locale];
if (localeObject === void 0) {
localeObject = locales.en;
}
return localeObject.formats;
};
this.adjustOffset = (value) => {
if (!this.hasTimezonePlugin()) {
return value;
}
const timezone = this.getTimezone(value);
if (timezone !== "UTC") {
const fixedValue = value.tz(this.cleanTimezone(timezone), true);
if (fixedValue.$offset === (value.$offset ?? 0)) {
return value;
}
value.$offset = fixedValue.$offset;
}
return value;
};
this.date = (value, timezone = "default") => {
if (value === null) {
return null;
}
let parsedValue;
if (timezone === "UTC") {
parsedValue = this.createUTCDate(value);
} else if (timezone === "system" || timezone === "default" && !this.hasTimezonePlugin()) {
parsedValue = this.createSystemDate(value);
} else {
parsedValue = this.createTZDate(value, timezone);
}
if (this.locale === void 0) {
return parsedValue;
}
return parsedValue.locale(this.locale);
};
this.getInvalidDate = () => dayjs(/* @__PURE__ */ new Date("Invalid date"));
this.getTimezone = (value) => {
var _a;
if (this.hasTimezonePlugin()) {
const zone = (_a = value.$x) == null ? void 0 : _a.$timezone;
if (zone) {
return zone;
}
}
if (this.hasUTCPlugin() && value.isUTC()) {
return "UTC";
}
return "system";
};
this.setTimezone = (value, timezone) => {
if (this.getTimezone(value) === timezone) {
return value;
}
if (timezone === "UTC") {
if (!this.hasUTCPlugin()) {
throw new Error(MISSING_UTC_PLUGIN);
}
return value.utc();
}
if (timezone === "system") {
return value.local();
}
if (!this.hasTimezonePlugin()) {
if (timezone === "default") {
return value;
}
throw new Error(MISSING_TIMEZONE_PLUGIN);
}
return dayjs.tz(value, this.cleanTimezone(timezone));
};
this.toJsDate = (value) => {
return value.toDate();
};
this.parse = (value, format) => {
if (value === "") {
return null;
}
return this.dayjs(value, format, this.locale, true);
};
this.getCurrentLocaleCode = () => {
return this.locale || "en";
};
this.is12HourCycleInCurrentLocale = () => {
return /A|a/.test(this.getLocaleFormats().LT || "");
};
this.expandFormat = (format) => {
const localeFormats = this.getLocaleFormats();
const t = (formatBis) => formatBis.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (_, a, b2) => a || b2.slice(1));
return format.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (_, a, b2) => {
const B2 = b2 && b2.toUpperCase();
return a || localeFormats[b2] || t(localeFormats[B2]);
});
};
this.isValid = (value) => {
if (value == null) {
return false;
}
return value.isValid();
};
this.format = (value, formatKey) => {
return this.formatByString(value, this.formats[formatKey]);
};
this.formatByString = (value, formatString) => {
return this.dayjs(value).format(formatString);
};
this.formatNumber = (numberToFormat) => {
return numberToFormat;
};
this.isEqual = (value, comparing) => {
if (value === null && comparing === null) {
return true;
}
if (value === null || comparing === null) {
return false;
}
return value.toDate().getTime() === comparing.toDate().getTime();
};
this.isSameYear = (value, comparing) => {
return this.isSame(value, comparing, "YYYY");
};
this.isSameMonth = (value, comparing) => {
return this.isSame(value, comparing, "YYYY-MM");
};
this.isSameDay = (value, comparing) => {
return this.isSame(value, comparing, "YYYY-MM-DD");
};
this.isSameHour = (value, comparing) => {
return value.isSame(comparing, "hour");
};
this.isAfter = (value, comparing) => {
return value > comparing;
};
this.isAfterYear = (value, comparing) => {
if (!this.hasUTCPlugin()) {
return value.isAfter(comparing, "year");
}
return !this.isSameYear(value, comparing) && value.utc() > comparing.utc();
};
this.isAfterDay = (value, comparing) => {
if (!this.hasUTCPlugin()) {
return value.isAfter(comparing, "day");
}
return !this.isSameDay(value, comparing) && value.utc() > comparing.utc();
};
this.isBefore = (value, comparing) => {
return value < comparing;
};
this.isBeforeYear = (value, comparing) => {
if (!this.hasUTCPlugin()) {
return value.isBefore(comparing, "year");
}
return !this.isSameYear(value, comparing) && value.utc() < comparing.utc();
};
this.isBeforeDay = (value, comparing) => {
if (!this.hasUTCPlugin()) {
return value.isBefore(comparing, "day");
}
return !this.isSameDay(value, comparing) && value.utc() < comparing.utc();
};
this.isWithinRange = (value, [start, end2]) => {
return value >= start && value <= end2;
};
this.startOfYear = (value) => {
return this.adjustOffset(value.startOf("year"));
};
this.startOfMonth = (value) => {
return this.adjustOffset(value.startOf("month"));
};
this.startOfWeek = (value) => {
return this.adjustOffset(this.setLocaleToValue(value).startOf("week"));
};
this.startOfDay = (value) => {
return this.adjustOffset(value.startOf("day"));
};
this.endOfYear = (value) => {
return this.adjustOffset(value.endOf("year"));
};
this.endOfMonth = (value) => {
return this.adjustOffset(value.endOf("month"));
};
this.endOfWeek = (value) => {
return this.adjustOffset(this.setLocaleToValue(value).endOf("week"));
};
this.endOfDay = (value) => {
return this.adjustOffset(value.endOf("day"));
};
this.addYears = (value, amount) => {
return this.adjustOffset(amount < 0 ? value.subtract(Math.abs(amount), "year") : value.add(amount, "year"));
};
this.addMonths = (value, amount) => {
return this.adjustOffset(amount < 0 ? value.subtract(Math.abs(amount), "month") : value.add(amount, "month"));
};
this.addWeeks = (value, amount) => {
return this.adjustOffset(amount < 0 ? value.subtract(Math.abs(amount), "week") : value.add(amount, "week"));
};
this.addDays = (value, amount) => {
return this.adjustOffset(amount < 0 ? value.subtract(Math.abs(amount), "day") : value.add(amount, "day"));
};
this.addHours = (value, amount) => {
return this.adjustOffset(amount < 0 ? value.subtract(Math.abs(amount), "hour") : value.add(amount, "hour"));
};
this.addMinutes = (value, amount) => {
return this.adjustOffset(amount < 0 ? value.subtract(Math.abs(amount), "minute") : value.add(amount, "minute"));
};
this.addSeconds = (value, amount) => {
return this.adjustOffset(amount < 0 ? value.subtract(Math.abs(amount), "second") : value.add(amount, "second"));
};
this.getYear = (value) => {
return value.year();
};
this.getMonth = (value) => {
return value.month();
};
this.getDate = (value) => {
return value.date();
};
this.getHours = (value) => {
return value.hour();
};
this.getMinutes = (value) => {
return value.minute();
};
this.getSeconds = (value) => {
return value.second();
};
this.getMilliseconds = (value) => {
return value.millisecond();
};
this.setYear = (value, year) => {
return this.adjustOffset(value.set("year", year));
};
this.setMonth = (value, month) => {
return this.adjustOffset(value.set("month", month));
};
this.setDate = (value, date) => {
return this.adjustOffset(value.set("date", date));
};
this.setHours = (value, hours) => {
return this.adjustOffset(value.set("hour", hours));
};
this.setMinutes = (value, minutes) => {
return this.adjustOffset(value.set("minute", minutes));
};
this.setSeconds = (value, seconds) => {
return this.adjustOffset(value.set("second", seconds));
};
this.setMilliseconds = (value, milliseconds) => {
return this.adjustOffset(value.set("millisecond", milliseconds));
};
this.getDaysInMonth = (value) => {
return value.daysInMonth();
};
this.getWeekArray = (value) => {
const start = this.startOfWeek(this.startOfMonth(value));
const end2 = this.endOfWeek(this.endOfMonth(value));
let count2 = 0;
let current = start;
const nestedWeeks = [];
while (current < end2) {
const weekNumber = Math.floor(count2 / 7);
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
nestedWeeks[weekNumber].push(current);
current = this.addDays(current, 1);
count2 += 1;
}
return nestedWeeks;
};
this.getWeekNumber = (value) => {
return value.week();
};
this.getYearRange = ([start, end2]) => {
const startDate = this.startOfYear(start);
const endDate = this.endOfYear(end2);
const years = [];
let current = startDate;
while (this.isBefore(current, endDate)) {
years.push(current);
current = this.addYears(current, 1);
}
return years;
};
this.dayjs = withLocale(dayjs, _locale);
this.locale = _locale;
this.formats = _extends$1({}, defaultFormats, formats);
dayjs.extend(customParseFormatPlugin);
}
getDayOfWeek(value) {
return value.day() + 1;
}
}
var de$1 = {
exports: {}
};
var de = de$1.exports;
(function(module, exports$1) {
!(function(e2, n2) {
module.exports = n2(dayjs_minExports);
})(de, (function(e2) {
function n2(e3) {
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : {
default: e3
};
}
var t = n2(e2), a = {
s: "ein paar Sekunden",
m: [
"eine Minute",
"einer Minute"
],
mm: "%d Minuten",
h: [
"eine Stunde",
"einer Stunde"
],
hh: "%d Stunden",
d: [
"ein Tag",
"einem Tag"
],
dd: [
"%d Tage",
"%d Tagen"
],
M: [
"ein Monat",
"einem Monat"
],
MM: [
"%d Monate",
"%d Monaten"
],
y: [
"ein Jahr",
"einem Jahr"
],
yy: [
"%d Jahre",
"%d Jahren"
]
};
function i(e3, n3, t2) {
var i2 = a[t2];
return Array.isArray(i2) && (i2 = i2[n3 ? 0 : 1]), i2.replace("%d", e3);
}
var r2 = {
name: "de",
weekdays: "Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),
weekdaysShort: "So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),
weekdaysMin: "So_Mo_Di_Mi_Do_Fr_Sa".split("_"),
months: "Januar_Februar_M\xE4rz_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),
monthsShort: "Jan._Feb._M\xE4rz_Apr._Mai_Juni_Juli_Aug._Sept._Okt._Nov._Dez.".split("_"),
ordinal: function(e3) {
return e3 + ".";
},
weekStart: 1,
yearStart: 4,
formats: {
LTS: "HH:mm:ss",
LT: "HH:mm",
L: "DD.MM.YYYY",
LL: "D. MMMM YYYY",
LLL: "D. MMMM YYYY HH:mm",
LLLL: "dddd, D. MMMM YYYY HH:mm"
},
relativeTime: {
future: "in %s",
past: "vor %s",
s: i,
m: i,
mm: i,
h: i,
hh: i,
d: i,
dd: i,
M: i,
MM: i,
y: i,
yy: i
}
};
return t.default.locale(r2, null, true), r2;
}));
})(de$1);
var en$1 = {
exports: {}
};
var en = en$1.exports;
(function(module, exports$1) {
!(function(e2, n2) {
module.exports = n2();
})(en, (function() {
return {
name: "en",
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
ordinal: function(e2) {
var n2 = [
"th",
"st",
"nd",
"rd"
], t = e2 % 100;
return "[" + e2 + (n2[(t - 20) % 10] || n2[t] || n2[0]) + "]";
}
};
}));
})(en$1);
var ru$1 = {
exports: {}
};
var ru = ru$1.exports;
(function(module, exports$1) {
!(function(_, t) {
module.exports = t(dayjs_minExports);
})(ru, (function(_) {
function t(_2) {
return _2 && "object" == typeof _2 && "default" in _2 ? _2 : {
default: _2
};
}
var e2 = t(_), n2 = "\u044F\u043D\u0432\u0430\u0440\u044F_\u0444\u0435\u0432\u0440\u0430\u043B\u044F_\u043C\u0430\u0440\u0442\u0430_\u0430\u043F\u0440\u0435\u043B\u044F_\u043C\u0430\u044F_\u0438\u044E\u043D\u044F_\u0438\u044E\u043B\u044F_\u0430\u0432\u0433\u0443\u0441\u0442\u0430_\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044F_\u043E\u043A\u0442\u044F\u0431\u0440\u044F_\u043D\u043E\u044F\u0431\u0440\u044F_\u0434\u0435\u043A\u0430\u0431\u0440\u044F".split("_"), s = "\u044F\u043D\u0432\u0430\u0440\u044C_\u0444\u0435\u0432\u0440\u0430\u043B\u044C_\u043C\u0430\u0440\u0442_\u0430\u043F\u0440\u0435\u043B\u044C_\u043C\u0430\u0439_\u0438\u044E\u043D\u044C_\u0438\u044E\u043B\u044C_\u0430\u0432\u0433\u0443\u0441\u0442_\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044C_\u043E\u043A\u0442\u044F\u0431\u0440\u044C_\u043D\u043E\u044F\u0431\u0440\u044C_\u0434\u0435\u043A\u0430\u0431\u0440\u044C".split("_"), r2 = "\u044F\u043D\u0432._\u0444\u0435\u0432\u0440._\u043C\u0430\u0440._\u0430\u043F\u0440._\u043C\u0430\u044F_\u0438\u044E\u043D\u044F_\u0438\u044E\u043B\u044F_\u0430\u0432\u0433._\u0441\u0435\u043D\u0442._\u043E\u043A\u0442._\u043D\u043E\u044F\u0431._\u0434\u0435\u043A.".split("_"), o = "\u044F\u043D\u0432._\u0444\u0435\u0432\u0440._\u043C\u0430\u0440\u0442_\u0430\u043F\u0440._\u043C\u0430\u0439_\u0438\u044E\u043D\u044C_\u0438\u044E\u043B\u044C_\u0430\u0432\u0433._\u0441\u0435\u043D\u0442._\u043E\u043A\u0442._\u043D\u043E\u044F\u0431._\u0434\u0435\u043A.".split("_"), i = /D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;
function d2(_2, t2, e3) {
var n3, s2;
return "m" === e3 ? t2 ? "\u043C\u0438\u043D\u0443\u0442\u0430" : "\u043C\u0438\u043D\u0443\u0442\u0443" : _2 + " " + (n3 = +_2, s2 = {
mm: t2 ? "\u043C\u0438\u043D\u0443\u0442\u0430_\u043C\u0438\u043D\u0443\u0442\u044B_\u043C\u0438\u043D\u0443\u0442" : "\u043C\u0438\u043D\u0443\u0442\u0443_\u043C\u0438\u043D\u0443\u0442\u044B_\u043C\u0438\u043D\u0443\u0442",
hh: "\u0447\u0430\u0441_\u0447\u0430\u0441\u0430_\u0447\u0430\u0441\u043E\u0432",
dd: "\u0434\u0435\u043D\u044C_\u0434\u043D\u044F_\u0434\u043D\u0435\u0439",
MM: "\u043C\u0435\u0441\u044F\u0446_\u043C\u0435\u0441\u044F\u0446\u0430_\u043C\u0435\u0441\u044F\u0446\u0435\u0432",
yy: "\u0433\u043E\u0434_\u0433\u043E\u0434\u0430_\u043B\u0435\u0442"
}[e3].split("_"), n3 % 10 == 1 && n3 % 100 != 11 ? s2[0] : n3 % 10 >= 2 && n3 % 10 <= 4 && (n3 % 100 < 10 || n3 % 100 >= 20) ? s2[1] : s2[2]);
}
var u2 = function(_2, t2) {
return i.test(t2) ? n2[_2.month()] : s[_2.month()];
};
u2.s = s, u2.f = n2;
var a = function(_2, t2) {
return i.test(t2) ? r2[_2.month()] : o[_2.month()];
};
a.s = o, a.f = r2;
var m2 = {
name: "ru",
weekdays: "\u0432\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u0435_\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A_\u0432\u0442\u043E\u0440\u043D\u0438\u043A_\u0441\u0440\u0435\u0434\u0430_\u0447\u0435\u0442\u0432\u0435\u0440\u0433_\u043F\u044F\u0442\u043D\u0438\u0446\u0430_\u0441\u0443\u0431\u0431\u043E\u0442\u0430".split("_"),
weekdaysShort: "\u0432\u0441\u043A_\u043F\u043D\u0434_\u0432\u0442\u0440_\u0441\u0440\u0434_\u0447\u0442\u0432_\u043F\u0442\u043D_\u0441\u0431\u0442".split("_"),
weekdaysMin: "\u0432\u0441_\u043F\u043D_\u0432\u0442_\u0441\u0440_\u0447\u0442_\u043F\u0442_\u0441\u0431".split("_"),
months: u2,
monthsShort: a,
weekStart: 1,
yearStart: 4,
formats: {
LT: "H:mm",
LTS: "H:mm:ss",
L: "DD.MM.YYYY",
LL: "D MMMM YYYY \u0433.",
LLL: "D MMMM YYYY \u0433., H:mm",
LLLL: "dddd, D MMMM YYYY \u0433., H:mm"
},
relativeTime: {
future: "\u0447\u0435\u0440\u0435\u0437 %s",
past: "%s \u043D\u0430\u0437\u0430\u0434",
s: "\u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u0441\u0435\u043A\u0443\u043D\u0434",
m: d2,
mm: d2,
h: "\u0447\u0430\u0441",
hh: d2,
d: "\u0434\u0435\u043D\u044C",
dd: d2,
M: "\u043C\u0435\u0441\u044F\u0446",
MM: d2,
y: "\u0433\u043E\u0434",
yy: d2
},
ordinal: function(_2) {
return _2;
},
meridiem: function(_2) {
return _2 < 4 ? "\u043D\u043E\u0447\u0438" : _2 < 12 ? "\u0443\u0442\u0440\u0430" : _2 < 17 ? "\u0434\u043D\u044F" : "\u0432\u0435\u0447\u0435\u0440\u0430";
}
};
return e2.default.locale(m2, null, true), m2;
}));
})(ru$1);
var zhCn$1 = {
exports: {}
};
var zhCn = zhCn$1.exports;
(function(module, exports$1) {
!(function(e2, _) {
module.exports = _(dayjs_minExports);
})(zhCn, (function(e2) {
function _(e3) {
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : {
default: e3
};
}
var t = _(e2), d2 = {
name: "zh-cn",
weekdays: "\u661F\u671F\u65E5_\u661F\u671F\u4E00_\u661F\u671F\u4E8C_\u661F\u671F\u4E09_\u661F\u671F\u56DB_\u661F\u671F\u4E94_\u661F\u671F\u516D".split("_"),
weekdaysShort: "\u5468\u65E5_\u5468\u4E00_\u5468\u4E8C_\u5468\u4E09_\u5468\u56DB_\u5468\u4E94_\u5468\u516D".split("_"),
weekdaysMin: "\u65E5_\u4E00_\u4E8C_\u4E09_\u56DB_\u4E94_\u516D".split("_"),
months: "\u4E00\u6708_\u4E8C\u6708_\u4E09\u6708_\u56DB\u6708_\u4E94\u6708_\u516D\u6708_\u4E03\u6708_\u516B\u6708_\u4E5D\u6708_\u5341\u6708_\u5341\u4E00\u6708_\u5341\u4E8C\u6708".split("_"),
monthsShort: "1\u6708_2\u6708_3\u6708_4\u6708_5\u6708_6\u6708_7\u6708_8\u6708_9\u6708_10\u6708_11\u6708_12\u6708".split("_"),
ordinal: function(e3, _2) {
return "W" === _2 ? e3 + "\u5468" : e3 + "\u65E5";
},
weekStart: 1,
yearStart: 4,
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "YYYY/MM/DD",
LL: "YYYY\u5E74M\u6708D\u65E5",
LLL: "YYYY\u5E74M\u6708D\u65E5Ah\u70B9mm\u5206",
LLLL: "YYYY\u5E74M\u6708D\u65E5ddddAh\u70B9mm\u5206",
l: "YYYY/M/D",
ll: "YYYY\u5E74M\u6708D\u65E5",
lll: "YYYY\u5E74M\u6708D\u65E5 HH:mm",
llll: "YYYY\u5E74M\u6708D\u65E5dddd HH:mm"
},
relativeTime: {
future: "%s\u5185",
past: "%s\u524D",
s: "\u51E0\u79D2",
m: "1 \u5206\u949F",
mm: "%d \u5206\u949F",
h: "1 \u5C0F\u65F6",
hh: "%d \u5C0F\u65F6",
d: "1 \u5929",
dd: "%d \u5929",
M: "1 \u4E2A\u6708",
MM: "%d \u4E2A\u6708",
y: "1 \u5E74",
yy: "%d \u5E74"
},
meridiem: function(e3, _2) {
var t2 = 100 * e3 + _2;
return t2 < 600 ? "\u51CC\u6668" : t2 < 900 ? "\u65E9\u4E0A" : t2 < 1100 ? "\u4E0A\u5348" : t2 < 1300 ? "\u4E2D\u5348" : t2 < 1800 ? "\u4E0B\u5348" : "\u665A\u4E0A";
}
};
return t.default.locale(d2, null, true), d2;
}));
})(zhCn$1);
var uk$1 = {
exports: {}
};
var uk = uk$1.exports;
(function(module, exports$1) {
!(function(_, e2) {
module.exports = e2(dayjs_minExports);
})(uk, (function(_) {
function e2(_2) {
return _2 && "object" == typeof _2 && "default" in _2 ? _2 : {
default: _2
};
}
var t = e2(_), s = "\u0441\u0456\u0447\u043D\u044F_\u043B\u044E\u0442\u043E\u0433\u043E_\u0431\u0435\u0440\u0435\u0437\u043D\u044F_\u043A\u0432\u0456\u0442\u043D\u044F_\u0442\u0440\u0430\u0432\u043D\u044F_\u0447\u0435\u0440\u0432\u043D\u044F_\u043B\u0438\u043F\u043D\u044F_\u0441\u0435\u0440\u043F\u043D\u044F_\u0432\u0435\u0440\u0435\u0441\u043D\u044F_\u0436\u043E\u0432\u0442\u043D\u044F_\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434\u0430_\u0433\u0440\u0443\u0434\u043D\u044F".split("_"), n2 = "\u0441\u0456\u0447\u0435\u043D\u044C_\u043B\u044E\u0442\u0438\u0439_\u0431\u0435\u0440\u0435\u0437\u0435\u043D\u044C_\u043A\u0432\u0456\u0442\u0435\u043D\u044C_\u0442\u0440\u0430\u0432\u0435\u043D\u044C_\u0447\u0435\u0440\u0432\u0435\u043D\u044C_\u043B\u0438\u043F\u0435\u043D\u044C_\u0441\u0435\u0440\u043F\u0435\u043D\u044C_\u0432\u0435\u0440\u0435\u0441\u0435\u043D\u044C_\u0436\u043E\u0432\u0442\u0435\u043D\u044C_\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434_\u0433\u0440\u0443\u0434\u0435\u043D\u044C".split("_"), o = /D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;
function d2(_2, e3, t2) {
var s2, n3;
return "m" === t2 ? e3 ? "\u0445\u0432\u0438\u043B\u0438\u043D\u0430" : "\u0445\u0432\u0438\u043B\u0438\u043D\u0443" : "h" === t2 ? e3 ? "\u0433\u043E\u0434\u0438\u043D\u0430" : "\u0433\u043E\u0434\u0438\u043D\u0443" : _2 + " " + (s2 = +_2, n3 = {
ss: e3 ? "\u0441\u0435\u043A\u0443\u043D\u0434\u0430_\u0441\u0435\u043A\u0443\u043D\u0434\u0438_\u0441\u0435\u043A\u0443\u043D\u0434" : "\u0441\u0435\u043A\u0443\u043D\u0434\u0443_\u0441\u0435\u043A\u0443\u043D\u0434\u0438_\u0441\u0435\u043A\u0443\u043D\u0434",
mm: e3 ? "\u0445\u0432\u0438\u043B\u0438\u043D\u0430_\u0445\u0432\u0438\u043B\u0438\u043D\u0438_\u0445\u0432\u0438\u043B\u0438\u043D" : "\u0445\u0432\u0438\u043B\u0438\u043D\u0443_\u0445\u0432\u0438\u043B\u0438\u043D\u0438_\u0445\u0432\u0438\u043B\u0438\u043D",
hh: e3 ? "\u0433\u043E\u0434\u0438\u043D\u0430_\u0433\u043E\u0434\u0438\u043D\u0438_\u0433\u043E\u0434\u0438\u043D" : "\u0433\u043E\u0434\u0438\u043D\u0443_\u0433\u043E\u0434\u0438\u043D\u0438_\u0433\u043E\u0434\u0438\u043D",
dd: "\u0434\u0435\u043D\u044C_\u0434\u043D\u0456_\u0434\u043D\u0456\u0432",
MM: "\u043C\u0456\u0441\u044F\u0446\u044C_\u043C\u0456\u0441\u044F\u0446\u0456_\u043C\u0456\u0441\u044F\u0446\u0456\u0432",
yy: "\u0440\u0456\u043A_\u0440\u043E\u043A\u0438_\u0440\u043E\u043A\u0456\u0432"
}[t2].split("_"), s2 % 10 == 1 && s2 % 100 != 11 ? n3[0] : s2 % 10 >= 2 && s2 % 10 <= 4 && (s2 % 100 < 10 || s2 % 100 >= 20) ? n3[1] : n3[2]);
}
var i = function(_2, e3) {
return o.test(e3) ? s[_2.month()] : n2[_2.month()];
};
i.s = n2, i.f = s;
var r2 = {
name: "uk",
weekdays: "\u043D\u0435\u0434\u0456\u043B\u044F_\u043F\u043E\u043D\u0435\u0434\u0456\u043B\u043E\u043A_\u0432\u0456\u0432\u0442\u043E\u0440\u043E\u043A_\u0441\u0435\u0440\u0435\u0434\u0430_\u0447\u0435\u0442\u0432\u0435\u0440_\u043F\u2019\u044F\u0442\u043D\u0438\u0446\u044F_\u0441\u0443\u0431\u043E\u0442\u0430".split("_"),
weekdaysShort: "\u043D\u0434\u043B_\u043F\u043D\u0434_\u0432\u0442\u0440_\u0441\u0440\u0434_\u0447\u0442\u0432_\u043F\u0442\u043D_\u0441\u0431\u0442".split("_"),
weekdaysMin: "\u043D\u0434_\u043F\u043D_\u0432\u0442_\u0441\u0440_\u0447\u0442_\u043F\u0442_\u0441\u0431".split("_"),
months: i,
monthsShort: "\u0441\u0456\u0447_\u043B\u044E\u0442_\u0431\u0435\u0440_\u043A\u0432\u0456\u0442_\u0442\u0440\u0430\u0432_\u0447\u0435\u0440\u0432_\u043B\u0438\u043F_\u0441\u0435\u0440\u043F_\u0432\u0435\u0440_\u0436\u043E\u0432\u0442_\u043B\u0438\u0441\u0442_\u0433\u0440\u0443\u0434".split("_"),
weekStart: 1,
relativeTime: {
future: "\u0437\u0430 %s",
past: "%s \u0442\u043E\u043C\u0443",
s: "\u0434\u0435\u043A\u0456\u043B\u044C\u043A\u0430 \u0441\u0435\u043A\u0443\u043D\u0434",
m: d2,
mm: d2,
h: d2,
hh: d2,
d: "\u0434\u0435\u043D\u044C",
dd: d2,
M: "\u043C\u0456\u0441\u044F\u0446\u044C",
MM: d2,
y: "\u0440\u0456\u043A",
yy: d2
},
ordinal: function(_2) {
return _2;
},
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "DD.MM.YYYY",
LL: "D MMMM YYYY \u0440.",
LLL: "D MMMM YYYY \u0440., HH:mm",
LLLL: "dddd, D MMMM YYYY \u0440., HH:mm"
}
};
return t.default.locale(r2, null, true), r2;
}));
})(uk$1);
var it$1 = {
exports: {}
};
var it = it$1.exports;
(function(module, exports$1) {
!(function(e2, o) {
module.exports = o(dayjs_minExports);
})(it, (function(e2) {
function o(e3) {
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : {
default: e3
};
}
var t = o(e2), n2 = {
name: "it",
weekdays: "domenica_luned\xEC_marted\xEC_mercoled\xEC_gioved\xEC_venerd\xEC_sabato".split("_"),
weekdaysShort: "dom_lun_mar_mer_gio_ven_sab".split("_"),
weekdaysMin: "do_lu_ma_me_gi_ve_sa".split("_"),
months: "gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),
weekStart: 1,
monthsShort: "gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "DD/MM/YYYY",
LL: "D MMMM YYYY",
LLL: "D MMMM YYYY HH:mm",
LLLL: "dddd D MMMM YYYY HH:mm"
},
relativeTime: {
future: "tra %s",
past: "%s fa",
s: "qualche secondo",
m: "un minuto",
mm: "%d minuti",
h: "un'ora",
hh: "%d ore",
d: "un giorno",
dd: "%d giorni",
M: "un mese",
MM: "%d mesi",
y: "un anno",
yy: "%d anni"
},
ordinal: function(e3) {
return e3 + "\xBA";
}
};
return t.default.locale(n2, null, true), n2;
}));
})(it$1);
var fr$1 = {
exports: {}
};
var fr = fr$1.exports;
(function(module, exports$1) {
!(function(e2, n2) {
module.exports = n2(dayjs_minExports);
})(fr, (function(e2) {
function n2(e3) {
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : {
default: e3
};
}
var t = n2(e2), i = {
name: "fr",
weekdays: "dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),
weekdaysShort: "dim._lun._mar._mer._jeu._ven._sam.".split("_"),
weekdaysMin: "di_lu_ma_me_je_ve_sa".split("_"),
months: "janvier_f\xE9vrier_mars_avril_mai_juin_juillet_ao\xFBt_septembre_octobre_novembre_d\xE9cembre".split("_"),
monthsShort: "janv._f\xE9vr._mars_avr._mai_juin_juil._ao\xFBt_sept._oct._nov._d\xE9c.".split("_"),
weekStart: 1,
yearStart: 4,
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "DD/MM/YYYY",
LL: "D MMMM YYYY",
LLL: "D MMMM YYYY HH:mm",
LLLL: "dddd D MMMM YYYY HH:mm"
},
relativeTime: {
future: "dans %s",
past: "il y a %s",
s: "quelques secondes",
m: "une minute",
mm: "%d minutes",
h: "une heure",
hh: "%d heures",
d: "un jour",
dd: "%d jours",
M: "un mois",
MM: "%d mois",
y: "un an",
yy: "%d ans"
},
ordinal: function(e3) {
return "" + e3 + (1 === e3 ? "er" : "");
}
};
return t.default.locale(i, null, true), i;
}));
})(fr$1);
var es$1 = {
exports: {}
};
var es = es$1.exports;
(function(module, exports$1) {
!(function(e2, o) {
module.exports = o(dayjs_minExports);
})(es, (function(e2) {
function o(e3) {
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : {
default: e3
};
}
var s = o(e2), d2 = {
name: "es",
monthsShort: "ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),
weekdays: "domingo_lunes_martes_mi\xE9rcoles_jueves_viernes_s\xE1bado".split("_"),
weekdaysShort: "dom._lun._mar._mi\xE9._jue._vie._s\xE1b.".split("_"),
weekdaysMin: "do_lu_ma_mi_ju_vi_s\xE1".split("_"),
months: "enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),
weekStart: 1,
formats: {
LT: "H:mm",
LTS: "H:mm:ss",
L: "DD/MM/YYYY",
LL: "D [de] MMMM [de] YYYY",
LLL: "D [de] MMMM [de] YYYY H:mm",
LLLL: "dddd, D [de] MMMM [de] YYYY H:mm"
},
relativeTime: {
future: "en %s",
past: "hace %s",
s: "unos segundos",
m: "un minuto",
mm: "%d minutos",
h: "una hora",
hh: "%d horas",
d: "un d\xEDa",
dd: "%d d\xEDas",
M: "un mes",
MM: "%d meses",
y: "un a\xF1o",
yy: "%d a\xF1os"
},
ordinal: function(e3) {
return e3 + "\xBA";
}
};
return s.default.locale(d2, null, true), d2;
}));
})(es$1);
var pl$1 = {
exports: {}
};
var pl = pl$1.exports;
(function(module, exports$1) {
!(function(e2, t) {
module.exports = t(dayjs_minExports);
})(pl, (function(e2) {
function t(e3) {
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : {
default: e3
};
}
var i = t(e2);
function a(e3) {
return e3 % 10 < 5 && e3 % 10 > 1 && ~~(e3 / 10) % 10 != 1;
}
function n2(e3, t2, i2) {
var n3 = e3 + " ";
switch (i2) {
case "m":
return t2 ? "minuta" : "minut\u0119";
case "mm":
return n3 + (a(e3) ? "minuty" : "minut");
case "h":
return t2 ? "godzina" : "godzin\u0119";
case "hh":
return n3 + (a(e3) ? "godziny" : "godzin");
case "MM":
return n3 + (a(e3) ? "miesi\u0105ce" : "miesi\u0119cy");
case "yy":
return n3 + (a(e3) ? "lata" : "lat");
}
}
var r2 = "stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_wrze\u015Bnia_pa\u017Adziernika_listopada_grudnia".split("_"), _ = "stycze\u0144_luty_marzec_kwiecie\u0144_maj_czerwiec_lipiec_sierpie\u0144_wrzesie\u0144_pa\u017Adziernik_listopad_grudzie\u0144".split("_"), s = /D MMMM/, d2 = function(e3, t2) {
return s.test(t2) ? r2[e3.month()] : _[e3.month()];
};
d2.s = _, d2.f = r2;
var o = {
name: "pl",
weekdays: "niedziela_poniedzia\u0142ek_wtorek_\u015Broda_czwartek_pi\u0105tek_sobota".split("_"),
weekdaysShort: "ndz_pon_wt_\u015Br_czw_pt_sob".split("_"),
weekdaysMin: "Nd_Pn_Wt_\u015Ar_Cz_Pt_So".split("_"),
months: d2,
monthsShort: "sty_lut_mar_kwi_maj_cze_lip_sie_wrz_pa\u017A_lis_gru".split("_"),
ordinal: function(e3) {
return e3 + ".";
},
weekStart: 1,
yearStart: 4,
relativeTime: {
future: "za %s",
past: "%s temu",
s: "kilka sekund",
m: n2,
mm: n2,
h: n2,
hh: n2,
d: "1 dzie\u0144",
dd: "%d dni",
M: "miesi\u0105c",
MM: n2,
y: "rok",
yy: n2
},
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "DD.MM.YYYY",
LL: "D MMMM YYYY",
LLL: "D MMMM YYYY HH:mm",
LLLL: "dddd, D MMMM YYYY HH:mm"
}
};
return i.default.locale(o, null, true), o;
}));
})(pl$1);
var pt$1 = {
exports: {}
};
var pt = pt$1.exports;
(function(module, exports$1) {
!(function(e2, a) {
module.exports = a(dayjs_minExports);
})(pt, (function(e2) {
function a(e3) {
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : {
default: e3
};
}
var o = a(e2), t = {
name: "pt",
weekdays: "domingo_segunda-feira_ter\xE7a-feira_quarta-feira_quinta-feira_sexta-feira_s\xE1bado".split("_"),
weekdaysShort: "dom_seg_ter_qua_qui_sex_sab".split("_"),
weekdaysMin: "Do_2\xAA_3\xAA_4\xAA_5\xAA_6\xAA_Sa".split("_"),
months: "janeiro_fevereiro_mar\xE7o_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),
monthsShort: "jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),
ordinal: function(e3) {
return e3 + "\xBA";
},
weekStart: 1,
yearStart: 4,
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "DD/MM/YYYY",
LL: "D [de] MMMM [de] YYYY",
LLL: "D [de] MMMM [de] YYYY [\xE0s] HH:mm",
LLLL: "dddd, D [de] MMMM [de] YYYY [\xE0s] HH:mm"
},
relativeTime: {
future: "em %s",
past: "h\xE1 %s",
s: "alguns segundos",
m: "um minuto",
mm: "%d minutos",
h: "uma hora",
hh: "%d horas",
d: "um dia",
dd: "%d dias",
M: "um m\xEAs",
MM: "%d meses",
y: "um ano",
yy: "%d anos"
}
};
return o.default.locale(t, null, true), t;
}));
})(pt$1);
var nl$1 = {
exports: {}
};
var nl = nl$1.exports;
(function(module, exports$1) {
!(function(e2, a) {
module.exports = a(dayjs_minExports);
})(nl, (function(e2) {
function a(e3) {
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : {
default: e3
};
}
var d2 = a(e2), n2 = {
name: "nl",
weekdays: "zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),
weekdaysShort: "zo._ma._di._wo._do._vr._za.".split("_"),
weekdaysMin: "zo_ma_di_wo_do_vr_za".split("_"),
months: "januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),
monthsShort: "jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_"),
ordinal: function(e3) {
return "[" + e3 + (1 === e3 || 8 === e3 || e3 >= 20 ? "ste" : "de") + "]";
},
weekStart: 1,
yearStart: 4,
formats: {
LT: "HH:mm",
LTS: "HH:mm:ss",
L: "DD-MM-YYYY",
LL: "D MMMM YYYY",
LLL: "D MMMM YYYY HH:mm",
LLLL: "dddd D MMMM YYYY HH:mm"
},
relativeTime: {
future: "over %s",
past: "%s geleden",
s: "een paar seconden",
m: "een minuut",
mm: "%d minuten",
h: "een uur",
hh: "%d uur",
d: "een dag",
dd: "%d dagen",
M: "een maand",
MM: "%d maanden",
y: "een jaar",
yy: "%d jaar"
}
};
return d2.default.locale(n2, null, true), n2;
}));
})(nl$1);
const styles$1 = {
textRoot: {
"& .MuiInputBase-root": {
width: "100%",
height: "100%"
}
}
};
class JQuiInputDate extends VisRxWidget {
EASY_DATE_FORMAT = "DD.MM.YYYY";
static getWidgetInfo() {
return {
id: "tplJquiInputDate",
visSet: "jqui",
visName: "Input Date",
visWidgetLabel: "jqui_input_date",
visPrev: "widgets/jqui/img/Prev_InputDate.png",
visOrder: 30,
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "variant",
label: "jqui_variant",
type: "select",
options: [
{
label: "standard",
value: "standard"
},
{
label: "outlined",
value: "outlined"
},
{
label: "filled",
value: "filled"
}
],
default: "standard"
},
{
name: "autoFocus",
type: "checkbox"
},
{
name: "clearable",
label: "jqui_clearable",
type: "checkbox"
},
{
name: "widgetTitle",
label: "jqui_widgetTitle",
type: "text"
},
{
name: "disableFuture",
label: "jqui_disableFuture",
type: "checkbox",
hidden: "!!data.disablePast"
},
{
name: "disablePast",
label: "jqui_disablePast",
type: "checkbox",
hidden: "!!data.disableFuture"
},
{
name: "asFullDate",
label: "jqui_asFullDate",
type: "checkbox"
},
{
name: "displayWeekNumber",
label: "jqui_displayWeekNumber",
type: "checkbox"
},
{
name: "wideFormat",
label: "jqui_wideFormat",
type: "checkbox"
}
]
}
],
visDefaultStyle: {
width: 250,
height: 56
}
};
}
getWidgetInfo() {
return JQuiInputDate.getWidgetInfo();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
props.style.overflow = "visible";
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsx(LocalizationProvider, {
dateAdapter: AdapterDayjs,
adapterLocale: this.props.context.lang,
children: jsxRuntimeExports.jsx(DatePicker, {
value: this.state.rxData.asFullDate ? dayjs(this.state.values[`${this.state.rxData.oid}.val`]) || "" : dayjs(this.state.values[`${this.state.rxData.oid}.val`], this.EASY_DATE_FORMAT),
label: this.state.rxData.widgetTitle || null,
autoFocus: this.state.rxData.autoFocus || false,
onChange: (newValue) => {
if (!newValue) {
return;
}
const val = this.state.rxData.asFullDate ? newValue.toDate().toString() : newValue.format(this.EASY_DATE_FORMAT);
this.props.context.setValue(this.state.rxData.oid, val);
},
formatDensity: this.state.rxData.wideFormat ? "spacious" : "dense",
slotProps: {
textField: {
variant: this.state.rxData.variant || "standard",
style: {
width: "100%",
height: "100%"
},
sx: styles$1.textRoot
},
field: {
clearable: this.state.rxData.clearable,
onClear: () => this.props.context.setValue(this.state.rxData.oid, "")
}
},
disableFuture: this.state.rxData.disableFuture || false,
disablePast: this.state.rxData.disablePast || false,
displayWeekNumber: this.state.rxData.displayWeekNumber || false
})
})
});
}
}
const styles = {
textRoot: {
"& .MuiInputBase-root": {
width: "100%",
height: "100%"
}
}
};
class JQuiInputDateTime extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplJquiInputDatetime",
visSet: "jqui",
visName: "Input Time",
visWidgetLabel: "jqui_input_time",
visPrev: "widgets/jqui/img/Prev_InputDateTime.png",
visOrder: 31,
visAttrs: [
{
name: "common",
fields: [
{
name: "oid",
type: "id"
},
{
name: "variant",
label: "jqui_variant",
type: "select",
options: [
{
label: "standard",
value: "standard"
},
{
label: "outlined",
value: "outlined"
},
{
label: "filled",
value: "filled"
}
],
default: "standard"
},
{
name: "autoFocus",
type: "checkbox"
},
{
name: "clearable",
label: "jqui_clearable",
type: "checkbox"
},
{
name: "widgetTitle",
label: "jqui_widgetTitle",
type: "text"
},
{
name: "ampm",
label: "jqui_ampm",
type: "checkbox"
},
{
name: "asDate",
label: "jqui_asDate",
type: "checkbox"
},
{
name: "stepMinute",
label: "jqui_stepMinute",
type: "select",
options: [
{
label: "1 minute",
value: 1
},
{
label: "2 minutes",
value: 2
},
{
label: "3 minutes",
value: 3
},
{
label: "4 minutes",
value: 4
},
{
label: "5 minutes",
value: 5
},
{
label: "10 minutes",
value: 10
},
{
label: "15 minutes",
value: 15
},
{
label: "20 minutes",
value: 20
},
{
label: "30 minutes",
value: 30
},
{
label: "60 minutes",
value: 60
}
]
}
]
}
],
visDefaultStyle: {
width: 250,
height: 56
}
};
}
getWidgetInfo() {
return JQuiInputDateTime.getWidgetInfo();
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
const val = this.state.values[`${this.state.rxData.oid}.val`];
const asDate = this.state.rxData.asDate;
props.style.overflow = "visible";
return jsxRuntimeExports.jsx("div", {
className: "vis-widget-body",
children: jsxRuntimeExports.jsx(LocalizationProvider, {
dateAdapter: AdapterDayjs,
adapterLocale: this.props.context.lang,
children: jsxRuntimeExports.jsx(TimePicker, {
value: val && !asDate ? dayjs(val, "HH:mm") : dayjs(val),
ampm: this.state.rxData.ampm || false,
minutesStep: parseInt(this.state.rxData.stepMinute, 10) || 1,
label: this.state.rxData.widgetTitle || null,
formatDensity: "dense",
format: "HH:mm",
autoFocus: this.state.rxData.autoFocus || false,
onChange: (value) => {
if (!value) {
return;
}
const res = !asDate ? value.format("HH:mm") : value.second(0).millisecond(0).toDate().toString();
this.props.context.setValue(this.state.rxData.oid, res);
},
slotProps: {
textField: {
variant: this.state.rxData.variant || "standard",
style: {
width: "100%",
height: "100%"
},
sx: styles.textRoot
},
field: {
clearable: this.state.rxData.clearable,
onClear: () => this.props.context.setValue(this.state.rxData.oid, "")
}
}
})
})
});
}
}
class JQuiToggle extends JQuiBinaryState {
static getWidgetInfo() {
const widgetInfo = JQuiBinaryState.getWidgetInfo();
const newWidgetInfo = {
id: "tplJquiToogle",
visSet: "jqui",
visName: "Icon Toggle",
visWidgetLabel: "jqui_icon_toggle",
visPrev: "widgets/jqui/img/Prev_IconToggle.png",
visOrder: 32,
visAttrs: widgetInfo.visAttrs,
visDefaultStyle: {
width: 92,
height: 36
}
};
newWidgetInfo.visAttrs[0].fields.unshift({
name: "_note",
type: "help",
text: "jqui_button_binary_control_note"
});
const iconFalse = JQuiBinaryState.findField(newWidgetInfo, "icon_false");
if (iconFalse) {
iconFalse.default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik0xMyAzaC0ydjEwaDJWM3ptNC44MyAyLjE3bC0xLjQyIDEuNDJBNi45MiA2LjkyIDAgMCAxIDE5IDEyYzAgMy44Ny0zLjEzIDctNyA3QTYuOTk1IDYuOTk1IDAgMCAxIDcuNTggNi41OEw2LjE3IDUuMTdBOC45MzIgOC45MzIgMCAwIDAgMyAxMmE5IDkgMCAwIDAgMTggMGMwLTIuNzQtMS4yMy01LjE4LTMuMTctNi44M3oiLz48L3N2Zz4=";
}
const colorTrue = JQuiBinaryState.findField(newWidgetInfo, "color_true");
if (colorTrue) {
colorTrue.default = "#93ff93";
}
return newWidgetInfo;
}
getWidgetInfo() {
return JQuiToggle.getWidgetInfo();
}
}
class TabsSliderTabs extends VisRxWidget {
static getWidgetInfo() {
return {
id: "tplSTab",
visSet: "tabs",
visName: "SliderTabs",
visSetLabel: "Tabs",
visPrev: "widgets/tabs/img/Prev_SliderTabs.png",
visWidgetLabel: "vis_2_widgets_widgets_tabs_label",
visSetIcon: "widgets/tabs/img/Prev_SliderTabs.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "show_tabs",
type: "slider",
min: 1,
max: 20,
label: "vis_2_widgets_widgets_tabs_show_tabs",
default: 2
},
{
name: "vertical",
type: "checkbox",
label: "vis_2_widgets_widgets_tabs_vertical"
},
{
name: "variant",
type: "select",
label: "vis_2_widgets_widgets_tabs_variant",
hidden: "!!data.vertical",
options: [
{
value: "",
label: "vis_2_widgets_widgets_tabs_variant_default"
},
{
value: "centered",
label: "vis_2_widgets_widgets_tabs_variant_centered"
},
{
value: "fullWidth",
label: "vis_2_widgets_widgets_tabs_variant_full_width"
}
]
},
{
name: "color",
type: "color",
label: "vis_2_widgets_widgets_tabs_color"
}
]
},
{
name: "node",
label: "vis_2_widgets_widgets_tabs_group_tab",
indexFrom: 1,
indexTo: "show_tabs",
fields: [
{
name: "title_tab_",
label: "vis_2_widgets_widgets_tabs_tab_title"
},
{
name: "contains_view_",
multiple: false,
type: "select-views",
label: "vis_2_widgets_widgets_tabs_tab_view"
},
{
name: "icon_tab_",
type: "icon64",
label: "vis_2_widgets_widgets_tabs_tab_icon",
hidden: '!!data["image_tab_" + index"]'
},
{
name: "image_tab_",
type: "image",
label: "vis_2_widgets_widgets_tabs_tab_image",
hidden: '!!data["icon_tab_" + index"]'
},
{
name: "icon_size_",
type: "slider",
min: 0,
max: 100,
label: "vis_2_widgets_widgets_tabs_tab_icon_size",
hidden: '!data["icon_tab_" + index"] && !data["image_tab_" + index"]'
},
{
name: "icon_color_",
type: "color",
label: "vis_2_widgets_widgets_tabs_tab_icon_color",
hidden: '!data["icon_tab_" + index"]'
},
{
name: "overflow_x_",
label: "vis_2_widgets_widgets_tabs_tab_overflow_x",
type: "select",
noTranslation: true,
options: [
"",
"visible",
"hidden",
"scroll",
"auto",
"initial",
"inherit"
]
},
{
name: "overflow_y_",
label: "vis_2_widgets_widgets_tabs_tab_overflow_y",
type: "select",
noTranslation: true,
options: [
"",
"visible",
"hidden",
"scroll",
"auto",
"initial",
"inherit"
]
}
]
}
],
visDefaultStyle: {
width: 250,
height: 250
}
};
}
componentDidMount() {
super.componentDidMount();
const tabIndexStr = window.localStorage.getItem(`${this.props.id}-tabIndex`);
let tabIndex = 0;
if (tabIndexStr) {
tabIndex = parseInt(tabIndexStr, 10) || 0;
}
this.setState({
tabIndex
});
}
getWidgetInfo() {
return TabsSliderTabs.getWidgetInfo();
}
getWidgetView() {
const view = this.state.rxData[`contains_view_${this.state.tabIndex + 1}`];
const style2 = {
flex: 1,
position: "relative"
};
const overflowX = this.state.rxData[`overflow_x_${this.state.tabIndex + 1}`];
const overflowY = this.state.rxData[`overflow_y_${this.state.tabIndex + 1}`];
if (overflowX && overflowY) {
if (overflowY === overflowX) {
style2.overflow = overflowX;
} else {
style2.overflowX = overflowX;
style2.overflowY = overflowY;
}
} else if (overflowX) {
style2.overflowX = overflowX;
} else if (overflowY) {
style2.overflowY = overflowY;
} else {
style2.overflow = "hidden";
}
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
style: style2,
children: [
this.state.editMode ? jsxRuntimeExports.jsx("div", {
className: "vis-editmode-helper"
}) : null,
view ? super.getWidgetView(view) : null
]
});
}
renderWidgetBody(props) {
super.renderWidgetBody(props);
if (props.style.width === void 0) {
props.style.width = 250;
}
if (props.style.height === void 0) {
props.style.height = 250;
}
const tabs = [];
for (let t = 0; t < parseInt(this.state.rxData.show_tabs, 10); t++) {
const color = this.state.rxData[`icon_color_${t + 1}`];
const icon = this.state.rxData[`icon_tab_${t + 1}`];
let image = this.state.rxData[`image_tab_${t + 1}`];
const size = this.state.rxData[`icon_size_${t + 1}`];
const title = this.state.rxData[`title_tab_${t + 1}`];
if (image && image.startsWith("_PRJ_NAME/")) {
image = image.replace("_PRJ_NAME/", `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
tabs.push(jsxRuntimeExports.jsx(__mf_109, {
label: title || (icon || image ? "" : `Tab ${t + 1}`),
icon: icon ? jsxRuntimeExports.jsx(__mf_15$1, {
src: icon,
style: {
color,
width: size,
height: size
}
}) : image ? jsxRuntimeExports.jsx(__mf_15$1, {
src: image,
style: {
width: size,
height: size
}
}) : null,
iconPosition: "start",
value: t,
style: {
color: this.state.rxData.color,
textTransform: "none"
},
wrapped: true
}, t.toString()));
}
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
style: {
display: "flex",
flexDirection: this.state.rxData.vertical ? "row" : "column"
},
children: [
jsxRuntimeExports.jsx("div", {
style: {
width: "100%",
overflow: "hidden"
},
children: jsxRuntimeExports.jsx(__mf_120, {
TabIndicatorProps: {
style: {
backgroundColor: this.state.rxData.color
}
},
value: this.state.tabIndex || 0,
onChange: (_e, tabIndex) => {
window.localStorage.setItem(`${this.props.id}-tabIndex`, tabIndex.toString());
this.setState({
tabIndex
});
},
scrollButtons: "auto",
centered: this.state.rxData.variant === "centered",
variant: this.state.rxData.variant === "fullWidth" ? "fullWidth" : this.state.rxData.variant === "centered" ? void 0 : "scrollable",
orientation: this.state.rxData.vertical ? "vertical" : void 0,
children: tabs
})
}),
this.getWidgetView()
]
});
}
}
class InstallSwipe {
el;
locked = false;
x0 = null;
onSwipeLeft = null;
onSwipeRight = null;
hideIndication = false;
indicationLeft = "";
indicationRight = "";
swipeThreshold = 30;
indicatorNode = null;
constructor(options) {
this.onSwipeRight = options.onSwipeRight;
this.onSwipeLeft = options.onSwipeLeft;
}
install(el, options) {
if (el) {
this.el = el;
}
if (options) {
if (options.hideIndication !== void 0) {
this.hideIndication = options.hideIndication;
}
if (options.indicationLeft !== void 0) {
this.indicationLeft = options.indicationLeft;
}
if (options.indicationRight !== void 0) {
this.indicationRight = options.indicationRight;
}
if (options.swipeThreshold !== void 0) {
this.swipeThreshold = Math.abs(options.swipeThreshold) || 30;
}
}
this.init();
}
destroy() {
var _a;
if ((_a = this.el) == null ? void 0 : _a._swipe) {
this.el.removeEventListener("mousedown", this.moveStart, false);
this.el.removeEventListener("touchstart", this.moveStart, false);
delete this.el._swipe;
this.removeIndicator();
}
}
static unify(e2) {
return e2.changedTouches ? e2.changedTouches[0] : e2;
}
move = (e2) => {
e2.preventDefault();
if (this.locked) {
const dx = InstallSwipe.unify(e2).clientX - this.x0;
if (dx > 0 && this.onSwipeRight && this.indicationRight) {
this.el.style.transform = `translateX(${dx}px)`;
} else if (dx < 0 && this.onSwipeLeft && this.indicationLeft) {
this.el.style.transform = `translateX(${dx}px)`;
}
if (Math.abs(dx) > this.swipeThreshold) {
this.showIndication(dx);
} else if (this.indicatorNode) {
this.indicatorNode.style.display = "none";
}
}
};
removeIndicator() {
if (this.indicatorNode) {
this.indicatorNode.remove();
this.indicatorNode = null;
}
if (this.locked) {
if (this.el) {
this.el.style.transform = "";
this.el.removeEventListener("mousemove", this.move, false);
this.el.removeEventListener("touchmove", this.move, false);
this.el.removeEventListener("mouseup", this.moveEnd, false);
this.el.removeEventListener("touchend", this.moveEnd, false);
}
this.x0 = null;
this.locked = false;
}
}
moveEnd = (e2) => {
if (this.locked) {
const dx = InstallSwipe.unify(e2).clientX - this.x0;
this.removeIndicator();
if (dx > this.swipeThreshold && this.onSwipeRight) {
this.onSwipeRight();
} else if (dx < -1 * this.swipeThreshold && this.onSwipeLeft) {
this.onSwipeLeft();
}
}
};
moveStart = (e2) => {
if (!this.locked) {
this.locked = true;
this.x0 = InstallSwipe.unify(e2).clientX;
this.el.addEventListener("mousemove", this.move, false);
this.el.addEventListener("touchmove", this.move, false);
this.el.addEventListener("mouseup", this.moveEnd, false);
this.el.addEventListener("touchend", this.moveEnd, false);
}
};
init() {
if (!this.el._swipe) {
this.el.addEventListener("mousedown", this.moveStart, false);
this.el.addEventListener("touchstart", this.moveStart, false);
this.el._swipe = true;
}
}
showIndication(dx) {
if (this.hideIndication) {
return;
}
if (!this.indicatorNode) {
this.indicatorNode = document.createElement("div");
this.indicatorNode.style.position = "absolute";
this.indicatorNode.setAttribute("id", "vis-2-swipe-indicator");
this.indicatorNode.style.top = "calc(50% - 16px)";
this.indicatorNode.style.zIndex = "2000";
this.indicatorNode.style.fontSize = "32px";
this.el.parentNode.appendChild(this.indicatorNode);
}
if (dx > this.swipeThreshold) {
this.indicatorNode.innerHTML = `\u2190 ${this.indicationRight}`;
this.indicatorNode.style.left = "5%";
this.indicatorNode.style.right = "";
this.indicatorNode.style.display = "block";
} else if (dx < -1 * this.swipeThreshold) {
this.indicatorNode.innerHTML = `${this.indicationLeft} \u2192`;
this.indicatorNode.style.right = "5%";
this.indicatorNode.style.left = "";
this.indicatorNode.style.display = "block";
} else {
this.indicatorNode.style.display = "none";
}
}
}
class Swipe extends VisRxWidget {
swipeable = null;
static getWidgetInfo() {
return {
id: "tplSwipe",
visSet: "swipe",
visName: "Swipe Navigation",
visSetLabel: "vis_2_widgets_widgets_swipe_label",
visPrev: "widgets/swipe/img/Prev_Swipe.png",
visWidgetLabel: "vis_2_widgets_widgets_swipe_label",
visSetIcon: "widgets/swipe/img/Prev_Swipe.png",
visAttrs: [
{
name: "common",
fields: [
{
name: "left_nav_view",
type: "select-views",
multiple: false
},
{
name: "right_nav_view",
type: "select-views",
multiple: false
},
{
name: "hideIndication",
label: "vis_2_widgets_swipe_hide_indication_label",
type: "checkbox"
},
{
name: "threshold",
label: "vis_2_widgets_swipe_threshold_label",
type: "number",
default: 30
}
]
}
],
visDefaultStyle: {
width: 160,
height: 82
}
};
}
componentDidMount() {
super.componentDidMount();
this.swipeable = this.swipeable || new InstallSwipe({
onSwipeLeft: () => {
if (this.state.rxData.left_nav_view) {
this.props.context.changeView(this.state.rxData.left_nav_view);
}
},
onSwipeRight: () => {
if (this.state.rxData.right_nav_view) {
this.props.context.changeView(this.state.rxData.right_nav_view);
}
}
});
}
getWidgetInfo() {
return Swipe.getWidgetInfo();
}
renderWidgetBody(props) {
var _a, _b, _c, _d;
super.renderWidgetBody(props);
if (this.props.editMode) {
(_a = this.swipeable) == null ? void 0 : _a.destroy();
return jsxRuntimeExports.jsxs("div", {
className: "vis-widget-body",
children: [
jsxRuntimeExports.jsx("div", {
style: {
fontWeight: "bold"
},
children: __mf_2$1.t("Swipe Navigation")
}),
jsxRuntimeExports.jsx("table", {
children: jsxRuntimeExports.jsxs("tbody", {
children: [
jsxRuntimeExports.jsxs("tr", {
children: [
jsxRuntimeExports.jsx("td", {
style: {
width: 40
},
children: __mf_2$1.t("left")
}),
jsxRuntimeExports.jsx("td", {
style: {
width: 20
},
children: ">"
}),
jsxRuntimeExports.jsx("td", {
children: this.state.rxData.left_nav_view
})
]
}),
jsxRuntimeExports.jsxs("tr", {
children: [
jsxRuntimeExports.jsx("td", {
style: {
width: 40
},
children: __mf_2$1.t("right")
}),
jsxRuntimeExports.jsx("td", {
style: {
width: 20
},
children: "<"
}),
jsxRuntimeExports.jsx("td", {
children: this.state.rxData.right_nav_view
})
]
})
]
})
})
]
});
}
const viewEl = (_b = this.props.refParent) == null ? void 0 : _b.current;
if (this.swipeable && viewEl) {
this.swipeable.install(viewEl, {
hideIndication: this.state.rxData.hideIndication,
indicationRight: this.state.rxData.right_nav_view ? ((_c = this.props.context.views[this.state.rxData.right_nav_view]) == null ? void 0 : _c.name) || this.state.rxData.right_nav_view : "",
indicationLeft: this.state.rxData.left_nav_view ? ((_d = this.props.context.views[this.state.rxData.left_nav_view]) == null ? void 0 : _d.name) || this.state.rxData.left_nav_view : "",
swipeThreshold: this.state.rxData.threshold || 30
});
}
return null;
}
}
const WIDGETS = [
BasicBar,
BasicBulb,
BasicHtml,
BasicHtmlNav,
BasicFilterDropdown,
BasicLink,
BasicValueString,
BasicValueInput,
BasicViewInWidget,
BasicViewInWidget8,
BasicGroup,
BasicSvgBool,
BasicRedNumber,
BasicSvgShape,
BasicScreenResolution,
BasicSpeechToText,
BasicIFrame,
BasicIFrame8,
BasicImage,
BasicImage8,
BasicFrame,
BasicNote,
BasicLogout,
JQuiButton,
JQuiButtonBlank,
JQuiIconLink,
JQuiIconInc,
JQuiIconHttpGet,
JQuiDialog,
JQuiIconDialog,
JQuiContainerDialog,
JQuiButtonNavigation,
JQuiIconNavigation,
JQuiButtonPasswordNavigation,
JQuiDialogExternal,
JQuiContainerButtonDialog,
JQuiContainerIconDialog,
JQuiButtonDialogClose,
JQuiInput,
JQuiInputSet,
JQuiBinaryState,
JQuiRadio,
JQuiState,
JQuiRadioList,
JQuiSelectList,
JQuiRadioSteps,
JQuiWriteState,
JQuiSlider,
JQuiSliderVertical,
JQuiIconStatePushButton,
JQuiIconStateBool,
JQuiInputDate,
JQuiInputDateTime,
JQuiToggle,
TabsSliderTabs,
Swipe
];
const DEFAULT_SET_COLORS = {
basic: "#f1f1f1",
bars: "#f6594e",
dwd: "#cb8928",
echarts: "#98B1C0",
eventlist: "#c52699",
hqwidgets: "#005067",
jqplot: "#00e753",
jqui: "#008be0",
metro: "#9f8ad8",
swipe: "#858585",
tabs: "#00d5a3",
"spotify-premium": "#00ae03"
};
getWidgetTypes = (usedWidgetSets) => {
if (!window.visWidgetTypes) {
window.visSets = {};
VisWidgetsCatalog.allWidgetsList = [];
if (!VisWidgetsCatalog.rxWidgets) {
return [];
}
window.visWidgetTypes = Array.from(document.querySelectorAll('script[type="text/ejs"]')).map((script) => {
var _a, _b, _c;
const name = script.getAttribute("id");
if (!name || !VisWidgetsCatalog.rxWidgets) {
return null;
}
let info;
if ((_a = VisWidgetsCatalog.rxWidgets[name]) == null ? void 0 : _a.getWidgetInfo) {
info = VisWidgetsCatalog.rxWidgets[name].getWidgetInfo();
if ((info == null ? void 0 : info.visAttrs) && typeof info.visAttrs !== "string") {
return null;
}
}
const widgetSet = script.getAttribute("data-vis-set") || "basic";
if (usedWidgetSets && !usedWidgetSets.includes(widgetSet)) {
console.log(`Ignored ${widgetSet}/${name} because not used in project`);
return null;
}
const color = script.getAttribute("data-vis-color");
(_b = window.visSets)[widgetSet] || (_b[widgetSet] = {});
if (color) {
window.visSets[widgetSet].color = color;
} else if (!window.visSets[widgetSet].color && DEFAULT_SET_COLORS[widgetSet]) {
window.visSets[widgetSet].color = DEFAULT_SET_COLORS[widgetSet];
}
const widgetObj = {
name,
title: (info == null ? void 0 : info.visName) || script.getAttribute("data-vis-name") || void 0,
label: (info == null ? void 0 : info.visWidgetLabel) || (info == null ? void 0 : info.visWidgetLabel) === "" ? info.visWidgetLabel : void 0,
preview: (info == null ? void 0 : info.visPrev) || script.getAttribute("data-vis-prev") || void 0,
help: script.getAttribute("data-vis-help") || void 0,
set: (info == null ? void 0 : info.visSet) || widgetSet,
imageHTML: script.getAttribute("data-vis-prev") || "",
init: script.getAttribute("data-vis-init") || void 0,
color: (info == null ? void 0 : info.visWidgetColor) || void 0,
params: (info == null ? void 0 : info.visAttrs) || Object.values(script.attributes).filter((attribute) => attribute.name.startsWith("data-vis-attrs")).map((attribute) => attribute.value).join(""),
setLabel: (info == null ? void 0 : info.visSetLabel) || void 0,
setColor: (info == null ? void 0 : info.visSetColor) || void 0,
order: (info == null ? void 0 : info.visOrder) === void 0 || (info == null ? void 0 : info.visOrder) === null ? 1e3 : typeof info.visOrder === "string" ? parseInt(info.visOrder, 10) : info.visOrder,
hidden: script.getAttribute("data-vis-no-palette") === "true"
};
(_c = VisWidgetsCatalog.allWidgetsList) == null ? void 0 : _c.push(widgetObj.name);
return widgetObj;
}).filter((w2) => w2);
const widgets = Object.values(VisWidgetsCatalog.rxWidgets);
widgets.forEach((widget) => {
var _a;
const widgetInfo = widget.getWidgetInfo();
const i18nPrefix = widget.i18nPrefix || "";
const widgetObj = {
name: widgetInfo.id,
preview: widgetInfo.visPrev,
title: widgetInfo.visName,
params: widgetInfo.visAttrs,
set: widgetInfo.visSet,
style: widgetInfo.visDefaultStyle,
label: widgetInfo.visWidgetLabel ? i18nPrefix + widgetInfo.visWidgetLabel : widgetInfo.visWidgetLabel === "" ? "" : void 0,
setLabel: widgetInfo.visSetLabel ? i18nPrefix + widgetInfo.visSetLabel : void 0,
setColor: widgetInfo.visSetColor,
setIcon: widgetInfo.visSetIcon || (widget.setIcon && widget.adapter && widget.setIcon ? `../adapter/${widget.adapter}/${widget.setIcon}` : void 0),
color: widgetInfo.visWidgetColor,
resizable: widgetInfo.visResizable,
resizeLocked: widgetInfo.visResizeLocked,
draggable: widgetInfo.visDraggable,
adapter: widget.adapter || void 0,
version: widget.version || void 0,
hidden: widget.visHidden,
order: widgetInfo.visOrder === void 0 ? 1e3 : widgetInfo.visOrder,
customPalette: widgetInfo.customPalette,
rx: true,
developerMode: (_a = widget.url) == null ? void 0 : _a.startsWith("http://"),
i18nPrefix
};
if (VisWidgetsCatalog.allWidgetsList && !VisWidgetsCatalog.allWidgetsList.includes(widgetObj.name)) {
VisWidgetsCatalog.allWidgetsList.push(widgetObj.name);
}
const index = window.visWidgetTypes.findIndex((item) => item.name === widgetObj.name);
if (index > -1) {
window.visWidgetTypes[index] = widgetObj;
} else {
window.visWidgetTypes.push(widgetObj);
}
if (i18nPrefix && typeof widgetInfo.visAttrs === "object") {
widgetInfo.visAttrs.forEach((group) => {
if (group.label && !group.label.startsWith(i18nPrefix)) {
group.label = i18nPrefix + group.label;
}
if (group.fields) {
group.fields.forEach((field) => {
const _field = field;
if (_field.label && !_field.label.startsWith(i18nPrefix)) {
_field.label = i18nPrefix + _field.label;
}
if (_field.tooltip && !_field.tooltip.startsWith(i18nPrefix)) {
_field.tooltip = i18nPrefix + _field.tooltip;
}
if (_field.options && !_field.noTranslation && Array.isArray(_field.options)) {
_field.options.forEach((option) => {
if (typeof option === "object") {
if (option.label && !option.label.startsWith(i18nPrefix)) {
option.label = i18nPrefix + option.label;
}
}
});
}
});
}
});
}
});
}
return window.visWidgetTypes;
};
VisWidgetsCatalog = class {
static rxWidgets = null;
static allWidgetsList = null;
static additionalSets = null;
static getUsedWidgetSets(project) {
let anyWithoutSet = false;
const widgetSets = [];
const views = Object.keys(project);
for (let v2 = 0; v2 < views.length; v2++) {
if (views[v2] === "___settings") {
continue;
}
const widgets = project[views[v2]].widgets;
const keys = Object.keys(widgets);
for (let w2 = 0; w2 < keys.length; w2++) {
const widgetSet = widgets[keys[w2]].widgetSet;
if (!widgetSet || widgets[keys[w2]].wSet || widgets[keys[w2]].set) {
anyWithoutSet = true;
break;
}
if (!widgetSets.includes(widgetSet)) {
widgetSets.push(widgetSet);
}
}
if (anyWithoutSet) {
console.warn("Found widgets without widget set. Will load all widget sets");
break;
}
}
!anyWithoutSet && widgetSets.sort();
return anyWithoutSet ? false : widgetSets;
}
static setUsedWidgetSets(project) {
let views;
const widgetTypes = window.visWidgetTypes;
const viewKeys = Object.keys(project);
for (let v2 = 0; v2 < viewKeys.length; v2++) {
if (viewKeys[v2] === "___settings") {
continue;
}
const widgets = project[viewKeys[v2]].widgets;
const keys = Object.keys(widgets);
for (let w2 = 0; w2 < keys.length; w2++) {
if (widgets[keys[w2]].set) {
views || (views = JSON.parse(JSON.stringify(project)));
delete views[viewKeys[v2]].widgets[keys[w2]].set;
}
if (widgets[keys[w2]].wSet) {
views || (views = JSON.parse(JSON.stringify(project)));
delete views[viewKeys[v2]].widgets[keys[w2]].wSet;
}
if (widgets[keys[w2]].widgetSet) {
continue;
}
const tpl = widgets[keys[w2]].tpl;
if (tpl === "_tplGroup") {
views || (views = JSON.parse(JSON.stringify(project)));
views[viewKeys[v2]].widgets[keys[w2]].widgetSet = "basic";
} else {
const tplWidget = widgetTypes.find((item) => item.name === tpl);
if (tplWidget) {
views || (views = JSON.parse(JSON.stringify(project)));
views[viewKeys[v2]].widgets[keys[w2]].widgetSet = tplWidget.set;
}
}
}
}
return views;
}
static collectRxInformation(socket, project, changeProject) {
if (!VisWidgetsCatalog.rxWidgets) {
VisWidgetsCatalog.rxWidgets = {};
let usedWidgetSets = null;
if (project) {
usedWidgetSets = VisWidgetsCatalog.getUsedWidgetSets(project);
}
return new Promise((resolve) => {
setTimeout(() => getRemoteWidgets(socket, !changeProject && usedWidgetSets ? usedWidgetSets : false).then((result) => {
const collectedWidgets = [
...WIDGETS,
...(result == null ? void 0 : result.widgetSets) || []
];
VisWidgetsCatalog.additionalSets = (result == null ? void 0 : result.additionalSets) || {};
collectedWidgets.forEach((WidgetEl) => {
if (!(WidgetEl == null ? void 0 : WidgetEl.getWidgetInfo)) {
console.error(`Invalid widget without getWidgetInfo: ${WidgetEl.constructor.name}`);
} else {
const info = WidgetEl.getWidgetInfo();
if (!info.visSet) {
console.error(`No visSet in info for "${WidgetEl.constructor.name}"`);
}
if (!info.id) {
console.error(`No id in info for "${WidgetEl.constructor.name}"`);
} else if (VisWidgetsCatalog.rxWidgets) {
VisWidgetsCatalog.rxWidgets[info.id] = WidgetEl;
}
}
});
if (changeProject) {
getWidgetTypes();
} else if (usedWidgetSets) {
getWidgetTypes(usedWidgetSets);
} else {
getWidgetTypes();
}
if (usedWidgetSets === false && changeProject) {
const newProject = VisWidgetsCatalog.setUsedWidgetSets(project);
if (newProject) {
console.warn("Found widgets without widget set. Project updated");
changeProject(newProject);
}
}
resolve(VisWidgetsCatalog.rxWidgets);
}), 0);
});
}
return Promise.resolve(VisWidgetsCatalog.rxWidgets);
}
};
function deepCloneRx(obj) {
if (Array.isArray(obj)) {
const newObj2 = [];
for (let key = 0; key < obj.length; key++) {
if (obj[key] !== void 0) {
if (Array.isArray(obj[key]) || typeof obj[key] === "object") {
if (Object.prototype.hasOwnProperty.call(obj, "$$typeof")) {
newObj2[key] = obj[key];
} else {
newObj2[key] = deepCloneRx(obj[key]);
}
} else {
newObj2[key] = obj[key];
}
}
}
return newObj2;
}
const newObj = {};
for (const key in obj) {
if (obj[key] !== void 0) {
if (Array.isArray(obj[key]) || typeof obj[key] === "object") {
if (Object.prototype.hasOwnProperty.call(obj, "$$typeof")) {
newObj[key] = obj[key];
} else {
newObj[key] = deepCloneRx(obj[key]);
}
} else {
newObj[key] = obj[key];
}
}
}
return newObj;
}
parseAttributes = (widgetParams, widgetIndex, commonGroups, commonFields, widgetSet, widgetData) => {
var _a;
if (typeof widgetParams === "string") {
let groupName = "common";
let indexedGroups = {};
let isIndexedGroup = false;
commonGroups || (commonGroups = {
common: 1
});
commonFields || (commonFields = {});
const fields = [
{
name: "common",
singleName: "common",
fields: []
}
];
let currentGroup = fields[0];
widgetIndex || (widgetIndex = 0);
widgetParams.split(";").forEach((fieldString) => {
var _a2, _b, _c, _d, _e, _f;
if (!fieldString) {
return;
}
if (fieldString.startsWith("group.")) {
const pparts = fieldString.split("/");
groupName = pparts[0].split(".")[1];
if (widgetIndex !== void 0 && widgetIndex > 0 && commonGroups && !commonGroups[groupName]) {
return;
}
indexedGroups = {};
if (pparts[1] !== "byindex") {
currentGroup = fields.find((group) => group.name === groupName);
if (!currentGroup) {
fields.push({
name: groupName,
singleName: groupName,
fields: []
});
currentGroup = fields[fields.length - 1];
}
if (commonGroups) {
if (!commonGroups[groupName]) {
commonGroups[groupName] = 0;
}
commonGroups[groupName]++;
}
isIndexedGroup = false;
} else {
isIndexedGroup = true;
}
} else {
const match2 = fieldString.match(/([a-zA-Z0-9._-]+)(\([a-zA-Z.0-9-_]*\))?(\[.*])?(\/[-_,^§~\s:/.a-zA-Z0-9]+)?/);
if (!match2) {
console.warn(`Invalid attribute ${fieldString}`);
return;
}
const repeats = match2[2];
let type;
let onChangeFunc;
if (match2[4]) {
const parts = match2[4].substring(1).split("/");
type = parts[0];
onChangeFunc = parts[1];
} else {
type = null;
}
const field = {
name: match2[1],
default: match2[3] ? match2[3].substring(1, match2[3].length - 1) : void 0,
type,
onChangeFunc
};
if (field.type) {
field.type = field.type.replace(/§/g, ";").replace(/~/g, "/").replace(/\^/g, '"').replace(/\^\^/g, "^");
}
if (typeof field.default === "string") {
field.default = field.default.replace(/§/g, ";").replace(/~/g, "/").replace(/\^/g, '"').replace(/\^\^/g, "^");
}
if ((_a2 = field.onChangeFunc) == null ? void 0 : _a2.startsWith("filterType")) {
field.filter = field.onChangeFunc.substring("filterType".length).toLowerCase();
delete field.onChangeFunc;
}
if (widgetIndex && widgetIndex > 0 && !repeats && commonFields && !commonFields[`${groupName}.${field.name}`]) {
return;
}
if (field.name === "oid" || field.name.match(/^oid-/)) {
field.type || (field.type = "id");
} else if (field.name === "color") {
field.type = "color";
} else if (field.name.match(/nav_view$/)) {
field.type = "views";
} else if (field.name === "sound") {
field.type = "text";
} else if (field.name.includes("_effect")) {
field.type = "text";
} else if (field.name.includes("_eff_opt")) {
field.type = "text";
} else if (!field.type) {
field.type = "text";
}
if (field.type && field.type.startsWith("id,")) {
const options = field.type.split(",");
field.type = options[0];
field.filter = options[1];
}
if (field.type && (field.type.startsWith("select,") || field.type.startsWith("nselect,") || field.type.startsWith("auto,"))) {
const options = field.type.split(",");
field.type = options[0];
field.options = options.slice(1);
}
if (field.type && (field.type.startsWith("slider,") || field.type.startsWith("number,"))) {
const options = field.type.split(",");
field.type = options[0];
field.min = parseInt(options[1]);
field.max = parseInt(options[2]);
field.step = parseInt(options[3]);
if (!field.step) {
field.step = field.max - field.min / 100;
}
}
if (field.type && field.type.startsWith("style,")) {
const options = field.type.split(",");
field.type = options[0];
field.filterFile = options[1];
field.filterName = options[2];
field.filterAttrs = options[3];
field.removeName = options[4];
if (!field.step && field.max !== void 0 && field.min !== void 0) {
field.step = field.max - field.min / 100;
}
}
if ((_b = field.type) == null ? void 0 : _b.startsWith("style,")) {
console.warn(`Attribute "${field.name}" of ${widgetSet} has wrong type: ${field.type}`);
field.type = field.type.split(",")[0];
}
field.singleName = field.name;
field.set = widgetSet;
if (repeats) {
const repeatsMatch = repeats.match(/\(([0-9a-z_]+)-([0-9a-z_]+)\)/i);
const name = field.name;
if (repeatsMatch) {
let from = 1;
let to = 1;
if (!repeatsMatch[1].match(/^[0-9]$/)) {
from = widgetData ? parseInt(widgetData[repeatsMatch[1]]) : 0;
}
if (!repeatsMatch[2].match(/^[0-9]$/)) {
to = widgetData ? parseInt(widgetData[repeatsMatch[2]]) : 0;
}
for (let i = from; i <= to; i++) {
if (isIndexedGroup) {
if (commonGroups && widgetIndex && widgetIndex > 0 && !commonGroups[`${groupName}-${i}`]) {
return;
}
if (commonFields && widgetIndex && widgetIndex > 0 && !commonFields[`${groupName}-${i}.${field.name}`]) {
return;
}
if (!indexedGroups[i]) {
currentGroup = {
name: `${groupName}-${i}`,
singleName: groupName,
index: i,
fields: []
};
indexedGroups[i] = currentGroup;
fields.push(currentGroup);
}
if (commonGroups) {
if (!commonGroups[`${groupName}-${i}`]) {
commonGroups[`${groupName}-${i}`] = 0;
}
commonGroups[`${groupName}-${i}`]++;
}
field.name = `${name}${i}`;
(_d = (_c = indexedGroups[i]) == null ? void 0 : _c.fields) == null ? void 0 : _d.push({
...field
});
if (commonFields) {
if (!commonFields[`${groupName}-${i}.${field.name}`]) {
commonFields[`${groupName}-${i}.${field.name}`] = 0;
}
commonFields[`${groupName}-${i}.${field.name}`]++;
}
} else {
field.name = `${name}${i}`;
field.index = i;
(_e = currentGroup == null ? void 0 : currentGroup.fields) == null ? void 0 : _e.push({
...field
});
if (commonFields) {
if (!commonFields[`${groupName}.${field.name}`]) {
commonFields[`${groupName}.${field.name}`] = 0;
}
commonFields[`${groupName}.${field.name}`]++;
}
}
}
}
} else {
(_f = currentGroup == null ? void 0 : currentGroup.fields) == null ? void 0 : _f.push(field);
if (commonFields) {
if (!commonFields[`${groupName}.${field.name}`]) {
commonFields[`${groupName}.${field.name}`] = 0;
}
commonFields[`${groupName}.${field.name}`]++;
}
}
}
});
return fields;
}
if (Array.isArray(widgetParams)) {
commonGroups || (commonGroups = {
common: 1
});
commonFields || (commonFields = {});
const fields = deepCloneRx(widgetParams);
let groupIndex = fields.findIndex((group) => typeof group.indexFrom === "number");
while (groupIndex > -1) {
const group = fields[groupIndex];
group.singleName = group.name;
let from;
let indexFrom;
if (Number.isInteger(group.indexFrom)) {
from = group.indexFrom;
} else {
from = parseInt(widgetData == null ? void 0 : widgetData[group.indexFrom || 1]);
indexFrom = from;
}
let to;
let indexTo;
if (Number.isInteger(group.indexTo)) {
to = parseInt(group.indexTo || "1", 10);
} else {
to = parseInt(widgetData == null ? void 0 : widgetData[group.indexTo || 1]);
indexTo = group.indexTo;
}
delete group.indexFrom;
delete group.indexTo;
const indexedGroups = [];
for (let i = from; i <= to; i++) {
const indexedGroup = {
...deepCloneRx(group),
index: i,
name: `${group.singleName}-${i}`,
hidden: group.hidden,
iterable: {
group: group.singleName || "",
isFirst: i === from,
isLast: i === to,
indexTo,
indexFrom
}
};
(_a = indexedGroup.fields) == null ? void 0 : _a.forEach((field, ii) => {
field.singleName = field.name;
field.name = `${field.name}${i}`;
field.index = i;
if (group.fields && group.fields[ii]) {
if (typeof group.fields[ii].hidden === "function") {
field.hidden = group.fields[ii].hidden;
}
if (typeof group.fields[ii].component === "function") {
field.component = group.fields[ii].component;
}
if (typeof group.fields[ii].onChange === "function") {
field.onChange = group.fields[ii].onChange;
}
if (typeof group.fields[ii].disabled === "function") {
field.disabled = group.fields[ii].disabled;
}
if (typeof group.fields[ii].error === "function") {
field.error = group.fields[ii].error;
}
}
});
indexedGroups.push(indexedGroup);
}
fields.splice(groupIndex, 1, ...indexedGroups);
groupIndex = fields.findIndex((_group) => _group.indexFrom);
}
fields.forEach((group) => {
var _a2;
if (!group.name) {
group.name = "common";
}
if (!group.singleName) {
group.singleName = group.name;
}
if (commonGroups) {
if (!commonGroups[group.name]) {
commonGroups[group.name] = 0;
}
commonGroups[group.name]++;
}
if (group.fields) {
let fieldIndex = group.fields.findIndex((field) => field.indexFrom);
while (fieldIndex > -1) {
const field = group.fields[fieldIndex];
field.singleName = field.name;
let from = 1;
let indexFrom;
if (Number.isInteger(field.indexFrom)) {
from = parseInt(field.indexFrom, 10);
} else if (typeof field.indexFrom === "string") {
from = parseInt(widgetData == null ? void 0 : widgetData[field.indexFrom]);
indexFrom = from;
}
let to = 1;
let indexTo;
if (Number.isInteger(field.indexTo)) {
to = parseInt(field.indexTo, 10);
} else if (typeof field.indexTo === "string") {
to = parseInt(widgetData == null ? void 0 : widgetData[field.indexTo]);
indexTo = field.indexTo;
}
delete field.indexFrom;
delete field.indexTo;
const indexedFields = [];
for (let i = from; i <= to; i++) {
const indexedField = deepCloneRx(field);
indexedField.index = i;
indexedField.name = `${field.singleName}${i}`;
indexedField.iterable = {
group: field.singleName,
isFirst: i === from,
isLast: i === to,
indexFrom,
indexTo
};
indexedFields.push(indexedField);
}
(_a2 = group.fields) == null ? void 0 : _a2.splice(fieldIndex, 1, ...indexedFields);
fieldIndex = group.fields.findIndex((_field) => _field.indexFrom);
}
group.fields.forEach((field) => {
if (!field.singleName) {
field.singleName = field.name;
}
field.set = widgetSet;
if (commonFields) {
if (!commonFields[`${group.name}.${field.name}`]) {
commonFields[`${group.name}.${field.name}`] = 0;
}
commonFields[`${group.name}.${field.name}`]++;
}
});
}
});
return fields;
}
return null;
};
});
export {
ConnectedDroppable as C,
DragDropContext as D,
FaFolderOpen as F,
GenIcon as G,
HTML5Backend as H,
MaterialIconSelector as M,
PublicDraggable as P,
UploadFile as U,
VisWidgetsCatalog as V,
__tla,
useCollector as a,
useDrag as b,
commonStyles as c,
FaFolder as d,
useDrop as e,
DndProvider as f,
getWidgetTypes as g,
VisView as h,
invariant$2 as i,
registerWidgetsLoadIndicator as j,
createTheme as k,
parseAttributes as p,
reactIsExports as r,
useDragDropManager as u,
v4 as v
};