"use strict";
var g = Object.defineProperty;
var E = Object.getOwnPropertyDescriptor;
var S = Object.getOwnPropertyNames;
var O = Object.prototype.hasOwnProperty;
var $ = (n, e) => g(n, "name", { value: e, configurable: !0 });
var T = (n, e) => {
  for (var t in e)
    g(n, t, { get: e[t], enumerable: !0 });
}, b = (n, e, t, o) => {
  if (e && typeof e == "object" || typeof e == "function")
    for (let r of S(e))
      !O.call(n, r) && r !== t && g(n, r, { get: () => e[r], enumerable: !(o = E(e, r)) || o.enumerable });
  return n;
};
var x = (n) => b(g({}, "__esModule", { value: !0 }), n);

// src/highlight/preview.ts
var _ = {};
T(_, {
  default: () => L
});
module.exports = x(_);
var I = require("storybook/internal/core-events"), p = require("@storybook/global"), m = require("storybook/preview-api");

// src/highlight/constants.ts
var c = "storybook/highlight", u = `${c}/add`, f = `${c}/reset`, H = `${c}/scroll-into-view`;

// src/highlight/preview.ts
var { document: h } = p.global, G = /* @__PURE__ */ $((n, {
  color: e = "#FF4785",
  style: t = "solid",
  width: o = "1px",
  offset: r = "2px",
  fadeOut: a = 0,
  pulseOut: i = 0
}) => {
  let s = Math.random().toString(36).substring(2, 15), l = "";
  return i ? l = `@keyframes ${s} {
      0% { outline: ${o} ${t} ${e}; }
      20% { outline: ${o} ${t} ${e}00; }
      40% { outline: ${o} ${t} ${e}; }
      60% { outline: ${o} ${t} ${e}00; }
      80% { outline: ${o} ${t} ${e}; }
      100% { outline: ${o} ${t} ${e}00; }
    }
` : a && (l = `@keyframes ${s} {
      0% { outline: ${o} ${t} ${e}; }
      100% { outline: ${o} ${t} ${e}00; }
    }
`), `${l}${n.join(", ")} {
    outline: ${o} ${t} ${e};
    outline-offset: ${r};
    ${i || a ? `animation: ${s} ${i || a}ms linear forwards;` : ""}
  }`;
}, "highlightStyle");
m.addons && m.addons.ready && m.addons.ready().then(() => {
  let n = m.addons.getChannel(), e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ $((i) => {
    let s = Math.random().toString(36).substring(2, 15);
    e.add(s);
    let l = h.createElement("style");
    l.innerHTML = G(Array.from(new Set(i.elements)), i), l.setAttribute("id", s), h.head.appendChild(l);
    let d = i.pulseOut || i.fadeOut;
    d && setTimeout(() => o(s), d + 500);
  }, "highlight"), o = /* @__PURE__ */ $((i) => {
    let s = h.getElementById(i);
    s?.parentNode?.removeChild(s), e.delete(i);
  }, "removeHighlight"), r = /* @__PURE__ */ $(() => {
    e.forEach(o);
  }, "resetHighlight"), a = /* @__PURE__ */ $((i, s) => {
    h.querySelector(i)?.scrollIntoView({ behavior: "smooth", block: "center", ...s }), t({
      elements: [i],
      color: "#1EA7FD",
      width: "2px",
      offset: "2px",
      pulseOut: 3e3
    });
  }, "scrollIntoView");
  n.on(I.STORY_CHANGED, r), n.on(H, a), n.on(f, r), n.on(u, t);
});
var L = /* @__PURE__ */ $(() => (0, m.definePreview)({}), "default");
