YUI.add("autocomplete-sources",function(a,e){var t=a.AutoCompleteBase,i=a.Lang,l="_sourceSuccess",_="maxResults",S="resultListLocator";a.mix(t.prototype,{_YQL_SOURCE_REGEX:/^(?:select|set|use)\s+/i,_beforeCreateObjectSource:function(e){return e instanceof a.Node&&"select"===e.get("nodeName").toLowerCase()?this._createSelectSource(e):a.JSONPRequest&&e instanceof a.JSONPRequest?this._createJSONPSource(e):this._createObjectSource(e)},_createIOSource:function(e){var t,c,r,s={type:"io"},o=this;function n(s){var n=s.request;o._cache&&n in o._cache?o[l](o._cache[n],s):(t&&t.isInProgress()&&t.abort(),t=a.io(o._getXHRUrl(e,s),{on:{success:function(e,t){var c;try{c=a.JSON.parse(t.responseText)}catch(r){a.error("JSON parse error",r)}c&&(o._cache&&(o._cache[n]=c),o[l](c,s))}}}))}return s.sendRequest=function(e){c=e,r||(r=!0,a.use("io-base","json-parse",function(){(s.sendRequest=n)(c)}))},s},_createJSONPSource:function(r){var t,c,s={type:"jsonp"},n=this;function o(t){var c=t.request,e=t.query;n._cache&&c in n._cache?n[l](n._cache[c],t):(r._config.on.success=function(e){n._cache&&(n._cache[c]=e),n[l](e,t)},r.send(e))}return s.sendRequest=function(e){t=e,c||(c=!0,a.use("jsonp",function(){r instanceof a.JSONPRequest||(r=new a.JSONPRequest(r,{format:a.bind(n._jsonpFormatter,n)})),(s.sendRequest=o)(t)}))},s},_createSelectSource:function(c){var r=this;return{type:"select",sendRequest:function(e){var t=[];c.get("options").each(function(e){t.push({html:e.get("innerHTML"),index:e.get("index"),node:e,selected:e.get("selected"),text:e.get("text"),value:e.get("value")})}),r[l](t,e)}}},_createStringSource:function(e){return this._YQL_SOURCE_REGEX.test(e)?this._createYQLSource(e):-1!==e.indexOf("{callback}")?this._createJSONPSource(e):this._createIOSource(e)},_createYQLSource:function(n){var t,c,o,u=this,r={type:"yql"};function s(t){var e=t.query,c=u.get("yqlEnv"),r=u.get(_),s=i.sub(n,{maxResults:0<r?r:1e3,request:t.request,query:e});u._cache&&s in u._cache?u[l](u._cache[s],t):(r=function(e){u._cache&&(u._cache[s]=e),u[l](e,t)},e={proto:u.get("yqlProtocol")},o?(o._callback=r,o._opts=e,o._params.q=s,c&&(o._params.env=c)):o=new a.YQLRequest(s,{on:{success:r},allowCache:!1},c?{env:c}:null,e),o.send())}return u.get(S)||u.set(S,u._defaultYQLLocator),r.sendRequest=function(e){t=e,c||(c=!0,a.use("yql",function(){(r.sendRequest=s)(t)}))},r},_defaultYQLLocator:function(e){var t,e=e&&e.query&&e.query.results;return e&&i.isObject(e)?(e=1===(t=a.Object.values(e)||[]).length?t[0]:t,i.isArray(e)||(e=[e])):e=[],e},_getXHRUrl:function(e,t){var c=this.get(_);return t.query!==t.request&&(e+=t.request),i.sub(e,{maxResults:0<c?c:1e3,query:encodeURIComponent(t.query)})},_jsonpFormatter:function(e,t,c){var r=this.get(_),s=this.get("requestTemplate");return s&&(e+=s(c)),i.sub(e,{callback:t,maxResults:0<r?r:1e3,query:encodeURIComponent(c)})}}),a.mix(t.ATTRS,{yqlEnv:{value:null},yqlProtocol:{value:"http"}}),a.mix(t.SOURCE_TYPES,{io:"_createIOSource",jsonp:"_createJSONPSource",object:"_beforeCreateObjectSource",select:"_createSelectSource",string:"_createStringSource",yql:"_createYQLSource"},!0)},"patched-v3.18.4",{optional:["io-base","json-parse","jsonp","yql"],requires:["autocomplete-base"]});