/**
* Copyright (c) 2025, Yandex LLC
* All rights reserved. (MIT Licensed)
*
* Yagr@4.10.0
* High-performance HTML5 canvas chart renderer based on uPlot
* https://github.com/gravity-ui/yagr
*/

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plugins/weekends/weekends.ts
var weekends_exports = {};
__export(weekends_exports, {
  default: () => WeekendsPlugin
});
module.exports = __toCommonJS(weekends_exports);

// src/YagrCore/defaults.ts
var DEFAULT_CANVAS_PIXEL_RATIO = typeof window === "undefined" ? 1 : window.devicePixelRatio;
var DEFAULT_POINT_SIZE = DEFAULT_CANVAS_PIXEL_RATIO >= 2 ? 4 : 2;
var SECOND = 1e3;
var MINUTE = SECOND * 60;
var HOUR = MINUTE * 60;
var DAY = HOUR * 24;
var YEAR = DAY * 365;
var DECADE = YEAR * 10;
var X_AXIS_INCRS = [
  // seconds divisors (# os ms)
  1,
  10,
  50,
  100,
  200,
  500,
  // minute divisors
  SECOND,
  SECOND * 2,
  SECOND * 5,
  SECOND * 10,
  SECOND * 15,
  SECOND * 30,
  // hour divisors
  MINUTE,
  MINUTE * 5,
  MINUTE * 10,
  MINUTE * 30,
  // day divisors
  HOUR,
  HOUR * 2,
  HOUR * 3,
  HOUR * 4,
  HOUR * 6,
  HOUR * 12,
  // month divisors
  DAY,
  DAY * 2,
  DAY * 3,
  DAY * 5,
  DAY * 10,
  DAY * 15,
  DAY * 30,
  DAY * 60,
  DAY * 120,
  DAY * 180,
  // year divisors
  YEAR,
  YEAR * 2,
  YEAR * 5,
  YEAR * 10
];
var TIME_MULTIPLIER = 1;

// src/plugins/weekends/weekends.ts
var DEFAULT_WEEKEND_COLOR = "rgb(250, 255, 0, 0.38)";
function WeekendsPlugin({
  color = DEFAULT_WEEKEND_COLOR,
  label,
  predicate
} = {}) {
  return (yagr) => {
    const weekends = [];
    let inWeekend = false;
    for (const ts of yagr.config.timeline) {
      let isWeekend = false;
      if (predicate) {
        isWeekend = predicate(ts);
      } else {
        const date = new Date(ts / (yagr.config.chart?.timeMultiplier || TIME_MULTIPLIER));
        const dayOfWeek = date.getDay();
        isWeekend = dayOfWeek === 6 || dayOfWeek === 0;
      }
      if (isWeekend && !inWeekend) {
        weekends.push([ts, ts]);
        inWeekend = true;
      }
      if (!isWeekend && inWeekend) {
        weekends[weekends.length - 1][1] = ts;
        inWeekend = false;
      }
    }
    yagr.plugins.plotLines?.add(
      weekends.map((val) => ({
        scale: "x",
        value: val,
        color,
        label: label ?? yagr.utils.i18n("weekend")
      }))
    );
    return {
      uplot: {
        hooks: {}
      }
    };
  };
}
if (typeof window !== "undefined") {
  Object.assign(window, { WeekendsPlugin });
}
//# sourceMappingURL=weekends.cjs.js.map
