/** * @license * Copyright (c) 2025 Handsoncode. All rights reserved. */ import { ArraySize } from '../../ArraySize'; import { ProcedureAst } from '../../parser'; import { InterpreterState } from '../InterpreterState'; import { InterpreterValue } from '../InterpreterValue'; import { FunctionPlugin, FunctionPluginTypecheck, ImplementedFunctions } from './FunctionPlugin'; /** * Plugin implementing the UNIQUE spreadsheet function. * * UNIQUE(array, [by_col], [exactly_once]) returns the distinct rows (or columns * when by_col is TRUE) of `array`, preserving first-occurrence order. When * exactly_once is TRUE, only rows/columns that occur exactly once are returned. * Equality delegates to {@link ArithmeticHelper}, so comparison honors the * caseSensitive/accentSensitive configuration (case-insensitive by default). */ export declare class UniquePlugin extends FunctionPlugin implements FunctionPluginTypecheck { static implementedFunctions: ImplementedFunctions; /** * Corresponds to UNIQUE(array, [by_col], [exactly_once]). * * Errors found anywhere in the input range are propagated. An empty result * (only reachable via exactly_once when nothing occurs exactly once) yields * #N/A, mirroring FILTER's empty-result handling. * * @param {ProcedureAst} ast - the parsed function-call AST node. * @param {InterpreterState} state - current interpreter evaluation state. */ unique(ast: ProcedureAst, state: InterpreterState): InterpreterValue; /** * Predicts the output array size for UNIQUE at parse time. * The size is data-dependent, so we predict the input size as an upper bound * (mirroring FILTER) and return the smaller actual result at runtime. A fresh * ArraySize is returned so the input's `isRef` flag is not propagated (an * ArraySize flagged as a ref is treated as scalar, which would collapse the * spilled result into a single cell). * * @param {ProcedureAst} ast - the parsed function-call AST node. * @param {InterpreterState} state - current interpreter evaluation state. */ uniqueArraySize(ast: ProcedureAst, state: InterpreterState): ArraySize; /** Returns the first {@link CellError} found in a 2-D array, or undefined. */ private static findFirstError; /** Transposes a 2-D array (rows <-> columns). */ private static transpose; }