{"version":3,"file":"vector2-CSkaMXvp.mjs","names":["internal.isVector2","internal.isWeighted","internal.makeWeighted","internal.withWeight","internal.unweighted","internal.weightedEquals","internal.equals","internal.make","internal.fromTuple","internal.transpose","internal.fromPolar","internal.magnitude","internal.normalize","internal.dot","internal.cross","internal.components","internal.softmax","internal.add","internal.subtract","internal.hadamard","internal.scale","internal.getX","internal.setX","internal.mapX","internal.getY","internal.setY","internal.mapY","internal.setR","internal.mapR","internal.getTheta","internal.setTheta","internal.mapTheta"],"sources":["../../src/vector/vector2.ts"],"sourcesContent":["import type { TwoDimensional } from '../dimensions.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector2TypeId, WeightedVector2TypeId } from './vector2.internal.ts'\nimport * as internal from './vector2.internal.ts'\n\n/**\n * A 2D vector.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Vector2 extends Pipeable, TwoDimensional<number> {\n  readonly [Vector2TypeId]: Vector2TypeId\n}\n\n/**\n * A 2D point with an associated positive scalar weight.\n *\n * Used by rational primitives (e.g. `RationalBezier2d`) where each control\n * point carries an influence weight. The interface is structurally distinct\n * from `Vector2` — its brand prevents accidental use with vector arithmetic\n * (`add`, `subtract`, `scale`, etc.) where weighted operations are not\n * well-defined.\n *\n * Construct via {@link makeWeighted} (from raw components) or\n * {@link withWeight} (from an existing `Vector2`).\n *\n * @since 2.0.0\n */\nexport interface Weighted extends Pipeable {\n  readonly [WeightedVector2TypeId]: WeightedVector2TypeId\n  readonly x: number\n  readonly y: number\n  readonly weight: number\n}\n\n/**\n * Checks if a value is a `Vector2`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `Vector2`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isVector2: (v: unknown) => v is Vector2 = internal.isVector2\n\n/**\n * Checks if a value is a `Vector2.Weighted`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `Vector2.Weighted`, `false` otherwise.\n * @since 2.0.0\n */\nexport const isWeighted: (v: unknown) => v is Weighted = internal.isWeighted\n\n/**\n * Creates a new `Vector2.Weighted` from raw components. The weight must be\n * finite and positive.\n *\n * @param x - The x component.\n * @param y - The y component.\n * @param weight - The positive scalar weight.\n * @returns A new `Vector2.Weighted` instance.\n * @since 2.0.0\n */\nexport const makeWeighted: (x: number, y: number, weight: number) => Weighted =\n  internal.makeWeighted\n\nexport const withWeight: {\n  /**\n   * Promotes a `Vector2` to a `Vector2.Weighted` by attaching the given\n   * positive scalar weight.\n   *\n   * @param v - The point to weight.\n   * @param weight - The positive scalar weight.\n   * @returns A new `Vector2.Weighted` instance.\n   * @since 2.0.0\n   */\n  (v: Vector2, weight: number): Weighted\n  /**\n   * Promotes a `Vector2` to a `Vector2.Weighted` by attaching the given\n   * positive scalar weight.\n   *\n   * @param weight - The positive scalar weight.\n   * @returns A function that takes a `Vector2` and returns a weighted point.\n   * @since 2.0.0\n   */\n  (weight: number): (v: Vector2) => Weighted\n} = internal.withWeight\n\n/**\n * Strips the weight from a `Vector2.Weighted`, returning the underlying point.\n *\n * @param w - The weighted point.\n * @returns A new `Vector2` instance with the same x and y components.\n * @since 2.0.0\n */\nexport const unweighted: (w: Weighted) => Vector2 = internal.unweighted\n\nexport const weightedEquals: {\n  /**\n   * Checks if two `Vector2.Weighted` instances are approximately equal —\n   * point components and weight all within the default absolute tolerance.\n   *\n   * @param a - The first weighted point.\n   * @param b - The second weighted point.\n   * @returns `true` when components and weight are within tolerance.\n   * @since 2.0.0\n   */\n  (a: Weighted, b: Weighted): boolean\n  /**\n   * Checks if two `Vector2.Weighted` instances are approximately equal.\n   *\n   * @param b - The second weighted point.\n   * @returns A function that takes the first weighted point and returns the comparison result.\n   * @since 2.0.0\n   */\n  (b: Weighted): (a: Weighted) => boolean\n} = internal.weightedEquals\n\nexport const equals: {\n  /**\n   * Checks if two `Vector2` instances are approximately equal within the\n   * default absolute tolerance ({@link EPSILON}).\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns `true` when each pair of components is within tolerance.\n   * @since 1.1.0\n   */\n  (a: Vector2, b: Vector2): boolean\n  /**\n   * Checks if two `Vector2` instances are approximately equal within the\n   * default absolute tolerance ({@link EPSILON}).\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the comparison result.\n   * @since 1.1.0\n   */\n  (b: Vector2): (a: Vector2) => boolean\n} = internal.equals\n\nexport const make: {\n  /**\n   * Creates a new `Vector2` instance.\n   *\n   * @param xy - The x and y components of the vector.\n   * @returns A new `Vector2` instance.\n   * @since 1.0.0\n   */\n  (xy: number): Vector2\n  /**\n   * Creates a new `Vector2` instance.\n   *\n   * @param x - The x component of the vector.\n   * @param y - The y component of the vector.\n   * @returns A new `Vector2` instance.\n   * @since 1.0.0\n   */\n  (x: number, y: number): Vector2\n} = internal.make\n\n/**\n * Creates a new `Vector2` instance from a `[x, y]` tuple. Inverse of\n * {@link components}.\n *\n * @param t - The `[x, y]` tuple.\n * @returns A new `Vector2` instance.\n * @since 2.0.0\n */\nexport const fromTuple: (t: readonly [number, number]) => Vector2 = internal.fromTuple\n\n/**\n * Transposes a 2-tuple of items into one or more `Vector2`s, one per channel\n * extracted by the projection function. See {@link Vector4.transpose} for the\n * full operation description; this is the 2-component analog.\n *\n * @param inputs - Exactly two items of any type.\n * @param project - A function returning a fixed-arity tuple of numbers — one per output channel.\n * @returns A tuple of `Vector2`s with the same arity as the projection's return tuple.\n * @since 2.0.0\n */\nexport const transpose: <T, const Channels extends ReadonlyArray<number>>(\n  inputs: readonly [T, T],\n  project: (item: T) => Channels,\n) => { readonly [K in keyof Channels]: Vector2 } = internal.transpose\n\n/**\n * Creates a new `Vector2` instance from polar coordinates.\n *\n * @param r - The radius.\n * @param theta - The angle, in radians.\n * @returns A new `Vector2` instance.\n * @since 1.0.0\n */\nexport const fromPolar: (r: number, theta: number) => Vector2 = internal.fromPolar\n\n/**\n * Calculates the magnitude of a `Vector2`.\n *\n * @param vector - The vector to calculate the magnitude of.\n * @returns The magnitude of the vector.\n * @since 1.0.0\n */\nexport const magnitude: (vector: Vector2) => number = internal.magnitude\n\n/**\n * Normalizes a `Vector2`.\n *\n * @param vector - The vector to normalize.\n * @returns A new `Vector2` instance with the same direction and a magnitude of 1.\n * @since 1.0.0\n */\nexport const normalize: (vector: Vector2) => Vector2 = internal.normalize\n\nexport const dot: {\n  /**\n   * Calculates the dot product of two `Vector2` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns The dot product of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector2, b: Vector2): number\n  /**\n   * Calculates the dot product of two `Vector2` instances.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the dot product.\n   * @since 1.0.0\n   */\n  (b: Vector2): (a: Vector2) => number\n} = internal.dot\n\nexport const cross: {\n  /**\n   * Calculates the cross product of two `Vector2` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns The cross product of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector2, b: Vector2): number\n  /**\n   * Calculates the cross product of two `Vector2` instances.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the cross product.\n   * @since 1.0.0\n   */\n  (b: Vector2): (a: Vector2) => number\n} = internal.cross\n\n/**\n * Returns the components of a `Vector2` as an array.\n *\n * @param r - The radius.\n * @param theta - The angle, in radians.\n * @returns A new `Vector2` instance.\n * @since 1.0.0\n */\nexport const components: (v: Vector2) => [number, number] = internal.components\n\n/**\n * Applies the softmax function to a `Vector2`.\n *\n * @param v - The vector to apply the softmax function to.\n * @returns A new `Vector2` instance with the softmax applied.\n * @since 1.0.0\n */\nexport const softmax: (v: Vector2) => Vector2 = internal.softmax\n\n/**\n * Creates a zero vector.\n *\n * @returns A new `Vector2` instance with both components set to 0.\n * @since 1.0.0\n */\nexport const zero = make(0)\n\n/**\n * Creates a unit vector.\n *\n * @returns A new `Vector2` instance with both components set to 1.\n * @since 1.0.0\n */\nexport const unit = make(1)\n\nexport const add: {\n  /**\n   * Adds two `Vector2` instances together.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector2` instance representing the sum of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector2, b: Vector2): Vector2\n  /**\n   * Adds two `Vector2` instances together.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the sum.\n   * @since 1.0.0\n   */\n  (b: Vector2): (a: Vector2) => Vector2\n} = internal.add\n\nexport const subtract: {\n  /**\n   * Subtracts one `Vector2` instance from another.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector2` instance representing the difference of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector2, b: Vector2): Vector2\n  /**\n   * Subtracts one `Vector2` instance from another.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the difference.\n   * @since 1.0.0\n   */\n  (b: Vector2): (a: Vector2) => Vector2\n} = internal.subtract\n\nexport const hadamard: {\n  /**\n   * Performs the Hadamard product of two `Vector2` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector2` instance representing the Hadamard product of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector2, b: Vector2): Vector2\n  /**\n   * Performs the Hadamard product of two `Vector2` instances.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the Hadamard product.\n   * @since 1.0.0\n   */\n  (b: Vector2): (a: Vector2) => Vector2\n} = internal.hadamard\n\nexport const scale: {\n  /**\n   * Scales a `Vector2` by a scalar value.\n   *\n   * @param s - The scalar value to scale by.\n   * @returns A function that takes a vector and returns the scaled vector.\n   * @since 1.0.0\n   */\n  (s: number): (v: Vector2) => Vector2\n  /**\n   * Scales a `Vector2` by a scalar value.\n   *\n   * @param v - The vector to scale.\n   * @param s - The scalar value to scale by.\n   * @returns A new `Vector2` instance representing the scaled vector.\n   * @since 1.0.0\n   */\n  (v: Vector2, s: number): Vector2\n} = internal.scale\n\n/**\n * Gets the x component of a `Vector2`.\n *\n * @param v - The vector to get the x component from.\n * @returns The x component of the vector.\n * @since 1.0.0\n */\nexport const getX: (v: Vector2) => number = internal.getX\n\nexport const setX: {\n  /**\n   * Sets the x component of a `Vector2`.\n   *\n   * @param v - The vector to set the x component of.\n   * @param x - The new x component.\n   * @returns A new `Vector2` instance with the updated x component.\n   * @since 1.0.0\n   */\n  (v: Vector2, x: number): Vector2\n  /**\n   * Sets the x component of a `Vector2`.\n   *\n   * @param x - The new x component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 1.0.0\n   */\n  (x: number): (v: Vector2) => Vector2\n} = internal.setX\n\nexport const mapX: {\n  /**\n   * Returns a new `Vector2` with the x component replaced by `f(v.x)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the x component.\n   * @returns A new `Vector2` with the updated x.\n   * @since 2.0.0\n   */\n  (v: Vector2, f: (x: number) => number): Vector2\n  /**\n   * Returns a new `Vector2` with the x component replaced by `f(v.x)`.\n   *\n   * @param f - The function to apply to the x component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (x: number) => number): (v: Vector2) => Vector2\n} = internal.mapX\n\n/**\n * Gets the y component of a `Vector2`.\n *\n * @param v - The vector to get the y component from.\n * @returns The y component of the vector.\n * @since 1.0.0\n */\nexport const getY: (v: Vector2) => number = internal.getY\n\nexport const setY: {\n  /**\n   * Sets the y component of a `Vector2`.\n   *\n   * @param v - The vector to set the y component of.\n   * @param y - The new y component.\n   * @returns A new `Vector2` instance with the updated y component.\n   * @since 1.0.0\n   */\n  (v: Vector2, y: number): Vector2\n  /**\n   * Sets the y component of a `Vector2`.\n   *\n   * @param y - The new y component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 1.0.0\n   */\n  (y: number): (v: Vector2) => Vector2\n} = internal.setY\n\nexport const mapY: {\n  /**\n   * Returns a new `Vector2` with the y component replaced by `f(v.y)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the y component.\n   * @returns A new `Vector2` with the updated y.\n   * @since 2.0.0\n   */\n  (v: Vector2, f: (y: number) => number): Vector2\n  /**\n   * Returns a new `Vector2` with the y component replaced by `f(v.y)`.\n   *\n   * @param f - The function to apply to the y component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (y: number) => number): (v: Vector2) => Vector2\n} = internal.mapY\n\n/**\n * Gets the radius of a `Vector2`.\n *\n * @param v - The vector to get the radius from.\n * @returns The radius of the vector.\n * @since 1.0.0\n */\nexport const getR: (v: Vector2) => number = magnitude\n\nexport const setR: {\n  /**\n   * Sets the radius of a `Vector2`.\n   *\n   * @param v - The vector to set the radius of.\n   * @param r - The new radius.\n   * @returns A new `Vector2` instance with the updated radius.\n   * @since 1.0.0\n   */\n  (v: Vector2, r: number): Vector2\n  /**\n   * Sets the radius of a `Vector2`.\n   *\n   * @param r - The new radius.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 1.0.0\n   */\n  (r: number): (v: Vector2) => Vector2\n} = internal.setR\n\nexport const mapR: {\n  /**\n   * Returns a new `Vector2` with the radius replaced by `f(magnitude(v))`,\n   * preserving the angle.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the radius.\n   * @returns A new `Vector2` with the updated radius.\n   * @since 2.0.0\n   */\n  (v: Vector2, f: (r: number) => number): Vector2\n  /**\n   * Returns a new `Vector2` with the radius replaced by `f(magnitude(v))`,\n   * preserving the angle.\n   *\n   * @param f - The function to apply to the radius.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (r: number) => number): (v: Vector2) => Vector2\n} = internal.mapR\n\n/**\n * Gets the angle of a `Vector2`.\n *\n * @param v - The vector to get the angle from.\n * @returns The angle of the vector in radians.\n * @since 1.0.0\n */\nexport const getTheta: (v: Vector2) => number = internal.getTheta\n\nexport const setTheta: {\n  /**\n   * Sets the angle of a `Vector2`.\n   *\n   * @param v - The vector to set the angle of.\n   * @param theta - The new angle, in radians.\n   * @returns A new `Vector2` instance with the updated angle.\n   * @since 1.0.0\n   */\n  (v: Vector2, theta: number): Vector2\n  /**\n   * Sets the angle of a `Vector2`.\n   *\n   * @param theta - The new angle, in radians.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 1.0.0\n   */\n  (theta: number): (v: Vector2) => Vector2\n} = internal.setTheta\n\nexport const mapTheta: {\n  /**\n   * Returns a new `Vector2` with the angle replaced by `f(getTheta(v))`,\n   * preserving the radius.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the angle (in radians).\n   * @returns A new `Vector2` with the updated angle.\n   * @since 2.0.0\n   */\n  (v: Vector2, f: (theta: number) => number): Vector2\n  /**\n   * Returns a new `Vector2` with the angle replaced by `f(getTheta(v))`,\n   * preserving the radius.\n   *\n   * @param f - The function to apply to the angle (in radians).\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (theta: number) => number): (v: Vector2) => Vector2\n} = internal.mapTheta\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,YAA0CA;;;;;;;;AASvD,MAAa,aAA4CC;;;;;;;;;;;AAYzD,MAAa,eACXC;AAEF,MAAa,aAoBTC;;;;;;;;AASJ,MAAa,aAAuCC;AAEpD,MAAa,iBAmBTC;AAEJ,MAAa,SAoBTC;AAEJ,MAAa,OAkBTC;;;;;;;;;AAUJ,MAAa,YAAuDC;;;;;;;;;;;AAYpE,MAAa,YAGsCC;;;;;;;;;AAUnD,MAAa,YAAmDC;;;;;;;;AAShE,MAAa,YAAyCC;;;;;;;;AAStD,MAAa,YAA0CC;AAEvD,MAAa,MAkBTC;AAEJ,MAAa,QAkBTC;;;;;;;;;AAUJ,MAAa,aAA+CC;;;;;;;;AAS5D,MAAa,UAAmCC;;;;;;;AAQhD,MAAa,OAAO,KAAK,EAAE;;;;;;;AAQ3B,MAAa,OAAO,KAAK,EAAE;AAE3B,MAAa,MAkBTC;AAEJ,MAAa,WAkBTC;AAEJ,MAAa,WAkBTC;AAEJ,MAAa,QAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC;;;;;;;;AASJ,MAAa,OAA+B;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAoBTC;;;;;;;;AASJ,MAAa,WAAmCC;AAEhD,MAAa,WAkBTC;AAEJ,MAAa,WAoBTC"}