} rest Any additional arguments will be used\n * as replacement children.\n * @returns {VNode}\n */\nexport function cloneElement(vnode, props, children) {\n\tlet normalizedProps = assign({}, vnode.props),\n\t\tkey,\n\t\tref,\n\t\ti;\n\n\tlet defaultProps;\n\n\tif (vnode.type && vnode.type.defaultProps) {\n\t\tdefaultProps = vnode.type.defaultProps;\n\t}\n\n\tfor (i in props) {\n\t\tif (i == 'key') key = props[i];\n\t\telse if (i == 'ref') ref = props[i];\n\t\telse if (props[i] === undefined && defaultProps !== undefined) {\n\t\t\tnormalizedProps[i] = defaultProps[i];\n\t\t} else {\n\t\t\tnormalizedProps[i] = props[i];\n\t\t}\n\t}\n\n\tif (arguments.length > 2) {\n\t\tnormalizedProps.children =\n\t\t\targuments.length > 3 ? slice.call(arguments, 2) : children;\n\t}\n\n\treturn createVNode(\n\t\tvnode.type,\n\t\tnormalizedProps,\n\t\tkey || vnode.key,\n\t\tref || vnode.ref,\n\t\tnull\n\t);\n}\n", "/**\n * Find the closest error boundary to a thrown error and call it\n * @param {object} error The thrown value\n * @param {VNode} vnode The vnode that threw the error that was caught (except\n * for unmounting when this parameter is the highest parent that was being\n * unmounted)\n * @param {VNode} [oldVNode]\n * @param {ErrorInfo} [errorInfo]\n */\nexport function _catchError(error, vnode, oldVNode, errorInfo) {\n\t/** @type {Component} */\n\tlet component,\n\t\t/** @type {ComponentType} */\n\t\tctor,\n\t\t/** @type {boolean} */\n\t\thandled;\n\n\tfor (; (vnode = vnode._parent); ) {\n\t\tif ((component = vnode._component) && !component._processingException) {\n\t\t\ttry {\n\t\t\t\tctor = component.constructor;\n\n\t\t\t\tif (ctor && ctor.getDerivedStateFromError != null) {\n\t\t\t\t\tcomponent.setState(ctor.getDerivedStateFromError(error));\n\t\t\t\t\thandled = component._dirty;\n\t\t\t\t}\n\n\t\t\t\tif (component.componentDidCatch != null) {\n\t\t\t\t\tcomponent.componentDidCatch(error, errorInfo || {});\n\t\t\t\t\thandled = component._dirty;\n\t\t\t\t}\n\n\t\t\t\t// This is an error boundary. Mark it as having bailed out, and whether it was mid-hydration.\n\t\t\t\tif (handled) {\n\t\t\t\t\treturn (component._pendingError = component);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\terror = e;\n\t\t\t}\n\t\t}\n\t}\n\n\tthrow error;\n}\n", "/**\n * Check if an object is a DOM element. Duck-typing based on `nodeType`.\n */\nexport default function isDOMElement(obj) {\n if (typeof obj !== 'object' || obj === null) return false;\n if (!('nodeType' in obj)) return false;\n return obj.nodeType === Node.ELEMENT_NODE;\n}", "import isDOMElement from \"./isDOMElement.js\";\nfunction findDOMElement(element, context) {\n if (context === void 0) {\n context = document;\n }\n if (typeof element === 'string') {\n return context.querySelector(element);\n }\n if (isDOMElement(element)) {\n return element;\n }\n return null;\n}\nexport default findDOMElement;", "/**\n * Get the declared text direction for an element.\n */\n\nfunction getTextDirection(element) {\n var _element;\n // There is another way to determine text direction using getComputedStyle(), as done here:\n // https://github.com/pencil-js/text-direction/blob/2a235ce95089b3185acec3b51313cbba921b3811/text-direction.js\n //\n // We do not use that approach because we are interested specifically in the _declared_ text direction.\n // If no text direction is declared, we have to provide our own explicit text direction so our\n // bidirectional CSS style sheets work.\n while (element && !element.dir) {\n // eslint-disable-next-line no-param-reassign\n element = element.parentNode;\n }\n return (_element = element) == null ? void 0 : _element.dir;\n}\nexport default getTextDirection;", "/* eslint-disable class-methods-use-this */\n\n/**\n * Core plugin logic that all plugins share.\n *\n * BasePlugin does not contain DOM rendering so it can be used for plugins\n * without a user interface.\n *\n * See `Plugin` for the extended version with Preact rendering for interfaces.\n */\n\nimport Translator from '@uppy/utils/lib/Translator';\n\n/**\n * DefinePluginOpts marks all of the passed AlwaysDefinedKeys as \u201Crequired\u201D or \u201Calways defined\u201D.\n */\n\nexport default class BasePlugin {\n constructor(uppy, opts) {\n this.uppy = uppy;\n this.opts = opts != null ? opts : {};\n }\n getPluginState() {\n const {\n plugins\n } = this.uppy.getState();\n return (plugins == null ? void 0 : plugins[this.id]) || {};\n }\n setPluginState(update) {\n const {\n plugins\n } = this.uppy.getState();\n this.uppy.setState({\n plugins: {\n ...plugins,\n [this.id]: {\n ...plugins[this.id],\n ...update\n }\n }\n });\n }\n setOptions(newOpts) {\n this.opts = {\n ...this.opts,\n ...newOpts\n };\n this.setPluginState(undefined); // so that UI re-renders with new options\n this.i18nInit();\n }\n i18nInit() {\n const translator = new Translator([this.defaultLocale, this.uppy.locale, this.opts.locale]);\n this.i18n = translator.translate.bind(translator);\n this.i18nArray = translator.translateArray.bind(translator);\n this.setPluginState(undefined); // so that UI re-renders and we see the updated locale\n }\n\n /**\n * Extendable methods\n * ==================\n * These methods are here to serve as an overview of the extendable methods as well as\n * making them not conditional in use, such as `if (this.afterUpdate)`.\n */\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n addTarget(plugin) {\n throw new Error(\"Extend the addTarget method to add your plugin to another plugin's target\");\n }\n install() {}\n uninstall() {}\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n update(state) {}\n\n // Called after every state update, after everything's mounted. Debounced.\n afterUpdate() {}\n}", "function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError(\"attempted to use private field on non-instance\"); return e; }\nvar id = 0;\nfunction _classPrivateFieldLooseKey(e) { return \"__private_\" + id++ + \"_\" + e; }\n/* eslint-disable class-methods-use-this */\nimport { render } from 'preact';\nimport findDOMElement from '@uppy/utils/lib/findDOMElement';\nimport getTextDirection from '@uppy/utils/lib/getTextDirection';\nimport BasePlugin from \"./BasePlugin.js\";\n/**\n * Defer a frequent call to the microtask queue.\n */\nfunction debounce(fn) {\n let calling = null;\n let latestArgs;\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n latestArgs = args;\n if (!calling) {\n calling = Promise.resolve().then(() => {\n calling = null;\n // At this point `args` may be different from the most\n // recent state, if multiple calls happened since this task\n // was queued. So we use the `latestArgs`, which definitely\n // is the most recent call.\n return fn(...latestArgs);\n });\n }\n return calling;\n };\n}\n\n/**\n * UIPlugin is the extended version of BasePlugin to incorporate rendering with Preact.\n * Use this for plugins that need a user interface.\n *\n * For plugins without an user interface, see BasePlugin.\n */\nvar _updateUI = /*#__PURE__*/_classPrivateFieldLooseKey(\"updateUI\");\nclass UIPlugin extends BasePlugin {\n constructor() {\n super(...arguments);\n Object.defineProperty(this, _updateUI, {\n writable: true,\n value: void 0\n });\n }\n getTargetPlugin(target // eslint-disable-line no-use-before-define\n ) {\n let targetPlugin;\n if (typeof (target == null ? void 0 : target.addTarget) === 'function') {\n // Targeting a plugin *instance*\n targetPlugin = target;\n if (!(targetPlugin instanceof UIPlugin)) {\n // eslint-disable-next-line no-console\n console.warn(new Error('The provided plugin is not an instance of UIPlugin. This is an indication of a bug with the way Uppy is bundled.', {\n cause: {\n targetPlugin,\n UIPlugin\n }\n }));\n }\n } else if (typeof target === 'function') {\n // Targeting a plugin type\n const Target = target;\n // Find the target plugin instance.\n this.uppy.iteratePlugins(p => {\n if (p instanceof Target) {\n targetPlugin = p;\n }\n });\n }\n return targetPlugin;\n }\n\n /**\n * Check if supplied `target` is a DOM element or an `object`.\n * If it\u2019s an object \u2014 target is a plugin, and we search `plugins`\n * for a plugin with same name and return its target.\n */\n mount(target,\n // eslint-disable-line no-use-before-define\n plugin) {\n const callerPluginName = plugin.id;\n const targetElement = findDOMElement(target);\n if (targetElement) {\n this.isTargetDOMEl = true;\n // When target is with a single element,\n // Preact thinks it\u2019s the Uppy root element in there when doing a diff,\n // and destroys it. So we are creating a fragment (could be empty div)\n const uppyRootElement = document.createElement('div');\n uppyRootElement.classList.add('uppy-Root');\n\n // API for plugins that require a synchronous rerender.\n _classPrivateFieldLooseBase(this, _updateUI)[_updateUI] = debounce(state => {\n // plugin could be removed, but this.rerender is debounced below,\n // so it could still be called even after uppy.removePlugin or uppy.destroy\n // hence the check\n if (!this.uppy.getPlugin(this.id)) return;\n render(this.render(state, uppyRootElement), uppyRootElement);\n this.afterUpdate();\n });\n this.uppy.log(`Installing ${callerPluginName} to a DOM element '${target}'`);\n if (this.opts.replaceTargetContent) {\n // Doing render(h(null), targetElement), which should have been\n // a better way, since because the component might need to do additional cleanup when it is removed,\n // stopped working \u2014 Preact just adds null into target, not replacing\n targetElement.innerHTML = '';\n }\n render(this.render(this.uppy.getState(), uppyRootElement), uppyRootElement);\n this.el = uppyRootElement;\n targetElement.appendChild(uppyRootElement);\n\n // Set the text direction if the page has not defined one.\n uppyRootElement.dir = this.opts.direction || getTextDirection(uppyRootElement) || 'ltr';\n this.onMount();\n return this.el;\n }\n const targetPlugin = this.getTargetPlugin(target);\n if (targetPlugin) {\n this.uppy.log(`Installing ${callerPluginName} to ${targetPlugin.id}`);\n this.parent = targetPlugin;\n this.el = targetPlugin.addTarget(plugin);\n this.onMount();\n return this.el;\n }\n this.uppy.log(`Not installing ${callerPluginName}`);\n let message = `Invalid target option given to ${callerPluginName}.`;\n if (typeof target === 'function') {\n message += ' The given target is not a Plugin class. ' + \"Please check that you're not specifying a React Component instead of a plugin. \" + 'If you are using @uppy/* packages directly, make sure you have only 1 version of @uppy/core installed: ' + 'run `npm ls @uppy/core` on the command line and verify that all the versions match and are deduped correctly.';\n } else {\n message += 'If you meant to target an HTML element, please make sure that the element exists. ' + 'Check that the