Liferay.Loader.define("liferay!template-web$codemirror@5.65.2/addon/fold/xml-fold",["module","exports","require","../../lib/codemirror"],(function(e,t,n){var i,r=void 0;window;i=function(e){"use strict";var t=e.Pos;function cmp(e,t){return e.line-t.line||e.ch-t.ch}var n="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",i=new RegExp("<(/?)(["+n+"]["+n+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");function Iter(e,t,n,i){this.line=t,this.ch=n,this.cm=e,this.text=e.getLine(t),this.min=i?Math.max(i.from,e.firstLine()):e.firstLine(),this.max=i?Math.min(i.to-1,e.lastLine()):e.lastLine()}function tagAt(e,n){var i=e.cm.getTokenTypeAt(t(e.line,n));return i&&/\btag\b/.test(i)}function nextLine(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function prevLine(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function toTagEnd(e){for(;;){var t=e.text.indexOf(">",e.ch);if(-1==t){if(nextLine(e))continue;return}if(tagAt(e,t+1)){var n=e.text.lastIndexOf("/",t),i=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,i?"selfClose":"regular"}e.ch=t+1}}function toTagStart(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==t){if(prevLine(e))continue;return}if(tagAt(e,t+1)){i.lastIndex=t,e.ch=t;var n=i.exec(e.text);if(n&&n.index==t)return n}else e.ch=t}}function toNextTag(e){for(;;){i.lastIndex=e.ch;var t=i.exec(e.text);if(!t){if(nextLine(e))continue;return}if(tagAt(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}function toPrevTag(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==t){if(prevLine(e))continue;return}if(tagAt(e,t+1)){var n=e.text.lastIndexOf("/",t),i=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,i?"selfClose":"regular"}e.ch=t}}function findMatchingClose(e,n){for(var i=[];;){var r,o=toNextTag(e),f=e.line,a=e.ch-(o?o[0].length:0);if(!o||!(r=toTagEnd(e)))return;if("selfClose"!=r)if(o[1]){for(var l=i.length-1;l>=0;--l)if(i[l]==o[2]){i.length=l;break}if(l<0&&(!n||n==o[2]))return{tag:o[2],from:t(f,a),to:t(e.line,e.ch)}}else i.push(o[2])}}function findMatchingOpen(e,n){for(var i=[];;){var r=toPrevTag(e);if(!r)return;if("selfClose"!=r){var o=e.line,f=e.ch,a=toTagStart(e);if(!a)return;if(a[1])i.push(a[2]);else{for(var l=i.length-1;l>=0;--l)if(i[l]==a[2]){i.length=l;break}if(l<0&&(!n||n==a[2]))return{tag:a[2],from:t(e.line,e.ch),to:t(o,f)}}}else toTagStart(e)}}e.registerHelper("fold","xml",(function(e,n){for(var i=new Iter(e,n.line,0);;){var r=toNextTag(i);if(!r||i.line!=n.line)return;var o=toTagEnd(i);if(!o)return;if(!r[1]&&"selfClose"!=o){var f=t(i.line,i.ch),a=findMatchingClose(i,r[2]);return a&&cmp(a.from,f)>0?{from:f,to:a.from}:null}}})),e.findMatchingTag=function(e,n,i){var r=new Iter(e,n.line,n.ch,i);if(-1!=r.text.indexOf(">")||-1!=r.text.indexOf("<")){var o=toTagEnd(r),f=o&&t(r.line,r.ch),a=o&&toTagStart(r);if(o&&a&&!(cmp(r,n)>0)){var l={from:t(r.line,r.ch),to:f,tag:a[2]};return"selfClose"==o?{open:l,close:null,at:"open"}:a[1]?{open:findMatchingOpen(r,a[2]),close:l,at:"close"}:{open:l,close:findMatchingClose(r=new Iter(e,f.line,f.ch,i),a[2]),at:"open"}}}},e.findEnclosingTag=function(e,t,n,i){for(var r=new Iter(e,t.line,t.ch,n);;){var o=findMatchingOpen(r,i);if(!o)break;var f=findMatchingClose(new Iter(e,t.line,t.ch,n),o.tag);if(f)return{open:o,close:f}}},e.scanForClosingTag=function(e,t,n,i){return findMatchingClose(new Iter(e,t.line,t.ch,i?{from:0,to:i}:null),n)}},"object"==typeof t&&"object"==typeof e?i(n("../../lib/codemirror")):"function"==typeof r&&r.amd?r(["../../lib/codemirror"],i):i(CodeMirror)}));
//# sourceMappingURL=xml-fold.js.map