0% found this document useful (0 votes)
149 views9 pages

11

The document discusses an AutoSuggest class and its SubstrateDataProvider subclass. SubstrateDataProvider handles fetching data from various backends like Outlook and SharePoint using an access token manager. It can summarize documents, emails, and other data based on the search scope.

Uploaded by

ANIL SINGH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views9 pages

11

The document discusses an AutoSuggest class and its SubstrateDataProvider subclass. SubstrateDataProvider handles fetching data from various backends like Outlook and SharePoint using an access token manager. It can summarize documents, emails, and other data based on the search scope.

Uploaded by

ANIL SINGH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 9

var __extends=this&&this.

__extends||function(){var n=function(t,i){return
n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t)
{n.__proto__=t}||function(n,t){for(var i in
t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r()
{this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):
(r.prototype=i.prototype,new r)}}(),AutoSuggest;(function(n){var t;(function(t){var
u="NT",b="NF",r="https://substrate.office.com{0}/api/v1/",k=r+"events",h=r+"init",d
=r+"suggestions?
query=",g=r+"query",nt=r+"recommendations",c="SubstrateSearchService",tt="https://o
utlook.office365.com/autodiscover/autodiscover.json/v1.0/{0}?
Protocol={1}",f="AutoDiscoveryKey",l="3sflights",it="3sdebug",e="gwsflt.",rt="textd
ecorations",a="scenario",ut="setflight",ft="debug",v="entitytypes",et="1",ot="scope
s",st="people.directorysearch",ht="Authorization",o="Content-Type",ct="X-
AnchorMailbox",lt="X-Client-Language",at="X-Client-LocalTime",y="Client-Request-
Id",p="User-Agent",vt="X-Debug-ExternalExp",yt="X-Client-
Flights",s="application/json",pt=6e4,i,w=!1,wt=function(r){function wt(u,o,s,c,a,v)
{var y=r.call(this,wt.getDataSource(c,a))||this,b,k,d,p;return
y._host=u,y._accessTokenManager=o,y._instrumentationHelper=s,y._authType=c,y._provi
derType=a,y._storage=v,y._autoDiscoveryData={stem:"/search",timestamp:-1},w||(w=!
0,k=function(n){return n.split(",").filter(function(n){return
n.toLocaleLowerCase().startsWith(e)}).map(function(n){return
n.substr(e.length)}).join(",")},t.config.th&&(i=k(ClientTestHooks.getUrlValue(l,"")
)),ThresholdUtilities.getCortanaHeaders(function(n){var t,r;n&&(t=n["X-BM-
ClientFeatures"],t&&(r=k(t),r&&(i=(i?i+",":"")
+r)))})),t.config.th&&ClientTestHooks.isTesthookParamSet("clearAutoDCache")&&y._sto
rage.removeItem(f),d=y._storage.getItem(f),d&&(p=n.safeExecute(function(){return
JSON.parse(d)},"parseAutoDiscovery",null),p&&!p.errorState?
y._autoDiscoveryData=p:y._storage.removeItem(f)),y._host.bindAccessTokenAvailable(f
unction(t){var r,u,i;if(t==y._authType){if(y._providerType==0)
{if(r=n.getCurrentTime(),b&&(u=r-b,u<pt))return;b=r;y.fetchUrl(h,null,"",function()
{},null,function(){return!0})}i=n.getCurrentDate();i.setDate(i.getDate()-
1);y._autoDiscoveryData.timestamp<i.getTime()&&y.getStem()(t,function(t)
{t.timestamp=n.getCurrentTime();y._autoDiscoveryData=t;t.errorState||
y._storage.setItem(f,JSON.stringify(t))})}}),y}return
__extends(wt,r),wt.prototype.getName=function(){return"SubstrateDataProvider
"+this._dataSource},wt.prototype.createUrl=function(i)
{if(this._providerType==1)return i.queryToFetch?
this.getBaseUrl():nt;if(i.scope==t.Scope.Documents){var
u=t.getEffectiveQuery(i);if(u!=i.queryToFetch)return this.getBaseUrl()
+n.encodeQueryParameter(u.toLocaleLowerCase())}return
r.prototype.createUrl.call(this,i)},wt.prototype.getBaseUrl=function(){return
this._providerType==1?g:d},wt.getDataSource=function(n,t){return t==0?
n==1?"SSUE":"SSUC":n==1?"SSEE":"SSEC"},wt.prototype.getPostBody=function(n){var
i,u,f,r;if(this._providerType==1){if(i=void
0,u=t.getEffectiveScope(n),u==t.Scope.All&&t.RuntimeConfig.QfMode!=5)throw new
Error("Unsupported scope "+n.scope);switch(u){case t.Scope.PeopleEmail:case
t.Scope.Emails:f=[{Score:
{SortDirection:"Desc",Count:t.config.maxNumberOfEmailsInTopResult}},{Time:
{SortDirection:"Desc"}}];i=this.buildPostBodyForQueryEndpoint(n,"Message",
["Exchange"],f);break;case t.Scope.Documents:case t.Scope.AllFiles:case
t.Scope.FilesFolders:case t.Scope.All:if(r=void 0,n.queryToFetch)
{switch(t.config.queryProvenances){case 0:r=["SharePoint"];break;case
1:r=["OneDriveBusiness"];break;case
2:r=["SharePoint","OneDriveBusiness"];break;default:throw new Error("Unexpected
query provenances:
"+t.config.queryProvenances);}i=this.buildPostBodyForQueryEndpoint(n,"Documents",r,
[{Score:"Desc"}])}else
i=this.buildPostBody("Document","OpenFile");break;default:throw new
Error("Unsupported scope "+n.scope);}return
JSON.stringify(i)}return""},wt.prototype.buildPostBodyForQueryEndpoint=function(n,t
,i,r){return
this.buildPostBody(t,"WindowsSearchBoxL2",n.queryToFetch,i,r,"ProvenanceOptimized",
"Forward")},wt.prototype.buildPostBody=function(n,t,i,r,u,f,e)
{return{EntityRequests:[{Query:i?
{QueryString:i}:undefined,EntityType:n,Provenances:r,Sort:u,PropertySet:f}],Cvid:th
is._host.getConversationId(),TextDecorations:e,Scenario:
{Name:t}}},wt.prototype.getStem=function(){var i=this;return
t.Promise.safeChainWithGlobalCaching("getStem",function(f){return
ThresholdUtilities.createPromise(function(e)
{i._accessTokenManager.getAccount(f,t.getSubstrateResourceOrScope(f),!1,!
0,function(t){var h,f,l;t&&t.UserName?(h=n.formatString(tt,
[t.UserName,c]),f={},f[o]=s,f[y]=i._host.getConversationId(),f[p]=navigator.userAge
nt,l=function(t,i,r){var u,f,o;if(r){e({stem:"",errorState:r});return}if(u=i,!u)
{e({stem:""});return}if(!u.Url){e({stem:"",errorState:"NAU"});return}if(u.Protocol!
=c){e({stem:"",errorState:"NAP"});return}if(f=n.tryParseUrl(u.Url,!0),o=f?
f.path:null,!o)
{e({stem:"",errorState:"NAS"});return}e({stem:o})},r.prototype.fetchUrl.call(i,h,f,
"",l,null,function(){return!
0})):e({stem:"",errorState:u})},t.getAuthAccountForCloudContent())})},function()
{return"autoDiscovery"})},wt.prototype.getAllAccountTokens=function(n,i){if(n||
t.RuntimeConfig.QfMode!
=5)this._accessTokenManager.getAccount(this._authType,t.getSubstrateResourceOrScope
(this._authType),!1,!0,function(n){n&&n.Token?
i([n]):i(null,u)},t.getAuthAccountForCloudContent());else{var
r=SearchAppWrapper.CortanaApp.fileExplorerSuggestionPage.currentSyncRootAccount;r?
this._accessTokenManager.getAccountByUserName(!0,1,r,!1,!0,function(n){n&&n.Token?
i([n]):i(null,u)},"Windows"):t.config.fileExplorerCloudInSpecialFolders&&t.isFileEx
plorerCurrentPathThisPcOrQuickAccess?
this._accessTokenManager.getAllSyncingAccounts(!0,1,!1,!0,function(n){n.length>0?
i(n):i(null,u)},"Windows"):(SharedLogHelper.LogError("fetchUrl",null,new
Error("Substrate provider called without
currentSyncRootAccount")),i(null,b))}},wt.prototype.fetchUrl=function(i,u,f,e,o,s)
{var l=this,v,c,a;if(!this._autoDiscoveryData.stem)
{e(this._dataSource,null,this._autoDiscoveryData.errorState,null,!
0);return}v=i==h;i=n.formatString(i,[this._autoDiscoveryData.stem]);u||
(u={});c={numOfPendingResponses:0};a=function(n){var
h=Object.assign({},u);h[ht]="Bearer "+n.Token;l._authType==1&&!
t.SubstrateTenantName&&n.TenantName&&(t.SubstrateTenantName=n.TenantName);h[ct]=n.R
outingHint;r.prototype.fetchUrl.call(l,i,h,f,function(n,t,i,r,u){--
c.numOfPendingResponses;e(n,t,i,r,u,c.numOfPendingResponses!
=0)},o,s)};this.getAllAccountTokens(v,function(n,t){t?
e(l._dataSource,null,t,null,null,!1):n?
(c.numOfPendingResponses=n.length,n.forEach(function(n){return a(n)})):
(c.numOfPendingResponses=1,a(null))})},wt.prototype.fetch=function(u,f,e,h,c,l){var
w=this,a,b,k;if(n.isDataSourceEnabled(this._dataSource,u))
{if(a={},a[lt]=t.uiLanguageCache,a[at]=n.getDateWithTimezone(),a[p]=navigator.userA
gent,typeof _CachedFlights!
="undefined"&&_CachedFlights.sort&&(a[vt]=_CachedFlights.sort().join(",")),a[y]=thi
s._instrumentationHelper.getImpressionGuid(e),b=this.buildParams(l,u.scope,!
u.queryToFetch),this._providerType==0){if(!b[v])return}else
a[o]=s;i&&(a[yt]=i);k=function(i,r,u,e,o,s){var h=parseInt(u);(h==403||
h==401)&&n.safeSetTimeout(function(){return
w._accessTokenManager.getAccount(w._authType,t.getSubstrateResourceOrScope(w._authT
ype),!0,!0,function()
{},t.getAuthAccountForCloudContent())},0,"SubstrateDataProvider
onResponseReceived");f(i,r,u,e,o,s)};r.prototype.fetch.call(this,u,k,e,h,c,b,a)}},w
t.prototype.buildParams=function(i,r,u){var f={},o;return
this._providerType==0&&(f[n.Service.QueryParams.ConversationId]=i[n.Service.QueryPa
rams.ConversationId],f[rt]=et,r!=t.Scope.People||this._authType!=1||u?r!
=t.Scope.All&&(f[a]=ot):f[a]=st,f[v]=this.getEntityTypes(r)),t.config.th&&(o=Client
TestHooks.getUrlValue(l,"").split(",").filter(function(n){return!
n.toLocaleLowerCase().startsWith(e)}).join(","),o&&(f[ut]=o),ClientTestHooks.isTest
hookParamSet(it)&&(f[ft]="1")),f},wt.prototype.getEntityTypes=function(n){var
i,r;switch(n){case t.Scope.Documents:case t.Scope.AllFiles:case
t.Scope.FilesFolders:i="Documents";break;case t.Scope.PeopleEmail:case
t.Scope.People:i="People";break;case
t.Scope.All:r=[];this._authType==1&&r.push("Documents");t.RuntimeConfig.QfMode!
=5&&r.push("People");i=r.join(",");break;default:throw new Error("Unsupported scope
"+n);}return i},wt.prototype.instrumentClick=function(t,i){if(t&&i){var
u=[{Key:t,Value:[{Name:"entityclicked",Attributes:[{Key:"id",Value:i},
{Key:"localtime",Value:n.getDateWithTimezone()}]}]}],r={};r[o]=s;this.fetchUrl(k,r,
JSON.stringify(u),function(){},null,function(){return!0})}},wt}
(t.CortanaJsonDataProvider);t.SubstrateDataProvider=wt})(t=n.WSB||(n.WSB={}))})
(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){function l(n,i,r)
{var u=t.OfficeTypeExtensionConfigs[n];u?
t.LocalDataProvider.getApps(u.appIds,function(n){var f=!t.Map.isEmpty(n);f?
i(u.uri):r()}):r()}function a(n,t,i){l(t,function(t){return
i.launchUri(t+n)},function(){return i.launchUri(n+"?web=1")})}function v(n,i,r,u,f)
{t.setExtraVerbs(n,function(){var i=[];return
i.push({verb:t.JumplistActionItemType[t.JumplistActionItemType.S_OpenInBrowser],dis
playName:f.getLocString("OpenInBrowser"),executeSync:function(){return
f.launchUri(r)},icon:
{type:1,content:"&#xE774"}}),n.locationUrl&&i.push({verb:t.JumplistActionItemType[t
.JumplistActionItemType.S_OpenFileLocationInBrowser],displayName:f.getLocString("Op
enFileLocationIn",u),executeSync:function(){return
f.launchUri(n.locationUrl)},icon:
{type:2,content:"&#xE838"}}),n.url&&SearchAppWrapper.CortanaApp.copyToClipboard&&i.
push({verb:t.JumplistActionItemType[t.JumplistActionItemType.S_CopyFullPath],displa
yName:f.getLocString("CopyFullPath"),executeSync:function(){return
SearchAppWrapper.CortanaApp.copyToClipboard(n.url,"")},icon:
{type:1,content:"&#xE8C8"}}),i},!1)}function y(n,t,i,r){var
f,e=t.toLocaleLowerCase(),s=decodeURI(i).toLocaleLowerCase().indexOf(e),u,o;s!=-
1&&(f=i.substr(0,s-
1),e.endsWith(".one")&&(f=f.substr(0,f.lastIndexOf("/"))));u=decodeURI(i).split("/"
);r?(o="OneDrive for
Business:\\",u.length>5&&u[3].toLocaleLowerCase()=="personal"&&u[5].toLocaleLowerCa
se()=="documents"&&(u=u.slice(6))):
(u=u.slice(3),o="SharePoint:\\");e.endsWith(".one")&&u.splice(u.length-
2,1);n.path=o+u.join("\\");n.url=i;f&&(n.locationUrl=f)}function
h(i,r,u,f,e,o,s,h,c,l,p,w,b,k,d,g,nt,tt,it){var
et=t.ScopeConfig[t.Scope.Documents].icon,ot=r+"?web=1",ut,rt,ft;return
f=HitHighlightingParser.removeMarkers(f),e&&(e=e.toLocaleLowerCase()),ut="FL",rt=t.
createSuggestion(i,u,t.getIconForTypeAsync(et,"."+e),et,ut,f,n.InstrumentedItem.cre
ateInstrumentedItem(b,ut),8,b,!0),rt.instrumentPingBack=w,rt.click=function()
{return
a(r,e,g)},rt.extensionLC="."+e,rt.lastModifiedDate=t.toDate(s),rt.lastModifiedBy=h,
rt.author=c,rt.matchedOnlyOnAuthor=l,rt.matchedOnlyOnContent=p,rt.textContentIfMatc
hed=nt,ft=o?3:4,y(rt,f,r,o),o||(rt.siteTitle=it),l?
rt.match=t.createMatch(t.MatchType.Author,c):u.includes(HitHighlightingParser.start
Marker)||(rt.match=t.tryGetLocationMatch(rt.path,k)||
tt),rt.sourceForGroup=ft,t.setFileTemplate(i,k,d,rt,g),v(rt,e,ot,t.getGroupSourceDi
splayName(ft,g),g),rt}var u={Word:{appIds:
["Microsoft.Office.WINWORD.EXE.15","Microsoft.Office.WINWORD.EXE.16","{6D809377-
6AF0-444B-8957-A3773F02200E}\\Microsoft Office\\Office15\\WINWORD.EXE","{7C5A40EF-
A0FB-4BFC-874A-C0F2E0B9FA8E}\\Microsoft Office\\Office15\\WINWORD.EXE","{6D809377-
6AF0-444B-8957-A3773F02200E}\\Microsoft Office\\Office16\\WINWORD.EXE","{7C5A40EF-
A0FB-4BFC-874A-C0F2E0B9FA8E}\\Microsoft
Office\\Office16\\WINWORD.EXE","Microsoft.Office.Word_8wekyb3d8bbwe!
microsoft.word"],uri:"ms-word:ofe|u|"},Excel:{appIds:
["Microsoft.Office.EXCEL.EXE.15","Microsoft.Office.EXCEL.EXE.16","{6D809377-6AF0-
444B-8957-A3773F02200E}\\Microsoft Office\\Office15\\EXCEL.EXE","{7C5A40EF-A0FB-
4BFC-874A-C0F2E0B9FA8E}\\Microsoft Office\\Office15\\EXCEL.EXE","{6D809377-6AF0-
444B-8957-A3773F02200E}\\Microsoft Office\\Office16\\EXCEL.EXE","{7C5A40EF-A0FB-
4BFC-874A-C0F2E0B9FA8E}\\Microsoft
Office\\Office16\\EXCEL.EXE","Microsoft.Office.Excel_8wekyb3d8bbwe!
microsoft.excel"],uri:"ms-excel:ofe|u|"},PowerPoint:{appIds:
["Microsoft.Office.POWERPNT.EXE.15","Microsoft.Office.POWERPNT.EXE.16","{6D809377-
6AF0-444B-8957-A3773F02200E}\\Microsoft Office\\Office15\\POWERPNT.EXE","{7C5A40EF-
A0FB-4BFC-874A-C0F2E0B9FA8E}\\Microsoft Office\\Office15\\POWERPNT.EXE","{6D809377-
6AF0-444B-8957-A3773F02200E}\\Microsoft Office\\Office16\\POWERPNT.EXE","{7C5A40EF-
A0FB-4BFC-874A-C0F2E0B9FA8E}\\Microsoft
Office\\Office16\\POWERPNT.EXE","Microsoft.Office.PowerPoint_8wekyb3d8bbwe!
microsoft.pptim"],uri:"ms-powerpoint:ofe|u|"},Visio:{appIds:["{7C5A40EF-A0FB-4BFC-
874A-C0F2E0B9FA8E}\\Microsoft Office\\Office15\\VISIO.EXE","{7C5A40EF-A0FB-4BFC-
874A-C0F2E0B9FA8E}\\Microsoft Office\\Office14\\VISIO.EXE","{6D809377-6AF0-444B-
8957-A3773F02200E}\\Microsoft Office\\Office16\\VISIO.EXE","{7C5A40EF-A0FB-4BFC-
874A-C0F2E0B9FA8E}\\Microsoft
Office\\Office16\\VISIO.EXE","Microsoft.Office.VISIO.EXE.15"],uri:"ms-visio:ofe|
u|"},OneNote:{appIds:
["Microsoft.Office.ONENOTE.EXE.15","Microsoft.Office.ONENOTE.EXE.16","{6D809377-
6AF0-444B-8957-A3773F02200E}\\Microsoft Office\\Office15\\ONENOTE.EXE","{7C5A40EF-
A0FB-4BFC-874A-C0F2E0B9FA8E}\\Microsoft Office\\Office15\\ONENOTE.EXE","{6D809377-
6AF0-444B-8957-A3773F02200E}\\Microsoft Office\\Office16\\ONENOTE.EXE","{7C5A40EF-
A0FB-4BFC-874A-C0F2E0B9FA8E}\\Microsoft
Office\\Office16\\ONENOTE.EXE","Microsoft.Office.OneNote_8wekyb3d8bbwe!
microsoft.onenoteim"],uri:"onenote:"}},e="sip:",c=["Microsoft.Office.lync.exe.15","
{6D809377-6AF0-444B-8957-A3773F02200E}Microsoft OfficeOffice15lync.exe","{6D809377-
6AF0-444B-8957-A3773F02200E}Microsoft OfficeOffice16lync.exe","{7C5A40EF-A0FB-4BFC-
874A-C0F2E0B9FA8E}Microsoft OfficeOffice15lync.exe","{7C5A40EF-A0FB-4BFC-874A-
C0F2E0B9FA8E}Microsoft OfficeOffice16lync.exe","{6D809377-6AF0-444B-8957-
A3773F02200E}MSOfficeOffice15lync.exe","{6D809377-6AF0-444B-8957-
A3773F02200E}MSOfficeOffice16lync.exe","{7C5A40EF-A0FB-4BFC-874A-
C0F2E0B9FA8E}MSOfficeOffice15lync.exe","{7C5A40EF-A0FB-4BFC-874A-
C0F2E0B9FA8E}MSOfficeOffice16lync.exe","Microsoft.Office.Desktop_8wekyb3d8bbwe!
Lync","com.squirrel.Teams.Teams",],i=u.Word,r=u.Excel,f=u.PowerPoint,o=u.Visio,s;t.
OfficeTypeExtensionConfigs={doc:i,dot:i,dotx:i,docx:i,docm:i,docb:i,xls:r,xlm:r,xls
x:r,xlsm:r,xlsb:r,xltx:r,ppt:f,pps:f,pptx:f,pptm:f,vsd:o,vsdx:o,one:u.OneNote};s=fu
nction(){function i(n,t,i,r,u,f,e)
{this._host=n;this._substrateSuggestionsDataProvider=t;this._instrumentationHelper=
i;this._accessTokenManager=r;this._substrateProfilePictureProvider=u;this._sequence
NumberReader=f;this._authType=e;this._mailboxLocations={}}return
i.prototype.parse=function(i,r,u,f,e,o){var
l=this,s,a;if(n.isDataSourceEnabled(u,i)){if(s=[],!f||!f.Groups)
{o(u,s,null);return}a=!t.config.peopleCardHandoffDisabled&&(u=="SSUE"||
t.config.msaPeopleCardHandoffEnabled);t.config.ssPeopleOff&&u=="SSUE"&&(a=!1);var
p=t.getEffectiveQuery(i),v=t.isL2(i),y=function(c){for(var
y,it,rt,b,nt,ut,ft,d,tt,k,w=0,g=f.Groups;w<g.length;w+
+)if(y=g[w],y.Suggestions&&y.Suggestions.length)switch(y.Type)
{case"Documents":for(it=y.Suggestions,rt=function(u){var e=n.safeExecute(function()
{return
h(i,u.Url,u.Text,u.FileName,u.FileExtension,u.FileSourceType=="OneDriveForBusiness"
,u.DateModified,null,u.CreatedBy||
HitHighlightingParser.removeMarkers(u.Author),u.PropertyHits&&u.PropertyHits[0]=="A
uthor",!1,function(){return
l._substrateSuggestionsDataProvider.instrumentClick(f.Instrumentation.TraceId,u.Ref
erenceId)},r,p,v,l._host,"",null,u.SourceTitle||"")},"buildSubstrateDocumentSuggest
ion");e&&t.isValidSuggestion(e,"SubstrateDocumentsSuggestionsParser")&&s.push(e)},b
=0,nt=it;b<nt.length;b+
+)k=nt[b],rt(k);t.decorateSuggestionsWithParentFolder(s,l._host);break;case"People"
:if(!(t.config.ssPeopleOff&&u=="SSUE")||i.queryToFetch=="")
{for(ut=y.Suggestions,ft=function(e){var o=n.safeExecute(function(){return
l.buildPersonSuggestion(a,e,r,f.Instrumentation.TraceId,v,u,i,c)},"buildPersonSugge
stion");o&&t.isValidSuggestion(o,"SubstratePeopleSuggestionsParser")&&s.push(o)},d=
0,tt=ut;d<tt.length;d++)k=tt[d],ft(k);a&&n.safeExecute(function(){return
l.prefetchPeopleCards(s.filter(function(n){return
n.type=="PPL"}),r,e)},"prefetchPeopleCards");t.isL2(i)||
l.decorateContactsWithSameDisplayName(s,i)}break;default:SharedLogHelper.LogError("
parseSubstrateResponse",y.Type,new Error("Unexpected group
type"))}o(u,s,null)};u=="SSUE"?t.LocalDataProvider.getApps(c,function(n){return y(!
t.Map.isEmpty(n))}):y(!1)}},i.prototype.prefetchPeopleCards=function(n,i,r){var
u=this;n.length&&this.getPeopleCardTokenAndMailboxLocation(function(f){var
s,e,o,h;f&&f.token&&f.location&&i==u._sequenceNumberReader.getSequenceNumber()&&r()
&&(s=f.location+"api/v1/personacards/preparePersona",e=SearchAppWrapper.CortanaApp.
createStringMap(),e.Authorization="Bearer "+f.token,e["X-
ClientCorrelationId"]=u._instrumentationHelper.getImpressionGuid(i),e["X-
ClientType"]="6",o=SearchAppWrapper.CortanaApp.createStringMap(),o["Content-
Type"]="application/json",h=JSON.stringify(n.map(function(n)
{return{Smtp:n.email,PersonaType:"User"}})),t.Promise.safeChain("prefetchPeopleCard
s",function(){return
SearchAppWrapper.CortanaApp.makeHttpRequestAsync(1,s,e,h,o)},function(n)
{if(n.statusCode!=200&&n.statusCode!=204){var t=new Error("Prefetch request failed
with status code:
"+n.statusCode);SharedLogHelper.LogError("prefetchPeopleCards",null,t)}}))})},i.pro
totype.buildPersonSuggestion=function(i,r,u,f,o,s,h,c){var y=this,d,a,g,w,ft;if(!
r.EmailAddresses||!r.EmailAddresses[0])return null;var
nt=this._substrateProfilePictureProvider.getPersonDefaultIcon(r.DisplayName),tt=r.E
mailAddresses[0],v=HitHighlightingParser.removeMarkers(tt),it=s=="SSUE",rt="PPL",l=
t.createSuggestion(h,r.Text,this._substrateProfilePictureProvider.getProfilePicture
Icon(this._authType,v,nt),nt,rt,r.DisplayName,n.InstrumentedItem.createInstrumented
Item(u,rt),it?8:12,u,!
0),b=r.Id,k;it&&(d=r.Id.split("@"),b=d[0],k=d[1]);l.email=v;l.emailHH=tt;l.uniqueNa
me=v;a=r.ImAddress;a&&!a.startsWith(e)&&(a=a.includes(":")?
undefined:e+a);a&&(l.imAddress=a,g=a.substr(e.length),g!
=v&&(l.alternativeEmail=g));w=b&&k&&!
i;l.tooltip=this.getPersonTooltip(r.DisplayName,r.Department,r.JobTitle,r.OfficeLoc
ation,r.CompanyName,v,l.alternativeEmail);l.instrumentPingBack=function(){return
y._substrateSuggestionsDataProvider.instrumentClick(f,r.ReferenceId)};l.click=funct
ion(n){return y.onPersonSuggestionClick(i,w,v,l.query,u,n,b,k)};var
ut=this._host.getLocString("Email"),et=function(){return
y._host.launchUri("mailto:"+v)},p={};return
p[ut]=[{text:v,click:et}],l.alternativeEmail&&(ft=function(){return
y._host.launchUri("mailto:"+l.alternativeEmail)},p[ut].push({text:l.alternativeEmai
l,click:ft})),r.OfficeLocation&&(p[this._host.getLocString("Location")]=[{text:r.Of
ficeLocation}]),r.CompanyName&&(p[this._host.getLocString("Company")]=[{text:r.Comp
anyName}]),l.previewMetadata=p,l.department=r.Department,this.setPersonTemplate(l,o
,r.JobTitle,h),this.setPersonContextMenuItems(l,i||w,c),!
t.RuntimeConfig.AlwaysWide&&(i||w)&&(l.calculateChildSuggestions=function(){return
y.getPersonChildSuggestions(h,l,u,s,c)}),l},i.prototype.getPersonChildSuggestions=f
unction(n,t,i,r,u){var
f=[];f.push(this.getChildSuggestion(n,t,"CortanaAnnotation_Email","&#xE715","mailto
:"+t.email,"PPLE",i));t.imAddress&&u&&f.push(this.getChildSuggestion(n,t,"SendInsta
ntMessage","&#xE8BD",t.imAddress,"PPLM",i));t.childSuggestions=f;t.calculateChildSu
ggestions=null;this._instrumentationHelper.instrumentDataSource(i,r,t.childSuggesti
ons,null)},i.prototype.getChildSuggestion=function(i,r,u,f,e,o,s){var
l=this,c=this._host.getLocString(u),h=t.createSuggestion(i,c,null,
{type:2,content:f},o,c,n.InstrumentedItem.createInstrumentedItem(s,o),r.handoffType
,s,!1,null,null,!0);return
h.parent=r,h.groupType=t.GroupType.Contact,h.click=function(){return
l._host.launchUri(e)},h.instrumentPingBack=r.instrumentPingBack,h},i.prototype.getP
eopleCardTokenAndMailboxLocation=function(i){var
r=this;this._accessTokenManager.getAccount(this._authType,this._authType==1?"394866
fc-eedb-4f01-8536-3ff84b16be2a":"LiveProfileCard.Access",!1,!0,function(u){var
f,o,s,e;if(!u||!u.Token)
{i(null);return}if(f=u.Token,o=r._mailboxLocations[u.RoutingHint],o)
{i({token:f,location:o});return}s=SearchAppWrapper.CortanaApp.createStringMap();e=S
earchAppWrapper.CortanaApp.createStringMap();e.Authorization="Bearer "+f;e["X-
ClientType"]="6";t.Promise.safeChain("lokiConfiguration",function(){return
SearchAppWrapper.CortanaApp.makeHttpRequestAsync(0,t.config.peopleCardLokiHost+"api
/v1/configuration/cortana",e,"",s)},function(e){if(e.statusCode!==200)
{i(null);return}t.Promise.safeChain("lokiConfigurationResponse",function(){return
e.readAsStringAsync()},function(t){if(!t){i(null);return}var
e=n.safeExecute(function(){return JSON.parse(t)},"parseLokiConfiguration");if(!e||!
e.LokiUrl)
{i(null);return}r._mailboxLocations[u.RoutingHint]=e.LokiUrl;i({token:f,location:e.
LokiUrl})},function(){return i(null)})},function(){return
i(null)})},t.getAuthAccountForCloudContent())},i.prototype.getSharePointHost=functi
on(n){for(var f,i,e,t,s,l,a,v=new DOMParser,u=0,h=n.value;u<h.length;u+
+)if(f=h[u],f.serviceElements)for(i=0,e=f.serviceElements;i<e.length;i++){var
y=e[i],p=v.parseFromString(y,"text/xml"),r=p.getElementsByTagName("ServiceParameter
"),o=void 0,c=!1;for(t=0;t<r.length;t+
+)if(s=r[t].getElementsByTagName("Name"),s[0].childNodes[0].nodeValue=="IsDefaultDa
taLocation"?
(l=r[t].getElementsByTagName("Value"),l[0].childNodes[0].nodeValue=="True"&&(c=!
0)):s[0].childNodes[0].nodeValue=="SPO_MySiteHost_AboutMeUrl"&&(a=r[t].getElementsB
yTagName("Value"),o=a[0].childNodes[0].nodeValue),c&&o)return o}return
null},i.prototype.onPersonSuggestionClick=function(i,r,u,f,e,o,s,h){var
c=this,l=function(){return c._host.launchUri("mailto:"+u)},a=function(){var
i=function(){return c._host.launchUri(c._sharePointSiteHostUrl+"?
aadObjectId="+s)};c._sharePointSiteHostUrl?
i():c._accessTokenManager.getAccount(1,"https://graph.windows.net/",!1,!
0,function(r){if(!r||!r.Token){l();return}var
f=SearchAppWrapper.CortanaApp.createStringMap(),u=SearchAppWrapper.CortanaApp.creat
eStringMap();u.Authorization="Bearer
"+r.Token;t.Promise.safeChain("getSharePointUrl",function(){return
SearchAppWrapper.CortanaApp.makeHttpRequestAsync(0,"https://graph.windows.net/"+h+"
/tenantDetails/"+h+"/serviceInfo?api-version=1.6-internal",u,"",f)},function(r)
{if(r.statusCode!==200)
{l();return}t.Promise.safeChain("readSharePointUrlResponse",function(){return
r.readAsStringAsync()},function(t){var r=t?n.safeExecute(function(){return
JSON.parse(t)},"parseSharePointUrlResponse"):null;if(!r)
{l();return}c._sharePointSiteHostUrl=c.getSharePointHost(r);c._sharePointSiteHostUr
l?i():l()},l)},l)},t.getAuthAccountForCloudContent())};i?
this.getPeopleCardTokenAndMailboxLocation(function(n)
{if(e==c._sequenceNumberReader.getSequenceNumber())if(n&&n.token&&n.location){var
i=n.location+"api/v1/personacard?
clientType=Cortana&userSmtp="+u+"&ClientCorrelationId="+c._instrumentationHelper.ge
tImpressionGuid(e)
+"&cts="+o+"&CultureInfoName="+t.uiLanguageCache;c._host.launchWebContent(i,f,n.tok
en)}else r?a():l()}):r?
a():l()},i.prototype.setPersonContextMenuItems=function(n,i,r){var
u=this;t.setExtraVerbs(n,function(){var
f=[],e=n.childSuggestions&&n.childSuggestions.some(function(n){return
n.displayed});return e||
(f.push({verb:t.JumplistActionItemType[t.JumplistActionItemType.S_SendEmail],displa
yName:u._host.getLocString("CortanaAnnotation_Email"),executeSync:function(){return
u._host.launchUri("mailto:"+n.email)},isDefault:!i,icon:
{content:"&#xE715",type:2}}),n.imAddress&&r&&f.push({verb:t.JumplistActionItemType[
t.JumplistActionItemType.S_SendInstantMessage],displayName:u._host.getLocString("Se
ndInstantMessage"),executeSync:function(){return
u._host.launchUri(n.imAddress)},icon:
{content:"&#xE8BD",type:2}})),SearchAppWrapper.CortanaApp.copyToClipboard&&f.push({
verb:t.JumplistActionItemType[t.JumplistActionItemType.S_CopyPersonDetails],display
Name:u._host.getLocString("CopyDetails"),executeSync:function(){return
SearchAppWrapper.CortanaApp.copyToClipboard(n.tooltip.replace(/\n/g,"\r\n"),"")},ic
on:{type:1,content:"&#xE8C8"}}),f},!
0)},i.prototype.setPersonTemplate=function(n,i,r,u){var
e=t.getEffectiveQuery(u),f;r?(n.jobTitle=r,n.primaryMetadata=r):n.text!
=n.emailHH&&(n.primaryMetadata=n.emailHH);e&&(n.text.includes(HitHighlightingParser
.startMarker)||(n.emailHH.includes(HitHighlightingParser.startMarker)?
(n.template=1,n.primaryMetadata=n.emailHH):n.alternativeEmail&&(f=HitHighlightingPa
rser.addMarkers(n.alternativeEmail,e),f.includes(HitHighlightingParser.startMarker)
&&(n.template=1,n.primaryMetadata=f))));n.narratorText=t.getNarratorText(n);i?
(n.template=u.isSearchHomeZI?0:1,u.isSearchHomeZI||
n.classNames.push("people","topResultTemplateInGroups")):n.template==1&&n.className
s.push("forceNoWrapOutsideTopResult")},i.prototype.getPersonTooltip=function(n,t,i,
r,u,f,e){var h="",c=[n,i,t,r,u],o,l,s;for(n!=f&&c.push(f),e&&n!
=e&&c.push(e),o=0,l=c;o<l.length;o++)s=l[o],s&&(h+=h?"\n"+s:s);return
h},i.prototype.decorateContactsWithSameDisplayName=function(n,i){for(var
r,e,u,f=0;f<n.length-1;++f)if(r=n[f],r.type=="PPL")for(e=f+1;e<n.length;+
+e)if(u=n[e],u.type=="PPL"&&r.text.toLocaleLowerCase()==u.text.toLocaleLowerCase())
{t.isL2(i)||(r.template!
=1&&r.classNames.push("forceNoWrapOutsideTopResult"),u.template!
=1&&u.classNames.push("forceNoWrapOutsideTopResult"));r.template=u.template=1;r.pri
maryMetadata=r.emailHH;u.primaryMetadata=u.emailHH;break}},i}
();t.SubstrateSuggestionsParser=s;t.buildSubstrateDocumentSuggestion=h})(t=n.WSB||
(n.WSB={}))}(AutoSuggest||(AutoSuggest={})),function(n){var t;(function(t){function
u(n,t){return function(){return n(t)}}var
f=["Microsoft.Office.OUTLOOK.EXE.15","Microsoft.Office.OUTLOOK.EXE.16","{6D809377-
6AF0-444B-8957-A3773F02200E}Microsoft OfficeOffice15OUTLOOK.EXE","{7C5A40EF-A0FB-
4BFC-874A-C0F2E0B9FA8E}Microsoft
OfficeOffice15OUTLOOK.EXE"],i="OutlookLaunchPref",r=[0,1],e=function(){function
e(n,t,i,r,u)
{this._host=n;this._substrateSuggestionsDataProvider=t;this._lightweightStorage=i;t
his._accessTokenManager=r;this._authType=u;this._outlookLaunchPreference={}}return
e.prototype.parse=function(i,r,u,f,e,o){var
w=this,s,a,h,c,v,y,b,k,l,p,d;if(n.isDataSourceEnabled(u,i)){if(s=[],!f||!
f.EntitySets)
{o(u,s,null);return}for(a=t.getEffectiveQuery(i),h=t.getEffectiveScope(i),c=0,v=f.E
ntitySets;c<v.length;c++)if(y=v[c],y.ResultSets)for(b=function(e){var
p,o,v,b,l,y,c;if(e.Results)if(h==t.Scope.All&&t.RuntimeConfig.QfMode!
=5)SharedLogHelper.LogError("parseSubstrateSearchResponse",h.toString(),new
Error("Unexpected scope"));else switch(h){case t.Scope.PeopleEmail:case
t.Scope.Emails:for(p=function(e){var o=n.safeExecute(function(){return
w.buildMessageSuggestion(i,e.Source,r,u,f.Instrumentation?
f.Instrumentation.TraceId:null,e.ReferenceId,a)},"buildMessageSuggestion");o&&t.isV
alidSuggestion(o,"parseSubstrateSearchResponse_emails",!
1)&&s.push(o)},o=0,v=e.Results;o<v.length;o++)c=v[o],p(c);break;case
t.Scope.Documents:case t.Scope.AllFiles:case t.Scope.FilesFolders:case
t.Scope.All:for(b=function(u){var o=n.safeExecute(function(){return
w.buildDocumentSuggestion(u.Source,r,f.Instrumentation?
f.Instrumentation.TraceId:null,u.ReferenceId,(u.Provenance||
e.Provenance)=="OneDriveBusiness",a,i)},"buildDocumentSuggestion");o&&t.isValidSugg
estion(o,"parseSubstrateSearchResponse_documents")&&s.push(o)},l=0,y=e.Results;l<y.
length;l+
+)c=y[l],b(c);t.decorateSuggestionsWithParentFolder(s,k._host);break;default:Shared
LogHelper.LogError("parseSubstrateSearchResponse",h.toString(),new
Error("Unexpected scope"))}},k=this,l=0,p=y.ResultSets;l<p.length;l+
+)d=p[l],b(d);o(u,s,null)}},e.prototype.buildDocumentSuggestion=function(n,i,r,u,f,
e,o){var w=this,a=e?
HitHighlightingParser.addMarkers(n.FileName,e):n.FileName,s=a.includes(HitHighlight
ingParser.startMarker);if(e&&!s&&(!t.config.minLengthForContentMatch||
o.queryToFetch.length<t.config.minLengthForContentMatch))return null;var
v=n.Author==null?
null:n.Author.DisplayName,c=t.matchesOnPropertyHH(v,e),b=n.Description?
t.decodeHtml(n.Description).replace(/<\/?[^>]+(>|
$)/g,""):"",y=t.tryGetTextContentMatch(b,e),k=y[0],p=y[1],l=n.LastModifiedBy==null?
null:n.LastModifiedBy.DisplayName,h;return s||c||
(t.matchesOnPropertyHH(l,e)&&(h=t.createMatch(t.MatchType.LastModifiedBy,l)),h=h||
p),t.buildSubstrateDocumentSuggestion(o,n.Url,a,n.FileName,n.FileExtension,f,n.Last
ModifiedDateTime,l,v,!s&&c,!s&&!c&&!!p,function(){return
w._substrateSuggestionsDataProvider.instrumentClick(r,u)},i,e,t.isL2(o),this._host,
k,h,n.SiteTitle||"")},e.prototype.buildMessageSuggestion=function(i,r,u,f,e,o,s)
{var w=this,y,a,l,p;if(r.IsDraft)return null;if(!r.WebLink)return
SharedLogHelper.LogError("buildMessageSuggestion",null,new Error("Missing web
link")),null;if(y=r.From&&r.From.EmailAddress?r.From.EmailAddress.Name||
r.From.EmailAddress.Address:null,a=r.Sender&&r.Sender.EmailAddress?
r.Sender.EmailAddress.Name||r.Sender.EmailAddress.Address:null,!y&&!a)return
SharedLogHelper.LogError("buildMessageSuggestion",null,new Error("No valid from or
sender fields present")),null;var v=y||
a,c=r.Subject,b=f=="SSEE",k=null;t.config.enableRichEmailPreview&&a&&(k=this.getPro
filePictureIcon(r.Sender.EmailAddress.Address,this.getPersonIcon(r.Sender.EmailAddr
ess.Name)));var
d="OLE",h=t.createSuggestion(i,HitHighlightingParser.addMarkers(v,s),k,null,d,c||
v,n.InstrumentedItem.createInstrumentedItem(u,d),b?8:12,u,!0),g=b?1:2;return
this.setEmailContextMenuItems(h,r.ItemHexId,r.WebLink,g),h.click=function(){return
w.launchEmail(r.ItemHexId,r.WebLink,g)},h.template=1,h.classNames.push("email","for
ceNoWrapOutsideTopResult","topResultTemplateInGroups"),h.primaryMetadata=HitHighlig
htingParser.addMarkers(c,s),h.secondaryMetadata=HitHighlig
htingParser.addMarkers(r.Preview,s),h.tooltip=v+
(c?"\n"+c:""),h.hc=r.SortOrderSource=="Relevance",h.previewIcon={content:"&#xE715",
type:2,needsAccentColor:!
0},r.HasAttachments&&(h.secondaryIcon={content:"&#xE723",type:2}),r.IsRead||
h.classNames.push("accentColor"),r.DateTimeReceived&&(l=t.toDate(r.DateTimeReceived
),p=t.getTodayTimeString(l),h.dateShort=p?
p:l.toLocaleDateString(),h.dateLong=l.toLocaleString(navigator.language,
{year:"numeric",month:"numeric",day:"numeric"}),h.dateAndTime=l.toLocaleString(navi
gator.language,
{weekday:"long",month:"long",day:"numeric",year:"numeric",hour:"numeric",minute:"nu
meric"})),h.internetMessageId=r.InternetMessageId,h.instrumentPingBack=function()
{return
w._substrateSuggestionsDataProvider.instrumentClick(e,o)},h.narratorText=t.getNarra
torText(h),h.subject=HitHighlightingParser.addMarkers(c,s),h.from=v,h.to=r.DisplayT
o,h.preview=r.Preview,h.hasAttachment=r.HasAttachments,h.importance=r.Importance!
="Normal"?
this._host.getLocString("EmailImportance",r.Importance):"",h},e.prototype.getPerson
Icon=function(n){var f=/[0-9a-zA-Z]/,t,i=n.trim().replace(/\s+/g," ").split("
",2),r,u;return i.length>0&&(r=i[0][0],f.test(r)&&(t=r),i.length==2&&(u=i[1]
[0],t&&f.test(u)?t+=u:t="")),{type:t?5:2,content:t?
t.toUpperCase():"&#xE77B",className:"peopleIcon"}},e.prototype.getProfilePictureTok
en=function(n)
{this._accessTokenManager.getAccount(this._authType,this._authType==1?"https://outl
ook.office.com/":"https://outlook.office.com/User.ReadWrite",!1,!0,function(t)
{return n(t?
t.Token:null)},t.getAuthAccountForCloudContent())},e.prototype.getProfilePictureIco
n=function(n,i){var r=this;return
t.Promise.safeChainWithGlobalCaching("getProfilePictureIcon",function(){return
ThresholdUtilities.createPromise(function(i){return
r.getProfilePictureToken(function(u){var f,e,o;if(!u)
{i(null);return}f=SearchAppWrapper.CortanaApp.createStringMap();e=SearchAppWrapper.
CortanaApp.createStringMap();f.Authorization="Bearer "+u;r._authType==0&&(f["X-
AnchorMailbox"]=n);o=r._authType==1?"https://substrate.office.com/api/v2.0/Users('"
+n+"')/photo/$value":"https://substrate.office.com/profile/v0/users/"+n+"/image/
$value";t.Promise.safeChain("getProfilePictureIcon",function(){return
SearchAppWrapper.CortanaApp.makeHttpRequestAsync(0,o,f,"",e)},function(n)
{if(n.statusCode!==200)
{i(null);return}t.Promise.safeChain("getProfilePictureIcon",function(){return
n.readAsStreamAsync()},i,function(){return i(null)})},function(){return
i(null)})})})},function(){return n+"_icon"},function(n){var
r=t.toIcon(n,"getProfilePictureIcon",i);return
r.className="peopleIcon",r},i)},e.prototype.setEmailContextMenuItems=function(n,i,r
,u){var e=this;i&&t.setExtraVerbsAsync(n,function(){var n=[];return
ThresholdUtilities.createPromise(function(o)
{t.LocalDataProvider.getApps(f,function(f){var a=!t.Map.isEmpty(f);if(a){var
h=e.getOutlookLaunchPreference(u),c="Outlook",l,s=Object.keys(f);s.length==1&&(c=f[
s[0]].deviceItem.displayName,l=f[s[0]].getIcon);n.push({verb:"OpenInOutlookWeb",dis
playName:e._host.getLocString("OpenIn","Outlook Web"),executeSync:function(){return
e.launchOutlookWeb(r,u)},isDefault:h==0,icon:
{content:"&#xE774",type:1}});n.push({verb:"LaunchOutlookNative",displayName:e._host
.getLocString("OpenIn",c),executeSync:function(){return
e.launchOutlokNative(i,u)},isDefault:h==1,getIcon:l})}o(n)})})},!
0)},e.prototype.launchOutlookWeb=function(n,t,i){var
r=this;this._host.launchUri(n,!1,function(){return
r.setOutlookLaunchPreference(0,t)},i)},e.prototype.launchOutlokNative=function(n,t,
i){var r=this;this._host.launchOutlook(n,function(){return
r.setOutlookLaunchPreference(1,t)},i)},e.prototype.launchEmail=function(t,i,f)
{for(var
c,e,s,l=this,v=this.getOutlookLaunchPreference(f),o=[v],h=0,a=r;h<a.length;h+
+)c=a[h],n.contains(o,c)||o.push(c);for(s=o.length-1;s>=0;s--)switch(o[s]){case
1:e=u(function(n){return l.launchOutlokNative(t,f,n)},e);break;case
0:e=u(function(n){return
l.launchOutlookWeb(i,f,n)},e)}e()},e.prototype.getOutlookLaunchPreference=function(
n){if(!this._outlookLaunchPreference[n]){var
t=parseInt(this._lightweightStorage.getItem(i+n));this._outlookLaunchPreference[n]=
isNaN(t)?r[0]:t}return
this._outlookLaunchPreference[n]},e.prototype.setOutlookLaunchPreference=function(n
,t)
{this._outlookLaunchPreference[t]=n;this._lightweightStorage.setItem(i+t,n.toString
())},e}();t.SubstrateSearchParser=e})(t=n.WSB||(n.WSB={}))}(AutoSuggest||
(AutoSuggest={}));1

You might also like