import { gM as i, gN as g, gO as u, eg as d, gP as h, gQ as C } from "./603b75d9.js";
import { useEffect as k } from "react";
const E = "cm-click-comp-name", S = i.mark({
  class: E
}), p = g.define(), a = u.define({
  create() {
    return i.none;
  },
  update(t, c) {
    t = t.map(c.changes);
    const n = c.effects.filter((r) => r.is(p));
    return n.length > 0 ? n[0].value : t;
  },
  provide: (t) => d.decorations.from(t)
});
function m(t, c) {
  if (!t || !c)
    return [];
  const n = [];
  let r = 0;
  return t.replace(/[a-zA-Z_$][\w$]*/g, (o) => {
    const e = t.indexOf(o, r);
    return e >= 0 && (c.hasOwnProperty(o) && (e === 0 || t[e - 1] !== ".") && n.push([e, e + o.length]), r = e + o.length), o;
  }), n;
}
function N(t, c, n) {
  if (!t || !n)
    return [];
  if (c === "Function")
    return m(t, n);
  const r = [];
  let o = 0;
  for (const e of h(t)) {
    if (C(e)) {
      const f = o + 2;
      m(e.slice(2, -2), n).forEach(([s, l]) => r.push([s + f, l + f]));
    }
    o += e.length;
  }
  return r;
}
function y(t, c, n, r) {
  k(() => {
    if (!t || c !== t.state.doc.toString())
      return;
    const o = N(c, n, r).map(([f, s]) => S.range(f, s)), e = [p.of(i.set(o))];
    t.state.field(a, !1) || e.push(g.appendConfig.of([a])), t.dispatch({
      effects: e
    });
  }, [t, c, n, r]);
}
export {
  E as c,
  y as u
};
