o) {
    _getPrototypeOf15 = Object.setPrototypeOf? Object.getPrototypeOf : function _getPrototypeOf26(o2) {
      return o2.__proto__ || Object.getPrototypeOf(o2);
    };
    return _getPrototypeOf15(o);
  }
  var zoneActive = "shiny-file-input-active";
  var zoneOver = "shiny-file-input-over";
  function zoneOf(el) {
    return (0, import_jquery21.default)(el).closest("div.input-group");
  }
  function enableDraghover(el) {
    var $el = (0, import_jquery21.default)(el);
    var childCounter = 0;
    $el.on({
      "dragenter.draghover": function dragenterDraghover(e) {
        if (childCounter++ === 0) {
          $el.trigger("draghover:enter", e);
        }
      },
      "dragleave.draghover": function dragleaveDraghover(e) {
        if (--childCounter === 0) {
          $el.trigger("draghover:leave", e);
        }
        if (childCounter < 0) {
          console.error("draghover childCounter is negative somehow");
        }
      },
      "dragover.draghover": function dragoverDraghover(e) {
        e.preventDefault();
      },
      "drop.draghover": function dropDraghover(e) {
        childCounter = 0;
        $el.trigger("draghover:drop", e);
        e.preventDefault();
      }
    });
    return $el;
  }
  function disableDraghover(el) {
    return (0, import_jquery21.default)(el).off(".draghover");
  }
  function enableDocumentEvents() {
    var $doc = (0, import_jquery21.default)("html");
    enableDraghover($doc).on({
      "draghover:enter.draghover": function draghoverEnterDraghover() {
        zoneOf($fileInputs).addClass(zoneActive);
      },
      "draghover:leave.draghover": function draghoverLeaveDraghover() {
        zoneOf($fileInputs).removeClass(zoneActive);
      },
      "draghover:drop.draghover": function draghoverDropDraghover() {
        zoneOf($fileInputs).removeClass(zoneOver).removeClass(zoneActive);
      }
    });
  }
  function disableDocumentEvents() {
    var $doc = (0, import_jquery21.default)("html");
    $doc.off(".draghover");
    disableDraghover($doc);
  }
  function canSetFiles(fileList) {
    var testEl = document.createElement("input");
    testEl.type = "file";
    try {
      testEl.files = fileList;
    } catch (e) {
      return false;
    }
    return true;
  }
  function handleDrop(e, el) {
    var files = e.originalEvent.dataTransfer.files, $el = (0, import_jquery21.default)(el);
    if (files === void 0 || files === null) {
      console.log("Dropping files is not supported on this browser. (no FileList)");
    } else if (!canSetFiles(files)) {
      $el.val("");
      uploadDroppedFilesIE10Plus(el, files);
    } else {
      $el.val("");
      el.files = e.originalEvent.dataTransfer.files;
      $el.trigger("change");
    }
  }
  function setFileText($el, files) {
    var $fileText = $el.closest("div.input-group").find("input[type=text]");
    if (files.length === 1) {
      $fileText.val(files[0].name);
    } else {
      $fileText.val(files.length + " files");
    }
  }
  function abortCurrentUpload($el) {
    var uploader = $el.data("currentUploader");
    if (uploader)
      uploader.abort();
    $el.removeAttr("data-restore");
  }
  function uploadDroppedFilesIE10Plus(el, files) {
    var $el = (0, import_jquery21.default)(el);
    abortCurrentUpload($el);
    setFileText($el, files);
    $el.data("currentUploader", new FileUploader(shinyShinyApp(), fileInputBindingGetId(el), files, el));
  }
  function uploadFiles(evt) {
    var $el = (0, import_jquery21.default)(evt.target);
    abortCurrentUpload($el);
    var files = evt.target.files;
    var id = fileInputBindingGetId(evt.target);
    if (files.length === 0)
      return;
    setFileText($el, files);
    $el.data("currentUploader", new FileUploader(shinyShinyApp(), id, files, evt.target));
  }
  var $fileInputs = (0, import_jquery21.default)();
  function fileInputBindingGetId(el) {
    return InputBinding.prototype.getId.call(this, el) || el.name;
  }
  var FileInputBinding = /* @__PURE__ */ function(_InputBinding) {
    _inherits15(FileInputBinding2, _InputBinding);
    var _super = _createSuper15(FileInputBinding2);
    function FileInputBinding2() {
      _classCallCheck17(this, FileInputBinding2);
      return _super.apply(this, arguments);
    }
    _createClass17(FileInputBinding2, [{
      key: "find",
      value: function find2(scope) {
        return (0, import_jquery21.default)(scope).find('input[type="file"]');
      }
    }, {
      key: "getId",
      value: function getId(el) {
        return fileInputBindingGetId(el);
      }
    }, {
      key: "getValue",
      value: function getValue(el) {
        var data = (0, import_jquery21.default)(el).attr("data-restore");
        if (data) {
          var dataParsed = JSON.parse(data);
          var $fileText = (0, import_jquery21.default)(el).closest("div.input-group").find("input[type=text]");
          if (dataParsed.name.length === 1) {
            $fileText.val(dataParsed.name[0]);
          } else {
            $fileText.val(dataParsed.name.length + " files");
          }
          var $progress = (0, import_jquery21.default)(el).closest("div.form-group").find(".progress");
          var $bar = $progress.find(".progress-bar");
          $progress.removeClass("active");
          $bar.width("100%");
          $bar.css("visibility", "visible");
          return dataParsed;
        } else {
          return null;
        }
      }
    }, {
      key: "setValue",
      value: function setValue(el, value) {
        el;
        value;
      }
    }, {
      key: "getType",
      value: function getType(el) {
        return "shiny.file";
        el;
      }
    }, {
      key: "subscribe",
      value: function subscribe(el, callback) {
        callback;
        (0, import_jquery21.default)(el).on("change.fileInputBinding", uploadFiles);
        if ($fileInputs.length === 0)
          enableDocumentEvents();
        $fileInputs = $fileInputs.add(el);
        var $zone = zoneOf(el);
        enableDraghover($zone).on({
          "draghover:enter.draghover": function draghoverEnterDraghover(e) {
            e;
            $zone.addClass(zoneOver);
          },
          "draghover:leave.draghover": function draghoverLeaveDraghover(e) {
            $zone.removeClass(zoneOver);
            e.stopPropagation();
          },
          "draghover:drop.draghover": function draghoverDropDraghover(e, dropEvent) {
            e;
            handleDrop(dropEvent, el);
          }
        });
      }
    }, {