!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}((function(t){"use strict";var e=t.Pos;function r(t,e,r){return r?t.indexOf(e)>=0:0==t.lastIndexOf(e,0)}t.registerHelper("hint","xml",(function(n,i){var s=i&&i.schemaInfo,a=i&&i.quoteChar||'"',o=i&&i.matchInMiddle;if(s){var l=n.getCursor(),f=n.getTokenAt(l);if(f.end>l.ch&&(f.end=l.ch,f.string=f.string.slice(0,l.ch-f.start)),(x=t.innerMode(n.getMode(),f.state)).mode.xmlCurrentTag){var g,c,h=[],u=!1,d=/\btag\b/.test(f.type)&&!/>$/.test(f.string),p=d&&/^\w/.test(f.string);if(p){var m=n.getLine(l.line).slice(Math.max(0,f.start-2),f.start),v=/<\/$/.test(m)?"close":/<$/.test(m)?"open":null;v&&(c=f.start-("close"==v?2:1))}else d&&"<"==f.string?v="open":d&&"</"==f.string&&(v="close");var y=x.mode.xmlCurrentTag(x.state);if(!d&&!y||v){p&&(g=f.string),u=v;var x,C=x.mode.xmlCurrentContext?x.mode.xmlCurrentContext(x.state):[],b=(x=C.length&&C[C.length-1])&&s[x],O=x?b&&b.children:s["!top"];if(O&&"close"!=v)for(var w=0;w<O.length;++w)g&&!r(O[w],g,o)||h.push("<"+O[w]);else if("close"!=v)for(var A in s)!s.hasOwnProperty(A)||"!top"==A||"!attrs"==A||g&&!r(A,g,o)||h.push("<"+A);x&&(!g||"close"==v&&r(x,g,o))&&h.push("</"+x+">")}else{var M=(b=y&&s[y.name])&&b.attrs,P=s["!attrs"];if(!M&&!P)return;if(M){if(P){var $={};for(var I in P)P.hasOwnProperty(I)&&($[I]=P[I]);for(var I in M)M.hasOwnProperty(I)&&($[I]=M[I]);M=$}}else M=P;if("string"==f.type||"="==f.string){var T,j=(m=n.getRange(e(l.line,Math.max(0,l.ch-60)),e(l.line,"string"==f.type?f.start:f.end))).match(/([^\s\u00a0=<>\"\']+)=$/);if(!j||!M.hasOwnProperty(j[1])||!(T=M[j[1]]))return;if("function"==typeof T&&(T=T.call(this,n)),"string"==f.type){g=f.string;var q=0;/['"]/.test(f.string.charAt(0))&&(a=f.string.charAt(0),g=f.string.slice(1),q++);var L=f.string.length;if(/['"]/.test(f.string.charAt(L-1))&&(a=f.string.charAt(L-1),g=f.string.substr(q,L-2)),q){var k=n.getLine(l.line);k.length>f.end&&k.charAt(f.end)==a&&f.end++}u=!0}var H=function(t){if(t)for(var e=0;e<t.length;++e)g&&!r(t[e],g,o)||h.push(a+t[e]+a);return z()};return T&&T.then?T.then(H):H(T)}for(var R in"attribute"==f.type&&(g=f.string,u=!0),M)!M.hasOwnProperty(R)||g&&!r(R,g,o)||h.push(R)}return z()}}function z(){return{list:h,from:u?e(l.line,null==c?f.start:c):l,to:u?e(l.line,f.end):l}}}))}));