var __extends=this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);r.prototype=t.prototype;n.prototype=new r},AutoSuggest;(function(n){var i=function(){function t(n,t){t===void 0&&(t=0);this._config=n;this._delay=t}return t.prototype.getDataSource=function(){return undefined},t.prototype.getBaseUrl=function(){return undefined},t.prototype.getPostBody=function(){return undefined},t.prototype.onBeforeFetchUrl=function(){},t.prototype.fetch=function(t,i,r,u,f,e,o,s){var c=this,h,l,a;if(n.isDataSourceEnabled(this.getDataSource(),t,this._config)){if(h=decodeURIComponent(this.getBaseUrl())+encodeURIComponent(t.queryToFetch.toLowerCase()),e)for(l in e)h+="&"+l+"="+e[l];if(a=this.getPostBody(t),this._timer&&(sb_ct(this._timer),this._timer=null),this._delay>0&&!t.isFormulatedQuery)this._timer=sb_st(function(){return n.safeExecute(function(){sb_ct(c._timer);c._timer=null;c.onBeforeFetchUrl(r,h);c.fetchUrl(h,o,a,i,u,f,s)},"fetchDelay")},this._delay);else{this.onBeforeFetchUrl(r,h);this.fetchUrl(h,o,a,i,u,f,s)}}},t.prototype.fetchUrl=function(t,i,r,u,f,e,o){var h=this,s=sj_gx(),c;if(s.open(r?"POST":"GET",t,!0),i)for(c in i)s.setRequestHeader(c,i[c]);s.onreadystatechange=function(){var r,i;e()&&s.readyState==4&&(s.onreadystatechange=function(){},u&&((s.status==200||s.status===401||s.status===403)&&(i=s.responseText,h._config.th&&i&&(i=i.replace(new RegExp("","gm"),"")),r=i?n.safeExecute(function(){return JSON.parse(i)},"parseWebProviderResponse",null,i.substr(0,200)):null),u(h.getDataSource(),r,null)),o&&s.status!=200&&SharedLogHelper.LogError("fetchUrl",h._config.th?null:"url: "+t,"statusCode: "+s.status))};s.withCredentials!==undefined&&(s.withCredentials=!0);s.send(r)},t}(),t,r;n.JsonDataProvider=i;t=function(n){function t(t){n.call(this,t)}return __extends(t,n),t.prototype.getResources=function(){return undefined},t.prototype.fetch=function(t,i,r,u,f,e,o){var s=this,h=function(n,t,r){var u,f,e,o;if(t&&(u=s.getResources(t),u)){if(s._downloadedStylesResources)for(f in u.Styles)for(e in u.Styles[f])s._downloadedStylesResources[f][e]?delete u.Styles[f][e]:s._downloadedStylesResources[f][e]=u.Styles[f][e];else s._downloadedStylesResources=u.Styles;o={Styles:u.Styles,Scripts:null};JsonInject.WriteHeadAndBeforeContentResources(o)}i(n,t,r)};n.prototype.fetch.call(this,t,h,r,u,f,e,o)},t}(i);n.ResourcesDataProvider=t;r=function(t){function i(n,i,r,u){var f=this;t.call(this,n);this._instrumentationHelper=i;this._config.suppnores&&r.bindConversationStart(function(){f._isSuppressNoResultsSupported=!f._config.suppressNoResultQueryUnsupportedMarkets[u()]})}return __extends(i,t),i.prototype.getDataSource=function(){return n.WebDataSource},i.prototype.getBaseUrl=function(){return this._config.u},i.prototype.onBeforeFetchUrl=function(n,t){this._instrumentationHelper.instrumentSnRProviderFetchUrl(n,t)},i.prototype.getResources=function(n){return n.Resources},i.prototype.fetch=function(n,i,r,u,f,e,o){var h=this,s;this._isSuppressNoResultsSupported&&n.queryToFetch.length<=1&&(this._lastQueryWithNoResults=null);this._isSuppressNoResultsSupported&&this.shouldSuppressFetch(n.queryToFetch)?i(this.getDataSource(),null,null):(s=i,this._isSuppressNoResultsSupported&&(s=function(t,r,u){h.setLastQueryWithNoResults(r,n.queryToFetch);i(t,r,u)}),t.prototype.fetch.call(this,n,s,r,u,f,e,o))},i.prototype.shouldSuppressFetch=function(n){return this._lastQueryWithNoResults&&n.startsWith(this._lastQueryWithNoResults)},i.prototype.setLastQueryWithNoResults=function(n,t){!n||n.RankingSignals&&n.RankingSignals.HADI||n.Suggestions&&!n.Suggestions.length&&(this._lastQueryWithNoResults=t)},i}(t);n.AsSuggestionsDataProvider=r})(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){function e(n,t,i,r,f){typeof indexedDB!="undefined"&&new u(n,f,t,i,r)}function o(n,t,i,r,f){typeof indexedDB!="undefined"&&new u(n,f,t,i,r)}function s(n,t,i,r,f,e){typeof indexedDB!="undefined"&&new u(n,e,t,i,r,f)}function h(n,t,i,r,f,e){typeof indexedDB!="undefined"&&new u(n,e,t,i,r,f)}function c(n,t,u){i(n,"deleteDatabase requested");try{var f=indexedDB.deleteDatabase(n);f.onsuccess=function(){i(n,"deleteDatabase completed");t&&t()};f.onerror=r("deleteDatabase.onError",function(t){SharedLogHelper.LogError("deleteDB",n,t);u&&u(t)})}catch(e){u(e)}}function r(n,t){return function(i){var r=n;try{r+=" "+i.target.error.name}catch(u){}t(new Error(r))}}var f=function(){function n(){}return n.StorageNotAvailable="X",n.TimedOut="T",n.ErrorWhenQueryingDb="E",n.QuerySucceeded="R",n}(),i,u;t.StorageState=f;t.instanceWithNumberKeys=e;t.instanceWithStringKeys=o;t.instanceWithNumberKeysAndSecondaryKey=s;t.instanceWithStringKeysAndSecondaryKey=h;i=sa_config.th&&ClientTestHooks.isTesthookParamSet("dbTrace")?function(t,i){return n.log("["+t+"] "+i)}:function(){};t.deleteDatabase=c;t.handleErrorEvent=r;u=function(){function t(n,u,f,e,o,s){var h=this,c;this.databaseName=n;this.onClosed=o;this.secondaryIndex=s;this.closePending=!1;this.storeName=n+"Store";i(this.databaseName,"open requested");try{c=indexedDB.open(n,u||1)}catch(l){e(new Error("IndexedDbClientSideStorage.const: Could not open database"));return}c.onsuccess=function(n){h.database=n.target.result;t.allInstances.push(h);i(h.databaseName,"open completed");f(h)};c.onupgradeneeded=function(n){var t,r;i(h.databaseName,"upgrading");t=n.target.result;t.objectStoreNames.contains(h.storeName)&&t.deleteObjectStore(h.storeName);r=t.createObjectStore(h.storeName);h.secondaryIndex&&r.createIndex(h.secondaryIndex,h.secondaryIndex,{unique:!1})};c.onerror=r("open.onError",e);c.onblocked=r("open.onBlocked",e)}return t.prototype.put=function(n,t,i,r){this.safeDbOperation("put",n.toString(),"readwrite",i,function(i,r,u){var f=i.put(t,n);f.onsuccess=r;f.onerror=u},r)},t.prototype.putMultiple=function(n,t,i){this.safeDbOperation("putMultiple",n.length.toString(),"readwrite",t,function(t,i,r){var u=0,f=function(){if(u0?(i(this.databaseName,"delaying close because of "+t.requestsInProgress+" requests in progress"),this.closePending=!0):t.allInstances.forEach(function(t){t.database&&(n.safeExecute(function(){return t.database.close()},r.databaseName+".close"),i(t.databaseName,"close completed"),t.database=null,t.onClosed())})},t.prototype.queryFromCursor=function(n,t,i){var r=[];n.onsuccess=function(n){var i=n.target.result;i&&r.push({key:i.primaryKey,value:i.value});i&&r.length!=sa_config.maxIndexedDBCursorIterations?i.continue():t(r)};n.onerror=i},t.prototype.removeFromCursor=function(n,t,i){var r=0;n.onsuccess=function(n){var i=n.target.result;i&&(i.delete(),r+=1);i&&r!=sa_config.maxIndexedDBCursorIterations?i.continue():t(null)};n.onerror=i},t.prototype.safeDbOperation=function(n,u,f,e,o,s){var h=this,l,c,a;i(this.databaseName,n+" requested"+(u?" "+u:""));t.requestsInProgress+=1;l=function(r){i(h.databaseName,n+" completed "+(u?u+" ":""));t.requestsInProgress-=1;e(r);h.closePending&&t.requestsInProgress==0&&h.innerClose()};c=function(n){t.requestsInProgress-=1;s(n);h.closePending&&t.requestsInProgress==0&&h.innerClose()};try{this.database?(a=this.database.transaction(this.storeName,f).objectStore(this.storeName),o(a,l,r(n+".onError",c))):c(new Error(n+" Database not initialized"))}catch(v){c(v)}},t.requestsInProgress=0,t.allInstances=[],t}()})(t=n.ClientSideStorage||(n.ClientSideStorage={}))}(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){var i=function(){function i(n,t,i,r,u,f,e,o){var s=this;this._config=n;this._storageFactory=t;this._createResponse=i;this._dataPopulated=r;this._getDataSourceState=u;this._dataSource=f;this._queryType=e;this._storageOpenInProgress=!1;this._pendingQueries=[];o&&(o.bindAppVisible(function(){return s.initStorage()}),o.bindDismissed(function(){return s._pendingQueries=[]}),o.bindAppHidden(function(){return s.teardownStorage()}))}return i.prototype.teardownStorage=function(){this._storage&&this._storage.close()},i.prototype.initStorage=function(){var n=this;!this._storageOpenInProgress&&this._dataPopulated()&&(this._storageOpenInProgress=!0,this._storageFactory(function(t){n._storage=t;n._storageOpenInProgress=!1;n._pendingQueries.forEach(function(n){return n()});n._pendingQueries=[]},function(t){n.onError(t,"open storage");n._storageOpenInProgress=!1;n._pendingQueries.forEach(function(n){return n()});n._pendingQueries=[]},function(){return n._storage=null}))},i.prototype.onError=function(n,t){SharedLogHelper.LogError(t,this._dataSource,n);this.teardownStorage()},i.prototype.reloadStorage=function(){this.teardownStorage();this.initStorage()},i.prototype.isReady=function(){return!!this._storage},i.prototype.getKey=function(n){return n.queryToFetch?n.queryToFetch.toLocaleLowerCase():""},i.prototype.fetch=function(i,r,u,f,e){var s=this,o;n.isDataSourceEnabled(this._dataSource,i,this._config)&&(o=function(n,u){var f=u==t.StorageState.QuerySucceeded;e()&&r(s._dataSource,s._createResponse(i,n,f),s._getDataSourceState(u))},this.innerQueryStorage(this._queryType,this.getKey(i),function(n){return o(n,t.StorageState.QuerySucceeded)},function(){return o(null,t.StorageState.ErrorWhenQueryingDb)},function(){return o(null,t.StorageState.StorageNotAvailable)},function(){return o(null,t.StorageState.TimedOut)}))},i.prototype.withStorage=function(n){return this._storage?(n(this._storage),!0):!1},i.prototype.getMaxKey=function(n){return n.slice(0,n.length-1)+String.fromCharCode(n.charCodeAt(n.length-1)+1)},i.prototype.queryStorage=function(n,t,i,r,u){this.innerQueryStorage(0,n,t,i,r,u)},i.prototype.innerQueryStorage=function(t,i,r,u,f,e){var h=this,s=null,o=!1,c=!0,a=function(){if(c)if(c=!1,h._storage){var n=function(n){s&&sb_ct(s);h.onError(n,"query");o||(o=!0,u())};t==0?h._storage.getValue(i,function(n){s&&sb_ct(s);o||(o=!0,r(n))},n):i?h._storage.getRange(i,h.getMaxKey(i),function(n){s&&sb_ct(s);o||(o=!0,r(n))},n):h._storage.getAll(function(n){s&&sb_ct(s);o||(o=!0,r(n))},n)}else s&&sb_ct(s),o||(o=!0,u())},l;if(this._storage)a();else if(this.initStorage(),this._storageOpenInProgress)this._pendingQueries.push(a);else{f();return}l=i?this._config.indexedDBTimeout:this._config.latencyTimeoutForZeroInput;l&&(s=sb_st(function(){return n.safeExecute(function(){c=!1;o||(o=!0,e())},"innerQueryStorage")},l))},i}();t.StorageBasedDataProvider=i})(t=n.ClientSideStorage||(n.ClientSideStorage={}))}(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){var i=function(){function i(n,t,i,r){this._config=n;this._host=t;this._instrumentationHelper=i;this._temporaryMessageHandler=r}return i.prototype.parse=function(i,r,u,f,e,o,s){var h=this,c=[];if(this._config.mruCandidatesEnabled){var l=[],a=[],v=[],y=[],p=[],w=[];f&&f.Suggestions&&f.Suggestions.forEach(function(u){var f,e;u.handoffType==2?t.isApp(u.type)?(f=u,l.push(f.id),y.push(f)):t.isSetting(u.type)?(f=u,a.push(f.id),p.push(f)):t.isFileOrFolder(u.type)&&(f=u,v.push(f.id),w.push(f)):n.isBrowserOnline()&&(e=n.safeExecute(function(){return h.parseMRUWebSuggestion(i,u,r)},"parseMRUWebSuggestion"),e&&c.push(e))});t.lookupById(i,t.DataSources.MRUApps,null,l,y,function(n){return[n.id]},t.DataSources.MRUSettings,null,a,p,function(n){return n.id},e,r,o,s,function(n,t,u,f){return h.parseIdLookupResponse(i,r,n,t,u,f)},t.DataSources.MRUFilesAndFolders,v,w,function(n){return n.id},this._config,this._instrumentationHelper)}o(n.MRUDataSource,c,f)},i.prototype.parseIdLookupResponse=function(i,r,u,f,e,o){var s=this,h;e.length==1&&(h=function(n){return s.setupRemoveFromHistoryContextMenu(n,u,s._host),u.appContextData&&(n.appContext=u.appContextData.appContext,n.query=u.appContextData.query,n.text=i.queryToFetch?HitHighlightingParser.addMarkers(u.appContextData.textWithoutHH,i.queryToFetch):u.appContextData.textWithoutHH),s.setRankingSignals(n,u),!0},n.safeExecute(function(){return t.parseLocalSuggestion(i,e[0],f,r,s._host,s._config,s._temporaryMessageHandler,u.type,s._instrumentationHelper,o,h)},"parseLocalSuggestion "+f))},i.prototype.setRankingSignals=function(n,t){n.hc=t.hc;n.highConfidenceMetaSuggestionScore=t.highConfidenceMetaSuggestionScore;n.prefetchConfidenceScore=t.prefetchConfidenceScore;n.fromHistory=!0},i.prototype.parseMRUWebSuggestion=function(i,r,u){var f=t.createSuggestion(i.queryToFetch?HitHighlightingParser.addMarkers(r.textWithoutHH,i.queryToFetch):r.textWithoutHH,null,r.icon,r.type,r.query,n.InstrumentedItem.createInstrumentedItem(u),r.handoffType,u,null,null),e,s,o;f.secondaryText=r.secondaryText;f.secondaryTextClass=t.CssClass_Annotation;this.setRankingSignals(f,r);switch(f.handoffType){case 5:case 4:if(!t.isCortanaEnabledCache)return null;e=r;t.setCat1SuggestionProperties(f,i,u,e.actionUri,e.taskFrame,e.confidence,e.source,this._host);break;case 1:s=r;t.setDnavSuggestionProperties(f,i,u,s.url,this._host);break;case 2:if(f.type==t.OnlineSuggestionTypes.Person_Consumer){o=r;t.setPeopleSuggestionProperties(f,i,u,o.contactName,o.peopleScenario,this._host);break}default:return SharedLogHelper.LogError("parseMruWebSuggestion",null,new Error("Unexpected handoff type: "+r.handoffType)),null}return t.isValidSuggestion(f,"parseMruWebSuggestion",!1)?(this.setupRemoveFromHistoryContextMenu(f,r,this._host),f):null},i.prototype.setupRemoveFromHistoryContextMenu=function(n,i,r){i.remove&&t.setExtraVerbs(n,function(){if(!i.remove)return[];if(n.duplicates&&n.duplicates.some(function(n){return!n.fromHistory}))return[];var u={verb:t.Verbs.RemoveFromDeviceHistory,displayName:r.getLocString(t.Verbs.RemoveFromDeviceHistory),executeAsync:function(){return i.remove(function(){return r.setQuery(null,!1,!0)}),delete i.remove,t.createVoidPromise()}};return[u]})},i}();t.MruParser=i})(t=n.Windows||(n.Windows={}))}(AutoSuggest||(AutoSuggest={}));__extends=this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);r.prototype=t.prototype;n.prototype=new r},function(n){var t;(function(t){var i="LastUpdated",r=function(t){function r(r,u,f,e,o,s,h,c,l,a){var v=this;this._candidatesEnabled=l;this._loggingEnabled=a;this._rankingSignalKeyGenerator=o;this._suggestionKeyGenerator=s;this._lightweightStorage=h;this._pendingWrites=[];u&&u.bindItemLaunch(function(n,t,i){return v.onLaunch(n,t,i)});r.th&&ClientTestHooks.isTesthookParamSet("clearMru")&&n.ClientSideStorage.deleteDatabase(c);var y,p=!0,w=function(t,r,u){return f(c,function(i){p&&(p=!1,y=n.safeExecute(function(){return new Date(Number(v._lightweightStorage().LastMruPruneDate))},"getLastMruPruneDate"));t(i);(!n.isValidDate(y)||n.getTimeDiffInDays(y)>=1)&&(y=new Date,n.safeExecute(function(){return v._lightweightStorage().LastMruPruneDate=String(y.getTime())},"storeLastMruPruneDate"),v.prune())},r,u,i)},b=function(n,t,i){return v.createResponse(n,t,i)},k=function(){return!0},d=function(t){return t==n.ClientSideStorage.StorageState.QuerySucceeded?undefined:t};e.bindClearMRURequested(function(t){v.teardownStorage();n.ClientSideStorage.deleteDatabase(c,function(){return t(!0)},function(){return t(!1)})});t.call(this,r,w,b,k,d,n.MRUDataSource,1,e)}return __extends(r,t),r.prototype.shouldStoreSuggestions=function(){return this._config.mruCandidatesEnabled&&(!this._candidatesEnabled||this._candidatesEnabled())},r.prototype.createResponse=function(n,t,i){var o=this,f,s,u,e,h;return t=t||[],f=this.getKey(n),this._lastKey=i?f:null,s=t.filter(function(n){return n.key==f})[0],this._valueForLastKey=s?s.value:null,u={},this._config.mruSignalsEnabled&&this._valueForLastKey&&(u.RankingSignals=this._valueForLastKey.RankingSignals,u.WebRankingSignalsCache=this._valueForLastKey.WebRankingSignalsCache,u.EngagementSignalsCache=this._valueForLastKey.EngagementSignalsCache,u.SuppressedGroupsCache=this._valueForLastKey.SuppressedGroupsCache),this.shouldStoreSuggestions()&&(e=[],h=this.getOldestDateToKeep(),t.forEach(function(n){var i=n.key,t=n.value;t.Suggestions&&t.Suggestions.forEach(function(n){var u=r.getLastLaunchTime(t,n,o._suggestionKeyGenerator);u&&u>=h&&(e.push({lastLaunchTime:u,suggestionData:n}),n.remove=function(t){return o.remove(i,n,t)})})}),e.length>0&&(u.Suggestions=[],e.sort(function(n,t){return t.lastLaunchTime-n.lastLaunchTime}),e.forEach(function(n){return o.addIfNotPresent(u.Suggestions,n.suggestionData,!0)}),f?f.length<=this._config.mruLengthA?u.Suggestions.splice(this._config.maxMruA):f.length<=this._config.mruLengthB&&u.Suggestions.splice(this._config.maxMruB):u.Suggestions.splice(this._config.maxMruZeroInput))),u},r.removeRankerSignals=function(n,t){return n=="highConfidenceMetaSuggestionScore"||n=="prefetchConfidenceScore"?undefined:t},r.prototype.addIfNotPresent=function(n,t,i){var e=JSON.stringify(t,r.removeRankerSignals),u=n.filter(function(n){return JSON.stringify(n,r.removeRankerSignals)==e})[0],f;u?i&&(f=u.remove,u.remove=function(n){return f(function(){return t.remove(n)})}):n.push(t)},r.prototype.onAfterWrite=function(){if(this._writing=!1,this._pendingWrites.length>0){var n=this._pendingWrites.shift();n()}else this._tearDownPending&&this.teardownStorage()},r.prototype.teardownStorage=function(){this._writing?this._tearDownPending=!0:(this._tearDownPending=!1,t.prototype.teardownStorage.call(this))},r.prototype.onLaunch=function(t,i,r){var u=this,e,f;if(!this._loggingEnabled||this._loggingEnabled()){if(this._writing){this._pendingWrites.push(function(){return u.onLaunch(t,i,r)});return}this._writing=!0;e=r?r[n.WebDataSource]:null;f=this.getKey(i);this._lastKey==f?this.updateAndSaveLaunchData(f,this._valueForLastKey,t,e):this.queryStorage(f,function(n){return u.updateAndSaveLaunchData(f,n,t,e)},function(){return u.onAfterWrite()},function(){return u.onAfterWrite()},function(){return u.onAfterWrite()})}},r.prototype.remove=function(n,t,i){var r=this;if(this._writing){this._pendingWrites.push(function(){return r.remove(n,t,i)});return}this._writing=!0;this._lastKey==n?this.removeAndSaveLaunchData(n,this._valueForLastKey,t,i):this.queryStorage(n,function(u){return r.removeAndSaveLaunchData(n,u,t,i)},function(){return r.onAfterWrite()},function(){return r.onAfterWrite()},function(){return r.onAfterWrite()})},r.getUnixTime=function(n){return n||(n=new Date),Math.round(n.getTime()/1e3)},r.prototype.createOrUpdateDbEntry=function(n,t,i,u){var f,e;return t?(t.LastUpdated=r.getUnixTime(),t.RankingSignals=t.RankingSignals||{}):t={LastUpdated:r.getUnixTime(),RankingSignals:{}},f=this._rankingSignalKeyGenerator(i),t.RankingSignals[f]?(t.RankingSignals[f].prefixLaunchCount+=1,t.RankingSignals[f].lastLaunchTime=t.LastUpdated):t.RankingSignals[f]={prefixLaunchCount:1,lastLaunchTime:t.LastUpdated},this._config.mruSignalsEnabled&&u&&(t.WebRankingSignalsCache=u.rankingSignals,t.EngagementSignalsCache=u.engagementSignals,t.SuppressedGroupsCache=u.suppressedGroups),this.shouldStoreSuggestions()&&(e=i.getMruData(),e&&n&&(t.Suggestions||(t.Suggestions=[]),this.addIfNotPresent(t.Suggestions,e,!1)),t.Suggestions&&t.Suggestions.forEach(function(n){return delete n.remove})),t},r.prototype.getOldestDateToKeep=function(){var n=new Date;return n.setDate(n.getDate()-this._config.mruMaxAgeInDays),r.getUnixTime(n)},r.prototype.updateAndSaveLaunchData=function(n,t,i,u){var f=this;t=this.createOrUpdateDbEntry(n,t,i,u);this._suggestionKeyGenerator&&r.removeOldLaunches(t,this.getOldestDateToKeep(),this._suggestionKeyGenerator);this._lastKey=n;this._valueForLastKey=t;this.withStorage(function(i){return i.put(n,t,function(){return f.onAfterWrite()},function(n){f.onError(n,"updateAndSaveLaunchData");f.onAfterWrite()})})||this.onAfterWrite()},r.prototype.removeAndSaveLaunchData=function(t,i,r,u){var f=this,o,e;if(!i){SharedLogHelper.LogError("removeAndSaveLaunchData",null,new Error("MRU entry not present"));this.onAfterWrite();return}if(o=JSON.stringify(r),e=n.indexOf(i.Suggestions||[],function(n){return JSON.stringify(n)==o}),e==-1){SharedLogHelper.LogError("removeAndSaveLaunchData",null,new Error("Suggestion not present in MRU"));this.onAfterWrite();return}i.Suggestions.splice(e,1);i.Suggestions.forEach(function(n){return delete n.remove});this._lastKey=t;this._valueForLastKey=i;this.withStorage(function(n){return n.put(t,i,function(){u&&u();f.onAfterWrite()},function(n){f.onError(n,"removeAndSaveLaunchData");f.onAfterWrite()})})||this.onAfterWrite()},r.getLastLaunchTime=function(n,t,i){if(n.RankingSignals){var r=n.RankingSignals[i(t)];if(r)return r.lastLaunchTime}},r.removeOldLaunches=function(n,t,i){var f,e,o,u;if(n.Suggestions)for(f=n.Suggestions.length-1;f>=0;--f)u=r.getLastLaunchTime(n,n.Suggestions[f],i),(!u||u=0;--v)a=i[v],h.hasOwnProperty(a)&&(n[a]=h[a],c&&n[a]&&(n[a].suggestionType=c),l.splice(v,1));l.length==0?r(n):(y=t.dataSourceMayContainPII(f)?f:f+" "+l,t.Promise.safeChain(e,function(){return o(l)},function(u){var e=t.Map.map(l,u,function(n){return s(n)}),f;if(h&&l.forEach(function(n){return h[n]=e[n]}),l.length!=i.length)for(f in n)n.hasOwnProperty(f)&&(e[f]=n[f]);r(e)},function(){return r({})},u,y))}},"resolveIdsWithCache "+f,null,null,function(){r({})})}function nt(n,i){if(!i.launchArguments||k.test(n.query))return!0;var r=i.id.toLowerCase();return t.BlacklistedSystemCommandsWhenNoArgs.some(function(n){return r.includes(n)})?!0:!1}function d(i,r,u,f){var h,o,y,e,c,p,b,w,s,v,a,l;if(t.isMobileCache)return!1;if(t.isApp(f))return(e=u.id,n.contains(it,e))?!0:(h=u.kind,h&&(h=h.toLowerCase(),h!="program"&&h!="unknown"))?!0:!i.allowUrlsInAppsGroup&&((e=e.toLowerCase(),e.startsWith("http:")||e.startsWith("https:")||e.startsWith("file:"))||(o=u.filePath,o&&(o=o.toLowerCase(),o.startsWith("http:")||o.startsWith("https:")||o.startsWith("file:"))))?!0:(y=u.extension,y&&y.toLowerCase()==".chm")?!0:!1;if(t.isSetting(f))return(e=u.id,n.contains(tt,e))?!0:!1;if(f==t.LocalSuggestionTypes.BrowsingHistory)return(c=u,n.olderThan2Weeks(c.dateVisited)||n.isBingSearchUrl(c.url))?!0:r.queryToFetch?r.isMultiWord&&(p=c.title?HitHighlightingParser.addMarkers(c.title,r.queryToFetch):null,b=p&&p.includes(HitHighlightingParser.startMarker),b)?!1:!n.matchesOnDomain(c.url,r):!1;if(t.isItemWithFileMetadata(f)){if((w=u,s=w.id,s&&(s.includes("\\.")||s.includes("/.")||(s=s.toLowerCase(),ut.some(function(n){return s.includes(n)}))))||(v=w.extension,v&&!r.queryToFetch.toLowerCase().includes(v.toLowerCase())&&n.contains(rt,v.toLowerCase())))return!0;if(f==t.LocalSuggestionTypes.CommandLine){if(a=u,l=a.displayName.split(" ")[0].toLowerCase(),l.includes("\\")||l.indexOf(":")==1)return!1;var e=a.id.toLowerCase(),k=e.lastIndexOf("."),d=e.lastIndexOf("\\"),g=a.kind=="folder"||k<0||k0&&(o&&o.register(function(){t.Promise.clearPendingItemsFromCache();SearchAppWrapper.CortanaApp.queryFormulationView.cancelLastDeviceQuery()},!1),d=n.safeExecute(function(){return SearchAppWrapper.CortanaApp.queryFormulationView.startDeviceQuery(i.queryToFetch)},"startDeviceQuery"),d?k.forEach(function(n){return h.searchFolderWithMultipleResults(i,n,d,u,s)}):this.emptyFetch(k,u)),p=l.filter(function(t){return n.isDataSourceEnabled(t.dataSource,i,h._config)}),p.length>0){if(!i.queryToFetch)throw new Error(f);t.Promise.safeChain("executeSearchAsync",function(){return SearchAppWrapper.CortanaApp.searchResultsView.executeSearchAsync(i.queryToFetch,i.taskFrame)},function(n){n?p.forEach(function(t){return h.searchFolderWithMultipleResults(i,t,n,u,s)}):h.emptyFetch(p,u)},function(){return h.emptyFetch(p,u)})}if(w=a.filter(function(t){return n.isDataSourceEnabled(t.dataSource,i,h._config)}),w.length>0){if(!i.queryToFetch)throw new Error(f);o&&w.forEach(function(n){return o.register(function(){return n.customCancellation()},!0)});w.forEach(function(n){return h.searchFolderWithMultipleResults(i,n,i,u,s)})}if(b=v.filter(function(t){return n.isDataSourceEnabled(t.dataSource,i,h._config)}),b.length>0){if(!i.queryToFetch)throw new Error(f);o&&b.forEach(function(n){return o.register(function(){return n.customCancellation()},!0)});b.forEach(function(n){return h.searchFolderWithSingleResult(i,n,i,u,s)})}n.isDataSourceEnabled(t.DataSources.LocalRecentApps,i,this._config)&&t.Promise.safeChain("getRecentAppsAsync",function(){return SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.getRecentAppsAsync()},function(n){var r=[];n.forEach(function(n){var t=h.toLocalResponseSuggestion(i,n,y);t!=null&&r.push(t)});u(t.DataSources.LocalRecentApps,{suggestions:r},null)},function(){return u(t.DataSources.LocalRecentApps,r,null)});i.taskFrame&&n.safeExecute(function(){return SearchAppWrapper.CortanaApp.searchResultsView.setTaskFrame(i.originalQuery,"")},"reset task frame")},u.prototype.emptyFetch=function(n,t){var i=this;n.forEach(function(n){i.logProviderFailure(n.dataSource);t(n.dataSource,r,u.getDataSourceState(0))})},u.prototype.getMax=function(n,t){var i=t.maxUpTo3chars;return n.queryToFetch.length>8||n.scope!=0?i=t.maxAfter8chars:n.queryToFetch.length>3&&(i=t.maxAfter3chars),n.scope!=0&&n.queryToFetch&&(i*=2),i},u.prototype.toLocalResponseSuggestion=function(n,t,r){var u=r.getSuggestionType(t,this._config);return d(this._config,n,t,u)?null:r.customCreateLocalResponseSuggestion?r.customCreateLocalResponseSuggestion(this._config,t,u,r.dataSource):i(this._config,t,u,r.dataSource)},u.prototype.toLocalResponse=function(n,t,i){var u=this,r=[];return t.forEach(function(t){var f=u.toLocalResponseSuggestion(n,t,i);f!=null&&r.push(f)}),{suggestions:r}},u.prototype.getProvider=function(n,t,i){if(i.supportsOEM&&n.useOemDataSources)for(var u=t,r=u.getProviders().first();r.hasCurrent;){if(r.current.key==1)return 1;r.moveNext()}return 0},u.prototype.getResults=function(t,i,r,u){var f=this,e=n.safeExecute(function(){return f.getProvider(t,r,u)},"getProvider",0);return e==1?r.getItemsAsync(0,i,1,[]):r.getItemsAsync(0,i)},u.prototype.searchFolderWithMultipleResults=function(i,f,e,o){var h=this,s=f.dataSource,c=n.safeExecute(function(){return f.getQueryResults(e)},"getQueryResults "+s),l;c?(l=this.getMax(i,f),t.Promise.safeChain("getItemsAsync "+s,function(){return h.getResults(i,l,c,f)},function(n){var t=n.resultSet,r;t?r=n.state:(t=n,r=3);o(s,h.toLocalResponse(i,t,f),u.getDataSourceState(r))},function(t){n.isCancellation(t)||h.logProviderFailure(s);o(s,r,null)})):o(s,r,null)},u.prototype.searchFolderWithSingleResult=function(i,u,f,e){var s=this,o=u.dataSource,h=n.safeExecute(function(){return u.getQueryResults(f)},"getQueryResults "+o);h?t.Promise.safeChain("tryGetResultAsync "+o,function(){return h.tryGetResultAsync()},function(n){return e(o,s.toLocalResponse(i,n?[n]:[],u),null)},function(t){n.isCancellation(t)||s.logProviderFailure(o);e(o,r,null)}):e(o,r,null)},u.prototype.logProviderFailure=function(i){var r=t.providerFailureLogName(i);r&&SearchAppWrapper.CortanaApp.queryFormulationView.logProviderFailure&&n.safeExecute(function(){return SearchAppWrapper.CortanaApp.queryFormulationView.logProviderFailure(r,"ErrorForTopHit")},"logProviderFailure")},u.getDataSourceState=function(n){switch(n){case 0:return t.LocalProviderIndexerState.Unknown;case 1:return t.LocalProviderIndexerState.NotIndexed;case 2:return t.LocalProviderIndexerState.PartiallyIndexed}return undefined},u.getApps=function(n,t,i,r,u,f,o){e(i,r,u,f,"findAppsAsync",function(n){return SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.findAppsAsync(n)},function(t){return s.customCreateLocalResponseSuggestion(n,t,o,f)},n.cacheAppItems?p:null,o)},u.getSettings=function(n,t,i,r,u,f,o){e(i,r,u,f,"findSettingsAsync",function(n){return SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.findSettingsAsync(n)},function(t){return h.customCreateLocalResponseSuggestion(n,t,o,f)},w,o)},u.getFiles=function(n,r,u,f,o,s){e(u,f,o,s,"findFilesAsync",function(n){return SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.findFilesAsync(n)},function(r){var u=t.getSuggestionTypeFromKindAndExtension(r.kind,r.extension,n);return i(n,r,u,s)},b,null)},u}();t.LocalDataProvider=g;f="Local provider doesn't support empty query"})(t=n.Windows||(n.Windows={}))}(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){function u(n,t){!n.query.includes(t.queryToFetch)&&n.query.toLowerCase().startsWith(t.queryToFetch.toLowerCase())&&(n.query=t.queryToFetch+n.query.substr(t.queryToFetch.length),n.text=HitHighlightingParser.addMarkers(n.query,t.queryToFetch))}function i(n,i,r,f,e,o,s,h){if(n.actionUri=f,n.confidence=o,n.source=s,n.handoffType==4){var c=n.query.toLowerCase()==i.queryToFetch.toLowerCase();n.updateFromQuery=function(i){return c?(n.query=i.queryToFetch,n.text=HitHighlightingParser.addMarkers(n.query,i.queryToFetch),n.narratorText=t.getNarratorText(n),!0):!1};n.click=function(){return h.launchCat1MyStuff(n.query,e)}}else n.secondaryTextClass=t.CssClass_Action,n.click=function(){return h.launchCat1(n.query,f,e)};n.getIcon||t.isValidIcon(n.icon)||(n.icon={type:4});u(n,i);n.narratorText=t.getNarratorText(n);n.getMruData=function(){return{type:n.type,handoffType:n.handoffType,hc:n.hc,highConfidenceMetaSuggestionScore:n.highConfidenceMetaSuggestionScore,prefetchConfidenceScore:n.prefetchConfidenceScore,query:n.query,textWithoutHH:HitHighlightingParser.removeMarkers(n.text),secondaryText:n.secondaryText,icon:n.getIcon?null:n.icon,actionUri:f,taskFrame:e,confidence:o,source:s}}}function r(n,i,r,u,f,e){n.contactName=u;n.peopleScenario=f;n.icon=t.ScopeConfig[13].icon;n.click=function(){return e.launchUrl("ms-people:search?SearchString="+encodeURIComponent(u))};n.mayContainPII=!0;n.narratorText=t.getNarratorText(n,e.getLocString("SearchPeople"));n.getMruData=function(){return{type:n.type,handoffType:n.handoffType,hc:n.hc,highConfidenceMetaSuggestionScore:n.highConfidenceMetaSuggestionScore,prefetchConfidenceScore:n.prefetchConfidenceScore,query:n.query,textWithoutHH:HitHighlightingParser.removeMarkers(n.text),secondaryText:n.secondaryText,icon:n.icon,contactName:n.contactName,peopleScenario:n.peopleScenario}}}function f(n,i,r,u,f){n.url=u;t.isValidIcon(n.icon)||(n.getIcon=f.getBrowserIcon);n.click=function(){return f.launchUrl(u)};n.narratorText=t.getNarratorText(n,f.getLocString("DirectNavSuggestion"));n.getMruData=function(){return{type:n.type,handoffType:n.handoffType,hc:n.hc,highConfidenceMetaSuggestionScore:n.highConfidenceMetaSuggestionScore,prefetchConfidenceScore:n.prefetchConfidenceScore,query:n.query,textWithoutHH:HitHighlightingParser.removeMarkers(n.text),secondaryText:n.secondaryText,icon:n.getIcon?null:n.icon,url:u}}}var e=function(){function e(n,t,i,r,u){this._config=n;this._host=t;this._instrumentationHelper=i;this._navigationHelper=r;this._temporaryMessageHandler=u}return e.prototype.parse=function(n,t,i,r,u,f,e){this.parseOnlineSuggestions(n,t,r,u,f,e)},e.prototype.parseOnlineSuggestions=function(i,r,u,f,e,o){var s=this,c,l,w;if(!u){n.isDataSourceEnabled(n.WebDataSource,i,this._config)&&e(n.WebDataSource,[],null);n.isDataSourceEnabled(t.DataSources.BingApps,i,this._config)&&e(t.DataSources.BingApps,[],null);n.isDataSourceEnabled(t.DataSources.BingSettings,i,this._config)&&e(t.DataSources.BingSettings,[],null);return}u.ELToken&&this._host.setElToken(u.ELToken);var a=[],v=[],y=[],h=[],p=[];n.safeExecute(function(){u.Suggestions.forEach(function(t){var o=t.Attributes,l=t.Attributes.stype,c=o.appId,f,e;if(c){v.push(t);c.split(";").forEach(function(t){n.contains(h,t)||h.push(t)});return}if(f=o.settingId,f){y.push(t);p.push(f);return}e=n.safeExecute(function(){return s.parseOnlineSuggestion(i,t,r,u.Resources)},"parseOnlineSuggestion");e&&a.push(e)})},"parseOnlineSuggestions");n.isDataSourceEnabled(n.WebDataSource,i,this._config)&&(c=null,l=null,u.RankingSignals&&(c=n.safeExecute(function(){return n.parseWebEngagementSignals(u.RankingSignals,s._config)},"parseWebEngagementSignals"),l=n.safeExecute(function(){return t.parseWebSuppresionSignals(u.RankingSignals,i,s._config)},"parseWebSuppressionSignals")),w={rankingSignals:u.RankingSignals,engagementSignals:c,suppressedGroups:l,webTopResultRoutingType:u.PrefixRoutingType},e(n.WebDataSource,a,w));t.lookupById(i,t.DataSources.BingApps,null,h,v,function(n){return n.Attributes.appId.split(";")},t.DataSources.BingSettings,null,p,y,function(n){return n.Attributes.settingId},f,r,e,o,function(n,t,f,e){return s.parseIdLookupResponse(u,i,r,n,t,f,e)},null,null,null,null,this._config,this._instrumentationHelper)},e.prototype.parseIdLookupResponse=function(u,f,e,o,s,h,c){var l=this,a,v;if(o.Attributes.stype!=t.OnlineSuggestionTypes.Store||!(h.length>0)){if(h.length!=1){a=n.safeExecute(function(){return l.parseOnlineSuggestion(f,o,e,u.Resources)},"parseOnlineSuggestion "+s);a&&c.push(a);return}v=function(u){var s=o.Attributes;return l.compliesWithMinVersion(s.appMinVersion,u.deviceItem.version)?(s&&s.k&&s.appNS&&(u.instItem=new n.InstrumentedItem(parseInt(s.k),s.appNS,!0)),u.appContext=s.appContext,l.setRankingSignals(u,o),o.Text&&s.query&&(!t.isApp(u.type)||u.appContext)&&(u.text=o.Text,u.query=s.query),o.SecondaryText&&(u.secondaryText=o.SecondaryText),u.handoffType==5&&i(u,f,e,s.actionUri,s.taskFrame,parseFloat(s.confidence),parseInt(s.source),l._host),u.type==t.OnlineSuggestionTypes.Person_Consumer&&r(u,f,e,s.contactName,s.peopleScenario,l._host),!0):!1};n.safeExecute(function(){return t.parseLocalSuggestion(f,h[0],s,e,l._host,l._config,l._temporaryMessageHandler,o.Attributes.stype,l._instrumentationHelper,c,v)},"parseLocalSuggestion "+s)}},e.prototype.parseOnlineSuggestion=function(u,o,s,h){var c=o.Attributes,v=c.stype,y,l,a;if(c.appId&&v!=t.OnlineSuggestionTypes.Store||c.settingId)return null;if(y=c&&c.k&&c.appNS?new n.InstrumentedItem(parseInt(c.k),c.appNS,!0):n.InstrumentedItem.createInstrumentedItem(s),l=t.createSuggestion(o.Text,null,e.getIcon(o),v,c.query,y,null,s,null,null),l.secondaryText=o.SecondaryText,l.secondaryTextClass=t.CssClass_Annotation,this.setRankingSignals(l,o),c.isAnswer==="1"){if(!c.url&&!t.isCortanaEnabledCache)return null;l.handoffType=6;this.setCat2or3SuggestionProperties(l,u,s,o.InstantAnswer,c.url,c.taskFrame,h)}else if(c.taskFrame){if(!t.isCortanaEnabledCache)return null;l.handoffType=c.actionUri.startsWith("action://FindMyStuff/")?4:5;i(l,u,s,c.actionUri,c.taskFrame,parseFloat(c.confidence),parseInt(c.source),this._host)}else if(l.type==t.OnlineSuggestionTypes.Store)l.handoffType=3,this.setStoreSuggestionProperties(l,u,s,c);else if(l.type==t.OnlineSuggestionTypes.Person_Consumer)l.handoffType=2,r(l,u,s,c.contactName,c.peopleScenario,this._host);else{if(!c.url)return null;l.type==t.OnlineSuggestionTypes.DirectNav||l.type==t.OnlineSuggestionTypes.Deeplink?(a=n.prettyPrintUrl(c.query,u.queryToFetch),a!=l.query&&(l.query=a,l.text=u.queryToFetch?HitHighlightingParser.addMarkers(a,u.queryToFetch):a),l.handoffType=1,f(l,u,s,c.url,this._host)):(l.handoffType=0,this.setWebSearchSuggestionProperties(l,u,s,c.url))}return t.isValidSuggestion(l,"parseOnlineSuggestion",!1)?l:null},e.prototype.setCat2or3SuggestionProperties=function(n,i,r,f,e,o,s){var c=this,h;n.secondaryTextClass=t.CssClass_Action;n.answerHtml=f&&f.Content?f.Content.HTML:null;n.answerHtml&&(h=JsonInject.GetResourceKeys([f]),h&&(n.executeScript=function(){return JsonInject.WriteAfterContentResources(JsonInject.FilterResources(s,h))}));u(n,i);e?(n.click=function(){return c.launchSearch(n.query,i,n.type,e,r,n.useRaf)},n.miniAnswerOnly=!0):(t.isValidIcon(n.icon)||(n.icon={type:4}),n.click=function(){return c._host.launchCat2or3a(n.query,o)});n.narratorText=t.getNarratorText(n)},e.prototype.setStoreSuggestionProperties=function(n,i,r,u){var e=this,f;n.icon.bgColor=u.bgColor=="transparent"?this._host.getAccentColor():u.bgColor;n.secondaryTextClass=t.CssClass_Action;f=parseFloat(u.avgRating);n.stars=this.getStars(f);n.catalogScore=parseFloat(u.catalogScore);n.avgRating=f;n.ratingCount=parseInt(u.ratingCount);n.click=function(){return e._host.launchStorePdp(u.productId)};n.narratorText=t.getNarratorText(n)},e.prototype.getStars=function(n){for(var r="",i=1;i<=5;++i)if(n>=i-.25)r+=t.CortanaFontIcons.FavoriteStarFill;else if(n>=i-.75){r+=t.CortanaFontIcons.HalfStarLeft;break}return r},e.getIcon=function(n){var t=n.IconContent;return t?t[0]=="B"?{content:t.slice(1),type:3}:t[0]=="S"?{content:t.slice(1),type:1}:{content:t,type:2}:{content:n.Icon,type:0}},e.prototype.launchSearch=function(n,t,i,r,u,f){r=this._navigationHelper.getSearchUrl(t.fullPartialQuery,n,i,r);this._host.launchSearch(n,r,f)},e.prototype.setRankingSignals=function(n,t){var i=t.Attributes;n.hc=i.hc==="1";n.highConfidenceMetaSuggestionScore=t.HighConfidenceMetaSuggestionScore;n.prefetchConfidenceScore=t.PrefetchConfidenceScore},e.prototype.compliesWithMinVersion=function(n,t){var r,u,i,f,e;if(!n)return!0;if(!t)return!1;for(r=n.split("."),u=t.split(".");r.length>u.length;)u.push("0");for(i=0;ie)return!0}return!0},e.prototype.setWebSearchSuggestionProperties=function(n,i,r,u){var f=this;t.isValidIcon(n.icon)||(n.icon={content:n.type==t.OnlineSuggestionTypes.SearchHistory?t.CortanaFontIcons.History:t.CortanaFontIcons.Search,type:2});n.secondaryText||(n.secondaryText=this._host.getLocString("SearchTheWeb"));n.click=function(){return f.launchSearch(n.query,i,n.type,u,r,n.useRaf)};n.narratorText=t.getNarratorText(n);n.type==t.OnlineSuggestionTypes.SearchHistory&&t.setExtraVerbs(n,function(){var n={verb:"ManageSearchHistory",displayName:f._host.getLocString("ManageSearchHistory"),executeAsync:function(){return SearchAppWrapper.CortanaApp.launcher.launchUriAsync("https://www.bing.com/profile/history?fsi=1&FORM=WNSHIS")}};return[n]})},e}();t.OnlineSuggestionsParser=e;t.setCat1SuggestionProperties=i;t.setPeopleSuggestionProperties=r;t.setDnavSuggestionProperties=f})(t=n.Windows||(n.Windows={}))}(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){function e(n){return n?[n]:[]}function d(n){if(n){var t=n.lastIndexOf(".");if(t>=0)return n.substring(t)}return""}function o(t){var i;return(t&&(i=typeof t=="string"||typeof t=="number"?new Date(t):t()),n.isValidDate(i))?i:null}function i(i,r,u,f,e,s,h,c){var a=r||i.type,l;f=="System.ItemTypeText"&&(f=null);l=o(u);t.isMedia(a)?(i.secondaryText=a==t.LocalSuggestionTypes.Photo?c.getLocString("ViewPhotoPrompt"):a==t.LocalSuggestionTypes.Video?c.getLocString("PlayVideoPrompt"):c.getLocString("PlaySongPrompt"),i.additionalInfoTextForTopResult=f,i.secondaryTextClass=t.CssClass_Action,i.narratorText=t.getNarratorText(i,i.secondaryText)):(l?(i.secondaryText=n.formatString(c.getLocString("LastModifiedAnnotation"),[l.toLocaleDateString()]),i.additionalInfoTextForTopResult=f):i.secondaryText=f,i.secondaryTextClass=t.CssClass_Annotation,i.narratorText=t.getNarratorText(i));i.tooltip=rt(i.path,e,s,h,l,c)}function s(n,i,r,u,f,e){n.additionalInfoText=i;n.additionalInfoTextClass="dark";n.text=r;n.query=HitHighlightingParser.removeMarkers(r);n.textLabel=e>1?"("+e+")":null;n.primaryTextClass="singleLine";n.template=1;n.secondaryText=u;n.secondaryTextClass=t.CssClass_Annotation;var s=o(f);s&&(n.rightAlignedText=s.toLocaleDateString());n.tooltip=HitHighlightingParser.removeMarkers(r+(r&&i?"\n":"")+i);n.narratorText=t.getNarratorText(n)}function g(n,i,r,u,f){return n?t.Promise.safeChainWithGlobalCaching("getImageWithLiveTokenAsync",function(){return SearchAppWrapper.CortanaApp.getImageWithLiveTokenAsync(r)},function(){return f},function(n){return t.toIcon(n,"getImageWithLiveTokenAsync",i)},i,null,3):h(i,u,f)}function h(n,i,r){return t.Promise.safeChainWithGlobalCaching("getIconForTypeAsync",function(n){return SearchAppWrapper.CortanaApp.queryFormulationView.deviceSearch.getIconForTypeAsync(i,t.getImageSizeValue(n))},function(n){return n+"_"+r},function(i){return t.toIcon(i,"getIconForTypeAsync",n)},n)}function c(n){return n!=null&&(n.type==4||!!n.content)}function u(n,t,i){if(!n.text)return SharedLogHelper.LogError(t,i?"":n.deviceItem?n.deviceItem.id:"",new Error("Missing text")),!1;if(!n.query)return SharedLogHelper.LogError(t,i?"":n.text,new Error("Missing query")),!1;if(!n.handoffType&&n.handoffType!==0)return SharedLogHelper.LogError(t,i?"":n.text,new Error("Missing handoff type")),!1;if(!n.type)return SharedLogHelper.LogError(t,i?"":n.text,new Error("Missing suggestion type")),!1;var r=!n.miniAnswerOnly;return r&&!n.getIcon&&!c(n.icon)?(SharedLogHelper.LogError(t,i?"":n.text,new Error("Missing icon")),!1):!0}function r(n,i){var r=n.getExtraVerbs;n.getExtraVerbs=function(){var n=r?r():[],u=i();return t.joinVerbsWithSeparator(n,u)}}function nt(n,i){var r=n.getExtraVerbsAsync;n.getExtraVerbsAsync=r?function(){return ThresholdUtilities.createPromise(function(n){r().then(function(r){i().then(function(i){n(t.joinVerbsWithSeparator(r,i))})})})}:i}function l(n){return SearchAppWrapper.CortanaApp.launcher.launchUriAsync(n)}function tt(n,t){var r=n.propertyHits?n.propertyHits:[],i=r.indexOf(t);return typeof i=="object"&&typeof i.returnValue!="undefined"?i.returnValue:i>=0}function it(n){var i,t;if(n&&typeof n=="object"&&n.length){for(i="",t=0;t900));s.th&&ClientTestHooks.isTesthookParamSet("forceRemoveIcon")&&t.setRemoveIcon(y);u(y,"parseLocalSuggestion "+f,g)&&v(y)&&a.push(y)}}function ct(n){return n==t.LocalSuggestionTypes.PathCompletion||n==t.LocalSuggestionTypes.Email||t.isFileOrFolder(n)}function lt(t,i){r(t,function(){var r,u;return t.duplicates&&(r=t.duplicates.filter(function(n){return n.handoffType==7})[0],r)?(u={verb:"OpenInOneDrive",displayName:n.formatString(i.getLocString("OpenIn"),["OneDrive"]),executeAsync:function(){return l(r.url)}},[u]):[]})}function at(i,u,e,o,s,h,c,l,a){var p=u.id,d=!1,y=n.contains(w,p),v;(y||(v=u.filePath,v&&(v=v.toLowerCase(),y=b.some(function(n){return v.includes(n)}),y||(d=k.some(function(n){return v.includes(n)})))),y)||(i.calculateChildSuggestions=function(){return vt(p,i,u,d,o,s,h,c,l,e,a)},e.maxJLcm&&r(i,function(){var n=[],r,u;return i.calculateChildSuggestions&&i.calculateChildSuggestions(),i.childSuggestions&&(r=!1,i.childSuggestions.filter(function(n){return!n.displayed&&n.groupType==14}).slice(0,e.maxJLcm).forEach(function(i){r=!0;var u={verb:i.text,displayName:i.text,executeAsync:function(){return f(i,o,s),t.createVoidPromise()}};n.push(u)}),u=!1,i.childSuggestions.filter(function(n){return!n.displayed&&n.groupType!=14}).slice(0,e.maxJLcm).forEach(function(i){var e,h;r&&!u&&(e={verb:null,displayName:null,executeAsync:null},n.push(e));u=!0;h={verb:i.text,displayName:i.text,executeAsync:function(){return f(i,o,s),t.createVoidPromise()}};n.push(h)})),n}))}function vt(i,r,e,o,s,h,c,l,a,v,y){var w,p,b;(r.calculateChildSuggestions=null,w=e.jumpList,w&&w.length!=0)&&(r.childSuggestions=[],p=e.filePath||"",b=p.indexOf("}"),p=p.substr(b+1),w.forEach(function(e){o&&e.type==2||(e.items.forEach(function(o,l){var v,a,w;if(o.displayName&&!n.olderThan2Weeks(o.lastAccessed)){v=t.getIcon(o,i+"_"+o.path+"_"+o.displayName,"jumpList",!1);a=t.createSuggestion(y.queryToFetch&&y.scope!=0&&y.scope!=1?HitHighlightingParser.addMarkers(o.displayName,y.queryToFetch):o.displayName,v,null,t.LocalSuggestionTypes.JumpListItem,o.displayName,n.InstrumentedItem.createInstrumentedItem(c),2,r.sequenceNumber);a.id=r.id+"_"+l;a.click=function(){return f(a,s,h)};a.jumpListItem=o;a.groupDisplayName=e.name;a.getMruData=function(){return r.getMruData()};a.parent=r;a.additionalInfoTextForTopResult=o.path;w=p&&o.path.endsWith(p);w||(a.path=o.path);switch(e.type){case 0:a.groupType=14;break;case 1:a.groupType=15;break;case 2:a.groupType=16;break;case 3:a.groupType=17;break;default:a.groupType=18}a.mayContainPII=a.groupType!=14;u(a,"calculateJumpListSuggestions",a.mayContainPII)&&(r.childSuggestions.push(a),yt(a,s))}}),r.childSuggestions.length>0&&a.instrumentDataSource(c,l,r.childSuggestions,null))}))}function f(n,i,r){t.Promise.safeChain("launchJumpList",function(){return n.jumpListItem.launchAsync()},null,function(){r.showTemporaryMessage(i.getLocString("JumpListItemUnavailable"),{content:t.CortanaFontIcons.Info,type:2});n.jumpListItem.deleteAsync&&t.Promise.safeChain("deleteJumpList",function(){return n.jumpListItem.deleteAsync()});pt(n);i.setFocusInSearchBox("jumpListItemUnavailable")})}function yt(n,i){n.jumpListItem.deleteAsync&&r(n,function(){var r={verb:t.Verbs.RemoveFromThisList,displayName:i.getLocString(t.Verbs.RemoveFromThisList),executeAsync:function(){return t.Promise.safeChain("deleteJumpList",function(){return n.jumpListItem.deleteAsync()},function(){return i.setQuery(null,!1,!0)}),t.createVoidPromise()}};return[r]})}function pt(n){var t=_ge(n.id);t.className+=" b_hide";n.suppressed=!0}var w=["Microsoft.Windows.Explorer","Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge","Microsoft.InternetExplorer.Default","Chrome","360browser",],b=["chrome","iexplore","opera","firefox","360browser","safari","skype",],k=["outlook",],a;t.getFileExtension=d;t.setFileTemplate=i;t.setEmailTemplate=s;t.getOneDriveSuggestionIcon=g;t.getIconForTypeAsync=h;t.isValidIcon=c;t.isValidSuggestion=u;t.setExtraVerbs=r;t.setExtraVerbsAsync=nt;t.getLaunchUrlContextMenuAction=l;a=function(){function i(n,t,i,r,u,f){this._config=n;this._host=t;this._instrumentationHelper=i;this._navigationHelper=r;this._temporaryMessageHandler=u;this._ciDataLoader=f}return i.prototype.parse=function(i,r,u,f,e,o){var s=this,h=[],c,l;f.suggestions.forEach(function(t){return n.safeExecute(function(){return p(i,t,u,r,s._host,s._config,s._temporaryMessageHandler,t.suggestionType,s._instrumentationHelper,h,function(){return!0})},"parseLocalSuggestion "+u)});t.isFileOrFolderLocalDataSource(u,this._config)&&v(i,h,this._config,this._host);c=u==t.DataSources.LocalApps||u==t.DataSources.LocalSettings;l=this._ciDataLoader&&c?{rankerExtraInfo:{ciVersion:this._ciDataLoader.getCurrentCiVersion()}}:null;o(u,h,l)},i}();t.SuggestionsParser=a;t.lookupById=ut;t.decorateLocalFilesAndFoldersAndMediaWithParentFolder=v;t.parseLocalSuggestion=p})(t=n.Windows||(n.Windows={}))}(AutoSuggest||(AutoSuggest={}));__extends=this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);r.prototype=t.prototype;n.prototype=new r},function(n){var t;(function(t){var r="/searchPreCache/mapClient?clientType=DefaultBrowser",u="/search?",f="/searchPreCache/cacheMappedClient?",e="pf=1",o="pf=2",s=function(n){function t(t){n.call(this,t)}return __extends(t,n),t}(n.JsonDataProvider),i;t.SearchPreCacheDataProvider=s;i=function(){function n(n,t){var i=this;this._webDataProvider=t;this.mapClient();n.bindConversationStart(function(){return i.mapClient()})}return n.prototype.attempPreCacheAndEnrichUrl=function(n){var t=n,i;return this._clientInfo&&this._clientInfo.mapped=="1"&&(i=n.replace(u,f)+"&"+e,this._webDataProvider.fetchUrl(i,{},null,null,null,function(){return!0}),t+="&"+o),this._clientInfo&&this._clientInfo.pcsId&&this._clientInfo.pcsId.length>0&&(t+="&pcsId="+this._clientInfo.pcsId),t},n.prototype.mapClient=function(){var n=this,t=function(t,i){return n._clientInfo=i};this._webDataProvider.fetchUrl(r,{},null,t,null,function(){return!0})},n}();t.SearchPreCacheHandler=i})(t=n.Windows||(n.Windows={}))}(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){var i;(function(t){var i=function(){function t(){this._countTasks=0;this._numTasks=-1;this._partialChunkFromPreviousBatch="";this._taskCache={};this._version=-1;this._prefixCount=-1}return t.prototype.getVersion=function(){return this._version},t.prototype.getPrefixCount=function(){return this._prefixCount},t.prototype.parse=function(n){return this.parseLines(this.splitToCompleteData(n))},t.prototype.flush=function(){return this._partialChunkFromPreviousBatch?this.parseLines([this._partialChunkFromPreviousBatch]):[]},t.prototype.splitToCompleteData=function(n){if(n.length>0){var t=n.split("\n").map(function(n){return n.trim()});return t.length>0&&(t[0]=this._partialChunkFromPreviousBatch+t[0],this._partialChunkFromPreviousBatch=t.pop()),t}return[]},t.prototype.parseLines=function(i){for(var r,f,e,h,o,s=[],u=0;uthis._rowsToSkip?(n=n.slice(this._rowsToSkip),this._rowsToSkip=0):(this._rowsToSkip-=n.length,n=[]));n.length>0?(u=n.map(function(n){return{key:n.prefix,value:n}}),this._storage.putMultiple(u,function(){if(i._progress+=u.length,r("[BCSDataLoader] "+i._progress),i._cancelRequested){i.close();return}sb_st(function(){return t()},i._config.bcsLoaderIntervalBetweenBatches)},function(n){SharedLogHelper.LogError("BCSDataLoader addToDatabase",null,n);i.close()})):t()},n.prototype.close=function(){this._bcsDataReader&&(this._bcsDataReader.close(),this._bcsDataReader=null);this._storage=null;this._onLoadingStopped&&(this._onLoadingStopped(this._progress),this._onLoadingStopped=null)},n}();i.BCSDataLoader=u})(i=t.Bcs||(t.Bcs={}))})(t=n.Windows||(n.Windows={}))}(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){var i;(function(i){var o="BingClientStore",c="BingClientStore2",s="bcs_population_status",h=2,e=function(){function n(){}return n.Populated="P",n.NotPopulated="X",n}(),f=function(){function n(){}return n.LoadingFromClient="C",n.LoadingFromServer="S",n.NotLoading="X",n}(),l=e.Populated+f.NotLoading+n.ClientSideStorage.StorageState.QuerySucceeded,u=function(){function n(){}return n.Start="S",n.Pause="P",n.Resume="R",n.Complete="C",n.Active="A",n.Inactive="I",n}(),r=sa_config.th&&ClientTestHooks.isTesthookParamSet("bcsPopulationTrace")?n.log:function(){},a=function(){function a(n,t,i,r,u,f,e,o){var s=this;this._config=n;this._clientSideStorageFactory=t;this._bcsDataReader=i;this._lightweightStorage=r;this._onDataPopulated=u;this._instrumentationHelper=e;this._status=null;this._allowPopulation=!1;n.th&&ClientTestHooks.isTesthookParamSet("clearBCS")&&(this._status=this.createEmptyStatus(),this.deleteDb(this._status.dbA),this.deleteDb(this._status.dbB));f?(f.bindShown(function(){return s.start()}),n.allowBcsPopulationWhenOtherCortanaCanvasIsActive?(f.bindAppVisible(function(){var n=SearchAppWrapper.CortanaApp.entryPoint;n&&n!="WNSSTB"&&s.start()}),f.bindAppHidden(function(){return s.stop()})):f.bindDismissed(function(){return s.stop()})):this.checkStatus();o&&o.bindItemLaunch(function(){return s.stop()})}return a.prototype.start=function(){this._allowPopulation=!0;this.checkStatus()},a.prototype.stop=function(){this._allowPopulation=!1;this._loader&&this._loader.cancel()},a.prototype.dbPopulatedForCurrentLanguage=function(){if(!this._status)return!1;var n=this.getActiveDb();return this.isFullyPopulated(n)&&n.language==t.getCurrentLanguage()},a.prototype.getActiveVersion=function(){return this._status?this.getVersion(this.getActiveDb()):undefined},a.prototype.getDataSourceState=function(n){var i=this.dbPopulatedForCurrentLanguage()?e.Populated:e.NotPopulated,r=this._dbBeingPopulated?this._dbBeingPopulated.source==0?f.LoadingFromClient:f.LoadingFromServer:f.NotLoading,t=i+r+n;return t==l?undefined:t},a.prototype.getActiveBCSStorage=function(n,t,i){this.getStorage(n,t,i,this.getActiveDb(),!0)},a.prototype.getActiveDb=function(){return this._status.activeDb==this._status.dbA.name?this._status.dbA:this._status.dbB},a.prototype.getInactiveDb=function(){return this._status.activeDb==this._status.dbA.name?this._status.dbB:this._status.dbA},a.prototype.resetDbStatus=function(n){n.version=-1;n.language=null;n.source=null;n.populatedRecords=0;n.totalRecords=-1;n.schemaVersion=n.schemaVersion?n.schemaVersion+1:1},a.prototype.deleteDb=function(t){this.resetDbStatus(t);n.ClientSideStorage.deleteDatabase(t.name);t.schemaVersion=0;this.saveStatus()},a.prototype.isFullyPopulated=function(n){return n.totalRecords>0&&n.populatedRecords==n.totalRecords},a.prototype.isPopulationInProgress=function(n){return n.totalRecords>0&&n.populatedRecords>0&&n.populatedRecordsu.version||o1&&(i=t[t.length-1].split("."),u=i.length==2?i[0]:"",r=+t[t.length-2])),{version:r,language:u}},i.prototype.getUrlForCINotification=function(t,i){return n.getWindowProtocol()+"//"+n.getWindowHost()+"/bcs/ci/"+t+"/"+i+".cab"},i.prototype.getCurrentCiVersion=function(){return this._ciVersion},i}();i.ConstraintIndexDataLoader=r})(i=t.ConstraintIndex||(t.ConstraintIndex={}))})(t=n.Windows||(n.Windows={}))}(AutoSuggest||(AutoSuggest={}))