import { type SpinOptions } from "./element-kit.ts"; import { HandAttributes } from "./hand-attributes.ts"; import { BUNDLE_BACKS } from "./hand-draw.ts"; export { BUNDLE_BACKS }; import { type CardLands } from "./layout.ts"; /** How a hand's cards are turned face down or face up. * * @example * ```ts * import type { HandTurnOptions } from "@johnmorrisdotca/toranpu/element"; * * const value: HandTurnOptions = { oneByOne: true, gap: 80 }; * console.log(value.gap); * ``` */ export type HandTurnOptions = { /** One card after another, from the first, rather than all at once. Unless said, all at once. */ oneByOne?: boolean; /** Milliseconds between one card and the next, one by one. Unless said, 110. */ gap?: number; }; /** * A HAND OF CARDS ON ANY PAGE: ``, fanned, in * any design and with any back. It can be turned face down where it lies, all * at once or one card after another, and back, or only the cards chosen; * squared up into one bundle ("scrunched") that never says how many cards * there are; parted at one card, which comes out from among the rest; held * closed, squared up with only the top card showing, to open into a fan on a * tap; and its cards marked, to be followed while face down, and spun. * * ```html * * ``` * * Attributes, all optional: * cards the hand: ids separated by spaces or commas (`AS KH 10D`), or the deck's one-letter codes * face-down every card shows its back; their faces are not in the page * turned cards that show the other side from the rest: face up in a hand face down, face down in one face up * scrunched squared up into one bundle that never says how many; face down, no faces in the page either; face * up, its top card showing * parted a card the hand is parted at: lifted out, wholly in view, the cards either side drawn away from it * marked cards that carry a mark, a dot on the corner seen face up or face down * closed how closed the hand lies, from 0 (a clear fan) to 1 (squared up, only the top card showing) * reveal a tap, Enter or Space opens a closed hand into a fan, and closes it again * order "rank" sorts the hand low to high, the ace high; "suit" groups it by suit, each in rank order; * "face" puts the number cards before the face cards; left out, the cards lie as they were dealt * (`arrangeCards`) * receive where a card given by replace() lands: "front", or "end" (unless said) * deal-after given new cards, how many milliseconds the hand waits before it gathers the old ones in and * opens on the new; a table gives each seat a little more, so the hands are dealt in turn * design, back, back-colour, mark, size, width, lang, sound as on `` * * Methods: `hide(options?)` and `show(options?)` turn every card one way, one * by one if asked, and `toggle(cards?, options?)` turns the cards named (or * all) over; `scrunch()` and `spread()` square the hand up and lay it out * again; `partAt(card)` and `unpart()`; `open()` and `close()` fan it and square * it; `sort()`, `group(by?)`, `unsort()`, `mixUp()`, `toss(card)` and * `replace(card, next)`; `mark(cards)` and `unmark(cards?)`; and `spin(cards?, * options?)`. Each returns a promise that settles when the cards have finished * moving. The motion is skipped on a device that asks for less. Each change is * a `toranpu-hand` event that bubbles, its detail `{ faceDown, scrunched, * open, turned, parted }`. * @example * ```ts * import { ToranpuHand } from "@johnmorrisdotca/toranpu/element"; * console.log(ToranpuHand.observedAttributes.includes("lang")); // true * ``` */ export declare class ToranpuHand extends HandAttributes { #private; /** The cards of the hand, as ids. Setting them, to a list or to text such as `"AS KH"`, lays the hand out afresh. */ get cards(): string[]; set cards(cards: string | readonly string[]); /** Turn every card face down where it lies: all at once, or one after another. */ hide(options?: HandTurnOptions): Promise; /** Turn every card face up again. */ show(options?: HandTurnOptions): Promise; /** * Turn the cards named over, each to its other side, where they lie: a card face up goes face down and * one face down comes up (John, 2026-10-01: "flips over any card(s)"). Unless cards are named, every card * of the hand, so a hand half turned is turned the other way about. A card the hand does not hold is * passed over; a hand holding two of a card turns both. */ toggle(cards?: string | readonly string[], options?: HandTurnOptions): Promise; /** * Square the hand up into one bundle that never says how many cards it holds, each card keeping its * side: face down, the bundle shows only backs; face up, its top card. (Until 2.13 a scrunch also * turned the hand face down; John, 2026-10-01, once cards could be turned over by themselves: "Scrunch * doesn't have to flip face down. Just brings cards together.") */ scrunch(): Promise; /** Lay a squared-up hand out again, each card as it now faces. */ spread(): Promise; /** * Part the hand at a card: that card is lifted out, upright and wholly in view, and the cards to its * left and right are drawn away from it, so a card from the middle leaves three groups, the left, it, * and the right (`partedHandLayout`). It keeps its side; `toggle` turns it. Parting at another card * moves the parting there; `null`, or `unpart()`, closes the hand up again. Nothing happens for a card * the hand does not hold. */ partAt(card: string | null): Promise; /** Close a parted hand up again into its fan. */ unpart(): Promise; /** Mark the cards named, with a dot on the corner that shows face up and face down alike, to follow them as they move. */ mark(cards: string | readonly string[]): void; /** Take the marks off the cards named, or off every card. */ unmark(cards?: string | readonly string[]): void; /** * Spin the cards named (or every card) where they lie, as a flick sets a card turning on a table: fast, * then slowing to a stop as it was, a whole number of turns later. Several spin together, each a moment * after the one before. `direction` is clockwise unless said; `turns` 3. Settles when every card is * still; at once where motion is reduced. A bundle's cards are not spun, having none to show. */ spin(cards?: string | readonly string[], options?: SpinOptions): Promise; /** Sort the hand by rank, low to high with the ace high, the cards sliding to their places. */ sort(): Promise; /** * Group the hand by suit (spades, hearts, clubs, diamonds), each suit in rank order; or, with `"face"`, * the number cards (ace to ten) before the face cards (jack, queen, king). */ group(by?: "suit" | "face"): Promise; /** Lay the hand out again in the order it was dealt. */ unsort(): Promise; /** Mix the hand up: the same cards in another order, each sliding to its new place. A sorted hand is unsorted first. */ mixUp(): Promise; /** Toss a card out of the hand: it lifts away, and the rest close up. Nothing happens for a card the hand does not hold. */ toss(card: string): Promise; /** * Toss a card out and take another in its stead: the new one drops in at the front or the end, as `lands` * says, or as the hand's `receive` attribute says, or at the end. */ replace(card: string, next: string, lands?: CardLands): Promise; /** Open a closed hand into a clear fan. */ open(): Promise; /** Square the hand up so that only the top card shows: to `closed` (unless said, all the way). */ close(closed?: number): Promise; connectedCallback(): void; disconnectedCallback(): void; attributeChangedCallback(name: string, before: string | null, after: string | null): void; }