import { Options as HtmlMinifierOptions } from "html-minifier-terser";
import zlib from "zlib";
import { PluginOption } from "vite";

//#region src/compress.d.ts
declare const compressors: {
  readonly "deflate-raw": (script: string) => NonSharedBuffer;
  readonly deflate: (script: string) => NonSharedBuffer;
  readonly gzip: (script: string) => NonSharedBuffer;
  readonly brotli: typeof zlib.brotliCompressSync;
  readonly zstd: (script: string) => NonSharedBuffer;
};
declare const compressFormatAlias: {
  readonly deflateRaw: "deflate-raw";
  readonly gz: "gzip";
  readonly br: "brotli";
  readonly brotliCompress: "brotli";
  readonly zstandard: "zstd";
  readonly zst: "zstd";
};
type Compressor = ((script: string) => (Uint8Array | Promise<Uint8Array>));
type CompressFormat = keyof typeof compressors | CompressionFormat;
type CompressFormatAlias = keyof typeof compressFormatAlias;
//#endregion
//#region src/options.d.ts
interface Options {
  /**
   * Rename index.html
   */
  rename?: string;
  /**
   * Enable compress.
   * @default true
   */
  enableCompress?: boolean;
  /**
   * Use Base128 to encode compressed script.
   * If false, use Base64.
   * https://www.npmjs.com/package/base128-ascii
   *
   * This option is only valid when the `enableCompress` option is set to true.
   *
   * @default true
   */
  useBase128?: boolean;
  /**
   * Compress format.
   *
   * https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/DecompressionStream
   *
   * This option is only valid when the `enableCompress` option is set to true.
   *
   * @type {"deflate-raw" | "deflate" | "gzip" | "brotli" | "zstd" | "deflateRaw" | "gz" | "br" | "brotliCompress" | "zstandard" | "zst"}
   *
   * @default "deflate-raw"
   */
  compressFormat?: CompressFormat | CompressFormatAlias;
  /**
   * Custom compressor.
   *
   * This option is only valid when the `enableCompress` option is set to true.
   */
  compressor?: Compressor;
  /**
   * https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference
   * @default defaultHtmlMinifierTerserOptions
   */
  htmlMinifierTerser?: HtmlMinifierOptions | boolean;
  /**
   * Try inline html used assets, if inlined or not used in JS.
   * @default true
   */
  tryInlineHtmlAssets?: boolean;
  /**
   * Remove inlined asset files.
   * @default true
   */
  removeInlinedAssetFiles?: boolean;
  /**
   * Try inline html favicon, if icon is in public dir.
   * @default true
   */
  tryInlineHtmlPublicIcon?: boolean;
  /**
   * Remove inlined html favicon files.
   * @default true
   */
  removeInlinedPublicIconFiles?: boolean;
  /**
   * Enable compress inlined html favicon.
   *
   * This option is only valid when the `enableCompress` option is set to true.
   *
   * ⚠️ Not works on Safari (See [#20](https://github.com/bddjr/vite-plugin-singlefile-compression/issues/20))
   *
   * @default false
   */
  enableCompressInlinedIcon?: boolean;
  /**
   * Use import.meta polyfill.
   * @default false
   */
  useImportMetaPolyfill?: boolean;
  /**
   * Do not log.
   * @default false
   */
  quiet?: boolean;
}
declare const defaultHtmlMinifierTerserOptions: HtmlMinifierOptions;
//#endregion
//#region src/index.d.ts
declare function singleFileCompression(opt?: Options): PluginOption;
//#endregion
export { type CompressFormat, type CompressFormatAlias, type Compressor, type HtmlMinifierOptions, type Options, singleFileCompression as default, singleFileCompression, defaultHtmlMinifierTerserOptions };