/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
define("dojo/selector/acme",["../dom","../sniff","../_base/array","../_base/lang","../_base/window"],function(Q,u,H,I,B){var R=I.trim,N=H.forEach,S="BackCompat"==B.doc.compatMode,v=!1,C=function(){return!0},O=function(a){a=0<="\x3e~+".indexOf(a.slice(-1))?a+" * ":a+" ";for(var b=function(J,ia){return R(a.slice(J,ia))},c=[],d=-1,e=-1,f=-1,l=-1,g=-1,h=-1,k=-1,n,r="",q="",T,p=0,ja=a.length,m=null,t=null,D=function(){0<=h&&(m.id=b(h,p).replace(/\\/g,""),h=-1);if(0<=k){var J=k==p?null:b(k,p);m[0>"\x3e~+".indexOf(J)?
"tag":"oper"]=J;k=-1}0<=g&&(m.classes.push(b(g+1,p).replace(/\\/g,"")),g=-1)};r=q,q=a.charAt(p),p<ja;p++)"\\"!=r&&(m||(T=p,m={query:null,pseudos:[],attrs:[],classes:[],tag:null,oper:null,id:null,getTag:function(){return v?this.otag:this.tag}},k=p),n?q==n&&(n=null):"'"==q||'"'==q?n=q:0<=d?"]"==q?(t.attr?t.matchFor=b(f||d+1,p):t.attr=b(d+1,p),!(d=t.matchFor)||'"'!=d.charAt(0)&&"'"!=d.charAt(0)||(t.matchFor=d.slice(1,-1)),t.matchFor&&(t.matchFor=t.matchFor.replace(/\\/g,"")),m.attrs.push(t),t=null,d=
f=-1):"\x3d"==q&&(f=0<="|~^$*".indexOf(r)?r:"",t.type=f+q,t.attr=b(d+1,p-f.length),f=p+1):0<=e?")"==q&&(0<=l&&(t.value=b(e+1,p)),l=e=-1):"#"==q?(D(),h=p+1):"."==q?(D(),g=p):":"==q?(D(),l=p):"["==q?(D(),d=p,t={}):"("==q?(0<=l&&(t={name:b(l+1,p),value:null},m.pseudos.push(t)),e=p):" "==q&&r!=q&&(D(),0<=l&&m.pseudos.push({name:b(l+1,p)}),m.loops=m.pseudos.length||m.attrs.length||m.classes.length,m.oquery=m.query=b(T,p),m.otag=m.tag=m.oper?null:m.tag||"*",m.tag&&(m.tag=m.tag.toUpperCase()),c.length&&
c[c.length-1].oper&&(m.infixOper=c.pop(),m.query=m.infixOper.query+" "+m.query),c.push(m),m=null));return c},y=function(a,b){return a?b?function(){return a.apply(window,arguments)&&b.apply(window,arguments)}:a:b},E=function(a,b){var c=b||[];a&&c.push(a);return c},K=function(a){return 1==a.nodeType},z=function(a,b){return a?"class"==b?a.className||"":"for"==b?a.htmlFor||"":"style"==b?a.style.cssText||"":(v?a.getAttribute(b):a.getAttribute(b,2))||"":""},U={"*\x3d":function(a,b){return function(c){return 0<=
z(c,a).indexOf(b)}},"^\x3d":function(a,b){return function(c){return 0==z(c,a).indexOf(b)}},"$\x3d":function(a,b){return function(c){c=" "+z(c,a);var d=c.lastIndexOf(b);return-1<d&&d==c.length-b.length}},"~\x3d":function(a,b){var c=" "+b+" ";return function(d){return 0<=(" "+z(d,a)+" ").indexOf(c)}},"|\x3d":function(a,b){var c=b+"-";return function(d){d=z(d,a);return d==b||0==d.indexOf(c)}},"\x3d":function(a,b){return function(c){return z(c,a)==b}}};I=B.doc.documentElement;var L=!(I.nextElementSibling||
"nextElementSibling"in I),F=L?"nextSibling":"nextElementSibling",ka=L?"previousSibling":"previousElementSibling",G=L?K:C,V=function(a){for(;a=a[ka];)if(G(a))return!1;return!0},W=function(a){for(;a=a[F];)if(G(a))return!1;return!0},M=function(a){var b=a.parentNode;b=7!=b.nodeType?b:b.nextSibling;var c=0,d=b.children||b.childNodes,e=a._i||a.getAttribute("_i")||-1,f=b._l||("undefined"!==typeof b.getAttribute?b.getAttribute("_l"):-1);if(!d)return-1;d=d.length;if(f==d&&0<=e&&0<=f)return e;u("ie")&&"undefined"!==
typeof b.setAttribute?b.setAttribute("_l",d):b._l=d;e=-1;for(b=b.firstElementChild||b.firstChild;b;b=b[F])G(b)&&(u("ie")?b.setAttribute("_i",++c):b._i=++c,a===b&&(e=c));return e},la=function(a){return!(M(a)%2)},ma=function(a){return M(a)%2},X={checked:function(a,b){return function(c){return!("checked"in c?!c.checked:!c.selected)}},disabled:function(a,b){return function(c){return c.disabled}},enabled:function(a,b){return function(c){return!c.disabled}},"first-child":function(){return V},"last-child":function(){return W},
"only-child":function(a,b){return function(c){return V(c)&&W(c)}},empty:function(a,b){return function(c){var d=c.childNodes;for(c=c.childNodes.length-1;0<=c;c--){var e=d[c].nodeType;if(1===e||3==e)return!1}return!0}},contains:function(a,b){var c=b.charAt(0);if('"'==c||"'"==c)b=b.slice(1,-1);return function(d){return 0<=d.innerHTML.indexOf(b)}},not:function(a,b){var c=O(b)[0],d={el:1};"*"!=c.tag&&(d.tag=1);c.classes.length||(d.classes=1);var e=w(c,d);return function(f){return!e(f)}},"nth-child":function(a,
b){var c=parseInt;if("odd"==b)return ma;if("even"==b)return la;if(-1!=b.indexOf("n")){var d=b.split("n",2),e=d[0]?"-"==d[0]?-1:c(d[0]):1,f=d[1]?c(d[1]):0,l=0,g=-1;0<e?0>f?f=f%e&&e+f%e:0<f&&(f>=e&&(l=f-f%e),f%=e):0>e&&(e*=-1,0<f&&(g=f,f%=e));if(0<e)return function(k){k=M(k);return k>=l&&(0>g||k<=g)&&k%e==f};b=f}var h=c(b);return function(k){return M(k)==h}}},na=9>u("ie")||9==u("ie")&&u("quirks")?function(a){var b=a.toLowerCase();"class"==b&&(a="className");return function(c){return v?c.getAttribute(a):
c[a]||c[b]}}:function(a){return function(b){return b&&b.getAttribute&&b.hasAttribute(a)}},w=function(a,b){if(!a)return C;b=b||{};var c=null;"el"in b||(c=y(c,K));"tag"in b||"*"!=a.tag&&(c=y(c,function(d){return d&&(v?d.tagName:d.tagName.toUpperCase())==a.getTag()}));"classes"in b||N(a.classes,function(d,e,f){var l=new RegExp("(?:^|\\s)"+d+"(?:\\s|$)");c=y(c,function(g){return l.test(g.className)});c.count=e});"pseudos"in b||N(a.pseudos,function(d){var e=d.name;X[e]&&(c=y(c,X[e](e,d.value)))});"attrs"in
b||N(a.attrs,function(d){var e,f=d.attr;d.type&&U[d.type]?e=U[d.type](f,d.matchFor):f.length&&(e=na(f));e&&(c=y(c,e))});"id"in b||a.id&&(c=y(c,function(d){return!!d&&d.id==a.id}));c||"default"in b||(c=C);return c},oa=function(a){return function(b,c,d){for(;b=b[F];)if(!L||K(b)){d&&!A(b,d)||!a(b)||c.push(b);break}return c}},pa=function(a){return function(b,c,d){for(b=b[F];b;){if(G(b)){if(d&&!A(b,d))break;a(b)&&c.push(b)}b=b[F]}return c}},Y=function(a,b){var c=function(d){var e=[];try{e=Array.prototype.slice.call(d)}catch(g){for(var f=
0,l=d.length;f<l;f++)e.push(d[f])}return e};a=a||C;return function(d,e,f){var l=0,g=[];g=c(d.children||d.childNodes);for(b&&H.forEach(g,function(h){1===h.nodeType&&(g=g.concat(c(h.getElementsByTagName("*"))))});d=g[l++];)G(d)&&(!f||A(d,f))&&a(d,l)&&e.push(d);return e}},Z=function(a,b){for(var c=a.parentNode;c&&c!=b;)c=c.parentNode;return!!c},aa={},ba=function(a){var b=aa[a.query];if(b)return b;var c=a.infixOper;c=c?c.oper:"";var d=w(a,{el:1}),e="*"==a.tag,f=B.doc.getElementsByClassName;if(c)f={el:1},
e&&(f.tag=1),d=w(a,f),"+"==c?b=oa(d):"~"==c?b=pa(d):"\x3e"==c&&(b=Y(d));else if(a.id)d=!a.loops&&e?C:w(a,{el:1,id:1}),b=function(g,h){var k=Q.byId(a.id,g.ownerDocument||g);g.ownerDocument&&!Z(g,g.ownerDocument)&&H.some(11===g.nodeType?g.childNodes:[g],function(n){n=Y(function(r){return r.id===a.id},!0)(n,[]);if(n.length)return k=n[0],!1});if(k&&d(k)&&(9==g.nodeType||Z(k,g)))return E(k,h)};else if(f&&/\{\s*\[native code\]\s*\}/.test(String(f))&&a.classes.length&&!S){d=w(a,{el:1,classes:1,id:1});var l=
a.classes.join(" ");b=function(g,h,k){h=E(0,h);for(var n,r=0,q=g.getElementsByClassName(l);n=q[r++];)d(n,g)&&A(n,k)&&h.push(n);return h}}else e||a.loops?(d=w(a,{el:1,tag:1,id:1}),b=function(g,h,k){h=E(0,h);for(var n,r=0,q=(n=a.getTag())?g.getElementsByTagName(n):[];n=q[r++];)d(n,g)&&A(n,k)&&h.push(n);return h}):b=function(g,h,k){h=E(0,h);var n=0,r=a.getTag();for(r=r?g.getElementsByTagName(r):[];g=r[n++];)A(g,k)&&h.push(g);return h};return aa[a.query]=b},ca={},da={},ea=function(a){var b=O(R(a));if(1==
b.length){var c=ba(b[0]);return function(d){if(d=c(d,[]))d.nozip=!0;return d}}return function(d){d=E(d);for(var e,f,l=b.length,g,h,k=0;k<l;k++){h=[];e=b[k];f=d.length-1;0<f&&(g={},h.nozip=!0);f=ba(e);for(var n=0;e=d[n];n++)f(e,h,g);if(!h.length)break;d=h}return h}},qa=u("ie")?"commentStrip":"nozip",fa=!!B.doc.querySelectorAll,ra=/\\[>~+]|n\+\d|([^ \\])?([>~+])([^ =])?/g,sa=function(a,b,c,d){return c?(b?b+" ":"")+c+(d?" "+d:""):a},ta=/([^[]*)([^\]]*])?/g,ua=function(a,b,c){return b.replace(ra,sa)+
(c||"")},ha=function(a,b){a=a.replace(ta,ua);if(fa){var c=da[a];if(c&&!b)return c}if(c=ca[a])return c;c=a.charAt(0);var d=-1==a.indexOf(" ");0<=a.indexOf("#")&&d&&(b=!0);if(!fa||b||-1!="\x3e~+".indexOf(c)||u("ie")&&-1!=a.indexOf(":")||S&&0<=a.indexOf(".")||-1!=a.indexOf(":contains")||-1!=a.indexOf(":checked")||-1!=a.indexOf("|\x3d")){var e=a.match(/([^\s,](?:"(?:\\.|[^"])+"|'(?:\\.|[^'])+'|[^,])*)/g);return ca[a]=2>e.length?ea(a):function(l){for(var g=0,h=[],k;k=e[g++];)h=h.concat(ea(k)(l));return h}}var f=
0<="\x3e~+".indexOf(a.charAt(a.length-1))?a+" *":a;return da[a]=function(l){if(9==l.nodeType||d)try{var g=l.querySelectorAll(f);g[qa]=!0;return g}catch(h){}return ha(a,!0)(l)}},x=0,va=u("ie")?function(a){return v?a.getAttribute("_uid")||a.setAttribute("_uid",++x)||x:a.uniqueID}:function(a){return a._uid||(a._uid=++x)},A=function(a,b){if(!b)return 1;var c=va(a);return b[c]?0:b[c]=1},wa=function(a){if(a&&a.nozip)return a;if(!a||!a.length)return[];if(2>a.length)return[a[0]];var b=[];x++;var c,d;if(u("ie")&&
v){var e=x+"";for(c=0;c<a.length;c++)(d=a[c])&&d.getAttribute("_zipIdx")!=e&&(b.push(d),d.setAttribute("_zipIdx",e))}else if(u("ie")&&a.commentStrip)try{for(c=0;c<a.length;c++)(d=a[c])&&K(d)&&b.push(d)}catch(f){}else for(c=0;c<a.length;c++)(d=a[c])&&d._zipIdx!=x&&(b.push(d),d._zipIdx=x);return b},P=function(a,b){b=b||B.doc;v="div"===(b.ownerDocument||b).createElement("div").tagName;var c=ha(a)(b);return c&&c.nozip?c:wa(c)};P.filter=function(a,b,c){var d=[],e=O(b);e=1!=e.length||/[^\w#\.]/.test(b)?
function(g){return-1!=H.indexOf(P(b,Q.byId(c)),g)}:w(e[0]);for(var f=0,l;l=a[f];f++)e(l)&&d.push(l);return d};return P});