import {
  a as e,
  c as T
} from "./chunk-IO47FP3U.js";

// ../node_modules/refractor/lang/markup-templating.js
var j = T((w, b) => {
  b.exports = g;
  g.displayName = "markupTemplating";
  g.aliases = [];
  function g(S) {
    (function(f) {
      function y(a, r) {
        return "___" + a.toUpperCase() + r + "___";
      }
      e(y, "getPlaceholder"), Object.defineProperties(f.languages["markup-templating"] = {}, {
        buildPlaceholders: {
          /**
           * Tokenize all inline templating expressions matching `placeholderPattern`.
           *
           * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
           * `true` will be replaced.
           *
           * @param {object} env The environment of the `before-tokenize` hook.
           * @param {string} language The language id.
           * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
           * @param {(match: string) => boolean} [replaceFilter]
           */
          value: /* @__PURE__ */ e(function(a, r, c, p) {
            if (a.language === r) {
              var u = a.tokenStack = [];
              a.code = a.code.replace(c, function(n) {
                if (typeof p == "function" && !p(n))
                  return n;
                for (var i = u.length, t; a.code.indexOf(t = y(r, i)) !== -1; )
                  ++i;
                return u[i] = n, t;
              }), a.grammar = f.languages.markup;
            }
          }, "value")
        },
        tokenizePlaceholders: {
          /**
           * Replace placeholders with proper tokens after tokenizing.
           *
           * @param {object} env The environment of the `after-tokenize` hook.
           * @param {string} language The language id.
           */
          value: /* @__PURE__ */ e(function(a, r) {
            if (a.language !== r || !a.tokenStack)
              return;
            a.grammar = f.languages[r];
            var c = 0, p = Object.keys(a.tokenStack);
            function u(n) {
              for (var i = 0; i < n.length && !(c >= p.length); i++) {
                var t = n[i];
                if (typeof t == "string" || t.content && typeof t.content == "string") {
                  var d = p[c], h = a.tokenStack[d], s = typeof t == "string" ? t : t.content, k = y(r, d), l = s.indexOf(k);
                  if (l > -1) {
                    ++c;
                    var v = s.substring(0, l), O = new f.Token(
                      r,
                      f.tokenize(h, a.grammar),
                      "language-" + r,
                      h
                    ), _ = s.substring(l + k.length), o = [];
                    v && o.push.apply(o, u([v])), o.push(O), _ && o.push.apply(o, u([_])), typeof t == "string" ? n.splice.apply(n, [i, 1].concat(o)) : t.content = o;
                  }
                } else t.content && u(t.content);
              }
              return n;
            }
            e(u, "walkTokens"), u(a.tokens);
          }, "value")
        }
      });
    })(S);
  }
  e(g, "markupTemplating");
});

export {
  j as a
};
