"use strict";function makeMap(e,t){const n=Object.create(null),a=e.split(",");for(let e=0;e<a.length;e++)n[a[e]]=!0;return t?e=>n[e.toLowerCase()]:e=>n[e]}const no=()=>!1,isNonPhrasingTag=makeMap("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),attribute=/^\s*([^\s"'<>/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,ncname="[a-zA-Z_][\\w\\-\\.]*",qnameCapture=`((?:${ncname}\\:)?${ncname})`,startTagOpen=new RegExp(`^<${qnameCapture}`),startTagClose=/^\s*(\/?)>/,endTag=new RegExp(`^<\\/${qnameCapture}[^>]*>`),doctype=/^<!DOCTYPE [^>]+>/i,comment=/^<!--/,conditionalComment=/^<!\[/;let IS_REGEX_CAPTURING_BROKEN=!1;"x".replace(/x(.)?/g,(e,t)=>{IS_REGEX_CAPTURING_BROKEN=""===t});const isPlainTextElement=makeMap("script,style,textarea",!0),reCache={},decodingMap={"&lt;":"<","&gt;":">","&quot;":'"',"&amp;":"&","&#10;":"\n","&#9;":"\t"},encodedAttr=/&(?:lt|gt|quot|amp);/g,encodedAttrWithNewLines=/&(?:lt|gt|quot|amp|#10|#9);/g,isIgnoreNewlineTag=makeMap("pre,textarea",!0),shouldIgnoreFirstNewline=(e,t)=>e&&isIgnoreNewlineTag(e)&&"\n"===t[0];function decodeAttr(e,t){const n=t?encodedAttrWithNewLines:encodedAttr;return e.replace(n,e=>decodingMap[e])}function parseHTML(e,t){const n=[],a=t.expectHTML,r=t.isUnaryTag||no,o=t.canBeLeftOpenTag||no;let s,c,i=0;for(;e;){if(s=e,c&&isPlainTextElement(c)){let n=0;const a=c.toLowerCase(),r=reCache[a]||(reCache[a]=new RegExp("([\\s\\S]*?)(</"+a+"[^>]*>)","i")),o=e.replace(r,(e,r,o)=>(n=o.length,isPlainTextElement(a)||"noscript"===a||(r=r.replace(/<!--([\s\S]*?)-->/g,"$1").replace(/<!\[CDATA\[([\s\S]*?)]]>/g,"$1")),shouldIgnoreFirstNewline(a,r)&&(r=r.slice(1)),t.chars&&t.chars(r),""));i+=e.length-o.length,e=o,h(a,i-n,i)}else{let n,a,r,o=e.indexOf("<");if(0===o){if(comment.test(e)){const n=e.indexOf("--\x3e");if(n>=0){t.shouldKeepComment&&t.comment(e.substring(4,n)),l(n+3);continue}}if(conditionalComment.test(e)){const t=e.indexOf("]>");if(t>=0){l(t+2);continue}}const n=e.match(doctype);if(n){l(n[0].length);continue}const a=e.match(endTag);if(a){const e=i;l(a[0].length),h(a[1],e,i);continue}const r=d();if(r){g(r),shouldIgnoreFirstNewline(c,e)&&l(1);continue}}if(o>=0){for(a=e.slice(o);!(endTag.test(a)||startTagOpen.test(a)||comment.test(a)||conditionalComment.test(a)||(r=a.indexOf("<",1))<0);)o+=r,a=e.slice(o);n=e.substring(0,o),l(o)}o<0&&(n=e,e=""),t.chars&&n&&t.chars(n)}if(e===s){t.chars&&t.chars(e),"production"!==process.env.NODE_ENV&&!n.length&&t.warn&&t.warn(`Mal-formatted tag at end of template: "${e}"`);break}}function l(t){i+=t,e=e.substring(t)}function d(){const t=e.match(startTagOpen);if(t){const n={tagName:t[1],attrs:[],start:i};let a,r;for(l(t[0].length);!(a=e.match(startTagClose))&&(r=e.match(attribute));)l(r[0].length),n.attrs.push(r);if(a)return n.unarySlash=a[1],l(a[0].length),n.end=i,n}}function g(e){const s=e.tagName,i=e.unarySlash;a&&("p"===c&&isNonPhrasingTag(s)&&h(c),o(s)&&c===s&&h(s));const l=r(s)||!!i,d=e.attrs.length,g=new Array(d);for(let n=0;n<d;n++){const a=e.attrs[n];IS_REGEX_CAPTURING_BROKEN&&-1===a[0].indexOf('""')&&(""===a[3]&&delete a[3],""===a[4]&&delete a[4],""===a[5]&&delete a[5]);const r=a[3]||a[4]||a[5]||"",o="a"===s&&"href"===a[1]?t.shouldDecodeNewlinesForHref:t.shouldDecodeNewlines;g[n]={name:a[1],value:decodeAttr(r,o)}}l||(n.push({tag:s,lowerCasedTag:s.toLowerCase(),attrs:g}),c=s),t.start&&t.start(s,g,l,e.start,e.end)}function h(e,a,r){let o,s;if(null==a&&(a=i),null==r&&(r=i),e&&(s=e.toLowerCase()),e)for(o=n.length-1;o>=0&&n[o].lowerCasedTag!==s;o--);else o=0;if(o>=0){for(let s=n.length-1;s>=o;s--)"production"!==process.env.NODE_ENV&&(s>o||!e)&&t.warn&&t.warn(`tag <${n[s].tag}> has no matching end tag.`),t.end&&t.end(n[s].tag,a,r);n.length=o,c=o&&n[o-1].tag}else"br"===s?t.start&&t.start(e,[],!0,a,r):"p"===s&&(t.start&&t.start(e,[],!1,a,r),t.end&&t.end(e,a,r))}h()}function parse(e){const t={tag:"root",attrs:[],unary:!1,start:0,contentStart:0,contentEnd:e.length,end:e.length,children:[],comments:[]},n=[t];let a=t;return parseHTML(e,{start:function(e,t,r,o,s){const c={tag:e,attrs:t,unary:r,start:o,children:[]};a.children.push(c),r?c.end=s:(c.contentStart=s,n.push(c),a=c)},end:function(e,t,r){n.pop(),a.contentEnd=t,a.end=r,a=n[n.length-1]}}),t}var parserVue=parse;module.exports=parserVue;
