var AutoSuggest;(function(n){var t;(function(t){function l(n){return n.toLocaleLowerCase().replace(p,"").trim()}function h(n,t,i,r,u){if(!n)return i;if(typeof n!="string")try{return{content:URL.createObjectURL(n),type:0,bgColor:r}}catch(f){return SharedLogHelper.LogError("convertToHtmlImage "+t,u,f),i}else return{content:n,type:0,bgColor:r}}function o(n,t){var i=parseInt(n,16),r=i>>16&255,u=i>>8&255,f=i&255;return"rgba("+r+","+u+","+f+","+t+")"}function a(n){switch(n){case 0:return 0;case 7:return 2;case 8:return 6;case 6:return 5;case 4:return 3;case 1:return 1;case 5:return 4;default:return 255}}var i,e,r,u,f,p=/[\.,:;?!¿¡]/g,s,c,v,y;t.SearchBoxOnTopFeatureName="SearchBoxOnTop";s="scopesBottom";c="sbot";t.toIcon=h;v={"action://Help/Launch":sa_config.htmlHelpCanvas?"Help":"SpeechHelp","ms-cortana://navigate/Settings":"Settings","ms-cortana://navigate/Notebook":"Notebook"};y=function(){function y(o){var c=this;this._config=o;this._queryParamsCache={};this._modifierKeyState={altKey:!1,ctrlKey:!1,shiftKey:!1};this._appVisibleEventHandlers=[];this._shownEventHandlers=[];this._conversationStartEventHandlers=[];this._dismissedEventHandlers=[];this._appHiddenEventHandlers=[];this._searchBoxGotFocusEventHandlers=[];this._searchBoxLostFocusEventHandlers=[];this._onSubmitHandlers=[];this._queryChangedHandlers=[];this._keyDownHandlers=[];this._keyUpHandlers=[];this._state=0;this._lastActiveElement=n.getCurrentActiveElement();this.usedImpressionIds={};this.getBrowserIcon=function(n,t){return c._browserIconCache(n,t)};this.getEdgeIcon=function(n,t){return c._edgeIconCache(n,t)};this._suggestionsContainer=_ge("suggestionsList");this._qfContainer=_ge("container");o.scopesOrder.length>0&&o.scopeBarAtBottom&&this._qfContainer.classList.add(s);n.safeExecute(function(){i=SearchAppWrapper.CortanaApp;e=i.queryFormulationView;r=i.launcher;u=i.searchBox;f=n.Service.QueryParams;c._currentCVID=n.cleanGuid(c.createGuid());c._randomPrivacyNumber=c.getNewPrivacyNumber();var o=e.searchHistory;o?o.addEventListener("cleardevicehistoryrequested",function(){n.log("clearDeviceHistoryRequested");var t=function(t){return n.safeExecute(function(){n.log(t?"clearDeviceHistory succeded":"clearDeviceHistory failed");o.signalClearDeviceHistoryCompleted(t)},"signalClearDeviceHistoryCompleted")};c._clearStorageRequestedEventHandler?(n.log("calling clearDeviceHistoryRequested handler"),n.safeExecute(function(){return c._clearStorageRequestedEventHandler(t),!0},"clearDeviceHistoryRequested")||t(!1)):(n.log("no handler for clearDeviceHistoryRequested"),t(!1))}):n.log("searchHistory not available");i.addEventListener("statechanged",function(n){return c.updateState(c._state,n.newState,!1)});u.addEventListener("querytextchanged",function(n){c.updateState(c._state,2,!0);c._queryToIgnoreOnQueryTextChangedEvent&&n.queryText==c._queryToIgnoreOnQueryTextChangedEvent||(c._queryToIgnoreOnQueryTextChangedEvent=null,c.callQueryChangedHandlers(n,!1,n.impressionId))});u.addEventListener("keydown",function(i){var u=i.keyCode,f={shiftKey:i.isShiftKeyPressed,ctrlKey:i.isControlKeyPressed,altKey:!1},r;c._config.searchBoxFocusEvents||(r=n.getCurrentActiveElement(),r&&!t.isBodyOrSuggestion(r)&&r.blur());c._keyDownHandlers.forEach(function(t){return n.safeExecute(function(){return t(u,f)},"keyDown")})});sj_b.addEventListener("keydown",function(t){if(t.target){var i=_ge("fbpgdg");if(i&&i.contains(t.target))return}(n.contains([38,40],t.keyCode)&&sj_pd(t),t.keyCode==13&&c.isRequestFocusAvailable())||c._keyDownHandlers.forEach(function(i){return n.safeExecute(function(){return i(t.keyCode,t)},"keyDown")})});u.addEventListener("keyup",function(t){var i=t.keyCode,r={shiftKey:t.isShiftKeyPressed,ctrlKey:t.isControlKeyPressed,altKey:!1};c._keyUpHandlers.forEach(function(t){return n.safeExecute(function(){return t(i,r)},"keyUp")})});sj_b.addEventListener("keyup",function(t){c._keyUpHandlers.forEach(function(i){return n.safeExecute(function(){return i(t.keyCode,t)},"keyUp")})});u.addEventListener("gotfocus",function(){c._searchBoxGotFocusEventHandlers.forEach(function(t){return n.safeExecute(function(){return t()},"gotfocus")})});u.addEventListener("lostfocus",function(){c._searchBoxLostFocusEventHandlers.forEach(function(t){return n.safeExecute(function(){return t()},"lostfocus")})})},"WindowsHostInit");this.bindAppVisible(function(){return c.initCachedVariables(!0)});this.bindShown(function(){c.initCachedVariables(!1);sj_evt.fire("ajax.threshold.pageStart",(new Date).getTime());var t=c.getNewConversationId();c._currentCVID!=t&&(c._currentCVID=t,c._randomPrivacyNumber=c.getNewPrivacyNumber(),c._conversationStartEventHandlers.forEach(function(t){return n.safeExecute(function(){return t()},"conversationStart")}));c._lastKeyWasEnter=!1;c._lastActiveElement=n.getCurrentActiveElement()});this.bindDismissed(function(){sj_evt.fire("WindowsFeedback.Form.Hide");sj_evt.fire("threshold.pageUnload");c.cleanupCachedVariables(!1)});this.bindAppHidden(function(){c.cleanupCachedVariables(!0);c.uploadClientErrorLog()});this.bindKeyDown(function(t,i){c._modifierKeyState=i;c._lastKeyRemovedAutocompletion=c._isQueryAutocompleted&&n.isDeletionKey(t,i);c._isQueryAutocompleted=!1;var r=n.getCurrentActiveElement(),u=t==13;u&&(!c._lastKeyWasEnter||r!=c._lastActiveElement)&&(c._onSubmitHandlers.forEach(function(r){return n.safeExecute(function(){return r(t,i)},"onSubmit handlers")}),r&&r.blur());c._lastKeyWasEnter=u;c._lastActiveElement=r});this.bindKeyUp(function(n){switch(n){case 16:c._modifierKeyState.shiftKey=!1;break;case 17:c._modifierKeyState.ctrlKey=!1}});typeof PageDebug=="undefined"&&(PageDebug={});this.setPageDebugCanvas();t.isMobileCache&&(this._browserIconCache=function(n,t){return t(h(_w.EdgeIcon,"browserIconMobile"))});this.checkFlightExpiration();!t.isMobileCache&&this._config.redirectSearchLaunchPolicy&&i.setDefaultUriLaunchPolicy&&i.setDefaultUriLaunchPolicy(1)}return y.prototype.uploadClientErrorLog=function(){var e,r,t,f,u;if(i.getFlightingLogsAndDelete)for(e=n.safeExecute(function(){return i.getFlightingLogsAndDelete()},"getFlightingLogsAndDelete",""),r=e.split("\r\n"),t=0;t0&&(this._headersCache["X-BM-ClientFeatures"]=o.join()),ThresholdUtilities.setBodyLangAttributes(i.uiLanguage),this.getFeatureEnabled(t.SearchBoxOnTopFeatureName).featureEnabled?(this._qfContainer.classList.add(c),this._config.scopesOrder.length>0&&!this._config.scopeBarAtBottom&&this._qfContainer.classList.add(s)):(this._qfContainer.classList.remove(c),this._config.scopesOrder.length>0&&!this._config.scopeBarAtBottom&&this._qfContainer.classList.remove(s)))},y.prototype.getAccentColor=function(){return"#"+this._accentColor},y.prototype.applyAccentColor=function(t){var u,f="accent-style",r=_ge(f),i;r||(r=_d.createElement("style"),r.setAttribute("id",f),r.type="text/css",u=!0);i=".icon svg { fill: {0} } .gridLayout .suggestion.sa_hv, .gridLayout .suggestion.sa_hv:hover { border-color: {1}; }";n.isHighContrastEnabled()||(i+=".action, .accentColor, .groupAnnotations { color: {0}; } .sa_hv, .sa_hv:hover, .sa_hv.selectable:active { background-color: {1}; }",i+=".jumpList:not(.sa_hv) { background: {2}; }");this._config.scopesCarousel?(i+="#root .selectedScope, #root .selectedScope:hover { color: {0}; border-bottom-color: {0}; }",i+="#pos1Button + label:hover, #pos1Button:checked + label { color: {0}; }",i+="#pos2Button + label:hover, #pos2Button:checked + label { color: {0}; }",i+="#pos3Button + label:hover, #pos3Button:checked + label { color: {0}; }"):n.isHighContrastEnabled()||(i+="#root .selectedScope { background-color: {3}; }",i+="#root .selectedScope:hover { background-color: {4}; }",i+="#root .selectedScope:active { background-color: {5}; }");sa_config.showMyStuffLinks||(i+=" .toggleSwitch input:checked + label::before { background-color: {0}; border-color: {0}; }");r.innerHTML=n.formatString(i,["#"+t,o(t,.3),o(t,.1),o(t,.4),o(t,.6),o(t,.7)]);u&&_d.head.appendChild(r)},y.prototype.createGuid=function(){return n.safeExecute(function(){return i.createGuid()},"createGuid","")},y.prototype.getLocString=function(n){var t=this._locStrings?this._locStrings[n]:this._enUsLocStrings[n];return n=="InSourceLabel"&&(t+="{0}"),t},y.prototype.getEnUsLocString=function(n){var t=this._enUsLocStrings[n];return n=="InSourceLabel"&&(t+="{0}"),t},y.prototype.getImpressionGuid=function(){return n.cleanGuid(this._currentRawImpressionId)},y.prototype.getConversationId=function(){return this._currentCVID},y.prototype.getPrivacyNumber=function(){return this._randomPrivacyNumber},y.prototype.getNewConversationId=function(){var t=n.cleanGuid(n.safeExecute(function(){return e.perfMetrics.conversationId},"conversationId"));return t||(SharedLogHelper.LogWarning("getNewConversationId",null,new Error("Client returned null conversation ID")),t=n.cleanGuid(this.createGuid())),t},y.prototype.getNewPrivacyNumber=function(){return Math.floor(Math.random()*Number.MAX_VALUE)},y.prototype.bindQueryChangedOrInitialized=function(n){this._queryChangedHandlers.push(n)},y.prototype.bindOnSubmit=function(n){this._onSubmitHandlers.push(n)},y.prototype.bindSearchBoxGotFocus=function(n){this._searchBoxGotFocusEventHandlers.push(n)},y.prototype.bindSearchBoxLostFocus=function(n){this._searchBoxLostFocusEventHandlers.push(n)},y.prototype.getModifierKeyState=function(){return this._modifierKeyState},y.prototype.checkFlightExpiration=function(){if(this._config.aC_fe){var n=this.formatDateYYYYMMDD(new Date),r=this._config.aC_fe;n>r&&t.Promise.safeChain("repopulateAppCacheAsync",function(){return i.repopulateAppCacheAsync()})}},y.prototype.formatDateYYYYMMDD=function(n){var r=n.getFullYear().toString(),t=(n.getMonth()+1).toString(),i=n.getDate().toString();return r+(t[1]?t:"0"+t[0])+(i[1]?i:"0"+i[0])},y.prototype.bindAppVisible=function(n){this._appVisibleEventHandlers.push(n)},y.prototype.bindShown=function(n){this._shownEventHandlers.push(n)},y.prototype.bindConversationStart=function(n){this._conversationStartEventHandlers.push(n)},y.prototype.bindDismissed=function(n){this._dismissedEventHandlers.push(n)},y.prototype.bindAppHidden=function(n){this._appHiddenEventHandlers.push(n)},y.prototype.bindKeyDown=function(n){this._keyDownHandlers.push(n)},y.prototype.bindKeyUp=function(n){this._keyUpHandlers.push(n)},y.prototype.getQuery=function(){return this.getStructuredQuery(u.getQueryText(),this._previousQuery)},y.prototype.setQuery=function(t,r,f){var e=this;t=t||r?t:this._currentQuery?this._currentQuery.originalQuery:null;r||f||(this._queryToIgnoreOnQueryTextChangedEvent=t);this._currentQuery&&this._currentQuery.taskFrame&&t==this._currentQuery.originalQuery&&n.safeExecute(function(){return i.searchResultsView.setTaskFrame(t,e._currentQuery.taskFrame)},"restore task frame");n.safeExecute(function(){return u.setQueryText(t,r)},"setQueryText");(r&&this._config.triggerQueryTextChangedEventsOnSetQuery||f)&&sb_st(function(){return n.safeExecute(function(){return e.callQueryChangedHandlers({queryText:t,cursorPosition:t.length},f)},"triggerQueryTextChangedEvent")},0)},y.prototype.setAutoCompleteQueryText=function(t){var i=this;n.safeExecute(function(){return u.setAutoCompleteQueryText(t,i._currentRawImpressionId)},"setAutoCompleteQueryText");this._isQueryAutocompleted=!0},y.prototype.launchUrl=function(n){t.Promise.safeChain("launchUrl",function(){return r.launchUriAsync(n)})},y.prototype.launchUrlInEdge=function(n){t.Promise.safeChain("launchUrlInEdge",function(){var t=r.createUriLaunchOptions();return t.launchPolicy=2,r.launchUriAsync(n,t)})},y.prototype.matchesVcd=function(n){var t,r,i,u,f,e;if(this._vcdKeywords&&n&&(t=l(n),t))for(r in this._vcdKeywords)if(this._vcdKeywords.hasOwnProperty(r)&&(i=l(r),i&&(u=t.indexOf(i),u>=0&&((f=this._vcdKeywords[r],f&1)||f&2&&u==0||f&4&&(u==t.length-i.length||(e=t.lastIndexOf(i),e==t.length-i.length))))))return!0;return!1},y.prototype.isRequestFocusAvailable=function(){return!!u.requestFocus},y.prototype.setFocusInSearchBox=function(t){if(this.isRequestFocusAvailable()){n.safeExecute(function(){return u.requestFocus()},"requestFocus",null,t);var i=n.getCurrentActiveElement();i&&i.blur()}},y.prototype.getFeatureEnabled=function(n){return i.getFeatureEnabled?i.getFeatureEnabled(n):{validFeature:!1,featureEnabled:!1}},y.prototype.getFeatureDWORD=function(n){return i.getFeatureDWORD?i.getFeatureDWORD(n):{validFeature:!1,featureValue:0}},y.prototype.getFeatureString=function(n){return i.getFeatureString?i.getFeatureString(n):{validFeature:!1,featureValue:""}},y.prototype.launchInApp=function(i,r,f){this.setQuery(r,!1,!1);n.safeExecute(f,i);t.isMobileCache&&u.requestUnfocus&&n.safeExecute(function(){return u.requestUnfocus()},"requestUnfocus",null,i)},y.prototype.launchSearch=function(n,u,f){var e=this;f?this.launchInApp("launchVoiceFlow",n,function(){return r.launchRAFAsync(n,e.getFormCode(),e.getInstrumentationParameters())}):t.isMobileCache?this.launchInApp("launchSearch",n,function(){var t=r.createSearchLaunchOptions();t.searchQuery=n;t.mode=1;t.uriContext=u.substr(u.indexOf("&")+1);r.launchSearchAsync(t)}):this._config.redirectSearchLaunchPolicy&&!i.setDefaultUriLaunchPolicy?t.Promise.safeChain("launchSearchInEdge",function(){return r.launchUriAsync("microsoft-edge:"+u)}):t.Promise.safeChain("launchSearch",function(){return r.launchUriAsync(u)})},y.prototype.launchMyStuff=function(i,u,f,e,o){var p=this,s,c,h,l,y,v;if(_w.localStorage&&e&&e.length>0){s=[];for(h in o)c=o[h],c.type!=t.SyntheticQSCodes.TopSearchMyStuff&&s.push(a(t.getGroupType(c)));for(h in e)l=a(e[h]),n.contains(s,l)||s.push(l);y={Query:i,SectionOrder:s};n.safeExecute(function(){return _w.localStorage.QFGroupOrder=JSON.stringify(y)},"save group order for myStuff")}v=f||this.getFormCode();this.launchInApp("launchMyStuff",i,function(){return r.launchMyStuffAsync(i,u,null,v,p.getInstrumentationParameters(v))})},y.prototype.launchCat1=function(n,t,u){var e=this,f=v[t];f?this.launchInApp("launch"+f,n,function(){return i.launchExperienceByName(f,null)}):this.launchInApp("launchCat1",n,function(){return r.launchCat1Async(n,u,e.getInstrumentationParameters())})},y.prototype.launchCat1MyStuff=function(n,t){var i=this;this.launchInApp("launchCat1MyStuff",n,function(){return r.launchMyStuffTaskFrameAsync(n,i.getFormCode(),t,i.getInstrumentationParameters())})},y.prototype.launchCat2or3a=function(n,t){var i=this;this.launchInApp("launchCat2",n,function(){return r.launchCat2Async(n,i.getFormCode(),t,i.getInstrumentationParameters())})},y.prototype.launchStorePdp=function(n){var i="ms-windows-store://pdp/?ProductId="+encodeURIComponent(n)+"&ocid="+encodeURIComponent(this._config.storeHandoffTag);t.Promise.safeChain("launchStorePdp",function(){return r.launchUriAsync(i)})},y.prototype.launchStoreSearch=function(n){var i="ms-windows-store:search?query="+encodeURIComponent(n);t.Promise.safeChain("launchStoreSearch",function(){return r.launchUriAsync(i)})},y.prototype.launchFolder=function(t){n.safeExecute(function(){return r.startLaunchFolder(t)},"launchFolder")},y.prototype.launchDeviceItem=function(n,i){t.Promise.safeChain("launchDeviceItem",function(){return r.launchSearchItemAsync(n)},null,null,null,i)},y.prototype.launchAppItem=function(i,u,f){n.safeExecute(function(){var n;f&&(n=r.createAppLaunchOptions(),n.appContext=f);t.Promise.safeChain("launchAppItem",function(){return r.launchSearchItemAsync(i,n)},null,null,null,u)},"launchAppItem",null,u)},y.prototype.tryLaunchWebContent=function(n,t){var u=!1,i;return r.launchWebContent&&(i=r.createWebContentLaunchOptions(),i.uri=n,t&&(i.searchBoxQueryText=t),this.launchInApp("launchWebContent",null,function(){return r.launchWebContent(i)}),u=!0),u},y.prototype.getCustomUrlParameters=function(n){var i=this._queryParamsCache,r=n.scope;return r==0?delete i[f.Scope]:i[f.Scope]=t.Scope[r].toLowerCase(),i},y.prototype.getCustomHeaders=function(){return this._headersCache},y.prototype.reloadWebView=function(){t.Promise.safeChain("reloadWebViewAsync",function(){return i.reloadWebViewAsync()})},y.prototype.getFormCode=function(){return"WNSGPH"},y}();t.Host=y})(t=n.Windows||(n.Windows={}))})(AutoSuggest||(AutoSuggest={}))