0?p(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(d=A[v])||d&&k.key==d.key&&k.type===d.type)A[v]=void 0;else for(h=0;h2&&(f.children=arguments.length>3?n.call(arguments,2):t),p(l.type,f,i||l.key,r||l.ref,null)},exports.createContext=function(n,l){var u={__c:l="__cC"+f++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=[],(t={})[l]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(x);},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u},exports.createElement=h,exports.createRef=function(){return {current:null}},exports.h=h,exports.hydrate=function n(l,u){N(l,u,n);},exports.isValidElement=t,exports.options=l,exports.render=N,exports.toChildArray=function n(l,u){return u=u||[],null==l||"boolean"==typeof l||(Array.isArray(l)?l.some(function(l){n(l,u);}):u.push(l)),u};
+
+ });
+
+ /**
+ * Check if an object is a DOM element. Duck-typing based on `nodeType`.
+ *
+ * @param {*} obj
+ */
+ var isDOMElement = function isDOMElement(obj) {
+ return (obj == null ? void 0 : obj.nodeType) === Node.ELEMENT_NODE;
+ };
+
+ /**
+ * Find a DOM element.
+ *
+ * @param {Node|string} element
+ * @returns {Node|null}
+ */
+
+
+ var findDOMElement = function findDOMElement(element, context) {
+ if (context === void 0) {
+ context = document;
+ }
+
+ if (typeof element === 'string') {
+ return context.querySelector(element);
+ }
+
+ if (isDOMElement(element)) {
+ return element;
+ }
+
+ return null;
+ };
+
+ /**
+ * Core plugin logic that all plugins share.
+ *
+ * BasePlugin does not contain DOM rendering so it can be used for plugins
+ * without a user interface.
+ *
+ * See `Plugin` for the extended version with Preact rendering for interfaces.
+ */
+
+
+ var BasePlugin_1$1 = class BasePlugin {
+ constructor(uppy, opts) {
+ if (opts === void 0) {
+ opts = {};
+ }
+
+ this.uppy = uppy;
+ this.opts = opts;
+ }
+
+ getPluginState() {
+ const {
+ plugins
+ } = this.uppy.getState();
+ return plugins[this.id] || {};
+ }
+
+ setPluginState(update) {
+ const {
+ plugins
+ } = this.uppy.getState();
+ this.uppy.setState({
+ plugins: { ...plugins,
+ [this.id]: { ...plugins[this.id],
+ ...update
+ }
+ }
+ });
+ }
+
+ setOptions(newOpts) {
+ this.opts = { ...this.opts,
+ ...newOpts
+ };
+ this.setPluginState(); // so that UI re-renders with new options
+
+ this.i18nInit();
+ }
+
+ i18nInit() {
+ const translator = new Translator_1([this.defaultLocale, this.uppy.locale, this.opts.locale]);
+ this.i18n = translator.translate.bind(translator);
+ this.i18nArray = translator.translateArray.bind(translator);
+ this.setPluginState(); // so that UI re-renders and we see the updated locale
+ }
+ /**
+ * Extendable methods
+ * ==================
+ * These methods are here to serve as an overview of the extendable methods as well as
+ * making them not conditional in use, such as `if (this.afterUpdate)`.
+ */
+ // eslint-disable-next-line class-methods-use-this
+
+
+ addTarget() {
+ throw new Error('Extend the addTarget method to add your plugin to another plugin\'s target');
+ } // eslint-disable-next-line class-methods-use-this
+
+
+ install() {} // eslint-disable-next-line class-methods-use-this
+
+
+ uninstall() {}
+ /**
+ * Called when plugin is mounted, whether in DOM or into another plugin.
+ * Needed because sometimes plugins are mounted separately/after `install`,
+ * so this.el and this.parent might not be available in `install`.
+ * This is the case with @uppy/react plugins, for example.
+ */
+
+
+ render() {
+ throw new Error('Extend the render method to add your plugin to a DOM element');
+ } // eslint-disable-next-line class-methods-use-this
+
+
+ update() {} // Called after every state update, after everything's mounted. Debounced.
+ // eslint-disable-next-line class-methods-use-this
+
+
+ afterUpdate() {}
+
+ };
+
+ function _classPrivateFieldLooseBase$5(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
+
+ var id$5 = 0;
+
+ function _classPrivateFieldLooseKey$5(name) { return "__private_" + id$5++ + "_" + name; }
+
+ const {
+ render
+ } = preact;
+
+
+
+
+ /**
+ * Defer a frequent call to the microtask queue.
+ *
+ * @param {() => T} fn
+ * @returns {Promise}
+ */
+
+
+ function debounce(fn) {
+ let calling = null;
+ let latestArgs = null;
+ return function () {
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+
+ latestArgs = args;
+
+ if (!calling) {
+ calling = Promise.resolve().then(() => {
+ calling = null; // At this point `args` may be different from the most
+ // recent state, if multiple calls happened since this task
+ // was queued. So we use the `latestArgs`, which definitely
+ // is the most recent call.
+
+ return fn(...latestArgs);
+ });
+ }
+
+ return calling;
+ };
+ }
+ /**
+ * UIPlugin is the extended version of BasePlugin to incorporate rendering with Preact.
+ * Use this for plugins that need a user interface.
+ *
+ * For plugins without an user interface, see BasePlugin.
+ */
+
+
+ var _updateUI = /*#__PURE__*/_classPrivateFieldLooseKey$5("updateUI");
+
+ class UIPlugin extends BasePlugin_1$1 {
+ constructor() {
+ super(...arguments);
+ Object.defineProperty(this, _updateUI, {
+ writable: true,
+ value: void 0
+ });
+ }
+
+ /**
+ * Check if supplied `target` is a DOM element or an `object`.
+ * If it’s an object — target is a plugin, and we search `plugins`
+ * for a plugin with same name and return its target.
+ */
+ mount(target, plugin) {
+ const callerPluginName = plugin.id;
+ const targetElement = findDOMElement(target);
+
+ if (targetElement) {
+ this.isTargetDOMEl = true; // When target is with a single element,
+ // Preact thinks it’s the Uppy root element in there when doing a diff,
+ // and destroys it. So we are creating a fragment (could be empty div)
+
+ const uppyRootElement = document.createDocumentFragment(); // API for plugins that require a synchronous rerender.
+
+ _classPrivateFieldLooseBase$5(this, _updateUI)[_updateUI] = debounce(state => {
+ // plugin could be removed, but this.rerender is debounced below,
+ // so it could still be called even after uppy.removePlugin or uppy.close
+ // hence the check
+ if (!this.uppy.getPlugin(this.id)) return;
+ render(this.render(state), uppyRootElement);
+ this.afterUpdate();
+ });
+ this.uppy.log(`Installing ${callerPluginName} to a DOM element '${target}'`);
+
+ if (this.opts.replaceTargetContent) {
+ // Doing render(h(null), targetElement), which should have been
+ // a better way, since because the component might need to do additional cleanup when it is removed,
+ // stopped working — Preact just adds null into target, not replacing
+ targetElement.innerHTML = '';
+ }
+
+ render(this.render(this.uppy.getState()), uppyRootElement);
+ this.el = uppyRootElement.firstElementChild;
+ targetElement.appendChild(uppyRootElement);
+ this.onMount();
+ return this.el;
+ }
+
+ let targetPlugin;
+
+ if (typeof target === 'object' && target instanceof UIPlugin) {
+ // Targeting a plugin *instance*
+ targetPlugin = target;
+ } else if (typeof target === 'function') {
+ // Targeting a plugin type
+ const Target = target; // Find the target plugin instance.
+
+ this.uppy.iteratePlugins(p => {
+ if (p instanceof Target) {
+ targetPlugin = p;
+ return false;
+ }
+ });
+ }
+
+ if (targetPlugin) {
+ this.uppy.log(`Installing ${callerPluginName} to ${targetPlugin.id}`);
+ this.parent = targetPlugin;
+ this.el = targetPlugin.addTarget(plugin);
+ this.onMount();
+ return this.el;
+ }
+
+ this.uppy.log(`Not installing ${callerPluginName}`);
+ let message = `Invalid target option given to ${callerPluginName}.`;
+
+ if (typeof target === 'function') {
+ 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.';
+ } else {
+ message += 'If you meant to target an HTML element, please make sure that the element exists. ' + 'Check that the
+
+
+ {% block head %}{% endblock %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% block main %}{% endblock %}
+
+
+