"use strict"; (self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] = self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] || []).push([[4588],{ /***/ 64588: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { autoCloseTags: () => (/* binding */ autoCloseTags), completeFromSchema: () => (/* binding */ completeFromSchema), xml: () => (/* binding */ xml), xmlLanguage: () => (/* binding */ xmlLanguage) }); // EXTERNAL MODULE: ../node_modules/@lezer/lr/dist/index.js var dist = __webpack_require__(49906); // EXTERNAL MODULE: consume shared module (default) @lezer/highlight@~1.2.0 (singleton) (fallback: ../node_modules/@lezer/highlight/dist/index.js) var index_js_ = __webpack_require__(92209); ;// CONCATENATED MODULE: ../node_modules/@lezer/xml/dist/index.js // This file was generated by lezer-generator. You probably shouldn't edit it. const StartTag = 1, StartCloseTag = 2, MissingCloseTag = 3, mismatchedStartCloseTag = 4, incompleteStartCloseTag = 5, commentContent$1 = 35, piContent$1 = 36, cdataContent$1 = 37, Element = 11, OpenTag = 13; /* Hand-written tokenizer for XML tag matching. */ function nameChar(ch) { return ch == 45 || ch == 46 || ch == 58 || ch >= 65 && ch <= 90 || ch == 95 || ch >= 97 && ch <= 122 || ch >= 161 } function isSpace(ch) { return ch == 9 || ch == 10 || ch == 13 || ch == 32 } let cachedName = null, cachedInput = null, cachedPos = 0; function tagNameAfter(input, offset) { let pos = input.pos + offset; if (cachedInput == input && cachedPos == pos) return cachedName while (isSpace(input.peek(offset))) offset++; let name = ""; for (;;) { let next = input.peek(offset); if (!nameChar(next)) break name += String.fromCharCode(next); offset++; } cachedInput = input; cachedPos = pos; return cachedName = name || null } function ElementContext(name, parent) { this.name = name; this.parent = parent; this.hash = parent ? parent.hash : 0; for (let i = 0; i < name.length; i++) this.hash += (this.hash << 4) + name.charCodeAt(i) + (name.charCodeAt(i) << 8); } const elementContext = new dist/* ContextTracker */.IK({ start: null, shift(context, term, stack, input) { return term == StartTag ? new ElementContext(tagNameAfter(input, 1) || "", context) : context }, reduce(context, term) { return term == Element && context ? context.parent : context }, reuse(context, node, _stack, input) { let type = node.type.id; return type == StartTag || type == OpenTag ? new ElementContext(tagNameAfter(input, 1) || "", context) : context }, hash(context) { return context ? context.hash : 0 }, strict: false }); const startTag = new dist/* ExternalTokenizer */.Jq((input, stack) => { if (input.next != 60 /* '<' */) return input.advance(); if (input.next == 47 /* '/' */) { input.advance(); let name = tagNameAfter(input, 0); if (!name) return input.acceptToken(incompleteStartCloseTag) if (stack.context && name == stack.context.name) return input.acceptToken(StartCloseTag) for (let cx = stack.context; cx; cx = cx.parent) if (cx.name == name) return input.acceptToken(MissingCloseTag, -2) input.acceptToken(mismatchedStartCloseTag); } else if (input.next != 33 /* '!' */ && input.next != 63 /* '?' */) { return input.acceptToken(StartTag) } }, {contextual: true}); function scanTo(type, end) { return new dist/* ExternalTokenizer */.Jq(input => { for (let endPos = 0, len = 0;; len++) { if (input.next < 0) { if (len) input.acceptToken(type); break } if (input.next == end.charCodeAt(endPos)) { endPos++; if (endPos == end.length) { if (len >= end.length) input.acceptToken(type, 1 - end.length); break } } else { endPos = input.next == end.charCodeAt(0) ? 1 : 0; } input.advance(); } }) } const commentContent = scanTo(commentContent$1, "-->"); const piContent = scanTo(piContent$1, "?>"); const cdataContent = scanTo(cdataContent$1, "]]>"); const xmlHighlighting = (0,index_js_.styleTags)({ Text: index_js_.tags.content, "StartTag StartCloseTag EndTag SelfCloseEndTag": index_js_.tags.angleBracket, TagName: index_js_.tags.tagName, "MismatchedCloseTag/Tagname": [index_js_.tags.tagName, index_js_.tags.invalid], AttributeName: index_js_.tags.attributeName, AttributeValue: index_js_.tags.attributeValue, Is: index_js_.tags.definitionOperator, "EntityReference CharacterReference": index_js_.tags.character, Comment: index_js_.tags.blockComment, ProcessingInst: index_js_.tags.processingInstruction, DoctypeDecl: index_js_.tags.documentMeta, Cdata: index_js_.tags.special(index_js_.tags.string) }); // This file was generated by lezer-generator. You probably shouldn't edit it. const parser = dist/* LRParser */.WQ.deserialize({ version: 14, states: ",SOQOaOOOrOxO'#CfOzOpO'#CiO!tOaO'#CgOOOP'#Cg'#CgO!{OrO'#CrO#TOtO'#CsO#]OpO'#CtOOOP'#DS'#DSOOOP'#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'#C}'#C}O$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-E6y-E6yOOOP1G.m1G.mO&VOpO,59ZO&_OpO,59ZOOOQ-E6z-E6zOOOP1G.x1G.xOOOS-E6{-E6{OOOP1G.y1G.yO&gOpO1G.zO&gOpO1G.zOOOP1G.z1G.zO&oO!bO7+$ZO&}O!bO7+$ZOOOP7+$Z7+$ZOOOP7+$c7+$cO'YOpO,59VO'bOpO,59VO'jO!bO,59eOOOO-E6w-E6wO'xOpO1G.uO'xOpO1G.uOOOP1G.u1G.uO(QOpO7+$fOOOP7+$f7+$fO(YO!bO<`#X;'S%y;'S;=`&_<%lO%yX>eV{WOr%ysv%yw#T%y#T#U>z#U;'S%y;'S;=`&_<%lO%yX?PV{WOr%ysv%yw#h%y#h#i?f#i;'S%y;'S;=`&_<%lO%yX?kV{WOr%ysv%yw#T%y#T#U a.from <= pos && a.to >= pos); let name = attr && attr.getChild("AttributeName"); return name ? doc.sliceString(name.from, name.to) : ""; } function findParentElement(tree) { for (let cur = tree && tree.parent; cur; cur = cur.parent) if (cur.name == "Element") return cur; return null; } function findLocation(state, pos) { var _a; let at = (0,dist_index_js_.syntaxTree)(state).resolveInner(pos, -1), inTag = null; for (let cur = at; !inTag && cur.parent; cur = cur.parent) if (cur.name == "OpenTag" || cur.name == "CloseTag" || cur.name == "SelfClosingTag" || cur.name == "MismatchedCloseTag") inTag = cur; if (inTag && (inTag.to > pos || inTag.lastChild.type.isError)) { let elt = inTag.parent; if (at.name == "TagName") return inTag.name == "CloseTag" || inTag.name == "MismatchedCloseTag" ? { type: "closeTag", from: at.from, context: elt } : { type: "openTag", from: at.from, context: findParentElement(elt) }; if (at.name == "AttributeName") return { type: "attrName", from: at.from, context: inTag }; if (at.name == "AttributeValue") return { type: "attrValue", from: at.from, context: inTag }; let before = at == inTag || at.name == "Attribute" ? at.childBefore(pos) : at; if ((before === null || before === void 0 ? void 0 : before.name) == "StartTag") return { type: "openTag", from: pos, context: findParentElement(elt) }; if ((before === null || before === void 0 ? void 0 : before.name) == "StartCloseTag" && before.to <= pos) return { type: "closeTag", from: pos, context: elt }; if ((before === null || before === void 0 ? void 0 : before.name) == "Is") return { type: "attrValue", from: pos, context: inTag }; if (before) return { type: "attrName", from: pos, context: inTag }; return null; } else if (at.name == "StartCloseTag") { return { type: "closeTag", from: pos, context: at.parent }; } while (at.parent && at.to == pos && !((_a = at.lastChild) === null || _a === void 0 ? void 0 : _a.type.isError)) at = at.parent; if (at.name == "Element" || at.name == "Text" || at.name == "Document") return { type: "tag", from: pos, context: at.name == "Element" ? at : findParentElement(at) }; return null; } class dist_Element { constructor(spec, attrs, attrValues) { this.attrs = attrs; this.attrValues = attrValues; this.children = []; this.name = spec.name; this.completion = Object.assign(Object.assign({ type: "type" }, spec.completion || {}), { label: this.name }); this.openCompletion = Object.assign(Object.assign({}, this.completion), { label: "<" + this.name }); this.closeCompletion = Object.assign(Object.assign({}, this.completion), { label: "", boost: 2 }); this.closeNameCompletion = Object.assign(Object.assign({}, this.completion), { label: this.name + ">" }); this.text = spec.textContent ? spec.textContent.map(s => ({ label: s, type: "text" })) : []; } } const Identifier = /^[:\-\.\w\u00b7-\uffff]*$/; function attrCompletion(spec) { return Object.assign(Object.assign({ type: "property" }, spec.completion || {}), { label: spec.name }); } function valueCompletion(spec) { return typeof spec == "string" ? { label: `"${spec}"`, type: "constant" } : /^"/.test(spec.label) ? spec : Object.assign(Object.assign({}, spec), { label: `"${spec.label}"` }); } /** Create a completion source for the given schema. */ function completeFromSchema(eltSpecs, attrSpecs) { let allAttrs = [], globalAttrs = []; let attrValues = Object.create(null); for (let s of attrSpecs) { let completion = attrCompletion(s); allAttrs.push(completion); if (s.global) globalAttrs.push(completion); if (s.values) attrValues[s.name] = s.values.map(valueCompletion); } let allElements = [], topElements = []; let byName = Object.create(null); for (let s of eltSpecs) { let attrs = globalAttrs, attrVals = attrValues; if (s.attributes) attrs = attrs.concat(s.attributes.map(s => { if (typeof s == "string") return allAttrs.find(a => a.label == s) || { label: s, type: "property" }; if (s.values) { if (attrVals == attrValues) attrVals = Object.create(attrVals); attrVals[s.name] = s.values.map(valueCompletion); } return attrCompletion(s); })); let elt = new dist_Element(s, attrs, attrVals); byName[elt.name] = elt; allElements.push(elt); if (s.top) topElements.push(elt); } if (!topElements.length) topElements = allElements; for (let i = 0; i < allElements.length; i++) { let s = eltSpecs[i], elt = allElements[i]; if (s.children) { for (let ch of s.children) if (byName[ch]) elt.children.push(byName[ch]); } else { elt.children = allElements; } } return cx => { var _a; let { doc } = cx.state, loc = findLocation(cx.state, cx.pos); if (!loc || (loc.type == "tag" && !cx.explicit)) return null; let { type, from, context } = loc; if (type == "openTag") { let children = topElements; let parentName = elementName$1(doc, context); if (parentName) { let parent = byName[parentName]; children = (parent === null || parent === void 0 ? void 0 : parent.children) || allElements; } return { from, options: children.map(ch => ch.completion), validFor: Identifier }; } else if (type == "closeTag") { let parentName = elementName$1(doc, context); return parentName ? { from, to: cx.pos + (doc.sliceString(cx.pos, cx.pos + 1) == ">" ? 1 : 0), options: [((_a = byName[parentName]) === null || _a === void 0 ? void 0 : _a.closeNameCompletion) || { label: parentName + ">", type: "type" }], validFor: Identifier } : null; } else if (type == "attrName") { let parent = byName[tagName(doc, context)]; return { from, options: (parent === null || parent === void 0 ? void 0 : parent.attrs) || globalAttrs, validFor: Identifier }; } else if (type == "attrValue") { let attr = attrName(doc, context, from); if (!attr) return null; let parent = byName[tagName(doc, context)]; let values = ((parent === null || parent === void 0 ? void 0 : parent.attrValues) || attrValues)[attr]; if (!values || !values.length) return null; return { from, to: cx.pos + (doc.sliceString(cx.pos, cx.pos + 1) == '"' ? 1 : 0), options: values, validFor: /^"[^"]*"?$/ }; } else if (type == "tag") { let parentName = elementName$1(doc, context), parent = byName[parentName]; let closing = [], last = context && context.lastChild; if (parentName && (!last || last.name != "CloseTag" || tagName(doc, last) != parentName)) closing.push(parent ? parent.closeCompletion : { label: "", type: "type", boost: 2 }); let options = closing.concat(((parent === null || parent === void 0 ? void 0 : parent.children) || (context ? allElements : topElements)).map(e => e.openCompletion)); if (context && (parent === null || parent === void 0 ? void 0 : parent.text.length)) { let openTag = context.firstChild; if (openTag.to > cx.pos - 20 && !/\S/.test(cx.state.sliceDoc(openTag.to, cx.pos))) options = options.concat(parent.text); } return { from, options, validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/ }; } else { return null; } }; } /** A language provider based on the [Lezer XML parser](https://github.com/lezer-parser/xml), extended with highlighting and indentation information. */ const xmlLanguage = /*@__PURE__*/dist_index_js_.LRLanguage.define({ name: "xml", parser: /*@__PURE__*/parser.configure({ props: [ /*@__PURE__*/dist_index_js_.indentNodeProp.add({ Element(context) { let closed = /^\s*<\//.test(context.textAfter); return context.lineIndent(context.node.from) + (closed ? 0 : context.unit); }, "OpenTag CloseTag SelfClosingTag"(context) { return context.column(context.node.from) + context.unit; } }), /*@__PURE__*/dist_index_js_.foldNodeProp.add({ Element(subtree) { let first = subtree.firstChild, last = subtree.lastChild; if (!first || first.name != "OpenTag") return null; return { from: first.to, to: last.name == "CloseTag" ? last.from : subtree.to }; } }), /*@__PURE__*/dist_index_js_.bracketMatchingHandle.add({ "OpenTag CloseTag": node => node.getChild("TagName") }) ] }), languageData: { commentTokens: { block: { open: "" } }, indentOnInput: /^\s*<\/$/ } }); /** XML language support. Includes schema-based autocompletion when configured. */ function xml(conf = {}) { let support = [xmlLanguage.data.of({ autocomplete: completeFromSchema(conf.elements || [], conf.attributes || []) })]; if (conf.autoCloseTags !== false) support.push(autoCloseTags); return new dist_index_js_.LanguageSupport(xmlLanguage, support); } function elementName(doc, tree, max = doc.length) { if (!tree) return ""; let tag = tree.firstChild; let name = tag && tag.getChild("TagName"); return name ? doc.sliceString(name.from, Math.min(name.to, max)) : ""; } /** Extension that will automatically insert close tags when a `>` or `/` is typed. */ const autoCloseTags = /*@__PURE__*/view_dist_index_js_.EditorView.inputHandler.of((view, from, to, text, insertTransaction) => { if (view.composing || view.state.readOnly || from != to || (text != ">" && text != "/") || !xmlLanguage.isActiveAt(view.state, from, -1)) return false; let base = insertTransaction(), { state } = base; let closeTags = state.changeByRange(range => { var _a, _b, _c; let { head } = range; let didType = state.doc.sliceString(head - 1, head) == text; let after = (0,dist_index_js_.syntaxTree)(state).resolveInner(head, -1), name; if (didType && text == ">" && after.name == "EndTag") { let tag = after.parent; if (((_b = (_a = tag.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" && (name = elementName(state.doc, tag.parent, head))) { let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0); let insert = ``; return { range, changes: { from: head, to, insert } }; } } else if (didType && text == "/" && after.name == "StartCloseTag") { let base = after.parent; if (after.from == head - 2 && ((_c = base.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" && (name = elementName(state.doc, base, head))) { let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0); let insert = `${name}>`; return { range: state_dist_index_js_.EditorSelection.cursor(head + insert.length, -1), changes: { from: head, to, insert } }; } } return { range }; }); if (closeTags.changes.empty) return false; view.dispatch([ base, state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true }) ]); return true; }); /***/ }) }]); //# sourceMappingURL=4588.46b592131684aa708905.js.map?v=46b592131684aa708905