/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference lib="dom" />

import { Scrapbox } from "https://raw.githubusercontent.com/scrapbox-jp/types/0.3.5/scrapbox.ts";

declare const scrapbox: Scrapbox;

export interface LaunchOptions {
  /** ピン留めするプロジェクト名 既定は現在のプロジェクト名 */
  project?: string;
  /** ピン留め更新処理の間隔 既定は`60000` */
  interval?: number;
}

export type Titles =
  | Iterable<string>
  | (() => Iterable<string> | Promise<Iterable<string>>);

/**
 * ピン留め処理を開始する
 * @param {Iterable<string>|(()=>(Iterable<string>|Promise<Iterable<string>>))} titles ピン留めしたいページのタイトル
 * @param {LaunchOptions} [options] オプション
 * @return {()=>void} 後始末用函数
 */
export declare const launch: (
  titles: Titles,
  option?: LaunchOptions,
) => {
  (): void;
};

/**
 * ピン留め処理
 * @param {string} project プロジェクト名
 * @param {Iterable<string>|(()=>(Iterable<string>|Promise<Iterable<string>>))} titles ピン留めしたいページのタイトル
 */
declare const updatePins: (project: string, titles: Titles) => Promise<void>;

/**
 * 指定したカードをpinする
 * @param {HTMLLIElement} card
 * @return {void}
 */
declare const pin: (card: HTMLLIElement) => void;

declare const cardList: () => HTMLUListElement[];

declare const listPins: () => void;

declare const id: "personal-pin-card";

/**
 * ページカードを作る
 *
 * ページリストにあるときはそれをコピーし、ないときは空のページカードを作る
 * @param {string} project プロジェクト名
 * @param {string} title ページタイトル
 * @return {HTMLLIElement}
 */
declare const makePseudoCard: (project: string, title: string) => HTMLLIElement;

/** このscriptで作成したカードを全部消す */
declare const deletePseudoCards: () => void;

declare const noEncodeChars: '@$&+=:;",';
declare const noTailChars: ':;",';

/**
 * titleをURIで使える形式にEncodeする
 *
 * ported from https://github.com/takker99/scrapbox-userscript-std/blob/0.14.5/title.ts#L28
 *
 * @param {string} title 変換するtitle
 * @return {string} 変換後の文字列
 */
declare const encodeTitleURI: (title: string) => string;