/*
 * Copyright (c) Microsoft Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.microsoft.playwright;

import com.microsoft.playwright.options.*;
import java.nio.file.Path;
import java.util.*;

/**
 * {@code FileChooser} objects are dispatched by the page in the [{@code event: Page.fileChooser}] event.
 */
public interface FileChooser {
  class SetFilesOptions {
    /**
     * Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
     * opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
     * inaccessible pages. Defaults to {@code false}.
     */
    public Boolean noWaitAfter;
    /**
     * Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
     * using the [{@code method: BrowserContext.setDefaultTimeout}] or [{@code method: Page.setDefaultTimeout}] methods.
     */
    public Double timeout;

    public SetFilesOptions withNoWaitAfter(boolean noWaitAfter) {
      this.noWaitAfter = noWaitAfter;
      return this;
    }
    public SetFilesOptions withTimeout(double timeout) {
      this.timeout = timeout;
      return this;
    }
  }
  /**
   * Returns input element associated with this file chooser.
   */
  ElementHandle element();
  /**
   * Returns whether this file chooser accepts multiple files.
   */
  boolean isMultiple();
  /**
   * Returns page this file chooser belongs to.
   */
  Page page();
  /**
   * Sets the value of the file input this chooser is associated with. If some of the {@code filePaths} are relative paths, then
   * they are resolved relative to the the current working directory. For empty array, clears the selected files.
   */
  default void setFiles(Path files) {
    setFiles(files, null);
  }
  /**
   * Sets the value of the file input this chooser is associated with. If some of the {@code filePaths} are relative paths, then
   * they are resolved relative to the the current working directory. For empty array, clears the selected files.
   */
  void setFiles(Path files, SetFilesOptions options);
  /**
   * Sets the value of the file input this chooser is associated with. If some of the {@code filePaths} are relative paths, then
   * they are resolved relative to the the current working directory. For empty array, clears the selected files.
   */
  default void setFiles(Path[] files) {
    setFiles(files, null);
  }
  /**
   * Sets the value of the file input this chooser is associated with. If some of the {@code filePaths} are relative paths, then
   * they are resolved relative to the the current working directory. For empty array, clears the selected files.
   */
  void setFiles(Path[] files, SetFilesOptions options);
  /**
   * Sets the value of the file input this chooser is associated with. If some of the {@code filePaths} are relative paths, then
   * they are resolved relative to the the current working directory. For empty array, clears the selected files.
   */
  default void setFiles(FilePayload files) {
    setFiles(files, null);
  }
  /**
   * Sets the value of the file input this chooser is associated with. If some of the {@code filePaths} are relative paths, then
   * they are resolved relative to the the current working directory. For empty array, clears the selected files.
   */
  void setFiles(FilePayload files, SetFilesOptions options);
  /**
   * Sets the value of the file input this chooser is associated with. If some of the {@code filePaths} are relative paths, then
   * they are resolved relative to the the current working directory. For empty array, clears the selected files.
   */
  default void setFiles(FilePayload[] files) {
    setFiles(files, null);
  }
  /**
   * Sets the value of the file input this chooser is associated with. If some of the {@code filePaths} are relative paths, then
   * they are resolved relative to the the current working directory. For empty array, clears the selected files.
   */
  void setFiles(FilePayload[] files, SetFilesOptions options);
}

