import { BailSignal as ot, Controller as st, FrameValue as it, Interpolation as at, SpringContext as nt, SpringRef as lt, SpringValue as ut, config as dt, inferTo as pt, useSpring as ct, useSprings as ft } from "../../core/dist/react-spring-core.esm.mjs";
import { unstable_batchedUpdates as k } from "react-dom";
import { Globals as A, createStringInterpolator as F, colors as _, eachProp as j, is as b, FluidValue as I, each as m, getFluidValue as v, hasFluidValue as w, addFluidObserver as T, removeFluidObserver as P, callFluidObservers as $, toArray as V } from "../../shared/dist/react-spring-shared.esm.mjs";
import { createInterpolator as ht, easings as bt, useIsomorphicLayoutEffect as gt } from "../../shared/dist/react-spring-shared.esm.mjs";
import { createHost as E, AnimatedObject as G } from "../../animated/dist/react-spring-animated.esm.mjs";
function y(t, e) {
  if (t == null)
    return {};
  var r = {}, s = Object.keys(t), a, i;
  for (i = 0; i < s.length; i++)
    a = s[i], !(e.indexOf(a) >= 0) && (r[a] = t[a]);
  return r;
}
const L = ["style", "children", "scrollTop", "scrollLeft", "viewBox"], C = /^--/;
function R(t, e) {
  return e == null || typeof e == "boolean" || e === "" ? "" : typeof e == "number" && e !== 0 && !C.test(t) && !(h.hasOwnProperty(t) && h[t]) ? e + "px" : ("" + e).trim();
}
const S = {};
function N(t, e) {
  if (!t.nodeType || !t.setAttribute)
    return !1;
  const r = t.nodeName === "filter" || t.parentNode && t.parentNode.nodeName === "filter", s = e, {
    style: a,
    children: i,
    scrollTop: l,
    scrollLeft: u,
    viewBox: d
  } = s, n = y(s, L), c = Object.values(n), f = Object.keys(n).map((o) => r || t.hasAttribute(o) ? o : S[o] || (S[o] = o.replace(/([A-Z])/g, (p) => "-" + p.toLowerCase())));
  i !== void 0 && (t.textContent = i);
  for (let o in a)
    if (a.hasOwnProperty(o)) {
      const p = R(o, a[o]);
      C.test(o) ? t.style.setProperty(o, p) : t.style[o] = p;
    }
  f.forEach((o, p) => {
    t.setAttribute(o, c[p]);
  }), l !== void 0 && (t.scrollTop = l), u !== void 0 && (t.scrollLeft = u), d !== void 0 && t.setAttribute("viewBox", d);
}
let h = {
  animationIterationCount: !0,
  borderImageOutset: !0,
  borderImageSlice: !0,
  borderImageWidth: !0,
  boxFlex: !0,
  boxFlexGroup: !0,
  boxOrdinalGroup: !0,
  columnCount: !0,
  columns: !0,
  flex: !0,
  flexGrow: !0,
  flexPositive: !0,
  flexShrink: !0,
  flexNegative: !0,
  flexOrder: !0,
  gridRow: !0,
  gridRowEnd: !0,
  gridRowSpan: !0,
  gridRowStart: !0,
  gridColumn: !0,
  gridColumnEnd: !0,
  gridColumnSpan: !0,
  gridColumnStart: !0,
  fontWeight: !0,
  lineClamp: !0,
  lineHeight: !0,
  opacity: !0,
  order: !0,
  orphans: !0,
  tabSize: !0,
  widows: !0,
  zIndex: !0,
  zoom: !0,
  fillOpacity: !0,
  floodOpacity: !0,
  stopOpacity: !0,
  strokeDasharray: !0,
  strokeDashoffset: !0,
  strokeMiterlimit: !0,
  strokeOpacity: !0,
  strokeWidth: !0
};
const W = (t, e) => t + e.charAt(0).toUpperCase() + e.substring(1), z = ["Webkit", "Ms", "Moz", "O"];
h = Object.keys(h).reduce((t, e) => (z.forEach((r) => t[W(r, e)] = t[e]), t), h);
const U = ["x", "y", "z"], B = /^(matrix|translate|scale|rotate|skew)/, M = /^(translate)/, q = /^(rotate|skew)/, x = (t, e) => b.num(t) && t !== 0 ? t + e : t, g = (t, e) => b.arr(t) ? t.every((r) => g(r, e)) : b.num(t) ? t === e : parseFloat(t) === e;
class D extends G {
  constructor(e) {
    let {
      x: r,
      y: s,
      z: a
    } = e, i = y(e, U);
    const l = [], u = [];
    (r || s || a) && (l.push([r || 0, s || 0, a || 0]), u.push((d) => [`translate3d(${d.map((n) => x(n, "px")).join(",")})`, g(d, 0)])), j(i, (d, n) => {
      if (n === "transform")
        l.push([d || ""]), u.push((c) => [c, c === ""]);
      else if (B.test(n)) {
        if (delete i[n], b.und(d))
          return;
        const c = M.test(n) ? "px" : q.test(n) ? "deg" : "";
        l.push(V(d)), u.push(n === "rotate3d" ? ([f, o, p, O]) => [`rotate3d(${f},${o},${p},${x(O, c)})`, g(O, 0)] : (f) => [`${n}(${f.map((o) => x(o, c)).join(",")})`, g(f, n.startsWith("scale") ? 1 : 0)]);
      }
    }), l.length && (i.transform = new H(l, u)), super(i);
  }
}
class H extends I {
  constructor(e, r) {
    super(), this._value = null, this.inputs = e, this.transforms = r;
  }
  get() {
    return this._value || (this._value = this._get());
  }
  _get() {
    let e = "", r = !0;
    return m(this.inputs, (s, a) => {
      const i = v(s[0]), [l, u] = this.transforms[a](b.arr(i) ? i : s.map(v));
      e += " " + l, r = r && u;
    }), r ? "none" : e;
  }
  observerAdded(e) {
    e == 1 && m(this.inputs, (r) => m(r, (s) => w(s) && T(s, this)));
  }
  observerRemoved(e) {
    e == 0 && m(this.inputs, (r) => m(r, (s) => w(s) && P(s, this)));
  }
  eventObserved(e) {
    e.type == "change" && (this._value = null), $(this, e);
  }
}
const K = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"], Z = ["scrollTop", "scrollLeft"];
A.assign({
  batchedUpdates: k,
  createStringInterpolator: F,
  colors: _
});
const J = E(K, {
  applyAnimatedValues: N,
  createAnimatedStyle: (t) => new D(t),
  getComponentProps: (t) => y(t, Z)
}), tt = J.animated;
export {
  ot as BailSignal,
  st as Controller,
  it as FrameValue,
  A as Globals,
  at as Interpolation,
  nt as SpringContext,
  lt as SpringRef,
  ut as SpringValue,
  tt as a,
  tt as animated,
  dt as config,
  ht as createInterpolator,
  bt as easings,
  pt as inferTo,
  gt as useIsomorphicLayoutEffect,
  ct as useSpring,
  ft as useSprings
};
