/* Copyright © 2020 Splunk Inc.
SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
in part without a valid written license from Splunk Inc. is PROHIBITED. */
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/EventAnnotations.tsx
var EventAnnotations_exports = {};
__export(EventAnnotations_exports, {
  EVENT_ANNOTATION_DIMENSIONS: () => EVENT_ANNOTATION_DIMENSIONS,
  EventAnnotationContainer: () => EventAnnotationContainer,
  getEventAnnotationRenderer: () => getEventAnnotationRenderer
});
module.exports = __toCommonJS(EventAnnotations_exports);

// esm-externals:react
var react_exports = {};
__export(react_exports, {
  default: () => react_default
});
var defaultImport = __toESM(require("react"));
__reExport(react_exports, require("react"));
var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;

// src/constants.ts
var Alert = "alert";
var Event = "event";
var InfoSeverity = "info";
var WarningSeverity = "warning";
var CriticalSeverity = "critical";
var MajorSeverity = "major";
var MinorSeverity = "minor";

// esm-externals:@splunk/react-icons/ArrowTriangleDown
var ArrowTriangleDown_exports = {};
__export(ArrowTriangleDown_exports, {
  default: () => ArrowTriangleDown_default
});
var defaultImport2 = __toESM(require("@splunk/react-icons/ArrowTriangleDown"));
__reExport(ArrowTriangleDown_exports, require("@splunk/react-icons/ArrowTriangleDown"));
var ArrowTriangleDown_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;

// esm-externals:@splunk/react-icons/Circle
var Circle_exports = {};
__export(Circle_exports, {
  default: () => Circle_default
});
var defaultImport3 = __toESM(require("@splunk/react-icons/Circle"));
__reExport(Circle_exports, require("@splunk/react-icons/Circle"));
var Circle_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;

// esm-externals:@splunk/react-icons/Diamond
var Diamond_exports = {};
__export(Diamond_exports, {
  default: () => Diamond_default
});
var defaultImport4 = __toESM(require("@splunk/react-icons/Diamond"));
__reExport(Diamond_exports, require("@splunk/react-icons/Diamond"));
var Diamond_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;

// esm-externals:@splunk/react-icons/Triangle
var Triangle_exports = {};
__export(Triangle_exports, {
  default: () => Triangle_default
});
var defaultImport5 = __toESM(require("@splunk/react-icons/Triangle"));
__reExport(Triangle_exports, require("@splunk/react-icons/Triangle"));
var Triangle_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;

// esm-externals:@splunk/react-icons/TrianglesLayeredDouble
var TrianglesLayeredDouble_exports = {};
__export(TrianglesLayeredDouble_exports, {
  default: () => TrianglesLayeredDouble_default
});
var defaultImport6 = __toESM(require("@splunk/react-icons/TrianglesLayeredDouble"));
__reExport(TrianglesLayeredDouble_exports, require("@splunk/react-icons/TrianglesLayeredDouble"));
var TrianglesLayeredDouble_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;

// src/icons/AlertIcon.tsx
var AlertIcon = (props) => {
  switch (props.severity) {
    case WarningSeverity:
      return /* @__PURE__ */ react_default.createElement(
        Diamond_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.warning },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
    case InfoSeverity:
      return /* @__PURE__ */ react_default.createElement(
        Circle_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.info },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
    case MinorSeverity:
      return /* @__PURE__ */ react_default.createElement(
        ArrowTriangleDown_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.minor },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
    case MajorSeverity:
      return /* @__PURE__ */ react_default.createElement(
        Triangle_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.major },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
    case CriticalSeverity:
    default:
      return /* @__PURE__ */ react_default.createElement(
        TrianglesLayeredDouble_default,
        {
          width: `${props.dimensions.width}px`,
          height: `${props.dimensions.width}px`,
          viewBox: "0 0 24 24",
          style: { color: props.theme.annotationIcon.alertIconColor.critical },
          variant: `${props.isCleared ? "outlined" : "filled"}`
        }
      );
  }
};

// esm-externals:@splunk/react-icons/CheckBox
var CheckBox_exports = {};
__export(CheckBox_exports, {
  default: () => CheckBox_default
});
var defaultImport7 = __toESM(require("@splunk/react-icons/CheckBox"));
__reExport(CheckBox_exports, require("@splunk/react-icons/CheckBox"));
var CheckBox_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;

// src/icons/CustomEventIcon.tsx
var CustomEventIcon = (props) => /* @__PURE__ */ react_default.createElement(
  CheckBox_default,
  {
    width: `${props.dimensions.width}px`,
    height: `${props.dimensions.width}px`,
    viewBox: "0 0 24 24",
    style: { color: props.theme.annotationIcon.customEventIconColor },
    variant: `${props.isCleared ? "outlined" : "filled"}`
  }
);

// esm-externals:@splunk/themes
var themes_exports = {};
__export(themes_exports, {
  default: () => themes_default
});
var defaultImport8 = __toESM(require("@splunk/themes"));
__reExport(themes_exports, require("@splunk/themes"));
var themes_default = "default" in defaultImport8 ? defaultImport8.default : defaultImport8;

// src/theme.tsx
var lightVizTheme = {
  name: "light",
  color: "#2C2C2C",
  font: "10px Arial",
  labelFont: "12px Arial",
  axis: {
    axisStroke: "#E6E6E6",
    gridStroke: "#DDDDDD",
    xLabelStroke: "#6B6B6B",
    yLabelStroke: "#4D4D4D"
  },
  tooltip: {
    lineStroke: "rgba(44, 44, 44, 0.85)",
    inactiveLineStroke: "#999",
    backgroundColor: "rgba(44, 44, 44, 0.85)",
    color: "white",
    secondaryColor: "#999"
  },
  pin: {
    iconStroke: "white",
    lineStroke: "#9e9e9e",
    dotFill: "#9e9e9e"
  },
  heatmap: {
    axisStroke: "#2c2c2c",
    axisFontSize: 12,
    colorScheme: [
      "#ffffff",
      "#ccd6d7",
      "#aec8cd",
      "#8fb8c7",
      "#6ea8c1",
      "#4b96bd",
      "#2181bb",
      "#0067ba",
      "#0047bd",
      "#0502ca"
    ]
  },
  annotationIcon: {
    customEventIconColor: "#818285",
    alertIconColor: {
      critical: "#E00000",
      major: "#C97705",
      minor: "#155A4E",
      warning: "#006BE5",
      info: "#7B4DF5"
    }
  }
};
var darkVizTheme = {
  name: "dark",
  color: "#FAFAFA",
  font: "10px Arial",
  labelFont: "12px Arial",
  axis: {
    axisStroke: "#43454B",
    gridStroke: "#43454B",
    xLabelStroke: "#909090",
    yLabelStroke: "#B5B5B5"
  },
  tooltip: {
    lineStroke: "white",
    inactiveLineStroke: "#666",
    backgroundColor: "rgba(64, 64, 64, 0.85)",
    color: "white",
    secondaryColor: "#999"
  },
  pin: {
    iconStroke: "white",
    lineStroke: "white",
    dotFill: "#bdbdbd"
  },
  heatmap: {
    axisStroke: "#fafafa",
    axisFontSize: 12,
    colorScheme: [
      "#000000",
      "#15355a",
      "#315272",
      "#496d89",
      "#60869e",
      "#759db3",
      "#89b4c7",
      "#9ccad9",
      "#afdfec",
      "#c2f5ff"
    ]
  },
  annotationIcon: {
    customEventIconColor: "#818285",
    alertIconColor: {
      critical: "#FF4242",
      major: "#F49106",
      minor: "#2CBDA3",
      warning: "#61CAFA",
      info: "#AB74F1"
    }
  }
};
function getVizThemeForKey(key) {
  switch (key) {
    case "dark": {
      return darkVizTheme;
    }
    case "light":
    default: {
      return lightVizTheme;
    }
  }
}
function useVizTheme() {
  const { colorScheme } = (0, themes_exports.useSplunkTheme)();
  return getVizThemeForKey(colorScheme);
}

// src/EventAnnotations.tsx
var EVENT_ANNOTATION_DIMENSIONS = {
  width: 12,
  height: 12
};
var EventAnnotationContainer = (props) => {
  const {
    plotUtilities,
    events,
    eventAnnotationConfig,
    onEventAnnotationHover,
    onEventAnnotationClick,
    xResolution
  } = props;
  const theme = useVizTheme();
  if (!events || !plotUtilities) {
    return null;
  }
  const { height: overHeight } = plotUtilities.dimensions.over;
  const annotationRenderer = getEventAnnotationRenderer(eventAnnotationConfig);
  return /* @__PURE__ */ react_default.createElement("div", { className: "olly-viz-event-annotation-wrap", style: { position: "absolute" } }, events.map((event) => {
    const x = plotUtilities.valToPos(event.time, "x") - EVENT_ANNOTATION_DIMENSIONS.width / 2;
    const y = overHeight;
    const annotationNode = annotationRenderer({
      event,
      theme,
      dimensions: EVENT_ANNOTATION_DIMENSIONS
    });
    return /* @__PURE__ */ react_default.createElement(
      "div",
      {
        key: `${event.key || ""}${event.time}`,
        className: "olly-viz-event-annotation",
        "data-test": "viz-event-annotation",
        style: {
          position: "absolute",
          left: `${x}px`,
          top: `${y}px`,
          width: `${EVENT_ANNOTATION_DIMENSIONS.width}px`,
          height: `${EVENT_ANNOTATION_DIMENSIONS.height}px`,
          display: "flex",
          alignItems: "center",
          justifyContent: "center",
          pointerEvents: "auto"
        },
        onMouseEnter: () => onEventAnnotationHover(event),
        onMouseLeave: () => onEventAnnotationHover(void 0),
        onClick: (mouseEvent) => {
          if (onEventAnnotationClick) {
            onEventAnnotationClick(__spreadProps(__spreadValues({}, event), { xResolution }), mouseEvent);
          }
        }
      },
      annotationNode
    );
  }));
};
var getEventAnnotationRenderer = (eventAnnotationConfig) => {
  const defaultAnnotationRenderer = ({
    event,
    theme,
    dimensions
  }) => {
    switch (event.type) {
      case Alert:
        return /* @__PURE__ */ react_default.createElement(
          AlertIcon,
          {
            theme,
            dimensions,
            severity: event.severity,
            isCleared: event.isCleared
          }
        );
      case Event:
      default:
        return /* @__PURE__ */ react_default.createElement(CustomEventIcon, { theme, dimensions, isCleared: event.isCleared });
    }
  };
  return (eventAnnotationConfig == null ? void 0 : eventAnnotationConfig.renderer) || defaultAnnotationRenderer;
};
//# sourceMappingURL=EventAnnotations.js.map
