var a;function u(e,t){return a=t,e}function l(e,t){var n=e.next();if(n=="<"&&e.eat("!")){if(e.eatWhile(/[\-]/))return t.tokenize=s,s(e,t);if(e.eatWhile(/[\w]/))return u("keyword","doindent")}else{if(n=="<"&&e.eat("?"))return t.tokenize=o("meta","?>"),u("meta",n);if(n=="#"&&e.eatWhile(/[\w]/))return u("atom","tag");if(n=="|")return u("keyword","separator");if(n.match(/[\(\)\[\]\-\.,\+\?>]/))return u(null,n);if(n.match(/[\[\]]/))return u("rule",n);if(n=='"'||n=="'")return t.tokenize=c(n),t.tokenize(e,t);if(e.eatWhile(/[a-zA-Z\?\+\d]/)){var r=e.current();return r.substr(r.length-1,r.length).match(/\?|\+/)!==null&&e.backUp(1),u("tag","tag")}else return n=="%"||n=="*"?u("number","number"):(e.eatWhile(/[\w\\\-_%.{,]/),u(null,null))}}function s(e,t){for(var n=0,r;(r=e.next())!=null;){if(n>=2&&r==">"){t.tokenize=l;break}n=r=="-"?n+1:0}return u("comment","comment")}function c(e){return function(t,n){for(var r=!1,i;(i=t.next())!=null;){if(i==e&&!r){n.tokenize=l;break}r=!r&&i=="\\"}return u("string","tag")}}function o(e,t){return function(n,r){for(;!n.eol();){if(n.match(t)){r.tokenize=l;break}n.next()}return e}}const k={name:"dtd",startState:function(){return{tokenize:l,baseIndent:0,stack:[]}},token:function(e,t){if(e.eatSpace())return null;var n=t.tokenize(e,t),r=t.stack[t.stack.length-1];return e.current()=="["||a==="doindent"||a=="["?t.stack.push("rule"):a==="endtag"?t.stack[t.stack.length-1]="endtag":e.current()=="]"||a=="]"||a==">"&&r=="rule"?t.stack.pop():a=="["&&t.stack.push("["),n},indent:function(e,t,n){var r=e.stack.length;return t.charAt(0)==="]"?r--:t.substr(t.length-1,t.length)===">"&&(t.substr(0,1)==="<"||a=="doindent"&&t.length>1||(a=="doindent"?r--:a==">"&&t.length>1||a=="tag"&&t!==">"||(a=="tag"&&e.stack[e.stack.length-1]=="rule"?r--:a=="tag"?r++:t===">"&&e.stack[e.stack.length-1]=="rule"&&a===">"?r--:t===">"&&e.stack[e.stack.length-1]=="rule"||(t.substr(0,1)!=="<"&&t.substr(0,1)===">"?--r:t===">"||--r))),(a==null||a=="]")&&r--),e.baseIndent+r*n.unit},languageData:{indentOnInput:/^\s*[\]>]$/}};export{k as t};
