import { B as tags, Et as EditorSelection, I as syntaxTree, O as indentNodeProp, Z as EditorView, m as bracketMatchingHandle, n as ExternalTokenizer, r as LRParser, s as LRLanguage, t as ContextTracker, u as LanguageSupport, w as foldNodeProp, z as styleTags } from "./dist-CCADb07R.js";
var StartTag = 1, StartCloseTag = 2, MissingCloseTag = 3, mismatchedStartCloseTag = 4, incompleteStartCloseTag = 5, commentContent$1 = 36, piContent$1 = 37, cdataContent$1 = 38, Element$1 = 11, OpenTag = 13;
function nameChar(m) {
  return m == 45 || m == 46 || m == 58 || m >= 65 && m <= 90 || m == 95 || m >= 97 && m <= 122 || m >= 161;
}
function isSpace(m) {
  return m == 9 || m == 10 || m == 13 || m == 32;
}
var cachedName = null, cachedInput = null, cachedPos = 0;
function tagNameAfter(m, V) {
  let H = m.pos + V;
  if (cachedInput == m && cachedPos == H) return cachedName;
  for (; isSpace(m.peek(V)); ) V++;
  let U = "";
  for (; ; ) {
    let H2 = m.peek(V);
    if (!nameChar(H2)) break;
    U += String.fromCharCode(H2), V++;
  }
  return cachedInput = m, cachedPos = H, cachedName = U || null;
}
function ElementContext(m, V) {
  this.name = m, this.parent = V;
}
var elementContext = new ContextTracker({
  start: null,
  shift(m, V, H, U) {
    return V == StartTag ? new ElementContext(tagNameAfter(U, 1) || "", m) : m;
  },
  reduce(m, V) {
    return V == Element$1 && m ? m.parent : m;
  },
  reuse(m, V, H, U) {
    let W = V.type.id;
    return W == StartTag || W == OpenTag ? new ElementContext(tagNameAfter(U, 1) || "", m) : m;
  },
  strict: false
}), startTag = new ExternalTokenizer((m, V) => {
  if (m.next == 60) {
    if (m.advance(), m.next == 47) {
      m.advance();
      let H = tagNameAfter(m, 0);
      if (!H) return m.acceptToken(incompleteStartCloseTag);
      if (V.context && H == V.context.name) return m.acceptToken(StartCloseTag);
      for (let U = V.context; U; U = U.parent) if (U.name == H) return m.acceptToken(MissingCloseTag, -2);
      m.acceptToken(mismatchedStartCloseTag);
    } else if (m.next != 33 && m.next != 63) return m.acceptToken(StartTag);
  }
}, { contextual: true });
function scanTo(m, V) {
  return new ExternalTokenizer((H) => {
    let U = 0, W = V.charCodeAt(0);
    scan: for (; !(H.next < 0); H.advance(), U++) if (H.next == W) {
      for (let m2 = 1; m2 < V.length; m2++) if (H.peek(m2) != V.charCodeAt(m2)) continue scan;
      break;
    }
    U && H.acceptToken(m);
  });
}
var commentContent = scanTo(commentContent$1, "-->"), piContent = scanTo(piContent$1, "?>"), cdataContent = scanTo(cdataContent$1, "]]>"), xmlHighlighting = styleTags({
  Text: tags.content,
  "StartTag StartCloseTag EndTag SelfCloseEndTag": tags.angleBracket,
  TagName: tags.tagName,
  "MismatchedCloseTag/TagName": [tags.tagName, tags.invalid],
  AttributeName: tags.attributeName,
  AttributeValue: tags.attributeValue,
  Is: tags.definitionOperator,
  "EntityReference CharacterReference": tags.character,
  Comment: tags.blockComment,
  ProcessingInst: tags.processingInstruction,
  DoctypeDecl: tags.documentMeta,
  Cdata: tags.special(tags.string)
}), parser = LRParser.deserialize({
  version: 14,
  states: ",lOQOaOOOrOxO'#CfOzOpO'#CiO!tOaO'#CgOOOP'#Cg'#CgO!{OrO'#CrO#TOtO'#CsO#]OpO'#CtOOOP'#DT'#DTOOOP'#Cv'#CvQQOaOOOOOW'#Cw'#CwO#eOxO,59QOOOP,59Q,59QOOOO'#Cx'#CxO#mOpO,59TO#uO!bO,59TOOOP'#C|'#C|O$TOaO,59RO$[OpO'#CoOOOP,59R,59ROOOQ'#C}'#C}O$dOrO,59^OOOP,59^,59^OOOS'#DO'#DOO$lOtO,59_OOOP,59_,59_O$tOpO,59`O$|OpO,59`OOOP-E6t-E6tOOOW-E6u-E6uOOOP1G.l1G.lOOOO-E6v-E6vO%UO!bO1G.oO%UO!bO1G.oO%dOpO'#CkO%lO!bO'#CyO%zO!bO1G.oOOOP1G.o1G.oOOOP1G.w1G.wOOOP-E6z-E6zOOOP1G.m1G.mO&VOpO,59ZO&_OpO,59ZOOOQ-E6{-E6{OOOP1G.x1G.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PPP%ZXWORYbXRORYb_t`qru!T!U!bQ!i!YS!p!e!fR!w!oQdRRybXSORYbQYORmYQ[PRn[Q_QQkVjp_krz!R!T!X!Z!^!`!f!j!oQr`QzcQ!RlQ!TqQ!XsQ!ZtQ!^{Q!`!QQ!f!YQ!j!]R!o!eQu`S!UqrU![u!U!bR!b!TQ!r!gR!x!rQ!u!hR!z!uQbRRxbQfTR|fQiUR!OiSXOYTaRb",
  nodeNames: "\u26A0 StartTag StartCloseTag MissingCloseTag StartCloseTag StartCloseTag Document Text EntityReference CharacterReference Cdata Element EndTag OpenTag TagName Attribute AttributeName Is AttributeValue CloseTag SelfCloseEndTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag DoctypeDecl",
  maxTerm: 50,
  context: elementContext,
  nodeProps: [
    [
      "closedBy",
      1,
      "SelfCloseEndTag EndTag",
      13,
      "CloseTag MissingCloseTag"
    ],
    [
      "openedBy",
      12,
      "StartTag StartCloseTag",
      19,
      "OpenTag",
      20,
      "StartTag"
    ],
    [
      "isolate",
      -6,
      13,
      18,
      19,
      21,
      22,
      24,
      ""
    ]
  ],
  propSources: [xmlHighlighting],
  skippedNodes: [0],
  repeatNodeCount: 9,
  tokenData: "!)v~R!YOX$qXY)iYZ)iZ]$q]^)i^p$qpq)iqr$qrs*vsv$qvw+fwx/ix}$q}!O0[!O!P$q!P!Q2z!Q![$q![!]4n!]!^$q!^!_8U!_!`!#t!`!a!$l!a!b!%d!b!c$q!c!}4n!}#P$q#P#Q!'W#Q#R$q#R#S4n#S#T$q#T#o4n#o%W$q%W%o4n%o%p$q%p&a4n&a&b$q&b1p4n1p4U$q4U4d4n4d4e$q4e$IS4n$IS$I`$q$I`$Ib4n$Ib$Kh$q$Kh%#t4n%#t&/x$q&/x&Et4n&Et&FV$q&FV;'S4n;'S;:j8O;:j;=`)c<%l?&r$q?&r?Ah4n?Ah?BY$q?BY?Mn4n?MnO$qi$zXVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$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#iK|#i;'S(o;'S;=`)]<%lO(oiLTX|W!O`Or(ors&osv(owx'}x#T(o#T#UH`#U;'S(o;'S;=`)]<%lO(oiLwX|W!O`Or(ors&osv(owx'}x#c(o#c#dMd#d;'S(o;'S;=`)]<%lO(oiMkX|W!O`Or(ors&osv(owx'}x#V(o#V#WNW#W;'S(o;'S;=`)]<%lO(oiN_X|W!O`Or(ors&osv(owx'}x#h(o#h#iNz#i;'S(o;'S;=`)]<%lO(oi! RX|W!O`Or(ors&osv(owx'}x#m(o#m#n! n#n;'S(o;'S;=`)]<%lO(oi! uX|W!O`Or(ors&osv(owx'}x#d(o#d#e!!b#e;'S(o;'S;=`)]<%lO(oi!!iX|W!O`Or(ors&osv(owx'}x#X(o#X#Y?y#Y;'S(o;'S;=`)]<%lO(oi!#_V!SP|W!O`Or(ors&osv(owx'}x;'S(o;'S;=`)]<%lO(ok!$PXaQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qo!$wX[UVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qk!%mZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_!`$q!`!a!&`!a;'S$q;'S;=`)c<%lO$qk!&kX!RQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qk!'aZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_#P$q#P#Q!(S#Q;'S$q;'S;=`)c<%lO$qk!(]ZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_!`$q!`!a!)O!a;'S$q;'S;=`)c<%lO$qk!)ZXxQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$q",
  tokenizers: [
    startTag,
    commentContent,
    piContent,
    cdataContent,
    0,
    1,
    2,
    3,
    4
  ],
  topRules: { Document: [0, 6] },
  tokenPrec: 0
});
function tagName(m, V) {
  let H = V && V.getChild("TagName");
  return H ? m.sliceString(H.from, H.to) : "";
}
function elementName$1(m, V) {
  let H = V && V.firstChild;
  return !H || H.name != "OpenTag" ? "" : tagName(m, H);
}
function attrName(m, V, H) {
  let U = V && V.getChildren("Attribute").find((m2) => m2.from <= H && m2.to >= H), W = U && U.getChild("AttributeName");
  return W ? m.sliceString(W.from, W.to) : "";
}
function findParentElement(m) {
  for (let V = m && m.parent; V; V = V.parent) if (V.name == "Element") return V;
  return null;
}
function findLocation(m, V) {
  var _a;
  let U = syntaxTree(m).resolveInner(V, -1), W = null;
  for (let m2 = U; !W && m2.parent; m2 = m2.parent) (m2.name == "OpenTag" || m2.name == "CloseTag" || m2.name == "SelfClosingTag" || m2.name == "MismatchedCloseTag") && (W = m2);
  if (W && (W.to > V || W.lastChild.type.isError)) {
    let m2 = W.parent;
    if (U.name == "TagName") return W.name == "CloseTag" || W.name == "MismatchedCloseTag" ? {
      type: "closeTag",
      from: U.from,
      context: m2
    } : {
      type: "openTag",
      from: U.from,
      context: findParentElement(m2)
    };
    if (U.name == "AttributeName") return {
      type: "attrName",
      from: U.from,
      context: W
    };
    if (U.name == "AttributeValue") return {
      type: "attrValue",
      from: U.from,
      context: W
    };
    let H = U == W || U.name == "Attribute" ? U.childBefore(V) : U;
    return (H == null ? void 0 : H.name) == "StartTag" ? {
      type: "openTag",
      from: V,
      context: findParentElement(m2)
    } : (H == null ? void 0 : H.name) == "StartCloseTag" && H.to <= V ? {
      type: "closeTag",
      from: V,
      context: m2
    } : (H == null ? void 0 : H.name) == "Is" ? {
      type: "attrValue",
      from: V,
      context: W
    } : H ? {
      type: "attrName",
      from: V,
      context: W
    } : null;
  } else if (U.name == "StartCloseTag") return {
    type: "closeTag",
    from: V,
    context: U.parent
  };
  for (; U.parent && U.to == V && !((_a = U.lastChild) == null ? void 0 : _a.type.isError); ) U = U.parent;
  return U.name == "Element" || U.name == "Text" || U.name == "Document" ? {
    type: "tag",
    from: V,
    context: U.name == "Element" ? U : findParentElement(U)
  } : null;
}
var Element = class {
  constructor(m, V, H) {
    this.attrs = V, this.attrValues = H, this.children = [], this.name = m.name, this.completion = Object.assign(Object.assign({ type: "type" }, m.completion || {}), { label: this.name }), this.openCompletion = Object.assign(Object.assign({}, this.completion), { label: "<" + this.name }), this.closeCompletion = Object.assign(Object.assign({}, this.completion), {
      label: "</" + this.name + ">",
      boost: 2
    }), this.closeNameCompletion = Object.assign(Object.assign({}, this.completion), { label: this.name + ">" }), this.text = m.textContent ? m.textContent.map((m2) => ({
      label: m2,
      type: "text"
    })) : [];
  }
}, Identifier = /^[:\-\.\w\u00b7-\uffff]*$/;
function attrCompletion(m) {
  return Object.assign(Object.assign({ type: "property" }, m.completion || {}), { label: m.name });
}
function valueCompletion(m) {
  return typeof m == "string" ? {
    label: `"${m}"`,
    type: "constant"
  } : /^"/.test(m.label) ? m : Object.assign(Object.assign({}, m), { label: `"${m.label}"` });
}
function completeFromSchema(m, V) {
  let H = [], U = [], W = /* @__PURE__ */ Object.create(null);
  for (let m2 of V) {
    let V2 = attrCompletion(m2);
    H.push(V2), m2.global && U.push(V2), m2.values && (W[m2.name] = m2.values.map(valueCompletion));
  }
  let G = [], K = [], q = /* @__PURE__ */ Object.create(null);
  for (let V2 of m) {
    let m2 = U, J = W;
    V2.attributes && (m2 = m2.concat(V2.attributes.map((m3) => typeof m3 == "string" ? H.find((V3) => V3.label == m3) || {
      label: m3,
      type: "property"
    } : (m3.values && (J == W && (J = Object.create(J)), J[m3.name] = m3.values.map(valueCompletion)), attrCompletion(m3)))));
    let Y = new Element(V2, m2, J);
    q[Y.name] = Y, G.push(Y), V2.top && K.push(Y);
  }
  K.length || (K = G);
  for (let V2 = 0; V2 < G.length; V2++) {
    let H2 = m[V2], U2 = G[V2];
    if (H2.children) for (let m2 of H2.children) q[m2] && U2.children.push(q[m2]);
    else U2.children = G;
  }
  return (m2) => {
    var _a, _b, _c, _d;
    let { doc: V2 } = m2.state, H2 = findLocation(m2.state, m2.pos);
    if (!H2 || H2.type == "tag" && !m2.explicit) return null;
    let { type: J, from: Y, context: X } = H2;
    if (J == "openTag") {
      let m3 = K, H3 = elementName$1(V2, X);
      return H3 && (m3 = ((_a = q[H3]) == null ? void 0 : _a.children) || G), {
        from: Y,
        options: m3.map((m4) => m4.completion),
        validFor: Identifier
      };
    } else if (J == "closeTag") {
      let H3 = elementName$1(V2, X);
      return H3 ? {
        from: Y,
        to: m2.pos + (V2.sliceString(m2.pos, m2.pos + 1) == ">" ? 1 : 0),
        options: [((_b = q[H3]) == null ? void 0 : _b.closeNameCompletion) || {
          label: H3 + ">",
          type: "type"
        }],
        validFor: Identifier
      } : null;
    } else if (J == "attrName") return {
      from: Y,
      options: ((_c = q[tagName(V2, X)]) == null ? void 0 : _c.attrs) || U,
      validFor: Identifier
    };
    else if (J == "attrValue") {
      let H3 = attrName(V2, X, Y);
      if (!H3) return null;
      let U2 = (((_d = q[tagName(V2, X)]) == null ? void 0 : _d.attrValues) || W)[H3];
      return !U2 || !U2.length ? null : {
        from: Y,
        to: m2.pos + (V2.sliceString(m2.pos, m2.pos + 1) == '"' ? 1 : 0),
        options: U2,
        validFor: /^"[^"]*"?$/
      };
    } else if (J == "tag") {
      let H3 = elementName$1(V2, X), U2 = q[H3], W2 = [], J2 = X && X.lastChild;
      H3 && (!J2 || J2.name != "CloseTag" || tagName(V2, J2) != H3) && W2.push(U2 ? U2.closeCompletion : {
        label: "</" + H3 + ">",
        type: "type",
        boost: 2
      });
      let Z = W2.concat(((U2 == null ? void 0 : U2.children) || (X ? G : K)).map((m3) => m3.openCompletion));
      if (X && (U2 == null ? void 0 : U2.text.length)) {
        let V3 = X.firstChild;
        V3.to > m2.pos - 20 && !/\S/.test(m2.state.sliceDoc(V3.to, m2.pos)) && (Z = Z.concat(U2.text));
      }
      return {
        from: Y,
        options: Z,
        validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/
      };
    } else return null;
  };
}
var xmlLanguage = /* @__PURE__ */ LRLanguage.define({
  name: "xml",
  parser: /* @__PURE__ */ parser.configure({ props: [
    /* @__PURE__ */ indentNodeProp.add({
      Element(m) {
        let V = /^\s*<\//.test(m.textAfter);
        return m.lineIndent(m.node.from) + (V ? 0 : m.unit);
      },
      "OpenTag CloseTag SelfClosingTag"(m) {
        return m.column(m.node.from) + m.unit;
      }
    }),
    /* @__PURE__ */ foldNodeProp.add({ Element(m) {
      let V = m.firstChild, H = m.lastChild;
      return !V || V.name != "OpenTag" ? null : {
        from: V.to,
        to: H.name == "CloseTag" ? H.from : m.to
      };
    } }),
    /* @__PURE__ */ bracketMatchingHandle.add({ "OpenTag CloseTag": (m) => m.getChild("TagName") })
  ] }),
  languageData: {
    commentTokens: { block: {
      open: "<!--",
      close: "-->"
    } },
    indentOnInput: /^\s*<\/$/
  }
});
function xml(m = {}) {
  let V = [xmlLanguage.data.of({ autocomplete: completeFromSchema(m.elements || [], m.attributes || []) })];
  return m.autoCloseTags !== false && V.push(autoCloseTags), new LanguageSupport(xmlLanguage, V);
}
function elementName(m, V, H = m.length) {
  if (!V) return "";
  let U = V.firstChild, W = U && U.getChild("TagName");
  return W ? m.sliceString(W.from, Math.min(W.to, H)) : "";
}
var autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((m, U, W, G, K) => {
  if (m.composing || m.state.readOnly || U != W || G != ">" && G != "/" || !xmlLanguage.isActiveAt(m.state, U, -1)) return false;
  let q = K(), { state: J } = q, Y = J.changeByRange((m2) => {
    var _a, _b, _c;
    let { head: U2 } = m2, W2 = J.doc.sliceString(U2 - 1, U2) == G, K2 = syntaxTree(J).resolveInner(U2, -1), q2;
    if (W2 && G == ">" && K2.name == "EndTag") {
      let V = K2.parent;
      if (((_b = (_a = V.parent) == null ? void 0 : _a.lastChild) == null ? void 0 : _b.name) != "CloseTag" && (q2 = elementName(J.doc, V.parent, U2))) return {
        range: m2,
        changes: {
          from: U2,
          to: U2 + (J.doc.sliceString(U2, U2 + 1) === ">" ? 1 : 0),
          insert: `</${q2}>`
        }
      };
    } else if (W2 && G == "/" && K2.name == "StartCloseTag") {
      let m3 = K2.parent;
      if (K2.from == U2 - 2 && ((_c = m3.lastChild) == null ? void 0 : _c.name) != "CloseTag" && (q2 = elementName(J.doc, m3, U2))) {
        let m4 = U2 + (J.doc.sliceString(U2, U2 + 1) === ">" ? 1 : 0), H = `${q2}>`;
        return {
          range: EditorSelection.cursor(U2 + H.length, -1),
          changes: {
            from: U2,
            to: m4,
            insert: H
          }
        };
      }
    }
    return { range: m2 };
  });
  return Y.changes.empty ? false : (m.dispatch([q, J.update(Y, {
    userEvent: "input.complete",
    scrollIntoView: true
  })]), true);
});
export {
  xmlLanguage as i,
  completeFromSchema as n,
  xml as r,
  autoCloseTags as t
};
