var u = Object.defineProperty;
var d = (e, t) => u(e, "name", { value: t, configurable: !0 });
import { StateField as l } from "../../../../../@codemirror_state@6.5.2/node_modules/@codemirror/state/dist/index.js";
import { EditorView as m, Decoration as n } from "../../../../../@codemirror_view@6.36.4/node_modules/@codemirror/view/dist/index.js";
import { addSuggestions as p, acceptSuggestion as h, clearSuggestion as S } from "./effects.js";
import { codeiumConfig as v } from "./config.js";
const w = n.mark({ class: "cm-ghostText" }), E = l.define({
  create(e) {
    return null;
  },
  update(e, t) {
    const i = t.state.facet(v);
    for (const r of t.effects) {
      if (r.is(p)) {
        const { changeSpecs: o, index: s } = r.value, a = o[s].map((g) => w.range(g.absoluteStartPos, g.absoluteEndPos)), c = a.at(-1)?.to, f = n.set([
          ...a,
          ...c !== void 0 && o.length > 1 && i.widgetClass ? [
            n.widget({
              widget: new i.widgetClass(s, o.length),
              side: 1
            }).range(c)
          ] : []
        ]);
        return {
          index: s,
          decorations: f,
          changeSpecs: o,
          reverseChangeSet: r.value.reverseChangeSet
        };
      }
      if (r.is(h) || r.is(S))
        return null;
    }
    return e && {
      ...e,
      decorations: e.decorations.map(t.changes),
      reverseChangeSet: e.reverseChangeSet.map(t.changes)
    };
  },
  provide: /* @__PURE__ */ d((e) => m.decorations.from(e, (t) => t?.decorations || n.none), "provide")
});
export {
  E as completionDecoration
};
