"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const DataEditor = require("@glideapps/glide-data-grid");
const kit_DataGrid_customRenderers_utils = require("../utils.cjs");
const kit_internal_functions = require("../../../internal/functions.cjs");
const LOADING_CELL = "loading-cell";
const PADDING = 10;
const MAX_STEPS = 10;
const renderer = {
  draw: (args, cell) => {
    const { ctx, rect, requestAnimationFrame } = args;
    const { appTheme } = cell.data;
    ctx.save();
    const x = rect.x + PADDING;
    const y = rect.y + PADDING;
    const w = rect.width - 2 * PADDING;
    const h = rect.height - 2 * PADDING;
    const step = Math.round(Date.now() / 100) % MAX_STEPS;
    const percent = step / MAX_STEPS;
    const inc = 2 * percent % 1;
    const factor = percent >= 0.5 ? 1 : 0;
    const rgba0 = kit_internal_functions.str2rgba(appTheme.ixBorder);
    const rgba1 = kit_internal_functions.str2rgba(appTheme.ixBorderStrong);
    const color0 = kit_internal_functions.rgba2str(kit_internal_functions.rgbaFromGradient(rgba0, rgba1, Math.abs(factor - inc)));
    const color1 = kit_internal_functions.rgba2str(kit_internal_functions.rgbaFromGradient(rgba0, rgba1, factor));
    const color2 = kit_internal_functions.rgba2str(kit_internal_functions.rgbaFromGradient(rgba0, rgba1, 1 - Math.abs(factor - inc)));
    const gradient = ctx.createLinearGradient(x, y, x + w, y);
    gradient.addColorStop(0, color0);
    gradient.addColorStop(2 * percent % 1, color1);
    gradient.addColorStop(1, color2);
    ctx.beginPath();
    kit_DataGrid_customRenderers_utils.roundedRect(ctx, x, y, w, h, 2);
    ctx.fillStyle = gradient;
    ctx.fill();
    ctx.restore();
    requestAnimationFrame();
  },
  isMatch: (cell) => {
    return "kind" in cell.data && cell.data.kind === LOADING_CELL;
  },
  kind: DataEditor.GridCellKind.Custom,
  needsHover: true,
  needsHoverPosition: true,
  onPaste: (_v, d) => d,
  provideEditor: () => void 0
};
exports.LOADING_CELL = LOADING_CELL;
exports.default = renderer;
